import{j as o,u as we,H as ve,P as Q,N as Jt,R as Qt,a as en,i as tn,B as nn,C as rn,b as Be}from"./reactflow-vendor-DVEEOIVt.js";import{r as s,c as on}from"./react-vendor-4ldeB94U.js";import{c as an,a as k,u as nt,b as Ue,d as K,P as O,e as rt,f as M,g as se,S as sn,D as cn,h as ln,i as un,j as ot,X as dn,k as fn,l as pn}from"./index-BXU-m2Zz.js";import{c as V,u as H,a as z,g as D,f as re,F as I,B as oe,e as G,b as xe,S as at,G as hn,h as $e}from"./shallow-CUABpCwf.js";import{S as R}from"./Stack-D0KwXe3b.js";import{I as mn}from"./IconFolder-wFGRbLxB.js";/**
 * @license lucide-react v0.446.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const gn=an("Check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);/**
 * @license @tabler/icons-react v3.18.0 - MIT
 *
 * This source code is licensed under the MIT license.
 * See the LICENSE file in the root directory of this source tree.
 */var vn=V("outline","arrow-back-up","IconArrowBackUp",[["path",{d:"M9 14l-4 -4l4 -4",key:"svg-0"}],["path",{d:"M5 10h11a4 4 0 1 1 0 8h-1",key:"svg-1"}]]);/**
 * @license @tabler/icons-react v3.18.0 - MIT
 *
 * This source code is licensed under the MIT license.
 * See the LICENSE file in the root directory of this source tree.
 */var xn=V("outline","arrow-forward-up","IconArrowForwardUp",[["path",{d:"M15 14l4 -4l-4 -4",key:"svg-0"}],["path",{d:"M19 10h-11a4 4 0 1 0 0 8h1",key:"svg-1"}]]);/**
 * @license @tabler/icons-react v3.18.0 - MIT
 *
 * This source code is licensed under the MIT license.
 * See the LICENSE file in the root directory of this source tree.
 */var bn=V("outline","arrows-diagonal-2","IconArrowsDiagonal2",[["path",{d:"M16 20l4 0l0 -4",key:"svg-0"}],["path",{d:"M14 14l6 6",key:"svg-1"}],["path",{d:"M8 4l-4 0l0 4",key:"svg-2"}],["path",{d:"M4 4l6 6",key:"svg-3"}]]);/**
 * @license @tabler/icons-react v3.18.0 - MIT
 *
 * This source code is licensed under the MIT license.
 * See the LICENSE file in the root directory of this source tree.
 */var yn=V("outline","circle-check","IconCircleCheck",[["path",{d:"M12 12m-9 0a9 9 0 1 0 18 0a9 9 0 1 0 -18 0",key:"svg-0"}],["path",{d:"M9 12l2 2l4 -4",key:"svg-1"}]]);/**
 * @license @tabler/icons-react v3.18.0 - MIT
 *
 * This source code is licensed under the MIT license.
 * See the LICENSE file in the root directory of this source tree.
 */var wn=V("outline","x","IconX",[["path",{d:"M18 6l-12 12",key:"svg-0"}],["path",{d:"M6 6l12 12",key:"svg-1"}]]);/**
 * @license @tabler/icons-react v3.18.0 - MIT
 *
 * This source code is licensed under the MIT license.
 * See the LICENSE file in the root directory of this source tree.
 */var Nn=V("outline","xbox-x","IconXboxX",[["path",{d:"M12 21a9 9 0 0 0 9 -9a9 9 0 0 0 -9 -9a9 9 0 0 0 -9 9a9 9 0 0 0 9 9z",key:"svg-0"}],["path",{d:"M9 8l6 8",key:"svg-1"}],["path",{d:"M15 8l-6 8",key:"svg-2"}]]);const st=s.forwardRef(({className:e,...t},n)=>o.jsx("textarea",{className:k("flex min-h-[20px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",e),ref:n,...t}));st.displayName="Textarea";const Ne=s.forwardRef(({className:e,type:t,...n},r)=>o.jsx("input",{type:t,className:k("flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",e),ref:r,...n}));Ne.displayName="Input";function Cn({input:e,nodeID:t}){const{updateValues:n,values:r}=H(z(a=>({values:a.values,updateValues:a.updateValues})));return o.jsx(Ne,{type:"number",value:r[D("input",t,e.id)]??"",onChange:a=>{n({[D("input",t,e.id)]:a.target.value===""?void 0:Number(a.target.value)})},className:"w-full border-zinc-700 [appearance:textfield] [&::-webkit-outer-spin-button]:appearance-none [&::-webkit-inner-spin-button]:appearance-none"})}var Sn=on.useId||(()=>{}),jn=0;function le(e){const[t,n]=s.useState(Sn());return nt(()=>{e||n(r=>r??String(jn++))},[e]),e||(t?`radix-${t}`:"")}var ue="focusScope.autoFocusOnMount",de="focusScope.autoFocusOnUnmount",Ve={bubbles:!1,cancelable:!0},En="FocusScope",ct=s.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:a,onUnmountAutoFocus:c,...l}=e,[i,p]=s.useState(null),m=Ue(a),v=Ue(c),f=s.useRef(null),d=K(t,u=>p(u)),b=s.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;s.useEffect(()=>{if(r){let u=function(w){if(b.paused||!i)return;const g=w.target;i.contains(g)?f.current=g:P(f.current,{select:!0})},x=function(w){if(b.paused||!i)return;const g=w.relatedTarget;g!==null&&(i.contains(g)||P(f.current,{select:!0}))},y=function(w){if(document.activeElement===document.body)for(const h of w)h.removedNodes.length>0&&P(i)};document.addEventListener("focusin",u),document.addEventListener("focusout",x);const N=new MutationObserver(y);return i&&N.observe(i,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",u),document.removeEventListener("focusout",x),N.disconnect()}}},[r,i,b.paused]),s.useEffect(()=>{if(i){Ge.add(b);const u=document.activeElement;if(!i.contains(u)){const y=new CustomEvent(ue,Ve);i.addEventListener(ue,m),i.dispatchEvent(y),y.defaultPrevented||(kn(Tn(it(i)),{select:!0}),document.activeElement===u&&P(i))}return()=>{i.removeEventListener(ue,m),setTimeout(()=>{const y=new CustomEvent(de,Ve);i.addEventListener(de,v),i.dispatchEvent(y),y.defaultPrevented||P(u??document.body,{select:!0}),i.removeEventListener(de,v),Ge.remove(b)},0)}}},[i,m,v,b]);const j=s.useCallback(u=>{if(!n&&!r||b.paused)return;const x=u.key==="Tab"&&!u.altKey&&!u.ctrlKey&&!u.metaKey,y=document.activeElement;if(x&&y){const N=u.currentTarget,[w,g]=Rn(N);w&&g?!u.shiftKey&&y===g?(u.preventDefault(),n&&P(w,{select:!0})):u.shiftKey&&y===w&&(u.preventDefault(),n&&P(g,{select:!0})):y===N&&u.preventDefault()}},[n,r,b.paused]);return o.jsx(O.div,{tabIndex:-1,...l,ref:d,onKeyDown:j})});ct.displayName=En;function kn(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(P(r,{select:t}),document.activeElement!==n)return}function Rn(e){const t=it(e),n=Xe(t,e),r=Xe(t.reverse(),e);return[n,r]}function it(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>{const a=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||a?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function Xe(e,t){for(const n of e)if(!In(n,{upTo:t}))return n}function In(e,{upTo:t}){if(getComputedStyle(e).visibility==="hidden")return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display==="none")return!0;e=e.parentElement}return!1}function Dn(e){return e instanceof HTMLInputElement&&"select"in e}function P(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&Dn(e)&&t&&e.select()}}var Ge=_n();function _n(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=Ke(e,t),e.unshift(t)},remove(t){var n;e=Ke(e,t),(n=e[0])==null||n.resume()}}}function Ke(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function Tn(e){return e.filter(t=>t.tagName!=="A")}var fe=0;function An(){s.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??Ye()),document.body.insertAdjacentElement("beforeend",e[1]??Ye()),fe++,()=>{fe===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),fe--}},[])}function Ye(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}var A=function(){return A=Object.assign||function(t){for(var n,r=1,a=arguments.length;r<a;r++){n=arguments[r];for(var c in n)Object.prototype.hasOwnProperty.call(n,c)&&(t[c]=n[c])}return t},A.apply(this,arguments)};function lt(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var a=0,r=Object.getOwnPropertySymbols(e);a<r.length;a++)t.indexOf(r[a])<0&&Object.prototype.propertyIsEnumerable.call(e,r[a])&&(n[r[a]]=e[r[a]]);return n}function Pn(e,t,n){if(n||arguments.length===2)for(var r=0,a=t.length,c;r<a;r++)(c||!(r in t))&&(c||(c=Array.prototype.slice.call(t,0,r)),c[r]=t[r]);return e.concat(c||Array.prototype.slice.call(t))}var ee="right-scroll-bar-position",te="width-before-scroll-bar",Fn="with-scroll-bars-hidden",On="--removed-body-scroll-bar-size";function pe(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function Mn(e,t){var n=s.useState(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(r){var a=n.value;a!==r&&(n.value=r,n.callback(r,a))}}}})[0];return n.callback=t,n.facade}var Ln=typeof window<"u"?s.useLayoutEffect:s.useEffect,qe=new WeakMap;function Hn(e,t){var n=Mn(null,function(r){return e.forEach(function(a){return pe(a,r)})});return Ln(function(){var r=qe.get(n);if(r){var a=new Set(r),c=new Set(e),l=n.current;a.forEach(function(i){c.has(i)||pe(i,null)}),c.forEach(function(i){a.has(i)||pe(i,l)})}qe.set(n,e)},[e]),n}function zn(e){return e}function Wn(e,t){t===void 0&&(t=zn);var n=[],r=!1,a={read:function(){if(r)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:e},useMedium:function(c){var l=t(c,r);return n.push(l),function(){n=n.filter(function(i){return i!==l})}},assignSyncMedium:function(c){for(r=!0;n.length;){var l=n;n=[],l.forEach(c)}n={push:function(i){return c(i)},filter:function(){return n}}},assignMedium:function(c){r=!0;var l=[];if(n.length){var i=n;n=[],i.forEach(c),l=n}var p=function(){var v=l;l=[],v.forEach(c)},m=function(){return Promise.resolve().then(p)};m(),n={push:function(v){l.push(v),m()},filter:function(v){return l=l.filter(v),n}}}};return a}function Bn(e){e===void 0&&(e={});var t=Wn(null);return t.options=A({async:!0,ssr:!1},e),t}var ut=function(e){var t=e.sideCar,n=lt(e,["sideCar"]);if(!t)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var r=t.read();if(!r)throw new Error("Sidecar medium not found");return s.createElement(r,A({},n))};ut.isSideCarExport=!0;function Un(e,t){return e.useMedium(t),ut}var dt=Bn(),he=function(){},ce=s.forwardRef(function(e,t){var n=s.useRef(null),r=s.useState({onScrollCapture:he,onWheelCapture:he,onTouchMoveCapture:he}),a=r[0],c=r[1],l=e.forwardProps,i=e.children,p=e.className,m=e.removeScrollBar,v=e.enabled,f=e.shards,d=e.sideCar,b=e.noIsolation,j=e.inert,u=e.allowPinchZoom,x=e.as,y=x===void 0?"div":x,N=e.gapMode,w=lt(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noIsolation","inert","allowPinchZoom","as","gapMode"]),g=d,h=Hn([n,t]),S=A(A({},w),a);return s.createElement(s.Fragment,null,v&&s.createElement(g,{sideCar:dt,removeScrollBar:m,shards:f,noIsolation:b,inert:j,setCallbacks:c,allowPinchZoom:!!u,lockRef:n,gapMode:N}),l?s.cloneElement(s.Children.only(i),A(A({},S),{ref:h})):s.createElement(y,A({},S,{className:p,ref:h}),i))});ce.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};ce.classNames={fullWidth:te,zeroRight:ee};var $n=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function Vn(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=$n();return t&&e.setAttribute("nonce",t),e}function Xn(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function Gn(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var Kn=function(){var e=0,t=null;return{add:function(n){e==0&&(t=Vn())&&(Xn(t,n),Gn(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},Yn=function(){var e=Kn();return function(t,n){s.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},ft=function(){var e=Yn(),t=function(n){var r=n.styles,a=n.dynamic;return e(r,a),null};return t},qn={left:0,top:0,right:0,gap:0},me=function(e){return parseInt(e||"",10)||0},Zn=function(e){var t=window.getComputedStyle(document.body),n=t[e==="padding"?"paddingLeft":"marginLeft"],r=t[e==="padding"?"paddingTop":"marginTop"],a=t[e==="padding"?"paddingRight":"marginRight"];return[me(n),me(r),me(a)]},Jn=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return qn;var t=Zn(e),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,r-n+t[2]-t[0])}},Qn=ft(),$="data-scroll-locked",er=function(e,t,n,r){var a=e.left,c=e.top,l=e.right,i=e.gap;return n===void 0&&(n="margin"),`
  .`.concat(Fn,` {
   overflow: hidden `).concat(r,`;
   padding-right: `).concat(i,"px ").concat(r,`;
  }
  body[`).concat($,`] {
    overflow: hidden `).concat(r,`;
    overscroll-behavior: contain;
    `).concat([t&&"position: relative ".concat(r,";"),n==="margin"&&`
    padding-left: `.concat(a,`px;
    padding-top: `).concat(c,`px;
    padding-right: `).concat(l,`px;
    margin-left:0;
    margin-top:0;
    margin-right: `).concat(i,"px ").concat(r,`;
    `),n==="padding"&&"padding-right: ".concat(i,"px ").concat(r,";")].filter(Boolean).join(""),`
  }
  
  .`).concat(ee,` {
    right: `).concat(i,"px ").concat(r,`;
  }
  
  .`).concat(te,` {
    margin-right: `).concat(i,"px ").concat(r,`;
  }
  
  .`).concat(ee," .").concat(ee,` {
    right: 0 `).concat(r,`;
  }
  
  .`).concat(te," .").concat(te,` {
    margin-right: 0 `).concat(r,`;
  }
  
  body[`).concat($,`] {
    `).concat(On,": ").concat(i,`px;
  }
`)},Ze=function(){var e=parseInt(document.body.getAttribute($)||"0",10);return isFinite(e)?e:0},tr=function(){s.useEffect(function(){return document.body.setAttribute($,(Ze()+1).toString()),function(){var e=Ze()-1;e<=0?document.body.removeAttribute($):document.body.setAttribute($,e.toString())}},[])},nr=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,a=r===void 0?"margin":r;tr();var c=s.useMemo(function(){return Jn(a)},[a]);return s.createElement(Qn,{styles:er(c,!t,a,n?"":"!important")})},be=!1;if(typeof window<"u")try{var Y=Object.defineProperty({},"passive",{get:function(){return be=!0,!0}});window.addEventListener("test",Y,Y),window.removeEventListener("test",Y,Y)}catch{be=!1}var W=be?{passive:!1}:!1,rr=function(e){return e.tagName==="TEXTAREA"},pt=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!=="hidden"&&!(n.overflowY===n.overflowX&&!rr(e)&&n[t]==="visible")},or=function(e){return pt(e,"overflowY")},ar=function(e){return pt(e,"overflowX")},Je=function(e,t){var n=t.ownerDocument,r=t;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var a=ht(e,r);if(a){var c=mt(e,r),l=c[1],i=c[2];if(l>i)return!0}r=r.parentNode}while(r&&r!==n.body);return!1},sr=function(e){var t=e.scrollTop,n=e.scrollHeight,r=e.clientHeight;return[t,n,r]},cr=function(e){var t=e.scrollLeft,n=e.scrollWidth,r=e.clientWidth;return[t,n,r]},ht=function(e,t){return e==="v"?or(t):ar(t)},mt=function(e,t){return e==="v"?sr(t):cr(t)},ir=function(e,t){return e==="h"&&t==="rtl"?-1:1},lr=function(e,t,n,r,a){var c=ir(e,window.getComputedStyle(t).direction),l=c*r,i=n.target,p=t.contains(i),m=!1,v=l>0,f=0,d=0;do{var b=mt(e,i),j=b[0],u=b[1],x=b[2],y=u-x-c*j;(j||y)&&ht(e,i)&&(f+=y,d+=j),i instanceof ShadowRoot?i=i.host:i=i.parentNode}while(!p&&i!==document.body||p&&(t.contains(i)||t===i));return(v&&(Math.abs(f)<1||!a)||!v&&(Math.abs(d)<1||!a))&&(m=!0),m},q=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},Qe=function(e){return[e.deltaX,e.deltaY]},et=function(e){return e&&"current"in e?e.current:e},ur=function(e,t){return e[0]===t[0]&&e[1]===t[1]},dr=function(e){return`
  .block-interactivity-`.concat(e,` {pointer-events: none;}
  .allow-interactivity-`).concat(e,` {pointer-events: all;}
`)},fr=0,B=[];function pr(e){var t=s.useRef([]),n=s.useRef([0,0]),r=s.useRef(),a=s.useState(fr++)[0],c=s.useState(ft)[0],l=s.useRef(e);s.useEffect(function(){l.current=e},[e]),s.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(a));var u=Pn([e.lockRef.current],(e.shards||[]).map(et),!0).filter(Boolean);return u.forEach(function(x){return x.classList.add("allow-interactivity-".concat(a))}),function(){document.body.classList.remove("block-interactivity-".concat(a)),u.forEach(function(x){return x.classList.remove("allow-interactivity-".concat(a))})}}},[e.inert,e.lockRef.current,e.shards]);var i=s.useCallback(function(u,x){if("touches"in u&&u.touches.length===2||u.type==="wheel"&&u.ctrlKey)return!l.current.allowPinchZoom;var y=q(u),N=n.current,w="deltaX"in u?u.deltaX:N[0]-y[0],g="deltaY"in u?u.deltaY:N[1]-y[1],h,S=u.target,E=Math.abs(w)>Math.abs(g)?"h":"v";if("touches"in u&&E==="h"&&S.type==="range")return!1;var C=Je(E,S);if(!C)return!0;if(C?h=E:(h=E==="v"?"h":"v",C=Je(E,S)),!C)return!1;if(!r.current&&"changedTouches"in u&&(w||g)&&(r.current=h),!h)return!0;var T=r.current||h;return lr(T,x,u,T==="h"?w:g,!0)},[]),p=s.useCallback(function(u){var x=u;if(!(!B.length||B[B.length-1]!==c)){var y="deltaY"in x?Qe(x):q(x),N=t.current.filter(function(h){return h.name===x.type&&(h.target===x.target||x.target===h.shadowParent)&&ur(h.delta,y)})[0];if(N&&N.should){x.cancelable&&x.preventDefault();return}if(!N){var w=(l.current.shards||[]).map(et).filter(Boolean).filter(function(h){return h.contains(x.target)}),g=w.length>0?i(x,w[0]):!l.current.noIsolation;g&&x.cancelable&&x.preventDefault()}}},[]),m=s.useCallback(function(u,x,y,N){var w={name:u,delta:x,target:y,should:N,shadowParent:hr(y)};t.current.push(w),setTimeout(function(){t.current=t.current.filter(function(g){return g!==w})},1)},[]),v=s.useCallback(function(u){n.current=q(u),r.current=void 0},[]),f=s.useCallback(function(u){m(u.type,Qe(u),u.target,i(u,e.lockRef.current))},[]),d=s.useCallback(function(u){m(u.type,q(u),u.target,i(u,e.lockRef.current))},[]);s.useEffect(function(){return B.push(c),e.setCallbacks({onScrollCapture:f,onWheelCapture:f,onTouchMoveCapture:d}),document.addEventListener("wheel",p,W),document.addEventListener("touchmove",p,W),document.addEventListener("touchstart",v,W),function(){B=B.filter(function(u){return u!==c}),document.removeEventListener("wheel",p,W),document.removeEventListener("touchmove",p,W),document.removeEventListener("touchstart",v,W)}},[]);var b=e.removeScrollBar,j=e.inert;return s.createElement(s.Fragment,null,j?s.createElement(c,{styles:dr(a)}):null,b?s.createElement(nr,{gapMode:e.gapMode}):null)}function hr(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const mr=Un(dt,pr);var gt=s.forwardRef(function(e,t){return s.createElement(ce,A({},e,{ref:t,sideCar:mr}))});gt.classNames=ce.classNames;var gr=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},U=new WeakMap,Z=new WeakMap,J={},ge=0,vt=function(e){return e&&(e.host||vt(e.parentNode))},vr=function(e,t){return t.map(function(n){if(e.contains(n))return n;var r=vt(n);return r&&e.contains(r)?r:(console.error("aria-hidden",n,"in not contained inside",e,". Doing nothing"),null)}).filter(function(n){return!!n})},xr=function(e,t,n,r){var a=vr(t,Array.isArray(e)?e:[e]);J[n]||(J[n]=new WeakMap);var c=J[n],l=[],i=new Set,p=new Set(a),m=function(f){!f||i.has(f)||(i.add(f),m(f.parentNode))};a.forEach(m);var v=function(f){!f||p.has(f)||Array.prototype.forEach.call(f.children,function(d){if(i.has(d))v(d);else try{var b=d.getAttribute(r),j=b!==null&&b!=="false",u=(U.get(d)||0)+1,x=(c.get(d)||0)+1;U.set(d,u),c.set(d,x),l.push(d),u===1&&j&&Z.set(d,!0),x===1&&d.setAttribute(n,"true"),j||d.setAttribute(r,"true")}catch(y){console.error("aria-hidden: cannot operate on ",d,y)}})};return v(t),i.clear(),ge++,function(){l.forEach(function(f){var d=U.get(f)-1,b=c.get(f)-1;U.set(f,d),c.set(f,b),d||(Z.has(f)||f.removeAttribute(r),Z.delete(f)),b||f.removeAttribute(n)}),ge--,ge||(U=new WeakMap,U=new WeakMap,Z=new WeakMap,J={})}},br=function(e,t,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),a=gr(e);return a?(r.push.apply(r,Array.from(a.querySelectorAll("[aria-live]"))),xr(r,a,n,"aria-hidden")):function(){return null}},Ce="Dialog",[xt,xo]=rt(Ce),[yr,_]=xt(Ce),bt=e=>{const{__scopeDialog:t,children:n,open:r,defaultOpen:a,onOpenChange:c,modal:l=!0}=e,i=s.useRef(null),p=s.useRef(null),[m=!1,v]=ot({prop:r,defaultProp:a,onChange:c});return o.jsx(yr,{scope:t,triggerRef:i,contentRef:p,contentId:le(),titleId:le(),descriptionId:le(),open:m,onOpenChange:v,onOpenToggle:s.useCallback(()=>v(f=>!f),[v]),modal:l,children:n})};bt.displayName=Ce;var yt="DialogTrigger",wr=s.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,a=_(yt,n),c=K(t,a.triggerRef);return o.jsx(O.button,{type:"button","aria-haspopup":"dialog","aria-expanded":a.open,"aria-controls":a.contentId,"data-state":Ee(a.open),...r,ref:c,onClick:M(e.onClick,a.onOpenToggle)})});wr.displayName=yt;var Se="DialogPortal",[Nr,wt]=xt(Se,{forceMount:void 0}),Nt=e=>{const{__scopeDialog:t,forceMount:n,children:r,container:a}=e,c=_(Se,t);return o.jsx(Nr,{scope:t,forceMount:n,children:s.Children.map(r,l=>o.jsx(se,{present:n||c.open,children:o.jsx(un,{asChild:!0,container:a,children:l})}))})};Nt.displayName=Se;var ae="DialogOverlay",Ct=s.forwardRef((e,t)=>{const n=wt(ae,e.__scopeDialog),{forceMount:r=n.forceMount,...a}=e,c=_(ae,e.__scopeDialog);return c.modal?o.jsx(se,{present:r||c.open,children:o.jsx(Cr,{...a,ref:t})}):null});Ct.displayName=ae;var Cr=s.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,a=_(ae,n);return o.jsx(gt,{as:sn,allowPinchZoom:!0,shards:[a.contentRef],children:o.jsx(O.div,{"data-state":Ee(a.open),...r,ref:t,style:{pointerEvents:"auto",...r.style}})})}),L="DialogContent",St=s.forwardRef((e,t)=>{const n=wt(L,e.__scopeDialog),{forceMount:r=n.forceMount,...a}=e,c=_(L,e.__scopeDialog);return o.jsx(se,{present:r||c.open,children:c.modal?o.jsx(Sr,{...a,ref:t}):o.jsx(jr,{...a,ref:t})})});St.displayName=L;var Sr=s.forwardRef((e,t)=>{const n=_(L,e.__scopeDialog),r=s.useRef(null),a=K(t,n.contentRef,r);return s.useEffect(()=>{const c=r.current;if(c)return br(c)},[]),o.jsx(jt,{...e,ref:a,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:M(e.onCloseAutoFocus,c=>{var l;c.preventDefault(),(l=n.triggerRef.current)==null||l.focus()}),onPointerDownOutside:M(e.onPointerDownOutside,c=>{const l=c.detail.originalEvent,i=l.button===0&&l.ctrlKey===!0;(l.button===2||i)&&c.preventDefault()}),onFocusOutside:M(e.onFocusOutside,c=>c.preventDefault())})}),jr=s.forwardRef((e,t)=>{const n=_(L,e.__scopeDialog),r=s.useRef(!1),a=s.useRef(!1);return o.jsx(jt,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:c=>{var l,i;(l=e.onCloseAutoFocus)==null||l.call(e,c),c.defaultPrevented||(r.current||(i=n.triggerRef.current)==null||i.focus(),c.preventDefault()),r.current=!1,a.current=!1},onInteractOutside:c=>{var p,m;(p=e.onInteractOutside)==null||p.call(e,c),c.defaultPrevented||(r.current=!0,c.detail.originalEvent.type==="pointerdown"&&(a.current=!0));const l=c.target;((m=n.triggerRef.current)==null?void 0:m.contains(l))&&c.preventDefault(),c.detail.originalEvent.type==="focusin"&&a.current&&c.preventDefault()}})}),jt=s.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:a,onCloseAutoFocus:c,...l}=e,i=_(L,n),p=s.useRef(null),m=K(t,p);return An(),o.jsxs(o.Fragment,{children:[o.jsx(ct,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:a,onUnmountAutoFocus:c,children:o.jsx(cn,{role:"dialog",id:i.contentId,"aria-describedby":i.descriptionId,"aria-labelledby":i.titleId,"data-state":Ee(i.open),...l,ref:m,onDismiss:()=>i.onOpenChange(!1)})}),o.jsxs(o.Fragment,{children:[o.jsx(Er,{titleId:i.titleId}),o.jsx(Rr,{contentRef:p,descriptionId:i.descriptionId})]})]})}),je="DialogTitle",Et=s.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,a=_(je,n);return o.jsx(O.h2,{id:a.titleId,...r,ref:t})});Et.displayName=je;var kt="DialogDescription",Rt=s.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,a=_(kt,n);return o.jsx(O.p,{id:a.descriptionId,...r,ref:t})});Rt.displayName=kt;var It="DialogClose",Dt=s.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,a=_(It,n);return o.jsx(O.button,{type:"button",...r,ref:t,onClick:M(e.onClick,()=>a.onOpenChange(!1))})});Dt.displayName=It;function Ee(e){return e?"open":"closed"}var _t="DialogTitleWarning",[bo,Tt]=ln(_t,{contentName:L,titleName:je,docsSlug:"dialog"}),Er=({titleId:e})=>{const t=Tt(_t),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.

If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component.

For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return s.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},kr="DialogDescriptionWarning",Rr=({contentRef:e,descriptionId:t})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${Tt(kr).contentName}}.`;return s.useEffect(()=>{var c;const a=(c=e.current)==null?void 0:c.getAttribute("aria-describedby");t&&a&&(document.getElementById(t)||console.warn(r))},[r,e,t]),null},Ir=bt,Dr=Nt,At=Ct,Pt=St,Ft=Et,Ot=Rt,_r=Dt;const Tr=Ir,Ar=Dr,Mt=s.forwardRef(({className:e,...t},n)=>o.jsx(At,{ref:n,className:k("fixed inset-0 z-50 bg-black/80  data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...t}));Mt.displayName=At.displayName;const Lt=s.forwardRef(({className:e,children:t,...n},r)=>o.jsxs(Ar,{children:[o.jsx(Mt,{}),o.jsxs(Pt,{ref:r,className:k("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",e),...n,children:[t,o.jsxs(_r,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",children:[o.jsx(dn,{className:"h-4 w-4"}),o.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));Lt.displayName=Pt.displayName;const Ht=({className:e,...t})=>o.jsx("div",{className:k("flex flex-col space-y-1.5 text-center sm:text-left",e),...t});Ht.displayName="DialogHeader";const Pr=s.forwardRef(({className:e,...t},n)=>o.jsx(Ft,{ref:n,className:k("text-lg font-semibold leading-none tracking-tight",e),...t}));Pr.displayName=Ft.displayName;const Fr=s.forwardRef(({className:e,...t},n)=>o.jsx(Ot,{ref:n,className:k("text-sm text-muted-foreground",e),...t}));Fr.displayName=Ot.displayName;function Or({extensions:e,defaultPath:t="",onSelect:n}){const[r,a]=s.useState([]),[c,l]=s.useState("."),[i,p]=s.useState(t);s.useEffect(()=>{re("/get_os_sep",{method:"GET"}).then(f=>f.text()).then(f=>{l(f)}),m(i)},[]);const m=f=>{re("/file_picker/list_files",{method:"POST",body:JSON.stringify({path:f,extensions:e})}).then(d=>d.json()).then(d=>{p(d.path),a(d.items)})},v=f=>{const d=i.split(c).slice(0,f+1).join(c);m(d)};return o.jsxs(R,{children:[o.jsxs(I,{className:"gap-4 mb-3",children:[o.jsx("p",{className:"text-xl font-semibold",children:"Choose File"}),o.jsx("p",{className:"text-sm text-muted-foreground",children:e==null?void 0:e.join(", ")})]}),o.jsx(I,{children:i.split(c).map((f,d)=>o.jsxs(I,{className:"mb-2",children:[o.jsx(oe,{variant:"link",className:"px-0 text-lg",onClick:()=>v(d),children:f}),o.jsx("span",{className:"px-1",children:d<i.split(c).length-1&&c})]},d))}),o.jsx(R,{className:"overflow-y-auto h-[70vh]",children:r.map(f=>f.type==="file"?o.jsx(Lr,{file:f,onClick:()=>n(f)},f.name):o.jsxs(I,{className:"cursor-pointer gap-1 hover:bg-secondary py-[1px]",onClick:()=>m(f.path),children:[o.jsx(mn,{size:16}),o.jsx("span",{children:f.name})]},f.name))})]})}const Mr=["jpg","jpeg","png","gif","bmp","tiff","webp"];function Lr({file:e,onClick:t}){const n=Mr.includes(e.name.split(".").pop()||"");return o.jsxs(I,{className:"gap-1 cursor-pointer hover:bg-secondary",onClick:t,children:[n&&o.jsx("img",{src:G+`/preview_image?path=${encodeURIComponent(e.path)}`,alt:e.name,className:"w-10 h-10 object-contain",style:{width:"50px",height:"50px",objectFit:"contain"}}),o.jsx("span",{children:e.name})]})}function Hr({onClose:e,extensions:t,defaultPath:n="",onSelect:r}){return o.jsx(Tr,{onOpenChange:e,open:!0,children:o.jsx(Lt,{className:"sm:max-w-[50vw]","aria-describedby":"Choose File",children:o.jsx(Ht,{children:o.jsx(Or,{extensions:t,defaultPath:n,onSelect:r})})})})}const zr=["png","jpg","jpeg","gif","bmp","tiff","webp"];function Wr(e){return zr.includes(e.split(".").pop()??"")}function Br(e){return/[\/\\]([^\/\\]+\.(png|jpg|jpeg|gif|bmp|tiff|webp))$/i.test(e)}function Ur({input:e,extensions:t,nodeID:n}){const{updateValues:r,values:a}=H(z(m=>({values:m.values,updateValues:m.updateValues})));we();const[c,l]=s.useState(!1),i=a[D("input",n,e.id)],p=i==null?void 0:i.split(xe.osSep).pop();return o.jsxs(R,{className:"px-1 w-full",children:[o.jsx(oe,{onClick:()=>l(!0),className:"mb-2",children:"Choose file"}),i&&o.jsxs(R,{children:[Wr(i)&&o.jsx("img",{src:G+`/preview_image?path=${encodeURIComponent(i)}`,alt:p,className:"object-contain max-w-[360px] max-h-[360px]",style:{objectFit:"contain"}}),o.jsxs(I,{className:"gap-2",children:[o.jsx("p",{className:"text-sm break-all",children:p}),o.jsx(oe,{variant:"secondary",className:"p-[1px] w-5 h-5",onClick:()=>{r({[D("input",n,e.id)]:void 0})},children:o.jsx(wn,{size:15})})]})]}),c&&o.jsx(Hr,{extensions:t,onClose:()=>l(!1),onSelect:m=>{l(!1),r({[D("input",n,e.id)]:m.rel_path})}})]})}function $r(e){const t=s.useRef({value:e,previous:e});return s.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}function Vr(e){const[t,n]=s.useState(void 0);return nt(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const r=new ResizeObserver(a=>{if(!Array.isArray(a)||!a.length)return;const c=a[0];let l,i;if("borderBoxSize"in c){const p=c.borderBoxSize,m=Array.isArray(p)?p[0]:p;l=m.inlineSize,i=m.blockSize}else l=e.offsetWidth,i=e.offsetHeight;n({width:l,height:i})});return r.observe(e,{box:"border-box"}),()=>r.unobserve(e)}else n(void 0)},[e]),t}var ke="Checkbox",[Xr,yo]=rt(ke),[Gr,Kr]=Xr(ke),zt=s.forwardRef((e,t)=>{const{__scopeCheckbox:n,name:r,checked:a,defaultChecked:c,required:l,disabled:i,value:p="on",onCheckedChange:m,form:v,...f}=e,[d,b]=s.useState(null),j=K(t,g=>b(g)),u=s.useRef(!1),x=d?v||!!d.closest("form"):!0,[y=!1,N]=ot({prop:a,defaultProp:c,onChange:m}),w=s.useRef(y);return s.useEffect(()=>{const g=d==null?void 0:d.form;if(g){const h=()=>N(w.current);return g.addEventListener("reset",h),()=>g.removeEventListener("reset",h)}},[d,N]),o.jsxs(Gr,{scope:n,state:y,disabled:i,children:[o.jsx(O.button,{type:"button",role:"checkbox","aria-checked":F(y)?"mixed":y,"aria-required":l,"data-state":Ut(y),"data-disabled":i?"":void 0,disabled:i,value:p,...f,ref:j,onKeyDown:M(e.onKeyDown,g=>{g.key==="Enter"&&g.preventDefault()}),onClick:M(e.onClick,g=>{N(h=>F(h)?!0:!h),x&&(u.current=g.isPropagationStopped(),u.current||g.stopPropagation())})}),x&&o.jsx(Yr,{control:d,bubbles:!u.current,name:r,value:p,checked:y,required:l,disabled:i,form:v,style:{transform:"translateX(-100%)"},defaultChecked:F(c)?!1:c})]})});zt.displayName=ke;var Wt="CheckboxIndicator",Bt=s.forwardRef((e,t)=>{const{__scopeCheckbox:n,forceMount:r,...a}=e,c=Kr(Wt,n);return o.jsx(se,{present:r||F(c.state)||c.state===!0,children:o.jsx(O.span,{"data-state":Ut(c.state),"data-disabled":c.disabled?"":void 0,...a,ref:t,style:{pointerEvents:"none",...e.style}})})});Bt.displayName=Wt;var Yr=e=>{const{control:t,checked:n,bubbles:r=!0,defaultChecked:a,...c}=e,l=s.useRef(null),i=$r(n),p=Vr(t);s.useEffect(()=>{const v=l.current,f=window.HTMLInputElement.prototype,b=Object.getOwnPropertyDescriptor(f,"checked").set;if(i!==n&&b){const j=new Event("click",{bubbles:r});v.indeterminate=F(n),b.call(v,F(n)?!1:n),v.dispatchEvent(j)}},[i,n,r]);const m=s.useRef(F(n)?!1:n);return o.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:a??m.current,...c,tabIndex:-1,ref:l,style:{...e.style,...p,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})};function F(e){return e==="indeterminate"}function Ut(e){return F(e)?"indeterminate":e?"checked":"unchecked"}var $t=zt,qr=Bt;const Vt=s.forwardRef(({className:e,...t},n)=>o.jsx($t,{ref:n,className:k("peer h-4 w-4 shrink-0 rounded-sm border border-primary ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",e),...t,children:o.jsx(qr,{className:k("flex items-center justify-center text-current"),children:o.jsx(gn,{className:"h-4 w-4"})})}));Vt.displayName=$t.displayName;const tt="8",ye="000";function Xt(e){return o.jsx(ve,{style:{width:`${tt}px`,height:`${tt}px`},...e})}function Zr({input:e,nodeID:t,isConnected:n}){const r=e.type==="int"||e.type==="float",a=e.widget;return o.jsx(R,{className:`flex w-full ${r?"h-10":""}`,children:o.jsxs(I,{className:"gap-2 w-full",children:[!e.hide_handle&&o.jsxs("div",{className:"relative flex items-center gap-1",children:[o.jsx(Xt,{type:"target",position:Q.Left,id:e.id}),o.jsx("span",{className:"text-sm font-semibold ml-2",children:e.name}),typeof e.type=="string"&&o.jsx("span",{className:"text-[10px] text-zinc-500 italic",children:e.type.split("[")[0]})]}),a?o.jsx(Jr,{input:e,nodeID:t}):!n&&o.jsx(Qr,{input:e,nodeID:t})]})},"input"+e.id)}function Jr({input:e,nodeID:t}){var n,r;if(((n=e.widget)==null?void 0:n.type)==="server_file_picker")return o.jsx(Ur,{input:e,extensions:(r=e.widget.options)==null?void 0:r.extensions,nodeID:t})}function Qr({input:e,nodeID:t}){const{updateValues:n,values:r}=H(z(l=>({values:l.values,updateValues:l.updateValues}))),a=s.useRef(null),c=we();if(s.useEffect(()=>{if(e.type!=="str")return;const l=a.current;if(!l)return;const i=()=>{l.style.height="auto",l.style.height=`${l.scrollHeight}px`,c(t)};return i(),l.addEventListener("input",i),()=>{l.removeEventListener("input",i)}},[e.type,t,c,r[D("input",t,e.id)]]),e.type==="int"||e.type==="float")return o.jsx(Cn,{input:e,nodeID:t});if(e.type==="bool")return o.jsx(Vt,{className:"mx-4",checked:r[D("input",t,e.id)]??!1,onCheckedChange:l=>{console.log("checked",l),n({[D("input",t,e.id)]:l.valueOf()})}});if(Array.isArray(e.type))return o.jsx("select",{id:"countries",value:r[D("input",t,e.id)]??"",onChange:l=>{n({[D("input",t,e.id)]:l.target.value})},className:"bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg block w-full p-2 dark:bg-zinc-700 dark:border-zinc-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500",children:e.type.map(l=>o.jsx("option",{value:l,children:l},l))});if(e.type==="str")return o.jsx(st,{ref:a,value:r[D("input",t,e.id)]??"",className:"border-zinc-700 py-1 flex-1 flex-grow nodrag nopan resize-none",style:{height:"auto",overflow:"hidden"},onChange:l=>{n({[D("input",t,e.id)]:l.target.value})}})}function eo({children:e}){const t=s.useRef(null),[n,r]=s.useState(100);return s.useEffect(()=>{var a;(a=t.current)!=null&&a.offsetHeight&&r(t.current.offsetHeight)},[]),o.jsxs("div",{className:"group h-full",children:[o.jsx(Jt,{className:"!w-3 !h-3 !translate-x-[-30%] !translate-y-[-30%] !bg-transparent !border-none group",minWidth:150,minHeight:n,children:o.jsx(bn,{size:10,className:"hidden group-hover:block absolute bottom-0 right-0"})}),o.jsx("div",{className:"h-full",ref:t,children:e})]})}var ne=(e=>(e.RUNNING="RUNNING",e.SUCCESS="SUCCESS",e.FAIL="FAIL",e))(ne||{});function to({output:e,nodeID:t,status:n}){const r=n==null?void 0:n.results;return r?o.jsxs(R,{className:"text-left m-2 gap-[1px]",children:[o.jsxs(I,{className:"gap-1 items-center mb-1",children:[o.jsx("p",{className:"text-[10px] text-muted-foreground ",children:"Outputs"}),(n==null?void 0:n.status)===ne.RUNNING&&o.jsx(at,{className:"w-4 h-4"}),(n==null?void 0:n.status)===ne.SUCCESS&&o.jsx(yn,{className:"w-4 h-4 text-green-500"}),(n==null?void 0:n.status)===ne.FAIL&&o.jsx(Nn,{className:"w-4 h-4 text-red-500"})]}),r==null?void 0:r.map((a,c)=>o.jsx(R,{children:o.jsxs(R,{className:"text-sm p-1 gap-1 rounded-md border border-zinc-600 bg-zinc-700",children:[typeof a=="object"?o.jsx("pre",{className:"whitespace-pre-wrap",children:JSON.stringify(a,null,2)}):o.jsx("pre",{className:"whitespace-pre-wrap break-all",children:a}),typeof a=="string"&&Br(a)&&o.jsxs(R,{className:"gap-1 justify-center items-center",children:[o.jsx("img",{src:G+`/preview_image?path=${encodeURIComponent(a)}`,alt:"image",className:"object-contain cursor-pointer w-full max-w-[500px] max-h-[500px]",style:{flex:1,objectFit:"contain"},onClick:()=>{window.open(G+`/preview_image?path=${encodeURIComponent(a)}`,"_blank")}}),o.jsx(oe,{className:"w-full",onClick:()=>{window.open(G+`/preview_image?path=${encodeURIComponent(a)}&download=1`,"_blank")},children:"Download"})]})]})},c)),(n==null?void 0:n.error)&&o.jsx(R,{children:o.jsx("div",{className:"text-sm p-1 rounded-md border bg-destructive",children:o.jsx("pre",{className:"whitespace-pre-wrap break-all",children:n==null?void 0:n.error})})})]}):null}function no({data:e,id:t}){var l,i;const{selectedNodeIDs:n,edges:r,status:a}=H(z(p=>{var m,v;return{selectedNodeIDs:p.selectedNodeIDs,edges:p.edges,status:(v=(m=p.job_status)==null?void 0:m.nodes)==null?void 0:v[t]}})),c=we();return s.useEffect(()=>{c(t)},[a,r,t,c]),o.jsx(eo,{children:o.jsxs("div",{className:"h-full flex flex-col min-w-[120px]",children:[o.jsxs("div",{className:"h-4 flex justify-end",children:[e.import_error&&o.jsxs("p",{className:"text-[10px] font-bold px-2",children:[o.jsx("span",{className:"text-red-500",children:" ❌ Import Failed: "}),o.jsx("span",{children:e.import_error})]}),o.jsxs("p",{className:"text-[10px] text-muted-foreground italic px-2 w-fit text-right",children:["#",t]})]}),o.jsxs(R,{className:`flex-1 bg-zinc-800 rounded-md ${n.includes(t)?"outline outline-[0.8px] outline-zinc-300":(a==null?void 0:a.status)==="RUNNING"?"outline outline-2 outline-purple-500":""}`,children:[o.jsxs(I,{className:`relative py-1 ${e.import_error?"bg-red-500":"bg-gray-700"} rounded-t-md justify-between`,children:[o.jsx(ve,{type:"target",position:Q.Left,id:"000"}),o.jsx(I,{className:"justify-between  flex-grow",children:o.jsx("p",{className:"px-2 font-semibold",children:e.node_title??e.name})}),o.jsx(ve,{type:"source",position:Q.Right,id:ye})]}),o.jsxs(I,{className:"flex justify-between py-2 h-full",children:[o.jsx("div",{className:"flex flex-col gap-2 h-full w-full pr-2",children:(l=e.input)==null?void 0:l.map(p=>{const m=r.some(v=>v.target===t&&v.targetHandle===p.id);return o.jsx(Zr,{input:p,nodeID:t,isConnected:m},p.id)})}),o.jsx(R,{className:"flex flex-col justify-center ml-2 gap-2",children:(i=e.output)==null?void 0:i.map(p=>{var m;return o.jsxs("div",{className:"relative flex items-center ml-3",children:[o.jsx("p",{className:"text-[10px] text-zinc-500 italic mr-[8px]",children:(m=p.type)==null?void 0:m.split("[")[0]}),o.jsx(Xt,{type:"source",position:Q.Right,id:p.id})]},"output"+p.id)})})]}),o.jsx(to,{nodeID:t,output:e.output??null,status:a??null})]})]})})}function ro(e,t){const[n,r]=s.useState(e);return s.useEffect(()=>{const a=setTimeout(()=>{r(e)},t);return()=>{clearTimeout(a)}},[e,t]),n}const Gt=s.forwardRef(({className:e,...t},n)=>o.jsx("div",{ref:n,className:k("rounded-lg border bg-card text-card-foreground shadow-sm",e),...t}));Gt.displayName="Card";const Kt=s.forwardRef(({className:e,...t},n)=>o.jsx("div",{ref:n,className:k("flex flex-col space-y-1.5 p-6",e),...t}));Kt.displayName="CardHeader";const oo=s.forwardRef(({className:e,...t},n)=>o.jsx("h3",{ref:n,className:k("text-2xl font-semibold leading-none tracking-tight",e),...t}));oo.displayName="CardTitle";const ao=s.forwardRef(({className:e,...t},n)=>o.jsx("p",{ref:n,className:k("text-sm text-muted-foreground",e),...t}));ao.displayName="CardDescription";const Yt=s.forwardRef(({className:e,...t},n)=>o.jsx("div",{ref:n,className:k("p-6 pt-0",e),...t}));Yt.displayName="CardContent";const so=s.forwardRef(({className:e,...t},n)=>o.jsx("div",{ref:n,className:k("flex items-center p-6 pt-0",e),...t}));so.displayName="CardFooter";const qt=s.forwardRef((e,t)=>o.jsx("div",{ref:t,className:k("text-xs rounded-lg bg-zinc-800 px-2 py-1 font-semibold",e.className),...e}));qt.displayName="Tag";function co({showSearch:e}){const{addNode:t,setShowSearch:n,addEdge:r}=H(z(d=>({addNode:d.addNode,setShowSearch:d.setShowSearch,addEdge:d.addEdge}))),[a,c]=s.useState(""),l=ro(a,300),[i,p]=s.useState([]),[m,v]=s.useState(!1);s.useEffect(()=>{v(!0),re("/search_functions?query="+encodeURIComponent(l)).then(d=>d.json()).then(d=>{p(d)}).finally(()=>v(!1))},[l]);const f=d=>{var x,y,N,w,g,h,S,E;const b=t({data:d,position:{x:e.mouseX,y:e.mouseY},type:"astFunction"}),j=((y=(x=b.data.input)==null?void 0:x.filter(C=>{var T;return C.type===((T=e.connectFrom)==null?void 0:T.handleType)&&!C.hide_handle}))==null?void 0:y[0])??((w=(N=b.data.input)==null?void 0:N.filter(C=>!C.hide_handle))==null?void 0:w[0]),u=((h=(g=b.data.output)==null?void 0:g.filter(C=>{var T;return C.type===((T=e.connectFrom)==null?void 0:T.handleType)&&!C.hide_handle}))==null?void 0:h[0])??((E=(S=b.data.output)==null?void 0:S.filter(C=>!C.hide_handle))==null?void 0:E[0]);if(e.connectFrom){const C={source:e.connectFrom.source??b.id,target:e.connectFrom.target??b.id,sourceHandle:e.connectFrom.sourceHandle??(u==null?void 0:u.id)??ye,targetHandle:e.connectFrom.targetHandle??(j==null?void 0:j.id)??ye};console.log("adding edge",C),r({id:C.source+"_"+C.target+"_"+C.sourceHandle+"_"+C.targetHandle,...C})}n(null)};return o.jsxs(Gt,{className:"sm:w-[60vw] w-[90vw] max-w-[700px]",style:{position:"fixed",top:"50%",left:"50%",transform:"translate(-50%, -50%)"},children:[o.jsxs(Kt,{className:"p-2 text-lg mb-2 relative",children:[o.jsx(Ne,{placeholder:"Search for functions and nodes",autoFocus:!0,value:a,onChange:d=>c(d.target.value)}),m&&o.jsx(at,{className:"w-4 h-4 absolute top-2 right-2"})]}),o.jsxs(Yt,{className:"h-[60vh] overflow-y-auto px-3",children:[o.jsx(R,{className:"",children:i.map((d,b)=>d&&o.jsxs(I,{className:"justify-between flex-wrap hover:bg-muted py-2 cursor-pointer",onClick:()=>f(d),children:[o.jsx("p",{children:d.name}),o.jsxs(I,{className:"gap-2",children:[o.jsx("p",{className:"text-muted-foreground text-sm",children:d.file_path??d.module}),o.jsx(qt,{children:d.type})]})]},`${d.type}-${d.name}-${b}`))}),i.length===0&&o.jsx("p",{children:"No results found"})]})]})}const io=e=>({nodes:e.nodes,edges:e.edges,onNodesChange:e.onNodesChange,onEdgesChange:e.onEdgesChange,setJobStatus:e.setJobStatus,onConnect:e.onConnect,addNode:e.addNode,loadGraph:e.loadGraph,setSelectedNodeIDs:e.setSelectedNodeIDs,setShowSearch:e.setShowSearch}),lo={astFunction:no};function uo(){const{theme:e}=fn(),{screenToFlowPosition:t}=en(),{dropingNode:n,setDropingNode:r}=pn(),{nodes:a,edges:c,onNodesChange:l,onEdgesChange:i,onConnect:p,addNode:m,loadGraph:v,setSelectedNodeIDs:f,setJobStatus:d,setShowSearch:b}=H(z(io));s.useEffect(()=>{const g=sessionStorage.getItem(hn);g&&(v(JSON.parse(g)),re("/refresh_node_def",{method:"POST",body:g}).then(S=>S.json()).then(S=>{v(S)})),console.log("connecting to websocket",xe.wsUrl);const h=new WebSocket(xe.wsUrl);return h.onopen=()=>{console.log("websocket connected")},h.onmessage=S=>{const E=JSON.parse(S.data);window.dispatchEvent(new CustomEvent("message",{detail:E})),console.log("message",E),E.type==="job_status"&&E.data&&d(E.data)},()=>{h.close()}},[]);const j=s.useCallback(g=>{g.preventDefault(),g.dataTransfer.dropEffect="move"},[]),u=s.useRef(0),x=s.useRef(0),y=s.useCallback(g=>{if(g.preventDefault(),!n)return;const h=t({x:g.clientX,y:g.clientY});m({data:n,position:h,type:"astFunction"}),r(null)},[t,n]),N=s.useCallback(g=>{const h=t({x:g.clientX,y:g.clientY});f([]);const S=Date.now();u.current&&S-u.current<300?b({mouseX:h.x,mouseY:h.y}):S-x.current>300&&b(null),u.current=S},[]),w=s.useCallback((g,h)=>{var Re,Ie,De,_e,Te,Ae,Pe,Fe,Oe,Me,Le,He,ze,We;if(x.current=Date.now(),h.isValid)return;if(!((Re=h.to)!=null&&Re.x)||!((Ie=h.to)!=null&&Ie.x))throw new Error("onConnectEnd No position found!");const S=t({x:(De=h.to)==null?void 0:De.x,y:(_e=h.to)==null?void 0:_e.y}),E=(Te=h.fromNode)==null?void 0:Te.data,C=(Ae=h.toNode)==null?void 0:Ae.data,T=(Fe=(Pe=E==null?void 0:E.output)==null?void 0:Pe.find(ie=>{var X;return ie.id===((X=h.fromHandle)==null?void 0:X.id)}))==null?void 0:Fe.type,Zt=(Me=(Oe=C==null?void 0:C.input)==null?void 0:Oe.find(ie=>{var X;return ie.id===((X=h.toHandle)==null?void 0:X.id)}))==null?void 0:Me.type;console.log("onconnectend",h),b({mouseX:S.x,mouseY:S.y,connectFrom:{source:(Le=h.fromNode)==null?void 0:Le.id,sourceHandle:((He=h.fromHandle)==null?void 0:He.id)??void 0,target:(ze=h.toNode)==null?void 0:ze.id,targetHandle:((We=h.toHandle)==null?void 0:We.id)??void 0,handleType:T??Zt}})},[]);return o.jsxs(tn,{nodes:a,nodeTypes:lo,edges:c,colorMode:e,onNodesChange:l,onEdgesChange:i,onDrop:y,onDragOver:j,onConnect:p,fitView:!0,fitViewOptions:{padding:.2},defaultEdgeOptions:{style:{strokeWidth:2,stroke:"#9049CF"}},onNodeClick:(g,h)=>{console.log("node click #"+h.id),f([h.id])},onPaneClick:N,onConnectEnd:w,zoomOnDoubleClick:!1,children:[o.jsx(nn,{}),o.jsxs(rn,{orientation:"horizontal",children:[o.jsx(Be,{onClick:$e.undo,children:o.jsx(vn,{size:16,className:"!fill-[none] !max-w-4 !max-h-4"})}),o.jsx(Be,{onClick:$e.redo,children:o.jsx(xn,{size:16,className:"!fill-[none] !max-w-4 !max-h-4"})})]})]})}function wo(){const{showSearch:e}=H(z(t=>({showSearch:t.showSearch})));return o.jsxs(Qt,{children:[o.jsx(uo,{}),e&&o.jsx(co,{showSearch:e})]})}export{uo as FlowCanvas,wo as default};
