@tuongaz/seeflow 0.1.81 → 0.1.83
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/web/assets/{architectureDiagram-3BPJPVTR-BfABufg7.js → architectureDiagram-3BPJPVTR-CHtgIZZ1.js} +1 -1
- package/dist/web/assets/{blockDiagram-GPEHLZMM-DEsJzjMp.js → blockDiagram-GPEHLZMM-D4zjpGBX.js} +1 -1
- package/dist/web/assets/{c4Diagram-AAUBKEIU-BI2bLAFy.js → c4Diagram-AAUBKEIU-zSpjD7ZC.js} +1 -1
- package/dist/web/assets/channel-CXa0j4Re.js +1 -0
- package/dist/web/assets/{chart-BbL2c3JQ.js → chart-D6WVIyqJ.js} +1 -1
- package/dist/web/assets/{chunk-2J33WTMH-Cgomd5cT.js → chunk-2J33WTMH-Cr7utMp9.js} +1 -1
- package/dist/web/assets/{chunk-4BX2VUAB-D7PhkaW3.js → chunk-4BX2VUAB-B6PCB6H4.js} +1 -1
- package/dist/web/assets/{chunk-55IACEB6-CUFJz27b.js → chunk-55IACEB6-D_PUAOtb.js} +1 -1
- package/dist/web/assets/{chunk-727SXJPM-DuhsbPQs.js → chunk-727SXJPM-DTQLQ_nx.js} +1 -1
- package/dist/web/assets/{chunk-AQP2D5EJ-1wXXetBT.js → chunk-AQP2D5EJ-OBgrFsDS.js} +1 -1
- package/dist/web/assets/{chunk-FMBD7UC4-D6ESudu6.js → chunk-FMBD7UC4-Cqo28fuY.js} +1 -1
- package/dist/web/assets/{chunk-ND2GUHAM-Dq8nvkVX.js → chunk-ND2GUHAM-DcquCeO4.js} +1 -1
- package/dist/web/assets/{chunk-QZHKN3VN-2m-ARThf.js → chunk-QZHKN3VN-SKsRSBcC.js} +1 -1
- package/dist/web/assets/classDiagram-4FO5ZUOK-DGPggFxp.js +1 -0
- package/dist/web/assets/classDiagram-v2-Q7XG4LA2-DGPggFxp.js +1 -0
- package/dist/web/assets/{code-block-DTN7FEQj.js → code-block-CQcwHam8.js} +1 -1
- package/dist/web/assets/{cose-bilkent-S5V4N54A-DjzT5K-0.js → cose-bilkent-S5V4N54A-Ds8DGArP.js} +1 -1
- package/dist/web/assets/{dagre-BM42HDAG-BwzsmtSu.js → dagre-BM42HDAG-CqMyTq3c.js} +1 -1
- package/dist/web/assets/{diagram-2AECGRRQ-FYQyXaT_.js → diagram-2AECGRRQ-CWEIApTd.js} +1 -1
- package/dist/web/assets/{diagram-5GNKFQAL-DAzyREi8.js → diagram-5GNKFQAL-8TEzgir4.js} +1 -1
- package/dist/web/assets/{diagram-KO2AKTUF-DGKrMcjo.js → diagram-KO2AKTUF-UNKtOw9m.js} +1 -1
- package/dist/web/assets/{diagram-LMA3HP47-Bff209n5.js → diagram-LMA3HP47-D6QoRbi6.js} +1 -1
- package/dist/web/assets/{diagram-OG6HWLK6-BuqayNQm.js → diagram-OG6HWLK6-CQqkl0nk.js} +1 -1
- package/dist/web/assets/{erDiagram-TEJ5UH35-BUjs8hUi.js → erDiagram-TEJ5UH35-Clv5A-5B.js} +1 -1
- package/dist/web/assets/{flowDiagram-I6XJVG4X-B_D_x2FB.js → flowDiagram-I6XJVG4X-4hg7rn9v.js} +1 -1
- package/dist/web/assets/{ganttDiagram-6RSMTGT7-DxfI1q3k.js → ganttDiagram-6RSMTGT7-3PAgpAEA.js} +1 -1
- package/dist/web/assets/{gitGraphDiagram-PVQCEYII-BIEMbeDK.js → gitGraphDiagram-PVQCEYII-D5g_5z1o.js} +1 -1
- package/dist/web/assets/{index-DRyzDJUb.js → index-CaE1zYAX.js} +5 -5
- package/dist/web/assets/{index.es-CiKqWLXZ.js → index.es-Cgv8Vcjx.js} +1 -1
- package/dist/web/assets/{infoDiagram-5YYISTIA-DdStjmcL.js → infoDiagram-5YYISTIA-BuFXAl4D.js} +1 -1
- package/dist/web/assets/{ishikawaDiagram-YF4QCWOH-1YlL8XhA.js → ishikawaDiagram-YF4QCWOH-DOE-GUy-.js} +1 -1
- package/dist/web/assets/{journeyDiagram-JHISSGLW-4UmpNnmE.js → journeyDiagram-JHISSGLW-B5BXjJgy.js} +1 -1
- package/dist/web/assets/{jspdf.es.min-CfPjY_mb.js → jspdf.es.min-_GQ7N2xd.js} +3 -3
- package/dist/web/assets/{kanban-definition-UN3LZRKU-BpHur4yM.js → kanban-definition-UN3LZRKU-DTLQ2kuG.js} +1 -1
- package/dist/web/assets/{linear-BlKd__8P.js → linear-DCKgJuDe.js} +1 -1
- package/dist/web/assets/{markdown-B0s014Jt.js → markdown-DQ9_ZAvJ.js} +1 -1
- package/dist/web/assets/{mermaid.core-C1P8oPqR.js → mermaid.core-Cf2CUPpR.js} +4 -4
- package/dist/web/assets/{mindmap-definition-RKZ34NQL-CbYEKJD0.js → mindmap-definition-RKZ34NQL-CI-_BCCZ.js} +1 -1
- package/dist/web/assets/{pieDiagram-4H26LBE5-DTM5C3b_.js → pieDiagram-4H26LBE5-BdTv4DaU.js} +1 -1
- package/dist/web/assets/{quadrantDiagram-W4KKPZXB-BTLv_k9D.js → quadrantDiagram-W4KKPZXB-pqQ7pKT1.js} +1 -1
- package/dist/web/assets/{requirementDiagram-4Y6WPE33-xrt0GAFn.js → requirementDiagram-4Y6WPE33-CCP9fYhL.js} +1 -1
- package/dist/web/assets/{sankeyDiagram-5OEKKPKP-CTC7QJzV.js → sankeyDiagram-5OEKKPKP-CpMAd0Mj.js} +1 -1
- package/dist/web/assets/{sequenceDiagram-3UESZ5HK-DXxHxv0c.js → sequenceDiagram-3UESZ5HK-BWg19eGL.js} +1 -1
- package/dist/web/assets/{stateDiagram-AJRCARHV-Cq8S_qAw.js → stateDiagram-AJRCARHV-BliITsKN.js} +1 -1
- package/dist/web/assets/stateDiagram-v2-BHNVJYJU-BCerI8Jf.js +1 -0
- package/dist/web/assets/{time-BWlQ2zTb.js → time-Dqs-aHL0.js} +1 -1
- package/dist/web/assets/{timeline-definition-PNZ67QCA-ooIJpgWs.js → timeline-definition-PNZ67QCA-Bk8P84Jg.js} +1 -1
- package/dist/web/assets/{vennDiagram-CIIHVFJN-ClAQa-gM.js → vennDiagram-CIIHVFJN-CMtXVM_H.js} +1 -1
- package/dist/web/assets/{wardley-L42UT6IY-UjncjFg7.js → wardley-L42UT6IY-CHP-BfXr.js} +1 -1
- package/dist/web/assets/{wardleyDiagram-YWT4CUSO-BQkPAPTU.js → wardleyDiagram-YWT4CUSO-DInIu6_2.js} +1 -1
- package/dist/web/assets/{xychartDiagram-2RQKCTM6-CO6j1v0J.js → xychartDiagram-2RQKCTM6-B0gobaUy.js} +1 -1
- package/dist/web/index.html +1 -1
- package/package.json +1 -1
- package/src/api.ts +42 -1
- package/src/cli-manifest.ts +21 -4
- package/src/cli.ts +46 -3
- package/src/mcp.ts +60 -11
- package/src/schema-catalog.ts +23 -0
- package/dist/web/assets/channel-C4GDf2FG.js +0 -1
- package/dist/web/assets/classDiagram-4FO5ZUOK-DxP4Rh0o.js +0 -1
- package/dist/web/assets/classDiagram-v2-Q7XG4LA2-DxP4Rh0o.js +0 -1
- package/dist/web/assets/stateDiagram-v2-BHNVJYJU-BI8aEZqM.js +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/chart-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/chart-D6WVIyqJ.js","assets/step-CWvwoXpJ.js","assets/band-BEGRCkg7.js","assets/init-BFKUnIhM.js","assets/ordinal-BQ3KlzSu.js","assets/linear-DCKgJuDe.js","assets/defaultLocale-CrowFXzY.js","assets/time-Dqs-aHL0.js","assets/mermaid.core-Cf2CUPpR.js","assets/purify.es-CLGrRn1w.js"])))=>i.map(i=>d[i]);
|
|
2
2
|
function iae(e,t){for(var n=0;n<t.length;n++){const o=t[n];if(typeof o!="string"&&!Array.isArray(o)){for(const r in o)if(r!=="default"&&!(r in e)){const a=Object.getOwnPropertyDescriptor(o,r);a&&Object.defineProperty(e,r,a.get?a:{enumerable:!0,get:()=>o[r]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const r of document.querySelectorAll('link[rel="modulepreload"]'))o(r);new MutationObserver(r=>{for(const a of r)if(a.type==="childList")for(const i of a.addedNodes)i.tagName==="LINK"&&i.rel==="modulepreload"&&o(i)}).observe(document,{childList:!0,subtree:!0});function n(r){const a={};return r.integrity&&(a.integrity=r.integrity),r.referrerPolicy&&(a.referrerPolicy=r.referrerPolicy),r.crossOrigin==="use-credentials"?a.credentials="include":r.crossOrigin==="anonymous"?a.credentials="omit":a.credentials="same-origin",a}function o(r){if(r.ep)return;r.ep=!0;const a=n(r);fetch(r.href,a)}})();var uP=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Qh(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var fK={exports:{}},kz={},pK={exports:{}},Ye={};/**
|
|
3
3
|
* @license React
|
|
4
4
|
* react.production.min.js
|
|
@@ -8466,7 +8466,7 @@ Error generating stack: `+a.message+`
|
|
|
8466
8466
|
+`).split(`
|
|
8467
8467
|
`)),u=l.reduce((h,f)=>h.concat(...f),[]);return[l,u]}return[[],[]]},[e]);return m.useEffect(()=>{const c=(t==null?void 0:t.target)??VB,l=(t==null?void 0:t.actInsideInputWithModifier)??!0;if(e!==null){const u=y=>{var w,g;if(r.current=y.ctrlKey||y.metaKey||y.shiftKey||y.altKey,(!r.current||r.current&&!l)&&NY(y))return!1;const v=UB(y.code,s);if(a.current.add(y[v]),BB(i,a.current,!1)){const M=((g=(w=y.composedPath)==null?void 0:w.call(y))==null?void 0:g[0])||y.target,x=(M==null?void 0:M.nodeName)==="BUTTON"||(M==null?void 0:M.nodeName)==="A";t.preventDefault!==!1&&(r.current||!x)&&y.preventDefault(),o(!0)}},h=y=>{const k=UB(y.code,s);BB(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",u),c==null||c.addEventListener("keyup",h),window.addEventListener("blur",f),window.addEventListener("contextmenu",f),()=>{c==null||c.removeEventListener("keydown",u),c==null||c.removeEventListener("keyup",h),window.removeEventListener("blur",f),window.removeEventListener("contextmenu",f)}}},[e,o]),n}function BB(e,t,n){return e.filter(o=>n||o.length===t.size).some(o=>o.every(r=>t.has(r)))}function UB(e,t){return t.includes(e)?"code":"key"}const rze=()=>{const e=Mt();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=lO(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},u=n.snapGrid??r,h=n.snapToGrid??a;return uf(l,o,h,u)},flowToScreenPosition:t=>{const{transform:n,domNode:o}=e.getState();if(!o)return t;const{x:r,y:a}=o.getBoundingClientRect(),i=BP(t,n);return{x:i.x+r,y:i.y+a}}}),[])};function JY(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)aze(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 aze(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 eQ(e,t){return JY(e,t)}function tQ(e,t){return JY(e,t)}function ad(e,t){return{id:e,type:"select",selected:t}}function Eu(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(ad(a.id,i)))}return o}function WB({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 GB(e){return{id:e.id,type:"remove"}}const KB=e=>yje(e),ize=e=>xY(e);function nQ(e){return m.forwardRef(e)}function ZB(e){const[t,n]=m.useState(BigInt(0)),[o]=m.useState(()=>sze(()=>n(r=>r+BigInt(1))));return sH(()=>{const r=o.get();r.length&&(e(r),o.reset())},[t]),o}function sze(e){let t=[];return{get:()=>t,reset:()=>{t=[]},push:n=>{t.push(n),e()}}}const oQ=m.createContext(null);function cze({children:e}){const t=Mt(),n=m.useCallback(s=>{const{nodes:c=[],setNodes:l,hasDefaultNodes:u,onNodesChange:h,nodeLookup:f,fitViewQueued:y,onNodesChangeMiddlewareMap:k}=t.getState();let v=c;for(const g of s)v=typeof g=="function"?g(v):g;let w=WB({items:v,lookup:f});for(const g of k.values())w=g(w);u&&l(v),w.length>0?h==null||h(w):y&&window.requestAnimationFrame(()=>{const{fitViewQueued:g,nodes:M,setNodes:x}=t.getState();g&&x(M)})},[]),o=ZB(n),r=m.useCallback(s=>{const{edges:c=[],setEdges:l,hasDefaultEdges:u,onEdgesChange:h,edgeLookup:f}=t.getState();let y=c;for(const k of s)y=typeof k=="function"?k(y):k;u?l(y):h&&h(WB({items:y,lookup:f}))},[]),a=ZB(r),i=m.useMemo(()=>({nodeQueue:o,edgeQueue:a}),[]);return p.jsx(oQ.Provider,{value:i,children:e})}function lze(){const e=m.useContext(oQ);if(!e)throw new Error("useBatchContext must be used within a BatchProvider");return e}const dze=e=>!!e.panZoom;function Wz(){const e=rze(),t=Mt(),n=lze(),o=He(dze),r=m.useMemo(()=>{const a=h=>t.getState().nodeLookup.get(h),i=h=>{n.nodeQueue.push(h)},s=h=>{n.edgeQueue.push(h)},c=h=>{var g,M;const{nodeLookup:f,nodeOrigin:y}=t.getState(),k=KB(h)?h:f.get(h.id),v=k.parentId?SY(k.position,k.measured,k.parentId,f,y):k.position,w={...k,position:v,width:((g=k.measured)==null?void 0:g.width)??k.width,height:((M=k.measured)==null?void 0:M.height)??k.height};return d0(w)},l=(h,f,y={replace:!1})=>{i(k=>k.map(v=>{if(v.id===h){const w=typeof f=="function"?f(v):f;return y.replace&&KB(w)?w:{...v,...w}}return v}))},u=(h,f,y={replace:!1})=>{s(k=>k.map(v=>{if(v.id===h){const w=typeof f=="function"?f(v):f;return y.replace&&ize(w)?w:{...v,...w}}return v}))};return{getNodes:()=>t.getState().nodes.map(h=>({...h})),getNode:h=>{var f;return(f=a(h))==null?void 0:f.internals.userNode},getInternalNode:a,getEdges:()=>{const{edges:h=[]}=t.getState();return h.map(f=>({...f}))},getEdge:h=>t.getState().edgeLookup.get(h),setNodes:i,setEdges:s,addNodes:h=>{const f=Array.isArray(h)?h:[h];n.nodeQueue.push(y=>[...y,...f])},addEdges:h=>{const f=Array.isArray(h)?h:[h];n.edgeQueue.push(y=>[...y,...f])},toObject:()=>{const{nodes:h=[],edges:f=[],transform:y}=t.getState(),[k,v,w]=y;return{nodes:h.map(g=>({...g})),edges:f.map(g=>({...g})),viewport:{x:k,y:v,zoom:w}}},deleteElements:async({nodes:h=[],edges:f=[]})=>{const{nodes:y,edges:k,onNodesDelete:v,onEdgesDelete:w,triggerNodeChanges:g,triggerEdgeChanges:M,onDelete:x,onBeforeDelete:b}=t.getState(),{nodes:C,edges:_}=await xje({nodesToRemove:h,edgesToRemove:f,nodes:y,edges:k,onBeforeDelete:b}),S=_.length>0,$=C.length>0;if(S){const j=_.map(GB);w==null||w(_),M(j)}if($){const j=C.map(GB);v==null||v(C),g(j)}return($||S)&&(x==null||x({nodes:C,edges:_})),{deletedNodes:C,deletedEdges:_}},getIntersectingNodes:(h,f=!0,y)=>{const k=_B(h),v=k?h:c(h),w=y!==void 0;return v?(y||t.getState().nodes).filter(g=>{const M=t.getState().nodeLookup.get(g.id);if(M&&!k&&(g.id===h.id||!M.internals.positionAbsolute))return!1;const x=d0(w?g:M),b=Dh(x,v);return f&&b>0||b>=x.width*x.height||b>=v.width*v.height}):[]},isNodeIntersecting:(h,f,y=!0)=>{const v=_B(h)?h:c(h);if(!v)return!1;const w=Dh(v,f);return y&&w>0||w>=f.width*f.height||w>=v.width*v.height},updateNode:l,updateNodeData:(h,f,y={replace:!1})=>{l(h,k=>{const v=typeof f=="function"?f(k):f;return y.replace?{...k,data:v}:{...k,data:{...k.data,...v}}},y)},updateEdge:u,updateEdgeData:(h,f,y={replace:!1})=>{u(h,k=>{const v=typeof f=="function"?f(k):f;return y.replace?{...k,data:v}:{...k,data:{...k.data,...v}}},y)},getNodesBounds:h=>{const{nodeLookup:f,nodeOrigin:y}=t.getState();return mje(h,{nodeLookup:f,nodeOrigin:y})},getHandleConnections:({type:h,id:f,nodeId:y})=>{var k;return Array.from(((k=t.getState().connectionLookup.get(`${y}-${h}${f?`-${f}`:""}`))==null?void 0:k.values())??[])},getNodeConnections:({type:h,handleId:f,nodeId:y})=>{var k;return Array.from(((k=t.getState().connectionLookup.get(`${y}${h?f?`-${h}-${f}`:`-${h}`:""}`))==null?void 0:k.values())??[])},fitView:async h=>{const f=t.getState().fitViewResolver??_je();return t.setState({fitViewQueued:!0,fitViewOptions:h,fitViewResolver:f}),n.nodeQueue.push(y=>[...y]),f.promise}}},[]);return m.useMemo(()=>({...r,...e,viewportInitialized:o}),[o])}const XB=e=>e.selected,uze=typeof window<"u"?window:void 0;function hze({deleteKeyCode:e,multiSelectionKeyCode:t}){const n=Mt(),{deleteElements:o}=Wz(),r=Oh(e,{actInsideInputWithModifier:!1}),a=Oh(t,{target:uze});m.useEffect(()=>{if(r){const{edges:i,nodes:s}=n.getState();o({nodes:s.filter(XB),edges:i.filter(XB)}),n.setState({nodesSelectionActive:!1})}},[r]),m.useEffect(()=>{n.setState({multiSelectionActive:a})},[a])}function fze(e){const t=Mt();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=dO(e.current);(o.height===0||o.width===0)&&((s=(i=t.getState()).onError)==null||s.call(i,"004",Hr.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 Gz={position:"absolute",width:"100%",height:"100%",top:0,left:0},pze=e=>({userSelectionActive:e.userSelectionActive,lib:e.lib,connectionInProgress:e.connection.inProgress});function yze({onPaneContextMenu:e,zoomOnScroll:t=!0,zoomOnPinch:n=!0,panOnScroll:o=!1,panOnScrollSpeed:r=.5,panOnScrollMode:a=kd.Free,zoomOnDoubleClick:i=!0,panOnDrag:s=!0,defaultViewport:c,translateExtent:l,minZoom:u,maxZoom:h,zoomActivationKeyCode:f,preventScrolling:y=!0,children:k,noWheelClassName:v,noPanClassName:w,onViewportChange:g,isControlledViewport:M,paneClickDistance:x,selectionOnDrag:b}){const C=Mt(),_=m.useRef(null),{userSelectionActive:S,lib:$,connectionInProgress:j}=He(pze,Nt),N=Oh(f),A=m.useRef();fze(_);const R=m.useCallback(Y=>{g==null||g({x:Y[0],y:Y[1],zoom:Y[2]}),M||C.setState({transform:Y})},[g,M]);return m.useEffect(()=>{if(_.current){A.current=sPe({domNode:_.current,minZoom:u,maxZoom:h,translateExtent:l,viewport:c,onDraggingChange:H=>C.setState(O=>O.paneDragging===H?O:{paneDragging:H}),onPanZoomStart:(H,O)=>{const{onViewportChangeStart:P,onMoveStart:I}=C.getState();I==null||I(H,O),P==null||P(O)},onPanZoom:(H,O)=>{const{onViewportChange:P,onMove:I}=C.getState();I==null||I(H,O),P==null||P(O)},onPanZoomEnd:(H,O)=>{const{onViewportChangeEnd:P,onMoveEnd:I}=C.getState();I==null||I(H,O),P==null||P(O)}});const{x:Y,y:z,zoom:V}=A.current.getViewport();return C.setState({panZoom:A.current,transform:[Y,z,V],domNode:_.current.closest(".react-flow")}),()=>{var H;(H=A.current)==null||H.destroy()}}},[]),m.useEffect(()=>{var Y;(Y=A.current)==null||Y.update({onPaneContextMenu:e,zoomOnScroll:t,zoomOnPinch:n,panOnScroll:o,panOnScrollSpeed:r,panOnScrollMode:a,zoomOnDoubleClick:i,panOnDrag:s,zoomActivationKeyPressed:N,preventScrolling:y,noPanClassName:w,userSelectionActive:S,noWheelClassName:v,lib:$,onTransformChange:R,connectionInProgress:j,selectionOnDrag:b,paneClickDistance:x})},[e,t,n,o,r,a,i,s,N,y,w,S,v,$,R,j,b,x]),p.jsx("div",{className:"react-flow__renderer",ref:_,style:Gz,children:k})}const mze=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function kze(){const{userSelectionActive:e,userSelectionRect:t}=He(mze,Nt);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 uT=(e,t)=>n=>{n.target===t.current&&(e==null||e(n))},gze=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,connectionInProgress:e.connection.inProgress,dragging:e.paneDragging});function vze({isSelecting:e,selectionKeyPressed:t,selectionMode:n=c0.Full,panOnDrag:o,paneClickDistance:r,selectionOnDrag:a,onSelectionStart:i,onSelectionEnd:s,onPaneClick:c,onPaneContextMenu:l,onPaneScroll:u,onPaneMouseEnter:h,onPaneMouseMove:f,onPaneMouseLeave:y,children:k}){const v=Mt(),{userSelectionActive:w,elementsSelectable:g,dragging:M,connectionInProgress:x}=He(gze,Nt),b=g&&(e||w),C=m.useRef(null),_=m.useRef(),S=m.useRef(new Set),$=m.useRef(new Set),j=m.useRef(!1),N=P=>{if(j.current||x){j.current=!1;return}c==null||c(P),v.getState().resetSelectedElements(),v.setState({nodesSelectionActive:!1})},A=P=>{if(Array.isArray(o)&&(o!=null&&o.includes(2))){P.preventDefault();return}l==null||l(P)},R=u?P=>u(P):void 0,Y=P=>{j.current&&(P.stopPropagation(),j.current=!1)},z=P=>{var J,ne;const{domNode:I}=v.getState();if(_.current=I==null?void 0:I.getBoundingClientRect(),!_.current)return;const L=P.target===C.current;if(!L&&!!P.target.closest(".nokey")||!e||!(a&&L||t)||P.button!==0||!P.isPrimary)return;(ne=(J=P.target)==null?void 0:J.setPointerCapture)==null||ne.call(J,P.pointerId),j.current=!1;const{x:E,y:ee}=Zo(P.nativeEvent,_.current);v.setState({userSelectionRect:{width:0,height:0,startX:E,startY:ee,x:E,y:ee}}),L||(P.stopPropagation(),P.preventDefault())},V=P=>{const{userSelectionRect:I,transform:L,nodeLookup:U,edgeLookup:D,connectionLookup:E,triggerNodeChanges:ee,triggerEdgeChanges:J,defaultEdgeOptions:ne,resetSelectedElements:oe}=v.getState();if(!_.current||!I)return;const{x:te,y:ce}=Zo(P.nativeEvent,_.current),{startX:ge,startY:ae}=I;if(!j.current){const Ve=t?0:r;if(Math.hypot(te-ge,ce-ae)<=Ve)return;oe(),i==null||i(P)}j.current=!0;const se={startX:ge,startY:ae,x:te<ge?te:ge,y:ce<ae?ce:ae,width:Math.abs(te-ge),height:Math.abs(ce-ae)},re=S.current,Pe=$.current;S.current=new Set(cO(U,se,L,n===c0.Partial,!0).map(Ve=>Ve.id)),$.current=new Set;const Be=(ne==null?void 0:ne.selectable)??!0;for(const Ve of S.current){const ht=E.get(Ve);if(ht)for(const{edgeId:Gt}of ht.values()){const Et=D.get(Gt);Et&&(Et.selectable??Be)&&$.current.add(Gt)}}if(!CB(re,S.current)){const Ve=Eu(U,S.current,!0);ee(Ve)}if(!CB(Pe,$.current)){const Ve=Eu(D,$.current);J(Ve)}v.setState({userSelectionRect:se,userSelectionActive:!0,nodesSelectionActive:!1})},H=P=>{var I,L;P.button===0&&((L=(I=P.target)==null?void 0:I.releasePointerCapture)==null||L.call(I,P.pointerId),!w&&P.target===C.current&&v.getState().userSelectionRect&&(N==null||N(P)),v.setState({userSelectionActive:!1,userSelectionRect:null}),j.current&&(s==null||s(P),v.setState({nodesSelectionActive:S.current.size>0})))},O=o===!0||Array.isArray(o)&&o.includes(0);return p.jsxs("div",{className:Wt(["react-flow__pane",{draggable:O,dragging:M,selection:e}]),onClick:b?void 0:uT(N,C),onContextMenu:uT(A,C),onWheel:uT(R,C),onPointerEnter:b?void 0:h,onPointerMove:b?V:f,onPointerUp:b?H:void 0,onPointerDownCapture:b?z:void 0,onClickCapture:b?Y:void 0,onPointerLeave:y,ref:C,style:Gz,children:[k,p.jsx(kze,{})]})}function cH({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",Hr.error012(e));return}t.setState({nodesSelectionActive:!1}),l.selected?(n||l.selected&&i)&&(a({nodes:[l],edges:[]}),requestAnimationFrame(()=>{var u;return(u=o==null?void 0:o.current)==null?void 0:u.blur()})):r([e])}function rQ({nodeRef:e,disabled:t=!1,noDragClassName:n,handleSelector:o,nodeId:r,isSelectable:a,nodeClickDistance:i}){const s=Mt(),[c,l]=m.useState(!1),u=m.useRef();return m.useEffect(()=>{u.current=Gje({getStoreItems:()=>s.getState(),onNodeMouseDown:h=>{cH({id:h,store:s,nodeRef:e})},onDragStart:()=>{l(!0)},onDragStop:()=>{l(!1)}})},[]),m.useEffect(()=>{if(!(t||!e.current||!u.current))return u.current.update({noDragClassName:n,handleSelector:o,domNode:e.current,isSelectable:a,nodeId:r,nodeClickDistance:i}),()=>{var h;(h=u.current)==null||h.destroy()}},[n,o,t,a,e,r,i]),c}const xze=e=>t=>t.selected&&(t.draggable||e&&typeof t.draggable>"u");function aQ(){const e=Mt();return m.useCallback(n=>{const{nodeExtent:o,snapToGrid:r,snapGrid:a,nodesDraggable:i,onError:s,updateNodePositions:c,nodeLookup:l,nodeOrigin:u}=e.getState(),h=new Map,f=xze(i),y=r?a[0]:5,k=r?a[1]:5,v=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+v,y:g.internals.positionAbsolute.y+w};r&&(M=df(M,a));const{position:x,positionAbsolute:b}=wY({nodeId:g.id,nextPosition:M,nodeLookup:l,nodeExtent:o,nodeOrigin:u,onError:s});g.position=x,g.internals.positionAbsolute=b,h.set(g.id,g)}c(h)},[])}const mO=m.createContext(null),wze=mO.Provider;mO.Consumer;const iQ=()=>m.useContext(mO),Mze=e=>({connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName,rfId:e.rfId}),bze=(e,t,n)=>o=>{const{connectionClickStartHandle:r,connectionMode:a,connection:i}=o,{fromHandle:s,toHandle:c,isValid:l}=i,u=(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:u,clickConnecting:(r==null?void 0:r.nodeId)===e&&(r==null?void 0:r.id)===t&&(r==null?void 0:r.type)===n,isPossibleEndHandle:a===s0.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:u&&l}};function _ze({type:e="source",position:t=me.Top,isValidConnection:n,isConnectable:o=!0,isConnectableStart:r=!0,isConnectableEnd:a=!0,id:i,onConnect:s,children:c,className:l,onMouseDown:u,onTouchStart:h,...f},y){var V,H;const k=i||null,v=e==="target",w=Mt(),g=iQ(),{connectOnClick:M,noPanClassName:x,rfId:b}=He(Mze,Nt),{connectingFrom:C,connectingTo:_,clickConnecting:S,isPossibleEndHandle:$,connectionInProcess:j,clickConnectionInProcess:N,valid:A}=He(bze(g,k,e),Nt);g||(H=(V=w.getState()).onError)==null||H.call(V,"010",Hr.error010());const R=O=>{const{defaultEdgeOptions:P,onConnect:I,hasDefaultEdges:L}=w.getState(),U={...P,...O};if(L){const{edges:D,setEdges:E}=w.getState();E(Eje(U,D))}I==null||I(U),s==null||s(U)},Y=O=>{if(!g)return;const P=IY(O.nativeEvent);if(r&&(P&&O.button===0||!P)){const I=w.getState();iH.onPointerDown(O.nativeEvent,{handleDomNode:O.currentTarget,autoPanOnConnect:I.autoPanOnConnect,connectionMode:I.connectionMode,connectionRadius:I.connectionRadius,domNode:I.domNode,nodeLookup:I.nodeLookup,lib:I.lib,isTarget:v,handleId:k,nodeId:g,flowId:I.rfId,panBy:I.panBy,cancelConnection:I.cancelConnection,onConnectStart:I.onConnectStart,onConnectEnd:(...L)=>{var U,D;return(D=(U=w.getState()).onConnectEnd)==null?void 0:D.call(U,...L)},updateConnection:I.updateConnection,onConnect:R,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:I.autoPanSpeed,dragThreshold:I.connectionDragThreshold})}P?u==null||u(O):h==null||h(O)},z=O=>{const{onClickConnectStart:P,onClickConnectEnd:I,connectionClickStartHandle:L,connectionMode:U,isValidConnection:D,lib:E,rfId:ee,nodeLookup:J,connection:ne}=w.getState();if(!g||!L&&!r)return;if(!L){P==null||P(O.nativeEvent,{nodeId:g,handleId:k,handleType:e}),w.setState({connectionClickStartHandle:{nodeId:g,type:e,id:k}});return}const oe=LY(O.target),te=n||D,{connection:ce,isValid:ge}=iH.isValid(O.nativeEvent,{handle:{nodeId:g,id:k,type:e},connectionMode:U,fromNodeId:L.nodeId,fromHandleId:L.id||null,fromType:L.type,isValidConnection:te,flowId:ee,doc:oe,lib:E,nodeLookup:J});ge&&ce&&R(ce);const ae=structuredClone(ne);delete ae.inProgress,ae.toPosition=ae.toHandle?ae.toHandle.position:null,I==null||I(O,ae),w.setState({connectionClickStartHandle:null})};return p.jsx("div",{"data-handleid":k,"data-nodeid":g,"data-handlepos":t,"data-id":`${b}-${g}-${k}-${e}`,className:Wt(["react-flow__handle",`react-flow__handle-${t}`,"nodrag",x,l,{source:!v,target:v,connectable:o,connectablestart:r,connectableend:a,clickconnecting:S,connectingfrom:C,connectingto:_,valid:A,connectionindicator:o&&(!j||$)&&(j||N?a:r)}]),onMouseDown:Y,onTouchStart:Y,onClick:M?z:void 0,ref:y,...f,children:c})}const ft=m.memo(nQ(_ze));function Cze({data:e,isConnectable:t,sourcePosition:n=me.Bottom}){return p.jsxs(p.Fragment,{children:[e==null?void 0:e.label,p.jsx(ft,{type:"source",position:n,isConnectable:t})]})}function Sze({data:e,isConnectable:t,targetPosition:n=me.Top,sourcePosition:o=me.Bottom}){return p.jsxs(p.Fragment,{children:[p.jsx(ft,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label,p.jsx(ft,{type:"source",position:o,isConnectable:t})]})}function Lze(){return null}function Nze({data:e,isConnectable:t,targetPosition:n=me.Top}){return p.jsxs(p.Fragment,{children:[p.jsx(ft,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label]})}const UP={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},YB={input:Cze,default:Sze,output:Nze,group:Lze};function Ize(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 Aze=e=>{const{width:t,height:n,x:o,y:r}=lf(e.nodeLookup,{filter:a=>!!a.selected});return{width:Ko(t)?t:null,height:Ko(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 Eze({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:n}){const o=Mt(),{width:r,height:a,transformString:i,userSelectionActive:s}=He(Aze,Nt),c=aQ(),l=m.useRef(null);m.useEffect(()=>{var y;n||(y=l.current)==null||y.focus({preventScroll:!0})},[n]);const u=!s&&r!==null&&a!==null;if(rQ({nodeRef:l,disabled:!u}),!u)return null;const h=e?y=>{const k=o.getState().nodes.filter(v=>v.selected);e(y,k)}:void 0,f=y=>{Object.prototype.hasOwnProperty.call(UP,y.key)&&(y.preventDefault(),c({direction:UP[y.key],factor:y.shiftKey?4:1}))};return p.jsx("div",{className:Wt(["react-flow__nodesselection","react-flow__container",t]),style:{transform:i},children:p.jsx("div",{ref:l,className:"react-flow__nodesselection-rect",onContextMenu:h,tabIndex:n?void 0:-1,onKeyDown:n?void 0:f,style:{width:r,height:a}})})}const QB=typeof window<"u"?window:void 0,$ze=e=>({nodesSelectionActive:e.nodesSelectionActive,userSelectionActive:e.userSelectionActive});function sQ({children:e,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:o,onPaneMouseLeave:r,onPaneContextMenu:a,onPaneScroll:i,paneClickDistance:s,deleteKeyCode:c,selectionKeyCode:l,selectionOnDrag:u,selectionMode:h,onSelectionStart:f,onSelectionEnd:y,multiSelectionKeyCode:k,panActivationKeyCode:v,zoomActivationKeyCode:w,elementsSelectable:g,zoomOnScroll:M,zoomOnPinch:x,panOnScroll:b,panOnScrollSpeed:C,panOnScrollMode:_,zoomOnDoubleClick:S,panOnDrag:$,defaultViewport:j,translateExtent:N,minZoom:A,maxZoom:R,preventScrolling:Y,onSelectionContextMenu:z,noWheelClassName:V,noPanClassName:H,disableKeyboardA11y:O,onViewportChange:P,isControlledViewport:I}){const{nodesSelectionActive:L,userSelectionActive:U}=He($ze,Nt),D=Oh(l,{target:QB}),E=Oh(v,{target:QB}),ee=E||$,J=E||b,ne=u&&ee!==!0,oe=D||U||ne;return hze({deleteKeyCode:c,multiSelectionKeyCode:k}),p.jsx(yze,{onPaneContextMenu:a,elementsSelectable:g,zoomOnScroll:M,zoomOnPinch:x,panOnScroll:J,panOnScrollSpeed:C,panOnScrollMode:_,zoomOnDoubleClick:S,panOnDrag:!D&&ee,defaultViewport:j,translateExtent:N,minZoom:A,maxZoom:R,zoomActivationKeyCode:w,preventScrolling:Y,noWheelClassName:V,noPanClassName:H,onViewportChange:P,isControlledViewport:I,paneClickDistance:s,selectionOnDrag:ne,children:p.jsxs(vze,{onSelectionStart:f,onSelectionEnd:y,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:o,onPaneMouseLeave:r,onPaneContextMenu:a,onPaneScroll:i,panOnDrag:ee,isSelecting:!!oe,selectionMode:h,selectionKeyPressed:D,paneClickDistance:s,selectionOnDrag:ne,children:[e,L&&p.jsx(Eze,{onSelectionContextMenu:z,noPanClassName:H,disableKeyboardA11y:O})]})})}sQ.displayName="FlowRenderer";const jze=m.memo(sQ),Pze=e=>t=>e?cO(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 zze(e){return He(m.useCallback(Pze(e),[e]),Nt)}const Rze=e=>e.updateNodeInternals;function Tze(){const e=He(Rze),[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 Dze({node:e,nodeType:t,hasDimensions:n,resizeObserver:o}){const r=Mt(),a=m.useRef(null),i=m.useRef(null),s=m.useRef(e.sourcePosition),c=m.useRef(e.targetPosition),l=m.useRef(t),u=n&&!!e.internals.handleBounds;return m.useEffect(()=>{a.current&&!e.hidden&&(!u||i.current!==a.current)&&(i.current&&(o==null||o.unobserve(i.current)),o==null||o.observe(a.current),i.current=a.current)},[u,e.hidden]),m.useEffect(()=>()=>{i.current&&(o==null||o.unobserve(i.current),i.current=null)},[]),m.useEffect(()=>{if(a.current){const h=l.current!==t,f=s.current!==e.sourcePosition,y=c.current!==e.targetPosition;(h||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 Hze({id:e,onClick:t,onMouseEnter:n,onMouseMove:o,onMouseLeave:r,onContextMenu:a,onDoubleClick:i,nodesDraggable:s,elementsSelectable:c,nodesConnectable:l,nodesFocusable:u,resizeObserver:h,noDragClassName:f,noPanClassName:y,disableKeyboardA11y:k,rfId:v,nodeTypes:w,nodeClickDistance:g,onError:M}){const{node:x,internals:b,isParent:C}=He(te=>{const ce=te.nodeLookup.get(e),ge=te.parentLookup.has(e);return{node:ce,internals:ce.internals,isParent:ge}},Nt);let _=x.type||"default",S=(w==null?void 0:w[_])||YB[_];S===void 0&&(M==null||M("003",Hr.error003(_)),_="default",S=(w==null?void 0:w.default)||YB.default);const $=!!(x.draggable||s&&typeof x.draggable>"u"),j=!!(x.selectable||c&&typeof x.selectable>"u"),N=!!(x.connectable||l&&typeof x.connectable>"u"),A=!!(x.focusable||u&&typeof x.focusable>"u"),R=Mt(),Y=CY(x),z=Dze({node:x,nodeType:_,hasDimensions:Y,resizeObserver:h}),V=rQ({nodeRef:z,disabled:x.hidden||!$,noDragClassName:f,handleSelector:x.dragHandle,nodeId:e,isSelectable:j,nodeClickDistance:g}),H=aQ();if(x.hidden)return null;const O=_a(x),P=Ize(x),I=j||$||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,ee=i?te=>i(te,{...b.userNode}):void 0,J=te=>{const{selectNodesOnDrag:ce,nodeDragThreshold:ge}=R.getState();j&&(!ce||!$||ge>0)&&cH({id:e,store:R,nodeRef:z}),t&&t(te,{...b.userNode})},ne=te=>{if(!(NY(te.nativeEvent)||k)){if(mY.includes(te.key)&&j){const ce=te.key==="Escape";cH({id:e,store:R,unselect:ce,nodeRef:z})}else if($&&x.selected&&Object.prototype.hasOwnProperty.call(UP,te.key)){te.preventDefault();const{ariaLabelConfig:ce}=R.getState();R.setState({ariaLiveMessage:ce["node.a11yDescription.ariaLiveMessage"]({direction:te.key.replace("Arrow","").toLowerCase(),x:~~b.positionAbsolute.x,y:~~b.positionAbsolute.y})}),H({direction:UP[te.key],factor:te.shiftKey?4:1})}}},oe=()=>{var Pe;if(k||!((Pe=z.current)!=null&&Pe.matches(":focus-visible")))return;const{transform:te,width:ce,height:ge,autoPanOnNodeFocus:ae,setCenter:se}=R.getState();if(!ae)return;cO(new Map([[e,x]]),{x:0,y:0,width:ce,height:ge},te,!0).length>0||se(x.position.x+O.width/2,x.position.y+O.height/2,{zoom:te[2]})};return p.jsx("div",{className:Wt(["react-flow__node",`react-flow__node-${_}`,{[y]:$},x.className,{selected:x.selected,selectable:j,parent:C,draggable:$,dragging:V}]),ref:z,style:{zIndex:b.z,transform:`translate(${b.positionAbsolute.x}px,${b.positionAbsolute.y}px)`,pointerEvents:I?"all":"none",visibility:Y?"visible":"hidden",...x.style,...P},"data-id":e,"data-testid":`rf__node-${e}`,onMouseEnter:L,onMouseMove:U,onMouseLeave:D,onContextMenu:E,onClick:J,onDoubleClick:ee,onKeyDown:A?ne:void 0,tabIndex:A?0:void 0,onFocus:A?oe:void 0,role:x.ariaRole??(A?"group":void 0),"aria-roledescription":"node","aria-describedby":k?void 0:`${XY}-${v}`,"aria-label":x.ariaLabel,...x.domAttributes,children:p.jsx(wze,{value:e,children:p.jsx(S,{id:e,data:x.data,type:_,positionAbsoluteX:b.positionAbsolute.x,positionAbsoluteY:b.positionAbsolute.y,selected:x.selected??!1,selectable:j,draggable:$,deletable:x.deletable??!0,isConnectable:N,sourcePosition:x.sourcePosition,targetPosition:x.targetPosition,dragging:V,dragHandle:x.dragHandle,zIndex:b.z,parentId:x.parentId,...O})})})}var qze=m.memo(Hze);const Oze=e=>({nodesDraggable:e.nodesDraggable,nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,onError:e.onError});function cQ(e){const{nodesDraggable:t,nodesConnectable:n,nodesFocusable:o,elementsSelectable:r,onError:a}=He(Oze,Nt),i=zze(e.onlyRenderVisibleElements),s=Tze();return p.jsx("div",{className:"react-flow__nodes",style:Gz,children:i.map(c=>p.jsx(qze,{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))})}cQ.displayName="NodeRenderer";const Fze=m.memo(cQ);function Vze(e){return He(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&&Nje({sourceNode:a,targetNode:i,width:n.width,height:n.height,transform:n.transform})&&o.push(r.id)}return o},[e]),Nt)}const Bze=({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"})},Uze=({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"})},JB={[Th.Arrow]:Bze,[Th.ArrowClosed]:Uze};function Wze(e){const t=Mt();return m.useMemo(()=>{var r,a;return Object.prototype.hasOwnProperty.call(JB,e)?JB[e]:((a=(r=t.getState()).onError)==null||a.call(r,"009",Hr.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=Wze(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},lQ=({defaultColor:e,rfId:t})=>{const n=He(a=>a.edges),o=He(a=>a.defaultEdgeOptions),r=m.useMemo(()=>Rje(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};lQ.displayName="MarkerDefinitions";var Kze=m.memo(lQ);function dQ({x:e,y:t,label:n,labelStyle:o,labelShowBg:r=!0,labelBgStyle:a,labelBgPadding:i=[2,4],labelBgBorderRadius:s=2,children:c,className:l,...u}){const[h,f]=m.useState({x:1,y:0,width:0,height:0}),y=Wt(["react-flow__edge-textwrapper",l]),k=m.useRef(null);return m.useEffect(()=>{if(k.current){const v=k.current.getBBox();f({x:v.x,y:v.y,width:v.width,height:v.height})}},[n]),n?p.jsxs("g",{transform:`translate(${e-h.width/2} ${t-h.height/2})`,className:y,visibility:h.width?"visible":"hidden",...u,children:[r&&p.jsx("rect",{width:h.width+2*i[0],x:-i[0],y:-i[1],height:h.height+2*i[1],className:"react-flow__edge-textbg",style:a,rx:s,ry:s}),p.jsx("text",{className:"react-flow__edge-text",y:h.height/2,dy:"0.3em",ref:k,style:o,children:n}),c]}):null}dQ.displayName="EdgeText";const Zze=m.memo(dQ);function hf({path:e,labelX:t,labelY:n,label:o,labelStyle:r,labelShowBg:a,labelBgStyle:i,labelBgPadding:s,labelBgBorderRadius:c,interactionWidth:l=20,...u}){return p.jsxs(p.Fragment,{children:[p.jsx("path",{...u,d:e,fill:"none",className:Wt(["react-flow__edge-path",u.className])}),l?p.jsx("path",{d:e,fill:"none",strokeOpacity:0,strokeWidth:l,className:"react-flow__edge-interaction"}):null,o&&Ko(t)&&Ko(n)?p.jsx(Zze,{x:t,y:n,label:o,labelStyle:r,labelShowBg:a,labelBgStyle:i,labelBgPadding:s,labelBgBorderRadius:c}):null]})}function eU({pos:e,x1:t,y1:n,x2:o,y2:r}){return e===me.Left||e===me.Right?[.5*(t+o),n]:[t,.5*(n+r)]}function uQ({sourceX:e,sourceY:t,sourcePosition:n=me.Bottom,targetX:o,targetY:r,targetPosition:a=me.Top}){const[i,s]=eU({pos:n,x1:e,y1:t,x2:o,y2:r}),[c,l]=eU({pos:a,x1:o,y1:r,x2:e,y2:t}),[u,h,f,y]=AY({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}`,u,h,f,y]}function hQ(e){return m.memo(({id:t,sourceX:n,sourceY:o,targetX:r,targetY:a,sourcePosition:i,targetPosition:s,label:c,labelStyle:l,labelShowBg:u,labelBgStyle:h,labelBgPadding:f,labelBgBorderRadius:y,style:k,markerEnd:v,markerStart:w,interactionWidth:g})=>{const[M,x,b]=uQ({sourceX:n,sourceY:o,sourcePosition:i,targetX:r,targetY:a,targetPosition:s}),C=e.isInternal?void 0:t;return p.jsx(hf,{id:C,path:M,labelX:x,labelY:b,label:c,labelStyle:l,labelShowBg:u,labelBgStyle:h,labelBgPadding:f,labelBgBorderRadius:y,style:k,markerEnd:v,markerStart:w,interactionWidth:g})})}const Xze=hQ({isInternal:!1}),fQ=hQ({isInternal:!0});Xze.displayName="SimpleBezierEdge";fQ.displayName="SimpleBezierEdgeInternal";function pQ(e){return m.memo(({id:t,sourceX:n,sourceY:o,targetX:r,targetY:a,label:i,labelStyle:s,labelShowBg:c,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:h,style:f,sourcePosition:y=me.Bottom,targetPosition:k=me.Top,markerEnd:v,markerStart:w,pathOptions:g,interactionWidth:M})=>{const[x,b,C]=qh({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(hf,{id:_,path:x,labelX:b,labelY:C,label:i,labelStyle:s,labelShowBg:c,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:h,style:f,markerEnd:v,markerStart:w,interactionWidth:M})})}const yQ=pQ({isInternal:!1}),mQ=pQ({isInternal:!0});yQ.displayName="SmoothStepEdge";mQ.displayName="SmoothStepEdgeInternal";function kQ(e){return m.memo(({id:t,...n})=>{var r;const o=e.isInternal?void 0:t;return p.jsx(yQ,{...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 Yze=kQ({isInternal:!1}),gQ=kQ({isInternal:!0});Yze.displayName="StepEdge";gQ.displayName="StepEdgeInternal";function vQ(e){return m.memo(({id:t,sourceX:n,sourceY:o,targetX:r,targetY:a,label:i,labelStyle:s,labelShowBg:c,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:h,style:f,markerEnd:y,markerStart:k,interactionWidth:v})=>{const[w,g,M]=$Y({sourceX:n,sourceY:o,targetX:r,targetY:a}),x=e.isInternal?void 0:t;return p.jsx(hf,{id:x,path:w,labelX:g,labelY:M,label:i,labelStyle:s,labelShowBg:c,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:h,style:f,markerEnd:y,markerStart:k,interactionWidth:v})})}const Qze=vQ({isInternal:!1}),xQ=vQ({isInternal:!0});Qze.displayName="StraightEdge";xQ.displayName="StraightEdgeInternal";function wQ(e){return m.memo(({id:t,sourceX:n,sourceY:o,targetX:r,targetY:a,sourcePosition:i=me.Bottom,targetPosition:s=me.Top,label:c,labelStyle:l,labelShowBg:u,labelBgStyle:h,labelBgPadding:f,labelBgBorderRadius:y,style:k,markerEnd:v,markerStart:w,pathOptions:g,interactionWidth:M})=>{const[x,b,C]=Fz({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(hf,{id:_,path:x,labelX:b,labelY:C,label:c,labelStyle:l,labelShowBg:u,labelBgStyle:h,labelBgPadding:f,labelBgBorderRadius:y,style:k,markerEnd:v,markerStart:w,interactionWidth:M})})}const Jze=wQ({isInternal:!1}),MQ=wQ({isInternal:!0});Jze.displayName="BezierEdge";MQ.displayName="BezierEdgeInternal";const tU={default:MQ,straight:xQ,step:gQ,smoothstep:mQ,simplebezier:fQ},nU={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null},eRe=(e,t,n)=>n===me.Left?e-t:n===me.Right?e+t:e,tRe=(e,t,n)=>n===me.Top?e-t:n===me.Bottom?e+t:e,oU="react-flow__edgeupdater";function rU({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:Wt([oU,`${oU}-${s}`]),cx:eRe(t,o,e),cy:tRe(n,o,e),r:o,stroke:"transparent",fill:"transparent"})}function nRe({isReconnectable:e,reconnectRadius:t,edge:n,sourceX:o,sourceY:r,targetX:a,targetY:i,sourcePosition:s,targetPosition:c,onReconnect:l,onReconnectStart:u,onReconnectEnd:h,setReconnecting:f,setUpdateHover:y}){const k=Mt(),v=(b,C)=>{if(b.button!==0)return;const{autoPanOnConnect:_,domNode:S,connectionMode:$,connectionRadius:j,lib:N,onConnectStart:A,cancelConnection:R,nodeLookup:Y,rfId:z,panBy:V,updateConnection:H}=k.getState(),O=C.type==="target",P=(U,D)=>{f(!1),h==null||h(U,n,C.type,D)},I=U=>l==null?void 0:l(n,U),L=(U,D)=>{f(!0),u==null||u(b,n,C.type),A==null||A(U,D)};iH.onPointerDown(b.nativeEvent,{autoPanOnConnect:_,connectionMode:$,connectionRadius:j,domNode:S,handleId:C.id,nodeId:C.nodeId,nodeLookup:Y,isTarget:O,edgeUpdaterType:C.type,lib:N,flowId:z,cancelConnection:R,panBy:V,isValidConnection:(...U)=>{var D,E;return((E=(D=k.getState()).isValidConnection)==null?void 0:E.call(D,...U))??!0},onConnect:I,onConnectStart:L,onConnectEnd:(...U)=>{var D,E;return(E=(D=k.getState()).onConnectEnd)==null?void 0:E.call(D,...U)},onReconnectEnd:P,updateConnection:H,getTransform:()=>k.getState().transform,getFromHandle:()=>k.getState().connection.fromHandle,dragThreshold:k.getState().connectionDragThreshold,handleDomNode:b.currentTarget})},w=b=>v(b,{nodeId:n.target,id:n.targetHandle??null,type:"target"}),g=b=>v(b,{nodeId:n.source,id:n.sourceHandle??null,type:"source"}),M=()=>y(!0),x=()=>y(!1);return p.jsxs(p.Fragment,{children:[(e===!0||e==="source")&&p.jsx(rU,{position:s,centerX:o,centerY:r,radius:t,onMouseDown:w,onMouseEnter:M,onMouseOut:x,type:"source"}),(e===!0||e==="target")&&p.jsx(rU,{position:c,centerX:a,centerY:i,radius:t,onMouseDown:g,onMouseEnter:M,onMouseOut:x,type:"target"})]})}function oRe({id:e,edgesFocusable:t,edgesReconnectable:n,elementsSelectable:o,onClick:r,onDoubleClick:a,onContextMenu:i,onMouseEnter:s,onMouseMove:c,onMouseLeave:l,reconnectRadius:u,onReconnect:h,onReconnectStart:f,onReconnectEnd:y,rfId:k,edgeTypes:v,noPanClassName:w,onError:g,disableKeyboardA11y:M}){let x=He(se=>se.edgeLookup.get(e));const b=He(se=>se.defaultEdgeOptions);x=b?{...b,...x}:x;let C=x.type||"default",_=(v==null?void 0:v[C])||tU[C];_===void 0&&(g==null||g("011",Hr.error011(C)),C="default",_=(v==null?void 0:v.default)||tU.default);const S=!!(x.focusable||t&&typeof x.focusable>"u"),$=typeof h<"u"&&(x.reconnectable||n&&typeof x.reconnectable>"u"),j=!!(x.selectable||o&&typeof x.selectable>"u"),N=m.useRef(null),[A,R]=m.useState(!1),[Y,z]=m.useState(!1),V=Mt(),{zIndex:H,sourceX:O,sourceY:P,targetX:I,targetY:L,sourcePosition:U,targetPosition:D}=He(m.useCallback(se=>{const re=se.nodeLookup.get(x.source),Pe=se.nodeLookup.get(x.target);if(!re||!Pe)return{zIndex:x.zIndex,...nU};const Be=zje({id:e,sourceNode:re,targetNode:Pe,sourceHandle:x.sourceHandle||null,targetHandle:x.targetHandle||null,connectionMode:se.connectionMode,onError:g});return{zIndex:Lje({selected:x.selected,zIndex:x.zIndex,sourceNode:re,targetNode:Pe,elevateOnSelect:se.elevateEdgesOnSelect,zIndexMode:se.zIndexMode}),...Be||nU}},[x.source,x.target,x.sourceHandle,x.targetHandle,x.selected,x.zIndex]),Nt),E=m.useMemo(()=>x.markerStart?`url('#${rH(x.markerStart,k)}')`:void 0,[x.markerStart,k]),ee=m.useMemo(()=>x.markerEnd?`url('#${rH(x.markerEnd,k)}')`:void 0,[x.markerEnd,k]);if(x.hidden||O===null||P===null||I===null||L===null)return null;const J=se=>{var Ve;const{addSelectedEdges:re,unselectNodesAndEdges:Pe,multiSelectionActive:Be}=V.getState();j&&(V.setState({nodesSelectionActive:!1}),x.selected&&Be?(Pe({nodes:[],edges:[x]}),(Ve=N.current)==null||Ve.blur()):re([e])),r&&r(se,x)},ne=a?se=>{a(se,{...x})}:void 0,oe=i?se=>{i(se,{...x})}:void 0,te=s?se=>{s(se,{...x})}:void 0,ce=c?se=>{c(se,{...x})}:void 0,ge=l?se=>{l(se,{...x})}:void 0,ae=se=>{var re;if(!M&&mY.includes(se.key)&&j){const{unselectNodesAndEdges:Pe,addSelectedEdges:Be}=V.getState();se.key==="Escape"?((re=N.current)==null||re.blur(),Pe({edges:[x]})):Be([e])}};return p.jsx("svg",{style:{zIndex:H},children:p.jsxs("g",{className:Wt(["react-flow__edge",`react-flow__edge-${C}`,x.className,w,{selected:x.selected,animated:x.animated,inactive:!j&&!r,updating:A,selectable:j}]),onClick:J,onDoubleClick:ne,onContextMenu:oe,onMouseEnter:te,onMouseMove:ce,onMouseLeave:ge,onKeyDown:S?ae:void 0,tabIndex:S?0:void 0,role:x.ariaRole??(S?"group":"img"),"aria-roledescription":"edge","data-id":e,"data-testid":`rf__edge-${e}`,"aria-label":x.ariaLabel===null?void 0:x.ariaLabel||`Edge from ${x.source} to ${x.target}`,"aria-describedby":S?`${YY}-${k}`:void 0,ref:N,...x.domAttributes,children:[!Y&&p.jsx(_,{id:e,source:x.source,target:x.target,type:x.type,selected:x.selected,animated:x.animated,selectable:j,deletable:x.deletable??!0,label:x.label,labelStyle:x.labelStyle,labelShowBg:x.labelShowBg,labelBgStyle:x.labelBgStyle,labelBgPadding:x.labelBgPadding,labelBgBorderRadius:x.labelBgBorderRadius,sourceX:O,sourceY:P,targetX:I,targetY:L,sourcePosition:U,targetPosition:D,data:x.data,style:x.style,sourceHandleId:x.sourceHandle,targetHandleId:x.targetHandle,markerStart:E,markerEnd:ee,pathOptions:"pathOptions"in x?x.pathOptions:void 0,interactionWidth:x.interactionWidth}),$&&p.jsx(nRe,{edge:x,isReconnectable:$,reconnectRadius:u,onReconnect:h,onReconnectStart:f,onReconnectEnd:y,sourceX:O,sourceY:P,targetX:I,targetY:L,sourcePosition:U,targetPosition:D,setUpdateHover:R,setReconnecting:z})]})})}var rRe=m.memo(oRe);const aRe=e=>({edgesFocusable:e.edgesFocusable,edgesReconnectable:e.edgesReconnectable,elementsSelectable:e.elementsSelectable,connectionMode:e.connectionMode,onError:e.onError});function bQ({defaultMarkerColor:e,onlyRenderVisibleElements:t,rfId:n,edgeTypes:o,noPanClassName:r,onReconnect:a,onEdgeContextMenu:i,onEdgeMouseEnter:s,onEdgeMouseMove:c,onEdgeMouseLeave:l,onEdgeClick:u,reconnectRadius:h,onEdgeDoubleClick:f,onReconnectStart:y,onReconnectEnd:k,disableKeyboardA11y:v}){const{edgesFocusable:w,edgesReconnectable:g,elementsSelectable:M,onError:x}=He(aRe,Nt),b=Vze(t);return p.jsxs("div",{className:"react-flow__edges",children:[p.jsx(Kze,{defaultColor:e,rfId:n}),b.map(C=>p.jsx(rRe,{id:C,edgesFocusable:w,edgesReconnectable:g,elementsSelectable:M,noPanClassName:r,onReconnect:a,onContextMenu:i,onMouseEnter:s,onMouseMove:c,onMouseLeave:l,onClick:u,reconnectRadius:h,onDoubleClick:f,onReconnectStart:y,onReconnectEnd:k,rfId:n,onError:x,edgeTypes:o,disableKeyboardA11y:v},C))]})}bQ.displayName="EdgeRenderer";const iRe=m.memo(bQ),sRe=e=>`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`;function cRe({children:e}){const t=He(sRe);return p.jsx("div",{className:"react-flow__viewport xyflow__viewport react-flow__container",style:{transform:t},children:e})}function lRe(e){const t=Wz(),n=m.useRef(!1);m.useEffect(()=>{!n.current&&t.viewportInitialized&&e&&(setTimeout(()=>e(t),1),n.current=!0)},[e,t.viewportInitialized])}const dRe=e=>{var t;return(t=e.panZoom)==null?void 0:t.syncViewport};function uRe(e){const t=He(dRe),n=Mt();return m.useEffect(()=>{e&&(t==null||t(e),n.setState({transform:[e.x,e.y,e.zoom]}))},[e,t]),null}function hRe(e){return e.connection.inProgress?{...e.connection,to:uf(e.connection.to,e.transform)}:{...e.connection}}function fRe(e){return hRe}function pRe(e){const t=fRe();return He(t,Nt)}const yRe=e=>({nodesConnectable:e.nodesConnectable,isValid:e.connection.isValid,inProgress:e.connection.inProgress,width:e.width,height:e.height});function mRe({containerStyle:e,style:t,type:n,component:o}){const{nodesConnectable:r,width:a,height:i,isValid:s,inProgress:c}=He(yRe,Nt);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:Wt(["react-flow__connection",vY(s)]),children:p.jsx(_Q,{style:t,type:n,CustomComponent:o,isValid:s})})})}const _Q=({style:e,type:t=si.Bezier,CustomComponent:n,isValid:o})=>{const{inProgress:r,from:a,fromNode:i,fromHandle:s,fromPosition:c,to:l,toNode:u,toHandle:h,toPosition:f,pointer:y}=pRe();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:vY(o),toNode:u,toHandle:h,pointer:y});let k="";const v={sourceX:a.x,sourceY:a.y,sourcePosition:c,targetX:l.x,targetY:l.y,targetPosition:f};switch(t){case si.Bezier:[k]=Fz(v);break;case si.SimpleBezier:[k]=uQ(v);break;case si.Step:[k]=qh({...v,borderRadius:0});break;case si.SmoothStep:[k]=qh(v);break;default:[k]=$Y(v)}return p.jsx("path",{d:k,fill:"none",className:"react-flow__connection-path",style:e})};_Q.displayName="ConnectionLine";const kRe={};function aU(e=kRe){m.useRef(e),Mt(),m.useEffect(()=>{},[e])}function gRe(){Mt(),m.useRef(!1),m.useEffect(()=>{},[])}function CQ({nodeTypes:e,edgeTypes:t,onInit:n,onNodeClick:o,onEdgeClick:r,onNodeDoubleClick:a,onEdgeDoubleClick:i,onNodeMouseEnter:s,onNodeMouseMove:c,onNodeMouseLeave:l,onNodeContextMenu:u,onSelectionContextMenu:h,onSelectionStart:f,onSelectionEnd:y,connectionLineType:k,connectionLineStyle:v,connectionLineComponent:w,connectionLineContainerStyle:g,selectionKeyCode:M,selectionOnDrag:x,selectionMode:b,multiSelectionKeyCode:C,panActivationKeyCode:_,zoomActivationKeyCode:S,deleteKeyCode:$,onlyRenderVisibleElements:j,elementsSelectable:N,defaultViewport:A,translateExtent:R,minZoom:Y,maxZoom:z,preventScrolling:V,defaultMarkerColor:H,zoomOnScroll:O,zoomOnPinch:P,panOnScroll:I,panOnScrollSpeed:L,panOnScrollMode:U,zoomOnDoubleClick:D,panOnDrag:E,onPaneClick:ee,onPaneMouseEnter:J,onPaneMouseMove:ne,onPaneMouseLeave:oe,onPaneScroll:te,onPaneContextMenu:ce,paneClickDistance:ge,nodeClickDistance:ae,onEdgeContextMenu:se,onEdgeMouseEnter:re,onEdgeMouseMove:Pe,onEdgeMouseLeave:Be,reconnectRadius:Ve,onReconnect:ht,onReconnectStart:Gt,onReconnectEnd:Et,noDragClassName:hn,noWheelClassName:fe,noPanClassName:Se,disableKeyboardA11y:fn,nodeExtent:pn,rfId:sn,viewport:W,onViewportChange:G}){return aU(e),aU(t),gRe(),lRe(n),uRe(W),p.jsx(jze,{onPaneClick:ee,onPaneMouseEnter:J,onPaneMouseMove:ne,onPaneMouseLeave:oe,onPaneContextMenu:ce,onPaneScroll:te,paneClickDistance:ge,deleteKeyCode:$,selectionKeyCode:M,selectionOnDrag:x,selectionMode:b,onSelectionStart:f,onSelectionEnd:y,multiSelectionKeyCode:C,panActivationKeyCode:_,zoomActivationKeyCode:S,elementsSelectable:N,zoomOnScroll:O,zoomOnPinch:P,zoomOnDoubleClick:D,panOnScroll:I,panOnScrollSpeed:L,panOnScrollMode:U,panOnDrag:E,defaultViewport:A,translateExtent:R,minZoom:Y,maxZoom:z,onSelectionContextMenu:h,preventScrolling:V,noDragClassName:hn,noWheelClassName:fe,noPanClassName:Se,disableKeyboardA11y:fn,onViewportChange:G,isControlledViewport:!!W,children:p.jsxs(cRe,{children:[p.jsx(iRe,{edgeTypes:t,onEdgeClick:r,onEdgeDoubleClick:i,onReconnect:ht,onReconnectStart:Gt,onReconnectEnd:Et,onlyRenderVisibleElements:j,onEdgeContextMenu:se,onEdgeMouseEnter:re,onEdgeMouseMove:Pe,onEdgeMouseLeave:Be,reconnectRadius:Ve,defaultMarkerColor:H,noPanClassName:Se,disableKeyboardA11y:fn,rfId:sn}),p.jsx(mRe,{style:v,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:u,nodeClickDistance:ae,onlyRenderVisibleElements:j,noPanClassName:Se,noDragClassName:hn,disableKeyboardA11y:fn,nodeExtent:pn,rfId:sn}),p.jsx("div",{className:"react-flow__viewport-portal"})]})})}CQ.displayName="GraphView";const vRe=m.memo(CQ),iU=({nodes:e,edges:t,defaultNodes:n,defaultEdges:o,width:r,height:a,fitView:i,fitViewOptions:s,minZoom:c=.5,maxZoom:l=2,nodeOrigin:u,nodeExtent:h,zIndexMode:f="basic"}={})=>{const y=new Map,k=new Map,v=new Map,w=new Map,g=o??t??[],M=n??e??[],x=u??[0,0],b=h??Rh;zY(v,w,g);const{nodesInitialized:C}=aH(M,y,k,{nodeOrigin:x,nodeExtent:b,zIndexMode:f});let _=[0,0,1];if(i&&r&&a){const S=lf(y,{filter:A=>!!((A.width||A.initialWidth)&&(A.height||A.initialHeight))}),{x:$,y:j,zoom:N}=lO(S,r,a,c,l,(s==null?void 0:s.padding)??.1);_=[$,j,N]}return{rfId:"1",width:r??0,height:a??0,transform:_,nodes:M,nodesInitialized:C,nodeLookup:y,parentLookup:k,edges:g,edgeLookup:w,connectionLookup:v,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:n!==void 0,hasDefaultEdges:o!==void 0,panZoom:null,minZoom:c,maxZoom:l,translateExtent:Rh,nodeExtent:b,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:s0.Strict,domNode:null,paneDragging:!1,noPanClassName:"nopan",nodeOrigin:x,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:{...gY},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:wje,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:"react",debug:!1,ariaLabelConfig:kY,zIndexMode:f,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map}},xRe=({nodes:e,edges:t,defaultNodes:n,defaultEdges:o,width:r,height:a,fitView:i,fitViewOptions:s,minZoom:c,maxZoom:l,nodeOrigin:u,nodeExtent:h,zIndexMode:f})=>HPe((y,k)=>{async function v(){const{nodeLookup:w,panZoom:g,fitViewOptions:M,fitViewResolver:x,width:b,height:C,minZoom:_,maxZoom:S}=k();g&&(await vje({nodes:w,width:b,height:C,panZoom:g,minZoom:_,maxZoom:S},M),x==null||x.resolve(!0),y({fitViewResolver:null}))}return{...iU({nodes:e,edges:t,width:r,height:a,fitView:i,fitViewOptions:s,minZoom:c,maxZoom:l,nodeOrigin:u,nodeExtent:h,defaultNodes:n,defaultEdges:o,zIndexMode:f}),setNodes:w=>{const{nodeLookup:g,parentLookup:M,nodeOrigin:x,elevateNodesOnSelect:b,fitViewQueued:C,zIndexMode:_,nodesSelectionActive:S}=k(),{nodesInitialized:$,hasSelectedNodes:j}=aH(w,g,M,{nodeOrigin:x,nodeExtent:h,elevateNodesOnSelect:b,checkEquality:!0,zIndexMode:_}),N=S&&j;C&&$?(v(),y({nodes:w,nodesInitialized:$,fitViewQueued:!1,fitViewOptions:void 0,nodesSelectionActive:N})):y({nodes:w,nodesInitialized:$,nodesSelectionActive:N})},setEdges:w=>{const{connectionLookup:g,edgeLookup:M}=k();zY(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:x,domNode:b,nodeOrigin:C,nodeExtent:_,debug:S,fitViewQueued:$,zIndexMode:j}=k(),{changes:N,updatedInternals:A}=Vje(w,M,x,b,C,_,j);A&&(Hje(M,x,{nodeOrigin:C,nodeExtent:_,zIndexMode:j}),$?(v(),y({fitViewQueued:!1,fitViewOptions:void 0})):y({}),(N==null?void 0:N.length)>0&&(S&&console.log("React Flow: trigger node changes",N),g==null||g(N)))},updateNodePositions:(w,g=!1)=>{const M=[];let x=[];const{nodeLookup:b,triggerNodeChanges:C,connection:_,updateConnection:S,onNodesChangeMiddlewareMap:$}=k();for(const[j,N]of w){const A=b.get(j),R=!!(A!=null&&A.expandParent&&(A!=null&&A.parentId)&&(N!=null&&N.position)),Y={id:j,type:"position",position:R?{x:Math.max(0,N.position.x),y:Math.max(0,N.position.y)}:N.position,dragging:g};if(A&&_.inProgress&&_.fromNode.id===A.id){const z=Sd(A,_.fromHandle,me.Left,!0);S({..._,from:z})}R&&A.parentId&&M.push({id:j,parentId:A.parentId,rect:{...N.internals.positionAbsolute,width:N.measured.width??0,height:N.measured.height??0}}),x.push(Y)}if(M.length>0){const{parentLookup:j,nodeOrigin:N}=k(),A=yO(M,b,j,N);x.push(...A)}for(const j of $.values())x=j(x);C(x)},triggerNodeChanges:w=>{const{onNodesChange:g,setNodes:M,nodes:x,hasDefaultNodes:b,debug:C}=k();if(w!=null&&w.length){if(b){const _=eQ(w,x);M(_)}C&&console.log("React Flow: trigger node changes",w),g==null||g(w)}},triggerEdgeChanges:w=>{const{onEdgesChange:g,setEdges:M,edges:x,hasDefaultEdges:b,debug:C}=k();if(w!=null&&w.length){if(b){const _=tQ(w,x);M(_)}C&&console.log("React Flow: trigger edge changes",w),g==null||g(w)}},addSelectedNodes:w=>{const{multiSelectionActive:g,edgeLookup:M,nodeLookup:x,triggerNodeChanges:b,triggerEdgeChanges:C}=k();if(g){const _=w.map(S=>ad(S,!0));b(_);return}b(Eu(x,new Set([...w]),!0)),C(Eu(M))},addSelectedEdges:w=>{const{multiSelectionActive:g,edgeLookup:M,nodeLookup:x,triggerNodeChanges:b,triggerEdgeChanges:C}=k();if(g){const _=w.map(S=>ad(S,!0));C(_);return}C(Eu(M,new Set([...w]))),b(Eu(x,new Set,!0))},unselectNodesAndEdges:({nodes:w,edges:g}={})=>{const{edges:M,nodes:x,nodeLookup:b,triggerNodeChanges:C,triggerEdgeChanges:_}=k(),S=w||x,$=g||M,j=[];for(const A of S){if(!A.selected)continue;const R=b.get(A.id);R&&(R.selected=!1),j.push(ad(A.id,!1))}const N=[];for(const A of $)A.selected&&N.push(ad(A.id,!1));C(j),_(N)},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:x,elementsSelectable:b}=k();if(!b)return;const C=g.reduce((S,$)=>$.selected?[...S,ad($.id,!1)]:S,[]),_=w.reduce((S,$)=>$.selected?[...S,ad($.id,!1)]:S,[]);M(C),x(_)},setNodeExtent:w=>{const{nodes:g,nodeLookup:M,parentLookup:x,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]||(aH(g,M,x,{nodeOrigin:b,nodeExtent:w,elevateNodesOnSelect:C,checkEquality:!1,zIndexMode:S}),y({nodeExtent:w}))},panBy:w=>{const{transform:g,width:M,height:x,panZoom:b,translateExtent:C}=k();return Bje({delta:w,panZoom:b,transform:g,translateExtent:C,width:M,height:x})},setCenter:async(w,g,M)=>{const{width:x,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:x/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:{...gY}})},updateConnection:w=>{y({connection:w})},reset:()=>y({...iU()})}},Object.is);function wRe({initialNodes:e,initialEdges:t,defaultNodes:n,defaultEdges:o,initialWidth:r,initialHeight:a,initialMinZoom:i,initialMaxZoom:s,initialFitViewOptions:c,fitView:l,nodeOrigin:u,nodeExtent:h,zIndexMode:f,children:y}){const[k]=m.useState(()=>xRe({nodes:e,edges:t,defaultNodes:n,defaultEdges:o,width:r,height:a,fitView:l,minZoom:i,maxZoom:s,fitViewOptions:c,nodeOrigin:u,nodeExtent:h,zIndexMode:f}));return p.jsx(qPe,{value:k,children:p.jsx(cze,{children:y})})}function MRe({children:e,nodes:t,edges:n,defaultNodes:o,defaultEdges:r,width:a,height:i,fitView:s,fitViewOptions:c,minZoom:l,maxZoom:u,nodeOrigin:h,nodeExtent:f,zIndexMode:y}){return m.useContext(Uz)?p.jsx(p.Fragment,{children:e}):p.jsx(wRe,{initialNodes:t,initialEdges:n,defaultNodes:o,defaultEdges:r,initialWidth:a,initialHeight:i,fitView:s,initialFitViewOptions:c,initialMinZoom:l,initialMaxZoom:u,nodeOrigin:h,nodeExtent:f,zIndexMode:y,children:e})}const bRe={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0};function _Re({nodes:e,edges:t,defaultNodes:n,defaultEdges:o,className:r,nodeTypes:a,edgeTypes:i,onNodeClick:s,onEdgeClick:c,onInit:l,onMove:u,onMoveStart:h,onMoveEnd:f,onConnect:y,onConnectStart:k,onConnectEnd:v,onClickConnectStart:w,onClickConnectEnd:g,onNodeMouseEnter:M,onNodeMouseMove:x,onNodeMouseLeave:b,onNodeContextMenu:C,onNodeDoubleClick:_,onNodeDragStart:S,onNodeDrag:$,onNodeDragStop:j,onNodesDelete:N,onEdgesDelete:A,onDelete:R,onSelectionChange:Y,onSelectionDragStart:z,onSelectionDrag:V,onSelectionDragStop:H,onSelectionContextMenu:O,onSelectionStart:P,onSelectionEnd:I,onBeforeDelete:L,connectionMode:U,connectionLineType:D=si.Bezier,connectionLineStyle:E,connectionLineComponent:ee,connectionLineContainerStyle:J,deleteKeyCode:ne="Backspace",selectionKeyCode:oe="Shift",selectionOnDrag:te=!1,selectionMode:ce=c0.Full,panActivationKeyCode:ge="Space",multiSelectionKeyCode:ae=Hh()?"Meta":"Control",zoomActivationKeyCode:se=Hh()?"Meta":"Control",snapToGrid:re,snapGrid:Pe,onlyRenderVisibleElements:Be=!1,selectNodesOnDrag:Ve,nodesDraggable:ht,autoPanOnNodeFocus:Gt,nodesConnectable:Et,nodesFocusable:hn,nodeOrigin:fe=QY,edgesFocusable:Se,edgesReconnectable:fn,elementsSelectable:pn=!0,defaultViewport:sn=JPe,minZoom:W=.5,maxZoom:G=2,translateExtent:K=Rh,preventScrolling:qe=!0,nodeExtent:Ze,defaultMarkerColor:Kt="#b1b1b7",zoomOnScroll:tn=!0,zoomOnPinch:nn=!0,panOnScroll:Hn=!1,panOnScrollSpeed:Cn=.5,panOnScrollMode:Tt=kd.Free,zoomOnDoubleClick:Ne=!0,panOnDrag:ze=!0,onPaneClick:Qe,onPaneMouseEnter:ct,onPaneMouseMove:ir,onPaneMouseLeave:qd,onPaneScroll:Od,onPaneContextMenu:Oi,paneClickDistance:Fd=1,nodeClickDistance:$t=0,children:Ft,onReconnect:Vd,onReconnectStart:Bd,onReconnectEnd:Ud,onEdgeContextMenu:Wd,onEdgeDoubleClick:Gd,onEdgeMouseEnter:Kd,onEdgeMouseMove:La,onEdgeMouseLeave:Na,reconnectRadius:sr=10,onNodesChange:Fi,onEdgesChange:Ia,noDragClassName:De="nodrag",noWheelClassName:vt="nowheel",noPanClassName:no="nopan",fitView:Vi,fitViewOptions:cr,connectOnClick:Sn,attributionPosition:Ro,proOptions:Ln,defaultEdgeOptions:qn,elevateNodesOnSelect:Zt=!0,elevateEdgesOnSelect:Xt=!1,disableKeyboardA11y:lr=!1,autoPanOnConnect:Bi,autoPanOnNodeDrag:Zd,autoPanSpeed:Xd,connectionRadius:Ui,isValidConnection:jt,onError:oo,style:Wr,id:Aa,nodeDragThreshold:bo,connectionDragThreshold:Gr,viewport:Yd,onViewportChange:_o,width:Ea,height:To,colorMode:yn="light",debug:Kr,onScroll:dr,ariaLabelConfig:V0,zIndexMode:Zr="basic",...Qd},$a){const Nn=Aa||"1",Xr=oze(yn),Do=m.useCallback(On=>{On.currentTarget.scrollTo({top:0,left:0,behavior:"instant"}),dr==null||dr(On)},[dr]);return p.jsx("div",{"data-testid":"rf__wrapper",...Qd,onScroll:Do,style:{...Wr,...bRe},ref:$a,className:Wt(["react-flow",r,Xr]),id:Aa,role:"application",children:p.jsxs(MRe,{nodes:e,edges:t,width:Ea,height:To,fitView:Vi,fitViewOptions:cr,minZoom:W,maxZoom:G,nodeOrigin:fe,nodeExtent:Ze,zIndexMode:Zr,children:[p.jsx(nze,{nodes:e,edges:t,defaultNodes:n,defaultEdges:o,onConnect:y,onConnectStart:k,onConnectEnd:v,onClickConnectStart:w,onClickConnectEnd:g,nodesDraggable:ht,autoPanOnNodeFocus:Gt,nodesConnectable:Et,nodesFocusable:hn,edgesFocusable:Se,edgesReconnectable:fn,elementsSelectable:pn,elevateNodesOnSelect:Zt,elevateEdgesOnSelect:Xt,minZoom:W,maxZoom:G,nodeExtent:Ze,onNodesChange:Fi,onEdgesChange:Ia,snapToGrid:re,snapGrid:Pe,connectionMode:U,translateExtent:K,connectOnClick:Sn,defaultEdgeOptions:qn,fitView:Vi,fitViewOptions:cr,onNodesDelete:N,onEdgesDelete:A,onDelete:R,onNodeDragStart:S,onNodeDrag:$,onNodeDragStop:j,onSelectionDrag:V,onSelectionDragStart:z,onSelectionDragStop:H,onMove:u,onMoveStart:h,onMoveEnd:f,noPanClassName:no,nodeOrigin:fe,rfId:Nn,autoPanOnConnect:Bi,autoPanOnNodeDrag:Zd,autoPanSpeed:Xd,onError:oo,connectionRadius:Ui,isValidConnection:jt,selectNodesOnDrag:Ve,nodeDragThreshold:bo,connectionDragThreshold:Gr,onBeforeDelete:L,debug:Kr,ariaLabelConfig:V0,zIndexMode:Zr}),p.jsx(vRe,{onInit:l,onNodeClick:s,onEdgeClick:c,onNodeMouseEnter:M,onNodeMouseMove:x,onNodeMouseLeave:b,onNodeContextMenu:C,onNodeDoubleClick:_,nodeTypes:a,edgeTypes:i,connectionLineType:D,connectionLineStyle:E,connectionLineComponent:ee,connectionLineContainerStyle:J,selectionKeyCode:oe,selectionOnDrag:te,selectionMode:ce,deleteKeyCode:ne,multiSelectionKeyCode:ae,panActivationKeyCode:ge,zoomActivationKeyCode:se,onlyRenderVisibleElements:Be,defaultViewport:sn,translateExtent:K,minZoom:W,maxZoom:G,preventScrolling:qe,zoomOnScroll:tn,zoomOnPinch:nn,zoomOnDoubleClick:Ne,panOnScroll:Hn,panOnScrollSpeed:Cn,panOnScrollMode:Tt,panOnDrag:ze,onPaneClick:Qe,onPaneMouseEnter:ct,onPaneMouseMove:ir,onPaneMouseLeave:qd,onPaneScroll:Od,onPaneContextMenu:Oi,paneClickDistance:Fd,nodeClickDistance:$t,onSelectionContextMenu:O,onSelectionStart:P,onSelectionEnd:I,onReconnect:Vd,onReconnectStart:Bd,onReconnectEnd:Ud,onEdgeContextMenu:Wd,onEdgeDoubleClick:Gd,onEdgeMouseEnter:Kd,onEdgeMouseMove:La,onEdgeMouseLeave:Na,reconnectRadius:sr,defaultMarkerColor:Kt,noDragClassName:De,noWheelClassName:vt,noPanClassName:no,rfId:Nn,disableKeyboardA11y:lr,nodeExtent:Ze,viewport:Yd,onViewportChange:_o}),p.jsx(QPe,{onSelectionChange:Y}),Ft,p.jsx(GPe,{proOptions:Ln,position:Ro}),p.jsx(WPe,{rfId:Nn,disableKeyboardA11y:lr})]})})}var CRe=nQ(_Re);const SRe=e=>{var t;return(t=e.domNode)==null?void 0:t.querySelector(".react-flow__edgelabel-renderer")};function LRe({children:e}){const t=He(SRe);return t?I0.createPortal(e,t):null}const NRe=e=>{var t;return(t=e.domNode)==null?void 0:t.querySelector(".react-flow__viewport-portal")};function IRe({children:e}){const t=He(NRe);return t?I0.createPortal(e,t):null}function SQ(){const e=Mt();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 sU(e){return He(m.useCallback(n=>n.nodeLookup.get(e),[e]),Nt)}function ARe({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:Wt(["react-flow__background-pattern",n,o])})}function ERe({radius:e,className:t}){return p.jsx("circle",{cx:e,cy:e,r:e,className:Wt(["react-flow__background-pattern","dots",t])})}var xi;(function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"})(xi||(xi={}));const $Re={[xi.Dots]:1,[xi.Lines]:1,[xi.Cross]:6},jRe=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function LQ({id:e,variant:t=xi.Dots,gap:n=20,size:o,lineWidth:r=1,offset:a=0,color:i,bgColor:s,style:c,className:l,patternClassName:u}){const h=m.useRef(null),{transform:f,patternId:y}=He(jRe,Nt),k=o||$Re[t],v=t===xi.Dots,w=t===xi.Cross,g=Array.isArray(n)?n:[n,n],M=[g[0]*f[2]||1,g[1]*f[2]||1],x=k*f[2],b=Array.isArray(a)?a:[a,a],C=w?[x,x]: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:Wt(["react-flow__background",l]),style:{...c,...Gz,"--xy-background-color-props":s,"--xy-background-pattern-color-props":i},ref:h,"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:v?p.jsx(ERe,{radius:x/2,className:u}):p.jsx(ARe,{dimensions:C,lineWidth:r,variant:t,className:u})}),p.jsx("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${S})`})]})}LQ.displayName="Background";const PRe=m.memo(LQ);function zRe(){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 RRe(){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 TRe(){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 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 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 HRe(){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 $u({children:e,className:t,...n}){return p.jsx("button",{type:"button",className:Wt(["react-flow__controls-button",t]),...n,children:e})}const qRe=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom,ariaLabelConfig:e.ariaLabelConfig});function NQ({style:e,showZoom:t=!0,showFitView:n=!0,showInteractive:o=!0,fitViewOptions:r,onZoomIn:a,onZoomOut:i,onFitView:s,onInteractiveChange:c,className:l,children:u,position:h="bottom-left",orientation:f="vertical","aria-label":y}){const k=Mt(),{isInteractive:v,minZoomReached:w,maxZoomReached:g,ariaLabelConfig:M}=He(qRe,Nt),{zoomIn:x,zoomOut:b,fitView:C}=Wz(),_=()=>{x(),a==null||a()},S=()=>{b(),i==null||i()},$=()=>{C(r),s==null||s()},j=()=>{k.setState({nodesDraggable:!v,nodesConnectable:!v,elementsSelectable:!v}),c==null||c(!v)},N=f==="horizontal"?"horizontal":"vertical";return p.jsxs(f0,{className:Wt(["react-flow__controls",N,l]),position:h,style:e,"data-testid":"rf__controls","aria-label":y??M["controls.ariaLabel"],children:[t&&p.jsxs(p.Fragment,{children:[p.jsx($u,{onClick:_,className:"react-flow__controls-zoomin",title:M["controls.zoomIn.ariaLabel"],"aria-label":M["controls.zoomIn.ariaLabel"],disabled:g,children:p.jsx(zRe,{})}),p.jsx($u,{onClick:S,className:"react-flow__controls-zoomout",title:M["controls.zoomOut.ariaLabel"],"aria-label":M["controls.zoomOut.ariaLabel"],disabled:w,children:p.jsx(RRe,{})})]}),n&&p.jsx($u,{className:"react-flow__controls-fitview",onClick:$,title:M["controls.fitView.ariaLabel"],"aria-label":M["controls.fitView.ariaLabel"],children:p.jsx(TRe,{})}),o&&p.jsx($u,{className:"react-flow__controls-interactive",onClick:j,title:M["controls.interactive.ariaLabel"],"aria-label":M["controls.interactive.ariaLabel"],children:v?p.jsx(HRe,{}):p.jsx(DRe,{})}),u]})}NQ.displayName="Controls";const ORe=m.memo(NQ);function FRe({id:e,x:t,y:n,width:o,height:r,style:a,color:i,strokeColor:s,strokeWidth:c,className:l,borderRadius:u,shapeRendering:h,selected:f,onClick:y}){const{background:k,backgroundColor:v}=a||{},w=i||k||v;return p.jsx("rect",{className:Wt(["react-flow__minimap-node",{selected:f},l]),x:t,y:n,rx:u,ry:u,width:o,height:r,style:{fill:w,stroke:s,strokeWidth:c},shapeRendering:h,onClick:y?g=>y(g,e):void 0})}const VRe=m.memo(FRe),BRe=e=>e.nodes.map(t=>t.id),hT=e=>e instanceof Function?e:()=>e;function URe({nodeStrokeColor:e,nodeColor:t,nodeClassName:n="",nodeBorderRadius:o=5,nodeStrokeWidth:r,nodeComponent:a=VRe,onClick:i}){const s=He(BRe,Nt),c=hT(t),l=hT(e),u=hT(n),h=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:u,nodeBorderRadius:o,nodeStrokeWidth:r,NodeComponent:a,onClick:i,shapeRendering:h},f))})}function WRe({id:e,nodeColorFunc:t,nodeStrokeColorFunc:n,nodeClassNameFunc:o,nodeBorderRadius:r,nodeStrokeWidth:a,shapeRendering:i,NodeComponent:s,onClick:c}){const{node:l,x:u,y:h,width:f,height:y}=He(k=>{const v=k.nodeLookup.get(e);if(!v)return{node:void 0,x:0,y:0,width:0,height:0};const w=v.internals.userNode,{x:g,y:M}=v.internals.positionAbsolute,{width:x,height:b}=_a(w);return{node:w,x:g,y:M,width:x,height:b}},Nt);return!l||l.hidden||!CY(l)?null:p.jsx(s,{x:u,y:h,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(WRe);var KRe=m.memo(URe);const ZRe=200,XRe=150,YRe=e=>!e.hidden,QRe=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?_Y(lf(e.nodeLookup,{filter:YRe}),t):t,rfId:e.rfId,panZoom:e.panZoom,translateExtent:e.translateExtent,flowWidth:e.width,flowHeight:e.height,ariaLabelConfig:e.ariaLabelConfig}},JRe="react-flow__minimap-desc";function IQ({style:e,className:t,nodeStrokeColor:n,nodeColor:o,nodeClassName:r="",nodeBorderRadius:a=5,nodeStrokeWidth:i,nodeComponent:s,bgColor:c,maskColor:l,maskStrokeColor:u,maskStrokeWidth:h,position:f="bottom-right",onClick:y,onNodeClick:k,pannable:v=!1,zoomable:w=!1,ariaLabel:g,inversePan:M,zoomStep:x=1,offsetScale:b=5}){const C=Mt(),_=m.useRef(null),{boundingRect:S,viewBB:$,rfId:j,panZoom:N,translateExtent:A,flowWidth:R,flowHeight:Y,ariaLabelConfig:z}=He(QRe,Nt),V=(e==null?void 0:e.width)??ZRe,H=(e==null?void 0:e.height)??XRe,O=S.width/V,P=S.height/H,I=Math.max(O,P),L=I*V,U=I*H,D=b*I,E=S.x-(L-S.width)/2-D,ee=S.y-(U-S.height)/2-D,J=L+D*2,ne=U+D*2,oe=`${JRe}-${j}`,te=m.useRef(0),ce=m.useRef();te.current=I,m.useEffect(()=>{if(_.current&&N)return ce.current=Jje({domNode:_.current,panZoom:N,getTransform:()=>C.getState().transform,getViewScale:()=>te.current}),()=>{var re;(re=ce.current)==null||re.destroy()}},[N]),m.useEffect(()=>{var re;(re=ce.current)==null||re.update({translateExtent:A,width:R,height:Y,inversePan:M,pannable:v,zoomStep:x,zoomable:w})},[v,w,M,x,A,R,Y]);const ge=y?re=>{var Ve;const[Pe,Be]=((Ve=ce.current)==null?void 0:Ve.pointer(re))||[0,0];y(re,{x:Pe,y:Be})}:void 0,ae=k?m.useCallback((re,Pe)=>{const Be=C.getState().nodeLookup.get(Pe).internals.userNode;k(re,Be)},[]):void 0,se=g??z["minimap.ariaLabel"];return p.jsx(f0,{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 u=="string"?u:void 0,"--xy-minimap-mask-stroke-width-props":typeof h=="number"?h*I: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:Wt(["react-flow__minimap",t]),"data-testid":"rf__minimap",children:p.jsxs("svg",{width:V,height:H,viewBox:`${E} ${ee} ${J} ${ne}`,className:"react-flow__minimap-svg",role:"img","aria-labelledby":oe,ref:_,onClick:ge,children:[se&&p.jsx("title",{id:oe,children:se}),p.jsx(KRe,{onClick:ae,nodeColor:o,nodeStrokeColor:n,nodeBorderRadius:a,nodeClassName:r,nodeStrokeWidth:i,nodeComponent:s}),p.jsx("path",{className:"react-flow__minimap-mask",d:`M${E-D},${ee-D}h${J+D*2}v${ne+D*2}h${-J-D*2}z
|
|
8468
8468
|
M${$.x},${$.y}h${$.width}v${$.height}h${-$.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}IQ.displayName="MiniMap";const eTe=m.memo(IQ),tTe=e=>t=>e?`${Math.max(1/t.transform[2],1)}`:void 0,nTe={[Ci.Line]:"right",[Ci.Handle]:"bottom-right"};function oTe({nodeId:e,position:t,variant:n=Ci.Handle,className:o,style:r=void 0,children:a,color:i,minWidth:s=10,minHeight:c=10,maxWidth:l=Number.MAX_VALUE,maxHeight:u=Number.MAX_VALUE,keepAspectRatio:h=!1,resizeDirection:f,autoScale:y=!0,shouldResize:k,onResizeStart:v,onResize:w,onResizeEnd:g}){const M=iQ(),x=typeof e=="string"?e:M,b=Mt(),C=m.useRef(null),_=n===Ci.Handle,S=He(m.useCallback(tTe(_&&y),[_,y]),Nt),$=m.useRef(null),j=t??nTe[n];m.useEffect(()=>{if(!(!C.current||!x))return $.current||($.current=fPe({domNode:C.current,nodeId:x,getStoreItems:()=>{const{nodeLookup:A,transform:R,snapGrid:Y,snapToGrid:z,nodeOrigin:V,domNode:H}=b.getState();return{nodeLookup:A,transform:R,snapGrid:Y,snapToGrid:z,nodeOrigin:V,paneDomNode:H}},onChange:(A,R)=>{const{triggerNodeChanges:Y,nodeLookup:z,parentLookup:V,nodeOrigin:H}=b.getState(),O=[],P={x:A.x,y:A.y},I=z.get(x);if(I&&I.expandParent&&I.parentId){const L=I.origin??H,U=A.width??I.measured.width??0,D=A.height??I.measured.height??0,E={id:I.id,parentId:I.parentId,rect:{width:U,height:D,...SY({x:A.x??I.position.x,y:A.y??I.position.y},{width:U,height:D},I.parentId,z,L)}},ee=yO([E],z,V,H);O.push(...ee),P.x=A.x?Math.max(L[0]*U,A.x):void 0,P.y=A.y?Math.max(L[1]*D,A.y):void 0}if(P.x!==void 0&&P.y!==void 0){const L={id:x,type:"position",position:{...P}};O.push(L)}if(A.width!==void 0&&A.height!==void 0){const U={id:x,type:"dimensions",resizing:!0,setAttributes:f?f==="horizontal"?"width":"height":!0,dimensions:{width:A.width,height:A.height}};O.push(U)}for(const L of R){const U={...L,type:"position"};O.push(U)}Y(O)},onEnd:({width:A,height:R})=>{const Y={id:x,type:"dimensions",resizing:!1,dimensions:{width:A,height:R}};b.getState().triggerNodeChanges([Y])}})),$.current.update({controlPosition:j,boundaries:{minWidth:s,minHeight:c,maxWidth:l,maxHeight:u},keepAspectRatio:h,resizeDirection:f,onResizeStart:v,onResize:w,onResizeEnd:g,shouldResize:k}),()=>{var A;(A=$.current)==null||A.destroy()}},[j,s,c,l,u,h,v,w,g,k]);const N=j.split("-");return p.jsx("div",{className:Wt(["react-flow__resize-control","nodrag",...N,n,o]),ref:C,style:{...r,scale:S,...i&&{[_?"backgroundColor":"borderColor"]:i}},children:a})}const cU=m.memo(oTe),rTe=24,aTe=e=>({type:Th.ArrowClosed,width:18,height:18,...e?{color:e}:{}}),iTe={solid:{},dashed:{strokeDasharray:"6 4"},dotted:{strokeDasharray:"2 4"}},sTe=3,lU=new WeakMap,cTe=(e,t,n=!1)=>{const o=lU.get(e);if(o&&o.isAdjacentToRunning===t&&o.selected===n)return o.edge;const r=e.style?iTe[e.style]:{},a=Lt(e.color,"edge"),i=e.borderSize??2,s=n?Math.max(sTe,i):i,l={...r,...a,...n?{strokeWidth:s,opacity:1}:{strokeWidth:s}},u=e.direction??"forward",h=a.stroke,f=aTe(h),y=u==="backward"||u==="both"?f:void 0,k=u==="forward"||u==="both"?f:void 0,v={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:rTe};return lU.set(e,{isAdjacentToRunning:t,selected:n,edge:v}),v},lTe=(e,t={})=>{const n=t.setTimer??((l,u)=>globalThis.setTimeout(l,u)),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 u=a;a=null,u&&u()},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}}},AQ="seeflow:detail-panel-width",fu=380,lH=320,dH=800;function uH(e){return Number.isFinite(e)?e<lH?lH:e>dH?dH:e:fu}function dTe(){if(typeof window>"u")return fu;try{const e=window.localStorage.getItem(AQ);if(e===null)return fu;const t=Number(e);return!Number.isFinite(t)||t<lH||t>dH?fu:t}catch{return fu}}function uTe(e){if(!(typeof window>"u"))try{const t=uH(e);window.localStorage.setItem(AQ,String(t))}catch{}}function hTe(e,t,n,o){const r=typeof window>"u"?null:window;if(!r)return;let a=uH(e);const i=c=>{a=uH(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 fTe(e,t,n){return`${n!==void 0?n.replace(/\/+$/,""):"/api/projects"}/${encodeURIComponent(e)}/files/${encodeURI(t)}`}const WP=(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),u=c===0?Number.POSITIVE_INFINITY:n/c,h=l===0?Number.POSITIVE_INFINITY:o/l,f=Math.min(u,h),y=r+i*f,k=a+s*f,v=c*o>=l*n?i>=0?"right":"left":s>=0?"bottom":"top";return{x:y,y:k,side:v}},hH=(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,u=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:u}:{side:"bottom",t:u}},GP=(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}},pTe=(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)}}},yTe=(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?GP(e.box,e.pin):e.autoPicked===!1?e.fallback:WP(e.box,a),s=t.pin?GP(t.box,t.pin):t.autoPicked===!1?t.fallback:WP(t.box,r);return{source:i,target:s}};function di({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 u=o||r==="blur-only",h=m.useRef(null),[f,y]=m.useState(!1),[k,v]=m.useState(e.length===0),w=m.useRef(lTe(400)),g=m.useRef(e),M=m.useRef(!1);m.useEffect(()=>{const A=h.current;if(!A)return;A.textContent=e,A.focus();const R=window.getSelection();if(R){const z=document.createRange();z.selectNodeContents(A),R.removeAllRanges(),R.addRange(z)}const Y=w.current;return()=>{Y.flush()}},[]);const x=()=>{const A=h.current;return A?u?A.innerText:A.textContent??"":""},b=A=>{w.current.cancel(),A!==g.current&&(g.current=A,t(A))},C=()=>{const A=x();if(v(A.length===0),a&&A.trim().length===0){w.current.cancel();return}w.current.schedule(()=>b(A))},_=()=>{w.current.cancel();const A=x();if(a&&A.trim().length===0){const R=h.current;R&&(R.textContent=e),y(!0),setTimeout(()=>y(!1),320),n();return}b(A),n()},S=()=>{w.current.cancel();const A=h.current;A&&(A.textContent=e),n()},$=A=>{if(A.stopPropagation(),A.nativeEvent.stopPropagation(),A.key==="Enter"){if(r==="blur-only"||o&&A.shiftKey){A.preventDefault(),document.execCommand("insertText",!1,`
|
|
8469
|
-
`);return}A.preventDefault(),M.current=!0,_();return}A.key==="Escape"&&(A.preventDefault(),M.current=!0,S())},j=A=>{A.preventDefault();const R=A.clipboardData.getData("text/plain");document.execCommand("insertText",!1,R)},N=()=>{if(M.current){M.current=!1;return}_()};return p.jsx("div",{ref:h,"data-testid":"inline-edit-input","data-field":i,"data-placeholder":l,role:"textbox",tabIndex:0,contentEditable:!0,suppressContentEditableWarning:!0,spellCheck:!1,onInput:C,onKeyDown:$,onPaste:j,onBlur:N,onMouseDown:A=>A.stopPropagation(),onClick:A=>A.stopPropagation(),onDoubleClick:A=>A.stopPropagation(),style:c,className:ie("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 EQ=8,dU=12,uU={height:`${EQ}px`,borderColor:"transparent"},hU={width:`${EQ}px`,borderColor:"transparent"},mTe={width:`${dU}px`,height:`${dU}px`,background:"transparent",border:"none"},kTe={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},gTe=[{position:"top",style:uU},{position:"bottom",style:uU},{position:"left",style:hU},{position:"right",style:hU}],vTe=["top-left","top-right","bottom-left","bottom-right"],fU={pointerEvents:"none",cursor:"default"};function E0({visible:e,minWidth:t=80,minHeight:n=40,onResizeStart:o,onResize:r,onResizeEnd:a,cornerVariant:i="invisible"}){const s=i==="visible"?kTe:mTe,c=u=>e?u:{...u,...fU},l=e?s:{...s,opacity:0,...fU};return p.jsxs(p.Fragment,{children:[gTe.map(({position:u,style:h})=>p.jsx(cU,{position:u,variant:Ci.Line,minWidth:t,minHeight:n,style:c(h),onResizeStart:o,onResize:r,onResizeEnd:a,children:p.jsx("span",{"data-testid":"resize-control","data-position":u})},u)),vTe.map(u=>p.jsx(cU,{position:u,variant:Ci.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":u})},u))]})}function $0(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),u=m.useRef(o),h=m.useRef(r);m.useEffect(()=>{c.current=t},[t]),m.useEffect(()=>{l.current=n},[n]),m.useEffect(()=>{u.current=o},[o]),m.useEffect(()=>{h.current=r},[r]);const f=m.useCallback((v,w)=>{var g;i(!0),(g=h.current)==null||g.call(h,!0),s.current=w?{x:w.x,y:w.y,width:w.width,height:w.height}:null},[]),y=m.useCallback((v,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((v,w)=>{var M,x,b,C;i(!1),(M=h.current)==null||M.call(h,!1);const g=s.current;s.current=null,!(g&&g.width===w.width&&g.height===w.height)&&((x=c.current)==null||x.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=u.current)==null||C.call(u,{x:w.x,y:w.y,width:w.width,height:w.height},g)))},[]);return{isResizing:a,onResizeStart:f,onResizeEvent:y,onResizeEnd:k}}const p0={width:48,height:48},pU="help-circle",xTe=24,wTe=24,fp="sf:opacity-0 sf:transition-opacity";function MTe(e){return Lt(e,"text").color??"currentColor"}const yU=new Set;function bTe({id:e,data:t,selected:n,isConnectable:o}){const{onResizeStart:r,onResizeEvent:a,onResizeEnd:i}=$0({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,u]=m.useState(!1),h=r0[t.icon];!h&&!yU.has(t.icon)&&(yU.add(t.icon),console.warn(`[iconNode] Unknown icon "${t.icon}"; falling back to "${pU}".`));const f=h??r0[pU],y=MTe(t.color),k=t.strokeWidth??2,v={...s?{}:{width:p0.width,height:p0.height}},w=g=>{!c||l||(g.stopPropagation(),u(!0))};return p.jsxs("div",{className:ie("sf:group sf:relative",s?"sf:h-full sf:w-full":""),style:v,"data-testid":"icon-node","data-node-type":"icon",onDoubleClick:w,children:[p.jsx(E0,{visible:!!n&&!!t.onResize&&!l,cornerVariant:"visible",minWidth:xTe,minHeight:wTe,onResizeStart:r,onResize:a,onResizeEnd:i}),p.jsx(ft,{type:"target",position:me.Top,id:"t",isConnectable:o,className:ie(fp,n&&"sf:opacity-100!")}),p.jsx(ft,{type:"target",position:me.Left,id:"l",isConnectable:o,className:ie(fp,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(di,{initialValue:t.name??"",field:"icon-node-label",onCommit:g=>{var M;return(M=t.onNameChange)==null?void 0:M.call(t,e,g)},onExit:()=>u(!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(ft,{type:"source",position:me.Right,id:"r",isConnectable:o,className:ie(fp,n&&"sf:opacity-100!")}),p.jsx(ft,{type:"source",position:me.Bottom,id:"b",isConnectable:o,className:ie(fp,n&&"sf:opacity-100!")})]})}function _Te(e,t){return e.selected===t.selected&&e.data===t.data&&e.width===t.width&&e.height===t.height}const CTe=m.memo(bTe,_Te);function STe(e,t){const n=e.screenToFlowPosition({x:t.width/2,y:t.height/2});return{x:n.x-p0.width/2,y:n.y-p0.height/2}}const $Q="seeflow:icon-recents",LTe=16;function jQ(){if(typeof window>"u")return[];try{const e=window.localStorage.getItem($Q);if(e===null)return[];const t=JSON.parse(e);return Array.isArray(t)?t.every(n=>typeof n=="string")?t:[]:[]}catch{return[]}}function NTe(e){if(!(typeof window>"u"))try{const n=jQ().filter(r=>r!==e),o=[e,...n].slice(0,LTe);window.localStorage.setItem($Q,JSON.stringify(o))}catch{}}const ITe=typeof navigator<"u"&&typeof navigator.platform=="string"&&navigator.platform.toLowerCase().includes("mac"),ATe=e=>e.length===1?e.toUpperCase():e==="Escape"?"Esc":e,Dt=(e,t=ITe)=>{const n=ATe(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("+")},kO=[{id:"tool.select",label:"Select tool",description:"Switch to the selection tool",category:"Tools",shortcut:Dt({key:"V"})},{id:"tool.hand",label:"Hand tool",description:"Pan the canvas; node interaction is suspended while armed",category:"Tools",shortcut:Dt({key:"H"})},{id:"tool.rectangle",label:"Rectangle",description:"Draw rectangle nodes",category:"Tools",shortcut:Dt({key:"R"})},{id:"tool.ellipse",label:"Ellipse",description:"Draw ellipse nodes",category:"Tools",shortcut:Dt({key:"O"})},{id:"tool.text",label:"Text",description:"Add a text node",category:"Tools",shortcut:Dt({key:"T"})},{id:"tool.sticky",label:"Sticky note",description:"Add a sticky note",category:"Tools",shortcut:Dt({key:"S"})},{id:"tool.database",label:"Database",description:"Add a database node",category:"Tools",shortcut:Dt({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:Dt({meta:!0,key:"Z"}),enabled:e=>e.canUndo},{id:"edit.redo",label:"Redo",category:"Edit",shortcut:Dt({meta:!0,shift:!0,key:"Z"}),enabled:e=>e.canRedo},{id:"edit.copy",label:"Copy",category:"Edit",shortcut:Dt({meta:!0,key:"C"}),enabled:e=>e.hasSelection},{id:"edit.paste",label:"Paste",category:"Edit",shortcut:Dt({meta:!0,key:"V"}),enabled:e=>e.hasClipboard},{id:"edit.duplicate",label:"Duplicate",category:"Edit",shortcut:Dt({meta:!0,key:"D"}),enabled:e=>e.hasSelection},{id:"edit.delete",label:"Delete",category:"Edit",shortcut:Dt({key:"Delete"}),enabled:e=>e.hasSelection},{id:"edit.selectAll",label:"Select all",category:"Edit",shortcut:Dt({meta:!0,key:"A"})},{id:"view.fit",label:"Fit view",description:"Fit everything in the viewport",category:"View",shortcut:Dt({meta:!0,key:"0"})},{id:"view.zoomIn",label:"Zoom in",category:"View",shortcut:Dt({meta:!0,key:"="})},{id:"view.zoomOut",label:"Zoom out",category:"View",shortcut:Dt({meta:!0,key:"-"})},{id:"view.zoom100",label:"Zoom to 100%",category:"View",shortcut:Dt({key:"1"})},{id:"view.zoomToSelection",label:"Zoom to selection",category:"View",shortcut:Dt({key:"F"}),enabled:e=>e.hasSelection},{id:"layout.tidy",label:"Tidy layout",description:"Auto-layout the canvas or current selection",category:"Layout",shortcut:Dt({meta:!0,shift:!0,key:"L"})},{id:"selection.deselect",label:"Deselect",description:"Clear selection and exit draw mode",category:"Selection",shortcut:Dt({key:"Escape"})},{id:"help.commandPalette",label:"Open command palette",category:"Help",shortcut:Dt({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}],fT=e=>{const t=kO.find(n=>n.id===e);return t?t.shortcut?`${t.label} (${t.shortcut})`:t.label:""},ETe=1,$Te=10,jTe=e=>{if(e.metaKey||e.ctrlKey||e.altKey)return null;const t=e.shiftKey?$Te:ETe;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}},PTe=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}},zTe=(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},RTe=({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"}},TTe=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}},Qa="seeflow",PQ=e=>`${e}:last-used-style:v1`,pT=()=>({node:{},connector:{}}),yT=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),gO=e=>{var t;try{const n=(t=globalThis.localStorage)==null?void 0:t.getItem(PQ(e));if(!n)return pT();const o=JSON.parse(n);if(!yT(o))return pT();const r=yT(o.node)?o.node:{},a=yT(o.connector)?o.connector:{};return{node:r,connector:a}}catch{return pT()}},zQ=(e,t)=>{var n;try{(n=globalThis.localStorage)==null||n.setItem(PQ(e),JSON.stringify(t))}catch{}},M2=e=>gO(e),mU=(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=gO(e);zQ(e,{...a,node:{...a.node,...r}})},DTe=(e,t)=>{const n=gO(e);zQ(e,{...n,connector:{...n.connector,...t}})},vO=1,kU=17,fH=(e,t)=>{if(!e)return{};const n={};for(const o of t)e[o]!==void 0&&(n[o]=e[o]);return n},HTe=["borderColor","backgroundColor","borderSize","borderStyle","fontSize","cornerRadius","shadow"],qTe=["borderColor","backgroundColor","borderSize","borderStyle","fontSize","shadow"],OTe=["fontSize"],FTe=["borderColor","borderWidth","borderStyle","shadow"];function gU(e,t,n){if(e==="text")return{width:t.width,height:t.height,fontSize:kU,...fH(n,OTe)};const o=e==="ellipse"?qTe:HTe;return{width:t.width,height:t.height,borderSize:vO,fontSize:kU,...fH(n,o)}}function VTe(e,t,n){return{path:e,width:t.width,height:t.height,borderWidth:vO,...fH(n,FTe)}}const So=async(e,t,n,o,r)=>{const a={method:t},i={...o??{}};r!==void 0&&(i["content-type"]="application/json",a.body=JSON.stringify(r)),Object.keys(i).length>0&&(a.headers=i);const s=await e(n,a);if(!s.ok){let c=null;try{c=await s.json()}catch{}throw new Error((c==null?void 0:c.error)??`${t} ${n} → ${s.status}`)}return await s.json()},BTe=e=>{const{baseUrl:t,project:n,flow:o}=e,r=e.fetch??globalThis.fetch.bind(globalThis),a=e.headers,i=`${t}/api/projects/${encodeURIComponent(n)}`,s=`${i}/flows/${encodeURIComponent(o)}`;return{async createNode(c){const l=await So(r,"POST",`${s}/nodes`,a,c);return{id:l.id,node:l.node}},async updateNode(c,l){await So(r,"PATCH",`${s}/nodes/${c}`,a,l)},async updateNodePosition(c,l){return await So(r,"PATCH",`${s}/nodes/${c}/position`,a,l)},async deleteNode(c){await So(r,"DELETE",`${s}/nodes/${c}`,a)},async reorderNode(c,l){await So(r,"PATCH",`${s}/nodes/${c}/order`,a,l)},async createConnector(c){return{id:(await So(r,"POST",`${s}/connectors`,a,c)).id}},async updateConnector(c,l){await So(r,"PATCH",`${s}/connectors/${c}`,a,l)},async deleteConnector(c){await So(r,"DELETE",`${s}/connectors/${c}`,a)},async uploadImage(c,l,u){const h=new FormData;h.append("file",l),h.append("filename",u);const f=`${s}/nodes/${encodeURIComponent(c)}/files/upload`,y={method:"POST",body:h};a&&(y.headers={...a});const k=await r(f,y);if(!k.ok){let v=null;try{v=await k.json()}catch{}throw new Error((v==null?void 0:v.error)??`POST ${f} → ${k.status}`)}return await k.json()},async playAction(c){return await So(r,"POST",`${s}/play/${c}`,a,{})},async openFile(c){await So(r,"POST",`${i}/files/open`,a,{path:c})},async revealFile(c){await So(r,"POST",`${i}/files/reveal`,a,{path:c})},async computeLayout(c,l){const u=await So(r,"POST",`${t}/api/layout`,a,{nodes:c,edges:l});return{nodes:u.nodes,connectors:u.connectors}}}};function RQ(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 UTe="modulepreload",WTe=function(e){return"/"+e},vU={},ff=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=WTe(c),c in vU)return;vU[c]=!0;const l=c.endsWith(".css"),u=l?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${c}"]${u}`))return;const h=document.createElement("link");if(h.rel=l?"stylesheet":UTe,l||(h.as="script"),h.crossOrigin="",h.href=c,s&&h.setAttribute("nonce",s),document.head.appendChild(h),l)return new Promise((f,y)=>{h.addEventListener("load",f),h.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 it;(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})(it||(it={}));var xU;(function(e){e.mergeShapes=(t,n)=>({...t,...n})})(xU||(xU={}));const _e=it.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),ri=e=>{switch(typeof e){case"undefined":return _e.undefined;case"string":return _e.string;case"number":return Number.isNaN(e)?_e.nan:_e.number;case"boolean":return _e.boolean;case"function":return _e.function;case"bigint":return _e.bigint;case"symbol":return _e.symbol;case"object":return Array.isArray(e)?_e.array:e===null?_e.null:e.then&&typeof e.then=="function"&&e.catch&&typeof e.catch=="function"?_e.promise:typeof Map<"u"&&e instanceof Map?_e.map:typeof Set<"u"&&e instanceof Set?_e.set:typeof Date<"u"&&e instanceof Date?_e.date:_e.object;default:return _e.unknown}},ke=it.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 ga 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 ga))throw new Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,it.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()}}ga.create=e=>new ga(e);const pH=(e,t)=>{let n;switch(e.code){case ke.invalid_type:e.received===_e.undefined?n="Required":n=`Expected ${e.expected}, received ${e.received}`;break;case ke.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(e.expected,it.jsonStringifyReplacer)}`;break;case ke.unrecognized_keys:n=`Unrecognized key(s) in object: ${it.joinValues(e.keys,", ")}`;break;case ke.invalid_union:n="Invalid input";break;case ke.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${it.joinValues(e.options)}`;break;case ke.invalid_enum_value:n=`Invalid enum value. Expected ${it.joinValues(e.options)}, received '${e.received}'`;break;case ke.invalid_arguments:n="Invalid function arguments";break;case ke.invalid_return_type:n="Invalid function return type";break;case ke.invalid_date:n="Invalid date";break;case ke.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}"`:it.assertNever(e.validation):e.validation!=="regex"?n=`Invalid ${e.validation}`:n="Invalid";break;case ke.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 ke.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 ke.custom:n="Invalid input";break;case ke.invalid_intersection_types:n="Intersection results could not be merged";break;case ke.not_multiple_of:n=`Number must be a multiple of ${e.multipleOf}`;break;case ke.not_finite:n="Number must be finite";break;default:n=t.defaultError,it.assertNever(e)}return{message:n}};let GTe=pH;function KTe(){return GTe}const ZTe=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 xe(e,t){const n=KTe(),o=ZTe({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,n,n===pH?void 0:pH].filter(r=>!!r)});e.common.issues.push(o)}class Pn{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 Pn.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"}),b2=e=>({status:"dirty",value:e}),zo=e=>({status:"valid",value:e}),wU=e=>e.status==="aborted",MU=e=>e.status==="dirty",y0=e=>e.status==="valid",KP=e=>typeof Promise<"u"&&e instanceof Promise;var Le;(function(e){e.errToObj=t=>typeof t=="string"?{message:t}:t||{},e.toString=t=>typeof t=="string"?t:t==null?void 0:t.message})(Le||(Le={}));class qr{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 bU=(e,t)=>{if(y0(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 ga(e.common.issues);return this._error=n,this._error}}};function Ke(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 ri(t.data)}_getOrReturnCtx(t,n){return n||{common:t.parent.common,data:t.data,parsedType:ri(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}_processInputParams(t){return{status:new Pn,ctx:{common:t.parent.common,data:t.data,parsedType:ri(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}}_parseSync(t){const n=this._parse(t);if(KP(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:ri(t)},r=this._parseSync({data:t,path:o.path,parent:o});return bU(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:ri(t)};if(!this["~standard"].async)try{const a=this._parseSync({data:t,path:[],parent:n});return y0(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=>y0(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:ri(t)},r=this._parse({data:t,path:o.path,parent:o}),a=await(KP(r)?r:Promise.resolve(r));return bU(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:ke.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 g0({schema:this,typeName:Oe.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 wi.create(this,this._def)}nullable(){return v0.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Tr.create(this)}promise(){return JP.create(this,this._def)}or(t){return XP.create([this,t],this._def)}and(t){return YP.create(this,t,this._def)}transform(t){return new g0({...Ke(this._def),schema:this,typeName:Oe.ZodEffects,effect:{type:"transform",transform:t}})}default(t){const n=typeof t=="function"?t:()=>t;return new vH({...Ke(this._def),innerType:this,defaultValue:n,typeName:Oe.ZodDefault})}brand(){return new gDe({typeName:Oe.ZodBranded,type:this,...Ke(this._def)})}catch(t){const n=typeof t=="function"?t:()=>t;return new xH({...Ke(this._def),innerType:this,catchValue:n,typeName:Oe.ZodCatch})}describe(t){const n=this.constructor;return new n({...this._def,description:t})}pipe(t){return xO.create(this,t)}readonly(){return wH.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const XTe=/^c[^\s-]{8,}$/i,YTe=/^[0-9a-z]+$/,QTe=/^[0-9A-HJKMNP-TV-Z]{26}$/i,JTe=/^[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,eDe=/^[a-z0-9_-]{21}$/i,tDe=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,nDe=/^[-+]?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)?)??$/,oDe=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,rDe="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let mT;const aDe=/^(?:(?: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])$/,iDe=/^(?:(?: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])$/,sDe=/^(([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]))$/,cDe=/^(([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])$/,lDe=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,dDe=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,TQ="((\\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])))",uDe=new RegExp(`^${TQ}$`);function DQ(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 hDe(e){return new RegExp(`^${DQ(e)}$`)}function fDe(e){let t=`${TQ}T${DQ(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 pDe(e,t){return!!((t==="v4"||!t)&&aDe.test(e)||(t==="v6"||!t)&&sDe.test(e))}function yDe(e,t){if(!tDe.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 mDe(e,t){return!!((t==="v4"||!t)&&iDe.test(e)||(t==="v6"||!t)&&cDe.test(e))}class ua extends et{_parse(t){if(this._def.coerce&&(t.data=String(t.data)),this._getType(t)!==_e.string){const a=this._getOrReturnCtx(t);return xe(a,{code:ke.invalid_type,expected:_e.string,received:a.parsedType}),Fe}const o=new Pn;let r;for(const a of this._def.checks)if(a.kind==="min")t.data.length<a.value&&(r=this._getOrReturnCtx(t,r),xe(r,{code:ke.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),xe(r,{code:ke.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?xe(r,{code:ke.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}):s&&xe(r,{code:ke.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}),o.dirty())}else if(a.kind==="email")oDe.test(t.data)||(r=this._getOrReturnCtx(t,r),xe(r,{validation:"email",code:ke.invalid_string,message:a.message}),o.dirty());else if(a.kind==="emoji")mT||(mT=new RegExp(rDe,"u")),mT.test(t.data)||(r=this._getOrReturnCtx(t,r),xe(r,{validation:"emoji",code:ke.invalid_string,message:a.message}),o.dirty());else if(a.kind==="uuid")JTe.test(t.data)||(r=this._getOrReturnCtx(t,r),xe(r,{validation:"uuid",code:ke.invalid_string,message:a.message}),o.dirty());else if(a.kind==="nanoid")eDe.test(t.data)||(r=this._getOrReturnCtx(t,r),xe(r,{validation:"nanoid",code:ke.invalid_string,message:a.message}),o.dirty());else if(a.kind==="cuid")XTe.test(t.data)||(r=this._getOrReturnCtx(t,r),xe(r,{validation:"cuid",code:ke.invalid_string,message:a.message}),o.dirty());else if(a.kind==="cuid2")YTe.test(t.data)||(r=this._getOrReturnCtx(t,r),xe(r,{validation:"cuid2",code:ke.invalid_string,message:a.message}),o.dirty());else if(a.kind==="ulid")QTe.test(t.data)||(r=this._getOrReturnCtx(t,r),xe(r,{validation:"ulid",code:ke.invalid_string,message:a.message}),o.dirty());else if(a.kind==="url")try{new URL(t.data)}catch{r=this._getOrReturnCtx(t,r),xe(r,{validation:"url",code:ke.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),xe(r,{validation:"regex",code:ke.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),xe(r,{code:ke.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),xe(r,{code:ke.invalid_string,validation:{startsWith:a.value},message:a.message}),o.dirty()):a.kind==="endsWith"?t.data.endsWith(a.value)||(r=this._getOrReturnCtx(t,r),xe(r,{code:ke.invalid_string,validation:{endsWith:a.value},message:a.message}),o.dirty()):a.kind==="datetime"?fDe(a).test(t.data)||(r=this._getOrReturnCtx(t,r),xe(r,{code:ke.invalid_string,validation:"datetime",message:a.message}),o.dirty()):a.kind==="date"?uDe.test(t.data)||(r=this._getOrReturnCtx(t,r),xe(r,{code:ke.invalid_string,validation:"date",message:a.message}),o.dirty()):a.kind==="time"?hDe(a).test(t.data)||(r=this._getOrReturnCtx(t,r),xe(r,{code:ke.invalid_string,validation:"time",message:a.message}),o.dirty()):a.kind==="duration"?nDe.test(t.data)||(r=this._getOrReturnCtx(t,r),xe(r,{validation:"duration",code:ke.invalid_string,message:a.message}),o.dirty()):a.kind==="ip"?pDe(t.data,a.version)||(r=this._getOrReturnCtx(t,r),xe(r,{validation:"ip",code:ke.invalid_string,message:a.message}),o.dirty()):a.kind==="jwt"?yDe(t.data,a.alg)||(r=this._getOrReturnCtx(t,r),xe(r,{validation:"jwt",code:ke.invalid_string,message:a.message}),o.dirty()):a.kind==="cidr"?mDe(t.data,a.version)||(r=this._getOrReturnCtx(t,r),xe(r,{validation:"cidr",code:ke.invalid_string,message:a.message}),o.dirty()):a.kind==="base64"?lDe.test(t.data)||(r=this._getOrReturnCtx(t,r),xe(r,{validation:"base64",code:ke.invalid_string,message:a.message}),o.dirty()):a.kind==="base64url"?dDe.test(t.data)||(r=this._getOrReturnCtx(t,r),xe(r,{validation:"base64url",code:ke.invalid_string,message:a.message}),o.dirty()):it.assertNever(a);return{status:o.value,value:t.data}}_regex(t,n,o){return this.refinement(r=>t.test(r),{validation:n,code:ke.invalid_string,...Le.errToObj(o)})}_addCheck(t){return new ua({...this._def,checks:[...this._def.checks,t]})}email(t){return this._addCheck({kind:"email",...Le.errToObj(t)})}url(t){return this._addCheck({kind:"url",...Le.errToObj(t)})}emoji(t){return this._addCheck({kind:"emoji",...Le.errToObj(t)})}uuid(t){return this._addCheck({kind:"uuid",...Le.errToObj(t)})}nanoid(t){return this._addCheck({kind:"nanoid",...Le.errToObj(t)})}cuid(t){return this._addCheck({kind:"cuid",...Le.errToObj(t)})}cuid2(t){return this._addCheck({kind:"cuid2",...Le.errToObj(t)})}ulid(t){return this._addCheck({kind:"ulid",...Le.errToObj(t)})}base64(t){return this._addCheck({kind:"base64",...Le.errToObj(t)})}base64url(t){return this._addCheck({kind:"base64url",...Le.errToObj(t)})}jwt(t){return this._addCheck({kind:"jwt",...Le.errToObj(t)})}ip(t){return this._addCheck({kind:"ip",...Le.errToObj(t)})}cidr(t){return this._addCheck({kind:"cidr",...Le.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,...Le.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,...Le.errToObj(t==null?void 0:t.message)})}duration(t){return this._addCheck({kind:"duration",...Le.errToObj(t)})}regex(t,n){return this._addCheck({kind:"regex",regex:t,...Le.errToObj(n)})}includes(t,n){return this._addCheck({kind:"includes",value:t,position:n==null?void 0:n.position,...Le.errToObj(n==null?void 0:n.message)})}startsWith(t,n){return this._addCheck({kind:"startsWith",value:t,...Le.errToObj(n)})}endsWith(t,n){return this._addCheck({kind:"endsWith",value:t,...Le.errToObj(n)})}min(t,n){return this._addCheck({kind:"min",value:t,...Le.errToObj(n)})}max(t,n){return this._addCheck({kind:"max",value:t,...Le.errToObj(n)})}length(t,n){return this._addCheck({kind:"length",value:t,...Le.errToObj(n)})}nonempty(t){return this.min(1,Le.errToObj(t))}trim(){return new ua({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new ua({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new ua({...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}}ua.create=e=>new ua({checks:[],typeName:Oe.ZodString,coerce:(e==null?void 0:e.coerce)??!1,...Ke(e)});function kDe(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 m0 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)!==_e.number){const a=this._getOrReturnCtx(t);return xe(a,{code:ke.invalid_type,expected:_e.number,received:a.parsedType}),Fe}let o;const r=new Pn;for(const a of this._def.checks)a.kind==="int"?it.isInteger(t.data)||(o=this._getOrReturnCtx(t,o),xe(o,{code:ke.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),xe(o,{code:ke.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),xe(o,{code:ke.too_big,maximum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),r.dirty()):a.kind==="multipleOf"?kDe(t.data,a.value)!==0&&(o=this._getOrReturnCtx(t,o),xe(o,{code:ke.not_multiple_of,multipleOf:a.value,message:a.message}),r.dirty()):a.kind==="finite"?Number.isFinite(t.data)||(o=this._getOrReturnCtx(t,o),xe(o,{code:ke.not_finite,message:a.message}),r.dirty()):it.assertNever(a);return{status:r.value,value:t.data}}gte(t,n){return this.setLimit("min",t,!0,Le.toString(n))}gt(t,n){return this.setLimit("min",t,!1,Le.toString(n))}lte(t,n){return this.setLimit("max",t,!0,Le.toString(n))}lt(t,n){return this.setLimit("max",t,!1,Le.toString(n))}setLimit(t,n,o,r){return new m0({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:o,message:Le.toString(r)}]})}_addCheck(t){return new m0({...this._def,checks:[...this._def.checks,t]})}int(t){return this._addCheck({kind:"int",message:Le.toString(t)})}positive(t){return this._addCheck({kind:"min",value:0,inclusive:!1,message:Le.toString(t)})}negative(t){return this._addCheck({kind:"max",value:0,inclusive:!1,message:Le.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:0,inclusive:!0,message:Le.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:0,inclusive:!0,message:Le.toString(t)})}multipleOf(t,n){return this._addCheck({kind:"multipleOf",value:t,message:Le.toString(n)})}finite(t){return this._addCheck({kind:"finite",message:Le.toString(t)})}safe(t){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:Le.toString(t)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:Le.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"&&it.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)}}m0.create=e=>new m0({checks:[],typeName:Oe.ZodNumber,coerce:(e==null?void 0:e.coerce)||!1,...Ke(e)});class Fh 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)!==_e.bigint)return this._getInvalidInput(t);let o;const r=new Pn;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),xe(o,{code:ke.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),xe(o,{code:ke.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),xe(o,{code:ke.not_multiple_of,multipleOf:a.value,message:a.message}),r.dirty()):it.assertNever(a);return{status:r.value,value:t.data}}_getInvalidInput(t){const n=this._getOrReturnCtx(t);return xe(n,{code:ke.invalid_type,expected:_e.bigint,received:n.parsedType}),Fe}gte(t,n){return this.setLimit("min",t,!0,Le.toString(n))}gt(t,n){return this.setLimit("min",t,!1,Le.toString(n))}lte(t,n){return this.setLimit("max",t,!0,Le.toString(n))}lt(t,n){return this.setLimit("max",t,!1,Le.toString(n))}setLimit(t,n,o,r){return new Fh({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:o,message:Le.toString(r)}]})}_addCheck(t){return new Fh({...this._def,checks:[...this._def.checks,t]})}positive(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:Le.toString(t)})}negative(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:Le.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:Le.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:Le.toString(t)})}multipleOf(t,n){return this._addCheck({kind:"multipleOf",value:t,message:Le.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}}Fh.create=e=>new Fh({checks:[],typeName:Oe.ZodBigInt,coerce:(e==null?void 0:e.coerce)??!1,...Ke(e)});class yH extends et{_parse(t){if(this._def.coerce&&(t.data=!!t.data),this._getType(t)!==_e.boolean){const o=this._getOrReturnCtx(t);return xe(o,{code:ke.invalid_type,expected:_e.boolean,received:o.parsedType}),Fe}return zo(t.data)}}yH.create=e=>new yH({typeName:Oe.ZodBoolean,coerce:(e==null?void 0:e.coerce)||!1,...Ke(e)});class ZP extends et{_parse(t){if(this._def.coerce&&(t.data=new Date(t.data)),this._getType(t)!==_e.date){const a=this._getOrReturnCtx(t);return xe(a,{code:ke.invalid_type,expected:_e.date,received:a.parsedType}),Fe}if(Number.isNaN(t.data.getTime())){const a=this._getOrReturnCtx(t);return xe(a,{code:ke.invalid_date}),Fe}const o=new Pn;let r;for(const a of this._def.checks)a.kind==="min"?t.data.getTime()<a.value&&(r=this._getOrReturnCtx(t,r),xe(r,{code:ke.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),xe(r,{code:ke.too_big,message:a.message,inclusive:!0,exact:!1,maximum:a.value,type:"date"}),o.dirty()):it.assertNever(a);return{status:o.value,value:new Date(t.data.getTime())}}_addCheck(t){return new ZP({...this._def,checks:[...this._def.checks,t]})}min(t,n){return this._addCheck({kind:"min",value:t.getTime(),message:Le.toString(n)})}max(t,n){return this._addCheck({kind:"max",value:t.getTime(),message:Le.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}}ZP.create=e=>new ZP({checks:[],coerce:(e==null?void 0:e.coerce)||!1,typeName:Oe.ZodDate,...Ke(e)});class _U extends et{_parse(t){if(this._getType(t)!==_e.symbol){const o=this._getOrReturnCtx(t);return xe(o,{code:ke.invalid_type,expected:_e.symbol,received:o.parsedType}),Fe}return zo(t.data)}}_U.create=e=>new _U({typeName:Oe.ZodSymbol,...Ke(e)});class CU extends et{_parse(t){if(this._getType(t)!==_e.undefined){const o=this._getOrReturnCtx(t);return xe(o,{code:ke.invalid_type,expected:_e.undefined,received:o.parsedType}),Fe}return zo(t.data)}}CU.create=e=>new CU({typeName:Oe.ZodUndefined,...Ke(e)});class SU extends et{_parse(t){if(this._getType(t)!==_e.null){const o=this._getOrReturnCtx(t);return xe(o,{code:ke.invalid_type,expected:_e.null,received:o.parsedType}),Fe}return zo(t.data)}}SU.create=e=>new SU({typeName:Oe.ZodNull,...Ke(e)});class LU extends et{constructor(){super(...arguments),this._any=!0}_parse(t){return zo(t.data)}}LU.create=e=>new LU({typeName:Oe.ZodAny,...Ke(e)});class mH extends et{constructor(){super(...arguments),this._unknown=!0}_parse(t){return zo(t.data)}}mH.create=e=>new mH({typeName:Oe.ZodUnknown,...Ke(e)});class Si extends et{_parse(t){const n=this._getOrReturnCtx(t);return xe(n,{code:ke.invalid_type,expected:_e.never,received:n.parsedType}),Fe}}Si.create=e=>new Si({typeName:Oe.ZodNever,...Ke(e)});class NU extends et{_parse(t){if(this._getType(t)!==_e.undefined){const o=this._getOrReturnCtx(t);return xe(o,{code:ke.invalid_type,expected:_e.void,received:o.parsedType}),Fe}return zo(t.data)}}NU.create=e=>new NU({typeName:Oe.ZodVoid,...Ke(e)});class Tr extends et{_parse(t){const{ctx:n,status:o}=this._processInputParams(t),r=this._def;if(n.parsedType!==_e.array)return xe(n,{code:ke.invalid_type,expected:_e.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)&&(xe(n,{code:i?ke.too_big:ke.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&&(xe(n,{code:ke.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&&(xe(n,{code:ke.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 qr(n,i,n.path,s)))).then(i=>Pn.mergeArray(o,i));const a=[...n.data].map((i,s)=>r.type._parseSync(new qr(n,i,n.path,s)));return Pn.mergeArray(o,a)}get element(){return this._def.type}min(t,n){return new Tr({...this._def,minLength:{value:t,message:Le.toString(n)}})}max(t,n){return new Tr({...this._def,maxLength:{value:t,message:Le.toString(n)}})}length(t,n){return new Tr({...this._def,exactLength:{value:t,message:Le.toString(n)}})}nonempty(t){return this.min(1,t)}}Tr.create=(e,t)=>new Tr({type:e,minLength:null,maxLength:null,exactLength:null,typeName:Oe.ZodArray,...Ke(t)});function pu(e){if(e instanceof Bt){const t={};for(const n in e.shape){const o=e.shape[n];t[n]=wi.create(pu(o))}return new Bt({...e._def,shape:()=>t})}else return e instanceof Tr?new Tr({...e._def,type:pu(e.element)}):e instanceof wi?wi.create(pu(e.unwrap())):e instanceof v0?v0.create(pu(e.unwrap())):e instanceof Ld?Ld.create(e.items.map(t=>pu(t))):e}class Bt 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=it.objectKeys(t);return this._cached={shape:t,keys:n},this._cached}_parse(t){if(this._getType(t)!==_e.object){const l=this._getOrReturnCtx(t);return xe(l,{code:ke.invalid_type,expected:_e.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 Si&&this._def.unknownKeys==="strip"))for(const l in r.data)i.includes(l)||s.push(l);const c=[];for(const l of i){const u=a[l],h=r.data[l];c.push({key:{status:"valid",value:l},value:u._parse(new qr(r,h,r.path,l)),alwaysSet:l in r.data})}if(this._def.catchall instanceof Si){const l=this._def.unknownKeys;if(l==="passthrough")for(const u of s)c.push({key:{status:"valid",value:u},value:{status:"valid",value:r.data[u]}});else if(l==="strict")s.length>0&&(xe(r,{code:ke.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 u of s){const h=r.data[u];c.push({key:{status:"valid",value:u},value:l._parse(new qr(r,h,r.path,u)),alwaysSet:u in r.data})}}return r.common.async?Promise.resolve().then(async()=>{const l=[];for(const u of c){const h=await u.key,f=await u.value;l.push({key:h,value:f,alwaysSet:u.alwaysSet})}return l}).then(l=>Pn.mergeObjectSync(o,l)):Pn.mergeObjectSync(o,c)}get shape(){return this._def.shape()}strict(t){return Le.errToObj,new Bt({...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:Le.errToObj(t).message??r}:{message:r}}}:{}})}strip(){return new Bt({...this._def,unknownKeys:"strip"})}passthrough(){return new Bt({...this._def,unknownKeys:"passthrough"})}extend(t){return new Bt({...this._def,shape:()=>({...this._def.shape(),...t})})}merge(t){return new Bt({unknownKeys:t._def.unknownKeys,catchall:t._def.catchall,shape:()=>({...this._def.shape(),...t._def.shape()}),typeName:Oe.ZodObject})}setKey(t,n){return this.augment({[t]:n})}catchall(t){return new Bt({...this._def,catchall:t})}pick(t){const n={};for(const o of it.objectKeys(t))t[o]&&this.shape[o]&&(n[o]=this.shape[o]);return new Bt({...this._def,shape:()=>n})}omit(t){const n={};for(const o of it.objectKeys(this.shape))t[o]||(n[o]=this.shape[o]);return new Bt({...this._def,shape:()=>n})}deepPartial(){return pu(this)}partial(t){const n={};for(const o of it.objectKeys(this.shape)){const r=this.shape[o];t&&!t[o]?n[o]=r:n[o]=r.optional()}return new Bt({...this._def,shape:()=>n})}required(t){const n={};for(const o of it.objectKeys(this.shape))if(t&&!t[o])n[o]=this.shape[o];else{let a=this.shape[o];for(;a instanceof wi;)a=a._def.innerType;n[o]=a}return new Bt({...this._def,shape:()=>n})}keyof(){return HQ(it.objectKeys(this.shape))}}Bt.create=(e,t)=>new Bt({shape:()=>e,unknownKeys:"strip",catchall:Si.create(),typeName:Oe.ZodObject,...Ke(t)});Bt.strictCreate=(e,t)=>new Bt({shape:()=>e,unknownKeys:"strict",catchall:Si.create(),typeName:Oe.ZodObject,...Ke(t)});Bt.lazycreate=(e,t)=>new Bt({shape:e,unknownKeys:"strip",catchall:Si.create(),typeName:Oe.ZodObject,...Ke(t)});class XP 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 ga(s.ctx.common.issues));return xe(n,{code:ke.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},u=c._parseSync({data:n.data,path:n.path,parent:l});if(u.status==="valid")return u;u.status==="dirty"&&!a&&(a={result:u,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 ga(c));return xe(n,{code:ke.invalid_union,unionErrors:s}),Fe}}get options(){return this._def.options}}XP.create=(e,t)=>new XP({options:e,typeName:Oe.ZodUnion,...Ke(t)});function kH(e,t){const n=ri(e),o=ri(t);if(e===t)return{valid:!0,data:e};if(n===_e.object&&o===_e.object){const r=it.objectKeys(t),a=it.objectKeys(e).filter(s=>r.indexOf(s)!==-1),i={...e,...t};for(const s of a){const c=kH(e[s],t[s]);if(!c.valid)return{valid:!1};i[s]=c.data}return{valid:!0,data:i}}else if(n===_e.array&&o===_e.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=kH(i,s);if(!c.valid)return{valid:!1};r.push(c.data)}return{valid:!0,data:r}}else return n===_e.date&&o===_e.date&&+e==+t?{valid:!0,data:e}:{valid:!1}}class YP extends et{_parse(t){const{status:n,ctx:o}=this._processInputParams(t),r=(a,i)=>{if(wU(a)||wU(i))return Fe;const s=kH(a.value,i.value);return s.valid?((MU(a)||MU(i))&&n.dirty(),{status:n.value,value:s.data}):(xe(o,{code:ke.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}))}}YP.create=(e,t,n)=>new YP({left:e,right:t,typeName:Oe.ZodIntersection,...Ke(n)});class Ld extends et{_parse(t){const{status:n,ctx:o}=this._processInputParams(t);if(o.parsedType!==_e.array)return xe(o,{code:ke.invalid_type,expected:_e.array,received:o.parsedType}),Fe;if(o.data.length<this._def.items.length)return xe(o,{code:ke.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),Fe;!this._def.rest&&o.data.length>this._def.items.length&&(xe(o,{code:ke.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 qr(o,i,o.path,s)):null}).filter(i=>!!i);return o.common.async?Promise.all(a).then(i=>Pn.mergeArray(n,i)):Pn.mergeArray(n,a)}get items(){return this._def.items}rest(t){return new Ld({...this._def,rest:t})}}Ld.create=(e,t)=>{if(!Array.isArray(e))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Ld({items:e,typeName:Oe.ZodTuple,rest:null,...Ke(t)})};class QP 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!==_e.object)return xe(o,{code:ke.invalid_type,expected:_e.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 qr(o,s,o.path,s)),value:i._parse(new qr(o,o.data[s],o.path,s)),alwaysSet:s in o.data});return o.common.async?Pn.mergeObjectAsync(n,r):Pn.mergeObjectSync(n,r)}get element(){return this._def.valueType}static create(t,n,o){return n instanceof et?new QP({keyType:t,valueType:n,typeName:Oe.ZodRecord,...Ke(o)}):new QP({keyType:ua.create(),valueType:t,typeName:Oe.ZodRecord,...Ke(n)})}}class IU 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!==_e.map)return xe(o,{code:ke.invalid_type,expected:_e.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 qr(o,s,o.path,[l,"key"])),value:a._parse(new qr(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,u=await c.value;if(l.status==="aborted"||u.status==="aborted")return Fe;(l.status==="dirty"||u.status==="dirty")&&n.dirty(),s.set(l.value,u.value)}return{status:n.value,value:s}})}else{const s=new Map;for(const c of i){const l=c.key,u=c.value;if(l.status==="aborted"||u.status==="aborted")return Fe;(l.status==="dirty"||u.status==="dirty")&&n.dirty(),s.set(l.value,u.value)}return{status:n.value,value:s}}}}IU.create=(e,t,n)=>new IU({valueType:t,keyType:e,typeName:Oe.ZodMap,...Ke(n)});class Vh extends et{_parse(t){const{status:n,ctx:o}=this._processInputParams(t);if(o.parsedType!==_e.set)return xe(o,{code:ke.invalid_type,expected:_e.set,received:o.parsedType}),Fe;const r=this._def;r.minSize!==null&&o.data.size<r.minSize.value&&(xe(o,{code:ke.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&&(xe(o,{code:ke.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 u of c){if(u.status==="aborted")return Fe;u.status==="dirty"&&n.dirty(),l.add(u.value)}return{status:n.value,value:l}}const s=[...o.data.values()].map((c,l)=>a._parse(new qr(o,c,o.path,l)));return o.common.async?Promise.all(s).then(c=>i(c)):i(s)}min(t,n){return new Vh({...this._def,minSize:{value:t,message:Le.toString(n)}})}max(t,n){return new Vh({...this._def,maxSize:{value:t,message:Le.toString(n)}})}size(t,n){return this.min(t,n).max(t,n)}nonempty(t){return this.min(1,t)}}Vh.create=(e,t)=>new Vh({valueType:e,minSize:null,maxSize:null,typeName:Oe.ZodSet,...Ke(t)});class AU 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})}}AU.create=(e,t)=>new AU({getter:e,typeName:Oe.ZodLazy,...Ke(t)});class gH extends et{_parse(t){if(t.data!==this._def.value){const n=this._getOrReturnCtx(t);return xe(n,{received:n.data,code:ke.invalid_literal,expected:this._def.value}),Fe}return{status:"valid",value:t.data}}get value(){return this._def.value}}gH.create=(e,t)=>new gH({value:e,typeName:Oe.ZodLiteral,...Ke(t)});function HQ(e,t){return new k0({values:e,typeName:Oe.ZodEnum,...Ke(t)})}class k0 extends et{_parse(t){if(typeof t.data!="string"){const n=this._getOrReturnCtx(t),o=this._def.values;return xe(n,{expected:it.joinValues(o),received:n.parsedType,code:ke.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 xe(n,{received:n.data,code:ke.invalid_enum_value,options:o}),Fe}return zo(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 k0.create(t,{...this._def,...n})}exclude(t,n=this._def){return k0.create(this.options.filter(o=>!t.includes(o)),{...this._def,...n})}}k0.create=HQ;class EU extends et{_parse(t){const n=it.getValidEnumValues(this._def.values),o=this._getOrReturnCtx(t);if(o.parsedType!==_e.string&&o.parsedType!==_e.number){const r=it.objectValues(n);return xe(o,{expected:it.joinValues(r),received:o.parsedType,code:ke.invalid_type}),Fe}if(this._cache||(this._cache=new Set(it.getValidEnumValues(this._def.values))),!this._cache.has(t.data)){const r=it.objectValues(n);return xe(o,{received:o.data,code:ke.invalid_enum_value,options:r}),Fe}return zo(t.data)}get enum(){return this._def.values}}EU.create=(e,t)=>new EU({values:e,typeName:Oe.ZodNativeEnum,...Ke(t)});class JP extends et{unwrap(){return this._def.type}_parse(t){const{ctx:n}=this._processInputParams(t);if(n.parsedType!==_e.promise&&n.common.async===!1)return xe(n,{code:ke.invalid_type,expected:_e.promise,received:n.parsedType}),Fe;const o=n.parsedType===_e.promise?n.data:Promise.resolve(n.data);return zo(o.then(r=>this._def.type.parseAsync(r,{path:n.path,errorMap:n.common.contextualErrorMap})))}}JP.create=(e,t)=>new JP({type:e,typeName:Oe.ZodPromise,...Ke(t)});class g0 extends et{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===Oe.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=>{xe(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"?b2(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"?b2(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(!y0(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=>y0(i)?Promise.resolve(r.transform(i.value,a)).then(s=>({status:n.value,value:s})):Fe);it.assertNever(r)}}g0.create=(e,t,n)=>new g0({schema:e,typeName:Oe.ZodEffects,effect:t,...Ke(n)});g0.createWithPreprocess=(e,t,n)=>new g0({schema:t,effect:{type:"preprocess",transform:e},typeName:Oe.ZodEffects,...Ke(n)});class wi extends et{_parse(t){return this._getType(t)===_e.undefined?zo(void 0):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}}wi.create=(e,t)=>new wi({innerType:e,typeName:Oe.ZodOptional,...Ke(t)});class v0 extends et{_parse(t){return this._getType(t)===_e.null?zo(null):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}}v0.create=(e,t)=>new v0({innerType:e,typeName:Oe.ZodNullable,...Ke(t)});class vH extends et{_parse(t){const{ctx:n}=this._processInputParams(t);let o=n.data;return n.parsedType===_e.undefined&&(o=this._def.defaultValue()),this._def.innerType._parse({data:o,path:n.path,parent:n})}removeDefault(){return this._def.innerType}}vH.create=(e,t)=>new vH({innerType:e,typeName:Oe.ZodDefault,defaultValue:typeof t.default=="function"?t.default:()=>t.default,...Ke(t)});class xH 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 KP(r)?r.then(a=>({status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new ga(o.common.issues)},input:o.data})})):{status:"valid",value:r.status==="valid"?r.value:this._def.catchValue({get error(){return new ga(o.common.issues)},input:o.data})}}removeCatch(){return this._def.innerType}}xH.create=(e,t)=>new xH({innerType:e,typeName:Oe.ZodCatch,catchValue:typeof t.catch=="function"?t.catch:()=>t.catch,...Ke(t)});class $U extends et{_parse(t){if(this._getType(t)!==_e.nan){const o=this._getOrReturnCtx(t);return xe(o,{code:ke.invalid_type,expected:_e.nan,received:o.parsedType}),Fe}return{status:"valid",value:t.data}}}$U.create=e=>new $U({typeName:Oe.ZodNaN,...Ke(e)});class gDe 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 xO 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(),b2(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 xO({in:t,out:n,typeName:Oe.ZodPipeline})}}class wH extends et{_parse(t){const n=this._def.innerType._parse(t),o=r=>(y0(r)&&(r.value=Object.freeze(r.value)),r);return KP(n)?n.then(r=>o(r)):o(n)}unwrap(){return this._def.innerType}}wH.create=(e,t)=>new wH({innerType:e,typeName:Oe.ZodReadonly,...Ke(t)});var Oe;(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"})(Oe||(Oe={}));const cn=ua.create,qQ=m0.create,vDe=yH.create,sh=mH.create;Si.create;const Xi=Tr.create,at=Bt.create,MH=XP.create;YP.create;Ld.create;const jU=QP.create,pp=gH.create,yp=k0.create;JP.create;wi.create;v0.create;const xDe=at({$state:cn().min(1)}),ra=at({$action:cn().min(1)}),wDe=at({$cond:sh(),$then:sh(),$else:sh().optional()}),Vo=e=>MH([e,xDe,ra,wDe]),Ht=Vo(cn()),ea=Vo(qQ()),mp=Vo(vDe()),OQ={Card:at({title:Ht.optional()}),Separator:at({orientation:Vo(yp(["horizontal","vertical"])).optional()}),Tabs:at({value:Ht.optional(),items:Xi(at({id:cn(),label:cn()})),onChange:ra.optional()}),Accordion:at({items:Xi(at({id:cn(),title:cn(),content:cn()}))}),Badge:at({label:Ht,variant:Vo(yp(["default","secondary","destructive","outline"])).optional()}),Avatar:at({src:Ht.optional(),alt:Ht.optional(),fallback:Ht.optional()}),Progress:at({value:ea}),Skeleton:at({width:ea.optional(),height:ea.optional()}),Label:at({text:Ht}),Heading:at({level:Vo(MH([pp(1),pp(2),pp(3),pp(4)])).optional(),text:Ht}),Text:at({text:Ht,muted:mp.optional()}),Icon:at({name:Ht,size:ea.optional()}),Chart:at({kind:Vo(yp(["bar","line","area","pie"])),data:Vo(Xi(jU(cn(),sh()))),xKey:Ht.optional(),series:Xi(at({key:cn(),label:cn().optional()})).optional()}),Table:at({columns:Xi(at({key:cn(),label:cn()})),rows:Vo(Xi(jU(cn(),sh())))}),Metric:at({label:Ht,value:Vo(MH([cn(),qQ()]))}),CodeBlock:at({code:Ht,language:Ht.optional()}),Markdown:at({content:Ht}),Button:at({label:Ht,variant:Vo(yp(["default","destructive","outline","secondary","ghost","link"])).optional(),onClick:ra.optional(),disabled:mp.optional()}),Input:at({value:Ht.optional(),placeholder:Ht.optional(),onChange:ra.optional()}),Checkbox:at({checked:mp.optional(),onChange:ra.optional(),label:Ht.optional()}),Switch:at({checked:mp.optional(),onChange:ra.optional()}),Select:at({value:Ht.optional(),items:Xi(at({value:cn(),label:cn()})),onChange:ra.optional()}),Textarea:at({value:Ht.optional(),placeholder:Ht.optional(),rows:ea.optional(),onChange:ra.optional()}),Slider:at({value:ea.optional(),min:ea.optional(),max:ea.optional(),step:ea.optional(),onChange:ra.optional()})},FQ=Object.keys(OQ);Object.fromEntries(FQ.map(e=>[e,{props:OQ[e],description:e}]));function PU(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function Or(...e){return t=>{let n=!1;const o=e.map(r=>{const a=PU(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():PU(e[r],null)}}}}function gt(...e){return m.useCallback(Or(...e),e)}var MDe=Symbol.for("react.lazy"),ez=lq[" use ".trim().toString()];function bDe(e){return typeof e=="object"&&e!==null&&"then"in e}function VQ(e){return e!=null&&typeof e=="object"&&"$$typeof"in e&&e.$$typeof===MDe&&"_payload"in e&&bDe(e._payload)}function _De(e){const t=SDe(e),n=m.forwardRef((o,r)=>{let{children:a,...i}=o;VQ(a)&&typeof ez=="function"&&(a=ez(a._payload));const s=m.Children.toArray(a),c=s.find(NDe);if(c){const l=c.props.children,u=s.map(h=>h===c?m.Children.count(l)>1?m.Children.only(null):m.isValidElement(l)?l.props.children:null:h);return p.jsx(t,{...i,ref:r,children:m.isValidElement(l)?m.cloneElement(l,void 0,u):null})}return p.jsx(t,{...i,ref:r,children:a})});return n.displayName=`${e}.Slot`,n}var CDe=_De("Slot");function SDe(e){const t=m.forwardRef((n,o)=>{let{children:r,...a}=n;if(VQ(r)&&typeof ez=="function"&&(r=ez(r._payload)),m.isValidElement(r)){const i=ADe(r),s=IDe(a,r.props);return r.type!==m.Fragment&&(s.ref=o?Or(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 LDe=Symbol("radix.slottable");function NDe(e){return m.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===LDe}function IDe(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 ADe(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 zU=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,RU=jX,BQ=(e,t)=>n=>{var o;if((t==null?void 0:t.variants)==null)return RU(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 u=n==null?void 0:n[l],h=a==null?void 0:a[l];if(u===null)return null;const f=zU(u)||zU(h);return r[l][f]}),s=n&&Object.entries(n).reduce((l,u)=>{let[h,f]=u;return f===void 0||(l[h]=f),l},{}),c=t==null||(o=t.compoundVariants)===null||o===void 0?void 0:o.reduce((l,u)=>{let{class:h,className:f,...y}=u;return Object.entries(y).every(k=>{let[v,w]=k;return Array.isArray(w)?w.includes({...a,...s}[v]):{...a,...s}[v]===w})?[...l,h,f]:l},[]);return RU(e,i,c,n==null?void 0:n.class,n==null?void 0:n.className)},EDe=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"}}),dt=m.forwardRef(({className:e,variant:t,size:n,asChild:o=!1,...r},a)=>{const i=o?CDe:"button";return p.jsx(i,{className:ie(EDe({variant:t,size:n,className:e})),ref:a,...r})});dt.displayName="Button";function UQ(e,[t,n]){return Math.min(n,Math.max(t,e))}function Ce(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 $De(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 or(e,t=[]){let n=[];function o(a,i){const s=m.createContext(i),c=n.length;n=[...n,i];const l=h=>{var g;const{scope:f,children:y,...k}=h,v=((g=f==null?void 0:f[e])==null?void 0:g[c])||s,w=m.useMemo(()=>k,Object.values(k));return p.jsx(v.Provider,{value:w,children:y})};l.displayName=a+"Provider";function u(h,f){var v;const y=((v=f==null?void 0:f[e])==null?void 0:v[c])||s,k=m.useContext(y);if(k)return k;if(i!==void 0)return i;throw new Error(`\`${h}\` must be used within \`${a}\``)}return[l,u]}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,jDe(r,...t)]}function jDe(...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 h=c(a)[`__scope${l}`];return{...s,...h}},{});return m.useMemo(()=>({[`__scope${t.scopeName}`]:i}),[i])}};return n.scopeName=t.scopeName,n}var Li=globalThis!=null&&globalThis.document?m.useLayoutEffect:()=>{},PDe=lq[" useInsertionEffect ".trim().toString()]||Li;function zd({prop:e,defaultProp:t,onChange:n=()=>{},caller:o}){const[r,a,i]=zDe({defaultProp:t,onChange:n}),s=e!==void 0,c=s?e:r;{const u=m.useRef(e!==void 0);m.useEffect(()=>{const h=u.current;h!==s&&console.warn(`${o} is changing from ${h?"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.`),u.current=s},[s,o])}const l=m.useCallback(u=>{var h;if(s){const f=RDe(u)?u(e):u;f!==e&&((h=i.current)==null||h.call(i,f))}else a(u)},[s,e,a,i]);return[c,l]}function zDe({defaultProp:e,onChange:t}){const[n,o]=m.useState(e),r=m.useRef(n),a=m.useRef(t);return PDe(()=>{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 RDe(e){return typeof e=="function"}var TDe=m.createContext(void 0);function Kz(e){const t=m.useContext(TDe);return e||t||"ltr"}function DDe(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 WQ(e){const[t,n]=m.useState(void 0);return Li(()=>{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 x0(e){const t=HDe(e),n=m.forwardRef((o,r)=>{const{children:a,...i}=o,s=m.Children.toArray(a),c=s.find(ODe);if(c){const l=c.props.children,u=s.map(h=>h===c?m.Children.count(l)>1?m.Children.only(null):m.isValidElement(l)?l.props.children:null:h);return p.jsx(t,{...i,ref:r,children:m.isValidElement(l)?m.cloneElement(l,void 0,u):null})}return p.jsx(t,{...i,ref:r,children:a})});return n.displayName=`${e}.Slot`,n}function HDe(e){const t=m.forwardRef((n,o)=>{const{children:r,...a}=n;if(m.isValidElement(r)){const i=VDe(r),s=FDe(a,r.props);return r.type!==m.Fragment&&(s.ref=o?Or(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 GQ=Symbol("radix.slottable");function qDe(e){const t=({children:n})=>p.jsx(p.Fragment,{children:n});return t.displayName=`${e}.Slottable`,t.__radixId=GQ,t}function ODe(e){return m.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===GQ}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 VDe(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 BDe=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Ue=BDe.reduce((e,t)=>{const n=x0(`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 KQ(e,t){e&&I0.flushSync(()=>e.dispatchEvent(t))}function wO(e){const t=e+"CollectionProvider",[n,o]=or(t),[r,a]=n(t,{collectionRef:{current:null},itemMap:new Map}),i=v=>{const{scope:w,children:g}=v,M=Lr.useRef(null),x=Lr.useRef(new Map).current;return p.jsx(r,{scope:w,itemMap:x,collectionRef:M,children:g})};i.displayName=t;const s=e+"CollectionSlot",c=x0(s),l=Lr.forwardRef((v,w)=>{const{scope:g,children:M}=v,x=a(s,g),b=gt(w,x.collectionRef);return p.jsx(c,{ref:b,children:M})});l.displayName=s;const u=e+"CollectionItemSlot",h="data-radix-collection-item",f=x0(u),y=Lr.forwardRef((v,w)=>{const{scope:g,children:M,...x}=v,b=Lr.useRef(null),C=gt(w,b),_=a(u,g);return Lr.useEffect(()=>(_.itemMap.set(b,{ref:b,...x}),()=>void _.itemMap.delete(b))),p.jsx(f,{[h]:"",ref:C,children:M})});y.displayName=u;function k(v){const w=a(e+"CollectionConsumer",v);return Lr.useCallback(()=>{const M=w.collectionRef.current;if(!M)return[];const x=Array.from(M.querySelectorAll(`[${h}]`));return Array.from(w.itemMap.values()).sort((_,S)=>x.indexOf(_.ref.current)-x.indexOf(S.ref.current))},[w.collectionRef,w.itemMap])}return[{Provider:i,Slot:l,ItemSlot:y},k,o]}var ZQ=["PageUp","PageDown"],XQ=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],YQ={"from-left":["Home","PageDown","ArrowDown","ArrowLeft"],"from-right":["Home","PageDown","ArrowDown","ArrowRight"],"from-bottom":["Home","PageDown","ArrowDown","ArrowLeft"],"from-top":["Home","PageDown","ArrowUp","ArrowLeft"]},j0="Slider",[bH,UDe,WDe]=wO(j0),[QQ]=or(j0,[WDe]),[GDe,Zz]=QQ(j0),JQ=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:u,onValueChange:h=()=>{},onValueCommit:f=()=>{},inverted:y=!1,form:k,...v}=e,w=m.useRef(new Set),g=m.useRef(0),x=i==="horizontal"?KDe:ZDe,[b=[],C]=zd({prop:u,defaultProp:l,onChange:A=>{var Y;(Y=[...w.current][g.current])==null||Y.focus(),h(A)}}),_=m.useRef(b);function S(A){const R=eHe(b,A);N(A,R)}function $(A){N(A,g.current)}function j(){const A=_.current[g.current];b[g.current]!==A&&f(b)}function N(A,R,{commit:Y}={commit:!1}){const z=rHe(a),V=aHe(Math.round((A-o)/a)*a+o,z),H=UQ(V,[o,r]);C((O=[])=>{const P=QDe(O,H,R);if(oHe(P,c*a)){g.current=P.indexOf(H);const I=String(P)!==String(O);return I&&Y&&f(P),I?P:O}else return O})}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(bH.Provider,{scope:e.__scopeSlider,children:p.jsx(bH.Slot,{scope:e.__scopeSlider,children:p.jsx(x,{"aria-disabled":s,"data-disabled":s?"":void 0,...v,ref:t,onPointerDown:Ce(v.onPointerDown,()=>{s||(_.current=b)}),min:o,max:r,inverted:y,onSlideStart:s?void 0:S,onSlideMove:s?void 0:$,onSlideEnd:s?void 0:j,onHomeKeyDown:()=>!s&&N(o,0,{commit:!0}),onEndKeyDown:()=>!s&&N(r,b.length-1,{commit:!0}),onStepKeyDown:({event:A,direction:R})=>{if(!s){const V=ZQ.includes(A.key)||A.shiftKey&&XQ.includes(A.key)?10:1,H=g.current,O=b[H],P=a*V*R;N(O+P,H,{commit:!0})}}})})})})});JQ.displayName=j0;var[eJ,tJ]=QQ(j0,{startEdge:"left",endEdge:"right",size:"width",direction:1}),KDe=m.forwardRef((e,t)=>{const{min:n,max:o,dir:r,inverted:a,onSlideStart:i,onSlideMove:s,onSlideEnd:c,onStepKeyDown:l,...u}=e,[h,f]=m.useState(null),y=gt(t,x=>f(x)),k=m.useRef(void 0),v=Kz(r),w=v==="ltr",g=w&&!a||!w&&a;function M(x){const b=k.current||h.getBoundingClientRect(),C=[0,b.width],S=MO(C,g?[n,o]:[o,n]);return k.current=b,S(x-b.left)}return p.jsx(eJ,{scope:e.__scopeSlider,startEdge:g?"left":"right",endEdge:g?"right":"left",direction:g?1:-1,size:"width",children:p.jsx(nJ,{dir:v,"data-orientation":"horizontal",...u,ref:y,style:{...u.style,"--radix-slider-thumb-transform":"translateX(-50%)"},onSlideStart:x=>{const b=M(x.clientX);i==null||i(b)},onSlideMove:x=>{const b=M(x.clientX);s==null||s(b)},onSlideEnd:()=>{k.current=void 0,c==null||c()},onStepKeyDown:x=>{const C=YQ[g?"from-left":"from-right"].includes(x.key);l==null||l({event:x,direction:C?-1:1})}})})}),ZDe=m.forwardRef((e,t)=>{const{min:n,max:o,inverted:r,onSlideStart:a,onSlideMove:i,onSlideEnd:s,onStepKeyDown:c,...l}=e,u=m.useRef(null),h=gt(t,u),f=m.useRef(void 0),y=!r;function k(v){const w=f.current||u.current.getBoundingClientRect(),g=[0,w.height],x=MO(g,y?[o,n]:[n,o]);return f.current=w,x(v-w.top)}return p.jsx(eJ,{scope:e.__scopeSlider,startEdge:y?"bottom":"top",endEdge:y?"top":"bottom",size:"height",direction:y?1:-1,children:p.jsx(nJ,{"data-orientation":"vertical",...l,ref:h,style:{...l.style,"--radix-slider-thumb-transform":"translateY(50%)"},onSlideStart:v=>{const w=k(v.clientY);a==null||a(w)},onSlideMove:v=>{const w=k(v.clientY);i==null||i(w)},onSlideEnd:()=>{f.current=void 0,s==null||s()},onStepKeyDown:v=>{const g=YQ[y?"from-bottom":"from-top"].includes(v.key);c==null||c({event:v,direction:g?-1:1})}})})}),nJ=m.forwardRef((e,t)=>{const{__scopeSlider:n,onSlideStart:o,onSlideMove:r,onSlideEnd:a,onHomeKeyDown:i,onEndKeyDown:s,onStepKeyDown:c,...l}=e,u=Zz(j0,n);return p.jsx(Ue.span,{...l,ref:t,onKeyDown:Ce(e.onKeyDown,h=>{h.key==="Home"?(i(h),h.preventDefault()):h.key==="End"?(s(h),h.preventDefault()):ZQ.concat(XQ).includes(h.key)&&(c(h),h.preventDefault())}),onPointerDown:Ce(e.onPointerDown,h=>{const f=h.target;f.setPointerCapture(h.pointerId),h.preventDefault(),u.thumbs.has(f)?f.focus():o(h)}),onPointerMove:Ce(e.onPointerMove,h=>{h.target.hasPointerCapture(h.pointerId)&&r(h)}),onPointerUp:Ce(e.onPointerUp,h=>{const f=h.target;f.hasPointerCapture(h.pointerId)&&(f.releasePointerCapture(h.pointerId),a(h))})})}),oJ="SliderTrack",rJ=m.forwardRef((e,t)=>{const{__scopeSlider:n,...o}=e,r=Zz(oJ,n);return p.jsx(Ue.span,{"data-disabled":r.disabled?"":void 0,"data-orientation":r.orientation,...o,ref:t})});rJ.displayName=oJ;var _H="SliderRange",aJ=m.forwardRef((e,t)=>{const{__scopeSlider:n,...o}=e,r=Zz(_H,n),a=tJ(_H,n),i=m.useRef(null),s=gt(t,i),c=r.values.length,l=r.values.map(f=>cJ(f,r.min,r.max)),u=c>1?Math.min(...l):0,h=100-Math.max(...l);return p.jsx(Ue.span,{"data-orientation":r.orientation,"data-disabled":r.disabled?"":void 0,...o,ref:s,style:{...e.style,[a.startEdge]:u+"%",[a.endEdge]:h+"%"}})});aJ.displayName=_H;var CH="SliderThumb",iJ=m.forwardRef((e,t)=>{const n=UDe(e.__scopeSlider),[o,r]=m.useState(null),a=gt(t,s=>r(s)),i=m.useMemo(()=>o?n().findIndex(s=>s.ref.current===o):-1,[n,o]);return p.jsx(XDe,{...e,ref:a,index:i})}),XDe=m.forwardRef((e,t)=>{const{__scopeSlider:n,index:o,name:r,...a}=e,i=Zz(CH,n),s=tJ(CH,n),[c,l]=m.useState(null),u=gt(t,M=>l(M)),h=c?i.form||!!c.closest("form"):!0,f=WQ(c),y=i.values[o],k=y===void 0?0:cJ(y,i.min,i.max),v=JDe(o,i.values.length),w=f==null?void 0:f[s.size],g=w?tHe(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(bH.ItemSlot,{scope:e.__scopeSlider,children:p.jsx(Ue.span,{role:"slider","aria-label":e["aria-label"]||v,"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:u,style:y===void 0?{display:"none"}:e.style,onFocus:Ce(e.onFocus,()=>{i.valueIndexToChangeRef.current=o})})}),h&&p.jsx(sJ,{name:r??(i.name?i.name+(i.values.length>1?"[]":""):void 0),form:i.form,value:y},o)]})});iJ.displayName=CH;var YDe="RadioBubbleInput",sJ=m.forwardRef(({__scopeSlider:e,value:t,...n},o)=>{const r=m.useRef(null),a=gt(r,o),i=DDe(t);return m.useEffect(()=>{const s=r.current;if(!s)return;const c=window.HTMLInputElement.prototype,u=Object.getOwnPropertyDescriptor(c,"value").set;if(i!==t&&u){const h=new Event("input",{bubbles:!0});u.call(s,t),s.dispatchEvent(h)}},[i,t]),p.jsx(Ue.input,{style:{display:"none"},...n,ref:a,defaultValue:t})});sJ.displayName=YDe;function QDe(e=[],t,n){const o=[...e];return o[n]=t,o.sort((r,a)=>r-a)}function cJ(e,t,n){const a=100/(n-t)*(e-t);return UQ(a,[0,100])}function JDe(e,t){return t>2?`Value ${e+1} of ${t}`:t===2?["Minimum","Maximum"][e]:void 0}function eHe(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 tHe(e,t,n){const o=e/2,a=MO([0,50],[0,o]);return(o-a(t)*n)*n}function nHe(e){return e.slice(0,-1).map((t,n)=>e[n+1]-t)}function oHe(e,t){if(t>0){const n=nHe(e);return Math.min(...n)>=t}return!0}function MO(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 rHe(e){return(String(e).split(".")[1]||"").length}function aHe(e,t){const n=Math.pow(10,t);return Math.round(e*n)/n}var lJ=JQ,iHe=rJ,sHe=aJ,cHe=iJ;const bO=m.forwardRef(({className:e,...t},n)=>p.jsxs(lJ,{ref:n,className:ie("sf:relative sf:flex sf:w-full sf:touch-none sf:select-none sf:items-center",e),...t,children:[p.jsx(iHe,{className:"sf:relative sf:h-1.5 sf:w-full sf:grow sf:overflow-hidden sf:rounded-full sf:bg-secondary",children:p.jsx(sHe,{className:"sf:absolute sf:h-full sf:bg-primary"})}),p.jsx(cHe,{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"})]}));bO.displayName=lJ.displayName;const lHe={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 dHe({text:e,level:t=2}){const n=`h${t}`;return p.jsx(n,{className:ie(lHe[t]),children:e})}const dJ=m.createContext({custom:{}});function uHe({value:e,children:t}){return p.jsx(dJ.Provider,{value:e,children:t})}function hHe(){return m.useContext(dJ)}function w0({name:e,as:t,size:n=16,fallback:o=ZNe,...r}){const a=hHe(),i=t??(e?a.custom[e]:void 0)??(e?r0[e]:void 0)??r0[o];return i?p.jsx(i,{size:n,...r}):null}function fHe({name:e,size:t=16}){return p.jsx(w0,{name:e,size:t,"aria-hidden":!0})}function pHe(e){return e==null?"":typeof e=="string"||typeof e=="number"?e:typeof e=="object"?JSON.stringify(e):String(e)}function yHe({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:pHe(t)})]})}function mHe(e){return e==null?"":typeof e=="string"||typeof e=="number"?String(e):JSON.stringify(e)}function kHe({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:mHe(n[r.key])},r.key))},o))})]})})}function gHe({text:e,muted:t}){return p.jsx("p",{className:ie("sf:text-sm",t&&"sf:text-muted-foreground"),children:e})}function vHe({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 xHe({orientation:e="horizontal"}){return p.jsx("div",{"aria-orientation":e,className:ie("sf:bg-border",e==="horizontal"?"sf:h-px sf:w-full":"sf:h-full sf:w-px")})}function wHe({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 MHe({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 TU={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 bHe({label:e,variant:t="default"}){return p.jsx("span",{className:ie("sf:inline-flex sf:items-center sf:rounded-full sf:px-2.5 sf:py-0.5 sf:font-medium sf:text-xs",TU[t]??TU.default),children:e})}function _He({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 CHe({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 SHe({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 LHe({text:e}){return p.jsx("span",{className:"sf:font-medium sf:text-sm sf:leading-none",children:e})}function NHe({label:e,variant:t="default",onClick:n,disabled:o}){return p.jsx(dt,{variant:t,disabled:o,onClick:()=>n==null?void 0:n(),children:e})}const _O="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 IHe({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:_O})}function AHe({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 EHe({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:ie("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:ie("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 $He({value:e,items:t,onChange:n}){return p.jsx("select",{value:e??"",onChange:o=>n==null?void 0:n({value:o.target.value}),className:_O,children:(t??[]).map(o=>p.jsx("option",{value:o.value,children:o.label},o.value))})}function jHe({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:ie(_O,"sf:min-h-16 sf:py-2")})}function PHe({value:e,min:t=0,max:n=100,step:o=1,onChange:r}){return p.jsx(bO,{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 zHe=m.lazy(()=>ff(()=>import("./chart-BbL2c3JQ.js"),__vite__mapDeps([0,1,2,3,4,5,6,7])));function RHe(e){return p.jsx(m.Suspense,{fallback:null,children:p.jsx(zHe,{...e})})}const THe=m.lazy(()=>ff(()=>import("./markdown-B0s014Jt.js"),[]));function DHe(e){return p.jsx(m.Suspense,{fallback:null,children:p.jsx(THe,{...e})})}const HHe=m.lazy(()=>ff(()=>import("./code-block-DTN7FEQj.js"),[]));function qHe(e){return p.jsx(m.Suspense,{fallback:null,children:p.jsx(HHe,{...e})})}const uJ={Card:vHe,Separator:xHe,Tabs:wHe,Accordion:MHe,Badge:bHe,Avatar:_He,Progress:CHe,Skeleton:SHe,Label:LHe,Heading:dHe,Text:gHe,Icon:fHe,Chart:RHe,Table:kHe,Metric:yHe,CodeBlock:qHe,Markdown:DHe,Button:NHe,Input:IHe,Checkbox:AHe,Switch:EHe,Select:$He,Textarea:jHe,Slider:PHe},DU=FQ.filter(e=>uJ[e]===void 0);if(DU.length>0)throw new Error(`componentRegistry is missing impls for: ${DU.join(", ")}. Every catalog entry in COMPONENT_NAMES must have a matching component impl.`);const OHe={components:uJ};function FHe(e,t){return t.kind==="set"?{...e,[t.path]:t.value}:{...e,...t.partial}}function hJ(e){return e===null||typeof e!="object"?!1:"$state"in e||"$action"in e||"$param"in e||"$cond"in e}function oP(e,t,n,o){if(!hJ(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=oP(e.$cond,t,n,o);return oP(r?e.$then:e.$else,t,n,o)}return e}function VHe(e,t,n,o){if(!e)return{};const r={};for(const[a,i]of Object.entries(e))r[a]=oP(i,t,n,o);return r}function HU({spec:e,nodeId:t,apiBaseUrl:n="/api",projectSlug:o,flowSlug:r}){const[a,i]=m.useReducer(FHe,e.state??{}),s=new Set(Object.keys(e.actions??{})),c=m.useCallback(async(l,u)=>{var y;const h=(y=e.actions)==null?void 0:y[l];if(!h)return;if(h.kind==="set"){const k=BHe(h.value,u,a);i({kind:"set",path:h.path,value:k});return}if(!o||!r)return;const f=`${n}/projects/${encodeURIComponent(o)}/flows/${encodeURIComponent(r)}/nodes/${encodeURIComponent(t)}/actions/${encodeURIComponent(l)}`;try{const k=await fetch(f,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(u??{})});if(!k.ok){const w=await k.text();i({kind:"set",path:`/__errors/${l}`,value:w});return}const v=await k.json();v!==null&&typeof v=="object"&&i({kind:"merge",partial:v})}catch(k){i({kind:"set",path:`/__errors/${l}`,value:k instanceof Error?k.message:String(k)})}},[e.actions,o,r,n,t,a]);return fJ(e.root,e,a,c,s)}function BHe(e,t,n){return hJ(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 fJ(e,t,n,o,r){const a=t.elements[e];if(!a)return null;const i=OHe.components[a.type];if(!i)return null;const s=VHe(a.props,n,o,r),l=(a.children??[]).map(u=>p.jsx(UHe,{children:fJ(u,t,n,o,r)},u));return p.jsx(i,{...s,children:l.length>0?l:void 0})}function UHe({children:e}){return e}function Fr(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 WHe(e,t=globalThis==null?void 0:globalThis.document){const n=Fr(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",SH="dismissableLayer.update",KHe="dismissableLayer.pointerDownOutside",ZHe="dismissableLayer.focusOutside",qU,pJ=m.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),pf=m.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:o,onPointerDownOutside:r,onFocusOutside:a,onInteractOutside:i,onDismiss:s,...c}=e,l=m.useContext(pJ),[u,h]=m.useState(null),f=(u==null?void 0:u.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,y]=m.useState({}),k=gt(t,S=>h(S)),v=Array.from(l.layers),[w]=[...l.layersWithOutsidePointerEventsDisabled].slice(-1),g=v.indexOf(w),M=u?v.indexOf(u):-1,x=l.layersWithOutsidePointerEventsDisabled.size>0,b=M>=g,C=QHe(S=>{const $=S.target,j=[...l.branches].some(N=>N.contains($));!b||j||(r==null||r(S),i==null||i(S),S.defaultPrevented||s==null||s())},f),_=JHe(S=>{const $=S.target;[...l.branches].some(N=>N.contains($))||(a==null||a(S),i==null||i(S),S.defaultPrevented||s==null||s())},f);return WHe(S=>{M===l.layers.size-1&&(o==null||o(S),!S.defaultPrevented&&s&&(S.preventDefault(),s()))},f),m.useEffect(()=>{if(u)return n&&(l.layersWithOutsidePointerEventsDisabled.size===0&&(qU=f.body.style.pointerEvents,f.body.style.pointerEvents="none"),l.layersWithOutsidePointerEventsDisabled.add(u)),l.layers.add(u),OU(),()=>{n&&l.layersWithOutsidePointerEventsDisabled.size===1&&(f.body.style.pointerEvents=qU)}},[u,f,n,l]),m.useEffect(()=>()=>{u&&(l.layers.delete(u),l.layersWithOutsidePointerEventsDisabled.delete(u),OU())},[u,l]),m.useEffect(()=>{const S=()=>y({});return document.addEventListener(SH,S),()=>document.removeEventListener(SH,S)},[]),p.jsx(Ue.div,{...c,ref:k,style:{pointerEvents:x?b?"auto":"none":void 0,...e.style},onFocusCapture:Ce(e.onFocusCapture,_.onFocusCapture),onBlurCapture:Ce(e.onBlurCapture,_.onBlurCapture),onPointerDownCapture:Ce(e.onPointerDownCapture,C.onPointerDownCapture)})});pf.displayName=GHe;var XHe="DismissableLayerBranch",YHe=m.forwardRef((e,t)=>{const n=m.useContext(pJ),o=m.useRef(null),r=gt(t,o);return m.useEffect(()=>{const a=o.current;if(a)return n.branches.add(a),()=>{n.branches.delete(a)}},[n.branches]),p.jsx(Ue.div,{...e,ref:r})});YHe.displayName=XHe;function QHe(e,t=globalThis==null?void 0:globalThis.document){const n=Fr(e),o=m.useRef(!1),r=m.useRef(()=>{});return m.useEffect(()=>{const a=s=>{if(s.target&&!o.current){let c=function(){yJ(KHe,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 JHe(e,t=globalThis==null?void 0:globalThis.document){const n=Fr(e),o=m.useRef(!1);return m.useEffect(()=>{const r=a=>{a.target&&!o.current&&yJ(ZHe,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 OU(){const e=new CustomEvent(SH);document.dispatchEvent(e)}function yJ(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?KQ(r,a):r.dispatchEvent(a)}var kT=0;function CO(){m.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??FU()),document.body.insertAdjacentElement("beforeend",e[1]??FU()),kT++,()=>{kT===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),kT--}},[])}function FU(){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 gT="focusScope.autoFocusOnMount",vT="focusScope.autoFocusOnUnmount",VU={bubbles:!1,cancelable:!0},eqe="FocusScope",Xz=m.forwardRef((e,t)=>{const{loop:n=!1,trapped:o=!1,onMountAutoFocus:r,onUnmountAutoFocus:a,...i}=e,[s,c]=m.useState(null),l=Fr(r),u=Fr(a),h=m.useRef(null),f=gt(t,v=>c(v)),y=m.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;m.useEffect(()=>{if(o){let v=function(x){if(y.paused||!s)return;const b=x.target;s.contains(b)?h.current=b:Ja(h.current,{select:!0})},w=function(x){if(y.paused||!s)return;const b=x.relatedTarget;b!==null&&(s.contains(b)||Ja(h.current,{select:!0}))},g=function(x){if(document.activeElement===document.body)for(const C of x)C.removedNodes.length>0&&Ja(s)};document.addEventListener("focusin",v),document.addEventListener("focusout",w);const M=new MutationObserver(g);return s&&M.observe(s,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",v),document.removeEventListener("focusout",w),M.disconnect()}}},[o,s,y.paused]),m.useEffect(()=>{if(s){UU.add(y);const v=document.activeElement;if(!s.contains(v)){const g=new CustomEvent(gT,VU);s.addEventListener(gT,l),s.dispatchEvent(g),g.defaultPrevented||(tqe(iqe(mJ(s)),{select:!0}),document.activeElement===v&&Ja(s))}return()=>{s.removeEventListener(gT,l),setTimeout(()=>{const g=new CustomEvent(vT,VU);s.addEventListener(vT,u),s.dispatchEvent(g),g.defaultPrevented||Ja(v??document.body,{select:!0}),s.removeEventListener(vT,u),UU.remove(y)},0)}}},[s,l,u,y]);const k=m.useCallback(v=>{if(!n&&!o||y.paused)return;const w=v.key==="Tab"&&!v.altKey&&!v.ctrlKey&&!v.metaKey,g=document.activeElement;if(w&&g){const M=v.currentTarget,[x,b]=nqe(M);x&&b?!v.shiftKey&&g===b?(v.preventDefault(),n&&Ja(x,{select:!0})):v.shiftKey&&g===x&&(v.preventDefault(),n&&Ja(b,{select:!0})):g===M&&v.preventDefault()}},[n,o,y.paused]);return p.jsx(Ue.div,{tabIndex:-1,...i,ref:f,onKeyDown:k})});Xz.displayName=eqe;function tqe(e,{select:t=!1}={}){const n=document.activeElement;for(const o of e)if(Ja(o,{select:t}),document.activeElement!==n)return}function nqe(e){const t=mJ(e),n=BU(t,e),o=BU(t.reverse(),e);return[n,o]}function mJ(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 BU(e,t){for(const n of e)if(!oqe(n,{upTo:t}))return n}function oqe(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 rqe(e){return e instanceof HTMLInputElement&&"select"in e}function Ja(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&rqe(e)&&t&&e.select()}}var UU=aqe();function aqe(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=WU(e,t),e.unshift(t)},remove(t){var n;e=WU(e,t),(n=e[0])==null||n.resume()}}}function WU(e,t){const n=[...e],o=n.indexOf(t);return o!==-1&&n.splice(o,1),n}function iqe(e){return e.filter(t=>t.tagName!=="A")}var sqe=lq[" useId ".trim().toString()]||(()=>{}),cqe=0;function jn(e){const[t,n]=m.useState(sqe());return Li(()=>{n(o=>o??String(cqe++))},[e]),e||(t?`radix-${t}`:"")}const lqe=["top","right","bottom","left"],Ni=Math.min,uo=Math.max,tz=Math.round,kp=Math.floor,Dr=e=>({x:e,y:e}),dqe={left:"right",right:"left",bottom:"top",top:"bottom"};function LH(e,t,n){return uo(e,Ni(t,n))}function va(e,t){return typeof e=="function"?e(t):e}function xa(e){return e.split("-")[0]}function P0(e){return e.split("-")[1]}function SO(e){return e==="x"?"y":"x"}function LO(e){return e==="y"?"height":"width"}function $r(e){const t=e[0];return t==="t"||t==="b"?"y":"x"}function NO(e){return SO($r(e))}function uqe(e,t,n){n===void 0&&(n=!1);const o=P0(e),r=NO(e),a=LO(r);let i=r==="x"?o===(n?"end":"start")?"right":"left":o==="start"?"bottom":"top";return t.reference[a]>t.floating[a]&&(i=nz(i)),[i,nz(i)]}function hqe(e){const t=nz(e);return[NH(e),t,NH(t)]}function NH(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const GU=["left","right"],KU=["right","left"],fqe=["top","bottom"],pqe=["bottom","top"];function yqe(e,t,n){switch(e){case"top":case"bottom":return n?t?KU:GU:t?GU:KU;case"left":case"right":return t?fqe:pqe;default:return[]}}function mqe(e,t,n,o){const r=P0(e);let a=yqe(xa(e),n==="start",o);return r&&(a=a.map(i=>i+"-"+r),t&&(a=a.concat(a.map(NH)))),a}function nz(e){const t=xa(e);return dqe[t]+e.slice(t.length)}function kqe(e){return{top:0,right:0,bottom:0,left:0,...e}}function kJ(e){return typeof e!="number"?kqe(e):{top:e,right:e,bottom:e,left:e}}function oz(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 ZU(e,t,n){let{reference:o,floating:r}=e;const a=$r(t),i=NO(t),s=LO(i),c=xa(t),l=a==="y",u=o.x+o.width/2-r.width/2,h=o.y+o.height/2-r.height/2,f=o[s]/2-r[s]/2;let y;switch(c){case"top":y={x:u,y:o.y-r.height};break;case"bottom":y={x:u,y:o.y+o.height};break;case"right":y={x:o.x+o.width,y:h};break;case"left":y={x:o.x-r.width,y:h};break;default:y={x:o.x,y:o.y}}switch(P0(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 gqe(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:u="viewport",elementContext:h="floating",altBoundary:f=!1,padding:y=0}=va(t,e),k=kJ(y),w=s[f?h==="floating"?"reference":"floating":h],g=oz(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:u,strategy:c})),M=h==="floating"?{x:o,y:r,width:i.floating.width,height:i.floating.height}:i.reference,x=await(a.getOffsetParent==null?void 0:a.getOffsetParent(s.floating)),b=await(a.isElement==null?void 0:a.isElement(x))?await(a.getScale==null?void 0:a.getScale(x))||{x:1,y:1}:{x:1,y:1},C=oz(a.convertOffsetParentRelativeRectToViewportRelativeRect?await a.convertOffsetParentRelativeRectToViewportRelativeRect({elements:s,rect:M,offsetParent:x,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 vqe=50,xqe=async(e,t,n)=>{const{placement:o="bottom",strategy:r="absolute",middleware:a=[],platform:i}=n,s=i.detectOverflow?i:{...i,detectOverflow:gqe},c=await(i.isRTL==null?void 0:i.isRTL(t));let l=await i.getElementRects({reference:e,floating:t,strategy:r}),{x:u,y:h}=ZU(l,o,c),f=o,y=0;const k={};for(let v=0;v<a.length;v++){const w=a[v];if(!w)continue;const{name:g,fn:M}=w,{x,y:b,data:C,reset:_}=await M({x:u,y:h,initialPlacement:o,placement:f,strategy:r,middlewareData:k,rects:l,platform:s,elements:{reference:e,floating:t}});u=x??u,h=b??h,k[g]={...k[g],...C},_&&y<vqe&&(y++,typeof _=="object"&&(_.placement&&(f=_.placement),_.rects&&(l=_.rects===!0?await i.getElementRects({reference:e,floating:t,strategy:r}):_.rects),{x:u,y:h}=ZU(l,f,c)),v=-1)}return{x:u,y:h,placement:f,strategy:r,middlewareData:k}},wqe=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:u=0}=va(e,t)||{};if(l==null)return{};const h=kJ(u),f={x:n,y:o},y=NO(r),k=LO(y),v=await i.getDimensions(l),w=y==="y",g=w?"top":"left",M=w?"bottom":"right",x=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=_?_[x]:0;(!S||!await(i.isElement==null?void 0:i.isElement(_)))&&(S=s.floating[x]||a.floating[k]);const $=b/2-C/2,j=S/2-v[k]/2-1,N=Ni(h[g],j),A=Ni(h[M],j),R=N,Y=S-v[k]-A,z=S/2-v[k]/2+$,V=LH(R,z,Y),H=!c.arrow&&P0(r)!=null&&z!==V&&a.reference[k]/2-(z<R?N:A)-v[k]/2<0,O=H?z<R?z-R:z-Y:0;return{[y]:f[y]+O,data:{[y]:V,centerOffset:z-V-O,...H&&{alignmentOffset:O}},reset:H}}}),Mqe=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:u=!0,crossAxis:h=!0,fallbackPlacements:f,fallbackStrategy:y="bestFit",fallbackAxisSideDirection:k="none",flipAlignment:v=!0,...w}=va(e,t);if((n=a.arrow)!=null&&n.alignmentOffset)return{};const g=xa(r),M=$r(s),x=xa(s)===s,b=await(c.isRTL==null?void 0:c.isRTL(l.floating)),C=f||(x||!v?[nz(s)]:hqe(s)),_=k!=="none";!f&&_&&C.push(...mqe(s,v,k,b));const S=[s,...C],$=await c.detectOverflow(t,w),j=[];let N=((o=a.flip)==null?void 0:o.overflows)||[];if(u&&j.push($[g]),h){const z=uqe(r,i,b);j.push($[z[0]],$[z[1]])}if(N=[...N,{placement:r,overflows:j}],!j.every(z=>z<=0)){var A,R;const z=(((A=a.flip)==null?void 0:A.index)||0)+1,V=S[z];if(V&&(!(h==="alignment"?M!==$r(V):!1)||N.every(P=>$r(P.placement)===M?P.overflows[0]>0:!0)))return{data:{index:z,overflows:N},reset:{placement:V}};let H=(R=N.filter(O=>O.overflows[0]<=0).sort((O,P)=>O.overflows[1]-P.overflows[1])[0])==null?void 0:R.placement;if(!H)switch(y){case"bestFit":{var Y;const O=(Y=N.filter(P=>{if(_){const I=$r(P.placement);return I===M||I==="y"}return!0}).map(P=>[P.placement,P.overflows.filter(I=>I>0).reduce((I,L)=>I+L,0)]).sort((P,I)=>P[1]-I[1])[0])==null?void 0:Y[0];O&&(H=O);break}case"initialPlacement":H=s;break}if(r!==H)return{reset:{placement:H}}}return{}}}};function XU(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function YU(e){return lqe.some(t=>e[t]>=0)}const bqe=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n,platform:o}=t,{strategy:r="referenceHidden",...a}=va(e,t);switch(r){case"referenceHidden":{const i=await o.detectOverflow(t,{...a,elementContext:"reference"}),s=XU(i,n.reference);return{data:{referenceHiddenOffsets:s,referenceHidden:YU(s)}}}case"escaped":{const i=await o.detectOverflow(t,{...a,altBoundary:!0}),s=XU(i,n.floating);return{data:{escapedOffsets:s,escaped:YU(s)}}}default:return{}}}}},gJ=new Set(["left","top"]);async function _qe(e,t){const{placement:n,platform:o,elements:r}=e,a=await(o.isRTL==null?void 0:o.isRTL(r.floating)),i=xa(n),s=P0(n),c=$r(n)==="y",l=gJ.has(i)?-1:1,u=a&&c?-1:1,h=va(t,e);let{mainAxis:f,crossAxis:y,alignmentAxis:k}=typeof h=="number"?{mainAxis:h,crossAxis:0,alignmentAxis:null}:{mainAxis:h.mainAxis||0,crossAxis:h.crossAxis||0,alignmentAxis:h.alignmentAxis};return s&&typeof k=="number"&&(y=s==="end"?k*-1:k),c?{x:y*u,y:f*l}:{x:f*l,y:y*u}}const Cqe=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 _qe(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}}}}},Sqe=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:x}=g;return{x:M,y:x}}},...l}=va(e,t),u={x:n,y:o},h=await a.detectOverflow(t,l),f=$r(xa(r)),y=SO(f);let k=u[y],v=u[f];if(i){const g=y==="y"?"top":"left",M=y==="y"?"bottom":"right",x=k+h[g],b=k-h[M];k=LH(x,k,b)}if(s){const g=f==="y"?"top":"left",M=f==="y"?"bottom":"right",x=v+h[g],b=v-h[M];v=LH(x,v,b)}const w=c.fn({...t,[y]:k,[f]:v});return{...w,data:{x:w.x-n,y:w.y-o,enabled:{[y]:i,[f]:s}}}}}},Lqe=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}=va(e,t),u={x:n,y:o},h=$r(r),f=SO(h);let y=u[f],k=u[h];const v=va(s,t),w=typeof v=="number"?{mainAxis:v,crossAxis:0}:{mainAxis:0,crossAxis:0,...v};if(c){const x=f==="y"?"height":"width",b=a.reference[f]-a.floating[x]+w.mainAxis,C=a.reference[f]+a.reference[x]-w.mainAxis;y<b?y=b:y>C&&(y=C)}if(l){var g,M;const x=f==="y"?"width":"height",b=gJ.has(xa(r)),C=a.reference[h]-a.floating[x]+(b&&((g=i.offset)==null?void 0:g[h])||0)+(b?0:w.crossAxis),_=a.reference[h]+a.reference[x]+(b?0:((M=i.offset)==null?void 0:M[h])||0)-(b?w.crossAxis:0);k<C?k=C:k>_&&(k=_)}return{[f]:y,[h]:k}}}},Nqe=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}=va(e,t),u=await i.detectOverflow(t,l),h=xa(r),f=P0(r),y=$r(r)==="y",{width:k,height:v}=a.floating;let w,g;h==="top"||h==="bottom"?(w=h,g=f===(await(i.isRTL==null?void 0:i.isRTL(s.floating))?"start":"end")?"left":"right"):(g=h,w=f==="end"?"top":"bottom");const M=v-u.top-u.bottom,x=k-u.left-u.right,b=Ni(v-u[w],M),C=Ni(k-u[g],x),_=!t.middlewareData.shift;let S=b,$=C;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&($=x),(o=t.middlewareData.shift)!=null&&o.enabled.y&&(S=M),_&&!f){const N=uo(u.left,0),A=uo(u.right,0),R=uo(u.top,0),Y=uo(u.bottom,0);y?$=k-2*(N!==0||A!==0?N+A:uo(u.left,u.right)):S=v-2*(R!==0||Y!==0?R+Y:uo(u.top,u.bottom))}await c({...t,availableWidth:$,availableHeight:S});const j=await i.getDimensions(s.floating);return k!==j.width||v!==j.height?{reset:{rects:!0}}:{}}}};function Yz(){return typeof window<"u"}function z0(e){return vJ(e)?(e.nodeName||"").toLowerCase():"#document"}function mo(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Br(e){var t;return(t=(vJ(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function vJ(e){return Yz()?e instanceof Node||e instanceof mo(e).Node:!1}function er(e){return Yz()?e instanceof Element||e instanceof mo(e).Element:!1}function Ca(e){return Yz()?e instanceof HTMLElement||e instanceof mo(e).HTMLElement:!1}function QU(e){return!Yz()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof mo(e).ShadowRoot}function yf(e){const{overflow:t,overflowX:n,overflowY:o,display:r}=tr(e);return/auto|scroll|overlay|hidden|clip/.test(t+o+n)&&r!=="inline"&&r!=="contents"}function Iqe(e){return/^(table|td|th)$/.test(z0(e))}function Qz(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}const Aqe=/transform|translate|scale|rotate|perspective|filter/,Eqe=/paint|layout|strict|content/,Yi=e=>!!e&&e!=="none";let xT;function IO(e){const t=er(e)?tr(e):e;return Yi(t.transform)||Yi(t.translate)||Yi(t.scale)||Yi(t.rotate)||Yi(t.perspective)||!AO()&&(Yi(t.backdropFilter)||Yi(t.filter))||Aqe.test(t.willChange||"")||Eqe.test(t.contain||"")}function $qe(e){let t=Ii(e);for(;Ca(t)&&!M0(t);){if(IO(t))return t;if(Qz(t))return null;t=Ii(t)}return null}function AO(){return xT==null&&(xT=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),xT}function M0(e){return/^(html|body|#document)$/.test(z0(e))}function tr(e){return mo(e).getComputedStyle(e)}function Jz(e){return er(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Ii(e){if(z0(e)==="html")return e;const t=e.assignedSlot||e.parentNode||QU(e)&&e.host||Br(e);return QU(t)?t.host:t}function xJ(e){const t=Ii(e);return M0(t)?e.ownerDocument?e.ownerDocument.body:e.body:Ca(t)&&yf(t)?t:xJ(t)}function Bh(e,t,n){var o;t===void 0&&(t=[]),n===void 0&&(n=!0);const r=xJ(e),a=r===((o=e.ownerDocument)==null?void 0:o.body),i=mo(r);if(a){const s=IH(i);return t.concat(i,i.visualViewport||[],yf(r)?r:[],s&&n?Bh(s):[])}else return t.concat(r,Bh(r,[],n))}function IH(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function wJ(e){const t=tr(e);let n=parseFloat(t.width)||0,o=parseFloat(t.height)||0;const r=Ca(e),a=r?e.offsetWidth:n,i=r?e.offsetHeight:o,s=tz(n)!==a||tz(o)!==i;return s&&(n=a,o=i),{width:n,height:o,$:s}}function EO(e){return er(e)?e:e.contextElement}function Ku(e){const t=EO(e);if(!Ca(t))return Dr(1);const n=t.getBoundingClientRect(),{width:o,height:r,$:a}=wJ(t);let i=(a?tz(n.width):n.width)/o,s=(a?tz(n.height):n.height)/r;return(!i||!Number.isFinite(i))&&(i=1),(!s||!Number.isFinite(s))&&(s=1),{x:i,y:s}}const jqe=Dr(0);function MJ(e){const t=mo(e);return!AO()||!t.visualViewport?jqe:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Pqe(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==mo(e)?!1:t}function Nd(e,t,n,o){t===void 0&&(t=!1),n===void 0&&(n=!1);const r=e.getBoundingClientRect(),a=EO(e);let i=Dr(1);t&&(o?er(o)&&(i=Ku(o)):i=Ku(e));const s=Pqe(a,n,o)?MJ(a):Dr(0);let c=(r.left+s.x)/i.x,l=(r.top+s.y)/i.y,u=r.width/i.x,h=r.height/i.y;if(a){const f=mo(a),y=o&&er(o)?mo(o):o;let k=f,v=IH(k);for(;v&&o&&y!==k;){const w=Ku(v),g=v.getBoundingClientRect(),M=tr(v),x=g.left+(v.clientLeft+parseFloat(M.paddingLeft))*w.x,b=g.top+(v.clientTop+parseFloat(M.paddingTop))*w.y;c*=w.x,l*=w.y,u*=w.x,h*=w.y,c+=x,l+=b,k=mo(v),v=IH(k)}}return oz({width:u,height:h,x:c,y:l})}function eR(e,t){const n=Jz(e).scrollLeft;return t?t.left+n:Nd(Br(e)).left+n}function bJ(e,t){const n=e.getBoundingClientRect(),o=n.left+t.scrollLeft-eR(e,n),r=n.top+t.scrollTop;return{x:o,y:r}}function zqe(e){let{elements:t,rect:n,offsetParent:o,strategy:r}=e;const a=r==="fixed",i=Br(o),s=t?Qz(t.floating):!1;if(o===i||s&&a)return n;let c={scrollLeft:0,scrollTop:0},l=Dr(1);const u=Dr(0),h=Ca(o);if((h||!h&&!a)&&((z0(o)!=="body"||yf(i))&&(c=Jz(o)),h)){const y=Nd(o);l=Ku(o),u.x=y.x+o.clientLeft,u.y=y.y+o.clientTop}const f=i&&!h&&!a?bJ(i,c):Dr(0);return{width:n.width*l.x,height:n.height*l.y,x:n.x*l.x-c.scrollLeft*l.x+u.x+f.x,y:n.y*l.y-c.scrollTop*l.y+u.y+f.y}}function Rqe(e){return Array.from(e.getClientRects())}function Tqe(e){const t=Br(e),n=Jz(e),o=e.ownerDocument.body,r=uo(t.scrollWidth,t.clientWidth,o.scrollWidth,o.clientWidth),a=uo(t.scrollHeight,t.clientHeight,o.scrollHeight,o.clientHeight);let i=-n.scrollLeft+eR(e);const s=-n.scrollTop;return tr(o).direction==="rtl"&&(i+=uo(t.clientWidth,o.clientWidth)-r),{width:r,height:a,x:i,y:s}}const JU=25;function Dqe(e,t){const n=mo(e),o=Br(e),r=n.visualViewport;let a=o.clientWidth,i=o.clientHeight,s=0,c=0;if(r){a=r.width,i=r.height;const u=AO();(!u||u&&t==="fixed")&&(s=r.offsetLeft,c=r.offsetTop)}const l=eR(o);if(l<=0){const u=o.ownerDocument,h=u.body,f=getComputedStyle(h),y=u.compatMode==="CSS1Compat"&&parseFloat(f.marginLeft)+parseFloat(f.marginRight)||0,k=Math.abs(o.clientWidth-h.clientWidth-y);k<=JU&&(a-=k)}else l<=JU&&(a+=l);return{width:a,height:i,x:s,y:c}}function Hqe(e,t){const n=Nd(e,!0,t==="fixed"),o=n.top+e.clientTop,r=n.left+e.clientLeft,a=Ca(e)?Ku(e):Dr(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 eW(e,t,n){let o;if(t==="viewport")o=Dqe(e,n);else if(t==="document")o=Tqe(Br(e));else if(er(t))o=Hqe(t,n);else{const r=MJ(e);o={x:t.x-r.x,y:t.y-r.y,width:t.width,height:t.height}}return oz(o)}function _J(e,t){const n=Ii(e);return n===t||!er(n)||M0(n)?!1:tr(n).position==="fixed"||_J(n,t)}function qqe(e,t){const n=t.get(e);if(n)return n;let o=Bh(e,[],!1).filter(s=>er(s)&&z0(s)!=="body"),r=null;const a=tr(e).position==="fixed";let i=a?Ii(e):e;for(;er(i)&&!M0(i);){const s=tr(i),c=IO(i);!c&&s.position==="fixed"&&(r=null),(a?!c&&!r:!c&&s.position==="static"&&!!r&&(r.position==="absolute"||r.position==="fixed")||yf(i)&&!c&&_J(e,i))?o=o.filter(u=>u!==i):r=s,i=Ii(i)}return t.set(e,o),o}function Oqe(e){let{element:t,boundary:n,rootBoundary:o,strategy:r}=e;const i=[...n==="clippingAncestors"?Qz(t)?[]:qqe(t,this._c):[].concat(n),o],s=eW(t,i[0],r);let c=s.top,l=s.right,u=s.bottom,h=s.left;for(let f=1;f<i.length;f++){const y=eW(t,i[f],r);c=uo(y.top,c),l=Ni(y.right,l),u=Ni(y.bottom,u),h=uo(y.left,h)}return{width:l-h,height:u-c,x:h,y:c}}function Fqe(e){const{width:t,height:n}=wJ(e);return{width:t,height:n}}function Vqe(e,t,n){const o=Ca(t),r=Br(t),a=n==="fixed",i=Nd(e,!0,a,t);let s={scrollLeft:0,scrollTop:0};const c=Dr(0);function l(){c.x=eR(r)}if(o||!o&&!a)if((z0(t)!=="body"||yf(r))&&(s=Jz(t)),o){const y=Nd(t,!0,a,t);c.x=y.x+t.clientLeft,c.y=y.y+t.clientTop}else r&&l();a&&!o&&r&&l();const u=r&&!o&&!a?bJ(r,s):Dr(0),h=i.left+s.scrollLeft-c.x-u.x,f=i.top+s.scrollTop-c.y-u.y;return{x:h,y:f,width:i.width,height:i.height}}function wT(e){return tr(e).position==="static"}function tW(e,t){if(!Ca(e)||tr(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return Br(e)===n&&(n=n.ownerDocument.body),n}function CJ(e,t){const n=mo(e);if(Qz(e))return n;if(!Ca(e)){let r=Ii(e);for(;r&&!M0(r);){if(er(r)&&!wT(r))return r;r=Ii(r)}return n}let o=tW(e,t);for(;o&&Iqe(o)&&wT(o);)o=tW(o,t);return o&&M0(o)&&wT(o)&&!IO(o)?n:o||$qe(e)||n}const Bqe=async function(e){const t=this.getOffsetParent||CJ,n=this.getDimensions,o=await n(e.floating);return{reference:Vqe(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:o.width,height:o.height}}};function Uqe(e){return tr(e).direction==="rtl"}const Wqe={convertOffsetParentRelativeRectToViewportRelativeRect:zqe,getDocumentElement:Br,getClippingRect:Oqe,getOffsetParent:CJ,getElementRects:Bqe,getClientRects:Rqe,getDimensions:Fqe,getScale:Ku,isElement:er,isRTL:Uqe};function SJ(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=Br(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:u,top:h,width:f,height:y}=l;if(s||t(),!f||!y)return;const k=kp(h),v=kp(r.clientWidth-(u+f)),w=kp(r.clientHeight-(h+y)),g=kp(u),x={rootMargin:-k+"px "+-v+"px "+-w+"px "+-g+"px",threshold:uo(0,Ni(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&&!SJ(l,e.getBoundingClientRect())&&i(),b=!1}try{n=new IntersectionObserver(C,{...x,root:r.ownerDocument})}catch{n=new IntersectionObserver(C,x)}n.observe(e)}return i(!0),a}function Kqe(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=EO(e),u=r||a?[...l?Bh(l):[],...t?Bh(t):[]]:[];u.forEach(g=>{r&&g.addEventListener("scroll",n,{passive:!0}),a&&g.addEventListener("resize",n)});const h=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 x;(x=y)==null||x.observe(t)})),n()}),l&&!c&&y.observe(l),t&&y.observe(t));let k,v=c?Nd(e):null;c&&w();function w(){const g=Nd(e);v&&!SJ(v,g)&&n(),v=g,k=requestAnimationFrame(w)}return n(),()=>{var g;u.forEach(M=>{r&&M.removeEventListener("scroll",n),a&&M.removeEventListener("resize",n)}),h==null||h(),(g=y)==null||g.disconnect(),y=null,c&&cancelAnimationFrame(k)}}const Zqe=Cqe,Xqe=Sqe,Yqe=Mqe,Qqe=Nqe,Jqe=bqe,nW=wqe,eOe=Lqe,tOe=(e,t,n)=>{const o=new Map,r={platform:Wqe,...n},a={...r.platform,_c:o};return xqe(e,t,{...r,platform:a})};var nOe=typeof document<"u",oOe=function(){},rP=nOe?m.useLayoutEffect:oOe;function rz(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(!rz(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)&&!rz(e[a],t[a]))return!1}return!0}return e!==e&&t!==t}function LJ(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function oW(e,t){const n=LJ(e);return Math.round(t*n)/n}function MT(e){const t=m.useRef(e);return rP(()=>{t.current=e}),t}function rOe(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,[u,h]=m.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[f,y]=m.useState(o);rz(f,o)||y(o);const[k,v]=m.useState(null),[w,g]=m.useState(null),M=m.useCallback(P=>{P!==_.current&&(_.current=P,v(P))},[]),x=m.useCallback(P=>{P!==S.current&&(S.current=P,g(P))},[]),b=a||k,C=i||w,_=m.useRef(null),S=m.useRef(null),$=m.useRef(u),j=c!=null,N=MT(c),A=MT(r),R=MT(l),Y=m.useCallback(()=>{if(!_.current||!S.current)return;const P={placement:t,strategy:n,middleware:f};A.current&&(P.platform=A.current),tOe(_.current,S.current,P).then(I=>{const L={...I,isPositioned:R.current!==!1};z.current&&!rz($.current,L)&&($.current=L,I0.flushSync(()=>{h(L)}))})},[f,t,n,A,R]);rP(()=>{l===!1&&$.current.isPositioned&&($.current.isPositioned=!1,h(P=>({...P,isPositioned:!1})))},[l]);const z=m.useRef(!1);rP(()=>(z.current=!0,()=>{z.current=!1}),[]),rP(()=>{if(b&&(_.current=b),C&&(S.current=C),b&&C){if(N.current)return N.current(b,C,Y);Y()}},[b,C,Y,N,j]);const V=m.useMemo(()=>({reference:_,floating:S,setReference:M,setFloating:x}),[M,x]),H=m.useMemo(()=>({reference:b,floating:C}),[b,C]),O=m.useMemo(()=>{const P={position:n,left:0,top:0};if(!H.floating)return P;const I=oW(H.floating,u.x),L=oW(H.floating,u.y);return s?{...P,transform:"translate("+I+"px, "+L+"px)",...LJ(H.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:I,top:L}},[n,s,H.floating,u.x,u.y]);return m.useMemo(()=>({...u,update:Y,refs:V,elements:H,floatingStyles:O}),[u,Y,V,H,O])}const aOe=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?nW({element:o.current,padding:r}).fn(n):{}:o?nW({element:o,padding:r}).fn(n):{}}}},iOe=(e,t)=>{const n=Zqe(e);return{name:n.name,fn:n.fn,options:[e,t]}},sOe=(e,t)=>{const n=Xqe(e);return{name:n.name,fn:n.fn,options:[e,t]}},cOe=(e,t)=>({fn:eOe(e).fn,options:[e,t]}),lOe=(e,t)=>{const n=Yqe(e);return{name:n.name,fn:n.fn,options:[e,t]}},dOe=(e,t)=>{const n=Qqe(e);return{name:n.name,fn:n.fn,options:[e,t]}},uOe=(e,t)=>{const n=Jqe(e);return{name:n.name,fn:n.fn,options:[e,t]}},hOe=(e,t)=>{const n=aOe(e);return{name:n.name,fn:n.fn,options:[e,t]}};var fOe="Arrow",NJ=m.forwardRef((e,t)=>{const{children:n,width:o=10,height:r=5,...a}=e;return p.jsx(Ue.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"})})});NJ.displayName=fOe;var pOe=NJ,$O="Popper",[IJ,R0]=or($O),[yOe,AJ]=IJ($O),EJ=e=>{const{__scopePopper:t,children:n}=e,[o,r]=m.useState(null);return p.jsx(yOe,{scope:t,anchor:o,onAnchorChange:r,children:n})};EJ.displayName=$O;var $J="PopperAnchor",jJ=m.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:o,...r}=e,a=AJ($J,n),i=m.useRef(null),s=gt(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(Ue.div,{...r,ref:s})});jJ.displayName=$J;var jO="PopperContent",[mOe,kOe]=IJ(jO),PJ=m.forwardRef((e,t)=>{var oe,te,ce,ge,ae,se;const{__scopePopper:n,side:o="bottom",sideOffset:r=0,align:a="center",alignOffset:i=0,arrowPadding:s=0,avoidCollisions:c=!0,collisionBoundary:l=[],collisionPadding:u=0,sticky:h="partial",hideWhenDetached:f=!1,updatePositionStrategy:y="optimized",onPlaced:k,...v}=e,w=AJ(jO,n),[g,M]=m.useState(null),x=gt(t,re=>M(re)),[b,C]=m.useState(null),_=WQ(b),S=(_==null?void 0:_.width)??0,$=(_==null?void 0:_.height)??0,j=o+(a!=="center"?"-"+a:""),N=typeof u=="number"?u:{top:0,right:0,bottom:0,left:0,...u},A=Array.isArray(l)?l:[l],R=A.length>0,Y={padding:N,boundary:A.filter(vOe),altBoundary:R},{refs:z,floatingStyles:V,placement:H,isPositioned:O,middlewareData:P}=rOe({strategy:"fixed",placement:j,whileElementsMounted:(...re)=>Kqe(...re,{animationFrame:y==="always"}),elements:{reference:w.anchor},middleware:[iOe({mainAxis:r+$,alignmentAxis:i}),c&&sOe({mainAxis:!0,crossAxis:!1,limiter:h==="partial"?cOe():void 0,...Y}),c&&lOe({...Y}),dOe({...Y,apply:({elements:re,rects:Pe,availableWidth:Be,availableHeight:Ve})=>{const{width:ht,height:Gt}=Pe.reference,Et=re.floating.style;Et.setProperty("--radix-popper-available-width",`${Be}px`),Et.setProperty("--radix-popper-available-height",`${Ve}px`),Et.setProperty("--radix-popper-anchor-width",`${ht}px`),Et.setProperty("--radix-popper-anchor-height",`${Gt}px`)}}),b&&hOe({element:b,padding:s}),xOe({arrowWidth:S,arrowHeight:$}),f&&uOe({strategy:"referenceHidden",...Y})]}),[I,L]=TJ(H),U=Fr(k);Li(()=>{O&&(U==null||U())},[O,U]);const D=(oe=P.arrow)==null?void 0:oe.x,E=(te=P.arrow)==null?void 0:te.y,ee=((ce=P.arrow)==null?void 0:ce.centerOffset)!==0,[J,ne]=m.useState();return Li(()=>{g&&ne(window.getComputedStyle(g).zIndex)},[g]),p.jsx("div",{ref:z.setFloating,"data-radix-popper-content-wrapper":"",style:{...V,transform:O?V.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:J,"--radix-popper-transform-origin":[(ge=P.transformOrigin)==null?void 0:ge.x,(ae=P.transformOrigin)==null?void 0:ae.y].join(" "),...((se=P.hide)==null?void 0:se.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:p.jsx(mOe,{scope:n,placedSide:I,onArrowChange:C,arrowX:D,arrowY:E,shouldHideArrow:ee,children:p.jsx(Ue.div,{"data-side":I,"data-align":L,...v,ref:x,style:{...v.style,animation:O?void 0:"none"}})})})});PJ.displayName=jO;var zJ="PopperArrow",gOe={top:"bottom",right:"left",bottom:"top",left:"right"},RJ=m.forwardRef(function(t,n){const{__scopePopper:o,...r}=t,a=kOe(zJ,o),i=gOe[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(pOe,{...r,ref:n,style:{...r.style,display:"block"}})})});RJ.displayName=zJ;function vOe(e){return e!==null}var xOe=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,u]=TJ(n),h={start:"0%",center:"50%",end:"100%"}[u],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="",v="";return l==="bottom"?(k=i?h:`${f}px`,v=`${-c}px`):l==="top"?(k=i?h:`${f}px`,v=`${o.floating.height+c}px`):l==="right"?(k=`${-c}px`,v=i?h:`${y}px`):l==="left"&&(k=`${o.floating.width+c}px`,v=i?h:`${y}px`),{data:{x:k,y:v}}}});function TJ(e){const[t,n="center"]=e.split("-");return[t,n]}var PO=EJ,tR=jJ,zO=PJ,RO=RJ,wOe="Portal",mf=m.forwardRef((e,t)=>{var s;const{container:n,...o}=e,[r,a]=m.useState(!1);Li(()=>a(!0),[]);const i=n||r&&((s=globalThis==null?void 0:globalThis.document)==null?void 0:s.body);return i?$se.createPortal(p.jsx(Ue.div,{...o,ref:t}),i):null});mf.displayName=wOe;function MOe(e,t){return m.useReducer((n,o)=>t[n][o]??n,e)}var Mo=e=>{const{present:t,children:n}=e,o=bOe(t),r=typeof n=="function"?n({present:o.isPresent}):m.Children.only(n),a=gt(o.ref,_Oe(r));return typeof n=="function"||o.isPresent?m.cloneElement(r,{ref:a}):null};Mo.displayName="Presence";function bOe(e){const[t,n]=m.useState(),o=m.useRef(null),r=m.useRef(e),a=m.useRef("none"),i=e?"mounted":"unmounted",[s,c]=MOe(i,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return m.useEffect(()=>{const l=gp(o.current);a.current=s==="mounted"?l:"none"},[s]),Li(()=>{const l=o.current,u=r.current;if(u!==e){const f=a.current,y=gp(l);e?c("MOUNT"):y==="none"||(l==null?void 0:l.display)==="none"?c("UNMOUNT"):c(u&&f!==y?"ANIMATION_OUT":"UNMOUNT"),r.current=e}},[e,c]),Li(()=>{if(t){let l;const u=t.ownerDocument.defaultView??window,h=y=>{const v=gp(o.current).includes(CSS.escape(y.animationName));if(y.target===t&&v&&(c("ANIMATION_END"),!r.current)){const w=t.style.animationFillMode;t.style.animationFillMode="forwards",l=u.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=w)})}},f=y=>{y.target===t&&(a.current=gp(o.current))};return t.addEventListener("animationstart",f),t.addEventListener("animationcancel",h),t.addEventListener("animationend",h),()=>{u.clearTimeout(l),t.removeEventListener("animationstart",f),t.removeEventListener("animationcancel",h),t.removeEventListener("animationend",h)}}else c("ANIMATION_END")},[t,c]),{isPresent:["mounted","unmountSuspended"].includes(s),ref:m.useCallback(l=>{o.current=l?getComputedStyle(l):null,n(l)},[])}}function gp(e){return(e==null?void 0:e.animationName)||"none"}function _Oe(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 COe=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},iu=new WeakMap,vp=new WeakMap,xp={},bT=0,DJ=function(e){return e&&(e.host||DJ(e.parentNode))},SOe=function(e,t){return t.map(function(n){if(e.contains(n))return n;var o=DJ(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})},LOe=function(e,t,n,o){var r=SOe(t,Array.isArray(e)?e:[e]);xp[n]||(xp[n]=new WeakMap);var a=xp[n],i=[],s=new Set,c=new Set(r),l=function(h){!h||s.has(h)||(s.add(h),l(h.parentNode))};r.forEach(l);var u=function(h){!h||c.has(h)||Array.prototype.forEach.call(h.children,function(f){if(s.has(f))u(f);else try{var y=f.getAttribute(o),k=y!==null&&y!=="false",v=(iu.get(f)||0)+1,w=(a.get(f)||0)+1;iu.set(f,v),a.set(f,w),i.push(f),v===1&&k&&vp.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 u(t),s.clear(),bT++,function(){i.forEach(function(h){var f=iu.get(h)-1,y=a.get(h)-1;iu.set(h,f),a.set(h,y),f||(vp.has(h)||h.removeAttribute(o),vp.delete(h)),y||h.removeAttribute(n)}),bT--,bT||(iu=new WeakMap,iu=new WeakMap,vp=new WeakMap,xp={})}},TO=function(e,t,n){n===void 0&&(n="data-aria-hidden");var o=Array.from(Array.isArray(e)?e:[e]),r=COe(e);return r?(o.push.apply(o,Array.from(r.querySelectorAll("[aria-live], script"))),LOe(o,r,n,"aria-hidden")):function(){return null}},Er=function(){return Er=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},Er.apply(this,arguments)};function HJ(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 NOe(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 aP="right-scroll-bar-position",iP="width-before-scroll-bar",IOe="with-scroll-bars-hidden",AOe="--removed-body-scroll-bar-size";function _T(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function EOe(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 $Oe=typeof window<"u"?m.useLayoutEffect:m.useEffect,rW=new WeakMap;function jOe(e,t){var n=EOe(null,function(o){return e.forEach(function(r){return _T(r,o)})});return $Oe(function(){var o=rW.get(n);if(o){var r=new Set(o),a=new Set(e),i=n.current;r.forEach(function(s){a.has(s)||_T(s,null)}),a.forEach(function(s){r.has(s)||_T(s,i)})}rW.set(n,e)},[e]),n}function POe(e){return e}function zOe(e,t){t===void 0&&(t=POe);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 u=i;i=[],u.forEach(a)},l=function(){return Promise.resolve().then(c)};l(),n={push:function(u){i.push(u),l()},filter:function(u){return i=i.filter(u),n}}}};return r}function ROe(e){e===void 0&&(e={});var t=zOe(null);return t.options=Er({async:!0,ssr:!1},e),t}var qJ=function(e){var t=e.sideCar,n=HJ(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,Er({},n))};qJ.isSideCarExport=!0;function TOe(e,t){return e.useMedium(t),qJ}var OJ=ROe(),CT=function(){},nR=m.forwardRef(function(e,t){var n=m.useRef(null),o=m.useState({onScrollCapture:CT,onWheelCapture:CT,onTouchMoveCapture:CT}),r=o[0],a=o[1],i=e.forwardProps,s=e.children,c=e.className,l=e.removeScrollBar,u=e.enabled,h=e.shards,f=e.sideCar,y=e.noRelative,k=e.noIsolation,v=e.inert,w=e.allowPinchZoom,g=e.as,M=g===void 0?"div":g,x=e.gapMode,b=HJ(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),C=f,_=jOe([n,t]),S=Er(Er({},b),r);return m.createElement(m.Fragment,null,u&&m.createElement(C,{sideCar:OJ,removeScrollBar:l,shards:h,noRelative:y,noIsolation:k,inert:v,setCallbacks:a,allowPinchZoom:!!w,lockRef:n,gapMode:x}),i?m.cloneElement(m.Children.only(s),Er(Er({},S),{ref:_})):m.createElement(M,Er({},S,{className:c,ref:_}),s))});nR.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};nR.classNames={fullWidth:iP,zeroRight:aP};var DOe=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function HOe(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=DOe();return t&&e.setAttribute("nonce",t),e}function qOe(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function OOe(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=HOe())&&(qOe(t,n),OOe(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},VOe=function(){var e=FOe();return function(t,n){m.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},FJ=function(){var e=VOe(),t=function(n){var o=n.styles,r=n.dynamic;return e(o,r),null};return t},BOe={left:0,top:0,right:0,gap:0},ST=function(e){return parseInt(e||"",10)||0},UOe=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[ST(n),ST(o),ST(r)]},WOe=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return BOe;var t=UOe(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=FJ(),Zu="data-scroll-locked",KOe=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
|
+
`);return}A.preventDefault(),M.current=!0,_();return}A.key==="Escape"&&(A.preventDefault(),M.current=!0,S())},j=A=>{A.preventDefault();const R=A.clipboardData.getData("text/plain");document.execCommand("insertText",!1,R)},N=()=>{if(M.current){M.current=!1;return}_()};return p.jsx("div",{ref:h,"data-testid":"inline-edit-input","data-field":i,"data-placeholder":l,role:"textbox",tabIndex:0,contentEditable:!0,suppressContentEditableWarning:!0,spellCheck:!1,onInput:C,onKeyDown:$,onPaste:j,onBlur:N,onMouseDown:A=>A.stopPropagation(),onClick:A=>A.stopPropagation(),onDoubleClick:A=>A.stopPropagation(),style:c,className:ie("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 EQ=8,dU=12,uU={height:`${EQ}px`,borderColor:"transparent"},hU={width:`${EQ}px`,borderColor:"transparent"},mTe={width:`${dU}px`,height:`${dU}px`,background:"transparent",border:"none"},kTe={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},gTe=[{position:"top",style:uU},{position:"bottom",style:uU},{position:"left",style:hU},{position:"right",style:hU}],vTe=["top-left","top-right","bottom-left","bottom-right"],fU={pointerEvents:"none",cursor:"default"};function E0({visible:e,minWidth:t=80,minHeight:n=40,onResizeStart:o,onResize:r,onResizeEnd:a,cornerVariant:i="invisible"}){const s=i==="visible"?kTe:mTe,c=u=>e?u:{...u,...fU},l=e?s:{...s,opacity:0,...fU};return p.jsxs(p.Fragment,{children:[gTe.map(({position:u,style:h})=>p.jsx(cU,{position:u,variant:Ci.Line,minWidth:t,minHeight:n,style:c(h),onResizeStart:o,onResize:r,onResizeEnd:a,children:p.jsx("span",{"data-testid":"resize-control","data-position":u})},u)),vTe.map(u=>p.jsx(cU,{position:u,variant:Ci.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":u})},u))]})}function $0(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),u=m.useRef(o),h=m.useRef(r);m.useEffect(()=>{c.current=t},[t]),m.useEffect(()=>{l.current=n},[n]),m.useEffect(()=>{u.current=o},[o]),m.useEffect(()=>{h.current=r},[r]);const f=m.useCallback((v,w)=>{var g;i(!0),(g=h.current)==null||g.call(h,!0),s.current=w?{x:w.x,y:w.y,width:w.width,height:w.height}:null},[]),y=m.useCallback((v,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((v,w)=>{var M,x,b,C;i(!1),(M=h.current)==null||M.call(h,!1);const g=s.current;s.current=null,!(g&&g.width===w.width&&g.height===w.height)&&((x=c.current)==null||x.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=u.current)==null||C.call(u,{x:w.x,y:w.y,width:w.width,height:w.height},g)))},[]);return{isResizing:a,onResizeStart:f,onResizeEvent:y,onResizeEnd:k}}const p0={width:48,height:48},pU="help-circle",xTe=24,wTe=24,fp="sf:opacity-0 sf:transition-opacity";function MTe(e){return Lt(e,"text").color??"currentColor"}const yU=new Set;function bTe({id:e,data:t,selected:n,isConnectable:o}){const{onResizeStart:r,onResizeEvent:a,onResizeEnd:i}=$0({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,u]=m.useState(!1),h=r0[t.icon];!h&&!yU.has(t.icon)&&(yU.add(t.icon),console.warn(`[iconNode] Unknown icon "${t.icon}"; falling back to "${pU}".`));const f=h??r0[pU],y=MTe(t.color),k=t.strokeWidth??2,v={...s?{}:{width:p0.width,height:p0.height}},w=g=>{!c||l||(g.stopPropagation(),u(!0))};return p.jsxs("div",{className:ie("sf:group sf:relative",s?"sf:h-full sf:w-full":""),style:v,"data-testid":"icon-node","data-node-type":"icon",onDoubleClick:w,children:[p.jsx(E0,{visible:!!n&&!!t.onResize&&!l,cornerVariant:"visible",minWidth:xTe,minHeight:wTe,onResizeStart:r,onResize:a,onResizeEnd:i}),p.jsx(ft,{type:"target",position:me.Top,id:"t",isConnectable:o,className:ie(fp,n&&"sf:opacity-100!")}),p.jsx(ft,{type:"target",position:me.Left,id:"l",isConnectable:o,className:ie(fp,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(di,{initialValue:t.name??"",field:"icon-node-label",onCommit:g=>{var M;return(M=t.onNameChange)==null?void 0:M.call(t,e,g)},onExit:()=>u(!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(ft,{type:"source",position:me.Right,id:"r",isConnectable:o,className:ie(fp,n&&"sf:opacity-100!")}),p.jsx(ft,{type:"source",position:me.Bottom,id:"b",isConnectable:o,className:ie(fp,n&&"sf:opacity-100!")})]})}function _Te(e,t){return e.selected===t.selected&&e.data===t.data&&e.width===t.width&&e.height===t.height}const CTe=m.memo(bTe,_Te);function STe(e,t){const n=e.screenToFlowPosition({x:t.width/2,y:t.height/2});return{x:n.x-p0.width/2,y:n.y-p0.height/2}}const $Q="seeflow:icon-recents",LTe=16;function jQ(){if(typeof window>"u")return[];try{const e=window.localStorage.getItem($Q);if(e===null)return[];const t=JSON.parse(e);return Array.isArray(t)?t.every(n=>typeof n=="string")?t:[]:[]}catch{return[]}}function NTe(e){if(!(typeof window>"u"))try{const n=jQ().filter(r=>r!==e),o=[e,...n].slice(0,LTe);window.localStorage.setItem($Q,JSON.stringify(o))}catch{}}const ITe=typeof navigator<"u"&&typeof navigator.platform=="string"&&navigator.platform.toLowerCase().includes("mac"),ATe=e=>e.length===1?e.toUpperCase():e==="Escape"?"Esc":e,Dt=(e,t=ITe)=>{const n=ATe(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("+")},kO=[{id:"tool.select",label:"Select tool",description:"Switch to the selection tool",category:"Tools",shortcut:Dt({key:"V"})},{id:"tool.hand",label:"Hand tool",description:"Pan the canvas; node interaction is suspended while armed",category:"Tools",shortcut:Dt({key:"H"})},{id:"tool.rectangle",label:"Rectangle",description:"Draw rectangle nodes",category:"Tools",shortcut:Dt({key:"R"})},{id:"tool.ellipse",label:"Ellipse",description:"Draw ellipse nodes",category:"Tools",shortcut:Dt({key:"O"})},{id:"tool.text",label:"Text",description:"Add a text node",category:"Tools",shortcut:Dt({key:"T"})},{id:"tool.sticky",label:"Sticky note",description:"Add a sticky note",category:"Tools",shortcut:Dt({key:"S"})},{id:"tool.database",label:"Database",description:"Add a database node",category:"Tools",shortcut:Dt({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:Dt({meta:!0,key:"Z"}),enabled:e=>e.canUndo},{id:"edit.redo",label:"Redo",category:"Edit",shortcut:Dt({meta:!0,shift:!0,key:"Z"}),enabled:e=>e.canRedo},{id:"edit.copy",label:"Copy",category:"Edit",shortcut:Dt({meta:!0,key:"C"}),enabled:e=>e.hasSelection},{id:"edit.paste",label:"Paste",category:"Edit",shortcut:Dt({meta:!0,key:"V"}),enabled:e=>e.hasClipboard},{id:"edit.duplicate",label:"Duplicate",category:"Edit",shortcut:Dt({meta:!0,key:"D"}),enabled:e=>e.hasSelection},{id:"edit.delete",label:"Delete",category:"Edit",shortcut:Dt({key:"Delete"}),enabled:e=>e.hasSelection},{id:"edit.selectAll",label:"Select all",category:"Edit",shortcut:Dt({meta:!0,key:"A"})},{id:"view.fit",label:"Fit view",description:"Fit everything in the viewport",category:"View",shortcut:Dt({meta:!0,key:"0"})},{id:"view.zoomIn",label:"Zoom in",category:"View",shortcut:Dt({meta:!0,key:"="})},{id:"view.zoomOut",label:"Zoom out",category:"View",shortcut:Dt({meta:!0,key:"-"})},{id:"view.zoom100",label:"Zoom to 100%",category:"View",shortcut:Dt({key:"1"})},{id:"view.zoomToSelection",label:"Zoom to selection",category:"View",shortcut:Dt({key:"F"}),enabled:e=>e.hasSelection},{id:"layout.tidy",label:"Tidy layout",description:"Auto-layout the canvas or current selection",category:"Layout",shortcut:Dt({meta:!0,shift:!0,key:"L"})},{id:"selection.deselect",label:"Deselect",description:"Clear selection and exit draw mode",category:"Selection",shortcut:Dt({key:"Escape"})},{id:"help.commandPalette",label:"Open command palette",category:"Help",shortcut:Dt({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}],fT=e=>{const t=kO.find(n=>n.id===e);return t?t.shortcut?`${t.label} (${t.shortcut})`:t.label:""},ETe=1,$Te=10,jTe=e=>{if(e.metaKey||e.ctrlKey||e.altKey)return null;const t=e.shiftKey?$Te:ETe;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}},PTe=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}},zTe=(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},RTe=({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"}},TTe=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}},Qa="seeflow",PQ=e=>`${e}:last-used-style:v1`,pT=()=>({node:{},connector:{}}),yT=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),gO=e=>{var t;try{const n=(t=globalThis.localStorage)==null?void 0:t.getItem(PQ(e));if(!n)return pT();const o=JSON.parse(n);if(!yT(o))return pT();const r=yT(o.node)?o.node:{},a=yT(o.connector)?o.connector:{};return{node:r,connector:a}}catch{return pT()}},zQ=(e,t)=>{var n;try{(n=globalThis.localStorage)==null||n.setItem(PQ(e),JSON.stringify(t))}catch{}},M2=e=>gO(e),mU=(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=gO(e);zQ(e,{...a,node:{...a.node,...r}})},DTe=(e,t)=>{const n=gO(e);zQ(e,{...n,connector:{...n.connector,...t}})},vO=1,kU=17,fH=(e,t)=>{if(!e)return{};const n={};for(const o of t)e[o]!==void 0&&(n[o]=e[o]);return n},HTe=["borderColor","backgroundColor","borderSize","borderStyle","fontSize","cornerRadius","shadow"],qTe=["borderColor","backgroundColor","borderSize","borderStyle","fontSize","shadow"],OTe=["fontSize"],FTe=["borderColor","borderWidth","borderStyle","shadow"];function gU(e,t,n){if(e==="text")return{width:t.width,height:t.height,fontSize:kU,...fH(n,OTe)};const o=e==="ellipse"?qTe:HTe;return{width:t.width,height:t.height,borderSize:vO,fontSize:kU,...fH(n,o)}}function VTe(e,t,n){return{path:e,width:t.width,height:t.height,borderWidth:vO,...fH(n,FTe)}}const So=async(e,t,n,o,r)=>{const a={method:t},i={...o??{}};r!==void 0&&(i["content-type"]="application/json",a.body=JSON.stringify(r)),Object.keys(i).length>0&&(a.headers=i);const s=await e(n,a);if(!s.ok){let c=null;try{c=await s.json()}catch{}throw new Error((c==null?void 0:c.error)??`${t} ${n} → ${s.status}`)}return await s.json()},BTe=e=>{const{baseUrl:t,project:n,flow:o}=e,r=e.fetch??globalThis.fetch.bind(globalThis),a=e.headers,i=`${t}/api/projects/${encodeURIComponent(n)}`,s=`${i}/flows/${encodeURIComponent(o)}`;return{async createNode(c){const l=await So(r,"POST",`${s}/nodes`,a,c);return{id:l.id,node:l.node}},async updateNode(c,l){await So(r,"PATCH",`${s}/nodes/${c}`,a,l)},async updateNodePosition(c,l){return await So(r,"PATCH",`${s}/nodes/${c}/position`,a,l)},async deleteNode(c){await So(r,"DELETE",`${s}/nodes/${c}`,a)},async reorderNode(c,l){await So(r,"PATCH",`${s}/nodes/${c}/order`,a,l)},async createConnector(c){return{id:(await So(r,"POST",`${s}/connectors`,a,c)).id}},async updateConnector(c,l){await So(r,"PATCH",`${s}/connectors/${c}`,a,l)},async deleteConnector(c){await So(r,"DELETE",`${s}/connectors/${c}`,a)},async uploadImage(c,l,u){const h=new FormData;h.append("file",l),h.append("filename",u);const f=`${s}/nodes/${encodeURIComponent(c)}/files/upload`,y={method:"POST",body:h};a&&(y.headers={...a});const k=await r(f,y);if(!k.ok){let v=null;try{v=await k.json()}catch{}throw new Error((v==null?void 0:v.error)??`POST ${f} → ${k.status}`)}return await k.json()},async playAction(c){return await So(r,"POST",`${s}/play/${c}`,a,{})},async openFile(c){await So(r,"POST",`${i}/files/open`,a,{path:c})},async revealFile(c){await So(r,"POST",`${i}/files/reveal`,a,{path:c})},async computeLayout(c,l){const u=await So(r,"POST",`${t}/api/layout`,a,{nodes:c,edges:l});return{nodes:u.nodes,connectors:u.connectors}}}};function RQ(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 UTe="modulepreload",WTe=function(e){return"/"+e},vU={},ff=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=WTe(c),c in vU)return;vU[c]=!0;const l=c.endsWith(".css"),u=l?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${c}"]${u}`))return;const h=document.createElement("link");if(h.rel=l?"stylesheet":UTe,l||(h.as="script"),h.crossOrigin="",h.href=c,s&&h.setAttribute("nonce",s),document.head.appendChild(h),l)return new Promise((f,y)=>{h.addEventListener("load",f),h.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 it;(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})(it||(it={}));var xU;(function(e){e.mergeShapes=(t,n)=>({...t,...n})})(xU||(xU={}));const _e=it.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),ri=e=>{switch(typeof e){case"undefined":return _e.undefined;case"string":return _e.string;case"number":return Number.isNaN(e)?_e.nan:_e.number;case"boolean":return _e.boolean;case"function":return _e.function;case"bigint":return _e.bigint;case"symbol":return _e.symbol;case"object":return Array.isArray(e)?_e.array:e===null?_e.null:e.then&&typeof e.then=="function"&&e.catch&&typeof e.catch=="function"?_e.promise:typeof Map<"u"&&e instanceof Map?_e.map:typeof Set<"u"&&e instanceof Set?_e.set:typeof Date<"u"&&e instanceof Date?_e.date:_e.object;default:return _e.unknown}},ke=it.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 ga 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 ga))throw new Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,it.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()}}ga.create=e=>new ga(e);const pH=(e,t)=>{let n;switch(e.code){case ke.invalid_type:e.received===_e.undefined?n="Required":n=`Expected ${e.expected}, received ${e.received}`;break;case ke.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(e.expected,it.jsonStringifyReplacer)}`;break;case ke.unrecognized_keys:n=`Unrecognized key(s) in object: ${it.joinValues(e.keys,", ")}`;break;case ke.invalid_union:n="Invalid input";break;case ke.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${it.joinValues(e.options)}`;break;case ke.invalid_enum_value:n=`Invalid enum value. Expected ${it.joinValues(e.options)}, received '${e.received}'`;break;case ke.invalid_arguments:n="Invalid function arguments";break;case ke.invalid_return_type:n="Invalid function return type";break;case ke.invalid_date:n="Invalid date";break;case ke.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}"`:it.assertNever(e.validation):e.validation!=="regex"?n=`Invalid ${e.validation}`:n="Invalid";break;case ke.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 ke.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 ke.custom:n="Invalid input";break;case ke.invalid_intersection_types:n="Intersection results could not be merged";break;case ke.not_multiple_of:n=`Number must be a multiple of ${e.multipleOf}`;break;case ke.not_finite:n="Number must be finite";break;default:n=t.defaultError,it.assertNever(e)}return{message:n}};let GTe=pH;function KTe(){return GTe}const ZTe=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 xe(e,t){const n=KTe(),o=ZTe({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,n,n===pH?void 0:pH].filter(r=>!!r)});e.common.issues.push(o)}class Pn{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 Pn.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"}),b2=e=>({status:"dirty",value:e}),zo=e=>({status:"valid",value:e}),wU=e=>e.status==="aborted",MU=e=>e.status==="dirty",y0=e=>e.status==="valid",KP=e=>typeof Promise<"u"&&e instanceof Promise;var Le;(function(e){e.errToObj=t=>typeof t=="string"?{message:t}:t||{},e.toString=t=>typeof t=="string"?t:t==null?void 0:t.message})(Le||(Le={}));class qr{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 bU=(e,t)=>{if(y0(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 ga(e.common.issues);return this._error=n,this._error}}};function Ke(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 ri(t.data)}_getOrReturnCtx(t,n){return n||{common:t.parent.common,data:t.data,parsedType:ri(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}_processInputParams(t){return{status:new Pn,ctx:{common:t.parent.common,data:t.data,parsedType:ri(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}}_parseSync(t){const n=this._parse(t);if(KP(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:ri(t)},r=this._parseSync({data:t,path:o.path,parent:o});return bU(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:ri(t)};if(!this["~standard"].async)try{const a=this._parseSync({data:t,path:[],parent:n});return y0(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=>y0(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:ri(t)},r=this._parse({data:t,path:o.path,parent:o}),a=await(KP(r)?r:Promise.resolve(r));return bU(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:ke.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 g0({schema:this,typeName:Oe.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 wi.create(this,this._def)}nullable(){return v0.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Tr.create(this)}promise(){return JP.create(this,this._def)}or(t){return XP.create([this,t],this._def)}and(t){return YP.create(this,t,this._def)}transform(t){return new g0({...Ke(this._def),schema:this,typeName:Oe.ZodEffects,effect:{type:"transform",transform:t}})}default(t){const n=typeof t=="function"?t:()=>t;return new vH({...Ke(this._def),innerType:this,defaultValue:n,typeName:Oe.ZodDefault})}brand(){return new gDe({typeName:Oe.ZodBranded,type:this,...Ke(this._def)})}catch(t){const n=typeof t=="function"?t:()=>t;return new xH({...Ke(this._def),innerType:this,catchValue:n,typeName:Oe.ZodCatch})}describe(t){const n=this.constructor;return new n({...this._def,description:t})}pipe(t){return xO.create(this,t)}readonly(){return wH.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const XTe=/^c[^\s-]{8,}$/i,YTe=/^[0-9a-z]+$/,QTe=/^[0-9A-HJKMNP-TV-Z]{26}$/i,JTe=/^[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,eDe=/^[a-z0-9_-]{21}$/i,tDe=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,nDe=/^[-+]?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)?)??$/,oDe=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,rDe="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let mT;const aDe=/^(?:(?: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])$/,iDe=/^(?:(?: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])$/,sDe=/^(([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]))$/,cDe=/^(([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])$/,lDe=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,dDe=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,TQ="((\\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])))",uDe=new RegExp(`^${TQ}$`);function DQ(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 hDe(e){return new RegExp(`^${DQ(e)}$`)}function fDe(e){let t=`${TQ}T${DQ(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 pDe(e,t){return!!((t==="v4"||!t)&&aDe.test(e)||(t==="v6"||!t)&&sDe.test(e))}function yDe(e,t){if(!tDe.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 mDe(e,t){return!!((t==="v4"||!t)&&iDe.test(e)||(t==="v6"||!t)&&cDe.test(e))}class ua extends et{_parse(t){if(this._def.coerce&&(t.data=String(t.data)),this._getType(t)!==_e.string){const a=this._getOrReturnCtx(t);return xe(a,{code:ke.invalid_type,expected:_e.string,received:a.parsedType}),Fe}const o=new Pn;let r;for(const a of this._def.checks)if(a.kind==="min")t.data.length<a.value&&(r=this._getOrReturnCtx(t,r),xe(r,{code:ke.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),xe(r,{code:ke.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?xe(r,{code:ke.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}):s&&xe(r,{code:ke.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}),o.dirty())}else if(a.kind==="email")oDe.test(t.data)||(r=this._getOrReturnCtx(t,r),xe(r,{validation:"email",code:ke.invalid_string,message:a.message}),o.dirty());else if(a.kind==="emoji")mT||(mT=new RegExp(rDe,"u")),mT.test(t.data)||(r=this._getOrReturnCtx(t,r),xe(r,{validation:"emoji",code:ke.invalid_string,message:a.message}),o.dirty());else if(a.kind==="uuid")JTe.test(t.data)||(r=this._getOrReturnCtx(t,r),xe(r,{validation:"uuid",code:ke.invalid_string,message:a.message}),o.dirty());else if(a.kind==="nanoid")eDe.test(t.data)||(r=this._getOrReturnCtx(t,r),xe(r,{validation:"nanoid",code:ke.invalid_string,message:a.message}),o.dirty());else if(a.kind==="cuid")XTe.test(t.data)||(r=this._getOrReturnCtx(t,r),xe(r,{validation:"cuid",code:ke.invalid_string,message:a.message}),o.dirty());else if(a.kind==="cuid2")YTe.test(t.data)||(r=this._getOrReturnCtx(t,r),xe(r,{validation:"cuid2",code:ke.invalid_string,message:a.message}),o.dirty());else if(a.kind==="ulid")QTe.test(t.data)||(r=this._getOrReturnCtx(t,r),xe(r,{validation:"ulid",code:ke.invalid_string,message:a.message}),o.dirty());else if(a.kind==="url")try{new URL(t.data)}catch{r=this._getOrReturnCtx(t,r),xe(r,{validation:"url",code:ke.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),xe(r,{validation:"regex",code:ke.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),xe(r,{code:ke.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),xe(r,{code:ke.invalid_string,validation:{startsWith:a.value},message:a.message}),o.dirty()):a.kind==="endsWith"?t.data.endsWith(a.value)||(r=this._getOrReturnCtx(t,r),xe(r,{code:ke.invalid_string,validation:{endsWith:a.value},message:a.message}),o.dirty()):a.kind==="datetime"?fDe(a).test(t.data)||(r=this._getOrReturnCtx(t,r),xe(r,{code:ke.invalid_string,validation:"datetime",message:a.message}),o.dirty()):a.kind==="date"?uDe.test(t.data)||(r=this._getOrReturnCtx(t,r),xe(r,{code:ke.invalid_string,validation:"date",message:a.message}),o.dirty()):a.kind==="time"?hDe(a).test(t.data)||(r=this._getOrReturnCtx(t,r),xe(r,{code:ke.invalid_string,validation:"time",message:a.message}),o.dirty()):a.kind==="duration"?nDe.test(t.data)||(r=this._getOrReturnCtx(t,r),xe(r,{validation:"duration",code:ke.invalid_string,message:a.message}),o.dirty()):a.kind==="ip"?pDe(t.data,a.version)||(r=this._getOrReturnCtx(t,r),xe(r,{validation:"ip",code:ke.invalid_string,message:a.message}),o.dirty()):a.kind==="jwt"?yDe(t.data,a.alg)||(r=this._getOrReturnCtx(t,r),xe(r,{validation:"jwt",code:ke.invalid_string,message:a.message}),o.dirty()):a.kind==="cidr"?mDe(t.data,a.version)||(r=this._getOrReturnCtx(t,r),xe(r,{validation:"cidr",code:ke.invalid_string,message:a.message}),o.dirty()):a.kind==="base64"?lDe.test(t.data)||(r=this._getOrReturnCtx(t,r),xe(r,{validation:"base64",code:ke.invalid_string,message:a.message}),o.dirty()):a.kind==="base64url"?dDe.test(t.data)||(r=this._getOrReturnCtx(t,r),xe(r,{validation:"base64url",code:ke.invalid_string,message:a.message}),o.dirty()):it.assertNever(a);return{status:o.value,value:t.data}}_regex(t,n,o){return this.refinement(r=>t.test(r),{validation:n,code:ke.invalid_string,...Le.errToObj(o)})}_addCheck(t){return new ua({...this._def,checks:[...this._def.checks,t]})}email(t){return this._addCheck({kind:"email",...Le.errToObj(t)})}url(t){return this._addCheck({kind:"url",...Le.errToObj(t)})}emoji(t){return this._addCheck({kind:"emoji",...Le.errToObj(t)})}uuid(t){return this._addCheck({kind:"uuid",...Le.errToObj(t)})}nanoid(t){return this._addCheck({kind:"nanoid",...Le.errToObj(t)})}cuid(t){return this._addCheck({kind:"cuid",...Le.errToObj(t)})}cuid2(t){return this._addCheck({kind:"cuid2",...Le.errToObj(t)})}ulid(t){return this._addCheck({kind:"ulid",...Le.errToObj(t)})}base64(t){return this._addCheck({kind:"base64",...Le.errToObj(t)})}base64url(t){return this._addCheck({kind:"base64url",...Le.errToObj(t)})}jwt(t){return this._addCheck({kind:"jwt",...Le.errToObj(t)})}ip(t){return this._addCheck({kind:"ip",...Le.errToObj(t)})}cidr(t){return this._addCheck({kind:"cidr",...Le.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,...Le.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,...Le.errToObj(t==null?void 0:t.message)})}duration(t){return this._addCheck({kind:"duration",...Le.errToObj(t)})}regex(t,n){return this._addCheck({kind:"regex",regex:t,...Le.errToObj(n)})}includes(t,n){return this._addCheck({kind:"includes",value:t,position:n==null?void 0:n.position,...Le.errToObj(n==null?void 0:n.message)})}startsWith(t,n){return this._addCheck({kind:"startsWith",value:t,...Le.errToObj(n)})}endsWith(t,n){return this._addCheck({kind:"endsWith",value:t,...Le.errToObj(n)})}min(t,n){return this._addCheck({kind:"min",value:t,...Le.errToObj(n)})}max(t,n){return this._addCheck({kind:"max",value:t,...Le.errToObj(n)})}length(t,n){return this._addCheck({kind:"length",value:t,...Le.errToObj(n)})}nonempty(t){return this.min(1,Le.errToObj(t))}trim(){return new ua({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new ua({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new ua({...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}}ua.create=e=>new ua({checks:[],typeName:Oe.ZodString,coerce:(e==null?void 0:e.coerce)??!1,...Ke(e)});function kDe(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 m0 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)!==_e.number){const a=this._getOrReturnCtx(t);return xe(a,{code:ke.invalid_type,expected:_e.number,received:a.parsedType}),Fe}let o;const r=new Pn;for(const a of this._def.checks)a.kind==="int"?it.isInteger(t.data)||(o=this._getOrReturnCtx(t,o),xe(o,{code:ke.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),xe(o,{code:ke.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),xe(o,{code:ke.too_big,maximum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),r.dirty()):a.kind==="multipleOf"?kDe(t.data,a.value)!==0&&(o=this._getOrReturnCtx(t,o),xe(o,{code:ke.not_multiple_of,multipleOf:a.value,message:a.message}),r.dirty()):a.kind==="finite"?Number.isFinite(t.data)||(o=this._getOrReturnCtx(t,o),xe(o,{code:ke.not_finite,message:a.message}),r.dirty()):it.assertNever(a);return{status:r.value,value:t.data}}gte(t,n){return this.setLimit("min",t,!0,Le.toString(n))}gt(t,n){return this.setLimit("min",t,!1,Le.toString(n))}lte(t,n){return this.setLimit("max",t,!0,Le.toString(n))}lt(t,n){return this.setLimit("max",t,!1,Le.toString(n))}setLimit(t,n,o,r){return new m0({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:o,message:Le.toString(r)}]})}_addCheck(t){return new m0({...this._def,checks:[...this._def.checks,t]})}int(t){return this._addCheck({kind:"int",message:Le.toString(t)})}positive(t){return this._addCheck({kind:"min",value:0,inclusive:!1,message:Le.toString(t)})}negative(t){return this._addCheck({kind:"max",value:0,inclusive:!1,message:Le.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:0,inclusive:!0,message:Le.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:0,inclusive:!0,message:Le.toString(t)})}multipleOf(t,n){return this._addCheck({kind:"multipleOf",value:t,message:Le.toString(n)})}finite(t){return this._addCheck({kind:"finite",message:Le.toString(t)})}safe(t){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:Le.toString(t)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:Le.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"&&it.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)}}m0.create=e=>new m0({checks:[],typeName:Oe.ZodNumber,coerce:(e==null?void 0:e.coerce)||!1,...Ke(e)});class Fh 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)!==_e.bigint)return this._getInvalidInput(t);let o;const r=new Pn;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),xe(o,{code:ke.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),xe(o,{code:ke.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),xe(o,{code:ke.not_multiple_of,multipleOf:a.value,message:a.message}),r.dirty()):it.assertNever(a);return{status:r.value,value:t.data}}_getInvalidInput(t){const n=this._getOrReturnCtx(t);return xe(n,{code:ke.invalid_type,expected:_e.bigint,received:n.parsedType}),Fe}gte(t,n){return this.setLimit("min",t,!0,Le.toString(n))}gt(t,n){return this.setLimit("min",t,!1,Le.toString(n))}lte(t,n){return this.setLimit("max",t,!0,Le.toString(n))}lt(t,n){return this.setLimit("max",t,!1,Le.toString(n))}setLimit(t,n,o,r){return new Fh({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:o,message:Le.toString(r)}]})}_addCheck(t){return new Fh({...this._def,checks:[...this._def.checks,t]})}positive(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:Le.toString(t)})}negative(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:Le.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:Le.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:Le.toString(t)})}multipleOf(t,n){return this._addCheck({kind:"multipleOf",value:t,message:Le.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}}Fh.create=e=>new Fh({checks:[],typeName:Oe.ZodBigInt,coerce:(e==null?void 0:e.coerce)??!1,...Ke(e)});class yH extends et{_parse(t){if(this._def.coerce&&(t.data=!!t.data),this._getType(t)!==_e.boolean){const o=this._getOrReturnCtx(t);return xe(o,{code:ke.invalid_type,expected:_e.boolean,received:o.parsedType}),Fe}return zo(t.data)}}yH.create=e=>new yH({typeName:Oe.ZodBoolean,coerce:(e==null?void 0:e.coerce)||!1,...Ke(e)});class ZP extends et{_parse(t){if(this._def.coerce&&(t.data=new Date(t.data)),this._getType(t)!==_e.date){const a=this._getOrReturnCtx(t);return xe(a,{code:ke.invalid_type,expected:_e.date,received:a.parsedType}),Fe}if(Number.isNaN(t.data.getTime())){const a=this._getOrReturnCtx(t);return xe(a,{code:ke.invalid_date}),Fe}const o=new Pn;let r;for(const a of this._def.checks)a.kind==="min"?t.data.getTime()<a.value&&(r=this._getOrReturnCtx(t,r),xe(r,{code:ke.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),xe(r,{code:ke.too_big,message:a.message,inclusive:!0,exact:!1,maximum:a.value,type:"date"}),o.dirty()):it.assertNever(a);return{status:o.value,value:new Date(t.data.getTime())}}_addCheck(t){return new ZP({...this._def,checks:[...this._def.checks,t]})}min(t,n){return this._addCheck({kind:"min",value:t.getTime(),message:Le.toString(n)})}max(t,n){return this._addCheck({kind:"max",value:t.getTime(),message:Le.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}}ZP.create=e=>new ZP({checks:[],coerce:(e==null?void 0:e.coerce)||!1,typeName:Oe.ZodDate,...Ke(e)});class _U extends et{_parse(t){if(this._getType(t)!==_e.symbol){const o=this._getOrReturnCtx(t);return xe(o,{code:ke.invalid_type,expected:_e.symbol,received:o.parsedType}),Fe}return zo(t.data)}}_U.create=e=>new _U({typeName:Oe.ZodSymbol,...Ke(e)});class CU extends et{_parse(t){if(this._getType(t)!==_e.undefined){const o=this._getOrReturnCtx(t);return xe(o,{code:ke.invalid_type,expected:_e.undefined,received:o.parsedType}),Fe}return zo(t.data)}}CU.create=e=>new CU({typeName:Oe.ZodUndefined,...Ke(e)});class SU extends et{_parse(t){if(this._getType(t)!==_e.null){const o=this._getOrReturnCtx(t);return xe(o,{code:ke.invalid_type,expected:_e.null,received:o.parsedType}),Fe}return zo(t.data)}}SU.create=e=>new SU({typeName:Oe.ZodNull,...Ke(e)});class LU extends et{constructor(){super(...arguments),this._any=!0}_parse(t){return zo(t.data)}}LU.create=e=>new LU({typeName:Oe.ZodAny,...Ke(e)});class mH extends et{constructor(){super(...arguments),this._unknown=!0}_parse(t){return zo(t.data)}}mH.create=e=>new mH({typeName:Oe.ZodUnknown,...Ke(e)});class Si extends et{_parse(t){const n=this._getOrReturnCtx(t);return xe(n,{code:ke.invalid_type,expected:_e.never,received:n.parsedType}),Fe}}Si.create=e=>new Si({typeName:Oe.ZodNever,...Ke(e)});class NU extends et{_parse(t){if(this._getType(t)!==_e.undefined){const o=this._getOrReturnCtx(t);return xe(o,{code:ke.invalid_type,expected:_e.void,received:o.parsedType}),Fe}return zo(t.data)}}NU.create=e=>new NU({typeName:Oe.ZodVoid,...Ke(e)});class Tr extends et{_parse(t){const{ctx:n,status:o}=this._processInputParams(t),r=this._def;if(n.parsedType!==_e.array)return xe(n,{code:ke.invalid_type,expected:_e.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)&&(xe(n,{code:i?ke.too_big:ke.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&&(xe(n,{code:ke.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&&(xe(n,{code:ke.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 qr(n,i,n.path,s)))).then(i=>Pn.mergeArray(o,i));const a=[...n.data].map((i,s)=>r.type._parseSync(new qr(n,i,n.path,s)));return Pn.mergeArray(o,a)}get element(){return this._def.type}min(t,n){return new Tr({...this._def,minLength:{value:t,message:Le.toString(n)}})}max(t,n){return new Tr({...this._def,maxLength:{value:t,message:Le.toString(n)}})}length(t,n){return new Tr({...this._def,exactLength:{value:t,message:Le.toString(n)}})}nonempty(t){return this.min(1,t)}}Tr.create=(e,t)=>new Tr({type:e,minLength:null,maxLength:null,exactLength:null,typeName:Oe.ZodArray,...Ke(t)});function pu(e){if(e instanceof Bt){const t={};for(const n in e.shape){const o=e.shape[n];t[n]=wi.create(pu(o))}return new Bt({...e._def,shape:()=>t})}else return e instanceof Tr?new Tr({...e._def,type:pu(e.element)}):e instanceof wi?wi.create(pu(e.unwrap())):e instanceof v0?v0.create(pu(e.unwrap())):e instanceof Ld?Ld.create(e.items.map(t=>pu(t))):e}class Bt 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=it.objectKeys(t);return this._cached={shape:t,keys:n},this._cached}_parse(t){if(this._getType(t)!==_e.object){const l=this._getOrReturnCtx(t);return xe(l,{code:ke.invalid_type,expected:_e.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 Si&&this._def.unknownKeys==="strip"))for(const l in r.data)i.includes(l)||s.push(l);const c=[];for(const l of i){const u=a[l],h=r.data[l];c.push({key:{status:"valid",value:l},value:u._parse(new qr(r,h,r.path,l)),alwaysSet:l in r.data})}if(this._def.catchall instanceof Si){const l=this._def.unknownKeys;if(l==="passthrough")for(const u of s)c.push({key:{status:"valid",value:u},value:{status:"valid",value:r.data[u]}});else if(l==="strict")s.length>0&&(xe(r,{code:ke.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 u of s){const h=r.data[u];c.push({key:{status:"valid",value:u},value:l._parse(new qr(r,h,r.path,u)),alwaysSet:u in r.data})}}return r.common.async?Promise.resolve().then(async()=>{const l=[];for(const u of c){const h=await u.key,f=await u.value;l.push({key:h,value:f,alwaysSet:u.alwaysSet})}return l}).then(l=>Pn.mergeObjectSync(o,l)):Pn.mergeObjectSync(o,c)}get shape(){return this._def.shape()}strict(t){return Le.errToObj,new Bt({...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:Le.errToObj(t).message??r}:{message:r}}}:{}})}strip(){return new Bt({...this._def,unknownKeys:"strip"})}passthrough(){return new Bt({...this._def,unknownKeys:"passthrough"})}extend(t){return new Bt({...this._def,shape:()=>({...this._def.shape(),...t})})}merge(t){return new Bt({unknownKeys:t._def.unknownKeys,catchall:t._def.catchall,shape:()=>({...this._def.shape(),...t._def.shape()}),typeName:Oe.ZodObject})}setKey(t,n){return this.augment({[t]:n})}catchall(t){return new Bt({...this._def,catchall:t})}pick(t){const n={};for(const o of it.objectKeys(t))t[o]&&this.shape[o]&&(n[o]=this.shape[o]);return new Bt({...this._def,shape:()=>n})}omit(t){const n={};for(const o of it.objectKeys(this.shape))t[o]||(n[o]=this.shape[o]);return new Bt({...this._def,shape:()=>n})}deepPartial(){return pu(this)}partial(t){const n={};for(const o of it.objectKeys(this.shape)){const r=this.shape[o];t&&!t[o]?n[o]=r:n[o]=r.optional()}return new Bt({...this._def,shape:()=>n})}required(t){const n={};for(const o of it.objectKeys(this.shape))if(t&&!t[o])n[o]=this.shape[o];else{let a=this.shape[o];for(;a instanceof wi;)a=a._def.innerType;n[o]=a}return new Bt({...this._def,shape:()=>n})}keyof(){return HQ(it.objectKeys(this.shape))}}Bt.create=(e,t)=>new Bt({shape:()=>e,unknownKeys:"strip",catchall:Si.create(),typeName:Oe.ZodObject,...Ke(t)});Bt.strictCreate=(e,t)=>new Bt({shape:()=>e,unknownKeys:"strict",catchall:Si.create(),typeName:Oe.ZodObject,...Ke(t)});Bt.lazycreate=(e,t)=>new Bt({shape:e,unknownKeys:"strip",catchall:Si.create(),typeName:Oe.ZodObject,...Ke(t)});class XP 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 ga(s.ctx.common.issues));return xe(n,{code:ke.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},u=c._parseSync({data:n.data,path:n.path,parent:l});if(u.status==="valid")return u;u.status==="dirty"&&!a&&(a={result:u,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 ga(c));return xe(n,{code:ke.invalid_union,unionErrors:s}),Fe}}get options(){return this._def.options}}XP.create=(e,t)=>new XP({options:e,typeName:Oe.ZodUnion,...Ke(t)});function kH(e,t){const n=ri(e),o=ri(t);if(e===t)return{valid:!0,data:e};if(n===_e.object&&o===_e.object){const r=it.objectKeys(t),a=it.objectKeys(e).filter(s=>r.indexOf(s)!==-1),i={...e,...t};for(const s of a){const c=kH(e[s],t[s]);if(!c.valid)return{valid:!1};i[s]=c.data}return{valid:!0,data:i}}else if(n===_e.array&&o===_e.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=kH(i,s);if(!c.valid)return{valid:!1};r.push(c.data)}return{valid:!0,data:r}}else return n===_e.date&&o===_e.date&&+e==+t?{valid:!0,data:e}:{valid:!1}}class YP extends et{_parse(t){const{status:n,ctx:o}=this._processInputParams(t),r=(a,i)=>{if(wU(a)||wU(i))return Fe;const s=kH(a.value,i.value);return s.valid?((MU(a)||MU(i))&&n.dirty(),{status:n.value,value:s.data}):(xe(o,{code:ke.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}))}}YP.create=(e,t,n)=>new YP({left:e,right:t,typeName:Oe.ZodIntersection,...Ke(n)});class Ld extends et{_parse(t){const{status:n,ctx:o}=this._processInputParams(t);if(o.parsedType!==_e.array)return xe(o,{code:ke.invalid_type,expected:_e.array,received:o.parsedType}),Fe;if(o.data.length<this._def.items.length)return xe(o,{code:ke.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),Fe;!this._def.rest&&o.data.length>this._def.items.length&&(xe(o,{code:ke.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 qr(o,i,o.path,s)):null}).filter(i=>!!i);return o.common.async?Promise.all(a).then(i=>Pn.mergeArray(n,i)):Pn.mergeArray(n,a)}get items(){return this._def.items}rest(t){return new Ld({...this._def,rest:t})}}Ld.create=(e,t)=>{if(!Array.isArray(e))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Ld({items:e,typeName:Oe.ZodTuple,rest:null,...Ke(t)})};class QP 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!==_e.object)return xe(o,{code:ke.invalid_type,expected:_e.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 qr(o,s,o.path,s)),value:i._parse(new qr(o,o.data[s],o.path,s)),alwaysSet:s in o.data});return o.common.async?Pn.mergeObjectAsync(n,r):Pn.mergeObjectSync(n,r)}get element(){return this._def.valueType}static create(t,n,o){return n instanceof et?new QP({keyType:t,valueType:n,typeName:Oe.ZodRecord,...Ke(o)}):new QP({keyType:ua.create(),valueType:t,typeName:Oe.ZodRecord,...Ke(n)})}}class IU 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!==_e.map)return xe(o,{code:ke.invalid_type,expected:_e.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 qr(o,s,o.path,[l,"key"])),value:a._parse(new qr(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,u=await c.value;if(l.status==="aborted"||u.status==="aborted")return Fe;(l.status==="dirty"||u.status==="dirty")&&n.dirty(),s.set(l.value,u.value)}return{status:n.value,value:s}})}else{const s=new Map;for(const c of i){const l=c.key,u=c.value;if(l.status==="aborted"||u.status==="aborted")return Fe;(l.status==="dirty"||u.status==="dirty")&&n.dirty(),s.set(l.value,u.value)}return{status:n.value,value:s}}}}IU.create=(e,t,n)=>new IU({valueType:t,keyType:e,typeName:Oe.ZodMap,...Ke(n)});class Vh extends et{_parse(t){const{status:n,ctx:o}=this._processInputParams(t);if(o.parsedType!==_e.set)return xe(o,{code:ke.invalid_type,expected:_e.set,received:o.parsedType}),Fe;const r=this._def;r.minSize!==null&&o.data.size<r.minSize.value&&(xe(o,{code:ke.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&&(xe(o,{code:ke.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 u of c){if(u.status==="aborted")return Fe;u.status==="dirty"&&n.dirty(),l.add(u.value)}return{status:n.value,value:l}}const s=[...o.data.values()].map((c,l)=>a._parse(new qr(o,c,o.path,l)));return o.common.async?Promise.all(s).then(c=>i(c)):i(s)}min(t,n){return new Vh({...this._def,minSize:{value:t,message:Le.toString(n)}})}max(t,n){return new Vh({...this._def,maxSize:{value:t,message:Le.toString(n)}})}size(t,n){return this.min(t,n).max(t,n)}nonempty(t){return this.min(1,t)}}Vh.create=(e,t)=>new Vh({valueType:e,minSize:null,maxSize:null,typeName:Oe.ZodSet,...Ke(t)});class AU 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})}}AU.create=(e,t)=>new AU({getter:e,typeName:Oe.ZodLazy,...Ke(t)});class gH extends et{_parse(t){if(t.data!==this._def.value){const n=this._getOrReturnCtx(t);return xe(n,{received:n.data,code:ke.invalid_literal,expected:this._def.value}),Fe}return{status:"valid",value:t.data}}get value(){return this._def.value}}gH.create=(e,t)=>new gH({value:e,typeName:Oe.ZodLiteral,...Ke(t)});function HQ(e,t){return new k0({values:e,typeName:Oe.ZodEnum,...Ke(t)})}class k0 extends et{_parse(t){if(typeof t.data!="string"){const n=this._getOrReturnCtx(t),o=this._def.values;return xe(n,{expected:it.joinValues(o),received:n.parsedType,code:ke.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 xe(n,{received:n.data,code:ke.invalid_enum_value,options:o}),Fe}return zo(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 k0.create(t,{...this._def,...n})}exclude(t,n=this._def){return k0.create(this.options.filter(o=>!t.includes(o)),{...this._def,...n})}}k0.create=HQ;class EU extends et{_parse(t){const n=it.getValidEnumValues(this._def.values),o=this._getOrReturnCtx(t);if(o.parsedType!==_e.string&&o.parsedType!==_e.number){const r=it.objectValues(n);return xe(o,{expected:it.joinValues(r),received:o.parsedType,code:ke.invalid_type}),Fe}if(this._cache||(this._cache=new Set(it.getValidEnumValues(this._def.values))),!this._cache.has(t.data)){const r=it.objectValues(n);return xe(o,{received:o.data,code:ke.invalid_enum_value,options:r}),Fe}return zo(t.data)}get enum(){return this._def.values}}EU.create=(e,t)=>new EU({values:e,typeName:Oe.ZodNativeEnum,...Ke(t)});class JP extends et{unwrap(){return this._def.type}_parse(t){const{ctx:n}=this._processInputParams(t);if(n.parsedType!==_e.promise&&n.common.async===!1)return xe(n,{code:ke.invalid_type,expected:_e.promise,received:n.parsedType}),Fe;const o=n.parsedType===_e.promise?n.data:Promise.resolve(n.data);return zo(o.then(r=>this._def.type.parseAsync(r,{path:n.path,errorMap:n.common.contextualErrorMap})))}}JP.create=(e,t)=>new JP({type:e,typeName:Oe.ZodPromise,...Ke(t)});class g0 extends et{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===Oe.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=>{xe(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"?b2(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"?b2(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(!y0(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=>y0(i)?Promise.resolve(r.transform(i.value,a)).then(s=>({status:n.value,value:s})):Fe);it.assertNever(r)}}g0.create=(e,t,n)=>new g0({schema:e,typeName:Oe.ZodEffects,effect:t,...Ke(n)});g0.createWithPreprocess=(e,t,n)=>new g0({schema:t,effect:{type:"preprocess",transform:e},typeName:Oe.ZodEffects,...Ke(n)});class wi extends et{_parse(t){return this._getType(t)===_e.undefined?zo(void 0):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}}wi.create=(e,t)=>new wi({innerType:e,typeName:Oe.ZodOptional,...Ke(t)});class v0 extends et{_parse(t){return this._getType(t)===_e.null?zo(null):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}}v0.create=(e,t)=>new v0({innerType:e,typeName:Oe.ZodNullable,...Ke(t)});class vH extends et{_parse(t){const{ctx:n}=this._processInputParams(t);let o=n.data;return n.parsedType===_e.undefined&&(o=this._def.defaultValue()),this._def.innerType._parse({data:o,path:n.path,parent:n})}removeDefault(){return this._def.innerType}}vH.create=(e,t)=>new vH({innerType:e,typeName:Oe.ZodDefault,defaultValue:typeof t.default=="function"?t.default:()=>t.default,...Ke(t)});class xH 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 KP(r)?r.then(a=>({status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new ga(o.common.issues)},input:o.data})})):{status:"valid",value:r.status==="valid"?r.value:this._def.catchValue({get error(){return new ga(o.common.issues)},input:o.data})}}removeCatch(){return this._def.innerType}}xH.create=(e,t)=>new xH({innerType:e,typeName:Oe.ZodCatch,catchValue:typeof t.catch=="function"?t.catch:()=>t.catch,...Ke(t)});class $U extends et{_parse(t){if(this._getType(t)!==_e.nan){const o=this._getOrReturnCtx(t);return xe(o,{code:ke.invalid_type,expected:_e.nan,received:o.parsedType}),Fe}return{status:"valid",value:t.data}}}$U.create=e=>new $U({typeName:Oe.ZodNaN,...Ke(e)});class gDe 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 xO 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(),b2(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 xO({in:t,out:n,typeName:Oe.ZodPipeline})}}class wH extends et{_parse(t){const n=this._def.innerType._parse(t),o=r=>(y0(r)&&(r.value=Object.freeze(r.value)),r);return KP(n)?n.then(r=>o(r)):o(n)}unwrap(){return this._def.innerType}}wH.create=(e,t)=>new wH({innerType:e,typeName:Oe.ZodReadonly,...Ke(t)});var Oe;(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"})(Oe||(Oe={}));const cn=ua.create,qQ=m0.create,vDe=yH.create,sh=mH.create;Si.create;const Xi=Tr.create,at=Bt.create,MH=XP.create;YP.create;Ld.create;const jU=QP.create,pp=gH.create,yp=k0.create;JP.create;wi.create;v0.create;const xDe=at({$state:cn().min(1)}),ra=at({$action:cn().min(1)}),wDe=at({$cond:sh(),$then:sh(),$else:sh().optional()}),Vo=e=>MH([e,xDe,ra,wDe]),Ht=Vo(cn()),ea=Vo(qQ()),mp=Vo(vDe()),OQ={Card:at({title:Ht.optional()}),Separator:at({orientation:Vo(yp(["horizontal","vertical"])).optional()}),Tabs:at({value:Ht.optional(),items:Xi(at({id:cn(),label:cn()})),onChange:ra.optional()}),Accordion:at({items:Xi(at({id:cn(),title:cn(),content:cn()}))}),Badge:at({label:Ht,variant:Vo(yp(["default","secondary","destructive","outline"])).optional()}),Avatar:at({src:Ht.optional(),alt:Ht.optional(),fallback:Ht.optional()}),Progress:at({value:ea}),Skeleton:at({width:ea.optional(),height:ea.optional()}),Label:at({text:Ht}),Heading:at({level:Vo(MH([pp(1),pp(2),pp(3),pp(4)])).optional(),text:Ht}),Text:at({text:Ht,muted:mp.optional()}),Icon:at({name:Ht,size:ea.optional()}),Chart:at({kind:Vo(yp(["bar","line","area","pie"])),data:Vo(Xi(jU(cn(),sh()))),xKey:Ht.optional(),series:Xi(at({key:cn(),label:cn().optional()})).optional()}),Table:at({columns:Xi(at({key:cn(),label:cn()})),rows:Vo(Xi(jU(cn(),sh())))}),Metric:at({label:Ht,value:Vo(MH([cn(),qQ()]))}),CodeBlock:at({code:Ht,language:Ht.optional()}),Markdown:at({content:Ht}),Button:at({label:Ht,variant:Vo(yp(["default","destructive","outline","secondary","ghost","link"])).optional(),onClick:ra.optional(),disabled:mp.optional()}),Input:at({value:Ht.optional(),placeholder:Ht.optional(),onChange:ra.optional()}),Checkbox:at({checked:mp.optional(),onChange:ra.optional(),label:Ht.optional()}),Switch:at({checked:mp.optional(),onChange:ra.optional()}),Select:at({value:Ht.optional(),items:Xi(at({value:cn(),label:cn()})),onChange:ra.optional()}),Textarea:at({value:Ht.optional(),placeholder:Ht.optional(),rows:ea.optional(),onChange:ra.optional()}),Slider:at({value:ea.optional(),min:ea.optional(),max:ea.optional(),step:ea.optional(),onChange:ra.optional()})},FQ=Object.keys(OQ);Object.fromEntries(FQ.map(e=>[e,{props:OQ[e],description:e}]));function PU(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function Or(...e){return t=>{let n=!1;const o=e.map(r=>{const a=PU(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():PU(e[r],null)}}}}function gt(...e){return m.useCallback(Or(...e),e)}var MDe=Symbol.for("react.lazy"),ez=lq[" use ".trim().toString()];function bDe(e){return typeof e=="object"&&e!==null&&"then"in e}function VQ(e){return e!=null&&typeof e=="object"&&"$$typeof"in e&&e.$$typeof===MDe&&"_payload"in e&&bDe(e._payload)}function _De(e){const t=SDe(e),n=m.forwardRef((o,r)=>{let{children:a,...i}=o;VQ(a)&&typeof ez=="function"&&(a=ez(a._payload));const s=m.Children.toArray(a),c=s.find(NDe);if(c){const l=c.props.children,u=s.map(h=>h===c?m.Children.count(l)>1?m.Children.only(null):m.isValidElement(l)?l.props.children:null:h);return p.jsx(t,{...i,ref:r,children:m.isValidElement(l)?m.cloneElement(l,void 0,u):null})}return p.jsx(t,{...i,ref:r,children:a})});return n.displayName=`${e}.Slot`,n}var CDe=_De("Slot");function SDe(e){const t=m.forwardRef((n,o)=>{let{children:r,...a}=n;if(VQ(r)&&typeof ez=="function"&&(r=ez(r._payload)),m.isValidElement(r)){const i=ADe(r),s=IDe(a,r.props);return r.type!==m.Fragment&&(s.ref=o?Or(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 LDe=Symbol("radix.slottable");function NDe(e){return m.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===LDe}function IDe(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 ADe(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 zU=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,RU=jX,BQ=(e,t)=>n=>{var o;if((t==null?void 0:t.variants)==null)return RU(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 u=n==null?void 0:n[l],h=a==null?void 0:a[l];if(u===null)return null;const f=zU(u)||zU(h);return r[l][f]}),s=n&&Object.entries(n).reduce((l,u)=>{let[h,f]=u;return f===void 0||(l[h]=f),l},{}),c=t==null||(o=t.compoundVariants)===null||o===void 0?void 0:o.reduce((l,u)=>{let{class:h,className:f,...y}=u;return Object.entries(y).every(k=>{let[v,w]=k;return Array.isArray(w)?w.includes({...a,...s}[v]):{...a,...s}[v]===w})?[...l,h,f]:l},[]);return RU(e,i,c,n==null?void 0:n.class,n==null?void 0:n.className)},EDe=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"}}),dt=m.forwardRef(({className:e,variant:t,size:n,asChild:o=!1,...r},a)=>{const i=o?CDe:"button";return p.jsx(i,{className:ie(EDe({variant:t,size:n,className:e})),ref:a,...r})});dt.displayName="Button";function UQ(e,[t,n]){return Math.min(n,Math.max(t,e))}function Ce(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 $De(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 or(e,t=[]){let n=[];function o(a,i){const s=m.createContext(i),c=n.length;n=[...n,i];const l=h=>{var g;const{scope:f,children:y,...k}=h,v=((g=f==null?void 0:f[e])==null?void 0:g[c])||s,w=m.useMemo(()=>k,Object.values(k));return p.jsx(v.Provider,{value:w,children:y})};l.displayName=a+"Provider";function u(h,f){var v;const y=((v=f==null?void 0:f[e])==null?void 0:v[c])||s,k=m.useContext(y);if(k)return k;if(i!==void 0)return i;throw new Error(`\`${h}\` must be used within \`${a}\``)}return[l,u]}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,jDe(r,...t)]}function jDe(...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 h=c(a)[`__scope${l}`];return{...s,...h}},{});return m.useMemo(()=>({[`__scope${t.scopeName}`]:i}),[i])}};return n.scopeName=t.scopeName,n}var Li=globalThis!=null&&globalThis.document?m.useLayoutEffect:()=>{},PDe=lq[" useInsertionEffect ".trim().toString()]||Li;function zd({prop:e,defaultProp:t,onChange:n=()=>{},caller:o}){const[r,a,i]=zDe({defaultProp:t,onChange:n}),s=e!==void 0,c=s?e:r;{const u=m.useRef(e!==void 0);m.useEffect(()=>{const h=u.current;h!==s&&console.warn(`${o} is changing from ${h?"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.`),u.current=s},[s,o])}const l=m.useCallback(u=>{var h;if(s){const f=RDe(u)?u(e):u;f!==e&&((h=i.current)==null||h.call(i,f))}else a(u)},[s,e,a,i]);return[c,l]}function zDe({defaultProp:e,onChange:t}){const[n,o]=m.useState(e),r=m.useRef(n),a=m.useRef(t);return PDe(()=>{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 RDe(e){return typeof e=="function"}var TDe=m.createContext(void 0);function Kz(e){const t=m.useContext(TDe);return e||t||"ltr"}function DDe(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 WQ(e){const[t,n]=m.useState(void 0);return Li(()=>{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 x0(e){const t=HDe(e),n=m.forwardRef((o,r)=>{const{children:a,...i}=o,s=m.Children.toArray(a),c=s.find(ODe);if(c){const l=c.props.children,u=s.map(h=>h===c?m.Children.count(l)>1?m.Children.only(null):m.isValidElement(l)?l.props.children:null:h);return p.jsx(t,{...i,ref:r,children:m.isValidElement(l)?m.cloneElement(l,void 0,u):null})}return p.jsx(t,{...i,ref:r,children:a})});return n.displayName=`${e}.Slot`,n}function HDe(e){const t=m.forwardRef((n,o)=>{const{children:r,...a}=n;if(m.isValidElement(r)){const i=VDe(r),s=FDe(a,r.props);return r.type!==m.Fragment&&(s.ref=o?Or(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 GQ=Symbol("radix.slottable");function qDe(e){const t=({children:n})=>p.jsx(p.Fragment,{children:n});return t.displayName=`${e}.Slottable`,t.__radixId=GQ,t}function ODe(e){return m.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===GQ}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 VDe(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 BDe=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Ue=BDe.reduce((e,t)=>{const n=x0(`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 KQ(e,t){e&&I0.flushSync(()=>e.dispatchEvent(t))}function wO(e){const t=e+"CollectionProvider",[n,o]=or(t),[r,a]=n(t,{collectionRef:{current:null},itemMap:new Map}),i=v=>{const{scope:w,children:g}=v,M=Lr.useRef(null),x=Lr.useRef(new Map).current;return p.jsx(r,{scope:w,itemMap:x,collectionRef:M,children:g})};i.displayName=t;const s=e+"CollectionSlot",c=x0(s),l=Lr.forwardRef((v,w)=>{const{scope:g,children:M}=v,x=a(s,g),b=gt(w,x.collectionRef);return p.jsx(c,{ref:b,children:M})});l.displayName=s;const u=e+"CollectionItemSlot",h="data-radix-collection-item",f=x0(u),y=Lr.forwardRef((v,w)=>{const{scope:g,children:M,...x}=v,b=Lr.useRef(null),C=gt(w,b),_=a(u,g);return Lr.useEffect(()=>(_.itemMap.set(b,{ref:b,...x}),()=>void _.itemMap.delete(b))),p.jsx(f,{[h]:"",ref:C,children:M})});y.displayName=u;function k(v){const w=a(e+"CollectionConsumer",v);return Lr.useCallback(()=>{const M=w.collectionRef.current;if(!M)return[];const x=Array.from(M.querySelectorAll(`[${h}]`));return Array.from(w.itemMap.values()).sort((_,S)=>x.indexOf(_.ref.current)-x.indexOf(S.ref.current))},[w.collectionRef,w.itemMap])}return[{Provider:i,Slot:l,ItemSlot:y},k,o]}var ZQ=["PageUp","PageDown"],XQ=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],YQ={"from-left":["Home","PageDown","ArrowDown","ArrowLeft"],"from-right":["Home","PageDown","ArrowDown","ArrowRight"],"from-bottom":["Home","PageDown","ArrowDown","ArrowLeft"],"from-top":["Home","PageDown","ArrowUp","ArrowLeft"]},j0="Slider",[bH,UDe,WDe]=wO(j0),[QQ]=or(j0,[WDe]),[GDe,Zz]=QQ(j0),JQ=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:u,onValueChange:h=()=>{},onValueCommit:f=()=>{},inverted:y=!1,form:k,...v}=e,w=m.useRef(new Set),g=m.useRef(0),x=i==="horizontal"?KDe:ZDe,[b=[],C]=zd({prop:u,defaultProp:l,onChange:A=>{var Y;(Y=[...w.current][g.current])==null||Y.focus(),h(A)}}),_=m.useRef(b);function S(A){const R=eHe(b,A);N(A,R)}function $(A){N(A,g.current)}function j(){const A=_.current[g.current];b[g.current]!==A&&f(b)}function N(A,R,{commit:Y}={commit:!1}){const z=rHe(a),V=aHe(Math.round((A-o)/a)*a+o,z),H=UQ(V,[o,r]);C((O=[])=>{const P=QDe(O,H,R);if(oHe(P,c*a)){g.current=P.indexOf(H);const I=String(P)!==String(O);return I&&Y&&f(P),I?P:O}else return O})}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(bH.Provider,{scope:e.__scopeSlider,children:p.jsx(bH.Slot,{scope:e.__scopeSlider,children:p.jsx(x,{"aria-disabled":s,"data-disabled":s?"":void 0,...v,ref:t,onPointerDown:Ce(v.onPointerDown,()=>{s||(_.current=b)}),min:o,max:r,inverted:y,onSlideStart:s?void 0:S,onSlideMove:s?void 0:$,onSlideEnd:s?void 0:j,onHomeKeyDown:()=>!s&&N(o,0,{commit:!0}),onEndKeyDown:()=>!s&&N(r,b.length-1,{commit:!0}),onStepKeyDown:({event:A,direction:R})=>{if(!s){const V=ZQ.includes(A.key)||A.shiftKey&&XQ.includes(A.key)?10:1,H=g.current,O=b[H],P=a*V*R;N(O+P,H,{commit:!0})}}})})})})});JQ.displayName=j0;var[eJ,tJ]=QQ(j0,{startEdge:"left",endEdge:"right",size:"width",direction:1}),KDe=m.forwardRef((e,t)=>{const{min:n,max:o,dir:r,inverted:a,onSlideStart:i,onSlideMove:s,onSlideEnd:c,onStepKeyDown:l,...u}=e,[h,f]=m.useState(null),y=gt(t,x=>f(x)),k=m.useRef(void 0),v=Kz(r),w=v==="ltr",g=w&&!a||!w&&a;function M(x){const b=k.current||h.getBoundingClientRect(),C=[0,b.width],S=MO(C,g?[n,o]:[o,n]);return k.current=b,S(x-b.left)}return p.jsx(eJ,{scope:e.__scopeSlider,startEdge:g?"left":"right",endEdge:g?"right":"left",direction:g?1:-1,size:"width",children:p.jsx(nJ,{dir:v,"data-orientation":"horizontal",...u,ref:y,style:{...u.style,"--radix-slider-thumb-transform":"translateX(-50%)"},onSlideStart:x=>{const b=M(x.clientX);i==null||i(b)},onSlideMove:x=>{const b=M(x.clientX);s==null||s(b)},onSlideEnd:()=>{k.current=void 0,c==null||c()},onStepKeyDown:x=>{const C=YQ[g?"from-left":"from-right"].includes(x.key);l==null||l({event:x,direction:C?-1:1})}})})}),ZDe=m.forwardRef((e,t)=>{const{min:n,max:o,inverted:r,onSlideStart:a,onSlideMove:i,onSlideEnd:s,onStepKeyDown:c,...l}=e,u=m.useRef(null),h=gt(t,u),f=m.useRef(void 0),y=!r;function k(v){const w=f.current||u.current.getBoundingClientRect(),g=[0,w.height],x=MO(g,y?[o,n]:[n,o]);return f.current=w,x(v-w.top)}return p.jsx(eJ,{scope:e.__scopeSlider,startEdge:y?"bottom":"top",endEdge:y?"top":"bottom",size:"height",direction:y?1:-1,children:p.jsx(nJ,{"data-orientation":"vertical",...l,ref:h,style:{...l.style,"--radix-slider-thumb-transform":"translateY(50%)"},onSlideStart:v=>{const w=k(v.clientY);a==null||a(w)},onSlideMove:v=>{const w=k(v.clientY);i==null||i(w)},onSlideEnd:()=>{f.current=void 0,s==null||s()},onStepKeyDown:v=>{const g=YQ[y?"from-bottom":"from-top"].includes(v.key);c==null||c({event:v,direction:g?-1:1})}})})}),nJ=m.forwardRef((e,t)=>{const{__scopeSlider:n,onSlideStart:o,onSlideMove:r,onSlideEnd:a,onHomeKeyDown:i,onEndKeyDown:s,onStepKeyDown:c,...l}=e,u=Zz(j0,n);return p.jsx(Ue.span,{...l,ref:t,onKeyDown:Ce(e.onKeyDown,h=>{h.key==="Home"?(i(h),h.preventDefault()):h.key==="End"?(s(h),h.preventDefault()):ZQ.concat(XQ).includes(h.key)&&(c(h),h.preventDefault())}),onPointerDown:Ce(e.onPointerDown,h=>{const f=h.target;f.setPointerCapture(h.pointerId),h.preventDefault(),u.thumbs.has(f)?f.focus():o(h)}),onPointerMove:Ce(e.onPointerMove,h=>{h.target.hasPointerCapture(h.pointerId)&&r(h)}),onPointerUp:Ce(e.onPointerUp,h=>{const f=h.target;f.hasPointerCapture(h.pointerId)&&(f.releasePointerCapture(h.pointerId),a(h))})})}),oJ="SliderTrack",rJ=m.forwardRef((e,t)=>{const{__scopeSlider:n,...o}=e,r=Zz(oJ,n);return p.jsx(Ue.span,{"data-disabled":r.disabled?"":void 0,"data-orientation":r.orientation,...o,ref:t})});rJ.displayName=oJ;var _H="SliderRange",aJ=m.forwardRef((e,t)=>{const{__scopeSlider:n,...o}=e,r=Zz(_H,n),a=tJ(_H,n),i=m.useRef(null),s=gt(t,i),c=r.values.length,l=r.values.map(f=>cJ(f,r.min,r.max)),u=c>1?Math.min(...l):0,h=100-Math.max(...l);return p.jsx(Ue.span,{"data-orientation":r.orientation,"data-disabled":r.disabled?"":void 0,...o,ref:s,style:{...e.style,[a.startEdge]:u+"%",[a.endEdge]:h+"%"}})});aJ.displayName=_H;var CH="SliderThumb",iJ=m.forwardRef((e,t)=>{const n=UDe(e.__scopeSlider),[o,r]=m.useState(null),a=gt(t,s=>r(s)),i=m.useMemo(()=>o?n().findIndex(s=>s.ref.current===o):-1,[n,o]);return p.jsx(XDe,{...e,ref:a,index:i})}),XDe=m.forwardRef((e,t)=>{const{__scopeSlider:n,index:o,name:r,...a}=e,i=Zz(CH,n),s=tJ(CH,n),[c,l]=m.useState(null),u=gt(t,M=>l(M)),h=c?i.form||!!c.closest("form"):!0,f=WQ(c),y=i.values[o],k=y===void 0?0:cJ(y,i.min,i.max),v=JDe(o,i.values.length),w=f==null?void 0:f[s.size],g=w?tHe(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(bH.ItemSlot,{scope:e.__scopeSlider,children:p.jsx(Ue.span,{role:"slider","aria-label":e["aria-label"]||v,"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:u,style:y===void 0?{display:"none"}:e.style,onFocus:Ce(e.onFocus,()=>{i.valueIndexToChangeRef.current=o})})}),h&&p.jsx(sJ,{name:r??(i.name?i.name+(i.values.length>1?"[]":""):void 0),form:i.form,value:y},o)]})});iJ.displayName=CH;var YDe="RadioBubbleInput",sJ=m.forwardRef(({__scopeSlider:e,value:t,...n},o)=>{const r=m.useRef(null),a=gt(r,o),i=DDe(t);return m.useEffect(()=>{const s=r.current;if(!s)return;const c=window.HTMLInputElement.prototype,u=Object.getOwnPropertyDescriptor(c,"value").set;if(i!==t&&u){const h=new Event("input",{bubbles:!0});u.call(s,t),s.dispatchEvent(h)}},[i,t]),p.jsx(Ue.input,{style:{display:"none"},...n,ref:a,defaultValue:t})});sJ.displayName=YDe;function QDe(e=[],t,n){const o=[...e];return o[n]=t,o.sort((r,a)=>r-a)}function cJ(e,t,n){const a=100/(n-t)*(e-t);return UQ(a,[0,100])}function JDe(e,t){return t>2?`Value ${e+1} of ${t}`:t===2?["Minimum","Maximum"][e]:void 0}function eHe(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 tHe(e,t,n){const o=e/2,a=MO([0,50],[0,o]);return(o-a(t)*n)*n}function nHe(e){return e.slice(0,-1).map((t,n)=>e[n+1]-t)}function oHe(e,t){if(t>0){const n=nHe(e);return Math.min(...n)>=t}return!0}function MO(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 rHe(e){return(String(e).split(".")[1]||"").length}function aHe(e,t){const n=Math.pow(10,t);return Math.round(e*n)/n}var lJ=JQ,iHe=rJ,sHe=aJ,cHe=iJ;const bO=m.forwardRef(({className:e,...t},n)=>p.jsxs(lJ,{ref:n,className:ie("sf:relative sf:flex sf:w-full sf:touch-none sf:select-none sf:items-center",e),...t,children:[p.jsx(iHe,{className:"sf:relative sf:h-1.5 sf:w-full sf:grow sf:overflow-hidden sf:rounded-full sf:bg-secondary",children:p.jsx(sHe,{className:"sf:absolute sf:h-full sf:bg-primary"})}),p.jsx(cHe,{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"})]}));bO.displayName=lJ.displayName;const lHe={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 dHe({text:e,level:t=2}){const n=`h${t}`;return p.jsx(n,{className:ie(lHe[t]),children:e})}const dJ=m.createContext({custom:{}});function uHe({value:e,children:t}){return p.jsx(dJ.Provider,{value:e,children:t})}function hHe(){return m.useContext(dJ)}function w0({name:e,as:t,size:n=16,fallback:o=ZNe,...r}){const a=hHe(),i=t??(e?a.custom[e]:void 0)??(e?r0[e]:void 0)??r0[o];return i?p.jsx(i,{size:n,...r}):null}function fHe({name:e,size:t=16}){return p.jsx(w0,{name:e,size:t,"aria-hidden":!0})}function pHe(e){return e==null?"":typeof e=="string"||typeof e=="number"?e:typeof e=="object"?JSON.stringify(e):String(e)}function yHe({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:pHe(t)})]})}function mHe(e){return e==null?"":typeof e=="string"||typeof e=="number"?String(e):JSON.stringify(e)}function kHe({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:mHe(n[r.key])},r.key))},o))})]})})}function gHe({text:e,muted:t}){return p.jsx("p",{className:ie("sf:text-sm",t&&"sf:text-muted-foreground"),children:e})}function vHe({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 xHe({orientation:e="horizontal"}){return p.jsx("div",{"aria-orientation":e,className:ie("sf:bg-border",e==="horizontal"?"sf:h-px sf:w-full":"sf:h-full sf:w-px")})}function wHe({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 MHe({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 TU={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 bHe({label:e,variant:t="default"}){return p.jsx("span",{className:ie("sf:inline-flex sf:items-center sf:rounded-full sf:px-2.5 sf:py-0.5 sf:font-medium sf:text-xs",TU[t]??TU.default),children:e})}function _He({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 CHe({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 SHe({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 LHe({text:e}){return p.jsx("span",{className:"sf:font-medium sf:text-sm sf:leading-none",children:e})}function NHe({label:e,variant:t="default",onClick:n,disabled:o}){return p.jsx(dt,{variant:t,disabled:o,onClick:()=>n==null?void 0:n(),children:e})}const _O="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 IHe({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:_O})}function AHe({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 EHe({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:ie("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:ie("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 $He({value:e,items:t,onChange:n}){return p.jsx("select",{value:e??"",onChange:o=>n==null?void 0:n({value:o.target.value}),className:_O,children:(t??[]).map(o=>p.jsx("option",{value:o.value,children:o.label},o.value))})}function jHe({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:ie(_O,"sf:min-h-16 sf:py-2")})}function PHe({value:e,min:t=0,max:n=100,step:o=1,onChange:r}){return p.jsx(bO,{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 zHe=m.lazy(()=>ff(()=>import("./chart-D6WVIyqJ.js"),__vite__mapDeps([0,1,2,3,4,5,6,7])));function RHe(e){return p.jsx(m.Suspense,{fallback:null,children:p.jsx(zHe,{...e})})}const THe=m.lazy(()=>ff(()=>import("./markdown-DQ9_ZAvJ.js"),[]));function DHe(e){return p.jsx(m.Suspense,{fallback:null,children:p.jsx(THe,{...e})})}const HHe=m.lazy(()=>ff(()=>import("./code-block-CQcwHam8.js"),[]));function qHe(e){return p.jsx(m.Suspense,{fallback:null,children:p.jsx(HHe,{...e})})}const uJ={Card:vHe,Separator:xHe,Tabs:wHe,Accordion:MHe,Badge:bHe,Avatar:_He,Progress:CHe,Skeleton:SHe,Label:LHe,Heading:dHe,Text:gHe,Icon:fHe,Chart:RHe,Table:kHe,Metric:yHe,CodeBlock:qHe,Markdown:DHe,Button:NHe,Input:IHe,Checkbox:AHe,Switch:EHe,Select:$He,Textarea:jHe,Slider:PHe},DU=FQ.filter(e=>uJ[e]===void 0);if(DU.length>0)throw new Error(`componentRegistry is missing impls for: ${DU.join(", ")}. Every catalog entry in COMPONENT_NAMES must have a matching component impl.`);const OHe={components:uJ};function FHe(e,t){return t.kind==="set"?{...e,[t.path]:t.value}:{...e,...t.partial}}function hJ(e){return e===null||typeof e!="object"?!1:"$state"in e||"$action"in e||"$param"in e||"$cond"in e}function oP(e,t,n,o){if(!hJ(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=oP(e.$cond,t,n,o);return oP(r?e.$then:e.$else,t,n,o)}return e}function VHe(e,t,n,o){if(!e)return{};const r={};for(const[a,i]of Object.entries(e))r[a]=oP(i,t,n,o);return r}function HU({spec:e,nodeId:t,apiBaseUrl:n="/api",projectSlug:o,flowSlug:r}){const[a,i]=m.useReducer(FHe,e.state??{}),s=new Set(Object.keys(e.actions??{})),c=m.useCallback(async(l,u)=>{var y;const h=(y=e.actions)==null?void 0:y[l];if(!h)return;if(h.kind==="set"){const k=BHe(h.value,u,a);i({kind:"set",path:h.path,value:k});return}if(!o||!r)return;const f=`${n}/projects/${encodeURIComponent(o)}/flows/${encodeURIComponent(r)}/nodes/${encodeURIComponent(t)}/actions/${encodeURIComponent(l)}`;try{const k=await fetch(f,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(u??{})});if(!k.ok){const w=await k.text();i({kind:"set",path:`/__errors/${l}`,value:w});return}const v=await k.json();v!==null&&typeof v=="object"&&i({kind:"merge",partial:v})}catch(k){i({kind:"set",path:`/__errors/${l}`,value:k instanceof Error?k.message:String(k)})}},[e.actions,o,r,n,t,a]);return fJ(e.root,e,a,c,s)}function BHe(e,t,n){return hJ(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 fJ(e,t,n,o,r){const a=t.elements[e];if(!a)return null;const i=OHe.components[a.type];if(!i)return null;const s=VHe(a.props,n,o,r),l=(a.children??[]).map(u=>p.jsx(UHe,{children:fJ(u,t,n,o,r)},u));return p.jsx(i,{...s,children:l.length>0?l:void 0})}function UHe({children:e}){return e}function Fr(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 WHe(e,t=globalThis==null?void 0:globalThis.document){const n=Fr(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",SH="dismissableLayer.update",KHe="dismissableLayer.pointerDownOutside",ZHe="dismissableLayer.focusOutside",qU,pJ=m.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),pf=m.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:o,onPointerDownOutside:r,onFocusOutside:a,onInteractOutside:i,onDismiss:s,...c}=e,l=m.useContext(pJ),[u,h]=m.useState(null),f=(u==null?void 0:u.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,y]=m.useState({}),k=gt(t,S=>h(S)),v=Array.from(l.layers),[w]=[...l.layersWithOutsidePointerEventsDisabled].slice(-1),g=v.indexOf(w),M=u?v.indexOf(u):-1,x=l.layersWithOutsidePointerEventsDisabled.size>0,b=M>=g,C=QHe(S=>{const $=S.target,j=[...l.branches].some(N=>N.contains($));!b||j||(r==null||r(S),i==null||i(S),S.defaultPrevented||s==null||s())},f),_=JHe(S=>{const $=S.target;[...l.branches].some(N=>N.contains($))||(a==null||a(S),i==null||i(S),S.defaultPrevented||s==null||s())},f);return WHe(S=>{M===l.layers.size-1&&(o==null||o(S),!S.defaultPrevented&&s&&(S.preventDefault(),s()))},f),m.useEffect(()=>{if(u)return n&&(l.layersWithOutsidePointerEventsDisabled.size===0&&(qU=f.body.style.pointerEvents,f.body.style.pointerEvents="none"),l.layersWithOutsidePointerEventsDisabled.add(u)),l.layers.add(u),OU(),()=>{n&&l.layersWithOutsidePointerEventsDisabled.size===1&&(f.body.style.pointerEvents=qU)}},[u,f,n,l]),m.useEffect(()=>()=>{u&&(l.layers.delete(u),l.layersWithOutsidePointerEventsDisabled.delete(u),OU())},[u,l]),m.useEffect(()=>{const S=()=>y({});return document.addEventListener(SH,S),()=>document.removeEventListener(SH,S)},[]),p.jsx(Ue.div,{...c,ref:k,style:{pointerEvents:x?b?"auto":"none":void 0,...e.style},onFocusCapture:Ce(e.onFocusCapture,_.onFocusCapture),onBlurCapture:Ce(e.onBlurCapture,_.onBlurCapture),onPointerDownCapture:Ce(e.onPointerDownCapture,C.onPointerDownCapture)})});pf.displayName=GHe;var XHe="DismissableLayerBranch",YHe=m.forwardRef((e,t)=>{const n=m.useContext(pJ),o=m.useRef(null),r=gt(t,o);return m.useEffect(()=>{const a=o.current;if(a)return n.branches.add(a),()=>{n.branches.delete(a)}},[n.branches]),p.jsx(Ue.div,{...e,ref:r})});YHe.displayName=XHe;function QHe(e,t=globalThis==null?void 0:globalThis.document){const n=Fr(e),o=m.useRef(!1),r=m.useRef(()=>{});return m.useEffect(()=>{const a=s=>{if(s.target&&!o.current){let c=function(){yJ(KHe,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 JHe(e,t=globalThis==null?void 0:globalThis.document){const n=Fr(e),o=m.useRef(!1);return m.useEffect(()=>{const r=a=>{a.target&&!o.current&&yJ(ZHe,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 OU(){const e=new CustomEvent(SH);document.dispatchEvent(e)}function yJ(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?KQ(r,a):r.dispatchEvent(a)}var kT=0;function CO(){m.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??FU()),document.body.insertAdjacentElement("beforeend",e[1]??FU()),kT++,()=>{kT===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),kT--}},[])}function FU(){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 gT="focusScope.autoFocusOnMount",vT="focusScope.autoFocusOnUnmount",VU={bubbles:!1,cancelable:!0},eqe="FocusScope",Xz=m.forwardRef((e,t)=>{const{loop:n=!1,trapped:o=!1,onMountAutoFocus:r,onUnmountAutoFocus:a,...i}=e,[s,c]=m.useState(null),l=Fr(r),u=Fr(a),h=m.useRef(null),f=gt(t,v=>c(v)),y=m.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;m.useEffect(()=>{if(o){let v=function(x){if(y.paused||!s)return;const b=x.target;s.contains(b)?h.current=b:Ja(h.current,{select:!0})},w=function(x){if(y.paused||!s)return;const b=x.relatedTarget;b!==null&&(s.contains(b)||Ja(h.current,{select:!0}))},g=function(x){if(document.activeElement===document.body)for(const C of x)C.removedNodes.length>0&&Ja(s)};document.addEventListener("focusin",v),document.addEventListener("focusout",w);const M=new MutationObserver(g);return s&&M.observe(s,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",v),document.removeEventListener("focusout",w),M.disconnect()}}},[o,s,y.paused]),m.useEffect(()=>{if(s){UU.add(y);const v=document.activeElement;if(!s.contains(v)){const g=new CustomEvent(gT,VU);s.addEventListener(gT,l),s.dispatchEvent(g),g.defaultPrevented||(tqe(iqe(mJ(s)),{select:!0}),document.activeElement===v&&Ja(s))}return()=>{s.removeEventListener(gT,l),setTimeout(()=>{const g=new CustomEvent(vT,VU);s.addEventListener(vT,u),s.dispatchEvent(g),g.defaultPrevented||Ja(v??document.body,{select:!0}),s.removeEventListener(vT,u),UU.remove(y)},0)}}},[s,l,u,y]);const k=m.useCallback(v=>{if(!n&&!o||y.paused)return;const w=v.key==="Tab"&&!v.altKey&&!v.ctrlKey&&!v.metaKey,g=document.activeElement;if(w&&g){const M=v.currentTarget,[x,b]=nqe(M);x&&b?!v.shiftKey&&g===b?(v.preventDefault(),n&&Ja(x,{select:!0})):v.shiftKey&&g===x&&(v.preventDefault(),n&&Ja(b,{select:!0})):g===M&&v.preventDefault()}},[n,o,y.paused]);return p.jsx(Ue.div,{tabIndex:-1,...i,ref:f,onKeyDown:k})});Xz.displayName=eqe;function tqe(e,{select:t=!1}={}){const n=document.activeElement;for(const o of e)if(Ja(o,{select:t}),document.activeElement!==n)return}function nqe(e){const t=mJ(e),n=BU(t,e),o=BU(t.reverse(),e);return[n,o]}function mJ(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 BU(e,t){for(const n of e)if(!oqe(n,{upTo:t}))return n}function oqe(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 rqe(e){return e instanceof HTMLInputElement&&"select"in e}function Ja(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&rqe(e)&&t&&e.select()}}var UU=aqe();function aqe(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=WU(e,t),e.unshift(t)},remove(t){var n;e=WU(e,t),(n=e[0])==null||n.resume()}}}function WU(e,t){const n=[...e],o=n.indexOf(t);return o!==-1&&n.splice(o,1),n}function iqe(e){return e.filter(t=>t.tagName!=="A")}var sqe=lq[" useId ".trim().toString()]||(()=>{}),cqe=0;function jn(e){const[t,n]=m.useState(sqe());return Li(()=>{n(o=>o??String(cqe++))},[e]),e||(t?`radix-${t}`:"")}const lqe=["top","right","bottom","left"],Ni=Math.min,uo=Math.max,tz=Math.round,kp=Math.floor,Dr=e=>({x:e,y:e}),dqe={left:"right",right:"left",bottom:"top",top:"bottom"};function LH(e,t,n){return uo(e,Ni(t,n))}function va(e,t){return typeof e=="function"?e(t):e}function xa(e){return e.split("-")[0]}function P0(e){return e.split("-")[1]}function SO(e){return e==="x"?"y":"x"}function LO(e){return e==="y"?"height":"width"}function $r(e){const t=e[0];return t==="t"||t==="b"?"y":"x"}function NO(e){return SO($r(e))}function uqe(e,t,n){n===void 0&&(n=!1);const o=P0(e),r=NO(e),a=LO(r);let i=r==="x"?o===(n?"end":"start")?"right":"left":o==="start"?"bottom":"top";return t.reference[a]>t.floating[a]&&(i=nz(i)),[i,nz(i)]}function hqe(e){const t=nz(e);return[NH(e),t,NH(t)]}function NH(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const GU=["left","right"],KU=["right","left"],fqe=["top","bottom"],pqe=["bottom","top"];function yqe(e,t,n){switch(e){case"top":case"bottom":return n?t?KU:GU:t?GU:KU;case"left":case"right":return t?fqe:pqe;default:return[]}}function mqe(e,t,n,o){const r=P0(e);let a=yqe(xa(e),n==="start",o);return r&&(a=a.map(i=>i+"-"+r),t&&(a=a.concat(a.map(NH)))),a}function nz(e){const t=xa(e);return dqe[t]+e.slice(t.length)}function kqe(e){return{top:0,right:0,bottom:0,left:0,...e}}function kJ(e){return typeof e!="number"?kqe(e):{top:e,right:e,bottom:e,left:e}}function oz(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 ZU(e,t,n){let{reference:o,floating:r}=e;const a=$r(t),i=NO(t),s=LO(i),c=xa(t),l=a==="y",u=o.x+o.width/2-r.width/2,h=o.y+o.height/2-r.height/2,f=o[s]/2-r[s]/2;let y;switch(c){case"top":y={x:u,y:o.y-r.height};break;case"bottom":y={x:u,y:o.y+o.height};break;case"right":y={x:o.x+o.width,y:h};break;case"left":y={x:o.x-r.width,y:h};break;default:y={x:o.x,y:o.y}}switch(P0(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 gqe(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:u="viewport",elementContext:h="floating",altBoundary:f=!1,padding:y=0}=va(t,e),k=kJ(y),w=s[f?h==="floating"?"reference":"floating":h],g=oz(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:u,strategy:c})),M=h==="floating"?{x:o,y:r,width:i.floating.width,height:i.floating.height}:i.reference,x=await(a.getOffsetParent==null?void 0:a.getOffsetParent(s.floating)),b=await(a.isElement==null?void 0:a.isElement(x))?await(a.getScale==null?void 0:a.getScale(x))||{x:1,y:1}:{x:1,y:1},C=oz(a.convertOffsetParentRelativeRectToViewportRelativeRect?await a.convertOffsetParentRelativeRectToViewportRelativeRect({elements:s,rect:M,offsetParent:x,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 vqe=50,xqe=async(e,t,n)=>{const{placement:o="bottom",strategy:r="absolute",middleware:a=[],platform:i}=n,s=i.detectOverflow?i:{...i,detectOverflow:gqe},c=await(i.isRTL==null?void 0:i.isRTL(t));let l=await i.getElementRects({reference:e,floating:t,strategy:r}),{x:u,y:h}=ZU(l,o,c),f=o,y=0;const k={};for(let v=0;v<a.length;v++){const w=a[v];if(!w)continue;const{name:g,fn:M}=w,{x,y:b,data:C,reset:_}=await M({x:u,y:h,initialPlacement:o,placement:f,strategy:r,middlewareData:k,rects:l,platform:s,elements:{reference:e,floating:t}});u=x??u,h=b??h,k[g]={...k[g],...C},_&&y<vqe&&(y++,typeof _=="object"&&(_.placement&&(f=_.placement),_.rects&&(l=_.rects===!0?await i.getElementRects({reference:e,floating:t,strategy:r}):_.rects),{x:u,y:h}=ZU(l,f,c)),v=-1)}return{x:u,y:h,placement:f,strategy:r,middlewareData:k}},wqe=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:u=0}=va(e,t)||{};if(l==null)return{};const h=kJ(u),f={x:n,y:o},y=NO(r),k=LO(y),v=await i.getDimensions(l),w=y==="y",g=w?"top":"left",M=w?"bottom":"right",x=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=_?_[x]:0;(!S||!await(i.isElement==null?void 0:i.isElement(_)))&&(S=s.floating[x]||a.floating[k]);const $=b/2-C/2,j=S/2-v[k]/2-1,N=Ni(h[g],j),A=Ni(h[M],j),R=N,Y=S-v[k]-A,z=S/2-v[k]/2+$,V=LH(R,z,Y),H=!c.arrow&&P0(r)!=null&&z!==V&&a.reference[k]/2-(z<R?N:A)-v[k]/2<0,O=H?z<R?z-R:z-Y:0;return{[y]:f[y]+O,data:{[y]:V,centerOffset:z-V-O,...H&&{alignmentOffset:O}},reset:H}}}),Mqe=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:u=!0,crossAxis:h=!0,fallbackPlacements:f,fallbackStrategy:y="bestFit",fallbackAxisSideDirection:k="none",flipAlignment:v=!0,...w}=va(e,t);if((n=a.arrow)!=null&&n.alignmentOffset)return{};const g=xa(r),M=$r(s),x=xa(s)===s,b=await(c.isRTL==null?void 0:c.isRTL(l.floating)),C=f||(x||!v?[nz(s)]:hqe(s)),_=k!=="none";!f&&_&&C.push(...mqe(s,v,k,b));const S=[s,...C],$=await c.detectOverflow(t,w),j=[];let N=((o=a.flip)==null?void 0:o.overflows)||[];if(u&&j.push($[g]),h){const z=uqe(r,i,b);j.push($[z[0]],$[z[1]])}if(N=[...N,{placement:r,overflows:j}],!j.every(z=>z<=0)){var A,R;const z=(((A=a.flip)==null?void 0:A.index)||0)+1,V=S[z];if(V&&(!(h==="alignment"?M!==$r(V):!1)||N.every(P=>$r(P.placement)===M?P.overflows[0]>0:!0)))return{data:{index:z,overflows:N},reset:{placement:V}};let H=(R=N.filter(O=>O.overflows[0]<=0).sort((O,P)=>O.overflows[1]-P.overflows[1])[0])==null?void 0:R.placement;if(!H)switch(y){case"bestFit":{var Y;const O=(Y=N.filter(P=>{if(_){const I=$r(P.placement);return I===M||I==="y"}return!0}).map(P=>[P.placement,P.overflows.filter(I=>I>0).reduce((I,L)=>I+L,0)]).sort((P,I)=>P[1]-I[1])[0])==null?void 0:Y[0];O&&(H=O);break}case"initialPlacement":H=s;break}if(r!==H)return{reset:{placement:H}}}return{}}}};function XU(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function YU(e){return lqe.some(t=>e[t]>=0)}const bqe=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n,platform:o}=t,{strategy:r="referenceHidden",...a}=va(e,t);switch(r){case"referenceHidden":{const i=await o.detectOverflow(t,{...a,elementContext:"reference"}),s=XU(i,n.reference);return{data:{referenceHiddenOffsets:s,referenceHidden:YU(s)}}}case"escaped":{const i=await o.detectOverflow(t,{...a,altBoundary:!0}),s=XU(i,n.floating);return{data:{escapedOffsets:s,escaped:YU(s)}}}default:return{}}}}},gJ=new Set(["left","top"]);async function _qe(e,t){const{placement:n,platform:o,elements:r}=e,a=await(o.isRTL==null?void 0:o.isRTL(r.floating)),i=xa(n),s=P0(n),c=$r(n)==="y",l=gJ.has(i)?-1:1,u=a&&c?-1:1,h=va(t,e);let{mainAxis:f,crossAxis:y,alignmentAxis:k}=typeof h=="number"?{mainAxis:h,crossAxis:0,alignmentAxis:null}:{mainAxis:h.mainAxis||0,crossAxis:h.crossAxis||0,alignmentAxis:h.alignmentAxis};return s&&typeof k=="number"&&(y=s==="end"?k*-1:k),c?{x:y*u,y:f*l}:{x:f*l,y:y*u}}const Cqe=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 _qe(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}}}}},Sqe=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:x}=g;return{x:M,y:x}}},...l}=va(e,t),u={x:n,y:o},h=await a.detectOverflow(t,l),f=$r(xa(r)),y=SO(f);let k=u[y],v=u[f];if(i){const g=y==="y"?"top":"left",M=y==="y"?"bottom":"right",x=k+h[g],b=k-h[M];k=LH(x,k,b)}if(s){const g=f==="y"?"top":"left",M=f==="y"?"bottom":"right",x=v+h[g],b=v-h[M];v=LH(x,v,b)}const w=c.fn({...t,[y]:k,[f]:v});return{...w,data:{x:w.x-n,y:w.y-o,enabled:{[y]:i,[f]:s}}}}}},Lqe=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}=va(e,t),u={x:n,y:o},h=$r(r),f=SO(h);let y=u[f],k=u[h];const v=va(s,t),w=typeof v=="number"?{mainAxis:v,crossAxis:0}:{mainAxis:0,crossAxis:0,...v};if(c){const x=f==="y"?"height":"width",b=a.reference[f]-a.floating[x]+w.mainAxis,C=a.reference[f]+a.reference[x]-w.mainAxis;y<b?y=b:y>C&&(y=C)}if(l){var g,M;const x=f==="y"?"width":"height",b=gJ.has(xa(r)),C=a.reference[h]-a.floating[x]+(b&&((g=i.offset)==null?void 0:g[h])||0)+(b?0:w.crossAxis),_=a.reference[h]+a.reference[x]+(b?0:((M=i.offset)==null?void 0:M[h])||0)-(b?w.crossAxis:0);k<C?k=C:k>_&&(k=_)}return{[f]:y,[h]:k}}}},Nqe=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}=va(e,t),u=await i.detectOverflow(t,l),h=xa(r),f=P0(r),y=$r(r)==="y",{width:k,height:v}=a.floating;let w,g;h==="top"||h==="bottom"?(w=h,g=f===(await(i.isRTL==null?void 0:i.isRTL(s.floating))?"start":"end")?"left":"right"):(g=h,w=f==="end"?"top":"bottom");const M=v-u.top-u.bottom,x=k-u.left-u.right,b=Ni(v-u[w],M),C=Ni(k-u[g],x),_=!t.middlewareData.shift;let S=b,$=C;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&($=x),(o=t.middlewareData.shift)!=null&&o.enabled.y&&(S=M),_&&!f){const N=uo(u.left,0),A=uo(u.right,0),R=uo(u.top,0),Y=uo(u.bottom,0);y?$=k-2*(N!==0||A!==0?N+A:uo(u.left,u.right)):S=v-2*(R!==0||Y!==0?R+Y:uo(u.top,u.bottom))}await c({...t,availableWidth:$,availableHeight:S});const j=await i.getDimensions(s.floating);return k!==j.width||v!==j.height?{reset:{rects:!0}}:{}}}};function Yz(){return typeof window<"u"}function z0(e){return vJ(e)?(e.nodeName||"").toLowerCase():"#document"}function mo(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Br(e){var t;return(t=(vJ(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function vJ(e){return Yz()?e instanceof Node||e instanceof mo(e).Node:!1}function er(e){return Yz()?e instanceof Element||e instanceof mo(e).Element:!1}function Ca(e){return Yz()?e instanceof HTMLElement||e instanceof mo(e).HTMLElement:!1}function QU(e){return!Yz()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof mo(e).ShadowRoot}function yf(e){const{overflow:t,overflowX:n,overflowY:o,display:r}=tr(e);return/auto|scroll|overlay|hidden|clip/.test(t+o+n)&&r!=="inline"&&r!=="contents"}function Iqe(e){return/^(table|td|th)$/.test(z0(e))}function Qz(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}const Aqe=/transform|translate|scale|rotate|perspective|filter/,Eqe=/paint|layout|strict|content/,Yi=e=>!!e&&e!=="none";let xT;function IO(e){const t=er(e)?tr(e):e;return Yi(t.transform)||Yi(t.translate)||Yi(t.scale)||Yi(t.rotate)||Yi(t.perspective)||!AO()&&(Yi(t.backdropFilter)||Yi(t.filter))||Aqe.test(t.willChange||"")||Eqe.test(t.contain||"")}function $qe(e){let t=Ii(e);for(;Ca(t)&&!M0(t);){if(IO(t))return t;if(Qz(t))return null;t=Ii(t)}return null}function AO(){return xT==null&&(xT=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),xT}function M0(e){return/^(html|body|#document)$/.test(z0(e))}function tr(e){return mo(e).getComputedStyle(e)}function Jz(e){return er(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Ii(e){if(z0(e)==="html")return e;const t=e.assignedSlot||e.parentNode||QU(e)&&e.host||Br(e);return QU(t)?t.host:t}function xJ(e){const t=Ii(e);return M0(t)?e.ownerDocument?e.ownerDocument.body:e.body:Ca(t)&&yf(t)?t:xJ(t)}function Bh(e,t,n){var o;t===void 0&&(t=[]),n===void 0&&(n=!0);const r=xJ(e),a=r===((o=e.ownerDocument)==null?void 0:o.body),i=mo(r);if(a){const s=IH(i);return t.concat(i,i.visualViewport||[],yf(r)?r:[],s&&n?Bh(s):[])}else return t.concat(r,Bh(r,[],n))}function IH(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function wJ(e){const t=tr(e);let n=parseFloat(t.width)||0,o=parseFloat(t.height)||0;const r=Ca(e),a=r?e.offsetWidth:n,i=r?e.offsetHeight:o,s=tz(n)!==a||tz(o)!==i;return s&&(n=a,o=i),{width:n,height:o,$:s}}function EO(e){return er(e)?e:e.contextElement}function Ku(e){const t=EO(e);if(!Ca(t))return Dr(1);const n=t.getBoundingClientRect(),{width:o,height:r,$:a}=wJ(t);let i=(a?tz(n.width):n.width)/o,s=(a?tz(n.height):n.height)/r;return(!i||!Number.isFinite(i))&&(i=1),(!s||!Number.isFinite(s))&&(s=1),{x:i,y:s}}const jqe=Dr(0);function MJ(e){const t=mo(e);return!AO()||!t.visualViewport?jqe:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Pqe(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==mo(e)?!1:t}function Nd(e,t,n,o){t===void 0&&(t=!1),n===void 0&&(n=!1);const r=e.getBoundingClientRect(),a=EO(e);let i=Dr(1);t&&(o?er(o)&&(i=Ku(o)):i=Ku(e));const s=Pqe(a,n,o)?MJ(a):Dr(0);let c=(r.left+s.x)/i.x,l=(r.top+s.y)/i.y,u=r.width/i.x,h=r.height/i.y;if(a){const f=mo(a),y=o&&er(o)?mo(o):o;let k=f,v=IH(k);for(;v&&o&&y!==k;){const w=Ku(v),g=v.getBoundingClientRect(),M=tr(v),x=g.left+(v.clientLeft+parseFloat(M.paddingLeft))*w.x,b=g.top+(v.clientTop+parseFloat(M.paddingTop))*w.y;c*=w.x,l*=w.y,u*=w.x,h*=w.y,c+=x,l+=b,k=mo(v),v=IH(k)}}return oz({width:u,height:h,x:c,y:l})}function eR(e,t){const n=Jz(e).scrollLeft;return t?t.left+n:Nd(Br(e)).left+n}function bJ(e,t){const n=e.getBoundingClientRect(),o=n.left+t.scrollLeft-eR(e,n),r=n.top+t.scrollTop;return{x:o,y:r}}function zqe(e){let{elements:t,rect:n,offsetParent:o,strategy:r}=e;const a=r==="fixed",i=Br(o),s=t?Qz(t.floating):!1;if(o===i||s&&a)return n;let c={scrollLeft:0,scrollTop:0},l=Dr(1);const u=Dr(0),h=Ca(o);if((h||!h&&!a)&&((z0(o)!=="body"||yf(i))&&(c=Jz(o)),h)){const y=Nd(o);l=Ku(o),u.x=y.x+o.clientLeft,u.y=y.y+o.clientTop}const f=i&&!h&&!a?bJ(i,c):Dr(0);return{width:n.width*l.x,height:n.height*l.y,x:n.x*l.x-c.scrollLeft*l.x+u.x+f.x,y:n.y*l.y-c.scrollTop*l.y+u.y+f.y}}function Rqe(e){return Array.from(e.getClientRects())}function Tqe(e){const t=Br(e),n=Jz(e),o=e.ownerDocument.body,r=uo(t.scrollWidth,t.clientWidth,o.scrollWidth,o.clientWidth),a=uo(t.scrollHeight,t.clientHeight,o.scrollHeight,o.clientHeight);let i=-n.scrollLeft+eR(e);const s=-n.scrollTop;return tr(o).direction==="rtl"&&(i+=uo(t.clientWidth,o.clientWidth)-r),{width:r,height:a,x:i,y:s}}const JU=25;function Dqe(e,t){const n=mo(e),o=Br(e),r=n.visualViewport;let a=o.clientWidth,i=o.clientHeight,s=0,c=0;if(r){a=r.width,i=r.height;const u=AO();(!u||u&&t==="fixed")&&(s=r.offsetLeft,c=r.offsetTop)}const l=eR(o);if(l<=0){const u=o.ownerDocument,h=u.body,f=getComputedStyle(h),y=u.compatMode==="CSS1Compat"&&parseFloat(f.marginLeft)+parseFloat(f.marginRight)||0,k=Math.abs(o.clientWidth-h.clientWidth-y);k<=JU&&(a-=k)}else l<=JU&&(a+=l);return{width:a,height:i,x:s,y:c}}function Hqe(e,t){const n=Nd(e,!0,t==="fixed"),o=n.top+e.clientTop,r=n.left+e.clientLeft,a=Ca(e)?Ku(e):Dr(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 eW(e,t,n){let o;if(t==="viewport")o=Dqe(e,n);else if(t==="document")o=Tqe(Br(e));else if(er(t))o=Hqe(t,n);else{const r=MJ(e);o={x:t.x-r.x,y:t.y-r.y,width:t.width,height:t.height}}return oz(o)}function _J(e,t){const n=Ii(e);return n===t||!er(n)||M0(n)?!1:tr(n).position==="fixed"||_J(n,t)}function qqe(e,t){const n=t.get(e);if(n)return n;let o=Bh(e,[],!1).filter(s=>er(s)&&z0(s)!=="body"),r=null;const a=tr(e).position==="fixed";let i=a?Ii(e):e;for(;er(i)&&!M0(i);){const s=tr(i),c=IO(i);!c&&s.position==="fixed"&&(r=null),(a?!c&&!r:!c&&s.position==="static"&&!!r&&(r.position==="absolute"||r.position==="fixed")||yf(i)&&!c&&_J(e,i))?o=o.filter(u=>u!==i):r=s,i=Ii(i)}return t.set(e,o),o}function Oqe(e){let{element:t,boundary:n,rootBoundary:o,strategy:r}=e;const i=[...n==="clippingAncestors"?Qz(t)?[]:qqe(t,this._c):[].concat(n),o],s=eW(t,i[0],r);let c=s.top,l=s.right,u=s.bottom,h=s.left;for(let f=1;f<i.length;f++){const y=eW(t,i[f],r);c=uo(y.top,c),l=Ni(y.right,l),u=Ni(y.bottom,u),h=uo(y.left,h)}return{width:l-h,height:u-c,x:h,y:c}}function Fqe(e){const{width:t,height:n}=wJ(e);return{width:t,height:n}}function Vqe(e,t,n){const o=Ca(t),r=Br(t),a=n==="fixed",i=Nd(e,!0,a,t);let s={scrollLeft:0,scrollTop:0};const c=Dr(0);function l(){c.x=eR(r)}if(o||!o&&!a)if((z0(t)!=="body"||yf(r))&&(s=Jz(t)),o){const y=Nd(t,!0,a,t);c.x=y.x+t.clientLeft,c.y=y.y+t.clientTop}else r&&l();a&&!o&&r&&l();const u=r&&!o&&!a?bJ(r,s):Dr(0),h=i.left+s.scrollLeft-c.x-u.x,f=i.top+s.scrollTop-c.y-u.y;return{x:h,y:f,width:i.width,height:i.height}}function wT(e){return tr(e).position==="static"}function tW(e,t){if(!Ca(e)||tr(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return Br(e)===n&&(n=n.ownerDocument.body),n}function CJ(e,t){const n=mo(e);if(Qz(e))return n;if(!Ca(e)){let r=Ii(e);for(;r&&!M0(r);){if(er(r)&&!wT(r))return r;r=Ii(r)}return n}let o=tW(e,t);for(;o&&Iqe(o)&&wT(o);)o=tW(o,t);return o&&M0(o)&&wT(o)&&!IO(o)?n:o||$qe(e)||n}const Bqe=async function(e){const t=this.getOffsetParent||CJ,n=this.getDimensions,o=await n(e.floating);return{reference:Vqe(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:o.width,height:o.height}}};function Uqe(e){return tr(e).direction==="rtl"}const Wqe={convertOffsetParentRelativeRectToViewportRelativeRect:zqe,getDocumentElement:Br,getClippingRect:Oqe,getOffsetParent:CJ,getElementRects:Bqe,getClientRects:Rqe,getDimensions:Fqe,getScale:Ku,isElement:er,isRTL:Uqe};function SJ(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=Br(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:u,top:h,width:f,height:y}=l;if(s||t(),!f||!y)return;const k=kp(h),v=kp(r.clientWidth-(u+f)),w=kp(r.clientHeight-(h+y)),g=kp(u),x={rootMargin:-k+"px "+-v+"px "+-w+"px "+-g+"px",threshold:uo(0,Ni(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&&!SJ(l,e.getBoundingClientRect())&&i(),b=!1}try{n=new IntersectionObserver(C,{...x,root:r.ownerDocument})}catch{n=new IntersectionObserver(C,x)}n.observe(e)}return i(!0),a}function Kqe(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=EO(e),u=r||a?[...l?Bh(l):[],...t?Bh(t):[]]:[];u.forEach(g=>{r&&g.addEventListener("scroll",n,{passive:!0}),a&&g.addEventListener("resize",n)});const h=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 x;(x=y)==null||x.observe(t)})),n()}),l&&!c&&y.observe(l),t&&y.observe(t));let k,v=c?Nd(e):null;c&&w();function w(){const g=Nd(e);v&&!SJ(v,g)&&n(),v=g,k=requestAnimationFrame(w)}return n(),()=>{var g;u.forEach(M=>{r&&M.removeEventListener("scroll",n),a&&M.removeEventListener("resize",n)}),h==null||h(),(g=y)==null||g.disconnect(),y=null,c&&cancelAnimationFrame(k)}}const Zqe=Cqe,Xqe=Sqe,Yqe=Mqe,Qqe=Nqe,Jqe=bqe,nW=wqe,eOe=Lqe,tOe=(e,t,n)=>{const o=new Map,r={platform:Wqe,...n},a={...r.platform,_c:o};return xqe(e,t,{...r,platform:a})};var nOe=typeof document<"u",oOe=function(){},rP=nOe?m.useLayoutEffect:oOe;function rz(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(!rz(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)&&!rz(e[a],t[a]))return!1}return!0}return e!==e&&t!==t}function LJ(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function oW(e,t){const n=LJ(e);return Math.round(t*n)/n}function MT(e){const t=m.useRef(e);return rP(()=>{t.current=e}),t}function rOe(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,[u,h]=m.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[f,y]=m.useState(o);rz(f,o)||y(o);const[k,v]=m.useState(null),[w,g]=m.useState(null),M=m.useCallback(P=>{P!==_.current&&(_.current=P,v(P))},[]),x=m.useCallback(P=>{P!==S.current&&(S.current=P,g(P))},[]),b=a||k,C=i||w,_=m.useRef(null),S=m.useRef(null),$=m.useRef(u),j=c!=null,N=MT(c),A=MT(r),R=MT(l),Y=m.useCallback(()=>{if(!_.current||!S.current)return;const P={placement:t,strategy:n,middleware:f};A.current&&(P.platform=A.current),tOe(_.current,S.current,P).then(I=>{const L={...I,isPositioned:R.current!==!1};z.current&&!rz($.current,L)&&($.current=L,I0.flushSync(()=>{h(L)}))})},[f,t,n,A,R]);rP(()=>{l===!1&&$.current.isPositioned&&($.current.isPositioned=!1,h(P=>({...P,isPositioned:!1})))},[l]);const z=m.useRef(!1);rP(()=>(z.current=!0,()=>{z.current=!1}),[]),rP(()=>{if(b&&(_.current=b),C&&(S.current=C),b&&C){if(N.current)return N.current(b,C,Y);Y()}},[b,C,Y,N,j]);const V=m.useMemo(()=>({reference:_,floating:S,setReference:M,setFloating:x}),[M,x]),H=m.useMemo(()=>({reference:b,floating:C}),[b,C]),O=m.useMemo(()=>{const P={position:n,left:0,top:0};if(!H.floating)return P;const I=oW(H.floating,u.x),L=oW(H.floating,u.y);return s?{...P,transform:"translate("+I+"px, "+L+"px)",...LJ(H.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:I,top:L}},[n,s,H.floating,u.x,u.y]);return m.useMemo(()=>({...u,update:Y,refs:V,elements:H,floatingStyles:O}),[u,Y,V,H,O])}const aOe=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?nW({element:o.current,padding:r}).fn(n):{}:o?nW({element:o,padding:r}).fn(n):{}}}},iOe=(e,t)=>{const n=Zqe(e);return{name:n.name,fn:n.fn,options:[e,t]}},sOe=(e,t)=>{const n=Xqe(e);return{name:n.name,fn:n.fn,options:[e,t]}},cOe=(e,t)=>({fn:eOe(e).fn,options:[e,t]}),lOe=(e,t)=>{const n=Yqe(e);return{name:n.name,fn:n.fn,options:[e,t]}},dOe=(e,t)=>{const n=Qqe(e);return{name:n.name,fn:n.fn,options:[e,t]}},uOe=(e,t)=>{const n=Jqe(e);return{name:n.name,fn:n.fn,options:[e,t]}},hOe=(e,t)=>{const n=aOe(e);return{name:n.name,fn:n.fn,options:[e,t]}};var fOe="Arrow",NJ=m.forwardRef((e,t)=>{const{children:n,width:o=10,height:r=5,...a}=e;return p.jsx(Ue.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"})})});NJ.displayName=fOe;var pOe=NJ,$O="Popper",[IJ,R0]=or($O),[yOe,AJ]=IJ($O),EJ=e=>{const{__scopePopper:t,children:n}=e,[o,r]=m.useState(null);return p.jsx(yOe,{scope:t,anchor:o,onAnchorChange:r,children:n})};EJ.displayName=$O;var $J="PopperAnchor",jJ=m.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:o,...r}=e,a=AJ($J,n),i=m.useRef(null),s=gt(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(Ue.div,{...r,ref:s})});jJ.displayName=$J;var jO="PopperContent",[mOe,kOe]=IJ(jO),PJ=m.forwardRef((e,t)=>{var oe,te,ce,ge,ae,se;const{__scopePopper:n,side:o="bottom",sideOffset:r=0,align:a="center",alignOffset:i=0,arrowPadding:s=0,avoidCollisions:c=!0,collisionBoundary:l=[],collisionPadding:u=0,sticky:h="partial",hideWhenDetached:f=!1,updatePositionStrategy:y="optimized",onPlaced:k,...v}=e,w=AJ(jO,n),[g,M]=m.useState(null),x=gt(t,re=>M(re)),[b,C]=m.useState(null),_=WQ(b),S=(_==null?void 0:_.width)??0,$=(_==null?void 0:_.height)??0,j=o+(a!=="center"?"-"+a:""),N=typeof u=="number"?u:{top:0,right:0,bottom:0,left:0,...u},A=Array.isArray(l)?l:[l],R=A.length>0,Y={padding:N,boundary:A.filter(vOe),altBoundary:R},{refs:z,floatingStyles:V,placement:H,isPositioned:O,middlewareData:P}=rOe({strategy:"fixed",placement:j,whileElementsMounted:(...re)=>Kqe(...re,{animationFrame:y==="always"}),elements:{reference:w.anchor},middleware:[iOe({mainAxis:r+$,alignmentAxis:i}),c&&sOe({mainAxis:!0,crossAxis:!1,limiter:h==="partial"?cOe():void 0,...Y}),c&&lOe({...Y}),dOe({...Y,apply:({elements:re,rects:Pe,availableWidth:Be,availableHeight:Ve})=>{const{width:ht,height:Gt}=Pe.reference,Et=re.floating.style;Et.setProperty("--radix-popper-available-width",`${Be}px`),Et.setProperty("--radix-popper-available-height",`${Ve}px`),Et.setProperty("--radix-popper-anchor-width",`${ht}px`),Et.setProperty("--radix-popper-anchor-height",`${Gt}px`)}}),b&&hOe({element:b,padding:s}),xOe({arrowWidth:S,arrowHeight:$}),f&&uOe({strategy:"referenceHidden",...Y})]}),[I,L]=TJ(H),U=Fr(k);Li(()=>{O&&(U==null||U())},[O,U]);const D=(oe=P.arrow)==null?void 0:oe.x,E=(te=P.arrow)==null?void 0:te.y,ee=((ce=P.arrow)==null?void 0:ce.centerOffset)!==0,[J,ne]=m.useState();return Li(()=>{g&&ne(window.getComputedStyle(g).zIndex)},[g]),p.jsx("div",{ref:z.setFloating,"data-radix-popper-content-wrapper":"",style:{...V,transform:O?V.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:J,"--radix-popper-transform-origin":[(ge=P.transformOrigin)==null?void 0:ge.x,(ae=P.transformOrigin)==null?void 0:ae.y].join(" "),...((se=P.hide)==null?void 0:se.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:p.jsx(mOe,{scope:n,placedSide:I,onArrowChange:C,arrowX:D,arrowY:E,shouldHideArrow:ee,children:p.jsx(Ue.div,{"data-side":I,"data-align":L,...v,ref:x,style:{...v.style,animation:O?void 0:"none"}})})})});PJ.displayName=jO;var zJ="PopperArrow",gOe={top:"bottom",right:"left",bottom:"top",left:"right"},RJ=m.forwardRef(function(t,n){const{__scopePopper:o,...r}=t,a=kOe(zJ,o),i=gOe[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(pOe,{...r,ref:n,style:{...r.style,display:"block"}})})});RJ.displayName=zJ;function vOe(e){return e!==null}var xOe=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,u]=TJ(n),h={start:"0%",center:"50%",end:"100%"}[u],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="",v="";return l==="bottom"?(k=i?h:`${f}px`,v=`${-c}px`):l==="top"?(k=i?h:`${f}px`,v=`${o.floating.height+c}px`):l==="right"?(k=`${-c}px`,v=i?h:`${y}px`):l==="left"&&(k=`${o.floating.width+c}px`,v=i?h:`${y}px`),{data:{x:k,y:v}}}});function TJ(e){const[t,n="center"]=e.split("-");return[t,n]}var PO=EJ,tR=jJ,zO=PJ,RO=RJ,wOe="Portal",mf=m.forwardRef((e,t)=>{var s;const{container:n,...o}=e,[r,a]=m.useState(!1);Li(()=>a(!0),[]);const i=n||r&&((s=globalThis==null?void 0:globalThis.document)==null?void 0:s.body);return i?$se.createPortal(p.jsx(Ue.div,{...o,ref:t}),i):null});mf.displayName=wOe;function MOe(e,t){return m.useReducer((n,o)=>t[n][o]??n,e)}var Mo=e=>{const{present:t,children:n}=e,o=bOe(t),r=typeof n=="function"?n({present:o.isPresent}):m.Children.only(n),a=gt(o.ref,_Oe(r));return typeof n=="function"||o.isPresent?m.cloneElement(r,{ref:a}):null};Mo.displayName="Presence";function bOe(e){const[t,n]=m.useState(),o=m.useRef(null),r=m.useRef(e),a=m.useRef("none"),i=e?"mounted":"unmounted",[s,c]=MOe(i,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return m.useEffect(()=>{const l=gp(o.current);a.current=s==="mounted"?l:"none"},[s]),Li(()=>{const l=o.current,u=r.current;if(u!==e){const f=a.current,y=gp(l);e?c("MOUNT"):y==="none"||(l==null?void 0:l.display)==="none"?c("UNMOUNT"):c(u&&f!==y?"ANIMATION_OUT":"UNMOUNT"),r.current=e}},[e,c]),Li(()=>{if(t){let l;const u=t.ownerDocument.defaultView??window,h=y=>{const v=gp(o.current).includes(CSS.escape(y.animationName));if(y.target===t&&v&&(c("ANIMATION_END"),!r.current)){const w=t.style.animationFillMode;t.style.animationFillMode="forwards",l=u.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=w)})}},f=y=>{y.target===t&&(a.current=gp(o.current))};return t.addEventListener("animationstart",f),t.addEventListener("animationcancel",h),t.addEventListener("animationend",h),()=>{u.clearTimeout(l),t.removeEventListener("animationstart",f),t.removeEventListener("animationcancel",h),t.removeEventListener("animationend",h)}}else c("ANIMATION_END")},[t,c]),{isPresent:["mounted","unmountSuspended"].includes(s),ref:m.useCallback(l=>{o.current=l?getComputedStyle(l):null,n(l)},[])}}function gp(e){return(e==null?void 0:e.animationName)||"none"}function _Oe(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 COe=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},iu=new WeakMap,vp=new WeakMap,xp={},bT=0,DJ=function(e){return e&&(e.host||DJ(e.parentNode))},SOe=function(e,t){return t.map(function(n){if(e.contains(n))return n;var o=DJ(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})},LOe=function(e,t,n,o){var r=SOe(t,Array.isArray(e)?e:[e]);xp[n]||(xp[n]=new WeakMap);var a=xp[n],i=[],s=new Set,c=new Set(r),l=function(h){!h||s.has(h)||(s.add(h),l(h.parentNode))};r.forEach(l);var u=function(h){!h||c.has(h)||Array.prototype.forEach.call(h.children,function(f){if(s.has(f))u(f);else try{var y=f.getAttribute(o),k=y!==null&&y!=="false",v=(iu.get(f)||0)+1,w=(a.get(f)||0)+1;iu.set(f,v),a.set(f,w),i.push(f),v===1&&k&&vp.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 u(t),s.clear(),bT++,function(){i.forEach(function(h){var f=iu.get(h)-1,y=a.get(h)-1;iu.set(h,f),a.set(h,y),f||(vp.has(h)||h.removeAttribute(o),vp.delete(h)),y||h.removeAttribute(n)}),bT--,bT||(iu=new WeakMap,iu=new WeakMap,vp=new WeakMap,xp={})}},TO=function(e,t,n){n===void 0&&(n="data-aria-hidden");var o=Array.from(Array.isArray(e)?e:[e]),r=COe(e);return r?(o.push.apply(o,Array.from(r.querySelectorAll("[aria-live], script"))),LOe(o,r,n,"aria-hidden")):function(){return null}},Er=function(){return Er=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},Er.apply(this,arguments)};function HJ(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 NOe(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 aP="right-scroll-bar-position",iP="width-before-scroll-bar",IOe="with-scroll-bars-hidden",AOe="--removed-body-scroll-bar-size";function _T(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function EOe(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 $Oe=typeof window<"u"?m.useLayoutEffect:m.useEffect,rW=new WeakMap;function jOe(e,t){var n=EOe(null,function(o){return e.forEach(function(r){return _T(r,o)})});return $Oe(function(){var o=rW.get(n);if(o){var r=new Set(o),a=new Set(e),i=n.current;r.forEach(function(s){a.has(s)||_T(s,null)}),a.forEach(function(s){r.has(s)||_T(s,i)})}rW.set(n,e)},[e]),n}function POe(e){return e}function zOe(e,t){t===void 0&&(t=POe);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 u=i;i=[],u.forEach(a)},l=function(){return Promise.resolve().then(c)};l(),n={push:function(u){i.push(u),l()},filter:function(u){return i=i.filter(u),n}}}};return r}function ROe(e){e===void 0&&(e={});var t=zOe(null);return t.options=Er({async:!0,ssr:!1},e),t}var qJ=function(e){var t=e.sideCar,n=HJ(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,Er({},n))};qJ.isSideCarExport=!0;function TOe(e,t){return e.useMedium(t),qJ}var OJ=ROe(),CT=function(){},nR=m.forwardRef(function(e,t){var n=m.useRef(null),o=m.useState({onScrollCapture:CT,onWheelCapture:CT,onTouchMoveCapture:CT}),r=o[0],a=o[1],i=e.forwardProps,s=e.children,c=e.className,l=e.removeScrollBar,u=e.enabled,h=e.shards,f=e.sideCar,y=e.noRelative,k=e.noIsolation,v=e.inert,w=e.allowPinchZoom,g=e.as,M=g===void 0?"div":g,x=e.gapMode,b=HJ(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),C=f,_=jOe([n,t]),S=Er(Er({},b),r);return m.createElement(m.Fragment,null,u&&m.createElement(C,{sideCar:OJ,removeScrollBar:l,shards:h,noRelative:y,noIsolation:k,inert:v,setCallbacks:a,allowPinchZoom:!!w,lockRef:n,gapMode:x}),i?m.cloneElement(m.Children.only(s),Er(Er({},S),{ref:_})):m.createElement(M,Er({},S,{className:c,ref:_}),s))});nR.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};nR.classNames={fullWidth:iP,zeroRight:aP};var DOe=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function HOe(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=DOe();return t&&e.setAttribute("nonce",t),e}function qOe(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function OOe(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=HOe())&&(qOe(t,n),OOe(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},VOe=function(){var e=FOe();return function(t,n){m.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},FJ=function(){var e=VOe(),t=function(n){var o=n.styles,r=n.dynamic;return e(o,r),null};return t},BOe={left:0,top:0,right:0,gap:0},ST=function(e){return parseInt(e||"",10)||0},UOe=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[ST(n),ST(o),ST(r)]},WOe=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return BOe;var t=UOe(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=FJ(),Zu="data-scroll-locked",KOe=function(e,t,n,o){var r=e.left,a=e.top,i=e.right,s=e.gap;return n===void 0&&(n="margin"),`
|
|
8470
8470
|
.`.concat(IOe,` {
|
|
8471
8471
|
overflow: hidden `).concat(o,`;
|
|
8472
8472
|
padding-right: `).concat(s,"px ").concat(o,`;
|
|
@@ -8538,10 +8538,10 @@ For more information, see https://radix-ui.com/primitives/docs/components/${t.do
|
|
|
8538
8538
|
`))+1))}const i="#".repeat(r),s=n.enter("headingAtx"),c=n.enter("phrasing");a.move(i+" ");let l=n.containerPhrasing(e,{before:"# ",after:`
|
|
8539
8539
|
`,...a.current()});return/^[\t ]/.test(l)&&(l=Yh(l.charCodeAt(0))+l.slice(1)),l=l?i+" "+l:i,n.options.closeAtx&&(l+=" "+i),c(),s(),l}Coe.peek=nQe;function Coe(e){return e.value||""}function nQe(){return"<"}Soe.peek=oQe;function Soe(e,t,n,o){const r=CF(n),a=r==='"'?"Quote":"Apostrophe",i=n.enter("image");let s=n.enter("label");const c=n.createTracker(o);let l=c.move("![");return l+=c.move(n.safe(e.alt,{before:l,after:"]",...c.current()})),l+=c.move("]("),s(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(s=n.enter("destinationLiteral"),l+=c.move("<"),l+=c.move(n.safe(e.url,{before:l,after:">",...c.current()})),l+=c.move(">")):(s=n.enter("destinationRaw"),l+=c.move(n.safe(e.url,{before:l,after:e.title?" ":")",...c.current()}))),s(),e.title&&(s=n.enter(`title${a}`),l+=c.move(" "+r),l+=c.move(n.safe(e.title,{before:l,after:r,...c.current()})),l+=c.move(r),s()),l+=c.move(")"),i(),l}function oQe(){return"!"}Loe.peek=rQe;function Loe(e,t,n,o){const r=e.referenceType,a=n.enter("imageReference");let i=n.enter("label");const s=n.createTracker(o);let c=s.move("![");const l=n.safe(e.alt,{before:c,after:"]",...s.current()});c+=s.move(l+"]["),i();const u=n.stack;n.stack=[],i=n.enter("reference");const h=n.safe(n.associationId(e),{before:c,after:"]",...s.current()});return i(),n.stack=u,a(),r==="full"||!l||l!==h?c+=s.move(h+"]"):r==="shortcut"?c=c.slice(0,-1):c+=s.move("]"),c}function rQe(){return"!"}Noe.peek=aQe;function Noe(e,t,n){let o=e.value||"",r="`",a=-1;for(;new RegExp("(^|[^`])"+r+"([^`]|$)").test(o);)r+="`";for(/[^ \r\n]/.test(o)&&(/^[ \r\n]/.test(o)&&/[ \r\n]$/.test(o)||/^`|`$/.test(o))&&(o=" "+o+" ");++a<n.unsafe.length;){const i=n.unsafe[a],s=n.compilePattern(i);let c;if(i.atBreak)for(;c=s.exec(o);){let l=c.index;o.charCodeAt(l)===10&&o.charCodeAt(l-1)===13&&l--,o=o.slice(0,l)+" "+o.slice(c.index+1)}}return r+o+r}function aQe(){return"`"}function Ioe(e,t){const n=mF(e);return!!(!t.options.resourceLink&&e.url&&!e.title&&e.children&&e.children.length===1&&e.children[0].type==="text"&&(n===e.url||"mailto:"+n===e.url)&&/^[a-z][a-z+.-]+:/i.test(e.url)&&!/[\0- <>\u007F]/.test(e.url))}Aoe.peek=iQe;function Aoe(e,t,n,o){const r=CF(n),a=r==='"'?"Quote":"Apostrophe",i=n.createTracker(o);let s,c;if(Ioe(e,n)){const u=n.stack;n.stack=[],s=n.enter("autolink");let h=i.move("<");return h+=i.move(n.containerPhrasing(e,{before:h,after:">",...i.current()})),h+=i.move(">"),s(),n.stack=u,h}s=n.enter("link"),c=n.enter("label");let l=i.move("[");return l+=i.move(n.containerPhrasing(e,{before:l,after:"](",...i.current()})),l+=i.move("]("),c(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(c=n.enter("destinationLiteral"),l+=i.move("<"),l+=i.move(n.safe(e.url,{before:l,after:">",...i.current()})),l+=i.move(">")):(c=n.enter("destinationRaw"),l+=i.move(n.safe(e.url,{before:l,after:e.title?" ":")",...i.current()}))),c(),e.title&&(c=n.enter(`title${a}`),l+=i.move(" "+r),l+=i.move(n.safe(e.title,{before:l,after:r,...i.current()})),l+=i.move(r),c()),l+=i.move(")"),s(),l}function iQe(e,t,n){return Ioe(e,n)?"<":"["}Eoe.peek=sQe;function Eoe(e,t,n,o){const r=e.referenceType,a=n.enter("linkReference");let i=n.enter("label");const s=n.createTracker(o);let c=s.move("[");const l=n.containerPhrasing(e,{before:c,after:"]",...s.current()});c+=s.move(l+"]["),i();const u=n.stack;n.stack=[],i=n.enter("reference");const h=n.safe(n.associationId(e),{before:c,after:"]",...s.current()});return i(),n.stack=u,a(),r==="full"||!l||l!==h?c+=s.move(h+"]"):r==="shortcut"?c=c.slice(0,-1):c+=s.move("]"),c}function sQe(){return"["}function SF(e){const t=e.options.bullet||"*";if(t!=="*"&&t!=="+"&&t!=="-")throw new Error("Cannot serialize items with `"+t+"` for `options.bullet`, expected `*`, `+`, or `-`");return t}function cQe(e){const t=SF(e),n=e.options.bulletOther;if(!n)return t==="*"?"-":"*";if(n!=="*"&&n!=="+"&&n!=="-")throw new Error("Cannot serialize items with `"+n+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(n===t)throw new Error("Expected `bullet` (`"+t+"`) and `bulletOther` (`"+n+"`) to be different");return n}function lQe(e){const t=e.options.bulletOrdered||".";if(t!=="."&&t!==")")throw new Error("Cannot serialize items with `"+t+"` for `options.bulletOrdered`, expected `.` or `)`");return t}function $oe(e){const t=e.options.rule||"*";if(t!=="*"&&t!=="-"&&t!=="_")throw new Error("Cannot serialize rules with `"+t+"` for `options.rule`, expected `*`, `-`, or `_`");return t}function dQe(e,t,n,o){const r=n.enter("list"),a=n.bulletCurrent;let i=e.ordered?lQe(n):SF(n);const s=e.ordered?i==="."?")":".":cQe(n);let c=t&&n.bulletLastUsed?i===n.bulletLastUsed:!1;if(!e.ordered){const u=e.children?e.children[0]:void 0;if((i==="*"||i==="-")&&u&&(!u.children||!u.children[0])&&n.stack[n.stack.length-1]==="list"&&n.stack[n.stack.length-2]==="listItem"&&n.stack[n.stack.length-3]==="list"&&n.stack[n.stack.length-4]==="listItem"&&n.indexStack[n.indexStack.length-1]===0&&n.indexStack[n.indexStack.length-2]===0&&n.indexStack[n.indexStack.length-3]===0&&(c=!0),$oe(n)===i&&u){let h=-1;for(;++h<e.children.length;){const f=e.children[h];if(f&&f.type==="listItem"&&f.children&&f.children[0]&&f.children[0].type==="thematicBreak"){c=!0;break}}}}c&&(i=s),n.bulletCurrent=i;const l=n.containerFlow(e,o);return n.bulletLastUsed=i,n.bulletCurrent=a,r(),l}function uQe(e){const t=e.options.listItemIndent||"one";if(t!=="tab"&&t!=="one"&&t!=="mixed")throw new Error("Cannot serialize items with `"+t+"` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`");return t}function hQe(e,t,n,o){const r=uQe(n);let a=n.bulletCurrent||SF(n);t&&t.type==="list"&&t.ordered&&(a=(typeof t.start=="number"&&t.start>-1?t.start:1)+(n.options.incrementListMarker===!1?0:t.children.indexOf(e))+a);let i=a.length+1;(r==="tab"||r==="mixed"&&(t&&t.type==="list"&&t.spread||e.spread))&&(i=Math.ceil(i/4)*4);const s=n.createTracker(o);s.move(a+" ".repeat(i-a.length)),s.shift(i);const c=n.enter("listItem"),l=n.indentLines(n.containerFlow(e,s.current()),u);return c(),l;function u(h,f,y){return f?(y?"":" ".repeat(i))+h:(y?a:a+" ".repeat(i-a.length))+h}}function fQe(e,t,n,o){const r=n.enter("paragraph"),a=n.enter("phrasing"),i=n.containerPhrasing(e,o);return a(),r(),i}const pQe=bR(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function yQe(e,t,n,o){return(e.children.some(function(i){return pQe(i)})?n.containerPhrasing:n.containerFlow).call(n,e,o)}function mQe(e){const t=e.options.strong||"*";if(t!=="*"&&t!=="_")throw new Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}joe.peek=kQe;function joe(e,t,n,o){const r=mQe(n),a=n.enter("strong"),i=n.createTracker(o),s=i.move(r+r);let c=i.move(n.containerPhrasing(e,{after:r,before:s,...i.current()}));const l=c.charCodeAt(0),u=fz(o.before.charCodeAt(o.before.length-1),l,r);u.inside&&(c=Yh(l)+c.slice(1));const h=c.charCodeAt(c.length-1),f=fz(o.after.charCodeAt(0),h,r);f.inside&&(c=c.slice(0,-1)+Yh(h));const y=i.move(r+r);return a(),n.attentionEncodeSurroundingInfo={after:f.outside,before:u.outside},s+c+y}function kQe(e,t,n){return n.options.strong||"*"}function gQe(e,t,n,o){return n.safe(e.value,o)}function vQe(e){const t=e.options.ruleRepetition||3;if(t<3)throw new Error("Cannot serialize rules with repetition `"+t+"` for `options.ruleRepetition`, expected `3` or more");return t}function xQe(e,t,n){const o=($oe(n)+(n.options.ruleSpaces?" ":"")).repeat(vQe(n));return n.options.ruleSpaces?o.slice(0,-1):o}const Poe={blockquote:VYe,break:gG,code:ZYe,definition:YYe,emphasis:_oe,hardBreak:gG,heading:tQe,html:Coe,image:Soe,imageReference:Loe,inlineCode:Noe,link:Aoe,linkReference:Eoe,list:dQe,listItem:hQe,paragraph:fQe,root:yQe,strong:joe,text:gQe,thematicBreak:xQe};function wQe(){return{enter:{table:MQe,tableData:vG,tableHeader:vG,tableRow:_Qe},exit:{codeText:CQe,table:bQe,tableData:GT,tableHeader:GT,tableRow:GT}}}function MQe(e){const t=e._align;this.enter({type:"table",align:t.map(function(n){return n==="none"?null:n}),children:[]},e),this.data.inTable=!0}function bQe(e){this.exit(e),this.data.inTable=void 0}function _Qe(e){this.enter({type:"tableRow",children:[]},e)}function GT(e){this.exit(e)}function vG(e){this.enter({type:"tableCell",children:[]},e)}function CQe(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,SQe));const n=this.stack[this.stack.length-1];n.type,n.value=t,this.exit(e)}function SQe(e,t){return t==="|"?t:e}function LQe(e){const t=e||{},n=t.tableCellPadding,o=t.tablePipeAlign,r=t.stringLength,a=n?" ":"|";return{unsafe:[{character:"\r",inConstruct:"tableCell"},{character:`
|
|
8540
8540
|
`,inConstruct:"tableCell"},{atBreak:!0,character:"|",after:"[ :-]"},{character:"|",inConstruct:"tableCell"},{atBreak:!0,character:":",after:"-"},{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{inlineCode:f,table:i,tableCell:c,tableRow:s}};function i(y,k,v,w){return l(u(y,v,w),y.align)}function s(y,k,v,w){const g=h(y,v,w),M=l([g]);return M.slice(0,M.indexOf(`
|
|
8541
|
-
`))}function c(y,k,v,w){const g=v.enter("tableCell"),M=v.enter("phrasing"),x=v.containerPhrasing(y,{...w,before:a,after:a});return M(),g(),x}function l(y,k){return OYe(y,{align:k,alignDelimiters:o,padding:n,stringLength:r})}function u(y,k,v){const w=y.children;let g=-1;const M=[],x=k.enter("table");for(;++g<w.length;)M[g]=h(w[g],k,v);return x(),M}function h(y,k,v){const w=y.children;let g=-1;const M=[],x=k.enter("tableRow");for(;++g<w.length;)M[g]=c(w[g],y,k,v);return x(),M}function f(y,k,v){let w=Poe.inlineCode(y,k,v);return v.stack.includes("tableCell")&&(w=w.replace(/\|/g,"\\$&")),w}}function NQe(){return{exit:{taskListCheckValueChecked:xG,taskListCheckValueUnchecked:xG,paragraph:AQe}}}function IQe(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:EQe}}}function xG(e){const t=this.stack[this.stack.length-2];t.type,t.checked=e.type==="taskListCheckValueChecked"}function AQe(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 EQe(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=Poe.listItem(e,t,n,{...o,...s.current()});return a&&(c=c.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,l)),c;function l(u){return u+i}}function $Qe(){return[dYe(),EYe(),zYe(),wQe(),NQe()]}function jQe(e){return{extensions:[uYe(),$Ye(e),RYe(),LQe(e),IQe()]}}const PQe={tokenize:qQe,partial:!0},zoe={tokenize:OQe,partial:!0},Roe={tokenize:FQe,partial:!0},Toe={tokenize:VQe,partial:!0},zQe={tokenize:BQe,partial:!0},Doe={name:"wwwAutolink",tokenize:DQe,previous:qoe},Hoe={name:"protocolAutolink",tokenize:HQe,previous:Ooe},Sa={name:"emailAutolink",tokenize:TQe,previous:Foe},Ur={};function RQe(){return{text:Ur}}let Qi=48;for(;Qi<123;)Ur[Qi]=Sa,Qi++,Qi===58?Qi=65:Qi===91&&(Qi=97);Ur[43]=Sa;Ur[45]=Sa;Ur[46]=Sa;Ur[95]=Sa;Ur[72]=[Sa,Hoe];Ur[104]=[Sa,Hoe];Ur[87]=[Sa,Doe];Ur[119]=[Sa,Doe];function TQe(e,t,n){const o=this;let r,a;return i;function i(h){return!YH(h)||!Foe.call(o,o.previous)||LF(o.events)?n(h):(e.enter("literalAutolink"),e.enter("literalAutolinkEmail"),s(h))}function s(h){return YH(h)?(e.consume(h),s):h===64?(e.consume(h),c):n(h)}function c(h){return h===46?e.check(zQe,u,l)(h):h===45||h===95||wn(h)?(a=!0,e.consume(h),c):u(h)}function l(h){return e.consume(h),r=!0,c}function u(h){return a&&r&&En(o.previous)?(e.exit("literalAutolinkEmail"),e.exit("literalAutolink"),t(h)):n(h)}}function DQe(e,t,n){const o=this;return r;function r(i){return i!==87&&i!==119||!qoe.call(o,o.previous)||LF(o.events)?n(i):(e.enter("literalAutolink"),e.enter("literalAutolinkWww"),e.check(PQe,e.attempt(zoe,e.attempt(Roe,a),n),n)(i))}function a(i){return e.exit("literalAutolinkWww"),e.exit("literalAutolink"),t(i)}}function HQe(e,t,n){const o=this;let r="",a=!1;return i;function i(h){return(h===72||h===104)&&Ooe.call(o,o.previous)&&!LF(o.events)?(e.enter("literalAutolink"),e.enter("literalAutolinkHttp"),r+=String.fromCodePoint(h),e.consume(h),s):n(h)}function s(h){if(En(h)&&r.length<5)return r+=String.fromCodePoint(h),e.consume(h),s;if(h===58){const f=r.toLowerCase();if(f==="http"||f==="https")return e.consume(h),c}return n(h)}function c(h){return h===47?(e.consume(h),a?l:(a=!0,c)):n(h)}function l(h){return h===null||dz(h)||kt(h)||Ed(h)||xR(h)?n(h):e.attempt(zoe,e.attempt(Roe,u),n)(h)}function u(h){return e.exit("literalAutolinkHttp"),e.exit("literalAutolink"),t(h)}}function qQe(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 OQe(e,t,n){let o,r,a;return i;function i(l){return l===46||l===95?e.check(Toe,c,s)(l):l===null||kt(l)||Ed(l)||l!==45&&xR(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(Toe,t,a)(i):i===null||kt(i)||Ed(i)?t(i):(e.consume(i),r)}function a(i){return i===41&&o++,e.consume(i),r}}function VQe(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||kt(s)||Ed(s)?t(s):n(s)}function r(s){return s===null||s===40||s===91||kt(s)||Ed(s)?t(s):o(s)}function a(s){return En(s)?i(s):n(s)}function i(s){return s===59?(e.consume(s),o):En(s)?(e.consume(s),i):n(s)}}function BQe(e,t,n){return o;function o(a){return e.consume(a),r}function r(a){return wn(a)?n(a):t(a)}}function qoe(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||kt(e)}function Ooe(e){return!En(e)}function Foe(e){return!(e===47||YH(e))}function YH(e){return e===43||e===45||e===46||e===95||wn(e)}function LF(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 UQe={tokenize:JQe,partial:!0};function WQe(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:XQe,continuation:{tokenize:YQe},exit:QQe}},text:{91:{name:"gfmFootnoteCall",tokenize:ZQe},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:GQe,resolveTo:KQe}}}}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=Qo(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 KQe(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 ZQe(e,t,n){const o=this,r=o.parser.gfmFootnotes||(o.parser.gfmFootnotes=[]);let a=0,i;return s;function s(h){return e.enter("gfmFootnoteCall"),e.enter("gfmFootnoteCallLabelMarker"),e.consume(h),e.exit("gfmFootnoteCallLabelMarker"),c}function c(h){return h!==94?n(h):(e.enter("gfmFootnoteCallMarker"),e.consume(h),e.exit("gfmFootnoteCallMarker"),e.enter("gfmFootnoteCallString"),e.enter("chunkString").contentType="string",l)}function l(h){if(a>999||h===93&&!i||h===null||h===91||kt(h))return n(h);if(h===93){e.exit("chunkString");const f=e.exit("gfmFootnoteCallString");return r.includes(Qo(o.sliceSerialize(f)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(h),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),t):n(h)}return kt(h)||(i=!0),a++,e.consume(h),h===92?u:l}function u(h){return h===91||h===92||h===93?(e.consume(h),a++,l):l(h)}}function XQe(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",u):n(k)}function u(k){if(i>999||k===93&&!s||k===null||k===91||kt(k))return n(k);if(k===93){e.exit("chunkString");const v=e.exit("gfmFootnoteDefinitionLabelString");return a=Qo(o.sliceSerialize(v)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(k),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),f}return kt(k)||(s=!0),i++,e.consume(k),k===92?h:u}function h(k){return k===91||k===92||k===93?(e.consume(k),i++,u):u(k)}function f(k){return k===58?(e.enter("definitionMarker"),e.consume(k),e.exit("definitionMarker"),r.includes(a)||r.push(a),ot(e,y,"gfmFootnoteDefinitionWhitespace")):n(k)}function y(k){return t(k)}}function YQe(e,t,n){return e.check($f,t,e.attempt(UQe,t,n))}function QQe(e){e.exit("gfmFootnoteDefinition")}function JQe(e,t,n){const o=this;return ot(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 eJe(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 u={type:"strikethrough",start:Object.assign({},i[l][1].start),end:Object.assign({},i[c][1].end)},h={type:"strikethroughText",start:Object.assign({},i[l][1].end),end:Object.assign({},i[c][1].start)},f=[["enter",u,s],["enter",i[l][1],s],["exit",i[l][1],s],["enter",h,s]],y=s.parser.constructs.insideSpan.null;y&&ko(f,f.length,0,wR(y,i.slice(l+1,c),s)),ko(f,f.length,0,[["exit",h,s],["enter",i[c][1],s],["exit",i[c][1],s],["exit",u,s]]),ko(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,u=this.events;let h=0;return f;function f(k){return l===126&&u[u.length-1][1].type!=="characterEscape"?c(k):(i.enter("strikethroughSequenceTemporary"),y(k))}function y(k){const v=C0(l);if(k===126)return h>1?c(k):(i.consume(k),h++,y);if(h<2&&!n)return c(k);const w=i.exit("strikethroughSequenceTemporary"),g=C0(k);return w._open=!g||g===2&&!!v,w._close=!v||v===2&&!!g,s(k)}}}class tJe{constructor(){this.map=[]}add(t,n,o){nJe(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 nJe(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 oJe(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 rJe(){return{flow:{null:{name:"table",tokenize:aJe,resolveAll:iJe}}}}function aJe(e,t,n){const o=this;let r=0,a=0,i;return s;function s(N){let A=o.events.length-1;for(;A>-1;){const z=o.events[A][1].type;if(z==="lineEnding"||z==="linePrefix")A--;else break}const R=A>-1?o.events[A][1].type:null,Y=R==="tableHead"||R==="tableRow"?_:c;return Y===_&&o.parser.lazy[o.now().line]?n(N):Y(N)}function c(N){return e.enter("tableHead"),e.enter("tableRow"),l(N)}function l(N){return N===124||(i=!0,a+=1),u(N)}function u(N){return N===null?n(N):Re(N)?a>1?(a=0,o.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(N),e.exit("lineEnding"),y):n(N):Xe(N)?ot(e,u,"whitespace")(N):(a+=1,i&&(i=!1,r+=1),N===124?(e.enter("tableCellDivider"),e.consume(N),e.exit("tableCellDivider"),i=!0,u):(e.enter("data"),h(N)))}function h(N){return N===null||N===124||kt(N)?(e.exit("data"),u(N)):(e.consume(N),N===92?f:h)}function f(N){return N===92||N===124?(e.consume(N),h):h(N)}function y(N){return o.interrupt=!1,o.parser.lazy[o.now().line]?n(N):(e.enter("tableDelimiterRow"),i=!1,Xe(N)?ot(e,k,"linePrefix",o.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(N):k(N))}function k(N){return N===45||N===58?w(N):N===124?(i=!0,e.enter("tableCellDivider"),e.consume(N),e.exit("tableCellDivider"),v):C(N)}function v(N){return Xe(N)?ot(e,w,"whitespace")(N):w(N)}function w(N){return N===58?(a+=1,i=!0,e.enter("tableDelimiterMarker"),e.consume(N),e.exit("tableDelimiterMarker"),g):N===45?(a+=1,g(N)):N===null||Re(N)?b(N):C(N)}function g(N){return N===45?(e.enter("tableDelimiterFiller"),M(N)):C(N)}function M(N){return N===45?(e.consume(N),M):N===58?(i=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(N),e.exit("tableDelimiterMarker"),x):(e.exit("tableDelimiterFiller"),x(N))}function x(N){return Xe(N)?ot(e,b,"whitespace")(N):b(N)}function b(N){return N===124?k(N):N===null||Re(N)?!i||r!==a?C(N):(e.exit("tableDelimiterRow"),e.exit("tableHead"),t(N)):C(N)}function C(N){return n(N)}function _(N){return e.enter("tableRow"),S(N)}function S(N){return N===124?(e.enter("tableCellDivider"),e.consume(N),e.exit("tableCellDivider"),S):N===null||Re(N)?(e.exit("tableRow"),t(N)):Xe(N)?ot(e,S,"whitespace")(N):(e.enter("data"),$(N))}function $(N){return N===null||N===124||kt(N)?(e.exit("data"),S(N)):(e.consume(N),N===92?j:$)}function j(N){return N===92||N===124?(e.consume(N),$):$(N)}}function iJe(e,t){let n=-1,o=!0,r=0,a=[0,0,0,0],i=[0,0,0,0],s=!1,c=0,l,u,h;const f=new tJe;for(;++n<e.length;){const y=e[n],k=y[1];y[0]==="enter"?k.type==="tableHead"?(s=!1,c!==0&&(wG(f,t,c,l,u),u=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,h=void 0,a=[0,0,0,0],i=[0,n+1,0,0],s&&(s=!1,u={type:"tableBody",start:Object.assign({},k.start),end:Object.assign({},k.end)},f.add(n,0,[["enter",u,t]])),r=k.type==="tableDelimiterRow"?2:u?3:1):r&&(k.type==="data"||k.type==="tableDelimiterMarker"||k.type==="tableDelimiterFiller")?(o=!1,i[2]===0&&(a[1]!==0&&(i[0]=i[1],h=jp(f,t,a,r,void 0,h),a=[0,0,0,0]),i[2]=n)):k.type==="tableCellDivider"&&(o?o=!1:(a[1]!==0&&(i[0]=i[1],h=jp(f,t,a,r,void 0,h)),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],h=jp(f,t,a,r,n,h)):i[1]!==0&&(h=jp(f,t,i,r,n,h)),r=0):r&&(k.type==="data"||k.type==="tableDelimiterMarker"||k.type==="tableDelimiterFiller")&&(i[3]=n)}for(c!==0&&wG(f,t,c,l,u),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=oJe(t.events,n))}return e}function jp(e,t,n,o,r,a){const i=o===1?"tableHeader":o===2?"tableDelimiter":"tableData",s="tableContent";n[0]!==0&&(a.end=Object.assign({},ku(t.events,n[0])),e.add(n[0],0,[["exit",a,t]]));const c=ku(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=ku(t.events,n[2]),u=ku(t.events,n[3]),h={type:s,start:Object.assign({},l),end:Object.assign({},u)};if(e.add(n[2],0,[["enter",h,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,v=n[3]-n[2]-1;e.add(k,v,[])}}e.add(n[3]+1,0,[["exit",h,t]])}return r!==void 0&&(a.end=Object.assign({},ku(t.events,r)),e.add(r,0,[["exit",a,t]]),a=void 0),a}function wG(e,t,n,o,r){const a=[],i=ku(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 ku(e,t){const n=e[t],o=n[0]==="enter"?"start":"end";return n[1][o]}const sJe={name:"tasklistCheck",tokenize:lJe};function cJe(){return{text:{91:sJe}}}function lJe(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 kt(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 Re(c)?t(c):Xe(c)?e.check({tokenize:dJe},t,n)(c):n(c)}}function dJe(e,t,n){return ot(e,o,"whitespace");function o(r){return r===null?n(r):t(r)}}function uJe(e){return Qne([RQe(),WQe(),eJe(e),rJe(),cJe()])}const hJe={};function fJe(e){const t=this,n=e||hJe,o=t.data(),r=o.micromarkExtensions||(o.micromarkExtensions=[]),a=o.fromMarkdownExtensions||(o.fromMarkdownExtensions=[]),i=o.toMarkdownExtensions||(o.toMarkdownExtensions=[]);r.push(uJe(n)),a.push($Qe()),i.push(jQe(n))}let Pp=null,pJe=0;function yJe(){return Pp||(Pp=ff(()=>import("./mermaid.core-C1P8oPqR.js").then(e=>e.ak),__vite__mapDeps([8,9,1])).then(e=>{const t=e;return t.default??t}),Pp)}function MG(){var e;return typeof document>"u"?!1:document.documentElement.classList.contains("dark")||(e=document.body)!=null&&e.classList.contains("dark")?!0:!!document.querySelector(".dark")}function bG({code:e,className:t}){const n=m.useRef(null),o=m.useRef(`seeflow-mermaid-${++pJe}`),[r,a]=m.useState(null),[i,s]=m.useState(()=>MG());return m.useEffect(()=>{if(typeof document>"u")return;const c=()=>s(MG()),l=new MutationObserver(c);return l.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),document.body&&l.observe(document.body,{attributes:!0,attributeFilter:["class"]}),()=>l.disconnect()},[]),m.useEffect(()=>{let c=!1;return a(null),yJe().then(async l=>{l.initialize({startOnLoad:!1,theme:i?"dark":"default",securityLevel:"strict",fontFamily:'"Inter", ui-sans-serif, system-ui, sans-serif'});const u=`${o.current}-${i?"d":"l"}`,h=await l.render(u,e);if(c)return;const f=n.current;f&&(f.innerHTML=h.svg)}).catch(l=>{c||a(l instanceof Error?l.message:String(l))}),()=>{c=!0}},[e,i]),r?p.jsx("pre",{"data-testid":"detail-panel-mermaid-fallback","data-mermaid-error":"true",title:r,className:ie("sf:mb-2 sf:overflow-x-auto sf:rounded sf:bg-muted/60 sf:px-2 sf:py-1 sf:font-mono sf:text-xs sf:text-foreground sf:last:mb-0",t),children:p.jsx("code",{children:e})}):p.jsx("div",{ref:n,"data-testid":"detail-panel-mermaid","data-mermaid-theme":i?"dark":"light",role:"img","aria-label":"Mermaid diagram",className:ie("sf:mb-2 sf:overflow-x-auto sf:rounded sf:bg-muted/30 sf:px-3 sf:py-2 sf:text-foreground sf:last:mb-0",t)})}function mJe({flowId:e,node:t,connector:n,adapter:o,onNameChange:r,onDescriptionChange:a,onDetailChange:i,onIconChange:s,statusReport:c,onClose:l}){const u=(t==null?void 0:t.type)==="text",h=(t==null?void 0:t.type)==="ellipse"||(t==null?void 0:t.type)==="sticky",f=u?null:t,y=f!==null||n!==null,k=f&&"name"in f.data?f.data.name??"":"",v=(f==null?void 0:f.data.description)??"",w=(f==null?void 0:f.data.detail)??"",g=f!==null&&!h,M=f!==null&&(f.type==="rectangle"||f.type==="component"),x=M&&typeof s=="function",b=M&&f&&"icon"in f.data?f.data.icon??null:null,[C,_]=m.useState(()=>dTe()),S=j=>{j.preventDefault(),hTe(C,j.clientX,{onWidth:_,onCommit:uTe})},$={"--detail-panel-w":`${C}px`,borderLeftWidth:"var(--detail-panel-border-left)",boxShadow:"var(--detail-panel-shadow)"};return p.jsx(dWe,{open:y,modal:!1,onOpenChange:j=>{j||l()},children:p.jsxs(bne,{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:$,"data-testid":"detail-panel",onEscapeKeyDown:j=>{var A;const N=document.activeElement;(A=N==null?void 0:N.getAttribute("data-testid"))!=null&&A.endsWith("-editor")&&j.preventDefault()},onInteractOutside:j=>{var R;const N=document.activeElement;(R=N==null?void 0:N.getAttribute("data-testid"))!=null&&R.endsWith("-editor")&&N.blur();const A=j.target;A!=null&&A.closest(".react-flow__resize-control")&&j.preventDefault(),A!=null&&A.closest("[data-radix-popper-content-wrapper]")&&j.preventDefault(),A!=null&&A.closest('[data-testid="canvas-style-strip"]')&&j.preventDefault(),A!=null&&A.closest(".react-flow__node")&&j.preventDefault(),A!=null&&A.closest(".react-flow__edge")&&j.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(cP,{"data-testid":"detail-panel-title",children:p.jsxs("div",{className:"sf:flex sf:items-center sf:gap-2",children:[x&&s?p.jsx(kJe,{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(w0,{name:b,size:16})}):null,p.jsx("div",{className:"sf:min-w-0 sf:flex-1",children:p.jsx(KT,{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(cP,{"data-testid":"detail-panel-title",className:"sf:sr-only",children:f.id}),p.jsxs(DH,{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(wJe,{report:c}):null,p.jsx(KT,{nodeId:f.id,value:v,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 sf:dark:text-zinc-400"}),p.jsx(KT,{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"}),f.type==="html"&&e?p.jsx(gJe,{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(cP,{"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(DH,{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(bJe,{connector:n})})]}):null]})})}function KT({nodeId:e,value:t,placeholder:n,multiline:o,ariaLabel:r,testIdBase:a,onSave:i,textClassName:s,markdown:c=!1}){const[l,u]=m.useState(!1),h=m.useRef(null),f=m.useRef(!1);m.useEffect(()=>{if(!l)return;const C=h.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:ie("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(_G,{value:t}):t});const k=()=>{const C=h.current,_=C?o?C.innerText:C.textContent??"":t;i(e,_),u(!1)},v=()=>{u(!1)},w=C=>{if(C.stopPropagation(),C.nativeEvent.stopPropagation(),C.key==="Escape"){C.preventDefault(),f.current=!0,v();return}if(C.key==="Enter"){if(C.preventDefault(),C.shiftKey||!o){k();return}document.execCommand("insertText",!1,`
|
|
8541
|
+
`))}function c(y,k,v,w){const g=v.enter("tableCell"),M=v.enter("phrasing"),x=v.containerPhrasing(y,{...w,before:a,after:a});return M(),g(),x}function l(y,k){return OYe(y,{align:k,alignDelimiters:o,padding:n,stringLength:r})}function u(y,k,v){const w=y.children;let g=-1;const M=[],x=k.enter("table");for(;++g<w.length;)M[g]=h(w[g],k,v);return x(),M}function h(y,k,v){const w=y.children;let g=-1;const M=[],x=k.enter("tableRow");for(;++g<w.length;)M[g]=c(w[g],y,k,v);return x(),M}function f(y,k,v){let w=Poe.inlineCode(y,k,v);return v.stack.includes("tableCell")&&(w=w.replace(/\|/g,"\\$&")),w}}function NQe(){return{exit:{taskListCheckValueChecked:xG,taskListCheckValueUnchecked:xG,paragraph:AQe}}}function IQe(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:EQe}}}function xG(e){const t=this.stack[this.stack.length-2];t.type,t.checked=e.type==="taskListCheckValueChecked"}function AQe(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 EQe(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=Poe.listItem(e,t,n,{...o,...s.current()});return a&&(c=c.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,l)),c;function l(u){return u+i}}function $Qe(){return[dYe(),EYe(),zYe(),wQe(),NQe()]}function jQe(e){return{extensions:[uYe(),$Ye(e),RYe(),LQe(e),IQe()]}}const PQe={tokenize:qQe,partial:!0},zoe={tokenize:OQe,partial:!0},Roe={tokenize:FQe,partial:!0},Toe={tokenize:VQe,partial:!0},zQe={tokenize:BQe,partial:!0},Doe={name:"wwwAutolink",tokenize:DQe,previous:qoe},Hoe={name:"protocolAutolink",tokenize:HQe,previous:Ooe},Sa={name:"emailAutolink",tokenize:TQe,previous:Foe},Ur={};function RQe(){return{text:Ur}}let Qi=48;for(;Qi<123;)Ur[Qi]=Sa,Qi++,Qi===58?Qi=65:Qi===91&&(Qi=97);Ur[43]=Sa;Ur[45]=Sa;Ur[46]=Sa;Ur[95]=Sa;Ur[72]=[Sa,Hoe];Ur[104]=[Sa,Hoe];Ur[87]=[Sa,Doe];Ur[119]=[Sa,Doe];function TQe(e,t,n){const o=this;let r,a;return i;function i(h){return!YH(h)||!Foe.call(o,o.previous)||LF(o.events)?n(h):(e.enter("literalAutolink"),e.enter("literalAutolinkEmail"),s(h))}function s(h){return YH(h)?(e.consume(h),s):h===64?(e.consume(h),c):n(h)}function c(h){return h===46?e.check(zQe,u,l)(h):h===45||h===95||wn(h)?(a=!0,e.consume(h),c):u(h)}function l(h){return e.consume(h),r=!0,c}function u(h){return a&&r&&En(o.previous)?(e.exit("literalAutolinkEmail"),e.exit("literalAutolink"),t(h)):n(h)}}function DQe(e,t,n){const o=this;return r;function r(i){return i!==87&&i!==119||!qoe.call(o,o.previous)||LF(o.events)?n(i):(e.enter("literalAutolink"),e.enter("literalAutolinkWww"),e.check(PQe,e.attempt(zoe,e.attempt(Roe,a),n),n)(i))}function a(i){return e.exit("literalAutolinkWww"),e.exit("literalAutolink"),t(i)}}function HQe(e,t,n){const o=this;let r="",a=!1;return i;function i(h){return(h===72||h===104)&&Ooe.call(o,o.previous)&&!LF(o.events)?(e.enter("literalAutolink"),e.enter("literalAutolinkHttp"),r+=String.fromCodePoint(h),e.consume(h),s):n(h)}function s(h){if(En(h)&&r.length<5)return r+=String.fromCodePoint(h),e.consume(h),s;if(h===58){const f=r.toLowerCase();if(f==="http"||f==="https")return e.consume(h),c}return n(h)}function c(h){return h===47?(e.consume(h),a?l:(a=!0,c)):n(h)}function l(h){return h===null||dz(h)||kt(h)||Ed(h)||xR(h)?n(h):e.attempt(zoe,e.attempt(Roe,u),n)(h)}function u(h){return e.exit("literalAutolinkHttp"),e.exit("literalAutolink"),t(h)}}function qQe(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 OQe(e,t,n){let o,r,a;return i;function i(l){return l===46||l===95?e.check(Toe,c,s)(l):l===null||kt(l)||Ed(l)||l!==45&&xR(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(Toe,t,a)(i):i===null||kt(i)||Ed(i)?t(i):(e.consume(i),r)}function a(i){return i===41&&o++,e.consume(i),r}}function VQe(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||kt(s)||Ed(s)?t(s):n(s)}function r(s){return s===null||s===40||s===91||kt(s)||Ed(s)?t(s):o(s)}function a(s){return En(s)?i(s):n(s)}function i(s){return s===59?(e.consume(s),o):En(s)?(e.consume(s),i):n(s)}}function BQe(e,t,n){return o;function o(a){return e.consume(a),r}function r(a){return wn(a)?n(a):t(a)}}function qoe(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||kt(e)}function Ooe(e){return!En(e)}function Foe(e){return!(e===47||YH(e))}function YH(e){return e===43||e===45||e===46||e===95||wn(e)}function LF(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 UQe={tokenize:JQe,partial:!0};function WQe(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:XQe,continuation:{tokenize:YQe},exit:QQe}},text:{91:{name:"gfmFootnoteCall",tokenize:ZQe},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:GQe,resolveTo:KQe}}}}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=Qo(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 KQe(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 ZQe(e,t,n){const o=this,r=o.parser.gfmFootnotes||(o.parser.gfmFootnotes=[]);let a=0,i;return s;function s(h){return e.enter("gfmFootnoteCall"),e.enter("gfmFootnoteCallLabelMarker"),e.consume(h),e.exit("gfmFootnoteCallLabelMarker"),c}function c(h){return h!==94?n(h):(e.enter("gfmFootnoteCallMarker"),e.consume(h),e.exit("gfmFootnoteCallMarker"),e.enter("gfmFootnoteCallString"),e.enter("chunkString").contentType="string",l)}function l(h){if(a>999||h===93&&!i||h===null||h===91||kt(h))return n(h);if(h===93){e.exit("chunkString");const f=e.exit("gfmFootnoteCallString");return r.includes(Qo(o.sliceSerialize(f)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(h),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),t):n(h)}return kt(h)||(i=!0),a++,e.consume(h),h===92?u:l}function u(h){return h===91||h===92||h===93?(e.consume(h),a++,l):l(h)}}function XQe(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",u):n(k)}function u(k){if(i>999||k===93&&!s||k===null||k===91||kt(k))return n(k);if(k===93){e.exit("chunkString");const v=e.exit("gfmFootnoteDefinitionLabelString");return a=Qo(o.sliceSerialize(v)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(k),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),f}return kt(k)||(s=!0),i++,e.consume(k),k===92?h:u}function h(k){return k===91||k===92||k===93?(e.consume(k),i++,u):u(k)}function f(k){return k===58?(e.enter("definitionMarker"),e.consume(k),e.exit("definitionMarker"),r.includes(a)||r.push(a),ot(e,y,"gfmFootnoteDefinitionWhitespace")):n(k)}function y(k){return t(k)}}function YQe(e,t,n){return e.check($f,t,e.attempt(UQe,t,n))}function QQe(e){e.exit("gfmFootnoteDefinition")}function JQe(e,t,n){const o=this;return ot(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 eJe(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 u={type:"strikethrough",start:Object.assign({},i[l][1].start),end:Object.assign({},i[c][1].end)},h={type:"strikethroughText",start:Object.assign({},i[l][1].end),end:Object.assign({},i[c][1].start)},f=[["enter",u,s],["enter",i[l][1],s],["exit",i[l][1],s],["enter",h,s]],y=s.parser.constructs.insideSpan.null;y&&ko(f,f.length,0,wR(y,i.slice(l+1,c),s)),ko(f,f.length,0,[["exit",h,s],["enter",i[c][1],s],["exit",i[c][1],s],["exit",u,s]]),ko(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,u=this.events;let h=0;return f;function f(k){return l===126&&u[u.length-1][1].type!=="characterEscape"?c(k):(i.enter("strikethroughSequenceTemporary"),y(k))}function y(k){const v=C0(l);if(k===126)return h>1?c(k):(i.consume(k),h++,y);if(h<2&&!n)return c(k);const w=i.exit("strikethroughSequenceTemporary"),g=C0(k);return w._open=!g||g===2&&!!v,w._close=!v||v===2&&!!g,s(k)}}}class tJe{constructor(){this.map=[]}add(t,n,o){nJe(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 nJe(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 oJe(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 rJe(){return{flow:{null:{name:"table",tokenize:aJe,resolveAll:iJe}}}}function aJe(e,t,n){const o=this;let r=0,a=0,i;return s;function s(N){let A=o.events.length-1;for(;A>-1;){const z=o.events[A][1].type;if(z==="lineEnding"||z==="linePrefix")A--;else break}const R=A>-1?o.events[A][1].type:null,Y=R==="tableHead"||R==="tableRow"?_:c;return Y===_&&o.parser.lazy[o.now().line]?n(N):Y(N)}function c(N){return e.enter("tableHead"),e.enter("tableRow"),l(N)}function l(N){return N===124||(i=!0,a+=1),u(N)}function u(N){return N===null?n(N):Re(N)?a>1?(a=0,o.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(N),e.exit("lineEnding"),y):n(N):Xe(N)?ot(e,u,"whitespace")(N):(a+=1,i&&(i=!1,r+=1),N===124?(e.enter("tableCellDivider"),e.consume(N),e.exit("tableCellDivider"),i=!0,u):(e.enter("data"),h(N)))}function h(N){return N===null||N===124||kt(N)?(e.exit("data"),u(N)):(e.consume(N),N===92?f:h)}function f(N){return N===92||N===124?(e.consume(N),h):h(N)}function y(N){return o.interrupt=!1,o.parser.lazy[o.now().line]?n(N):(e.enter("tableDelimiterRow"),i=!1,Xe(N)?ot(e,k,"linePrefix",o.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(N):k(N))}function k(N){return N===45||N===58?w(N):N===124?(i=!0,e.enter("tableCellDivider"),e.consume(N),e.exit("tableCellDivider"),v):C(N)}function v(N){return Xe(N)?ot(e,w,"whitespace")(N):w(N)}function w(N){return N===58?(a+=1,i=!0,e.enter("tableDelimiterMarker"),e.consume(N),e.exit("tableDelimiterMarker"),g):N===45?(a+=1,g(N)):N===null||Re(N)?b(N):C(N)}function g(N){return N===45?(e.enter("tableDelimiterFiller"),M(N)):C(N)}function M(N){return N===45?(e.consume(N),M):N===58?(i=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(N),e.exit("tableDelimiterMarker"),x):(e.exit("tableDelimiterFiller"),x(N))}function x(N){return Xe(N)?ot(e,b,"whitespace")(N):b(N)}function b(N){return N===124?k(N):N===null||Re(N)?!i||r!==a?C(N):(e.exit("tableDelimiterRow"),e.exit("tableHead"),t(N)):C(N)}function C(N){return n(N)}function _(N){return e.enter("tableRow"),S(N)}function S(N){return N===124?(e.enter("tableCellDivider"),e.consume(N),e.exit("tableCellDivider"),S):N===null||Re(N)?(e.exit("tableRow"),t(N)):Xe(N)?ot(e,S,"whitespace")(N):(e.enter("data"),$(N))}function $(N){return N===null||N===124||kt(N)?(e.exit("data"),S(N)):(e.consume(N),N===92?j:$)}function j(N){return N===92||N===124?(e.consume(N),$):$(N)}}function iJe(e,t){let n=-1,o=!0,r=0,a=[0,0,0,0],i=[0,0,0,0],s=!1,c=0,l,u,h;const f=new tJe;for(;++n<e.length;){const y=e[n],k=y[1];y[0]==="enter"?k.type==="tableHead"?(s=!1,c!==0&&(wG(f,t,c,l,u),u=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,h=void 0,a=[0,0,0,0],i=[0,n+1,0,0],s&&(s=!1,u={type:"tableBody",start:Object.assign({},k.start),end:Object.assign({},k.end)},f.add(n,0,[["enter",u,t]])),r=k.type==="tableDelimiterRow"?2:u?3:1):r&&(k.type==="data"||k.type==="tableDelimiterMarker"||k.type==="tableDelimiterFiller")?(o=!1,i[2]===0&&(a[1]!==0&&(i[0]=i[1],h=jp(f,t,a,r,void 0,h),a=[0,0,0,0]),i[2]=n)):k.type==="tableCellDivider"&&(o?o=!1:(a[1]!==0&&(i[0]=i[1],h=jp(f,t,a,r,void 0,h)),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],h=jp(f,t,a,r,n,h)):i[1]!==0&&(h=jp(f,t,i,r,n,h)),r=0):r&&(k.type==="data"||k.type==="tableDelimiterMarker"||k.type==="tableDelimiterFiller")&&(i[3]=n)}for(c!==0&&wG(f,t,c,l,u),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=oJe(t.events,n))}return e}function jp(e,t,n,o,r,a){const i=o===1?"tableHeader":o===2?"tableDelimiter":"tableData",s="tableContent";n[0]!==0&&(a.end=Object.assign({},ku(t.events,n[0])),e.add(n[0],0,[["exit",a,t]]));const c=ku(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=ku(t.events,n[2]),u=ku(t.events,n[3]),h={type:s,start:Object.assign({},l),end:Object.assign({},u)};if(e.add(n[2],0,[["enter",h,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,v=n[3]-n[2]-1;e.add(k,v,[])}}e.add(n[3]+1,0,[["exit",h,t]])}return r!==void 0&&(a.end=Object.assign({},ku(t.events,r)),e.add(r,0,[["exit",a,t]]),a=void 0),a}function wG(e,t,n,o,r){const a=[],i=ku(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 ku(e,t){const n=e[t],o=n[0]==="enter"?"start":"end";return n[1][o]}const sJe={name:"tasklistCheck",tokenize:lJe};function cJe(){return{text:{91:sJe}}}function lJe(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 kt(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 Re(c)?t(c):Xe(c)?e.check({tokenize:dJe},t,n)(c):n(c)}}function dJe(e,t,n){return ot(e,o,"whitespace");function o(r){return r===null?n(r):t(r)}}function uJe(e){return Qne([RQe(),WQe(),eJe(e),rJe(),cJe()])}const hJe={};function fJe(e){const t=this,n=e||hJe,o=t.data(),r=o.micromarkExtensions||(o.micromarkExtensions=[]),a=o.fromMarkdownExtensions||(o.fromMarkdownExtensions=[]),i=o.toMarkdownExtensions||(o.toMarkdownExtensions=[]);r.push(uJe(n)),a.push($Qe()),i.push(jQe(n))}let Pp=null,pJe=0;function yJe(){return Pp||(Pp=ff(()=>import("./mermaid.core-Cf2CUPpR.js").then(e=>e.ak),__vite__mapDeps([8,9,1])).then(e=>{const t=e;return t.default??t}),Pp)}function MG(){var e;return typeof document>"u"?!1:document.documentElement.classList.contains("dark")||(e=document.body)!=null&&e.classList.contains("dark")?!0:!!document.querySelector(".dark")}function bG({code:e,className:t}){const n=m.useRef(null),o=m.useRef(`seeflow-mermaid-${++pJe}`),[r,a]=m.useState(null),[i,s]=m.useState(()=>MG());return m.useEffect(()=>{if(typeof document>"u")return;const c=()=>s(MG()),l=new MutationObserver(c);return l.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),document.body&&l.observe(document.body,{attributes:!0,attributeFilter:["class"]}),()=>l.disconnect()},[]),m.useEffect(()=>{let c=!1;return a(null),yJe().then(async l=>{l.initialize({startOnLoad:!1,theme:i?"dark":"default",securityLevel:"strict",fontFamily:'"Inter", ui-sans-serif, system-ui, sans-serif'});const u=`${o.current}-${i?"d":"l"}`,h=await l.render(u,e);if(c)return;const f=n.current;f&&(f.innerHTML=h.svg)}).catch(l=>{c||a(l instanceof Error?l.message:String(l))}),()=>{c=!0}},[e,i]),r?p.jsx("pre",{"data-testid":"detail-panel-mermaid-fallback","data-mermaid-error":"true",title:r,className:ie("sf:mb-2 sf:overflow-x-auto sf:rounded sf:bg-muted/60 sf:px-2 sf:py-1 sf:font-mono sf:text-xs sf:text-foreground sf:last:mb-0",t),children:p.jsx("code",{children:e})}):p.jsx("div",{ref:n,"data-testid":"detail-panel-mermaid","data-mermaid-theme":i?"dark":"light",role:"img","aria-label":"Mermaid diagram",className:ie("sf:mb-2 sf:overflow-x-auto sf:rounded sf:bg-muted/30 sf:px-3 sf:py-2 sf:text-foreground sf:last:mb-0",t)})}function mJe({flowId:e,node:t,connector:n,adapter:o,onNameChange:r,onDescriptionChange:a,onDetailChange:i,onIconChange:s,statusReport:c,onClose:l}){const u=(t==null?void 0:t.type)==="text",h=(t==null?void 0:t.type)==="ellipse"||(t==null?void 0:t.type)==="sticky",f=u?null:t,y=f!==null||n!==null,k=f&&"name"in f.data?f.data.name??"":"",v=(f==null?void 0:f.data.description)??"",w=(f==null?void 0:f.data.detail)??"",g=f!==null&&!h,M=f!==null&&(f.type==="rectangle"||f.type==="component"),x=M&&typeof s=="function",b=M&&f&&"icon"in f.data?f.data.icon??null:null,[C,_]=m.useState(()=>dTe()),S=j=>{j.preventDefault(),hTe(C,j.clientX,{onWidth:_,onCommit:uTe})},$={"--detail-panel-w":`${C}px`,borderLeftWidth:"var(--detail-panel-border-left)",boxShadow:"var(--detail-panel-shadow)"};return p.jsx(dWe,{open:y,modal:!1,onOpenChange:j=>{j||l()},children:p.jsxs(bne,{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:$,"data-testid":"detail-panel",onEscapeKeyDown:j=>{var A;const N=document.activeElement;(A=N==null?void 0:N.getAttribute("data-testid"))!=null&&A.endsWith("-editor")&&j.preventDefault()},onInteractOutside:j=>{var R;const N=document.activeElement;(R=N==null?void 0:N.getAttribute("data-testid"))!=null&&R.endsWith("-editor")&&N.blur();const A=j.target;A!=null&&A.closest(".react-flow__resize-control")&&j.preventDefault(),A!=null&&A.closest("[data-radix-popper-content-wrapper]")&&j.preventDefault(),A!=null&&A.closest('[data-testid="canvas-style-strip"]')&&j.preventDefault(),A!=null&&A.closest(".react-flow__node")&&j.preventDefault(),A!=null&&A.closest(".react-flow__edge")&&j.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(cP,{"data-testid":"detail-panel-title",children:p.jsxs("div",{className:"sf:flex sf:items-center sf:gap-2",children:[x&&s?p.jsx(kJe,{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(w0,{name:b,size:16})}):null,p.jsx("div",{className:"sf:min-w-0 sf:flex-1",children:p.jsx(KT,{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(cP,{"data-testid":"detail-panel-title",className:"sf:sr-only",children:f.id}),p.jsxs(DH,{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(wJe,{report:c}):null,p.jsx(KT,{nodeId:f.id,value:v,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 sf:dark:text-zinc-400"}),p.jsx(KT,{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"}),f.type==="html"&&e?p.jsx(gJe,{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(cP,{"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(DH,{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(bJe,{connector:n})})]}):null]})})}function KT({nodeId:e,value:t,placeholder:n,multiline:o,ariaLabel:r,testIdBase:a,onSave:i,textClassName:s,markdown:c=!1}){const[l,u]=m.useState(!1),h=m.useRef(null),f=m.useRef(!1);m.useEffect(()=>{if(!l)return;const C=h.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:ie("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(_G,{value:t}):t});const k=()=>{const C=h.current,_=C?o?C.innerText:C.textContent??"":t;i(e,_),u(!1)},v=()=>{u(!1)},w=C=>{if(C.stopPropagation(),C.nativeEvent.stopPropagation(),C.key==="Escape"){C.preventDefault(),f.current=!0,v();return}if(C.key==="Enter"){if(C.preventDefault(),C.shiftKey||!o){k();return}document.execCommand("insertText",!1,`
|
|
8542
8542
|
`)}},g=C=>{C.preventDefault();const _=C.clipboardData.getData("text/plain");document.execCommand("insertText",!1,_)},M=C=>{},x=()=>{if(f.current){f.current=!1;return}k()},b=()=>{l||u(!0)};return p.jsx("div",{className:"relative","data-testid":a,"data-editing":l?"true":"false",children:l?p.jsx("div",{ref:h,contentEditable:"plaintext-only",suppressContentEditableWarning:!0,spellCheck:!1,tabIndex:0,onKeyDown:w,onPaste:g,onInput:M,onBlur:x,"data-testid":`${a}-editor`,className:ie("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:ie("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(_G,{value:t}):t})})}function kJe({nodeId:e,icon:t,onChange:n}){const[o,r]=m.useState(!1);return p.jsx(HO,{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:ie("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(w0,{name:t,size:16,"aria-hidden":!0}):p.jsx(B2,{className:"sf:h-4 sf:w-4","aria-hidden":!0})})})}function gJe({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 u,h;r({kind:"pending"});try{l==="open"?await((u=e==null?void 0:e.openFile)==null?void 0:u.call(e,s)):await((h=e==null?void 0:e.revealFile)==null?void 0:h.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(dt,{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(X2,{className:"sf:h-3.5 sf:w-3.5"}),"Open in editor"]}):null,i?p.jsxs(dt,{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(F2,{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:ie("sf:text-[11px] sf:text-destructive"),children:o.message??""}):null]})}function vJe(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 xJe(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 wJe({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(FO,{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: ${vJe(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:xJe(r)})]},o))}):null]})}function Voe(e){return typeof e=="string"?e.replace(/\n$/,""):Array.isArray(e)?e.map(t=>typeof t=="string"?t:"").join("").replace(/\n$/,""):String(e??"").replace(/\n$/,"")}function MJe(e){if(!m.isValidElement(e))return null;const t=e.props;return!t||typeof t.className!="string"||!t.className.includes("language-mermaid")?null:Voe(t.children)}function _G({value:e}){return p.jsx(eYe,{remarkPlugins:[fJe],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})=>typeof n=="string"&&n.includes("language-mermaid")?p.jsx(bG,{code:Voe(t)}):(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})=>{const n=MJe(t);return n!==null?p.jsx(bG,{code:n}):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 bJe({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(ta,{label:"Source",value:e.source}),p.jsx(ta,{label:"Target",value:e.target}),e.label?p.jsx(ta,{label:"Label",value:e.label}):null,e.style?p.jsx(ta,{label:"Style",value:e.style}):null,e.color?p.jsx(ta,{label:"Color",value:e.color}):null,e.direction?p.jsx(ta,{label:"Direction",value:e.direction}):null,e.url?p.jsx(ta,{label:"URL",value:`${e.method??"GET"} ${e.url}`}):null,e.eventName?p.jsx(ta,{label:"Event",value:e.eventName}):null,e.queueName?p.jsx(ta,{label:"Queue",value:e.queueName}):null]})})}function ta({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 _Je="https://seeflow.dev/embed",CJe=(e,t)=>{const n=`${_Je}/${encodeURIComponent(e)}`;return t?`${n}?theme=${t}`:n},SJe=e=>{var t,n;return(n=(t=e==null?void 0:e.documentElement)==null?void 0:t.classList)!=null&&n.contains("dark")?"dark":"light"},LJe=e=>e.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<"),NJe=e=>[`<iframe src="${LJe(e)}"`,' width="100%"',' height="600"',' style="border:0"',' allow="fullscreen"',' loading="lazy"></iframe>'].join(`
|
|
8543
8543
|
`),IJe="Embed this canvas",AJe="Paste this iframe into any page to embed the canvas.",EJe="Copy snippet",$Je="Copied!",jJe="Press ⌘C to copy",PJe="Close",zJe="Theme",RJe=1500,TJe=[{value:"match",label:"Match my theme"},{value:"light",label:"Light"},{value:"dark",label:"Dark"}],DJe=e=>e==="light"?"light":e==="dark"?"dark":SJe(typeof document<"u"?document:null);function HJe({open:e,onOpenChange:t,projectId:n}){const[o,r]=m.useState("idle"),[a,i]=m.useState("match"),s=m.useRef(null),c=m.useMemo(()=>NJe(CJe(n,DJe(a))),[n,a]),l=m.useCallback(async()=>{try{await navigator.clipboard.writeText(c),r("copied"),setTimeout(()=>r("idle"),RJe)}catch{r("fallback");const u=s.current;u&&(u.focus(),u.select())}},[c]);return p.jsx(wa,{open:e,onOpenChange:t,children:p.jsxs(Ri,{"data-testid":"embed-dialog-content",children:[p.jsxs(Ti,{children:[p.jsx(Di,{children:IJe}),p.jsx(Hi,{children:AJe})]}),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:zJe}),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:TJe.map(u=>{const h=a===u.value;return p.jsx("button",{type:"button","aria-pressed":h,"aria-label":u.label,"data-testid":`embed-dialog-theme-${u.value}`,"data-active":h,onClick:()=>i(u.value),className:ie("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",h?"sf:bg-secondary sf:text-secondary-foreground sf:shadow-sm":"sf:text-muted-foreground sf:hover:bg-accent sf:hover:text-accent-foreground"),children:u.label},u.value)})})]}),p.jsx("textarea",{ref:s,"data-testid":"embed-dialog-snippet",readOnly:!0,rows:7,value:c,spellCheck:!1,onFocus:u=>u.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:jJe}):null,p.jsxs(Ma,{children:[p.jsx(dt,{variant:"outline","data-testid":"embed-dialog-close",onClick:()=>t(!1),children:PJe}),p.jsx(dt,{"data-testid":"embed-dialog-copy",onClick:l,children:o==="copied"?$Je:EJe})]})]})})}const CG="Share / download",qJe="Download PDF",OJe="Download PNG",FJe="Embed",VJe="Export to seeflow.dev";function BJe({mode:e,projectId:t,enableEmbed:n,onDownloadPdf:o,onDownloadPng:r,onExportToCloud:a,embedOpen:i,onEmbedOpenChange:s}){const[c,l]=m.useState(!1),[u,h]=m.useState(!1),[f,y]=m.useState(!1),k=i!==void 0,v=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||u||(h(!0),Promise.resolve(r()).finally(()=>h(!1)))},[r,u]),x=!!o,b=!!r,C=n&&typeof t=="string"&&t.length>0,_=e==="edit"&&!!a;return!x&&!b&&!C&&!_?null:p.jsxs(p.Fragment,{children:[p.jsxs(ane,{children:[p.jsx(ine,{asChild:!0,children:p.jsx("button",{type:"button","data-testid":"share-menu-trigger","aria-label":CG,title:CG,className:ie("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(th,{className:"sf:h-4 sf:w-4","aria-hidden":"true"})})}),p.jsxs(aF,{align:"end","data-testid":"share-menu-content",onCloseAutoFocus:S=>{S.preventDefault()},children:[x?p.jsxs(C2,{"data-testid":"share-menu-pdf",disabled:c,onSelect:S=>{S.preventDefault(),g()},children:[c?p.jsx(Nr,{className:"sf:h-4 sf:w-4 sf:animate-spin","aria-hidden":"true"}):p.jsx(O2,{className:"sf:h-4 sf:w-4","aria-hidden":"true"}),p.jsx("span",{children:qJe})]}):null,b?p.jsxs(C2,{"data-testid":"share-menu-png",disabled:u,onSelect:S=>{S.preventDefault(),M()},children:[u?p.jsx(Nr,{className:"sf:h-4 sf:w-4 sf:animate-spin","aria-hidden":"true"}):p.jsx(U2,{className:"sf:h-4 sf:w-4","aria-hidden":"true"}),p.jsx("span",{children:OJe})]}):null,C?p.jsxs(C2,{"data-testid":"share-menu-embed",onSelect:S=>{S.preventDefault(),w(!0)},children:[p.jsx(qu,{className:"sf:h-4 sf:w-4","aria-hidden":"true"}),p.jsx("span",{children:FJe})]}):null,_?p.jsxs(C2,{"data-testid":"share-menu-export-cloud",onSelect:()=>{a==null||a()},children:[p.jsx(oh,{className:"sf:h-4 sf:w-4","aria-hidden":"true"}),p.jsx("span",{children:VJe})]}):null]})]}),C&&t?p.jsx(HJe,{open:v,onOpenChange:w,projectId:t}):null]})}function UJe({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(Nf,{children:[p.jsx(If,{asChild:!0,children:p.jsx(dt,{"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(Nr,{className:"sf:h-4 sf:w-4 sf:animate-spin","aria-hidden":"true"}):p.jsx(Y2,{className:"sf:h-4 sf:w-4","aria-hidden":"true"})})}),p.jsx(q0,{side:"bottom",children:"Restart demo"})]})}const WJe=8;function GJe(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 KJe(e){return e.length>=2}function ZJe({selectedNodes:e,onMultiResize:t,paddingPx:n=WJe}){Wz();const[o,r]=m.useState(null),[a,i]=m.useState(null);if(m.useRef(!1),m.useRef(null),!KJe(e))return null;const s=GJe(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 SG=22,LG=11,NG=3,IG=2,ZT=8,XT=1,AG=["none","default","slate","gray","red","rose","orange","amber","lime","green","teal","cyan","blue","indigo","violet","purple","pink"],zp=[{value:"solid",icon:lz,label:"Solid",testId:"style-tab-border-style-solid"},{value:"dashed",icon:vne,label:"Dashed",testId:"style-tab-border-style-dashed"},{value:"dotted",icon:xne,label:"Dotted",testId:"style-tab-border-style-dotted"}],EG=[{value:"solid",icon:lz,label:"Solid",testId:"style-tab-edge-style-solid"},{value:"dashed",icon:vne,label:"Dashed",testId:"style-tab-edge-style-dashed"},{value:"dotted",icon:xne,label:"Dotted",testId:"style-tab-edge-style-dotted"}],$G=[{value:"curve",icon:wne,label:"Curve",testId:"style-tab-edge-path-curve"},{value:"step",icon:lWe,label:"Zigzag",testId:"style-tab-edge-path-step"}],jG=[{value:"none",icon:G2,label:"None",testId:"style-tab-direction-none"},{value:"backward",icon:Z2,label:"Backward",testId:"style-tab-direction-backward"},{value:"forward",icon:Hu,label:"Forward",testId:"style-tab-direction-forward"},{value:"both",icon:R2,label:"Both",testId:"style-tab-direction-both"}];function XJe({nodes:e,connectors:t,onStyleNode:n,onStyleNodePreview:o,onStyleNodes:r,onStyleNodesPreview:a,onStyleConnector:i,onStyleConnectorPreview:s,onRequestIconReplace:c}){const l=e.length>0,u=t.length>0;if(!l&&!u)return null;const h=l&&!u,f=!l&&u,y=e[0],k=t[0],v=e.filter(W=>W.type!=="icon"),w=v[0],g=h&&e.every(W=>W.type==="icon"),M=g?e.find(W=>W.type==="icon"):void 0,x=h&&e.every(W=>W.type==="image"),b=h&&(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",$=(k==null?void 0:k.style)??"solid",j=(k==null?void 0:k.direction)??"forward",N=(k==null?void 0:k.path)??"curve",A=W=>{for(const G of e)n(G.id,{borderColor:W});for(const G of t)i(G.id,{color:W})},R=W=>{for(const G of e)n(G.id,{backgroundColor:W})},Y=W=>{for(const G of e)n(G.id,{borderStyle:W});for(const G of t)i(G.id,{style:W})},z=W=>{for(const G of e)n(G.id,{borderSize:W});for(const G of t)i(G.id,{borderSize:W})},V=W=>{for(const G of e)o==null||o(G.id,{borderSize:W});for(const G of t)s==null||s(G.id,{borderSize:W})},H=W=>{if(e.length>1&&r)r(e.map(G=>G.id),{fontSize:W});else for(const G of e)n(G.id,{fontSize:W})},O=W=>{if(e.length>1&&a)a(e.map(G=>G.id),{fontSize:W});else for(const G of e)o==null||o(G.id,{fontSize:W})},P=v.length>1&&new Set(v.map(W=>W.data.fontSize??SG)).size>1,I=W=>{if(e.length>1&&r)r(e.map(G=>G.id),{textColor:W});else for(const G of e)n(G.id,{textColor:W})},L=(w==null?void 0:w.data.textColor)??(b?(w==null?void 0:w.data.borderColor)??"default":"default"),U=W=>{for(const G of t)i(G.id,{fontSize:W})},D=W=>{for(const G of t)s==null||s(G.id,{fontSize:W})},E=t.length>1&&new Set(t.map(W=>W.fontSize??LG)).size>1,ee=W=>{for(const G of e)n(G.id,{cornerRadius:W})},J=W=>{for(const G of e)o==null||o(G.id,{cornerRadius:W})},ne=v.length>1&&new Set(v.map(W=>W.data.cornerRadius??ZT)).size>1,oe=W=>{for(const G of e)n(G.id,{shadow:W})},te=W=>{for(const G of e)o==null||o(G.id,{shadow:W})},ce=v.length>1&&new Set(v.map(W=>W.data.shadow??XT)).size>1,ge=W=>{for(const G of t)i(G.id,{path:W})},ae=W=>{for(const G of t)i(G.id,{direction:W})},se=W=>{for(const G of e)n(G.id,{color:W})},re=(M==null?void 0:M.data.color)??"default",Pe=f?(k==null?void 0:k.borderSize)??IG:(w==null?void 0:w.data.borderSize)??NG,Be=f?IG:NG,Ve=f?"edge":"border",ht=f?"Connector color":b?"Color":"Border color",Gt=f?"connector color":b?"color":"border color",Et=f?"style-tab-edge-color-trigger":b?"style-tab-color-trigger":"style-tab-border-color-trigger",hn=f||b?"style-tab-color":"style-tab-border-color";if(g){const W=!!c&&e.length===1&&!!M,G=()=>{M&&c&&c(M.id)};return p.jsx(ch,{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(QJe,{testId:"style-strip-icon-color",tooltip:"Icon color",ariaLabel:"icon color",activeToken:re,previewKind:"edge",tokenTestIdPrefix:"style-tab-icon-color",innerTestId:"style-tab-icon-color-trigger",allowNone:!1,onSelect:se}),W?p.jsxs(Nf,{children:[p.jsx(If,{asChild:!0,children:p.jsx("button",{type:"button","data-testid":"style-strip-change-icon","aria-label":"change icon",title:"Change icon",onClick:G,className:ie("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(Fu,{className:"sf:h-4 sf:w-4"})})}),p.jsx(q0,{side:"right",className:"sf:px-2 sf:py-1 sf:text-xs",children:"Change icon"})]}):null]})})}if(x){const W=e[0],G=(W==null?void 0:W.data.borderColor)??"default",K=(W==null?void 0:W.data.borderStyle)??"solid",qe=(W==null?void 0:W.data.borderWidth)??1,Ze=Qe=>{for(const ct of e)n(ct.id,{borderColor:Qe})},Kt=Qe=>{for(const ct of e)n(ct.id,{borderStyle:Qe})},tn=Qe=>{for(const ct of e)n(ct.id,{borderWidth:Qe})},nn=Qe=>{for(const ct of e)o==null||o(ct.id,{borderWidth:Qe})},Hn=Qe=>{for(const ct of e)n(ct.id,{cornerRadius:Qe})},Cn=Qe=>{for(const ct of e)o==null||o(ct.id,{cornerRadius:Qe})},Tt=Qe=>{for(const ct of e)n(ct.id,{shadow:Qe})},Ne=Qe=>{for(const ct of e)o==null||o(ct.id,{shadow:Qe})},ze=()=>{const Qe=G==="none";return p.jsx("span",{className:ie("sf:relative sf:h-5 sf:w-5 sf:rounded-full",Qe&&"sf:bg-card"),style:Qe?void 0:hh(G),children:Qe?p.jsx(fh,{}):null})};return p.jsx(ch,{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(ao,{testId:"style-strip-image-border-color-button",tooltip:"Border color",ariaLabel:"image border color",renderIcon:ze,children:p.jsx(S2,{testId:"style-strip-image-border-color",activeToken:G,previewKind:"border",tokenTestIdPrefix:"style-tab-image-border-color",innerTestId:"style-tab-image-border-color-trigger",ariaLabel:"image border color",onSelect:Ze})}),p.jsx(ao,{testId:"style-strip-image-corner-radius-button",tooltip:"Corners",ariaLabel:"image corners",renderIcon:()=>p.jsx(Ou,{className:"sf:h-4 sf:w-4"}),children:p.jsx("div",{"data-testid":"style-strip-image-corner-radius",children:p.jsx(Ji,{value:W==null?void 0:W.data.cornerRadius,defaultValue:ZT,min:0,max:32,suffix:"px",onPreview:Cn,onCommit:Hn,testId:"style-tab-image-corner-radius-slider"})})}),p.jsx(ao,{testId:"style-strip-image-shadow-button",tooltip:"Shadow",ariaLabel:"image shadow",renderIcon:()=>p.jsx(sa,{className:"sf:h-4 sf:w-4"}),children:p.jsx("div",{"data-testid":"style-strip-image-shadow",children:p.jsx(Ji,{value:W==null?void 0:W.data.shadow,defaultValue:XT,min:0,max:5,onPreview:Ne,onCommit:Tt,testId:"style-tab-image-shadow-slider"})})}),p.jsx(ao,{testId:"style-strip-image-border-style",tooltip:"Border style",ariaLabel:"image border style",renderIcon:()=>{var ct;const Qe=((ct=zp.find(ir=>ir.value===K))==null?void 0:ct.icon)??lz;return p.jsx(Qe,{className:"sf:h-4 sf:w-4"})},children:p.jsx(d2,{ariaLabel:"Border style",value:K,onChange:Kt,options:zp})}),p.jsx(ao,{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:qe}),children:p.jsx(Ji,{value:W==null?void 0:W.data.borderWidth,defaultValue:1,min:0,max:8,suffix:"px",onPreview:nn,onCommit:tn,testId:"style-tab-image-border-width-slider"})})]})})}const fe=h&&!b,Se=!b,fn=!f,pn=()=>{const W=C==="none";return p.jsx("span",{className:ie("sf:relative sf:h-5 sf:w-5 sf:rounded-full",W&&"sf:bg-card"),style:W?void 0:hh(C),children:W?p.jsx(fh,{}):null})},sn=()=>{const W=_==="none";return p.jsx("span",{className:ie("sf:relative sf:h-5 sf:w-5 sf:rounded-full",W&&"sf:bg-card"),style:W?void 0:hh(_),children:W?p.jsx(fh,{}):null})};return p.jsx(ch,{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(ao,{testId:"style-strip-border-color-button",tooltip:ht,ariaLabel:Gt,renderIcon:pn,children:p.jsx(S2,{testId:"style-strip-border-color",activeToken:C,previewKind:Ve,tokenTestIdPrefix:hn,innerTestId:Et,ariaLabel:Gt,allowNone:!f,onSelect:A})}),fe?p.jsx(ao,{testId:"style-strip-fill-button",tooltip:"Fill",ariaLabel:"fill",renderIcon:sn,children:p.jsx(S2,{testId:"style-strip-fill",activeToken:_,previewKind:"background",tokenTestIdPrefix:"style-tab-background-color",innerTestId:"style-tab-background-color-trigger",ariaLabel:"fill",onSelect:R})}):null,l?p.jsx(ao,{testId:"style-strip-corner-radius-button",tooltip:"Corners",ariaLabel:"corners",renderIcon:()=>p.jsx(Ou,{className:"sf:h-4 sf:w-4"}),children:p.jsx("div",{"data-testid":"style-strip-corner-radius",children:p.jsx(Ji,{value:w==null?void 0:w.data.cornerRadius,defaultValue:ZT,min:0,max:32,suffix:"px",indeterminate:ne,onPreview:J,onCommit:ee,testId:"style-tab-corner-radius-slider"})})}):null,l?p.jsx(ao,{testId:"style-strip-shadow-button",tooltip:"Shadow",ariaLabel:"shadow",renderIcon:()=>p.jsx(sa,{className:"sf:h-4 sf:w-4"}),children:p.jsx("div",{"data-testid":"style-strip-shadow",children:p.jsx(Ji,{value:w==null?void 0:w.data.shadow,defaultValue:XT,min:0,max:5,indeterminate:ce,onPreview:te,onCommit:oe,testId:"style-tab-shadow-slider"})})}):null,Se?p.jsx(ao,{testId:"style-strip-border",tooltip:f?"Connector":"Border",ariaLabel:f?"connector":"border",renderIcon:()=>{var G,K;const W=(f?(G=EG.find(qe=>qe.value===$))==null?void 0:G.icon:(K=zp.find(qe=>qe.value===S))==null?void 0:K.icon)??lz;return p.jsx(W,{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(Rp,{label:"Style",testId:"style-strip-border-style",children:f?p.jsx(d2,{ariaLabel:"Connector style",value:$,onChange:W=>Y(W),options:EG}):p.jsx(d2,{ariaLabel:"Border style",value:S,onChange:W=>Y(W),options:zp})}),p.jsx(Rp,{label:"Width",testId:"style-strip-border-size",children:p.jsx(Ji,{value:Pe,defaultValue:Be,min:0,max:8,suffix:"px",onPreview:V,onCommit:z,testId:f?"style-tab-stroke-width-slider":"style-tab-border-size-slider"})})]})}):null,l||f?p.jsx(ao,{testId:"style-strip-text",tooltip:"Text",ariaLabel:"text",renderIcon:()=>p.jsx(Vu,{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(Rp,{label:"Size",testId:f?"style-strip-connector-font-size":"style-strip-font-size",children:p.jsx(Ji,{value:f?k==null?void 0:k.fontSize:w==null?void 0:w.data.fontSize,defaultValue:f?LG:SG,min:f?8:10,max:32,suffix:"px",indeterminate:f?E:P,onPreview:f?D:O,onCommit:f?U:H,testId:f?"style-tab-connector-font-size-slider":"style-tab-font-size-slider"})}),fn?p.jsx(Rp,{label:"Color",children:p.jsx(S2,{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:I})}):null]})}):null,f?p.jsx(ao,{testId:"style-strip-path",tooltip:"Connector path",ariaLabel:"connector path",renderIcon:()=>{var G;const W=((G=$G.find(K=>K.value===N))==null?void 0:G.icon)??wne;return p.jsx(W,{className:"sf:h-4 sf:w-4"})},children:p.jsx(d2,{ariaLabel:"Connector path",value:N,onChange:ge,options:$G})}):null,f?p.jsx(ao,{testId:"style-strip-direction",tooltip:"Direction",ariaLabel:"direction",renderIcon:()=>{var G;const W=((G=jG.find(K=>K.value===j))==null?void 0:G.icon)??Hu;return p.jsx(W,{className:"sf:h-4 sf:w-4"})},children:p.jsx(d2,{ariaLabel:"Connector direction",value:j,onChange:ae,options:jG})}):null]})})}function hh(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:qse[e].edge}}function fh(){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 YJe({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:ie("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:hh(e),children:[a?p.jsx(fh,{}):null,t&&!a?p.jsx(fd,{className:"sf:h-2.5 sf:w-2.5 sf:drop-shadow-sm",style:{color:"hsl(var(--foreground))"}}):null]})}function QJe({testId:e,tooltip:t,ariaLabel:n,activeToken:o,previewKind:r,tokenTestIdPrefix:a,innerTestId:i,allowNone:s,onSelect:c}){const[l,u]=m.useState(!1),h=o==="none";return p.jsxs(Rd,{open:l,onOpenChange:u,children:[p.jsxs(Nf,{children:[p.jsx(If,{asChild:!0,children:p.jsx(D0,{asChild:!0,children:p.jsx("button",{type:"button","data-testid":e,"data-active-token":o,"aria-label":`${n}: ${o}`,title:t,className:ie("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:ie("sf:relative sf:h-5 sf:w-5 sf:rounded-full",h&&"sf:bg-card"),style:h?void 0:hh(o),children:h?p.jsx(fh,{}):null})})})}),p.jsx(q0,{side:"right",className:"sf:px-2 sf:py-1 sf:text-xs",children:t})]}),p.jsx(zi,{side:"right",align:"start",className:"sf:w-auto sf:p-1.5","data-testid":`${i}-popover`,children:p.jsx(S2,{testId:`${a}-grid`,activeToken:o,previewKind:r,tokenTestIdPrefix:a,innerTestId:i,ariaLabel:n,allowNone:s,onSelect:f=>{c(f),u(!1)}})})]})}function S2({testId:e,activeToken:t,previewKind:n,tokenTestIdPrefix:o,innerTestId:r,ariaLabel:a,allowNone:i,onSelect:s}){const c=i===!1?AG.filter(l=>l!=="none"):AG;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(YJe,{token:l,isActive:t===l,onClick:()=>s(l),testId:`${o}-${l}`,ariaLabel:`${a} ${l}`},l))})}function Rp({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 ao({testId:e,tooltip:t,ariaLabel:n,renderIcon:o,children:r}){const[a,i]=m.useState(!1);return p.jsxs(Rd,{open:a,onOpenChange:i,children:[p.jsxs(Nf,{children:[p.jsx(If,{asChild:!0,children:p.jsx(D0,{asChild:!0,children:p.jsx("button",{type:"button","data-testid":e,"aria-label":n,title:t,className:ie("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(q0,{side:"right",className:"sf:px-2 sf:py-1 sf:text-xs",children:t})]}),p.jsx(zi,{side:"right",align:"start",className:"sf:w-auto sf:p-3",children:r})]})}function Ji({value:e,defaultValue:t,min:n,max:o,suffix:r,indeterminate:a,onPreview:i,onCommit:s,testId:c}){const l=e??t,[u,h]=m.useState(l),[f,y]=m.useState(!1);m.useEffect(()=>{h(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(bO,{min:n,max:o,step:1,value:[u],onValueChange:([v])=>{const w=v??n;h(w),y(!0),i==null||i(w)},onValueCommit:([v])=>s(v??n),"data-testid":c,"data-indeterminate":k?"true":void 0,className:ie("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:[u,r]})})]})}function JJe(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 eet=(()=>{let e=0;const t=()=>`0000${(Math.random()*36**4<<0).toString(36)}`.slice(-4);return()=>(e+=1,`u${t()}${e}`)})();function Mi(e){const t=[];for(let n=0,o=e.length;n<o;n++)t.push(e[n]);return t}let uu=null;function Boe(e={}){return uu||(e.includeStyleProperties?(uu=e.includeStyleProperties,uu):(uu=Mi(window.getComputedStyle(document.documentElement)),uu))}function pz(e,t){const o=(e.ownerDocument.defaultView||window).getComputedStyle(e).getPropertyValue(t);return o?parseFloat(o.replace("px","")):0}function tet(e){const t=pz(e,"border-left-width"),n=pz(e,"border-right-width");return e.clientWidth+t+n}function net(e){const t=pz(e,"border-top-width"),n=pz(e,"border-bottom-width");return e.clientHeight+t+n}function Uoe(e,t={}){const n=t.width||tet(e),o=t.height||net(e);return{width:n,height:o}}function oet(){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 io=16384;function ret(e){(e.width>io||e.height>io)&&(e.width>io&&e.height>io?e.width>e.height?(e.height*=io/e.width,e.width=io):(e.width*=io/e.height,e.height=io):e.width>io?(e.height*=io/e.width,e.width=io):(e.width*=io/e.height,e.height=io))}function yz(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 aet(e){return Promise.resolve().then(()=>new XMLSerializer().serializeToString(e)).then(encodeURIComponent).then(t=>`data:image/svg+xml;charset=utf-8,${t}`)}async function iet(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),aet(r)}const Jn=(e,t)=>{if(e instanceof t)return!0;const n=Object.getPrototypeOf(e);return n===null?!1:n.constructor.name===t.name||Jn(n,t)};function set(e){const t=e.getPropertyValue("content");return`${e.cssText} content: '${t.replace(/'|"/g,"")}';`}function cet(e,t){return Boe(t).map(n=>{const o=e.getPropertyValue(n),r=e.getPropertyPriority(n);return`${n}: ${o}${r?" !important":""};`}).join(" ")}function det(e,t,n,o){const r=`.${e}:${t}`,a=n.cssText?set(n):cet(n,o);return document.createTextNode(`${r}{${a}}`)}function PG(e,t,n,o){const r=window.getComputedStyle(e,n),a=r.getPropertyValue("content");if(a===""||a==="none")return;const i=eet();try{t.className=`${t.className} ${i}`}catch{return}const s=document.createElement("style");s.appendChild(det(i,n,r,o)),t.appendChild(s)}function uet(e,t,n){PG(e,t,":before",n),PG(e,t,":after",n)}const zG="application/font-woff",RG="image/jpeg",het={woff:zG,woff2:zG,ttf:"application/font-truetype",eot:"application/vnd.ms-fontobject",png:"image/png",jpg:RG,jpeg:RG,gif:"image/gif",tiff:"image/tiff",svg:"image/svg+xml",webp:"image/webp"};function fet(e){const t=/\.([^./]*?)$/g.exec(e);return t?t[1]:""}function NF(e){const t=fet(e).toLowerCase();return het[t]||""}function pet(e){return e.split(/,/)[1]}function QH(e){return e.search(/^(data:)/)!==-1}function yet(e,t){return`data:${t};base64,${e}`}async function Woe(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 YT={};function met(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 IF(e,t,n){const o=met(e,t,n.includeQueryParams);if(YT[o]!=null)return YT[o];n.cacheBust&&(e+=(/\?/.test(e)?"&":"?")+new Date().getTime());let r;try{const a=await Woe(e,n.fetchRequestInit,({res:i,result:s})=>(t||(t=i.headers.get("Content-Type")||""),pet(s)));r=yet(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 YT[o]=r,r}async function ket(e){const t=e.toDataURL();return t==="data:,"?e.cloneNode(!1):yz(t)}async function get(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 yz(s)}const n=e.poster,o=NF(n),r=await IF(n,o,t);return yz(r)}async function vet(e,t){var n;try{if(!((n=e==null?void 0:e.contentDocument)===null||n===void 0)&&n.body)return await CR(e.contentDocument.body,t,!0)}catch{}return e.cloneNode(!1)}async function xet(e,t){return Jn(e,HTMLCanvasElement)?ket(e):Jn(e,HTMLVideoElement)?get(e,t):Jn(e,HTMLIFrameElement)?vet(e,t):e.cloneNode(Goe(e))}const wet=e=>e.tagName!=null&&e.tagName.toUpperCase()==="SLOT",Goe=e=>e.tagName!=null&&e.tagName.toUpperCase()==="SVG";async function Met(e,t,n){var o,r;if(Goe(t))return t;let a=[];return wet(e)&&e.assignedNodes?a=Mi(e.assignedNodes()):Jn(e,HTMLIFrameElement)&&(!((o=e.contentDocument)===null||o===void 0)&&o.body)?a=Mi(e.contentDocument.body.childNodes):a=Mi(((r=e.shadowRoot)!==null&&r!==void 0?r:e).childNodes),a.length===0||Jn(e,HTMLVideoElement)||await a.reduce((i,s)=>i.then(()=>CR(s,n)).then(c=>{c&&t.appendChild(c)}),Promise.resolve()),t}function bet(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):Boe(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`),Jn(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 _et(e,t){Jn(e,HTMLTextAreaElement)&&(t.innerHTML=e.value),Jn(e,HTMLInputElement)&&t.setAttribute("value",e.value)}function Cet(e,t){if(Jn(e,HTMLSelectElement)){const n=t,o=Array.from(n.children).find(r=>e.value===r.getAttribute("value"));o&&o.setAttribute("selected","")}}function Let(e,t,n){return Jn(t,Element)&&(bet(e,t,n),uet(e,t,n),_et(e,t),Cet(e,t)),t}async function Net(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 CR(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 CR(e,t,n){return!n&&t.filter&&!t.filter(e)?null:Promise.resolve(e).then(o=>xet(o,t)).then(o=>Met(e,o,t)).then(o=>Let(e,o,t)).then(o=>Net(o,t))}const Koe=/url\((['"]?)([^'"]+?)\1\)/g,Iet=/url\([^)]+\)\s*format\((["']?)([^"']+)\1\)/g,Aet=/src:\s*(?:url\([^)]+\)\s*format\([^)]+\)[,;]\s*)+/g;function Eet(e){const t=e.replace(/([.*+?^${}()|\[\]\/\\])/g,"\\$1");return new RegExp(`(url\\(['"]?)(${t})(['"]?\\))`,"g")}function $et(e){const t=[];return e.replace(Koe,(n,o,r)=>(t.push(r),n)),t.filter(n=>!QH(n))}async function jet(e,t,n,o,r){try{const a=n?JJe(t,n):t,i=NF(t);let s;return r||(s=await IF(a,i,o)),e.replace(Eet(t),`$1${s}$3`)}catch{}return e}function Pet(e,{preferredFontFormat:t}){return t?e.replace(Aet,n=>{for(;;){const[o,,r]=Iet.exec(n)||[];if(!r)return"";if(r===t)return`src: ${o};`}}):e}function Zoe(e){return e.search(Koe)!==-1}async function Xoe(e,t,n){if(!Zoe(e))return e;const o=Pet(e,n);return $et(o).reduce((a,i)=>a.then(s=>jet(s,i,t,n)),Promise.resolve(o))}async function hu(e,t,n){var o;const r=(o=t.style)===null||o===void 0?void 0:o.getPropertyValue(e);if(r){const a=await Xoe(r,null,n);return t.style.setProperty(e,a,t.style.getPropertyPriority(e)),!0}return!1}async function zet(e,t){await hu("background",e,t)||await hu("background-image",e,t),await hu("mask",e,t)||await hu("-webkit-mask",e,t)||await hu("mask-image",e,t)||await hu("-webkit-mask-image",e,t)}async function Ret(e,t){const n=Jn(e,HTMLImageElement);if(!(n&&!QH(e.src))&&!(Jn(e,SVGImageElement)&&!QH(e.href.baseVal)))return;const o=n?e.src:e.href.baseVal,r=await IF(o,NF(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 Tet(e,t){const o=Mi(e.childNodes).map(r=>Yoe(r,t));await Promise.all(o).then(()=>e)}async function Yoe(e,t){Jn(e,Element)&&(await zet(e,t),await Ret(e,t),await Tet(e,t))}function Det(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 TG={};async function DG(e){let t=TG[e];if(t!=null)return t;const o=await(await fetch(e)).text();return t={url:e,cssText:o},TG[e]=t,t}async function HG(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),Woe(s,t.fetchRequestInit,({result:c})=>(n=n.replace(i,`url(${c})`),[i,c]))});return Promise.all(a).then(()=>n)}function qG(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 Het(e,t){const n=[],o=[];return e.forEach(r=>{if("cssRules"in r)try{Mi(r.cssRules||[]).forEach((a,i)=>{if(a.type===CSSRule.IMPORT_RULE){let s=i+1;const c=a.href,l=DG(c).then(u=>HG(u,t)).then(u=>qG(u).forEach(h=>{try{r.insertRule(h,h.startsWith("@import")?s+=1:r.cssRules.length)}catch(f){console.error("Error inserting rule from remote css",{rule:h,error:f})}})).catch(u=>{console.error("Error loading remote css",u.toString())});o.push(l)}})}catch(a){const i=e.find(s=>s.href==null)||document.styleSheets[0];r.href!=null&&o.push(DG(r.href).then(s=>HG(s,t)).then(s=>qG(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{Mi(r.cssRules||[]).forEach(a=>{n.push(a)})}catch(a){console.error(`Error while reading CSS rules from ${r.href}`,a)}}),n))}function qet(e){return e.filter(t=>t.type===CSSRule.FONT_FACE_RULE).filter(t=>Zoe(t.style.getPropertyValue("src")))}async function Oet(e,t){if(e.ownerDocument==null)throw new Error("Provided element is not within a Document");const n=Mi(e.ownerDocument.styleSheets),o=await Het(n,t);return qet(o)}function Qoe(e){return e.trim().replace(/["']/g,"")}function Fet(e){const t=new Set;function n(o){(o.style.fontFamily||getComputedStyle(o).fontFamily).split(",").forEach(a=>{t.add(Qoe(a))}),Array.from(o.children).forEach(a=>{a instanceof HTMLElement&&n(a)})}return n(e),t}async function Vet(e,t){const n=await Oet(e,t),o=Fet(e);return(await Promise.all(n.filter(a=>o.has(Qoe(a.style.fontFamily))).map(a=>{const i=a.parentStyleSheet?a.parentStyleSheet.href:null;return Xoe(a.cssText,i,t)}))).join(`
|
|
8544
|
-
`)}async function Bet(e,t){const n=t.fontEmbedCSS!=null?t.fontEmbedCSS:t.skipFonts?null:await Vet(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 Uet(e,t={}){const{width:n,height:o}=Uoe(e,t),r=await CR(e,t,!0);return await Bet(r,t),await Yoe(r,t),Det(r,t),await iet(r,n,o)}async function Wet(e,t={}){const{width:n,height:o}=Uoe(e,t),r=await Uet(e,t),a=await yz(r),i=document.createElement("canvas"),s=i.getContext("2d"),c=t.pixelRatio||oet(),l=t.canvasWidth||n,u=t.canvasHeight||o;return i.width=l*c,i.height=u*c,t.skipAutoScale||ret(i),i.style.width=`${l}`,i.style.height=`${u}`,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 Get(e,t={}){return(await Wet(e,t)).toDataURL()}const Ket=e=>e instanceof Element?!(e.classList.contains("react-flow__minimap")||e.classList.contains("react-flow__controls")||e.classList.contains("react-flow__panel")):!0,Zet=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"},Xet=async e=>{const t=await Get(e,{cacheBust:!0,filter:Ket,backgroundColor:Zet(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}},Yet=(e,t)=>{const n=document.createElement("a");n.href=e,n.download=t,n.rel="noopener",document.body.appendChild(n),n.click(),n.remove()},Qet=e=>{const t=e.replace(/[^A-Za-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"");return t.length>0?t.slice(0,80):"canvas"},OG=(e,t)=>`${Qet(e??"canvas")}.${t}`,Jet=({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 u=document.querySelector(".react-flow__viewport");if(!u)return null;const h=l.getViewport();try{return await l.fitView({duration:0,padding:.1}),await new Promise(f=>requestAnimationFrame(()=>f())),await Xet(u)}finally{l.setViewport(h,{duration:0})}},[t]),i=m.useCallback(async()=>{o(null);try{const l=await a();if(!l)return;Yet(l.dataUrl,OG(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:u}=await ff(async()=>{const{jsPDF:y}=await import("./jspdf.es.min-CfPjY_mb.js").then(k=>k.j);return{jsPDF:y}},[]),h=l.width>l.height?"landscape":"portrait",f=new u({orientation:h,unit:"px",format:[l.width,l.height],hotfixes:["px_scaling"]});f.addImage(l.dataUrl,"PNG",0,0,l.width,l.height),f.save(OG(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}},ett=12,ttt=1200;function ntt(e,t={}){const n=t.idleMs??ttt;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 v=e.getBoundingClientRect();e.style.setProperty("--mx",`${y-v.left}px`),e.style.setProperty("--my",`${k-v.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 ott(){const e=m.useRef(null),t=He(i=>i.transform,(i,s)=>i[0]===s[0]&&i[1]===s[1]&&i[2]===s[2]),[n,o,r]=t,a=ett*r;return m.useEffect(()=>{var h;const i=e.current;if(!i)return;const s=(h=i.parentElement)==null?void 0:h.querySelector(".react-flow__pane");if(!s)return;const{onMove:c,onLeave:l,dispose:u}=ntt(i);return s.addEventListener("mousemove",c,{passive:!0}),s.addEventListener("mouseleave",l,{passive:!0}),()=>{s.removeEventListener("mousemove",c),s.removeEventListener("mouseleave",l),u()}},[]),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 rtt={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},att={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},itt={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 stt(e){const t=e.mode==="edit"?rtt:e.mode==="mini"?itt:att;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 FG=40,f2={padding:.15,duration:300,includeHiddenNodes:!1};function ctt(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 VG=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},ltt=(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},Joe=15,QT=(e,t,n)=>{const o=ltt(t,n);if(o)return o;if(!e)return null;let r=null,a=Joe;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),u=Math.max(c.top-n,0,n-c.bottom),h=Math.hypot(l,u);h<=a&&(r=s,a=h)}return r};function BG(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 u=c.measured.width??c.width??0,h=c.measured.height??c.height??0,f=l.measured.width??l.width??0,y=l.measured.height??l.height??0;if(u===0||h===0||f===0||y===0)return;const k={x:c.internals.positionAbsolute.x,y:c.internals.positionAbsolute.y,w:u,h},v={x:l.internals.positionAbsolute.x+f/2,y:l.internals.positionAbsolute.y+y/2};return pTe(k,WP(k,v))}function dtt(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 utt=(e,t)=>{if(!t)return e;const n=t.data?{...e.data,...t.data}:e.data;return{...e,...t,data:n}},htt=(e,t)=>t?{...e,...t}:e,ftt={rectangle:kVe,ellipse:Za,sticky:Za,text:Za,database:Za,server:Za,user:Za,queue:Za,cloud:Za,image:uVe,icon:CTe,html:iVe,component:jFe},ptt={editableEdge:xVe},ytt={zIndex:0},mtt={hideAttribution:!0},ktt=8,UG=(e,t)=>e?typeof e=="string"?`url('#${e}')`:`url('#${`${t?`${t}__`:""}${Object.keys(e).sort().map(r=>`${r}=${e[r]}`).join("&")}`}')`:void 0,gtt=e=>function({fromX:n,fromY:o,toX:r,toY:a,fromPosition:i,toPosition:s,connectionLineStyle:c}){const l=He(U=>e.current?U.edges.find(D=>D.reconnectable===!0)??null:null),u=l==null?void 0:l.data,h=He(U=>{var E;const D=U.connection;return((E=D==null?void 0:D.fromHandle)==null?void 0:E.nodeId)??null}),f=He(U=>l!=null&&l.source?U.nodeLookup.get(l.source)??null:null),y=He(U=>l!=null&&l.target?U.nodeLookup.get(l.target)??null:null),k=He(U=>h?U.nodeLookup.get(h)??null:null),v=(l==null?void 0:l.source)===h,w=l?v?f:y:k,g=v?y:f,M=v?u==null?void 0:u.sourcePin:u==null?void 0:u.targetPin,x=v?u==null?void 0:u.sourceHandleAutoPicked:u==null?void 0:u.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 ee=null;if(M)ee=GP(E,M);else if(x!==!1&&g){const J=g.measured.width??g.width??0,ne=g.measured.height??g.height??0;if(J>0&&ne>0){const oe={x:g.internals.positionAbsolute.x+J/2,y:g.internals.positionAbsolute.y+ne/2};ee=WP(E,oe)}}ee&&(b=ee.x,C=ee.y,_=WG[ee.side])}}const S=He(U=>U.transform[2]),$=He(U=>U.nodeLookup),j=He(U=>{var D;return((D=U.connection.toHandle)==null?void 0:D.nodeId)??null});let N=r,A=a,R=s;if(S>0){const U=Joe/S,D=l?v?l.target:l.source:null;let E=null;if(j&&j!==D){const ee=$.get(j)??null;ee&&(E=ee)}if(!E){let ee=U;for(const J of $.values()){if(D&&J.id===D||w&&J.id===w.id)continue;const ne=J.measured.width??J.width??0,oe=J.measured.height??J.height??0;if(ne===0||oe===0)continue;const te=J.internals.positionAbsolute.x,ce=J.internals.positionAbsolute.y,ge=Math.max(te-r,0,r-(te+ne)),ae=Math.max(ce-a,0,a-(ce+oe)),se=Math.hypot(ge,ae);se<=ee&&(ee=se,E=J)}}if(!E&&l&&w){const ee=w.measured.width??w.width??0,J=w.measured.height??w.height??0;if(ee>0&&J>0){const ne=w.internals.positionAbsolute.x,oe=w.internals.positionAbsolute.y,te=Math.max(ne-r,0,r-(ne+ee)),ce=Math.max(oe-a,0,a-(oe+J));Math.hypot(te,ce)<=U&&(E=w)}}if(E){const ee=E.measured.width??E.width??0,J=E.measured.height??E.height??0;if(ee>0&&J>0){const ne=hH({x:E.internals.positionAbsolute.x,y:E.internals.positionAbsolute.y,w:ee,h:J},{x:r,y:a}),oe=GP({x:E.internals.positionAbsolute.x,y:E.internals.positionAbsolute.y,w:ee,h:J},ne);N=oe.x,A=oe.y,R=WG[oe.side]}}}const Y=(u==null?void 0:u.path)==="step",[z]=Y?qh({sourceX:b,sourceY:C,sourcePosition:_,targetX:N,targetY:A,targetPosition:R,borderRadius:ktt}):Fz({sourceX:b,sourceY:C,sourcePosition:_,targetX:N,targetY:A,targetPosition:R}),V=(l==null?void 0:l.style)??c??void 0,H=He(U=>U.rfId),O=v?l==null?void 0:l.markerStart:l==null?void 0:l.markerEnd,P=v?l==null?void 0:l.markerEnd:l==null?void 0:l.markerStart,I=UG(O,H),L=UG(P,H);return p.jsx("path",{d:z,fill:"none",className:"react-flow__connection-path",style:V,markerStart:I,markerEnd:L})},WG={top:me.Top,right:me.Right,bottom:me.Bottom,left:me.Left};function vtt({storeApiRef:e}){const t=Mt();return m.useEffect(()=>(e.current=t,()=>{e.current===t&&(e.current=null)}),[t,e]),null}function xtt({wrapperRef:e}){const t=He(o=>o.transform[2]),n=e.current;return n&&n.style.setProperty("--rf-zoom",String(t)),null}const wtt=new Set(["INPUT","TEXTAREA","SELECT"]),ere=e=>e?wtt.has(e.tagName)?!0:e instanceof HTMLElement&&e.isContentEditable:!1;function Mtt(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"||ere(r)?!1:s==="c"?n.length===0||!a?!1:(t.preventDefault(),a([...n]),!0):!o||!i?!1:(t.preventDefault(),i(),!0)}const GG=(e,t)=>{var n;return((n=e==null?void 0:e[t])==null?void 0:n.status)??"idle"},btt=(e,t)=>{var n;return(n=e==null?void 0:e[t])==null?void 0:n.status},_tt=(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 Ctt(e,t){var UF,WF;const{mode:n,adapter:o,topLeftSlot:r,projectId:a,flowSlug:i,fileBaseUrl:s,apiBaseUrl:c="/api",nodes:l,connectors:u,selectedNodeIds:h,selectedConnectorIds:f,onSelectionChange:y,runtime:k,onPlayNode:v,onNodePositionChange:w,onNodePositionsChange:g,onNodeResize:M,onNodeResizeEnd:x,onHtmlNodeFitToContent:b,onComponentNodeFitToContent:C,onMultiResize:_,onNodeNameChange:S,onNodeDescriptionChange:$,onConnectorLabelChange:j,onCreateShapeNode:N,onCreateImageFromFile:A,onRetryImageUpload:R,onCreateHtmlNode:Y,onCreateConnector:z,onReconnectConnector:V,onReorderNode:H,onDeleteNode:O,onCopyNode:P,onPasteAt:I,hasClipboard:L,onCopySelection:U,onPasteSelection:D,selectedNodes:E,selectedConnectors:ee,onStyleNode:J,onStyleNodePreview:ne,onStyleNodes:oe,onStyleNodesPreview:te,onStyleConnector:ce,onStyleConnectorPreview:ge,onRfInit:ae,onTidy:se,onNodeClick:re,onConnectorClick:Pe,onPaneClick:Be,onCreateAndConnectFromPane:Ve,pendingEditNodeId:ht,iconPickerOpen:Gt,onOpenIconPicker:Et,onCloseIconPicker:hn,onPickIcon:fe,onRequestIconReplace:Se,onPinEndpoint:fn,onUnpinEndpoint:pn,canvasMode:sn,onCanvasModeChange:W,disableSidebar:G,statusReport:K,onNameChange:qe,onDescriptionChange:Ze,onDetailChange:Kt,onIconChange:tn,autoFitView:nn,autoFitViewSignal:Hn,customIcons:Cn,onExportToCloud:Tt,onRestartDemo:Ne,onNodeDragStart:ze,onNodeDragStop:Qe,onViewportChange:ct,showToolbar:ir,showStyleStrip:qd,showDetailPanel:Od,showStatusBadges:Oi,showResizeHandles:Fd,showControls:$t,showShareMenu:Ft,showMiniMap:Vd,showRestart:Bd,enableKeyboard:Ud,enableContextMenu:Wd,enableDragDrop:Gd,enableImageDrop:Kd,enableZoom:La,enablePan:Na,enableSelection:sr,enableNodeMove:Fi,enableEmbed:Ia}=e,De=m.useMemo(()=>stt({mode:n,showToolbar:ir,showStyleStrip:qd,showDetailPanel:Od,showStatusBadges:Oi,showResizeHandles:Fd,showControls:$t,showShareMenu:Ft,showMiniMap:Vd,showRestart:Bd,enableKeyboard:Ud,enableContextMenu:Wd,enableDragDrop:Gd,enableImageDrop:Kd,enableZoom:La,enablePan:Na,enableSelection:sr,enableNodeMove:Fi,enableEmbed:Ia}),[n,ir,qd,Od,Oi,Fd,$t,Ft,Vd,Bd,Ud,Wd,Gd,Kd,La,Na,sr,Fi,Ia]),vt=n==="edit",no=m.useRef(De);m.useEffect(()=>{no.current=De},[De]);const Vi=nn??(n==="mini"?!0:void 0),cr=m.useMemo(()=>ctt(Vi),[Vi]),Sn=k==null?void 0:k.runs,Ro=k==null?void 0:k.statuses,Ln=(UF=k==null?void 0:k.pendingOverrides)==null?void 0:UF.nodes,qn=(WF=k==null?void 0:k.pendingOverrides)==null?void 0:WF.connectors,Zt=m.useRef(null),Xt=m.useRef(null),lr=m.useRef(!1),Bi=m.useRef(!1),Zd=m.useRef(!1),Xd=m.useRef(cr);Xd.current=cr,m.useEffect(()=>{if(lr.current||!cr.onMount||l.length===0)return;const X=Xt.current;X&&(X.fitView(f2),lr.current=!0)},[l,cr.onMount]);const Ui=m.useRef(null),jt=sn.kind==="draw"?sn.shape:null,oo=sn.kind==="hand",Wr=m.useRef(new Map),Aa=m.useCallback((X,Q)=>(Wr.current.set(X,Q),()=>{Wr.current.get(X)===Q&&Wr.current.delete(X)}),[]),[bo,Gr]=m.useState(!1),Yd=m.useRef(!1);m.useEffect(()=>{Yd.current=bo},[bo]);const _o=m.useRef(!1),Ea=m.useRef(!1),To=m.useRef(!1),[yn,Kr]=m.useState(null),dr=m.useRef(null);m.useEffect(()=>{dr.current=yn},[yn]),m.useCallback(()=>{Kr(null)},[]);const V0=m.useMemo(()=>gtt(To),[]),Zr=m.useRef(null),Qd=m.useRef(null),$a=m.useCallback(X=>{const Q=Zt.current;if(!Q){Zr.current=X;return}const le=Zr.current;if(le&&le!==X){const ue=Q.querySelector(`.react-flow__node[data-id="${CSS.escape(le)}"]`);ue==null||ue.removeAttribute("data-connect-source")}if(X){const ue=Q.querySelector(`.react-flow__node[data-id="${CSS.escape(X)}"]`);ue==null||ue.setAttribute("data-connect-source","true")}Zr.current=X},[]),Nn=m.useCallback(X=>{const Q=Zt.current,le=Qd.current;if(le!==X){if(Q&&le){const ue=Q.querySelector(`.react-flow__node[data-id="${CSS.escape(le)}"]`);ue==null||ue.removeAttribute("data-connect-target")}if(Q&&X){const ue=Q.querySelector(`.react-flow__node[data-id="${CSS.escape(X)}"]`);ue==null||ue.setAttribute("data-connect-target","true")}Qd.current=X}},[]),Xr=m.useCallback(()=>{$a(null),Nn(null)},[$a,Nn]);m.useEffect(()=>{if(!bo){Nn(null);return}let X=null,Q=null;const le=()=>{X=null;const he=Q;if(Q=null,!he)return;const Ee=QT(Zt.current,he.clientX,he.clientY),ve=(Ee==null?void 0:Ee.getAttribute("data-id"))??null;if(ve&&ve===Zr.current){Nn(null);return}Nn(ve)},ue=he=>{Q={clientX:he.clientX,clientY:he.clientY},X===null&&(X=requestAnimationFrame(le))};return document.addEventListener("pointermove",ue,{passive:!0}),()=>{document.removeEventListener("pointermove",ue),X!==null&&cancelAnimationFrame(X)}},[bo,Nn]);const[Do,On]=m.useState(null),[Fn,Ho]=m.useState(null),ja=m.useRef(null),Pa=m.useRef(null),Wi=m.useRef(null),za=m.useRef(!1);m.useEffect(()=>{ja.current=jt},[jt]);const Jd=m.useCallback(()=>{W({kind:"select"}),On(null),Ho(null),ja.current=null,Pa.current=null,Wi.current=null,za.current=!1},[W]);m.useEffect(()=>{if(!De.enableKeyboard)return;const X=Q=>{var he,Ee;if(Q.key!=="Escape"||ere(document.activeElement))return;if(ja.current){Q.preventDefault(),Jd();return}if(Yd.current){Q.preventDefault(),_o.current=!0,Ea.current=!0;try{(he=Ui.current)==null||he.getState().cancelConnection()}catch{}document.dispatchEvent(new MouseEvent("mouseup",{bubbles:!0,cancelable:!0,button:0})),Gr(!1);return}if(dr.current){Q.preventDefault(),Kr(null);return}const le=je.current.size>0,ue=pt.current.size>0;(le||ue)&&(Q.preventDefault(),(Ee=tt.current)==null||Ee.call(tt,[],[]))};return window.addEventListener("keydown",X),()=>window.removeEventListener("keydown",X)},[Jd,De.enableKeyboard]),m.useEffect(()=>{if(!De.enableKeyboard)return;const X=Q=>{Mtt({event:Q,selectedNodeIds:h,hasClipboard:!!L,activeElement:document.activeElement,onCopySelection:U,onPasteSelection:D})};return window.addEventListener("keydown",X),()=>window.removeEventListener("keydown",X)},[h,L,U,D,De.enableKeyboard]);const It=m.useCallback(X=>{var ue,he;if(!ja.current)return;const Q=X.target;if(!(Q!=null&&Q.classList.contains("react-flow__pane")))return;const le={x:X.clientX,y:X.clientY};za.current=!0,Pa.current=le,Wi.current=le,On(le),Ho(le);try{(he=(ue=X.currentTarget).setPointerCapture)==null||he.call(ue,X.pointerId)}catch{}X.preventDefault(),X.stopPropagation()},[]),B0=m.useCallback(X=>{if(!za.current)return;const Q={x:X.clientX,y:X.clientY};Wi.current=Q,Ho(Q)},[]),U0=m.useCallback(X=>{var pr,X0;if(!za.current)return;za.current=!1;try{(X0=(pr=X.currentTarget).releasePointerCapture)==null||X0.call(pr,X.pointerId)}catch{}const Q=Pa.current,le=Wi.current,ue=ja.current,he=Xt.current;if(Jd(),!Q||!le||!ue||!he)return;const Ee=Math.min(Q.x,le.x),ve=Math.min(Q.y,le.y),Ae=Math.max(Q.x,le.x),nt=Math.max(Q.y,le.y),lt=Ae-Ee,yt=nt-ve,Te=he.screenToFlowPosition({x:Ee,y:ve}),Un=he.screenToFlowPosition({x:Ae,y:nt}),fr=Un.x-Te.x,mt=Un.y-Te.y,be=lt<FG||yt<FG,Yt=be?az[ue].width:fr,ou=be?az[ue].height:mt;N==null||N(ue,Te,{width:Yt,height:ou})},[Jd,N]),In=m.useRef(!1),ur=m.useRef(!1),Pf=m.useRef(new Map),Ra=m.useCallback(()=>{var X;Bi.current&&(ur.current||In.current||(Bi.current=!1,(X=Xt.current)==null||X.fitView(f2)))},[]),W0=m.useCallback(X=>{ur.current=X,X||Ra()},[Ra]);m.useEffect(()=>{var X;if(!Zd.current){Zd.current=!0;return}if(Xd.current.onExternalNodeChange){if(ur.current||In.current){Bi.current=!0;return}(X=Xt.current)==null||X.fitView(f2)}},[Hn]);const zf=!!H||!!O||!!P||!!I||!!pn,[Vn,Gi]=m.useState(null),[Ta,Ki]=m.useState(!1),[G0,Da]=m.useState(null),[Ha,T]=m.useState(null),F=m.useRef(null),Z=m.useRef(null);m.useEffect(()=>{if(!Vn)return;const X=Z.current;if(!X)return;const Q=new MouseEvent("contextmenu",{clientX:Vn.x,clientY:Vn.y,bubbles:!0,cancelable:!0,button:2,buttons:2});X.dispatchEvent(Q)},[Vn]);const B=m.useCallback(X=>{const Q=F.current;!Q||!H||H(Q,X)},[H]),q=m.useCallback(()=>{const X=F.current;!X||!O||O(X)},[O]),de=m.useCallback(()=>{const X=F.current;!X||!P||P(X)},[P]),$e=m.useCallback(()=>{const X=F.current;!X||!Se||Se(X)},[Se]);m.useCallback((X,Q,le,ue,he)=>{no.current.enableContextMenu&&(F.current=null,Ki(!1),Da(null),T({connectorId:X,kind:Q,pinned:le}),Gi({x:ue,y:he}))},[]);const Me=m.useCallback(()=>{const X=Ha;!X||!pn||pn(X.connectorId,X.kind)},[Ha,pn]),st=m.useCallback(()=>{if(!I)return;const X=Vn,Q=Xt.current;if(!X||!Q)return;const le=Q.screenToFlowPosition({x:X.x,y:X.y});I(le)},[Vn,I]),mn=typeof navigator<"u"&&/Mac|iPhone|iPad|iPod/.test(navigator.platform||navigator.userAgent||""),eu=mn?"⌘C":"Ctrl+C",ro=mn?"⌘V":"Ctrl+V",Ie=m.useMemo(()=>new Set(h),[h]),Je=m.useMemo(()=>new Set(f),[f]),kn=m.useMemo(()=>{if(h.length<2)return[];const X=Ln,Q=[];for(const le of h){const ue=l.find(Ae=>Ae.id===le);if(!ue)continue;const he=X==null?void 0:X[le],Ee=(he==null?void 0:he.data)??{},ve=ue.data;Q.push({id:le,position:(he==null?void 0:he.position)??ue.position,data:{width:Ee.width??ve.width,height:Ee.height??ve.height}})}return Q},[l,Ln,h]),Bn=E??[],Yr=m.useMemo(()=>{const X=he=>{const Ee=vt?void 0:Pf.current.get(he.id),ve={id:he.id,type:he.type,position:Ee??he.position,data:{...he.data,projectId:a,fileBaseUrl:s,projectSlug:he.type==="component"?a:void 0,flowSlug:he.type==="component"?i:void 0,apiBaseUrl:he.type==="component"?c:void 0,onRetryUpload:R,status:btt(Sn,he.id),errorMessage:_tt(Sn,he.id),statusReport:Ro==null?void 0:Ro[he.id],onPlay:v,onResize:M,onResizeEnd:x,setResizing:W0,onFitToContent:he.type==="html"?b:he.type==="component"?C:void 0,onNameChange:(()=>{if(vt&&he.type!=="ellipse")return S})(),onDescriptionChange:(()=>{if(vt&&(he.type==="rectangle"||he.type==="ellipse"||he.type==="sticky"))return $})(),onIconChange:(()=>{if(vt&&!(he.type!=="rectangle"&&he.type!=="component"))return tn})(),autoEditOnMount:ht===he.id?!0:void 0},selected:Ie.has(he.id)};return(!(he.data.autoSize===!0)||ur.current)&&(he.data.width!==void 0&&(ve.width=he.data.width),he.data.height!==void 0&&(ve.height=he.data.height)),Ie.has(he.id)||(ve.connectable=!1),ve},Q=l.map(he=>X(utt(he,Ln==null?void 0:Ln[he.id]))),le=new Set(l.map(he=>he.id)),ue=[];if(Ln)for(const[he,Ee]of Object.entries(Ln)){if(le.has(he))continue;const ve=Ee;typeof ve.type!="string"||!ve.position||!ve.data||ue.push(X({...ve,id:he}))}return[...Q,...ue]},[a,i,s,c,l,Ie,Sn,Ro,v,M,x,b,C,W0,Ln,S,$,tn,R,ht,vt]),[K0,hr]=m.useState(Yr);m.useEffect(()=>{In.current||ur.current||hr(Yr)},[Yr]),m.useEffect(()=>{on.current=K0},[K0]);const je=m.useRef(Ie);m.useEffect(()=>{je.current=Ie},[Ie]);const tt=m.useRef(y);m.useEffect(()=>{tt.current=y},[y]);const pt=m.useRef(Je);m.useEffect(()=>{pt.current=Je},[Je]);const on=m.useRef(Yr),Co=m.useRef(!1),qa=m.useRef(new Set),tu=m.useRef(new Set),nu=m.useRef(new Set),LR=m.useRef(new Set),Oa=m.useRef(null),Nre=m.useCallback(X=>{var mt;const Q=Co.current?nu.current:(mt=Oa.current)!=null&&mt.shift?Oa.current.nodeIds:null,le=Q&&Q.size>0?X.filter(be=>be.type!=="select"?!0:!(be.selected===!1&&Q.has(be.id))):X,ue=new Set;for(const be of le)be.type==="select"&&ue.add(be.id);const he=eQ(le,on.current),Ee=new Set;if(ur.current)for(const be of le)be.type==="dimensions"&&Ee.add(be.id);const ve=Ee.size===0?he:he.map(be=>!Ee.has(be.id)||be.width===void 0&&be.height===void 0?be:{...be,data:{...be.data,...be.width!==void 0?{width:be.width}:{},...be.height!==void 0?{height:be.height}:{}}}),Ae=je.current,nt=Co.current||Ae.size===0?ve:ve.map(be=>Ae.has(be.id)&&!ue.has(be.id)&&!be.selected?{...be,selected:!0}:be);if(on.current=nt,hr(nt),ue.size===0)return;if(Co.current){for(const be of le)be.type==="select"&&(be.selected?qa.current.add(be.id):qa.current.delete(be.id));return}const lt=tt.current;if(!lt)return;const yt=nt.filter(be=>be.selected).map(be=>be.id),Te=je.current;Te.size===yt.length&&yt.every(be=>Te.has(be))||(je.current=new Set(yt),lt(yt,[...pt.current]))},[]),Rf=m.useRef([]),Ire=m.useCallback(X=>{var yt;const Q=Co.current?LR.current:(yt=Oa.current)!=null&&yt.shift?Oa.current.edgeIds:null,le=Q&&Q.size>0?X.filter(Te=>Te.type!=="select"?!0:!(Te.selected===!1&&Q.has(Te.id))):X,ue=new Set;for(const Te of le)Te.type==="select"&&ue.add(Te.id);if(ue.size===0)return;if(Co.current){for(const Te of le)Te.type==="select"&&(Te.selected?tu.current.add(Te.id):tu.current.delete(Te.id));return}const he=tt.current;if(!he)return;const ve=tQ(le,Rf.current).filter(Te=>Te.selected).map(Te=>Te.id),Ae=pt.current;Ae.size===ve.length&&ve.every(Te=>Ae.has(Te))||(pt.current=new Set(ve),he([...je.current],ve))},[]),Are=m.useCallback(X=>{Co.current=!0;const Q=Oa.current,le=(Q==null?void 0:Q.shift)??(X.shiftKey||X.metaKey||X.ctrlKey);nu.current=le?new Set((Q==null?void 0:Q.nodeIds)??je.current):new Set,LR.current=le?new Set((Q==null?void 0:Q.edgeIds)??pt.current):new Set,qa.current=new Set(nu.current),tu.current=new Set(LR.current)},[]),Ere=m.useCallback(()=>{Co.current=!1,Oa.current=null;const X=tt.current;if(!X)return;const Q=[...qa.current],le=new Set(Q),ue=new Set(tu.current);for(const nt of Rf.current)le.has(nt.source)&&le.has(nt.target)&&ue.add(nt.id);const he=je.current,Ee=pt.current,ve=he.size===le.size&&Q.every(nt=>he.has(nt)),Ae=Ee.size===ue.size&&[...ue].every(nt=>Ee.has(nt));ve&&Ae||(je.current=new Set(Q),pt.current=new Set(ue),X(Q,[...ue]))},[]),$re=m.useCallback(X=>{if(Oa.current=null,ja.current||X.button!==0)return;const Q=X.target;Q!=null&&Q.classList.contains("react-flow__pane")&&(Oa.current={shift:X.shiftKey||X.metaKey||X.ctrlKey,nodeIds:new Set(je.current),edgeIds:new Set(pt.current)})},[]),jre=m.useCallback(X=>{if(!no.current.enableContextMenu||je.current.size<2)return;const le=X.target;le!==Z.current&&(le!=null&&le.closest(".seeflow-connector-endpoint-dot")||(X.preventDefault(),X.stopPropagation(),F.current=null,Ki(!0),Da(null),T(null),Gi({x:X.clientX,y:X.clientY})))},[]),Pre=m.useCallback(X=>{const Q=X.dataTransfer;if(!Q)return;const le=Q.types?Array.from(Q.types):[],ue=le.includes("Files"),he=le.includes(_W),Ee=ue&&!!A&&De.enableImageDrop,ve=he&&!!Y&&De.enableDragDrop;if(!(!Ee&&!ve)){X.preventDefault();try{Q.dropEffect="copy"}catch{}}},[A,Y,De.enableImageDrop,De.enableDragDrop]),zre=m.useCallback(X=>{const Q=X.dataTransfer;if((Q!=null&&Q.types?Array.from(Q.types):[]).includes(_W)&&Y&&De.enableDragDrop){X.preventDefault();const Ee=Xt.current;if(!Ee)return;const ve=Ee.screenToFlowPosition({x:X.clientX,y:X.clientY});Y({position:ve});return}if(!A||!De.enableImageDrop)return;const he={x:X.clientX,y:X.clientY};X.preventDefault(),oIe({dataTransfer:Q,clientPos:he,rfInstance:Xt.current,computeDims:rIe,dispatch:A})},[A,Y,De.enableImageDrop,De.enableDragDrop]),jF=!!V,PF=Je.size===1?[...Je][0]:null,NR=m.useMemo(()=>{const X=Ae=>{const nt=GG(Sn,Ae.source)==="running"||GG(Sn,Ae.target)==="running",lt=Je.has(Ae.id),yt=cTe(Ae,nt,lt);lt&&(yt.selected=!0);const Te=jF&&Ae.id===PF,Un=Te?{...yt,reconnectable:!0}:yt;return{...Un,data:{...Un.data,onLabelChange:vt?j:void 0,reconnectable:Te,registerEditHandle:Aa}}},Q=new Set(u.map(Ae=>Ae.id)),le=u.map(Ae=>X(htt(Ae,qn==null?void 0:qn[Ae.id]))),ue=[];if(qn)for(const[Ae,nt]of Object.entries(qn)){if(Q.has(Ae))continue;const lt=nt;typeof lt.source!="string"||typeof lt.target!="string"||ue.push(X({...lt,id:Ae}))}const he=[...le,...ue],Ee=[],ve=[];for(const Ae of he)Je.has(Ae.id)?ve.push(Ae):Ee.push(Ae);return[...Ee,...ve]},[u,Sn,Je,PF,qn,j,jF,Aa,vt]);m.useEffect(()=>{Rf.current=NR},[NR]);const Z0=e.adapter??null,Rre=m.useMemo(()=>{if(Z0!=null&&Z0.computeLayout)return async()=>{const X=Xt.current,Q=on.current;if(Q.length<2)return;const le=Q.map(mt=>{var X0;const be=(X0=X==null?void 0:X.getInternalNode(mt.id))==null?void 0:X0.measured,Yt=mt.data,ou=(be==null?void 0:be.width)??Yt.width??200,pr=(be==null?void 0:be.height)??Yt.height??120;return{id:mt.id,type:mt.type,width:ou,height:pr}}),ue=new Map;for(const mt of Q)ue.set(mt.id,mt.position);const he=Rf.current.map(mt=>({id:mt.id,source:mt.source,target:mt.target})),Ee=Z0.computeLayout;if(!Ee)return;const ve=await Ee(le,he),Ae=new Map;for(const[mt,be]of Object.entries(ve.nodes))Ae.set(mt,be.position);let nt=Number.POSITIVE_INFINITY,lt=Number.POSITIVE_INFINITY,yt=Number.POSITIVE_INFINITY,Te=Number.POSITIVE_INFINITY;for(const mt of le){const be=ue.get(mt.id);if(!be)continue;be.x<nt&&(nt=be.x),be.y<lt&&(lt=be.y);const Yt=Ae.get(mt.id);Yt&&(Yt.x<yt&&(yt=Yt.x),Yt.y<Te&&(Te=Yt.y))}const Un=Number.isFinite(nt)&&Number.isFinite(yt)?nt-yt:0,fr=Number.isFinite(lt)&&Number.isFinite(Te)?lt-Te:0;hr(mt=>mt.map(be=>{const Yt=Ae.get(be.id);return Yt?{...be,position:{x:Yt.x+Un,y:Yt.y+fr}}:be}))}},[Z0]),Tf=se??(vt?void 0:Rre),Df=m.useRef(!1),zF=m.useRef(null),Tre=m.useCallback(X=>{var Ae;if(!vt||!z)return;const{source:Q,target:le}=X;if(!Q||!le||Q===le)return;Df.current=!0;const ue=((Ae=zF.current)==null?void 0:Ae.nodeId)??null,he=ue!==null&&ue===le&&ue!==Q;z(he?le:Q,he?Q:le)},[z,vt]),IR=m.useCallback(X=>{const Q=le=>{if(!le)return!1;const ue=on.current.find(he=>he.id===le);return ue?ue.type==="text":!1};return!Q(X.source)&&!Q(X.target)},[]),Dre=m.useCallback((X,Q)=>{var yt;Gr(!1),Xr();const le=Df.current;if(Df.current=!1,le||To.current)return;if(_o.current){_o.current=!1;return}if(!z)return;const ue=(yt=Q.fromNode)==null?void 0:yt.id,he=Q.fromHandle;if(!ue||!he)return;const Ee=VG(X);if(!Ee)return;const ve=QT(Zt.current,Ee.clientX,Ee.clientY);if(!ve)return;const Ae=ve.getAttribute("data-id");if(!Ae||Ae===ue||!IR({source:ue,target:Ae,sourceHandle:null,targetHandle:null}))return;let nt;const lt=Xt.current;if(lt){const Te=lt.getInternalNode(Ae);if(Te){const Un=Te.measured.width??Te.width??0,fr=Te.measured.height??Te.height??0;if(Un>0&&fr>0){const mt=lt.screenToFlowPosition({x:Ee.clientX,y:Ee.clientY});nt=hH({x:Te.internals.positionAbsolute.x,y:Te.internals.positionAbsolute.y,w:Un,h:fr},mt)}}}z(ue,Ae,nt?{targetPin:nt}:void 0)},[z,Xr,IR]),Hf=m.useRef(!1),Hre=m.useCallback((X,Q)=>{if(!V)return;const{source:le,target:ue,sourceHandle:he,targetHandle:Ee}=Q;if(!le||!ue||le===ue)return;const ve={};if(le!==X.source&&(ve.source=le),ue!==X.target&&(ve.target=ue),typeof he=="string"&&he!==X.sourceHandle&&(ve.sourceHandle=he),typeof Ee=="string"&&Ee!==X.targetHandle&&(ve.targetHandle=Ee),ve.source===void 0&&ve.target===void 0&&ve.sourceHandle===void 0&&ve.targetHandle===void 0)return;(ve.source!==void 0||ve.sourceHandle!==void 0)&&(ve.sourceHandleAutoPicked=!1),(ve.target!==void 0||ve.targetHandle!==void 0)&&(ve.targetHandleAutoPicked=!1);const Ae=Xt.current;if(!(ve.source===void 0&&ve.target===void 0)&&Ae){const lt=ve.source!==void 0?"source":"target",yt=BG(lt,X.source,X.target,X.data,Te=>Ae.getInternalNode(Te)??null);yt&&(lt==="source"?ve.targetPin=yt:ve.sourcePin=yt)}Hf.current=!0,V(X.id,ve)},[V]),qre=m.useCallback((X,Q,le,ue)=>{var ou;Gr(!1),Xr(),To.current=!1;const he=Hf.current;if(Hf.current=!1,he)return;if(Ea.current){Ea.current=!1;return}if(!V)return;const Ee=VG(X);let ve=((ou=ue.toNode)==null?void 0:ou.id)??null;if(!ve&&Ee){const pr=QT(Zt.current,Ee.clientX,Ee.clientY);ve=(pr==null?void 0:pr.getAttribute("data-id"))??null}const Ae=le==="source"?"target":"source",nt=dtt(Ae,Q.source,Q.target,ve);if(nt==="no-op"||nt==="self-loop"||!Ee)return;const lt=Xt.current;if(!lt)return;const yt=nt==="pin-own"?Ae==="source"?Q.source:Q.target:ve,Te=lt.getInternalNode(yt);if(!Te)return;const Un=Te.measured.width??Te.width??0,fr=Te.measured.height??Te.height??0;if(Un===0||fr===0)return;const mt=lt.screenToFlowPosition({x:Ee.clientX,y:Ee.clientY}),be=hH({x:Te.internals.positionAbsolute.x,y:Te.internals.positionAbsolute.y,w:Un,h:fr},mt);if(nt==="pin-own"){if(!fn)return;fn(Q.id,Ae,be);return}const Yt=BG(Ae,Q.source,Q.target,Q.data,pr=>lt.getInternalNode(pr)??null);Ae==="source"?V(Q.id,{source:ve,sourceHandle:null,sourceHandleAutoPicked:!1,sourcePin:be,...Yt?{targetPin:Yt}:{}}):V(Q.id,{target:ve,targetHandle:null,targetHandleAutoPicked:!1,targetPin:be,...Yt?{sourcePin:Yt}:{}})},[V,Xr,fn]),Zi=m.useMemo(()=>{var Ae;if(!Do||!Fn)return null;const X=(Ae=Zt.current)==null?void 0:Ae.getBoundingClientRect(),Q=(X==null?void 0:X.left)??0,le=(X==null?void 0:X.top)??0,ue=Math.min(Do.x,Fn.x),he=Math.min(Do.y,Fn.y),Ee=Math.abs(Fn.x-Do.x),ve=Math.abs(Fn.y-Do.y);return{left:ue-Q,top:he-le,width:Ee,height:ve}},[Do,Fn]),Fa=jt?M2(Qa).node:void 0,Ore=jt?cee(jt):"",Fre=jt?lee(jt,Fa):void 0,Vre=jt==="text",[RF,TF]=m.useState(!1),[Bre,qf]=m.useState(!1),[Ure,DF]=m.useState(!1),Va=Jet({projectId:a,getReactFlow:()=>Xt.current});m.useImperativeHandle(t,()=>({exportPdf:Va.exportPdf,exportPng:Va.exportPng,openEmbedDialog:()=>DF(!0),capturePreview:Va.capturePreview}),[Va.exportPdf,Va.exportPng,Va.capturePreview]),m.useEffect(()=>{if(!De.enableKeyboard)return;const X=ue=>{if(!ue)return!1;const he=ue.tagName;return he==="INPUT"||he==="TEXTAREA"||he==="SELECT"?!0:ue instanceof HTMLElement&&ue.isContentEditable},Q=ue=>{ue.code==="Space"&&(X(document.activeElement)||(ue.preventDefault(),TF(!0)))},le=ue=>{ue.code==="Space"&&(TF(!1),qf(!1))};return window.addEventListener("keydown",Q),window.addEventListener("keyup",le),()=>{window.removeEventListener("keydown",Q),window.removeEventListener("keyup",le)}},[De.enableKeyboard]);const Of=m.useCallback(X=>{if(X.length!==0){if(!vt){const Q=Pf.current;for(const le of X)Q.set(le.id,{x:le.position.x,y:le.position.y});return}if(X.length===1){const Q=X[0];Q&&w&&w(Q.id,{x:Q.position.x,y:Q.position.y});return}if(g){g(X.map(Q=>({id:Q.id,position:{x:Q.position.x,y:Q.position.y}})));return}if(w)for(const Q of X)w(Q.id,{x:Q.position.x,y:Q.position.y})}},[w,g,vt]),HF=m.useCallback((X,Q,le)=>{In.current=!1,Of(le),Ra()},[Of,Ra]),qF=m.useCallback(()=>{In.current=!0},[]),OF=m.useCallback((X,Q)=>{In.current=!1,Of(Q),Ra()},[Of,Ra]),Wre=m.useCallback((X,Q)=>{dr.current&&Kr(null);const le=Zt.current;le&&le.style.setProperty("--rf-zoom",String(Q.zoom)),ct==null||ct(Q)},[ct]),Gre=m.useCallback(()=>{In.current=!0,ze==null||ze()},[ze]),Kre=m.useCallback((X,Q,le)=>{HF(X,Q,le),Qe==null||Qe()},[HF,Qe]),Zre=m.useCallback(()=>{qF(),ze==null||ze()},[qF,ze]),Xre=m.useCallback((X,Q)=>{OF(X,Q),Qe==null||Qe()},[OF,Qe]),Yre=m.useCallback((X,Q)=>{var le;(le=Wr.current.get(Q.id))==null||le()},[]),Qre=m.useCallback((X,Q)=>{re==null||re(Q.id)},[re]),Jre=m.useCallback(X=>{Be==null||Be()},[Be]),eae=m.useCallback((X,Q)=>{Pe==null||Pe(Q.id)},[Pe]),FF=jt?"crosshair":oo||RF?Bre?"grabbing":"grab":void 0,VF=h[0],BF=f[0],tae=VF?l.find(X=>X.id===VF)??null:null,nae=BF?u.find(X=>X.id===BF)??null:null,oae=a??null,rae=De.showDetailPanel&&!G,aae=m.useMemo(()=>({custom:Cn??{}}),[Cn]);return p.jsx(uHe,{value:aae,children:p.jsx("div",{"data-testid":"seeflow-canvas","data-mode":n,"data-canvas-mode":sn.kind,ref:Zt,className:"seeflow-canvas-root sf:relative sf:h-full sf:w-full",style:FF?{cursor:FF}:void 0,onPointerDownCapture:$re,onPointerDown:X=>{RF&&qf(!0),It(X)},onPointerMove:B0,onPointerUp:X=>{qf(!1),U0(X)},onPointerCancel:()=>{za.current=!1,Pa.current=null,Wi.current=null,On(null),Ho(null),qf(!1)},onContextMenuCapture:jre,onDragOver:Pre,onDrop:zre,children:p.jsxs(bFe,{containerRef:Zt,children:[p.jsxs(CRe,{nodes:K0,edges:NR,onNodesChange:Nre,nodeTypes:ftt,edgeTypes:ptt,proOptions:mtt,fitView:!0,minZoom:n==="mini"?.05:.5,nodesDraggable:(vt?!!w:!0)&&!jt&&!oo&&De.enableNodeMove,nodesConnectable:vt&&!!z&&!jt&&!oo,deleteKeyCode:vt?["Backspace","Delete"]:null,zoomOnScroll:De.enableZoom,zoomOnPinch:De.enableZoom,className:bo?"seeflow-connecting":void 0,onConnect:vt?Tre:void 0,isValidConnection:IR,onConnectStart:(X,Q)=>{Gr(!0),Df.current=!1,zF.current={nodeId:Q.nodeId??null,handleType:Q.handleType??null},$a(Q.nodeId??null)},onConnectEnd:Dre,onReconnect:vt&&V?Hre:void 0,onReconnectStart:(X,Q,le)=>{Gr(!0),Hf.current=!1,To.current=!0;const ue=le==="source"?Q.source:Q.target;$a(ue)},onReconnectEnd:qre,connectionLineComponent:V0,connectionLineStyle:{strokeWidth:2},connectionRadius:32,reconnectRadius:10,edgesReconnectable:!1,elevateNodesOnSelect:!1,elementsSelectable:!jt&&!oo&&De.enableSelection,selectNodesOnDrag:!1,nodeClickDistance:5,selectionOnDrag:!jt&&!oo&&De.enableSelection,panOnDrag:jt?!1:oo?[0,1,2]:De.enablePan?[1,2]:!1,selectionMode:c0.Partial,selectionKeyCode:null,multiSelectionKeyCode:jt?null:["Meta","Shift"],panActivationKeyCode:jt?null:"Space",onSelectionStart:Are,onSelectionEnd:Ere,defaultEdgeOptions:ytt,zoomOnDoubleClick:!1,onInit:X=>{Xt.current=X;const Q=Zt.current;Q&&Q.style.setProperty("--rf-zoom",String(X.getZoom())),Q&&Q.setAttribute("data-canvas-ready","true"),!lr.current&&cr.onMount&&l.length>0&&(X.fitView(f2),lr.current=!0),ae==null||ae(X)},onMove:Wre,onEdgesChange:Ire,onNodeDragStart:Gre,onNodeDragStop:Kre,onSelectionDragStart:Zre,onSelectionDragStop:Xre,onNodeClick:Qre,onEdgeClick:eae,onEdgeDoubleClick:Yre,onPaneClick:Jre,onNodeContextMenu:De.enableContextMenu&&zf?(X,Q)=>{X.preventDefault(),F.current=Q.id,Ki(!0),Da(Q.type??null),T(null),Gi({x:X.clientX,y:X.clientY})}:void 0,onPaneContextMenu:De.enableContextMenu&&I?X=>{X.preventDefault(),F.current=null,Ki(!1),Da(null),T(null),Gi({x:X.clientX,y:X.clientY})}:void 0,children:[p.jsx(vtt,{storeApiRef:Ui}),p.jsx(xtt,{wrapperRef:Zt}),p.jsx(PRe,{gap:12,size:.6}),n!=="mini"&&p.jsx(ott,{}),De.showControls?p.jsxs(ORe,{showInteractive:!1,showFitView:!1,children:[p.jsx($u,{"data-testid":"controls-fit-view","aria-label":"Fit view",title:"Fit view",disabled:l.length===0,onClick:()=>{var X;(X=Xt.current)==null||X.fitView(f2)},children:p.jsx(pd,{className:"sf:h-3 sf:w-3","aria-hidden":"true"})}),p.jsx($u,{"data-testid":"controls-tidy","aria-label":"Tidy layout (⌘⇧L)",title:"Tidy layout (⌘⇧L)",disabled:!Tf,onClick:()=>Tf==null?void 0:Tf(),children:p.jsx(W2,{className:"sf:h-3 sf:w-3","aria-hidden":"true"})})]}):null,De.showMiniMap?p.jsx(eTe,{className:"sf-canvas-minimap"}):null,De.showResizeHandles?p.jsx(ZJe,{selectedNodes:kn,onMultiResize:_}):null,r||De.showToolbar||De.showStyleStrip&&J&&ce?p.jsx(f0,{position:"top-left",children:p.jsxs("div",{className:"sf:flex sf:flex-col sf:items-start sf:gap-2",children:[r,De.showToolbar?p.jsx(wWe,{mode:sn,onModeChange:W,iconPickerOpen:Gt??!1,onOpenIconPicker:Et,onCloseIconPicker:hn,onPickIcon:fe,showShapeTools:vt&&!!N}):null,De.showStyleStrip&&J&&ce?p.jsx(XJe,{nodes:Bn,connectors:ee??[],onStyleNode:J,onStyleNodePreview:ne,onStyleNodes:oe,onStyleNodesPreview:te,onStyleConnector:ce,onStyleConnectorPreview:ge,onRequestIconReplace:Se}):null]})}):null,De.showShareMenu||De.showRestart&&Ne?p.jsx(f0,{position:"top-right",children:p.jsxs("div",{className:"sf:flex sf:items-center sf:gap-1",children:[De.showRestart&&Ne?p.jsx(UJe,{onRestartDemo:Ne}):null,De.showShareMenu?p.jsx(BJe,{mode:n==="mini"?"view":n,projectId:a,enableEmbed:De.enableEmbed,onDownloadPdf:Va.exportPdf,onDownloadPng:Va.exportPng,onExportToCloud:Tt,embedOpen:Ure,onEmbedOpenChange:DF}):null]})}):null]}),Zi?p.jsx("div",{"data-testid":"canvas-draw-ghost","data-ghost-shape":jt??void 0,"aria-hidden":!0,className:ie("sf:pointer-events-none sf:absolute sf:z-10",Ore,Vre?"sf:rounded-sm sf:border sf:border-dashed sf:border-muted-foreground/40":""),style:{...Fre,left:Zi.left,top:Zi.top,width:Zi.width,height:Zi.height},children:(()=>{const X=jt?OO[jt]:void 0;if(!X)return null;const Q=dee(Fa);return p.jsx(X,{width:Zi.width,height:Zi.height,borderColor:Q.borderColor,backgroundColor:Q.backgroundColor,borderSize:(Fa==null?void 0:Fa.borderSize)??vO,borderStyle:Fa==null?void 0:Fa.borderStyle})})()}):null,De.enableContextMenu&&zf?p.jsxs(hUe,{onOpenChange:X=>{X||(Gi(null),F.current=null,Da(null),T(null))},children:[p.jsx(fUe,{asChild:!0,children:p.jsx("div",{ref:Z,"data-testid":"node-context-menu-trigger","aria-hidden":!0,className:"sf:pointer-events-none sf:fixed",style:{left:(Vn==null?void 0:Vn.x)??0,top:(Vn==null?void 0:Vn.y)??0,width:0,height:0}})}),p.jsxs(qte,{"data-testid":"node-context-menu",children:[Ha!=null&&Ha.pinned&&pn?p.jsx(_r,{"data-testid":"connector-endpoint-context-menu-unpin",onSelect:Me,children:"Unpin"}):null,Ta&&P?p.jsxs(_r,{"data-testid":"node-context-menu-copy",onSelect:de,children:["Copy",p.jsx(zH,{children:eu})]}):null,I?p.jsxs(_r,{"data-testid":"node-context-menu-paste",disabled:!L,onSelect:st,children:["Paste",p.jsx(zH,{children:ro})]}):null,Ta&&(P||I)&&(G0==="icon"&&Se||H||O)?p.jsx(sP,{}):null,Ta&&G0==="icon"&&Se?p.jsx(_r,{"data-testid":"node-context-menu-change-icon",onSelect:$e,children:"Change icon"}):null,Ta&&G0==="icon"&&Se&&(H||O)?p.jsx(sP,{}):null,Ta&&H?p.jsxs(p.Fragment,{children:[p.jsx(_r,{"data-testid":"node-context-menu-to-front",onSelect:()=>B({op:"toFront"}),children:"Bring to front"}),p.jsx(_r,{"data-testid":"node-context-menu-forward",onSelect:()=>B({op:"forward"}),children:"Bring forward"}),p.jsx(_r,{"data-testid":"node-context-menu-backward",onSelect:()=>B({op:"backward"}),children:"Send backward"}),p.jsx(_r,{"data-testid":"node-context-menu-to-back",onSelect:()=>B({op:"toBack"}),children:"Send to back"})]}):null,Ta&&H&&O?p.jsx(sP,{}):null,Ta&&O?p.jsx(_r,{"data-testid":"node-context-menu-delete",onSelect:q,children:"Delete"}):null]})]}):null,Ve?p.jsxs(Rd,{open:!!yn,onOpenChange:X=>{X||Kr(null)},children:[p.jsx(_Fe,{asChild:!0,children:p.jsx("div",{"data-testid":"drop-popover-anchor","aria-hidden":!0,className:"sf:pointer-events-none sf:fixed",style:{left:(yn==null?void 0:yn.clientX)??0,top:(yn==null?void 0:yn.clientY)??0,width:0,height:0}})}),p.jsx(zi,{"data-testid":"drop-popover",align:"start",side:"bottom",sideOffset:4,className:"sf:w-auto sf:p-1",onOpenAutoFocus:X=>{X.preventDefault()},children:p.jsx("div",{role:"menu","aria-label":"Create connected node",className:"sf:flex sf:flex-col sf:gap-0.5",children:xWe.map(({shape:X,label:Q,Icon:le})=>p.jsxs("button",{type:"button",role:"menuitem","data-testid":`drop-popover-shape-${X}`,onClick:()=>{const ue=yn;ue&&(Ve({sourceNodeId:ue.sourceNodeId,position:{x:ue.flowX,y:ue.flowY},shape:X}),Kr(null))},className:ie("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:Q})]},X))})})]}):null,rae?p.jsx(mJe,{flowId:oae,node:tae,connector:nae,adapter:o??null,statusReport:K,onNameChange:qe,onDescriptionChange:Ze,onDetailChange:Kt,onIconChange:tn,onClose:()=>{var X;(X=tt.current)==null||X.call(tt,[],[])}}):null]})})})}const Stt=m.forwardRef(Ctt);function Ltt({open:e,onOpenChange:t,onCreated:n}){const[o,r]=m.useState(""),[a,i]=m.useState(""),[s,c]=m.useState(""),[l,u]=m.useState(null),[h,f]=m.useState(!1);m.useEffect(()=>{e&&(r(""),i(""),c(""),u(null),f(!1))},[e]);const y=o.trim(),k=a.trim(),v=s.trim(),w=y.length>0&&k.length>0&&!h,g=async M=>{if(M.preventDefault(),!!w){f(!0),u(null);try{const x=await Tse({path:y,name:k,...v.length>0?{description:v}:{}});n(x),t(!1)}catch(x){u(x instanceof Error?x.message:String(x)),f(!1)}}};return p.jsx(wa,{open:e,onOpenChange:t,children:p.jsxs(Ri,{className:"sm:max-w-md","data-testid":"create-project-dialog",onOpenAutoFocus:M=>{M.preventDefault();const x=document.querySelector('[data-testid="create-project-path-input"]');x==null||x.focus()},children:[p.jsxs(Ti,{children:[p.jsx(Di,{children:"Create new project"}),p.jsx(Hi,{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(Ma,{children:[p.jsx(dt,{type:"button",variant:"ghost",onClick:()=>t(!1),disabled:h,children:"Cancel"}),p.jsx(dt,{type:"submit",disabled:!w,"data-testid":"create-project-submit",children:h?"Creating…":"Create project"})]})]})]})})}const Ntt="seeflow:last-flow:",tre=e=>`${Ntt}${e}`,nre=e=>{if(typeof window>"u")return null;try{return window.localStorage.getItem(tre(e))}catch{return null}},Itt=(e,t)=>{if(!(typeof window>"u"))try{window.localStorage.setItem(tre(e),t)}catch{}},Att=(e,t)=>{var o;if(e.length===0)return null;if(t){const r=e.find(a=>a.flowSlug===t);if(r)return r.flowSlug}const n=e.find(r=>r.isDefault);return n?n.flowSlug:((o=e[0])==null?void 0:o.flowSlug)??null},JH="seeflow:navigate",Ett=e=>(window.addEventListener("popstate",e),window.addEventListener(JH,e),()=>{window.removeEventListener("popstate",e),window.removeEventListener(JH,e)}),KG=()=>window.location.pathname,$tt=()=>m.useSyncExternalStore(Ett,KG,KG),jr=e=>{e!==window.location.pathname&&(window.history.pushState({},"",e),window.dispatchEvent(new Event(JH)))},ui=(e,t)=>`/projects/${encodeURIComponent(e)}/flows/${encodeURIComponent(t)}`,jtt=e=>{const t=e.split("/").filter(Boolean);if(t.length!==4||t[0]!=="projects"||t[2]!=="flows")return null;const n=decodeURIComponent(t[1]??""),o=decodeURIComponent(t[3]??"");return!n||!o?null:{project:n,flow:o}},ore=e=>{const t=e.indexOf("/");return t<0?ui(e,""):ui(e.slice(0,t),e.slice(t+1))},Ptt=e=>{const t=e.split("/").filter(Boolean);if(t.length!==2||t[0]!=="projects")return null;const n=decodeURIComponent(t[1]??"");return n?{project:n}:null};/**
|
|
8544
|
+
`)}async function Bet(e,t){const n=t.fontEmbedCSS!=null?t.fontEmbedCSS:t.skipFonts?null:await Vet(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 Uet(e,t={}){const{width:n,height:o}=Uoe(e,t),r=await CR(e,t,!0);return await Bet(r,t),await Yoe(r,t),Det(r,t),await iet(r,n,o)}async function Wet(e,t={}){const{width:n,height:o}=Uoe(e,t),r=await Uet(e,t),a=await yz(r),i=document.createElement("canvas"),s=i.getContext("2d"),c=t.pixelRatio||oet(),l=t.canvasWidth||n,u=t.canvasHeight||o;return i.width=l*c,i.height=u*c,t.skipAutoScale||ret(i),i.style.width=`${l}`,i.style.height=`${u}`,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 Get(e,t={}){return(await Wet(e,t)).toDataURL()}const Ket=e=>e instanceof Element?!(e.classList.contains("react-flow__minimap")||e.classList.contains("react-flow__controls")||e.classList.contains("react-flow__panel")):!0,Zet=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"},Xet=async e=>{const t=await Get(e,{cacheBust:!0,filter:Ket,backgroundColor:Zet(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}},Yet=(e,t)=>{const n=document.createElement("a");n.href=e,n.download=t,n.rel="noopener",document.body.appendChild(n),n.click(),n.remove()},Qet=e=>{const t=e.replace(/[^A-Za-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"");return t.length>0?t.slice(0,80):"canvas"},OG=(e,t)=>`${Qet(e??"canvas")}.${t}`,Jet=({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 u=document.querySelector(".react-flow__viewport");if(!u)return null;const h=l.getViewport();try{return await l.fitView({duration:0,padding:.1}),await new Promise(f=>requestAnimationFrame(()=>f())),await Xet(u)}finally{l.setViewport(h,{duration:0})}},[t]),i=m.useCallback(async()=>{o(null);try{const l=await a();if(!l)return;Yet(l.dataUrl,OG(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:u}=await ff(async()=>{const{jsPDF:y}=await import("./jspdf.es.min-_GQ7N2xd.js").then(k=>k.j);return{jsPDF:y}},[]),h=l.width>l.height?"landscape":"portrait",f=new u({orientation:h,unit:"px",format:[l.width,l.height],hotfixes:["px_scaling"]});f.addImage(l.dataUrl,"PNG",0,0,l.width,l.height),f.save(OG(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}},ett=12,ttt=1200;function ntt(e,t={}){const n=t.idleMs??ttt;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 v=e.getBoundingClientRect();e.style.setProperty("--mx",`${y-v.left}px`),e.style.setProperty("--my",`${k-v.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 ott(){const e=m.useRef(null),t=He(i=>i.transform,(i,s)=>i[0]===s[0]&&i[1]===s[1]&&i[2]===s[2]),[n,o,r]=t,a=ett*r;return m.useEffect(()=>{var h;const i=e.current;if(!i)return;const s=(h=i.parentElement)==null?void 0:h.querySelector(".react-flow__pane");if(!s)return;const{onMove:c,onLeave:l,dispose:u}=ntt(i);return s.addEventListener("mousemove",c,{passive:!0}),s.addEventListener("mouseleave",l,{passive:!0}),()=>{s.removeEventListener("mousemove",c),s.removeEventListener("mouseleave",l),u()}},[]),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 rtt={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},att={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},itt={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 stt(e){const t=e.mode==="edit"?rtt:e.mode==="mini"?itt:att;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 FG=40,f2={padding:.15,duration:300,includeHiddenNodes:!1};function ctt(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 VG=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},ltt=(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},Joe=15,QT=(e,t,n)=>{const o=ltt(t,n);if(o)return o;if(!e)return null;let r=null,a=Joe;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),u=Math.max(c.top-n,0,n-c.bottom),h=Math.hypot(l,u);h<=a&&(r=s,a=h)}return r};function BG(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 u=c.measured.width??c.width??0,h=c.measured.height??c.height??0,f=l.measured.width??l.width??0,y=l.measured.height??l.height??0;if(u===0||h===0||f===0||y===0)return;const k={x:c.internals.positionAbsolute.x,y:c.internals.positionAbsolute.y,w:u,h},v={x:l.internals.positionAbsolute.x+f/2,y:l.internals.positionAbsolute.y+y/2};return pTe(k,WP(k,v))}function dtt(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 utt=(e,t)=>{if(!t)return e;const n=t.data?{...e.data,...t.data}:e.data;return{...e,...t,data:n}},htt=(e,t)=>t?{...e,...t}:e,ftt={rectangle:kVe,ellipse:Za,sticky:Za,text:Za,database:Za,server:Za,user:Za,queue:Za,cloud:Za,image:uVe,icon:CTe,html:iVe,component:jFe},ptt={editableEdge:xVe},ytt={zIndex:0},mtt={hideAttribution:!0},ktt=8,UG=(e,t)=>e?typeof e=="string"?`url('#${e}')`:`url('#${`${t?`${t}__`:""}${Object.keys(e).sort().map(r=>`${r}=${e[r]}`).join("&")}`}')`:void 0,gtt=e=>function({fromX:n,fromY:o,toX:r,toY:a,fromPosition:i,toPosition:s,connectionLineStyle:c}){const l=He(U=>e.current?U.edges.find(D=>D.reconnectable===!0)??null:null),u=l==null?void 0:l.data,h=He(U=>{var E;const D=U.connection;return((E=D==null?void 0:D.fromHandle)==null?void 0:E.nodeId)??null}),f=He(U=>l!=null&&l.source?U.nodeLookup.get(l.source)??null:null),y=He(U=>l!=null&&l.target?U.nodeLookup.get(l.target)??null:null),k=He(U=>h?U.nodeLookup.get(h)??null:null),v=(l==null?void 0:l.source)===h,w=l?v?f:y:k,g=v?y:f,M=v?u==null?void 0:u.sourcePin:u==null?void 0:u.targetPin,x=v?u==null?void 0:u.sourceHandleAutoPicked:u==null?void 0:u.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 ee=null;if(M)ee=GP(E,M);else if(x!==!1&&g){const J=g.measured.width??g.width??0,ne=g.measured.height??g.height??0;if(J>0&&ne>0){const oe={x:g.internals.positionAbsolute.x+J/2,y:g.internals.positionAbsolute.y+ne/2};ee=WP(E,oe)}}ee&&(b=ee.x,C=ee.y,_=WG[ee.side])}}const S=He(U=>U.transform[2]),$=He(U=>U.nodeLookup),j=He(U=>{var D;return((D=U.connection.toHandle)==null?void 0:D.nodeId)??null});let N=r,A=a,R=s;if(S>0){const U=Joe/S,D=l?v?l.target:l.source:null;let E=null;if(j&&j!==D){const ee=$.get(j)??null;ee&&(E=ee)}if(!E){let ee=U;for(const J of $.values()){if(D&&J.id===D||w&&J.id===w.id)continue;const ne=J.measured.width??J.width??0,oe=J.measured.height??J.height??0;if(ne===0||oe===0)continue;const te=J.internals.positionAbsolute.x,ce=J.internals.positionAbsolute.y,ge=Math.max(te-r,0,r-(te+ne)),ae=Math.max(ce-a,0,a-(ce+oe)),se=Math.hypot(ge,ae);se<=ee&&(ee=se,E=J)}}if(!E&&l&&w){const ee=w.measured.width??w.width??0,J=w.measured.height??w.height??0;if(ee>0&&J>0){const ne=w.internals.positionAbsolute.x,oe=w.internals.positionAbsolute.y,te=Math.max(ne-r,0,r-(ne+ee)),ce=Math.max(oe-a,0,a-(oe+J));Math.hypot(te,ce)<=U&&(E=w)}}if(E){const ee=E.measured.width??E.width??0,J=E.measured.height??E.height??0;if(ee>0&&J>0){const ne=hH({x:E.internals.positionAbsolute.x,y:E.internals.positionAbsolute.y,w:ee,h:J},{x:r,y:a}),oe=GP({x:E.internals.positionAbsolute.x,y:E.internals.positionAbsolute.y,w:ee,h:J},ne);N=oe.x,A=oe.y,R=WG[oe.side]}}}const Y=(u==null?void 0:u.path)==="step",[z]=Y?qh({sourceX:b,sourceY:C,sourcePosition:_,targetX:N,targetY:A,targetPosition:R,borderRadius:ktt}):Fz({sourceX:b,sourceY:C,sourcePosition:_,targetX:N,targetY:A,targetPosition:R}),V=(l==null?void 0:l.style)??c??void 0,H=He(U=>U.rfId),O=v?l==null?void 0:l.markerStart:l==null?void 0:l.markerEnd,P=v?l==null?void 0:l.markerEnd:l==null?void 0:l.markerStart,I=UG(O,H),L=UG(P,H);return p.jsx("path",{d:z,fill:"none",className:"react-flow__connection-path",style:V,markerStart:I,markerEnd:L})},WG={top:me.Top,right:me.Right,bottom:me.Bottom,left:me.Left};function vtt({storeApiRef:e}){const t=Mt();return m.useEffect(()=>(e.current=t,()=>{e.current===t&&(e.current=null)}),[t,e]),null}function xtt({wrapperRef:e}){const t=He(o=>o.transform[2]),n=e.current;return n&&n.style.setProperty("--rf-zoom",String(t)),null}const wtt=new Set(["INPUT","TEXTAREA","SELECT"]),ere=e=>e?wtt.has(e.tagName)?!0:e instanceof HTMLElement&&e.isContentEditable:!1;function Mtt(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"||ere(r)?!1:s==="c"?n.length===0||!a?!1:(t.preventDefault(),a([...n]),!0):!o||!i?!1:(t.preventDefault(),i(),!0)}const GG=(e,t)=>{var n;return((n=e==null?void 0:e[t])==null?void 0:n.status)??"idle"},btt=(e,t)=>{var n;return(n=e==null?void 0:e[t])==null?void 0:n.status},_tt=(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 Ctt(e,t){var UF,WF;const{mode:n,adapter:o,topLeftSlot:r,projectId:a,flowSlug:i,fileBaseUrl:s,apiBaseUrl:c="/api",nodes:l,connectors:u,selectedNodeIds:h,selectedConnectorIds:f,onSelectionChange:y,runtime:k,onPlayNode:v,onNodePositionChange:w,onNodePositionsChange:g,onNodeResize:M,onNodeResizeEnd:x,onHtmlNodeFitToContent:b,onComponentNodeFitToContent:C,onMultiResize:_,onNodeNameChange:S,onNodeDescriptionChange:$,onConnectorLabelChange:j,onCreateShapeNode:N,onCreateImageFromFile:A,onRetryImageUpload:R,onCreateHtmlNode:Y,onCreateConnector:z,onReconnectConnector:V,onReorderNode:H,onDeleteNode:O,onCopyNode:P,onPasteAt:I,hasClipboard:L,onCopySelection:U,onPasteSelection:D,selectedNodes:E,selectedConnectors:ee,onStyleNode:J,onStyleNodePreview:ne,onStyleNodes:oe,onStyleNodesPreview:te,onStyleConnector:ce,onStyleConnectorPreview:ge,onRfInit:ae,onTidy:se,onNodeClick:re,onConnectorClick:Pe,onPaneClick:Be,onCreateAndConnectFromPane:Ve,pendingEditNodeId:ht,iconPickerOpen:Gt,onOpenIconPicker:Et,onCloseIconPicker:hn,onPickIcon:fe,onRequestIconReplace:Se,onPinEndpoint:fn,onUnpinEndpoint:pn,canvasMode:sn,onCanvasModeChange:W,disableSidebar:G,statusReport:K,onNameChange:qe,onDescriptionChange:Ze,onDetailChange:Kt,onIconChange:tn,autoFitView:nn,autoFitViewSignal:Hn,customIcons:Cn,onExportToCloud:Tt,onRestartDemo:Ne,onNodeDragStart:ze,onNodeDragStop:Qe,onViewportChange:ct,showToolbar:ir,showStyleStrip:qd,showDetailPanel:Od,showStatusBadges:Oi,showResizeHandles:Fd,showControls:$t,showShareMenu:Ft,showMiniMap:Vd,showRestart:Bd,enableKeyboard:Ud,enableContextMenu:Wd,enableDragDrop:Gd,enableImageDrop:Kd,enableZoom:La,enablePan:Na,enableSelection:sr,enableNodeMove:Fi,enableEmbed:Ia}=e,De=m.useMemo(()=>stt({mode:n,showToolbar:ir,showStyleStrip:qd,showDetailPanel:Od,showStatusBadges:Oi,showResizeHandles:Fd,showControls:$t,showShareMenu:Ft,showMiniMap:Vd,showRestart:Bd,enableKeyboard:Ud,enableContextMenu:Wd,enableDragDrop:Gd,enableImageDrop:Kd,enableZoom:La,enablePan:Na,enableSelection:sr,enableNodeMove:Fi,enableEmbed:Ia}),[n,ir,qd,Od,Oi,Fd,$t,Ft,Vd,Bd,Ud,Wd,Gd,Kd,La,Na,sr,Fi,Ia]),vt=n==="edit",no=m.useRef(De);m.useEffect(()=>{no.current=De},[De]);const Vi=nn??(n==="mini"?!0:void 0),cr=m.useMemo(()=>ctt(Vi),[Vi]),Sn=k==null?void 0:k.runs,Ro=k==null?void 0:k.statuses,Ln=(UF=k==null?void 0:k.pendingOverrides)==null?void 0:UF.nodes,qn=(WF=k==null?void 0:k.pendingOverrides)==null?void 0:WF.connectors,Zt=m.useRef(null),Xt=m.useRef(null),lr=m.useRef(!1),Bi=m.useRef(!1),Zd=m.useRef(!1),Xd=m.useRef(cr);Xd.current=cr,m.useEffect(()=>{if(lr.current||!cr.onMount||l.length===0)return;const X=Xt.current;X&&(X.fitView(f2),lr.current=!0)},[l,cr.onMount]);const Ui=m.useRef(null),jt=sn.kind==="draw"?sn.shape:null,oo=sn.kind==="hand",Wr=m.useRef(new Map),Aa=m.useCallback((X,Q)=>(Wr.current.set(X,Q),()=>{Wr.current.get(X)===Q&&Wr.current.delete(X)}),[]),[bo,Gr]=m.useState(!1),Yd=m.useRef(!1);m.useEffect(()=>{Yd.current=bo},[bo]);const _o=m.useRef(!1),Ea=m.useRef(!1),To=m.useRef(!1),[yn,Kr]=m.useState(null),dr=m.useRef(null);m.useEffect(()=>{dr.current=yn},[yn]),m.useCallback(()=>{Kr(null)},[]);const V0=m.useMemo(()=>gtt(To),[]),Zr=m.useRef(null),Qd=m.useRef(null),$a=m.useCallback(X=>{const Q=Zt.current;if(!Q){Zr.current=X;return}const le=Zr.current;if(le&&le!==X){const ue=Q.querySelector(`.react-flow__node[data-id="${CSS.escape(le)}"]`);ue==null||ue.removeAttribute("data-connect-source")}if(X){const ue=Q.querySelector(`.react-flow__node[data-id="${CSS.escape(X)}"]`);ue==null||ue.setAttribute("data-connect-source","true")}Zr.current=X},[]),Nn=m.useCallback(X=>{const Q=Zt.current,le=Qd.current;if(le!==X){if(Q&&le){const ue=Q.querySelector(`.react-flow__node[data-id="${CSS.escape(le)}"]`);ue==null||ue.removeAttribute("data-connect-target")}if(Q&&X){const ue=Q.querySelector(`.react-flow__node[data-id="${CSS.escape(X)}"]`);ue==null||ue.setAttribute("data-connect-target","true")}Qd.current=X}},[]),Xr=m.useCallback(()=>{$a(null),Nn(null)},[$a,Nn]);m.useEffect(()=>{if(!bo){Nn(null);return}let X=null,Q=null;const le=()=>{X=null;const he=Q;if(Q=null,!he)return;const Ee=QT(Zt.current,he.clientX,he.clientY),ve=(Ee==null?void 0:Ee.getAttribute("data-id"))??null;if(ve&&ve===Zr.current){Nn(null);return}Nn(ve)},ue=he=>{Q={clientX:he.clientX,clientY:he.clientY},X===null&&(X=requestAnimationFrame(le))};return document.addEventListener("pointermove",ue,{passive:!0}),()=>{document.removeEventListener("pointermove",ue),X!==null&&cancelAnimationFrame(X)}},[bo,Nn]);const[Do,On]=m.useState(null),[Fn,Ho]=m.useState(null),ja=m.useRef(null),Pa=m.useRef(null),Wi=m.useRef(null),za=m.useRef(!1);m.useEffect(()=>{ja.current=jt},[jt]);const Jd=m.useCallback(()=>{W({kind:"select"}),On(null),Ho(null),ja.current=null,Pa.current=null,Wi.current=null,za.current=!1},[W]);m.useEffect(()=>{if(!De.enableKeyboard)return;const X=Q=>{var he,Ee;if(Q.key!=="Escape"||ere(document.activeElement))return;if(ja.current){Q.preventDefault(),Jd();return}if(Yd.current){Q.preventDefault(),_o.current=!0,Ea.current=!0;try{(he=Ui.current)==null||he.getState().cancelConnection()}catch{}document.dispatchEvent(new MouseEvent("mouseup",{bubbles:!0,cancelable:!0,button:0})),Gr(!1);return}if(dr.current){Q.preventDefault(),Kr(null);return}const le=je.current.size>0,ue=pt.current.size>0;(le||ue)&&(Q.preventDefault(),(Ee=tt.current)==null||Ee.call(tt,[],[]))};return window.addEventListener("keydown",X),()=>window.removeEventListener("keydown",X)},[Jd,De.enableKeyboard]),m.useEffect(()=>{if(!De.enableKeyboard)return;const X=Q=>{Mtt({event:Q,selectedNodeIds:h,hasClipboard:!!L,activeElement:document.activeElement,onCopySelection:U,onPasteSelection:D})};return window.addEventListener("keydown",X),()=>window.removeEventListener("keydown",X)},[h,L,U,D,De.enableKeyboard]);const It=m.useCallback(X=>{var ue,he;if(!ja.current)return;const Q=X.target;if(!(Q!=null&&Q.classList.contains("react-flow__pane")))return;const le={x:X.clientX,y:X.clientY};za.current=!0,Pa.current=le,Wi.current=le,On(le),Ho(le);try{(he=(ue=X.currentTarget).setPointerCapture)==null||he.call(ue,X.pointerId)}catch{}X.preventDefault(),X.stopPropagation()},[]),B0=m.useCallback(X=>{if(!za.current)return;const Q={x:X.clientX,y:X.clientY};Wi.current=Q,Ho(Q)},[]),U0=m.useCallback(X=>{var pr,X0;if(!za.current)return;za.current=!1;try{(X0=(pr=X.currentTarget).releasePointerCapture)==null||X0.call(pr,X.pointerId)}catch{}const Q=Pa.current,le=Wi.current,ue=ja.current,he=Xt.current;if(Jd(),!Q||!le||!ue||!he)return;const Ee=Math.min(Q.x,le.x),ve=Math.min(Q.y,le.y),Ae=Math.max(Q.x,le.x),nt=Math.max(Q.y,le.y),lt=Ae-Ee,yt=nt-ve,Te=he.screenToFlowPosition({x:Ee,y:ve}),Un=he.screenToFlowPosition({x:Ae,y:nt}),fr=Un.x-Te.x,mt=Un.y-Te.y,be=lt<FG||yt<FG,Yt=be?az[ue].width:fr,ou=be?az[ue].height:mt;N==null||N(ue,Te,{width:Yt,height:ou})},[Jd,N]),In=m.useRef(!1),ur=m.useRef(!1),Pf=m.useRef(new Map),Ra=m.useCallback(()=>{var X;Bi.current&&(ur.current||In.current||(Bi.current=!1,(X=Xt.current)==null||X.fitView(f2)))},[]),W0=m.useCallback(X=>{ur.current=X,X||Ra()},[Ra]);m.useEffect(()=>{var X;if(!Zd.current){Zd.current=!0;return}if(Xd.current.onExternalNodeChange){if(ur.current||In.current){Bi.current=!0;return}(X=Xt.current)==null||X.fitView(f2)}},[Hn]);const zf=!!H||!!O||!!P||!!I||!!pn,[Vn,Gi]=m.useState(null),[Ta,Ki]=m.useState(!1),[G0,Da]=m.useState(null),[Ha,T]=m.useState(null),F=m.useRef(null),Z=m.useRef(null);m.useEffect(()=>{if(!Vn)return;const X=Z.current;if(!X)return;const Q=new MouseEvent("contextmenu",{clientX:Vn.x,clientY:Vn.y,bubbles:!0,cancelable:!0,button:2,buttons:2});X.dispatchEvent(Q)},[Vn]);const B=m.useCallback(X=>{const Q=F.current;!Q||!H||H(Q,X)},[H]),q=m.useCallback(()=>{const X=F.current;!X||!O||O(X)},[O]),de=m.useCallback(()=>{const X=F.current;!X||!P||P(X)},[P]),$e=m.useCallback(()=>{const X=F.current;!X||!Se||Se(X)},[Se]);m.useCallback((X,Q,le,ue,he)=>{no.current.enableContextMenu&&(F.current=null,Ki(!1),Da(null),T({connectorId:X,kind:Q,pinned:le}),Gi({x:ue,y:he}))},[]);const Me=m.useCallback(()=>{const X=Ha;!X||!pn||pn(X.connectorId,X.kind)},[Ha,pn]),st=m.useCallback(()=>{if(!I)return;const X=Vn,Q=Xt.current;if(!X||!Q)return;const le=Q.screenToFlowPosition({x:X.x,y:X.y});I(le)},[Vn,I]),mn=typeof navigator<"u"&&/Mac|iPhone|iPad|iPod/.test(navigator.platform||navigator.userAgent||""),eu=mn?"⌘C":"Ctrl+C",ro=mn?"⌘V":"Ctrl+V",Ie=m.useMemo(()=>new Set(h),[h]),Je=m.useMemo(()=>new Set(f),[f]),kn=m.useMemo(()=>{if(h.length<2)return[];const X=Ln,Q=[];for(const le of h){const ue=l.find(Ae=>Ae.id===le);if(!ue)continue;const he=X==null?void 0:X[le],Ee=(he==null?void 0:he.data)??{},ve=ue.data;Q.push({id:le,position:(he==null?void 0:he.position)??ue.position,data:{width:Ee.width??ve.width,height:Ee.height??ve.height}})}return Q},[l,Ln,h]),Bn=E??[],Yr=m.useMemo(()=>{const X=he=>{const Ee=vt?void 0:Pf.current.get(he.id),ve={id:he.id,type:he.type,position:Ee??he.position,data:{...he.data,projectId:a,fileBaseUrl:s,projectSlug:he.type==="component"?a:void 0,flowSlug:he.type==="component"?i:void 0,apiBaseUrl:he.type==="component"?c:void 0,onRetryUpload:R,status:btt(Sn,he.id),errorMessage:_tt(Sn,he.id),statusReport:Ro==null?void 0:Ro[he.id],onPlay:v,onResize:M,onResizeEnd:x,setResizing:W0,onFitToContent:he.type==="html"?b:he.type==="component"?C:void 0,onNameChange:(()=>{if(vt&&he.type!=="ellipse")return S})(),onDescriptionChange:(()=>{if(vt&&(he.type==="rectangle"||he.type==="ellipse"||he.type==="sticky"))return $})(),onIconChange:(()=>{if(vt&&!(he.type!=="rectangle"&&he.type!=="component"))return tn})(),autoEditOnMount:ht===he.id?!0:void 0},selected:Ie.has(he.id)};return(!(he.data.autoSize===!0)||ur.current)&&(he.data.width!==void 0&&(ve.width=he.data.width),he.data.height!==void 0&&(ve.height=he.data.height)),Ie.has(he.id)||(ve.connectable=!1),ve},Q=l.map(he=>X(utt(he,Ln==null?void 0:Ln[he.id]))),le=new Set(l.map(he=>he.id)),ue=[];if(Ln)for(const[he,Ee]of Object.entries(Ln)){if(le.has(he))continue;const ve=Ee;typeof ve.type!="string"||!ve.position||!ve.data||ue.push(X({...ve,id:he}))}return[...Q,...ue]},[a,i,s,c,l,Ie,Sn,Ro,v,M,x,b,C,W0,Ln,S,$,tn,R,ht,vt]),[K0,hr]=m.useState(Yr);m.useEffect(()=>{In.current||ur.current||hr(Yr)},[Yr]),m.useEffect(()=>{on.current=K0},[K0]);const je=m.useRef(Ie);m.useEffect(()=>{je.current=Ie},[Ie]);const tt=m.useRef(y);m.useEffect(()=>{tt.current=y},[y]);const pt=m.useRef(Je);m.useEffect(()=>{pt.current=Je},[Je]);const on=m.useRef(Yr),Co=m.useRef(!1),qa=m.useRef(new Set),tu=m.useRef(new Set),nu=m.useRef(new Set),LR=m.useRef(new Set),Oa=m.useRef(null),Nre=m.useCallback(X=>{var mt;const Q=Co.current?nu.current:(mt=Oa.current)!=null&&mt.shift?Oa.current.nodeIds:null,le=Q&&Q.size>0?X.filter(be=>be.type!=="select"?!0:!(be.selected===!1&&Q.has(be.id))):X,ue=new Set;for(const be of le)be.type==="select"&&ue.add(be.id);const he=eQ(le,on.current),Ee=new Set;if(ur.current)for(const be of le)be.type==="dimensions"&&Ee.add(be.id);const ve=Ee.size===0?he:he.map(be=>!Ee.has(be.id)||be.width===void 0&&be.height===void 0?be:{...be,data:{...be.data,...be.width!==void 0?{width:be.width}:{},...be.height!==void 0?{height:be.height}:{}}}),Ae=je.current,nt=Co.current||Ae.size===0?ve:ve.map(be=>Ae.has(be.id)&&!ue.has(be.id)&&!be.selected?{...be,selected:!0}:be);if(on.current=nt,hr(nt),ue.size===0)return;if(Co.current){for(const be of le)be.type==="select"&&(be.selected?qa.current.add(be.id):qa.current.delete(be.id));return}const lt=tt.current;if(!lt)return;const yt=nt.filter(be=>be.selected).map(be=>be.id),Te=je.current;Te.size===yt.length&&yt.every(be=>Te.has(be))||(je.current=new Set(yt),lt(yt,[...pt.current]))},[]),Rf=m.useRef([]),Ire=m.useCallback(X=>{var yt;const Q=Co.current?LR.current:(yt=Oa.current)!=null&&yt.shift?Oa.current.edgeIds:null,le=Q&&Q.size>0?X.filter(Te=>Te.type!=="select"?!0:!(Te.selected===!1&&Q.has(Te.id))):X,ue=new Set;for(const Te of le)Te.type==="select"&&ue.add(Te.id);if(ue.size===0)return;if(Co.current){for(const Te of le)Te.type==="select"&&(Te.selected?tu.current.add(Te.id):tu.current.delete(Te.id));return}const he=tt.current;if(!he)return;const ve=tQ(le,Rf.current).filter(Te=>Te.selected).map(Te=>Te.id),Ae=pt.current;Ae.size===ve.length&&ve.every(Te=>Ae.has(Te))||(pt.current=new Set(ve),he([...je.current],ve))},[]),Are=m.useCallback(X=>{Co.current=!0;const Q=Oa.current,le=(Q==null?void 0:Q.shift)??(X.shiftKey||X.metaKey||X.ctrlKey);nu.current=le?new Set((Q==null?void 0:Q.nodeIds)??je.current):new Set,LR.current=le?new Set((Q==null?void 0:Q.edgeIds)??pt.current):new Set,qa.current=new Set(nu.current),tu.current=new Set(LR.current)},[]),Ere=m.useCallback(()=>{Co.current=!1,Oa.current=null;const X=tt.current;if(!X)return;const Q=[...qa.current],le=new Set(Q),ue=new Set(tu.current);for(const nt of Rf.current)le.has(nt.source)&&le.has(nt.target)&&ue.add(nt.id);const he=je.current,Ee=pt.current,ve=he.size===le.size&&Q.every(nt=>he.has(nt)),Ae=Ee.size===ue.size&&[...ue].every(nt=>Ee.has(nt));ve&&Ae||(je.current=new Set(Q),pt.current=new Set(ue),X(Q,[...ue]))},[]),$re=m.useCallback(X=>{if(Oa.current=null,ja.current||X.button!==0)return;const Q=X.target;Q!=null&&Q.classList.contains("react-flow__pane")&&(Oa.current={shift:X.shiftKey||X.metaKey||X.ctrlKey,nodeIds:new Set(je.current),edgeIds:new Set(pt.current)})},[]),jre=m.useCallback(X=>{if(!no.current.enableContextMenu||je.current.size<2)return;const le=X.target;le!==Z.current&&(le!=null&&le.closest(".seeflow-connector-endpoint-dot")||(X.preventDefault(),X.stopPropagation(),F.current=null,Ki(!0),Da(null),T(null),Gi({x:X.clientX,y:X.clientY})))},[]),Pre=m.useCallback(X=>{const Q=X.dataTransfer;if(!Q)return;const le=Q.types?Array.from(Q.types):[],ue=le.includes("Files"),he=le.includes(_W),Ee=ue&&!!A&&De.enableImageDrop,ve=he&&!!Y&&De.enableDragDrop;if(!(!Ee&&!ve)){X.preventDefault();try{Q.dropEffect="copy"}catch{}}},[A,Y,De.enableImageDrop,De.enableDragDrop]),zre=m.useCallback(X=>{const Q=X.dataTransfer;if((Q!=null&&Q.types?Array.from(Q.types):[]).includes(_W)&&Y&&De.enableDragDrop){X.preventDefault();const Ee=Xt.current;if(!Ee)return;const ve=Ee.screenToFlowPosition({x:X.clientX,y:X.clientY});Y({position:ve});return}if(!A||!De.enableImageDrop)return;const he={x:X.clientX,y:X.clientY};X.preventDefault(),oIe({dataTransfer:Q,clientPos:he,rfInstance:Xt.current,computeDims:rIe,dispatch:A})},[A,Y,De.enableImageDrop,De.enableDragDrop]),jF=!!V,PF=Je.size===1?[...Je][0]:null,NR=m.useMemo(()=>{const X=Ae=>{const nt=GG(Sn,Ae.source)==="running"||GG(Sn,Ae.target)==="running",lt=Je.has(Ae.id),yt=cTe(Ae,nt,lt);lt&&(yt.selected=!0);const Te=jF&&Ae.id===PF,Un=Te?{...yt,reconnectable:!0}:yt;return{...Un,data:{...Un.data,onLabelChange:vt?j:void 0,reconnectable:Te,registerEditHandle:Aa}}},Q=new Set(u.map(Ae=>Ae.id)),le=u.map(Ae=>X(htt(Ae,qn==null?void 0:qn[Ae.id]))),ue=[];if(qn)for(const[Ae,nt]of Object.entries(qn)){if(Q.has(Ae))continue;const lt=nt;typeof lt.source!="string"||typeof lt.target!="string"||ue.push(X({...lt,id:Ae}))}const he=[...le,...ue],Ee=[],ve=[];for(const Ae of he)Je.has(Ae.id)?ve.push(Ae):Ee.push(Ae);return[...Ee,...ve]},[u,Sn,Je,PF,qn,j,jF,Aa,vt]);m.useEffect(()=>{Rf.current=NR},[NR]);const Z0=e.adapter??null,Rre=m.useMemo(()=>{if(Z0!=null&&Z0.computeLayout)return async()=>{const X=Xt.current,Q=on.current;if(Q.length<2)return;const le=Q.map(mt=>{var X0;const be=(X0=X==null?void 0:X.getInternalNode(mt.id))==null?void 0:X0.measured,Yt=mt.data,ou=(be==null?void 0:be.width)??Yt.width??200,pr=(be==null?void 0:be.height)??Yt.height??120;return{id:mt.id,type:mt.type,width:ou,height:pr}}),ue=new Map;for(const mt of Q)ue.set(mt.id,mt.position);const he=Rf.current.map(mt=>({id:mt.id,source:mt.source,target:mt.target})),Ee=Z0.computeLayout;if(!Ee)return;const ve=await Ee(le,he),Ae=new Map;for(const[mt,be]of Object.entries(ve.nodes))Ae.set(mt,be.position);let nt=Number.POSITIVE_INFINITY,lt=Number.POSITIVE_INFINITY,yt=Number.POSITIVE_INFINITY,Te=Number.POSITIVE_INFINITY;for(const mt of le){const be=ue.get(mt.id);if(!be)continue;be.x<nt&&(nt=be.x),be.y<lt&&(lt=be.y);const Yt=Ae.get(mt.id);Yt&&(Yt.x<yt&&(yt=Yt.x),Yt.y<Te&&(Te=Yt.y))}const Un=Number.isFinite(nt)&&Number.isFinite(yt)?nt-yt:0,fr=Number.isFinite(lt)&&Number.isFinite(Te)?lt-Te:0;hr(mt=>mt.map(be=>{const Yt=Ae.get(be.id);return Yt?{...be,position:{x:Yt.x+Un,y:Yt.y+fr}}:be}))}},[Z0]),Tf=se??(vt?void 0:Rre),Df=m.useRef(!1),zF=m.useRef(null),Tre=m.useCallback(X=>{var Ae;if(!vt||!z)return;const{source:Q,target:le}=X;if(!Q||!le||Q===le)return;Df.current=!0;const ue=((Ae=zF.current)==null?void 0:Ae.nodeId)??null,he=ue!==null&&ue===le&&ue!==Q;z(he?le:Q,he?Q:le)},[z,vt]),IR=m.useCallback(X=>{const Q=le=>{if(!le)return!1;const ue=on.current.find(he=>he.id===le);return ue?ue.type==="text":!1};return!Q(X.source)&&!Q(X.target)},[]),Dre=m.useCallback((X,Q)=>{var yt;Gr(!1),Xr();const le=Df.current;if(Df.current=!1,le||To.current)return;if(_o.current){_o.current=!1;return}if(!z)return;const ue=(yt=Q.fromNode)==null?void 0:yt.id,he=Q.fromHandle;if(!ue||!he)return;const Ee=VG(X);if(!Ee)return;const ve=QT(Zt.current,Ee.clientX,Ee.clientY);if(!ve)return;const Ae=ve.getAttribute("data-id");if(!Ae||Ae===ue||!IR({source:ue,target:Ae,sourceHandle:null,targetHandle:null}))return;let nt;const lt=Xt.current;if(lt){const Te=lt.getInternalNode(Ae);if(Te){const Un=Te.measured.width??Te.width??0,fr=Te.measured.height??Te.height??0;if(Un>0&&fr>0){const mt=lt.screenToFlowPosition({x:Ee.clientX,y:Ee.clientY});nt=hH({x:Te.internals.positionAbsolute.x,y:Te.internals.positionAbsolute.y,w:Un,h:fr},mt)}}}z(ue,Ae,nt?{targetPin:nt}:void 0)},[z,Xr,IR]),Hf=m.useRef(!1),Hre=m.useCallback((X,Q)=>{if(!V)return;const{source:le,target:ue,sourceHandle:he,targetHandle:Ee}=Q;if(!le||!ue||le===ue)return;const ve={};if(le!==X.source&&(ve.source=le),ue!==X.target&&(ve.target=ue),typeof he=="string"&&he!==X.sourceHandle&&(ve.sourceHandle=he),typeof Ee=="string"&&Ee!==X.targetHandle&&(ve.targetHandle=Ee),ve.source===void 0&&ve.target===void 0&&ve.sourceHandle===void 0&&ve.targetHandle===void 0)return;(ve.source!==void 0||ve.sourceHandle!==void 0)&&(ve.sourceHandleAutoPicked=!1),(ve.target!==void 0||ve.targetHandle!==void 0)&&(ve.targetHandleAutoPicked=!1);const Ae=Xt.current;if(!(ve.source===void 0&&ve.target===void 0)&&Ae){const lt=ve.source!==void 0?"source":"target",yt=BG(lt,X.source,X.target,X.data,Te=>Ae.getInternalNode(Te)??null);yt&&(lt==="source"?ve.targetPin=yt:ve.sourcePin=yt)}Hf.current=!0,V(X.id,ve)},[V]),qre=m.useCallback((X,Q,le,ue)=>{var ou;Gr(!1),Xr(),To.current=!1;const he=Hf.current;if(Hf.current=!1,he)return;if(Ea.current){Ea.current=!1;return}if(!V)return;const Ee=VG(X);let ve=((ou=ue.toNode)==null?void 0:ou.id)??null;if(!ve&&Ee){const pr=QT(Zt.current,Ee.clientX,Ee.clientY);ve=(pr==null?void 0:pr.getAttribute("data-id"))??null}const Ae=le==="source"?"target":"source",nt=dtt(Ae,Q.source,Q.target,ve);if(nt==="no-op"||nt==="self-loop"||!Ee)return;const lt=Xt.current;if(!lt)return;const yt=nt==="pin-own"?Ae==="source"?Q.source:Q.target:ve,Te=lt.getInternalNode(yt);if(!Te)return;const Un=Te.measured.width??Te.width??0,fr=Te.measured.height??Te.height??0;if(Un===0||fr===0)return;const mt=lt.screenToFlowPosition({x:Ee.clientX,y:Ee.clientY}),be=hH({x:Te.internals.positionAbsolute.x,y:Te.internals.positionAbsolute.y,w:Un,h:fr},mt);if(nt==="pin-own"){if(!fn)return;fn(Q.id,Ae,be);return}const Yt=BG(Ae,Q.source,Q.target,Q.data,pr=>lt.getInternalNode(pr)??null);Ae==="source"?V(Q.id,{source:ve,sourceHandle:null,sourceHandleAutoPicked:!1,sourcePin:be,...Yt?{targetPin:Yt}:{}}):V(Q.id,{target:ve,targetHandle:null,targetHandleAutoPicked:!1,targetPin:be,...Yt?{sourcePin:Yt}:{}})},[V,Xr,fn]),Zi=m.useMemo(()=>{var Ae;if(!Do||!Fn)return null;const X=(Ae=Zt.current)==null?void 0:Ae.getBoundingClientRect(),Q=(X==null?void 0:X.left)??0,le=(X==null?void 0:X.top)??0,ue=Math.min(Do.x,Fn.x),he=Math.min(Do.y,Fn.y),Ee=Math.abs(Fn.x-Do.x),ve=Math.abs(Fn.y-Do.y);return{left:ue-Q,top:he-le,width:Ee,height:ve}},[Do,Fn]),Fa=jt?M2(Qa).node:void 0,Ore=jt?cee(jt):"",Fre=jt?lee(jt,Fa):void 0,Vre=jt==="text",[RF,TF]=m.useState(!1),[Bre,qf]=m.useState(!1),[Ure,DF]=m.useState(!1),Va=Jet({projectId:a,getReactFlow:()=>Xt.current});m.useImperativeHandle(t,()=>({exportPdf:Va.exportPdf,exportPng:Va.exportPng,openEmbedDialog:()=>DF(!0),capturePreview:Va.capturePreview}),[Va.exportPdf,Va.exportPng,Va.capturePreview]),m.useEffect(()=>{if(!De.enableKeyboard)return;const X=ue=>{if(!ue)return!1;const he=ue.tagName;return he==="INPUT"||he==="TEXTAREA"||he==="SELECT"?!0:ue instanceof HTMLElement&&ue.isContentEditable},Q=ue=>{ue.code==="Space"&&(X(document.activeElement)||(ue.preventDefault(),TF(!0)))},le=ue=>{ue.code==="Space"&&(TF(!1),qf(!1))};return window.addEventListener("keydown",Q),window.addEventListener("keyup",le),()=>{window.removeEventListener("keydown",Q),window.removeEventListener("keyup",le)}},[De.enableKeyboard]);const Of=m.useCallback(X=>{if(X.length!==0){if(!vt){const Q=Pf.current;for(const le of X)Q.set(le.id,{x:le.position.x,y:le.position.y});return}if(X.length===1){const Q=X[0];Q&&w&&w(Q.id,{x:Q.position.x,y:Q.position.y});return}if(g){g(X.map(Q=>({id:Q.id,position:{x:Q.position.x,y:Q.position.y}})));return}if(w)for(const Q of X)w(Q.id,{x:Q.position.x,y:Q.position.y})}},[w,g,vt]),HF=m.useCallback((X,Q,le)=>{In.current=!1,Of(le),Ra()},[Of,Ra]),qF=m.useCallback(()=>{In.current=!0},[]),OF=m.useCallback((X,Q)=>{In.current=!1,Of(Q),Ra()},[Of,Ra]),Wre=m.useCallback((X,Q)=>{dr.current&&Kr(null);const le=Zt.current;le&&le.style.setProperty("--rf-zoom",String(Q.zoom)),ct==null||ct(Q)},[ct]),Gre=m.useCallback(()=>{In.current=!0,ze==null||ze()},[ze]),Kre=m.useCallback((X,Q,le)=>{HF(X,Q,le),Qe==null||Qe()},[HF,Qe]),Zre=m.useCallback(()=>{qF(),ze==null||ze()},[qF,ze]),Xre=m.useCallback((X,Q)=>{OF(X,Q),Qe==null||Qe()},[OF,Qe]),Yre=m.useCallback((X,Q)=>{var le;(le=Wr.current.get(Q.id))==null||le()},[]),Qre=m.useCallback((X,Q)=>{re==null||re(Q.id)},[re]),Jre=m.useCallback(X=>{Be==null||Be()},[Be]),eae=m.useCallback((X,Q)=>{Pe==null||Pe(Q.id)},[Pe]),FF=jt?"crosshair":oo||RF?Bre?"grabbing":"grab":void 0,VF=h[0],BF=f[0],tae=VF?l.find(X=>X.id===VF)??null:null,nae=BF?u.find(X=>X.id===BF)??null:null,oae=a??null,rae=De.showDetailPanel&&!G,aae=m.useMemo(()=>({custom:Cn??{}}),[Cn]);return p.jsx(uHe,{value:aae,children:p.jsx("div",{"data-testid":"seeflow-canvas","data-mode":n,"data-canvas-mode":sn.kind,ref:Zt,className:"seeflow-canvas-root sf:relative sf:h-full sf:w-full",style:FF?{cursor:FF}:void 0,onPointerDownCapture:$re,onPointerDown:X=>{RF&&qf(!0),It(X)},onPointerMove:B0,onPointerUp:X=>{qf(!1),U0(X)},onPointerCancel:()=>{za.current=!1,Pa.current=null,Wi.current=null,On(null),Ho(null),qf(!1)},onContextMenuCapture:jre,onDragOver:Pre,onDrop:zre,children:p.jsxs(bFe,{containerRef:Zt,children:[p.jsxs(CRe,{nodes:K0,edges:NR,onNodesChange:Nre,nodeTypes:ftt,edgeTypes:ptt,proOptions:mtt,fitView:!0,minZoom:n==="mini"?.05:.5,nodesDraggable:(vt?!!w:!0)&&!jt&&!oo&&De.enableNodeMove,nodesConnectable:vt&&!!z&&!jt&&!oo,deleteKeyCode:vt?["Backspace","Delete"]:null,zoomOnScroll:De.enableZoom,zoomOnPinch:De.enableZoom,className:bo?"seeflow-connecting":void 0,onConnect:vt?Tre:void 0,isValidConnection:IR,onConnectStart:(X,Q)=>{Gr(!0),Df.current=!1,zF.current={nodeId:Q.nodeId??null,handleType:Q.handleType??null},$a(Q.nodeId??null)},onConnectEnd:Dre,onReconnect:vt&&V?Hre:void 0,onReconnectStart:(X,Q,le)=>{Gr(!0),Hf.current=!1,To.current=!0;const ue=le==="source"?Q.source:Q.target;$a(ue)},onReconnectEnd:qre,connectionLineComponent:V0,connectionLineStyle:{strokeWidth:2},connectionRadius:32,reconnectRadius:10,edgesReconnectable:!1,elevateNodesOnSelect:!1,elementsSelectable:!jt&&!oo&&De.enableSelection,selectNodesOnDrag:!1,nodeClickDistance:5,selectionOnDrag:!jt&&!oo&&De.enableSelection,panOnDrag:jt?!1:oo?[0,1,2]:De.enablePan?[1,2]:!1,selectionMode:c0.Partial,selectionKeyCode:null,multiSelectionKeyCode:jt?null:["Meta","Shift"],panActivationKeyCode:jt?null:"Space",onSelectionStart:Are,onSelectionEnd:Ere,defaultEdgeOptions:ytt,zoomOnDoubleClick:!1,onInit:X=>{Xt.current=X;const Q=Zt.current;Q&&Q.style.setProperty("--rf-zoom",String(X.getZoom())),Q&&Q.setAttribute("data-canvas-ready","true"),!lr.current&&cr.onMount&&l.length>0&&(X.fitView(f2),lr.current=!0),ae==null||ae(X)},onMove:Wre,onEdgesChange:Ire,onNodeDragStart:Gre,onNodeDragStop:Kre,onSelectionDragStart:Zre,onSelectionDragStop:Xre,onNodeClick:Qre,onEdgeClick:eae,onEdgeDoubleClick:Yre,onPaneClick:Jre,onNodeContextMenu:De.enableContextMenu&&zf?(X,Q)=>{X.preventDefault(),F.current=Q.id,Ki(!0),Da(Q.type??null),T(null),Gi({x:X.clientX,y:X.clientY})}:void 0,onPaneContextMenu:De.enableContextMenu&&I?X=>{X.preventDefault(),F.current=null,Ki(!1),Da(null),T(null),Gi({x:X.clientX,y:X.clientY})}:void 0,children:[p.jsx(vtt,{storeApiRef:Ui}),p.jsx(xtt,{wrapperRef:Zt}),p.jsx(PRe,{gap:12,size:.6}),n!=="mini"&&p.jsx(ott,{}),De.showControls?p.jsxs(ORe,{showInteractive:!1,showFitView:!1,children:[p.jsx($u,{"data-testid":"controls-fit-view","aria-label":"Fit view",title:"Fit view",disabled:l.length===0,onClick:()=>{var X;(X=Xt.current)==null||X.fitView(f2)},children:p.jsx(pd,{className:"sf:h-3 sf:w-3","aria-hidden":"true"})}),p.jsx($u,{"data-testid":"controls-tidy","aria-label":"Tidy layout (⌘⇧L)",title:"Tidy layout (⌘⇧L)",disabled:!Tf,onClick:()=>Tf==null?void 0:Tf(),children:p.jsx(W2,{className:"sf:h-3 sf:w-3","aria-hidden":"true"})})]}):null,De.showMiniMap?p.jsx(eTe,{className:"sf-canvas-minimap"}):null,De.showResizeHandles?p.jsx(ZJe,{selectedNodes:kn,onMultiResize:_}):null,r||De.showToolbar||De.showStyleStrip&&J&&ce?p.jsx(f0,{position:"top-left",children:p.jsxs("div",{className:"sf:flex sf:flex-col sf:items-start sf:gap-2",children:[r,De.showToolbar?p.jsx(wWe,{mode:sn,onModeChange:W,iconPickerOpen:Gt??!1,onOpenIconPicker:Et,onCloseIconPicker:hn,onPickIcon:fe,showShapeTools:vt&&!!N}):null,De.showStyleStrip&&J&&ce?p.jsx(XJe,{nodes:Bn,connectors:ee??[],onStyleNode:J,onStyleNodePreview:ne,onStyleNodes:oe,onStyleNodesPreview:te,onStyleConnector:ce,onStyleConnectorPreview:ge,onRequestIconReplace:Se}):null]})}):null,De.showShareMenu||De.showRestart&&Ne?p.jsx(f0,{position:"top-right",children:p.jsxs("div",{className:"sf:flex sf:items-center sf:gap-1",children:[De.showRestart&&Ne?p.jsx(UJe,{onRestartDemo:Ne}):null,De.showShareMenu?p.jsx(BJe,{mode:n==="mini"?"view":n,projectId:a,enableEmbed:De.enableEmbed,onDownloadPdf:Va.exportPdf,onDownloadPng:Va.exportPng,onExportToCloud:Tt,embedOpen:Ure,onEmbedOpenChange:DF}):null]})}):null]}),Zi?p.jsx("div",{"data-testid":"canvas-draw-ghost","data-ghost-shape":jt??void 0,"aria-hidden":!0,className:ie("sf:pointer-events-none sf:absolute sf:z-10",Ore,Vre?"sf:rounded-sm sf:border sf:border-dashed sf:border-muted-foreground/40":""),style:{...Fre,left:Zi.left,top:Zi.top,width:Zi.width,height:Zi.height},children:(()=>{const X=jt?OO[jt]:void 0;if(!X)return null;const Q=dee(Fa);return p.jsx(X,{width:Zi.width,height:Zi.height,borderColor:Q.borderColor,backgroundColor:Q.backgroundColor,borderSize:(Fa==null?void 0:Fa.borderSize)??vO,borderStyle:Fa==null?void 0:Fa.borderStyle})})()}):null,De.enableContextMenu&&zf?p.jsxs(hUe,{onOpenChange:X=>{X||(Gi(null),F.current=null,Da(null),T(null))},children:[p.jsx(fUe,{asChild:!0,children:p.jsx("div",{ref:Z,"data-testid":"node-context-menu-trigger","aria-hidden":!0,className:"sf:pointer-events-none sf:fixed",style:{left:(Vn==null?void 0:Vn.x)??0,top:(Vn==null?void 0:Vn.y)??0,width:0,height:0}})}),p.jsxs(qte,{"data-testid":"node-context-menu",children:[Ha!=null&&Ha.pinned&&pn?p.jsx(_r,{"data-testid":"connector-endpoint-context-menu-unpin",onSelect:Me,children:"Unpin"}):null,Ta&&P?p.jsxs(_r,{"data-testid":"node-context-menu-copy",onSelect:de,children:["Copy",p.jsx(zH,{children:eu})]}):null,I?p.jsxs(_r,{"data-testid":"node-context-menu-paste",disabled:!L,onSelect:st,children:["Paste",p.jsx(zH,{children:ro})]}):null,Ta&&(P||I)&&(G0==="icon"&&Se||H||O)?p.jsx(sP,{}):null,Ta&&G0==="icon"&&Se?p.jsx(_r,{"data-testid":"node-context-menu-change-icon",onSelect:$e,children:"Change icon"}):null,Ta&&G0==="icon"&&Se&&(H||O)?p.jsx(sP,{}):null,Ta&&H?p.jsxs(p.Fragment,{children:[p.jsx(_r,{"data-testid":"node-context-menu-to-front",onSelect:()=>B({op:"toFront"}),children:"Bring to front"}),p.jsx(_r,{"data-testid":"node-context-menu-forward",onSelect:()=>B({op:"forward"}),children:"Bring forward"}),p.jsx(_r,{"data-testid":"node-context-menu-backward",onSelect:()=>B({op:"backward"}),children:"Send backward"}),p.jsx(_r,{"data-testid":"node-context-menu-to-back",onSelect:()=>B({op:"toBack"}),children:"Send to back"})]}):null,Ta&&H&&O?p.jsx(sP,{}):null,Ta&&O?p.jsx(_r,{"data-testid":"node-context-menu-delete",onSelect:q,children:"Delete"}):null]})]}):null,Ve?p.jsxs(Rd,{open:!!yn,onOpenChange:X=>{X||Kr(null)},children:[p.jsx(_Fe,{asChild:!0,children:p.jsx("div",{"data-testid":"drop-popover-anchor","aria-hidden":!0,className:"sf:pointer-events-none sf:fixed",style:{left:(yn==null?void 0:yn.clientX)??0,top:(yn==null?void 0:yn.clientY)??0,width:0,height:0}})}),p.jsx(zi,{"data-testid":"drop-popover",align:"start",side:"bottom",sideOffset:4,className:"sf:w-auto sf:p-1",onOpenAutoFocus:X=>{X.preventDefault()},children:p.jsx("div",{role:"menu","aria-label":"Create connected node",className:"sf:flex sf:flex-col sf:gap-0.5",children:xWe.map(({shape:X,label:Q,Icon:le})=>p.jsxs("button",{type:"button",role:"menuitem","data-testid":`drop-popover-shape-${X}`,onClick:()=>{const ue=yn;ue&&(Ve({sourceNodeId:ue.sourceNodeId,position:{x:ue.flowX,y:ue.flowY},shape:X}),Kr(null))},className:ie("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:Q})]},X))})})]}):null,rae?p.jsx(mJe,{flowId:oae,node:tae,connector:nae,adapter:o??null,statusReport:K,onNameChange:qe,onDescriptionChange:Ze,onDetailChange:Kt,onIconChange:tn,onClose:()=>{var X;(X=tt.current)==null||X.call(tt,[],[])}}):null]})})})}const Stt=m.forwardRef(Ctt);function Ltt({open:e,onOpenChange:t,onCreated:n}){const[o,r]=m.useState(""),[a,i]=m.useState(""),[s,c]=m.useState(""),[l,u]=m.useState(null),[h,f]=m.useState(!1);m.useEffect(()=>{e&&(r(""),i(""),c(""),u(null),f(!1))},[e]);const y=o.trim(),k=a.trim(),v=s.trim(),w=y.length>0&&k.length>0&&!h,g=async M=>{if(M.preventDefault(),!!w){f(!0),u(null);try{const x=await Tse({path:y,name:k,...v.length>0?{description:v}:{}});n(x),t(!1)}catch(x){u(x instanceof Error?x.message:String(x)),f(!1)}}};return p.jsx(wa,{open:e,onOpenChange:t,children:p.jsxs(Ri,{className:"sm:max-w-md","data-testid":"create-project-dialog",onOpenAutoFocus:M=>{M.preventDefault();const x=document.querySelector('[data-testid="create-project-path-input"]');x==null||x.focus()},children:[p.jsxs(Ti,{children:[p.jsx(Di,{children:"Create new project"}),p.jsx(Hi,{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(Ma,{children:[p.jsx(dt,{type:"button",variant:"ghost",onClick:()=>t(!1),disabled:h,children:"Cancel"}),p.jsx(dt,{type:"submit",disabled:!w,"data-testid":"create-project-submit",children:h?"Creating…":"Create project"})]})]})]})})}const Ntt="seeflow:last-flow:",tre=e=>`${Ntt}${e}`,nre=e=>{if(typeof window>"u")return null;try{return window.localStorage.getItem(tre(e))}catch{return null}},Itt=(e,t)=>{if(!(typeof window>"u"))try{window.localStorage.setItem(tre(e),t)}catch{}},Att=(e,t)=>{var o;if(e.length===0)return null;if(t){const r=e.find(a=>a.flowSlug===t);if(r)return r.flowSlug}const n=e.find(r=>r.isDefault);return n?n.flowSlug:((o=e[0])==null?void 0:o.flowSlug)??null},JH="seeflow:navigate",Ett=e=>(window.addEventListener("popstate",e),window.addEventListener(JH,e),()=>{window.removeEventListener("popstate",e),window.removeEventListener(JH,e)}),KG=()=>window.location.pathname,$tt=()=>m.useSyncExternalStore(Ett,KG,KG),jr=e=>{e!==window.location.pathname&&(window.history.pushState({},"",e),window.dispatchEvent(new Event(JH)))},ui=(e,t)=>`/projects/${encodeURIComponent(e)}/flows/${encodeURIComponent(t)}`,jtt=e=>{const t=e.split("/").filter(Boolean);if(t.length!==4||t[0]!=="projects"||t[2]!=="flows")return null;const n=decodeURIComponent(t[1]??""),o=decodeURIComponent(t[3]??"");return!n||!o?null:{project:n,flow:o}},ore=e=>{const t=e.indexOf("/");return t<0?ui(e,""):ui(e.slice(0,t),e.slice(t+1))},Ptt=e=>{const t=e.split("/").filter(Boolean);if(t.length!==2||t[0]!=="projects")return null;const n=decodeURIComponent(t[1]??"");return n?{project:n}:null};/**
|
|
8545
8545
|
* @license lucide-react v0.453.0 - ISC
|
|
8546
8546
|
*
|
|
8547
8547
|
* This source code is licensed under the ISC license.
|
|
@@ -8616,4 +8616,4 @@ For more information, see https://radix-ui.com/primitives/docs/components/${t.do
|
|
|
8616
8616
|
*
|
|
8617
8617
|
* This source code is licensed under the ISC license.
|
|
8618
8618
|
* See the LICENSE file in the root directory of this source tree.
|
|
8619
|
-
*/const Vtt=ar("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 Btt({projects:e,currentProjectSlug:t,onProjectCreated:n,onUnregisterProject:o}){const[r,a]=m.useState(!1),[i,s]=m.useState(!1),[c,l]=m.useState(null),[u,h]=m.useState(!1),[f,y]=m.useState(null);m.useEffect(()=>{const C=_=>{_.key==="k"&&(_.metaKey||_.ctrlKey)&&(_.preventDefault(),a(S=>!S))};return document.addEventListener("keydown",C),()=>document.removeEventListener("keydown",C)},[]);const k=e.find(C=>C.projectSlug===t),v=C=>{const S=nre(C.projectSlug)??C.defaultFlow;jr(ui(C.projectSlug,S))},w=C=>{n==null||n(C)},g=C=>{l(C),y(null)},M=()=>{u||(l(null),y(null))},x=async()=>{if(c){h(!0),y(null);try{await(o==null?void 0:o(c.projectSlug)),l(null)}catch(C){y(C instanceof Error?C.message:String(C))}finally{h(!1)}}},b=(c==null?void 0:c.flowCount)??0;return p.jsxs(p.Fragment,{children:[p.jsxs(Rd,{open:r,onOpenChange:a,children:[p.jsx(D0,{asChild:!0,children:p.jsxs(dt,{type:"button",variant:"outline",size:"sm","aria-label":"Switch project","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 project"}),p.jsx(Tee,{children:"⌘K"}),p.jsx(ire,{className:"h-3.5 w-3.5 opacity-60"})]})}),p.jsx(zi,{align:"end",sideOffset:6,className:"w-[320px] p-0","data-testid":"project-switcher-popover",children:p.jsxs(GO,{children:[p.jsx(Ree,{placeholder:"Search projects..."}),p.jsxs(KO,{children:[p.jsx(ZO,{children:"No projects."}),e.length>0?p.jsx(Uh,{heading:"Projects",children:e.map(C=>p.jsxs(Wh,{value:`${C.name} ${C.projectSlug}`,onSelect:()=>{a(!1),v(C)},"data-testid":`project-switcher-row-${C.projectSlug}`,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:C.name}),C.repoPath?p.jsx("span",{className:"w-full truncate text-xs text-muted-foreground",children:C.repoPath}):null]}),p.jsx("button",{type:"button","aria-label":`Unregister ${C.name}`,"data-testid":`project-switcher-unregister-${C.projectSlug}`,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:_=>{_.stopPropagation(),a(!1),g(C)},children:p.jsx(lre,{className:"h-3.5 w-3.5"})})]},C.projectSlug))}):null,e.length>0?p.jsx(XO,{}):null,p.jsx(Uh,{children:p.jsxs(Wh,{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(cre,{className:"h-4 w-4 opacity-70"}),p.jsx("span",{className:"font-medium",children:"Create new project"})]})})]})]})})]}),p.jsx(Ltt,{open:i,onOpenChange:s,onCreated:w}),p.jsx(wa,{open:c!==null,onOpenChange:C=>{C||M()},children:p.jsxs(Ri,{className:"sm:max-w-md","data-testid":"unregister-project-dialog",children:[p.jsxs(Ti,{children:[p.jsx(Di,{children:"Unregister project?"}),p.jsxs(Hi,{children:["This removes ",p.jsx("strong",{children:c==null?void 0:c.name})," from SeeFlow."," ",p.jsxs("strong",{children:["All ",b," ",b===1?"flow":"flows"]})," ","under this project will be unregistered.",c!=null&&c.repoPath?p.jsxs(p.Fragment,{children:[" ","Your files at ",p.jsx("code",{className:"text-xs",children:c.repoPath})," will not be deleted."]}):null]})]}),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(Ma,{children:[p.jsx(dt,{type:"button",variant:"ghost",onClick:M,disabled:u,children:"Cancel"}),p.jsx(dt,{type:"button",variant:"destructive",onClick:x,disabled:u,"data-testid":"unregister-project-confirm",children:u?"Unregistering…":"Unregister"})]})]})})]})}const dre="seeflow:theme",ZG="(prefers-color-scheme: dark)";function Utt(e){return e==="light"||e==="dark"||e==="system"}function Wtt(e){try{const t=e.getItem(dre);return Utt(t)?t:"system"}catch{return"system"}}function Gtt(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 Ktt(e,t){try{e.setItem(dre,t)}catch{}}function Ztt(e,t){return e==="system"?t?"dark":"light":e}function Xtt(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 Qtt(){const[e,t]=m.useState(()=>{if(typeof window>"u")return"system";const i=Gtt(window.location.search);return i||Wtt(window.localStorage)}),[n,o]=m.useState(()=>typeof window>"u"?!1:window.matchMedia(ZG).matches);m.useEffect(()=>{if(typeof window>"u")return;const i=window.matchMedia(ZG);return Ytt(i,o)},[]);const r=Ztt(e,n);m.useEffect(()=>{typeof document>"u"||Xtt(document.documentElement,r)},[r]);const a=m.useCallback(i=>{typeof window<"u"&&Ktt(window.localStorage,i),t(i)},[]);return{theme:e,setTheme:a,resolvedTheme:r}}const Jtt=[{value:"light",label:"Light"},{value:"dark",label:"Dark"},{value:"system",label:"System"}];function ent({projects:e,currentProjectSlug:t,onProjectCreated:n,onUnregisterProject:o}){const{theme:r,setTheme:a}=Qtt();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:shadow-[0_4px_12px_-6px_rgba(0,0,0,0.6)]",children:[p.jsxs("button",{type:"button",onClick:()=>jr("/"),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(Vtt,{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.81"]})]}),p.jsxs("div",{className:"flex items-center gap-3",children:[p.jsx(Btt,{projects:e,currentProjectSlug:t,onProjectCreated:n,onUnregisterProject:o}),p.jsxs(ane,{children:[p.jsx(ine,{asChild:!0,children:p.jsx(dt,{type:"button",variant:"outline",size:"icon","aria-label":"Settings","data-testid":"settings-trigger",children:p.jsx(Ott,{className:"h-4 w-4"})})}),p.jsxs(aF,{align:"end",sideOffset:6,className:"w-44","data-testid":"settings-menu",children:[p.jsx(sne,{children:"Theme"}),p.jsx(DUe,{value:r,onValueChange:i=>a(i),children:Jtt.map(i=>p.jsx(cne,{value:i.value,"data-testid":`theme-${i.value}`,children:i.label},i.value))})]})]})]})]})}const tnt=(e,t)=>{const n=e!==null&&t!==null,[o,r]=m.useState(null),[a,i]=m.useState(n),[s,c]=m.useState(null),l=m.useCallback(()=>{!e||!t||(i(!0),SX(e,t).then(h=>{r(h),c(null)}).catch(h=>{console.error("[useDemoData] failed",h),c(String(h))}).finally(()=>i(!1)))},[e,t]),u=m.useCallback(h=>{r(h),c(null)},[]);return m.useEffect(()=>{if(!e||!t){r(null),i(!1);return}l()},[e,t,l]),{detail:o,loading:a,error:s,refresh:l,applyDetail:u}},nnt=()=>{const[e,t]=m.useState(null),[n,o]=m.useState(null),r=m.useCallback(()=>jse().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}},ont=5,rnt={"node:running":"running","node:done":"done","node:error":"error"},ant=(e,t)=>{if(t.type==="reset")return{};const n=e[t.nodeId]??[],o=[t.entry,...n].slice(0,ont);return{...e,[t.nodeId]:o}},int=e=>{const[t,n]=m.useReducer(ant,{}),o=m.useRef(n);o.current=n,m.useEffect(()=>{o.current({type:"reset"})},[e]);const r=m.useCallback(i=>{const s=rnt[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,u=typeof i.ts=="number"?i.ts:Date.now();o.current({type:"append",nodeId:c,entry:{status:s,ts:u,runId:l}})},[]),a=m.useCallback(()=>{o.current({type:"reset"})},[]);return{events:t,apply:r,reset:a}},snt=(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()}}}},cnt=e=>{const[t,n]=m.useReducer(snt,{}),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}},lnt=new Set(["ok","warn","error","pending"]),dnt=(e,t)=>{if(t.type!=="node:status")return e;const n=typeof t.nodeId=="string"?t.nodeId:null;if(!n||typeof t.state!="string"||!lnt.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}}},unt=(e,t)=>{switch(t.type){case"reset":return{};case"event":return dnt(e,t.event)}},hnt=e=>{const[t,n]=m.useReducer(unt,{}),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}},ure=e=>{const t=e!==null,[n,o]=m.useState(null),[r,a]=m.useState(t),[i,s]=m.useState(null),c=m.useCallback(()=>{e&&(a(!0),CX(e).then(f=>{o(f),s(null)}).catch(f=>{console.error("[useProjectFlows] failed",f),o([]),s(String(f))}).finally(()=>a(!1)))},[e]);m.useEffect(()=>{if(!e){o(null),a(!1);return}c()},[e,c]);const l=m.useCallback(async f=>{if(!e)throw new Error("no-project");const y=await zse(e,f);return c(),y},[e,c]),u=m.useCallback(async(f,y)=>{if(!e)throw new Error("no-project");const k=await Rse(e,f,y);return c(),k},[e,c]),h=m.useCallback(async(f,y)=>{if(!e)throw new Error("no-project");const k=await LX(e,f,y);return c(),k},[e,c]);return{flows:n,loading:r,error:i,refresh:c,createFlow:l,renameFlow:u,deleteFlow:h}},fnt=()=>{const[e,t]=m.useState(null),[n,o]=m.useState(!0),[r,a]=m.useState(null),i=m.useCallback(()=>(o(!0),Pse().then(c=>{t(c),a(null)}).catch(c=>{console.error("[useProjects] failed",c),t([]),a(String(c))}).finally(()=>o(!1))),[]);m.useEffect(()=>{i()},[i]);const s=m.useCallback(async c=>{const u=[...await CX(c)].sort((h,f)=>h.isDefault===f.isDefault?0:h.isDefault?1:-1);for(const h of u)await LX(c,h.flowSlug);await i()},[i]);return{projects:e,loading:n,error:r,refresh:i,unregisterProject:s}},pnt=(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}},ynt=(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 u=`/api/events?flowId=${encodeURIComponent(e)}`,h=new EventSource(u);h.addEventListener("open",()=>o(!0)),h.addEventListener("error",()=>o(!1)),h.addEventListener("hello",()=>{var f;(f=s.current)==null||f.call(s)}),h.addEventListener("flow:reload",f=>{var v,w;const y=XG(f,"flow:reload");(v=l.current)==null||v.call(l,y);const k=mnt(y);k&&((w=c.current)==null||w.call(c,k))});for(const f of["node:running","node:done","node:error","node:status"])h.addEventListener(f,y=>{var k;(k=l.current)==null||k.call(l,XG(y,f))});return()=>{h.close()}},[e]),{connected:n}},XG=(e,t)=>{try{const n=JSON.parse(e.data);return{type:t,ts:Date.now(),...n}}catch{return{type:t,ts:Date.now()}}},mnt=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,hre="seeflow:last-project",knt=()=>{if(typeof window>"u")return null;try{return window.localStorage.getItem(hre)}catch{return null}},YG=e=>{if(!(typeof window>"u"))try{window.localStorage.setItem(hre,e)}catch{}},gnt=(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},QG=["File","Edit","View","Tools","Layout","Selection","Help"],fre="seeflow:command-palette:recent",pre=5,yre=new Map(kO.map(e=>[e.id,e])),vnt=e=>typeof e=="string"&&yre.has(e),JG=()=>{if(typeof window>"u")return[];try{const e=window.localStorage.getItem(fre);if(!e)return[];const t=JSON.parse(e);return Array.isArray(t)?t.filter(vnt).slice(0,pre):[]}catch{return[]}},xnt=e=>{if(!(typeof window>"u"))try{window.localStorage.setItem(fre,JSON.stringify(e))}catch{}},eK=(e,t)=>e.enabled?e.enabled(t):!0,wnt=(e,t)=>t.length===0?!0:`${e.label} ${e.description??""}`.toLowerCase().includes(t);function Mnt({open:e,onOpenChange:t,runCommand:n,ctx:o}){const[r,a]=m.useState(""),[i,s]=m.useState(0),[c,l]=m.useState(()=>JG()),u=m.useRef(null),h=m.useRef(null);m.useEffect(()=>{e&&(a(""),s(0),l(JG()))},[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 j=[];for(const A of c){const R=yre.get(A);R&&j.push({cmd:R,enabled:eK(R,o)})}return{groups:[{category:"Recent",rows:j}],flat:j}}const C=new Map;for(const j of kO){if(!wnt(j,b))continue;const N={cmd:j,enabled:eK(j,o)},A=C.get(j.category);A?A.push(N):C.set(j.category,[N])}const S=[...QG.filter(j=>C.has(j)),...Array.from(C.keys()).filter(j=>!QG.includes(j))].map(j=>({category:j,rows:C.get(j)??[]})),$=S.flatMap(j=>j.rows);return{groups:S,flat:$}},[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($=>$.enabled);S!==-1&&(C=S)}return C})},[y]);const k=m.useCallback(b=>{y.length!==0&&s(C=>{var S;let _=C;for(let $=0;$<y.length;$++)if(_=(_+b+y.length)%y.length,(S=y[_])!=null&&S.enabled)return _;return C})},[y]),v=m.useCallback(b=>{l(C=>{const _=[b,...C.filter(S=>S!==b)].slice(0,pre);return xnt(_),_})},[]),w=m.useCallback(b=>{const C=y[b];!C||!C.enabled||(v(C.cmd.id),n(C.cmd.id),t(!1))},[y,t,v,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=h.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 x=r.trim().length>0;return p.jsx(iR,{open:e,onOpenChange:t,children:p.jsx(sR,{children:p.jsxs(H0,{className:ie("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=u.current)==null||C.focus()},children:[p.jsx("div",{className:ie("border-b",y.length===0&&!x&&"border-b-0"),children:p.jsx("input",{ref:u,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:h,"data-testid":"command-palette-list","data-empty":y.length===0?"true":"false",className:ie("max-h-[50vh] overflow-y-auto",y.length>0?"py-1":"","seeflow-no-scrollbar"),children:y.length===0?x?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,$=S===i;return p.jsxs("button",{type:"button","data-testid":`command-palette-row-${_.cmd.id}`,"data-command-row-index":S,"data-highlighted":$?"true":"false","aria-disabled":_.enabled?void 0:!0,disabled:!_.enabled,onMouseEnter:()=>{_.enabled&&s(S)},onClick:()=>w(S),className:ie("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",$&&_.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 bn=Uint8Array,po=Uint16Array,AF=Int32Array,EF=new bn([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]),$F=new bn([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]),tK=new bn([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),mre=function(e,t){for(var n=new po(31),o=0;o<31;++o)n[o]=t+=1<<e[o-1];for(var r=new AF(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}},kre=mre(EF,2),bnt=kre.b,eq=kre.r;bnt[28]=258,eq[258]=28;var _nt=mre($F,0),nK=_nt.r,tq=new po(32768);for(var Ct=0;Ct<32768;++Ct){var Ya=(Ct&43690)>>1|(Ct&21845)<<1;Ya=(Ya&52428)>>2|(Ya&13107)<<2,Ya=(Ya&61680)>>4|(Ya&3855)<<4,tq[Ct]=((Ya&65280)>>8|(Ya&255)<<8)>>1}var ph=function(e,t,n){for(var o=e.length,r=0,a=new po(t);r<o;++r)e[r]&&++a[e[r]-1];var i=new po(t);for(r=1;r<t;++r)i[r]=i[r-1]+a[r-1]<<1;var s;if(n){s=new po(1<<t);var c=15-t;for(r=0;r<o;++r)if(e[r])for(var l=r<<4|e[r],u=t-e[r],h=i[e[r]-1]++<<u,f=h|(1<<u)-1;h<=f;++h)s[tq[h]>>c]=l}else for(s=new po(o),r=0;r<o;++r)e[r]&&(s[r]=tq[i[e[r]-1]++]>>15-e[r]);return s},$d=new bn(288);for(var Ct=0;Ct<144;++Ct)$d[Ct]=8;for(var Ct=144;Ct<256;++Ct)$d[Ct]=9;for(var Ct=256;Ct<280;++Ct)$d[Ct]=7;for(var Ct=280;Ct<288;++Ct)$d[Ct]=8;var mz=new bn(32);for(var Ct=0;Ct<32;++Ct)mz[Ct]=5;var Cnt=ph($d,9,0),Snt=ph(mz,5,0),gre=function(e){return(e+7)/8|0},vre=function(e,t,n){return(n==null||n>e.length)&&(n=e.length),new bn(e.subarray(t,n))},Lnt=["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"],SR=function(e,t,n){var o=new Error(t||Lnt[e]);if(o.code=e,Error.captureStackTrace&&Error.captureStackTrace(o,SR),!n)throw o;return o},na=function(e,t,n){n<<=t&7;var o=t/8|0;e[o]|=n,e[o+1]|=n>>8},p2=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},JT=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:wre,l:0};if(r==1){var i=new bn(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,u=1,h=2;for(n[0]={s:-1,f:s.f+c.f,l:s,r:c};u!=r-1;)s=n[n[l].f<n[h].f?l++:h++],c=n[l!=u&&n[l].f<n[h].f?l++:h++],n[u++]={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 po(f+1),k=nq(n[u-1],y,0);if(k>t){var o=0,v=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)v+=g-(1<<k-y[M]),y[M]=t;else break}for(v>>=w;v>0;){var x=a[o].s;y[x]<t?v-=1<<t-y[x]++-1:++o}for(;o>=0&&v;--o){var b=a[o].s;y[b]==t&&(--y[b],++v)}k=t}return{t:new bn(y),l:k}},nq=function(e,t,n){return e.s==-1?Math.max(nq(e.l,t,n+1),nq(e.r,t,n+1)):t[e.s]=n},oK=function(e){for(var t=e.length;t&&!e[--t];);for(var n=new po(++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}},y2=function(e,t){for(var n=0,o=0;o<t.length;++o)n+=e[o]*t[o];return n},xre=function(e,t,n){var o=n.length,r=gre(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},rK=function(e,t,n,o,r,a,i,s,c,l,u){na(t,u++,n),++r[256];for(var h=JT(r,15),f=h.t,y=h.l,k=JT(a,15),v=k.t,w=k.l,g=oK(f),M=g.c,x=g.n,b=oK(v),C=b.c,_=b.n,S=new po(19),$=0;$<M.length;++$)++S[M[$]&31];for(var $=0;$<C.length;++$)++S[C[$]&31];for(var j=JT(S,7),N=j.t,A=j.l,R=19;R>4&&!N[tK[R-1]];--R);var Y=l+5<<3,z=y2(r,$d)+y2(a,mz)+i,V=y2(r,f)+y2(a,v)+i+14+3*R+y2(S,N)+2*S[16]+3*S[17]+7*S[18];if(c>=0&&Y<=z&&Y<=V)return xre(t,u,e.subarray(c,c+l));var H,O,P,I;if(na(t,u,1+(V<z)),u+=2,V<z){H=ph(f,y,0),O=f,P=ph(v,w,0),I=v;var L=ph(N,A,0);na(t,u,x-257),na(t,u+5,_-1),na(t,u+10,R-4),u+=14;for(var $=0;$<R;++$)na(t,u+3*$,N[tK[$]]);u+=3*R;for(var U=[M,C],D=0;D<2;++D)for(var E=U[D],$=0;$<E.length;++$){var ee=E[$]&31;na(t,u,L[ee]),u+=N[ee],ee>15&&(na(t,u,E[$]>>5&127),u+=E[$]>>12)}}else H=Cnt,O=$d,P=Snt,I=mz;for(var $=0;$<s;++$){var J=o[$];if(J>255){var ee=J>>18&31;p2(t,u,H[ee+257]),u+=O[ee+257],ee>7&&(na(t,u,J>>23&31),u+=EF[ee]);var ne=J&31;p2(t,u,P[ne]),u+=I[ne],ne>3&&(p2(t,u,J>>5&8191),u+=$F[ne])}else p2(t,u,H[J]),u+=O[J]}return p2(t,u,H[256]),u+O[256]},Nnt=new AF([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),wre=new bn(0),Int=function(e,t,n,o,r,a){var i=a.z||e.length,s=new bn(o+i+5*(1+Math.ceil(i/7e3))+r),c=s.subarray(o,s.length-r),l=a.l,u=(a.r||0)&7;if(t){u&&(c[0]=a.r>>3);for(var h=Nnt[t-1],f=h>>13,y=h&8191,k=(1<<n)-1,v=a.p||new po(32768),w=a.h||new po(k+1),g=Math.ceil(n/3),M=2*g,x=function(Pe){return(e[Pe]^e[Pe+1]<<g^e[Pe+2]<<M)&k},b=new AF(25e3),C=new po(288),_=new po(32),S=0,$=0,j=a.i||0,N=0,A=a.w||0,R=0;j+2<i;++j){var Y=x(j),z=j&32767,V=w[Y];if(v[z]=V,w[Y]=z,A<=j){var H=i-j;if((S>7e3||N>24576)&&(H>423||!l)){u=rK(e,c,0,b,C,_,$,N,R,j-R,u),N=S=$=0,R=j;for(var O=0;O<286;++O)C[O]=0;for(var O=0;O<30;++O)_[O]=0}var P=2,I=0,L=y,U=z-V&32767;if(H>2&&Y==x(j-U))for(var D=Math.min(f,H)-1,E=Math.min(32767,j),ee=Math.min(258,H);U<=E&&--L&&z!=V;){if(e[j+P]==e[j+P-U]){for(var J=0;J<ee&&e[j+J]==e[j+J-U];++J);if(J>P){if(P=J,I=U,J>D)break;for(var ne=Math.min(U,J-2),oe=0,O=0;O<ne;++O){var te=j-U+O&32767,ce=v[te],ge=te-ce&32767;ge>oe&&(oe=ge,V=te)}}}z=V,V=v[z],U+=z-V&32767}if(I){b[N++]=268435456|eq[P]<<18|nK[I];var ae=eq[P]&31,se=nK[I]&31;$+=EF[ae]+$F[se],++C[257+ae],++_[se],A=j+P,++S}else b[N++]=e[j],++C[e[j]]}}for(j=Math.max(j,A);j<i;++j)b[N++]=e[j],++C[e[j]];u=rK(e,c,l,b,C,_,$,N,R,j-R,u),l||(a.r=u&7|c[u/8|0]<<3,u-=7,a.h=w,a.p=v,a.i=j,a.w=A)}else{for(var j=a.w||0;j<i+l;j+=65535){var re=j+65535;re>=i&&(c[u/8|0]=l,re=i),u=xre(c,u+1,e.subarray(j,re))}a.i=i}return vre(s,0,o+gre(u)+r)},Ant=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}(),Ent=function(){var e=-1;return{p:function(t){for(var n=e,o=0;o<t.length;++o)n=Ant[n&255^t[o]]^n>>>8;e=n},d:function(){return~e}}},Mre=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}}},bre=function(e,t,n,o,r){if(!r&&(r={l:1},t.dictionary)){var a=t.dictionary.subarray(-32768),i=new bn(a.length+e.length);i.set(a),i.set(e,a.length),e=i,r.w=a.length}return Int(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)},_re=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},Qt=function(e,t,n){for(;n;++t)e[t]=n,n>>>=8},$nt=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=Mre();r.p(t.dictionary),Qt(e,2,r.d())}};function jnt(e,t){return bre(e,t||{},0,0)}function Aot(e,t){t||(t={});var n=Mre();n.p(e);var o=bre(e,t,t.dictionary?6:2,4);return $nt(o,t),Qt(o,o.length-4,n.d()),o}var Cre=function(e,t,n,o){for(var r in e){var a=e[r],i=t+r,s=o;Array.isArray(a)&&(s=_re(o,a[1]),a=a[0]),a instanceof bn?n[i]=[a,s]:(n[i+="/"]=[new bn(0),s],Cre(a,i,n,o))}},aK=typeof TextEncoder<"u"&&new TextEncoder,Pnt=typeof TextDecoder<"u"&&new TextDecoder,znt=0;try{Pnt.decode(wre,{stream:!0}),znt=1}catch{}function oq(e,t){var n;if(aK)return aK.encode(e);for(var o=e.length,r=new bn(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 bn(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 vre(r,0,a)}var rq=function(e){var t=0;if(e)for(var n in e){var o=e[n].length;o>65535&&SR(9),t+=o+4}return t},iK=function(e,t,n,o,r,a,i,s){var c=o.length,l=n.extra,u=s&&s.length,h=rq(l);Qt(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)&&SR(10),Qt(e,t,y<<25|f.getMonth()+1<<21|f.getDate()<<16|f.getHours()<<11|f.getMinutes()<<5|f.getSeconds()>>1),t+=4,a!=-1&&(Qt(e,t,n.crc),Qt(e,t+4,a<0?-a-2:a),Qt(e,t+8,n.size)),Qt(e,t+12,c),Qt(e,t+14,h),t+=16,i!=null&&(Qt(e,t,u),Qt(e,t+6,n.attrs),Qt(e,t+10,i),t+=14),e.set(o,t),t+=c,h)for(var k in l){var v=l[k],w=v.length;Qt(e,t,+k),Qt(e,t+2,w),e.set(v,t+4),t+=4+w}return u&&(e.set(s,t),t+=u),t},Rnt=function(e,t,n,o,r){Qt(e,t,101010256),Qt(e,t+8,n),Qt(e,t+10,n),Qt(e,t+12,o),Qt(e,t+16,r)};function Tnt(e,t){t||(t={});var n={},o=[];Cre(e,"",n,t);var r=0,a=0;for(var i in n){var s=n[i],c=s[0],l=s[1],u=l.level==0?0:8,h=oq(i),f=h.length,y=l.comment,k=y&&oq(y),v=k&&k.length,w=rq(l.extra);f>65535&&SR(11);var g=u?jnt(c,l):c,M=g.length,x=Ent();x.p(c),o.push(_re(l,{size:c.length,crc:x.d(),c:g,f:h,m:k,u:f!=i.length||k&&y.length!=v,o:r,compression:u})),r+=30+f+w+M,a+=76+2*(f+w)+(v||0)+M}for(var b=new bn(a+22),C=r,_=a-r,S=0;S<o.length;++S){var h=o[S];iK(b,h.o,h,h.f,h.u,h.c.length);var $=30+h.f.length+rq(h.extra);b.set(h.c,h.o+$),iK(b,r,h,h.f,h.u,h.c.length,h.o,h.m),r+=16+$+(h.m?h.m.length:0)}return Rnt(b,r,o.length,_,C),b}const Dnt="https://seeflow.dev/api";async function Hnt(e,t,n,o,r,a){const i=await SX(e,t);if(!i.flow)throw new Error("Flow has no data");const s=i.flow,c=new Set,l=[];for(const v of s.nodes)v.type==="image"&&v.data.path&&!c.has(v.data.path)&&(c.add(v.data.path),l.push(v.data.path));const h={[r==="link"?"flow.private.json":"flow.json"]:oq(JSON.stringify(s))};if(a){const v=a.split(",")[1];v&&(h["preview.png"]=Uint8Array.from(atob(v),w=>w.charCodeAt(0)))}for(const v of l){const w=await fetch(`/api/projects/${encodeURIComponent(e)}/files/${v}`);w.ok&&(h[`files/${v}`]=new Uint8Array(await w.arrayBuffer()))}const f=Tnt(h),y=await fetch(`${Dnt}/flows?email=${encodeURIComponent(n)}&name=${encodeURIComponent(o)}`,{method:"POST",headers:{"content-type":"application/zip"},body:f.buffer});if(!y.ok)throw new Error(`Export failed with status ${y.status}`);const k=await y.json();if(typeof k.url!="string")throw new Error("Invalid response from cloud API: missing url");return{shareUrl:k.url}}function qnt(e,t){return m.useCallback((n,o,r,a)=>Hnt(e,t,n,o,r,a),[e,t])}const sK="seeflow.export.email",cK="seeflow.export.name",lK="seeflow.export.visibility";function Ont({open:e,onOpenChange:t,project:n,flow:o,flowName:r,onCapturePreview:a}){const[i,s]=m.useState(""),[c,l]=m.useState(""),[u,h]=m.useState("public"),[f,y]=m.useState({kind:"idle"}),[k,v]=m.useState(!1),w=qnt(n,o);m.useEffect(()=>{e&&(s(localStorage.getItem(sK)??""),l(r??localStorage.getItem(cK)??""),h(localStorage.getItem(lK)??"public"),y({kind:"idle"}),v(!1))},[e,r]);const g=m.useCallback(async()=>{y({kind:"loading"});try{const C=await(a==null?void 0:a()),{shareUrl:_}=await w(i.trim(),c.trim(),u,C);localStorage.setItem(sK,i.trim()),localStorage.setItem(cK,c.trim()),localStorage.setItem(lK,u),y({kind:"done",shareUrl:_})}catch(C){y({kind:"error",message:C instanceof Error?C.message:String(C)})}},[w,i,c,u,a]),M=m.useCallback(async()=>{if(f.kind==="done")try{await navigator.clipboard.writeText(f.shareUrl),v(!0),setTimeout(()=>v(!1),2e3)}catch(C){console.error("Failed to copy to clipboard:",C)}},[f]),x=f.kind==="loading",b=i.trim().length>0&&c.trim().length>0;return p.jsx(wa,{open:e,onOpenChange:t,children:p.jsxs(Ri,{className:"sm:max-w-md","data-testid":"export-dialog",onOpenAutoFocus:C=>{C.preventDefault();const _=document.querySelector('[data-testid="export-email-input"]');_==null||_.focus()},children:[p.jsxs(Ti,{children:[p.jsx(Di,{children:"Export to seeflow.dev"}),p.jsx(Hi,{children:"Upload this diagram to the cloud and get a shareable link."})]}),f.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:i,onChange:C=>s(C.target.value),disabled:x,"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:c,onChange:C=>l(C.target.value),disabled:x,"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:u,onChange:C=>h(C.target.value),disabled:x,"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"})]})]}),f.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:f.message}):null]}),p.jsx(Ma,{children:f.kind==="error"?p.jsxs(p.Fragment,{children:[p.jsx(dt,{type:"button",variant:"ghost",onClick:()=>t(!1),"data-testid":"export-cancel",children:"Cancel"}),p.jsx(dt,{type:"button",onClick:()=>y({kind:"idle"}),"data-testid":"export-retry",children:"Try again"})]}):p.jsxs(p.Fragment,{children:[p.jsx(dt,{type:"button",variant:"ghost",onClick:()=>t(!1),disabled:x,"data-testid":"export-cancel",children:"Cancel"}),p.jsx(dt,{type:"button",onClick:g,disabled:x||!b,"data-testid":"export-submit",children:x?p.jsxs(p.Fragment,{children:[p.jsx(Htt,{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:f.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(dt,{type:"button",variant:"outline",size:"icon",onClick:M,"aria-label":"Copy link","data-testid":"export-copy",children:k?p.jsx(are,{className:"h-4 w-4","aria-hidden":"true"}):p.jsx(sre,{className:"h-4 w-4","aria-hidden":"true"})}),p.jsx(dt,{type:"button",variant:"outline",size:"icon",onClick:()=>window.open(f.shareUrl,"_blank"),"aria-label":"View in new tab","data-testid":"export-view",children:p.jsx(Dtt,{className:"h-4 w-4","aria-hidden":"true"})})]})]}),p.jsx(Ma,{children:p.jsx(dt,{type:"button",onClick:()=>t(!1),"data-testid":"export-done",children:"Done"})})]})]})})}function Fnt(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}const Vnt=/^[a-z0-9][a-z0-9-]*$/,Bnt={"--tw-enter-translate-x":"-50%","--tw-enter-translate-y":"-50%","--tw-exit-translate-x":"-50%","--tw-exit-translate-y":"-50%","--tw-enter-scale":"1","--tw-exit-scale":"1"};function Unt({open:e,onOpenChange:t,onCreate:n,onCreated:o}){const[r,a]=m.useState(""),[i,s]=m.useState(""),[c,l]=m.useState(!1),[u,h]=m.useState(null),[f,y]=m.useState(!1);m.useEffect(()=>{e&&(a(""),s(""),l(!1),h(null),y(!1))},[e]);const k=C=>{a(C),c||s(Fnt(C))},v=C=>{s(C),c||l(!0)},w=i.trim(),g=r.trim(),M=w.length>0&&Vnt.test(w),x=M&&g.length>0&&!f,b=async C=>{if(C.preventDefault(),!x){!M&&w.length>0&&h("Flow id must match /^[a-z0-9][a-z0-9-]*$/");return}y(!0),h(null);try{const S=await n({id:w,name:g});o==null||o(S),t(!1)}catch(_){h(_ instanceof Error?_.message:String(_)),y(!1)}};return p.jsx(wa,{open:e,onOpenChange:t,children:p.jsxs(Ri,{className:"sm:max-w-md",style:Bnt,"data-testid":"flow-create-dialog",onOpenAutoFocus:C=>{C.preventDefault();const _=document.querySelector('[data-testid="flow-create-name-input"]');_==null||_.focus()},children:[p.jsxs(Ti,{children:[p.jsx(Di,{children:"Create new flow"}),p.jsx(Hi,{children:"A new flow folder is scaffolded under flows/<id>/ in your project."})]}),p.jsxs("form",{onSubmit:b,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:"Display name"}),p.jsx("input",{type:"text",required:!0,autoComplete:"off",spellCheck:!1,value:r,onChange:C=>k(C.target.value),"data-testid":"flow-create-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.jsx("span",{className:"font-medium",children:"Flow id"}),p.jsx("input",{type:"text",required:!0,autoComplete:"off",spellCheck:!1,placeholder:"my-retry-flow",value:i,onChange:C=>v(C.target.value),"data-testid":"flow-create-id-input",className:"rounded-md border bg-background px-3 py-2 font-mono text-sm outline-hidden ring-offset-background focus:border-ring focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2"}),p.jsx("span",{className:"text-xs text-muted-foreground",children:"Auto-filled from the display name. Lowercase letters, digits, and dashes; must start with a letter or digit."})]}),u?p.jsx("div",{role:"alert","data-testid":"flow-create-error",className:"rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-sm text-destructive",children:u}):null,p.jsxs(Ma,{children:[p.jsx(dt,{type:"button",variant:"ghost",onClick:()=>t(!1),disabled:f,children:"Cancel"}),p.jsx(dt,{type:"submit",disabled:!x,"data-testid":"flow-create-submit",children:f?"Creating…":"Create flow"})]})]})]})})}function Wnt({open:e,onOpenChange:t,flow:n,flows:o,onDelete:r,onDeleted:a}){var M;const i=m.useMemo(()=>o.filter(x=>x.flowSlug!==(n==null?void 0:n.flowSlug)),[o,n==null?void 0:n.flowSlug]),s=((M=i[0])==null?void 0:M.flowSlug)??"",[c,l]=m.useState(s),[u,h]=m.useState(null),[f,y]=m.useState(!1);if(m.useEffect(()=>{e&&(l(s),h(null),y(!1))},[e,s]),!n)return p.jsx(wa,{open:!1,onOpenChange:t});const k=n.isDefault,v=c.length>0,w=(!k||v)&&!f,g=async x=>{if(x.preventDefault(),!!w){y(!0),h(null);try{const b=k?{newDefault:c}:void 0;await r(n.flowSlug,b),a==null||a(n.flowSlug,b==null?void 0:b.newDefault),t(!1)}catch(b){h(b instanceof Error?b.message:String(b)),y(!1)}}};return p.jsx(wa,{open:e,onOpenChange:t,children:p.jsxs(Ri,{className:"sm:max-w-md","data-testid":"flow-delete-dialog",children:[p.jsxs(Ti,{children:[p.jsx(Di,{children:"Delete flow"}),p.jsxs(Hi,{children:["This removes flows/",n.flowSlug,"/ from disk and updates seeflow.json. The action cannot be undone."]})]}),p.jsxs("form",{onSubmit:g,className:"flex flex-col gap-4",children:[p.jsxs("p",{className:"text-sm",children:["Delete ",p.jsx("span",{className:"font-medium",children:n.name})," ",p.jsxs("span",{className:"font-mono text-muted-foreground",children:["(",n.flowSlug,")"]}),"?"]}),k?p.jsxs("label",{className:"flex flex-col gap-1.5 text-sm",children:[p.jsx("span",{className:"font-medium",children:"New default flow"}),p.jsx("select",{value:c,onChange:x=>l(x.target.value),"data-testid":"flow-delete-new-default-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",children:i.map(x=>p.jsxs("option",{value:x.flowSlug,children:[x.name," (",x.flowSlug,")"]},x.flowSlug))}),p.jsxs("span",{className:"text-xs text-muted-foreground",children:[n.name," is the project default — pick a replacement before deleting."]})]}):null,u?p.jsx("div",{role:"alert","data-testid":"flow-delete-error",className:"rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-sm text-destructive",children:u}):null,p.jsxs(Ma,{children:[p.jsx(dt,{type:"button",variant:"ghost",onClick:()=>t(!1),disabled:f,children:"Cancel"}),p.jsx(dt,{type:"submit",variant:"destructive",disabled:!w,"data-testid":"flow-delete-submit",children:f?"Deleting…":"Delete"})]})]})]})})}function Gnt({open:e,onOpenChange:t,flow:n,onRename:o,onRenamed:r}){const[a,i]=m.useState(""),[s,c]=m.useState(null),[l,u]=m.useState(!1);if(m.useEffect(()=>{e&&n&&(i(n.name),c(null),u(!1))},[e,n]),!n)return p.jsx(wa,{open:!1,onOpenChange:t});const h=a.trim(),f=h!==n.name,y=h.length>0&&f&&!l,k=async v=>{if(v.preventDefault(),!!y){u(!0),c(null);try{const w={name:h},g=await o(n.flowSlug,w);r==null||r(g,n.flowSlug),t(!1)}catch(w){c(w instanceof Error?w.message:String(w)),u(!1)}}};return p.jsx(wa,{open:e,onOpenChange:t,children:p.jsxs(Ri,{className:"sm:max-w-md","data-testid":"flow-rename-dialog",onOpenAutoFocus:v=>{v.preventDefault();const w=document.querySelector('[data-testid="flow-rename-name-input"]');w==null||w.focus(),w==null||w.select()},children:[p.jsxs(Ti,{children:[p.jsx(Di,{children:"Rename flow"}),p.jsx(Hi,{children:"Update the display name. The flow id is fixed once created."})]}),p.jsxs("form",{onSubmit:k,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:"Flow id"}),p.jsx("input",{type:"text",readOnly:!0,disabled:!0,autoComplete:"off",spellCheck:!1,value:n.flowSlug,"data-testid":"flow-rename-id-input",className:"cursor-not-allowed rounded-md border bg-muted px-3 py-2 font-mono text-sm text-muted-foreground"})]}),p.jsxs("label",{className:"flex flex-col gap-1.5 text-sm",children:[p.jsx("span",{className:"font-medium",children:"Display name"}),p.jsx("input",{type:"text",required:!0,autoComplete:"off",spellCheck:!1,value:a,onChange:v=>i(v.target.value),"data-testid":"flow-rename-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"})]}),s?p.jsx("div",{role:"alert","data-testid":"flow-rename-error",className:"rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-sm text-destructive",children:s}):null,p.jsxs(Ma,{children:[p.jsx(dt,{type:"button",variant:"ghost",onClick:()=>t(!1),disabled:l,children:"Cancel"}),p.jsx(dt,{type:"submit",disabled:!y,"data-testid":"flow-rename-submit",children:l?"Saving…":"Save"})]})]})]})})}function Knt({project:e,activeFlow:t,flows:n,onSelect:o,onCreate:r,onRename:a,onDelete:i}){const[s,c]=m.useState(!1),l=n.find(u=>u.flowSlug===t);return p.jsxs(Rd,{open:s,onOpenChange:c,children:[p.jsx(D0,{asChild:!0,children:p.jsxs(dt,{type:"button",variant:"outline",size:"sm","aria-label":`Switch flow for ${e}`,"aria-expanded":s,className:"gap-2","data-testid":"flow-switcher-trigger",children:[p.jsx("span",{className:"max-w-[180px] truncate text-sm",children:(l==null?void 0:l.name)??t}),p.jsx(ire,{className:"h-3.5 w-3.5 opacity-60"})]})}),p.jsx(zi,{align:"start",sideOffset:6,className:"w-[260px] p-0","data-testid":"flow-switcher-popover",children:p.jsx(GO,{children:p.jsxs(KO,{children:[p.jsx(ZO,{children:"No flows."}),n.length>0?p.jsx(Uh,{heading:"Flows",children:n.map(u=>{const h=u.flowSlug===t;return p.jsxs(Wh,{value:`${u.name} ${u.flowSlug}`,"aria-current":h?"true":void 0,"data-testid":`flow-switcher-row-${u.flowSlug}`,"data-active":h?"true":void 0,onSelect:()=>{c(!1),o==null||o(u.flowSlug)},className:ie("group flex items-center justify-between gap-2",h&&"bg-accent text-accent-foreground"),children:[p.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[u.icon?p.jsx("span",{"aria-hidden":"true",className:"text-xs opacity-70",children:u.icon}):null,p.jsx("span",{className:"truncate font-medium",children:u.name}),u.isDefault?p.jsx("span",{className:"shrink-0 rounded bg-muted px-1.5 py-0.5 text-[10px] uppercase tracking-wide text-muted-foreground",children:"default"}):null]}),p.jsxs("div",{className:"flex shrink-0 items-center gap-0.5 opacity-0 transition-opacity group-hover:opacity-100 focus-within:opacity-100",children:[p.jsx("button",{type:"button","aria-label":`Rename ${u.name}`,"data-testid":`flow-switcher-rename-${u.flowSlug}`,className:"rounded p-0.5 hover:text-foreground focus-visible:outline-hidden focus-visible:ring-1 focus-visible:ring-ring",onClick:f=>{f.stopPropagation(),c(!1),a==null||a(u.flowSlug)},children:p.jsx(qtt,{className:"h-3.5 w-3.5"})}),p.jsx("button",{type:"button","aria-label":`Delete ${u.name}`,"data-testid":`flow-switcher-delete-${u.flowSlug}`,className:"rounded p-0.5 hover:text-destructive focus-visible:outline-hidden focus-visible:ring-1 focus-visible:ring-ring",onClick:f=>{f.stopPropagation(),c(!1),i==null||i(u.flowSlug)},children:p.jsx(lre,{className:"h-3.5 w-3.5"})})]})]},u.flowSlug)})}):null,n.length>0?p.jsx(XO,{}):null,p.jsx(Uh,{children:p.jsxs(Wh,{value:"+ new flow","data-testid":"flow-switcher-create",onSelect:()=>{c(!1),r==null||r()},className:"flex items-center gap-2 text-sm",children:[p.jsx(cre,{className:"h-4 w-4 opacity-70"}),p.jsx("span",{className:"font-medium",children:"New flow"})]})})]})})})]})}const Znt=(e,t)=>{if(e.has(t))return e;const n=new Set(e);return n.add(t),n},Xnt=(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},Ynt=(e,t)=>{if(!e.has(t))return e;const n=new Set(e);return n.delete(t),n},Qnt=(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},Jnt=(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},dK=()=>{const[e,t]=m.useState(()=>new Set),n=m.useCallback(c=>{t(l=>Znt(l,c))},[]),o=m.useCallback(c=>{t(l=>Xnt(l,c))},[]),r=m.useCallback(c=>{t(l=>Ynt(l,c))},[]),a=m.useCallback(c=>{t(l=>Qnt(l,c))},[]),i=m.useCallback(c=>{t(l=>Jnt(l,c))},[]),s=m.useCallback(()=>t(new Set),[]);return{ids:e,mark:n,markMany:o,unmark:r,unmarkMany:a,pruneAgainst:i,reset:s}},eot=(e,t)=>e===t?!0:e==null||t==null||typeof e!=typeof t||typeof e!="object"?!1:JSON.stringify(e)===JSON.stringify(t),tot=(e,t,n)=>({...e,[t]:{...e[t],...n}}),not=(e,t)=>{if(!(t in e))return e;const n={...e};return delete n[t],n},oot=(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 u=!1;for(const h of Object.keys(s))eot(s[h],c[h])?r=!0:(l[h]=s[h],u=!0);u?a[i]=l:(r=!0,delete a[i])}return r?a:e},uK=()=>{const[e,t]=m.useState({}),n=m.useCallback((i,s)=>{t(c=>tot(c,i,s))},[]),o=m.useCallback(i=>{t(s=>not(s,i))},[]),r=m.useCallback(i=>{t(s=>oot(s,i))},[]),a=m.useCallback(()=>t({}),[]);return{overrides:e,setOverride:n,dropOverride:o,pruneAgainst:r,reset:a}},rot=500,aot=500,iot={stack:[],cursor:0},sot=(e,t,n)=>{const o=Date.now(),r=rot,a=aot,{stack:i,cursor:s}=e;if(t.coalesceKey&&s>0){const u=i[s-1];if(u&&u.coalesceKey===t.coalesceKey&&o-u.capturedAt<=a){const h=i.slice(0,s);return h[s-1]={...u,do:t.do,capturedAt:o},{stack:h,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}},cot=e=>e.cursor===0?{state:e,entry:void 0}:{state:{...e,cursor:e.cursor-1},entry:e.stack[e.cursor-1]},lot=e=>e.cursor===e.stack.length?{state:e,entry:void 0}:{state:{...e,cursor:e.cursor+1},entry:e.stack[e.cursor]},dot=()=>({stack:[],cursor:0}),uot=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}},hot=(e,t)=>t.state,fot=()=>{const[e,t]=m.useReducer(hot,iot),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(sot(n.current,k))},[a]),s=m.useCallback(()=>{r.current=Date.now();const y=o.current.then(()=>{const k=cot(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=lot(n.current);if(k.entry)return a(k.state),{entry:k.entry}});return o.current=y.then(()=>{},()=>{}),y},[a]),l=m.useCallback(()=>{a(dot())},[a]),u=m.useCallback(()=>{a(uot(n.current))},[a]),h=m.useCallback(()=>{r.current=Date.now()},[]),f=m.useCallback(()=>r.current,[]);return{push:i,undo:s,redo:c,clear:l,dropTop:u,canUndo:e.cursor>0,canRedo:e.cursor<e.stack.length,markMutation:h,lastMutationAt:f}};function pot({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,u=n?n.y-c:a.y,h=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+u}}}),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:h,newConnectors:f,idMap:i}}const yot=e=>({type:"image",position:e.position,data:{path:"",alt:e.originalFilename,width:e.dims.width,height:e.dims.height,_uploading:!0}}),mot=e=>({type:"image",data:Sre(e)}),kot=e=>({type:"image",position:e.position,data:{path:"",alt:e.originalFilename,width:e.dims.width,height:e.dims.height,_uploadError:e.message}}),Sre=e=>({...VTe(e.path,e.dims,e.lastUsed),alt:e.originalFilename}),got=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,yot({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,kot({position:i,dims:s,originalFilename:a,message:k})),y}t.setOverride(n,mot({path:l,dims:s,originalFilename:a,lastUsed:c}));const u=Sre({path:l,dims:s,originalFilename:a,lastUsed:c}),h={id:n,type:"image",position:i,data:u},{id:f}=await t.createNode(o,h);t.forgetRetry(n),t.pushUndo&&t.pushUndo({do:async()=>{await t.createNode(o,{...h,id:f})},undo:async()=>{await t.deleteNode(o,f)}})},vot="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",xot=248;function oa(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<xot&&(t+=vot[r%62])}}return t}const wot=new Set(["INPUT","TEXTAREA","SELECT"]),Oo=e=>e?wot.has(e.tagName)?!0:e instanceof HTMLElement&&e.isContentEditable:!1,Mot=(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 bot({project:e,flow:t,slug:n,demos:o,detail:r,loading:a,runs:i,nodeEvents:s,statusByNode:c,onPlayNode:l,onRestartDemo:u,refreshFlows:h}){var Da,Ha;const f=o.find(T=>T.slug===n),{flows:y,createFlow:k,renameFlow:v,deleteFlow:w}=ure(e),[g,M]=m.useState([]),[x,b]=m.useState([]),[C,_]=m.useState(null),S=m.useRef(g),$=m.useRef(x);m.useEffect(()=>{S.current=g},[g]),m.useEffect(()=>{$.current=x},[x]);const j=m.useRef(null),N=m.useRef(null),A=m.useRef(null),R=uK(),Y=uK(),z=dK(),V=dK(),[H,O]=m.useState(null),[P,I]=m.useState(null),[L,U]=m.useState({kind:"select"}),D=m.useRef({kind:"select"});m.useEffect(()=>{D.current=L},[L]);const[E,ee]=m.useState(!1),J=m.useRef(new Set),ne=`${e}/${t}`,oe=!J.current.has(ne);m.useEffect(()=>{J.current.add(ne)},[ne]);const te=m.useRef(null),ce=m.useCallback(T=>{te.current=T},[]),ge=fot(),{push:ae,dropTop:se,markMutation:re,clear:Pe,lastMutationAt:Be}=ge,{reset:Ve}=R,{reset:ht}=Y,{reset:Gt}=z,{reset:Et}=V;m.useEffect(()=>{M([]),b([]),_(null),Ve(),ht(),Gt(),Et(),O(null),I(null),Nn.current=null,Do(!1),oo.current.clear(),ge.clear()},[r==null?void 0:r.id]);const hn=m.useCallback((T,F)=>{M(T),b(F)},[]),fe=(Da=r==null?void 0:r.flow)==null?void 0:Da.nodes,Se=(Ha=r==null?void 0:r.flow)==null?void 0:Ha.connectors,{pruneAgainst:fn}=R,{pruneAgainst:pn}=Y,{pruneAgainst:sn}=z,{pruneAgainst:W}=V;m.useEffect(()=>{fe&&(fn(fe),sn(fe)),Date.now()-Be()>2e3&&Pe()},[fe,fn,sn,Be,Pe]),m.useEffect(()=>{Se&&(pn(Se),W(Se)),Date.now()-Be()>2e3&&Pe()},[Se,pn,W,Be,Pe]),m.useEffect(()=>{if(!(!fe||!H)&&fe.length===H.length){for(let T=0;T<fe.length;T++){const F=fe[T],Z=H[T];if(!F||F.id!==Z)return}O(null)}},[fe,H]);const G=(r==null?void 0:r.id)??null,K=m.useMemo(()=>BTe({baseUrl:"",project:e,flow:t}),[e,t]),[qe,Ze]=m.useState(!1),[Kt,tn]=m.useState(!1),[nn,Hn]=m.useState(null),[Cn,Tt]=m.useState(null),{setOverride:Ne,dropOverride:ze}=R,Qe=m.useRef(R.overrides);m.useEffect(()=>{Qe.current=R.overrides},[R.overrides]);const ct=m.useCallback((T,F)=>{var B;if(!G||!K)return;const Z=(B=fe==null?void 0:fe.find(q=>q.id===T))==null?void 0:B.position;Ne(T,{position:F}),I(null),re(),Z&&ae({do:async()=>{await K.updateNodePosition(T,F)},undo:async()=>{await K.updateNodePosition(T,Z)},coalesceKey:`node:${T}:position`}),K.updateNodePosition(T,F).catch(q=>{ze(T),Z&&se(),I(q instanceof Error?q.message:String(q)),console.error("updateNodePosition failed",q)})},[G,K,fe,Ne,ze,ae,se,re]),ir=m.useCallback(T=>{if(!G||!K||T.length===0)return;const F=Qe.current,Z=T.map(B=>{var $e;const q=fe==null?void 0:fe.find(Me=>Me.id===B.id);if(!q)return null;const de=(($e=F[B.id])==null?void 0:$e.position)??q.position;return{id:B.id,prev:de,next:B.position}}).filter(B=>B!==null);if(Z.length!==0){for(const B of Z)Ne(B.id,{position:B.next});I(null),re(),ae({do:async()=>{await Promise.allSettled(Z.map(B=>K.updateNodePosition(B.id,B.next)))},undo:async()=>{await Promise.allSettled(Z.map(B=>K.updateNodePosition(B.id,B.prev)))}}),Promise.all(Z.map(async B=>{try{return await K.updateNodePosition(B.id,B.next),null}catch(q){return ze(B.id),q instanceof Error?q.message:String(q)}})).then(B=>{const q=B.find(de=>de!==null);q&&I(q)})}},[G,K,fe,Ne,ze,ae,re]),qd=m.useCallback((T,F)=>{Ne(T,{position:{x:F.x,y:F.y},data:{width:F.width,height:F.height}})},[Ne]),Od=m.useCallback((T,F)=>{if(!G||!K)return;const Z=fe==null?void 0:fe.find(de=>de.id===T),B=Z?{width:Z.data.width,height:Z.data.height,position:{x:Z.position.x,y:Z.position.y}}:void 0,q={width:F.width,height:F.height,position:{x:F.x,y:F.y}};Ne(T,{position:q.position,data:{width:q.width,height:q.height}}),I(null),re(),B&&ae({do:async()=>{await K.updateNode(T,q)},undo:async()=>{await K.updateNode(T,B)},coalesceKey:`node:${T}:resize`}),K.updateNode(T,q).catch(de=>{ze(T),B&&se(),I(de instanceof Error?de.message:String(de)),console.error("updateNode resize failed",de)})},[G,K,fe,Ne,ze,ae,se,re]),Oi=m.useCallback(T=>{if(!G||!K)return;const F=fe==null?void 0:fe.find(q=>q.id===T);if(!F)return;const Z={autoSize:F.data.autoSize,width:F.data.width,height:F.data.height},B={autoSize:!0};Ne(T,{data:{autoSize:!0,width:void 0,height:void 0}}),I(null),re(),ae({do:async()=>{await K.updateNode(T,B)},undo:async()=>{await K.updateNode(T,Z)},coalesceKey:`node:${T}:fit-to-content`}),K.updateNode(T,B).catch(q=>{ze(T),se(),I(q instanceof Error?q.message:String(q)),console.error("updateNode (fit-to-content) failed",q)})},[G,K,fe,Ne,ze,ae,se,re]),Fd=m.useCallback(T=>{if(!G||!K||T.length===0)return;const F=[];for(const B of T){const q=fe==null?void 0:fe.find(st=>st.id===B.id);if(!q)continue;const de=q.data,$e={position:{x:q.position.x,y:q.position.y}};de.width!==void 0&&($e.width=de.width),de.height!==void 0&&($e.height=de.height);const Me={position:B.position};B.width!==void 0&&(Me.width=B.width),B.height!==void 0&&(Me.height=B.height),F.push({id:B.id,prev:$e,next:Me})}if(F.length===0)return;for(const B of F){const q={};B.next.width!==void 0&&(q.width=B.next.width),B.next.height!==void 0&&(q.height=B.next.height),Ne(B.id,{position:B.next.position,...Object.keys(q).length>0?{data:q}:{}})}I(null),re();const Z=F.map(B=>B.id).sort();ae({do:async()=>{await Promise.allSettled(F.map(B=>K.updateNode(B.id,B.next)))},undo:async()=>{await Promise.allSettled(F.map(B=>K.updateNode(B.id,B.prev)))},coalesceKey:`multi:resize:${Z.join(",")}`}),Promise.all(F.map(async B=>{try{return await K.updateNode(B.id,B.next),null}catch(q){return ze(B.id),q instanceof Error?q.message:String(q)}})).then(B=>{const q=B.find(de=>de!==null);q&&I(q)})},[G,K,fe,Ne,ze,ae,re]),{setOverride:$t,dropOverride:Ft}=Y,Vd=m.useCallback((T,F)=>{Ne(T,{data:F})},[Ne]),Bd=m.useCallback((T,F)=>{for(const Z of T)Ne(Z,{data:F})},[Ne]),Ud=m.useCallback((T,F)=>{$t(T,F)},[$t]),Wd=m.useCallback((T,F)=>{if(!G||!K)return;mU(Qa,F);const Z=fe==null?void 0:fe.find(q=>q.id===T);let B=null;if(Z){B={};const q=Z.data;for(const de of Object.keys(F))B[de]=q[de]}if(Ne(T,{data:F}),I(null),re(),B){const q=B;ae({do:async()=>{await K.updateNode(T,F)},undo:async()=>{await K.updateNode(T,q)},coalesceKey:`node:${T}:style`})}K.updateNode(T,F).catch(q=>{ze(T),B&&se(),I(q instanceof Error?q.message:String(q)),console.error("updateNode style failed",q)})},[G,K,fe,Ne,ze,ae,se,re]),Gd=m.useCallback((T,F)=>{if(!G||!K||T.length===0)return;mU(Qa,F);const Z=T.map(B=>{const q=fe==null?void 0:fe.find(Me=>Me.id===B);if(!q)return null;const de=q.data,$e={};for(const Me of Object.keys(F))$e[Me]=de[Me];return{id:B,prev:$e}}).filter(B=>B!==null);if(Z.length!==0){for(const B of Z)Ne(B.id,{data:F});I(null),re(),ae({do:async()=>{await Promise.allSettled(Z.map(B=>K.updateNode(B.id,F)))},undo:async()=>{await Promise.allSettled(Z.map(B=>K.updateNode(B.id,B.prev)))}}),Promise.all(Z.map(async B=>{try{return await K.updateNode(B.id,F),null}catch(q){return ze(B.id),q instanceof Error?q.message:String(q)}})).then(B=>{const q=B.find(de=>de!==null);q&&I(q)})}},[G,K,fe,Ne,ze,ae,re]),Kd=m.useCallback((T,F)=>{if(!G||!K)return;DTe(Qa,F);const Z=Se==null?void 0:Se.find(q=>q.id===T);let B=null;if(Z){B={};const q=Z;for(const de of Object.keys(F))B[de]=q[de]}if($t(T,F),I(null),re(),B){const q=B;ae({do:async()=>{await K.updateConnector(T,F)},undo:async()=>{await K.updateConnector(T,q)},coalesceKey:`connector:${T}:style`})}K.updateConnector(T,F).catch(q=>{Ft(T),B&&se(),I(q instanceof Error?q.message:String(q)),console.error("updateConnector failed",q)})},[G,K,Se,$t,Ft,ae,se,re]),{mark:La,markMany:Na,unmark:sr,unmarkMany:Fi}=z,{mark:Ia,markMany:De,unmark:vt,unmarkMany:no}=V,Vi=m.useCallback(T=>{if(!G||!K)return;const F=fe==null?void 0:fe.find(Me=>Me.id===T);if(!F)return;const Z=(Se??[]).filter(Me=>Me.source===T||Me.target===T),B=Z.map(Me=>Me.id),q=new Set(B);I(null),La(T),B.length>0&&De(B),M(Me=>Me.filter(st=>st!==T)),b(Me=>Me.filter(st=>!q.has(st))),re();const de=F,$e=Z;ae({do:async()=>{La(T),B.length>0&&De(B),await K.deleteNode(T)},undo:async()=>{sr(T),B.length>0&&no(B),await K.createNode({id:de.id,type:de.type,position:de.position,data:de.data});for(const Me of $e)await K.createConnector({...Me,id:Me.id})}}),K.deleteNode(T).catch(Me=>{sr(T),B.length>0&&no(B),se(),I(Me instanceof Error?Me.message:String(Me)),console.error("deleteNode failed",Me)})},[G,K,fe,Se,La,De,sr,no,ae,se,re]),cr=m.useCallback((T,F)=>{if(!G||!K||!fe)return;const Z=H??fe.map(de=>de.id),B=Mot(Z,T,F);if(!B)return;const q=Z.indexOf(T);O(B),I(null),re(),ae({do:async()=>{await K.reorderNode(T,F)},undo:async()=>{await K.reorderNode(T,{op:"toIndex",index:q})}}),K.reorderNode(T,F).catch(de=>{O(null),se(),I(de instanceof Error?de.message:String(de)),console.error("reorderNode failed",de)})},[G,K,fe,H,ae,se,re]);m.useCallback(T=>{if(!G||!K)return;const F=Se==null?void 0:Se.find(B=>B.id===T);if(!F)return;I(null),Ia(T),b(B=>B.filter(q=>q!==T)),re();const Z=F;ae({do:async()=>{Ia(T),await K.deleteConnector(T)},undo:async()=>{vt(T),await K.createConnector({...Z,id:Z.id})}}),K.deleteConnector(T).catch(B=>{vt(T),se(),I(B instanceof Error?B.message:String(B)),console.error("deleteConnector failed",B)})},[G,K,Se,Ia,vt,ae,se,re]);const Sn=m.useCallback((T,F)=>{if(!G||!K||T.length===0&&F.length===0)return;const Z=new Set(T),B=T.map(Ie=>fe==null?void 0:fe.find(Je=>Je.id===Ie)).filter(Ie=>!!Ie),q=(Se??[]).filter(Ie=>Z.has(Ie.source)||Z.has(Ie.target)),de=new Set(q.map(Ie=>Ie.id)),$e=F.map(Ie=>Se==null?void 0:Se.find(Je=>Je.id===Ie)).filter(Ie=>!!Ie).filter(Ie=>!de.has(Ie.id));if(B.length===0&&q.length===0&&$e.length===0)return;I(null);const Me=B.map(Ie=>Ie.id),st=[...q.map(Ie=>Ie.id),...$e.map(Ie=>Ie.id)];Me.length>0&&Na(Me),st.length>0&&De(st);const mn=B;M(Ie=>Ie.filter(Je=>!Z.has(Je)));const eu=new Set($e.map(Ie=>Ie.id));b(Ie=>Ie.filter(Je=>!eu.has(Je)&&!de.has(Je))),re(),ae({do:async()=>{Me.length>0&&Na(Me),st.length>0&&De(st);for(const Ie of mn)await K.deleteNode(Ie.id).catch(()=>{});await Promise.allSettled($e.map(Ie=>K.deleteConnector(Ie.id)))},undo:async()=>{Me.length>0&&Fi(Me),st.length>0&&no(st);for(let Ie=mn.length-1;Ie>=0;Ie--){const Je=mn[Ie];Je&&await K.createNode({id:Je.id,type:Je.type,position:Je.position,data:Je.data})}for(const Ie of[...q,...$e])await K.createConnector({...Ie,id:Ie.id})}});const ro=new Map;for(const Ie of B)ro.set(Ie.id,q.filter(Je=>Je.source===Ie.id||Je.target===Ie.id).map(Je=>Je.id));(async()=>{const Ie=[];for(const kn of mn)try{await K.deleteNode(kn.id)}catch(Bn){sr(kn.id);const Yr=ro.get(kn.id)??[];Yr.length>0&&no(Yr),Ie.push(Bn instanceof Error?Bn.message:String(Bn))}const Je=await Promise.all($e.map(async kn=>{try{return await K.deleteConnector(kn.id),null}catch(Bn){return vt(kn.id),Bn instanceof Error?Bn.message:String(Bn)}}));for(const kn of Je)kn!==null&&Ie.push(kn);Ie.length>0&&Ie[0]!==void 0&&I(Ie[0])})()},[G,K,fe,Se,Na,De,sr,Fi,vt,no,ae,re]);m.useEffect(()=>{j.current=Sn},[Sn]),m.useEffect(()=>{const T=F=>{if(F.key!=="Delete"&&F.key!=="Backspace"||Oo(document.activeElement)||document.querySelector('[data-testid="inline-edit-input"]'))return;const Z=S.current,B=$.current;Z.length===0&&B.length===0||(F.preventDefault(),Sn(Z,B))};return window.addEventListener("keydown",T),()=>window.removeEventListener("keydown",T)},[Sn]);const{undo:Ro,redo:Ln,canUndo:qn,canRedo:Zt}=ge;m.useEffect(()=>{const T=async F=>{if((F.metaKey||F.ctrlKey)&&F.key.toLowerCase()==="z"&&!Oo(document.activeElement)){if(F.preventDefault(),F.shiftKey){if(!Zt)return;try{const Z=await Ln();Z!=null&&Z.entry&&await Z.entry.do()}catch(Z){I(Z instanceof Error?Z.message:String(Z)),console.error("redo failed",Z)}return}if(qn)try{const Z=await Ro();Z!=null&&Z.entry&&await Z.entry.undo()}catch(Z){I(Z instanceof Error?Z.message:String(Z)),console.error("undo failed",Z)}}};return window.addEventListener("keydown",T),()=>window.removeEventListener("keydown",T)},[Ro,Ln,qn,Zt]);const Xt=m.useCallback((T,F)=>{if(!G||!K)return;const Z=fe==null?void 0:fe.find(de=>de.id===T),q=(Z&&"name"in Z.data?Z.data.name:void 0)??"";Ne(T,{data:{name:F}}),I(null),re(),Z&&ae({do:async()=>{await K.updateNode(T,{name:F})},undo:async()=>{await K.updateNode(T,{name:q})},coalesceKey:`node:${T}:name`}),K.updateNode(T,{name:F}).catch(de=>{Z&&se(),I(de instanceof Error?de.message:String(de)),console.error("updateNode name failed",de)})},[G,K,fe,Ne,ae,se,re]),lr=m.useCallback((T,F)=>{if(!G||!K)return;const Z=fe==null?void 0:fe.find(q=>q.id===T);if(!Z)return;const B=Z.data.description??"";Ne(T,{data:{description:F}}),I(null),re(),ae({do:async()=>{await K.updateNode(T,{description:F})},undo:async()=>{await K.updateNode(T,{description:B})},coalesceKey:`node:${T}:description`}),K.updateNode(T,{description:F}).catch(q=>{se(),I(q instanceof Error?q.message:String(q)),console.error("updateNode description failed",q)})},[G,K,fe,Ne,ae,se,re]),Bi=m.useCallback((T,F)=>{if(!G||!K)return;const Z=fe==null?void 0:fe.find(q=>q.id===T);if(!Z)return;const B=Z.data.detail??"";Ne(T,{data:{detail:F}}),I(null),re(),ae({do:async()=>{await K.updateNode(T,{detail:F})},undo:async()=>{await K.updateNode(T,{detail:B})},coalesceKey:`node:${T}:detail`}),K.updateNode(T,{detail:F}).catch(q=>{se(),I(q instanceof Error?q.message:String(q)),console.error("updateNode detail failed",q)})},[G,K,fe,Ne,ae,se,re]),Zd=m.useCallback((T,F)=>{if(!G||!K)return;const Z=fe==null?void 0:fe.find(q=>q.id===T);if(!Z)return;const B="icon"in Z.data?Z.data.icon??null:null;Ne(T,{data:{icon:F??void 0}}),I(null),re(),ae({do:async()=>{await K.updateNode(T,{icon:F})},undo:async()=>{await K.updateNode(T,{icon:B})},coalesceKey:`node:${T}:icon`}),K.updateNode(T,{icon:F}).catch(q=>{se(),I(q instanceof Error?q.message:String(q)),console.error("updateNode icon failed",q)})},[G,K,fe,Ne,ae,se,re]),Xd=m.useCallback((T,F,Z)=>{if(!G||!K)return;I(null);const B=`node-${oa()}`,q=gU(T,Z,M2(Qa).node),de={id:B,type:T,position:F,data:q};Ne(B,{id:B,type:T,position:F,data:q}),re(),K.createNode(de).then(({id:Me})=>{ae({do:async()=>{await K.createNode({...de,id:Me})},undo:async()=>{await K.deleteNode(Me)}})}).catch(Me=>{ze(B),I(Me instanceof Error?Me.message:String(Me)),console.error("createNode failed",Me)})},[G,K,Ne,ze,ae,re]),Ui=m.useCallback((T,F)=>{if(!G||!K)return;I(null);const Z=`node-${oa()}`,B={icon:T,width:p0.width,height:p0.height},q={id:Z,type:"icon",position:F,data:B};Ne(Z,{id:Z,type:"icon",position:F,data:B}),M([Z]),re(),K.createNode(q).then(({id:$e})=>{ae({do:async()=>{await K.createNode({...q,id:$e})},undo:async()=>{await K.deleteNode($e)}})}).catch($e=>{ze(Z),I($e instanceof Error?$e.message:String($e)),console.error("createNode (icon) failed",$e)})},[G,K,Ne,ze,ae,re]),jt=m.useCallback(T=>{if(!G||!K)return;I(null);const F=`node-${oa()}`,Z={id:F,type:"html",position:T.position,data:{}},B={id:F,type:"html",position:T.position,data:{}};Ne(F,B),M([F]),re(),K.createNode(Z).then(({id:q})=>{ae({do:async()=>{await K.createNode({...Z,id:q})},undo:async()=>{await K.deleteNode(q)}})}).catch(q=>{ze(F),I(q instanceof Error?q.message:String(q)),console.error("createNode (type:'html') failed",q)})},[G,K,Ne,ze,ae,re]),oo=m.useRef(new Map),Wr=m.useCallback((T,F)=>{oo.current.set(T,F)},[]),Aa=m.useCallback(T=>{oo.current.delete(T)},[]),bo=m.useCallback(T=>{!G||!K||(I(null),re(),got({...T,flowId:G,lastUsed:M2(Qa).node},{upload:(F,Z,B,q)=>K.uploadImage(Z,B,q),createNode:async(F,Z)=>{const{id:B}=await K.createNode(Z);return{id:B}},deleteNode:async(F,Z)=>(await K.deleteNode(Z),{ok:!0}),setOverride:Ne,pushUndo:ae,rememberRetry:Wr,forgetRetry:Aa}).catch(F=>{console.error("image-upload-flow failed",F)}))},[G,K,Ne,ae,re,Wr,Aa]),Gr=m.useCallback(T=>{if(!G||!K)return;const F=`node-${oa()}`;bo({nodeId:F,...T})},[G,K,bo]),Yd=m.useCallback(T=>{const F=oo.current.get(T);F&&bo({nodeId:T,...F})},[bo]),[_o,Ea]=m.useState({open:!1,mode:"insert"}),To=m.useCallback((T,F)=>{Ea({open:!0,mode:T,nodeId:F})},[]),yn=m.useCallback(()=>{Ea(T=>({...T,open:!1}))},[]),Kr=m.useCallback(()=>{To("insert")},[To]),dr=m.useCallback(T=>To("replace",T),[To]),V0=m.useCallback(T=>{if(NTe(T),_o.mode==="replace"&&_o.nodeId){if(G&&K){const F=_o.nodeId,Z=fe==null?void 0:fe.find(q=>q.id===F),B=(Z==null?void 0:Z.type)==="icon"?Z.data.icon:void 0;if(Ne(F,{data:{icon:T}}),I(null),re(),B!==void 0){const q=B;ae({do:async()=>{await K.updateNode(F,{icon:T})},undo:async()=>{await K.updateNode(F,{icon:q})},coalesceKey:`node:${F}:icon`})}K.updateNode(F,{icon:T}).catch(q=>{ze(F),B!==void 0&&se(),I(q instanceof Error?q.message:String(q)),console.error("updateNode (icon replace) failed",q)})}}else{const F=te.current;if(F&&G){const Z=STe(F,{width:window.innerWidth,height:window.innerHeight});Ui(T,Z)}}yn()},[_o.mode,_o.nodeId,G,K,fe,Ne,ze,ae,se,re,Ui,yn]),Zr=m.useCallback((T,F)=>{if(!G||!K)return;const Z=Se==null?void 0:Se.find(q=>q.id===T),B=Z==null?void 0:Z.label;$t(T,{label:F}),I(null),re(),Z&&ae({do:async()=>{await K.updateConnector(T,{label:F})},undo:async()=>{await K.updateConnector(T,{label:B})},coalesceKey:`connector:${T}:label`}),K.updateConnector(T,{label:F}).catch(q=>{Z&&se(),I(q instanceof Error?q.message:String(q)),console.error("updateConnector label failed",q)})},[G,K,Se,$t,ae,se,re]),Qd=m.useCallback((T,F,Z)=>{if(!G||!K)return;const B=`conn-${oa()}`,q=Z==null?void 0:Z.targetPin,de=M2(Qa).connector,$e={id:B,source:T,target:F,sourceHandleAutoPicked:!0,targetHandleAutoPicked:!0,...q?{targetPin:q}:{},...de},Me={id:B,source:T,target:F,sourceHandleAutoPicked:!0,targetHandleAutoPicked:!0,...q?{targetPin:q}:{},...de};$t(B,$e),I(null),re(),K.createConnector(Me).then(({id:st})=>{ae({do:async()=>{await K.createConnector({...Me,id:st})},undo:async()=>{await K.deleteConnector(st)}})}).catch(st=>{Ft(B),I(st instanceof Error?st.message:String(st)),console.error("createConnector failed",st)})},[G,K,$t,Ft,ae,re]),$a=m.useCallback(({sourceNodeId:T,position:F,shape:Z})=>{if(!G||!K)return;I(null);const B=`node-${oa()}`,q=`conn-${oa()}`,de=az[Z],$e=M2(Qa),Me=gU(Z,de,$e.node),st={id:B,type:Z,position:F,data:Me},mn={id:q,source:T,target:B,sourceHandleAutoPicked:!0,targetHandleAutoPicked:!0,...$e.connector};Ne(B,{id:B,type:Z,position:F,data:Me}),$t(q,mn),_(B),re(),(async()=>{try{await K.createNode(st),await K.createConnector(mn),ae({do:async()=>{await K.createNode(st),await K.createConnector(mn)},undo:async()=>{Ft(q),ze(B),await K.deleteConnector(q).catch(()=>{}),await K.deleteNode(B).catch(()=>{})}})}catch(ro){ze(B),Ft(q),I(ro instanceof Error?ro.message:String(ro)),console.error("createAndConnectFromPane failed",ro)}})()},[G,K,Ne,ze,$t,Ft,ae,re]),Nn=m.useRef(null),[Xr,Do]=m.useState(!1),On=m.useCallback(T=>{if(!fe)return;const F=new Set(T),Z=fe.filter(q=>F.has(q.id));if(Z.length===0)return;const B=(Se??[]).filter(q=>F.has(q.source)&&F.has(q.target));Nn.current=JSON.parse(JSON.stringify({nodes:Z,connectors:B})),Do(!0)},[fe,Se]),Fn=m.useCallback(T=>{if(!G||!K)return;const F=Nn.current;if(!F||F.nodes.length===0)return;const{newNodes:Z,newConnectors:B}=pot({nodes:F.nodes,connectors:F.connectors,flowPos:T,nodeIdGen:()=>`node-${oa()}`,connectorIdGen:()=>`conn-${oa()}`});for(const q of Z)Ne(q.id,q);for(const q of B)$t(q.id,q);M(Z.map(q=>q.id)),b(B.map(q=>q.id)),I(null),re(),(async()=>{try{for(const q of Z)await K.createNode({id:q.id,type:q.type,position:q.position,data:q.data});for(const q of B)await K.createConnector(q);ae({do:async()=>{for(const q of Z)await K.createNode({id:q.id,type:q.type,position:q.position,data:q.data});for(const q of B)await K.createConnector(q)},undo:async()=>{await Promise.allSettled(B.map(q=>K.deleteConnector(q.id))),await Promise.allSettled(Z.map(q=>K.deleteNode(q.id)))}})}catch(q){for(const de of Z)ze(de.id);for(const de of B)Ft(de.id);I(q instanceof Error?q.message:String(q)),console.error("paste failed",q)}})()},[G,K,Ne,ze,$t,Ft,re,ae]);m.useEffect(()=>{const T=F=>{const Z=RTe({event:F,isEditableActive:Oo(document.activeElement),hasNodes:!!fe&&fe.length>0,hasConnectors:!!Se&&Se.length>0,selectedIds:S.current,hasClipboard:!!Nn.current});if(Z.type!=="noop"&&!(Z.type==="copy"||Z.type==="paste")){if(F.preventDefault(),Z.type==="selectAll"){M((fe??[]).map(B=>B.id)),b((Se??[]).map(B=>B.id));return}On([...Z.ids]),Fn(null)}};return window.addEventListener("keydown",T),()=>window.removeEventListener("keydown",T)},[fe,Se,On,Fn]),m.useEffect(()=>{const T=F=>{const Z=jTe(F);if(!Z||Oo(document.activeElement))return;const B=S.current;if(B.length===0)return;const q=R.overrides,de=(fe??[]).map(Me=>{var mn;const st=((mn=q[Me.id])==null?void 0:mn.position)??Me.position;return{id:Me.id,position:st}}),$e=zTe(Z,B,de);if($e.length!==0)if(F.preventDefault(),$e.length===1){const Me=$e[0];Me&&ct(Me.id,Me.position)}else ir($e)};return window.addEventListener("keydown",T),()=>window.removeEventListener("keydown",T)},[fe,R.overrides,ct,ir]),m.useEffect(()=>{const T=F=>{const Z=PTe(F);if(!Z||Oo(document.activeElement))return;F.preventDefault();const B=te.current;B&&(Z==="fit"?B.fitView({padding:.2,duration:200}):Z==="in"?B.zoomIn({duration:150}):B.zoomOut({duration:150}))};return window.addEventListener("keydown",T),()=>window.removeEventListener("keydown",T)},[]);const Ho=m.useCallback(async T=>{if(!G||!K||!fe||!K.computeLayout)return;const F=R.overrides,Z=te.current,B=T==="selection"?new Set(S.current):null,q=B?fe.filter(je=>B.has(je.id)):fe;if(q.length<2)return;const de=new Set(q.map(je=>je.id)),$e=(Se??[]).filter(je=>de.has(je.source)&&de.has(je.target)),Me=new Map,st=q.map(je=>{var nu;const tt=((nu=F[je.id])==null?void 0:nu.position)??je.position;Me.set(je.id,tt);const pt=Z==null?void 0:Z.getInternalNode(je.id),on=pt==null?void 0:pt.measured,Co=je.data,qa=(on==null?void 0:on.width)??Co.width??200,tu=(on==null?void 0:on.height)??Co.height??120;return{id:je.id,type:je.type,width:qa,height:tu}}),mn=$e.map(je=>({id:je.id,source:je.source,target:je.target})),eu=await K.computeLayout(st,mn),ro=new Map;for(const[je,tt]of Object.entries(eu.nodes))ro.set(je,tt.position);let Ie=Number.POSITIVE_INFINITY,Je=Number.POSITIVE_INFINITY,kn=Number.POSITIVE_INFINITY,Bn=Number.POSITIVE_INFINITY;for(const je of st){const tt=Me.get(je.id);if(!tt)continue;tt.x<Ie&&(Ie=tt.x),tt.y<Je&&(Je=tt.y);const pt=ro.get(je.id);pt&&(pt.x<kn&&(kn=pt.x),pt.y<Bn&&(Bn=pt.y))}const Yr=Number.isFinite(Ie)&&Number.isFinite(kn)?Ie-kn:0,K0=Number.isFinite(Je)&&Number.isFinite(Bn)?Je-Bn:0,hr=[];for(const je of st){const tt=Me.get(je.id),pt=ro.get(je.id);if(!tt||!pt)continue;const on={x:pt.x+Yr,y:pt.y+K0},Co=on.x-tt.x,qa=on.y-tt.y;Math.abs(Co)<1&&Math.abs(qa)<1||hr.push({id:je.id,prev:tt,next:on})}if(hr.length!==0){I(null);for(const je of hr)Ne(je.id,{position:je.next});re(),ae({do:async()=>{await Promise.allSettled(hr.map(je=>K.updateNodePosition(je.id,je.next)))},undo:async()=>{await Promise.allSettled(hr.map(je=>K.updateNodePosition(je.id,je.prev)))}}),Promise.all(hr.map(async je=>{try{return await K.updateNodePosition(je.id,je.next),null}catch(tt){return ze(je.id),tt instanceof Error?tt.message:String(tt)}})).then(je=>{const tt=je.filter(on=>on!==null),pt=tt[0];pt&&(I(tt.length===1?pt:`${tt.length} node updates failed (first: ${pt})`),console.error("Tidy: some updateNodePosition calls failed",tt))})}},[G,K,fe,Se,R.overrides,Ne,ze,ae,re]);m.useEffect(()=>{const T=F=>{if(!(F.metaKey||F.ctrlKey)||!F.shiftKey||F.altKey||F.key.toLowerCase()!=="l"||Oo(document.activeElement))return;F.preventDefault();const Z=S.current.length>0?"selection":"all";Ho(Z)};return window.addEventListener("keydown",T),()=>window.removeEventListener("keydown",T)},[Ho]);const ja=m.useCallback(()=>{const T=S.current.length>0?"selection":"all";Ho(T)},[Ho]);m.useEffect(()=>{const T=F=>{if(Oo(document.activeElement)||document.querySelector('[data-testid="inline-edit-input"]'))return;const Z=TTe(F);if(Z===null)return;const B=D.current;if(Z==="select"){B.kind!=="select"&&U({kind:"select"});return}if(Z==="hand"){U(B.kind==="hand"?{kind:"select"}:{kind:"hand"});return}if(B.kind==="draw"&&B.shape===Z){U({kind:"select"});return}U({kind:"draw",shape:Z})};return window.addEventListener("keydown",T),()=>window.removeEventListener("keydown",T)},[]),m.useEffect(()=>{const T=F=>{if(F.key!=="Escape"||Oo(document.activeElement)||document.querySelector('[data-testid="inline-edit-input"]'))return;if(D.current.kind!=="select"){U({kind:"select"});return}S.current.length>0&&M([]),$.current.length>0&&b([])};return window.addEventListener("keydown",T),()=>window.removeEventListener("keydown",T)},[]),m.useEffect(()=>{const T=F=>{if(F.key.toLowerCase()!=="f"||F.metaKey||F.ctrlKey||F.shiftKey||F.altKey||Oo(document.activeElement)||document.querySelector('[data-testid="inline-edit-input"]'))return;const Z=S.current;if(Z.length===0)return;const B=te.current;B&&B.fitView({nodes:Z.map(q=>({id:q})),padding:.2,duration:200})};return window.addEventListener("keydown",T),()=>window.removeEventListener("keydown",T)},[]),m.useEffect(()=>{const T=F=>{if(F.key!=="1"||F.metaKey||F.ctrlKey||F.shiftKey||F.altKey||Oo(document.activeElement)||document.querySelector('[data-testid="inline-edit-input"]'))return;const Z=te.current;if(!Z)return;const{x:B,y:q}=Z.getViewport();Z.setViewport({x:B,y:q,zoom:1},{duration:150})};return window.addEventListener("keydown",T),()=>window.removeEventListener("keydown",T)},[]);const Pa=m.useCallback(T=>{var F,Z,B;switch(T){case"tool.select":U({kind:"select"});return;case"tool.hand":U({kind:"hand"});return;case"tool.rectangle":U({kind:"draw",shape:"rectangle"});return;case"tool.ellipse":U({kind:"draw",shape:"ellipse"});return;case"tool.text":U({kind:"draw",shape:"text"});return;case"tool.sticky":U({kind:"draw",shape:"sticky"});return;case"tool.database":U({kind:"draw",shape:"database"});return;case"edit.undo":{if(!qn)return;(async()=>{try{const q=await Ro();q!=null&&q.entry&&await q.entry.undo()}catch(q){I(q instanceof Error?q.message:String(q)),console.error("undo failed",q)}})();return}case"edit.redo":{if(!Zt)return;(async()=>{try{const q=await Ln();q!=null&&q.entry&&await q.entry.do()}catch(q){I(q instanceof Error?q.message:String(q)),console.error("redo failed",q)}})();return}case"edit.copy":{const q=S.current;if(q.length===0)return;On([...q]);return}case"edit.paste":Fn(null);return;case"edit.duplicate":{const q=S.current;if(q.length===0)return;On([...q]),Fn(null);return}case"edit.delete":{const q=S.current,de=$.current;if(q.length===0&&de.length===0)return;Sn([...q],[...de]);return}case"edit.selectAll":M((fe??[]).map(q=>q.id)),b((Se??[]).map(q=>q.id));return;case"view.fit":{const q=te.current;if(!q)return;q.fitView({padding:.2,duration:200});return}case"view.zoomIn":{const q=te.current;if(!q)return;q.zoomIn({duration:150});return}case"view.zoomOut":{const q=te.current;if(!q)return;q.zoomOut({duration:150});return}case"view.zoom100":{const q=te.current;if(!q)return;const{x:de,y:$e}=q.getViewport();q.setViewport({x:de,y:$e,zoom:1},{duration:150});return}case"view.zoomToSelection":{const q=S.current;if(q.length===0)return;const de=te.current;if(!de)return;de.fitView({nodes:q.map($e=>({id:$e})),padding:.2,duration:200});return}case"layout.tidy":{const q=S.current.length>0?"selection":"all";Ho(q);return}case"selection.deselect":S.current.length>0&&M([]),$.current.length>0&&b([]),D.current.kind!=="select"&&U({kind:"select"});return;case"help.commandPalette":ee(!0);return;case"export.pdf":{(F=A.current)==null||F.exportPdf();return}case"export.png":{(Z=A.current)==null||Z.exportPng();return}case"session.reset":{(B=N.current)==null||B.call(N);return}}},[qn,Zt,Ro,Ln,On,Fn,Sn,fe,Se,Ho]);m.useEffect(()=>{const T=F=>{(F.metaKey||F.ctrlKey)&&(F.shiftKey||F.altKey||F.key.toLowerCase()==="p"&&(F.preventDefault(),!Oo(document.activeElement)&&Pa("help.commandPalette")))};return window.addEventListener("keydown",T),()=>window.removeEventListener("keydown",T)},[Pa]),m.useEffect(()=>{N.current=u??null},[u]);const Wi=m.useCallback((T,F)=>{if(!G||!K)return;const Z=Se==null?void 0:Se.find(de=>de.id===T),B=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,q={...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($t(T,q),I(null),re(),B){const de=B;ae({do:async()=>{await K.updateConnector(T,F)},undo:async()=>{await K.updateConnector(T,de)},coalesceKey:`connector:${T}:reconnect`})}K.updateConnector(T,F).catch(de=>{Ft(T),B&&se(),I(de instanceof Error?de.message:String(de)),console.error("updateConnector reconnect failed",de)})},[G,K,Se,$t,Ft,ae,se,re]),za=m.useCallback((T,F,Z)=>{if(!G||!K)return;const B=Se==null?void 0:Se.find($e=>$e.id===T),q=B?F==="source"?B.sourcePin:B.targetPin:void 0,de=F==="source"?"sourcePin":"targetPin";if($t(T,{[de]:Z}),I(null),re(),B){const $e={[de]:q??null};ae({do:async()=>{await K.updateConnector(T,{[de]:Z})},undo:async()=>{await K.updateConnector(T,$e)},coalesceKey:`connector:${T}:${de}`})}K.updateConnector(T,{[de]:Z}).catch($e=>{Ft(T),B&&se(),I($e instanceof Error?$e.message:String($e)),console.error("updateConnector pin failed",$e)})},[G,K,Se,$t,Ft,ae,se,re]),Jd=m.useCallback((T,F)=>{if(!G||!K)return;const Z=Se==null?void 0:Se.find(de=>de.id===T),B=Z?F==="source"?Z.sourcePin:Z.targetPin:void 0;if(!B)return;const q=F==="source"?"sourcePin":"targetPin";$t(T,{[q]:void 0}),I(null),re(),ae({do:async()=>{await K.updateConnector(T,{[q]:null})},undo:async()=>{await K.updateConnector(T,{[q]:B})}}),K.updateConnector(T,{[q]:null}).catch(de=>{Ft(T),se(),I(de instanceof Error?de.message:String(de)),console.error("updateConnector unpin failed",de)})},[G,K,Se,$t,Ft,ae,se,re]),It=r==null?void 0:r.flow,B0=R.overrides,U0=Y.overrides,In=z.ids,ur=V.ids,Pf=m.useMemo(()=>{if(!It||g.length===0)return[];const T=new Map(It.nodes.map(Z=>[Z.id,Z])),F=[];for(const Z of g){const B=T.get(Z);if(!B)continue;const q=B0[Z];if(!q){F.push(B);continue}const de=q.data?{...B.data,...q.data}:B.data;F.push({...B,...q,data:de})}return F},[It,g,B0]),Ra=m.useMemo(()=>{if(!It||x.length===0)return[];const T=new Map(It.connectors.map(Z=>[Z.id,Z])),F=[];for(const Z of x){const B=T.get(Z);if(!B)continue;const q=U0[Z];F.push(q?{...B,...q}:B)}return F},[It,x,U0]),W0=m.useMemo(()=>{if(!It)return null;if(!H)return It.nodes;const T=new Map(It.nodes.map(B=>[B.id,B])),F=[],Z=new Set;for(const B of H){const q=T.get(B);q&&(F.push(q),Z.add(B))}for(const B of It.nodes)Z.has(B.id)||F.push(B);return F},[It,H]),zf=m.useMemo(()=>{const T=W0??(It==null?void 0:It.nodes)??null;return T?In.size===0?T:T.filter(F=>!In.has(F.id)):null},[W0,It,In]),Vn=m.useMemo(()=>{const T=(It==null?void 0:It.connectors)??null;return T?ur.size===0&&In.size===0?T:T.filter(F=>!ur.has(F.id)&&!In.has(F.source)&&!In.has(F.target)):null},[It,ur,In]),Gi=(y==null?void 0:y.some(T=>T.flowSlug===t))??!1;if(!f&&!Gi&&!(y===null))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: ",n]}),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(!f||a&&!r)return p.jsx("div",{className:"flex h-full w-full items-center justify-center text-sm text-muted-foreground",children:"Loading demo…"});const Ki=g[0],G0=Ki?c[Ki]:void 0;return p.jsxs("div",{className:"relative h-full w-full",children:[r&&!r.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:r.error})]}):null,p.jsx(Unt,{open:Kt,onOpenChange:tn,onCreate:k,onCreated:async T=>{await h(),J.current.add(`${e}/${T.flowSlug}`),jr(ui(e,T.flowSlug))}}),p.jsx(Gnt,{open:nn!==null,onOpenChange:T=>{T||Hn(null)},flow:nn,onRename:v,onRenamed:async(T,F)=>{await h(),T.flowSlug!==F&&(J.current.add(`${e}/${T.flowSlug}`),jr(ui(e,T.flowSlug)))}}),p.jsx(Wnt,{open:Cn!==null,onOpenChange:T=>{T||Tt(null)},flow:Cn,flows:y??[],onDelete:w,onDeleted:async(T,F)=>{var B;if(await h(),T!==t)return;const Z=F??((B=y==null?void 0:y.find(q=>q.isDefault&&q.flowSlug!==T))==null?void 0:B.flowSlug);Z&&jr(ui(e,Z))}}),It&&K?p.jsx(Stt,{ref:A,mode:"edit",adapter:K,topLeftSlot:p.jsx(Knt,{project:e,activeFlow:t,flows:y??[],onSelect:T=>{T!==t&&jr(ui(e,T))},onCreate:()=>tn(!0),onRename:T=>{const F=y==null?void 0:y.find(Z=>Z.flowSlug===T);F&&Hn({flowSlug:F.flowSlug,name:F.name,icon:F.icon})},onDelete:T=>{const F=y==null?void 0:y.find(Z=>Z.flowSlug===T);F&&Tt({flowSlug:F.flowSlug,name:F.name,isDefault:F.isDefault})}}),projectId:e,flowSlug:t,enableEmbed:!1,onExportToCloud:G?()=>Ze(!0):void 0,onRestartDemo:u,nodes:zf??It.nodes,connectors:Vn??It.connectors,selectedNodeIds:g,selectedConnectorIds:x,onSelectionChange:hn,runtime:{runs:i,statuses:c,pendingOverrides:{nodes:B0,connectors:U0}},onPlayNode:l,onNodePositionChange:ct,onNodePositionsChange:ir,onNodeResize:qd,onNodeResizeEnd:Od,onHtmlNodeFitToContent:Oi,onComponentNodeFitToContent:Oi,onMultiResize:Fd,onNodeNameChange:Xt,onNodeDescriptionChange:lr,onConnectorLabelChange:Zr,onCreateShapeNode:Xd,onCreateImageFromFile:G?Gr:void 0,onRetryImageUpload:G?Yd:void 0,onCreateHtmlNode:G?jt:void 0,iconPickerOpen:_o.open,onOpenIconPicker:G?Kr:void 0,onCloseIconPicker:G?yn:void 0,onPickIcon:G?V0:void 0,onRequestIconReplace:G?dr:void 0,onCreateConnector:Qd,onReconnectConnector:Wi,onPinEndpoint:G?za:void 0,onUnpinEndpoint:G?Jd:void 0,onReorderNode:cr,onDeleteNode:Vi,onCopyNode:T=>On([T]),onPasteAt:Fn,onCopySelection:G?On:void 0,onPasteSelection:G?()=>Fn(null):void 0,hasClipboard:Xr,selectedNodes:Pf,selectedConnectors:Ra,onStyleNode:Wd,onStyleNodePreview:Vd,onStyleNodes:Gd,onStyleNodesPreview:Bd,onStyleConnector:Kd,onStyleConnectorPreview:Ud,onRfInit:ce,onTidy:fe?ja:void 0,onCreateAndConnectFromPane:$a,pendingEditNodeId:C,canvasMode:L,onCanvasModeChange:U,statusReport:G0,onNameChange:Xt,onDescriptionChange:lr,onDetailChange:Bi,onIconChange:Zd,autoFitView:oe},`${e}/${t}`):p.jsx("div",{className:"flex h-full w-full items-center justify-center text-sm text-muted-foreground",children:"No demo data yet."}),P?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}),p.jsx("button",{type:"button",className:"ml-3 underline underline-offset-2",onClick:()=>I(null),children:"Dismiss"})]}):null,p.jsx(Mnt,{open:E,onOpenChange:ee,runCommand:Pa,ctx:{hasSelection:g.length>0||x.length>0,canUndo:qn,canRedo:Zt,hasClipboard:Xr,canExportDemo:!!G,canResetSession:!!u}}),G?p.jsx(Ont,{open:qe,onOpenChange:Ze,project:e,flow:t,flowName:(r==null?void 0:r.name)??f.name,onCapturePreview:()=>{var T;return((T=A.current)==null?void 0:T.capturePreview())??Promise.resolve(void 0)}}):null]})}const hK="npx seeflow register --path .";function _ot(){const[e,t]=m.useState(!1),n=async()=>{try{await navigator.clipboard.writeText(hK),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(Ftt,{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:hK}),p.jsx(dt,{type:"button",variant:"ghost",size:"sm",onClick:n,"aria-label":"Copy register command",children:e?p.jsx(are,{className:"h-4 w-4"}):p.jsx(sre,{className:"h-4 w-4"})})]})]})})}function Cot({demos:e}){return e.length===0?p.jsx(_ot,{}):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:()=>jr(ore(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))})]})})}function Sot(){const e=$tt(),{demos:t,refresh:n}=nnt(),{projects:o,refresh:r,unregisterProject:a}=fnt(),i=jtt(e),s=(i==null?void 0:i.project)??null,c=(i==null?void 0:i.flow)??null,l=Ptt(e),u=(l==null?void 0:l.project)??null,{flows:h}=ure(u);pnt({onRegistryReload:()=>{n(),r()}});const f=i?`${i.project}/${i.flow}`:null,y=f?(t??[]).find(O=>O.slug===f):void 0,k=(y==null?void 0:y.id)??null;m.useEffect(()=>{f&&t!==null&&(y||n())},[f,t,y,n]);const{detail:v,loading:w,refresh:g,applyDetail:M}=tnt(s,c),{runs:x,apply:b}=cnt(k),{events:C,apply:_}=int(k),{statusByNode:S,apply:$,reset:j}=hnt(k),N=m.useCallback(()=>{j(),g(),n()},[g,n,j]),A=m.useCallback(O=>{if(!k||!y)return;const P={id:k,slug:y.slug,filePath:""},I=O.valid?{...P,name:O.flow.name??y.name,flow:O.flow,valid:!0,error:null}:{...P,name:y.name,flow:null,valid:!1,error:O.error};M(I)},[k,y,M]),R=m.useCallback(O=>{b(O),_(O),$(O)},[b,_,$]);ynt(k,{onHello:N,onFlowReload:A,onEvent:R});const Y=m.useCallback(async()=>{if(!(!s||!c))try{await Dse(s,c)}catch(O){console.error("Failed to restart demo:",O)}},[s,c]),z=m.useCallback(O=>{YG(O.id),n(),r()},[n,r]),V=m.useCallback(async O=>{await a(O),await n(),s===O&&jr("/")},[a,n,s]);m.useEffect(()=>{if(e!=="/"||t===null)return;const O=gnt(t,knt());O&&jr(ore(O.slug))},[e,t]),m.useEffect(()=>{y&&YG(y.id)},[y]),m.useEffect(()=>{s&&c&&Itt(s,c)},[s,c]),m.useEffect(()=>{if(!u||!h)return;const O=Att(h,nre(u));O&&jr(ui(u,O))},[u,h]);const H=m.useCallback(O=>{!s||!c||Hse(s,c,O).catch(P=>{b({type:"node:error",nodeId:O,message:P instanceof Error?P.message:String(P),ts:Date.now()})})},[s,c,b]);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(ch,{delayDuration:150,children:p.jsxs("div",{className:"flex h-full w-full flex-col bg-background text-foreground",children:[p.jsx(ent,{projects:o??[],currentProjectSlug:s??void 0,onProjectCreated:z,onUnregisterProject:V}),p.jsx("main",{className:"min-h-0 flex-1",children:s&&c&&f?p.jsx(bot,{project:s,flow:c,slug:f,demos:t,detail:v,loading:w,runs:x,nodeEvents:C,statusByNode:S,onPlayNode:H,onRestartDemo:k?Y:void 0,refreshFlows:n}):p.jsx(Cot,{demos:t})})]})})}const Lre=document.getElementById("root");if(!Lre)throw new Error("Root element #root not found");eD.createRoot(Lre).render(p.jsx(Lr.StrictMode,{children:p.jsx(Sot,{})}));export{sf as C,eYe as M,Lr as R,ff as _,Zn as a,jX as b,yG as c,uP as d,oO as e,eY as f,PWe as g,Qh as h,TWe as i,Lot as j,ah as k,Ir as l,p as m,oY as n,fJe as o,jEe as p,MWe as q,m as r,ho as s,DWe as t,dF as u,LWe as w,Aot as z};
|
|
8619
|
+
*/const Vtt=ar("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 Btt({projects:e,currentProjectSlug:t,onProjectCreated:n,onUnregisterProject:o}){const[r,a]=m.useState(!1),[i,s]=m.useState(!1),[c,l]=m.useState(null),[u,h]=m.useState(!1),[f,y]=m.useState(null);m.useEffect(()=>{const C=_=>{_.key==="k"&&(_.metaKey||_.ctrlKey)&&(_.preventDefault(),a(S=>!S))};return document.addEventListener("keydown",C),()=>document.removeEventListener("keydown",C)},[]);const k=e.find(C=>C.projectSlug===t),v=C=>{const S=nre(C.projectSlug)??C.defaultFlow;jr(ui(C.projectSlug,S))},w=C=>{n==null||n(C)},g=C=>{l(C),y(null)},M=()=>{u||(l(null),y(null))},x=async()=>{if(c){h(!0),y(null);try{await(o==null?void 0:o(c.projectSlug)),l(null)}catch(C){y(C instanceof Error?C.message:String(C))}finally{h(!1)}}},b=(c==null?void 0:c.flowCount)??0;return p.jsxs(p.Fragment,{children:[p.jsxs(Rd,{open:r,onOpenChange:a,children:[p.jsx(D0,{asChild:!0,children:p.jsxs(dt,{type:"button",variant:"outline",size:"sm","aria-label":"Switch project","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 project"}),p.jsx(Tee,{children:"⌘K"}),p.jsx(ire,{className:"h-3.5 w-3.5 opacity-60"})]})}),p.jsx(zi,{align:"end",sideOffset:6,className:"w-[320px] p-0","data-testid":"project-switcher-popover",children:p.jsxs(GO,{children:[p.jsx(Ree,{placeholder:"Search projects..."}),p.jsxs(KO,{children:[p.jsx(ZO,{children:"No projects."}),e.length>0?p.jsx(Uh,{heading:"Projects",children:e.map(C=>p.jsxs(Wh,{value:`${C.name} ${C.projectSlug}`,onSelect:()=>{a(!1),v(C)},"data-testid":`project-switcher-row-${C.projectSlug}`,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:C.name}),C.repoPath?p.jsx("span",{className:"w-full truncate text-xs text-muted-foreground",children:C.repoPath}):null]}),p.jsx("button",{type:"button","aria-label":`Unregister ${C.name}`,"data-testid":`project-switcher-unregister-${C.projectSlug}`,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:_=>{_.stopPropagation(),a(!1),g(C)},children:p.jsx(lre,{className:"h-3.5 w-3.5"})})]},C.projectSlug))}):null,e.length>0?p.jsx(XO,{}):null,p.jsx(Uh,{children:p.jsxs(Wh,{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(cre,{className:"h-4 w-4 opacity-70"}),p.jsx("span",{className:"font-medium",children:"Create new project"})]})})]})]})})]}),p.jsx(Ltt,{open:i,onOpenChange:s,onCreated:w}),p.jsx(wa,{open:c!==null,onOpenChange:C=>{C||M()},children:p.jsxs(Ri,{className:"sm:max-w-md","data-testid":"unregister-project-dialog",children:[p.jsxs(Ti,{children:[p.jsx(Di,{children:"Unregister project?"}),p.jsxs(Hi,{children:["This removes ",p.jsx("strong",{children:c==null?void 0:c.name})," from SeeFlow."," ",p.jsxs("strong",{children:["All ",b," ",b===1?"flow":"flows"]})," ","under this project will be unregistered.",c!=null&&c.repoPath?p.jsxs(p.Fragment,{children:[" ","Your files at ",p.jsx("code",{className:"text-xs",children:c.repoPath})," will not be deleted."]}):null]})]}),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(Ma,{children:[p.jsx(dt,{type:"button",variant:"ghost",onClick:M,disabled:u,children:"Cancel"}),p.jsx(dt,{type:"button",variant:"destructive",onClick:x,disabled:u,"data-testid":"unregister-project-confirm",children:u?"Unregistering…":"Unregister"})]})]})})]})}const dre="seeflow:theme",ZG="(prefers-color-scheme: dark)";function Utt(e){return e==="light"||e==="dark"||e==="system"}function Wtt(e){try{const t=e.getItem(dre);return Utt(t)?t:"system"}catch{return"system"}}function Gtt(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 Ktt(e,t){try{e.setItem(dre,t)}catch{}}function Ztt(e,t){return e==="system"?t?"dark":"light":e}function Xtt(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 Qtt(){const[e,t]=m.useState(()=>{if(typeof window>"u")return"system";const i=Gtt(window.location.search);return i||Wtt(window.localStorage)}),[n,o]=m.useState(()=>typeof window>"u"?!1:window.matchMedia(ZG).matches);m.useEffect(()=>{if(typeof window>"u")return;const i=window.matchMedia(ZG);return Ytt(i,o)},[]);const r=Ztt(e,n);m.useEffect(()=>{typeof document>"u"||Xtt(document.documentElement,r)},[r]);const a=m.useCallback(i=>{typeof window<"u"&&Ktt(window.localStorage,i),t(i)},[]);return{theme:e,setTheme:a,resolvedTheme:r}}const Jtt=[{value:"light",label:"Light"},{value:"dark",label:"Dark"},{value:"system",label:"System"}];function ent({projects:e,currentProjectSlug:t,onProjectCreated:n,onUnregisterProject:o}){const{theme:r,setTheme:a}=Qtt();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:shadow-[0_4px_12px_-6px_rgba(0,0,0,0.6)]",children:[p.jsxs("button",{type:"button",onClick:()=>jr("/"),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(Vtt,{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.83"]})]}),p.jsxs("div",{className:"flex items-center gap-3",children:[p.jsx(Btt,{projects:e,currentProjectSlug:t,onProjectCreated:n,onUnregisterProject:o}),p.jsxs(ane,{children:[p.jsx(ine,{asChild:!0,children:p.jsx(dt,{type:"button",variant:"outline",size:"icon","aria-label":"Settings","data-testid":"settings-trigger",children:p.jsx(Ott,{className:"h-4 w-4"})})}),p.jsxs(aF,{align:"end",sideOffset:6,className:"w-44","data-testid":"settings-menu",children:[p.jsx(sne,{children:"Theme"}),p.jsx(DUe,{value:r,onValueChange:i=>a(i),children:Jtt.map(i=>p.jsx(cne,{value:i.value,"data-testid":`theme-${i.value}`,children:i.label},i.value))})]})]})]})]})}const tnt=(e,t)=>{const n=e!==null&&t!==null,[o,r]=m.useState(null),[a,i]=m.useState(n),[s,c]=m.useState(null),l=m.useCallback(()=>{!e||!t||(i(!0),SX(e,t).then(h=>{r(h),c(null)}).catch(h=>{console.error("[useDemoData] failed",h),c(String(h))}).finally(()=>i(!1)))},[e,t]),u=m.useCallback(h=>{r(h),c(null)},[]);return m.useEffect(()=>{if(!e||!t){r(null),i(!1);return}l()},[e,t,l]),{detail:o,loading:a,error:s,refresh:l,applyDetail:u}},nnt=()=>{const[e,t]=m.useState(null),[n,o]=m.useState(null),r=m.useCallback(()=>jse().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}},ont=5,rnt={"node:running":"running","node:done":"done","node:error":"error"},ant=(e,t)=>{if(t.type==="reset")return{};const n=e[t.nodeId]??[],o=[t.entry,...n].slice(0,ont);return{...e,[t.nodeId]:o}},int=e=>{const[t,n]=m.useReducer(ant,{}),o=m.useRef(n);o.current=n,m.useEffect(()=>{o.current({type:"reset"})},[e]);const r=m.useCallback(i=>{const s=rnt[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,u=typeof i.ts=="number"?i.ts:Date.now();o.current({type:"append",nodeId:c,entry:{status:s,ts:u,runId:l}})},[]),a=m.useCallback(()=>{o.current({type:"reset"})},[]);return{events:t,apply:r,reset:a}},snt=(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()}}}},cnt=e=>{const[t,n]=m.useReducer(snt,{}),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}},lnt=new Set(["ok","warn","error","pending"]),dnt=(e,t)=>{if(t.type!=="node:status")return e;const n=typeof t.nodeId=="string"?t.nodeId:null;if(!n||typeof t.state!="string"||!lnt.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}}},unt=(e,t)=>{switch(t.type){case"reset":return{};case"event":return dnt(e,t.event)}},hnt=e=>{const[t,n]=m.useReducer(unt,{}),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}},ure=e=>{const t=e!==null,[n,o]=m.useState(null),[r,a]=m.useState(t),[i,s]=m.useState(null),c=m.useCallback(()=>{e&&(a(!0),CX(e).then(f=>{o(f),s(null)}).catch(f=>{console.error("[useProjectFlows] failed",f),o([]),s(String(f))}).finally(()=>a(!1)))},[e]);m.useEffect(()=>{if(!e){o(null),a(!1);return}c()},[e,c]);const l=m.useCallback(async f=>{if(!e)throw new Error("no-project");const y=await zse(e,f);return c(),y},[e,c]),u=m.useCallback(async(f,y)=>{if(!e)throw new Error("no-project");const k=await Rse(e,f,y);return c(),k},[e,c]),h=m.useCallback(async(f,y)=>{if(!e)throw new Error("no-project");const k=await LX(e,f,y);return c(),k},[e,c]);return{flows:n,loading:r,error:i,refresh:c,createFlow:l,renameFlow:u,deleteFlow:h}},fnt=()=>{const[e,t]=m.useState(null),[n,o]=m.useState(!0),[r,a]=m.useState(null),i=m.useCallback(()=>(o(!0),Pse().then(c=>{t(c),a(null)}).catch(c=>{console.error("[useProjects] failed",c),t([]),a(String(c))}).finally(()=>o(!1))),[]);m.useEffect(()=>{i()},[i]);const s=m.useCallback(async c=>{const u=[...await CX(c)].sort((h,f)=>h.isDefault===f.isDefault?0:h.isDefault?1:-1);for(const h of u)await LX(c,h.flowSlug);await i()},[i]);return{projects:e,loading:n,error:r,refresh:i,unregisterProject:s}},pnt=(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}},ynt=(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 u=`/api/events?flowId=${encodeURIComponent(e)}`,h=new EventSource(u);h.addEventListener("open",()=>o(!0)),h.addEventListener("error",()=>o(!1)),h.addEventListener("hello",()=>{var f;(f=s.current)==null||f.call(s)}),h.addEventListener("flow:reload",f=>{var v,w;const y=XG(f,"flow:reload");(v=l.current)==null||v.call(l,y);const k=mnt(y);k&&((w=c.current)==null||w.call(c,k))});for(const f of["node:running","node:done","node:error","node:status"])h.addEventListener(f,y=>{var k;(k=l.current)==null||k.call(l,XG(y,f))});return()=>{h.close()}},[e]),{connected:n}},XG=(e,t)=>{try{const n=JSON.parse(e.data);return{type:t,ts:Date.now(),...n}}catch{return{type:t,ts:Date.now()}}},mnt=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,hre="seeflow:last-project",knt=()=>{if(typeof window>"u")return null;try{return window.localStorage.getItem(hre)}catch{return null}},YG=e=>{if(!(typeof window>"u"))try{window.localStorage.setItem(hre,e)}catch{}},gnt=(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},QG=["File","Edit","View","Tools","Layout","Selection","Help"],fre="seeflow:command-palette:recent",pre=5,yre=new Map(kO.map(e=>[e.id,e])),vnt=e=>typeof e=="string"&&yre.has(e),JG=()=>{if(typeof window>"u")return[];try{const e=window.localStorage.getItem(fre);if(!e)return[];const t=JSON.parse(e);return Array.isArray(t)?t.filter(vnt).slice(0,pre):[]}catch{return[]}},xnt=e=>{if(!(typeof window>"u"))try{window.localStorage.setItem(fre,JSON.stringify(e))}catch{}},eK=(e,t)=>e.enabled?e.enabled(t):!0,wnt=(e,t)=>t.length===0?!0:`${e.label} ${e.description??""}`.toLowerCase().includes(t);function Mnt({open:e,onOpenChange:t,runCommand:n,ctx:o}){const[r,a]=m.useState(""),[i,s]=m.useState(0),[c,l]=m.useState(()=>JG()),u=m.useRef(null),h=m.useRef(null);m.useEffect(()=>{e&&(a(""),s(0),l(JG()))},[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 j=[];for(const A of c){const R=yre.get(A);R&&j.push({cmd:R,enabled:eK(R,o)})}return{groups:[{category:"Recent",rows:j}],flat:j}}const C=new Map;for(const j of kO){if(!wnt(j,b))continue;const N={cmd:j,enabled:eK(j,o)},A=C.get(j.category);A?A.push(N):C.set(j.category,[N])}const S=[...QG.filter(j=>C.has(j)),...Array.from(C.keys()).filter(j=>!QG.includes(j))].map(j=>({category:j,rows:C.get(j)??[]})),$=S.flatMap(j=>j.rows);return{groups:S,flat:$}},[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($=>$.enabled);S!==-1&&(C=S)}return C})},[y]);const k=m.useCallback(b=>{y.length!==0&&s(C=>{var S;let _=C;for(let $=0;$<y.length;$++)if(_=(_+b+y.length)%y.length,(S=y[_])!=null&&S.enabled)return _;return C})},[y]),v=m.useCallback(b=>{l(C=>{const _=[b,...C.filter(S=>S!==b)].slice(0,pre);return xnt(_),_})},[]),w=m.useCallback(b=>{const C=y[b];!C||!C.enabled||(v(C.cmd.id),n(C.cmd.id),t(!1))},[y,t,v,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=h.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 x=r.trim().length>0;return p.jsx(iR,{open:e,onOpenChange:t,children:p.jsx(sR,{children:p.jsxs(H0,{className:ie("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=u.current)==null||C.focus()},children:[p.jsx("div",{className:ie("border-b",y.length===0&&!x&&"border-b-0"),children:p.jsx("input",{ref:u,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:h,"data-testid":"command-palette-list","data-empty":y.length===0?"true":"false",className:ie("max-h-[50vh] overflow-y-auto",y.length>0?"py-1":"","seeflow-no-scrollbar"),children:y.length===0?x?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,$=S===i;return p.jsxs("button",{type:"button","data-testid":`command-palette-row-${_.cmd.id}`,"data-command-row-index":S,"data-highlighted":$?"true":"false","aria-disabled":_.enabled?void 0:!0,disabled:!_.enabled,onMouseEnter:()=>{_.enabled&&s(S)},onClick:()=>w(S),className:ie("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",$&&_.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 bn=Uint8Array,po=Uint16Array,AF=Int32Array,EF=new bn([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]),$F=new bn([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]),tK=new bn([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),mre=function(e,t){for(var n=new po(31),o=0;o<31;++o)n[o]=t+=1<<e[o-1];for(var r=new AF(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}},kre=mre(EF,2),bnt=kre.b,eq=kre.r;bnt[28]=258,eq[258]=28;var _nt=mre($F,0),nK=_nt.r,tq=new po(32768);for(var Ct=0;Ct<32768;++Ct){var Ya=(Ct&43690)>>1|(Ct&21845)<<1;Ya=(Ya&52428)>>2|(Ya&13107)<<2,Ya=(Ya&61680)>>4|(Ya&3855)<<4,tq[Ct]=((Ya&65280)>>8|(Ya&255)<<8)>>1}var ph=function(e,t,n){for(var o=e.length,r=0,a=new po(t);r<o;++r)e[r]&&++a[e[r]-1];var i=new po(t);for(r=1;r<t;++r)i[r]=i[r-1]+a[r-1]<<1;var s;if(n){s=new po(1<<t);var c=15-t;for(r=0;r<o;++r)if(e[r])for(var l=r<<4|e[r],u=t-e[r],h=i[e[r]-1]++<<u,f=h|(1<<u)-1;h<=f;++h)s[tq[h]>>c]=l}else for(s=new po(o),r=0;r<o;++r)e[r]&&(s[r]=tq[i[e[r]-1]++]>>15-e[r]);return s},$d=new bn(288);for(var Ct=0;Ct<144;++Ct)$d[Ct]=8;for(var Ct=144;Ct<256;++Ct)$d[Ct]=9;for(var Ct=256;Ct<280;++Ct)$d[Ct]=7;for(var Ct=280;Ct<288;++Ct)$d[Ct]=8;var mz=new bn(32);for(var Ct=0;Ct<32;++Ct)mz[Ct]=5;var Cnt=ph($d,9,0),Snt=ph(mz,5,0),gre=function(e){return(e+7)/8|0},vre=function(e,t,n){return(n==null||n>e.length)&&(n=e.length),new bn(e.subarray(t,n))},Lnt=["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"],SR=function(e,t,n){var o=new Error(t||Lnt[e]);if(o.code=e,Error.captureStackTrace&&Error.captureStackTrace(o,SR),!n)throw o;return o},na=function(e,t,n){n<<=t&7;var o=t/8|0;e[o]|=n,e[o+1]|=n>>8},p2=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},JT=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:wre,l:0};if(r==1){var i=new bn(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,u=1,h=2;for(n[0]={s:-1,f:s.f+c.f,l:s,r:c};u!=r-1;)s=n[n[l].f<n[h].f?l++:h++],c=n[l!=u&&n[l].f<n[h].f?l++:h++],n[u++]={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 po(f+1),k=nq(n[u-1],y,0);if(k>t){var o=0,v=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)v+=g-(1<<k-y[M]),y[M]=t;else break}for(v>>=w;v>0;){var x=a[o].s;y[x]<t?v-=1<<t-y[x]++-1:++o}for(;o>=0&&v;--o){var b=a[o].s;y[b]==t&&(--y[b],++v)}k=t}return{t:new bn(y),l:k}},nq=function(e,t,n){return e.s==-1?Math.max(nq(e.l,t,n+1),nq(e.r,t,n+1)):t[e.s]=n},oK=function(e){for(var t=e.length;t&&!e[--t];);for(var n=new po(++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}},y2=function(e,t){for(var n=0,o=0;o<t.length;++o)n+=e[o]*t[o];return n},xre=function(e,t,n){var o=n.length,r=gre(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},rK=function(e,t,n,o,r,a,i,s,c,l,u){na(t,u++,n),++r[256];for(var h=JT(r,15),f=h.t,y=h.l,k=JT(a,15),v=k.t,w=k.l,g=oK(f),M=g.c,x=g.n,b=oK(v),C=b.c,_=b.n,S=new po(19),$=0;$<M.length;++$)++S[M[$]&31];for(var $=0;$<C.length;++$)++S[C[$]&31];for(var j=JT(S,7),N=j.t,A=j.l,R=19;R>4&&!N[tK[R-1]];--R);var Y=l+5<<3,z=y2(r,$d)+y2(a,mz)+i,V=y2(r,f)+y2(a,v)+i+14+3*R+y2(S,N)+2*S[16]+3*S[17]+7*S[18];if(c>=0&&Y<=z&&Y<=V)return xre(t,u,e.subarray(c,c+l));var H,O,P,I;if(na(t,u,1+(V<z)),u+=2,V<z){H=ph(f,y,0),O=f,P=ph(v,w,0),I=v;var L=ph(N,A,0);na(t,u,x-257),na(t,u+5,_-1),na(t,u+10,R-4),u+=14;for(var $=0;$<R;++$)na(t,u+3*$,N[tK[$]]);u+=3*R;for(var U=[M,C],D=0;D<2;++D)for(var E=U[D],$=0;$<E.length;++$){var ee=E[$]&31;na(t,u,L[ee]),u+=N[ee],ee>15&&(na(t,u,E[$]>>5&127),u+=E[$]>>12)}}else H=Cnt,O=$d,P=Snt,I=mz;for(var $=0;$<s;++$){var J=o[$];if(J>255){var ee=J>>18&31;p2(t,u,H[ee+257]),u+=O[ee+257],ee>7&&(na(t,u,J>>23&31),u+=EF[ee]);var ne=J&31;p2(t,u,P[ne]),u+=I[ne],ne>3&&(p2(t,u,J>>5&8191),u+=$F[ne])}else p2(t,u,H[J]),u+=O[J]}return p2(t,u,H[256]),u+O[256]},Nnt=new AF([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),wre=new bn(0),Int=function(e,t,n,o,r,a){var i=a.z||e.length,s=new bn(o+i+5*(1+Math.ceil(i/7e3))+r),c=s.subarray(o,s.length-r),l=a.l,u=(a.r||0)&7;if(t){u&&(c[0]=a.r>>3);for(var h=Nnt[t-1],f=h>>13,y=h&8191,k=(1<<n)-1,v=a.p||new po(32768),w=a.h||new po(k+1),g=Math.ceil(n/3),M=2*g,x=function(Pe){return(e[Pe]^e[Pe+1]<<g^e[Pe+2]<<M)&k},b=new AF(25e3),C=new po(288),_=new po(32),S=0,$=0,j=a.i||0,N=0,A=a.w||0,R=0;j+2<i;++j){var Y=x(j),z=j&32767,V=w[Y];if(v[z]=V,w[Y]=z,A<=j){var H=i-j;if((S>7e3||N>24576)&&(H>423||!l)){u=rK(e,c,0,b,C,_,$,N,R,j-R,u),N=S=$=0,R=j;for(var O=0;O<286;++O)C[O]=0;for(var O=0;O<30;++O)_[O]=0}var P=2,I=0,L=y,U=z-V&32767;if(H>2&&Y==x(j-U))for(var D=Math.min(f,H)-1,E=Math.min(32767,j),ee=Math.min(258,H);U<=E&&--L&&z!=V;){if(e[j+P]==e[j+P-U]){for(var J=0;J<ee&&e[j+J]==e[j+J-U];++J);if(J>P){if(P=J,I=U,J>D)break;for(var ne=Math.min(U,J-2),oe=0,O=0;O<ne;++O){var te=j-U+O&32767,ce=v[te],ge=te-ce&32767;ge>oe&&(oe=ge,V=te)}}}z=V,V=v[z],U+=z-V&32767}if(I){b[N++]=268435456|eq[P]<<18|nK[I];var ae=eq[P]&31,se=nK[I]&31;$+=EF[ae]+$F[se],++C[257+ae],++_[se],A=j+P,++S}else b[N++]=e[j],++C[e[j]]}}for(j=Math.max(j,A);j<i;++j)b[N++]=e[j],++C[e[j]];u=rK(e,c,l,b,C,_,$,N,R,j-R,u),l||(a.r=u&7|c[u/8|0]<<3,u-=7,a.h=w,a.p=v,a.i=j,a.w=A)}else{for(var j=a.w||0;j<i+l;j+=65535){var re=j+65535;re>=i&&(c[u/8|0]=l,re=i),u=xre(c,u+1,e.subarray(j,re))}a.i=i}return vre(s,0,o+gre(u)+r)},Ant=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}(),Ent=function(){var e=-1;return{p:function(t){for(var n=e,o=0;o<t.length;++o)n=Ant[n&255^t[o]]^n>>>8;e=n},d:function(){return~e}}},Mre=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}}},bre=function(e,t,n,o,r){if(!r&&(r={l:1},t.dictionary)){var a=t.dictionary.subarray(-32768),i=new bn(a.length+e.length);i.set(a),i.set(e,a.length),e=i,r.w=a.length}return Int(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)},_re=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},Qt=function(e,t,n){for(;n;++t)e[t]=n,n>>>=8},$nt=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=Mre();r.p(t.dictionary),Qt(e,2,r.d())}};function jnt(e,t){return bre(e,t||{},0,0)}function Aot(e,t){t||(t={});var n=Mre();n.p(e);var o=bre(e,t,t.dictionary?6:2,4);return $nt(o,t),Qt(o,o.length-4,n.d()),o}var Cre=function(e,t,n,o){for(var r in e){var a=e[r],i=t+r,s=o;Array.isArray(a)&&(s=_re(o,a[1]),a=a[0]),a instanceof bn?n[i]=[a,s]:(n[i+="/"]=[new bn(0),s],Cre(a,i,n,o))}},aK=typeof TextEncoder<"u"&&new TextEncoder,Pnt=typeof TextDecoder<"u"&&new TextDecoder,znt=0;try{Pnt.decode(wre,{stream:!0}),znt=1}catch{}function oq(e,t){var n;if(aK)return aK.encode(e);for(var o=e.length,r=new bn(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 bn(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 vre(r,0,a)}var rq=function(e){var t=0;if(e)for(var n in e){var o=e[n].length;o>65535&&SR(9),t+=o+4}return t},iK=function(e,t,n,o,r,a,i,s){var c=o.length,l=n.extra,u=s&&s.length,h=rq(l);Qt(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)&&SR(10),Qt(e,t,y<<25|f.getMonth()+1<<21|f.getDate()<<16|f.getHours()<<11|f.getMinutes()<<5|f.getSeconds()>>1),t+=4,a!=-1&&(Qt(e,t,n.crc),Qt(e,t+4,a<0?-a-2:a),Qt(e,t+8,n.size)),Qt(e,t+12,c),Qt(e,t+14,h),t+=16,i!=null&&(Qt(e,t,u),Qt(e,t+6,n.attrs),Qt(e,t+10,i),t+=14),e.set(o,t),t+=c,h)for(var k in l){var v=l[k],w=v.length;Qt(e,t,+k),Qt(e,t+2,w),e.set(v,t+4),t+=4+w}return u&&(e.set(s,t),t+=u),t},Rnt=function(e,t,n,o,r){Qt(e,t,101010256),Qt(e,t+8,n),Qt(e,t+10,n),Qt(e,t+12,o),Qt(e,t+16,r)};function Tnt(e,t){t||(t={});var n={},o=[];Cre(e,"",n,t);var r=0,a=0;for(var i in n){var s=n[i],c=s[0],l=s[1],u=l.level==0?0:8,h=oq(i),f=h.length,y=l.comment,k=y&&oq(y),v=k&&k.length,w=rq(l.extra);f>65535&&SR(11);var g=u?jnt(c,l):c,M=g.length,x=Ent();x.p(c),o.push(_re(l,{size:c.length,crc:x.d(),c:g,f:h,m:k,u:f!=i.length||k&&y.length!=v,o:r,compression:u})),r+=30+f+w+M,a+=76+2*(f+w)+(v||0)+M}for(var b=new bn(a+22),C=r,_=a-r,S=0;S<o.length;++S){var h=o[S];iK(b,h.o,h,h.f,h.u,h.c.length);var $=30+h.f.length+rq(h.extra);b.set(h.c,h.o+$),iK(b,r,h,h.f,h.u,h.c.length,h.o,h.m),r+=16+$+(h.m?h.m.length:0)}return Rnt(b,r,o.length,_,C),b}const Dnt="https://seeflow.dev/api";async function Hnt(e,t,n,o,r,a){const i=await SX(e,t);if(!i.flow)throw new Error("Flow has no data");const s=i.flow,c=new Set,l=[];for(const v of s.nodes)v.type==="image"&&v.data.path&&!c.has(v.data.path)&&(c.add(v.data.path),l.push(v.data.path));const h={[r==="link"?"flow.private.json":"flow.json"]:oq(JSON.stringify(s))};if(a){const v=a.split(",")[1];v&&(h["preview.png"]=Uint8Array.from(atob(v),w=>w.charCodeAt(0)))}for(const v of l){const w=await fetch(`/api/projects/${encodeURIComponent(e)}/files/${v}`);w.ok&&(h[`files/${v}`]=new Uint8Array(await w.arrayBuffer()))}const f=Tnt(h),y=await fetch(`${Dnt}/flows?email=${encodeURIComponent(n)}&name=${encodeURIComponent(o)}`,{method:"POST",headers:{"content-type":"application/zip"},body:f.buffer});if(!y.ok)throw new Error(`Export failed with status ${y.status}`);const k=await y.json();if(typeof k.url!="string")throw new Error("Invalid response from cloud API: missing url");return{shareUrl:k.url}}function qnt(e,t){return m.useCallback((n,o,r,a)=>Hnt(e,t,n,o,r,a),[e,t])}const sK="seeflow.export.email",cK="seeflow.export.name",lK="seeflow.export.visibility";function Ont({open:e,onOpenChange:t,project:n,flow:o,flowName:r,onCapturePreview:a}){const[i,s]=m.useState(""),[c,l]=m.useState(""),[u,h]=m.useState("public"),[f,y]=m.useState({kind:"idle"}),[k,v]=m.useState(!1),w=qnt(n,o);m.useEffect(()=>{e&&(s(localStorage.getItem(sK)??""),l(r??localStorage.getItem(cK)??""),h(localStorage.getItem(lK)??"public"),y({kind:"idle"}),v(!1))},[e,r]);const g=m.useCallback(async()=>{y({kind:"loading"});try{const C=await(a==null?void 0:a()),{shareUrl:_}=await w(i.trim(),c.trim(),u,C);localStorage.setItem(sK,i.trim()),localStorage.setItem(cK,c.trim()),localStorage.setItem(lK,u),y({kind:"done",shareUrl:_})}catch(C){y({kind:"error",message:C instanceof Error?C.message:String(C)})}},[w,i,c,u,a]),M=m.useCallback(async()=>{if(f.kind==="done")try{await navigator.clipboard.writeText(f.shareUrl),v(!0),setTimeout(()=>v(!1),2e3)}catch(C){console.error("Failed to copy to clipboard:",C)}},[f]),x=f.kind==="loading",b=i.trim().length>0&&c.trim().length>0;return p.jsx(wa,{open:e,onOpenChange:t,children:p.jsxs(Ri,{className:"sm:max-w-md","data-testid":"export-dialog",onOpenAutoFocus:C=>{C.preventDefault();const _=document.querySelector('[data-testid="export-email-input"]');_==null||_.focus()},children:[p.jsxs(Ti,{children:[p.jsx(Di,{children:"Export to seeflow.dev"}),p.jsx(Hi,{children:"Upload this diagram to the cloud and get a shareable link."})]}),f.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:i,onChange:C=>s(C.target.value),disabled:x,"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:c,onChange:C=>l(C.target.value),disabled:x,"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:u,onChange:C=>h(C.target.value),disabled:x,"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"})]})]}),f.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:f.message}):null]}),p.jsx(Ma,{children:f.kind==="error"?p.jsxs(p.Fragment,{children:[p.jsx(dt,{type:"button",variant:"ghost",onClick:()=>t(!1),"data-testid":"export-cancel",children:"Cancel"}),p.jsx(dt,{type:"button",onClick:()=>y({kind:"idle"}),"data-testid":"export-retry",children:"Try again"})]}):p.jsxs(p.Fragment,{children:[p.jsx(dt,{type:"button",variant:"ghost",onClick:()=>t(!1),disabled:x,"data-testid":"export-cancel",children:"Cancel"}),p.jsx(dt,{type:"button",onClick:g,disabled:x||!b,"data-testid":"export-submit",children:x?p.jsxs(p.Fragment,{children:[p.jsx(Htt,{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:f.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(dt,{type:"button",variant:"outline",size:"icon",onClick:M,"aria-label":"Copy link","data-testid":"export-copy",children:k?p.jsx(are,{className:"h-4 w-4","aria-hidden":"true"}):p.jsx(sre,{className:"h-4 w-4","aria-hidden":"true"})}),p.jsx(dt,{type:"button",variant:"outline",size:"icon",onClick:()=>window.open(f.shareUrl,"_blank"),"aria-label":"View in new tab","data-testid":"export-view",children:p.jsx(Dtt,{className:"h-4 w-4","aria-hidden":"true"})})]})]}),p.jsx(Ma,{children:p.jsx(dt,{type:"button",onClick:()=>t(!1),"data-testid":"export-done",children:"Done"})})]})]})})}function Fnt(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}const Vnt=/^[a-z0-9][a-z0-9-]*$/,Bnt={"--tw-enter-translate-x":"-50%","--tw-enter-translate-y":"-50%","--tw-exit-translate-x":"-50%","--tw-exit-translate-y":"-50%","--tw-enter-scale":"1","--tw-exit-scale":"1"};function Unt({open:e,onOpenChange:t,onCreate:n,onCreated:o}){const[r,a]=m.useState(""),[i,s]=m.useState(""),[c,l]=m.useState(!1),[u,h]=m.useState(null),[f,y]=m.useState(!1);m.useEffect(()=>{e&&(a(""),s(""),l(!1),h(null),y(!1))},[e]);const k=C=>{a(C),c||s(Fnt(C))},v=C=>{s(C),c||l(!0)},w=i.trim(),g=r.trim(),M=w.length>0&&Vnt.test(w),x=M&&g.length>0&&!f,b=async C=>{if(C.preventDefault(),!x){!M&&w.length>0&&h("Flow id must match /^[a-z0-9][a-z0-9-]*$/");return}y(!0),h(null);try{const S=await n({id:w,name:g});o==null||o(S),t(!1)}catch(_){h(_ instanceof Error?_.message:String(_)),y(!1)}};return p.jsx(wa,{open:e,onOpenChange:t,children:p.jsxs(Ri,{className:"sm:max-w-md",style:Bnt,"data-testid":"flow-create-dialog",onOpenAutoFocus:C=>{C.preventDefault();const _=document.querySelector('[data-testid="flow-create-name-input"]');_==null||_.focus()},children:[p.jsxs(Ti,{children:[p.jsx(Di,{children:"Create new flow"}),p.jsx(Hi,{children:"A new flow folder is scaffolded under flows/<id>/ in your project."})]}),p.jsxs("form",{onSubmit:b,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:"Display name"}),p.jsx("input",{type:"text",required:!0,autoComplete:"off",spellCheck:!1,value:r,onChange:C=>k(C.target.value),"data-testid":"flow-create-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.jsx("span",{className:"font-medium",children:"Flow id"}),p.jsx("input",{type:"text",required:!0,autoComplete:"off",spellCheck:!1,placeholder:"my-retry-flow",value:i,onChange:C=>v(C.target.value),"data-testid":"flow-create-id-input",className:"rounded-md border bg-background px-3 py-2 font-mono text-sm outline-hidden ring-offset-background focus:border-ring focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2"}),p.jsx("span",{className:"text-xs text-muted-foreground",children:"Auto-filled from the display name. Lowercase letters, digits, and dashes; must start with a letter or digit."})]}),u?p.jsx("div",{role:"alert","data-testid":"flow-create-error",className:"rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-sm text-destructive",children:u}):null,p.jsxs(Ma,{children:[p.jsx(dt,{type:"button",variant:"ghost",onClick:()=>t(!1),disabled:f,children:"Cancel"}),p.jsx(dt,{type:"submit",disabled:!x,"data-testid":"flow-create-submit",children:f?"Creating…":"Create flow"})]})]})]})})}function Wnt({open:e,onOpenChange:t,flow:n,flows:o,onDelete:r,onDeleted:a}){var M;const i=m.useMemo(()=>o.filter(x=>x.flowSlug!==(n==null?void 0:n.flowSlug)),[o,n==null?void 0:n.flowSlug]),s=((M=i[0])==null?void 0:M.flowSlug)??"",[c,l]=m.useState(s),[u,h]=m.useState(null),[f,y]=m.useState(!1);if(m.useEffect(()=>{e&&(l(s),h(null),y(!1))},[e,s]),!n)return p.jsx(wa,{open:!1,onOpenChange:t});const k=n.isDefault,v=c.length>0,w=(!k||v)&&!f,g=async x=>{if(x.preventDefault(),!!w){y(!0),h(null);try{const b=k?{newDefault:c}:void 0;await r(n.flowSlug,b),a==null||a(n.flowSlug,b==null?void 0:b.newDefault),t(!1)}catch(b){h(b instanceof Error?b.message:String(b)),y(!1)}}};return p.jsx(wa,{open:e,onOpenChange:t,children:p.jsxs(Ri,{className:"sm:max-w-md","data-testid":"flow-delete-dialog",children:[p.jsxs(Ti,{children:[p.jsx(Di,{children:"Delete flow"}),p.jsxs(Hi,{children:["This removes flows/",n.flowSlug,"/ from disk and updates seeflow.json. The action cannot be undone."]})]}),p.jsxs("form",{onSubmit:g,className:"flex flex-col gap-4",children:[p.jsxs("p",{className:"text-sm",children:["Delete ",p.jsx("span",{className:"font-medium",children:n.name})," ",p.jsxs("span",{className:"font-mono text-muted-foreground",children:["(",n.flowSlug,")"]}),"?"]}),k?p.jsxs("label",{className:"flex flex-col gap-1.5 text-sm",children:[p.jsx("span",{className:"font-medium",children:"New default flow"}),p.jsx("select",{value:c,onChange:x=>l(x.target.value),"data-testid":"flow-delete-new-default-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",children:i.map(x=>p.jsxs("option",{value:x.flowSlug,children:[x.name," (",x.flowSlug,")"]},x.flowSlug))}),p.jsxs("span",{className:"text-xs text-muted-foreground",children:[n.name," is the project default — pick a replacement before deleting."]})]}):null,u?p.jsx("div",{role:"alert","data-testid":"flow-delete-error",className:"rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-sm text-destructive",children:u}):null,p.jsxs(Ma,{children:[p.jsx(dt,{type:"button",variant:"ghost",onClick:()=>t(!1),disabled:f,children:"Cancel"}),p.jsx(dt,{type:"submit",variant:"destructive",disabled:!w,"data-testid":"flow-delete-submit",children:f?"Deleting…":"Delete"})]})]})]})})}function Gnt({open:e,onOpenChange:t,flow:n,onRename:o,onRenamed:r}){const[a,i]=m.useState(""),[s,c]=m.useState(null),[l,u]=m.useState(!1);if(m.useEffect(()=>{e&&n&&(i(n.name),c(null),u(!1))},[e,n]),!n)return p.jsx(wa,{open:!1,onOpenChange:t});const h=a.trim(),f=h!==n.name,y=h.length>0&&f&&!l,k=async v=>{if(v.preventDefault(),!!y){u(!0),c(null);try{const w={name:h},g=await o(n.flowSlug,w);r==null||r(g,n.flowSlug),t(!1)}catch(w){c(w instanceof Error?w.message:String(w)),u(!1)}}};return p.jsx(wa,{open:e,onOpenChange:t,children:p.jsxs(Ri,{className:"sm:max-w-md","data-testid":"flow-rename-dialog",onOpenAutoFocus:v=>{v.preventDefault();const w=document.querySelector('[data-testid="flow-rename-name-input"]');w==null||w.focus(),w==null||w.select()},children:[p.jsxs(Ti,{children:[p.jsx(Di,{children:"Rename flow"}),p.jsx(Hi,{children:"Update the display name. The flow id is fixed once created."})]}),p.jsxs("form",{onSubmit:k,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:"Flow id"}),p.jsx("input",{type:"text",readOnly:!0,disabled:!0,autoComplete:"off",spellCheck:!1,value:n.flowSlug,"data-testid":"flow-rename-id-input",className:"cursor-not-allowed rounded-md border bg-muted px-3 py-2 font-mono text-sm text-muted-foreground"})]}),p.jsxs("label",{className:"flex flex-col gap-1.5 text-sm",children:[p.jsx("span",{className:"font-medium",children:"Display name"}),p.jsx("input",{type:"text",required:!0,autoComplete:"off",spellCheck:!1,value:a,onChange:v=>i(v.target.value),"data-testid":"flow-rename-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"})]}),s?p.jsx("div",{role:"alert","data-testid":"flow-rename-error",className:"rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-sm text-destructive",children:s}):null,p.jsxs(Ma,{children:[p.jsx(dt,{type:"button",variant:"ghost",onClick:()=>t(!1),disabled:l,children:"Cancel"}),p.jsx(dt,{type:"submit",disabled:!y,"data-testid":"flow-rename-submit",children:l?"Saving…":"Save"})]})]})]})})}function Knt({project:e,activeFlow:t,flows:n,onSelect:o,onCreate:r,onRename:a,onDelete:i}){const[s,c]=m.useState(!1),l=n.find(u=>u.flowSlug===t);return p.jsxs(Rd,{open:s,onOpenChange:c,children:[p.jsx(D0,{asChild:!0,children:p.jsxs(dt,{type:"button",variant:"outline",size:"sm","aria-label":`Switch flow for ${e}`,"aria-expanded":s,className:"gap-2","data-testid":"flow-switcher-trigger",children:[p.jsx("span",{className:"max-w-[180px] truncate text-sm",children:(l==null?void 0:l.name)??t}),p.jsx(ire,{className:"h-3.5 w-3.5 opacity-60"})]})}),p.jsx(zi,{align:"start",sideOffset:6,className:"w-[260px] p-0","data-testid":"flow-switcher-popover",children:p.jsx(GO,{children:p.jsxs(KO,{children:[p.jsx(ZO,{children:"No flows."}),n.length>0?p.jsx(Uh,{heading:"Flows",children:n.map(u=>{const h=u.flowSlug===t;return p.jsxs(Wh,{value:`${u.name} ${u.flowSlug}`,"aria-current":h?"true":void 0,"data-testid":`flow-switcher-row-${u.flowSlug}`,"data-active":h?"true":void 0,onSelect:()=>{c(!1),o==null||o(u.flowSlug)},className:ie("group flex items-center justify-between gap-2",h&&"bg-accent text-accent-foreground"),children:[p.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[u.icon?p.jsx("span",{"aria-hidden":"true",className:"text-xs opacity-70",children:u.icon}):null,p.jsx("span",{className:"truncate font-medium",children:u.name}),u.isDefault?p.jsx("span",{className:"shrink-0 rounded bg-muted px-1.5 py-0.5 text-[10px] uppercase tracking-wide text-muted-foreground",children:"default"}):null]}),p.jsxs("div",{className:"flex shrink-0 items-center gap-0.5 opacity-0 transition-opacity group-hover:opacity-100 focus-within:opacity-100",children:[p.jsx("button",{type:"button","aria-label":`Rename ${u.name}`,"data-testid":`flow-switcher-rename-${u.flowSlug}`,className:"rounded p-0.5 hover:text-foreground focus-visible:outline-hidden focus-visible:ring-1 focus-visible:ring-ring",onClick:f=>{f.stopPropagation(),c(!1),a==null||a(u.flowSlug)},children:p.jsx(qtt,{className:"h-3.5 w-3.5"})}),p.jsx("button",{type:"button","aria-label":`Delete ${u.name}`,"data-testid":`flow-switcher-delete-${u.flowSlug}`,className:"rounded p-0.5 hover:text-destructive focus-visible:outline-hidden focus-visible:ring-1 focus-visible:ring-ring",onClick:f=>{f.stopPropagation(),c(!1),i==null||i(u.flowSlug)},children:p.jsx(lre,{className:"h-3.5 w-3.5"})})]})]},u.flowSlug)})}):null,n.length>0?p.jsx(XO,{}):null,p.jsx(Uh,{children:p.jsxs(Wh,{value:"+ new flow","data-testid":"flow-switcher-create",onSelect:()=>{c(!1),r==null||r()},className:"flex items-center gap-2 text-sm",children:[p.jsx(cre,{className:"h-4 w-4 opacity-70"}),p.jsx("span",{className:"font-medium",children:"New flow"})]})})]})})})]})}const Znt=(e,t)=>{if(e.has(t))return e;const n=new Set(e);return n.add(t),n},Xnt=(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},Ynt=(e,t)=>{if(!e.has(t))return e;const n=new Set(e);return n.delete(t),n},Qnt=(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},Jnt=(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},dK=()=>{const[e,t]=m.useState(()=>new Set),n=m.useCallback(c=>{t(l=>Znt(l,c))},[]),o=m.useCallback(c=>{t(l=>Xnt(l,c))},[]),r=m.useCallback(c=>{t(l=>Ynt(l,c))},[]),a=m.useCallback(c=>{t(l=>Qnt(l,c))},[]),i=m.useCallback(c=>{t(l=>Jnt(l,c))},[]),s=m.useCallback(()=>t(new Set),[]);return{ids:e,mark:n,markMany:o,unmark:r,unmarkMany:a,pruneAgainst:i,reset:s}},eot=(e,t)=>e===t?!0:e==null||t==null||typeof e!=typeof t||typeof e!="object"?!1:JSON.stringify(e)===JSON.stringify(t),tot=(e,t,n)=>({...e,[t]:{...e[t],...n}}),not=(e,t)=>{if(!(t in e))return e;const n={...e};return delete n[t],n},oot=(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 u=!1;for(const h of Object.keys(s))eot(s[h],c[h])?r=!0:(l[h]=s[h],u=!0);u?a[i]=l:(r=!0,delete a[i])}return r?a:e},uK=()=>{const[e,t]=m.useState({}),n=m.useCallback((i,s)=>{t(c=>tot(c,i,s))},[]),o=m.useCallback(i=>{t(s=>not(s,i))},[]),r=m.useCallback(i=>{t(s=>oot(s,i))},[]),a=m.useCallback(()=>t({}),[]);return{overrides:e,setOverride:n,dropOverride:o,pruneAgainst:r,reset:a}},rot=500,aot=500,iot={stack:[],cursor:0},sot=(e,t,n)=>{const o=Date.now(),r=rot,a=aot,{stack:i,cursor:s}=e;if(t.coalesceKey&&s>0){const u=i[s-1];if(u&&u.coalesceKey===t.coalesceKey&&o-u.capturedAt<=a){const h=i.slice(0,s);return h[s-1]={...u,do:t.do,capturedAt:o},{stack:h,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}},cot=e=>e.cursor===0?{state:e,entry:void 0}:{state:{...e,cursor:e.cursor-1},entry:e.stack[e.cursor-1]},lot=e=>e.cursor===e.stack.length?{state:e,entry:void 0}:{state:{...e,cursor:e.cursor+1},entry:e.stack[e.cursor]},dot=()=>({stack:[],cursor:0}),uot=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}},hot=(e,t)=>t.state,fot=()=>{const[e,t]=m.useReducer(hot,iot),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(sot(n.current,k))},[a]),s=m.useCallback(()=>{r.current=Date.now();const y=o.current.then(()=>{const k=cot(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=lot(n.current);if(k.entry)return a(k.state),{entry:k.entry}});return o.current=y.then(()=>{},()=>{}),y},[a]),l=m.useCallback(()=>{a(dot())},[a]),u=m.useCallback(()=>{a(uot(n.current))},[a]),h=m.useCallback(()=>{r.current=Date.now()},[]),f=m.useCallback(()=>r.current,[]);return{push:i,undo:s,redo:c,clear:l,dropTop:u,canUndo:e.cursor>0,canRedo:e.cursor<e.stack.length,markMutation:h,lastMutationAt:f}};function pot({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,u=n?n.y-c:a.y,h=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+u}}}),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:h,newConnectors:f,idMap:i}}const yot=e=>({type:"image",position:e.position,data:{path:"",alt:e.originalFilename,width:e.dims.width,height:e.dims.height,_uploading:!0}}),mot=e=>({type:"image",data:Sre(e)}),kot=e=>({type:"image",position:e.position,data:{path:"",alt:e.originalFilename,width:e.dims.width,height:e.dims.height,_uploadError:e.message}}),Sre=e=>({...VTe(e.path,e.dims,e.lastUsed),alt:e.originalFilename}),got=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,yot({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,kot({position:i,dims:s,originalFilename:a,message:k})),y}t.setOverride(n,mot({path:l,dims:s,originalFilename:a,lastUsed:c}));const u=Sre({path:l,dims:s,originalFilename:a,lastUsed:c}),h={id:n,type:"image",position:i,data:u},{id:f}=await t.createNode(o,h);t.forgetRetry(n),t.pushUndo&&t.pushUndo({do:async()=>{await t.createNode(o,{...h,id:f})},undo:async()=>{await t.deleteNode(o,f)}})},vot="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",xot=248;function oa(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<xot&&(t+=vot[r%62])}}return t}const wot=new Set(["INPUT","TEXTAREA","SELECT"]),Oo=e=>e?wot.has(e.tagName)?!0:e instanceof HTMLElement&&e.isContentEditable:!1,Mot=(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 bot({project:e,flow:t,slug:n,demos:o,detail:r,loading:a,runs:i,nodeEvents:s,statusByNode:c,onPlayNode:l,onRestartDemo:u,refreshFlows:h}){var Da,Ha;const f=o.find(T=>T.slug===n),{flows:y,createFlow:k,renameFlow:v,deleteFlow:w}=ure(e),[g,M]=m.useState([]),[x,b]=m.useState([]),[C,_]=m.useState(null),S=m.useRef(g),$=m.useRef(x);m.useEffect(()=>{S.current=g},[g]),m.useEffect(()=>{$.current=x},[x]);const j=m.useRef(null),N=m.useRef(null),A=m.useRef(null),R=uK(),Y=uK(),z=dK(),V=dK(),[H,O]=m.useState(null),[P,I]=m.useState(null),[L,U]=m.useState({kind:"select"}),D=m.useRef({kind:"select"});m.useEffect(()=>{D.current=L},[L]);const[E,ee]=m.useState(!1),J=m.useRef(new Set),ne=`${e}/${t}`,oe=!J.current.has(ne);m.useEffect(()=>{J.current.add(ne)},[ne]);const te=m.useRef(null),ce=m.useCallback(T=>{te.current=T},[]),ge=fot(),{push:ae,dropTop:se,markMutation:re,clear:Pe,lastMutationAt:Be}=ge,{reset:Ve}=R,{reset:ht}=Y,{reset:Gt}=z,{reset:Et}=V;m.useEffect(()=>{M([]),b([]),_(null),Ve(),ht(),Gt(),Et(),O(null),I(null),Nn.current=null,Do(!1),oo.current.clear(),ge.clear()},[r==null?void 0:r.id]);const hn=m.useCallback((T,F)=>{M(T),b(F)},[]),fe=(Da=r==null?void 0:r.flow)==null?void 0:Da.nodes,Se=(Ha=r==null?void 0:r.flow)==null?void 0:Ha.connectors,{pruneAgainst:fn}=R,{pruneAgainst:pn}=Y,{pruneAgainst:sn}=z,{pruneAgainst:W}=V;m.useEffect(()=>{fe&&(fn(fe),sn(fe)),Date.now()-Be()>2e3&&Pe()},[fe,fn,sn,Be,Pe]),m.useEffect(()=>{Se&&(pn(Se),W(Se)),Date.now()-Be()>2e3&&Pe()},[Se,pn,W,Be,Pe]),m.useEffect(()=>{if(!(!fe||!H)&&fe.length===H.length){for(let T=0;T<fe.length;T++){const F=fe[T],Z=H[T];if(!F||F.id!==Z)return}O(null)}},[fe,H]);const G=(r==null?void 0:r.id)??null,K=m.useMemo(()=>BTe({baseUrl:"",project:e,flow:t}),[e,t]),[qe,Ze]=m.useState(!1),[Kt,tn]=m.useState(!1),[nn,Hn]=m.useState(null),[Cn,Tt]=m.useState(null),{setOverride:Ne,dropOverride:ze}=R,Qe=m.useRef(R.overrides);m.useEffect(()=>{Qe.current=R.overrides},[R.overrides]);const ct=m.useCallback((T,F)=>{var B;if(!G||!K)return;const Z=(B=fe==null?void 0:fe.find(q=>q.id===T))==null?void 0:B.position;Ne(T,{position:F}),I(null),re(),Z&&ae({do:async()=>{await K.updateNodePosition(T,F)},undo:async()=>{await K.updateNodePosition(T,Z)},coalesceKey:`node:${T}:position`}),K.updateNodePosition(T,F).catch(q=>{ze(T),Z&&se(),I(q instanceof Error?q.message:String(q)),console.error("updateNodePosition failed",q)})},[G,K,fe,Ne,ze,ae,se,re]),ir=m.useCallback(T=>{if(!G||!K||T.length===0)return;const F=Qe.current,Z=T.map(B=>{var $e;const q=fe==null?void 0:fe.find(Me=>Me.id===B.id);if(!q)return null;const de=(($e=F[B.id])==null?void 0:$e.position)??q.position;return{id:B.id,prev:de,next:B.position}}).filter(B=>B!==null);if(Z.length!==0){for(const B of Z)Ne(B.id,{position:B.next});I(null),re(),ae({do:async()=>{await Promise.allSettled(Z.map(B=>K.updateNodePosition(B.id,B.next)))},undo:async()=>{await Promise.allSettled(Z.map(B=>K.updateNodePosition(B.id,B.prev)))}}),Promise.all(Z.map(async B=>{try{return await K.updateNodePosition(B.id,B.next),null}catch(q){return ze(B.id),q instanceof Error?q.message:String(q)}})).then(B=>{const q=B.find(de=>de!==null);q&&I(q)})}},[G,K,fe,Ne,ze,ae,re]),qd=m.useCallback((T,F)=>{Ne(T,{position:{x:F.x,y:F.y},data:{width:F.width,height:F.height}})},[Ne]),Od=m.useCallback((T,F)=>{if(!G||!K)return;const Z=fe==null?void 0:fe.find(de=>de.id===T),B=Z?{width:Z.data.width,height:Z.data.height,position:{x:Z.position.x,y:Z.position.y}}:void 0,q={width:F.width,height:F.height,position:{x:F.x,y:F.y}};Ne(T,{position:q.position,data:{width:q.width,height:q.height}}),I(null),re(),B&&ae({do:async()=>{await K.updateNode(T,q)},undo:async()=>{await K.updateNode(T,B)},coalesceKey:`node:${T}:resize`}),K.updateNode(T,q).catch(de=>{ze(T),B&&se(),I(de instanceof Error?de.message:String(de)),console.error("updateNode resize failed",de)})},[G,K,fe,Ne,ze,ae,se,re]),Oi=m.useCallback(T=>{if(!G||!K)return;const F=fe==null?void 0:fe.find(q=>q.id===T);if(!F)return;const Z={autoSize:F.data.autoSize,width:F.data.width,height:F.data.height},B={autoSize:!0};Ne(T,{data:{autoSize:!0,width:void 0,height:void 0}}),I(null),re(),ae({do:async()=>{await K.updateNode(T,B)},undo:async()=>{await K.updateNode(T,Z)},coalesceKey:`node:${T}:fit-to-content`}),K.updateNode(T,B).catch(q=>{ze(T),se(),I(q instanceof Error?q.message:String(q)),console.error("updateNode (fit-to-content) failed",q)})},[G,K,fe,Ne,ze,ae,se,re]),Fd=m.useCallback(T=>{if(!G||!K||T.length===0)return;const F=[];for(const B of T){const q=fe==null?void 0:fe.find(st=>st.id===B.id);if(!q)continue;const de=q.data,$e={position:{x:q.position.x,y:q.position.y}};de.width!==void 0&&($e.width=de.width),de.height!==void 0&&($e.height=de.height);const Me={position:B.position};B.width!==void 0&&(Me.width=B.width),B.height!==void 0&&(Me.height=B.height),F.push({id:B.id,prev:$e,next:Me})}if(F.length===0)return;for(const B of F){const q={};B.next.width!==void 0&&(q.width=B.next.width),B.next.height!==void 0&&(q.height=B.next.height),Ne(B.id,{position:B.next.position,...Object.keys(q).length>0?{data:q}:{}})}I(null),re();const Z=F.map(B=>B.id).sort();ae({do:async()=>{await Promise.allSettled(F.map(B=>K.updateNode(B.id,B.next)))},undo:async()=>{await Promise.allSettled(F.map(B=>K.updateNode(B.id,B.prev)))},coalesceKey:`multi:resize:${Z.join(",")}`}),Promise.all(F.map(async B=>{try{return await K.updateNode(B.id,B.next),null}catch(q){return ze(B.id),q instanceof Error?q.message:String(q)}})).then(B=>{const q=B.find(de=>de!==null);q&&I(q)})},[G,K,fe,Ne,ze,ae,re]),{setOverride:$t,dropOverride:Ft}=Y,Vd=m.useCallback((T,F)=>{Ne(T,{data:F})},[Ne]),Bd=m.useCallback((T,F)=>{for(const Z of T)Ne(Z,{data:F})},[Ne]),Ud=m.useCallback((T,F)=>{$t(T,F)},[$t]),Wd=m.useCallback((T,F)=>{if(!G||!K)return;mU(Qa,F);const Z=fe==null?void 0:fe.find(q=>q.id===T);let B=null;if(Z){B={};const q=Z.data;for(const de of Object.keys(F))B[de]=q[de]}if(Ne(T,{data:F}),I(null),re(),B){const q=B;ae({do:async()=>{await K.updateNode(T,F)},undo:async()=>{await K.updateNode(T,q)},coalesceKey:`node:${T}:style`})}K.updateNode(T,F).catch(q=>{ze(T),B&&se(),I(q instanceof Error?q.message:String(q)),console.error("updateNode style failed",q)})},[G,K,fe,Ne,ze,ae,se,re]),Gd=m.useCallback((T,F)=>{if(!G||!K||T.length===0)return;mU(Qa,F);const Z=T.map(B=>{const q=fe==null?void 0:fe.find(Me=>Me.id===B);if(!q)return null;const de=q.data,$e={};for(const Me of Object.keys(F))$e[Me]=de[Me];return{id:B,prev:$e}}).filter(B=>B!==null);if(Z.length!==0){for(const B of Z)Ne(B.id,{data:F});I(null),re(),ae({do:async()=>{await Promise.allSettled(Z.map(B=>K.updateNode(B.id,F)))},undo:async()=>{await Promise.allSettled(Z.map(B=>K.updateNode(B.id,B.prev)))}}),Promise.all(Z.map(async B=>{try{return await K.updateNode(B.id,F),null}catch(q){return ze(B.id),q instanceof Error?q.message:String(q)}})).then(B=>{const q=B.find(de=>de!==null);q&&I(q)})}},[G,K,fe,Ne,ze,ae,re]),Kd=m.useCallback((T,F)=>{if(!G||!K)return;DTe(Qa,F);const Z=Se==null?void 0:Se.find(q=>q.id===T);let B=null;if(Z){B={};const q=Z;for(const de of Object.keys(F))B[de]=q[de]}if($t(T,F),I(null),re(),B){const q=B;ae({do:async()=>{await K.updateConnector(T,F)},undo:async()=>{await K.updateConnector(T,q)},coalesceKey:`connector:${T}:style`})}K.updateConnector(T,F).catch(q=>{Ft(T),B&&se(),I(q instanceof Error?q.message:String(q)),console.error("updateConnector failed",q)})},[G,K,Se,$t,Ft,ae,se,re]),{mark:La,markMany:Na,unmark:sr,unmarkMany:Fi}=z,{mark:Ia,markMany:De,unmark:vt,unmarkMany:no}=V,Vi=m.useCallback(T=>{if(!G||!K)return;const F=fe==null?void 0:fe.find(Me=>Me.id===T);if(!F)return;const Z=(Se??[]).filter(Me=>Me.source===T||Me.target===T),B=Z.map(Me=>Me.id),q=new Set(B);I(null),La(T),B.length>0&&De(B),M(Me=>Me.filter(st=>st!==T)),b(Me=>Me.filter(st=>!q.has(st))),re();const de=F,$e=Z;ae({do:async()=>{La(T),B.length>0&&De(B),await K.deleteNode(T)},undo:async()=>{sr(T),B.length>0&&no(B),await K.createNode({id:de.id,type:de.type,position:de.position,data:de.data});for(const Me of $e)await K.createConnector({...Me,id:Me.id})}}),K.deleteNode(T).catch(Me=>{sr(T),B.length>0&&no(B),se(),I(Me instanceof Error?Me.message:String(Me)),console.error("deleteNode failed",Me)})},[G,K,fe,Se,La,De,sr,no,ae,se,re]),cr=m.useCallback((T,F)=>{if(!G||!K||!fe)return;const Z=H??fe.map(de=>de.id),B=Mot(Z,T,F);if(!B)return;const q=Z.indexOf(T);O(B),I(null),re(),ae({do:async()=>{await K.reorderNode(T,F)},undo:async()=>{await K.reorderNode(T,{op:"toIndex",index:q})}}),K.reorderNode(T,F).catch(de=>{O(null),se(),I(de instanceof Error?de.message:String(de)),console.error("reorderNode failed",de)})},[G,K,fe,H,ae,se,re]);m.useCallback(T=>{if(!G||!K)return;const F=Se==null?void 0:Se.find(B=>B.id===T);if(!F)return;I(null),Ia(T),b(B=>B.filter(q=>q!==T)),re();const Z=F;ae({do:async()=>{Ia(T),await K.deleteConnector(T)},undo:async()=>{vt(T),await K.createConnector({...Z,id:Z.id})}}),K.deleteConnector(T).catch(B=>{vt(T),se(),I(B instanceof Error?B.message:String(B)),console.error("deleteConnector failed",B)})},[G,K,Se,Ia,vt,ae,se,re]);const Sn=m.useCallback((T,F)=>{if(!G||!K||T.length===0&&F.length===0)return;const Z=new Set(T),B=T.map(Ie=>fe==null?void 0:fe.find(Je=>Je.id===Ie)).filter(Ie=>!!Ie),q=(Se??[]).filter(Ie=>Z.has(Ie.source)||Z.has(Ie.target)),de=new Set(q.map(Ie=>Ie.id)),$e=F.map(Ie=>Se==null?void 0:Se.find(Je=>Je.id===Ie)).filter(Ie=>!!Ie).filter(Ie=>!de.has(Ie.id));if(B.length===0&&q.length===0&&$e.length===0)return;I(null);const Me=B.map(Ie=>Ie.id),st=[...q.map(Ie=>Ie.id),...$e.map(Ie=>Ie.id)];Me.length>0&&Na(Me),st.length>0&&De(st);const mn=B;M(Ie=>Ie.filter(Je=>!Z.has(Je)));const eu=new Set($e.map(Ie=>Ie.id));b(Ie=>Ie.filter(Je=>!eu.has(Je)&&!de.has(Je))),re(),ae({do:async()=>{Me.length>0&&Na(Me),st.length>0&&De(st);for(const Ie of mn)await K.deleteNode(Ie.id).catch(()=>{});await Promise.allSettled($e.map(Ie=>K.deleteConnector(Ie.id)))},undo:async()=>{Me.length>0&&Fi(Me),st.length>0&&no(st);for(let Ie=mn.length-1;Ie>=0;Ie--){const Je=mn[Ie];Je&&await K.createNode({id:Je.id,type:Je.type,position:Je.position,data:Je.data})}for(const Ie of[...q,...$e])await K.createConnector({...Ie,id:Ie.id})}});const ro=new Map;for(const Ie of B)ro.set(Ie.id,q.filter(Je=>Je.source===Ie.id||Je.target===Ie.id).map(Je=>Je.id));(async()=>{const Ie=[];for(const kn of mn)try{await K.deleteNode(kn.id)}catch(Bn){sr(kn.id);const Yr=ro.get(kn.id)??[];Yr.length>0&&no(Yr),Ie.push(Bn instanceof Error?Bn.message:String(Bn))}const Je=await Promise.all($e.map(async kn=>{try{return await K.deleteConnector(kn.id),null}catch(Bn){return vt(kn.id),Bn instanceof Error?Bn.message:String(Bn)}}));for(const kn of Je)kn!==null&&Ie.push(kn);Ie.length>0&&Ie[0]!==void 0&&I(Ie[0])})()},[G,K,fe,Se,Na,De,sr,Fi,vt,no,ae,re]);m.useEffect(()=>{j.current=Sn},[Sn]),m.useEffect(()=>{const T=F=>{if(F.key!=="Delete"&&F.key!=="Backspace"||Oo(document.activeElement)||document.querySelector('[data-testid="inline-edit-input"]'))return;const Z=S.current,B=$.current;Z.length===0&&B.length===0||(F.preventDefault(),Sn(Z,B))};return window.addEventListener("keydown",T),()=>window.removeEventListener("keydown",T)},[Sn]);const{undo:Ro,redo:Ln,canUndo:qn,canRedo:Zt}=ge;m.useEffect(()=>{const T=async F=>{if((F.metaKey||F.ctrlKey)&&F.key.toLowerCase()==="z"&&!Oo(document.activeElement)){if(F.preventDefault(),F.shiftKey){if(!Zt)return;try{const Z=await Ln();Z!=null&&Z.entry&&await Z.entry.do()}catch(Z){I(Z instanceof Error?Z.message:String(Z)),console.error("redo failed",Z)}return}if(qn)try{const Z=await Ro();Z!=null&&Z.entry&&await Z.entry.undo()}catch(Z){I(Z instanceof Error?Z.message:String(Z)),console.error("undo failed",Z)}}};return window.addEventListener("keydown",T),()=>window.removeEventListener("keydown",T)},[Ro,Ln,qn,Zt]);const Xt=m.useCallback((T,F)=>{if(!G||!K)return;const Z=fe==null?void 0:fe.find(de=>de.id===T),q=(Z&&"name"in Z.data?Z.data.name:void 0)??"";Ne(T,{data:{name:F}}),I(null),re(),Z&&ae({do:async()=>{await K.updateNode(T,{name:F})},undo:async()=>{await K.updateNode(T,{name:q})},coalesceKey:`node:${T}:name`}),K.updateNode(T,{name:F}).catch(de=>{Z&&se(),I(de instanceof Error?de.message:String(de)),console.error("updateNode name failed",de)})},[G,K,fe,Ne,ae,se,re]),lr=m.useCallback((T,F)=>{if(!G||!K)return;const Z=fe==null?void 0:fe.find(q=>q.id===T);if(!Z)return;const B=Z.data.description??"";Ne(T,{data:{description:F}}),I(null),re(),ae({do:async()=>{await K.updateNode(T,{description:F})},undo:async()=>{await K.updateNode(T,{description:B})},coalesceKey:`node:${T}:description`}),K.updateNode(T,{description:F}).catch(q=>{se(),I(q instanceof Error?q.message:String(q)),console.error("updateNode description failed",q)})},[G,K,fe,Ne,ae,se,re]),Bi=m.useCallback((T,F)=>{if(!G||!K)return;const Z=fe==null?void 0:fe.find(q=>q.id===T);if(!Z)return;const B=Z.data.detail??"";Ne(T,{data:{detail:F}}),I(null),re(),ae({do:async()=>{await K.updateNode(T,{detail:F})},undo:async()=>{await K.updateNode(T,{detail:B})},coalesceKey:`node:${T}:detail`}),K.updateNode(T,{detail:F}).catch(q=>{se(),I(q instanceof Error?q.message:String(q)),console.error("updateNode detail failed",q)})},[G,K,fe,Ne,ae,se,re]),Zd=m.useCallback((T,F)=>{if(!G||!K)return;const Z=fe==null?void 0:fe.find(q=>q.id===T);if(!Z)return;const B="icon"in Z.data?Z.data.icon??null:null;Ne(T,{data:{icon:F??void 0}}),I(null),re(),ae({do:async()=>{await K.updateNode(T,{icon:F})},undo:async()=>{await K.updateNode(T,{icon:B})},coalesceKey:`node:${T}:icon`}),K.updateNode(T,{icon:F}).catch(q=>{se(),I(q instanceof Error?q.message:String(q)),console.error("updateNode icon failed",q)})},[G,K,fe,Ne,ae,se,re]),Xd=m.useCallback((T,F,Z)=>{if(!G||!K)return;I(null);const B=`node-${oa()}`,q=gU(T,Z,M2(Qa).node),de={id:B,type:T,position:F,data:q};Ne(B,{id:B,type:T,position:F,data:q}),re(),K.createNode(de).then(({id:Me})=>{ae({do:async()=>{await K.createNode({...de,id:Me})},undo:async()=>{await K.deleteNode(Me)}})}).catch(Me=>{ze(B),I(Me instanceof Error?Me.message:String(Me)),console.error("createNode failed",Me)})},[G,K,Ne,ze,ae,re]),Ui=m.useCallback((T,F)=>{if(!G||!K)return;I(null);const Z=`node-${oa()}`,B={icon:T,width:p0.width,height:p0.height},q={id:Z,type:"icon",position:F,data:B};Ne(Z,{id:Z,type:"icon",position:F,data:B}),M([Z]),re(),K.createNode(q).then(({id:$e})=>{ae({do:async()=>{await K.createNode({...q,id:$e})},undo:async()=>{await K.deleteNode($e)}})}).catch($e=>{ze(Z),I($e instanceof Error?$e.message:String($e)),console.error("createNode (icon) failed",$e)})},[G,K,Ne,ze,ae,re]),jt=m.useCallback(T=>{if(!G||!K)return;I(null);const F=`node-${oa()}`,Z={id:F,type:"html",position:T.position,data:{}},B={id:F,type:"html",position:T.position,data:{}};Ne(F,B),M([F]),re(),K.createNode(Z).then(({id:q})=>{ae({do:async()=>{await K.createNode({...Z,id:q})},undo:async()=>{await K.deleteNode(q)}})}).catch(q=>{ze(F),I(q instanceof Error?q.message:String(q)),console.error("createNode (type:'html') failed",q)})},[G,K,Ne,ze,ae,re]),oo=m.useRef(new Map),Wr=m.useCallback((T,F)=>{oo.current.set(T,F)},[]),Aa=m.useCallback(T=>{oo.current.delete(T)},[]),bo=m.useCallback(T=>{!G||!K||(I(null),re(),got({...T,flowId:G,lastUsed:M2(Qa).node},{upload:(F,Z,B,q)=>K.uploadImage(Z,B,q),createNode:async(F,Z)=>{const{id:B}=await K.createNode(Z);return{id:B}},deleteNode:async(F,Z)=>(await K.deleteNode(Z),{ok:!0}),setOverride:Ne,pushUndo:ae,rememberRetry:Wr,forgetRetry:Aa}).catch(F=>{console.error("image-upload-flow failed",F)}))},[G,K,Ne,ae,re,Wr,Aa]),Gr=m.useCallback(T=>{if(!G||!K)return;const F=`node-${oa()}`;bo({nodeId:F,...T})},[G,K,bo]),Yd=m.useCallback(T=>{const F=oo.current.get(T);F&&bo({nodeId:T,...F})},[bo]),[_o,Ea]=m.useState({open:!1,mode:"insert"}),To=m.useCallback((T,F)=>{Ea({open:!0,mode:T,nodeId:F})},[]),yn=m.useCallback(()=>{Ea(T=>({...T,open:!1}))},[]),Kr=m.useCallback(()=>{To("insert")},[To]),dr=m.useCallback(T=>To("replace",T),[To]),V0=m.useCallback(T=>{if(NTe(T),_o.mode==="replace"&&_o.nodeId){if(G&&K){const F=_o.nodeId,Z=fe==null?void 0:fe.find(q=>q.id===F),B=(Z==null?void 0:Z.type)==="icon"?Z.data.icon:void 0;if(Ne(F,{data:{icon:T}}),I(null),re(),B!==void 0){const q=B;ae({do:async()=>{await K.updateNode(F,{icon:T})},undo:async()=>{await K.updateNode(F,{icon:q})},coalesceKey:`node:${F}:icon`})}K.updateNode(F,{icon:T}).catch(q=>{ze(F),B!==void 0&&se(),I(q instanceof Error?q.message:String(q)),console.error("updateNode (icon replace) failed",q)})}}else{const F=te.current;if(F&&G){const Z=STe(F,{width:window.innerWidth,height:window.innerHeight});Ui(T,Z)}}yn()},[_o.mode,_o.nodeId,G,K,fe,Ne,ze,ae,se,re,Ui,yn]),Zr=m.useCallback((T,F)=>{if(!G||!K)return;const Z=Se==null?void 0:Se.find(q=>q.id===T),B=Z==null?void 0:Z.label;$t(T,{label:F}),I(null),re(),Z&&ae({do:async()=>{await K.updateConnector(T,{label:F})},undo:async()=>{await K.updateConnector(T,{label:B})},coalesceKey:`connector:${T}:label`}),K.updateConnector(T,{label:F}).catch(q=>{Z&&se(),I(q instanceof Error?q.message:String(q)),console.error("updateConnector label failed",q)})},[G,K,Se,$t,ae,se,re]),Qd=m.useCallback((T,F,Z)=>{if(!G||!K)return;const B=`conn-${oa()}`,q=Z==null?void 0:Z.targetPin,de=M2(Qa).connector,$e={id:B,source:T,target:F,sourceHandleAutoPicked:!0,targetHandleAutoPicked:!0,...q?{targetPin:q}:{},...de},Me={id:B,source:T,target:F,sourceHandleAutoPicked:!0,targetHandleAutoPicked:!0,...q?{targetPin:q}:{},...de};$t(B,$e),I(null),re(),K.createConnector(Me).then(({id:st})=>{ae({do:async()=>{await K.createConnector({...Me,id:st})},undo:async()=>{await K.deleteConnector(st)}})}).catch(st=>{Ft(B),I(st instanceof Error?st.message:String(st)),console.error("createConnector failed",st)})},[G,K,$t,Ft,ae,re]),$a=m.useCallback(({sourceNodeId:T,position:F,shape:Z})=>{if(!G||!K)return;I(null);const B=`node-${oa()}`,q=`conn-${oa()}`,de=az[Z],$e=M2(Qa),Me=gU(Z,de,$e.node),st={id:B,type:Z,position:F,data:Me},mn={id:q,source:T,target:B,sourceHandleAutoPicked:!0,targetHandleAutoPicked:!0,...$e.connector};Ne(B,{id:B,type:Z,position:F,data:Me}),$t(q,mn),_(B),re(),(async()=>{try{await K.createNode(st),await K.createConnector(mn),ae({do:async()=>{await K.createNode(st),await K.createConnector(mn)},undo:async()=>{Ft(q),ze(B),await K.deleteConnector(q).catch(()=>{}),await K.deleteNode(B).catch(()=>{})}})}catch(ro){ze(B),Ft(q),I(ro instanceof Error?ro.message:String(ro)),console.error("createAndConnectFromPane failed",ro)}})()},[G,K,Ne,ze,$t,Ft,ae,re]),Nn=m.useRef(null),[Xr,Do]=m.useState(!1),On=m.useCallback(T=>{if(!fe)return;const F=new Set(T),Z=fe.filter(q=>F.has(q.id));if(Z.length===0)return;const B=(Se??[]).filter(q=>F.has(q.source)&&F.has(q.target));Nn.current=JSON.parse(JSON.stringify({nodes:Z,connectors:B})),Do(!0)},[fe,Se]),Fn=m.useCallback(T=>{if(!G||!K)return;const F=Nn.current;if(!F||F.nodes.length===0)return;const{newNodes:Z,newConnectors:B}=pot({nodes:F.nodes,connectors:F.connectors,flowPos:T,nodeIdGen:()=>`node-${oa()}`,connectorIdGen:()=>`conn-${oa()}`});for(const q of Z)Ne(q.id,q);for(const q of B)$t(q.id,q);M(Z.map(q=>q.id)),b(B.map(q=>q.id)),I(null),re(),(async()=>{try{for(const q of Z)await K.createNode({id:q.id,type:q.type,position:q.position,data:q.data});for(const q of B)await K.createConnector(q);ae({do:async()=>{for(const q of Z)await K.createNode({id:q.id,type:q.type,position:q.position,data:q.data});for(const q of B)await K.createConnector(q)},undo:async()=>{await Promise.allSettled(B.map(q=>K.deleteConnector(q.id))),await Promise.allSettled(Z.map(q=>K.deleteNode(q.id)))}})}catch(q){for(const de of Z)ze(de.id);for(const de of B)Ft(de.id);I(q instanceof Error?q.message:String(q)),console.error("paste failed",q)}})()},[G,K,Ne,ze,$t,Ft,re,ae]);m.useEffect(()=>{const T=F=>{const Z=RTe({event:F,isEditableActive:Oo(document.activeElement),hasNodes:!!fe&&fe.length>0,hasConnectors:!!Se&&Se.length>0,selectedIds:S.current,hasClipboard:!!Nn.current});if(Z.type!=="noop"&&!(Z.type==="copy"||Z.type==="paste")){if(F.preventDefault(),Z.type==="selectAll"){M((fe??[]).map(B=>B.id)),b((Se??[]).map(B=>B.id));return}On([...Z.ids]),Fn(null)}};return window.addEventListener("keydown",T),()=>window.removeEventListener("keydown",T)},[fe,Se,On,Fn]),m.useEffect(()=>{const T=F=>{const Z=jTe(F);if(!Z||Oo(document.activeElement))return;const B=S.current;if(B.length===0)return;const q=R.overrides,de=(fe??[]).map(Me=>{var mn;const st=((mn=q[Me.id])==null?void 0:mn.position)??Me.position;return{id:Me.id,position:st}}),$e=zTe(Z,B,de);if($e.length!==0)if(F.preventDefault(),$e.length===1){const Me=$e[0];Me&&ct(Me.id,Me.position)}else ir($e)};return window.addEventListener("keydown",T),()=>window.removeEventListener("keydown",T)},[fe,R.overrides,ct,ir]),m.useEffect(()=>{const T=F=>{const Z=PTe(F);if(!Z||Oo(document.activeElement))return;F.preventDefault();const B=te.current;B&&(Z==="fit"?B.fitView({padding:.2,duration:200}):Z==="in"?B.zoomIn({duration:150}):B.zoomOut({duration:150}))};return window.addEventListener("keydown",T),()=>window.removeEventListener("keydown",T)},[]);const Ho=m.useCallback(async T=>{if(!G||!K||!fe||!K.computeLayout)return;const F=R.overrides,Z=te.current,B=T==="selection"?new Set(S.current):null,q=B?fe.filter(je=>B.has(je.id)):fe;if(q.length<2)return;const de=new Set(q.map(je=>je.id)),$e=(Se??[]).filter(je=>de.has(je.source)&&de.has(je.target)),Me=new Map,st=q.map(je=>{var nu;const tt=((nu=F[je.id])==null?void 0:nu.position)??je.position;Me.set(je.id,tt);const pt=Z==null?void 0:Z.getInternalNode(je.id),on=pt==null?void 0:pt.measured,Co=je.data,qa=(on==null?void 0:on.width)??Co.width??200,tu=(on==null?void 0:on.height)??Co.height??120;return{id:je.id,type:je.type,width:qa,height:tu}}),mn=$e.map(je=>({id:je.id,source:je.source,target:je.target})),eu=await K.computeLayout(st,mn),ro=new Map;for(const[je,tt]of Object.entries(eu.nodes))ro.set(je,tt.position);let Ie=Number.POSITIVE_INFINITY,Je=Number.POSITIVE_INFINITY,kn=Number.POSITIVE_INFINITY,Bn=Number.POSITIVE_INFINITY;for(const je of st){const tt=Me.get(je.id);if(!tt)continue;tt.x<Ie&&(Ie=tt.x),tt.y<Je&&(Je=tt.y);const pt=ro.get(je.id);pt&&(pt.x<kn&&(kn=pt.x),pt.y<Bn&&(Bn=pt.y))}const Yr=Number.isFinite(Ie)&&Number.isFinite(kn)?Ie-kn:0,K0=Number.isFinite(Je)&&Number.isFinite(Bn)?Je-Bn:0,hr=[];for(const je of st){const tt=Me.get(je.id),pt=ro.get(je.id);if(!tt||!pt)continue;const on={x:pt.x+Yr,y:pt.y+K0},Co=on.x-tt.x,qa=on.y-tt.y;Math.abs(Co)<1&&Math.abs(qa)<1||hr.push({id:je.id,prev:tt,next:on})}if(hr.length!==0){I(null);for(const je of hr)Ne(je.id,{position:je.next});re(),ae({do:async()=>{await Promise.allSettled(hr.map(je=>K.updateNodePosition(je.id,je.next)))},undo:async()=>{await Promise.allSettled(hr.map(je=>K.updateNodePosition(je.id,je.prev)))}}),Promise.all(hr.map(async je=>{try{return await K.updateNodePosition(je.id,je.next),null}catch(tt){return ze(je.id),tt instanceof Error?tt.message:String(tt)}})).then(je=>{const tt=je.filter(on=>on!==null),pt=tt[0];pt&&(I(tt.length===1?pt:`${tt.length} node updates failed (first: ${pt})`),console.error("Tidy: some updateNodePosition calls failed",tt))})}},[G,K,fe,Se,R.overrides,Ne,ze,ae,re]);m.useEffect(()=>{const T=F=>{if(!(F.metaKey||F.ctrlKey)||!F.shiftKey||F.altKey||F.key.toLowerCase()!=="l"||Oo(document.activeElement))return;F.preventDefault();const Z=S.current.length>0?"selection":"all";Ho(Z)};return window.addEventListener("keydown",T),()=>window.removeEventListener("keydown",T)},[Ho]);const ja=m.useCallback(()=>{const T=S.current.length>0?"selection":"all";Ho(T)},[Ho]);m.useEffect(()=>{const T=F=>{if(Oo(document.activeElement)||document.querySelector('[data-testid="inline-edit-input"]'))return;const Z=TTe(F);if(Z===null)return;const B=D.current;if(Z==="select"){B.kind!=="select"&&U({kind:"select"});return}if(Z==="hand"){U(B.kind==="hand"?{kind:"select"}:{kind:"hand"});return}if(B.kind==="draw"&&B.shape===Z){U({kind:"select"});return}U({kind:"draw",shape:Z})};return window.addEventListener("keydown",T),()=>window.removeEventListener("keydown",T)},[]),m.useEffect(()=>{const T=F=>{if(F.key!=="Escape"||Oo(document.activeElement)||document.querySelector('[data-testid="inline-edit-input"]'))return;if(D.current.kind!=="select"){U({kind:"select"});return}S.current.length>0&&M([]),$.current.length>0&&b([])};return window.addEventListener("keydown",T),()=>window.removeEventListener("keydown",T)},[]),m.useEffect(()=>{const T=F=>{if(F.key.toLowerCase()!=="f"||F.metaKey||F.ctrlKey||F.shiftKey||F.altKey||Oo(document.activeElement)||document.querySelector('[data-testid="inline-edit-input"]'))return;const Z=S.current;if(Z.length===0)return;const B=te.current;B&&B.fitView({nodes:Z.map(q=>({id:q})),padding:.2,duration:200})};return window.addEventListener("keydown",T),()=>window.removeEventListener("keydown",T)},[]),m.useEffect(()=>{const T=F=>{if(F.key!=="1"||F.metaKey||F.ctrlKey||F.shiftKey||F.altKey||Oo(document.activeElement)||document.querySelector('[data-testid="inline-edit-input"]'))return;const Z=te.current;if(!Z)return;const{x:B,y:q}=Z.getViewport();Z.setViewport({x:B,y:q,zoom:1},{duration:150})};return window.addEventListener("keydown",T),()=>window.removeEventListener("keydown",T)},[]);const Pa=m.useCallback(T=>{var F,Z,B;switch(T){case"tool.select":U({kind:"select"});return;case"tool.hand":U({kind:"hand"});return;case"tool.rectangle":U({kind:"draw",shape:"rectangle"});return;case"tool.ellipse":U({kind:"draw",shape:"ellipse"});return;case"tool.text":U({kind:"draw",shape:"text"});return;case"tool.sticky":U({kind:"draw",shape:"sticky"});return;case"tool.database":U({kind:"draw",shape:"database"});return;case"edit.undo":{if(!qn)return;(async()=>{try{const q=await Ro();q!=null&&q.entry&&await q.entry.undo()}catch(q){I(q instanceof Error?q.message:String(q)),console.error("undo failed",q)}})();return}case"edit.redo":{if(!Zt)return;(async()=>{try{const q=await Ln();q!=null&&q.entry&&await q.entry.do()}catch(q){I(q instanceof Error?q.message:String(q)),console.error("redo failed",q)}})();return}case"edit.copy":{const q=S.current;if(q.length===0)return;On([...q]);return}case"edit.paste":Fn(null);return;case"edit.duplicate":{const q=S.current;if(q.length===0)return;On([...q]),Fn(null);return}case"edit.delete":{const q=S.current,de=$.current;if(q.length===0&&de.length===0)return;Sn([...q],[...de]);return}case"edit.selectAll":M((fe??[]).map(q=>q.id)),b((Se??[]).map(q=>q.id));return;case"view.fit":{const q=te.current;if(!q)return;q.fitView({padding:.2,duration:200});return}case"view.zoomIn":{const q=te.current;if(!q)return;q.zoomIn({duration:150});return}case"view.zoomOut":{const q=te.current;if(!q)return;q.zoomOut({duration:150});return}case"view.zoom100":{const q=te.current;if(!q)return;const{x:de,y:$e}=q.getViewport();q.setViewport({x:de,y:$e,zoom:1},{duration:150});return}case"view.zoomToSelection":{const q=S.current;if(q.length===0)return;const de=te.current;if(!de)return;de.fitView({nodes:q.map($e=>({id:$e})),padding:.2,duration:200});return}case"layout.tidy":{const q=S.current.length>0?"selection":"all";Ho(q);return}case"selection.deselect":S.current.length>0&&M([]),$.current.length>0&&b([]),D.current.kind!=="select"&&U({kind:"select"});return;case"help.commandPalette":ee(!0);return;case"export.pdf":{(F=A.current)==null||F.exportPdf();return}case"export.png":{(Z=A.current)==null||Z.exportPng();return}case"session.reset":{(B=N.current)==null||B.call(N);return}}},[qn,Zt,Ro,Ln,On,Fn,Sn,fe,Se,Ho]);m.useEffect(()=>{const T=F=>{(F.metaKey||F.ctrlKey)&&(F.shiftKey||F.altKey||F.key.toLowerCase()==="p"&&(F.preventDefault(),!Oo(document.activeElement)&&Pa("help.commandPalette")))};return window.addEventListener("keydown",T),()=>window.removeEventListener("keydown",T)},[Pa]),m.useEffect(()=>{N.current=u??null},[u]);const Wi=m.useCallback((T,F)=>{if(!G||!K)return;const Z=Se==null?void 0:Se.find(de=>de.id===T),B=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,q={...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($t(T,q),I(null),re(),B){const de=B;ae({do:async()=>{await K.updateConnector(T,F)},undo:async()=>{await K.updateConnector(T,de)},coalesceKey:`connector:${T}:reconnect`})}K.updateConnector(T,F).catch(de=>{Ft(T),B&&se(),I(de instanceof Error?de.message:String(de)),console.error("updateConnector reconnect failed",de)})},[G,K,Se,$t,Ft,ae,se,re]),za=m.useCallback((T,F,Z)=>{if(!G||!K)return;const B=Se==null?void 0:Se.find($e=>$e.id===T),q=B?F==="source"?B.sourcePin:B.targetPin:void 0,de=F==="source"?"sourcePin":"targetPin";if($t(T,{[de]:Z}),I(null),re(),B){const $e={[de]:q??null};ae({do:async()=>{await K.updateConnector(T,{[de]:Z})},undo:async()=>{await K.updateConnector(T,$e)},coalesceKey:`connector:${T}:${de}`})}K.updateConnector(T,{[de]:Z}).catch($e=>{Ft(T),B&&se(),I($e instanceof Error?$e.message:String($e)),console.error("updateConnector pin failed",$e)})},[G,K,Se,$t,Ft,ae,se,re]),Jd=m.useCallback((T,F)=>{if(!G||!K)return;const Z=Se==null?void 0:Se.find(de=>de.id===T),B=Z?F==="source"?Z.sourcePin:Z.targetPin:void 0;if(!B)return;const q=F==="source"?"sourcePin":"targetPin";$t(T,{[q]:void 0}),I(null),re(),ae({do:async()=>{await K.updateConnector(T,{[q]:null})},undo:async()=>{await K.updateConnector(T,{[q]:B})}}),K.updateConnector(T,{[q]:null}).catch(de=>{Ft(T),se(),I(de instanceof Error?de.message:String(de)),console.error("updateConnector unpin failed",de)})},[G,K,Se,$t,Ft,ae,se,re]),It=r==null?void 0:r.flow,B0=R.overrides,U0=Y.overrides,In=z.ids,ur=V.ids,Pf=m.useMemo(()=>{if(!It||g.length===0)return[];const T=new Map(It.nodes.map(Z=>[Z.id,Z])),F=[];for(const Z of g){const B=T.get(Z);if(!B)continue;const q=B0[Z];if(!q){F.push(B);continue}const de=q.data?{...B.data,...q.data}:B.data;F.push({...B,...q,data:de})}return F},[It,g,B0]),Ra=m.useMemo(()=>{if(!It||x.length===0)return[];const T=new Map(It.connectors.map(Z=>[Z.id,Z])),F=[];for(const Z of x){const B=T.get(Z);if(!B)continue;const q=U0[Z];F.push(q?{...B,...q}:B)}return F},[It,x,U0]),W0=m.useMemo(()=>{if(!It)return null;if(!H)return It.nodes;const T=new Map(It.nodes.map(B=>[B.id,B])),F=[],Z=new Set;for(const B of H){const q=T.get(B);q&&(F.push(q),Z.add(B))}for(const B of It.nodes)Z.has(B.id)||F.push(B);return F},[It,H]),zf=m.useMemo(()=>{const T=W0??(It==null?void 0:It.nodes)??null;return T?In.size===0?T:T.filter(F=>!In.has(F.id)):null},[W0,It,In]),Vn=m.useMemo(()=>{const T=(It==null?void 0:It.connectors)??null;return T?ur.size===0&&In.size===0?T:T.filter(F=>!ur.has(F.id)&&!In.has(F.source)&&!In.has(F.target)):null},[It,ur,In]),Gi=(y==null?void 0:y.some(T=>T.flowSlug===t))??!1;if(!f&&!Gi&&!(y===null))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: ",n]}),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(!f||a&&!r)return p.jsx("div",{className:"flex h-full w-full items-center justify-center text-sm text-muted-foreground",children:"Loading demo…"});const Ki=g[0],G0=Ki?c[Ki]:void 0;return p.jsxs("div",{className:"relative h-full w-full",children:[r&&!r.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:r.error})]}):null,p.jsx(Unt,{open:Kt,onOpenChange:tn,onCreate:k,onCreated:async T=>{await h(),J.current.add(`${e}/${T.flowSlug}`),jr(ui(e,T.flowSlug))}}),p.jsx(Gnt,{open:nn!==null,onOpenChange:T=>{T||Hn(null)},flow:nn,onRename:v,onRenamed:async(T,F)=>{await h(),T.flowSlug!==F&&(J.current.add(`${e}/${T.flowSlug}`),jr(ui(e,T.flowSlug)))}}),p.jsx(Wnt,{open:Cn!==null,onOpenChange:T=>{T||Tt(null)},flow:Cn,flows:y??[],onDelete:w,onDeleted:async(T,F)=>{var B;if(await h(),T!==t)return;const Z=F??((B=y==null?void 0:y.find(q=>q.isDefault&&q.flowSlug!==T))==null?void 0:B.flowSlug);Z&&jr(ui(e,Z))}}),It&&K?p.jsx(Stt,{ref:A,mode:"edit",adapter:K,topLeftSlot:p.jsx(Knt,{project:e,activeFlow:t,flows:y??[],onSelect:T=>{T!==t&&jr(ui(e,T))},onCreate:()=>tn(!0),onRename:T=>{const F=y==null?void 0:y.find(Z=>Z.flowSlug===T);F&&Hn({flowSlug:F.flowSlug,name:F.name,icon:F.icon})},onDelete:T=>{const F=y==null?void 0:y.find(Z=>Z.flowSlug===T);F&&Tt({flowSlug:F.flowSlug,name:F.name,isDefault:F.isDefault})}}),projectId:e,flowSlug:t,enableEmbed:!1,onExportToCloud:G?()=>Ze(!0):void 0,onRestartDemo:u,nodes:zf??It.nodes,connectors:Vn??It.connectors,selectedNodeIds:g,selectedConnectorIds:x,onSelectionChange:hn,runtime:{runs:i,statuses:c,pendingOverrides:{nodes:B0,connectors:U0}},onPlayNode:l,onNodePositionChange:ct,onNodePositionsChange:ir,onNodeResize:qd,onNodeResizeEnd:Od,onHtmlNodeFitToContent:Oi,onComponentNodeFitToContent:Oi,onMultiResize:Fd,onNodeNameChange:Xt,onNodeDescriptionChange:lr,onConnectorLabelChange:Zr,onCreateShapeNode:Xd,onCreateImageFromFile:G?Gr:void 0,onRetryImageUpload:G?Yd:void 0,onCreateHtmlNode:G?jt:void 0,iconPickerOpen:_o.open,onOpenIconPicker:G?Kr:void 0,onCloseIconPicker:G?yn:void 0,onPickIcon:G?V0:void 0,onRequestIconReplace:G?dr:void 0,onCreateConnector:Qd,onReconnectConnector:Wi,onPinEndpoint:G?za:void 0,onUnpinEndpoint:G?Jd:void 0,onReorderNode:cr,onDeleteNode:Vi,onCopyNode:T=>On([T]),onPasteAt:Fn,onCopySelection:G?On:void 0,onPasteSelection:G?()=>Fn(null):void 0,hasClipboard:Xr,selectedNodes:Pf,selectedConnectors:Ra,onStyleNode:Wd,onStyleNodePreview:Vd,onStyleNodes:Gd,onStyleNodesPreview:Bd,onStyleConnector:Kd,onStyleConnectorPreview:Ud,onRfInit:ce,onTidy:fe?ja:void 0,onCreateAndConnectFromPane:$a,pendingEditNodeId:C,canvasMode:L,onCanvasModeChange:U,statusReport:G0,onNameChange:Xt,onDescriptionChange:lr,onDetailChange:Bi,onIconChange:Zd,autoFitView:oe},`${e}/${t}`):p.jsx("div",{className:"flex h-full w-full items-center justify-center text-sm text-muted-foreground",children:"No demo data yet."}),P?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}),p.jsx("button",{type:"button",className:"ml-3 underline underline-offset-2",onClick:()=>I(null),children:"Dismiss"})]}):null,p.jsx(Mnt,{open:E,onOpenChange:ee,runCommand:Pa,ctx:{hasSelection:g.length>0||x.length>0,canUndo:qn,canRedo:Zt,hasClipboard:Xr,canExportDemo:!!G,canResetSession:!!u}}),G?p.jsx(Ont,{open:qe,onOpenChange:Ze,project:e,flow:t,flowName:(r==null?void 0:r.name)??f.name,onCapturePreview:()=>{var T;return((T=A.current)==null?void 0:T.capturePreview())??Promise.resolve(void 0)}}):null]})}const hK="npx seeflow register --path .";function _ot(){const[e,t]=m.useState(!1),n=async()=>{try{await navigator.clipboard.writeText(hK),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(Ftt,{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:hK}),p.jsx(dt,{type:"button",variant:"ghost",size:"sm",onClick:n,"aria-label":"Copy register command",children:e?p.jsx(are,{className:"h-4 w-4"}):p.jsx(sre,{className:"h-4 w-4"})})]})]})})}function Cot({demos:e}){return e.length===0?p.jsx(_ot,{}):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:()=>jr(ore(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))})]})})}function Sot(){const e=$tt(),{demos:t,refresh:n}=nnt(),{projects:o,refresh:r,unregisterProject:a}=fnt(),i=jtt(e),s=(i==null?void 0:i.project)??null,c=(i==null?void 0:i.flow)??null,l=Ptt(e),u=(l==null?void 0:l.project)??null,{flows:h}=ure(u);pnt({onRegistryReload:()=>{n(),r()}});const f=i?`${i.project}/${i.flow}`:null,y=f?(t??[]).find(O=>O.slug===f):void 0,k=(y==null?void 0:y.id)??null;m.useEffect(()=>{f&&t!==null&&(y||n())},[f,t,y,n]);const{detail:v,loading:w,refresh:g,applyDetail:M}=tnt(s,c),{runs:x,apply:b}=cnt(k),{events:C,apply:_}=int(k),{statusByNode:S,apply:$,reset:j}=hnt(k),N=m.useCallback(()=>{j(),g(),n()},[g,n,j]),A=m.useCallback(O=>{if(!k||!y)return;const P={id:k,slug:y.slug,filePath:""},I=O.valid?{...P,name:O.flow.name??y.name,flow:O.flow,valid:!0,error:null}:{...P,name:y.name,flow:null,valid:!1,error:O.error};M(I)},[k,y,M]),R=m.useCallback(O=>{b(O),_(O),$(O)},[b,_,$]);ynt(k,{onHello:N,onFlowReload:A,onEvent:R});const Y=m.useCallback(async()=>{if(!(!s||!c))try{await Dse(s,c)}catch(O){console.error("Failed to restart demo:",O)}},[s,c]),z=m.useCallback(O=>{YG(O.id),n(),r()},[n,r]),V=m.useCallback(async O=>{await a(O),await n(),s===O&&jr("/")},[a,n,s]);m.useEffect(()=>{if(e!=="/"||t===null)return;const O=gnt(t,knt());O&&jr(ore(O.slug))},[e,t]),m.useEffect(()=>{y&&YG(y.id)},[y]),m.useEffect(()=>{s&&c&&Itt(s,c)},[s,c]),m.useEffect(()=>{if(!u||!h)return;const O=Att(h,nre(u));O&&jr(ui(u,O))},[u,h]);const H=m.useCallback(O=>{!s||!c||Hse(s,c,O).catch(P=>{b({type:"node:error",nodeId:O,message:P instanceof Error?P.message:String(P),ts:Date.now()})})},[s,c,b]);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(ch,{delayDuration:150,children:p.jsxs("div",{className:"flex h-full w-full flex-col bg-background text-foreground",children:[p.jsx(ent,{projects:o??[],currentProjectSlug:s??void 0,onProjectCreated:z,onUnregisterProject:V}),p.jsx("main",{className:"min-h-0 flex-1",children:s&&c&&f?p.jsx(bot,{project:s,flow:c,slug:f,demos:t,detail:v,loading:w,runs:x,nodeEvents:C,statusByNode:S,onPlayNode:H,onRestartDemo:k?Y:void 0,refreshFlows:n}):p.jsx(Cot,{demos:t})})]})})}const Lre=document.getElementById("root");if(!Lre)throw new Error("Root element #root not found");eD.createRoot(Lre).render(p.jsx(Lr.StrictMode,{children:p.jsx(Sot,{})}));export{sf as C,eYe as M,Lr as R,ff as _,Zn as a,jX as b,yG as c,uP as d,oO as e,eY as f,PWe as g,Qh as h,TWe as i,Lot as j,ah as k,Ir as l,p as m,oY as n,fJe as o,jEe as p,MWe as q,m as r,ho as s,DWe as t,dF as u,LWe as w,Aot as z};
|