diff --git a/internal/ui_dist/assets/index-Bp9xkpyC.js b/internal/ui_dist/assets/index-Bp9xkpyC.js new file mode 100644 index 0000000..d8bfd56 --- /dev/null +++ b/internal/ui_dist/assets/index-Bp9xkpyC.js @@ -0,0 +1,1355 @@ +(function(){const n=document.createElement("link").relList;if(n&&n.supports&&n.supports("modulepreload"))return;for(const o of document.querySelectorAll('link[rel="modulepreload"]'))a(o);new MutationObserver(o=>{for(const l of o)if(l.type==="childList")for(const c of l.addedNodes)c.tagName==="LINK"&&c.rel==="modulepreload"&&a(c)}).observe(document,{childList:!0,subtree:!0});function r(o){const l={};return o.integrity&&(l.integrity=o.integrity),o.referrerPolicy&&(l.referrerPolicy=o.referrerPolicy),o.crossOrigin==="use-credentials"?l.credentials="include":o.crossOrigin==="anonymous"?l.credentials="omit":l.credentials="same-origin",l}function a(o){if(o.ep)return;o.ep=!0;const l=r(o);fetch(o.href,l)}})();var Lc=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function eb(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var jp={exports:{}},ys={};var zw;function Lz(){if(zw)return ys;zw=1;var e=Symbol.for("react.transitional.element"),n=Symbol.for("react.fragment");function r(a,o,l){var c=null;if(l!==void 0&&(c=""+l),o.key!==void 0&&(c=""+o.key),"key"in o){l={};for(var d in o)d!=="key"&&(l[d]=o[d])}else l=o;return o=l.ref,{$$typeof:e,type:a,key:c,ref:o!==void 0?o:null,props:l}}return ys.Fragment=n,ys.jsx=r,ys.jsxs=r,ys}var Nw;function Bz(){return Nw||(Nw=1,jp.exports=Lz()),jp.exports}var u=Bz(),Tp={exports:{}},Te={};var Mw;function Hz(){if(Mw)return Te;Mw=1;var e=Symbol.for("react.transitional.element"),n=Symbol.for("react.portal"),r=Symbol.for("react.fragment"),a=Symbol.for("react.strict_mode"),o=Symbol.for("react.profiler"),l=Symbol.for("react.consumer"),c=Symbol.for("react.context"),d=Symbol.for("react.forward_ref"),p=Symbol.for("react.suspense"),h=Symbol.for("react.memo"),g=Symbol.for("react.lazy"),y=Symbol.for("react.activity"),m=Symbol.iterator;function b(V){return V===null||typeof V!="object"?null:(V=m&&V[m]||V["@@iterator"],typeof V=="function"?V:null)}var S={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},w=Object.assign,C={};function _(V,W,ee){this.props=V,this.context=W,this.refs=C,this.updater=ee||S}_.prototype.isReactComponent={},_.prototype.setState=function(V,W){if(typeof V!="object"&&typeof V!="function"&&V!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,V,W,"setState")},_.prototype.forceUpdate=function(V){this.updater.enqueueForceUpdate(this,V,"forceUpdate")};function j(){}j.prototype=_.prototype;function k(V,W,ee){this.props=V,this.context=W,this.refs=C,this.updater=ee||S}var T=k.prototype=new j;T.constructor=k,w(T,_.prototype),T.isPureReactComponent=!0;var E=Array.isArray;function z(){}var A={H:null,A:null,T:null,S:null},M=Object.prototype.hasOwnProperty;function O(V,W,ee){var G=ee.ref;return{$$typeof:e,type:V,key:W,ref:G!==void 0?G:null,props:ee}}function P(V,W){return O(V.type,W,V.props)}function L(V){return typeof V=="object"&&V!==null&&V.$$typeof===e}function I(V){var W={"=":"=0",":":"=2"};return"$"+V.replace(/[=:]/g,function(ee){return W[ee]})}var F=/\/+/g;function U(V,W){return typeof V=="object"&&V!==null&&V.key!=null?I(""+V.key):W.toString(36)}function B(V){switch(V.status){case"fulfilled":return V.value;case"rejected":throw V.reason;default:switch(typeof V.status=="string"?V.then(z,z):(V.status="pending",V.then(function(W){V.status==="pending"&&(V.status="fulfilled",V.value=W)},function(W){V.status==="pending"&&(V.status="rejected",V.reason=W)})),V.status){case"fulfilled":return V.value;case"rejected":throw V.reason}}throw V}function D(V,W,ee,G,X){var Q=typeof V;(Q==="undefined"||Q==="boolean")&&(V=null);var ie=!1;if(V===null)ie=!0;else switch(Q){case"bigint":case"string":case"number":ie=!0;break;case"object":switch(V.$$typeof){case e:case n:ie=!0;break;case g:return ie=V._init,D(ie(V._payload),W,ee,G,X)}}if(ie)return X=X(V),ie=G===""?"."+U(V,0):G,E(X)?(ee="",ie!=null&&(ee=ie.replace(F,"$&/")+"/"),D(X,W,ee,"",function(ye){return ye})):X!=null&&(L(X)&&(X=P(X,ee+(X.key==null||V&&V.key===X.key?"":(""+X.key).replace(F,"$&/")+"/")+ie)),W.push(X)),1;ie=0;var se=G===""?".":G+":";if(E(V))for(var he=0;he>>1,ne=D[K];if(0>>1;Ko(ee,$))Go(X,ee)?(D[K]=X,D[G]=$,K=G):(D[K]=ee,D[W]=$,K=W);else if(Go(X,$))D[K]=X,D[G]=$,K=G;else break e}}return q}function o(D,q){var $=D.sortIndex-q.sortIndex;return $!==0?$:D.id-q.id}if(e.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var l=performance;e.unstable_now=function(){return l.now()}}else{var c=Date,d=c.now();e.unstable_now=function(){return c.now()-d}}var p=[],h=[],g=1,y=null,m=3,b=!1,S=!1,w=!1,C=!1,_=typeof setTimeout=="function"?setTimeout:null,j=typeof clearTimeout=="function"?clearTimeout:null,k=typeof setImmediate<"u"?setImmediate:null;function T(D){for(var q=r(h);q!==null;){if(q.callback===null)a(h);else if(q.startTime<=D)a(h),q.sortIndex=q.expirationTime,n(p,q);else break;q=r(h)}}function E(D){if(w=!1,T(D),!S)if(r(p)!==null)S=!0,z||(z=!0,I());else{var q=r(h);q!==null&&B(E,q.startTime-D)}}var z=!1,A=-1,M=5,O=-1;function P(){return C?!0:!(e.unstable_now()-OD&&P());){var K=y.callback;if(typeof K=="function"){y.callback=null,m=y.priorityLevel;var ne=K(y.expirationTime<=D);if(D=e.unstable_now(),typeof ne=="function"){y.callback=ne,T(D),q=!0;break t}y===r(p)&&a(p),T(D)}else a(p);y=r(p)}if(y!==null)q=!0;else{var V=r(h);V!==null&&B(E,V.startTime-D),q=!1}}break e}finally{y=null,m=$,b=!1}q=void 0}}finally{q?I():z=!1}}}var I;if(typeof k=="function")I=function(){k(L)};else if(typeof MessageChannel<"u"){var F=new MessageChannel,U=F.port2;F.port1.onmessage=L,I=function(){U.postMessage(null)}}else I=function(){_(L,0)};function B(D,q){A=_(function(){D(e.unstable_now())},q)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(D){D.callback=null},e.unstable_forceFrameRate=function(D){0>D||125K?(D.sortIndex=$,n(h,D),r(p)===null&&D===r(h)&&(w?(j(A),A=-1):w=!0,B(E,$-K))):(D.sortIndex=ne,n(p,D),S||b||(S=!0,z||(z=!0,I()))),D},e.unstable_shouldYield=P,e.unstable_wrapCallback=function(D){var q=m;return function(){var $=m;m=q;try{return D.apply(this,arguments)}finally{m=$}}}})(zp)),zp}var qw;function Fz(){return qw||(qw=1,Rp.exports=Uz()),Rp.exports}var Np={exports:{}},Lt={};var Iw;function Pz(){if(Iw)return Lt;Iw=1;var e=el();function n(p){var h="https://react.dev/errors/"+p;if(1"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(n){console.error(n)}}return e(),Np.exports=Pz(),Np.exports}var Bw;function $z(){if(Bw)return ms;Bw=1;var e=Fz(),n=el(),r=RT();function a(t){var i="https://react.dev/errors/"+t;if(1ne||(t.current=K[ne],K[ne]=null,ne--)}function ee(t,i){ne++,K[ne]=t.current,t.current=i}var G=V(null),X=V(null),Q=V(null),ie=V(null);function se(t,i){switch(ee(Q,i),ee(X,t),ee(G,null),i.nodeType){case 9:case 11:t=(t=i.documentElement)&&(t=t.namespaceURI)?ew(t):0;break;default:if(t=i.tagName,i=i.namespaceURI)i=ew(i),t=tw(i,t);else switch(t){case"svg":t=1;break;case"math":t=2;break;default:t=0}}W(G),ee(G,t)}function he(){W(G),W(X),W(Q)}function ye(t){t.memoizedState!==null&&ee(ie,t);var i=G.current,s=tw(i,t.type);i!==s&&(ee(X,t),ee(G,s))}function be(t){X.current===t&&(W(G),W(X)),ie.current===t&&(W(ie),fs._currentValue=$)}var we,xe;function ke(t){if(we===void 0)try{throw Error()}catch(s){var i=s.stack.trim().match(/\n( *(at )?)/);we=i&&i[1]||"",xe=-1)":-1v||Y[f]!==re[v]){var ce=` +`+Y[f].replace(" at new "," at ");return t.displayName&&ce.includes("")&&(ce=ce.replace("",t.displayName)),ce}while(1<=f&&0<=v);break}}}finally{ae=!1,Error.prepareStackTrace=s}return(s=t?t.displayName||t.name:"")?ke(s):""}function ge(t,i){switch(t.tag){case 26:case 27:case 5:return ke(t.type);case 16:return ke("Lazy");case 13:return t.child!==i&&i!==null?ke("Suspense Fallback"):ke("Suspense");case 19:return ke("SuspenseList");case 0:case 15:return pe(t.type,!1);case 11:return pe(t.type.render,!1);case 1:return pe(t.type,!0);case 31:return ke("Activity");default:return""}}function je(t){try{var i="",s=null;do i+=ge(t,s),s=t,t=t.return;while(t);return i}catch(f){return` +Error generating stack: `+f.message+` +`+f.stack}}var Ae=Object.prototype.hasOwnProperty,ze=e.unstable_scheduleCallback,Ne=e.unstable_cancelCallback,We=e.unstable_shouldYield,He=e.unstable_requestPaint,Ge=e.unstable_now,Dt=e.unstable_getCurrentPriorityLevel,Pt=e.unstable_ImmediatePriority,Qe=e.unstable_UserBlockingPriority,Ct=e.unstable_NormalPriority,ta=e.unstable_LowPriority,Zn=e.unstable_IdlePriority,wo=e.log,na=e.unstable_setDisableYieldValue,qt=null,at=null;function qn(t){if(typeof wo=="function"&&na(t),at&&typeof at.setStrictMode=="function")try{at.setStrictMode(qt,t)}catch{}}var Ht=Math.clz32?Math.clz32:hd,fd=Math.log,pd=Math.LN2;function hd(t){return t>>>=0,t===0?32:31-(fd(t)/pd|0)|0}var ra=256,ia=262144,aa=4194304;function Qn(t){var i=t&42;if(i!==0)return i;switch(t&-t){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return t&261888;case 262144:case 524288:case 1048576:case 2097152:return t&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return t&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return t}}function oa(t,i,s){var f=t.pendingLanes;if(f===0)return 0;var v=0,x=t.suspendedLanes,R=t.pingedLanes;t=t.warmLanes;var H=f&134217727;return H!==0?(f=H&~x,f!==0?v=Qn(f):(R&=H,R!==0?v=Qn(R):s||(s=H&~t,s!==0&&(v=Qn(s))))):(H=f&~x,H!==0?v=Qn(H):R!==0?v=Qn(R):s||(s=f&~t,s!==0&&(v=Qn(s)))),v===0?0:i!==0&&i!==v&&(i&x)===0&&(x=v&-v,s=i&-i,x>=s||x===32&&(s&4194048)!==0)?i:v}function hi(t,i){return(t.pendingLanes&~(t.suspendedLanes&~t.pingedLanes)&i)===0}function gd(t,i){switch(t){case 1:case 2:case 4:case 8:case 64:return i+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return i+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function gl(){var t=aa;return aa<<=1,(aa&62914560)===0&&(aa=4194304),t}function _o(t){for(var i=[],s=0;31>s;s++)i.push(t);return i}function gi(t,i){t.pendingLanes|=i,i!==268435456&&(t.suspendedLanes=0,t.pingedLanes=0,t.warmLanes=0)}function yd(t,i,s,f,v,x){var R=t.pendingLanes;t.pendingLanes=s,t.suspendedLanes=0,t.pingedLanes=0,t.warmLanes=0,t.expiredLanes&=s,t.entangledLanes&=s,t.errorRecoveryDisabledLanes&=s,t.shellSuspendCounter=0;var H=t.entanglements,Y=t.expirationTimes,re=t.hiddenUpdates;for(s=R&~s;0"u")return null;try{return t.activeElement||t.body}catch{return t.body}}var Sd=/[\n"\\]/g;function Vt(t){return t.replace(Sd,function(i){return"\\"+i.charCodeAt(0).toString(16)+" "})}function vi(t,i,s,f,v,x,R,H){t.name="",R!=null&&typeof R!="function"&&typeof R!="symbol"&&typeof R!="boolean"?t.type=R:t.removeAttribute("type"),i!=null?R==="number"?(i===0&&t.value===""||t.value!=i)&&(t.value=""+$t(i)):t.value!==""+$t(i)&&(t.value=""+$t(i)):R!=="submit"&&R!=="reset"||t.removeAttribute("value"),i!=null?To(t,R,$t(i)):s!=null?To(t,R,$t(s)):f!=null&&t.removeAttribute("value"),v==null&&x!=null&&(t.defaultChecked=!!x),v!=null&&(t.checked=v&&typeof v!="function"&&typeof v!="symbol"),H!=null&&typeof H!="function"&&typeof H!="symbol"&&typeof H!="boolean"?t.name=""+$t(H):t.removeAttribute("name")}function Tl(t,i,s,f,v,x,R,H){if(x!=null&&typeof x!="function"&&typeof x!="symbol"&&typeof x!="boolean"&&(t.type=x),i!=null||s!=null){if(!(x!=="submit"&&x!=="reset"||i!=null)){ua(t);return}s=s!=null?""+$t(s):"",i=i!=null?""+$t(i):s,H||i===t.value||(t.value=i),t.defaultValue=i}f=f??v,f=typeof f!="function"&&typeof f!="symbol"&&!!f,t.checked=H?t.checked:!!f,t.defaultChecked=!!f,R!=null&&typeof R!="function"&&typeof R!="symbol"&&typeof R!="boolean"&&(t.name=R),ua(t)}function To(t,i,s){i==="number"&&mi(t.ownerDocument)===t||t.defaultValue===""+s||(t.defaultValue=""+s)}function tr(t,i,s,f){if(t=t.options,i){i={};for(var v=0;v"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Ed=!1;if(rr)try{var Ro={};Object.defineProperty(Ro,"passive",{get:function(){Ed=!0}}),window.addEventListener("test",Ro,Ro),window.removeEventListener("test",Ro,Ro)}catch{Ed=!1}var Dr=null,jd=null,Rl=null;function tx(){if(Rl)return Rl;var t,i=jd,s=i.length,f,v="value"in Dr?Dr.value:Dr.textContent,x=v.length;for(t=0;t=Mo),sx=" ",lx=!1;function cx(t,i){switch(t){case"keyup":return oR.indexOf(i.keyCode)!==-1;case"keydown":return i.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function ux(t){return t=t.detail,typeof t=="object"&&"data"in t?t.data:null}var ha=!1;function lR(t,i){switch(t){case"compositionend":return ux(i);case"keypress":return i.which!==32?null:(lx=!0,sx);case"textInput":return t=i.data,t===sx&&lx?null:t;default:return null}}function cR(t,i){if(ha)return t==="compositionend"||!Nd&&cx(t,i)?(t=tx(),Rl=jd=Dr=null,ha=!1,t):null;switch(t){case"paste":return null;case"keypress":if(!(i.ctrlKey||i.altKey||i.metaKey)||i.ctrlKey&&i.altKey){if(i.char&&1=i)return{node:s,offset:i-t};t=f}e:{for(;s;){if(s.nextSibling){s=s.nextSibling;break e}s=s.parentNode}s=void 0}s=vx(s)}}function xx(t,i){return t&&i?t===i?!0:t&&t.nodeType===3?!1:i&&i.nodeType===3?xx(t,i.parentNode):"contains"in t?t.contains(i):t.compareDocumentPosition?!!(t.compareDocumentPosition(i)&16):!1:!1}function Sx(t){t=t!=null&&t.ownerDocument!=null&&t.ownerDocument.defaultView!=null?t.ownerDocument.defaultView:window;for(var i=mi(t.document);i instanceof t.HTMLIFrameElement;){try{var s=typeof i.contentWindow.location.href=="string"}catch{s=!1}if(s)t=i.contentWindow;else break;i=mi(t.document)}return i}function Dd(t){var i=t&&t.nodeName&&t.nodeName.toLowerCase();return i&&(i==="input"&&(t.type==="text"||t.type==="search"||t.type==="tel"||t.type==="url"||t.type==="password")||i==="textarea"||t.contentEditable==="true")}var mR=rr&&"documentMode"in document&&11>=document.documentMode,ga=null,qd=null,Io=null,Id=!1;function wx(t,i,s){var f=s.window===s?s.document:s.nodeType===9?s:s.ownerDocument;Id||ga==null||ga!==mi(f)||(f=ga,"selectionStart"in f&&Dd(f)?f={start:f.selectionStart,end:f.selectionEnd}:(f=(f.ownerDocument&&f.ownerDocument.defaultView||window).getSelection(),f={anchorNode:f.anchorNode,anchorOffset:f.anchorOffset,focusNode:f.focusNode,focusOffset:f.focusOffset}),Io&&qo(Io,f)||(Io=f,f=_c(qd,"onSelect"),0>=R,v-=R,Ln=1<<32-Ht(i)+v|s<Me?(Ie=Se,Se=null):Ie=Se.sibling;var Fe=oe(J,Se,te[Me],de);if(Fe===null){Se===null&&(Se=Ie);break}t&&Se&&Fe.alternate===null&&i(J,Se),Z=x(Fe,Z,Me),Ue===null?Ce=Fe:Ue.sibling=Fe,Ue=Fe,Se=Ie}if(Me===te.length)return s(J,Se),Le&&ar(J,Me),Ce;if(Se===null){for(;MeMe?(Ie=Se,Se=null):Ie=Se.sibling;var ri=oe(J,Se,Fe.value,de);if(ri===null){Se===null&&(Se=Ie);break}t&&Se&&ri.alternate===null&&i(J,Se),Z=x(ri,Z,Me),Ue===null?Ce=ri:Ue.sibling=ri,Ue=ri,Se=Ie}if(Fe.done)return s(J,Se),Le&&ar(J,Me),Ce;if(Se===null){for(;!Fe.done;Me++,Fe=te.next())Fe=fe(J,Fe.value,de),Fe!==null&&(Z=x(Fe,Z,Me),Ue===null?Ce=Fe:Ue.sibling=Fe,Ue=Fe);return Le&&ar(J,Me),Ce}for(Se=f(Se);!Fe.done;Me++,Fe=te.next())Fe=le(Se,J,Me,Fe.value,de),Fe!==null&&(t&&Fe.alternate!==null&&Se.delete(Fe.key===null?Me:Fe.key),Z=x(Fe,Z,Me),Ue===null?Ce=Fe:Ue.sibling=Fe,Ue=Fe);return t&&Se.forEach(function(Iz){return i(J,Iz)}),Le&&ar(J,Me),Ce}function Ke(J,Z,te,de){if(typeof te=="object"&&te!==null&&te.type===w&&te.key===null&&(te=te.props.children),typeof te=="object"&&te!==null){switch(te.$$typeof){case b:e:{for(var Ce=te.key;Z!==null;){if(Z.key===Ce){if(Ce=te.type,Ce===w){if(Z.tag===7){s(J,Z.sibling),de=v(Z,te.props.children),de.return=J,J=de;break e}}else if(Z.elementType===Ce||typeof Ce=="object"&&Ce!==null&&Ce.$$typeof===M&&Ti(Ce)===Z.type){s(J,Z.sibling),de=v(Z,te.props),Po(de,te),de.return=J,J=de;break e}s(J,Z);break}else i(J,Z);Z=Z.sibling}te.type===w?(de=_i(te.props.children,J.mode,de,te.key),de.return=J,J=de):(de=Hl(te.type,te.key,te.props,null,J.mode,de),Po(de,te),de.return=J,J=de)}return R(J);case S:e:{for(Ce=te.key;Z!==null;){if(Z.key===Ce)if(Z.tag===4&&Z.stateNode.containerInfo===te.containerInfo&&Z.stateNode.implementation===te.implementation){s(J,Z.sibling),de=v(Z,te.children||[]),de.return=J,J=de;break e}else{s(J,Z);break}else i(J,Z);Z=Z.sibling}de=$d(te,J.mode,de),de.return=J,J=de}return R(J);case M:return te=Ti(te),Ke(J,Z,te,de)}if(B(te))return ve(J,Z,te,de);if(I(te)){if(Ce=I(te),typeof Ce!="function")throw Error(a(150));return te=Ce.call(te),Ee(J,Z,te,de)}if(typeof te.then=="function")return Ke(J,Z,Gl(te),de);if(te.$$typeof===k)return Ke(J,Z,Pl(J,te),de);Yl(J,te)}return typeof te=="string"&&te!==""||typeof te=="number"||typeof te=="bigint"?(te=""+te,Z!==null&&Z.tag===6?(s(J,Z.sibling),de=v(Z,te),de.return=J,J=de):(s(J,Z),de=Pd(te,J.mode,de),de.return=J,J=de),R(J)):s(J,Z)}return function(J,Z,te,de){try{Fo=0;var Ce=Ke(J,Z,te,de);return Ea=null,Ce}catch(Se){if(Se===Ca||Se===Vl)throw Se;var Ue=rn(29,Se,null,J.mode);return Ue.lanes=de,Ue.return=J,Ue}}}var Ri=Vx(!0),Wx=Vx(!1),Hr=!1;function nf(t){t.updateQueue={baseState:t.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function rf(t,i){t=t.updateQueue,i.updateQueue===t&&(i.updateQueue={baseState:t.baseState,firstBaseUpdate:t.firstBaseUpdate,lastBaseUpdate:t.lastBaseUpdate,shared:t.shared,callbacks:null})}function Ur(t){return{lane:t,tag:0,payload:null,callback:null,next:null}}function Fr(t,i,s){var f=t.updateQueue;if(f===null)return null;if(f=f.shared,(Pe&2)!==0){var v=f.pending;return v===null?i.next=i:(i.next=v.next,v.next=i),f.pending=i,i=Bl(t),Ax(t,null,s),i}return Ll(t,f,i,s),Bl(t)}function $o(t,i,s){if(i=i.updateQueue,i!==null&&(i=i.shared,(s&4194048)!==0)){var f=i.lanes;f&=t.pendingLanes,s|=f,i.lanes=s,ml(t,s)}}function af(t,i){var s=t.updateQueue,f=t.alternate;if(f!==null&&(f=f.updateQueue,s===f)){var v=null,x=null;if(s=s.firstBaseUpdate,s!==null){do{var R={lane:s.lane,tag:s.tag,payload:s.payload,callback:null,next:null};x===null?v=x=R:x=x.next=R,s=s.next}while(s!==null);x===null?v=x=i:x=x.next=i}else v=x=i;s={baseState:f.baseState,firstBaseUpdate:v,lastBaseUpdate:x,shared:f.shared,callbacks:f.callbacks},t.updateQueue=s;return}t=s.lastBaseUpdate,t===null?s.firstBaseUpdate=i:t.next=i,s.lastBaseUpdate=i}var of=!1;function Vo(){if(of){var t=ka;if(t!==null)throw t}}function Wo(t,i,s,f){of=!1;var v=t.updateQueue;Hr=!1;var x=v.firstBaseUpdate,R=v.lastBaseUpdate,H=v.shared.pending;if(H!==null){v.shared.pending=null;var Y=H,re=Y.next;Y.next=null,R===null?x=re:R.next=re,R=Y;var ce=t.alternate;ce!==null&&(ce=ce.updateQueue,H=ce.lastBaseUpdate,H!==R&&(H===null?ce.firstBaseUpdate=re:H.next=re,ce.lastBaseUpdate=Y))}if(x!==null){var fe=v.baseState;R=0,ce=re=Y=null,H=x;do{var oe=H.lane&-536870913,le=oe!==H.lane;if(le?(qe&oe)===oe:(f&oe)===oe){oe!==0&&oe===_a&&(of=!0),ce!==null&&(ce=ce.next={lane:0,tag:H.tag,payload:H.payload,callback:null,next:null});e:{var ve=t,Ee=H;oe=i;var Ke=s;switch(Ee.tag){case 1:if(ve=Ee.payload,typeof ve=="function"){fe=ve.call(Ke,fe,oe);break e}fe=ve;break e;case 3:ve.flags=ve.flags&-65537|128;case 0:if(ve=Ee.payload,oe=typeof ve=="function"?ve.call(Ke,fe,oe):ve,oe==null)break e;fe=y({},fe,oe);break e;case 2:Hr=!0}}oe=H.callback,oe!==null&&(t.flags|=64,le&&(t.flags|=8192),le=v.callbacks,le===null?v.callbacks=[oe]:le.push(oe))}else le={lane:oe,tag:H.tag,payload:H.payload,callback:H.callback,next:null},ce===null?(re=ce=le,Y=fe):ce=ce.next=le,R|=oe;if(H=H.next,H===null){if(H=v.shared.pending,H===null)break;le=H,H=le.next,le.next=null,v.lastBaseUpdate=le,v.shared.pending=null}}while(!0);ce===null&&(Y=fe),v.baseState=Y,v.firstBaseUpdate=re,v.lastBaseUpdate=ce,x===null&&(v.shared.lanes=0),Gr|=R,t.lanes=R,t.memoizedState=fe}}function Gx(t,i){if(typeof t!="function")throw Error(a(191,t));t.call(i)}function Yx(t,i){var s=t.callbacks;if(s!==null)for(t.callbacks=null,t=0;tx?x:8;var R=D.T,H={};D.T=H,Cf(t,!1,i,s);try{var Y=v(),re=D.S;if(re!==null&&re(H,Y),Y!==null&&typeof Y=="object"&&typeof Y.then=="function"){var ce=ER(Y,f);Xo(t,i,ce,cn(t))}else Xo(t,i,f,cn(t))}catch(fe){Xo(t,i,{then:function(){},status:"rejected",reason:fe},cn())}finally{q.p=x,R!==null&&H.types!==null&&(R.types=H.types),D.T=R}}function NR(){}function _f(t,i,s,f){if(t.tag!==5)throw Error(a(476));var v=E1(t).queue;C1(t,v,i,$,s===null?NR:function(){return j1(t),s(f)})}function E1(t){var i=t.memoizedState;if(i!==null)return i;i={memoizedState:$,baseState:$,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:cr,lastRenderedState:$},next:null};var s={};return i.next={memoizedState:s,baseState:s,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:cr,lastRenderedState:s},next:null},t.memoizedState=i,t=t.alternate,t!==null&&(t.memoizedState=i),i}function j1(t){var i=E1(t);i.next===null&&(i=t.alternate.memoizedState),Xo(t,i.next.queue,{},cn())}function kf(){return Rt(fs)}function T1(){return ct().memoizedState}function A1(){return ct().memoizedState}function MR(t){for(var i=t.return;i!==null;){switch(i.tag){case 24:case 3:var s=cn();t=Ur(s);var f=Fr(i,t,s);f!==null&&(Zt(f,i,s),$o(f,i,s)),i={cache:Qd()},t.payload=i;return}i=i.return}}function OR(t,i,s){var f=cn();s={lane:f,revertLane:0,gesture:null,action:s,hasEagerState:!1,eagerState:null,next:null},ic(t)?z1(i,s):(s=Ud(t,i,s,f),s!==null&&(Zt(s,t,f),N1(s,i,f)))}function R1(t,i,s){var f=cn();Xo(t,i,s,f)}function Xo(t,i,s,f){var v={lane:f,revertLane:0,gesture:null,action:s,hasEagerState:!1,eagerState:null,next:null};if(ic(t))z1(i,v);else{var x=t.alternate;if(t.lanes===0&&(x===null||x.lanes===0)&&(x=i.lastRenderedReducer,x!==null))try{var R=i.lastRenderedState,H=x(R,s);if(v.hasEagerState=!0,v.eagerState=H,nn(H,R))return Ll(t,i,v,0),Ze===null&&Il(),!1}catch{}if(s=Ud(t,i,v,f),s!==null)return Zt(s,t,f),N1(s,i,f),!0}return!1}function Cf(t,i,s,f){if(f={lane:2,revertLane:rp(),gesture:null,action:f,hasEagerState:!1,eagerState:null,next:null},ic(t)){if(i)throw Error(a(479))}else i=Ud(t,s,f,2),i!==null&&Zt(i,t,2)}function ic(t){var i=t.alternate;return t===Re||i!==null&&i===Re}function z1(t,i){Ta=Zl=!0;var s=t.pending;s===null?i.next=i:(i.next=s.next,s.next=i),t.pending=i}function N1(t,i,s){if((s&4194048)!==0){var f=i.lanes;f&=t.pendingLanes,s|=f,i.lanes=s,ml(t,s)}}var Ko={readContext:Rt,use:ec,useCallback:ot,useContext:ot,useEffect:ot,useImperativeHandle:ot,useLayoutEffect:ot,useInsertionEffect:ot,useMemo:ot,useReducer:ot,useRef:ot,useState:ot,useDebugValue:ot,useDeferredValue:ot,useTransition:ot,useSyncExternalStore:ot,useId:ot,useHostTransitionStatus:ot,useFormState:ot,useActionState:ot,useOptimistic:ot,useMemoCache:ot,useCacheRefresh:ot};Ko.useEffectEvent=ot;var M1={readContext:Rt,use:ec,useCallback:function(t,i){return Ut().memoizedState=[t,i===void 0?null:i],t},useContext:Rt,useEffect:y1,useImperativeHandle:function(t,i,s){s=s!=null?s.concat([t]):null,nc(4194308,4,x1.bind(null,i,t),s)},useLayoutEffect:function(t,i){return nc(4194308,4,t,i)},useInsertionEffect:function(t,i){nc(4,2,t,i)},useMemo:function(t,i){var s=Ut();i=i===void 0?null:i;var f=t();if(zi){qn(!0);try{t()}finally{qn(!1)}}return s.memoizedState=[f,i],f},useReducer:function(t,i,s){var f=Ut();if(s!==void 0){var v=s(i);if(zi){qn(!0);try{s(i)}finally{qn(!1)}}}else v=i;return f.memoizedState=f.baseState=v,t={pending:null,lanes:0,dispatch:null,lastRenderedReducer:t,lastRenderedState:v},f.queue=t,t=t.dispatch=OR.bind(null,Re,t),[f.memoizedState,t]},useRef:function(t){var i=Ut();return t={current:t},i.memoizedState=t},useState:function(t){t=vf(t);var i=t.queue,s=R1.bind(null,Re,i);return i.dispatch=s,[t.memoizedState,s]},useDebugValue:Sf,useDeferredValue:function(t,i){var s=Ut();return wf(s,t,i)},useTransition:function(){var t=vf(!1);return t=C1.bind(null,Re,t.queue,!0,!1),Ut().memoizedState=t,[!1,t]},useSyncExternalStore:function(t,i,s){var f=Re,v=Ut();if(Le){if(s===void 0)throw Error(a(407));s=s()}else{if(s=i(),Ze===null)throw Error(a(349));(qe&127)!==0||e1(f,i,s)}v.memoizedState=s;var x={value:s,getSnapshot:i};return v.queue=x,y1(n1.bind(null,f,x,t),[t]),f.flags|=2048,Ra(9,{destroy:void 0},t1.bind(null,f,x,s,i),null),s},useId:function(){var t=Ut(),i=Ze.identifierPrefix;if(Le){var s=Bn,f=Ln;s=(f&~(1<<32-Ht(f)-1)).toString(32)+s,i="_"+i+"R_"+s,s=Ql++,0<\/script>",x=x.removeChild(x.firstChild);break;case"select":x=typeof f.is=="string"?R.createElement("select",{is:f.is}):R.createElement("select"),f.multiple?x.multiple=!0:f.size&&(x.size=f.size);break;default:x=typeof f.is=="string"?R.createElement(v,{is:f.is}):R.createElement(v)}}x[wt]=i,x[It]=f;e:for(R=i.child;R!==null;){if(R.tag===5||R.tag===6)x.appendChild(R.stateNode);else if(R.tag!==4&&R.tag!==27&&R.child!==null){R.child.return=R,R=R.child;continue}if(R===i)break e;for(;R.sibling===null;){if(R.return===null||R.return===i)break e;R=R.return}R.sibling.return=R.return,R=R.sibling}i.stateNode=x;e:switch(Nt(x,v,f),v){case"button":case"input":case"select":case"textarea":f=!!f.autoFocus;break e;case"img":f=!0;break e;default:f=!1}f&&dr(i)}}return et(i),Bf(i,i.type,t===null?null:t.memoizedProps,i.pendingProps,s),null;case 6:if(t&&i.stateNode!=null)t.memoizedProps!==f&&dr(i);else{if(typeof f!="string"&&i.stateNode===null)throw Error(a(166));if(t=Q.current,Sa(i)){if(t=i.stateNode,s=i.memoizedProps,f=null,v=At,v!==null)switch(v.tag){case 27:case 5:f=v.memoizedProps}t[wt]=i,t=!!(t.nodeValue===s||f!==null&&f.suppressHydrationWarning===!0||QS(t.nodeValue,s)),t||Lr(i,!0)}else t=kc(t).createTextNode(f),t[wt]=i,i.stateNode=t}return et(i),null;case 31:if(s=i.memoizedState,t===null||t.memoizedState!==null){if(f=Sa(i),s!==null){if(t===null){if(!f)throw Error(a(318));if(t=i.memoizedState,t=t!==null?t.dehydrated:null,!t)throw Error(a(557));t[wt]=i}else ki(),(i.flags&128)===0&&(i.memoizedState=null),i.flags|=4;et(i),t=!1}else s=Yd(),t!==null&&t.memoizedState!==null&&(t.memoizedState.hydrationErrors=s),t=!0;if(!t)return i.flags&256?(on(i),i):(on(i),null);if((i.flags&128)!==0)throw Error(a(558))}return et(i),null;case 13:if(f=i.memoizedState,t===null||t.memoizedState!==null&&t.memoizedState.dehydrated!==null){if(v=Sa(i),f!==null&&f.dehydrated!==null){if(t===null){if(!v)throw Error(a(318));if(v=i.memoizedState,v=v!==null?v.dehydrated:null,!v)throw Error(a(317));v[wt]=i}else ki(),(i.flags&128)===0&&(i.memoizedState=null),i.flags|=4;et(i),v=!1}else v=Yd(),t!==null&&t.memoizedState!==null&&(t.memoizedState.hydrationErrors=v),v=!0;if(!v)return i.flags&256?(on(i),i):(on(i),null)}return on(i),(i.flags&128)!==0?(i.lanes=s,i):(s=f!==null,t=t!==null&&t.memoizedState!==null,s&&(f=i.child,v=null,f.alternate!==null&&f.alternate.memoizedState!==null&&f.alternate.memoizedState.cachePool!==null&&(v=f.alternate.memoizedState.cachePool.pool),x=null,f.memoizedState!==null&&f.memoizedState.cachePool!==null&&(x=f.memoizedState.cachePool.pool),x!==v&&(f.flags|=2048)),s!==t&&s&&(i.child.flags|=8192),cc(i,i.updateQueue),et(i),null);case 4:return he(),t===null&&sp(i.stateNode.containerInfo),et(i),null;case 10:return sr(i.type),et(i),null;case 19:if(W(lt),f=i.memoizedState,f===null)return et(i),null;if(v=(i.flags&128)!==0,x=f.rendering,x===null)if(v)Qo(f,!1);else{if(st!==0||t!==null&&(t.flags&128)!==0)for(t=i.child;t!==null;){if(x=Kl(t),x!==null){for(i.flags|=128,Qo(f,!1),t=x.updateQueue,i.updateQueue=t,cc(i,t),i.subtreeFlags=0,t=s,s=i.child;s!==null;)Rx(s,t),s=s.sibling;return ee(lt,lt.current&1|2),Le&&ar(i,f.treeForkCount),i.child}t=t.sibling}f.tail!==null&&Ge()>hc&&(i.flags|=128,v=!0,Qo(f,!1),i.lanes=4194304)}else{if(!v)if(t=Kl(x),t!==null){if(i.flags|=128,v=!0,t=t.updateQueue,i.updateQueue=t,cc(i,t),Qo(f,!0),f.tail===null&&f.tailMode==="hidden"&&!x.alternate&&!Le)return et(i),null}else 2*Ge()-f.renderingStartTime>hc&&s!==536870912&&(i.flags|=128,v=!0,Qo(f,!1),i.lanes=4194304);f.isBackwards?(x.sibling=i.child,i.child=x):(t=f.last,t!==null?t.sibling=x:i.child=x,f.last=x)}return f.tail!==null?(t=f.tail,f.rendering=t,f.tail=t.sibling,f.renderingStartTime=Ge(),t.sibling=null,s=lt.current,ee(lt,v?s&1|2:s&1),Le&&ar(i,f.treeForkCount),t):(et(i),null);case 22:case 23:return on(i),lf(),f=i.memoizedState!==null,t!==null?t.memoizedState!==null!==f&&(i.flags|=8192):f&&(i.flags|=8192),f?(s&536870912)!==0&&(i.flags&128)===0&&(et(i),i.subtreeFlags&6&&(i.flags|=8192)):et(i),s=i.updateQueue,s!==null&&cc(i,s.retryQueue),s=null,t!==null&&t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(s=t.memoizedState.cachePool.pool),f=null,i.memoizedState!==null&&i.memoizedState.cachePool!==null&&(f=i.memoizedState.cachePool.pool),f!==s&&(i.flags|=2048),t!==null&&W(ji),null;case 24:return s=null,t!==null&&(s=t.memoizedState.cache),i.memoizedState.cache!==s&&(i.flags|=2048),sr(pt),et(i),null;case 25:return null;case 30:return null}throw Error(a(156,i.tag))}function BR(t,i){switch(Wd(i),i.tag){case 1:return t=i.flags,t&65536?(i.flags=t&-65537|128,i):null;case 3:return sr(pt),he(),t=i.flags,(t&65536)!==0&&(t&128)===0?(i.flags=t&-65537|128,i):null;case 26:case 27:case 5:return be(i),null;case 31:if(i.memoizedState!==null){if(on(i),i.alternate===null)throw Error(a(340));ki()}return t=i.flags,t&65536?(i.flags=t&-65537|128,i):null;case 13:if(on(i),t=i.memoizedState,t!==null&&t.dehydrated!==null){if(i.alternate===null)throw Error(a(340));ki()}return t=i.flags,t&65536?(i.flags=t&-65537|128,i):null;case 19:return W(lt),null;case 4:return he(),null;case 10:return sr(i.type),null;case 22:case 23:return on(i),lf(),t!==null&&W(ji),t=i.flags,t&65536?(i.flags=t&-65537|128,i):null;case 24:return sr(pt),null;case 25:return null;default:return null}}function rS(t,i){switch(Wd(i),i.tag){case 3:sr(pt),he();break;case 26:case 27:case 5:be(i);break;case 4:he();break;case 31:i.memoizedState!==null&&on(i);break;case 13:on(i);break;case 19:W(lt);break;case 10:sr(i.type);break;case 22:case 23:on(i),lf(),t!==null&&W(ji);break;case 24:sr(pt)}}function Jo(t,i){try{var s=i.updateQueue,f=s!==null?s.lastEffect:null;if(f!==null){var v=f.next;s=v;do{if((s.tag&t)===t){f=void 0;var x=s.create,R=s.inst;f=x(),R.destroy=f}s=s.next}while(s!==v)}}catch(H){Ve(i,i.return,H)}}function Vr(t,i,s){try{var f=i.updateQueue,v=f!==null?f.lastEffect:null;if(v!==null){var x=v.next;f=x;do{if((f.tag&t)===t){var R=f.inst,H=R.destroy;if(H!==void 0){R.destroy=void 0,v=i;var Y=s,re=H;try{re()}catch(ce){Ve(v,Y,ce)}}}f=f.next}while(f!==x)}}catch(ce){Ve(i,i.return,ce)}}function iS(t){var i=t.updateQueue;if(i!==null){var s=t.stateNode;try{Yx(i,s)}catch(f){Ve(t,t.return,f)}}}function aS(t,i,s){s.props=Ni(t.type,t.memoizedProps),s.state=t.memoizedState;try{s.componentWillUnmount()}catch(f){Ve(t,i,f)}}function es(t,i){try{var s=t.ref;if(s!==null){switch(t.tag){case 26:case 27:case 5:var f=t.stateNode;break;case 30:f=t.stateNode;break;default:f=t.stateNode}typeof s=="function"?t.refCleanup=s(f):s.current=f}}catch(v){Ve(t,i,v)}}function Hn(t,i){var s=t.ref,f=t.refCleanup;if(s!==null)if(typeof f=="function")try{f()}catch(v){Ve(t,i,v)}finally{t.refCleanup=null,t=t.alternate,t!=null&&(t.refCleanup=null)}else if(typeof s=="function")try{s(null)}catch(v){Ve(t,i,v)}else s.current=null}function oS(t){var i=t.type,s=t.memoizedProps,f=t.stateNode;try{e:switch(i){case"button":case"input":case"select":case"textarea":s.autoFocus&&f.focus();break e;case"img":s.src?f.src=s.src:s.srcSet&&(f.srcset=s.srcSet)}}catch(v){Ve(t,t.return,v)}}function Hf(t,i,s){try{var f=t.stateNode;sz(f,t.type,s,i),f[It]=i}catch(v){Ve(t,t.return,v)}}function sS(t){return t.tag===5||t.tag===3||t.tag===26||t.tag===27&&Qr(t.type)||t.tag===4}function Uf(t){e:for(;;){for(;t.sibling===null;){if(t.return===null||sS(t.return))return null;t=t.return}for(t.sibling.return=t.return,t=t.sibling;t.tag!==5&&t.tag!==6&&t.tag!==18;){if(t.tag===27&&Qr(t.type)||t.flags&2||t.child===null||t.tag===4)continue e;t.child.return=t,t=t.child}if(!(t.flags&2))return t.stateNode}}function Ff(t,i,s){var f=t.tag;if(f===5||f===6)t=t.stateNode,i?(s.nodeType===9?s.body:s.nodeName==="HTML"?s.ownerDocument.body:s).insertBefore(t,i):(i=s.nodeType===9?s.body:s.nodeName==="HTML"?s.ownerDocument.body:s,i.appendChild(t),s=s._reactRootContainer,s!=null||i.onclick!==null||(i.onclick=nr));else if(f!==4&&(f===27&&Qr(t.type)&&(s=t.stateNode,i=null),t=t.child,t!==null))for(Ff(t,i,s),t=t.sibling;t!==null;)Ff(t,i,s),t=t.sibling}function uc(t,i,s){var f=t.tag;if(f===5||f===6)t=t.stateNode,i?s.insertBefore(t,i):s.appendChild(t);else if(f!==4&&(f===27&&Qr(t.type)&&(s=t.stateNode),t=t.child,t!==null))for(uc(t,i,s),t=t.sibling;t!==null;)uc(t,i,s),t=t.sibling}function lS(t){var i=t.stateNode,s=t.memoizedProps;try{for(var f=t.type,v=i.attributes;v.length;)i.removeAttributeNode(v[0]);Nt(i,f,s),i[wt]=t,i[It]=s}catch(x){Ve(t,t.return,x)}}var fr=!1,yt=!1,Pf=!1,cS=typeof WeakSet=="function"?WeakSet:Set,Et=null;function HR(t,i){if(t=t.containerInfo,up=zc,t=Sx(t),Dd(t)){if("selectionStart"in t)var s={start:t.selectionStart,end:t.selectionEnd};else e:{s=(s=t.ownerDocument)&&s.defaultView||window;var f=s.getSelection&&s.getSelection();if(f&&f.rangeCount!==0){s=f.anchorNode;var v=f.anchorOffset,x=f.focusNode;f=f.focusOffset;try{s.nodeType,x.nodeType}catch{s=null;break e}var R=0,H=-1,Y=-1,re=0,ce=0,fe=t,oe=null;t:for(;;){for(var le;fe!==s||v!==0&&fe.nodeType!==3||(H=R+v),fe!==x||f!==0&&fe.nodeType!==3||(Y=R+f),fe.nodeType===3&&(R+=fe.nodeValue.length),(le=fe.firstChild)!==null;)oe=fe,fe=le;for(;;){if(fe===t)break t;if(oe===s&&++re===v&&(H=R),oe===x&&++ce===f&&(Y=R),(le=fe.nextSibling)!==null)break;fe=oe,oe=fe.parentNode}fe=le}s=H===-1||Y===-1?null:{start:H,end:Y}}else s=null}s=s||{start:0,end:0}}else s=null;for(dp={focusedElem:t,selectionRange:s},zc=!1,Et=i;Et!==null;)if(i=Et,t=i.child,(i.subtreeFlags&1028)!==0&&t!==null)t.return=i,Et=t;else for(;Et!==null;){switch(i=Et,x=i.alternate,t=i.flags,i.tag){case 0:if((t&4)!==0&&(t=i.updateQueue,t=t!==null?t.events:null,t!==null))for(s=0;s title"))),Nt(x,f,s),x[wt]=t,ft(x),f=x;break e;case"link":var R=gw("link","href",v).get(f+(s.href||""));if(R){for(var H=0;HKe&&(R=Ke,Ke=Ee,Ee=R);var J=bx(H,Ee),Z=bx(H,Ke);if(J&&Z&&(le.rangeCount!==1||le.anchorNode!==J.node||le.anchorOffset!==J.offset||le.focusNode!==Z.node||le.focusOffset!==Z.offset)){var te=fe.createRange();te.setStart(J.node,J.offset),le.removeAllRanges(),Ee>Ke?(le.addRange(te),le.extend(Z.node,Z.offset)):(te.setEnd(Z.node,Z.offset),le.addRange(te))}}}}for(fe=[],le=H;le=le.parentNode;)le.nodeType===1&&fe.push({element:le,left:le.scrollLeft,top:le.scrollTop});for(typeof H.focus=="function"&&H.focus(),H=0;Hs?32:s,D.T=null,s=Kf,Kf=null;var x=Xr,R=mr;if(_t=0,Da=Xr=null,mr=0,(Pe&6)!==0)throw Error(a(331));var H=Pe;if(Pe|=4,xS(x.current),mS(x,x.current,R,s),Pe=H,os(0,!1),at&&typeof at.onPostCommitFiberRoot=="function")try{at.onPostCommitFiberRoot(qt,x)}catch{}return!0}finally{q.p=v,D.T=f,LS(t,i)}}function HS(t,i,s){i=pn(s,i),i=Af(t.stateNode,i,2),t=Fr(t,i,2),t!==null&&(gi(t,2),Un(t))}function Ve(t,i,s){if(t.tag===3)HS(t,t,s);else for(;i!==null;){if(i.tag===3){HS(i,t,s);break}else if(i.tag===1){var f=i.stateNode;if(typeof i.type.getDerivedStateFromError=="function"||typeof f.componentDidCatch=="function"&&(Yr===null||!Yr.has(f))){t=pn(s,t),s=U1(2),f=Fr(i,s,2),f!==null&&(F1(s,f,i,t),gi(f,2),Un(f));break}}i=i.return}}function ep(t,i,s){var f=t.pingCache;if(f===null){f=t.pingCache=new PR;var v=new Set;f.set(i,v)}else v=f.get(i),v===void 0&&(v=new Set,f.set(i,v));v.has(s)||(Wf=!0,v.add(s),t=YR.bind(null,t,i,s),i.then(t,t))}function YR(t,i,s){var f=t.pingCache;f!==null&&f.delete(i),t.pingedLanes|=t.suspendedLanes&s,t.warmLanes&=~s,Ze===t&&(qe&s)===s&&(st===4||st===3&&(qe&62914560)===qe&&300>Ge()-pc?(Pe&2)===0&&qa(t,0):Gf|=s,Oa===qe&&(Oa=0)),Un(t)}function US(t,i){i===0&&(i=gl()),t=wi(t,i),t!==null&&(gi(t,i),Un(t))}function XR(t){var i=t.memoizedState,s=0;i!==null&&(s=i.retryLane),US(t,s)}function KR(t,i){var s=0;switch(t.tag){case 31:case 13:var f=t.stateNode,v=t.memoizedState;v!==null&&(s=v.retryLane);break;case 19:f=t.stateNode;break;case 22:f=t.stateNode._retryCache;break;default:throw Error(a(314))}f!==null&&f.delete(i),US(t,s)}function ZR(t,i){return ze(t,i)}var xc=null,La=null,tp=!1,Sc=!1,np=!1,Zr=0;function Un(t){t!==La&&t.next===null&&(La===null?xc=La=t:La=La.next=t),Sc=!0,tp||(tp=!0,JR())}function os(t,i){if(!np&&Sc){np=!0;do for(var s=!1,f=xc;f!==null;){if(t!==0){var v=f.pendingLanes;if(v===0)var x=0;else{var R=f.suspendedLanes,H=f.pingedLanes;x=(1<<31-Ht(42|t)+1)-1,x&=v&~(R&~H),x=x&201326741?x&201326741|1:x?x|2:0}x!==0&&(s=!0,VS(f,x))}else x=qe,x=oa(f,f===Ze?x:0,f.cancelPendingCommit!==null||f.timeoutHandle!==-1),(x&3)===0||hi(f,x)||(s=!0,VS(f,x));f=f.next}while(s);np=!1}}function QR(){FS()}function FS(){Sc=tp=!1;var t=0;Zr!==0&&cz()&&(t=Zr);for(var i=Ge(),s=null,f=xc;f!==null;){var v=f.next,x=PS(f,i);x===0?(f.next=null,s===null?xc=v:s.next=v,v===null&&(La=s)):(s=f,(t!==0||(x&3)!==0)&&(Sc=!0)),f=v}_t!==0&&_t!==5||os(t),Zr!==0&&(Zr=0)}function PS(t,i){for(var s=t.suspendedLanes,f=t.pingedLanes,v=t.expirationTimes,x=t.pendingLanes&-62914561;0H)break;var ce=Y.transferSize,fe=Y.initiatorType;ce&&JS(fe)&&(Y=Y.responseEnd,R+=ce*(Y"u"?null:document;function dw(t,i,s){var f=Ba;if(f&&typeof i=="string"&&i){var v=Vt(i);v='link[rel="'+t+'"][href="'+v+'"]',typeof s=="string"&&(v+='[crossorigin="'+s+'"]'),uw.has(v)||(uw.add(v),t={rel:t,crossOrigin:s,href:i},f.querySelector(v)===null&&(i=f.createElement("link"),Nt(i,"link",t),ft(i),f.head.appendChild(i)))}}function vz(t){vr.D(t),dw("dns-prefetch",t,null)}function bz(t,i){vr.C(t,i),dw("preconnect",t,i)}function xz(t,i,s){vr.L(t,i,s);var f=Ba;if(f&&t&&i){var v='link[rel="preload"][as="'+Vt(i)+'"]';i==="image"&&s&&s.imageSrcSet?(v+='[imagesrcset="'+Vt(s.imageSrcSet)+'"]',typeof s.imageSizes=="string"&&(v+='[imagesizes="'+Vt(s.imageSizes)+'"]')):v+='[href="'+Vt(t)+'"]';var x=v;switch(i){case"style":x=Ha(t);break;case"script":x=Ua(t)}bn.has(x)||(t=y({rel:"preload",href:i==="image"&&s&&s.imageSrcSet?void 0:t,as:i},s),bn.set(x,t),f.querySelector(v)!==null||i==="style"&&f.querySelector(us(x))||i==="script"&&f.querySelector(ds(x))||(i=f.createElement("link"),Nt(i,"link",t),ft(i),f.head.appendChild(i)))}}function Sz(t,i){vr.m(t,i);var s=Ba;if(s&&t){var f=i&&typeof i.as=="string"?i.as:"script",v='link[rel="modulepreload"][as="'+Vt(f)+'"][href="'+Vt(t)+'"]',x=v;switch(f){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":x=Ua(t)}if(!bn.has(x)&&(t=y({rel:"modulepreload",href:t},i),bn.set(x,t),s.querySelector(v)===null)){switch(f){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(s.querySelector(ds(x)))return}f=s.createElement("link"),Nt(f,"link",t),ft(f),s.head.appendChild(f)}}}function wz(t,i,s){vr.S(t,i,s);var f=Ba;if(f&&t){var v=Mr(f).hoistableStyles,x=Ha(t);i=i||"default";var R=v.get(x);if(!R){var H={loading:0,preload:null};if(R=f.querySelector(us(x)))H.loading=5;else{t=y({rel:"stylesheet",href:t,"data-precedence":i},s),(s=bn.get(x))&&vp(t,s);var Y=R=f.createElement("link");ft(Y),Nt(Y,"link",t),Y._p=new Promise(function(re,ce){Y.onload=re,Y.onerror=ce}),Y.addEventListener("load",function(){H.loading|=1}),Y.addEventListener("error",function(){H.loading|=2}),H.loading|=4,Ec(R,i,f)}R={type:"stylesheet",instance:R,count:1,state:H},v.set(x,R)}}}function _z(t,i){vr.X(t,i);var s=Ba;if(s&&t){var f=Mr(s).hoistableScripts,v=Ua(t),x=f.get(v);x||(x=s.querySelector(ds(v)),x||(t=y({src:t,async:!0},i),(i=bn.get(v))&&bp(t,i),x=s.createElement("script"),ft(x),Nt(x,"link",t),s.head.appendChild(x)),x={type:"script",instance:x,count:1,state:null},f.set(v,x))}}function kz(t,i){vr.M(t,i);var s=Ba;if(s&&t){var f=Mr(s).hoistableScripts,v=Ua(t),x=f.get(v);x||(x=s.querySelector(ds(v)),x||(t=y({src:t,async:!0,type:"module"},i),(i=bn.get(v))&&bp(t,i),x=s.createElement("script"),ft(x),Nt(x,"link",t),s.head.appendChild(x)),x={type:"script",instance:x,count:1,state:null},f.set(v,x))}}function fw(t,i,s,f){var v=(v=Q.current)?Cc(v):null;if(!v)throw Error(a(446));switch(t){case"meta":case"title":return null;case"style":return typeof s.precedence=="string"&&typeof s.href=="string"?(i=Ha(s.href),s=Mr(v).hoistableStyles,f=s.get(i),f||(f={type:"style",instance:null,count:0,state:null},s.set(i,f)),f):{type:"void",instance:null,count:0,state:null};case"link":if(s.rel==="stylesheet"&&typeof s.href=="string"&&typeof s.precedence=="string"){t=Ha(s.href);var x=Mr(v).hoistableStyles,R=x.get(t);if(R||(v=v.ownerDocument||v,R={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},x.set(t,R),(x=v.querySelector(us(t)))&&!x._p&&(R.instance=x,R.state.loading=5),bn.has(t)||(s={rel:"preload",as:"style",href:s.href,crossOrigin:s.crossOrigin,integrity:s.integrity,media:s.media,hrefLang:s.hrefLang,referrerPolicy:s.referrerPolicy},bn.set(t,s),x||Cz(v,t,s,R.state))),i&&f===null)throw Error(a(528,""));return R}if(i&&f!==null)throw Error(a(529,""));return null;case"script":return i=s.async,s=s.src,typeof s=="string"&&i&&typeof i!="function"&&typeof i!="symbol"?(i=Ua(s),s=Mr(v).hoistableScripts,f=s.get(i),f||(f={type:"script",instance:null,count:0,state:null},s.set(i,f)),f):{type:"void",instance:null,count:0,state:null};default:throw Error(a(444,t))}}function Ha(t){return'href="'+Vt(t)+'"'}function us(t){return'link[rel="stylesheet"]['+t+"]"}function pw(t){return y({},t,{"data-precedence":t.precedence,precedence:null})}function Cz(t,i,s,f){t.querySelector('link[rel="preload"][as="style"]['+i+"]")?f.loading=1:(i=t.createElement("link"),f.preload=i,i.addEventListener("load",function(){return f.loading|=1}),i.addEventListener("error",function(){return f.loading|=2}),Nt(i,"link",s),ft(i),t.head.appendChild(i))}function Ua(t){return'[src="'+Vt(t)+'"]'}function ds(t){return"script[async]"+t}function hw(t,i,s){if(i.count++,i.instance===null)switch(i.type){case"style":var f=t.querySelector('style[data-href~="'+Vt(s.href)+'"]');if(f)return i.instance=f,ft(f),f;var v=y({},s,{"data-href":s.href,"data-precedence":s.precedence,href:null,precedence:null});return f=(t.ownerDocument||t).createElement("style"),ft(f),Nt(f,"style",v),Ec(f,s.precedence,t),i.instance=f;case"stylesheet":v=Ha(s.href);var x=t.querySelector(us(v));if(x)return i.state.loading|=4,i.instance=x,ft(x),x;f=pw(s),(v=bn.get(v))&&vp(f,v),x=(t.ownerDocument||t).createElement("link"),ft(x);var R=x;return R._p=new Promise(function(H,Y){R.onload=H,R.onerror=Y}),Nt(x,"link",f),i.state.loading|=4,Ec(x,s.precedence,t),i.instance=x;case"script":return x=Ua(s.src),(v=t.querySelector(ds(x)))?(i.instance=v,ft(v),v):(f=s,(v=bn.get(x))&&(f=y({},s),bp(f,v)),t=t.ownerDocument||t,v=t.createElement("script"),ft(v),Nt(v,"link",f),t.head.appendChild(v),i.instance=v);case"void":return null;default:throw Error(a(443,i.type))}else i.type==="stylesheet"&&(i.state.loading&4)===0&&(f=i.instance,i.state.loading|=4,Ec(f,s.precedence,t));return i.instance}function Ec(t,i,s){for(var f=s.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),v=f.length?f[f.length-1]:null,x=v,R=0;R title"):null)}function Ez(t,i,s){if(s===1||i.itemProp!=null)return!1;switch(t){case"meta":case"title":return!0;case"style":if(typeof i.precedence!="string"||typeof i.href!="string"||i.href==="")break;return!0;case"link":if(typeof i.rel!="string"||typeof i.href!="string"||i.href===""||i.onLoad||i.onError)break;return i.rel==="stylesheet"?(t=i.disabled,typeof i.precedence=="string"&&t==null):!0;case"script":if(i.async&&typeof i.async!="function"&&typeof i.async!="symbol"&&!i.onLoad&&!i.onError&&i.src&&typeof i.src=="string")return!0}return!1}function mw(t){return!(t.type==="stylesheet"&&(t.state.loading&3)===0)}function jz(t,i,s,f){if(s.type==="stylesheet"&&(typeof f.media!="string"||matchMedia(f.media).matches!==!1)&&(s.state.loading&4)===0){if(s.instance===null){var v=Ha(f.href),x=i.querySelector(us(v));if(x){i=x._p,i!==null&&typeof i=="object"&&typeof i.then=="function"&&(t.count++,t=Tc.bind(t),i.then(t,t)),s.state.loading|=4,s.instance=x,ft(x);return}x=i.ownerDocument||i,f=pw(f),(v=bn.get(v))&&vp(f,v),x=x.createElement("link"),ft(x);var R=x;R._p=new Promise(function(H,Y){R.onload=H,R.onerror=Y}),Nt(x,"link",f),s.instance=x}t.stylesheets===null&&(t.stylesheets=new Map),t.stylesheets.set(s,i),(i=s.state.preload)&&(s.state.loading&3)===0&&(t.count++,s=Tc.bind(t),i.addEventListener("load",s),i.addEventListener("error",s))}}var xp=0;function Tz(t,i){return t.stylesheets&&t.count===0&&Rc(t,t.stylesheets),0xp?50:800)+i);return t.unsuspend=s,function(){t.unsuspend=null,clearTimeout(f),clearTimeout(v)}}:null}function Tc(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)Rc(this,this.stylesheets);else if(this.unsuspend){var t=this.unsuspend;this.unsuspend=null,t()}}}var Ac=null;function Rc(t,i){t.stylesheets=null,t.unsuspend!==null&&(t.count++,Ac=new Map,i.forEach(Az,t),Ac=null,Tc.call(t))}function Az(t,i){if(!(i.state.loading&4)){var s=Ac.get(t);if(s)var f=s.get(null);else{s=new Map,Ac.set(t,s);for(var v=t.querySelectorAll("link[data-precedence],style[data-precedence]"),x=0;x"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(n){console.error(n)}}return e(),Ap.exports=$z(),Ap.exports}var Wz=Vz();let Wi={};function Gz(e){Wi={...Wi,...e}}function zT(){return Wi}function Ru(){return Wi.baseUrl??"/api"}function zu(){const e={"Content-Type":"application/json"},n=(Wi.getToken??(()=>localStorage.getItem("auth_token")))();return n&&(e.Authorization=`Bearer ${n}`),e}async function Nu(e){if(!e.ok){const r=await e.text().catch(()=>e.statusText);throw Wi.onResponseError&&Wi.onResponseError(e.status,r),new Error(`HTTP ${e.status}: ${r}`)}const n=await e.text();if(n)return JSON.parse(n)}async function bt(e){const n=await fetch(`${Ru()}${e}`,{headers:zu()});return Nu(n)}async function Tt(e,n){const r=await fetch(`${Ru()}${e}`,{method:"POST",headers:zu(),body:n!==void 0?JSON.stringify(n):void 0});return Nu(r)}async function Mu(e,n){const r=await fetch(`${Ru()}${e}`,{method:"PUT",headers:zu(),body:n!==void 0?JSON.stringify(n):void 0});return Nu(r)}async function tl(e){const n=await fetch(`${Ru()}${e}`,{method:"DELETE",headers:zu()});return Nu(n)}const Uw=e=>{let n;const r=new Set,a=(h,g)=>{const y=typeof h=="function"?h(n):h;if(!Object.is(y,n)){const m=n;n=g??(typeof y!="object"||y===null)?y:Object.assign({},n,y),r.forEach(b=>b(n,m))}},o=()=>n,d={setState:a,getState:o,getInitialState:()=>p,subscribe:h=>(r.add(h),()=>r.delete(h))},p=n=e(a,o,d);return d},NT=(e=>e?Uw(e):Uw),Yz=e=>e;function Xz(e,n=Yz){const r=js.useSyncExternalStore(e.subscribe,js.useCallback(()=>n(e.getState()),[e,n]),js.useCallback(()=>n(e.getInitialState()),[e,n]));return js.useDebugValue(r),r}const Fw=e=>{const n=NT(e),r=a=>Xz(n,a);return Object.assign(r,n),r},Mn=(e=>e?Fw(e):Fw),_0="/api/v1";async function Pa(e,n){const r=localStorage.getItem("auth_token"),a={"Content-Type":"application/json"};r&&(a.Authorization=`Bearer ${r}`);const o=await fetch(`${_0}${e}`,{...n,headers:{...a,...n?.headers}});if(!o.ok){const l=await o.json().catch(()=>null),c=l?.error??l?.message??`HTTP ${o.status}`;throw new Error(c)}if(o.status!==204)return o.json()}let qs=null;function Bc(e,n){qs&&clearTimeout(qs);const r=Math.max((e-60)*1e3,1e4);qs=setTimeout(()=>{n().catch(()=>{})},r)}const _r=Mn((e,n)=>({user:null,token:localStorage.getItem("auth_token"),refreshToken:localStorage.getItem("auth_refresh_token"),isAuthenticated:!!localStorage.getItem("auth_token"),isLoading:!1,error:null,setupRequired:null,setupLoading:!1,login:async(r,a)=>{e({isLoading:!0,error:null});try{const o=await Pa("/auth/login",{method:"POST",body:JSON.stringify({email:r,password:a})});localStorage.setItem("auth_token",o.access_token),localStorage.setItem("auth_refresh_token",o.refresh_token),e({token:o.access_token,refreshToken:o.refresh_token,isAuthenticated:!0,isLoading:!1}),Bc(o.expires_in,n().refreshAuth),await n().loadUser()}catch(o){const l=o instanceof Error?o.message:"Login failed",c=/invalid.*(cred|password|user)|unauthorized|401/i.test(l)?"Invalid email or password":l;e({isLoading:!1,error:c})}},register:async(r,a,o)=>{e({isLoading:!0,error:null});try{const l=await Pa("/auth/register",{method:"POST",body:JSON.stringify({email:r,password:a,display_name:o})});localStorage.setItem("auth_token",l.access_token),localStorage.setItem("auth_refresh_token",l.refresh_token),e({token:l.access_token,refreshToken:l.refresh_token,isAuthenticated:!0,isLoading:!1}),Bc(l.expires_in,n().refreshAuth),await n().loadUser()}catch(l){e({isLoading:!1,error:l instanceof Error?l.message:"Registration failed"})}},logout:()=>{const r=localStorage.getItem("auth_token");r&&fetch(`${_0}/auth/logout`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${r}`}}).catch(()=>{}),qs&&clearTimeout(qs),localStorage.removeItem("auth_token"),localStorage.removeItem("auth_refresh_token"),e({user:null,token:null,refreshToken:null,isAuthenticated:!1,error:null})},refreshAuth:async()=>{const r=n().refreshToken||localStorage.getItem("auth_refresh_token");if(r)try{const a=await Pa("/auth/refresh",{method:"POST",body:JSON.stringify({refresh_token:r})});localStorage.setItem("auth_token",a.access_token),localStorage.setItem("auth_refresh_token",a.refresh_token),e({token:a.access_token,refreshToken:a.refresh_token,isAuthenticated:!0}),Bc(a.expires_in,n().refreshAuth)}catch{n().logout()}},loadUser:async()=>{try{const r=new AbortController,a=setTimeout(()=>r.abort(),5e3),o=await Pa("/auth/me",{signal:r.signal});clearTimeout(a),e({user:o})}catch(r){const a=r instanceof Error?r.message:"";(a.includes("401")||a.includes("403")||a.includes("user not found")||a.includes("Unauthorized"))&&n().logout()}},oauthLogin:r=>{window.location.href=`${_0}/auth/oauth2/${encodeURIComponent(r)}`},setTokenFromCallback:(r,a)=>{localStorage.setItem("auth_token",r),localStorage.setItem("auth_refresh_token",a),e({token:r,refreshToken:a,isAuthenticated:!0}),n().loadUser()},checkSetupStatus:async()=>{e({setupLoading:!0});try{const r=new AbortController,a=setTimeout(()=>r.abort(),3e3),o=await Pa("/auth/setup-status",{signal:r.signal});clearTimeout(a),e({setupRequired:o.needsSetup,setupLoading:!1})}catch{e({setupRequired:!1,setupLoading:!1})}},setupAdmin:async(r,a,o)=>{e({isLoading:!0,error:null});try{const l=await Pa("/auth/setup",{method:"POST",body:JSON.stringify({email:r,password:a,name:o})});localStorage.setItem("auth_token",l.access_token),localStorage.setItem("auth_refresh_token",l.refresh_token),e({token:l.access_token,refreshToken:l.refresh_token,isAuthenticated:!0,isLoading:!1,setupRequired:!1}),Bc(l.expires_in,n().refreshAuth),await n().loadUser()}catch(l){e({isLoading:!1,error:l instanceof Error?l.message:"Setup failed"})}},clearError:()=>e({error:null})}));function xt(e){if(typeof e=="string"||typeof e=="number")return""+e;let n="";if(Array.isArray(e))for(let r=0,a;r{}};function Ou(){for(var e=0,n=arguments.length,r={},a;e=0&&(a=r.slice(o+1),r=r.slice(0,o)),r&&!n.hasOwnProperty(r))throw new Error("unknown type: "+r);return{type:r,name:a}})}ou.prototype=Ou.prototype={constructor:ou,on:function(e,n){var r=this._,a=Zz(e+"",r),o,l=-1,c=a.length;if(arguments.length<2){for(;++l0)for(var r=new Array(o),a=0,o,l;a=0&&(n=e.slice(0,r))!=="xmlns"&&(e=e.slice(r+1)),$w.hasOwnProperty(n)?{space:$w[n],local:e}:e}function Jz(e){return function(){var n=this.ownerDocument,r=this.namespaceURI;return r===k0&&n.documentElement.namespaceURI===k0?n.createElement(e):n.createElementNS(r,e)}}function e5(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function MT(e){var n=Du(e);return(n.local?e5:Jz)(n)}function t5(){}function tb(e){return e==null?t5:function(){return this.querySelector(e)}}function n5(e){typeof e!="function"&&(e=tb(e));for(var n=this._groups,r=n.length,a=new Array(r),o=0;o=k&&(k=j+1);!(E=C[k])&&++k=0;)(c=a[o])&&(l&&c.compareDocumentPosition(l)^4&&l.parentNode.insertBefore(c,l),l=c);return this}function j5(e){e||(e=T5);function n(y,m){return y&&m?e(y.__data__,m.__data__):!y-!m}for(var r=this._groups,a=r.length,o=new Array(a),l=0;ln?1:e>=n?0:NaN}function A5(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function R5(){return Array.from(this)}function z5(){for(var e=this._groups,n=0,r=e.length;n1?this.each((n==null?F5:typeof n=="function"?$5:P5)(e,n,r??"")):oo(this.node(),e)}function oo(e,n){return e.style.getPropertyValue(n)||LT(e).getComputedStyle(e,null).getPropertyValue(n)}function W5(e){return function(){delete this[e]}}function G5(e,n){return function(){this[e]=n}}function Y5(e,n){return function(){var r=n.apply(this,arguments);r==null?delete this[e]:this[e]=r}}function X5(e,n){return arguments.length>1?this.each((n==null?W5:typeof n=="function"?Y5:G5)(e,n)):this.node()[e]}function BT(e){return e.trim().split(/^|\s+/)}function nb(e){return e.classList||new HT(e)}function HT(e){this._node=e,this._names=BT(e.getAttribute("class")||"")}HT.prototype={add:function(e){var n=this._names.indexOf(e);n<0&&(this._names.push(e),this._node.setAttribute("class",this._names.join(" ")))},remove:function(e){var n=this._names.indexOf(e);n>=0&&(this._names.splice(n,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(e){return this._names.indexOf(e)>=0}};function UT(e,n){for(var r=nb(e),a=-1,o=n.length;++a=0&&(r=n.slice(a+1),n=n.slice(0,a)),{type:n,name:r}})}function _N(e){return function(){var n=this.__on;if(n){for(var r=0,a=-1,o=n.length,l;r()=>e;function C0(e,{sourceEvent:n,subject:r,target:a,identifier:o,active:l,x:c,y:d,dx:p,dy:h,dispatch:g}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:n,enumerable:!0,configurable:!0},subject:{value:r,enumerable:!0,configurable:!0},target:{value:a,enumerable:!0,configurable:!0},identifier:{value:o,enumerable:!0,configurable:!0},active:{value:l,enumerable:!0,configurable:!0},x:{value:c,enumerable:!0,configurable:!0},y:{value:d,enumerable:!0,configurable:!0},dx:{value:p,enumerable:!0,configurable:!0},dy:{value:h,enumerable:!0,configurable:!0},_:{value:g}})}C0.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function MN(e){return!e.ctrlKey&&!e.button}function ON(){return this.parentNode}function DN(e,n){return n??{x:e.x,y:e.y}}function qN(){return navigator.maxTouchPoints||"ontouchstart"in this}function GT(){var e=MN,n=ON,r=DN,a=qN,o={},l=Ou("start","drag","end"),c=0,d,p,h,g,y=0;function m(T){T.on("mousedown.drag",b).filter(a).on("touchstart.drag",C).on("touchmove.drag",_,NN).on("touchend.drag touchcancel.drag",j).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function b(T,E){if(!(g||!e.call(this,T,E))){var z=k(this,n.call(this,T,E),T,E,"mouse");z&&(un(T.view).on("mousemove.drag",S,Us).on("mouseup.drag",w,Us),VT(T.view),Mp(T),h=!1,d=T.clientX,p=T.clientY,z("start",T))}}function S(T){if(ro(T),!h){var E=T.clientX-d,z=T.clientY-p;h=E*E+z*z>y}o.mouse("drag",T)}function w(T){un(T.view).on("mousemove.drag mouseup.drag",null),WT(T.view,h),ro(T),o.mouse("end",T)}function C(T,E){if(e.call(this,T,E)){var z=T.changedTouches,A=n.call(this,T,E),M=z.length,O,P;for(O=0;O>8&15|n>>4&240,n>>4&15|n&240,(n&15)<<4|n&15,1):r===8?Uc(n>>24&255,n>>16&255,n>>8&255,(n&255)/255):r===4?Uc(n>>12&15|n>>8&240,n>>8&15|n>>4&240,n>>4&15|n&240,((n&15)<<4|n&15)/255):null):(n=LN.exec(e))?new Qt(n[1],n[2],n[3],1):(n=BN.exec(e))?new Qt(n[1]*255/100,n[2]*255/100,n[3]*255/100,1):(n=HN.exec(e))?Uc(n[1],n[2],n[3],n[4]):(n=UN.exec(e))?Uc(n[1]*255/100,n[2]*255/100,n[3]*255/100,n[4]):(n=FN.exec(e))?Zw(n[1],n[2]/100,n[3]/100,1):(n=PN.exec(e))?Zw(n[1],n[2]/100,n[3]/100,n[4]):Vw.hasOwnProperty(e)?Yw(Vw[e]):e==="transparent"?new Qt(NaN,NaN,NaN,0):null}function Yw(e){return new Qt(e>>16&255,e>>8&255,e&255,1)}function Uc(e,n,r,a){return a<=0&&(e=n=r=NaN),new Qt(e,n,r,a)}function WN(e){return e instanceof rl||(e=Gi(e)),e?(e=e.rgb(),new Qt(e.r,e.g,e.b,e.opacity)):new Qt}function E0(e,n,r,a){return arguments.length===1?WN(e):new Qt(e,n,r,a??1)}function Qt(e,n,r,a){this.r=+e,this.g=+n,this.b=+r,this.opacity=+a}rb(Qt,E0,YT(rl,{brighter(e){return e=e==null?pu:Math.pow(pu,e),new Qt(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?Fs:Math.pow(Fs,e),new Qt(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new Qt(Fi(this.r),Fi(this.g),Fi(this.b),hu(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:Xw,formatHex:Xw,formatHex8:GN,formatRgb:Kw,toString:Kw}));function Xw(){return`#${Ui(this.r)}${Ui(this.g)}${Ui(this.b)}`}function GN(){return`#${Ui(this.r)}${Ui(this.g)}${Ui(this.b)}${Ui((isNaN(this.opacity)?1:this.opacity)*255)}`}function Kw(){const e=hu(this.opacity);return`${e===1?"rgb(":"rgba("}${Fi(this.r)}, ${Fi(this.g)}, ${Fi(this.b)}${e===1?")":`, ${e})`}`}function hu(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function Fi(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function Ui(e){return e=Fi(e),(e<16?"0":"")+e.toString(16)}function Zw(e,n,r,a){return a<=0?e=n=r=NaN:r<=0||r>=1?e=n=NaN:n<=0&&(e=NaN),new An(e,n,r,a)}function XT(e){if(e instanceof An)return new An(e.h,e.s,e.l,e.opacity);if(e instanceof rl||(e=Gi(e)),!e)return new An;if(e instanceof An)return e;e=e.rgb();var n=e.r/255,r=e.g/255,a=e.b/255,o=Math.min(n,r,a),l=Math.max(n,r,a),c=NaN,d=l-o,p=(l+o)/2;return d?(n===l?c=(r-a)/d+(r0&&p<1?0:c,new An(c,d,p,e.opacity)}function YN(e,n,r,a){return arguments.length===1?XT(e):new An(e,n,r,a??1)}function An(e,n,r,a){this.h=+e,this.s=+n,this.l=+r,this.opacity=+a}rb(An,YN,YT(rl,{brighter(e){return e=e==null?pu:Math.pow(pu,e),new An(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?Fs:Math.pow(Fs,e),new An(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,n=isNaN(e)||isNaN(this.s)?0:this.s,r=this.l,a=r+(r<.5?r:1-r)*n,o=2*r-a;return new Qt(Op(e>=240?e-240:e+120,o,a),Op(e,o,a),Op(e<120?e+240:e-120,o,a),this.opacity)},clamp(){return new An(Qw(this.h),Fc(this.s),Fc(this.l),hu(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const e=hu(this.opacity);return`${e===1?"hsl(":"hsla("}${Qw(this.h)}, ${Fc(this.s)*100}%, ${Fc(this.l)*100}%${e===1?")":`, ${e})`}`}}));function Qw(e){return e=(e||0)%360,e<0?e+360:e}function Fc(e){return Math.max(0,Math.min(1,e||0))}function Op(e,n,r){return(e<60?n+(r-n)*e/60:e<180?r:e<240?n+(r-n)*(240-e)/60:n)*255}const ib=e=>()=>e;function XN(e,n){return function(r){return e+r*n}}function KN(e,n,r){return e=Math.pow(e,r),n=Math.pow(n,r)-e,r=1/r,function(a){return Math.pow(e+a*n,r)}}function ZN(e){return(e=+e)==1?KT:function(n,r){return r-n?KN(n,r,e):ib(isNaN(n)?r:n)}}function KT(e,n){var r=n-e;return r?XN(e,r):ib(isNaN(e)?n:e)}const gu=(function e(n){var r=ZN(n);function a(o,l){var c=r((o=E0(o)).r,(l=E0(l)).r),d=r(o.g,l.g),p=r(o.b,l.b),h=KT(o.opacity,l.opacity);return function(g){return o.r=c(g),o.g=d(g),o.b=p(g),o.opacity=h(g),o+""}}return a.gamma=e,a})(1);function QN(e,n){n||(n=[]);var r=e?Math.min(n.length,e.length):0,a=n.slice(),o;return function(l){for(o=0;or&&(l=n.slice(r,l),d[c]?d[c]+=l:d[++c]=l),(a=a[0])===(o=o[0])?d[c]?d[c]+=o:d[++c]=o:(d[++c]=null,p.push({i:c,x:Pn(a,o)})),r=Dp.lastIndex;return r180?g+=360:g-h>180&&(h+=360),m.push({i:y.push(o(y)+"rotate(",null,a)-2,x:Pn(h,g)})):g&&y.push(o(y)+"rotate("+g+a)}function d(h,g,y,m){h!==g?m.push({i:y.push(o(y)+"skewX(",null,a)-2,x:Pn(h,g)}):g&&y.push(o(y)+"skewX("+g+a)}function p(h,g,y,m,b,S){if(h!==y||g!==m){var w=b.push(o(b)+"scale(",null,",",null,")");S.push({i:w-4,x:Pn(h,y)},{i:w-2,x:Pn(g,m)})}else(y!==1||m!==1)&&b.push(o(b)+"scale("+y+","+m+")")}return function(h,g){var y=[],m=[];return h=e(h),g=e(g),l(h.translateX,h.translateY,g.translateX,g.translateY,y,m),c(h.rotate,g.rotate,y,m),d(h.skewX,g.skewX,y,m),p(h.scaleX,h.scaleY,g.scaleX,g.scaleY,y,m),h=g=null,function(b){for(var S=-1,w=m.length,C;++S=0&&e._call.call(void 0,n),e=e._next;--so}function t_(){Yi=(mu=$s.now())+qu,so=Ts=0;try{pM()}finally{so=0,gM(),Yi=0}}function hM(){var e=$s.now(),n=e-mu;n>e6&&(qu-=n,mu=e)}function gM(){for(var e,n=yu,r,a=1/0;n;)n._call?(a>n._time&&(a=n._time),e=n,n=n._next):(r=n._next,n._next=null,n=e?e._next=r:yu=r);As=e,A0(a)}function A0(e){if(!so){Ts&&(Ts=clearTimeout(Ts));var n=e-Yi;n>24?(e<1/0&&(Ts=setTimeout(t_,e-$s.now()-qu)),vs&&(vs=clearInterval(vs))):(vs||(mu=$s.now(),vs=setInterval(hM,e6)),so=1,t6(t_))}}function n_(e,n,r){var a=new vu;return n=n==null?0:+n,a.restart(o=>{a.stop(),e(o+n)},n,r),a}var yM=Ou("start","end","cancel","interrupt"),mM=[],r6=0,r_=1,R0=2,lu=3,i_=4,z0=5,cu=6;function Iu(e,n,r,a,o,l){var c=e.__transition;if(!c)e.__transition={};else if(r in c)return;vM(e,r,{name:n,index:a,group:o,on:yM,tween:mM,time:l.time,delay:l.delay,duration:l.duration,ease:l.ease,timer:null,state:r6})}function ob(e,n){var r=On(e,n);if(r.state>r6)throw new Error("too late; already scheduled");return r}function Xn(e,n){var r=On(e,n);if(r.state>lu)throw new Error("too late; already running");return r}function On(e,n){var r=e.__transition;if(!r||!(r=r[n]))throw new Error("transition not found");return r}function vM(e,n,r){var a=e.__transition,o;a[n]=r,r.timer=n6(l,0,r.time);function l(h){r.state=r_,r.timer.restart(c,r.delay,r.time),r.delay<=h&&c(h-r.delay)}function c(h){var g,y,m,b;if(r.state!==r_)return p();for(g in a)if(b=a[g],b.name===r.name){if(b.state===lu)return n_(c);b.state===i_?(b.state=cu,b.timer.stop(),b.on.call("interrupt",e,e.__data__,b.index,b.group),delete a[g]):+gR0&&a.state=0&&(n=n.slice(0,r)),!n||n==="start"})}function YM(e,n,r){var a,o,l=GM(n)?ob:Xn;return function(){var c=l(this,e),d=c.on;d!==a&&(o=(a=d).copy()).on(n,r),c.on=o}}function XM(e,n){var r=this._id;return arguments.length<2?On(this.node(),r).on.on(e):this.each(YM(r,e,n))}function KM(e){return function(){var n=this.parentNode;for(var r in this.__transition)if(+r!==e)return;n&&n.removeChild(this)}}function ZM(){return this.on("end.remove",KM(this._id))}function QM(e){var n=this._name,r=this._id;typeof e!="function"&&(e=tb(e));for(var a=this._groups,o=a.length,l=new Array(o),c=0;c()=>e;function _O(e,{sourceEvent:n,target:r,transform:a,dispatch:o}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:n,enumerable:!0,configurable:!0},target:{value:r,enumerable:!0,configurable:!0},transform:{value:a,enumerable:!0,configurable:!0},_:{value:o}})}function Sr(e,n,r){this.k=e,this.x=n,this.y=r}Sr.prototype={constructor:Sr,scale:function(e){return e===1?this:new Sr(this.k*e,this.x,this.y)},translate:function(e,n){return e===0&n===0?this:new Sr(this.k,this.x+this.k*e,this.y+this.k*n)},apply:function(e){return[e[0]*this.k+this.x,e[1]*this.k+this.y]},applyX:function(e){return e*this.k+this.x},applyY:function(e){return e*this.k+this.y},invert:function(e){return[(e[0]-this.x)/this.k,(e[1]-this.y)/this.k]},invertX:function(e){return(e-this.x)/this.k},invertY:function(e){return(e-this.y)/this.k},rescaleX:function(e){return e.copy().domain(e.range().map(this.invertX,this).map(e.invert,e))},rescaleY:function(e){return e.copy().domain(e.range().map(this.invertY,this).map(e.invert,e))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var Lu=new Sr(1,0,0);s6.prototype=Sr.prototype;function s6(e){for(;!e.__zoom;)if(!(e=e.parentNode))return Lu;return e.__zoom}function qp(e){e.stopImmediatePropagation()}function bs(e){e.preventDefault(),e.stopImmediatePropagation()}function kO(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function CO(){var e=this;return e instanceof SVGElement?(e=e.ownerSVGElement||e,e.hasAttribute("viewBox")?(e=e.viewBox.baseVal,[[e.x,e.y],[e.x+e.width,e.y+e.height]]):[[0,0],[e.width.baseVal.value,e.height.baseVal.value]]):[[0,0],[e.clientWidth,e.clientHeight]]}function a_(){return this.__zoom||Lu}function EO(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function jO(){return navigator.maxTouchPoints||"ontouchstart"in this}function TO(e,n,r){var a=e.invertX(n[0][0])-r[0][0],o=e.invertX(n[1][0])-r[1][0],l=e.invertY(n[0][1])-r[0][1],c=e.invertY(n[1][1])-r[1][1];return e.translate(o>a?(a+o)/2:Math.min(0,a)||Math.max(0,o),c>l?(l+c)/2:Math.min(0,l)||Math.max(0,c))}function l6(){var e=kO,n=CO,r=TO,a=EO,o=jO,l=[0,1/0],c=[[-1/0,-1/0],[1/0,1/0]],d=250,p=su,h=Ou("start","zoom","end"),g,y,m,b=500,S=150,w=0,C=10;function _(U){U.property("__zoom",a_).on("wheel.zoom",M,{passive:!1}).on("mousedown.zoom",O).on("dblclick.zoom",P).filter(o).on("touchstart.zoom",L).on("touchmove.zoom",I).on("touchend.zoom touchcancel.zoom",F).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}_.transform=function(U,B,D,q){var $=U.selection?U.selection():U;$.property("__zoom",a_),U!==$?E(U,B,D,q):$.interrupt().each(function(){z(this,arguments).event(q).start().zoom(null,typeof B=="function"?B.apply(this,arguments):B).end()})},_.scaleBy=function(U,B,D,q){_.scaleTo(U,function(){var $=this.__zoom.k,K=typeof B=="function"?B.apply(this,arguments):B;return $*K},D,q)},_.scaleTo=function(U,B,D,q){_.transform(U,function(){var $=n.apply(this,arguments),K=this.__zoom,ne=D==null?T($):typeof D=="function"?D.apply(this,arguments):D,V=K.invert(ne),W=typeof B=="function"?B.apply(this,arguments):B;return r(k(j(K,W),ne,V),$,c)},D,q)},_.translateBy=function(U,B,D,q){_.transform(U,function(){return r(this.__zoom.translate(typeof B=="function"?B.apply(this,arguments):B,typeof D=="function"?D.apply(this,arguments):D),n.apply(this,arguments),c)},null,q)},_.translateTo=function(U,B,D,q,$){_.transform(U,function(){var K=n.apply(this,arguments),ne=this.__zoom,V=q==null?T(K):typeof q=="function"?q.apply(this,arguments):q;return r(Lu.translate(V[0],V[1]).scale(ne.k).translate(typeof B=="function"?-B.apply(this,arguments):-B,typeof D=="function"?-D.apply(this,arguments):-D),K,c)},q,$)};function j(U,B){return B=Math.max(l[0],Math.min(l[1],B)),B===U.k?U:new Sr(B,U.x,U.y)}function k(U,B,D){var q=B[0]-D[0]*U.k,$=B[1]-D[1]*U.k;return q===U.x&&$===U.y?U:new Sr(U.k,q,$)}function T(U){return[(+U[0][0]+ +U[1][0])/2,(+U[0][1]+ +U[1][1])/2]}function E(U,B,D,q){U.on("start.zoom",function(){z(this,arguments).event(q).start()}).on("interrupt.zoom end.zoom",function(){z(this,arguments).event(q).end()}).tween("zoom",function(){var $=this,K=arguments,ne=z($,K).event(q),V=n.apply($,K),W=D==null?T(V):typeof D=="function"?D.apply($,K):D,ee=Math.max(V[1][0]-V[0][0],V[1][1]-V[0][1]),G=$.__zoom,X=typeof B=="function"?B.apply($,K):B,Q=p(G.invert(W).concat(ee/G.k),X.invert(W).concat(ee/X.k));return function(ie){if(ie===1)ie=X;else{var se=Q(ie),he=ee/se[2];ie=new Sr(he,W[0]-se[0]*he,W[1]-se[1]*he)}ne.zoom(null,ie)}})}function z(U,B,D){return!D&&U.__zooming||new A(U,B)}function A(U,B){this.that=U,this.args=B,this.active=0,this.sourceEvent=null,this.extent=n.apply(U,B),this.taps=0}A.prototype={event:function(U){return U&&(this.sourceEvent=U),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(U,B){return this.mouse&&U!=="mouse"&&(this.mouse[1]=B.invert(this.mouse[0])),this.touch0&&U!=="touch"&&(this.touch0[1]=B.invert(this.touch0[0])),this.touch1&&U!=="touch"&&(this.touch1[1]=B.invert(this.touch1[0])),this.that.__zoom=B,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(U){var B=un(this.that).datum();h.call(U,this.that,new _O(U,{sourceEvent:this.sourceEvent,target:_,transform:this.that.__zoom,dispatch:h}),B)}};function M(U,...B){if(!e.apply(this,arguments))return;var D=z(this,B).event(U),q=this.__zoom,$=Math.max(l[0],Math.min(l[1],q.k*Math.pow(2,a.apply(this,arguments)))),K=Tn(U);if(D.wheel)(D.mouse[0][0]!==K[0]||D.mouse[0][1]!==K[1])&&(D.mouse[1]=q.invert(D.mouse[0]=K)),clearTimeout(D.wheel);else{if(q.k===$)return;D.mouse=[K,q.invert(K)],uu(this),D.start()}bs(U),D.wheel=setTimeout(ne,S),D.zoom("mouse",r(k(j(q,$),D.mouse[0],D.mouse[1]),D.extent,c));function ne(){D.wheel=null,D.end()}}function O(U,...B){if(m||!e.apply(this,arguments))return;var D=U.currentTarget,q=z(this,B,!0).event(U),$=un(U.view).on("mousemove.zoom",W,!0).on("mouseup.zoom",ee,!0),K=Tn(U,D),ne=U.clientX,V=U.clientY;VT(U.view),qp(U),q.mouse=[K,this.__zoom.invert(K)],uu(this),q.start();function W(G){if(bs(G),!q.moved){var X=G.clientX-ne,Q=G.clientY-V;q.moved=X*X+Q*Q>w}q.event(G).zoom("mouse",r(k(q.that.__zoom,q.mouse[0]=Tn(G,D),q.mouse[1]),q.extent,c))}function ee(G){$.on("mousemove.zoom mouseup.zoom",null),WT(G.view,q.moved),bs(G),q.event(G).end()}}function P(U,...B){if(e.apply(this,arguments)){var D=this.__zoom,q=Tn(U.changedTouches?U.changedTouches[0]:U,this),$=D.invert(q),K=D.k*(U.shiftKey?.5:2),ne=r(k(j(D,K),q,$),n.apply(this,B),c);bs(U),d>0?un(this).transition().duration(d).call(E,ne,q,U):un(this).call(_.transform,ne,q,U)}}function L(U,...B){if(e.apply(this,arguments)){var D=U.touches,q=D.length,$=z(this,B,U.changedTouches.length===q).event(U),K,ne,V,W;for(qp(U),ne=0;ne"[React Flow]: Seems like you have not used zustand provider as an ancestor. Help: https://reactflow.dev/error#001",error002:()=>"It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.",error003:e=>`Node type "${e}" not found. Using fallback type "default".`,error004:()=>"The React Flow parent container needs a width and a height to render the graph.",error005:()=>"Only child nodes can use a parent extent.",error006:()=>"Can't create edge. An edge needs a source and a target.",error007:e=>`The old edge with id=${e} does not exist.`,error009:e=>`Marker type "${e}" doesn't exist.`,error008:(e,{id:n,sourceHandle:r,targetHandle:a})=>`Couldn't create edge for ${e} handle id: "${e==="source"?r:a}", edge id: ${n}.`,error010:()=>"Handle: No node id found. Make sure to only use a Handle inside a custom Node.",error011:e=>`Edge type "${e}" not found. Using fallback type "default".`,error012:e=>`Node with id "${e}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`,error013:(e="react")=>`It seems that you haven't loaded the styles. Please import '@xyflow/${e}/dist/style.css' or base.css to make sure everything is working properly.`,error014:()=>"useNodeConnections: No node ID found. Call useNodeConnections inside a custom Node or provide a node ID.",error015:()=>"It seems that you are trying to drag a node that is not initialized. Please use onNodesChange as explained in the docs."},Vs=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],c6=["Enter"," ","Escape"],u6={"node.a11yDescription.default":"Press enter or space to select a node. Press delete to remove it and escape to cancel.","node.a11yDescription.keyboardDisabled":"Press enter or space to select a node. You can then use the arrow keys to move the node around. Press delete to remove it and escape to cancel.","node.a11yDescription.ariaLiveMessage":({direction:e,x:n,y:r})=>`Moved selected node ${e}. New position, x: ${n}, y: ${r}`,"edge.a11yDescription.default":"Press enter or space to select an edge. You can then press delete to remove it or escape to cancel.","controls.ariaLabel":"Control Panel","controls.zoomIn.ariaLabel":"Zoom In","controls.zoomOut.ariaLabel":"Zoom Out","controls.fitView.ariaLabel":"Fit View","controls.interactive.ariaLabel":"Toggle Interactivity","minimap.ariaLabel":"Mini Map","handle.ariaLabel":"Handle"};var lo;(function(e){e.Strict="strict",e.Loose="loose"})(lo||(lo={}));var Pi;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(Pi||(Pi={}));var Ws;(function(e){e.Partial="partial",e.Full="full"})(Ws||(Ws={}));const d6={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var ui;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(ui||(ui={}));var bu;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(bu||(bu={}));var me;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(me||(me={}));const o_={[me.Left]:me.Right,[me.Right]:me.Left,[me.Top]:me.Bottom,[me.Bottom]:me.Top};function f6(e){return e===null?null:e?"valid":"invalid"}const p6=e=>"id"in e&&"source"in e&&"target"in e,AO=e=>"id"in e&&"position"in e&&!("source"in e)&&!("target"in e),lb=e=>"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e),il=(e,n=[0,0])=>{const{width:r,height:a}=Er(e),o=e.origin??n,l=r*o[0],c=a*o[1];return{x:e.position.x-l,y:e.position.y-c}},RO=(e,n={nodeOrigin:[0,0]})=>{if(e.length===0)return{x:0,y:0,width:0,height:0};const r=e.reduce((a,o)=>{const l=typeof o=="string";let c=!n.nodeLookup&&!l?o:void 0;n.nodeLookup&&(c=l?n.nodeLookup.get(o):lb(o)?o:n.nodeLookup.get(o.id));const d=c?xu(c,n.nodeOrigin):{x:0,y:0,x2:0,y2:0};return Bu(a,d)},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return Hu(r)},al=(e,n={})=>{let r={x:1/0,y:1/0,x2:-1/0,y2:-1/0},a=!1;return e.forEach(o=>{(n.filter===void 0||n.filter(o))&&(r=Bu(r,xu(o)),a=!0)}),a?Hu(r):{x:0,y:0,width:0,height:0}},cb=(e,n,[r,a,o]=[0,0,1],l=!1,c=!1)=>{const d={...sl(n,[r,a,o]),width:n.width/o,height:n.height/o},p=[];for(const h of e.values()){const{measured:g,selectable:y=!0,hidden:m=!1}=h;if(c&&!y||m)continue;const b=g.width??h.width??h.initialWidth??null,S=g.height??h.height??h.initialHeight??null,w=Gs(d,uo(h)),C=(b??0)*(S??0),_=l&&w>0;(!h.internals.handleBounds||_||w>=C||h.dragging)&&p.push(h)}return p},zO=(e,n)=>{const r=new Set;return e.forEach(a=>{r.add(a.id)}),n.filter(a=>r.has(a.source)||r.has(a.target))};function NO(e,n){const r=new Map,a=n?.nodes?new Set(n.nodes.map(o=>o.id)):null;return e.forEach(o=>{o.measured.width&&o.measured.height&&(n?.includeHiddenNodes||!o.hidden)&&(!a||a.has(o.id))&&r.set(o.id,o)}),r}async function MO({nodes:e,width:n,height:r,panZoom:a,minZoom:o,maxZoom:l},c){if(e.size===0)return Promise.resolve(!0);const d=NO(e,c),p=al(d),h=ub(p,n,r,c?.minZoom??o,c?.maxZoom??l,c?.padding??.1);return await a.setViewport(h,{duration:c?.duration,ease:c?.ease,interpolate:c?.interpolate}),Promise.resolve(!0)}function h6({nodeId:e,nextPosition:n,nodeLookup:r,nodeOrigin:a=[0,0],nodeExtent:o,onError:l}){const c=r.get(e),d=c.parentId?r.get(c.parentId):void 0,{x:p,y:h}=d?d.internals.positionAbsolute:{x:0,y:0},g=c.origin??a;let y=c.extent||o;if(c.extent==="parent"&&!c.expandParent)if(!d)l?.("005",Yn.error005());else{const b=d.measured.width,S=d.measured.height;b&&S&&(y=[[p,h],[p+b,h+S]])}else d&&fo(c.extent)&&(y=[[c.extent[0][0]+p,c.extent[0][1]+h],[c.extent[1][0]+p,c.extent[1][1]+h]]);const m=fo(y)?Xi(n,y,c.measured):n;return(c.measured.width===void 0||c.measured.height===void 0)&&l?.("015",Yn.error015()),{position:{x:m.x-p+(c.measured.width??0)*g[0],y:m.y-h+(c.measured.height??0)*g[1]},positionAbsolute:m}}async function OO({nodesToRemove:e=[],edgesToRemove:n=[],nodes:r,edges:a,onBeforeDelete:o}){const l=new Set(e.map(m=>m.id)),c=[];for(const m of r){if(m.deletable===!1)continue;const b=l.has(m.id),S=!b&&m.parentId&&c.find(w=>w.id===m.parentId);(b||S)&&c.push(m)}const d=new Set(n.map(m=>m.id)),p=a.filter(m=>m.deletable!==!1),g=zO(c,p);for(const m of p)d.has(m.id)&&!g.find(S=>S.id===m.id)&&g.push(m);if(!o)return{edges:g,nodes:c};const y=await o({nodes:c,edges:g});return typeof y=="boolean"?y?{edges:g,nodes:c}:{edges:[],nodes:[]}:y}const co=(e,n=0,r=1)=>Math.min(Math.max(e,n),r),Xi=(e={x:0,y:0},n,r)=>({x:co(e.x,n[0][0],n[1][0]-(r?.width??0)),y:co(e.y,n[0][1],n[1][1]-(r?.height??0))});function g6(e,n,r){const{width:a,height:o}=Er(r),{x:l,y:c}=r.internals.positionAbsolute;return Xi(e,[[l,c],[l+a,c+o]],n)}const s_=(e,n,r)=>er?-co(Math.abs(e-r),1,n)/n:0,y6=(e,n,r=15,a=40)=>{const o=s_(e.x,a,n.width-a)*r,l=s_(e.y,a,n.height-a)*r;return[o,l]},Bu=(e,n)=>({x:Math.min(e.x,n.x),y:Math.min(e.y,n.y),x2:Math.max(e.x2,n.x2),y2:Math.max(e.y2,n.y2)}),N0=({x:e,y:n,width:r,height:a})=>({x:e,y:n,x2:e+r,y2:n+a}),Hu=({x:e,y:n,x2:r,y2:a})=>({x:e,y:n,width:r-e,height:a-n}),uo=(e,n=[0,0])=>{const{x:r,y:a}=lb(e)?e.internals.positionAbsolute:il(e,n);return{x:r,y:a,width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}},xu=(e,n=[0,0])=>{const{x:r,y:a}=lb(e)?e.internals.positionAbsolute:il(e,n);return{x:r,y:a,x2:r+(e.measured?.width??e.width??e.initialWidth??0),y2:a+(e.measured?.height??e.height??e.initialHeight??0)}},m6=(e,n)=>Hu(Bu(N0(e),N0(n))),Gs=(e,n)=>{const r=Math.max(0,Math.min(e.x+e.width,n.x+n.width)-Math.max(e.x,n.x)),a=Math.max(0,Math.min(e.y+e.height,n.y+n.height)-Math.max(e.y,n.y));return Math.ceil(r*a)},l_=e=>Rn(e.width)&&Rn(e.height)&&Rn(e.x)&&Rn(e.y),Rn=e=>!isNaN(e)&&isFinite(e),DO=(e,n)=>{},ol=(e,n=[1,1])=>({x:n[0]*Math.round(e.x/n[0]),y:n[1]*Math.round(e.y/n[1])}),sl=({x:e,y:n},[r,a,o],l=!1,c=[1,1])=>{const d={x:(e-r)/o,y:(n-a)/o};return l?ol(d,c):d},Su=({x:e,y:n},[r,a,o])=>({x:e*o+r,y:n*o+a});function $a(e,n){if(typeof e=="number")return Math.floor((n-n/(1+e))*.5);if(typeof e=="string"&&e.endsWith("px")){const r=parseFloat(e);if(!Number.isNaN(r))return Math.floor(r)}if(typeof e=="string"&&e.endsWith("%")){const r=parseFloat(e);if(!Number.isNaN(r))return Math.floor(n*r*.01)}return console.error(`[React Flow] The padding value "${e}" is invalid. Please provide a number or a string with a valid unit (px or %).`),0}function qO(e,n,r){if(typeof e=="string"||typeof e=="number"){const a=$a(e,r),o=$a(e,n);return{top:a,right:o,bottom:a,left:o,x:o*2,y:a*2}}if(typeof e=="object"){const a=$a(e.top??e.y??0,r),o=$a(e.bottom??e.y??0,r),l=$a(e.left??e.x??0,n),c=$a(e.right??e.x??0,n);return{top:a,right:c,bottom:o,left:l,x:l+c,y:a+o}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function IO(e,n,r,a,o,l){const{x:c,y:d}=Su(e,[n,r,a]),{x:p,y:h}=Su({x:e.x+e.width,y:e.y+e.height},[n,r,a]),g=o-p,y=l-h;return{left:Math.floor(c),top:Math.floor(d),right:Math.floor(g),bottom:Math.floor(y)}}const ub=(e,n,r,a,o,l)=>{const c=qO(l,n,r),d=(n-c.x)/e.width,p=(r-c.y)/e.height,h=Math.min(d,p),g=co(h,a,o),y=e.x+e.width/2,m=e.y+e.height/2,b=n/2-y*g,S=r/2-m*g,w=IO(e,b,S,g,n,r),C={left:Math.min(w.left-c.left,0),top:Math.min(w.top-c.top,0),right:Math.min(w.right-c.right,0),bottom:Math.min(w.bottom-c.bottom,0)};return{x:b-C.left+C.right,y:S-C.top+C.bottom,zoom:g}},Ys=()=>typeof navigator<"u"&&navigator?.userAgent?.indexOf("Mac")>=0;function fo(e){return e!=null&&e!=="parent"}function Er(e){return{width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}}function v6(e){return(e.measured?.width??e.width??e.initialWidth)!==void 0&&(e.measured?.height??e.height??e.initialHeight)!==void 0}function b6(e,n={width:0,height:0},r,a,o){const l={...e},c=a.get(r);if(c){const d=c.origin||o;l.x+=c.internals.positionAbsolute.x-(n.width??0)*d[0],l.y+=c.internals.positionAbsolute.y-(n.height??0)*d[1]}return l}function c_(e,n){if(e.size!==n.size)return!1;for(const r of e)if(!n.has(r))return!1;return!0}function LO(){let e,n;return{promise:new Promise((a,o)=>{e=a,n=o}),resolve:e,reject:n}}function BO(e){return{...u6,...e||{}}}function Ls(e,{snapGrid:n=[0,0],snapToGrid:r=!1,transform:a,containerBounds:o}){const{x:l,y:c}=zn(e),d=sl({x:l-(o?.left??0),y:c-(o?.top??0)},a),{x:p,y:h}=r?ol(d,n):d;return{xSnapped:p,ySnapped:h,...d}}const db=e=>({width:e.offsetWidth,height:e.offsetHeight}),x6=e=>e?.getRootNode?.()||window?.document,HO=["INPUT","SELECT","TEXTAREA"];function S6(e){const n=e.composedPath?.()?.[0]||e.target;return n?.nodeType!==1?!1:HO.includes(n.nodeName)||n.hasAttribute("contenteditable")||!!n.closest(".nokey")}const w6=e=>"clientX"in e,zn=(e,n)=>{const r=w6(e),a=r?e.clientX:e.touches?.[0].clientX,o=r?e.clientY:e.touches?.[0].clientY;return{x:a-(n?.left??0),y:o-(n?.top??0)}},u_=(e,n,r,a,o)=>{const l=n.querySelectorAll(`.${e}`);return!l||!l.length?null:Array.from(l).map(c=>{const d=c.getBoundingClientRect();return{id:c.getAttribute("data-handleid"),type:e,nodeId:o,position:c.getAttribute("data-handlepos"),x:(d.left-r.left)/a,y:(d.top-r.top)/a,...db(c)}})};function _6({sourceX:e,sourceY:n,targetX:r,targetY:a,sourceControlX:o,sourceControlY:l,targetControlX:c,targetControlY:d}){const p=e*.125+o*.375+c*.375+r*.125,h=n*.125+l*.375+d*.375+a*.125,g=Math.abs(p-e),y=Math.abs(h-n);return[p,h,g,y]}function Vc(e,n){return e>=0?.5*e:n*25*Math.sqrt(-e)}function d_({pos:e,x1:n,y1:r,x2:a,y2:o,c:l}){switch(e){case me.Left:return[n-Vc(n-a,l),r];case me.Right:return[n+Vc(a-n,l),r];case me.Top:return[n,r-Vc(r-o,l)];case me.Bottom:return[n,r+Vc(o-r,l)]}}function fb({sourceX:e,sourceY:n,sourcePosition:r=me.Bottom,targetX:a,targetY:o,targetPosition:l=me.Top,curvature:c=.25}){const[d,p]=d_({pos:r,x1:e,y1:n,x2:a,y2:o,c}),[h,g]=d_({pos:l,x1:a,y1:o,x2:e,y2:n,c}),[y,m,b,S]=_6({sourceX:e,sourceY:n,targetX:a,targetY:o,sourceControlX:d,sourceControlY:p,targetControlX:h,targetControlY:g});return[`M${e},${n} C${d},${p} ${h},${g} ${a},${o}`,y,m,b,S]}function k6({sourceX:e,sourceY:n,targetX:r,targetY:a}){const o=Math.abs(r-e)/2,l=r0}const PO=({source:e,sourceHandle:n,target:r,targetHandle:a})=>`xy-edge__${e}${n||""}-${r}${a||""}`,$O=(e,n)=>n.some(r=>r.source===e.source&&r.target===e.target&&(r.sourceHandle===e.sourceHandle||!r.sourceHandle&&!e.sourceHandle)&&(r.targetHandle===e.targetHandle||!r.targetHandle&&!e.targetHandle)),C6=(e,n,r={})=>{if(!e.source||!e.target)return n;const a=r.getEdgeId||PO;let o;return p6(e)?o={...e}:o={...e,id:a(e)},$O(o,n)?n:(o.sourceHandle===null&&delete o.sourceHandle,o.targetHandle===null&&delete o.targetHandle,n.concat(o))};function E6({sourceX:e,sourceY:n,targetX:r,targetY:a}){const[o,l,c,d]=k6({sourceX:e,sourceY:n,targetX:r,targetY:a});return[`M ${e},${n}L ${r},${a}`,o,l,c,d]}const f_={[me.Left]:{x:-1,y:0},[me.Right]:{x:1,y:0},[me.Top]:{x:0,y:-1},[me.Bottom]:{x:0,y:1}},VO=({source:e,sourcePosition:n=me.Bottom,target:r})=>n===me.Left||n===me.Right?e.xMath.sqrt(Math.pow(n.x-e.x,2)+Math.pow(n.y-e.y,2));function WO({source:e,sourcePosition:n=me.Bottom,target:r,targetPosition:a=me.Top,center:o,offset:l,stepPosition:c}){const d=f_[n],p=f_[a],h={x:e.x+d.x*l,y:e.y+d.y*l},g={x:r.x+p.x*l,y:r.y+p.y*l},y=VO({source:h,sourcePosition:n,target:g}),m=y.x!==0?"x":"y",b=y[m];let S=[],w,C;const _={x:0,y:0},j={x:0,y:0},[,,k,T]=k6({sourceX:e.x,sourceY:e.y,targetX:r.x,targetY:r.y});if(d[m]*p[m]===-1){m==="x"?(w=o.x??h.x+(g.x-h.x)*c,C=o.y??(h.y+g.y)/2):(w=o.x??(h.x+g.x)/2,C=o.y??h.y+(g.y-h.y)*c);const z=[{x:w,y:h.y},{x:w,y:g.y}],A=[{x:h.x,y:C},{x:g.x,y:C}];d[m]===b?S=m==="x"?z:A:S=m==="x"?A:z}else{const z=[{x:h.x,y:g.y}],A=[{x:g.x,y:h.y}];if(m==="x"?S=d.x===b?A:z:S=d.y===b?z:A,n===a){const I=Math.abs(e[m]-r[m]);if(I<=l){const F=Math.min(l-1,l-I);d[m]===b?_[m]=(h[m]>e[m]?-1:1)*F:j[m]=(g[m]>r[m]?-1:1)*F}}if(n!==a){const I=m==="x"?"y":"x",F=d[m]===p[I],U=h[I]>g[I],B=h[I]=L?(w=(M.x+O.x)/2,C=S[0].y):(w=S[0].x,C=(M.y+O.y)/2)}return[[e,{x:h.x+_.x,y:h.y+_.y},...S,{x:g.x+j.x,y:g.y+j.y},r],w,C,k,T]}function GO(e,n,r,a){const o=Math.min(p_(e,n)/2,p_(n,r)/2,a),{x:l,y:c}=n;if(e.x===l&&l===r.x||e.y===c&&c===r.y)return`L${l} ${c}`;if(e.y===c){const h=e.x{let T="";return k>0&&kr.id===n):e[0])||null}function O0(e,n){return e?typeof e=="string"?e:`${n?`${n}__`:""}${Object.keys(e).sort().map(a=>`${a}=${e[a]}`).join("&")}`:""}function XO(e,{id:n,defaultColor:r,defaultMarkerStart:a,defaultMarkerEnd:o}){const l=new Set;return e.reduce((c,d)=>([d.markerStart||a,d.markerEnd||o].forEach(p=>{if(p&&typeof p=="object"){const h=O0(p,n);l.has(h)||(c.push({id:h,color:p.color||r,...p}),l.add(h))}}),c),[]).sort((c,d)=>c.id.localeCompare(d.id))}const j6=1e3,KO=10,pb={nodeOrigin:[0,0],nodeExtent:Vs,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},ZO={...pb,checkEquality:!0};function hb(e,n){const r={...e};for(const a in n)n[a]!==void 0&&(r[a]=n[a]);return r}function QO(e,n,r){const a=hb(pb,r);for(const o of e.values())if(o.parentId)yb(o,e,n,a);else{const l=il(o,a.nodeOrigin),c=fo(o.extent)?o.extent:a.nodeExtent,d=Xi(l,c,Er(o));o.internals.positionAbsolute=d}}function JO(e,n){if(!e.handles)return e.measured?n?.internals.handleBounds:void 0;const r=[],a=[];for(const o of e.handles){const l={id:o.id,width:o.width??1,height:o.height??1,nodeId:e.id,x:o.x,y:o.y,position:o.position,type:o.type};o.type==="source"?r.push(l):o.type==="target"&&a.push(l)}return{source:r,target:a}}function gb(e){return e==="manual"}function D0(e,n,r,a={}){const o=hb(ZO,a),l={i:0},c=new Map(n),d=o?.elevateNodesOnSelect&&!gb(o.zIndexMode)?j6:0;let p=e.length>0;n.clear(),r.clear();for(const h of e){let g=c.get(h.id);if(o.checkEquality&&h===g?.internals.userNode)n.set(h.id,g);else{const y=il(h,o.nodeOrigin),m=fo(h.extent)?h.extent:o.nodeExtent,b=Xi(y,m,Er(h));g={...o.defaults,...h,measured:{width:h.measured?.width,height:h.measured?.height},internals:{positionAbsolute:b,handleBounds:JO(h,g),z:T6(h,d,o.zIndexMode),userNode:h}},n.set(h.id,g)}(g.measured===void 0||g.measured.width===void 0||g.measured.height===void 0)&&!g.hidden&&(p=!1),h.parentId&&yb(g,n,r,a,l)}return p}function eD(e,n){if(!e.parentId)return;const r=n.get(e.parentId);r?r.set(e.id,e):n.set(e.parentId,new Map([[e.id,e]]))}function yb(e,n,r,a,o){const{elevateNodesOnSelect:l,nodeOrigin:c,nodeExtent:d,zIndexMode:p}=hb(pb,a),h=e.parentId,g=n.get(h);if(!g){console.warn(`Parent node ${h} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}eD(e,r),o&&!g.parentId&&g.internals.rootParentIndex===void 0&&p==="auto"&&(g.internals.rootParentIndex=++o.i,g.internals.z=g.internals.z+o.i*KO),o&&g.internals.rootParentIndex!==void 0&&(o.i=g.internals.rootParentIndex);const y=l&&!gb(p)?j6:0,{x:m,y:b,z:S}=tD(e,g,c,d,y,p),{positionAbsolute:w}=e.internals,C=m!==w.x||b!==w.y;(C||S!==e.internals.z)&&n.set(e.id,{...e,internals:{...e.internals,positionAbsolute:C?{x:m,y:b}:w,z:S}})}function T6(e,n,r){const a=Rn(e.zIndex)?e.zIndex:0;return gb(r)?a:a+(e.selected?n:0)}function tD(e,n,r,a,o,l){const{x:c,y:d}=n.internals.positionAbsolute,p=Er(e),h=il(e,r),g=fo(e.extent)?Xi(h,e.extent,p):h;let y=Xi({x:c+g.x,y:d+g.y},a,p);e.extent==="parent"&&(y=g6(y,p,n));const m=T6(e,o,l),b=n.internals.z??0;return{x:y.x,y:y.y,z:b>=m?b+1:m}}function mb(e,n,r,a=[0,0]){const o=[],l=new Map;for(const c of e){const d=n.get(c.parentId);if(!d)continue;const p=l.get(c.parentId)?.expandedRect??uo(d),h=m6(p,c.rect);l.set(c.parentId,{expandedRect:h,parent:d})}return l.size>0&&l.forEach(({expandedRect:c,parent:d},p)=>{const h=d.internals.positionAbsolute,g=Er(d),y=d.origin??a,m=c.x0||b>0||C||_)&&(o.push({id:p,type:"position",position:{x:d.position.x-m+C,y:d.position.y-b+_}}),r.get(p)?.forEach(j=>{e.some(k=>k.id===j.id)||o.push({id:j.id,type:"position",position:{x:j.position.x+m,y:j.position.y+b}})})),(g.width0){const b=mb(m,n,r,o);h.push(...b)}return{changes:h,updatedInternals:p}}async function rD({delta:e,panZoom:n,transform:r,translateExtent:a,width:o,height:l}){if(!n||!e.x&&!e.y)return Promise.resolve(!1);const c=await n.setViewportConstrained({x:r[0]+e.x,y:r[1]+e.y,zoom:r[2]},[[0,0],[o,l]],a),d=!!c&&(c.x!==r[0]||c.y!==r[1]||c.k!==r[2]);return Promise.resolve(d)}function m_(e,n,r,a,o,l){let c=o;const d=a.get(c)||new Map;a.set(c,d.set(r,n)),c=`${o}-${e}`;const p=a.get(c)||new Map;if(a.set(c,p.set(r,n)),l){c=`${o}-${e}-${l}`;const h=a.get(c)||new Map;a.set(c,h.set(r,n))}}function A6(e,n,r){e.clear(),n.clear();for(const a of r){const{source:o,target:l,sourceHandle:c=null,targetHandle:d=null}=a,p={edgeId:a.id,source:o,target:l,sourceHandle:c,targetHandle:d},h=`${o}-${c}--${l}-${d}`,g=`${l}-${d}--${o}-${c}`;m_("source",p,g,e,o,c),m_("target",p,h,e,l,d),n.set(a.id,a)}}function R6(e,n){if(!e.parentId)return!1;const r=n.get(e.parentId);return r?r.selected?!0:R6(r,n):!1}function v_(e,n,r){let a=e;do{if(a?.matches?.(n))return!0;if(a===r)return!1;a=a?.parentElement}while(a);return!1}function iD(e,n,r,a){const o=new Map;for(const[l,c]of e)if((c.selected||c.id===a)&&(!c.parentId||!R6(c,e))&&(c.draggable||n&&typeof c.draggable>"u")){const d=e.get(l);d&&o.set(l,{id:l,position:d.position||{x:0,y:0},distance:{x:r.x-d.internals.positionAbsolute.x,y:r.y-d.internals.positionAbsolute.y},extent:d.extent,parentId:d.parentId,origin:d.origin,expandParent:d.expandParent,internals:{positionAbsolute:d.internals.positionAbsolute||{x:0,y:0}},measured:{width:d.measured.width??0,height:d.measured.height??0}})}return o}function Ip({nodeId:e,dragItems:n,nodeLookup:r,dragging:a=!0}){const o=[];for(const[c,d]of n){const p=r.get(c)?.internals.userNode;p&&o.push({...p,position:d.position,dragging:a})}if(!e)return[o[0],o];const l=r.get(e)?.internals.userNode;return[l?{...l,position:n.get(e)?.position||l.position,dragging:a}:o[0],o]}function aD({dragItems:e,snapGrid:n,x:r,y:a}){const o=e.values().next().value;if(!o)return null;const l={x:r-o.distance.x,y:a-o.distance.y},c=ol(l,n);return{x:c.x-l.x,y:c.y-l.y}}function oD({onNodeMouseDown:e,getStoreItems:n,onDragStart:r,onDrag:a,onDragStop:o}){let l={x:null,y:null},c=0,d=new Map,p=!1,h={x:0,y:0},g=null,y=!1,m=null,b=!1,S=!1,w=null;function C({noDragClassName:j,handleSelector:k,domNode:T,isSelectable:E,nodeId:z,nodeClickDistance:A=0}){m=un(T);function M({x:I,y:F}){const{nodeLookup:U,nodeExtent:B,snapGrid:D,snapToGrid:q,nodeOrigin:$,onNodeDrag:K,onSelectionDrag:ne,onError:V,updateNodePositions:W}=n();l={x:I,y:F};let ee=!1;const G=d.size>1,X=G&&B?N0(al(d)):null,Q=G&&q?aD({dragItems:d,snapGrid:D,x:I,y:F}):null;for(const[ie,se]of d){if(!U.has(ie))continue;let he={x:I-se.distance.x,y:F-se.distance.y};q&&(he=Q?{x:Math.round(he.x+Q.x),y:Math.round(he.y+Q.y)}:ol(he,D));let ye=null;if(G&&B&&!se.extent&&X){const{positionAbsolute:xe}=se.internals,ke=xe.x-X.x+B[0][0],ae=xe.x+se.measured.width-X.x2+B[1][0],pe=xe.y-X.y+B[0][1],ge=xe.y+se.measured.height-X.y2+B[1][1];ye=[[ke,pe],[ae,ge]]}const{position:be,positionAbsolute:we}=h6({nodeId:ie,nextPosition:he,nodeLookup:U,nodeExtent:ye||B,nodeOrigin:$,onError:V});ee=ee||se.position.x!==be.x||se.position.y!==be.y,se.position=be,se.internals.positionAbsolute=we}if(S=S||ee,!!ee&&(W(d,!0),w&&(a||K||!z&&ne))){const[ie,se]=Ip({nodeId:z,dragItems:d,nodeLookup:U});a?.(w,d,ie,se),K?.(w,ie,se),z||ne?.(w,se)}}async function O(){if(!g)return;const{transform:I,panBy:F,autoPanSpeed:U,autoPanOnNodeDrag:B}=n();if(!B){p=!1,cancelAnimationFrame(c);return}const[D,q]=y6(h,g,U);(D!==0||q!==0)&&(l.x=(l.x??0)-D/I[2],l.y=(l.y??0)-q/I[2],await F({x:D,y:q})&&M(l)),c=requestAnimationFrame(O)}function P(I){const{nodeLookup:F,multiSelectionActive:U,nodesDraggable:B,transform:D,snapGrid:q,snapToGrid:$,selectNodesOnDrag:K,onNodeDragStart:ne,onSelectionDragStart:V,unselectNodesAndEdges:W}=n();y=!0,(!K||!E)&&!U&&z&&(F.get(z)?.selected||W()),E&&K&&z&&e?.(z);const ee=Ls(I.sourceEvent,{transform:D,snapGrid:q,snapToGrid:$,containerBounds:g});if(l=ee,d=iD(F,B,ee,z),d.size>0&&(r||ne||!z&&V)){const[G,X]=Ip({nodeId:z,dragItems:d,nodeLookup:F});r?.(I.sourceEvent,d,G,X),ne?.(I.sourceEvent,G,X),z||V?.(I.sourceEvent,X)}}const L=GT().clickDistance(A).on("start",I=>{const{domNode:F,nodeDragThreshold:U,transform:B,snapGrid:D,snapToGrid:q}=n();g=F?.getBoundingClientRect()||null,b=!1,S=!1,w=I.sourceEvent,U===0&&P(I),l=Ls(I.sourceEvent,{transform:B,snapGrid:D,snapToGrid:q,containerBounds:g}),h=zn(I.sourceEvent,g)}).on("drag",I=>{const{autoPanOnNodeDrag:F,transform:U,snapGrid:B,snapToGrid:D,nodeDragThreshold:q,nodeLookup:$}=n(),K=Ls(I.sourceEvent,{transform:U,snapGrid:B,snapToGrid:D,containerBounds:g});if(w=I.sourceEvent,(I.sourceEvent.type==="touchmove"&&I.sourceEvent.touches.length>1||z&&!$.has(z))&&(b=!0),!b){if(!p&&F&&y&&(p=!0,O()),!y){const ne=zn(I.sourceEvent,g),V=ne.x-h.x,W=ne.y-h.y;Math.sqrt(V*V+W*W)>q&&P(I)}(l.x!==K.xSnapped||l.y!==K.ySnapped)&&d&&y&&(h=zn(I.sourceEvent,g),M(K))}}).on("end",I=>{if(!(!y||b)&&(p=!1,y=!1,cancelAnimationFrame(c),d.size>0)){const{nodeLookup:F,updateNodePositions:U,onNodeDragStop:B,onSelectionDragStop:D}=n();if(S&&(U(d,!1),S=!1),o||B||!z&&D){const[q,$]=Ip({nodeId:z,dragItems:d,nodeLookup:F,dragging:!1});o?.(I.sourceEvent,d,q,$),B?.(I.sourceEvent,q,$),z||D?.(I.sourceEvent,$)}}}).filter(I=>{const F=I.target;return!I.button&&(!j||!v_(F,`.${j}`,T))&&(!k||v_(F,k,T))});m.call(L)}function _(){m?.on(".drag",null)}return{update:C,destroy:_}}function sD(e,n,r){const a=[],o={x:e.x-r,y:e.y-r,width:r*2,height:r*2};for(const l of n.values())Gs(o,uo(l))>0&&a.push(l);return a}const lD=250;function cD(e,n,r,a){let o=[],l=1/0;const c=sD(e,r,n+lD);for(const d of c){const p=[...d.internals.handleBounds?.source??[],...d.internals.handleBounds?.target??[]];for(const h of p){if(a.nodeId===h.nodeId&&a.type===h.type&&a.id===h.id)continue;const{x:g,y}=Ki(d,h,h.position,!0),m=Math.sqrt(Math.pow(g-e.x,2)+Math.pow(y-e.y,2));m>n||(m1){const d=a.type==="source"?"target":"source";return o.find(p=>p.type===d)??o[0]}return o[0]}function z6(e,n,r,a,o,l=!1){const c=a.get(e);if(!c)return null;const d=o==="strict"?c.internals.handleBounds?.[n]:[...c.internals.handleBounds?.source??[],...c.internals.handleBounds?.target??[]],p=(r?d?.find(h=>h.id===r):d?.[0])??null;return p&&l?{...p,...Ki(c,p,p.position,!0)}:p}function N6(e,n){return e||(n?.classList.contains("target")?"target":n?.classList.contains("source")?"source":null)}function uD(e,n){let r=null;return n?r=!0:e&&!n&&(r=!1),r}const M6=()=>!0;function dD(e,{connectionMode:n,connectionRadius:r,handleId:a,nodeId:o,edgeUpdaterType:l,isTarget:c,domNode:d,nodeLookup:p,lib:h,autoPanOnConnect:g,flowId:y,panBy:m,cancelConnection:b,onConnectStart:S,onConnect:w,onConnectEnd:C,isValidConnection:_=M6,onReconnectEnd:j,updateConnection:k,getTransform:T,getFromHandle:E,autoPanSpeed:z,dragThreshold:A=1,handleDomNode:M}){const O=x6(e.target);let P=0,L;const{x:I,y:F}=zn(e),U=N6(l,M),B=d?.getBoundingClientRect();let D=!1;if(!B||!U)return;const q=z6(o,U,a,p,n);if(!q)return;let $=zn(e,B),K=!1,ne=null,V=!1,W=null;function ee(){if(!g||!B)return;const[be,we]=y6($,B,z);m({x:be,y:we}),P=requestAnimationFrame(ee)}const G={...q,nodeId:o,type:U,position:q.position},X=p.get(o);let ie={inProgress:!0,isValid:null,from:Ki(X,G,me.Left,!0),fromHandle:G,fromPosition:G.position,fromNode:X,to:$,toHandle:null,toPosition:o_[G.position],toNode:null,pointer:$};function se(){D=!0,k(ie),S?.(e,{nodeId:o,handleId:a,handleType:U})}A===0&&se();function he(be){if(!D){const{x:ge,y:je}=zn(be),Ae=ge-I,ze=je-F;if(!(Ae*Ae+ze*ze>A*A))return;se()}if(!E()||!G){ye(be);return}const we=T();$=zn(be,B),L=cD(sl($,we,!1,[1,1]),r,p,G),K||(ee(),K=!0);const xe=O6(be,{handle:L,connectionMode:n,fromNodeId:o,fromHandleId:a,fromType:c?"target":"source",isValidConnection:_,doc:O,lib:h,flowId:y,nodeLookup:p});W=xe.handleDomNode,ne=xe.connection,V=uD(!!L,xe.isValid);const ke=p.get(o),ae=ke?Ki(ke,G,me.Left,!0):ie.from,pe={...ie,from:ae,isValid:V,to:xe.toHandle&&V?Su({x:xe.toHandle.x,y:xe.toHandle.y},we):$,toHandle:xe.toHandle,toPosition:V&&xe.toHandle?xe.toHandle.position:o_[G.position],toNode:xe.toHandle?p.get(xe.toHandle.nodeId):null,pointer:$};k(pe),ie=pe}function ye(be){if(!("touches"in be&&be.touches.length>0)){if(D){(L||W)&&ne&&V&&w?.(ne);const{inProgress:we,...xe}=ie,ke={...xe,toPosition:ie.toHandle?ie.toPosition:null};C?.(be,ke),l&&j?.(be,ke)}b(),cancelAnimationFrame(P),K=!1,V=!1,ne=null,W=null,O.removeEventListener("mousemove",he),O.removeEventListener("mouseup",ye),O.removeEventListener("touchmove",he),O.removeEventListener("touchend",ye)}}O.addEventListener("mousemove",he),O.addEventListener("mouseup",ye),O.addEventListener("touchmove",he),O.addEventListener("touchend",ye)}function O6(e,{handle:n,connectionMode:r,fromNodeId:a,fromHandleId:o,fromType:l,doc:c,lib:d,flowId:p,isValidConnection:h=M6,nodeLookup:g}){const y=l==="target",m=n?c.querySelector(`.${d}-flow__handle[data-id="${p}-${n?.nodeId}-${n?.id}-${n?.type}"]`):null,{x:b,y:S}=zn(e),w=c.elementFromPoint(b,S),C=w?.classList.contains(`${d}-flow__handle`)?w:m,_={handleDomNode:C,isValid:!1,connection:null,toHandle:null};if(C){const j=N6(void 0,C),k=C.getAttribute("data-nodeid"),T=C.getAttribute("data-handleid"),E=C.classList.contains("connectable"),z=C.classList.contains("connectableend");if(!k||!j)return _;const A={source:y?k:a,sourceHandle:y?T:o,target:y?a:k,targetHandle:y?o:T};_.connection=A;const O=E&&z&&(r===lo.Strict?y&&j==="source"||!y&&j==="target":k!==a||T!==o);_.isValid=O&&h(A),_.toHandle=z6(k,j,T,g,r,!0)}return _}const q0={onPointerDown:dD,isValid:O6};function fD({domNode:e,panZoom:n,getTransform:r,getViewScale:a}){const o=un(e);function l({translateExtent:d,width:p,height:h,zoomStep:g=1,pannable:y=!0,zoomable:m=!0,inversePan:b=!1}){const S=k=>{if(k.sourceEvent.type!=="wheel"||!n)return;const T=r(),E=k.sourceEvent.ctrlKey&&Ys()?10:1,z=-k.sourceEvent.deltaY*(k.sourceEvent.deltaMode===1?.05:k.sourceEvent.deltaMode?1:.002)*g,A=T[2]*Math.pow(2,z*E);n.scaleTo(A)};let w=[0,0];const C=k=>{(k.sourceEvent.type==="mousedown"||k.sourceEvent.type==="touchstart")&&(w=[k.sourceEvent.clientX??k.sourceEvent.touches[0].clientX,k.sourceEvent.clientY??k.sourceEvent.touches[0].clientY])},_=k=>{const T=r();if(k.sourceEvent.type!=="mousemove"&&k.sourceEvent.type!=="touchmove"||!n)return;const E=[k.sourceEvent.clientX??k.sourceEvent.touches[0].clientX,k.sourceEvent.clientY??k.sourceEvent.touches[0].clientY],z=[E[0]-w[0],E[1]-w[1]];w=E;const A=a()*Math.max(T[2],Math.log(T[2]))*(b?-1:1),M={x:T[0]-z[0]*A,y:T[1]-z[1]*A},O=[[0,0],[p,h]];n.setViewportConstrained({x:M.x,y:M.y,zoom:T[2]},O,d)},j=l6().on("start",C).on("zoom",y?_:null).on("zoom.wheel",m?S:null);o.call(j,{})}function c(){o.on("zoom",null)}return{update:l,destroy:c,pointer:Tn}}const Uu=e=>({x:e.x,y:e.y,zoom:e.k}),Lp=({x:e,y:n,zoom:r})=>Lu.translate(e,n).scale(r),Ja=(e,n)=>e.target.closest(`.${n}`),D6=(e,n)=>n===2&&Array.isArray(e)&&e.includes(2),pD=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,Bp=(e,n=0,r=pD,a=()=>{})=>{const o=typeof n=="number"&&n>0;return o||a(),o?e.transition().duration(n).ease(r).on("end",a):e},q6=e=>{const n=e.ctrlKey&&Ys()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*n};function hD({zoomPanValues:e,noWheelClassName:n,d3Selection:r,d3Zoom:a,panOnScrollMode:o,panOnScrollSpeed:l,zoomOnPinch:c,onPanZoomStart:d,onPanZoom:p,onPanZoomEnd:h}){return g=>{if(Ja(g,n))return g.ctrlKey&&g.preventDefault(),!1;g.preventDefault(),g.stopImmediatePropagation();const y=r.property("__zoom").k||1;if(g.ctrlKey&&c){const C=Tn(g),_=q6(g),j=y*Math.pow(2,_);a.scaleTo(r,j,C,g);return}const m=g.deltaMode===1?20:1;let b=o===Pi.Vertical?0:g.deltaX*m,S=o===Pi.Horizontal?0:g.deltaY*m;!Ys()&&g.shiftKey&&o!==Pi.Vertical&&(b=g.deltaY*m,S=0),a.translateBy(r,-(b/y)*l,-(S/y)*l,{internal:!0});const w=Uu(r.property("__zoom"));clearTimeout(e.panScrollTimeout),e.isPanScrolling?(p?.(g,w),e.panScrollTimeout=setTimeout(()=>{h?.(g,w),e.isPanScrolling=!1},150)):(e.isPanScrolling=!0,d?.(g,w))}}function gD({noWheelClassName:e,preventScrolling:n,d3ZoomHandler:r}){return function(a,o){const l=a.type==="wheel",c=!n&&l&&!a.ctrlKey,d=Ja(a,e);if(a.ctrlKey&&l&&d&&a.preventDefault(),c||d)return null;a.preventDefault(),r.call(this,a,o)}}function yD({zoomPanValues:e,onDraggingChange:n,onPanZoomStart:r}){return a=>{if(a.sourceEvent?.internal)return;const o=Uu(a.transform);e.mouseButton=a.sourceEvent?.button||0,e.isZoomingOrPanning=!0,e.prevViewport=o,a.sourceEvent?.type==="mousedown"&&n(!0),r&&r?.(a.sourceEvent,o)}}function mD({zoomPanValues:e,panOnDrag:n,onPaneContextMenu:r,onTransformChange:a,onPanZoom:o}){return l=>{e.usedRightMouseButton=!!(r&&D6(n,e.mouseButton??0)),l.sourceEvent?.sync||a([l.transform.x,l.transform.y,l.transform.k]),o&&!l.sourceEvent?.internal&&o?.(l.sourceEvent,Uu(l.transform))}}function vD({zoomPanValues:e,panOnDrag:n,panOnScroll:r,onDraggingChange:a,onPanZoomEnd:o,onPaneContextMenu:l}){return c=>{if(!c.sourceEvent?.internal&&(e.isZoomingOrPanning=!1,l&&D6(n,e.mouseButton??0)&&!e.usedRightMouseButton&&c.sourceEvent&&l(c.sourceEvent),e.usedRightMouseButton=!1,a(!1),o)){const d=Uu(c.transform);e.prevViewport=d,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{o?.(c.sourceEvent,d)},r?150:0)}}}function bD({zoomActivationKeyPressed:e,zoomOnScroll:n,zoomOnPinch:r,panOnDrag:a,panOnScroll:o,zoomOnDoubleClick:l,userSelectionActive:c,noWheelClassName:d,noPanClassName:p,lib:h,connectionInProgress:g}){return y=>{const m=e||n,b=r&&y.ctrlKey,S=y.type==="wheel";if(y.button===1&&y.type==="mousedown"&&(Ja(y,`${h}-flow__node`)||Ja(y,`${h}-flow__edge`)))return!0;if(!a&&!m&&!o&&!l&&!r||c||g&&!S||Ja(y,d)&&S||Ja(y,p)&&(!S||o&&S&&!e)||!r&&y.ctrlKey&&S)return!1;if(!r&&y.type==="touchstart"&&y.touches?.length>1)return y.preventDefault(),!1;if(!m&&!o&&!b&&S||!a&&(y.type==="mousedown"||y.type==="touchstart")||Array.isArray(a)&&!a.includes(y.button)&&y.type==="mousedown")return!1;const w=Array.isArray(a)&&a.includes(y.button)||!y.button||y.button<=1;return(!y.ctrlKey||S)&&w}}function xD({domNode:e,minZoom:n,maxZoom:r,translateExtent:a,viewport:o,onPanZoom:l,onPanZoomStart:c,onPanZoomEnd:d,onDraggingChange:p}){const h={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},g=e.getBoundingClientRect(),y=l6().scaleExtent([n,r]).translateExtent(a),m=un(e).call(y);j({x:o.x,y:o.y,zoom:co(o.zoom,n,r)},[[0,0],[g.width,g.height]],a);const b=m.on("wheel.zoom"),S=m.on("dblclick.zoom");y.wheelDelta(q6);function w(L,I){return m?new Promise(F=>{y?.interpolate(I?.interpolate==="linear"?Is:su).transform(Bp(m,I?.duration,I?.ease,()=>F(!0)),L)}):Promise.resolve(!1)}function C({noWheelClassName:L,noPanClassName:I,onPaneContextMenu:F,userSelectionActive:U,panOnScroll:B,panOnDrag:D,panOnScrollMode:q,panOnScrollSpeed:$,preventScrolling:K,zoomOnPinch:ne,zoomOnScroll:V,zoomOnDoubleClick:W,zoomActivationKeyPressed:ee,lib:G,onTransformChange:X,connectionInProgress:Q,paneClickDistance:ie,selectionOnDrag:se}){U&&!h.isZoomingOrPanning&&_();const he=B&&!ee&&!U;y.clickDistance(se?1/0:!Rn(ie)||ie<0?0:ie);const ye=he?hD({zoomPanValues:h,noWheelClassName:L,d3Selection:m,d3Zoom:y,panOnScrollMode:q,panOnScrollSpeed:$,zoomOnPinch:ne,onPanZoomStart:c,onPanZoom:l,onPanZoomEnd:d}):gD({noWheelClassName:L,preventScrolling:K,d3ZoomHandler:b});if(m.on("wheel.zoom",ye,{passive:!1}),!U){const we=yD({zoomPanValues:h,onDraggingChange:p,onPanZoomStart:c});y.on("start",we);const xe=mD({zoomPanValues:h,panOnDrag:D,onPaneContextMenu:!!F,onPanZoom:l,onTransformChange:X});y.on("zoom",xe);const ke=vD({zoomPanValues:h,panOnDrag:D,panOnScroll:B,onPaneContextMenu:F,onPanZoomEnd:d,onDraggingChange:p});y.on("end",ke)}const be=bD({zoomActivationKeyPressed:ee,panOnDrag:D,zoomOnScroll:V,panOnScroll:B,zoomOnDoubleClick:W,zoomOnPinch:ne,userSelectionActive:U,noPanClassName:I,noWheelClassName:L,lib:G,connectionInProgress:Q});y.filter(be),W?m.on("dblclick.zoom",S):m.on("dblclick.zoom",null)}function _(){y.on("zoom",null)}async function j(L,I,F){const U=Lp(L),B=y?.constrain()(U,I,F);return B&&await w(B),new Promise(D=>D(B))}async function k(L,I){const F=Lp(L);return await w(F,I),new Promise(U=>U(F))}function T(L){if(m){const I=Lp(L),F=m.property("__zoom");(F.k!==L.zoom||F.x!==L.x||F.y!==L.y)&&y?.transform(m,I,null,{sync:!0})}}function E(){const L=m?s6(m.node()):{x:0,y:0,k:1};return{x:L.x,y:L.y,zoom:L.k}}function z(L,I){return m?new Promise(F=>{y?.interpolate(I?.interpolate==="linear"?Is:su).scaleTo(Bp(m,I?.duration,I?.ease,()=>F(!0)),L)}):Promise.resolve(!1)}function A(L,I){return m?new Promise(F=>{y?.interpolate(I?.interpolate==="linear"?Is:su).scaleBy(Bp(m,I?.duration,I?.ease,()=>F(!0)),L)}):Promise.resolve(!1)}function M(L){y?.scaleExtent(L)}function O(L){y?.translateExtent(L)}function P(L){const I=!Rn(L)||L<0?0:L;y?.clickDistance(I)}return{update:C,destroy:_,setViewport:k,setViewportConstrained:j,getViewport:E,scaleTo:z,scaleBy:A,setScaleExtent:M,setTranslateExtent:O,syncViewport:T,setClickDistance:P}}var po;(function(e){e.Line="line",e.Handle="handle"})(po||(po={}));function SD({width:e,prevWidth:n,height:r,prevHeight:a,affectsX:o,affectsY:l}){const c=e-n,d=r-a,p=[c>0?1:c<0?-1:0,d>0?1:d<0?-1:0];return c&&o&&(p[0]=p[0]*-1),d&&l&&(p[1]=p[1]*-1),p}function b_(e){const n=e.includes("right")||e.includes("left"),r=e.includes("bottom")||e.includes("top"),a=e.includes("left"),o=e.includes("top");return{isHorizontal:n,isVertical:r,affectsX:a,affectsY:o}}function ii(e,n){return Math.max(0,n-e)}function ai(e,n){return Math.max(0,e-n)}function Wc(e,n,r){return Math.max(0,n-e,e-r)}function x_(e,n){return e?!n:n}function wD(e,n,r,a,o,l,c,d){let{affectsX:p,affectsY:h}=n;const{isHorizontal:g,isVertical:y}=n,m=g&&y,{xSnapped:b,ySnapped:S}=r,{minWidth:w,maxWidth:C,minHeight:_,maxHeight:j}=a,{x:k,y:T,width:E,height:z,aspectRatio:A}=e;let M=Math.floor(g?b-e.pointerX:0),O=Math.floor(y?S-e.pointerY:0);const P=E+(p?-M:M),L=z+(h?-O:O),I=-l[0]*E,F=-l[1]*z;let U=Wc(P,w,C),B=Wc(L,_,j);if(c){let $=0,K=0;p&&M<0?$=ii(k+M+I,c[0][0]):!p&&M>0&&($=ai(k+P+I,c[1][0])),h&&O<0?K=ii(T+O+F,c[0][1]):!h&&O>0&&(K=ai(T+L+F,c[1][1])),U=Math.max(U,$),B=Math.max(B,K)}if(d){let $=0,K=0;p&&M>0?$=ai(k+M,d[0][0]):!p&&M<0&&($=ii(k+P,d[1][0])),h&&O>0?K=ai(T+O,d[0][1]):!h&&O<0&&(K=ii(T+L,d[1][1])),U=Math.max(U,$),B=Math.max(B,K)}if(o){if(g){const $=Wc(P/A,_,j)*A;if(U=Math.max(U,$),c){let K=0;!p&&!h||p&&!h&&m?K=ai(T+F+P/A,c[1][1])*A:K=ii(T+F+(p?M:-M)/A,c[0][1])*A,U=Math.max(U,K)}if(d){let K=0;!p&&!h||p&&!h&&m?K=ii(T+P/A,d[1][1])*A:K=ai(T+(p?M:-M)/A,d[0][1])*A,U=Math.max(U,K)}}if(y){const $=Wc(L*A,w,C)/A;if(B=Math.max(B,$),c){let K=0;!p&&!h||h&&!p&&m?K=ai(k+L*A+I,c[1][0])/A:K=ii(k+(h?O:-O)*A+I,c[0][0])/A,B=Math.max(B,K)}if(d){let K=0;!p&&!h||h&&!p&&m?K=ii(k+L*A,d[1][0])/A:K=ai(k+(h?O:-O)*A,d[0][0])/A,B=Math.max(B,K)}}}O=O+(O<0?B:-B),M=M+(M<0?U:-U),o&&(m?P>L*A?O=(x_(p,h)?-M:M)/A:M=(x_(p,h)?-O:O)*A:g?(O=M/A,h=p):(M=O*A,p=h));const D=p?k+M:k,q=h?T+O:T;return{width:E+(p?-M:M),height:z+(h?-O:O),x:l[0]*M*(p?-1:1)+D,y:l[1]*O*(h?-1:1)+q}}const I6={width:0,height:0,x:0,y:0},_D={...I6,pointerX:0,pointerY:0,aspectRatio:1};function kD(e){return[[0,0],[e.measured.width,e.measured.height]]}function CD(e,n,r){const a=n.position.x+e.position.x,o=n.position.y+e.position.y,l=e.measured.width??0,c=e.measured.height??0,d=r[0]*l,p=r[1]*c;return[[a-d,o-p],[a+l-d,o+c-p]]}function ED({domNode:e,nodeId:n,getStoreItems:r,onChange:a,onEnd:o}){const l=un(e);let c={controlDirection:b_("bottom-right"),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function d({controlPosition:h,boundaries:g,keepAspectRatio:y,resizeDirection:m,onResizeStart:b,onResize:S,onResizeEnd:w,shouldResize:C}){let _={...I6},j={..._D};c={boundaries:g,resizeDirection:m,keepAspectRatio:y,controlDirection:b_(h)};let k,T=null,E=[],z,A,M,O=!1;const P=GT().on("start",L=>{const{nodeLookup:I,transform:F,snapGrid:U,snapToGrid:B,nodeOrigin:D,paneDomNode:q}=r();if(k=I.get(n),!k)return;T=q?.getBoundingClientRect()??null;const{xSnapped:$,ySnapped:K}=Ls(L.sourceEvent,{transform:F,snapGrid:U,snapToGrid:B,containerBounds:T});_={width:k.measured.width??0,height:k.measured.height??0,x:k.position.x??0,y:k.position.y??0},j={..._,pointerX:$,pointerY:K,aspectRatio:_.width/_.height},z=void 0,k.parentId&&(k.extent==="parent"||k.expandParent)&&(z=I.get(k.parentId),A=z&&k.extent==="parent"?kD(z):void 0),E=[],M=void 0;for(const[ne,V]of I)if(V.parentId===n&&(E.push({id:ne,position:{...V.position},extent:V.extent}),V.extent==="parent"||V.expandParent)){const W=CD(V,k,V.origin??D);M?M=[[Math.min(W[0][0],M[0][0]),Math.min(W[0][1],M[0][1])],[Math.max(W[1][0],M[1][0]),Math.max(W[1][1],M[1][1])]]:M=W}b?.(L,{..._})}).on("drag",L=>{const{transform:I,snapGrid:F,snapToGrid:U,nodeOrigin:B}=r(),D=Ls(L.sourceEvent,{transform:I,snapGrid:F,snapToGrid:U,containerBounds:T}),q=[];if(!k)return;const{x:$,y:K,width:ne,height:V}=_,W={},ee=k.origin??B,{width:G,height:X,x:Q,y:ie}=wD(j,c.controlDirection,D,c.boundaries,c.keepAspectRatio,ee,A,M),se=G!==ne,he=X!==V,ye=Q!==$&&se,be=ie!==K&&he;if(!ye&&!be&&!se&&!he)return;if((ye||be||ee[0]===1||ee[1]===1)&&(W.x=ye?Q:_.x,W.y=be?ie:_.y,_.x=W.x,_.y=W.y,E.length>0)){const ae=Q-$,pe=ie-K;for(const ge of E)ge.position={x:ge.position.x-ae+ee[0]*(G-ne),y:ge.position.y-pe+ee[1]*(X-V)},q.push(ge)}if((se||he)&&(W.width=se&&(!c.resizeDirection||c.resizeDirection==="horizontal")?G:_.width,W.height=he&&(!c.resizeDirection||c.resizeDirection==="vertical")?X:_.height,_.width=W.width,_.height=W.height),z&&k.expandParent){const ae=ee[0]*(W.width??0);W.x&&W.x{O&&(w?.(L,{..._}),o?.({..._}),O=!1)});l.call(P)}function p(){l.on(".drag",null)}return{update:d,destroy:p}}var Hp={exports:{}},Up={},Fp={exports:{}},Pp={};var S_;function jD(){if(S_)return Pp;S_=1;var e=el();function n(y,m){return y===m&&(y!==0||1/y===1/m)||y!==y&&m!==m}var r=typeof Object.is=="function"?Object.is:n,a=e.useState,o=e.useEffect,l=e.useLayoutEffect,c=e.useDebugValue;function d(y,m){var b=m(),S=a({inst:{value:b,getSnapshot:m}}),w=S[0].inst,C=S[1];return l(function(){w.value=b,w.getSnapshot=m,p(w)&&C({inst:w})},[y,b,m]),o(function(){return p(w)&&C({inst:w}),y(function(){p(w)&&C({inst:w})})},[y]),c(b),b}function p(y){var m=y.getSnapshot;y=y.value;try{var b=m();return!r(y,b)}catch{return!0}}function h(y,m){return m()}var g=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?h:d;return Pp.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:g,Pp}var w_;function TD(){return w_||(w_=1,Fp.exports=jD()),Fp.exports}var __;function AD(){if(__)return Up;__=1;var e=el(),n=TD();function r(h,g){return h===g&&(h!==0||1/h===1/g)||h!==h&&g!==g}var a=typeof Object.is=="function"?Object.is:r,o=n.useSyncExternalStore,l=e.useRef,c=e.useEffect,d=e.useMemo,p=e.useDebugValue;return Up.useSyncExternalStoreWithSelector=function(h,g,y,m,b){var S=l(null);if(S.current===null){var w={hasValue:!1,value:null};S.current=w}else w=S.current;S=d(function(){function _(z){if(!j){if(j=!0,k=z,z=m(z),b!==void 0&&w.hasValue){var A=w.value;if(b(A,z))return T=A}return T=z}if(A=T,a(k,z))return A;var M=m(z);return b!==void 0&&b(A,M)?(k=z,A):(k=z,T=M)}var j=!1,k,T,E=y===void 0?null:y;return[function(){return _(g())},E===null?void 0:function(){return _(E())}]},[g,y,m,b]);var C=o(h,S[0],S[1]);return c(function(){w.hasValue=!0,w.value=C},[C]),p(C),C},Up}var k_;function RD(){return k_||(k_=1,Hp.exports=AD()),Hp.exports}var zD=RD();const ND=eb(zD),{useSyncExternalStoreWithSelector:MD}=ND,OD=e=>e;function L6(e,n=OD,r){const a=MD(e.subscribe,e.getState,e.getInitialState,n,r);return js.useDebugValue(a),a}const C_=(e,n)=>{const r=NT(e),a=(o,l=n)=>L6(r,o,l);return Object.assign(a,r),a},DD=((e,n)=>e?C_(e,n):C_),E_=e=>Symbol.iterator in e,j_=e=>"entries"in e,T_=(e,n)=>{const r=e instanceof Map?e:new Map(e.entries()),a=n instanceof Map?n:new Map(n.entries());if(r.size!==a.size)return!1;for(const[o,l]of r)if(!a.has(o)||!Object.is(l,a.get(o)))return!1;return!0},qD=(e,n)=>{const r=e[Symbol.iterator](),a=n[Symbol.iterator]();let o=r.next(),l=a.next();for(;!o.done&&!l.done;){if(!Object.is(o.value,l.value))return!1;o=r.next(),l=a.next()}return!!o.done&&!!l.done};function nt(e,n){return Object.is(e,n)?!0:typeof e!="object"||e===null||typeof n!="object"||n===null||Object.getPrototypeOf(e)!==Object.getPrototypeOf(n)?!1:E_(e)&&E_(n)?j_(e)&&j_(n)?T_(e,n):qD(e,n):T_({entries:()=>Object.entries(e)},{entries:()=>Object.entries(n)})}var ID=RT();const Fu=N.createContext(null),LD=Fu.Provider,B6=Yn.error001();function Be(e,n){const r=N.useContext(Fu);if(r===null)throw new Error(B6);return L6(r,e,n)}function rt(){const e=N.useContext(Fu);if(e===null)throw new Error(B6);return N.useMemo(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe}),[e])}const A_={display:"none"},BD={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},H6="react-flow__node-desc",U6="react-flow__edge-desc",HD="react-flow__aria-live",UD=e=>e.ariaLiveMessage,FD=e=>e.ariaLabelConfig;function PD({rfId:e}){const n=Be(UD);return u.jsx("div",{id:`${HD}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:BD,children:n})}function $D({rfId:e,disableKeyboardA11y:n}){const r=Be(FD);return u.jsxs(u.Fragment,{children:[u.jsx("div",{id:`${H6}-${e}`,style:A_,children:n?r["node.a11yDescription.default"]:r["node.a11yDescription.keyboardDisabled"]}),u.jsx("div",{id:`${U6}-${e}`,style:A_,children:r["edge.a11yDescription.default"]}),!n&&u.jsx(PD,{rfId:e})]})}const Pu=N.forwardRef(({position:e="top-left",children:n,className:r,style:a,...o},l)=>{const c=`${e}`.split("-");return u.jsx("div",{className:xt(["react-flow__panel",r,...c]),style:a,ref:l,...o,children:n})});Pu.displayName="Panel";function VD({proOptions:e,position:n="bottom-right"}){return e?.hideAttribution?null:u.jsx(Pu,{position:n,className:"react-flow__attribution","data-message":"Please only hide this attribution when you are subscribed to React Flow Pro: https://pro.reactflow.dev",children:u.jsx("a",{href:"https://reactflow.dev",target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution",children:"React Flow"})})}const WD=e=>{const n=[],r=[];for(const[,a]of e.nodeLookup)a.selected&&n.push(a.internals.userNode);for(const[,a]of e.edgeLookup)a.selected&&r.push(a);return{selectedNodes:n,selectedEdges:r}},Gc=e=>e.id;function GD(e,n){return nt(e.selectedNodes.map(Gc),n.selectedNodes.map(Gc))&&nt(e.selectedEdges.map(Gc),n.selectedEdges.map(Gc))}function YD({onSelectionChange:e}){const n=rt(),{selectedNodes:r,selectedEdges:a}=Be(WD,GD);return N.useEffect(()=>{const o={nodes:r,edges:a};e?.(o),n.getState().onSelectionChangeHandlers.forEach(l=>l(o))},[r,a,e]),null}const XD=e=>!!e.onSelectionChangeHandlers;function KD({onSelectionChange:e}){const n=Be(XD);return e||n?u.jsx(YD,{onSelectionChange:e}):null}const F6=[0,0],ZD={x:0,y:0,zoom:1},QD=["nodes","edges","defaultNodes","defaultEdges","onConnect","onConnectStart","onConnectEnd","onClickConnectStart","onClickConnectEnd","nodesDraggable","autoPanOnNodeFocus","nodesConnectable","nodesFocusable","edgesFocusable","edgesReconnectable","elevateNodesOnSelect","elevateEdgesOnSelect","minZoom","maxZoom","nodeExtent","onNodesChange","onEdgesChange","elementsSelectable","connectionMode","snapGrid","snapToGrid","translateExtent","connectOnClick","defaultEdgeOptions","fitView","fitViewOptions","onNodesDelete","onEdgesDelete","onDelete","onNodeDrag","onNodeDragStart","onNodeDragStop","onSelectionDrag","onSelectionDragStart","onSelectionDragStop","onMoveStart","onMove","onMoveEnd","noPanClassName","nodeOrigin","autoPanOnConnect","autoPanOnNodeDrag","onError","connectionRadius","isValidConnection","selectNodesOnDrag","nodeDragThreshold","connectionDragThreshold","onBeforeDelete","debug","autoPanSpeed","ariaLabelConfig","zIndexMode"],R_=[...QD,"rfId"],JD=e=>({setNodes:e.setNodes,setEdges:e.setEdges,setMinZoom:e.setMinZoom,setMaxZoom:e.setMaxZoom,setTranslateExtent:e.setTranslateExtent,setNodeExtent:e.setNodeExtent,reset:e.reset,setDefaultNodesAndEdges:e.setDefaultNodesAndEdges}),z_={translateExtent:Vs,nodeOrigin:F6,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1"};function eq(e){const{setNodes:n,setEdges:r,setMinZoom:a,setMaxZoom:o,setTranslateExtent:l,setNodeExtent:c,reset:d,setDefaultNodesAndEdges:p}=Be(JD,nt),h=rt();N.useEffect(()=>(p(e.defaultNodes,e.defaultEdges),()=>{g.current=z_,d()}),[]);const g=N.useRef(z_);return N.useEffect(()=>{for(const y of R_){const m=e[y],b=g.current[y];m!==b&&(typeof e[y]>"u"||(y==="nodes"?n(m):y==="edges"?r(m):y==="minZoom"?a(m):y==="maxZoom"?o(m):y==="translateExtent"?l(m):y==="nodeExtent"?c(m):y==="ariaLabelConfig"?h.setState({ariaLabelConfig:BO(m)}):y==="fitView"?h.setState({fitViewQueued:m}):y==="fitViewOptions"?h.setState({fitViewOptions:m}):h.setState({[y]:m})))}g.current=e},R_.map(y=>e[y])),null}function N_(){return typeof window>"u"||!window.matchMedia?null:window.matchMedia("(prefers-color-scheme: dark)")}function tq(e){const[n,r]=N.useState(e==="system"?null:e);return N.useEffect(()=>{if(e!=="system"){r(e);return}const a=N_(),o=()=>r(a?.matches?"dark":"light");return o(),a?.addEventListener("change",o),()=>{a?.removeEventListener("change",o)}},[e]),n!==null?n:N_()?.matches?"dark":"light"}const M_=typeof document<"u"?document:null;function Xs(e=null,n={target:M_,actInsideInputWithModifier:!0}){const[r,a]=N.useState(!1),o=N.useRef(!1),l=N.useRef(new Set([])),[c,d]=N.useMemo(()=>{if(e!==null){const h=(Array.isArray(e)?e:[e]).filter(y=>typeof y=="string").map(y=>y.replace("+",` +`).replace(` + +`,` ++`).split(` +`)),g=h.reduce((y,m)=>y.concat(...m),[]);return[h,g]}return[[],[]]},[e]);return N.useEffect(()=>{const p=n?.target??M_,h=n?.actInsideInputWithModifier??!0;if(e!==null){const g=b=>{if(o.current=b.ctrlKey||b.metaKey||b.shiftKey||b.altKey,(!o.current||o.current&&!h)&&S6(b))return!1;const w=D_(b.code,d);if(l.current.add(b[w]),O_(c,l.current,!1)){const C=b.composedPath?.()?.[0]||b.target,_=C?.nodeName==="BUTTON"||C?.nodeName==="A";n.preventDefault!==!1&&(o.current||!_)&&b.preventDefault(),a(!0)}},y=b=>{const S=D_(b.code,d);O_(c,l.current,!0)?(a(!1),l.current.clear()):l.current.delete(b[S]),b.key==="Meta"&&l.current.clear(),o.current=!1},m=()=>{l.current.clear(),a(!1)};return p?.addEventListener("keydown",g),p?.addEventListener("keyup",y),window.addEventListener("blur",m),window.addEventListener("contextmenu",m),()=>{p?.removeEventListener("keydown",g),p?.removeEventListener("keyup",y),window.removeEventListener("blur",m),window.removeEventListener("contextmenu",m)}}},[e,a]),r}function O_(e,n,r){return e.filter(a=>r||a.length===n.size).some(a=>a.every(o=>n.has(o)))}function D_(e,n){return n.includes(e)?"code":"key"}const nq=()=>{const e=rt();return N.useMemo(()=>({zoomIn:n=>{const{panZoom:r}=e.getState();return r?r.scaleBy(1.2,{duration:n?.duration}):Promise.resolve(!1)},zoomOut:n=>{const{panZoom:r}=e.getState();return r?r.scaleBy(1/1.2,{duration:n?.duration}):Promise.resolve(!1)},zoomTo:(n,r)=>{const{panZoom:a}=e.getState();return a?a.scaleTo(n,{duration:r?.duration}):Promise.resolve(!1)},getZoom:()=>e.getState().transform[2],setViewport:async(n,r)=>{const{transform:[a,o,l],panZoom:c}=e.getState();return c?(await c.setViewport({x:n.x??a,y:n.y??o,zoom:n.zoom??l},r),Promise.resolve(!0)):Promise.resolve(!1)},getViewport:()=>{const[n,r,a]=e.getState().transform;return{x:n,y:r,zoom:a}},setCenter:async(n,r,a)=>e.getState().setCenter(n,r,a),fitBounds:async(n,r)=>{const{width:a,height:o,minZoom:l,maxZoom:c,panZoom:d}=e.getState(),p=ub(n,a,o,l,c,r?.padding??.1);return d?(await d.setViewport(p,{duration:r?.duration,ease:r?.ease,interpolate:r?.interpolate}),Promise.resolve(!0)):Promise.resolve(!1)},screenToFlowPosition:(n,r={})=>{const{transform:a,snapGrid:o,snapToGrid:l,domNode:c}=e.getState();if(!c)return n;const{x:d,y:p}=c.getBoundingClientRect(),h={x:n.x-d,y:n.y-p},g=r.snapGrid??o,y=r.snapToGrid??l;return sl(h,a,y,g)},flowToScreenPosition:n=>{const{transform:r,domNode:a}=e.getState();if(!a)return n;const{x:o,y:l}=a.getBoundingClientRect(),c=Su(n,r);return{x:c.x+o,y:c.y+l}}}),[])};function P6(e,n){const r=[],a=new Map,o=[];for(const l of e)if(l.type==="add"){o.push(l);continue}else if(l.type==="remove"||l.type==="replace")a.set(l.id,[l]);else{const c=a.get(l.id);c?c.push(l):a.set(l.id,[l])}for(const l of n){const c=a.get(l.id);if(!c){r.push(l);continue}if(c[0].type==="remove")continue;if(c[0].type==="replace"){r.push({...c[0].item});continue}const d={...l};for(const p of c)rq(p,d);r.push(d)}return o.length&&o.forEach(l=>{l.index!==void 0?r.splice(l.index,0,{...l.item}):r.push({...l.item})}),r}function rq(e,n){switch(e.type){case"select":{n.selected=e.selected;break}case"position":{typeof e.position<"u"&&(n.position=e.position),typeof e.dragging<"u"&&(n.dragging=e.dragging);break}case"dimensions":{typeof e.dimensions<"u"&&(n.measured={...e.dimensions},e.setAttributes&&((e.setAttributes===!0||e.setAttributes==="width")&&(n.width=e.dimensions.width),(e.setAttributes===!0||e.setAttributes==="height")&&(n.height=e.dimensions.height))),typeof e.resizing=="boolean"&&(n.resizing=e.resizing);break}}}function vb(e,n){return P6(e,n)}function $6(e,n){return P6(e,n)}function Li(e,n){return{id:e,type:"select",selected:n}}function eo(e,n=new Set,r=!1){const a=[];for(const[o,l]of e){const c=n.has(o);!(l.selected===void 0&&!c)&&l.selected!==c&&(r&&(l.selected=c),a.push(Li(l.id,c)))}return a}function q_({items:e=[],lookup:n}){const r=[],a=new Map(e.map(o=>[o.id,o]));for(const[o,l]of e.entries()){const c=n.get(l.id),d=c?.internals?.userNode??c;d!==void 0&&d!==l&&r.push({id:l.id,item:l,type:"replace"}),d===void 0&&r.push({item:l,type:"add",index:o})}for(const[o]of n)a.get(o)===void 0&&r.push({id:o,type:"remove"});return r}function I_(e){return{id:e.id,type:"remove"}}const L_=e=>AO(e),iq=e=>p6(e);function V6(e){return N.forwardRef(e)}const aq=typeof window<"u"?N.useLayoutEffect:N.useEffect;function B_(e){const[n,r]=N.useState(BigInt(0)),[a]=N.useState(()=>oq(()=>r(o=>o+BigInt(1))));return aq(()=>{const o=a.get();o.length&&(e(o),a.reset())},[n]),a}function oq(e){let n=[];return{get:()=>n,reset:()=>{n=[]},push:r=>{n.push(r),e()}}}const W6=N.createContext(null);function sq({children:e}){const n=rt(),r=N.useCallback(d=>{const{nodes:p=[],setNodes:h,hasDefaultNodes:g,onNodesChange:y,nodeLookup:m,fitViewQueued:b,onNodesChangeMiddlewareMap:S}=n.getState();let w=p;for(const _ of d)w=typeof _=="function"?_(w):_;let C=q_({items:w,lookup:m});for(const _ of S.values())C=_(C);g&&h(w),C.length>0?y?.(C):b&&window.requestAnimationFrame(()=>{const{fitViewQueued:_,nodes:j,setNodes:k}=n.getState();_&&k(j)})},[]),a=B_(r),o=N.useCallback(d=>{const{edges:p=[],setEdges:h,hasDefaultEdges:g,onEdgesChange:y,edgeLookup:m}=n.getState();let b=p;for(const S of d)b=typeof S=="function"?S(b):S;g?h(b):y&&y(q_({items:b,lookup:m}))},[]),l=B_(o),c=N.useMemo(()=>({nodeQueue:a,edgeQueue:l}),[]);return u.jsx(W6.Provider,{value:c,children:e})}function lq(){const e=N.useContext(W6);if(!e)throw new Error("useBatchContext must be used within a BatchProvider");return e}const cq=e=>!!e.panZoom;function yo(){const e=nq(),n=rt(),r=lq(),a=Be(cq),o=N.useMemo(()=>{const l=y=>n.getState().nodeLookup.get(y),c=y=>{r.nodeQueue.push(y)},d=y=>{r.edgeQueue.push(y)},p=y=>{const{nodeLookup:m,nodeOrigin:b}=n.getState(),S=L_(y)?y:m.get(y.id),w=S.parentId?b6(S.position,S.measured,S.parentId,m,b):S.position,C={...S,position:w,width:S.measured?.width??S.width,height:S.measured?.height??S.height};return uo(C)},h=(y,m,b={replace:!1})=>{c(S=>S.map(w=>{if(w.id===y){const C=typeof m=="function"?m(w):m;return b.replace&&L_(C)?C:{...w,...C}}return w}))},g=(y,m,b={replace:!1})=>{d(S=>S.map(w=>{if(w.id===y){const C=typeof m=="function"?m(w):m;return b.replace&&iq(C)?C:{...w,...C}}return w}))};return{getNodes:()=>n.getState().nodes.map(y=>({...y})),getNode:y=>l(y)?.internals.userNode,getInternalNode:l,getEdges:()=>{const{edges:y=[]}=n.getState();return y.map(m=>({...m}))},getEdge:y=>n.getState().edgeLookup.get(y),setNodes:c,setEdges:d,addNodes:y=>{const m=Array.isArray(y)?y:[y];r.nodeQueue.push(b=>[...b,...m])},addEdges:y=>{const m=Array.isArray(y)?y:[y];r.edgeQueue.push(b=>[...b,...m])},toObject:()=>{const{nodes:y=[],edges:m=[],transform:b}=n.getState(),[S,w,C]=b;return{nodes:y.map(_=>({..._})),edges:m.map(_=>({..._})),viewport:{x:S,y:w,zoom:C}}},deleteElements:async({nodes:y=[],edges:m=[]})=>{const{nodes:b,edges:S,onNodesDelete:w,onEdgesDelete:C,triggerNodeChanges:_,triggerEdgeChanges:j,onDelete:k,onBeforeDelete:T}=n.getState(),{nodes:E,edges:z}=await OO({nodesToRemove:y,edgesToRemove:m,nodes:b,edges:S,onBeforeDelete:T}),A=z.length>0,M=E.length>0;if(A){const O=z.map(I_);C?.(z),j(O)}if(M){const O=E.map(I_);w?.(E),_(O)}return(M||A)&&k?.({nodes:E,edges:z}),{deletedNodes:E,deletedEdges:z}},getIntersectingNodes:(y,m=!0,b)=>{const S=l_(y),w=S?y:p(y),C=b!==void 0;return w?(b||n.getState().nodes).filter(_=>{const j=n.getState().nodeLookup.get(_.id);if(j&&!S&&(_.id===y.id||!j.internals.positionAbsolute))return!1;const k=uo(C?_:j),T=Gs(k,w);return m&&T>0||T>=k.width*k.height||T>=w.width*w.height}):[]},isNodeIntersecting:(y,m,b=!0)=>{const w=l_(y)?y:p(y);if(!w)return!1;const C=Gs(w,m);return b&&C>0||C>=m.width*m.height||C>=w.width*w.height},updateNode:h,updateNodeData:(y,m,b={replace:!1})=>{h(y,S=>{const w=typeof m=="function"?m(S):m;return b.replace?{...S,data:w}:{...S,data:{...S.data,...w}}},b)},updateEdge:g,updateEdgeData:(y,m,b={replace:!1})=>{g(y,S=>{const w=typeof m=="function"?m(S):m;return b.replace?{...S,data:w}:{...S,data:{...S.data,...w}}},b)},getNodesBounds:y=>{const{nodeLookup:m,nodeOrigin:b}=n.getState();return RO(y,{nodeLookup:m,nodeOrigin:b})},getHandleConnections:({type:y,id:m,nodeId:b})=>Array.from(n.getState().connectionLookup.get(`${b}-${y}${m?`-${m}`:""}`)?.values()??[]),getNodeConnections:({type:y,handleId:m,nodeId:b})=>Array.from(n.getState().connectionLookup.get(`${b}${y?m?`-${y}-${m}`:`-${y}`:""}`)?.values()??[]),fitView:async y=>{const m=n.getState().fitViewResolver??LO();return n.setState({fitViewQueued:!0,fitViewOptions:y,fitViewResolver:m}),r.nodeQueue.push(b=>[...b]),m.promise}}},[]);return N.useMemo(()=>({...o,...e,viewportInitialized:a}),[a])}const H_=e=>e.selected,uq=typeof window<"u"?window:void 0;function dq({deleteKeyCode:e,multiSelectionKeyCode:n}){const r=rt(),{deleteElements:a}=yo(),o=Xs(e,{actInsideInputWithModifier:!1}),l=Xs(n,{target:uq});N.useEffect(()=>{if(o){const{edges:c,nodes:d}=r.getState();a({nodes:d.filter(H_),edges:c.filter(H_)}),r.setState({nodesSelectionActive:!1})}},[o]),N.useEffect(()=>{r.setState({multiSelectionActive:l})},[l])}function fq(e){const n=rt();N.useEffect(()=>{const r=()=>{if(!e.current||!(e.current.checkVisibility?.()??!0))return!1;const a=db(e.current);(a.height===0||a.width===0)&&n.getState().onError?.("004",Yn.error004()),n.setState({width:a.width||500,height:a.height||500})};if(e.current){r(),window.addEventListener("resize",r);const a=new ResizeObserver(()=>r());return a.observe(e.current),()=>{window.removeEventListener("resize",r),a&&e.current&&a.unobserve(e.current)}}},[])}const $u={position:"absolute",width:"100%",height:"100%",top:0,left:0},pq=e=>({userSelectionActive:e.userSelectionActive,lib:e.lib,connectionInProgress:e.connection.inProgress});function hq({onPaneContextMenu:e,zoomOnScroll:n=!0,zoomOnPinch:r=!0,panOnScroll:a=!1,panOnScrollSpeed:o=.5,panOnScrollMode:l=Pi.Free,zoomOnDoubleClick:c=!0,panOnDrag:d=!0,defaultViewport:p,translateExtent:h,minZoom:g,maxZoom:y,zoomActivationKeyCode:m,preventScrolling:b=!0,children:S,noWheelClassName:w,noPanClassName:C,onViewportChange:_,isControlledViewport:j,paneClickDistance:k,selectionOnDrag:T}){const E=rt(),z=N.useRef(null),{userSelectionActive:A,lib:M,connectionInProgress:O}=Be(pq,nt),P=Xs(m),L=N.useRef();fq(z);const I=N.useCallback(F=>{_?.({x:F[0],y:F[1],zoom:F[2]}),j||E.setState({transform:F})},[_,j]);return N.useEffect(()=>{if(z.current){L.current=xD({domNode:z.current,minZoom:g,maxZoom:y,translateExtent:h,viewport:p,onDraggingChange:D=>E.setState({paneDragging:D}),onPanZoomStart:(D,q)=>{const{onViewportChangeStart:$,onMoveStart:K}=E.getState();K?.(D,q),$?.(q)},onPanZoom:(D,q)=>{const{onViewportChange:$,onMove:K}=E.getState();K?.(D,q),$?.(q)},onPanZoomEnd:(D,q)=>{const{onViewportChangeEnd:$,onMoveEnd:K}=E.getState();K?.(D,q),$?.(q)}});const{x:F,y:U,zoom:B}=L.current.getViewport();return E.setState({panZoom:L.current,transform:[F,U,B],domNode:z.current.closest(".react-flow")}),()=>{L.current?.destroy()}}},[]),N.useEffect(()=>{L.current?.update({onPaneContextMenu:e,zoomOnScroll:n,zoomOnPinch:r,panOnScroll:a,panOnScrollSpeed:o,panOnScrollMode:l,zoomOnDoubleClick:c,panOnDrag:d,zoomActivationKeyPressed:P,preventScrolling:b,noPanClassName:C,userSelectionActive:A,noWheelClassName:w,lib:M,onTransformChange:I,connectionInProgress:O,selectionOnDrag:T,paneClickDistance:k})},[e,n,r,a,o,l,c,d,P,b,C,A,w,M,I,O,T,k]),u.jsx("div",{className:"react-flow__renderer",ref:z,style:$u,children:S})}const gq=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function yq(){const{userSelectionActive:e,userSelectionRect:n}=Be(gq,nt);return e&&n?u.jsx("div",{className:"react-flow__selection react-flow__container",style:{width:n.width,height:n.height,transform:`translate(${n.x}px, ${n.y}px)`}}):null}const $p=(e,n)=>r=>{r.target===n.current&&e?.(r)},mq=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,connectionInProgress:e.connection.inProgress,dragging:e.paneDragging});function vq({isSelecting:e,selectionKeyPressed:n,selectionMode:r=Ws.Full,panOnDrag:a,paneClickDistance:o,selectionOnDrag:l,onSelectionStart:c,onSelectionEnd:d,onPaneClick:p,onPaneContextMenu:h,onPaneScroll:g,onPaneMouseEnter:y,onPaneMouseMove:m,onPaneMouseLeave:b,children:S}){const w=rt(),{userSelectionActive:C,elementsSelectable:_,dragging:j,connectionInProgress:k}=Be(mq,nt),T=_&&(e||C),E=N.useRef(null),z=N.useRef(),A=N.useRef(new Set),M=N.useRef(new Set),O=N.useRef(!1),P=$=>{if(O.current||k){O.current=!1;return}p?.($),w.getState().resetSelectedElements(),w.setState({nodesSelectionActive:!1})},L=$=>{if(Array.isArray(a)&&a?.includes(2)){$.preventDefault();return}h?.($)},I=g?$=>g($):void 0,F=$=>{O.current&&($.stopPropagation(),O.current=!1)},U=$=>{const{domNode:K}=w.getState();if(z.current=K?.getBoundingClientRect(),!z.current)return;const ne=$.target===E.current;if(!ne&&!!$.target.closest(".nokey")||!e||!(l&&ne||n)||$.button!==0||!$.isPrimary)return;$.target?.setPointerCapture?.($.pointerId),O.current=!1;const{x:ee,y:G}=zn($.nativeEvent,z.current);w.setState({userSelectionRect:{width:0,height:0,startX:ee,startY:G,x:ee,y:G}}),ne||($.stopPropagation(),$.preventDefault())},B=$=>{const{userSelectionRect:K,transform:ne,nodeLookup:V,edgeLookup:W,connectionLookup:ee,triggerNodeChanges:G,triggerEdgeChanges:X,defaultEdgeOptions:Q,resetSelectedElements:ie}=w.getState();if(!z.current||!K)return;const{x:se,y:he}=zn($.nativeEvent,z.current),{startX:ye,startY:be}=K;if(!O.current){const pe=n?0:o;if(Math.hypot(se-ye,he-be)<=pe)return;ie(),c?.($)}O.current=!0;const we={startX:ye,startY:be,x:sepe.id)),M.current=new Set;const ae=Q?.selectable??!0;for(const pe of A.current){const ge=ee.get(pe);if(ge)for(const{edgeId:je}of ge.values()){const Ae=W.get(je);Ae&&(Ae.selectable??ae)&&M.current.add(je)}}if(!c_(xe,A.current)){const pe=eo(V,A.current,!0);G(pe)}if(!c_(ke,M.current)){const pe=eo(W,M.current);X(pe)}w.setState({userSelectionRect:we,userSelectionActive:!0,nodesSelectionActive:!1})},D=$=>{$.button===0&&($.target?.releasePointerCapture?.($.pointerId),!C&&$.target===E.current&&w.getState().userSelectionRect&&P?.($),w.setState({userSelectionActive:!1,userSelectionRect:null}),O.current&&(d?.($),w.setState({nodesSelectionActive:A.current.size>0})))},q=a===!0||Array.isArray(a)&&a.includes(0);return u.jsxs("div",{className:xt(["react-flow__pane",{draggable:q,dragging:j,selection:e}]),onClick:T?void 0:$p(P,E),onContextMenu:$p(L,E),onWheel:$p(I,E),onPointerEnter:T?void 0:y,onPointerMove:T?B:m,onPointerUp:T?D:void 0,onPointerDownCapture:T?U:void 0,onClickCapture:T?F:void 0,onPointerLeave:b,ref:E,style:$u,children:[S,u.jsx(yq,{})]})}function I0({id:e,store:n,unselect:r=!1,nodeRef:a}){const{addSelectedNodes:o,unselectNodesAndEdges:l,multiSelectionActive:c,nodeLookup:d,onError:p}=n.getState(),h=d.get(e);if(!h){p?.("012",Yn.error012(e));return}n.setState({nodesSelectionActive:!1}),h.selected?(r||h.selected&&c)&&(l({nodes:[h],edges:[]}),requestAnimationFrame(()=>a?.current?.blur())):o([e])}function G6({nodeRef:e,disabled:n=!1,noDragClassName:r,handleSelector:a,nodeId:o,isSelectable:l,nodeClickDistance:c}){const d=rt(),[p,h]=N.useState(!1),g=N.useRef();return N.useEffect(()=>{g.current=oD({getStoreItems:()=>d.getState(),onNodeMouseDown:y=>{I0({id:y,store:d,nodeRef:e})},onDragStart:()=>{h(!0)},onDragStop:()=>{h(!1)}})},[]),N.useEffect(()=>{if(n)g.current?.destroy();else if(e.current)return g.current?.update({noDragClassName:r,handleSelector:a,domNode:e.current,isSelectable:l,nodeId:o,nodeClickDistance:c}),()=>{g.current?.destroy()}},[r,a,n,l,e,o]),p}const bq=e=>n=>n.selected&&(n.draggable||e&&typeof n.draggable>"u");function Y6(){const e=rt();return N.useCallback(r=>{const{nodeExtent:a,snapToGrid:o,snapGrid:l,nodesDraggable:c,onError:d,updateNodePositions:p,nodeLookup:h,nodeOrigin:g}=e.getState(),y=new Map,m=bq(c),b=o?l[0]:5,S=o?l[1]:5,w=r.direction.x*b*r.factor,C=r.direction.y*S*r.factor;for(const[,_]of h){if(!m(_))continue;let j={x:_.internals.positionAbsolute.x+w,y:_.internals.positionAbsolute.y+C};o&&(j=ol(j,l));const{position:k,positionAbsolute:T}=h6({nodeId:_.id,nextPosition:j,nodeLookup:h,nodeExtent:a,nodeOrigin:g,onError:d});_.position=k,_.internals.positionAbsolute=T,y.set(_.id,_)}p(y)},[])}const bb=N.createContext(null),xq=bb.Provider;bb.Consumer;const X6=()=>N.useContext(bb),Sq=e=>({connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName,rfId:e.rfId}),wq=(e,n,r)=>a=>{const{connectionClickStartHandle:o,connectionMode:l,connection:c}=a,{fromHandle:d,toHandle:p,isValid:h}=c,g=p?.nodeId===e&&p?.id===n&&p?.type===r;return{connectingFrom:d?.nodeId===e&&d?.id===n&&d?.type===r,connectingTo:g,clickConnecting:o?.nodeId===e&&o?.id===n&&o?.type===r,isPossibleEndHandle:l===lo.Strict?d?.type!==r:e!==d?.nodeId||n!==d?.id,connectionInProcess:!!d,clickConnectionInProcess:!!o,valid:g&&h}};function _q({type:e="source",position:n=me.Top,isValidConnection:r,isConnectable:a=!0,isConnectableStart:o=!0,isConnectableEnd:l=!0,id:c,onConnect:d,children:p,className:h,onMouseDown:g,onTouchStart:y,...m},b){const S=c||null,w=e==="target",C=rt(),_=X6(),{connectOnClick:j,noPanClassName:k,rfId:T}=Be(Sq,nt),{connectingFrom:E,connectingTo:z,clickConnecting:A,isPossibleEndHandle:M,connectionInProcess:O,clickConnectionInProcess:P,valid:L}=Be(wq(_,S,e),nt);_||C.getState().onError?.("010",Yn.error010());const I=B=>{const{defaultEdgeOptions:D,onConnect:q,hasDefaultEdges:$}=C.getState(),K={...D,...B};if($){const{edges:ne,setEdges:V}=C.getState();V(C6(K,ne))}q?.(K),d?.(K)},F=B=>{if(!_)return;const D=w6(B.nativeEvent);if(o&&(D&&B.button===0||!D)){const q=C.getState();q0.onPointerDown(B.nativeEvent,{handleDomNode:B.currentTarget,autoPanOnConnect:q.autoPanOnConnect,connectionMode:q.connectionMode,connectionRadius:q.connectionRadius,domNode:q.domNode,nodeLookup:q.nodeLookup,lib:q.lib,isTarget:w,handleId:S,nodeId:_,flowId:q.rfId,panBy:q.panBy,cancelConnection:q.cancelConnection,onConnectStart:q.onConnectStart,onConnectEnd:q.onConnectEnd,updateConnection:q.updateConnection,onConnect:I,isValidConnection:r||q.isValidConnection,getTransform:()=>C.getState().transform,getFromHandle:()=>C.getState().connection.fromHandle,autoPanSpeed:q.autoPanSpeed,dragThreshold:q.connectionDragThreshold})}D?g?.(B):y?.(B)},U=B=>{const{onClickConnectStart:D,onClickConnectEnd:q,connectionClickStartHandle:$,connectionMode:K,isValidConnection:ne,lib:V,rfId:W,nodeLookup:ee,connection:G}=C.getState();if(!_||!$&&!o)return;if(!$){D?.(B.nativeEvent,{nodeId:_,handleId:S,handleType:e}),C.setState({connectionClickStartHandle:{nodeId:_,type:e,id:S}});return}const X=x6(B.target),Q=r||ne,{connection:ie,isValid:se}=q0.isValid(B.nativeEvent,{handle:{nodeId:_,id:S,type:e},connectionMode:K,fromNodeId:$.nodeId,fromHandleId:$.id||null,fromType:$.type,isValidConnection:Q,flowId:W,doc:X,lib:V,nodeLookup:ee});se&&ie&&I(ie);const he=structuredClone(G);delete he.inProgress,he.toPosition=he.toHandle?he.toHandle.position:null,q?.(B,he),C.setState({connectionClickStartHandle:null})};return u.jsx("div",{"data-handleid":S,"data-nodeid":_,"data-handlepos":n,"data-id":`${T}-${_}-${S}-${e}`,className:xt(["react-flow__handle",`react-flow__handle-${n}`,"nodrag",k,h,{source:!w,target:w,connectable:a,connectablestart:o,connectableend:l,clickconnecting:A,connectingfrom:E,connectingto:z,valid:L,connectionindicator:a&&(!O||M)&&(O||P?l:o)}]),onMouseDown:F,onTouchStart:F,onClick:j?U:void 0,ref:b,...m,children:p})}const Jt=N.memo(V6(_q));function kq({data:e,isConnectable:n,sourcePosition:r=me.Bottom}){return u.jsxs(u.Fragment,{children:[e?.label,u.jsx(Jt,{type:"source",position:r,isConnectable:n})]})}function Cq({data:e,isConnectable:n,targetPosition:r=me.Top,sourcePosition:a=me.Bottom}){return u.jsxs(u.Fragment,{children:[u.jsx(Jt,{type:"target",position:r,isConnectable:n}),e?.label,u.jsx(Jt,{type:"source",position:a,isConnectable:n})]})}function Eq(){return null}function jq({data:e,isConnectable:n,targetPosition:r=me.Top}){return u.jsxs(u.Fragment,{children:[u.jsx(Jt,{type:"target",position:r,isConnectable:n}),e?.label]})}const wu={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},U_={input:kq,default:Cq,output:jq,group:Eq};function Tq(e){return e.internals.handleBounds===void 0?{width:e.width??e.initialWidth??e.style?.width,height:e.height??e.initialHeight??e.style?.height}:{width:e.width??e.style?.width,height:e.height??e.style?.height}}const Aq=e=>{const{width:n,height:r,x:a,y:o}=al(e.nodeLookup,{filter:l=>!!l.selected});return{width:Rn(n)?n:null,height:Rn(r)?r:null,userSelectionActive:e.userSelectionActive,transformString:`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]}) translate(${a}px,${o}px)`}};function Rq({onSelectionContextMenu:e,noPanClassName:n,disableKeyboardA11y:r}){const a=rt(),{width:o,height:l,transformString:c,userSelectionActive:d}=Be(Aq,nt),p=Y6(),h=N.useRef(null);if(N.useEffect(()=>{r||h.current?.focus({preventScroll:!0})},[r]),G6({nodeRef:h}),d||!o||!l)return null;const g=e?m=>{const b=a.getState().nodes.filter(S=>S.selected);e(m,b)}:void 0,y=m=>{Object.prototype.hasOwnProperty.call(wu,m.key)&&(m.preventDefault(),p({direction:wu[m.key],factor:m.shiftKey?4:1}))};return u.jsx("div",{className:xt(["react-flow__nodesselection","react-flow__container",n]),style:{transform:c},children:u.jsx("div",{ref:h,className:"react-flow__nodesselection-rect",onContextMenu:g,tabIndex:r?void 0:-1,onKeyDown:r?void 0:y,style:{width:o,height:l}})})}const F_=typeof window<"u"?window:void 0,zq=e=>({nodesSelectionActive:e.nodesSelectionActive,userSelectionActive:e.userSelectionActive});function K6({children:e,onPaneClick:n,onPaneMouseEnter:r,onPaneMouseMove:a,onPaneMouseLeave:o,onPaneContextMenu:l,onPaneScroll:c,paneClickDistance:d,deleteKeyCode:p,selectionKeyCode:h,selectionOnDrag:g,selectionMode:y,onSelectionStart:m,onSelectionEnd:b,multiSelectionKeyCode:S,panActivationKeyCode:w,zoomActivationKeyCode:C,elementsSelectable:_,zoomOnScroll:j,zoomOnPinch:k,panOnScroll:T,panOnScrollSpeed:E,panOnScrollMode:z,zoomOnDoubleClick:A,panOnDrag:M,defaultViewport:O,translateExtent:P,minZoom:L,maxZoom:I,preventScrolling:F,onSelectionContextMenu:U,noWheelClassName:B,noPanClassName:D,disableKeyboardA11y:q,onViewportChange:$,isControlledViewport:K}){const{nodesSelectionActive:ne,userSelectionActive:V}=Be(zq,nt),W=Xs(h,{target:F_}),ee=Xs(w,{target:F_}),G=ee||M,X=ee||T,Q=g&&G!==!0,ie=W||V||Q;return dq({deleteKeyCode:p,multiSelectionKeyCode:S}),u.jsx(hq,{onPaneContextMenu:l,elementsSelectable:_,zoomOnScroll:j,zoomOnPinch:k,panOnScroll:X,panOnScrollSpeed:E,panOnScrollMode:z,zoomOnDoubleClick:A,panOnDrag:!W&&G,defaultViewport:O,translateExtent:P,minZoom:L,maxZoom:I,zoomActivationKeyCode:C,preventScrolling:F,noWheelClassName:B,noPanClassName:D,onViewportChange:$,isControlledViewport:K,paneClickDistance:d,selectionOnDrag:Q,children:u.jsxs(vq,{onSelectionStart:m,onSelectionEnd:b,onPaneClick:n,onPaneMouseEnter:r,onPaneMouseMove:a,onPaneMouseLeave:o,onPaneContextMenu:l,onPaneScroll:c,panOnDrag:G,isSelecting:!!ie,selectionMode:y,selectionKeyPressed:W,paneClickDistance:d,selectionOnDrag:Q,children:[e,ne&&u.jsx(Rq,{onSelectionContextMenu:U,noPanClassName:D,disableKeyboardA11y:q})]})})}K6.displayName="FlowRenderer";const Nq=N.memo(K6),Mq=e=>n=>e?cb(n.nodeLookup,{x:0,y:0,width:n.width,height:n.height},n.transform,!0).map(r=>r.id):Array.from(n.nodeLookup.keys());function Oq(e){return Be(N.useCallback(Mq(e),[e]),nt)}const Dq=e=>e.updateNodeInternals;function qq(){const e=Be(Dq),[n]=N.useState(()=>typeof ResizeObserver>"u"?null:new ResizeObserver(r=>{const a=new Map;r.forEach(o=>{const l=o.target.getAttribute("data-id");a.set(l,{id:l,nodeElement:o.target,force:!0})}),e(a)}));return N.useEffect(()=>()=>{n?.disconnect()},[n]),n}function Iq({node:e,nodeType:n,hasDimensions:r,resizeObserver:a}){const o=rt(),l=N.useRef(null),c=N.useRef(null),d=N.useRef(e.sourcePosition),p=N.useRef(e.targetPosition),h=N.useRef(n),g=r&&!!e.internals.handleBounds;return N.useEffect(()=>{l.current&&!e.hidden&&(!g||c.current!==l.current)&&(c.current&&a?.unobserve(c.current),a?.observe(l.current),c.current=l.current)},[g,e.hidden]),N.useEffect(()=>()=>{c.current&&(a?.unobserve(c.current),c.current=null)},[]),N.useEffect(()=>{if(l.current){const y=h.current!==n,m=d.current!==e.sourcePosition,b=p.current!==e.targetPosition;(y||m||b)&&(h.current=n,d.current=e.sourcePosition,p.current=e.targetPosition,o.getState().updateNodeInternals(new Map([[e.id,{id:e.id,nodeElement:l.current,force:!0}]])))}},[e.id,n,e.sourcePosition,e.targetPosition]),l}function Lq({id:e,onClick:n,onMouseEnter:r,onMouseMove:a,onMouseLeave:o,onContextMenu:l,onDoubleClick:c,nodesDraggable:d,elementsSelectable:p,nodesConnectable:h,nodesFocusable:g,resizeObserver:y,noDragClassName:m,noPanClassName:b,disableKeyboardA11y:S,rfId:w,nodeTypes:C,nodeClickDistance:_,onError:j}){const{node:k,internals:T,isParent:E}=Be(se=>{const he=se.nodeLookup.get(e),ye=se.parentLookup.has(e);return{node:he,internals:he.internals,isParent:ye}},nt);let z=k.type||"default",A=C?.[z]||U_[z];A===void 0&&(j?.("003",Yn.error003(z)),z="default",A=C?.default||U_.default);const M=!!(k.draggable||d&&typeof k.draggable>"u"),O=!!(k.selectable||p&&typeof k.selectable>"u"),P=!!(k.connectable||h&&typeof k.connectable>"u"),L=!!(k.focusable||g&&typeof k.focusable>"u"),I=rt(),F=v6(k),U=Iq({node:k,nodeType:z,hasDimensions:F,resizeObserver:y}),B=G6({nodeRef:U,disabled:k.hidden||!M,noDragClassName:m,handleSelector:k.dragHandle,nodeId:e,isSelectable:O,nodeClickDistance:_}),D=Y6();if(k.hidden)return null;const q=Er(k),$=Tq(k),K=O||M||n||r||a||o,ne=r?se=>r(se,{...T.userNode}):void 0,V=a?se=>a(se,{...T.userNode}):void 0,W=o?se=>o(se,{...T.userNode}):void 0,ee=l?se=>l(se,{...T.userNode}):void 0,G=c?se=>c(se,{...T.userNode}):void 0,X=se=>{const{selectNodesOnDrag:he,nodeDragThreshold:ye}=I.getState();O&&(!he||!M||ye>0)&&I0({id:e,store:I,nodeRef:U}),n&&n(se,{...T.userNode})},Q=se=>{if(!(S6(se.nativeEvent)||S)){if(c6.includes(se.key)&&O){const he=se.key==="Escape";I0({id:e,store:I,unselect:he,nodeRef:U})}else if(M&&k.selected&&Object.prototype.hasOwnProperty.call(wu,se.key)){se.preventDefault();const{ariaLabelConfig:he}=I.getState();I.setState({ariaLiveMessage:he["node.a11yDescription.ariaLiveMessage"]({direction:se.key.replace("Arrow","").toLowerCase(),x:~~T.positionAbsolute.x,y:~~T.positionAbsolute.y})}),D({direction:wu[se.key],factor:se.shiftKey?4:1})}}},ie=()=>{if(S||!U.current?.matches(":focus-visible"))return;const{transform:se,width:he,height:ye,autoPanOnNodeFocus:be,setCenter:we}=I.getState();if(!be)return;cb(new Map([[e,k]]),{x:0,y:0,width:he,height:ye},se,!0).length>0||we(k.position.x+q.width/2,k.position.y+q.height/2,{zoom:se[2]})};return u.jsx("div",{className:xt(["react-flow__node",`react-flow__node-${z}`,{[b]:M},k.className,{selected:k.selected,selectable:O,parent:E,draggable:M,dragging:B}]),ref:U,style:{zIndex:T.z,transform:`translate(${T.positionAbsolute.x}px,${T.positionAbsolute.y}px)`,pointerEvents:K?"all":"none",visibility:F?"visible":"hidden",...k.style,...$},"data-id":e,"data-testid":`rf__node-${e}`,onMouseEnter:ne,onMouseMove:V,onMouseLeave:W,onContextMenu:ee,onClick:X,onDoubleClick:G,onKeyDown:L?Q:void 0,tabIndex:L?0:void 0,onFocus:L?ie:void 0,role:k.ariaRole??(L?"group":void 0),"aria-roledescription":"node","aria-describedby":S?void 0:`${H6}-${w}`,"aria-label":k.ariaLabel,...k.domAttributes,children:u.jsx(xq,{value:e,children:u.jsx(A,{id:e,data:k.data,type:z,positionAbsoluteX:T.positionAbsolute.x,positionAbsoluteY:T.positionAbsolute.y,selected:k.selected??!1,selectable:O,draggable:M,deletable:k.deletable??!0,isConnectable:P,sourcePosition:k.sourcePosition,targetPosition:k.targetPosition,dragging:B,dragHandle:k.dragHandle,zIndex:T.z,parentId:k.parentId,...q})})})}var Bq=N.memo(Lq);const Hq=e=>({nodesDraggable:e.nodesDraggable,nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,onError:e.onError});function Z6(e){const{nodesDraggable:n,nodesConnectable:r,nodesFocusable:a,elementsSelectable:o,onError:l}=Be(Hq,nt),c=Oq(e.onlyRenderVisibleElements),d=qq();return u.jsx("div",{className:"react-flow__nodes",style:$u,children:c.map(p=>u.jsx(Bq,{id:p,nodeTypes:e.nodeTypes,nodeExtent:e.nodeExtent,onClick:e.onNodeClick,onMouseEnter:e.onNodeMouseEnter,onMouseMove:e.onNodeMouseMove,onMouseLeave:e.onNodeMouseLeave,onContextMenu:e.onNodeContextMenu,onDoubleClick:e.onNodeDoubleClick,noDragClassName:e.noDragClassName,noPanClassName:e.noPanClassName,rfId:e.rfId,disableKeyboardA11y:e.disableKeyboardA11y,resizeObserver:d,nodesDraggable:n,nodesConnectable:r,nodesFocusable:a,elementsSelectable:o,nodeClickDistance:e.nodeClickDistance,onError:l},p))})}Z6.displayName="NodeRenderer";const Uq=N.memo(Z6);function Fq(e){return Be(N.useCallback(r=>{if(!e)return r.edges.map(o=>o.id);const a=[];if(r.width&&r.height)for(const o of r.edges){const l=r.nodeLookup.get(o.source),c=r.nodeLookup.get(o.target);l&&c&&FO({sourceNode:l,targetNode:c,width:r.width,height:r.height,transform:r.transform})&&a.push(o.id)}return a},[e]),nt)}const Pq=({color:e="none",strokeWidth:n=1})=>{const r={strokeWidth:n,...e&&{stroke:e}};return u.jsx("polyline",{className:"arrow",style:r,strokeLinecap:"round",fill:"none",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4"})},$q=({color:e="none",strokeWidth:n=1})=>{const r={strokeWidth:n,...e&&{stroke:e,fill:e}};return u.jsx("polyline",{className:"arrowclosed",style:r,strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"})},P_={[bu.Arrow]:Pq,[bu.ArrowClosed]:$q};function Vq(e){const n=rt();return N.useMemo(()=>Object.prototype.hasOwnProperty.call(P_,e)?P_[e]:(n.getState().onError?.("009",Yn.error009(e)),null),[e])}const Wq=({id:e,type:n,color:r,width:a=12.5,height:o=12.5,markerUnits:l="strokeWidth",strokeWidth:c,orient:d="auto-start-reverse"})=>{const p=Vq(n);return p?u.jsx("marker",{className:"react-flow__arrowhead",id:e,markerWidth:`${a}`,markerHeight:`${o}`,viewBox:"-10 -10 20 20",markerUnits:l,orient:d,refX:"0",refY:"0",children:u.jsx(p,{color:r,strokeWidth:c})}):null},Q6=({defaultColor:e,rfId:n})=>{const r=Be(l=>l.edges),a=Be(l=>l.defaultEdgeOptions),o=N.useMemo(()=>XO(r,{id:n,defaultColor:e,defaultMarkerStart:a?.markerStart,defaultMarkerEnd:a?.markerEnd}),[r,a,n,e]);return o.length?u.jsx("svg",{className:"react-flow__marker","aria-hidden":"true",children:u.jsx("defs",{children:o.map(l=>u.jsx(Wq,{id:l.id,type:l.type,color:l.color,width:l.width,height:l.height,markerUnits:l.markerUnits,strokeWidth:l.strokeWidth,orient:l.orient},l.id))})}):null};Q6.displayName="MarkerDefinitions";var Gq=N.memo(Q6);function J6({x:e,y:n,label:r,labelStyle:a,labelShowBg:o=!0,labelBgStyle:l,labelBgPadding:c=[2,4],labelBgBorderRadius:d=2,children:p,className:h,...g}){const[y,m]=N.useState({x:1,y:0,width:0,height:0}),b=xt(["react-flow__edge-textwrapper",h]),S=N.useRef(null);return N.useEffect(()=>{if(S.current){const w=S.current.getBBox();m({x:w.x,y:w.y,width:w.width,height:w.height})}},[r]),r?u.jsxs("g",{transform:`translate(${e-y.width/2} ${n-y.height/2})`,className:b,visibility:y.width?"visible":"hidden",...g,children:[o&&u.jsx("rect",{width:y.width+2*c[0],x:-c[0],y:-c[1],height:y.height+2*c[1],className:"react-flow__edge-textbg",style:l,rx:d,ry:d}),u.jsx("text",{className:"react-flow__edge-text",y:y.height/2,dy:"0.3em",ref:S,style:a,children:r}),p]}):null}J6.displayName="EdgeText";const Yq=N.memo(J6);function ll({path:e,labelX:n,labelY:r,label:a,labelStyle:o,labelShowBg:l,labelBgStyle:c,labelBgPadding:d,labelBgBorderRadius:p,interactionWidth:h=20,...g}){return u.jsxs(u.Fragment,{children:[u.jsx("path",{...g,d:e,fill:"none",className:xt(["react-flow__edge-path",g.className])}),h?u.jsx("path",{d:e,fill:"none",strokeOpacity:0,strokeWidth:h,className:"react-flow__edge-interaction"}):null,a&&Rn(n)&&Rn(r)?u.jsx(Yq,{x:n,y:r,label:a,labelStyle:o,labelShowBg:l,labelBgStyle:c,labelBgPadding:d,labelBgBorderRadius:p}):null]})}function $_({pos:e,x1:n,y1:r,x2:a,y2:o}){return e===me.Left||e===me.Right?[.5*(n+a),r]:[n,.5*(r+o)]}function e8({sourceX:e,sourceY:n,sourcePosition:r=me.Bottom,targetX:a,targetY:o,targetPosition:l=me.Top}){const[c,d]=$_({pos:r,x1:e,y1:n,x2:a,y2:o}),[p,h]=$_({pos:l,x1:a,y1:o,x2:e,y2:n}),[g,y,m,b]=_6({sourceX:e,sourceY:n,targetX:a,targetY:o,sourceControlX:c,sourceControlY:d,targetControlX:p,targetControlY:h});return[`M${e},${n} C${c},${d} ${p},${h} ${a},${o}`,g,y,m,b]}function t8(e){return N.memo(({id:n,sourceX:r,sourceY:a,targetX:o,targetY:l,sourcePosition:c,targetPosition:d,label:p,labelStyle:h,labelShowBg:g,labelBgStyle:y,labelBgPadding:m,labelBgBorderRadius:b,style:S,markerEnd:w,markerStart:C,interactionWidth:_})=>{const[j,k,T]=e8({sourceX:r,sourceY:a,sourcePosition:c,targetX:o,targetY:l,targetPosition:d}),E=e.isInternal?void 0:n;return u.jsx(ll,{id:E,path:j,labelX:k,labelY:T,label:p,labelStyle:h,labelShowBg:g,labelBgStyle:y,labelBgPadding:m,labelBgBorderRadius:b,style:S,markerEnd:w,markerStart:C,interactionWidth:_})})}const Xq=t8({isInternal:!1}),n8=t8({isInternal:!0});Xq.displayName="SimpleBezierEdge";n8.displayName="SimpleBezierEdgeInternal";function r8(e){return N.memo(({id:n,sourceX:r,sourceY:a,targetX:o,targetY:l,label:c,labelStyle:d,labelShowBg:p,labelBgStyle:h,labelBgPadding:g,labelBgBorderRadius:y,style:m,sourcePosition:b=me.Bottom,targetPosition:S=me.Top,markerEnd:w,markerStart:C,pathOptions:_,interactionWidth:j})=>{const[k,T,E]=M0({sourceX:r,sourceY:a,sourcePosition:b,targetX:o,targetY:l,targetPosition:S,borderRadius:_?.borderRadius,offset:_?.offset,stepPosition:_?.stepPosition}),z=e.isInternal?void 0:n;return u.jsx(ll,{id:z,path:k,labelX:T,labelY:E,label:c,labelStyle:d,labelShowBg:p,labelBgStyle:h,labelBgPadding:g,labelBgBorderRadius:y,style:m,markerEnd:w,markerStart:C,interactionWidth:j})})}const i8=r8({isInternal:!1}),a8=r8({isInternal:!0});i8.displayName="SmoothStepEdge";a8.displayName="SmoothStepEdgeInternal";function o8(e){return N.memo(({id:n,...r})=>{const a=e.isInternal?void 0:n;return u.jsx(i8,{...r,id:a,pathOptions:N.useMemo(()=>({borderRadius:0,offset:r.pathOptions?.offset}),[r.pathOptions?.offset])})})}const Kq=o8({isInternal:!1}),s8=o8({isInternal:!0});Kq.displayName="StepEdge";s8.displayName="StepEdgeInternal";function l8(e){return N.memo(({id:n,sourceX:r,sourceY:a,targetX:o,targetY:l,label:c,labelStyle:d,labelShowBg:p,labelBgStyle:h,labelBgPadding:g,labelBgBorderRadius:y,style:m,markerEnd:b,markerStart:S,interactionWidth:w})=>{const[C,_,j]=E6({sourceX:r,sourceY:a,targetX:o,targetY:l}),k=e.isInternal?void 0:n;return u.jsx(ll,{id:k,path:C,labelX:_,labelY:j,label:c,labelStyle:d,labelShowBg:p,labelBgStyle:h,labelBgPadding:g,labelBgBorderRadius:y,style:m,markerEnd:b,markerStart:S,interactionWidth:w})})}const Zq=l8({isInternal:!1}),c8=l8({isInternal:!0});Zq.displayName="StraightEdge";c8.displayName="StraightEdgeInternal";function u8(e){return N.memo(({id:n,sourceX:r,sourceY:a,targetX:o,targetY:l,sourcePosition:c=me.Bottom,targetPosition:d=me.Top,label:p,labelStyle:h,labelShowBg:g,labelBgStyle:y,labelBgPadding:m,labelBgBorderRadius:b,style:S,markerEnd:w,markerStart:C,pathOptions:_,interactionWidth:j})=>{const[k,T,E]=fb({sourceX:r,sourceY:a,sourcePosition:c,targetX:o,targetY:l,targetPosition:d,curvature:_?.curvature}),z=e.isInternal?void 0:n;return u.jsx(ll,{id:z,path:k,labelX:T,labelY:E,label:p,labelStyle:h,labelShowBg:g,labelBgStyle:y,labelBgPadding:m,labelBgBorderRadius:b,style:S,markerEnd:w,markerStart:C,interactionWidth:j})})}const Qq=u8({isInternal:!1}),d8=u8({isInternal:!0});Qq.displayName="BezierEdge";d8.displayName="BezierEdgeInternal";const V_={default:d8,straight:c8,step:s8,smoothstep:a8,simplebezier:n8},W_={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null},Jq=(e,n,r)=>r===me.Left?e-n:r===me.Right?e+n:e,eI=(e,n,r)=>r===me.Top?e-n:r===me.Bottom?e+n:e,G_="react-flow__edgeupdater";function Y_({position:e,centerX:n,centerY:r,radius:a=10,onMouseDown:o,onMouseEnter:l,onMouseOut:c,type:d}){return u.jsx("circle",{onMouseDown:o,onMouseEnter:l,onMouseOut:c,className:xt([G_,`${G_}-${d}`]),cx:Jq(n,a,e),cy:eI(r,a,e),r:a,stroke:"transparent",fill:"transparent"})}function tI({isReconnectable:e,reconnectRadius:n,edge:r,sourceX:a,sourceY:o,targetX:l,targetY:c,sourcePosition:d,targetPosition:p,onReconnect:h,onReconnectStart:g,onReconnectEnd:y,setReconnecting:m,setUpdateHover:b}){const S=rt(),w=(T,E)=>{if(T.button!==0)return;const{autoPanOnConnect:z,domNode:A,isValidConnection:M,connectionMode:O,connectionRadius:P,lib:L,onConnectStart:I,onConnectEnd:F,cancelConnection:U,nodeLookup:B,rfId:D,panBy:q,updateConnection:$}=S.getState(),K=E.type==="target",ne=(ee,G)=>{m(!1),y?.(ee,r,E.type,G)},V=ee=>h?.(r,ee),W=(ee,G)=>{m(!0),g?.(T,r,E.type),I?.(ee,G)};q0.onPointerDown(T.nativeEvent,{autoPanOnConnect:z,connectionMode:O,connectionRadius:P,domNode:A,handleId:E.id,nodeId:E.nodeId,nodeLookup:B,isTarget:K,edgeUpdaterType:E.type,lib:L,flowId:D,cancelConnection:U,panBy:q,isValidConnection:M,onConnect:V,onConnectStart:W,onConnectEnd:F,onReconnectEnd:ne,updateConnection:$,getTransform:()=>S.getState().transform,getFromHandle:()=>S.getState().connection.fromHandle,dragThreshold:S.getState().connectionDragThreshold,handleDomNode:T.currentTarget})},C=T=>w(T,{nodeId:r.target,id:r.targetHandle??null,type:"target"}),_=T=>w(T,{nodeId:r.source,id:r.sourceHandle??null,type:"source"}),j=()=>b(!0),k=()=>b(!1);return u.jsxs(u.Fragment,{children:[(e===!0||e==="source")&&u.jsx(Y_,{position:d,centerX:a,centerY:o,radius:n,onMouseDown:C,onMouseEnter:j,onMouseOut:k,type:"source"}),(e===!0||e==="target")&&u.jsx(Y_,{position:p,centerX:l,centerY:c,radius:n,onMouseDown:_,onMouseEnter:j,onMouseOut:k,type:"target"})]})}function nI({id:e,edgesFocusable:n,edgesReconnectable:r,elementsSelectable:a,onClick:o,onDoubleClick:l,onContextMenu:c,onMouseEnter:d,onMouseMove:p,onMouseLeave:h,reconnectRadius:g,onReconnect:y,onReconnectStart:m,onReconnectEnd:b,rfId:S,edgeTypes:w,noPanClassName:C,onError:_,disableKeyboardA11y:j}){let k=Be(we=>we.edgeLookup.get(e));const T=Be(we=>we.defaultEdgeOptions);k=T?{...T,...k}:k;let E=k.type||"default",z=w?.[E]||V_[E];z===void 0&&(_?.("011",Yn.error011(E)),E="default",z=w?.default||V_.default);const A=!!(k.focusable||n&&typeof k.focusable>"u"),M=typeof y<"u"&&(k.reconnectable||r&&typeof k.reconnectable>"u"),O=!!(k.selectable||a&&typeof k.selectable>"u"),P=N.useRef(null),[L,I]=N.useState(!1),[F,U]=N.useState(!1),B=rt(),{zIndex:D,sourceX:q,sourceY:$,targetX:K,targetY:ne,sourcePosition:V,targetPosition:W}=Be(N.useCallback(we=>{const xe=we.nodeLookup.get(k.source),ke=we.nodeLookup.get(k.target);if(!xe||!ke)return{zIndex:k.zIndex,...W_};const ae=YO({id:e,sourceNode:xe,targetNode:ke,sourceHandle:k.sourceHandle||null,targetHandle:k.targetHandle||null,connectionMode:we.connectionMode,onError:_});return{zIndex:UO({selected:k.selected,zIndex:k.zIndex,sourceNode:xe,targetNode:ke,elevateOnSelect:we.elevateEdgesOnSelect,zIndexMode:we.zIndexMode}),...ae||W_}},[k.source,k.target,k.sourceHandle,k.targetHandle,k.selected,k.zIndex]),nt),ee=N.useMemo(()=>k.markerStart?`url('#${O0(k.markerStart,S)}')`:void 0,[k.markerStart,S]),G=N.useMemo(()=>k.markerEnd?`url('#${O0(k.markerEnd,S)}')`:void 0,[k.markerEnd,S]);if(k.hidden||q===null||$===null||K===null||ne===null)return null;const X=we=>{const{addSelectedEdges:xe,unselectNodesAndEdges:ke,multiSelectionActive:ae}=B.getState();O&&(B.setState({nodesSelectionActive:!1}),k.selected&&ae?(ke({nodes:[],edges:[k]}),P.current?.blur()):xe([e])),o&&o(we,k)},Q=l?we=>{l(we,{...k})}:void 0,ie=c?we=>{c(we,{...k})}:void 0,se=d?we=>{d(we,{...k})}:void 0,he=p?we=>{p(we,{...k})}:void 0,ye=h?we=>{h(we,{...k})}:void 0,be=we=>{if(!j&&c6.includes(we.key)&&O){const{unselectNodesAndEdges:xe,addSelectedEdges:ke}=B.getState();we.key==="Escape"?(P.current?.blur(),xe({edges:[k]})):ke([e])}};return u.jsx("svg",{style:{zIndex:D},children:u.jsxs("g",{className:xt(["react-flow__edge",`react-flow__edge-${E}`,k.className,C,{selected:k.selected,animated:k.animated,inactive:!O&&!o,updating:L,selectable:O}]),onClick:X,onDoubleClick:Q,onContextMenu:ie,onMouseEnter:se,onMouseMove:he,onMouseLeave:ye,onKeyDown:A?be:void 0,tabIndex:A?0:void 0,role:k.ariaRole??(A?"group":"img"),"aria-roledescription":"edge","data-id":e,"data-testid":`rf__edge-${e}`,"aria-label":k.ariaLabel===null?void 0:k.ariaLabel||`Edge from ${k.source} to ${k.target}`,"aria-describedby":A?`${U6}-${S}`:void 0,ref:P,...k.domAttributes,children:[!F&&u.jsx(z,{id:e,source:k.source,target:k.target,type:k.type,selected:k.selected,animated:k.animated,selectable:O,deletable:k.deletable??!0,label:k.label,labelStyle:k.labelStyle,labelShowBg:k.labelShowBg,labelBgStyle:k.labelBgStyle,labelBgPadding:k.labelBgPadding,labelBgBorderRadius:k.labelBgBorderRadius,sourceX:q,sourceY:$,targetX:K,targetY:ne,sourcePosition:V,targetPosition:W,data:k.data,style:k.style,sourceHandleId:k.sourceHandle,targetHandleId:k.targetHandle,markerStart:ee,markerEnd:G,pathOptions:"pathOptions"in k?k.pathOptions:void 0,interactionWidth:k.interactionWidth}),M&&u.jsx(tI,{edge:k,isReconnectable:M,reconnectRadius:g,onReconnect:y,onReconnectStart:m,onReconnectEnd:b,sourceX:q,sourceY:$,targetX:K,targetY:ne,sourcePosition:V,targetPosition:W,setUpdateHover:I,setReconnecting:U})]})})}var rI=N.memo(nI);const iI=e=>({edgesFocusable:e.edgesFocusable,edgesReconnectable:e.edgesReconnectable,elementsSelectable:e.elementsSelectable,connectionMode:e.connectionMode,onError:e.onError});function f8({defaultMarkerColor:e,onlyRenderVisibleElements:n,rfId:r,edgeTypes:a,noPanClassName:o,onReconnect:l,onEdgeContextMenu:c,onEdgeMouseEnter:d,onEdgeMouseMove:p,onEdgeMouseLeave:h,onEdgeClick:g,reconnectRadius:y,onEdgeDoubleClick:m,onReconnectStart:b,onReconnectEnd:S,disableKeyboardA11y:w}){const{edgesFocusable:C,edgesReconnectable:_,elementsSelectable:j,onError:k}=Be(iI,nt),T=Fq(n);return u.jsxs("div",{className:"react-flow__edges",children:[u.jsx(Gq,{defaultColor:e,rfId:r}),T.map(E=>u.jsx(rI,{id:E,edgesFocusable:C,edgesReconnectable:_,elementsSelectable:j,noPanClassName:o,onReconnect:l,onContextMenu:c,onMouseEnter:d,onMouseMove:p,onMouseLeave:h,onClick:g,reconnectRadius:y,onDoubleClick:m,onReconnectStart:b,onReconnectEnd:S,rfId:r,onError:k,edgeTypes:a,disableKeyboardA11y:w},E))]})}f8.displayName="EdgeRenderer";const aI=N.memo(f8),oI=e=>`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`;function sI({children:e}){const n=Be(oI);return u.jsx("div",{className:"react-flow__viewport xyflow__viewport react-flow__container",style:{transform:n},children:e})}function lI(e){const n=yo(),r=N.useRef(!1);N.useEffect(()=>{!r.current&&n.viewportInitialized&&e&&(setTimeout(()=>e(n),1),r.current=!0)},[e,n.viewportInitialized])}const cI=e=>e.panZoom?.syncViewport;function uI(e){const n=Be(cI),r=rt();return N.useEffect(()=>{e&&(n?.(e),r.setState({transform:[e.x,e.y,e.zoom]}))},[e,n]),null}function dI(e){return e.connection.inProgress?{...e.connection,to:sl(e.connection.to,e.transform)}:{...e.connection}}function fI(e){return dI}function pI(e){const n=fI();return Be(n,nt)}const hI=e=>({nodesConnectable:e.nodesConnectable,isValid:e.connection.isValid,inProgress:e.connection.inProgress,width:e.width,height:e.height});function gI({containerStyle:e,style:n,type:r,component:a}){const{nodesConnectable:o,width:l,height:c,isValid:d,inProgress:p}=Be(hI,nt);return!(l&&o&&p)?null:u.jsx("svg",{style:e,width:l,height:c,className:"react-flow__connectionline react-flow__container",children:u.jsx("g",{className:xt(["react-flow__connection",f6(d)]),children:u.jsx(p8,{style:n,type:r,CustomComponent:a,isValid:d})})})}const p8=({style:e,type:n=ui.Bezier,CustomComponent:r,isValid:a})=>{const{inProgress:o,from:l,fromNode:c,fromHandle:d,fromPosition:p,to:h,toNode:g,toHandle:y,toPosition:m,pointer:b}=pI();if(!o)return;if(r)return u.jsx(r,{connectionLineType:n,connectionLineStyle:e,fromNode:c,fromHandle:d,fromX:l.x,fromY:l.y,toX:h.x,toY:h.y,fromPosition:p,toPosition:m,connectionStatus:f6(a),toNode:g,toHandle:y,pointer:b});let S="";const w={sourceX:l.x,sourceY:l.y,sourcePosition:p,targetX:h.x,targetY:h.y,targetPosition:m};switch(n){case ui.Bezier:[S]=fb(w);break;case ui.SimpleBezier:[S]=e8(w);break;case ui.Step:[S]=M0({...w,borderRadius:0});break;case ui.SmoothStep:[S]=M0(w);break;default:[S]=E6(w)}return u.jsx("path",{d:S,fill:"none",className:"react-flow__connection-path",style:e})};p8.displayName="ConnectionLine";const yI={};function X_(e=yI){N.useRef(e),rt(),N.useEffect(()=>{},[e])}function mI(){rt(),N.useRef(!1),N.useEffect(()=>{},[])}function h8({nodeTypes:e,edgeTypes:n,onInit:r,onNodeClick:a,onEdgeClick:o,onNodeDoubleClick:l,onEdgeDoubleClick:c,onNodeMouseEnter:d,onNodeMouseMove:p,onNodeMouseLeave:h,onNodeContextMenu:g,onSelectionContextMenu:y,onSelectionStart:m,onSelectionEnd:b,connectionLineType:S,connectionLineStyle:w,connectionLineComponent:C,connectionLineContainerStyle:_,selectionKeyCode:j,selectionOnDrag:k,selectionMode:T,multiSelectionKeyCode:E,panActivationKeyCode:z,zoomActivationKeyCode:A,deleteKeyCode:M,onlyRenderVisibleElements:O,elementsSelectable:P,defaultViewport:L,translateExtent:I,minZoom:F,maxZoom:U,preventScrolling:B,defaultMarkerColor:D,zoomOnScroll:q,zoomOnPinch:$,panOnScroll:K,panOnScrollSpeed:ne,panOnScrollMode:V,zoomOnDoubleClick:W,panOnDrag:ee,onPaneClick:G,onPaneMouseEnter:X,onPaneMouseMove:Q,onPaneMouseLeave:ie,onPaneScroll:se,onPaneContextMenu:he,paneClickDistance:ye,nodeClickDistance:be,onEdgeContextMenu:we,onEdgeMouseEnter:xe,onEdgeMouseMove:ke,onEdgeMouseLeave:ae,reconnectRadius:pe,onReconnect:ge,onReconnectStart:je,onReconnectEnd:Ae,noDragClassName:ze,noWheelClassName:Ne,noPanClassName:We,disableKeyboardA11y:He,nodeExtent:Ge,rfId:Dt,viewport:Pt,onViewportChange:Qe}){return X_(e),X_(n),mI(),lI(r),uI(Pt),u.jsx(Nq,{onPaneClick:G,onPaneMouseEnter:X,onPaneMouseMove:Q,onPaneMouseLeave:ie,onPaneContextMenu:he,onPaneScroll:se,paneClickDistance:ye,deleteKeyCode:M,selectionKeyCode:j,selectionOnDrag:k,selectionMode:T,onSelectionStart:m,onSelectionEnd:b,multiSelectionKeyCode:E,panActivationKeyCode:z,zoomActivationKeyCode:A,elementsSelectable:P,zoomOnScroll:q,zoomOnPinch:$,zoomOnDoubleClick:W,panOnScroll:K,panOnScrollSpeed:ne,panOnScrollMode:V,panOnDrag:ee,defaultViewport:L,translateExtent:I,minZoom:F,maxZoom:U,onSelectionContextMenu:y,preventScrolling:B,noDragClassName:ze,noWheelClassName:Ne,noPanClassName:We,disableKeyboardA11y:He,onViewportChange:Qe,isControlledViewport:!!Pt,children:u.jsxs(sI,{children:[u.jsx(aI,{edgeTypes:n,onEdgeClick:o,onEdgeDoubleClick:c,onReconnect:ge,onReconnectStart:je,onReconnectEnd:Ae,onlyRenderVisibleElements:O,onEdgeContextMenu:we,onEdgeMouseEnter:xe,onEdgeMouseMove:ke,onEdgeMouseLeave:ae,reconnectRadius:pe,defaultMarkerColor:D,noPanClassName:We,disableKeyboardA11y:He,rfId:Dt}),u.jsx(gI,{style:w,type:S,component:C,containerStyle:_}),u.jsx("div",{className:"react-flow__edgelabel-renderer"}),u.jsx(Uq,{nodeTypes:e,onNodeClick:a,onNodeDoubleClick:l,onNodeMouseEnter:d,onNodeMouseMove:p,onNodeMouseLeave:h,onNodeContextMenu:g,nodeClickDistance:be,onlyRenderVisibleElements:O,noPanClassName:We,noDragClassName:ze,disableKeyboardA11y:He,nodeExtent:Ge,rfId:Dt}),u.jsx("div",{className:"react-flow__viewport-portal"})]})})}h8.displayName="GraphView";const vI=N.memo(h8),K_=({nodes:e,edges:n,defaultNodes:r,defaultEdges:a,width:o,height:l,fitView:c,fitViewOptions:d,minZoom:p=.5,maxZoom:h=2,nodeOrigin:g,nodeExtent:y,zIndexMode:m="basic"}={})=>{const b=new Map,S=new Map,w=new Map,C=new Map,_=a??n??[],j=r??e??[],k=g??[0,0],T=y??Vs;A6(w,C,_);const E=D0(j,b,S,{nodeOrigin:k,nodeExtent:T,zIndexMode:m});let z=[0,0,1];if(c&&o&&l){const A=al(b,{filter:L=>!!((L.width||L.initialWidth)&&(L.height||L.initialHeight))}),{x:M,y:O,zoom:P}=ub(A,o,l,p,h,d?.padding??.1);z=[M,O,P]}return{rfId:"1",width:o??0,height:l??0,transform:z,nodes:j,nodesInitialized:E,nodeLookup:b,parentLookup:S,edges:_,edgeLookup:C,connectionLookup:w,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:r!==void 0,hasDefaultEdges:a!==void 0,panZoom:null,minZoom:p,maxZoom:h,translateExtent:Vs,nodeExtent:T,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:lo.Strict,domNode:null,paneDragging:!1,noPanClassName:"nopan",nodeOrigin:k,nodeDragThreshold:1,connectionDragThreshold:1,snapGrid:[15,15],snapToGrid:!1,nodesDraggable:!0,nodesConnectable:!0,nodesFocusable:!0,edgesFocusable:!0,edgesReconnectable:!0,elementsSelectable:!0,elevateNodesOnSelect:!0,elevateEdgesOnSelect:!0,selectNodesOnDrag:!0,multiSelectionActive:!1,fitViewQueued:c??!1,fitViewOptions:d,fitViewResolver:null,connection:{...d6},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:DO,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:"react",debug:!1,ariaLabelConfig:u6,zIndexMode:m,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map}},bI=({nodes:e,edges:n,defaultNodes:r,defaultEdges:a,width:o,height:l,fitView:c,fitViewOptions:d,minZoom:p,maxZoom:h,nodeOrigin:g,nodeExtent:y,zIndexMode:m})=>DD((b,S)=>{async function w(){const{nodeLookup:C,panZoom:_,fitViewOptions:j,fitViewResolver:k,width:T,height:E,minZoom:z,maxZoom:A}=S();_&&(await MO({nodes:C,width:T,height:E,panZoom:_,minZoom:z,maxZoom:A},j),k?.resolve(!0),b({fitViewResolver:null}))}return{...K_({nodes:e,edges:n,width:o,height:l,fitView:c,fitViewOptions:d,minZoom:p,maxZoom:h,nodeOrigin:g,nodeExtent:y,defaultNodes:r,defaultEdges:a,zIndexMode:m}),setNodes:C=>{const{nodeLookup:_,parentLookup:j,nodeOrigin:k,elevateNodesOnSelect:T,fitViewQueued:E,zIndexMode:z}=S(),A=D0(C,_,j,{nodeOrigin:k,nodeExtent:y,elevateNodesOnSelect:T,checkEquality:!0,zIndexMode:z});E&&A?(w(),b({nodes:C,nodesInitialized:A,fitViewQueued:!1,fitViewOptions:void 0})):b({nodes:C,nodesInitialized:A})},setEdges:C=>{const{connectionLookup:_,edgeLookup:j}=S();A6(_,j,C),b({edges:C})},setDefaultNodesAndEdges:(C,_)=>{if(C){const{setNodes:j}=S();j(C),b({hasDefaultNodes:!0})}if(_){const{setEdges:j}=S();j(_),b({hasDefaultEdges:!0})}},updateNodeInternals:C=>{const{triggerNodeChanges:_,nodeLookup:j,parentLookup:k,domNode:T,nodeOrigin:E,nodeExtent:z,debug:A,fitViewQueued:M,zIndexMode:O}=S(),{changes:P,updatedInternals:L}=nD(C,j,k,T,E,z,O);L&&(QO(j,k,{nodeOrigin:E,nodeExtent:z,zIndexMode:O}),M?(w(),b({fitViewQueued:!1,fitViewOptions:void 0})):b({}),P?.length>0&&(A&&console.log("React Flow: trigger node changes",P),_?.(P)))},updateNodePositions:(C,_=!1)=>{const j=[];let k=[];const{nodeLookup:T,triggerNodeChanges:E,connection:z,updateConnection:A,onNodesChangeMiddlewareMap:M}=S();for(const[O,P]of C){const L=T.get(O),I=!!(L?.expandParent&&L?.parentId&&P?.position),F={id:O,type:"position",position:I?{x:Math.max(0,P.position.x),y:Math.max(0,P.position.y)}:P.position,dragging:_};if(L&&z.inProgress&&z.fromNode.id===L.id){const U=Ki(L,z.fromHandle,me.Left,!0);A({...z,from:U})}I&&L.parentId&&j.push({id:O,parentId:L.parentId,rect:{...P.internals.positionAbsolute,width:P.measured.width??0,height:P.measured.height??0}}),k.push(F)}if(j.length>0){const{parentLookup:O,nodeOrigin:P}=S(),L=mb(j,T,O,P);k.push(...L)}for(const O of M.values())k=O(k);E(k)},triggerNodeChanges:C=>{const{onNodesChange:_,setNodes:j,nodes:k,hasDefaultNodes:T,debug:E}=S();if(C?.length){if(T){const z=vb(C,k);j(z)}E&&console.log("React Flow: trigger node changes",C),_?.(C)}},triggerEdgeChanges:C=>{const{onEdgesChange:_,setEdges:j,edges:k,hasDefaultEdges:T,debug:E}=S();if(C?.length){if(T){const z=$6(C,k);j(z)}E&&console.log("React Flow: trigger edge changes",C),_?.(C)}},addSelectedNodes:C=>{const{multiSelectionActive:_,edgeLookup:j,nodeLookup:k,triggerNodeChanges:T,triggerEdgeChanges:E}=S();if(_){const z=C.map(A=>Li(A,!0));T(z);return}T(eo(k,new Set([...C]),!0)),E(eo(j))},addSelectedEdges:C=>{const{multiSelectionActive:_,edgeLookup:j,nodeLookup:k,triggerNodeChanges:T,triggerEdgeChanges:E}=S();if(_){const z=C.map(A=>Li(A,!0));E(z);return}E(eo(j,new Set([...C]))),T(eo(k,new Set,!0))},unselectNodesAndEdges:({nodes:C,edges:_}={})=>{const{edges:j,nodes:k,nodeLookup:T,triggerNodeChanges:E,triggerEdgeChanges:z}=S(),A=C||k,M=_||j,O=A.map(L=>{const I=T.get(L.id);return I&&(I.selected=!1),Li(L.id,!1)}),P=M.map(L=>Li(L.id,!1));E(O),z(P)},setMinZoom:C=>{const{panZoom:_,maxZoom:j}=S();_?.setScaleExtent([C,j]),b({minZoom:C})},setMaxZoom:C=>{const{panZoom:_,minZoom:j}=S();_?.setScaleExtent([j,C]),b({maxZoom:C})},setTranslateExtent:C=>{S().panZoom?.setTranslateExtent(C),b({translateExtent:C})},resetSelectedElements:()=>{const{edges:C,nodes:_,triggerNodeChanges:j,triggerEdgeChanges:k,elementsSelectable:T}=S();if(!T)return;const E=_.reduce((A,M)=>M.selected?[...A,Li(M.id,!1)]:A,[]),z=C.reduce((A,M)=>M.selected?[...A,Li(M.id,!1)]:A,[]);j(E),k(z)},setNodeExtent:C=>{const{nodes:_,nodeLookup:j,parentLookup:k,nodeOrigin:T,elevateNodesOnSelect:E,nodeExtent:z,zIndexMode:A}=S();C[0][0]===z[0][0]&&C[0][1]===z[0][1]&&C[1][0]===z[1][0]&&C[1][1]===z[1][1]||(D0(_,j,k,{nodeOrigin:T,nodeExtent:C,elevateNodesOnSelect:E,checkEquality:!1,zIndexMode:A}),b({nodeExtent:C}))},panBy:C=>{const{transform:_,width:j,height:k,panZoom:T,translateExtent:E}=S();return rD({delta:C,panZoom:T,transform:_,translateExtent:E,width:j,height:k})},setCenter:async(C,_,j)=>{const{width:k,height:T,maxZoom:E,panZoom:z}=S();if(!z)return Promise.resolve(!1);const A=typeof j?.zoom<"u"?j.zoom:E;return await z.setViewport({x:k/2-C*A,y:T/2-_*A,zoom:A},{duration:j?.duration,ease:j?.ease,interpolate:j?.interpolate}),Promise.resolve(!0)},cancelConnection:()=>{b({connection:{...d6}})},updateConnection:C=>{b({connection:C})},reset:()=>b({...K_()})}},Object.is);function g8({initialNodes:e,initialEdges:n,defaultNodes:r,defaultEdges:a,initialWidth:o,initialHeight:l,initialMinZoom:c,initialMaxZoom:d,initialFitViewOptions:p,fitView:h,nodeOrigin:g,nodeExtent:y,zIndexMode:m,children:b}){const[S]=N.useState(()=>bI({nodes:e,edges:n,defaultNodes:r,defaultEdges:a,width:o,height:l,fitView:h,minZoom:c,maxZoom:d,fitViewOptions:p,nodeOrigin:g,nodeExtent:y,zIndexMode:m}));return u.jsx(LD,{value:S,children:u.jsx(sq,{children:b})})}function xI({children:e,nodes:n,edges:r,defaultNodes:a,defaultEdges:o,width:l,height:c,fitView:d,fitViewOptions:p,minZoom:h,maxZoom:g,nodeOrigin:y,nodeExtent:m,zIndexMode:b}){return N.useContext(Fu)?u.jsx(u.Fragment,{children:e}):u.jsx(g8,{initialNodes:n,initialEdges:r,defaultNodes:a,defaultEdges:o,initialWidth:l,initialHeight:c,fitView:d,initialFitViewOptions:p,initialMinZoom:h,initialMaxZoom:g,nodeOrigin:y,nodeExtent:m,zIndexMode:b,children:e})}const SI={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0};function wI({nodes:e,edges:n,defaultNodes:r,defaultEdges:a,className:o,nodeTypes:l,edgeTypes:c,onNodeClick:d,onEdgeClick:p,onInit:h,onMove:g,onMoveStart:y,onMoveEnd:m,onConnect:b,onConnectStart:S,onConnectEnd:w,onClickConnectStart:C,onClickConnectEnd:_,onNodeMouseEnter:j,onNodeMouseMove:k,onNodeMouseLeave:T,onNodeContextMenu:E,onNodeDoubleClick:z,onNodeDragStart:A,onNodeDrag:M,onNodeDragStop:O,onNodesDelete:P,onEdgesDelete:L,onDelete:I,onSelectionChange:F,onSelectionDragStart:U,onSelectionDrag:B,onSelectionDragStop:D,onSelectionContextMenu:q,onSelectionStart:$,onSelectionEnd:K,onBeforeDelete:ne,connectionMode:V,connectionLineType:W=ui.Bezier,connectionLineStyle:ee,connectionLineComponent:G,connectionLineContainerStyle:X,deleteKeyCode:Q="Backspace",selectionKeyCode:ie="Shift",selectionOnDrag:se=!1,selectionMode:he=Ws.Full,panActivationKeyCode:ye="Space",multiSelectionKeyCode:be=Ys()?"Meta":"Control",zoomActivationKeyCode:we=Ys()?"Meta":"Control",snapToGrid:xe,snapGrid:ke,onlyRenderVisibleElements:ae=!1,selectNodesOnDrag:pe,nodesDraggable:ge,autoPanOnNodeFocus:je,nodesConnectable:Ae,nodesFocusable:ze,nodeOrigin:Ne=F6,edgesFocusable:We,edgesReconnectable:He,elementsSelectable:Ge=!0,defaultViewport:Dt=ZD,minZoom:Pt=.5,maxZoom:Qe=2,translateExtent:Ct=Vs,preventScrolling:ta=!0,nodeExtent:Zn,defaultMarkerColor:wo="#b1b1b7",zoomOnScroll:na=!0,zoomOnPinch:qt=!0,panOnScroll:at=!1,panOnScrollSpeed:qn=.5,panOnScrollMode:Ht=Pi.Free,zoomOnDoubleClick:fd=!0,panOnDrag:pd=!0,onPaneClick:hd,onPaneMouseEnter:ra,onPaneMouseMove:ia,onPaneMouseLeave:aa,onPaneScroll:Qn,onPaneContextMenu:oa,paneClickDistance:hi=1,nodeClickDistance:gd=0,children:gl,onReconnect:_o,onReconnectStart:gi,onReconnectEnd:yd,onEdgeContextMenu:yl,onEdgeDoubleClick:ml,onEdgeMouseEnter:vl,onEdgeMouseMove:ko,onEdgeMouseLeave:Co,reconnectRadius:bl=10,onNodesChange:xl,onEdgesChange:In,noDragClassName:wt="nodrag",noWheelClassName:It="nowheel",noPanClassName:Jn="nopan",fitView:sa,fitViewOptions:Sl,connectOnClick:md,attributionPosition:wl,proOptions:yi,defaultEdgeOptions:Eo,elevateNodesOnSelect:Rr=!0,elevateEdgesOnSelect:zr=!1,disableKeyboardA11y:Nr=!1,autoPanOnConnect:Mr,autoPanOnNodeDrag:ft,autoPanSpeed:_l,connectionRadius:kl,isValidConnection:er,onError:Or,style:vd,id:jo,nodeDragThreshold:Cl,connectionDragThreshold:bd,viewport:la,onViewportChange:ca,width:wn,height:$t,colorMode:El="light",debug:xd,onScroll:ua,ariaLabelConfig:jl,zIndexMode:mi="basic",...Sd},Vt){const vi=jo||"1",Tl=tq(El),To=N.useCallback(tr=>{tr.currentTarget.scrollTo({top:0,left:0,behavior:"instant"}),ua?.(tr)},[ua]);return u.jsx("div",{"data-testid":"rf__wrapper",...Sd,onScroll:To,style:{...vd,...SI},ref:Vt,className:xt(["react-flow",o,Tl]),id:jo,role:"application",children:u.jsxs(xI,{nodes:e,edges:n,width:wn,height:$t,fitView:sa,fitViewOptions:Sl,minZoom:Pt,maxZoom:Qe,nodeOrigin:Ne,nodeExtent:Zn,zIndexMode:mi,children:[u.jsx(vI,{onInit:h,onNodeClick:d,onEdgeClick:p,onNodeMouseEnter:j,onNodeMouseMove:k,onNodeMouseLeave:T,onNodeContextMenu:E,onNodeDoubleClick:z,nodeTypes:l,edgeTypes:c,connectionLineType:W,connectionLineStyle:ee,connectionLineComponent:G,connectionLineContainerStyle:X,selectionKeyCode:ie,selectionOnDrag:se,selectionMode:he,deleteKeyCode:Q,multiSelectionKeyCode:be,panActivationKeyCode:ye,zoomActivationKeyCode:we,onlyRenderVisibleElements:ae,defaultViewport:Dt,translateExtent:Ct,minZoom:Pt,maxZoom:Qe,preventScrolling:ta,zoomOnScroll:na,zoomOnPinch:qt,zoomOnDoubleClick:fd,panOnScroll:at,panOnScrollSpeed:qn,panOnScrollMode:Ht,panOnDrag:pd,onPaneClick:hd,onPaneMouseEnter:ra,onPaneMouseMove:ia,onPaneMouseLeave:aa,onPaneScroll:Qn,onPaneContextMenu:oa,paneClickDistance:hi,nodeClickDistance:gd,onSelectionContextMenu:q,onSelectionStart:$,onSelectionEnd:K,onReconnect:_o,onReconnectStart:gi,onReconnectEnd:yd,onEdgeContextMenu:yl,onEdgeDoubleClick:ml,onEdgeMouseEnter:vl,onEdgeMouseMove:ko,onEdgeMouseLeave:Co,reconnectRadius:bl,defaultMarkerColor:wo,noDragClassName:wt,noWheelClassName:It,noPanClassName:Jn,rfId:vi,disableKeyboardA11y:Nr,nodeExtent:Zn,viewport:la,onViewportChange:ca}),u.jsx(eq,{nodes:e,edges:n,defaultNodes:r,defaultEdges:a,onConnect:b,onConnectStart:S,onConnectEnd:w,onClickConnectStart:C,onClickConnectEnd:_,nodesDraggable:ge,autoPanOnNodeFocus:je,nodesConnectable:Ae,nodesFocusable:ze,edgesFocusable:We,edgesReconnectable:He,elementsSelectable:Ge,elevateNodesOnSelect:Rr,elevateEdgesOnSelect:zr,minZoom:Pt,maxZoom:Qe,nodeExtent:Zn,onNodesChange:xl,onEdgesChange:In,snapToGrid:xe,snapGrid:ke,connectionMode:V,translateExtent:Ct,connectOnClick:md,defaultEdgeOptions:Eo,fitView:sa,fitViewOptions:Sl,onNodesDelete:P,onEdgesDelete:L,onDelete:I,onNodeDragStart:A,onNodeDrag:M,onNodeDragStop:O,onSelectionDrag:B,onSelectionDragStart:U,onSelectionDragStop:D,onMove:g,onMoveStart:y,onMoveEnd:m,noPanClassName:Jn,nodeOrigin:Ne,rfId:vi,autoPanOnConnect:Mr,autoPanOnNodeDrag:ft,autoPanSpeed:_l,onError:Or,connectionRadius:kl,isValidConnection:er,selectNodesOnDrag:pe,nodeDragThreshold:Cl,connectionDragThreshold:bd,onBeforeDelete:ne,debug:xd,ariaLabelConfig:jl,zIndexMode:mi}),u.jsx(KD,{onSelectionChange:F}),gl,u.jsx(VD,{proOptions:yi,position:wl}),u.jsx($D,{rfId:vi,disableKeyboardA11y:Nr})]})})}var _I=V6(wI);const kI=e=>e.domNode?.querySelector(".react-flow__edgelabel-renderer");function CI({children:e}){const n=Be(kI);return n?ID.createPortal(e,n):null}function EI({dimensions:e,lineWidth:n,variant:r,className:a}){return u.jsx("path",{strokeWidth:n,d:`M${e[0]/2} 0 V${e[1]} M0 ${e[1]/2} H${e[0]}`,className:xt(["react-flow__background-pattern",r,a])})}function jI({radius:e,className:n}){return u.jsx("circle",{cx:e,cy:e,r:e,className:xt(["react-flow__background-pattern","dots",n])})}var wr;(function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"})(wr||(wr={}));const TI={[wr.Dots]:1,[wr.Lines]:1,[wr.Cross]:6},AI=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function y8({id:e,variant:n=wr.Dots,gap:r=20,size:a,lineWidth:o=1,offset:l=0,color:c,bgColor:d,style:p,className:h,patternClassName:g}){const y=N.useRef(null),{transform:m,patternId:b}=Be(AI,nt),S=a||TI[n],w=n===wr.Dots,C=n===wr.Cross,_=Array.isArray(r)?r:[r,r],j=[_[0]*m[2]||1,_[1]*m[2]||1],k=S*m[2],T=Array.isArray(l)?l:[l,l],E=C?[k,k]:j,z=[T[0]*m[2]||1+E[0]/2,T[1]*m[2]||1+E[1]/2],A=`${b}${e||""}`;return u.jsxs("svg",{className:xt(["react-flow__background",h]),style:{...p,...$u,"--xy-background-color-props":d,"--xy-background-pattern-color-props":c},ref:y,"data-testid":"rf__background",children:[u.jsx("pattern",{id:A,x:m[0]%j[0],y:m[1]%j[1],width:j[0],height:j[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${z[0]},-${z[1]})`,children:w?u.jsx(jI,{radius:k/2,className:g}):u.jsx(EI,{dimensions:E,lineWidth:o,variant:n,className:g})}),u.jsx("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${A})`})]})}y8.displayName="Background";const RI=N.memo(y8);function zI(){return u.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",children:u.jsx("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"})})}function NI(){return u.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5",children:u.jsx("path",{d:"M0 0h32v4.2H0z"})})}function MI(){return u.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30",children:u.jsx("path",{d:"M3.692 4.63c0-.53.4-.938.939-.938h5.215V0H4.708C2.13 0 0 2.054 0 4.63v5.216h3.692V4.631zM27.354 0h-5.2v3.692h5.17c.53 0 .984.4.984.939v5.215H32V4.631A4.624 4.624 0 0027.354 0zm.954 24.83c0 .532-.4.94-.939.94h-5.215v3.768h5.215c2.577 0 4.631-2.13 4.631-4.707v-5.139h-3.692v5.139zm-23.677.94c-.531 0-.939-.4-.939-.94v-5.138H0v5.139c0 2.577 2.13 4.707 4.708 4.707h5.138V25.77H4.631z"})})}function OI(){return u.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:u.jsx("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0 8 0 4.571 3.429 4.571 7.619v3.048H3.048A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047zm4.724-13.866H7.467V7.619c0-2.59 2.133-4.724 4.723-4.724 2.591 0 4.724 2.133 4.724 4.724v3.048z"})})}function DI(){return u.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:u.jsx("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0c-4.114 1.828-1.37 2.133.305 2.438 1.676.305 4.42 2.59 4.42 5.181v3.048H3.047A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047z"})})}function Yc({children:e,className:n,...r}){return u.jsx("button",{type:"button",className:xt(["react-flow__controls-button",n]),...r,children:e})}const qI=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom,ariaLabelConfig:e.ariaLabelConfig});function m8({style:e,showZoom:n=!0,showFitView:r=!0,showInteractive:a=!0,fitViewOptions:o,onZoomIn:l,onZoomOut:c,onFitView:d,onInteractiveChange:p,className:h,children:g,position:y="bottom-left",orientation:m="vertical","aria-label":b}){const S=rt(),{isInteractive:w,minZoomReached:C,maxZoomReached:_,ariaLabelConfig:j}=Be(qI,nt),{zoomIn:k,zoomOut:T,fitView:E}=yo(),z=()=>{k(),l?.()},A=()=>{T(),c?.()},M=()=>{E(o),d?.()},O=()=>{S.setState({nodesDraggable:!w,nodesConnectable:!w,elementsSelectable:!w}),p?.(!w)},P=m==="horizontal"?"horizontal":"vertical";return u.jsxs(Pu,{className:xt(["react-flow__controls",P,h]),position:y,style:e,"data-testid":"rf__controls","aria-label":b??j["controls.ariaLabel"],children:[n&&u.jsxs(u.Fragment,{children:[u.jsx(Yc,{onClick:z,className:"react-flow__controls-zoomin",title:j["controls.zoomIn.ariaLabel"],"aria-label":j["controls.zoomIn.ariaLabel"],disabled:_,children:u.jsx(zI,{})}),u.jsx(Yc,{onClick:A,className:"react-flow__controls-zoomout",title:j["controls.zoomOut.ariaLabel"],"aria-label":j["controls.zoomOut.ariaLabel"],disabled:C,children:u.jsx(NI,{})})]}),r&&u.jsx(Yc,{className:"react-flow__controls-fitview",onClick:M,title:j["controls.fitView.ariaLabel"],"aria-label":j["controls.fitView.ariaLabel"],children:u.jsx(MI,{})}),a&&u.jsx(Yc,{className:"react-flow__controls-interactive",onClick:O,title:j["controls.interactive.ariaLabel"],"aria-label":j["controls.interactive.ariaLabel"],children:w?u.jsx(DI,{}):u.jsx(OI,{})}),g]})}m8.displayName="Controls";const II=N.memo(m8);function LI({id:e,x:n,y:r,width:a,height:o,style:l,color:c,strokeColor:d,strokeWidth:p,className:h,borderRadius:g,shapeRendering:y,selected:m,onClick:b}){const{background:S,backgroundColor:w}=l||{},C=c||S||w;return u.jsx("rect",{className:xt(["react-flow__minimap-node",{selected:m},h]),x:n,y:r,rx:g,ry:g,width:a,height:o,style:{fill:C,stroke:d,strokeWidth:p},shapeRendering:y,onClick:b?_=>b(_,e):void 0})}const BI=N.memo(LI),HI=e=>e.nodes.map(n=>n.id),Vp=e=>e instanceof Function?e:()=>e;function UI({nodeStrokeColor:e,nodeColor:n,nodeClassName:r="",nodeBorderRadius:a=5,nodeStrokeWidth:o,nodeComponent:l=BI,onClick:c}){const d=Be(HI,nt),p=Vp(n),h=Vp(e),g=Vp(r),y=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return u.jsx(u.Fragment,{children:d.map(m=>u.jsx(PI,{id:m,nodeColorFunc:p,nodeStrokeColorFunc:h,nodeClassNameFunc:g,nodeBorderRadius:a,nodeStrokeWidth:o,NodeComponent:l,onClick:c,shapeRendering:y},m))})}function FI({id:e,nodeColorFunc:n,nodeStrokeColorFunc:r,nodeClassNameFunc:a,nodeBorderRadius:o,nodeStrokeWidth:l,shapeRendering:c,NodeComponent:d,onClick:p}){const{node:h,x:g,y,width:m,height:b}=Be(S=>{const{internals:w}=S.nodeLookup.get(e),C=w.userNode,{x:_,y:j}=w.positionAbsolute,{width:k,height:T}=Er(C);return{node:C,x:_,y:j,width:k,height:T}},nt);return!h||h.hidden||!v6(h)?null:u.jsx(d,{x:g,y,width:m,height:b,style:h.style,selected:!!h.selected,className:a(h),color:n(h),borderRadius:o,strokeColor:r(h),strokeWidth:l,shapeRendering:c,onClick:p,id:h.id})}const PI=N.memo(FI);var $I=N.memo(UI);const VI=200,WI=150,GI=e=>!e.hidden,YI=e=>{const n={x:-e.transform[0]/e.transform[2],y:-e.transform[1]/e.transform[2],width:e.width/e.transform[2],height:e.height/e.transform[2]};return{viewBB:n,boundingRect:e.nodeLookup.size>0?m6(al(e.nodeLookup,{filter:GI}),n):n,rfId:e.rfId,panZoom:e.panZoom,translateExtent:e.translateExtent,flowWidth:e.width,flowHeight:e.height,ariaLabelConfig:e.ariaLabelConfig}},XI="react-flow__minimap-desc";function v8({style:e,className:n,nodeStrokeColor:r,nodeColor:a,nodeClassName:o="",nodeBorderRadius:l=5,nodeStrokeWidth:c,nodeComponent:d,bgColor:p,maskColor:h,maskStrokeColor:g,maskStrokeWidth:y,position:m="bottom-right",onClick:b,onNodeClick:S,pannable:w=!1,zoomable:C=!1,ariaLabel:_,inversePan:j,zoomStep:k=1,offsetScale:T=5}){const E=rt(),z=N.useRef(null),{boundingRect:A,viewBB:M,rfId:O,panZoom:P,translateExtent:L,flowWidth:I,flowHeight:F,ariaLabelConfig:U}=Be(YI,nt),B=e?.width??VI,D=e?.height??WI,q=A.width/B,$=A.height/D,K=Math.max(q,$),ne=K*B,V=K*D,W=T*K,ee=A.x-(ne-A.width)/2-W,G=A.y-(V-A.height)/2-W,X=ne+W*2,Q=V+W*2,ie=`${XI}-${O}`,se=N.useRef(0),he=N.useRef();se.current=K,N.useEffect(()=>{if(z.current&&P)return he.current=fD({domNode:z.current,panZoom:P,getTransform:()=>E.getState().transform,getViewScale:()=>se.current}),()=>{he.current?.destroy()}},[P]),N.useEffect(()=>{he.current?.update({translateExtent:L,width:I,height:F,inversePan:j,pannable:w,zoomStep:k,zoomable:C})},[w,C,j,k,L,I,F]);const ye=b?xe=>{const[ke,ae]=he.current?.pointer(xe)||[0,0];b(xe,{x:ke,y:ae})}:void 0,be=S?N.useCallback((xe,ke)=>{const ae=E.getState().nodeLookup.get(ke).internals.userNode;S(xe,ae)},[]):void 0,we=_??U["minimap.ariaLabel"];return u.jsx(Pu,{position:m,style:{...e,"--xy-minimap-background-color-props":typeof p=="string"?p:void 0,"--xy-minimap-mask-background-color-props":typeof h=="string"?h:void 0,"--xy-minimap-mask-stroke-color-props":typeof g=="string"?g:void 0,"--xy-minimap-mask-stroke-width-props":typeof y=="number"?y*K:void 0,"--xy-minimap-node-background-color-props":typeof a=="string"?a:void 0,"--xy-minimap-node-stroke-color-props":typeof r=="string"?r:void 0,"--xy-minimap-node-stroke-width-props":typeof c=="number"?c:void 0},className:xt(["react-flow__minimap",n]),"data-testid":"rf__minimap",children:u.jsxs("svg",{width:B,height:D,viewBox:`${ee} ${G} ${X} ${Q}`,className:"react-flow__minimap-svg",role:"img","aria-labelledby":ie,ref:z,onClick:ye,children:[we&&u.jsx("title",{id:ie,children:we}),u.jsx($I,{onClick:be,nodeColor:a,nodeStrokeColor:r,nodeBorderRadius:l,nodeClassName:o,nodeStrokeWidth:c,nodeComponent:d}),u.jsx("path",{className:"react-flow__minimap-mask",d:`M${ee-W},${G-W}h${X+W*2}v${Q+W*2}h${-X-W*2}z + M${M.x},${M.y}h${M.width}v${M.height}h${-M.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}v8.displayName="MiniMap";const KI=N.memo(v8),ZI=e=>n=>e?`${Math.max(1/n.transform[2],1)}`:void 0,QI={[po.Line]:"right",[po.Handle]:"bottom-right"};function JI({nodeId:e,position:n,variant:r=po.Handle,className:a,style:o=void 0,children:l,color:c,minWidth:d=10,minHeight:p=10,maxWidth:h=Number.MAX_VALUE,maxHeight:g=Number.MAX_VALUE,keepAspectRatio:y=!1,resizeDirection:m,autoScale:b=!0,shouldResize:S,onResizeStart:w,onResize:C,onResizeEnd:_}){const j=X6(),k=typeof e=="string"?e:j,T=rt(),E=N.useRef(null),z=r===po.Handle,A=Be(N.useCallback(ZI(z&&b),[z,b]),nt),M=N.useRef(null),O=n??QI[r];N.useEffect(()=>{if(!(!E.current||!k))return M.current||(M.current=ED({domNode:E.current,nodeId:k,getStoreItems:()=>{const{nodeLookup:L,transform:I,snapGrid:F,snapToGrid:U,nodeOrigin:B,domNode:D}=T.getState();return{nodeLookup:L,transform:I,snapGrid:F,snapToGrid:U,nodeOrigin:B,paneDomNode:D}},onChange:(L,I)=>{const{triggerNodeChanges:F,nodeLookup:U,parentLookup:B,nodeOrigin:D}=T.getState(),q=[],$={x:L.x,y:L.y},K=U.get(k);if(K&&K.expandParent&&K.parentId){const ne=K.origin??D,V=L.width??K.measured.width??0,W=L.height??K.measured.height??0,ee={id:K.id,parentId:K.parentId,rect:{width:V,height:W,...b6({x:L.x??K.position.x,y:L.y??K.position.y},{width:V,height:W},K.parentId,U,ne)}},G=mb([ee],U,B,D);q.push(...G),$.x=L.x?Math.max(ne[0]*V,L.x):void 0,$.y=L.y?Math.max(ne[1]*W,L.y):void 0}if($.x!==void 0&&$.y!==void 0){const ne={id:k,type:"position",position:{...$}};q.push(ne)}if(L.width!==void 0&&L.height!==void 0){const V={id:k,type:"dimensions",resizing:!0,setAttributes:m?m==="horizontal"?"width":"height":!0,dimensions:{width:L.width,height:L.height}};q.push(V)}for(const ne of I){const V={...ne,type:"position"};q.push(V)}F(q)},onEnd:({width:L,height:I})=>{const F={id:k,type:"dimensions",resizing:!1,dimensions:{width:L,height:I}};T.getState().triggerNodeChanges([F])}})),M.current.update({controlPosition:O,boundaries:{minWidth:d,minHeight:p,maxWidth:h,maxHeight:g},keepAspectRatio:y,resizeDirection:m,onResizeStart:w,onResize:C,onResizeEnd:_,shouldResize:S}),()=>{M.current?.destroy()}},[O,d,p,h,g,y,w,C,_,S]);const P=O.split("-");return u.jsx("div",{className:xt(["react-flow__resize-control","nodrag",...P,r,a]),ref:E,style:{...o,scale:A,...c&&{[z?"backgroundColor":"borderColor"]:c}},children:l})}N.memo(JI);const Wn={http:"#3b82f6",messaging:"#8b5cf6",statemachine:"#f59e0b",events:"#ef4444",integration:"#10b981",scheduling:"#6366f1",infrastructure:"#64748b",middleware:"#06b6d4",database:"#f97316",observability:"#84cc16",pipeline:"#e879f9",cicd:"#f472b6",security:"#fb923c",deployment:"#34d399",platform:"#0ea5e9"},L0=[{type:"http.server",label:"HTTP Server",category:"http",defaultConfig:{address:":8080"},configFields:[{key:"address",label:"Address",type:"string",defaultValue:":8080"},{key:"readTimeout",label:"Read Timeout",type:"string",defaultValue:"30s"},{key:"writeTimeout",label:"Write Timeout",type:"string",defaultValue:"30s"}],ioSignature:{inputs:[],outputs:[{name:"request",type:"http.Request"}]},maxIncoming:0},{type:"http.router",label:"HTTP Router",category:"http",defaultConfig:{},configFields:[{key:"prefix",label:"Path Prefix",type:"string"}],ioSignature:{inputs:[{name:"request",type:"http.Request"}],outputs:[{name:"routed",type:"http.Request"}]}},{type:"http.handler",label:"HTTP Handler",category:"http",defaultConfig:{method:"GET",path:"/"},configFields:[{key:"method",label:"Method",type:"select",options:["GET","POST","PUT","DELETE","PATCH"]},{key:"path",label:"Path",type:"string",defaultValue:"/"}],ioSignature:{inputs:[{name:"request",type:"http.Request"}],outputs:[{name:"response",type:"http.Response"}]}},{type:"http.proxy",label:"HTTP Proxy",category:"http",defaultConfig:{target:""},configFields:[{key:"target",label:"Target URL",type:"string"},{key:"pathRewrite",label:"Path Rewrite",type:"string"}],ioSignature:{inputs:[{name:"request",type:"http.Request"}],outputs:[{name:"proxied",type:"http.Response"}]}},{type:"http.simple_proxy",label:"Simple Proxy",category:"http",defaultConfig:{},configFields:[{key:"targets",label:"Targets",type:"map",mapValueType:"string",description:"Map of URL prefix to backend URL (e.g. /api -> http://localhost:3000)",placeholder:"/api=http://backend:8080"}],ioSignature:{inputs:[{name:"request",type:"http.Request"}],outputs:[{name:"proxied",type:"http.Response"}]}},{type:"static.fileserver",label:"Static File Server",category:"http",defaultConfig:{prefix:"/",spaFallback:!0,cacheMaxAge:3600},configFields:[{key:"root",label:"Root Directory",type:"string",required:!0,description:"Path to the directory containing static files",placeholder:"./ui/dist"},{key:"prefix",label:"URL Prefix",type:"string",defaultValue:"/",description:"URL path prefix to serve files under",placeholder:"/"},{key:"spaFallback",label:"SPA Fallback",type:"boolean",defaultValue:!0,description:"When enabled, serves index.html for unmatched paths (for single-page apps)"},{key:"cacheMaxAge",label:"Cache Max-Age (sec)",type:"number",defaultValue:3600,description:"Cache-Control max-age in seconds for static assets"},{key:"router",label:"Router Name",type:"string",description:"Explicit router module name to register on (auto-detected if omitted)",placeholder:"my-router",inheritFrom:"dependency.name"}],ioSignature:{inputs:[{name:"request",type:"http.Request"}],outputs:[{name:"file",type:"http.Response"}]}},{type:"api.handler",label:"API Handler",category:"http",defaultConfig:{method:"GET",path:"/api"},configFields:[{key:"method",label:"Method",type:"select",options:["GET","POST","PUT","DELETE","PATCH"]},{key:"path",label:"Path",type:"string",defaultValue:"/api"}],ioSignature:{inputs:[{name:"request",type:"http.Request"}],outputs:[{name:"response",type:"JSON"}]}},{type:"http.middleware.auth",label:"Auth Middleware",category:"middleware",defaultConfig:{type:"jwt"},configFields:[{key:"type",label:"Auth Type",type:"select",options:["jwt","basic","apikey"]},{key:"secret",label:"Secret",type:"string"}],ioSignature:{inputs:[{name:"request",type:"http.Request"}],outputs:[{name:"authed",type:"http.Request"}]}},{type:"http.middleware.logging",label:"Logging Middleware",category:"middleware",defaultConfig:{level:"info"},configFields:[{key:"level",label:"Log Level",type:"select",options:["debug","info","warn","error"]}],ioSignature:{inputs:[{name:"request",type:"http.Request"}],outputs:[{name:"logged",type:"http.Request"}]}},{type:"http.middleware.ratelimit",label:"Rate Limiter",category:"middleware",defaultConfig:{rps:100},configFields:[{key:"rps",label:"Requests/sec",type:"number",defaultValue:100},{key:"burst",label:"Burst",type:"number",defaultValue:200}],ioSignature:{inputs:[{name:"request",type:"http.Request"}],outputs:[{name:"limited",type:"http.Request"}]}},{type:"http.middleware.cors",label:"CORS Middleware",category:"middleware",defaultConfig:{allowedOrigins:["*"],allowedMethods:["GET","POST","PUT","DELETE","OPTIONS"]},configFields:[{key:"allowedOrigins",label:"Allowed Origins",type:"array",arrayItemType:"string",defaultValue:["*"],description:"Allowed origins"},{key:"allowedMethods",label:"Allowed Methods",type:"array",arrayItemType:"string",defaultValue:["GET","POST","PUT","DELETE","OPTIONS"],description:"Allowed HTTP methods"}],ioSignature:{inputs:[{name:"request",type:"http.Request"}],outputs:[{name:"cors",type:"http.Request"}]}},{type:"messaging.broker",label:"Message Broker",category:"messaging",defaultConfig:{provider:"nats"},configFields:[{key:"provider",label:"Provider",type:"select",options:["nats","rabbitmq","kafka"]},{key:"url",label:"URL",type:"string"}],ioSignature:{inputs:[{name:"message",type:"[]byte"}],outputs:[{name:"message",type:"[]byte"}]}},{type:"messaging.handler",label:"Message Handler",category:"messaging",defaultConfig:{topic:""},configFields:[{key:"topic",label:"Topic",type:"string"},{key:"queue",label:"Queue Group",type:"string"}],ioSignature:{inputs:[{name:"message",type:"[]byte"}],outputs:[{name:"result",type:"[]byte"}]}},{type:"messaging.broker.eventbus",label:"EventBus Bridge",category:"messaging",defaultConfig:{},configFields:[],ioSignature:{inputs:[{name:"event",type:"Event"}],outputs:[{name:"message",type:"[]byte"}]}},{type:"statemachine.engine",label:"State Machine",category:"statemachine",defaultConfig:{},configFields:[{key:"initialState",label:"Initial State",type:"string"}],ioSignature:{inputs:[{name:"event",type:"Event"}],outputs:[{name:"transition",type:"Transition"}]}},{type:"state.tracker",label:"State Tracker",category:"statemachine",defaultConfig:{},configFields:[{key:"store",label:"Store Type",type:"select",options:["memory","redis","database"]}],ioSignature:{inputs:[{name:"state",type:"State"}],outputs:[{name:"tracked",type:"State"}]}},{type:"state.connector",label:"State Connector",category:"statemachine",defaultConfig:{},configFields:[],ioSignature:{inputs:[{name:"state",type:"State"}],outputs:[{name:"connected",type:"State"}]}},{type:"processing.step",label:"Processing Step",category:"statemachine",defaultConfig:{maxRetries:2,retryBackoffMs:1e3,timeoutSeconds:30},configFields:[{key:"componentId",label:"Component ID",type:"string",required:!0,description:"Service name of the component to execute",inheritFrom:"dependency.name"},{key:"successTransition",label:"Success Transition",type:"string",description:"State transition to trigger on success",placeholder:"completed"},{key:"compensateTransition",label:"Compensate Transition",type:"string",description:"State transition to trigger on failure for compensation",placeholder:"failed"},{key:"maxRetries",label:"Max Retries",type:"number",defaultValue:2,description:"Maximum number of retry attempts"},{key:"retryBackoffMs",label:"Retry Backoff (ms)",type:"number",defaultValue:1e3,description:"Base backoff duration in milliseconds between retries"},{key:"timeoutSeconds",label:"Timeout (sec)",type:"number",defaultValue:30,description:"Maximum execution time per attempt in seconds"}],ioSignature:{inputs:[{name:"input",type:"any"}],outputs:[{name:"result",type:"any"},{name:"transition",type:"string"}]}},{type:"conditional.ifelse",label:"If/Else Branch",category:"statemachine",defaultConfig:{expression:"",true_target:"",false_target:""},configFields:[{key:"expression",label:"Condition Expression",type:"string"},{key:"true_target",label:"True Target",type:"string"},{key:"false_target",label:"False Target",type:"string"}],ioSignature:{inputs:[{name:"input",type:"any"}],outputs:[{name:"true",type:"any",handleId:"true"},{name:"false",type:"any",handleId:"false"}]}},{type:"conditional.switch",label:"Switch Branch",category:"statemachine",defaultConfig:{expression:"",cases:[]},configFields:[{key:"expression",label:"Switch Expression",type:"string"},{key:"cases",label:"Cases",type:"array",arrayItemType:"string"}],ioSignature:{inputs:[{name:"input",type:"any"}],outputs:[{name:"default",type:"any"}]}},{type:"conditional.expression",label:"Expression Branch",category:"statemachine",defaultConfig:{expression:"",outputs:[]},configFields:[{key:"expression",label:"Expression",type:"string"},{key:"outputs",label:"Output Labels",type:"array",arrayItemType:"string"}],ioSignature:{inputs:[{name:"input",type:"any"}],outputs:[{name:"result",type:"any"}]}},{type:"scheduler.modular",label:"Scheduler",category:"scheduling",defaultConfig:{},configFields:[{key:"interval",label:"Interval",type:"string",defaultValue:"1m"},{key:"cron",label:"Cron Expression",type:"string"}],ioSignature:{inputs:[],outputs:[{name:"tick",type:"Time"}]},maxIncoming:0},{type:"cache.modular",label:"Cache",category:"infrastructure",defaultConfig:{provider:"memory"},configFields:[{key:"provider",label:"Provider",type:"select",options:["memory","redis"]},{key:"ttl",label:"TTL",type:"string",defaultValue:"5m"}],ioSignature:{inputs:[{name:"key",type:"string"}],outputs:[{name:"value",type:"any"}]}},{type:"database.modular",label:"Database",category:"infrastructure",defaultConfig:{driver:"postgres"},configFields:[{key:"driver",label:"Driver",type:"select",options:["postgres","mysql","sqlite"]},{key:"dsn",label:"DSN",type:"string"}],ioSignature:{inputs:[{name:"query",type:"SQL"}],outputs:[{name:"result",type:"Rows"}]}},{type:"database.workflow",label:"Workflow Database",category:"database",defaultConfig:{driver:"postgres"},configFields:[{key:"driver",label:"Driver",type:"select",options:["postgres","mysql","sqlite"]},{key:"dsn",label:"DSN",type:"string"},{key:"maxOpenConns",label:"Max Open Connections",type:"number",defaultValue:25},{key:"maxIdleConns",label:"Max Idle Connections",type:"number",defaultValue:5}],ioSignature:{inputs:[{name:"query",type:"SQL"}],outputs:[{name:"result",type:"Rows"}]}},{type:"persistence.store",label:"Persistence Store",category:"database",defaultConfig:{database:"database"},configFields:[{key:"database",label:"Database Service",type:"string",defaultValue:"database",description:"Name of the database module to use for storage",placeholder:"database",inheritFrom:"dependency.name"}],ioSignature:{inputs:[{name:"data",type:"any"}],outputs:[{name:"persistence",type:"PersistenceStore"}]}},{type:"metrics.collector",label:"Metrics Collector",category:"observability",defaultConfig:{},configFields:[],ioSignature:{inputs:[{name:"metrics",type:"Metric[]"}],outputs:[]},maxOutgoing:0},{type:"health.checker",label:"Health Checker",category:"observability",defaultConfig:{},configFields:[],ioSignature:{inputs:[],outputs:[{name:"status",type:"HealthStatus"}]}},{type:"log.collector",label:"Log Collector",category:"observability",defaultConfig:{logLevel:"info",outputFormat:"json",retentionDays:7},configFields:[{key:"logLevel",label:"Log Level",type:"select",options:["debug","info","warn","error"],defaultValue:"info",description:"Minimum log level to collect"},{key:"outputFormat",label:"Output Format",type:"select",options:["json","text"],defaultValue:"json",description:"Format for log output"},{key:"retentionDays",label:"Retention Days",type:"number",defaultValue:7,description:"Number of days to retain log entries"}],ioSignature:{inputs:[{name:"logs",type:"LogEntry[]"}],outputs:[]},maxOutgoing:0},{type:"http.middleware.requestid",label:"Request ID Middleware",category:"middleware",defaultConfig:{},configFields:[{key:"headerName",label:"Header Name",type:"string",defaultValue:"X-Request-ID"}],ioSignature:{inputs:[{name:"request",type:"http.Request"}],outputs:[{name:"tagged",type:"http.Request"}]}},{type:"http.middleware.securityheaders",label:"Security Headers",category:"middleware",defaultConfig:{frameOptions:"DENY",contentTypeOptions:"nosniff",hstsMaxAge:31536e3,referrerPolicy:"strict-origin-when-cross-origin",permissionsPolicy:"camera=(), microphone=(), geolocation=()"},configFields:[{key:"contentSecurityPolicy",label:"Content Security Policy",type:"string",description:"CSP header value",placeholder:"default-src 'self'",group:"headers"},{key:"frameOptions",label:"X-Frame-Options",type:"select",options:["DENY","SAMEORIGIN"],defaultValue:"DENY",description:"Controls whether the page can be embedded in frames",group:"headers"},{key:"contentTypeOptions",label:"X-Content-Type-Options",type:"string",defaultValue:"nosniff",description:"Prevents MIME type sniffing",group:"headers"},{key:"hstsMaxAge",label:"HSTS Max-Age (sec)",type:"number",defaultValue:31536e3,description:"HTTP Strict Transport Security max-age in seconds",group:"headers"},{key:"referrerPolicy",label:"Referrer Policy",type:"select",options:["no-referrer","no-referrer-when-downgrade","origin","origin-when-cross-origin","same-origin","strict-origin","strict-origin-when-cross-origin","unsafe-url"],defaultValue:"strict-origin-when-cross-origin",description:"Controls the Referer header sent with requests",group:"headers"},{key:"permissionsPolicy",label:"Permissions Policy",type:"string",defaultValue:"camera=(), microphone=(), geolocation=()",description:"Controls which browser features are allowed",group:"headers"}],ioSignature:{inputs:[{name:"request",type:"http.Request"}],outputs:[{name:"secured",type:"http.Request"}]}},{type:"auth.jwt",label:"JWT Auth",category:"middleware",defaultConfig:{tokenExpiry:"24h",issuer:"workflow"},configFields:[{key:"secret",label:"JWT Secret",type:"string",required:!0,description:"Secret key for signing JWT tokens (supports $ENV_VAR expansion)",placeholder:"$JWT_SECRET",sensitive:!0},{key:"tokenExpiry",label:"Token Expiry",type:"string",defaultValue:"24h",description:"Token expiration duration (e.g. 1h, 24h, 7d)",placeholder:"24h"},{key:"issuer",label:"Issuer",type:"string",defaultValue:"workflow",description:"Token issuer claim",placeholder:"workflow"},{key:"seedFile",label:"Seed Users File",type:"string",description:"Path to JSON file with initial user accounts",placeholder:"data/users.json"},{key:"responseFormat",label:"Response Format",type:"select",options:["standard","oauth2"],description:"Format of authentication response payloads"}],ioSignature:{inputs:[{name:"credentials",type:"Credentials"}],outputs:[{name:"auth",type:"AuthService"}]}},{type:"data.transformer",label:"Data Transformer",category:"integration",defaultConfig:{},configFields:[{key:"pipelines",label:"Pipeline Config",type:"json"}],ioSignature:{inputs:[{name:"data",type:"any"}],outputs:[{name:"transformed",type:"any"}]}},{type:"webhook.sender",label:"Webhook Sender",category:"integration",defaultConfig:{maxRetries:3},configFields:[{key:"maxRetries",label:"Max Retries",type:"number",defaultValue:3},{key:"initialBackoff",label:"Initial Backoff",type:"string",defaultValue:"1s"},{key:"maxBackoff",label:"Max Backoff",type:"string",defaultValue:"60s"},{key:"timeout",label:"Timeout",type:"string",defaultValue:"30s"}],ioSignature:{inputs:[{name:"payload",type:"JSON"}],outputs:[{name:"response",type:"http.Response"}]}},{type:"notification.slack",label:"Slack Notification",category:"integration",defaultConfig:{username:"workflow-bot"},configFields:[{key:"webhookURL",label:"Webhook URL",type:"string"},{key:"channel",label:"Channel",type:"string"},{key:"username",label:"Username",type:"string",defaultValue:"workflow-bot"}],ioSignature:{inputs:[{name:"message",type:"string"}],outputs:[{name:"sent",type:"boolean"}]}},{type:"storage.s3",label:"S3 Storage",category:"integration",defaultConfig:{region:"us-east-1"},configFields:[{key:"bucket",label:"Bucket",type:"string"},{key:"region",label:"Region",type:"string",defaultValue:"us-east-1"},{key:"endpoint",label:"Endpoint",type:"string"}],ioSignature:{inputs:[{name:"data",type:"[]byte"}],outputs:[{name:"url",type:"string"}]}},{type:"messaging.nats",label:"NATS Broker",category:"messaging",defaultConfig:{url:"nats://localhost:4222"},configFields:[{key:"url",label:"URL",type:"string",defaultValue:"nats://localhost:4222"}],ioSignature:{inputs:[{name:"message",type:"[]byte"}],outputs:[{name:"message",type:"[]byte"}]}},{type:"messaging.kafka",label:"Kafka Broker",category:"messaging",defaultConfig:{brokers:["localhost:9092"]},configFields:[{key:"brokers",label:"Brokers",type:"array",arrayItemType:"string",defaultValue:["localhost:9092"],placeholder:"localhost:9092"},{key:"groupID",label:"Group ID",type:"string"}],ioSignature:{inputs:[{name:"message",type:"[]byte"}],outputs:[{name:"message",type:"[]byte"}]}},{type:"observability.otel",label:"OpenTelemetry",category:"observability",defaultConfig:{endpoint:"localhost:4318",serviceName:"workflow"},configFields:[{key:"endpoint",label:"OTLP Endpoint",type:"string",defaultValue:"localhost:4318"},{key:"serviceName",label:"Service Name",type:"string",defaultValue:"workflow"}],ioSignature:{inputs:[{name:"spans",type:"Span[]"}],outputs:[{name:"exported",type:"boolean"}]}},{type:"storage.local",label:"Local Storage",category:"integration",defaultConfig:{rootDir:"./data/storage"},configFields:[{key:"rootDir",label:"Root Directory",type:"string",defaultValue:"./data/storage"}],ioSignature:{inputs:[{name:"data",type:"[]byte"}],outputs:[{name:"storage",type:"StorageProvider"}]}},{type:"storage.gcs",label:"GCS Storage",category:"integration",defaultConfig:{},configFields:[{key:"bucket",label:"Bucket",type:"string",required:!0},{key:"project",label:"GCP Project",type:"string"},{key:"credentialsFile",label:"Credentials File",type:"filepath"}],ioSignature:{inputs:[{name:"data",type:"[]byte"}],outputs:[{name:"storage",type:"StorageProvider"}]}},{type:"secrets.vault",label:"Vault Secrets",category:"infrastructure",defaultConfig:{mountPath:"secret"},configFields:[{key:"address",label:"Vault Address",type:"string",required:!0,placeholder:"https://vault.example.com:8200"},{key:"token",label:"Vault Token",type:"string",required:!0,placeholder:"${VAULT_TOKEN}",sensitive:!0},{key:"mountPath",label:"Mount Path",type:"string",defaultValue:"secret",placeholder:"secret"},{key:"namespace",label:"Namespace",type:"string",placeholder:"admin"}],ioSignature:{inputs:[],outputs:[{name:"secrets",type:"SecretProvider"}]}},{type:"secrets.aws",label:"AWS Secrets Manager",category:"infrastructure",defaultConfig:{region:"us-east-1"},configFields:[{key:"region",label:"AWS Region",type:"string",defaultValue:"us-east-1",placeholder:"us-east-1"},{key:"accessKeyId",label:"Access Key ID",type:"string",placeholder:"${AWS_ACCESS_KEY_ID}",sensitive:!0},{key:"secretAccessKey",label:"Secret Access Key",type:"string",placeholder:"${AWS_SECRET_ACCESS_KEY}",sensitive:!0}],ioSignature:{inputs:[],outputs:[{name:"secrets",type:"SecretProvider"}]}},{type:"openapi.generator",label:"OpenAPI Generator",category:"integration",defaultConfig:{title:"Workflow API",version:"1.0.0"},configFields:[{key:"title",label:"API Title",type:"string",defaultValue:"Workflow API",placeholder:"My API"},{key:"version",label:"API Version",type:"string",defaultValue:"1.0.0",placeholder:"1.0.0"},{key:"description",label:"Description",type:"string",placeholder:"API generated from workflow routes"},{key:"servers",label:"Server URLs",type:"array",arrayItemType:"string",placeholder:"http://localhost:8080"}],ioSignature:{inputs:[{name:"routes",type:"RouteConfig"}],outputs:[{name:"spec",type:"OpenAPISpec"}]}},{type:"openapi.consumer",label:"OpenAPI Consumer",category:"integration",defaultConfig:{},configFields:[{key:"specUrl",label:"Spec URL",type:"string",placeholder:"https://api.example.com/openapi.json"},{key:"specFile",label:"Spec File",type:"filepath",placeholder:"specs/external-api.json"},{key:"fieldMapping",label:"Field Mapping",type:"map",mapValueType:"string",description:"Custom field name mapping between local and external schemas",group:"advanced"}],ioSignature:{inputs:[{name:"spec",type:"OpenAPISpec"}],outputs:[{name:"client",type:"ExternalAPIClient"}]}},{type:"storage.sqlite",label:"SQLite Storage",category:"database",defaultConfig:{dbPath:"data/workflow.db",maxConnections:5,walMode:!0},configFields:[{key:"dbPath",label:"Database Path",type:"string",defaultValue:"data/workflow.db",placeholder:"data/workflow.db"},{key:"maxConnections",label:"Max Connections",type:"number",defaultValue:5},{key:"walMode",label:"WAL Mode",type:"boolean",defaultValue:!0}],ioSignature:{inputs:[],outputs:[{name:"database",type:"sql.DB"}]}},{type:"auth.user-store",label:"User Store",category:"infrastructure",defaultConfig:{},configFields:[],ioSignature:{inputs:[{name:"credentials",type:"Credentials"}],outputs:[{name:"user-store",type:"UserStore"}]}},{type:"dynamic.component",label:"Dynamic Component",category:"infrastructure",defaultConfig:{},configFields:[{key:"componentId",label:"Component ID",type:"string",description:"ID to look up in the dynamic component registry (defaults to module name)"},{key:"source",label:"Source File",type:"string",description:"Path to Go source file to load dynamically",placeholder:"components/my_processor.go"},{key:"provides",label:"Provides Services",type:"array",arrayItemType:"string",description:"Service names this component provides",placeholder:"my-service"},{key:"requires",label:"Requires Services",type:"array",arrayItemType:"string",description:"Service names this component depends on",placeholder:"database"}],ioSignature:{inputs:[{name:"input",type:"any"}],outputs:[{name:"output",type:"any"}]}},{type:"workflow.registry",label:"Workflow Registry",category:"infrastructure",defaultConfig:{storageBackend:""},configFields:[{key:"storageBackend",label:"Storage Backend",type:"string",defaultValue:"",placeholder:"admin-db",description:"Name of a storage.sqlite module to share its DB connection",inheritFrom:"dependency.name"}],ioSignature:{inputs:[{name:"storageBackend",type:"SQLiteStorage"}],outputs:[{name:"registry",type:"WorkflowRegistry"}]}},{type:"step.validate",label:"Validate",category:"pipeline",defaultConfig:{strategy:"required_fields",required_fields:[]},configFields:[{key:"strategy",label:"Strategy",type:"select",options:["required_fields","json_schema"],defaultValue:"required_fields",description:"Validation strategy"},{key:"required_fields",label:"Required Fields",type:"array",arrayItemType:"string",description:"Fields that must be present in the pipeline context"},{key:"schema",label:"JSON Schema",type:"json",description:"JSON Schema for json_schema strategy"}]},{type:"step.set",label:"Set Values",category:"pipeline",defaultConfig:{values:{}},configFields:[{key:"values",label:"Values",type:"map",mapValueType:"string",description:"Key-value pairs to set in the pipeline context (supports {{ template }} expressions)"}]},{type:"step.log",label:"Log",category:"pipeline",defaultConfig:{level:"info",message:""},configFields:[{key:"level",label:"Level",type:"select",options:["debug","info","warn","error"],defaultValue:"info"},{key:"message",label:"Message",type:"string",description:"Log message (supports {{ template }} expressions)",required:!0}]},{type:"step.conditional",label:"Conditional Route",category:"pipeline",defaultConfig:{field:"",routes:{},default:""},configFields:[{key:"field",label:"Field",type:"string",description:"Field to evaluate (supports {{ template }} expressions)",required:!0},{key:"routes",label:"Routes",type:"map",mapValueType:"string",description:"Map of field values to target step names"},{key:"default",label:"Default Step",type:"string",description:"Step to route to when no match is found"}]},{type:"step.transform",label:"Transform",category:"pipeline",defaultConfig:{transformer:"",pipeline:""},configFields:[{key:"transformer",label:"Transformer Service",type:"string",description:"Name of the DataTransformer module to use",inheritFrom:"dependency.name"},{key:"pipeline",label:"Pipeline Name",type:"string",description:"Named transformation pipeline within the transformer"},{key:"operations",label:"Operations",type:"json",description:"Inline transformation operations (alternative to named pipeline)"}]},{type:"step.publish",label:"Publish Event",category:"pipeline",defaultConfig:{topic:"",payload:{}},configFields:[{key:"topic",label:"Topic",type:"string",description:"Event topic to publish to (supports {{ template }} expressions)",required:!0},{key:"payload",label:"Payload",type:"json",description:"Event payload (supports {{ template }} expressions in string values)"},{key:"broker",label:"Broker Service",type:"string",description:"Name of the messaging broker module (optional, uses EventBus by default)",inheritFrom:"dependency.name"}]},{type:"step.http_call",label:"HTTP Call",category:"pipeline",defaultConfig:{url:"",method:"GET"},configFields:[{key:"url",label:"URL",type:"string",description:"Request URL (supports {{ template }} expressions)",required:!0},{key:"method",label:"Method",type:"select",options:["GET","POST","PUT","PATCH","DELETE","HEAD"],defaultValue:"GET"},{key:"headers",label:"Headers",type:"map",mapValueType:"string",description:"Request headers"},{key:"body",label:"Body",type:"json",description:"Request body (supports {{ template }} expressions in string values)"},{key:"timeout",label:"Timeout",type:"string",defaultValue:"30s",description:"Request timeout"}]},{type:"step.shell_exec",label:"Shell Exec",category:"cicd",defaultConfig:{image:"ubuntu:22.04",commands:[]},configFields:[{key:"image",label:"Docker Image",type:"string",required:!0,description:"Docker image to run commands in"},{key:"commands",label:"Commands",type:"array",description:"Shell commands to execute sequentially"},{key:"work_dir",label:"Working Directory",type:"string",description:"Working directory inside the container"},{key:"timeout",label:"Timeout",type:"string",description:"Maximum execution time for all commands"},{key:"env",label:"Environment Variables",type:"map",mapValueType:"string",description:"Environment variables to set in the container"},{key:"artifacts_out",label:"Output Artifacts",type:"json",description:"Artifacts to collect after execution"}]},{type:"step.artifact_pull",label:"Artifact Pull",category:"cicd",defaultConfig:{source:"previous_execution",dest:""},configFields:[{key:"source",label:"Source",type:"select",options:["previous_execution","url","s3"],required:!0,description:"Artifact source type"},{key:"dest",label:"Destination Path",type:"string",required:!0,description:"Local file path to write the artifact to"},{key:"key",label:"Artifact Key",type:"string",description:"Artifact key (required for previous_execution and s3 sources)"},{key:"execution_id",label:"Execution ID",type:"string",description:"Execution ID to pull from (defaults to current execution)"},{key:"url",label:"URL",type:"string",description:"URL to download artifact from (required for url source)"}]},{type:"step.artifact_push",label:"Artifact Push",category:"cicd",defaultConfig:{source_path:"",key:"",dest:"artifact_store"},configFields:[{key:"source_path",label:"Source Path",type:"string",required:!0,description:"Local file path to read and push"},{key:"key",label:"Artifact Key",type:"string",required:!0,description:"Unique key for the artifact in the store"},{key:"dest",label:"Destination",type:"string",description:"Destination store identifier"}]},{type:"step.docker_build",label:"Docker Build",category:"cicd",defaultConfig:{context:".",dockerfile:"Dockerfile"},configFields:[{key:"context",label:"Build Context",type:"string",required:!0,description:"Path to the Docker build context directory"},{key:"dockerfile",label:"Dockerfile",type:"string",description:"Path to Dockerfile relative to context"},{key:"tags",label:"Image Tags",type:"array",description:"Tags for the built image"},{key:"build_args",label:"Build Args",type:"map",mapValueType:"string",description:"Docker build arguments"},{key:"cache_from",label:"Cache From",type:"array",description:"Images to use as cache sources"}]},{type:"step.docker_push",label:"Docker Push",category:"cicd",defaultConfig:{image:""},configFields:[{key:"image",label:"Image",type:"string",required:!0,description:"Image name to push"},{key:"registry",label:"Registry",type:"string",description:"Registry hostname (prepended to image name)"},{key:"auth_provider",label:"Auth Provider",type:"string",description:"Authentication provider for the registry"}]},{type:"step.docker_run",label:"Docker Run",category:"cicd",defaultConfig:{image:"",wait_for_exit:!0},configFields:[{key:"image",label:"Docker Image",type:"string",required:!0,description:"Docker image to run"},{key:"command",label:"Command",type:"array",description:"Command to execute in the container"},{key:"env",label:"Environment Variables",type:"map",mapValueType:"string",description:"Environment variables for the container"},{key:"wait_for_exit",label:"Wait For Exit",type:"boolean",description:"Whether to wait for the container to exit"},{key:"timeout",label:"Timeout",type:"string",description:"Maximum execution time"}]},{type:"step.scan_sast",label:"SAST Scan",category:"security",defaultConfig:{scanner:"semgrep",image:"semgrep/semgrep:latest",source_path:"/workspace",fail_on_severity:"error",output_format:"sarif"},configFields:[{key:"scanner",label:"Scanner",type:"string",required:!0,description:"SAST scanner to use (e.g., semgrep)"},{key:"image",label:"Scanner Image",type:"string",description:"Docker image for the scanner"},{key:"source_path",label:"Source Path",type:"string",description:"Path to source code to scan"},{key:"rules",label:"Rules",type:"array",description:"Scanner rule configurations"},{key:"fail_on_severity",label:"Fail on Severity",type:"select",options:["critical","high","medium","low","info"],description:"Minimum severity level to fail the gate"},{key:"output_format",label:"Output Format",type:"select",options:["sarif","json"],description:"Scan output format"}]},{type:"step.scan_container",label:"Container Scan",category:"security",defaultConfig:{scanner:"trivy",image:"aquasec/trivy:latest",severity_threshold:"HIGH",output_format:"sarif"},configFields:[{key:"scanner",label:"Scanner",type:"string",description:"Container scanner to use"},{key:"image",label:"Scanner Image",type:"string",description:"Docker image for the scanner"},{key:"target_image",label:"Target Image",type:"string",required:!0,description:"Docker image to scan for vulnerabilities"},{key:"severity_threshold",label:"Severity Threshold",type:"select",options:["CRITICAL","HIGH","MEDIUM","LOW"],description:"Minimum severity to report"},{key:"ignore_unfixed",label:"Ignore Unfixed",type:"boolean",description:"Skip vulnerabilities without available fixes"},{key:"output_format",label:"Output Format",type:"select",options:["sarif","json"],description:"Scan output format"}]},{type:"step.scan_deps",label:"Dependency Scan",category:"security",defaultConfig:{scanner:"grype",image:"anchore/grype:latest",source_path:"/workspace",fail_on_severity:"high",output_format:"sarif"},configFields:[{key:"scanner",label:"Scanner",type:"string",description:"Dependency scanner to use"},{key:"image",label:"Scanner Image",type:"string",description:"Docker image for the scanner"},{key:"source_path",label:"Source Path",type:"string",description:"Path to source code to scan for dependencies"},{key:"fail_on_severity",label:"Fail on Severity",type:"select",options:["critical","high","medium","low","info"],description:"Minimum severity level to fail the gate"},{key:"output_format",label:"Output Format",type:"select",options:["sarif","json"],description:"Scan output format"}]},{type:"step.deploy",label:"Deploy",category:"deployment",defaultConfig:{environment:"",strategy:"rolling",image:""},configFields:[{key:"environment",label:"Environment",type:"string",required:!0,description:"Target deployment environment"},{key:"strategy",label:"Strategy",type:"select",options:["rolling","blue_green","canary"],required:!0,description:"Deployment strategy to use"},{key:"image",label:"Image",type:"string",required:!0,description:"Docker image to deploy"},{key:"provider",label:"Provider",type:"select",options:["aws","gcp","azure","digitalocean"],description:"Cloud provider to deploy to"},{key:"rollback_on_failure",label:"Rollback on Failure",type:"boolean",description:"Automatically rollback if deployment fails"},{key:"health_check",label:"Health Check",type:"json",description:"Health check configuration (path, interval, timeout, thresholds)"}]},{type:"step.gate",label:"Approval Gate",category:"deployment",defaultConfig:{type:"manual",timeout:"24h"},configFields:[{key:"type",label:"Gate Type",type:"select",options:["manual","automated","scheduled"],required:!0,description:"Type of approval gate"},{key:"approvers",label:"Approvers",type:"array",description:"List of approver identifiers (for manual gates)"},{key:"timeout",label:"Timeout",type:"string",description:"Maximum time to wait for approval"},{key:"auto_approve_conditions",label:"Auto-Approve Conditions",type:"array",description:"Conditions for automated approval"},{key:"schedule",label:"Schedule Window",type:"json",description:"Time window for scheduled gates (weekdays, start_hour, end_hour)"}]},{type:"featureflag.service",label:"Feature Flag Service",category:"infrastructure",defaultConfig:{provider:"generic",cache_ttl:"1m",sse_enabled:!0},configFields:[{key:"provider",label:"Provider",type:"select",options:["generic","launchdarkly"],defaultValue:"generic",description:"Feature flag backend provider"},{key:"cache_ttl",label:"Cache TTL",type:"string",defaultValue:"1m",description:"Duration to cache flag evaluations",placeholder:"1m"},{key:"sse_enabled",label:"SSE Enabled",type:"boolean",defaultValue:!0,description:"Enable Server-Sent Events for real-time flag change notifications"},{key:"store_path",label:"Store Path",type:"string",description:"Path for the flag definition store (file-based provider)",placeholder:"data/flags.json"},{key:"launchdarkly_sdk_key",label:"LaunchDarkly SDK Key",type:"string",sensitive:!0,description:"LaunchDarkly server-side SDK key (required when provider is launchdarkly)",group:"LaunchDarkly"}],ioSignature:{inputs:[],outputs:[{name:"featureflag.Service",type:"featureflag.Service"}]},maxIncoming:0},{type:"step.feature_flag",label:"Feature Flag Check",category:"pipeline",defaultConfig:{output_key:"flag_value"},configFields:[{key:"flag",label:"Flag Key",type:"string",required:!0,description:"Feature flag key to evaluate",placeholder:"feature.my-flag"},{key:"user_from",label:"User From",type:"string",description:"Template expression to extract user identifier from context",placeholder:"{{.request.user_id}}"},{key:"group_from",label:"Group From",type:"string",description:"Template expression to extract group identifier from context",placeholder:"{{.request.group}}"},{key:"output_key",label:"Output Key",type:"string",defaultValue:"flag_value",description:"Key to store the flag value in pipeline context",placeholder:"flag_value"}]},{type:"step.ff_gate",label:"Feature Flag Gate",category:"pipeline",defaultConfig:{},configFields:[{key:"flag",label:"Flag Key",type:"string",required:!0,description:"Feature flag key to evaluate",placeholder:"feature.my-flag"},{key:"on_enabled",label:"On Enabled",type:"string",description:"Branch or step to execute when flag is enabled"},{key:"on_disabled",label:"On Disabled",type:"string",description:"Branch or step to execute when flag is disabled"},{key:"user_from",label:"User From",type:"string",description:"Template expression to extract user identifier from context",placeholder:"{{.request.user_id}}"},{key:"group_from",label:"Group From",type:"string",description:"Template expression to extract group identifier from context",placeholder:"{{.request.group}}"}]},{type:"platform.provider",label:"Platform Provider",category:"platform",defaultConfig:{name:"aws"},configFields:[{key:"name",label:"Provider Name",type:"string",required:!0,description:"Provider identifier (e.g., aws, docker-compose)",placeholder:"aws"},{key:"config",label:"Provider Config",type:"json",description:"Provider-specific configuration"}],ioSignature:{inputs:[],outputs:[{name:"provider",type:"platform.Provider"}]},maxIncoming:0},{type:"platform.resource",label:"Platform Resource",category:"platform",defaultConfig:{tier:"application"},configFields:[{key:"name",label:"Resource Name",type:"string",required:!0,description:"Unique resource identifier",placeholder:"web-cluster"},{key:"type",label:"Capability Type",type:"string",required:!0,description:"Abstract capability type",placeholder:"container_runtime"},{key:"tier",label:"Tier",type:"select",options:["infrastructure","shared_primitive","application"],defaultValue:"application"}],ioSignature:{inputs:[{name:"provider",type:"platform.Provider"}],outputs:[{name:"output",type:"ResourceOutput"}]}},{type:"platform.context",label:"Platform Context",category:"platform",defaultConfig:{tier:"application"},configFields:[{key:"org",label:"Organization",type:"string",required:!0,placeholder:"acme-corp"},{key:"environment",label:"Environment",type:"string",required:!0,placeholder:"production"},{key:"tier",label:"Tier",type:"select",options:["infrastructure","shared_primitive","application"],defaultValue:"application"}],ioSignature:{inputs:[],outputs:[{name:"context",type:"PlatformContext"}]},maxIncoming:0},{type:"step.platform_plan",label:"Platform Plan",category:"pipeline",defaultConfig:{},configFields:[{key:"provider_service",label:"Provider Service",type:"string",description:"Service name for the platform provider"},{key:"resources_from",label:"Resources From",type:"string",defaultValue:"resource_declarations"},{key:"tier",label:"Tier",type:"select",options:["1","2","3"],defaultValue:"3"},{key:"dry_run",label:"Dry Run",type:"boolean",defaultValue:"false"}]},{type:"step.platform_apply",label:"Platform Apply",category:"pipeline",defaultConfig:{},configFields:[{key:"provider_service",label:"Provider Service",type:"string"},{key:"plan_from",label:"Plan From",type:"string",defaultValue:"platform_plan"}]},{type:"step.platform_destroy",label:"Platform Destroy",category:"pipeline",defaultConfig:{},configFields:[{key:"provider_service",label:"Provider Service",type:"string"},{key:"resources_from",label:"Resources From",type:"string",defaultValue:"applied_resources"}]},{type:"step.drift_check",label:"Drift Check",category:"pipeline",defaultConfig:{},configFields:[{key:"provider_service",label:"Provider Service",type:"string"},{key:"resources_from",label:"Resources From",type:"string",defaultValue:"applied_resources"}]},{type:"step.constraint_check",label:"Constraint Check",category:"pipeline",defaultConfig:{},configFields:[{key:"constraints",label:"Constraints",type:"json",description:"Constraint definitions"},{key:"resources_from",label:"Resources From",type:"string",defaultValue:"resource_declarations"}]},{type:"step.platform_template",label:"Platform Template",category:"pipeline",defaultConfig:{},configFields:[{key:"template_name",label:"Template Name",type:"string",required:!0},{key:"template_version",label:"Template Version",type:"string"},{key:"parameters",label:"Parameters",type:"json",description:"Template parameter values"}]}],Vu=Object.fromEntries(L0.map(e=>[e.type,e])),B0=[{key:"http",label:"HTTP"},{key:"middleware",label:"Middleware"},{key:"messaging",label:"Messaging"},{key:"statemachine",label:"State Machine"},{key:"events",label:"Events"},{key:"integration",label:"Integration"},{key:"scheduling",label:"Scheduling"},{key:"infrastructure",label:"Infrastructure"},{key:"database",label:"Database"},{key:"observability",label:"Observability"},{key:"pipeline",label:"Pipeline Steps"},{key:"cicd",label:"CI/CD"},{key:"security",label:"Security"},{key:"deployment",label:"Deployment"},{key:"platform",label:"Platform"}];function eL(e,n){let r;try{r=e()}catch{return}return{getItem:o=>{var l;const c=p=>p===null?null:JSON.parse(p,void 0),d=(l=r.getItem(o))!=null?l:null;return d instanceof Promise?d.then(c):c(d)},setItem:(o,l)=>r.setItem(o,JSON.stringify(l,void 0)),removeItem:o=>r.removeItem(o)}}const H0=e=>n=>{try{const r=e(n);return r instanceof Promise?r:{then(a){return H0(a)(r)},catch(a){return this}}}catch(r){return{then(a){return this},catch(a){return H0(a)(r)}}}},tL=(e,n)=>(r,a,o)=>{let l={storage:eL(()=>window.localStorage),partialize:C=>C,version:0,merge:(C,_)=>({..._,...C}),...n},c=!1,d=0;const p=new Set,h=new Set;let g=l.storage;if(!g)return e((...C)=>{console.warn(`[zustand persist middleware] Unable to update item '${l.name}', the given storage is currently unavailable.`),r(...C)},a,o);const y=()=>{const C=l.partialize({...a()});return g.setItem(l.name,{state:C,version:l.version})},m=o.setState;o.setState=(C,_)=>(m(C,_),y());const b=e((...C)=>(r(...C),y()),a,o);o.getInitialState=()=>b;let S;const w=()=>{var C,_;if(!g)return;const j=++d;c=!1,p.forEach(T=>{var E;return T((E=a())!=null?E:b)});const k=((_=l.onRehydrateStorage)==null?void 0:_.call(l,(C=a())!=null?C:b))||void 0;return H0(g.getItem.bind(g))(l.name).then(T=>{if(T)if(typeof T.version=="number"&&T.version!==l.version){if(l.migrate){const E=l.migrate(T.state,T.version);return E instanceof Promise?E.then(z=>[!0,z]):[!0,E]}console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}else return[!1,T.state];return[!1,void 0]}).then(T=>{var E;if(j!==d)return;const[z,A]=T;if(S=l.merge(A,(E=a())!=null?E:b),r(S,!0),z)return y()}).then(()=>{j===d&&(k?.(S,void 0),S=a(),c=!0,h.forEach(T=>T(S)))}).catch(T=>{j===d&&k?.(void 0,T)})};return o.persist={setOptions:C=>{l={...l,...C},C.storage&&(g=C.storage)},clearStorage:()=>{g?.removeItem(l.name)},getOptions:()=>l,rehydrate:()=>w(),hasHydrated:()=>c,onHydrate:C=>(p.add(C),()=>{p.delete(C)}),onFinishHydration:C=>(h.add(C),()=>{h.delete(C)})},l.skipHydration||w(),S||b},b8=tL;function nL(e){switch(e){case"string":case"duration":return"string";case"number":return"number";case"boolean":return"boolean";case"select":return"select";case"array":return"array";case"map":return"map";case"json":return"json";case"filepath":return"filepath";case"sql":return"sql";default:return"string"}}function Z_(e){return e.map(n=>({key:n.key,label:n.label,type:nL(n.type),options:n.options,defaultValue:n.defaultValue,description:n.description,placeholder:n.placeholder,required:n.required,group:n.group,arrayItemType:n.arrayItemType,mapValueType:n.mapValueType,inheritFrom:n.inheritFrom,sensitive:n.sensitive}))}function Q_(e,n){const r=e??[],a=n??[];if(!(r.length===0&&a.length===0))return{inputs:r.map(o=>({name:o.name,type:o.type})),outputs:a.map(o=>({name:o.name,type:o.type}))}}const rL=["http","messaging","statemachine","events","integration","scheduling","infrastructure","middleware","database","observability","pipeline","cicd","security","deployment"];function J_(e){return rL.includes(e)?e:"infrastructure"}function iL(e,n){const r=[],a=new Set;for(const o of e){a.add(o.type);const l=n[o.type];if(l){const c=Q_(l.inputs,l.outputs);r.push({...o,label:l.label||o.label,category:J_(l.category||o.category),configFields:l.configFields.length>0?Z_(l.configFields):o.configFields,defaultConfig:l.defaultConfig??o.defaultConfig,ioSignature:c??o.ioSignature,maxIncoming:l.maxIncoming??o.maxIncoming,maxOutgoing:l.maxOutgoing??o.maxOutgoing})}else r.push(o)}for(const[o,l]of Object.entries(n))a.has(o)||r.push({type:o,label:l.label,category:J_(l.category),configFields:Z_(l.configFields),defaultConfig:l.defaultConfig??{},ioSignature:Q_(l.inputs,l.outputs),maxIncoming:l.maxIncoming,maxOutgoing:l.maxOutgoing});return r}const vt=Mn((e,n)=>({loaded:!1,loading:!1,serverSchemas:{},moduleTypes:L0,moduleTypeMap:Vu,services:[],servicesLoaded:!1,fetchSchemas:async()=>{if(!n().loading){e({loading:!0});try{const r=localStorage.getItem("auth_token"),a={};r&&(a.Authorization=`Bearer ${r}`);const o=await fetch("/api/v1/admin/schemas/modules",{headers:a});if(!o.ok){console.warn("Failed to fetch module schemas, using static defaults"),e({loading:!1,loaded:!0});return}const l=await o.json(),c=iL(L0,l),d=Object.fromEntries(c.map(p=>[p.type,p]));e({serverSchemas:l,moduleTypes:c,moduleTypeMap:d,loaded:!0,loading:!1})}catch(r){console.warn("Error fetching module schemas:",r),e({loading:!1,loaded:!0})}}},fetchServices:async()=>{try{const r=localStorage.getItem("auth_token"),a={};r&&(a.Authorization=`Bearer ${r}`);let o=await fetch("/api/v1/admin/engine/services",{headers:a});if(o.ok||(o=await fetch("/api/workflow/services",{headers:a})),!o.ok){console.warn("Failed to fetch services"),e({servicesLoaded:!0});return}const l=await o.json();e({services:l,servicesLoaded:!0})}catch(r){console.warn("Error fetching services:",r),e({servicesLoaded:!0})}}}));function x8(e){return typeof e>"u"||e===null}function aL(e){return typeof e=="object"&&e!==null}function oL(e){return Array.isArray(e)?e:x8(e)?[]:[e]}function sL(e,n){var r,a,o,l;if(n)for(l=Object.keys(n),r=0,a=l.length;rd&&(l=" ... ",n=a-d+l.length),r-a>d&&(c=" ...",r=a+d-c.length),{str:l+e.slice(n,r).replace(/\t/g,"→")+c,pos:a-n+l.length}}function Gp(e,n){return kt.repeat(" ",n-e.length)+e}function yL(e,n){if(n=Object.create(n||null),!e.buffer)return null;n.maxLength||(n.maxLength=79),typeof n.indent!="number"&&(n.indent=1),typeof n.linesBefore!="number"&&(n.linesBefore=3),typeof n.linesAfter!="number"&&(n.linesAfter=2);for(var r=/\r?\n|\r|\0/g,a=[0],o=[],l,c=-1;l=r.exec(e.buffer);)o.push(l.index),a.push(l.index+l[0].length),e.position<=l.index&&c<0&&(c=a.length-2);c<0&&(c=a.length-1);var d="",p,h,g=Math.min(e.line+n.linesAfter,o.length).toString().length,y=n.maxLength-(n.indent+g+3);for(p=1;p<=n.linesBefore&&!(c-p<0);p++)h=Wp(e.buffer,a[c-p],o[c-p],e.position-(a[c]-a[c-p]),y),d=kt.repeat(" ",n.indent)+Gp((e.line-p+1).toString(),g)+" | "+h.str+` +`+d;for(h=Wp(e.buffer,a[c],o[c],e.position,y),d+=kt.repeat(" ",n.indent)+Gp((e.line+1).toString(),g)+" | "+h.str+` +`,d+=kt.repeat("-",n.indent+g+3+h.pos)+`^ +`,p=1;p<=n.linesAfter&&!(c+p>=o.length);p++)h=Wp(e.buffer,a[c+p],o[c+p],e.position-(a[c]-a[c+p]),y),d+=kt.repeat(" ",n.indent)+Gp((e.line+p+1).toString(),g)+" | "+h.str+` +`;return d.replace(/\n$/,"")}var mL=yL,vL=["kind","multi","resolve","construct","instanceOf","predicate","represent","representName","defaultStyle","styleAliases"],bL=["scalar","sequence","mapping"];function xL(e){var n={};return e!==null&&Object.keys(e).forEach(function(r){e[r].forEach(function(a){n[String(a)]=r})}),n}function SL(e,n){if(n=n||{},Object.keys(n).forEach(function(r){if(vL.indexOf(r)===-1)throw new Ft('Unknown option "'+r+'" is met in definition of "'+e+'" YAML type.')}),this.options=n,this.tag=e,this.kind=n.kind||null,this.resolve=n.resolve||function(){return!0},this.construct=n.construct||function(r){return r},this.instanceOf=n.instanceOf||null,this.predicate=n.predicate||null,this.represent=n.represent||null,this.representName=n.representName||null,this.defaultStyle=n.defaultStyle||null,this.multi=n.multi||!1,this.styleAliases=xL(n.styleAliases||null),bL.indexOf(this.kind)===-1)throw new Ft('Unknown kind "'+this.kind+'" is specified for "'+e+'" YAML type.')}var Ot=SL;function e2(e,n){var r=[];return e[n].forEach(function(a){var o=r.length;r.forEach(function(l,c){l.tag===a.tag&&l.kind===a.kind&&l.multi===a.multi&&(o=c)}),r[o]=a}),r}function wL(){var e={scalar:{},sequence:{},mapping:{},fallback:{},multi:{scalar:[],sequence:[],mapping:[],fallback:[]}},n,r;function a(o){o.multi?(e.multi[o.kind].push(o),e.multi.fallback.push(o)):e[o.kind][o.tag]=e.fallback[o.tag]=o}for(n=0,r=arguments.length;n=0?"0b"+e.toString(2):"-0b"+e.toString(2).slice(1)},octal:function(e){return e>=0?"0o"+e.toString(8):"-0o"+e.toString(8).slice(1)},decimal:function(e){return e.toString(10)},hexadecimal:function(e){return e>=0?"0x"+e.toString(16).toUpperCase():"-0x"+e.toString(16).toUpperCase().slice(1)}},defaultStyle:"decimal",styleAliases:{binary:[2,"bin"],octal:[8,"oct"],decimal:[10,"dec"],hexadecimal:[16,"hex"]}}),DL=new RegExp("^(?:[-+]?(?:[0-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");function qL(e){return!(e===null||!DL.test(e)||e[e.length-1]==="_")}function IL(e){var n,r;return n=e.replace(/_/g,"").toLowerCase(),r=n[0]==="-"?-1:1,"+-".indexOf(n[0])>=0&&(n=n.slice(1)),n===".inf"?r===1?Number.POSITIVE_INFINITY:Number.NEGATIVE_INFINITY:n===".nan"?NaN:r*parseFloat(n,10)}var LL=/^[-+]?[0-9]+e/;function BL(e,n){var r;if(isNaN(e))switch(n){case"lowercase":return".nan";case"uppercase":return".NAN";case"camelcase":return".NaN"}else if(Number.POSITIVE_INFINITY===e)switch(n){case"lowercase":return".inf";case"uppercase":return".INF";case"camelcase":return".Inf"}else if(Number.NEGATIVE_INFINITY===e)switch(n){case"lowercase":return"-.inf";case"uppercase":return"-.INF";case"camelcase":return"-.Inf"}else if(kt.isNegativeZero(e))return"-0.0";return r=e.toString(10),LL.test(r)?r.replace("e",".e"):r}function HL(e){return Object.prototype.toString.call(e)==="[object Number]"&&(e%1!==0||kt.isNegativeZero(e))}var R8=new Ot("tag:yaml.org,2002:float",{kind:"scalar",resolve:qL,construct:IL,predicate:HL,represent:BL,defaultStyle:"lowercase"}),z8=E8.extend({implicit:[j8,T8,A8,R8]}),N8=z8,M8=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$"),O8=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)(?:[Tt]|[ \\t]+)([0-9][0-9]?):([0-9][0-9]):([0-9][0-9])(?:\\.([0-9]*))?(?:[ \\t]*(Z|([-+])([0-9][0-9]?)(?::([0-9][0-9]))?))?$");function UL(e){return e===null?!1:M8.exec(e)!==null||O8.exec(e)!==null}function FL(e){var n,r,a,o,l,c,d,p=0,h=null,g,y,m;if(n=M8.exec(e),n===null&&(n=O8.exec(e)),n===null)throw new Error("Date resolve error");if(r=+n[1],a=+n[2]-1,o=+n[3],!n[4])return new Date(Date.UTC(r,a,o));if(l=+n[4],c=+n[5],d=+n[6],n[7]){for(p=n[7].slice(0,3);p.length<3;)p+="0";p=+p}return n[9]&&(g=+n[10],y=+(n[11]||0),h=(g*60+y)*6e4,n[9]==="-"&&(h=-h)),m=new Date(Date.UTC(r,a,o,l,c,d,p)),h&&m.setTime(m.getTime()-h),m}function PL(e){return e.toISOString()}var D8=new Ot("tag:yaml.org,2002:timestamp",{kind:"scalar",resolve:UL,construct:FL,instanceOf:Date,represent:PL});function $L(e){return e==="<<"||e===null}var q8=new Ot("tag:yaml.org,2002:merge",{kind:"scalar",resolve:$L}),xb=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/= +\r`;function VL(e){if(e===null)return!1;var n,r,a=0,o=e.length,l=xb;for(r=0;r64)){if(n<0)return!1;a+=6}return a%8===0}function WL(e){var n,r,a=e.replace(/[\r\n=]/g,""),o=a.length,l=xb,c=0,d=[];for(n=0;n>16&255),d.push(c>>8&255),d.push(c&255)),c=c<<6|l.indexOf(a.charAt(n));return r=o%4*6,r===0?(d.push(c>>16&255),d.push(c>>8&255),d.push(c&255)):r===18?(d.push(c>>10&255),d.push(c>>2&255)):r===12&&d.push(c>>4&255),new Uint8Array(d)}function GL(e){var n="",r=0,a,o,l=e.length,c=xb;for(a=0;a>18&63],n+=c[r>>12&63],n+=c[r>>6&63],n+=c[r&63]),r=(r<<8)+e[a];return o=l%3,o===0?(n+=c[r>>18&63],n+=c[r>>12&63],n+=c[r>>6&63],n+=c[r&63]):o===2?(n+=c[r>>10&63],n+=c[r>>4&63],n+=c[r<<2&63],n+=c[64]):o===1&&(n+=c[r>>2&63],n+=c[r<<4&63],n+=c[64],n+=c[64]),n}function YL(e){return Object.prototype.toString.call(e)==="[object Uint8Array]"}var I8=new Ot("tag:yaml.org,2002:binary",{kind:"scalar",resolve:VL,construct:WL,predicate:YL,represent:GL}),XL=Object.prototype.hasOwnProperty,KL=Object.prototype.toString;function ZL(e){if(e===null)return!0;var n=[],r,a,o,l,c,d=e;for(r=0,a=d.length;r>10)+55296,(e-65536&1023)+56320)}function V8(e,n,r){n==="__proto__"?Object.defineProperty(e,n,{configurable:!0,enumerable:!0,writable:!0,value:r}):e[n]=r}var W8=new Array(256),G8=new Array(256);for(var Va=0;Va<256;Va++)W8[Va]=r2(Va)?1:0,G8[Va]=r2(Va);function pB(e,n){this.input=e,this.filename=n.filename||null,this.schema=n.schema||Sb,this.onWarning=n.onWarning||null,this.legacy=n.legacy||!1,this.json=n.json||!1,this.listener=n.listener||null,this.implicitTypes=this.schema.compiledImplicit,this.typeMap=this.schema.compiledTypeMap,this.length=e.length,this.position=0,this.line=0,this.lineStart=0,this.lineIndent=0,this.firstTabInLine=-1,this.documents=[]}function Y8(e,n){var r={name:e.filename,buffer:e.input.slice(0,-1),position:e.position,line:e.line,column:e.position-e.lineStart};return r.snippet=mL(r),new Ft(n,r)}function _e(e,n){throw Y8(e,n)}function Cu(e,n){e.onWarning&&e.onWarning.call(null,Y8(e,n))}var i2={YAML:function(n,r,a){var o,l,c;n.version!==null&&_e(n,"duplication of %YAML directive"),a.length!==1&&_e(n,"YAML directive accepts exactly one argument"),o=/^([0-9]+)\.([0-9]+)$/.exec(a[0]),o===null&&_e(n,"ill-formed argument of the YAML directive"),l=parseInt(o[1],10),c=parseInt(o[2],10),l!==1&&_e(n,"unacceptable YAML version of the document"),n.version=a[0],n.checkLineBreaks=c<2,c!==1&&c!==2&&Cu(n,"unsupported YAML version of the document")},TAG:function(n,r,a){var o,l;a.length!==2&&_e(n,"TAG directive accepts exactly two arguments"),o=a[0],l=a[1],P8.test(o)||_e(n,"ill-formed tag handle (first argument) of the TAG directive"),fi.call(n.tagMap,o)&&_e(n,'there is a previously declared suffix for "'+o+'" tag handle'),$8.test(l)||_e(n,"ill-formed tag prefix (second argument) of the TAG directive");try{l=decodeURIComponent(l)}catch{_e(n,"tag prefix is malformed: "+l)}n.tagMap[o]=l}};function di(e,n,r,a){var o,l,c,d;if(n1&&(e.result+=kt.repeat(` +`,n-1))}function hB(e,n,r){var a,o,l,c,d,p,h,g,y=e.kind,m=e.result,b;if(b=e.input.charCodeAt(e.position),en(b)||to(b)||b===35||b===38||b===42||b===33||b===124||b===62||b===39||b===34||b===37||b===64||b===96||(b===63||b===45)&&(o=e.input.charCodeAt(e.position+1),en(o)||r&&to(o)))return!1;for(e.kind="scalar",e.result="",l=c=e.position,d=!1;b!==0;){if(b===58){if(o=e.input.charCodeAt(e.position+1),en(o)||r&&to(o))break}else if(b===35){if(a=e.input.charCodeAt(e.position-1),en(a))break}else{if(e.position===e.lineStart&&Wu(e)||r&&to(b))break;if(Gn(b))if(p=e.line,h=e.lineStart,g=e.lineIndent,mt(e,!1,-1),e.lineIndent>=n){d=!0,b=e.input.charCodeAt(e.position);continue}else{e.position=c,e.line=p,e.lineStart=h,e.lineIndent=g;break}}d&&(di(e,l,c,!1),_b(e,e.line-p),l=c=e.position,d=!1),$i(b)||(c=e.position+1),b=e.input.charCodeAt(++e.position)}return di(e,l,c,!1),e.result?!0:(e.kind=y,e.result=m,!1)}function gB(e,n){var r,a,o;if(r=e.input.charCodeAt(e.position),r!==39)return!1;for(e.kind="scalar",e.result="",e.position++,a=o=e.position;(r=e.input.charCodeAt(e.position))!==0;)if(r===39)if(di(e,a,e.position,!0),r=e.input.charCodeAt(++e.position),r===39)a=e.position,e.position++,o=e.position;else return!0;else Gn(r)?(di(e,a,o,!0),_b(e,mt(e,!1,n)),a=o=e.position):e.position===e.lineStart&&Wu(e)?_e(e,"unexpected end of the document within a single quoted scalar"):(e.position++,o=e.position);_e(e,"unexpected end of the stream within a single quoted scalar")}function yB(e,n){var r,a,o,l,c,d;if(d=e.input.charCodeAt(e.position),d!==34)return!1;for(e.kind="scalar",e.result="",e.position++,r=a=e.position;(d=e.input.charCodeAt(e.position))!==0;){if(d===34)return di(e,r,e.position,!0),e.position++,!0;if(d===92){if(di(e,r,e.position,!0),d=e.input.charCodeAt(++e.position),Gn(d))mt(e,!1,n);else if(d<256&&W8[d])e.result+=G8[d],e.position++;else if((c=uB(d))>0){for(o=c,l=0;o>0;o--)d=e.input.charCodeAt(++e.position),(c=cB(d))>=0?l=(l<<4)+c:_e(e,"expected hexadecimal character");e.result+=fB(l),e.position++}else _e(e,"unknown escape sequence");r=a=e.position}else Gn(d)?(di(e,r,a,!0),_b(e,mt(e,!1,n)),r=a=e.position):e.position===e.lineStart&&Wu(e)?_e(e,"unexpected end of the document within a double quoted scalar"):(e.position++,a=e.position)}_e(e,"unexpected end of the stream within a double quoted scalar")}function mB(e,n){var r=!0,a,o,l,c=e.tag,d,p=e.anchor,h,g,y,m,b,S=Object.create(null),w,C,_,j;if(j=e.input.charCodeAt(e.position),j===91)g=93,b=!1,d=[];else if(j===123)g=125,b=!0,d={};else return!1;for(e.anchor!==null&&(e.anchorMap[e.anchor]=d),j=e.input.charCodeAt(++e.position);j!==0;){if(mt(e,!0,n),j=e.input.charCodeAt(e.position),j===g)return e.position++,e.tag=c,e.anchor=p,e.kind=b?"mapping":"sequence",e.result=d,!0;r?j===44&&_e(e,"expected the node content, but found ','"):_e(e,"missed comma between flow collection entries"),C=w=_=null,y=m=!1,j===63&&(h=e.input.charCodeAt(e.position+1),en(h)&&(y=m=!0,e.position++,mt(e,!0,n))),a=e.line,o=e.lineStart,l=e.position,ho(e,n,_u,!1,!0),C=e.tag,w=e.result,mt(e,!0,n),j=e.input.charCodeAt(e.position),(m||e.line===a)&&j===58&&(y=!0,j=e.input.charCodeAt(++e.position),mt(e,!0,n),ho(e,n,_u,!1,!0),_=e.result),b?no(e,d,S,C,w,_,a,o,l):y?d.push(no(e,null,S,C,w,_,a,o,l)):d.push(w),mt(e,!0,n),j=e.input.charCodeAt(e.position),j===44?(r=!0,j=e.input.charCodeAt(++e.position)):r=!1}_e(e,"unexpected end of the stream within a flow collection")}function vB(e,n){var r,a,o=Yp,l=!1,c=!1,d=n,p=0,h=!1,g,y;if(y=e.input.charCodeAt(e.position),y===124)a=!1;else if(y===62)a=!0;else return!1;for(e.kind="scalar",e.result="";y!==0;)if(y=e.input.charCodeAt(++e.position),y===43||y===45)Yp===o?o=y===43?t2:aB:_e(e,"repeat of a chomping mode identifier");else if((g=dB(y))>=0)g===0?_e(e,"bad explicit indentation width of a block scalar; it cannot be less than one"):c?_e(e,"repeat of an indentation width identifier"):(d=n+g-1,c=!0);else break;if($i(y)){do y=e.input.charCodeAt(++e.position);while($i(y));if(y===35)do y=e.input.charCodeAt(++e.position);while(!Gn(y)&&y!==0)}for(;y!==0;){for(wb(e),e.lineIndent=0,y=e.input.charCodeAt(e.position);(!c||e.lineIndentd&&(d=e.lineIndent),Gn(y)){p++;continue}if(e.lineIndentn)&&p!==0)_e(e,"bad indentation of a sequence entry");else if(e.lineIndentn)&&(C&&(c=e.line,d=e.lineStart,p=e.position),ho(e,n,ku,!0,o)&&(C?S=e.result:w=e.result),C||(no(e,y,m,b,S,w,c,d,p),b=S=w=null),mt(e,!0,-1),j=e.input.charCodeAt(e.position)),(e.line===l||e.lineIndent>n)&&j!==0)_e(e,"bad indentation of a mapping entry");else if(e.lineIndentn?p=1:e.lineIndent===n?p=0:e.lineIndentn?p=1:e.lineIndent===n?p=0:e.lineIndent tag; it should be "scalar", not "'+e.kind+'"'),y=0,m=e.implicitTypes.length;y"),e.result!==null&&S.kind!==e.kind&&_e(e,"unacceptable node kind for !<"+e.tag+'> tag; it should be "'+S.kind+'", not "'+e.kind+'"'),S.resolve(e.result,e.tag)?(e.result=S.construct(e.result,e.tag),e.anchor!==null&&(e.anchorMap[e.anchor]=e.result)):_e(e,"cannot resolve a node with !<"+e.tag+"> explicit tag")}return e.listener!==null&&e.listener("close",e),e.tag!==null||e.anchor!==null||g}function _B(e){var n=e.position,r,a,o,l=!1,c;for(e.version=null,e.checkLineBreaks=e.legacy,e.tagMap=Object.create(null),e.anchorMap=Object.create(null);(c=e.input.charCodeAt(e.position))!==0&&(mt(e,!0,-1),c=e.input.charCodeAt(e.position),!(e.lineIndent>0||c!==37));){for(l=!0,c=e.input.charCodeAt(++e.position),r=e.position;c!==0&&!en(c);)c=e.input.charCodeAt(++e.position);for(a=e.input.slice(r,e.position),o=[],a.length<1&&_e(e,"directive name must not be less than one character in length");c!==0;){for(;$i(c);)c=e.input.charCodeAt(++e.position);if(c===35){do c=e.input.charCodeAt(++e.position);while(c!==0&&!Gn(c));break}if(Gn(c))break;for(r=e.position;c!==0&&!en(c);)c=e.input.charCodeAt(++e.position);o.push(e.input.slice(r,e.position))}c!==0&&wb(e),fi.call(i2,a)?i2[a](e,a,o):Cu(e,'unknown document directive "'+a+'"')}if(mt(e,!0,-1),e.lineIndent===0&&e.input.charCodeAt(e.position)===45&&e.input.charCodeAt(e.position+1)===45&&e.input.charCodeAt(e.position+2)===45?(e.position+=3,mt(e,!0,-1)):l&&_e(e,"directives end mark is expected"),ho(e,e.lineIndent-1,ku,!1,!0),mt(e,!0,-1),e.checkLineBreaks&&sB.test(e.input.slice(n,e.position))&&Cu(e,"non-ASCII line breaks are interpreted as content"),e.documents.push(e.result),e.position===e.lineStart&&Wu(e)){e.input.charCodeAt(e.position)===46&&(e.position+=3,mt(e,!0,-1));return}if(e.position"u"&&(r=n,n=null);var a=X8(e,r);if(typeof n!="function")return a;for(var o=0,l=a.length;o=55296&&r<=56319&&n+1=56320&&a<=57343)?(r-55296)*1024+a-56320+65536:r}function i3(e){var n=/^\n* /;return n.test(e)}var a3=1,$0=2,o3=3,s3=4,Qa=5;function JB(e,n,r,a,o,l,c,d){var p,h=0,g=null,y=!1,m=!1,b=a!==-1,S=-1,w=ZB(Rs(e,0))&&QB(Rs(e,e.length-1));if(n||c)for(p=0;p=65536?p+=2:p++){if(h=Rs(e,p),!Js(h))return Qa;w=w&&c2(h,g,d),g=h}else{for(p=0;p=65536?p+=2:p++){if(h=Rs(e,p),h===Zs)y=!0,b&&(m=m||p-S-1>a&&e[S+1]!==" ",S=p);else if(!Js(h))return Qa;w=w&&c2(h,g,d),g=h}m=m||b&&p-S-1>a&&e[S+1]!==" "}return!y&&!m?w&&!c&&!o(e)?a3:l===Qs?Qa:$0:r>9&&i3(e)?Qa:c?l===Qs?Qa:$0:m?s3:o3}function e7(e,n,r,a,o){e.dump=(function(){if(n.length===0)return e.quotingType===Qs?'""':"''";if(!e.noCompatMode&&($B.indexOf(n)!==-1||VB.test(n)))return e.quotingType===Qs?'"'+n+'"':"'"+n+"'";var l=e.indent*Math.max(1,r),c=e.lineWidth===-1?-1:Math.max(Math.min(e.lineWidth,40),e.lineWidth-l),d=a||e.flowLevel>-1&&r>=e.flowLevel;function p(h){return KB(e,h)}switch(JB(n,d,e.indent,c,p,e.quotingType,e.forceQuotes&&!a,o)){case a3:return n;case $0:return"'"+n.replace(/'/g,"''")+"'";case o3:return"|"+u2(n,e.indent)+d2(s2(n,l));case s3:return">"+u2(n,e.indent)+d2(s2(t7(n,c),l));case Qa:return'"'+n7(n)+'"';default:throw new Ft("impossible error: invalid scalar style")}})()}function u2(e,n){var r=i3(e)?String(n):"",a=e[e.length-1]===` +`,o=a&&(e[e.length-2]===` +`||e===` +`),l=o?"+":a?"":"-";return r+l+` +`}function d2(e){return e[e.length-1]===` +`?e.slice(0,-1):e}function t7(e,n){for(var r=/(\n+)([^\n]*)/g,a=(function(){var h=e.indexOf(` +`);return h=h!==-1?h:e.length,r.lastIndex=h,f2(e.slice(0,h),n)})(),o=e[0]===` +`||e[0]===" ",l,c;c=r.exec(e);){var d=c[1],p=c[2];l=p[0]===" ",a+=d+(!o&&!l&&p!==""?` +`:"")+f2(p,n),o=l}return a}function f2(e,n){if(e===""||e[0]===" ")return e;for(var r=/ [^ ]/g,a,o=0,l,c=0,d=0,p="";a=r.exec(e);)d=a.index,d-o>n&&(l=c>o?c:d,p+=` +`+e.slice(o,l),o=l+1),c=d;return p+=` +`,e.length-o>n&&c>o?p+=e.slice(o,c)+` +`+e.slice(c+1):p+=e.slice(o),p.slice(1)}function n7(e){for(var n="",r=0,a,o=0;o=65536?o+=2:o++)r=Rs(e,o),a=Bt[r],!a&&Js(r)?(n+=e[o],r>=65536&&(n+=e[o+1])):n+=a||GB(r);return n}function r7(e,n,r){var a="",o=e.tag,l,c,d;for(l=0,c=r.length;l"u"&&Cr(e,n,null,!1,!1))&&(a!==""&&(a+=","+(e.condenseFlow?"":" ")),a+=e.dump);e.tag=o,e.dump="["+a+"]"}function p2(e,n,r,a){var o="",l=e.tag,c,d,p;for(c=0,d=r.length;c"u"&&Cr(e,n+1,null,!0,!0,!1,!0))&&((!a||o!=="")&&(o+=P0(e,n)),e.dump&&Zs===e.dump.charCodeAt(0)?o+="-":o+="- ",o+=e.dump);e.tag=l,e.dump=o||"[]"}function i7(e,n,r){var a="",o=e.tag,l=Object.keys(r),c,d,p,h,g;for(c=0,d=l.length;c1024&&(g+="? "),g+=e.dump+(e.condenseFlow?'"':"")+":"+(e.condenseFlow?"":" "),Cr(e,n,h,!1,!1)&&(g+=e.dump,a+=g));e.tag=o,e.dump="{"+a+"}"}function a7(e,n,r,a){var o="",l=e.tag,c=Object.keys(r),d,p,h,g,y,m;if(e.sortKeys===!0)c.sort();else if(typeof e.sortKeys=="function")c.sort(e.sortKeys);else if(e.sortKeys)throw new Ft("sortKeys must be a boolean or a function");for(d=0,p=c.length;d1024,y&&(e.dump&&Zs===e.dump.charCodeAt(0)?m+="?":m+="? "),m+=e.dump,y&&(m+=P0(e,n)),Cr(e,n+1,g,!0,y)&&(e.dump&&Zs===e.dump.charCodeAt(0)?m+=":":m+=": ",m+=e.dump,o+=m));e.tag=l,e.dump=o||"{}"}function h2(e,n,r){var a,o,l,c,d,p;for(o=r?e.explicitTypes:e.implicitTypes,l=0,c=o.length;l tag resolver accepts not "'+p+'" style');e.dump=a}return!0}return!1}function Cr(e,n,r,a,o,l,c){e.tag=null,e.dump=r,h2(e,r,!1)||h2(e,r,!0);var d=Z8.call(e.dump),p=a,h;a&&(a=e.flowLevel<0||e.flowLevel>n);var g=d==="[object Object]"||d==="[object Array]",y,m;if(g&&(y=e.duplicates.indexOf(r),m=y!==-1),(e.tag!==null&&e.tag!=="?"||m||e.indent!==2&&n>0)&&(o=!1),m&&e.usedDuplicates[y])e.dump="*ref_"+y;else{if(g&&m&&!e.usedDuplicates[y]&&(e.usedDuplicates[y]=!0),d==="[object Object]")a&&Object.keys(e.dump).length!==0?(a7(e,n,e.dump,o),m&&(e.dump="&ref_"+y+e.dump)):(i7(e,n,e.dump),m&&(e.dump="&ref_"+y+" "+e.dump));else if(d==="[object Array]")a&&e.dump.length!==0?(e.noArrayIndent&&!c&&n>0?p2(e,n-1,e.dump,o):p2(e,n,e.dump,o),m&&(e.dump="&ref_"+y+e.dump)):(r7(e,n,e.dump),m&&(e.dump="&ref_"+y+" "+e.dump));else if(d==="[object String]")e.tag!=="?"&&e7(e,e.dump,n,l,p);else{if(d==="[object Undefined]")return!1;if(e.skipInvalid)return!1;throw new Ft("unacceptable kind of an object to dump "+d)}e.tag!==null&&e.tag!=="?"&&(h=encodeURI(e.tag[0]==="!"?e.tag.slice(1):e.tag).replace(/!/g,"%21"),e.tag[0]==="!"?h="!"+h:h.slice(0,18)==="tag:yaml.org,2002:"?h="!!"+h.slice(18):h="!<"+h+">",e.dump=h+" "+e.dump)}return!0}function o7(e,n){var r=[],a=[],o,l;for(V0(e,r,a),o=0,l=a.length;o-1}return eh=n,eh}var th,S2;function T7(){if(S2)return th;S2=1;var e=Gu();function n(r,a){var o=this.__data__,l=e(o,r);return l<0?(++this.size,o.push([r,a])):o[l][1]=a,this}return th=n,th}var nh,w2;function Yu(){if(w2)return nh;w2=1;var e=k7(),n=C7(),r=E7(),a=j7(),o=T7();function l(c){var d=-1,p=c==null?0:c.length;for(this.clear();++d-1&&a%1==0&&a-1&&r%1==0&&r<=e}return Zh=n,Zh}var Qh,bk;function tH(){if(bk)return Qh;bk=1;var e=Zi(),n=Rb(),r=Kn(),a="[object Arguments]",o="[object Array]",l="[object Boolean]",c="[object Date]",d="[object Error]",p="[object Function]",h="[object Map]",g="[object Number]",y="[object Object]",m="[object RegExp]",b="[object Set]",S="[object String]",w="[object WeakMap]",C="[object ArrayBuffer]",_="[object DataView]",j="[object Float32Array]",k="[object Float64Array]",T="[object Int8Array]",E="[object Int16Array]",z="[object Int32Array]",A="[object Uint8Array]",M="[object Uint8ClampedArray]",O="[object Uint16Array]",P="[object Uint32Array]",L={};L[j]=L[k]=L[T]=L[E]=L[z]=L[A]=L[M]=L[O]=L[P]=!0,L[a]=L[o]=L[C]=L[l]=L[_]=L[c]=L[d]=L[p]=L[h]=L[g]=L[y]=L[m]=L[b]=L[S]=L[w]=!1;function I(F){return r(F)&&n(F.length)&&!!L[e(F)]}return Qh=I,Qh}var Jh,xk;function td(){if(xk)return Jh;xk=1;function e(n){return function(r){return n(r)}}return Jh=e,Jh}var Ns={exports:{}};Ns.exports;var Sk;function zb(){return Sk||(Sk=1,(function(e,n){var r=c3(),a=n&&!n.nodeType&&n,o=a&&!0&&e&&!e.nodeType&&e,l=o&&o.exports===a,c=l&&r.process,d=(function(){try{var p=o&&o.require&&o.require("util").types;return p||c&&c.binding&&c.binding("util")}catch{}})();e.exports=d})(Ns,Ns.exports)),Ns.exports}var eg,wk;function fl(){if(wk)return eg;wk=1;var e=tH(),n=td(),r=zb(),a=r&&r.isTypedArray,o=a?n(a):e;return eg=o,eg}var tg,_k;function f3(){if(_k)return tg;_k=1;var e=Q7(),n=dl(),r=St(),a=bo(),o=ed(),l=fl(),c=Object.prototype,d=c.hasOwnProperty;function p(h,g){var y=r(h),m=!y&&n(h),b=!y&&!m&&a(h),S=!y&&!m&&!b&&l(h),w=y||m||b||S,C=w?e(h.length,String):[],_=C.length;for(var j in h)(g||d.call(h,j))&&!(w&&(j=="length"||b&&(j=="offset"||j=="parent")||S&&(j=="buffer"||j=="byteLength"||j=="byteOffset")||o(j,_)))&&C.push(j);return C}return tg=p,tg}var ng,kk;function nd(){if(kk)return ng;kk=1;var e=Object.prototype;function n(r){var a=r&&r.constructor,o=typeof a=="function"&&a.prototype||e;return r===o}return ng=n,ng}var rg,Ck;function p3(){if(Ck)return rg;Ck=1;function e(n,r){return function(a){return n(r(a))}}return rg=e,rg}var ig,Ek;function nH(){if(Ek)return ig;Ek=1;var e=p3(),n=e(Object.keys,Object);return ig=n,ig}var ag,jk;function Nb(){if(jk)return ag;jk=1;var e=nd(),n=nH(),r=Object.prototype,a=r.hasOwnProperty;function o(l){if(!e(l))return n(l);var c=[];for(var d in Object(l))a.call(l,d)&&d!="constructor"&&c.push(d);return c}return ag=o,ag}var og,Tk;function jr(){if(Tk)return og;Tk=1;var e=cl(),n=Rb();function r(a){return a!=null&&n(a.length)&&!e(a)}return og=r,og}var sg,Ak;function pi(){if(Ak)return sg;Ak=1;var e=f3(),n=Nb(),r=jr();function a(o){return r(o)?e(o):n(o)}return sg=a,sg}var lg,Rk;function rH(){if(Rk)return lg;Rk=1;var e=ul(),n=pi();function r(a,o){return a&&e(o,n(o),a)}return lg=r,lg}var cg,zk;function iH(){if(zk)return cg;zk=1;function e(n){var r=[];if(n!=null)for(var a in Object(n))r.push(a);return r}return cg=e,cg}var ug,Nk;function aH(){if(Nk)return ug;Nk=1;var e=xn(),n=nd(),r=iH(),a=Object.prototype,o=a.hasOwnProperty;function l(c){if(!e(c))return r(c);var d=n(c),p=[];for(var h in c)h=="constructor"&&(d||!o.call(c,h))||p.push(h);return p}return ug=l,ug}var dg,Mk;function Ji(){if(Mk)return dg;Mk=1;var e=f3(),n=aH(),r=jr();function a(o){return r(o)?e(o,!0):n(o)}return dg=a,dg}var fg,Ok;function oH(){if(Ok)return fg;Ok=1;var e=ul(),n=Ji();function r(a,o){return a&&e(o,n(o),a)}return fg=r,fg}var Ms={exports:{}};Ms.exports;var Dk;function h3(){return Dk||(Dk=1,(function(e,n){var r=Dn(),a=n&&!n.nodeType&&n,o=a&&!0&&e&&!e.nodeType&&e,l=o&&o.exports===a,c=l?r.Buffer:void 0,d=c?c.allocUnsafe:void 0;function p(h,g){if(g)return h.slice();var y=h.length,m=d?d(y):new h.constructor(y);return h.copy(m),m}e.exports=p})(Ms,Ms.exports)),Ms.exports}var pg,qk;function g3(){if(qk)return pg;qk=1;function e(n,r){var a=-1,o=n.length;for(r||(r=Array(o));++ab))return!1;var w=y.get(c),C=y.get(d);if(w&&C)return w==d&&C==c;var _=-1,j=!0,k=p&o?new e:void 0;for(y.set(c,d),y.set(d,c);++_0&&l(g)?o>1?r(g,o-1,l,c,d):e(d,g):c||(d[d.length]=g)}return d}return im=r,im}var am,TE;function r9(){if(TE)return am;TE=1;function e(n,r,a){switch(a.length){case 0:return n.call(r);case 1:return n.call(r,a[0]);case 2:return n.call(r,a[0],a[1]);case 3:return n.call(r,a[0],a[1],a[2])}return n.apply(r,a)}return am=e,am}var om,AE;function W3(){if(AE)return om;AE=1;var e=r9(),n=Math.max;function r(a,o,l){return o=n(o===void 0?a.length-1:o,0),function(){for(var c=arguments,d=-1,p=n(c.length-o,0),h=Array(p);++d0){if(++l>=e)return arguments[0]}else l=0;return o.apply(void 0,arguments)}}return lm=a,lm}var cm,NE;function G3(){if(NE)return cm;NE=1;var e=i9(),n=a9(),r=n(e);return cm=r,cm}var um,ME;function ld(){if(ME)return um;ME=1;var e=ea(),n=W3(),r=G3();function a(o,l){return r(n(o,l,e),o+"")}return um=a,um}var dm,OE;function Y3(){if(OE)return dm;OE=1;function e(n,r,a,o){for(var l=n.length,c=a+(o?1:-1);o?c--:++c-1}return gm=n,gm}var ym,BE;function u9(){if(BE)return ym;BE=1;function e(n,r,a){for(var o=-1,l=n==null?0:n.length;++o=c){var _=h?null:o(p);if(_)return l(_);S=!1,m=a,C=new e}else C=h?[]:w;e:for(;++y1?b.setNode(S,y):b.setNode(S)}),this},o.prototype.setNode=function(g,y){return e.has(this._nodes,g)?(arguments.length>1&&(this._nodes[g]=y),this):(this._nodes[g]=arguments.length>1?y:this._defaultNodeLabelFn(g),this._isCompound&&(this._parent[g]=r,this._children[g]={},this._children[r][g]=!0),this._in[g]={},this._preds[g]={},this._out[g]={},this._sucs[g]={},++this._nodeCount,this)},o.prototype.node=function(g){return this._nodes[g]},o.prototype.hasNode=function(g){return e.has(this._nodes,g)},o.prototype.removeNode=function(g){var y=this;if(e.has(this._nodes,g)){var m=function(b){y.removeEdge(y._edgeObjs[b])};delete this._nodes[g],this._isCompound&&(this._removeFromParentsChildList(g),delete this._parent[g],e.each(this.children(g),function(b){y.setParent(b)}),delete this._children[g]),e.each(e.keys(this._in[g]),m),delete this._in[g],delete this._preds[g],e.each(e.keys(this._out[g]),m),delete this._out[g],delete this._sucs[g],--this._nodeCount}return this},o.prototype.setParent=function(g,y){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(e.isUndefined(y))y=r;else{y+="";for(var m=y;!e.isUndefined(m);m=this.parent(m))if(m===g)throw new Error("Setting "+y+" as parent of "+g+" would create a cycle");this.setNode(y)}return this.setNode(g),this._removeFromParentsChildList(g),this._parent[g]=y,this._children[y][g]=!0,this},o.prototype._removeFromParentsChildList=function(g){delete this._children[this._parent[g]][g]},o.prototype.parent=function(g){if(this._isCompound){var y=this._parent[g];if(y!==r)return y}},o.prototype.children=function(g){if(e.isUndefined(g)&&(g=r),this._isCompound){var y=this._children[g];if(y)return e.keys(y)}else{if(g===r)return this.nodes();if(this.hasNode(g))return[]}},o.prototype.predecessors=function(g){var y=this._preds[g];if(y)return e.keys(y)},o.prototype.successors=function(g){var y=this._sucs[g];if(y)return e.keys(y)},o.prototype.neighbors=function(g){var y=this.predecessors(g);if(y)return e.union(y,this.successors(g))},o.prototype.isLeaf=function(g){var y;return this.isDirected()?y=this.successors(g):y=this.neighbors(g),y.length===0},o.prototype.filterNodes=function(g){var y=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});y.setGraph(this.graph());var m=this;e.each(this._nodes,function(w,C){g(C)&&y.setNode(C,w)}),e.each(this._edgeObjs,function(w){y.hasNode(w.v)&&y.hasNode(w.w)&&y.setEdge(w,m.edge(w))});var b={};function S(w){var C=m.parent(w);return C===void 0||y.hasNode(C)?(b[w]=C,C):C in b?b[C]:S(C)}return this._isCompound&&e.each(y.nodes(),function(w){y.setParent(w,S(w))}),y},o.prototype.setDefaultEdgeLabel=function(g){return e.isFunction(g)||(g=e.constant(g)),this._defaultEdgeLabelFn=g,this},o.prototype.edgeCount=function(){return this._edgeCount},o.prototype.edges=function(){return e.values(this._edgeObjs)},o.prototype.setPath=function(g,y){var m=this,b=arguments;return e.reduce(g,function(S,w){return b.length>1?m.setEdge(S,w,y):m.setEdge(S,w),w}),this},o.prototype.setEdge=function(){var g,y,m,b,S=!1,w=arguments[0];typeof w=="object"&&w!==null&&"v"in w?(g=w.v,y=w.w,m=w.name,arguments.length===2&&(b=arguments[1],S=!0)):(g=w,y=arguments[1],m=arguments[3],arguments.length>2&&(b=arguments[2],S=!0)),g=""+g,y=""+y,e.isUndefined(m)||(m=""+m);var C=d(this._isDirected,g,y,m);if(e.has(this._edgeLabels,C))return S&&(this._edgeLabels[C]=b),this;if(!e.isUndefined(m)&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(g),this.setNode(y),this._edgeLabels[C]=S?b:this._defaultEdgeLabelFn(g,y,m);var _=p(this._isDirected,g,y,m);return g=_.v,y=_.w,Object.freeze(_),this._edgeObjs[C]=_,l(this._preds[y],g),l(this._sucs[g],y),this._in[y][C]=_,this._out[g][C]=_,this._edgeCount++,this},o.prototype.edge=function(g,y,m){var b=arguments.length===1?h(this._isDirected,arguments[0]):d(this._isDirected,g,y,m);return this._edgeLabels[b]},o.prototype.hasEdge=function(g,y,m){var b=arguments.length===1?h(this._isDirected,arguments[0]):d(this._isDirected,g,y,m);return e.has(this._edgeLabels,b)},o.prototype.removeEdge=function(g,y,m){var b=arguments.length===1?h(this._isDirected,arguments[0]):d(this._isDirected,g,y,m),S=this._edgeObjs[b];return S&&(g=S.v,y=S.w,delete this._edgeLabels[b],delete this._edgeObjs[b],c(this._preds[y],g),c(this._sucs[g],y),delete this._in[y][b],delete this._out[g][b],this._edgeCount--),this},o.prototype.inEdges=function(g,y){var m=this._in[g];if(m){var b=e.values(m);return y?e.filter(b,function(S){return S.v===y}):b}},o.prototype.outEdges=function(g,y){var m=this._out[g];if(m){var b=e.values(m);return y?e.filter(b,function(S){return S.w===y}):b}},o.prototype.nodeEdges=function(g,y){var m=this.inEdges(g,y);if(m)return m.concat(this.outEdges(g,y))};function l(g,y){g[y]?g[y]++:g[y]=1}function c(g,y){--g[y]||delete g[y]}function d(g,y,m,b){var S=""+y,w=""+m;if(!g&&S>w){var C=S;S=w,w=C}return S+a+w+a+(e.isUndefined(b)?n:b)}function p(g,y,m,b){var S=""+y,w=""+m;if(!g&&S>w){var C=S;S=w,w=C}var _={v:S,w};return b&&(_.name=b),_}function h(g,y){return d(g,y.v,y.w,y.name)}return Cm}var Em,XE;function y9(){return XE||(XE=1,Em="2.1.8"),Em}var jm,KE;function m9(){return KE||(KE=1,jm={Graph:Fb(),version:y9()}),jm}var Tm,ZE;function v9(){if(ZE)return Tm;ZE=1;var e=Sn(),n=Fb();Tm={write:r,read:l};function r(c){var d={options:{directed:c.isDirected(),multigraph:c.isMultigraph(),compound:c.isCompound()},nodes:a(c),edges:o(c)};return e.isUndefined(c.graph())||(d.value=e.clone(c.graph())),d}function a(c){return e.map(c.nodes(),function(d){var p=c.node(d),h=c.parent(d),g={v:d};return e.isUndefined(p)||(g.value=p),e.isUndefined(h)||(g.parent=h),g})}function o(c){return e.map(c.edges(),function(d){var p=c.edge(d),h={v:d.v,w:d.w};return e.isUndefined(d.name)||(h.name=d.name),e.isUndefined(p)||(h.value=p),h})}function l(c){var d=new n(c.options).setGraph(c.value);return e.each(c.nodes,function(p){d.setNode(p.v,p.value),p.parent&&d.setParent(p.v,p.parent)}),e.each(c.edges,function(p){d.setEdge({v:p.v,w:p.w,name:p.name},p.value)}),d}return Tm}var Am,QE;function b9(){if(QE)return Am;QE=1;var e=Sn();Am=n;function n(r){var a={},o=[],l;function c(d){e.has(a,d)||(a[d]=!0,l.push(d),e.each(r.successors(d),c),e.each(r.predecessors(d),c))}return e.each(r.nodes(),function(d){l=[],c(d),l.length&&o.push(l)}),o}return Am}var Rm,JE;function Z3(){if(JE)return Rm;JE=1;var e=Sn();Rm=n;function n(){this._arr=[],this._keyIndices={}}return n.prototype.size=function(){return this._arr.length},n.prototype.keys=function(){return this._arr.map(function(r){return r.key})},n.prototype.has=function(r){return e.has(this._keyIndices,r)},n.prototype.priority=function(r){var a=this._keyIndices[r];if(a!==void 0)return this._arr[a].priority},n.prototype.min=function(){if(this.size()===0)throw new Error("Queue underflow");return this._arr[0].key},n.prototype.add=function(r,a){var o=this._keyIndices;if(r=String(r),!e.has(o,r)){var l=this._arr,c=l.length;return o[r]=c,l.push({key:r,priority:a}),this._decrease(c),!0}return!1},n.prototype.removeMin=function(){this._swap(0,this._arr.length-1);var r=this._arr.pop();return delete this._keyIndices[r.key],this._heapify(0),r.key},n.prototype.decrease=function(r,a){var o=this._keyIndices[r];if(a>this._arr[o].priority)throw new Error("New priority is greater than current priority. Key: "+r+" Old: "+this._arr[o].priority+" New: "+a);this._arr[o].priority=a,this._decrease(o)},n.prototype._heapify=function(r){var a=this._arr,o=2*r,l=o+1,c=r;o>1,!(a[l].priority0&&(y=g.removeMin(),m=h[y],m.distance!==Number.POSITIVE_INFINITY);)p(y).forEach(b);return h}return zm}var Nm,t4;function x9(){if(t4)return Nm;t4=1;var e=Q3(),n=Sn();Nm=r;function r(a,o,l){return n.transform(a.nodes(),function(c,d){c[d]=e(a,d,o,l)},{})}return Nm}var Mm,n4;function J3(){if(n4)return Mm;n4=1;var e=Sn();Mm=n;function n(r){var a=0,o=[],l={},c=[];function d(p){var h=l[p]={onStack:!0,lowlink:a,index:a++};if(o.push(p),r.successors(p).forEach(function(m){e.has(l,m)?l[m].onStack&&(h.lowlink=Math.min(h.lowlink,l[m].index)):(d(m),h.lowlink=Math.min(h.lowlink,l[m].lowlink))}),h.lowlink===h.index){var g=[],y;do y=o.pop(),l[y].onStack=!1,g.push(y);while(p!==y);c.push(g)}}return r.nodes().forEach(function(p){e.has(l,p)||d(p)}),c}return Mm}var Om,r4;function S9(){if(r4)return Om;r4=1;var e=Sn(),n=J3();Om=r;function r(a){return e.filter(n(a),function(o){return o.length>1||o.length===1&&a.hasEdge(o[0],o[0])})}return Om}var Dm,i4;function w9(){if(i4)return Dm;i4=1;var e=Sn();Dm=r;var n=e.constant(1);function r(o,l,c){return a(o,l||n,c||function(d){return o.outEdges(d)})}function a(o,l,c){var d={},p=o.nodes();return p.forEach(function(h){d[h]={},d[h][h]={distance:0},p.forEach(function(g){h!==g&&(d[h][g]={distance:Number.POSITIVE_INFINITY})}),c(h).forEach(function(g){var y=g.v===h?g.w:g.v,m=l(g);d[h][y]={distance:m,predecessor:h}})}),p.forEach(function(h){var g=d[h];p.forEach(function(y){var m=d[y];p.forEach(function(b){var S=m[h],w=g[b],C=m[b],_=S.distance+w.distance;_0;){if(h=p.removeMin(),e.has(d,h))c.setEdge(h,d[h]);else{if(y)throw new Error("Input graph is not connected: "+o);y=!0}o.nodeEdges(h).forEach(g)}return c}return Um}var Fm,d4;function j9(){return d4||(d4=1,Fm={components:b9(),dijkstra:Q3(),dijkstraAll:x9(),findCycles:S9(),floydWarshall:w9(),isAcyclic:_9(),postorder:k9(),preorder:C9(),prim:E9(),tarjan:J3(),topsort:eA()}),Fm}var Pm,f4;function T9(){if(f4)return Pm;f4=1;var e=m9();return Pm={Graph:e.Graph,json:v9(),alg:j9(),version:e.version},Pm}var $m,p4;function Nn(){if(p4)return $m;p4=1;var e;if(typeof Eb=="function")try{e=T9()}catch{}return e||(e=window.graphlib),$m=e,$m}var Vm,h4;function A9(){if(h4)return Vm;h4=1;var e=E3(),n=1,r=4;function a(o){return e(o,n|r)}return Vm=a,Vm}var Wm,g4;function cd(){if(g4)return Wm;g4=1;var e=mo(),n=jr(),r=ed(),a=xn();function o(l,c,d){if(!a(d))return!1;var p=typeof c;return(p=="number"?n(d)&&r(c,d.length):p=="string"&&c in d)?e(d[c],l):!1}return Wm=o,Wm}var Gm,y4;function R9(){if(y4)return Gm;y4=1;var e=ld(),n=mo(),r=cd(),a=Ji(),o=Object.prototype,l=o.hasOwnProperty,c=e(function(d,p){d=Object(d);var h=-1,g=p.length,y=g>2?p[2]:void 0;for(y&&r(p[0],p[1],y)&&(g=1);++h-1?p[h?l[g]:g]:void 0}}return Ym=a,Ym}var Xm,v4;function N9(){if(v4)return Xm;v4=1;var e=/\s/;function n(r){for(var a=r.length;a--&&e.test(r.charAt(a)););return a}return Xm=n,Xm}var Km,b4;function M9(){if(b4)return Km;b4=1;var e=N9(),n=/^\s+/;function r(a){return a&&a.slice(0,e(a)+1).replace(n,"")}return Km=r,Km}var Zm,x4;function O9(){if(x4)return Zm;x4=1;var e=M9(),n=xn(),r=So(),a=NaN,o=/^[-+]0x[0-9a-f]+$/i,l=/^0b[01]+$/i,c=/^0o[0-7]+$/i,d=parseInt;function p(h){if(typeof h=="number")return h;if(r(h))return a;if(n(h)){var g=typeof h.valueOf=="function"?h.valueOf():h;h=n(g)?g+"":g}if(typeof h!="string")return h===0?h:+h;h=e(h);var y=l.test(h);return y||c.test(h)?d(h.slice(2),y?2:8):o.test(h)?a:+h}return Zm=p,Zm}var Qm,S4;function nA(){if(S4)return Qm;S4=1;var e=O9(),n=1/0,r=17976931348623157e292;function a(o){if(!o)return o===0?o:0;if(o=e(o),o===n||o===-n){var l=o<0?-1:1;return l*r}return o===o?o:0}return Qm=a,Qm}var Jm,w4;function D9(){if(w4)return Jm;w4=1;var e=nA();function n(r){var a=e(r),o=a%1;return a===a?o?a-o:a:0}return Jm=n,Jm}var ev,_4;function q9(){if(_4)return ev;_4=1;var e=Y3(),n=Tr(),r=D9(),a=Math.max;function o(l,c,d){var p=l==null?0:l.length;if(!p)return-1;var h=d==null?0:r(d);return h<0&&(h=a(p+h,0)),e(l,n(c,3),h)}return ev=o,ev}var tv,k4;function I9(){if(k4)return tv;k4=1;var e=z9(),n=q9(),r=e(n);return tv=r,tv}var nv,C4;function rA(){if(C4)return nv;C4=1;var e=Ub();function n(r){var a=r==null?0:r.length;return a?e(r,1):[]}return nv=n,nv}var rv,E4;function L9(){if(E4)return rv;E4=1;var e=Ib(),n=j3(),r=Ji();function a(o,l){return o==null?o:e(o,n(l),r)}return rv=a,rv}var iv,j4;function B9(){if(j4)return iv;j4=1;function e(n){var r=n==null?0:n.length;return r?n[r-1]:void 0}return iv=e,iv}var av,T4;function H9(){if(T4)return av;T4=1;var e=Qu(),n=Lb(),r=Tr();function a(o,l){var c={};return l=r(l,3),n(o,function(d,p,h){e(c,p,l(d,p,h))}),c}return av=a,av}var ov,A4;function Pb(){if(A4)return ov;A4=1;var e=So();function n(r,a,o){for(var l=-1,c=r.length;++lr}return sv=e,sv}var lv,z4;function F9(){if(z4)return lv;z4=1;var e=Pb(),n=U9(),r=ea();function a(o){return o&&o.length?e(o,r,n):void 0}return lv=a,lv}var cv,N4;function iA(){if(N4)return cv;N4=1;var e=Qu(),n=mo();function r(a,o,l){(l!==void 0&&!n(a[o],l)||l===void 0&&!(o in a))&&e(a,o,l)}return cv=r,cv}var uv,M4;function P9(){if(M4)return uv;M4=1;var e=Zi(),n=rd(),r=Kn(),a="[object Object]",o=Function.prototype,l=Object.prototype,c=o.toString,d=l.hasOwnProperty,p=c.call(Object);function h(g){if(!r(g)||e(g)!=a)return!1;var y=n(g);if(y===null)return!0;var m=d.call(y,"constructor")&&y.constructor;return typeof m=="function"&&m instanceof m&&c.call(m)==p}return uv=h,uv}var dv,O4;function aA(){if(O4)return dv;O4=1;function e(n,r){if(!(r==="constructor"&&typeof n[r]=="function")&&r!="__proto__")return n[r]}return dv=e,dv}var fv,D4;function $9(){if(D4)return fv;D4=1;var e=ul(),n=Ji();function r(a){return e(a,n(a))}return fv=r,fv}var pv,q4;function V9(){if(q4)return pv;q4=1;var e=iA(),n=h3(),r=_3(),a=g3(),o=C3(),l=dl(),c=St(),d=X3(),p=bo(),h=cl(),g=xn(),y=P9(),m=fl(),b=aA(),S=$9();function w(C,_,j,k,T,E,z){var A=b(C,j),M=b(_,j),O=z.get(M);if(O){e(C,j,O);return}var P=E?E(A,M,j+"",C,_,z):void 0,L=P===void 0;if(L){var I=c(M),F=!I&&p(M),U=!I&&!F&&m(M);P=M,I||F||U?c(A)?P=A:d(A)?P=a(A):F?(L=!1,P=n(M,!0)):U?(L=!1,P=r(M,!0)):P=[]:y(M)||l(M)?(P=A,l(A)?P=S(A):(!g(A)||h(A))&&(P=o(M))):L=!1}L&&(z.set(M,P),T(P,M,k,E,z),z.delete(M)),e(C,j,P)}return pv=w,pv}var hv,I4;function W9(){if(I4)return hv;I4=1;var e=Zu(),n=iA(),r=Ib(),a=V9(),o=xn(),l=Ji(),c=aA();function d(p,h,g,y,m){p!==h&&r(h,function(b,S){if(m||(m=new e),o(b))a(p,h,S,g,d,y,m);else{var w=y?y(c(p,S),b,S+"",p,h,m):void 0;w===void 0&&(w=b),n(p,S,w)}},l)}return hv=d,hv}var gv,L4;function G9(){if(L4)return gv;L4=1;var e=ld(),n=cd();function r(a){return e(function(o,l){var c=-1,d=l.length,p=d>1?l[d-1]:void 0,h=d>2?l[2]:void 0;for(p=a.length>3&&typeof p=="function"?(d--,p):void 0,h&&n(l[0],l[1],h)&&(p=d<3?void 0:p,d=1),o=Object(o);++ca||d&&p&&g&&!h&&!y||l&&p&&g||!o&&g||!c)return 1;if(!l&&!d&&!y&&r=h)return g;var y=o[l];return g*(y=="desc"?-1:1)}}return r.index-a.index}return zv=n,zv}var Nv,tj;function cU(){if(tj)return Nv;tj=1;var e=ad(),n=sd(),r=Tr(),a=P3(),o=oU(),l=td(),c=lU(),d=ea(),p=St();function h(g,y,m){y.length?y=e(y,function(w){return p(w)?function(C){return n(C,w.length===1?w[0]:w)}:w}):y=[d];var b=-1;y=e(y,l(r));var S=a(g,function(w,C,_){var j=e(y,function(k){return k(w)});return{criteria:j,index:++b,value:w}});return o(S,function(w,C){return c(w,C,m)})}return Nv=h,Nv}var Mv,nj;function uU(){if(nj)return Mv;nj=1;var e=Ub(),n=cU(),r=ld(),a=cd(),o=r(function(l,c){if(l==null)return[];var d=c.length;return d>1&&a(l,c[0],c[1])?c=[]:d>2&&a(c[0],c[1],c[2])&&(c=[c[0]]),n(l,e(c,1),[])});return Mv=o,Mv}var Ov,rj;function dU(){if(rj)return Ov;rj=1;var e=q3(),n=0;function r(a){var o=++n;return e(a)+o}return Ov=r,Ov}var Dv,ij;function fU(){if(ij)return Dv;ij=1;function e(n,r,a){for(var o=-1,l=n.length,c=r.length,d={};++o0;--C)if(w=g[C].dequeue(),w){m=m.concat(c(h,g,y,w,!0));break}}}return m}function c(h,g,y,m,b){var S=b?[]:void 0;return e.forEach(h.inEdges(m.v),function(w){var C=h.edge(w),_=h.node(w.v);b&&S.push({v:w.v,w:w.w}),_.out-=C,p(g,y,_)}),e.forEach(h.outEdges(m.v),function(w){var C=h.edge(w),_=w.w,j=h.node(_);j.in-=C,p(g,y,j)}),h.removeNode(m.v),S}function d(h,g){var y=new n,m=0,b=0;e.forEach(h.nodes(),function(C){y.setNode(C,{v:C,in:0,out:0})}),e.forEach(h.edges(),function(C){var _=y.edge(C.v,C.w)||0,j=g(C),k=_+j;y.setEdge(C.v,C.w,k),b=Math.max(b,y.node(C.v).out+=j),m=Math.max(m,y.node(C.w).in+=j)});var S=e.range(b+m+3).map(function(){return new r}),w=m+1;return e.forEach(y.nodes(),function(C){p(S,w,y.node(C))}),{graph:y,buckets:S,zeroIdx:w}}function p(h,g,y){y.out?y.in?h[y.out-y.in+g].enqueue(y):h[h.length-1].enqueue(y):h[0].enqueue(y)}return Bv}var Hv,cj;function yU(){if(cj)return Hv;cj=1;var e=it(),n=gU();Hv={run:r,undo:o};function r(l){var c=l.graph().acyclicer==="greedy"?n(l,d(l)):a(l);e.forEach(c,function(p){var h=l.edge(p);l.removeEdge(p),h.forwardName=p.name,h.reversed=!0,l.setEdge(p.w,p.v,h,e.uniqueId("rev"))});function d(p){return function(h){return p.edge(h).weight}}}function a(l){var c=[],d={},p={};function h(g){e.has(p,g)||(p[g]=!0,d[g]=!0,e.forEach(l.outEdges(g),function(y){e.has(d,y.w)?c.push(y):h(y.w)}),delete d[g])}return e.forEach(l.nodes(),h),c}function o(l){e.forEach(l.edges(),function(c){var d=l.edge(c);if(d.reversed){l.removeEdge(c);var p=d.forwardName;delete d.reversed,delete d.forwardName,l.setEdge(c.w,c.v,d,p)}})}return Hv}var Uv,uj;function tn(){if(uj)return Uv;uj=1;var e=it(),n=Nn().Graph;Uv={addDummyNode:r,simplify:a,asNonCompoundGraph:o,successorWeights:l,predecessorWeights:c,intersectRect:d,buildLayerMatrix:p,normalizeRanks:h,removeEmptyRanks:g,addBorderNode:y,maxRank:m,partition:b,time:S,notime:w};function r(C,_,j,k){var T;do T=e.uniqueId(k);while(C.hasNode(T));return j.dummy=_,C.setNode(T,j),T}function a(C){var _=new n().setGraph(C.graph());return e.forEach(C.nodes(),function(j){_.setNode(j,C.node(j))}),e.forEach(C.edges(),function(j){var k=_.edge(j.v,j.w)||{weight:0,minlen:1},T=C.edge(j);_.setEdge(j.v,j.w,{weight:k.weight+T.weight,minlen:Math.max(k.minlen,T.minlen)})}),_}function o(C){var _=new n({multigraph:C.isMultigraph()}).setGraph(C.graph());return e.forEach(C.nodes(),function(j){C.children(j).length||_.setNode(j,C.node(j))}),e.forEach(C.edges(),function(j){_.setEdge(j,C.edge(j))}),_}function l(C){var _=e.map(C.nodes(),function(j){var k={};return e.forEach(C.outEdges(j),function(T){k[T.w]=(k[T.w]||0)+C.edge(T).weight}),k});return e.zipObject(C.nodes(),_)}function c(C){var _=e.map(C.nodes(),function(j){var k={};return e.forEach(C.inEdges(j),function(T){k[T.v]=(k[T.v]||0)+C.edge(T).weight}),k});return e.zipObject(C.nodes(),_)}function d(C,_){var j=C.x,k=C.y,T=_.x-j,E=_.y-k,z=C.width/2,A=C.height/2;if(!T&&!E)throw new Error("Not possible to find intersection inside of the rectangle");var M,O;return Math.abs(E)*z>Math.abs(T)*A?(E<0&&(A=-A),M=A*T/E,O=A):(T<0&&(z=-z),M=z,O=z*E/T),{x:j+M,y:k+O}}function p(C){var _=e.map(e.range(m(C)+1),function(){return[]});return e.forEach(C.nodes(),function(j){var k=C.node(j),T=k.rank;e.isUndefined(T)||(_[T][k.order]=j)}),_}function h(C){var _=e.min(e.map(C.nodes(),function(j){return C.node(j).rank}));e.forEach(C.nodes(),function(j){var k=C.node(j);e.has(k,"rank")&&(k.rank-=_)})}function g(C){var _=e.min(e.map(C.nodes(),function(E){return C.node(E).rank})),j=[];e.forEach(C.nodes(),function(E){var z=C.node(E).rank-_;j[z]||(j[z]=[]),j[z].push(E)});var k=0,T=C.graph().nodeRankFactor;e.forEach(j,function(E,z){e.isUndefined(E)&&z%T!==0?--k:k&&e.forEach(E,function(A){C.node(A).rank+=k})})}function y(C,_,j,k){var T={width:0,height:0};return arguments.length>=4&&(T.rank=j,T.order=k),r(C,"border",T,_)}function m(C){return e.max(e.map(C.nodes(),function(_){var j=C.node(_).rank;if(!e.isUndefined(j))return j}))}function b(C,_){var j={lhs:[],rhs:[]};return e.forEach(C,function(k){_(k)?j.lhs.push(k):j.rhs.push(k)}),j}function S(C,_){var j=e.now();try{return _()}finally{console.log(C+" time: "+(e.now()-j)+"ms")}}function w(C,_){return _()}return Uv}var Fv,dj;function mU(){if(dj)return Fv;dj=1;var e=it(),n=tn();Fv={run:r,undo:o};function r(l){l.graph().dummyChains=[],e.forEach(l.edges(),function(c){a(l,c)})}function a(l,c){var d=c.v,p=l.node(d).rank,h=c.w,g=l.node(h).rank,y=c.name,m=l.edge(c),b=m.labelRank;if(g!==p+1){l.removeEdge(c);var S,w,C;for(C=0,++p;pO.lim&&(P=O,L=!0);var I=e.filter(T.edges(),function(F){return L===j(k,k.node(F.v),P)&&L!==j(k,k.node(F.w),P)});return e.minBy(I,function(F){return r(T,F)})}function w(k,T,E,z){var A=E.v,M=E.w;k.removeEdge(A,M),k.setEdge(z.v,z.w,{}),y(k),p(k,T),C(k,T)}function C(k,T){var E=e.find(k.nodes(),function(A){return!T.node(A).parent}),z=o(k,E);z=z.slice(1),e.forEach(z,function(A){var M=k.node(A).parent,O=T.edge(A,M),P=!1;O||(O=T.edge(M,A),P=!0),T.node(A).rank=T.node(M).rank+(P?O.minlen:-O.minlen)})}function _(k,T,E){return k.hasEdge(T,E)}function j(k,T,E){return E.low<=T.lim&&T.lim<=E.lim}return Vv}var Wv,gj;function bU(){if(gj)return Wv;gj=1;var e=Tu(),n=e.longestPath,r=sA(),a=vU();Wv=o;function o(p){switch(p.graph().ranker){case"network-simplex":d(p);break;case"tight-tree":c(p);break;case"longest-path":l(p);break;default:d(p)}}var l=n;function c(p){n(p),r(p)}function d(p){a(p)}return Wv}var Gv,yj;function xU(){if(yj)return Gv;yj=1;var e=it();Gv=n;function n(o){var l=a(o);e.forEach(o.graph().dummyChains,function(c){for(var d=o.node(c),p=d.edgeObj,h=r(o,l,p.v,p.w),g=h.path,y=h.lca,m=0,b=g[m],S=!0;c!==p.w;){if(d=o.node(c),S){for(;(b=g[m])!==y&&o.node(b).maxRankg||y>l[m].lim));for(b=m,m=d;(m=o.parent(m))!==b;)h.push(m);return{path:p.concat(h.reverse()),lca:b}}function a(o){var l={},c=0;function d(p){var h=c;e.forEach(o.children(p),d),l[p]={low:h,lim:c++}}return e.forEach(o.children(),d),l}return Gv}var Yv,mj;function SU(){if(mj)return Yv;mj=1;var e=it(),n=tn();Yv={run:r,cleanup:c};function r(d){var p=n.addDummyNode(d,"root",{},"_root"),h=o(d),g=e.max(e.values(h))-1,y=2*g+1;d.graph().nestingRoot=p,e.forEach(d.edges(),function(b){d.edge(b).minlen*=y});var m=l(d)+1;e.forEach(d.children(),function(b){a(d,p,y,m,g,h,b)}),d.graph().nodeRankFactor=y}function a(d,p,h,g,y,m,b){var S=d.children(b);if(!S.length){b!==p&&d.setEdge(p,b,{weight:0,minlen:h});return}var w=n.addBorderNode(d,"_bt"),C=n.addBorderNode(d,"_bb"),_=d.node(b);d.setParent(w,b),_.borderTop=w,d.setParent(C,b),_.borderBottom=C,e.forEach(S,function(j){a(d,p,h,g,y,m,j);var k=d.node(j),T=k.borderTop?k.borderTop:j,E=k.borderBottom?k.borderBottom:j,z=k.borderTop?g:2*g,A=T!==E?1:y-m[b]+1;d.setEdge(w,T,{weight:z,minlen:A,nestingEdge:!0}),d.setEdge(E,C,{weight:z,minlen:A,nestingEdge:!0})}),d.parent(b)||d.setEdge(p,w,{weight:0,minlen:y+m[b]})}function o(d){var p={};function h(g,y){var m=d.children(g);m&&m.length&&e.forEach(m,function(b){h(b,y+1)}),p[g]=y}return e.forEach(d.children(),function(g){h(g,1)}),p}function l(d){return e.reduce(d.edges(),function(p,h){return p+d.edge(h).weight},0)}function c(d){var p=d.graph();d.removeNode(p.nestingRoot),delete p.nestingRoot,e.forEach(d.edges(),function(h){var g=d.edge(h);g.nestingEdge&&d.removeEdge(h)})}return Yv}var Xv,vj;function wU(){if(vj)return Xv;vj=1;var e=it(),n=tn();Xv=r;function r(o){function l(c){var d=o.children(c),p=o.node(c);if(d.length&&e.forEach(d,l),e.has(p,"minRank")){p.borderLeft=[],p.borderRight=[];for(var h=p.minRank,g=p.maxRank+1;h0;)b%2&&(S+=g[b+1]),b=b-1>>1,g[b]+=m.weight;y+=m.weight*S})),y}return Qv}var Jv,wj;function EU(){if(wj)return Jv;wj=1;var e=it();Jv=n;function n(r,a){return e.map(a,function(o){var l=r.inEdges(o);if(l.length){var c=e.reduce(l,function(d,p){var h=r.edge(p),g=r.node(p.v);return{sum:d.sum+h.weight*g.order,weight:d.weight+h.weight}},{sum:0,weight:0});return{v:o,barycenter:c.sum/c.weight,weight:c.weight}}else return{v:o}})}return Jv}var e0,_j;function jU(){if(_j)return e0;_j=1;var e=it();e0=n;function n(o,l){var c={};e.forEach(o,function(p,h){var g=c[p.v]={indegree:0,in:[],out:[],vs:[p.v],i:h};e.isUndefined(p.barycenter)||(g.barycenter=p.barycenter,g.weight=p.weight)}),e.forEach(l.edges(),function(p){var h=c[p.v],g=c[p.w];!e.isUndefined(h)&&!e.isUndefined(g)&&(g.indegree++,h.out.push(c[p.w]))});var d=e.filter(c,function(p){return!p.indegree});return r(d)}function r(o){var l=[];function c(h){return function(g){g.merged||(e.isUndefined(g.barycenter)||e.isUndefined(h.barycenter)||g.barycenter>=h.barycenter)&&a(h,g)}}function d(h){return function(g){g.in.push(h),--g.indegree===0&&o.push(g)}}for(;o.length;){var p=o.pop();l.push(p),e.forEach(p.in.reverse(),c(p)),e.forEach(p.out,d(p))}return e.map(e.filter(l,function(h){return!h.merged}),function(h){return e.pick(h,["vs","i","barycenter","weight"])})}function a(o,l){var c=0,d=0;o.weight&&(c+=o.barycenter*o.weight,d+=o.weight),l.weight&&(c+=l.barycenter*l.weight,d+=l.weight),o.vs=l.vs.concat(o.vs),o.barycenter=c/d,o.weight=d,o.i=Math.min(l.i,o.i),l.merged=!0}return e0}var t0,kj;function TU(){if(kj)return t0;kj=1;var e=it(),n=tn();t0=r;function r(l,c){var d=n.partition(l,function(w){return e.has(w,"barycenter")}),p=d.lhs,h=e.sortBy(d.rhs,function(w){return-w.i}),g=[],y=0,m=0,b=0;p.sort(o(!!c)),b=a(g,h,b),e.forEach(p,function(w){b+=w.vs.length,g.push(w.vs),y+=w.barycenter*w.weight,m+=w.weight,b=a(g,h,b)});var S={vs:e.flatten(g,!0)};return m&&(S.barycenter=y/m,S.weight=m),S}function a(l,c,d){for(var p;c.length&&(p=e.last(c)).i<=d;)c.pop(),l.push(p.vs),d++;return d}function o(l){return function(c,d){return c.barycenterd.barycenter?1:l?d.i-c.i:c.i-d.i}}return t0}var n0,Cj;function AU(){if(Cj)return n0;Cj=1;var e=it(),n=EU(),r=jU(),a=TU();n0=o;function o(d,p,h,g){var y=d.children(p),m=d.node(p),b=m?m.borderLeft:void 0,S=m?m.borderRight:void 0,w={};b&&(y=e.filter(y,function(E){return E!==b&&E!==S}));var C=n(d,y);e.forEach(C,function(E){if(d.children(E.v).length){var z=o(d,E.v,h,g);w[E.v]=z,e.has(z,"barycenter")&&c(E,z)}});var _=r(C,h);l(_,w);var j=a(_,g);if(b&&(j.vs=e.flatten([b,j.vs,S],!0),d.predecessors(b).length)){var k=d.node(d.predecessors(b)[0]),T=d.node(d.predecessors(S)[0]);e.has(j,"barycenter")||(j.barycenter=0,j.weight=0),j.barycenter=(j.barycenter*j.weight+k.order+T.order)/(j.weight+2),j.weight+=2}return j}function l(d,p){e.forEach(d,function(h){h.vs=e.flatten(h.vs.map(function(g){return p[g]?p[g].vs:g}),!0)})}function c(d,p){e.isUndefined(d.barycenter)?(d.barycenter=p.barycenter,d.weight=p.weight):(d.barycenter=(d.barycenter*d.weight+p.barycenter*p.weight)/(d.weight+p.weight),d.weight+=p.weight)}return n0}var r0,Ej;function RU(){if(Ej)return r0;Ej=1;var e=it(),n=Nn().Graph;r0=r;function r(o,l,c){var d=a(o),p=new n({compound:!0}).setGraph({root:d}).setDefaultNodeLabel(function(h){return o.node(h)});return e.forEach(o.nodes(),function(h){var g=o.node(h),y=o.parent(h);(g.rank===l||g.minRank<=l&&l<=g.maxRank)&&(p.setNode(h),p.setParent(h,y||d),e.forEach(o[c](h),function(m){var b=m.v===h?m.w:m.v,S=p.edge(b,h),w=e.isUndefined(S)?0:S.weight;p.setEdge(b,h,{weight:o.edge(m).weight+w})}),e.has(g,"minRank")&&p.setNode(h,{borderLeft:g.borderLeft[l],borderRight:g.borderRight[l]}))}),p}function a(o){for(var l;o.hasNode(l=e.uniqueId("_root")););return l}return r0}var i0,jj;function zU(){if(jj)return i0;jj=1;var e=it();i0=n;function n(r,a,o){var l={},c;e.forEach(o,function(d){for(var p=r.parent(d),h,g;p;){if(h=r.parent(p),h?(g=l[h],l[h]=p):(g=c,c=p),g&&g!==p){a.setEdge(g,p);return}p=h}})}return i0}var a0,Tj;function NU(){if(Tj)return a0;Tj=1;var e=it(),n=kU(),r=CU(),a=AU(),o=RU(),l=zU(),c=Nn().Graph,d=tn();a0=p;function p(m){var b=d.maxRank(m),S=h(m,e.range(1,b+1),"inEdges"),w=h(m,e.range(b-1,-1,-1),"outEdges"),C=n(m);y(m,C);for(var _=Number.POSITIVE_INFINITY,j,k=0,T=0;T<4;++k,++T){g(k%2?S:w,k%4>=2),C=d.buildLayerMatrix(m);var E=r(m,C);E<_&&(T=0,j=e.cloneDeep(C),_=E)}y(m,j)}function h(m,b,S){return e.map(b,function(w){return o(m,w,S)})}function g(m,b){var S=new c;e.forEach(m,function(w){var C=w.graph().root,_=a(w,C,S,b);e.forEach(_.vs,function(j,k){w.node(j).order=k}),l(w,S,_.vs)})}function y(m,b){e.forEach(b,function(S){e.forEach(S,function(w,C){m.node(w).order=C})})}return a0}var o0,Aj;function MU(){if(Aj)return o0;Aj=1;var e=it(),n=Nn().Graph,r=tn();o0={positionX:S,findType1Conflicts:a,findType2Conflicts:o,addConflict:c,hasConflict:d,verticalAlignment:p,horizontalCompaction:h,alignCoordinates:m,findSmallestWidthAlignment:y,balance:b};function a(_,j){var k={};function T(E,z){var A=0,M=0,O=E.length,P=e.last(z);return e.forEach(z,function(L,I){var F=l(_,L),U=F?_.node(F).order:O;(F||L===P)&&(e.forEach(z.slice(M,I+1),function(B){e.forEach(_.predecessors(B),function(D){var q=_.node(D),$=q.order;($P)&&c(k,F,L)})})}function E(z,A){var M=-1,O,P=0;return e.forEach(A,function(L,I){if(_.node(L).dummy==="border"){var F=_.predecessors(L);F.length&&(O=_.node(F[0]).order,T(A,P,I,M,O),P=I,M=O)}T(A,P,A.length,O,z.length)}),A}return e.reduce(j,E),k}function l(_,j){if(_.node(j).dummy)return e.find(_.predecessors(j),function(k){return _.node(k).dummy})}function c(_,j,k){if(j>k){var T=j;j=k,k=T}var E=_[j];E||(_[j]=E={}),E[k]=!0}function d(_,j,k){if(j>k){var T=j;j=k,k=T}return e.has(_[j],k)}function p(_,j,k,T){var E={},z={},A={};return e.forEach(j,function(M){e.forEach(M,function(O,P){E[O]=O,z[O]=O,A[O]=P})}),e.forEach(j,function(M){var O=-1;e.forEach(M,function(P){var L=T(P);if(L.length){L=e.sortBy(L,function(D){return A[D]});for(var I=(L.length-1)/2,F=Math.floor(I),U=Math.ceil(I);F<=U;++F){var B=L[F];z[P]===P&&O({}));const a=new Set(e.map(o=>o.id));for(const o of e)r.setNode(o.id,{width:qj,height:Ij});for(const o of n)a.has(o.source)&&a.has(o.target)&&r.setEdge(o.source,o.target);return Dj.layout(r),e.map(o=>{const l=r.node(o.id);return l?{...o,position:{x:l.x-qj/2,y:l.y-Ij/2}}:o})}function Lj(){const e=vt.getState();return e.loaded?e.moduleTypeMap:Vu}function Os(e,n,r,a,o,l){const c=`e-${r}-${e}-${n}${o?`-${o}`:""}`,d={edgeType:r,label:a,...l!==void 0?{chainOrder:l}:{}},p={id:c,source:e,target:n,data:d};return o&&(p.sourceHandle=o),a&&(p.label=a,p.labelBgStyle={fill:"#1e1e2e",fillOpacity:.9}),p}function FU(e,n){const r=[],a=new Set;function o(l,c,d,p,h){const g=`${l}->${c}:${d}`;a.has(g)||(a.add(g),r.push(Os(l,c,d,p,void 0,h)))}for(const[,l]of Object.entries(e)){const c=l;if(!(!c||typeof c!="object")){if("router"in c&&"routes"in c){const d=c,p=d.server?n[d.server]:void 0,h=n[d.router];if(p&&h&&o(p,h,"http-route","http"),d.routes&&h)for(const g of d.routes){const y=n[g.handler];if(g.middlewares&&g.middlewares.length>0){const m=g.middlewares.map(b=>n[b]).filter(b=>!!b);if(m.length>0){const b=m.length;o(h,m[0],"middleware-chain","middleware",1);for(let S=0;S0&&r.set(h,g)}return r}function $U(e,n){const r=e.filter(_=>!_.data.synthesized),a=[],o=[],l=[],c=[],d=[],p=[];for(const _ of n)switch(_.data?.edgeType??"dependency"){case"http-route":o.push(_);break;case"messaging-subscription":l.push(_);break;case"conditional":c.push(_);break;case"middleware-chain":d.push(_);break;case"pipeline-flow":p.push(_);break;case"auto-wire":break;default:a.push(_);break}const h=PU(p,e),g=new Set;for(const _ of h.values())for(const j of _)g.add(j.id);const y={},m={};for(const _ of r)m[_.id]=_.data.label;for(const _ of c){const j=r.find(T=>T.id===_.source);if(!j||j.data.synthesized)continue;y[_.source]||(y[_.source]={});const k=_.sourceHandle??_.data?.label??"default";y[_.source][k]=m[_.target]??_.target}const b={};for(const _ of a){b[_.target]||(b[_.target]=[]);const j=r.find(k=>k.id===_.source);j&&b[_.target].push(j.data.label)}const S=r.filter(_=>!g.has(_.id)).map(_=>{const j={name:_.data.label,type:_.data.moduleType};_.data.config&&Object.keys(_.data.config).length>0&&(j.config={..._.data.config});const k=b[_.id];k&&k.length>0&&(j.dependsOn=k);const T=y[_.id];return T&&Object.keys(T).length>0&&(j.branches=T),j.ui_position={x:Math.round(_.position.x),y:Math.round(_.position.y)},j}),w={};if(o.length>0||d.length>0){const _={};for(const T of e)_[T.id]=T.data.label;const j=o.find(T=>T.data?.label==="http"),k=o.filter(T=>T.data?.label!=="http"&&T.data?.label!=="middleware");if(j){const T={server:_[j.source],router:_[j.target]},E=[];for(const O of k){const L=(O.data?.label??"GET /").split(" ",2);E.push({method:L[0],path:L[1]??"/",handler:_[O.target]})}if(d.length>0){const O=j.target,P=d.filter(L=>L.source===O);for(const L of P){const F=(L.data?.label??"").match(/^(\S+)\s+(\S+)/),U=F?.[1]??"GET",B=F?.[2]??"/",D=[];let q=L.target;const $=new Set;for(;q&&!$.has(q);){$.add(q);const K=_[q];e.find(ee=>ee.id===q)?.data.moduleType?.startsWith("http.middleware.")&&K&&D.push(K);const W=d.find(ee=>ee.source===q&&ee.id!==L.id);if(W){const ee=e.find(X=>X.id===W.target);if(!ee?.data.moduleType?.startsWith("http.middleware.")&&ee){E.push({method:U,path:B,handler:_[W.target],...D.length>0?{middlewares:D}:{}});break}q=W.target}else{D.length>0&&E.push({method:U,path:B,handler:"",middlewares:D});break}}}}const z=[],A=new Set;for(const O of e){const P=O.data.handlerRoutes;if(P&&P.length>0){A.add(O.data.label);for(const L of P){const I={method:L.method,path:L.path,handler:O.data.label};L.middlewares&&L.middlewares.length>0&&(I.middlewares=L.middlewares),L.pipeline&&L.pipeline.steps.length>0&&(I.pipeline=L.pipeline),z.push(I)}}}for(const O of e){const P=h.get(O.id);if(!P||P.length===0)continue;const L=P.map(F=>({name:F.data.label,type:F.data.moduleType.replace("step.",""),...F.data.config&&Object.keys(F.data.config).length>0?{config:F.data.config}:{}})),I=z.filter(F=>F.handler===O.data.label);if(I.length>0)for(const F of I)F.pipeline={steps:L};else{const F=E.filter(U=>U.handler===O.data.label);if(F.length>0){A.add(O.data.label);for(const U of F)z.push({...U,pipeline:{steps:L}})}}}const M=[...E.filter(O=>!A.has(O.handler)),...z];M.length>0&&(T.routes=M),w.http=T}}if(l.length>0){const _={};for(const T of e)_[T.id]=T.data.label;const j=l[0].source,k={broker:_[j],subscriptions:l.map(T=>{const E=T.data?.label??"";return{topic:E.startsWith("topic: ")?E.slice(7):E,handler:_[T.target]}})};w.messaging=k}return{modules:S,workflows:w,triggers:{}}}function VU(e){const n=[],r=[],a={};let o=!1;e.modules.forEach((S,w)=>{const C=`${S.type.replace(/\./g,"_")}_${w+1}`;a[S.name]=C;const _=Lj()[S.type],j=S.ui_position;j&&(o=!0),n.push({id:C,type:W0(S.type),position:j?{x:j.x,y:j.y}:{x:0,y:0},data:{moduleType:S.type,label:S.name,config:S.config??(_?{..._.defaultConfig}:{})}})}),e.modules.forEach(S=>{if(S.dependsOn){const w=a[S.name];for(const C of S.dependsOn){const _=a[C];_&&w&&r.push(Os(_,w,"dependency",C))}}}),e.modules.forEach(S=>{if(S.branches){const w=a[S.name];if(!w)return;for(const[C,_]of Object.entries(S.branches)){const j=a[_];j&&r.push(Os(w,j,"conditional",C,C))}}});const l={};for(const[,S]of Object.entries(e.workflows)){const w=S;if(!(!w||typeof w!="object")&&"router"in w&&"routes"in w){const C=w;if(C.routes)for(const _ of C.routes){l[_.handler]||(l[_.handler]=[]);const j={method:_.method,path:_.path};if(_.middlewares&&_.middlewares.length>0&&(j.middlewares=_.middlewares),_.pipeline){const k=_.pipeline;k.steps&&k.steps.length>0&&(j.pipeline={steps:k.steps})}l[_.handler].push(j)}}}const c={};for(const[,S]of Object.entries(e.workflows)){const w=S;if(!(!w||typeof w!="object")&&"router"in w&&"routes"in w){const C=w,_=C.router;if(!_)continue;const j=new Set(c[_]??[]);if(C.routes){for(const k of C.routes)if(k.middlewares)for(const T of k.middlewares)j.has(T)||(j.add(T),c[_]||(c[_]=[]),c[_].push(T))}}}for(const S of n){const w=l[S.data.label];w&&w.length>0&&(S.data.handlerRoutes=w);const C=c[S.data.label];C&&C.length>0&&(S.data.config={...S.data.config,middlewareChain:C})}const d=new Set(["api.query","api.command"]);let p=0;for(const S of n){if(!d.has(S.data.moduleType))continue;const w=l[S.data.label];if(w)for(const C of w){const _=C;if(!_.pipeline?.steps||_.pipeline.steps.length===0)continue;let j=S.id;for(let k=0;k<_.pipeline.steps.length;k++){const T=_.pipeline.steps[k];p++;const E=T.type.startsWith("step.")?T.type:`step.${T.type}`,z=`pipeline_step_${p}`,A=Lj()[E],M={id:z,type:W0(E),position:{x:S.position.x+250,y:S.position.y+(k+1)*100},data:{moduleType:E,label:T.name,config:T.config??(A?{...A.defaultConfig}:{})}};n.push(M),r.push(Os(j,z,"pipeline-flow",void 0,void 0,k+1)),j=z}}}const h=FU(e.workflows,a),g=new Set(r.map(S=>`${S.source}->${S.target}`));for(const S of h){const w=`${S.source}->${S.target}`;g.has(w)||(r.push(S),g.add(w))}const y=new Set(["health.checker","metrics.collector","log.collector"]),m=new Set(["http.router"]),b=e.modules.find(S=>m.has(S.type));if(b){const S=a[b.name];if(S){for(const w of e.modules)if(y.has(w.type)){const C=a[w.name];if(C){const _=`${C}->${S}`;g.has(_)||(r.push(Os(C,S,"auto-wire","auto-wired")),g.add(_))}}}}if(!o){const S=lA(n,r);for(let w=0;w{o[w.id]=b,a.push({...w,position:{x:20,y:c+C*(d+20)},parentId:b,extent:"parent"})}),p+=l+60}const h=new Set,g=[];for(const y of n){const m=o[y.source],b=o[y.target];if(!(!m||!b))if(m===b)g.push(y);else{const S=`${m}->${b}`;h.has(S)||(h.add(S),g.push({id:`ge-${m}-${b}`,source:m,target:b,style:{stroke:"#585b70",strokeWidth:3},animated:!0}))}}return{nodes:a,edges:g}}function GU(e,n){const r=new Set;for(const b of n)r.add(b.source),r.add(b.target);const a=e.filter(b=>!r.has(b.id)&&b.type!=="groupNode"&&!b.parentId);if(a.length===0)return{nodes:e,edges:n};const o={observability:"Monitoring",infrastructure:"Infrastructure",events:"Events"},l={};for(const b of a){const w=cA()[b.data.moduleType]?.category||"infrastructure";l[w]||(l[w]=[]),l[w].push(b)}const c=new Set(a.map(b=>b.id)),d=e.filter(b=>!c.has(b.id)),p=320,h=50,g=80;let y=0;for(const b of e)b.position.x>y&&(y=b.position.x);let m=y+400;for(const[b,S]of Object.entries(l)){if(S.length<2){d.push(...S);continue}const w=`autogroup-${b}`,C=h+S.length*(g+20)+20,_=Wn[b]||"#64748b";d.push({id:w,type:"groupNode",position:{x:m,y:50},data:{label:o[b]||b.charAt(0).toUpperCase()+b.slice(1),category:b,childCount:S.length,collapsed:!1,moduleType:"group",config:{}},style:{width:p,height:C,background:`${_}10`}}),S.forEach((j,k)=>{d.push({...j,position:{x:20,y:h+k*(g+20)},parentId:w,extent:"parent"})}),m+=p+60}return{nodes:d,edges:n}}const YU={"http.Request":["any","PipelineContext"],"http.Response":["any","JSON","[]byte"],JSON:["any","[]byte","string"],"[]byte":["any","string"],Event:["any","[]byte","JSON"],CloudEvent:["any","Event","[]byte","JSON"],Transition:["any","Event"],State:["any"],string:["any"],boolean:["any"],Token:["any","string"],Credentials:["any"],Time:["any","Event"],SQL:["any","string"],Rows:["any","JSON"],HealthStatus:["any","JSON"],"Metric[]":["any"],LogEntry:["any","JSON"],"LogEntry[]":["any"],"[]LogEntry":["any"],"Span[]":["any"],Command:["any","PipelineContext"],RouteConfig:["any","JSON"],OpenAPISpec:["any","JSON"],SlackResponse:["any","JSON"],SQLiteStorage:["any","sql.DB"],"func()":["any"],PipelineContext:["any","StepResult","PipelineContext"],StepResult:["any","PipelineContext","StepResult"],"prometheus.Metrics":["any"],"net.Listener":["any"],Scheduler:["any"],AuthService:["any"],EventBus:["any"],Cache:["any"],"http.Client":["any"],"sql.DB":["any"],SchemaValidator:["any"],StorageProvider:["any"],SecretProvider:["any"],PersistenceStore:["any"],WorkflowRegistry:["any"],ExternalAPIClient:["any"],FileStore:["any","StorageProvider"],ObjectStore:["any","StorageProvider"],UserStore:["any"],"trace.Span":["any"],"trace.Tracer":["any"]};function go(e,n){if(e===n||e==="any"||n==="any")return!0;const r=YU[e];return!!(r&&r.includes(n))}function uA(e){return e.ioSignature?e.ioSignature.outputs.map(n=>n.type):[]}function dA(e){return e.ioSignature?e.ioSignature.inputs.map(n=>n.type):[]}function XU(e,n){return n.filter(r=>{const a=dA(r);return a.length===0?!1:a.some(o=>go(e,o))})}function KU(e,n){return n.filter(r=>{const a=uA(r);return a.length===0?!1:a.some(o=>go(o,e))})}function ZU(e,n,r,a,o){const l=[];for(const c of a){if(c.id===e)continue;const d=o[c.data.moduleType];if(!d?.ioSignature)continue;let p=!1;r==="source"?p=d.ioSignature.inputs.some(g=>n.some(y=>go(y,g.type))):p=d.ioSignature.outputs.some(g=>n.some(y=>go(g.type,y))),p&&l.push(c.id)}return l}function QU(e,n){const r=e.startsWith("step."),a=n.startsWith("step.");return r&&a||(e==="api.query"||e==="api.command")&&a}function fA(e,n){return n.filter(r=>r.target===e).length}function pA(e,n){return n.filter(r=>r.source===e).length}function G0(e,n,r,a){const l=r[a]?.maxIncoming;return l==null?!0:l===0?!1:fA(e,n)({nodes:[],edges:[],selectedNodeId:null,selectedEdgeId:null,nodeCounter:0,importedWorkflows:{},importedTriggers:{},importedPipelines:{},activeWorkflowRecord:null,setActiveWorkflowRecord:r=>e({activeWorkflowRecord:r}),tabs:[Hj("default","Workflow 1")],activeTabId:"default",crossWorkflowLinks:[],toasts:[],addToast:(r,a)=>{const o=`toast-${++JU}`;e({toasts:[...n().toasts,{id:o,message:r,type:a}]})},removeToast:r=>{e({toasts:n().toasts.filter(a=>a.id!==r)})},undoStack:[],redoStack:[],pushHistory:()=>{const{nodes:r,edges:a,undoStack:o}=n(),l={nodes:JSON.parse(JSON.stringify(r)),edges:JSON.parse(JSON.stringify(a))};e({undoStack:[...o.slice(-49),l],redoStack:[]})},undo:()=>{const{undoStack:r,nodes:a,edges:o}=n();if(r.length===0)return;const l=r[r.length-1];e({undoStack:r.slice(0,-1),redoStack:[...n().redoStack,{nodes:JSON.parse(JSON.stringify(a)),edges:JSON.parse(JSON.stringify(o))}],nodes:l.nodes,edges:l.edges})},redo:()=>{const{redoStack:r,nodes:a,edges:o}=n();if(r.length===0)return;const l=r[r.length-1];e({redoStack:r.slice(0,-1),undoStack:[...n().undoStack,{nodes:JSON.parse(JSON.stringify(a)),edges:JSON.parse(JSON.stringify(o))}],nodes:l.nodes,edges:l.edges})},viewLevel:"component",setViewLevel:r=>e({viewLevel:r}),showAIPanel:!1,showComponentBrowser:!1,toggleAIPanel:()=>e({showAIPanel:!n().showAIPanel}),toggleComponentBrowser:()=>e({showComponentBrowser:!n().showComponentBrowser}),onNodesChange:r=>{e({nodes:vb(r,n().nodes)})},onEdgesChange:r=>{e({edges:$6(r,n().edges)})},onConnect:r=>{n().pushHistory();const{source:a,target:o}=r,l=n().nodes,c=l.find(p=>p.id===a),d=l.find(p=>p.id===o);if(c&&d&&QU(c.data.moduleType,d.data.moduleType)){const h=n().edges.filter(m=>m.data?.edgeType==="pipeline-flow").length+1,y={id:`e-pipeline-flow-${a}-${o}`,source:a,target:o,sourceHandle:r.sourceHandle??void 0,targetHandle:r.targetHandle??void 0,data:{edgeType:"pipeline-flow",chainOrder:h}};e({edges:[...n().edges,y]})}else e({edges:C6(r,n().edges)})},setSelectedNode:r=>e({selectedNodeId:r,selectedEdgeId:null}),setSelectedEdge:r=>e({selectedEdgeId:r,selectedNodeId:null}),removeEdge:r=>{n().pushHistory(),e({edges:n().edges.filter(a=>a.id!==r),selectedEdgeId:n().selectedEdgeId===r?null:n().selectedEdgeId})},addNode:(r,a)=>{const l=vt.getState().moduleTypeMap[r]??Vu[r];if(!l)return;n().pushHistory();const c=n().nodeCounter+1,p={id:`${r.replace(/\./g,"_")}_${c}`,type:W0(r),position:a,data:{moduleType:r,label:`${l.label} ${c}`,config:{...l.defaultConfig}}},h=n().nodes;if(e({nodes:[...h,p],nodeCounter:c}),r.startsWith("http.middleware.")){const g=h.filter(y=>y.data.moduleType==="http.router");if(g.length===1){const y=g[0],m=y.data.config?.middlewareChain??[];e({nodes:n().nodes.map(b=>b.id===y.id?{...b,data:{...b.data,config:{...b.data.config,middlewareChain:[...m,p.data.label]}}}:b)})}else if(g.length>1){let y=g[0],m=1/0;for(const S of g){const w=S.position.x-a.x,C=S.position.y-a.y,_=w*w+C*C;_S.id===y.id?{...S,data:{...S.data,config:{...S.data.config,middlewareChain:[...b,p.data.label]}}}:S)}),n().addToast(`Auto-associated "${p.data.label}" with nearest router "${y.data.label}"`,"info")}}},removeNode:r=>{n().pushHistory(),e({nodes:n().nodes.filter(a=>a.id!==r),edges:n().edges.filter(a=>a.source!==r&&a.target!==r),selectedNodeId:n().selectedNodeId===r?null:n().selectedNodeId})},updateNodeConfig:(r,a)=>{n().pushHistory(),e({nodes:n().nodes.map(o=>o.id===r?{...o,data:{...o.data,config:{...o.data.config,...a}}}:o)})},updateNodeName:(r,a)=>{n().pushHistory(),e({nodes:n().nodes.map(o=>o.id===r?{...o,data:{...o.data,label:a}}:o)})},updateHandlerRoutes:(r,a)=>{n().pushHistory(),e({nodes:n().nodes.map(o=>o.id===r?{...o,data:{...o.data,handlerRoutes:a}}:o)})},exportToConfig:()=>{const{nodes:r,edges:a,importedWorkflows:o,importedTriggers:l,importedPipelines:c}=n(),d=$U(r,a);return Object.keys(d.workflows).length===0&&Object.keys(o).length>0&&(d.workflows=o),Object.keys(d.triggers).length===0&&Object.keys(l).length>0&&(d.triggers=l),Object.keys(c).length>0&&(d.pipelines=c),d},importFromConfig:r=>{n().pushHistory();const{nodes:a,edges:o}=VU(r);e({nodes:a,edges:o,selectedNodeId:null,importedWorkflows:r.workflows??{},importedTriggers:r.triggers??{},importedPipelines:r.pipelines??{}})},clearCanvas:()=>{n().pushHistory(),e({nodes:[],edges:[],selectedNodeId:null,selectedEdgeId:null,nodeCounter:0,importedWorkflows:{},importedTriggers:{},importedPipelines:{}})},validationErrors:[],setValidationErrors:r=>e({validationErrors:r}),clearValidationErrors:()=>e({validationErrors:[]}),connectingFrom:null,compatibleNodeIds:[],connectionPicklist:null,setConnectingFrom:r=>e({connectingFrom:r}),setCompatibleNodeIds:r=>e({compatibleNodeIds:r}),showConnectionPicklist:r=>e({connectionPicklist:r}),hideConnectionPicklist:()=>e({connectionPicklist:null,connectingFrom:null,compatibleNodeIds:[]}),snapTargetId:null,setSnapTargetId:r=>e({snapTargetId:r}),addTab:()=>{const{tabs:r,nodes:a,edges:o,undoStack:l,redoStack:c,activeTabId:d}=n();f0++;const p=`tab-${Date.now()}`,h=Hj(p,`Workflow ${f0}`),g=r.map(y=>y.id===d?{...y,nodes:structuredClone(a),edges:structuredClone(o),undoStack:structuredClone(l),redoStack:structuredClone(c)}:y);e({tabs:[...g,h],activeTabId:p,nodes:[],edges:[],undoStack:[],redoStack:[],selectedNodeId:null,selectedEdgeId:null,nodeCounter:0})},closeTab:r=>{const{tabs:a,activeTabId:o}=n();if(a.length<=1)return;const l=a.findIndex(d=>d.id===r),c=a.filter(d=>d.id!==r);if(r===o){const d=c[Math.min(l,c.length-1)];e({tabs:c,activeTabId:d.id,nodes:d.nodes,edges:d.edges,undoStack:d.undoStack,redoStack:d.redoStack,selectedNodeId:null,selectedEdgeId:null})}else e({tabs:c})},switchTab:r=>{const{activeTabId:a,tabs:o,nodes:l,edges:c,undoStack:d,redoStack:p}=n();if(r===a)return;const h=o.map(y=>y.id===a?{...y,nodes:structuredClone(l),edges:structuredClone(c),undoStack:structuredClone(d),redoStack:structuredClone(p)}:y),g=h.find(y=>y.id===r);g&&e({tabs:h,activeTabId:r,nodes:g.nodes,edges:g.edges,undoStack:g.undoStack,redoStack:g.redoStack,selectedNodeId:null,selectedEdgeId:null})},renameTab:(r,a)=>{e({tabs:n().tabs.map(o=>o.id===r?{...o,name:a}:o)})},duplicateTab:r=>{const{tabs:a,nodes:o,edges:l,undoStack:c,redoStack:d,activeTabId:p}=n(),h=a.map(b=>b.id===p?{...b,nodes:structuredClone(o),edges:structuredClone(l),undoStack:structuredClone(c),redoStack:structuredClone(d)}:b),g=h.find(b=>b.id===r);if(!g)return;f0++;const y=`tab-${Date.now()}`,m={...structuredClone(g),id:y,name:`Copy of ${g.name}`};e({tabs:[...h,m],activeTabId:y,nodes:m.nodes,edges:m.edges,undoStack:m.undoStack,redoStack:m.redoStack,selectedNodeId:null})},autoGroupOrphans:()=>{const{nodes:r,edges:a}=n();n().pushHistory();const o=GU(r,a);e({nodes:o.nodes,edges:o.edges})},autoLayout:()=>{const{nodes:r,edges:a}=n();if(r.length===0)return;n().pushHistory();const o=lA(r,a);e({nodes:o})},addCrossWorkflowLink:r=>{e({crossWorkflowLinks:[...n().crossWorkflowLinks,r]})},removeCrossWorkflowLink:r=>{e({crossWorkflowLinks:n().crossWorkflowLinks.filter(a=>a.id!==r)})}}),{name:"workflow-store",partialize:e=>({nodes:e.nodes,edges:e.edges,nodeCounter:e.nodeCounter,importedWorkflows:e.importedWorkflows,importedTriggers:e.importedTriggers,importedPipelines:e.importedPipelines,activeWorkflowRecord:e.activeWorkflowRecord,tabs:e.tabs,activeTabId:e.activeTabId})}));function eF(){const[e,n]=N.useState(Object.fromEntries(B0.map(j=>[j.key,!1]))),[r,a]=N.useState(""),o=ue(j=>j.addNode),l=vt(j=>j.moduleTypes),c=vt(j=>j.fetchSchemas),d=vt(j=>j.loaded);N.useEffect(()=>{d||c()},[d,c]);const p=j=>{n(k=>({...k,[j]:!k[j]}))},h=(j,k)=>{j.dataTransfer.setData("application/workflow-module-type",k),j.dataTransfer.effectAllowed="move"},{getViewport:g}=yo(),y=N.useRef(0),m=N.useRef(0),b=N.useCallback(j=>{const k=Date.now();if(k-y.current<400)return;y.current=k;const T=g(),E=window.innerWidth,z=window.innerHeight,A=(E/2-T.x)/T.zoom,M=(z/2-T.y)/T.zoom,O=m.current++,P=O%4,L=Math.floor(O/4)%4,I=(P-1.5)*60,F=(L-1.5)*50,U={x:Math.round(A+I),y:Math.round(M+F)};o(j,U)},[o,g]),S=(j,k)=>{j.stopPropagation(),j.preventDefault(),b(k)},w=r.toLowerCase(),C=N.useMemo(()=>B0.map(j=>({...j,types:l.filter(k=>k.category!==j.key?!1:w?k.label.toLowerCase().includes(w)||k.type.toLowerCase().includes(w):!0)})),[w,l]),_=j=>{j.stopPropagation()};return u.jsxs("div",{onClick:_,onMouseDown:_,onDoubleClick:_,style:{width:"100%",background:"#181825",overflowY:"auto",height:"100%",padding:"8px 0",position:"relative",zIndex:15,pointerEvents:"auto"},children:[u.jsx("div",{style:{padding:"8px 16px",fontWeight:700,fontSize:14,color:"#cdd6f4",borderBottom:"1px solid #313244",marginBottom:4},children:"Modules"}),u.jsx("div",{style:{padding:"4px 12px 8px"},children:u.jsx("input",{type:"text",placeholder:"Filter modules...",value:r,onChange:j=>a(j.target.value),style:{width:"100%",padding:"6px 8px",fontSize:12,background:"#1e1e2e",border:"1px solid #313244",borderRadius:4,color:"#cdd6f4",outline:"none",boxSizing:"border-box"}})}),C.map(j=>u.jsx("div",{children:j.types.length>0&&u.jsxs(u.Fragment,{children:[u.jsxs("div",{onClick:k=>{k.stopPropagation(),p(j.key)},onMouseDown:k=>k.stopPropagation(),style:{padding:"6px 16px",cursor:"pointer",display:"flex",alignItems:"center",gap:6,color:Wn[j.key],fontSize:12,fontWeight:600,userSelect:"none"},children:[u.jsx("span",{style:{transform:e[j.key]?"rotate(90deg)":"none",transition:"transform 0.15s"},children:"▶"}),j.label,u.jsx("span",{style:{marginLeft:"auto",color:"#585b70",fontSize:11},children:j.types.length})]}),e[j.key]&&j.types.map(k=>u.jsxs("div",{draggable:!0,onDragStart:T=>h(T,k.type),onDoubleClick:T=>S(T,k.type),onClick:T=>T.stopPropagation(),onMouseDown:T=>T.stopPropagation(),title:"Drag to canvas or double-click to add",style:{padding:"5px 16px 5px 28px",cursor:"grab",fontSize:12,color:"#bac2de",display:"flex",alignItems:"center",gap:6,transition:"background 0.1s"},onMouseOver:T=>T.currentTarget.style.background="#313244",onMouseOut:T=>T.currentTarget.style.background="transparent",children:[k.type.startsWith("conditional.")?u.jsx("span",{style:{width:8,height:8,transform:"rotate(45deg)",background:Wn[j.key],flexShrink:0}}):u.jsx("span",{style:{width:8,height:8,borderRadius:"50%",background:Wn[j.key],flexShrink:0}}),k.label]},k.type))]})},j.key))]})}function tF({color:e}){return u.jsx("div",{style:{position:"absolute",bottom:-8,left:"50%",transform:"translateX(-50%)",zIndex:5,pointerEvents:"none"},children:u.jsx("svg",{width:"28",height:"8",viewBox:"0 0 28 8",children:u.jsx("path",{d:"M4,0 L6,8 L22,8 L24,0",fill:e+"40",stroke:e,strokeWidth:1.5})})})}function nF({color:e}){return u.jsx("div",{style:{position:"absolute",top:-8,left:"50%",transform:"translateX(-50%)",zIndex:5,pointerEvents:"none"},children:u.jsx("svg",{width:"28",height:"8",viewBox:"0 0 28 8",children:u.jsx("path",{d:"M4,8 L6,0 L22,0 L24,8",fill:e+"20",stroke:e+"60",strokeWidth:1.5})})})}function Uj({ports:e,direction:n,color:r}){const[a,o]=N.useState(e.length<=2);if(e.length===0)return null;const l=n==="in"?"→":"←";return u.jsx("div",{style:{padding:"2px 0"},children:!a&&e.length>2?u.jsxs("div",{onClick:c=>{c.stopPropagation(),o(!0)},style:{fontSize:9,color:"#585b70",cursor:"pointer",padding:"1px 0"},children:[l," ",e.length," ",n==="in"?"inputs":"outputs"]}):e.map(c=>u.jsxs("div",{style:{display:"flex",alignItems:"center",gap:3,fontSize:9,color:"#585b70",padding:"1px 0"},children:[u.jsx("span",{style:{width:5,height:5,borderRadius:"50%",background:r,opacity:.6,flexShrink:0}}),u.jsx("span",{style:{color:"#a6adc8"},children:c.name}),u.jsx("span",{style:{color:"#45475a"},children:c.type})]},c.name))})}function Ar({id:e,label:n,moduleType:r,icon:a,preview:o,hasInput:l,hasOutput:c,children:d}){const p=ue(W=>W.selectedNodeId),h=ue(W=>W.setSelectedNode),g=ue(W=>W.connectingFrom),y=ue(W=>W.compatibleNodeIds),b=vt(W=>W.moduleTypeMap)[r],S=b?.category??"infrastructure",w=Wn[S],C=p===e,_=b?.ioSignature,j=ue(W=>W.edges),k=l??(b?.maxIncoming!==0&&!r.startsWith("trigger.")),T=c??b?.maxOutgoing!==0,E=N.useMemo(()=>{const W=b?.maxIncoming;return W==null||W===0?!1:fA(e,j)>=W},[b?.maxIncoming,e,j]),z=N.useMemo(()=>{const W=b?.maxOutgoing;return W==null||W===0?!1:pA(e,j)>=W},[b?.maxOutgoing,e,j]),A=ue(W=>r!=="step.delegate"?null:W.nodes.find(G=>G.id===e)?.data?.config?.service||null),M=o??(A?`→ ${A}`:void 0),O=N.useMemo(()=>{if(!r.startsWith("step."))return null;for(const W of j){const ee=W.data;if(ee?.edgeType==="pipeline-flow"&&W.target===e)return ee.chainOrder??null}return null},[r,j,e]),P=ue(W=>W.validationErrors),L=N.useMemo(()=>P.filter(W=>W.nodeId===e),[P,e]),I=L.length>0,F=g!==null,U=g?.nodeId===e,B=F&&!U&&y.includes(e),D=F&&!U&&!y.includes(e),$=ue(W=>W.snapTargetId)===e,K=N.useMemo(()=>{const ee={background:"#1e1e2e",border:`2px solid ${I?"#f38ba8":C?"#fff":w}`,borderRadius:8,padding:0,minWidth:180,fontFamily:"system-ui, sans-serif",fontSize:12,color:"#cdd6f4",boxShadow:I?"0 0 0 2px rgba(243, 139, 168, 0.3), 0 4px 12px rgba(0,0,0,0.4)":C?`0 0 0 2px ${w}40, 0 4px 12px rgba(0,0,0,0.4)`:"0 2px 8px rgba(0,0,0,0.3)",cursor:"pointer",transition:"opacity 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease, filter 0.3s ease"};return $?(ee.border="2px solid #22c55e",ee.boxShadow="0 0 0 3px rgba(34, 197, 94, 0.4), 0 0 20px rgba(34, 197, 94, 0.3)"):U?ee.boxShadow=`0 0 0 2px ${w}60, 0 4px 16px rgba(0,0,0,0.4)`:B?(ee.border="2px solid #22c55e",ee.boxShadow="0 0 0 2px rgba(34, 197, 94, 0.3), 0 0 12px rgba(34, 197, 94, 0.2)"):D&&(ee.opacity=.35,ee.filter="saturate(0.3)"),ee},[C,w,U,B,D,$,I]),ne=N.useMemo(()=>{const W={background:w,width:10,height:10,border:"2px solid #1e1e2e",transition:"width 0.2s ease, height 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease"};return E?(W.opacity=.3,W.background="#585b70"):B&&g?.handleType==="source"&&(W.width=14,W.height=14,W.boxShadow="0 0 8px rgba(34, 197, 94, 0.6)",W.background="#22c55e"),W},[w,B,g?.handleType,E]),V=N.useMemo(()=>{const W={background:w,width:10,height:10,border:"2px solid #1e1e2e",transition:"width 0.2s ease, height 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease"};return z?(W.opacity=.3,W.background="#585b70"):B&&g?.handleType==="target"&&(W.width=14,W.height=14,W.boxShadow="0 0 8px rgba(34, 197, 94, 0.6)",W.background="#22c55e"),W},[w,B,g?.handleType,z]);return u.jsxs("div",{onClick:()=>h(e),className:$?"snap-target-glow":B?"connection-compatible":void 0,style:K,children:[k&&u.jsxs(u.Fragment,{children:[u.jsx(Jt,{type:"target",position:me.Top,style:{...ne,width:20,height:6,borderRadius:"0 0 4px 4px",top:-3}}),u.jsx(nF,{color:w})]}),u.jsxs("div",{style:{background:`${w}20`,borderBottom:`1px solid ${w}40`,padding:"6px 10px",borderRadius:"6px 6px 0 0",display:"flex",alignItems:"center",gap:6},children:[u.jsx("span",{style:{fontSize:16},children:a}),O!==null&&u.jsx("span",{style:{width:18,height:18,borderRadius:"50%",background:"#e879f930",color:"#e879f9",display:"flex",alignItems:"center",justifyContent:"center",fontSize:10,fontWeight:700,flexShrink:0},title:`Pipeline step #${O}`,children:O}),u.jsx("span",{style:{fontWeight:600,flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:n}),I&&u.jsx("span",{style:{width:18,height:18,borderRadius:"50%",background:"#f38ba830",color:"#f38ba8",display:"flex",alignItems:"center",justifyContent:"center",fontSize:10,fontWeight:700,flexShrink:0},title:L.map(W=>W.message).join(` +`),children:L.length})]}),u.jsxs("div",{style:{padding:"6px 10px"},children:[_&&_.inputs.length>0&&u.jsx(Uj,{ports:_.inputs,direction:"in",color:w}),u.jsx("span",{style:{background:`${w}30`,color:w,padding:"2px 6px",borderRadius:4,fontSize:10,fontWeight:500},children:r}),M&&u.jsx("div",{style:{marginTop:4,color:"#a6adc8",fontSize:11},children:r==="step.delegate"&&!o?u.jsxs(u.Fragment,{children:[u.jsxs("span",{style:{color:"#585b70"},children:["→"," "]}),u.jsx("span",{style:{color:"#bac2de"},children:A})]}):M}),d,_&&_.outputs.length>0&&u.jsx(Uj,{ports:_.outputs,direction:"out",color:w})]}),T&&u.jsxs(u.Fragment,{children:[u.jsx(Jt,{type:"source",position:me.Bottom,style:{...V,width:20,height:6,borderRadius:"4px 4px 0 0",bottom:-3}}),u.jsx(tF,{color:w})]})]})}function rF({id:e,data:n}){const r=n.config?.address||":8080";return u.jsx(Ar,{id:e,label:n.label,moduleType:n.moduleType,icon:u.jsx(iF,{}),preview:r})}function iF(){return u.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:[u.jsx("circle",{cx:"8",cy:"8",r:"7",stroke:"#3b82f6",strokeWidth:"1.5"}),u.jsx("path",{d:"M3 8h10M8 3c-1.5 2-1.5 8 0 10M8 3c1.5 2 1.5 8 0 10",stroke:"#3b82f6",strokeWidth:"1"})]})}function aF(e){const n=e.handlerRoutes;if(!n||n.length===0)return e.config?.prefix||e.config?.path||"/";const r=[...new Set(n.map(a=>a.method))];return`${n.length} route${n.length!==1?"s":""} (${r.join(", ")})`}function oF({id:e,data:n}){const r=aF(n);return u.jsx(Ar,{id:e,label:n.label,moduleType:n.moduleType,icon:u.jsx(sF,{}),preview:r})}function sF(){return u.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:[u.jsx("path",{d:"M8 2v4M8 6L3 12M8 6l5 6",stroke:"#3b82f6",strokeWidth:"1.5",strokeLinecap:"round"}),u.jsx("circle",{cx:"3",cy:"13",r:"1.5",fill:"#3b82f6"}),u.jsx("circle",{cx:"8",cy:"2",r:"1.5",fill:"#3b82f6"}),u.jsx("circle",{cx:"13",cy:"13",r:"1.5",fill:"#3b82f6"})]})}function lF({id:e,data:n}){const r=n.config?.provider||"",a=n.config?.topic||"",o=a?`${r} / ${a}`:r;return u.jsx(Ar,{id:e,label:n.label,moduleType:n.moduleType,icon:u.jsx(cF,{}),preview:o||void 0})}function cF(){return u.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:[u.jsx("rect",{x:"1",y:"3",width:"14",height:"10",rx:"2",stroke:"#8b5cf6",strokeWidth:"1.5"}),u.jsx("path",{d:"M1 5l7 4 7-4",stroke:"#8b5cf6",strokeWidth:"1.2"})]})}function uF({id:e,data:n}){const r=n.config?.initialState||"";return u.jsx(Ar,{id:e,label:n.label,moduleType:n.moduleType,icon:u.jsx(dF,{}),preview:r?`initial: ${r}`:void 0})}function dF(){return u.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:[u.jsx("circle",{cx:"4",cy:"8",r:"3",stroke:"#f59e0b",strokeWidth:"1.5"}),u.jsx("circle",{cx:"12",cy:"8",r:"3",stroke:"#f59e0b",strokeWidth:"1.5"}),u.jsx("path",{d:"M7 8h2",stroke:"#f59e0b",strokeWidth:"1.5",markerEnd:"url(#arr)"})]})}function fF({id:e,data:n}){const r=n.config?.interval||"",a=n.config?.cron||"",o=a?`cron: ${a}`:r?`every ${r}`:void 0;return u.jsx(Ar,{id:e,label:n.label,moduleType:n.moduleType,icon:u.jsx(pF,{}),preview:o})}function pF(){return u.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:[u.jsx("circle",{cx:"8",cy:"8",r:"6.5",stroke:"#6366f1",strokeWidth:"1.5"}),u.jsx("path",{d:"M8 4v4l3 2",stroke:"#6366f1",strokeWidth:"1.5",strokeLinecap:"round"})]})}function hF({id:e,data:n}){const r=n.config?.output||"";return u.jsx(Ar,{id:e,label:n.label,moduleType:n.moduleType,icon:u.jsx(gF,{}),preview:r?`output: ${r}`:void 0})}function gF(){return u.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:u.jsx("path",{d:"M9 1L3 9h4l-1 6 6-8H8l1-6z",fill:"#ef4444",opacity:"0.8"})})}function yF({id:e,data:n}){const r=n.config?.baseURL||"";return u.jsx(Ar,{id:e,label:n.label,moduleType:n.moduleType,icon:u.jsx(mF,{}),preview:r||void 0})}function mF(){return u.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:u.jsx("path",{d:"M6.5 9.5l3-3M5 11a2.83 2.83 0 01-1-4l2-2a2.83 2.83 0 014 0M11 5a2.83 2.83 0 011 4l-2 2a2.83 2.83 0 01-4 0",stroke:"#10b981",strokeWidth:"1.5",strokeLinecap:"round"})})}function vF(e){const n=ue(a=>a.edges),r=ue(a=>a.nodes);return N.useMemo(()=>{const a=n.filter(S=>S.data?.edgeType==="middleware-chain");if(a.length===0)return null;const o=a.some(S=>S.target===e),l=a.some(S=>S.source===e);if(!o&&!l)return null;const c=[e];let d=e;const p=new Set;for(p.add(d);;){const S=a.find(w=>w.target===d&&!p.has(w.source));if(!S)break;p.add(S.source),c.unshift(S.source),d=S.source}d=e;const h=[],g=new Set;for(g.add(d);;){const S=a.find(w=>w.source===d&&!g.has(w.target));if(!S)break;g.add(S.target),h.push(S.target),d=S.target}const m=[...c,...h].filter(S=>r.find(C=>C.id===S)?.data.moduleType?.startsWith("http.middleware."));if(m.length===0)return null;const b=m.indexOf(e);return b===-1?null:{position:b+1,total:m.length}},[n,r,e])}function bF({id:e,data:n}){const r=n.config?.type||"",a=n.config?.level||"",o=n.config?.rps;let l;r?l=`auth: ${r}`:a?l=`level: ${a}`:o&&(l=`${o} req/s`);const c=vF(e);return u.jsxs("div",{style:{position:"relative"},children:[c&&u.jsxs("div",{style:{position:"absolute",top:-8,right:-8,width:24,height:24,borderRadius:"50%",background:"#fab387",color:"#1e1e2e",display:"flex",alignItems:"center",justifyContent:"center",fontSize:10,fontWeight:700,zIndex:10,border:"2px solid #1e1e2e",boxShadow:"0 1px 4px rgba(0,0,0,0.4)",lineHeight:1},title:`Middleware ${c.position} of ${c.total} in chain`,children:[c.position,"/",c.total]}),u.jsx(Ar,{id:e,label:n.label,moduleType:n.moduleType,icon:u.jsx(xF,{}),preview:l})]})}function xF(){return u.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:u.jsx("path",{d:"M8 1.5L2.5 4v4c0 3.5 2.5 5.5 5.5 6.5 3-1 5.5-3 5.5-6.5V4L8 1.5z",stroke:"#06b6d4",strokeWidth:"1.5",fill:"none"})})}function SF({id:e,data:n}){const r=n.config?.driver||"",a=n.config?.provider||"",o=r||a||void 0;return u.jsx(Ar,{id:e,label:n.label,moduleType:n.moduleType,icon:u.jsx(wF,{}),preview:o})}function wF(){return u.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:[u.jsx("rect",{x:"2",y:"2",width:"12",height:"4",rx:"1",stroke:"#64748b",strokeWidth:"1.5"}),u.jsx("rect",{x:"2",y:"10",width:"12",height:"4",rx:"1",stroke:"#64748b",strokeWidth:"1.5"}),u.jsx("circle",{cx:"5",cy:"4",r:"1",fill:"#64748b"}),u.jsx("circle",{cx:"5",cy:"12",r:"1",fill:"#64748b"}),u.jsx("path",{d:"M8 6v4",stroke:"#64748b",strokeWidth:"1",strokeDasharray:"2 1"})]})}function _F({id:e,data:n}){const r=n,a=Wn[r.category]||"#64748b",{setNodes:o}=yo(),l=N.useCallback(()=>{o(c=>c.map(d=>{if(d.id===e){const p=!r.collapsed;return{...d,data:{...d.data,collapsed:p},style:p?{...d.style,height:40,overflow:"hidden"}:{...d.style,height:void 0,overflow:void 0}}}return d.parentId===e?{...d,hidden:!r.collapsed}:d}))},[e,r.collapsed,o]);return r.collapsed?u.jsxs("div",{style:{background:`${a}20`,border:`2px solid ${a}60`,borderRadius:8,minWidth:200,height:40,padding:0},children:[u.jsxs("div",{style:{background:`${a}30`,padding:"6px 12px",borderRadius:"6px 6px 6px 6px",display:"flex",alignItems:"center",gap:8,height:"100%"},children:[u.jsx("button",{onClick:l,style:{background:"none",border:"none",color:a,cursor:"pointer",fontSize:12,padding:0,lineHeight:1},children:"▶"}),u.jsx("span",{style:{color:a,fontWeight:700,fontSize:13},children:r.label}),u.jsxs("span",{style:{background:a,color:"#1e1e2e",borderRadius:10,padding:"1px 8px",fontSize:11,fontWeight:700},children:[r.childCount," modules"]})]}),u.jsx(Jt,{type:"target",position:me.Left,style:{background:a}}),u.jsx(Jt,{type:"source",position:me.Right,style:{background:a}})]}):u.jsxs("div",{style:{background:`${a}15`,border:`2px dashed ${a}60`,borderRadius:12,minWidth:200,minHeight:100,padding:0},children:[u.jsxs("div",{style:{background:`${a}30`,padding:"6px 12px",borderRadius:"10px 10px 0 0",display:"flex",alignItems:"center",gap:8},children:[u.jsx("button",{onClick:l,style:{background:"none",border:"none",color:a,cursor:"pointer",fontSize:12,padding:0,lineHeight:1},children:"▼"}),u.jsx("span",{style:{color:a,fontWeight:700,fontSize:13},children:r.label}),u.jsx("span",{style:{background:a,color:"#1e1e2e",borderRadius:10,padding:"1px 8px",fontSize:11,fontWeight:700},children:r.childCount})]}),u.jsx(Jt,{type:"target",position:me.Left,style:{background:a}}),u.jsx(Jt,{type:"source",position:me.Right,style:{background:a}})]})}const kF=N.memo(_F);function CF({id:e,data:n}){const r=ue(S=>S.selectedNodeId),a=ue(S=>S.setSelectedNode),o=r===e,l=Wn.statemachine,c=n.config?.expression||"?",p=vt(S=>S.moduleTypeMap)[n.moduleType],h=n.moduleType==="conditional.ifelse"?"ifelse":n.moduleType==="conditional.switch"?"switch":"expression",g=n.config?.cases??[],y=n.config?.outputs??[];let m;h==="ifelse"?m=[{id:"true",label:"true",position:me.Right},{id:"false",label:"false",position:me.Bottom}]:h==="switch"?m=g.length>0?g.map((S,w)=>({id:`case-${w}`,label:S,position:me.Bottom})):[{id:"default",label:"default",position:me.Bottom}]:m=y.length>0?y.map((S,w)=>({id:`out-${w}`,label:S,position:me.Bottom})):[{id:"result",label:"result",position:me.Bottom}];const b=100;return u.jsxs("div",{onClick:()=>a(e),style:{position:"relative",width:b+40,height:b+40,cursor:"pointer"},children:[u.jsx(Jt,{type:"target",position:me.Top,style:{background:l,width:10,height:10,border:"2px solid #1e1e2e",top:0,left:"50%",transform:"translateX(-50%)"}}),u.jsx("div",{style:{position:"absolute",top:20,left:20,width:b,height:b,transform:"rotate(45deg)",background:"#1e1e2e",border:`2px solid ${o?"#fff":l}`,boxShadow:o?`0 0 0 2px ${l}40, 0 4px 12px rgba(0,0,0,0.4)`:"0 2px 8px rgba(0,0,0,0.3)"}}),u.jsxs("div",{style:{position:"absolute",top:20,left:20,width:b,height:b,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",color:"#cdd6f4",fontFamily:"system-ui, sans-serif",fontSize:10,textAlign:"center",pointerEvents:"none",zIndex:1},children:[u.jsx("span",{style:{fontSize:14,fontWeight:600,color:l,marginBottom:2},children:h==="ifelse"?"IF":h==="switch"?"SW":"EX"}),u.jsx("span",{style:{fontSize:9,maxWidth:60,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",color:"#a6adc8"},children:c})]}),u.jsx("div",{style:{position:"absolute",bottom:-16,left:0,width:"100%",textAlign:"center",fontSize:10,color:"#a6adc8",fontFamily:"system-ui, sans-serif",whiteSpace:"nowrap"},children:p?.label??n.label}),m.map((S,w)=>{if(h==="ifelse")return S.id==="true"?u.jsx(Jt,{id:S.id,type:"source",position:me.Right,style:{background:"#22c55e",width:8,height:8,border:"2px solid #1e1e2e",right:0,top:"50%",transform:"translateY(-50%)"}},S.id):u.jsx(Jt,{id:S.id,type:"source",position:me.Bottom,style:{background:"#ef4444",width:8,height:8,border:"2px solid #1e1e2e",bottom:0,left:"50%",transform:"translateX(-50%)"}},S.id);const C=m.length,_=C>1?w/(C-1)*80+10:50;return u.jsx(Jt,{id:S.id,type:"source",position:me.Bottom,style:{background:l,width:8,height:8,border:"2px solid #1e1e2e",bottom:0,left:`${_}%`,transform:"translateX(-50%)"}},S.id)})]})}const EF={groupNode:kF,httpNode:rF,httpRouterNode:oF,messagingNode:lF,stateMachineNode:uF,schedulerNode:fF,eventNode:hF,integrationNode:yF,middlewareNode:bF,infrastructureNode:SF,conditionalNode:CF},jF={projectSwitcher:200,nodePalette:240,propertyPanel:280},Bi={projectSwitcher:{min:150,max:350},nodePalette:{min:180,max:400},propertyPanel:{min:200,max:500}},Fn=Mn()(b8((e,n)=>({projectSwitcherCollapsed:!1,nodePaletteCollapsed:!1,propertyPanelCollapsed:!1,panelWidths:{...jF},toggleProjectSwitcher:()=>e({projectSwitcherCollapsed:!n().projectSwitcherCollapsed}),toggleNodePalette:()=>e({nodePaletteCollapsed:!n().nodePaletteCollapsed}),togglePropertyPanel:()=>e({propertyPanelCollapsed:!n().propertyPanelCollapsed}),setProjectSwitcherCollapsed:r=>e({projectSwitcherCollapsed:r}),setNodePaletteCollapsed:r=>e({nodePaletteCollapsed:r}),setPropertyPanelCollapsed:r=>e({propertyPanelCollapsed:r}),setPanelWidth:(r,a)=>{const o=Bi[r],l=Math.round(Math.max(o.min,Math.min(o.max,a)));e({panelWidths:{...n().panelWidths,[r]:l}})}}),{name:"workflow-ui-layout"}));async function TF(){return bt("/admin/engine/config")}async function AF(e){await Mu("/admin/engine/config",e)}async function RF(e){return Tt("/admin/engine/validate",e)}async function zF(e){return Tt("/admin/ai/generate",{intent:e})}async function NF(e){return Tt("/admin/ai/suggest",{useCase:e})}async function MF(){return bt("/admin/components")}async function OF(e,n,r){await Tt("/admin/components",{id:e,source:n,language:r})}async function DF(e){await tl(`/admin/components/${encodeURIComponent(e)}`)}function qF(){return bt("/auth/users")}function IF(e,n,r,a){return Tt("/auth/users",{email:e,password:n,name:r,role:a})}function LF(e){return tl(`/auth/users/${encodeURIComponent(e)}`)}function BF(e,n){return Mu(`/auth/users/${encodeURIComponent(e)}/role`,{role:n})}function X0(){return bt("/admin/companies")}function HF(e,n){return Tt("/admin/companies",{name:e,slug:n})}function Fj(e){return bt(`/admin/companies/${encodeURIComponent(e)}/organizations`)}function UF(e,n,r){return Tt(`/admin/companies/${encodeURIComponent(e)}/organizations`,{name:n,slug:r})}function Pj(e){return bt(`/admin/organizations/${encodeURIComponent(e)}/projects`)}function FF(){return bt("/admin/projects")}function PF(e,n,r){return Tt(`/admin/organizations/${encodeURIComponent(e)}/projects`,{name:n,slug:r})}function $b(e){return bt(e?`/admin/projects/${encodeURIComponent(e)}/workflows`:"/admin/workflows")}function $F(e,n){return Tt(`/admin/projects/${encodeURIComponent(e)}/workflows`,n)}function $j(e,n){return Mu(`/admin/workflows/${encodeURIComponent(e)}`,n)}function VF(e){return tl(`/admin/workflows/${encodeURIComponent(e)}`)}function ud(e){return Tt(`/admin/workflows/${encodeURIComponent(e)}/deploy`)}function dd(e){return Tt(`/admin/workflows/${encodeURIComponent(e)}/stop`)}function hA(e,n){return Tt("/admin/workflows/load-from-path",{project_id:e,path:n})}function WF(e){return bt(`/admin/workflows/${encodeURIComponent(e)}/versions`)}function GF(){return bt("/admin/dashboard")}function YF(e){return bt(`/admin/workflows/${encodeURIComponent(e)}/dashboard`)}function XF(e,n){const r=new URLSearchParams;n?.status&&r.set("status",n.status),n?.since&&r.set("since",n.since),n?.until&&r.set("until",n.until);const a=r.toString();return bt(`/admin/workflows/${encodeURIComponent(e)}/executions${a?"?"+a:""}`)}function KF(e){return bt(`/admin/executions/${encodeURIComponent(e)}`)}function ZF(e){return bt(`/admin/executions/${encodeURIComponent(e)}/steps`)}function QF(e,n){return Tt(`/admin/workflows/${encodeURIComponent(e)}/trigger`,{trigger_data:{}})}function JF(e){return Tt(`/admin/executions/${encodeURIComponent(e)}/cancel`)}function eP(e,n){const r=new URLSearchParams;n?.level&&r.set("level",n.level),n?.executionId&&r.set("execution_id",n.executionId),n?.module&&r.set("module",n.module),n?.since&&r.set("since",n.since);const a=r.toString();return bt(`/admin/workflows/${encodeURIComponent(e)}/logs${a?"?"+a:""}`)}function tP(e,n){const{baseUrl:r}=zT(),a=`${r}/admin/workflows/${encodeURIComponent(e)}/logs/stream?token=${encodeURIComponent(n)}`;return new EventSource(a)}function nP(e){return bt(`/admin/workflows/${encodeURIComponent(e)}/events`)}function rP(e,n){const{baseUrl:r}=zT(),a=`${r}/admin/workflows/${encodeURIComponent(e)}/events/stream?token=${encodeURIComponent(n)}`;return new EventSource(a)}function iP(e){return bt(`/admin/iam/providers/${encodeURIComponent(e)}`)}function aP(e,n){return Tt("/admin/iam/providers",{...n,company_id:e})}function oP(e,n){return Mu(`/admin/iam/providers/${encodeURIComponent(e)}`,n)}function sP(e){return tl(`/admin/iam/providers/${encodeURIComponent(e)}`)}function lP(e){return Tt(`/admin/iam/providers/${encodeURIComponent(e)}/test`)}function cP(e){return bt(`/admin/iam/providers/${encodeURIComponent(e)}/mappings`)}function uP(e,n){return Tt(`/admin/iam/providers/${encodeURIComponent(e)}/mappings`,n)}function dP(e){return tl(`/admin/iam/mappings/${encodeURIComponent(e)}`)}function p0(){return bt("/admin/runtime/instances")}function fP(e){return Tt(`/admin/runtime/instances/${encodeURIComponent(e)}/stop`)}const Vj=50,Wj=8;function Gj(e,n){return!(n[e]?.maxIncoming===0||e.startsWith("trigger."))}function Yj(e,n){return n[e]?.maxOutgoing!==0}function Xj(e,n,r){const a=r[e],o=r[n];if(!a?.ioSignature||!o?.ioSignature)return!0;const l=a.ioSignature.outputs.map(d=>d.type),c=o.ioSignature.inputs.map(d=>d.type);return l.length===0||c.length===0?!0:l.some(d=>c.some(p=>go(d,p)))}function Kj(e,n){const r=document.querySelector(`[data-id="${e}"]`);if(r){const a=r.getBoundingClientRect();return{width:a.width/n,height:a.height/n}}return{width:180,height:80}}function Zj(e,n,r,a,o,l){const c=r.find(m=>m.id===e);if(!c?.position)return null;const d=c.data.moduleType,p=Kj(e,l),h=new Set;for(const m of a)m.source===e&&h.add(m.target),m.target===e&&h.add(m.source);let g=null,y=1/0;for(const m of r){if(m.id===e||h.has(m.id)||!m.position)continue;const b=m.data.moduleType,S=Kj(m.id,l);if(Yj(b,o)&&Gj(d,o)&&Xj(b,d,o)&&Y0(m.id,a,o,b)&&G0(e,a,o,d)){const w={x:m.position.x+S.width/2,y:m.position.y+S.height},C={x:n.x+p.width/2,y:n.y},_=w.x-C.x,j=w.y-C.y,k=Math.sqrt(_*_+j*j);kM.moduleTypes),m=N.useMemo(()=>{if(n.outputTypes.length===0)return y;let M=[];for(const P of n.outputTypes)n.handleType==="source"?M=M.concat(XU(P,y)):M=M.concat(KU(P,y));const O=new Set;return M.filter(P=>O.has(P.type)?!1:(O.add(P.type),!0))},[n,y]),b=o.toLowerCase(),S=N.useMemo(()=>b?m.filter(M=>M.label.toLowerCase().includes(b)||M.type.toLowerCase().includes(b)):m,[m,b]),w=N.useMemo(()=>B0.map(M=>({...M,types:S.filter(O=>O.category===M.key)})).filter(M=>M.types.length>0),[S]),C=N.useMemo(()=>w.flatMap(M=>M.types),[w]);N.useEffect(()=>{d(0)},[C.length]),N.useEffect(()=>{h.current?.focus()},[]),N.useEffect(()=>{const M=P=>{p.current&&!p.current.contains(P.target)&&a()},O=setTimeout(()=>{document.addEventListener("mousedown",M)},100);return()=>{clearTimeout(O),document.removeEventListener("mousedown",M)}},[a]);const _=N.useCallback(M=>{M.key==="Escape"?(M.preventDefault(),M.stopPropagation(),a()):M.key==="ArrowDown"?(M.preventDefault(),d(O=>{const P=Math.min(O+1,C.length-1);return g.current[P]?.scrollIntoView({block:"nearest"}),P})):M.key==="ArrowUp"?(M.preventDefault(),d(O=>{const P=Math.max(O-1,0);return g.current[P]?.scrollIntoView({block:"nearest"}),P})):M.key==="Enter"&&C.length>0&&(M.preventDefault(),r(C[c].type))},[C,c,r,a]),j=260,k=340,T=Math.min(e.x,window.innerWidth-j-20),E=Math.min(e.y,window.innerHeight-k-20),z=n.outputTypes.join(" | ");let A=0;return u.jsxs("div",{ref:p,onKeyDown:_,style:{position:"absolute",left:Math.max(T,10),top:Math.max(E,10),width:j,maxHeight:k,background:"#181825",border:"1px solid #313244",borderRadius:8,boxShadow:"0 8px 32px rgba(0,0,0,0.5)",zIndex:100,display:"flex",flexDirection:"column",overflow:"hidden",animation:"picklist-enter 0.15s ease-out",fontFamily:"system-ui, sans-serif"},children:[u.jsxs("div",{style:{padding:"8px 12px 4px",borderBottom:"1px solid #313244"},children:[u.jsxs("div",{style:{fontSize:11,color:"#6c7086",marginBottom:4},children:["Connect ",n.handleType==="source"?"output":"input",": ",u.jsx("span",{style:{color:"#89b4fa"},children:z})]}),u.jsx("input",{ref:h,type:"text",placeholder:"Search compatible modules...",value:o,onChange:M=>l(M.target.value),style:{width:"100%",padding:"6px 8px",fontSize:12,background:"#1e1e2e",border:"1px solid #313244",borderRadius:4,color:"#cdd6f4",outline:"none",boxSizing:"border-box"}})]}),u.jsxs("div",{style:{overflowY:"auto",flex:1,padding:"4px 0"},children:[w.length===0&&u.jsx("div",{style:{padding:"12px 16px",color:"#6c7086",fontSize:12,textAlign:"center"},children:"No compatible modules found"}),w.map(M=>u.jsxs("div",{children:[u.jsx("div",{style:{padding:"4px 12px",fontSize:10,fontWeight:600,color:Wn[M.key],textTransform:"uppercase",letterSpacing:"0.5px"},children:M.label}),M.types.map(O=>{const P=A++,L=P===c;return u.jsxs("div",{ref:I=>{g.current[P]=I},onClick:()=>r(O.type),onMouseEnter:()=>d(P),style:{padding:"5px 12px 5px 20px",cursor:"pointer",fontSize:12,color:L?"#cdd6f4":"#bac2de",background:L?"#313244":"transparent",display:"flex",alignItems:"center",gap:6,transition:"background 0.1s"},children:[u.jsx("span",{style:{width:8,height:8,borderRadius:"50%",background:Wn[M.key],flexShrink:0}}),u.jsxs("div",{style:{flex:1,minWidth:0},children:[u.jsx("div",{style:{fontWeight:500,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:O.label}),u.jsx("div",{style:{fontSize:10,color:"#585b70",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:O.type})]})]},O.type)})]},M.key))]}),u.jsxs("div",{style:{padding:"4px 12px",borderTop:"1px solid #313244",fontSize:10,color:"#585b70",display:"flex",gap:8},children:[u.jsx("span",{children:"Up/Down to navigate"}),u.jsx("span",{children:"Enter to select"}),u.jsx("span",{children:"Esc to close"})]})]})}function hP({id:e,sourceX:n,sourceY:r,targetX:a,targetY:o,sourcePosition:l,targetPosition:c,style:d,markerEnd:p,data:h}){const g=ue(w=>w.removeEdge),[y,m,b]=fb({sourceX:n,sourceY:r,sourcePosition:l,targetX:a,targetY:o,targetPosition:c}),S=h?.edgeType==="auto-wire";return u.jsxs(u.Fragment,{children:[u.jsx(ll,{path:y,markerEnd:p,style:d}),!S&&u.jsx(CI,{children:u.jsxs("div",{className:"edge-delete-button",style:{position:"absolute",transform:`translate(-50%, -50%) translate(${m}px,${b}px)`,pointerEvents:"all"},children:[h?.label!=null&&u.jsx("span",{className:"edge-label",children:String(h.label)}),u.jsx("button",{className:"edge-delete-btn",onClick:w=>{w.stopPropagation(),g(e)},title:"Delete connection",children:"×"})]})})]})}const gP=N.memo(hP);function yP({x:e,y:n,edgeId:r,onClose:a}){const o=ue(l=>l.removeEdge);return u.jsxs("div",{className:"context-menu",style:{position:"fixed",left:e,top:n,zIndex:1e3},children:[u.jsx("button",{className:"context-menu-item context-menu-item-danger",onClick:()=>{o(r),a()},children:"Delete Connection"}),u.jsx("button",{className:"context-menu-item",onClick:a,children:"Cancel"})]})}function mP({x:e,y:n,nodeId:r,onClose:a}){const o=ue(p=>p.edges),l=ue(p=>p.removeEdge),c=ue(p=>p.removeNode),d=o.filter(p=>p.source===r||p.target===r).filter(p=>p.data?.edgeType!=="auto-wire");return u.jsxs("div",{className:"context-menu",style:{position:"fixed",left:e,top:n,zIndex:1e3},children:[d.length>0&&u.jsxs("button",{className:"context-menu-item",onClick:()=>{d.forEach(p=>l(p.id)),a()},children:["Disconnect All (",d.length,")"]}),u.jsx("button",{className:"context-menu-item context-menu-item-danger",onClick:()=>{c(r),a()},children:"Delete Node"}),u.jsx("button",{className:"context-menu-item",onClick:a,children:"Cancel"})]})}const vP={deletable:gP};function bP(){const e=ue(ae=>ae.nodes),n=ue(ae=>ae.edges),r=ue(ae=>ae.onNodesChange),a=ue(ae=>ae.onEdgesChange),o=ue(ae=>ae.onConnect),l=ue(ae=>ae.addNode),c=ue(ae=>ae.setSelectedNode),d=ue(ae=>ae.selectedNodeId),p=ue(ae=>ae.selectedEdgeId),h=ue(ae=>ae.setSelectedEdge),g=ue(ae=>ae.removeEdge),y=ue(ae=>ae.removeNode),m=ue(ae=>ae.undo),b=ue(ae=>ae.redo),S=ue(ae=>ae.exportToConfig),w=ue(ae=>ae.addToast),C=ue(ae=>ae.viewLevel),_=ue(ae=>ae.setConnectingFrom),j=ue(ae=>ae.setCompatibleNodeIds),k=ue(ae=>ae.showConnectionPicklist),T=ue(ae=>ae.hideConnectionPicklist),E=ue(ae=>ae.connectionPicklist),z=ue(ae=>ae.connectingFrom),A=ue(ae=>ae.setSnapTargetId),M=ue(ae=>ae.pushHistory),O=vt(ae=>ae.moduleTypeMap),P=Fn(ae=>ae.propertyPanelCollapsed),L=Fn(ae=>ae.setPropertyPanelCollapsed),{screenToFlowPosition:I,getViewport:F}=yo(),U=N.useRef(null),[B,D]=N.useState(null),q=N.useMemo(()=>{const ae={dependency:{stroke:"#585b70",strokeWidth:1.5,opacity:.4},"http-route":{stroke:"#3b82f6",strokeWidth:2.5},"messaging-subscription":{stroke:"#8b5cf6",strokeWidth:2.5},statemachine:{stroke:"#f59e0b",strokeWidth:2.5},event:{stroke:"#ef4444",strokeWidth:2},conditional:{stroke:"#22c55e",strokeWidth:2},"auto-wire":{stroke:"#45475a",strokeWidth:1,opacity:.3},"middleware-chain":{stroke:"#fab387",strokeWidth:2.5},"pipeline-flow":{stroke:"#e879f9",strokeWidth:3}};return n.map(pe=>{const ge=pe.data,je=ge?.edgeType,Ae=je==="auto-wire",ze=pe.id===p&&!Ae;if(!je){if(ze){const Ct=pe.style?.stroke||"#585b70";return{...pe,type:"deletable",style:{...pe.style,strokeWidth:(pe.style?.strokeWidth||2)+1.5,opacity:1,filter:`drop-shadow(0 0 4px ${Ct})`}}}return{...pe,type:"deletable"}}const Ne=ae[je];if(!Ne)return pe;const We=je==="middleware-chain",He=je==="pipeline-flow",Ge=We||He?ge?.chainOrder:void 0,Dt=ze?Ne.strokeWidth+1.5:Ne.strokeWidth,Pt=ze?1:Ne.opacity??1,Qe=ze?`drop-shadow(0 0 4px ${Ne.stroke})`:void 0;return{...pe,...Ae?{}:{type:"deletable"},...Ge!==void 0?{label:`#${Ge}`}:{},style:{...pe.style,stroke:Ne.stroke,strokeWidth:Dt,opacity:Pt,filter:Qe},labelStyle:We||He?{fill:Ne.stroke,fontWeight:700,fontSize:14}:{fill:Ne.stroke,fontWeight:600,fontSize:11},labelBgStyle:We||He?{fill:"#1e1e2e",fillOpacity:.95,rx:10,ry:10}:{fill:"#1e1e2e",fillOpacity:.9},labelBgPadding:We||He?[4,4]:void 0,...Ae?{deletable:!1,selectable:!1,animated:!1}:{}}})},[n,p]),{nodes:$,edges:K}=N.useMemo(()=>C==="container"&&e.length>0?WU(e,q):{nodes:e,edges:q},[C,e,q]),ne=N.useCallback(ae=>{ae.preventDefault(),ae.dataTransfer.dropEffect="move"},[]),V=N.useCallback(ae=>{ae.preventDefault();const pe=ae.dataTransfer.getData("application/workflow-module-type");if(!pe)return;const ge=I({x:ae.clientX,y:ae.clientY});ge.x=Math.max(ge.x,20),ge.y=Math.max(ge.y,20),l(pe,ge)},[l,I]),W=N.useCallback(ae=>{o(ae)},[o]),ee=N.useCallback((ae,pe)=>{c(pe.id),P&&L(!1)},[c,P,L]),G=N.useCallback((ae,pe)=>{pe.data?.edgeType!=="auto-wire"&&h(pe.id)},[h]),X=N.useCallback(()=>{c(null),h(null),D(null),E&&T()},[c,h,E,T]),Q=N.useCallback((ae,pe)=>{ae.preventDefault(),pe.data?.edgeType!=="auto-wire"&&D({type:"edge",x:ae.clientX,y:ae.clientY,id:pe.id})},[]),ie=N.useCallback((ae,pe)=>{ae.preventDefault(),D({type:"node",x:ae.clientX,y:ae.clientY,id:pe.id})},[]),se=N.useCallback(()=>{D(null)},[]),he=N.useCallback((ae,pe)=>{const{nodeId:ge,handleType:je}=pe;if(!ge)return;const Ae=e.find(He=>He.id===ge);if(!Ae)return;const ze=O[Ae.data.moduleType];if(!ze?.ioSignature)return;const Ne=je==="source"?uA(ze):dA(ze);if(Ne.length===0)return;_({nodeId:ge,handleId:pe.handleId??null,handleType:je??"source",outputTypes:Ne});const We=ZU(ge,Ne,je??"source",e,O);j(We)},[e,O,_,j]),ye=N.useCallback(ae=>{if(!ue.getState().connectingFrom)return;if(!ae.target?.closest(".react-flow__handle")){const Ae=ae.clientX,ze=ae.clientY,Ne=U.current?.getBoundingClientRect();Ne&&k({x:Ae-Ne.left,y:ze-Ne.top});return}_(null),j([])},[_,j,k]),be=N.useCallback(ae=>{const{source:pe,target:ge}=ae;if(!pe||!ge||pe===ge)return!1;const je=ue.getState().edges;if(je.some(Qe=>Qe.source===pe&&Qe.target===ge))return!1;const ze=e.find(Qe=>Qe.id===pe),Ne=e.find(Qe=>Qe.id===ge);if(!ze||!Ne)return!1;const We=O[ze.data.moduleType],He=O[Ne.data.moduleType];if(!We?.ioSignature||!He?.ioSignature)return!0;const Ge=We.ioSignature.outputs.map(Qe=>Qe.type),Dt=He.ioSignature.inputs.map(Qe=>Qe.type);return Ge.length===0||Dt.length===0?!0:!(!Ge.some(Qe=>Dt.some(Ct=>go(Qe,Ct)))||!Y0(pe,je,O,ze.data.moduleType)||!G0(ge,je,O,Ne.data.moduleType))},[e,O]);N.useEffect(()=>{const ae=pe=>{const ge=pe.target,je=ge.tagName==="INPUT"||ge.tagName==="TEXTAREA"||ge.tagName==="SELECT";if((pe.key==="Delete"||pe.key==="Backspace")&&!je&&(d?(pe.preventDefault(),y(d)):p&&(pe.preventDefault(),g(p))),pe.key==="Escape"&&(c(null),h(null),D(null),T()),pe.key==="z"&&(pe.ctrlKey||pe.metaKey)&&!pe.shiftKey&&(pe.preventDefault(),m()),(pe.key==="y"&&(pe.ctrlKey||pe.metaKey)||pe.key==="z"&&(pe.ctrlKey||pe.metaKey)&&pe.shiftKey)&&(pe.preventDefault(),b()),pe.key==="s"&&(pe.ctrlKey||pe.metaKey)){pe.preventDefault();const Ae=S();AF(Ae).then(()=>w("Workflow saved to server","success")).catch(ze=>w(`Save failed: ${ze.message}`,"error"))}};return window.addEventListener("keydown",ae),()=>window.removeEventListener("keydown",ae)},[d,p,y,g,c,h,m,b,S,w,T]);const we=N.useCallback((ae,pe)=>{const{zoom:ge}=F(),je=ue.getState(),Ae=vt.getState().moduleTypeMap,ze=Zj(pe.id,pe.position,je.nodes,je.edges,Ae,ge);A(ze?ze.targetNodeId:null)},[F,A]),xe=N.useCallback((ae,pe)=>{const{zoom:ge}=F(),je=ue.getState(),Ae=vt.getState().moduleTypeMap,ze=Zj(pe.id,pe.position,je.nodes,je.edges,Ae,ge);if(ze){M();const Ne={id:pe.id,type:"position",position:ze.snappedPosition},We=ue.getState().nodes,He=vb([Ne],We);ue.setState({nodes:He}),o({source:ze.sourceNodeId,target:ze.targetForEdge,sourceHandle:null,targetHandle:null})}A(null)},[F,M,o,A]),ke=N.useCallback(ae=>{const pe=ue.getState().connectingFrom,ge=ue.getState().connectionPicklist;if(!pe||!ge)return;const je=U.current?.getBoundingClientRect();if(!je)return;const Ae=I({x:ge.x+je.left,y:ge.y+je.top});Ae.x=Math.max(Ae.x,20),Ae.y=Math.max(Ae.y,20),l(ae,Ae);const ze=ue.getState().nodes,Ne=ze[ze.length-1];Ne&&(pe.handleType==="source"?o({source:pe.nodeId,target:Ne.id,sourceHandle:pe.handleId,targetHandle:null}):o({source:Ne.id,target:pe.nodeId,sourceHandle:null,targetHandle:pe.handleId}),T())},[l,o,I,T]);return u.jsxs("div",{ref:U,style:{flex:1,height:"100%",position:"relative"},onDragOver:ne,onDrop:V,children:[u.jsxs(_I,{nodes:$,edges:K,onNodesChange:r,onEdgesChange:a,onConnect:W,onConnectStart:he,onConnectEnd:ye,isValidConnection:be,onNodeDrag:we,onNodeDragStop:xe,onEdgeClick:G,onEdgeContextMenu:Q,onNodeContextMenu:ie,onPaneClick:X,onNodeDoubleClick:ee,nodeTypes:EF,edgeTypes:vP,fitView:!0,proOptions:{hideAttribution:!0},defaultEdgeOptions:{type:"deletable",animated:!1,style:{stroke:"#585b70",strokeWidth:2}},style:{background:"#1e1e2e"},children:[u.jsx(RI,{variant:wr.Dots,gap:20,size:1,color:"#313244"}),u.jsx(II,{style:{background:"#181825",border:"1px solid #313244",borderRadius:6}}),u.jsx(KI,{nodeColor:()=>"#45475a",maskColor:"rgba(0,0,0,0.5)",style:{background:"#181825",border:"1px solid #313244",borderRadius:6,zIndex:4},pannable:!0,zoomable:!0})]}),E&&z&&u.jsx(pP,{position:E,connectingFrom:z,onSelect:ke,onClose:T}),B?.type==="edge"&&u.jsx(yP,{x:B.x,y:B.y,edgeId:B.id,onClose:se}),B?.type==="node"&&u.jsx(mP,{x:B.x,y:B.y,nodeId:B.id,onClose:se})]})}const Qj={width:"100%",padding:"6px 8px",background:"#1e1e2e",border:"1px solid #313244",borderRadius:4,color:"#cdd6f4",fontSize:12,outline:"none",boxSizing:"border-box"},Jj={background:"none",border:"none",color:"#6c7086",cursor:"pointer",fontSize:8,padding:"0 2px",lineHeight:1};function xP({value:e,onChange:n,itemType:r,placeholder:a}){const[o,l]=N.useState(""),[c,d]=N.useState(null),p=Array.isArray(e)?e:[],h=j=>{if(r==="number"){const k=Number(j);return isNaN(k)?j:k}return r==="boolean"?j==="true":j},g=()=>{const j=o.trim();j&&(n([...p,h(j)]),l(""))},y=j=>{n(p.filter((k,T)=>T!==j))},m=(j,k)=>{const T=[...p];T[j]=h(k),n(T)},b=j=>{if(j===0)return;const k=[...p];[k[j-1],k[j]]=[k[j],k[j-1]],n(k)},S=j=>{if(j>=p.length-1)return;const k=[...p];[k[j],k[j+1]]=[k[j+1],k[j]],n(k)},w=j=>{d(j)},C=(j,k)=>{if(j.preventDefault(),c===null||c===k)return;const T=[...p],[E]=T.splice(c,1);T.splice(k,0,E),d(k),n(T)},_=()=>{d(null)};return u.jsxs("div",{children:[p.map((j,k)=>u.jsxs("div",{draggable:!0,onDragStart:()=>w(k),onDragOver:T=>C(T,k),onDragEnd:_,style:{display:"flex",gap:4,marginBottom:3,alignItems:"center",padding:"2px 0",background:c===k?"#313244":"transparent",borderRadius:4,cursor:"grab"},children:[u.jsx("span",{style:{color:"#45475a",fontSize:10,cursor:"grab",flexShrink:0,userSelect:"none",padding:"0 2px"},title:"Drag to reorder",children:"⋮⋮"}),u.jsx("input",{type:r==="number"?"number":"text",value:String(j??""),onChange:T=>m(k,T.target.value),style:{...Qj,flex:1}}),u.jsx("button",{onClick:()=>b(k),disabled:k===0,style:{...Jj,opacity:k===0?.3:1},title:"Move up",children:"▲"}),u.jsx("button",{onClick:()=>S(k),disabled:k>=p.length-1,style:{...Jj,opacity:k>=p.length-1?.3:1},title:"Move down",children:"▼"}),u.jsx("button",{onClick:()=>y(k),style:{background:"none",border:"none",color:"#f38ba8",cursor:"pointer",fontSize:11,padding:"0 4px",flexShrink:0},title:"Remove item",children:"x"})]},k)),u.jsxs("div",{style:{display:"flex",gap:4},children:[u.jsx("input",{type:r==="number"?"number":"text",value:o,onChange:j=>l(j.target.value),placeholder:a||"Add item...",style:{...Qj,flex:1},onKeyDown:j=>{j.key==="Enter"&&(j.preventDefault(),g())}}),u.jsx("button",{onClick:g,style:{background:"#313244",border:"1px solid #45475a",borderRadius:4,color:"#cdd6f4",cursor:"pointer",fontSize:11,padding:"4px 8px",flexShrink:0},children:"+"})]}),p.length===0&&u.jsx("div",{style:{color:"#585b70",fontSize:10,marginTop:4},children:"No items. Type above and press Enter or click + to add."})]})}const Xc={width:"100%",padding:"6px 8px",background:"#1e1e2e",border:"1px solid #313244",borderRadius:4,color:"#cdd6f4",fontSize:12,outline:"none",boxSizing:"border-box"},eT={background:"none",border:"none",color:"#6c7086",cursor:"pointer",fontSize:8,padding:"0 2px",lineHeight:1};function Wa(e){const n={};for(const[r,a]of e)n[r]=a;return n}function SP({value:e,onChange:n,valueType:r,placeholder:a}){const[o,l]=N.useState(""),[c,d]=N.useState(""),[p,h]=N.useState(null),[g,y]=N.useState(null),m=e&&typeof e=="object"&&!Array.isArray(e)?Object.entries(e):[],b=A=>{if(r==="number"){const M=Number(A);return isNaN(M)?A:M}return r==="boolean"?A==="true":A},S=()=>{const A=o.trim();A&&(n({...e,[A]:b(c.trim())}),l(""),d(""))},w=A=>{const M=m.filter((O,P)=>P!==A);n(Wa(M))},C=(A,M)=>{const O=[...m];O[A]=[O[A][0],b(M)],n(Wa(O))},_=(A,M)=>{const O=M.trim();if(!O||m.some(([I],F)=>F!==A&&I===O))return;const L=[...m];L[A]=[O,L[A][1]],n(Wa(L)),y(null)},j=A=>{if(A===0)return;const M=[...m];[M[A-1],M[A]]=[M[A],M[A-1]],n(Wa(M))},k=A=>{if(A>=m.length-1)return;const M=[...m];[M[A],M[A+1]]=[M[A+1],M[A]],n(Wa(M))},T=A=>{h(A)},E=(A,M)=>{if(A.preventDefault(),p===null||p===M)return;const O=[...m],[P]=O.splice(p,1);O.splice(M,0,P),h(M),n(Wa(O))},z=()=>{h(null)};return u.jsxs("div",{children:[m.map(([A,M],O)=>u.jsxs("div",{draggable:g!==O,onDragStart:()=>T(O),onDragOver:P=>E(P,O),onDragEnd:z,style:{display:"flex",gap:4,marginBottom:3,alignItems:"center",padding:"2px 0",background:p===O?"#313244":"transparent",borderRadius:4,cursor:g===O?"default":"grab"},children:[u.jsx("span",{style:{color:"#45475a",fontSize:10,cursor:"grab",flexShrink:0,userSelect:"none",padding:"0 2px"},title:"Drag to reorder",children:"⋮⋮"}),g===O?u.jsx("input",{type:"text",defaultValue:A,autoFocus:!0,onBlur:P=>_(O,P.target.value),onKeyDown:P=>{P.key==="Enter"?_(O,P.target.value):P.key==="Escape"&&y(null)},style:{...Xc,width:"auto",flex:"0 0 70px",fontSize:11,padding:"4px 6px"}}):u.jsx("span",{onClick:()=>y(O),style:{color:"#a6adc8",fontSize:11,minWidth:50,maxWidth:80,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flexShrink:0,cursor:"text",padding:"2px 4px",borderRadius:3,border:"1px solid transparent"},title:`${A} (click to rename)`,children:A}),u.jsx("input",{type:r==="number"?"number":"text",value:String(M??""),onChange:P=>C(O,P.target.value),style:{...Xc,flex:1}}),u.jsx("button",{onClick:()=>j(O),disabled:O===0,style:{...eT,opacity:O===0?.3:1},title:"Move up",children:"▲"}),u.jsx("button",{onClick:()=>k(O),disabled:O>=m.length-1,style:{...eT,opacity:O>=m.length-1?.3:1},title:"Move down",children:"▼"}),u.jsx("button",{onClick:()=>w(O),style:{background:"none",border:"none",color:"#f38ba8",cursor:"pointer",fontSize:11,padding:"0 4px",flexShrink:0},title:"Remove entry",children:"x"})]},`${A}-${O}`)),u.jsxs("div",{style:{display:"flex",gap:4},children:[u.jsx("input",{type:"text",value:o,onChange:A=>l(A.target.value),placeholder:"key",style:{...Xc,flex:1},onKeyDown:A=>{A.key==="Enter"&&(A.preventDefault(),S())}}),u.jsx("input",{type:r==="number"?"number":"text",value:c,onChange:A=>d(A.target.value),placeholder:a||"value",style:{...Xc,flex:1},onKeyDown:A=>{A.key==="Enter"&&(A.preventDefault(),S())}}),u.jsx("button",{onClick:S,style:{background:"#313244",border:"1px solid #45475a",borderRadius:4,color:"#cdd6f4",cursor:"pointer",fontSize:11,padding:"4px 8px",flexShrink:0},children:"+"})]}),m.length===0&&u.jsx("div",{style:{color:"#585b70",fontSize:10,marginTop:4},children:"No entries. Add a key-value pair above."})]})}function wP({nodeId:e,middlewareChain:n,onChange:r}){const a=ue(S=>S.nodes),[o,l]=N.useState(null),c=N.useMemo(()=>{const S=new Set(n);return a.filter(w=>w.data.moduleType.startsWith("http.middleware.")&&w.id!==e&&!S.has(w.data.label)).map(w=>({id:w.id,label:w.data.label}))},[a,e,n]),d=N.useCallback(S=>{r(n.filter((w,C)=>C!==S))},[n,r]),p=N.useCallback(S=>{r([...n,S])},[n,r]),h=S=>{l(S)},g=(S,w)=>{if(S.preventDefault(),o===null||o===w)return;const C=[...n],[_]=C.splice(o,1);C.splice(w,0,_),l(w),r(C)},y=()=>{l(null)},m=S=>{if(S===0)return;const w=[...n];[w[S-1],w[S]]=[w[S],w[S-1]],r(w)},b=S=>{if(S>=n.length-1)return;const w=[...n];[w[S],w[S+1]]=[w[S+1],w[S]],r(w)};return u.jsxs("div",{style:{marginBottom:16},children:[u.jsx("span",{style:{color:"#a6adc8",fontSize:11,display:"block",marginBottom:6,fontWeight:600},children:"Middleware Chain"}),n.length===0&&u.jsx("div",{style:{color:"#585b70",fontSize:11,marginBottom:6},children:"No middleware attached. Add middleware below."}),n.map((S,w)=>u.jsxs("div",{draggable:!0,onDragStart:()=>h(w),onDragOver:C=>g(C,w),onDragEnd:y,style:{display:"flex",alignItems:"center",gap:4,padding:"4px 6px",marginBottom:2,background:o===w?"#313244":"#1e1e2e",borderRadius:4,border:"1px solid #313244",cursor:"grab",fontSize:11},children:[u.jsx("span",{style:{width:18,height:18,borderRadius:"50%",background:"#fab387",color:"#1e1e2e",display:"flex",alignItems:"center",justifyContent:"center",fontSize:10,fontWeight:700,flexShrink:0},children:w+1}),u.jsx("span",{style:{flex:1,color:"#cdd6f4",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:S}),u.jsx("button",{onClick:()=>m(w),disabled:w===0,style:tT,title:"Move up",children:"▲"}),u.jsx("button",{onClick:()=>b(w),disabled:w>=n.length-1,style:tT,title:"Move down",children:"▼"}),u.jsx("button",{onClick:()=>d(w),style:{background:"none",border:"none",color:"#f38ba8",cursor:"pointer",fontSize:11,padding:"0 2px"},title:"Remove",children:"x"})]},`${S}-${w}`)),c.length>0&&u.jsxs("div",{style:{marginTop:6},children:[u.jsx("span",{style:{color:"#585b70",fontSize:10,display:"block",marginBottom:4},children:"Available middleware:"}),u.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:4},children:c.map(S=>u.jsxs("button",{onClick:()=>p(S.label),style:{padding:"2px 8px",background:"#313244",border:"1px solid #45475a",borderRadius:4,color:"#fab387",cursor:"pointer",fontSize:10,fontWeight:500},title:`Add ${S.label} to chain`,children:["+ ",S.label]},S.id))})]})]})}const tT={background:"none",border:"none",color:"#6c7086",cursor:"pointer",fontSize:8,padding:"0 2px",lineHeight:1},_P={width:"100%",padding:"6px 8px",background:"#1e1e2e",border:"1px solid #313244",borderRadius:4,color:"#cdd6f4",fontSize:12,outline:"none",boxSizing:"border-box"};function kP({value:e,onChange:n,projectId:r,placeholder:a,description:o}){const[l,c]=N.useState(!1),[d,p]=N.useState([]),[h,g]=N.useState(""),[y,m]=N.useState(!1),[b,S]=N.useState(!1),w=r||"default",C=N.useCallback(async T=>{m(!0);try{const E=localStorage.getItem("auth_token"),z={};E&&(z.Authorization=`Bearer ${E}`);const A=T?`?prefix=${encodeURIComponent(T)}`:"",M=await fetch(`/api/v1/workspaces/${w}/files${A}`,{headers:z});if(M.ok){const O=await M.json();p(O||[])}else p([])}catch{p([])}finally{m(!1)}},[w]);N.useEffect(()=>{l&&C(h)},[l,h,C]);const _=async T=>{const E=T.target.files?.[0];if(E){S(!0);try{const z=localStorage.getItem("auth_token"),A={};z&&(A.Authorization=`Bearer ${z}`);const M=new FormData;M.append("file",E),h&&M.append("path",h+"/"+E.name);const O=await fetch(`/api/v1/workspaces/${w}/files`,{method:"POST",headers:A,body:M});if(O.ok){const P=await O.json();n(P.path||E.name),C(h)}}finally{S(!1)}}},j=T=>{T.isDir?g(T.path):(n(T.path),c(!1))},k=()=>{const T=h.split("/").filter(Boolean);T.pop(),g(T.join("/"))};return u.jsxs("div",{children:[u.jsxs("div",{style:{display:"flex",gap:4},children:[u.jsx("input",{type:"text",value:e,onChange:T=>n(T.target.value),placeholder:a||"Select file...",style:{..._P,flex:1}}),u.jsx("button",{onClick:()=>c(!l),style:{background:"#313244",border:"1px solid #45475a",borderRadius:4,color:"#cdd6f4",cursor:"pointer",fontSize:11,padding:"4px 8px",whiteSpace:"nowrap"},children:l?"Close":"Browse"})]}),o&&u.jsx("span",{style:{color:"#585b70",fontSize:10,display:"block",marginTop:2},children:o}),l&&u.jsxs("div",{style:{background:"#1e1e2e",border:"1px solid #313244",borderRadius:4,marginTop:4,maxHeight:200,overflowY:"auto",fontSize:11},children:[u.jsxs("div",{style:{display:"flex",gap:4,padding:"4px 6px",borderBottom:"1px solid #313244",alignItems:"center"},children:[h&&u.jsx("button",{onClick:k,style:{background:"none",border:"none",color:"#89b4fa",cursor:"pointer",fontSize:11,padding:"2px 4px"},children:".. (up)"}),u.jsxs("span",{style:{color:"#585b70",fontSize:10,flex:1},children:["/",h]}),u.jsxs("label",{style:{background:"#313244",border:"1px solid #45475a",borderRadius:3,color:"#cdd6f4",cursor:"pointer",fontSize:10,padding:"2px 6px"},children:[b?"Uploading...":"Upload",u.jsx("input",{type:"file",onChange:_,style:{display:"none"},disabled:b})]})]}),y?u.jsx("div",{style:{padding:8,color:"#585b70",textAlign:"center"},children:"Loading..."}):d.length===0?u.jsx("div",{style:{padding:8,color:"#585b70",textAlign:"center"},children:"No files"}):d.map(T=>u.jsxs("div",{onClick:()=>j(T),style:{padding:"4px 8px",cursor:"pointer",display:"flex",justifyContent:"space-between",alignItems:"center",borderBottom:"1px solid #181825"},onMouseEnter:E=>E.currentTarget.style.background="#313244",onMouseLeave:E=>E.currentTarget.style.background="transparent",children:[u.jsxs("span",{style:{color:T.isDir?"#89b4fa":"#cdd6f4"},children:[T.isDir?"[dir] ":"",T.name]}),!T.isDir&&u.jsx("span",{style:{color:"#585b70",fontSize:10},children:CP(T.size)})]},T.path))]})]})}function CP(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}const EP=new Set(["SELECT","INSERT","UPDATE","DELETE","FROM","WHERE","SET","VALUES","INTO","JOIN","ON","AND","OR","NOT","ORDER","BY","GROUP","LIMIT","AS","CREATE","ALTER","DROP","TABLE","INDEX","IS","NULL","LIKE","IN","EXISTS","BETWEEN","CASE","WHEN","THEN","ELSE","END","HAVING","DISTINCT","COUNT","DEFAULT","PRIMARY","KEY","FOREIGN","REFERENCES","CASCADE","LEFT","RIGHT","INNER","OUTER","FULL","CROSS","UNION","ALL","ANY","SOME","ASC","DESC","OFFSET","FETCH","NEXT","ROWS","ONLY","WITH","RECURSIVE","RETURNING","CONFLICT","DO","NOTHING","SUM","AVG","MIN","MAX","COALESCE","IFNULL","NULLIF"]);function jP(e){const n=[];let r=0;for(;r${ci(o)}`),r+=o.length;continue}if(e[r]==="'"){let a=r+1;for(;a${ci(e.slice(r,a))}`),r=a;continue}if(e[r]==="{"&&e[r+1]==="{"){const a=e.indexOf("}}",r+2);if(a!==-1){const o=e.slice(r,a+2);n.push(`${ci(o)}`),r=a+2;continue}}if(e[r]==="?"){n.push('?'),r++;continue}if(/\d/.test(e[r])&&(r===0||/[\s,=(+\-*/]/.test(e[r-1]))){let a=r;for(;a${ci(e.slice(r,a))}`),r=a;continue}}if(/[a-zA-Z_]/.test(e[r])){let a=r;for(;a${ci(o)}`):n.push(ci(o)),r=a;continue}if(e[r]===` +`){n.push(` +`),r++;continue}n.push(ci(e[r])),r++}return n.join("")}function ci(e){return e.replace(/&/g,"&").replace(//g,">")}const nT={fontFamily:'ui-monospace, "Cascadia Code", "Source Code Pro", Menlo, monospace',fontSize:12,lineHeight:"1.5",padding:"8px",border:"1px solid #313244",borderRadius:4,whiteSpace:"pre-wrap",wordWrap:"break-word",overflowWrap:"break-word",tabSize:2,boxSizing:"border-box",width:"100%"};function TP({value:e,onChange:n,placeholder:r}){const a=N.useRef(null),o=N.useCallback(d=>{n(d.target.value)},[n]),l=N.useCallback(d=>{if(d.key==="Tab"){d.preventDefault();const p=d.currentTarget,h=p.selectionStart,g=p.selectionEnd,y=e.slice(0,h)+" "+e.slice(g);n(y),requestAnimationFrame(()=>{p.selectionStart=p.selectionEnd=h+2})}},[e,n]),c=jP(e);return u.jsxs("div",{style:{position:"relative",width:"100%"},children:[u.jsx("div",{"aria-hidden":!0,style:{...nT,position:"absolute",top:0,left:0,background:"#1e1e2e",color:"#cdd6f4",pointerEvents:"none",minHeight:"7.5em"},dangerouslySetInnerHTML:{__html:c||`${ci(r??"")}`}}),u.jsx("textarea",{ref:a,value:e,onChange:o,onKeyDown:l,placeholder:r,spellCheck:!1,rows:6,style:{...nT,position:"relative",background:"transparent",color:"transparent",caretColor:"#cdd6f4",resize:"vertical",outline:"none",minHeight:"7.5em",...e===""?{}:{}}})]})}function AP({value:e,onChange:n,placeholder:r,nodes:a,currentNodeId:o}){const[l,c]=N.useState(!1),d=vt(S=>S.services),p=vt(S=>S.servicesLoaded),h=vt(S=>S.fetchServices);N.useEffect(()=>{p||h()},[p,h]);const g=N.useMemo(()=>a.filter(S=>S.id!==o).map(S=>({name:S.data.label,source:"canvas",type:S.data.moduleType||"",implements:[]})),[a,o]),y=N.useMemo(()=>d.map(S=>({name:S.name,source:"server",type:S.type||"",implements:S.implements||[]})),[d]),m=N.useMemo(()=>{const S=new Set,w=[];for(const C of[...g,...y])S.has(C.name)||(S.add(C.name),w.push(C));return w.sort((C,_)=>C.name.localeCompare(_.name))},[g,y]),b={width:"100%",padding:"4px 8px",background:"#1e1e2e",border:"1px solid #313244",borderRadius:4,color:"#cdd6f4",fontSize:12,boxSizing:"border-box"};return u.jsxs("div",{style:{position:"relative"},children:[u.jsxs("div",{style:{display:"flex",gap:4},children:[u.jsx("input",{type:"text",value:e,onChange:S=>n(S.target.value),placeholder:r,style:{...b,flex:1}}),u.jsx("button",{onClick:()=>c(!l),style:{padding:"4px 8px",background:l?"#45475a":"#313244",border:"1px solid #45475a",borderRadius:4,color:"#cdd6f4",fontSize:11,cursor:"pointer"},title:"Pick a service",children:l?"▲":"▼"})]}),l&&u.jsx("div",{style:{marginTop:4,background:"#1e1e2e",border:"1px solid #313244",borderRadius:4,maxHeight:160,overflowY:"auto"},children:m.length===0?u.jsx("div",{style:{padding:"8px 10px",color:"#585b70",fontSize:11},children:"No services available"}):m.map(S=>u.jsxs("div",{onClick:()=>{n(S.name),c(!1)},style:{padding:"5px 10px",cursor:"pointer",fontSize:12,color:e===S.name?"#a6e3a1":"#cdd6f4",background:e===S.name?"#313244":"transparent",display:"flex",flexDirection:"column",gap:2},onMouseEnter:w=>{w.currentTarget.style.background="#313244"},onMouseLeave:w=>{w.currentTarget.style.background=e===S.name?"#313244":"transparent"},children:[u.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[u.jsx("span",{style:{fontSize:9,padding:"1px 4px",borderRadius:3,background:S.source==="canvas"?"#45475a":"#313244",color:S.source==="canvas"?"#89b4fa":"#a6adc8"},children:S.source==="canvas"?"node":"svc"}),S.name]}),(S.type||S.implements.length>0)&&u.jsxs("div",{style:{display:"flex",alignItems:"center",gap:4,paddingLeft:2},children:[S.type&&u.jsx("span",{style:{fontSize:9,fontFamily:"monospace",color:"#585b70"},children:S.type}),S.implements.map(w=>u.jsx("span",{style:{fontSize:8,padding:"0 3px",borderRadius:2,background:"#45475a",color:"#a6adc8"},children:w},w))]})]},S.name))})]})}const RP={"step.request_parse":[{name:"path_params",type:"map",description:"URL path parameters"},{name:"query_params",type:"map",description:"URL query parameters"},{name:"body",type:"object",description:"Request body (parsed JSON)"},{name:"headers",type:"map",description:"Request headers"},{name:"method",type:"string",description:"HTTP method"}],"step.set":[],"step.db_query":[{name:"row",type:"object",description:"Single result (mode: single)"},{name:"rows",type:"array",description:"All results (mode: list)"},{name:"found",type:"boolean",description:"Whether any rows matched"}],"step.db_exec":[{name:"rows_affected",type:"number",description:"Number of rows affected"},{name:"last_insert_id",type:"number",description:"Auto-increment ID of inserted row"}],"step.json_response":[],"step.conditional":[{name:"matched_route",type:"string",description:"Which route was matched"}],"step.http_call":[{name:"status",type:"number",description:"HTTP status code"},{name:"body",type:"object",description:"Response body"},{name:"headers",type:"map",description:"Response headers"}],"step.validate":[{name:"valid",type:"boolean",description:"Whether validation passed"}],"step.log":[],"step.publish":[],"step.delegate":[{name:"result",type:"any",description:"Delegate response"}],"step.transform":[{name:"result",type:"any",description:"Transform output"}]},rT={string:"#a6e3a1",number:"#fab387",boolean:"#89b4fa",object:"#cba6f7",array:"#f9e2af",map:"#f38ba8",any:"#585b70"};function gA(e){return e.startsWith("step.")?e:"step."+e}function zP(e){const n=gA(e.type);if(n==="step.set"&&e.config?.values){const r=e.config.values;return Object.keys(r).map(a=>({name:a,type:"any",description:`Set value: ${String(r[a]).slice(0,30)}`}))}return RP[n]??[]}function iT(e){return!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(e)}function NP(e,n){return n.type==="map"?`{{index .steps "${e}" "${n.name}" "?"}}`:iT(e)||iT(n.name)?`{{index .steps "${e}" "${n.name}"}}`:`{{ .steps.${e}.${n.name} }}`}function K0({precedingSteps:e,onSelect:n}){const[r,a]=N.useState(!1),[o,l]=N.useState(new Set),c=N.useRef(null),d=N.useRef(null);N.useEffect(()=>{if(!r)return;const y=b=>{c.current&&!c.current.contains(b.target)&&d.current&&!d.current.contains(b.target)&&a(!1)},m=b=>{b.key==="Escape"&&a(!1)};return document.addEventListener("mousedown",y),document.addEventListener("keydown",m),()=>{document.removeEventListener("mousedown",y),document.removeEventListener("keydown",m)}},[r]);const p=y=>{l(m=>{const b=new Set(m);return b.has(y)?b.delete(y):b.add(y),b})},h=(y,m)=>{n(NP(y,m)),a(!1)},g=y=>{n(y),a(!1)};return e.length>0,u.jsxs("div",{style:{position:"relative",display:"inline-flex"},children:[u.jsx("button",{ref:d,onClick:()=>a(y=>!y),style:{background:r?"#313244":"transparent",border:"1px solid #45475a",borderRadius:4,color:r?"#cba6f7":"#585b70",cursor:"pointer",fontSize:11,padding:"2px 6px",fontFamily:'ui-monospace, "Cascadia Code", "Source Code Pro", Menlo, monospace',lineHeight:"16px",transition:"color 0.15s, background 0.15s"},title:"Insert field reference",children:"{ }"}),r&&u.jsxs("div",{ref:c,style:{position:"absolute",top:"100%",right:0,marginTop:4,width:280,maxHeight:300,overflowY:"auto",background:"#1e1e2e",border:"1px solid #313244",borderRadius:6,zIndex:1e3,boxShadow:"0 4px 12px rgba(0,0,0,0.4)"},children:[u.jsx("div",{style:{padding:"6px 10px",borderBottom:"1px solid #313244",color:"#a6adc8",fontSize:10,fontWeight:600},children:"Insert Field Reference"}),e.map((y,m)=>{const b=zP(y),S=o.has(m);return b.length===0?null:u.jsxs("div",{children:[u.jsxs("div",{onClick:()=>p(m),style:{display:"flex",alignItems:"center",gap:6,padding:"5px 10px",cursor:"pointer",borderBottom:"1px solid #181825",background:S?"#181825":"transparent"},onMouseEnter:w=>{w.currentTarget.style.background="#181825"},onMouseLeave:w=>{S||(w.currentTarget.style.background="transparent")},children:[u.jsx("span",{style:{fontSize:7,color:"#585b70",transition:"transform 0.15s",transform:S?"rotate(90deg)":"rotate(0deg)"},children:"▶"}),u.jsx("span",{style:{background:"#cba6f720",color:"#cba6f7",fontSize:9,fontWeight:700,padding:"1px 5px",borderRadius:4,flexShrink:0},children:m+1}),u.jsx("span",{style:{color:"#cdd6f4",fontSize:11,fontWeight:500,flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:y.name}),u.jsx("span",{style:{color:"#585b70",fontSize:9},children:gA(y.type).replace("step.","")})]}),S&&u.jsx("div",{style:{padding:"2px 0"},children:b.map(w=>u.jsxs("div",{onClick:()=>h(y.name,w),style:{display:"flex",alignItems:"center",gap:6,padding:"4px 10px 4px 32px",cursor:"pointer",fontSize:11},onMouseEnter:C=>{C.currentTarget.style.background="#313244"},onMouseLeave:C=>{C.currentTarget.style.background="transparent"},children:[u.jsx("span",{style:{color:"#cdd6f4",fontWeight:600,fontFamily:"monospace",fontSize:10},children:w.name}),u.jsx("span",{style:{background:(rT[w.type]??"#585b70")+"20",color:rT[w.type]??"#585b70",fontSize:8,padding:"0 4px",borderRadius:3,fontWeight:600,flexShrink:0},children:w.type}),w.description&&u.jsx("span",{style:{color:"#585b70",fontSize:9,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flex:1},children:w.description})]},w.name))})]},`${y.name}-${m}`)}),u.jsxs("div",{style:{borderTop:e.length>0?"1px solid #313244":void 0},children:[u.jsx("div",{style:{padding:"5px 10px",color:"#585b70",fontSize:9,fontWeight:600,textTransform:"uppercase",letterSpacing:.5},children:"Built-in"}),u.jsxs("div",{onClick:()=>g("{{ uuidv4 }}"),style:{display:"flex",alignItems:"center",gap:6,padding:"4px 10px 4px 20px",cursor:"pointer",fontSize:11},onMouseEnter:y=>{y.currentTarget.style.background="#313244"},onMouseLeave:y=>{y.currentTarget.style.background="transparent"},children:[u.jsx("span",{style:{color:"#cdd6f4",fontWeight:600,fontFamily:"monospace",fontSize:10},children:"uuidv4"}),u.jsx("span",{style:{background:"#a6e3a120",color:"#a6e3a1",fontSize:8,padding:"0 4px",borderRadius:3,fontWeight:600},children:"string"}),u.jsx("span",{style:{color:"#585b70",fontSize:9},children:"Generate UUID"})]}),u.jsxs("div",{onClick:()=>g("{{ now }}"),style:{display:"flex",alignItems:"center",gap:6,padding:"4px 10px 4px 20px",cursor:"pointer",fontSize:11,marginBottom:4},onMouseEnter:y=>{y.currentTarget.style.background="#313244"},onMouseLeave:y=>{y.currentTarget.style.background="transparent"},children:[u.jsx("span",{style:{color:"#cdd6f4",fontWeight:600,fontFamily:"monospace",fontSize:10},children:"now"}),u.jsx("span",{style:{background:"#a6e3a120",color:"#a6e3a1",fontSize:8,padding:"0 4px",borderRadius:3,fontWeight:600},children:"string"}),u.jsx("span",{style:{color:"#585b70",fontSize:9},children:"Current timestamp"})]})]})]})]})}const aT=[{value:"validate",label:"Validate"},{value:"transform",label:"Transform"},{value:"conditional",label:"Conditional"},{value:"set",label:"Set Values"},{value:"log",label:"Log"},{value:"publish",label:"Publish Event"},{value:"http_call",label:"HTTP Call"},{value:"delegate",label:"Delegate"},{value:"db_query",label:"DB Query"},{value:"db_exec",label:"DB Exec"},{value:"request_parse",label:"Request Parse"},{value:"json_response",label:"JSON Response"}],oT={"step.request_parse":"start","step.validate":"middleware","step.conditional":"middleware","step.set":"transform","step.transform":"transform","step.log":"middleware","step.db_query":"action","step.db_exec":"action","step.http_call":"action","step.delegate":"action","step.publish":"action","step.json_response":"end"},sT={start:"#a6e3a1",middleware:"#89b4fa",transform:"#fab387",action:"#cba6f7",end:"#f38ba8"},MP={start:"▶",middleware:"◆",transform:"⟳",action:"⚡",end:"■"},OP={start:"Start",middleware:"Middleware",transform:"Transform",action:"Action",end:"Response"};function lT(e){return oT["step."+e]??oT[e]??"action"}function DP(e){if(!e.config)return"";const n=e.type;if(n==="delegate"||n==="step.delegate")return e.config.service?`→ ${e.config.service}`:"";if(n==="db_exec"||n==="db_query"||n==="step.db_exec"||n==="step.db_query"){const r=String(e.config.query??"");return r.length>35?r.slice(0,35)+"...":r}if(n==="set"||n==="step.set"){const r=e.config.values;if(r&&typeof r=="object"&&!Array.isArray(r)){const a=Object.keys(r);return a.length>0?a.join(", "):""}return""}return n==="json_response"||n==="step.json_response"?e.config.status?`${e.config.status}`:"":(n==="validate"||n==="step.validate")&&e.config.schema?"schema":""}const ut=20,$n=6,h0=38;function cT({color:e,prevColor:n}){const r=`notch-grad-${e}-${n}`.replace(/#/g,"");return u.jsx("div",{style:{display:"flex",justifyContent:"center",height:$n,marginTop:-1,position:"relative",zIndex:1},children:u.jsxs("svg",{width:ut+8,height:$n,viewBox:`0 0 ${ut+8} ${$n}`,style:{display:"block"},children:[u.jsx("defs",{children:u.jsxs("linearGradient",{id:r,x1:"0",y1:"0",x2:"0",y2:"1",children:[u.jsx("stop",{offset:"0%",stopColor:n,stopOpacity:.6}),u.jsx("stop",{offset:"100%",stopColor:e,stopOpacity:.6})]})}),u.jsx("path",{d:`M0,0 L${(ut+8-ut)/2},0 L${(ut+8-ut)/2+2},${$n} L${(ut+8+ut)/2-2},${$n} L${(ut+8+ut)/2},0 L${ut+8},0`,fill:"none",stroke:`url(#${r})`,strokeWidth:2})]})})}function uT({color:e}){return u.jsx("div",{style:{display:"flex",justifyContent:"center",height:$n,marginBottom:-1,position:"relative",zIndex:2},children:u.jsx("svg",{width:ut+8,height:$n,viewBox:`0 0 ${ut+8} ${$n}`,style:{display:"block"},children:u.jsx("path",{d:`M${(ut+8-ut)/2},0 L${(ut+8-ut)/2+2},${$n} L${(ut+8+ut)/2-2},${$n} L${(ut+8+ut)/2},0`,fill:e+"30",stroke:e+"60",strokeWidth:1})})})}function dT({steps:e,onChange:n}){const[r,a]=N.useState(!1),[o,l]=N.useState(!1),[c,d]=N.useState(null),[p,h]=N.useState(""),[g,y]=N.useState("validate"),[m,b]=N.useState(""),[S,w]=N.useState(null),[C,_]=N.useState(null),j=N.useRef(null),k=B=>{const D=j.current;if(D){const q=D.selectionStart,$=D.selectionEnd,K=m.slice(0,q)+B+m.slice($);b(K),requestAnimationFrame(()=>{D.selectionStart=D.selectionEnd=q+B.length,D.focus()})}else b(m+B)},T=()=>{if(!p.trim())return;let B;if(m.trim())try{B=JSON.parse(m)}catch{B=void 0}n([...e,{name:p.trim(),type:g,config:B}]),M()},E=()=>{if(c===null||!p.trim())return;let B;if(m.trim())try{B=JSON.parse(m)}catch{B=void 0}const D=e.map((q,$)=>$===c?{name:p.trim(),type:g,config:B}:q);n(D),M()},z=B=>{n(e.filter((D,q)=>q!==B))},A=B=>{const D=e[B];d(B),h(D.name);const q=D.type.startsWith("step.")?D.type.slice(5):D.type;y(q),b(D.config?JSON.stringify(D.config,null,2):""),l(!1)},M=()=>{l(!1),d(null),h(""),y("validate"),b("")},O=B=>{const D=B.startsWith("step.")?B.slice(5):B;return aT.find(q=>q.value===D)?.label??B},P=N.useCallback((B,D)=>{w(D),B.dataTransfer.effectAllowed="move",B.dataTransfer.setData("text/plain",String(D)),B.currentTarget instanceof HTMLElement&&(B.currentTarget.style.opacity="0.5")},[]),L=N.useCallback(B=>{B.currentTarget instanceof HTMLElement&&(B.currentTarget.style.opacity="1"),w(null),_(null)},[]),I=N.useCallback((B,D)=>{B.preventDefault(),B.dataTransfer.dropEffect="move",_(D)},[]),F=N.useCallback((B,D)=>{B.preventDefault();const q=S;if(q===null||q===D){w(null),_(null);return}const $=[...e],[K]=$.splice(q,1);$.splice(D,0,K),n($),w(null),_(null)},[S,e,n]);return u.jsxs("div",{style:{marginTop:4},children:[u.jsxs("div",{onClick:()=>a(B=>!B),style:{display:"flex",alignItems:"center",gap:4,cursor:"pointer",fontSize:10,color:"#585b70",userSelect:"none"},children:[u.jsx("span",{style:{fontSize:8,transition:"transform 0.15s",transform:r?"rotate(90deg)":"rotate(0deg)"},children:"▶"}),u.jsx("span",{children:"Pipeline"}),e.length>0&&u.jsxs("span",{style:{background:"#e879f920",color:"#e879f9",padding:"0 5px",borderRadius:6,fontSize:9},children:[e.length," step",e.length!==1?"s":""]}),u.jsx("button",{onClick:B=>{B.stopPropagation(),l(!0),d(null),a(!0)},style:{marginLeft:"auto",background:"#313244",border:"1px solid #45475a",borderRadius:3,color:"#e879f9",cursor:"pointer",fontSize:9,padding:"0 4px"},title:"Add pipeline step",children:"+"})]}),r&&u.jsxs("div",{style:{marginTop:4,background:"#181825",border:"1px solid #313244",borderRadius:6,padding:"6px 6px 6px 10px",position:"relative"},children:[e.length>1&&u.jsx("div",{style:{position:"absolute",left:12,top:h0/2+6,bottom:o?60:h0/2+6,width:2,background:"linear-gradient(to bottom, #a6e3a140, #f38ba840)",borderRadius:1,zIndex:0}}),e.map((B,D)=>{const q=lT(B.type),$=sT[q],K=MP[q],ne=OP[q],V=DP(B),W=D===0,ee=D===e.length-1,G=D>0?lT(e[D-1].type):q,X=D>0?sT[G]:$,Q=S===D,ie=C===D&&S!==D;return c===D?u.jsxs("div",{style:{position:"relative",zIndex:1},children:[!W&&u.jsx(cT,{color:$,prevColor:X}),u.jsx("div",{style:{background:"#1e1e2e",borderLeft:`3px solid ${$}`,borderRadius:6,padding:6,marginLeft:12},children:U(!0)}),!ee&&u.jsx(uT,{color:$})]},`edit-${D}`):u.jsxs("div",{style:{position:"relative",zIndex:1},draggable:!0,onDragStart:se=>P(se,D),onDragEnd:L,onDragOver:se=>I(se,D),onDrop:se=>F(se,D),children:[!W&&u.jsx(cT,{color:$,prevColor:X}),u.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,padding:"4px 6px",minHeight:h0,background:ie?"#313244":Q?"#1e1e2e80":"#1e1e2e",borderLeft:`3px solid ${$}`,borderTop:W?`1px solid ${$}40`:void 0,borderBottom:ee?`1px solid ${$}40`:void 0,borderRight:`1px solid ${$}20`,borderRadius:W&&ee?6:W?"6px 6px 2px 2px":ee?"2px 2px 6px 6px":"2px",marginLeft:12,position:"relative",transition:"background 0.15s, box-shadow 0.15s",boxShadow:ie?`0 0 0 1px ${$}60, 0 2px 8px ${$}20`:Q?"0 4px 12px rgba(0,0,0,0.4)":"none",cursor:"grab"},onMouseEnter:se=>{Q||(se.currentTarget.style.background="#242438")},onMouseLeave:se=>{Q||(se.currentTarget.style.background="#1e1e2e")},children:[u.jsx("div",{style:{position:"absolute",left:-16,top:"50%",transform:"translateY(-50%)",width:8,height:8,borderRadius:"50%",background:$,border:"2px solid #181825",zIndex:2}}),u.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:1,cursor:"grab",opacity:.3,flexShrink:0,padding:"0 2px"},title:"Drag to reorder",children:[u.jsx("div",{style:{width:6,height:1.5,background:"#585b70",borderRadius:1}}),u.jsx("div",{style:{width:6,height:1.5,background:"#585b70",borderRadius:1}}),u.jsx("div",{style:{width:6,height:1.5,background:"#585b70",borderRadius:1}})]}),u.jsx("div",{style:{width:20,height:20,borderRadius:5,background:$+"20",color:$,display:"flex",alignItems:"center",justifyContent:"center",fontSize:10,flexShrink:0,border:`1px solid ${$}30`},title:ne,children:K}),u.jsxs("div",{style:{flex:1,minWidth:0,overflow:"hidden"},children:[u.jsx("div",{style:{color:"#cdd6f4",fontWeight:600,fontSize:11,lineHeight:"14px",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:B.name}),u.jsx("div",{style:{color:$,fontSize:9,lineHeight:"11px",opacity:.7},children:O(B.type)})]}),V&&u.jsx("span",{style:{color:"#585b70",fontSize:9,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",maxWidth:80,flexShrink:1},title:V,children:V}),u.jsxs("div",{style:{display:"flex",alignItems:"center",gap:2,flexShrink:0},children:[u.jsx("button",{onClick:se=>{se.stopPropagation(),A(D)},style:{...fT,opacity:.5},title:"Edit step",children:"✎"}),u.jsx("button",{onClick:se=>{se.stopPropagation(),z(D)},style:{...fT,color:"#f38ba8",opacity:.6},title:"Delete step",children:"✕"})]})]}),!ee&&u.jsx(uT,{color:$})]},`${B.name}-${D}`)}),o&&u.jsx("div",{style:{padding:6,borderTop:e.length>0?"1px solid #313244":void 0,marginTop:e.length>0?6:0,marginLeft:12},children:U(!1)}),e.length===0&&!o&&u.jsx("div",{style:{padding:"6px 4px",color:"#585b70",fontSize:10,textAlign:"center"},children:"No pipeline steps"})]})]});function U(B){const D=B&&c!==null?c:e.length,q=e.slice(0,D).map($=>({name:$.name,type:$.type,config:$.config}));return u.jsxs(u.Fragment,{children:[u.jsxs("div",{style:{display:"flex",gap:4,marginBottom:4},children:[u.jsx("select",{value:g,onChange:$=>y($.target.value),style:{...g0,width:100,flexShrink:0},children:aT.map($=>u.jsx("option",{value:$.value,children:$.label},$.value))}),u.jsx("input",{value:p,onChange:$=>h($.target.value),placeholder:"Step name...",style:{...g0,flex:1},autoFocus:!0,onKeyDown:$=>{$.key==="Enter"&&(B?E():T()),$.key==="Escape"&&M()}})]}),u.jsxs("div",{style:{position:"relative"},children:[q.length>0&&u.jsx("div",{style:{display:"flex",justifyContent:"flex-end",marginBottom:3},children:u.jsx(K0,{precedingSteps:q,onSelect:$=>k($)})}),u.jsx("textarea",{ref:j,value:m,onChange:$=>b($.target.value),placeholder:'{"key": "value"}',rows:3,style:{...g0,width:"100%",resize:"vertical",fontFamily:"monospace",fontSize:10,marginBottom:4}})]}),u.jsxs("div",{style:{display:"flex",gap:4,justifyContent:"flex-end"},children:[u.jsx("button",{onClick:M,style:qP,children:"Cancel"}),u.jsx("button",{onClick:B?E:T,style:IP,children:B?"Save":"Add"})]})]})}}const g0={padding:"3px 5px",background:"#1e1e2e",border:"1px solid #313244",borderRadius:3,color:"#cdd6f4",fontSize:10,outline:"none",boxSizing:"border-box"},fT={background:"none",border:"none",color:"#585b70",cursor:"pointer",fontSize:8,padding:"0 1px",lineHeight:1},qP={background:"#313244",border:"1px solid #45475a",borderRadius:3,color:"#a6adc8",cursor:"pointer",fontSize:9,padding:"2px 8px"},IP={background:"#e879f930",border:"1px solid #e879f950",borderRadius:3,color:"#e879f9",cursor:"pointer",fontSize:9,padding:"2px 8px"};function LP(e,n,r,a){if(!e.inheritFrom)return null;const o=e.inheritFrom.indexOf(".");if(o<0)return null;const l=e.inheritFrom.slice(0,o),c=e.inheritFrom.slice(o+1);if(!l||!c)return null;for(const d of r){if(d.target!==n||(d.data?.edgeType??"dependency")!==l)continue;const g=a.find(m=>m.id===d.source);if(!g)continue;if(c==="name")return{value:g.data.label,sourceName:g.data.label};const y=g.data.config[c];if(y!==void 0)return{value:y,sourceName:g.data.label}}return null}function BP(){const e=ue(E=>E.nodes),n=ue(E=>E.edges),r=ue(E=>E.selectedNodeId),a=ue(E=>E.updateNodeConfig),o=ue(E=>E.updateNodeName),l=ue(E=>E.removeNode),c=ue(E=>E.setSelectedNode),d=vt(E=>E.moduleTypeMap),p=vt(E=>E.fetchSchemas),h=vt(E=>E.loaded);N.useEffect(()=>{h||p()},[h,p]);const g=e.find(E=>E.id===r),y=g?d[g.data.moduleType]:void 0,m=N.useMemo(()=>y?.configFields??[],[y]),b=N.useMemo(()=>{if(!g||!g.data.moduleType.startsWith("step."))return[];const E=n.filter(P=>P.data?.edgeType==="pipeline-flow");if(E.length===0)return[];const z=new Map;for(const P of E)z.set(P.target,P.source);const A=[];let M=z.get(g.id);const O=new Set;for(;M&&!O.has(M);){O.add(M);const P=e.find(L=>L.id===M);P&&P.data.moduleType.startsWith("step.")&&A.unshift({name:P.data.label,type:P.data.moduleType,config:P.data.config}),M=z.get(M)}return A},[g,n,e]),S=N.useMemo(()=>{const E={};if(!g)return E;for(const z of m){if(!z.inheritFrom)continue;const A=LP(z,g.id,n,e);A&&(E[z.key]=A)}return E},[g,m,n,e]),[w,C]=N.useState(new Set),_=N.useRef({}),j=N.useCallback((E,z)=>{S[E]&&C(A=>new Set(A).add(E)),g&&a(g.id,{[E]:z})},[S,g,a]),k=N.useCallback((E,z,A)=>{const M=_.current[E];if(M){const O=M.selectionStart??A.length,P=M.selectionEnd??O,L=A.slice(0,O)+z+A.slice(P);j(E,L),requestAnimationFrame(()=>{M.focus();const I=O+z.length;M.selectionStart=M.selectionEnd=I})}else j(E,A+z)},[j]);if(!g)return u.jsx("div",{style:{width:"100%",background:"#181825",padding:16,color:"#585b70",fontSize:13,display:"flex",alignItems:"center",justifyContent:"center",height:"100%",boxSizing:"border-box"},children:"Select a node to edit its properties"});const T=y?Wn[y.category]:"#64748b";return u.jsxs("div",{style:{width:"100%",background:"#181825",overflowY:"auto",height:"100%",fontSize:12,color:"#cdd6f4"},children:[u.jsxs("div",{style:{padding:"12px 16px",borderBottom:"1px solid #313244",display:"flex",alignItems:"center",justifyContent:"space-between"},children:[u.jsx("span",{style:{fontWeight:700,fontSize:14},children:"Properties"}),u.jsx("button",{onClick:()=>c(null),style:{background:"none",border:"none",color:"#585b70",cursor:"pointer",fontSize:16,padding:"0 4px"},children:"x"})]}),u.jsxs("div",{style:{padding:16},children:[u.jsxs("label",{style:{display:"block",marginBottom:12},children:[u.jsx("span",{style:{color:"#a6adc8",fontSize:11,display:"block",marginBottom:4},children:"Name"}),u.jsx("input",{value:g.data.label,onChange:E=>o(g.id,E.target.value),style:ao})]}),u.jsxs("div",{style:{marginBottom:16},children:[u.jsx("span",{style:{color:"#a6adc8",fontSize:11,display:"block",marginBottom:4},children:"Type"}),u.jsx("span",{style:{background:`${T}20`,color:T,padding:"3px 8px",borderRadius:4,fontSize:11,fontWeight:500},children:g.data.moduleType})]}),m.length>0&&u.jsxs("div",{style:{marginBottom:16},children:[u.jsx("span",{style:{color:"#a6adc8",fontSize:11,display:"block",marginBottom:8,fontWeight:600},children:"Configuration"}),m.map(E=>{const z=S[E.key],A=w.has(E.key),M=g.data.config[E.key]!==void 0&&g.data.config[E.key]!==""&&g.data.config[E.key]!==null,O=z&&!A&&!M,P=M?g.data.config[E.key]:O?z?.value:g.data.config[E.key]??E.defaultValue,L=O?{...ao,fontStyle:"italic",color:"#a6e3a1",opacity:.8}:ao;return u.jsxs("label",{style:{display:"block",marginBottom:10},children:[u.jsxs("span",{style:{color:"#a6adc8",fontSize:11,display:"flex",alignItems:"center",marginBottom:3,gap:4},children:[u.jsxs("span",{children:[E.label,E.required&&u.jsx("span",{style:{color:"#f38ba8",marginLeft:2},children:"*"})]}),z&&!A&&u.jsxs("span",{style:{color:"#a6e3a1",fontSize:9,cursor:"pointer"},title:`Click to override inherited value from ${z.sourceName}`,onClick:()=>C(I=>new Set(I).add(E.key)),children:["inherited from ",z.sourceName]}),z&&A&&u.jsx("span",{style:{color:"#fab387",fontSize:9,cursor:"pointer"},title:"Click to restore inherited value",onClick:()=>{C(I=>{const F=new Set(I);return F.delete(E.key),F}),a(g.id,{[E.key]:void 0})},children:"overridden"})]}),E.type==="select"?u.jsxs("select",{value:String(P??""),onChange:I=>j(E.key,I.target.value),style:L,children:[u.jsx("option",{value:"",children:"--"}),E.options?.map(I=>u.jsx("option",{value:I,children:I},I))]}):E.type==="number"?u.jsx("input",{type:"number",value:String(P??""),onChange:I=>j(E.key,Number(I.target.value)),placeholder:E.placeholder,style:L}):E.type==="boolean"?u.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[u.jsx("input",{type:"checkbox",checked:!!(P??!1),onChange:I=>j(E.key,I.target.checked)}),E.description&&u.jsx("span",{style:{color:"#585b70",fontSize:10},children:E.description})]}):E.type==="array"?u.jsx(xP,{label:E.label,value:P??[],onChange:I=>j(E.key,I),itemType:E.arrayItemType,placeholder:E.placeholder}):E.type==="map"?u.jsx(SP,{label:E.label,value:P??{},onChange:I=>j(E.key,I),valueType:E.mapValueType,placeholder:E.placeholder}):E.type==="json"?u.jsx("textarea",{value:typeof P=="string"?P:JSON.stringify(P??"",null,2),onChange:I=>{try{j(E.key,JSON.parse(I.target.value))}catch{j(E.key,I.target.value)}},rows:4,placeholder:E.placeholder,style:{...L,resize:"vertical",fontFamily:"monospace"}}):E.type==="filepath"?u.jsx(kP,{value:String(P??""),onChange:I=>j(E.key,I),placeholder:E.placeholder,description:E.description}):E.type==="sql"?u.jsxs("div",{children:[b.length>0&&u.jsx("div",{style:{display:"flex",justifyContent:"flex-end",marginBottom:4},children:u.jsx(K0,{precedingSteps:b,onSelect:I=>k(E.key,I,String(P??""))})}),u.jsx(TP,{value:String(P??""),onChange:I=>j(E.key,I),placeholder:E.placeholder})]}):E.inheritFrom==="dependency.name"?u.jsx(AP,{value:String(P??""),onChange:I=>j(E.key,I),placeholder:E.placeholder,nodes:e,currentNodeId:g.id}):E.sensitive?u.jsx(HP,{value:String(P??""),onChange:I=>j(E.key,I),placeholder:E.placeholder}):b.length>0&&g.data.moduleType.startsWith("step.")?u.jsxs("div",{style:{display:"flex",gap:4,alignItems:"center"},children:[u.jsx("input",{ref:I=>{_.current[E.key]=I},type:"text",value:String(P??""),onChange:I=>j(E.key,I.target.value),placeholder:E.placeholder,style:{...L,flex:1}}),u.jsx(K0,{precedingSteps:b,onSelect:I=>k(E.key,I,String(P??""))})]}):u.jsx("input",{type:"text",value:String(P??""),onChange:I=>j(E.key,I.target.value),placeholder:E.placeholder,style:L}),E.description&&E.type!=="boolean"&&u.jsx("span",{style:{color:"#585b70",fontSize:10,display:"block",marginTop:2},children:E.description})]},E.key)})]}),y?.ioSignature&&(y.ioSignature.inputs.length>0||y.ioSignature.outputs.length>0)&&u.jsxs("div",{style:{marginBottom:16},children:[u.jsx("span",{style:{color:"#a6adc8",fontSize:11,display:"block",marginBottom:8,fontWeight:600},children:"I/O Ports"}),y.ioSignature.inputs.length>0&&u.jsxs("div",{style:{marginBottom:6},children:[u.jsx("span",{style:{color:"#585b70",fontSize:10,display:"block",marginBottom:2},children:"Inputs"}),y.ioSignature.inputs.map(E=>u.jsxs("div",{style:{display:"flex",gap:4,alignItems:"center",fontSize:11,padding:"1px 0"},children:[u.jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:T,opacity:.6}}),u.jsx("span",{style:{color:"#cdd6f4"},children:E.name}),u.jsx("span",{style:{color:"#585b70"},children:E.type})]},E.name))]}),y.ioSignature.outputs.length>0&&u.jsxs("div",{children:[u.jsx("span",{style:{color:"#585b70",fontSize:10,display:"block",marginBottom:2},children:"Outputs"}),y.ioSignature.outputs.map(E=>u.jsxs("div",{style:{display:"flex",gap:4,alignItems:"center",fontSize:11,padding:"1px 0"},children:[u.jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:T,opacity:.6}}),u.jsx("span",{style:{color:"#cdd6f4"},children:E.name}),u.jsx("span",{style:{color:"#585b70"},children:E.type})]},E.name))]})]}),(g.data.handlerRoutes||g.data.moduleType==="api.query"||g.data.moduleType==="api.command")&&u.jsx($P,{routes:g.data.handlerRoutes??[],nodeId:g.id,color:T,delegate:String(g.data.config?.delegate??"")}),g.data.moduleType==="conditional.switch"&&u.jsx(UP,{cases:g.data.config?.cases??[],onChange:E=>a(g.id,{cases:E})}),g.data.moduleType==="conditional.expression"&&u.jsx(FP,{outputs:g.data.config?.outputs??[],onChange:E=>a(g.id,{outputs:E})}),g.data.moduleType==="http.router"&&u.jsx(wP,{nodeId:g.id,middlewareChain:g.data.config?.middlewareChain??[],onChange:E=>a(g.id,{middlewareChain:E})}),u.jsx("button",{onClick:()=>{l(g.id)},style:{width:"100%",padding:"8px 12px",background:"#45475a",border:"1px solid #585b70",borderRadius:6,color:"#f38ba8",cursor:"pointer",fontSize:12,fontWeight:500},children:"Delete Node"})]})]})}function HP({value:e,onChange:n,placeholder:r}){const[a,o]=N.useState(!1);return u.jsxs("div",{style:{position:"relative"},children:[u.jsx("input",{type:a?"text":"password",value:e,onChange:l=>n(l.target.value),placeholder:r,style:{...ao,paddingRight:30}}),u.jsx("button",{type:"button",onClick:()=>o(l=>!l),style:{position:"absolute",right:4,top:"50%",transform:"translateY(-50%)",background:"none",border:"none",color:"#585b70",cursor:"pointer",fontSize:11,padding:"2px 4px"},title:a?"Hide value":"Show value",children:a?"hide":"show"})]})}function UP({cases:e,onChange:n}){const[r,a]=N.useState("");return u.jsxs("div",{style:{marginBottom:16},children:[u.jsx("span",{style:{color:"#a6adc8",fontSize:11,display:"block",marginBottom:6,fontWeight:600},children:"Switch Cases"}),e.map((o,l)=>u.jsxs("div",{style:{display:"flex",gap:4,marginBottom:4,alignItems:"center"},children:[u.jsx("span",{style:{color:"#cdd6f4",fontSize:11,flex:1},children:o}),u.jsx("button",{onClick:()=>n(e.filter((c,d)=>d!==l)),style:{background:"none",border:"none",color:"#f38ba8",cursor:"pointer",fontSize:11,padding:"0 4px"},children:"x"})]},l)),u.jsxs("div",{style:{display:"flex",gap:4},children:[u.jsx("input",{value:r,onChange:o=>a(o.target.value),placeholder:"Add case...",style:{...ao,flex:1},onKeyDown:o=>{o.key==="Enter"&&r.trim()&&(n([...e,r.trim()]),a(""))}}),u.jsx("button",{onClick:()=>{r.trim()&&(n([...e,r.trim()]),a(""))},style:{background:"#313244",border:"1px solid #45475a",borderRadius:4,color:"#cdd6f4",cursor:"pointer",fontSize:11,padding:"4px 8px"},children:"+"})]})]})}function FP({outputs:e,onChange:n}){const[r,a]=N.useState("");return u.jsxs("div",{style:{marginBottom:16},children:[u.jsx("span",{style:{color:"#a6adc8",fontSize:11,display:"block",marginBottom:6,fontWeight:600},children:"Output Labels"}),e.map((o,l)=>u.jsxs("div",{style:{display:"flex",gap:4,marginBottom:4,alignItems:"center"},children:[u.jsx("span",{style:{color:"#cdd6f4",fontSize:11,flex:1},children:o}),u.jsx("button",{onClick:()=>n(e.filter((c,d)=>d!==l)),style:{background:"none",border:"none",color:"#f38ba8",cursor:"pointer",fontSize:11,padding:"0 4px"},children:"x"})]},l)),u.jsxs("div",{style:{display:"flex",gap:4},children:[u.jsx("input",{value:r,onChange:o=>a(o.target.value),placeholder:"Add output...",style:{...ao,flex:1},onKeyDown:o=>{o.key==="Enter"&&r.trim()&&(n([...e,r.trim()]),a(""))}}),u.jsx("button",{onClick:()=>{r.trim()&&(n([...e,r.trim()]),a(""))},style:{background:"#313244",border:"1px solid #45475a",borderRadius:4,color:"#cdd6f4",cursor:"pointer",fontSize:11,padding:"4px 8px"},children:"+"})]})]})}const PP={GET:"#a6e3a1",POST:"#89b4fa",PUT:"#fab387",DELETE:"#f38ba8",PATCH:"#cba6f7",OPTIONS:"#585b70",HEAD:"#585b70"};function $P({routes:e,nodeId:n,color:r,delegate:a}){const[o,l]=N.useState(!0),[c,d]=N.useState(!1),[p,h]=N.useState(null),[g,y]=N.useState("GET"),[m,b]=N.useState(""),[S,w]=N.useState(""),C=ue(I=>I.updateHandlerRoutes),_=ue(I=>I.setSelectedNode),j=ue(I=>I.nodes),k=ue(I=>I.edges),T=j.filter(I=>I.data.moduleType.startsWith("http.middleware.")).map(I=>I.data.label),E=N.useMemo(()=>{const I=[],F=k.filter($=>$.data?.edgeType==="pipeline-flow");if(F.length===0)return I;const U=F.find($=>$.source===n);if(!U)return I;const B=new Map;for(const $ of F)$.source!==n&&B.set($.source,$.target);let D=U.target;const q=new Set;for(;D&&!q.has(D);){q.add(D);const $=j.find(K=>K.id===D);$&&$.data.moduleType.startsWith("step.")&&I.push({id:$.id,label:$.data.label,type:$.data.moduleType}),D=B.get(D)}return I},[n,k,j]),z=I=>{window.confirm("Delete this route?")&&C(n,e.filter((F,U)=>U!==I))},A=()=>{if(!m.trim())return;const I=S.trim()?S.split(",").map(U=>U.trim()).filter(Boolean):void 0,F={method:g,path:m.trim()};I&&I.length>0&&(F.middlewares=I),C(n,[...e,F]),y("GET"),b(""),w(""),d(!1)},M=()=>{if(p===null||!m.trim())return;const I=S.trim()?S.split(",").map(U=>U.trim()).filter(Boolean):void 0,F=e.map((U,B)=>{if(B!==p)return U;const D={method:g,path:m.trim()};return I&&I.length>0&&(D.middlewares=I),U.pipeline&&U.pipeline.steps.length>0&&(D.pipeline=U.pipeline),D});C(n,F),h(null),y("GET"),b(""),w("")},O=I=>{const F=e[I];h(I),y(F.method),b(F.path),w(F.middlewares?.join(", ")??""),d(!1)},P=()=>{h(null),d(!1),y("GET"),b(""),w("")},L=["GET","POST","PUT","DELETE","PATCH","OPTIONS","HEAD"];return u.jsxs("div",{style:{marginBottom:16},children:[u.jsxs("div",{style:{color:"#a6adc8",fontSize:11,display:"flex",alignItems:"center",marginBottom:8,fontWeight:600,gap:4},children:[u.jsx("span",{onClick:()=>l(I=>!I),style:{fontSize:9,cursor:"pointer",transition:"transform 0.15s",transform:o?"rotate(90deg)":"rotate(0deg)"},children:"▶"}),u.jsx("span",{onClick:()=>l(I=>!I),style:{cursor:"pointer",userSelect:"none"},children:"Routes"}),u.jsx("span",{style:{background:`${r}30`,color:r,padding:"1px 6px",borderRadius:8,fontSize:10,fontWeight:500,marginLeft:4},children:e.length}),u.jsx("button",{onClick:()=>{d(!0),h(null),y("GET"),b(""),w("")},style:{marginLeft:"auto",background:"#313244",border:"1px solid #45475a",borderRadius:4,color:"#a6e3a1",cursor:"pointer",fontSize:10,padding:"1px 6px",fontWeight:600},title:"Add route",children:"+"})]}),o&&u.jsxs("div",{style:{background:"#11111b",border:"1px solid #313244",borderRadius:6,padding:"6px 0",maxHeight:400,overflowY:"auto"},children:[e.map((I,F)=>{const U=PP[I.method]??"#cdd6f4";return p===F?u.jsxs("div",{style:{padding:"6px 10px",borderBottom:"1px solid #1e1e2e"},children:[u.jsxs("div",{style:{display:"flex",gap:4,marginBottom:4},children:[u.jsx("select",{value:g,onChange:B=>y(B.target.value),style:{...Ga,width:70,flexShrink:0},children:L.map(B=>u.jsx("option",{value:B,children:B},B))}),u.jsx("input",{value:m,onChange:B=>b(B.target.value),placeholder:"/api/...",style:{...Ga,flex:1}})]}),u.jsx("input",{value:S,onChange:B=>w(B.target.value),placeholder:`Middleware (comma-sep)${T.length>0?": "+T.join(", "):""}`,style:{...Ga,width:"100%",marginBottom:4,fontSize:10}}),u.jsxs("div",{style:{display:"flex",gap:4,justifyContent:"flex-end"},children:[u.jsx("button",{onClick:P,style:pT,children:"Cancel"}),u.jsx("button",{onClick:M,style:hT,children:"Save"})]})]},`edit-${F}`):u.jsxs("div",{style:{borderBottom:F0&&u.jsxs("span",{style:{color:"#585b70",fontSize:9,flexShrink:0},title:I.middlewares.join(", "),children:["+",I.middlewares.length," mw"]}),I.pipeline&&I.pipeline.steps.length>0&&u.jsxs("span",{style:{color:"#e879f9",fontSize:9,flexShrink:0},title:I.pipeline.steps.map(B=>B.name).join(" → "),children:[I.pipeline.steps.length," step",I.pipeline.steps.length!==1?"s":""]}),u.jsx("button",{onClick:()=>O(F),style:{background:"none",border:"none",color:"#585b70",cursor:"pointer",fontSize:10,padding:"0 2px",flexShrink:0},title:"Edit route",children:"✎"}),u.jsx("button",{onClick:()=>z(F),style:{background:"none",border:"none",color:"#f38ba8",cursor:"pointer",fontSize:10,padding:"0 2px",flexShrink:0},title:"Delete route",children:"x"})]}),u.jsx("div",{style:{padding:"0 10px 4px"},children:E.length>0?u.jsxs("div",{style:{marginTop:4},children:[u.jsx("div",{style:{fontSize:10,color:"#585b70",marginBottom:2},children:"Pipeline (canvas)"}),u.jsx("div",{style:{display:"flex",flexWrap:"wrap",alignItems:"center",gap:2,fontSize:10},children:E.map((B,D)=>u.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:2},children:[D>0&&u.jsx("span",{style:{color:"#585b70"},children:"→"}),u.jsx("span",{onClick:()=>_(B.id),style:{color:"#e879f9",cursor:"pointer",padding:"1px 4px",borderRadius:3,background:"#e879f910"},title:`Click to select ${B.type} node`,children:B.label})]},B.id))})]}):(I.pipeline?.steps?.length??0)>0?u.jsx(dT,{steps:I.pipeline?.steps??[],onChange:B=>{const D=e.map((q,$)=>$===F?{...q,pipeline:B.length>0?{steps:B}:void 0}:q);C(n,D)}}):a?u.jsxs("div",{style:{fontSize:10,color:"#585b70",padding:"2px 0",display:"flex",alignItems:"center",gap:4},children:[u.jsx("span",{style:{color:"#f9e2af",fontSize:9,padding:"1px 4px",borderRadius:3,background:"#f9e2af15"},children:"delegate"}),u.jsx("span",{style:{color:"#a6adc8"},children:a})]}):u.jsx(dT,{steps:[],onChange:B=>{const D=e.map((q,$)=>$===F?{...q,pipeline:B.length>0?{steps:B}:void 0}:q);C(n,D)}})})]},`${I.method}-${I.path}-${F}`)}),c&&u.jsxs("div",{style:{padding:"6px 10px",borderTop:e.length>0?"1px solid #313244":void 0},children:[u.jsxs("div",{style:{display:"flex",gap:4,marginBottom:4},children:[u.jsx("select",{value:g,onChange:I=>y(I.target.value),style:{...Ga,width:70,flexShrink:0},children:L.map(I=>u.jsx("option",{value:I,children:I},I))}),u.jsx("input",{value:m,onChange:I=>b(I.target.value),placeholder:"/api/...",style:{...Ga,flex:1},onKeyDown:I=>{I.key==="Enter"&&A(),I.key==="Escape"&&P()},autoFocus:!0})]}),u.jsx("input",{value:S,onChange:I=>w(I.target.value),placeholder:`Middleware (comma-sep)${T.length>0?": "+T.join(", "):""}`,style:{...Ga,width:"100%",marginBottom:4,fontSize:10},onKeyDown:I=>{I.key==="Enter"&&A(),I.key==="Escape"&&P()}}),u.jsxs("div",{style:{display:"flex",gap:4,justifyContent:"flex-end"},children:[u.jsx("button",{onClick:P,style:pT,children:"Cancel"}),u.jsx("button",{onClick:A,style:hT,children:"Add"})]})]}),e.length===0&&!c&&u.jsx("div",{style:{padding:"8px 10px",color:"#585b70",fontSize:11,textAlign:"center"},children:"No routes. Click + to add one."})]})]})}const Ga={padding:"4px 6px",background:"#1e1e2e",border:"1px solid #313244",borderRadius:4,color:"#cdd6f4",fontSize:11,outline:"none",boxSizing:"border-box",fontFamily:'ui-monospace, "Cascadia Code", "Source Code Pro", Menlo, monospace'},pT={background:"none",border:"1px solid #45475a",borderRadius:4,color:"#585b70",cursor:"pointer",fontSize:10,padding:"2px 8px"},hT={background:"#313244",border:"1px solid #45475a",borderRadius:4,color:"#a6e3a1",cursor:"pointer",fontSize:10,padding:"2px 8px",fontWeight:600},ao={width:"100%",padding:"6px 8px",background:"#1e1e2e",border:"1px solid #313244",borderRadius:4,color:"#cdd6f4",fontSize:12,outline:"none",boxSizing:"border-box"};function VP({workflowId:e,workflowName:n,onClose:r,onRestore:a}){const[o,l]=N.useState([]),[c,d]=N.useState(!0),[p,h]=N.useState(null);N.useEffect(()=>{let m=!1;return WF(e).then(b=>{m||l(b)}).catch(()=>{}).finally(()=>{m||d(!1)}),()=>{m=!0}},[e]);const g=m=>{try{return new Date(m).toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}catch{return m}},y=m=>!m||m==="system"?"System":m.length>20?m.slice(0,8)+"...":m;return u.jsx("div",{style:{position:"fixed",top:0,left:0,right:0,bottom:0,background:"rgba(0,0,0,0.6)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:9999},onClick:m=>{m.target===m.currentTarget&&r()},children:u.jsxs("div",{style:{background:"#1e1e2e",border:"1px solid #313244",borderRadius:10,width:600,maxHeight:"80vh",display:"flex",flexDirection:"column",overflow:"hidden"},children:[u.jsxs("div",{style:{padding:"16px 20px",borderBottom:"1px solid #313244",display:"flex",alignItems:"center",justifyContent:"space-between"},children:[u.jsxs("div",{children:[u.jsx("div",{style:{color:"#cdd6f4",fontWeight:700,fontSize:16},children:"Edit History"}),u.jsx("div",{style:{color:"#6c7086",fontSize:12,marginTop:2},children:n})]}),u.jsx("button",{onClick:r,style:{background:"none",border:"none",color:"#585b70",cursor:"pointer",fontSize:18,padding:"0 4px"},children:"x"})]}),u.jsxs("div",{style:{flex:1,overflowY:"auto",padding:"12px 0"},children:[c&&u.jsx("div",{style:{padding:20,textAlign:"center",color:"#6c7086",fontSize:13},children:"Loading version history..."}),!c&&o.length===0&&u.jsx("div",{style:{padding:20,textAlign:"center",color:"#6c7086",fontSize:13},children:"No version history available."}),!c&&o.map((m,b)=>u.jsxs("div",{style:{borderBottom:bh(p===m.version?null:m.version),children:[u.jsxs("div",{style:{width:32,height:32,borderRadius:"50%",background:b===0?"#89b4fa":"#313244",display:"flex",alignItems:"center",justifyContent:"center",color:b===0?"#1e1e2e":"#a6adc8",fontSize:12,fontWeight:700,flexShrink:0},children:["v",m.version]}),u.jsxs("div",{style:{flex:1},children:[u.jsxs("div",{style:{color:"#cdd6f4",fontSize:13},children:["Version ",m.version,b===0&&u.jsx("span",{style:{marginLeft:8,padding:"1px 6px",background:"#89b4fa22",color:"#89b4fa",borderRadius:4,fontSize:10,fontWeight:600},children:"Current"})]}),u.jsxs("div",{style:{color:"#6c7086",fontSize:11,marginTop:2},children:["by ",y(m.created_by)," · ",g(m.created_at)]})]}),a&&b>0&&u.jsx("button",{onClick:S=>{S.stopPropagation(),window.confirm(`Restore to version ${m.version}? This will create a new version with the old configuration.`)&&a(m.config_yaml,m.version)},style:{padding:"4px 10px",background:"#313244",border:"1px solid #45475a",borderRadius:4,color:"#f9e2af",fontSize:11,cursor:"pointer",fontWeight:500},children:"Restore"}),u.jsx("span",{style:{color:"#585b70",fontSize:14},children:p===m.version?"▼":"▶"})]}),p===m.version&&u.jsx("div",{style:{padding:"0 20px 12px",marginLeft:44},children:u.jsx("pre",{style:{background:"#181825",border:"1px solid #313244",borderRadius:6,padding:10,color:"#a6adc8",fontSize:11,fontFamily:"monospace",maxHeight:200,overflowY:"auto",whiteSpace:"pre-wrap",wordBreak:"break-word",margin:0},children:m.config_yaml||"(empty)"})})]},m.id))]})]})})}function WP(){const e=ue(q=>q.exportToConfig),n=ue(q=>q.importFromConfig),r=ue(q=>q.clearCanvas),a=ue(q=>q.nodes),o=ue(q=>q.addToast),l=ue(q=>q.setValidationErrors),c=ue(q=>q.clearValidationErrors),d=ue(q=>q.undo),p=ue(q=>q.redo),h=ue(q=>q.undoStack),g=ue(q=>q.redoStack),y=ue(q=>q.toggleAIPanel),m=ue(q=>q.showAIPanel),b=ue(q=>q.toggleComponentBrowser),S=ue(q=>q.showComponentBrowser),w=ue(q=>q.viewLevel),C=ue(q=>q.setViewLevel),_=ue(q=>q.autoGroupOrphans),j=ue(q=>q.autoLayout),k=ue(q=>q.activeWorkflowRecord),T=ue(q=>q.setActiveWorkflowRecord),[E,z]=N.useState(!1),[A,M]=N.useState(!1),O=async()=>{if(k){M(!0);try{const q=await ud(k.id);T(q),o(`Deployed v${q.version} - status: ${q.status}`,"success")}catch(q){o(`Deploy failed: ${q.message}`,"error")}finally{M(!1)}}},P=async()=>{if(k){M(!0);try{const q=await dd(k.id);T(q),o(`Stopped "${q.name}"`,"success")}catch(q){o(`Stop failed: ${q.message}`,"error")}finally{M(!1)}}},L=()=>{const q=e(),$=Bj(q),K=new Blob([$],{type:"text/yaml"}),ne=URL.createObjectURL(K),V=document.createElement("a");V.href=ne,V.download="workflow.yaml",V.click(),URL.revokeObjectURL(ne)},I=()=>{const q=document.createElement("input");q.type="file",q.accept=".yaml,.yml,.json",q.onchange=async()=>{const $=q.files?.[0];if(!$||a.length>0&&!window.confirm("This will replace your current workflow. Any unsaved changes will be lost. Continue?"))return;const K=await $.text();try{if($.name.endsWith(".json")){const ne=JSON.parse(K);n(ne)}else{const ne=Bs(K);n(ne)}o("Workflow imported from file","success")}catch(ne){console.error("Failed to import:",ne),o("Failed to parse workflow file","error")}},q.click()},F=async()=>{if(!(a.length>0&&!window.confirm("This will replace your current workflow with the server configuration. Any unsaved changes will be lost. Continue?")))try{const q=await TF();n(q),o("Workflow loaded from server","success")}catch(q){o(`Failed to load: ${q.message}`,"error")}},U=async()=>{const q=window.prompt(`Enter server-local path to a workflow YAML file or directory: + +Examples: + example/chat-platform + /home/user/workflow/example/ecommerce-app.yaml`);if(q){if(!k){o("No workflow selected. Create a workflow first, then import config from server.","warning");return}try{const $=await hA(k.project_id,q),K=Bs($.config_yaml);n(K),o(`Loaded "${$.name}" from server path`,"success")}catch($){o(`Failed to load from server: ${$.message}`,"error")}}},B=async()=>{if(!k){o("No workflow selected. Load or create a workflow first, then save.","warning");return}const q=e();try{const $=Bj(q),K=await $j(k.id,{name:k.name,config_yaml:$});T(K),o(`Saved v${K.version}`,"success")}catch($){o(`Save failed: ${$.message}`,"error")}},D=async()=>{c();const q=e(),$=a,K=G=>{for(const X of $)if(X.data.label&&G.includes(X.data.label))return X.id},ne=[];q.modules.length===0&&ne.push("Workflow has no modules");const W=q.modules.filter(G=>!G.type.startsWith("step.")).map(G=>G.name),ee=W.filter((G,X)=>W.indexOf(G)!==X);if(ee.length>0){const G=[...new Set(ee)];ne.push(`Duplicate module names: ${G.join(", ")}`)}if(q.workflows)for(const[G,X]of Object.entries(q.workflows)){const Q=X;if(Q.routes){for(const ie of Q.routes)if(ie.pipeline?.steps){const se=ie.pipeline.steps.map(ye=>ye.name),he=se.filter((ye,be)=>se.indexOf(ye)!==be);if(he.length>0){const ye=[...new Set(he)],be=`${ie.method??"?"} ${ie.path??"/"}`;ne.push(`Duplicate step names in ${G} route ${be}: ${ye.join(", ")}`)}}}}for(const G of q.modules)if(G.name.trim()||ne.push(`Module of type ${G.type} has no name`),G.dependsOn){const X=q.modules.map(Q=>Q.name);for(const Q of G.dependsOn)X.includes(Q)||ne.push(`${G.name} depends on unknown module: ${Q}`)}if(ne.length>0){const G=ne.map(X=>({message:X,nodeId:K(X)}));l(G),o(`${ne.length} validation error${ne.length!==1?"s":""} found`,"error");return}try{const G=await RF(q);if(G.valid)c(),o("Workflow is valid","success");else{const X=[];for(const Q of G.errors)X.push({message:Q,nodeId:K(Q)});for(const Q of G.warnings)X.push({message:Q,nodeId:K(Q)});l(X),o(`${X.length} validation error${X.length!==1?"s":""} found`,"error")}}catch{c(),o("Workflow is valid (local check only)","info")}};return u.jsxs("div",{style:{height:44,background:"#181825",borderBottom:"1px solid #313244",display:"flex",alignItems:"center",padding:"0 16px",gap:8},children:[u.jsx("span",{style:{fontWeight:700,fontSize:14,color:"#cdd6f4",marginRight:16},children:k?k.name:"Workflow Editor"}),k&&u.jsxs("span",{style:{fontSize:11,color:"#6c7086",marginRight:8},children:["v",k.version]}),u.jsx(Mt,{label:"Import",onClick:I}),u.jsx(Mt,{label:"Load Server",onClick:F}),u.jsx(Mt,{label:"From Path",onClick:U}),u.jsx(Mt,{label:"Export YAML",onClick:L,disabled:a.length===0}),u.jsx(Mt,{label:"Save",onClick:B,disabled:a.length===0}),k&&(k.status==="draft"||k.status==="stopped"||k.status==="error")&&u.jsx(Mt,{label:A?"Deploying...":"Deploy",onClick:O,disabled:A,variant:"deploy"}),k&&k.status==="active"&&u.jsx(Mt,{label:A?"Stopping...":"Stop",onClick:P,disabled:A,variant:"danger"}),k&&u.jsx(Mt,{label:"History",onClick:()=>z(!0)}),u.jsx(Mt,{label:"Validate",onClick:D,disabled:a.length===0}),u.jsx(y0,{}),u.jsx(Mt,{label:"Undo",onClick:d,disabled:h.length===0}),u.jsx(Mt,{label:"Redo",onClick:p,disabled:g.length===0}),u.jsx(y0,{}),u.jsx(Mt,{label:"AI Copilot",onClick:y,variant:m?"active":void 0}),u.jsx(Mt,{label:"Components",onClick:b,variant:S?"active":void 0}),u.jsx(y0,{}),u.jsx(Mt,{label:w==="component"?"Container View":"Component View",onClick:()=>C(w==="component"?"container":"component"),disabled:a.length===0}),u.jsx(Mt,{label:"Auto Layout",onClick:j,disabled:a.length===0}),u.jsx(Mt,{label:"Auto-group",onClick:_,disabled:a.length===0}),u.jsx("div",{style:{flex:1}}),u.jsxs("span",{style:{color:"#585b70",fontSize:11,marginRight:8},children:[a.length," ",a.length===1?"module":"modules"]}),u.jsx(Mt,{label:"Clear",onClick:()=>{window.confirm("This will remove all modules from the canvas. This cannot be undone. Continue?")&&r()},disabled:a.length===0,variant:"danger"}),E&&k&&u.jsx(VP,{workflowId:k.id,workflowName:k.name,onClose:()=>z(!1),onRestore:async(q,$)=>{try{const K=await $j(k.id,{name:k.name,config_yaml:q});T(K);const ne=Bs(q);r(),n(ne),o(`Restored to v${$}, saved as v${K.version}`,"success"),z(!1)}catch(K){o(`Restore failed: ${K.message}`,"error")}}})]})}function y0(){return u.jsx("div",{style:{width:1,height:20,background:"#313244",margin:"0 4px"}})}function Mt({label:e,onClick:n,disabled:r,variant:a}){const o=r?"#585b70":a==="danger"?"#f38ba8":a==="active"?"#89b4fa":a==="deploy"?"#1e1e2e":"#cdd6f4";return u.jsx("button",{onClick:n,disabled:r,style:{padding:"5px 12px",background:a==="deploy"?"#a6e3a1":a==="active"?"#313244":a==="danger"?"#45475a":"#313244",border:`1px solid ${a==="deploy"?"#a6e3a1":a==="active"?"#89b4fa":"#45475a"}`,borderRadius:4,color:o,fontSize:12,cursor:r?"default":"pointer",fontWeight:a==="deploy"?700:500,opacity:r?.5:1},children:e})}const GP=1e3,YP=1e3;let Kc=null,Zc=null,Ya=null,Xa=null,xs=[],Ss=[];const jt=Mn((e,n)=>({activeView:"dashboard",selectedWorkflowId:null,systemDashboard:null,workflowDashboard:null,dashboardLoading:!1,executions:[],selectedExecution:null,executionSteps:[],executionFilter:{},logEntries:[],logFilter:{},logStreaming:!1,events:[],eventStreaming:!1,iamProviders:[],iamMappings:{},setActiveView:r=>e({activeView:r}),setSelectedWorkflowId:r=>e({selectedWorkflowId:r}),fetchSystemDashboard:async()=>{e({dashboardLoading:!0});try{const r=await GF();e({systemDashboard:r,dashboardLoading:!1})}catch{e({dashboardLoading:!1})}},fetchWorkflowDashboard:async r=>{e({dashboardLoading:!0});try{const a=await YF(r);e({workflowDashboard:a,dashboardLoading:!1})}catch{e({dashboardLoading:!1})}},fetchExecutions:async(r,a)=>{try{const o=await XF(r,a);e({executions:o})}catch{}},fetchExecutionDetail:async r=>{try{const a=await KF(r);e({selectedExecution:a})}catch{}},fetchExecutionSteps:async r=>{try{const a=await ZF(r);e({executionSteps:a})}catch{}},setExecutionFilter:r=>e({executionFilter:r}),triggerExecution:async r=>{try{await QF(r),await n().fetchExecutions(r,n().executionFilter)}catch{}},cancelExecution:async r=>{try{await JF(r);const a=n().selectedWorkflowId;a&&await n().fetchExecutions(a,n().executionFilter)}catch{}},fetchLogs:async(r,a)=>{try{const o=await eP(r,a);e({logEntries:o})}catch{}},setLogFilter:r=>e({logFilter:r}),startLogStream:r=>{n().stopLogStream();const a=localStorage.getItem("auth_token")||"",o=tP(r,a);Kc=o,xs=[],o.onmessage=l=>{try{const c=JSON.parse(l.data);xs.push(c),Ya||(Ya=setTimeout(()=>{const{logEntries:d}=n(),p=[...d,...xs].slice(-GP);e({logEntries:p}),xs=[],Ya=null},100))}catch{}},o.onerror=()=>{},e({logStreaming:!0})},stopLogStream:()=>{Kc&&(Kc.close(),Kc=null),Ya&&(clearTimeout(Ya),Ya=null),xs=[],e({logStreaming:!1})},fetchEvents:async r=>{try{const a=await nP(r);e({events:a})}catch{}},startEventStream:r=>{n().stopEventStream();const a=localStorage.getItem("auth_token")||"",o=rP(r,a);Zc=o,Ss=[],o.onmessage=l=>{try{const c=JSON.parse(l.data);Ss.push(c),Xa||(Xa=setTimeout(()=>{const{events:d}=n(),p=[...d,...Ss].slice(-YP);e({events:p}),Ss=[],Xa=null},100))}catch{}},e({eventStreaming:!0})},stopEventStream:()=>{Zc&&(Zc.close(),Zc=null),Xa&&(clearTimeout(Xa),Xa=null),Ss=[],e({eventStreaming:!1})},fetchIAMProviders:async r=>{try{const a=await iP(r);e({iamProviders:a})}catch{}},createIAMProvider:async(r,a)=>{await aP(r,a),await n().fetchIAMProviders(r)},updateIAMProvider:async(r,a)=>{await oP(r,a)},deleteIAMProvider:async r=>{await sP(r)},testIAMProvider:async r=>lP(r),fetchIAMRoleMappings:async r=>{try{const a=await cP(r);e({iamMappings:{...n().iamMappings,[r]:a}})}catch{}},createIAMRoleMapping:async(r,a)=>{await uP(r,a),await n().fetchIAMRoleMappings(r)},deleteIAMRoleMapping:async(r,a)=>{await dP(r),await n().fetchIAMRoleMappings(a)}}));function XP(){const e=ue(M=>M.tabs),n=ue(M=>M.activeTabId),r=ue(M=>M.addTab),a=ue(M=>M.closeTab),o=ue(M=>M.switchTab),l=ue(M=>M.renameTab),c=ue(M=>M.duplicateTab),d=ue(M=>M.clearCanvas),p=ue(M=>M.setActiveWorkflowRecord),h=jt(M=>M.setActiveView),g=jt(M=>M.setSelectedWorkflowId),[y,m]=N.useState(null),[b,S]=N.useState(""),[w,C]=N.useState(null),_=N.useRef(null),j=N.useRef(null);N.useEffect(()=>{y&&_.current&&(_.current.focus(),_.current.select())},[y]),N.useEffect(()=>{if(!w)return;const M=()=>C(null);return document.addEventListener("click",M),()=>document.removeEventListener("click",M)},[w]);const k=N.useCallback((M,O)=>{m(M),S(O)},[]),T=N.useCallback(()=>{y&&b.trim()&&l(y,b.trim()),m(null)},[y,b,l]),E=N.useCallback((M,O)=>{M.preventDefault(),C({tabId:O,x:M.clientX,y:M.clientY})},[]),z=N.useCallback(()=>{j.current?.scrollBy({left:-150,behavior:"smooth"})},[]),A=N.useCallback(()=>{j.current?.scrollBy({left:150,behavior:"smooth"})},[]);return u.jsxs("div",{style:{height:32,background:"#181825",borderBottom:"1px solid #313244",display:"flex",alignItems:"stretch",position:"relative",userSelect:"none"},children:[u.jsx("button",{onClick:z,style:{background:"none",border:"none",color:"#585b70",cursor:"pointer",padding:"0 4px",fontSize:12,flexShrink:0},children:"◀"}),u.jsx("div",{ref:j,style:{display:"flex",alignItems:"stretch",overflow:"hidden",flex:1},children:e.map(M=>{const O=M.id===n;return u.jsxs("div",{onClick:()=>o(M.id),onDoubleClick:()=>k(M.id,M.name),onContextMenu:P=>E(P,M.id),style:{display:"flex",alignItems:"center",gap:6,padding:"0 12px",cursor:"pointer",background:O?"#1e1e2e":"transparent",borderBottom:O?"2px solid #89b4fa":"2px solid transparent",flexShrink:0,minWidth:0},children:[y===M.id?u.jsx("input",{ref:_,value:b,onChange:P=>S(P.target.value),onBlur:T,onKeyDown:P=>{P.key==="Enter"&&T(),P.key==="Escape"&&m(null)},style:{background:"#313244",border:"1px solid #89b4fa",borderRadius:3,color:"#cdd6f4",fontSize:11,padding:"1px 4px",width:100,outline:"none"}}):u.jsxs("span",{style:{color:O?"#cdd6f4":"#6c7086",fontSize:11,fontWeight:O?600:400,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",maxWidth:120},children:[M.name,M.dirty?" *":""]}),u.jsx("button",{onClick:P=>{P.stopPropagation(),e.length<=1?(d(),p(null),g(null),l(n,"Workflow 1"),h("dashboard")):a(M.id)},title:"Close workflow",style:{background:"none",border:"none",color:"#585b70",cursor:"pointer",fontSize:12,padding:"0 2px",lineHeight:1,opacity:.6},onMouseEnter:P=>{P.target.style.opacity="1",P.target.style.color="#f38ba8"},onMouseLeave:P=>{P.target.style.opacity="0.6",P.target.style.color="#585b70"},children:"x"})]},M.id)})}),u.jsx("button",{onClick:A,style:{background:"none",border:"none",color:"#585b70",cursor:"pointer",padding:"0 4px",fontSize:12,flexShrink:0},children:"▶"}),u.jsx("button",{onClick:r,style:{background:"none",border:"none",borderLeft:"1px solid #313244",color:"#6c7086",cursor:"pointer",padding:"0 10px",fontSize:14,fontWeight:700,flexShrink:0},onMouseEnter:M=>{M.target.style.color="#89b4fa"},onMouseLeave:M=>{M.target.style.color="#6c7086"},children:"+"}),w&&u.jsxs("div",{style:{position:"fixed",left:w.x,top:w.y,background:"#313244",border:"1px solid #45475a",borderRadius:6,padding:"4px 0",zIndex:1e3,boxShadow:"0 4px 12px rgba(0,0,0,0.5)"},children:[u.jsx(m0,{label:"Rename",onClick:()=>{const M=e.find(O=>O.id===w.tabId);M&&k(M.id,M.name),C(null)}}),u.jsx(m0,{label:"Duplicate",onClick:()=>{c(w.tabId),C(null)}}),u.jsx(m0,{label:"Close",onClick:()=>{e.length<=1?(d(),p(null),h("dashboard")):a(w.tabId),C(null)},danger:!0})]})]})}function m0({label:e,onClick:n,danger:r}){return u.jsx("button",{onClick:n,style:{display:"block",width:"100%",background:"none",border:"none",color:r?"#f38ba8":"#cdd6f4",padding:"6px 16px",fontSize:12,textAlign:"left",cursor:"pointer"},onMouseEnter:a=>{a.target.style.background="#45475a"},onMouseLeave:a=>{a.target.style.background="none"},children:e})}const KP={success:{bg:"#1e3a2f",border:"#10b981",text:"#6ee7b7"},error:{bg:"#3b1f2b",border:"#ef4444",text:"#fca5a5"},info:{bg:"#1e2d40",border:"#3b82f6",text:"#93c5fd"},warning:{bg:"#3a2e1e",border:"#f59e0b",text:"#fcd34d"}};function ZP(){const e=ue(r=>r.toasts),n=ue(r=>r.removeToast);return u.jsx("div",{style:{position:"fixed",bottom:16,right:16,zIndex:9999,display:"flex",flexDirection:"column",gap:8,maxWidth:400},children:e.map(r=>u.jsx(QP,{toast:r,onDismiss:()=>n(r.id)},r.id))})}function QP({toast:e,onDismiss:n}){const r=KP[e.type];return N.useEffect(()=>{const a=setTimeout(n,4e3);return()=>clearTimeout(a)},[n]),u.jsxs("div",{style:{background:r.bg,border:`1px solid ${r.border}`,borderRadius:6,padding:"10px 14px",color:r.text,fontSize:13,display:"flex",alignItems:"flex-start",gap:8,boxShadow:"0 4px 12px rgba(0,0,0,0.4)",animation:"toastSlideIn 0.2s ease-out"},children:[u.jsx("span",{style:{flex:1,lineHeight:1.4,whiteSpace:"pre-wrap"},children:e.message}),u.jsx("button",{onClick:n,style:{background:"none",border:"none",color:r.text,cursor:"pointer",fontSize:14,padding:"0 2px",opacity:.7,lineHeight:1},children:"x"})]})}const JP=["REST API with auth and rate limiting","Event-driven microservice","HTTP proxy with logging","Scheduled data pipeline","WebSocket chat backend"];function e$(){const[e,n]=N.useState(""),[r,a]=N.useState(!1),[o,l]=N.useState(null),[c,d]=N.useState(""),[p,h]=N.useState([]),[g,y]=N.useState(!1),[m,b]=N.useState(!1),S=ue(E=>E.importFromConfig),w=ue(E=>E.addToast),C=ue(E=>E.toggleAIPanel),_=async()=>{if(e.trim()){a(!0),l(null),d("");try{const E=await zF(e.trim());l(E.config),d(E.explanation)}catch(E){const z=E.message;z.includes("no AI generators")||z.includes("500")||z.includes("not configured")?(b(!0),w("AI service unavailable. No AI providers are configured on the server.","error")):w(`Generation failed: ${z}`,"error")}finally{a(!1)}}},j=()=>{o&&(S(o),w("Generated workflow applied to canvas","success"),l(null),d(""),n(""))},k=async E=>{y(!0);try{const z=await NF(E);h(z)}catch(z){const A=z.message;A.includes("no AI generators")||A.includes("500")||A.includes("not configured")?(b(!0),w("AI service unavailable. No AI providers are configured on the server.","error")):w(`Suggestions failed: ${A}`,"error")}finally{y(!1)}},T=E=>{n(E),l(null),d("")};return u.jsxs("div",{style:{width:360,background:"#181825",borderLeft:"1px solid #313244",display:"flex",flexDirection:"column",height:"100%",overflow:"hidden"},children:[u.jsxs("div",{style:{padding:"12px 16px",borderBottom:"1px solid #313244",display:"flex",alignItems:"center",justifyContent:"space-between"},children:[u.jsx("span",{style:{fontWeight:700,fontSize:14,color:"#cdd6f4"},children:"AI Copilot"}),u.jsx("button",{onClick:C,style:{background:"none",border:"none",color:"#585b70",cursor:"pointer",fontSize:16,padding:"0 4px"},children:"x"})]}),u.jsxs("div",{style:{flex:1,overflowY:"auto",padding:16},children:[m&&u.jsxs("div",{style:{padding:"10px 12px",background:"#302020",border:"1px solid #f38ba8",borderRadius:6,marginBottom:16,fontSize:12,lineHeight:1.5},children:[u.jsx("div",{style:{color:"#f38ba8",fontWeight:600,marginBottom:4},children:"AI Not Configured"}),u.jsx("div",{style:{color:"#a6adc8"},children:"No AI providers are configured on the server. To enable AI features, configure an AI provider (e.g., Anthropic Claude, OpenAI) in your server settings or environment variables."}),u.jsx("div",{style:{color:"#585b70",marginTop:6,fontSize:11},children:"The workflow editor is fully functional without AI — use the Components panel to add modules manually."})]}),u.jsxs("div",{style:{marginBottom:16},children:[u.jsx("label",{style:{color:"#a6adc8",fontSize:11,display:"block",marginBottom:6},children:"Describe your workflow"}),u.jsx("textarea",{value:e,onChange:E=>n(E.target.value),placeholder:"e.g., REST API with JWT authentication, rate limiting, and database storage",rows:4,style:{width:"100%",padding:"8px 10px",background:"#1e1e2e",border:"1px solid #313244",borderRadius:6,color:"#cdd6f4",fontSize:12,resize:"vertical",outline:"none",fontFamily:"system-ui, sans-serif",boxSizing:"border-box"},onKeyDown:E=>{E.key==="Enter"&&(E.ctrlKey||E.metaKey)&&_()}}),u.jsx("button",{onClick:_,disabled:r||!e.trim(),style:{width:"100%",padding:"8px 14px",background:r?"#45475a":"#89b4fa",border:"none",borderRadius:6,color:r?"#a6adc8":"#1e1e2e",fontSize:12,fontWeight:600,cursor:r?"default":"pointer",marginTop:8},children:r?"Generating...":"Generate Workflow"})]}),u.jsxs("div",{style:{marginBottom:16},children:[u.jsx("span",{style:{color:"#a6adc8",fontSize:11,display:"block",marginBottom:8},children:"Quick start"}),u.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:6},children:JP.map(E=>u.jsx("button",{onClick:()=>T(E),style:{padding:"4px 10px",background:"#1e1e2e",border:"1px solid #313244",borderRadius:12,color:"#89b4fa",fontSize:11,cursor:"pointer",whiteSpace:"nowrap"},children:E},E))})]}),o&&u.jsxs("div",{style:{marginBottom:16},children:[u.jsx("span",{style:{color:"#a6adc8",fontSize:11,display:"block",marginBottom:6},children:"Generated workflow"}),c&&u.jsx("p",{style:{color:"#bac2de",fontSize:12,lineHeight:1.5,marginBottom:8},children:c}),u.jsx("div",{style:{background:"#1e1e2e",border:"1px solid #313244",borderRadius:6,padding:"8px 10px",fontSize:11,color:"#a6adc8",fontFamily:"monospace",maxHeight:200,overflowY:"auto",marginBottom:8,whiteSpace:"pre-wrap",wordBreak:"break-word"},children:o.modules.map(E=>`${E.name} (${E.type})`).join(` +`)}),u.jsx("button",{onClick:j,style:{width:"100%",padding:"8px 14px",background:"#10b981",border:"none",borderRadius:6,color:"#1e1e2e",fontSize:12,fontWeight:600,cursor:"pointer"},children:"Apply to Canvas"})]}),u.jsxs("div",{style:{borderTop:"1px solid #313244",paddingTop:16},children:[u.jsx("span",{style:{color:"#a6adc8",fontSize:11,display:"block",marginBottom:8},children:"Explore suggestions"}),u.jsxs("div",{style:{display:"flex",gap:6},children:[u.jsx("input",{type:"text",placeholder:"Use case (e.g., e-commerce)",style:{flex:1,padding:"6px 8px",background:"#1e1e2e",border:"1px solid #313244",borderRadius:4,color:"#cdd6f4",fontSize:12,outline:"none"},onKeyDown:E=>{E.key==="Enter"&&k(E.currentTarget.value)}}),u.jsx("button",{onClick:()=>{const E=document.querySelector('[placeholder*="Use case"]');E?.value&&k(E.value)},disabled:g,style:{padding:"6px 12px",background:"#313244",border:"1px solid #45475a",borderRadius:4,color:g?"#585b70":"#cdd6f4",fontSize:12,cursor:g?"default":"pointer"},children:g?"...":"Suggest"})]}),p.length>0&&u.jsx("div",{style:{marginTop:10,display:"flex",flexDirection:"column",gap:6},children:p.map((E,z)=>u.jsxs("div",{style:{background:"#1e1e2e",border:"1px solid #313244",borderRadius:6,padding:"8px 10px",cursor:"pointer"},onClick:()=>T(E.intent),children:[u.jsx("div",{style:{color:"#cdd6f4",fontSize:12,fontWeight:600},children:E.title}),u.jsx("div",{style:{color:"#a6adc8",fontSize:11,marginTop:2},children:E.description})]},z))})]})]})]})}function t$(){const[e,n]=N.useState([]),[r,a]=N.useState(!1),[o,l]=N.useState(null),[c,d]=N.useState(!1),[p,h]=N.useState(""),[g,y]=N.useState(""),[m,b]=N.useState("go"),[S,w]=N.useState(!1),C=ue(z=>z.addToast),_=ue(z=>z.toggleComponentBrowser),j=N.useCallback(async()=>{a(!0);try{const z=await MF();n(z)}catch{n([])}finally{a(!1)}},[]);N.useEffect(()=>{j()},[j]);const k=async()=>{if(!(!p.trim()||!g.trim())){w(!0);try{await OF(p.trim(),g,m),C(`Component "${p}" created`,"success"),d(!1),h(""),y(""),j()}catch(z){C(`Create failed: ${z.message}`,"error")}finally{w(!1)}}},T=async z=>{try{await DF(z),C(`Component "${z}" deleted`,"success"),o?.name===z&&l(null),j()}catch(A){C(`Delete failed: ${A.message}`,"error")}},E={running:"#10b981",stopped:"#585b70",error:"#ef4444"};return u.jsxs("div",{style:{width:360,background:"#181825",borderLeft:"1px solid #313244",display:"flex",flexDirection:"column",height:"100%",overflow:"hidden"},children:[u.jsxs("div",{style:{padding:"12px 16px",borderBottom:"1px solid #313244",display:"flex",alignItems:"center",justifyContent:"space-between"},children:[u.jsx("span",{style:{fontWeight:700,fontSize:14,color:"#cdd6f4"},children:"Dynamic Components"}),u.jsxs("div",{style:{display:"flex",gap:8},children:[u.jsx("button",{onClick:j,style:{background:"none",border:"none",color:"#585b70",cursor:"pointer",fontSize:12},children:"Refresh"}),u.jsx("button",{onClick:_,style:{background:"none",border:"none",color:"#585b70",cursor:"pointer",fontSize:16,padding:"0 4px"},children:"x"})]})]}),u.jsxs("div",{style:{flex:1,overflowY:"auto",padding:16},children:[u.jsx("button",{onClick:()=>d(!c),style:{width:"100%",padding:"8px 14px",background:c?"#45475a":"#313244",border:"1px solid #45475a",borderRadius:6,color:"#cdd6f4",fontSize:12,fontWeight:600,cursor:"pointer",marginBottom:12},children:c?"Cancel":"+ Create Component"}),c&&u.jsxs("div",{style:{background:"#1e1e2e",border:"1px solid #313244",borderRadius:6,padding:12,marginBottom:16},children:[u.jsxs("label",{style:{display:"block",marginBottom:10},children:[u.jsx("span",{style:{color:"#a6adc8",fontSize:11,display:"block",marginBottom:3},children:"Name"}),u.jsx("input",{value:p,onChange:z=>h(z.target.value),placeholder:"my-component",style:Qc})]}),u.jsxs("label",{style:{display:"block",marginBottom:10},children:[u.jsx("span",{style:{color:"#a6adc8",fontSize:11,display:"block",marginBottom:3},children:"Language"}),u.jsxs("select",{value:m,onChange:z=>b(z.target.value),style:Qc,children:[u.jsx("option",{value:"go",children:"Go"}),u.jsx("option",{value:"javascript",children:"JavaScript"}),u.jsx("option",{value:"wasm",children:"WebAssembly"})]})]}),u.jsxs("label",{style:{display:"block",marginBottom:10},children:[u.jsx("span",{style:{color:"#a6adc8",fontSize:11,display:"block",marginBottom:3},children:"Source"}),u.jsx("textarea",{value:g,onChange:z=>y(z.target.value),placeholder:"package main...",rows:8,style:{...Qc,fontFamily:"monospace",resize:"vertical"}})]}),u.jsx("button",{onClick:k,disabled:S||!p.trim()||!g.trim(),style:{width:"100%",padding:"8px 14px",background:S?"#45475a":"#89b4fa",border:"none",borderRadius:6,color:S?"#a6adc8":"#1e1e2e",fontSize:12,fontWeight:600,cursor:S?"default":"pointer"},children:S?"Creating...":"Create"})]}),r&&u.jsx("div",{style:{color:"#585b70",fontSize:12},children:"Loading..."}),!r&&e.length===0&&u.jsxs("div",{style:{color:"#585b70",fontSize:12,textAlign:"center",padding:24},children:["No dynamic components loaded.",` +`,"Start the server to manage components."]}),e.map(z=>u.jsxs("div",{style:{background:o?.name===z.name?"#313244":"#1e1e2e",border:"1px solid #313244",borderRadius:6,padding:"10px 12px",marginBottom:8,cursor:"pointer"},onClick:()=>l(o?.name===z.name?null:z),children:[u.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[u.jsx("span",{style:{width:8,height:8,borderRadius:"50%",background:E[z.status]??"#585b70",flexShrink:0}}),u.jsx("span",{style:{color:"#cdd6f4",fontSize:12,fontWeight:600,flex:1},children:z.name}),u.jsx("span",{style:{color:"#585b70",fontSize:10},children:z.language}),u.jsx("button",{onClick:A=>{A.stopPropagation(),T(z.name)},style:{background:"none",border:"none",color:"#f38ba8",cursor:"pointer",fontSize:11,padding:"0 4px"},children:"Delete"})]}),u.jsxs("div",{style:{color:"#585b70",fontSize:10,marginTop:4},children:["Status: ",z.status," | Loaded: ",z.loadedAt]}),o?.name===z.name&&z.source&&u.jsxs("div",{style:{marginTop:8},children:[u.jsx("span",{style:{color:"#a6adc8",fontSize:10,display:"block",marginBottom:4},children:"Source"}),u.jsx("textarea",{readOnly:!0,value:z.source,rows:10,style:{...Qc,fontFamily:"monospace",fontSize:11,resize:"vertical",cursor:"text"}})]})]},z.name))]})]})}const Qc={width:"100%",padding:"6px 8px",background:"#1e1e2e",border:"1px solid #313244",borderRadius:4,color:"#cdd6f4",fontSize:12,outline:"none",boxSizing:"border-box"};function n$(){const[e,n]=N.useState("signin"),[r,a]=N.useState(""),[o,l]=N.useState(""),[c,d]=N.useState(""),[p,h]=N.useState(""),[g,y]=N.useState(null),{login:m,register:b,isLoading:S,error:w,clearError:C}=_r(),_=async k=>{if(k.preventDefault(),y(null),C(),e==="signup"){if(o!==c){y("Passwords do not match");return}if(o.length<6){y("Password must be at least 6 characters");return}await b(r,o,p)}else await m(r,o)},j=g||w;return u.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",height:"100vh",width:"100vw",background:"#1e1e2e",fontFamily:"system-ui, -apple-system, sans-serif"},children:u.jsxs("div",{style:{width:400,background:"#181825",borderRadius:12,border:"1px solid #313244",padding:32},children:[u.jsxs("div",{style:{textAlign:"center",marginBottom:24},children:[u.jsx("h1",{style:{color:"#89b4fa",margin:0,fontSize:24,fontWeight:700},children:"Workflow Engine"}),u.jsx("p",{style:{color:"#a6adc8",margin:"8px 0 0",fontSize:14},children:"Build and manage workflow pipelines"})]}),u.jsxs("div",{style:{display:"flex",gap:0,marginBottom:24,background:"#313244",borderRadius:8,padding:3},children:[u.jsx("button",{onClick:()=>{n("signin"),C(),y(null)},style:{flex:1,padding:"8px 0",border:"none",borderRadius:6,fontSize:14,fontWeight:600,cursor:"pointer",background:e==="signin"?"#89b4fa":"transparent",color:e==="signin"?"#1e1e2e":"#a6adc8"},children:"Sign In"}),u.jsx("button",{onClick:()=>{n("signup"),C(),y(null)},style:{flex:1,padding:"8px 0",border:"none",borderRadius:6,fontSize:14,fontWeight:600,cursor:"pointer",background:e==="signup"?"#89b4fa":"transparent",color:e==="signup"?"#1e1e2e":"#a6adc8"},children:"Sign Up"})]}),j&&u.jsx("div",{style:{background:"rgba(243, 139, 168, 0.15)",border:"1px solid #f38ba8",borderRadius:6,padding:"8px 12px",marginBottom:16,color:"#f38ba8",fontSize:13},children:j}),u.jsxs("form",{onSubmit:_,children:[e==="signup"&&u.jsxs("div",{style:{marginBottom:12},children:[u.jsx("label",{style:{display:"block",color:"#cdd6f4",fontSize:13,marginBottom:4},children:"Display Name"}),u.jsx("input",{type:"text",value:p,onChange:k=>h(k.target.value),placeholder:"Your name",style:Jc})]}),u.jsxs("div",{style:{marginBottom:12},children:[u.jsx("label",{style:{display:"block",color:"#cdd6f4",fontSize:13,marginBottom:4},children:"Email"}),u.jsx("input",{type:"email",value:r,onChange:k=>a(k.target.value),placeholder:"you@example.com",required:!0,style:Jc})]}),u.jsxs("div",{style:{marginBottom:12},children:[u.jsx("label",{style:{display:"block",color:"#cdd6f4",fontSize:13,marginBottom:4},children:"Password"}),u.jsx("input",{type:"password",value:o,onChange:k=>l(k.target.value),placeholder:"Enter password",required:!0,autoComplete:e==="signin"?"current-password":"new-password",style:Jc})]}),e==="signup"&&u.jsxs("div",{style:{marginBottom:12},children:[u.jsx("label",{style:{display:"block",color:"#cdd6f4",fontSize:13,marginBottom:4},children:"Confirm Password"}),u.jsx("input",{type:"password",value:c,onChange:k=>d(k.target.value),placeholder:"Confirm password",required:!0,autoComplete:"new-password",style:Jc})]}),u.jsx("button",{type:"submit",disabled:S,style:{width:"100%",padding:"10px 0",background:S?"#585b70":"#89b4fa",border:"none",borderRadius:6,color:"#1e1e2e",fontSize:14,fontWeight:600,cursor:S?"not-allowed":"pointer",marginTop:8},children:S?"Please wait...":e==="signin"?"Sign In":"Create Account"})]})]})})}const Jc={width:"100%",padding:"10px 12px",background:"#313244",border:"1px solid #45475a",borderRadius:6,color:"#cdd6f4",fontSize:14,outline:"none",boxSizing:"border-box"};function r$(){const[e,n]=N.useState(""),[r,a]=N.useState(""),[o,l]=N.useState(""),[c,d]=N.useState(""),[p,h]=N.useState(null),{setupAdmin:g,isLoading:y,error:m,clearError:b}=_r(),S=async C=>{if(C.preventDefault(),h(null),b(),o.length<6){h("Password must be at least 6 characters");return}if(o!==c){h("Passwords do not match");return}await g(e,o,r)},w=p||m;return u.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",height:"100vh",width:"100vw",background:"#1e1e2e",fontFamily:"system-ui, -apple-system, sans-serif"},children:u.jsxs("div",{style:{width:400,background:"#181825",borderRadius:12,border:"1px solid #313244",padding:32},children:[u.jsxs("div",{style:{textAlign:"center",marginBottom:24},children:[u.jsx("h1",{style:{color:"#89b4fa",margin:0,fontSize:24,fontWeight:700},children:"Welcome to Workflow Engine"}),u.jsx("p",{style:{color:"#a6adc8",margin:"8px 0 0",fontSize:14},children:"Create your admin account to get started"})]}),w&&u.jsx("div",{style:{background:"rgba(243, 139, 168, 0.15)",border:"1px solid #f38ba8",borderRadius:6,padding:"8px 12px",marginBottom:16,color:"#f38ba8",fontSize:13},children:w}),u.jsxs("form",{onSubmit:S,children:[u.jsxs("div",{style:{marginBottom:12},children:[u.jsx("label",{style:{display:"block",color:"#cdd6f4",fontSize:13,marginBottom:4},children:"Name"}),u.jsx("input",{type:"text",value:r,onChange:C=>a(C.target.value),placeholder:"Your name",style:eu})]}),u.jsxs("div",{style:{marginBottom:12},children:[u.jsx("label",{style:{display:"block",color:"#cdd6f4",fontSize:13,marginBottom:4},children:"Email"}),u.jsx("input",{type:"email",value:e,onChange:C=>n(C.target.value),placeholder:"admin@example.com",required:!0,style:eu})]}),u.jsxs("div",{style:{marginBottom:12},children:[u.jsx("label",{style:{display:"block",color:"#cdd6f4",fontSize:13,marginBottom:4},children:"Password"}),u.jsx("input",{type:"password",value:o,onChange:C=>l(C.target.value),placeholder:"Min 6 characters",required:!0,autoComplete:"new-password",style:eu})]}),u.jsxs("div",{style:{marginBottom:12},children:[u.jsx("label",{style:{display:"block",color:"#cdd6f4",fontSize:13,marginBottom:4},children:"Confirm Password"}),u.jsx("input",{type:"password",value:c,onChange:C=>d(C.target.value),placeholder:"Confirm password",required:!0,autoComplete:"new-password",style:eu})]}),u.jsx("button",{type:"submit",disabled:y,style:{width:"100%",padding:"10px 0",background:y?"#585b70":"#89b4fa",border:"none",borderRadius:6,color:"#1e1e2e",fontSize:14,fontWeight:600,cursor:y?"not-allowed":"pointer",marginTop:8},children:y?"Creating account...":"Create Admin Account"})]})]})})}const eu={width:"100%",padding:"10px 12px",background:"#313244",border:"1px solid #45475a",borderRadius:6,color:"#cdd6f4",fontSize:14,outline:"none",boxSizing:"border-box"};function i$({selectedProjectId:e,onSelectProject:n}){const[r,a]=N.useState([]),[o,l]=N.useState(null),[c,d]=N.useState(""),p=_r(b=>b.user?.role),h=N.useCallback(async()=>{try{const b=await X0();a((b||[]).map(S=>({company:S,orgs:[],expanded:!1,loading:!1})))}catch{}},[]);N.useEffect(()=>{let b=!1;return X0().then(S=>{b||a((S||[]).map(w=>({company:w,orgs:[],expanded:!1,loading:!1})))}).catch(()=>{}),()=>{b=!0}},[]);const g=async b=>{const S=[...r],w=S[b];if(w.expanded=!w.expanded,w.expanded&&w.orgs.length===0){w.loading=!0,a([...S]);try{const C=await Fj(w.company.id);w.orgs=(C||[]).map(_=>({org:_,projects:[],expanded:!1,loading:!1}))}catch{}w.loading=!1}a([...S])},y=async(b,S)=>{const w=[...r],C=w[b].orgs[S];if(C.expanded=!C.expanded,C.expanded&&C.projects.length===0){C.loading=!0,a([...w]);try{const _=await Pj(C.org.id);C.projects=_||[]}catch{}C.loading=!1}a([...w])},m=async()=>{if(!(!c.trim()||!o)){try{if(o.type==="company")await HF(c),await h();else if(o.type==="org"&&o.parentId){await UF(o.parentId,c);const b=r.findIndex(S=>S.company.id===o.parentId);if(b>=0){const S=[...r],w=await Fj(o.parentId);S[b].orgs=(w||[]).map(C=>({org:C,projects:[],expanded:!1,loading:!1})),a(S)}}else if(o.type==="project"&&o.parentId){const b=await PF(o.parentId,c),S=[...r];for(const w of S){const C=w.orgs.find(_=>_.org.id===o.parentId);if(C){const _=await Pj(o.parentId);C.projects=_||[];break}}a(S),n(b)}}catch{}l(null),d("")}};return u.jsxs("div",{style:{width:"100%",background:"#181825",overflowY:"auto",fontSize:13,color:"#cdd6f4",display:"flex",flexDirection:"column",height:"100%"},children:[u.jsxs("div",{onClick:()=>n(null),style:{padding:"8px 12px",borderBottom:"1px solid #313244",cursor:"pointer",display:"flex",alignItems:"center",gap:6,background:e===null?"rgba(137, 180, 250, 0.10)":"transparent",color:e===null?"#89b4fa":"#cdd6f4",fontWeight:500,fontSize:13},children:[u.jsx("span",{style:{fontSize:14},children:"📋"}),"All Workflows"]}),u.jsxs("div",{style:{padding:"8px 12px",borderBottom:"1px solid #313244",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[u.jsx("span",{style:{fontWeight:600,fontSize:12,color:"#a6adc8",textTransform:"uppercase"},children:"Companies"}),u.jsx("button",{onClick:()=>l({type:"company"}),style:ws,title:"New Company",children:"+"})]}),o&&u.jsxs("div",{style:{padding:"6px 8px",borderBottom:"1px solid #313244"},children:[u.jsxs("div",{style:{color:"#a6adc8",fontSize:11,marginBottom:4},children:["New ",o.type]}),u.jsx("input",{autoFocus:!0,value:c,onChange:b=>d(b.target.value),onKeyDown:b=>{b.key==="Enter"&&m(),b.key==="Escape"&&(l(null),d(""))},placeholder:"Name...",style:{width:"100%",padding:"4px 6px",background:"#313244",border:"1px solid #45475a",borderRadius:4,color:"#cdd6f4",fontSize:12,outline:"none",boxSizing:"border-box"}}),u.jsxs("div",{style:{display:"flex",gap:4,marginTop:4},children:[u.jsx("button",{onClick:m,style:{...ws,fontSize:11,padding:"2px 8px"},children:"Create"}),u.jsx("button",{onClick:()=>{l(null),d("")},style:{...ws,fontSize:11,padding:"2px 8px",background:"#45475a"},children:"Cancel"})]})]}),u.jsxs("div",{style:{flex:1,overflowY:"auto"},children:[r.map((b,S)=>b.company.is_system&&p!=="admin"?null:u.jsxs("div",{children:[u.jsxs("div",{style:{padding:"6px 8px",display:"flex",alignItems:"center",gap:4,cursor:"pointer",background:b.expanded?"#1e1e2e":"transparent"},onClick:()=>g(S),children:[u.jsx("span",{style:{fontSize:10,width:12},children:b.expanded?"▼":"▶"}),u.jsxs("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",color:b.company.is_system?"#f9e2af":void 0},title:b.company.is_system?"System (Admin Only)":b.company.name,children:[b.company.is_system?"🔒 ":"🏢 ",b.company.is_system?"System (Admin Only)":b.company.name]}),!b.company.is_system&&u.jsx("button",{onClick:w=>{w.stopPropagation(),l({type:"org",parentId:b.company.id})},style:{...ws,fontSize:10,padding:"0 4px"},title:"New Organization",children:"+"})]}),b.expanded&&u.jsxs("div",{style:{paddingLeft:12},children:[!b.loading&&b.orgs.length>0&&u.jsx("div",{style:{padding:"2px 8px",fontSize:9,color:"#585b70",textTransform:"uppercase",letterSpacing:"0.05em"},children:"Organizations"}),b.loading&&u.jsx("div",{style:{padding:"4px 8px",color:"#6c7086",fontSize:11},children:"Loading..."}),b.orgs.map((w,C)=>u.jsxs("div",{children:[u.jsxs("div",{style:{padding:"4px 8px",display:"flex",alignItems:"center",gap:4,cursor:"pointer",background:w.expanded?"#1e1e2e":"transparent"},onClick:()=>y(S,C),children:[u.jsx("span",{style:{fontSize:10,width:12},children:w.expanded?"▼":"▶"}),u.jsx("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:w.org.name,children:w.org.name}),!b.company.is_system&&u.jsx("button",{onClick:_=>{_.stopPropagation(),l({type:"project",parentId:w.org.id})},style:{...ws,fontSize:10,padding:"0 4px"},title:"New Project",children:"+"})]}),w.expanded&&u.jsxs("div",{style:{paddingLeft:12},children:[!w.loading&&w.projects.length>0&&u.jsx("div",{style:{padding:"2px 8px",fontSize:9,color:"#585b70",textTransform:"uppercase",letterSpacing:"0.05em"},children:"Projects"}),w.loading&&u.jsx("div",{style:{padding:"2px 8px",color:"#6c7086",fontSize:11},children:"Loading..."}),w.projects.map(_=>u.jsx("div",{onClick:j=>{j.stopPropagation(),n(_)},title:_.name,style:{padding:"4px 8px",cursor:"pointer",borderRadius:4,background:e===_.id?"rgba(137, 180, 250, 0.15)":"transparent",color:e===_.id?"#89b4fa":"#cdd6f4",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:_.name},_.id))]})]},w.org.id))]})]},b.company.id)),r.length===0&&u.jsxs("div",{style:{padding:"16px 12px",color:"#6c7086",fontSize:12,textAlign:"center"},children:["No companies yet.",u.jsx("br",{}),"Click + to create one."]})]})]})}const ws={background:"#313244",border:"none",borderRadius:4,color:"#89b4fa",cursor:"pointer",fontSize:14,fontWeight:700,padding:"0 6px",lineHeight:"18px"},gT={draft:{bg:"#585b70",text:"#cdd6f4"},active:{bg:"rgba(166, 227, 161, 0.2)",text:"#a6e3a1"},stopped:{bg:"rgba(249, 226, 175, 0.2)",text:"#f9e2af"},error:{bg:"rgba(243, 139, 168, 0.2)",text:"#f38ba8"},deploying:{bg:"rgba(137, 180, 250, 0.2)",text:"#89b4fa"},stopping:{bg:"rgba(249, 226, 175, 0.2)",text:"#f9e2af"}};function a$({projectId:e,projectName:n,onOpenWorkflow:r}){const[a,o]=N.useState([]),[l,c]=N.useState(new Map),[d,p]=N.useState(""),[h,g]=N.useState(!1),[y,m]=N.useState(""),[b,S]=N.useState(!0),[w,C]=N.useState({}),[_,j]=N.useState({});N.useEffect(()=>{let L=!1;return S(!0),$b(e).then(I=>{L||o(I||[])}).catch(()=>{}).finally(()=>{L||S(!1)}),()=>{L=!0}},[e]),N.useEffect(()=>{if(e)return;let L=!1;return FF().then(I=>{if(!L){const F=new Map;for(const U of I||[])F.set(U.id,U.name);c(F)}}).catch(()=>{}),()=>{L=!0}},[e]);const k=async()=>{if(y.trim()){if(!e){j(L=>({...L,_global:"Select a project from the sidebar before creating a workflow."})),g(!1),m("");return}try{const L=await $F(e,{name:y});o(I=>[L,...I]),g(!1),m("")}catch{}}},T=async L=>{C(I=>({...I,[L]:"deploying"})),j(I=>{const F={...I};return delete F[L],F});try{const I=await ud(L);o(F=>F.map(U=>U.id===L?I:U))}catch(I){j(F=>({...F,[L]:I.message}))}finally{C(I=>{const F={...I};return delete F[L],F})}},E=async L=>{C(I=>({...I,[L]:"stopping"})),j(I=>{const F={...I};return delete F[L],F});try{const I=await dd(L);o(F=>F.map(U=>U.id===L?I:U))}catch(I){j(F=>({...F,[L]:I.message}))}finally{C(I=>{const F={...I};return delete F[L],F})}},z=async()=>{if(!e){j(I=>({...I,_global:"Select a project from the sidebar before loading from server path."}));return}const L=window.prompt("Enter server-local path to a workflow YAML file or directory:");if(L)try{const I=await hA(e,L);o(F=>[I,...F])}catch(I){j(F=>({...F,_global:I.message}))}},A=async L=>{if(confirm("Delete this workflow? This action cannot be undone."))try{await VF(L),o(I=>I.filter(F=>F.id!==L))}catch{}},M=a.filter(L=>L.name.toLowerCase().includes(d.toLowerCase())),O=!e,P=n||"All Workflows";return u.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",background:"#1e1e2e",color:"#cdd6f4",overflow:"hidden"},children:[u.jsxs("div",{style:{padding:"16px 24px",borderBottom:"1px solid #313244",display:"flex",alignItems:"center",gap:12},children:[u.jsx("h2",{style:{margin:0,fontSize:18,fontWeight:600,flex:1},children:P}),u.jsx("input",{type:"text",placeholder:"Filter workflows...",value:d,onChange:L=>p(L.target.value),style:{padding:"6px 10px",background:"#313244",border:"1px solid #45475a",borderRadius:6,color:"#cdd6f4",fontSize:13,outline:"none",width:200}}),u.jsx("button",{onClick:z,style:{padding:"6px 14px",background:"#45475a",border:"none",borderRadius:6,color:"#cdd6f4",fontSize:13,fontWeight:600,cursor:"pointer"},children:"From Server Path"}),u.jsx("button",{onClick:()=>g(!0),style:{padding:"6px 14px",background:"#89b4fa",border:"none",borderRadius:6,color:"#1e1e2e",fontSize:13,fontWeight:600,cursor:"pointer"},children:"New Workflow"})]}),h&&u.jsxs("div",{style:{padding:"12px 24px",borderBottom:"1px solid #313244",display:"flex",gap:8,alignItems:"center"},children:[u.jsx("input",{autoFocus:!0,value:y,onChange:L=>m(L.target.value),onKeyDown:L=>{L.key==="Enter"&&k(),L.key==="Escape"&&(g(!1),m(""))},placeholder:"Workflow name...",style:{flex:1,padding:"6px 10px",background:"#313244",border:"1px solid #45475a",borderRadius:6,color:"#cdd6f4",fontSize:13,outline:"none"}}),u.jsx("button",{onClick:k,style:yT("#89b4fa"),children:"Create"}),u.jsx("button",{onClick:()=>{g(!1),m("")},style:yT("#45475a"),children:"Cancel"})]}),u.jsxs("div",{style:{flex:1,overflowY:"auto",padding:"8px 24px"},children:[b&&u.jsx("div",{style:{padding:24,textAlign:"center",color:"#6c7086"},children:"Loading..."}),!b&&M.length===0&&u.jsx("div",{style:{padding:24,textAlign:"center",color:"#6c7086"},children:a.length===0?"No workflows yet. Create one to get started.":"No matching workflows."}),_._global&&u.jsxs("div",{style:{padding:"8px 12px",marginBottom:8,background:"rgba(243, 139, 168, 0.15)",borderRadius:6,color:"#f38ba8",fontSize:12},children:[_._global,u.jsx("button",{onClick:()=>j(L=>{const I={...L};return delete I._global,I}),style:{...Ka,color:"#f38ba8",marginLeft:8},children:"×"})]}),M.map(L=>{const I=w[L.id],F=_[L.id],U=I||L.status,B=gT[U]||gT.draft,D=O?l.get(L.project_id)||"Unknown":null;return u.jsxs("div",{children:[u.jsxs("div",{style:{display:"flex",alignItems:"center",padding:"10px 12px",borderRadius:F?"8px 8px 0 0":8,marginBottom:F?0:4,background:"#181825",border:"1px solid #313244",gap:12},children:[u.jsxs("div",{style:{flex:1,cursor:"pointer",minWidth:0},onClick:()=>r(L),children:[u.jsxs("div",{style:{fontWeight:500,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",color:L.is_system?"#f9e2af":"#89b4fa",display:"flex",alignItems:"center",gap:6},children:[!!L.is_system&&u.jsx("span",{title:"System workflow",children:"🛡"}),L.name,!!L.is_system&&u.jsxs("span",{style:{fontSize:10,padding:"1px 5px",borderRadius:8,background:"rgba(249, 226, 175, 0.15)",color:"#f9e2af",fontWeight:600},children:["v",L.version]})]}),u.jsxs("div",{style:{fontSize:11,color:"#6c7086",marginTop:2},children:[!L.is_system&&u.jsxs(u.Fragment,{children:["v",L.version," · "]}),new Date(L.updated_at).toLocaleDateString(),!!L.is_system&&" · Admin Configuration"]})]}),O&&D&&u.jsx("span",{style:{fontSize:11,color:"#a6adc8",maxWidth:140,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flexShrink:0},title:D,children:D}),u.jsx("span",{style:{padding:"3px 8px",borderRadius:10,fontSize:11,fontWeight:600,background:B.bg,color:B.text,whiteSpace:"nowrap"},children:I?`${I}...`:L.status}),u.jsxs("div",{style:{display:"flex",gap:4},children:[(L.status==="draft"||L.status==="stopped"||L.status==="error")&&!I&&u.jsx("button",{onClick:()=>T(L.id),style:Ka,title:"Deploy",children:"▶"}),L.status==="active"&&!I&&u.jsx("button",{onClick:()=>E(L.id),style:Ka,title:"Stop",children:"■"}),u.jsx("button",{onClick:()=>r(L),style:Ka,title:"Edit",children:"✎"}),!L.is_system&&u.jsx("button",{onClick:()=>A(L.id),style:{...Ka,color:"#f38ba8"},title:"Delete",children:"✕"})]})]}),F&&u.jsxs("div",{style:{padding:"6px 12px",background:"rgba(243, 139, 168, 0.1)",borderRadius:"0 0 8px 8px",border:"1px solid #313244",borderTop:"none",marginBottom:4,fontSize:11,color:"#f38ba8",display:"flex",alignItems:"center",gap:8},children:[u.jsx("span",{style:{flex:1},children:F}),u.jsx("button",{onClick:()=>j(q=>{const $={...q};return delete $[L.id],$}),style:{...Ka,color:"#f38ba8",fontSize:12,padding:2},children:"×"})]})]},L.id)})]})]})}const Ka={background:"none",border:"none",color:"#a6adc8",cursor:"pointer",fontSize:14,padding:"4px 6px",borderRadius:4};function yT(e){return{padding:"6px 12px",background:e,border:"none",borderRadius:6,color:e==="#45475a"?"#cdd6f4":"#1e1e2e",fontSize:13,fontWeight:600,cursor:"pointer"}}const mT={viewer:0,operator:1,editor:2,admin:3};function o$(e,n){if(!n)return!0;if(!e)return!1;const r=mT[e]??-1,a=mT[n]??999;return r>=a}function s$(e,n){return n?!e||e.length===0?!1:e.includes(n)||e.includes("*"):!0}function v0(){const e=localStorage.getItem("auth_token"),n={"Content-Type":"application/json"};return e&&(n.Authorization=`Bearer ${e}`),n}function tu(e,n,r){const o=e.filter(d=>d.enabled).flatMap(d=>d.uiPages??[]),l=new Map;for(const d of o)l.set(d.id,d);return Array.from(l.values()).filter(d=>!(!o$(n,d.requiredRole)||!s$(r,d.requiredPermission)))}const Vi=Mn((e,n)=>({plugins:[],loading:!1,loaded:!1,enabling:{},error:null,userRole:void 0,userPermissions:[],enabledPages:[],fetchPlugins:async()=>{if(!n().loading){e({loading:!0,error:null});try{const r=await fetch("/api/v1/admin/plugins",{headers:v0()});if(!r.ok){console.warn("Failed to fetch plugins");const{userRole:c,userPermissions:d}=n();e({loading:!1,loaded:!0,enabledPages:tu([],c,d)});return}const a=await r.json(),{userRole:o,userPermissions:l}=n();e({plugins:a,loaded:!0,loading:!1,enabledPages:tu(a,o,l)})}catch(r){console.warn("Error fetching plugins:",r);const{userRole:a,userPermissions:o}=n();e({loading:!1,loaded:!0,enabledPages:tu([],a,o)})}}},enablePlugin:async r=>{e(a=>({enabling:{...a.enabling,[r]:!0},error:null}));try{const a=await fetch(`/api/v1/admin/plugins/${encodeURIComponent(r)}/enable`,{method:"POST",headers:v0()});if(!a.ok){const o=await a.text().catch(()=>a.statusText);throw new Error(o||`Enable failed: ${a.status}`)}e(o=>({enabling:{...o.enabling,[r]:!1}})),await n().fetchPlugins()}catch(a){e(o=>({enabling:{...o.enabling,[r]:!1},error:a instanceof Error?a.message:"Enable failed"}))}},disablePlugin:async r=>{e(a=>({enabling:{...a.enabling,[r]:!0},error:null}));try{const a=await fetch(`/api/v1/admin/plugins/${encodeURIComponent(r)}/disable`,{method:"POST",headers:v0()});if(!a.ok){const o=await a.text().catch(()=>a.statusText);throw new Error(o||`Disable failed: ${a.status}`)}e(o=>({enabling:{...o.enabling,[r]:!1}})),await n().fetchPlugins()}catch(a){e(o=>({enabling:{...o.enabling,[r]:!1},error:a instanceof Error?a.message:"Disable failed"}))}},setUserAccess:(r,a=[])=>{const{plugins:o}=n();e({userRole:r,userPermissions:a,enabledPages:tu(o,r,a)})},clearError:()=>e({error:null})}));function b0({page:e,isActive:n,onClick:r}){return u.jsx("button",{onClick:r,title:e.label,"aria-label":e.label,"aria-current":n?"page":void 0,style:{width:40,height:40,display:"flex",alignItems:"center",justifyContent:"center",background:"none",border:"none",borderLeft:n?"3px solid #89b4fa":"3px solid transparent",borderRadius:0,cursor:"pointer",padding:0,position:"relative",flexShrink:0,fontSize:18,filter:n?"none":"grayscale(0.6) opacity(0.65)"},children:u.jsx("span",{"aria-hidden":"true",children:e.icon})})}function x0(){return u.jsx("div",{style:{width:28,height:1,background:"#45475a",margin:"6px 0 2px",flexShrink:0},"aria-hidden":"true"})}function l$(){const e=jt(b=>b.activeView),n=jt(b=>b.setActiveView),r=ue(b=>b.activeWorkflowRecord),a=ue(b=>b.nodes),o=jt(b=>b.selectedWorkflowId),l=_r(b=>b.user),c=_r(b=>b.logout),d=Vi(b=>b.enabledPages),p=!!(r||a.length>0||o),{globalPages:h,pluginPages:g,workflowPages:y}=N.useMemo(()=>{const b=d.filter(C=>C.category==="global").sort((C,_)=>C.order-_.order),S=d.filter(C=>C.category==="plugin").sort((C,_)=>C.order-_.order),w=d.filter(C=>C.category==="workflow").sort((C,_)=>C.order-_.order);return{globalPages:b,pluginPages:S,workflowPages:w}},[d]),m=N.useCallback(b=>{n(b)},[n]);return u.jsxs("nav",{role:"navigation","aria-label":"Main navigation",style:{width:48,minWidth:48,background:"#11111b",display:"flex",flexDirection:"column",alignItems:"center",paddingTop:8,gap:4,borderRight:"1px solid #313244",position:"relative",zIndex:10,flexShrink:0},children:[h.map(b=>u.jsx(b0,{page:b,isActive:e===b.id,onClick:()=>m(b.id)},b.id)),g.length>0&&u.jsxs(u.Fragment,{children:[u.jsx(x0,{}),g.map(b=>u.jsx(b0,{page:b,isActive:e===b.id,onClick:()=>m(b.id)},b.id))]}),p&&y.length>0&&u.jsxs(u.Fragment,{children:[u.jsx(x0,{}),u.jsx("div",{style:{fontSize:8,fontWeight:700,color:"#585b70",textTransform:"uppercase",letterSpacing:1,marginBottom:2,flexShrink:0},"aria-hidden":"true",children:"WF"}),y.map(b=>u.jsx(b0,{page:b,isActive:e===b.id,onClick:()=>m(b.id)},b.id))]}),u.jsx("div",{style:{flex:1}}),u.jsx(x0,{}),u.jsx("button",{onClick:c,title:`Sign out${l?` (${l.email})`:""}`,"aria-label":"Sign out",style:{width:40,height:40,display:"flex",alignItems:"center",justifyContent:"center",background:"none",border:"none",borderLeft:"3px solid transparent",borderRadius:0,cursor:"pointer",padding:0,flexShrink:0,fontSize:18,filter:"grayscale(0.4) opacity(0.7)",marginBottom:4},children:u.jsx("span",{"aria-hidden":"true",children:"🚪"})})]})}const c$={draft:"#6c7086",active:"#a6e3a1",stopped:"#f9e2af",error:"#f38ba8"},u$={pending:"#6c7086",running:"#89b4fa",completed:"#a6e3a1",failed:"#f38ba8",cancelled:"#f9e2af"};function nu({label:e,value:n,color:r}){return u.jsxs("div",{style:{background:"#313244",borderRadius:8,padding:"16px 20px",borderLeft:`4px solid ${r}`,flex:1,minWidth:160},children:[u.jsx("div",{style:{fontSize:28,fontWeight:700,color:"#cdd6f4"},children:n}),u.jsx("div",{style:{fontSize:12,color:"#a6adc8",marginTop:4},children:e})]})}function yA({status:e}){const n=c$[e]||"#6c7086";return u.jsx("span",{style:{display:"inline-block",padding:"2px 10px",borderRadius:12,fontSize:11,fontWeight:600,background:n+"22",color:n},children:e})}function d$({summary:e,onClick:n,onDeploy:r,onStop:a,actionInProgress:o}){const l=Object.values(e.executions).reduce((g,y)=>g+y,0),c=(e.log_counts?.error??0)+(e.log_counts?.fatal??0),d=o||e.status,p=(e.status==="draft"||e.status==="stopped"||e.status==="error")&&!o,h=e.status==="active"&&!o;return u.jsxs("div",{style:{background:"#313244",border:"1px solid #45475a",borderRadius:8,padding:16,cursor:"pointer",transition:"border-color 0.15s"},onMouseEnter:g=>g.currentTarget.style.borderColor="#89b4fa",onMouseLeave:g=>g.currentTarget.style.borderColor="#45475a",children:[u.jsxs("div",{onClick:n,children:[u.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:8},children:[u.jsx("span",{style:{color:"#cdd6f4",fontWeight:600,fontSize:14},children:e.workflow_name}),u.jsx(yA,{status:d})]}),u.jsxs("div",{style:{fontSize:12,color:"#a6adc8"},children:[l," executions",c>0&&u.jsxs("span",{style:{color:"#f38ba8",marginLeft:8},children:[c," errors"]})]})]}),u.jsxs("div",{style:{display:"flex",gap:6,marginTop:10,borderTop:"1px solid #45475a",paddingTop:10},children:[p&&u.jsx("button",{onClick:g=>{g.stopPropagation(),r()},style:{background:"rgba(166, 227, 161, 0.15)",color:"#a6e3a1",border:"1px solid rgba(166, 227, 161, 0.3)",borderRadius:4,padding:"3px 10px",fontSize:11,fontWeight:600,cursor:"pointer"},children:"Deploy"}),h&&u.jsx("button",{onClick:g=>{g.stopPropagation(),a()},style:{background:"rgba(249, 226, 175, 0.15)",color:"#f9e2af",border:"1px solid rgba(249, 226, 175, 0.3)",borderRadius:4,padding:"3px 10px",fontSize:11,fontWeight:600,cursor:"pointer"},children:"Stop"}),o&&u.jsxs("span",{style:{fontSize:11,color:"#6c7086",padding:"3px 0"},children:[o,"..."]}),u.jsx("button",{onClick:g=>{g.stopPropagation(),n()},style:{background:"none",color:"#89b4fa",border:"1px solid #45475a",borderRadius:4,padding:"3px 10px",fontSize:11,cursor:"pointer",marginLeft:"auto"},children:"View"})]})]})}function f$(){const{systemDashboard:e,dashboardLoading:n,fetchSystemDashboard:r,setActiveView:a,setSelectedWorkflowId:o}=jt(),l=ue(E=>E.setActiveWorkflowRecord),c=ue(E=>E.renameTab),d=ue(E=>E.activeTabId),[p,h]=N.useState([]),[g,y]=N.useState({}),m=N.useCallback(async E=>{y(z=>({...z,[E]:"deploying"}));try{await ud(E),r()}catch{}finally{y(z=>{const A={...z};return delete A[E],A})}},[r]),b=N.useCallback(async E=>{y(z=>({...z,[E]:"stopping"}));try{await dd(E),r()}catch{}finally{y(z=>{const A={...z};return delete A[E],A})}},[r]);N.useEffect(()=>{r(),p0().then(z=>h(z.instances??[])).catch(()=>{});const E=setInterval(()=>{r(),p0().then(z=>h(z.instances??[])).catch(()=>{})},1e4);return()=>clearInterval(E)},[r]);const S=N.useMemo(()=>e?.workflow_summaries??[],[e]),w=N.useCallback(E=>{const A=S.find(M=>M.workflow_id===E)?.workflow_name??E;o(E),c(d,A),l({id:E,name:A}),a("executions")},[a,o,S,c,d,l]),C=S.filter(E=>E.status==="active").length,_=S.reduce((E,z)=>E+Object.values(z.executions).reduce((A,M)=>A+M,0),0),j=S.reduce((E,z)=>E+(z.executions?.failed??0),0),k=_>0?(j/_*100).toFixed(1):"0",T=S.filter(E=>(E.executions?.failed??0)>0).map(E=>({name:E.workflow_name,count:E.executions.failed??0,id:E.workflow_id})).sort((E,z)=>z.count-E.count).slice(0,5);return u.jsxs("div",{style:{flex:1,background:"#1e1e2e",overflow:"auto",padding:24},children:[u.jsxs("h2",{style:{color:"#cdd6f4",margin:"0 0 20px",fontSize:20,fontWeight:600},children:["System Dashboard ",u.jsx("span",{style:{fontSize:12,color:"#6c7086",fontWeight:400},children:"v1.0.0"})]}),n&&!e&&u.jsx("div",{style:{color:"#6c7086",padding:40,textAlign:"center"},children:"Loading..."}),u.jsxs("div",{style:{display:"flex",gap:16,marginBottom:24,flexWrap:"wrap"},children:[u.jsx(nu,{label:"Total Workflows",value:e?.total_workflows??0,color:"#89b4fa"}),u.jsx(nu,{label:"Active Workflows",value:C,color:"#a6e3a1"}),u.jsx(nu,{label:"Total Executions",value:_,color:"#fab387"}),u.jsx(nu,{label:"Error Rate",value:`${k}%`,color:"#f38ba8"})]}),u.jsx("h3",{style:{color:"#cdd6f4",fontSize:14,fontWeight:600,marginBottom:12},children:"Workflows"}),u.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(260px, 1fr))",gap:12,marginBottom:24},children:[S.map(E=>u.jsx(d$,{summary:E,onClick:()=>w(E.workflow_id),onDeploy:()=>m(E.workflow_id),onStop:()=>b(E.workflow_id),actionInProgress:g[E.workflow_id]},E.workflow_id)),S.length===0&&!n&&u.jsx("div",{style:{color:"#6c7086",fontSize:13,gridColumn:"1 / -1"},children:"No workflows found."})]}),p.length>0&&u.jsxs(u.Fragment,{children:[u.jsxs("h3",{style:{color:"#cdd6f4",fontSize:14,fontWeight:600,marginBottom:12},children:["Runtime Instances (",p.length,")"]}),u.jsx("div",{style:{background:"#313244",borderRadius:8,overflow:"hidden",marginBottom:24},children:p.map((E,z)=>u.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"10px 16px",borderBottom:zfP(E.id).then(()=>p0().then(A=>h(A.instances??[])).catch(()=>{})),style:{background:"#f38ba822",color:"#f38ba8",border:"1px solid #f38ba844",borderRadius:4,padding:"2px 8px",fontSize:11,cursor:"pointer"},children:"Stop"})]})]},E.id))})]}),T.length>0&&u.jsxs(u.Fragment,{children:[u.jsx("h3",{style:{color:"#cdd6f4",fontSize:14,fontWeight:600,marginBottom:12},children:"Top Errors"}),u.jsx("div",{style:{background:"#313244",borderRadius:8,overflow:"hidden"},children:T.map((E,z)=>u.jsxs("div",{style:{display:"flex",justifyContent:"space-between",padding:"10px 16px",borderBottom:zw(E.id),children:[u.jsx("span",{style:{color:"#cdd6f4",fontSize:13},children:E.name}),u.jsxs("span",{style:{color:"#f38ba8",fontSize:13,fontWeight:600,background:"#f38ba822",padding:"1px 8px",borderRadius:8},children:[E.count," failed"]})]},E.id))})]}),S.length>0&&u.jsxs(u.Fragment,{children:[u.jsx("h3",{style:{color:"#cdd6f4",fontSize:14,fontWeight:600,margin:"24px 0 12px"},children:"Execution Status Breakdown"}),u.jsxs("div",{style:{background:"#313244",borderRadius:8,overflow:"hidden"},children:[u.jsxs("div",{style:{display:"grid",gridTemplateColumns:"2fr repeat(5, 1fr)",padding:"10px 16px",background:"#181825",fontSize:11,color:"#a6adc8",fontWeight:600},children:[u.jsx("span",{children:"Workflow"}),u.jsx("span",{children:"Pending"}),u.jsx("span",{children:"Running"}),u.jsx("span",{children:"Completed"}),u.jsx("span",{children:"Failed"}),u.jsx("span",{children:"Cancelled"})]}),S.map((E,z)=>u.jsxs("div",{style:{display:"grid",gridTemplateColumns:"2fr repeat(5, 1fr)",padding:"8px 16px",borderBottom:zu.jsx("span",{style:{color:u$[A]},children:E.executions[A]??0},A))]},E.workflow_id))]})]})]})}const mA={pending:"#6c7086",running:"#89b4fa",completed:"#a6e3a1",failed:"#f38ba8",cancelled:"#f9e2af",skipped:"#6c7086"};function vT({status:e}){const n=mA[e]||"#6c7086";return u.jsx("span",{style:{display:"inline-block",padding:"2px 10px",borderRadius:12,fontSize:11,fontWeight:600,background:n+"22",color:n},children:e})}function vA(e){return e==null?"-":e<1e3?`${e}ms`:e<6e4?`${(e/1e3).toFixed(1)}s`:`${(e/6e4).toFixed(1)}m`}function p$(e){return new Date(e).toLocaleString()}function h$(e){return e.length>8?e.slice(0,8)+"...":e}function g$({steps:e}){const[n,r]=N.useState(null),a=[...e].sort((l,c)=>l.sequence_num-c.sequence_num),o=Math.max(...a.map(l=>l.duration_ms??0),1);return u.jsxs("div",{style:{padding:"12px 16px 12px 32px",background:"#181825",borderTop:"1px solid #45475a"},children:[a.map(l=>{const c=l.duration_ms?Math.max(l.duration_ms/o*100,4):4,d=l.status==="failed",p=n===l.id;return u.jsxs("div",{style:{marginBottom:8},children:[u.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer",padding:"4px 0"},onClick:()=>r(p?null:l.id),children:[u.jsx("div",{style:{width:8,height:8,borderRadius:"50%",background:mA[l.status]||"#6c7086",flexShrink:0}}),u.jsx("span",{style:{color:"#cdd6f4",fontSize:12,fontWeight:500,minWidth:120},children:l.step_name}),u.jsx("span",{style:{fontSize:10,padding:"1px 6px",borderRadius:4,background:"#45475a",color:"#a6adc8"},children:l.step_type}),u.jsx("div",{style:{flex:1,height:6,background:"#45475a",borderRadius:3,overflow:"hidden"},children:u.jsx("div",{style:{width:`${c}%`,height:"100%",background:d?"#f38ba8":"#89b4fa",borderRadius:3}})}),u.jsx("span",{style:{color:"#a6adc8",fontSize:11,minWidth:50,textAlign:"right"},children:vA(l.duration_ms)})]}),d&&l.error_message&&u.jsx("div",{style:{color:"#f38ba8",fontSize:11,marginLeft:24,marginTop:2},children:l.error_message}),p&&u.jsxs("div",{style:{marginLeft:24,marginTop:4,fontSize:11},children:[l.input_data!=null&&u.jsxs("div",{style:{marginBottom:4},children:[u.jsx("span",{style:{color:"#a6adc8"},children:"Input: "}),u.jsx("pre",{style:{background:"#0d1117",padding:8,borderRadius:4,color:"#a6e3a1",overflow:"auto",maxHeight:120,margin:"2px 0",fontFamily:"monospace",fontSize:11},children:JSON.stringify(l.input_data,null,2)})]}),l.output_data!=null&&u.jsxs("div",{children:[u.jsx("span",{style:{color:"#a6adc8"},children:"Output: "}),u.jsx("pre",{style:{background:"#0d1117",padding:8,borderRadius:4,color:"#a6e3a1",overflow:"auto",maxHeight:120,margin:"2px 0",fontFamily:"monospace",fontSize:11},children:JSON.stringify(l.output_data,null,2)})]})]})]},l.id)}),a.length===0&&u.jsx("div",{style:{color:"#6c7086",fontSize:12},children:"No steps recorded."})]})}function y$(){const{selectedWorkflowId:e,executions:n,executionSteps:r,executionFilter:a,fetchExecutions:o,fetchExecutionSteps:l,setExecutionFilter:c,triggerExecution:d,cancelExecution:p,setActiveView:h,setSelectedWorkflowId:g,workflowDashboard:y,fetchWorkflowDashboard:m}=jt(),[b,S]=N.useState(null),[w,C]=N.useState(""),[_,j]=N.useState(null),k=N.useCallback(async()=>{if(e){j("deploying");try{await ud(e),m(e)}catch{}finally{j(null)}}},[e,m]),T=N.useCallback(async()=>{if(e){j("stopping");try{await dd(e),m(e)}catch{}finally{j(null)}}},[e,m]);N.useEffect(()=>{e&&(o(e,a),m(e))},[e,a,o,m]),N.useEffect(()=>{if(!e)return;const q=setInterval(()=>{o(e,a)},1e4);return()=>clearInterval(q)},[e,a,o]);const E=N.useCallback(q=>{if(b===q.id){S(null);return}S(q.id),l(q.id)},[b,l]),z=N.useCallback(q=>{C(q),c({...a,status:q||void 0})},[a,c]),A=N.useCallback(()=>{g(null),h("dashboard")},[h,g]),M=y?.workflow?.name??"Workflow",O=y?.workflow?.status??"",P=y?.execution_counts??{},L=Object.values(P).reduce((q,$)=>q+$,0),I=N.useMemo(()=>{const q={};for(const $ of n)q[$.status]=(q[$.status]??0)+1;return q},[n]),F=n.length,U=L>0?L:F,B=L>0?P.completed??0:I.completed??0,D=U>0?(B/U*100).toFixed(0):"-";return u.jsxs("div",{style:{flex:1,background:"#1e1e2e",overflow:"auto",padding:24},children:[u.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,marginBottom:20},children:[u.jsx("button",{onClick:A,style:{background:"none",border:"none",color:"#89b4fa",cursor:"pointer",fontSize:13,padding:"2px 4px"},children:"← Dashboard"}),u.jsx("h2",{style:{color:"#cdd6f4",margin:0,fontSize:20,fontWeight:600},children:M}),O&&u.jsx(vT,{status:O}),u.jsx("div",{style:{flex:1}}),e&&(O==="draft"||O==="stopped"||O==="error")&&!_&&u.jsx("button",{onClick:k,style:{background:"rgba(166, 227, 161, 0.2)",border:"1px solid rgba(166, 227, 161, 0.4)",borderRadius:6,color:"#a6e3a1",padding:"6px 16px",fontSize:13,fontWeight:600,cursor:"pointer"},children:"Deploy"}),e&&O==="active"&&!_&&u.jsx("button",{onClick:T,style:{background:"rgba(249, 226, 175, 0.2)",border:"1px solid rgba(249, 226, 175, 0.4)",borderRadius:6,color:"#f9e2af",padding:"6px 16px",fontSize:13,fontWeight:600,cursor:"pointer"},children:"Stop"}),_&&u.jsxs("span",{style:{color:"#6c7086",fontSize:13},children:[_,"..."]}),e&&u.jsx("button",{onClick:()=>d(e),style:{background:"#89b4fa",border:"none",borderRadius:6,color:"#1e1e2e",padding:"6px 16px",fontSize:13,fontWeight:600,cursor:"pointer"},children:"Trigger Execution"})]}),u.jsxs("div",{style:{display:"flex",gap:16,marginBottom:20,flexWrap:"wrap"},children:[u.jsxs("div",{style:{background:"#313244",borderRadius:8,padding:"12px 20px",borderLeft:"4px solid #a6e3a1",minWidth:120},children:[u.jsxs("div",{style:{fontSize:24,fontWeight:700,color:"#cdd6f4"},children:[D,"%"]}),u.jsx("div",{style:{fontSize:11,color:"#a6adc8"},children:"Success Rate"})]}),u.jsxs("div",{style:{background:"#313244",borderRadius:8,padding:"12px 20px",borderLeft:"4px solid #89b4fa",minWidth:120},children:[u.jsx("div",{style:{fontSize:24,fontWeight:700,color:"#cdd6f4"},children:U}),u.jsx("div",{style:{fontSize:11,color:"#a6adc8"},children:"Total Executions"})]})]}),u.jsxs("div",{style:{display:"flex",gap:8,marginBottom:16,alignItems:"center"},children:[u.jsx("span",{style:{color:"#a6adc8",fontSize:12},children:"Filter:"}),["","pending","running","completed","failed","cancelled"].map(q=>u.jsx("button",{onClick:()=>z(q),style:{background:w===q?"#89b4fa":"#313244",color:w===q?"#1e1e2e":"#cdd6f4",border:"1px solid #45475a",borderRadius:4,padding:"3px 10px",fontSize:11,cursor:"pointer",fontWeight:w===q?600:400},children:q||"All"},q))]}),u.jsxs("div",{style:{background:"#313244",borderRadius:8,overflow:"hidden"},children:[u.jsxs("div",{style:{display:"grid",gridTemplateColumns:"100px 100px 100px 90px 140px 60px",padding:"10px 16px",background:"#181825",fontSize:11,color:"#a6adc8",fontWeight:600},children:[u.jsx("span",{children:"ID"}),u.jsx("span",{children:"Trigger"}),u.jsx("span",{children:"Status"}),u.jsx("span",{children:"Duration"}),u.jsx("span",{children:"Started"}),u.jsx("span",{})]}),n.map((q,$)=>u.jsxs("div",{children:[u.jsxs("div",{onClick:()=>E(q),style:{display:"grid",gridTemplateColumns:"100px 100px 100px 90px 140px 60px",padding:"8px 16px",borderBottom:"1px solid #45475a",fontSize:12,background:$%2===0?"transparent":"#181825",cursor:"pointer",alignItems:"center"},children:[u.jsx("span",{style:{color:"#89b4fa",fontFamily:"monospace",fontSize:11},children:h$(q.id)}),u.jsx("span",{style:{color:"#a6adc8"},children:q.trigger_type}),u.jsx("span",{children:u.jsx(vT,{status:q.status})}),u.jsx("span",{style:{color:"#a6adc8"},children:vA(q.duration_ms)}),u.jsx("span",{style:{color:"#a6adc8",fontSize:11},children:p$(q.started_at)}),u.jsx("span",{children:(q.status==="pending"||q.status==="running")&&u.jsx("button",{onClick:K=>{K.stopPropagation(),p(q.id)},style:{background:"#f38ba822",border:"1px solid #f38ba8",borderRadius:4,color:"#f38ba8",fontSize:10,padding:"2px 6px",cursor:"pointer"},children:"Cancel"})})]}),b===q.id&&u.jsx(g$,{steps:r})]},q.id)),n.length===0&&u.jsx("div",{style:{padding:20,color:"#6c7086",fontSize:13,textAlign:"center"},children:"No executions found."})]})]})}const ru={debug:"#6c7086",info:"#89b4fa",warn:"#f9e2af",error:"#f38ba8",fatal:"#f38ba8"},m$=["debug","info","warn","error","fatal"];function v$(e){return new Date(e).toISOString().replace("T"," ").slice(0,23)}function b$(){const{logEntries:e,logStreaming:n,logFilter:r,selectedWorkflowId:a,fetchLogs:o,setLogFilter:l,startLogStream:c,stopLogStream:d}=jt(),[p,h]=N.useState(""),[g,y]=N.useState(""),[m,b]=N.useState(!0),S=N.useRef(null);N.useEffect(()=>{a&&o(a,r)},[a,r,o]),N.useEffect(()=>{m&&S.current&&(S.current.scrollTop=S.current.scrollHeight)},[e,m]);const w=N.useCallback(()=>{if(!S.current)return;const{scrollTop:T,scrollHeight:E,clientHeight:z}=S.current,A=E-T-z<40;b(A)},[]),C=N.useCallback(()=>{n?d():a&&c(a)},[n,a,c,d]),_=N.useCallback(T=>{const E=g===T?"":T;y(E),l({...r,level:E||void 0})},[g,r,l]),j=e.filter(T=>{if(p){const E=p.toLowerCase();if(!T.message.toLowerCase().includes(E)&&!(T.module_name||"").toLowerCase().includes(E))return!1}return!0}),k=N.useCallback(()=>{const T=JSON.stringify(j,null,2),E=new Blob([T],{type:"application/json"}),z=URL.createObjectURL(E),A=document.createElement("a");A.href=z,A.download=`logs-${new Date().toISOString().slice(0,10)}.json`,A.click(),URL.revokeObjectURL(z)},[j]);return u.jsxs("div",{style:{flex:1,background:"#1e1e2e",display:"flex",flexDirection:"column",overflow:"hidden"},children:[u.jsxs("div",{style:{padding:"12px 16px",borderBottom:"1px solid #313244",display:"flex",alignItems:"center",gap:8,flexWrap:"wrap"},children:[u.jsx("h2",{style:{color:"#cdd6f4",margin:0,fontSize:16,fontWeight:600,marginRight:12},children:"Logs"}),m$.map(T=>u.jsx("button",{onClick:()=>_(T),style:{background:g===T?ru[T]+"33":"#313244",color:g===T?ru[T]:"#a6adc8",border:`1px solid ${g===T?ru[T]:"#45475a"}`,borderRadius:4,padding:"3px 8px",fontSize:11,cursor:"pointer",fontWeight:g===T?600:400,textTransform:"uppercase"},children:T},T)),u.jsx("input",{type:"text",placeholder:"Search logs...",value:p,onChange:T=>h(T.target.value),style:{background:"#313244",border:"1px solid #45475a",borderRadius:4,color:"#cdd6f4",padding:"4px 8px",fontSize:12,outline:"none",width:180,marginLeft:"auto"}}),u.jsx("button",{onClick:C,style:{background:n?"#a6e3a122":"#313244",color:n?"#a6e3a1":"#a6adc8",border:`1px solid ${n?"#a6e3a1":"#45475a"}`,borderRadius:4,padding:"4px 10px",fontSize:11,cursor:"pointer",fontWeight:600},children:n?"Streaming":"Stream"}),u.jsx("button",{onClick:k,style:{background:"#313244",border:"1px solid #45475a",borderRadius:4,color:"#a6adc8",padding:"4px 10px",fontSize:11,cursor:"pointer"},children:"Export"})]}),!a&&u.jsx("div",{style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",color:"#6c7086"},children:"Select a workflow from the Dashboard to view logs."}),a&&u.jsxs("div",{ref:S,onScroll:w,style:{flex:1,overflow:"auto",background:"#0d1117",fontFamily:"monospace",fontSize:12,lineHeight:"20px",padding:"8px 0"},children:[j.map(T=>{const E=ru[T.level]||"#cdd6f4",z=T.level==="fatal";return u.jsxs("div",{style:{padding:"1px 12px",whiteSpace:"pre-wrap",wordBreak:"break-word",fontWeight:z?700:400},children:[u.jsxs("span",{style:{color:"#6c7086"},children:["[",v$(T.created_at),"]"]})," ",u.jsxs("span",{style:{color:E,fontWeight:600},children:["[",T.level.toUpperCase().padEnd(5),"]"]})," ",T.module_name&&u.jsxs("span",{style:{color:"#fab387"},children:["[",T.module_name,"]"]})," ",u.jsx("span",{style:{color:"#cdd6f4"},children:T.message})]},T.id)}),j.length===0&&u.jsx("div",{style:{padding:20,color:"#6c7086",textAlign:"center"},children:e.length===0?"No log entries.":"No logs match the current filter."})]})]})}const bA={event:"#89b4fa",info:"#a6e3a1",warn:"#f9e2af",error:"#f38ba8",fatal:"#cba6f7",debug:"#6c7086"};function x$(e){return new Date(e).toLocaleString()}function S$({event:e,isExpanded:n,onToggle:r}){const a=bA[e.level]||"#6c7086",o=String(e.id).slice(0,8);let l=null;if(e.fields)try{l=JSON.parse(e.fields)}catch{}return u.jsxs("div",{style:{background:"#313244",border:"1px solid #45475a",borderRadius:8,marginBottom:8,overflow:"hidden"},children:[u.jsxs("div",{onClick:r,style:{display:"flex",alignItems:"center",gap:10,padding:"10px 14px",cursor:"pointer"},children:[u.jsx("span",{style:{display:"inline-block",padding:"2px 8px",borderRadius:4,fontSize:10,fontWeight:600,background:a+"22",color:a},children:e.level.toUpperCase()}),u.jsx("span",{style:{color:"#cdd6f4",fontSize:12,flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.message}),e.module_name&&u.jsxs("span",{style:{color:"#89b4fa",fontSize:11,fontFamily:"monospace"},children:["[",e.module_name,"]"]}),u.jsxs("span",{style:{color:"#6c7086",fontSize:11,fontFamily:"monospace"},children:["#",o]}),u.jsx("span",{style:{color:"#6c7086",fontSize:11},children:x$(e.created_at)}),u.jsx("span",{style:{color:"#6c7086",fontSize:12},children:n?"▲":"▼"})]}),n&&u.jsxs("div",{style:{borderTop:"1px solid #45475a",padding:12,background:"#181825"},children:[e.execution_id&&u.jsxs("div",{style:{marginBottom:8},children:[u.jsx("div",{style:{color:"#a6adc8",fontSize:11,marginBottom:4},children:"Execution ID"}),u.jsx("code",{style:{color:"#89b4fa",fontSize:11},children:e.execution_id})]}),l&&Object.keys(l).length>0&&u.jsxs("div",{style:{marginBottom:8},children:[u.jsx("div",{style:{color:"#a6adc8",fontSize:11,marginBottom:4},children:"Fields"}),u.jsx("pre",{style:{background:"#0d1117",padding:8,borderRadius:4,color:"#a6e3a1",fontSize:11,fontFamily:"monospace",overflow:"auto",maxHeight:200,margin:0},children:JSON.stringify(l,null,2)})]})]})]})}function w$(){const{events:e,eventStreaming:n,selectedWorkflowId:r,fetchEvents:a,startEventStream:o,stopEventStream:l}=jt(),[c,d]=N.useState(null),[p,h]=N.useState("");N.useEffect(()=>{r&&a(r)},[r,a]);const g=N.useCallback(()=>{n?l():r&&o(r)},[n,r,o,l]),y=e.filter(b=>!(p&&!b.message.toLowerCase().includes(p.toLowerCase()))),m={};for(const b of e)m[b.level]=(m[b.level]||0)+1;return u.jsxs("div",{style:{flex:1,background:"#1e1e2e",display:"flex",flexDirection:"column",overflow:"hidden"},children:[u.jsxs("div",{style:{padding:"12px 16px",borderBottom:"1px solid #313244",display:"flex",alignItems:"center",gap:8,flexWrap:"wrap"},children:[u.jsx("h2",{style:{color:"#cdd6f4",margin:0,fontSize:16,fontWeight:600,marginRight:12},children:"Events"}),u.jsx("input",{type:"text",value:p,onChange:b=>h(b.target.value),placeholder:"Filter events...",style:{background:"#313244",border:"1px solid #45475a",borderRadius:4,color:"#cdd6f4",padding:"4px 8px",fontSize:12,outline:"none",width:180}}),u.jsx("span",{style:{flex:1}}),u.jsx("button",{onClick:g,style:{background:n?"#a6e3a122":"#313244",color:n?"#a6e3a1":"#a6adc8",border:`1px solid ${n?"#a6e3a1":"#45475a"}`,borderRadius:4,padding:"4px 10px",fontSize:11,cursor:"pointer",fontWeight:600},children:n?"Live":"Stream"})]}),!r&&u.jsx("div",{style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",color:"#6c7086"},children:"Select a workflow from the Dashboard to view events."}),r&&u.jsxs("div",{style:{flex:1,overflow:"auto",padding:16},children:[u.jsxs("div",{style:{display:"flex",gap:12,marginBottom:16,flexWrap:"wrap"},children:[Object.entries(m).map(([b,S])=>u.jsxs("div",{style:{background:"#313244",borderRadius:8,padding:"8px 16px",borderLeft:`3px solid ${bA[b]||"#6c7086"}`},children:[u.jsx("div",{style:{fontSize:18,fontWeight:700,color:"#cdd6f4"},children:S}),u.jsx("div",{style:{fontSize:10,color:"#a6adc8",textTransform:"capitalize"},children:b})]},b)),u.jsxs("div",{style:{background:"#313244",borderRadius:8,padding:"8px 16px",borderLeft:"3px solid #fab387"},children:[u.jsx("div",{style:{fontSize:18,fontWeight:700,color:"#cdd6f4"},children:e.length}),u.jsx("div",{style:{fontSize:10,color:"#a6adc8"},children:"Total"})]})]}),y.map(b=>u.jsx(S$,{event:b,isExpanded:c===b.id,onToggle:()=>d(c===b.id?null:b.id)},b.id)),y.length===0&&u.jsx("div",{style:{color:"#6c7086",textAlign:"center",padding:40},children:"No events found."})]})]})}function _$({onClose:e,onCreated:n}){const[r,a]=N.useState(""),[o,l]=N.useState(""),[c,d]=N.useState(""),[p,h]=N.useState("user"),[g,y]=N.useState(null),[m,b]=N.useState(!1),S=async w=>{if(w.preventDefault(),y(null),c.length<6){y("Password must be at least 6 characters");return}b(!0);try{await IF(r,c,o,p),n(),e()}catch(C){y(C instanceof Error?C.message:"Failed to create user")}finally{b(!1)}};return u.jsx("div",{style:{position:"fixed",inset:0,background:"rgba(0,0,0,0.6)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},onClick:e,children:u.jsxs("div",{onClick:w=>w.stopPropagation(),style:{background:"#1e1e2e",border:"1px solid #45475a",borderRadius:12,padding:24,width:400},children:[u.jsx("h3",{style:{color:"#cdd6f4",margin:"0 0 16px",fontSize:16},children:"Add User"}),g&&u.jsx("div",{style:{background:"rgba(243, 139, 168, 0.15)",border:"1px solid #f38ba8",borderRadius:6,padding:"8px 12px",marginBottom:12,color:"#f38ba8",fontSize:13},children:g}),u.jsxs("form",{onSubmit:S,children:[u.jsxs("div",{style:{marginBottom:12},children:[u.jsx("label",{style:{color:"#a6adc8",fontSize:12,display:"block",marginBottom:4},children:"Name"}),u.jsx("input",{type:"text",value:o,onChange:w=>l(w.target.value),placeholder:"User name",style:S0})]}),u.jsxs("div",{style:{marginBottom:12},children:[u.jsx("label",{style:{color:"#a6adc8",fontSize:12,display:"block",marginBottom:4},children:"Email"}),u.jsx("input",{type:"email",value:r,onChange:w=>a(w.target.value),required:!0,placeholder:"user@example.com",style:S0})]}),u.jsxs("div",{style:{marginBottom:12},children:[u.jsx("label",{style:{color:"#a6adc8",fontSize:12,display:"block",marginBottom:4},children:"Password"}),u.jsx("input",{type:"password",value:c,onChange:w=>d(w.target.value),required:!0,placeholder:"Min 6 characters",style:S0})]}),u.jsxs("div",{style:{marginBottom:12},children:[u.jsx("label",{style:{color:"#a6adc8",fontSize:12,display:"block",marginBottom:4},children:"Role"}),u.jsxs("select",{value:p,onChange:w=>h(w.target.value),style:{width:"100%",background:"#313244",border:"1px solid #45475a",borderRadius:6,color:"#cdd6f4",padding:"8px 12px",fontSize:13,outline:"none"},children:[u.jsx("option",{value:"user",children:"User"}),u.jsx("option",{value:"admin",children:"Admin"})]})]}),u.jsxs("div",{style:{display:"flex",gap:8,marginTop:20},children:[u.jsx("button",{type:"submit",disabled:m,style:{background:m?"#585b70":"#89b4fa",border:"none",borderRadius:6,color:"#1e1e2e",padding:"8px 20px",fontSize:13,fontWeight:600,cursor:m?"not-allowed":"pointer"},children:m?"Creating...":"Create"}),u.jsx("button",{type:"button",onClick:e,style:{background:"#313244",border:"1px solid #45475a",borderRadius:6,color:"#cdd6f4",padding:"8px 20px",fontSize:13,cursor:"pointer"},children:"Cancel"})]})]})]})})}const S0={width:"100%",background:"#313244",border:"1px solid #45475a",borderRadius:6,color:"#cdd6f4",padding:"8px 12px",fontSize:13,outline:"none",boxSizing:"border-box"};function k$(){const[e,n]=N.useState([]),[r,a]=N.useState(!0),[o,l]=N.useState(null),[c,d]=N.useState(!1),[p,h]=N.useState(null),g=_r(S=>S.user),y=N.useCallback(async()=>{try{const S=await qF();n(S),l(null)}catch(S){l(S instanceof Error?S.message:"Failed to load users")}finally{a(!1)}},[]);N.useEffect(()=>{y()},[y]);const m=async(S,w)=>{try{await BF(S,w),await y()}catch(C){l(C instanceof Error?C.message:"Failed to update role")}},b=async S=>{try{await LF(S),h(null),await y()}catch(w){l(w instanceof Error?w.message:"Failed to delete user")}};return u.jsxs("div",{children:[u.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,marginBottom:16},children:[u.jsx("h3",{style:{color:"#cdd6f4",margin:0,fontSize:16,fontWeight:600},children:"Users"}),u.jsx("span",{style:{flex:1}}),u.jsx("button",{onClick:()=>d(!0),style:{background:"#89b4fa",border:"none",borderRadius:6,color:"#1e1e2e",padding:"8px 16px",fontSize:13,fontWeight:600,cursor:"pointer"},children:"Add User"})]}),o&&u.jsx("div",{style:{background:"rgba(243, 139, 168, 0.15)",border:"1px solid #f38ba8",borderRadius:6,padding:"8px 12px",marginBottom:12,color:"#f38ba8",fontSize:13},children:o}),r?u.jsx("div",{style:{color:"#6c7086",fontSize:13,padding:20,textAlign:"center"},children:"Loading users..."}):u.jsxs("div",{style:{background:"#313244",borderRadius:8,overflow:"hidden"},children:[u.jsxs("div",{style:{display:"grid",gridTemplateColumns:"2fr 2fr 100px 140px 80px",padding:"10px 16px",background:"#181825",fontSize:11,color:"#a6adc8",fontWeight:600},children:[u.jsx("span",{children:"Email"}),u.jsx("span",{children:"Name"}),u.jsx("span",{children:"Role"}),u.jsx("span",{children:"Created"}),u.jsx("span",{children:"Actions"})]}),e.map((S,w)=>u.jsxs("div",{children:[u.jsxs("div",{style:{display:"grid",gridTemplateColumns:"2fr 2fr 100px 140px 80px",padding:"10px 16px",borderBottom:"1px solid #45475a",fontSize:13,background:w%2===0?"transparent":"#181825",alignItems:"center"},children:[u.jsx("span",{style:{color:"#cdd6f4",overflow:"hidden",textOverflow:"ellipsis"},children:S.email}),u.jsx("span",{style:{color:"#a6adc8"},children:S.name||"-"}),u.jsx("span",{children:u.jsxs("select",{value:S.role||"user",onChange:C=>m(S.id,C.target.value),style:{background:"#313244",border:"1px solid #45475a",borderRadius:4,color:"#cdd6f4",padding:"2px 6px",fontSize:11,outline:"none"},children:[u.jsx("option",{value:"user",children:"user"}),u.jsx("option",{value:"admin",children:"admin"})]})}),u.jsx("span",{style:{color:"#6c7086",fontSize:11},children:S.createdAt?new Date(S.createdAt).toLocaleDateString():"-"}),u.jsx("span",{children:g?.id!==S.id&&u.jsx("button",{onClick:()=>h(S.id),style:{background:"#f38ba822",border:"1px solid #f38ba8",borderRadius:4,color:"#f38ba8",fontSize:10,padding:"2px 8px",cursor:"pointer"},children:"Delete"})})]}),p===S.id&&u.jsxs("div",{style:{padding:"8px 16px",background:"#f38ba811",borderBottom:"1px solid #45475a",display:"flex",alignItems:"center",gap:8,fontSize:12,color:"#f38ba8"},children:[u.jsxs("span",{children:["Delete ",S.email,"?"]}),u.jsx("button",{onClick:()=>b(S.id),style:{background:"#f38ba8",border:"none",borderRadius:4,color:"#1e1e2e",fontSize:11,fontWeight:600,padding:"3px 10px",cursor:"pointer"},children:"Confirm"}),u.jsx("button",{onClick:()=>h(null),style:{background:"#313244",border:"1px solid #45475a",borderRadius:4,color:"#cdd6f4",fontSize:11,padding:"3px 10px",cursor:"pointer"},children:"Cancel"})]})]},S.id)),e.length===0&&u.jsx("div",{style:{padding:20,color:"#6c7086",fontSize:13,textAlign:"center"},children:"No users found."})]}),c&&u.jsx(_$,{onClose:()=>d(!1),onCreated:y})]})}const C$={vault:{enabled:!1,address:"",token:"",mountPath:"secret",namespace:""},aws:{enabled:!1,region:"us-east-1",accessKeyId:"",secretAccessKey:""}};function E$(){const[e,n]=N.useState(C$),[r,a]=N.useState(!1),o=(c,d,p)=>{a(!1),n(h=>({...h,[c]:{...h[c],[d]:p}}))},l=()=>{localStorage.setItem("secrets_config",JSON.stringify(e)),a(!0),setTimeout(()=>a(!1),2e3)};return u.jsxs("div",{children:[u.jsx("div",{style:{display:"flex",alignItems:"center",gap:12,marginBottom:16},children:u.jsx("h3",{style:{color:"#cdd6f4",margin:0,fontSize:16,fontWeight:600},children:"Secrets Providers"})}),u.jsxs("p",{style:{color:"#6c7086",fontSize:13,marginBottom:20},children:["Configure external secrets providers. Secret references in module configs (e.g. ",u.jsxs("code",{style:{color:"#89b4fa"},children:["$","${vault:secret/path#field}"]})," or"," ",u.jsxs("code",{style:{color:"#89b4fa"},children:["$","${aws-sm:my-secret}"]}),") will be resolved at startup."]}),u.jsxs("div",{style:{background:"#313244",borderRadius:8,padding:16,marginBottom:16},children:[u.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:12},children:[u.jsx("input",{type:"checkbox",checked:e.vault.enabled,onChange:c=>o("vault","enabled",c.target.checked)}),u.jsx("span",{style:{color:"#cdd6f4",fontSize:14,fontWeight:600},children:"HashiCorp Vault"})]}),e.vault.enabled&&u.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:10},children:[u.jsxs("label",{children:[u.jsx("span",{style:{color:"#a6adc8",fontSize:12,display:"block",marginBottom:4},children:"Vault Address"}),u.jsx("input",{type:"text",value:e.vault.address??"",onChange:c=>o("vault","address",c.target.value),placeholder:"https://vault.example.com:8200",style:Di})]}),u.jsxs("label",{children:[u.jsx("span",{style:{color:"#a6adc8",fontSize:12,display:"block",marginBottom:4},children:"Token"}),u.jsx("input",{type:"password",value:e.vault.token??"",onChange:c=>o("vault","token",c.target.value),placeholder:"hvs.xxxxx",style:Di})]}),u.jsxs("label",{children:[u.jsx("span",{style:{color:"#a6adc8",fontSize:12,display:"block",marginBottom:4},children:"Mount Path"}),u.jsx("input",{type:"text",value:e.vault.mountPath??"secret",onChange:c=>o("vault","mountPath",c.target.value),placeholder:"secret",style:Di})]}),u.jsxs("label",{children:[u.jsx("span",{style:{color:"#a6adc8",fontSize:12,display:"block",marginBottom:4},children:"Namespace (optional)"}),u.jsx("input",{type:"text",value:e.vault.namespace??"",onChange:c=>o("vault","namespace",c.target.value),placeholder:"admin",style:Di})]})]})]}),u.jsxs("div",{style:{background:"#313244",borderRadius:8,padding:16,marginBottom:16},children:[u.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:12},children:[u.jsx("input",{type:"checkbox",checked:e.aws.enabled,onChange:c=>o("aws","enabled",c.target.checked)}),u.jsx("span",{style:{color:"#cdd6f4",fontSize:14,fontWeight:600},children:"AWS Secrets Manager"})]}),e.aws.enabled&&u.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:10},children:[u.jsxs("label",{children:[u.jsx("span",{style:{color:"#a6adc8",fontSize:12,display:"block",marginBottom:4},children:"AWS Region"}),u.jsx("input",{type:"text",value:e.aws.region??"us-east-1",onChange:c=>o("aws","region",c.target.value),placeholder:"us-east-1",style:Di})]}),u.jsxs("label",{children:[u.jsx("span",{style:{color:"#a6adc8",fontSize:12,display:"block",marginBottom:4},children:"Access Key ID (optional, uses default chain if empty)"}),u.jsx("input",{type:"password",value:e.aws.accessKeyId??"",onChange:c=>o("aws","accessKeyId",c.target.value),placeholder:"AKIA...",style:Di})]}),u.jsxs("label",{children:[u.jsx("span",{style:{color:"#a6adc8",fontSize:12,display:"block",marginBottom:4},children:"Secret Access Key (optional)"}),u.jsx("input",{type:"password",value:e.aws.secretAccessKey??"",onChange:c=>o("aws","secretAccessKey",c.target.value),placeholder:"secret key",style:Di})]})]})]}),u.jsx("button",{onClick:l,style:{background:r?"#a6e3a1":"#89b4fa",border:"none",borderRadius:6,color:"#1e1e2e",padding:"8px 20px",fontSize:13,fontWeight:600,cursor:"pointer"},children:r?"Saved":"Save Configuration"})]})}const Di={width:"100%",background:"#1e1e2e",border:"1px solid #45475a",borderRadius:6,color:"#cdd6f4",padding:"8px 12px",fontSize:13,outline:"none",boxSizing:"border-box"},j$={aws_iam:"#fab387",kubernetes:"#89b4fa",oidc:"#cba6f7",saml:"#a6e3a1",ldap:"#f9e2af",custom:"#6c7086"},xA=[{value:"aws_iam",label:"AWS IAM"},{value:"kubernetes",label:"Kubernetes"},{value:"oidc",label:"OIDC"},{value:"saml",label:"SAML"},{value:"ldap",label:"LDAP"},{value:"custom",label:"Custom"}];function T$({type:e}){const n=j$[e]||"#6c7086",r=xA.find(a=>a.value===e)?.label??e;return u.jsx("span",{style:{display:"inline-block",padding:"2px 8px",borderRadius:4,fontSize:10,fontWeight:600,background:n+"22",color:n},children:r})}const A$={aws_iam:[{key:"region",label:"Region"},{key:"account_id",label:"Account ID"},{key:"role_arn_pattern",label:"Role ARN Pattern"},{key:"external_id",label:"External ID"}],kubernetes:[{key:"api_server_url",label:"API Server URL"},{key:"namespace",label:"Namespace"},{key:"ca_cert",label:"CA Certificate",type:"textarea"}],oidc:[{key:"issuer_url",label:"Issuer URL"},{key:"client_id",label:"Client ID"},{key:"claims_mapping",label:"Claims Mapping (JSON)",type:"textarea"}],saml:[{key:"metadata_url",label:"Metadata URL"},{key:"entity_id",label:"Entity ID"}],ldap:[{key:"server_url",label:"Server URL"},{key:"base_dn",label:"Base DN"},{key:"bind_dn",label:"Bind DN"},{key:"search_filter",label:"Search Filter"}],custom:[{key:"config_json",label:"Configuration (JSON)",type:"textarea"}]};function R$({onClose:e,onSave:n}){const[r,a]=N.useState({provider_type:"aws_iam",name:"",config:{},enabled:!0}),o=A$[r.provider_type]||[],l=c=>{c.preventDefault(),n(r)};return u.jsx("div",{style:{position:"fixed",inset:0,background:"rgba(0,0,0,0.6)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},onClick:e,children:u.jsxs("div",{onClick:c=>c.stopPropagation(),style:{background:"#1e1e2e",border:"1px solid #45475a",borderRadius:12,padding:24,width:480,maxHeight:"80vh",overflow:"auto"},children:[u.jsx("h3",{style:{color:"#cdd6f4",margin:"0 0 16px",fontSize:16},children:"Add IAM Provider"}),u.jsxs("form",{onSubmit:l,children:[u.jsxs("div",{style:{marginBottom:12},children:[u.jsx("label",{style:{color:"#a6adc8",fontSize:12,display:"block",marginBottom:4},children:"Provider Type"}),u.jsx("select",{value:r.provider_type,onChange:c=>a({...r,provider_type:c.target.value,config:{}}),style:{width:"100%",background:"#313244",border:"1px solid #45475a",borderRadius:6,color:"#cdd6f4",padding:"8px 12px",fontSize:13,outline:"none"},children:xA.map(c=>u.jsx("option",{value:c.value,children:c.label},c.value))})]}),u.jsxs("div",{style:{marginBottom:12},children:[u.jsx("label",{style:{color:"#a6adc8",fontSize:12,display:"block",marginBottom:4},children:"Name"}),u.jsx("input",{type:"text",value:r.name,onChange:c=>a({...r,name:c.target.value}),required:!0,style:{width:"100%",background:"#313244",border:"1px solid #45475a",borderRadius:6,color:"#cdd6f4",padding:"8px 12px",fontSize:13,outline:"none",boxSizing:"border-box"}})]}),o.map(c=>u.jsxs("div",{style:{marginBottom:12},children:[u.jsx("label",{style:{color:"#a6adc8",fontSize:12,display:"block",marginBottom:4},children:c.label}),c.type==="textarea"?u.jsx("textarea",{value:r.config[c.key]||"",onChange:d=>a({...r,config:{...r.config,[c.key]:d.target.value}}),rows:4,style:{width:"100%",background:"#313244",border:"1px solid #45475a",borderRadius:6,color:"#cdd6f4",padding:"8px 12px",fontSize:12,fontFamily:"monospace",outline:"none",resize:"vertical",boxSizing:"border-box"}}):u.jsx("input",{type:"text",value:r.config[c.key]||"",onChange:d=>a({...r,config:{...r.config,[c.key]:d.target.value}}),style:{width:"100%",background:"#313244",border:"1px solid #45475a",borderRadius:6,color:"#cdd6f4",padding:"8px 12px",fontSize:13,outline:"none",boxSizing:"border-box"}})]},c.key)),u.jsxs("div",{style:{display:"flex",gap:8,marginTop:20},children:[u.jsx("button",{type:"submit",style:{background:"#89b4fa",border:"none",borderRadius:6,color:"#1e1e2e",padding:"8px 20px",fontSize:13,fontWeight:600,cursor:"pointer"},children:"Create"}),u.jsx("button",{type:"button",onClick:e,style:{background:"#313244",border:"1px solid #45475a",borderRadius:6,color:"#cdd6f4",padding:"8px 20px",fontSize:13,cursor:"pointer"},children:"Cancel"})]})]})]})})}function z$({mappings:e,onDelete:n,onAdd:r}){const[a,o]=N.useState(!1),[l,c]=N.useState({external_identifier:"",resource_type:"company",resource_id:"",role:"viewer"}),d=p=>{p.preventDefault(),r(l),c({external_identifier:"",resource_type:"company",resource_id:"",role:"viewer"}),o(!1)};return u.jsxs("div",{style:{marginTop:8},children:[u.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:8},children:[u.jsx("span",{style:{color:"#a6adc8",fontSize:12,fontWeight:600},children:"Role Mappings"}),u.jsx("button",{onClick:()=>o(!a),style:{background:"#313244",border:"1px solid #45475a",borderRadius:4,color:"#89b4fa",fontSize:11,padding:"2px 8px",cursor:"pointer"},children:"+ Add"})]}),a&&u.jsxs("form",{onSubmit:d,style:{display:"flex",gap:6,marginBottom:8,flexWrap:"wrap",alignItems:"flex-end"},children:[u.jsx("input",{type:"text",placeholder:"External ID",value:l.external_identifier,onChange:p=>c({...l,external_identifier:p.target.value}),required:!0,style:{background:"#313244",border:"1px solid #45475a",borderRadius:4,color:"#cdd6f4",padding:"4px 8px",fontSize:11,outline:"none",width:140}}),u.jsxs("select",{value:l.resource_type,onChange:p=>c({...l,resource_type:p.target.value}),style:{background:"#313244",border:"1px solid #45475a",borderRadius:4,color:"#cdd6f4",padding:"4px 8px",fontSize:11,outline:"none"},children:[u.jsx("option",{value:"company",children:"Company"}),u.jsx("option",{value:"project",children:"Project"}),u.jsx("option",{value:"workflow",children:"Workflow"})]}),u.jsx("input",{type:"text",placeholder:"Resource ID",value:l.resource_id,onChange:p=>c({...l,resource_id:p.target.value}),required:!0,style:{background:"#313244",border:"1px solid #45475a",borderRadius:4,color:"#cdd6f4",padding:"4px 8px",fontSize:11,outline:"none",width:140,fontFamily:"monospace"}}),u.jsxs("select",{value:l.role,onChange:p=>c({...l,role:p.target.value}),style:{background:"#313244",border:"1px solid #45475a",borderRadius:4,color:"#cdd6f4",padding:"4px 8px",fontSize:11,outline:"none"},children:[u.jsx("option",{value:"viewer",children:"Viewer"}),u.jsx("option",{value:"editor",children:"Editor"}),u.jsx("option",{value:"admin",children:"Admin"}),u.jsx("option",{value:"owner",children:"Owner"})]}),u.jsx("button",{type:"submit",style:{background:"#89b4fa",border:"none",borderRadius:4,color:"#1e1e2e",padding:"4px 12px",fontSize:11,fontWeight:600,cursor:"pointer"},children:"Add"})]}),e.length>0&&u.jsxs("div",{style:{background:"#181825",borderRadius:6,overflow:"hidden"},children:[u.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 80px 1fr 70px 40px",padding:"6px 10px",fontSize:10,color:"#6c7086",fontWeight:600},children:[u.jsx("span",{children:"External ID"}),u.jsx("span",{children:"Type"}),u.jsx("span",{children:"Resource"}),u.jsx("span",{children:"Role"}),u.jsx("span",{})]}),e.map(p=>u.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 80px 1fr 70px 40px",padding:"5px 10px",fontSize:11,borderTop:"1px solid #31324444",alignItems:"center"},children:[u.jsx("span",{style:{color:"#cdd6f4",fontFamily:"monospace",fontSize:10},children:p.external_identifier}),u.jsx("span",{style:{color:"#a6adc8"},children:p.resource_type}),u.jsxs("span",{style:{color:"#89b4fa",fontFamily:"monospace",fontSize:10},children:[p.resource_id.slice(0,8),"..."]}),u.jsx("span",{style:{color:"#a6adc8"},children:p.role}),u.jsx("button",{onClick:()=>n(p.id),style:{background:"none",border:"none",color:"#f38ba8",cursor:"pointer",fontSize:11,padding:0},children:"X"})]},p.id))]}),e.length===0&&!a&&u.jsx("div",{style:{color:"#6c7086",fontSize:11,padding:"4px 0"},children:"No mappings configured."})]})}function N$(){const{iamProviders:e,iamMappings:n,fetchIAMProviders:r,createIAMProvider:a,deleteIAMProvider:o,testIAMProvider:l,fetchIAMRoleMappings:c,createIAMRoleMapping:d,deleteIAMRoleMapping:p}=jt(),[h,g]=N.useState([]),[y,m]=N.useState(""),[b,S]=N.useState(!1),[w,C]=N.useState({}),[_,j]=N.useState(null);N.useEffect(()=>{X0().then(O=>{g(O),O.length>0&&!y&&m(O[0].id)}).catch(()=>{})},[]),N.useEffect(()=>{y&&r(y)},[y,r]);const k=N.useCallback(O=>{if(_===O){j(null);return}j(O),c(O)},[_,c]),T=N.useCallback(async O=>{try{await a(y,{provider_type:O.provider_type,name:O.name,config:O.config,enabled:O.enabled}),S(!1)}catch{}},[y,a]),E=N.useCallback(async O=>{try{const P=await l(O);C(L=>({...L,[O]:P}))}catch(P){C(L=>({...L,[O]:{success:!1,message:String(P)}}))}},[l]),z=N.useCallback(async O=>{try{await o(O),y&&r(y)}catch{}},[o,r,y]),A=N.useCallback(async(O,P)=>{try{await d(O,{external_identifier:P.external_identifier,resource_type:P.resource_type,resource_id:P.resource_id,role:P.role})}catch{}},[d]),M=N.useCallback(async(O,P)=>{try{await p(O,P)}catch{}},[p]);return u.jsxs("div",{style:{flex:1,background:"#1e1e2e",overflow:"auto",padding:24},children:[u.jsx("div",{style:{marginBottom:32},children:u.jsx(k$,{})}),u.jsx("div",{style:{height:1,background:"#45475a",marginBottom:24}}),u.jsx("div",{style:{marginBottom:32},children:u.jsx(E$,{})}),u.jsx("div",{style:{height:1,background:"#45475a",marginBottom:24}}),u.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,marginBottom:20},children:[u.jsx("h2",{style:{color:"#cdd6f4",margin:0,fontSize:18,fontWeight:600},children:"IAM Settings"}),h.length>1&&u.jsx("select",{value:y,onChange:O=>m(O.target.value),style:{background:"#313244",border:"1px solid #45475a",borderRadius:6,color:"#cdd6f4",padding:"6px 10px",fontSize:12,outline:"none"},children:h.map(O=>u.jsx("option",{value:O.id,children:O.name},O.id))}),u.jsx("span",{style:{flex:1}}),u.jsx("button",{onClick:()=>S(!0),style:{background:"#89b4fa",border:"none",borderRadius:6,color:"#1e1e2e",padding:"8px 16px",fontSize:13,fontWeight:600,cursor:"pointer"},children:"Add Provider"})]}),u.jsxs("div",{style:{background:"#313244",borderRadius:8,overflow:"hidden"},children:[u.jsxs("div",{style:{display:"grid",gridTemplateColumns:"2fr 100px 80px 120px",padding:"10px 16px",background:"#181825",fontSize:11,color:"#a6adc8",fontWeight:600},children:[u.jsx("span",{children:"Name"}),u.jsx("span",{children:"Type"}),u.jsx("span",{children:"Status"}),u.jsx("span",{children:"Actions"})]}),e.map((O,P)=>{const L=w[O.id],I=_===O.id;return u.jsxs("div",{children:[u.jsxs("div",{style:{display:"grid",gridTemplateColumns:"2fr 100px 80px 120px",padding:"10px 16px",borderBottom:"1px solid #45475a",fontSize:13,background:P%2===0?"transparent":"#181825",alignItems:"center",cursor:"pointer"},onClick:()=>k(O.id),children:[u.jsx("span",{style:{color:"#cdd6f4"},children:O.name}),u.jsx("span",{children:u.jsx(T$,{type:O.provider_type})}),u.jsxs("span",{children:[u.jsx("span",{style:{display:"inline-block",width:8,height:8,borderRadius:"50%",background:O.enabled?"#a6e3a1":"#6c7086",marginRight:6}}),u.jsx("span",{style:{color:"#a6adc8",fontSize:11},children:O.enabled?"On":"Off"})]}),u.jsxs("span",{style:{display:"flex",gap:6},children:[u.jsx("button",{onClick:F=>{F.stopPropagation(),E(O.id)},style:{background:"#313244",border:"1px solid #45475a",borderRadius:4,color:"#89b4fa",fontSize:10,padding:"2px 8px",cursor:"pointer"},children:"Test"}),u.jsx("button",{onClick:F=>{F.stopPropagation(),z(O.id)},style:{background:"#f38ba822",border:"1px solid #f38ba8",borderRadius:4,color:"#f38ba8",fontSize:10,padding:"2px 8px",cursor:"pointer"},children:"Delete"})]})]}),L&&u.jsx("div",{style:{padding:"6px 16px",background:L.success?"#a6e3a111":"#f38ba811",borderBottom:"1px solid #45475a",fontSize:11,color:L.success?"#a6e3a1":"#f38ba8"},children:L.success?"Connection successful":`Failed: ${L.message}`}),I&&u.jsx("div",{style:{padding:"8px 16px 12px",borderBottom:"1px solid #45475a",background:"#181825"},children:u.jsx(z$,{providerId:O.id,mappings:n[O.id]??[],onDelete:F=>M(F,O.id),onAdd:F=>A(O.id,F)})})]},O.id)}),e.length===0&&u.jsx("div",{style:{padding:20,color:"#6c7086",fontSize:13,textAlign:"center"},children:"No IAM providers configured."})]}),b&&u.jsx(R$,{onClose:()=>S(!1),onSave:T})]})}const M$=Mn(e=>({searchQuery:"",error:null,setSearchQuery:n=>e({searchQuery:n}),clearError:()=>e({error:null})}));function O$(e,n){return n.filter(r=>r.dependencies?.some(a=>a.name===e)).map(r=>r.name)}function SA(e){return(e.dependencies??[]).map(n=>n.name)}function Z0({name:e,enabled:n}){return u.jsx("span",{style:{display:"inline-block",padding:"1px 6px",borderRadius:3,fontSize:10,background:n?"#a6e3a122":"#45475a",color:n?"#a6e3a1":"#a6adc8",border:`1px solid ${n?"#a6e3a144":"#585b70"}`},children:e})}function wA({enabled:e}){return u.jsx("span",{style:{display:"inline-block",padding:"2px 8px",borderRadius:4,fontSize:10,fontWeight:600,background:e?"#a6e3a122":"#45475a",color:e?"#a6e3a1":"#a6adc8"},children:e?"Enabled":"Disabled"})}function D$({plugin:e,allPlugins:n,onToggle:r,actionLoading:a,onClick:o}){const l=SA(e);return u.jsxs("div",{onClick:()=>o(e),style:{background:"#313244",border:"1px solid #45475a",borderRadius:8,padding:16,cursor:"pointer",transition:"border-color 0.15s",display:"flex",flexDirection:"column",gap:8},onMouseEnter:c=>c.currentTarget.style.borderColor="#89b4fa",onMouseLeave:c=>c.currentTarget.style.borderColor="#45475a",children:[u.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start"},children:[u.jsxs("div",{children:[u.jsx("div",{style:{color:"#cdd6f4",fontWeight:600,fontSize:14},children:e.name}),u.jsxs("div",{style:{fontSize:11,color:"#6c7086",marginTop:2},children:["v",e.version]})]}),u.jsx(wA,{enabled:e.enabled})]}),u.jsx("div",{style:{fontSize:12,color:"#a6adc8",lineHeight:1.4,flex:1},children:e.description&&e.description.length>120?e.description.slice(0,120)+"...":e.description}),l.length>0&&u.jsxs("div",{style:{display:"flex",gap:4,flexWrap:"wrap",alignItems:"center"},children:[u.jsx("span",{style:{fontSize:10,color:"#6c7086"},children:"deps:"}),l.map(c=>{const d=n.find(p=>p.name===c);return u.jsx(Z0,{name:c,enabled:d?.enabled??!1},c)})]}),u.jsx("div",{style:{display:"flex",justifyContent:"flex-end",alignItems:"center",marginTop:4},children:u.jsx("button",{disabled:a,onClick:c=>{c.stopPropagation(),r(e)},style:{padding:"4px 14px",borderRadius:4,border:"none",fontSize:12,fontWeight:600,cursor:a?"wait":"pointer",opacity:a?.6:1,background:e.enabled?"#f38ba822":"#89b4fa",color:e.enabled?"#f38ba8":"#1e1e2e"},children:a?"...":e.enabled?"Disable":"Enable"})})]})}function q$({plugin:e,allPlugins:n,onClose:r,onToggle:a,actionLoading:o}){const l=SA(e),d=O$(e.name,n).filter(p=>n.find(g=>g.name===p)?.enabled);return u.jsx("div",{onClick:r,style:{position:"fixed",inset:0,background:"rgba(0,0,0,0.6)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},children:u.jsxs("div",{onClick:p=>p.stopPropagation(),style:{background:"#1e1e2e",border:"1px solid #45475a",borderRadius:12,width:"90%",maxWidth:700,maxHeight:"85vh",overflow:"auto",padding:24},children:[u.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",marginBottom:16},children:[u.jsxs("div",{children:[u.jsx("h2",{style:{color:"#cdd6f4",margin:0,fontSize:20,fontWeight:600},children:e.name}),u.jsxs("div",{style:{fontSize:12,color:"#6c7086",marginTop:4},children:["v",e.version]})]}),u.jsx("button",{onClick:r,style:{background:"none",border:"none",color:"#6c7086",fontSize:20,cursor:"pointer",padding:4},children:"x"})]}),u.jsx("div",{style:{display:"flex",gap:8,alignItems:"center",marginBottom:16},children:u.jsx(wA,{enabled:e.enabled})}),u.jsx("h3",{style:{color:"#cdd6f4",fontSize:14,fontWeight:600,marginBottom:8},children:"Description"}),u.jsx("p",{style:{color:"#a6adc8",fontSize:13,lineHeight:1.6,marginBottom:20},children:e.description}),l.length>0&&u.jsxs("div",{style:{marginBottom:16},children:[u.jsx("h3",{style:{color:"#cdd6f4",fontSize:14,fontWeight:600,marginBottom:8},children:"Dependencies"}),u.jsx("div",{style:{display:"flex",gap:6,flexWrap:"wrap"},children:l.map(p=>{const h=n.find(g=>g.name===p);return u.jsx(Z0,{name:p,enabled:h?.enabled??!1},p)})}),!e.enabled&&l.some(p=>!n.find(h=>h.name===p)?.enabled)&&u.jsx("div",{style:{fontSize:11,color:"#f9e2af",marginTop:6},children:"Enabling this plugin will also enable its disabled dependencies."})]}),e.enabled&&d.length>0&&u.jsxs("div",{style:{marginBottom:16},children:[u.jsx("h3",{style:{color:"#cdd6f4",fontSize:14,fontWeight:600,marginBottom:8},children:"Enabled Dependents"}),u.jsx("div",{style:{display:"flex",gap:6,flexWrap:"wrap"},children:d.map(p=>u.jsx(Z0,{name:p,enabled:!0},p))}),u.jsx("div",{style:{fontSize:11,color:"#f38ba8",marginTop:6},children:"Disabling this plugin may also disable the plugins listed above."})]}),(e.uiPages?.length??0)>0&&u.jsxs("div",{style:{marginBottom:20},children:[u.jsx("h3",{style:{color:"#cdd6f4",fontSize:14,fontWeight:600,marginBottom:8},children:"UI Pages"}),u.jsx("div",{style:{display:"flex",gap:6,flexWrap:"wrap"},children:e.uiPages.map(p=>u.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:4,padding:"2px 8px",borderRadius:4,fontSize:11,background:"#45475a",color:"#cdd6f4"},children:[u.jsx("span",{children:p.icon})," ",p.label]},p.id))})]}),u.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:u.jsx("button",{disabled:o,onClick:()=>a(e),style:{padding:"8px 24px",borderRadius:6,border:"none",fontSize:13,fontWeight:600,cursor:o?"wait":"pointer",opacity:o?.6:1,background:e.enabled?"#f38ba822":"#89b4fa",color:e.enabled?"#f38ba8":"#1e1e2e"},children:o?"...":e.enabled?"Disable":"Enable"})})]})})}function I$(){const{plugins:e,enabling:n,error:r,enablePlugin:a,disablePlugin:o,clearError:l}=Vi(),{searchQuery:c,setSearchQuery:d}=M$(),[p,h]=N.useState(null),[g,y]=N.useState("enabled"),m=r,b=l,S=N.useCallback(k=>{k.enabled?o(k.name):a(k.name)},[a,o]),{enabledPlugins:w,disabledPlugins:C}=N.useMemo(()=>{const k=e.filter(E=>E.enabled),T=e.filter(E=>!E.enabled);return{enabledPlugins:k,disabledPlugins:T}},[e]),_=N.useMemo(()=>{const k=g==="enabled"?w:C;if(!c)return k;const T=c.toLowerCase();return k.filter(E=>E.name.toLowerCase().includes(T)||E.description?.toLowerCase().includes(T))},[g,w,C,c]),j=N.useMemo(()=>p?e.find(k=>k.name===p.name)??p:null,[p,e]);return u.jsxs("div",{style:{flex:1,background:"#1e1e2e",overflow:"auto",padding:24},children:[u.jsx("h2",{style:{color:"#cdd6f4",margin:"0 0 4px",fontSize:20,fontWeight:600},children:"Plugin Marketplace"}),u.jsx("p",{style:{color:"#6c7086",fontSize:13,margin:"0 0 20px"},children:"Enable and disable plugins to customize your workflow engine."}),m&&u.jsxs("div",{style:{background:"#f38ba822",border:"1px solid #f38ba8",borderRadius:6,padding:"8px 12px",marginBottom:16,display:"flex",justifyContent:"space-between",alignItems:"center"},children:[u.jsx("span",{style:{color:"#f38ba8",fontSize:13},children:m}),u.jsx("button",{onClick:b,style:{background:"none",border:"none",color:"#f38ba8",cursor:"pointer",fontSize:14},children:"x"})]}),u.jsx("div",{style:{display:"flex",gap:0,marginBottom:20,borderBottom:"1px solid #45475a"},children:["enabled","available"].map(k=>u.jsx("button",{onClick:()=>y(k),style:{padding:"8px 20px",background:"none",border:"none",borderBottom:g===k?"2px solid #89b4fa":"2px solid transparent",color:g===k?"#89b4fa":"#6c7086",fontSize:13,fontWeight:600,cursor:"pointer"},children:k==="enabled"?`Enabled (${w.length})`:`Available (${C.length})`},k))}),u.jsx("div",{style:{display:"flex",gap:12,marginBottom:20},children:u.jsx("input",{type:"text",placeholder:g==="enabled"?"Filter enabled plugins...":"Search available plugins...",value:c,onChange:k=>d(k.target.value),style:{flex:1,minWidth:200,padding:"8px 12px",borderRadius:6,border:"1px solid #45475a",background:"#313244",color:"#cdd6f4",fontSize:13,outline:"none"}})}),u.jsxs("div",{style:{fontSize:12,color:"#6c7086",marginBottom:12},children:["Showing ",_.length," plugin",_.length!==1?"s":"",c&&u.jsxs(u.Fragment,{children:[' matching "',c,'"']})]}),u.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(300px, 1fr))",gap:12},children:[_.map(k=>u.jsx(D$,{plugin:k,allPlugins:e,onToggle:S,actionLoading:!!n[k.name],onClick:h},k.name)),_.length===0&&u.jsx("div",{style:{color:"#6c7086",fontSize:13,gridColumn:"1 / -1",padding:40,textAlign:"center"},children:g==="enabled"?"No plugins enabled yet.":"No available plugins to enable."})]}),j&&u.jsx(q$,{plugin:j,allPlugins:e,onClose:()=>h(null),onToggle:S,actionLoading:!!n[j.name]})]})}const L$={Simple:"#a6e3a1",Intermediate:"#f9e2af",Advanced:"#f38ba8"},B$=["HTTP","Pipeline","Event-Driven","CRON","WebSocket","Database","AI","Integration","State Machine","Monitoring"],H$=[{id:"rest-api",name:"REST API Gateway",description:"A complete REST API with CRUD endpoints, input validation, authentication middleware, and database persistence. Includes health check and metrics endpoints.",complexity:"Intermediate",tags:["HTTP","Database"],yaml:`name: rest-api-gateway +version: "1.0" + +modules: + - name: http-server + type: httpserver + config: + port: 8080 + read_timeout: "30s" + + - name: auth + type: auth_middleware + config: + provider: jwt + secret: "{{secrets.jwt_secret}}" + + - name: main-db + type: database + config: + driver: postgres + dsn: "{{secrets.db_dsn}}" + + - name: validator + type: json_schema + config: + strict: true + +workflows: + - name: list-items + trigger: + type: http + method: GET + path: /api/items + steps: + - module: auth + - module: main-db + action: query + sql: "SELECT * FROM items ORDER BY created_at DESC" + + - name: create-item + trigger: + type: http + method: POST + path: /api/items + steps: + - module: auth + - module: validator + schema: item-create + - module: main-db + action: exec + sql: "INSERT INTO items (name, value) VALUES ($1, $2)"`},{id:"event-pipeline",name:"Event Processing Pipeline",description:"An event-driven pipeline that consumes messages from an event bus, transforms data through multiple stages, and publishes results. Includes dead letter queue handling.",complexity:"Advanced",tags:["Event-Driven","Pipeline"],yaml:`name: event-pipeline +version: "1.0" + +modules: + - name: event-bus + type: eventbus + config: + provider: memory + buffer_size: 1000 + + - name: transformer + type: json_transform + config: + mappings: + - source: "$.raw_data" + target: "$.processed" + + - name: enricher + type: http_client + config: + base_url: "https://api.enrichment.io" + timeout: "5s" + + - name: output-db + type: database + config: + driver: postgres + dsn: "{{secrets.output_db_dsn}}" + + - name: dlq + type: eventbus + config: + provider: memory + topic_prefix: "dlq." + +workflows: + - name: process-events + trigger: + type: messaging + topic: incoming-events + steps: + - module: transformer + - module: enricher + action: POST + path: /enrich + on_error: continue + - module: output-db + action: exec + error_handler: + module: dlq + topic: failed-events`},{id:"cron-job",name:"Scheduled CRON Job",description:"A scheduled workflow that runs at configurable intervals. Fetches data from an API, processes it, and sends summary reports via email or Slack.",complexity:"Simple",tags:["CRON","HTTP"],yaml:`name: scheduled-report +version: "1.0" + +modules: + - name: data-source + type: http_client + config: + base_url: "https://api.internal.io" + timeout: "30s" + headers: + Authorization: "Bearer {{secrets.api_token}}" + + - name: formatter + type: json_transform + config: + template: report + + - name: notifier + type: http_client + config: + base_url: "https://hooks.slack.com" + + - name: scheduler + type: scheduler + config: + timezone: "America/New_York" + +workflows: + - name: daily-report + trigger: + type: cron + schedule: "0 9 * * 1-5" + steps: + - module: data-source + action: GET + path: /metrics/daily + - module: formatter + - module: notifier + action: POST + path: "/services/{{secrets.slack_webhook_id}}"`},{id:"chat-app",name:"Chat Application",description:"A real-time chat application using WebSocket connections, with message persistence, user presence tracking, and AI-powered auto-moderation.",complexity:"Advanced",tags:["WebSocket","Event-Driven","AI"],yaml:`name: chat-application +version: "1.0" + +modules: + - name: ws-server + type: httpserver + config: + port: 8080 + websocket: true + ws_path: /ws + + - name: auth + type: auth_middleware + config: + provider: jwt + + - name: message-db + type: database + config: + driver: postgres + dsn: "{{secrets.chat_db_dsn}}" + + - name: event-bus + type: eventbus + config: + provider: memory + + - name: ai-moderator + type: llm_provider + config: + provider: anthropic + model: "claude-haiku-4-20250414" + max_tokens: 256 + + - name: cache + type: cache + config: + provider: redis + address: "{{secrets.redis_url}}" + +workflows: + - name: send-message + trigger: + type: websocket + event: message + steps: + - module: auth + - module: ai-moderator + action: moderate + prompt: "Is this message appropriate? Respond YES or NO." + - module: message-db + action: exec + sql: "INSERT INTO messages (user_id, room_id, content) VALUES ($1, $2, $3)" + - module: event-bus + action: publish + topic: "chat.{{room_id}}" + + - name: join-room + trigger: + type: websocket + event: join + steps: + - module: auth + - module: cache + action: set + key: "presence:{{user_id}}" + ttl: "5m"`},{id:"ecommerce-order",name:"E-commerce Order Flow",description:"Complete order processing pipeline with inventory check, payment processing, order confirmation, shipping label generation, and email notifications.",complexity:"Advanced",tags:["HTTP","Pipeline","Event-Driven"],yaml:`name: ecommerce-order-flow +version: "1.0" + +modules: + - name: http-server + type: httpserver + config: + port: 8080 + + - name: order-db + type: database + config: + driver: postgres + dsn: "{{secrets.order_db_dsn}}" + + - name: inventory-svc + type: http_client + config: + base_url: "https://inventory.internal" + + - name: payment-svc + type: http_client + config: + base_url: "https://payments.internal" + + - name: shipping-svc + type: http_client + config: + base_url: "https://shipping.internal" + + - name: email-svc + type: http_client + config: + base_url: "https://email.internal" + + - name: event-bus + type: eventbus + config: + provider: memory + +workflows: + - name: place-order + trigger: + type: http + method: POST + path: /api/orders + steps: + - module: inventory-svc + action: POST + path: /check + - module: payment-svc + action: POST + path: /charge + - module: order-db + action: exec + sql: "INSERT INTO orders ..." + - module: event-bus + action: publish + topic: order.created + + - name: fulfill-order + trigger: + type: messaging + topic: order.created + steps: + - module: shipping-svc + action: POST + path: /labels + - module: order-db + action: exec + sql: "UPDATE orders SET status='shipped' WHERE id=$1" + - module: email-svc + action: POST + path: /send + template: order-shipped`},{id:"data-etl",name:"Data ETL Pipeline",description:"Extract-Transform-Load pipeline that reads from multiple data sources, applies transformations and aggregations, and loads into a data warehouse.",complexity:"Intermediate",tags:["Pipeline","Database"],yaml:`name: data-etl-pipeline +version: "1.0" + +modules: + - name: source-db + type: database + config: + driver: postgres + dsn: "{{secrets.source_db_dsn}}" + + - name: source-api + type: http_client + config: + base_url: "https://api.datasource.io" + timeout: "60s" + + - name: transformer + type: json_transform + config: + mappings: + - source: "$.records[*]" + target: "$.rows" + transform: "flatten" + + - name: warehouse-db + type: database + config: + driver: postgres + dsn: "{{secrets.warehouse_dsn}}" + + - name: scheduler + type: scheduler + +workflows: + - name: nightly-etl + trigger: + type: cron + schedule: "0 2 * * *" + steps: + - module: source-db + action: query + sql: "SELECT * FROM transactions WHERE date = CURRENT_DATE - 1" + - module: source-api + action: GET + path: /daily-metrics + - module: transformer + - module: warehouse-db + action: exec + sql: "INSERT INTO fact_daily ..."`},{id:"webhook-processor",name:"Webhook Processor",description:"Receives webhooks from external services (GitHub, Stripe, Twilio), validates signatures, routes by event type, and triggers appropriate workflow actions.",complexity:"Simple",tags:["HTTP","Event-Driven"],yaml:`name: webhook-processor +version: "1.0" + +modules: + - name: http-server + type: httpserver + config: + port: 8080 + + - name: event-bus + type: eventbus + config: + provider: memory + + - name: logger + type: event_logger + config: + store: database + + - name: db + type: database + config: + driver: postgres + dsn: "{{secrets.db_dsn}}" + +workflows: + - name: github-webhook + trigger: + type: http + method: POST + path: /webhooks/github + steps: + - module: logger + - module: event-bus + action: publish + topic: "github.{{event_type}}" + + - name: stripe-webhook + trigger: + type: http + method: POST + path: /webhooks/stripe + steps: + - module: logger + - module: event-bus + action: publish + topic: "stripe.{{event_type}}" + + - name: handle-payment + trigger: + type: messaging + topic: stripe.payment_intent.succeeded + steps: + - module: db + action: exec + sql: "UPDATE orders SET paid=true WHERE stripe_id=$1"`},{id:"multi-service",name:"Multi-Service Integration",description:"Orchestrates communication between multiple microservices with retry logic, circuit breakers, and distributed tracing. Includes health monitoring for all services.",complexity:"Advanced",tags:["HTTP","Integration","Pipeline"],yaml:`name: multi-service-integration +version: "1.0" + +modules: + - name: api-gateway + type: httpserver + config: + port: 8080 + + - name: user-svc + type: http_client + config: + base_url: "https://users.internal" + retry_count: 3 + circuit_breaker: + threshold: 5 + timeout: "30s" + + - name: billing-svc + type: http_client + config: + base_url: "https://billing.internal" + retry_count: 3 + + - name: notification-svc + type: http_client + config: + base_url: "https://notifications.internal" + + - name: analytics-svc + type: http_client + config: + base_url: "https://analytics.internal" + + - name: cache + type: cache + config: + provider: redis + address: "{{secrets.redis_url}}" + default_ttl: "5m" + + - name: metrics + type: prometheus_exporter + config: + port: 9090 + +workflows: + - name: user-signup + trigger: + type: http + method: POST + path: /api/signup + steps: + - module: user-svc + action: POST + path: /users + - module: billing-svc + action: POST + path: /accounts + - module: notification-svc + action: POST + path: /send + template: welcome-email + - module: analytics-svc + action: POST + path: /events + data: + event: user_signup + + - name: get-user-profile + trigger: + type: http + method: GET + path: /api/users/:id + steps: + - module: cache + action: get + key: "user:{{params.id}}" + on_miss: continue + - module: user-svc + action: GET + path: "/users/{{params.id}}" + - module: cache + action: set + key: "user:{{params.id}}"`},{id:"ai-assistant",name:"AI-Powered Assistant",description:"Conversational AI assistant with tool use, context management, and multi-turn dialogue. Integrates with knowledge base for RAG-powered responses.",complexity:"Intermediate",tags:["AI","HTTP","Database"],yaml:`name: ai-assistant +version: "1.0" + +modules: + - name: http-server + type: httpserver + config: + port: 8080 + + - name: llm + type: llm_provider + config: + provider: anthropic + model: "claude-sonnet-4-20250514" + max_tokens: 4096 + + - name: vector-db + type: vector_store + config: + backend: pgvector + dimensions: 1536 + + - name: conversation-db + type: database + config: + driver: postgres + dsn: "{{secrets.db_dsn}}" + +workflows: + - name: chat + trigger: + type: http + method: POST + path: /api/chat + steps: + - module: conversation-db + action: query + sql: "SELECT * FROM messages WHERE session=$1 ORDER BY created_at DESC LIMIT 10" + - module: vector-db + action: search + query: "{{input.message}}" + top_k: 5 + - module: llm + action: complete + system: "You are a helpful assistant. Use the provided context." + context: "{{steps.vector-db.results}}"`},{id:"state-machine-order",name:"State Machine Order Processor",description:"Order lifecycle management using a state machine engine. Tracks orders through created, validated, paid, shipped, and delivered states with configurable transitions and guards.",complexity:"Advanced",tags:["State Machine","Pipeline"],yaml:`name: state-machine-order-processor +version: "1.0" + +modules: + - name: http-server + type: httpserver + config: + port: 8080 + + - name: order-db + type: database + config: + driver: postgres + dsn: "{{secrets.order_db_dsn}}" + + - name: state-engine + type: statemachine.engine + config: + states: + - created + - validated + - paid + - shipped + - delivered + - cancelled + transitions: + - from: created + to: validated + action: validate + - from: validated + to: paid + action: charge + - from: paid + to: shipped + action: ship + - from: shipped + to: delivered + action: confirm_delivery + - from: [created, validated] + to: cancelled + action: cancel + + - name: event-bus + type: eventbus + config: + provider: memory + +workflows: + - name: transition-order + trigger: + type: http + method: POST + path: /api/orders/:id/transition + steps: + - module: state-engine + action: transition + entity: "{{params.id}}" + - module: order-db + action: exec + sql: "UPDATE orders SET state=$1 WHERE id=$2" + - module: event-bus + action: publish + topic: "order.{{new_state}}"`},{id:"cdc-data-sync",name:"CDC Data Sync",description:"Change data capture pipeline that listens for PostgreSQL changes, transforms records, and syncs them to an analytics database in near real-time.",complexity:"Intermediate",tags:["Database","Event-Driven"],yaml:`name: cdc-data-sync +version: "1.0" + +modules: + - name: source-db + type: database + config: + driver: postgres + dsn: "{{secrets.source_dsn}}" + cdc: + enabled: true + slot: analytics_slot + + - name: event-bus + type: eventbus + config: + provider: memory + buffer_size: 5000 + + - name: transformer + type: json_transform + config: + mappings: + - source: "$.old" + target: "$.diff.before" + - source: "$.new" + target: "$.diff.after" + + - name: analytics-db + type: database + config: + driver: postgres + dsn: "{{secrets.analytics_dsn}}" + +workflows: + - name: capture-changes + trigger: + type: messaging + topic: cdc.source-db + steps: + - module: transformer + - module: analytics-db + action: exec + sql: "INSERT INTO change_log (table_name, operation, payload) VALUES ($1, $2, $3)" + - module: event-bus + action: publish + topic: "sync.completed"`},{id:"rate-limiter-gateway",name:"API Rate Limiter Gateway",description:"HTTP gateway with built-in rate limiting per client IP, CORS middleware, and request logging. Proxies validated requests to upstream services.",complexity:"Simple",tags:["HTTP"],yaml:`name: api-rate-limiter-gateway +version: "1.0" + +modules: + - name: http-server + type: httpserver + config: + port: 8080 + cors: + allowed_origins: ["*"] + allowed_methods: ["GET", "POST", "PUT", "DELETE"] + allowed_headers: ["Authorization", "Content-Type"] + rate_limit: + requests_per_second: 100 + burst: 20 + + - name: upstream + type: http_client + config: + base_url: "https://api.backend.internal" + timeout: "10s" + + - name: logger + type: event_logger + config: + store: stdout + format: json + +workflows: + - name: proxy-request + trigger: + type: http + method: "*" + path: /api/* + steps: + - module: logger + - module: upstream + action: proxy + strip_prefix: /api`},{id:"monitoring-dashboard",name:"Real-Time Monitoring Dashboard",description:"Metrics collection service with health checks, Prometheus-compatible endpoints, and configurable alerting thresholds. Monitors upstream services and reports status.",complexity:"Intermediate",tags:["Monitoring","HTTP"],yaml:`name: realtime-monitoring-dashboard +version: "1.0" + +modules: + - name: http-server + type: httpserver + config: + port: 8080 + + - name: metrics + type: prometheus_exporter + config: + port: 9090 + path: /metrics + + - name: health-checker + type: http_client + config: + timeout: "5s" + + - name: alert-bus + type: eventbus + config: + provider: memory + + - name: scheduler + type: scheduler + config: + timezone: "UTC" + + - name: cache + type: cache + config: + provider: memory + default_ttl: "30s" + +workflows: + - name: collect-health + trigger: + type: cron + schedule: "*/30 * * * * *" + steps: + - module: health-checker + action: GET + path: /health + targets: + - "https://api.internal/health" + - "https://db-proxy.internal/health" + - "https://queue.internal/health" + - module: cache + action: set + key: "service-health" + - module: metrics + action: gauge + name: service_health_status + + - name: health-endpoint + trigger: + type: http + method: GET + path: /api/health + steps: + - module: cache + action: get + key: "service-health"`},{id:"saga-travel-booking",name:"Saga Travel Booking",description:"Distributed saga pattern for travel booking that coordinates flight, hotel, and car rental reservations. Includes compensation logic to roll back on partial failures.",complexity:"Advanced",tags:["Pipeline","Integration"],yaml:`name: saga-travel-booking +version: "1.0" + +modules: + - name: http-server + type: httpserver + config: + port: 8080 + + - name: flight-svc + type: http_client + config: + base_url: "https://flights.travel.internal" + timeout: "15s" + + - name: hotel-svc + type: http_client + config: + base_url: "https://hotels.travel.internal" + timeout: "15s" + + - name: car-svc + type: http_client + config: + base_url: "https://cars.travel.internal" + timeout: "15s" + + - name: booking-db + type: database + config: + driver: postgres + dsn: "{{secrets.booking_dsn}}" + + - name: event-bus + type: eventbus + config: + provider: memory + +workflows: + - name: book-trip + trigger: + type: http + method: POST + path: /api/bookings + steps: + - module: flight-svc + action: POST + path: /reserve + compensate: + action: POST + path: /cancel + - module: hotel-svc + action: POST + path: /reserve + compensate: + action: POST + path: /cancel + - module: car-svc + action: POST + path: /reserve + compensate: + action: POST + path: /cancel + - module: booking-db + action: exec + sql: "INSERT INTO bookings (user_id, flight, hotel, car, status) VALUES ($1,$2,$3,$4,'confirmed')" + - module: event-bus + action: publish + topic: booking.confirmed`},{id:"mq-consumer",name:"Message Queue Consumer",description:"Kafka message consumer with configurable consumer groups, automatic retries with exponential backoff, and dead letter queue routing for failed messages.",complexity:"Intermediate",tags:["Event-Driven","Pipeline"],yaml:`name: message-queue-consumer +version: "1.0" + +modules: + - name: kafka-consumer + type: eventbus + config: + provider: kafka + brokers: ["{{secrets.kafka_brokers}}"] + group_id: order-processors + topics: ["orders.pending"] + + - name: transformer + type: json_transform + config: + mappings: + - source: "$.payload" + target: "$.order" + + - name: order-db + type: database + config: + driver: postgres + dsn: "{{secrets.order_db_dsn}}" + + - name: dlq + type: eventbus + config: + provider: kafka + brokers: ["{{secrets.kafka_brokers}}"] + topic_prefix: "dlq." + +workflows: + - name: process-order + trigger: + type: messaging + topic: orders.pending + retry: + max_attempts: 3 + backoff: exponential + initial_delay: "1s" + steps: + - module: transformer + - module: order-db + action: exec + sql: "INSERT INTO processed_orders (id, data, status) VALUES ($1, $2, 'done')" + error_handler: + module: dlq + topic: orders.pending`},{id:"auth-service",name:"Authentication Service",description:"JWT-based authentication service with user registration, login, and token refresh endpoints. Passwords are hashed with bcrypt and tokens stored in a database.",complexity:"Intermediate",tags:["HTTP","Database"],yaml:`name: authentication-service +version: "1.0" + +modules: + - name: http-server + type: httpserver + config: + port: 8080 + + - name: auth + type: auth_middleware + config: + provider: jwt + secret: "{{secrets.jwt_secret}}" + expiry: "24h" + refresh_expiry: "7d" + + - name: user-db + type: database + config: + driver: postgres + dsn: "{{secrets.auth_db_dsn}}" + + - name: validator + type: json_schema + config: + strict: true + +workflows: + - name: register + trigger: + type: http + method: POST + path: /api/auth/register + steps: + - module: validator + schema: user-register + - module: user-db + action: exec + sql: "INSERT INTO users (email, password_hash, created_at) VALUES ($1, $2, NOW())" + - module: auth + action: issue_token + + - name: login + trigger: + type: http + method: POST + path: /api/auth/login + steps: + - module: user-db + action: query + sql: "SELECT id, password_hash FROM users WHERE email=$1" + - module: auth + action: verify_password + - module: auth + action: issue_token + + - name: refresh + trigger: + type: http + method: POST + path: /api/auth/refresh + steps: + - module: auth + action: refresh_token`},{id:"file-processing",name:"File Processing Pipeline",description:"Processes uploaded files through a multi-stage pipeline: receive via HTTP, validate format, apply transformations, and store results in a database with S3 archival.",complexity:"Intermediate",tags:["Pipeline","Database"],yaml:`name: file-processing-pipeline +version: "1.0" + +modules: + - name: http-server + type: httpserver + config: + port: 8080 + max_body_size: "50MB" + + - name: file-store + type: http_client + config: + base_url: "{{secrets.s3_endpoint}}" + headers: + Authorization: "Bearer {{secrets.s3_token}}" + + - name: transformer + type: json_transform + config: + mappings: + - source: "$.raw" + target: "$.normalized" + transform: "flatten" + + - name: results-db + type: database + config: + driver: postgres + dsn: "{{secrets.results_dsn}}" + + - name: event-bus + type: eventbus + config: + provider: memory + +workflows: + - name: upload-file + trigger: + type: http + method: POST + path: /api/files/upload + steps: + - module: file-store + action: PUT + path: "/raw/{{file.name}}" + - module: event-bus + action: publish + topic: file.uploaded + + - name: process-file + trigger: + type: messaging + topic: file.uploaded + steps: + - module: file-store + action: GET + path: "/raw/{{file.name}}" + - module: transformer + - module: results-db + action: exec + sql: "INSERT INTO processed_files (name, result, processed_at) VALUES ($1, $2, NOW())" + - module: file-store + action: PUT + path: "/processed/{{file.name}}"`},{id:"multi-tenant-saas",name:"Multi-Tenant SaaS Backend",description:"Multi-tenant backend with company, organization, and project hierarchy. Includes role-based access control, tenant-scoped data isolation, and admin management APIs.",complexity:"Advanced",tags:["HTTP","Database"],yaml:`name: multi-tenant-saas-backend +version: "1.0" + +modules: + - name: http-server + type: httpserver + config: + port: 8080 + + - name: auth + type: auth_middleware + config: + provider: jwt + secret: "{{secrets.jwt_secret}}" + tenant_header: "X-Tenant-ID" + + - name: tenant-db + type: database + config: + driver: postgres + dsn: "{{secrets.tenant_db_dsn}}" + multi_tenant: + enabled: true + isolation: schema + + - name: cache + type: cache + config: + provider: redis + address: "{{secrets.redis_url}}" + + - name: validator + type: json_schema + config: + strict: true + +workflows: + - name: list-projects + trigger: + type: http + method: GET + path: /api/orgs/:orgId/projects + steps: + - module: auth + required_role: member + - module: tenant-db + action: query + sql: "SELECT * FROM projects WHERE org_id=$1" + + - name: create-project + trigger: + type: http + method: POST + path: /api/orgs/:orgId/projects + steps: + - module: auth + required_role: admin + - module: validator + schema: project-create + - module: tenant-db + action: exec + sql: "INSERT INTO projects (org_id, name, created_by) VALUES ($1, $2, $3)" + + - name: manage-members + trigger: + type: http + method: POST + path: /api/orgs/:orgId/members + steps: + - module: auth + required_role: owner + - module: tenant-db + action: exec + sql: "INSERT INTO org_members (org_id, user_id, role) VALUES ($1, $2, $3)"`},{id:"iot-telemetry",name:"IoT Device Telemetry",description:"Ingests telemetry data from IoT devices, stores time-series readings, computes rolling aggregates, and triggers alerts when thresholds are exceeded.",complexity:"Intermediate",tags:["Event-Driven","Database","Monitoring"],yaml:`name: iot-device-telemetry +version: "1.0" + +modules: + - name: http-server + type: httpserver + config: + port: 8080 + + - name: event-bus + type: eventbus + config: + provider: memory + buffer_size: 10000 + + - name: timeseries-db + type: database + config: + driver: postgres + dsn: "{{secrets.timeseries_dsn}}" + + - name: alert-notifier + type: http_client + config: + base_url: "https://alerts.internal" + timeout: "5s" + + - name: metrics + type: prometheus_exporter + config: + port: 9090 + +workflows: + - name: ingest-reading + trigger: + type: http + method: POST + path: /api/devices/:deviceId/telemetry + steps: + - module: timeseries-db + action: exec + sql: "INSERT INTO readings (device_id, metric, value, ts) VALUES ($1, $2, $3, NOW())" + - module: metrics + action: gauge + name: device_reading + labels: ["device_id", "metric"] + - module: event-bus + action: publish + topic: "telemetry.{{params.deviceId}}" + + - name: check-thresholds + trigger: + type: messaging + topic: "telemetry.*" + steps: + - module: timeseries-db + action: query + sql: "SELECT AVG(value) as avg_val FROM readings WHERE device_id=$1 AND ts > NOW() - INTERVAL '5 min'" + - module: alert-notifier + action: POST + path: /evaluate + condition: "avg_val > threshold"`},{id:"content-management",name:"Content Management API",description:"Blog and CMS REST API with full CRUD operations, content versioning, and draft/publish workflow. Supports categories and tag-based filtering.",complexity:"Simple",tags:["HTTP","Database"],yaml:`name: content-management-api +version: "1.0" + +modules: + - name: http-server + type: httpserver + config: + port: 8080 + + - name: auth + type: auth_middleware + config: + provider: jwt + secret: "{{secrets.jwt_secret}}" + + - name: content-db + type: database + config: + driver: postgres + dsn: "{{secrets.content_dsn}}" + + - name: validator + type: json_schema + config: + strict: true + +workflows: + - name: list-articles + trigger: + type: http + method: GET + path: /api/articles + steps: + - module: content-db + action: query + sql: "SELECT id, title, slug, status, updated_at FROM articles WHERE status='published' ORDER BY updated_at DESC" + + - name: create-article + trigger: + type: http + method: POST + path: /api/articles + steps: + - module: auth + - module: validator + schema: article-create + - module: content-db + action: exec + sql: "INSERT INTO articles (title, slug, body, status, version, author_id) VALUES ($1,$2,$3,'draft',1,$4)" + + - name: publish-article + trigger: + type: http + method: POST + path: /api/articles/:id/publish + steps: + - module: auth + - module: content-db + action: exec + sql: "UPDATE articles SET status='published', version=version+1, published_at=NOW() WHERE id=$1"`},{id:"notification-hub",name:"Notification Hub",description:"Multi-channel notification dispatch service that routes messages to email, SMS, Slack, and push notification providers based on user preferences and event type.",complexity:"Simple",tags:["Event-Driven","Integration"],yaml:`name: notification-hub +version: "1.0" + +modules: + - name: event-bus + type: eventbus + config: + provider: memory + buffer_size: 5000 + + - name: email-provider + type: http_client + config: + base_url: "https://api.sendgrid.com/v3" + headers: + Authorization: "Bearer {{secrets.sendgrid_key}}" + + - name: sms-provider + type: http_client + config: + base_url: "https://api.twilio.com" + timeout: "10s" + + - name: slack-provider + type: http_client + config: + base_url: "https://hooks.slack.com" + + - name: push-provider + type: http_client + config: + base_url: "https://fcm.googleapis.com/v1" + headers: + Authorization: "Bearer {{secrets.fcm_token}}" + +workflows: + - name: send-email + trigger: + type: messaging + topic: notify.email + steps: + - module: email-provider + action: POST + path: /mail/send + + - name: send-sms + trigger: + type: messaging + topic: notify.sms + steps: + - module: sms-provider + action: POST + path: /Messages.json + + - name: send-slack + trigger: + type: messaging + topic: notify.slack + steps: + - module: slack-provider + action: POST + path: "/services/{{secrets.slack_webhook}}" + + - name: send-push + trigger: + type: messaging + topic: notify.push + steps: + - module: push-provider + action: POST + path: /messages:send`},{id:"search-indexer",name:"Search Indexer Pipeline",description:"CDC-powered search indexing pipeline that captures database changes, applies JQ transforms to shape documents, and upserts them into a search index for full-text queries.",complexity:"Intermediate",tags:["Pipeline","Event-Driven","Database"],yaml:`name: search-indexer-pipeline +version: "1.0" + +modules: + - name: source-db + type: database + config: + driver: postgres + dsn: "{{secrets.source_dsn}}" + cdc: + enabled: true + slot: search_indexer_slot + + - name: event-bus + type: eventbus + config: + provider: memory + buffer_size: 5000 + + - name: transformer + type: json_transform + config: + mappings: + - source: "$.new" + target: "$.document" + transform: "jq" + expression: '{id: .id, title: .title, body: .body, tags: (.tags // [] | join(" ")), updated: .updated_at}' + + - name: search-client + type: http_client + config: + base_url: "{{secrets.search_endpoint}}" + headers: + Authorization: "Bearer {{secrets.search_api_key}}" + timeout: "10s" + + - name: metrics + type: prometheus_exporter + config: + port: 9090 + +workflows: + - name: index-change + trigger: + type: messaging + topic: cdc.source-db + steps: + - module: transformer + - module: search-client + action: PUT + path: "/indexes/content/documents/{{document.id}}" + - module: metrics + action: counter + name: documents_indexed + + - name: reindex-all + trigger: + type: http + method: POST + path: /api/reindex + steps: + - module: source-db + action: query + sql: "SELECT * FROM content ORDER BY id" + - module: transformer + - module: search-client + action: POST + path: /indexes/content/documents/batch`}];function _A({complexity:e}){const n=L$[e];return u.jsx("span",{style:{display:"inline-block",padding:"2px 10px",borderRadius:12,fontSize:11,fontWeight:600,background:n+"22",color:n},children:e})}function kA({tag:e}){return u.jsx("span",{style:{display:"inline-block",padding:"1px 6px",borderRadius:3,fontSize:10,background:"#45475a",color:"#a6adc8"},children:e})}function U$({template:e,onPreview:n,onUse:r}){return u.jsxs("div",{onClick:()=>n(e),style:{background:"#313244",border:"1px solid #45475a",borderRadius:8,padding:16,cursor:"pointer",transition:"border-color 0.15s",display:"flex",flexDirection:"column",gap:8},onMouseEnter:a=>a.currentTarget.style.borderColor="#89b4fa",onMouseLeave:a=>a.currentTarget.style.borderColor="#45475a",children:[u.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start"},children:[u.jsx("div",{style:{color:"#cdd6f4",fontWeight:600,fontSize:14},children:e.name}),u.jsx(_A,{complexity:e.complexity})]}),u.jsx("div",{style:{fontSize:12,color:"#a6adc8",lineHeight:1.4,flex:1},children:e.description}),u.jsx("div",{style:{display:"flex",gap:4,flexWrap:"wrap"},children:e.tags.map(a=>u.jsx(kA,{tag:a},a))}),u.jsx("div",{style:{display:"flex",justifyContent:"flex-end",marginTop:4},children:u.jsx("button",{onClick:a=>{a.stopPropagation(),r(e)},style:{padding:"6px 16px",borderRadius:4,border:"none",fontSize:12,fontWeight:600,cursor:"pointer",background:"#89b4fa",color:"#1e1e2e"},children:"Use Template"})})]})}function F$({template:e,onClose:n,onUse:r}){return u.jsx("div",{onClick:n,style:{position:"fixed",inset:0,background:"rgba(0,0,0,0.6)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},children:u.jsxs("div",{onClick:a=>a.stopPropagation(),style:{background:"#1e1e2e",border:"1px solid #45475a",borderRadius:12,width:"90%",maxWidth:700,maxHeight:"85vh",overflow:"auto",padding:24},children:[u.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",marginBottom:16},children:[u.jsxs("div",{children:[u.jsx("h2",{style:{color:"#cdd6f4",margin:0,fontSize:20,fontWeight:600},children:e.name}),u.jsxs("div",{style:{display:"flex",gap:8,alignItems:"center",marginTop:8},children:[u.jsx(_A,{complexity:e.complexity}),e.tags.map(a=>u.jsx(kA,{tag:a},a))]})]}),u.jsx("button",{onClick:n,style:{background:"none",border:"none",color:"#6c7086",fontSize:20,cursor:"pointer",padding:4},children:"x"})]}),u.jsx("p",{style:{color:"#a6adc8",fontSize:13,lineHeight:1.6,marginBottom:20},children:e.description}),u.jsx("h3",{style:{color:"#cdd6f4",fontSize:14,fontWeight:600,marginBottom:8},children:"Workflow Configuration"}),u.jsx("pre",{style:{background:"#181825",border:"1px solid #313244",borderRadius:6,padding:12,fontSize:12,color:"#89b4fa",overflow:"auto",maxHeight:400,marginBottom:20,lineHeight:1.5},children:e.yaml}),u.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8},children:[u.jsx("button",{onClick:n,style:{padding:"8px 20px",borderRadius:6,border:"1px solid #45475a",fontSize:13,fontWeight:600,cursor:"pointer",background:"transparent",color:"#a6adc8"},children:"Close"}),u.jsx("button",{onClick:()=>r(e),style:{padding:"8px 24px",borderRadius:6,border:"none",fontSize:13,fontWeight:600,cursor:"pointer",background:"#89b4fa",color:"#1e1e2e"},children:"Use Template"})]})]})})}function P$(){const[e,n]=N.useState(null),[r,a]=N.useState("All"),[o,l]=N.useState("All"),[c,d]=N.useState(new Set),p=ue(w=>w.importFromConfig),h=ue(w=>w.clearCanvas),g=ue(w=>w.addToast),y=ue(w=>w.nodes),m=jt(w=>w.setActiveView),b=N.useMemo(()=>H$.filter(w=>{const C=r==="All"||w.complexity===r,_=o==="All"||w.tags.includes(o);return C&&_}),[r,o]),S=w=>{if(!(y.length>0&&!window.confirm("This will replace your current workflow. Any unsaved changes will be lost. Continue?")))try{const C=Bs(w.yaml);h(),p(C),d(_=>new Set(_).add(w.id)),n(null),m("editor"),g(`Template "${w.name}" loaded`,"success")}catch(C){console.error("Failed to load template:",C),g("Failed to load template","error")}};return u.jsxs("div",{style:{flex:1,background:"#1e1e2e",overflow:"auto",padding:24},children:[u.jsx("h2",{style:{color:"#cdd6f4",margin:"0 0 4px",fontSize:20,fontWeight:600},children:"Template Gallery"}),u.jsx("p",{style:{color:"#6c7086",fontSize:13,margin:"0 0 20px"},children:"Start with a pre-built workflow template and customize it for your needs."}),u.jsxs("div",{style:{display:"flex",gap:12,marginBottom:20,flexWrap:"wrap"},children:[u.jsxs("select",{value:r,onChange:w=>a(w.target.value),style:{padding:"8px 12px",borderRadius:6,border:"1px solid #45475a",background:"#313244",color:"#cdd6f4",fontSize:13,outline:"none",cursor:"pointer"},children:[u.jsx("option",{value:"All",children:"All Complexities"}),u.jsx("option",{value:"Simple",children:"Simple"}),u.jsx("option",{value:"Intermediate",children:"Intermediate"}),u.jsx("option",{value:"Advanced",children:"Advanced"})]}),u.jsxs("select",{value:o,onChange:w=>l(w.target.value),style:{padding:"8px 12px",borderRadius:6,border:"1px solid #45475a",background:"#313244",color:"#cdd6f4",fontSize:13,outline:"none",cursor:"pointer"},children:[u.jsx("option",{value:"All",children:"All Tags"}),B$.map(w=>u.jsx("option",{value:w,children:w},w))]})]}),u.jsxs("div",{style:{fontSize:12,color:"#6c7086",marginBottom:12},children:["Showing ",b.length," template",b.length!==1?"s":""]}),u.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(320px, 1fr))",gap:12},children:[b.map(w=>u.jsxs("div",{style:{position:"relative"},children:[c.has(w.id)&&u.jsx("div",{style:{position:"absolute",top:8,right:8,background:"#a6e3a122",color:"#a6e3a1",padding:"2px 8px",borderRadius:4,fontSize:10,fontWeight:600,zIndex:1},children:"Added"}),u.jsx(U$,{template:w,onPreview:n,onUse:S})]},w.id)),b.length===0&&u.jsx("div",{style:{color:"#6c7086",fontSize:13,gridColumn:"1 / -1",padding:40,textAlign:"center"},children:"No templates match your filter criteria."})]}),e&&u.jsx(F$,{template:e,onClose:()=>n(null),onUse:S})]})}function _s(){const e={"Content-Type":"application/json"},n=localStorage.getItem("auth_token");return n&&(e.Authorization=`Bearer ${n}`),e}const xr=Mn((e,n)=>({environments:[],loading:!1,error:null,selectedEnvironment:null,fetchEnvironments:async r=>{if(!n().loading){e({loading:!0,error:null});try{const a=new URLSearchParams;r?.workflow_id&&a.set("workflow_id",r.workflow_id),r?.provider&&a.set("provider",r.provider),r?.status&&a.set("status",r.status);const o=a.toString(),l="/api/v1/admin/environments"+(o?`?${o}`:""),c=await fetch(l,{headers:_s()});if(!c.ok){const h=await c.json().catch(()=>({}));throw new Error(h.error||`Failed to fetch environments (${c.status})`)}const d=await c.json(),p=Array.isArray(d)?d:[];e({environments:p,loading:!1})}catch(a){e({loading:!1,error:a instanceof Error?a.message:String(a)})}}},createEnvironment:async r=>{e({error:null});try{const a=await fetch("/api/v1/admin/environments",{method:"POST",headers:_s(),body:JSON.stringify(r)});if(!a.ok){const l=await a.json().catch(()=>({}));throw new Error(l.error||`Failed to create environment (${a.status})`)}const o=await a.json();e(l=>({environments:[...l.environments,o]}))}catch(a){throw e({error:a instanceof Error?a.message:String(a)}),a}},updateEnvironment:async(r,a)=>{e({error:null});try{const o=await fetch(`/api/v1/admin/environments/${r}`,{method:"PUT",headers:_s(),body:JSON.stringify(a)});if(!o.ok){const c=await o.json().catch(()=>({}));throw new Error(c.error||`Failed to update environment (${o.status})`)}const l=await o.json();e(c=>({environments:c.environments.map(d=>d.id===r?l:d),selectedEnvironment:c.selectedEnvironment?.id===r?l:c.selectedEnvironment}))}catch(o){throw e({error:o instanceof Error?o.message:String(o)}),o}},deleteEnvironment:async r=>{e({error:null});try{const a=await fetch(`/api/v1/admin/environments/${r}`,{method:"DELETE",headers:_s()});if(!a.ok){const o=await a.json().catch(()=>({}));throw new Error(o.error||`Failed to delete environment (${a.status})`)}e(o=>({environments:o.environments.filter(l=>l.id!==r),selectedEnvironment:o.selectedEnvironment?.id===r?null:o.selectedEnvironment}))}catch(a){throw e({error:a instanceof Error?a.message:String(a)}),a}},testConnection:async r=>{const a=await fetch(`/api/v1/admin/environments/${r}/test`,{method:"POST",headers:_s()});if(!a.ok){const o=await a.json().catch(()=>({}));throw new Error(o.error||`Test failed (${a.status})`)}return await a.json()},setSelectedEnvironment:r=>{e({selectedEnvironment:r})}})),$$={active:"#a6e3a1",provisioning:"#f9e2af",error:"#f38ba8",decommissioned:"#6c7086"},Q0=["aws","gcp","azure","digitalocean"],Au={aws:"AWS",gcp:"Google Cloud",azure:"Azure",digitalocean:"DigitalOcean"},V$={aws:[{key:"region",label:"Region",sensitive:!1,target:"config",placeholder:"us-east-1"},{key:"access_key_id",label:"Access Key ID",sensitive:!0,target:"secrets"},{key:"secret_access_key",label:"Secret Access Key",sensitive:!0,target:"secrets"}],gcp:[{key:"project_id",label:"Project ID",sensitive:!1,target:"config",placeholder:"my-project-123"},{key:"region",label:"Region",sensitive:!1,target:"config",placeholder:"us-central1"},{key:"credentials_json",label:"Credentials JSON",sensitive:!0,target:"secrets"}],azure:[{key:"subscription_id",label:"Subscription ID",sensitive:!1,target:"config"},{key:"tenant_id",label:"Tenant ID",sensitive:!1,target:"config"},{key:"client_id",label:"Client ID",sensitive:!1,target:"config"},{key:"client_secret",label:"Client Secret",sensitive:!0,target:"secrets"}],digitalocean:[{key:"region",label:"Region",sensitive:!1,target:"config",placeholder:"nyc3"},{key:"api_token",label:"API Token",sensitive:!0,target:"secrets"}]};function CA(){const e=Vi(r=>r.enabledPages),n=new Set(e.filter(r=>r.category==="cloud-providers").map(r=>r.id.replace("-settings","")));return n.size===0?[...Q0]:Q0.filter(r=>n.has(r))}function bT(e){return e?new Date(e).toLocaleDateString("en-US",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}):"-"}function W$({status:e}){const n=$$[e]||"#6c7086";return u.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:6,padding:"2px 8px",borderRadius:4,fontSize:11,fontWeight:600,background:n+"22",color:n,textTransform:"capitalize"},children:[u.jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:n,display:"inline-block"}}),e]})}function G$(){return u.jsx("div",{style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",color:"#a6adc8",fontSize:14,padding:40},children:"Loading environments..."})}function Y$({message:e,onDismiss:n}){return u.jsxs("div",{style:{background:"#f38ba822",border:"1px solid #f38ba844",borderRadius:6,padding:"10px 16px",marginBottom:16,display:"flex",justifyContent:"space-between",alignItems:"center",fontSize:13,color:"#f38ba8"},children:[u.jsx("span",{children:e}),u.jsx("button",{onClick:n,style:{background:"none",border:"none",color:"#f38ba8",cursor:"pointer",fontSize:16,padding:"0 4px"},children:"x"})]})}function X$(){return{name:"",workflow_id:"",provider:"aws",region:"",config:{},secrets:{}}}function K$(e){const n=Q0.includes(e.provider)?e.provider:"aws",r={},a={};for(const[o,l]of Object.entries(e.config??{}))r[o]=String(l);for(const[o,l]of Object.entries(e.secrets??{}))a[o]=String(l);return{name:e.name,workflow_id:e.workflow_id,provider:n,region:e.region,config:r,secrets:a}}function xT({initial:e,title:n,onSave:r,onCancel:a,saving:o}){const l=CA(),[c,d]=N.useState(e),p=V$[c.provider]||[],h=(m,b)=>d(S=>({...S,[m]:b})),g=(m,b)=>{d(S=>m.target==="secrets"?{...S,secrets:{...S.secrets,[m.key]:b}}:{...S,config:{...S.config,[m.key]:b}})},y=m=>m.target==="secrets"?c.secrets[m.key]||"":c.config[m.key]||"";return u.jsx("div",{onClick:a,style:{position:"fixed",inset:0,background:"rgba(0,0,0,0.6)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},children:u.jsxs("div",{onClick:m=>m.stopPropagation(),style:{background:"#1e1e2e",border:"1px solid #45475a",borderRadius:12,padding:24,width:"90%",maxWidth:520,maxHeight:"80vh",overflowY:"auto"},children:[u.jsx("h3",{style:{color:"#cdd6f4",margin:"0 0 16px",fontSize:16,fontWeight:600},children:n}),u.jsx(ks,{label:"Name",required:!0,children:u.jsx("input",{value:c.name,onChange:m=>h("name",m.target.value),placeholder:"production-us-east",style:Hi})}),u.jsx(ks,{label:"Workflow ID",required:!0,children:u.jsx("input",{value:c.workflow_id,onChange:m=>h("workflow_id",m.target.value),placeholder:"workflow-uuid",style:Hi})}),u.jsx(ks,{label:"Provider",required:!0,children:u.jsx("select",{value:c.provider,onChange:m=>h("provider",m.target.value),style:Hi,children:l.map(m=>u.jsx("option",{value:m,children:Au[m]},m))})}),u.jsx(ks,{label:"Region",children:u.jsx("input",{value:c.region,onChange:m=>h("region",m.target.value),placeholder:"us-east-1",style:Hi})}),p.length>0&&u.jsxs("div",{style:{marginTop:12,padding:"12px 0",borderTop:"1px solid #45475a"},children:[u.jsxs("div",{style:{fontSize:12,color:"#a6adc8",fontWeight:600,marginBottom:8},children:[Au[c.provider]," Configuration"]}),p.map(m=>u.jsx(ks,{label:m.label,sensitive:m.sensitive,children:u.jsx("input",{value:y(m),onChange:b=>g(m,b.target.value),placeholder:m.placeholder,type:m.sensitive?"password":"text",style:Hi})},m.key))]}),u.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8,marginTop:16},children:[u.jsx("button",{onClick:a,style:EA,disabled:o,children:"Cancel"}),u.jsx("button",{onClick:()=>r(c),style:Vb,disabled:o||!c.name||!c.workflow_id,children:o?"Saving...":"Save"})]})]})})}function ks({label:e,required:n,sensitive:r,children:a}){return u.jsxs("div",{style:{marginBottom:12},children:[u.jsxs("label",{style:{display:"block",fontSize:12,color:"#a6adc8",marginBottom:4},children:[e,n&&u.jsx("span",{style:{color:"#f38ba8",marginLeft:2},children:"*"}),r&&u.jsx("span",{style:{color:"#f9e2af",marginLeft:6,fontSize:10},children:"sensitive"})]}),a]})}function Z$({envName:e,onConfirm:n,onCancel:r}){return u.jsx("div",{onClick:r,style:{position:"fixed",inset:0,background:"rgba(0,0,0,0.6)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},children:u.jsxs("div",{onClick:a=>a.stopPropagation(),style:{background:"#1e1e2e",border:"1px solid #45475a",borderRadius:12,padding:24,width:"90%",maxWidth:400},children:[u.jsx("h3",{style:{color:"#cdd6f4",margin:"0 0 12px",fontSize:16,fontWeight:600},children:"Delete Environment"}),u.jsxs("p",{style:{color:"#a6adc8",fontSize:13,lineHeight:1.5,marginBottom:16},children:["Are you sure you want to delete ",u.jsx("strong",{style:{color:"#cdd6f4"},children:e}),"? This action cannot be undone."]}),u.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8},children:[u.jsx("button",{onClick:r,style:EA,children:"Cancel"}),u.jsx("button",{onClick:n,style:{...Vb,background:"#f38ba8"},children:"Delete"})]})]})})}function Q$({env:e,onEdit:n,onDelete:r,onTest:a}){return u.jsxs("div",{style:{background:"#313244",borderRadius:8,border:"1px solid #45475a",padding:16,transition:"border-color 0.15s"},onMouseEnter:o=>o.currentTarget.style.borderColor="#89b4fa",onMouseLeave:o=>o.currentTarget.style.borderColor="#45475a",children:[u.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:10},children:[u.jsxs("div",{children:[u.jsx("div",{style:{color:"#cdd6f4",fontWeight:600,fontSize:15},children:e.name}),u.jsxs("div",{style:{fontSize:11,color:"#6c7086",marginTop:2},children:[Au[e.provider]||e.provider,e.region?` / ${e.region}`:""]})]}),u.jsx(W$,{status:e.status})]}),u.jsxs("div",{style:{fontSize:12,color:"#a6adc8",marginBottom:12,display:"flex",gap:16,flexWrap:"wrap"},children:[u.jsxs("span",{children:[u.jsx("span",{style:{color:"#6c7086"},children:"Workflow: "}),u.jsx("span",{style:{color:"#89b4fa",fontFamily:"monospace",fontSize:11},children:e.workflow_id})]}),u.jsxs("span",{children:[u.jsx("span",{style:{color:"#6c7086"},children:"Created: "}),bT(e.created_at)]}),u.jsxs("span",{children:[u.jsx("span",{style:{color:"#6c7086"},children:"Updated: "}),bT(e.updated_at)]})]}),u.jsxs("div",{style:{display:"flex",gap:8},children:[u.jsx("button",{onClick:()=>a(e),style:du,children:"Test Connection"}),u.jsx("button",{onClick:()=>n(e),style:du,children:"Edit"}),u.jsx("button",{onClick:()=>r(e),style:{...du,color:"#f38ba8",borderColor:"#f38ba844"},children:"Delete"})]})]})}function J$(){const e=CA(),n=xr(F=>F.environments),r=xr(F=>F.loading),a=xr(F=>F.error),o=xr(F=>F.fetchEnvironments),l=xr(F=>F.createEnvironment),c=xr(F=>F.updateEnvironment),d=xr(F=>F.deleteEnvironment),p=xr(F=>F.testConnection),[h,g]=N.useState(!1),[y,m]=N.useState(null),[b,S]=N.useState(null),[w,C]=N.useState(!1),[_,j]=N.useState(null),[k,T]=N.useState(""),[E,z]=N.useState("");N.useEffect(()=>{o()},[]);const A=N.useCallback(async F=>{C(!0);try{await l({name:F.name,workflow_id:F.workflow_id,provider:F.provider,region:F.region,config:F.config,secrets:F.secrets}),g(!1)}catch{}finally{C(!1)}},[l]),M=N.useCallback(async F=>{if(y){C(!0);try{await c(y.id,{name:F.name,workflow_id:F.workflow_id,provider:F.provider,region:F.region,config:F.config,secrets:F.secrets}),m(null)}catch{}finally{C(!1)}}},[y,c]),O=N.useCallback(async()=>{if(b)try{await d(b.id),S(null)}catch{}},[b,d]),P=N.useCallback(async F=>{j(null);try{const U=await p(F.id);j({envId:F.id,success:U.success,message:U.message})}catch(U){j({envId:F.id,success:!1,message:U instanceof Error?U.message:"Test failed"})}},[p]),L=N.useCallback(()=>{const F={};k&&(F.provider=k),E&&(F.status=E),o(Object.keys(F).length>0?F:void 0)},[o,k,E]),I=(Array.isArray(n)?n:[]).filter(F=>!(k&&F.provider!==k||E&&F.status!==E));return u.jsxs("div",{style:{flex:1,background:"#1e1e2e",overflow:"auto",padding:24},children:[u.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",marginBottom:20},children:[u.jsxs("div",{children:[u.jsx("h2",{style:{color:"#cdd6f4",margin:"0 0 4px",fontSize:20,fontWeight:600},children:"Environments"}),u.jsx("p",{style:{color:"#6c7086",fontSize:13,margin:0},children:"Manage deployment targets and cloud provider configurations."})]}),u.jsx("button",{onClick:()=>g(!0),style:Vb,children:"+ Create Environment"})]}),a&&u.jsx(Y$,{message:a,onDismiss:()=>xr.setState({error:null})}),_&&u.jsxs("div",{style:{background:_.success?"#a6e3a122":"#f38ba822",border:`1px solid ${_.success?"#a6e3a144":"#f38ba844"}`,borderRadius:6,padding:"10px 16px",marginBottom:16,display:"flex",justifyContent:"space-between",alignItems:"center",fontSize:13,color:_.success?"#a6e3a1":"#f38ba8"},children:[u.jsxs("span",{children:["Connection test: ",_.message]}),u.jsx("button",{onClick:()=>j(null),style:{background:"none",border:"none",color:_.success?"#a6e3a1":"#f38ba8",cursor:"pointer",fontSize:16,padding:"0 4px"},children:"x"})]}),u.jsxs("div",{style:{display:"flex",gap:8,marginBottom:16,alignItems:"center"},children:[u.jsxs("select",{value:k,onChange:F=>T(F.target.value),style:{...Hi,width:160,marginBottom:0},children:[u.jsx("option",{value:"",children:"All Providers"}),e.map(F=>u.jsx("option",{value:F,children:Au[F]},F))]}),u.jsxs("select",{value:E,onChange:F=>z(F.target.value),style:{...Hi,width:160,marginBottom:0},children:[u.jsx("option",{value:"",children:"All Statuses"}),u.jsx("option",{value:"active",children:"Active"}),u.jsx("option",{value:"provisioning",children:"Provisioning"}),u.jsx("option",{value:"error",children:"Error"}),u.jsx("option",{value:"decommissioned",children:"Decommissioned"})]}),u.jsx("button",{onClick:L,style:du,children:"Refresh"}),u.jsxs("span",{style:{fontSize:12,color:"#6c7086",marginLeft:8},children:[I.length," environment",I.length!==1?"s":""]})]}),r&&n.length===0?u.jsx(G$,{}):I.length===0?u.jsx("div",{style:{color:"#6c7086",fontSize:14,textAlign:"center",padding:40,background:"#313244",borderRadius:8},children:n.length===0?"No environments yet. Create one to get started.":"No environments match the current filters."}):u.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(420px, 1fr))",gap:16},children:I.map(F=>u.jsx(Q$,{env:F,onEdit:m,onDelete:S,onTest:P},F.id))}),h&&u.jsx(xT,{initial:X$(),title:"Create Environment",onSave:A,onCancel:()=>g(!1),saving:w}),y&&u.jsx(xT,{initial:K$(y),title:`Edit: ${y.name}`,onSave:M,onCancel:()=>m(null),saving:w}),b&&u.jsx(Z$,{envName:b.name,onConfirm:O,onCancel:()=>S(null)})]})}const Hi={width:"100%",padding:"8px 10px",borderRadius:6,border:"1px solid #45475a",background:"#313244",color:"#cdd6f4",fontSize:13,outline:"none",boxSizing:"border-box"},Vb={padding:"8px 20px",borderRadius:6,border:"none",fontSize:13,fontWeight:600,cursor:"pointer",background:"#89b4fa",color:"#1e1e2e"},EA={padding:"8px 20px",borderRadius:6,border:"1px solid #45475a",fontSize:13,fontWeight:600,cursor:"pointer",background:"transparent",color:"#a6adc8"},du={padding:"4px 12px",borderRadius:4,border:"1px solid #45475a",fontSize:11,fontWeight:600,cursor:"pointer",background:"transparent",color:"#89b4fa"};function Za(){const e={"Content-Type":"application/json"},n=localStorage.getItem("auth_token");return n&&(e.Authorization=`Bearer ${n}`),e}const qi="/api/v1/admin/feature-flags";let iu=null;const En=Mn((e,n)=>({flags:[],loading:!1,error:null,sseConnected:!1,fetchFlags:async()=>{if(!n().loading){e({loading:!0,error:null});try{const r=await fetch(qi,{headers:Za()});if(!r.ok){const l=await r.json().catch(()=>({}));throw new Error(l.error||`Failed to fetch flags (${r.status})`)}const a=await r.json(),o=Array.isArray(a)?a:[];e({flags:o,loading:!1})}catch(r){e({loading:!1,error:r instanceof Error?r.message:String(r)})}}},createFlag:async r=>{e({error:null});try{const a=await fetch(qi,{method:"POST",headers:Za(),body:JSON.stringify(r)});if(!a.ok){const l=await a.json().catch(()=>({}));throw new Error(l.error||`Failed to create flag (${a.status})`)}const o=await a.json();e(l=>({flags:[...l.flags,o]}))}catch(a){throw e({error:a instanceof Error?a.message:String(a)}),a}},updateFlag:async(r,a)=>{e({error:null});try{const o=await fetch(`${qi}/${encodeURIComponent(r)}`,{method:"PUT",headers:Za(),body:JSON.stringify(a)});if(!o.ok){const c=await o.json().catch(()=>({}));throw new Error(c.error||`Failed to update flag (${o.status})`)}const l=await o.json();e(c=>({flags:c.flags.map(d=>d.key===r?l:d)}))}catch(o){throw e({error:o instanceof Error?o.message:String(o)}),o}},deleteFlag:async r=>{e({error:null});try{const a=await fetch(`${qi}/${encodeURIComponent(r)}`,{method:"DELETE",headers:Za()});if(!a.ok){const o=await a.json().catch(()=>({}));throw new Error(o.error||`Failed to delete flag (${a.status})`)}e(o=>({flags:o.flags.filter(l=>l.key!==r)}))}catch(a){throw e({error:a instanceof Error?a.message:String(a)}),a}},setOverrides:async(r,a)=>{e({error:null});try{const o=await fetch(`${qi}/${encodeURIComponent(r)}/overrides`,{method:"PUT",headers:Za(),body:JSON.stringify(a)});if(!o.ok){const c=await o.json().catch(()=>({}));throw new Error(c.error||`Failed to set overrides (${o.status})`)}const l=await o.json();e(c=>({flags:c.flags.map(d=>d.key===r?l:d)}))}catch(o){throw e({error:o instanceof Error?o.message:String(o)}),o}},evaluateFlag:async(r,a)=>{const o=new URLSearchParams;if(a.user&&o.set("user",a.user),a.group&&o.set("group",a.group),a.attributes)for(const[h,g]of Object.entries(a.attributes))o.set(`attr.${h}`,g);const l=o.toString(),c=`${qi}/${encodeURIComponent(r)}/evaluate${l?`?${l}`:""}`,d=await fetch(c,{headers:Za()});if(!d.ok){const h=await d.json().catch(()=>({}));throw new Error(h.error||`Evaluation failed (${d.status})`)}return(await d.json()).value},connectSSE:()=>{n().disconnectSSE();const r=localStorage.getItem("auth_token")||"",a=`${qi}/stream${r?`?token=${encodeURIComponent(r)}`:""}`,o=new EventSource(a);iu=o,o.addEventListener("flag.updated",l=>{try{const c=JSON.parse(l.data);e(d=>({flags:d.flags.map(p=>p.key===c.key?c:p)}))}catch{}}),o.addEventListener("flag.created",l=>{try{const c=JSON.parse(l.data);e(d=>d.flags.some(p=>p.key===c.key)?{flags:d.flags.map(p=>p.key===c.key?c:p)}:{flags:[...d.flags,c]})}catch{}}),o.addEventListener("flag.deleted",l=>{try{const c=JSON.parse(l.data),d=c.key||c;e(p=>({flags:p.flags.filter(h=>h.key!==d)}))}catch{}}),o.onopen=()=>{e({sseConnected:!0})},o.onerror=()=>{e({sseConnected:!1})}},disconnectSSE:()=>{iu&&(iu.close(),iu=null),e({sseConnected:!1})}})),au={width:"100%",padding:"6px 8px",borderRadius:4,border:"1px solid #45475a",background:"#313244",color:"#cdd6f4",fontSize:12,outline:"none",boxSizing:"border-box"},eV={padding:"4px 10px",borderRadius:4,border:"1px solid #45475a",fontSize:11,fontWeight:600,cursor:"pointer",background:"transparent",color:"#89b4fa"};function tV(e,n){if(n==="boolean")return e==="true";if(n==="number")return Number(e)||0;if(n==="json")try{return JSON.parse(e)}catch{return e}return e}function nV(e){return e==null?"":typeof e=="object"?JSON.stringify(e):String(e)}function rV({overrides:e,flagType:n,onChange:r}){const[a,o]=N.useState("user"),[l,c]=N.useState(""),[d,p]=N.useState(""),h=()=>{if(!l.trim())return;const y={type:a,key:l.trim(),value:tV(d,n)};r([...e,y]),c(""),p("")},g=y=>{r(e.filter((m,b)=>b!==y))};return u.jsxs("div",{children:[u.jsxs("div",{style:{fontSize:12,fontWeight:600,color:"#a6adc8",marginBottom:8},children:["Overrides (",e.length,")"]}),e.length>0&&u.jsx("div",{style:{marginBottom:12},children:e.map((y,m)=>u.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"6px 8px",background:"#313244",borderRadius:4,marginBottom:4,fontSize:12},children:[u.jsx("span",{style:{padding:"1px 6px",borderRadius:3,background:y.type==="user"?"#89b4fa22":"#a6e3a122",color:y.type==="user"?"#89b4fa":"#a6e3a1",fontSize:10,fontWeight:600,textTransform:"uppercase",flexShrink:0},children:y.type}),u.jsx("span",{style:{color:"#cdd6f4",fontFamily:"monospace"},children:y.key}),u.jsx("span",{style:{color:"#6c7086"},children:"="}),u.jsx("span",{style:{color:"#f9e2af",fontFamily:"monospace",flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:nV(y.value)}),u.jsx("button",{onClick:()=>g(m),style:{background:"none",border:"none",color:"#f38ba8",cursor:"pointer",fontSize:14,padding:"0 4px",flexShrink:0},children:"x"})]},m))}),u.jsxs("div",{style:{display:"flex",gap:6,alignItems:"flex-end"},children:[u.jsxs("div",{style:{width:80},children:[u.jsx("div",{style:{fontSize:10,color:"#6c7086",marginBottom:2},children:"Type"}),u.jsxs("select",{value:a,onChange:y=>o(y.target.value),style:{...au,width:80},children:[u.jsx("option",{value:"user",children:"User"}),u.jsx("option",{value:"group",children:"Group"})]})]}),u.jsxs("div",{style:{flex:1},children:[u.jsx("div",{style:{fontSize:10,color:"#6c7086",marginBottom:2},children:"Key"}),u.jsx("input",{value:l,onChange:y=>c(y.target.value),placeholder:a==="user"?"user-id":"group-name",style:au})]}),u.jsxs("div",{style:{flex:1},children:[u.jsx("div",{style:{fontSize:10,color:"#6c7086",marginBottom:2},children:"Value"}),n==="boolean"?u.jsxs("select",{value:d,onChange:y=>p(y.target.value),style:au,children:[u.jsx("option",{value:"true",children:"true"}),u.jsx("option",{value:"false",children:"false"})]}):u.jsx("input",{value:d,onChange:y=>p(y.target.value),placeholder:"override value",style:au})]}),u.jsx("button",{onClick:h,style:{...eV,flexShrink:0},children:"+ Add"})]})]})}const iV=[{value:"eq",label:"="},{value:"neq",label:"!="},{value:"in",label:"in"},{value:"contains",label:"contains"},{value:"startsWith",label:"starts with"},{value:"gt",label:">"},{value:"lt",label:"<"}],Hs={padding:"5px 8px",borderRadius:4,border:"1px solid #45475a",background:"#313244",color:"#cdd6f4",fontSize:12,outline:"none",boxSizing:"border-box"},Ds={padding:"3px 8px",borderRadius:4,border:"1px solid #45475a",fontSize:11,fontWeight:600,cursor:"pointer",background:"transparent",color:"#89b4fa"};function aV(e,n){if(n==="boolean")return e==="true";if(n==="number")return Number(e)||0;if(n==="json")try{return JSON.parse(e)}catch{return e}return e}function oV(e){return e==null?"":typeof e=="object"?JSON.stringify(e):String(e)}function jA(){return{attribute:"",operator:"eq",value:""}}function sV(e){const n=e==="boolean"?!0:e==="number"?0:"";return{conditions:[jA()],value:n}}function lV({condition:e,onChange:n,onRemove:r}){return u.jsxs("div",{style:{display:"flex",gap:4,alignItems:"center",marginBottom:4},children:[u.jsx("input",{value:e.attribute,onChange:a=>n({...e,attribute:a.target.value}),placeholder:"attribute",style:{...Hs,width:120}}),u.jsx("select",{value:e.operator,onChange:a=>n({...e,operator:a.target.value}),style:{...Hs,width:100},children:iV.map(a=>u.jsx("option",{value:a.value,children:a.label},a.value))}),u.jsx("input",{value:e.value,onChange:a=>n({...e,value:a.target.value}),placeholder:"value",style:{...Hs,flex:1}}),u.jsx("button",{onClick:r,style:{background:"none",border:"none",color:"#f38ba8",cursor:"pointer",fontSize:13,padding:"0 4px",flexShrink:0},children:"x"})]})}function cV({rule:e,index:n,flagType:r,onChange:a,onRemove:o,onMoveUp:l,onMoveDown:c,isFirst:d,isLast:p}){const h=(m,b)=>{const S=e.conditions.map((w,C)=>C===m?b:w);a({...e,conditions:S})},g=m=>{e.conditions.length<=1||a({...e,conditions:e.conditions.filter((b,S)=>S!==m)})},y=()=>{a({...e,conditions:[...e.conditions,jA()]})};return u.jsxs("div",{style:{background:"#1e1e2e",border:"1px solid #45475a",borderRadius:6,padding:12,marginBottom:8},children:[u.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:8},children:[u.jsxs("span",{style:{fontSize:12,fontWeight:600,color:"#a6adc8"},children:["Rule ",n+1]}),u.jsxs("div",{style:{display:"flex",gap:4},children:[u.jsx("button",{onClick:l,disabled:d,style:{...Ds,opacity:d?.3:1,cursor:d?"default":"pointer"},title:"Move up",children:"^"}),u.jsx("button",{onClick:c,disabled:p,style:{...Ds,opacity:p?.3:1,cursor:p?"default":"pointer"},title:"Move down",children:"v"}),u.jsx("button",{onClick:o,style:{...Ds,color:"#f38ba8",borderColor:"#f38ba844"},children:"Remove"})]})]}),u.jsxs("div",{style:{marginBottom:8},children:[u.jsx("div",{style:{fontSize:10,color:"#6c7086",marginBottom:4,textTransform:"uppercase",letterSpacing:.5},children:"Conditions (all must match)"}),e.conditions.map((m,b)=>u.jsx(lV,{condition:m,onChange:S=>h(b,S),onRemove:()=>g(b)},b)),u.jsx("button",{onClick:y,style:{...Ds,marginTop:4,fontSize:10},children:"+ Condition"})]}),u.jsxs("div",{style:{display:"flex",gap:8,alignItems:"center"},children:[u.jsxs("div",{style:{flex:1},children:[u.jsx("div",{style:{fontSize:10,color:"#6c7086",marginBottom:2},children:"Result Value"}),r==="boolean"?u.jsxs("select",{value:String(e.value),onChange:m=>a({...e,value:m.target.value==="true"}),style:{...Hs,width:"100%"},children:[u.jsx("option",{value:"true",children:"true"}),u.jsx("option",{value:"false",children:"false"})]}):u.jsx("input",{value:oV(e.value),onChange:m=>a({...e,value:aV(m.target.value,r)}),placeholder:"result value",style:{...Hs,width:"100%"}})]}),u.jsxs("div",{style:{width:140},children:[u.jsx("div",{style:{fontSize:10,color:"#6c7086",marginBottom:2},children:"Rollout %"}),u.jsxs("div",{style:{display:"flex",alignItems:"center",gap:4},children:[u.jsx("input",{type:"range",min:0,max:100,value:e.percentage??100,onChange:m=>a({...e,percentage:Number(m.target.value)}),style:{flex:1}}),u.jsxs("span",{style:{fontSize:11,color:"#cdd6f4",width:30,textAlign:"right"},children:[e.percentage??100,"%"]})]})]})]})]})}function uV({rules:e,flagType:n,onChange:r}){const[a,o]=N.useState(!1),l=()=>{r([...e,sV(n)])},c=(h,g)=>{r(e.map((y,m)=>m===h?g:y))},d=h=>{r(e.filter((g,y)=>y!==h))},p=(h,g)=>{if(g<0||g>=e.length)return;const y=[...e],[m]=y.splice(h,1);y.splice(g,0,m),r(y)};return u.jsxs("div",{children:[u.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:8,cursor:"pointer"},onClick:()=>o(!a),children:[u.jsxs("div",{style:{fontSize:12,fontWeight:600,color:"#a6adc8"},children:["Targeting Rules (",e.length,")"]}),u.jsx("span",{style:{fontSize:10,color:"#6c7086"},children:a?"[+]":"[-]"})]}),!a&&u.jsxs(u.Fragment,{children:[e.map((h,g)=>u.jsx(cV,{rule:h,index:g,flagType:n,onChange:y=>c(g,y),onRemove:()=>d(g),onMoveUp:()=>p(g,g-1),onMoveDown:()=>p(g,g+1),isFirst:g===0,isLast:g===e.length-1},g)),u.jsx("button",{onClick:l,style:Ds,children:"+ Add Rule"})]})]})}const jn={width:"100%",padding:"8px 10px",borderRadius:6,border:"1px solid #45475a",background:"#313244",color:"#cdd6f4",fontSize:13,outline:"none",boxSizing:"border-box"},Wb={padding:"8px 20px",borderRadius:6,border:"none",fontSize:13,fontWeight:600,cursor:"pointer",background:"#89b4fa",color:"#1e1e2e"},TA={padding:"8px 20px",borderRadius:6,border:"1px solid #45475a",fontSize:13,fontWeight:600,cursor:"pointer",background:"transparent",color:"#a6adc8"},J0={padding:"4px 12px",borderRadius:4,border:"1px solid #45475a",fontSize:11,fontWeight:600,cursor:"pointer",background:"transparent",color:"#89b4fa"};function AA({enabled:e,onChange:n}){return u.jsx("button",{onClick:()=>n(!e),style:{width:36,height:20,borderRadius:10,border:"none",cursor:"pointer",background:e?"#a6e3a1":"#45475a",position:"relative",transition:"background 0.15s",flexShrink:0},children:u.jsx("div",{style:{width:14,height:14,borderRadius:"50%",background:"#1e1e2e",position:"absolute",top:3,left:e?19:3,transition:"left 0.15s"}})})}function dV({type:e}){const n={boolean:"#a6e3a1",string:"#89b4fa",number:"#f9e2af",json:"#cba6f7"};return u.jsx("span",{style:{padding:"1px 6px",borderRadius:3,fontSize:10,fontWeight:600,background:(n[e]||"#6c7086")+"22",color:n[e]||"#6c7086",textTransform:"uppercase"},children:e})}function fV({message:e,onDismiss:n}){return u.jsxs("div",{style:{background:"#f38ba822",border:"1px solid #f38ba844",borderRadius:6,padding:"10px 16px",marginBottom:16,display:"flex",justifyContent:"space-between",alignItems:"center",fontSize:13,color:"#f38ba8"},children:[u.jsx("span",{children:e}),u.jsx("button",{onClick:n,style:{background:"none",border:"none",color:"#f38ba8",cursor:"pointer",fontSize:16,padding:"0 4px"},children:"x"})]})}function Ii({label:e,required:n,children:r}){return u.jsxs("div",{style:{marginBottom:12},children:[u.jsxs("label",{style:{display:"block",fontSize:12,color:"#a6adc8",marginBottom:4},children:[e,n&&u.jsx("span",{style:{color:"#f38ba8",marginLeft:2},children:"*"})]}),r]})}function RA(e){return e==null?"-":typeof e=="object"?JSON.stringify(e):String(e)}function pV(){return{key:"",name:"",description:"",type:"boolean",enabled:!1,default_value:"false",tags:"",scope:"global",overrides:[],targeting_rules:[]}}function hV(e){return{key:e.key,name:e.name,description:e.description||"",type:e.type,enabled:e.enabled,default_value:RA(e.default_value),tags:(e.tags||[]).join(", "),scope:e.scope||"global",overrides:e.overrides||[],targeting_rules:e.targeting_rules||[]}}function ST(e,n){if(n==="boolean")return e==="true";if(n==="number")return Number(e)||0;if(n==="json")try{return JSON.parse(e)}catch{return e}return e}function wT({initial:e,title:n,isEdit:r,onSave:a,onCancel:o,saving:l}){const[c,d]=N.useState(e),p=(h,g)=>d(y=>({...y,[h]:g}));return u.jsx("div",{onClick:o,style:{position:"fixed",inset:0,background:"rgba(0,0,0,0.6)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},children:u.jsxs("div",{onClick:h=>h.stopPropagation(),style:{background:"#1e1e2e",border:"1px solid #45475a",borderRadius:12,padding:24,width:"90%",maxWidth:600,maxHeight:"85vh",overflowY:"auto"},children:[u.jsx("h3",{style:{color:"#cdd6f4",margin:"0 0 16px",fontSize:16,fontWeight:600},children:n}),u.jsx(Ii,{label:"Key",required:!0,children:u.jsx("input",{value:c.key,onChange:h=>p("key",h.target.value),placeholder:"feature.my-flag",disabled:r,style:{...jn,opacity:r?.5:1}})}),u.jsx(Ii,{label:"Name",required:!0,children:u.jsx("input",{value:c.name,onChange:h=>p("name",h.target.value),placeholder:"My Feature Flag",style:jn})}),u.jsx(Ii,{label:"Description",children:u.jsx("textarea",{value:c.description,onChange:h=>p("description",h.target.value),placeholder:"What does this flag control?",rows:2,style:{...jn,resize:"vertical"}})}),u.jsxs("div",{style:{display:"flex",gap:12},children:[u.jsx("div",{style:{flex:1},children:u.jsx(Ii,{label:"Type",required:!0,children:u.jsxs("select",{value:c.type,onChange:h=>p("type",h.target.value),disabled:r,style:{...jn,opacity:r?.5:1},children:[u.jsx("option",{value:"boolean",children:"Boolean"}),u.jsx("option",{value:"string",children:"String"}),u.jsx("option",{value:"number",children:"Number"}),u.jsx("option",{value:"json",children:"JSON"})]})})}),u.jsx("div",{style:{flex:1},children:u.jsx(Ii,{label:"Scope",children:u.jsx("input",{value:c.scope,onChange:h=>p("scope",h.target.value),placeholder:"global",style:jn})})})]}),u.jsx(Ii,{label:"Default Value",required:!0,children:c.type==="boolean"?u.jsxs("select",{value:c.default_value,onChange:h=>p("default_value",h.target.value),style:jn,children:[u.jsx("option",{value:"true",children:"true"}),u.jsx("option",{value:"false",children:"false"})]}):u.jsx("input",{value:c.default_value,onChange:h=>p("default_value",h.target.value),placeholder:c.type==="number"?"0":c.type==="json"?"{}":"value",style:jn})}),u.jsxs("div",{style:{display:"flex",gap:12},children:[u.jsx("div",{style:{flex:1},children:u.jsx(Ii,{label:"Tags (comma-separated)",children:u.jsx("input",{value:c.tags,onChange:h=>p("tags",h.target.value),placeholder:"frontend, experiment",style:jn})})}),u.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,paddingTop:16},children:[u.jsx("span",{style:{fontSize:12,color:"#a6adc8"},children:"Enabled"}),u.jsx(AA,{enabled:c.enabled,onChange:h=>p("enabled",h)})]})]}),u.jsx("div",{style:{borderTop:"1px solid #45475a",paddingTop:12,marginTop:4},children:u.jsx(rV,{overrides:c.overrides,flagType:c.type,onChange:h=>p("overrides",h)})}),u.jsx("div",{style:{borderTop:"1px solid #45475a",paddingTop:12,marginTop:12},children:u.jsx(uV,{rules:c.targeting_rules,flagType:c.type,onChange:h=>p("targeting_rules",h)})}),u.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8,marginTop:16},children:[u.jsx("button",{onClick:o,style:TA,disabled:l,children:"Cancel"}),u.jsx("button",{onClick:()=>a(c),style:Wb,disabled:l||!c.key||!c.name,children:l?"Saving...":"Save"})]})]})})}function gV({flagKey:e,onConfirm:n,onCancel:r}){return u.jsx("div",{onClick:r,style:{position:"fixed",inset:0,background:"rgba(0,0,0,0.6)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},children:u.jsxs("div",{onClick:a=>a.stopPropagation(),style:{background:"#1e1e2e",border:"1px solid #45475a",borderRadius:12,padding:24,width:"90%",maxWidth:400},children:[u.jsx("h3",{style:{color:"#cdd6f4",margin:"0 0 12px",fontSize:16,fontWeight:600},children:"Delete Flag"}),u.jsxs("p",{style:{color:"#a6adc8",fontSize:13,lineHeight:1.5,marginBottom:16},children:["Are you sure you want to delete ",u.jsx("strong",{style:{color:"#cdd6f4"},children:e}),"? This action cannot be undone."]}),u.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8},children:[u.jsx("button",{onClick:r,style:TA,children:"Cancel"}),u.jsx("button",{onClick:n,style:{...Wb,background:"#f38ba8"},children:"Delete"})]})]})})}function yV({flag:e,onToggle:n,onEdit:r,onDelete:a}){return u.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,padding:"12px 16px",background:"#313244",borderRadius:8,border:"1px solid #45475a",transition:"border-color 0.15s"},onMouseEnter:o=>o.currentTarget.style.borderColor="#89b4fa",onMouseLeave:o=>o.currentTarget.style.borderColor="#45475a",children:[u.jsx(AA,{enabled:e.enabled,onChange:o=>n(e.key,o)}),u.jsxs("div",{style:{flex:1,minWidth:0},children:[u.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:2},children:[u.jsx("span",{style:{color:"#cdd6f4",fontWeight:600,fontSize:14},children:e.name}),u.jsx(dV,{type:e.type}),e.scope&&e.scope!=="global"&&u.jsx("span",{style:{fontSize:10,color:"#6c7086",padding:"1px 5px",background:"#45475a",borderRadius:3},children:e.scope})]}),u.jsx("div",{style:{fontSize:11,color:"#6c7086",fontFamily:"monospace"},children:e.key}),e.description&&u.jsx("div",{style:{fontSize:12,color:"#a6adc8",marginTop:2,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.description}),e.tags&&e.tags.length>0&&u.jsx("div",{style:{display:"flex",gap:4,marginTop:4},children:e.tags.map(o=>u.jsx("span",{style:{padding:"1px 5px",borderRadius:3,fontSize:10,background:"#89b4fa22",color:"#89b4fa"},children:o},o))})]}),u.jsxs("div",{style:{textAlign:"right",flexShrink:0,minWidth:80},children:[u.jsx("div",{style:{fontSize:11,color:"#6c7086"},children:"Value"}),u.jsx("div",{style:{fontSize:13,color:"#f9e2af",fontFamily:"monospace"},children:RA(e.default_value)})]}),u.jsxs("div",{style:{display:"flex",gap:4,flexShrink:0},children:[u.jsx("button",{onClick:()=>r(e),style:J0,children:"Edit"}),u.jsx("button",{onClick:()=>a(e),style:{...J0,color:"#f38ba8",borderColor:"#f38ba844"},children:"Delete"})]})]})}function mV(){const e=En(B=>B.flags),n=En(B=>B.loading),r=En(B=>B.error),a=En(B=>B.sseConnected),o=En(B=>B.fetchFlags),l=En(B=>B.createFlag),c=En(B=>B.updateFlag),d=En(B=>B.deleteFlag),p=En(B=>B.connectSSE),h=En(B=>B.disconnectSSE),[g,y]=N.useState(!1),[m,b]=N.useState(null),[S,w]=N.useState(null),[C,_]=N.useState(!1),[j,k]=N.useState(""),[T,E]=N.useState(""),[z,A]=N.useState("");N.useEffect(()=>(o(),p(),()=>h()),[]);const M=N.useCallback(async B=>{_(!0);try{const D={key:B.key,name:B.name,description:B.description||void 0,type:B.type,enabled:B.enabled,default_value:ST(B.default_value,B.type),tags:B.tags?B.tags.split(",").map(q=>q.trim()).filter(Boolean):void 0,scope:B.scope||void 0};await l(D),(B.overrides.length>0||B.targeting_rules.length>0)&&await c(B.key,{overrides:B.overrides,targeting_rules:B.targeting_rules}),y(!1)}catch{}finally{_(!1)}},[l,c]),O=N.useCallback(async B=>{if(m){_(!0);try{await c(m.key,{name:B.name,description:B.description,enabled:B.enabled,default_value:ST(B.default_value,B.type),tags:B.tags?B.tags.split(",").map(D=>D.trim()).filter(Boolean):[],scope:B.scope,overrides:B.overrides,targeting_rules:B.targeting_rules}),b(null)}catch{}finally{_(!1)}}},[m,c]),P=N.useCallback(async()=>{if(S)try{await d(S.key),w(null)}catch{}},[S,d]),L=N.useCallback(async(B,D)=>{try{await c(B,{enabled:D})}catch{}},[c]),I=Array.from(new Set(e.flatMap(B=>B.tags||[]))).sort(),F=Array.from(new Set(e.map(B=>B.scope||"global").filter(Boolean))).sort(),U=e.filter(B=>{if(j){const D=j.toLowerCase(),q=B.name.toLowerCase().includes(D),$=B.key.toLowerCase().includes(D),K=(B.description||"").toLowerCase().includes(D);if(!q&&!$&&!K)return!1}return!(T&&!(B.tags||[]).includes(T)||z&&(B.scope||"global")!==z)});return u.jsxs("div",{style:{flex:1,background:"#1e1e2e",overflow:"auto",padding:24},children:[u.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",marginBottom:20},children:[u.jsxs("div",{children:[u.jsx("h2",{style:{color:"#cdd6f4",margin:"0 0 4px",fontSize:20,fontWeight:600},children:"Feature Flags"}),u.jsxs("p",{style:{color:"#6c7086",fontSize:13,margin:0},children:["Manage feature flags, targeting rules, and overrides.",a&&u.jsx("span",{style:{marginLeft:8,fontSize:11,color:"#a6e3a1"},children:"(live)"})]})]}),u.jsx("button",{onClick:()=>y(!0),style:Wb,children:"+ Create Flag"})]}),r&&u.jsx(fV,{message:r,onDismiss:()=>En.setState({error:null})}),u.jsxs("div",{style:{display:"flex",gap:8,marginBottom:16,alignItems:"center"},children:[u.jsx("input",{value:j,onChange:B=>k(B.target.value),placeholder:"Search flags...",style:{...jn,width:240,marginBottom:0}}),I.length>0&&u.jsxs("select",{value:T,onChange:B=>E(B.target.value),style:{...jn,width:140,marginBottom:0},children:[u.jsx("option",{value:"",children:"All Tags"}),I.map(B=>u.jsx("option",{value:B,children:B},B))]}),F.length>1&&u.jsxs("select",{value:z,onChange:B=>A(B.target.value),style:{...jn,width:140,marginBottom:0},children:[u.jsx("option",{value:"",children:"All Scopes"}),F.map(B=>u.jsx("option",{value:B,children:B},B))]}),u.jsx("button",{onClick:()=>o(),style:J0,children:"Refresh"}),u.jsxs("span",{style:{fontSize:12,color:"#6c7086",marginLeft:8},children:[U.length," flag",U.length!==1?"s":""]})]}),n&&e.length===0?u.jsx("div",{style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",color:"#a6adc8",fontSize:14,padding:40},children:"Loading flags..."}):U.length===0?u.jsx("div",{style:{color:"#6c7086",fontSize:14,textAlign:"center",padding:40,background:"#313244",borderRadius:8},children:e.length===0?"No feature flags yet. Create one to get started.":"No flags match the current filters."}):u.jsx("div",{style:{display:"flex",flexDirection:"column",gap:8},children:U.map(B=>u.jsx(yV,{flag:B,onToggle:L,onEdit:b,onDelete:w},B.key))}),g&&u.jsx(wT,{initial:pV(),title:"Create Feature Flag",isEdit:!1,onSave:M,onCancel:()=>y(!1),saving:C}),m&&u.jsx(wT,{initial:hV(m),title:`Edit: ${m.name}`,isEdit:!0,onSave:O,onCancel:()=>b(null),saving:C}),S&&u.jsx(gV,{flagKey:S.key,onConfirm:P,onCancel:()=>w(null)})]})}const vV="/api/v1";function bV(){const e={"Content-Type":"application/json"},n=localStorage.getItem("auth_token");return n&&(e.Authorization=`Bearer ${n}`),e}async function oi(e,n){const r=await fetch(`${vV}/admin/plugins/store-browser${e}`,{...n,headers:{...bV(),...n?.headers}});if(!r.ok){const a=await r.text().catch(()=>r.statusText);throw new Error(`API ${r.status}: ${a}`)}if(r.status!==204)return r.json()}const xV=50;function SV(){try{const e=localStorage.getItem("store_browser_sql_history");if(e)return JSON.parse(e)}catch{}return[]}function wV(e){try{localStorage.setItem("store_browser_sql_history",JSON.stringify(e.slice(-50)))}catch{}}const hl=Mn((e,n)=>({activeTab:"tables",setActiveTab:r=>e({activeTab:r}),tables:[],selectedTable:null,tableSchema:[],tableRows:[],tablePage:1,tableTotal:0,tableLoading:!1,fetchTables:async()=>{e({tableLoading:!0});try{const r=await oi("/tables");e({tables:r.tables||[],tableLoading:!1})}catch{e({tables:[],tableLoading:!1})}},selectTable:async r=>{e({selectedTable:r,tableSchema:[],tableRows:[],tablePage:1,tableTotal:0,tableLoading:!0});try{const a=await oi(`/tables/${encodeURIComponent(r)}/schema`);e({tableSchema:a.columns||[]})}catch{e({tableSchema:[]})}await n().fetchTableRows(1)},fetchTableRows:async r=>{const a=n().selectedTable;if(!a)return;const o=r??n().tablePage;e({tableLoading:!0,tablePage:o});try{const l=await oi(`/tables/${encodeURIComponent(a)}/rows?page=${o}&page_size=${xV}`);e({tableRows:l.rows||[],tableTotal:l.total||0,tableLoading:!1})}catch{e({tableRows:[],tableLoading:!1})}},events:[],eventFilters:{},eventsLoading:!1,fetchEvents:async()=>{e({eventsLoading:!0});try{const r=new URLSearchParams,{eventFilters:a}=n();a.execution_id&&r.set("execution_id",a.execution_id),a.event_type&&r.set("event_type",a.event_type);const o=r.toString(),l=await oi(`/events${o?"?"+o:""}`);e({events:l.events||[],eventsLoading:!1})}catch{e({events:[],eventsLoading:!1})}},setEventFilter:(r,a)=>{e({eventFilters:{...n().eventFilters,[r]:a||void 0}})},dlqEntries:[],dlqFilters:{},dlqLoading:!1,fetchDLQ:async()=>{e({dlqLoading:!0});try{const r=new URLSearchParams,{dlqFilters:a}=n();a.status&&r.set("status",a.status),a.pipeline&&r.set("pipeline",a.pipeline);const o=r.toString(),l=await oi(`/dlq${o?"?"+o:""}`);e({dlqEntries:l.entries||[],dlqLoading:!1})}catch{e({dlqEntries:[],dlqLoading:!1})}},setDLQFilter:(r,a)=>{e({dlqFilters:{...n().dlqFilters,[r]:a||void 0}})},retryDLQ:async r=>{await oi(`/dlq/${encodeURIComponent(r)}/retry`,{method:"POST"}),await n().fetchDLQ()},discardDLQ:async r=>{await oi(`/dlq/${encodeURIComponent(r)}/discard`,{method:"POST"}),await n().fetchDLQ()},sqlQuery:"",sqlResults:null,sqlError:null,sqlHistory:SV(),sqlLoading:!1,setSqlQuery:r=>e({sqlQuery:r}),executeSql:async()=>{const r=n().sqlQuery.trim();if(r){e({sqlLoading:!0,sqlError:null,sqlResults:null});try{const a=await oi("/query",{method:"POST",body:JSON.stringify({query:r})}),o=[...n().sqlHistory.filter(l=>l!==r),r];wV(o),e({sqlResults:a,sqlLoading:!1,sqlHistory:o})}catch(a){e({sqlError:a instanceof Error?a.message:String(a),sqlLoading:!1})}}}})),_T={padding:"6px 12px",textAlign:"left",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",maxWidth:300,borderBottom:"1px solid #313244"};function Gb({columns:e,rows:n,loading:r,page:a,total:o,pageSize:l=50,onPageChange:c,onRowClick:d,selectedRowIndex:p}){const h=o!=null?Math.max(1,Math.ceil(o/l)):void 0;return u.jsxs("div",{style:{display:"flex",flexDirection:"column",flex:1,minHeight:0},children:[u.jsx("div",{style:{flex:1,overflow:"auto"},children:u.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12,fontFamily:"monospace"},children:[u.jsx("thead",{children:u.jsx("tr",{children:e.map(g=>u.jsx("th",{style:{..._T,position:"sticky",top:0,background:"#181825",color:"#89b4fa",fontWeight:600,fontSize:11,textTransform:"uppercase",letterSpacing:"0.5px",zIndex:1},children:g},g))})}),u.jsxs("tbody",{children:[r&&n.length===0&&u.jsx("tr",{children:u.jsx("td",{colSpan:e.length,style:{padding:24,textAlign:"center",color:"#6c7086"},children:"Loading..."})}),!r&&n.length===0&&u.jsx("tr",{children:u.jsx("td",{colSpan:e.length,style:{padding:24,textAlign:"center",color:"#6c7086"},children:"No data."})}),n.map((g,y)=>u.jsx("tr",{onClick:()=>d?.(g,y),style:{background:p===y?"#313244":y%2===0?"#1e1e2e":"#181825",cursor:d?"pointer":void 0},children:e.map(m=>{const b=g[m],S=b==null?"":typeof b=="object"?JSON.stringify(b):String(b);return u.jsx("td",{style:{..._T,color:"#cdd6f4"},title:S,children:S},m)})},y))]})]})}),h!=null&&h>1&&a!=null&&c&&u.jsxs("div",{style:{padding:"8px 12px",borderTop:"1px solid #313244",display:"flex",alignItems:"center",justifyContent:"space-between",background:"#181825",fontSize:12,color:"#a6adc8",flexShrink:0},children:[u.jsxs("span",{children:["Page ",a," of ",h," (",o," rows)"]}),u.jsxs("div",{style:{display:"flex",gap:4},children:[u.jsx("button",{disabled:a<=1,onClick:()=>c(a-1),style:{background:"#313244",border:"1px solid #45475a",borderRadius:4,color:a<=1?"#45475a":"#cdd6f4",padding:"3px 10px",fontSize:11,cursor:a<=1?"not-allowed":"pointer"},children:"Prev"}),u.jsx("button",{disabled:a>=h,onClick:()=>c(a+1),style:{background:"#313244",border:"1px solid #45475a",borderRadius:4,color:a>=h?"#45475a":"#cdd6f4",padding:"3px 10px",fontSize:11,cursor:a>=h?"not-allowed":"pointer"},children:"Next"})]})]})]})}function _V(){const{tables:e,selectedTable:n,tableSchema:r,tableRows:a,tablePage:o,tableTotal:l,tableLoading:c,fetchTables:d,selectTable:p,fetchTableRows:h}=hl();N.useEffect(()=>{d()},[d]);const g=r.length>0?r.map(y=>y.name):a.length>0?Object.keys(a[0]):[];return u.jsxs("div",{style:{display:"flex",flex:1,minHeight:0},children:[u.jsxs("div",{style:{width:200,borderRight:"1px solid #313244",background:"#181825",overflow:"auto",flexShrink:0},children:[u.jsxs("div",{style:{padding:"10px 12px",fontSize:11,color:"#6c7086",textTransform:"uppercase",letterSpacing:"0.5px",fontWeight:600},children:["Tables (",e.length,")"]}),e.map(y=>u.jsx("div",{onClick:()=>p(y),style:{padding:"6px 12px",fontSize:12,color:n===y?"#89b4fa":"#cdd6f4",background:n===y?"#313244":"transparent",cursor:"pointer",borderLeft:n===y?"2px solid #89b4fa":"2px solid transparent",fontFamily:"monospace"},children:y},y)),e.length===0&&!c&&u.jsx("div",{style:{padding:"12px",color:"#6c7086",fontSize:12},children:"No tables found."})]}),u.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",minWidth:0},children:[!n&&u.jsx("div",{style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",color:"#6c7086",fontSize:13},children:"Select a table to browse its contents."}),n&&u.jsxs(u.Fragment,{children:[r.length>0&&u.jsx("div",{style:{padding:"8px 12px",borderBottom:"1px solid #313244",background:"#181825",display:"flex",gap:12,flexWrap:"wrap",fontSize:11},children:r.map(y=>u.jsxs("span",{style:{color:"#a6adc8"},children:[u.jsx("span",{style:{color:"#cdd6f4",fontWeight:600,fontFamily:"monospace"},children:y.name}),u.jsx("span",{style:{color:"#6c7086",marginLeft:4},children:y.type}),y.pk&&u.jsx("span",{style:{marginLeft:4,color:"#f9e2af",fontSize:9,fontWeight:600},children:"PK"}),y.notnull&&u.jsx("span",{style:{marginLeft:4,color:"#f38ba8",fontSize:9,fontWeight:600},children:"NOT NULL"})]},y.name))}),u.jsx(Gb,{columns:g,rows:a,loading:c,page:o,total:l,pageSize:50,onPageChange:y=>h(y)})]})]})]})}const kT={background:"#313244",border:"1px solid #45475a",borderRadius:4,color:"#cdd6f4",padding:"4px 8px",fontSize:12,outline:"none"},kV=["","workflow.started","workflow.completed","workflow.failed","step.started","step.completed","step.failed"];function CV(){const{events:e,eventFilters:n,eventsLoading:r,fetchEvents:a,setEventFilter:o}=hl(),[l,c]=N.useState(null);N.useEffect(()=>{a()},[a]);const d=()=>{a()},p=["id","execution_id","event_type","created_at"],h=e.map(g=>({id:g.id,execution_id:g.execution_id,event_type:g.event_type,created_at:g.created_at,_event_data:g.event_data}));return u.jsxs("div",{style:{display:"flex",flexDirection:"column",flex:1,minHeight:0},children:[u.jsxs("div",{style:{padding:"8px 12px",borderBottom:"1px solid #313244",background:"#181825",display:"flex",alignItems:"center",gap:8,flexShrink:0},children:[u.jsx("span",{style:{color:"#6c7086",fontSize:11,fontWeight:600},children:"Filters:"}),u.jsx("input",{type:"text",placeholder:"Execution ID",value:n.execution_id||"",onChange:g=>o("execution_id",g.target.value),style:{...kT,width:200}}),u.jsxs("select",{value:n.event_type||"",onChange:g=>o("event_type",g.target.value),style:kT,children:[u.jsx("option",{value:"",children:"All Event Types"}),kV.filter(Boolean).map(g=>u.jsx("option",{value:g,children:g},g))]}),u.jsx("button",{onClick:d,style:{background:"#89b4fa",border:"none",borderRadius:4,color:"#1e1e2e",padding:"5px 12px",fontSize:11,fontWeight:600,cursor:"pointer"},children:"Apply"})]}),u.jsx(Gb,{columns:p,rows:h,loading:r,onRowClick:(g,y)=>c(l===y?null:y),selectedRowIndex:l??void 0}),l!=null&&h[l]&&u.jsxs("div",{style:{borderTop:"1px solid #313244",background:"#181825",padding:12,maxHeight:200,overflow:"auto",flexShrink:0},children:[u.jsx("div",{style:{fontSize:11,color:"#6c7086",marginBottom:6,fontWeight:600,textTransform:"uppercase"},children:"Event Data"}),u.jsx("pre",{style:{margin:0,fontFamily:"monospace",fontSize:12,color:"#cdd6f4",whiteSpace:"pre-wrap",wordBreak:"break-word"},children:JSON.stringify(h[l]._event_data,null,2)})]})]})}const CT={background:"#313244",border:"1px solid #45475a",borderRadius:4,color:"#cdd6f4",padding:"4px 8px",fontSize:12,outline:"none"},EV={pending:"#f9e2af",retrying:"#89b4fa",resolved:"#a6e3a1",discarded:"#6c7086"},jV=["","pending","retrying","resolved","discarded"];function TV(){const{dlqEntries:e,dlqFilters:n,dlqLoading:r,fetchDLQ:a,setDLQFilter:o,retryDLQ:l,discardDLQ:c}=hl();N.useEffect(()=>{a()},[a]);const d=()=>{a()},p=["id","pipeline_name","step_name","error_message","status","retry_count","created_at","actions"],h=e.map(g=>({id:g.id,pipeline_name:g.pipeline_name,step_name:g.step_name,error_message:g.error_message,status:g.status,retry_count:g.retry_count,created_at:g.created_at,actions:g.status,_raw:g}));return u.jsxs("div",{style:{display:"flex",flexDirection:"column",flex:1,minHeight:0},children:[u.jsxs("div",{style:{padding:"8px 12px",borderBottom:"1px solid #313244",background:"#181825",display:"flex",alignItems:"center",gap:8,flexShrink:0},children:[u.jsx("span",{style:{color:"#6c7086",fontSize:11,fontWeight:600},children:"Filters:"}),u.jsxs("select",{value:n.status||"",onChange:g=>o("status",g.target.value),style:CT,children:[u.jsx("option",{value:"",children:"All Statuses"}),jV.filter(Boolean).map(g=>u.jsx("option",{value:g,children:g},g))]}),u.jsx("input",{type:"text",placeholder:"Pipeline name",value:n.pipeline||"",onChange:g=>o("pipeline",g.target.value),style:{...CT,width:180}}),u.jsx("button",{onClick:d,style:{background:"#89b4fa",border:"none",borderRadius:4,color:"#1e1e2e",padding:"5px 12px",fontSize:11,fontWeight:600,cursor:"pointer"},children:"Apply"})]}),u.jsx("div",{style:{flex:1,overflow:"auto"},children:u.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12,fontFamily:"monospace"},children:[u.jsx("thead",{children:u.jsx("tr",{children:p.map(g=>u.jsx("th",{style:{padding:"6px 12px",textAlign:"left",position:"sticky",top:0,background:"#181825",color:"#89b4fa",fontWeight:600,fontSize:11,textTransform:"uppercase",letterSpacing:"0.5px",borderBottom:"1px solid #313244",zIndex:1},children:g==="actions"?"":g},g))})}),u.jsxs("tbody",{children:[r&&h.length===0&&u.jsx("tr",{children:u.jsx("td",{colSpan:p.length,style:{padding:24,textAlign:"center",color:"#6c7086"},children:"Loading..."})}),!r&&h.length===0&&u.jsx("tr",{children:u.jsx("td",{colSpan:p.length,style:{padding:24,textAlign:"center",color:"#6c7086"},children:"No DLQ entries."})}),h.map((g,y)=>u.jsx("tr",{style:{background:y%2===0?"#1e1e2e":"#181825"},children:p.map(m=>{if(m==="status"){const w=EV[g.status]||"#a6adc8";return u.jsx("td",{style:{padding:"6px 12px",borderBottom:"1px solid #313244"},children:u.jsx("span",{style:{display:"inline-block",padding:"2px 8px",borderRadius:10,fontSize:10,fontWeight:600,color:w,background:w+"22",border:`1px solid ${w}44`},children:g.status})},m)}if(m==="actions"){const w=g.status==="pending";return u.jsx("td",{style:{padding:"6px 12px",borderBottom:"1px solid #313244"},children:w&&u.jsxs("div",{style:{display:"flex",gap:4},children:[u.jsx("button",{onClick:()=>l(g.id),style:{background:"#89b4fa22",border:"1px solid #89b4fa44",borderRadius:4,color:"#89b4fa",padding:"2px 8px",fontSize:10,fontWeight:600,cursor:"pointer"},children:"Retry"}),u.jsx("button",{onClick:()=>c(g.id),style:{background:"#f38ba822",border:"1px solid #f38ba844",borderRadius:4,color:"#f38ba8",padding:"2px 8px",fontSize:10,fontWeight:600,cursor:"pointer"},children:"Discard"})]})},m)}const b=g[m],S=b==null?"":String(b);return u.jsx("td",{style:{padding:"6px 12px",color:"#cdd6f4",borderBottom:"1px solid #313244",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",maxWidth:250},title:S,children:S},m)})},g.id))]})]})})]})}function AV(){const{sqlQuery:e,sqlResults:n,sqlError:r,sqlHistory:a,sqlLoading:o,setSqlQuery:l,executeSql:c}=hl(),[d,p]=N.useState(!1),h=N.useCallback(b=>{(b.ctrlKey||b.metaKey)&&b.key==="Enter"&&(b.preventDefault(),c())},[c]),g=N.useCallback(b=>{l(b),p(!1)},[l]),y=n?.rows||[],m=n?.columns?.length?n.columns:y.length>0?Object.keys(y[0]):[];return u.jsxs("div",{style:{display:"flex",flex:1,minHeight:0},children:[u.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",minWidth:0},children:[u.jsxs("div",{style:{padding:12,borderBottom:"1px solid #313244",background:"#181825",flexShrink:0},children:[u.jsx("textarea",{value:e,onChange:b=>l(b.target.value),onKeyDown:h,placeholder:"SELECT * FROM ...",spellCheck:!1,style:{width:"100%",minHeight:80,maxHeight:200,background:"#11111b",border:"1px solid #313244",borderRadius:4,color:"#cdd6f4",fontFamily:"monospace",fontSize:13,padding:10,outline:"none",resize:"vertical",boxSizing:"border-box"}}),u.jsxs("div",{style:{display:"flex",gap:8,marginTop:8,alignItems:"center"},children:[u.jsx("button",{onClick:c,disabled:o||!e.trim(),style:{background:"#89b4fa",border:"none",borderRadius:4,color:"#1e1e2e",padding:"6px 16px",fontSize:12,fontWeight:600,cursor:o||!e.trim()?"not-allowed":"pointer",opacity:o||!e.trim()?.5:1},children:o?"Executing...":"Execute"}),u.jsx("span",{style:{color:"#6c7086",fontSize:11},children:"Ctrl+Enter to run"}),u.jsxs("button",{onClick:()=>p(!d),style:{marginLeft:"auto",background:"#313244",border:"1px solid #45475a",borderRadius:4,color:d?"#89b4fa":"#a6adc8",padding:"4px 10px",fontSize:11,cursor:"pointer"},children:["History (",a.length,")"]})]})]}),r&&u.jsx("div",{style:{padding:"8px 12px",background:"#f38ba811",borderBottom:"1px solid #f38ba844",color:"#f38ba8",fontSize:12,fontFamily:"monospace",flexShrink:0},children:r}),n&&u.jsx(Gb,{columns:m,rows:y,loading:o}),!n&&!r&&u.jsx("div",{style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",color:"#6c7086",fontSize:13},children:"Enter a SQL query and press Execute."})]}),d&&u.jsxs("div",{style:{width:260,borderLeft:"1px solid #313244",background:"#181825",overflow:"auto",flexShrink:0},children:[u.jsx("div",{style:{padding:"10px 12px",fontSize:11,color:"#6c7086",textTransform:"uppercase",letterSpacing:"0.5px",fontWeight:600,borderBottom:"1px solid #313244"},children:"Query History"}),a.length===0&&u.jsx("div",{style:{padding:12,color:"#6c7086",fontSize:12},children:"No history yet."}),[...a].reverse().map((b,S)=>u.jsx("div",{onClick:()=>g(b),style:{padding:"8px 12px",borderBottom:"1px solid #313244",cursor:"pointer",fontSize:11,fontFamily:"monospace",color:"#cdd6f4",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},title:b,children:b},S))]})]})}const RV=[{key:"tables",label:"Tables"},{key:"events",label:"Events"},{key:"dlq",label:"DLQ"},{key:"sql",label:"SQL Console"}];function zV(){const{activeTab:e,setActiveTab:n}=hl();return u.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",background:"#1e1e2e",overflow:"hidden"},children:[u.jsx("div",{style:{display:"flex",borderBottom:"1px solid #313244",background:"#181825",flexShrink:0},children:RV.map(r=>u.jsx("button",{onClick:()=>n(r.key),style:{padding:"10px 20px",background:"transparent",border:"none",borderBottom:e===r.key?"2px solid #89b4fa":"2px solid transparent",color:e===r.key?"#89b4fa":"#a6adc8",fontSize:13,fontWeight:e===r.key?600:400,cursor:"pointer"},children:r.label},r.key))}),e==="tables"&&u.jsx(_V,{}),e==="events"&&u.jsx(CV,{}),e==="dlq"&&u.jsx(TV,{}),e==="sql"&&u.jsx(AV,{})]})}const NV="/api/v1";function MV(){const e={"Content-Type":"application/json"},n=localStorage.getItem("auth_token");return n&&(e.Authorization=`Bearer ${n}`),e}async function si(e,n){const r=await fetch(`${NV}${e}`,{...n,headers:{...MV(),...n?.headers}});if(!r.ok){const a=await r.text().catch(()=>r.statusText);throw new Error(`API ${r.status}: ${a}`)}if(r.status!==204)return r.json()}function OV(e){const n=[];for(const r of e){const a=r.split("/");let o=n,l="";for(const c of a){l=l?`${l}/${c}`:c;let d=o.find(p=>p.name===c);d||(d={name:c,fullPath:l,children:[]},o.push(d)),o=d.children}}return n}const li="/admin/plugins/doc-manager",dt=Mn((e,n)=>({docs:[],selectedDoc:null,categories:[],loading:!1,filters:{},editorContent:"",editorDirty:!1,setFilter:(r,a)=>{e(o=>({filters:{...o.filters,[r]:a||void 0}}))},fetchDocs:async()=>{e({loading:!0});try{const{filters:r}=n(),a=new URLSearchParams;r.workflow_id&&a.set("workflow_id",r.workflow_id),r.category&&a.set("category",r.category),r.search&&a.set("search",r.search);const o=a.toString(),l=await si(`${li}/docs${o?"?"+o:""}`);e({docs:l,loading:!1})}catch{e({docs:[],loading:!1})}},fetchDoc:async r=>{try{const a=await si(`${li}/docs/${encodeURIComponent(r)}`);e({selectedDoc:a,editorContent:a.content,editorDirty:!1})}catch{}},createDoc:async r=>{await si(`${li}/docs`,{method:"POST",body:JSON.stringify(r)}),await n().fetchDocs()},updateDoc:async(r,a)=>{const o=await si(`${li}/docs/${encodeURIComponent(r)}`,{method:"PUT",body:JSON.stringify(a)});e({selectedDoc:o,editorContent:o.content,editorDirty:!1}),await n().fetchDocs()},deleteDoc:async r=>{await si(`${li}/docs/${encodeURIComponent(r)}`,{method:"DELETE"});const{selectedDoc:a}=n();a?.id===r&&e({selectedDoc:null,editorContent:"",editorDirty:!1}),await n().fetchDocs()},fetchCategories:async()=>{try{const r=await si(`${li}/categories`);e({categories:r})}catch{e({categories:[]})}},createCategory:async r=>{await si(`${li}/categories`,{method:"POST",body:JSON.stringify({name:r})}),await n().fetchCategories()},deleteCategory:async r=>{await si(`${li}/categories/${encodeURIComponent(r)}`,{method:"DELETE"}),await n().fetchCategories()},setEditorContent:r=>{const{selectedDoc:a}=n();e({editorContent:r,editorDirty:a?r!==a.content:r!==""})},selectDoc:r=>{e({selectedDoc:r,editorContent:r?.content??"",editorDirty:!1})}}));function DV(e,n){return e.filter(r=>r.category===n||r.category.startsWith(n+"/")).length}function zA({node:e,docs:n,selectedCategory:r,onSelect:a,depth:o}){const[l,c]=N.useState(!0),d=e.children.length>0,p=r===e.fullPath,h=DV(n,e.fullPath);return u.jsxs("div",{children:[u.jsxs("div",{onClick:()=>a(e.fullPath),style:{display:"flex",alignItems:"center",gap:4,padding:"4px 8px",paddingLeft:8+o*14,cursor:"pointer",background:p?"#313244":"transparent",borderLeft:p?"2px solid #89b4fa":"2px solid transparent",fontSize:12,color:p?"#cdd6f4":"#a6adc8",fontWeight:p?600:400,transition:"background 0.1s"},onMouseEnter:g=>{p||(g.currentTarget.style.background="#1e1e2e")},onMouseLeave:g=>{p||(g.currentTarget.style.background="transparent")},children:[d&&u.jsx("span",{onClick:g=>{g.stopPropagation(),c(!l)},style:{display:"inline-flex",width:14,justifyContent:"center",color:"#6c7086",fontSize:10,flexShrink:0,cursor:"pointer"},children:l?"▼":"▶"}),!d&&u.jsx("span",{style:{width:14,flexShrink:0}}),u.jsx("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.name}),h>0&&u.jsx("span",{style:{color:"#6c7086",fontSize:10,flexShrink:0},children:h})]}),d&&l&&u.jsx("div",{children:e.children.map(g=>u.jsx(zA,{node:g,docs:n,selectedCategory:r,onSelect:a,depth:o+1},g.fullPath))})]})}function qV({tree:e,docs:n,selectedCategory:r,onSelect:a}){return u.jsxs("div",{style:{fontSize:12},children:[u.jsxs("div",{onClick:()=>a(""),style:{display:"flex",alignItems:"center",gap:4,padding:"4px 8px",cursor:"pointer",background:r===""?"#313244":"transparent",borderLeft:r===""?"2px solid #89b4fa":"2px solid transparent",color:r===""?"#cdd6f4":"#a6adc8",fontWeight:r===""?600:400,transition:"background 0.1s"},onMouseEnter:o=>{r!==""&&(o.currentTarget.style.background="#1e1e2e")},onMouseLeave:o=>{r!==""&&(o.currentTarget.style.background="transparent")},children:[u.jsx("span",{style:{width:14,flexShrink:0}}),u.jsx("span",{style:{flex:1},children:"All categories"}),u.jsx("span",{style:{color:"#6c7086",fontSize:10},children:n.length})]}),e.map(o=>u.jsx(zA,{node:o,docs:n,selectedCategory:r,onSelect:a,depth:0},o.fullPath))]})}const NA={width:"100%",background:"#313244",border:"1px solid #45475a",borderRadius:6,color:"#cdd6f4",padding:"8px 10px",fontSize:13,outline:"none",boxSizing:"border-box"},IV={...NA,appearance:"auto"};function LV(e){try{return new Date(e).toLocaleDateString(void 0,{month:"short",day:"numeric",year:"numeric"})}catch{return e}}function BV({onNew:e}){const n=dt(_=>_.docs),r=dt(_=>_.selectedDoc),a=dt(_=>_.loading),o=dt(_=>_.filters),l=dt(_=>_.categories),c=dt(_=>_.setFilter),d=dt(_=>_.fetchDocs),p=dt(_=>_.fetchCategories),h=dt(_=>_.fetchDoc),[g,y]=N.useState([]);N.useEffect(()=>{d(),p(),$b().then(y).catch(()=>y([]))},[d,p]),N.useEffect(()=>{d()},[o,d]);const m=N.useMemo(()=>OV(l),[l]),b=_=>{c("search",_)},S=_=>{c("category",_)},w=_=>{c("workflow_id",_)},C=_=>{h(_.id)};return u.jsxs("div",{style:{width:250,minWidth:250,background:"#181825",borderRight:"1px solid #313244",display:"flex",flexDirection:"column",height:"100%",overflow:"hidden"},children:[u.jsxs("div",{style:{padding:"12px 12px 8px"},children:[u.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:10},children:[u.jsx("span",{style:{color:"#cdd6f4",fontSize:14,fontWeight:600},children:"Documents"}),u.jsx("button",{onClick:e,style:{background:"#89b4fa",border:"none",borderRadius:6,color:"#1e1e2e",padding:"5px 12px",fontSize:12,fontWeight:600,cursor:"pointer"},children:"+ New"})]}),u.jsx("input",{type:"text",placeholder:"Search docs...",value:o.search??"",onChange:_=>b(_.target.value),style:{...NA,marginBottom:6}}),u.jsxs("select",{value:o.workflow_id??"",onChange:_=>w(_.target.value),style:{...IV,marginBottom:6},children:[u.jsx("option",{value:"",children:"All workflows"}),g.map(_=>u.jsx("option",{value:_.id,children:_.name},_.id))]})]}),u.jsxs("div",{style:{borderTop:"1px solid #313244",padding:"6px 0"},children:[u.jsx("div",{style:{padding:"2px 12px 4px",color:"#6c7086",fontSize:10,fontWeight:600,textTransform:"uppercase",letterSpacing:.5},children:"Categories"}),u.jsx(qV,{tree:m,docs:n,selectedCategory:o.category??"",onSelect:S})]}),u.jsx("div",{style:{flex:1,overflowY:"auto",padding:"4px 0",borderTop:"1px solid #313244"},children:a?u.jsx("div",{style:{color:"#6c7086",fontSize:12,padding:16,textAlign:"center"},children:"Loading..."}):n.length===0?u.jsx("div",{style:{color:"#6c7086",fontSize:12,padding:16,textAlign:"center"},children:"No documents found."}):n.map(_=>{const j=r?.id===_.id;return u.jsxs("div",{onClick:()=>C(_),style:{padding:"10px 12px",cursor:"pointer",background:j?"#313244":"transparent",borderLeft:j?"3px solid #89b4fa":"3px solid transparent",transition:"background 0.15s"},onMouseEnter:k=>{j||(k.currentTarget.style.background="#1e1e2e")},onMouseLeave:k=>{j||(k.currentTarget.style.background="transparent")},children:[u.jsx("div",{style:{color:j?"#cdd6f4":"#a6adc8",fontSize:13,fontWeight:j?600:400,marginBottom:4,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:_.title}),u.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[_.category&&u.jsx("span",{style:{background:"#45475a",color:"#89b4fa",fontSize:10,padding:"1px 6px",borderRadius:3,fontWeight:500},children:_.category}),u.jsx("span",{style:{color:"#6c7086",fontSize:10},children:LV(_.updated_at)})]})]},_.id)})})]})}function HV(e){let n=e.replace(/&/g,"&").replace(//g,">");n=n.replace(/```(\w*)\n([\s\S]*?)```/g,(l,c,d)=>`
${d.trim()}
`);const r=n.split(` +`),a=[];let o=!1;for(let l=0;l")){o&&(a.push(""),o=!1),a.push(c);continue}if(c.startsWith("### ")){o&&(a.push(""),o=!1),a.push(`

${Cs(c.slice(4))}

`);continue}if(c.startsWith("## ")){o&&(a.push(""),o=!1),a.push(`

${Cs(c.slice(3))}

`);continue}if(c.startsWith("# ")){o&&(a.push(""),o=!1),a.push(`

${Cs(c.slice(2))}

`);continue}if(c.match(/^[-*] /)){o||(a.push('
    '),o=!0),a.push(`
  • ${Cs(c.slice(2))}
  • `);continue}if(o&&(a.push("
"),o=!1),c.trim()===""){a.push("
");continue}a.push(`

${Cs(c)}

`)}return o&&a.push(""),a.join(` +`)}function Cs(e){let n=e.replace(/`([^`]+)`/g,'$1');return n=n.replace(/\*\*([^*]+)\*\*/g,'$1'),n=n.replace(/\*([^*]+)\*/g,"$1"),n=n.replace(/\[([^\]]+)\]\(([^)]+)\)/g,'$1'),n}const ET={background:"#313244",border:"1px solid #45475a",borderRadius:6,color:"#cdd6f4",padding:"8px 10px",fontSize:13,outline:"none",boxSizing:"border-box"};function jT({isNew:e,onCancel:n}){const r=dt(E=>E.selectedDoc),a=dt(E=>E.editorContent),o=dt(E=>E.editorDirty),l=dt(E=>E.setEditorContent),c=dt(E=>E.createDoc),d=dt(E=>E.updateDoc),p=dt(E=>E.categories),[h,g]=N.useState(e?"":r?.title??""),[y,m]=N.useState(e?"":r?.category??""),[b,S]=N.useState(!1),[w,C]=N.useState(null);N.useEffect(()=>{!e&&r&&(g(r.title),m(r.category))},[e,r]);const _=e?h!=="":h!==(r?.title??""),j=e?y!=="":y!==(r?.category??""),k=o||_||j,T=async()=>{if(!h.trim()){C("Title is required");return}C(null),S(!0);try{e?(await c({title:h.trim(),content:a,category:y||void 0}),n()):r&&await d(r.id,{title:h.trim(),content:a,category:y||void 0})}catch(E){C(E instanceof Error?E.message:"Failed to save")}finally{S(!1)}};return u.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",height:"100%",overflow:"hidden"},children:[u.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"10px 16px",borderBottom:"1px solid #313244",background:"#181825",flexShrink:0},children:[u.jsx("input",{type:"text",placeholder:"Document title",value:h,onChange:E=>g(E.target.value),style:{...ET,flex:1}}),u.jsxs("select",{value:y,onChange:E=>m(E.target.value),style:{...ET,width:150},children:[u.jsx("option",{value:"",children:"No category"}),p.map(E=>u.jsx("option",{value:E,children:E},E))]}),k&&u.jsx("span",{style:{color:"#f9e2af",fontSize:11,fontWeight:500},children:"unsaved"}),u.jsx("button",{onClick:T,disabled:b,style:{background:b?"#585b70":"#89b4fa",border:"none",borderRadius:6,color:"#1e1e2e",padding:"7px 16px",fontSize:13,fontWeight:600,cursor:b?"not-allowed":"pointer"},children:b?"Saving...":"Save"}),u.jsx("button",{onClick:n,style:{background:"#313244",border:"1px solid #45475a",borderRadius:6,color:"#cdd6f4",padding:"7px 16px",fontSize:13,cursor:"pointer"},children:"Cancel"})]}),w&&u.jsx("div",{style:{background:"rgba(243, 139, 168, 0.15)",border:"1px solid #f38ba8",borderRadius:0,padding:"6px 16px",color:"#f38ba8",fontSize:12},children:w}),u.jsxs("div",{style:{flex:1,display:"flex",overflow:"hidden"},children:[u.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",borderRight:"1px solid #313244"},children:[u.jsx("div",{style:{padding:"6px 12px",color:"#6c7086",fontSize:11,fontWeight:500,borderBottom:"1px solid #313244"},children:"Markdown"}),u.jsx("textarea",{value:a,onChange:E=>l(E.target.value),placeholder:"Write your markdown content here...",style:{flex:1,background:"#1e1e2e",color:"#cdd6f4",border:"none",outline:"none",padding:16,fontSize:14,fontFamily:"'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace",lineHeight:1.6,resize:"none",boxSizing:"border-box"}})]}),u.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column"},children:[u.jsx("div",{style:{padding:"6px 12px",color:"#6c7086",fontSize:11,fontWeight:500,borderBottom:"1px solid #313244"},children:"Preview"}),u.jsx("div",{style:{flex:1,overflowY:"auto",padding:16,background:"#1e1e2e"},dangerouslySetInnerHTML:{__html:HV(a)}})]})]})]})}function UV(e){let n=(e??"").replace(/&/g,"&").replace(//g,">");n=n.replace(/```(\w*)\n([\s\S]*?)```/g,(l,c,d)=>`
${d.trim()}
`);const r=n.split(` +`),a=[];let o=!1;for(let l=0;l")){o&&(a.push(""),o=!1),a.push(c);continue}if(c.startsWith("### ")){o&&(a.push(""),o=!1),a.push(`

${Es(c.slice(4))}

`);continue}if(c.startsWith("## ")){o&&(a.push(""),o=!1),a.push(`

${Es(c.slice(3))}

`);continue}if(c.startsWith("# ")){o&&(a.push(""),o=!1),a.push(`

${Es(c.slice(2))}

`);continue}if(c.match(/^[-*] /)){o||(a.push('
    '),o=!0),a.push(`
  • ${Es(c.slice(2))}
  • `);continue}if(o&&(a.push("
"),o=!1),c.trim()===""){a.push("
");continue}a.push(`

${Es(c)}

`)}return o&&a.push(""),a.join(` +`)}function Es(e){let n=e.replace(/`([^`]+)`/g,'$1');return n=n.replace(/\*\*([^*]+)\*\*/g,'$1'),n=n.replace(/\*([^*]+)\*/g,"$1"),n=n.replace(/\[([^\]]+)\]\(([^)]+)\)/g,'$1'),n}function TT(e){try{return new Date(e).toLocaleString(void 0,{month:"short",day:"numeric",year:"numeric",hour:"2-digit",minute:"2-digit"})}catch{return e}}function FV({onEdit:e}){const n=dt(p=>p.selectedDoc),r=dt(p=>p.deleteDoc),[a,o]=N.useState(!1),[l,c]=N.useState(!1);if(!n)return null;const d=async()=>{c(!0);try{await r(n.id)}catch{}finally{c(!1),o(!1)}};return u.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",height:"100%",overflow:"hidden"},children:[u.jsxs("div",{style:{padding:"16px 24px",borderBottom:"1px solid #313244",background:"#181825",flexShrink:0},children:[u.jsxs("div",{style:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",gap:12},children:[u.jsxs("div",{style:{flex:1},children:[u.jsx("h1",{style:{color:"#cdd6f4",fontSize:20,fontWeight:600,margin:"0 0 8px"},children:n.title}),u.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,flexWrap:"wrap"},children:[n.category&&u.jsx("span",{style:{background:"#45475a",color:"#89b4fa",fontSize:11,padding:"2px 8px",borderRadius:4,fontWeight:500},children:n.category}),u.jsxs("span",{style:{color:"#6c7086",fontSize:11},children:["Created: ",TT(n.created_at)]}),u.jsxs("span",{style:{color:"#6c7086",fontSize:11},children:["Updated: ",TT(n.updated_at)]})]})]}),u.jsxs("div",{style:{display:"flex",gap:8,flexShrink:0},children:[u.jsx("button",{onClick:e,style:{background:"#89b4fa",border:"none",borderRadius:6,color:"#1e1e2e",padding:"7px 16px",fontSize:13,fontWeight:600,cursor:"pointer"},children:"Edit"}),u.jsx("button",{onClick:()=>o(!0),style:{background:"rgba(243, 139, 168, 0.15)",border:"1px solid #f38ba8",borderRadius:6,color:"#f38ba8",padding:"7px 16px",fontSize:13,cursor:"pointer"},children:"Delete"})]})]}),a&&u.jsxs("div",{style:{marginTop:12,padding:"8px 12px",background:"rgba(243, 139, 168, 0.1)",border:"1px solid #f38ba8",borderRadius:6,display:"flex",alignItems:"center",gap:10,fontSize:12,color:"#f38ba8"},children:[u.jsx("span",{children:"Delete this document?"}),u.jsx("button",{onClick:d,disabled:l,style:{background:"#f38ba8",border:"none",borderRadius:4,color:"#1e1e2e",fontSize:11,fontWeight:600,padding:"4px 12px",cursor:l?"not-allowed":"pointer"},children:l?"Deleting...":"Confirm"}),u.jsx("button",{onClick:()=>o(!1),style:{background:"#313244",border:"1px solid #45475a",borderRadius:4,color:"#cdd6f4",fontSize:11,padding:"4px 12px",cursor:"pointer"},children:"Cancel"})]})]}),u.jsx("div",{style:{flex:1,overflowY:"auto",padding:24,background:"#1e1e2e"},dangerouslySetInnerHTML:{__html:UV(n.content)}})]})}function PV(){const e=dt(c=>c.selectedDoc),[n,r]=N.useState("view"),a=()=>{dt.getState().selectDoc(null),dt.getState().setEditorContent(""),r("new")},o=()=>{r("edit")},l=()=>{r("view")};return u.jsxs("div",{style:{display:"flex",height:"100%",background:"#1e1e2e",overflow:"hidden"},children:[u.jsx(BV,{onNew:a}),u.jsx("div",{style:{flex:1,display:"flex",flexDirection:"column",overflow:"hidden"},children:n==="new"?u.jsx(jT,{isNew:!0,onCancel:l}):n==="edit"&&e?u.jsx(jT,{isNew:!1,onCancel:l}):e?u.jsx(FV,{onEdit:o}):u.jsxs("div",{style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",flexDirection:"column",gap:12},children:[u.jsx("div",{style:{color:"#6c7086",fontSize:16},children:"No document selected"}),u.jsx("div",{style:{color:"#585b70",fontSize:13},children:"Select a document from the list or create a new one"})]})})]})}function $V({data:e,columns:n}){const[r,a]=N.useState(null),[o,l]=N.useState(!0),c=N.useCallback(p=>{r===p?l(!o):(a(p),l(!0))},[r,o]),d=[...e].sort((p,h)=>{if(!r)return 0;const g=String(p[r]??""),y=String(h[r]??"");return o?g.localeCompare(y):y.localeCompare(g)});return u.jsx("div",{style:{overflowX:"auto"},children:u.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:13,color:"#cdd6f4"},children:[u.jsx("thead",{children:u.jsx("tr",{children:n.map(p=>u.jsxs("th",{onClick:p.sortable!==!1?()=>c(p.key):void 0,style:{textAlign:"left",padding:"8px 12px",borderBottom:"1px solid #45475a",cursor:p.sortable!==!1?"pointer":"default",userSelect:"none",fontWeight:600,color:"#89b4fa"},children:[p.label,r===p.key&&(o?" ▲":" ▼")]},p.key))})}),u.jsxs("tbody",{children:[d.map((p,h)=>u.jsx("tr",{style:{background:h%2===0?"transparent":"rgba(69,71,90,0.2)"},children:n.map(g=>u.jsx("td",{style:{padding:"6px 12px",borderBottom:"1px solid #313244"},children:String(p[g.key]??"")},g.key))},h)),d.length===0&&u.jsx("tr",{children:u.jsx("td",{colSpan:n.length,style:{padding:16,textAlign:"center",color:"#585b70"},children:"No data available"})})]})]})})}function VV({data:e}){const n=Object.entries(e);return u.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:16},children:n.map(([r,a])=>u.jsxs("div",{style:{background:"#1e1e2e",border:"1px solid #313244",borderRadius:8,padding:"16px 24px",minWidth:160,flex:"1 1 200px"},children:[u.jsx("div",{style:{fontSize:11,color:"#585b70",textTransform:"uppercase",marginBottom:4},children:r.replace(/_/g," ")}),u.jsx("div",{style:{fontSize:24,fontWeight:700,color:"#cdd6f4"},children:typeof a=="number"?a.toLocaleString():String(a??"-")})]},r))})}function WV({data:e}){return u.jsx("div",{style:{display:"flex",flexDirection:"column",gap:8},children:Object.entries(e).map(([n,r])=>u.jsxs("div",{style:{display:"flex",gap:12,fontSize:13},children:[u.jsx("span",{style:{color:"#89b4fa",fontWeight:600,minWidth:140},children:n.replace(/_/g," ")}),u.jsx("span",{style:{color:"#cdd6f4"},children:typeof r=="object"?JSON.stringify(r,null,2):String(r??"-")})]},n))})}function GV({page:e}){const[n,r]=N.useReducer((d,p)=>{switch(p.type){case"start":return{...d,loading:!0,error:null};case"success":return{data:p.data,loading:!1,error:null};case"error":return{...d,loading:!1,error:p.error}}},{data:null,loading:!1,error:null}),{data:a,loading:o,error:l}=n;if(N.useEffect(()=>{if(!e.apiEndpoint)return;r({type:"start"});const d=localStorage.getItem("auth_token"),p={"Content-Type":"application/json"};d&&(p.Authorization=`Bearer ${d}`),fetch(e.apiEndpoint,{headers:p}).then(h=>{if(!h.ok)throw new Error(`HTTP ${h.status}`);return h.json()}).then(h=>r({type:"success",data:h})).catch(h=>r({type:"error",error:h instanceof Error?h.message:"Failed to fetch data"}))},[e.apiEndpoint]),o)return u.jsx("div",{style:{padding:24,color:"#585b70"},children:"Loading..."});if(l)return u.jsxs("div",{style:{padding:24,color:"#f38ba8"},children:["Error loading data: ",l]});if(!e.apiEndpoint)return u.jsx("div",{style:{padding:24,color:"#585b70"},children:"No data source configured for this page."});if(!a)return null;const c=e.template||"detail-view";return u.jsxs("div",{style:{padding:24},children:[u.jsxs("h2",{style:{color:"#cdd6f4",fontSize:18,fontWeight:600,marginBottom:16},children:[e.icon," ",e.label]}),c==="data-table"&&Array.isArray(a)&&a.length>0&&u.jsx($V,{data:a,columns:Object.keys(a[0]).map(d=>({key:d,label:d.replace(/_/g," ").replace(/\b\w/g,p=>p.toUpperCase()),sortable:!0}))}),c==="chart-dashboard"&&typeof a=="object"&&!Array.isArray(a)&&u.jsx(VV,{data:a}),c==="detail-view"&&typeof a=="object"&&!Array.isArray(a)&&u.jsx(WV,{data:a}),c==="data-table"&&Array.isArray(a)&&a.length===0&&u.jsx("div",{style:{color:"#585b70",padding:16},children:"No records found."})]})}function AT(){const e=jt(c=>c.selectedWorkflowId),n=jt(c=>c.setSelectedWorkflowId),[r,a]=N.useState([]),[o,l]=N.useState(!0);return N.useEffect(()=>{let c=!1;return $b().then(d=>{c||a(d)}).catch(()=>{}).finally(()=>{c||l(!1)}),()=>{c=!0}},[]),u.jsxs("div",{style:{padding:"6px 16px",background:"#181825",borderBottom:"1px solid #313244",display:"flex",alignItems:"center",gap:10,flexShrink:0},children:[u.jsx("span",{style:{color:"#a6adc8",fontSize:11,fontWeight:600},children:"Workflow:"}),u.jsxs("select",{value:e??"",onChange:c=>n(c.target.value||null),style:{padding:"4px 8px",background:"#1e1e2e",border:"1px solid #313244",borderRadius:4,color:"#cdd6f4",fontSize:12,outline:"none",minWidth:200},children:[u.jsx("option",{value:"",children:o?"Loading...":"-- Select a workflow --"}),r.map(c=>u.jsxs("option",{value:c.id,children:[c.name," ",c.is_system?"(System)":""]},c.id))]}),e&&u.jsx("button",{onClick:()=>n(null),style:{background:"none",border:"none",color:"#585b70",cursor:"pointer",fontSize:11,padding:"2px 6px"},children:"Clear"})]})}function w0({collapsed:e,onToggle:n,side:r,panelName:a,width:o,onResize:l,minWidth:c=100,maxWidth:d=600,children:p}){const h=r==="left"?"borderRight":"borderLeft",g=e?0:o,[y,m]=N.useState(!1),[b,S]=N.useState(!1),[w,C]=N.useState(!1),_=N.useRef(0),j=N.useRef(0),k=N.useCallback(A=>{e||!l||(A.preventDefault(),m(!0),_.current=A.clientX,j.current=o)},[e,l,o]);N.useEffect(()=>{if(!y)return;const A=O=>{const P=r==="left"?O.clientX-_.current:_.current-O.clientX,L=Math.max(c,Math.min(d,j.current+P));l?.(L)},M=()=>{m(!1)};return document.addEventListener("mousemove",A),document.addEventListener("mouseup",M),document.body.style.cursor="col-resize",document.body.style.userSelect="none",()=>{document.removeEventListener("mousemove",A),document.removeEventListener("mouseup",M),document.body.style.cursor="",document.body.style.userSelect=""}},[y,l,r,c,d]);const T=e?`Expand ${a}`:`Collapse ${a}`,E=u.jsx("span",{style:{display:"flex",flexDirection:"column",gap:3,alignItems:"center"},children:[0,1,2].map(A=>u.jsx("span",{style:{width:4,height:4,borderRadius:"50%",background:b?"#cdd6f4":"#585b70",transition:"background 0.15s"}},A))}),z=N.useCallback(A=>{A.stopPropagation()},[]);return u.jsxs("div",{onClick:z,onMouseDown:z,style:{display:"flex",flexDirection:r==="left"?"row":"row-reverse",height:"100%",position:"relative",zIndex:12,flexShrink:0},children:[u.jsx("div",{style:{width:g,minWidth:0,overflow:"hidden",transition:y?"none":"width 0.2s ease",[h]:e?"none":"1px solid #313244"},children:u.jsx("div",{style:{width:o,minWidth:o,height:"100%"},children:p})}),!e&&l&&u.jsx("div",{onMouseDown:k,onMouseEnter:()=>C(!0),onMouseLeave:()=>C(!1),style:{width:5,minWidth:5,cursor:"col-resize",background:w||y?"#45475a":"transparent",transition:"background 0.15s",position:"relative",zIndex:2},title:"Drag to resize"}),u.jsxs("button",{onClick:n,title:T,onMouseEnter:()=>S(!0),onMouseLeave:()=>S(!1),style:{width:16,minWidth:16,background:b?"#313244":"#1e1e2e",border:"none",[h]:"1px solid #313244",color:b?"#cdd6f4":"#585b70",cursor:"pointer",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:8,fontSize:12,padding:0,transition:"background 0.15s, color 0.15s"},children:[E,u.jsx("span",{style:{display:"inline-block",transition:"transform 0.2s ease",transform:YV(r,e),fontSize:8},children:"▶"})]})]})}function YV(e,n){return e==="left"?n?"rotate(0deg)":"rotate(180deg)":n?"rotate(180deg)":"rotate(0deg)"}function XV(){const e=ue(A=>A.showAIPanel),n=ue(A=>A.showComponentBrowser),r=ue(A=>A.importFromConfig),a=ue(A=>A.clearCanvas),o=ue(A=>A.setActiveWorkflowRecord),l=ue(A=>A.activeWorkflowRecord),c=ue(A=>A.renameTab),d=ue(A=>A.activeTabId),p=jt(A=>A.setSelectedWorkflowId),h=Fn(A=>A.projectSwitcherCollapsed),g=Fn(A=>A.nodePaletteCollapsed),y=Fn(A=>A.propertyPanelCollapsed),m=Fn(A=>A.toggleProjectSwitcher),b=Fn(A=>A.toggleNodePalette),S=Fn(A=>A.togglePropertyPanel),w=Fn(A=>A.panelWidths),C=Fn(A=>A.setPanelWidth),_=ue(A=>A.nodes),[j,k]=N.useState(null);N.useEffect(()=>{l?.id&&p(l.id)},[l,p]),N.useEffect(()=>{const A=M=>{if(!(M.ctrlKey||M.metaKey))return;const O=M.target;O.tagName==="INPUT"||O.tagName==="TEXTAREA"||O.tagName==="SELECT"||(M.key==="1"?(M.preventDefault(),m()):M.key==="2"?(M.preventDefault(),b()):M.key==="3"&&(M.preventDefault(),S()))};return window.addEventListener("keydown",A),()=>window.removeEventListener("keydown",A)},[m,b,S]);const T=l||_.length>0?"editor":"projects",E=N.useCallback(A=>{k(A)},[]),z=N.useCallback(A=>{if(a(),A.config_yaml)try{const M=Bs(A.config_yaml);r(M)}catch{}o(A),c(d,A.name)},[a,r,o,c,d]);return u.jsxs(u.Fragment,{children:[u.jsx(w0,{collapsed:h,onToggle:m,side:"left",panelName:"Projects",width:w.projectSwitcher,onResize:A=>C("projectSwitcher",A),minWidth:Bi.projectSwitcher.min,maxWidth:Bi.projectSwitcher.max,children:u.jsx(i$,{selectedProjectId:j?.id??null,onSelectProject:E})}),T==="projects"&&u.jsx(a$,{projectId:j?.id,projectName:j?.name,onOpenWorkflow:z}),T==="editor"&&u.jsxs(u.Fragment,{children:[u.jsx(w0,{collapsed:g,onToggle:b,side:"left",panelName:"Module Palette",width:w.nodePalette,onResize:A=>C("nodePalette",A),minWidth:Bi.nodePalette.min,maxWidth:Bi.nodePalette.max,children:u.jsx(eF,{})}),u.jsx("div",{style:{flex:1,display:"flex",flexDirection:"column",overflow:"hidden",position:"relative",zIndex:0},children:u.jsx(bP,{})}),u.jsx(w0,{collapsed:y,onToggle:S,side:"right",panelName:"Properties",width:w.propertyPanel,onResize:A=>C("propertyPanel",A),minWidth:Bi.propertyPanel.min,maxWidth:Bi.propertyPanel.max,children:u.jsx(BP,{})}),e&&u.jsx(e$,{}),n&&u.jsx(t$,{})]})]})}function Yb({children:e}){return jt(r=>r.selectedWorkflowId)?u.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",background:"#1e1e2e",overflow:"hidden"},children:[u.jsx(AT,{}),u.jsx("div",{style:{flex:1,display:"flex",overflow:"hidden"},children:e})]}):u.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",background:"#1e1e2e",overflow:"hidden"},children:[u.jsx(AT,{}),u.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",color:"#6c7086",gap:8},children:[u.jsx("div",{style:{fontSize:14},children:"No workflow selected."}),u.jsx("div",{style:{fontSize:12},children:"Select a workflow above, or open one in the Editor first."})]})]})}function KV(){const e=jt(n=>n.selectedWorkflowId);return u.jsx(Yb,{children:e&&u.jsx(y$,{})})}function ZV(){return u.jsx(Yb,{children:u.jsx(b$,{})})}function QV(){return u.jsx(Yb,{children:u.jsx(w$,{})})}function JV(){const e=ue(a=>a.validationErrors),n=ue(a=>a.clearValidationErrors),r=ue(a=>a.setSelectedNode);return e.length===0?null:u.jsxs("div",{style:{background:"#f38ba822",borderBottom:"1px solid #f38ba8",padding:"4px 16px",display:"flex",alignItems:"center",gap:8,fontSize:12,color:"#f38ba8",maxHeight:80,overflowY:"auto"},children:[u.jsxs("span",{style:{fontWeight:600,flexShrink:0},children:[e.length," error",e.length!==1?"s":"",":"]}),u.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"4px 12px",flex:1},children:e.map((a,o)=>u.jsx("span",{onClick:()=>a.nodeId&&r(a.nodeId),style:{cursor:a.nodeId?"pointer":"default",textDecoration:a.nodeId?"underline":"none"},children:a.message},o))}),u.jsx("button",{onClick:n,style:{background:"none",border:"none",color:"#f38ba8",cursor:"pointer",fontSize:14,padding:"0 4px",flexShrink:0},children:"×"})]})}const eW={dashboard:f$,editor:XV,executions:KV,logs:ZV,events:QV,marketplace:I$,templates:P$,environments:J$,settings:N$,"feature-flags":mV,"store-browser":zV,docs:PV};function tW(){const e=jt(c=>c.activeView),n=ue(c=>c.activeWorkflowRecord),r=ue(c=>c.nodes),a=jt(c=>c.selectedWorkflowId),o=Vi(c=>c.enabledPages),l=!!(n||r.length>0||a);return u.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100vh",width:"100vw",overflow:"hidden",fontFamily:"system-ui, -apple-system, sans-serif"},children:[e==="editor"&&u.jsx(WP,{}),e==="editor"&&u.jsx(JV,{}),(e==="editor"||l)&&u.jsx(XP,{}),u.jsxs("div",{style:{display:"flex",flex:1,overflow:"hidden",position:"relative",isolation:"isolate"},children:[u.jsx(l$,{}),(()=>{const c=o.find(p=>p.id===e);if(!c)return null;const d=eW[e];return d?u.jsx(d,{}):c.template?u.jsx(GV,{page:c}):null})()]}),u.jsx(ZP,{})]})}function nW(){const{isAuthenticated:e,loadUser:n,setTokenFromCallback:r,setupRequired:a,setupLoading:o,checkSetupStatus:l}=_r(),c=!new URLSearchParams(window.location.search).get("token")&&e,[d,p]=N.useState(!c);return N.useEffect(()=>{const h=new URLSearchParams(window.location.search),g=h.get("token"),y=h.get("refresh_token");g&&y?(r(g,y),window.history.replaceState({},"",window.location.pathname)):e&&n().then(()=>p(!0)),l()},[]),a===null||o||!d?u.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",height:"100vh",width:"100vw",background:"#1e1e2e",color:"#a6adc8",fontFamily:"system-ui, -apple-system, sans-serif",fontSize:14},children:"Loading..."}):a?u.jsx(r$,{}):e?u.jsx(rW,{}):u.jsx(n$,{})}function rW(){const e=vt(c=>c.fetchSchemas),n=vt(c=>c.loaded),r=Vi(c=>c.fetchPlugins),a=Vi(c=>c.loaded),o=Vi(c=>c.setUserAccess),l=_r(c=>c.user);return N.useEffect(()=>{n||e()},[n,e]),N.useEffect(()=>{a||r()},[a,r]),N.useEffect(()=>{l&&o(l.role)},[l,o]),u.jsx(g8,{children:u.jsx(tW,{})})}class iW extends N.Component{state={error:null};static getDerivedStateFromError(n){return{error:n}}render(){return this.state.error?u.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",height:"100vh",background:"#1e1e2e",color:"#cdd6f4",fontFamily:"system-ui, sans-serif",padding:40},children:[u.jsx("h1",{style:{color:"#f38ba8",marginBottom:16},children:"Something went wrong"}),u.jsx("p",{style:{color:"#a6adc8",marginBottom:24,maxWidth:600,textAlign:"center"},children:this.state.error.message}),u.jsx("button",{onClick:()=>{this.setState({error:null}),window.location.reload()},style:{padding:"10px 24px",background:"#89b4fa",border:"none",borderRadius:6,color:"#1e1e2e",fontSize:14,fontWeight:600,cursor:"pointer"},children:"Reload"})]}):this.props.children}}function aW(){return u.jsx(iW,{children:u.jsx(nW,{})})}Gz({baseUrl:"/api/v1",onResponseError:(e,n)=>{if(e===401||e===403){const r=n.toLowerCase();(r.includes("user not found")||r.includes("unauthorized")||r.includes("invalid")||r.includes("expired")||e===401)&&_r.getState().logout()}}});Wz.createRoot(document.getElementById("root")).render(u.jsx(N.StrictMode,{children:u.jsx(aW,{})})); diff --git a/internal/ui_dist/assets/index-By5vjkWb.css b/internal/ui_dist/assets/index-By5vjkWb.css new file mode 100644 index 0000000..37ffb6b --- /dev/null +++ b/internal/ui_dist/assets/index-By5vjkWb.css @@ -0,0 +1 @@ +*{margin:0;padding:0;box-sizing:border-box}html,body,#root{width:100%;height:100%;overflow:hidden;background:#1e1e2e;color:#cdd6f4;font-family:system-ui,-apple-system,sans-serif}.react-flow__controls button{background:#313244!important;border:none!important;color:#cdd6f4!important;fill:#cdd6f4!important}.react-flow__controls button:hover{background:#45475a!important}.react-flow__edge-path{stroke:#585b70}.react-flow__connection-line{stroke:#89b4fa}.react-flow__handle{cursor:crosshair;transition:transform .15s ease,box-shadow .15s ease,background-color .15s ease;border:none!important}.react-flow__handle:hover{transform:scaleX(1.3) scaleY(1.4);box-shadow:0 0 8px 2px #89b4fa80;z-index:10}.react-flow__handle.connecting{box-shadow:0 0 10px 3px #89b4fab3}.react-flow__handle-top{clip-path:polygon(0% 100%,15% 0%,85% 0%,100% 100%)}.react-flow__handle-bottom{clip-path:polygon(0% 0%,15% 100%,85% 100%,100% 0%)}@keyframes toastSlideIn{0%{transform:translate(100%);opacity:0}to{transform:translate(0);opacity:1}}@keyframes compatible-pulse{0%,to{box-shadow:0 0 0 2px #22c55e4d,0 0 12px #22c55e26}50%{box-shadow:0 0 0 3px #22c55e66,0 0 18px #22c55e40}}.connection-compatible{animation:compatible-pulse 1.5s ease-in-out infinite}@keyframes snap-pulse{0%{box-shadow:0 0 0 3px #22c55e4d,0 0 16px #22c55e33}to{box-shadow:0 0 0 3px #22c55e80,0 0 24px #22c55e66}}.snap-target-glow{animation:snap-pulse .8s ease-in-out infinite alternate}@keyframes picklist-enter{0%{opacity:0;transform:scale(.95)}to{opacity:1;transform:scale(1)}}.edge-delete-button{display:flex;align-items:center;gap:4px}.edge-delete-btn{display:none;width:20px;height:20px;border-radius:50%;border:1px solid #45475a;background:#1e1e2e;color:#f38ba8;font-size:14px;line-height:1;cursor:pointer;padding:0;align-items:center;justify-content:center}.edge-delete-button:hover .edge-delete-btn{display:flex}.edge-delete-btn:hover{background:#f38ba8;color:#1e1e2e;border-color:#f38ba8}.edge-label{font-size:11px;color:#bac2de;background:#1e1e2e;padding:1px 6px;border-radius:4px;white-space:nowrap}.context-menu{background:#181825;border:1px solid #313244;border-radius:6px;box-shadow:0 8px 24px #00000080;min-width:160px;padding:4px 0;font-family:system-ui,-apple-system,sans-serif;animation:picklist-enter .1s ease-out}.context-menu-item{display:block;width:100%;padding:7px 14px;border:none;background:none;color:#cdd6f4;font-size:12px;text-align:left;cursor:pointer;white-space:nowrap}.context-menu-item:hover{background:#313244}.context-menu-item-danger{color:#f38ba8}.context-menu-item-danger:hover{background:#f38ba81a}.react-flow{direction:ltr;--xy-edge-stroke-default: #b1b1b7;--xy-edge-stroke-width-default: 1;--xy-edge-stroke-selected-default: #555;--xy-connectionline-stroke-default: #b1b1b7;--xy-connectionline-stroke-width-default: 1;--xy-attribution-background-color-default: rgba(255, 255, 255, .5);--xy-minimap-background-color-default: #fff;--xy-minimap-mask-background-color-default: rgba(240, 240, 240, .6);--xy-minimap-mask-stroke-color-default: transparent;--xy-minimap-mask-stroke-width-default: 1;--xy-minimap-node-background-color-default: #e2e2e2;--xy-minimap-node-stroke-color-default: transparent;--xy-minimap-node-stroke-width-default: 2;--xy-background-color-default: transparent;--xy-background-pattern-dots-color-default: #91919a;--xy-background-pattern-lines-color-default: #eee;--xy-background-pattern-cross-color-default: #e2e2e2;background-color:var(--xy-background-color, var(--xy-background-color-default));--xy-node-color-default: inherit;--xy-node-border-default: 1px solid #1a192b;--xy-node-background-color-default: #fff;--xy-node-group-background-color-default: rgba(240, 240, 240, .25);--xy-node-boxshadow-hover-default: 0 1px 4px 1px rgba(0, 0, 0, .08);--xy-node-boxshadow-selected-default: 0 0 0 .5px #1a192b;--xy-node-border-radius-default: 3px;--xy-handle-background-color-default: #1a192b;--xy-handle-border-color-default: #fff;--xy-selection-background-color-default: rgba(0, 89, 220, .08);--xy-selection-border-default: 1px dotted rgba(0, 89, 220, .8);--xy-controls-button-background-color-default: #fefefe;--xy-controls-button-background-color-hover-default: #f4f4f4;--xy-controls-button-color-default: inherit;--xy-controls-button-color-hover-default: inherit;--xy-controls-button-border-color-default: #eee;--xy-controls-box-shadow-default: 0 0 2px 1px rgba(0, 0, 0, .08);--xy-edge-label-background-color-default: #ffffff;--xy-edge-label-color-default: inherit;--xy-resize-background-color-default: #3367d9}.react-flow.dark{--xy-edge-stroke-default: #3e3e3e;--xy-edge-stroke-width-default: 1;--xy-edge-stroke-selected-default: #727272;--xy-connectionline-stroke-default: #b1b1b7;--xy-connectionline-stroke-width-default: 1;--xy-attribution-background-color-default: rgba(150, 150, 150, .25);--xy-minimap-background-color-default: #141414;--xy-minimap-mask-background-color-default: rgba(60, 60, 60, .6);--xy-minimap-mask-stroke-color-default: transparent;--xy-minimap-mask-stroke-width-default: 1;--xy-minimap-node-background-color-default: #2b2b2b;--xy-minimap-node-stroke-color-default: transparent;--xy-minimap-node-stroke-width-default: 2;--xy-background-color-default: #141414;--xy-background-pattern-dots-color-default: #777;--xy-background-pattern-lines-color-default: #777;--xy-background-pattern-cross-color-default: #777;--xy-node-color-default: #f8f8f8;--xy-node-border-default: 1px solid #3c3c3c;--xy-node-background-color-default: #1e1e1e;--xy-node-group-background-color-default: rgba(240, 240, 240, .25);--xy-node-boxshadow-hover-default: 0 1px 4px 1px rgba(255, 255, 255, .08);--xy-node-boxshadow-selected-default: 0 0 0 .5px #999;--xy-handle-background-color-default: #bebebe;--xy-handle-border-color-default: #1e1e1e;--xy-selection-background-color-default: rgba(200, 200, 220, .08);--xy-selection-border-default: 1px dotted rgba(200, 200, 220, .8);--xy-controls-button-background-color-default: #2b2b2b;--xy-controls-button-background-color-hover-default: #3e3e3e;--xy-controls-button-color-default: #f8f8f8;--xy-controls-button-color-hover-default: #fff;--xy-controls-button-border-color-default: #5b5b5b;--xy-controls-box-shadow-default: 0 0 2px 1px rgba(0, 0, 0, .08);--xy-edge-label-background-color-default: #141414;--xy-edge-label-color-default: #f8f8f8}.react-flow__background{background-color:var(--xy-background-color-props, var(--xy-background-color, var(--xy-background-color-default)));pointer-events:none;z-index:-1}.react-flow__container{position:absolute;width:100%;height:100%;top:0;left:0}.react-flow__pane{z-index:1}.react-flow__pane.draggable{cursor:grab}.react-flow__pane.dragging{cursor:grabbing}.react-flow__pane.selection{cursor:pointer}.react-flow__viewport{transform-origin:0 0;z-index:2;pointer-events:none}.react-flow__renderer{z-index:4}.react-flow__selection{z-index:6}.react-flow__nodesselection-rect:focus,.react-flow__nodesselection-rect:focus-visible{outline:none}.react-flow__edge-path{stroke:var(--xy-edge-stroke, var(--xy-edge-stroke-default));stroke-width:var(--xy-edge-stroke-width, var(--xy-edge-stroke-width-default));fill:none}.react-flow__connection-path{stroke:var(--xy-connectionline-stroke, var(--xy-connectionline-stroke-default));stroke-width:var(--xy-connectionline-stroke-width, var(--xy-connectionline-stroke-width-default));fill:none}.react-flow .react-flow__edges{position:absolute}.react-flow .react-flow__edges svg{overflow:visible;position:absolute;pointer-events:none}.react-flow__edge{pointer-events:visibleStroke}.react-flow__edge.selectable{cursor:pointer}.react-flow__edge.animated path{stroke-dasharray:5;animation:dashdraw .5s linear infinite}.react-flow__edge.animated path.react-flow__edge-interaction{stroke-dasharray:none;animation:none}.react-flow__edge.inactive{pointer-events:none}.react-flow__edge.selected,.react-flow__edge:focus,.react-flow__edge:focus-visible{outline:none}.react-flow__edge.selected .react-flow__edge-path,.react-flow__edge.selectable:focus .react-flow__edge-path,.react-flow__edge.selectable:focus-visible .react-flow__edge-path{stroke:var(--xy-edge-stroke-selected, var(--xy-edge-stroke-selected-default))}.react-flow__edge-textwrapper{pointer-events:all}.react-flow__edge .react-flow__edge-text{pointer-events:none;-webkit-user-select:none;-moz-user-select:none;user-select:none}.react-flow__arrowhead polyline{stroke:var(--xy-edge-stroke, var(--xy-edge-stroke-default))}.react-flow__arrowhead polyline.arrowclosed{fill:var(--xy-edge-stroke, var(--xy-edge-stroke-default))}.react-flow__connection{pointer-events:none}.react-flow__connection .animated{stroke-dasharray:5;animation:dashdraw .5s linear infinite}svg.react-flow__connectionline{z-index:1001;overflow:visible;position:absolute}.react-flow__nodes{pointer-events:none;transform-origin:0 0}.react-flow__node{position:absolute;-webkit-user-select:none;-moz-user-select:none;user-select:none;pointer-events:all;transform-origin:0 0;box-sizing:border-box;cursor:default}.react-flow__node.selectable{cursor:pointer}.react-flow__node.draggable{cursor:grab;pointer-events:all}.react-flow__node.draggable.dragging{cursor:grabbing}.react-flow__nodesselection{z-index:3;transform-origin:left top;pointer-events:none}.react-flow__nodesselection-rect{position:absolute;pointer-events:all;cursor:grab}.react-flow__handle{position:absolute;pointer-events:none;min-width:5px;min-height:5px;width:6px;height:6px;background-color:var(--xy-handle-background-color, var(--xy-handle-background-color-default));border:1px solid var(--xy-handle-border-color, var(--xy-handle-border-color-default));border-radius:100%}.react-flow__handle.connectingfrom{pointer-events:all}.react-flow__handle.connectionindicator{pointer-events:all;cursor:crosshair}.react-flow__handle-bottom{top:auto;left:50%;bottom:0;transform:translate(-50%,50%)}.react-flow__handle-top{top:0;left:50%;transform:translate(-50%,-50%)}.react-flow__handle-left{top:50%;left:0;transform:translate(-50%,-50%)}.react-flow__handle-right{top:50%;right:0;transform:translate(50%,-50%)}.react-flow__edgeupdater{cursor:move;pointer-events:all}.react-flow__pane.selection .react-flow__panel{pointer-events:none}.react-flow__panel{position:absolute;z-index:5;margin:15px}.react-flow__panel.top{top:0}.react-flow__panel.bottom{bottom:0}.react-flow__panel.top.center,.react-flow__panel.bottom.center{left:50%;transform:translate(-15px) translate(-50%)}.react-flow__panel.left{left:0}.react-flow__panel.right{right:0}.react-flow__panel.left.center,.react-flow__panel.right.center{top:50%;transform:translateY(-15px) translateY(-50%)}.react-flow__attribution{font-size:10px;background:var(--xy-attribution-background-color, var(--xy-attribution-background-color-default));padding:2px 3px;margin:0}.react-flow__attribution a{text-decoration:none;color:#999}@keyframes dashdraw{0%{stroke-dashoffset:10}}.react-flow__edgelabel-renderer{position:absolute;width:100%;height:100%;pointer-events:none;-webkit-user-select:none;-moz-user-select:none;user-select:none;left:0;top:0}.react-flow__viewport-portal{position:absolute;width:100%;height:100%;left:0;top:0;-webkit-user-select:none;-moz-user-select:none;user-select:none}.react-flow__minimap{background:var( --xy-minimap-background-color-props, var(--xy-minimap-background-color, var(--xy-minimap-background-color-default)) )}.react-flow__minimap-svg{display:block}.react-flow__minimap-mask{fill:var( --xy-minimap-mask-background-color-props, var(--xy-minimap-mask-background-color, var(--xy-minimap-mask-background-color-default)) );stroke:var( --xy-minimap-mask-stroke-color-props, var(--xy-minimap-mask-stroke-color, var(--xy-minimap-mask-stroke-color-default)) );stroke-width:var( --xy-minimap-mask-stroke-width-props, var(--xy-minimap-mask-stroke-width, var(--xy-minimap-mask-stroke-width-default)) )}.react-flow__minimap-node{fill:var( --xy-minimap-node-background-color-props, var(--xy-minimap-node-background-color, var(--xy-minimap-node-background-color-default)) );stroke:var( --xy-minimap-node-stroke-color-props, var(--xy-minimap-node-stroke-color, var(--xy-minimap-node-stroke-color-default)) );stroke-width:var( --xy-minimap-node-stroke-width-props, var(--xy-minimap-node-stroke-width, var(--xy-minimap-node-stroke-width-default)) )}.react-flow__background-pattern.dots{fill:var( --xy-background-pattern-color-props, var(--xy-background-pattern-color, var(--xy-background-pattern-dots-color-default)) )}.react-flow__background-pattern.lines{stroke:var( --xy-background-pattern-color-props, var(--xy-background-pattern-color, var(--xy-background-pattern-lines-color-default)) )}.react-flow__background-pattern.cross{stroke:var( --xy-background-pattern-color-props, var(--xy-background-pattern-color, var(--xy-background-pattern-cross-color-default)) )}.react-flow__controls{display:flex;flex-direction:column;box-shadow:var(--xy-controls-box-shadow, var(--xy-controls-box-shadow-default))}.react-flow__controls.horizontal{flex-direction:row}.react-flow__controls-button{display:flex;justify-content:center;align-items:center;height:26px;width:26px;padding:4px;border:none;background:var(--xy-controls-button-background-color, var(--xy-controls-button-background-color-default));border-bottom:1px solid var( --xy-controls-button-border-color-props, var(--xy-controls-button-border-color, var(--xy-controls-button-border-color-default)) );color:var( --xy-controls-button-color-props, var(--xy-controls-button-color, var(--xy-controls-button-color-default)) );cursor:pointer;-webkit-user-select:none;-moz-user-select:none;user-select:none}.react-flow__controls-button svg{width:100%;max-width:12px;max-height:12px;fill:currentColor}.react-flow__edge.updating .react-flow__edge-path{stroke:#777}.react-flow__edge-text{font-size:10px}.react-flow__node.selectable:focus,.react-flow__node.selectable:focus-visible{outline:none}.react-flow__node-input,.react-flow__node-default,.react-flow__node-output,.react-flow__node-group{padding:10px;border-radius:var(--xy-node-border-radius, var(--xy-node-border-radius-default));width:150px;font-size:12px;color:var(--xy-node-color, var(--xy-node-color-default));text-align:center;border:var(--xy-node-border, var(--xy-node-border-default));background-color:var(--xy-node-background-color, var(--xy-node-background-color-default))}.react-flow__node-input.selectable:hover,.react-flow__node-default.selectable:hover,.react-flow__node-output.selectable:hover,.react-flow__node-group.selectable:hover{box-shadow:var(--xy-node-boxshadow-hover, var(--xy-node-boxshadow-hover-default))}.react-flow__node-input.selectable.selected,.react-flow__node-input.selectable:focus,.react-flow__node-input.selectable:focus-visible,.react-flow__node-default.selectable.selected,.react-flow__node-default.selectable:focus,.react-flow__node-default.selectable:focus-visible,.react-flow__node-output.selectable.selected,.react-flow__node-output.selectable:focus,.react-flow__node-output.selectable:focus-visible,.react-flow__node-group.selectable.selected,.react-flow__node-group.selectable:focus,.react-flow__node-group.selectable:focus-visible{box-shadow:var(--xy-node-boxshadow-selected, var(--xy-node-boxshadow-selected-default))}.react-flow__node-group{background-color:var(--xy-node-group-background-color, var(--xy-node-group-background-color-default))}.react-flow__nodesselection-rect,.react-flow__selection{background:var(--xy-selection-background-color, var(--xy-selection-background-color-default));border:var(--xy-selection-border, var(--xy-selection-border-default))}.react-flow__nodesselection-rect:focus,.react-flow__nodesselection-rect:focus-visible,.react-flow__selection:focus,.react-flow__selection:focus-visible{outline:none}.react-flow__controls-button:hover{background:var( --xy-controls-button-background-color-hover-props, var(--xy-controls-button-background-color-hover, var(--xy-controls-button-background-color-hover-default)) );color:var( --xy-controls-button-color-hover-props, var(--xy-controls-button-color-hover, var(--xy-controls-button-color-hover-default)) )}.react-flow__controls-button:disabled{pointer-events:none}.react-flow__controls-button:disabled svg{fill-opacity:.4}.react-flow__controls-button:last-child{border-bottom:none}.react-flow__controls.horizontal .react-flow__controls-button{border-bottom:none;border-right:1px solid var( --xy-controls-button-border-color-props, var(--xy-controls-button-border-color, var(--xy-controls-button-border-color-default)) )}.react-flow__controls.horizontal .react-flow__controls-button:last-child{border-right:none}.react-flow__resize-control{position:absolute}.react-flow__resize-control.left,.react-flow__resize-control.right{cursor:ew-resize}.react-flow__resize-control.top,.react-flow__resize-control.bottom{cursor:ns-resize}.react-flow__resize-control.top.left,.react-flow__resize-control.bottom.right{cursor:nwse-resize}.react-flow__resize-control.bottom.left,.react-flow__resize-control.top.right{cursor:nesw-resize}.react-flow__resize-control.handle{width:5px;height:5px;border:1px solid #fff;border-radius:1px;background-color:var(--xy-resize-background-color, var(--xy-resize-background-color-default));translate:-50% -50%}.react-flow__resize-control.handle.left{left:0;top:50%}.react-flow__resize-control.handle.right{left:100%;top:50%}.react-flow__resize-control.handle.top{left:50%;top:0}.react-flow__resize-control.handle.bottom{left:50%;top:100%}.react-flow__resize-control.handle.top.left,.react-flow__resize-control.handle.bottom.left{left:0}.react-flow__resize-control.handle.top.right,.react-flow__resize-control.handle.bottom.right{left:100%}.react-flow__resize-control.line{border-color:var(--xy-resize-background-color, var(--xy-resize-background-color-default));border-width:0;border-style:solid}.react-flow__resize-control.line.left,.react-flow__resize-control.line.right{width:1px;transform:translate(-50%);top:0;height:100%}.react-flow__resize-control.line.left{left:0;border-left-width:1px}.react-flow__resize-control.line.right{left:100%;border-right-width:1px}.react-flow__resize-control.line.top,.react-flow__resize-control.line.bottom{height:1px;transform:translateY(-50%);left:0;width:100%}.react-flow__resize-control.line.top{top:0;border-top-width:1px}.react-flow__resize-control.line.bottom{border-bottom-width:1px;top:100%}.react-flow__edge-textbg{fill:var(--xy-edge-label-background-color, var(--xy-edge-label-background-color-default))}.react-flow__edge-text{fill:var(--xy-edge-label-color, var(--xy-edge-label-color-default))} diff --git a/internal/ui_dist/index.html b/internal/ui_dist/index.html index 7415683..4886505 100644 --- a/internal/ui_dist/index.html +++ b/internal/ui_dist/index.html @@ -1,2 +1,14 @@ - -Admin UI not built. Run 'make ui' to build. + + + + + + + Workflow Engine + + + + +
+ + diff --git a/internal/ui_dist/vite.svg b/internal/ui_dist/vite.svg new file mode 100644 index 0000000..e7b8dfb --- /dev/null +++ b/internal/ui_dist/vite.svg @@ -0,0 +1 @@ + \ No newline at end of file