@tuongaz/seeflow 0.1.71 → 0.1.74

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -8465,7 +8465,7 @@ Error generating stack: `+a.message+`
8465
8465
  +`).split(`
8466
8466
  `)),h=l.reduce((u,f)=>u.concat(...f),[]);return[l,h]}return[[],[]]},[e]);return m.useEffect(()=>{const c=(t==null?void 0:t.target)??IB,l=(t==null?void 0:t.actInsideInputWithModifier)??!0;if(e!==null){const h=y=>{var w,g;if(r.current=y.ctrlKey||y.metaKey||y.shiftKey||y.altKey,(!r.current||r.current&&!l)&&sY(y))return!1;const x=AB(y.code,s);if(a.current.add(y[x]),NB(i,a.current,!1)){const M=((g=(w=y.composedPath)==null?void 0:w.call(y))==null?void 0:g[0])||y.target,v=(M==null?void 0:M.nodeName)==="BUTTON"||(M==null?void 0:M.nodeName)==="A";t.preventDefault!==!1&&(r.current||!v)&&y.preventDefault(),o(!0)}},u=y=>{const k=AB(y.code,s);NB(i,a.current,!0)?(o(!1),a.current.clear()):a.current.delete(y[k]),y.key==="Meta"&&a.current.clear(),r.current=!1},f=()=>{a.current.clear(),o(!1)};return c==null||c.addEventListener("keydown",h),c==null||c.addEventListener("keyup",u),window.addEventListener("blur",f),window.addEventListener("contextmenu",f),()=>{c==null||c.removeEventListener("keydown",h),c==null||c.removeEventListener("keyup",u),window.removeEventListener("blur",f),window.removeEventListener("contextmenu",f)}}},[e,o]),n}function NB(e,t,n){return e.filter(o=>n||o.length===t.size).some(o=>o.every(r=>t.has(r)))}function AB(e,t){return t.includes(e)?"code":"key"}const Nje=()=>{const e=wt();return m.useMemo(()=>({zoomIn:t=>{const{panZoom:n}=e.getState();return n?n.scaleBy(1.2,t):Promise.resolve(!1)},zoomOut:t=>{const{panZoom:n}=e.getState();return n?n.scaleBy(1/1.2,t):Promise.resolve(!1)},zoomTo:(t,n)=>{const{panZoom:o}=e.getState();return o?o.scaleTo(t,n):Promise.resolve(!1)},getZoom:()=>e.getState().transform[2],setViewport:async(t,n)=>{const{transform:[o,r,a],panZoom:i}=e.getState();return i?(await i.setViewport({x:t.x??o,y:t.y??r,zoom:t.zoom??a},n),Promise.resolve(!0)):Promise.resolve(!1)},getViewport:()=>{const[t,n,o]=e.getState().transform;return{x:t,y:n,zoom:o}},setCenter:async(t,n,o)=>e.getState().setCenter(t,n,o),fitBounds:async(t,n)=>{const{width:o,height:r,minZoom:a,maxZoom:i,panZoom:s}=e.getState(),c=tO(t,o,r,a,i,(n==null?void 0:n.padding)??.1);return s?(await s.setViewport(c,{duration:n==null?void 0:n.duration,ease:n==null?void 0:n.ease,interpolate:n==null?void 0:n.interpolate}),Promise.resolve(!0)):Promise.resolve(!1)},screenToFlowPosition:(t,n={})=>{const{transform:o,snapGrid:r,snapToGrid:a,domNode:i}=e.getState();if(!i)return t;const{x:s,y:c}=i.getBoundingClientRect(),l={x:t.x-s,y:t.y-c},h=n.snapGrid??r,u=n.snapToGrid??a;return Oh(l,o,u,h)},flowToScreenPosition:t=>{const{transform:n,domNode:o}=e.getState();if(!o)return t;const{x:r,y:a}=o.getBoundingClientRect(),i=Cj(t,n);return{x:i.x+r,y:i.y+a}}}),[])};function $Y(e,t){const n=[],o=new Map,r=[];for(const a of e)if(a.type==="add"){r.push(a);continue}else if(a.type==="remove"||a.type==="replace")o.set(a.id,[a]);else{const i=o.get(a.id);i?i.push(a):o.set(a.id,[a])}for(const a of t){const i=o.get(a.id);if(!i){n.push(a);continue}if(i[0].type==="remove")continue;if(i[0].type==="replace"){n.push({...i[0].item});continue}const s={...a};for(const c of i)Aje(c,s);n.push(s)}return r.length&&r.forEach(a=>{a.index!==void 0?n.splice(a.index,0,{...a.item}):n.push({...a.item})}),n}function Aje(e,t){switch(e.type){case"select":{t.selected=e.selected;break}case"position":{typeof e.position<"u"&&(t.position=e.position),typeof e.dragging<"u"&&(t.dragging=e.dragging);break}case"dimensions":{typeof e.dimensions<"u"&&(t.measured={...e.dimensions},e.setAttributes&&((e.setAttributes===!0||e.setAttributes==="width")&&(t.width=e.dimensions.width),(e.setAttributes===!0||e.setAttributes==="height")&&(t.height=e.dimensions.height))),typeof e.resizing=="boolean"&&(t.resizing=e.resizing);break}}}function PY(e,t){return $Y(e,t)}function jY(e,t){return $Y(e,t)}function K1(e,t){return{id:e,type:"select",selected:t}}function hu(e,t=new Set,n=!1){const o=[];for(const[r,a]of e){const i=t.has(r);!(a.selected===void 0&&!i)&&a.selected!==i&&(n&&(a.selected=i),o.push(K1(a.id,i)))}return o}function EB({items:e=[],lookup:t}){var r;const n=[],o=new Map(e.map(a=>[a.id,a]));for(const[a,i]of e.entries()){const s=t.get(i.id),c=((r=s==null?void 0:s.internals)==null?void 0:r.userNode)??s;c!==void 0&&c!==i&&n.push({id:i.id,item:i,type:"replace"}),c===void 0&&n.push({item:i,type:"add",index:a})}for(const[a]of t)o.get(a)===void 0&&n.push({id:a,type:"remove"});return n}function $B(e){return{id:e.id,type:"remove"}}const PB=e=>q$e(e),Eje=e=>JX(e);function zY(e){return m.forwardRef(e)}function jB(e){const[t,n]=m.useState(BigInt(0)),[o]=m.useState(()=>$je(()=>n(r=>r+BigInt(1))));return XD(()=>{const r=o.get();r.length&&(e(r),o.reset())},[t]),o}function $je(e){let t=[];return{get:()=>t,reset:()=>{t=[]},push:n=>{t.push(n),e()}}}const RY=m.createContext(null);function Pje({children:e}){const t=wt(),n=m.useCallback(s=>{const{nodes:c=[],setNodes:l,hasDefaultNodes:h,onNodesChange:u,nodeLookup:f,fitViewQueued:y,onNodesChangeMiddlewareMap:k}=t.getState();let x=c;for(const g of s)x=typeof g=="function"?g(x):g;let w=EB({items:x,lookup:f});for(const g of k.values())w=g(w);h&&l(x),w.length>0?u==null||u(w):y&&window.requestAnimationFrame(()=>{const{fitViewQueued:g,nodes:M,setNodes:v}=t.getState();g&&v(M)})},[]),o=jB(n),r=m.useCallback(s=>{const{edges:c=[],setEdges:l,hasDefaultEdges:h,onEdgesChange:u,edgeLookup:f}=t.getState();let y=c;for(const k of s)y=typeof k=="function"?k(y):k;h?l(y):u&&u(EB({items:y,lookup:f}))},[]),a=jB(r),i=m.useMemo(()=>({nodeQueue:o,edgeQueue:a}),[]);return p.jsx(RY.Provider,{value:i,children:e})}function jje(){const e=m.useContext(RY);if(!e)throw new Error("useBatchContext must be used within a BatchProvider");return e}const zje=e=>!!e.panZoom;function Sz(){const e=Nje(),t=wt(),n=jje(),o=Te(zje),r=m.useMemo(()=>{const a=u=>t.getState().nodeLookup.get(u),i=u=>{n.nodeQueue.push(u)},s=u=>{n.edgeQueue.push(u)},c=u=>{var g,M;const{nodeLookup:f,nodeOrigin:y}=t.getState(),k=PB(u)?u:f.get(u.id),x=k.parentId?aY(k.position,k.measured,k.parentId,f,y):k.position,w={...k,position:x,width:((g=k.measured)==null?void 0:g.width)??k.width,height:((M=k.measured)==null?void 0:M.height)??k.height};return Uu(w)},l=(u,f,y={replace:!1})=>{i(k=>k.map(x=>{if(x.id===u){const w=typeof f=="function"?f(x):f;return y.replace&&PB(w)?w:{...x,...w}}return x}))},h=(u,f,y={replace:!1})=>{s(k=>k.map(x=>{if(x.id===u){const w=typeof f=="function"?f(x):f;return y.replace&&Eje(w)?w:{...x,...w}}return x}))};return{getNodes:()=>t.getState().nodes.map(u=>({...u})),getNode:u=>{var f;return(f=a(u))==null?void 0:f.internals.userNode},getInternalNode:a,getEdges:()=>{const{edges:u=[]}=t.getState();return u.map(f=>({...f}))},getEdge:u=>t.getState().edgeLookup.get(u),setNodes:i,setEdges:s,addNodes:u=>{const f=Array.isArray(u)?u:[u];n.nodeQueue.push(y=>[...y,...f])},addEdges:u=>{const f=Array.isArray(u)?u:[u];n.edgeQueue.push(y=>[...y,...f])},toObject:()=>{const{nodes:u=[],edges:f=[],transform:y}=t.getState(),[k,x,w]=y;return{nodes:u.map(g=>({...g})),edges:f.map(g=>({...g})),viewport:{x:k,y:x,zoom:w}}},deleteElements:async({nodes:u=[],edges:f=[]})=>{const{nodes:y,edges:k,onNodesDelete:x,onEdgesDelete:w,triggerNodeChanges:g,triggerEdgeChanges:M,onDelete:v,onBeforeDelete:b}=t.getState(),{nodes:C,edges:_}=await U$e({nodesToRemove:u,edgesToRemove:f,nodes:y,edges:k,onBeforeDelete:b}),S=_.length>0,A=C.length>0;if(S){const P=_.map($B);w==null||w(_),M(P)}if(A){const P=C.map($B);x==null||x(C),g(P)}return(A||S)&&(v==null||v({nodes:C,edges:_})),{deletedNodes:C,deletedEdges:_}},getIntersectingNodes:(u,f=!0,y)=>{const k=lB(u),x=k?u:c(u),w=y!==void 0;return x?(y||t.getState().nodes).filter(g=>{const M=t.getState().nodeLookup.get(g.id);if(M&&!k&&(g.id===u.id||!M.internals.positionAbsolute))return!1;const v=Uu(w?g:M),b=gh(v,x);return f&&b>0||b>=v.width*v.height||b>=x.width*x.height}):[]},isNodeIntersecting:(u,f,y=!0)=>{const x=lB(u)?u:c(u);if(!x)return!1;const w=gh(x,f);return y&&w>0||w>=f.width*f.height||w>=x.width*x.height},updateNode:l,updateNodeData:(u,f,y={replace:!1})=>{l(u,k=>{const x=typeof f=="function"?f(k):f;return y.replace?{...k,data:x}:{...k,data:{...k.data,...x}}},y)},updateEdge:h,updateEdgeData:(u,f,y={replace:!1})=>{h(u,k=>{const x=typeof f=="function"?f(k):f;return y.replace?{...k,data:x}:{...k,data:{...k.data,...x}}},y)},getNodesBounds:u=>{const{nodeLookup:f,nodeOrigin:y}=t.getState();return O$e(u,{nodeLookup:f,nodeOrigin:y})},getHandleConnections:({type:u,id:f,nodeId:y})=>{var k;return Array.from(((k=t.getState().connectionLookup.get(`${y}-${u}${f?`-${f}`:""}`))==null?void 0:k.values())??[])},getNodeConnections:({type:u,handleId:f,nodeId:y})=>{var k;return Array.from(((k=t.getState().connectionLookup.get(`${y}${u?f?`-${u}-${f}`:`-${u}`:""}`))==null?void 0:k.values())??[])},fitView:async u=>{const f=t.getState().fitViewResolver??K$e();return t.setState({fitViewQueued:!0,fitViewOptions:u,fitViewResolver:f}),n.nodeQueue.push(y=>[...y]),f.promise}}},[]);return m.useMemo(()=>({...r,...e,viewportInitialized:o}),[o])}const zB=e=>e.selected,Rje=typeof window<"u"?window:void 0;function Tje({deleteKeyCode:e,multiSelectionKeyCode:t}){const n=wt(),{deleteElements:o}=Sz(),r=wh(e,{actInsideInputWithModifier:!1}),a=wh(t,{target:Rje});m.useEffect(()=>{if(r){const{edges:i,nodes:s}=n.getState();o({nodes:s.filter(zB),edges:i.filter(zB)}),n.setState({nodesSelectionActive:!1})}},[r]),m.useEffect(()=>{n.setState({multiSelectionActive:a})},[a])}function Dje(e){const t=wt();m.useEffect(()=>{const n=()=>{var r,a,i,s;if(!e.current||!(((a=(r=e.current).checkVisibility)==null?void 0:a.call(r))??!0))return!1;const o=nO(e.current);(o.height===0||o.width===0)&&((s=(i=t.getState()).onError)==null||s.call(i,"004",Or.error004())),t.setState({width:o.width||500,height:o.height||500})};if(e.current){n(),window.addEventListener("resize",n);const o=new ResizeObserver(()=>n());return o.observe(e.current),()=>{window.removeEventListener("resize",n),o&&e.current&&o.unobserve(e.current)}}},[])}const Lz={position:"absolute",width:"100%",height:"100%",top:0,left:0},Hje=e=>({userSelectionActive:e.userSelectionActive,lib:e.lib,connectionInProgress:e.connection.inProgress});function qje({onPaneContextMenu:e,zoomOnScroll:t=!0,zoomOnPinch:n=!0,panOnScroll:o=!1,panOnScrollSpeed:r=.5,panOnScrollMode:a=sd.Free,zoomOnDoubleClick:i=!0,panOnDrag:s=!0,defaultViewport:c,translateExtent:l,minZoom:h,maxZoom:u,zoomActivationKeyCode:f,preventScrolling:y=!0,children:k,noWheelClassName:x,noPanClassName:w,onViewportChange:g,isControlledViewport:M,paneClickDistance:v,selectionOnDrag:b}){const C=wt(),_=m.useRef(null),{userSelectionActive:S,lib:A,connectionInProgress:P}=Te(Hje,At),I=wh(f),$=m.useRef();Dje(_);const N=m.useCallback(X=>{g==null||g({x:X[0],y:X[1],zoom:X[2]}),M||C.setState({transform:X})},[g,M]);return m.useEffect(()=>{if(_.current){$.current=$Pe({domNode:_.current,minZoom:h,maxZoom:u,translateExtent:l,viewport:c,onDraggingChange:H=>C.setState(B=>B.paneDragging===H?B:{paneDragging:H}),onPanZoomStart:(H,B)=>{const{onViewportChangeStart:z,onMoveStart:R}=C.getState();R==null||R(H,B),z==null||z(B)},onPanZoom:(H,B)=>{const{onViewportChange:z,onMove:R}=C.getState();R==null||R(H,B),z==null||z(B)},onPanZoomEnd:(H,B)=>{const{onViewportChangeEnd:z,onMoveEnd:R}=C.getState();R==null||R(H,B),z==null||z(B)}});const{x:X,y:j,zoom:O}=$.current.getViewport();return C.setState({panZoom:$.current,transform:[X,j,O],domNode:_.current.closest(".react-flow")}),()=>{var H;(H=$.current)==null||H.destroy()}}},[]),m.useEffect(()=>{var X;(X=$.current)==null||X.update({onPaneContextMenu:e,zoomOnScroll:t,zoomOnPinch:n,panOnScroll:o,panOnScrollSpeed:r,panOnScrollMode:a,zoomOnDoubleClick:i,panOnDrag:s,zoomActivationKeyPressed:I,preventScrolling:y,noPanClassName:w,userSelectionActive:S,noWheelClassName:x,lib:A,onTransformChange:N,connectionInProgress:P,selectionOnDrag:b,paneClickDistance:v})},[e,t,n,o,r,a,i,s,I,y,w,S,x,A,N,P,b,v]),p.jsx("div",{className:"react-flow__renderer",ref:_,style:Lz,children:k})}const Oje=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function Fje(){const{userSelectionActive:e,userSelectionRect:t}=Te(Oje,At);return e&&t?p.jsx("div",{className:"react-flow__selection react-flow__container",style:{width:t.width,height:t.height,transform:`translate(${t.x}px, ${t.y}px)`}}):null}const eT=(e,t)=>n=>{n.target===t.current&&(e==null||e(n))},Vje=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,connectionInProgress:e.connection.inProgress,dragging:e.paneDragging});function Bje({isSelecting:e,selectionKeyPressed:t,selectionMode:n=Vu.Full,panOnDrag:o,paneClickDistance:r,selectionOnDrag:a,onSelectionStart:i,onSelectionEnd:s,onPaneClick:c,onPaneContextMenu:l,onPaneScroll:h,onPaneMouseEnter:u,onPaneMouseMove:f,onPaneMouseLeave:y,children:k}){const x=wt(),{userSelectionActive:w,elementsSelectable:g,dragging:M,connectionInProgress:v}=Te(Vje,At),b=g&&(e||w),C=m.useRef(null),_=m.useRef(),S=m.useRef(new Set),A=m.useRef(new Set),P=m.useRef(!1),I=z=>{if(P.current||v){P.current=!1;return}c==null||c(z),x.getState().resetSelectedElements(),x.setState({nodesSelectionActive:!1})},$=z=>{if(Array.isArray(o)&&(o!=null&&o.includes(2))){z.preventDefault();return}l==null||l(z)},N=h?z=>h(z):void 0,X=z=>{P.current&&(z.stopPropagation(),P.current=!1)},j=z=>{var Y,Q;const{domNode:R}=x.getState();if(_.current=R==null?void 0:R.getBoundingClientRect(),!_.current)return;const L=z.target===C.current;if(!L&&!!z.target.closest(".nokey")||!e||!(a&&L||t)||z.button!==0||!z.isPrimary)return;(Q=(Y=z.target)==null?void 0:Y.setPointerCapture)==null||Q.call(Y,z.pointerId),P.current=!1;const{x:E,y:W}=Zo(z.nativeEvent,_.current);x.setState({userSelectionRect:{width:0,height:0,startX:E,startY:W,x:E,y:W}}),L||(z.stopPropagation(),z.preventDefault())},O=z=>{const{userSelectionRect:R,transform:L,nodeLookup:U,edgeLookup:D,connectionLookup:E,triggerNodeChanges:W,triggerEdgeChanges:Y,defaultEdgeOptions:Q,resetSelectedElements:oe}=x.getState();if(!_.current||!R)return;const{x:te,y:se}=Zo(z.nativeEvent,_.current),{startX:we,startY:ke}=R;if(!P.current){const Ve=t?0:r;if(Math.hypot(te-we,se-ke)<=Ve)return;oe(),i==null||i(z)}P.current=!0;const ge={startX:we,startY:ke,x:te<we?te:we,y:se<ke?se:ke,width:Math.abs(te-we),height:Math.abs(se-ke)},ve=S.current,re=A.current;S.current=new Set(eO(U,ge,L,n===Vu.Partial,!0).map(Ve=>Ve.id)),A.current=new Set;const me=(Q==null?void 0:Q.selectable)??!0;for(const Ve of S.current){const lt=E.get(Ve);if(lt)for(const{edgeId:Vt}of lt.values()){const Et=D.get(Vt);Et&&(Et.selectable??me)&&A.current.add(Vt)}}if(!dB(ve,S.current)){const Ve=hu(U,S.current,!0);W(Ve)}if(!dB(re,A.current)){const Ve=hu(D,A.current);Y(Ve)}x.setState({userSelectionRect:ge,userSelectionActive:!0,nodesSelectionActive:!1})},H=z=>{var R,L;z.button===0&&((L=(R=z.target)==null?void 0:R.releasePointerCapture)==null||L.call(R,z.pointerId),!w&&z.target===C.current&&x.getState().userSelectionRect&&(I==null||I(z)),x.setState({userSelectionActive:!1,userSelectionRect:null}),P.current&&(s==null||s(z),x.setState({nodesSelectionActive:S.current.size>0})))},B=o===!0||Array.isArray(o)&&o.includes(0);return p.jsxs("div",{className:Zt(["react-flow__pane",{draggable:B,dragging:M,selection:e}]),onClick:b?void 0:eT(I,C),onContextMenu:eT($,C),onWheel:eT(N,C),onPointerEnter:b?void 0:u,onPointerMove:b?O:f,onPointerUp:b?H:void 0,onPointerDownCapture:b?j:void 0,onClickCapture:b?X:void 0,onPointerLeave:y,ref:C,style:Lz,children:[k,p.jsx(Fje,{})]})}function YD({id:e,store:t,unselect:n=!1,nodeRef:o}){const{addSelectedNodes:r,unselectNodesAndEdges:a,multiSelectionActive:i,nodeLookup:s,onError:c}=t.getState(),l=s.get(e);if(!l){c==null||c("012",Or.error012(e));return}t.setState({nodesSelectionActive:!1}),l.selected?(n||l.selected&&i)&&(a({nodes:[l],edges:[]}),requestAnimationFrame(()=>{var h;return(h=o==null?void 0:o.current)==null?void 0:h.blur()})):r([e])}function TY({nodeRef:e,disabled:t=!1,noDragClassName:n,handleSelector:o,nodeId:r,isSelectable:a,nodeClickDistance:i}){const s=wt(),[c,l]=m.useState(!1),h=m.useRef();return m.useEffect(()=>{h.current=gPe({getStoreItems:()=>s.getState(),onNodeMouseDown:u=>{YD({id:u,store:s,nodeRef:e})},onDragStart:()=>{l(!0)},onDragStop:()=>{l(!1)}})},[]),m.useEffect(()=>{if(!(t||!e.current||!h.current))return h.current.update({noDragClassName:n,handleSelector:o,domNode:e.current,isSelectable:a,nodeId:r,nodeClickDistance:i}),()=>{var u;(u=h.current)==null||u.destroy()}},[n,o,t,a,e,r,i]),c}const Uje=e=>t=>t.selected&&(t.draggable||e&&typeof t.draggable>"u");function DY(){const e=wt();return m.useCallback(n=>{const{nodeExtent:o,snapToGrid:r,snapGrid:a,nodesDraggable:i,onError:s,updateNodePositions:c,nodeLookup:l,nodeOrigin:h}=e.getState(),u=new Map,f=Uje(i),y=r?a[0]:5,k=r?a[1]:5,x=n.direction.x*y*n.factor,w=n.direction.y*k*n.factor;for(const[,g]of l){if(!f(g))continue;let M={x:g.internals.positionAbsolute.x+x,y:g.internals.positionAbsolute.y+w};r&&(M=qh(M,a));const{position:v,positionAbsolute:b}=eY({nodeId:g.id,nextPosition:M,nodeLookup:l,nodeExtent:o,nodeOrigin:h,onError:s});g.position=v,g.internals.positionAbsolute=b,u.set(g.id,g)}c(u)},[])}const cO=m.createContext(null),Wje=cO.Provider;cO.Consumer;const HY=()=>m.useContext(cO),Gje=e=>({connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName,rfId:e.rfId}),Zje=(e,t,n)=>o=>{const{connectionClickStartHandle:r,connectionMode:a,connection:i}=o,{fromHandle:s,toHandle:c,isValid:l}=i,h=(c==null?void 0:c.nodeId)===e&&(c==null?void 0:c.id)===t&&(c==null?void 0:c.type)===n;return{connectingFrom:(s==null?void 0:s.nodeId)===e&&(s==null?void 0:s.id)===t&&(s==null?void 0:s.type)===n,connectingTo:h,clickConnecting:(r==null?void 0:r.nodeId)===e&&(r==null?void 0:r.id)===t&&(r==null?void 0:r.type)===n,isPossibleEndHandle:a===Fu.Strict?(s==null?void 0:s.type)!==n:e!==(s==null?void 0:s.nodeId)||t!==(s==null?void 0:s.id),connectionInProcess:!!s,clickConnectionInProcess:!!r,valid:h&&l}};function Kje({type:e="source",position:t=pe.Top,isValidConnection:n,isConnectable:o=!0,isConnectableStart:r=!0,isConnectableEnd:a=!0,id:i,onConnect:s,children:c,className:l,onMouseDown:h,onTouchStart:u,...f},y){var O,H;const k=i||null,x=e==="target",w=wt(),g=HY(),{connectOnClick:M,noPanClassName:v,rfId:b}=Te(Gje,At),{connectingFrom:C,connectingTo:_,clickConnecting:S,isPossibleEndHandle:A,connectionInProcess:P,clickConnectionInProcess:I,valid:$}=Te(Zje(g,k,e),At);g||(H=(O=w.getState()).onError)==null||H.call(O,"010",Or.error010());const N=B=>{const{defaultEdgeOptions:z,onConnect:R,hasDefaultEdges:L}=w.getState(),U={...z,...B};if(L){const{edges:D,setEdges:E}=w.getState();E(nPe(U,D))}R==null||R(U),s==null||s(U)},X=B=>{if(!g)return;const z=cY(B.nativeEvent);if(r&&(z&&B.button===0||!z)){const R=w.getState();KD.onPointerDown(B.nativeEvent,{handleDomNode:B.currentTarget,autoPanOnConnect:R.autoPanOnConnect,connectionMode:R.connectionMode,connectionRadius:R.connectionRadius,domNode:R.domNode,nodeLookup:R.nodeLookup,lib:R.lib,isTarget:x,handleId:k,nodeId:g,flowId:R.rfId,panBy:R.panBy,cancelConnection:R.cancelConnection,onConnectStart:R.onConnectStart,onConnectEnd:(...L)=>{var U,D;return(D=(U=w.getState()).onConnectEnd)==null?void 0:D.call(U,...L)},updateConnection:R.updateConnection,onConnect:N,isValidConnection:n||((...L)=>{var U,D;return((D=(U=w.getState()).isValidConnection)==null?void 0:D.call(U,...L))??!0}),getTransform:()=>w.getState().transform,getFromHandle:()=>w.getState().connection.fromHandle,autoPanSpeed:R.autoPanSpeed,dragThreshold:R.connectionDragThreshold})}z?h==null||h(B):u==null||u(B)},j=B=>{const{onClickConnectStart:z,onClickConnectEnd:R,connectionClickStartHandle:L,connectionMode:U,isValidConnection:D,lib:E,rfId:W,nodeLookup:Y,connection:Q}=w.getState();if(!g||!L&&!r)return;if(!L){z==null||z(B.nativeEvent,{nodeId:g,handleId:k,handleType:e}),w.setState({connectionClickStartHandle:{nodeId:g,type:e,id:k}});return}const oe=iY(B.target),te=n||D,{connection:se,isValid:we}=KD.isValid(B.nativeEvent,{handle:{nodeId:g,id:k,type:e},connectionMode:U,fromNodeId:L.nodeId,fromHandleId:L.id||null,fromType:L.type,isValidConnection:te,flowId:W,doc:oe,lib:E,nodeLookup:Y});we&&se&&N(se);const ke=structuredClone(Q);delete ke.inProgress,ke.toPosition=ke.toHandle?ke.toHandle.position:null,R==null||R(B,ke),w.setState({connectionClickStartHandle:null})};return p.jsx("div",{"data-handleid":k,"data-nodeid":g,"data-handlepos":t,"data-id":`${b}-${g}-${k}-${e}`,className:Zt(["react-flow__handle",`react-flow__handle-${t}`,"nodrag",v,l,{source:!x,target:x,connectable:o,connectablestart:r,connectableend:a,clickconnecting:S,connectingfrom:C,connectingto:_,valid:$,connectionindicator:o&&(!P||A)&&(P||I?a:r)}]),onMouseDown:X,onTouchStart:X,onClick:M?j:void 0,ref:y,...f,children:c})}const ht=m.memo(zY(Kje));function Xje({data:e,isConnectable:t,sourcePosition:n=pe.Bottom}){return p.jsxs(p.Fragment,{children:[e==null?void 0:e.label,p.jsx(ht,{type:"source",position:n,isConnectable:t})]})}function Yje({data:e,isConnectable:t,targetPosition:n=pe.Top,sourcePosition:o=pe.Bottom}){return p.jsxs(p.Fragment,{children:[p.jsx(ht,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label,p.jsx(ht,{type:"source",position:o,isConnectable:t})]})}function Qje(){return null}function Jje({data:e,isConnectable:t,targetPosition:n=pe.Top}){return p.jsxs(p.Fragment,{children:[p.jsx(ht,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label]})}const Sj={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},RB={input:Xje,default:Yje,output:Jje,group:Qje};function eze(e){var t,n,o,r;return e.internals.handleBounds===void 0?{width:e.width??e.initialWidth??((t=e.style)==null?void 0:t.width),height:e.height??e.initialHeight??((n=e.style)==null?void 0:n.height)}:{width:e.width??((o=e.style)==null?void 0:o.width),height:e.height??((r=e.style)==null?void 0:r.height)}}const tze=e=>{const{width:t,height:n,x:o,y:r}=Hh(e.nodeLookup,{filter:a=>!!a.selected});return{width:Go(t)?t:null,height:Go(n)?n:null,userSelectionActive:e.userSelectionActive,transformString:`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]}) translate(${o}px,${r}px)`}};function nze({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:n}){const o=wt(),{width:r,height:a,transformString:i,userSelectionActive:s}=Te(tze,At),c=DY(),l=m.useRef(null);m.useEffect(()=>{var y;n||(y=l.current)==null||y.focus({preventScroll:!0})},[n]);const h=!s&&r!==null&&a!==null;if(TY({nodeRef:l,disabled:!h}),!h)return null;const u=e?y=>{const k=o.getState().nodes.filter(x=>x.selected);e(y,k)}:void 0,f=y=>{Object.prototype.hasOwnProperty.call(Sj,y.key)&&(y.preventDefault(),c({direction:Sj[y.key],factor:y.shiftKey?4:1}))};return p.jsx("div",{className:Zt(["react-flow__nodesselection","react-flow__container",t]),style:{transform:i},children:p.jsx("div",{ref:l,className:"react-flow__nodesselection-rect",onContextMenu:u,tabIndex:n?void 0:-1,onKeyDown:n?void 0:f,style:{width:r,height:a}})})}const TB=typeof window<"u"?window:void 0,oze=e=>({nodesSelectionActive:e.nodesSelectionActive,userSelectionActive:e.userSelectionActive});function qY({children:e,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:o,onPaneMouseLeave:r,onPaneContextMenu:a,onPaneScroll:i,paneClickDistance:s,deleteKeyCode:c,selectionKeyCode:l,selectionOnDrag:h,selectionMode:u,onSelectionStart:f,onSelectionEnd:y,multiSelectionKeyCode:k,panActivationKeyCode:x,zoomActivationKeyCode:w,elementsSelectable:g,zoomOnScroll:M,zoomOnPinch:v,panOnScroll:b,panOnScrollSpeed:C,panOnScrollMode:_,zoomOnDoubleClick:S,panOnDrag:A,defaultViewport:P,translateExtent:I,minZoom:$,maxZoom:N,preventScrolling:X,onSelectionContextMenu:j,noWheelClassName:O,noPanClassName:H,disableKeyboardA11y:B,onViewportChange:z,isControlledViewport:R}){const{nodesSelectionActive:L,userSelectionActive:U}=Te(oze,At),D=wh(l,{target:TB}),E=wh(x,{target:TB}),W=E||A,Y=E||b,Q=h&&W!==!0,oe=D||U||Q;return Tje({deleteKeyCode:c,multiSelectionKeyCode:k}),p.jsx(qje,{onPaneContextMenu:a,elementsSelectable:g,zoomOnScroll:M,zoomOnPinch:v,panOnScroll:Y,panOnScrollSpeed:C,panOnScrollMode:_,zoomOnDoubleClick:S,panOnDrag:!D&&W,defaultViewport:P,translateExtent:I,minZoom:$,maxZoom:N,zoomActivationKeyCode:w,preventScrolling:X,noWheelClassName:O,noPanClassName:H,onViewportChange:z,isControlledViewport:R,paneClickDistance:s,selectionOnDrag:Q,children:p.jsxs(Bje,{onSelectionStart:f,onSelectionEnd:y,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:o,onPaneMouseLeave:r,onPaneContextMenu:a,onPaneScroll:i,panOnDrag:W,isSelecting:!!oe,selectionMode:u,selectionKeyPressed:D,paneClickDistance:s,selectionOnDrag:Q,children:[e,L&&p.jsx(nze,{onSelectionContextMenu:j,noPanClassName:H,disableKeyboardA11y:B})]})})}qY.displayName="FlowRenderer";const rze=m.memo(qY),aze=e=>t=>e?eO(t.nodeLookup,{x:0,y:0,width:t.width,height:t.height},t.transform,!0).map(n=>n.id):Array.from(t.nodeLookup.keys());function ize(e){return Te(m.useCallback(aze(e),[e]),At)}const sze=e=>e.updateNodeInternals;function cze(){const e=Te(sze),[t]=m.useState(()=>typeof ResizeObserver>"u"?null:new ResizeObserver(n=>{const o=new Map;n.forEach(r=>{const a=r.target.getAttribute("data-id");o.set(a,{id:a,nodeElement:r.target,force:!0})}),e(o)}));return m.useEffect(()=>()=>{t==null||t.disconnect()},[t]),t}function lze({node:e,nodeType:t,hasDimensions:n,resizeObserver:o}){const r=wt(),a=m.useRef(null),i=m.useRef(null),s=m.useRef(e.sourcePosition),c=m.useRef(e.targetPosition),l=m.useRef(t),h=n&&!!e.internals.handleBounds;return m.useEffect(()=>{a.current&&!e.hidden&&(!h||i.current!==a.current)&&(i.current&&(o==null||o.unobserve(i.current)),o==null||o.observe(a.current),i.current=a.current)},[h,e.hidden]),m.useEffect(()=>()=>{i.current&&(o==null||o.unobserve(i.current),i.current=null)},[]),m.useEffect(()=>{if(a.current){const u=l.current!==t,f=s.current!==e.sourcePosition,y=c.current!==e.targetPosition;(u||f||y)&&(l.current=t,s.current=e.sourcePosition,c.current=e.targetPosition,r.getState().updateNodeInternals(new Map([[e.id,{id:e.id,nodeElement:a.current,force:!0}]])))}},[e.id,t,e.sourcePosition,e.targetPosition]),a}function dze({id:e,onClick:t,onMouseEnter:n,onMouseMove:o,onMouseLeave:r,onContextMenu:a,onDoubleClick:i,nodesDraggable:s,elementsSelectable:c,nodesConnectable:l,nodesFocusable:h,resizeObserver:u,noDragClassName:f,noPanClassName:y,disableKeyboardA11y:k,rfId:x,nodeTypes:w,nodeClickDistance:g,onError:M}){const{node:v,internals:b,isParent:C}=Te(te=>{const se=te.nodeLookup.get(e),we=te.parentLookup.has(e);return{node:se,internals:se.internals,isParent:we}},At);let _=v.type||"default",S=(w==null?void 0:w[_])||RB[_];S===void 0&&(M==null||M("003",Or.error003(_)),_="default",S=(w==null?void 0:w.default)||RB.default);const A=!!(v.draggable||s&&typeof v.draggable>"u"),P=!!(v.selectable||c&&typeof v.selectable>"u"),I=!!(v.connectable||l&&typeof v.connectable>"u"),$=!!(v.focusable||h&&typeof v.focusable>"u"),N=wt(),X=rY(v),j=lze({node:v,nodeType:_,hasDimensions:X,resizeObserver:u}),O=TY({nodeRef:j,disabled:v.hidden||!A,noDragClassName:f,handleSelector:v.dragHandle,nodeId:e,isSelectable:P,nodeClickDistance:g}),H=DY();if(v.hidden)return null;const B=Ia(v),z=eze(v),R=P||A||t||n||o||r,L=n?te=>n(te,{...b.userNode}):void 0,U=o?te=>o(te,{...b.userNode}):void 0,D=r?te=>r(te,{...b.userNode}):void 0,E=a?te=>a(te,{...b.userNode}):void 0,W=i?te=>i(te,{...b.userNode}):void 0,Y=te=>{const{selectNodesOnDrag:se,nodeDragThreshold:we}=N.getState();P&&(!se||!A||we>0)&&YD({id:e,store:N,nodeRef:j}),t&&t(te,{...b.userNode})},Q=te=>{if(!(sY(te.nativeEvent)||k)){if(KX.includes(te.key)&&P){const se=te.key==="Escape";YD({id:e,store:N,unselect:se,nodeRef:j})}else if(A&&v.selected&&Object.prototype.hasOwnProperty.call(Sj,te.key)){te.preventDefault();const{ariaLabelConfig:se}=N.getState();N.setState({ariaLiveMessage:se["node.a11yDescription.ariaLiveMessage"]({direction:te.key.replace("Arrow","").toLowerCase(),x:~~b.positionAbsolute.x,y:~~b.positionAbsolute.y})}),H({direction:Sj[te.key],factor:te.shiftKey?4:1})}}},oe=()=>{var re;if(k||!((re=j.current)!=null&&re.matches(":focus-visible")))return;const{transform:te,width:se,height:we,autoPanOnNodeFocus:ke,setCenter:ge}=N.getState();if(!ke)return;eO(new Map([[e,v]]),{x:0,y:0,width:se,height:we},te,!0).length>0||ge(v.position.x+B.width/2,v.position.y+B.height/2,{zoom:te[2]})};return p.jsx("div",{className:Zt(["react-flow__node",`react-flow__node-${_}`,{[y]:A},v.className,{selected:v.selected,selectable:P,parent:C,draggable:A,dragging:O}]),ref:j,style:{zIndex:b.z,transform:`translate(${b.positionAbsolute.x}px,${b.positionAbsolute.y}px)`,pointerEvents:R?"all":"none",visibility:X?"visible":"hidden",...v.style,...z},"data-id":e,"data-testid":`rf__node-${e}`,onMouseEnter:L,onMouseMove:U,onMouseLeave:D,onContextMenu:E,onClick:Y,onDoubleClick:W,onKeyDown:$?Q:void 0,tabIndex:$?0:void 0,onFocus:$?oe:void 0,role:v.ariaRole??($?"group":void 0),"aria-roledescription":"node","aria-describedby":k?void 0:`${NY}-${x}`,"aria-label":v.ariaLabel,...v.domAttributes,children:p.jsx(Wje,{value:e,children:p.jsx(S,{id:e,data:v.data,type:_,positionAbsoluteX:b.positionAbsolute.x,positionAbsoluteY:b.positionAbsolute.y,selected:v.selected??!1,selectable:P,draggable:A,deletable:v.deletable??!0,isConnectable:I,sourcePosition:v.sourcePosition,targetPosition:v.targetPosition,dragging:O,dragHandle:v.dragHandle,zIndex:b.z,parentId:v.parentId,...B})})})}var uze=m.memo(dze);const hze=e=>({nodesDraggable:e.nodesDraggable,nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,onError:e.onError});function OY(e){const{nodesDraggable:t,nodesConnectable:n,nodesFocusable:o,elementsSelectable:r,onError:a}=Te(hze,At),i=ize(e.onlyRenderVisibleElements),s=cze();return p.jsx("div",{className:"react-flow__nodes",style:Lz,children:i.map(c=>p.jsx(uze,{id:c,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:s,nodesDraggable:t,nodesConnectable:n,nodesFocusable:o,elementsSelectable:r,nodeClickDistance:e.nodeClickDistance,onError:a},c))})}OY.displayName="NodeRenderer";const fze=m.memo(OY);function pze(e){return Te(m.useCallback(n=>{if(!e)return n.edges.map(r=>r.id);const o=[];if(n.width&&n.height)for(const r of n.edges){const a=n.nodeLookup.get(r.source),i=n.nodeLookup.get(r.target);a&&i&&J$e({sourceNode:a,targetNode:i,width:n.width,height:n.height,transform:n.transform})&&o.push(r.id)}return o},[e]),At)}const yze=({color:e="none",strokeWidth:t=1})=>{const n={strokeWidth:t,...e&&{stroke:e}};return p.jsx("polyline",{className:"arrow",style:n,strokeLinecap:"round",fill:"none",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4"})},mze=({color:e="none",strokeWidth:t=1})=>{const n={strokeWidth:t,...e&&{stroke:e,fill:e}};return p.jsx("polyline",{className:"arrowclosed",style:n,strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"})},DB={[kh.Arrow]:yze,[kh.ArrowClosed]:mze};function kze(e){const t=wt();return m.useMemo(()=>{var r,a;return Object.prototype.hasOwnProperty.call(DB,e)?DB[e]:((a=(r=t.getState()).onError)==null||a.call(r,"009",Or.error009(e)),null)},[e])}const gze=({id:e,type:t,color:n,width:o=12.5,height:r=12.5,markerUnits:a="strokeWidth",strokeWidth:i,orient:s="auto-start-reverse"})=>{const c=kze(t);return c?p.jsx("marker",{className:"react-flow__arrowhead",id:e,markerWidth:`${o}`,markerHeight:`${r}`,viewBox:"-10 -10 20 20",markerUnits:a,orient:s,refX:"0",refY:"0",children:p.jsx(c,{color:n,strokeWidth:i})}):null},FY=({defaultColor:e,rfId:t})=>{const n=Te(a=>a.edges),o=Te(a=>a.defaultEdgeOptions),r=m.useMemo(()=>sPe(n,{id:t,defaultColor:e,defaultMarkerStart:o==null?void 0:o.markerStart,defaultMarkerEnd:o==null?void 0:o.markerEnd}),[n,o,t,e]);return r.length?p.jsx("svg",{className:"react-flow__marker","aria-hidden":"true",children:p.jsx("defs",{children:r.map(a=>p.jsx(gze,{id:a.id,type:a.type,color:a.color,width:a.width,height:a.height,markerUnits:a.markerUnits,strokeWidth:a.strokeWidth,orient:a.orient},a.id))})}):null};FY.displayName="MarkerDefinitions";var vze=m.memo(FY);function VY({x:e,y:t,label:n,labelStyle:o,labelShowBg:r=!0,labelBgStyle:a,labelBgPadding:i=[2,4],labelBgBorderRadius:s=2,children:c,className:l,...h}){const[u,f]=m.useState({x:1,y:0,width:0,height:0}),y=Zt(["react-flow__edge-textwrapper",l]),k=m.useRef(null);return m.useEffect(()=>{if(k.current){const x=k.current.getBBox();f({x:x.x,y:x.y,width:x.width,height:x.height})}},[n]),n?p.jsxs("g",{transform:`translate(${e-u.width/2} ${t-u.height/2})`,className:y,visibility:u.width?"visible":"hidden",...h,children:[r&&p.jsx("rect",{width:u.width+2*i[0],x:-i[0],y:-i[1],height:u.height+2*i[1],className:"react-flow__edge-textbg",style:a,rx:s,ry:s}),p.jsx("text",{className:"react-flow__edge-text",y:u.height/2,dy:"0.3em",ref:k,style:o,children:n}),c]}):null}VY.displayName="EdgeText";const xze=m.memo(VY);function Fh({path:e,labelX:t,labelY:n,label:o,labelStyle:r,labelShowBg:a,labelBgStyle:i,labelBgPadding:s,labelBgBorderRadius:c,interactionWidth:l=20,...h}){return p.jsxs(p.Fragment,{children:[p.jsx("path",{...h,d:e,fill:"none",className:Zt(["react-flow__edge-path",h.className])}),l?p.jsx("path",{d:e,fill:"none",strokeOpacity:0,strokeWidth:l,className:"react-flow__edge-interaction"}):null,o&&Go(t)&&Go(n)?p.jsx(xze,{x:t,y:n,label:o,labelStyle:r,labelShowBg:a,labelBgStyle:i,labelBgPadding:s,labelBgBorderRadius:c}):null]})}function HB({pos:e,x1:t,y1:n,x2:o,y2:r}){return e===pe.Left||e===pe.Right?[.5*(t+o),n]:[t,.5*(n+r)]}function BY({sourceX:e,sourceY:t,sourcePosition:n=pe.Bottom,targetX:o,targetY:r,targetPosition:a=pe.Top}){const[i,s]=HB({pos:n,x1:e,y1:t,x2:o,y2:r}),[c,l]=HB({pos:a,x1:o,y1:r,x2:e,y2:t}),[h,u,f,y]=lY({sourceX:e,sourceY:t,targetX:o,targetY:r,sourceControlX:i,sourceControlY:s,targetControlX:c,targetControlY:l});return[`M${e},${t} C${i},${s} ${c},${l} ${o},${r}`,h,u,f,y]}function UY(e){return m.memo(({id:t,sourceX:n,sourceY:o,targetX:r,targetY:a,sourcePosition:i,targetPosition:s,label:c,labelStyle:l,labelShowBg:h,labelBgStyle:u,labelBgPadding:f,labelBgBorderRadius:y,style:k,markerEnd:x,markerStart:w,interactionWidth:g})=>{const[M,v,b]=BY({sourceX:n,sourceY:o,sourcePosition:i,targetX:r,targetY:a,targetPosition:s}),C=e.isInternal?void 0:t;return p.jsx(Fh,{id:C,path:M,labelX:v,labelY:b,label:c,labelStyle:l,labelShowBg:h,labelBgStyle:u,labelBgPadding:f,labelBgBorderRadius:y,style:k,markerEnd:x,markerStart:w,interactionWidth:g})})}const wze=UY({isInternal:!1}),WY=UY({isInternal:!0});wze.displayName="SimpleBezierEdge";WY.displayName="SimpleBezierEdgeInternal";function GY(e){return m.memo(({id:t,sourceX:n,sourceY:o,targetX:r,targetY:a,label:i,labelStyle:s,labelShowBg:c,labelBgStyle:l,labelBgPadding:h,labelBgBorderRadius:u,style:f,sourcePosition:y=pe.Bottom,targetPosition:k=pe.Top,markerEnd:x,markerStart:w,pathOptions:g,interactionWidth:M})=>{const[v,b,C]=xh({sourceX:n,sourceY:o,sourcePosition:y,targetX:r,targetY:a,targetPosition:k,borderRadius:g==null?void 0:g.borderRadius,offset:g==null?void 0:g.offset,stepPosition:g==null?void 0:g.stepPosition}),_=e.isInternal?void 0:t;return p.jsx(Fh,{id:_,path:v,labelX:b,labelY:C,label:i,labelStyle:s,labelShowBg:c,labelBgStyle:l,labelBgPadding:h,labelBgBorderRadius:u,style:f,markerEnd:x,markerStart:w,interactionWidth:M})})}const ZY=GY({isInternal:!1}),KY=GY({isInternal:!0});ZY.displayName="SmoothStepEdge";KY.displayName="SmoothStepEdgeInternal";function XY(e){return m.memo(({id:t,...n})=>{var r;const o=e.isInternal?void 0:t;return p.jsx(ZY,{...n,id:o,pathOptions:m.useMemo(()=>{var a;return{borderRadius:0,offset:(a=n.pathOptions)==null?void 0:a.offset}},[(r=n.pathOptions)==null?void 0:r.offset])})})}const Mze=XY({isInternal:!1}),YY=XY({isInternal:!0});Mze.displayName="StepEdge";YY.displayName="StepEdgeInternal";function QY(e){return m.memo(({id:t,sourceX:n,sourceY:o,targetX:r,targetY:a,label:i,labelStyle:s,labelShowBg:c,labelBgStyle:l,labelBgPadding:h,labelBgBorderRadius:u,style:f,markerEnd:y,markerStart:k,interactionWidth:x})=>{const[w,g,M]=uY({sourceX:n,sourceY:o,targetX:r,targetY:a}),v=e.isInternal?void 0:t;return p.jsx(Fh,{id:v,path:w,labelX:g,labelY:M,label:i,labelStyle:s,labelShowBg:c,labelBgStyle:l,labelBgPadding:h,labelBgBorderRadius:u,style:f,markerEnd:y,markerStart:k,interactionWidth:x})})}const bze=QY({isInternal:!1}),JY=QY({isInternal:!0});bze.displayName="StraightEdge";JY.displayName="StraightEdgeInternal";function eQ(e){return m.memo(({id:t,sourceX:n,sourceY:o,targetX:r,targetY:a,sourcePosition:i=pe.Bottom,targetPosition:s=pe.Top,label:c,labelStyle:l,labelShowBg:h,labelBgStyle:u,labelBgPadding:f,labelBgBorderRadius:y,style:k,markerEnd:x,markerStart:w,pathOptions:g,interactionWidth:M})=>{const[v,b,C]=Mz({sourceX:n,sourceY:o,sourcePosition:i,targetX:r,targetY:a,targetPosition:s,curvature:g==null?void 0:g.curvature}),_=e.isInternal?void 0:t;return p.jsx(Fh,{id:_,path:v,labelX:b,labelY:C,label:c,labelStyle:l,labelShowBg:h,labelBgStyle:u,labelBgPadding:f,labelBgBorderRadius:y,style:k,markerEnd:x,markerStart:w,interactionWidth:M})})}const _ze=eQ({isInternal:!1}),tQ=eQ({isInternal:!0});_ze.displayName="BezierEdge";tQ.displayName="BezierEdgeInternal";const qB={default:tQ,straight:JY,step:YY,smoothstep:KY,simplebezier:WY},OB={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null},Cze=(e,t,n)=>n===pe.Left?e-t:n===pe.Right?e+t:e,Sze=(e,t,n)=>n===pe.Top?e-t:n===pe.Bottom?e+t:e,FB="react-flow__edgeupdater";function VB({position:e,centerX:t,centerY:n,radius:o=10,onMouseDown:r,onMouseEnter:a,onMouseOut:i,type:s}){return p.jsx("circle",{onMouseDown:r,onMouseEnter:a,onMouseOut:i,className:Zt([FB,`${FB}-${s}`]),cx:Cze(t,o,e),cy:Sze(n,o,e),r:o,stroke:"transparent",fill:"transparent"})}function Lze({isReconnectable:e,reconnectRadius:t,edge:n,sourceX:o,sourceY:r,targetX:a,targetY:i,sourcePosition:s,targetPosition:c,onReconnect:l,onReconnectStart:h,onReconnectEnd:u,setReconnecting:f,setUpdateHover:y}){const k=wt(),x=(b,C)=>{if(b.button!==0)return;const{autoPanOnConnect:_,domNode:S,connectionMode:A,connectionRadius:P,lib:I,onConnectStart:$,cancelConnection:N,nodeLookup:X,rfId:j,panBy:O,updateConnection:H}=k.getState(),B=C.type==="target",z=(U,D)=>{f(!1),u==null||u(U,n,C.type,D)},R=U=>l==null?void 0:l(n,U),L=(U,D)=>{f(!0),h==null||h(b,n,C.type),$==null||$(U,D)};KD.onPointerDown(b.nativeEvent,{autoPanOnConnect:_,connectionMode:A,connectionRadius:P,domNode:S,handleId:C.id,nodeId:C.nodeId,nodeLookup:X,isTarget:B,edgeUpdaterType:C.type,lib:I,flowId:j,cancelConnection:N,panBy:O,isValidConnection:(...U)=>{var D,E;return((E=(D=k.getState()).isValidConnection)==null?void 0:E.call(D,...U))??!0},onConnect:R,onConnectStart:L,onConnectEnd:(...U)=>{var D,E;return(E=(D=k.getState()).onConnectEnd)==null?void 0:E.call(D,...U)},onReconnectEnd:z,updateConnection:H,getTransform:()=>k.getState().transform,getFromHandle:()=>k.getState().connection.fromHandle,dragThreshold:k.getState().connectionDragThreshold,handleDomNode:b.currentTarget})},w=b=>x(b,{nodeId:n.target,id:n.targetHandle??null,type:"target"}),g=b=>x(b,{nodeId:n.source,id:n.sourceHandle??null,type:"source"}),M=()=>y(!0),v=()=>y(!1);return p.jsxs(p.Fragment,{children:[(e===!0||e==="source")&&p.jsx(VB,{position:s,centerX:o,centerY:r,radius:t,onMouseDown:w,onMouseEnter:M,onMouseOut:v,type:"source"}),(e===!0||e==="target")&&p.jsx(VB,{position:c,centerX:a,centerY:i,radius:t,onMouseDown:g,onMouseEnter:M,onMouseOut:v,type:"target"})]})}function Ize({id:e,edgesFocusable:t,edgesReconnectable:n,elementsSelectable:o,onClick:r,onDoubleClick:a,onContextMenu:i,onMouseEnter:s,onMouseMove:c,onMouseLeave:l,reconnectRadius:h,onReconnect:u,onReconnectStart:f,onReconnectEnd:y,rfId:k,edgeTypes:x,noPanClassName:w,onError:g,disableKeyboardA11y:M}){let v=Te(ge=>ge.edgeLookup.get(e));const b=Te(ge=>ge.defaultEdgeOptions);v=b?{...b,...v}:v;let C=v.type||"default",_=(x==null?void 0:x[C])||qB[C];_===void 0&&(g==null||g("011",Or.error011(C)),C="default",_=(x==null?void 0:x.default)||qB.default);const S=!!(v.focusable||t&&typeof v.focusable>"u"),A=typeof u<"u"&&(v.reconnectable||n&&typeof v.reconnectable>"u"),P=!!(v.selectable||o&&typeof v.selectable>"u"),I=m.useRef(null),[$,N]=m.useState(!1),[X,j]=m.useState(!1),O=wt(),{zIndex:H,sourceX:B,sourceY:z,targetX:R,targetY:L,sourcePosition:U,targetPosition:D}=Te(m.useCallback(ge=>{const ve=ge.nodeLookup.get(v.source),re=ge.nodeLookup.get(v.target);if(!ve||!re)return{zIndex:v.zIndex,...OB};const me=iPe({id:e,sourceNode:ve,targetNode:re,sourceHandle:v.sourceHandle||null,targetHandle:v.targetHandle||null,connectionMode:ge.connectionMode,onError:g});return{zIndex:Q$e({selected:v.selected,zIndex:v.zIndex,sourceNode:ve,targetNode:re,elevateOnSelect:ge.elevateEdgesOnSelect,zIndexMode:ge.zIndexMode}),...me||OB}},[v.source,v.target,v.sourceHandle,v.targetHandle,v.selected,v.zIndex]),At),E=m.useMemo(()=>v.markerStart?`url('#${GD(v.markerStart,k)}')`:void 0,[v.markerStart,k]),W=m.useMemo(()=>v.markerEnd?`url('#${GD(v.markerEnd,k)}')`:void 0,[v.markerEnd,k]);if(v.hidden||B===null||z===null||R===null||L===null)return null;const Y=ge=>{var Ve;const{addSelectedEdges:ve,unselectNodesAndEdges:re,multiSelectionActive:me}=O.getState();P&&(O.setState({nodesSelectionActive:!1}),v.selected&&me?(re({nodes:[],edges:[v]}),(Ve=I.current)==null||Ve.blur()):ve([e])),r&&r(ge,v)},Q=a?ge=>{a(ge,{...v})}:void 0,oe=i?ge=>{i(ge,{...v})}:void 0,te=s?ge=>{s(ge,{...v})}:void 0,se=c?ge=>{c(ge,{...v})}:void 0,we=l?ge=>{l(ge,{...v})}:void 0,ke=ge=>{var ve;if(!M&&KX.includes(ge.key)&&P){const{unselectNodesAndEdges:re,addSelectedEdges:me}=O.getState();ge.key==="Escape"?((ve=I.current)==null||ve.blur(),re({edges:[v]})):me([e])}};return p.jsx("svg",{style:{zIndex:H},children:p.jsxs("g",{className:Zt(["react-flow__edge",`react-flow__edge-${C}`,v.className,w,{selected:v.selected,animated:v.animated,inactive:!P&&!r,updating:$,selectable:P}]),onClick:Y,onDoubleClick:Q,onContextMenu:oe,onMouseEnter:te,onMouseMove:se,onMouseLeave:we,onKeyDown:S?ke:void 0,tabIndex:S?0:void 0,role:v.ariaRole??(S?"group":"img"),"aria-roledescription":"edge","data-id":e,"data-testid":`rf__edge-${e}`,"aria-label":v.ariaLabel===null?void 0:v.ariaLabel||`Edge from ${v.source} to ${v.target}`,"aria-describedby":S?`${AY}-${k}`:void 0,ref:I,...v.domAttributes,children:[!X&&p.jsx(_,{id:e,source:v.source,target:v.target,type:v.type,selected:v.selected,animated:v.animated,selectable:P,deletable:v.deletable??!0,label:v.label,labelStyle:v.labelStyle,labelShowBg:v.labelShowBg,labelBgStyle:v.labelBgStyle,labelBgPadding:v.labelBgPadding,labelBgBorderRadius:v.labelBgBorderRadius,sourceX:B,sourceY:z,targetX:R,targetY:L,sourcePosition:U,targetPosition:D,data:v.data,style:v.style,sourceHandleId:v.sourceHandle,targetHandleId:v.targetHandle,markerStart:E,markerEnd:W,pathOptions:"pathOptions"in v?v.pathOptions:void 0,interactionWidth:v.interactionWidth}),A&&p.jsx(Lze,{edge:v,isReconnectable:A,reconnectRadius:h,onReconnect:u,onReconnectStart:f,onReconnectEnd:y,sourceX:B,sourceY:z,targetX:R,targetY:L,sourcePosition:U,targetPosition:D,setUpdateHover:N,setReconnecting:j})]})})}var Nze=m.memo(Ize);const Aze=e=>({edgesFocusable:e.edgesFocusable,edgesReconnectable:e.edgesReconnectable,elementsSelectable:e.elementsSelectable,connectionMode:e.connectionMode,onError:e.onError});function nQ({defaultMarkerColor:e,onlyRenderVisibleElements:t,rfId:n,edgeTypes:o,noPanClassName:r,onReconnect:a,onEdgeContextMenu:i,onEdgeMouseEnter:s,onEdgeMouseMove:c,onEdgeMouseLeave:l,onEdgeClick:h,reconnectRadius:u,onEdgeDoubleClick:f,onReconnectStart:y,onReconnectEnd:k,disableKeyboardA11y:x}){const{edgesFocusable:w,edgesReconnectable:g,elementsSelectable:M,onError:v}=Te(Aze,At),b=pze(t);return p.jsxs("div",{className:"react-flow__edges",children:[p.jsx(vze,{defaultColor:e,rfId:n}),b.map(C=>p.jsx(Nze,{id:C,edgesFocusable:w,edgesReconnectable:g,elementsSelectable:M,noPanClassName:r,onReconnect:a,onContextMenu:i,onMouseEnter:s,onMouseMove:c,onMouseLeave:l,onClick:h,reconnectRadius:u,onDoubleClick:f,onReconnectStart:y,onReconnectEnd:k,rfId:n,onError:v,edgeTypes:o,disableKeyboardA11y:x},C))]})}nQ.displayName="EdgeRenderer";const Eze=m.memo(nQ),$ze=e=>`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`;function Pze({children:e}){const t=Te($ze);return p.jsx("div",{className:"react-flow__viewport xyflow__viewport react-flow__container",style:{transform:t},children:e})}function jze(e){const t=Sz(),n=m.useRef(!1);m.useEffect(()=>{!n.current&&t.viewportInitialized&&e&&(setTimeout(()=>e(t),1),n.current=!0)},[e,t.viewportInitialized])}const zze=e=>{var t;return(t=e.panZoom)==null?void 0:t.syncViewport};function Rze(e){const t=Te(zze),n=wt();return m.useEffect(()=>{e&&(t==null||t(e),n.setState({transform:[e.x,e.y,e.zoom]}))},[e,t]),null}function Tze(e){return e.connection.inProgress?{...e.connection,to:Oh(e.connection.to,e.transform)}:{...e.connection}}function Dze(e){return Tze}function Hze(e){const t=Dze();return Te(t,At)}const qze=e=>({nodesConnectable:e.nodesConnectable,isValid:e.connection.isValid,inProgress:e.connection.inProgress,width:e.width,height:e.height});function Oze({containerStyle:e,style:t,type:n,component:o}){const{nodesConnectable:r,width:a,height:i,isValid:s,inProgress:c}=Te(qze,At);return!(a&&r&&c)?null:p.jsx("svg",{style:e,width:a,height:i,className:"react-flow__connectionline react-flow__container",children:p.jsx("g",{className:Zt(["react-flow__connection",QX(s)]),children:p.jsx(oQ,{style:t,type:n,CustomComponent:o,isValid:s})})})}const oQ=({style:e,type:t=ai.Bezier,CustomComponent:n,isValid:o})=>{const{inProgress:r,from:a,fromNode:i,fromHandle:s,fromPosition:c,to:l,toNode:h,toHandle:u,toPosition:f,pointer:y}=Hze();if(!r)return;if(n)return p.jsx(n,{connectionLineType:t,connectionLineStyle:e,fromNode:i,fromHandle:s,fromX:a.x,fromY:a.y,toX:l.x,toY:l.y,fromPosition:c,toPosition:f,connectionStatus:QX(o),toNode:h,toHandle:u,pointer:y});let k="";const x={sourceX:a.x,sourceY:a.y,sourcePosition:c,targetX:l.x,targetY:l.y,targetPosition:f};switch(t){case ai.Bezier:[k]=Mz(x);break;case ai.SimpleBezier:[k]=BY(x);break;case ai.Step:[k]=xh({...x,borderRadius:0});break;case ai.SmoothStep:[k]=xh(x);break;default:[k]=uY(x)}return p.jsx("path",{d:k,fill:"none",className:"react-flow__connection-path",style:e})};oQ.displayName="ConnectionLine";const Fze={};function BB(e=Fze){m.useRef(e),wt(),m.useEffect(()=>{},[e])}function Vze(){wt(),m.useRef(!1),m.useEffect(()=>{},[])}function rQ({nodeTypes:e,edgeTypes:t,onInit:n,onNodeClick:o,onEdgeClick:r,onNodeDoubleClick:a,onEdgeDoubleClick:i,onNodeMouseEnter:s,onNodeMouseMove:c,onNodeMouseLeave:l,onNodeContextMenu:h,onSelectionContextMenu:u,onSelectionStart:f,onSelectionEnd:y,connectionLineType:k,connectionLineStyle:x,connectionLineComponent:w,connectionLineContainerStyle:g,selectionKeyCode:M,selectionOnDrag:v,selectionMode:b,multiSelectionKeyCode:C,panActivationKeyCode:_,zoomActivationKeyCode:S,deleteKeyCode:A,onlyRenderVisibleElements:P,elementsSelectable:I,defaultViewport:$,translateExtent:N,minZoom:X,maxZoom:j,preventScrolling:O,defaultMarkerColor:H,zoomOnScroll:B,zoomOnPinch:z,panOnScroll:R,panOnScrollSpeed:L,panOnScrollMode:U,zoomOnDoubleClick:D,panOnDrag:E,onPaneClick:W,onPaneMouseEnter:Y,onPaneMouseMove:Q,onPaneMouseLeave:oe,onPaneScroll:te,onPaneContextMenu:se,paneClickDistance:we,nodeClickDistance:ke,onEdgeContextMenu:ge,onEdgeMouseEnter:ve,onEdgeMouseMove:re,onEdgeMouseLeave:me,reconnectRadius:Ve,onReconnect:lt,onReconnectStart:Vt,onReconnectEnd:Et,noDragClassName:ce,noWheelClassName:J,noPanClassName:ln,disableKeyboardA11y:rn,nodeExtent:Ee,rfId:Ge,viewport:G,onViewportChange:ne}){return BB(e),BB(t),Vze(),jze(n),Rze(G),p.jsx(rze,{onPaneClick:W,onPaneMouseEnter:Y,onPaneMouseMove:Q,onPaneMouseLeave:oe,onPaneContextMenu:se,onPaneScroll:te,paneClickDistance:we,deleteKeyCode:A,selectionKeyCode:M,selectionOnDrag:v,selectionMode:b,onSelectionStart:f,onSelectionEnd:y,multiSelectionKeyCode:C,panActivationKeyCode:_,zoomActivationKeyCode:S,elementsSelectable:I,zoomOnScroll:B,zoomOnPinch:z,zoomOnDoubleClick:D,panOnScroll:R,panOnScrollSpeed:L,panOnScrollMode:U,panOnDrag:E,defaultViewport:$,translateExtent:N,minZoom:X,maxZoom:j,onSelectionContextMenu:u,preventScrolling:O,noDragClassName:ce,noWheelClassName:J,noPanClassName:ln,disableKeyboardA11y:rn,onViewportChange:ne,isControlledViewport:!!G,children:p.jsxs(Pze,{children:[p.jsx(Eze,{edgeTypes:t,onEdgeClick:r,onEdgeDoubleClick:i,onReconnect:lt,onReconnectStart:Vt,onReconnectEnd:Et,onlyRenderVisibleElements:P,onEdgeContextMenu:ge,onEdgeMouseEnter:ve,onEdgeMouseMove:re,onEdgeMouseLeave:me,reconnectRadius:Ve,defaultMarkerColor:H,noPanClassName:ln,disableKeyboardA11y:rn,rfId:Ge}),p.jsx(Oze,{style:x,type:k,component:w,containerStyle:g}),p.jsx("div",{className:"react-flow__edgelabel-renderer"}),p.jsx(fze,{nodeTypes:e,onNodeClick:o,onNodeDoubleClick:a,onNodeMouseEnter:s,onNodeMouseMove:c,onNodeMouseLeave:l,onNodeContextMenu:h,nodeClickDistance:ke,onlyRenderVisibleElements:P,noPanClassName:ln,noDragClassName:ce,disableKeyboardA11y:rn,nodeExtent:Ee,rfId:Ge}),p.jsx("div",{className:"react-flow__viewport-portal"})]})})}rQ.displayName="GraphView";const Bze=m.memo(rQ),UB=({nodes:e,edges:t,defaultNodes:n,defaultEdges:o,width:r,height:a,fitView:i,fitViewOptions:s,minZoom:c=.5,maxZoom:l=2,nodeOrigin:h,nodeExtent:u,zIndexMode:f="basic"}={})=>{const y=new Map,k=new Map,x=new Map,w=new Map,g=o??t??[],M=n??e??[],v=h??[0,0],b=u??mh;pY(x,w,g);const{nodesInitialized:C}=ZD(M,y,k,{nodeOrigin:v,nodeExtent:b,zIndexMode:f});let _=[0,0,1];if(i&&r&&a){const S=Hh(y,{filter:$=>!!(($.width||$.initialWidth)&&($.height||$.initialHeight))}),{x:A,y:P,zoom:I}=tO(S,r,a,c,l,(s==null?void 0:s.padding)??.1);_=[A,P,I]}return{rfId:"1",width:r??0,height:a??0,transform:_,nodes:M,nodesInitialized:C,nodeLookup:y,parentLookup:k,edges:g,edgeLookup:w,connectionLookup:x,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:n!==void 0,hasDefaultEdges:o!==void 0,panZoom:null,minZoom:c,maxZoom:l,translateExtent:mh,nodeExtent:b,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:Fu.Strict,domNode:null,paneDragging:!1,noPanClassName:"nopan",nodeOrigin:v,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:i??!1,fitViewOptions:s,fitViewResolver:null,connection:{...YX},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:W$e,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:"react",debug:!1,ariaLabelConfig:XX,zIndexMode:f,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map}},Uze=({nodes:e,edges:t,defaultNodes:n,defaultEdges:o,width:r,height:a,fitView:i,fitViewOptions:s,minZoom:c,maxZoom:l,nodeOrigin:h,nodeExtent:u,zIndexMode:f})=>dje((y,k)=>{async function x(){const{nodeLookup:w,panZoom:g,fitViewOptions:M,fitViewResolver:v,width:b,height:C,minZoom:_,maxZoom:S}=k();g&&(await B$e({nodes:w,width:b,height:C,panZoom:g,minZoom:_,maxZoom:S},M),v==null||v.resolve(!0),y({fitViewResolver:null}))}return{...UB({nodes:e,edges:t,width:r,height:a,fitView:i,fitViewOptions:s,minZoom:c,maxZoom:l,nodeOrigin:h,nodeExtent:u,defaultNodes:n,defaultEdges:o,zIndexMode:f}),setNodes:w=>{const{nodeLookup:g,parentLookup:M,nodeOrigin:v,elevateNodesOnSelect:b,fitViewQueued:C,zIndexMode:_,nodesSelectionActive:S}=k(),{nodesInitialized:A,hasSelectedNodes:P}=ZD(w,g,M,{nodeOrigin:v,nodeExtent:u,elevateNodesOnSelect:b,checkEquality:!0,zIndexMode:_}),I=S&&P;C&&A?(x(),y({nodes:w,nodesInitialized:A,fitViewQueued:!1,fitViewOptions:void 0,nodesSelectionActive:I})):y({nodes:w,nodesInitialized:A,nodesSelectionActive:I})},setEdges:w=>{const{connectionLookup:g,edgeLookup:M}=k();pY(g,M,w),y({edges:w})},setDefaultNodesAndEdges:(w,g)=>{if(w){const{setNodes:M}=k();M(w),y({hasDefaultNodes:!0})}if(g){const{setEdges:M}=k();M(g),y({hasDefaultEdges:!0})}},updateNodeInternals:w=>{const{triggerNodeChanges:g,nodeLookup:M,parentLookup:v,domNode:b,nodeOrigin:C,nodeExtent:_,debug:S,fitViewQueued:A,zIndexMode:P}=k(),{changes:I,updatedInternals:$}=pPe(w,M,v,b,C,_,P);$&&(dPe(M,v,{nodeOrigin:C,nodeExtent:_,zIndexMode:P}),A?(x(),y({fitViewQueued:!1,fitViewOptions:void 0})):y({}),(I==null?void 0:I.length)>0&&(S&&console.log("React Flow: trigger node changes",I),g==null||g(I)))},updateNodePositions:(w,g=!1)=>{const M=[];let v=[];const{nodeLookup:b,triggerNodeChanges:C,connection:_,updateConnection:S,onNodesChangeMiddlewareMap:A}=k();for(const[P,I]of w){const $=b.get(P),N=!!($!=null&&$.expandParent&&($!=null&&$.parentId)&&(I!=null&&I.position)),X={id:P,type:"position",position:N?{x:Math.max(0,I.position.x),y:Math.max(0,I.position.y)}:I.position,dragging:g};if($&&_.inProgress&&_.fromNode.id===$.id){const j=md($,_.fromHandle,pe.Left,!0);S({..._,from:j})}N&&$.parentId&&M.push({id:P,parentId:$.parentId,rect:{...I.internals.positionAbsolute,width:I.measured.width??0,height:I.measured.height??0}}),v.push(X)}if(M.length>0){const{parentLookup:P,nodeOrigin:I}=k(),$=sO(M,b,P,I);v.push(...$)}for(const P of A.values())v=P(v);C(v)},triggerNodeChanges:w=>{const{onNodesChange:g,setNodes:M,nodes:v,hasDefaultNodes:b,debug:C}=k();if(w!=null&&w.length){if(b){const _=PY(w,v);M(_)}C&&console.log("React Flow: trigger node changes",w),g==null||g(w)}},triggerEdgeChanges:w=>{const{onEdgesChange:g,setEdges:M,edges:v,hasDefaultEdges:b,debug:C}=k();if(w!=null&&w.length){if(b){const _=jY(w,v);M(_)}C&&console.log("React Flow: trigger edge changes",w),g==null||g(w)}},addSelectedNodes:w=>{const{multiSelectionActive:g,edgeLookup:M,nodeLookup:v,triggerNodeChanges:b,triggerEdgeChanges:C}=k();if(g){const _=w.map(S=>K1(S,!0));b(_);return}b(hu(v,new Set([...w]),!0)),C(hu(M))},addSelectedEdges:w=>{const{multiSelectionActive:g,edgeLookup:M,nodeLookup:v,triggerNodeChanges:b,triggerEdgeChanges:C}=k();if(g){const _=w.map(S=>K1(S,!0));C(_);return}C(hu(M,new Set([...w]))),b(hu(v,new Set,!0))},unselectNodesAndEdges:({nodes:w,edges:g}={})=>{const{edges:M,nodes:v,nodeLookup:b,triggerNodeChanges:C,triggerEdgeChanges:_}=k(),S=w||v,A=g||M,P=[];for(const $ of S){if(!$.selected)continue;const N=b.get($.id);N&&(N.selected=!1),P.push(K1($.id,!1))}const I=[];for(const $ of A)$.selected&&I.push(K1($.id,!1));C(P),_(I)},setMinZoom:w=>{const{panZoom:g,maxZoom:M}=k();g==null||g.setScaleExtent([w,M]),y({minZoom:w})},setMaxZoom:w=>{const{panZoom:g,minZoom:M}=k();g==null||g.setScaleExtent([M,w]),y({maxZoom:w})},setTranslateExtent:w=>{var g;(g=k().panZoom)==null||g.setTranslateExtent(w),y({translateExtent:w})},resetSelectedElements:()=>{const{edges:w,nodes:g,triggerNodeChanges:M,triggerEdgeChanges:v,elementsSelectable:b}=k();if(!b)return;const C=g.reduce((S,A)=>A.selected?[...S,K1(A.id,!1)]:S,[]),_=w.reduce((S,A)=>A.selected?[...S,K1(A.id,!1)]:S,[]);M(C),v(_)},setNodeExtent:w=>{const{nodes:g,nodeLookup:M,parentLookup:v,nodeOrigin:b,elevateNodesOnSelect:C,nodeExtent:_,zIndexMode:S}=k();w[0][0]===_[0][0]&&w[0][1]===_[0][1]&&w[1][0]===_[1][0]&&w[1][1]===_[1][1]||(ZD(g,M,v,{nodeOrigin:b,nodeExtent:w,elevateNodesOnSelect:C,checkEquality:!1,zIndexMode:S}),y({nodeExtent:w}))},panBy:w=>{const{transform:g,width:M,height:v,panZoom:b,translateExtent:C}=k();return yPe({delta:w,panZoom:b,transform:g,translateExtent:C,width:M,height:v})},setCenter:async(w,g,M)=>{const{width:v,height:b,maxZoom:C,panZoom:_}=k();if(!_)return Promise.resolve(!1);const S=typeof(M==null?void 0:M.zoom)<"u"?M.zoom:C;return await _.setViewport({x:v/2-w*S,y:b/2-g*S,zoom:S},{duration:M==null?void 0:M.duration,ease:M==null?void 0:M.ease,interpolate:M==null?void 0:M.interpolate}),Promise.resolve(!0)},cancelConnection:()=>{y({connection:{...YX}})},updateConnection:w=>{y({connection:w})},reset:()=>y({...UB()})}},Object.is);function Wze({initialNodes:e,initialEdges:t,defaultNodes:n,defaultEdges:o,initialWidth:r,initialHeight:a,initialMinZoom:i,initialMaxZoom:s,initialFitViewOptions:c,fitView:l,nodeOrigin:h,nodeExtent:u,zIndexMode:f,children:y}){const[k]=m.useState(()=>Uze({nodes:e,edges:t,defaultNodes:n,defaultEdges:o,width:r,height:a,fitView:l,minZoom:i,maxZoom:s,fitViewOptions:c,nodeOrigin:h,nodeExtent:u,zIndexMode:f}));return p.jsx(uje,{value:k,children:p.jsx(Pje,{children:y})})}function Gze({children:e,nodes:t,edges:n,defaultNodes:o,defaultEdges:r,width:a,height:i,fitView:s,fitViewOptions:c,minZoom:l,maxZoom:h,nodeOrigin:u,nodeExtent:f,zIndexMode:y}){return m.useContext(Cz)?p.jsx(p.Fragment,{children:e}):p.jsx(Wze,{initialNodes:t,initialEdges:n,defaultNodes:o,defaultEdges:r,initialWidth:a,initialHeight:i,fitView:s,initialFitViewOptions:c,initialMinZoom:l,initialMaxZoom:h,nodeOrigin:u,nodeExtent:f,zIndexMode:y,children:e})}const Zze={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0};function Kze({nodes:e,edges:t,defaultNodes:n,defaultEdges:o,className:r,nodeTypes:a,edgeTypes:i,onNodeClick:s,onEdgeClick:c,onInit:l,onMove:h,onMoveStart:u,onMoveEnd:f,onConnect:y,onConnectStart:k,onConnectEnd:x,onClickConnectStart:w,onClickConnectEnd:g,onNodeMouseEnter:M,onNodeMouseMove:v,onNodeMouseLeave:b,onNodeContextMenu:C,onNodeDoubleClick:_,onNodeDragStart:S,onNodeDrag:A,onNodeDragStop:P,onNodesDelete:I,onEdgesDelete:$,onDelete:N,onSelectionChange:X,onSelectionDragStart:j,onSelectionDrag:O,onSelectionDragStop:H,onSelectionContextMenu:B,onSelectionStart:z,onSelectionEnd:R,onBeforeDelete:L,connectionMode:U,connectionLineType:D=ai.Bezier,connectionLineStyle:E,connectionLineComponent:W,connectionLineContainerStyle:Y,deleteKeyCode:Q="Backspace",selectionKeyCode:oe="Shift",selectionOnDrag:te=!1,selectionMode:se=Vu.Full,panActivationKeyCode:we="Space",multiSelectionKeyCode:ke=vh()?"Meta":"Control",zoomActivationKeyCode:ge=vh()?"Meta":"Control",snapToGrid:ve,snapGrid:re,onlyRenderVisibleElements:me=!1,selectNodesOnDrag:Ve,nodesDraggable:lt,autoPanOnNodeFocus:Vt,nodesConnectable:Et,nodesFocusable:ce,nodeOrigin:J=EY,edgesFocusable:ln,edgesReconnectable:rn,elementsSelectable:Ee=!0,defaultViewport:Ge=_je,minZoom:G=.5,maxZoom:ne=2,translateExtent:Ie=mh,preventScrolling:De=!0,nodeExtent:Ke,defaultMarkerColor:Bt="#b1b1b7",zoomOnScroll:bn=!0,zoomOnPinch:Qe=!0,panOnScroll:ft=!1,panOnScrollSpeed:_n=.5,panOnScrollMode:Rt=sd.Free,zoomOnDoubleClick:Cn=!0,panOnDrag:an=!0,onPaneClick:dt,onPaneMouseEnter:Mt,onPaneMouseMove:rr,onPaneMouseLeave:Ea,onPaneScroll:ar,onPaneContextMenu:Pi,paneClickDistance:$a=1,nodeClickDistance:Ao=0,children:ir,onReconnect:Eo,onReconnectStart:Ad,onReconnectEnd:Ed,onEdgeContextMenu:$o,onEdgeDoubleClick:Kr,onEdgeMouseEnter:Xr,onEdgeMouseMove:He,onEdgeMouseLeave:gt,reconnectRadius:Pa=10,onNodesChange:ji,onEdgesChange:Yr,noDragClassName:sr="nodrag",noWheelClassName:ja="nowheel",noPanClassName:Rn="nopan",fitView:Po,fitViewOptions:Kt,connectOnClick:Xt,attributionPosition:Qr,proOptions:cr,defaultEdgeOptions:$d,elevateNodesOnSelect:Pd=!0,elevateEdgesOnSelect:jo=!1,disableKeyboardA11y:bt=!1,autoPanOnConnect:Kn,autoPanOnNodeDrag:lr,autoPanSpeed:jd,connectionRadius:Jr,isValidConnection:ea,onError:zd,style:zi,id:za,nodeDragThreshold:zo,connectionDragThreshold:Sn,viewport:dr,onViewportChange:Xn,width:Ro,height:Yn,colorMode:Rd="light",debug:ur,onScroll:Qn,ariaLabelConfig:Ra,zIndexMode:To="basic",...ut},go){const vo=za||"1",pn=Ije(Rd),hr=m.useCallback(fr=>{fr.currentTarget.scrollTo({top:0,left:0,behavior:"instant"}),Qn==null||Qn(fr)},[Qn]);return p.jsx("div",{"data-testid":"rf__wrapper",...ut,onScroll:hr,style:{...zi,...Zze},ref:go,className:Zt(["react-flow",r,pn]),id:za,role:"application",children:p.jsxs(Gze,{nodes:e,edges:t,width:Ro,height:Yn,fitView:Po,fitViewOptions:Kt,minZoom:G,maxZoom:ne,nodeOrigin:J,nodeExtent:Ke,zIndexMode:To,children:[p.jsx(Lje,{nodes:e,edges:t,defaultNodes:n,defaultEdges:o,onConnect:y,onConnectStart:k,onConnectEnd:x,onClickConnectStart:w,onClickConnectEnd:g,nodesDraggable:lt,autoPanOnNodeFocus:Vt,nodesConnectable:Et,nodesFocusable:ce,edgesFocusable:ln,edgesReconnectable:rn,elementsSelectable:Ee,elevateNodesOnSelect:Pd,elevateEdgesOnSelect:jo,minZoom:G,maxZoom:ne,nodeExtent:Ke,onNodesChange:ji,onEdgesChange:Yr,snapToGrid:ve,snapGrid:re,connectionMode:U,translateExtent:Ie,connectOnClick:Xt,defaultEdgeOptions:$d,fitView:Po,fitViewOptions:Kt,onNodesDelete:I,onEdgesDelete:$,onDelete:N,onNodeDragStart:S,onNodeDrag:A,onNodeDragStop:P,onSelectionDrag:O,onSelectionDragStart:j,onSelectionDragStop:H,onMove:h,onMoveStart:u,onMoveEnd:f,noPanClassName:Rn,nodeOrigin:J,rfId:vo,autoPanOnConnect:Kn,autoPanOnNodeDrag:lr,autoPanSpeed:jd,onError:zd,connectionRadius:Jr,isValidConnection:ea,selectNodesOnDrag:Ve,nodeDragThreshold:zo,connectionDragThreshold:Sn,onBeforeDelete:L,debug:ur,ariaLabelConfig:Ra,zIndexMode:To}),p.jsx(Bze,{onInit:l,onNodeClick:s,onEdgeClick:c,onNodeMouseEnter:M,onNodeMouseMove:v,onNodeMouseLeave:b,onNodeContextMenu:C,onNodeDoubleClick:_,nodeTypes:a,edgeTypes:i,connectionLineType:D,connectionLineStyle:E,connectionLineComponent:W,connectionLineContainerStyle:Y,selectionKeyCode:oe,selectionOnDrag:te,selectionMode:se,deleteKeyCode:Q,multiSelectionKeyCode:ke,panActivationKeyCode:we,zoomActivationKeyCode:ge,onlyRenderVisibleElements:me,defaultViewport:Ge,translateExtent:Ie,minZoom:G,maxZoom:ne,preventScrolling:De,zoomOnScroll:bn,zoomOnPinch:Qe,zoomOnDoubleClick:Cn,panOnScroll:ft,panOnScrollSpeed:_n,panOnScrollMode:Rt,panOnDrag:an,onPaneClick:dt,onPaneMouseEnter:Mt,onPaneMouseMove:rr,onPaneMouseLeave:Ea,onPaneScroll:ar,onPaneContextMenu:Pi,paneClickDistance:$a,nodeClickDistance:Ao,onSelectionContextMenu:B,onSelectionStart:z,onSelectionEnd:R,onReconnect:Eo,onReconnectStart:Ad,onReconnectEnd:Ed,onEdgeContextMenu:$o,onEdgeDoubleClick:Kr,onEdgeMouseEnter:Xr,onEdgeMouseMove:He,onEdgeMouseLeave:gt,reconnectRadius:Pa,defaultMarkerColor:Bt,noDragClassName:sr,noWheelClassName:ja,noPanClassName:Rn,rfId:vo,disableKeyboardA11y:bt,nodeExtent:Ke,viewport:dr,onViewportChange:Xn}),p.jsx(bje,{onSelectionChange:X}),ir,p.jsx(gje,{proOptions:cr,position:Qr}),p.jsx(kje,{rfId:vo,disableKeyboardA11y:bt})]})})}var Xze=zY(Kze);const Yze=e=>{var t;return(t=e.domNode)==null?void 0:t.querySelector(".react-flow__edgelabel-renderer")};function Qze({children:e}){const t=Te(Yze);return t?h0.createPortal(e,t):null}const Jze=e=>{var t;return(t=e.domNode)==null?void 0:t.querySelector(".react-flow__viewport-portal")};function eRe({children:e}){const t=Te(Jze);return t?h0.createPortal(e,t):null}function aQ(){const e=wt();return m.useCallback(t=>{const{domNode:n,updateNodeInternals:o}=e.getState(),r=Array.isArray(t)?t:[t],a=new Map;r.forEach(i=>{const s=n==null?void 0:n.querySelector(`.react-flow__node[data-id="${i}"]`);s&&a.set(i,{id:i,nodeElement:s,force:!0})}),requestAnimationFrame(()=>o(a,{triggerFitView:!1}))},[])}function WB(e){return Te(m.useCallback(n=>n.nodeLookup.get(e),[e]),At)}function tRe({dimensions:e,lineWidth:t,variant:n,className:o}){return p.jsx("path",{strokeWidth:t,d:`M${e[0]/2} 0 V${e[1]} M0 ${e[1]/2} H${e[0]}`,className:Zt(["react-flow__background-pattern",n,o])})}function nRe({radius:e,className:t}){return p.jsx("circle",{cx:e,cy:e,r:e,className:Zt(["react-flow__background-pattern","dots",t])})}var ki;(function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"})(ki||(ki={}));const oRe={[ki.Dots]:1,[ki.Lines]:1,[ki.Cross]:6},rRe=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function iQ({id:e,variant:t=ki.Dots,gap:n=20,size:o,lineWidth:r=1,offset:a=0,color:i,bgColor:s,style:c,className:l,patternClassName:h}){const u=m.useRef(null),{transform:f,patternId:y}=Te(rRe,At),k=o||oRe[t],x=t===ki.Dots,w=t===ki.Cross,g=Array.isArray(n)?n:[n,n],M=[g[0]*f[2]||1,g[1]*f[2]||1],v=k*f[2],b=Array.isArray(a)?a:[a,a],C=w?[v,v]:M,_=[b[0]*f[2]||1+C[0]/2,b[1]*f[2]||1+C[1]/2],S=`${y}${e||""}`;return p.jsxs("svg",{className:Zt(["react-flow__background",l]),style:{...c,...Lz,"--xy-background-color-props":s,"--xy-background-pattern-color-props":i},ref:u,"data-testid":"rf__background",children:[p.jsx("pattern",{id:S,x:f[0]%M[0],y:f[1]%M[1],width:M[0],height:M[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${_[0]},-${_[1]})`,children:x?p.jsx(nRe,{radius:v/2,className:h}):p.jsx(tRe,{dimensions:C,lineWidth:r,variant:t,className:h})}),p.jsx("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${S})`})]})}iQ.displayName="Background";const aRe=m.memo(iQ);function iRe(){return p.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",children:p.jsx("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"})})}function sRe(){return p.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5",children:p.jsx("path",{d:"M0 0h32v4.2H0z"})})}function cRe(){return p.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30",children:p.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 lRe(){return p.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:p.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 dRe(){return p.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:p.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 fu({children:e,className:t,...n}){return p.jsx("button",{type:"button",className:Zt(["react-flow__controls-button",t]),...n,children:e})}const uRe=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom,ariaLabelConfig:e.ariaLabelConfig});function sQ({style:e,showZoom:t=!0,showFitView:n=!0,showInteractive:o=!0,fitViewOptions:r,onZoomIn:a,onZoomOut:i,onFitView:s,onInteractiveChange:c,className:l,children:h,position:u="bottom-left",orientation:f="vertical","aria-label":y}){const k=wt(),{isInteractive:x,minZoomReached:w,maxZoomReached:g,ariaLabelConfig:M}=Te(uRe,At),{zoomIn:v,zoomOut:b,fitView:C}=Sz(),_=()=>{v(),a==null||a()},S=()=>{b(),i==null||i()},A=()=>{C(r),s==null||s()},P=()=>{k.setState({nodesDraggable:!x,nodesConnectable:!x,elementsSelectable:!x}),c==null||c(!x)},I=f==="horizontal"?"horizontal":"vertical";return p.jsxs(Zu,{className:Zt(["react-flow__controls",I,l]),position:u,style:e,"data-testid":"rf__controls","aria-label":y??M["controls.ariaLabel"],children:[t&&p.jsxs(p.Fragment,{children:[p.jsx(fu,{onClick:_,className:"react-flow__controls-zoomin",title:M["controls.zoomIn.ariaLabel"],"aria-label":M["controls.zoomIn.ariaLabel"],disabled:g,children:p.jsx(iRe,{})}),p.jsx(fu,{onClick:S,className:"react-flow__controls-zoomout",title:M["controls.zoomOut.ariaLabel"],"aria-label":M["controls.zoomOut.ariaLabel"],disabled:w,children:p.jsx(sRe,{})})]}),n&&p.jsx(fu,{className:"react-flow__controls-fitview",onClick:A,title:M["controls.fitView.ariaLabel"],"aria-label":M["controls.fitView.ariaLabel"],children:p.jsx(cRe,{})}),o&&p.jsx(fu,{className:"react-flow__controls-interactive",onClick:P,title:M["controls.interactive.ariaLabel"],"aria-label":M["controls.interactive.ariaLabel"],children:x?p.jsx(dRe,{}):p.jsx(lRe,{})}),h]})}sQ.displayName="Controls";const hRe=m.memo(sQ);function fRe({id:e,x:t,y:n,width:o,height:r,style:a,color:i,strokeColor:s,strokeWidth:c,className:l,borderRadius:h,shapeRendering:u,selected:f,onClick:y}){const{background:k,backgroundColor:x}=a||{},w=i||k||x;return p.jsx("rect",{className:Zt(["react-flow__minimap-node",{selected:f},l]),x:t,y:n,rx:h,ry:h,width:o,height:r,style:{fill:w,stroke:s,strokeWidth:c},shapeRendering:u,onClick:y?g=>y(g,e):void 0})}const pRe=m.memo(fRe),yRe=e=>e.nodes.map(t=>t.id),tT=e=>e instanceof Function?e:()=>e;function mRe({nodeStrokeColor:e,nodeColor:t,nodeClassName:n="",nodeBorderRadius:o=5,nodeStrokeWidth:r,nodeComponent:a=pRe,onClick:i}){const s=Te(yRe,At),c=tT(t),l=tT(e),h=tT(n),u=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return p.jsx(p.Fragment,{children:s.map(f=>p.jsx(gRe,{id:f,nodeColorFunc:c,nodeStrokeColorFunc:l,nodeClassNameFunc:h,nodeBorderRadius:o,nodeStrokeWidth:r,NodeComponent:a,onClick:i,shapeRendering:u},f))})}function kRe({id:e,nodeColorFunc:t,nodeStrokeColorFunc:n,nodeClassNameFunc:o,nodeBorderRadius:r,nodeStrokeWidth:a,shapeRendering:i,NodeComponent:s,onClick:c}){const{node:l,x:h,y:u,width:f,height:y}=Te(k=>{const x=k.nodeLookup.get(e);if(!x)return{node:void 0,x:0,y:0,width:0,height:0};const w=x.internals.userNode,{x:g,y:M}=x.internals.positionAbsolute,{width:v,height:b}=Ia(w);return{node:w,x:g,y:M,width:v,height:b}},At);return!l||l.hidden||!rY(l)?null:p.jsx(s,{x:h,y:u,width:f,height:y,style:l.style,selected:!!l.selected,className:o(l),color:t(l),borderRadius:r,strokeColor:n(l),strokeWidth:a,shapeRendering:i,onClick:c,id:l.id})}const gRe=m.memo(kRe);var vRe=m.memo(mRe);const xRe=200,wRe=150,MRe=e=>!e.hidden,bRe=e=>{const t={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:t,boundingRect:e.nodeLookup.size>0?oY(Hh(e.nodeLookup,{filter:MRe}),t):t,rfId:e.rfId,panZoom:e.panZoom,translateExtent:e.translateExtent,flowWidth:e.width,flowHeight:e.height,ariaLabelConfig:e.ariaLabelConfig}},_Re="react-flow__minimap-desc";function cQ({style:e,className:t,nodeStrokeColor:n,nodeColor:o,nodeClassName:r="",nodeBorderRadius:a=5,nodeStrokeWidth:i,nodeComponent:s,bgColor:c,maskColor:l,maskStrokeColor:h,maskStrokeWidth:u,position:f="bottom-right",onClick:y,onNodeClick:k,pannable:x=!1,zoomable:w=!1,ariaLabel:g,inversePan:M,zoomStep:v=1,offsetScale:b=5}){const C=wt(),_=m.useRef(null),{boundingRect:S,viewBB:A,rfId:P,panZoom:I,translateExtent:$,flowWidth:N,flowHeight:X,ariaLabelConfig:j}=Te(bRe,At),O=(e==null?void 0:e.width)??xRe,H=(e==null?void 0:e.height)??wRe,B=S.width/O,z=S.height/H,R=Math.max(B,z),L=R*O,U=R*H,D=b*R,E=S.x-(L-S.width)/2-D,W=S.y-(U-S.height)/2-D,Y=L+D*2,Q=U+D*2,oe=`${_Re}-${P}`,te=m.useRef(0),se=m.useRef();te.current=R,m.useEffect(()=>{if(_.current&&I)return se.current=_Pe({domNode:_.current,panZoom:I,getTransform:()=>C.getState().transform,getViewScale:()=>te.current}),()=>{var ve;(ve=se.current)==null||ve.destroy()}},[I]),m.useEffect(()=>{var ve;(ve=se.current)==null||ve.update({translateExtent:$,width:N,height:X,inversePan:M,pannable:x,zoomStep:v,zoomable:w})},[x,w,M,v,$,N,X]);const we=y?ve=>{var Ve;const[re,me]=((Ve=se.current)==null?void 0:Ve.pointer(ve))||[0,0];y(ve,{x:re,y:me})}:void 0,ke=k?m.useCallback((ve,re)=>{const me=C.getState().nodeLookup.get(re).internals.userNode;k(ve,me)},[]):void 0,ge=g??j["minimap.ariaLabel"];return p.jsx(Zu,{position:f,style:{...e,"--xy-minimap-background-color-props":typeof c=="string"?c:void 0,"--xy-minimap-mask-background-color-props":typeof l=="string"?l:void 0,"--xy-minimap-mask-stroke-color-props":typeof h=="string"?h:void 0,"--xy-minimap-mask-stroke-width-props":typeof u=="number"?u*R:void 0,"--xy-minimap-node-background-color-props":typeof o=="string"?o:void 0,"--xy-minimap-node-stroke-color-props":typeof n=="string"?n:void 0,"--xy-minimap-node-stroke-width-props":typeof i=="number"?i:void 0},className:Zt(["react-flow__minimap",t]),"data-testid":"rf__minimap",children:p.jsxs("svg",{width:O,height:H,viewBox:`${E} ${W} ${Y} ${Q}`,className:"react-flow__minimap-svg",role:"img","aria-labelledby":oe,ref:_,onClick:we,children:[ge&&p.jsx("title",{id:oe,children:ge}),p.jsx(vRe,{onClick:ke,nodeColor:o,nodeStrokeColor:n,nodeBorderRadius:a,nodeClassName:r,nodeStrokeWidth:i,nodeComponent:s}),p.jsx("path",{className:"react-flow__minimap-mask",d:`M${E-D},${W-D}h${Y+D*2}v${Q+D*2}h${-Y-D*2}z
8467
8467
  M${A.x},${A.y}h${A.width}v${A.height}h${-A.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}cQ.displayName="MiniMap";const CRe=m.memo(cQ),SRe=e=>t=>e?`${Math.max(1/t.transform[2],1)}`:void 0,LRe={[Mi.Line]:"right",[Mi.Handle]:"bottom-right"};function IRe({nodeId:e,position:t,variant:n=Mi.Handle,className:o,style:r=void 0,children:a,color:i,minWidth:s=10,minHeight:c=10,maxWidth:l=Number.MAX_VALUE,maxHeight:h=Number.MAX_VALUE,keepAspectRatio:u=!1,resizeDirection:f,autoScale:y=!0,shouldResize:k,onResizeStart:x,onResize:w,onResizeEnd:g}){const M=HY(),v=typeof e=="string"?e:M,b=wt(),C=m.useRef(null),_=n===Mi.Handle,S=Te(m.useCallback(SRe(_&&y),[_,y]),At),A=m.useRef(null),P=t??LRe[n];m.useEffect(()=>{if(!(!C.current||!v))return A.current||(A.current=DPe({domNode:C.current,nodeId:v,getStoreItems:()=>{const{nodeLookup:$,transform:N,snapGrid:X,snapToGrid:j,nodeOrigin:O,domNode:H}=b.getState();return{nodeLookup:$,transform:N,snapGrid:X,snapToGrid:j,nodeOrigin:O,paneDomNode:H}},onChange:($,N)=>{const{triggerNodeChanges:X,nodeLookup:j,parentLookup:O,nodeOrigin:H}=b.getState(),B=[],z={x:$.x,y:$.y},R=j.get(v);if(R&&R.expandParent&&R.parentId){const L=R.origin??H,U=$.width??R.measured.width??0,D=$.height??R.measured.height??0,E={id:R.id,parentId:R.parentId,rect:{width:U,height:D,...aY({x:$.x??R.position.x,y:$.y??R.position.y},{width:U,height:D},R.parentId,j,L)}},W=sO([E],j,O,H);B.push(...W),z.x=$.x?Math.max(L[0]*U,$.x):void 0,z.y=$.y?Math.max(L[1]*D,$.y):void 0}if(z.x!==void 0&&z.y!==void 0){const L={id:v,type:"position",position:{...z}};B.push(L)}if($.width!==void 0&&$.height!==void 0){const U={id:v,type:"dimensions",resizing:!0,setAttributes:f?f==="horizontal"?"width":"height":!0,dimensions:{width:$.width,height:$.height}};B.push(U)}for(const L of N){const U={...L,type:"position"};B.push(U)}X(B)},onEnd:({width:$,height:N})=>{const X={id:v,type:"dimensions",resizing:!1,dimensions:{width:$,height:N}};b.getState().triggerNodeChanges([X])}})),A.current.update({controlPosition:P,boundaries:{minWidth:s,minHeight:c,maxWidth:l,maxHeight:h},keepAspectRatio:u,resizeDirection:f,onResizeStart:x,onResize:w,onResizeEnd:g,shouldResize:k}),()=>{var $;($=A.current)==null||$.destroy()}},[P,s,c,l,h,u,x,w,g,k]);const I=P.split("-");return p.jsx("div",{className:Zt(["react-flow__resize-control","nodrag",...I,n,o]),ref:C,style:{...r,scale:S,...i&&{[_?"backgroundColor":"borderColor"]:i}},children:a})}const GB=m.memo(IRe),NRe=24,ARe=e=>({type:kh.ArrowClosed,width:18,height:18,...e?{color:e}:{}}),ERe={solid:{},dashed:{strokeDasharray:"6 4"},dotted:{strokeDasharray:"2 4"}},$Re=3,ZB=new WeakMap,PRe=(e,t,n=!1)=>{const o=ZB.get(e);if(o&&o.isAdjacentToRunning===t&&o.selected===n)return o.edge;const r=e.style?ERe[e.style]:{},a=Nt(e.color,"edge"),i=e.borderSize??2,s=n?Math.max($Re,i):i,l={...r,...a,...n?{strokeWidth:s,opacity:1}:{strokeWidth:s}},h=e.direction??"forward",u=a.stroke,f=ARe(u),y=h==="backward"||h==="both"?f:void 0,k=h==="forward"||h==="both"?f:void 0,x={id:e.id,source:e.source,target:e.target,sourceHandle:e.sourceHandle,targetHandle:e.targetHandle,type:"editableEdge",label:e.label,animated:t,data:{path:e.path,sourceHandleAutoPicked:e.sourceHandleAutoPicked,targetHandleAutoPicked:e.targetHandleAutoPicked,sourcePin:e.sourcePin,targetPin:e.targetPin,fontSize:e.fontSize},style:l,markerStart:y,markerEnd:k,interactionWidth:NRe};return ZB.set(e,{isAdjacentToRunning:t,selected:n,edge:x}),x},jRe=(e,t={})=>{const n=t.setTimer??((l,h)=>globalThis.setTimeout(l,h)),o=t.clearTimer??(l=>{globalThis.clearTimeout(l)});let r=null,a=null;return{schedule:l=>{r!==null&&o(r),a=l,r=n(()=>{r=null;const h=a;a=null,h&&h()},e)},flush:()=>{r!==null&&(o(r),r=null);const l=a;a=null,l&&l()},cancel:()=>{r!==null&&(o(r),r=null),a=null},get pending(){return r!==null}}},lQ="seeflow:detail-panel-width",Zd=380,QD=320,JD=800;function eH(e){return Number.isFinite(e)?e<QD?QD:e>JD?JD:e:Zd}function zRe(){if(typeof window>"u")return Zd;try{const e=window.localStorage.getItem(lQ);if(e===null)return Zd;const t=Number(e);return!Number.isFinite(t)||t<QD||t>JD?Zd:t}catch{return Zd}}function RRe(e){if(!(typeof window>"u"))try{const t=eH(e);window.localStorage.setItem(lQ,String(t))}catch{}}function TRe(e,t,n,o){const r=typeof window>"u"?null:window;if(!r)return;let a=eH(e);const i=c=>{a=eH(e+(t-c.clientX)),n.onWidth(a)},s=()=>{r.removeEventListener("pointermove",i),r.removeEventListener("pointerup",s),r.removeEventListener("pointercancel",s),n.onCommit(a)};r.addEventListener("pointermove",i),r.addEventListener("pointerup",s),r.addEventListener("pointercancel",s)}function DRe(e,t,n){return`${n!==void 0?n.replace(/\/+$/,""):"/api/projects"}/${encodeURIComponent(e)}/files/${encodeURI(t)}`}const Lj=(e,t)=>{const n=e.w/2,o=e.h/2,r=e.x+n,a=e.y+o,i=t.x-r,s=t.y-a;if(i===0&&s===0)return{x:r,y:a,side:"right"};const c=Math.abs(i),l=Math.abs(s),h=c===0?Number.POSITIVE_INFINITY:n/c,u=l===0?Number.POSITIVE_INFINITY:o/l,f=Math.min(h,u),y=r+i*f,k=a+s*f,x=c*o>=l*n?i>=0?"right":"left":s>=0?"bottom":"top";return{x:y,y:k,side:x}},tH=(e,t)=>{const n=Math.max(0,Math.min(e.w,t.x-e.x)),o=Math.max(0,Math.min(e.h,t.y-e.y)),r=n,a=e.w-n,i=o,s=e.h-o,c=Math.min(r,a,i,s),l=e.h===0?0:o/e.h,h=e.w===0?0:n/e.w;return c===r?{side:"left",t:l}:c===a?{side:"right",t:l}:c===i?{side:"top",t:h}:{side:"bottom",t:h}},Ij=(e,t)=>{const n=Math.min(1,Math.max(0,t.t));let o,r;switch(t.side){case"top":o=e.x+n*e.w,r=e.y;break;case"bottom":o=e.x+n*e.w,r=e.y+e.h;break;case"left":o=e.x,r=e.y+n*e.h;break;case"right":o=e.x+e.w,r=e.y+n*e.h;break}return{x:o,y:r,side:t.side}},HRe=(e,t)=>{const n=o=>Math.min(1,Math.max(0,o));switch(t.side){case"top":case"bottom":return{side:t.side,t:e.w===0?0:n((t.x-e.x)/e.w)};case"left":case"right":return{side:t.side,t:e.h===0?0:n((t.y-e.y)/e.h)}}},qRe=(e,t)=>{const n=(e==null?void 0:e.fallback)??{x:0,y:0,side:"right"},o=(t==null?void 0:t.fallback)??{x:0,y:0,side:"left"};if(!e||!t)return{source:n,target:o};const r={x:e.box.x+e.box.w/2,y:e.box.y+e.box.h/2},a={x:t.box.x+t.box.w/2,y:t.box.y+t.box.h/2},i=e.pin?Ij(e.box,e.pin):e.autoPicked===!1?e.fallback:Lj(e.box,a),s=t.pin?Ij(t.box,t.pin):t.autoPicked===!1?t.fallback:Lj(t.box,r);return{source:i,target:s}};function ci({initialValue:e,onCommit:t,onExit:n,multiline:o=!1,commitMode:r="enter-commits",required:a=!1,field:i,className:s,style:c,placeholder:l}){const h=o||r==="blur-only",u=m.useRef(null),[f,y]=m.useState(!1),[k,x]=m.useState(e.length===0),w=m.useRef(jRe(400)),g=m.useRef(e),M=m.useRef(!1);m.useEffect(()=>{const $=u.current;if(!$)return;$.textContent=e,$.focus();const N=window.getSelection();if(N){const j=document.createRange();j.selectNodeContents($),N.removeAllRanges(),N.addRange(j)}const X=w.current;return()=>{X.flush()}},[]);const v=()=>{const $=u.current;return $?h?$.innerText:$.textContent??"":""},b=$=>{w.current.cancel(),$!==g.current&&(g.current=$,t($))},C=()=>{const $=v();if(x($.length===0),a&&$.trim().length===0){w.current.cancel();return}w.current.schedule(()=>b($))},_=()=>{w.current.cancel();const $=v();if(a&&$.trim().length===0){const N=u.current;N&&(N.textContent=e),y(!0),setTimeout(()=>y(!1),320),n();return}b($),n()},S=()=>{w.current.cancel();const $=u.current;$&&($.textContent=e),n()},A=$=>{if($.stopPropagation(),$.nativeEvent.stopPropagation(),$.key==="Enter"){if(r==="blur-only"||o&&$.shiftKey){$.preventDefault(),document.execCommand("insertText",!1,`
8468
- `);return}$.preventDefault(),M.current=!0,_();return}$.key==="Escape"&&($.preventDefault(),M.current=!0,S())},P=$=>{$.preventDefault();const N=$.clipboardData.getData("text/plain");document.execCommand("insertText",!1,N)},I=()=>{if(M.current){M.current=!1;return}_()};return p.jsx("div",{ref:u,"data-testid":"inline-edit-input","data-field":i,"data-placeholder":l,role:"textbox",tabIndex:0,contentEditable:!0,suppressContentEditableWarning:!0,spellCheck:!1,onInput:C,onKeyDown:A,onPaste:P,onBlur:I,onMouseDown:$=>$.stopPropagation(),onClick:$=>$.stopPropagation(),onDoubleClick:$=>$.stopPropagation(),style:c,className:ae("nodrag nopan nowheel sf:block sf:w-full sf:bg-transparent sf:p-0 sf:text-inherit sf:outline-none","sf:whitespace-pre-wrap sf:wrap-break-word",k&&l?"inline-edit-empty":"",f?"inline-edit-shake":"",s)})}const dQ=8,KB=12,XB={height:`${dQ}px`,borderColor:"transparent"},YB={width:`${dQ}px`,borderColor:"transparent"},ORe={width:`${KB}px`,height:`${KB}px`,background:"transparent",border:"none"},FRe={width:"calc(10px / var(--rf-zoom, 1))",height:"calc(10px / var(--rf-zoom, 1))",background:"hsl(var(--background))",border:"calc(1px / var(--rf-zoom, 1)) solid hsl(var(--primary) / 0.6)",borderRadius:"calc(2px / var(--rf-zoom, 1))",zIndex:1},VRe=[{position:"top",style:XB},{position:"bottom",style:XB},{position:"left",style:YB},{position:"right",style:YB}],BRe=["top-left","top-right","bottom-left","bottom-right"],QB={pointerEvents:"none",cursor:"default"};function p0({visible:e,minWidth:t=80,minHeight:n=40,onResizeStart:o,onResize:r,onResizeEnd:a,cornerVariant:i="invisible"}){const s=i==="visible"?FRe:ORe,c=h=>e?h:{...h,...QB},l=e?s:{...s,opacity:0,...QB};return p.jsxs(p.Fragment,{children:[VRe.map(({position:h,style:u})=>p.jsx(GB,{position:h,variant:Mi.Line,minWidth:t,minHeight:n,style:c(u),onResizeStart:o,onResize:r,onResizeEnd:a,children:p.jsx("span",{"data-testid":"resize-control","data-position":h})},h)),BRe.map(h=>p.jsx(GB,{position:h,variant:Mi.Handle,minWidth:t,minHeight:n,style:l,autoScale:!1,onResizeStart:o,onResize:r,onResizeEnd:a,children:p.jsx("span",{"data-testid":"resize-control","data-position":h})},h))]})}function y0(e){const{onResize:t,onResizeEnd:n,onResizeFinal:o,setResizing:r}=e,[a,i]=m.useState(!1),s=m.useRef(null),c=m.useRef(t),l=m.useRef(n),h=m.useRef(o),u=m.useRef(r);m.useEffect(()=>{c.current=t},[t]),m.useEffect(()=>{l.current=n},[n]),m.useEffect(()=>{h.current=o},[o]),m.useEffect(()=>{u.current=r},[r]);const f=m.useCallback((x,w)=>{var g;i(!0),(g=u.current)==null||g.call(u,!0),s.current=w?{x:w.x,y:w.y,width:w.width,height:w.height}:null},[]),y=m.useCallback((x,w)=>{var g;(g=c.current)==null||g.call(c,{x:w.x,y:w.y,width:w.width,height:w.height})},[]),k=m.useCallback((x,w)=>{var M,v,b,C;i(!1),(M=u.current)==null||M.call(u,!1);const g=s.current;s.current=null,!(g&&g.width===w.width&&g.height===w.height)&&((v=c.current)==null||v.call(c,{x:w.x,y:w.y,width:w.width,height:w.height}),(b=l.current)==null||b.call(l,{x:w.x,y:w.y,width:w.width,height:w.height}),g&&((C=h.current)==null||C.call(h,{x:w.x,y:w.y,width:w.width,height:w.height},g)))},[]);return{isResizing:a,onResizeStart:f,onResizeEvent:y,onResizeEnd:k}}const Ku={width:48,height:48},JB="help-circle",URe=24,WRe=24,Kf="sf:opacity-0 sf:transition-opacity";function GRe(e){return Nt(e,"text").color??"currentColor"}const eU=new Set;function ZRe({id:e,data:t,selected:n,isConnectable:o}){const{onResizeStart:r,onResizeEvent:a,onResizeEnd:i}=y0({onResize:g=>{var M;return(M=t.onResize)==null?void 0:M.call(t,e,g)},onResizeEnd:g=>{var M;return(M=t.onResizeEnd)==null?void 0:M.call(t,e,g)},setResizing:t.setResizing}),s=t.width!==void 0||t.height!==void 0,c=!!t.onNameChange,[l,h]=m.useState(!1),u=Hu[t.icon];!u&&!eU.has(t.icon)&&(eU.add(t.icon),console.warn(`[iconNode] Unknown icon "${t.icon}"; falling back to "${JB}".`));const f=u??Hu[JB],y=GRe(t.color),k=t.strokeWidth??2,x={...s?{}:{width:Ku.width,height:Ku.height}},w=g=>{!c||l||(g.stopPropagation(),h(!0))};return p.jsxs("div",{className:ae("sf:group sf:relative",s?"sf:h-full sf:w-full":""),style:x,"data-testid":"icon-node","data-node-type":"icon",onDoubleClick:w,children:[p.jsx(p0,{visible:!!n&&!!t.onResize&&!l,cornerVariant:"visible",minWidth:URe,minHeight:WRe,onResizeStart:r,onResize:a,onResizeEnd:i}),p.jsx(ht,{type:"target",position:pe.Top,id:"t",isConnectable:o,className:ae(Kf,n&&"sf:opacity-100!")}),p.jsx(ht,{type:"target",position:pe.Left,id:"l",isConnectable:o,className:ae(Kf,n&&"sf:opacity-100!")}),f?p.jsx(f,{color:y,strokeWidth:k,absoluteStrokeWidth:!0,"aria-label":t.alt,className:"sf:block sf:h-full sf:w-full sf:pointer-events-none sf:select-none"}):null,l&&c?p.jsx("div",{className:"sf:absolute sf:left-0 sf:right-0 sf:top-full sf:mt-1 sf:text-center sf:text-xs sf:text-muted-foreground",children:p.jsx(ci,{initialValue:t.name??"",field:"icon-node-label",onCommit:g=>{var M;return(M=t.onNameChange)==null?void 0:M.call(t,e,g)},onExit:()=>h(!1),placeholder:"Label"})}):t.name?p.jsx("span",{"data-testid":"icon-node-label",className:"sf:pointer-events-none sf:absolute sf:left-0 sf:right-0 sf:top-full sf:mt-1 sf:truncate sf:text-center sf:text-xs sf:text-muted-foreground sf:select-none",children:t.name}):null,p.jsx(ht,{type:"source",position:pe.Right,id:"r",isConnectable:o,className:ae(Kf,n&&"sf:opacity-100!")}),p.jsx(ht,{type:"source",position:pe.Bottom,id:"b",isConnectable:o,className:ae(Kf,n&&"sf:opacity-100!")})]})}function KRe(e,t){return e.selected===t.selected&&e.data===t.data&&e.width===t.width&&e.height===t.height}const XRe=m.memo(ZRe,KRe);function YRe(e,t){const n=e.screenToFlowPosition({x:t.width/2,y:t.height/2});return{x:n.x-Ku.width/2,y:n.y-Ku.height/2}}const uQ="seeflow:icon-recents",QRe=16;function hQ(){if(typeof window>"u")return[];try{const e=window.localStorage.getItem(uQ);if(e===null)return[];const t=JSON.parse(e);return Array.isArray(t)?t.every(n=>typeof n=="string")?t:[]:[]}catch{return[]}}function JRe(e){if(!(typeof window>"u"))try{const n=hQ().filter(r=>r!==e),o=[e,...n].slice(0,QRe);window.localStorage.setItem(uQ,JSON.stringify(o))}catch{}}const eTe=typeof navigator<"u"&&typeof navigator.platform=="string"&&navigator.platform.toLowerCase().includes("mac"),tTe=e=>e.length===1?e.toUpperCase():e==="Escape"?"Esc":e,Tt=(e,t=eTe)=>{const n=tTe(e.key);if(t){let r="";return e.meta&&(r+="⌘"),e.alt&&(r+="⌥"),e.shift&&(r+="⇧"),`${r}${n}`}const o=[];return e.meta&&o.push("Ctrl"),e.shift&&o.push("Shift"),e.alt&&o.push("Alt"),o.push(n),o.join("+")},lO=[{id:"tool.select",label:"Select tool",description:"Switch to the selection tool",category:"Tools",shortcut:Tt({key:"V"})},{id:"tool.hand",label:"Hand tool",description:"Pan the canvas; node interaction is suspended while armed",category:"Tools",shortcut:Tt({key:"H"})},{id:"tool.rectangle",label:"Rectangle",description:"Draw rectangle nodes",category:"Tools",shortcut:Tt({key:"R"})},{id:"tool.ellipse",label:"Ellipse",description:"Draw ellipse nodes",category:"Tools",shortcut:Tt({key:"O"})},{id:"tool.text",label:"Text",description:"Add a text node",category:"Tools",shortcut:Tt({key:"T"})},{id:"tool.sticky",label:"Sticky note",description:"Add a sticky note",category:"Tools",shortcut:Tt({key:"S"})},{id:"tool.database",label:"Database",description:"Add a database node",category:"Tools",shortcut:Tt({key:"D"})},{id:"tool.server",label:"Server",description:"Add a server node",category:"Tools"},{id:"tool.user",label:"User",description:"Add a user node",category:"Tools"},{id:"tool.queue",label:"Queue",description:"Add a queue node",category:"Tools"},{id:"tool.cloud",label:"Cloud",description:"Add a cloud node",category:"Tools"},{id:"edit.undo",label:"Undo",category:"Edit",shortcut:Tt({meta:!0,key:"Z"}),enabled:e=>e.canUndo},{id:"edit.redo",label:"Redo",category:"Edit",shortcut:Tt({meta:!0,shift:!0,key:"Z"}),enabled:e=>e.canRedo},{id:"edit.copy",label:"Copy",category:"Edit",shortcut:Tt({meta:!0,key:"C"}),enabled:e=>e.hasSelection},{id:"edit.paste",label:"Paste",category:"Edit",shortcut:Tt({meta:!0,key:"V"}),enabled:e=>e.hasClipboard},{id:"edit.duplicate",label:"Duplicate",category:"Edit",shortcut:Tt({meta:!0,key:"D"}),enabled:e=>e.hasSelection},{id:"edit.delete",label:"Delete",category:"Edit",shortcut:Tt({key:"Delete"}),enabled:e=>e.hasSelection},{id:"edit.selectAll",label:"Select all",category:"Edit",shortcut:Tt({meta:!0,key:"A"})},{id:"view.fit",label:"Fit view",description:"Fit everything in the viewport",category:"View",shortcut:Tt({meta:!0,key:"0"})},{id:"view.zoomIn",label:"Zoom in",category:"View",shortcut:Tt({meta:!0,key:"="})},{id:"view.zoomOut",label:"Zoom out",category:"View",shortcut:Tt({meta:!0,key:"-"})},{id:"view.zoom100",label:"Zoom to 100%",category:"View",shortcut:Tt({key:"1"})},{id:"view.zoomToSelection",label:"Zoom to selection",category:"View",shortcut:Tt({key:"F"}),enabled:e=>e.hasSelection},{id:"layout.tidy",label:"Tidy layout",description:"Auto-layout the canvas or current selection",category:"Layout",shortcut:Tt({meta:!0,shift:!0,key:"L"})},{id:"selection.deselect",label:"Deselect",description:"Clear selection and exit draw mode",category:"Selection",shortcut:Tt({key:"Escape"})},{id:"help.commandPalette",label:"Open command palette",category:"Help",shortcut:Tt({meta:!0,key:"P"})},{id:"export.pdf",label:"Export to PDF",description:"Download the current canvas as a PDF",category:"File",enabled:e=>e.canExportDemo},{id:"export.png",label:"Export as image",description:"Download the current canvas as a PNG",category:"File",enabled:e=>e.canExportDemo},{id:"session.reset",label:"Restart the demo",description:"Stop running scripts and re-run the reset script",category:"File",enabled:e=>e.canResetSession}],nT=e=>{const t=lO.find(n=>n.id===e);return t?t.shortcut?`${t.label} (${t.shortcut})`:t.label:""},nTe=1,oTe=10,rTe=e=>{if(e.metaKey||e.ctrlKey||e.altKey)return null;const t=e.shiftKey?oTe:nTe;switch(e.key){case"ArrowLeft":return{dx:-t,dy:0};case"ArrowRight":return{dx:t,dy:0};case"ArrowUp":return{dx:0,dy:-t};case"ArrowDown":return{dx:0,dy:t};default:return null}},aTe=e=>{if(!(e.metaKey||e.ctrlKey)||e.altKey)return null;switch(e.key){case"0":return"fit";case"=":case"+":return"in";case"-":case"_":return"out";default:return null}},iTe=(e,t,n)=>{if(t.length===0)return[];const o=new Map(n.map(a=>[a.id,a])),r=[];for(const a of t){const i=o.get(a);i&&r.push({id:a,position:{x:i.position.x+e.dx,y:i.position.y+e.dy}})}return r},sTe=({event:e,isEditableActive:t,hasNodes:n,hasConnectors:o,selectedIds:r,hasClipboard:a})=>{if(!(e.metaKey||e.ctrlKey))return{type:"noop"};if(e.shiftKey||e.altKey)return{type:"noop"};const i=e.key.toLowerCase();return i!=="a"&&i!=="c"&&i!=="v"&&i!=="d"?{type:"noop"}:t?{type:"noop"}:i==="a"?!n&&!o?{type:"noop"}:{type:"selectAll"}:i==="c"?r.length===0?{type:"noop"}:{type:"copy",ids:r}:i==="d"?r.length===0?{type:"noop"}:{type:"duplicate",ids:r}:a?{type:"paste"}:{type:"noop"}},cTe=e=>{if(e.metaKey||e.ctrlKey||e.shiftKey||e.altKey)return null;switch(e.key.toLowerCase()){case"v":return"select";case"h":return"hand";case"r":return"rectangle";case"o":return"ellipse";case"t":return"text";case"s":return"sticky";case"d":return"database";default:return null}},Xa="seeflow",fQ=e=>`${e}:last-used-style:v1`,oT=()=>({node:{},connector:{}}),rT=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),dO=e=>{var t;try{const n=(t=globalThis.localStorage)==null?void 0:t.getItem(fQ(e));if(!n)return oT();const o=JSON.parse(n);if(!rT(o))return oT();const r=rT(o.node)?o.node:{},a=rT(o.connector)?o.connector:{};return{node:r,connector:a}}catch{return oT()}},pQ=(e,t)=>{var n;try{(n=globalThis.localStorage)==null||n.setItem(fQ(e),JSON.stringify(t))}catch{}},n2=e=>dO(e),tU=(e,t)=>{const{alt:n,...o}=t,r={...o};r.borderSize!==void 0&&r.borderWidth===void 0?r.borderWidth=r.borderSize:r.borderWidth!==void 0&&r.borderSize===void 0&&(r.borderSize=r.borderWidth);const a=dO(e);pQ(e,{...a,node:{...a.node,...r}})},lTe=(e,t)=>{const n=dO(e);pQ(e,{...n,connector:{...n.connector,...t}})},uO=1,nU=17,nH=(e,t)=>{if(!e)return{};const n={};for(const o of t)e[o]!==void 0&&(n[o]=e[o]);return n},dTe=["borderColor","backgroundColor","borderSize","borderStyle","fontSize","cornerRadius","shadow"],uTe=["borderColor","backgroundColor","borderSize","borderStyle","fontSize","shadow"],hTe=["fontSize"],fTe=["borderColor","borderWidth","borderStyle","shadow"];function oU(e,t,n){if(e==="text")return{width:t.width,height:t.height,fontSize:nU,...nH(n,hTe)};const o=e==="ellipse"?uTe:dTe;return{width:t.width,height:t.height,borderSize:uO,fontSize:nU,...nH(n,o)}}function pTe(e,t,n){return{path:e,width:t.width,height:t.height,borderWidth:uO,...nH(n,fTe)}}const xo=async(e,t,n,o)=>{const r={method:t};o!==void 0&&(r.headers={"content-type":"application/json"},r.body=JSON.stringify(o));const a=await e(n,r);if(!a.ok){let i=null;try{i=await a.json()}catch{}throw new Error((i==null?void 0:i.error)??`${t} ${n} → ${a.status}`)}return await a.json()},yTe=e=>{const{baseUrl:t,flowId:n}=e,o=e.fetch??globalThis.fetch.bind(globalThis),r=`${t}/api/flows/${n}`;return{async createNode(a){const i=await xo(o,"POST",`${r}/nodes`,a);return{id:i.id,node:i.node}},async updateNode(a,i){await xo(o,"PATCH",`${r}/nodes/${a}`,i)},async updateNodePosition(a,i){return await xo(o,"PATCH",`${r}/nodes/${a}/position`,i)},async deleteNode(a){await xo(o,"DELETE",`${r}/nodes/${a}`)},async reorderNode(a,i){await xo(o,"PATCH",`${r}/nodes/${a}/order`,i)},async createConnector(a){return{id:(await xo(o,"POST",`${r}/connectors`,a)).id}},async updateConnector(a,i){await xo(o,"PATCH",`${r}/connectors/${a}`,i)},async deleteConnector(a){await xo(o,"DELETE",`${r}/connectors/${a}`)},async uploadImage(a,i,s){const c=new FormData;c.append("file",i),c.append("filename",s);const l=`${t}/api/projects/${encodeURIComponent(n)}/nodes/${encodeURIComponent(a)}/files/upload`,h=await o(l,{method:"POST",body:c});if(!h.ok){let u=null;try{u=await h.json()}catch{}throw new Error((u==null?void 0:u.error)??`POST ${l} → ${h.status}`)}return await h.json()},async playAction(a){return await xo(o,"POST",`${r}/play/${a}`,{})},async openFile(a){await xo(o,"POST",`${t}/api/projects/${encodeURIComponent(n)}/files/open`,{path:a})},async revealFile(a){await xo(o,"POST",`${t}/api/projects/${encodeURIComponent(n)}/files/reveal`,{path:a})},async computeLayout(a,i){const s=await xo(o,"POST",`${t}/api/layout`,{nodes:a,edges:i});return{nodes:s.nodes,connectors:s.connectors}}}};function yQ(e,t,n){let o=null,r=!1;const a=new ResizeObserver(()=>{r||(o!==null&&clearTimeout(o),o=setTimeout(()=>{o=null,!r&&n()},t))});return a.observe(e),()=>{r||(r=!0,o!==null&&(clearTimeout(o),o=null),a.disconnect())}}const mTe="modulepreload",kTe=function(e){return"/"+e},rU={},Iz=function(t,n,o){let r=Promise.resolve();if(n&&n.length>0){document.getElementsByTagName("link");const i=document.querySelector("meta[property=csp-nonce]"),s=(i==null?void 0:i.nonce)||(i==null?void 0:i.getAttribute("nonce"));r=Promise.allSettled(n.map(c=>{if(c=kTe(c),c in rU)return;rU[c]=!0;const l=c.endsWith(".css"),h=l?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${c}"]${h}`))return;const u=document.createElement("link");if(u.rel=l?"stylesheet":mTe,l||(u.as="script"),u.crossOrigin="",u.href=c,s&&u.setAttribute("nonce",s),document.head.appendChild(u),l)return new Promise((f,y)=>{u.addEventListener("load",f),u.addEventListener("error",()=>y(new Error(`Unable to preload CSS for ${c}`)))})}))}function a(i){const s=new Event("vite:preloadError",{cancelable:!0});if(s.payload=i,window.dispatchEvent(s),!s.defaultPrevented)throw i}return r.then(i=>{for(const s of i||[])s.status==="rejected"&&a(s.reason);return t().catch(a)})};var at;(function(e){e.assertEqual=r=>{};function t(r){}e.assertIs=t;function n(r){throw new Error}e.assertNever=n,e.arrayToEnum=r=>{const a={};for(const i of r)a[i]=i;return a},e.getValidEnumValues=r=>{const a=e.objectKeys(r).filter(s=>typeof r[r[s]]!="number"),i={};for(const s of a)i[s]=r[s];return e.objectValues(i)},e.objectValues=r=>e.objectKeys(r).map(function(a){return r[a]}),e.objectKeys=typeof Object.keys=="function"?r=>Object.keys(r):r=>{const a=[];for(const i in r)Object.prototype.hasOwnProperty.call(r,i)&&a.push(i);return a},e.find=(r,a)=>{for(const i of r)if(a(i))return i},e.isInteger=typeof Number.isInteger=="function"?r=>Number.isInteger(r):r=>typeof r=="number"&&Number.isFinite(r)&&Math.floor(r)===r;function o(r,a=" | "){return r.map(i=>typeof i=="string"?`'${i}'`:i).join(a)}e.joinValues=o,e.jsonStringifyReplacer=(r,a)=>typeof a=="bigint"?a.toString():a})(at||(at={}));var aU;(function(e){e.mergeShapes=(t,n)=>({...t,...n})})(aU||(aU={}));const Se=at.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),ni=e=>{switch(typeof e){case"undefined":return Se.undefined;case"string":return Se.string;case"number":return Number.isNaN(e)?Se.nan:Se.number;case"boolean":return Se.boolean;case"function":return Se.function;case"bigint":return Se.bigint;case"symbol":return Se.symbol;case"object":return Array.isArray(e)?Se.array:e===null?Se.null:e.then&&typeof e.then=="function"&&e.catch&&typeof e.catch=="function"?Se.promise:typeof Map<"u"&&e instanceof Map?Se.map:typeof Set<"u"&&e instanceof Set?Se.set:typeof Date<"u"&&e instanceof Date?Se.date:Se.object;default:return Se.unknown}},ye=at.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]);class _a extends Error{get errors(){return this.issues}constructor(t){super(),this.issues=[],this.addIssue=o=>{this.issues=[...this.issues,o]},this.addIssues=(o=[])=>{this.issues=[...this.issues,...o]};const n=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,n):this.__proto__=n,this.name="ZodError",this.issues=t}format(t){const n=t||function(a){return a.message},o={_errors:[]},r=a=>{for(const i of a.issues)if(i.code==="invalid_union")i.unionErrors.map(r);else if(i.code==="invalid_return_type")r(i.returnTypeError);else if(i.code==="invalid_arguments")r(i.argumentsError);else if(i.path.length===0)o._errors.push(n(i));else{let s=o,c=0;for(;c<i.path.length;){const l=i.path[c];c===i.path.length-1?(s[l]=s[l]||{_errors:[]},s[l]._errors.push(n(i))):s[l]=s[l]||{_errors:[]},s=s[l],c++}}};return r(this),o}static assert(t){if(!(t instanceof _a))throw new Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,at.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(t=n=>n.message){const n={},o=[];for(const r of this.issues)if(r.path.length>0){const a=r.path[0];n[a]=n[a]||[],n[a].push(t(r))}else o.push(t(r));return{formErrors:o,fieldErrors:n}}get formErrors(){return this.flatten()}}_a.create=e=>new _a(e);const oH=(e,t)=>{let n;switch(e.code){case ye.invalid_type:e.received===Se.undefined?n="Required":n=`Expected ${e.expected}, received ${e.received}`;break;case ye.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(e.expected,at.jsonStringifyReplacer)}`;break;case ye.unrecognized_keys:n=`Unrecognized key(s) in object: ${at.joinValues(e.keys,", ")}`;break;case ye.invalid_union:n="Invalid input";break;case ye.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${at.joinValues(e.options)}`;break;case ye.invalid_enum_value:n=`Invalid enum value. Expected ${at.joinValues(e.options)}, received '${e.received}'`;break;case ye.invalid_arguments:n="Invalid function arguments";break;case ye.invalid_return_type:n="Invalid function return type";break;case ye.invalid_date:n="Invalid date";break;case ye.invalid_string:typeof e.validation=="object"?"includes"in e.validation?(n=`Invalid input: must include "${e.validation.includes}"`,typeof e.validation.position=="number"&&(n=`${n} at one or more positions greater than or equal to ${e.validation.position}`)):"startsWith"in e.validation?n=`Invalid input: must start with "${e.validation.startsWith}"`:"endsWith"in e.validation?n=`Invalid input: must end with "${e.validation.endsWith}"`:at.assertNever(e.validation):e.validation!=="regex"?n=`Invalid ${e.validation}`:n="Invalid";break;case ye.too_small:e.type==="array"?n=`Array must contain ${e.exact?"exactly":e.inclusive?"at least":"more than"} ${e.minimum} element(s)`:e.type==="string"?n=`String must contain ${e.exact?"exactly":e.inclusive?"at least":"over"} ${e.minimum} character(s)`:e.type==="number"?n=`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:e.type==="bigint"?n=`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:e.type==="date"?n=`Date must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(e.minimum))}`:n="Invalid input";break;case ye.too_big:e.type==="array"?n=`Array must contain ${e.exact?"exactly":e.inclusive?"at most":"less than"} ${e.maximum} element(s)`:e.type==="string"?n=`String must contain ${e.exact?"exactly":e.inclusive?"at most":"under"} ${e.maximum} character(s)`:e.type==="number"?n=`Number must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:e.type==="bigint"?n=`BigInt must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:e.type==="date"?n=`Date must be ${e.exact?"exactly":e.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(e.maximum))}`:n="Invalid input";break;case ye.custom:n="Invalid input";break;case ye.invalid_intersection_types:n="Intersection results could not be merged";break;case ye.not_multiple_of:n=`Number must be a multiple of ${e.multipleOf}`;break;case ye.not_finite:n="Number must be finite";break;default:n=t.defaultError,at.assertNever(e)}return{message:n}};let gTe=oH;function vTe(){return gTe}const xTe=e=>{const{data:t,path:n,errorMaps:o,issueData:r}=e,a=[...n,...r.path||[]],i={...r,path:a};if(r.message!==void 0)return{...r,path:a,message:r.message};let s="";const c=o.filter(l=>!!l).slice().reverse();for(const l of c)s=l(i,{data:t,defaultError:s}).message;return{...r,path:a,message:s}};function Me(e,t){const n=vTe(),o=xTe({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,n,n===oH?void 0:oH].filter(r=>!!r)});e.common.issues.push(o)}class En{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(t,n){const o=[];for(const r of n){if(r.status==="aborted")return Fe;r.status==="dirty"&&t.dirty(),o.push(r.value)}return{status:t.value,value:o}}static async mergeObjectAsync(t,n){const o=[];for(const r of n){const a=await r.key,i=await r.value;o.push({key:a,value:i})}return En.mergeObjectSync(t,o)}static mergeObjectSync(t,n){const o={};for(const r of n){const{key:a,value:i}=r;if(a.status==="aborted"||i.status==="aborted")return Fe;a.status==="dirty"&&t.dirty(),i.status==="dirty"&&t.dirty(),a.value!=="__proto__"&&(typeof i.value<"u"||r.alwaysSet)&&(o[a.value]=i.value)}return{status:t.value,value:o}}}const Fe=Object.freeze({status:"aborted"}),o2=e=>({status:"dirty",value:e}),No=e=>({status:"valid",value:e}),iU=e=>e.status==="aborted",sU=e=>e.status==="dirty",Xu=e=>e.status==="valid",Nj=e=>typeof Promise<"u"&&e instanceof Promise;var Ne;(function(e){e.errToObj=t=>typeof t=="string"?{message:t}:t||{},e.toString=t=>typeof t=="string"?t:t==null?void 0:t.message})(Ne||(Ne={}));class Fr{constructor(t,n,o,r){this._cachedPath=[],this.parent=t,this.data=n,this._path=o,this._key=r}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const cU=(e,t)=>{if(Xu(t))return{success:!0,data:t.value};if(!e.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const n=new _a(e.common.issues);return this._error=n,this._error}}};function Ze(e){if(!e)return{};const{errorMap:t,invalid_type_error:n,required_error:o,description:r}=e;if(t&&(n||o))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return t?{errorMap:t,description:r}:{errorMap:(i,s)=>{const{message:c}=e;return i.code==="invalid_enum_value"?{message:c??s.defaultError}:typeof s.data>"u"?{message:c??o??s.defaultError}:i.code!=="invalid_type"?{message:s.defaultError}:{message:c??n??s.defaultError}},description:r}}class et{get description(){return this._def.description}_getType(t){return ni(t.data)}_getOrReturnCtx(t,n){return n||{common:t.parent.common,data:t.data,parsedType:ni(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}_processInputParams(t){return{status:new En,ctx:{common:t.parent.common,data:t.data,parsedType:ni(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}}_parseSync(t){const n=this._parse(t);if(Nj(n))throw new Error("Synchronous parse encountered promise.");return n}_parseAsync(t){const n=this._parse(t);return Promise.resolve(n)}parse(t,n){const o=this.safeParse(t,n);if(o.success)return o.data;throw o.error}safeParse(t,n){const o={common:{issues:[],async:(n==null?void 0:n.async)??!1,contextualErrorMap:n==null?void 0:n.errorMap},path:(n==null?void 0:n.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:ni(t)},r=this._parseSync({data:t,path:o.path,parent:o});return cU(o,r)}"~validate"(t){var o,r;const n={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:ni(t)};if(!this["~standard"].async)try{const a=this._parseSync({data:t,path:[],parent:n});return Xu(a)?{value:a.value}:{issues:n.common.issues}}catch(a){(r=(o=a==null?void 0:a.message)==null?void 0:o.toLowerCase())!=null&&r.includes("encountered")&&(this["~standard"].async=!0),n.common={issues:[],async:!0}}return this._parseAsync({data:t,path:[],parent:n}).then(a=>Xu(a)?{value:a.value}:{issues:n.common.issues})}async parseAsync(t,n){const o=await this.safeParseAsync(t,n);if(o.success)return o.data;throw o.error}async safeParseAsync(t,n){const o={common:{issues:[],contextualErrorMap:n==null?void 0:n.errorMap,async:!0},path:(n==null?void 0:n.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:ni(t)},r=this._parse({data:t,path:o.path,parent:o}),a=await(Nj(r)?r:Promise.resolve(r));return cU(o,a)}refine(t,n){const o=r=>typeof n=="string"||typeof n>"u"?{message:n}:typeof n=="function"?n(r):n;return this._refinement((r,a)=>{const i=t(r),s=()=>a.addIssue({code:ye.custom,...o(r)});return typeof Promise<"u"&&i instanceof Promise?i.then(c=>c?!0:(s(),!1)):i?!0:(s(),!1)})}refinement(t,n){return this._refinement((o,r)=>t(o)?!0:(r.addIssue(typeof n=="function"?n(o,r):n),!1))}_refinement(t){return new Ju({schema:this,typeName:qe.ZodEffects,effect:{type:"refinement",refinement:t}})}superRefine(t){return this._refinement(t)}constructor(t){this.spa=this.safeParseAsync,this._def=t,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:n=>this["~validate"](n)}}optional(){return gi.create(this,this._def)}nullable(){return e0.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Hr.create(this)}promise(){return jj.create(this,this._def)}or(t){return Ej.create([this,t],this._def)}and(t){return $j.create(this,t,this._def)}transform(t){return new Ju({...Ze(this._def),schema:this,typeName:qe.ZodEffects,effect:{type:"transform",transform:t}})}default(t){const n=typeof t=="function"?t:()=>t;return new cH({...Ze(this._def),innerType:this,defaultValue:n,typeName:qe.ZodDefault})}brand(){return new VTe({typeName:qe.ZodBranded,type:this,...Ze(this._def)})}catch(t){const n=typeof t=="function"?t:()=>t;return new lH({...Ze(this._def),innerType:this,catchValue:n,typeName:qe.ZodCatch})}describe(t){const n=this.constructor;return new n({...this._def,description:t})}pipe(t){return hO.create(this,t)}readonly(){return dH.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const wTe=/^c[^\s-]{8,}$/i,MTe=/^[0-9a-z]+$/,bTe=/^[0-9A-HJKMNP-TV-Z]{26}$/i,_Te=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,CTe=/^[a-z0-9_-]{21}$/i,STe=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,LTe=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,ITe=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,NTe="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let aT;const ATe=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,ETe=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,$Te=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,PTe=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,jTe=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,zTe=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,mQ="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",RTe=new RegExp(`^${mQ}$`);function kQ(e){let t="[0-5]\\d";e.precision?t=`${t}\\.\\d{${e.precision}}`:e.precision==null&&(t=`${t}(\\.\\d+)?`);const n=e.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${t})${n}`}function TTe(e){return new RegExp(`^${kQ(e)}$`)}function DTe(e){let t=`${mQ}T${kQ(e)}`;const n=[];return n.push(e.local?"Z?":"Z"),e.offset&&n.push("([+-]\\d{2}:?\\d{2})"),t=`${t}(${n.join("|")})`,new RegExp(`^${t}$`)}function HTe(e,t){return!!((t==="v4"||!t)&&ATe.test(e)||(t==="v6"||!t)&&$Te.test(e))}function qTe(e,t){if(!STe.test(e))return!1;try{const[n]=e.split(".");if(!n)return!1;const o=n.replace(/-/g,"+").replace(/_/g,"/").padEnd(n.length+(4-n.length%4)%4,"="),r=JSON.parse(atob(o));return!(typeof r!="object"||r===null||"typ"in r&&(r==null?void 0:r.typ)!=="JWT"||!r.alg||t&&r.alg!==t)}catch{return!1}}function OTe(e,t){return!!((t==="v4"||!t)&&ETe.test(e)||(t==="v6"||!t)&&PTe.test(e))}class ka extends et{_parse(t){if(this._def.coerce&&(t.data=String(t.data)),this._getType(t)!==Se.string){const a=this._getOrReturnCtx(t);return Me(a,{code:ye.invalid_type,expected:Se.string,received:a.parsedType}),Fe}const o=new En;let r;for(const a of this._def.checks)if(a.kind==="min")t.data.length<a.value&&(r=this._getOrReturnCtx(t,r),Me(r,{code:ye.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),o.dirty());else if(a.kind==="max")t.data.length>a.value&&(r=this._getOrReturnCtx(t,r),Me(r,{code:ye.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),o.dirty());else if(a.kind==="length"){const i=t.data.length>a.value,s=t.data.length<a.value;(i||s)&&(r=this._getOrReturnCtx(t,r),i?Me(r,{code:ye.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}):s&&Me(r,{code:ye.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}),o.dirty())}else if(a.kind==="email")ITe.test(t.data)||(r=this._getOrReturnCtx(t,r),Me(r,{validation:"email",code:ye.invalid_string,message:a.message}),o.dirty());else if(a.kind==="emoji")aT||(aT=new RegExp(NTe,"u")),aT.test(t.data)||(r=this._getOrReturnCtx(t,r),Me(r,{validation:"emoji",code:ye.invalid_string,message:a.message}),o.dirty());else if(a.kind==="uuid")_Te.test(t.data)||(r=this._getOrReturnCtx(t,r),Me(r,{validation:"uuid",code:ye.invalid_string,message:a.message}),o.dirty());else if(a.kind==="nanoid")CTe.test(t.data)||(r=this._getOrReturnCtx(t,r),Me(r,{validation:"nanoid",code:ye.invalid_string,message:a.message}),o.dirty());else if(a.kind==="cuid")wTe.test(t.data)||(r=this._getOrReturnCtx(t,r),Me(r,{validation:"cuid",code:ye.invalid_string,message:a.message}),o.dirty());else if(a.kind==="cuid2")MTe.test(t.data)||(r=this._getOrReturnCtx(t,r),Me(r,{validation:"cuid2",code:ye.invalid_string,message:a.message}),o.dirty());else if(a.kind==="ulid")bTe.test(t.data)||(r=this._getOrReturnCtx(t,r),Me(r,{validation:"ulid",code:ye.invalid_string,message:a.message}),o.dirty());else if(a.kind==="url")try{new URL(t.data)}catch{r=this._getOrReturnCtx(t,r),Me(r,{validation:"url",code:ye.invalid_string,message:a.message}),o.dirty()}else a.kind==="regex"?(a.regex.lastIndex=0,a.regex.test(t.data)||(r=this._getOrReturnCtx(t,r),Me(r,{validation:"regex",code:ye.invalid_string,message:a.message}),o.dirty())):a.kind==="trim"?t.data=t.data.trim():a.kind==="includes"?t.data.includes(a.value,a.position)||(r=this._getOrReturnCtx(t,r),Me(r,{code:ye.invalid_string,validation:{includes:a.value,position:a.position},message:a.message}),o.dirty()):a.kind==="toLowerCase"?t.data=t.data.toLowerCase():a.kind==="toUpperCase"?t.data=t.data.toUpperCase():a.kind==="startsWith"?t.data.startsWith(a.value)||(r=this._getOrReturnCtx(t,r),Me(r,{code:ye.invalid_string,validation:{startsWith:a.value},message:a.message}),o.dirty()):a.kind==="endsWith"?t.data.endsWith(a.value)||(r=this._getOrReturnCtx(t,r),Me(r,{code:ye.invalid_string,validation:{endsWith:a.value},message:a.message}),o.dirty()):a.kind==="datetime"?DTe(a).test(t.data)||(r=this._getOrReturnCtx(t,r),Me(r,{code:ye.invalid_string,validation:"datetime",message:a.message}),o.dirty()):a.kind==="date"?RTe.test(t.data)||(r=this._getOrReturnCtx(t,r),Me(r,{code:ye.invalid_string,validation:"date",message:a.message}),o.dirty()):a.kind==="time"?TTe(a).test(t.data)||(r=this._getOrReturnCtx(t,r),Me(r,{code:ye.invalid_string,validation:"time",message:a.message}),o.dirty()):a.kind==="duration"?LTe.test(t.data)||(r=this._getOrReturnCtx(t,r),Me(r,{validation:"duration",code:ye.invalid_string,message:a.message}),o.dirty()):a.kind==="ip"?HTe(t.data,a.version)||(r=this._getOrReturnCtx(t,r),Me(r,{validation:"ip",code:ye.invalid_string,message:a.message}),o.dirty()):a.kind==="jwt"?qTe(t.data,a.alg)||(r=this._getOrReturnCtx(t,r),Me(r,{validation:"jwt",code:ye.invalid_string,message:a.message}),o.dirty()):a.kind==="cidr"?OTe(t.data,a.version)||(r=this._getOrReturnCtx(t,r),Me(r,{validation:"cidr",code:ye.invalid_string,message:a.message}),o.dirty()):a.kind==="base64"?jTe.test(t.data)||(r=this._getOrReturnCtx(t,r),Me(r,{validation:"base64",code:ye.invalid_string,message:a.message}),o.dirty()):a.kind==="base64url"?zTe.test(t.data)||(r=this._getOrReturnCtx(t,r),Me(r,{validation:"base64url",code:ye.invalid_string,message:a.message}),o.dirty()):at.assertNever(a);return{status:o.value,value:t.data}}_regex(t,n,o){return this.refinement(r=>t.test(r),{validation:n,code:ye.invalid_string,...Ne.errToObj(o)})}_addCheck(t){return new ka({...this._def,checks:[...this._def.checks,t]})}email(t){return this._addCheck({kind:"email",...Ne.errToObj(t)})}url(t){return this._addCheck({kind:"url",...Ne.errToObj(t)})}emoji(t){return this._addCheck({kind:"emoji",...Ne.errToObj(t)})}uuid(t){return this._addCheck({kind:"uuid",...Ne.errToObj(t)})}nanoid(t){return this._addCheck({kind:"nanoid",...Ne.errToObj(t)})}cuid(t){return this._addCheck({kind:"cuid",...Ne.errToObj(t)})}cuid2(t){return this._addCheck({kind:"cuid2",...Ne.errToObj(t)})}ulid(t){return this._addCheck({kind:"ulid",...Ne.errToObj(t)})}base64(t){return this._addCheck({kind:"base64",...Ne.errToObj(t)})}base64url(t){return this._addCheck({kind:"base64url",...Ne.errToObj(t)})}jwt(t){return this._addCheck({kind:"jwt",...Ne.errToObj(t)})}ip(t){return this._addCheck({kind:"ip",...Ne.errToObj(t)})}cidr(t){return this._addCheck({kind:"cidr",...Ne.errToObj(t)})}datetime(t){return typeof t=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:t}):this._addCheck({kind:"datetime",precision:typeof(t==null?void 0:t.precision)>"u"?null:t==null?void 0:t.precision,offset:(t==null?void 0:t.offset)??!1,local:(t==null?void 0:t.local)??!1,...Ne.errToObj(t==null?void 0:t.message)})}date(t){return this._addCheck({kind:"date",message:t})}time(t){return typeof t=="string"?this._addCheck({kind:"time",precision:null,message:t}):this._addCheck({kind:"time",precision:typeof(t==null?void 0:t.precision)>"u"?null:t==null?void 0:t.precision,...Ne.errToObj(t==null?void 0:t.message)})}duration(t){return this._addCheck({kind:"duration",...Ne.errToObj(t)})}regex(t,n){return this._addCheck({kind:"regex",regex:t,...Ne.errToObj(n)})}includes(t,n){return this._addCheck({kind:"includes",value:t,position:n==null?void 0:n.position,...Ne.errToObj(n==null?void 0:n.message)})}startsWith(t,n){return this._addCheck({kind:"startsWith",value:t,...Ne.errToObj(n)})}endsWith(t,n){return this._addCheck({kind:"endsWith",value:t,...Ne.errToObj(n)})}min(t,n){return this._addCheck({kind:"min",value:t,...Ne.errToObj(n)})}max(t,n){return this._addCheck({kind:"max",value:t,...Ne.errToObj(n)})}length(t,n){return this._addCheck({kind:"length",value:t,...Ne.errToObj(n)})}nonempty(t){return this.min(1,Ne.errToObj(t))}trim(){return new ka({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new ka({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new ka({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(t=>t.kind==="datetime")}get isDate(){return!!this._def.checks.find(t=>t.kind==="date")}get isTime(){return!!this._def.checks.find(t=>t.kind==="time")}get isDuration(){return!!this._def.checks.find(t=>t.kind==="duration")}get isEmail(){return!!this._def.checks.find(t=>t.kind==="email")}get isURL(){return!!this._def.checks.find(t=>t.kind==="url")}get isEmoji(){return!!this._def.checks.find(t=>t.kind==="emoji")}get isUUID(){return!!this._def.checks.find(t=>t.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(t=>t.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(t=>t.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(t=>t.kind==="cuid2")}get isULID(){return!!this._def.checks.find(t=>t.kind==="ulid")}get isIP(){return!!this._def.checks.find(t=>t.kind==="ip")}get isCIDR(){return!!this._def.checks.find(t=>t.kind==="cidr")}get isBase64(){return!!this._def.checks.find(t=>t.kind==="base64")}get isBase64url(){return!!this._def.checks.find(t=>t.kind==="base64url")}get minLength(){let t=null;for(const n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t}get maxLength(){let t=null;for(const n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t}}ka.create=e=>new ka({checks:[],typeName:qe.ZodString,coerce:(e==null?void 0:e.coerce)??!1,...Ze(e)});function FTe(e,t){const n=(e.toString().split(".")[1]||"").length,o=(t.toString().split(".")[1]||"").length,r=n>o?n:o,a=Number.parseInt(e.toFixed(r).replace(".","")),i=Number.parseInt(t.toFixed(r).replace(".",""));return a%i/10**r}class Yu extends et{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(t){if(this._def.coerce&&(t.data=Number(t.data)),this._getType(t)!==Se.number){const a=this._getOrReturnCtx(t);return Me(a,{code:ye.invalid_type,expected:Se.number,received:a.parsedType}),Fe}let o;const r=new En;for(const a of this._def.checks)a.kind==="int"?at.isInteger(t.data)||(o=this._getOrReturnCtx(t,o),Me(o,{code:ye.invalid_type,expected:"integer",received:"float",message:a.message}),r.dirty()):a.kind==="min"?(a.inclusive?t.data<a.value:t.data<=a.value)&&(o=this._getOrReturnCtx(t,o),Me(o,{code:ye.too_small,minimum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),r.dirty()):a.kind==="max"?(a.inclusive?t.data>a.value:t.data>=a.value)&&(o=this._getOrReturnCtx(t,o),Me(o,{code:ye.too_big,maximum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),r.dirty()):a.kind==="multipleOf"?FTe(t.data,a.value)!==0&&(o=this._getOrReturnCtx(t,o),Me(o,{code:ye.not_multiple_of,multipleOf:a.value,message:a.message}),r.dirty()):a.kind==="finite"?Number.isFinite(t.data)||(o=this._getOrReturnCtx(t,o),Me(o,{code:ye.not_finite,message:a.message}),r.dirty()):at.assertNever(a);return{status:r.value,value:t.data}}gte(t,n){return this.setLimit("min",t,!0,Ne.toString(n))}gt(t,n){return this.setLimit("min",t,!1,Ne.toString(n))}lte(t,n){return this.setLimit("max",t,!0,Ne.toString(n))}lt(t,n){return this.setLimit("max",t,!1,Ne.toString(n))}setLimit(t,n,o,r){return new Yu({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:o,message:Ne.toString(r)}]})}_addCheck(t){return new Yu({...this._def,checks:[...this._def.checks,t]})}int(t){return this._addCheck({kind:"int",message:Ne.toString(t)})}positive(t){return this._addCheck({kind:"min",value:0,inclusive:!1,message:Ne.toString(t)})}negative(t){return this._addCheck({kind:"max",value:0,inclusive:!1,message:Ne.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:0,inclusive:!0,message:Ne.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:0,inclusive:!0,message:Ne.toString(t)})}multipleOf(t,n){return this._addCheck({kind:"multipleOf",value:t,message:Ne.toString(n)})}finite(t){return this._addCheck({kind:"finite",message:Ne.toString(t)})}safe(t){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:Ne.toString(t)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:Ne.toString(t)})}get minValue(){let t=null;for(const n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t}get maxValue(){let t=null;for(const n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t}get isInt(){return!!this._def.checks.find(t=>t.kind==="int"||t.kind==="multipleOf"&&at.isInteger(t.value))}get isFinite(){let t=null,n=null;for(const o of this._def.checks){if(o.kind==="finite"||o.kind==="int"||o.kind==="multipleOf")return!0;o.kind==="min"?(n===null||o.value>n)&&(n=o.value):o.kind==="max"&&(t===null||o.value<t)&&(t=o.value)}return Number.isFinite(n)&&Number.isFinite(t)}}Yu.create=e=>new Yu({checks:[],typeName:qe.ZodNumber,coerce:(e==null?void 0:e.coerce)||!1,...Ze(e)});class Mh extends et{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(t){if(this._def.coerce)try{t.data=BigInt(t.data)}catch{return this._getInvalidInput(t)}if(this._getType(t)!==Se.bigint)return this._getInvalidInput(t);let o;const r=new En;for(const a of this._def.checks)a.kind==="min"?(a.inclusive?t.data<a.value:t.data<=a.value)&&(o=this._getOrReturnCtx(t,o),Me(o,{code:ye.too_small,type:"bigint",minimum:a.value,inclusive:a.inclusive,message:a.message}),r.dirty()):a.kind==="max"?(a.inclusive?t.data>a.value:t.data>=a.value)&&(o=this._getOrReturnCtx(t,o),Me(o,{code:ye.too_big,type:"bigint",maximum:a.value,inclusive:a.inclusive,message:a.message}),r.dirty()):a.kind==="multipleOf"?t.data%a.value!==BigInt(0)&&(o=this._getOrReturnCtx(t,o),Me(o,{code:ye.not_multiple_of,multipleOf:a.value,message:a.message}),r.dirty()):at.assertNever(a);return{status:r.value,value:t.data}}_getInvalidInput(t){const n=this._getOrReturnCtx(t);return Me(n,{code:ye.invalid_type,expected:Se.bigint,received:n.parsedType}),Fe}gte(t,n){return this.setLimit("min",t,!0,Ne.toString(n))}gt(t,n){return this.setLimit("min",t,!1,Ne.toString(n))}lte(t,n){return this.setLimit("max",t,!0,Ne.toString(n))}lt(t,n){return this.setLimit("max",t,!1,Ne.toString(n))}setLimit(t,n,o,r){return new Mh({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:o,message:Ne.toString(r)}]})}_addCheck(t){return new Mh({...this._def,checks:[...this._def.checks,t]})}positive(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:Ne.toString(t)})}negative(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:Ne.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:Ne.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:Ne.toString(t)})}multipleOf(t,n){return this._addCheck({kind:"multipleOf",value:t,message:Ne.toString(n)})}get minValue(){let t=null;for(const n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t}get maxValue(){let t=null;for(const n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t}}Mh.create=e=>new Mh({checks:[],typeName:qe.ZodBigInt,coerce:(e==null?void 0:e.coerce)??!1,...Ze(e)});class rH extends et{_parse(t){if(this._def.coerce&&(t.data=!!t.data),this._getType(t)!==Se.boolean){const o=this._getOrReturnCtx(t);return Me(o,{code:ye.invalid_type,expected:Se.boolean,received:o.parsedType}),Fe}return No(t.data)}}rH.create=e=>new rH({typeName:qe.ZodBoolean,coerce:(e==null?void 0:e.coerce)||!1,...Ze(e)});class Aj extends et{_parse(t){if(this._def.coerce&&(t.data=new Date(t.data)),this._getType(t)!==Se.date){const a=this._getOrReturnCtx(t);return Me(a,{code:ye.invalid_type,expected:Se.date,received:a.parsedType}),Fe}if(Number.isNaN(t.data.getTime())){const a=this._getOrReturnCtx(t);return Me(a,{code:ye.invalid_date}),Fe}const o=new En;let r;for(const a of this._def.checks)a.kind==="min"?t.data.getTime()<a.value&&(r=this._getOrReturnCtx(t,r),Me(r,{code:ye.too_small,message:a.message,inclusive:!0,exact:!1,minimum:a.value,type:"date"}),o.dirty()):a.kind==="max"?t.data.getTime()>a.value&&(r=this._getOrReturnCtx(t,r),Me(r,{code:ye.too_big,message:a.message,inclusive:!0,exact:!1,maximum:a.value,type:"date"}),o.dirty()):at.assertNever(a);return{status:o.value,value:new Date(t.data.getTime())}}_addCheck(t){return new Aj({...this._def,checks:[...this._def.checks,t]})}min(t,n){return this._addCheck({kind:"min",value:t.getTime(),message:Ne.toString(n)})}max(t,n){return this._addCheck({kind:"max",value:t.getTime(),message:Ne.toString(n)})}get minDate(){let t=null;for(const n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t!=null?new Date(t):null}get maxDate(){let t=null;for(const n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t!=null?new Date(t):null}}Aj.create=e=>new Aj({checks:[],coerce:(e==null?void 0:e.coerce)||!1,typeName:qe.ZodDate,...Ze(e)});class lU extends et{_parse(t){if(this._getType(t)!==Se.symbol){const o=this._getOrReturnCtx(t);return Me(o,{code:ye.invalid_type,expected:Se.symbol,received:o.parsedType}),Fe}return No(t.data)}}lU.create=e=>new lU({typeName:qe.ZodSymbol,...Ze(e)});class dU extends et{_parse(t){if(this._getType(t)!==Se.undefined){const o=this._getOrReturnCtx(t);return Me(o,{code:ye.invalid_type,expected:Se.undefined,received:o.parsedType}),Fe}return No(t.data)}}dU.create=e=>new dU({typeName:qe.ZodUndefined,...Ze(e)});class uU extends et{_parse(t){if(this._getType(t)!==Se.null){const o=this._getOrReturnCtx(t);return Me(o,{code:ye.invalid_type,expected:Se.null,received:o.parsedType}),Fe}return No(t.data)}}uU.create=e=>new uU({typeName:qe.ZodNull,...Ze(e)});class hU extends et{constructor(){super(...arguments),this._any=!0}_parse(t){return No(t.data)}}hU.create=e=>new hU({typeName:qe.ZodAny,...Ze(e)});class aH extends et{constructor(){super(...arguments),this._unknown=!0}_parse(t){return No(t.data)}}aH.create=e=>new aH({typeName:qe.ZodUnknown,...Ze(e)});class bi extends et{_parse(t){const n=this._getOrReturnCtx(t);return Me(n,{code:ye.invalid_type,expected:Se.never,received:n.parsedType}),Fe}}bi.create=e=>new bi({typeName:qe.ZodNever,...Ze(e)});class fU extends et{_parse(t){if(this._getType(t)!==Se.undefined){const o=this._getOrReturnCtx(t);return Me(o,{code:ye.invalid_type,expected:Se.void,received:o.parsedType}),Fe}return No(t.data)}}fU.create=e=>new fU({typeName:qe.ZodVoid,...Ze(e)});class Hr extends et{_parse(t){const{ctx:n,status:o}=this._processInputParams(t),r=this._def;if(n.parsedType!==Se.array)return Me(n,{code:ye.invalid_type,expected:Se.array,received:n.parsedType}),Fe;if(r.exactLength!==null){const i=n.data.length>r.exactLength.value,s=n.data.length<r.exactLength.value;(i||s)&&(Me(n,{code:i?ye.too_big:ye.too_small,minimum:s?r.exactLength.value:void 0,maximum:i?r.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:r.exactLength.message}),o.dirty())}if(r.minLength!==null&&n.data.length<r.minLength.value&&(Me(n,{code:ye.too_small,minimum:r.minLength.value,type:"array",inclusive:!0,exact:!1,message:r.minLength.message}),o.dirty()),r.maxLength!==null&&n.data.length>r.maxLength.value&&(Me(n,{code:ye.too_big,maximum:r.maxLength.value,type:"array",inclusive:!0,exact:!1,message:r.maxLength.message}),o.dirty()),n.common.async)return Promise.all([...n.data].map((i,s)=>r.type._parseAsync(new Fr(n,i,n.path,s)))).then(i=>En.mergeArray(o,i));const a=[...n.data].map((i,s)=>r.type._parseSync(new Fr(n,i,n.path,s)));return En.mergeArray(o,a)}get element(){return this._def.type}min(t,n){return new Hr({...this._def,minLength:{value:t,message:Ne.toString(n)}})}max(t,n){return new Hr({...this._def,maxLength:{value:t,message:Ne.toString(n)}})}length(t,n){return new Hr({...this._def,exactLength:{value:t,message:Ne.toString(n)}})}nonempty(t){return this.min(1,t)}}Hr.create=(e,t)=>new Hr({type:e,minLength:null,maxLength:null,exactLength:null,typeName:qe.ZodArray,...Ze(t)});function Kd(e){if(e instanceof Wt){const t={};for(const n in e.shape){const o=e.shape[n];t[n]=gi.create(Kd(o))}return new Wt({...e._def,shape:()=>t})}else return e instanceof Hr?new Hr({...e._def,type:Kd(e.element)}):e instanceof gi?gi.create(Kd(e.unwrap())):e instanceof e0?e0.create(Kd(e.unwrap())):e instanceof kd?kd.create(e.items.map(t=>Kd(t))):e}class Wt extends et{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const t=this._def.shape(),n=at.objectKeys(t);return this._cached={shape:t,keys:n},this._cached}_parse(t){if(this._getType(t)!==Se.object){const l=this._getOrReturnCtx(t);return Me(l,{code:ye.invalid_type,expected:Se.object,received:l.parsedType}),Fe}const{status:o,ctx:r}=this._processInputParams(t),{shape:a,keys:i}=this._getCached(),s=[];if(!(this._def.catchall instanceof bi&&this._def.unknownKeys==="strip"))for(const l in r.data)i.includes(l)||s.push(l);const c=[];for(const l of i){const h=a[l],u=r.data[l];c.push({key:{status:"valid",value:l},value:h._parse(new Fr(r,u,r.path,l)),alwaysSet:l in r.data})}if(this._def.catchall instanceof bi){const l=this._def.unknownKeys;if(l==="passthrough")for(const h of s)c.push({key:{status:"valid",value:h},value:{status:"valid",value:r.data[h]}});else if(l==="strict")s.length>0&&(Me(r,{code:ye.unrecognized_keys,keys:s}),o.dirty());else if(l!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const l=this._def.catchall;for(const h of s){const u=r.data[h];c.push({key:{status:"valid",value:h},value:l._parse(new Fr(r,u,r.path,h)),alwaysSet:h in r.data})}}return r.common.async?Promise.resolve().then(async()=>{const l=[];for(const h of c){const u=await h.key,f=await h.value;l.push({key:u,value:f,alwaysSet:h.alwaysSet})}return l}).then(l=>En.mergeObjectSync(o,l)):En.mergeObjectSync(o,c)}get shape(){return this._def.shape()}strict(t){return Ne.errToObj,new Wt({...this._def,unknownKeys:"strict",...t!==void 0?{errorMap:(n,o)=>{var a,i;const r=((i=(a=this._def).errorMap)==null?void 0:i.call(a,n,o).message)??o.defaultError;return n.code==="unrecognized_keys"?{message:Ne.errToObj(t).message??r}:{message:r}}}:{}})}strip(){return new Wt({...this._def,unknownKeys:"strip"})}passthrough(){return new Wt({...this._def,unknownKeys:"passthrough"})}extend(t){return new Wt({...this._def,shape:()=>({...this._def.shape(),...t})})}merge(t){return new Wt({unknownKeys:t._def.unknownKeys,catchall:t._def.catchall,shape:()=>({...this._def.shape(),...t._def.shape()}),typeName:qe.ZodObject})}setKey(t,n){return this.augment({[t]:n})}catchall(t){return new Wt({...this._def,catchall:t})}pick(t){const n={};for(const o of at.objectKeys(t))t[o]&&this.shape[o]&&(n[o]=this.shape[o]);return new Wt({...this._def,shape:()=>n})}omit(t){const n={};for(const o of at.objectKeys(this.shape))t[o]||(n[o]=this.shape[o]);return new Wt({...this._def,shape:()=>n})}deepPartial(){return Kd(this)}partial(t){const n={};for(const o of at.objectKeys(this.shape)){const r=this.shape[o];t&&!t[o]?n[o]=r:n[o]=r.optional()}return new Wt({...this._def,shape:()=>n})}required(t){const n={};for(const o of at.objectKeys(this.shape))if(t&&!t[o])n[o]=this.shape[o];else{let a=this.shape[o];for(;a instanceof gi;)a=a._def.innerType;n[o]=a}return new Wt({...this._def,shape:()=>n})}keyof(){return gQ(at.objectKeys(this.shape))}}Wt.create=(e,t)=>new Wt({shape:()=>e,unknownKeys:"strip",catchall:bi.create(),typeName:qe.ZodObject,...Ze(t)});Wt.strictCreate=(e,t)=>new Wt({shape:()=>e,unknownKeys:"strict",catchall:bi.create(),typeName:qe.ZodObject,...Ze(t)});Wt.lazycreate=(e,t)=>new Wt({shape:e,unknownKeys:"strip",catchall:bi.create(),typeName:qe.ZodObject,...Ze(t)});class Ej extends et{_parse(t){const{ctx:n}=this._processInputParams(t),o=this._def.options;function r(a){for(const s of a)if(s.result.status==="valid")return s.result;for(const s of a)if(s.result.status==="dirty")return n.common.issues.push(...s.ctx.common.issues),s.result;const i=a.map(s=>new _a(s.ctx.common.issues));return Me(n,{code:ye.invalid_union,unionErrors:i}),Fe}if(n.common.async)return Promise.all(o.map(async a=>{const i={...n,common:{...n.common,issues:[]},parent:null};return{result:await a._parseAsync({data:n.data,path:n.path,parent:i}),ctx:i}})).then(r);{let a;const i=[];for(const c of o){const l={...n,common:{...n.common,issues:[]},parent:null},h=c._parseSync({data:n.data,path:n.path,parent:l});if(h.status==="valid")return h;h.status==="dirty"&&!a&&(a={result:h,ctx:l}),l.common.issues.length&&i.push(l.common.issues)}if(a)return n.common.issues.push(...a.ctx.common.issues),a.result;const s=i.map(c=>new _a(c));return Me(n,{code:ye.invalid_union,unionErrors:s}),Fe}}get options(){return this._def.options}}Ej.create=(e,t)=>new Ej({options:e,typeName:qe.ZodUnion,...Ze(t)});function iH(e,t){const n=ni(e),o=ni(t);if(e===t)return{valid:!0,data:e};if(n===Se.object&&o===Se.object){const r=at.objectKeys(t),a=at.objectKeys(e).filter(s=>r.indexOf(s)!==-1),i={...e,...t};for(const s of a){const c=iH(e[s],t[s]);if(!c.valid)return{valid:!1};i[s]=c.data}return{valid:!0,data:i}}else if(n===Se.array&&o===Se.array){if(e.length!==t.length)return{valid:!1};const r=[];for(let a=0;a<e.length;a++){const i=e[a],s=t[a],c=iH(i,s);if(!c.valid)return{valid:!1};r.push(c.data)}return{valid:!0,data:r}}else return n===Se.date&&o===Se.date&&+e==+t?{valid:!0,data:e}:{valid:!1}}class $j extends et{_parse(t){const{status:n,ctx:o}=this._processInputParams(t),r=(a,i)=>{if(iU(a)||iU(i))return Fe;const s=iH(a.value,i.value);return s.valid?((sU(a)||sU(i))&&n.dirty(),{status:n.value,value:s.data}):(Me(o,{code:ye.invalid_intersection_types}),Fe)};return o.common.async?Promise.all([this._def.left._parseAsync({data:o.data,path:o.path,parent:o}),this._def.right._parseAsync({data:o.data,path:o.path,parent:o})]).then(([a,i])=>r(a,i)):r(this._def.left._parseSync({data:o.data,path:o.path,parent:o}),this._def.right._parseSync({data:o.data,path:o.path,parent:o}))}}$j.create=(e,t,n)=>new $j({left:e,right:t,typeName:qe.ZodIntersection,...Ze(n)});class kd extends et{_parse(t){const{status:n,ctx:o}=this._processInputParams(t);if(o.parsedType!==Se.array)return Me(o,{code:ye.invalid_type,expected:Se.array,received:o.parsedType}),Fe;if(o.data.length<this._def.items.length)return Me(o,{code:ye.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),Fe;!this._def.rest&&o.data.length>this._def.items.length&&(Me(o,{code:ye.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),n.dirty());const a=[...o.data].map((i,s)=>{const c=this._def.items[s]||this._def.rest;return c?c._parse(new Fr(o,i,o.path,s)):null}).filter(i=>!!i);return o.common.async?Promise.all(a).then(i=>En.mergeArray(n,i)):En.mergeArray(n,a)}get items(){return this._def.items}rest(t){return new kd({...this._def,rest:t})}}kd.create=(e,t)=>{if(!Array.isArray(e))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new kd({items:e,typeName:qe.ZodTuple,rest:null,...Ze(t)})};class Pj extends et{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){const{status:n,ctx:o}=this._processInputParams(t);if(o.parsedType!==Se.object)return Me(o,{code:ye.invalid_type,expected:Se.object,received:o.parsedType}),Fe;const r=[],a=this._def.keyType,i=this._def.valueType;for(const s in o.data)r.push({key:a._parse(new Fr(o,s,o.path,s)),value:i._parse(new Fr(o,o.data[s],o.path,s)),alwaysSet:s in o.data});return o.common.async?En.mergeObjectAsync(n,r):En.mergeObjectSync(n,r)}get element(){return this._def.valueType}static create(t,n,o){return n instanceof et?new Pj({keyType:t,valueType:n,typeName:qe.ZodRecord,...Ze(o)}):new Pj({keyType:ka.create(),valueType:t,typeName:qe.ZodRecord,...Ze(n)})}}class pU extends et{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){const{status:n,ctx:o}=this._processInputParams(t);if(o.parsedType!==Se.map)return Me(o,{code:ye.invalid_type,expected:Se.map,received:o.parsedType}),Fe;const r=this._def.keyType,a=this._def.valueType,i=[...o.data.entries()].map(([s,c],l)=>({key:r._parse(new Fr(o,s,o.path,[l,"key"])),value:a._parse(new Fr(o,c,o.path,[l,"value"]))}));if(o.common.async){const s=new Map;return Promise.resolve().then(async()=>{for(const c of i){const l=await c.key,h=await c.value;if(l.status==="aborted"||h.status==="aborted")return Fe;(l.status==="dirty"||h.status==="dirty")&&n.dirty(),s.set(l.value,h.value)}return{status:n.value,value:s}})}else{const s=new Map;for(const c of i){const l=c.key,h=c.value;if(l.status==="aborted"||h.status==="aborted")return Fe;(l.status==="dirty"||h.status==="dirty")&&n.dirty(),s.set(l.value,h.value)}return{status:n.value,value:s}}}}pU.create=(e,t,n)=>new pU({valueType:t,keyType:e,typeName:qe.ZodMap,...Ze(n)});class bh extends et{_parse(t){const{status:n,ctx:o}=this._processInputParams(t);if(o.parsedType!==Se.set)return Me(o,{code:ye.invalid_type,expected:Se.set,received:o.parsedType}),Fe;const r=this._def;r.minSize!==null&&o.data.size<r.minSize.value&&(Me(o,{code:ye.too_small,minimum:r.minSize.value,type:"set",inclusive:!0,exact:!1,message:r.minSize.message}),n.dirty()),r.maxSize!==null&&o.data.size>r.maxSize.value&&(Me(o,{code:ye.too_big,maximum:r.maxSize.value,type:"set",inclusive:!0,exact:!1,message:r.maxSize.message}),n.dirty());const a=this._def.valueType;function i(c){const l=new Set;for(const h of c){if(h.status==="aborted")return Fe;h.status==="dirty"&&n.dirty(),l.add(h.value)}return{status:n.value,value:l}}const s=[...o.data.values()].map((c,l)=>a._parse(new Fr(o,c,o.path,l)));return o.common.async?Promise.all(s).then(c=>i(c)):i(s)}min(t,n){return new bh({...this._def,minSize:{value:t,message:Ne.toString(n)}})}max(t,n){return new bh({...this._def,maxSize:{value:t,message:Ne.toString(n)}})}size(t,n){return this.min(t,n).max(t,n)}nonempty(t){return this.min(1,t)}}bh.create=(e,t)=>new bh({valueType:e,minSize:null,maxSize:null,typeName:qe.ZodSet,...Ze(t)});class yU extends et{get schema(){return this._def.getter()}_parse(t){const{ctx:n}=this._processInputParams(t);return this._def.getter()._parse({data:n.data,path:n.path,parent:n})}}yU.create=(e,t)=>new yU({getter:e,typeName:qe.ZodLazy,...Ze(t)});class sH extends et{_parse(t){if(t.data!==this._def.value){const n=this._getOrReturnCtx(t);return Me(n,{received:n.data,code:ye.invalid_literal,expected:this._def.value}),Fe}return{status:"valid",value:t.data}}get value(){return this._def.value}}sH.create=(e,t)=>new sH({value:e,typeName:qe.ZodLiteral,...Ze(t)});function gQ(e,t){return new Qu({values:e,typeName:qe.ZodEnum,...Ze(t)})}class Qu extends et{_parse(t){if(typeof t.data!="string"){const n=this._getOrReturnCtx(t),o=this._def.values;return Me(n,{expected:at.joinValues(o),received:n.parsedType,code:ye.invalid_type}),Fe}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(t.data)){const n=this._getOrReturnCtx(t),o=this._def.values;return Me(n,{received:n.data,code:ye.invalid_enum_value,options:o}),Fe}return No(t.data)}get options(){return this._def.values}get enum(){const t={};for(const n of this._def.values)t[n]=n;return t}get Values(){const t={};for(const n of this._def.values)t[n]=n;return t}get Enum(){const t={};for(const n of this._def.values)t[n]=n;return t}extract(t,n=this._def){return Qu.create(t,{...this._def,...n})}exclude(t,n=this._def){return Qu.create(this.options.filter(o=>!t.includes(o)),{...this._def,...n})}}Qu.create=gQ;class mU extends et{_parse(t){const n=at.getValidEnumValues(this._def.values),o=this._getOrReturnCtx(t);if(o.parsedType!==Se.string&&o.parsedType!==Se.number){const r=at.objectValues(n);return Me(o,{expected:at.joinValues(r),received:o.parsedType,code:ye.invalid_type}),Fe}if(this._cache||(this._cache=new Set(at.getValidEnumValues(this._def.values))),!this._cache.has(t.data)){const r=at.objectValues(n);return Me(o,{received:o.data,code:ye.invalid_enum_value,options:r}),Fe}return No(t.data)}get enum(){return this._def.values}}mU.create=(e,t)=>new mU({values:e,typeName:qe.ZodNativeEnum,...Ze(t)});class jj extends et{unwrap(){return this._def.type}_parse(t){const{ctx:n}=this._processInputParams(t);if(n.parsedType!==Se.promise&&n.common.async===!1)return Me(n,{code:ye.invalid_type,expected:Se.promise,received:n.parsedType}),Fe;const o=n.parsedType===Se.promise?n.data:Promise.resolve(n.data);return No(o.then(r=>this._def.type.parseAsync(r,{path:n.path,errorMap:n.common.contextualErrorMap})))}}jj.create=(e,t)=>new jj({type:e,typeName:qe.ZodPromise,...Ze(t)});class Ju extends et{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===qe.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(t){const{status:n,ctx:o}=this._processInputParams(t),r=this._def.effect||null,a={addIssue:i=>{Me(o,i),i.fatal?n.abort():n.dirty()},get path(){return o.path}};if(a.addIssue=a.addIssue.bind(a),r.type==="preprocess"){const i=r.transform(o.data,a);if(o.common.async)return Promise.resolve(i).then(async s=>{if(n.value==="aborted")return Fe;const c=await this._def.schema._parseAsync({data:s,path:o.path,parent:o});return c.status==="aborted"?Fe:c.status==="dirty"||n.value==="dirty"?o2(c.value):c});{if(n.value==="aborted")return Fe;const s=this._def.schema._parseSync({data:i,path:o.path,parent:o});return s.status==="aborted"?Fe:s.status==="dirty"||n.value==="dirty"?o2(s.value):s}}if(r.type==="refinement"){const i=s=>{const c=r.refinement(s,a);if(o.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return s};if(o.common.async===!1){const s=this._def.schema._parseSync({data:o.data,path:o.path,parent:o});return s.status==="aborted"?Fe:(s.status==="dirty"&&n.dirty(),i(s.value),{status:n.value,value:s.value})}else return this._def.schema._parseAsync({data:o.data,path:o.path,parent:o}).then(s=>s.status==="aborted"?Fe:(s.status==="dirty"&&n.dirty(),i(s.value).then(()=>({status:n.value,value:s.value}))))}if(r.type==="transform")if(o.common.async===!1){const i=this._def.schema._parseSync({data:o.data,path:o.path,parent:o});if(!Xu(i))return Fe;const s=r.transform(i.value,a);if(s instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:n.value,value:s}}else return this._def.schema._parseAsync({data:o.data,path:o.path,parent:o}).then(i=>Xu(i)?Promise.resolve(r.transform(i.value,a)).then(s=>({status:n.value,value:s})):Fe);at.assertNever(r)}}Ju.create=(e,t,n)=>new Ju({schema:e,typeName:qe.ZodEffects,effect:t,...Ze(n)});Ju.createWithPreprocess=(e,t,n)=>new Ju({schema:t,effect:{type:"preprocess",transform:e},typeName:qe.ZodEffects,...Ze(n)});class gi extends et{_parse(t){return this._getType(t)===Se.undefined?No(void 0):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}}gi.create=(e,t)=>new gi({innerType:e,typeName:qe.ZodOptional,...Ze(t)});class e0 extends et{_parse(t){return this._getType(t)===Se.null?No(null):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}}e0.create=(e,t)=>new e0({innerType:e,typeName:qe.ZodNullable,...Ze(t)});class cH extends et{_parse(t){const{ctx:n}=this._processInputParams(t);let o=n.data;return n.parsedType===Se.undefined&&(o=this._def.defaultValue()),this._def.innerType._parse({data:o,path:n.path,parent:n})}removeDefault(){return this._def.innerType}}cH.create=(e,t)=>new cH({innerType:e,typeName:qe.ZodDefault,defaultValue:typeof t.default=="function"?t.default:()=>t.default,...Ze(t)});class lH extends et{_parse(t){const{ctx:n}=this._processInputParams(t),o={...n,common:{...n.common,issues:[]}},r=this._def.innerType._parse({data:o.data,path:o.path,parent:{...o}});return Nj(r)?r.then(a=>({status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new _a(o.common.issues)},input:o.data})})):{status:"valid",value:r.status==="valid"?r.value:this._def.catchValue({get error(){return new _a(o.common.issues)},input:o.data})}}removeCatch(){return this._def.innerType}}lH.create=(e,t)=>new lH({innerType:e,typeName:qe.ZodCatch,catchValue:typeof t.catch=="function"?t.catch:()=>t.catch,...Ze(t)});class kU extends et{_parse(t){if(this._getType(t)!==Se.nan){const o=this._getOrReturnCtx(t);return Me(o,{code:ye.invalid_type,expected:Se.nan,received:o.parsedType}),Fe}return{status:"valid",value:t.data}}}kU.create=e=>new kU({typeName:qe.ZodNaN,...Ze(e)});class VTe extends et{_parse(t){const{ctx:n}=this._processInputParams(t),o=n.data;return this._def.type._parse({data:o,path:n.path,parent:n})}unwrap(){return this._def.type}}class hO extends et{_parse(t){const{status:n,ctx:o}=this._processInputParams(t);if(o.common.async)return(async()=>{const a=await this._def.in._parseAsync({data:o.data,path:o.path,parent:o});return a.status==="aborted"?Fe:a.status==="dirty"?(n.dirty(),o2(a.value)):this._def.out._parseAsync({data:a.value,path:o.path,parent:o})})();{const r=this._def.in._parseSync({data:o.data,path:o.path,parent:o});return r.status==="aborted"?Fe:r.status==="dirty"?(n.dirty(),{status:"dirty",value:r.value}):this._def.out._parseSync({data:r.value,path:o.path,parent:o})}}static create(t,n){return new hO({in:t,out:n,typeName:qe.ZodPipeline})}}class dH extends et{_parse(t){const n=this._def.innerType._parse(t),o=r=>(Xu(r)&&(r.value=Object.freeze(r.value)),r);return Nj(n)?n.then(r=>o(r)):o(n)}unwrap(){return this._def.innerType}}dH.create=(e,t)=>new dH({innerType:e,typeName:qe.ZodReadonly,...Ze(t)});var qe;(function(e){e.ZodString="ZodString",e.ZodNumber="ZodNumber",e.ZodNaN="ZodNaN",e.ZodBigInt="ZodBigInt",e.ZodBoolean="ZodBoolean",e.ZodDate="ZodDate",e.ZodSymbol="ZodSymbol",e.ZodUndefined="ZodUndefined",e.ZodNull="ZodNull",e.ZodAny="ZodAny",e.ZodUnknown="ZodUnknown",e.ZodNever="ZodNever",e.ZodVoid="ZodVoid",e.ZodArray="ZodArray",e.ZodObject="ZodObject",e.ZodUnion="ZodUnion",e.ZodDiscriminatedUnion="ZodDiscriminatedUnion",e.ZodIntersection="ZodIntersection",e.ZodTuple="ZodTuple",e.ZodRecord="ZodRecord",e.ZodMap="ZodMap",e.ZodSet="ZodSet",e.ZodFunction="ZodFunction",e.ZodLazy="ZodLazy",e.ZodLiteral="ZodLiteral",e.ZodEnum="ZodEnum",e.ZodEffects="ZodEffects",e.ZodNativeEnum="ZodNativeEnum",e.ZodOptional="ZodOptional",e.ZodNullable="ZodNullable",e.ZodDefault="ZodDefault",e.ZodCatch="ZodCatch",e.ZodPromise="ZodPromise",e.ZodBranded="ZodBranded",e.ZodPipeline="ZodPipeline",e.ZodReadonly="ZodReadonly"})(qe||(qe={}));const dn=ka.create,vQ=Yu.create,BTe=rH.create,O2=aH.create;bi.create;const qi=Hr.create,rt=Wt.create,uH=Ej.create;$j.create;kd.create;const gU=Pj.create,Xf=sH.create,Yf=Qu.create;jj.create;gi.create;e0.create;const UTe=rt({$state:dn().min(1)}),da=rt({$action:dn().min(1)}),WTe=rt({$cond:O2(),$then:O2(),$else:O2().optional()}),Fo=e=>uH([e,UTe,da,WTe]),Dt=Fo(dn()),ia=Fo(vQ()),Qf=Fo(BTe()),xQ={Card:rt({title:Dt.optional()}),Separator:rt({orientation:Fo(Yf(["horizontal","vertical"])).optional()}),Tabs:rt({value:Dt.optional(),items:qi(rt({id:dn(),label:dn()})),onChange:da.optional()}),Accordion:rt({items:qi(rt({id:dn(),title:dn(),content:dn()}))}),Badge:rt({label:Dt,variant:Fo(Yf(["default","secondary","destructive","outline"])).optional()}),Avatar:rt({src:Dt.optional(),alt:Dt.optional(),fallback:Dt.optional()}),Progress:rt({value:ia}),Skeleton:rt({width:ia.optional(),height:ia.optional()}),Label:rt({text:Dt}),Heading:rt({level:Fo(uH([Xf(1),Xf(2),Xf(3),Xf(4)])).optional(),text:Dt}),Text:rt({text:Dt,muted:Qf.optional()}),Icon:rt({name:Dt,size:ia.optional()}),Chart:rt({kind:Fo(Yf(["bar","line","area","pie"])),data:Fo(qi(gU(dn(),O2()))),xKey:Dt.optional(),series:qi(rt({key:dn(),label:dn().optional()})).optional()}),Table:rt({columns:qi(rt({key:dn(),label:dn()})),rows:Fo(qi(gU(dn(),O2())))}),Metric:rt({label:Dt,value:Fo(uH([dn(),vQ()]))}),CodeBlock:rt({code:Dt,language:Dt.optional()}),Markdown:rt({content:Dt}),Button:rt({label:Dt,variant:Fo(Yf(["default","destructive","outline","secondary","ghost","link"])).optional(),onClick:da.optional(),disabled:Qf.optional()}),Input:rt({value:Dt.optional(),placeholder:Dt.optional(),onChange:da.optional()}),Checkbox:rt({checked:Qf.optional(),onChange:da.optional(),label:Dt.optional()}),Switch:rt({checked:Qf.optional(),onChange:da.optional()}),Select:rt({value:Dt.optional(),items:qi(rt({value:dn(),label:dn()})),onChange:da.optional()}),Textarea:rt({value:Dt.optional(),placeholder:Dt.optional(),rows:ia.optional(),onChange:da.optional()}),Slider:rt({value:ia.optional(),min:ia.optional(),max:ia.optional(),step:ia.optional(),onChange:da.optional()})},wQ=Object.keys(xQ);Object.fromEntries(wQ.map(e=>[e,{props:xQ[e],description:e}]));function vU(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function Vr(...e){return t=>{let n=!1;const o=e.map(r=>{const a=vU(r,t);return!n&&typeof a=="function"&&(n=!0),a});if(n)return()=>{for(let r=0;r<o.length;r++){const a=o[r];typeof a=="function"?a():vU(e[r],null)}}}}function kt(...e){return m.useCallback(Vr(...e),e)}var GTe=Symbol.for("react.lazy"),zj=eq[" use ".trim().toString()];function ZTe(e){return typeof e=="object"&&e!==null&&"then"in e}function MQ(e){return e!=null&&typeof e=="object"&&"$$typeof"in e&&e.$$typeof===GTe&&"_payload"in e&&ZTe(e._payload)}function KTe(e){const t=YTe(e),n=m.forwardRef((o,r)=>{let{children:a,...i}=o;MQ(a)&&typeof zj=="function"&&(a=zj(a._payload));const s=m.Children.toArray(a),c=s.find(JTe);if(c){const l=c.props.children,h=s.map(u=>u===c?m.Children.count(l)>1?m.Children.only(null):m.isValidElement(l)?l.props.children:null:u);return p.jsx(t,{...i,ref:r,children:m.isValidElement(l)?m.cloneElement(l,void 0,h):null})}return p.jsx(t,{...i,ref:r,children:a})});return n.displayName=`${e}.Slot`,n}var XTe=KTe("Slot");function YTe(e){const t=m.forwardRef((n,o)=>{let{children:r,...a}=n;if(MQ(r)&&typeof zj=="function"&&(r=zj(r._payload)),m.isValidElement(r)){const i=tDe(r),s=eDe(a,r.props);return r.type!==m.Fragment&&(s.ref=o?Vr(o,i):i),m.cloneElement(r,s)}return m.Children.count(r)>1?m.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var QTe=Symbol("radix.slottable");function JTe(e){return m.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===QTe}function eDe(e,t){const n={...t};for(const o in t){const r=e[o],a=t[o];/^on[A-Z]/.test(o)?r&&a?n[o]=(...s)=>{const c=a(...s);return r(...s),c}:r&&(n[o]=r):o==="style"?n[o]={...r,...a}:o==="className"&&(n[o]=[r,a].filter(Boolean).join(" "))}return{...e,...n}}function tDe(e){var o,r;let t=(o=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:o.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(r=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}const xU=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,wU=fX,bQ=(e,t)=>n=>{var o;if((t==null?void 0:t.variants)==null)return wU(e,n==null?void 0:n.class,n==null?void 0:n.className);const{variants:r,defaultVariants:a}=t,i=Object.keys(r).map(l=>{const h=n==null?void 0:n[l],u=a==null?void 0:a[l];if(h===null)return null;const f=xU(h)||xU(u);return r[l][f]}),s=n&&Object.entries(n).reduce((l,h)=>{let[u,f]=h;return f===void 0||(l[u]=f),l},{}),c=t==null||(o=t.compoundVariants)===null||o===void 0?void 0:o.reduce((l,h)=>{let{class:u,className:f,...y}=h;return Object.entries(y).every(k=>{let[x,w]=k;return Array.isArray(w)?w.includes({...a,...s}[x]):{...a,...s}[x]===w})?[...l,u,f]:l},[]);return wU(e,i,c,n==null?void 0:n.class,n==null?void 0:n.className)},nDe=bQ("sf:inline-flex sf:items-center sf:justify-center sf:whitespace-nowrap sf:rounded-md sf:text-sm sf:font-medium sf:ring-offset-background sf:transition-colors sf:focus-visible:outline-hidden sf:focus-visible:ring-2 sf:focus-visible:ring-ring sf:focus-visible:ring-offset-2 sf:disabled:pointer-events-none sf:disabled:opacity-50",{variants:{variant:{default:"sf:bg-primary sf:text-primary-foreground sf:font-semibold sf:hover:bg-emerald-400",destructive:"sf:bg-destructive sf:text-destructive-foreground sf:hover:bg-destructive/90",outline:"sf:border sf:border-input sf:bg-background sf:hover:bg-secondary sf:hover:text-foreground",secondary:"sf:bg-secondary sf:text-secondary-foreground sf:hover:bg-secondary/80",ghost:"sf:text-muted-foreground sf:hover:bg-muted sf:hover:text-foreground",link:"sf:text-primary sf:underline-offset-4 sf:hover:underline"},size:{default:"sf:h-9 sf:px-4 sf:py-2",sm:"sf:h-8 sf:rounded-md sf:px-3",lg:"sf:h-11 sf:rounded-md sf:px-8",icon:"sf:h-9 sf:w-9"}},defaultVariants:{variant:"default",size:"default"}}),qt=m.forwardRef(({className:e,variant:t,size:n,asChild:o=!1,...r},a)=>{const i=o?XTe:"button";return p.jsx(i,{className:ae(nDe({variant:t,size:n,className:e})),ref:a,...r})});qt.displayName="Button";function _Q(e,[t,n]){return Math.min(n,Math.max(t,e))}function Le(e,t,{checkForDefaultPrevented:n=!0}={}){return function(r){if(e==null||e(r),n===!1||!r.defaultPrevented)return t==null?void 0:t(r)}}function oDe(e,t){const n=m.createContext(t),o=a=>{const{children:i,...s}=a,c=m.useMemo(()=>s,Object.values(s));return p.jsx(n.Provider,{value:c,children:i})};o.displayName=e+"Provider";function r(a){const i=m.useContext(n);if(i)return i;if(t!==void 0)return t;throw new Error(`\`${a}\` must be used within \`${e}\``)}return[o,r]}function nr(e,t=[]){let n=[];function o(a,i){const s=m.createContext(i),c=n.length;n=[...n,i];const l=u=>{var g;const{scope:f,children:y,...k}=u,x=((g=f==null?void 0:f[e])==null?void 0:g[c])||s,w=m.useMemo(()=>k,Object.values(k));return p.jsx(x.Provider,{value:w,children:y})};l.displayName=a+"Provider";function h(u,f){var x;const y=((x=f==null?void 0:f[e])==null?void 0:x[c])||s,k=m.useContext(y);if(k)return k;if(i!==void 0)return i;throw new Error(`\`${u}\` must be used within \`${a}\``)}return[l,h]}const r=()=>{const a=n.map(i=>m.createContext(i));return function(s){const c=(s==null?void 0:s[e])||a;return m.useMemo(()=>({[`__scope${e}`]:{...s,[e]:c}}),[s,c])}};return r.scopeName=e,[o,rDe(r,...t)]}function rDe(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const o=e.map(r=>({useScope:r(),scopeName:r.scopeName}));return function(a){const i=o.reduce((s,{useScope:c,scopeName:l})=>{const u=c(a)[`__scope${l}`];return{...s,...u}},{});return m.useMemo(()=>({[`__scope${t.scopeName}`]:i}),[i])}};return n.scopeName=t.scopeName,n}var _i=globalThis!=null&&globalThis.document?m.useLayoutEffect:()=>{},aDe=eq[" useInsertionEffect ".trim().toString()]||_i;function Cd({prop:e,defaultProp:t,onChange:n=()=>{},caller:o}){const[r,a,i]=iDe({defaultProp:t,onChange:n}),s=e!==void 0,c=s?e:r;{const h=m.useRef(e!==void 0);m.useEffect(()=>{const u=h.current;u!==s&&console.warn(`${o} is changing from ${u?"controlled":"uncontrolled"} to ${s?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),h.current=s},[s,o])}const l=m.useCallback(h=>{var u;if(s){const f=sDe(h)?h(e):h;f!==e&&((u=i.current)==null||u.call(i,f))}else a(h)},[s,e,a,i]);return[c,l]}function iDe({defaultProp:e,onChange:t}){const[n,o]=m.useState(e),r=m.useRef(n),a=m.useRef(t);return aDe(()=>{a.current=t},[t]),m.useEffect(()=>{var i;r.current!==n&&((i=a.current)==null||i.call(a,n),r.current=n)},[n,r]),[n,o,a]}function sDe(e){return typeof e=="function"}var cDe=m.createContext(void 0);function Nz(e){const t=m.useContext(cDe);return e||t||"ltr"}function lDe(e){const t=m.useRef({value:e,previous:e});return m.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}function CQ(e){const[t,n]=m.useState(void 0);return _i(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const o=new ResizeObserver(r=>{if(!Array.isArray(r)||!r.length)return;const a=r[0];let i,s;if("borderBoxSize"in a){const c=a.borderBoxSize,l=Array.isArray(c)?c[0]:c;i=l.inlineSize,s=l.blockSize}else i=e.offsetWidth,s=e.offsetHeight;n({width:i,height:s})});return o.observe(e,{box:"border-box"}),()=>o.unobserve(e)}else n(void 0)},[e]),t}function t0(e){const t=dDe(e),n=m.forwardRef((o,r)=>{const{children:a,...i}=o,s=m.Children.toArray(a),c=s.find(hDe);if(c){const l=c.props.children,h=s.map(u=>u===c?m.Children.count(l)>1?m.Children.only(null):m.isValidElement(l)?l.props.children:null:u);return p.jsx(t,{...i,ref:r,children:m.isValidElement(l)?m.cloneElement(l,void 0,h):null})}return p.jsx(t,{...i,ref:r,children:a})});return n.displayName=`${e}.Slot`,n}function dDe(e){const t=m.forwardRef((n,o)=>{const{children:r,...a}=n;if(m.isValidElement(r)){const i=pDe(r),s=fDe(a,r.props);return r.type!==m.Fragment&&(s.ref=o?Vr(o,i):i),m.cloneElement(r,s)}return m.Children.count(r)>1?m.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var SQ=Symbol("radix.slottable");function uDe(e){const t=({children:n})=>p.jsx(p.Fragment,{children:n});return t.displayName=`${e}.Slottable`,t.__radixId=SQ,t}function hDe(e){return m.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===SQ}function fDe(e,t){const n={...t};for(const o in t){const r=e[o],a=t[o];/^on[A-Z]/.test(o)?r&&a?n[o]=(...s)=>{const c=a(...s);return r(...s),c}:r&&(n[o]=r):o==="style"?n[o]={...r,...a}:o==="className"&&(n[o]=[r,a].filter(Boolean).join(" "))}return{...e,...n}}function pDe(e){var o,r;let t=(o=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:o.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(r=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var yDe=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Be=yDe.reduce((e,t)=>{const n=t0(`Primitive.${t}`),o=m.forwardRef((r,a)=>{const{asChild:i,...s}=r,c=i?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),p.jsx(c,{...s,ref:a})});return o.displayName=`Primitive.${t}`,{...e,[t]:o}},{});function LQ(e,t){e&&h0.flushSync(()=>e.dispatchEvent(t))}function fO(e){const t=e+"CollectionProvider",[n,o]=nr(t),[r,a]=n(t,{collectionRef:{current:null},itemMap:new Map}),i=x=>{const{scope:w,children:g}=x,M=Ar.useRef(null),v=Ar.useRef(new Map).current;return p.jsx(r,{scope:w,itemMap:v,collectionRef:M,children:g})};i.displayName=t;const s=e+"CollectionSlot",c=t0(s),l=Ar.forwardRef((x,w)=>{const{scope:g,children:M}=x,v=a(s,g),b=kt(w,v.collectionRef);return p.jsx(c,{ref:b,children:M})});l.displayName=s;const h=e+"CollectionItemSlot",u="data-radix-collection-item",f=t0(h),y=Ar.forwardRef((x,w)=>{const{scope:g,children:M,...v}=x,b=Ar.useRef(null),C=kt(w,b),_=a(h,g);return Ar.useEffect(()=>(_.itemMap.set(b,{ref:b,...v}),()=>void _.itemMap.delete(b))),p.jsx(f,{[u]:"",ref:C,children:M})});y.displayName=h;function k(x){const w=a(e+"CollectionConsumer",x);return Ar.useCallback(()=>{const M=w.collectionRef.current;if(!M)return[];const v=Array.from(M.querySelectorAll(`[${u}]`));return Array.from(w.itemMap.values()).sort((_,S)=>v.indexOf(_.ref.current)-v.indexOf(S.ref.current))},[w.collectionRef,w.itemMap])}return[{Provider:i,Slot:l,ItemSlot:y},k,o]}var IQ=["PageUp","PageDown"],NQ=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],AQ={"from-left":["Home","PageDown","ArrowDown","ArrowLeft"],"from-right":["Home","PageDown","ArrowDown","ArrowRight"],"from-bottom":["Home","PageDown","ArrowDown","ArrowLeft"],"from-top":["Home","PageDown","ArrowUp","ArrowLeft"]},m0="Slider",[hH,mDe,kDe]=fO(m0),[EQ]=nr(m0,[kDe]),[gDe,Az]=EQ(m0),$Q=m.forwardRef((e,t)=>{const{name:n,min:o=0,max:r=100,step:a=1,orientation:i="horizontal",disabled:s=!1,minStepsBetweenThumbs:c=0,defaultValue:l=[o],value:h,onValueChange:u=()=>{},onValueCommit:f=()=>{},inverted:y=!1,form:k,...x}=e,w=m.useRef(new Set),g=m.useRef(0),v=i==="horizontal"?vDe:xDe,[b=[],C]=Cd({prop:h,defaultProp:l,onChange:$=>{var X;(X=[...w.current][g.current])==null||X.focus(),u($)}}),_=m.useRef(b);function S($){const N=CDe(b,$);I($,N)}function A($){I($,g.current)}function P(){const $=_.current[g.current];b[g.current]!==$&&f(b)}function I($,N,{commit:X}={commit:!1}){const j=NDe(a),O=ADe(Math.round(($-o)/a)*a+o,j),H=_Q(O,[o,r]);C((B=[])=>{const z=bDe(B,H,N);if(IDe(z,c*a)){g.current=z.indexOf(H);const R=String(z)!==String(B);return R&&X&&f(z),R?z:B}else return B})}return p.jsx(gDe,{scope:e.__scopeSlider,name:n,disabled:s,min:o,max:r,valueIndexToChangeRef:g,thumbs:w.current,values:b,orientation:i,form:k,children:p.jsx(hH.Provider,{scope:e.__scopeSlider,children:p.jsx(hH.Slot,{scope:e.__scopeSlider,children:p.jsx(v,{"aria-disabled":s,"data-disabled":s?"":void 0,...x,ref:t,onPointerDown:Le(x.onPointerDown,()=>{s||(_.current=b)}),min:o,max:r,inverted:y,onSlideStart:s?void 0:S,onSlideMove:s?void 0:A,onSlideEnd:s?void 0:P,onHomeKeyDown:()=>!s&&I(o,0,{commit:!0}),onEndKeyDown:()=>!s&&I(r,b.length-1,{commit:!0}),onStepKeyDown:({event:$,direction:N})=>{if(!s){const O=IQ.includes($.key)||$.shiftKey&&NQ.includes($.key)?10:1,H=g.current,B=b[H],z=a*O*N;I(B+z,H,{commit:!0})}}})})})})});$Q.displayName=m0;var[PQ,jQ]=EQ(m0,{startEdge:"left",endEdge:"right",size:"width",direction:1}),vDe=m.forwardRef((e,t)=>{const{min:n,max:o,dir:r,inverted:a,onSlideStart:i,onSlideMove:s,onSlideEnd:c,onStepKeyDown:l,...h}=e,[u,f]=m.useState(null),y=kt(t,v=>f(v)),k=m.useRef(void 0),x=Nz(r),w=x==="ltr",g=w&&!a||!w&&a;function M(v){const b=k.current||u.getBoundingClientRect(),C=[0,b.width],S=pO(C,g?[n,o]:[o,n]);return k.current=b,S(v-b.left)}return p.jsx(PQ,{scope:e.__scopeSlider,startEdge:g?"left":"right",endEdge:g?"right":"left",direction:g?1:-1,size:"width",children:p.jsx(zQ,{dir:x,"data-orientation":"horizontal",...h,ref:y,style:{...h.style,"--radix-slider-thumb-transform":"translateX(-50%)"},onSlideStart:v=>{const b=M(v.clientX);i==null||i(b)},onSlideMove:v=>{const b=M(v.clientX);s==null||s(b)},onSlideEnd:()=>{k.current=void 0,c==null||c()},onStepKeyDown:v=>{const C=AQ[g?"from-left":"from-right"].includes(v.key);l==null||l({event:v,direction:C?-1:1})}})})}),xDe=m.forwardRef((e,t)=>{const{min:n,max:o,inverted:r,onSlideStart:a,onSlideMove:i,onSlideEnd:s,onStepKeyDown:c,...l}=e,h=m.useRef(null),u=kt(t,h),f=m.useRef(void 0),y=!r;function k(x){const w=f.current||h.current.getBoundingClientRect(),g=[0,w.height],v=pO(g,y?[o,n]:[n,o]);return f.current=w,v(x-w.top)}return p.jsx(PQ,{scope:e.__scopeSlider,startEdge:y?"bottom":"top",endEdge:y?"top":"bottom",size:"height",direction:y?1:-1,children:p.jsx(zQ,{"data-orientation":"vertical",...l,ref:u,style:{...l.style,"--radix-slider-thumb-transform":"translateY(50%)"},onSlideStart:x=>{const w=k(x.clientY);a==null||a(w)},onSlideMove:x=>{const w=k(x.clientY);i==null||i(w)},onSlideEnd:()=>{f.current=void 0,s==null||s()},onStepKeyDown:x=>{const g=AQ[y?"from-bottom":"from-top"].includes(x.key);c==null||c({event:x,direction:g?-1:1})}})})}),zQ=m.forwardRef((e,t)=>{const{__scopeSlider:n,onSlideStart:o,onSlideMove:r,onSlideEnd:a,onHomeKeyDown:i,onEndKeyDown:s,onStepKeyDown:c,...l}=e,h=Az(m0,n);return p.jsx(Be.span,{...l,ref:t,onKeyDown:Le(e.onKeyDown,u=>{u.key==="Home"?(i(u),u.preventDefault()):u.key==="End"?(s(u),u.preventDefault()):IQ.concat(NQ).includes(u.key)&&(c(u),u.preventDefault())}),onPointerDown:Le(e.onPointerDown,u=>{const f=u.target;f.setPointerCapture(u.pointerId),u.preventDefault(),h.thumbs.has(f)?f.focus():o(u)}),onPointerMove:Le(e.onPointerMove,u=>{u.target.hasPointerCapture(u.pointerId)&&r(u)}),onPointerUp:Le(e.onPointerUp,u=>{const f=u.target;f.hasPointerCapture(u.pointerId)&&(f.releasePointerCapture(u.pointerId),a(u))})})}),RQ="SliderTrack",TQ=m.forwardRef((e,t)=>{const{__scopeSlider:n,...o}=e,r=Az(RQ,n);return p.jsx(Be.span,{"data-disabled":r.disabled?"":void 0,"data-orientation":r.orientation,...o,ref:t})});TQ.displayName=RQ;var fH="SliderRange",DQ=m.forwardRef((e,t)=>{const{__scopeSlider:n,...o}=e,r=Az(fH,n),a=jQ(fH,n),i=m.useRef(null),s=kt(t,i),c=r.values.length,l=r.values.map(f=>OQ(f,r.min,r.max)),h=c>1?Math.min(...l):0,u=100-Math.max(...l);return p.jsx(Be.span,{"data-orientation":r.orientation,"data-disabled":r.disabled?"":void 0,...o,ref:s,style:{...e.style,[a.startEdge]:h+"%",[a.endEdge]:u+"%"}})});DQ.displayName=fH;var pH="SliderThumb",HQ=m.forwardRef((e,t)=>{const n=mDe(e.__scopeSlider),[o,r]=m.useState(null),a=kt(t,s=>r(s)),i=m.useMemo(()=>o?n().findIndex(s=>s.ref.current===o):-1,[n,o]);return p.jsx(wDe,{...e,ref:a,index:i})}),wDe=m.forwardRef((e,t)=>{const{__scopeSlider:n,index:o,name:r,...a}=e,i=Az(pH,n),s=jQ(pH,n),[c,l]=m.useState(null),h=kt(t,M=>l(M)),u=c?i.form||!!c.closest("form"):!0,f=CQ(c),y=i.values[o],k=y===void 0?0:OQ(y,i.min,i.max),x=_De(o,i.values.length),w=f==null?void 0:f[s.size],g=w?SDe(w,k,s.direction):0;return m.useEffect(()=>{if(c)return i.thumbs.add(c),()=>{i.thumbs.delete(c)}},[c,i.thumbs]),p.jsxs("span",{style:{transform:"var(--radix-slider-thumb-transform)",position:"absolute",[s.startEdge]:`calc(${k}% + ${g}px)`},children:[p.jsx(hH.ItemSlot,{scope:e.__scopeSlider,children:p.jsx(Be.span,{role:"slider","aria-label":e["aria-label"]||x,"aria-valuemin":i.min,"aria-valuenow":y,"aria-valuemax":i.max,"aria-orientation":i.orientation,"data-orientation":i.orientation,"data-disabled":i.disabled?"":void 0,tabIndex:i.disabled?void 0:0,...a,ref:h,style:y===void 0?{display:"none"}:e.style,onFocus:Le(e.onFocus,()=>{i.valueIndexToChangeRef.current=o})})}),u&&p.jsx(qQ,{name:r??(i.name?i.name+(i.values.length>1?"[]":""):void 0),form:i.form,value:y},o)]})});HQ.displayName=pH;var MDe="RadioBubbleInput",qQ=m.forwardRef(({__scopeSlider:e,value:t,...n},o)=>{const r=m.useRef(null),a=kt(r,o),i=lDe(t);return m.useEffect(()=>{const s=r.current;if(!s)return;const c=window.HTMLInputElement.prototype,h=Object.getOwnPropertyDescriptor(c,"value").set;if(i!==t&&h){const u=new Event("input",{bubbles:!0});h.call(s,t),s.dispatchEvent(u)}},[i,t]),p.jsx(Be.input,{style:{display:"none"},...n,ref:a,defaultValue:t})});qQ.displayName=MDe;function bDe(e=[],t,n){const o=[...e];return o[n]=t,o.sort((r,a)=>r-a)}function OQ(e,t,n){const a=100/(n-t)*(e-t);return _Q(a,[0,100])}function _De(e,t){return t>2?`Value ${e+1} of ${t}`:t===2?["Minimum","Maximum"][e]:void 0}function CDe(e,t){if(e.length===1)return 0;const n=e.map(r=>Math.abs(r-t)),o=Math.min(...n);return n.indexOf(o)}function SDe(e,t,n){const o=e/2,a=pO([0,50],[0,o]);return(o-a(t)*n)*n}function LDe(e){return e.slice(0,-1).map((t,n)=>e[n+1]-t)}function IDe(e,t){if(t>0){const n=LDe(e);return Math.min(...n)>=t}return!0}function pO(e,t){return n=>{if(e[0]===e[1]||t[0]===t[1])return t[0];const o=(t[1]-t[0])/(e[1]-e[0]);return t[0]+o*(n-e[0])}}function NDe(e){return(String(e).split(".")[1]||"").length}function ADe(e,t){const n=Math.pow(10,t);return Math.round(e*n)/n}var FQ=$Q,EDe=TQ,$De=DQ,PDe=HQ;const yO=m.forwardRef(({className:e,...t},n)=>p.jsxs(FQ,{ref:n,className:ae("sf:relative sf:flex sf:w-full sf:touch-none sf:select-none sf:items-center",e),...t,children:[p.jsx(EDe,{className:"sf:relative sf:h-1.5 sf:w-full sf:grow sf:overflow-hidden sf:rounded-full sf:bg-secondary",children:p.jsx($De,{className:"sf:absolute sf:h-full sf:bg-primary"})}),p.jsx(PDe,{className:"sf:block sf:h-4 sf:w-4 sf:rounded-full sf:border sf:border-primary/60 sf:bg-background sf:shadow-sm sf:transition-colors sf:hover:border-primary sf:focus-visible:outline-hidden sf:focus-visible:ring-2 sf:focus-visible:ring-ring sf:disabled:pointer-events-none sf:disabled:opacity-50"})]}));yO.displayName=FQ.displayName;const jDe={1:"sf:text-2xl sf:font-semibold sf:tracking-tight",2:"sf:text-xl sf:font-semibold sf:tracking-tight",3:"sf:text-lg sf:font-semibold",4:"sf:text-base sf:font-semibold"};function zDe({text:e,level:t=2}){const n=`h${t}`;return p.jsx(n,{className:ae(jDe[t]),children:e})}const VQ=m.createContext({custom:{}});function RDe({value:e,children:t}){return p.jsx(VQ.Provider,{value:e,children:t})}function TDe(){return m.useContext(VQ)}function n0({name:e,as:t,size:n=16,fallback:o=vIe,...r}){const a=TDe(),i=t??(e?a.custom[e]:void 0)??(e?Hu[e]:void 0)??Hu[o];return i?p.jsx(i,{size:n,...r}):null}function DDe({name:e,size:t=16}){return p.jsx(n0,{name:e,size:t,"aria-hidden":!0})}function HDe(e){return e==null?"":typeof e=="string"||typeof e=="number"?e:typeof e=="object"?JSON.stringify(e):String(e)}function qDe({label:e,value:t}){return p.jsxs("div",{className:"sf:flex sf:flex-col sf:gap-1",children:[p.jsx("span",{className:"sf:text-muted-foreground sf:text-xs sf:uppercase sf:tracking-wide",children:e}),p.jsx("span",{className:"sf:font-semibold sf:text-2xl sf:tabular-nums",children:HDe(t)})]})}function ODe(e){return e==null?"":typeof e=="string"||typeof e=="number"?String(e):JSON.stringify(e)}function FDe({columns:e=[],rows:t=[]}){return p.jsx("div",{className:"sf:w-full sf:overflow-x-auto",children:p.jsxs("table",{className:"sf:w-full sf:text-left sf:text-sm",children:[p.jsx("thead",{className:"sf:border-b sf:bg-muted/50",children:p.jsx("tr",{children:e.map(n=>p.jsx("th",{scope:"col",className:"sf:px-3 sf:py-2 sf:font-medium sf:text-muted-foreground",children:n.label},n.key))})}),p.jsx("tbody",{children:t.map((n,o)=>p.jsx("tr",{className:"sf:border-b last:sf:border-0",children:e.map(r=>p.jsx("td",{className:"sf:px-3 sf:py-2",children:ODe(n[r.key])},r.key))},o))})]})})}function VDe({text:e,muted:t}){return p.jsx("p",{className:ae("sf:text-sm",t&&"sf:text-muted-foreground"),children:e})}function BDe({title:e,children:t}){return p.jsxs("div",{className:"sf:bg-card sf:p-4 sf:text-card-foreground sf:shadow-sm",children:[e!==void 0?p.jsx("div",{className:"sf:mb-3 sf:font-semibold sf:text-base sf:leading-tight",children:e}):null,p.jsx("div",{className:"sf:flex sf:flex-col sf:gap-3",children:t})]})}function UDe({orientation:e="horizontal"}){return p.jsx("div",{"aria-orientation":e,className:ae("sf:bg-border",e==="horizontal"?"sf:h-px sf:w-full":"sf:h-full sf:w-px")})}function WDe({value:e,items:t,onChange:n,children:o}){const r=t??[];return p.jsxs("div",{className:"sf:flex sf:flex-col sf:gap-2",children:[p.jsx("div",{className:"sf:inline-flex sf:h-9 sf:items-center sf:justify-start sf:rounded-md sf:bg-muted sf:p-1 sf:text-muted-foreground",children:r.map(a=>p.jsx("button",{type:"button","data-state":e===a.id?"active":"inactive",onClick:()=>n==null?void 0:n({value:a.id}),className:"sf:inline-flex sf:items-center sf:justify-center sf:whitespace-nowrap sf:rounded-sm sf:px-3 sf:py-1 sf:text-xs sf:font-medium sf:transition-all sf:data-[state=active]:bg-background sf:data-[state=active]:text-foreground sf:data-[state=active]:shadow-sm",children:a.label},a.id))}),o]})}function GDe({items:e}){const t=e??[];return p.jsx("div",{className:"sf:flex sf:flex-col sf:divide-y sf:rounded-md sf:border",children:t.map(n=>p.jsxs("details",{className:"sf:group sf:px-3 sf:py-2",children:[p.jsx("summary",{className:"sf:cursor-pointer sf:py-1 sf:font-medium sf:text-sm",children:n.title}),p.jsx("div",{className:"sf:py-2 sf:text-muted-foreground sf:text-sm",children:n.content})]},n.id))})}const MU={default:"sf:bg-primary sf:text-primary-foreground",secondary:"sf:bg-secondary sf:text-secondary-foreground",destructive:"sf:bg-destructive sf:text-destructive-foreground",outline:"sf:border sf:border-border sf:text-foreground"};function ZDe({label:e,variant:t="default"}){return p.jsx("span",{className:ae("sf:inline-flex sf:items-center sf:rounded-full sf:px-2.5 sf:py-0.5 sf:font-medium sf:text-xs",MU[t]??MU.default),children:e})}function KDe({src:e,alt:t,fallback:n}){return e?p.jsx("img",{src:e,alt:t??"",className:"sf:inline-block sf:h-9 sf:w-9 sf:rounded-full sf:object-cover"}):p.jsx("span",{className:"sf:inline-flex sf:h-9 sf:w-9 sf:items-center sf:justify-center sf:rounded-full sf:bg-muted sf:font-medium sf:text-muted-foreground sf:text-sm",children:n??"?"})}function XDe({value:e=0}){const t=Math.max(0,Math.min(100,e));return p.jsx("div",{"aria-valuenow":t,"aria-valuemin":0,"aria-valuemax":100,className:"sf:relative sf:h-2 sf:w-full sf:overflow-hidden sf:rounded-full sf:bg-secondary",children:p.jsx("div",{className:"sf:h-full sf:bg-primary sf:transition-all",style:{width:`${t}%`}})})}function YDe({width:e,height:t}){return p.jsx("div",{className:"sf:animate-pulse sf:rounded-md sf:bg-muted",style:{width:e??"100%",height:t??16}})}function QDe({text:e}){return p.jsx("span",{className:"sf:font-medium sf:text-sm sf:leading-none",children:e})}function JDe({label:e,variant:t="default",onClick:n,disabled:o}){return p.jsx(qt,{variant:t,disabled:o,onClick:()=>n==null?void 0:n(),children:e})}const mO="sf:flex sf:h-9 sf:w-full sf:rounded-md sf:border sf:border-input sf:bg-background sf:px-3 sf:py-1 sf:text-sm sf:shadow-sm sf:transition-colors sf:placeholder:text-muted-foreground sf:focus-visible:outline-hidden sf:focus-visible:ring-1 sf:focus-visible:ring-ring sf:disabled:cursor-not-allowed sf:disabled:opacity-50";function eHe({value:e,placeholder:t,onChange:n}){return p.jsx("input",{type:"text",value:e??"",placeholder:t,onChange:o=>n==null?void 0:n({value:o.target.value}),className:mO})}function tHe({checked:e,onChange:t,label:n}){return p.jsxs("label",{className:"sf:inline-flex sf:items-center sf:gap-2 sf:text-sm",children:[p.jsx("input",{type:"checkbox",checked:e??!1,onChange:o=>t==null?void 0:t({checked:o.target.checked}),className:"sf:h-4 sf:w-4 sf:rounded sf:border sf:border-input sf:accent-primary"}),n]})}function nHe({checked:e,onChange:t}){return p.jsx("button",{type:"button",role:"switch","aria-checked":e??!1,onClick:()=>t==null?void 0:t({checked:!(e??!1)}),className:ae("sf:relative sf:inline-flex sf:h-5 sf:w-9 sf:shrink-0 sf:cursor-pointer sf:items-center sf:rounded-full sf:border-2 sf:border-transparent sf:transition-colors",e?"sf:bg-primary":"sf:bg-input"),children:p.jsx("span",{className:ae("sf:pointer-events-none sf:block sf:h-4 sf:w-4 sf:rounded-full sf:bg-background sf:shadow-lg sf:ring-0 sf:transition-transform",e?"sf:translate-x-4":"sf:translate-x-0")})})}function oHe({value:e,items:t,onChange:n}){return p.jsx("select",{value:e??"",onChange:o=>n==null?void 0:n({value:o.target.value}),className:mO,children:(t??[]).map(o=>p.jsx("option",{value:o.value,children:o.label},o.value))})}function rHe({value:e,placeholder:t,rows:n,onChange:o}){return p.jsx("textarea",{value:e??"",placeholder:t,rows:n,onChange:r=>o==null?void 0:o({value:r.target.value}),className:ae(mO,"sf:min-h-16 sf:py-2")})}function aHe({value:e,min:t=0,max:n=100,step:o=1,onChange:r}){return p.jsx(yO,{value:e===void 0?void 0:[e],min:t,max:n,step:o,onValueChange:a=>{const[i]=a;typeof i=="number"&&(r==null||r({value:i}))}})}const iHe=m.lazy(()=>Iz(()=>import("./chart-CpHY42Vq.js"),[]));function sHe(e){return p.jsx(m.Suspense,{fallback:null,children:p.jsx(iHe,{...e})})}const cHe=m.lazy(()=>Iz(()=>import("./markdown-DAvRjvM0.js"),[]));function lHe(e){return p.jsx(m.Suspense,{fallback:null,children:p.jsx(cHe,{...e})})}const dHe=m.lazy(()=>Iz(()=>import("./code-block-CagXzbCC.js"),[]));function uHe(e){return p.jsx(m.Suspense,{fallback:null,children:p.jsx(dHe,{...e})})}const BQ={Card:BDe,Separator:UDe,Tabs:WDe,Accordion:GDe,Badge:ZDe,Avatar:KDe,Progress:XDe,Skeleton:YDe,Label:QDe,Heading:zDe,Text:VDe,Icon:DDe,Chart:sHe,Table:FDe,Metric:qDe,CodeBlock:uHe,Markdown:lHe,Button:JDe,Input:eHe,Checkbox:tHe,Switch:nHe,Select:oHe,Textarea:rHe,Slider:aHe},bU=wQ.filter(e=>BQ[e]===void 0);if(bU.length>0)throw new Error(`componentRegistry is missing impls for: ${bU.join(", ")}. Every catalog entry in COMPONENT_NAMES must have a matching component impl.`);const hHe={components:BQ};function fHe(e,t){return t.kind==="set"?{...e,[t.path]:t.value}:{...e,...t.partial}}function UQ(e){return e===null||typeof e!="object"?!1:"$state"in e||"$action"in e||"$param"in e||"$cond"in e}function DP(e,t,n,o){if(!UQ(e))return e;if(typeof e.$state=="string")return t[e.$state];if(typeof e.$action=="string"){const r=e.$action;return o.has(r)?a=>n(r,a):void 0}if("$cond"in e){const r=DP(e.$cond,t,n,o);return DP(r?e.$then:e.$else,t,n,o)}return e}function pHe(e,t,n,o){if(!e)return{};const r={};for(const[a,i]of Object.entries(e))r[a]=DP(i,t,n,o);return r}function _U({spec:e,nodeId:t,apiBaseUrl:n="/api",flowId:o}){const[r,a]=m.useReducer(fHe,e.state??{}),i=new Set(Object.keys(e.actions??{})),s=m.useCallback(async(c,l)=>{var f;const h=(f=e.actions)==null?void 0:f[c];if(!h)return;if(h.kind==="set"){const y=yHe(h.value,l,r);a({kind:"set",path:h.path,value:y});return}if(!o)return;const u=`${n}/flows/${o}/nodes/${t}/actions/${c}`;try{const y=await fetch(u,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(l??{})});if(!y.ok){const x=await y.text();a({kind:"set",path:`/__errors/${c}`,value:x});return}const k=await y.json();k!==null&&typeof k=="object"&&a({kind:"merge",partial:k})}catch(y){a({kind:"set",path:`/__errors/${c}`,value:y instanceof Error?y.message:String(y)})}},[e.actions,o,n,t,r]);return WQ(e.root,e,r,s,i)}function yHe(e,t,n){return UQ(e)?typeof e.$param=="string"?t!==null&&typeof t=="object"?t[e.$param]:void 0:typeof e.$state=="string"?n[e.$state]:e:e}function WQ(e,t,n,o,r){const a=t.elements[e];if(!a)return null;const i=hHe.components[a.type];if(!i)return null;const s=pHe(a.props,n,o,r),l=(a.children??[]).map(h=>p.jsx(mHe,{children:WQ(h,t,n,o,r)},h));return p.jsx(i,{...s,children:l.length>0?l:void 0})}function mHe({children:e}){return e}function Br(e){const t=m.useRef(e);return m.useEffect(()=>{t.current=e}),m.useMemo(()=>(...n)=>{var o;return(o=t.current)==null?void 0:o.call(t,...n)},[])}function kHe(e,t=globalThis==null?void 0:globalThis.document){const n=Br(e);m.useEffect(()=>{const o=r=>{r.key==="Escape"&&n(r)};return t.addEventListener("keydown",o,{capture:!0}),()=>t.removeEventListener("keydown",o,{capture:!0})},[n,t])}var gHe="DismissableLayer",yH="dismissableLayer.update",vHe="dismissableLayer.pointerDownOutside",xHe="dismissableLayer.focusOutside",CU,GQ=m.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Vh=m.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:o,onPointerDownOutside:r,onFocusOutside:a,onInteractOutside:i,onDismiss:s,...c}=e,l=m.useContext(GQ),[h,u]=m.useState(null),f=(h==null?void 0:h.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,y]=m.useState({}),k=kt(t,S=>u(S)),x=Array.from(l.layers),[w]=[...l.layersWithOutsidePointerEventsDisabled].slice(-1),g=x.indexOf(w),M=h?x.indexOf(h):-1,v=l.layersWithOutsidePointerEventsDisabled.size>0,b=M>=g,C=bHe(S=>{const A=S.target,P=[...l.branches].some(I=>I.contains(A));!b||P||(r==null||r(S),i==null||i(S),S.defaultPrevented||s==null||s())},f),_=_He(S=>{const A=S.target;[...l.branches].some(I=>I.contains(A))||(a==null||a(S),i==null||i(S),S.defaultPrevented||s==null||s())},f);return kHe(S=>{M===l.layers.size-1&&(o==null||o(S),!S.defaultPrevented&&s&&(S.preventDefault(),s()))},f),m.useEffect(()=>{if(h)return n&&(l.layersWithOutsidePointerEventsDisabled.size===0&&(CU=f.body.style.pointerEvents,f.body.style.pointerEvents="none"),l.layersWithOutsidePointerEventsDisabled.add(h)),l.layers.add(h),SU(),()=>{n&&l.layersWithOutsidePointerEventsDisabled.size===1&&(f.body.style.pointerEvents=CU)}},[h,f,n,l]),m.useEffect(()=>()=>{h&&(l.layers.delete(h),l.layersWithOutsidePointerEventsDisabled.delete(h),SU())},[h,l]),m.useEffect(()=>{const S=()=>y({});return document.addEventListener(yH,S),()=>document.removeEventListener(yH,S)},[]),p.jsx(Be.div,{...c,ref:k,style:{pointerEvents:v?b?"auto":"none":void 0,...e.style},onFocusCapture:Le(e.onFocusCapture,_.onFocusCapture),onBlurCapture:Le(e.onBlurCapture,_.onBlurCapture),onPointerDownCapture:Le(e.onPointerDownCapture,C.onPointerDownCapture)})});Vh.displayName=gHe;var wHe="DismissableLayerBranch",MHe=m.forwardRef((e,t)=>{const n=m.useContext(GQ),o=m.useRef(null),r=kt(t,o);return m.useEffect(()=>{const a=o.current;if(a)return n.branches.add(a),()=>{n.branches.delete(a)}},[n.branches]),p.jsx(Be.div,{...e,ref:r})});MHe.displayName=wHe;function bHe(e,t=globalThis==null?void 0:globalThis.document){const n=Br(e),o=m.useRef(!1),r=m.useRef(()=>{});return m.useEffect(()=>{const a=s=>{if(s.target&&!o.current){let c=function(){ZQ(vHe,n,l,{discrete:!0})};const l={originalEvent:s};s.pointerType==="touch"?(t.removeEventListener("click",r.current),r.current=c,t.addEventListener("click",r.current,{once:!0})):c()}else t.removeEventListener("click",r.current);o.current=!1},i=window.setTimeout(()=>{t.addEventListener("pointerdown",a)},0);return()=>{window.clearTimeout(i),t.removeEventListener("pointerdown",a),t.removeEventListener("click",r.current)}},[t,n]),{onPointerDownCapture:()=>o.current=!0}}function _He(e,t=globalThis==null?void 0:globalThis.document){const n=Br(e),o=m.useRef(!1);return m.useEffect(()=>{const r=a=>{a.target&&!o.current&&ZQ(xHe,n,{originalEvent:a},{discrete:!1})};return t.addEventListener("focusin",r),()=>t.removeEventListener("focusin",r)},[t,n]),{onFocusCapture:()=>o.current=!0,onBlurCapture:()=>o.current=!1}}function SU(){const e=new CustomEvent(yH);document.dispatchEvent(e)}function ZQ(e,t,n,{discrete:o}){const r=n.originalEvent.target,a=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&r.addEventListener(e,t,{once:!0}),o?LQ(r,a):r.dispatchEvent(a)}var iT=0;function kO(){m.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??LU()),document.body.insertAdjacentElement("beforeend",e[1]??LU()),iT++,()=>{iT===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),iT--}},[])}function LU(){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 sT="focusScope.autoFocusOnMount",cT="focusScope.autoFocusOnUnmount",IU={bubbles:!1,cancelable:!0},CHe="FocusScope",Ez=m.forwardRef((e,t)=>{const{loop:n=!1,trapped:o=!1,onMountAutoFocus:r,onUnmountAutoFocus:a,...i}=e,[s,c]=m.useState(null),l=Br(r),h=Br(a),u=m.useRef(null),f=kt(t,x=>c(x)),y=m.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;m.useEffect(()=>{if(o){let x=function(v){if(y.paused||!s)return;const b=v.target;s.contains(b)?u.current=b:Ya(u.current,{select:!0})},w=function(v){if(y.paused||!s)return;const b=v.relatedTarget;b!==null&&(s.contains(b)||Ya(u.current,{select:!0}))},g=function(v){if(document.activeElement===document.body)for(const C of v)C.removedNodes.length>0&&Ya(s)};document.addEventListener("focusin",x),document.addEventListener("focusout",w);const M=new MutationObserver(g);return s&&M.observe(s,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",x),document.removeEventListener("focusout",w),M.disconnect()}}},[o,s,y.paused]),m.useEffect(()=>{if(s){AU.add(y);const x=document.activeElement;if(!s.contains(x)){const g=new CustomEvent(sT,IU);s.addEventListener(sT,l),s.dispatchEvent(g),g.defaultPrevented||(SHe(EHe(KQ(s)),{select:!0}),document.activeElement===x&&Ya(s))}return()=>{s.removeEventListener(sT,l),setTimeout(()=>{const g=new CustomEvent(cT,IU);s.addEventListener(cT,h),s.dispatchEvent(g),g.defaultPrevented||Ya(x??document.body,{select:!0}),s.removeEventListener(cT,h),AU.remove(y)},0)}}},[s,l,h,y]);const k=m.useCallback(x=>{if(!n&&!o||y.paused)return;const w=x.key==="Tab"&&!x.altKey&&!x.ctrlKey&&!x.metaKey,g=document.activeElement;if(w&&g){const M=x.currentTarget,[v,b]=LHe(M);v&&b?!x.shiftKey&&g===b?(x.preventDefault(),n&&Ya(v,{select:!0})):x.shiftKey&&g===v&&(x.preventDefault(),n&&Ya(b,{select:!0})):g===M&&x.preventDefault()}},[n,o,y.paused]);return p.jsx(Be.div,{tabIndex:-1,...i,ref:f,onKeyDown:k})});Ez.displayName=CHe;function SHe(e,{select:t=!1}={}){const n=document.activeElement;for(const o of e)if(Ya(o,{select:t}),document.activeElement!==n)return}function LHe(e){const t=KQ(e),n=NU(t,e),o=NU(t.reverse(),e);return[n,o]}function KQ(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:o=>{const r=o.tagName==="INPUT"&&o.type==="hidden";return o.disabled||o.hidden||r?NodeFilter.FILTER_SKIP:o.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function NU(e,t){for(const n of e)if(!IHe(n,{upTo:t}))return n}function IHe(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 NHe(e){return e instanceof HTMLInputElement&&"select"in e}function Ya(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&NHe(e)&&t&&e.select()}}var AU=AHe();function AHe(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=EU(e,t),e.unshift(t)},remove(t){var n;e=EU(e,t),(n=e[0])==null||n.resume()}}}function EU(e,t){const n=[...e],o=n.indexOf(t);return o!==-1&&n.splice(o,1),n}function EHe(e){return e.filter(t=>t.tagName!=="A")}var $He=eq[" useId ".trim().toString()]||(()=>{}),PHe=0;function An(e){const[t,n]=m.useState($He());return _i(()=>{n(o=>o??String(PHe++))},[e]),e||(t?`radix-${t}`:"")}const jHe=["top","right","bottom","left"],Ci=Math.min,ao=Math.max,Rj=Math.round,Jf=Math.floor,qr=e=>({x:e,y:e}),zHe={left:"right",right:"left",bottom:"top",top:"bottom"};function mH(e,t,n){return ao(e,Ci(t,n))}function Ca(e,t){return typeof e=="function"?e(t):e}function Sa(e){return e.split("-")[0]}function k0(e){return e.split("-")[1]}function gO(e){return e==="x"?"y":"x"}function vO(e){return e==="y"?"height":"width"}function zr(e){const t=e[0];return t==="t"||t==="b"?"y":"x"}function xO(e){return gO(zr(e))}function RHe(e,t,n){n===void 0&&(n=!1);const o=k0(e),r=xO(e),a=vO(r);let i=r==="x"?o===(n?"end":"start")?"right":"left":o==="start"?"bottom":"top";return t.reference[a]>t.floating[a]&&(i=Tj(i)),[i,Tj(i)]}function THe(e){const t=Tj(e);return[kH(e),t,kH(t)]}function kH(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const $U=["left","right"],PU=["right","left"],DHe=["top","bottom"],HHe=["bottom","top"];function qHe(e,t,n){switch(e){case"top":case"bottom":return n?t?PU:$U:t?$U:PU;case"left":case"right":return t?DHe:HHe;default:return[]}}function OHe(e,t,n,o){const r=k0(e);let a=qHe(Sa(e),n==="start",o);return r&&(a=a.map(i=>i+"-"+r),t&&(a=a.concat(a.map(kH)))),a}function Tj(e){const t=Sa(e);return zHe[t]+e.slice(t.length)}function FHe(e){return{top:0,right:0,bottom:0,left:0,...e}}function XQ(e){return typeof e!="number"?FHe(e):{top:e,right:e,bottom:e,left:e}}function Dj(e){const{x:t,y:n,width:o,height:r}=e;return{width:o,height:r,top:n,left:t,right:t+o,bottom:n+r,x:t,y:n}}function jU(e,t,n){let{reference:o,floating:r}=e;const a=zr(t),i=xO(t),s=vO(i),c=Sa(t),l=a==="y",h=o.x+o.width/2-r.width/2,u=o.y+o.height/2-r.height/2,f=o[s]/2-r[s]/2;let y;switch(c){case"top":y={x:h,y:o.y-r.height};break;case"bottom":y={x:h,y:o.y+o.height};break;case"right":y={x:o.x+o.width,y:u};break;case"left":y={x:o.x-r.width,y:u};break;default:y={x:o.x,y:o.y}}switch(k0(t)){case"start":y[i]-=f*(n&&l?-1:1);break;case"end":y[i]+=f*(n&&l?-1:1);break}return y}async function VHe(e,t){var n;t===void 0&&(t={});const{x:o,y:r,platform:a,rects:i,elements:s,strategy:c}=e,{boundary:l="clippingAncestors",rootBoundary:h="viewport",elementContext:u="floating",altBoundary:f=!1,padding:y=0}=Ca(t,e),k=XQ(y),w=s[f?u==="floating"?"reference":"floating":u],g=Dj(await a.getClippingRect({element:(n=await(a.isElement==null?void 0:a.isElement(w)))==null||n?w:w.contextElement||await(a.getDocumentElement==null?void 0:a.getDocumentElement(s.floating)),boundary:l,rootBoundary:h,strategy:c})),M=u==="floating"?{x:o,y:r,width:i.floating.width,height:i.floating.height}:i.reference,v=await(a.getOffsetParent==null?void 0:a.getOffsetParent(s.floating)),b=await(a.isElement==null?void 0:a.isElement(v))?await(a.getScale==null?void 0:a.getScale(v))||{x:1,y:1}:{x:1,y:1},C=Dj(a.convertOffsetParentRelativeRectToViewportRelativeRect?await a.convertOffsetParentRelativeRectToViewportRelativeRect({elements:s,rect:M,offsetParent:v,strategy:c}):M);return{top:(g.top-C.top+k.top)/b.y,bottom:(C.bottom-g.bottom+k.bottom)/b.y,left:(g.left-C.left+k.left)/b.x,right:(C.right-g.right+k.right)/b.x}}const BHe=50,UHe=async(e,t,n)=>{const{placement:o="bottom",strategy:r="absolute",middleware:a=[],platform:i}=n,s=i.detectOverflow?i:{...i,detectOverflow:VHe},c=await(i.isRTL==null?void 0:i.isRTL(t));let l=await i.getElementRects({reference:e,floating:t,strategy:r}),{x:h,y:u}=jU(l,o,c),f=o,y=0;const k={};for(let x=0;x<a.length;x++){const w=a[x];if(!w)continue;const{name:g,fn:M}=w,{x:v,y:b,data:C,reset:_}=await M({x:h,y:u,initialPlacement:o,placement:f,strategy:r,middlewareData:k,rects:l,platform:s,elements:{reference:e,floating:t}});h=v??h,u=b??u,k[g]={...k[g],...C},_&&y<BHe&&(y++,typeof _=="object"&&(_.placement&&(f=_.placement),_.rects&&(l=_.rects===!0?await i.getElementRects({reference:e,floating:t,strategy:r}):_.rects),{x:h,y:u}=jU(l,f,c)),x=-1)}return{x:h,y:u,placement:f,strategy:r,middlewareData:k}},WHe=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:o,placement:r,rects:a,platform:i,elements:s,middlewareData:c}=t,{element:l,padding:h=0}=Ca(e,t)||{};if(l==null)return{};const u=XQ(h),f={x:n,y:o},y=xO(r),k=vO(y),x=await i.getDimensions(l),w=y==="y",g=w?"top":"left",M=w?"bottom":"right",v=w?"clientHeight":"clientWidth",b=a.reference[k]+a.reference[y]-f[y]-a.floating[k],C=f[y]-a.reference[y],_=await(i.getOffsetParent==null?void 0:i.getOffsetParent(l));let S=_?_[v]:0;(!S||!await(i.isElement==null?void 0:i.isElement(_)))&&(S=s.floating[v]||a.floating[k]);const A=b/2-C/2,P=S/2-x[k]/2-1,I=Ci(u[g],P),$=Ci(u[M],P),N=I,X=S-x[k]-$,j=S/2-x[k]/2+A,O=mH(N,j,X),H=!c.arrow&&k0(r)!=null&&j!==O&&a.reference[k]/2-(j<N?I:$)-x[k]/2<0,B=H?j<N?j-N:j-X:0;return{[y]:f[y]+B,data:{[y]:O,centerOffset:j-O-B,...H&&{alignmentOffset:B}},reset:H}}}),GHe=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,o;const{placement:r,middlewareData:a,rects:i,initialPlacement:s,platform:c,elements:l}=t,{mainAxis:h=!0,crossAxis:u=!0,fallbackPlacements:f,fallbackStrategy:y="bestFit",fallbackAxisSideDirection:k="none",flipAlignment:x=!0,...w}=Ca(e,t);if((n=a.arrow)!=null&&n.alignmentOffset)return{};const g=Sa(r),M=zr(s),v=Sa(s)===s,b=await(c.isRTL==null?void 0:c.isRTL(l.floating)),C=f||(v||!x?[Tj(s)]:THe(s)),_=k!=="none";!f&&_&&C.push(...OHe(s,x,k,b));const S=[s,...C],A=await c.detectOverflow(t,w),P=[];let I=((o=a.flip)==null?void 0:o.overflows)||[];if(h&&P.push(A[g]),u){const j=RHe(r,i,b);P.push(A[j[0]],A[j[1]])}if(I=[...I,{placement:r,overflows:P}],!P.every(j=>j<=0)){var $,N;const j=((($=a.flip)==null?void 0:$.index)||0)+1,O=S[j];if(O&&(!(u==="alignment"?M!==zr(O):!1)||I.every(z=>zr(z.placement)===M?z.overflows[0]>0:!0)))return{data:{index:j,overflows:I},reset:{placement:O}};let H=(N=I.filter(B=>B.overflows[0]<=0).sort((B,z)=>B.overflows[1]-z.overflows[1])[0])==null?void 0:N.placement;if(!H)switch(y){case"bestFit":{var X;const B=(X=I.filter(z=>{if(_){const R=zr(z.placement);return R===M||R==="y"}return!0}).map(z=>[z.placement,z.overflows.filter(R=>R>0).reduce((R,L)=>R+L,0)]).sort((z,R)=>z[1]-R[1])[0])==null?void 0:X[0];B&&(H=B);break}case"initialPlacement":H=s;break}if(r!==H)return{reset:{placement:H}}}return{}}}};function zU(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function RU(e){return jHe.some(t=>e[t]>=0)}const ZHe=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n,platform:o}=t,{strategy:r="referenceHidden",...a}=Ca(e,t);switch(r){case"referenceHidden":{const i=await o.detectOverflow(t,{...a,elementContext:"reference"}),s=zU(i,n.reference);return{data:{referenceHiddenOffsets:s,referenceHidden:RU(s)}}}case"escaped":{const i=await o.detectOverflow(t,{...a,altBoundary:!0}),s=zU(i,n.floating);return{data:{escapedOffsets:s,escaped:RU(s)}}}default:return{}}}}},YQ=new Set(["left","top"]);async function KHe(e,t){const{placement:n,platform:o,elements:r}=e,a=await(o.isRTL==null?void 0:o.isRTL(r.floating)),i=Sa(n),s=k0(n),c=zr(n)==="y",l=YQ.has(i)?-1:1,h=a&&c?-1:1,u=Ca(t,e);let{mainAxis:f,crossAxis:y,alignmentAxis:k}=typeof u=="number"?{mainAxis:u,crossAxis:0,alignmentAxis:null}:{mainAxis:u.mainAxis||0,crossAxis:u.crossAxis||0,alignmentAxis:u.alignmentAxis};return s&&typeof k=="number"&&(y=s==="end"?k*-1:k),c?{x:y*h,y:f*l}:{x:f*l,y:y*h}}const XHe=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,o;const{x:r,y:a,placement:i,middlewareData:s}=t,c=await KHe(t,e);return i===((n=s.offset)==null?void 0:n.placement)&&(o=s.arrow)!=null&&o.alignmentOffset?{}:{x:r+c.x,y:a+c.y,data:{...c,placement:i}}}}},YHe=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:o,placement:r,platform:a}=t,{mainAxis:i=!0,crossAxis:s=!1,limiter:c={fn:g=>{let{x:M,y:v}=g;return{x:M,y:v}}},...l}=Ca(e,t),h={x:n,y:o},u=await a.detectOverflow(t,l),f=zr(Sa(r)),y=gO(f);let k=h[y],x=h[f];if(i){const g=y==="y"?"top":"left",M=y==="y"?"bottom":"right",v=k+u[g],b=k-u[M];k=mH(v,k,b)}if(s){const g=f==="y"?"top":"left",M=f==="y"?"bottom":"right",v=x+u[g],b=x-u[M];x=mH(v,x,b)}const w=c.fn({...t,[y]:k,[f]:x});return{...w,data:{x:w.x-n,y:w.y-o,enabled:{[y]:i,[f]:s}}}}}},QHe=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:o,placement:r,rects:a,middlewareData:i}=t,{offset:s=0,mainAxis:c=!0,crossAxis:l=!0}=Ca(e,t),h={x:n,y:o},u=zr(r),f=gO(u);let y=h[f],k=h[u];const x=Ca(s,t),w=typeof x=="number"?{mainAxis:x,crossAxis:0}:{mainAxis:0,crossAxis:0,...x};if(c){const v=f==="y"?"height":"width",b=a.reference[f]-a.floating[v]+w.mainAxis,C=a.reference[f]+a.reference[v]-w.mainAxis;y<b?y=b:y>C&&(y=C)}if(l){var g,M;const v=f==="y"?"width":"height",b=YQ.has(Sa(r)),C=a.reference[u]-a.floating[v]+(b&&((g=i.offset)==null?void 0:g[u])||0)+(b?0:w.crossAxis),_=a.reference[u]+a.reference[v]+(b?0:((M=i.offset)==null?void 0:M[u])||0)-(b?w.crossAxis:0);k<C?k=C:k>_&&(k=_)}return{[f]:y,[u]:k}}}},JHe=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var n,o;const{placement:r,rects:a,platform:i,elements:s}=t,{apply:c=()=>{},...l}=Ca(e,t),h=await i.detectOverflow(t,l),u=Sa(r),f=k0(r),y=zr(r)==="y",{width:k,height:x}=a.floating;let w,g;u==="top"||u==="bottom"?(w=u,g=f===(await(i.isRTL==null?void 0:i.isRTL(s.floating))?"start":"end")?"left":"right"):(g=u,w=f==="end"?"top":"bottom");const M=x-h.top-h.bottom,v=k-h.left-h.right,b=Ci(x-h[w],M),C=Ci(k-h[g],v),_=!t.middlewareData.shift;let S=b,A=C;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(A=v),(o=t.middlewareData.shift)!=null&&o.enabled.y&&(S=M),_&&!f){const I=ao(h.left,0),$=ao(h.right,0),N=ao(h.top,0),X=ao(h.bottom,0);y?A=k-2*(I!==0||$!==0?I+$:ao(h.left,h.right)):S=x-2*(N!==0||X!==0?N+X:ao(h.top,h.bottom))}await c({...t,availableWidth:A,availableHeight:S});const P=await i.getDimensions(s.floating);return k!==P.width||x!==P.height?{reset:{rects:!0}}:{}}}};function $z(){return typeof window<"u"}function g0(e){return QQ(e)?(e.nodeName||"").toLowerCase():"#document"}function uo(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Wr(e){var t;return(t=(QQ(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function QQ(e){return $z()?e instanceof Node||e instanceof uo(e).Node:!1}function Jo(e){return $z()?e instanceof Element||e instanceof uo(e).Element:!1}function Na(e){return $z()?e instanceof HTMLElement||e instanceof uo(e).HTMLElement:!1}function TU(e){return!$z()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof uo(e).ShadowRoot}function Bh(e){const{overflow:t,overflowX:n,overflowY:o,display:r}=er(e);return/auto|scroll|overlay|hidden|clip/.test(t+o+n)&&r!=="inline"&&r!=="contents"}function eqe(e){return/^(table|td|th)$/.test(g0(e))}function Pz(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}const tqe=/transform|translate|scale|rotate|perspective|filter/,nqe=/paint|layout|strict|content/,Oi=e=>!!e&&e!=="none";let lT;function wO(e){const t=Jo(e)?er(e):e;return Oi(t.transform)||Oi(t.translate)||Oi(t.scale)||Oi(t.rotate)||Oi(t.perspective)||!MO()&&(Oi(t.backdropFilter)||Oi(t.filter))||tqe.test(t.willChange||"")||nqe.test(t.contain||"")}function oqe(e){let t=Si(e);for(;Na(t)&&!o0(t);){if(wO(t))return t;if(Pz(t))return null;t=Si(t)}return null}function MO(){return lT==null&&(lT=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),lT}function o0(e){return/^(html|body|#document)$/.test(g0(e))}function er(e){return uo(e).getComputedStyle(e)}function jz(e){return Jo(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Si(e){if(g0(e)==="html")return e;const t=e.assignedSlot||e.parentNode||TU(e)&&e.host||Wr(e);return TU(t)?t.host:t}function JQ(e){const t=Si(e);return o0(t)?e.ownerDocument?e.ownerDocument.body:e.body:Na(t)&&Bh(t)?t:JQ(t)}function _h(e,t,n){var o;t===void 0&&(t=[]),n===void 0&&(n=!0);const r=JQ(e),a=r===((o=e.ownerDocument)==null?void 0:o.body),i=uo(r);if(a){const s=gH(i);return t.concat(i,i.visualViewport||[],Bh(r)?r:[],s&&n?_h(s):[])}else return t.concat(r,_h(r,[],n))}function gH(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function eJ(e){const t=er(e);let n=parseFloat(t.width)||0,o=parseFloat(t.height)||0;const r=Na(e),a=r?e.offsetWidth:n,i=r?e.offsetHeight:o,s=Rj(n)!==a||Rj(o)!==i;return s&&(n=a,o=i),{width:n,height:o,$:s}}function bO(e){return Jo(e)?e:e.contextElement}function Nu(e){const t=bO(e);if(!Na(t))return qr(1);const n=t.getBoundingClientRect(),{width:o,height:r,$:a}=eJ(t);let i=(a?Rj(n.width):n.width)/o,s=(a?Rj(n.height):n.height)/r;return(!i||!Number.isFinite(i))&&(i=1),(!s||!Number.isFinite(s))&&(s=1),{x:i,y:s}}const rqe=qr(0);function tJ(e){const t=uo(e);return!MO()||!t.visualViewport?rqe:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function aqe(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==uo(e)?!1:t}function gd(e,t,n,o){t===void 0&&(t=!1),n===void 0&&(n=!1);const r=e.getBoundingClientRect(),a=bO(e);let i=qr(1);t&&(o?Jo(o)&&(i=Nu(o)):i=Nu(e));const s=aqe(a,n,o)?tJ(a):qr(0);let c=(r.left+s.x)/i.x,l=(r.top+s.y)/i.y,h=r.width/i.x,u=r.height/i.y;if(a){const f=uo(a),y=o&&Jo(o)?uo(o):o;let k=f,x=gH(k);for(;x&&o&&y!==k;){const w=Nu(x),g=x.getBoundingClientRect(),M=er(x),v=g.left+(x.clientLeft+parseFloat(M.paddingLeft))*w.x,b=g.top+(x.clientTop+parseFloat(M.paddingTop))*w.y;c*=w.x,l*=w.y,h*=w.x,u*=w.y,c+=v,l+=b,k=uo(x),x=gH(k)}}return Dj({width:h,height:u,x:c,y:l})}function zz(e,t){const n=jz(e).scrollLeft;return t?t.left+n:gd(Wr(e)).left+n}function nJ(e,t){const n=e.getBoundingClientRect(),o=n.left+t.scrollLeft-zz(e,n),r=n.top+t.scrollTop;return{x:o,y:r}}function iqe(e){let{elements:t,rect:n,offsetParent:o,strategy:r}=e;const a=r==="fixed",i=Wr(o),s=t?Pz(t.floating):!1;if(o===i||s&&a)return n;let c={scrollLeft:0,scrollTop:0},l=qr(1);const h=qr(0),u=Na(o);if((u||!u&&!a)&&((g0(o)!=="body"||Bh(i))&&(c=jz(o)),u)){const y=gd(o);l=Nu(o),h.x=y.x+o.clientLeft,h.y=y.y+o.clientTop}const f=i&&!u&&!a?nJ(i,c):qr(0);return{width:n.width*l.x,height:n.height*l.y,x:n.x*l.x-c.scrollLeft*l.x+h.x+f.x,y:n.y*l.y-c.scrollTop*l.y+h.y+f.y}}function sqe(e){return Array.from(e.getClientRects())}function cqe(e){const t=Wr(e),n=jz(e),o=e.ownerDocument.body,r=ao(t.scrollWidth,t.clientWidth,o.scrollWidth,o.clientWidth),a=ao(t.scrollHeight,t.clientHeight,o.scrollHeight,o.clientHeight);let i=-n.scrollLeft+zz(e);const s=-n.scrollTop;return er(o).direction==="rtl"&&(i+=ao(t.clientWidth,o.clientWidth)-r),{width:r,height:a,x:i,y:s}}const DU=25;function lqe(e,t){const n=uo(e),o=Wr(e),r=n.visualViewport;let a=o.clientWidth,i=o.clientHeight,s=0,c=0;if(r){a=r.width,i=r.height;const h=MO();(!h||h&&t==="fixed")&&(s=r.offsetLeft,c=r.offsetTop)}const l=zz(o);if(l<=0){const h=o.ownerDocument,u=h.body,f=getComputedStyle(u),y=h.compatMode==="CSS1Compat"&&parseFloat(f.marginLeft)+parseFloat(f.marginRight)||0,k=Math.abs(o.clientWidth-u.clientWidth-y);k<=DU&&(a-=k)}else l<=DU&&(a+=l);return{width:a,height:i,x:s,y:c}}function dqe(e,t){const n=gd(e,!0,t==="fixed"),o=n.top+e.clientTop,r=n.left+e.clientLeft,a=Na(e)?Nu(e):qr(1),i=e.clientWidth*a.x,s=e.clientHeight*a.y,c=r*a.x,l=o*a.y;return{width:i,height:s,x:c,y:l}}function HU(e,t,n){let o;if(t==="viewport")o=lqe(e,n);else if(t==="document")o=cqe(Wr(e));else if(Jo(t))o=dqe(t,n);else{const r=tJ(e);o={x:t.x-r.x,y:t.y-r.y,width:t.width,height:t.height}}return Dj(o)}function oJ(e,t){const n=Si(e);return n===t||!Jo(n)||o0(n)?!1:er(n).position==="fixed"||oJ(n,t)}function uqe(e,t){const n=t.get(e);if(n)return n;let o=_h(e,[],!1).filter(s=>Jo(s)&&g0(s)!=="body"),r=null;const a=er(e).position==="fixed";let i=a?Si(e):e;for(;Jo(i)&&!o0(i);){const s=er(i),c=wO(i);!c&&s.position==="fixed"&&(r=null),(a?!c&&!r:!c&&s.position==="static"&&!!r&&(r.position==="absolute"||r.position==="fixed")||Bh(i)&&!c&&oJ(e,i))?o=o.filter(h=>h!==i):r=s,i=Si(i)}return t.set(e,o),o}function hqe(e){let{element:t,boundary:n,rootBoundary:o,strategy:r}=e;const i=[...n==="clippingAncestors"?Pz(t)?[]:uqe(t,this._c):[].concat(n),o],s=HU(t,i[0],r);let c=s.top,l=s.right,h=s.bottom,u=s.left;for(let f=1;f<i.length;f++){const y=HU(t,i[f],r);c=ao(y.top,c),l=Ci(y.right,l),h=Ci(y.bottom,h),u=ao(y.left,u)}return{width:l-u,height:h-c,x:u,y:c}}function fqe(e){const{width:t,height:n}=eJ(e);return{width:t,height:n}}function pqe(e,t,n){const o=Na(t),r=Wr(t),a=n==="fixed",i=gd(e,!0,a,t);let s={scrollLeft:0,scrollTop:0};const c=qr(0);function l(){c.x=zz(r)}if(o||!o&&!a)if((g0(t)!=="body"||Bh(r))&&(s=jz(t)),o){const y=gd(t,!0,a,t);c.x=y.x+t.clientLeft,c.y=y.y+t.clientTop}else r&&l();a&&!o&&r&&l();const h=r&&!o&&!a?nJ(r,s):qr(0),u=i.left+s.scrollLeft-c.x-h.x,f=i.top+s.scrollTop-c.y-h.y;return{x:u,y:f,width:i.width,height:i.height}}function dT(e){return er(e).position==="static"}function qU(e,t){if(!Na(e)||er(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return Wr(e)===n&&(n=n.ownerDocument.body),n}function rJ(e,t){const n=uo(e);if(Pz(e))return n;if(!Na(e)){let r=Si(e);for(;r&&!o0(r);){if(Jo(r)&&!dT(r))return r;r=Si(r)}return n}let o=qU(e,t);for(;o&&eqe(o)&&dT(o);)o=qU(o,t);return o&&o0(o)&&dT(o)&&!wO(o)?n:o||oqe(e)||n}const yqe=async function(e){const t=this.getOffsetParent||rJ,n=this.getDimensions,o=await n(e.floating);return{reference:pqe(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:o.width,height:o.height}}};function mqe(e){return er(e).direction==="rtl"}const kqe={convertOffsetParentRelativeRectToViewportRelativeRect:iqe,getDocumentElement:Wr,getClippingRect:hqe,getOffsetParent:rJ,getElementRects:yqe,getClientRects:sqe,getDimensions:fqe,getScale:Nu,isElement:Jo,isRTL:mqe};function aJ(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function gqe(e,t){let n=null,o;const r=Wr(e);function a(){var s;clearTimeout(o),(s=n)==null||s.disconnect(),n=null}function i(s,c){s===void 0&&(s=!1),c===void 0&&(c=1),a();const l=e.getBoundingClientRect(),{left:h,top:u,width:f,height:y}=l;if(s||t(),!f||!y)return;const k=Jf(u),x=Jf(r.clientWidth-(h+f)),w=Jf(r.clientHeight-(u+y)),g=Jf(h),v={rootMargin:-k+"px "+-x+"px "+-w+"px "+-g+"px",threshold:ao(0,Ci(1,c))||1};let b=!0;function C(_){const S=_[0].intersectionRatio;if(S!==c){if(!b)return i();S?i(!1,S):o=setTimeout(()=>{i(!1,1e-7)},1e3)}S===1&&!aJ(l,e.getBoundingClientRect())&&i(),b=!1}try{n=new IntersectionObserver(C,{...v,root:r.ownerDocument})}catch{n=new IntersectionObserver(C,v)}n.observe(e)}return i(!0),a}function vqe(e,t,n,o){o===void 0&&(o={});const{ancestorScroll:r=!0,ancestorResize:a=!0,elementResize:i=typeof ResizeObserver=="function",layoutShift:s=typeof IntersectionObserver=="function",animationFrame:c=!1}=o,l=bO(e),h=r||a?[...l?_h(l):[],...t?_h(t):[]]:[];h.forEach(g=>{r&&g.addEventListener("scroll",n,{passive:!0}),a&&g.addEventListener("resize",n)});const u=l&&s?gqe(l,n):null;let f=-1,y=null;i&&(y=new ResizeObserver(g=>{let[M]=g;M&&M.target===l&&y&&t&&(y.unobserve(t),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var v;(v=y)==null||v.observe(t)})),n()}),l&&!c&&y.observe(l),t&&y.observe(t));let k,x=c?gd(e):null;c&&w();function w(){const g=gd(e);x&&!aJ(x,g)&&n(),x=g,k=requestAnimationFrame(w)}return n(),()=>{var g;h.forEach(M=>{r&&M.removeEventListener("scroll",n),a&&M.removeEventListener("resize",n)}),u==null||u(),(g=y)==null||g.disconnect(),y=null,c&&cancelAnimationFrame(k)}}const xqe=XHe,wqe=YHe,Mqe=GHe,bqe=JHe,_qe=ZHe,OU=WHe,Cqe=QHe,Sqe=(e,t,n)=>{const o=new Map,r={platform:kqe,...n},a={...r.platform,_c:o};return UHe(e,t,{...r,platform:a})};var Lqe=typeof document<"u",Iqe=function(){},HP=Lqe?m.useLayoutEffect:Iqe;function Hj(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let n,o,r;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(o=n;o--!==0;)if(!Hj(e[o],t[o]))return!1;return!0}if(r=Object.keys(e),n=r.length,n!==Object.keys(t).length)return!1;for(o=n;o--!==0;)if(!{}.hasOwnProperty.call(t,r[o]))return!1;for(o=n;o--!==0;){const a=r[o];if(!(a==="_owner"&&e.$$typeof)&&!Hj(e[a],t[a]))return!1}return!0}return e!==e&&t!==t}function iJ(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function FU(e,t){const n=iJ(e);return Math.round(t*n)/n}function uT(e){const t=m.useRef(e);return HP(()=>{t.current=e}),t}function Nqe(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:o=[],platform:r,elements:{reference:a,floating:i}={},transform:s=!0,whileElementsMounted:c,open:l}=e,[h,u]=m.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[f,y]=m.useState(o);Hj(f,o)||y(o);const[k,x]=m.useState(null),[w,g]=m.useState(null),M=m.useCallback(z=>{z!==_.current&&(_.current=z,x(z))},[]),v=m.useCallback(z=>{z!==S.current&&(S.current=z,g(z))},[]),b=a||k,C=i||w,_=m.useRef(null),S=m.useRef(null),A=m.useRef(h),P=c!=null,I=uT(c),$=uT(r),N=uT(l),X=m.useCallback(()=>{if(!_.current||!S.current)return;const z={placement:t,strategy:n,middleware:f};$.current&&(z.platform=$.current),Sqe(_.current,S.current,z).then(R=>{const L={...R,isPositioned:N.current!==!1};j.current&&!Hj(A.current,L)&&(A.current=L,h0.flushSync(()=>{u(L)}))})},[f,t,n,$,N]);HP(()=>{l===!1&&A.current.isPositioned&&(A.current.isPositioned=!1,u(z=>({...z,isPositioned:!1})))},[l]);const j=m.useRef(!1);HP(()=>(j.current=!0,()=>{j.current=!1}),[]),HP(()=>{if(b&&(_.current=b),C&&(S.current=C),b&&C){if(I.current)return I.current(b,C,X);X()}},[b,C,X,I,P]);const O=m.useMemo(()=>({reference:_,floating:S,setReference:M,setFloating:v}),[M,v]),H=m.useMemo(()=>({reference:b,floating:C}),[b,C]),B=m.useMemo(()=>{const z={position:n,left:0,top:0};if(!H.floating)return z;const R=FU(H.floating,h.x),L=FU(H.floating,h.y);return s?{...z,transform:"translate("+R+"px, "+L+"px)",...iJ(H.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:R,top:L}},[n,s,H.floating,h.x,h.y]);return m.useMemo(()=>({...h,update:X,refs:O,elements:H,floatingStyles:B}),[h,X,O,H,B])}const Aqe=e=>{function t(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:e,fn(n){const{element:o,padding:r}=typeof e=="function"?e(n):e;return o&&t(o)?o.current!=null?OU({element:o.current,padding:r}).fn(n):{}:o?OU({element:o,padding:r}).fn(n):{}}}},Eqe=(e,t)=>{const n=xqe(e);return{name:n.name,fn:n.fn,options:[e,t]}},$qe=(e,t)=>{const n=wqe(e);return{name:n.name,fn:n.fn,options:[e,t]}},Pqe=(e,t)=>({fn:Cqe(e).fn,options:[e,t]}),jqe=(e,t)=>{const n=Mqe(e);return{name:n.name,fn:n.fn,options:[e,t]}},zqe=(e,t)=>{const n=bqe(e);return{name:n.name,fn:n.fn,options:[e,t]}},Rqe=(e,t)=>{const n=_qe(e);return{name:n.name,fn:n.fn,options:[e,t]}},Tqe=(e,t)=>{const n=Aqe(e);return{name:n.name,fn:n.fn,options:[e,t]}};var Dqe="Arrow",sJ=m.forwardRef((e,t)=>{const{children:n,width:o=10,height:r=5,...a}=e;return p.jsx(Be.svg,{...a,ref:t,width:o,height:r,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:p.jsx("polygon",{points:"0,0 30,0 15,10"})})});sJ.displayName=Dqe;var Hqe=sJ,_O="Popper",[cJ,v0]=nr(_O),[qqe,lJ]=cJ(_O),dJ=e=>{const{__scopePopper:t,children:n}=e,[o,r]=m.useState(null);return p.jsx(qqe,{scope:t,anchor:o,onAnchorChange:r,children:n})};dJ.displayName=_O;var uJ="PopperAnchor",hJ=m.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:o,...r}=e,a=lJ(uJ,n),i=m.useRef(null),s=kt(t,i),c=m.useRef(null);return m.useEffect(()=>{const l=c.current;c.current=(o==null?void 0:o.current)||i.current,l!==c.current&&a.onAnchorChange(c.current)}),o?null:p.jsx(Be.div,{...r,ref:s})});hJ.displayName=uJ;var CO="PopperContent",[Oqe,Fqe]=cJ(CO),fJ=m.forwardRef((e,t)=>{var oe,te,se,we,ke,ge;const{__scopePopper:n,side:o="bottom",sideOffset:r=0,align:a="center",alignOffset:i=0,arrowPadding:s=0,avoidCollisions:c=!0,collisionBoundary:l=[],collisionPadding:h=0,sticky:u="partial",hideWhenDetached:f=!1,updatePositionStrategy:y="optimized",onPlaced:k,...x}=e,w=lJ(CO,n),[g,M]=m.useState(null),v=kt(t,ve=>M(ve)),[b,C]=m.useState(null),_=CQ(b),S=(_==null?void 0:_.width)??0,A=(_==null?void 0:_.height)??0,P=o+(a!=="center"?"-"+a:""),I=typeof h=="number"?h:{top:0,right:0,bottom:0,left:0,...h},$=Array.isArray(l)?l:[l],N=$.length>0,X={padding:I,boundary:$.filter(Bqe),altBoundary:N},{refs:j,floatingStyles:O,placement:H,isPositioned:B,middlewareData:z}=Nqe({strategy:"fixed",placement:P,whileElementsMounted:(...ve)=>vqe(...ve,{animationFrame:y==="always"}),elements:{reference:w.anchor},middleware:[Eqe({mainAxis:r+A,alignmentAxis:i}),c&&$qe({mainAxis:!0,crossAxis:!1,limiter:u==="partial"?Pqe():void 0,...X}),c&&jqe({...X}),zqe({...X,apply:({elements:ve,rects:re,availableWidth:me,availableHeight:Ve})=>{const{width:lt,height:Vt}=re.reference,Et=ve.floating.style;Et.setProperty("--radix-popper-available-width",`${me}px`),Et.setProperty("--radix-popper-available-height",`${Ve}px`),Et.setProperty("--radix-popper-anchor-width",`${lt}px`),Et.setProperty("--radix-popper-anchor-height",`${Vt}px`)}}),b&&Tqe({element:b,padding:s}),Uqe({arrowWidth:S,arrowHeight:A}),f&&Rqe({strategy:"referenceHidden",...X})]}),[R,L]=mJ(H),U=Br(k);_i(()=>{B&&(U==null||U())},[B,U]);const D=(oe=z.arrow)==null?void 0:oe.x,E=(te=z.arrow)==null?void 0:te.y,W=((se=z.arrow)==null?void 0:se.centerOffset)!==0,[Y,Q]=m.useState();return _i(()=>{g&&Q(window.getComputedStyle(g).zIndex)},[g]),p.jsx("div",{ref:j.setFloating,"data-radix-popper-content-wrapper":"",style:{...O,transform:B?O.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:Y,"--radix-popper-transform-origin":[(we=z.transformOrigin)==null?void 0:we.x,(ke=z.transformOrigin)==null?void 0:ke.y].join(" "),...((ge=z.hide)==null?void 0:ge.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:p.jsx(Oqe,{scope:n,placedSide:R,onArrowChange:C,arrowX:D,arrowY:E,shouldHideArrow:W,children:p.jsx(Be.div,{"data-side":R,"data-align":L,...x,ref:v,style:{...x.style,animation:B?void 0:"none"}})})})});fJ.displayName=CO;var pJ="PopperArrow",Vqe={top:"bottom",right:"left",bottom:"top",left:"right"},yJ=m.forwardRef(function(t,n){const{__scopePopper:o,...r}=t,a=Fqe(pJ,o),i=Vqe[a.placedSide];return p.jsx("span",{ref:a.onArrowChange,style:{position:"absolute",left:a.arrowX,top:a.arrowY,[i]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[a.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[a.placedSide],visibility:a.shouldHideArrow?"hidden":void 0},children:p.jsx(Hqe,{...r,ref:n,style:{...r.style,display:"block"}})})});yJ.displayName=pJ;function Bqe(e){return e!==null}var Uqe=e=>({name:"transformOrigin",options:e,fn(t){var w,g,M;const{placement:n,rects:o,middlewareData:r}=t,i=((w=r.arrow)==null?void 0:w.centerOffset)!==0,s=i?0:e.arrowWidth,c=i?0:e.arrowHeight,[l,h]=mJ(n),u={start:"0%",center:"50%",end:"100%"}[h],f=(((g=r.arrow)==null?void 0:g.x)??0)+s/2,y=(((M=r.arrow)==null?void 0:M.y)??0)+c/2;let k="",x="";return l==="bottom"?(k=i?u:`${f}px`,x=`${-c}px`):l==="top"?(k=i?u:`${f}px`,x=`${o.floating.height+c}px`):l==="right"?(k=`${-c}px`,x=i?u:`${y}px`):l==="left"&&(k=`${o.floating.width+c}px`,x=i?u:`${y}px`),{data:{x:k,y:x}}}});function mJ(e){const[t,n="center"]=e.split("-");return[t,n]}var SO=dJ,Rz=hJ,LO=fJ,IO=yJ,Wqe="Portal",Uh=m.forwardRef((e,t)=>{var s;const{container:n,...o}=e,[r,a]=m.useState(!1);_i(()=>a(!0),[]);const i=n||r&&((s=globalThis==null?void 0:globalThis.document)==null?void 0:s.body);return i?rse.createPortal(p.jsx(Be.div,{...o,ref:t}),i):null});Uh.displayName=Wqe;function Gqe(e,t){return m.useReducer((n,o)=>t[n][o]??n,e)}var ko=e=>{const{present:t,children:n}=e,o=Zqe(t),r=typeof n=="function"?n({present:o.isPresent}):m.Children.only(n),a=kt(o.ref,Kqe(r));return typeof n=="function"||o.isPresent?m.cloneElement(r,{ref:a}):null};ko.displayName="Presence";function Zqe(e){const[t,n]=m.useState(),o=m.useRef(null),r=m.useRef(e),a=m.useRef("none"),i=e?"mounted":"unmounted",[s,c]=Gqe(i,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return m.useEffect(()=>{const l=ep(o.current);a.current=s==="mounted"?l:"none"},[s]),_i(()=>{const l=o.current,h=r.current;if(h!==e){const f=a.current,y=ep(l);e?c("MOUNT"):y==="none"||(l==null?void 0:l.display)==="none"?c("UNMOUNT"):c(h&&f!==y?"ANIMATION_OUT":"UNMOUNT"),r.current=e}},[e,c]),_i(()=>{if(t){let l;const h=t.ownerDocument.defaultView??window,u=y=>{const x=ep(o.current).includes(CSS.escape(y.animationName));if(y.target===t&&x&&(c("ANIMATION_END"),!r.current)){const w=t.style.animationFillMode;t.style.animationFillMode="forwards",l=h.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=w)})}},f=y=>{y.target===t&&(a.current=ep(o.current))};return t.addEventListener("animationstart",f),t.addEventListener("animationcancel",u),t.addEventListener("animationend",u),()=>{h.clearTimeout(l),t.removeEventListener("animationstart",f),t.removeEventListener("animationcancel",u),t.removeEventListener("animationend",u)}}else c("ANIMATION_END")},[t,c]),{isPresent:["mounted","unmountSuspended"].includes(s),ref:m.useCallback(l=>{o.current=l?getComputedStyle(l):null,n(l)},[])}}function ep(e){return(e==null?void 0:e.animationName)||"none"}function Kqe(e){var o,r;let t=(o=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:o.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(r=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var Xqe=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},Od=new WeakMap,tp=new WeakMap,np={},hT=0,kJ=function(e){return e&&(e.host||kJ(e.parentNode))},Yqe=function(e,t){return t.map(function(n){if(e.contains(n))return n;var o=kJ(n);return o&&e.contains(o)?o:(console.error("aria-hidden",n,"in not contained inside",e,". Doing nothing"),null)}).filter(function(n){return!!n})},Qqe=function(e,t,n,o){var r=Yqe(t,Array.isArray(e)?e:[e]);np[n]||(np[n]=new WeakMap);var a=np[n],i=[],s=new Set,c=new Set(r),l=function(u){!u||s.has(u)||(s.add(u),l(u.parentNode))};r.forEach(l);var h=function(u){!u||c.has(u)||Array.prototype.forEach.call(u.children,function(f){if(s.has(f))h(f);else try{var y=f.getAttribute(o),k=y!==null&&y!=="false",x=(Od.get(f)||0)+1,w=(a.get(f)||0)+1;Od.set(f,x),a.set(f,w),i.push(f),x===1&&k&&tp.set(f,!0),w===1&&f.setAttribute(n,"true"),k||f.setAttribute(o,"true")}catch(g){console.error("aria-hidden: cannot operate on ",f,g)}})};return h(t),s.clear(),hT++,function(){i.forEach(function(u){var f=Od.get(u)-1,y=a.get(u)-1;Od.set(u,f),a.set(u,y),f||(tp.has(u)||u.removeAttribute(o),tp.delete(u)),y||u.removeAttribute(n)}),hT--,hT||(Od=new WeakMap,Od=new WeakMap,tp=new WeakMap,np={})}},NO=function(e,t,n){n===void 0&&(n="data-aria-hidden");var o=Array.from(Array.isArray(e)?e:[e]),r=Xqe(e);return r?(o.push.apply(o,Array.from(r.querySelectorAll("[aria-live], script"))),Qqe(o,r,n,"aria-hidden")):function(){return null}},jr=function(){return jr=Object.assign||function(t){for(var n,o=1,r=arguments.length;o<r;o++){n=arguments[o];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(t[a]=n[a])}return t},jr.apply(this,arguments)};function gJ(e,t){var n={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.indexOf(o)<0&&(n[o]=e[o]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,o=Object.getOwnPropertySymbols(e);r<o.length;r++)t.indexOf(o[r])<0&&Object.prototype.propertyIsEnumerable.call(e,o[r])&&(n[o[r]]=e[o[r]]);return n}function Jqe(e,t,n){if(n||arguments.length===2)for(var o=0,r=t.length,a;o<r;o++)(a||!(o in t))&&(a||(a=Array.prototype.slice.call(t,0,o)),a[o]=t[o]);return e.concat(a||Array.prototype.slice.call(t))}var qP="right-scroll-bar-position",OP="width-before-scroll-bar",eOe="with-scroll-bars-hidden",tOe="--removed-body-scroll-bar-size";function fT(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function nOe(e,t){var n=m.useState(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(o){var r=n.value;r!==o&&(n.value=o,n.callback(o,r))}}}})[0];return n.callback=t,n.facade}var oOe=typeof window<"u"?m.useLayoutEffect:m.useEffect,VU=new WeakMap;function rOe(e,t){var n=nOe(null,function(o){return e.forEach(function(r){return fT(r,o)})});return oOe(function(){var o=VU.get(n);if(o){var r=new Set(o),a=new Set(e),i=n.current;r.forEach(function(s){a.has(s)||fT(s,null)}),a.forEach(function(s){r.has(s)||fT(s,i)})}VU.set(n,e)},[e]),n}function aOe(e){return e}function iOe(e,t){t===void 0&&(t=aOe);var n=[],o=!1,r={read:function(){if(o)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(a){var i=t(a,o);return n.push(i),function(){n=n.filter(function(s){return s!==i})}},assignSyncMedium:function(a){for(o=!0;n.length;){var i=n;n=[],i.forEach(a)}n={push:function(s){return a(s)},filter:function(){return n}}},assignMedium:function(a){o=!0;var i=[];if(n.length){var s=n;n=[],s.forEach(a),i=n}var c=function(){var h=i;i=[],h.forEach(a)},l=function(){return Promise.resolve().then(c)};l(),n={push:function(h){i.push(h),l()},filter:function(h){return i=i.filter(h),n}}}};return r}function sOe(e){e===void 0&&(e={});var t=iOe(null);return t.options=jr({async:!0,ssr:!1},e),t}var vJ=function(e){var t=e.sideCar,n=gJ(e,["sideCar"]);if(!t)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var o=t.read();if(!o)throw new Error("Sidecar medium not found");return m.createElement(o,jr({},n))};vJ.isSideCarExport=!0;function cOe(e,t){return e.useMedium(t),vJ}var xJ=sOe(),pT=function(){},Tz=m.forwardRef(function(e,t){var n=m.useRef(null),o=m.useState({onScrollCapture:pT,onWheelCapture:pT,onTouchMoveCapture:pT}),r=o[0],a=o[1],i=e.forwardProps,s=e.children,c=e.className,l=e.removeScrollBar,h=e.enabled,u=e.shards,f=e.sideCar,y=e.noRelative,k=e.noIsolation,x=e.inert,w=e.allowPinchZoom,g=e.as,M=g===void 0?"div":g,v=e.gapMode,b=gJ(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),C=f,_=rOe([n,t]),S=jr(jr({},b),r);return m.createElement(m.Fragment,null,h&&m.createElement(C,{sideCar:xJ,removeScrollBar:l,shards:u,noRelative:y,noIsolation:k,inert:x,setCallbacks:a,allowPinchZoom:!!w,lockRef:n,gapMode:v}),i?m.cloneElement(m.Children.only(s),jr(jr({},S),{ref:_})):m.createElement(M,jr({},S,{className:c,ref:_}),s))});Tz.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};Tz.classNames={fullWidth:OP,zeroRight:qP};var lOe=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function dOe(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=lOe();return t&&e.setAttribute("nonce",t),e}function uOe(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function hOe(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var fOe=function(){var e=0,t=null;return{add:function(n){e==0&&(t=dOe())&&(uOe(t,n),hOe(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},pOe=function(){var e=fOe();return function(t,n){m.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},wJ=function(){var e=pOe(),t=function(n){var o=n.styles,r=n.dynamic;return e(o,r),null};return t},yOe={left:0,top:0,right:0,gap:0},yT=function(e){return parseInt(e||"",10)||0},mOe=function(e){var t=window.getComputedStyle(document.body),n=t[e==="padding"?"paddingLeft":"marginLeft"],o=t[e==="padding"?"paddingTop":"marginTop"],r=t[e==="padding"?"paddingRight":"marginRight"];return[yT(n),yT(o),yT(r)]},kOe=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return yOe;var t=mOe(e),n=document.documentElement.clientWidth,o=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,o-n+t[2]-t[0])}},gOe=wJ(),Au="data-scroll-locked",vOe=function(e,t,n,o){var r=e.left,a=e.top,i=e.right,s=e.gap;return n===void 0&&(n="margin"),`
8468
+ `);return}$.preventDefault(),M.current=!0,_();return}$.key==="Escape"&&($.preventDefault(),M.current=!0,S())},P=$=>{$.preventDefault();const N=$.clipboardData.getData("text/plain");document.execCommand("insertText",!1,N)},I=()=>{if(M.current){M.current=!1;return}_()};return p.jsx("div",{ref:u,"data-testid":"inline-edit-input","data-field":i,"data-placeholder":l,role:"textbox",tabIndex:0,contentEditable:!0,suppressContentEditableWarning:!0,spellCheck:!1,onInput:C,onKeyDown:A,onPaste:P,onBlur:I,onMouseDown:$=>$.stopPropagation(),onClick:$=>$.stopPropagation(),onDoubleClick:$=>$.stopPropagation(),style:c,className:ae("nodrag nopan nowheel sf:block sf:w-full sf:bg-transparent sf:p-0 sf:text-inherit sf:outline-none","sf:whitespace-pre-wrap sf:wrap-break-word",k&&l?"inline-edit-empty":"",f?"inline-edit-shake":"",s)})}const dQ=8,KB=12,XB={height:`${dQ}px`,borderColor:"transparent"},YB={width:`${dQ}px`,borderColor:"transparent"},ORe={width:`${KB}px`,height:`${KB}px`,background:"transparent",border:"none"},FRe={width:"calc(10px / var(--rf-zoom, 1))",height:"calc(10px / var(--rf-zoom, 1))",background:"hsl(var(--background))",border:"calc(1px / var(--rf-zoom, 1)) solid hsl(var(--primary) / 0.6)",borderRadius:"calc(2px / var(--rf-zoom, 1))",zIndex:1},VRe=[{position:"top",style:XB},{position:"bottom",style:XB},{position:"left",style:YB},{position:"right",style:YB}],BRe=["top-left","top-right","bottom-left","bottom-right"],QB={pointerEvents:"none",cursor:"default"};function p0({visible:e,minWidth:t=80,minHeight:n=40,onResizeStart:o,onResize:r,onResizeEnd:a,cornerVariant:i="invisible"}){const s=i==="visible"?FRe:ORe,c=h=>e?h:{...h,...QB},l=e?s:{...s,opacity:0,...QB};return p.jsxs(p.Fragment,{children:[VRe.map(({position:h,style:u})=>p.jsx(GB,{position:h,variant:Mi.Line,minWidth:t,minHeight:n,style:c(u),onResizeStart:o,onResize:r,onResizeEnd:a,children:p.jsx("span",{"data-testid":"resize-control","data-position":h})},h)),BRe.map(h=>p.jsx(GB,{position:h,variant:Mi.Handle,minWidth:t,minHeight:n,style:l,autoScale:!1,onResizeStart:o,onResize:r,onResizeEnd:a,children:p.jsx("span",{"data-testid":"resize-control","data-position":h})},h))]})}function y0(e){const{onResize:t,onResizeEnd:n,onResizeFinal:o,setResizing:r}=e,[a,i]=m.useState(!1),s=m.useRef(null),c=m.useRef(t),l=m.useRef(n),h=m.useRef(o),u=m.useRef(r);m.useEffect(()=>{c.current=t},[t]),m.useEffect(()=>{l.current=n},[n]),m.useEffect(()=>{h.current=o},[o]),m.useEffect(()=>{u.current=r},[r]);const f=m.useCallback((x,w)=>{var g;i(!0),(g=u.current)==null||g.call(u,!0),s.current=w?{x:w.x,y:w.y,width:w.width,height:w.height}:null},[]),y=m.useCallback((x,w)=>{var g;(g=c.current)==null||g.call(c,{x:w.x,y:w.y,width:w.width,height:w.height})},[]),k=m.useCallback((x,w)=>{var M,v,b,C;i(!1),(M=u.current)==null||M.call(u,!1);const g=s.current;s.current=null,!(g&&g.width===w.width&&g.height===w.height)&&((v=c.current)==null||v.call(c,{x:w.x,y:w.y,width:w.width,height:w.height}),(b=l.current)==null||b.call(l,{x:w.x,y:w.y,width:w.width,height:w.height}),g&&((C=h.current)==null||C.call(h,{x:w.x,y:w.y,width:w.width,height:w.height},g)))},[]);return{isResizing:a,onResizeStart:f,onResizeEvent:y,onResizeEnd:k}}const Ku={width:48,height:48},JB="help-circle",URe=24,WRe=24,Kf="sf:opacity-0 sf:transition-opacity";function GRe(e){return Nt(e,"text").color??"currentColor"}const eU=new Set;function ZRe({id:e,data:t,selected:n,isConnectable:o}){const{onResizeStart:r,onResizeEvent:a,onResizeEnd:i}=y0({onResize:g=>{var M;return(M=t.onResize)==null?void 0:M.call(t,e,g)},onResizeEnd:g=>{var M;return(M=t.onResizeEnd)==null?void 0:M.call(t,e,g)},setResizing:t.setResizing}),s=t.width!==void 0||t.height!==void 0,c=!!t.onNameChange,[l,h]=m.useState(!1),u=Hu[t.icon];!u&&!eU.has(t.icon)&&(eU.add(t.icon),console.warn(`[iconNode] Unknown icon "${t.icon}"; falling back to "${JB}".`));const f=u??Hu[JB],y=GRe(t.color),k=t.strokeWidth??2,x={...s?{}:{width:Ku.width,height:Ku.height}},w=g=>{!c||l||(g.stopPropagation(),h(!0))};return p.jsxs("div",{className:ae("sf:group sf:relative",s?"sf:h-full sf:w-full":""),style:x,"data-testid":"icon-node","data-node-type":"icon",onDoubleClick:w,children:[p.jsx(p0,{visible:!!n&&!!t.onResize&&!l,cornerVariant:"visible",minWidth:URe,minHeight:WRe,onResizeStart:r,onResize:a,onResizeEnd:i}),p.jsx(ht,{type:"target",position:pe.Top,id:"t",isConnectable:o,className:ae(Kf,n&&"sf:opacity-100!")}),p.jsx(ht,{type:"target",position:pe.Left,id:"l",isConnectable:o,className:ae(Kf,n&&"sf:opacity-100!")}),f?p.jsx(f,{color:y,strokeWidth:k,absoluteStrokeWidth:!0,"aria-label":t.alt,className:"sf:block sf:h-full sf:w-full sf:pointer-events-none sf:select-none"}):null,l&&c?p.jsx("div",{className:"sf:absolute sf:left-0 sf:right-0 sf:top-full sf:mt-1 sf:text-center sf:text-xs sf:text-muted-foreground",children:p.jsx(ci,{initialValue:t.name??"",field:"icon-node-label",onCommit:g=>{var M;return(M=t.onNameChange)==null?void 0:M.call(t,e,g)},onExit:()=>h(!1),placeholder:"Label"})}):t.name?p.jsx("span",{"data-testid":"icon-node-label",className:"sf:pointer-events-none sf:absolute sf:left-0 sf:right-0 sf:top-full sf:mt-1 sf:truncate sf:text-center sf:text-xs sf:text-muted-foreground sf:select-none",children:t.name}):null,p.jsx(ht,{type:"source",position:pe.Right,id:"r",isConnectable:o,className:ae(Kf,n&&"sf:opacity-100!")}),p.jsx(ht,{type:"source",position:pe.Bottom,id:"b",isConnectable:o,className:ae(Kf,n&&"sf:opacity-100!")})]})}function KRe(e,t){return e.selected===t.selected&&e.data===t.data&&e.width===t.width&&e.height===t.height}const XRe=m.memo(ZRe,KRe);function YRe(e,t){const n=e.screenToFlowPosition({x:t.width/2,y:t.height/2});return{x:n.x-Ku.width/2,y:n.y-Ku.height/2}}const uQ="seeflow:icon-recents",QRe=16;function hQ(){if(typeof window>"u")return[];try{const e=window.localStorage.getItem(uQ);if(e===null)return[];const t=JSON.parse(e);return Array.isArray(t)?t.every(n=>typeof n=="string")?t:[]:[]}catch{return[]}}function JRe(e){if(!(typeof window>"u"))try{const n=hQ().filter(r=>r!==e),o=[e,...n].slice(0,QRe);window.localStorage.setItem(uQ,JSON.stringify(o))}catch{}}const eTe=typeof navigator<"u"&&typeof navigator.platform=="string"&&navigator.platform.toLowerCase().includes("mac"),tTe=e=>e.length===1?e.toUpperCase():e==="Escape"?"Esc":e,Tt=(e,t=eTe)=>{const n=tTe(e.key);if(t){let r="";return e.meta&&(r+="⌘"),e.alt&&(r+="⌥"),e.shift&&(r+="⇧"),`${r}${n}`}const o=[];return e.meta&&o.push("Ctrl"),e.shift&&o.push("Shift"),e.alt&&o.push("Alt"),o.push(n),o.join("+")},lO=[{id:"tool.select",label:"Select tool",description:"Switch to the selection tool",category:"Tools",shortcut:Tt({key:"V"})},{id:"tool.hand",label:"Hand tool",description:"Pan the canvas; node interaction is suspended while armed",category:"Tools",shortcut:Tt({key:"H"})},{id:"tool.rectangle",label:"Rectangle",description:"Draw rectangle nodes",category:"Tools",shortcut:Tt({key:"R"})},{id:"tool.ellipse",label:"Ellipse",description:"Draw ellipse nodes",category:"Tools",shortcut:Tt({key:"O"})},{id:"tool.text",label:"Text",description:"Add a text node",category:"Tools",shortcut:Tt({key:"T"})},{id:"tool.sticky",label:"Sticky note",description:"Add a sticky note",category:"Tools",shortcut:Tt({key:"S"})},{id:"tool.database",label:"Database",description:"Add a database node",category:"Tools",shortcut:Tt({key:"D"})},{id:"tool.server",label:"Server",description:"Add a server node",category:"Tools"},{id:"tool.user",label:"User",description:"Add a user node",category:"Tools"},{id:"tool.queue",label:"Queue",description:"Add a queue node",category:"Tools"},{id:"tool.cloud",label:"Cloud",description:"Add a cloud node",category:"Tools"},{id:"edit.undo",label:"Undo",category:"Edit",shortcut:Tt({meta:!0,key:"Z"}),enabled:e=>e.canUndo},{id:"edit.redo",label:"Redo",category:"Edit",shortcut:Tt({meta:!0,shift:!0,key:"Z"}),enabled:e=>e.canRedo},{id:"edit.copy",label:"Copy",category:"Edit",shortcut:Tt({meta:!0,key:"C"}),enabled:e=>e.hasSelection},{id:"edit.paste",label:"Paste",category:"Edit",shortcut:Tt({meta:!0,key:"V"}),enabled:e=>e.hasClipboard},{id:"edit.duplicate",label:"Duplicate",category:"Edit",shortcut:Tt({meta:!0,key:"D"}),enabled:e=>e.hasSelection},{id:"edit.delete",label:"Delete",category:"Edit",shortcut:Tt({key:"Delete"}),enabled:e=>e.hasSelection},{id:"edit.selectAll",label:"Select all",category:"Edit",shortcut:Tt({meta:!0,key:"A"})},{id:"view.fit",label:"Fit view",description:"Fit everything in the viewport",category:"View",shortcut:Tt({meta:!0,key:"0"})},{id:"view.zoomIn",label:"Zoom in",category:"View",shortcut:Tt({meta:!0,key:"="})},{id:"view.zoomOut",label:"Zoom out",category:"View",shortcut:Tt({meta:!0,key:"-"})},{id:"view.zoom100",label:"Zoom to 100%",category:"View",shortcut:Tt({key:"1"})},{id:"view.zoomToSelection",label:"Zoom to selection",category:"View",shortcut:Tt({key:"F"}),enabled:e=>e.hasSelection},{id:"layout.tidy",label:"Tidy layout",description:"Auto-layout the canvas or current selection",category:"Layout",shortcut:Tt({meta:!0,shift:!0,key:"L"})},{id:"selection.deselect",label:"Deselect",description:"Clear selection and exit draw mode",category:"Selection",shortcut:Tt({key:"Escape"})},{id:"help.commandPalette",label:"Open command palette",category:"Help",shortcut:Tt({meta:!0,key:"P"})},{id:"export.pdf",label:"Export to PDF",description:"Download the current canvas as a PDF",category:"File",enabled:e=>e.canExportDemo},{id:"export.png",label:"Export as image",description:"Download the current canvas as a PNG",category:"File",enabled:e=>e.canExportDemo},{id:"session.reset",label:"Restart the demo",description:"Stop running scripts and re-run the reset script",category:"File",enabled:e=>e.canResetSession}],nT=e=>{const t=lO.find(n=>n.id===e);return t?t.shortcut?`${t.label} (${t.shortcut})`:t.label:""},nTe=1,oTe=10,rTe=e=>{if(e.metaKey||e.ctrlKey||e.altKey)return null;const t=e.shiftKey?oTe:nTe;switch(e.key){case"ArrowLeft":return{dx:-t,dy:0};case"ArrowRight":return{dx:t,dy:0};case"ArrowUp":return{dx:0,dy:-t};case"ArrowDown":return{dx:0,dy:t};default:return null}},aTe=e=>{if(!(e.metaKey||e.ctrlKey)||e.altKey)return null;switch(e.key){case"0":return"fit";case"=":case"+":return"in";case"-":case"_":return"out";default:return null}},iTe=(e,t,n)=>{if(t.length===0)return[];const o=new Map(n.map(a=>[a.id,a])),r=[];for(const a of t){const i=o.get(a);i&&r.push({id:a,position:{x:i.position.x+e.dx,y:i.position.y+e.dy}})}return r},sTe=({event:e,isEditableActive:t,hasNodes:n,hasConnectors:o,selectedIds:r,hasClipboard:a})=>{if(!(e.metaKey||e.ctrlKey))return{type:"noop"};if(e.shiftKey||e.altKey)return{type:"noop"};const i=e.key.toLowerCase();return i!=="a"&&i!=="c"&&i!=="v"&&i!=="d"?{type:"noop"}:t?{type:"noop"}:i==="a"?!n&&!o?{type:"noop"}:{type:"selectAll"}:i==="c"?r.length===0?{type:"noop"}:{type:"copy",ids:r}:i==="d"?r.length===0?{type:"noop"}:{type:"duplicate",ids:r}:a?{type:"paste"}:{type:"noop"}},cTe=e=>{if(e.metaKey||e.ctrlKey||e.shiftKey||e.altKey)return null;switch(e.key.toLowerCase()){case"v":return"select";case"h":return"hand";case"r":return"rectangle";case"o":return"ellipse";case"t":return"text";case"s":return"sticky";case"d":return"database";default:return null}},Xa="seeflow",fQ=e=>`${e}:last-used-style:v1`,oT=()=>({node:{},connector:{}}),rT=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),dO=e=>{var t;try{const n=(t=globalThis.localStorage)==null?void 0:t.getItem(fQ(e));if(!n)return oT();const o=JSON.parse(n);if(!rT(o))return oT();const r=rT(o.node)?o.node:{},a=rT(o.connector)?o.connector:{};return{node:r,connector:a}}catch{return oT()}},pQ=(e,t)=>{var n;try{(n=globalThis.localStorage)==null||n.setItem(fQ(e),JSON.stringify(t))}catch{}},n2=e=>dO(e),tU=(e,t)=>{const{alt:n,...o}=t,r={...o};r.borderSize!==void 0&&r.borderWidth===void 0?r.borderWidth=r.borderSize:r.borderWidth!==void 0&&r.borderSize===void 0&&(r.borderSize=r.borderWidth);const a=dO(e);pQ(e,{...a,node:{...a.node,...r}})},lTe=(e,t)=>{const n=dO(e);pQ(e,{...n,connector:{...n.connector,...t}})},uO=1,nU=17,nH=(e,t)=>{if(!e)return{};const n={};for(const o of t)e[o]!==void 0&&(n[o]=e[o]);return n},dTe=["borderColor","backgroundColor","borderSize","borderStyle","fontSize","cornerRadius","shadow"],uTe=["borderColor","backgroundColor","borderSize","borderStyle","fontSize","shadow"],hTe=["fontSize"],fTe=["borderColor","borderWidth","borderStyle","shadow"];function oU(e,t,n){if(e==="text")return{width:t.width,height:t.height,fontSize:nU,...nH(n,hTe)};const o=e==="ellipse"?uTe:dTe;return{width:t.width,height:t.height,borderSize:uO,fontSize:nU,...nH(n,o)}}function pTe(e,t,n){return{path:e,width:t.width,height:t.height,borderWidth:uO,...nH(n,fTe)}}const xo=async(e,t,n,o)=>{const r={method:t};o!==void 0&&(r.headers={"content-type":"application/json"},r.body=JSON.stringify(o));const a=await e(n,r);if(!a.ok){let i=null;try{i=await a.json()}catch{}throw new Error((i==null?void 0:i.error)??`${t} ${n} → ${a.status}`)}return await a.json()},yTe=e=>{const{baseUrl:t,flowId:n}=e,o=e.fetch??globalThis.fetch.bind(globalThis),r=`${t}/api/flows/${n}`;return{async createNode(a){const i=await xo(o,"POST",`${r}/nodes`,a);return{id:i.id,node:i.node}},async updateNode(a,i){await xo(o,"PATCH",`${r}/nodes/${a}`,i)},async updateNodePosition(a,i){return await xo(o,"PATCH",`${r}/nodes/${a}/position`,i)},async deleteNode(a){await xo(o,"DELETE",`${r}/nodes/${a}`)},async reorderNode(a,i){await xo(o,"PATCH",`${r}/nodes/${a}/order`,i)},async createConnector(a){return{id:(await xo(o,"POST",`${r}/connectors`,a)).id}},async updateConnector(a,i){await xo(o,"PATCH",`${r}/connectors/${a}`,i)},async deleteConnector(a){await xo(o,"DELETE",`${r}/connectors/${a}`)},async uploadImage(a,i,s){const c=new FormData;c.append("file",i),c.append("filename",s);const l=`${t}/api/projects/${encodeURIComponent(n)}/nodes/${encodeURIComponent(a)}/files/upload`,h=await o(l,{method:"POST",body:c});if(!h.ok){let u=null;try{u=await h.json()}catch{}throw new Error((u==null?void 0:u.error)??`POST ${l} → ${h.status}`)}return await h.json()},async playAction(a){return await xo(o,"POST",`${r}/play/${a}`,{})},async openFile(a){await xo(o,"POST",`${t}/api/projects/${encodeURIComponent(n)}/files/open`,{path:a})},async revealFile(a){await xo(o,"POST",`${t}/api/projects/${encodeURIComponent(n)}/files/reveal`,{path:a})},async computeLayout(a,i){const s=await xo(o,"POST",`${t}/api/layout`,{nodes:a,edges:i});return{nodes:s.nodes,connectors:s.connectors}}}};function yQ(e,t,n){let o=null,r=!1;const a=new ResizeObserver(()=>{r||(o!==null&&clearTimeout(o),o=setTimeout(()=>{o=null,!r&&n()},t))});return a.observe(e),()=>{r||(r=!0,o!==null&&(clearTimeout(o),o=null),a.disconnect())}}const mTe="modulepreload",kTe=function(e){return"/"+e},rU={},Iz=function(t,n,o){let r=Promise.resolve();if(n&&n.length>0){document.getElementsByTagName("link");const i=document.querySelector("meta[property=csp-nonce]"),s=(i==null?void 0:i.nonce)||(i==null?void 0:i.getAttribute("nonce"));r=Promise.allSettled(n.map(c=>{if(c=kTe(c),c in rU)return;rU[c]=!0;const l=c.endsWith(".css"),h=l?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${c}"]${h}`))return;const u=document.createElement("link");if(u.rel=l?"stylesheet":mTe,l||(u.as="script"),u.crossOrigin="",u.href=c,s&&u.setAttribute("nonce",s),document.head.appendChild(u),l)return new Promise((f,y)=>{u.addEventListener("load",f),u.addEventListener("error",()=>y(new Error(`Unable to preload CSS for ${c}`)))})}))}function a(i){const s=new Event("vite:preloadError",{cancelable:!0});if(s.payload=i,window.dispatchEvent(s),!s.defaultPrevented)throw i}return r.then(i=>{for(const s of i||[])s.status==="rejected"&&a(s.reason);return t().catch(a)})};var at;(function(e){e.assertEqual=r=>{};function t(r){}e.assertIs=t;function n(r){throw new Error}e.assertNever=n,e.arrayToEnum=r=>{const a={};for(const i of r)a[i]=i;return a},e.getValidEnumValues=r=>{const a=e.objectKeys(r).filter(s=>typeof r[r[s]]!="number"),i={};for(const s of a)i[s]=r[s];return e.objectValues(i)},e.objectValues=r=>e.objectKeys(r).map(function(a){return r[a]}),e.objectKeys=typeof Object.keys=="function"?r=>Object.keys(r):r=>{const a=[];for(const i in r)Object.prototype.hasOwnProperty.call(r,i)&&a.push(i);return a},e.find=(r,a)=>{for(const i of r)if(a(i))return i},e.isInteger=typeof Number.isInteger=="function"?r=>Number.isInteger(r):r=>typeof r=="number"&&Number.isFinite(r)&&Math.floor(r)===r;function o(r,a=" | "){return r.map(i=>typeof i=="string"?`'${i}'`:i).join(a)}e.joinValues=o,e.jsonStringifyReplacer=(r,a)=>typeof a=="bigint"?a.toString():a})(at||(at={}));var aU;(function(e){e.mergeShapes=(t,n)=>({...t,...n})})(aU||(aU={}));const Se=at.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),ni=e=>{switch(typeof e){case"undefined":return Se.undefined;case"string":return Se.string;case"number":return Number.isNaN(e)?Se.nan:Se.number;case"boolean":return Se.boolean;case"function":return Se.function;case"bigint":return Se.bigint;case"symbol":return Se.symbol;case"object":return Array.isArray(e)?Se.array:e===null?Se.null:e.then&&typeof e.then=="function"&&e.catch&&typeof e.catch=="function"?Se.promise:typeof Map<"u"&&e instanceof Map?Se.map:typeof Set<"u"&&e instanceof Set?Se.set:typeof Date<"u"&&e instanceof Date?Se.date:Se.object;default:return Se.unknown}},ye=at.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]);class _a extends Error{get errors(){return this.issues}constructor(t){super(),this.issues=[],this.addIssue=o=>{this.issues=[...this.issues,o]},this.addIssues=(o=[])=>{this.issues=[...this.issues,...o]};const n=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,n):this.__proto__=n,this.name="ZodError",this.issues=t}format(t){const n=t||function(a){return a.message},o={_errors:[]},r=a=>{for(const i of a.issues)if(i.code==="invalid_union")i.unionErrors.map(r);else if(i.code==="invalid_return_type")r(i.returnTypeError);else if(i.code==="invalid_arguments")r(i.argumentsError);else if(i.path.length===0)o._errors.push(n(i));else{let s=o,c=0;for(;c<i.path.length;){const l=i.path[c];c===i.path.length-1?(s[l]=s[l]||{_errors:[]},s[l]._errors.push(n(i))):s[l]=s[l]||{_errors:[]},s=s[l],c++}}};return r(this),o}static assert(t){if(!(t instanceof _a))throw new Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,at.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(t=n=>n.message){const n={},o=[];for(const r of this.issues)if(r.path.length>0){const a=r.path[0];n[a]=n[a]||[],n[a].push(t(r))}else o.push(t(r));return{formErrors:o,fieldErrors:n}}get formErrors(){return this.flatten()}}_a.create=e=>new _a(e);const oH=(e,t)=>{let n;switch(e.code){case ye.invalid_type:e.received===Se.undefined?n="Required":n=`Expected ${e.expected}, received ${e.received}`;break;case ye.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(e.expected,at.jsonStringifyReplacer)}`;break;case ye.unrecognized_keys:n=`Unrecognized key(s) in object: ${at.joinValues(e.keys,", ")}`;break;case ye.invalid_union:n="Invalid input";break;case ye.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${at.joinValues(e.options)}`;break;case ye.invalid_enum_value:n=`Invalid enum value. Expected ${at.joinValues(e.options)}, received '${e.received}'`;break;case ye.invalid_arguments:n="Invalid function arguments";break;case ye.invalid_return_type:n="Invalid function return type";break;case ye.invalid_date:n="Invalid date";break;case ye.invalid_string:typeof e.validation=="object"?"includes"in e.validation?(n=`Invalid input: must include "${e.validation.includes}"`,typeof e.validation.position=="number"&&(n=`${n} at one or more positions greater than or equal to ${e.validation.position}`)):"startsWith"in e.validation?n=`Invalid input: must start with "${e.validation.startsWith}"`:"endsWith"in e.validation?n=`Invalid input: must end with "${e.validation.endsWith}"`:at.assertNever(e.validation):e.validation!=="regex"?n=`Invalid ${e.validation}`:n="Invalid";break;case ye.too_small:e.type==="array"?n=`Array must contain ${e.exact?"exactly":e.inclusive?"at least":"more than"} ${e.minimum} element(s)`:e.type==="string"?n=`String must contain ${e.exact?"exactly":e.inclusive?"at least":"over"} ${e.minimum} character(s)`:e.type==="number"?n=`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:e.type==="bigint"?n=`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:e.type==="date"?n=`Date must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(e.minimum))}`:n="Invalid input";break;case ye.too_big:e.type==="array"?n=`Array must contain ${e.exact?"exactly":e.inclusive?"at most":"less than"} ${e.maximum} element(s)`:e.type==="string"?n=`String must contain ${e.exact?"exactly":e.inclusive?"at most":"under"} ${e.maximum} character(s)`:e.type==="number"?n=`Number must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:e.type==="bigint"?n=`BigInt must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:e.type==="date"?n=`Date must be ${e.exact?"exactly":e.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(e.maximum))}`:n="Invalid input";break;case ye.custom:n="Invalid input";break;case ye.invalid_intersection_types:n="Intersection results could not be merged";break;case ye.not_multiple_of:n=`Number must be a multiple of ${e.multipleOf}`;break;case ye.not_finite:n="Number must be finite";break;default:n=t.defaultError,at.assertNever(e)}return{message:n}};let gTe=oH;function vTe(){return gTe}const xTe=e=>{const{data:t,path:n,errorMaps:o,issueData:r}=e,a=[...n,...r.path||[]],i={...r,path:a};if(r.message!==void 0)return{...r,path:a,message:r.message};let s="";const c=o.filter(l=>!!l).slice().reverse();for(const l of c)s=l(i,{data:t,defaultError:s}).message;return{...r,path:a,message:s}};function Me(e,t){const n=vTe(),o=xTe({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,n,n===oH?void 0:oH].filter(r=>!!r)});e.common.issues.push(o)}class En{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(t,n){const o=[];for(const r of n){if(r.status==="aborted")return Fe;r.status==="dirty"&&t.dirty(),o.push(r.value)}return{status:t.value,value:o}}static async mergeObjectAsync(t,n){const o=[];for(const r of n){const a=await r.key,i=await r.value;o.push({key:a,value:i})}return En.mergeObjectSync(t,o)}static mergeObjectSync(t,n){const o={};for(const r of n){const{key:a,value:i}=r;if(a.status==="aborted"||i.status==="aborted")return Fe;a.status==="dirty"&&t.dirty(),i.status==="dirty"&&t.dirty(),a.value!=="__proto__"&&(typeof i.value<"u"||r.alwaysSet)&&(o[a.value]=i.value)}return{status:t.value,value:o}}}const Fe=Object.freeze({status:"aborted"}),o2=e=>({status:"dirty",value:e}),No=e=>({status:"valid",value:e}),iU=e=>e.status==="aborted",sU=e=>e.status==="dirty",Xu=e=>e.status==="valid",Nj=e=>typeof Promise<"u"&&e instanceof Promise;var Ne;(function(e){e.errToObj=t=>typeof t=="string"?{message:t}:t||{},e.toString=t=>typeof t=="string"?t:t==null?void 0:t.message})(Ne||(Ne={}));class Fr{constructor(t,n,o,r){this._cachedPath=[],this.parent=t,this.data=n,this._path=o,this._key=r}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const cU=(e,t)=>{if(Xu(t))return{success:!0,data:t.value};if(!e.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const n=new _a(e.common.issues);return this._error=n,this._error}}};function Ze(e){if(!e)return{};const{errorMap:t,invalid_type_error:n,required_error:o,description:r}=e;if(t&&(n||o))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return t?{errorMap:t,description:r}:{errorMap:(i,s)=>{const{message:c}=e;return i.code==="invalid_enum_value"?{message:c??s.defaultError}:typeof s.data>"u"?{message:c??o??s.defaultError}:i.code!=="invalid_type"?{message:s.defaultError}:{message:c??n??s.defaultError}},description:r}}class et{get description(){return this._def.description}_getType(t){return ni(t.data)}_getOrReturnCtx(t,n){return n||{common:t.parent.common,data:t.data,parsedType:ni(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}_processInputParams(t){return{status:new En,ctx:{common:t.parent.common,data:t.data,parsedType:ni(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}}_parseSync(t){const n=this._parse(t);if(Nj(n))throw new Error("Synchronous parse encountered promise.");return n}_parseAsync(t){const n=this._parse(t);return Promise.resolve(n)}parse(t,n){const o=this.safeParse(t,n);if(o.success)return o.data;throw o.error}safeParse(t,n){const o={common:{issues:[],async:(n==null?void 0:n.async)??!1,contextualErrorMap:n==null?void 0:n.errorMap},path:(n==null?void 0:n.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:ni(t)},r=this._parseSync({data:t,path:o.path,parent:o});return cU(o,r)}"~validate"(t){var o,r;const n={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:ni(t)};if(!this["~standard"].async)try{const a=this._parseSync({data:t,path:[],parent:n});return Xu(a)?{value:a.value}:{issues:n.common.issues}}catch(a){(r=(o=a==null?void 0:a.message)==null?void 0:o.toLowerCase())!=null&&r.includes("encountered")&&(this["~standard"].async=!0),n.common={issues:[],async:!0}}return this._parseAsync({data:t,path:[],parent:n}).then(a=>Xu(a)?{value:a.value}:{issues:n.common.issues})}async parseAsync(t,n){const o=await this.safeParseAsync(t,n);if(o.success)return o.data;throw o.error}async safeParseAsync(t,n){const o={common:{issues:[],contextualErrorMap:n==null?void 0:n.errorMap,async:!0},path:(n==null?void 0:n.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:ni(t)},r=this._parse({data:t,path:o.path,parent:o}),a=await(Nj(r)?r:Promise.resolve(r));return cU(o,a)}refine(t,n){const o=r=>typeof n=="string"||typeof n>"u"?{message:n}:typeof n=="function"?n(r):n;return this._refinement((r,a)=>{const i=t(r),s=()=>a.addIssue({code:ye.custom,...o(r)});return typeof Promise<"u"&&i instanceof Promise?i.then(c=>c?!0:(s(),!1)):i?!0:(s(),!1)})}refinement(t,n){return this._refinement((o,r)=>t(o)?!0:(r.addIssue(typeof n=="function"?n(o,r):n),!1))}_refinement(t){return new Ju({schema:this,typeName:qe.ZodEffects,effect:{type:"refinement",refinement:t}})}superRefine(t){return this._refinement(t)}constructor(t){this.spa=this.safeParseAsync,this._def=t,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:n=>this["~validate"](n)}}optional(){return gi.create(this,this._def)}nullable(){return e0.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Hr.create(this)}promise(){return jj.create(this,this._def)}or(t){return Ej.create([this,t],this._def)}and(t){return $j.create(this,t,this._def)}transform(t){return new Ju({...Ze(this._def),schema:this,typeName:qe.ZodEffects,effect:{type:"transform",transform:t}})}default(t){const n=typeof t=="function"?t:()=>t;return new cH({...Ze(this._def),innerType:this,defaultValue:n,typeName:qe.ZodDefault})}brand(){return new VTe({typeName:qe.ZodBranded,type:this,...Ze(this._def)})}catch(t){const n=typeof t=="function"?t:()=>t;return new lH({...Ze(this._def),innerType:this,catchValue:n,typeName:qe.ZodCatch})}describe(t){const n=this.constructor;return new n({...this._def,description:t})}pipe(t){return hO.create(this,t)}readonly(){return dH.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const wTe=/^c[^\s-]{8,}$/i,MTe=/^[0-9a-z]+$/,bTe=/^[0-9A-HJKMNP-TV-Z]{26}$/i,_Te=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,CTe=/^[a-z0-9_-]{21}$/i,STe=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,LTe=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,ITe=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,NTe="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let aT;const ATe=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,ETe=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,$Te=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,PTe=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,jTe=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,zTe=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,mQ="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",RTe=new RegExp(`^${mQ}$`);function kQ(e){let t="[0-5]\\d";e.precision?t=`${t}\\.\\d{${e.precision}}`:e.precision==null&&(t=`${t}(\\.\\d+)?`);const n=e.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${t})${n}`}function TTe(e){return new RegExp(`^${kQ(e)}$`)}function DTe(e){let t=`${mQ}T${kQ(e)}`;const n=[];return n.push(e.local?"Z?":"Z"),e.offset&&n.push("([+-]\\d{2}:?\\d{2})"),t=`${t}(${n.join("|")})`,new RegExp(`^${t}$`)}function HTe(e,t){return!!((t==="v4"||!t)&&ATe.test(e)||(t==="v6"||!t)&&$Te.test(e))}function qTe(e,t){if(!STe.test(e))return!1;try{const[n]=e.split(".");if(!n)return!1;const o=n.replace(/-/g,"+").replace(/_/g,"/").padEnd(n.length+(4-n.length%4)%4,"="),r=JSON.parse(atob(o));return!(typeof r!="object"||r===null||"typ"in r&&(r==null?void 0:r.typ)!=="JWT"||!r.alg||t&&r.alg!==t)}catch{return!1}}function OTe(e,t){return!!((t==="v4"||!t)&&ETe.test(e)||(t==="v6"||!t)&&PTe.test(e))}class ka extends et{_parse(t){if(this._def.coerce&&(t.data=String(t.data)),this._getType(t)!==Se.string){const a=this._getOrReturnCtx(t);return Me(a,{code:ye.invalid_type,expected:Se.string,received:a.parsedType}),Fe}const o=new En;let r;for(const a of this._def.checks)if(a.kind==="min")t.data.length<a.value&&(r=this._getOrReturnCtx(t,r),Me(r,{code:ye.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),o.dirty());else if(a.kind==="max")t.data.length>a.value&&(r=this._getOrReturnCtx(t,r),Me(r,{code:ye.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),o.dirty());else if(a.kind==="length"){const i=t.data.length>a.value,s=t.data.length<a.value;(i||s)&&(r=this._getOrReturnCtx(t,r),i?Me(r,{code:ye.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}):s&&Me(r,{code:ye.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}),o.dirty())}else if(a.kind==="email")ITe.test(t.data)||(r=this._getOrReturnCtx(t,r),Me(r,{validation:"email",code:ye.invalid_string,message:a.message}),o.dirty());else if(a.kind==="emoji")aT||(aT=new RegExp(NTe,"u")),aT.test(t.data)||(r=this._getOrReturnCtx(t,r),Me(r,{validation:"emoji",code:ye.invalid_string,message:a.message}),o.dirty());else if(a.kind==="uuid")_Te.test(t.data)||(r=this._getOrReturnCtx(t,r),Me(r,{validation:"uuid",code:ye.invalid_string,message:a.message}),o.dirty());else if(a.kind==="nanoid")CTe.test(t.data)||(r=this._getOrReturnCtx(t,r),Me(r,{validation:"nanoid",code:ye.invalid_string,message:a.message}),o.dirty());else if(a.kind==="cuid")wTe.test(t.data)||(r=this._getOrReturnCtx(t,r),Me(r,{validation:"cuid",code:ye.invalid_string,message:a.message}),o.dirty());else if(a.kind==="cuid2")MTe.test(t.data)||(r=this._getOrReturnCtx(t,r),Me(r,{validation:"cuid2",code:ye.invalid_string,message:a.message}),o.dirty());else if(a.kind==="ulid")bTe.test(t.data)||(r=this._getOrReturnCtx(t,r),Me(r,{validation:"ulid",code:ye.invalid_string,message:a.message}),o.dirty());else if(a.kind==="url")try{new URL(t.data)}catch{r=this._getOrReturnCtx(t,r),Me(r,{validation:"url",code:ye.invalid_string,message:a.message}),o.dirty()}else a.kind==="regex"?(a.regex.lastIndex=0,a.regex.test(t.data)||(r=this._getOrReturnCtx(t,r),Me(r,{validation:"regex",code:ye.invalid_string,message:a.message}),o.dirty())):a.kind==="trim"?t.data=t.data.trim():a.kind==="includes"?t.data.includes(a.value,a.position)||(r=this._getOrReturnCtx(t,r),Me(r,{code:ye.invalid_string,validation:{includes:a.value,position:a.position},message:a.message}),o.dirty()):a.kind==="toLowerCase"?t.data=t.data.toLowerCase():a.kind==="toUpperCase"?t.data=t.data.toUpperCase():a.kind==="startsWith"?t.data.startsWith(a.value)||(r=this._getOrReturnCtx(t,r),Me(r,{code:ye.invalid_string,validation:{startsWith:a.value},message:a.message}),o.dirty()):a.kind==="endsWith"?t.data.endsWith(a.value)||(r=this._getOrReturnCtx(t,r),Me(r,{code:ye.invalid_string,validation:{endsWith:a.value},message:a.message}),o.dirty()):a.kind==="datetime"?DTe(a).test(t.data)||(r=this._getOrReturnCtx(t,r),Me(r,{code:ye.invalid_string,validation:"datetime",message:a.message}),o.dirty()):a.kind==="date"?RTe.test(t.data)||(r=this._getOrReturnCtx(t,r),Me(r,{code:ye.invalid_string,validation:"date",message:a.message}),o.dirty()):a.kind==="time"?TTe(a).test(t.data)||(r=this._getOrReturnCtx(t,r),Me(r,{code:ye.invalid_string,validation:"time",message:a.message}),o.dirty()):a.kind==="duration"?LTe.test(t.data)||(r=this._getOrReturnCtx(t,r),Me(r,{validation:"duration",code:ye.invalid_string,message:a.message}),o.dirty()):a.kind==="ip"?HTe(t.data,a.version)||(r=this._getOrReturnCtx(t,r),Me(r,{validation:"ip",code:ye.invalid_string,message:a.message}),o.dirty()):a.kind==="jwt"?qTe(t.data,a.alg)||(r=this._getOrReturnCtx(t,r),Me(r,{validation:"jwt",code:ye.invalid_string,message:a.message}),o.dirty()):a.kind==="cidr"?OTe(t.data,a.version)||(r=this._getOrReturnCtx(t,r),Me(r,{validation:"cidr",code:ye.invalid_string,message:a.message}),o.dirty()):a.kind==="base64"?jTe.test(t.data)||(r=this._getOrReturnCtx(t,r),Me(r,{validation:"base64",code:ye.invalid_string,message:a.message}),o.dirty()):a.kind==="base64url"?zTe.test(t.data)||(r=this._getOrReturnCtx(t,r),Me(r,{validation:"base64url",code:ye.invalid_string,message:a.message}),o.dirty()):at.assertNever(a);return{status:o.value,value:t.data}}_regex(t,n,o){return this.refinement(r=>t.test(r),{validation:n,code:ye.invalid_string,...Ne.errToObj(o)})}_addCheck(t){return new ka({...this._def,checks:[...this._def.checks,t]})}email(t){return this._addCheck({kind:"email",...Ne.errToObj(t)})}url(t){return this._addCheck({kind:"url",...Ne.errToObj(t)})}emoji(t){return this._addCheck({kind:"emoji",...Ne.errToObj(t)})}uuid(t){return this._addCheck({kind:"uuid",...Ne.errToObj(t)})}nanoid(t){return this._addCheck({kind:"nanoid",...Ne.errToObj(t)})}cuid(t){return this._addCheck({kind:"cuid",...Ne.errToObj(t)})}cuid2(t){return this._addCheck({kind:"cuid2",...Ne.errToObj(t)})}ulid(t){return this._addCheck({kind:"ulid",...Ne.errToObj(t)})}base64(t){return this._addCheck({kind:"base64",...Ne.errToObj(t)})}base64url(t){return this._addCheck({kind:"base64url",...Ne.errToObj(t)})}jwt(t){return this._addCheck({kind:"jwt",...Ne.errToObj(t)})}ip(t){return this._addCheck({kind:"ip",...Ne.errToObj(t)})}cidr(t){return this._addCheck({kind:"cidr",...Ne.errToObj(t)})}datetime(t){return typeof t=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:t}):this._addCheck({kind:"datetime",precision:typeof(t==null?void 0:t.precision)>"u"?null:t==null?void 0:t.precision,offset:(t==null?void 0:t.offset)??!1,local:(t==null?void 0:t.local)??!1,...Ne.errToObj(t==null?void 0:t.message)})}date(t){return this._addCheck({kind:"date",message:t})}time(t){return typeof t=="string"?this._addCheck({kind:"time",precision:null,message:t}):this._addCheck({kind:"time",precision:typeof(t==null?void 0:t.precision)>"u"?null:t==null?void 0:t.precision,...Ne.errToObj(t==null?void 0:t.message)})}duration(t){return this._addCheck({kind:"duration",...Ne.errToObj(t)})}regex(t,n){return this._addCheck({kind:"regex",regex:t,...Ne.errToObj(n)})}includes(t,n){return this._addCheck({kind:"includes",value:t,position:n==null?void 0:n.position,...Ne.errToObj(n==null?void 0:n.message)})}startsWith(t,n){return this._addCheck({kind:"startsWith",value:t,...Ne.errToObj(n)})}endsWith(t,n){return this._addCheck({kind:"endsWith",value:t,...Ne.errToObj(n)})}min(t,n){return this._addCheck({kind:"min",value:t,...Ne.errToObj(n)})}max(t,n){return this._addCheck({kind:"max",value:t,...Ne.errToObj(n)})}length(t,n){return this._addCheck({kind:"length",value:t,...Ne.errToObj(n)})}nonempty(t){return this.min(1,Ne.errToObj(t))}trim(){return new ka({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new ka({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new ka({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(t=>t.kind==="datetime")}get isDate(){return!!this._def.checks.find(t=>t.kind==="date")}get isTime(){return!!this._def.checks.find(t=>t.kind==="time")}get isDuration(){return!!this._def.checks.find(t=>t.kind==="duration")}get isEmail(){return!!this._def.checks.find(t=>t.kind==="email")}get isURL(){return!!this._def.checks.find(t=>t.kind==="url")}get isEmoji(){return!!this._def.checks.find(t=>t.kind==="emoji")}get isUUID(){return!!this._def.checks.find(t=>t.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(t=>t.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(t=>t.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(t=>t.kind==="cuid2")}get isULID(){return!!this._def.checks.find(t=>t.kind==="ulid")}get isIP(){return!!this._def.checks.find(t=>t.kind==="ip")}get isCIDR(){return!!this._def.checks.find(t=>t.kind==="cidr")}get isBase64(){return!!this._def.checks.find(t=>t.kind==="base64")}get isBase64url(){return!!this._def.checks.find(t=>t.kind==="base64url")}get minLength(){let t=null;for(const n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t}get maxLength(){let t=null;for(const n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t}}ka.create=e=>new ka({checks:[],typeName:qe.ZodString,coerce:(e==null?void 0:e.coerce)??!1,...Ze(e)});function FTe(e,t){const n=(e.toString().split(".")[1]||"").length,o=(t.toString().split(".")[1]||"").length,r=n>o?n:o,a=Number.parseInt(e.toFixed(r).replace(".","")),i=Number.parseInt(t.toFixed(r).replace(".",""));return a%i/10**r}class Yu extends et{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(t){if(this._def.coerce&&(t.data=Number(t.data)),this._getType(t)!==Se.number){const a=this._getOrReturnCtx(t);return Me(a,{code:ye.invalid_type,expected:Se.number,received:a.parsedType}),Fe}let o;const r=new En;for(const a of this._def.checks)a.kind==="int"?at.isInteger(t.data)||(o=this._getOrReturnCtx(t,o),Me(o,{code:ye.invalid_type,expected:"integer",received:"float",message:a.message}),r.dirty()):a.kind==="min"?(a.inclusive?t.data<a.value:t.data<=a.value)&&(o=this._getOrReturnCtx(t,o),Me(o,{code:ye.too_small,minimum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),r.dirty()):a.kind==="max"?(a.inclusive?t.data>a.value:t.data>=a.value)&&(o=this._getOrReturnCtx(t,o),Me(o,{code:ye.too_big,maximum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),r.dirty()):a.kind==="multipleOf"?FTe(t.data,a.value)!==0&&(o=this._getOrReturnCtx(t,o),Me(o,{code:ye.not_multiple_of,multipleOf:a.value,message:a.message}),r.dirty()):a.kind==="finite"?Number.isFinite(t.data)||(o=this._getOrReturnCtx(t,o),Me(o,{code:ye.not_finite,message:a.message}),r.dirty()):at.assertNever(a);return{status:r.value,value:t.data}}gte(t,n){return this.setLimit("min",t,!0,Ne.toString(n))}gt(t,n){return this.setLimit("min",t,!1,Ne.toString(n))}lte(t,n){return this.setLimit("max",t,!0,Ne.toString(n))}lt(t,n){return this.setLimit("max",t,!1,Ne.toString(n))}setLimit(t,n,o,r){return new Yu({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:o,message:Ne.toString(r)}]})}_addCheck(t){return new Yu({...this._def,checks:[...this._def.checks,t]})}int(t){return this._addCheck({kind:"int",message:Ne.toString(t)})}positive(t){return this._addCheck({kind:"min",value:0,inclusive:!1,message:Ne.toString(t)})}negative(t){return this._addCheck({kind:"max",value:0,inclusive:!1,message:Ne.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:0,inclusive:!0,message:Ne.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:0,inclusive:!0,message:Ne.toString(t)})}multipleOf(t,n){return this._addCheck({kind:"multipleOf",value:t,message:Ne.toString(n)})}finite(t){return this._addCheck({kind:"finite",message:Ne.toString(t)})}safe(t){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:Ne.toString(t)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:Ne.toString(t)})}get minValue(){let t=null;for(const n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t}get maxValue(){let t=null;for(const n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t}get isInt(){return!!this._def.checks.find(t=>t.kind==="int"||t.kind==="multipleOf"&&at.isInteger(t.value))}get isFinite(){let t=null,n=null;for(const o of this._def.checks){if(o.kind==="finite"||o.kind==="int"||o.kind==="multipleOf")return!0;o.kind==="min"?(n===null||o.value>n)&&(n=o.value):o.kind==="max"&&(t===null||o.value<t)&&(t=o.value)}return Number.isFinite(n)&&Number.isFinite(t)}}Yu.create=e=>new Yu({checks:[],typeName:qe.ZodNumber,coerce:(e==null?void 0:e.coerce)||!1,...Ze(e)});class Mh extends et{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(t){if(this._def.coerce)try{t.data=BigInt(t.data)}catch{return this._getInvalidInput(t)}if(this._getType(t)!==Se.bigint)return this._getInvalidInput(t);let o;const r=new En;for(const a of this._def.checks)a.kind==="min"?(a.inclusive?t.data<a.value:t.data<=a.value)&&(o=this._getOrReturnCtx(t,o),Me(o,{code:ye.too_small,type:"bigint",minimum:a.value,inclusive:a.inclusive,message:a.message}),r.dirty()):a.kind==="max"?(a.inclusive?t.data>a.value:t.data>=a.value)&&(o=this._getOrReturnCtx(t,o),Me(o,{code:ye.too_big,type:"bigint",maximum:a.value,inclusive:a.inclusive,message:a.message}),r.dirty()):a.kind==="multipleOf"?t.data%a.value!==BigInt(0)&&(o=this._getOrReturnCtx(t,o),Me(o,{code:ye.not_multiple_of,multipleOf:a.value,message:a.message}),r.dirty()):at.assertNever(a);return{status:r.value,value:t.data}}_getInvalidInput(t){const n=this._getOrReturnCtx(t);return Me(n,{code:ye.invalid_type,expected:Se.bigint,received:n.parsedType}),Fe}gte(t,n){return this.setLimit("min",t,!0,Ne.toString(n))}gt(t,n){return this.setLimit("min",t,!1,Ne.toString(n))}lte(t,n){return this.setLimit("max",t,!0,Ne.toString(n))}lt(t,n){return this.setLimit("max",t,!1,Ne.toString(n))}setLimit(t,n,o,r){return new Mh({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:o,message:Ne.toString(r)}]})}_addCheck(t){return new Mh({...this._def,checks:[...this._def.checks,t]})}positive(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:Ne.toString(t)})}negative(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:Ne.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:Ne.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:Ne.toString(t)})}multipleOf(t,n){return this._addCheck({kind:"multipleOf",value:t,message:Ne.toString(n)})}get minValue(){let t=null;for(const n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t}get maxValue(){let t=null;for(const n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t}}Mh.create=e=>new Mh({checks:[],typeName:qe.ZodBigInt,coerce:(e==null?void 0:e.coerce)??!1,...Ze(e)});class rH extends et{_parse(t){if(this._def.coerce&&(t.data=!!t.data),this._getType(t)!==Se.boolean){const o=this._getOrReturnCtx(t);return Me(o,{code:ye.invalid_type,expected:Se.boolean,received:o.parsedType}),Fe}return No(t.data)}}rH.create=e=>new rH({typeName:qe.ZodBoolean,coerce:(e==null?void 0:e.coerce)||!1,...Ze(e)});class Aj extends et{_parse(t){if(this._def.coerce&&(t.data=new Date(t.data)),this._getType(t)!==Se.date){const a=this._getOrReturnCtx(t);return Me(a,{code:ye.invalid_type,expected:Se.date,received:a.parsedType}),Fe}if(Number.isNaN(t.data.getTime())){const a=this._getOrReturnCtx(t);return Me(a,{code:ye.invalid_date}),Fe}const o=new En;let r;for(const a of this._def.checks)a.kind==="min"?t.data.getTime()<a.value&&(r=this._getOrReturnCtx(t,r),Me(r,{code:ye.too_small,message:a.message,inclusive:!0,exact:!1,minimum:a.value,type:"date"}),o.dirty()):a.kind==="max"?t.data.getTime()>a.value&&(r=this._getOrReturnCtx(t,r),Me(r,{code:ye.too_big,message:a.message,inclusive:!0,exact:!1,maximum:a.value,type:"date"}),o.dirty()):at.assertNever(a);return{status:o.value,value:new Date(t.data.getTime())}}_addCheck(t){return new Aj({...this._def,checks:[...this._def.checks,t]})}min(t,n){return this._addCheck({kind:"min",value:t.getTime(),message:Ne.toString(n)})}max(t,n){return this._addCheck({kind:"max",value:t.getTime(),message:Ne.toString(n)})}get minDate(){let t=null;for(const n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t!=null?new Date(t):null}get maxDate(){let t=null;for(const n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t!=null?new Date(t):null}}Aj.create=e=>new Aj({checks:[],coerce:(e==null?void 0:e.coerce)||!1,typeName:qe.ZodDate,...Ze(e)});class lU extends et{_parse(t){if(this._getType(t)!==Se.symbol){const o=this._getOrReturnCtx(t);return Me(o,{code:ye.invalid_type,expected:Se.symbol,received:o.parsedType}),Fe}return No(t.data)}}lU.create=e=>new lU({typeName:qe.ZodSymbol,...Ze(e)});class dU extends et{_parse(t){if(this._getType(t)!==Se.undefined){const o=this._getOrReturnCtx(t);return Me(o,{code:ye.invalid_type,expected:Se.undefined,received:o.parsedType}),Fe}return No(t.data)}}dU.create=e=>new dU({typeName:qe.ZodUndefined,...Ze(e)});class uU extends et{_parse(t){if(this._getType(t)!==Se.null){const o=this._getOrReturnCtx(t);return Me(o,{code:ye.invalid_type,expected:Se.null,received:o.parsedType}),Fe}return No(t.data)}}uU.create=e=>new uU({typeName:qe.ZodNull,...Ze(e)});class hU extends et{constructor(){super(...arguments),this._any=!0}_parse(t){return No(t.data)}}hU.create=e=>new hU({typeName:qe.ZodAny,...Ze(e)});class aH extends et{constructor(){super(...arguments),this._unknown=!0}_parse(t){return No(t.data)}}aH.create=e=>new aH({typeName:qe.ZodUnknown,...Ze(e)});class bi extends et{_parse(t){const n=this._getOrReturnCtx(t);return Me(n,{code:ye.invalid_type,expected:Se.never,received:n.parsedType}),Fe}}bi.create=e=>new bi({typeName:qe.ZodNever,...Ze(e)});class fU extends et{_parse(t){if(this._getType(t)!==Se.undefined){const o=this._getOrReturnCtx(t);return Me(o,{code:ye.invalid_type,expected:Se.void,received:o.parsedType}),Fe}return No(t.data)}}fU.create=e=>new fU({typeName:qe.ZodVoid,...Ze(e)});class Hr extends et{_parse(t){const{ctx:n,status:o}=this._processInputParams(t),r=this._def;if(n.parsedType!==Se.array)return Me(n,{code:ye.invalid_type,expected:Se.array,received:n.parsedType}),Fe;if(r.exactLength!==null){const i=n.data.length>r.exactLength.value,s=n.data.length<r.exactLength.value;(i||s)&&(Me(n,{code:i?ye.too_big:ye.too_small,minimum:s?r.exactLength.value:void 0,maximum:i?r.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:r.exactLength.message}),o.dirty())}if(r.minLength!==null&&n.data.length<r.minLength.value&&(Me(n,{code:ye.too_small,minimum:r.minLength.value,type:"array",inclusive:!0,exact:!1,message:r.minLength.message}),o.dirty()),r.maxLength!==null&&n.data.length>r.maxLength.value&&(Me(n,{code:ye.too_big,maximum:r.maxLength.value,type:"array",inclusive:!0,exact:!1,message:r.maxLength.message}),o.dirty()),n.common.async)return Promise.all([...n.data].map((i,s)=>r.type._parseAsync(new Fr(n,i,n.path,s)))).then(i=>En.mergeArray(o,i));const a=[...n.data].map((i,s)=>r.type._parseSync(new Fr(n,i,n.path,s)));return En.mergeArray(o,a)}get element(){return this._def.type}min(t,n){return new Hr({...this._def,minLength:{value:t,message:Ne.toString(n)}})}max(t,n){return new Hr({...this._def,maxLength:{value:t,message:Ne.toString(n)}})}length(t,n){return new Hr({...this._def,exactLength:{value:t,message:Ne.toString(n)}})}nonempty(t){return this.min(1,t)}}Hr.create=(e,t)=>new Hr({type:e,minLength:null,maxLength:null,exactLength:null,typeName:qe.ZodArray,...Ze(t)});function Kd(e){if(e instanceof Wt){const t={};for(const n in e.shape){const o=e.shape[n];t[n]=gi.create(Kd(o))}return new Wt({...e._def,shape:()=>t})}else return e instanceof Hr?new Hr({...e._def,type:Kd(e.element)}):e instanceof gi?gi.create(Kd(e.unwrap())):e instanceof e0?e0.create(Kd(e.unwrap())):e instanceof kd?kd.create(e.items.map(t=>Kd(t))):e}class Wt extends et{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const t=this._def.shape(),n=at.objectKeys(t);return this._cached={shape:t,keys:n},this._cached}_parse(t){if(this._getType(t)!==Se.object){const l=this._getOrReturnCtx(t);return Me(l,{code:ye.invalid_type,expected:Se.object,received:l.parsedType}),Fe}const{status:o,ctx:r}=this._processInputParams(t),{shape:a,keys:i}=this._getCached(),s=[];if(!(this._def.catchall instanceof bi&&this._def.unknownKeys==="strip"))for(const l in r.data)i.includes(l)||s.push(l);const c=[];for(const l of i){const h=a[l],u=r.data[l];c.push({key:{status:"valid",value:l},value:h._parse(new Fr(r,u,r.path,l)),alwaysSet:l in r.data})}if(this._def.catchall instanceof bi){const l=this._def.unknownKeys;if(l==="passthrough")for(const h of s)c.push({key:{status:"valid",value:h},value:{status:"valid",value:r.data[h]}});else if(l==="strict")s.length>0&&(Me(r,{code:ye.unrecognized_keys,keys:s}),o.dirty());else if(l!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const l=this._def.catchall;for(const h of s){const u=r.data[h];c.push({key:{status:"valid",value:h},value:l._parse(new Fr(r,u,r.path,h)),alwaysSet:h in r.data})}}return r.common.async?Promise.resolve().then(async()=>{const l=[];for(const h of c){const u=await h.key,f=await h.value;l.push({key:u,value:f,alwaysSet:h.alwaysSet})}return l}).then(l=>En.mergeObjectSync(o,l)):En.mergeObjectSync(o,c)}get shape(){return this._def.shape()}strict(t){return Ne.errToObj,new Wt({...this._def,unknownKeys:"strict",...t!==void 0?{errorMap:(n,o)=>{var a,i;const r=((i=(a=this._def).errorMap)==null?void 0:i.call(a,n,o).message)??o.defaultError;return n.code==="unrecognized_keys"?{message:Ne.errToObj(t).message??r}:{message:r}}}:{}})}strip(){return new Wt({...this._def,unknownKeys:"strip"})}passthrough(){return new Wt({...this._def,unknownKeys:"passthrough"})}extend(t){return new Wt({...this._def,shape:()=>({...this._def.shape(),...t})})}merge(t){return new Wt({unknownKeys:t._def.unknownKeys,catchall:t._def.catchall,shape:()=>({...this._def.shape(),...t._def.shape()}),typeName:qe.ZodObject})}setKey(t,n){return this.augment({[t]:n})}catchall(t){return new Wt({...this._def,catchall:t})}pick(t){const n={};for(const o of at.objectKeys(t))t[o]&&this.shape[o]&&(n[o]=this.shape[o]);return new Wt({...this._def,shape:()=>n})}omit(t){const n={};for(const o of at.objectKeys(this.shape))t[o]||(n[o]=this.shape[o]);return new Wt({...this._def,shape:()=>n})}deepPartial(){return Kd(this)}partial(t){const n={};for(const o of at.objectKeys(this.shape)){const r=this.shape[o];t&&!t[o]?n[o]=r:n[o]=r.optional()}return new Wt({...this._def,shape:()=>n})}required(t){const n={};for(const o of at.objectKeys(this.shape))if(t&&!t[o])n[o]=this.shape[o];else{let a=this.shape[o];for(;a instanceof gi;)a=a._def.innerType;n[o]=a}return new Wt({...this._def,shape:()=>n})}keyof(){return gQ(at.objectKeys(this.shape))}}Wt.create=(e,t)=>new Wt({shape:()=>e,unknownKeys:"strip",catchall:bi.create(),typeName:qe.ZodObject,...Ze(t)});Wt.strictCreate=(e,t)=>new Wt({shape:()=>e,unknownKeys:"strict",catchall:bi.create(),typeName:qe.ZodObject,...Ze(t)});Wt.lazycreate=(e,t)=>new Wt({shape:e,unknownKeys:"strip",catchall:bi.create(),typeName:qe.ZodObject,...Ze(t)});class Ej extends et{_parse(t){const{ctx:n}=this._processInputParams(t),o=this._def.options;function r(a){for(const s of a)if(s.result.status==="valid")return s.result;for(const s of a)if(s.result.status==="dirty")return n.common.issues.push(...s.ctx.common.issues),s.result;const i=a.map(s=>new _a(s.ctx.common.issues));return Me(n,{code:ye.invalid_union,unionErrors:i}),Fe}if(n.common.async)return Promise.all(o.map(async a=>{const i={...n,common:{...n.common,issues:[]},parent:null};return{result:await a._parseAsync({data:n.data,path:n.path,parent:i}),ctx:i}})).then(r);{let a;const i=[];for(const c of o){const l={...n,common:{...n.common,issues:[]},parent:null},h=c._parseSync({data:n.data,path:n.path,parent:l});if(h.status==="valid")return h;h.status==="dirty"&&!a&&(a={result:h,ctx:l}),l.common.issues.length&&i.push(l.common.issues)}if(a)return n.common.issues.push(...a.ctx.common.issues),a.result;const s=i.map(c=>new _a(c));return Me(n,{code:ye.invalid_union,unionErrors:s}),Fe}}get options(){return this._def.options}}Ej.create=(e,t)=>new Ej({options:e,typeName:qe.ZodUnion,...Ze(t)});function iH(e,t){const n=ni(e),o=ni(t);if(e===t)return{valid:!0,data:e};if(n===Se.object&&o===Se.object){const r=at.objectKeys(t),a=at.objectKeys(e).filter(s=>r.indexOf(s)!==-1),i={...e,...t};for(const s of a){const c=iH(e[s],t[s]);if(!c.valid)return{valid:!1};i[s]=c.data}return{valid:!0,data:i}}else if(n===Se.array&&o===Se.array){if(e.length!==t.length)return{valid:!1};const r=[];for(let a=0;a<e.length;a++){const i=e[a],s=t[a],c=iH(i,s);if(!c.valid)return{valid:!1};r.push(c.data)}return{valid:!0,data:r}}else return n===Se.date&&o===Se.date&&+e==+t?{valid:!0,data:e}:{valid:!1}}class $j extends et{_parse(t){const{status:n,ctx:o}=this._processInputParams(t),r=(a,i)=>{if(iU(a)||iU(i))return Fe;const s=iH(a.value,i.value);return s.valid?((sU(a)||sU(i))&&n.dirty(),{status:n.value,value:s.data}):(Me(o,{code:ye.invalid_intersection_types}),Fe)};return o.common.async?Promise.all([this._def.left._parseAsync({data:o.data,path:o.path,parent:o}),this._def.right._parseAsync({data:o.data,path:o.path,parent:o})]).then(([a,i])=>r(a,i)):r(this._def.left._parseSync({data:o.data,path:o.path,parent:o}),this._def.right._parseSync({data:o.data,path:o.path,parent:o}))}}$j.create=(e,t,n)=>new $j({left:e,right:t,typeName:qe.ZodIntersection,...Ze(n)});class kd extends et{_parse(t){const{status:n,ctx:o}=this._processInputParams(t);if(o.parsedType!==Se.array)return Me(o,{code:ye.invalid_type,expected:Se.array,received:o.parsedType}),Fe;if(o.data.length<this._def.items.length)return Me(o,{code:ye.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),Fe;!this._def.rest&&o.data.length>this._def.items.length&&(Me(o,{code:ye.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),n.dirty());const a=[...o.data].map((i,s)=>{const c=this._def.items[s]||this._def.rest;return c?c._parse(new Fr(o,i,o.path,s)):null}).filter(i=>!!i);return o.common.async?Promise.all(a).then(i=>En.mergeArray(n,i)):En.mergeArray(n,a)}get items(){return this._def.items}rest(t){return new kd({...this._def,rest:t})}}kd.create=(e,t)=>{if(!Array.isArray(e))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new kd({items:e,typeName:qe.ZodTuple,rest:null,...Ze(t)})};class Pj extends et{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){const{status:n,ctx:o}=this._processInputParams(t);if(o.parsedType!==Se.object)return Me(o,{code:ye.invalid_type,expected:Se.object,received:o.parsedType}),Fe;const r=[],a=this._def.keyType,i=this._def.valueType;for(const s in o.data)r.push({key:a._parse(new Fr(o,s,o.path,s)),value:i._parse(new Fr(o,o.data[s],o.path,s)),alwaysSet:s in o.data});return o.common.async?En.mergeObjectAsync(n,r):En.mergeObjectSync(n,r)}get element(){return this._def.valueType}static create(t,n,o){return n instanceof et?new Pj({keyType:t,valueType:n,typeName:qe.ZodRecord,...Ze(o)}):new Pj({keyType:ka.create(),valueType:t,typeName:qe.ZodRecord,...Ze(n)})}}class pU extends et{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){const{status:n,ctx:o}=this._processInputParams(t);if(o.parsedType!==Se.map)return Me(o,{code:ye.invalid_type,expected:Se.map,received:o.parsedType}),Fe;const r=this._def.keyType,a=this._def.valueType,i=[...o.data.entries()].map(([s,c],l)=>({key:r._parse(new Fr(o,s,o.path,[l,"key"])),value:a._parse(new Fr(o,c,o.path,[l,"value"]))}));if(o.common.async){const s=new Map;return Promise.resolve().then(async()=>{for(const c of i){const l=await c.key,h=await c.value;if(l.status==="aborted"||h.status==="aborted")return Fe;(l.status==="dirty"||h.status==="dirty")&&n.dirty(),s.set(l.value,h.value)}return{status:n.value,value:s}})}else{const s=new Map;for(const c of i){const l=c.key,h=c.value;if(l.status==="aborted"||h.status==="aborted")return Fe;(l.status==="dirty"||h.status==="dirty")&&n.dirty(),s.set(l.value,h.value)}return{status:n.value,value:s}}}}pU.create=(e,t,n)=>new pU({valueType:t,keyType:e,typeName:qe.ZodMap,...Ze(n)});class bh extends et{_parse(t){const{status:n,ctx:o}=this._processInputParams(t);if(o.parsedType!==Se.set)return Me(o,{code:ye.invalid_type,expected:Se.set,received:o.parsedType}),Fe;const r=this._def;r.minSize!==null&&o.data.size<r.minSize.value&&(Me(o,{code:ye.too_small,minimum:r.minSize.value,type:"set",inclusive:!0,exact:!1,message:r.minSize.message}),n.dirty()),r.maxSize!==null&&o.data.size>r.maxSize.value&&(Me(o,{code:ye.too_big,maximum:r.maxSize.value,type:"set",inclusive:!0,exact:!1,message:r.maxSize.message}),n.dirty());const a=this._def.valueType;function i(c){const l=new Set;for(const h of c){if(h.status==="aborted")return Fe;h.status==="dirty"&&n.dirty(),l.add(h.value)}return{status:n.value,value:l}}const s=[...o.data.values()].map((c,l)=>a._parse(new Fr(o,c,o.path,l)));return o.common.async?Promise.all(s).then(c=>i(c)):i(s)}min(t,n){return new bh({...this._def,minSize:{value:t,message:Ne.toString(n)}})}max(t,n){return new bh({...this._def,maxSize:{value:t,message:Ne.toString(n)}})}size(t,n){return this.min(t,n).max(t,n)}nonempty(t){return this.min(1,t)}}bh.create=(e,t)=>new bh({valueType:e,minSize:null,maxSize:null,typeName:qe.ZodSet,...Ze(t)});class yU extends et{get schema(){return this._def.getter()}_parse(t){const{ctx:n}=this._processInputParams(t);return this._def.getter()._parse({data:n.data,path:n.path,parent:n})}}yU.create=(e,t)=>new yU({getter:e,typeName:qe.ZodLazy,...Ze(t)});class sH extends et{_parse(t){if(t.data!==this._def.value){const n=this._getOrReturnCtx(t);return Me(n,{received:n.data,code:ye.invalid_literal,expected:this._def.value}),Fe}return{status:"valid",value:t.data}}get value(){return this._def.value}}sH.create=(e,t)=>new sH({value:e,typeName:qe.ZodLiteral,...Ze(t)});function gQ(e,t){return new Qu({values:e,typeName:qe.ZodEnum,...Ze(t)})}class Qu extends et{_parse(t){if(typeof t.data!="string"){const n=this._getOrReturnCtx(t),o=this._def.values;return Me(n,{expected:at.joinValues(o),received:n.parsedType,code:ye.invalid_type}),Fe}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(t.data)){const n=this._getOrReturnCtx(t),o=this._def.values;return Me(n,{received:n.data,code:ye.invalid_enum_value,options:o}),Fe}return No(t.data)}get options(){return this._def.values}get enum(){const t={};for(const n of this._def.values)t[n]=n;return t}get Values(){const t={};for(const n of this._def.values)t[n]=n;return t}get Enum(){const t={};for(const n of this._def.values)t[n]=n;return t}extract(t,n=this._def){return Qu.create(t,{...this._def,...n})}exclude(t,n=this._def){return Qu.create(this.options.filter(o=>!t.includes(o)),{...this._def,...n})}}Qu.create=gQ;class mU extends et{_parse(t){const n=at.getValidEnumValues(this._def.values),o=this._getOrReturnCtx(t);if(o.parsedType!==Se.string&&o.parsedType!==Se.number){const r=at.objectValues(n);return Me(o,{expected:at.joinValues(r),received:o.parsedType,code:ye.invalid_type}),Fe}if(this._cache||(this._cache=new Set(at.getValidEnumValues(this._def.values))),!this._cache.has(t.data)){const r=at.objectValues(n);return Me(o,{received:o.data,code:ye.invalid_enum_value,options:r}),Fe}return No(t.data)}get enum(){return this._def.values}}mU.create=(e,t)=>new mU({values:e,typeName:qe.ZodNativeEnum,...Ze(t)});class jj extends et{unwrap(){return this._def.type}_parse(t){const{ctx:n}=this._processInputParams(t);if(n.parsedType!==Se.promise&&n.common.async===!1)return Me(n,{code:ye.invalid_type,expected:Se.promise,received:n.parsedType}),Fe;const o=n.parsedType===Se.promise?n.data:Promise.resolve(n.data);return No(o.then(r=>this._def.type.parseAsync(r,{path:n.path,errorMap:n.common.contextualErrorMap})))}}jj.create=(e,t)=>new jj({type:e,typeName:qe.ZodPromise,...Ze(t)});class Ju extends et{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===qe.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(t){const{status:n,ctx:o}=this._processInputParams(t),r=this._def.effect||null,a={addIssue:i=>{Me(o,i),i.fatal?n.abort():n.dirty()},get path(){return o.path}};if(a.addIssue=a.addIssue.bind(a),r.type==="preprocess"){const i=r.transform(o.data,a);if(o.common.async)return Promise.resolve(i).then(async s=>{if(n.value==="aborted")return Fe;const c=await this._def.schema._parseAsync({data:s,path:o.path,parent:o});return c.status==="aborted"?Fe:c.status==="dirty"||n.value==="dirty"?o2(c.value):c});{if(n.value==="aborted")return Fe;const s=this._def.schema._parseSync({data:i,path:o.path,parent:o});return s.status==="aborted"?Fe:s.status==="dirty"||n.value==="dirty"?o2(s.value):s}}if(r.type==="refinement"){const i=s=>{const c=r.refinement(s,a);if(o.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return s};if(o.common.async===!1){const s=this._def.schema._parseSync({data:o.data,path:o.path,parent:o});return s.status==="aborted"?Fe:(s.status==="dirty"&&n.dirty(),i(s.value),{status:n.value,value:s.value})}else return this._def.schema._parseAsync({data:o.data,path:o.path,parent:o}).then(s=>s.status==="aborted"?Fe:(s.status==="dirty"&&n.dirty(),i(s.value).then(()=>({status:n.value,value:s.value}))))}if(r.type==="transform")if(o.common.async===!1){const i=this._def.schema._parseSync({data:o.data,path:o.path,parent:o});if(!Xu(i))return Fe;const s=r.transform(i.value,a);if(s instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:n.value,value:s}}else return this._def.schema._parseAsync({data:o.data,path:o.path,parent:o}).then(i=>Xu(i)?Promise.resolve(r.transform(i.value,a)).then(s=>({status:n.value,value:s})):Fe);at.assertNever(r)}}Ju.create=(e,t,n)=>new Ju({schema:e,typeName:qe.ZodEffects,effect:t,...Ze(n)});Ju.createWithPreprocess=(e,t,n)=>new Ju({schema:t,effect:{type:"preprocess",transform:e},typeName:qe.ZodEffects,...Ze(n)});class gi extends et{_parse(t){return this._getType(t)===Se.undefined?No(void 0):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}}gi.create=(e,t)=>new gi({innerType:e,typeName:qe.ZodOptional,...Ze(t)});class e0 extends et{_parse(t){return this._getType(t)===Se.null?No(null):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}}e0.create=(e,t)=>new e0({innerType:e,typeName:qe.ZodNullable,...Ze(t)});class cH extends et{_parse(t){const{ctx:n}=this._processInputParams(t);let o=n.data;return n.parsedType===Se.undefined&&(o=this._def.defaultValue()),this._def.innerType._parse({data:o,path:n.path,parent:n})}removeDefault(){return this._def.innerType}}cH.create=(e,t)=>new cH({innerType:e,typeName:qe.ZodDefault,defaultValue:typeof t.default=="function"?t.default:()=>t.default,...Ze(t)});class lH extends et{_parse(t){const{ctx:n}=this._processInputParams(t),o={...n,common:{...n.common,issues:[]}},r=this._def.innerType._parse({data:o.data,path:o.path,parent:{...o}});return Nj(r)?r.then(a=>({status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new _a(o.common.issues)},input:o.data})})):{status:"valid",value:r.status==="valid"?r.value:this._def.catchValue({get error(){return new _a(o.common.issues)},input:o.data})}}removeCatch(){return this._def.innerType}}lH.create=(e,t)=>new lH({innerType:e,typeName:qe.ZodCatch,catchValue:typeof t.catch=="function"?t.catch:()=>t.catch,...Ze(t)});class kU extends et{_parse(t){if(this._getType(t)!==Se.nan){const o=this._getOrReturnCtx(t);return Me(o,{code:ye.invalid_type,expected:Se.nan,received:o.parsedType}),Fe}return{status:"valid",value:t.data}}}kU.create=e=>new kU({typeName:qe.ZodNaN,...Ze(e)});class VTe extends et{_parse(t){const{ctx:n}=this._processInputParams(t),o=n.data;return this._def.type._parse({data:o,path:n.path,parent:n})}unwrap(){return this._def.type}}class hO extends et{_parse(t){const{status:n,ctx:o}=this._processInputParams(t);if(o.common.async)return(async()=>{const a=await this._def.in._parseAsync({data:o.data,path:o.path,parent:o});return a.status==="aborted"?Fe:a.status==="dirty"?(n.dirty(),o2(a.value)):this._def.out._parseAsync({data:a.value,path:o.path,parent:o})})();{const r=this._def.in._parseSync({data:o.data,path:o.path,parent:o});return r.status==="aborted"?Fe:r.status==="dirty"?(n.dirty(),{status:"dirty",value:r.value}):this._def.out._parseSync({data:r.value,path:o.path,parent:o})}}static create(t,n){return new hO({in:t,out:n,typeName:qe.ZodPipeline})}}class dH extends et{_parse(t){const n=this._def.innerType._parse(t),o=r=>(Xu(r)&&(r.value=Object.freeze(r.value)),r);return Nj(n)?n.then(r=>o(r)):o(n)}unwrap(){return this._def.innerType}}dH.create=(e,t)=>new dH({innerType:e,typeName:qe.ZodReadonly,...Ze(t)});var qe;(function(e){e.ZodString="ZodString",e.ZodNumber="ZodNumber",e.ZodNaN="ZodNaN",e.ZodBigInt="ZodBigInt",e.ZodBoolean="ZodBoolean",e.ZodDate="ZodDate",e.ZodSymbol="ZodSymbol",e.ZodUndefined="ZodUndefined",e.ZodNull="ZodNull",e.ZodAny="ZodAny",e.ZodUnknown="ZodUnknown",e.ZodNever="ZodNever",e.ZodVoid="ZodVoid",e.ZodArray="ZodArray",e.ZodObject="ZodObject",e.ZodUnion="ZodUnion",e.ZodDiscriminatedUnion="ZodDiscriminatedUnion",e.ZodIntersection="ZodIntersection",e.ZodTuple="ZodTuple",e.ZodRecord="ZodRecord",e.ZodMap="ZodMap",e.ZodSet="ZodSet",e.ZodFunction="ZodFunction",e.ZodLazy="ZodLazy",e.ZodLiteral="ZodLiteral",e.ZodEnum="ZodEnum",e.ZodEffects="ZodEffects",e.ZodNativeEnum="ZodNativeEnum",e.ZodOptional="ZodOptional",e.ZodNullable="ZodNullable",e.ZodDefault="ZodDefault",e.ZodCatch="ZodCatch",e.ZodPromise="ZodPromise",e.ZodBranded="ZodBranded",e.ZodPipeline="ZodPipeline",e.ZodReadonly="ZodReadonly"})(qe||(qe={}));const dn=ka.create,vQ=Yu.create,BTe=rH.create,O2=aH.create;bi.create;const qi=Hr.create,rt=Wt.create,uH=Ej.create;$j.create;kd.create;const gU=Pj.create,Xf=sH.create,Yf=Qu.create;jj.create;gi.create;e0.create;const UTe=rt({$state:dn().min(1)}),da=rt({$action:dn().min(1)}),WTe=rt({$cond:O2(),$then:O2(),$else:O2().optional()}),Fo=e=>uH([e,UTe,da,WTe]),Dt=Fo(dn()),ia=Fo(vQ()),Qf=Fo(BTe()),xQ={Card:rt({title:Dt.optional()}),Separator:rt({orientation:Fo(Yf(["horizontal","vertical"])).optional()}),Tabs:rt({value:Dt.optional(),items:qi(rt({id:dn(),label:dn()})),onChange:da.optional()}),Accordion:rt({items:qi(rt({id:dn(),title:dn(),content:dn()}))}),Badge:rt({label:Dt,variant:Fo(Yf(["default","secondary","destructive","outline"])).optional()}),Avatar:rt({src:Dt.optional(),alt:Dt.optional(),fallback:Dt.optional()}),Progress:rt({value:ia}),Skeleton:rt({width:ia.optional(),height:ia.optional()}),Label:rt({text:Dt}),Heading:rt({level:Fo(uH([Xf(1),Xf(2),Xf(3),Xf(4)])).optional(),text:Dt}),Text:rt({text:Dt,muted:Qf.optional()}),Icon:rt({name:Dt,size:ia.optional()}),Chart:rt({kind:Fo(Yf(["bar","line","area","pie"])),data:Fo(qi(gU(dn(),O2()))),xKey:Dt.optional(),series:qi(rt({key:dn(),label:dn().optional()})).optional()}),Table:rt({columns:qi(rt({key:dn(),label:dn()})),rows:Fo(qi(gU(dn(),O2())))}),Metric:rt({label:Dt,value:Fo(uH([dn(),vQ()]))}),CodeBlock:rt({code:Dt,language:Dt.optional()}),Markdown:rt({content:Dt}),Button:rt({label:Dt,variant:Fo(Yf(["default","destructive","outline","secondary","ghost","link"])).optional(),onClick:da.optional(),disabled:Qf.optional()}),Input:rt({value:Dt.optional(),placeholder:Dt.optional(),onChange:da.optional()}),Checkbox:rt({checked:Qf.optional(),onChange:da.optional(),label:Dt.optional()}),Switch:rt({checked:Qf.optional(),onChange:da.optional()}),Select:rt({value:Dt.optional(),items:qi(rt({value:dn(),label:dn()})),onChange:da.optional()}),Textarea:rt({value:Dt.optional(),placeholder:Dt.optional(),rows:ia.optional(),onChange:da.optional()}),Slider:rt({value:ia.optional(),min:ia.optional(),max:ia.optional(),step:ia.optional(),onChange:da.optional()})},wQ=Object.keys(xQ);Object.fromEntries(wQ.map(e=>[e,{props:xQ[e],description:e}]));function vU(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function Vr(...e){return t=>{let n=!1;const o=e.map(r=>{const a=vU(r,t);return!n&&typeof a=="function"&&(n=!0),a});if(n)return()=>{for(let r=0;r<o.length;r++){const a=o[r];typeof a=="function"?a():vU(e[r],null)}}}}function kt(...e){return m.useCallback(Vr(...e),e)}var GTe=Symbol.for("react.lazy"),zj=eq[" use ".trim().toString()];function ZTe(e){return typeof e=="object"&&e!==null&&"then"in e}function MQ(e){return e!=null&&typeof e=="object"&&"$$typeof"in e&&e.$$typeof===GTe&&"_payload"in e&&ZTe(e._payload)}function KTe(e){const t=YTe(e),n=m.forwardRef((o,r)=>{let{children:a,...i}=o;MQ(a)&&typeof zj=="function"&&(a=zj(a._payload));const s=m.Children.toArray(a),c=s.find(JTe);if(c){const l=c.props.children,h=s.map(u=>u===c?m.Children.count(l)>1?m.Children.only(null):m.isValidElement(l)?l.props.children:null:u);return p.jsx(t,{...i,ref:r,children:m.isValidElement(l)?m.cloneElement(l,void 0,h):null})}return p.jsx(t,{...i,ref:r,children:a})});return n.displayName=`${e}.Slot`,n}var XTe=KTe("Slot");function YTe(e){const t=m.forwardRef((n,o)=>{let{children:r,...a}=n;if(MQ(r)&&typeof zj=="function"&&(r=zj(r._payload)),m.isValidElement(r)){const i=tDe(r),s=eDe(a,r.props);return r.type!==m.Fragment&&(s.ref=o?Vr(o,i):i),m.cloneElement(r,s)}return m.Children.count(r)>1?m.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var QTe=Symbol("radix.slottable");function JTe(e){return m.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===QTe}function eDe(e,t){const n={...t};for(const o in t){const r=e[o],a=t[o];/^on[A-Z]/.test(o)?r&&a?n[o]=(...s)=>{const c=a(...s);return r(...s),c}:r&&(n[o]=r):o==="style"?n[o]={...r,...a}:o==="className"&&(n[o]=[r,a].filter(Boolean).join(" "))}return{...e,...n}}function tDe(e){var o,r;let t=(o=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:o.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(r=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}const xU=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,wU=fX,bQ=(e,t)=>n=>{var o;if((t==null?void 0:t.variants)==null)return wU(e,n==null?void 0:n.class,n==null?void 0:n.className);const{variants:r,defaultVariants:a}=t,i=Object.keys(r).map(l=>{const h=n==null?void 0:n[l],u=a==null?void 0:a[l];if(h===null)return null;const f=xU(h)||xU(u);return r[l][f]}),s=n&&Object.entries(n).reduce((l,h)=>{let[u,f]=h;return f===void 0||(l[u]=f),l},{}),c=t==null||(o=t.compoundVariants)===null||o===void 0?void 0:o.reduce((l,h)=>{let{class:u,className:f,...y}=h;return Object.entries(y).every(k=>{let[x,w]=k;return Array.isArray(w)?w.includes({...a,...s}[x]):{...a,...s}[x]===w})?[...l,u,f]:l},[]);return wU(e,i,c,n==null?void 0:n.class,n==null?void 0:n.className)},nDe=bQ("sf:inline-flex sf:items-center sf:justify-center sf:whitespace-nowrap sf:rounded-md sf:text-sm sf:font-medium sf:ring-offset-background sf:transition-colors sf:focus-visible:outline-hidden sf:focus-visible:ring-2 sf:focus-visible:ring-ring sf:focus-visible:ring-offset-2 sf:disabled:pointer-events-none sf:disabled:opacity-50",{variants:{variant:{default:"sf:bg-primary sf:text-primary-foreground sf:font-semibold sf:hover:bg-emerald-400",destructive:"sf:bg-destructive sf:text-destructive-foreground sf:hover:bg-destructive/90",outline:"sf:border sf:border-input sf:bg-background sf:hover:bg-secondary sf:hover:text-foreground",secondary:"sf:bg-secondary sf:text-secondary-foreground sf:hover:bg-secondary/80",ghost:"sf:text-muted-foreground sf:hover:bg-muted sf:hover:text-foreground",link:"sf:text-primary sf:underline-offset-4 sf:hover:underline"},size:{default:"sf:h-9 sf:px-4 sf:py-2",sm:"sf:h-8 sf:rounded-md sf:px-3",lg:"sf:h-11 sf:rounded-md sf:px-8",icon:"sf:h-9 sf:w-9"}},defaultVariants:{variant:"default",size:"default"}}),qt=m.forwardRef(({className:e,variant:t,size:n,asChild:o=!1,...r},a)=>{const i=o?XTe:"button";return p.jsx(i,{className:ae(nDe({variant:t,size:n,className:e})),ref:a,...r})});qt.displayName="Button";function _Q(e,[t,n]){return Math.min(n,Math.max(t,e))}function Le(e,t,{checkForDefaultPrevented:n=!0}={}){return function(r){if(e==null||e(r),n===!1||!r.defaultPrevented)return t==null?void 0:t(r)}}function oDe(e,t){const n=m.createContext(t),o=a=>{const{children:i,...s}=a,c=m.useMemo(()=>s,Object.values(s));return p.jsx(n.Provider,{value:c,children:i})};o.displayName=e+"Provider";function r(a){const i=m.useContext(n);if(i)return i;if(t!==void 0)return t;throw new Error(`\`${a}\` must be used within \`${e}\``)}return[o,r]}function nr(e,t=[]){let n=[];function o(a,i){const s=m.createContext(i),c=n.length;n=[...n,i];const l=u=>{var g;const{scope:f,children:y,...k}=u,x=((g=f==null?void 0:f[e])==null?void 0:g[c])||s,w=m.useMemo(()=>k,Object.values(k));return p.jsx(x.Provider,{value:w,children:y})};l.displayName=a+"Provider";function h(u,f){var x;const y=((x=f==null?void 0:f[e])==null?void 0:x[c])||s,k=m.useContext(y);if(k)return k;if(i!==void 0)return i;throw new Error(`\`${u}\` must be used within \`${a}\``)}return[l,h]}const r=()=>{const a=n.map(i=>m.createContext(i));return function(s){const c=(s==null?void 0:s[e])||a;return m.useMemo(()=>({[`__scope${e}`]:{...s,[e]:c}}),[s,c])}};return r.scopeName=e,[o,rDe(r,...t)]}function rDe(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const o=e.map(r=>({useScope:r(),scopeName:r.scopeName}));return function(a){const i=o.reduce((s,{useScope:c,scopeName:l})=>{const u=c(a)[`__scope${l}`];return{...s,...u}},{});return m.useMemo(()=>({[`__scope${t.scopeName}`]:i}),[i])}};return n.scopeName=t.scopeName,n}var _i=globalThis!=null&&globalThis.document?m.useLayoutEffect:()=>{},aDe=eq[" useInsertionEffect ".trim().toString()]||_i;function Cd({prop:e,defaultProp:t,onChange:n=()=>{},caller:o}){const[r,a,i]=iDe({defaultProp:t,onChange:n}),s=e!==void 0,c=s?e:r;{const h=m.useRef(e!==void 0);m.useEffect(()=>{const u=h.current;u!==s&&console.warn(`${o} is changing from ${u?"controlled":"uncontrolled"} to ${s?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),h.current=s},[s,o])}const l=m.useCallback(h=>{var u;if(s){const f=sDe(h)?h(e):h;f!==e&&((u=i.current)==null||u.call(i,f))}else a(h)},[s,e,a,i]);return[c,l]}function iDe({defaultProp:e,onChange:t}){const[n,o]=m.useState(e),r=m.useRef(n),a=m.useRef(t);return aDe(()=>{a.current=t},[t]),m.useEffect(()=>{var i;r.current!==n&&((i=a.current)==null||i.call(a,n),r.current=n)},[n,r]),[n,o,a]}function sDe(e){return typeof e=="function"}var cDe=m.createContext(void 0);function Nz(e){const t=m.useContext(cDe);return e||t||"ltr"}function lDe(e){const t=m.useRef({value:e,previous:e});return m.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}function CQ(e){const[t,n]=m.useState(void 0);return _i(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const o=new ResizeObserver(r=>{if(!Array.isArray(r)||!r.length)return;const a=r[0];let i,s;if("borderBoxSize"in a){const c=a.borderBoxSize,l=Array.isArray(c)?c[0]:c;i=l.inlineSize,s=l.blockSize}else i=e.offsetWidth,s=e.offsetHeight;n({width:i,height:s})});return o.observe(e,{box:"border-box"}),()=>o.unobserve(e)}else n(void 0)},[e]),t}function t0(e){const t=dDe(e),n=m.forwardRef((o,r)=>{const{children:a,...i}=o,s=m.Children.toArray(a),c=s.find(hDe);if(c){const l=c.props.children,h=s.map(u=>u===c?m.Children.count(l)>1?m.Children.only(null):m.isValidElement(l)?l.props.children:null:u);return p.jsx(t,{...i,ref:r,children:m.isValidElement(l)?m.cloneElement(l,void 0,h):null})}return p.jsx(t,{...i,ref:r,children:a})});return n.displayName=`${e}.Slot`,n}function dDe(e){const t=m.forwardRef((n,o)=>{const{children:r,...a}=n;if(m.isValidElement(r)){const i=pDe(r),s=fDe(a,r.props);return r.type!==m.Fragment&&(s.ref=o?Vr(o,i):i),m.cloneElement(r,s)}return m.Children.count(r)>1?m.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var SQ=Symbol("radix.slottable");function uDe(e){const t=({children:n})=>p.jsx(p.Fragment,{children:n});return t.displayName=`${e}.Slottable`,t.__radixId=SQ,t}function hDe(e){return m.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===SQ}function fDe(e,t){const n={...t};for(const o in t){const r=e[o],a=t[o];/^on[A-Z]/.test(o)?r&&a?n[o]=(...s)=>{const c=a(...s);return r(...s),c}:r&&(n[o]=r):o==="style"?n[o]={...r,...a}:o==="className"&&(n[o]=[r,a].filter(Boolean).join(" "))}return{...e,...n}}function pDe(e){var o,r;let t=(o=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:o.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(r=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var yDe=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Be=yDe.reduce((e,t)=>{const n=t0(`Primitive.${t}`),o=m.forwardRef((r,a)=>{const{asChild:i,...s}=r,c=i?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),p.jsx(c,{...s,ref:a})});return o.displayName=`Primitive.${t}`,{...e,[t]:o}},{});function LQ(e,t){e&&h0.flushSync(()=>e.dispatchEvent(t))}function fO(e){const t=e+"CollectionProvider",[n,o]=nr(t),[r,a]=n(t,{collectionRef:{current:null},itemMap:new Map}),i=x=>{const{scope:w,children:g}=x,M=Ar.useRef(null),v=Ar.useRef(new Map).current;return p.jsx(r,{scope:w,itemMap:v,collectionRef:M,children:g})};i.displayName=t;const s=e+"CollectionSlot",c=t0(s),l=Ar.forwardRef((x,w)=>{const{scope:g,children:M}=x,v=a(s,g),b=kt(w,v.collectionRef);return p.jsx(c,{ref:b,children:M})});l.displayName=s;const h=e+"CollectionItemSlot",u="data-radix-collection-item",f=t0(h),y=Ar.forwardRef((x,w)=>{const{scope:g,children:M,...v}=x,b=Ar.useRef(null),C=kt(w,b),_=a(h,g);return Ar.useEffect(()=>(_.itemMap.set(b,{ref:b,...v}),()=>void _.itemMap.delete(b))),p.jsx(f,{[u]:"",ref:C,children:M})});y.displayName=h;function k(x){const w=a(e+"CollectionConsumer",x);return Ar.useCallback(()=>{const M=w.collectionRef.current;if(!M)return[];const v=Array.from(M.querySelectorAll(`[${u}]`));return Array.from(w.itemMap.values()).sort((_,S)=>v.indexOf(_.ref.current)-v.indexOf(S.ref.current))},[w.collectionRef,w.itemMap])}return[{Provider:i,Slot:l,ItemSlot:y},k,o]}var IQ=["PageUp","PageDown"],NQ=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],AQ={"from-left":["Home","PageDown","ArrowDown","ArrowLeft"],"from-right":["Home","PageDown","ArrowDown","ArrowRight"],"from-bottom":["Home","PageDown","ArrowDown","ArrowLeft"],"from-top":["Home","PageDown","ArrowUp","ArrowLeft"]},m0="Slider",[hH,mDe,kDe]=fO(m0),[EQ]=nr(m0,[kDe]),[gDe,Az]=EQ(m0),$Q=m.forwardRef((e,t)=>{const{name:n,min:o=0,max:r=100,step:a=1,orientation:i="horizontal",disabled:s=!1,minStepsBetweenThumbs:c=0,defaultValue:l=[o],value:h,onValueChange:u=()=>{},onValueCommit:f=()=>{},inverted:y=!1,form:k,...x}=e,w=m.useRef(new Set),g=m.useRef(0),v=i==="horizontal"?vDe:xDe,[b=[],C]=Cd({prop:h,defaultProp:l,onChange:$=>{var X;(X=[...w.current][g.current])==null||X.focus(),u($)}}),_=m.useRef(b);function S($){const N=CDe(b,$);I($,N)}function A($){I($,g.current)}function P(){const $=_.current[g.current];b[g.current]!==$&&f(b)}function I($,N,{commit:X}={commit:!1}){const j=NDe(a),O=ADe(Math.round(($-o)/a)*a+o,j),H=_Q(O,[o,r]);C((B=[])=>{const z=bDe(B,H,N);if(IDe(z,c*a)){g.current=z.indexOf(H);const R=String(z)!==String(B);return R&&X&&f(z),R?z:B}else return B})}return p.jsx(gDe,{scope:e.__scopeSlider,name:n,disabled:s,min:o,max:r,valueIndexToChangeRef:g,thumbs:w.current,values:b,orientation:i,form:k,children:p.jsx(hH.Provider,{scope:e.__scopeSlider,children:p.jsx(hH.Slot,{scope:e.__scopeSlider,children:p.jsx(v,{"aria-disabled":s,"data-disabled":s?"":void 0,...x,ref:t,onPointerDown:Le(x.onPointerDown,()=>{s||(_.current=b)}),min:o,max:r,inverted:y,onSlideStart:s?void 0:S,onSlideMove:s?void 0:A,onSlideEnd:s?void 0:P,onHomeKeyDown:()=>!s&&I(o,0,{commit:!0}),onEndKeyDown:()=>!s&&I(r,b.length-1,{commit:!0}),onStepKeyDown:({event:$,direction:N})=>{if(!s){const O=IQ.includes($.key)||$.shiftKey&&NQ.includes($.key)?10:1,H=g.current,B=b[H],z=a*O*N;I(B+z,H,{commit:!0})}}})})})})});$Q.displayName=m0;var[PQ,jQ]=EQ(m0,{startEdge:"left",endEdge:"right",size:"width",direction:1}),vDe=m.forwardRef((e,t)=>{const{min:n,max:o,dir:r,inverted:a,onSlideStart:i,onSlideMove:s,onSlideEnd:c,onStepKeyDown:l,...h}=e,[u,f]=m.useState(null),y=kt(t,v=>f(v)),k=m.useRef(void 0),x=Nz(r),w=x==="ltr",g=w&&!a||!w&&a;function M(v){const b=k.current||u.getBoundingClientRect(),C=[0,b.width],S=pO(C,g?[n,o]:[o,n]);return k.current=b,S(v-b.left)}return p.jsx(PQ,{scope:e.__scopeSlider,startEdge:g?"left":"right",endEdge:g?"right":"left",direction:g?1:-1,size:"width",children:p.jsx(zQ,{dir:x,"data-orientation":"horizontal",...h,ref:y,style:{...h.style,"--radix-slider-thumb-transform":"translateX(-50%)"},onSlideStart:v=>{const b=M(v.clientX);i==null||i(b)},onSlideMove:v=>{const b=M(v.clientX);s==null||s(b)},onSlideEnd:()=>{k.current=void 0,c==null||c()},onStepKeyDown:v=>{const C=AQ[g?"from-left":"from-right"].includes(v.key);l==null||l({event:v,direction:C?-1:1})}})})}),xDe=m.forwardRef((e,t)=>{const{min:n,max:o,inverted:r,onSlideStart:a,onSlideMove:i,onSlideEnd:s,onStepKeyDown:c,...l}=e,h=m.useRef(null),u=kt(t,h),f=m.useRef(void 0),y=!r;function k(x){const w=f.current||h.current.getBoundingClientRect(),g=[0,w.height],v=pO(g,y?[o,n]:[n,o]);return f.current=w,v(x-w.top)}return p.jsx(PQ,{scope:e.__scopeSlider,startEdge:y?"bottom":"top",endEdge:y?"top":"bottom",size:"height",direction:y?1:-1,children:p.jsx(zQ,{"data-orientation":"vertical",...l,ref:u,style:{...l.style,"--radix-slider-thumb-transform":"translateY(50%)"},onSlideStart:x=>{const w=k(x.clientY);a==null||a(w)},onSlideMove:x=>{const w=k(x.clientY);i==null||i(w)},onSlideEnd:()=>{f.current=void 0,s==null||s()},onStepKeyDown:x=>{const g=AQ[y?"from-bottom":"from-top"].includes(x.key);c==null||c({event:x,direction:g?-1:1})}})})}),zQ=m.forwardRef((e,t)=>{const{__scopeSlider:n,onSlideStart:o,onSlideMove:r,onSlideEnd:a,onHomeKeyDown:i,onEndKeyDown:s,onStepKeyDown:c,...l}=e,h=Az(m0,n);return p.jsx(Be.span,{...l,ref:t,onKeyDown:Le(e.onKeyDown,u=>{u.key==="Home"?(i(u),u.preventDefault()):u.key==="End"?(s(u),u.preventDefault()):IQ.concat(NQ).includes(u.key)&&(c(u),u.preventDefault())}),onPointerDown:Le(e.onPointerDown,u=>{const f=u.target;f.setPointerCapture(u.pointerId),u.preventDefault(),h.thumbs.has(f)?f.focus():o(u)}),onPointerMove:Le(e.onPointerMove,u=>{u.target.hasPointerCapture(u.pointerId)&&r(u)}),onPointerUp:Le(e.onPointerUp,u=>{const f=u.target;f.hasPointerCapture(u.pointerId)&&(f.releasePointerCapture(u.pointerId),a(u))})})}),RQ="SliderTrack",TQ=m.forwardRef((e,t)=>{const{__scopeSlider:n,...o}=e,r=Az(RQ,n);return p.jsx(Be.span,{"data-disabled":r.disabled?"":void 0,"data-orientation":r.orientation,...o,ref:t})});TQ.displayName=RQ;var fH="SliderRange",DQ=m.forwardRef((e,t)=>{const{__scopeSlider:n,...o}=e,r=Az(fH,n),a=jQ(fH,n),i=m.useRef(null),s=kt(t,i),c=r.values.length,l=r.values.map(f=>OQ(f,r.min,r.max)),h=c>1?Math.min(...l):0,u=100-Math.max(...l);return p.jsx(Be.span,{"data-orientation":r.orientation,"data-disabled":r.disabled?"":void 0,...o,ref:s,style:{...e.style,[a.startEdge]:h+"%",[a.endEdge]:u+"%"}})});DQ.displayName=fH;var pH="SliderThumb",HQ=m.forwardRef((e,t)=>{const n=mDe(e.__scopeSlider),[o,r]=m.useState(null),a=kt(t,s=>r(s)),i=m.useMemo(()=>o?n().findIndex(s=>s.ref.current===o):-1,[n,o]);return p.jsx(wDe,{...e,ref:a,index:i})}),wDe=m.forwardRef((e,t)=>{const{__scopeSlider:n,index:o,name:r,...a}=e,i=Az(pH,n),s=jQ(pH,n),[c,l]=m.useState(null),h=kt(t,M=>l(M)),u=c?i.form||!!c.closest("form"):!0,f=CQ(c),y=i.values[o],k=y===void 0?0:OQ(y,i.min,i.max),x=_De(o,i.values.length),w=f==null?void 0:f[s.size],g=w?SDe(w,k,s.direction):0;return m.useEffect(()=>{if(c)return i.thumbs.add(c),()=>{i.thumbs.delete(c)}},[c,i.thumbs]),p.jsxs("span",{style:{transform:"var(--radix-slider-thumb-transform)",position:"absolute",[s.startEdge]:`calc(${k}% + ${g}px)`},children:[p.jsx(hH.ItemSlot,{scope:e.__scopeSlider,children:p.jsx(Be.span,{role:"slider","aria-label":e["aria-label"]||x,"aria-valuemin":i.min,"aria-valuenow":y,"aria-valuemax":i.max,"aria-orientation":i.orientation,"data-orientation":i.orientation,"data-disabled":i.disabled?"":void 0,tabIndex:i.disabled?void 0:0,...a,ref:h,style:y===void 0?{display:"none"}:e.style,onFocus:Le(e.onFocus,()=>{i.valueIndexToChangeRef.current=o})})}),u&&p.jsx(qQ,{name:r??(i.name?i.name+(i.values.length>1?"[]":""):void 0),form:i.form,value:y},o)]})});HQ.displayName=pH;var MDe="RadioBubbleInput",qQ=m.forwardRef(({__scopeSlider:e,value:t,...n},o)=>{const r=m.useRef(null),a=kt(r,o),i=lDe(t);return m.useEffect(()=>{const s=r.current;if(!s)return;const c=window.HTMLInputElement.prototype,h=Object.getOwnPropertyDescriptor(c,"value").set;if(i!==t&&h){const u=new Event("input",{bubbles:!0});h.call(s,t),s.dispatchEvent(u)}},[i,t]),p.jsx(Be.input,{style:{display:"none"},...n,ref:a,defaultValue:t})});qQ.displayName=MDe;function bDe(e=[],t,n){const o=[...e];return o[n]=t,o.sort((r,a)=>r-a)}function OQ(e,t,n){const a=100/(n-t)*(e-t);return _Q(a,[0,100])}function _De(e,t){return t>2?`Value ${e+1} of ${t}`:t===2?["Minimum","Maximum"][e]:void 0}function CDe(e,t){if(e.length===1)return 0;const n=e.map(r=>Math.abs(r-t)),o=Math.min(...n);return n.indexOf(o)}function SDe(e,t,n){const o=e/2,a=pO([0,50],[0,o]);return(o-a(t)*n)*n}function LDe(e){return e.slice(0,-1).map((t,n)=>e[n+1]-t)}function IDe(e,t){if(t>0){const n=LDe(e);return Math.min(...n)>=t}return!0}function pO(e,t){return n=>{if(e[0]===e[1]||t[0]===t[1])return t[0];const o=(t[1]-t[0])/(e[1]-e[0]);return t[0]+o*(n-e[0])}}function NDe(e){return(String(e).split(".")[1]||"").length}function ADe(e,t){const n=Math.pow(10,t);return Math.round(e*n)/n}var FQ=$Q,EDe=TQ,$De=DQ,PDe=HQ;const yO=m.forwardRef(({className:e,...t},n)=>p.jsxs(FQ,{ref:n,className:ae("sf:relative sf:flex sf:w-full sf:touch-none sf:select-none sf:items-center",e),...t,children:[p.jsx(EDe,{className:"sf:relative sf:h-1.5 sf:w-full sf:grow sf:overflow-hidden sf:rounded-full sf:bg-secondary",children:p.jsx($De,{className:"sf:absolute sf:h-full sf:bg-primary"})}),p.jsx(PDe,{className:"sf:block sf:h-4 sf:w-4 sf:rounded-full sf:border sf:border-primary/60 sf:bg-background sf:shadow-sm sf:transition-colors sf:hover:border-primary sf:focus-visible:outline-hidden sf:focus-visible:ring-2 sf:focus-visible:ring-ring sf:disabled:pointer-events-none sf:disabled:opacity-50"})]}));yO.displayName=FQ.displayName;const jDe={1:"sf:text-2xl sf:font-semibold sf:tracking-tight",2:"sf:text-xl sf:font-semibold sf:tracking-tight",3:"sf:text-lg sf:font-semibold",4:"sf:text-base sf:font-semibold"};function zDe({text:e,level:t=2}){const n=`h${t}`;return p.jsx(n,{className:ae(jDe[t]),children:e})}const VQ=m.createContext({custom:{}});function RDe({value:e,children:t}){return p.jsx(VQ.Provider,{value:e,children:t})}function TDe(){return m.useContext(VQ)}function n0({name:e,as:t,size:n=16,fallback:o=vIe,...r}){const a=TDe(),i=t??(e?a.custom[e]:void 0)??(e?Hu[e]:void 0)??Hu[o];return i?p.jsx(i,{size:n,...r}):null}function DDe({name:e,size:t=16}){return p.jsx(n0,{name:e,size:t,"aria-hidden":!0})}function HDe(e){return e==null?"":typeof e=="string"||typeof e=="number"?e:typeof e=="object"?JSON.stringify(e):String(e)}function qDe({label:e,value:t}){return p.jsxs("div",{className:"sf:flex sf:flex-col sf:gap-1",children:[p.jsx("span",{className:"sf:text-muted-foreground sf:text-xs sf:uppercase sf:tracking-wide",children:e}),p.jsx("span",{className:"sf:font-semibold sf:text-2xl sf:tabular-nums",children:HDe(t)})]})}function ODe(e){return e==null?"":typeof e=="string"||typeof e=="number"?String(e):JSON.stringify(e)}function FDe({columns:e=[],rows:t=[]}){return p.jsx("div",{className:"sf:w-full sf:overflow-x-auto",children:p.jsxs("table",{className:"sf:w-full sf:text-left sf:text-sm",children:[p.jsx("thead",{className:"sf:border-b sf:bg-muted/50",children:p.jsx("tr",{children:e.map(n=>p.jsx("th",{scope:"col",className:"sf:px-3 sf:py-2 sf:font-medium sf:text-muted-foreground",children:n.label},n.key))})}),p.jsx("tbody",{children:t.map((n,o)=>p.jsx("tr",{className:"sf:border-b last:sf:border-0",children:e.map(r=>p.jsx("td",{className:"sf:px-3 sf:py-2",children:ODe(n[r.key])},r.key))},o))})]})})}function VDe({text:e,muted:t}){return p.jsx("p",{className:ae("sf:text-sm",t&&"sf:text-muted-foreground"),children:e})}function BDe({title:e,children:t}){return p.jsxs("div",{className:"sf:bg-card sf:p-4 sf:text-card-foreground sf:shadow-sm",children:[e!==void 0?p.jsx("div",{className:"sf:mb-3 sf:font-semibold sf:text-base sf:leading-tight",children:e}):null,p.jsx("div",{className:"sf:flex sf:flex-col sf:gap-3",children:t})]})}function UDe({orientation:e="horizontal"}){return p.jsx("div",{"aria-orientation":e,className:ae("sf:bg-border",e==="horizontal"?"sf:h-px sf:w-full":"sf:h-full sf:w-px")})}function WDe({value:e,items:t,onChange:n,children:o}){const r=t??[];return p.jsxs("div",{className:"sf:flex sf:flex-col sf:gap-2",children:[p.jsx("div",{className:"sf:inline-flex sf:h-9 sf:items-center sf:justify-start sf:rounded-md sf:bg-muted sf:p-1 sf:text-muted-foreground",children:r.map(a=>p.jsx("button",{type:"button","data-state":e===a.id?"active":"inactive",onClick:()=>n==null?void 0:n({value:a.id}),className:"sf:inline-flex sf:items-center sf:justify-center sf:whitespace-nowrap sf:rounded-sm sf:px-3 sf:py-1 sf:text-xs sf:font-medium sf:transition-all sf:data-[state=active]:bg-background sf:data-[state=active]:text-foreground sf:data-[state=active]:shadow-sm",children:a.label},a.id))}),o]})}function GDe({items:e}){const t=e??[];return p.jsx("div",{className:"sf:flex sf:flex-col sf:divide-y sf:rounded-md sf:border",children:t.map(n=>p.jsxs("details",{className:"sf:group sf:px-3 sf:py-2",children:[p.jsx("summary",{className:"sf:cursor-pointer sf:py-1 sf:font-medium sf:text-sm",children:n.title}),p.jsx("div",{className:"sf:py-2 sf:text-muted-foreground sf:text-sm",children:n.content})]},n.id))})}const MU={default:"sf:bg-primary sf:text-primary-foreground",secondary:"sf:bg-secondary sf:text-secondary-foreground",destructive:"sf:bg-destructive sf:text-destructive-foreground",outline:"sf:border sf:border-border sf:text-foreground"};function ZDe({label:e,variant:t="default"}){return p.jsx("span",{className:ae("sf:inline-flex sf:items-center sf:rounded-full sf:px-2.5 sf:py-0.5 sf:font-medium sf:text-xs",MU[t]??MU.default),children:e})}function KDe({src:e,alt:t,fallback:n}){return e?p.jsx("img",{src:e,alt:t??"",className:"sf:inline-block sf:h-9 sf:w-9 sf:rounded-full sf:object-cover"}):p.jsx("span",{className:"sf:inline-flex sf:h-9 sf:w-9 sf:items-center sf:justify-center sf:rounded-full sf:bg-muted sf:font-medium sf:text-muted-foreground sf:text-sm",children:n??"?"})}function XDe({value:e=0}){const t=Math.max(0,Math.min(100,e));return p.jsx("div",{"aria-valuenow":t,"aria-valuemin":0,"aria-valuemax":100,className:"sf:relative sf:h-2 sf:w-full sf:overflow-hidden sf:rounded-full sf:bg-secondary",children:p.jsx("div",{className:"sf:h-full sf:bg-primary sf:transition-all",style:{width:`${t}%`}})})}function YDe({width:e,height:t}){return p.jsx("div",{className:"sf:animate-pulse sf:rounded-md sf:bg-muted",style:{width:e??"100%",height:t??16}})}function QDe({text:e}){return p.jsx("span",{className:"sf:font-medium sf:text-sm sf:leading-none",children:e})}function JDe({label:e,variant:t="default",onClick:n,disabled:o}){return p.jsx(qt,{variant:t,disabled:o,onClick:()=>n==null?void 0:n(),children:e})}const mO="sf:flex sf:h-9 sf:w-full sf:rounded-md sf:border sf:border-input sf:bg-background sf:px-3 sf:py-1 sf:text-sm sf:shadow-sm sf:transition-colors sf:placeholder:text-muted-foreground sf:focus-visible:outline-hidden sf:focus-visible:ring-1 sf:focus-visible:ring-ring sf:disabled:cursor-not-allowed sf:disabled:opacity-50";function eHe({value:e,placeholder:t,onChange:n}){return p.jsx("input",{type:"text",value:e??"",placeholder:t,onChange:o=>n==null?void 0:n({value:o.target.value}),className:mO})}function tHe({checked:e,onChange:t,label:n}){return p.jsxs("label",{className:"sf:inline-flex sf:items-center sf:gap-2 sf:text-sm",children:[p.jsx("input",{type:"checkbox",checked:e??!1,onChange:o=>t==null?void 0:t({checked:o.target.checked}),className:"sf:h-4 sf:w-4 sf:rounded sf:border sf:border-input sf:accent-primary"}),n]})}function nHe({checked:e,onChange:t}){return p.jsx("button",{type:"button",role:"switch","aria-checked":e??!1,onClick:()=>t==null?void 0:t({checked:!(e??!1)}),className:ae("sf:relative sf:inline-flex sf:h-5 sf:w-9 sf:shrink-0 sf:cursor-pointer sf:items-center sf:rounded-full sf:border-2 sf:border-transparent sf:transition-colors",e?"sf:bg-primary":"sf:bg-input"),children:p.jsx("span",{className:ae("sf:pointer-events-none sf:block sf:h-4 sf:w-4 sf:rounded-full sf:bg-background sf:shadow-lg sf:ring-0 sf:transition-transform",e?"sf:translate-x-4":"sf:translate-x-0")})})}function oHe({value:e,items:t,onChange:n}){return p.jsx("select",{value:e??"",onChange:o=>n==null?void 0:n({value:o.target.value}),className:mO,children:(t??[]).map(o=>p.jsx("option",{value:o.value,children:o.label},o.value))})}function rHe({value:e,placeholder:t,rows:n,onChange:o}){return p.jsx("textarea",{value:e??"",placeholder:t,rows:n,onChange:r=>o==null?void 0:o({value:r.target.value}),className:ae(mO,"sf:min-h-16 sf:py-2")})}function aHe({value:e,min:t=0,max:n=100,step:o=1,onChange:r}){return p.jsx(yO,{value:e===void 0?void 0:[e],min:t,max:n,step:o,onValueChange:a=>{const[i]=a;typeof i=="number"&&(r==null||r({value:i}))}})}const iHe=m.lazy(()=>Iz(()=>import("./chart-Bk7w2gX0.js"),[]));function sHe(e){return p.jsx(m.Suspense,{fallback:null,children:p.jsx(iHe,{...e})})}const cHe=m.lazy(()=>Iz(()=>import("./markdown-tPuLLX8d.js"),[]));function lHe(e){return p.jsx(m.Suspense,{fallback:null,children:p.jsx(cHe,{...e})})}const dHe=m.lazy(()=>Iz(()=>import("./code-block-DTATyN2X.js"),[]));function uHe(e){return p.jsx(m.Suspense,{fallback:null,children:p.jsx(dHe,{...e})})}const BQ={Card:BDe,Separator:UDe,Tabs:WDe,Accordion:GDe,Badge:ZDe,Avatar:KDe,Progress:XDe,Skeleton:YDe,Label:QDe,Heading:zDe,Text:VDe,Icon:DDe,Chart:sHe,Table:FDe,Metric:qDe,CodeBlock:uHe,Markdown:lHe,Button:JDe,Input:eHe,Checkbox:tHe,Switch:nHe,Select:oHe,Textarea:rHe,Slider:aHe},bU=wQ.filter(e=>BQ[e]===void 0);if(bU.length>0)throw new Error(`componentRegistry is missing impls for: ${bU.join(", ")}. Every catalog entry in COMPONENT_NAMES must have a matching component impl.`);const hHe={components:BQ};function fHe(e,t){return t.kind==="set"?{...e,[t.path]:t.value}:{...e,...t.partial}}function UQ(e){return e===null||typeof e!="object"?!1:"$state"in e||"$action"in e||"$param"in e||"$cond"in e}function DP(e,t,n,o){if(!UQ(e))return e;if(typeof e.$state=="string")return t[e.$state];if(typeof e.$action=="string"){const r=e.$action;return o.has(r)?a=>n(r,a):void 0}if("$cond"in e){const r=DP(e.$cond,t,n,o);return DP(r?e.$then:e.$else,t,n,o)}return e}function pHe(e,t,n,o){if(!e)return{};const r={};for(const[a,i]of Object.entries(e))r[a]=DP(i,t,n,o);return r}function _U({spec:e,nodeId:t,apiBaseUrl:n="/api",flowId:o}){const[r,a]=m.useReducer(fHe,e.state??{}),i=new Set(Object.keys(e.actions??{})),s=m.useCallback(async(c,l)=>{var f;const h=(f=e.actions)==null?void 0:f[c];if(!h)return;if(h.kind==="set"){const y=yHe(h.value,l,r);a({kind:"set",path:h.path,value:y});return}if(!o)return;const u=`${n}/flows/${o}/nodes/${t}/actions/${c}`;try{const y=await fetch(u,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(l??{})});if(!y.ok){const x=await y.text();a({kind:"set",path:`/__errors/${c}`,value:x});return}const k=await y.json();k!==null&&typeof k=="object"&&a({kind:"merge",partial:k})}catch(y){a({kind:"set",path:`/__errors/${c}`,value:y instanceof Error?y.message:String(y)})}},[e.actions,o,n,t,r]);return WQ(e.root,e,r,s,i)}function yHe(e,t,n){return UQ(e)?typeof e.$param=="string"?t!==null&&typeof t=="object"?t[e.$param]:void 0:typeof e.$state=="string"?n[e.$state]:e:e}function WQ(e,t,n,o,r){const a=t.elements[e];if(!a)return null;const i=hHe.components[a.type];if(!i)return null;const s=pHe(a.props,n,o,r),l=(a.children??[]).map(h=>p.jsx(mHe,{children:WQ(h,t,n,o,r)},h));return p.jsx(i,{...s,children:l.length>0?l:void 0})}function mHe({children:e}){return e}function Br(e){const t=m.useRef(e);return m.useEffect(()=>{t.current=e}),m.useMemo(()=>(...n)=>{var o;return(o=t.current)==null?void 0:o.call(t,...n)},[])}function kHe(e,t=globalThis==null?void 0:globalThis.document){const n=Br(e);m.useEffect(()=>{const o=r=>{r.key==="Escape"&&n(r)};return t.addEventListener("keydown",o,{capture:!0}),()=>t.removeEventListener("keydown",o,{capture:!0})},[n,t])}var gHe="DismissableLayer",yH="dismissableLayer.update",vHe="dismissableLayer.pointerDownOutside",xHe="dismissableLayer.focusOutside",CU,GQ=m.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Vh=m.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:o,onPointerDownOutside:r,onFocusOutside:a,onInteractOutside:i,onDismiss:s,...c}=e,l=m.useContext(GQ),[h,u]=m.useState(null),f=(h==null?void 0:h.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,y]=m.useState({}),k=kt(t,S=>u(S)),x=Array.from(l.layers),[w]=[...l.layersWithOutsidePointerEventsDisabled].slice(-1),g=x.indexOf(w),M=h?x.indexOf(h):-1,v=l.layersWithOutsidePointerEventsDisabled.size>0,b=M>=g,C=bHe(S=>{const A=S.target,P=[...l.branches].some(I=>I.contains(A));!b||P||(r==null||r(S),i==null||i(S),S.defaultPrevented||s==null||s())},f),_=_He(S=>{const A=S.target;[...l.branches].some(I=>I.contains(A))||(a==null||a(S),i==null||i(S),S.defaultPrevented||s==null||s())},f);return kHe(S=>{M===l.layers.size-1&&(o==null||o(S),!S.defaultPrevented&&s&&(S.preventDefault(),s()))},f),m.useEffect(()=>{if(h)return n&&(l.layersWithOutsidePointerEventsDisabled.size===0&&(CU=f.body.style.pointerEvents,f.body.style.pointerEvents="none"),l.layersWithOutsidePointerEventsDisabled.add(h)),l.layers.add(h),SU(),()=>{n&&l.layersWithOutsidePointerEventsDisabled.size===1&&(f.body.style.pointerEvents=CU)}},[h,f,n,l]),m.useEffect(()=>()=>{h&&(l.layers.delete(h),l.layersWithOutsidePointerEventsDisabled.delete(h),SU())},[h,l]),m.useEffect(()=>{const S=()=>y({});return document.addEventListener(yH,S),()=>document.removeEventListener(yH,S)},[]),p.jsx(Be.div,{...c,ref:k,style:{pointerEvents:v?b?"auto":"none":void 0,...e.style},onFocusCapture:Le(e.onFocusCapture,_.onFocusCapture),onBlurCapture:Le(e.onBlurCapture,_.onBlurCapture),onPointerDownCapture:Le(e.onPointerDownCapture,C.onPointerDownCapture)})});Vh.displayName=gHe;var wHe="DismissableLayerBranch",MHe=m.forwardRef((e,t)=>{const n=m.useContext(GQ),o=m.useRef(null),r=kt(t,o);return m.useEffect(()=>{const a=o.current;if(a)return n.branches.add(a),()=>{n.branches.delete(a)}},[n.branches]),p.jsx(Be.div,{...e,ref:r})});MHe.displayName=wHe;function bHe(e,t=globalThis==null?void 0:globalThis.document){const n=Br(e),o=m.useRef(!1),r=m.useRef(()=>{});return m.useEffect(()=>{const a=s=>{if(s.target&&!o.current){let c=function(){ZQ(vHe,n,l,{discrete:!0})};const l={originalEvent:s};s.pointerType==="touch"?(t.removeEventListener("click",r.current),r.current=c,t.addEventListener("click",r.current,{once:!0})):c()}else t.removeEventListener("click",r.current);o.current=!1},i=window.setTimeout(()=>{t.addEventListener("pointerdown",a)},0);return()=>{window.clearTimeout(i),t.removeEventListener("pointerdown",a),t.removeEventListener("click",r.current)}},[t,n]),{onPointerDownCapture:()=>o.current=!0}}function _He(e,t=globalThis==null?void 0:globalThis.document){const n=Br(e),o=m.useRef(!1);return m.useEffect(()=>{const r=a=>{a.target&&!o.current&&ZQ(xHe,n,{originalEvent:a},{discrete:!1})};return t.addEventListener("focusin",r),()=>t.removeEventListener("focusin",r)},[t,n]),{onFocusCapture:()=>o.current=!0,onBlurCapture:()=>o.current=!1}}function SU(){const e=new CustomEvent(yH);document.dispatchEvent(e)}function ZQ(e,t,n,{discrete:o}){const r=n.originalEvent.target,a=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&r.addEventListener(e,t,{once:!0}),o?LQ(r,a):r.dispatchEvent(a)}var iT=0;function kO(){m.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??LU()),document.body.insertAdjacentElement("beforeend",e[1]??LU()),iT++,()=>{iT===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),iT--}},[])}function LU(){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 sT="focusScope.autoFocusOnMount",cT="focusScope.autoFocusOnUnmount",IU={bubbles:!1,cancelable:!0},CHe="FocusScope",Ez=m.forwardRef((e,t)=>{const{loop:n=!1,trapped:o=!1,onMountAutoFocus:r,onUnmountAutoFocus:a,...i}=e,[s,c]=m.useState(null),l=Br(r),h=Br(a),u=m.useRef(null),f=kt(t,x=>c(x)),y=m.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;m.useEffect(()=>{if(o){let x=function(v){if(y.paused||!s)return;const b=v.target;s.contains(b)?u.current=b:Ya(u.current,{select:!0})},w=function(v){if(y.paused||!s)return;const b=v.relatedTarget;b!==null&&(s.contains(b)||Ya(u.current,{select:!0}))},g=function(v){if(document.activeElement===document.body)for(const C of v)C.removedNodes.length>0&&Ya(s)};document.addEventListener("focusin",x),document.addEventListener("focusout",w);const M=new MutationObserver(g);return s&&M.observe(s,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",x),document.removeEventListener("focusout",w),M.disconnect()}}},[o,s,y.paused]),m.useEffect(()=>{if(s){AU.add(y);const x=document.activeElement;if(!s.contains(x)){const g=new CustomEvent(sT,IU);s.addEventListener(sT,l),s.dispatchEvent(g),g.defaultPrevented||(SHe(EHe(KQ(s)),{select:!0}),document.activeElement===x&&Ya(s))}return()=>{s.removeEventListener(sT,l),setTimeout(()=>{const g=new CustomEvent(cT,IU);s.addEventListener(cT,h),s.dispatchEvent(g),g.defaultPrevented||Ya(x??document.body,{select:!0}),s.removeEventListener(cT,h),AU.remove(y)},0)}}},[s,l,h,y]);const k=m.useCallback(x=>{if(!n&&!o||y.paused)return;const w=x.key==="Tab"&&!x.altKey&&!x.ctrlKey&&!x.metaKey,g=document.activeElement;if(w&&g){const M=x.currentTarget,[v,b]=LHe(M);v&&b?!x.shiftKey&&g===b?(x.preventDefault(),n&&Ya(v,{select:!0})):x.shiftKey&&g===v&&(x.preventDefault(),n&&Ya(b,{select:!0})):g===M&&x.preventDefault()}},[n,o,y.paused]);return p.jsx(Be.div,{tabIndex:-1,...i,ref:f,onKeyDown:k})});Ez.displayName=CHe;function SHe(e,{select:t=!1}={}){const n=document.activeElement;for(const o of e)if(Ya(o,{select:t}),document.activeElement!==n)return}function LHe(e){const t=KQ(e),n=NU(t,e),o=NU(t.reverse(),e);return[n,o]}function KQ(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:o=>{const r=o.tagName==="INPUT"&&o.type==="hidden";return o.disabled||o.hidden||r?NodeFilter.FILTER_SKIP:o.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function NU(e,t){for(const n of e)if(!IHe(n,{upTo:t}))return n}function IHe(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 NHe(e){return e instanceof HTMLInputElement&&"select"in e}function Ya(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&NHe(e)&&t&&e.select()}}var AU=AHe();function AHe(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=EU(e,t),e.unshift(t)},remove(t){var n;e=EU(e,t),(n=e[0])==null||n.resume()}}}function EU(e,t){const n=[...e],o=n.indexOf(t);return o!==-1&&n.splice(o,1),n}function EHe(e){return e.filter(t=>t.tagName!=="A")}var $He=eq[" useId ".trim().toString()]||(()=>{}),PHe=0;function An(e){const[t,n]=m.useState($He());return _i(()=>{n(o=>o??String(PHe++))},[e]),e||(t?`radix-${t}`:"")}const jHe=["top","right","bottom","left"],Ci=Math.min,ao=Math.max,Rj=Math.round,Jf=Math.floor,qr=e=>({x:e,y:e}),zHe={left:"right",right:"left",bottom:"top",top:"bottom"};function mH(e,t,n){return ao(e,Ci(t,n))}function Ca(e,t){return typeof e=="function"?e(t):e}function Sa(e){return e.split("-")[0]}function k0(e){return e.split("-")[1]}function gO(e){return e==="x"?"y":"x"}function vO(e){return e==="y"?"height":"width"}function zr(e){const t=e[0];return t==="t"||t==="b"?"y":"x"}function xO(e){return gO(zr(e))}function RHe(e,t,n){n===void 0&&(n=!1);const o=k0(e),r=xO(e),a=vO(r);let i=r==="x"?o===(n?"end":"start")?"right":"left":o==="start"?"bottom":"top";return t.reference[a]>t.floating[a]&&(i=Tj(i)),[i,Tj(i)]}function THe(e){const t=Tj(e);return[kH(e),t,kH(t)]}function kH(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const $U=["left","right"],PU=["right","left"],DHe=["top","bottom"],HHe=["bottom","top"];function qHe(e,t,n){switch(e){case"top":case"bottom":return n?t?PU:$U:t?$U:PU;case"left":case"right":return t?DHe:HHe;default:return[]}}function OHe(e,t,n,o){const r=k0(e);let a=qHe(Sa(e),n==="start",o);return r&&(a=a.map(i=>i+"-"+r),t&&(a=a.concat(a.map(kH)))),a}function Tj(e){const t=Sa(e);return zHe[t]+e.slice(t.length)}function FHe(e){return{top:0,right:0,bottom:0,left:0,...e}}function XQ(e){return typeof e!="number"?FHe(e):{top:e,right:e,bottom:e,left:e}}function Dj(e){const{x:t,y:n,width:o,height:r}=e;return{width:o,height:r,top:n,left:t,right:t+o,bottom:n+r,x:t,y:n}}function jU(e,t,n){let{reference:o,floating:r}=e;const a=zr(t),i=xO(t),s=vO(i),c=Sa(t),l=a==="y",h=o.x+o.width/2-r.width/2,u=o.y+o.height/2-r.height/2,f=o[s]/2-r[s]/2;let y;switch(c){case"top":y={x:h,y:o.y-r.height};break;case"bottom":y={x:h,y:o.y+o.height};break;case"right":y={x:o.x+o.width,y:u};break;case"left":y={x:o.x-r.width,y:u};break;default:y={x:o.x,y:o.y}}switch(k0(t)){case"start":y[i]-=f*(n&&l?-1:1);break;case"end":y[i]+=f*(n&&l?-1:1);break}return y}async function VHe(e,t){var n;t===void 0&&(t={});const{x:o,y:r,platform:a,rects:i,elements:s,strategy:c}=e,{boundary:l="clippingAncestors",rootBoundary:h="viewport",elementContext:u="floating",altBoundary:f=!1,padding:y=0}=Ca(t,e),k=XQ(y),w=s[f?u==="floating"?"reference":"floating":u],g=Dj(await a.getClippingRect({element:(n=await(a.isElement==null?void 0:a.isElement(w)))==null||n?w:w.contextElement||await(a.getDocumentElement==null?void 0:a.getDocumentElement(s.floating)),boundary:l,rootBoundary:h,strategy:c})),M=u==="floating"?{x:o,y:r,width:i.floating.width,height:i.floating.height}:i.reference,v=await(a.getOffsetParent==null?void 0:a.getOffsetParent(s.floating)),b=await(a.isElement==null?void 0:a.isElement(v))?await(a.getScale==null?void 0:a.getScale(v))||{x:1,y:1}:{x:1,y:1},C=Dj(a.convertOffsetParentRelativeRectToViewportRelativeRect?await a.convertOffsetParentRelativeRectToViewportRelativeRect({elements:s,rect:M,offsetParent:v,strategy:c}):M);return{top:(g.top-C.top+k.top)/b.y,bottom:(C.bottom-g.bottom+k.bottom)/b.y,left:(g.left-C.left+k.left)/b.x,right:(C.right-g.right+k.right)/b.x}}const BHe=50,UHe=async(e,t,n)=>{const{placement:o="bottom",strategy:r="absolute",middleware:a=[],platform:i}=n,s=i.detectOverflow?i:{...i,detectOverflow:VHe},c=await(i.isRTL==null?void 0:i.isRTL(t));let l=await i.getElementRects({reference:e,floating:t,strategy:r}),{x:h,y:u}=jU(l,o,c),f=o,y=0;const k={};for(let x=0;x<a.length;x++){const w=a[x];if(!w)continue;const{name:g,fn:M}=w,{x:v,y:b,data:C,reset:_}=await M({x:h,y:u,initialPlacement:o,placement:f,strategy:r,middlewareData:k,rects:l,platform:s,elements:{reference:e,floating:t}});h=v??h,u=b??u,k[g]={...k[g],...C},_&&y<BHe&&(y++,typeof _=="object"&&(_.placement&&(f=_.placement),_.rects&&(l=_.rects===!0?await i.getElementRects({reference:e,floating:t,strategy:r}):_.rects),{x:h,y:u}=jU(l,f,c)),x=-1)}return{x:h,y:u,placement:f,strategy:r,middlewareData:k}},WHe=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:o,placement:r,rects:a,platform:i,elements:s,middlewareData:c}=t,{element:l,padding:h=0}=Ca(e,t)||{};if(l==null)return{};const u=XQ(h),f={x:n,y:o},y=xO(r),k=vO(y),x=await i.getDimensions(l),w=y==="y",g=w?"top":"left",M=w?"bottom":"right",v=w?"clientHeight":"clientWidth",b=a.reference[k]+a.reference[y]-f[y]-a.floating[k],C=f[y]-a.reference[y],_=await(i.getOffsetParent==null?void 0:i.getOffsetParent(l));let S=_?_[v]:0;(!S||!await(i.isElement==null?void 0:i.isElement(_)))&&(S=s.floating[v]||a.floating[k]);const A=b/2-C/2,P=S/2-x[k]/2-1,I=Ci(u[g],P),$=Ci(u[M],P),N=I,X=S-x[k]-$,j=S/2-x[k]/2+A,O=mH(N,j,X),H=!c.arrow&&k0(r)!=null&&j!==O&&a.reference[k]/2-(j<N?I:$)-x[k]/2<0,B=H?j<N?j-N:j-X:0;return{[y]:f[y]+B,data:{[y]:O,centerOffset:j-O-B,...H&&{alignmentOffset:B}},reset:H}}}),GHe=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,o;const{placement:r,middlewareData:a,rects:i,initialPlacement:s,platform:c,elements:l}=t,{mainAxis:h=!0,crossAxis:u=!0,fallbackPlacements:f,fallbackStrategy:y="bestFit",fallbackAxisSideDirection:k="none",flipAlignment:x=!0,...w}=Ca(e,t);if((n=a.arrow)!=null&&n.alignmentOffset)return{};const g=Sa(r),M=zr(s),v=Sa(s)===s,b=await(c.isRTL==null?void 0:c.isRTL(l.floating)),C=f||(v||!x?[Tj(s)]:THe(s)),_=k!=="none";!f&&_&&C.push(...OHe(s,x,k,b));const S=[s,...C],A=await c.detectOverflow(t,w),P=[];let I=((o=a.flip)==null?void 0:o.overflows)||[];if(h&&P.push(A[g]),u){const j=RHe(r,i,b);P.push(A[j[0]],A[j[1]])}if(I=[...I,{placement:r,overflows:P}],!P.every(j=>j<=0)){var $,N;const j=((($=a.flip)==null?void 0:$.index)||0)+1,O=S[j];if(O&&(!(u==="alignment"?M!==zr(O):!1)||I.every(z=>zr(z.placement)===M?z.overflows[0]>0:!0)))return{data:{index:j,overflows:I},reset:{placement:O}};let H=(N=I.filter(B=>B.overflows[0]<=0).sort((B,z)=>B.overflows[1]-z.overflows[1])[0])==null?void 0:N.placement;if(!H)switch(y){case"bestFit":{var X;const B=(X=I.filter(z=>{if(_){const R=zr(z.placement);return R===M||R==="y"}return!0}).map(z=>[z.placement,z.overflows.filter(R=>R>0).reduce((R,L)=>R+L,0)]).sort((z,R)=>z[1]-R[1])[0])==null?void 0:X[0];B&&(H=B);break}case"initialPlacement":H=s;break}if(r!==H)return{reset:{placement:H}}}return{}}}};function zU(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function RU(e){return jHe.some(t=>e[t]>=0)}const ZHe=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n,platform:o}=t,{strategy:r="referenceHidden",...a}=Ca(e,t);switch(r){case"referenceHidden":{const i=await o.detectOverflow(t,{...a,elementContext:"reference"}),s=zU(i,n.reference);return{data:{referenceHiddenOffsets:s,referenceHidden:RU(s)}}}case"escaped":{const i=await o.detectOverflow(t,{...a,altBoundary:!0}),s=zU(i,n.floating);return{data:{escapedOffsets:s,escaped:RU(s)}}}default:return{}}}}},YQ=new Set(["left","top"]);async function KHe(e,t){const{placement:n,platform:o,elements:r}=e,a=await(o.isRTL==null?void 0:o.isRTL(r.floating)),i=Sa(n),s=k0(n),c=zr(n)==="y",l=YQ.has(i)?-1:1,h=a&&c?-1:1,u=Ca(t,e);let{mainAxis:f,crossAxis:y,alignmentAxis:k}=typeof u=="number"?{mainAxis:u,crossAxis:0,alignmentAxis:null}:{mainAxis:u.mainAxis||0,crossAxis:u.crossAxis||0,alignmentAxis:u.alignmentAxis};return s&&typeof k=="number"&&(y=s==="end"?k*-1:k),c?{x:y*h,y:f*l}:{x:f*l,y:y*h}}const XHe=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,o;const{x:r,y:a,placement:i,middlewareData:s}=t,c=await KHe(t,e);return i===((n=s.offset)==null?void 0:n.placement)&&(o=s.arrow)!=null&&o.alignmentOffset?{}:{x:r+c.x,y:a+c.y,data:{...c,placement:i}}}}},YHe=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:o,placement:r,platform:a}=t,{mainAxis:i=!0,crossAxis:s=!1,limiter:c={fn:g=>{let{x:M,y:v}=g;return{x:M,y:v}}},...l}=Ca(e,t),h={x:n,y:o},u=await a.detectOverflow(t,l),f=zr(Sa(r)),y=gO(f);let k=h[y],x=h[f];if(i){const g=y==="y"?"top":"left",M=y==="y"?"bottom":"right",v=k+u[g],b=k-u[M];k=mH(v,k,b)}if(s){const g=f==="y"?"top":"left",M=f==="y"?"bottom":"right",v=x+u[g],b=x-u[M];x=mH(v,x,b)}const w=c.fn({...t,[y]:k,[f]:x});return{...w,data:{x:w.x-n,y:w.y-o,enabled:{[y]:i,[f]:s}}}}}},QHe=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:o,placement:r,rects:a,middlewareData:i}=t,{offset:s=0,mainAxis:c=!0,crossAxis:l=!0}=Ca(e,t),h={x:n,y:o},u=zr(r),f=gO(u);let y=h[f],k=h[u];const x=Ca(s,t),w=typeof x=="number"?{mainAxis:x,crossAxis:0}:{mainAxis:0,crossAxis:0,...x};if(c){const v=f==="y"?"height":"width",b=a.reference[f]-a.floating[v]+w.mainAxis,C=a.reference[f]+a.reference[v]-w.mainAxis;y<b?y=b:y>C&&(y=C)}if(l){var g,M;const v=f==="y"?"width":"height",b=YQ.has(Sa(r)),C=a.reference[u]-a.floating[v]+(b&&((g=i.offset)==null?void 0:g[u])||0)+(b?0:w.crossAxis),_=a.reference[u]+a.reference[v]+(b?0:((M=i.offset)==null?void 0:M[u])||0)-(b?w.crossAxis:0);k<C?k=C:k>_&&(k=_)}return{[f]:y,[u]:k}}}},JHe=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var n,o;const{placement:r,rects:a,platform:i,elements:s}=t,{apply:c=()=>{},...l}=Ca(e,t),h=await i.detectOverflow(t,l),u=Sa(r),f=k0(r),y=zr(r)==="y",{width:k,height:x}=a.floating;let w,g;u==="top"||u==="bottom"?(w=u,g=f===(await(i.isRTL==null?void 0:i.isRTL(s.floating))?"start":"end")?"left":"right"):(g=u,w=f==="end"?"top":"bottom");const M=x-h.top-h.bottom,v=k-h.left-h.right,b=Ci(x-h[w],M),C=Ci(k-h[g],v),_=!t.middlewareData.shift;let S=b,A=C;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(A=v),(o=t.middlewareData.shift)!=null&&o.enabled.y&&(S=M),_&&!f){const I=ao(h.left,0),$=ao(h.right,0),N=ao(h.top,0),X=ao(h.bottom,0);y?A=k-2*(I!==0||$!==0?I+$:ao(h.left,h.right)):S=x-2*(N!==0||X!==0?N+X:ao(h.top,h.bottom))}await c({...t,availableWidth:A,availableHeight:S});const P=await i.getDimensions(s.floating);return k!==P.width||x!==P.height?{reset:{rects:!0}}:{}}}};function $z(){return typeof window<"u"}function g0(e){return QQ(e)?(e.nodeName||"").toLowerCase():"#document"}function uo(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Wr(e){var t;return(t=(QQ(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function QQ(e){return $z()?e instanceof Node||e instanceof uo(e).Node:!1}function Jo(e){return $z()?e instanceof Element||e instanceof uo(e).Element:!1}function Na(e){return $z()?e instanceof HTMLElement||e instanceof uo(e).HTMLElement:!1}function TU(e){return!$z()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof uo(e).ShadowRoot}function Bh(e){const{overflow:t,overflowX:n,overflowY:o,display:r}=er(e);return/auto|scroll|overlay|hidden|clip/.test(t+o+n)&&r!=="inline"&&r!=="contents"}function eqe(e){return/^(table|td|th)$/.test(g0(e))}function Pz(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}const tqe=/transform|translate|scale|rotate|perspective|filter/,nqe=/paint|layout|strict|content/,Oi=e=>!!e&&e!=="none";let lT;function wO(e){const t=Jo(e)?er(e):e;return Oi(t.transform)||Oi(t.translate)||Oi(t.scale)||Oi(t.rotate)||Oi(t.perspective)||!MO()&&(Oi(t.backdropFilter)||Oi(t.filter))||tqe.test(t.willChange||"")||nqe.test(t.contain||"")}function oqe(e){let t=Si(e);for(;Na(t)&&!o0(t);){if(wO(t))return t;if(Pz(t))return null;t=Si(t)}return null}function MO(){return lT==null&&(lT=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),lT}function o0(e){return/^(html|body|#document)$/.test(g0(e))}function er(e){return uo(e).getComputedStyle(e)}function jz(e){return Jo(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Si(e){if(g0(e)==="html")return e;const t=e.assignedSlot||e.parentNode||TU(e)&&e.host||Wr(e);return TU(t)?t.host:t}function JQ(e){const t=Si(e);return o0(t)?e.ownerDocument?e.ownerDocument.body:e.body:Na(t)&&Bh(t)?t:JQ(t)}function _h(e,t,n){var o;t===void 0&&(t=[]),n===void 0&&(n=!0);const r=JQ(e),a=r===((o=e.ownerDocument)==null?void 0:o.body),i=uo(r);if(a){const s=gH(i);return t.concat(i,i.visualViewport||[],Bh(r)?r:[],s&&n?_h(s):[])}else return t.concat(r,_h(r,[],n))}function gH(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function eJ(e){const t=er(e);let n=parseFloat(t.width)||0,o=parseFloat(t.height)||0;const r=Na(e),a=r?e.offsetWidth:n,i=r?e.offsetHeight:o,s=Rj(n)!==a||Rj(o)!==i;return s&&(n=a,o=i),{width:n,height:o,$:s}}function bO(e){return Jo(e)?e:e.contextElement}function Nu(e){const t=bO(e);if(!Na(t))return qr(1);const n=t.getBoundingClientRect(),{width:o,height:r,$:a}=eJ(t);let i=(a?Rj(n.width):n.width)/o,s=(a?Rj(n.height):n.height)/r;return(!i||!Number.isFinite(i))&&(i=1),(!s||!Number.isFinite(s))&&(s=1),{x:i,y:s}}const rqe=qr(0);function tJ(e){const t=uo(e);return!MO()||!t.visualViewport?rqe:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function aqe(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==uo(e)?!1:t}function gd(e,t,n,o){t===void 0&&(t=!1),n===void 0&&(n=!1);const r=e.getBoundingClientRect(),a=bO(e);let i=qr(1);t&&(o?Jo(o)&&(i=Nu(o)):i=Nu(e));const s=aqe(a,n,o)?tJ(a):qr(0);let c=(r.left+s.x)/i.x,l=(r.top+s.y)/i.y,h=r.width/i.x,u=r.height/i.y;if(a){const f=uo(a),y=o&&Jo(o)?uo(o):o;let k=f,x=gH(k);for(;x&&o&&y!==k;){const w=Nu(x),g=x.getBoundingClientRect(),M=er(x),v=g.left+(x.clientLeft+parseFloat(M.paddingLeft))*w.x,b=g.top+(x.clientTop+parseFloat(M.paddingTop))*w.y;c*=w.x,l*=w.y,h*=w.x,u*=w.y,c+=v,l+=b,k=uo(x),x=gH(k)}}return Dj({width:h,height:u,x:c,y:l})}function zz(e,t){const n=jz(e).scrollLeft;return t?t.left+n:gd(Wr(e)).left+n}function nJ(e,t){const n=e.getBoundingClientRect(),o=n.left+t.scrollLeft-zz(e,n),r=n.top+t.scrollTop;return{x:o,y:r}}function iqe(e){let{elements:t,rect:n,offsetParent:o,strategy:r}=e;const a=r==="fixed",i=Wr(o),s=t?Pz(t.floating):!1;if(o===i||s&&a)return n;let c={scrollLeft:0,scrollTop:0},l=qr(1);const h=qr(0),u=Na(o);if((u||!u&&!a)&&((g0(o)!=="body"||Bh(i))&&(c=jz(o)),u)){const y=gd(o);l=Nu(o),h.x=y.x+o.clientLeft,h.y=y.y+o.clientTop}const f=i&&!u&&!a?nJ(i,c):qr(0);return{width:n.width*l.x,height:n.height*l.y,x:n.x*l.x-c.scrollLeft*l.x+h.x+f.x,y:n.y*l.y-c.scrollTop*l.y+h.y+f.y}}function sqe(e){return Array.from(e.getClientRects())}function cqe(e){const t=Wr(e),n=jz(e),o=e.ownerDocument.body,r=ao(t.scrollWidth,t.clientWidth,o.scrollWidth,o.clientWidth),a=ao(t.scrollHeight,t.clientHeight,o.scrollHeight,o.clientHeight);let i=-n.scrollLeft+zz(e);const s=-n.scrollTop;return er(o).direction==="rtl"&&(i+=ao(t.clientWidth,o.clientWidth)-r),{width:r,height:a,x:i,y:s}}const DU=25;function lqe(e,t){const n=uo(e),o=Wr(e),r=n.visualViewport;let a=o.clientWidth,i=o.clientHeight,s=0,c=0;if(r){a=r.width,i=r.height;const h=MO();(!h||h&&t==="fixed")&&(s=r.offsetLeft,c=r.offsetTop)}const l=zz(o);if(l<=0){const h=o.ownerDocument,u=h.body,f=getComputedStyle(u),y=h.compatMode==="CSS1Compat"&&parseFloat(f.marginLeft)+parseFloat(f.marginRight)||0,k=Math.abs(o.clientWidth-u.clientWidth-y);k<=DU&&(a-=k)}else l<=DU&&(a+=l);return{width:a,height:i,x:s,y:c}}function dqe(e,t){const n=gd(e,!0,t==="fixed"),o=n.top+e.clientTop,r=n.left+e.clientLeft,a=Na(e)?Nu(e):qr(1),i=e.clientWidth*a.x,s=e.clientHeight*a.y,c=r*a.x,l=o*a.y;return{width:i,height:s,x:c,y:l}}function HU(e,t,n){let o;if(t==="viewport")o=lqe(e,n);else if(t==="document")o=cqe(Wr(e));else if(Jo(t))o=dqe(t,n);else{const r=tJ(e);o={x:t.x-r.x,y:t.y-r.y,width:t.width,height:t.height}}return Dj(o)}function oJ(e,t){const n=Si(e);return n===t||!Jo(n)||o0(n)?!1:er(n).position==="fixed"||oJ(n,t)}function uqe(e,t){const n=t.get(e);if(n)return n;let o=_h(e,[],!1).filter(s=>Jo(s)&&g0(s)!=="body"),r=null;const a=er(e).position==="fixed";let i=a?Si(e):e;for(;Jo(i)&&!o0(i);){const s=er(i),c=wO(i);!c&&s.position==="fixed"&&(r=null),(a?!c&&!r:!c&&s.position==="static"&&!!r&&(r.position==="absolute"||r.position==="fixed")||Bh(i)&&!c&&oJ(e,i))?o=o.filter(h=>h!==i):r=s,i=Si(i)}return t.set(e,o),o}function hqe(e){let{element:t,boundary:n,rootBoundary:o,strategy:r}=e;const i=[...n==="clippingAncestors"?Pz(t)?[]:uqe(t,this._c):[].concat(n),o],s=HU(t,i[0],r);let c=s.top,l=s.right,h=s.bottom,u=s.left;for(let f=1;f<i.length;f++){const y=HU(t,i[f],r);c=ao(y.top,c),l=Ci(y.right,l),h=Ci(y.bottom,h),u=ao(y.left,u)}return{width:l-u,height:h-c,x:u,y:c}}function fqe(e){const{width:t,height:n}=eJ(e);return{width:t,height:n}}function pqe(e,t,n){const o=Na(t),r=Wr(t),a=n==="fixed",i=gd(e,!0,a,t);let s={scrollLeft:0,scrollTop:0};const c=qr(0);function l(){c.x=zz(r)}if(o||!o&&!a)if((g0(t)!=="body"||Bh(r))&&(s=jz(t)),o){const y=gd(t,!0,a,t);c.x=y.x+t.clientLeft,c.y=y.y+t.clientTop}else r&&l();a&&!o&&r&&l();const h=r&&!o&&!a?nJ(r,s):qr(0),u=i.left+s.scrollLeft-c.x-h.x,f=i.top+s.scrollTop-c.y-h.y;return{x:u,y:f,width:i.width,height:i.height}}function dT(e){return er(e).position==="static"}function qU(e,t){if(!Na(e)||er(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return Wr(e)===n&&(n=n.ownerDocument.body),n}function rJ(e,t){const n=uo(e);if(Pz(e))return n;if(!Na(e)){let r=Si(e);for(;r&&!o0(r);){if(Jo(r)&&!dT(r))return r;r=Si(r)}return n}let o=qU(e,t);for(;o&&eqe(o)&&dT(o);)o=qU(o,t);return o&&o0(o)&&dT(o)&&!wO(o)?n:o||oqe(e)||n}const yqe=async function(e){const t=this.getOffsetParent||rJ,n=this.getDimensions,o=await n(e.floating);return{reference:pqe(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:o.width,height:o.height}}};function mqe(e){return er(e).direction==="rtl"}const kqe={convertOffsetParentRelativeRectToViewportRelativeRect:iqe,getDocumentElement:Wr,getClippingRect:hqe,getOffsetParent:rJ,getElementRects:yqe,getClientRects:sqe,getDimensions:fqe,getScale:Nu,isElement:Jo,isRTL:mqe};function aJ(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function gqe(e,t){let n=null,o;const r=Wr(e);function a(){var s;clearTimeout(o),(s=n)==null||s.disconnect(),n=null}function i(s,c){s===void 0&&(s=!1),c===void 0&&(c=1),a();const l=e.getBoundingClientRect(),{left:h,top:u,width:f,height:y}=l;if(s||t(),!f||!y)return;const k=Jf(u),x=Jf(r.clientWidth-(h+f)),w=Jf(r.clientHeight-(u+y)),g=Jf(h),v={rootMargin:-k+"px "+-x+"px "+-w+"px "+-g+"px",threshold:ao(0,Ci(1,c))||1};let b=!0;function C(_){const S=_[0].intersectionRatio;if(S!==c){if(!b)return i();S?i(!1,S):o=setTimeout(()=>{i(!1,1e-7)},1e3)}S===1&&!aJ(l,e.getBoundingClientRect())&&i(),b=!1}try{n=new IntersectionObserver(C,{...v,root:r.ownerDocument})}catch{n=new IntersectionObserver(C,v)}n.observe(e)}return i(!0),a}function vqe(e,t,n,o){o===void 0&&(o={});const{ancestorScroll:r=!0,ancestorResize:a=!0,elementResize:i=typeof ResizeObserver=="function",layoutShift:s=typeof IntersectionObserver=="function",animationFrame:c=!1}=o,l=bO(e),h=r||a?[...l?_h(l):[],...t?_h(t):[]]:[];h.forEach(g=>{r&&g.addEventListener("scroll",n,{passive:!0}),a&&g.addEventListener("resize",n)});const u=l&&s?gqe(l,n):null;let f=-1,y=null;i&&(y=new ResizeObserver(g=>{let[M]=g;M&&M.target===l&&y&&t&&(y.unobserve(t),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var v;(v=y)==null||v.observe(t)})),n()}),l&&!c&&y.observe(l),t&&y.observe(t));let k,x=c?gd(e):null;c&&w();function w(){const g=gd(e);x&&!aJ(x,g)&&n(),x=g,k=requestAnimationFrame(w)}return n(),()=>{var g;h.forEach(M=>{r&&M.removeEventListener("scroll",n),a&&M.removeEventListener("resize",n)}),u==null||u(),(g=y)==null||g.disconnect(),y=null,c&&cancelAnimationFrame(k)}}const xqe=XHe,wqe=YHe,Mqe=GHe,bqe=JHe,_qe=ZHe,OU=WHe,Cqe=QHe,Sqe=(e,t,n)=>{const o=new Map,r={platform:kqe,...n},a={...r.platform,_c:o};return UHe(e,t,{...r,platform:a})};var Lqe=typeof document<"u",Iqe=function(){},HP=Lqe?m.useLayoutEffect:Iqe;function Hj(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let n,o,r;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(o=n;o--!==0;)if(!Hj(e[o],t[o]))return!1;return!0}if(r=Object.keys(e),n=r.length,n!==Object.keys(t).length)return!1;for(o=n;o--!==0;)if(!{}.hasOwnProperty.call(t,r[o]))return!1;for(o=n;o--!==0;){const a=r[o];if(!(a==="_owner"&&e.$$typeof)&&!Hj(e[a],t[a]))return!1}return!0}return e!==e&&t!==t}function iJ(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function FU(e,t){const n=iJ(e);return Math.round(t*n)/n}function uT(e){const t=m.useRef(e);return HP(()=>{t.current=e}),t}function Nqe(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:o=[],platform:r,elements:{reference:a,floating:i}={},transform:s=!0,whileElementsMounted:c,open:l}=e,[h,u]=m.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[f,y]=m.useState(o);Hj(f,o)||y(o);const[k,x]=m.useState(null),[w,g]=m.useState(null),M=m.useCallback(z=>{z!==_.current&&(_.current=z,x(z))},[]),v=m.useCallback(z=>{z!==S.current&&(S.current=z,g(z))},[]),b=a||k,C=i||w,_=m.useRef(null),S=m.useRef(null),A=m.useRef(h),P=c!=null,I=uT(c),$=uT(r),N=uT(l),X=m.useCallback(()=>{if(!_.current||!S.current)return;const z={placement:t,strategy:n,middleware:f};$.current&&(z.platform=$.current),Sqe(_.current,S.current,z).then(R=>{const L={...R,isPositioned:N.current!==!1};j.current&&!Hj(A.current,L)&&(A.current=L,h0.flushSync(()=>{u(L)}))})},[f,t,n,$,N]);HP(()=>{l===!1&&A.current.isPositioned&&(A.current.isPositioned=!1,u(z=>({...z,isPositioned:!1})))},[l]);const j=m.useRef(!1);HP(()=>(j.current=!0,()=>{j.current=!1}),[]),HP(()=>{if(b&&(_.current=b),C&&(S.current=C),b&&C){if(I.current)return I.current(b,C,X);X()}},[b,C,X,I,P]);const O=m.useMemo(()=>({reference:_,floating:S,setReference:M,setFloating:v}),[M,v]),H=m.useMemo(()=>({reference:b,floating:C}),[b,C]),B=m.useMemo(()=>{const z={position:n,left:0,top:0};if(!H.floating)return z;const R=FU(H.floating,h.x),L=FU(H.floating,h.y);return s?{...z,transform:"translate("+R+"px, "+L+"px)",...iJ(H.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:R,top:L}},[n,s,H.floating,h.x,h.y]);return m.useMemo(()=>({...h,update:X,refs:O,elements:H,floatingStyles:B}),[h,X,O,H,B])}const Aqe=e=>{function t(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:e,fn(n){const{element:o,padding:r}=typeof e=="function"?e(n):e;return o&&t(o)?o.current!=null?OU({element:o.current,padding:r}).fn(n):{}:o?OU({element:o,padding:r}).fn(n):{}}}},Eqe=(e,t)=>{const n=xqe(e);return{name:n.name,fn:n.fn,options:[e,t]}},$qe=(e,t)=>{const n=wqe(e);return{name:n.name,fn:n.fn,options:[e,t]}},Pqe=(e,t)=>({fn:Cqe(e).fn,options:[e,t]}),jqe=(e,t)=>{const n=Mqe(e);return{name:n.name,fn:n.fn,options:[e,t]}},zqe=(e,t)=>{const n=bqe(e);return{name:n.name,fn:n.fn,options:[e,t]}},Rqe=(e,t)=>{const n=_qe(e);return{name:n.name,fn:n.fn,options:[e,t]}},Tqe=(e,t)=>{const n=Aqe(e);return{name:n.name,fn:n.fn,options:[e,t]}};var Dqe="Arrow",sJ=m.forwardRef((e,t)=>{const{children:n,width:o=10,height:r=5,...a}=e;return p.jsx(Be.svg,{...a,ref:t,width:o,height:r,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:p.jsx("polygon",{points:"0,0 30,0 15,10"})})});sJ.displayName=Dqe;var Hqe=sJ,_O="Popper",[cJ,v0]=nr(_O),[qqe,lJ]=cJ(_O),dJ=e=>{const{__scopePopper:t,children:n}=e,[o,r]=m.useState(null);return p.jsx(qqe,{scope:t,anchor:o,onAnchorChange:r,children:n})};dJ.displayName=_O;var uJ="PopperAnchor",hJ=m.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:o,...r}=e,a=lJ(uJ,n),i=m.useRef(null),s=kt(t,i),c=m.useRef(null);return m.useEffect(()=>{const l=c.current;c.current=(o==null?void 0:o.current)||i.current,l!==c.current&&a.onAnchorChange(c.current)}),o?null:p.jsx(Be.div,{...r,ref:s})});hJ.displayName=uJ;var CO="PopperContent",[Oqe,Fqe]=cJ(CO),fJ=m.forwardRef((e,t)=>{var oe,te,se,we,ke,ge;const{__scopePopper:n,side:o="bottom",sideOffset:r=0,align:a="center",alignOffset:i=0,arrowPadding:s=0,avoidCollisions:c=!0,collisionBoundary:l=[],collisionPadding:h=0,sticky:u="partial",hideWhenDetached:f=!1,updatePositionStrategy:y="optimized",onPlaced:k,...x}=e,w=lJ(CO,n),[g,M]=m.useState(null),v=kt(t,ve=>M(ve)),[b,C]=m.useState(null),_=CQ(b),S=(_==null?void 0:_.width)??0,A=(_==null?void 0:_.height)??0,P=o+(a!=="center"?"-"+a:""),I=typeof h=="number"?h:{top:0,right:0,bottom:0,left:0,...h},$=Array.isArray(l)?l:[l],N=$.length>0,X={padding:I,boundary:$.filter(Bqe),altBoundary:N},{refs:j,floatingStyles:O,placement:H,isPositioned:B,middlewareData:z}=Nqe({strategy:"fixed",placement:P,whileElementsMounted:(...ve)=>vqe(...ve,{animationFrame:y==="always"}),elements:{reference:w.anchor},middleware:[Eqe({mainAxis:r+A,alignmentAxis:i}),c&&$qe({mainAxis:!0,crossAxis:!1,limiter:u==="partial"?Pqe():void 0,...X}),c&&jqe({...X}),zqe({...X,apply:({elements:ve,rects:re,availableWidth:me,availableHeight:Ve})=>{const{width:lt,height:Vt}=re.reference,Et=ve.floating.style;Et.setProperty("--radix-popper-available-width",`${me}px`),Et.setProperty("--radix-popper-available-height",`${Ve}px`),Et.setProperty("--radix-popper-anchor-width",`${lt}px`),Et.setProperty("--radix-popper-anchor-height",`${Vt}px`)}}),b&&Tqe({element:b,padding:s}),Uqe({arrowWidth:S,arrowHeight:A}),f&&Rqe({strategy:"referenceHidden",...X})]}),[R,L]=mJ(H),U=Br(k);_i(()=>{B&&(U==null||U())},[B,U]);const D=(oe=z.arrow)==null?void 0:oe.x,E=(te=z.arrow)==null?void 0:te.y,W=((se=z.arrow)==null?void 0:se.centerOffset)!==0,[Y,Q]=m.useState();return _i(()=>{g&&Q(window.getComputedStyle(g).zIndex)},[g]),p.jsx("div",{ref:j.setFloating,"data-radix-popper-content-wrapper":"",style:{...O,transform:B?O.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:Y,"--radix-popper-transform-origin":[(we=z.transformOrigin)==null?void 0:we.x,(ke=z.transformOrigin)==null?void 0:ke.y].join(" "),...((ge=z.hide)==null?void 0:ge.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:p.jsx(Oqe,{scope:n,placedSide:R,onArrowChange:C,arrowX:D,arrowY:E,shouldHideArrow:W,children:p.jsx(Be.div,{"data-side":R,"data-align":L,...x,ref:v,style:{...x.style,animation:B?void 0:"none"}})})})});fJ.displayName=CO;var pJ="PopperArrow",Vqe={top:"bottom",right:"left",bottom:"top",left:"right"},yJ=m.forwardRef(function(t,n){const{__scopePopper:o,...r}=t,a=Fqe(pJ,o),i=Vqe[a.placedSide];return p.jsx("span",{ref:a.onArrowChange,style:{position:"absolute",left:a.arrowX,top:a.arrowY,[i]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[a.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[a.placedSide],visibility:a.shouldHideArrow?"hidden":void 0},children:p.jsx(Hqe,{...r,ref:n,style:{...r.style,display:"block"}})})});yJ.displayName=pJ;function Bqe(e){return e!==null}var Uqe=e=>({name:"transformOrigin",options:e,fn(t){var w,g,M;const{placement:n,rects:o,middlewareData:r}=t,i=((w=r.arrow)==null?void 0:w.centerOffset)!==0,s=i?0:e.arrowWidth,c=i?0:e.arrowHeight,[l,h]=mJ(n),u={start:"0%",center:"50%",end:"100%"}[h],f=(((g=r.arrow)==null?void 0:g.x)??0)+s/2,y=(((M=r.arrow)==null?void 0:M.y)??0)+c/2;let k="",x="";return l==="bottom"?(k=i?u:`${f}px`,x=`${-c}px`):l==="top"?(k=i?u:`${f}px`,x=`${o.floating.height+c}px`):l==="right"?(k=`${-c}px`,x=i?u:`${y}px`):l==="left"&&(k=`${o.floating.width+c}px`,x=i?u:`${y}px`),{data:{x:k,y:x}}}});function mJ(e){const[t,n="center"]=e.split("-");return[t,n]}var SO=dJ,Rz=hJ,LO=fJ,IO=yJ,Wqe="Portal",Uh=m.forwardRef((e,t)=>{var s;const{container:n,...o}=e,[r,a]=m.useState(!1);_i(()=>a(!0),[]);const i=n||r&&((s=globalThis==null?void 0:globalThis.document)==null?void 0:s.body);return i?rse.createPortal(p.jsx(Be.div,{...o,ref:t}),i):null});Uh.displayName=Wqe;function Gqe(e,t){return m.useReducer((n,o)=>t[n][o]??n,e)}var ko=e=>{const{present:t,children:n}=e,o=Zqe(t),r=typeof n=="function"?n({present:o.isPresent}):m.Children.only(n),a=kt(o.ref,Kqe(r));return typeof n=="function"||o.isPresent?m.cloneElement(r,{ref:a}):null};ko.displayName="Presence";function Zqe(e){const[t,n]=m.useState(),o=m.useRef(null),r=m.useRef(e),a=m.useRef("none"),i=e?"mounted":"unmounted",[s,c]=Gqe(i,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return m.useEffect(()=>{const l=ep(o.current);a.current=s==="mounted"?l:"none"},[s]),_i(()=>{const l=o.current,h=r.current;if(h!==e){const f=a.current,y=ep(l);e?c("MOUNT"):y==="none"||(l==null?void 0:l.display)==="none"?c("UNMOUNT"):c(h&&f!==y?"ANIMATION_OUT":"UNMOUNT"),r.current=e}},[e,c]),_i(()=>{if(t){let l;const h=t.ownerDocument.defaultView??window,u=y=>{const x=ep(o.current).includes(CSS.escape(y.animationName));if(y.target===t&&x&&(c("ANIMATION_END"),!r.current)){const w=t.style.animationFillMode;t.style.animationFillMode="forwards",l=h.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=w)})}},f=y=>{y.target===t&&(a.current=ep(o.current))};return t.addEventListener("animationstart",f),t.addEventListener("animationcancel",u),t.addEventListener("animationend",u),()=>{h.clearTimeout(l),t.removeEventListener("animationstart",f),t.removeEventListener("animationcancel",u),t.removeEventListener("animationend",u)}}else c("ANIMATION_END")},[t,c]),{isPresent:["mounted","unmountSuspended"].includes(s),ref:m.useCallback(l=>{o.current=l?getComputedStyle(l):null,n(l)},[])}}function ep(e){return(e==null?void 0:e.animationName)||"none"}function Kqe(e){var o,r;let t=(o=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:o.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(r=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var Xqe=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},Od=new WeakMap,tp=new WeakMap,np={},hT=0,kJ=function(e){return e&&(e.host||kJ(e.parentNode))},Yqe=function(e,t){return t.map(function(n){if(e.contains(n))return n;var o=kJ(n);return o&&e.contains(o)?o:(console.error("aria-hidden",n,"in not contained inside",e,". Doing nothing"),null)}).filter(function(n){return!!n})},Qqe=function(e,t,n,o){var r=Yqe(t,Array.isArray(e)?e:[e]);np[n]||(np[n]=new WeakMap);var a=np[n],i=[],s=new Set,c=new Set(r),l=function(u){!u||s.has(u)||(s.add(u),l(u.parentNode))};r.forEach(l);var h=function(u){!u||c.has(u)||Array.prototype.forEach.call(u.children,function(f){if(s.has(f))h(f);else try{var y=f.getAttribute(o),k=y!==null&&y!=="false",x=(Od.get(f)||0)+1,w=(a.get(f)||0)+1;Od.set(f,x),a.set(f,w),i.push(f),x===1&&k&&tp.set(f,!0),w===1&&f.setAttribute(n,"true"),k||f.setAttribute(o,"true")}catch(g){console.error("aria-hidden: cannot operate on ",f,g)}})};return h(t),s.clear(),hT++,function(){i.forEach(function(u){var f=Od.get(u)-1,y=a.get(u)-1;Od.set(u,f),a.set(u,y),f||(tp.has(u)||u.removeAttribute(o),tp.delete(u)),y||u.removeAttribute(n)}),hT--,hT||(Od=new WeakMap,Od=new WeakMap,tp=new WeakMap,np={})}},NO=function(e,t,n){n===void 0&&(n="data-aria-hidden");var o=Array.from(Array.isArray(e)?e:[e]),r=Xqe(e);return r?(o.push.apply(o,Array.from(r.querySelectorAll("[aria-live], script"))),Qqe(o,r,n,"aria-hidden")):function(){return null}},jr=function(){return jr=Object.assign||function(t){for(var n,o=1,r=arguments.length;o<r;o++){n=arguments[o];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(t[a]=n[a])}return t},jr.apply(this,arguments)};function gJ(e,t){var n={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.indexOf(o)<0&&(n[o]=e[o]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,o=Object.getOwnPropertySymbols(e);r<o.length;r++)t.indexOf(o[r])<0&&Object.prototype.propertyIsEnumerable.call(e,o[r])&&(n[o[r]]=e[o[r]]);return n}function Jqe(e,t,n){if(n||arguments.length===2)for(var o=0,r=t.length,a;o<r;o++)(a||!(o in t))&&(a||(a=Array.prototype.slice.call(t,0,o)),a[o]=t[o]);return e.concat(a||Array.prototype.slice.call(t))}var qP="right-scroll-bar-position",OP="width-before-scroll-bar",eOe="with-scroll-bars-hidden",tOe="--removed-body-scroll-bar-size";function fT(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function nOe(e,t){var n=m.useState(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(o){var r=n.value;r!==o&&(n.value=o,n.callback(o,r))}}}})[0];return n.callback=t,n.facade}var oOe=typeof window<"u"?m.useLayoutEffect:m.useEffect,VU=new WeakMap;function rOe(e,t){var n=nOe(null,function(o){return e.forEach(function(r){return fT(r,o)})});return oOe(function(){var o=VU.get(n);if(o){var r=new Set(o),a=new Set(e),i=n.current;r.forEach(function(s){a.has(s)||fT(s,null)}),a.forEach(function(s){r.has(s)||fT(s,i)})}VU.set(n,e)},[e]),n}function aOe(e){return e}function iOe(e,t){t===void 0&&(t=aOe);var n=[],o=!1,r={read:function(){if(o)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(a){var i=t(a,o);return n.push(i),function(){n=n.filter(function(s){return s!==i})}},assignSyncMedium:function(a){for(o=!0;n.length;){var i=n;n=[],i.forEach(a)}n={push:function(s){return a(s)},filter:function(){return n}}},assignMedium:function(a){o=!0;var i=[];if(n.length){var s=n;n=[],s.forEach(a),i=n}var c=function(){var h=i;i=[],h.forEach(a)},l=function(){return Promise.resolve().then(c)};l(),n={push:function(h){i.push(h),l()},filter:function(h){return i=i.filter(h),n}}}};return r}function sOe(e){e===void 0&&(e={});var t=iOe(null);return t.options=jr({async:!0,ssr:!1},e),t}var vJ=function(e){var t=e.sideCar,n=gJ(e,["sideCar"]);if(!t)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var o=t.read();if(!o)throw new Error("Sidecar medium not found");return m.createElement(o,jr({},n))};vJ.isSideCarExport=!0;function cOe(e,t){return e.useMedium(t),vJ}var xJ=sOe(),pT=function(){},Tz=m.forwardRef(function(e,t){var n=m.useRef(null),o=m.useState({onScrollCapture:pT,onWheelCapture:pT,onTouchMoveCapture:pT}),r=o[0],a=o[1],i=e.forwardProps,s=e.children,c=e.className,l=e.removeScrollBar,h=e.enabled,u=e.shards,f=e.sideCar,y=e.noRelative,k=e.noIsolation,x=e.inert,w=e.allowPinchZoom,g=e.as,M=g===void 0?"div":g,v=e.gapMode,b=gJ(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),C=f,_=rOe([n,t]),S=jr(jr({},b),r);return m.createElement(m.Fragment,null,h&&m.createElement(C,{sideCar:xJ,removeScrollBar:l,shards:u,noRelative:y,noIsolation:k,inert:x,setCallbacks:a,allowPinchZoom:!!w,lockRef:n,gapMode:v}),i?m.cloneElement(m.Children.only(s),jr(jr({},S),{ref:_})):m.createElement(M,jr({},S,{className:c,ref:_}),s))});Tz.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};Tz.classNames={fullWidth:OP,zeroRight:qP};var lOe=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function dOe(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=lOe();return t&&e.setAttribute("nonce",t),e}function uOe(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function hOe(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var fOe=function(){var e=0,t=null;return{add:function(n){e==0&&(t=dOe())&&(uOe(t,n),hOe(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},pOe=function(){var e=fOe();return function(t,n){m.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},wJ=function(){var e=pOe(),t=function(n){var o=n.styles,r=n.dynamic;return e(o,r),null};return t},yOe={left:0,top:0,right:0,gap:0},yT=function(e){return parseInt(e||"",10)||0},mOe=function(e){var t=window.getComputedStyle(document.body),n=t[e==="padding"?"paddingLeft":"marginLeft"],o=t[e==="padding"?"paddingTop":"marginTop"],r=t[e==="padding"?"paddingRight":"marginRight"];return[yT(n),yT(o),yT(r)]},kOe=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return yOe;var t=mOe(e),n=document.documentElement.clientWidth,o=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,o-n+t[2]-t[0])}},gOe=wJ(),Au="data-scroll-locked",vOe=function(e,t,n,o){var r=e.left,a=e.top,i=e.right,s=e.gap;return n===void 0&&(n="margin"),`
8469
8469
  .`.concat(eOe,` {
8470
8470
  overflow: hidden `).concat(o,`;
8471
8471
  padding-right: `).concat(s,"px ").concat(o,`;
@@ -8540,7 +8540,7 @@ For more information, see https://radix-ui.com/primitives/docs/components/${t.do
8540
8540
  `))}function c(y,k,x,w){const g=x.enter("tableCell"),M=x.enter("phrasing"),v=x.containerPhrasing(y,{...w,before:a,after:a});return M(),g(),v}function l(y,k){return hYe(y,{align:k,alignDelimiters:o,padding:n,stringLength:r})}function h(y,k,x){const w=y.children;let g=-1;const M=[],v=k.enter("table");for(;++g<w.length;)M[g]=u(w[g],k,x);return v(),M}function u(y,k,x){const w=y.children;let g=-1;const M=[],v=k.enter("tableRow");for(;++g<w.length;)M[g]=c(w[g],y,k,x);return v(),M}function f(y,k,x){let w=koe.inlineCode(y,k,x);return x.stack.includes("tableCell")&&(w=w.replace(/\|/g,"\\$&")),w}}function JYe(){return{exit:{taskListCheckValueChecked:aG,taskListCheckValueUnchecked:aG,paragraph:tQe}}}function eQe(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:nQe}}}function aG(e){const t=this.stack[this.stack.length-2];t.type,t.checked=e.type==="taskListCheckValueChecked"}function tQe(e){const t=this.stack[this.stack.length-2];if(t&&t.type==="listItem"&&typeof t.checked=="boolean"){const n=this.stack[this.stack.length-1];n.type;const o=n.children[0];if(o&&o.type==="text"){const r=t.children;let a=-1,i;for(;++a<r.length;){const s=r[a];if(s.type==="paragraph"){i=s;break}}i===n&&(o.value=o.value.slice(1),o.value.length===0?n.children.shift():n.position&&o.position&&typeof o.position.start.offset=="number"&&(o.position.start.column++,o.position.start.offset++,n.position.start=Object.assign({},o.position.start)))}}this.exit(e)}function nQe(e,t,n,o){const r=e.children[0],a=typeof e.checked=="boolean"&&r&&r.type==="paragraph",i="["+(e.checked?"x":" ")+"] ",s=n.createTracker(o);a&&s.move(i);let c=koe.listItem(e,t,n,{...o,...s.current()});return a&&(c=c.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,l)),c;function l(h){return h+i}}function oQe(){return[zXe(),nYe(),iYe(),WYe(),JYe()]}function rQe(e){return{extensions:[RXe(),oYe(e),sYe(),QYe(e),eQe()]}}const aQe={tokenize:uQe,partial:!0},goe={tokenize:hQe,partial:!0},voe={tokenize:fQe,partial:!0},xoe={tokenize:pQe,partial:!0},iQe={tokenize:yQe,partial:!0},woe={name:"wwwAutolink",tokenize:lQe,previous:boe},Moe={name:"protocolAutolink",tokenize:dQe,previous:_oe},Aa={name:"emailAutolink",tokenize:cQe,previous:Coe},Gr={};function sQe(){return{text:Gr}}let Fi=48;for(;Fi<123;)Gr[Fi]=Aa,Fi++,Fi===58?Fi=65:Fi===91&&(Fi=97);Gr[43]=Aa;Gr[45]=Aa;Gr[46]=Aa;Gr[95]=Aa;Gr[72]=[Aa,Moe];Gr[104]=[Aa,Moe];Gr[87]=[Aa,woe];Gr[119]=[Aa,woe];function cQe(e,t,n){const o=this;let r,a;return i;function i(u){return!FH(u)||!Coe.call(o,o.previous)||yF(o.events)?n(u):(e.enter("literalAutolink"),e.enter("literalAutolinkEmail"),s(u))}function s(u){return FH(u)?(e.consume(u),s):u===64?(e.consume(u),c):n(u)}function c(u){return u===46?e.check(iQe,h,l)(u):u===45||u===95||vn(u)?(a=!0,e.consume(u),c):h(u)}function l(u){return e.consume(u),r=!0,c}function h(u){return a&&r&&In(o.previous)?(e.exit("literalAutolinkEmail"),e.exit("literalAutolink"),t(u)):n(u)}}function lQe(e,t,n){const o=this;return r;function r(i){return i!==87&&i!==119||!boe.call(o,o.previous)||yF(o.events)?n(i):(e.enter("literalAutolink"),e.enter("literalAutolinkWww"),e.check(aQe,e.attempt(goe,e.attempt(voe,a),n),n)(i))}function a(i){return e.exit("literalAutolinkWww"),e.exit("literalAutolink"),t(i)}}function dQe(e,t,n){const o=this;let r="",a=!1;return i;function i(u){return(u===72||u===104)&&_oe.call(o,o.previous)&&!yF(o.events)?(e.enter("literalAutolink"),e.enter("literalAutolinkHttp"),r+=String.fromCodePoint(u),e.consume(u),s):n(u)}function s(u){if(In(u)&&r.length<5)return r+=String.fromCodePoint(u),e.consume(u),s;if(u===58){const f=r.toLowerCase();if(f==="http"||f==="https")return e.consume(u),c}return n(u)}function c(u){return u===47?(e.consume(u),a?l:(a=!0,c)):n(u)}function l(u){return u===null||Uj(u)||mt(u)||wd(u)||nR(u)?n(u):e.attempt(goe,e.attempt(voe,h),n)(u)}function h(u){return e.exit("literalAutolinkHttp"),e.exit("literalAutolink"),t(u)}}function uQe(e,t,n){let o=0;return r;function r(i){return(i===87||i===119)&&o<3?(o++,e.consume(i),r):i===46&&o===3?(e.consume(i),a):n(i)}function a(i){return i===null?n(i):t(i)}}function hQe(e,t,n){let o,r,a;return i;function i(l){return l===46||l===95?e.check(xoe,c,s)(l):l===null||mt(l)||wd(l)||l!==45&&nR(l)?c(l):(a=!0,e.consume(l),i)}function s(l){return l===95?o=!0:(r=o,o=void 0),e.consume(l),i}function c(l){return r||o||!a?n(l):t(l)}}function fQe(e,t){let n=0,o=0;return r;function r(i){return i===40?(n++,e.consume(i),r):i===41&&o<n?a(i):i===33||i===34||i===38||i===39||i===41||i===42||i===44||i===46||i===58||i===59||i===60||i===63||i===93||i===95||i===126?e.check(xoe,t,a)(i):i===null||mt(i)||wd(i)?t(i):(e.consume(i),r)}function a(i){return i===41&&o++,e.consume(i),r}}function pQe(e,t,n){return o;function o(s){return s===33||s===34||s===39||s===41||s===42||s===44||s===46||s===58||s===59||s===63||s===95||s===126?(e.consume(s),o):s===38?(e.consume(s),a):s===93?(e.consume(s),r):s===60||s===null||mt(s)||wd(s)?t(s):n(s)}function r(s){return s===null||s===40||s===91||mt(s)||wd(s)?t(s):o(s)}function a(s){return In(s)?i(s):n(s)}function i(s){return s===59?(e.consume(s),o):In(s)?(e.consume(s),i):n(s)}}function yQe(e,t,n){return o;function o(a){return e.consume(a),r}function r(a){return vn(a)?n(a):t(a)}}function boe(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||mt(e)}function _oe(e){return!In(e)}function Coe(e){return!(e===47||FH(e))}function FH(e){return e===43||e===45||e===46||e===95||vn(e)}function yF(e){let t=e.length,n=!1;for(;t--;){const o=e[t][1];if((o.type==="labelLink"||o.type==="labelImage")&&!o._balanced){n=!0;break}if(o._gfmAutolinkLiteralWalkedInto){n=!1;break}}return e.length>0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}const mQe={tokenize:_Qe,partial:!0};function kQe(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:wQe,continuation:{tokenize:MQe},exit:bQe}},text:{91:{name:"gfmFootnoteCall",tokenize:xQe},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:gQe,resolveTo:vQe}}}}function gQe(e,t,n){const o=this;let r=o.events.length;const a=o.parser.gfmFootnotes||(o.parser.gfmFootnotes=[]);let i;for(;r--;){const c=o.events[r][1];if(c.type==="labelImage"){i=c;break}if(c.type==="gfmFootnoteCall"||c.type==="labelLink"||c.type==="label"||c.type==="image"||c.type==="link")break}return s;function s(c){if(!i||!i._balanced)return n(c);const l=Yo(o.sliceSerialize({start:i.end,end:o.now()}));return l.codePointAt(0)!==94||!a.includes(l.slice(1))?n(c):(e.enter("gfmFootnoteCallLabelMarker"),e.consume(c),e.exit("gfmFootnoteCallLabelMarker"),t(c))}}function vQe(e,t){let n=e.length;for(;n--;)if(e[n][1].type==="labelImage"&&e[n][0]==="enter"){e[n][1];break}e[n+1][1].type="data",e[n+3][1].type="gfmFootnoteCallLabelMarker";const o={type:"gfmFootnoteCall",start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},r={type:"gfmFootnoteCallMarker",start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};r.end.column++,r.end.offset++,r.end._bufferIndex++;const a={type:"gfmFootnoteCallString",start:Object.assign({},r.end),end:Object.assign({},e[e.length-1][1].start)},i={type:"chunkString",contentType:"string",start:Object.assign({},a.start),end:Object.assign({},a.end)},s=[e[n+1],e[n+2],["enter",o,t],e[n+3],e[n+4],["enter",r,t],["exit",r,t],["enter",a,t],["enter",i,t],["exit",i,t],["exit",a,t],e[e.length-2],e[e.length-1],["exit",o,t]];return e.splice(n,e.length-n+1,...s),e}function xQe(e,t,n){const o=this,r=o.parser.gfmFootnotes||(o.parser.gfmFootnotes=[]);let a=0,i;return s;function s(u){return e.enter("gfmFootnoteCall"),e.enter("gfmFootnoteCallLabelMarker"),e.consume(u),e.exit("gfmFootnoteCallLabelMarker"),c}function c(u){return u!==94?n(u):(e.enter("gfmFootnoteCallMarker"),e.consume(u),e.exit("gfmFootnoteCallMarker"),e.enter("gfmFootnoteCallString"),e.enter("chunkString").contentType="string",l)}function l(u){if(a>999||u===93&&!i||u===null||u===91||mt(u))return n(u);if(u===93){e.exit("chunkString");const f=e.exit("gfmFootnoteCallString");return r.includes(Yo(o.sliceSerialize(f)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(u),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),t):n(u)}return mt(u)||(i=!0),a++,e.consume(u),u===92?h:l}function h(u){return u===91||u===92||u===93?(e.consume(u),a++,l):l(u)}}function wQe(e,t,n){const o=this,r=o.parser.gfmFootnotes||(o.parser.gfmFootnotes=[]);let a,i=0,s;return c;function c(k){return e.enter("gfmFootnoteDefinition")._container=!0,e.enter("gfmFootnoteDefinitionLabel"),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(k),e.exit("gfmFootnoteDefinitionLabelMarker"),l}function l(k){return k===94?(e.enter("gfmFootnoteDefinitionMarker"),e.consume(k),e.exit("gfmFootnoteDefinitionMarker"),e.enter("gfmFootnoteDefinitionLabelString"),e.enter("chunkString").contentType="string",h):n(k)}function h(k){if(i>999||k===93&&!s||k===null||k===91||mt(k))return n(k);if(k===93){e.exit("chunkString");const x=e.exit("gfmFootnoteDefinitionLabelString");return a=Yo(o.sliceSerialize(x)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(k),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),f}return mt(k)||(s=!0),i++,e.consume(k),k===92?u:h}function u(k){return k===91||k===92||k===93?(e.consume(k),i++,h):h(k)}function f(k){return k===58?(e.enter("definitionMarker"),e.consume(k),e.exit("definitionMarker"),r.includes(a)||r.push(a),nt(e,y,"gfmFootnoteDefinitionWhitespace")):n(k)}function y(k){return t(k)}}function MQe(e,t,n){return e.check(ff,t,e.attempt(mQe,t,n))}function bQe(e){e.exit("gfmFootnoteDefinition")}function _Qe(e,t,n){const o=this;return nt(e,r,"gfmFootnoteDefinitionIndent",5);function r(a){const i=o.events[o.events.length-1];return i&&i[1].type==="gfmFootnoteDefinitionIndent"&&i[2].sliceSerialize(i[1],!0).length===4?t(a):n(a)}}function CQe(e){let n=(e||{}).singleTilde;const o={name:"strikethrough",tokenize:a,resolveAll:r};return n==null&&(n=!0),{text:{126:o},insideSpan:{null:[o]},attentionMarkers:{null:[126]}};function r(i,s){let c=-1;for(;++c<i.length;)if(i[c][0]==="enter"&&i[c][1].type==="strikethroughSequenceTemporary"&&i[c][1]._close){let l=c;for(;l--;)if(i[l][0]==="exit"&&i[l][1].type==="strikethroughSequenceTemporary"&&i[l][1]._open&&i[c][1].end.offset-i[c][1].start.offset===i[l][1].end.offset-i[l][1].start.offset){i[c][1].type="strikethroughSequence",i[l][1].type="strikethroughSequence";const h={type:"strikethrough",start:Object.assign({},i[l][1].start),end:Object.assign({},i[c][1].end)},u={type:"strikethroughText",start:Object.assign({},i[l][1].end),end:Object.assign({},i[c][1].start)},f=[["enter",h,s],["enter",i[l][1],s],["exit",i[l][1],s],["enter",u,s]],y=s.parser.constructs.insideSpan.null;y&&ho(f,f.length,0,oR(y,i.slice(l+1,c),s)),ho(f,f.length,0,[["exit",u,s],["enter",i[c][1],s],["exit",i[c][1],s],["exit",h,s]]),ho(i,l-1,c-l+3,f),c=l+f.length-2;break}}for(c=-1;++c<i.length;)i[c][1].type==="strikethroughSequenceTemporary"&&(i[c][1].type="data");return i}function a(i,s,c){const l=this.previous,h=this.events;let u=0;return f;function f(k){return l===126&&h[h.length-1][1].type!=="characterEscape"?c(k):(i.enter("strikethroughSequenceTemporary"),y(k))}function y(k){const x=s0(l);if(k===126)return u>1?c(k):(i.consume(k),u++,y);if(u<2&&!n)return c(k);const w=i.exit("strikethroughSequenceTemporary"),g=s0(k);return w._open=!g||g===2&&!!x,w._close=!x||x===2&&!!g,s(k)}}}class SQe{constructor(){this.map=[]}add(t,n,o){LQe(this,t,n,o)}consume(t){if(this.map.sort(function(a,i){return a[0]-i[0]}),this.map.length===0)return;let n=this.map.length;const o=[];for(;n>0;)n-=1,o.push(t.slice(this.map[n][0]+this.map[n][1]),this.map[n][2]),t.length=this.map[n][0];o.push(t.slice()),t.length=0;let r=o.pop();for(;r;){for(const a of r)t.push(a);r=o.pop()}this.map.length=0}}function LQe(e,t,n,o){let r=0;if(!(n===0&&o.length===0)){for(;r<e.map.length;){if(e.map[r][0]===t){e.map[r][1]+=n,e.map[r][2].push(...o);return}r+=1}e.map.push([t,n,o])}}function IQe(e,t){let n=!1;const o=[];for(;t<e.length;){const r=e[t];if(n){if(r[0]==="enter")r[1].type==="tableContent"&&o.push(e[t+1][1].type==="tableDelimiterMarker"?"left":"none");else if(r[1].type==="tableContent"){if(e[t-1][1].type==="tableDelimiterMarker"){const a=o.length-1;o[a]=o[a]==="left"?"center":"right"}}else if(r[1].type==="tableDelimiterRow")break}else r[0]==="enter"&&r[1].type==="tableDelimiterRow"&&(n=!0);t+=1}return o}function NQe(){return{flow:{null:{name:"table",tokenize:AQe,resolveAll:EQe}}}}function AQe(e,t,n){const o=this;let r=0,a=0,i;return s;function s(I){let $=o.events.length-1;for(;$>-1;){const j=o.events[$][1].type;if(j==="lineEnding"||j==="linePrefix")$--;else break}const N=$>-1?o.events[$][1].type:null,X=N==="tableHead"||N==="tableRow"?_:c;return X===_&&o.parser.lazy[o.now().line]?n(I):X(I)}function c(I){return e.enter("tableHead"),e.enter("tableRow"),l(I)}function l(I){return I===124||(i=!0,a+=1),h(I)}function h(I){return I===null?n(I):ze(I)?a>1?(a=0,o.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(I),e.exit("lineEnding"),y):n(I):Xe(I)?nt(e,h,"whitespace")(I):(a+=1,i&&(i=!1,r+=1),I===124?(e.enter("tableCellDivider"),e.consume(I),e.exit("tableCellDivider"),i=!0,h):(e.enter("data"),u(I)))}function u(I){return I===null||I===124||mt(I)?(e.exit("data"),h(I)):(e.consume(I),I===92?f:u)}function f(I){return I===92||I===124?(e.consume(I),u):u(I)}function y(I){return o.interrupt=!1,o.parser.lazy[o.now().line]?n(I):(e.enter("tableDelimiterRow"),i=!1,Xe(I)?nt(e,k,"linePrefix",o.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(I):k(I))}function k(I){return I===45||I===58?w(I):I===124?(i=!0,e.enter("tableCellDivider"),e.consume(I),e.exit("tableCellDivider"),x):C(I)}function x(I){return Xe(I)?nt(e,w,"whitespace")(I):w(I)}function w(I){return I===58?(a+=1,i=!0,e.enter("tableDelimiterMarker"),e.consume(I),e.exit("tableDelimiterMarker"),g):I===45?(a+=1,g(I)):I===null||ze(I)?b(I):C(I)}function g(I){return I===45?(e.enter("tableDelimiterFiller"),M(I)):C(I)}function M(I){return I===45?(e.consume(I),M):I===58?(i=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(I),e.exit("tableDelimiterMarker"),v):(e.exit("tableDelimiterFiller"),v(I))}function v(I){return Xe(I)?nt(e,b,"whitespace")(I):b(I)}function b(I){return I===124?k(I):I===null||ze(I)?!i||r!==a?C(I):(e.exit("tableDelimiterRow"),e.exit("tableHead"),t(I)):C(I)}function C(I){return n(I)}function _(I){return e.enter("tableRow"),S(I)}function S(I){return I===124?(e.enter("tableCellDivider"),e.consume(I),e.exit("tableCellDivider"),S):I===null||ze(I)?(e.exit("tableRow"),t(I)):Xe(I)?nt(e,S,"whitespace")(I):(e.enter("data"),A(I))}function A(I){return I===null||I===124||mt(I)?(e.exit("data"),S(I)):(e.consume(I),I===92?P:A)}function P(I){return I===92||I===124?(e.consume(I),A):A(I)}}function EQe(e,t){let n=-1,o=!0,r=0,a=[0,0,0,0],i=[0,0,0,0],s=!1,c=0,l,h,u;const f=new SQe;for(;++n<e.length;){const y=e[n],k=y[1];y[0]==="enter"?k.type==="tableHead"?(s=!1,c!==0&&(iG(f,t,c,l,h),h=void 0,c=0),l={type:"table",start:Object.assign({},k.start),end:Object.assign({},k.end)},f.add(n,0,[["enter",l,t]])):k.type==="tableRow"||k.type==="tableDelimiterRow"?(o=!0,u=void 0,a=[0,0,0,0],i=[0,n+1,0,0],s&&(s=!1,h={type:"tableBody",start:Object.assign({},k.start),end:Object.assign({},k.end)},f.add(n,0,[["enter",h,t]])),r=k.type==="tableDelimiterRow"?2:h?3:1):r&&(k.type==="data"||k.type==="tableDelimiterMarker"||k.type==="tableDelimiterFiller")?(o=!1,i[2]===0&&(a[1]!==0&&(i[0]=i[1],u=yp(f,t,a,r,void 0,u),a=[0,0,0,0]),i[2]=n)):k.type==="tableCellDivider"&&(o?o=!1:(a[1]!==0&&(i[0]=i[1],u=yp(f,t,a,r,void 0,u)),a=i,i=[a[1],n,0,0])):k.type==="tableHead"?(s=!0,c=n):k.type==="tableRow"||k.type==="tableDelimiterRow"?(c=n,a[1]!==0?(i[0]=i[1],u=yp(f,t,a,r,n,u)):i[1]!==0&&(u=yp(f,t,i,r,n,u)),r=0):r&&(k.type==="data"||k.type==="tableDelimiterMarker"||k.type==="tableDelimiterFiller")&&(i[3]=n)}for(c!==0&&iG(f,t,c,l,h),f.consume(t.events),n=-1;++n<t.events.length;){const y=t.events[n];y[0]==="enter"&&y[1].type==="table"&&(y[1]._align=IQe(t.events,n))}return e}function yp(e,t,n,o,r,a){const i=o===1?"tableHeader":o===2?"tableDelimiter":"tableData",s="tableContent";n[0]!==0&&(a.end=Object.assign({},Qd(t.events,n[0])),e.add(n[0],0,[["exit",a,t]]));const c=Qd(t.events,n[1]);if(a={type:i,start:Object.assign({},c),end:Object.assign({},c)},e.add(n[1],0,[["enter",a,t]]),n[2]!==0){const l=Qd(t.events,n[2]),h=Qd(t.events,n[3]),u={type:s,start:Object.assign({},l),end:Object.assign({},h)};if(e.add(n[2],0,[["enter",u,t]]),o!==2){const f=t.events[n[2]],y=t.events[n[3]];if(f[1].end=Object.assign({},y[1].end),f[1].type="chunkText",f[1].contentType="text",n[3]>n[2]+1){const k=n[2]+1,x=n[3]-n[2]-1;e.add(k,x,[])}}e.add(n[3]+1,0,[["exit",u,t]])}return r!==void 0&&(a.end=Object.assign({},Qd(t.events,r)),e.add(r,0,[["exit",a,t]]),a=void 0),a}function iG(e,t,n,o,r){const a=[],i=Qd(t.events,n);r&&(r.end=Object.assign({},i),a.push(["exit",r,t])),o.end=Object.assign({},i),a.push(["exit",o,t]),e.add(n+1,0,a)}function Qd(e,t){const n=e[t],o=n[0]==="enter"?"start":"end";return n[1][o]}const $Qe={name:"tasklistCheck",tokenize:jQe};function PQe(){return{text:{91:$Qe}}}function jQe(e,t,n){const o=this;return r;function r(c){return o.previous!==null||!o._gfmTasklistFirstContentOfListItem?n(c):(e.enter("taskListCheck"),e.enter("taskListCheckMarker"),e.consume(c),e.exit("taskListCheckMarker"),a)}function a(c){return mt(c)?(e.enter("taskListCheckValueUnchecked"),e.consume(c),e.exit("taskListCheckValueUnchecked"),i):c===88||c===120?(e.enter("taskListCheckValueChecked"),e.consume(c),e.exit("taskListCheckValueChecked"),i):n(c)}function i(c){return c===93?(e.enter("taskListCheckMarker"),e.consume(c),e.exit("taskListCheckMarker"),e.exit("taskListCheck"),s):n(c)}function s(c){return ze(c)?t(c):Xe(c)?e.check({tokenize:zQe},t,n)(c):n(c)}}function zQe(e,t,n){return nt(e,o,"whitespace");function o(r){return r===null?n(r):t(r)}}function RQe(e){return zne([sQe(),kQe(),CQe(e),NQe(),PQe()])}const TQe={};function DQe(e){const t=this,n=e||TQe,o=t.data(),r=o.micromarkExtensions||(o.micromarkExtensions=[]),a=o.fromMarkdownExtensions||(o.fromMarkdownExtensions=[]),i=o.toMarkdownExtensions||(o.toMarkdownExtensions=[]);r.push(RQe(n)),a.push(oQe()),i.push(rQe(n))}function HQe({flowId:e,node:t,connector:n,adapter:o,onNameChange:r,onDescriptionChange:a,onDetailChange:i,onIconChange:s,statusReport:c,onClose:l}){const h=(t==null?void 0:t.type)==="text",u=(t==null?void 0:t.type)==="ellipse"||(t==null?void 0:t.type)==="sticky",f=h?null:t,y=f!==null||n!==null,k=f&&"name"in f.data?f.data.name??"":"",x=(f==null?void 0:f.data.description)??"",w=(f==null?void 0:f.data.detail)??"",g=f!==null&&!u,M=f!==null&&(f.type==="rectangle"||f.type==="component"),v=M&&typeof s=="function",b=M&&f&&"icon"in f.data?f.data.icon??null:null,[C,_]=m.useState(()=>zRe()),S=P=>{P.preventDefault(),TRe(C,P.clientX,{onWidth:_,onCommit:RRe})},A={"--detail-panel-w":`${C}px`,borderLeftWidth:"var(--detail-panel-border-left)",boxShadow:"var(--detail-panel-shadow)"};return p.jsx(zUe,{open:y,modal:!1,onOpenChange:P=>{P||l()},children:p.jsxs(ine,{side:"right",className:"sf:w-full! sf:max-w-full! sf:overflow-y-auto sf:bg-card/94 sf:backdrop-blur-[14px] sf:border-border sf:sm:w-(--detail-panel-w)! sf:sm:max-w-(--detail-panel-w)!",style:A,"data-testid":"detail-panel",onEscapeKeyDown:P=>{var $;const I=document.activeElement;($=I==null?void 0:I.getAttribute("data-testid"))!=null&&$.endsWith("-editor")&&P.preventDefault()},onInteractOutside:P=>{var N;const I=document.activeElement;(N=I==null?void 0:I.getAttribute("data-testid"))!=null&&N.endsWith("-editor")&&I.blur();const $=P.target;$!=null&&$.closest(".react-flow__resize-control")&&P.preventDefault(),$!=null&&$.closest("[data-radix-popper-content-wrapper]")&&P.preventDefault(),$!=null&&$.closest('[data-testid="canvas-style-strip"]')&&P.preventDefault(),$!=null&&$.closest(".react-flow__node")&&P.preventDefault(),$!=null&&$.closest(".react-flow__edge")&&P.preventDefault()},children:[p.jsx("div",{"aria-label":"Resize detail panel",onPointerDown:S,"data-testid":"detail-panel-resize-handle",className:"sf:absolute sf:inset-y-0 sf:left-0 sf:z-10 sf:hidden sf:w-1.5 sf:cursor-col-resize sf:bg-transparent sf:transition-colors sf:hover:bg-border sf:sm:block"}),f?p.jsxs("div",{className:"sf:flex sf:flex-col sf:gap-4",children:[p.jsxs("div",{className:"sf:-mx-6 sf:-mt-6 sf:flex sf:flex-col sf:border-b sf:border-border/60 sf:bg-card/60 sf:px-6 sf:pb-2.5 sf:pt-3 sf:pr-12",children:[g?p.jsx(VP,{"data-testid":"detail-panel-title",children:p.jsxs("div",{className:"sf:flex sf:items-center sf:gap-2",children:[v&&s?p.jsx(qQe,{nodeId:f.id,icon:b,onChange:s}):M&&b?p.jsx("span",{"data-testid":"detail-panel-icon-readonly","aria-hidden":!0,className:"sf:inline-flex sf:h-7 sf:w-7 sf:shrink-0 sf:items-center sf:justify-center sf:text-foreground/90",children:p.jsx(n0,{name:b,size:16})}):null,p.jsx("div",{className:"sf:min-w-0 sf:flex-1",children:p.jsx(TT,{nodeId:f.id,value:k,placeholder:"Name",multiline:!1,ariaLabel:"Name",testIdBase:"detail-panel-name",onSave:r,textClassName:"sf:text-lg sf:font-semibold sf:tracking-tight sf:text-foreground/95"})})]})}):p.jsx(VP,{"data-testid":"detail-panel-title",className:"sf:sr-only",children:f.id}),p.jsxs(NH,{className:"sf:sr-only",children:[f.id," · ",f.type]})]}),p.jsxs("div",{className:"sf:mt-0 sf:flex sf:flex-col sf:gap-3",children:[c?p.jsx(BQe,{report:c}):null,p.jsx(TT,{nodeId:f.id,value:x,placeholder:"Short description shown on the node body",multiline:!0,ariaLabel:"Description",testIdBase:"detail-panel-description",onSave:a,textClassName:"sf:text-[13px] sf:leading-relaxed sf:text-muted-foreground"}),p.jsx(TT,{nodeId:f.id,value:w,placeholder:"Long-form notes, context, anything…",multiline:!0,ariaLabel:"Detail",testIdBase:"detail-panel-detail",onSave:i,markdown:!0,textClassName:"sf:text-sm sf:leading-relaxed sf:text-foreground/90"}),f.type==="html"&&e?p.jsx(OQe,{adapter:o,nodeId:f.id,htmlPath:"view.html"}):null]})]}):n?p.jsxs("div",{className:"sf:flex sf:flex-col sf:gap-4",children:[p.jsxs("div",{className:"sf:-mx-6 sf:-mt-6 sf:flex sf:flex-col sf:border-b sf:border-border/60 sf:bg-card/60 sf:px-6 sf:pb-2.5 sf:pt-3 sf:pr-12",children:[p.jsx(VP,{"data-testid":"detail-panel-title",className:"sf:text-lg sf:font-semibold sf:tracking-tight sf:text-foreground/95",children:n.label??"Connector"}),p.jsx(NH,{className:"sf:sr-only",children:n.id})]}),p.jsx("div",{className:"sf:mt-0 sf:flex sf:flex-col sf:gap-3",children:p.jsx(UQe,{connector:n})})]}):null]})})}function TT({nodeId:e,value:t,placeholder:n,multiline:o,ariaLabel:r,testIdBase:a,onSave:i,textClassName:s,markdown:c=!1}){const[l,h]=m.useState(!1),u=m.useRef(null),f=m.useRef(!1);m.useEffect(()=>{if(!l)return;const C=u.current;if(!C)return;C.textContent=t,C.focus();const _=window.getSelection();if(_){const S=document.createRange();S.selectNodeContents(C),S.collapse(!1),_.removeAllRanges(),_.addRange(S)}},[l,t]);const y=t==="";if(!i)return p.jsx("div",{"data-testid":a,"aria-label":r,className:ae("sf:w-full sf:rounded-md sf:px-2 sf:py-1.5 sf:text-sm",y?"sf:italic sf:text-muted-foreground/50":"text-foreground",!c&&"sf:whitespace-pre-wrap sf:wrap-break-word",s),children:y?n:c?p.jsx(sG,{value:t}):t});const k=()=>{const C=u.current,_=C?o?C.innerText:C.textContent??"":t;i(e,_),h(!1)},x=()=>{h(!1)},w=C=>{if(C.stopPropagation(),C.nativeEvent.stopPropagation(),C.key==="Escape"){C.preventDefault(),f.current=!0,x();return}if(C.key==="Enter"){if(C.preventDefault(),C.shiftKey||!o){k();return}document.execCommand("insertText",!1,`
8541
8541
  `)}},g=C=>{C.preventDefault();const _=C.clipboardData.getData("text/plain");document.execCommand("insertText",!1,_)},M=C=>{},v=()=>{if(f.current){f.current=!1;return}k()},b=()=>{l||h(!0)};return p.jsx("div",{className:"relative","data-testid":a,"data-editing":l?"true":"false",children:l?p.jsx("div",{ref:u,contentEditable:"plaintext-only",suppressContentEditableWarning:!0,spellCheck:!1,tabIndex:0,onKeyDown:w,onPaste:g,onInput:M,onBlur:v,"data-testid":`${a}-editor`,className:ae("sf:block sf:w-full sf:whitespace-pre-wrap sf:wrap-break-word sf:rounded-md sf:px-2 sf:py-1.5 sf:text-sm sf:outline-hidden",s),role:"textbox","aria-multiline":o?"true":"false","aria-label":r}):p.jsx("button",{type:"button",onClick:b,"aria-label":`Edit ${r.toLowerCase()}`,className:ae("sf:block sf:w-full sf:cursor-text sf:rounded-md sf:px-2 sf:py-1.5 sf:text-left sf:text-sm sf:transition-colors sf:hover:bg-muted/50",y?"sf:italic sf:text-muted-foreground/50":"text-foreground",!c&&"sf:whitespace-pre-wrap sf:wrap-break-word",s),children:y?n:c?p.jsx(sG,{value:t}):t})})}function qQe({nodeId:e,icon:t,onChange:n}){const[o,r]=m.useState(!1);return p.jsx(EO,{open:o,onOpenChange:r,onPick:a=>{n(e,a),r(!1)},anchor:p.jsx("button",{type:"button","data-testid":"detail-panel-icon-trigger","aria-label":t?"Change icon":"Add icon","aria-pressed":o,className:ae("sf:inline-flex sf:h-7 sf:w-7 sf:shrink-0 sf:items-center sf:justify-center sf:rounded-md sf:text-foreground sf:transition-colors",t?"sf:hover:bg-muted":"sf:border sf:border-dashed sf:border-muted-foreground/40 sf:text-muted-foreground/60 sf:hover:border-muted-foreground sf:hover:text-foreground","sf:focus-visible:outline-hidden sf:focus-visible:ring-2 sf:focus-visible:ring-ring sf:focus-visible:ring-offset-1"),children:t?p.jsx(n0,{name:t,size:16,"aria-hidden":!0}):p.jsx(_2,{className:"sf:h-4 sf:w-4","aria-hidden":!0})})})}function OQe({adapter:e,nodeId:t,htmlPath:n}){const[o,r]=m.useState({kind:"idle"}),a=typeof(e==null?void 0:e.openFile)=="function",i=typeof(e==null?void 0:e.revealFile)=="function",s=`nodes/${t}/${n}`,c=async l=>{var h,u;r({kind:"pending"});try{l==="open"?await((h=e==null?void 0:e.openFile)==null?void 0:h.call(e,s)):await((u=e==null?void 0:e.revealFile)==null?void 0:u.call(e,s)),r({kind:"idle"})}catch(f){r({kind:"error",message:f instanceof Error?f.message:String(f)})}};return p.jsxs("div",{className:"sf:flex sf:flex-col sf:gap-2 sf:rounded-md sf:border sf:bg-card sf:px-3 sf:py-2 sf:text-xs","data-testid":"detail-panel-html-node",children:[p.jsxs("div",{className:"sf:flex sf:flex-col sf:gap-1",children:[p.jsx("span",{className:"sf:font-mono sf:text-[11px] sf:text-muted-foreground sf:uppercase sf:tracking-widest",children:"Path"}),p.jsx("code",{"data-testid":"detail-panel-html-path",className:"sf:block sf:break-all sf:rounded sf:bg-muted/40 sf:px-2 sf:py-1 sf:font-mono sf:text-[11px]",children:n})]}),a||i?p.jsxs("div",{className:"sf:flex sf:flex-wrap sf:items-center sf:gap-2",children:[a?p.jsxs(qt,{type:"button",size:"sm",variant:"outline",className:"sf:h-7 sf:gap-1.5 sf:px-2",onClick:()=>{c("open")},disabled:o.kind==="pending","data-testid":"detail-panel-html-open","aria-label":"Open in editor",children:[p.jsx(A2,{className:"sf:h-3.5 sf:w-3.5"}),"Open in editor"]}):null,i?p.jsxs(qt,{type:"button",size:"sm",variant:"outline",className:"sf:h-7 sf:gap-1.5 sf:px-2",onClick:()=>{c("reveal")},disabled:o.kind==="pending","data-testid":"detail-panel-html-reveal","aria-label":"Reveal in Finder/Explorer",children:[p.jsx(M2,{className:"sf:h-3.5 sf:w-3.5"}),"Reveal"]}):null]}):null,o.kind==="error"?p.jsx("div",{"data-testid":"detail-panel-html-status","data-status":o.kind,className:ae("sf:text-[11px] sf:text-destructive"),children:o.message??""}):null]})}function FQe(e,t){const n=Math.max(0,t-e);if(n<1e3)return"just now";const o=Math.floor(n/1e3);if(o<60)return`${o}s ago`;const r=Math.floor(o/60);if(r<60)return`${r}m ago`;const a=Math.floor(r/60);return a<24?`${a}h ago`:`${Math.floor(a/24)}d ago`}function VQe(e){if(e===null)return"null";if(e===void 0)return"undefined";if(typeof e=="string")return e;try{return JSON.stringify(e)}catch{return String(e)}}function BQe({report:e,now:t=Date.now()}){const n=e.data?Object.entries(e.data):[];return p.jsxs("section",{className:"sf:flex sf:flex-col sf:gap-2 sf:rounded-md sf:border sf:bg-card sf:px-3 sf:py-2 sf:text-xs","data-testid":"detail-panel-status","data-state":e.state,children:[p.jsxs("div",{className:"sf:flex sf:items-center sf:justify-between sf:gap-2",children:[p.jsx(jO,{state:e.state,summary:e.summary,"data-testid":"detail-panel-status-badge"}),p.jsx("span",{className:"sf:shrink-0 sf:text-[10px] sf:text-muted-foreground","data-testid":"detail-panel-status-relative-time",children:`Last updated: ${FQe(e.ts,t)}`})]}),e.detail?p.jsx("div",{"data-testid":"detail-panel-status-detail",className:"sf:whitespace-pre-wrap sf:wrap-break-word sf:rounded sf:bg-muted/40 sf:px-2 sf:py-1 sf:text-[11px] sf:text-foreground",children:e.detail}):null,n.length>0?p.jsx("dl",{"data-testid":"detail-panel-status-data",className:"sf:grid sf:grid-cols-[auto_1fr] sf:gap-x-3 sf:gap-y-1 sf:text-[11px]",children:n.map(([o,r])=>p.jsxs("div",{className:"contents","data-testid":"detail-panel-status-data-row",children:[p.jsx("dt",{className:"sf:truncate sf:font-medium sf:text-muted-foreground",children:o}),p.jsx("dd",{className:"sf:break-all sf:font-mono sf:text-foreground",children:VQe(r)})]},o))}):null]})}function sG({value:e}){return p.jsx(CXe,{remarkPlugins:[DQe],components:{h1:({children:t})=>p.jsx("h1",{className:"sf:mb-1 sf:text-base sf:font-bold sf:leading-snug",children:t}),h2:({children:t})=>p.jsx("h2",{className:"sf:mb-1 sf:text-sm sf:font-semibold sf:leading-snug",children:t}),h3:({children:t})=>p.jsx("h3",{className:"sf:mb-0.5 sf:text-sm sf:font-medium sf:leading-snug",children:t}),p:({children:t})=>p.jsx("p",{className:"sf:mb-2 sf:last:mb-0 sf:leading-relaxed",children:t}),ul:({children:t})=>p.jsx("ul",{className:"sf:mb-2 sf:list-disc sf:pl-4 sf:last:mb-0",children:t}),ol:({children:t})=>p.jsx("ol",{className:"sf:mb-2 sf:list-decimal sf:pl-4 sf:last:mb-0",children:t}),li:({children:t})=>p.jsx("li",{className:"mb-0.5",children:t}),code:({children:t,className:n})=>(n==null?void 0:n.includes("language-"))?p.jsx("code",{className:"sf:block sf:overflow-x-auto sf:rounded sf:bg-muted/60 sf:px-2 sf:py-1 sf:font-mono sf:text-xs",children:t}):p.jsx("code",{className:"sf:rounded sf:bg-muted/60 sf:px-1 sf:py-0.5 sf:font-mono sf:text-xs",children:t}),pre:({children:t})=>p.jsx("pre",{className:"sf:mb-2 sf:last:mb-0",children:t}),blockquote:({children:t})=>p.jsx("blockquote",{className:"sf:mb-2 sf:border-l-2 sf:border-muted-foreground/30 sf:pl-3 sf:italic sf:text-muted-foreground sf:last:mb-0",children:t}),a:({href:t,children:n})=>p.jsx("a",{href:t,target:"_blank",rel:"noreferrer",className:"sf:text-primary sf:underline sf:underline-offset-2",children:n}),strong:({children:t})=>p.jsx("strong",{className:"font-semibold",children:t}),em:({children:t})=>p.jsx("em",{className:"italic",children:t}),hr:()=>p.jsx("hr",{className:"sf:my-2 sf:border-border"}),table:({children:t})=>p.jsx("div",{className:"sf:mb-2 sf:overflow-x-auto sf:last:mb-0",children:p.jsx("table",{className:"sf:w-full sf:border-collapse sf:text-xs",children:t})}),th:({children:t})=>p.jsx("th",{className:"sf:border sf:border-border sf:bg-muted/40 sf:px-2 sf:py-1 sf:text-left sf:font-medium",children:t}),td:({children:t})=>p.jsx("td",{className:"sf:border sf:border-border sf:px-2 sf:py-1",children:t})},children:e})}function UQe({connector:e}){return p.jsx("div",{className:"sf:rounded-md sf:border sf:bg-card sf:px-3 sf:py-2 sf:text-xs",children:p.jsxs("dl",{className:"divide-y",children:[p.jsx(sa,{label:"Source",value:e.source}),p.jsx(sa,{label:"Target",value:e.target}),e.label?p.jsx(sa,{label:"Label",value:e.label}):null,e.style?p.jsx(sa,{label:"Style",value:e.style}):null,e.color?p.jsx(sa,{label:"Color",value:e.color}):null,e.direction?p.jsx(sa,{label:"Direction",value:e.direction}):null,e.url?p.jsx(sa,{label:"URL",value:`${e.method??"GET"} ${e.url}`}):null,e.eventName?p.jsx(sa,{label:"Event",value:e.eventName}):null,e.queueName?p.jsx(sa,{label:"Queue",value:e.queueName}):null]})})}function sa({label:e,value:t}){return p.jsxs("div",{className:"sf:flex sf:items-start sf:gap-3 sf:py-2 sf:first:pt-0 sf:last:pb-0",children:[p.jsx("dt",{className:"sf:w-20 sf:shrink-0 sf:font-medium sf:text-muted-foreground",children:e}),p.jsx("dd",{className:"sf:flex-1 sf:break-all sf:font-mono",children:t})]})}const WQe="https://seeflow.dev/embed",GQe=(e,t)=>{const n=`${WQe}/${encodeURIComponent(e)}`;return t?`${n}?theme=${t}`:n},ZQe=e=>{var t,n;return(n=(t=e==null?void 0:e.documentElement)==null?void 0:t.classList)!=null&&n.contains("dark")?"dark":"light"},KQe=e=>e.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;"),XQe=e=>[`<iframe src="${KQe(e)}"`,' width="100%"',' height="600"',' style="border:0"',' allow="fullscreen"',' loading="lazy"></iframe>'].join(`
8542
8542
  `),YQe="Embed this canvas",QQe="Paste this iframe into any page to embed the canvas.",JQe="Copy snippet",eJe="Copied!",tJe="Press ⌘C to copy",nJe="Close",oJe="Theme",rJe=1500,aJe=[{value:"match",label:"Match my theme"},{value:"light",label:"Light"},{value:"dark",label:"Dark"}],iJe=e=>e==="light"?"light":e==="dark"?"dark":ZQe(typeof document<"u"?document:null);function sJe({open:e,onOpenChange:t,projectId:n}){const[o,r]=m.useState("idle"),[a,i]=m.useState("match"),s=m.useRef(null),c=m.useMemo(()=>XQe(GQe(n,iJe(a))),[n,a]),l=m.useCallback(async()=>{try{await navigator.clipboard.writeText(c),r("copied"),setTimeout(()=>r("idle"),rJe)}catch{r("fallback");const h=s.current;h&&(h.focus(),h.select())}},[c]);return p.jsx(Wz,{open:e,onOpenChange:t,children:p.jsxs(ef,{"data-testid":"embed-dialog-content",children:[p.jsxs(tf,{children:[p.jsx(nf,{children:YQe}),p.jsx(of,{children:QQe})]}),p.jsxs("fieldset",{className:"sf:flex sf:flex-col sf:gap-2 sf:border-0 sf:p-0",children:[p.jsx("legend",{id:"embed-dialog-theme-label",className:"sf:mb-2 sf:text-xs sf:font-medium sf:text-foreground",children:oJe}),p.jsx("div",{"data-testid":"embed-dialog-theme-group",className:"sf:inline-flex sf:self-start sf:rounded-md sf:border sf:border-input sf:bg-background sf:p-0.5",children:aJe.map(h=>{const u=a===h.value;return p.jsx("button",{type:"button","aria-pressed":u,"aria-label":h.label,"data-testid":`embed-dialog-theme-${h.value}`,"data-active":u,onClick:()=>i(h.value),className:ae("sf:rounded sf:px-3 sf:py-1 sf:text-xs sf:transition-colors sf:focus-visible:outline-hidden sf:focus-visible:ring-1 sf:focus-visible:ring-ring",u?"sf:bg-secondary sf:text-secondary-foreground sf:shadow-sm":"sf:text-muted-foreground sf:hover:bg-accent sf:hover:text-accent-foreground"),children:h.label},h.value)})})]}),p.jsx("textarea",{ref:s,"data-testid":"embed-dialog-snippet",readOnly:!0,rows:7,value:c,spellCheck:!1,onFocus:h=>h.currentTarget.select(),className:"sf:w-full sf:resize-none sf:rounded-md sf:border sf:border-border sf:bg-background sf:p-3 sf:font-mono sf:text-xs sf:leading-relaxed sf:text-foreground sf:focus:outline-hidden sf:focus:ring-2 sf:focus:ring-ring"}),o==="fallback"?p.jsx("p",{"data-testid":"embed-dialog-fallback-hint",className:"sf:text-xs sf:text-muted-foreground",children:tJe}):null,p.jsxs(a0,{children:[p.jsx(qt,{variant:"outline","data-testid":"embed-dialog-close",onClick:()=>t(!1),children:nJe}),p.jsx(qt,{"data-testid":"embed-dialog-copy",onClick:l,children:o==="copied"?eJe:JQe})]})]})})}const cG="Share / download",cJe="Download PDF",lJe="Download PNG",dJe="Embed",uJe="Export to seeflow.dev";function hJe({mode:e,projectId:t,enableEmbed:n,onDownloadPdf:o,onDownloadPng:r,onExportToCloud:a,embedOpen:i,onEmbedOpenChange:s}){const[c,l]=m.useState(!1),[h,u]=m.useState(!1),[f,y]=m.useState(!1),k=i!==void 0,x=k?i:f,w=m.useCallback(S=>{k||y(S),s==null||s(S)},[k,s]),g=m.useCallback(()=>{!o||c||(l(!0),Promise.resolve(o()).finally(()=>l(!1)))},[o,c]),M=m.useCallback(()=>{!r||h||(u(!0),Promise.resolve(r()).finally(()=>u(!1)))},[r,h]),v=!!o,b=!!r,C=n&&typeof t=="string"&&t.length>0,_=e==="edit"&&!!a;return!v&&!b&&!C&&!_?null:p.jsxs(p.Fragment,{children:[p.jsxs(Fte,{children:[p.jsx(Vte,{asChild:!0,children:p.jsx("button",{type:"button","data-testid":"share-menu-trigger","aria-label":cG,title:cG,className:ae("sf:inline-flex sf:h-8 sf:w-8 sf:items-center sf:justify-center sf:rounded-md sf:border sf:border-border sf:bg-background/95 sf:text-muted-foreground sf:shadow-md sf:backdrop-blur-sm sf:transition-colors","sf:hover:bg-accent sf:hover:text-accent-foreground","sf:focus-visible:outline-hidden sf:focus-visible:ring-2 sf:focus-visible:ring-ring"),children:p.jsx(z2,{className:"sf:h-4 sf:w-4","aria-hidden":"true"})})}),p.jsxs(GO,{align:"end","data-testid":"share-menu-content",onCloseAutoFocus:S=>{S.preventDefault()},children:[v?p.jsxs(a2,{"data-testid":"share-menu-pdf",disabled:c,onSelect:S=>{S.preventDefault(),g()},children:[c?p.jsx(Er,{className:"sf:h-4 sf:w-4 sf:animate-spin","aria-hidden":"true"}):p.jsx(w2,{className:"sf:h-4 sf:w-4","aria-hidden":"true"}),p.jsx("span",{children:cJe})]}):null,b?p.jsxs(a2,{"data-testid":"share-menu-png",disabled:h,onSelect:S=>{S.preventDefault(),M()},children:[h?p.jsx(Er,{className:"sf:h-4 sf:w-4 sf:animate-spin","aria-hidden":"true"}):p.jsx(C2,{className:"sf:h-4 sf:w-4","aria-hidden":"true"}),p.jsx("span",{children:lJe})]}):null,C?p.jsxs(a2,{"data-testid":"share-menu-embed",onSelect:S=>{S.preventDefault(),w(!0)},children:[p.jsx(wu,{className:"sf:h-4 sf:w-4","aria-hidden":"true"}),p.jsx("span",{children:dJe})]}):null,_?p.jsxs(a2,{"data-testid":"share-menu-export-cloud",onSelect:()=>{a==null||a()},children:[p.jsx(T2,{className:"sf:h-4 sf:w-4","aria-hidden":"true"}),p.jsx("span",{children:uJe})]}):null]})]}),C&&t?p.jsx(sJe,{open:x,onOpenChange:w,projectId:t}):null]})}function fJe({onRestartDemo:e}){const[t,n]=m.useState(!1),o=m.useCallback(()=>{t||(n(!0),Promise.resolve(e()).finally(()=>{n(!1)}))},[e,t]);return p.jsxs(lf,{children:[p.jsx(df,{asChild:!0,children:p.jsx(qt,{"data-testid":"header-restart-demo",type:"button",variant:"ghost",size:"icon","aria-label":"Restart demo",title:"Restart demo",disabled:t,onClick:o,className:"sf:h-8 sf:w-8",children:t?p.jsx(Er,{className:"sf:h-4 sf:w-4 sf:animate-spin","aria-hidden":"true"}):p.jsx(E2,{className:"sf:h-4 sf:w-4","aria-hidden":"true"})})}),p.jsx(b0,{side:"bottom",children:"Restart demo"})]})}const pJe=8;function yJe(e){let t=Number.POSITIVE_INFINITY,n=Number.POSITIVE_INFINITY,o=Number.NEGATIVE_INFINITY,r=Number.NEGATIVE_INFINITY,a=!1;for(const i of e){const s=i.data.width,c=i.data.height;s===void 0||c===void 0||(a=!0,i.position.x<t&&(t=i.position.x),i.position.y<n&&(n=i.position.y),i.position.x+s>o&&(o=i.position.x+s),i.position.y+c>r&&(r=i.position.y+c))}return a?{x:t,y:n,width:o-t,height:r-n}:null}function mJe(e){return e.length>=2}function kJe({selectedNodes:e,onMultiResize:t,paddingPx:n=pJe}){Sz();const[o,r]=m.useState(null),[a,i]=m.useState(null);if(m.useRef(!1),m.useRef(null),!mJe(e))return null;const s=yJe(e);if(!s)return null;const c=a??s;return c.x-n,c.y-n,c.width+n*2,c.height+n*2,null}const lG=22,dG=11,uG=3,hG=2,DT=8,HT=1,fG=["none","default","slate","gray","red","rose","orange","amber","lime","green","teal","cyan","blue","indigo","violet","purple","pink"],mp=[{value:"solid",icon:Bj,label:"Solid",testId:"style-tab-border-style-solid"},{value:"dashed",icon:nne,label:"Dashed",testId:"style-tab-border-style-dashed"},{value:"dotted",icon:one,label:"Dotted",testId:"style-tab-border-style-dotted"}],pG=[{value:"solid",icon:Bj,label:"Solid",testId:"style-tab-edge-style-solid"},{value:"dashed",icon:nne,label:"Dashed",testId:"style-tab-edge-style-dashed"},{value:"dotted",icon:one,label:"Dotted",testId:"style-tab-edge-style-dotted"}],yG=[{value:"curve",icon:rne,label:"Curve",testId:"style-tab-edge-path-curve"},{value:"step",icon:jUe,label:"Zigzag",testId:"style-tab-edge-path-step"}],mG=[{value:"none",icon:L2,label:"None",testId:"style-tab-direction-none"},{value:"backward",icon:N2,label:"Backward",testId:"style-tab-direction-backward"},{value:"forward",icon:xu,label:"Forward",testId:"style-tab-direction-forward"},{value:"both",icon:m2,label:"Both",testId:"style-tab-direction-both"}];function gJe({nodes:e,connectors:t,onStyleNode:n,onStyleNodePreview:o,onStyleNodes:r,onStyleNodesPreview:a,onStyleConnector:i,onStyleConnectorPreview:s,onRequestIconReplace:c}){const l=e.length>0,h=t.length>0;if(!l&&!h)return null;const u=l&&!h,f=!l&&h,y=e[0],k=t[0],x=e.filter(G=>G.type!=="icon"),w=x[0],g=u&&e.every(G=>G.type==="icon"),M=g?e.find(G=>G.type==="icon"):void 0,v=u&&e.every(G=>G.type==="image"),b=u&&(y==null?void 0:y.type)==="text",C=(f?k==null?void 0:k.color:w==null?void 0:w.data.borderColor)??"default",_=(w==null?void 0:w.data.backgroundColor)??"default",S=(w==null?void 0:w.data.borderStyle)??"solid",A=(k==null?void 0:k.style)??"solid",P=(k==null?void 0:k.direction)??"forward",I=(k==null?void 0:k.path)??"curve",$=G=>{for(const ne of e)n(ne.id,{borderColor:G});for(const ne of t)i(ne.id,{color:G})},N=G=>{for(const ne of e)n(ne.id,{backgroundColor:G})},X=G=>{for(const ne of e)n(ne.id,{borderStyle:G});for(const ne of t)i(ne.id,{style:G})},j=G=>{for(const ne of e)n(ne.id,{borderSize:G});for(const ne of t)i(ne.id,{borderSize:G})},O=G=>{for(const ne of e)o==null||o(ne.id,{borderSize:G});for(const ne of t)s==null||s(ne.id,{borderSize:G})},H=G=>{if(e.length>1&&r)r(e.map(ne=>ne.id),{fontSize:G});else for(const ne of e)n(ne.id,{fontSize:G})},B=G=>{if(e.length>1&&a)a(e.map(ne=>ne.id),{fontSize:G});else for(const ne of e)o==null||o(ne.id,{fontSize:G})},z=x.length>1&&new Set(x.map(G=>G.data.fontSize??lG)).size>1,R=G=>{if(e.length>1&&r)r(e.map(ne=>ne.id),{textColor:G});else for(const ne of e)n(ne.id,{textColor:G})},L=(w==null?void 0:w.data.textColor)??(b?(w==null?void 0:w.data.borderColor)??"default":"default"),U=G=>{for(const ne of t)i(ne.id,{fontSize:G})},D=G=>{for(const ne of t)s==null||s(ne.id,{fontSize:G})},E=t.length>1&&new Set(t.map(G=>G.fontSize??dG)).size>1,W=G=>{for(const ne of e)n(ne.id,{cornerRadius:G})},Y=G=>{for(const ne of e)o==null||o(ne.id,{cornerRadius:G})},Q=x.length>1&&new Set(x.map(G=>G.data.cornerRadius??DT)).size>1,oe=G=>{for(const ne of e)n(ne.id,{shadow:G})},te=G=>{for(const ne of e)o==null||o(ne.id,{shadow:G})},se=x.length>1&&new Set(x.map(G=>G.data.shadow??HT)).size>1,we=G=>{for(const ne of t)i(ne.id,{path:G})},ke=G=>{for(const ne of t)i(ne.id,{direction:G})},ge=G=>{for(const ne of e)n(ne.id,{color:G})},ve=(M==null?void 0:M.data.color)??"default",re=f?(k==null?void 0:k.borderSize)??hG:(w==null?void 0:w.data.borderSize)??uG,me=f?hG:uG,Ve=f?"edge":"border",lt=f?"Connector color":b?"Color":"Border color",Vt=f?"connector color":b?"color":"border color",Et=f?"style-tab-edge-color-trigger":b?"style-tab-color-trigger":"style-tab-border-color-trigger",ce=f||b?"style-tab-color":"style-tab-border-color";if(g){const G=!!c&&e.length===1&&!!M,ne=()=>{M&&c&&c(M.id)};return p.jsx(F2,{delayDuration:300,children:p.jsxs("div",{"data-testid":"canvas-style-strip",className:"sf:pointer-events-auto sf:flex sf:flex-col sf:items-center sf:gap-1 sf:rounded-lg sf:border sf:border-border sf:bg-background/95 sf:p-1 sf:shadow-md sf:backdrop-blur",children:[p.jsx(xJe,{testId:"style-strip-icon-color",tooltip:"Icon color",ariaLabel:"icon color",activeToken:ve,previewKind:"edge",tokenTestIdPrefix:"style-tab-icon-color",innerTestId:"style-tab-icon-color-trigger",allowNone:!1,onSelect:ge}),G?p.jsxs(lf,{children:[p.jsx(df,{asChild:!0,children:p.jsx("button",{type:"button","data-testid":"style-strip-change-icon","aria-label":"change icon",title:"Change icon",onClick:ne,className:ae("sf:inline-flex sf:h-8 sf:w-8 sf:items-center sf:justify-center sf:rounded-md sf:text-muted-foreground sf:transition-colors sf:hover:bg-accent sf:hover:text-accent-foreground","sf:focus-visible:outline-hidden sf:focus-visible:ring-2 sf:focus-visible:ring-ring sf:focus-visible:ring-offset-1"),children:p.jsx(bu,{className:"sf:h-4 sf:w-4"})})}),p.jsx(b0,{side:"right",className:"sf:px-2 sf:py-1 sf:text-xs",children:"Change icon"})]}):null]})})}if(v){const G=e[0],ne=(G==null?void 0:G.data.borderColor)??"default",Ie=(G==null?void 0:G.data.borderStyle)??"solid",De=(G==null?void 0:G.data.borderWidth)??1,Ke=dt=>{for(const Mt of e)n(Mt.id,{borderColor:dt})},Bt=dt=>{for(const Mt of e)n(Mt.id,{borderStyle:dt})},bn=dt=>{for(const Mt of e)n(Mt.id,{borderWidth:dt})},Qe=dt=>{for(const Mt of e)o==null||o(Mt.id,{borderWidth:dt})},ft=dt=>{for(const Mt of e)n(Mt.id,{cornerRadius:dt})},_n=dt=>{for(const Mt of e)o==null||o(Mt.id,{cornerRadius:dt})},Rt=dt=>{for(const Mt of e)n(Mt.id,{shadow:dt})},Cn=dt=>{for(const Mt of e)o==null||o(Mt.id,{shadow:dt})},an=()=>{const dt=ne==="none";return p.jsx("span",{className:ae("sf:relative sf:h-5 sf:w-5 sf:rounded-full",dt&&"sf:bg-card"),style:dt?void 0:W2(ne),children:dt?p.jsx(G2,{}):null})};return p.jsx(F2,{delayDuration:300,children:p.jsxs("div",{"data-testid":"canvas-style-strip",className:"sf:pointer-events-auto sf:flex sf:flex-col sf:items-center sf:gap-1 sf:rounded-lg sf:border sf:border-border sf:bg-background/95 sf:p-1 sf:shadow-md sf:backdrop-blur",children:[p.jsx(eo,{testId:"style-strip-image-border-color-button",tooltip:"Border color",ariaLabel:"image border color",renderIcon:an,children:p.jsx(i2,{testId:"style-strip-image-border-color",activeToken:ne,previewKind:"border",tokenTestIdPrefix:"style-tab-image-border-color",innerTestId:"style-tab-image-border-color-trigger",ariaLabel:"image border color",onSelect:Ke})}),p.jsx(eo,{testId:"style-strip-image-corner-radius-button",tooltip:"Corners",ariaLabel:"image corners",renderIcon:()=>p.jsx(Mu,{className:"sf:h-4 sf:w-4"}),children:p.jsx("div",{"data-testid":"style-strip-image-corner-radius",children:p.jsx(Vi,{value:G==null?void 0:G.data.cornerRadius,defaultValue:DT,min:0,max:32,suffix:"px",onPreview:_n,onCommit:ft,testId:"style-tab-image-corner-radius-slider"})})}),p.jsx(eo,{testId:"style-strip-image-shadow-button",tooltip:"Shadow",ariaLabel:"image shadow",renderIcon:()=>p.jsx(fa,{className:"sf:h-4 sf:w-4"}),children:p.jsx("div",{"data-testid":"style-strip-image-shadow",children:p.jsx(Vi,{value:G==null?void 0:G.data.shadow,defaultValue:HT,min:0,max:5,onPreview:Cn,onCommit:Rt,testId:"style-tab-image-shadow-slider"})})}),p.jsx(eo,{testId:"style-strip-image-border-style",tooltip:"Border style",ariaLabel:"image border style",renderIcon:()=>{var Mt;const dt=((Mt=mp.find(rr=>rr.value===Ie))==null?void 0:Mt.icon)??Bj;return p.jsx(dt,{className:"sf:h-4 sf:w-4"})},children:p.jsx(B0,{ariaLabel:"Border style",value:Ie,onChange:Bt,options:mp})}),p.jsx(eo,{testId:"style-strip-image-border-width",tooltip:"Border width",ariaLabel:"image border width",renderIcon:()=>p.jsx("span",{className:"sf:font-mono sf:text-[10px] sf:tabular-nums",children:De}),children:p.jsx(Vi,{value:G==null?void 0:G.data.borderWidth,defaultValue:1,min:0,max:8,suffix:"px",onPreview:Qe,onCommit:bn,testId:"style-tab-image-border-width-slider"})})]})})}const J=u&&!b,ln=!b,rn=!f,Ee=()=>{const G=C==="none";return p.jsx("span",{className:ae("sf:relative sf:h-5 sf:w-5 sf:rounded-full",G&&"sf:bg-card"),style:G?void 0:W2(C),children:G?p.jsx(G2,{}):null})},Ge=()=>{const G=_==="none";return p.jsx("span",{className:ae("sf:relative sf:h-5 sf:w-5 sf:rounded-full",G&&"sf:bg-card"),style:G?void 0:W2(_),children:G?p.jsx(G2,{}):null})};return p.jsx(F2,{delayDuration:300,children:p.jsxs("div",{"data-testid":"canvas-style-strip",className:"sf:pointer-events-auto sf:flex sf:flex-col sf:items-center sf:gap-1 sf:rounded-lg sf:border sf:border-border sf:bg-background/95 sf:p-1 sf:shadow-md sf:backdrop-blur",children:[b?null:p.jsx(eo,{testId:"style-strip-border-color-button",tooltip:lt,ariaLabel:Vt,renderIcon:Ee,children:p.jsx(i2,{testId:"style-strip-border-color",activeToken:C,previewKind:Ve,tokenTestIdPrefix:ce,innerTestId:Et,ariaLabel:Vt,allowNone:!f,onSelect:$})}),J?p.jsx(eo,{testId:"style-strip-fill-button",tooltip:"Fill",ariaLabel:"fill",renderIcon:Ge,children:p.jsx(i2,{testId:"style-strip-fill",activeToken:_,previewKind:"background",tokenTestIdPrefix:"style-tab-background-color",innerTestId:"style-tab-background-color-trigger",ariaLabel:"fill",onSelect:N})}):null,l?p.jsx(eo,{testId:"style-strip-corner-radius-button",tooltip:"Corners",ariaLabel:"corners",renderIcon:()=>p.jsx(Mu,{className:"sf:h-4 sf:w-4"}),children:p.jsx("div",{"data-testid":"style-strip-corner-radius",children:p.jsx(Vi,{value:w==null?void 0:w.data.cornerRadius,defaultValue:DT,min:0,max:32,suffix:"px",indeterminate:Q,onPreview:Y,onCommit:W,testId:"style-tab-corner-radius-slider"})})}):null,l?p.jsx(eo,{testId:"style-strip-shadow-button",tooltip:"Shadow",ariaLabel:"shadow",renderIcon:()=>p.jsx(fa,{className:"sf:h-4 sf:w-4"}),children:p.jsx("div",{"data-testid":"style-strip-shadow",children:p.jsx(Vi,{value:w==null?void 0:w.data.shadow,defaultValue:HT,min:0,max:5,indeterminate:se,onPreview:te,onCommit:oe,testId:"style-tab-shadow-slider"})})}):null,ln?p.jsx(eo,{testId:"style-strip-border",tooltip:f?"Connector":"Border",ariaLabel:f?"connector":"border",renderIcon:()=>{var ne,Ie;const G=(f?(ne=pG.find(De=>De.value===A))==null?void 0:ne.icon:(Ie=mp.find(De=>De.value===S))==null?void 0:Ie.icon)??Bj;return p.jsx(G,{className:"sf:h-4 sf:w-4"})},children:p.jsxs("div",{className:"sf:flex sf:w-56 sf:flex-col sf:gap-3",children:[p.jsx(kp,{label:"Style",testId:"style-strip-border-style",children:f?p.jsx(B0,{ariaLabel:"Connector style",value:A,onChange:G=>X(G),options:pG}):p.jsx(B0,{ariaLabel:"Border style",value:S,onChange:G=>X(G),options:mp})}),p.jsx(kp,{label:"Width",testId:"style-strip-border-size",children:p.jsx(Vi,{value:re,defaultValue:me,min:0,max:8,suffix:"px",onPreview:O,onCommit:j,testId:f?"style-tab-stroke-width-slider":"style-tab-border-size-slider"})})]})}):null,l||f?p.jsx(eo,{testId:"style-strip-text",tooltip:"Text",ariaLabel:"text",renderIcon:()=>p.jsx(_u,{className:"sf:h-4 sf:w-4"}),children:p.jsxs("div",{className:"sf:flex sf:w-56 sf:flex-col sf:gap-3",children:[p.jsx(kp,{label:"Size",testId:f?"style-strip-connector-font-size":"style-strip-font-size",children:p.jsx(Vi,{value:f?k==null?void 0:k.fontSize:w==null?void 0:w.data.fontSize,defaultValue:f?dG:lG,min:f?8:10,max:32,suffix:"px",indeterminate:f?E:z,onPreview:f?D:B,onCommit:f?U:H,testId:f?"style-tab-connector-font-size-slider":"style-tab-font-size-slider"})}),rn?p.jsx(kp,{label:"Color",children:p.jsx(i2,{testId:"style-strip-text-color",activeToken:L,previewKind:"edge",tokenTestIdPrefix:"style-tab-text-color",innerTestId:"style-tab-text-color-trigger",ariaLabel:"text color",allowNone:!1,onSelect:R})}):null]})}):null,f?p.jsx(eo,{testId:"style-strip-path",tooltip:"Connector path",ariaLabel:"connector path",renderIcon:()=>{var ne;const G=((ne=yG.find(Ie=>Ie.value===I))==null?void 0:ne.icon)??rne;return p.jsx(G,{className:"sf:h-4 sf:w-4"})},children:p.jsx(B0,{ariaLabel:"Connector path",value:I,onChange:we,options:yG})}):null,f?p.jsx(eo,{testId:"style-strip-direction",tooltip:"Direction",ariaLabel:"direction",renderIcon:()=>{var ne;const G=((ne=mG.find(Ie=>Ie.value===P))==null?void 0:ne.icon)??xu;return p.jsx(G,{className:"sf:h-4 sf:w-4"})},children:p.jsx(B0,{ariaLabel:"Connector direction",value:P,onChange:ke,options:mG})}):null]})})}function W2(e){return e==="default"?{backgroundImage:"linear-gradient(to right, hsl(var(--primary)) 0%, hsl(var(--primary)) 50%, hsl(var(--card)) 50%, hsl(var(--card)) 100%)"}:{backgroundColor:dse[e].edge}}function G2(){return p.jsx("span",{"aria-hidden":"true",className:"sf:pointer-events-none sf:absolute sf:inset-0 sf:rounded-full",style:{backgroundImage:"linear-gradient(45deg, transparent 45%, hsl(0, 75%, 55%) 45%, hsl(0, 75%, 55%) 55%, transparent 55%)"}})}function vJe({token:e,isActive:t,onClick:n,testId:o,ariaLabel:r}){const a=e==="none";return p.jsxs("button",{type:"button",onClick:n,"data-testid":o,"data-active":t,"aria-label":r,"aria-pressed":t,title:e,className:ae("sf:relative sf:flex sf:h-5 sf:w-5 sf:items-center sf:justify-center sf:rounded-full sf:transition-all",a&&"sf:border sf:border-border sf:bg-card",t?"sf:ring-2 sf:ring-ring sf:ring-offset-1 sf:ring-offset-popover":"sf:hover:scale-110"),style:a?void 0:W2(e),children:[a?p.jsx(G2,{}):null,t&&!a?p.jsx(od,{className:"sf:h-2.5 sf:w-2.5 sf:drop-shadow-sm",style:{color:"hsl(var(--foreground))"}}):null]})}function xJe({testId:e,tooltip:t,ariaLabel:n,activeToken:o,previewKind:r,tokenTestIdPrefix:a,innerTestId:i,allowNone:s,onSelect:c}){const[l,h]=m.useState(!1),u=o==="none";return p.jsxs(w0,{open:l,onOpenChange:h,children:[p.jsxs(lf,{children:[p.jsx(df,{asChild:!0,children:p.jsx(Gh,{asChild:!0,children:p.jsx("button",{type:"button","data-testid":e,"data-active-token":o,"aria-label":`${n}: ${o}`,title:t,className:ae("sf:group sf:relative sf:inline-flex sf:h-8 sf:w-8 sf:items-center sf:justify-center sf:rounded-md sf:text-muted-foreground sf:transition-colors sf:hover:bg-accent sf:hover:text-accent-foreground","sf:focus-visible:outline-hidden sf:focus-visible:ring-2 sf:focus-visible:ring-ring sf:focus-visible:ring-offset-1"),children:p.jsx("span",{"data-testid":i,className:ae("sf:relative sf:h-5 sf:w-5 sf:rounded-full",u&&"sf:bg-card"),style:u?void 0:W2(o),children:u?p.jsx(G2,{}):null})})})}),p.jsx(b0,{side:"right",className:"sf:px-2 sf:py-1 sf:text-xs",children:t})]}),p.jsx(Sd,{side:"right",align:"start",className:"sf:w-auto sf:p-1.5","data-testid":`${i}-popover`,children:p.jsx(i2,{testId:`${a}-grid`,activeToken:o,previewKind:r,tokenTestIdPrefix:a,innerTestId:i,ariaLabel:n,allowNone:s,onSelect:f=>{c(f),h(!1)}})})]})}function i2({testId:e,activeToken:t,previewKind:n,tokenTestIdPrefix:o,innerTestId:r,ariaLabel:a,allowNone:i,onSelect:s}){const c=i===!1?fG.filter(l=>l!=="none"):fG;return p.jsx("div",{"data-testid":e,"data-active-token":t,"data-inner-testid":r,className:"sf:grid sf:grid-cols-6 sf:gap-1",children:c.map(l=>p.jsx(vJe,{token:l,isActive:t===l,onClick:()=>s(l),testId:`${o}-${l}`,ariaLabel:`${a} ${l}`},l))})}function kp({label:e,testId:t,children:n}){return p.jsxs("div",{className:"sf:flex sf:flex-col sf:gap-1.5","data-testid":t,children:[p.jsx("div",{className:"sf:text-[11px] sf:font-medium sf:uppercase sf:tracking-wide sf:text-muted-foreground",children:e}),n]})}function eo({testId:e,tooltip:t,ariaLabel:n,renderIcon:o,children:r}){const[a,i]=m.useState(!1);return p.jsxs(w0,{open:a,onOpenChange:i,children:[p.jsxs(lf,{children:[p.jsx(df,{asChild:!0,children:p.jsx(Gh,{asChild:!0,children:p.jsx("button",{type:"button","data-testid":e,"aria-label":n,title:t,className:ae("sf:inline-flex sf:h-8 sf:w-8 sf:items-center sf:justify-center sf:rounded-md sf:text-muted-foreground sf:transition-colors sf:hover:bg-accent sf:hover:text-accent-foreground","sf:focus-visible:outline-hidden sf:focus-visible:ring-2 sf:focus-visible:ring-ring sf:focus-visible:ring-offset-1"),children:o()})})}),p.jsx(b0,{side:"right",className:"sf:px-2 sf:py-1 sf:text-xs",children:t})]}),p.jsx(Sd,{side:"right",align:"start",className:"sf:w-auto sf:p-3",children:r})]})}function Vi({value:e,defaultValue:t,min:n,max:o,suffix:r,indeterminate:a,onPreview:i,onCommit:s,testId:c}){const l=e??t,[h,u]=m.useState(l),[f,y]=m.useState(!1);m.useEffect(()=>{u(l),y(!1)},[l]);const k=a&&!f;return p.jsxs("div",{className:"sf:flex sf:w-48 sf:items-center sf:gap-3",children:[p.jsx(yO,{min:n,max:o,step:1,value:[h],onValueChange:([x])=>{const w=x??n;u(w),y(!0),i==null||i(w)},onValueCommit:([x])=>s(x??n),"data-testid":c,"data-indeterminate":k?"true":void 0,className:ae("sf:flex-1",k&&"sf:opacity-60")}),p.jsx("span",{"data-testid":`${c}-value`,className:"sf:w-12 sf:shrink-0 sf:text-right sf:text-xs sf:tabular-nums sf:text-muted-foreground",children:k?"Mixed":p.jsxs(p.Fragment,{children:[h,r]})})]})}function wJe(e,t){if(e.match(/^[a-z]+:\/\//i))return e;if(e.match(/^\/\//))return window.location.protocol+e;if(e.match(/^[a-z]+:/i))return e;const n=document.implementation.createHTMLDocument(),o=n.createElement("base"),r=n.createElement("a");return n.head.appendChild(o),n.body.appendChild(r),t&&(o.href=t),r.href=e,r.href}const MJe=(()=>{let e=0;const t=()=>`0000${(Math.random()*36**4<<0).toString(36)}`.slice(-4);return()=>(e+=1,`u${t()}${e}`)})();function vi(e){const t=[];for(let n=0,o=e.length;n<o;n++)t.push(e[n]);return t}let Wd=null;function Soe(e={}){return Wd||(e.includeStyleProperties?(Wd=e.includeStyleProperties,Wd):(Wd=vi(window.getComputedStyle(document.documentElement)),Wd))}function Kj(e,t){const o=(e.ownerDocument.defaultView||window).getComputedStyle(e).getPropertyValue(t);return o?parseFloat(o.replace("px","")):0}function bJe(e){const t=Kj(e,"border-left-width"),n=Kj(e,"border-right-width");return e.clientWidth+t+n}function _Je(e){const t=Kj(e,"border-top-width"),n=Kj(e,"border-bottom-width");return e.clientHeight+t+n}function Loe(e,t={}){const n=t.width||bJe(e),o=t.height||_Je(e);return{width:n,height:o}}function CJe(){let e,t;try{t=process}catch{}const n=t&&t.env?t.env.devicePixelRatio:null;return n&&(e=parseInt(n,10),Number.isNaN(e)&&(e=1)),e||window.devicePixelRatio||1}const to=16384;function SJe(e){(e.width>to||e.height>to)&&(e.width>to&&e.height>to?e.width>e.height?(e.height*=to/e.width,e.width=to):(e.width*=to/e.height,e.height=to):e.width>to?(e.height*=to/e.width,e.width=to):(e.width*=to/e.height,e.height=to))}function Xj(e){return new Promise((t,n)=>{const o=new Image;o.onload=()=>{o.decode().then(()=>{requestAnimationFrame(()=>t(o))})},o.onerror=n,o.crossOrigin="anonymous",o.decoding="async",o.src=e})}async function LJe(e){return Promise.resolve().then(()=>new XMLSerializer().serializeToString(e)).then(encodeURIComponent).then(t=>`data:image/svg+xml;charset=utf-8,${t}`)}async function IJe(e,t,n){const o="http://www.w3.org/2000/svg",r=document.createElementNS(o,"svg"),a=document.createElementNS(o,"foreignObject");return r.setAttribute("width",`${t}`),r.setAttribute("height",`${n}`),r.setAttribute("viewBox",`0 0 ${t} ${n}`),a.setAttribute("width","100%"),a.setAttribute("height","100%"),a.setAttribute("x","0"),a.setAttribute("y","0"),a.setAttribute("externalResourcesRequired","true"),r.appendChild(a),a.appendChild(e),LJe(r)}const Wn=(e,t)=>{if(e instanceof t)return!0;const n=Object.getPrototypeOf(e);return n===null?!1:n.constructor.name===t.name||Wn(n,t)};function NJe(e){const t=e.getPropertyValue("content");return`${e.cssText} content: '${t.replace(/'|"/g,"")}';`}function AJe(e,t){return Soe(t).map(n=>{const o=e.getPropertyValue(n),r=e.getPropertyPriority(n);return`${n}: ${o}${r?" !important":""};`}).join(" ")}function EJe(e,t,n,o){const r=`.${e}:${t}`,a=n.cssText?NJe(n):AJe(n,o);return document.createTextNode(`${r}{${a}}`)}function kG(e,t,n,o){const r=window.getComputedStyle(e,n),a=r.getPropertyValue("content");if(a===""||a==="none")return;const i=MJe();try{t.className=`${t.className} ${i}`}catch{return}const s=document.createElement("style");s.appendChild(EJe(i,n,r,o)),t.appendChild(s)}function $Je(e,t,n){kG(e,t,":before",n),kG(e,t,":after",n)}const gG="application/font-woff",vG="image/jpeg",PJe={woff:gG,woff2:gG,ttf:"application/font-truetype",eot:"application/vnd.ms-fontobject",png:"image/png",jpg:vG,jpeg:vG,gif:"image/gif",tiff:"image/tiff",svg:"image/svg+xml",webp:"image/webp"};function jJe(e){const t=/\.([^./]*?)$/g.exec(e);return t?t[1]:""}function mF(e){const t=jJe(e).toLowerCase();return PJe[t]||""}function zJe(e){return e.split(/,/)[1]}function VH(e){return e.search(/^(data:)/)!==-1}function RJe(e,t){return`data:${t};base64,${e}`}async function Ioe(e,t,n){const o=await fetch(e,t);if(o.status===404)throw new Error(`Resource "${o.url}" not found`);const r=await o.blob();return new Promise((a,i)=>{const s=new FileReader;s.onerror=i,s.onloadend=()=>{try{a(n({res:o,result:s.result}))}catch(c){i(c)}},s.readAsDataURL(r)})}const qT={};function TJe(e,t,n){let o=e.replace(/\?.*/,"");return n&&(o=e),/ttf|otf|eot|woff2?/i.test(o)&&(o=o.replace(/.*\//,"")),t?`[${t}]${o}`:o}async function kF(e,t,n){const o=TJe(e,t,n.includeQueryParams);if(qT[o]!=null)return qT[o];n.cacheBust&&(e+=(/\?/.test(e)?"&":"?")+new Date().getTime());let r;try{const a=await Ioe(e,n.fetchRequestInit,({res:i,result:s})=>(t||(t=i.headers.get("Content-Type")||""),zJe(s)));r=RJe(a,t)}catch(a){r=n.imagePlaceholder||"";let i=`Failed to fetch resource: ${e}`;a&&(i=typeof a=="string"?a:a.message),i&&console.warn(i)}return qT[o]=r,r}async function DJe(e){const t=e.toDataURL();return t==="data:,"?e.cloneNode(!1):Xj(t)}async function HJe(e,t){if(e.currentSrc){const a=document.createElement("canvas"),i=a.getContext("2d");a.width=e.clientWidth,a.height=e.clientHeight,i==null||i.drawImage(e,0,0,a.width,a.height);const s=a.toDataURL();return Xj(s)}const n=e.poster,o=mF(n),r=await kF(n,o,t);return Xj(r)}async function qJe(e,t){var n;try{if(!((n=e==null?void 0:e.contentDocument)===null||n===void 0)&&n.body)return await sR(e.contentDocument.body,t,!0)}catch{}return e.cloneNode(!1)}async function OJe(e,t){return Wn(e,HTMLCanvasElement)?DJe(e):Wn(e,HTMLVideoElement)?HJe(e,t):Wn(e,HTMLIFrameElement)?qJe(e,t):e.cloneNode(Noe(e))}const FJe=e=>e.tagName!=null&&e.tagName.toUpperCase()==="SLOT",Noe=e=>e.tagName!=null&&e.tagName.toUpperCase()==="SVG";async function VJe(e,t,n){var o,r;if(Noe(t))return t;let a=[];return FJe(e)&&e.assignedNodes?a=vi(e.assignedNodes()):Wn(e,HTMLIFrameElement)&&(!((o=e.contentDocument)===null||o===void 0)&&o.body)?a=vi(e.contentDocument.body.childNodes):a=vi(((r=e.shadowRoot)!==null&&r!==void 0?r:e).childNodes),a.length===0||Wn(e,HTMLVideoElement)||await a.reduce((i,s)=>i.then(()=>sR(s,n)).then(c=>{c&&t.appendChild(c)}),Promise.resolve()),t}function BJe(e,t,n){const o=t.style;if(!o)return;const r=window.getComputedStyle(e);r.cssText?(o.cssText=r.cssText,o.transformOrigin=r.transformOrigin):Soe(n).forEach(a=>{let i=r.getPropertyValue(a);a==="font-size"&&i.endsWith("px")&&(i=`${Math.floor(parseFloat(i.substring(0,i.length-2)))-.1}px`),Wn(e,HTMLIFrameElement)&&a==="display"&&i==="inline"&&(i="block"),a==="d"&&t.getAttribute("d")&&(i=`path(${t.getAttribute("d")})`),o.setProperty(a,i,r.getPropertyPriority(a))})}function UJe(e,t){Wn(e,HTMLTextAreaElement)&&(t.innerHTML=e.value),Wn(e,HTMLInputElement)&&t.setAttribute("value",e.value)}function WJe(e,t){if(Wn(e,HTMLSelectElement)){const n=t,o=Array.from(n.children).find(r=>e.value===r.getAttribute("value"));o&&o.setAttribute("selected","")}}function GJe(e,t,n){return Wn(t,Element)&&(BJe(e,t,n),$Je(e,t,n),UJe(e,t),WJe(e,t)),t}async function ZJe(e,t){const n=e.querySelectorAll?e.querySelectorAll("use"):[];if(n.length===0)return e;const o={};for(let a=0;a<n.length;a++){const s=n[a].getAttribute("xlink:href");if(s){const c=e.querySelector(s),l=document.querySelector(s);!c&&l&&!o[s]&&(o[s]=await sR(l,t,!0))}}const r=Object.values(o);if(r.length){const a="http://www.w3.org/1999/xhtml",i=document.createElementNS(a,"svg");i.setAttribute("xmlns",a),i.style.position="absolute",i.style.width="0",i.style.height="0",i.style.overflow="hidden",i.style.display="none";const s=document.createElementNS(a,"defs");i.appendChild(s);for(let c=0;c<r.length;c++)s.appendChild(r[c]);e.appendChild(i)}return e}async function sR(e,t,n){return!n&&t.filter&&!t.filter(e)?null:Promise.resolve(e).then(o=>OJe(o,t)).then(o=>VJe(e,o,t)).then(o=>GJe(e,o,t)).then(o=>ZJe(o,t))}const Aoe=/url\((['"]?)([^'"]+?)\1\)/g,KJe=/url\([^)]+\)\s*format\((["']?)([^"']+)\1\)/g,XJe=/src:\s*(?:url\([^)]+\)\s*format\([^)]+\)[,;]\s*)+/g;function YJe(e){const t=e.replace(/([.*+?^${}()|\[\]\/\\])/g,"\\$1");return new RegExp(`(url\\(['"]?)(${t})(['"]?\\))`,"g")}function QJe(e){const t=[];return e.replace(Aoe,(n,o,r)=>(t.push(r),n)),t.filter(n=>!VH(n))}async function JJe(e,t,n,o,r){try{const a=n?wJe(t,n):t,i=mF(t);let s;return r||(s=await kF(a,i,o)),e.replace(YJe(t),`$1${s}$3`)}catch{}return e}function eet(e,{preferredFontFormat:t}){return t?e.replace(XJe,n=>{for(;;){const[o,,r]=KJe.exec(n)||[];if(!r)return"";if(r===t)return`src: ${o};`}}):e}function Eoe(e){return e.search(Aoe)!==-1}async function $oe(e,t,n){if(!Eoe(e))return e;const o=eet(e,n);return QJe(o).reduce((a,i)=>a.then(s=>JJe(s,i,t,n)),Promise.resolve(o))}async function Gd(e,t,n){var o;const r=(o=t.style)===null||o===void 0?void 0:o.getPropertyValue(e);if(r){const a=await $oe(r,null,n);return t.style.setProperty(e,a,t.style.getPropertyPriority(e)),!0}return!1}async function tet(e,t){await Gd("background",e,t)||await Gd("background-image",e,t),await Gd("mask",e,t)||await Gd("-webkit-mask",e,t)||await Gd("mask-image",e,t)||await Gd("-webkit-mask-image",e,t)}async function net(e,t){const n=Wn(e,HTMLImageElement);if(!(n&&!VH(e.src))&&!(Wn(e,SVGImageElement)&&!VH(e.href.baseVal)))return;const o=n?e.src:e.href.baseVal,r=await kF(o,mF(o),t);await new Promise((a,i)=>{e.onload=a,e.onerror=t.onImageErrorHandler?(...c)=>{try{a(t.onImageErrorHandler(...c))}catch(l){i(l)}}:i;const s=e;s.decode&&(s.decode=a),s.loading==="lazy"&&(s.loading="eager"),n?(e.srcset="",e.src=r):e.href.baseVal=r})}async function oet(e,t){const o=vi(e.childNodes).map(r=>Poe(r,t));await Promise.all(o).then(()=>e)}async function Poe(e,t){Wn(e,Element)&&(await tet(e,t),await net(e,t),await oet(e,t))}function ret(e,t){const{style:n}=e;t.backgroundColor&&(n.backgroundColor=t.backgroundColor),t.width&&(n.width=`${t.width}px`),t.height&&(n.height=`${t.height}px`);const o=t.style;return o!=null&&Object.keys(o).forEach(r=>{n[r]=o[r]}),e}const xG={};async function wG(e){let t=xG[e];if(t!=null)return t;const o=await(await fetch(e)).text();return t={url:e,cssText:o},xG[e]=t,t}async function MG(e,t){let n=e.cssText;const o=/url\(["']?([^"')]+)["']?\)/g,a=(n.match(/url\([^)]+\)/g)||[]).map(async i=>{let s=i.replace(o,"$1");return s.startsWith("https://")||(s=new URL(s,e.url).href),Ioe(s,t.fetchRequestInit,({result:c})=>(n=n.replace(i,`url(${c})`),[i,c]))});return Promise.all(a).then(()=>n)}function bG(e){if(e==null)return[];const t=[],n=/(\/\*[\s\S]*?\*\/)/gi;let o=e.replace(n,"");const r=new RegExp("((@.*?keyframes [\\s\\S]*?){([\\s\\S]*?}\\s*?)})","gi");for(;;){const c=r.exec(o);if(c===null)break;t.push(c[0])}o=o.replace(r,"");const a=/@import[\s\S]*?url\([^)]*\)[\s\S]*?;/gi,i="((\\s*?(?:\\/\\*[\\s\\S]*?\\*\\/)?\\s*?@media[\\s\\S]*?){([\\s\\S]*?)}\\s*?})|(([\\s\\S]*?){([\\s\\S]*?)})",s=new RegExp(i,"gi");for(;;){let c=a.exec(o);if(c===null){if(c=s.exec(o),c===null)break;a.lastIndex=s.lastIndex}else s.lastIndex=a.lastIndex;t.push(c[0])}return t}async function aet(e,t){const n=[],o=[];return e.forEach(r=>{if("cssRules"in r)try{vi(r.cssRules||[]).forEach((a,i)=>{if(a.type===CSSRule.IMPORT_RULE){let s=i+1;const c=a.href,l=wG(c).then(h=>MG(h,t)).then(h=>bG(h).forEach(u=>{try{r.insertRule(u,u.startsWith("@import")?s+=1:r.cssRules.length)}catch(f){console.error("Error inserting rule from remote css",{rule:u,error:f})}})).catch(h=>{console.error("Error loading remote css",h.toString())});o.push(l)}})}catch(a){const i=e.find(s=>s.href==null)||document.styleSheets[0];r.href!=null&&o.push(wG(r.href).then(s=>MG(s,t)).then(s=>bG(s).forEach(c=>{i.insertRule(c,i.cssRules.length)})).catch(s=>{console.error("Error loading remote stylesheet",s)})),console.error("Error inlining remote css file",a)}}),Promise.all(o).then(()=>(e.forEach(r=>{if("cssRules"in r)try{vi(r.cssRules||[]).forEach(a=>{n.push(a)})}catch(a){console.error(`Error while reading CSS rules from ${r.href}`,a)}}),n))}function iet(e){return e.filter(t=>t.type===CSSRule.FONT_FACE_RULE).filter(t=>Eoe(t.style.getPropertyValue("src")))}async function set(e,t){if(e.ownerDocument==null)throw new Error("Provided element is not within a Document");const n=vi(e.ownerDocument.styleSheets),o=await aet(n,t);return iet(o)}function joe(e){return e.trim().replace(/["']/g,"")}function cet(e){const t=new Set;function n(o){(o.style.fontFamily||getComputedStyle(o).fontFamily).split(",").forEach(a=>{t.add(joe(a))}),Array.from(o.children).forEach(a=>{a instanceof HTMLElement&&n(a)})}return n(e),t}async function det(e,t){const n=await set(e,t),o=cet(e);return(await Promise.all(n.filter(a=>o.has(joe(a.style.fontFamily))).map(a=>{const i=a.parentStyleSheet?a.parentStyleSheet.href:null;return $oe(a.cssText,i,t)}))).join(`
8543
- `)}async function uet(e,t){const n=t.fontEmbedCSS!=null?t.fontEmbedCSS:t.skipFonts?null:await det(e,t);if(n){const o=document.createElement("style"),r=document.createTextNode(n);o.appendChild(r),e.firstChild?e.insertBefore(o,e.firstChild):e.appendChild(o)}}async function het(e,t={}){const{width:n,height:o}=Loe(e,t),r=await sR(e,t,!0);return await uet(r,t),await Poe(r,t),ret(r,t),await IJe(r,n,o)}async function fet(e,t={}){const{width:n,height:o}=Loe(e,t),r=await het(e,t),a=await Xj(r),i=document.createElement("canvas"),s=i.getContext("2d"),c=t.pixelRatio||CJe(),l=t.canvasWidth||n,h=t.canvasHeight||o;return i.width=l*c,i.height=h*c,t.skipAutoScale||SJe(i),i.style.width=`${l}`,i.style.height=`${h}`,t.backgroundColor&&(s.fillStyle=t.backgroundColor,s.fillRect(0,0,i.width,i.height)),s.drawImage(a,0,0,i.width,i.height),i}async function pet(e,t={}){return(await fet(e,t)).toDataURL()}const yet=e=>e instanceof Element?!(e.classList.contains("react-flow__minimap")||e.classList.contains("react-flow__controls")||e.classList.contains("react-flow__panel")):!0,met=e=>{var o;let t=e;for(;t&&!t.classList.contains("seeflow-canvas-root");)t=t.parentElement;if(t){const r=getComputedStyle(t).getPropertyValue("--bg-canvas").trim();if(r.length>0)return r}const n=(o=e.ownerDocument)==null?void 0:o.documentElement;return n!=null&&n.classList.contains("dark")?"#0a0a0c":"#fafafa"},ket=async e=>{const t=await pet(e,{cacheBust:!0,filter:yet,backgroundColor:met(e)}),n=await new Promise((o,r)=>{const a=new Image;a.onload=()=>o({width:a.naturalWidth,height:a.naturalHeight}),a.onerror=()=>r(new Error("Failed to decode captured image")),a.src=t});return{dataUrl:t,...n}},get=(e,t)=>{const n=document.createElement("a");n.href=e,n.download=t,n.rel="noopener",document.body.appendChild(n),n.click(),n.remove()},vet=e=>{const t=e.replace(/[^A-Za-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"");return t.length>0?t.slice(0,80):"canvas"},_G=(e,t)=>`${vet(e??"canvas")}.${t}`,xet=({projectId:e,getReactFlow:t})=>{const[n,o]=m.useState(null),r=m.useCallback(()=>o(null),[]),a=m.useCallback(async()=>{const l=t();if(!l)return null;const h=document.querySelector(".react-flow__viewport");if(!h)return null;const u=l.getViewport();try{return await l.fitView({duration:0,padding:.1}),await new Promise(f=>requestAnimationFrame(()=>f())),await ket(h)}finally{l.setViewport(u,{duration:0})}},[t]),i=m.useCallback(async()=>{o(null);try{const l=await a();if(!l)return;get(l.dataUrl,_G(e,"png"))}catch(l){o(l instanceof Error?l.message:String(l))}},[a,e]),s=m.useCallback(async()=>{o(null);try{const l=await a();if(!l)return;const{jsPDF:h}=await Iz(async()=>{const{jsPDF:y}=await import("./jspdf.es.min-CIMMqiVE.js").then(k=>k.j);return{jsPDF:y}},[]),u=l.width>l.height?"landscape":"portrait",f=new h({orientation:u,unit:"px",format:[l.width,l.height],hotfixes:["px_scaling"]});f.addImage(l.dataUrl,"PNG",0,0,l.width,l.height),f.save(_G(e,"pdf"))}catch(l){o(l instanceof Error?l.message:String(l))}},[a,e]),c=m.useCallback(async()=>{const l=await a();return l==null?void 0:l.dataUrl},[a]);return{exportPdf:s,exportPng:i,capturePreview:c,lastError:n,clearError:r}},wet=12,Met=1200;function bet(e,t={}){const n=t.idleMs??Met;let o,r=null,a=null;const i=typeof requestAnimationFrame<"u",s=()=>{o!==void 0&&(clearTimeout(o),o=void 0)},c=()=>{a!==null&&typeof cancelAnimationFrame<"u"&&cancelAnimationFrame(a),a=null},l=()=>{if(a=null,!r)return;const{clientX:y,clientY:k}=r;r=null;const x=e.getBoundingClientRect();e.style.setProperty("--mx",`${y-x.left}px`),e.style.setProperty("--my",`${k-x.top}px`),e.dataset.active="true",s(),o=setTimeout(()=>{e.dataset.active="false",o=void 0},n)};return{onMove:y=>{if(r={clientX:y.clientX,clientY:y.clientY},!i){l();return}a===null&&(a=requestAnimationFrame(l))},onLeave:()=>{c(),r=null,s(),e.dataset.active="false"},dispose:()=>{c(),r=null,s()}}}function _et(){const e=m.useRef(null),t=Te(i=>i.transform,(i,s)=>i[0]===s[0]&&i[1]===s[1]&&i[2]===s[2]),[n,o,r]=t,a=wet*r;return m.useEffect(()=>{var u;const i=e.current;if(!i)return;const s=(u=i.parentElement)==null?void 0:u.querySelector(".react-flow__pane");if(!s)return;const{onMove:c,onLeave:l,dispose:h}=bet(i);return s.addEventListener("mousemove",c,{passive:!0}),s.addEventListener("mouseleave",l,{passive:!0}),()=>{s.removeEventListener("mousemove",c),s.removeEventListener("mouseleave",l),h()}},[]),p.jsx("div",{ref:e,className:"glow-overlay","data-active":"false","data-testid":"canvas-glow-overlay",style:{backgroundPosition:`${n}px ${o}px`,backgroundSize:`${a}px ${a}px`}})}const Cet={showToolbar:!0,showStyleStrip:!0,showDetailPanel:!0,showStatusBadges:!0,showResizeHandles:!0,showControls:!0,showShareMenu:!0,showMiniMap:!0,showRestart:!0,enableKeyboard:!0,enableContextMenu:!0,enableDragDrop:!0,enableImageDrop:!0,enableZoom:!0,enablePan:!0,enableSelection:!0,enableNodeMove:!0,enableEmbed:!1},Let={showToolbar:!0,showStyleStrip:!1,showDetailPanel:!1,showStatusBadges:!0,showResizeHandles:!1,showControls:!0,showShareMenu:!0,showMiniMap:!0,showRestart:!1,enableKeyboard:!1,enableContextMenu:!1,enableDragDrop:!1,enableImageDrop:!1,enableZoom:!0,enablePan:!0,enableSelection:!0,enableNodeMove:!0,enableEmbed:!1},Iet={showToolbar:!1,showStyleStrip:!1,showDetailPanel:!1,showStatusBadges:!1,showResizeHandles:!1,showControls:!1,showShareMenu:!1,showMiniMap:!1,showRestart:!1,enableKeyboard:!1,enableContextMenu:!1,enableDragDrop:!1,enableImageDrop:!1,enableZoom:!1,enablePan:!1,enableSelection:!1,enableNodeMove:!1,enableEmbed:!1};function Net(e){const t=e.mode==="edit"?Cet:e.mode==="mini"?Iet:Let;return{showToolbar:e.showToolbar??t.showToolbar,showStyleStrip:e.showStyleStrip??t.showStyleStrip,showDetailPanel:e.showDetailPanel??t.showDetailPanel,showStatusBadges:e.showStatusBadges??t.showStatusBadges,showResizeHandles:e.showResizeHandles??t.showResizeHandles,showControls:e.showControls??t.showControls,showShareMenu:e.showShareMenu??t.showShareMenu,showMiniMap:e.showMiniMap??t.showMiniMap,showRestart:e.showRestart??t.showRestart,enableKeyboard:e.enableKeyboard??t.enableKeyboard,enableContextMenu:e.enableContextMenu??t.enableContextMenu,enableDragDrop:e.enableDragDrop??t.enableDragDrop,enableImageDrop:e.enableImageDrop??t.enableImageDrop,enableZoom:e.enableZoom??t.enableZoom,enablePan:e.enablePan??t.enablePan,enableSelection:e.enableSelection??t.enableSelection,enableNodeMove:e.enableNodeMove??t.enableNodeMove,enableEmbed:e.enableEmbed??t.enableEmbed}}const CG=40,G0={padding:.15,duration:300,includeHiddenNodes:!1};function Aet(e){return e===void 0||e===!1?{onMount:!1,onExternalNodeChange:!1}:e===!0?{onMount:!0,onExternalNodeChange:!0}:{onMount:e.onMount??!0,onExternalNodeChange:e.onExternalNodeChange??!0}}const SG=e=>{if("clientX"in e)return{clientX:e.clientX,clientY:e.clientY};const t=e.changedTouches[0]??e.touches[0];return t?{clientX:t.clientX,clientY:t.clientY}:null},Eet=(e,t)=>{var o;const n=document.elementsFromPoint(e,t);for(const r of n){const a=(o=r.closest)==null?void 0:o.call(r,".react-flow__node");if(a)return a}return null},zoe=15,OT=(e,t,n)=>{const o=Eet(t,n);if(o)return o;if(!e)return null;let r=null,a=zoe;const i=e.querySelectorAll(".react-flow__node");for(const s of i){const c=s.getBoundingClientRect();if(c.width===0||c.height===0)continue;const l=Math.max(c.left-t,0,t-c.right),h=Math.max(c.top-n,0,n-c.bottom),u=Math.hypot(l,h);u<=a&&(r=s,a=u)}return r};function LG(e,t,n,o,r){if(e==="source"?(o==null?void 0:o.targetPin)!==void 0||(o==null?void 0:o.targetHandleAutoPicked)===!1:(o==null?void 0:o.sourcePin)!==void 0||(o==null?void 0:o.sourceHandleAutoPicked)===!1)return;const i=e==="source"?n:t,s=e==="source"?t:n,c=r(i),l=r(s);if(!c||!l)return;const h=c.measured.width??c.width??0,u=c.measured.height??c.height??0,f=l.measured.width??l.width??0,y=l.measured.height??l.height??0;if(h===0||u===0||f===0||y===0)return;const k={x:c.internals.positionAbsolute.x,y:c.internals.positionAbsolute.y,w:h,h:u},x={x:l.internals.positionAbsolute.x+f/2,y:l.internals.positionAbsolute.y+y/2};return HRe(k,Lj(k,x))}function $et(e,t,n,o){if(o===null)return"no-op";const r=e==="source"?t:n;return o===(e==="source"?n:t)?"self-loop":o===r?"pin-own":"reconnect-and-pin"}const Pet=(e,t)=>{if(!t)return e;const n=t.data?{...e.data,...t.data}:e.data;return{...e,...t,data:n}},jet=(e,t)=>t?{...e,...t}:e,zet={rectangle:FFe,ellipse:Ga,sticky:Ga,text:Ga,database:Ga,server:Ga,user:Ga,queue:Ga,cloud:Ga,image:RFe,icon:XRe,html:EFe,component:rFe},Ret={editableEdge:UFe},Tet={zIndex:0},Det=8,IG=(e,t)=>e?typeof e=="string"?`url('#${e}')`:`url('#${`${t?`${t}__`:""}${Object.keys(e).sort().map(r=>`${r}=${e[r]}`).join("&")}`}')`:void 0,Het=e=>function({fromX:n,fromY:o,toX:r,toY:a,fromPosition:i,toPosition:s,connectionLineStyle:c}){const l=Te(U=>e.current?U.edges.find(D=>D.reconnectable===!0)??null:null),h=l==null?void 0:l.data,u=Te(U=>{var E;const D=U.connection;return((E=D==null?void 0:D.fromHandle)==null?void 0:E.nodeId)??null}),f=Te(U=>l!=null&&l.source?U.nodeLookup.get(l.source)??null:null),y=Te(U=>l!=null&&l.target?U.nodeLookup.get(l.target)??null:null),k=Te(U=>u?U.nodeLookup.get(u)??null:null),x=(l==null?void 0:l.source)===u,w=l?x?f:y:k,g=x?y:f,M=x?h==null?void 0:h.sourcePin:h==null?void 0:h.targetPin,v=x?h==null?void 0:h.sourceHandleAutoPicked:h==null?void 0:h.targetHandleAutoPicked;let b=n,C=o,_=i;if(w){const U=w.measured.width??w.width??0,D=w.measured.height??w.height??0;if(U>0&&D>0){const E={x:w.internals.positionAbsolute.x,y:w.internals.positionAbsolute.y,w:U,h:D};let W=null;if(M)W=Ij(E,M);else if(v!==!1&&g){const Y=g.measured.width??g.width??0,Q=g.measured.height??g.height??0;if(Y>0&&Q>0){const oe={x:g.internals.positionAbsolute.x+Y/2,y:g.internals.positionAbsolute.y+Q/2};W=Lj(E,oe)}}W&&(b=W.x,C=W.y,_=NG[W.side])}}const S=Te(U=>U.transform[2]),A=Te(U=>U.nodeLookup),P=Te(U=>{var D;return((D=U.connection.toHandle)==null?void 0:D.nodeId)??null});let I=r,$=a,N=s;if(S>0){const U=zoe/S,D=l?x?l.target:l.source:null;let E=null;if(P&&P!==D){const W=A.get(P)??null;W&&(E=W)}if(!E){let W=U;for(const Y of A.values()){if(D&&Y.id===D||w&&Y.id===w.id)continue;const Q=Y.measured.width??Y.width??0,oe=Y.measured.height??Y.height??0;if(Q===0||oe===0)continue;const te=Y.internals.positionAbsolute.x,se=Y.internals.positionAbsolute.y,we=Math.max(te-r,0,r-(te+Q)),ke=Math.max(se-a,0,a-(se+oe)),ge=Math.hypot(we,ke);ge<=W&&(W=ge,E=Y)}}if(!E&&l&&w){const W=w.measured.width??w.width??0,Y=w.measured.height??w.height??0;if(W>0&&Y>0){const Q=w.internals.positionAbsolute.x,oe=w.internals.positionAbsolute.y,te=Math.max(Q-r,0,r-(Q+W)),se=Math.max(oe-a,0,a-(oe+Y));Math.hypot(te,se)<=U&&(E=w)}}if(E){const W=E.measured.width??E.width??0,Y=E.measured.height??E.height??0;if(W>0&&Y>0){const Q=tH({x:E.internals.positionAbsolute.x,y:E.internals.positionAbsolute.y,w:W,h:Y},{x:r,y:a}),oe=Ij({x:E.internals.positionAbsolute.x,y:E.internals.positionAbsolute.y,w:W,h:Y},Q);I=oe.x,$=oe.y,N=NG[oe.side]}}}const X=(h==null?void 0:h.path)==="step",[j]=X?xh({sourceX:b,sourceY:C,sourcePosition:_,targetX:I,targetY:$,targetPosition:N,borderRadius:Det}):Mz({sourceX:b,sourceY:C,sourcePosition:_,targetX:I,targetY:$,targetPosition:N}),O=(l==null?void 0:l.style)??c??void 0,H=Te(U=>U.rfId),B=x?l==null?void 0:l.markerStart:l==null?void 0:l.markerEnd,z=x?l==null?void 0:l.markerEnd:l==null?void 0:l.markerStart,R=IG(B,H),L=IG(z,H);return p.jsx("path",{d:j,fill:"none",className:"react-flow__connection-path",style:O,markerStart:R,markerEnd:L})},NG={top:pe.Top,right:pe.Right,bottom:pe.Bottom,left:pe.Left};function qet({storeApiRef:e}){const t=wt();return m.useEffect(()=>(e.current=t,()=>{e.current===t&&(e.current=null)}),[t,e]),null}function Oet({wrapperRef:e}){const t=Te(o=>o.transform[2]),n=e.current;return n&&n.style.setProperty("--rf-zoom",String(t)),null}const Fet=new Set(["INPUT","TEXTAREA","SELECT"]),Roe=e=>e?Fet.has(e.tagName)?!0:e instanceof HTMLElement&&e.isContentEditable:!1;function Vet(e){const{event:t,selectedNodeIds:n,hasClipboard:o,activeElement:r,onCopySelection:a,onPasteSelection:i}=e;if(!(t.metaKey||t.ctrlKey)||t.shiftKey||t.altKey)return!1;const s=t.key.toLowerCase();return s!=="c"&&s!=="v"||Roe(r)?!1:s==="c"?n.length===0||!a?!1:(t.preventDefault(),a([...n]),!0):!o||!i?!1:(t.preventDefault(),i(),!0)}const AG=(e,t)=>{var n;return((n=e==null?void 0:e[t])==null?void 0:n.status)??"idle"},Bet=(e,t)=>{var n;return(n=e==null?void 0:e[t])==null?void 0:n.status},Uet=(e,t)=>{var n,o;return((n=e==null?void 0:e[t])==null?void 0:n.status)==="error"?(o=e[t])==null?void 0:o.error:void 0};function Wet(e,t){var AF,EF;const{mode:n,adapter:o,projectId:r,fileBaseUrl:a,apiBaseUrl:i="/api",nodes:s,connectors:c,selectedNodeIds:l,selectedConnectorIds:h,onSelectionChange:u,runtime:f,onPlayNode:y,onNodePositionChange:k,onNodePositionsChange:x,onNodeResize:w,onNodeResizeEnd:g,onHtmlNodeFitToContent:M,onComponentNodeFitToContent:v,onMultiResize:b,onNodeNameChange:C,onNodeDescriptionChange:_,onConnectorLabelChange:S,onCreateShapeNode:A,onCreateImageFromFile:P,onRetryImageUpload:I,onCreateHtmlNode:$,onCreateConnector:N,onReconnectConnector:X,onReorderNode:j,onDeleteNode:O,onCopyNode:H,onPasteAt:B,hasClipboard:z,onCopySelection:R,onPasteSelection:L,selectedNodes:U,selectedConnectors:D,onStyleNode:E,onStyleNodePreview:W,onStyleNodes:Y,onStyleNodesPreview:Q,onStyleConnector:oe,onStyleConnectorPreview:te,onRfInit:se,onTidy:we,onNodeClick:ke,onConnectorClick:ge,onPaneClick:ve,onCreateAndConnectFromPane:re,pendingEditNodeId:me,iconPickerOpen:Ve,onOpenIconPicker:lt,onCloseIconPicker:Vt,onPickIcon:Et,onRequestIconReplace:ce,onPinEndpoint:J,onUnpinEndpoint:ln,canvasMode:rn,onCanvasModeChange:Ee,disableSidebar:Ge,statusReport:G,onNameChange:ne,onDescriptionChange:Ie,onDetailChange:De,onIconChange:Ke,autoFitView:Bt,autoFitViewSignal:bn,customIcons:Qe,onExportToCloud:ft,onRestartDemo:_n,showToolbar:Rt,showStyleStrip:Cn,showDetailPanel:an,showStatusBadges:dt,showResizeHandles:Mt,showControls:rr,showShareMenu:Ea,showMiniMap:ar,showRestart:Pi,enableKeyboard:$a,enableContextMenu:Ao,enableDragDrop:ir,enableImageDrop:Eo,enableZoom:Ad,enablePan:Ed,enableSelection:$o,enableNodeMove:Kr,enableEmbed:Xr}=e,He=m.useMemo(()=>Net({mode:n,showToolbar:Rt,showStyleStrip:Cn,showDetailPanel:an,showStatusBadges:dt,showResizeHandles:Mt,showControls:rr,showShareMenu:Ea,showMiniMap:ar,showRestart:Pi,enableKeyboard:$a,enableContextMenu:Ao,enableDragDrop:ir,enableImageDrop:Eo,enableZoom:Ad,enablePan:Ed,enableSelection:$o,enableNodeMove:Kr,enableEmbed:Xr}),[n,Rt,Cn,an,dt,Mt,rr,Ea,ar,Pi,$a,Ao,ir,Eo,Ad,Ed,$o,Kr,Xr]),gt=n==="edit",Pa=m.useRef(He);m.useEffect(()=>{Pa.current=He},[He]);const ji=Bt??(n==="mini"?!0:void 0),Yr=m.useMemo(()=>Aet(ji),[ji]),sr=f==null?void 0:f.runs,ja=f==null?void 0:f.statuses,Rn=(AF=f==null?void 0:f.pendingOverrides)==null?void 0:AF.nodes,Po=(EF=f==null?void 0:f.pendingOverrides)==null?void 0:EF.connectors,Kt=m.useRef(null),Xt=m.useRef(null),Qr=m.useRef(!1),cr=m.useRef(!1),$d=m.useRef(!1),Pd=m.useRef(Yr);Pd.current=Yr,m.useEffect(()=>{if(Qr.current||!Yr.onMount||s.length===0)return;const K=Xt.current;K&&(K.fitView(G0),Qr.current=!0)},[s,Yr.onMount]);const jo=m.useRef(null),bt=rn.kind==="draw"?rn.shape:null,Kn=rn.kind==="hand",lr=m.useRef(new Map),jd=m.useCallback((K,ee)=>(lr.current.set(K,ee),()=>{lr.current.get(K)===ee&&lr.current.delete(K)}),[]),[Jr,ea]=m.useState(!1),zd=m.useRef(!1);m.useEffect(()=>{zd.current=Jr},[Jr]);const zi=m.useRef(!1),za=m.useRef(!1),zo=m.useRef(!1),[Sn,dr]=m.useState(null),Xn=m.useRef(null);m.useEffect(()=>{Xn.current=Sn},[Sn]),m.useCallback(()=>{dr(null)},[]);const Ro=m.useMemo(()=>Het(zo),[]),Yn=m.useRef(null),Rd=m.useRef(null),ur=m.useCallback(K=>{const ee=Kt.current;if(!ee){Yn.current=K;return}const le=Yn.current;if(le&&le!==K){const de=ee.querySelector(`.react-flow__node[data-id="${CSS.escape(le)}"]`);de==null||de.removeAttribute("data-connect-source")}if(K){const de=ee.querySelector(`.react-flow__node[data-id="${CSS.escape(K)}"]`);de==null||de.setAttribute("data-connect-source","true")}Yn.current=K},[]),Qn=m.useCallback(K=>{const ee=Kt.current,le=Rd.current;if(le!==K){if(ee&&le){const de=ee.querySelector(`.react-flow__node[data-id="${CSS.escape(le)}"]`);de==null||de.removeAttribute("data-connect-target")}if(ee&&K){const de=ee.querySelector(`.react-flow__node[data-id="${CSS.escape(K)}"]`);de==null||de.setAttribute("data-connect-target","true")}Rd.current=K}},[]),Ra=m.useCallback(()=>{ur(null),Qn(null)},[ur,Qn]);m.useEffect(()=>{if(!Jr){Qn(null);return}let K=null,ee=null;const le=()=>{K=null;const ue=ee;if(ee=null,!ue)return;const je=OT(Kt.current,ue.clientX,ue.clientY),xe=(je==null?void 0:je.getAttribute("data-id"))??null;if(xe&&xe===Yn.current){Qn(null);return}Qn(xe)},de=ue=>{ee={clientX:ue.clientX,clientY:ue.clientY},K===null&&(K=requestAnimationFrame(le))};return document.addEventListener("pointermove",de,{passive:!0}),()=>{document.removeEventListener("pointermove",de),K!==null&&cancelAnimationFrame(K)}},[Jr,Qn]);const[To,ut]=m.useState(null),[go,vo]=m.useState(null),pn=m.useRef(null),hr=m.useRef(null),fr=m.useRef(null),Ta=m.useRef(!1);m.useEffect(()=>{pn.current=bt},[bt]);const Ri=m.useCallback(()=>{Ee({kind:"select"}),ut(null),vo(null),pn.current=null,hr.current=null,fr.current=null,Ta.current=!1},[Ee]);m.useEffect(()=>{if(!He.enableKeyboard)return;const K=ee=>{var ue,je;if(ee.key!=="Escape"||Roe(document.activeElement))return;if(pn.current){ee.preventDefault(),Ri();return}if(zd.current){ee.preventDefault(),zi.current=!0,za.current=!0;try{(ue=jo.current)==null||ue.getState().cancelConnection()}catch{}document.dispatchEvent(new MouseEvent("mouseup",{bubbles:!0,cancelable:!0,button:0})),ea(!1);return}if(Xn.current){ee.preventDefault(),dr(null);return}const le=Do.current.size>0,de=oa.current.size>0;(le||de)&&(ee.preventDefault(),(je=yr.current)==null||je.call(yr,[],[]))};return window.addEventListener("keydown",K),()=>window.removeEventListener("keydown",K)},[Ri,He.enableKeyboard]),m.useEffect(()=>{if(!He.enableKeyboard)return;const K=ee=>{Vet({event:ee,selectedNodeIds:l,hasClipboard:!!z,activeElement:document.activeElement,onCopySelection:R,onPasteSelection:L})};return window.addEventListener("keydown",K),()=>window.removeEventListener("keydown",K)},[l,z,R,L,He.enableKeyboard]);const lR=m.useCallback(K=>{var de,ue;if(!pn.current)return;const ee=K.target;if(!(ee!=null&&ee.classList.contains("react-flow__pane")))return;const le={x:K.clientX,y:K.clientY};Ta.current=!0,hr.current=le,fr.current=le,ut(le),vo(le);try{(ue=(de=K.currentTarget).setPointerCapture)==null||ue.call(de,K.pointerId)}catch{}K.preventDefault(),K.stopPropagation()},[]),dR=m.useCallback(K=>{if(!Ta.current)return;const ee={x:K.clientX,y:K.clientY};fr.current=ee,vo(ee)},[]),yf=m.useCallback(K=>{var kr,A0;if(!Ta.current)return;Ta.current=!1;try{(A0=(kr=K.currentTarget).releasePointerCapture)==null||A0.call(kr,K.pointerId)}catch{}const ee=hr.current,le=fr.current,de=pn.current,ue=Xt.current;if(Ri(),!ee||!le||!de||!ue)return;const je=Math.min(ee.x,le.x),xe=Math.min(ee.y,le.y),Pe=Math.max(ee.x,le.x),tt=Math.max(ee.y,le.y),st=Pe-je,pt=tt-xe,Re=ue.screenToFlowPosition({x:je,y:xe}),Dn=ue.screenToFlowPosition({x:Pe,y:tt}),mr=Dn.x-Re.x,yt=Dn.y-Re.y,Ce=st<CG||pt<CG,en=Ce?qj[de].width:mr,Dd=Ce?qj[de].height:yt;A==null||A(de,Re,{width:en,height:Dd})},[Ri,A]),ta=m.useRef(!1),na=m.useRef(!1),S0=m.useRef(new Map),q=m.useCallback(()=>{var K;cr.current&&(na.current||ta.current||(cr.current=!1,(K=Xt.current)==null||K.fitView(G0)))},[]),F=m.useCallback(K=>{na.current=K,K||q()},[q]);m.useEffect(()=>{var K;if(!$d.current){$d.current=!0;return}if(Pd.current.onExternalNodeChange){if(na.current||ta.current){cr.current=!0;return}(K=Xt.current)==null||K.fitView(G0)}},[bn]);const Z=!!j||!!O||!!H||!!B||!!ln,[V,T]=m.useState(null),[ie,Ae]=m.useState(!1),[be,Je]=m.useState(null),[Yt,pr]=m.useState(null),Ot=m.useRef(null),$e=m.useRef(null);m.useEffect(()=>{if(!V)return;const K=$e.current;if(!K)return;const ee=new MouseEvent("contextmenu",{clientX:V.x,clientY:V.y,bubbles:!0,cancelable:!0,button:2,buttons:2});K.dispatchEvent(ee)},[V]);const it=m.useCallback(K=>{const ee=Ot.current;!ee||!j||j(ee,K)},[j]),yn=m.useCallback(()=>{const K=Ot.current;!K||!O||O(K)},[O]),Tn=m.useCallback(()=>{const K=Ot.current;!K||!H||H(K)},[H]),Td=m.useCallback(()=>{const K=Ot.current;!K||!ce||ce(K)},[ce]);m.useCallback((K,ee,le,de,ue)=>{Pa.current.enableContextMenu&&(Ot.current=null,Ae(!1),Je(null),pr({connectorId:K,kind:ee,pinned:le}),T({x:de,y:ue}))},[]);const uR=m.useCallback(()=>{const K=Yt;!K||!ln||ln(K.connectorId,K.kind)},[Yt,ln]),Da=m.useCallback(()=>{if(!B)return;const K=V,ee=Xt.current;if(!K||!ee)return;const le=ee.screenToFlowPosition({x:K.x,y:K.y});B(le)},[V,B]),Oe=typeof navigator<"u"&&/Mac|iPhone|iPad|iPod/.test(navigator.platform||navigator.userAgent||""),_t=Oe?"⌘C":"Ctrl+C",Qt=Oe?"⌘V":"Ctrl+V",Jt=m.useMemo(()=>new Set(l),[l]),Jn=m.useMemo(()=>new Set(h),[h]),L0=m.useMemo(()=>{if(l.length<2)return[];const K=Rn,ee=[];for(const le of l){const de=s.find(Pe=>Pe.id===le);if(!de)continue;const ue=K==null?void 0:K[le],je=(ue==null?void 0:ue.data)??{},xe=de.data;ee.push({id:le,position:(ue==null?void 0:ue.position)??de.position,data:{width:je.width??xe.width,height:je.height??xe.height}})}return ee},[s,Rn,l]),hR=U??[],Ti=m.useMemo(()=>{const K=ue=>{const je=gt?void 0:S0.current.get(ue.id),xe={id:ue.id,type:ue.type,position:je??ue.position,data:{...ue.data,projectId:r,fileBaseUrl:a,flowId:ue.type==="component"?r:void 0,apiBaseUrl:ue.type==="component"?i:void 0,onRetryUpload:I,status:Bet(sr,ue.id),errorMessage:Uet(sr,ue.id),statusReport:ja==null?void 0:ja[ue.id],onPlay:y,onResize:w,onResizeEnd:g,setResizing:F,onFitToContent:ue.type==="html"?M:ue.type==="component"?v:void 0,onNameChange:(()=>{if(gt&&ue.type!=="ellipse")return C})(),onDescriptionChange:(()=>{if(gt&&(ue.type==="rectangle"||ue.type==="ellipse"||ue.type==="sticky"))return _})(),onIconChange:(()=>{if(gt&&!(ue.type!=="rectangle"&&ue.type!=="component"))return Ke})(),autoEditOnMount:me===ue.id?!0:void 0},selected:Jt.has(ue.id)};return(!(ue.data.autoSize===!0)||na.current)&&(ue.data.width!==void 0&&(xe.width=ue.data.width),ue.data.height!==void 0&&(xe.height=ue.data.height)),Jt.has(ue.id)||(xe.connectable=!1),xe},ee=s.map(ue=>K(Pet(ue,Rn==null?void 0:Rn[ue.id]))),le=new Set(s.map(ue=>ue.id)),de=[];if(Rn)for(const[ue,je]of Object.entries(Rn)){if(le.has(ue))continue;const xe=je;typeof xe.type!="string"||!xe.position||!xe.data||de.push(K({...xe,id:ue}))}return[...ee,...de]},[r,a,i,s,Jt,sr,ja,y,w,g,M,v,F,Rn,C,_,Ke,I,me,gt]),[fR,pR]=m.useState(Ti);m.useEffect(()=>{ta.current||na.current||pR(Ti)},[Ti]),m.useEffect(()=>{I0.current=fR},[fR]);const Do=m.useRef(Jt);m.useEffect(()=>{Do.current=Jt},[Jt]);const yr=m.useRef(u);m.useEffect(()=>{yr.current=u},[u]);const oa=m.useRef(Jn);m.useEffect(()=>{oa.current=Jn},[Jn]);const I0=m.useRef(Ti),Di=m.useRef(!1),mf=m.useRef(new Set),kf=m.useRef(new Set),yR=m.useRef(new Set),mR=m.useRef(new Set),Ha=m.useRef(null),ore=m.useCallback(K=>{var yt;const ee=Di.current?yR.current:(yt=Ha.current)!=null&&yt.shift?Ha.current.nodeIds:null,le=ee&&ee.size>0?K.filter(Ce=>Ce.type!=="select"?!0:!(Ce.selected===!1&&ee.has(Ce.id))):K,de=new Set;for(const Ce of le)Ce.type==="select"&&de.add(Ce.id);const ue=PY(le,I0.current),je=new Set;if(na.current)for(const Ce of le)Ce.type==="dimensions"&&je.add(Ce.id);const xe=je.size===0?ue:ue.map(Ce=>!je.has(Ce.id)||Ce.width===void 0&&Ce.height===void 0?Ce:{...Ce,data:{...Ce.data,...Ce.width!==void 0?{width:Ce.width}:{},...Ce.height!==void 0?{height:Ce.height}:{}}}),Pe=Do.current,tt=Di.current||Pe.size===0?xe:xe.map(Ce=>Pe.has(Ce.id)&&!de.has(Ce.id)&&!Ce.selected?{...Ce,selected:!0}:Ce);if(I0.current=tt,pR(tt),de.size===0)return;if(Di.current){for(const Ce of le)Ce.type==="select"&&(Ce.selected?mf.current.add(Ce.id):mf.current.delete(Ce.id));return}const st=yr.current;if(!st)return;const pt=tt.filter(Ce=>Ce.selected).map(Ce=>Ce.id),Re=Do.current;Re.size===pt.length&&pt.every(Ce=>Re.has(Ce))||(Do.current=new Set(pt),st(pt,[...oa.current]))},[]),gf=m.useRef([]),rre=m.useCallback(K=>{var pt;const ee=Di.current?mR.current:(pt=Ha.current)!=null&&pt.shift?Ha.current.edgeIds:null,le=ee&&ee.size>0?K.filter(Re=>Re.type!=="select"?!0:!(Re.selected===!1&&ee.has(Re.id))):K,de=new Set;for(const Re of le)Re.type==="select"&&de.add(Re.id);if(de.size===0)return;if(Di.current){for(const Re of le)Re.type==="select"&&(Re.selected?kf.current.add(Re.id):kf.current.delete(Re.id));return}const ue=yr.current;if(!ue)return;const xe=jY(le,gf.current).filter(Re=>Re.selected).map(Re=>Re.id),Pe=oa.current;Pe.size===xe.length&&xe.every(Re=>Pe.has(Re))||(oa.current=new Set(xe),ue([...Do.current],xe))},[]),are=m.useCallback(K=>{Di.current=!0;const ee=Ha.current,le=(ee==null?void 0:ee.shift)??(K.shiftKey||K.metaKey||K.ctrlKey);yR.current=le?new Set((ee==null?void 0:ee.nodeIds)??Do.current):new Set,mR.current=le?new Set((ee==null?void 0:ee.edgeIds)??oa.current):new Set,mf.current=new Set(yR.current),kf.current=new Set(mR.current)},[]),ire=m.useCallback(()=>{Di.current=!1,Ha.current=null;const K=yr.current;if(!K)return;const ee=[...mf.current],le=new Set(ee),de=new Set(kf.current);for(const tt of gf.current)le.has(tt.source)&&le.has(tt.target)&&de.add(tt.id);const ue=Do.current,je=oa.current,xe=ue.size===le.size&&ee.every(tt=>ue.has(tt)),Pe=je.size===de.size&&[...de].every(tt=>je.has(tt));xe&&Pe||(Do.current=new Set(ee),oa.current=new Set(de),K(ee,[...de]))},[]),sre=m.useCallback(K=>{if(Ha.current=null,pn.current||K.button!==0)return;const ee=K.target;ee!=null&&ee.classList.contains("react-flow__pane")&&(Ha.current={shift:K.shiftKey||K.metaKey||K.ctrlKey,nodeIds:new Set(Do.current),edgeIds:new Set(oa.current)})},[]),cre=m.useCallback(K=>{if(!Pa.current.enableContextMenu||Do.current.size<2)return;const le=K.target;le!==$e.current&&(le!=null&&le.closest(".seeflow-connector-endpoint-dot")||(K.preventDefault(),K.stopPropagation(),Ot.current=null,Ae(!0),Je(null),pr(null),T({x:K.clientX,y:K.clientY})))},[]),lre=m.useCallback(K=>{const ee=K.dataTransfer;if(!ee)return;const le=ee.types?Array.from(ee.types):[],de=le.includes("Files"),ue=le.includes(lW),je=de&&!!P&&He.enableImageDrop,xe=ue&&!!$&&He.enableDragDrop;if(!(!je&&!xe)){K.preventDefault();try{ee.dropEffect="copy"}catch{}}},[P,$,He.enableImageDrop,He.enableDragDrop]),dre=m.useCallback(K=>{const ee=K.dataTransfer;if((ee!=null&&ee.types?Array.from(ee.types):[]).includes(lW)&&$&&He.enableDragDrop){K.preventDefault();const je=Xt.current;if(!je)return;const xe=je.screenToFlowPosition({x:K.clientX,y:K.clientY});$({position:xe});return}if(!P||!He.enableImageDrop)return;const ue={x:K.clientX,y:K.clientY};K.preventDefault(),LIe({dataTransfer:ee,clientPos:ue,rfInstance:Xt.current,computeDims:IIe,dispatch:P})},[P,$,He.enableImageDrop,He.enableDragDrop]),wF=!!X,MF=Jn.size===1?[...Jn][0]:null,kR=m.useMemo(()=>{const K=Pe=>{const tt=AG(sr,Pe.source)==="running"||AG(sr,Pe.target)==="running",st=Jn.has(Pe.id),pt=PRe(Pe,tt,st);st&&(pt.selected=!0);const Re=wF&&Pe.id===MF,Dn=Re?{...pt,reconnectable:!0}:pt;return{...Dn,data:{...Dn.data,onLabelChange:gt?S:void 0,reconnectable:Re,registerEditHandle:jd}}},ee=new Set(c.map(Pe=>Pe.id)),le=c.map(Pe=>K(jet(Pe,Po==null?void 0:Po[Pe.id]))),de=[];if(Po)for(const[Pe,tt]of Object.entries(Po)){if(ee.has(Pe))continue;const st=tt;typeof st.source!="string"||typeof st.target!="string"||de.push(K({...st,id:Pe}))}const ue=[...le,...de],je=[],xe=[];for(const Pe of ue)Jn.has(Pe.id)?xe.push(Pe):je.push(Pe);return[...je,...xe]},[c,sr,Jn,MF,Po,S,wF,jd,gt]);m.useEffect(()=>{gf.current=kR},[kR]);const N0=e.adapter??null,ure=m.useMemo(()=>{if(N0!=null&&N0.computeLayout)return async()=>{const K=Xt.current,ee=I0.current;if(ee.length<2)return;const le=ee.map(yt=>{var A0;const Ce=(A0=K==null?void 0:K.getInternalNode(yt.id))==null?void 0:A0.measured,en=yt.data,Dd=(Ce==null?void 0:Ce.width)??en.width??200,kr=(Ce==null?void 0:Ce.height)??en.height??120;return{id:yt.id,type:yt.type,width:Dd,height:kr}}),de=new Map;for(const yt of ee)de.set(yt.id,yt.position);const ue=gf.current.map(yt=>({id:yt.id,source:yt.source,target:yt.target})),je=N0.computeLayout;if(!je)return;const xe=await je(le,ue),Pe=new Map;for(const[yt,Ce]of Object.entries(xe.nodes))Pe.set(yt,Ce.position);let tt=Number.POSITIVE_INFINITY,st=Number.POSITIVE_INFINITY,pt=Number.POSITIVE_INFINITY,Re=Number.POSITIVE_INFINITY;for(const yt of le){const Ce=de.get(yt.id);if(!Ce)continue;Ce.x<tt&&(tt=Ce.x),Ce.y<st&&(st=Ce.y);const en=Pe.get(yt.id);en&&(en.x<pt&&(pt=en.x),en.y<Re&&(Re=en.y))}const Dn=Number.isFinite(tt)&&Number.isFinite(pt)?tt-pt:0,mr=Number.isFinite(st)&&Number.isFinite(Re)?st-Re:0;pR(yt=>yt.map(Ce=>{const en=Pe.get(Ce.id);return en?{...Ce,position:{x:en.x+Dn,y:en.y+mr}}:Ce}))}},[N0]),vf=we??(gt?void 0:ure),xf=m.useRef(!1),bF=m.useRef(null),hre=m.useCallback(K=>{var Pe;if(!gt||!N)return;const{source:ee,target:le}=K;if(!ee||!le||ee===le)return;xf.current=!0;const de=((Pe=bF.current)==null?void 0:Pe.nodeId)??null,ue=de!==null&&de===le&&de!==ee;N(ue?le:ee,ue?ee:le)},[N,gt]),gR=m.useCallback(K=>{const ee=le=>{if(!le)return!1;const de=I0.current.find(ue=>ue.id===le);return de?de.type==="text":!1};return!ee(K.source)&&!ee(K.target)},[]),fre=m.useCallback((K,ee)=>{var pt;ea(!1),Ra();const le=xf.current;if(xf.current=!1,le||zo.current)return;if(zi.current){zi.current=!1;return}if(!N)return;const de=(pt=ee.fromNode)==null?void 0:pt.id,ue=ee.fromHandle;if(!de||!ue)return;const je=SG(K);if(!je)return;const xe=OT(Kt.current,je.clientX,je.clientY);if(!xe)return;const Pe=xe.getAttribute("data-id");if(!Pe||Pe===de||!gR({source:de,target:Pe,sourceHandle:null,targetHandle:null}))return;let tt;const st=Xt.current;if(st){const Re=st.getInternalNode(Pe);if(Re){const Dn=Re.measured.width??Re.width??0,mr=Re.measured.height??Re.height??0;if(Dn>0&&mr>0){const yt=st.screenToFlowPosition({x:je.clientX,y:je.clientY});tt=tH({x:Re.internals.positionAbsolute.x,y:Re.internals.positionAbsolute.y,w:Dn,h:mr},yt)}}}N(de,Pe,tt?{targetPin:tt}:void 0)},[N,Ra,gR]),wf=m.useRef(!1),pre=m.useCallback((K,ee)=>{if(!X)return;const{source:le,target:de,sourceHandle:ue,targetHandle:je}=ee;if(!le||!de||le===de)return;const xe={};if(le!==K.source&&(xe.source=le),de!==K.target&&(xe.target=de),typeof ue=="string"&&ue!==K.sourceHandle&&(xe.sourceHandle=ue),typeof je=="string"&&je!==K.targetHandle&&(xe.targetHandle=je),xe.source===void 0&&xe.target===void 0&&xe.sourceHandle===void 0&&xe.targetHandle===void 0)return;(xe.source!==void 0||xe.sourceHandle!==void 0)&&(xe.sourceHandleAutoPicked=!1),(xe.target!==void 0||xe.targetHandle!==void 0)&&(xe.targetHandleAutoPicked=!1);const Pe=Xt.current;if(!(xe.source===void 0&&xe.target===void 0)&&Pe){const st=xe.source!==void 0?"source":"target",pt=LG(st,K.source,K.target,K.data,Re=>Pe.getInternalNode(Re)??null);pt&&(st==="source"?xe.targetPin=pt:xe.sourcePin=pt)}wf.current=!0,X(K.id,xe)},[X]),yre=m.useCallback((K,ee,le,de)=>{var Dd;ea(!1),Ra(),zo.current=!1;const ue=wf.current;if(wf.current=!1,ue)return;if(za.current){za.current=!1;return}if(!X)return;const je=SG(K);let xe=((Dd=de.toNode)==null?void 0:Dd.id)??null;if(!xe&&je){const kr=OT(Kt.current,je.clientX,je.clientY);xe=(kr==null?void 0:kr.getAttribute("data-id"))??null}const Pe=le==="source"?"target":"source",tt=$et(Pe,ee.source,ee.target,xe);if(tt==="no-op"||tt==="self-loop"||!je)return;const st=Xt.current;if(!st)return;const pt=tt==="pin-own"?Pe==="source"?ee.source:ee.target:xe,Re=st.getInternalNode(pt);if(!Re)return;const Dn=Re.measured.width??Re.width??0,mr=Re.measured.height??Re.height??0;if(Dn===0||mr===0)return;const yt=st.screenToFlowPosition({x:je.clientX,y:je.clientY}),Ce=tH({x:Re.internals.positionAbsolute.x,y:Re.internals.positionAbsolute.y,w:Dn,h:mr},yt);if(tt==="pin-own"){if(!J)return;J(ee.id,Pe,Ce);return}const en=LG(Pe,ee.source,ee.target,ee.data,kr=>st.getInternalNode(kr)??null);Pe==="source"?X(ee.id,{source:xe,sourceHandle:null,sourceHandleAutoPicked:!1,sourcePin:Ce,...en?{targetPin:en}:{}}):X(ee.id,{target:xe,targetHandle:null,targetHandleAutoPicked:!1,targetPin:Ce,...en?{sourcePin:en}:{}})},[X,Ra,J]),Hi=m.useMemo(()=>{var Pe;if(!To||!go)return null;const K=(Pe=Kt.current)==null?void 0:Pe.getBoundingClientRect(),ee=(K==null?void 0:K.left)??0,le=(K==null?void 0:K.top)??0,de=Math.min(To.x,go.x),ue=Math.min(To.y,go.y),je=Math.abs(go.x-To.x),xe=Math.abs(go.y-To.y);return{left:de-ee,top:ue-le,width:je,height:xe}},[To,go]),qa=bt?n2(Xa).node:void 0,mre=bt?OJ(bt):"",kre=bt?FJ(bt,qa):void 0,gre=bt==="text",[_F,CF]=m.useState(!1),[vre,Mf]=m.useState(!1),[xre,SF]=m.useState(!1),Oa=xet({projectId:r,getReactFlow:()=>Xt.current});m.useImperativeHandle(t,()=>({exportPdf:Oa.exportPdf,exportPng:Oa.exportPng,openEmbedDialog:()=>SF(!0),capturePreview:Oa.capturePreview}),[Oa.exportPdf,Oa.exportPng,Oa.capturePreview]),m.useEffect(()=>{if(!He.enableKeyboard)return;const K=de=>{if(!de)return!1;const ue=de.tagName;return ue==="INPUT"||ue==="TEXTAREA"||ue==="SELECT"?!0:de instanceof HTMLElement&&de.isContentEditable},ee=de=>{de.code==="Space"&&(K(document.activeElement)||(de.preventDefault(),CF(!0)))},le=de=>{de.code==="Space"&&(CF(!1),Mf(!1))};return window.addEventListener("keydown",ee),window.addEventListener("keyup",le),()=>{window.removeEventListener("keydown",ee),window.removeEventListener("keyup",le)}},[He.enableKeyboard]);const bf=m.useCallback(K=>{if(K.length!==0){if(!gt){const ee=S0.current;for(const le of K)ee.set(le.id,{x:le.position.x,y:le.position.y});return}if(K.length===1){const ee=K[0];ee&&k&&k(ee.id,{x:ee.position.x,y:ee.position.y});return}if(x){x(K.map(ee=>({id:ee.id,position:{x:ee.position.x,y:ee.position.y}})));return}if(k)for(const ee of K)k(ee.id,{x:ee.position.x,y:ee.position.y})}},[k,x,gt]),wre=m.useCallback((K,ee,le)=>{ta.current=!1,bf(le),q()},[bf,q]),Mre=m.useCallback(()=>{ta.current=!0},[]),bre=m.useCallback((K,ee)=>{ta.current=!1,bf(ee),q()},[bf,q]),_re=m.useCallback((K,ee)=>{ke==null||ke(ee.id)},[ke]),Cre=m.useCallback(K=>{ve==null||ve()},[ve]),Sre=m.useCallback((K,ee)=>{ge==null||ge(ee.id)},[ge]),LF=bt?"crosshair":Kn||_F?vre?"grabbing":"grab":void 0,IF=l[0],NF=h[0],Lre=IF?s.find(K=>K.id===IF)??null:null,Ire=NF?c.find(K=>K.id===NF)??null:null,Nre=r??null,Are=He.showDetailPanel&&!Ge,Ere=m.useMemo(()=>({custom:Qe??{}}),[Qe]);return p.jsx(RDe,{value:Ere,children:p.jsx("div",{"data-testid":"seeflow-canvas","data-mode":n,"data-canvas-mode":rn.kind,ref:Kt,className:"seeflow-canvas-root sf:relative sf:h-full sf:w-full",style:LF?{cursor:LF}:void 0,onPointerDownCapture:sre,onPointerDown:K=>{_F&&Mf(!0),lR(K)},onPointerMove:dR,onPointerUp:K=>{Mf(!1),yf(K)},onPointerCancel:()=>{Ta.current=!1,hr.current=null,fr.current=null,ut(null),vo(null),Mf(!1)},onContextMenuCapture:cre,onDragOver:lre,onDrop:dre,children:p.jsxs(ZOe,{containerRef:Kt,children:[p.jsxs(Xze,{nodes:fR,edges:kR,onNodesChange:ore,nodeTypes:zet,edgeTypes:Ret,proOptions:{hideAttribution:!0},fitView:!0,minZoom:n==="mini"?.05:.5,nodesDraggable:(gt?!!k:!0)&&!bt&&!Kn&&He.enableNodeMove,nodesConnectable:gt&&!!N&&!bt&&!Kn,deleteKeyCode:gt?["Backspace","Delete"]:null,zoomOnScroll:He.enableZoom,zoomOnPinch:He.enableZoom,className:Jr?"seeflow-connecting":void 0,onConnect:gt?hre:void 0,isValidConnection:gR,onConnectStart:(K,ee)=>{ea(!0),xf.current=!1,bF.current={nodeId:ee.nodeId??null,handleType:ee.handleType??null},ur(ee.nodeId??null)},onConnectEnd:fre,onReconnect:gt&&X?pre:void 0,onReconnectStart:(K,ee,le)=>{ea(!0),wf.current=!1,zo.current=!0;const de=le==="source"?ee.source:ee.target;ur(de)},onReconnectEnd:yre,connectionLineComponent:Ro,connectionLineStyle:{strokeWidth:2},connectionRadius:32,reconnectRadius:10,edgesReconnectable:!1,elevateNodesOnSelect:!1,elementsSelectable:!bt&&!Kn&&He.enableSelection,selectNodesOnDrag:!1,nodeClickDistance:5,selectionOnDrag:!bt&&!Kn&&He.enableSelection,panOnDrag:bt?!1:Kn?[0,1,2]:He.enablePan?[1,2]:!1,selectionMode:Vu.Partial,selectionKeyCode:null,multiSelectionKeyCode:bt?null:["Meta","Shift"],panActivationKeyCode:bt?null:"Space",onSelectionStart:are,onSelectionEnd:ire,defaultEdgeOptions:Tet,zoomOnDoubleClick:!1,onInit:K=>{Xt.current=K;const ee=Kt.current;ee&&ee.style.setProperty("--rf-zoom",String(K.getZoom())),ee&&ee.setAttribute("data-canvas-ready","true"),!Qr.current&&Yr.onMount&&s.length>0&&(K.fitView(G0),Qr.current=!0),se==null||se(K)},onMove:(K,ee)=>{Xn.current&&dr(null);const le=Kt.current;le&&le.style.setProperty("--rf-zoom",String(ee.zoom))},onEdgesChange:rre,onNodeDragStart:()=>{ta.current=!0},onNodeDragStop:wre,onSelectionDragStart:Mre,onSelectionDragStop:bre,onNodeClick:_re,onEdgeClick:Sre,onEdgeDoubleClick:(K,ee)=>{var le;(le=lr.current.get(ee.id))==null||le()},onPaneClick:Cre,onNodeContextMenu:He.enableContextMenu&&Z?(K,ee)=>{K.preventDefault(),Ot.current=ee.id,Ae(!0),Je(ee.type??null),pr(null),T({x:K.clientX,y:K.clientY})}:void 0,onPaneContextMenu:He.enableContextMenu&&B?K=>{K.preventDefault(),Ot.current=null,Ae(!1),Je(null),pr(null),T({x:K.clientX,y:K.clientY})}:void 0,children:[p.jsx(qet,{storeApiRef:jo}),p.jsx(Oet,{wrapperRef:Kt}),p.jsx(aRe,{gap:12,size:.6}),n!=="mini"&&p.jsx(_et,{}),He.showControls?p.jsxs(hRe,{showInteractive:!1,showFitView:!1,children:[p.jsx(fu,{"data-testid":"controls-fit-view","aria-label":"Fit view",title:"Fit view",disabled:s.length===0,onClick:()=>{var K;(K=Xt.current)==null||K.fitView(G0)},children:p.jsx(rd,{className:"sf:h-3 sf:w-3","aria-hidden":"true"})}),p.jsx(fu,{"data-testid":"controls-tidy","aria-label":"Tidy layout (⌘⇧L)",title:"Tidy layout (⌘⇧L)",disabled:!vf,onClick:()=>vf==null?void 0:vf(),children:p.jsx(S2,{className:"sf:h-3 sf:w-3","aria-hidden":"true"})})]}):null,He.showMiniMap?p.jsx(CRe,{className:"sf-canvas-minimap"}):null,He.showResizeHandles?p.jsx(kJe,{selectedNodes:L0,onMultiResize:b}):null,He.showToolbar||He.showStyleStrip&&E&&oe?p.jsx(Zu,{position:"top-left",children:p.jsxs("div",{className:"sf:flex sf:flex-col sf:gap-2",children:[He.showToolbar?p.jsx(WUe,{mode:rn,onModeChange:Ee,iconPickerOpen:Ve??!1,onOpenIconPicker:lt,onCloseIconPicker:Vt,onPickIcon:Et,showShapeTools:gt&&!!A}):null,He.showStyleStrip&&E&&oe?p.jsx(gJe,{nodes:hR,connectors:D??[],onStyleNode:E,onStyleNodePreview:W,onStyleNodes:Y,onStyleNodesPreview:Q,onStyleConnector:oe,onStyleConnectorPreview:te,onRequestIconReplace:ce}):null]})}):null,He.showShareMenu||He.showRestart&&_n?p.jsx(Zu,{position:"top-right",children:p.jsxs("div",{className:"sf:flex sf:items-center sf:gap-1",children:[He.showRestart&&_n?p.jsx(fJe,{onRestartDemo:_n}):null,He.showShareMenu?p.jsx(hJe,{mode:n==="mini"?"view":n,projectId:r,enableEmbed:He.enableEmbed,onDownloadPdf:Oa.exportPdf,onDownloadPng:Oa.exportPng,onExportToCloud:ft,embedOpen:xre,onEmbedOpenChange:SF}):null]})}):null]}),Hi?p.jsx("div",{"data-testid":"canvas-draw-ghost","data-ghost-shape":bt??void 0,"aria-hidden":!0,className:ae("sf:pointer-events-none sf:absolute sf:z-10",mre,gre?"sf:rounded-sm sf:border sf:border-dashed sf:border-muted-foreground/40":""),style:{...kre,left:Hi.left,top:Hi.top,width:Hi.width,height:Hi.height},children:(()=>{const K=bt?PO[bt]:void 0;if(!K)return null;const ee=VJ(qa);return p.jsx(K,{width:Hi.width,height:Hi.height,borderColor:ee.borderColor,backgroundColor:ee.backgroundColor,borderSize:(qa==null?void 0:qa.borderSize)??uO,borderStyle:qa==null?void 0:qa.borderStyle})})()}):null,He.enableContextMenu&&Z?p.jsxs(TBe,{onOpenChange:K=>{K||(T(null),Ot.current=null,Je(null),pr(null))},children:[p.jsx(DBe,{asChild:!0,children:p.jsx("div",{ref:$e,"data-testid":"node-context-menu-trigger","aria-hidden":!0,className:"sf:pointer-events-none sf:fixed",style:{left:(V==null?void 0:V.x)??0,top:(V==null?void 0:V.y)??0,width:0,height:0}})}),p.jsxs(bte,{"data-testid":"node-context-menu",children:[Yt!=null&&Yt.pinned&&ln?p.jsx(Lr,{"data-testid":"connector-endpoint-context-menu-unpin",onSelect:uR,children:"Unpin"}):null,ie&&H?p.jsxs(Lr,{"data-testid":"node-context-menu-copy",onSelect:Tn,children:["Copy",p.jsx(SH,{children:_t})]}):null,B?p.jsxs(Lr,{"data-testid":"node-context-menu-paste",disabled:!z,onSelect:Da,children:["Paste",p.jsx(SH,{children:Qt})]}):null,ie&&(H||B)&&(be==="icon"&&ce||j||O)?p.jsx(FP,{}):null,ie&&be==="icon"&&ce?p.jsx(Lr,{"data-testid":"node-context-menu-change-icon",onSelect:Td,children:"Change icon"}):null,ie&&be==="icon"&&ce&&(j||O)?p.jsx(FP,{}):null,ie&&j?p.jsxs(p.Fragment,{children:[p.jsx(Lr,{"data-testid":"node-context-menu-to-front",onSelect:()=>it({op:"toFront"}),children:"Bring to front"}),p.jsx(Lr,{"data-testid":"node-context-menu-forward",onSelect:()=>it({op:"forward"}),children:"Bring forward"}),p.jsx(Lr,{"data-testid":"node-context-menu-backward",onSelect:()=>it({op:"backward"}),children:"Send backward"}),p.jsx(Lr,{"data-testid":"node-context-menu-to-back",onSelect:()=>it({op:"toBack"}),children:"Send to back"})]}):null,ie&&j&&O?p.jsx(FP,{}):null,ie&&O?p.jsx(Lr,{"data-testid":"node-context-menu-delete",onSelect:yn,children:"Delete"}):null]})]}):null,re?p.jsxs(w0,{open:!!Sn,onOpenChange:K=>{K||dr(null)},children:[p.jsx(KOe,{asChild:!0,children:p.jsx("div",{"data-testid":"drop-popover-anchor","aria-hidden":!0,className:"sf:pointer-events-none sf:fixed",style:{left:(Sn==null?void 0:Sn.clientX)??0,top:(Sn==null?void 0:Sn.clientY)??0,width:0,height:0}})}),p.jsx(Sd,{"data-testid":"drop-popover",align:"start",side:"bottom",sideOffset:4,className:"sf:w-auto sf:p-1",onOpenAutoFocus:K=>{K.preventDefault()},children:p.jsx("div",{role:"menu","aria-label":"Create connected node",className:"sf:flex sf:flex-col sf:gap-0.5",children:UUe.map(({shape:K,label:ee,Icon:le})=>p.jsxs("button",{type:"button",role:"menuitem","data-testid":`drop-popover-shape-${K}`,onClick:()=>{const de=Sn;de&&(re({sourceNodeId:de.sourceNodeId,position:{x:de.flowX,y:de.flowY},shape:K}),dr(null))},className:ae("sf:flex sf:items-center sf:gap-2 sf:rounded-sm sf:px-2 sf:py-1.5 sf:text-left sf:text-sm","sf:hover:bg-accent sf:hover:text-accent-foreground","sf:focus:bg-accent sf:focus:text-accent-foreground sf:focus:outline-hidden"),children:[p.jsx(le,{className:"sf:h-4 sf:w-4 sf:text-muted-foreground","aria-hidden":"true"}),p.jsx("span",{children:ee})]},K))})})]}):null,Are?p.jsx(HQe,{flowId:Nre,node:Lre,connector:Ire,adapter:o??null,statusReport:G,onNameChange:ne,onDescriptionChange:Ie,onDetailChange:De,onIconChange:Ke,onClose:()=>{var K;(K=yr.current)==null||K.call(yr,[],[])}}):null]})})})}const Get=m.forwardRef(Wet);function Zet({open:e,onOpenChange:t,onCreated:n}){const[o,r]=m.useState(""),[a,i]=m.useState(""),[s,c]=m.useState(""),[l,h]=m.useState(null),[u,f]=m.useState(!1);m.useEffect(()=>{e&&(r(""),i(""),c(""),h(null),f(!1))},[e]);const y=o.trim(),k=a.trim(),x=s.trim(),w=y.length>0&&k.length>0&&!u,g=async M=>{if(M.preventDefault(),!!w){f(!0),h(null);try{const v=await sse({path:y,name:k,...x.length>0?{description:x}:{}});n(v),t(!1)}catch(v){h(v instanceof Error?v.message:String(v)),f(!1)}}};return p.jsx(Wz,{open:e,onOpenChange:t,children:p.jsxs(ef,{className:"sm:max-w-md","data-testid":"create-project-dialog",onOpenAutoFocus:M=>{M.preventDefault();const v=document.querySelector('[data-testid="create-project-path-input"]');v==null||v.focus()},children:[p.jsxs(tf,{children:[p.jsx(nf,{children:"Create new project"}),p.jsx(of,{children:"Scaffold a new SeeFlow project at the path you provide."})]}),p.jsxs("form",{onSubmit:g,className:"flex flex-col gap-4",children:[p.jsxs("label",{className:"flex flex-col gap-1.5 text-sm",children:[p.jsx("span",{className:"font-medium",children:"Project path"}),p.jsx("input",{type:"text",required:!0,autoComplete:"off",spellCheck:!1,placeholder:"/absolute/path/to/my-project",value:o,onChange:M=>r(M.target.value),"data-testid":"create-project-path-input",className:"rounded-md border bg-background px-3 py-2 text-sm outline-hidden ring-offset-background focus:border-ring focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2"})]}),p.jsxs("label",{className:"flex flex-col gap-1.5 text-sm",children:[p.jsx("span",{className:"font-medium",children:"Project name"}),p.jsx("input",{type:"text",required:!0,autoComplete:"off",spellCheck:!1,value:a,onChange:M=>i(M.target.value),"data-testid":"create-project-name-input",className:"rounded-md border bg-background px-3 py-2 text-sm outline-hidden ring-offset-background focus:border-ring focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2"})]}),p.jsxs("label",{className:"flex flex-col gap-1.5 text-sm",children:[p.jsxs("span",{className:"font-medium",children:["Description ",p.jsx("span",{className:"text-muted-foreground",children:"(optional)"})]}),p.jsx("textarea",{rows:3,autoComplete:"off",spellCheck:!1,value:s,onChange:M=>c(M.target.value),"data-testid":"create-project-description-input",className:"rounded-md border bg-background px-3 py-2 text-sm outline-hidden ring-offset-background focus:border-ring focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2"})]}),l?p.jsx("div",{role:"alert","data-testid":"create-project-error",className:"rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-sm text-destructive",children:l}):null,p.jsxs(a0,{children:[p.jsx(qt,{type:"button",variant:"ghost",onClick:()=>t(!1),disabled:u,children:"Cancel"}),p.jsx(qt,{type:"submit",disabled:!w,"data-testid":"create-project-submit",children:u?"Creating…":"Create project"})]})]})]})})}const BH="seeflow:navigate",Ket=e=>(window.addEventListener("popstate",e),window.addEventListener(BH,e),()=>{window.removeEventListener("popstate",e),window.removeEventListener(BH,e)}),EG=()=>window.location.pathname,Xet=()=>m.useSyncExternalStore(Ket,EG,EG),c0=e=>{e!==window.location.pathname&&(window.history.pushState({},"",e),window.dispatchEvent(new Event(BH)))};/**
8543
+ `)}async function uet(e,t){const n=t.fontEmbedCSS!=null?t.fontEmbedCSS:t.skipFonts?null:await det(e,t);if(n){const o=document.createElement("style"),r=document.createTextNode(n);o.appendChild(r),e.firstChild?e.insertBefore(o,e.firstChild):e.appendChild(o)}}async function het(e,t={}){const{width:n,height:o}=Loe(e,t),r=await sR(e,t,!0);return await uet(r,t),await Poe(r,t),ret(r,t),await IJe(r,n,o)}async function fet(e,t={}){const{width:n,height:o}=Loe(e,t),r=await het(e,t),a=await Xj(r),i=document.createElement("canvas"),s=i.getContext("2d"),c=t.pixelRatio||CJe(),l=t.canvasWidth||n,h=t.canvasHeight||o;return i.width=l*c,i.height=h*c,t.skipAutoScale||SJe(i),i.style.width=`${l}`,i.style.height=`${h}`,t.backgroundColor&&(s.fillStyle=t.backgroundColor,s.fillRect(0,0,i.width,i.height)),s.drawImage(a,0,0,i.width,i.height),i}async function pet(e,t={}){return(await fet(e,t)).toDataURL()}const yet=e=>e instanceof Element?!(e.classList.contains("react-flow__minimap")||e.classList.contains("react-flow__controls")||e.classList.contains("react-flow__panel")):!0,met=e=>{var o;let t=e;for(;t&&!t.classList.contains("seeflow-canvas-root");)t=t.parentElement;if(t){const r=getComputedStyle(t).getPropertyValue("--bg-canvas").trim();if(r.length>0)return r}const n=(o=e.ownerDocument)==null?void 0:o.documentElement;return n!=null&&n.classList.contains("dark")?"#0a0a0c":"#fafafa"},ket=async e=>{const t=await pet(e,{cacheBust:!0,filter:yet,backgroundColor:met(e)}),n=await new Promise((o,r)=>{const a=new Image;a.onload=()=>o({width:a.naturalWidth,height:a.naturalHeight}),a.onerror=()=>r(new Error("Failed to decode captured image")),a.src=t});return{dataUrl:t,...n}},get=(e,t)=>{const n=document.createElement("a");n.href=e,n.download=t,n.rel="noopener",document.body.appendChild(n),n.click(),n.remove()},vet=e=>{const t=e.replace(/[^A-Za-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"");return t.length>0?t.slice(0,80):"canvas"},_G=(e,t)=>`${vet(e??"canvas")}.${t}`,xet=({projectId:e,getReactFlow:t})=>{const[n,o]=m.useState(null),r=m.useCallback(()=>o(null),[]),a=m.useCallback(async()=>{const l=t();if(!l)return null;const h=document.querySelector(".react-flow__viewport");if(!h)return null;const u=l.getViewport();try{return await l.fitView({duration:0,padding:.1}),await new Promise(f=>requestAnimationFrame(()=>f())),await ket(h)}finally{l.setViewport(u,{duration:0})}},[t]),i=m.useCallback(async()=>{o(null);try{const l=await a();if(!l)return;get(l.dataUrl,_G(e,"png"))}catch(l){o(l instanceof Error?l.message:String(l))}},[a,e]),s=m.useCallback(async()=>{o(null);try{const l=await a();if(!l)return;const{jsPDF:h}=await Iz(async()=>{const{jsPDF:y}=await import("./jspdf.es.min-CvwMPY1k.js").then(k=>k.j);return{jsPDF:y}},[]),u=l.width>l.height?"landscape":"portrait",f=new h({orientation:u,unit:"px",format:[l.width,l.height],hotfixes:["px_scaling"]});f.addImage(l.dataUrl,"PNG",0,0,l.width,l.height),f.save(_G(e,"pdf"))}catch(l){o(l instanceof Error?l.message:String(l))}},[a,e]),c=m.useCallback(async()=>{const l=await a();return l==null?void 0:l.dataUrl},[a]);return{exportPdf:s,exportPng:i,capturePreview:c,lastError:n,clearError:r}},wet=12,Met=1200;function bet(e,t={}){const n=t.idleMs??Met;let o,r=null,a=null;const i=typeof requestAnimationFrame<"u",s=()=>{o!==void 0&&(clearTimeout(o),o=void 0)},c=()=>{a!==null&&typeof cancelAnimationFrame<"u"&&cancelAnimationFrame(a),a=null},l=()=>{if(a=null,!r)return;const{clientX:y,clientY:k}=r;r=null;const x=e.getBoundingClientRect();e.style.setProperty("--mx",`${y-x.left}px`),e.style.setProperty("--my",`${k-x.top}px`),e.dataset.active="true",s(),o=setTimeout(()=>{e.dataset.active="false",o=void 0},n)};return{onMove:y=>{if(r={clientX:y.clientX,clientY:y.clientY},!i){l();return}a===null&&(a=requestAnimationFrame(l))},onLeave:()=>{c(),r=null,s(),e.dataset.active="false"},dispose:()=>{c(),r=null,s()}}}function _et(){const e=m.useRef(null),t=Te(i=>i.transform,(i,s)=>i[0]===s[0]&&i[1]===s[1]&&i[2]===s[2]),[n,o,r]=t,a=wet*r;return m.useEffect(()=>{var u;const i=e.current;if(!i)return;const s=(u=i.parentElement)==null?void 0:u.querySelector(".react-flow__pane");if(!s)return;const{onMove:c,onLeave:l,dispose:h}=bet(i);return s.addEventListener("mousemove",c,{passive:!0}),s.addEventListener("mouseleave",l,{passive:!0}),()=>{s.removeEventListener("mousemove",c),s.removeEventListener("mouseleave",l),h()}},[]),p.jsx("div",{ref:e,className:"glow-overlay","data-active":"false","data-testid":"canvas-glow-overlay",style:{backgroundPosition:`${n}px ${o}px`,backgroundSize:`${a}px ${a}px`}})}const Cet={showToolbar:!0,showStyleStrip:!0,showDetailPanel:!0,showStatusBadges:!0,showResizeHandles:!0,showControls:!0,showShareMenu:!0,showMiniMap:!0,showRestart:!0,enableKeyboard:!0,enableContextMenu:!0,enableDragDrop:!0,enableImageDrop:!0,enableZoom:!0,enablePan:!0,enableSelection:!0,enableNodeMove:!0,enableEmbed:!1},Let={showToolbar:!0,showStyleStrip:!1,showDetailPanel:!1,showStatusBadges:!0,showResizeHandles:!1,showControls:!0,showShareMenu:!0,showMiniMap:!0,showRestart:!1,enableKeyboard:!1,enableContextMenu:!1,enableDragDrop:!1,enableImageDrop:!1,enableZoom:!0,enablePan:!0,enableSelection:!0,enableNodeMove:!0,enableEmbed:!1},Iet={showToolbar:!1,showStyleStrip:!1,showDetailPanel:!1,showStatusBadges:!1,showResizeHandles:!1,showControls:!1,showShareMenu:!1,showMiniMap:!1,showRestart:!1,enableKeyboard:!1,enableContextMenu:!1,enableDragDrop:!1,enableImageDrop:!1,enableZoom:!1,enablePan:!1,enableSelection:!1,enableNodeMove:!1,enableEmbed:!1};function Net(e){const t=e.mode==="edit"?Cet:e.mode==="mini"?Iet:Let;return{showToolbar:e.showToolbar??t.showToolbar,showStyleStrip:e.showStyleStrip??t.showStyleStrip,showDetailPanel:e.showDetailPanel??t.showDetailPanel,showStatusBadges:e.showStatusBadges??t.showStatusBadges,showResizeHandles:e.showResizeHandles??t.showResizeHandles,showControls:e.showControls??t.showControls,showShareMenu:e.showShareMenu??t.showShareMenu,showMiniMap:e.showMiniMap??t.showMiniMap,showRestart:e.showRestart??t.showRestart,enableKeyboard:e.enableKeyboard??t.enableKeyboard,enableContextMenu:e.enableContextMenu??t.enableContextMenu,enableDragDrop:e.enableDragDrop??t.enableDragDrop,enableImageDrop:e.enableImageDrop??t.enableImageDrop,enableZoom:e.enableZoom??t.enableZoom,enablePan:e.enablePan??t.enablePan,enableSelection:e.enableSelection??t.enableSelection,enableNodeMove:e.enableNodeMove??t.enableNodeMove,enableEmbed:e.enableEmbed??t.enableEmbed}}const CG=40,G0={padding:.15,duration:300,includeHiddenNodes:!1};function Aet(e){return e===void 0||e===!1?{onMount:!1,onExternalNodeChange:!1}:e===!0?{onMount:!0,onExternalNodeChange:!0}:{onMount:e.onMount??!0,onExternalNodeChange:e.onExternalNodeChange??!0}}const SG=e=>{if("clientX"in e)return{clientX:e.clientX,clientY:e.clientY};const t=e.changedTouches[0]??e.touches[0];return t?{clientX:t.clientX,clientY:t.clientY}:null},Eet=(e,t)=>{var o;const n=document.elementsFromPoint(e,t);for(const r of n){const a=(o=r.closest)==null?void 0:o.call(r,".react-flow__node");if(a)return a}return null},zoe=15,OT=(e,t,n)=>{const o=Eet(t,n);if(o)return o;if(!e)return null;let r=null,a=zoe;const i=e.querySelectorAll(".react-flow__node");for(const s of i){const c=s.getBoundingClientRect();if(c.width===0||c.height===0)continue;const l=Math.max(c.left-t,0,t-c.right),h=Math.max(c.top-n,0,n-c.bottom),u=Math.hypot(l,h);u<=a&&(r=s,a=u)}return r};function LG(e,t,n,o,r){if(e==="source"?(o==null?void 0:o.targetPin)!==void 0||(o==null?void 0:o.targetHandleAutoPicked)===!1:(o==null?void 0:o.sourcePin)!==void 0||(o==null?void 0:o.sourceHandleAutoPicked)===!1)return;const i=e==="source"?n:t,s=e==="source"?t:n,c=r(i),l=r(s);if(!c||!l)return;const h=c.measured.width??c.width??0,u=c.measured.height??c.height??0,f=l.measured.width??l.width??0,y=l.measured.height??l.height??0;if(h===0||u===0||f===0||y===0)return;const k={x:c.internals.positionAbsolute.x,y:c.internals.positionAbsolute.y,w:h,h:u},x={x:l.internals.positionAbsolute.x+f/2,y:l.internals.positionAbsolute.y+y/2};return HRe(k,Lj(k,x))}function $et(e,t,n,o){if(o===null)return"no-op";const r=e==="source"?t:n;return o===(e==="source"?n:t)?"self-loop":o===r?"pin-own":"reconnect-and-pin"}const Pet=(e,t)=>{if(!t)return e;const n=t.data?{...e.data,...t.data}:e.data;return{...e,...t,data:n}},jet=(e,t)=>t?{...e,...t}:e,zet={rectangle:FFe,ellipse:Ga,sticky:Ga,text:Ga,database:Ga,server:Ga,user:Ga,queue:Ga,cloud:Ga,image:RFe,icon:XRe,html:EFe,component:rFe},Ret={editableEdge:UFe},Tet={zIndex:0},Det=8,IG=(e,t)=>e?typeof e=="string"?`url('#${e}')`:`url('#${`${t?`${t}__`:""}${Object.keys(e).sort().map(r=>`${r}=${e[r]}`).join("&")}`}')`:void 0,Het=e=>function({fromX:n,fromY:o,toX:r,toY:a,fromPosition:i,toPosition:s,connectionLineStyle:c}){const l=Te(U=>e.current?U.edges.find(D=>D.reconnectable===!0)??null:null),h=l==null?void 0:l.data,u=Te(U=>{var E;const D=U.connection;return((E=D==null?void 0:D.fromHandle)==null?void 0:E.nodeId)??null}),f=Te(U=>l!=null&&l.source?U.nodeLookup.get(l.source)??null:null),y=Te(U=>l!=null&&l.target?U.nodeLookup.get(l.target)??null:null),k=Te(U=>u?U.nodeLookup.get(u)??null:null),x=(l==null?void 0:l.source)===u,w=l?x?f:y:k,g=x?y:f,M=x?h==null?void 0:h.sourcePin:h==null?void 0:h.targetPin,v=x?h==null?void 0:h.sourceHandleAutoPicked:h==null?void 0:h.targetHandleAutoPicked;let b=n,C=o,_=i;if(w){const U=w.measured.width??w.width??0,D=w.measured.height??w.height??0;if(U>0&&D>0){const E={x:w.internals.positionAbsolute.x,y:w.internals.positionAbsolute.y,w:U,h:D};let W=null;if(M)W=Ij(E,M);else if(v!==!1&&g){const Y=g.measured.width??g.width??0,Q=g.measured.height??g.height??0;if(Y>0&&Q>0){const oe={x:g.internals.positionAbsolute.x+Y/2,y:g.internals.positionAbsolute.y+Q/2};W=Lj(E,oe)}}W&&(b=W.x,C=W.y,_=NG[W.side])}}const S=Te(U=>U.transform[2]),A=Te(U=>U.nodeLookup),P=Te(U=>{var D;return((D=U.connection.toHandle)==null?void 0:D.nodeId)??null});let I=r,$=a,N=s;if(S>0){const U=zoe/S,D=l?x?l.target:l.source:null;let E=null;if(P&&P!==D){const W=A.get(P)??null;W&&(E=W)}if(!E){let W=U;for(const Y of A.values()){if(D&&Y.id===D||w&&Y.id===w.id)continue;const Q=Y.measured.width??Y.width??0,oe=Y.measured.height??Y.height??0;if(Q===0||oe===0)continue;const te=Y.internals.positionAbsolute.x,se=Y.internals.positionAbsolute.y,we=Math.max(te-r,0,r-(te+Q)),ke=Math.max(se-a,0,a-(se+oe)),ge=Math.hypot(we,ke);ge<=W&&(W=ge,E=Y)}}if(!E&&l&&w){const W=w.measured.width??w.width??0,Y=w.measured.height??w.height??0;if(W>0&&Y>0){const Q=w.internals.positionAbsolute.x,oe=w.internals.positionAbsolute.y,te=Math.max(Q-r,0,r-(Q+W)),se=Math.max(oe-a,0,a-(oe+Y));Math.hypot(te,se)<=U&&(E=w)}}if(E){const W=E.measured.width??E.width??0,Y=E.measured.height??E.height??0;if(W>0&&Y>0){const Q=tH({x:E.internals.positionAbsolute.x,y:E.internals.positionAbsolute.y,w:W,h:Y},{x:r,y:a}),oe=Ij({x:E.internals.positionAbsolute.x,y:E.internals.positionAbsolute.y,w:W,h:Y},Q);I=oe.x,$=oe.y,N=NG[oe.side]}}}const X=(h==null?void 0:h.path)==="step",[j]=X?xh({sourceX:b,sourceY:C,sourcePosition:_,targetX:I,targetY:$,targetPosition:N,borderRadius:Det}):Mz({sourceX:b,sourceY:C,sourcePosition:_,targetX:I,targetY:$,targetPosition:N}),O=(l==null?void 0:l.style)??c??void 0,H=Te(U=>U.rfId),B=x?l==null?void 0:l.markerStart:l==null?void 0:l.markerEnd,z=x?l==null?void 0:l.markerEnd:l==null?void 0:l.markerStart,R=IG(B,H),L=IG(z,H);return p.jsx("path",{d:j,fill:"none",className:"react-flow__connection-path",style:O,markerStart:R,markerEnd:L})},NG={top:pe.Top,right:pe.Right,bottom:pe.Bottom,left:pe.Left};function qet({storeApiRef:e}){const t=wt();return m.useEffect(()=>(e.current=t,()=>{e.current===t&&(e.current=null)}),[t,e]),null}function Oet({wrapperRef:e}){const t=Te(o=>o.transform[2]),n=e.current;return n&&n.style.setProperty("--rf-zoom",String(t)),null}const Fet=new Set(["INPUT","TEXTAREA","SELECT"]),Roe=e=>e?Fet.has(e.tagName)?!0:e instanceof HTMLElement&&e.isContentEditable:!1;function Vet(e){const{event:t,selectedNodeIds:n,hasClipboard:o,activeElement:r,onCopySelection:a,onPasteSelection:i}=e;if(!(t.metaKey||t.ctrlKey)||t.shiftKey||t.altKey)return!1;const s=t.key.toLowerCase();return s!=="c"&&s!=="v"||Roe(r)?!1:s==="c"?n.length===0||!a?!1:(t.preventDefault(),a([...n]),!0):!o||!i?!1:(t.preventDefault(),i(),!0)}const AG=(e,t)=>{var n;return((n=e==null?void 0:e[t])==null?void 0:n.status)??"idle"},Bet=(e,t)=>{var n;return(n=e==null?void 0:e[t])==null?void 0:n.status},Uet=(e,t)=>{var n,o;return((n=e==null?void 0:e[t])==null?void 0:n.status)==="error"?(o=e[t])==null?void 0:o.error:void 0};function Wet(e,t){var AF,EF;const{mode:n,adapter:o,projectId:r,fileBaseUrl:a,apiBaseUrl:i="/api",nodes:s,connectors:c,selectedNodeIds:l,selectedConnectorIds:h,onSelectionChange:u,runtime:f,onPlayNode:y,onNodePositionChange:k,onNodePositionsChange:x,onNodeResize:w,onNodeResizeEnd:g,onHtmlNodeFitToContent:M,onComponentNodeFitToContent:v,onMultiResize:b,onNodeNameChange:C,onNodeDescriptionChange:_,onConnectorLabelChange:S,onCreateShapeNode:A,onCreateImageFromFile:P,onRetryImageUpload:I,onCreateHtmlNode:$,onCreateConnector:N,onReconnectConnector:X,onReorderNode:j,onDeleteNode:O,onCopyNode:H,onPasteAt:B,hasClipboard:z,onCopySelection:R,onPasteSelection:L,selectedNodes:U,selectedConnectors:D,onStyleNode:E,onStyleNodePreview:W,onStyleNodes:Y,onStyleNodesPreview:Q,onStyleConnector:oe,onStyleConnectorPreview:te,onRfInit:se,onTidy:we,onNodeClick:ke,onConnectorClick:ge,onPaneClick:ve,onCreateAndConnectFromPane:re,pendingEditNodeId:me,iconPickerOpen:Ve,onOpenIconPicker:lt,onCloseIconPicker:Vt,onPickIcon:Et,onRequestIconReplace:ce,onPinEndpoint:J,onUnpinEndpoint:ln,canvasMode:rn,onCanvasModeChange:Ee,disableSidebar:Ge,statusReport:G,onNameChange:ne,onDescriptionChange:Ie,onDetailChange:De,onIconChange:Ke,autoFitView:Bt,autoFitViewSignal:bn,customIcons:Qe,onExportToCloud:ft,onRestartDemo:_n,showToolbar:Rt,showStyleStrip:Cn,showDetailPanel:an,showStatusBadges:dt,showResizeHandles:Mt,showControls:rr,showShareMenu:Ea,showMiniMap:ar,showRestart:Pi,enableKeyboard:$a,enableContextMenu:Ao,enableDragDrop:ir,enableImageDrop:Eo,enableZoom:Ad,enablePan:Ed,enableSelection:$o,enableNodeMove:Kr,enableEmbed:Xr}=e,He=m.useMemo(()=>Net({mode:n,showToolbar:Rt,showStyleStrip:Cn,showDetailPanel:an,showStatusBadges:dt,showResizeHandles:Mt,showControls:rr,showShareMenu:Ea,showMiniMap:ar,showRestart:Pi,enableKeyboard:$a,enableContextMenu:Ao,enableDragDrop:ir,enableImageDrop:Eo,enableZoom:Ad,enablePan:Ed,enableSelection:$o,enableNodeMove:Kr,enableEmbed:Xr}),[n,Rt,Cn,an,dt,Mt,rr,Ea,ar,Pi,$a,Ao,ir,Eo,Ad,Ed,$o,Kr,Xr]),gt=n==="edit",Pa=m.useRef(He);m.useEffect(()=>{Pa.current=He},[He]);const ji=Bt??(n==="mini"?!0:void 0),Yr=m.useMemo(()=>Aet(ji),[ji]),sr=f==null?void 0:f.runs,ja=f==null?void 0:f.statuses,Rn=(AF=f==null?void 0:f.pendingOverrides)==null?void 0:AF.nodes,Po=(EF=f==null?void 0:f.pendingOverrides)==null?void 0:EF.connectors,Kt=m.useRef(null),Xt=m.useRef(null),Qr=m.useRef(!1),cr=m.useRef(!1),$d=m.useRef(!1),Pd=m.useRef(Yr);Pd.current=Yr,m.useEffect(()=>{if(Qr.current||!Yr.onMount||s.length===0)return;const K=Xt.current;K&&(K.fitView(G0),Qr.current=!0)},[s,Yr.onMount]);const jo=m.useRef(null),bt=rn.kind==="draw"?rn.shape:null,Kn=rn.kind==="hand",lr=m.useRef(new Map),jd=m.useCallback((K,ee)=>(lr.current.set(K,ee),()=>{lr.current.get(K)===ee&&lr.current.delete(K)}),[]),[Jr,ea]=m.useState(!1),zd=m.useRef(!1);m.useEffect(()=>{zd.current=Jr},[Jr]);const zi=m.useRef(!1),za=m.useRef(!1),zo=m.useRef(!1),[Sn,dr]=m.useState(null),Xn=m.useRef(null);m.useEffect(()=>{Xn.current=Sn},[Sn]),m.useCallback(()=>{dr(null)},[]);const Ro=m.useMemo(()=>Het(zo),[]),Yn=m.useRef(null),Rd=m.useRef(null),ur=m.useCallback(K=>{const ee=Kt.current;if(!ee){Yn.current=K;return}const le=Yn.current;if(le&&le!==K){const de=ee.querySelector(`.react-flow__node[data-id="${CSS.escape(le)}"]`);de==null||de.removeAttribute("data-connect-source")}if(K){const de=ee.querySelector(`.react-flow__node[data-id="${CSS.escape(K)}"]`);de==null||de.setAttribute("data-connect-source","true")}Yn.current=K},[]),Qn=m.useCallback(K=>{const ee=Kt.current,le=Rd.current;if(le!==K){if(ee&&le){const de=ee.querySelector(`.react-flow__node[data-id="${CSS.escape(le)}"]`);de==null||de.removeAttribute("data-connect-target")}if(ee&&K){const de=ee.querySelector(`.react-flow__node[data-id="${CSS.escape(K)}"]`);de==null||de.setAttribute("data-connect-target","true")}Rd.current=K}},[]),Ra=m.useCallback(()=>{ur(null),Qn(null)},[ur,Qn]);m.useEffect(()=>{if(!Jr){Qn(null);return}let K=null,ee=null;const le=()=>{K=null;const ue=ee;if(ee=null,!ue)return;const je=OT(Kt.current,ue.clientX,ue.clientY),xe=(je==null?void 0:je.getAttribute("data-id"))??null;if(xe&&xe===Yn.current){Qn(null);return}Qn(xe)},de=ue=>{ee={clientX:ue.clientX,clientY:ue.clientY},K===null&&(K=requestAnimationFrame(le))};return document.addEventListener("pointermove",de,{passive:!0}),()=>{document.removeEventListener("pointermove",de),K!==null&&cancelAnimationFrame(K)}},[Jr,Qn]);const[To,ut]=m.useState(null),[go,vo]=m.useState(null),pn=m.useRef(null),hr=m.useRef(null),fr=m.useRef(null),Ta=m.useRef(!1);m.useEffect(()=>{pn.current=bt},[bt]);const Ri=m.useCallback(()=>{Ee({kind:"select"}),ut(null),vo(null),pn.current=null,hr.current=null,fr.current=null,Ta.current=!1},[Ee]);m.useEffect(()=>{if(!He.enableKeyboard)return;const K=ee=>{var ue,je;if(ee.key!=="Escape"||Roe(document.activeElement))return;if(pn.current){ee.preventDefault(),Ri();return}if(zd.current){ee.preventDefault(),zi.current=!0,za.current=!0;try{(ue=jo.current)==null||ue.getState().cancelConnection()}catch{}document.dispatchEvent(new MouseEvent("mouseup",{bubbles:!0,cancelable:!0,button:0})),ea(!1);return}if(Xn.current){ee.preventDefault(),dr(null);return}const le=Do.current.size>0,de=oa.current.size>0;(le||de)&&(ee.preventDefault(),(je=yr.current)==null||je.call(yr,[],[]))};return window.addEventListener("keydown",K),()=>window.removeEventListener("keydown",K)},[Ri,He.enableKeyboard]),m.useEffect(()=>{if(!He.enableKeyboard)return;const K=ee=>{Vet({event:ee,selectedNodeIds:l,hasClipboard:!!z,activeElement:document.activeElement,onCopySelection:R,onPasteSelection:L})};return window.addEventListener("keydown",K),()=>window.removeEventListener("keydown",K)},[l,z,R,L,He.enableKeyboard]);const lR=m.useCallback(K=>{var de,ue;if(!pn.current)return;const ee=K.target;if(!(ee!=null&&ee.classList.contains("react-flow__pane")))return;const le={x:K.clientX,y:K.clientY};Ta.current=!0,hr.current=le,fr.current=le,ut(le),vo(le);try{(ue=(de=K.currentTarget).setPointerCapture)==null||ue.call(de,K.pointerId)}catch{}K.preventDefault(),K.stopPropagation()},[]),dR=m.useCallback(K=>{if(!Ta.current)return;const ee={x:K.clientX,y:K.clientY};fr.current=ee,vo(ee)},[]),yf=m.useCallback(K=>{var kr,A0;if(!Ta.current)return;Ta.current=!1;try{(A0=(kr=K.currentTarget).releasePointerCapture)==null||A0.call(kr,K.pointerId)}catch{}const ee=hr.current,le=fr.current,de=pn.current,ue=Xt.current;if(Ri(),!ee||!le||!de||!ue)return;const je=Math.min(ee.x,le.x),xe=Math.min(ee.y,le.y),Pe=Math.max(ee.x,le.x),tt=Math.max(ee.y,le.y),st=Pe-je,pt=tt-xe,Re=ue.screenToFlowPosition({x:je,y:xe}),Dn=ue.screenToFlowPosition({x:Pe,y:tt}),mr=Dn.x-Re.x,yt=Dn.y-Re.y,Ce=st<CG||pt<CG,en=Ce?qj[de].width:mr,Dd=Ce?qj[de].height:yt;A==null||A(de,Re,{width:en,height:Dd})},[Ri,A]),ta=m.useRef(!1),na=m.useRef(!1),S0=m.useRef(new Map),q=m.useCallback(()=>{var K;cr.current&&(na.current||ta.current||(cr.current=!1,(K=Xt.current)==null||K.fitView(G0)))},[]),F=m.useCallback(K=>{na.current=K,K||q()},[q]);m.useEffect(()=>{var K;if(!$d.current){$d.current=!0;return}if(Pd.current.onExternalNodeChange){if(na.current||ta.current){cr.current=!0;return}(K=Xt.current)==null||K.fitView(G0)}},[bn]);const Z=!!j||!!O||!!H||!!B||!!ln,[V,T]=m.useState(null),[ie,Ae]=m.useState(!1),[be,Je]=m.useState(null),[Yt,pr]=m.useState(null),Ot=m.useRef(null),$e=m.useRef(null);m.useEffect(()=>{if(!V)return;const K=$e.current;if(!K)return;const ee=new MouseEvent("contextmenu",{clientX:V.x,clientY:V.y,bubbles:!0,cancelable:!0,button:2,buttons:2});K.dispatchEvent(ee)},[V]);const it=m.useCallback(K=>{const ee=Ot.current;!ee||!j||j(ee,K)},[j]),yn=m.useCallback(()=>{const K=Ot.current;!K||!O||O(K)},[O]),Tn=m.useCallback(()=>{const K=Ot.current;!K||!H||H(K)},[H]),Td=m.useCallback(()=>{const K=Ot.current;!K||!ce||ce(K)},[ce]);m.useCallback((K,ee,le,de,ue)=>{Pa.current.enableContextMenu&&(Ot.current=null,Ae(!1),Je(null),pr({connectorId:K,kind:ee,pinned:le}),T({x:de,y:ue}))},[]);const uR=m.useCallback(()=>{const K=Yt;!K||!ln||ln(K.connectorId,K.kind)},[Yt,ln]),Da=m.useCallback(()=>{if(!B)return;const K=V,ee=Xt.current;if(!K||!ee)return;const le=ee.screenToFlowPosition({x:K.x,y:K.y});B(le)},[V,B]),Oe=typeof navigator<"u"&&/Mac|iPhone|iPad|iPod/.test(navigator.platform||navigator.userAgent||""),_t=Oe?"⌘C":"Ctrl+C",Qt=Oe?"⌘V":"Ctrl+V",Jt=m.useMemo(()=>new Set(l),[l]),Jn=m.useMemo(()=>new Set(h),[h]),L0=m.useMemo(()=>{if(l.length<2)return[];const K=Rn,ee=[];for(const le of l){const de=s.find(Pe=>Pe.id===le);if(!de)continue;const ue=K==null?void 0:K[le],je=(ue==null?void 0:ue.data)??{},xe=de.data;ee.push({id:le,position:(ue==null?void 0:ue.position)??de.position,data:{width:je.width??xe.width,height:je.height??xe.height}})}return ee},[s,Rn,l]),hR=U??[],Ti=m.useMemo(()=>{const K=ue=>{const je=gt?void 0:S0.current.get(ue.id),xe={id:ue.id,type:ue.type,position:je??ue.position,data:{...ue.data,projectId:r,fileBaseUrl:a,flowId:ue.type==="component"?r:void 0,apiBaseUrl:ue.type==="component"?i:void 0,onRetryUpload:I,status:Bet(sr,ue.id),errorMessage:Uet(sr,ue.id),statusReport:ja==null?void 0:ja[ue.id],onPlay:y,onResize:w,onResizeEnd:g,setResizing:F,onFitToContent:ue.type==="html"?M:ue.type==="component"?v:void 0,onNameChange:(()=>{if(gt&&ue.type!=="ellipse")return C})(),onDescriptionChange:(()=>{if(gt&&(ue.type==="rectangle"||ue.type==="ellipse"||ue.type==="sticky"))return _})(),onIconChange:(()=>{if(gt&&!(ue.type!=="rectangle"&&ue.type!=="component"))return Ke})(),autoEditOnMount:me===ue.id?!0:void 0},selected:Jt.has(ue.id)};return(!(ue.data.autoSize===!0)||na.current)&&(ue.data.width!==void 0&&(xe.width=ue.data.width),ue.data.height!==void 0&&(xe.height=ue.data.height)),Jt.has(ue.id)||(xe.connectable=!1),xe},ee=s.map(ue=>K(Pet(ue,Rn==null?void 0:Rn[ue.id]))),le=new Set(s.map(ue=>ue.id)),de=[];if(Rn)for(const[ue,je]of Object.entries(Rn)){if(le.has(ue))continue;const xe=je;typeof xe.type!="string"||!xe.position||!xe.data||de.push(K({...xe,id:ue}))}return[...ee,...de]},[r,a,i,s,Jt,sr,ja,y,w,g,M,v,F,Rn,C,_,Ke,I,me,gt]),[fR,pR]=m.useState(Ti);m.useEffect(()=>{ta.current||na.current||pR(Ti)},[Ti]),m.useEffect(()=>{I0.current=fR},[fR]);const Do=m.useRef(Jt);m.useEffect(()=>{Do.current=Jt},[Jt]);const yr=m.useRef(u);m.useEffect(()=>{yr.current=u},[u]);const oa=m.useRef(Jn);m.useEffect(()=>{oa.current=Jn},[Jn]);const I0=m.useRef(Ti),Di=m.useRef(!1),mf=m.useRef(new Set),kf=m.useRef(new Set),yR=m.useRef(new Set),mR=m.useRef(new Set),Ha=m.useRef(null),ore=m.useCallback(K=>{var yt;const ee=Di.current?yR.current:(yt=Ha.current)!=null&&yt.shift?Ha.current.nodeIds:null,le=ee&&ee.size>0?K.filter(Ce=>Ce.type!=="select"?!0:!(Ce.selected===!1&&ee.has(Ce.id))):K,de=new Set;for(const Ce of le)Ce.type==="select"&&de.add(Ce.id);const ue=PY(le,I0.current),je=new Set;if(na.current)for(const Ce of le)Ce.type==="dimensions"&&je.add(Ce.id);const xe=je.size===0?ue:ue.map(Ce=>!je.has(Ce.id)||Ce.width===void 0&&Ce.height===void 0?Ce:{...Ce,data:{...Ce.data,...Ce.width!==void 0?{width:Ce.width}:{},...Ce.height!==void 0?{height:Ce.height}:{}}}),Pe=Do.current,tt=Di.current||Pe.size===0?xe:xe.map(Ce=>Pe.has(Ce.id)&&!de.has(Ce.id)&&!Ce.selected?{...Ce,selected:!0}:Ce);if(I0.current=tt,pR(tt),de.size===0)return;if(Di.current){for(const Ce of le)Ce.type==="select"&&(Ce.selected?mf.current.add(Ce.id):mf.current.delete(Ce.id));return}const st=yr.current;if(!st)return;const pt=tt.filter(Ce=>Ce.selected).map(Ce=>Ce.id),Re=Do.current;Re.size===pt.length&&pt.every(Ce=>Re.has(Ce))||(Do.current=new Set(pt),st(pt,[...oa.current]))},[]),gf=m.useRef([]),rre=m.useCallback(K=>{var pt;const ee=Di.current?mR.current:(pt=Ha.current)!=null&&pt.shift?Ha.current.edgeIds:null,le=ee&&ee.size>0?K.filter(Re=>Re.type!=="select"?!0:!(Re.selected===!1&&ee.has(Re.id))):K,de=new Set;for(const Re of le)Re.type==="select"&&de.add(Re.id);if(de.size===0)return;if(Di.current){for(const Re of le)Re.type==="select"&&(Re.selected?kf.current.add(Re.id):kf.current.delete(Re.id));return}const ue=yr.current;if(!ue)return;const xe=jY(le,gf.current).filter(Re=>Re.selected).map(Re=>Re.id),Pe=oa.current;Pe.size===xe.length&&xe.every(Re=>Pe.has(Re))||(oa.current=new Set(xe),ue([...Do.current],xe))},[]),are=m.useCallback(K=>{Di.current=!0;const ee=Ha.current,le=(ee==null?void 0:ee.shift)??(K.shiftKey||K.metaKey||K.ctrlKey);yR.current=le?new Set((ee==null?void 0:ee.nodeIds)??Do.current):new Set,mR.current=le?new Set((ee==null?void 0:ee.edgeIds)??oa.current):new Set,mf.current=new Set(yR.current),kf.current=new Set(mR.current)},[]),ire=m.useCallback(()=>{Di.current=!1,Ha.current=null;const K=yr.current;if(!K)return;const ee=[...mf.current],le=new Set(ee),de=new Set(kf.current);for(const tt of gf.current)le.has(tt.source)&&le.has(tt.target)&&de.add(tt.id);const ue=Do.current,je=oa.current,xe=ue.size===le.size&&ee.every(tt=>ue.has(tt)),Pe=je.size===de.size&&[...de].every(tt=>je.has(tt));xe&&Pe||(Do.current=new Set(ee),oa.current=new Set(de),K(ee,[...de]))},[]),sre=m.useCallback(K=>{if(Ha.current=null,pn.current||K.button!==0)return;const ee=K.target;ee!=null&&ee.classList.contains("react-flow__pane")&&(Ha.current={shift:K.shiftKey||K.metaKey||K.ctrlKey,nodeIds:new Set(Do.current),edgeIds:new Set(oa.current)})},[]),cre=m.useCallback(K=>{if(!Pa.current.enableContextMenu||Do.current.size<2)return;const le=K.target;le!==$e.current&&(le!=null&&le.closest(".seeflow-connector-endpoint-dot")||(K.preventDefault(),K.stopPropagation(),Ot.current=null,Ae(!0),Je(null),pr(null),T({x:K.clientX,y:K.clientY})))},[]),lre=m.useCallback(K=>{const ee=K.dataTransfer;if(!ee)return;const le=ee.types?Array.from(ee.types):[],de=le.includes("Files"),ue=le.includes(lW),je=de&&!!P&&He.enableImageDrop,xe=ue&&!!$&&He.enableDragDrop;if(!(!je&&!xe)){K.preventDefault();try{ee.dropEffect="copy"}catch{}}},[P,$,He.enableImageDrop,He.enableDragDrop]),dre=m.useCallback(K=>{const ee=K.dataTransfer;if((ee!=null&&ee.types?Array.from(ee.types):[]).includes(lW)&&$&&He.enableDragDrop){K.preventDefault();const je=Xt.current;if(!je)return;const xe=je.screenToFlowPosition({x:K.clientX,y:K.clientY});$({position:xe});return}if(!P||!He.enableImageDrop)return;const ue={x:K.clientX,y:K.clientY};K.preventDefault(),LIe({dataTransfer:ee,clientPos:ue,rfInstance:Xt.current,computeDims:IIe,dispatch:P})},[P,$,He.enableImageDrop,He.enableDragDrop]),wF=!!X,MF=Jn.size===1?[...Jn][0]:null,kR=m.useMemo(()=>{const K=Pe=>{const tt=AG(sr,Pe.source)==="running"||AG(sr,Pe.target)==="running",st=Jn.has(Pe.id),pt=PRe(Pe,tt,st);st&&(pt.selected=!0);const Re=wF&&Pe.id===MF,Dn=Re?{...pt,reconnectable:!0}:pt;return{...Dn,data:{...Dn.data,onLabelChange:gt?S:void 0,reconnectable:Re,registerEditHandle:jd}}},ee=new Set(c.map(Pe=>Pe.id)),le=c.map(Pe=>K(jet(Pe,Po==null?void 0:Po[Pe.id]))),de=[];if(Po)for(const[Pe,tt]of Object.entries(Po)){if(ee.has(Pe))continue;const st=tt;typeof st.source!="string"||typeof st.target!="string"||de.push(K({...st,id:Pe}))}const ue=[...le,...de],je=[],xe=[];for(const Pe of ue)Jn.has(Pe.id)?xe.push(Pe):je.push(Pe);return[...je,...xe]},[c,sr,Jn,MF,Po,S,wF,jd,gt]);m.useEffect(()=>{gf.current=kR},[kR]);const N0=e.adapter??null,ure=m.useMemo(()=>{if(N0!=null&&N0.computeLayout)return async()=>{const K=Xt.current,ee=I0.current;if(ee.length<2)return;const le=ee.map(yt=>{var A0;const Ce=(A0=K==null?void 0:K.getInternalNode(yt.id))==null?void 0:A0.measured,en=yt.data,Dd=(Ce==null?void 0:Ce.width)??en.width??200,kr=(Ce==null?void 0:Ce.height)??en.height??120;return{id:yt.id,type:yt.type,width:Dd,height:kr}}),de=new Map;for(const yt of ee)de.set(yt.id,yt.position);const ue=gf.current.map(yt=>({id:yt.id,source:yt.source,target:yt.target})),je=N0.computeLayout;if(!je)return;const xe=await je(le,ue),Pe=new Map;for(const[yt,Ce]of Object.entries(xe.nodes))Pe.set(yt,Ce.position);let tt=Number.POSITIVE_INFINITY,st=Number.POSITIVE_INFINITY,pt=Number.POSITIVE_INFINITY,Re=Number.POSITIVE_INFINITY;for(const yt of le){const Ce=de.get(yt.id);if(!Ce)continue;Ce.x<tt&&(tt=Ce.x),Ce.y<st&&(st=Ce.y);const en=Pe.get(yt.id);en&&(en.x<pt&&(pt=en.x),en.y<Re&&(Re=en.y))}const Dn=Number.isFinite(tt)&&Number.isFinite(pt)?tt-pt:0,mr=Number.isFinite(st)&&Number.isFinite(Re)?st-Re:0;pR(yt=>yt.map(Ce=>{const en=Pe.get(Ce.id);return en?{...Ce,position:{x:en.x+Dn,y:en.y+mr}}:Ce}))}},[N0]),vf=we??(gt?void 0:ure),xf=m.useRef(!1),bF=m.useRef(null),hre=m.useCallback(K=>{var Pe;if(!gt||!N)return;const{source:ee,target:le}=K;if(!ee||!le||ee===le)return;xf.current=!0;const de=((Pe=bF.current)==null?void 0:Pe.nodeId)??null,ue=de!==null&&de===le&&de!==ee;N(ue?le:ee,ue?ee:le)},[N,gt]),gR=m.useCallback(K=>{const ee=le=>{if(!le)return!1;const de=I0.current.find(ue=>ue.id===le);return de?de.type==="text":!1};return!ee(K.source)&&!ee(K.target)},[]),fre=m.useCallback((K,ee)=>{var pt;ea(!1),Ra();const le=xf.current;if(xf.current=!1,le||zo.current)return;if(zi.current){zi.current=!1;return}if(!N)return;const de=(pt=ee.fromNode)==null?void 0:pt.id,ue=ee.fromHandle;if(!de||!ue)return;const je=SG(K);if(!je)return;const xe=OT(Kt.current,je.clientX,je.clientY);if(!xe)return;const Pe=xe.getAttribute("data-id");if(!Pe||Pe===de||!gR({source:de,target:Pe,sourceHandle:null,targetHandle:null}))return;let tt;const st=Xt.current;if(st){const Re=st.getInternalNode(Pe);if(Re){const Dn=Re.measured.width??Re.width??0,mr=Re.measured.height??Re.height??0;if(Dn>0&&mr>0){const yt=st.screenToFlowPosition({x:je.clientX,y:je.clientY});tt=tH({x:Re.internals.positionAbsolute.x,y:Re.internals.positionAbsolute.y,w:Dn,h:mr},yt)}}}N(de,Pe,tt?{targetPin:tt}:void 0)},[N,Ra,gR]),wf=m.useRef(!1),pre=m.useCallback((K,ee)=>{if(!X)return;const{source:le,target:de,sourceHandle:ue,targetHandle:je}=ee;if(!le||!de||le===de)return;const xe={};if(le!==K.source&&(xe.source=le),de!==K.target&&(xe.target=de),typeof ue=="string"&&ue!==K.sourceHandle&&(xe.sourceHandle=ue),typeof je=="string"&&je!==K.targetHandle&&(xe.targetHandle=je),xe.source===void 0&&xe.target===void 0&&xe.sourceHandle===void 0&&xe.targetHandle===void 0)return;(xe.source!==void 0||xe.sourceHandle!==void 0)&&(xe.sourceHandleAutoPicked=!1),(xe.target!==void 0||xe.targetHandle!==void 0)&&(xe.targetHandleAutoPicked=!1);const Pe=Xt.current;if(!(xe.source===void 0&&xe.target===void 0)&&Pe){const st=xe.source!==void 0?"source":"target",pt=LG(st,K.source,K.target,K.data,Re=>Pe.getInternalNode(Re)??null);pt&&(st==="source"?xe.targetPin=pt:xe.sourcePin=pt)}wf.current=!0,X(K.id,xe)},[X]),yre=m.useCallback((K,ee,le,de)=>{var Dd;ea(!1),Ra(),zo.current=!1;const ue=wf.current;if(wf.current=!1,ue)return;if(za.current){za.current=!1;return}if(!X)return;const je=SG(K);let xe=((Dd=de.toNode)==null?void 0:Dd.id)??null;if(!xe&&je){const kr=OT(Kt.current,je.clientX,je.clientY);xe=(kr==null?void 0:kr.getAttribute("data-id"))??null}const Pe=le==="source"?"target":"source",tt=$et(Pe,ee.source,ee.target,xe);if(tt==="no-op"||tt==="self-loop"||!je)return;const st=Xt.current;if(!st)return;const pt=tt==="pin-own"?Pe==="source"?ee.source:ee.target:xe,Re=st.getInternalNode(pt);if(!Re)return;const Dn=Re.measured.width??Re.width??0,mr=Re.measured.height??Re.height??0;if(Dn===0||mr===0)return;const yt=st.screenToFlowPosition({x:je.clientX,y:je.clientY}),Ce=tH({x:Re.internals.positionAbsolute.x,y:Re.internals.positionAbsolute.y,w:Dn,h:mr},yt);if(tt==="pin-own"){if(!J)return;J(ee.id,Pe,Ce);return}const en=LG(Pe,ee.source,ee.target,ee.data,kr=>st.getInternalNode(kr)??null);Pe==="source"?X(ee.id,{source:xe,sourceHandle:null,sourceHandleAutoPicked:!1,sourcePin:Ce,...en?{targetPin:en}:{}}):X(ee.id,{target:xe,targetHandle:null,targetHandleAutoPicked:!1,targetPin:Ce,...en?{sourcePin:en}:{}})},[X,Ra,J]),Hi=m.useMemo(()=>{var Pe;if(!To||!go)return null;const K=(Pe=Kt.current)==null?void 0:Pe.getBoundingClientRect(),ee=(K==null?void 0:K.left)??0,le=(K==null?void 0:K.top)??0,de=Math.min(To.x,go.x),ue=Math.min(To.y,go.y),je=Math.abs(go.x-To.x),xe=Math.abs(go.y-To.y);return{left:de-ee,top:ue-le,width:je,height:xe}},[To,go]),qa=bt?n2(Xa).node:void 0,mre=bt?OJ(bt):"",kre=bt?FJ(bt,qa):void 0,gre=bt==="text",[_F,CF]=m.useState(!1),[vre,Mf]=m.useState(!1),[xre,SF]=m.useState(!1),Oa=xet({projectId:r,getReactFlow:()=>Xt.current});m.useImperativeHandle(t,()=>({exportPdf:Oa.exportPdf,exportPng:Oa.exportPng,openEmbedDialog:()=>SF(!0),capturePreview:Oa.capturePreview}),[Oa.exportPdf,Oa.exportPng,Oa.capturePreview]),m.useEffect(()=>{if(!He.enableKeyboard)return;const K=de=>{if(!de)return!1;const ue=de.tagName;return ue==="INPUT"||ue==="TEXTAREA"||ue==="SELECT"?!0:de instanceof HTMLElement&&de.isContentEditable},ee=de=>{de.code==="Space"&&(K(document.activeElement)||(de.preventDefault(),CF(!0)))},le=de=>{de.code==="Space"&&(CF(!1),Mf(!1))};return window.addEventListener("keydown",ee),window.addEventListener("keyup",le),()=>{window.removeEventListener("keydown",ee),window.removeEventListener("keyup",le)}},[He.enableKeyboard]);const bf=m.useCallback(K=>{if(K.length!==0){if(!gt){const ee=S0.current;for(const le of K)ee.set(le.id,{x:le.position.x,y:le.position.y});return}if(K.length===1){const ee=K[0];ee&&k&&k(ee.id,{x:ee.position.x,y:ee.position.y});return}if(x){x(K.map(ee=>({id:ee.id,position:{x:ee.position.x,y:ee.position.y}})));return}if(k)for(const ee of K)k(ee.id,{x:ee.position.x,y:ee.position.y})}},[k,x,gt]),wre=m.useCallback((K,ee,le)=>{ta.current=!1,bf(le),q()},[bf,q]),Mre=m.useCallback(()=>{ta.current=!0},[]),bre=m.useCallback((K,ee)=>{ta.current=!1,bf(ee),q()},[bf,q]),_re=m.useCallback((K,ee)=>{ke==null||ke(ee.id)},[ke]),Cre=m.useCallback(K=>{ve==null||ve()},[ve]),Sre=m.useCallback((K,ee)=>{ge==null||ge(ee.id)},[ge]),LF=bt?"crosshair":Kn||_F?vre?"grabbing":"grab":void 0,IF=l[0],NF=h[0],Lre=IF?s.find(K=>K.id===IF)??null:null,Ire=NF?c.find(K=>K.id===NF)??null:null,Nre=r??null,Are=He.showDetailPanel&&!Ge,Ere=m.useMemo(()=>({custom:Qe??{}}),[Qe]);return p.jsx(RDe,{value:Ere,children:p.jsx("div",{"data-testid":"seeflow-canvas","data-mode":n,"data-canvas-mode":rn.kind,ref:Kt,className:"seeflow-canvas-root sf:relative sf:h-full sf:w-full",style:LF?{cursor:LF}:void 0,onPointerDownCapture:sre,onPointerDown:K=>{_F&&Mf(!0),lR(K)},onPointerMove:dR,onPointerUp:K=>{Mf(!1),yf(K)},onPointerCancel:()=>{Ta.current=!1,hr.current=null,fr.current=null,ut(null),vo(null),Mf(!1)},onContextMenuCapture:cre,onDragOver:lre,onDrop:dre,children:p.jsxs(ZOe,{containerRef:Kt,children:[p.jsxs(Xze,{nodes:fR,edges:kR,onNodesChange:ore,nodeTypes:zet,edgeTypes:Ret,proOptions:{hideAttribution:!0},fitView:!0,minZoom:n==="mini"?.05:.5,nodesDraggable:(gt?!!k:!0)&&!bt&&!Kn&&He.enableNodeMove,nodesConnectable:gt&&!!N&&!bt&&!Kn,deleteKeyCode:gt?["Backspace","Delete"]:null,zoomOnScroll:He.enableZoom,zoomOnPinch:He.enableZoom,className:Jr?"seeflow-connecting":void 0,onConnect:gt?hre:void 0,isValidConnection:gR,onConnectStart:(K,ee)=>{ea(!0),xf.current=!1,bF.current={nodeId:ee.nodeId??null,handleType:ee.handleType??null},ur(ee.nodeId??null)},onConnectEnd:fre,onReconnect:gt&&X?pre:void 0,onReconnectStart:(K,ee,le)=>{ea(!0),wf.current=!1,zo.current=!0;const de=le==="source"?ee.source:ee.target;ur(de)},onReconnectEnd:yre,connectionLineComponent:Ro,connectionLineStyle:{strokeWidth:2},connectionRadius:32,reconnectRadius:10,edgesReconnectable:!1,elevateNodesOnSelect:!1,elementsSelectable:!bt&&!Kn&&He.enableSelection,selectNodesOnDrag:!1,nodeClickDistance:5,selectionOnDrag:!bt&&!Kn&&He.enableSelection,panOnDrag:bt?!1:Kn?[0,1,2]:He.enablePan?[1,2]:!1,selectionMode:Vu.Partial,selectionKeyCode:null,multiSelectionKeyCode:bt?null:["Meta","Shift"],panActivationKeyCode:bt?null:"Space",onSelectionStart:are,onSelectionEnd:ire,defaultEdgeOptions:Tet,zoomOnDoubleClick:!1,onInit:K=>{Xt.current=K;const ee=Kt.current;ee&&ee.style.setProperty("--rf-zoom",String(K.getZoom())),ee&&ee.setAttribute("data-canvas-ready","true"),!Qr.current&&Yr.onMount&&s.length>0&&(K.fitView(G0),Qr.current=!0),se==null||se(K)},onMove:(K,ee)=>{Xn.current&&dr(null);const le=Kt.current;le&&le.style.setProperty("--rf-zoom",String(ee.zoom))},onEdgesChange:rre,onNodeDragStart:()=>{ta.current=!0},onNodeDragStop:wre,onSelectionDragStart:Mre,onSelectionDragStop:bre,onNodeClick:_re,onEdgeClick:Sre,onEdgeDoubleClick:(K,ee)=>{var le;(le=lr.current.get(ee.id))==null||le()},onPaneClick:Cre,onNodeContextMenu:He.enableContextMenu&&Z?(K,ee)=>{K.preventDefault(),Ot.current=ee.id,Ae(!0),Je(ee.type??null),pr(null),T({x:K.clientX,y:K.clientY})}:void 0,onPaneContextMenu:He.enableContextMenu&&B?K=>{K.preventDefault(),Ot.current=null,Ae(!1),Je(null),pr(null),T({x:K.clientX,y:K.clientY})}:void 0,children:[p.jsx(qet,{storeApiRef:jo}),p.jsx(Oet,{wrapperRef:Kt}),p.jsx(aRe,{gap:12,size:.6}),n!=="mini"&&p.jsx(_et,{}),He.showControls?p.jsxs(hRe,{showInteractive:!1,showFitView:!1,children:[p.jsx(fu,{"data-testid":"controls-fit-view","aria-label":"Fit view",title:"Fit view",disabled:s.length===0,onClick:()=>{var K;(K=Xt.current)==null||K.fitView(G0)},children:p.jsx(rd,{className:"sf:h-3 sf:w-3","aria-hidden":"true"})}),p.jsx(fu,{"data-testid":"controls-tidy","aria-label":"Tidy layout (⌘⇧L)",title:"Tidy layout (⌘⇧L)",disabled:!vf,onClick:()=>vf==null?void 0:vf(),children:p.jsx(S2,{className:"sf:h-3 sf:w-3","aria-hidden":"true"})})]}):null,He.showMiniMap?p.jsx(CRe,{className:"sf-canvas-minimap"}):null,He.showResizeHandles?p.jsx(kJe,{selectedNodes:L0,onMultiResize:b}):null,He.showToolbar||He.showStyleStrip&&E&&oe?p.jsx(Zu,{position:"top-left",children:p.jsxs("div",{className:"sf:flex sf:flex-col sf:gap-2",children:[He.showToolbar?p.jsx(WUe,{mode:rn,onModeChange:Ee,iconPickerOpen:Ve??!1,onOpenIconPicker:lt,onCloseIconPicker:Vt,onPickIcon:Et,showShapeTools:gt&&!!A}):null,He.showStyleStrip&&E&&oe?p.jsx(gJe,{nodes:hR,connectors:D??[],onStyleNode:E,onStyleNodePreview:W,onStyleNodes:Y,onStyleNodesPreview:Q,onStyleConnector:oe,onStyleConnectorPreview:te,onRequestIconReplace:ce}):null]})}):null,He.showShareMenu||He.showRestart&&_n?p.jsx(Zu,{position:"top-right",children:p.jsxs("div",{className:"sf:flex sf:items-center sf:gap-1",children:[He.showRestart&&_n?p.jsx(fJe,{onRestartDemo:_n}):null,He.showShareMenu?p.jsx(hJe,{mode:n==="mini"?"view":n,projectId:r,enableEmbed:He.enableEmbed,onDownloadPdf:Oa.exportPdf,onDownloadPng:Oa.exportPng,onExportToCloud:ft,embedOpen:xre,onEmbedOpenChange:SF}):null]})}):null]}),Hi?p.jsx("div",{"data-testid":"canvas-draw-ghost","data-ghost-shape":bt??void 0,"aria-hidden":!0,className:ae("sf:pointer-events-none sf:absolute sf:z-10",mre,gre?"sf:rounded-sm sf:border sf:border-dashed sf:border-muted-foreground/40":""),style:{...kre,left:Hi.left,top:Hi.top,width:Hi.width,height:Hi.height},children:(()=>{const K=bt?PO[bt]:void 0;if(!K)return null;const ee=VJ(qa);return p.jsx(K,{width:Hi.width,height:Hi.height,borderColor:ee.borderColor,backgroundColor:ee.backgroundColor,borderSize:(qa==null?void 0:qa.borderSize)??uO,borderStyle:qa==null?void 0:qa.borderStyle})})()}):null,He.enableContextMenu&&Z?p.jsxs(TBe,{onOpenChange:K=>{K||(T(null),Ot.current=null,Je(null),pr(null))},children:[p.jsx(DBe,{asChild:!0,children:p.jsx("div",{ref:$e,"data-testid":"node-context-menu-trigger","aria-hidden":!0,className:"sf:pointer-events-none sf:fixed",style:{left:(V==null?void 0:V.x)??0,top:(V==null?void 0:V.y)??0,width:0,height:0}})}),p.jsxs(bte,{"data-testid":"node-context-menu",children:[Yt!=null&&Yt.pinned&&ln?p.jsx(Lr,{"data-testid":"connector-endpoint-context-menu-unpin",onSelect:uR,children:"Unpin"}):null,ie&&H?p.jsxs(Lr,{"data-testid":"node-context-menu-copy",onSelect:Tn,children:["Copy",p.jsx(SH,{children:_t})]}):null,B?p.jsxs(Lr,{"data-testid":"node-context-menu-paste",disabled:!z,onSelect:Da,children:["Paste",p.jsx(SH,{children:Qt})]}):null,ie&&(H||B)&&(be==="icon"&&ce||j||O)?p.jsx(FP,{}):null,ie&&be==="icon"&&ce?p.jsx(Lr,{"data-testid":"node-context-menu-change-icon",onSelect:Td,children:"Change icon"}):null,ie&&be==="icon"&&ce&&(j||O)?p.jsx(FP,{}):null,ie&&j?p.jsxs(p.Fragment,{children:[p.jsx(Lr,{"data-testid":"node-context-menu-to-front",onSelect:()=>it({op:"toFront"}),children:"Bring to front"}),p.jsx(Lr,{"data-testid":"node-context-menu-forward",onSelect:()=>it({op:"forward"}),children:"Bring forward"}),p.jsx(Lr,{"data-testid":"node-context-menu-backward",onSelect:()=>it({op:"backward"}),children:"Send backward"}),p.jsx(Lr,{"data-testid":"node-context-menu-to-back",onSelect:()=>it({op:"toBack"}),children:"Send to back"})]}):null,ie&&j&&O?p.jsx(FP,{}):null,ie&&O?p.jsx(Lr,{"data-testid":"node-context-menu-delete",onSelect:yn,children:"Delete"}):null]})]}):null,re?p.jsxs(w0,{open:!!Sn,onOpenChange:K=>{K||dr(null)},children:[p.jsx(KOe,{asChild:!0,children:p.jsx("div",{"data-testid":"drop-popover-anchor","aria-hidden":!0,className:"sf:pointer-events-none sf:fixed",style:{left:(Sn==null?void 0:Sn.clientX)??0,top:(Sn==null?void 0:Sn.clientY)??0,width:0,height:0}})}),p.jsx(Sd,{"data-testid":"drop-popover",align:"start",side:"bottom",sideOffset:4,className:"sf:w-auto sf:p-1",onOpenAutoFocus:K=>{K.preventDefault()},children:p.jsx("div",{role:"menu","aria-label":"Create connected node",className:"sf:flex sf:flex-col sf:gap-0.5",children:UUe.map(({shape:K,label:ee,Icon:le})=>p.jsxs("button",{type:"button",role:"menuitem","data-testid":`drop-popover-shape-${K}`,onClick:()=>{const de=Sn;de&&(re({sourceNodeId:de.sourceNodeId,position:{x:de.flowX,y:de.flowY},shape:K}),dr(null))},className:ae("sf:flex sf:items-center sf:gap-2 sf:rounded-sm sf:px-2 sf:py-1.5 sf:text-left sf:text-sm","sf:hover:bg-accent sf:hover:text-accent-foreground","sf:focus:bg-accent sf:focus:text-accent-foreground sf:focus:outline-hidden"),children:[p.jsx(le,{className:"sf:h-4 sf:w-4 sf:text-muted-foreground","aria-hidden":"true"}),p.jsx("span",{children:ee})]},K))})})]}):null,Are?p.jsx(HQe,{flowId:Nre,node:Lre,connector:Ire,adapter:o??null,statusReport:G,onNameChange:ne,onDescriptionChange:Ie,onDetailChange:De,onIconChange:Ke,onClose:()=>{var K;(K=yr.current)==null||K.call(yr,[],[])}}):null]})})})}const Get=m.forwardRef(Wet);function Zet({open:e,onOpenChange:t,onCreated:n}){const[o,r]=m.useState(""),[a,i]=m.useState(""),[s,c]=m.useState(""),[l,h]=m.useState(null),[u,f]=m.useState(!1);m.useEffect(()=>{e&&(r(""),i(""),c(""),h(null),f(!1))},[e]);const y=o.trim(),k=a.trim(),x=s.trim(),w=y.length>0&&k.length>0&&!u,g=async M=>{if(M.preventDefault(),!!w){f(!0),h(null);try{const v=await sse({path:y,name:k,...x.length>0?{description:x}:{}});n(v),t(!1)}catch(v){h(v instanceof Error?v.message:String(v)),f(!1)}}};return p.jsx(Wz,{open:e,onOpenChange:t,children:p.jsxs(ef,{className:"sm:max-w-md","data-testid":"create-project-dialog",onOpenAutoFocus:M=>{M.preventDefault();const v=document.querySelector('[data-testid="create-project-path-input"]');v==null||v.focus()},children:[p.jsxs(tf,{children:[p.jsx(nf,{children:"Create new project"}),p.jsx(of,{children:"Scaffold a new SeeFlow project at the path you provide."})]}),p.jsxs("form",{onSubmit:g,className:"flex flex-col gap-4",children:[p.jsxs("label",{className:"flex flex-col gap-1.5 text-sm",children:[p.jsx("span",{className:"font-medium",children:"Project path"}),p.jsx("input",{type:"text",required:!0,autoComplete:"off",spellCheck:!1,placeholder:"/absolute/path/to/my-project",value:o,onChange:M=>r(M.target.value),"data-testid":"create-project-path-input",className:"rounded-md border bg-background px-3 py-2 text-sm outline-hidden ring-offset-background focus:border-ring focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2"})]}),p.jsxs("label",{className:"flex flex-col gap-1.5 text-sm",children:[p.jsx("span",{className:"font-medium",children:"Project name"}),p.jsx("input",{type:"text",required:!0,autoComplete:"off",spellCheck:!1,value:a,onChange:M=>i(M.target.value),"data-testid":"create-project-name-input",className:"rounded-md border bg-background px-3 py-2 text-sm outline-hidden ring-offset-background focus:border-ring focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2"})]}),p.jsxs("label",{className:"flex flex-col gap-1.5 text-sm",children:[p.jsxs("span",{className:"font-medium",children:["Description ",p.jsx("span",{className:"text-muted-foreground",children:"(optional)"})]}),p.jsx("textarea",{rows:3,autoComplete:"off",spellCheck:!1,value:s,onChange:M=>c(M.target.value),"data-testid":"create-project-description-input",className:"rounded-md border bg-background px-3 py-2 text-sm outline-hidden ring-offset-background focus:border-ring focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2"})]}),l?p.jsx("div",{role:"alert","data-testid":"create-project-error",className:"rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-sm text-destructive",children:l}):null,p.jsxs(a0,{children:[p.jsx(qt,{type:"button",variant:"ghost",onClick:()=>t(!1),disabled:u,children:"Cancel"}),p.jsx(qt,{type:"submit",disabled:!w,"data-testid":"create-project-submit",children:u?"Creating…":"Create project"})]})]})]})})}const BH="seeflow:navigate",Ket=e=>(window.addEventListener("popstate",e),window.addEventListener(BH,e),()=>{window.removeEventListener("popstate",e),window.removeEventListener(BH,e)}),EG=()=>window.location.pathname,Xet=()=>m.useSyncExternalStore(Ket,EG,EG),c0=e=>{e!==window.location.pathname&&(window.history.pushState({},"",e),window.dispatchEvent(new Event(BH)))};/**
8544
8544
  * @license lucide-react v0.453.0 - ISC
8545
8545
  *
8546
8546
  * This source code is licensed under the ISC license.
@@ -8610,4 +8610,4 @@ For more information, see https://radix-ui.com/primitives/docs/components/${t.do
8610
8610
  *
8611
8611
  * This source code is licensed under the ISC license.
8612
8612
  * See the LICENSE file in the root directory of this source tree.
8613
- */const stt=Zr("Workflow",[["rect",{width:"8",height:"8",x:"3",y:"3",rx:"2",key:"by2w9f"}],["path",{d:"M7 11v4a2 2 0 0 0 2 2h4",key:"xkn7yn"}],["rect",{width:"8",height:"8",x:"13",y:"13",rx:"2",key:"1cgmvn"}]]);function ctt({demos:e,currentSlug:t,onProjectCreated:n,onProjectUnregistered:o}){const[r,a]=m.useState(!1),[i,s]=m.useState(!1),[c,l]=m.useState(null),[h,u]=m.useState(!1),[f,y]=m.useState(null);m.useEffect(()=>{const v=b=>{b.key==="k"&&(b.metaKey||b.ctrlKey)&&(b.preventDefault(),a(C=>!C))};return document.addEventListener("keydown",v),()=>document.removeEventListener("keydown",v)},[]);const k=e.find(v=>v.slug===t),x=v=>{n==null||n(v),c0(`/d/${v.slug}`)},w=v=>{l(v),y(null)},g=()=>{h||(l(null),y(null))},M=async()=>{if(c){u(!0),y(null);try{await ise(c.id);const v=c.id;l(null),o==null||o(v)}catch(v){y(v instanceof Error?v.message:String(v))}finally{u(!1)}}};return p.jsxs(p.Fragment,{children:[p.jsxs(w0,{open:r,onOpenChange:a,children:[p.jsx(Gh,{asChild:!0,children:p.jsxs(qt,{type:"button",variant:"outline",size:"sm","aria-label":"Switch demo","aria-expanded":r,className:"gap-2","data-testid":"project-switcher-trigger",children:[p.jsx("span",{className:"max-w-[180px] truncate text-sm",children:(k==null?void 0:k.name)??"Select demo"}),p.jsx(xee,{children:"⌘K"}),p.jsx(ett,{className:"h-3.5 w-3.5 opacity-60"})]})}),p.jsx(Sd,{align:"end",sideOffset:6,className:"w-[320px] p-0","data-testid":"project-switcher-popover",children:p.jsxs(yee,{children:[p.jsx(mee,{placeholder:"Search demos..."}),p.jsxs(kee,{children:[p.jsx(gee,{children:"No demos."}),e.length>0?p.jsx(MH,{heading:"Demos",children:e.map(v=>p.jsxs(bH,{value:`${v.name} ${v.slug}`,onSelect:()=>{a(!1),c0(`/d/${v.slug}`)},className:"group flex items-center justify-between gap-2",children:[p.jsxs("div",{className:"flex min-w-0 flex-col items-start gap-0.5",children:[p.jsx("span",{className:"font-medium",children:v.name}),p.jsx("span",{className:"w-full truncate text-xs text-muted-foreground",children:v.repoPath})]}),p.jsx("button",{type:"button","aria-label":`Unregister ${v.name}`,className:"shrink-0 rounded p-0.5 opacity-0 transition-opacity hover:text-destructive group-hover:opacity-100 focus-visible:opacity-100 focus-visible:outline-hidden focus-visible:ring-1 focus-visible:ring-ring",onClick:b=>{b.stopPropagation(),a(!1),w(v)},children:p.jsx(itt,{className:"h-3.5 w-3.5"})})]},v.id))}):null,e.length>0?p.jsx(vee,{}):null,p.jsx(MH,{children:p.jsxs(bH,{value:"+ create new project",onSelect:()=>{a(!1),s(!0)},"data-testid":"project-switcher-create",className:"flex items-center gap-2 text-sm",children:[p.jsx(ott,{className:"h-4 w-4 opacity-70"}),p.jsx("span",{className:"font-medium",children:"Create new project"})]})})]})]})})]}),p.jsx(Zet,{open:i,onOpenChange:s,onCreated:x}),p.jsx(Wz,{open:c!==null,onOpenChange:v=>{v||g()},children:p.jsxs(ef,{className:"sm:max-w-md","data-testid":"unregister-project-dialog",children:[p.jsxs(tf,{children:[p.jsx(nf,{children:"Unregister project?"}),p.jsxs(of,{children:["This removes ",p.jsx("strong",{children:c==null?void 0:c.name})," from SeeFlow. Your files at"," ",p.jsx("code",{className:"text-xs",children:c==null?void 0:c.repoPath})," will not be deleted."]})]}),f?p.jsx("div",{role:"alert","data-testid":"unregister-project-error",className:"rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-sm text-destructive",children:f}):null,p.jsxs(a0,{children:[p.jsx(qt,{type:"button",variant:"ghost",onClick:g,disabled:h,children:"Cancel"}),p.jsx(qt,{type:"button",variant:"destructive",onClick:M,disabled:h,"data-testid":"unregister-project-confirm",children:h?"Unregistering…":"Unregister"})]})]})})]})}const qoe="seeflow:theme",$G="(prefers-color-scheme: dark)";function ltt(e){return e==="light"||e==="dark"||e==="system"}function dtt(e){try{const t=e.getItem(qoe);return ltt(t)?t:"system"}catch{return"system"}}function utt(e){try{const t=new URLSearchParams(e);if(!t.has("theme"))return null;const n=t.get("theme");return n==="light"||n==="dark"?n:"light"}catch{return null}}function htt(e,t){try{e.setItem(qoe,t)}catch{}}function ftt(e,t){return e==="system"?t?"dark":"light":e}function ptt(e,t){t==="dark"?(e.classList.add("dark"),e.classList.remove("light")):(e.classList.add("light"),e.classList.remove("dark"))}function ytt(e,t){var o;const n=r=>t(r.matches);return e.addEventListener?(e.addEventListener("change",n),()=>{var r;return(r=e.removeEventListener)==null?void 0:r.call(e,"change",n)}):((o=e.addListener)==null||o.call(e,n),()=>{var r;return(r=e.removeListener)==null?void 0:r.call(e,n)})}function mtt(){const[e,t]=m.useState(()=>{if(typeof window>"u")return"system";const i=utt(window.location.search);return i||dtt(window.localStorage)}),[n,o]=m.useState(()=>typeof window>"u"?!1:window.matchMedia($G).matches);m.useEffect(()=>{if(typeof window>"u")return;const i=window.matchMedia($G);return ytt(i,o)},[]);const r=ftt(e,n);m.useEffect(()=>{typeof document>"u"||ptt(document.documentElement,r)},[r]);const a=m.useCallback(i=>{typeof window<"u"&&htt(window.localStorage,i),t(i)},[]);return{theme:e,setTheme:a,resolvedTheme:r}}const ktt=[{value:"light",label:"Light"},{value:"dark",label:"Dark"},{value:"system",label:"System"}];function gtt({demos:e,currentSlug:t,onProjectCreated:n,onProjectUnregistered:o}){const{theme:r,setTheme:a}=mtt();return p.jsxs("header",{className:"relative flex h-14 shrink-0 items-center justify-between bg-background/85 px-5 backdrop-blur-md shadow-[0_1px_3px_-1px_rgba(15,23,42,0.06),0_2px_8px_-4px_rgba(15,23,42,0.05)] dark:border-b dark:border-border/60 dark:shadow-[0_4px_12px_-6px_rgba(0,0,0,0.6)]",children:[p.jsxs("button",{type:"button",onClick:()=>c0("/"),className:"-ml-1.5 flex items-center gap-2 rounded-md px-1.5 py-1 text-base font-bold tracking-tight transition-colors hover:bg-muted/60",children:[p.jsx(stt,{size:18,strokeWidth:2.25,className:"text-emerald-400"}),"SeeFlow",p.jsxs("span",{className:"ml-1 text-[10px] font-normal tracking-normal text-muted-foreground/70",children:["v","0.1.71"]})]}),p.jsxs("div",{className:"flex items-center gap-3",children:[p.jsx(ctt,{demos:e,currentSlug:t,onProjectCreated:n,onProjectUnregistered:o}),p.jsxs(Fte,{children:[p.jsx(Vte,{asChild:!0,children:p.jsx(qt,{type:"button",variant:"outline",size:"icon","aria-label":"Settings","data-testid":"settings-trigger",children:p.jsx(rtt,{className:"h-4 w-4"})})}),p.jsxs(GO,{align:"end",sideOffset:6,className:"w-44","data-testid":"settings-menu",children:[p.jsx(Bte,{children:"Theme"}),p.jsx(lUe,{value:r,onValueChange:i=>a(i),children:ktt.map(i=>p.jsx(Ute,{value:i.value,"data-testid":`theme-${i.value}`,children:i.label},i.value))})]})]})]})]})}const vtt=e=>{const[t,n]=m.useState(null),[o,r]=m.useState(e!==null),[a,i]=m.useState(null),s=m.useCallback(()=>{e&&(r(!0),cX(e).then(l=>{n(l),i(null)}).catch(l=>{console.error("[useDemoData] failed",l),i(String(l))}).finally(()=>r(!1)))},[e]),c=m.useCallback(l=>{n(l),i(null)},[]);return m.useEffect(()=>{if(!e){n(null),r(!1);return}s()},[e,s]),{detail:t,loading:o,error:a,refresh:s,applyDetail:c}},xtt=()=>{const[e,t]=m.useState(null),[n,o]=m.useState(null),r=m.useCallback(()=>ase().then(a=>{t(a),o(null)}).catch(a=>{console.error("[useDemos] failed",a),t([]),o(String(a))}),[]);return m.useEffect(()=>{r()},[r]),{demos:e,error:n,refresh:r}},wtt=5,Mtt={"node:running":"running","node:done":"done","node:error":"error"},btt=(e,t)=>{if(t.type==="reset")return{};const n=e[t.nodeId]??[],o=[t.entry,...n].slice(0,wtt);return{...e,[t.nodeId]:o}},_tt=e=>{const[t,n]=m.useReducer(btt,{}),o=m.useRef(n);o.current=n,m.useEffect(()=>{o.current({type:"reset"})},[e]);const r=m.useCallback(i=>{const s=Mtt[i.type];if(!s)return;const c=typeof i.nodeId=="string"?i.nodeId:null;if(!c)return;const l=typeof i.runId=="string"?i.runId:void 0,h=typeof i.ts=="number"?i.ts:Date.now();o.current({type:"append",nodeId:c,entry:{status:s,ts:h,runId:l}})},[]),a=m.useCallback(()=>{o.current({type:"reset"})},[]);return{events:t,apply:r,reset:a}},Ctt=(e,t)=>{var n,o;switch(t.type){case"reset":return{};case"running":return{...e,[t.nodeId]:{status:"running",runId:t.runId,ts:t.ts??Date.now()}};case"done":return{...e,[t.nodeId]:{...e[t.nodeId],status:"done",runId:t.runId??((n=e[t.nodeId])==null?void 0:n.runId),responseStatus:t.responseStatus,body:t.body,ts:t.ts??Date.now()}};case"error":return{...e,[t.nodeId]:{...e[t.nodeId],status:"error",runId:t.runId??((o=e[t.nodeId])==null?void 0:o.runId),error:t.message,ts:t.ts??Date.now()}}}},Stt=e=>{const[t,n]=m.useReducer(Ctt,{}),o=m.useRef(n);o.current=n,m.useEffect(()=>{o.current({type:"reset"})},[e]);const r=m.useCallback(i=>{const s=typeof i.nodeId=="string"?i.nodeId:null;if(!s)return;const c=typeof i.runId=="string"?i.runId:void 0;if(i.type==="node:running"){o.current({type:"running",nodeId:s,runId:c,ts:i.ts});return}if(i.type==="node:done"){const l=typeof i.status=="number"?i.status:void 0;o.current({type:"done",nodeId:s,runId:c,responseStatus:l,body:i.body,ts:i.ts});return}if(i.type==="node:error"){const l=typeof i.message=="string"?i.message:void 0;o.current({type:"error",nodeId:s,runId:c,message:l,ts:i.ts})}},[]),a=m.useCallback(()=>{o.current({type:"reset"})},[]);return{runs:t,apply:r,reset:a}},Ltt=new Set(["ok","warn","error","pending"]),Itt=(e,t)=>{if(t.type!=="node:status")return e;const n=typeof t.nodeId=="string"?t.nodeId:null;if(!n||typeof t.state!="string"||!Ltt.has(t.state))return e;const o=typeof t.summary=="string"?t.summary:void 0,r=typeof t.detail=="string"?t.detail:void 0,a=t.data&&typeof t.data=="object"&&!Array.isArray(t.data)?t.data:void 0,i=typeof t.ts=="number"?t.ts:Date.now();return{...e,[n]:{state:t.state,summary:o,detail:r,data:a,ts:i}}},Ntt=(e,t)=>{switch(t.type){case"reset":return{};case"event":return Itt(e,t.event)}},Att=e=>{const[t,n]=m.useReducer(Ntt,{}),o=m.useRef(n);o.current=n,m.useEffect(()=>{o.current({type:"reset"})},[e]);const r=m.useCallback(i=>{o.current({type:"event",event:i})},[]),a=m.useCallback(()=>{o.current({type:"reset"})},[]);return{statusByNode:t,apply:r,reset:a}},Ett=(e={})=>{const[t,n]=m.useState(!1),{onRegistryReload:o,onHello:r}=e,a=m.useRef(o),i=m.useRef(r);return m.useEffect(()=>{a.current=o,i.current=r},[o,r]),m.useEffect(()=>{const s=new EventSource("/api/registry/events");return s.addEventListener("open",()=>n(!0)),s.addEventListener("error",()=>n(!1)),s.addEventListener("hello",()=>{var c;(c=i.current)==null||c.call(i)}),s.addEventListener("registry:reload",()=>{var c;(c=a.current)==null||c.call(a)}),()=>{s.close()}},[]),{connected:t}},$tt=(e,t={})=>{const[n,o]=m.useState(!1),{onHello:r,onFlowReload:a,onEvent:i}=t,s=m.useRef(r),c=m.useRef(a),l=m.useRef(i);return m.useEffect(()=>{s.current=r,c.current=a,l.current=i},[r,a,i]),m.useEffect(()=>{if(!e){o(!1);return}const h=`/api/events?flowId=${encodeURIComponent(e)}`,u=new EventSource(h);u.addEventListener("open",()=>o(!0)),u.addEventListener("error",()=>o(!1)),u.addEventListener("hello",()=>{var f;(f=s.current)==null||f.call(s)}),u.addEventListener("flow:reload",f=>{var x,w;const y=PG(f,"flow:reload");(x=l.current)==null||x.call(l,y);const k=Ptt(y);k&&((w=c.current)==null||w.call(c,k))});for(const f of["node:running","node:done","node:error","node:status"])u.addEventListener(f,y=>{var k;(k=l.current)==null||k.call(l,PG(y,f))});return()=>{u.close()}},[e]),{connected:n}},PG=(e,t)=>{try{const n=JSON.parse(e.data);return{type:t,ts:Date.now(),...n}}catch{return{type:t,ts:Date.now()}}},Ptt=e=>e.valid===!0&&e.flow&&typeof e.flow=="object"?{valid:!0,flow:e.flow}:e.valid===!1&&typeof e.error=="string"?{valid:!1,error:e.error}:null,Ooe="seeflow:last-project",jtt=()=>{if(typeof window>"u")return null;try{return window.localStorage.getItem(Ooe)}catch{return null}},jG=e=>{if(!(typeof window>"u"))try{window.localStorage.setItem(Ooe,e)}catch{}},ztt=(e,t)=>{if(e.length===0)return null;if(e.length===1)return e[0]??null;if(t){const n=e.find(o=>o.id===t);if(n)return n}return null},zG=["File","Edit","View","Tools","Layout","Selection","Help"],Foe="seeflow:command-palette:recent",Voe=5,Boe=new Map(lO.map(e=>[e.id,e])),Rtt=e=>typeof e=="string"&&Boe.has(e),RG=()=>{if(typeof window>"u")return[];try{const e=window.localStorage.getItem(Foe);if(!e)return[];const t=JSON.parse(e);return Array.isArray(t)?t.filter(Rtt).slice(0,Voe):[]}catch{return[]}},Ttt=e=>{if(!(typeof window>"u"))try{window.localStorage.setItem(Foe,JSON.stringify(e))}catch{}},TG=(e,t)=>e.enabled?e.enabled(t):!0,Dtt=(e,t)=>t.length===0?!0:`${e.label} ${e.description??""}`.toLowerCase().includes(t);function Htt({open:e,onOpenChange:t,runCommand:n,ctx:o}){const[r,a]=m.useState(""),[i,s]=m.useState(0),[c,l]=m.useState(()=>RG()),h=m.useRef(null),u=m.useRef(null);m.useEffect(()=>{e&&(a(""),s(0),l(RG()))},[e]);const{groups:f,flat:y}=m.useMemo(()=>{const b=r.trim().toLowerCase();if(b.length===0){if(c.length===0)return{groups:[],flat:[]};const P=[];for(const $ of c){const N=Boe.get($);N&&P.push({cmd:N,enabled:TG(N,o)})}return{groups:[{category:"Recent",rows:P}],flat:P}}const C=new Map;for(const P of lO){if(!Dtt(P,b))continue;const I={cmd:P,enabled:TG(P,o)},$=C.get(P.category);$?$.push(I):C.set(P.category,[I])}const S=[...zG.filter(P=>C.has(P)),...Array.from(C.keys()).filter(P=>!zG.includes(P))].map(P=>({category:P,rows:C.get(P)??[]})),A=S.flatMap(P=>P.rows);return{groups:S,flat:A}},[r,o,c]);m.useEffect(()=>{if(y.length===0){s(0);return}s(b=>{var _;let C=b;if(C>=y.length&&(C=0),!((_=y[C])!=null&&_.enabled)){const S=y.findIndex(A=>A.enabled);S!==-1&&(C=S)}return C})},[y]);const k=m.useCallback(b=>{y.length!==0&&s(C=>{var S;let _=C;for(let A=0;A<y.length;A++)if(_=(_+b+y.length)%y.length,(S=y[_])!=null&&S.enabled)return _;return C})},[y]),x=m.useCallback(b=>{l(C=>{const _=[b,...C.filter(S=>S!==b)].slice(0,Voe);return Ttt(_),_})},[]),w=m.useCallback(b=>{const C=y[b];!C||!C.enabled||(x(C.cmd.id),n(C.cmd.id),t(!1))},[y,t,x,n]),g=m.useCallback(b=>{if(b.key==="ArrowDown"){b.preventDefault(),k(1);return}if(b.key==="ArrowUp"){b.preventDefault(),k(-1);return}b.key==="Enter"&&(b.preventDefault(),w(i))},[w,i,k]);m.useEffect(()=>{if(!e)return;const b=u.current;if(!b)return;const C=b.querySelector(`[data-command-row-index="${i}"]`);C&&typeof C.scrollIntoView=="function"&&C.scrollIntoView({block:"nearest"})},[i,e]);const v=r.trim().length>0;return p.jsx(Oz,{open:e,onOpenChange:t,children:p.jsx(Fz,{children:p.jsxs(M0,{className:ae("fixed left-0 right-0 top-[20%] z-50 mx-auto w-[480px] max-w-[90vw] border border-border bg-card 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","sm:rounded-lg"),"data-testid":"command-palette",onOpenAutoFocus:b=>{var C;b.preventDefault(),(C=h.current)==null||C.focus()},children:[p.jsx("div",{className:ae("border-b",y.length===0&&!v&&"border-b-0"),children:p.jsx("input",{ref:h,type:"text",value:r,onChange:b=>a(b.target.value),onKeyDown:g,placeholder:"Type a command…","data-testid":"command-palette-input","aria-label":"Search commands",autoComplete:"off",spellCheck:!1,className:"w-full bg-transparent px-4 py-3 text-sm outline-hidden placeholder:text-muted-foreground"})}),p.jsx("div",{ref:u,"data-testid":"command-palette-list","data-empty":y.length===0?"true":"false",className:ae("max-h-[50vh] overflow-y-auto",y.length>0?"py-1":"","seeflow-no-scrollbar"),children:y.length===0?v?p.jsxs("div",{"data-testid":"command-palette-empty",className:"px-4 py-6 text-center text-sm text-muted-foreground",children:['No commands match "',r,'"']}):null:(()=>{let b=-1;return f.map(C=>p.jsxs("div",{className:"py-1",children:[p.jsx("div",{className:"px-3 pb-1 pt-2 text-xs font-medium uppercase tracking-wide text-muted-foreground",children:C.category}),C.rows.map(_=>{b+=1;const S=b,A=S===i;return p.jsxs("button",{type:"button","data-testid":`command-palette-row-${_.cmd.id}`,"data-command-row-index":S,"data-highlighted":A?"true":"false","aria-disabled":_.enabled?void 0:!0,disabled:!_.enabled,onMouseEnter:()=>{_.enabled&&s(S)},onClick:()=>w(S),className:ae("flex w-full items-center justify-between gap-3 px-3 py-2 text-left text-sm outline-hidden",_.enabled?"cursor-pointer text-foreground hover:bg-muted":"cursor-not-allowed text-muted-foreground/50",A&&_.enabled?"bg-muted":""),children:[p.jsxs("div",{className:"flex min-w-0 flex-col",children:[p.jsx("span",{className:"truncate font-medium",children:_.cmd.label}),_.cmd.description?p.jsx("span",{className:"truncate text-xs text-muted-foreground",children:_.cmd.description}):null]}),_.cmd.shortcut?p.jsx("kbd",{"data-testid":`command-palette-shortcut-${_.cmd.id}`,className:"shrink-0 rounded border bg-muted px-1.5 py-0.5 font-mono text-[11px] text-muted-foreground",children:_.cmd.shortcut}):null]},_.cmd.id)})]},C.category))})()})]})})})}var wn=Uint8Array,co=Uint16Array,gF=Int32Array,vF=new wn([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),xF=new wn([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),DG=new wn([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Uoe=function(e,t){for(var n=new co(31),o=0;o<31;++o)n[o]=t+=1<<e[o-1];for(var r=new gF(n[30]),o=1;o<30;++o)for(var a=n[o];a<n[o+1];++a)r[a]=a-n[o]<<5|o;return{b:n,r}},Woe=Uoe(vF,2),qtt=Woe.b,UH=Woe.r;qtt[28]=258,UH[258]=28;var Ott=Uoe(xF,0),HG=Ott.r,WH=new co(32768);for(var Lt=0;Lt<32768;++Lt){var Ka=(Lt&43690)>>1|(Lt&21845)<<1;Ka=(Ka&52428)>>2|(Ka&13107)<<2,Ka=(Ka&61680)>>4|(Ka&3855)<<4,WH[Lt]=((Ka&65280)>>8|(Ka&255)<<8)>>1}var Z2=function(e,t,n){for(var o=e.length,r=0,a=new co(t);r<o;++r)e[r]&&++a[e[r]-1];var i=new co(t);for(r=1;r<t;++r)i[r]=i[r-1]+a[r-1]<<1;var s;if(n){s=new co(1<<t);var c=15-t;for(r=0;r<o;++r)if(e[r])for(var l=r<<4|e[r],h=t-e[r],u=i[e[r]-1]++<<h,f=u|(1<<h)-1;u<=f;++u)s[WH[u]>>c]=l}else for(s=new co(o),r=0;r<o;++r)e[r]&&(s[r]=WH[i[e[r]-1]++]>>15-e[r]);return s},Md=new wn(288);for(var Lt=0;Lt<144;++Lt)Md[Lt]=8;for(var Lt=144;Lt<256;++Lt)Md[Lt]=9;for(var Lt=256;Lt<280;++Lt)Md[Lt]=7;for(var Lt=280;Lt<288;++Lt)Md[Lt]=8;var Yj=new wn(32);for(var Lt=0;Lt<32;++Lt)Yj[Lt]=5;var Ftt=Z2(Md,9,0),Vtt=Z2(Yj,5,0),Goe=function(e){return(e+7)/8|0},Zoe=function(e,t,n){return(n==null||n>e.length)&&(n=e.length),new wn(e.subarray(t,n))},Btt=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],cR=function(e,t,n){var o=new Error(t||Btt[e]);if(o.code=e,Error.captureStackTrace&&Error.captureStackTrace(o,cR),!n)throw o;return o},ca=function(e,t,n){n<<=t&7;var o=t/8|0;e[o]|=n,e[o+1]|=n>>8},Z0=function(e,t,n){n<<=t&7;var o=t/8|0;e[o]|=n,e[o+1]|=n>>8,e[o+2]|=n>>16},FT=function(e,t){for(var n=[],o=0;o<e.length;++o)e[o]&&n.push({s:o,f:e[o]});var r=n.length,a=n.slice();if(!r)return{t:Xoe,l:0};if(r==1){var i=new wn(n[0].s+1);return i[n[0].s]=1,{t:i,l:1}}n.sort(function(C,_){return C.f-_.f}),n.push({s:-1,f:25001});var s=n[0],c=n[1],l=0,h=1,u=2;for(n[0]={s:-1,f:s.f+c.f,l:s,r:c};h!=r-1;)s=n[n[l].f<n[u].f?l++:u++],c=n[l!=h&&n[l].f<n[u].f?l++:u++],n[h++]={s:-1,f:s.f+c.f,l:s,r:c};for(var f=a[0].s,o=1;o<r;++o)a[o].s>f&&(f=a[o].s);var y=new co(f+1),k=GH(n[h-1],y,0);if(k>t){var o=0,x=0,w=k-t,g=1<<w;for(a.sort(function(_,S){return y[S.s]-y[_.s]||_.f-S.f});o<r;++o){var M=a[o].s;if(y[M]>t)x+=g-(1<<k-y[M]),y[M]=t;else break}for(x>>=w;x>0;){var v=a[o].s;y[v]<t?x-=1<<t-y[v]++-1:++o}for(;o>=0&&x;--o){var b=a[o].s;y[b]==t&&(--y[b],++x)}k=t}return{t:new wn(y),l:k}},GH=function(e,t,n){return e.s==-1?Math.max(GH(e.l,t,n+1),GH(e.r,t,n+1)):t[e.s]=n},qG=function(e){for(var t=e.length;t&&!e[--t];);for(var n=new co(++t),o=0,r=e[0],a=1,i=function(c){n[o++]=c},s=1;s<=t;++s)if(e[s]==r&&s!=t)++a;else{if(!r&&a>2){for(;a>138;a-=138)i(32754);a>2&&(i(a>10?a-11<<5|28690:a-3<<5|12305),a=0)}else if(a>3){for(i(r),--a;a>6;a-=6)i(8304);a>2&&(i(a-3<<5|8208),a=0)}for(;a--;)i(r);a=1,r=e[s]}return{c:n.subarray(0,o),n:t}},K0=function(e,t){for(var n=0,o=0;o<t.length;++o)n+=e[o]*t[o];return n},Koe=function(e,t,n){var o=n.length,r=Goe(t+2);e[r]=o&255,e[r+1]=o>>8,e[r+2]=e[r]^255,e[r+3]=e[r+1]^255;for(var a=0;a<o;++a)e[r+a+4]=n[a];return(r+4+o)*8},OG=function(e,t,n,o,r,a,i,s,c,l,h){ca(t,h++,n),++r[256];for(var u=FT(r,15),f=u.t,y=u.l,k=FT(a,15),x=k.t,w=k.l,g=qG(f),M=g.c,v=g.n,b=qG(x),C=b.c,_=b.n,S=new co(19),A=0;A<M.length;++A)++S[M[A]&31];for(var A=0;A<C.length;++A)++S[C[A]&31];for(var P=FT(S,7),I=P.t,$=P.l,N=19;N>4&&!I[DG[N-1]];--N);var X=l+5<<3,j=K0(r,Md)+K0(a,Yj)+i,O=K0(r,f)+K0(a,x)+i+14+3*N+K0(S,I)+2*S[16]+3*S[17]+7*S[18];if(c>=0&&X<=j&&X<=O)return Koe(t,h,e.subarray(c,c+l));var H,B,z,R;if(ca(t,h,1+(O<j)),h+=2,O<j){H=Z2(f,y,0),B=f,z=Z2(x,w,0),R=x;var L=Z2(I,$,0);ca(t,h,v-257),ca(t,h+5,_-1),ca(t,h+10,N-4),h+=14;for(var A=0;A<N;++A)ca(t,h+3*A,I[DG[A]]);h+=3*N;for(var U=[M,C],D=0;D<2;++D)for(var E=U[D],A=0;A<E.length;++A){var W=E[A]&31;ca(t,h,L[W]),h+=I[W],W>15&&(ca(t,h,E[A]>>5&127),h+=E[A]>>12)}}else H=Ftt,B=Md,z=Vtt,R=Yj;for(var A=0;A<s;++A){var Y=o[A];if(Y>255){var W=Y>>18&31;Z0(t,h,H[W+257]),h+=B[W+257],W>7&&(ca(t,h,Y>>23&31),h+=vF[W]);var Q=Y&31;Z0(t,h,z[Q]),h+=R[Q],Q>3&&(Z0(t,h,Y>>5&8191),h+=xF[Q])}else Z0(t,h,H[Y]),h+=B[Y]}return Z0(t,h,H[256]),h+B[256]},Utt=new gF([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),Xoe=new wn(0),Wtt=function(e,t,n,o,r,a){var i=a.z||e.length,s=new wn(o+i+5*(1+Math.ceil(i/7e3))+r),c=s.subarray(o,s.length-r),l=a.l,h=(a.r||0)&7;if(t){h&&(c[0]=a.r>>3);for(var u=Utt[t-1],f=u>>13,y=u&8191,k=(1<<n)-1,x=a.p||new co(32768),w=a.h||new co(k+1),g=Math.ceil(n/3),M=2*g,v=function(re){return(e[re]^e[re+1]<<g^e[re+2]<<M)&k},b=new gF(25e3),C=new co(288),_=new co(32),S=0,A=0,P=a.i||0,I=0,$=a.w||0,N=0;P+2<i;++P){var X=v(P),j=P&32767,O=w[X];if(x[j]=O,w[X]=j,$<=P){var H=i-P;if((S>7e3||I>24576)&&(H>423||!l)){h=OG(e,c,0,b,C,_,A,I,N,P-N,h),I=S=A=0,N=P;for(var B=0;B<286;++B)C[B]=0;for(var B=0;B<30;++B)_[B]=0}var z=2,R=0,L=y,U=j-O&32767;if(H>2&&X==v(P-U))for(var D=Math.min(f,H)-1,E=Math.min(32767,P),W=Math.min(258,H);U<=E&&--L&&j!=O;){if(e[P+z]==e[P+z-U]){for(var Y=0;Y<W&&e[P+Y]==e[P+Y-U];++Y);if(Y>z){if(z=Y,R=U,Y>D)break;for(var Q=Math.min(U,Y-2),oe=0,B=0;B<Q;++B){var te=P-U+B&32767,se=x[te],we=te-se&32767;we>oe&&(oe=we,O=te)}}}j=O,O=x[j],U+=j-O&32767}if(R){b[I++]=268435456|UH[z]<<18|HG[R];var ke=UH[z]&31,ge=HG[R]&31;A+=vF[ke]+xF[ge],++C[257+ke],++_[ge],$=P+z,++S}else b[I++]=e[P],++C[e[P]]}}for(P=Math.max(P,$);P<i;++P)b[I++]=e[P],++C[e[P]];h=OG(e,c,l,b,C,_,A,I,N,P-N,h),l||(a.r=h&7|c[h/8|0]<<3,h-=7,a.h=w,a.p=x,a.i=P,a.w=$)}else{for(var P=a.w||0;P<i+l;P+=65535){var ve=P+65535;ve>=i&&(c[h/8|0]=l,ve=i),h=Koe(c,h+1,e.subarray(P,ve))}a.i=i}return Zoe(s,0,o+Goe(h)+r)},Gtt=function(){for(var e=new Int32Array(256),t=0;t<256;++t){for(var n=t,o=9;--o;)n=(n&1&&-306674912)^n>>>1;e[t]=n}return e}(),Ztt=function(){var e=-1;return{p:function(t){for(var n=e,o=0;o<t.length;++o)n=Gtt[n&255^t[o]]^n>>>8;e=n},d:function(){return~e}}},Yoe=function(){var e=1,t=0;return{p:function(n){for(var o=e,r=t,a=n.length|0,i=0;i!=a;){for(var s=Math.min(i+2655,a);i<s;++i)r+=o+=n[i];o=(o&65535)+15*(o>>16),r=(r&65535)+15*(r>>16)}e=o,t=r},d:function(){return e%=65521,t%=65521,(e&255)<<24|(e&65280)<<8|(t&255)<<8|t>>8}}},Qoe=function(e,t,n,o,r){if(!r&&(r={l:1},t.dictionary)){var a=t.dictionary.subarray(-32768),i=new wn(a.length+e.length);i.set(a),i.set(e,a.length),e=i,r.w=a.length}return Wtt(e,t.level==null?6:t.level,t.mem==null?r.l?Math.ceil(Math.max(8,Math.min(13,Math.log(e.length)))*1.5):20:12+t.mem,n,o,r)},Joe=function(e,t){var n={};for(var o in e)n[o]=e[o];for(var o in t)n[o]=t[o];return n},tn=function(e,t,n){for(;n;++t)e[t]=n,n>>>=8},Ktt=function(e,t){var n=t.level,o=n==0?0:n<6?1:n==9?3:2;if(e[0]=120,e[1]=o<<6|(t.dictionary&&32),e[1]|=31-(e[0]<<8|e[1])%31,t.dictionary){var r=Yoe();r.p(t.dictionary),tn(e,2,r.d())}};function Xtt(e,t){return Qoe(e,t||{},0,0)}function qnt(e,t){t||(t={});var n=Yoe();n.p(e);var o=Qoe(e,t,t.dictionary?6:2,4);return Ktt(o,t),tn(o,o.length-4,n.d()),o}var ere=function(e,t,n,o){for(var r in e){var a=e[r],i=t+r,s=o;Array.isArray(a)&&(s=Joe(o,a[1]),a=a[0]),a instanceof wn?n[i]=[a,s]:(n[i+="/"]=[new wn(0),s],ere(a,i,n,o))}},FG=typeof TextEncoder<"u"&&new TextEncoder,Ytt=typeof TextDecoder<"u"&&new TextDecoder,Qtt=0;try{Ytt.decode(Xoe,{stream:!0}),Qtt=1}catch{}function ZH(e,t){var n;if(FG)return FG.encode(e);for(var o=e.length,r=new wn(e.length+(e.length>>1)),a=0,i=function(l){r[a++]=l},n=0;n<o;++n){if(a+5>r.length){var s=new wn(a+8+(o-n<<1));s.set(r),r=s}var c=e.charCodeAt(n);c<128||t?i(c):c<2048?(i(192|c>>6),i(128|c&63)):c>55295&&c<57344?(c=65536+(c&1047552)|e.charCodeAt(++n)&1023,i(240|c>>18),i(128|c>>12&63),i(128|c>>6&63),i(128|c&63)):(i(224|c>>12),i(128|c>>6&63),i(128|c&63))}return Zoe(r,0,a)}var KH=function(e){var t=0;if(e)for(var n in e){var o=e[n].length;o>65535&&cR(9),t+=o+4}return t},VG=function(e,t,n,o,r,a,i,s){var c=o.length,l=n.extra,h=s&&s.length,u=KH(l);tn(e,t,i!=null?33639248:67324752),t+=4,i!=null&&(e[t++]=20,e[t++]=n.os),e[t]=20,t+=2,e[t++]=n.flag<<1|(a<0&&8),e[t++]=r&&8,e[t++]=n.compression&255,e[t++]=n.compression>>8;var f=new Date(n.mtime==null?Date.now():n.mtime),y=f.getFullYear()-1980;if((y<0||y>119)&&cR(10),tn(e,t,y<<25|f.getMonth()+1<<21|f.getDate()<<16|f.getHours()<<11|f.getMinutes()<<5|f.getSeconds()>>1),t+=4,a!=-1&&(tn(e,t,n.crc),tn(e,t+4,a<0?-a-2:a),tn(e,t+8,n.size)),tn(e,t+12,c),tn(e,t+14,u),t+=16,i!=null&&(tn(e,t,h),tn(e,t+6,n.attrs),tn(e,t+10,i),t+=14),e.set(o,t),t+=c,u)for(var k in l){var x=l[k],w=x.length;tn(e,t,+k),tn(e,t+2,w),e.set(x,t+4),t+=4+w}return h&&(e.set(s,t),t+=h),t},Jtt=function(e,t,n,o,r){tn(e,t,101010256),tn(e,t+8,n),tn(e,t+10,n),tn(e,t+12,o),tn(e,t+16,r)};function ent(e,t){t||(t={});var n={},o=[];ere(e,"",n,t);var r=0,a=0;for(var i in n){var s=n[i],c=s[0],l=s[1],h=l.level==0?0:8,u=ZH(i),f=u.length,y=l.comment,k=y&&ZH(y),x=k&&k.length,w=KH(l.extra);f>65535&&cR(11);var g=h?Xtt(c,l):c,M=g.length,v=Ztt();v.p(c),o.push(Joe(l,{size:c.length,crc:v.d(),c:g,f:u,m:k,u:f!=i.length||k&&y.length!=x,o:r,compression:h})),r+=30+f+w+M,a+=76+2*(f+w)+(x||0)+M}for(var b=new wn(a+22),C=r,_=a-r,S=0;S<o.length;++S){var u=o[S];VG(b,u.o,u,u.f,u.u,u.c.length);var A=30+u.f.length+KH(u.extra);b.set(u.c,u.o+A),VG(b,r,u,u.f,u.u,u.c.length,u.o,u.m),r+=16+A+(u.m?u.m.length:0)}return Jtt(b,r,o.length,_,C),b}const tnt="https://seeflow.dev/api";async function nnt(e,t,n,o,r){const a=await cX(e);if(!a.flow)throw new Error("Flow has no data");const i=a.flow,s=new Set,c=[];for(const k of i.nodes)k.type==="image"&&k.data.path&&!s.has(k.data.path)&&(s.add(k.data.path),c.push(k.data.path));const h={[o==="link"?"flow.private.json":"flow.json"]:ZH(JSON.stringify(i))};if(r){const k=r.split(",")[1];k&&(h["preview.png"]=Uint8Array.from(atob(k),x=>x.charCodeAt(0)))}for(const k of c){const x=await fetch(`/api/projects/${encodeURIComponent(e)}/files/${k}`);x.ok&&(h[`files/${k}`]=new Uint8Array(await x.arrayBuffer()))}const u=ent(h),f=await fetch(`${tnt}/flows?email=${encodeURIComponent(t)}&name=${encodeURIComponent(n)}`,{method:"POST",headers:{"content-type":"application/zip"},body:u.buffer});if(!f.ok)throw new Error(`Export failed with status ${f.status}`);const y=await f.json();if(typeof y.url!="string")throw new Error("Invalid response from cloud API: missing url");return{shareUrl:y.url}}function ont(e){return m.useCallback((t,n,o,r)=>nnt(e,t,n,o,r),[e])}const BG="seeflow.export.email",UG="seeflow.export.name",WG="seeflow.export.visibility";function rnt({open:e,onOpenChange:t,projectId:n,flowName:o,onCapturePreview:r}){const[a,i]=m.useState(""),[s,c]=m.useState(""),[l,h]=m.useState("public"),[u,f]=m.useState({kind:"idle"}),[y,k]=m.useState(!1),x=ont(n);m.useEffect(()=>{e&&(i(localStorage.getItem(BG)??""),c(o??localStorage.getItem(UG)??""),h(localStorage.getItem(WG)??"public"),f({kind:"idle"}),k(!1))},[e,o]);const w=m.useCallback(async()=>{f({kind:"loading"});try{const b=await(r==null?void 0:r()),{shareUrl:C}=await x(a.trim(),s.trim(),l,b);localStorage.setItem(BG,a.trim()),localStorage.setItem(UG,s.trim()),localStorage.setItem(WG,l),f({kind:"done",shareUrl:C})}catch(b){f({kind:"error",message:b instanceof Error?b.message:String(b)})}},[x,a,s,l,r]),g=m.useCallback(async()=>{if(u.kind==="done")try{await navigator.clipboard.writeText(u.shareUrl),k(!0),setTimeout(()=>k(!1),2e3)}catch(b){console.error("Failed to copy to clipboard:",b)}},[u]),M=u.kind==="loading",v=a.trim().length>0&&s.trim().length>0;return p.jsx(Wz,{open:e,onOpenChange:t,children:p.jsxs(ef,{className:"sm:max-w-md","data-testid":"export-dialog",onOpenAutoFocus:b=>{b.preventDefault();const C=document.querySelector('[data-testid="export-email-input"]');C==null||C.focus()},children:[p.jsxs(tf,{children:[p.jsx(nf,{children:"Export to seeflow.dev"}),p.jsx(of,{children:"Upload this diagram to the cloud and get a shareable link."})]}),u.kind!=="done"?p.jsxs(p.Fragment,{children:[p.jsxs("div",{className:"flex flex-col gap-4",children:[p.jsxs("label",{className:"flex flex-col gap-1.5 text-sm",children:[p.jsx("span",{className:"font-medium",children:"Email"}),p.jsx("input",{type:"email",required:!0,autoComplete:"email",value:a,onChange:b=>i(b.target.value),disabled:M,"data-testid":"export-email-input",className:"rounded-md border bg-background px-3 py-2 text-sm outline-hidden ring-offset-background focus:border-ring focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50"}),p.jsx("span",{className:"text-xs text-muted-foreground",children:"We'll use this to let you manage your flows in the future."})]}),p.jsxs("label",{className:"flex flex-col gap-1.5 text-sm",children:[p.jsx("span",{className:"font-medium",children:"Flow Name"}),p.jsx("input",{type:"text",required:!0,value:s,onChange:b=>c(b.target.value),disabled:M,"data-testid":"export-name-input",className:"rounded-md border bg-background px-3 py-2 text-sm outline-hidden ring-offset-background focus:border-ring focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50"})]}),p.jsxs("label",{className:"flex flex-col gap-1.5 text-sm",children:[p.jsx("span",{className:"font-medium",children:"Visibility"}),p.jsxs("select",{value:l,onChange:b=>h(b.target.value),disabled:M,"data-testid":"export-visibility-select",className:"rounded-md border bg-background px-3 py-2 text-sm outline-hidden ring-offset-background focus:border-ring focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",children:[p.jsx("option",{value:"public",children:"Public — anyone can discover it"}),p.jsx("option",{value:"link",children:"Anyone with the link"})]})]}),u.kind==="error"?p.jsx("div",{role:"alert","data-testid":"export-error",className:"rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-sm text-destructive",children:u.message}):null]}),p.jsx(a0,{children:u.kind==="error"?p.jsxs(p.Fragment,{children:[p.jsx(qt,{type:"button",variant:"ghost",onClick:()=>t(!1),"data-testid":"export-cancel",children:"Cancel"}),p.jsx(qt,{type:"button",onClick:()=>f({kind:"idle"}),"data-testid":"export-retry",children:"Try again"})]}):p.jsxs(p.Fragment,{children:[p.jsx(qt,{type:"button",variant:"ghost",onClick:()=>t(!1),disabled:M,"data-testid":"export-cancel",children:"Cancel"}),p.jsx(qt,{type:"button",onClick:w,disabled:M||!v,"data-testid":"export-submit",children:M?p.jsxs(p.Fragment,{children:[p.jsx(ntt,{className:"h-4 w-4 animate-spin","aria-hidden":"true"}),p.jsx("span",{children:"Uploading…"})]}):"Export"})]})})]}):p.jsxs(p.Fragment,{children:[p.jsxs("div",{className:"flex flex-col gap-3",children:[p.jsx("p",{className:"text-sm text-muted-foreground",children:"Your diagram is live. Share this link:"}),p.jsxs("div",{className:"flex gap-2",children:[p.jsx("input",{type:"text",readOnly:!0,value:u.shareUrl,"data-testid":"export-share-url",className:"min-w-0 flex-1 rounded-md border bg-muted px-3 py-2 text-sm outline-hidden"}),p.jsx(qt,{type:"button",variant:"outline",size:"icon",onClick:g,"aria-label":"Copy link","data-testid":"export-copy",children:y?p.jsx(Doe,{className:"h-4 w-4","aria-hidden":"true"}):p.jsx(Hoe,{className:"h-4 w-4","aria-hidden":"true"})}),p.jsx(qt,{type:"button",variant:"outline",size:"icon",onClick:()=>window.open(u.shareUrl,"_blank"),"aria-label":"View in new tab","data-testid":"export-view",children:p.jsx(ttt,{className:"h-4 w-4","aria-hidden":"true"})})]})]}),p.jsx(a0,{children:p.jsx(qt,{type:"button",onClick:()=>t(!1),"data-testid":"export-done",children:"Done"})})]})]})})}const ant=(e,t)=>{if(e.has(t))return e;const n=new Set(e);return n.add(t),n},int=(e,t)=>{if(t.length===0)return e;let n=!1;const o=new Set(e);for(const r of t)o.has(r)||(o.add(r),n=!0);return n?o:e},snt=(e,t)=>{if(!e.has(t))return e;const n=new Set(e);return n.delete(t),n},cnt=(e,t)=>{if(t.length===0)return e;let n=!1;const o=new Set(e);for(const r of t)o.has(r)&&(o.delete(r),n=!0);return n?o:e},lnt=(e,t)=>{if(e.size===0)return e;const n=new Set(t.map(a=>a.id));let o=!1;const r=new Set(e);for(const a of r)n.has(a)||(r.delete(a),o=!0);return o?r:e},GG=()=>{const[e,t]=m.useState(()=>new Set),n=m.useCallback(c=>{t(l=>ant(l,c))},[]),o=m.useCallback(c=>{t(l=>int(l,c))},[]),r=m.useCallback(c=>{t(l=>snt(l,c))},[]),a=m.useCallback(c=>{t(l=>cnt(l,c))},[]),i=m.useCallback(c=>{t(l=>lnt(l,c))},[]),s=m.useCallback(()=>t(new Set),[]);return{ids:e,mark:n,markMany:o,unmark:r,unmarkMany:a,pruneAgainst:i,reset:s}},dnt=(e,t)=>e===t?!0:e==null||t==null||typeof e!=typeof t||typeof e!="object"?!1:JSON.stringify(e)===JSON.stringify(t),unt=(e,t,n)=>({...e,[t]:{...e[t],...n}}),hnt=(e,t)=>{if(!(t in e))return e;const n={...e};return delete n[t],n},fnt=(e,t)=>{const n=Object.entries(e);if(n.length===0)return e;const o=new Map(t.map(i=>[i.id,i]));let r=!1;const a={...e};for(const[i,s]of n){const c=o.get(i);if(!c)continue;const l={};let h=!1;for(const u of Object.keys(s))dnt(s[u],c[u])?r=!0:(l[u]=s[u],h=!0);h?a[i]=l:(r=!0,delete a[i])}return r?a:e},ZG=()=>{const[e,t]=m.useState({}),n=m.useCallback((i,s)=>{t(c=>unt(c,i,s))},[]),o=m.useCallback(i=>{t(s=>hnt(s,i))},[]),r=m.useCallback(i=>{t(s=>fnt(s,i))},[]),a=m.useCallback(()=>t({}),[]);return{overrides:e,setOverride:n,dropOverride:o,pruneAgainst:r,reset:a}},pnt=500,ynt=500,mnt={stack:[],cursor:0},knt=(e,t,n)=>{const o=Date.now(),r=pnt,a=ynt,{stack:i,cursor:s}=e;if(t.coalesceKey&&s>0){const h=i[s-1];if(h&&h.coalesceKey===t.coalesceKey&&o-h.capturedAt<=a){const u=i.slice(0,s);return u[s-1]={...h,do:t.do,capturedAt:o},{stack:u,cursor:s}}}const c=i.slice(0,s);c.push({...t,capturedAt:o});let l=s+1;for(;c.length>r;)c.shift(),l-=1;return l<0&&(l=0),{stack:c,cursor:l}},gnt=e=>e.cursor===0?{state:e,entry:void 0}:{state:{...e,cursor:e.cursor-1},entry:e.stack[e.cursor-1]},vnt=e=>e.cursor===e.stack.length?{state:e,entry:void 0}:{state:{...e,cursor:e.cursor+1},entry:e.stack[e.cursor]},xnt=()=>({stack:[],cursor:0}),wnt=e=>{if(e.cursor===0)return e;const t=e.stack.slice();return t.splice(e.cursor-1,1),{stack:t,cursor:e.cursor-1}},Mnt=(e,t)=>t.state,bnt=()=>{const[e,t]=m.useReducer(Mnt,mnt),n=m.useRef(e);n.current=e;const o=m.useRef(Promise.resolve()),r=m.useRef(0),a=m.useCallback(y=>{y!==n.current&&(n.current=y,t({type:"replace",state:y}))},[]),i=m.useCallback(y=>{const k={do:y.do,undo:y.undo,coalesceKey:y.coalesceKey,capturedAt:y.capturedAt??Date.now()};a(knt(n.current,k))},[a]),s=m.useCallback(()=>{r.current=Date.now();const y=o.current.then(()=>{const k=gnt(n.current);if(k.entry)return a(k.state),{entry:k.entry}});return o.current=y.then(()=>{},()=>{}),y},[a]),c=m.useCallback(()=>{r.current=Date.now();const y=o.current.then(()=>{const k=vnt(n.current);if(k.entry)return a(k.state),{entry:k.entry}});return o.current=y.then(()=>{},()=>{}),y},[a]),l=m.useCallback(()=>{a(xnt())},[a]),h=m.useCallback(()=>{a(wnt(n.current))},[a]),u=m.useCallback(()=>{r.current=Date.now()},[]),f=m.useCallback(()=>r.current,[]);return{push:i,undo:s,redo:c,clear:l,dropTop:h,canUndo:e.cursor>0,canRedo:e.cursor<e.stack.length,markMutation:u,lastMutationAt:f}};function _nt({nodes:e,connectors:t,flowPos:n,nodeIdGen:o,connectorIdGen:r,defaultOffset:a={x:24,y:24}}){const i=new Map;for(const y of e)i.set(y.id,o(y.id));let s=Number.POSITIVE_INFINITY,c=Number.POSITIVE_INFINITY;for(const y of e)y.position.x<s&&(s=y.position.x),y.position.y<c&&(c=y.position.y);Number.isFinite(s)||(s=0),Number.isFinite(c)||(c=0);const l=n?n.x-s:a.x,h=n?n.y-c:a.y,u=e.map(y=>{const k=i.get(y.id);if(k===void 0)throw new Error(`paste id missing for ${y.id}`);return{...y,id:k,position:{x:y.position.x+l,y:y.position.y+h}}}),f=t.map(y=>{const k=r(y.id);return{...y,id:k,source:i.get(y.source)??y.source,target:i.get(y.target)??y.target}});return{newNodes:u,newConnectors:f,idMap:i}}const Cnt=e=>({type:"image",position:e.position,data:{path:"",alt:e.originalFilename,width:e.dims.width,height:e.dims.height,_uploading:!0}}),Snt=e=>({type:"image",data:tre(e)}),Lnt=e=>({type:"image",position:e.position,data:{path:"",alt:e.originalFilename,width:e.dims.width,height:e.dims.height,_uploadError:e.message}}),tre=e=>({...pTe(e.path,e.dims,e.lastUsed),alt:e.originalFilename}),Int=async(e,t)=>{const{nodeId:n,flowId:o,file:r,originalFilename:a,position:i,dims:s,lastUsed:c}=e;t.rememberRetry(n,{file:r,originalFilename:a,position:i,dims:s}),t.setOverride(n,Cnt({position:i,dims:s,originalFilename:a}));let l;try{l=(await t.upload(o,n,r,a)).path}catch(y){const k=y instanceof Error?y.message:String(y);throw t.setOverride(n,Lnt({position:i,dims:s,originalFilename:a,message:k})),y}t.setOverride(n,Snt({path:l,dims:s,originalFilename:a,lastUsed:c}));const h=tre({path:l,dims:s,originalFilename:a,lastUsed:c}),u={id:n,type:"image",position:i,data:h},{id:f}=await t.createNode(o,u);t.forgetRetry(n),t.pushUndo&&t.pushUndo({do:async()=>{await t.createNode(o,{...u,id:f})},undo:async()=>{await t.deleteNode(o,f)}})},Nnt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",Ant=248;function la(e=10){let t="";const n=new Uint8Array(e*2);for(;t.length<e;){crypto.getRandomValues(n);for(let o=0;o<n.length&&t.length<e;o++){const r=n[o];r<Ant&&(t+=Nnt[r%62])}}return t}const Ent=new Set(["INPUT","TEXTAREA","SELECT"]),qo=e=>e?Ent.has(e.tagName)?!0:e instanceof HTMLElement&&e.isContentEditable:!1,$nt=(e,t,n)=>{const o=e.indexOf(t);if(o<0)return null;const r=e.length,a=[...e];switch(n.op){case"forward":{if(o>=r-1)return null;const i=a[o],s=a[o+1];return i===void 0||s===void 0?null:(a[o]=s,a[o+1]=i,a)}case"backward":{if(o<=0)return null;const i=a[o],s=a[o-1];return i===void 0||s===void 0?null:(a[o]=s,a[o-1]=i,a)}case"toFront":{if(o===r-1)return null;const[i]=a.splice(o,1);return i===void 0?null:(a.push(i),a)}case"toBack":{if(o===0)return null;const[i]=a.splice(o,1);return i===void 0?null:(a.unshift(i),a)}case"toIndex":{const i=Math.min(Math.max(n.index,0),r-1);if(i===o)return null;const[s]=a.splice(o,1);return s===void 0?null:(a.splice(i,0,s),a)}}};function Pnt({slug:e,demos:t,detail:n,loading:o,runs:r,nodeEvents:a,statusByNode:i,onPlayNode:s,onRestartDemo:c}){var na,S0;const l=t.find(q=>q.slug===e),[h,u]=m.useState([]),[f,y]=m.useState([]),[k,x]=m.useState(null),w=m.useRef(h),g=m.useRef(f);m.useEffect(()=>{w.current=h},[h]),m.useEffect(()=>{g.current=f},[f]);const M=m.useRef(null),v=m.useRef(null),b=m.useRef(null),C=ZG(),_=ZG(),S=GG(),A=GG(),[P,I]=m.useState(null),[$,N]=m.useState(null),[X,j]=m.useState({kind:"select"}),O=m.useRef({kind:"select"});m.useEffect(()=>{O.current=X},[X]);const[H,B]=m.useState(!1),[z,R]=m.useState(0),L=m.useRef(null),U=m.useRef(null),D=m.useCallback(q=>{U.current=q},[]),E=bnt(),{push:W,dropTop:Y,markMutation:Q,clear:oe,lastMutationAt:te}=E,{reset:se}=C,{reset:we}=_,{reset:ke}=S,{reset:ge}=A;m.useEffect(()=>{u([]),y([]),x(null),se(),we(),ke(),ge(),I(null),N(null),zo.current=null,dr(!1),Kt.current.clear(),E.clear()},[n==null?void 0:n.id]);const ve=m.useCallback((q,F)=>{u(q),y(F)},[]),re=(na=n==null?void 0:n.flow)==null?void 0:na.nodes,me=(S0=n==null?void 0:n.flow)==null?void 0:S0.connectors,{pruneAgainst:Ve}=C,{pruneAgainst:lt}=_,{pruneAgainst:Vt}=S,{pruneAgainst:Et}=A;m.useEffect(()=>{re&&(Ve(re),Vt(re)),Date.now()-te()>2e3&&oe()},[re,Ve,Vt,te,oe]),m.useEffect(()=>{if(!re)return;const q=L.current,F=new Set(re.map(ie=>ie.id));if(L.current=F,q===null)return;const Z=C.overrides,V=S.ids;let T=!1;for(const ie of F)if(!q.has(ie)&&!(ie in Z)){T=!0;break}if(!T){for(const ie of q)if(!F.has(ie)&&!V.has(ie)){T=!0;break}}T&&R(ie=>ie+1)},[re]),m.useEffect(()=>{me&&(lt(me),Et(me)),Date.now()-te()>2e3&&oe()},[me,lt,Et,te,oe]),m.useEffect(()=>{if(!(!re||!P)&&re.length===P.length){for(let q=0;q<re.length;q++){const F=re[q],Z=P[q];if(!F||F.id!==Z)return}I(null)}},[re,P]);const ce=(n==null?void 0:n.id)??null,J=m.useMemo(()=>ce?yTe({baseUrl:"",flowId:ce}):null,[ce]),[ln,rn]=m.useState(!1),{setOverride:Ee,dropOverride:Ge}=C,G=m.useRef(C.overrides);m.useEffect(()=>{G.current=C.overrides},[C.overrides]);const ne=m.useCallback((q,F)=>{var V;if(!ce||!J)return;const Z=(V=re==null?void 0:re.find(T=>T.id===q))==null?void 0:V.position;Ee(q,{position:F}),N(null),Q(),Z&&W({do:async()=>{await J.updateNodePosition(q,F)},undo:async()=>{await J.updateNodePosition(q,Z)},coalesceKey:`node:${q}:position`}),J.updateNodePosition(q,F).catch(T=>{Ge(q),Z&&Y(),N(T instanceof Error?T.message:String(T)),console.error("updateNodePosition failed",T)})},[ce,J,re,Ee,Ge,W,Y,Q]),Ie=m.useCallback(q=>{if(!ce||!J||q.length===0)return;const F=G.current,Z=q.map(V=>{var Ae;const T=re==null?void 0:re.find(be=>be.id===V.id);if(!T)return null;const ie=((Ae=F[V.id])==null?void 0:Ae.position)??T.position;return{id:V.id,prev:ie,next:V.position}}).filter(V=>V!==null);if(Z.length!==0){for(const V of Z)Ee(V.id,{position:V.next});N(null),Q(),W({do:async()=>{await Promise.allSettled(Z.map(V=>J.updateNodePosition(V.id,V.next)))},undo:async()=>{await Promise.allSettled(Z.map(V=>J.updateNodePosition(V.id,V.prev)))}}),Promise.all(Z.map(async V=>{try{return await J.updateNodePosition(V.id,V.next),null}catch(T){return Ge(V.id),T instanceof Error?T.message:String(T)}})).then(V=>{const T=V.find(ie=>ie!==null);T&&N(T)})}},[ce,J,re,Ee,Ge,W,Q]),De=m.useCallback((q,F)=>{Ee(q,{position:{x:F.x,y:F.y},data:{width:F.width,height:F.height}})},[Ee]),Ke=m.useCallback((q,F)=>{if(!ce||!J)return;const Z=re==null?void 0:re.find(ie=>ie.id===q),V=Z?{width:Z.data.width,height:Z.data.height,position:{x:Z.position.x,y:Z.position.y}}:void 0,T={width:F.width,height:F.height,position:{x:F.x,y:F.y}};Ee(q,{position:T.position,data:{width:T.width,height:T.height}}),N(null),Q(),V&&W({do:async()=>{await J.updateNode(q,T)},undo:async()=>{await J.updateNode(q,V)},coalesceKey:`node:${q}:resize`}),J.updateNode(q,T).catch(ie=>{Ge(q),V&&Y(),N(ie instanceof Error?ie.message:String(ie)),console.error("updateNode resize failed",ie)})},[ce,J,re,Ee,Ge,W,Y,Q]),Bt=m.useCallback(q=>{if(!ce||!J)return;const F=re==null?void 0:re.find(T=>T.id===q);if(!F)return;const Z={autoSize:F.data.autoSize,width:F.data.width,height:F.data.height},V={autoSize:!0};Ee(q,{data:{autoSize:!0,width:void 0,height:void 0}}),N(null),Q(),W({do:async()=>{await J.updateNode(q,V)},undo:async()=>{await J.updateNode(q,Z)},coalesceKey:`node:${q}:fit-to-content`}),J.updateNode(q,V).catch(T=>{Ge(q),Y(),N(T instanceof Error?T.message:String(T)),console.error("updateNode (fit-to-content) failed",T)})},[ce,J,re,Ee,Ge,W,Y,Q]),bn=m.useCallback(q=>{if(!ce||!J||q.length===0)return;const F=[];for(const V of q){const T=re==null?void 0:re.find(Je=>Je.id===V.id);if(!T)continue;const ie=T.data,Ae={position:{x:T.position.x,y:T.position.y}};ie.width!==void 0&&(Ae.width=ie.width),ie.height!==void 0&&(Ae.height=ie.height);const be={position:V.position};V.width!==void 0&&(be.width=V.width),V.height!==void 0&&(be.height=V.height),F.push({id:V.id,prev:Ae,next:be})}if(F.length===0)return;for(const V of F){const T={};V.next.width!==void 0&&(T.width=V.next.width),V.next.height!==void 0&&(T.height=V.next.height),Ee(V.id,{position:V.next.position,...Object.keys(T).length>0?{data:T}:{}})}N(null),Q();const Z=F.map(V=>V.id).sort();W({do:async()=>{await Promise.allSettled(F.map(V=>J.updateNode(V.id,V.next)))},undo:async()=>{await Promise.allSettled(F.map(V=>J.updateNode(V.id,V.prev)))},coalesceKey:`multi:resize:${Z.join(",")}`}),Promise.all(F.map(async V=>{try{return await J.updateNode(V.id,V.next),null}catch(T){return Ge(V.id),T instanceof Error?T.message:String(T)}})).then(V=>{const T=V.find(ie=>ie!==null);T&&N(T)})},[ce,J,re,Ee,Ge,W,Q]),{setOverride:Qe,dropOverride:ft}=_,_n=m.useCallback((q,F)=>{Ee(q,{data:F})},[Ee]),Rt=m.useCallback((q,F)=>{for(const Z of q)Ee(Z,{data:F})},[Ee]),Cn=m.useCallback((q,F)=>{Qe(q,F)},[Qe]),an=m.useCallback((q,F)=>{if(!ce||!J)return;tU(Xa,F);const Z=re==null?void 0:re.find(T=>T.id===q);let V=null;if(Z){V={};const T=Z.data;for(const ie of Object.keys(F))V[ie]=T[ie]}if(Ee(q,{data:F}),N(null),Q(),V){const T=V;W({do:async()=>{await J.updateNode(q,F)},undo:async()=>{await J.updateNode(q,T)},coalesceKey:`node:${q}:style`})}J.updateNode(q,F).catch(T=>{Ge(q),V&&Y(),N(T instanceof Error?T.message:String(T)),console.error("updateNode style failed",T)})},[ce,J,re,Ee,Ge,W,Y,Q]),dt=m.useCallback((q,F)=>{if(!ce||!J||q.length===0)return;tU(Xa,F);const Z=q.map(V=>{const T=re==null?void 0:re.find(be=>be.id===V);if(!T)return null;const ie=T.data,Ae={};for(const be of Object.keys(F))Ae[be]=ie[be];return{id:V,prev:Ae}}).filter(V=>V!==null);if(Z.length!==0){for(const V of Z)Ee(V.id,{data:F});N(null),Q(),W({do:async()=>{await Promise.allSettled(Z.map(V=>J.updateNode(V.id,F)))},undo:async()=>{await Promise.allSettled(Z.map(V=>J.updateNode(V.id,V.prev)))}}),Promise.all(Z.map(async V=>{try{return await J.updateNode(V.id,F),null}catch(T){return Ge(V.id),T instanceof Error?T.message:String(T)}})).then(V=>{const T=V.find(ie=>ie!==null);T&&N(T)})}},[ce,J,re,Ee,Ge,W,Q]),Mt=m.useCallback((q,F)=>{if(!ce||!J)return;lTe(Xa,F);const Z=me==null?void 0:me.find(T=>T.id===q);let V=null;if(Z){V={};const T=Z;for(const ie of Object.keys(F))V[ie]=T[ie]}if(Qe(q,F),N(null),Q(),V){const T=V;W({do:async()=>{await J.updateConnector(q,F)},undo:async()=>{await J.updateConnector(q,T)},coalesceKey:`connector:${q}:style`})}J.updateConnector(q,F).catch(T=>{ft(q),V&&Y(),N(T instanceof Error?T.message:String(T)),console.error("updateConnector failed",T)})},[ce,J,me,Qe,ft,W,Y,Q]),{mark:rr,markMany:Ea,unmark:ar,unmarkMany:Pi}=S,{mark:$a,markMany:Ao,unmark:ir,unmarkMany:Eo}=A,Ad=m.useCallback(q=>{if(!ce||!J)return;const F=re==null?void 0:re.find(be=>be.id===q);if(!F)return;const Z=(me??[]).filter(be=>be.source===q||be.target===q),V=Z.map(be=>be.id),T=new Set(V);N(null),rr(q),V.length>0&&Ao(V),u(be=>be.filter(Je=>Je!==q)),y(be=>be.filter(Je=>!T.has(Je))),Q();const ie=F,Ae=Z;W({do:async()=>{rr(q),V.length>0&&Ao(V),await J.deleteNode(q)},undo:async()=>{ar(q),V.length>0&&Eo(V),await J.createNode({id:ie.id,type:ie.type,position:ie.position,data:ie.data});for(const be of Ae)await J.createConnector({...be,id:be.id})}}),J.deleteNode(q).catch(be=>{ar(q),V.length>0&&Eo(V),Y(),N(be instanceof Error?be.message:String(be)),console.error("deleteNode failed",be)})},[ce,J,re,me,rr,Ao,ar,Eo,W,Y,Q]),Ed=m.useCallback((q,F)=>{if(!ce||!J||!re)return;const Z=P??re.map(ie=>ie.id),V=$nt(Z,q,F);if(!V)return;const T=Z.indexOf(q);I(V),N(null),Q(),W({do:async()=>{await J.reorderNode(q,F)},undo:async()=>{await J.reorderNode(q,{op:"toIndex",index:T})}}),J.reorderNode(q,F).catch(ie=>{I(null),Y(),N(ie instanceof Error?ie.message:String(ie)),console.error("reorderNode failed",ie)})},[ce,J,re,P,W,Y,Q]);m.useCallback(q=>{if(!ce||!J)return;const F=me==null?void 0:me.find(V=>V.id===q);if(!F)return;N(null),$a(q),y(V=>V.filter(T=>T!==q)),Q();const Z=F;W({do:async()=>{$a(q),await J.deleteConnector(q)},undo:async()=>{ir(q),await J.createConnector({...Z,id:Z.id})}}),J.deleteConnector(q).catch(V=>{ir(q),Y(),N(V instanceof Error?V.message:String(V)),console.error("deleteConnector failed",V)})},[ce,J,me,$a,ir,W,Y,Q]);const $o=m.useCallback((q,F)=>{if(!ce||!J||q.length===0&&F.length===0)return;const Z=new Set(q),V=q.map($e=>re==null?void 0:re.find(it=>it.id===$e)).filter($e=>!!$e),T=(me??[]).filter($e=>Z.has($e.source)||Z.has($e.target)),ie=new Set(T.map($e=>$e.id)),Ae=F.map($e=>me==null?void 0:me.find(it=>it.id===$e)).filter($e=>!!$e).filter($e=>!ie.has($e.id));if(V.length===0&&T.length===0&&Ae.length===0)return;N(null);const be=V.map($e=>$e.id),Je=[...T.map($e=>$e.id),...Ae.map($e=>$e.id)];be.length>0&&Ea(be),Je.length>0&&Ao(Je);const Yt=V;u($e=>$e.filter(it=>!Z.has(it)));const pr=new Set(Ae.map($e=>$e.id));y($e=>$e.filter(it=>!pr.has(it)&&!ie.has(it))),Q(),W({do:async()=>{be.length>0&&Ea(be),Je.length>0&&Ao(Je);for(const $e of Yt)await J.deleteNode($e.id).catch(()=>{});await Promise.allSettled(Ae.map($e=>J.deleteConnector($e.id)))},undo:async()=>{be.length>0&&Pi(be),Je.length>0&&Eo(Je);for(let $e=Yt.length-1;$e>=0;$e--){const it=Yt[$e];it&&await J.createNode({id:it.id,type:it.type,position:it.position,data:it.data})}for(const $e of[...T,...Ae])await J.createConnector({...$e,id:$e.id})}});const Ot=new Map;for(const $e of V)Ot.set($e.id,T.filter(it=>it.source===$e.id||it.target===$e.id).map(it=>it.id));(async()=>{const $e=[];for(const yn of Yt)try{await J.deleteNode(yn.id)}catch(Tn){ar(yn.id);const Td=Ot.get(yn.id)??[];Td.length>0&&Eo(Td),$e.push(Tn instanceof Error?Tn.message:String(Tn))}const it=await Promise.all(Ae.map(async yn=>{try{return await J.deleteConnector(yn.id),null}catch(Tn){return ir(yn.id),Tn instanceof Error?Tn.message:String(Tn)}}));for(const yn of it)yn!==null&&$e.push(yn);$e.length>0&&$e[0]!==void 0&&N($e[0])})()},[ce,J,re,me,Ea,Ao,ar,Pi,ir,Eo,W,Q]);m.useEffect(()=>{M.current=$o},[$o]),m.useEffect(()=>{const q=F=>{if(F.key!=="Delete"&&F.key!=="Backspace"||qo(document.activeElement)||document.querySelector('[data-testid="inline-edit-input"]'))return;const Z=w.current,V=g.current;Z.length===0&&V.length===0||(F.preventDefault(),$o(Z,V))};return window.addEventListener("keydown",q),()=>window.removeEventListener("keydown",q)},[$o]);const{undo:Kr,redo:Xr,canUndo:He,canRedo:gt}=E;m.useEffect(()=>{const q=async F=>{if((F.metaKey||F.ctrlKey)&&F.key.toLowerCase()==="z"&&!qo(document.activeElement)){if(F.preventDefault(),F.shiftKey){if(!gt)return;try{const Z=await Xr();Z!=null&&Z.entry&&await Z.entry.do()}catch(Z){N(Z instanceof Error?Z.message:String(Z)),console.error("redo failed",Z)}return}if(He)try{const Z=await Kr();Z!=null&&Z.entry&&await Z.entry.undo()}catch(Z){N(Z instanceof Error?Z.message:String(Z)),console.error("undo failed",Z)}}};return window.addEventListener("keydown",q),()=>window.removeEventListener("keydown",q)},[Kr,Xr,He,gt]);const Pa=m.useCallback((q,F)=>{if(!ce||!J)return;const Z=re==null?void 0:re.find(ie=>ie.id===q),T=(Z&&"name"in Z.data?Z.data.name:void 0)??"";Ee(q,{data:{name:F}}),N(null),Q(),Z&&W({do:async()=>{await J.updateNode(q,{name:F})},undo:async()=>{await J.updateNode(q,{name:T})},coalesceKey:`node:${q}:name`}),J.updateNode(q,{name:F}).catch(ie=>{Z&&Y(),N(ie instanceof Error?ie.message:String(ie)),console.error("updateNode name failed",ie)})},[ce,J,re,Ee,W,Y,Q]),ji=m.useCallback((q,F)=>{if(!ce||!J)return;const Z=re==null?void 0:re.find(T=>T.id===q);if(!Z)return;const V=Z.data.description??"";Ee(q,{data:{description:F}}),N(null),Q(),W({do:async()=>{await J.updateNode(q,{description:F})},undo:async()=>{await J.updateNode(q,{description:V})},coalesceKey:`node:${q}:description`}),J.updateNode(q,{description:F}).catch(T=>{Y(),N(T instanceof Error?T.message:String(T)),console.error("updateNode description failed",T)})},[ce,J,re,Ee,W,Y,Q]),Yr=m.useCallback((q,F)=>{if(!ce||!J)return;const Z=re==null?void 0:re.find(T=>T.id===q);if(!Z)return;const V=Z.data.detail??"";Ee(q,{data:{detail:F}}),N(null),Q(),W({do:async()=>{await J.updateNode(q,{detail:F})},undo:async()=>{await J.updateNode(q,{detail:V})},coalesceKey:`node:${q}:detail`}),J.updateNode(q,{detail:F}).catch(T=>{Y(),N(T instanceof Error?T.message:String(T)),console.error("updateNode detail failed",T)})},[ce,J,re,Ee,W,Y,Q]),sr=m.useCallback((q,F)=>{if(!ce||!J)return;const Z=re==null?void 0:re.find(T=>T.id===q);if(!Z)return;const V="icon"in Z.data?Z.data.icon??null:null;Ee(q,{data:{icon:F??void 0}}),N(null),Q(),W({do:async()=>{await J.updateNode(q,{icon:F})},undo:async()=>{await J.updateNode(q,{icon:V})},coalesceKey:`node:${q}:icon`}),J.updateNode(q,{icon:F}).catch(T=>{Y(),N(T instanceof Error?T.message:String(T)),console.error("updateNode icon failed",T)})},[ce,J,re,Ee,W,Y,Q]),ja=m.useCallback((q,F,Z)=>{if(!ce||!J)return;N(null);const V=`node-${la()}`,T=oU(q,Z,n2(Xa).node),ie={id:V,type:q,position:F,data:T};Ee(V,{id:V,type:q,position:F,data:T}),Q(),J.createNode(ie).then(({id:be})=>{W({do:async()=>{await J.createNode({...ie,id:be})},undo:async()=>{await J.deleteNode(be)}})}).catch(be=>{Ge(V),N(be instanceof Error?be.message:String(be)),console.error("createNode failed",be)})},[ce,J,Ee,Ge,W,Q]),Rn=m.useCallback((q,F)=>{if(!ce||!J)return;N(null);const Z=`node-${la()}`,V={icon:q,width:Ku.width,height:Ku.height},T={id:Z,type:"icon",position:F,data:V};Ee(Z,{id:Z,type:"icon",position:F,data:V}),u([Z]),Q(),J.createNode(T).then(({id:Ae})=>{W({do:async()=>{await J.createNode({...T,id:Ae})},undo:async()=>{await J.deleteNode(Ae)}})}).catch(Ae=>{Ge(Z),N(Ae instanceof Error?Ae.message:String(Ae)),console.error("createNode (icon) failed",Ae)})},[ce,J,Ee,Ge,W,Q]),Po=m.useCallback(q=>{if(!ce||!J)return;N(null);const F=`node-${la()}`,Z={id:F,type:"html",position:q.position,data:{}},V={id:F,type:"html",position:q.position,data:{}};Ee(F,V),u([F]),Q(),J.createNode(Z).then(({id:T})=>{W({do:async()=>{await J.createNode({...Z,id:T})},undo:async()=>{await J.deleteNode(T)}})}).catch(T=>{Ge(F),N(T instanceof Error?T.message:String(T)),console.error("createNode (type:'html') failed",T)})},[ce,J,Ee,Ge,W,Q]),Kt=m.useRef(new Map),Xt=m.useCallback((q,F)=>{Kt.current.set(q,F)},[]),Qr=m.useCallback(q=>{Kt.current.delete(q)},[]),cr=m.useCallback(q=>{!ce||!J||(N(null),Q(),Int({...q,flowId:ce,lastUsed:n2(Xa).node},{upload:(F,Z,V,T)=>J.uploadImage(Z,V,T),createNode:async(F,Z)=>{const{id:V}=await J.createNode(Z);return{id:V}},deleteNode:async(F,Z)=>(await J.deleteNode(Z),{ok:!0}),setOverride:Ee,pushUndo:W,rememberRetry:Xt,forgetRetry:Qr}).catch(F=>{console.error("image-upload-flow failed",F)}))},[ce,J,Ee,W,Q,Xt,Qr]),$d=m.useCallback(q=>{if(!ce||!J)return;const F=`node-${la()}`;cr({nodeId:F,...q})},[ce,J,cr]),Pd=m.useCallback(q=>{const F=Kt.current.get(q);F&&cr({nodeId:q,...F})},[cr]),[jo,bt]=m.useState({open:!1,mode:"insert"}),Kn=m.useCallback((q,F)=>{bt({open:!0,mode:q,nodeId:F})},[]),lr=m.useCallback(()=>{bt(q=>({...q,open:!1}))},[]),jd=m.useCallback(()=>{Kn("insert")},[Kn]),Jr=m.useCallback(q=>Kn("replace",q),[Kn]),ea=m.useCallback(q=>{if(JRe(q),jo.mode==="replace"&&jo.nodeId){if(ce&&J){const F=jo.nodeId,Z=re==null?void 0:re.find(T=>T.id===F),V=(Z==null?void 0:Z.type)==="icon"?Z.data.icon:void 0;if(Ee(F,{data:{icon:q}}),N(null),Q(),V!==void 0){const T=V;W({do:async()=>{await J.updateNode(F,{icon:q})},undo:async()=>{await J.updateNode(F,{icon:T})},coalesceKey:`node:${F}:icon`})}J.updateNode(F,{icon:q}).catch(T=>{Ge(F),V!==void 0&&Y(),N(T instanceof Error?T.message:String(T)),console.error("updateNode (icon replace) failed",T)})}}else{const F=U.current;if(F&&ce){const Z=YRe(F,{width:window.innerWidth,height:window.innerHeight});Rn(q,Z)}}lr()},[jo.mode,jo.nodeId,ce,J,re,Ee,Ge,W,Y,Q,Rn,lr]),zd=m.useCallback((q,F)=>{if(!ce||!J)return;const Z=me==null?void 0:me.find(T=>T.id===q),V=Z==null?void 0:Z.label;Qe(q,{label:F}),N(null),Q(),Z&&W({do:async()=>{await J.updateConnector(q,{label:F})},undo:async()=>{await J.updateConnector(q,{label:V})},coalesceKey:`connector:${q}:label`}),J.updateConnector(q,{label:F}).catch(T=>{Z&&Y(),N(T instanceof Error?T.message:String(T)),console.error("updateConnector label failed",T)})},[ce,J,me,Qe,W,Y,Q]),zi=m.useCallback((q,F,Z)=>{if(!ce||!J)return;const V=`conn-${la()}`,T=Z==null?void 0:Z.targetPin,ie=n2(Xa).connector,Ae={id:V,source:q,target:F,sourceHandleAutoPicked:!0,targetHandleAutoPicked:!0,...T?{targetPin:T}:{},...ie},be={id:V,source:q,target:F,sourceHandleAutoPicked:!0,targetHandleAutoPicked:!0,...T?{targetPin:T}:{},...ie};Qe(V,Ae),N(null),Q(),J.createConnector(be).then(({id:Je})=>{W({do:async()=>{await J.createConnector({...be,id:Je})},undo:async()=>{await J.deleteConnector(Je)}})}).catch(Je=>{ft(V),N(Je instanceof Error?Je.message:String(Je)),console.error("createConnector failed",Je)})},[ce,J,Qe,ft,W,Q]),za=m.useCallback(({sourceNodeId:q,position:F,shape:Z})=>{if(!ce||!J)return;N(null);const V=`node-${la()}`,T=`conn-${la()}`,ie=qj[Z],Ae=n2(Xa),be=oU(Z,ie,Ae.node),Je={id:V,type:Z,position:F,data:be},Yt={id:T,source:q,target:V,sourceHandleAutoPicked:!0,targetHandleAutoPicked:!0,...Ae.connector};Ee(V,{id:V,type:Z,position:F,data:be}),Qe(T,Yt),x(V),Q(),(async()=>{try{await J.createNode(Je),await J.createConnector(Yt),W({do:async()=>{await J.createNode(Je),await J.createConnector(Yt)},undo:async()=>{ft(T),Ge(V),await J.deleteConnector(T).catch(()=>{}),await J.deleteNode(V).catch(()=>{})}})}catch(Ot){Ge(V),ft(T),N(Ot instanceof Error?Ot.message:String(Ot)),console.error("createAndConnectFromPane failed",Ot)}})()},[ce,J,Ee,Ge,Qe,ft,W,Q]),zo=m.useRef(null),[Sn,dr]=m.useState(!1),Xn=m.useCallback(q=>{if(!re)return;const F=new Set(q),Z=re.filter(T=>F.has(T.id));if(Z.length===0)return;const V=(me??[]).filter(T=>F.has(T.source)&&F.has(T.target));zo.current=JSON.parse(JSON.stringify({nodes:Z,connectors:V})),dr(!0)},[re,me]),Ro=m.useCallback(q=>{if(!ce||!J)return;const F=zo.current;if(!F||F.nodes.length===0)return;const{newNodes:Z,newConnectors:V}=_nt({nodes:F.nodes,connectors:F.connectors,flowPos:q,nodeIdGen:()=>`node-${la()}`,connectorIdGen:()=>`conn-${la()}`});for(const T of Z)Ee(T.id,T);for(const T of V)Qe(T.id,T);u(Z.map(T=>T.id)),y(V.map(T=>T.id)),N(null),Q(),(async()=>{try{for(const T of Z)await J.createNode({id:T.id,type:T.type,position:T.position,data:T.data});for(const T of V)await J.createConnector(T);W({do:async()=>{for(const T of Z)await J.createNode({id:T.id,type:T.type,position:T.position,data:T.data});for(const T of V)await J.createConnector(T)},undo:async()=>{await Promise.allSettled(V.map(T=>J.deleteConnector(T.id))),await Promise.allSettled(Z.map(T=>J.deleteNode(T.id)))}})}catch(T){for(const ie of Z)Ge(ie.id);for(const ie of V)ft(ie.id);N(T instanceof Error?T.message:String(T)),console.error("paste failed",T)}})()},[ce,J,Ee,Ge,Qe,ft,Q,W]);m.useEffect(()=>{const q=F=>{const Z=sTe({event:F,isEditableActive:qo(document.activeElement),hasNodes:!!re&&re.length>0,hasConnectors:!!me&&me.length>0,selectedIds:w.current,hasClipboard:!!zo.current});if(Z.type!=="noop"&&!(Z.type==="copy"||Z.type==="paste")){if(F.preventDefault(),Z.type==="selectAll"){u((re??[]).map(V=>V.id)),y((me??[]).map(V=>V.id));return}Xn([...Z.ids]),Ro(null)}};return window.addEventListener("keydown",q),()=>window.removeEventListener("keydown",q)},[re,me,Xn,Ro]),m.useEffect(()=>{const q=F=>{const Z=rTe(F);if(!Z||qo(document.activeElement))return;const V=w.current;if(V.length===0)return;const T=C.overrides,ie=(re??[]).map(be=>{var Yt;const Je=((Yt=T[be.id])==null?void 0:Yt.position)??be.position;return{id:be.id,position:Je}}),Ae=iTe(Z,V,ie);if(Ae.length!==0)if(F.preventDefault(),Ae.length===1){const be=Ae[0];be&&ne(be.id,be.position)}else Ie(Ae)};return window.addEventListener("keydown",q),()=>window.removeEventListener("keydown",q)},[re,C.overrides,ne,Ie]),m.useEffect(()=>{const q=F=>{const Z=aTe(F);if(!Z||qo(document.activeElement))return;F.preventDefault();const V=U.current;V&&(Z==="fit"?V.fitView({padding:.2,duration:200}):Z==="in"?V.zoomIn({duration:150}):V.zoomOut({duration:150}))};return window.addEventListener("keydown",q),()=>window.removeEventListener("keydown",q)},[]);const Yn=m.useCallback(async q=>{if(!ce||!J||!re||!J.computeLayout)return;const F=C.overrides,Z=U.current,V=q==="selection"?new Set(w.current):null,T=V?re.filter(Oe=>V.has(Oe.id)):re;if(T.length<2)return;const ie=new Set(T.map(Oe=>Oe.id)),Ae=(me??[]).filter(Oe=>ie.has(Oe.source)&&ie.has(Oe.target)),be=new Map,Je=T.map(Oe=>{var Ti;const _t=((Ti=F[Oe.id])==null?void 0:Ti.position)??Oe.position;be.set(Oe.id,_t);const Qt=Z==null?void 0:Z.getInternalNode(Oe.id),Jt=Qt==null?void 0:Qt.measured,Jn=Oe.data,L0=(Jt==null?void 0:Jt.width)??Jn.width??200,hR=(Jt==null?void 0:Jt.height)??Jn.height??120;return{id:Oe.id,type:Oe.type,width:L0,height:hR}}),Yt=Ae.map(Oe=>({id:Oe.id,source:Oe.source,target:Oe.target})),pr=await J.computeLayout(Je,Yt),Ot=new Map;for(const[Oe,_t]of Object.entries(pr.nodes))Ot.set(Oe,_t.position);let $e=Number.POSITIVE_INFINITY,it=Number.POSITIVE_INFINITY,yn=Number.POSITIVE_INFINITY,Tn=Number.POSITIVE_INFINITY;for(const Oe of Je){const _t=be.get(Oe.id);if(!_t)continue;_t.x<$e&&($e=_t.x),_t.y<it&&(it=_t.y);const Qt=Ot.get(Oe.id);Qt&&(Qt.x<yn&&(yn=Qt.x),Qt.y<Tn&&(Tn=Qt.y))}const Td=Number.isFinite($e)&&Number.isFinite(yn)?$e-yn:0,uR=Number.isFinite(it)&&Number.isFinite(Tn)?it-Tn:0,Da=[];for(const Oe of Je){const _t=be.get(Oe.id),Qt=Ot.get(Oe.id);if(!_t||!Qt)continue;const Jt={x:Qt.x+Td,y:Qt.y+uR},Jn=Jt.x-_t.x,L0=Jt.y-_t.y;Math.abs(Jn)<1&&Math.abs(L0)<1||Da.push({id:Oe.id,prev:_t,next:Jt})}if(Da.length!==0){N(null);for(const Oe of Da)Ee(Oe.id,{position:Oe.next});Q(),W({do:async()=>{await Promise.allSettled(Da.map(Oe=>J.updateNodePosition(Oe.id,Oe.next)))},undo:async()=>{await Promise.allSettled(Da.map(Oe=>J.updateNodePosition(Oe.id,Oe.prev)))}}),Promise.all(Da.map(async Oe=>{try{return await J.updateNodePosition(Oe.id,Oe.next),null}catch(_t){return Ge(Oe.id),_t instanceof Error?_t.message:String(_t)}})).then(Oe=>{const _t=Oe.filter(Jt=>Jt!==null),Qt=_t[0];Qt&&(N(_t.length===1?Qt:`${_t.length} node updates failed (first: ${Qt})`),console.error("Tidy: some updateNodePosition calls failed",_t))})}},[ce,J,re,me,C.overrides,Ee,Ge,W,Q]);m.useEffect(()=>{const q=F=>{if(!(F.metaKey||F.ctrlKey)||!F.shiftKey||F.altKey||F.key.toLowerCase()!=="l"||qo(document.activeElement))return;F.preventDefault();const Z=w.current.length>0?"selection":"all";Yn(Z)};return window.addEventListener("keydown",q),()=>window.removeEventListener("keydown",q)},[Yn]);const Rd=m.useCallback(()=>{const q=w.current.length>0?"selection":"all";Yn(q)},[Yn]);m.useEffect(()=>{const q=F=>{if(qo(document.activeElement)||document.querySelector('[data-testid="inline-edit-input"]'))return;const Z=cTe(F);if(Z===null)return;const V=O.current;if(Z==="select"){V.kind!=="select"&&j({kind:"select"});return}if(Z==="hand"){j(V.kind==="hand"?{kind:"select"}:{kind:"hand"});return}if(V.kind==="draw"&&V.shape===Z){j({kind:"select"});return}j({kind:"draw",shape:Z})};return window.addEventListener("keydown",q),()=>window.removeEventListener("keydown",q)},[]),m.useEffect(()=>{const q=F=>{if(F.key!=="Escape"||qo(document.activeElement)||document.querySelector('[data-testid="inline-edit-input"]'))return;if(O.current.kind!=="select"){j({kind:"select"});return}w.current.length>0&&u([]),g.current.length>0&&y([])};return window.addEventListener("keydown",q),()=>window.removeEventListener("keydown",q)},[]),m.useEffect(()=>{const q=F=>{if(F.key.toLowerCase()!=="f"||F.metaKey||F.ctrlKey||F.shiftKey||F.altKey||qo(document.activeElement)||document.querySelector('[data-testid="inline-edit-input"]'))return;const Z=w.current;if(Z.length===0)return;const V=U.current;V&&V.fitView({nodes:Z.map(T=>({id:T})),padding:.2,duration:200})};return window.addEventListener("keydown",q),()=>window.removeEventListener("keydown",q)},[]),m.useEffect(()=>{const q=F=>{if(F.key!=="1"||F.metaKey||F.ctrlKey||F.shiftKey||F.altKey||qo(document.activeElement)||document.querySelector('[data-testid="inline-edit-input"]'))return;const Z=U.current;if(!Z)return;const{x:V,y:T}=Z.getViewport();Z.setViewport({x:V,y:T,zoom:1},{duration:150})};return window.addEventListener("keydown",q),()=>window.removeEventListener("keydown",q)},[]);const ur=m.useCallback(q=>{var F,Z,V;switch(q){case"tool.select":j({kind:"select"});return;case"tool.hand":j({kind:"hand"});return;case"tool.rectangle":j({kind:"draw",shape:"rectangle"});return;case"tool.ellipse":j({kind:"draw",shape:"ellipse"});return;case"tool.text":j({kind:"draw",shape:"text"});return;case"tool.sticky":j({kind:"draw",shape:"sticky"});return;case"tool.database":j({kind:"draw",shape:"database"});return;case"edit.undo":{if(!He)return;(async()=>{try{const T=await Kr();T!=null&&T.entry&&await T.entry.undo()}catch(T){N(T instanceof Error?T.message:String(T)),console.error("undo failed",T)}})();return}case"edit.redo":{if(!gt)return;(async()=>{try{const T=await Xr();T!=null&&T.entry&&await T.entry.do()}catch(T){N(T instanceof Error?T.message:String(T)),console.error("redo failed",T)}})();return}case"edit.copy":{const T=w.current;if(T.length===0)return;Xn([...T]);return}case"edit.paste":Ro(null);return;case"edit.duplicate":{const T=w.current;if(T.length===0)return;Xn([...T]),Ro(null);return}case"edit.delete":{const T=w.current,ie=g.current;if(T.length===0&&ie.length===0)return;$o([...T],[...ie]);return}case"edit.selectAll":u((re??[]).map(T=>T.id)),y((me??[]).map(T=>T.id));return;case"view.fit":{const T=U.current;if(!T)return;T.fitView({padding:.2,duration:200});return}case"view.zoomIn":{const T=U.current;if(!T)return;T.zoomIn({duration:150});return}case"view.zoomOut":{const T=U.current;if(!T)return;T.zoomOut({duration:150});return}case"view.zoom100":{const T=U.current;if(!T)return;const{x:ie,y:Ae}=T.getViewport();T.setViewport({x:ie,y:Ae,zoom:1},{duration:150});return}case"view.zoomToSelection":{const T=w.current;if(T.length===0)return;const ie=U.current;if(!ie)return;ie.fitView({nodes:T.map(Ae=>({id:Ae})),padding:.2,duration:200});return}case"layout.tidy":{const T=w.current.length>0?"selection":"all";Yn(T);return}case"selection.deselect":w.current.length>0&&u([]),g.current.length>0&&y([]),O.current.kind!=="select"&&j({kind:"select"});return;case"help.commandPalette":B(!0);return;case"export.pdf":{(F=b.current)==null||F.exportPdf();return}case"export.png":{(Z=b.current)==null||Z.exportPng();return}case"session.reset":{(V=v.current)==null||V.call(v);return}}},[He,gt,Kr,Xr,Xn,Ro,$o,re,me,Yn]);m.useEffect(()=>{const q=F=>{(F.metaKey||F.ctrlKey)&&(F.shiftKey||F.altKey||F.key.toLowerCase()==="p"&&(F.preventDefault(),!qo(document.activeElement)&&ur("help.commandPalette")))};return window.addEventListener("keydown",q),()=>window.removeEventListener("keydown",q)},[ur]),m.useEffect(()=>{v.current=c??null},[c]);const Qn=m.useCallback((q,F)=>{if(!ce||!J)return;const Z=me==null?void 0:me.find(ie=>ie.id===q),V=Z?{source:Z.source,target:Z.target,sourceHandle:Z.sourceHandle,targetHandle:Z.targetHandle,sourceHandleAutoPicked:Z.sourceHandleAutoPicked,targetHandleAutoPicked:Z.targetHandleAutoPicked,sourcePin:Z.sourcePin??null,targetPin:Z.targetPin??null}:null,T={...F.source!==void 0?{source:F.source}:{},...F.target!==void 0?{target:F.target}:{},...F.sourceHandle!==void 0?{sourceHandle:F.sourceHandle===null?void 0:F.sourceHandle}:{},...F.targetHandle!==void 0?{targetHandle:F.targetHandle===null?void 0:F.targetHandle}:{},...F.sourceHandleAutoPicked!==void 0?{sourceHandleAutoPicked:F.sourceHandleAutoPicked}:{},...F.targetHandleAutoPicked!==void 0?{targetHandleAutoPicked:F.targetHandleAutoPicked}:{},...F.sourcePin!==void 0?{sourcePin:F.sourcePin===null?void 0:F.sourcePin}:{},...F.targetPin!==void 0?{targetPin:F.targetPin===null?void 0:F.targetPin}:{}};if(Qe(q,T),N(null),Q(),V){const ie=V;W({do:async()=>{await J.updateConnector(q,F)},undo:async()=>{await J.updateConnector(q,ie)},coalesceKey:`connector:${q}:reconnect`})}J.updateConnector(q,F).catch(ie=>{ft(q),V&&Y(),N(ie instanceof Error?ie.message:String(ie)),console.error("updateConnector reconnect failed",ie)})},[ce,J,me,Qe,ft,W,Y,Q]),Ra=m.useCallback((q,F,Z)=>{if(!ce||!J)return;const V=me==null?void 0:me.find(Ae=>Ae.id===q),T=V?F==="source"?V.sourcePin:V.targetPin:void 0,ie=F==="source"?"sourcePin":"targetPin";if(Qe(q,{[ie]:Z}),N(null),Q(),V){const Ae={[ie]:T??null};W({do:async()=>{await J.updateConnector(q,{[ie]:Z})},undo:async()=>{await J.updateConnector(q,Ae)},coalesceKey:`connector:${q}:${ie}`})}J.updateConnector(q,{[ie]:Z}).catch(Ae=>{ft(q),V&&Y(),N(Ae instanceof Error?Ae.message:String(Ae)),console.error("updateConnector pin failed",Ae)})},[ce,J,me,Qe,ft,W,Y,Q]),To=m.useCallback((q,F)=>{if(!ce||!J)return;const Z=me==null?void 0:me.find(ie=>ie.id===q),V=Z?F==="source"?Z.sourcePin:Z.targetPin:void 0;if(!V)return;const T=F==="source"?"sourcePin":"targetPin";Qe(q,{[T]:void 0}),N(null),Q(),W({do:async()=>{await J.updateConnector(q,{[T]:null})},undo:async()=>{await J.updateConnector(q,{[T]:V})}}),J.updateConnector(q,{[T]:null}).catch(ie=>{ft(q),Y(),N(ie instanceof Error?ie.message:String(ie)),console.error("updateConnector unpin failed",ie)})},[ce,J,me,Qe,ft,W,Y,Q]),ut=n==null?void 0:n.flow,go=C.overrides,vo=_.overrides,pn=S.ids,hr=A.ids,fr=m.useMemo(()=>{if(!ut||h.length===0)return[];const q=new Map(ut.nodes.map(Z=>[Z.id,Z])),F=[];for(const Z of h){const V=q.get(Z);if(!V)continue;const T=go[Z];if(!T){F.push(V);continue}const ie=T.data?{...V.data,...T.data}:V.data;F.push({...V,...T,data:ie})}return F},[ut,h,go]),Ta=m.useMemo(()=>{if(!ut||f.length===0)return[];const q=new Map(ut.connectors.map(Z=>[Z.id,Z])),F=[];for(const Z of f){const V=q.get(Z);if(!V)continue;const T=vo[Z];F.push(T?{...V,...T}:V)}return F},[ut,f,vo]),Ri=m.useMemo(()=>{if(!ut)return null;if(!P)return ut.nodes;const q=new Map(ut.nodes.map(V=>[V.id,V])),F=[],Z=new Set;for(const V of P){const T=q.get(V);T&&(F.push(T),Z.add(V))}for(const V of ut.nodes)Z.has(V.id)||F.push(V);return F},[ut,P]),lR=m.useMemo(()=>{const q=Ri??(ut==null?void 0:ut.nodes)??null;return q?pn.size===0?q:q.filter(F=>!pn.has(F.id)):null},[Ri,ut,pn]),dR=m.useMemo(()=>{const q=(ut==null?void 0:ut.connectors)??null;return q?hr.size===0&&pn.size===0?q:q.filter(F=>!hr.has(F.id)&&!pn.has(F.source)&&!pn.has(F.target)):null},[ut,hr,pn]);if(!l)return p.jsxs("div",{className:"flex h-full w-full flex-col items-center justify-center gap-2 bg-background p-6 text-center",children:[p.jsxs("p",{className:"text-sm font-medium",children:["Unknown demo: ",e]}),p.jsx("p",{className:"text-xs text-muted-foreground",children:"The slug may have been removed. Re-register from the project repo to bring it back."})]});if(o&&!n)return p.jsx("div",{className:"flex h-full w-full items-center justify-center text-sm text-muted-foreground",children:"Loading demo…"});const yf=h[0],ta=yf?i[yf]:void 0;return p.jsxs("div",{className:"relative h-full w-full",children:[n&&!n.valid?p.jsxs("div",{"data-testid":"demo-error-banner",className:"absolute inset-x-0 top-0 z-10 border-b border-rose-500/40 bg-rose-50 px-4 py-2 text-xs text-rose-900 shadow-xs dark:bg-rose-950/40 dark:text-rose-100",children:[p.jsx("span",{className:"font-medium uppercase tracking-wide",children:"Invalid demo: "}),p.jsx("span",{className:"font-mono",children:n.error})]}):null,ut&&J?p.jsx(Get,{ref:b,mode:"edit",adapter:J,projectId:ce??void 0,enableEmbed:!1,onExportToCloud:ce?()=>rn(!0):void 0,onRestartDemo:c,nodes:lR??ut.nodes,connectors:dR??ut.connectors,selectedNodeIds:h,selectedConnectorIds:f,onSelectionChange:ve,runtime:{runs:r,statuses:i,pendingOverrides:{nodes:go,connectors:vo}},onPlayNode:s,onNodePositionChange:ne,onNodePositionsChange:Ie,onNodeResize:De,onNodeResizeEnd:Ke,onHtmlNodeFitToContent:Bt,onComponentNodeFitToContent:Bt,onMultiResize:bn,onNodeNameChange:Pa,onNodeDescriptionChange:ji,onConnectorLabelChange:zd,onCreateShapeNode:ja,onCreateImageFromFile:ce?$d:void 0,onRetryImageUpload:ce?Pd:void 0,onCreateHtmlNode:ce?Po:void 0,iconPickerOpen:jo.open,onOpenIconPicker:ce?jd:void 0,onCloseIconPicker:ce?lr:void 0,onPickIcon:ce?ea:void 0,onRequestIconReplace:ce?Jr:void 0,onCreateConnector:zi,onReconnectConnector:Qn,onPinEndpoint:ce?Ra:void 0,onUnpinEndpoint:ce?To:void 0,onReorderNode:Ed,onDeleteNode:Ad,onCopyNode:q=>Xn([q]),onPasteAt:Ro,onCopySelection:ce?Xn:void 0,onPasteSelection:ce?()=>Ro(null):void 0,hasClipboard:Sn,selectedNodes:fr,selectedConnectors:Ta,onStyleNode:an,onStyleNodePreview:_n,onStyleNodes:dt,onStyleNodesPreview:Rt,onStyleConnector:Mt,onStyleConnectorPreview:Cn,onRfInit:D,onTidy:re?Rd:void 0,onCreateAndConnectFromPane:za,pendingEditNodeId:k,canvasMode:X,onCanvasModeChange:j,statusReport:ta,onNameChange:Pa,onDescriptionChange:ji,onDetailChange:Yr,onIconChange:sr,autoFitView:!0,autoFitViewSignal:z}):p.jsx("div",{className:"flex h-full w-full items-center justify-center text-sm text-muted-foreground",children:"No demo data yet."}),$?p.jsxs("div",{"data-testid":"edit-error-banner",className:"absolute inset-x-0 bottom-4 z-20 mx-auto w-fit max-w-[80%] rounded-md border border-rose-500/50 bg-rose-50 px-3 py-2 text-xs text-rose-900 shadow-md dark:bg-rose-950/60 dark:text-rose-100",children:[p.jsx("span",{className:"font-medium",children:"Couldn't save change: "}),p.jsx("span",{className:"font-mono",children:$}),p.jsx("button",{type:"button",className:"ml-3 underline underline-offset-2",onClick:()=>N(null),children:"Dismiss"})]}):null,p.jsx(Htt,{open:H,onOpenChange:B,runCommand:ur,ctx:{hasSelection:h.length>0||f.length>0,canUndo:He,canRedo:gt,hasClipboard:Sn,canExportDemo:!!ce,canResetSession:!!c}}),ce?p.jsx(rnt,{open:ln,onOpenChange:rn,projectId:ce,flowName:(n==null?void 0:n.name)??l.name,onCapturePreview:()=>{var q;return((q=b.current)==null?void 0:q.capturePreview())??Promise.resolve(void 0)}}):null]})}const KG="npx seeflow register --path .";function jnt(){const[e,t]=m.useState(!1),n=async()=>{try{await navigator.clipboard.writeText(KG),t(!0),setTimeout(()=>t(!1),1200)}catch(o){console.error("[empty-state] copy failed",o)}};return p.jsx("div",{"data-testid":"seeflow-empty-state",className:"flex h-full w-full items-center justify-center bg-background p-6",children:p.jsxs("div",{className:"flex max-w-lg flex-col items-center gap-6 text-center",children:[p.jsx("div",{className:"flex h-12 w-12 items-center justify-center rounded-full bg-muted",children:p.jsx(att,{className:"h-6 w-6 text-muted-foreground"})}),p.jsxs("div",{className:"space-y-2",children:[p.jsx("h1",{className:"text-2xl font-semibold tracking-tight text-foreground",children:"No demos registered yet"}),p.jsxs("p",{className:"text-sm text-muted-foreground",children:["Point SeeFlow at any folder containing a"," ",p.jsx("code",{className:"rounded bg-muted px-1.5 py-0.5 text-xs",children:"flow.json"})," file and it'll appear here."]})]}),p.jsxs("div",{className:"flex w-full items-center gap-2 rounded-md border border-border bg-card px-3 py-2 font-mono text-sm",children:[p.jsx("span",{className:"text-muted-foreground select-none",children:"$"}),p.jsx("code",{className:"flex-1 truncate text-left",children:KG}),p.jsx(qt,{type:"button",variant:"ghost",size:"sm",onClick:n,"aria-label":"Copy register command",children:e?p.jsx(Doe,{className:"h-4 w-4"}):p.jsx(Hoe,{className:"h-4 w-4"})})]})]})})}function znt({demos:e}){return e.length===0?p.jsx(jnt,{}):p.jsx("div",{className:"flex h-full w-full items-start justify-center overflow-y-auto bg-background p-8",children:p.jsxs("div",{"data-testid":"studio-home-picker",className:"flex w-full max-w-2xl flex-col gap-6 pt-8",children:[p.jsxs("div",{className:"space-y-1",children:[p.jsx("h1",{className:"text-2xl font-semibold tracking-tight",children:"Open a demo"}),p.jsxs("p",{className:"text-sm text-muted-foreground",children:[e.length," demos registered — pick one to load its canvas."]})]}),p.jsx("ul",{className:"flex flex-col gap-2",children:e.map(t=>p.jsx("li",{children:p.jsxs("button",{type:"button",onClick:()=>c0(`/d/${t.slug}`),"data-testid":`studio-home-demo-${t.slug}`,className:"flex w-full flex-col items-start gap-0.5 rounded-lg border border-border bg-card px-4 py-3 text-left transition-colors hover:border-input",style:{boxShadow:"var(--shadow-card)"},children:[p.jsx("span",{className:"text-sm font-medium",children:t.name}),p.jsx("span",{className:"truncate text-xs text-muted-foreground",children:t.repoPath})]})},t.id))})]})})}const Rnt=e=>{if(!e.startsWith("/d/"))return null;const t=e.slice(3);return t.length>0?decodeURIComponent(t):null};function Tnt(){const e=Xet(),{demos:t,refresh:n}=xtt(),o=Rnt(e);Ett({onRegistryReload:n});const r=o?(t??[]).find(A=>A.slug===o):void 0,a=(r==null?void 0:r.id)??null,{detail:i,loading:s,refresh:c,applyDetail:l}=vtt(a),{runs:h,apply:u}=Stt(a),{events:f,apply:y}=_tt(a),{statusByNode:k,apply:x,reset:w}=Att(a),g=m.useCallback(()=>{w(),c(),n()},[c,n,w]),M=m.useCallback(A=>{if(!a||!r)return;const P={id:a,slug:r.slug,filePath:""},I=A.valid?{...P,name:A.flow.name??r.name,flow:A.flow,valid:!0,error:null}:{...P,name:r.name,flow:null,valid:!1,error:A.error};l(I)},[a,r,l]),v=m.useCallback(A=>{u(A),y(A),x(A)},[u,y,x]);$tt(a,{onHello:g,onFlowReload:M,onEvent:v});const b=m.useCallback(async()=>{if(a)try{await cse(a)}catch(A){console.error("Failed to restart demo:",A)}},[a]),C=m.useCallback(A=>{jG(A.id),n()},[n]),_=m.useCallback(async A=>{await n(),a===A&&c0("/")},[n,a]);m.useEffect(()=>{if(e!=="/"||t===null)return;const A=ztt(t,jtt());A&&c0(`/d/${A.slug}`)},[e,t]),m.useEffect(()=>{r&&jG(r.id)},[r]);const S=m.useCallback(A=>{a&&lse(a,A).catch(P=>{u({type:"node:error",nodeId:A,message:P instanceof Error?P.message:String(P),ts:Date.now()})})},[a,u]);return t===null?p.jsx("div",{className:"flex h-full w-full items-center justify-center bg-background text-sm text-muted-foreground",children:"Loading…"}):p.jsx(F2,{delayDuration:150,children:p.jsxs("div",{className:"flex h-full w-full flex-col bg-background text-foreground",children:[p.jsx(gtt,{demos:t,currentSlug:o??void 0,onProjectCreated:C,onProjectUnregistered:_}),p.jsx("main",{className:"min-h-0 flex-1",children:o?p.jsx(Pnt,{slug:o,demos:t,detail:i,loading:s,runs:h,nodeEvents:f,statusByNode:k,onPlayNode:S,onRestartDemo:a?b:void 0}):p.jsx(znt,{demos:t})})]})})}const nre=document.getElementById("root");if(!nre)throw new Error("Root element #root not found");VT.createRoot(nre).render(p.jsx(Ar.StrictMode,{children:p.jsx(Tnt,{})}));export{CXe as M,Ar as R,Iz as _,fX as a,WP as b,eG as c,$r as d,DQe as e,aWe as f,Ah as g,cWe as h,H2 as i,p as j,lWe as k,QO as l,m as r,GUe as s,QUe as w,qnt as z};
8613
+ */const stt=Zr("Workflow",[["rect",{width:"8",height:"8",x:"3",y:"3",rx:"2",key:"by2w9f"}],["path",{d:"M7 11v4a2 2 0 0 0 2 2h4",key:"xkn7yn"}],["rect",{width:"8",height:"8",x:"13",y:"13",rx:"2",key:"1cgmvn"}]]);function ctt({demos:e,currentSlug:t,onProjectCreated:n,onProjectUnregistered:o}){const[r,a]=m.useState(!1),[i,s]=m.useState(!1),[c,l]=m.useState(null),[h,u]=m.useState(!1),[f,y]=m.useState(null);m.useEffect(()=>{const v=b=>{b.key==="k"&&(b.metaKey||b.ctrlKey)&&(b.preventDefault(),a(C=>!C))};return document.addEventListener("keydown",v),()=>document.removeEventListener("keydown",v)},[]);const k=e.find(v=>v.slug===t),x=v=>{n==null||n(v),c0(`/d/${v.slug}`)},w=v=>{l(v),y(null)},g=()=>{h||(l(null),y(null))},M=async()=>{if(c){u(!0),y(null);try{await ise(c.id);const v=c.id;l(null),o==null||o(v)}catch(v){y(v instanceof Error?v.message:String(v))}finally{u(!1)}}};return p.jsxs(p.Fragment,{children:[p.jsxs(w0,{open:r,onOpenChange:a,children:[p.jsx(Gh,{asChild:!0,children:p.jsxs(qt,{type:"button",variant:"outline",size:"sm","aria-label":"Switch demo","aria-expanded":r,className:"gap-2","data-testid":"project-switcher-trigger",children:[p.jsx("span",{className:"max-w-[180px] truncate text-sm",children:(k==null?void 0:k.name)??"Select demo"}),p.jsx(xee,{children:"⌘K"}),p.jsx(ett,{className:"h-3.5 w-3.5 opacity-60"})]})}),p.jsx(Sd,{align:"end",sideOffset:6,className:"w-[320px] p-0","data-testid":"project-switcher-popover",children:p.jsxs(yee,{children:[p.jsx(mee,{placeholder:"Search demos..."}),p.jsxs(kee,{children:[p.jsx(gee,{children:"No demos."}),e.length>0?p.jsx(MH,{heading:"Demos",children:e.map(v=>p.jsxs(bH,{value:`${v.name} ${v.slug}`,onSelect:()=>{a(!1),c0(`/d/${v.slug}`)},className:"group flex items-center justify-between gap-2",children:[p.jsxs("div",{className:"flex min-w-0 flex-col items-start gap-0.5",children:[p.jsx("span",{className:"font-medium",children:v.name}),p.jsx("span",{className:"w-full truncate text-xs text-muted-foreground",children:v.repoPath})]}),p.jsx("button",{type:"button","aria-label":`Unregister ${v.name}`,className:"shrink-0 rounded p-0.5 opacity-0 transition-opacity hover:text-destructive group-hover:opacity-100 focus-visible:opacity-100 focus-visible:outline-hidden focus-visible:ring-1 focus-visible:ring-ring",onClick:b=>{b.stopPropagation(),a(!1),w(v)},children:p.jsx(itt,{className:"h-3.5 w-3.5"})})]},v.id))}):null,e.length>0?p.jsx(vee,{}):null,p.jsx(MH,{children:p.jsxs(bH,{value:"+ create new project",onSelect:()=>{a(!1),s(!0)},"data-testid":"project-switcher-create",className:"flex items-center gap-2 text-sm",children:[p.jsx(ott,{className:"h-4 w-4 opacity-70"}),p.jsx("span",{className:"font-medium",children:"Create new project"})]})})]})]})})]}),p.jsx(Zet,{open:i,onOpenChange:s,onCreated:x}),p.jsx(Wz,{open:c!==null,onOpenChange:v=>{v||g()},children:p.jsxs(ef,{className:"sm:max-w-md","data-testid":"unregister-project-dialog",children:[p.jsxs(tf,{children:[p.jsx(nf,{children:"Unregister project?"}),p.jsxs(of,{children:["This removes ",p.jsx("strong",{children:c==null?void 0:c.name})," from SeeFlow. Your files at"," ",p.jsx("code",{className:"text-xs",children:c==null?void 0:c.repoPath})," will not be deleted."]})]}),f?p.jsx("div",{role:"alert","data-testid":"unregister-project-error",className:"rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-sm text-destructive",children:f}):null,p.jsxs(a0,{children:[p.jsx(qt,{type:"button",variant:"ghost",onClick:g,disabled:h,children:"Cancel"}),p.jsx(qt,{type:"button",variant:"destructive",onClick:M,disabled:h,"data-testid":"unregister-project-confirm",children:h?"Unregistering…":"Unregister"})]})]})})]})}const qoe="seeflow:theme",$G="(prefers-color-scheme: dark)";function ltt(e){return e==="light"||e==="dark"||e==="system"}function dtt(e){try{const t=e.getItem(qoe);return ltt(t)?t:"system"}catch{return"system"}}function utt(e){try{const t=new URLSearchParams(e);if(!t.has("theme"))return null;const n=t.get("theme");return n==="light"||n==="dark"?n:"light"}catch{return null}}function htt(e,t){try{e.setItem(qoe,t)}catch{}}function ftt(e,t){return e==="system"?t?"dark":"light":e}function ptt(e,t){t==="dark"?(e.classList.add("dark"),e.classList.remove("light")):(e.classList.add("light"),e.classList.remove("dark"))}function ytt(e,t){var o;const n=r=>t(r.matches);return e.addEventListener?(e.addEventListener("change",n),()=>{var r;return(r=e.removeEventListener)==null?void 0:r.call(e,"change",n)}):((o=e.addListener)==null||o.call(e,n),()=>{var r;return(r=e.removeListener)==null?void 0:r.call(e,n)})}function mtt(){const[e,t]=m.useState(()=>{if(typeof window>"u")return"system";const i=utt(window.location.search);return i||dtt(window.localStorage)}),[n,o]=m.useState(()=>typeof window>"u"?!1:window.matchMedia($G).matches);m.useEffect(()=>{if(typeof window>"u")return;const i=window.matchMedia($G);return ytt(i,o)},[]);const r=ftt(e,n);m.useEffect(()=>{typeof document>"u"||ptt(document.documentElement,r)},[r]);const a=m.useCallback(i=>{typeof window<"u"&&htt(window.localStorage,i),t(i)},[]);return{theme:e,setTheme:a,resolvedTheme:r}}const ktt=[{value:"light",label:"Light"},{value:"dark",label:"Dark"},{value:"system",label:"System"}];function gtt({demos:e,currentSlug:t,onProjectCreated:n,onProjectUnregistered:o}){const{theme:r,setTheme:a}=mtt();return p.jsxs("header",{className:"relative flex h-14 shrink-0 items-center justify-between bg-background/85 px-5 backdrop-blur-md shadow-[0_1px_3px_-1px_rgba(15,23,42,0.06),0_2px_8px_-4px_rgba(15,23,42,0.05)] dark:border-b dark:border-border/60 dark:shadow-[0_4px_12px_-6px_rgba(0,0,0,0.6)]",children:[p.jsxs("button",{type:"button",onClick:()=>c0("/"),className:"-ml-1.5 flex items-center gap-2 rounded-md px-1.5 py-1 text-base font-bold tracking-tight transition-colors hover:bg-muted/60",children:[p.jsx(stt,{size:18,strokeWidth:2.25,className:"text-emerald-400"}),"SeeFlow",p.jsxs("span",{className:"ml-1 text-[10px] font-normal tracking-normal text-muted-foreground/70",children:["v","0.1.74"]})]}),p.jsxs("div",{className:"flex items-center gap-3",children:[p.jsx(ctt,{demos:e,currentSlug:t,onProjectCreated:n,onProjectUnregistered:o}),p.jsxs(Fte,{children:[p.jsx(Vte,{asChild:!0,children:p.jsx(qt,{type:"button",variant:"outline",size:"icon","aria-label":"Settings","data-testid":"settings-trigger",children:p.jsx(rtt,{className:"h-4 w-4"})})}),p.jsxs(GO,{align:"end",sideOffset:6,className:"w-44","data-testid":"settings-menu",children:[p.jsx(Bte,{children:"Theme"}),p.jsx(lUe,{value:r,onValueChange:i=>a(i),children:ktt.map(i=>p.jsx(Ute,{value:i.value,"data-testid":`theme-${i.value}`,children:i.label},i.value))})]})]})]})]})}const vtt=e=>{const[t,n]=m.useState(null),[o,r]=m.useState(e!==null),[a,i]=m.useState(null),s=m.useCallback(()=>{e&&(r(!0),cX(e).then(l=>{n(l),i(null)}).catch(l=>{console.error("[useDemoData] failed",l),i(String(l))}).finally(()=>r(!1)))},[e]),c=m.useCallback(l=>{n(l),i(null)},[]);return m.useEffect(()=>{if(!e){n(null),r(!1);return}s()},[e,s]),{detail:t,loading:o,error:a,refresh:s,applyDetail:c}},xtt=()=>{const[e,t]=m.useState(null),[n,o]=m.useState(null),r=m.useCallback(()=>ase().then(a=>{t(a),o(null)}).catch(a=>{console.error("[useDemos] failed",a),t([]),o(String(a))}),[]);return m.useEffect(()=>{r()},[r]),{demos:e,error:n,refresh:r}},wtt=5,Mtt={"node:running":"running","node:done":"done","node:error":"error"},btt=(e,t)=>{if(t.type==="reset")return{};const n=e[t.nodeId]??[],o=[t.entry,...n].slice(0,wtt);return{...e,[t.nodeId]:o}},_tt=e=>{const[t,n]=m.useReducer(btt,{}),o=m.useRef(n);o.current=n,m.useEffect(()=>{o.current({type:"reset"})},[e]);const r=m.useCallback(i=>{const s=Mtt[i.type];if(!s)return;const c=typeof i.nodeId=="string"?i.nodeId:null;if(!c)return;const l=typeof i.runId=="string"?i.runId:void 0,h=typeof i.ts=="number"?i.ts:Date.now();o.current({type:"append",nodeId:c,entry:{status:s,ts:h,runId:l}})},[]),a=m.useCallback(()=>{o.current({type:"reset"})},[]);return{events:t,apply:r,reset:a}},Ctt=(e,t)=>{var n,o;switch(t.type){case"reset":return{};case"running":return{...e,[t.nodeId]:{status:"running",runId:t.runId,ts:t.ts??Date.now()}};case"done":return{...e,[t.nodeId]:{...e[t.nodeId],status:"done",runId:t.runId??((n=e[t.nodeId])==null?void 0:n.runId),responseStatus:t.responseStatus,body:t.body,ts:t.ts??Date.now()}};case"error":return{...e,[t.nodeId]:{...e[t.nodeId],status:"error",runId:t.runId??((o=e[t.nodeId])==null?void 0:o.runId),error:t.message,ts:t.ts??Date.now()}}}},Stt=e=>{const[t,n]=m.useReducer(Ctt,{}),o=m.useRef(n);o.current=n,m.useEffect(()=>{o.current({type:"reset"})},[e]);const r=m.useCallback(i=>{const s=typeof i.nodeId=="string"?i.nodeId:null;if(!s)return;const c=typeof i.runId=="string"?i.runId:void 0;if(i.type==="node:running"){o.current({type:"running",nodeId:s,runId:c,ts:i.ts});return}if(i.type==="node:done"){const l=typeof i.status=="number"?i.status:void 0;o.current({type:"done",nodeId:s,runId:c,responseStatus:l,body:i.body,ts:i.ts});return}if(i.type==="node:error"){const l=typeof i.message=="string"?i.message:void 0;o.current({type:"error",nodeId:s,runId:c,message:l,ts:i.ts})}},[]),a=m.useCallback(()=>{o.current({type:"reset"})},[]);return{runs:t,apply:r,reset:a}},Ltt=new Set(["ok","warn","error","pending"]),Itt=(e,t)=>{if(t.type!=="node:status")return e;const n=typeof t.nodeId=="string"?t.nodeId:null;if(!n||typeof t.state!="string"||!Ltt.has(t.state))return e;const o=typeof t.summary=="string"?t.summary:void 0,r=typeof t.detail=="string"?t.detail:void 0,a=t.data&&typeof t.data=="object"&&!Array.isArray(t.data)?t.data:void 0,i=typeof t.ts=="number"?t.ts:Date.now();return{...e,[n]:{state:t.state,summary:o,detail:r,data:a,ts:i}}},Ntt=(e,t)=>{switch(t.type){case"reset":return{};case"event":return Itt(e,t.event)}},Att=e=>{const[t,n]=m.useReducer(Ntt,{}),o=m.useRef(n);o.current=n,m.useEffect(()=>{o.current({type:"reset"})},[e]);const r=m.useCallback(i=>{o.current({type:"event",event:i})},[]),a=m.useCallback(()=>{o.current({type:"reset"})},[]);return{statusByNode:t,apply:r,reset:a}},Ett=(e={})=>{const[t,n]=m.useState(!1),{onRegistryReload:o,onHello:r}=e,a=m.useRef(o),i=m.useRef(r);return m.useEffect(()=>{a.current=o,i.current=r},[o,r]),m.useEffect(()=>{const s=new EventSource("/api/registry/events");return s.addEventListener("open",()=>n(!0)),s.addEventListener("error",()=>n(!1)),s.addEventListener("hello",()=>{var c;(c=i.current)==null||c.call(i)}),s.addEventListener("registry:reload",()=>{var c;(c=a.current)==null||c.call(a)}),()=>{s.close()}},[]),{connected:t}},$tt=(e,t={})=>{const[n,o]=m.useState(!1),{onHello:r,onFlowReload:a,onEvent:i}=t,s=m.useRef(r),c=m.useRef(a),l=m.useRef(i);return m.useEffect(()=>{s.current=r,c.current=a,l.current=i},[r,a,i]),m.useEffect(()=>{if(!e){o(!1);return}const h=`/api/events?flowId=${encodeURIComponent(e)}`,u=new EventSource(h);u.addEventListener("open",()=>o(!0)),u.addEventListener("error",()=>o(!1)),u.addEventListener("hello",()=>{var f;(f=s.current)==null||f.call(s)}),u.addEventListener("flow:reload",f=>{var x,w;const y=PG(f,"flow:reload");(x=l.current)==null||x.call(l,y);const k=Ptt(y);k&&((w=c.current)==null||w.call(c,k))});for(const f of["node:running","node:done","node:error","node:status"])u.addEventListener(f,y=>{var k;(k=l.current)==null||k.call(l,PG(y,f))});return()=>{u.close()}},[e]),{connected:n}},PG=(e,t)=>{try{const n=JSON.parse(e.data);return{type:t,ts:Date.now(),...n}}catch{return{type:t,ts:Date.now()}}},Ptt=e=>e.valid===!0&&e.flow&&typeof e.flow=="object"?{valid:!0,flow:e.flow}:e.valid===!1&&typeof e.error=="string"?{valid:!1,error:e.error}:null,Ooe="seeflow:last-project",jtt=()=>{if(typeof window>"u")return null;try{return window.localStorage.getItem(Ooe)}catch{return null}},jG=e=>{if(!(typeof window>"u"))try{window.localStorage.setItem(Ooe,e)}catch{}},ztt=(e,t)=>{if(e.length===0)return null;if(e.length===1)return e[0]??null;if(t){const n=e.find(o=>o.id===t);if(n)return n}return null},zG=["File","Edit","View","Tools","Layout","Selection","Help"],Foe="seeflow:command-palette:recent",Voe=5,Boe=new Map(lO.map(e=>[e.id,e])),Rtt=e=>typeof e=="string"&&Boe.has(e),RG=()=>{if(typeof window>"u")return[];try{const e=window.localStorage.getItem(Foe);if(!e)return[];const t=JSON.parse(e);return Array.isArray(t)?t.filter(Rtt).slice(0,Voe):[]}catch{return[]}},Ttt=e=>{if(!(typeof window>"u"))try{window.localStorage.setItem(Foe,JSON.stringify(e))}catch{}},TG=(e,t)=>e.enabled?e.enabled(t):!0,Dtt=(e,t)=>t.length===0?!0:`${e.label} ${e.description??""}`.toLowerCase().includes(t);function Htt({open:e,onOpenChange:t,runCommand:n,ctx:o}){const[r,a]=m.useState(""),[i,s]=m.useState(0),[c,l]=m.useState(()=>RG()),h=m.useRef(null),u=m.useRef(null);m.useEffect(()=>{e&&(a(""),s(0),l(RG()))},[e]);const{groups:f,flat:y}=m.useMemo(()=>{const b=r.trim().toLowerCase();if(b.length===0){if(c.length===0)return{groups:[],flat:[]};const P=[];for(const $ of c){const N=Boe.get($);N&&P.push({cmd:N,enabled:TG(N,o)})}return{groups:[{category:"Recent",rows:P}],flat:P}}const C=new Map;for(const P of lO){if(!Dtt(P,b))continue;const I={cmd:P,enabled:TG(P,o)},$=C.get(P.category);$?$.push(I):C.set(P.category,[I])}const S=[...zG.filter(P=>C.has(P)),...Array.from(C.keys()).filter(P=>!zG.includes(P))].map(P=>({category:P,rows:C.get(P)??[]})),A=S.flatMap(P=>P.rows);return{groups:S,flat:A}},[r,o,c]);m.useEffect(()=>{if(y.length===0){s(0);return}s(b=>{var _;let C=b;if(C>=y.length&&(C=0),!((_=y[C])!=null&&_.enabled)){const S=y.findIndex(A=>A.enabled);S!==-1&&(C=S)}return C})},[y]);const k=m.useCallback(b=>{y.length!==0&&s(C=>{var S;let _=C;for(let A=0;A<y.length;A++)if(_=(_+b+y.length)%y.length,(S=y[_])!=null&&S.enabled)return _;return C})},[y]),x=m.useCallback(b=>{l(C=>{const _=[b,...C.filter(S=>S!==b)].slice(0,Voe);return Ttt(_),_})},[]),w=m.useCallback(b=>{const C=y[b];!C||!C.enabled||(x(C.cmd.id),n(C.cmd.id),t(!1))},[y,t,x,n]),g=m.useCallback(b=>{if(b.key==="ArrowDown"){b.preventDefault(),k(1);return}if(b.key==="ArrowUp"){b.preventDefault(),k(-1);return}b.key==="Enter"&&(b.preventDefault(),w(i))},[w,i,k]);m.useEffect(()=>{if(!e)return;const b=u.current;if(!b)return;const C=b.querySelector(`[data-command-row-index="${i}"]`);C&&typeof C.scrollIntoView=="function"&&C.scrollIntoView({block:"nearest"})},[i,e]);const v=r.trim().length>0;return p.jsx(Oz,{open:e,onOpenChange:t,children:p.jsx(Fz,{children:p.jsxs(M0,{className:ae("fixed left-0 right-0 top-[20%] z-50 mx-auto w-[480px] max-w-[90vw] border border-border bg-card 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","sm:rounded-lg"),"data-testid":"command-palette",onOpenAutoFocus:b=>{var C;b.preventDefault(),(C=h.current)==null||C.focus()},children:[p.jsx("div",{className:ae("border-b",y.length===0&&!v&&"border-b-0"),children:p.jsx("input",{ref:h,type:"text",value:r,onChange:b=>a(b.target.value),onKeyDown:g,placeholder:"Type a command…","data-testid":"command-palette-input","aria-label":"Search commands",autoComplete:"off",spellCheck:!1,className:"w-full bg-transparent px-4 py-3 text-sm outline-hidden placeholder:text-muted-foreground"})}),p.jsx("div",{ref:u,"data-testid":"command-palette-list","data-empty":y.length===0?"true":"false",className:ae("max-h-[50vh] overflow-y-auto",y.length>0?"py-1":"","seeflow-no-scrollbar"),children:y.length===0?v?p.jsxs("div",{"data-testid":"command-palette-empty",className:"px-4 py-6 text-center text-sm text-muted-foreground",children:['No commands match "',r,'"']}):null:(()=>{let b=-1;return f.map(C=>p.jsxs("div",{className:"py-1",children:[p.jsx("div",{className:"px-3 pb-1 pt-2 text-xs font-medium uppercase tracking-wide text-muted-foreground",children:C.category}),C.rows.map(_=>{b+=1;const S=b,A=S===i;return p.jsxs("button",{type:"button","data-testid":`command-palette-row-${_.cmd.id}`,"data-command-row-index":S,"data-highlighted":A?"true":"false","aria-disabled":_.enabled?void 0:!0,disabled:!_.enabled,onMouseEnter:()=>{_.enabled&&s(S)},onClick:()=>w(S),className:ae("flex w-full items-center justify-between gap-3 px-3 py-2 text-left text-sm outline-hidden",_.enabled?"cursor-pointer text-foreground hover:bg-muted":"cursor-not-allowed text-muted-foreground/50",A&&_.enabled?"bg-muted":""),children:[p.jsxs("div",{className:"flex min-w-0 flex-col",children:[p.jsx("span",{className:"truncate font-medium",children:_.cmd.label}),_.cmd.description?p.jsx("span",{className:"truncate text-xs text-muted-foreground",children:_.cmd.description}):null]}),_.cmd.shortcut?p.jsx("kbd",{"data-testid":`command-palette-shortcut-${_.cmd.id}`,className:"shrink-0 rounded border bg-muted px-1.5 py-0.5 font-mono text-[11px] text-muted-foreground",children:_.cmd.shortcut}):null]},_.cmd.id)})]},C.category))})()})]})})})}var wn=Uint8Array,co=Uint16Array,gF=Int32Array,vF=new wn([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),xF=new wn([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),DG=new wn([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Uoe=function(e,t){for(var n=new co(31),o=0;o<31;++o)n[o]=t+=1<<e[o-1];for(var r=new gF(n[30]),o=1;o<30;++o)for(var a=n[o];a<n[o+1];++a)r[a]=a-n[o]<<5|o;return{b:n,r}},Woe=Uoe(vF,2),qtt=Woe.b,UH=Woe.r;qtt[28]=258,UH[258]=28;var Ott=Uoe(xF,0),HG=Ott.r,WH=new co(32768);for(var Lt=0;Lt<32768;++Lt){var Ka=(Lt&43690)>>1|(Lt&21845)<<1;Ka=(Ka&52428)>>2|(Ka&13107)<<2,Ka=(Ka&61680)>>4|(Ka&3855)<<4,WH[Lt]=((Ka&65280)>>8|(Ka&255)<<8)>>1}var Z2=function(e,t,n){for(var o=e.length,r=0,a=new co(t);r<o;++r)e[r]&&++a[e[r]-1];var i=new co(t);for(r=1;r<t;++r)i[r]=i[r-1]+a[r-1]<<1;var s;if(n){s=new co(1<<t);var c=15-t;for(r=0;r<o;++r)if(e[r])for(var l=r<<4|e[r],h=t-e[r],u=i[e[r]-1]++<<h,f=u|(1<<h)-1;u<=f;++u)s[WH[u]>>c]=l}else for(s=new co(o),r=0;r<o;++r)e[r]&&(s[r]=WH[i[e[r]-1]++]>>15-e[r]);return s},Md=new wn(288);for(var Lt=0;Lt<144;++Lt)Md[Lt]=8;for(var Lt=144;Lt<256;++Lt)Md[Lt]=9;for(var Lt=256;Lt<280;++Lt)Md[Lt]=7;for(var Lt=280;Lt<288;++Lt)Md[Lt]=8;var Yj=new wn(32);for(var Lt=0;Lt<32;++Lt)Yj[Lt]=5;var Ftt=Z2(Md,9,0),Vtt=Z2(Yj,5,0),Goe=function(e){return(e+7)/8|0},Zoe=function(e,t,n){return(n==null||n>e.length)&&(n=e.length),new wn(e.subarray(t,n))},Btt=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],cR=function(e,t,n){var o=new Error(t||Btt[e]);if(o.code=e,Error.captureStackTrace&&Error.captureStackTrace(o,cR),!n)throw o;return o},ca=function(e,t,n){n<<=t&7;var o=t/8|0;e[o]|=n,e[o+1]|=n>>8},Z0=function(e,t,n){n<<=t&7;var o=t/8|0;e[o]|=n,e[o+1]|=n>>8,e[o+2]|=n>>16},FT=function(e,t){for(var n=[],o=0;o<e.length;++o)e[o]&&n.push({s:o,f:e[o]});var r=n.length,a=n.slice();if(!r)return{t:Xoe,l:0};if(r==1){var i=new wn(n[0].s+1);return i[n[0].s]=1,{t:i,l:1}}n.sort(function(C,_){return C.f-_.f}),n.push({s:-1,f:25001});var s=n[0],c=n[1],l=0,h=1,u=2;for(n[0]={s:-1,f:s.f+c.f,l:s,r:c};h!=r-1;)s=n[n[l].f<n[u].f?l++:u++],c=n[l!=h&&n[l].f<n[u].f?l++:u++],n[h++]={s:-1,f:s.f+c.f,l:s,r:c};for(var f=a[0].s,o=1;o<r;++o)a[o].s>f&&(f=a[o].s);var y=new co(f+1),k=GH(n[h-1],y,0);if(k>t){var o=0,x=0,w=k-t,g=1<<w;for(a.sort(function(_,S){return y[S.s]-y[_.s]||_.f-S.f});o<r;++o){var M=a[o].s;if(y[M]>t)x+=g-(1<<k-y[M]),y[M]=t;else break}for(x>>=w;x>0;){var v=a[o].s;y[v]<t?x-=1<<t-y[v]++-1:++o}for(;o>=0&&x;--o){var b=a[o].s;y[b]==t&&(--y[b],++x)}k=t}return{t:new wn(y),l:k}},GH=function(e,t,n){return e.s==-1?Math.max(GH(e.l,t,n+1),GH(e.r,t,n+1)):t[e.s]=n},qG=function(e){for(var t=e.length;t&&!e[--t];);for(var n=new co(++t),o=0,r=e[0],a=1,i=function(c){n[o++]=c},s=1;s<=t;++s)if(e[s]==r&&s!=t)++a;else{if(!r&&a>2){for(;a>138;a-=138)i(32754);a>2&&(i(a>10?a-11<<5|28690:a-3<<5|12305),a=0)}else if(a>3){for(i(r),--a;a>6;a-=6)i(8304);a>2&&(i(a-3<<5|8208),a=0)}for(;a--;)i(r);a=1,r=e[s]}return{c:n.subarray(0,o),n:t}},K0=function(e,t){for(var n=0,o=0;o<t.length;++o)n+=e[o]*t[o];return n},Koe=function(e,t,n){var o=n.length,r=Goe(t+2);e[r]=o&255,e[r+1]=o>>8,e[r+2]=e[r]^255,e[r+3]=e[r+1]^255;for(var a=0;a<o;++a)e[r+a+4]=n[a];return(r+4+o)*8},OG=function(e,t,n,o,r,a,i,s,c,l,h){ca(t,h++,n),++r[256];for(var u=FT(r,15),f=u.t,y=u.l,k=FT(a,15),x=k.t,w=k.l,g=qG(f),M=g.c,v=g.n,b=qG(x),C=b.c,_=b.n,S=new co(19),A=0;A<M.length;++A)++S[M[A]&31];for(var A=0;A<C.length;++A)++S[C[A]&31];for(var P=FT(S,7),I=P.t,$=P.l,N=19;N>4&&!I[DG[N-1]];--N);var X=l+5<<3,j=K0(r,Md)+K0(a,Yj)+i,O=K0(r,f)+K0(a,x)+i+14+3*N+K0(S,I)+2*S[16]+3*S[17]+7*S[18];if(c>=0&&X<=j&&X<=O)return Koe(t,h,e.subarray(c,c+l));var H,B,z,R;if(ca(t,h,1+(O<j)),h+=2,O<j){H=Z2(f,y,0),B=f,z=Z2(x,w,0),R=x;var L=Z2(I,$,0);ca(t,h,v-257),ca(t,h+5,_-1),ca(t,h+10,N-4),h+=14;for(var A=0;A<N;++A)ca(t,h+3*A,I[DG[A]]);h+=3*N;for(var U=[M,C],D=0;D<2;++D)for(var E=U[D],A=0;A<E.length;++A){var W=E[A]&31;ca(t,h,L[W]),h+=I[W],W>15&&(ca(t,h,E[A]>>5&127),h+=E[A]>>12)}}else H=Ftt,B=Md,z=Vtt,R=Yj;for(var A=0;A<s;++A){var Y=o[A];if(Y>255){var W=Y>>18&31;Z0(t,h,H[W+257]),h+=B[W+257],W>7&&(ca(t,h,Y>>23&31),h+=vF[W]);var Q=Y&31;Z0(t,h,z[Q]),h+=R[Q],Q>3&&(Z0(t,h,Y>>5&8191),h+=xF[Q])}else Z0(t,h,H[Y]),h+=B[Y]}return Z0(t,h,H[256]),h+B[256]},Utt=new gF([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),Xoe=new wn(0),Wtt=function(e,t,n,o,r,a){var i=a.z||e.length,s=new wn(o+i+5*(1+Math.ceil(i/7e3))+r),c=s.subarray(o,s.length-r),l=a.l,h=(a.r||0)&7;if(t){h&&(c[0]=a.r>>3);for(var u=Utt[t-1],f=u>>13,y=u&8191,k=(1<<n)-1,x=a.p||new co(32768),w=a.h||new co(k+1),g=Math.ceil(n/3),M=2*g,v=function(re){return(e[re]^e[re+1]<<g^e[re+2]<<M)&k},b=new gF(25e3),C=new co(288),_=new co(32),S=0,A=0,P=a.i||0,I=0,$=a.w||0,N=0;P+2<i;++P){var X=v(P),j=P&32767,O=w[X];if(x[j]=O,w[X]=j,$<=P){var H=i-P;if((S>7e3||I>24576)&&(H>423||!l)){h=OG(e,c,0,b,C,_,A,I,N,P-N,h),I=S=A=0,N=P;for(var B=0;B<286;++B)C[B]=0;for(var B=0;B<30;++B)_[B]=0}var z=2,R=0,L=y,U=j-O&32767;if(H>2&&X==v(P-U))for(var D=Math.min(f,H)-1,E=Math.min(32767,P),W=Math.min(258,H);U<=E&&--L&&j!=O;){if(e[P+z]==e[P+z-U]){for(var Y=0;Y<W&&e[P+Y]==e[P+Y-U];++Y);if(Y>z){if(z=Y,R=U,Y>D)break;for(var Q=Math.min(U,Y-2),oe=0,B=0;B<Q;++B){var te=P-U+B&32767,se=x[te],we=te-se&32767;we>oe&&(oe=we,O=te)}}}j=O,O=x[j],U+=j-O&32767}if(R){b[I++]=268435456|UH[z]<<18|HG[R];var ke=UH[z]&31,ge=HG[R]&31;A+=vF[ke]+xF[ge],++C[257+ke],++_[ge],$=P+z,++S}else b[I++]=e[P],++C[e[P]]}}for(P=Math.max(P,$);P<i;++P)b[I++]=e[P],++C[e[P]];h=OG(e,c,l,b,C,_,A,I,N,P-N,h),l||(a.r=h&7|c[h/8|0]<<3,h-=7,a.h=w,a.p=x,a.i=P,a.w=$)}else{for(var P=a.w||0;P<i+l;P+=65535){var ve=P+65535;ve>=i&&(c[h/8|0]=l,ve=i),h=Koe(c,h+1,e.subarray(P,ve))}a.i=i}return Zoe(s,0,o+Goe(h)+r)},Gtt=function(){for(var e=new Int32Array(256),t=0;t<256;++t){for(var n=t,o=9;--o;)n=(n&1&&-306674912)^n>>>1;e[t]=n}return e}(),Ztt=function(){var e=-1;return{p:function(t){for(var n=e,o=0;o<t.length;++o)n=Gtt[n&255^t[o]]^n>>>8;e=n},d:function(){return~e}}},Yoe=function(){var e=1,t=0;return{p:function(n){for(var o=e,r=t,a=n.length|0,i=0;i!=a;){for(var s=Math.min(i+2655,a);i<s;++i)r+=o+=n[i];o=(o&65535)+15*(o>>16),r=(r&65535)+15*(r>>16)}e=o,t=r},d:function(){return e%=65521,t%=65521,(e&255)<<24|(e&65280)<<8|(t&255)<<8|t>>8}}},Qoe=function(e,t,n,o,r){if(!r&&(r={l:1},t.dictionary)){var a=t.dictionary.subarray(-32768),i=new wn(a.length+e.length);i.set(a),i.set(e,a.length),e=i,r.w=a.length}return Wtt(e,t.level==null?6:t.level,t.mem==null?r.l?Math.ceil(Math.max(8,Math.min(13,Math.log(e.length)))*1.5):20:12+t.mem,n,o,r)},Joe=function(e,t){var n={};for(var o in e)n[o]=e[o];for(var o in t)n[o]=t[o];return n},tn=function(e,t,n){for(;n;++t)e[t]=n,n>>>=8},Ktt=function(e,t){var n=t.level,o=n==0?0:n<6?1:n==9?3:2;if(e[0]=120,e[1]=o<<6|(t.dictionary&&32),e[1]|=31-(e[0]<<8|e[1])%31,t.dictionary){var r=Yoe();r.p(t.dictionary),tn(e,2,r.d())}};function Xtt(e,t){return Qoe(e,t||{},0,0)}function qnt(e,t){t||(t={});var n=Yoe();n.p(e);var o=Qoe(e,t,t.dictionary?6:2,4);return Ktt(o,t),tn(o,o.length-4,n.d()),o}var ere=function(e,t,n,o){for(var r in e){var a=e[r],i=t+r,s=o;Array.isArray(a)&&(s=Joe(o,a[1]),a=a[0]),a instanceof wn?n[i]=[a,s]:(n[i+="/"]=[new wn(0),s],ere(a,i,n,o))}},FG=typeof TextEncoder<"u"&&new TextEncoder,Ytt=typeof TextDecoder<"u"&&new TextDecoder,Qtt=0;try{Ytt.decode(Xoe,{stream:!0}),Qtt=1}catch{}function ZH(e,t){var n;if(FG)return FG.encode(e);for(var o=e.length,r=new wn(e.length+(e.length>>1)),a=0,i=function(l){r[a++]=l},n=0;n<o;++n){if(a+5>r.length){var s=new wn(a+8+(o-n<<1));s.set(r),r=s}var c=e.charCodeAt(n);c<128||t?i(c):c<2048?(i(192|c>>6),i(128|c&63)):c>55295&&c<57344?(c=65536+(c&1047552)|e.charCodeAt(++n)&1023,i(240|c>>18),i(128|c>>12&63),i(128|c>>6&63),i(128|c&63)):(i(224|c>>12),i(128|c>>6&63),i(128|c&63))}return Zoe(r,0,a)}var KH=function(e){var t=0;if(e)for(var n in e){var o=e[n].length;o>65535&&cR(9),t+=o+4}return t},VG=function(e,t,n,o,r,a,i,s){var c=o.length,l=n.extra,h=s&&s.length,u=KH(l);tn(e,t,i!=null?33639248:67324752),t+=4,i!=null&&(e[t++]=20,e[t++]=n.os),e[t]=20,t+=2,e[t++]=n.flag<<1|(a<0&&8),e[t++]=r&&8,e[t++]=n.compression&255,e[t++]=n.compression>>8;var f=new Date(n.mtime==null?Date.now():n.mtime),y=f.getFullYear()-1980;if((y<0||y>119)&&cR(10),tn(e,t,y<<25|f.getMonth()+1<<21|f.getDate()<<16|f.getHours()<<11|f.getMinutes()<<5|f.getSeconds()>>1),t+=4,a!=-1&&(tn(e,t,n.crc),tn(e,t+4,a<0?-a-2:a),tn(e,t+8,n.size)),tn(e,t+12,c),tn(e,t+14,u),t+=16,i!=null&&(tn(e,t,h),tn(e,t+6,n.attrs),tn(e,t+10,i),t+=14),e.set(o,t),t+=c,u)for(var k in l){var x=l[k],w=x.length;tn(e,t,+k),tn(e,t+2,w),e.set(x,t+4),t+=4+w}return h&&(e.set(s,t),t+=h),t},Jtt=function(e,t,n,o,r){tn(e,t,101010256),tn(e,t+8,n),tn(e,t+10,n),tn(e,t+12,o),tn(e,t+16,r)};function ent(e,t){t||(t={});var n={},o=[];ere(e,"",n,t);var r=0,a=0;for(var i in n){var s=n[i],c=s[0],l=s[1],h=l.level==0?0:8,u=ZH(i),f=u.length,y=l.comment,k=y&&ZH(y),x=k&&k.length,w=KH(l.extra);f>65535&&cR(11);var g=h?Xtt(c,l):c,M=g.length,v=Ztt();v.p(c),o.push(Joe(l,{size:c.length,crc:v.d(),c:g,f:u,m:k,u:f!=i.length||k&&y.length!=x,o:r,compression:h})),r+=30+f+w+M,a+=76+2*(f+w)+(x||0)+M}for(var b=new wn(a+22),C=r,_=a-r,S=0;S<o.length;++S){var u=o[S];VG(b,u.o,u,u.f,u.u,u.c.length);var A=30+u.f.length+KH(u.extra);b.set(u.c,u.o+A),VG(b,r,u,u.f,u.u,u.c.length,u.o,u.m),r+=16+A+(u.m?u.m.length:0)}return Jtt(b,r,o.length,_,C),b}const tnt="https://seeflow.dev/api";async function nnt(e,t,n,o,r){const a=await cX(e);if(!a.flow)throw new Error("Flow has no data");const i=a.flow,s=new Set,c=[];for(const k of i.nodes)k.type==="image"&&k.data.path&&!s.has(k.data.path)&&(s.add(k.data.path),c.push(k.data.path));const h={[o==="link"?"flow.private.json":"flow.json"]:ZH(JSON.stringify(i))};if(r){const k=r.split(",")[1];k&&(h["preview.png"]=Uint8Array.from(atob(k),x=>x.charCodeAt(0)))}for(const k of c){const x=await fetch(`/api/projects/${encodeURIComponent(e)}/files/${k}`);x.ok&&(h[`files/${k}`]=new Uint8Array(await x.arrayBuffer()))}const u=ent(h),f=await fetch(`${tnt}/flows?email=${encodeURIComponent(t)}&name=${encodeURIComponent(n)}`,{method:"POST",headers:{"content-type":"application/zip"},body:u.buffer});if(!f.ok)throw new Error(`Export failed with status ${f.status}`);const y=await f.json();if(typeof y.url!="string")throw new Error("Invalid response from cloud API: missing url");return{shareUrl:y.url}}function ont(e){return m.useCallback((t,n,o,r)=>nnt(e,t,n,o,r),[e])}const BG="seeflow.export.email",UG="seeflow.export.name",WG="seeflow.export.visibility";function rnt({open:e,onOpenChange:t,projectId:n,flowName:o,onCapturePreview:r}){const[a,i]=m.useState(""),[s,c]=m.useState(""),[l,h]=m.useState("public"),[u,f]=m.useState({kind:"idle"}),[y,k]=m.useState(!1),x=ont(n);m.useEffect(()=>{e&&(i(localStorage.getItem(BG)??""),c(o??localStorage.getItem(UG)??""),h(localStorage.getItem(WG)??"public"),f({kind:"idle"}),k(!1))},[e,o]);const w=m.useCallback(async()=>{f({kind:"loading"});try{const b=await(r==null?void 0:r()),{shareUrl:C}=await x(a.trim(),s.trim(),l,b);localStorage.setItem(BG,a.trim()),localStorage.setItem(UG,s.trim()),localStorage.setItem(WG,l),f({kind:"done",shareUrl:C})}catch(b){f({kind:"error",message:b instanceof Error?b.message:String(b)})}},[x,a,s,l,r]),g=m.useCallback(async()=>{if(u.kind==="done")try{await navigator.clipboard.writeText(u.shareUrl),k(!0),setTimeout(()=>k(!1),2e3)}catch(b){console.error("Failed to copy to clipboard:",b)}},[u]),M=u.kind==="loading",v=a.trim().length>0&&s.trim().length>0;return p.jsx(Wz,{open:e,onOpenChange:t,children:p.jsxs(ef,{className:"sm:max-w-md","data-testid":"export-dialog",onOpenAutoFocus:b=>{b.preventDefault();const C=document.querySelector('[data-testid="export-email-input"]');C==null||C.focus()},children:[p.jsxs(tf,{children:[p.jsx(nf,{children:"Export to seeflow.dev"}),p.jsx(of,{children:"Upload this diagram to the cloud and get a shareable link."})]}),u.kind!=="done"?p.jsxs(p.Fragment,{children:[p.jsxs("div",{className:"flex flex-col gap-4",children:[p.jsxs("label",{className:"flex flex-col gap-1.5 text-sm",children:[p.jsx("span",{className:"font-medium",children:"Email"}),p.jsx("input",{type:"email",required:!0,autoComplete:"email",value:a,onChange:b=>i(b.target.value),disabled:M,"data-testid":"export-email-input",className:"rounded-md border bg-background px-3 py-2 text-sm outline-hidden ring-offset-background focus:border-ring focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50"}),p.jsx("span",{className:"text-xs text-muted-foreground",children:"We'll use this to let you manage your flows in the future."})]}),p.jsxs("label",{className:"flex flex-col gap-1.5 text-sm",children:[p.jsx("span",{className:"font-medium",children:"Flow Name"}),p.jsx("input",{type:"text",required:!0,value:s,onChange:b=>c(b.target.value),disabled:M,"data-testid":"export-name-input",className:"rounded-md border bg-background px-3 py-2 text-sm outline-hidden ring-offset-background focus:border-ring focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50"})]}),p.jsxs("label",{className:"flex flex-col gap-1.5 text-sm",children:[p.jsx("span",{className:"font-medium",children:"Visibility"}),p.jsxs("select",{value:l,onChange:b=>h(b.target.value),disabled:M,"data-testid":"export-visibility-select",className:"rounded-md border bg-background px-3 py-2 text-sm outline-hidden ring-offset-background focus:border-ring focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",children:[p.jsx("option",{value:"public",children:"Public — anyone can discover it"}),p.jsx("option",{value:"link",children:"Anyone with the link"})]})]}),u.kind==="error"?p.jsx("div",{role:"alert","data-testid":"export-error",className:"rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-sm text-destructive",children:u.message}):null]}),p.jsx(a0,{children:u.kind==="error"?p.jsxs(p.Fragment,{children:[p.jsx(qt,{type:"button",variant:"ghost",onClick:()=>t(!1),"data-testid":"export-cancel",children:"Cancel"}),p.jsx(qt,{type:"button",onClick:()=>f({kind:"idle"}),"data-testid":"export-retry",children:"Try again"})]}):p.jsxs(p.Fragment,{children:[p.jsx(qt,{type:"button",variant:"ghost",onClick:()=>t(!1),disabled:M,"data-testid":"export-cancel",children:"Cancel"}),p.jsx(qt,{type:"button",onClick:w,disabled:M||!v,"data-testid":"export-submit",children:M?p.jsxs(p.Fragment,{children:[p.jsx(ntt,{className:"h-4 w-4 animate-spin","aria-hidden":"true"}),p.jsx("span",{children:"Uploading…"})]}):"Export"})]})})]}):p.jsxs(p.Fragment,{children:[p.jsxs("div",{className:"flex flex-col gap-3",children:[p.jsx("p",{className:"text-sm text-muted-foreground",children:"Your diagram is live. Share this link:"}),p.jsxs("div",{className:"flex gap-2",children:[p.jsx("input",{type:"text",readOnly:!0,value:u.shareUrl,"data-testid":"export-share-url",className:"min-w-0 flex-1 rounded-md border bg-muted px-3 py-2 text-sm outline-hidden"}),p.jsx(qt,{type:"button",variant:"outline",size:"icon",onClick:g,"aria-label":"Copy link","data-testid":"export-copy",children:y?p.jsx(Doe,{className:"h-4 w-4","aria-hidden":"true"}):p.jsx(Hoe,{className:"h-4 w-4","aria-hidden":"true"})}),p.jsx(qt,{type:"button",variant:"outline",size:"icon",onClick:()=>window.open(u.shareUrl,"_blank"),"aria-label":"View in new tab","data-testid":"export-view",children:p.jsx(ttt,{className:"h-4 w-4","aria-hidden":"true"})})]})]}),p.jsx(a0,{children:p.jsx(qt,{type:"button",onClick:()=>t(!1),"data-testid":"export-done",children:"Done"})})]})]})})}const ant=(e,t)=>{if(e.has(t))return e;const n=new Set(e);return n.add(t),n},int=(e,t)=>{if(t.length===0)return e;let n=!1;const o=new Set(e);for(const r of t)o.has(r)||(o.add(r),n=!0);return n?o:e},snt=(e,t)=>{if(!e.has(t))return e;const n=new Set(e);return n.delete(t),n},cnt=(e,t)=>{if(t.length===0)return e;let n=!1;const o=new Set(e);for(const r of t)o.has(r)&&(o.delete(r),n=!0);return n?o:e},lnt=(e,t)=>{if(e.size===0)return e;const n=new Set(t.map(a=>a.id));let o=!1;const r=new Set(e);for(const a of r)n.has(a)||(r.delete(a),o=!0);return o?r:e},GG=()=>{const[e,t]=m.useState(()=>new Set),n=m.useCallback(c=>{t(l=>ant(l,c))},[]),o=m.useCallback(c=>{t(l=>int(l,c))},[]),r=m.useCallback(c=>{t(l=>snt(l,c))},[]),a=m.useCallback(c=>{t(l=>cnt(l,c))},[]),i=m.useCallback(c=>{t(l=>lnt(l,c))},[]),s=m.useCallback(()=>t(new Set),[]);return{ids:e,mark:n,markMany:o,unmark:r,unmarkMany:a,pruneAgainst:i,reset:s}},dnt=(e,t)=>e===t?!0:e==null||t==null||typeof e!=typeof t||typeof e!="object"?!1:JSON.stringify(e)===JSON.stringify(t),unt=(e,t,n)=>({...e,[t]:{...e[t],...n}}),hnt=(e,t)=>{if(!(t in e))return e;const n={...e};return delete n[t],n},fnt=(e,t)=>{const n=Object.entries(e);if(n.length===0)return e;const o=new Map(t.map(i=>[i.id,i]));let r=!1;const a={...e};for(const[i,s]of n){const c=o.get(i);if(!c)continue;const l={};let h=!1;for(const u of Object.keys(s))dnt(s[u],c[u])?r=!0:(l[u]=s[u],h=!0);h?a[i]=l:(r=!0,delete a[i])}return r?a:e},ZG=()=>{const[e,t]=m.useState({}),n=m.useCallback((i,s)=>{t(c=>unt(c,i,s))},[]),o=m.useCallback(i=>{t(s=>hnt(s,i))},[]),r=m.useCallback(i=>{t(s=>fnt(s,i))},[]),a=m.useCallback(()=>t({}),[]);return{overrides:e,setOverride:n,dropOverride:o,pruneAgainst:r,reset:a}},pnt=500,ynt=500,mnt={stack:[],cursor:0},knt=(e,t,n)=>{const o=Date.now(),r=pnt,a=ynt,{stack:i,cursor:s}=e;if(t.coalesceKey&&s>0){const h=i[s-1];if(h&&h.coalesceKey===t.coalesceKey&&o-h.capturedAt<=a){const u=i.slice(0,s);return u[s-1]={...h,do:t.do,capturedAt:o},{stack:u,cursor:s}}}const c=i.slice(0,s);c.push({...t,capturedAt:o});let l=s+1;for(;c.length>r;)c.shift(),l-=1;return l<0&&(l=0),{stack:c,cursor:l}},gnt=e=>e.cursor===0?{state:e,entry:void 0}:{state:{...e,cursor:e.cursor-1},entry:e.stack[e.cursor-1]},vnt=e=>e.cursor===e.stack.length?{state:e,entry:void 0}:{state:{...e,cursor:e.cursor+1},entry:e.stack[e.cursor]},xnt=()=>({stack:[],cursor:0}),wnt=e=>{if(e.cursor===0)return e;const t=e.stack.slice();return t.splice(e.cursor-1,1),{stack:t,cursor:e.cursor-1}},Mnt=(e,t)=>t.state,bnt=()=>{const[e,t]=m.useReducer(Mnt,mnt),n=m.useRef(e);n.current=e;const o=m.useRef(Promise.resolve()),r=m.useRef(0),a=m.useCallback(y=>{y!==n.current&&(n.current=y,t({type:"replace",state:y}))},[]),i=m.useCallback(y=>{const k={do:y.do,undo:y.undo,coalesceKey:y.coalesceKey,capturedAt:y.capturedAt??Date.now()};a(knt(n.current,k))},[a]),s=m.useCallback(()=>{r.current=Date.now();const y=o.current.then(()=>{const k=gnt(n.current);if(k.entry)return a(k.state),{entry:k.entry}});return o.current=y.then(()=>{},()=>{}),y},[a]),c=m.useCallback(()=>{r.current=Date.now();const y=o.current.then(()=>{const k=vnt(n.current);if(k.entry)return a(k.state),{entry:k.entry}});return o.current=y.then(()=>{},()=>{}),y},[a]),l=m.useCallback(()=>{a(xnt())},[a]),h=m.useCallback(()=>{a(wnt(n.current))},[a]),u=m.useCallback(()=>{r.current=Date.now()},[]),f=m.useCallback(()=>r.current,[]);return{push:i,undo:s,redo:c,clear:l,dropTop:h,canUndo:e.cursor>0,canRedo:e.cursor<e.stack.length,markMutation:u,lastMutationAt:f}};function _nt({nodes:e,connectors:t,flowPos:n,nodeIdGen:o,connectorIdGen:r,defaultOffset:a={x:24,y:24}}){const i=new Map;for(const y of e)i.set(y.id,o(y.id));let s=Number.POSITIVE_INFINITY,c=Number.POSITIVE_INFINITY;for(const y of e)y.position.x<s&&(s=y.position.x),y.position.y<c&&(c=y.position.y);Number.isFinite(s)||(s=0),Number.isFinite(c)||(c=0);const l=n?n.x-s:a.x,h=n?n.y-c:a.y,u=e.map(y=>{const k=i.get(y.id);if(k===void 0)throw new Error(`paste id missing for ${y.id}`);return{...y,id:k,position:{x:y.position.x+l,y:y.position.y+h}}}),f=t.map(y=>{const k=r(y.id);return{...y,id:k,source:i.get(y.source)??y.source,target:i.get(y.target)??y.target}});return{newNodes:u,newConnectors:f,idMap:i}}const Cnt=e=>({type:"image",position:e.position,data:{path:"",alt:e.originalFilename,width:e.dims.width,height:e.dims.height,_uploading:!0}}),Snt=e=>({type:"image",data:tre(e)}),Lnt=e=>({type:"image",position:e.position,data:{path:"",alt:e.originalFilename,width:e.dims.width,height:e.dims.height,_uploadError:e.message}}),tre=e=>({...pTe(e.path,e.dims,e.lastUsed),alt:e.originalFilename}),Int=async(e,t)=>{const{nodeId:n,flowId:o,file:r,originalFilename:a,position:i,dims:s,lastUsed:c}=e;t.rememberRetry(n,{file:r,originalFilename:a,position:i,dims:s}),t.setOverride(n,Cnt({position:i,dims:s,originalFilename:a}));let l;try{l=(await t.upload(o,n,r,a)).path}catch(y){const k=y instanceof Error?y.message:String(y);throw t.setOverride(n,Lnt({position:i,dims:s,originalFilename:a,message:k})),y}t.setOverride(n,Snt({path:l,dims:s,originalFilename:a,lastUsed:c}));const h=tre({path:l,dims:s,originalFilename:a,lastUsed:c}),u={id:n,type:"image",position:i,data:h},{id:f}=await t.createNode(o,u);t.forgetRetry(n),t.pushUndo&&t.pushUndo({do:async()=>{await t.createNode(o,{...u,id:f})},undo:async()=>{await t.deleteNode(o,f)}})},Nnt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",Ant=248;function la(e=10){let t="";const n=new Uint8Array(e*2);for(;t.length<e;){crypto.getRandomValues(n);for(let o=0;o<n.length&&t.length<e;o++){const r=n[o];r<Ant&&(t+=Nnt[r%62])}}return t}const Ent=new Set(["INPUT","TEXTAREA","SELECT"]),qo=e=>e?Ent.has(e.tagName)?!0:e instanceof HTMLElement&&e.isContentEditable:!1,$nt=(e,t,n)=>{const o=e.indexOf(t);if(o<0)return null;const r=e.length,a=[...e];switch(n.op){case"forward":{if(o>=r-1)return null;const i=a[o],s=a[o+1];return i===void 0||s===void 0?null:(a[o]=s,a[o+1]=i,a)}case"backward":{if(o<=0)return null;const i=a[o],s=a[o-1];return i===void 0||s===void 0?null:(a[o]=s,a[o-1]=i,a)}case"toFront":{if(o===r-1)return null;const[i]=a.splice(o,1);return i===void 0?null:(a.push(i),a)}case"toBack":{if(o===0)return null;const[i]=a.splice(o,1);return i===void 0?null:(a.unshift(i),a)}case"toIndex":{const i=Math.min(Math.max(n.index,0),r-1);if(i===o)return null;const[s]=a.splice(o,1);return s===void 0?null:(a.splice(i,0,s),a)}}};function Pnt({slug:e,demos:t,detail:n,loading:o,runs:r,nodeEvents:a,statusByNode:i,onPlayNode:s,onRestartDemo:c}){var na,S0;const l=t.find(q=>q.slug===e),[h,u]=m.useState([]),[f,y]=m.useState([]),[k,x]=m.useState(null),w=m.useRef(h),g=m.useRef(f);m.useEffect(()=>{w.current=h},[h]),m.useEffect(()=>{g.current=f},[f]);const M=m.useRef(null),v=m.useRef(null),b=m.useRef(null),C=ZG(),_=ZG(),S=GG(),A=GG(),[P,I]=m.useState(null),[$,N]=m.useState(null),[X,j]=m.useState({kind:"select"}),O=m.useRef({kind:"select"});m.useEffect(()=>{O.current=X},[X]);const[H,B]=m.useState(!1),[z,R]=m.useState(0),L=m.useRef(null),U=m.useRef(null),D=m.useCallback(q=>{U.current=q},[]),E=bnt(),{push:W,dropTop:Y,markMutation:Q,clear:oe,lastMutationAt:te}=E,{reset:se}=C,{reset:we}=_,{reset:ke}=S,{reset:ge}=A;m.useEffect(()=>{u([]),y([]),x(null),se(),we(),ke(),ge(),I(null),N(null),zo.current=null,dr(!1),Kt.current.clear(),E.clear()},[n==null?void 0:n.id]);const ve=m.useCallback((q,F)=>{u(q),y(F)},[]),re=(na=n==null?void 0:n.flow)==null?void 0:na.nodes,me=(S0=n==null?void 0:n.flow)==null?void 0:S0.connectors,{pruneAgainst:Ve}=C,{pruneAgainst:lt}=_,{pruneAgainst:Vt}=S,{pruneAgainst:Et}=A;m.useEffect(()=>{re&&(Ve(re),Vt(re)),Date.now()-te()>2e3&&oe()},[re,Ve,Vt,te,oe]),m.useEffect(()=>{if(!re)return;const q=L.current,F=new Set(re.map(ie=>ie.id));if(L.current=F,q===null)return;const Z=C.overrides,V=S.ids;let T=!1;for(const ie of F)if(!q.has(ie)&&!(ie in Z)){T=!0;break}if(!T){for(const ie of q)if(!F.has(ie)&&!V.has(ie)){T=!0;break}}T&&R(ie=>ie+1)},[re]),m.useEffect(()=>{me&&(lt(me),Et(me)),Date.now()-te()>2e3&&oe()},[me,lt,Et,te,oe]),m.useEffect(()=>{if(!(!re||!P)&&re.length===P.length){for(let q=0;q<re.length;q++){const F=re[q],Z=P[q];if(!F||F.id!==Z)return}I(null)}},[re,P]);const ce=(n==null?void 0:n.id)??null,J=m.useMemo(()=>ce?yTe({baseUrl:"",flowId:ce}):null,[ce]),[ln,rn]=m.useState(!1),{setOverride:Ee,dropOverride:Ge}=C,G=m.useRef(C.overrides);m.useEffect(()=>{G.current=C.overrides},[C.overrides]);const ne=m.useCallback((q,F)=>{var V;if(!ce||!J)return;const Z=(V=re==null?void 0:re.find(T=>T.id===q))==null?void 0:V.position;Ee(q,{position:F}),N(null),Q(),Z&&W({do:async()=>{await J.updateNodePosition(q,F)},undo:async()=>{await J.updateNodePosition(q,Z)},coalesceKey:`node:${q}:position`}),J.updateNodePosition(q,F).catch(T=>{Ge(q),Z&&Y(),N(T instanceof Error?T.message:String(T)),console.error("updateNodePosition failed",T)})},[ce,J,re,Ee,Ge,W,Y,Q]),Ie=m.useCallback(q=>{if(!ce||!J||q.length===0)return;const F=G.current,Z=q.map(V=>{var Ae;const T=re==null?void 0:re.find(be=>be.id===V.id);if(!T)return null;const ie=((Ae=F[V.id])==null?void 0:Ae.position)??T.position;return{id:V.id,prev:ie,next:V.position}}).filter(V=>V!==null);if(Z.length!==0){for(const V of Z)Ee(V.id,{position:V.next});N(null),Q(),W({do:async()=>{await Promise.allSettled(Z.map(V=>J.updateNodePosition(V.id,V.next)))},undo:async()=>{await Promise.allSettled(Z.map(V=>J.updateNodePosition(V.id,V.prev)))}}),Promise.all(Z.map(async V=>{try{return await J.updateNodePosition(V.id,V.next),null}catch(T){return Ge(V.id),T instanceof Error?T.message:String(T)}})).then(V=>{const T=V.find(ie=>ie!==null);T&&N(T)})}},[ce,J,re,Ee,Ge,W,Q]),De=m.useCallback((q,F)=>{Ee(q,{position:{x:F.x,y:F.y},data:{width:F.width,height:F.height}})},[Ee]),Ke=m.useCallback((q,F)=>{if(!ce||!J)return;const Z=re==null?void 0:re.find(ie=>ie.id===q),V=Z?{width:Z.data.width,height:Z.data.height,position:{x:Z.position.x,y:Z.position.y}}:void 0,T={width:F.width,height:F.height,position:{x:F.x,y:F.y}};Ee(q,{position:T.position,data:{width:T.width,height:T.height}}),N(null),Q(),V&&W({do:async()=>{await J.updateNode(q,T)},undo:async()=>{await J.updateNode(q,V)},coalesceKey:`node:${q}:resize`}),J.updateNode(q,T).catch(ie=>{Ge(q),V&&Y(),N(ie instanceof Error?ie.message:String(ie)),console.error("updateNode resize failed",ie)})},[ce,J,re,Ee,Ge,W,Y,Q]),Bt=m.useCallback(q=>{if(!ce||!J)return;const F=re==null?void 0:re.find(T=>T.id===q);if(!F)return;const Z={autoSize:F.data.autoSize,width:F.data.width,height:F.data.height},V={autoSize:!0};Ee(q,{data:{autoSize:!0,width:void 0,height:void 0}}),N(null),Q(),W({do:async()=>{await J.updateNode(q,V)},undo:async()=>{await J.updateNode(q,Z)},coalesceKey:`node:${q}:fit-to-content`}),J.updateNode(q,V).catch(T=>{Ge(q),Y(),N(T instanceof Error?T.message:String(T)),console.error("updateNode (fit-to-content) failed",T)})},[ce,J,re,Ee,Ge,W,Y,Q]),bn=m.useCallback(q=>{if(!ce||!J||q.length===0)return;const F=[];for(const V of q){const T=re==null?void 0:re.find(Je=>Je.id===V.id);if(!T)continue;const ie=T.data,Ae={position:{x:T.position.x,y:T.position.y}};ie.width!==void 0&&(Ae.width=ie.width),ie.height!==void 0&&(Ae.height=ie.height);const be={position:V.position};V.width!==void 0&&(be.width=V.width),V.height!==void 0&&(be.height=V.height),F.push({id:V.id,prev:Ae,next:be})}if(F.length===0)return;for(const V of F){const T={};V.next.width!==void 0&&(T.width=V.next.width),V.next.height!==void 0&&(T.height=V.next.height),Ee(V.id,{position:V.next.position,...Object.keys(T).length>0?{data:T}:{}})}N(null),Q();const Z=F.map(V=>V.id).sort();W({do:async()=>{await Promise.allSettled(F.map(V=>J.updateNode(V.id,V.next)))},undo:async()=>{await Promise.allSettled(F.map(V=>J.updateNode(V.id,V.prev)))},coalesceKey:`multi:resize:${Z.join(",")}`}),Promise.all(F.map(async V=>{try{return await J.updateNode(V.id,V.next),null}catch(T){return Ge(V.id),T instanceof Error?T.message:String(T)}})).then(V=>{const T=V.find(ie=>ie!==null);T&&N(T)})},[ce,J,re,Ee,Ge,W,Q]),{setOverride:Qe,dropOverride:ft}=_,_n=m.useCallback((q,F)=>{Ee(q,{data:F})},[Ee]),Rt=m.useCallback((q,F)=>{for(const Z of q)Ee(Z,{data:F})},[Ee]),Cn=m.useCallback((q,F)=>{Qe(q,F)},[Qe]),an=m.useCallback((q,F)=>{if(!ce||!J)return;tU(Xa,F);const Z=re==null?void 0:re.find(T=>T.id===q);let V=null;if(Z){V={};const T=Z.data;for(const ie of Object.keys(F))V[ie]=T[ie]}if(Ee(q,{data:F}),N(null),Q(),V){const T=V;W({do:async()=>{await J.updateNode(q,F)},undo:async()=>{await J.updateNode(q,T)},coalesceKey:`node:${q}:style`})}J.updateNode(q,F).catch(T=>{Ge(q),V&&Y(),N(T instanceof Error?T.message:String(T)),console.error("updateNode style failed",T)})},[ce,J,re,Ee,Ge,W,Y,Q]),dt=m.useCallback((q,F)=>{if(!ce||!J||q.length===0)return;tU(Xa,F);const Z=q.map(V=>{const T=re==null?void 0:re.find(be=>be.id===V);if(!T)return null;const ie=T.data,Ae={};for(const be of Object.keys(F))Ae[be]=ie[be];return{id:V,prev:Ae}}).filter(V=>V!==null);if(Z.length!==0){for(const V of Z)Ee(V.id,{data:F});N(null),Q(),W({do:async()=>{await Promise.allSettled(Z.map(V=>J.updateNode(V.id,F)))},undo:async()=>{await Promise.allSettled(Z.map(V=>J.updateNode(V.id,V.prev)))}}),Promise.all(Z.map(async V=>{try{return await J.updateNode(V.id,F),null}catch(T){return Ge(V.id),T instanceof Error?T.message:String(T)}})).then(V=>{const T=V.find(ie=>ie!==null);T&&N(T)})}},[ce,J,re,Ee,Ge,W,Q]),Mt=m.useCallback((q,F)=>{if(!ce||!J)return;lTe(Xa,F);const Z=me==null?void 0:me.find(T=>T.id===q);let V=null;if(Z){V={};const T=Z;for(const ie of Object.keys(F))V[ie]=T[ie]}if(Qe(q,F),N(null),Q(),V){const T=V;W({do:async()=>{await J.updateConnector(q,F)},undo:async()=>{await J.updateConnector(q,T)},coalesceKey:`connector:${q}:style`})}J.updateConnector(q,F).catch(T=>{ft(q),V&&Y(),N(T instanceof Error?T.message:String(T)),console.error("updateConnector failed",T)})},[ce,J,me,Qe,ft,W,Y,Q]),{mark:rr,markMany:Ea,unmark:ar,unmarkMany:Pi}=S,{mark:$a,markMany:Ao,unmark:ir,unmarkMany:Eo}=A,Ad=m.useCallback(q=>{if(!ce||!J)return;const F=re==null?void 0:re.find(be=>be.id===q);if(!F)return;const Z=(me??[]).filter(be=>be.source===q||be.target===q),V=Z.map(be=>be.id),T=new Set(V);N(null),rr(q),V.length>0&&Ao(V),u(be=>be.filter(Je=>Je!==q)),y(be=>be.filter(Je=>!T.has(Je))),Q();const ie=F,Ae=Z;W({do:async()=>{rr(q),V.length>0&&Ao(V),await J.deleteNode(q)},undo:async()=>{ar(q),V.length>0&&Eo(V),await J.createNode({id:ie.id,type:ie.type,position:ie.position,data:ie.data});for(const be of Ae)await J.createConnector({...be,id:be.id})}}),J.deleteNode(q).catch(be=>{ar(q),V.length>0&&Eo(V),Y(),N(be instanceof Error?be.message:String(be)),console.error("deleteNode failed",be)})},[ce,J,re,me,rr,Ao,ar,Eo,W,Y,Q]),Ed=m.useCallback((q,F)=>{if(!ce||!J||!re)return;const Z=P??re.map(ie=>ie.id),V=$nt(Z,q,F);if(!V)return;const T=Z.indexOf(q);I(V),N(null),Q(),W({do:async()=>{await J.reorderNode(q,F)},undo:async()=>{await J.reorderNode(q,{op:"toIndex",index:T})}}),J.reorderNode(q,F).catch(ie=>{I(null),Y(),N(ie instanceof Error?ie.message:String(ie)),console.error("reorderNode failed",ie)})},[ce,J,re,P,W,Y,Q]);m.useCallback(q=>{if(!ce||!J)return;const F=me==null?void 0:me.find(V=>V.id===q);if(!F)return;N(null),$a(q),y(V=>V.filter(T=>T!==q)),Q();const Z=F;W({do:async()=>{$a(q),await J.deleteConnector(q)},undo:async()=>{ir(q),await J.createConnector({...Z,id:Z.id})}}),J.deleteConnector(q).catch(V=>{ir(q),Y(),N(V instanceof Error?V.message:String(V)),console.error("deleteConnector failed",V)})},[ce,J,me,$a,ir,W,Y,Q]);const $o=m.useCallback((q,F)=>{if(!ce||!J||q.length===0&&F.length===0)return;const Z=new Set(q),V=q.map($e=>re==null?void 0:re.find(it=>it.id===$e)).filter($e=>!!$e),T=(me??[]).filter($e=>Z.has($e.source)||Z.has($e.target)),ie=new Set(T.map($e=>$e.id)),Ae=F.map($e=>me==null?void 0:me.find(it=>it.id===$e)).filter($e=>!!$e).filter($e=>!ie.has($e.id));if(V.length===0&&T.length===0&&Ae.length===0)return;N(null);const be=V.map($e=>$e.id),Je=[...T.map($e=>$e.id),...Ae.map($e=>$e.id)];be.length>0&&Ea(be),Je.length>0&&Ao(Je);const Yt=V;u($e=>$e.filter(it=>!Z.has(it)));const pr=new Set(Ae.map($e=>$e.id));y($e=>$e.filter(it=>!pr.has(it)&&!ie.has(it))),Q(),W({do:async()=>{be.length>0&&Ea(be),Je.length>0&&Ao(Je);for(const $e of Yt)await J.deleteNode($e.id).catch(()=>{});await Promise.allSettled(Ae.map($e=>J.deleteConnector($e.id)))},undo:async()=>{be.length>0&&Pi(be),Je.length>0&&Eo(Je);for(let $e=Yt.length-1;$e>=0;$e--){const it=Yt[$e];it&&await J.createNode({id:it.id,type:it.type,position:it.position,data:it.data})}for(const $e of[...T,...Ae])await J.createConnector({...$e,id:$e.id})}});const Ot=new Map;for(const $e of V)Ot.set($e.id,T.filter(it=>it.source===$e.id||it.target===$e.id).map(it=>it.id));(async()=>{const $e=[];for(const yn of Yt)try{await J.deleteNode(yn.id)}catch(Tn){ar(yn.id);const Td=Ot.get(yn.id)??[];Td.length>0&&Eo(Td),$e.push(Tn instanceof Error?Tn.message:String(Tn))}const it=await Promise.all(Ae.map(async yn=>{try{return await J.deleteConnector(yn.id),null}catch(Tn){return ir(yn.id),Tn instanceof Error?Tn.message:String(Tn)}}));for(const yn of it)yn!==null&&$e.push(yn);$e.length>0&&$e[0]!==void 0&&N($e[0])})()},[ce,J,re,me,Ea,Ao,ar,Pi,ir,Eo,W,Q]);m.useEffect(()=>{M.current=$o},[$o]),m.useEffect(()=>{const q=F=>{if(F.key!=="Delete"&&F.key!=="Backspace"||qo(document.activeElement)||document.querySelector('[data-testid="inline-edit-input"]'))return;const Z=w.current,V=g.current;Z.length===0&&V.length===0||(F.preventDefault(),$o(Z,V))};return window.addEventListener("keydown",q),()=>window.removeEventListener("keydown",q)},[$o]);const{undo:Kr,redo:Xr,canUndo:He,canRedo:gt}=E;m.useEffect(()=>{const q=async F=>{if((F.metaKey||F.ctrlKey)&&F.key.toLowerCase()==="z"&&!qo(document.activeElement)){if(F.preventDefault(),F.shiftKey){if(!gt)return;try{const Z=await Xr();Z!=null&&Z.entry&&await Z.entry.do()}catch(Z){N(Z instanceof Error?Z.message:String(Z)),console.error("redo failed",Z)}return}if(He)try{const Z=await Kr();Z!=null&&Z.entry&&await Z.entry.undo()}catch(Z){N(Z instanceof Error?Z.message:String(Z)),console.error("undo failed",Z)}}};return window.addEventListener("keydown",q),()=>window.removeEventListener("keydown",q)},[Kr,Xr,He,gt]);const Pa=m.useCallback((q,F)=>{if(!ce||!J)return;const Z=re==null?void 0:re.find(ie=>ie.id===q),T=(Z&&"name"in Z.data?Z.data.name:void 0)??"";Ee(q,{data:{name:F}}),N(null),Q(),Z&&W({do:async()=>{await J.updateNode(q,{name:F})},undo:async()=>{await J.updateNode(q,{name:T})},coalesceKey:`node:${q}:name`}),J.updateNode(q,{name:F}).catch(ie=>{Z&&Y(),N(ie instanceof Error?ie.message:String(ie)),console.error("updateNode name failed",ie)})},[ce,J,re,Ee,W,Y,Q]),ji=m.useCallback((q,F)=>{if(!ce||!J)return;const Z=re==null?void 0:re.find(T=>T.id===q);if(!Z)return;const V=Z.data.description??"";Ee(q,{data:{description:F}}),N(null),Q(),W({do:async()=>{await J.updateNode(q,{description:F})},undo:async()=>{await J.updateNode(q,{description:V})},coalesceKey:`node:${q}:description`}),J.updateNode(q,{description:F}).catch(T=>{Y(),N(T instanceof Error?T.message:String(T)),console.error("updateNode description failed",T)})},[ce,J,re,Ee,W,Y,Q]),Yr=m.useCallback((q,F)=>{if(!ce||!J)return;const Z=re==null?void 0:re.find(T=>T.id===q);if(!Z)return;const V=Z.data.detail??"";Ee(q,{data:{detail:F}}),N(null),Q(),W({do:async()=>{await J.updateNode(q,{detail:F})},undo:async()=>{await J.updateNode(q,{detail:V})},coalesceKey:`node:${q}:detail`}),J.updateNode(q,{detail:F}).catch(T=>{Y(),N(T instanceof Error?T.message:String(T)),console.error("updateNode detail failed",T)})},[ce,J,re,Ee,W,Y,Q]),sr=m.useCallback((q,F)=>{if(!ce||!J)return;const Z=re==null?void 0:re.find(T=>T.id===q);if(!Z)return;const V="icon"in Z.data?Z.data.icon??null:null;Ee(q,{data:{icon:F??void 0}}),N(null),Q(),W({do:async()=>{await J.updateNode(q,{icon:F})},undo:async()=>{await J.updateNode(q,{icon:V})},coalesceKey:`node:${q}:icon`}),J.updateNode(q,{icon:F}).catch(T=>{Y(),N(T instanceof Error?T.message:String(T)),console.error("updateNode icon failed",T)})},[ce,J,re,Ee,W,Y,Q]),ja=m.useCallback((q,F,Z)=>{if(!ce||!J)return;N(null);const V=`node-${la()}`,T=oU(q,Z,n2(Xa).node),ie={id:V,type:q,position:F,data:T};Ee(V,{id:V,type:q,position:F,data:T}),Q(),J.createNode(ie).then(({id:be})=>{W({do:async()=>{await J.createNode({...ie,id:be})},undo:async()=>{await J.deleteNode(be)}})}).catch(be=>{Ge(V),N(be instanceof Error?be.message:String(be)),console.error("createNode failed",be)})},[ce,J,Ee,Ge,W,Q]),Rn=m.useCallback((q,F)=>{if(!ce||!J)return;N(null);const Z=`node-${la()}`,V={icon:q,width:Ku.width,height:Ku.height},T={id:Z,type:"icon",position:F,data:V};Ee(Z,{id:Z,type:"icon",position:F,data:V}),u([Z]),Q(),J.createNode(T).then(({id:Ae})=>{W({do:async()=>{await J.createNode({...T,id:Ae})},undo:async()=>{await J.deleteNode(Ae)}})}).catch(Ae=>{Ge(Z),N(Ae instanceof Error?Ae.message:String(Ae)),console.error("createNode (icon) failed",Ae)})},[ce,J,Ee,Ge,W,Q]),Po=m.useCallback(q=>{if(!ce||!J)return;N(null);const F=`node-${la()}`,Z={id:F,type:"html",position:q.position,data:{}},V={id:F,type:"html",position:q.position,data:{}};Ee(F,V),u([F]),Q(),J.createNode(Z).then(({id:T})=>{W({do:async()=>{await J.createNode({...Z,id:T})},undo:async()=>{await J.deleteNode(T)}})}).catch(T=>{Ge(F),N(T instanceof Error?T.message:String(T)),console.error("createNode (type:'html') failed",T)})},[ce,J,Ee,Ge,W,Q]),Kt=m.useRef(new Map),Xt=m.useCallback((q,F)=>{Kt.current.set(q,F)},[]),Qr=m.useCallback(q=>{Kt.current.delete(q)},[]),cr=m.useCallback(q=>{!ce||!J||(N(null),Q(),Int({...q,flowId:ce,lastUsed:n2(Xa).node},{upload:(F,Z,V,T)=>J.uploadImage(Z,V,T),createNode:async(F,Z)=>{const{id:V}=await J.createNode(Z);return{id:V}},deleteNode:async(F,Z)=>(await J.deleteNode(Z),{ok:!0}),setOverride:Ee,pushUndo:W,rememberRetry:Xt,forgetRetry:Qr}).catch(F=>{console.error("image-upload-flow failed",F)}))},[ce,J,Ee,W,Q,Xt,Qr]),$d=m.useCallback(q=>{if(!ce||!J)return;const F=`node-${la()}`;cr({nodeId:F,...q})},[ce,J,cr]),Pd=m.useCallback(q=>{const F=Kt.current.get(q);F&&cr({nodeId:q,...F})},[cr]),[jo,bt]=m.useState({open:!1,mode:"insert"}),Kn=m.useCallback((q,F)=>{bt({open:!0,mode:q,nodeId:F})},[]),lr=m.useCallback(()=>{bt(q=>({...q,open:!1}))},[]),jd=m.useCallback(()=>{Kn("insert")},[Kn]),Jr=m.useCallback(q=>Kn("replace",q),[Kn]),ea=m.useCallback(q=>{if(JRe(q),jo.mode==="replace"&&jo.nodeId){if(ce&&J){const F=jo.nodeId,Z=re==null?void 0:re.find(T=>T.id===F),V=(Z==null?void 0:Z.type)==="icon"?Z.data.icon:void 0;if(Ee(F,{data:{icon:q}}),N(null),Q(),V!==void 0){const T=V;W({do:async()=>{await J.updateNode(F,{icon:q})},undo:async()=>{await J.updateNode(F,{icon:T})},coalesceKey:`node:${F}:icon`})}J.updateNode(F,{icon:q}).catch(T=>{Ge(F),V!==void 0&&Y(),N(T instanceof Error?T.message:String(T)),console.error("updateNode (icon replace) failed",T)})}}else{const F=U.current;if(F&&ce){const Z=YRe(F,{width:window.innerWidth,height:window.innerHeight});Rn(q,Z)}}lr()},[jo.mode,jo.nodeId,ce,J,re,Ee,Ge,W,Y,Q,Rn,lr]),zd=m.useCallback((q,F)=>{if(!ce||!J)return;const Z=me==null?void 0:me.find(T=>T.id===q),V=Z==null?void 0:Z.label;Qe(q,{label:F}),N(null),Q(),Z&&W({do:async()=>{await J.updateConnector(q,{label:F})},undo:async()=>{await J.updateConnector(q,{label:V})},coalesceKey:`connector:${q}:label`}),J.updateConnector(q,{label:F}).catch(T=>{Z&&Y(),N(T instanceof Error?T.message:String(T)),console.error("updateConnector label failed",T)})},[ce,J,me,Qe,W,Y,Q]),zi=m.useCallback((q,F,Z)=>{if(!ce||!J)return;const V=`conn-${la()}`,T=Z==null?void 0:Z.targetPin,ie=n2(Xa).connector,Ae={id:V,source:q,target:F,sourceHandleAutoPicked:!0,targetHandleAutoPicked:!0,...T?{targetPin:T}:{},...ie},be={id:V,source:q,target:F,sourceHandleAutoPicked:!0,targetHandleAutoPicked:!0,...T?{targetPin:T}:{},...ie};Qe(V,Ae),N(null),Q(),J.createConnector(be).then(({id:Je})=>{W({do:async()=>{await J.createConnector({...be,id:Je})},undo:async()=>{await J.deleteConnector(Je)}})}).catch(Je=>{ft(V),N(Je instanceof Error?Je.message:String(Je)),console.error("createConnector failed",Je)})},[ce,J,Qe,ft,W,Q]),za=m.useCallback(({sourceNodeId:q,position:F,shape:Z})=>{if(!ce||!J)return;N(null);const V=`node-${la()}`,T=`conn-${la()}`,ie=qj[Z],Ae=n2(Xa),be=oU(Z,ie,Ae.node),Je={id:V,type:Z,position:F,data:be},Yt={id:T,source:q,target:V,sourceHandleAutoPicked:!0,targetHandleAutoPicked:!0,...Ae.connector};Ee(V,{id:V,type:Z,position:F,data:be}),Qe(T,Yt),x(V),Q(),(async()=>{try{await J.createNode(Je),await J.createConnector(Yt),W({do:async()=>{await J.createNode(Je),await J.createConnector(Yt)},undo:async()=>{ft(T),Ge(V),await J.deleteConnector(T).catch(()=>{}),await J.deleteNode(V).catch(()=>{})}})}catch(Ot){Ge(V),ft(T),N(Ot instanceof Error?Ot.message:String(Ot)),console.error("createAndConnectFromPane failed",Ot)}})()},[ce,J,Ee,Ge,Qe,ft,W,Q]),zo=m.useRef(null),[Sn,dr]=m.useState(!1),Xn=m.useCallback(q=>{if(!re)return;const F=new Set(q),Z=re.filter(T=>F.has(T.id));if(Z.length===0)return;const V=(me??[]).filter(T=>F.has(T.source)&&F.has(T.target));zo.current=JSON.parse(JSON.stringify({nodes:Z,connectors:V})),dr(!0)},[re,me]),Ro=m.useCallback(q=>{if(!ce||!J)return;const F=zo.current;if(!F||F.nodes.length===0)return;const{newNodes:Z,newConnectors:V}=_nt({nodes:F.nodes,connectors:F.connectors,flowPos:q,nodeIdGen:()=>`node-${la()}`,connectorIdGen:()=>`conn-${la()}`});for(const T of Z)Ee(T.id,T);for(const T of V)Qe(T.id,T);u(Z.map(T=>T.id)),y(V.map(T=>T.id)),N(null),Q(),(async()=>{try{for(const T of Z)await J.createNode({id:T.id,type:T.type,position:T.position,data:T.data});for(const T of V)await J.createConnector(T);W({do:async()=>{for(const T of Z)await J.createNode({id:T.id,type:T.type,position:T.position,data:T.data});for(const T of V)await J.createConnector(T)},undo:async()=>{await Promise.allSettled(V.map(T=>J.deleteConnector(T.id))),await Promise.allSettled(Z.map(T=>J.deleteNode(T.id)))}})}catch(T){for(const ie of Z)Ge(ie.id);for(const ie of V)ft(ie.id);N(T instanceof Error?T.message:String(T)),console.error("paste failed",T)}})()},[ce,J,Ee,Ge,Qe,ft,Q,W]);m.useEffect(()=>{const q=F=>{const Z=sTe({event:F,isEditableActive:qo(document.activeElement),hasNodes:!!re&&re.length>0,hasConnectors:!!me&&me.length>0,selectedIds:w.current,hasClipboard:!!zo.current});if(Z.type!=="noop"&&!(Z.type==="copy"||Z.type==="paste")){if(F.preventDefault(),Z.type==="selectAll"){u((re??[]).map(V=>V.id)),y((me??[]).map(V=>V.id));return}Xn([...Z.ids]),Ro(null)}};return window.addEventListener("keydown",q),()=>window.removeEventListener("keydown",q)},[re,me,Xn,Ro]),m.useEffect(()=>{const q=F=>{const Z=rTe(F);if(!Z||qo(document.activeElement))return;const V=w.current;if(V.length===0)return;const T=C.overrides,ie=(re??[]).map(be=>{var Yt;const Je=((Yt=T[be.id])==null?void 0:Yt.position)??be.position;return{id:be.id,position:Je}}),Ae=iTe(Z,V,ie);if(Ae.length!==0)if(F.preventDefault(),Ae.length===1){const be=Ae[0];be&&ne(be.id,be.position)}else Ie(Ae)};return window.addEventListener("keydown",q),()=>window.removeEventListener("keydown",q)},[re,C.overrides,ne,Ie]),m.useEffect(()=>{const q=F=>{const Z=aTe(F);if(!Z||qo(document.activeElement))return;F.preventDefault();const V=U.current;V&&(Z==="fit"?V.fitView({padding:.2,duration:200}):Z==="in"?V.zoomIn({duration:150}):V.zoomOut({duration:150}))};return window.addEventListener("keydown",q),()=>window.removeEventListener("keydown",q)},[]);const Yn=m.useCallback(async q=>{if(!ce||!J||!re||!J.computeLayout)return;const F=C.overrides,Z=U.current,V=q==="selection"?new Set(w.current):null,T=V?re.filter(Oe=>V.has(Oe.id)):re;if(T.length<2)return;const ie=new Set(T.map(Oe=>Oe.id)),Ae=(me??[]).filter(Oe=>ie.has(Oe.source)&&ie.has(Oe.target)),be=new Map,Je=T.map(Oe=>{var Ti;const _t=((Ti=F[Oe.id])==null?void 0:Ti.position)??Oe.position;be.set(Oe.id,_t);const Qt=Z==null?void 0:Z.getInternalNode(Oe.id),Jt=Qt==null?void 0:Qt.measured,Jn=Oe.data,L0=(Jt==null?void 0:Jt.width)??Jn.width??200,hR=(Jt==null?void 0:Jt.height)??Jn.height??120;return{id:Oe.id,type:Oe.type,width:L0,height:hR}}),Yt=Ae.map(Oe=>({id:Oe.id,source:Oe.source,target:Oe.target})),pr=await J.computeLayout(Je,Yt),Ot=new Map;for(const[Oe,_t]of Object.entries(pr.nodes))Ot.set(Oe,_t.position);let $e=Number.POSITIVE_INFINITY,it=Number.POSITIVE_INFINITY,yn=Number.POSITIVE_INFINITY,Tn=Number.POSITIVE_INFINITY;for(const Oe of Je){const _t=be.get(Oe.id);if(!_t)continue;_t.x<$e&&($e=_t.x),_t.y<it&&(it=_t.y);const Qt=Ot.get(Oe.id);Qt&&(Qt.x<yn&&(yn=Qt.x),Qt.y<Tn&&(Tn=Qt.y))}const Td=Number.isFinite($e)&&Number.isFinite(yn)?$e-yn:0,uR=Number.isFinite(it)&&Number.isFinite(Tn)?it-Tn:0,Da=[];for(const Oe of Je){const _t=be.get(Oe.id),Qt=Ot.get(Oe.id);if(!_t||!Qt)continue;const Jt={x:Qt.x+Td,y:Qt.y+uR},Jn=Jt.x-_t.x,L0=Jt.y-_t.y;Math.abs(Jn)<1&&Math.abs(L0)<1||Da.push({id:Oe.id,prev:_t,next:Jt})}if(Da.length!==0){N(null);for(const Oe of Da)Ee(Oe.id,{position:Oe.next});Q(),W({do:async()=>{await Promise.allSettled(Da.map(Oe=>J.updateNodePosition(Oe.id,Oe.next)))},undo:async()=>{await Promise.allSettled(Da.map(Oe=>J.updateNodePosition(Oe.id,Oe.prev)))}}),Promise.all(Da.map(async Oe=>{try{return await J.updateNodePosition(Oe.id,Oe.next),null}catch(_t){return Ge(Oe.id),_t instanceof Error?_t.message:String(_t)}})).then(Oe=>{const _t=Oe.filter(Jt=>Jt!==null),Qt=_t[0];Qt&&(N(_t.length===1?Qt:`${_t.length} node updates failed (first: ${Qt})`),console.error("Tidy: some updateNodePosition calls failed",_t))})}},[ce,J,re,me,C.overrides,Ee,Ge,W,Q]);m.useEffect(()=>{const q=F=>{if(!(F.metaKey||F.ctrlKey)||!F.shiftKey||F.altKey||F.key.toLowerCase()!=="l"||qo(document.activeElement))return;F.preventDefault();const Z=w.current.length>0?"selection":"all";Yn(Z)};return window.addEventListener("keydown",q),()=>window.removeEventListener("keydown",q)},[Yn]);const Rd=m.useCallback(()=>{const q=w.current.length>0?"selection":"all";Yn(q)},[Yn]);m.useEffect(()=>{const q=F=>{if(qo(document.activeElement)||document.querySelector('[data-testid="inline-edit-input"]'))return;const Z=cTe(F);if(Z===null)return;const V=O.current;if(Z==="select"){V.kind!=="select"&&j({kind:"select"});return}if(Z==="hand"){j(V.kind==="hand"?{kind:"select"}:{kind:"hand"});return}if(V.kind==="draw"&&V.shape===Z){j({kind:"select"});return}j({kind:"draw",shape:Z})};return window.addEventListener("keydown",q),()=>window.removeEventListener("keydown",q)},[]),m.useEffect(()=>{const q=F=>{if(F.key!=="Escape"||qo(document.activeElement)||document.querySelector('[data-testid="inline-edit-input"]'))return;if(O.current.kind!=="select"){j({kind:"select"});return}w.current.length>0&&u([]),g.current.length>0&&y([])};return window.addEventListener("keydown",q),()=>window.removeEventListener("keydown",q)},[]),m.useEffect(()=>{const q=F=>{if(F.key.toLowerCase()!=="f"||F.metaKey||F.ctrlKey||F.shiftKey||F.altKey||qo(document.activeElement)||document.querySelector('[data-testid="inline-edit-input"]'))return;const Z=w.current;if(Z.length===0)return;const V=U.current;V&&V.fitView({nodes:Z.map(T=>({id:T})),padding:.2,duration:200})};return window.addEventListener("keydown",q),()=>window.removeEventListener("keydown",q)},[]),m.useEffect(()=>{const q=F=>{if(F.key!=="1"||F.metaKey||F.ctrlKey||F.shiftKey||F.altKey||qo(document.activeElement)||document.querySelector('[data-testid="inline-edit-input"]'))return;const Z=U.current;if(!Z)return;const{x:V,y:T}=Z.getViewport();Z.setViewport({x:V,y:T,zoom:1},{duration:150})};return window.addEventListener("keydown",q),()=>window.removeEventListener("keydown",q)},[]);const ur=m.useCallback(q=>{var F,Z,V;switch(q){case"tool.select":j({kind:"select"});return;case"tool.hand":j({kind:"hand"});return;case"tool.rectangle":j({kind:"draw",shape:"rectangle"});return;case"tool.ellipse":j({kind:"draw",shape:"ellipse"});return;case"tool.text":j({kind:"draw",shape:"text"});return;case"tool.sticky":j({kind:"draw",shape:"sticky"});return;case"tool.database":j({kind:"draw",shape:"database"});return;case"edit.undo":{if(!He)return;(async()=>{try{const T=await Kr();T!=null&&T.entry&&await T.entry.undo()}catch(T){N(T instanceof Error?T.message:String(T)),console.error("undo failed",T)}})();return}case"edit.redo":{if(!gt)return;(async()=>{try{const T=await Xr();T!=null&&T.entry&&await T.entry.do()}catch(T){N(T instanceof Error?T.message:String(T)),console.error("redo failed",T)}})();return}case"edit.copy":{const T=w.current;if(T.length===0)return;Xn([...T]);return}case"edit.paste":Ro(null);return;case"edit.duplicate":{const T=w.current;if(T.length===0)return;Xn([...T]),Ro(null);return}case"edit.delete":{const T=w.current,ie=g.current;if(T.length===0&&ie.length===0)return;$o([...T],[...ie]);return}case"edit.selectAll":u((re??[]).map(T=>T.id)),y((me??[]).map(T=>T.id));return;case"view.fit":{const T=U.current;if(!T)return;T.fitView({padding:.2,duration:200});return}case"view.zoomIn":{const T=U.current;if(!T)return;T.zoomIn({duration:150});return}case"view.zoomOut":{const T=U.current;if(!T)return;T.zoomOut({duration:150});return}case"view.zoom100":{const T=U.current;if(!T)return;const{x:ie,y:Ae}=T.getViewport();T.setViewport({x:ie,y:Ae,zoom:1},{duration:150});return}case"view.zoomToSelection":{const T=w.current;if(T.length===0)return;const ie=U.current;if(!ie)return;ie.fitView({nodes:T.map(Ae=>({id:Ae})),padding:.2,duration:200});return}case"layout.tidy":{const T=w.current.length>0?"selection":"all";Yn(T);return}case"selection.deselect":w.current.length>0&&u([]),g.current.length>0&&y([]),O.current.kind!=="select"&&j({kind:"select"});return;case"help.commandPalette":B(!0);return;case"export.pdf":{(F=b.current)==null||F.exportPdf();return}case"export.png":{(Z=b.current)==null||Z.exportPng();return}case"session.reset":{(V=v.current)==null||V.call(v);return}}},[He,gt,Kr,Xr,Xn,Ro,$o,re,me,Yn]);m.useEffect(()=>{const q=F=>{(F.metaKey||F.ctrlKey)&&(F.shiftKey||F.altKey||F.key.toLowerCase()==="p"&&(F.preventDefault(),!qo(document.activeElement)&&ur("help.commandPalette")))};return window.addEventListener("keydown",q),()=>window.removeEventListener("keydown",q)},[ur]),m.useEffect(()=>{v.current=c??null},[c]);const Qn=m.useCallback((q,F)=>{if(!ce||!J)return;const Z=me==null?void 0:me.find(ie=>ie.id===q),V=Z?{source:Z.source,target:Z.target,sourceHandle:Z.sourceHandle,targetHandle:Z.targetHandle,sourceHandleAutoPicked:Z.sourceHandleAutoPicked,targetHandleAutoPicked:Z.targetHandleAutoPicked,sourcePin:Z.sourcePin??null,targetPin:Z.targetPin??null}:null,T={...F.source!==void 0?{source:F.source}:{},...F.target!==void 0?{target:F.target}:{},...F.sourceHandle!==void 0?{sourceHandle:F.sourceHandle===null?void 0:F.sourceHandle}:{},...F.targetHandle!==void 0?{targetHandle:F.targetHandle===null?void 0:F.targetHandle}:{},...F.sourceHandleAutoPicked!==void 0?{sourceHandleAutoPicked:F.sourceHandleAutoPicked}:{},...F.targetHandleAutoPicked!==void 0?{targetHandleAutoPicked:F.targetHandleAutoPicked}:{},...F.sourcePin!==void 0?{sourcePin:F.sourcePin===null?void 0:F.sourcePin}:{},...F.targetPin!==void 0?{targetPin:F.targetPin===null?void 0:F.targetPin}:{}};if(Qe(q,T),N(null),Q(),V){const ie=V;W({do:async()=>{await J.updateConnector(q,F)},undo:async()=>{await J.updateConnector(q,ie)},coalesceKey:`connector:${q}:reconnect`})}J.updateConnector(q,F).catch(ie=>{ft(q),V&&Y(),N(ie instanceof Error?ie.message:String(ie)),console.error("updateConnector reconnect failed",ie)})},[ce,J,me,Qe,ft,W,Y,Q]),Ra=m.useCallback((q,F,Z)=>{if(!ce||!J)return;const V=me==null?void 0:me.find(Ae=>Ae.id===q),T=V?F==="source"?V.sourcePin:V.targetPin:void 0,ie=F==="source"?"sourcePin":"targetPin";if(Qe(q,{[ie]:Z}),N(null),Q(),V){const Ae={[ie]:T??null};W({do:async()=>{await J.updateConnector(q,{[ie]:Z})},undo:async()=>{await J.updateConnector(q,Ae)},coalesceKey:`connector:${q}:${ie}`})}J.updateConnector(q,{[ie]:Z}).catch(Ae=>{ft(q),V&&Y(),N(Ae instanceof Error?Ae.message:String(Ae)),console.error("updateConnector pin failed",Ae)})},[ce,J,me,Qe,ft,W,Y,Q]),To=m.useCallback((q,F)=>{if(!ce||!J)return;const Z=me==null?void 0:me.find(ie=>ie.id===q),V=Z?F==="source"?Z.sourcePin:Z.targetPin:void 0;if(!V)return;const T=F==="source"?"sourcePin":"targetPin";Qe(q,{[T]:void 0}),N(null),Q(),W({do:async()=>{await J.updateConnector(q,{[T]:null})},undo:async()=>{await J.updateConnector(q,{[T]:V})}}),J.updateConnector(q,{[T]:null}).catch(ie=>{ft(q),Y(),N(ie instanceof Error?ie.message:String(ie)),console.error("updateConnector unpin failed",ie)})},[ce,J,me,Qe,ft,W,Y,Q]),ut=n==null?void 0:n.flow,go=C.overrides,vo=_.overrides,pn=S.ids,hr=A.ids,fr=m.useMemo(()=>{if(!ut||h.length===0)return[];const q=new Map(ut.nodes.map(Z=>[Z.id,Z])),F=[];for(const Z of h){const V=q.get(Z);if(!V)continue;const T=go[Z];if(!T){F.push(V);continue}const ie=T.data?{...V.data,...T.data}:V.data;F.push({...V,...T,data:ie})}return F},[ut,h,go]),Ta=m.useMemo(()=>{if(!ut||f.length===0)return[];const q=new Map(ut.connectors.map(Z=>[Z.id,Z])),F=[];for(const Z of f){const V=q.get(Z);if(!V)continue;const T=vo[Z];F.push(T?{...V,...T}:V)}return F},[ut,f,vo]),Ri=m.useMemo(()=>{if(!ut)return null;if(!P)return ut.nodes;const q=new Map(ut.nodes.map(V=>[V.id,V])),F=[],Z=new Set;for(const V of P){const T=q.get(V);T&&(F.push(T),Z.add(V))}for(const V of ut.nodes)Z.has(V.id)||F.push(V);return F},[ut,P]),lR=m.useMemo(()=>{const q=Ri??(ut==null?void 0:ut.nodes)??null;return q?pn.size===0?q:q.filter(F=>!pn.has(F.id)):null},[Ri,ut,pn]),dR=m.useMemo(()=>{const q=(ut==null?void 0:ut.connectors)??null;return q?hr.size===0&&pn.size===0?q:q.filter(F=>!hr.has(F.id)&&!pn.has(F.source)&&!pn.has(F.target)):null},[ut,hr,pn]);if(!l)return p.jsxs("div",{className:"flex h-full w-full flex-col items-center justify-center gap-2 bg-background p-6 text-center",children:[p.jsxs("p",{className:"text-sm font-medium",children:["Unknown demo: ",e]}),p.jsx("p",{className:"text-xs text-muted-foreground",children:"The slug may have been removed. Re-register from the project repo to bring it back."})]});if(o&&!n)return p.jsx("div",{className:"flex h-full w-full items-center justify-center text-sm text-muted-foreground",children:"Loading demo…"});const yf=h[0],ta=yf?i[yf]:void 0;return p.jsxs("div",{className:"relative h-full w-full",children:[n&&!n.valid?p.jsxs("div",{"data-testid":"demo-error-banner",className:"absolute inset-x-0 top-0 z-10 border-b border-rose-500/40 bg-rose-50 px-4 py-2 text-xs text-rose-900 shadow-xs dark:bg-rose-950/40 dark:text-rose-100",children:[p.jsx("span",{className:"font-medium uppercase tracking-wide",children:"Invalid demo: "}),p.jsx("span",{className:"font-mono",children:n.error})]}):null,ut&&J?p.jsx(Get,{ref:b,mode:"edit",adapter:J,projectId:ce??void 0,enableEmbed:!1,onExportToCloud:ce?()=>rn(!0):void 0,onRestartDemo:c,nodes:lR??ut.nodes,connectors:dR??ut.connectors,selectedNodeIds:h,selectedConnectorIds:f,onSelectionChange:ve,runtime:{runs:r,statuses:i,pendingOverrides:{nodes:go,connectors:vo}},onPlayNode:s,onNodePositionChange:ne,onNodePositionsChange:Ie,onNodeResize:De,onNodeResizeEnd:Ke,onHtmlNodeFitToContent:Bt,onComponentNodeFitToContent:Bt,onMultiResize:bn,onNodeNameChange:Pa,onNodeDescriptionChange:ji,onConnectorLabelChange:zd,onCreateShapeNode:ja,onCreateImageFromFile:ce?$d:void 0,onRetryImageUpload:ce?Pd:void 0,onCreateHtmlNode:ce?Po:void 0,iconPickerOpen:jo.open,onOpenIconPicker:ce?jd:void 0,onCloseIconPicker:ce?lr:void 0,onPickIcon:ce?ea:void 0,onRequestIconReplace:ce?Jr:void 0,onCreateConnector:zi,onReconnectConnector:Qn,onPinEndpoint:ce?Ra:void 0,onUnpinEndpoint:ce?To:void 0,onReorderNode:Ed,onDeleteNode:Ad,onCopyNode:q=>Xn([q]),onPasteAt:Ro,onCopySelection:ce?Xn:void 0,onPasteSelection:ce?()=>Ro(null):void 0,hasClipboard:Sn,selectedNodes:fr,selectedConnectors:Ta,onStyleNode:an,onStyleNodePreview:_n,onStyleNodes:dt,onStyleNodesPreview:Rt,onStyleConnector:Mt,onStyleConnectorPreview:Cn,onRfInit:D,onTidy:re?Rd:void 0,onCreateAndConnectFromPane:za,pendingEditNodeId:k,canvasMode:X,onCanvasModeChange:j,statusReport:ta,onNameChange:Pa,onDescriptionChange:ji,onDetailChange:Yr,onIconChange:sr,autoFitView:!0,autoFitViewSignal:z}):p.jsx("div",{className:"flex h-full w-full items-center justify-center text-sm text-muted-foreground",children:"No demo data yet."}),$?p.jsxs("div",{"data-testid":"edit-error-banner",className:"absolute inset-x-0 bottom-4 z-20 mx-auto w-fit max-w-[80%] rounded-md border border-rose-500/50 bg-rose-50 px-3 py-2 text-xs text-rose-900 shadow-md dark:bg-rose-950/60 dark:text-rose-100",children:[p.jsx("span",{className:"font-medium",children:"Couldn't save change: "}),p.jsx("span",{className:"font-mono",children:$}),p.jsx("button",{type:"button",className:"ml-3 underline underline-offset-2",onClick:()=>N(null),children:"Dismiss"})]}):null,p.jsx(Htt,{open:H,onOpenChange:B,runCommand:ur,ctx:{hasSelection:h.length>0||f.length>0,canUndo:He,canRedo:gt,hasClipboard:Sn,canExportDemo:!!ce,canResetSession:!!c}}),ce?p.jsx(rnt,{open:ln,onOpenChange:rn,projectId:ce,flowName:(n==null?void 0:n.name)??l.name,onCapturePreview:()=>{var q;return((q=b.current)==null?void 0:q.capturePreview())??Promise.resolve(void 0)}}):null]})}const KG="npx seeflow register --path .";function jnt(){const[e,t]=m.useState(!1),n=async()=>{try{await navigator.clipboard.writeText(KG),t(!0),setTimeout(()=>t(!1),1200)}catch(o){console.error("[empty-state] copy failed",o)}};return p.jsx("div",{"data-testid":"seeflow-empty-state",className:"flex h-full w-full items-center justify-center bg-background p-6",children:p.jsxs("div",{className:"flex max-w-lg flex-col items-center gap-6 text-center",children:[p.jsx("div",{className:"flex h-12 w-12 items-center justify-center rounded-full bg-muted",children:p.jsx(att,{className:"h-6 w-6 text-muted-foreground"})}),p.jsxs("div",{className:"space-y-2",children:[p.jsx("h1",{className:"text-2xl font-semibold tracking-tight text-foreground",children:"No demos registered yet"}),p.jsxs("p",{className:"text-sm text-muted-foreground",children:["Point SeeFlow at any folder containing a"," ",p.jsx("code",{className:"rounded bg-muted px-1.5 py-0.5 text-xs",children:"flow.json"})," file and it'll appear here."]})]}),p.jsxs("div",{className:"flex w-full items-center gap-2 rounded-md border border-border bg-card px-3 py-2 font-mono text-sm",children:[p.jsx("span",{className:"text-muted-foreground select-none",children:"$"}),p.jsx("code",{className:"flex-1 truncate text-left",children:KG}),p.jsx(qt,{type:"button",variant:"ghost",size:"sm",onClick:n,"aria-label":"Copy register command",children:e?p.jsx(Doe,{className:"h-4 w-4"}):p.jsx(Hoe,{className:"h-4 w-4"})})]})]})})}function znt({demos:e}){return e.length===0?p.jsx(jnt,{}):p.jsx("div",{className:"flex h-full w-full items-start justify-center overflow-y-auto bg-background p-8",children:p.jsxs("div",{"data-testid":"studio-home-picker",className:"flex w-full max-w-2xl flex-col gap-6 pt-8",children:[p.jsxs("div",{className:"space-y-1",children:[p.jsx("h1",{className:"text-2xl font-semibold tracking-tight",children:"Open a demo"}),p.jsxs("p",{className:"text-sm text-muted-foreground",children:[e.length," demos registered — pick one to load its canvas."]})]}),p.jsx("ul",{className:"flex flex-col gap-2",children:e.map(t=>p.jsx("li",{children:p.jsxs("button",{type:"button",onClick:()=>c0(`/d/${t.slug}`),"data-testid":`studio-home-demo-${t.slug}`,className:"flex w-full flex-col items-start gap-0.5 rounded-lg border border-border bg-card px-4 py-3 text-left transition-colors hover:border-input",style:{boxShadow:"var(--shadow-card)"},children:[p.jsx("span",{className:"text-sm font-medium",children:t.name}),p.jsx("span",{className:"truncate text-xs text-muted-foreground",children:t.repoPath})]})},t.id))})]})})}const Rnt=e=>{if(!e.startsWith("/d/"))return null;const t=e.slice(3);return t.length>0?decodeURIComponent(t):null};function Tnt(){const e=Xet(),{demos:t,refresh:n}=xtt(),o=Rnt(e);Ett({onRegistryReload:n});const r=o?(t??[]).find(A=>A.slug===o):void 0,a=(r==null?void 0:r.id)??null,{detail:i,loading:s,refresh:c,applyDetail:l}=vtt(a),{runs:h,apply:u}=Stt(a),{events:f,apply:y}=_tt(a),{statusByNode:k,apply:x,reset:w}=Att(a),g=m.useCallback(()=>{w(),c(),n()},[c,n,w]),M=m.useCallback(A=>{if(!a||!r)return;const P={id:a,slug:r.slug,filePath:""},I=A.valid?{...P,name:A.flow.name??r.name,flow:A.flow,valid:!0,error:null}:{...P,name:r.name,flow:null,valid:!1,error:A.error};l(I)},[a,r,l]),v=m.useCallback(A=>{u(A),y(A),x(A)},[u,y,x]);$tt(a,{onHello:g,onFlowReload:M,onEvent:v});const b=m.useCallback(async()=>{if(a)try{await cse(a)}catch(A){console.error("Failed to restart demo:",A)}},[a]),C=m.useCallback(A=>{jG(A.id),n()},[n]),_=m.useCallback(async A=>{await n(),a===A&&c0("/")},[n,a]);m.useEffect(()=>{if(e!=="/"||t===null)return;const A=ztt(t,jtt());A&&c0(`/d/${A.slug}`)},[e,t]),m.useEffect(()=>{r&&jG(r.id)},[r]);const S=m.useCallback(A=>{a&&lse(a,A).catch(P=>{u({type:"node:error",nodeId:A,message:P instanceof Error?P.message:String(P),ts:Date.now()})})},[a,u]);return t===null?p.jsx("div",{className:"flex h-full w-full items-center justify-center bg-background text-sm text-muted-foreground",children:"Loading…"}):p.jsx(F2,{delayDuration:150,children:p.jsxs("div",{className:"flex h-full w-full flex-col bg-background text-foreground",children:[p.jsx(gtt,{demos:t,currentSlug:o??void 0,onProjectCreated:C,onProjectUnregistered:_}),p.jsx("main",{className:"min-h-0 flex-1",children:o?p.jsx(Pnt,{slug:o,demos:t,detail:i,loading:s,runs:h,nodeEvents:f,statusByNode:k,onPlayNode:S,onRestartDemo:a?b:void 0}):p.jsx(znt,{demos:t})})]})})}const nre=document.getElementById("root");if(!nre)throw new Error("Root element #root not found");VT.createRoot(nre).render(p.jsx(Ar.StrictMode,{children:p.jsx(Tnt,{})}));export{CXe as M,Ar as R,Iz as _,fX as a,WP as b,eG as c,$r as d,DQe as e,aWe as f,Ah as g,cWe as h,H2 as i,p as j,lWe as k,QO as l,m as r,GUe as s,QUe as w,qnt as z};