@dudousxd/nestjs-durable-dashboard 0.23.0 → 0.23.2
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/spa/assets/index-BaKLbYh4.js +23 -0
- package/dist/spa/assets/{index-BtzlEmp5.js → index-ZjDhAZOY.js} +1 -1
- package/dist/spa/assets/{preview-BcY_cOCE.js → preview-2XsIwIad.js} +1 -1
- package/dist/spa/index.html +2 -2
- package/dist/spa/preview.html +2 -2
- package/package.json +2 -2
- package/dist/spa/assets/index-zXtRhNoU.js +0 -23
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dudousxd/nestjs-durable-dashboard",
|
|
3
|
-
"version": "0.23.
|
|
3
|
+
"version": "0.23.2",
|
|
4
4
|
"description": "Embedded control plane (runs, step timeline, retry/cancel) for nestjs-durable — bundled React SPA served by NestJS",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Davide Carvalho",
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
"tsup": "8.3.5",
|
|
57
57
|
"typescript": "5.9.3",
|
|
58
58
|
"vite": "5.4.21",
|
|
59
|
-
"@dudousxd/nestjs-durable-core": "^0.
|
|
59
|
+
"@dudousxd/nestjs-durable-core": "^0.40.1"
|
|
60
60
|
},
|
|
61
61
|
"scripts": {
|
|
62
62
|
"build": "vite build && tsup && tsc -p tsconfig.client.json",
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
var kr=e=>{throw TypeError(e)};var Sn=(e,t,n)=>t.has(e)||kr("Cannot "+n);var ne=(e,t,n)=>(Sn(e,t,"read from private field"),n?n.call(e):t.get(e)),Ve=(e,t,n)=>t.has(e)?kr("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),Fe=(e,t,n,r)=>(Sn(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),Oe=(e,t,n)=>(Sn(e,t,"access private method"),n);import{S as $a,s as Ia,h as Cr,g as za,n as As,u as rr,r as M,a as Aa,b as Ta,c as Rn,i as Ts,j as h,K as Hn,X as Ke,B as Ps,d as Pa,e as pt,R as Da,C as Ds,f as Ra,k as ue,l as Ha,m as La,o as sr,p as Ba,q as Va,P as Fa,t as kn,v as Oa,Q as Xa,w as qa,x as Ya}from"./index-BtzlEmp5.js";var ze,Ae,oe,ye,Ne,Bt,Ln,zs,Wa=(zs=class extends $a{constructor(t,n){super();Ve(this,Ne);Ve(this,ze);Ve(this,Ae);Ve(this,oe);Ve(this,ye);Fe(this,ze,t),this.setOptions(n),this.bindMethods(),Oe(this,Ne,Bt).call(this)}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(t){var r;const n=this.options;this.options=ne(this,ze).defaultMutationOptions(t),Ia(this.options,n)||ne(this,ze).getMutationCache().notify({type:"observerOptionsUpdated",mutation:ne(this,oe),observer:this}),n!=null&&n.mutationKey&&this.options.mutationKey&&Cr(n.mutationKey)!==Cr(this.options.mutationKey)?this.reset():((r=ne(this,oe))==null?void 0:r.state.status)==="pending"&&ne(this,oe).setOptions(this.options)}onUnsubscribe(){var t;this.hasListeners()||(t=ne(this,oe))==null||t.removeObserver(this)}onMutationUpdate(t){Oe(this,Ne,Bt).call(this),Oe(this,Ne,Ln).call(this,t)}getCurrentResult(){return ne(this,Ae)}reset(){var t;(t=ne(this,oe))==null||t.removeObserver(this),Fe(this,oe,void 0),Oe(this,Ne,Bt).call(this),Oe(this,Ne,Ln).call(this)}mutate(t,n){var r;return Fe(this,ye,n),(r=ne(this,oe))==null||r.removeObserver(this),Fe(this,oe,ne(this,ze).getMutationCache().build(ne(this,ze),this.options)),ne(this,oe).addObserver(this),ne(this,oe).execute(t)}},ze=new WeakMap,Ae=new WeakMap,oe=new WeakMap,ye=new WeakMap,Ne=new WeakSet,Bt=function(){var n;const t=((n=ne(this,oe))==null?void 0:n.state)??za();Fe(this,Ae,{...t,isPending:t.status==="pending",isSuccess:t.status==="success",isError:t.status==="error",isIdle:t.status==="idle",mutate:this.mutate,reset:this.reset})},Ln=function(t){As.batch(()=>{var n,r,s,i,o,a,c,l;if(ne(this,ye)&&this.hasListeners()){const d=ne(this,Ae).variables,f=ne(this,Ae).context;(t==null?void 0:t.type)==="success"?((r=(n=ne(this,ye)).onSuccess)==null||r.call(n,t.data,d,f),(i=(s=ne(this,ye)).onSettled)==null||i.call(s,t.data,null,d,f)):(t==null?void 0:t.type)==="error"&&((a=(o=ne(this,ye)).onError)==null||a.call(o,t.error,d,f),(l=(c=ne(this,ye)).onSettled)==null||l.call(c,void 0,t.error,d,f))}this.listeners.forEach(d=>{d(ne(this,Ae))})})},zs);function lt(e,t){const n=rr(),[r]=M.useState(()=>new Wa(n,e));M.useEffect(()=>{r.setOptions(e)},[r,e]);const s=M.useSyncExternalStore(M.useCallback(o=>r.subscribe(As.batchCalls(o)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),i=M.useCallback((o,a)=>{r.mutate(o,a).catch(Aa)},[r]);if(s.error&&Ta(r.options.throwOnError,[s.error]))throw s.error;return{...s,mutate:i,mutateAsync:s.mutate}}function Ka(e,t){if(!e)return t;const n=new Map(e.timeline.map(r=>[r.seq,r]));return{...t,timeline:t.timeline.map(r=>{var i,o;if((r.status==="pending"||r.status==="running")&&(((i=r.events)==null?void 0:i.length)??0)===0){const a=(o=n.get(r.seq))==null?void 0:o.events;if(a!=null&&a.length)return{...r,events:a}}return r})}}function qt(e){return e<1e3?`${Math.round(e)}ms`:e<6e4?`${(e/1e3).toFixed(2)}s`:`${(e/6e4).toFixed(2)}m`}function jr(e,t){return qt(new Date(t).getTime()-new Date(e).getTime())}function Mr(e){return ir(new Date(e).getTime())}function ir(e){return new Date(e).toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit",second:"2-digit",fractionalSecondDigits:3})}const Rs={ok:"border-emerald-500/25 bg-emerald-500/10 text-emerald-300",failed:"border-red-500/25 bg-red-500/10 text-red-300",skipped:"border-amber-500/25 bg-amber-500/10 text-amber-300"},Ga={debug:"text-zinc-500",info:"text-zinc-300",warn:"text-amber-300",error:"text-red-300"},Ua=["ok","failed","skipped"];function Hs({e}){return h.jsxs("div",{className:"flex gap-2 py-0.5",children:[h.jsx("span",{className:"shrink-0 text-zinc-600 tnum",children:ir(e.at)}),h.jsx("span",{className:`shrink-0 uppercase ${Ga[e.level]}`,children:e.level}),h.jsx("span",{className:"min-w-0 break-words text-zinc-300",children:e.message})]})}function $r({sub:e,showGroup:t=!0}){var a,c;const n=((a=e.terminal)==null?void 0:a.message)!==void 0&&e.terminal.message!==e.name,r=e.phases.length>0||e.logs.length>0||n,[s,i]=M.useState(e.status==="failed"),o=e.status?Rs[e.status]:"border-amber-500/25 bg-amber-500/10 text-amber-300";return h.jsxs("li",{className:`rounded-md border ${o}`,children:[h.jsxs("button",{type:"button",disabled:!r,onClick:()=>i(l=>!l),className:"flex w-full items-center justify-between gap-2 px-2.5 py-1.5 text-left text-[11.5px] disabled:cursor-default","aria-expanded":r?s:void 0,children:[h.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[r&&h.jsx("span",{className:`text-[9px] text-zinc-500 transition-transform duration-150 ${s?"":"-rotate-90"}`,children:"▼"}),h.jsx("span",{className:"mono truncate text-zinc-200",children:e.name}),t&&e.group&&h.jsx("span",{className:"mono shrink-0 text-[10px] uppercase tracking-wider text-zinc-500",children:e.group})]}),h.jsxs("span",{className:"mono flex shrink-0 items-center gap-2 text-[10px] uppercase tracking-wider",children:[e.durationMs!==void 0&&h.jsx("span",{className:"tnum text-zinc-400",children:qt(e.durationMs)}),h.jsx("span",{children:e.status??"running"})]})]}),s&&h.jsxs("div",{className:"border-t border-[var(--line)]/60 px-2.5 py-2",children:[e.phases.length>0&&h.jsx("ul",{className:"mono mb-2 flex flex-col gap-0.5 text-[10.5px]",children:e.phases.map((l,d)=>h.jsxs("li",{className:"flex gap-2",children:[h.jsx("span",{className:"shrink-0 text-zinc-600 tnum",children:ir(l.at)}),h.jsx("span",{className:"text-zinc-400",children:l.phase}),e.startedAt!==void 0&&h.jsxs("span",{className:"text-zinc-600 tnum",children:["+",qt(l.at-e.startedAt)]})]},`${l.at}-${l.phase}-${d}`))}),((c=e.terminal)==null?void 0:c.message)&&e.terminal.message!==e.name&&h.jsx("div",{className:`mono mb-2 rounded border p-2 text-[11px] ${e.status==="failed"?"border-red-500/25 bg-red-500/10 text-red-200":"border-[var(--line)] bg-black/20 text-zinc-300"}`,children:e.terminal.message}),e.logs.length>0&&h.jsx("div",{className:"mono flex flex-col gap-0.5 text-[11px]",children:e.logs.map((l,d)=>h.jsx(Hs,{e:l},`${l.at}-${d}`))})]})]})}function Za({events:e}){const{subs:t,stepLogs:n}=Pa(e),r=Ua.map(i=>[i,t.filter(o=>o.status===i).length]).filter(([,i])=>i>0),s=t.some(i=>i.group);return h.jsxs(h.Fragment,{children:[t.length>0&&h.jsxs("section",{className:"rise",children:[h.jsxs("div",{className:"mb-1.5 flex items-center justify-between",children:[h.jsxs("span",{className:"mono text-[10px] uppercase tracking-[0.18em] text-zinc-500",children:["sub-processes · ",t.length]}),h.jsx("span",{className:"mono flex gap-2 text-[10px] uppercase tracking-wider",children:r.map(([i,o])=>h.jsxs("span",{className:Rs[i].split(" ").pop(),children:[o," ",i]},i))})]}),s?Object.entries(t.reduce((i,o)=>{const a=o.group??"—";return i[a]===void 0&&(i[a]=[]),i[a].push(o),i},{})).sort(([i],[o])=>i==="—"?1:o==="—"?-1:i.localeCompare(o)).map(([i,o])=>h.jsxs("div",{className:"mb-2",children:[h.jsx("div",{className:"mono mb-1 text-[10px] uppercase tracking-wider text-zinc-500",children:i}),h.jsx("ul",{className:"flex flex-col gap-1",children:o.map(a=>h.jsx($r,{sub:a,showGroup:!1},a.id))})]},i)):h.jsx("ul",{className:"flex flex-col gap-1",children:t.map(i=>h.jsx($r,{sub:i},i.id))})]}),n.length>0&&h.jsxs("section",{className:"rise",children:[h.jsxs("div",{className:"mono mb-1.5 text-[10px] uppercase tracking-[0.18em] text-zinc-500",children:["logs · ",n.length]}),h.jsx("div",{className:"mono max-h-64 overflow-auto rounded-lg border border-[var(--line)] bg-black/40 p-2.5 text-[11px] leading-relaxed",children:n.map((i,o)=>h.jsx(Hs,{e:i},`${i.at}-${o}`))})]})]})}function Qa({value:e}){const[t,n]=M.useState(!1);return h.jsxs("button",{type:"button",className:"flex items-center gap-1 rounded border border-[var(--line)] px-1.5 py-0.5 text-[10px] uppercase tracking-wider text-zinc-500 transition-colors hover:text-zinc-200",onClick:async()=>{try{await navigator.clipboard.writeText(e),n(!0),setTimeout(()=>n(!1),1200)}catch{}},children:[t?h.jsx(Ds,{width:11,height:11}):h.jsx(Ra,{width:11,height:11}),t?"copied":"copy"]})}function Yt({label:e,value:t}){const n=typeof t=="string"?t:JSON.stringify(t,null,2);return h.jsxs("section",{className:"rise",children:[h.jsxs("div",{className:"mb-1.5 flex items-center justify-between",children:[h.jsx("span",{className:"mono text-[10px] uppercase tracking-[0.18em] text-zinc-500",children:e}),h.jsx(Qa,{value:n})]}),h.jsx("pre",{className:"mono max-h-64 overflow-auto rounded-lg border border-[var(--line)] bg-black/40 p-3 text-[11.5px] leading-relaxed text-zinc-300",children:n})]})}function Ce({k:e,v:t,mono:n=!0}){return h.jsxs("div",{className:"flex items-baseline justify-between gap-3 py-1.5",children:[h.jsx("span",{className:"mono shrink-0 text-[10px] uppercase tracking-[0.16em] text-zinc-600",children:e}),h.jsx("span",{className:`truncate text-right text-[12px] text-zinc-200 ${n?"mono tnum":""}`,children:t})]})}function Ja({id:e,onOpenRun:t}){const{data:n}=pt({queryKey:["run",e],queryFn:()=>ue.run(e)}),[r,s]=M.useState(new Set),i=o=>s(a=>{const c=new Set(a);return c.has(o)?c.delete(o):c.add(o),c});return n?n.timeline.length===0?h.jsxs("div",{className:"mono px-2 py-2 text-[10px] text-zinc-600",children:["no steps recorded yet — child ",n.run.status]}):h.jsx("div",{className:"mt-2 max-h-80 space-y-1 overflow-auto rounded-md border border-[var(--line)] bg-black/20 p-1.5",children:h.jsx(Da,{run:n.run,timeline:n.timeline,depth:0,onSelect:()=>{},onOpenRun:t??(()=>{}),expanded:r,onToggleChild:i})}):h.jsx("div",{className:"mono px-2 py-2 text-[10px] text-zinc-600",children:"loading child run…"})}function ec({step:e,run:t,onClose:n,onOpenRun:r}){const s=Rn(e),[i,o]=M.useState(!1),a=e.status==="failed",c=e.status==="pending"||e.status==="running",l=Ts(e.kind),d=jr(t.createdAt,e.startedAt),f=e.enqueuedAt?new Date(e.startedAt).getTime()-new Date(e.enqueuedAt).getTime():0;return h.jsxs("aside",{className:"absolute inset-y-0 right-0 z-20 flex w-[380px] max-w-[90%] flex-col border-l border-[var(--line)] bg-[var(--panel)]/95 shadow-2xl backdrop-blur-md rise",children:[h.jsxs("div",{className:"flex items-start justify-between gap-3 border-b border-[var(--line)] px-5 py-4",children:[h.jsxs("div",{className:"min-w-0",children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("span",{className:`grid h-6 w-6 shrink-0 place-items-center rounded-md ${a?"bg-red-500/15 text-red-300":c?"bg-amber-500/15 text-amber-300":"bg-emerald-500/15 text-emerald-300"}`,children:h.jsx(l,{width:13,height:13})}),h.jsx("h3",{className:"truncate text-[15px] font-semibold tracking-tight text-zinc-50",children:e.name})]}),h.jsxs("div",{className:`mono mt-1 text-[11px] uppercase tracking-wider s-${e.status}`,children:[e.status," · ",Hn[e.kind]??e.kind]})]}),h.jsx("button",{type:"button",onClick:n,className:"grid h-7 w-7 shrink-0 place-items-center rounded-md border border-[var(--line)] text-zinc-500 transition-colors hover:text-zinc-200","aria-label":"Close",children:h.jsx(Ke,{})})]}),h.jsxs("div",{className:"flex min-h-0 flex-1 flex-col gap-4 overflow-auto px-5 py-4",children:[h.jsxs("div",{className:"rounded-lg border border-[var(--line)] bg-black/20 px-3.5 py-1",children:[h.jsx(Ce,{k:"seq",v:`#${e.seq}`}),f>=1&&h.jsx(Ce,{k:"queued",v:h.jsx("span",{className:"text-sky-300",children:qt(f)})}),h.jsx(Ce,{k:"duration",v:c?h.jsx("span",{className:"text-amber-300",children:"running…"}):jr(e.startedAt,e.finishedAt)}),h.jsx(Ce,{k:"attempts",v:h.jsxs("span",{className:e.attempts>1?"text-amber-300":"",children:[e.attempts>1&&h.jsx(Ps,{width:11,height:11,className:"mr-1 inline"}),e.attempts]})}),e.workerGroup&&h.jsx(Ce,{k:"worker",v:`@${e.workerGroup}`}),h.jsx(Ce,{k:"started",v:Mr(e.startedAt)}),h.jsx(Ce,{k:"finished",v:Mr(e.finishedAt)}),h.jsx(Ce,{k:"offset",v:`+${d}`})]}),a&&e.error&&h.jsxs("section",{className:"rise",children:[h.jsx("div",{className:"mono mb-1.5 text-[10px] uppercase tracking-[0.18em] text-red-400/80",children:"error"}),h.jsx("div",{className:"mono rounded-lg border border-red-500/25 bg-red-500/10 p-3 text-[11.5px] leading-relaxed text-red-200",children:e.error.message})]}),e.events&&e.events.length>0&&h.jsx(Za,{events:e.events}),s&&h.jsxs("section",{className:"rise",children:[h.jsxs("div",{className:"mb-1.5 flex items-center justify-between",children:[h.jsx("span",{className:"mono text-[10px] uppercase tracking-[0.18em] text-zinc-500",children:"child run"}),r&&h.jsx("button",{type:"button",onClick:()=>r(s),className:"mono rounded border border-[var(--line)] px-1.5 py-0.5 text-[10px] uppercase tracking-wider text-zinc-500 transition-colors hover:text-zinc-200",children:"open ↗"})]}),h.jsxs("button",{type:"button",onClick:()=>o(u=>!u),className:"flex w-full items-center gap-2 rounded-md border border-indigo-500/30 bg-indigo-500/10 px-2.5 py-1.5 text-left transition-colors hover:bg-indigo-500/20",title:i?"Collapse child run":"Expand child run inline",children:[h.jsx("span",{className:"inline-block text-[9px] text-indigo-300 transition-transform",style:{transform:i?"rotate(90deg)":"rotate(0deg)"},children:"▸"}),h.jsx("span",{className:"mono truncate text-[11px] text-indigo-300",children:s})]}),i&&h.jsx(Ja,{id:s,onOpenRun:r})]}),e.input!==void 0&&h.jsx(Yt,{label:"input",value:e.input}),e.output!==void 0&&h.jsx(Yt,{label:"output",value:e.output})]})]})}function tc({run:e,onClose:t}){const n=e.input===void 0&&e.output===void 0&&!e.error;return h.jsxs("aside",{className:"absolute inset-y-0 right-0 z-30 flex w-[380px] max-w-[90%] flex-col border-l border-[var(--line)] bg-[var(--panel)]/95 shadow-2xl backdrop-blur-md rise",children:[h.jsxs("div",{className:"flex items-start justify-between gap-3 border-b border-[var(--line)] px-5 py-4",children:[h.jsxs("div",{className:"min-w-0",children:[h.jsx("h3",{className:"truncate text-[15px] font-semibold tracking-tight text-zinc-50",children:e.workflow}),h.jsxs("div",{className:`mono mt-1 text-[11px] uppercase tracking-wider s-${e.status}`,children:["run · ",e.status]})]}),h.jsx("button",{type:"button",onClick:t,className:"grid h-7 w-7 shrink-0 place-items-center rounded-md border border-[var(--line)] text-zinc-500 transition-colors hover:text-zinc-200","aria-label":"Close",children:h.jsx(Ke,{})})]}),h.jsxs("div",{className:"flex min-h-0 flex-1 flex-col gap-4 overflow-auto px-5 py-4",children:[e.error&&h.jsxs("section",{className:"rise",children:[h.jsx("div",{className:"mono mb-1.5 text-[10px] uppercase tracking-[0.18em] text-red-400/80",children:"error"}),h.jsx("div",{className:"mono rounded-lg border border-red-500/25 bg-red-500/10 p-3 text-[11.5px] leading-relaxed text-red-200",children:e.error.message})]}),e.input!==void 0&&h.jsx(Yt,{label:"input",value:e.input}),e.output!==void 0&&h.jsx(Yt,{label:"output",value:e.output}),n&&h.jsx("div",{className:"text-sm text-zinc-600",children:"No input/output recorded."})]})]})}function se(e){if(typeof e=="string"||typeof e=="number")return""+e;let t="";if(Array.isArray(e))for(let n=0,r;n<e.length;n++)(r=se(e[n]))!==""&&(t+=(t&&" ")+r);else for(let n in e)e[n]&&(t+=(t&&" ")+n);return t}var nc={value:()=>{}};function rn(){for(var e=0,t=arguments.length,n={},r;e<t;++e){if(!(r=arguments[e]+"")||r in n||/[\s.]/.test(r))throw new Error("illegal type: "+r);n[r]=[]}return new Vt(n)}function Vt(e){this._=e}function rc(e,t){return e.trim().split(/^|\s+/).map(function(n){var r="",s=n.indexOf(".");if(s>=0&&(r=n.slice(s+1),n=n.slice(0,s)),n&&!t.hasOwnProperty(n))throw new Error("unknown type: "+n);return{type:n,name:r}})}Vt.prototype=rn.prototype={constructor:Vt,on:function(e,t){var n=this._,r=rc(e+"",n),s,i=-1,o=r.length;if(arguments.length<2){for(;++i<o;)if((s=(e=r[i]).type)&&(s=sc(n[s],e.name)))return s;return}if(t!=null&&typeof t!="function")throw new Error("invalid callback: "+t);for(;++i<o;)if(s=(e=r[i]).type)n[s]=Ir(n[s],e.name,t);else if(t==null)for(s in n)n[s]=Ir(n[s],e.name,null);return this},copy:function(){var e={},t=this._;for(var n in t)e[n]=t[n].slice();return new Vt(e)},call:function(e,t){if((s=arguments.length-2)>0)for(var n=new Array(s),r=0,s,i;r<s;++r)n[r]=arguments[r+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(i=this._[e],r=0,s=i.length;r<s;++r)i[r].value.apply(t,n)},apply:function(e,t,n){if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(var r=this._[e],s=0,i=r.length;s<i;++s)r[s].value.apply(t,n)}};function sc(e,t){for(var n=0,r=e.length,s;n<r;++n)if((s=e[n]).name===t)return s.value}function Ir(e,t,n){for(var r=0,s=e.length;r<s;++r)if(e[r].name===t){e[r]=nc,e=e.slice(0,r).concat(e.slice(r+1));break}return n!=null&&e.push({name:t,value:n}),e}var Bn="http://www.w3.org/1999/xhtml";const zr={svg:"http://www.w3.org/2000/svg",xhtml:Bn,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function sn(e){var t=e+="",n=t.indexOf(":");return n>=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),zr.hasOwnProperty(t)?{space:zr[t],local:e}:e}function ic(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===Bn&&t.documentElement.namespaceURI===Bn?t.createElement(e):t.createElementNS(n,e)}}function oc(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function Ls(e){var t=sn(e);return(t.local?oc:ic)(t)}function ac(){}function or(e){return e==null?ac:function(){return this.querySelector(e)}}function cc(e){typeof e!="function"&&(e=or(e));for(var t=this._groups,n=t.length,r=new Array(n),s=0;s<n;++s)for(var i=t[s],o=i.length,a=r[s]=new Array(o),c,l,d=0;d<o;++d)(c=i[d])&&(l=e.call(c,c.__data__,d,i))&&("__data__"in c&&(l.__data__=c.__data__),a[d]=l);return new le(r,this._parents)}function lc(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function uc(){return[]}function Bs(e){return e==null?uc:function(){return this.querySelectorAll(e)}}function dc(e){return function(){return lc(e.apply(this,arguments))}}function fc(e){typeof e=="function"?e=dc(e):e=Bs(e);for(var t=this._groups,n=t.length,r=[],s=[],i=0;i<n;++i)for(var o=t[i],a=o.length,c,l=0;l<a;++l)(c=o[l])&&(r.push(e.call(c,c.__data__,l,o)),s.push(c));return new le(r,s)}function Vs(e){return function(){return this.matches(e)}}function Fs(e){return function(t){return t.matches(e)}}var hc=Array.prototype.find;function pc(e){return function(){return hc.call(this.children,e)}}function gc(){return this.firstElementChild}function mc(e){return this.select(e==null?gc:pc(typeof e=="function"?e:Fs(e)))}var xc=Array.prototype.filter;function yc(){return Array.from(this.children)}function wc(e){return function(){return xc.call(this.children,e)}}function vc(e){return this.selectAll(e==null?yc:wc(typeof e=="function"?e:Fs(e)))}function bc(e){typeof e!="function"&&(e=Vs(e));for(var t=this._groups,n=t.length,r=new Array(n),s=0;s<n;++s)for(var i=t[s],o=i.length,a=r[s]=[],c,l=0;l<o;++l)(c=i[l])&&e.call(c,c.__data__,l,i)&&a.push(c);return new le(r,this._parents)}function Os(e){return new Array(e.length)}function Nc(){return new le(this._enter||this._groups.map(Os),this._parents)}function Wt(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}Wt.prototype={constructor:Wt,appendChild:function(e){return this._parent.insertBefore(e,this._next)},insertBefore:function(e,t){return this._parent.insertBefore(e,t)},querySelector:function(e){return this._parent.querySelector(e)},querySelectorAll:function(e){return this._parent.querySelectorAll(e)}};function _c(e){return function(){return e}}function Ec(e,t,n,r,s,i){for(var o=0,a,c=t.length,l=i.length;o<l;++o)(a=t[o])?(a.__data__=i[o],r[o]=a):n[o]=new Wt(e,i[o]);for(;o<c;++o)(a=t[o])&&(s[o]=a)}function Sc(e,t,n,r,s,i,o){var a,c,l=new Map,d=t.length,f=i.length,u=new Array(d),p;for(a=0;a<d;++a)(c=t[a])&&(u[a]=p=o.call(c,c.__data__,a,t)+"",l.has(p)?s[a]=c:l.set(p,c));for(a=0;a<f;++a)p=o.call(e,i[a],a,i)+"",(c=l.get(p))?(r[a]=c,c.__data__=i[a],l.delete(p)):n[a]=new Wt(e,i[a]);for(a=0;a<d;++a)(c=t[a])&&l.get(u[a])===c&&(s[a]=c)}function kc(e){return e.__data__}function Cc(e,t){if(!arguments.length)return Array.from(this,kc);var n=t?Sc:Ec,r=this._parents,s=this._groups;typeof e!="function"&&(e=_c(e));for(var i=s.length,o=new Array(i),a=new Array(i),c=new Array(i),l=0;l<i;++l){var d=r[l],f=s[l],u=f.length,p=jc(e.call(d,d&&d.__data__,l,r)),g=p.length,m=a[l]=new Array(g),b=o[l]=new Array(g),y=c[l]=new Array(u);n(d,f,m,b,y,p,t);for(var S=0,v=0,w,j;S<g;++S)if(w=m[S]){for(S>=v&&(v=S+1);!(j=b[v])&&++v<g;);w._next=j||null}}return o=new le(o,r),o._enter=a,o._exit=c,o}function jc(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function Mc(){return new le(this._exit||this._groups.map(Os),this._parents)}function $c(e,t,n){var r=this.enter(),s=this,i=this.exit();return typeof e=="function"?(r=e(r),r&&(r=r.selection())):r=r.append(e+""),t!=null&&(s=t(s),s&&(s=s.selection())),n==null?i.remove():n(i),r&&s?r.merge(s).order():s}function Ic(e){for(var t=e.selection?e.selection():e,n=this._groups,r=t._groups,s=n.length,i=r.length,o=Math.min(s,i),a=new Array(s),c=0;c<o;++c)for(var l=n[c],d=r[c],f=l.length,u=a[c]=new Array(f),p,g=0;g<f;++g)(p=l[g]||d[g])&&(u[g]=p);for(;c<s;++c)a[c]=n[c];return new le(a,this._parents)}function zc(){for(var e=this._groups,t=-1,n=e.length;++t<n;)for(var r=e[t],s=r.length-1,i=r[s],o;--s>=0;)(o=r[s])&&(i&&o.compareDocumentPosition(i)^4&&i.parentNode.insertBefore(o,i),i=o);return this}function Ac(e){e||(e=Tc);function t(f,u){return f&&u?e(f.__data__,u.__data__):!f-!u}for(var n=this._groups,r=n.length,s=new Array(r),i=0;i<r;++i){for(var o=n[i],a=o.length,c=s[i]=new Array(a),l,d=0;d<a;++d)(l=o[d])&&(c[d]=l);c.sort(t)}return new le(s,this._parents).order()}function Tc(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function Pc(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function Dc(){return Array.from(this)}function Rc(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],s=0,i=r.length;s<i;++s){var o=r[s];if(o)return o}return null}function Hc(){let e=0;for(const t of this)++e;return e}function Lc(){return!this.node()}function Bc(e){for(var t=this._groups,n=0,r=t.length;n<r;++n)for(var s=t[n],i=0,o=s.length,a;i<o;++i)(a=s[i])&&e.call(a,a.__data__,i,s);return this}function Vc(e){return function(){this.removeAttribute(e)}}function Fc(e){return function(){this.removeAttributeNS(e.space,e.local)}}function Oc(e,t){return function(){this.setAttribute(e,t)}}function Xc(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function qc(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function Yc(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttributeNS(e.space,e.local):this.setAttributeNS(e.space,e.local,n)}}function Wc(e,t){var n=sn(e);if(arguments.length<2){var r=this.node();return n.local?r.getAttributeNS(n.space,n.local):r.getAttribute(n)}return this.each((t==null?n.local?Fc:Vc:typeof t=="function"?n.local?Yc:qc:n.local?Xc:Oc)(n,t))}function Xs(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function Kc(e){return function(){this.style.removeProperty(e)}}function Gc(e,t,n){return function(){this.style.setProperty(e,t,n)}}function Uc(e,t,n){return function(){var r=t.apply(this,arguments);r==null?this.style.removeProperty(e):this.style.setProperty(e,r,n)}}function Zc(e,t,n){return arguments.length>1?this.each((t==null?Kc:typeof t=="function"?Uc:Gc)(e,t,n??"")):Ge(this.node(),e)}function Ge(e,t){return e.style.getPropertyValue(t)||Xs(e).getComputedStyle(e,null).getPropertyValue(t)}function Qc(e){return function(){delete this[e]}}function Jc(e,t){return function(){this[e]=t}}function el(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function tl(e,t){return arguments.length>1?this.each((t==null?Qc:typeof t=="function"?el:Jc)(e,t)):this.node()[e]}function qs(e){return e.trim().split(/^|\s+/)}function ar(e){return e.classList||new Ys(e)}function Ys(e){this._node=e,this._names=qs(e.getAttribute("class")||"")}Ys.prototype={add:function(e){var t=this._names.indexOf(e);t<0&&(this._names.push(e),this._node.setAttribute("class",this._names.join(" ")))},remove:function(e){var t=this._names.indexOf(e);t>=0&&(this._names.splice(t,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(e){return this._names.indexOf(e)>=0}};function Ws(e,t){for(var n=ar(e),r=-1,s=t.length;++r<s;)n.add(t[r])}function Ks(e,t){for(var n=ar(e),r=-1,s=t.length;++r<s;)n.remove(t[r])}function nl(e){return function(){Ws(this,e)}}function rl(e){return function(){Ks(this,e)}}function sl(e,t){return function(){(t.apply(this,arguments)?Ws:Ks)(this,e)}}function il(e,t){var n=qs(e+"");if(arguments.length<2){for(var r=ar(this.node()),s=-1,i=n.length;++s<i;)if(!r.contains(n[s]))return!1;return!0}return this.each((typeof t=="function"?sl:t?nl:rl)(n,t))}function ol(){this.textContent=""}function al(e){return function(){this.textContent=e}}function cl(e){return function(){var t=e.apply(this,arguments);this.textContent=t??""}}function ll(e){return arguments.length?this.each(e==null?ol:(typeof e=="function"?cl:al)(e)):this.node().textContent}function ul(){this.innerHTML=""}function dl(e){return function(){this.innerHTML=e}}function fl(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??""}}function hl(e){return arguments.length?this.each(e==null?ul:(typeof e=="function"?fl:dl)(e)):this.node().innerHTML}function pl(){this.nextSibling&&this.parentNode.appendChild(this)}function gl(){return this.each(pl)}function ml(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function xl(){return this.each(ml)}function yl(e){var t=typeof e=="function"?e:Ls(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function wl(){return null}function vl(e,t){var n=typeof e=="function"?e:Ls(e),r=t==null?wl:typeof t=="function"?t:or(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),r.apply(this,arguments)||null)})}function bl(){var e=this.parentNode;e&&e.removeChild(this)}function Nl(){return this.each(bl)}function _l(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function El(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Sl(e){return this.select(e?El:_l)}function kl(e){return arguments.length?this.property("__data__",e):this.node().__data__}function Cl(e){return function(t){e.call(this,t,this.__data__)}}function jl(e){return e.trim().split(/^|\s+/).map(function(t){var n="",r=t.indexOf(".");return r>=0&&(n=t.slice(r+1),t=t.slice(0,r)),{type:t,name:n}})}function Ml(e){return function(){var t=this.__on;if(t){for(var n=0,r=-1,s=t.length,i;n<s;++n)i=t[n],(!e.type||i.type===e.type)&&i.name===e.name?this.removeEventListener(i.type,i.listener,i.options):t[++r]=i;++r?t.length=r:delete this.__on}}}function $l(e,t,n){return function(){var r=this.__on,s,i=Cl(t);if(r){for(var o=0,a=r.length;o<a;++o)if((s=r[o]).type===e.type&&s.name===e.name){this.removeEventListener(s.type,s.listener,s.options),this.addEventListener(s.type,s.listener=i,s.options=n),s.value=t;return}}this.addEventListener(e.type,i,n),s={type:e.type,name:e.name,value:t,listener:i,options:n},r?r.push(s):this.__on=[s]}}function Il(e,t,n){var r=jl(e+""),s,i=r.length,o;if(arguments.length<2){var a=this.node().__on;if(a){for(var c=0,l=a.length,d;c<l;++c)for(s=0,d=a[c];s<i;++s)if((o=r[s]).type===d.type&&o.name===d.name)return d.value}return}for(a=t?$l:Ml,s=0;s<i;++s)this.each(a(r[s],t,n));return this}function Gs(e,t,n){var r=Xs(e),s=r.CustomEvent;typeof s=="function"?s=new s(t,n):(s=r.document.createEvent("Event"),n?(s.initEvent(t,n.bubbles,n.cancelable),s.detail=n.detail):s.initEvent(t,!1,!1)),e.dispatchEvent(s)}function zl(e,t){return function(){return Gs(this,e,t)}}function Al(e,t){return function(){return Gs(this,e,t.apply(this,arguments))}}function Tl(e,t){return this.each((typeof t=="function"?Al:zl)(e,t))}function*Pl(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],s=0,i=r.length,o;s<i;++s)(o=r[s])&&(yield o)}var Us=[null];function le(e,t){this._groups=e,this._parents=t}function St(){return new le([[document.documentElement]],Us)}function Dl(){return this}le.prototype=St.prototype={constructor:le,select:cc,selectAll:fc,selectChild:mc,selectChildren:vc,filter:bc,data:Cc,enter:Nc,exit:Mc,join:$c,merge:Ic,selection:Dl,order:zc,sort:Ac,call:Pc,nodes:Dc,node:Rc,size:Hc,empty:Lc,each:Bc,attr:Wc,style:Zc,property:tl,classed:il,text:ll,html:hl,raise:gl,lower:xl,append:yl,insert:vl,remove:Nl,clone:Sl,datum:kl,on:Il,dispatch:Tl,[Symbol.iterator]:Pl};function ce(e){return typeof e=="string"?new le([[document.querySelector(e)]],[document.documentElement]):new le([[e]],Us)}function Rl(e){let t;for(;t=e.sourceEvent;)e=t;return e}function de(e,t){if(e=Rl(e),t===void 0&&(t=e.currentTarget),t){var n=t.ownerSVGElement||t;if(n.createSVGPoint){var r=n.createSVGPoint();return r.x=e.clientX,r.y=e.clientY,r=r.matrixTransform(t.getScreenCTM().inverse()),[r.x,r.y]}if(t.getBoundingClientRect){var s=t.getBoundingClientRect();return[e.clientX-s.left-t.clientLeft,e.clientY-s.top-t.clientTop]}}return[e.pageX,e.pageY]}const Hl={passive:!1},gt={capture:!0,passive:!1};function Cn(e){e.stopImmediatePropagation()}function Ye(e){e.preventDefault(),e.stopImmediatePropagation()}function Zs(e){var t=e.document.documentElement,n=ce(e).on("dragstart.drag",Ye,gt);"onselectstart"in t?n.on("selectstart.drag",Ye,gt):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function Qs(e,t){var n=e.document.documentElement,r=ce(e).on("dragstart.drag",null);t&&(r.on("click.drag",Ye,gt),setTimeout(function(){r.on("click.drag",null)},0)),"onselectstart"in n?r.on("selectstart.drag",null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}const It=e=>()=>e;function Vn(e,{sourceEvent:t,subject:n,target:r,identifier:s,active:i,x:o,y:a,dx:c,dy:l,dispatch:d}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},subject:{value:n,enumerable:!0,configurable:!0},target:{value:r,enumerable:!0,configurable:!0},identifier:{value:s,enumerable:!0,configurable:!0},active:{value:i,enumerable:!0,configurable:!0},x:{value:o,enumerable:!0,configurable:!0},y:{value:a,enumerable:!0,configurable:!0},dx:{value:c,enumerable:!0,configurable:!0},dy:{value:l,enumerable:!0,configurable:!0},_:{value:d}})}Vn.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function Ll(e){return!e.ctrlKey&&!e.button}function Bl(){return this.parentNode}function Vl(e,t){return t??{x:e.x,y:e.y}}function Fl(){return navigator.maxTouchPoints||"ontouchstart"in this}function Js(){var e=Ll,t=Bl,n=Vl,r=Fl,s={},i=rn("start","drag","end"),o=0,a,c,l,d,f=0;function u(w){w.on("mousedown.drag",p).filter(r).on("touchstart.drag",b).on("touchmove.drag",y,Hl).on("touchend.drag touchcancel.drag",S).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function p(w,j){if(!(d||!e.call(this,w,j))){var P=v(this,t.call(this,w,j),w,j,"mouse");P&&(ce(w.view).on("mousemove.drag",g,gt).on("mouseup.drag",m,gt),Zs(w.view),Cn(w),l=!1,a=w.clientX,c=w.clientY,P("start",w))}}function g(w){if(Ye(w),!l){var j=w.clientX-a,P=w.clientY-c;l=j*j+P*P>f}s.mouse("drag",w)}function m(w){ce(w.view).on("mousemove.drag mouseup.drag",null),Qs(w.view,l),Ye(w),s.mouse("end",w)}function b(w,j){if(e.call(this,w,j)){var P=w.changedTouches,k=t.call(this,w,j),$=P.length,z,T;for(z=0;z<$;++z)(T=v(this,k,w,j,P[z].identifier,P[z]))&&(Cn(w),T("start",w,P[z]))}}function y(w){var j=w.changedTouches,P=j.length,k,$;for(k=0;k<P;++k)($=s[j[k].identifier])&&(Ye(w),$("drag",w,j[k]))}function S(w){var j=w.changedTouches,P=j.length,k,$;for(d&&clearTimeout(d),d=setTimeout(function(){d=null},500),k=0;k<P;++k)($=s[j[k].identifier])&&(Cn(w),$("end",w,j[k]))}function v(w,j,P,k,$,z){var T=i.copy(),H=de(z||P,j),L,D,x;if((x=n.call(w,new Vn("beforestart",{sourceEvent:P,target:u,identifier:$,active:o,x:H[0],y:H[1],dx:0,dy:0,dispatch:T}),k))!=null)return L=x.x-H[0]||0,D=x.y-H[1]||0,function C(_,I,N){var E=H,A;switch(_){case"start":s[$]=C,A=o++;break;case"end":delete s[$],--o;case"drag":H=de(N||I,j),A=o;break}T.call(_,w,new Vn(_,{sourceEvent:I,subject:x,target:u,identifier:$,active:A,x:H[0]+L,y:H[1]+D,dx:H[0]-E[0],dy:H[1]-E[1],dispatch:T}),k)}}return u.filter=function(w){return arguments.length?(e=typeof w=="function"?w:It(!!w),u):e},u.container=function(w){return arguments.length?(t=typeof w=="function"?w:It(w),u):t},u.subject=function(w){return arguments.length?(n=typeof w=="function"?w:It(w),u):n},u.touchable=function(w){return arguments.length?(r=typeof w=="function"?w:It(!!w),u):r},u.on=function(){var w=i.on.apply(i,arguments);return w===i?u:w},u.clickDistance=function(w){return arguments.length?(f=(w=+w)*w,u):Math.sqrt(f)},u}function cr(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function ei(e,t){var n=Object.create(e.prototype);for(var r in t)n[r]=t[r];return n}function kt(){}var mt=.7,Kt=1/mt,We="\\s*([+-]?\\d+)\\s*",xt="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",ge="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",Ol=/^#([0-9a-f]{3,8})$/,Xl=new RegExp(`^rgb\\(${We},${We},${We}\\)$`),ql=new RegExp(`^rgb\\(${ge},${ge},${ge}\\)$`),Yl=new RegExp(`^rgba\\(${We},${We},${We},${xt}\\)$`),Wl=new RegExp(`^rgba\\(${ge},${ge},${ge},${xt}\\)$`),Kl=new RegExp(`^hsl\\(${xt},${ge},${ge}\\)$`),Gl=new RegExp(`^hsla\\(${xt},${ge},${ge},${xt}\\)$`),Ar={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};cr(kt,yt,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:Tr,formatHex:Tr,formatHex8:Ul,formatHsl:Zl,formatRgb:Pr,toString:Pr});function Tr(){return this.rgb().formatHex()}function Ul(){return this.rgb().formatHex8()}function Zl(){return ti(this).formatHsl()}function Pr(){return this.rgb().formatRgb()}function yt(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=Ol.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?Dr(t):n===3?new ae(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?zt(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?zt(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|t&240,((t&15)<<4|t&15)/255):null):(t=Xl.exec(e))?new ae(t[1],t[2],t[3],1):(t=ql.exec(e))?new ae(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=Yl.exec(e))?zt(t[1],t[2],t[3],t[4]):(t=Wl.exec(e))?zt(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=Kl.exec(e))?Lr(t[1],t[2]/100,t[3]/100,1):(t=Gl.exec(e))?Lr(t[1],t[2]/100,t[3]/100,t[4]):Ar.hasOwnProperty(e)?Dr(Ar[e]):e==="transparent"?new ae(NaN,NaN,NaN,0):null}function Dr(e){return new ae(e>>16&255,e>>8&255,e&255,1)}function zt(e,t,n,r){return r<=0&&(e=t=n=NaN),new ae(e,t,n,r)}function Ql(e){return e instanceof kt||(e=yt(e)),e?(e=e.rgb(),new ae(e.r,e.g,e.b,e.opacity)):new ae}function Fn(e,t,n,r){return arguments.length===1?Ql(e):new ae(e,t,n,r??1)}function ae(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}cr(ae,Fn,ei(kt,{brighter(e){return e=e==null?Kt:Math.pow(Kt,e),new ae(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?mt:Math.pow(mt,e),new ae(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new ae(Re(this.r),Re(this.g),Re(this.b),Gt(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:Rr,formatHex:Rr,formatHex8:Jl,formatRgb:Hr,toString:Hr}));function Rr(){return`#${De(this.r)}${De(this.g)}${De(this.b)}`}function Jl(){return`#${De(this.r)}${De(this.g)}${De(this.b)}${De((isNaN(this.opacity)?1:this.opacity)*255)}`}function Hr(){const e=Gt(this.opacity);return`${e===1?"rgb(":"rgba("}${Re(this.r)}, ${Re(this.g)}, ${Re(this.b)}${e===1?")":`, ${e})`}`}function Gt(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function Re(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function De(e){return e=Re(e),(e<16?"0":"")+e.toString(16)}function Lr(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new fe(e,t,n,r)}function ti(e){if(e instanceof fe)return new fe(e.h,e.s,e.l,e.opacity);if(e instanceof kt||(e=yt(e)),!e)return new fe;if(e instanceof fe)return e;e=e.rgb();var t=e.r/255,n=e.g/255,r=e.b/255,s=Math.min(t,n,r),i=Math.max(t,n,r),o=NaN,a=i-s,c=(i+s)/2;return a?(t===i?o=(n-r)/a+(n<r)*6:n===i?o=(r-t)/a+2:o=(t-n)/a+4,a/=c<.5?i+s:2-i-s,o*=60):a=c>0&&c<1?0:o,new fe(o,a,c,e.opacity)}function eu(e,t,n,r){return arguments.length===1?ti(e):new fe(e,t,n,r??1)}function fe(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}cr(fe,eu,ei(kt,{brighter(e){return e=e==null?Kt:Math.pow(Kt,e),new fe(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?mt:Math.pow(mt,e),new fe(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,n=this.l,r=n+(n<.5?n:1-n)*t,s=2*n-r;return new ae(jn(e>=240?e-240:e+120,s,r),jn(e,s,r),jn(e<120?e+240:e-120,s,r),this.opacity)},clamp(){return new fe(Br(this.h),At(this.s),At(this.l),Gt(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const e=Gt(this.opacity);return`${e===1?"hsl(":"hsla("}${Br(this.h)}, ${At(this.s)*100}%, ${At(this.l)*100}%${e===1?")":`, ${e})`}`}}));function Br(e){return e=(e||0)%360,e<0?e+360:e}function At(e){return Math.max(0,Math.min(1,e||0))}function jn(e,t,n){return(e<60?t+(n-t)*e/60:e<180?n:e<240?t+(n-t)*(240-e)/60:t)*255}const ni=e=>()=>e;function tu(e,t){return function(n){return e+n*t}}function nu(e,t,n){return e=Math.pow(e,n),t=Math.pow(t,n)-e,n=1/n,function(r){return Math.pow(e+r*t,n)}}function ru(e){return(e=+e)==1?ri:function(t,n){return n-t?nu(t,n,e):ni(isNaN(t)?n:t)}}function ri(e,t){var n=t-e;return n?tu(e,n):ni(isNaN(e)?t:e)}const Vr=function e(t){var n=ru(t);function r(s,i){var o=n((s=Fn(s)).r,(i=Fn(i)).r),a=n(s.g,i.g),c=n(s.b,i.b),l=ri(s.opacity,i.opacity);return function(d){return s.r=o(d),s.g=a(d),s.b=c(d),s.opacity=l(d),s+""}}return r.gamma=e,r}(1);function $e(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}var On=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Mn=new RegExp(On.source,"g");function su(e){return function(){return e}}function iu(e){return function(t){return e(t)+""}}function ou(e,t){var n=On.lastIndex=Mn.lastIndex=0,r,s,i,o=-1,a=[],c=[];for(e=e+"",t=t+"";(r=On.exec(e))&&(s=Mn.exec(t));)(i=s.index)>n&&(i=t.slice(n,i),a[o]?a[o]+=i:a[++o]=i),(r=r[0])===(s=s[0])?a[o]?a[o]+=s:a[++o]=s:(a[++o]=null,c.push({i:o,x:$e(r,s)})),n=Mn.lastIndex;return n<t.length&&(i=t.slice(n),a[o]?a[o]+=i:a[++o]=i),a.length<2?c[0]?iu(c[0].x):su(t):(t=c.length,function(l){for(var d=0,f;d<t;++d)a[(f=c[d]).i]=f.x(l);return a.join("")})}var Fr=180/Math.PI,Xn={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function si(e,t,n,r,s,i){var o,a,c;return(o=Math.sqrt(e*e+t*t))&&(e/=o,t/=o),(c=e*n+t*r)&&(n-=e*c,r-=t*c),(a=Math.sqrt(n*n+r*r))&&(n/=a,r/=a,c/=a),e*r<t*n&&(e=-e,t=-t,c=-c,o=-o),{translateX:s,translateY:i,rotate:Math.atan2(t,e)*Fr,skewX:Math.atan(c)*Fr,scaleX:o,scaleY:a}}var Tt;function au(e){const t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?Xn:si(t.a,t.b,t.c,t.d,t.e,t.f)}function cu(e){return e==null||(Tt||(Tt=document.createElementNS("http://www.w3.org/2000/svg","g")),Tt.setAttribute("transform",e),!(e=Tt.transform.baseVal.consolidate()))?Xn:(e=e.matrix,si(e.a,e.b,e.c,e.d,e.e,e.f))}function ii(e,t,n,r){function s(l){return l.length?l.pop()+" ":""}function i(l,d,f,u,p,g){if(l!==f||d!==u){var m=p.push("translate(",null,t,null,n);g.push({i:m-4,x:$e(l,f)},{i:m-2,x:$e(d,u)})}else(f||u)&&p.push("translate("+f+t+u+n)}function o(l,d,f,u){l!==d?(l-d>180?d+=360:d-l>180&&(l+=360),u.push({i:f.push(s(f)+"rotate(",null,r)-2,x:$e(l,d)})):d&&f.push(s(f)+"rotate("+d+r)}function a(l,d,f,u){l!==d?u.push({i:f.push(s(f)+"skewX(",null,r)-2,x:$e(l,d)}):d&&f.push(s(f)+"skewX("+d+r)}function c(l,d,f,u,p,g){if(l!==f||d!==u){var m=p.push(s(p)+"scale(",null,",",null,")");g.push({i:m-4,x:$e(l,f)},{i:m-2,x:$e(d,u)})}else(f!==1||u!==1)&&p.push(s(p)+"scale("+f+","+u+")")}return function(l,d){var f=[],u=[];return l=e(l),d=e(d),i(l.translateX,l.translateY,d.translateX,d.translateY,f,u),o(l.rotate,d.rotate,f,u),a(l.skewX,d.skewX,f,u),c(l.scaleX,l.scaleY,d.scaleX,d.scaleY,f,u),l=d=null,function(p){for(var g=-1,m=u.length,b;++g<m;)f[(b=u[g]).i]=b.x(p);return f.join("")}}}var lu=ii(au,"px, ","px)","deg)"),uu=ii(cu,", ",")",")"),du=1e-12;function Or(e){return((e=Math.exp(e))+1/e)/2}function fu(e){return((e=Math.exp(e))-1/e)/2}function hu(e){return((e=Math.exp(2*e))-1)/(e+1)}const pu=function e(t,n,r){function s(i,o){var a=i[0],c=i[1],l=i[2],d=o[0],f=o[1],u=o[2],p=d-a,g=f-c,m=p*p+g*g,b,y;if(m<du)y=Math.log(u/l)/t,b=function(k){return[a+k*p,c+k*g,l*Math.exp(t*k*y)]};else{var S=Math.sqrt(m),v=(u*u-l*l+r*m)/(2*l*n*S),w=(u*u-l*l-r*m)/(2*u*n*S),j=Math.log(Math.sqrt(v*v+1)-v),P=Math.log(Math.sqrt(w*w+1)-w);y=(P-j)/t,b=function(k){var $=k*y,z=Or(j),T=l/(n*S)*(z*hu(t*$+j)-fu(j));return[a+T*p,c+T*g,l*z/Or(t*$+j)]}}return b.duration=y*1e3*t/Math.SQRT2,b}return s.rho=function(i){var o=Math.max(.001,+i),a=o*o,c=a*a;return e(o,a,c)},s}(Math.SQRT2,2,4);var Ue=0,ut=0,at=0,oi=1e3,Ut,dt,Zt=0,Le=0,on=0,wt=typeof performance=="object"&&performance.now?performance:Date,ai=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function lr(){return Le||(ai(gu),Le=wt.now()+on)}function gu(){Le=0}function Qt(){this._call=this._time=this._next=null}Qt.prototype=ci.prototype={constructor:Qt,restart:function(e,t,n){if(typeof e!="function")throw new TypeError("callback is not a function");n=(n==null?lr():+n)+(t==null?0:+t),!this._next&&dt!==this&&(dt?dt._next=this:Ut=this,dt=this),this._call=e,this._time=n,qn()},stop:function(){this._call&&(this._call=null,this._time=1/0,qn())}};function ci(e,t,n){var r=new Qt;return r.restart(e,t,n),r}function mu(){lr(),++Ue;for(var e=Ut,t;e;)(t=Le-e._time)>=0&&e._call.call(void 0,t),e=e._next;--Ue}function Xr(){Le=(Zt=wt.now())+on,Ue=ut=0;try{mu()}finally{Ue=0,yu(),Le=0}}function xu(){var e=wt.now(),t=e-Zt;t>oi&&(on-=t,Zt=e)}function yu(){for(var e,t=Ut,n,r=1/0;t;)t._call?(r>t._time&&(r=t._time),e=t,t=t._next):(n=t._next,t._next=null,t=e?e._next=n:Ut=n);dt=e,qn(r)}function qn(e){if(!Ue){ut&&(ut=clearTimeout(ut));var t=e-Le;t>24?(e<1/0&&(ut=setTimeout(Xr,e-wt.now()-on)),at&&(at=clearInterval(at))):(at||(Zt=wt.now(),at=setInterval(xu,oi)),Ue=1,ai(Xr))}}function qr(e,t,n){var r=new Qt;return t=t==null?0:+t,r.restart(s=>{r.stop(),e(s+t)},t,n),r}var wu=rn("start","end","cancel","interrupt"),vu=[],li=0,Yr=1,Yn=2,Ft=3,Wr=4,Wn=5,Ot=6;function an(e,t,n,r,s,i){var o=e.__transition;if(!o)e.__transition={};else if(n in o)return;bu(e,n,{name:t,index:r,group:s,on:wu,tween:vu,time:i.time,delay:i.delay,duration:i.duration,ease:i.ease,timer:null,state:li})}function ur(e,t){var n=pe(e,t);if(n.state>li)throw new Error("too late; already scheduled");return n}function me(e,t){var n=pe(e,t);if(n.state>Ft)throw new Error("too late; already running");return n}function pe(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function bu(e,t,n){var r=e.__transition,s;r[t]=n,n.timer=ci(i,0,n.time);function i(l){n.state=Yr,n.timer.restart(o,n.delay,n.time),n.delay<=l&&o(l-n.delay)}function o(l){var d,f,u,p;if(n.state!==Yr)return c();for(d in r)if(p=r[d],p.name===n.name){if(p.state===Ft)return qr(o);p.state===Wr?(p.state=Ot,p.timer.stop(),p.on.call("interrupt",e,e.__data__,p.index,p.group),delete r[d]):+d<t&&(p.state=Ot,p.timer.stop(),p.on.call("cancel",e,e.__data__,p.index,p.group),delete r[d])}if(qr(function(){n.state===Ft&&(n.state=Wr,n.timer.restart(a,n.delay,n.time),a(l))}),n.state=Yn,n.on.call("start",e,e.__data__,n.index,n.group),n.state===Yn){for(n.state=Ft,s=new Array(u=n.tween.length),d=0,f=-1;d<u;++d)(p=n.tween[d].value.call(e,e.__data__,n.index,n.group))&&(s[++f]=p);s.length=f+1}}function a(l){for(var d=l<n.duration?n.ease.call(null,l/n.duration):(n.timer.restart(c),n.state=Wn,1),f=-1,u=s.length;++f<u;)s[f].call(e,d);n.state===Wn&&(n.on.call("end",e,e.__data__,n.index,n.group),c())}function c(){n.state=Ot,n.timer.stop(),delete r[t];for(var l in r)return;delete e.__transition}}function Xt(e,t){var n=e.__transition,r,s,i=!0,o;if(n){t=t==null?null:t+"";for(o in n){if((r=n[o]).name!==t){i=!1;continue}s=r.state>Yn&&r.state<Wn,r.state=Ot,r.timer.stop(),r.on.call(s?"interrupt":"cancel",e,e.__data__,r.index,r.group),delete n[o]}i&&delete e.__transition}}function Nu(e){return this.each(function(){Xt(this,e)})}function _u(e,t){var n,r;return function(){var s=me(this,e),i=s.tween;if(i!==n){r=n=i;for(var o=0,a=r.length;o<a;++o)if(r[o].name===t){r=r.slice(),r.splice(o,1);break}}s.tween=r}}function Eu(e,t,n){var r,s;if(typeof n!="function")throw new Error;return function(){var i=me(this,e),o=i.tween;if(o!==r){s=(r=o).slice();for(var a={name:t,value:n},c=0,l=s.length;c<l;++c)if(s[c].name===t){s[c]=a;break}c===l&&s.push(a)}i.tween=s}}function Su(e,t){var n=this._id;if(e+="",arguments.length<2){for(var r=pe(this.node(),n).tween,s=0,i=r.length,o;s<i;++s)if((o=r[s]).name===e)return o.value;return null}return this.each((t==null?_u:Eu)(n,e,t))}function dr(e,t,n){var r=e._id;return e.each(function(){var s=me(this,r);(s.value||(s.value={}))[t]=n.apply(this,arguments)}),function(s){return pe(s,r).value[t]}}function ui(e,t){var n;return(typeof t=="number"?$e:t instanceof yt?Vr:(n=yt(t))?(t=n,Vr):ou)(e,t)}function ku(e){return function(){this.removeAttribute(e)}}function Cu(e){return function(){this.removeAttributeNS(e.space,e.local)}}function ju(e,t,n){var r,s=n+"",i;return function(){var o=this.getAttribute(e);return o===s?null:o===r?i:i=t(r=o,n)}}function Mu(e,t,n){var r,s=n+"",i;return function(){var o=this.getAttributeNS(e.space,e.local);return o===s?null:o===r?i:i=t(r=o,n)}}function $u(e,t,n){var r,s,i;return function(){var o,a=n(this),c;return a==null?void this.removeAttribute(e):(o=this.getAttribute(e),c=a+"",o===c?null:o===r&&c===s?i:(s=c,i=t(r=o,a)))}}function Iu(e,t,n){var r,s,i;return function(){var o,a=n(this),c;return a==null?void this.removeAttributeNS(e.space,e.local):(o=this.getAttributeNS(e.space,e.local),c=a+"",o===c?null:o===r&&c===s?i:(s=c,i=t(r=o,a)))}}function zu(e,t){var n=sn(e),r=n==="transform"?uu:ui;return this.attrTween(e,typeof t=="function"?(n.local?Iu:$u)(n,r,dr(this,"attr."+e,t)):t==null?(n.local?Cu:ku)(n):(n.local?Mu:ju)(n,r,t))}function Au(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function Tu(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function Pu(e,t){var n,r;function s(){var i=t.apply(this,arguments);return i!==r&&(n=(r=i)&&Tu(e,i)),n}return s._value=t,s}function Du(e,t){var n,r;function s(){var i=t.apply(this,arguments);return i!==r&&(n=(r=i)&&Au(e,i)),n}return s._value=t,s}function Ru(e,t){var n="attr."+e;if(arguments.length<2)return(n=this.tween(n))&&n._value;if(t==null)return this.tween(n,null);if(typeof t!="function")throw new Error;var r=sn(e);return this.tween(n,(r.local?Pu:Du)(r,t))}function Hu(e,t){return function(){ur(this,e).delay=+t.apply(this,arguments)}}function Lu(e,t){return t=+t,function(){ur(this,e).delay=t}}function Bu(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?Hu:Lu)(t,e)):pe(this.node(),t).delay}function Vu(e,t){return function(){me(this,e).duration=+t.apply(this,arguments)}}function Fu(e,t){return t=+t,function(){me(this,e).duration=t}}function Ou(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?Vu:Fu)(t,e)):pe(this.node(),t).duration}function Xu(e,t){if(typeof t!="function")throw new Error;return function(){me(this,e).ease=t}}function qu(e){var t=this._id;return arguments.length?this.each(Xu(t,e)):pe(this.node(),t).ease}function Yu(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!="function")throw new Error;me(this,e).ease=n}}function Wu(e){if(typeof e!="function")throw new Error;return this.each(Yu(this._id,e))}function Ku(e){typeof e!="function"&&(e=Vs(e));for(var t=this._groups,n=t.length,r=new Array(n),s=0;s<n;++s)for(var i=t[s],o=i.length,a=r[s]=[],c,l=0;l<o;++l)(c=i[l])&&e.call(c,c.__data__,l,i)&&a.push(c);return new _e(r,this._parents,this._name,this._id)}function Gu(e){if(e._id!==this._id)throw new Error;for(var t=this._groups,n=e._groups,r=t.length,s=n.length,i=Math.min(r,s),o=new Array(r),a=0;a<i;++a)for(var c=t[a],l=n[a],d=c.length,f=o[a]=new Array(d),u,p=0;p<d;++p)(u=c[p]||l[p])&&(f[p]=u);for(;a<r;++a)o[a]=t[a];return new _e(o,this._parents,this._name,this._id)}function Uu(e){return(e+"").trim().split(/^|\s+/).every(function(t){var n=t.indexOf(".");return n>=0&&(t=t.slice(0,n)),!t||t==="start"})}function Zu(e,t,n){var r,s,i=Uu(t)?ur:me;return function(){var o=i(this,e),a=o.on;a!==r&&(s=(r=a).copy()).on(t,n),o.on=s}}function Qu(e,t){var n=this._id;return arguments.length<2?pe(this.node(),n).on.on(e):this.each(Zu(n,e,t))}function Ju(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function ed(){return this.on("end.remove",Ju(this._id))}function td(e){var t=this._name,n=this._id;typeof e!="function"&&(e=or(e));for(var r=this._groups,s=r.length,i=new Array(s),o=0;o<s;++o)for(var a=r[o],c=a.length,l=i[o]=new Array(c),d,f,u=0;u<c;++u)(d=a[u])&&(f=e.call(d,d.__data__,u,a))&&("__data__"in d&&(f.__data__=d.__data__),l[u]=f,an(l[u],t,n,u,l,pe(d,n)));return new _e(i,this._parents,t,n)}function nd(e){var t=this._name,n=this._id;typeof e!="function"&&(e=Bs(e));for(var r=this._groups,s=r.length,i=[],o=[],a=0;a<s;++a)for(var c=r[a],l=c.length,d,f=0;f<l;++f)if(d=c[f]){for(var u=e.call(d,d.__data__,f,c),p,g=pe(d,n),m=0,b=u.length;m<b;++m)(p=u[m])&&an(p,t,n,m,u,g);i.push(u),o.push(d)}return new _e(i,o,t,n)}var rd=St.prototype.constructor;function sd(){return new rd(this._groups,this._parents)}function id(e,t){var n,r,s;return function(){var i=Ge(this,e),o=(this.style.removeProperty(e),Ge(this,e));return i===o?null:i===n&&o===r?s:s=t(n=i,r=o)}}function di(e){return function(){this.style.removeProperty(e)}}function od(e,t,n){var r,s=n+"",i;return function(){var o=Ge(this,e);return o===s?null:o===r?i:i=t(r=o,n)}}function ad(e,t,n){var r,s,i;return function(){var o=Ge(this,e),a=n(this),c=a+"";return a==null&&(c=a=(this.style.removeProperty(e),Ge(this,e))),o===c?null:o===r&&c===s?i:(s=c,i=t(r=o,a))}}function cd(e,t){var n,r,s,i="style."+t,o="end."+i,a;return function(){var c=me(this,e),l=c.on,d=c.value[i]==null?a||(a=di(t)):void 0;(l!==n||s!==d)&&(r=(n=l).copy()).on(o,s=d),c.on=r}}function ld(e,t,n){var r=(e+="")=="transform"?lu:ui;return t==null?this.styleTween(e,id(e,r)).on("end.style."+e,di(e)):typeof t=="function"?this.styleTween(e,ad(e,r,dr(this,"style."+e,t))).each(cd(this._id,e)):this.styleTween(e,od(e,r,t),n).on("end.style."+e,null)}function ud(e,t,n){return function(r){this.style.setProperty(e,t.call(this,r),n)}}function dd(e,t,n){var r,s;function i(){var o=t.apply(this,arguments);return o!==s&&(r=(s=o)&&ud(e,o,n)),r}return i._value=t,i}function fd(e,t,n){var r="style."+(e+="");if(arguments.length<2)return(r=this.tween(r))&&r._value;if(t==null)return this.tween(r,null);if(typeof t!="function")throw new Error;return this.tween(r,dd(e,t,n??""))}function hd(e){return function(){this.textContent=e}}function pd(e){return function(){var t=e(this);this.textContent=t??""}}function gd(e){return this.tween("text",typeof e=="function"?pd(dr(this,"text",e)):hd(e==null?"":e+""))}function md(e){return function(t){this.textContent=e.call(this,t)}}function xd(e){var t,n;function r(){var s=e.apply(this,arguments);return s!==n&&(t=(n=s)&&md(s)),t}return r._value=e,r}function yd(e){var t="text";if(arguments.length<1)return(t=this.tween(t))&&t._value;if(e==null)return this.tween(t,null);if(typeof e!="function")throw new Error;return this.tween(t,xd(e))}function wd(){for(var e=this._name,t=this._id,n=fi(),r=this._groups,s=r.length,i=0;i<s;++i)for(var o=r[i],a=o.length,c,l=0;l<a;++l)if(c=o[l]){var d=pe(c,t);an(c,e,n,l,o,{time:d.time+d.delay+d.duration,delay:0,duration:d.duration,ease:d.ease})}return new _e(r,this._parents,e,n)}function vd(){var e,t,n=this,r=n._id,s=n.size();return new Promise(function(i,o){var a={value:o},c={value:function(){--s===0&&i()}};n.each(function(){var l=me(this,r),d=l.on;d!==e&&(t=(e=d).copy(),t._.cancel.push(a),t._.interrupt.push(a),t._.end.push(c)),l.on=t}),s===0&&i()})}var bd=0;function _e(e,t,n,r){this._groups=e,this._parents=t,this._name=n,this._id=r}function fi(){return++bd}var xe=St.prototype;_e.prototype={constructor:_e,select:td,selectAll:nd,selectChild:xe.selectChild,selectChildren:xe.selectChildren,filter:Ku,merge:Gu,selection:sd,transition:wd,call:xe.call,nodes:xe.nodes,node:xe.node,size:xe.size,empty:xe.empty,each:xe.each,on:Qu,attr:zu,attrTween:Ru,style:ld,styleTween:fd,text:gd,textTween:yd,remove:ed,tween:Su,delay:Bu,duration:Ou,ease:qu,easeVarying:Wu,end:vd,[Symbol.iterator]:xe[Symbol.iterator]};function Nd(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var _d={time:null,delay:0,duration:250,ease:Nd};function Ed(e,t){for(var n;!(n=e.__transition)||!(n=n[t]);)if(!(e=e.parentNode))throw new Error(`transition ${t} not found`);return n}function Sd(e){var t,n;e instanceof _e?(t=e._id,e=e._name):(t=fi(),(n=_d).time=lr(),e=e==null?null:e+"");for(var r=this._groups,s=r.length,i=0;i<s;++i)for(var o=r[i],a=o.length,c,l=0;l<a;++l)(c=o[l])&&an(c,e,t,l,o,n||Ed(c,t));return new _e(r,this._parents,e,t)}St.prototype.interrupt=Nu;St.prototype.transition=Sd;const Pt=e=>()=>e;function kd(e,{sourceEvent:t,target:n,transform:r,dispatch:s}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:r,enumerable:!0,configurable:!0},_:{value:s}})}function we(e,t,n){this.k=e,this.x=t,this.y=n}we.prototype={constructor:we,scale:function(e){return e===1?this:new we(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new we(this.k,this.x+this.k*e,this.y+this.k*t)},apply:function(e){return[e[0]*this.k+this.x,e[1]*this.k+this.y]},applyX:function(e){return e*this.k+this.x},applyY:function(e){return e*this.k+this.y},invert:function(e){return[(e[0]-this.x)/this.k,(e[1]-this.y)/this.k]},invertX:function(e){return(e-this.x)/this.k},invertY:function(e){return(e-this.y)/this.k},rescaleX:function(e){return e.copy().domain(e.range().map(this.invertX,this).map(e.invert,e))},rescaleY:function(e){return e.copy().domain(e.range().map(this.invertY,this).map(e.invert,e))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var cn=new we(1,0,0);hi.prototype=we.prototype;function hi(e){for(;!e.__zoom;)if(!(e=e.parentNode))return cn;return e.__zoom}function $n(e){e.stopImmediatePropagation()}function ct(e){e.preventDefault(),e.stopImmediatePropagation()}function Cd(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function jd(){var e=this;return e instanceof SVGElement?(e=e.ownerSVGElement||e,e.hasAttribute("viewBox")?(e=e.viewBox.baseVal,[[e.x,e.y],[e.x+e.width,e.y+e.height]]):[[0,0],[e.width.baseVal.value,e.height.baseVal.value]]):[[0,0],[e.clientWidth,e.clientHeight]]}function Kr(){return this.__zoom||cn}function Md(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function $d(){return navigator.maxTouchPoints||"ontouchstart"in this}function Id(e,t,n){var r=e.invertX(t[0][0])-n[0][0],s=e.invertX(t[1][0])-n[1][0],i=e.invertY(t[0][1])-n[0][1],o=e.invertY(t[1][1])-n[1][1];return e.translate(s>r?(r+s)/2:Math.min(0,r)||Math.max(0,s),o>i?(i+o)/2:Math.min(0,i)||Math.max(0,o))}function pi(){var e=Cd,t=jd,n=Id,r=Md,s=$d,i=[0,1/0],o=[[-1/0,-1/0],[1/0,1/0]],a=250,c=pu,l=rn("start","zoom","end"),d,f,u,p=500,g=150,m=0,b=10;function y(x){x.property("__zoom",Kr).on("wheel.zoom",$,{passive:!1}).on("mousedown.zoom",z).on("dblclick.zoom",T).filter(s).on("touchstart.zoom",H).on("touchmove.zoom",L).on("touchend.zoom touchcancel.zoom",D).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}y.transform=function(x,C,_,I){var N=x.selection?x.selection():x;N.property("__zoom",Kr),x!==N?j(x,C,_,I):N.interrupt().each(function(){P(this,arguments).event(I).start().zoom(null,typeof C=="function"?C.apply(this,arguments):C).end()})},y.scaleBy=function(x,C,_,I){y.scaleTo(x,function(){var N=this.__zoom.k,E=typeof C=="function"?C.apply(this,arguments):C;return N*E},_,I)},y.scaleTo=function(x,C,_,I){y.transform(x,function(){var N=t.apply(this,arguments),E=this.__zoom,A=_==null?w(N):typeof _=="function"?_.apply(this,arguments):_,R=E.invert(A),B=typeof C=="function"?C.apply(this,arguments):C;return n(v(S(E,B),A,R),N,o)},_,I)},y.translateBy=function(x,C,_,I){y.transform(x,function(){return n(this.__zoom.translate(typeof C=="function"?C.apply(this,arguments):C,typeof _=="function"?_.apply(this,arguments):_),t.apply(this,arguments),o)},null,I)},y.translateTo=function(x,C,_,I,N){y.transform(x,function(){var E=t.apply(this,arguments),A=this.__zoom,R=I==null?w(E):typeof I=="function"?I.apply(this,arguments):I;return n(cn.translate(R[0],R[1]).scale(A.k).translate(typeof C=="function"?-C.apply(this,arguments):-C,typeof _=="function"?-_.apply(this,arguments):-_),E,o)},I,N)};function S(x,C){return C=Math.max(i[0],Math.min(i[1],C)),C===x.k?x:new we(C,x.x,x.y)}function v(x,C,_){var I=C[0]-_[0]*x.k,N=C[1]-_[1]*x.k;return I===x.x&&N===x.y?x:new we(x.k,I,N)}function w(x){return[(+x[0][0]+ +x[1][0])/2,(+x[0][1]+ +x[1][1])/2]}function j(x,C,_,I){x.on("start.zoom",function(){P(this,arguments).event(I).start()}).on("interrupt.zoom end.zoom",function(){P(this,arguments).event(I).end()}).tween("zoom",function(){var N=this,E=arguments,A=P(N,E).event(I),R=t.apply(N,E),B=_==null?w(R):typeof _=="function"?_.apply(N,E):_,q=Math.max(R[1][0]-R[0][0],R[1][1]-R[0][1]),F=N.__zoom,O=typeof C=="function"?C.apply(N,E):C,Y=c(F.invert(B).concat(q/F.k),O.invert(B).concat(q/O.k));return function(K){if(K===1)K=O;else{var V=Y(K),G=q/V[2];K=new we(G,B[0]-V[0]*G,B[1]-V[1]*G)}A.zoom(null,K)}})}function P(x,C,_){return!_&&x.__zooming||new k(x,C)}function k(x,C){this.that=x,this.args=C,this.active=0,this.sourceEvent=null,this.extent=t.apply(x,C),this.taps=0}k.prototype={event:function(x){return x&&(this.sourceEvent=x),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(x,C){return this.mouse&&x!=="mouse"&&(this.mouse[1]=C.invert(this.mouse[0])),this.touch0&&x!=="touch"&&(this.touch0[1]=C.invert(this.touch0[0])),this.touch1&&x!=="touch"&&(this.touch1[1]=C.invert(this.touch1[0])),this.that.__zoom=C,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(x){var C=ce(this.that).datum();l.call(x,this.that,new kd(x,{sourceEvent:this.sourceEvent,target:y,transform:this.that.__zoom,dispatch:l}),C)}};function $(x,...C){if(!e.apply(this,arguments))return;var _=P(this,C).event(x),I=this.__zoom,N=Math.max(i[0],Math.min(i[1],I.k*Math.pow(2,r.apply(this,arguments)))),E=de(x);if(_.wheel)(_.mouse[0][0]!==E[0]||_.mouse[0][1]!==E[1])&&(_.mouse[1]=I.invert(_.mouse[0]=E)),clearTimeout(_.wheel);else{if(I.k===N)return;_.mouse=[E,I.invert(E)],Xt(this),_.start()}ct(x),_.wheel=setTimeout(A,g),_.zoom("mouse",n(v(S(I,N),_.mouse[0],_.mouse[1]),_.extent,o));function A(){_.wheel=null,_.end()}}function z(x,...C){if(u||!e.apply(this,arguments))return;var _=x.currentTarget,I=P(this,C,!0).event(x),N=ce(x.view).on("mousemove.zoom",B,!0).on("mouseup.zoom",q,!0),E=de(x,_),A=x.clientX,R=x.clientY;Zs(x.view),$n(x),I.mouse=[E,this.__zoom.invert(E)],Xt(this),I.start();function B(F){if(ct(F),!I.moved){var O=F.clientX-A,Y=F.clientY-R;I.moved=O*O+Y*Y>m}I.event(F).zoom("mouse",n(v(I.that.__zoom,I.mouse[0]=de(F,_),I.mouse[1]),I.extent,o))}function q(F){N.on("mousemove.zoom mouseup.zoom",null),Qs(F.view,I.moved),ct(F),I.event(F).end()}}function T(x,...C){if(e.apply(this,arguments)){var _=this.__zoom,I=de(x.changedTouches?x.changedTouches[0]:x,this),N=_.invert(I),E=_.k*(x.shiftKey?.5:2),A=n(v(S(_,E),I,N),t.apply(this,C),o);ct(x),a>0?ce(this).transition().duration(a).call(j,A,I,x):ce(this).call(y.transform,A,I,x)}}function H(x,...C){if(e.apply(this,arguments)){var _=x.touches,I=_.length,N=P(this,C,x.changedTouches.length===I).event(x),E,A,R,B;for($n(x),A=0;A<I;++A)R=_[A],B=de(R,this),B=[B,this.__zoom.invert(B),R.identifier],N.touch0?!N.touch1&&N.touch0[2]!==B[2]&&(N.touch1=B,N.taps=0):(N.touch0=B,E=!0,N.taps=1+!!d);d&&(d=clearTimeout(d)),E&&(N.taps<2&&(f=B[0],d=setTimeout(function(){d=null},p)),Xt(this),N.start())}}function L(x,...C){if(this.__zooming){var _=P(this,C).event(x),I=x.changedTouches,N=I.length,E,A,R,B;for(ct(x),E=0;E<N;++E)A=I[E],R=de(A,this),_.touch0&&_.touch0[2]===A.identifier?_.touch0[0]=R:_.touch1&&_.touch1[2]===A.identifier&&(_.touch1[0]=R);if(A=_.that.__zoom,_.touch1){var q=_.touch0[0],F=_.touch0[1],O=_.touch1[0],Y=_.touch1[1],K=(K=O[0]-q[0])*K+(K=O[1]-q[1])*K,V=(V=Y[0]-F[0])*V+(V=Y[1]-F[1])*V;A=S(A,Math.sqrt(K/V)),R=[(q[0]+O[0])/2,(q[1]+O[1])/2],B=[(F[0]+Y[0])/2,(F[1]+Y[1])/2]}else if(_.touch0)R=_.touch0[0],B=_.touch0[1];else return;_.zoom("touch",n(v(A,R,B),_.extent,o))}}function D(x,...C){if(this.__zooming){var _=P(this,C).event(x),I=x.changedTouches,N=I.length,E,A;for($n(x),u&&clearTimeout(u),u=setTimeout(function(){u=null},p),E=0;E<N;++E)A=I[E],_.touch0&&_.touch0[2]===A.identifier?delete _.touch0:_.touch1&&_.touch1[2]===A.identifier&&delete _.touch1;if(_.touch1&&!_.touch0&&(_.touch0=_.touch1,delete _.touch1),_.touch0)_.touch0[1]=this.__zoom.invert(_.touch0[0]);else if(_.end(),_.taps===2&&(A=de(A,this),Math.hypot(f[0]-A[0],f[1]-A[1])<b)){var R=ce(this).on("dblclick.zoom");R&&R.apply(this,arguments)}}}return y.wheelDelta=function(x){return arguments.length?(r=typeof x=="function"?x:Pt(+x),y):r},y.filter=function(x){return arguments.length?(e=typeof x=="function"?x:Pt(!!x),y):e},y.touchable=function(x){return arguments.length?(s=typeof x=="function"?x:Pt(!!x),y):s},y.extent=function(x){return arguments.length?(t=typeof x=="function"?x:Pt([[+x[0][0],+x[0][1]],[+x[1][0],+x[1][1]]]),y):t},y.scaleExtent=function(x){return arguments.length?(i[0]=+x[0],i[1]=+x[1],y):[i[0],i[1]]},y.translateExtent=function(x){return arguments.length?(o[0][0]=+x[0][0],o[1][0]=+x[1][0],o[0][1]=+x[0][1],o[1][1]=+x[1][1],y):[[o[0][0],o[0][1]],[o[1][0],o[1][1]]]},y.constrain=function(x){return arguments.length?(n=x,y):n},y.duration=function(x){return arguments.length?(a=+x,y):a},y.interpolate=function(x){return arguments.length?(c=x,y):c},y.on=function(){var x=l.on.apply(l,arguments);return x===l?y:x},y.clickDistance=function(x){return arguments.length?(m=(x=+x)*x,y):Math.sqrt(m)},y.tapDistance=function(x){return arguments.length?(b=+x,y):b},y}const Ee={error001:()=>"[React Flow]: Seems like you have not used zustand provider as an ancestor. Help: https://reactflow.dev/error#001",error002:()=>"It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.",error003:e=>`Node type "${e}" not found. Using fallback type "default".`,error004:()=>"The React Flow parent container needs a width and a height to render the graph.",error005:()=>"Only child nodes can use a parent extent.",error006:()=>"Can't create edge. An edge needs a source and a target.",error007:e=>`The old edge with id=${e} does not exist.`,error009:e=>`Marker type "${e}" doesn't exist.`,error008:(e,{id:t,sourceHandle:n,targetHandle:r})=>`Couldn't create edge for ${e} handle id: "${e==="source"?n:r}", edge id: ${t}.`,error010:()=>"Handle: No node id found. Make sure to only use a Handle inside a custom Node.",error011:e=>`Edge type "${e}" not found. Using fallback type "default".`,error012:e=>`Node with id "${e}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`,error013:(e="react")=>`It seems that you haven't loaded the styles. Please import '@xyflow/${e}/dist/style.css' or base.css to make sure everything is working properly.`},vt=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],gi=["Enter"," ","Escape"];var Ze;(function(e){e.Strict="strict",e.Loose="loose"})(Ze||(Ze={}));var He;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(He||(He={}));var bt;(function(e){e.Partial="partial",e.Full="full"})(bt||(bt={}));const mi={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null};var Ie;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(Ie||(Ie={}));var Jt;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(Jt||(Jt={}));var X;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(X||(X={}));const Gr={[X.Left]:X.Right,[X.Right]:X.Left,[X.Top]:X.Bottom,[X.Bottom]:X.Top};function xi(e){return e===null?null:e?"valid":"invalid"}const yi=e=>"id"in e&&"source"in e&&"target"in e,zd=e=>"id"in e&&"position"in e&&!("source"in e)&&!("target"in e),fr=e=>"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e),Ct=(e,t=[0,0])=>{const{width:n,height:r}=Se(e),s=e.origin??t,i=n*s[0],o=r*s[1];return{x:e.position.x-i,y:e.position.y-o}},Ad=(e,t={nodeOrigin:[0,0],nodeLookup:void 0})=>{if(e.length===0)return{x:0,y:0,width:0,height:0};const n=e.reduce((r,s)=>{const i=typeof s=="string";let o=!t.nodeLookup&&!i?s:void 0;t.nodeLookup&&(o=i?t.nodeLookup.get(s):fr(s)?s:t.nodeLookup.get(s.id));const a=o?en(o,t.nodeOrigin):{x:0,y:0,x2:0,y2:0};return ln(r,a)},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return un(n)},jt=(e,t={})=>{if(e.size===0)return{x:0,y:0,width:0,height:0};let n={x:1/0,y:1/0,x2:-1/0,y2:-1/0};return e.forEach(r=>{if(t.filter===void 0||t.filter(r)){const s=en(r);n=ln(n,s)}}),un(n)},wi=(e,t,[n,r,s]=[0,0,1],i=!1,o=!1)=>{const a={...Mt(t,[n,r,s]),width:t.width/s,height:t.height/s},c=[];for(const l of e.values()){const{measured:d,selectable:f=!0,hidden:u=!1}=l;if(o&&!f||u)continue;const p=d.width??l.width??l.initialWidth??null,g=d.height??l.height??l.initialHeight??null,m=Nt(a,Je(l)),b=(p??0)*(g??0),y=i&&m>0;(!l.internals.handleBounds||y||m>=b||l.dragging)&&c.push(l)}return c},Td=(e,t)=>{const n=new Set;return e.forEach(r=>{n.add(r.id)}),t.filter(r=>n.has(r.source)||n.has(r.target))};function Kn(e,t){const n=new Map,r=t!=null&&t.nodes?new Set(t.nodes.map(s=>s.id)):null;return e.forEach(s=>{s.measured.width&&s.measured.height&&((t==null?void 0:t.includeHiddenNodes)||!s.hidden)&&(!r||r.has(s.id))&&n.set(s.id,s)}),n}async function Gn({nodes:e,width:t,height:n,panZoom:r,minZoom:s,maxZoom:i},o){if(e.size===0)return Promise.resolve(!1);const a=jt(e),c=hr(a,t,n,(o==null?void 0:o.minZoom)??s,(o==null?void 0:o.maxZoom)??i,(o==null?void 0:o.padding)??.1);return await r.setViewport(c,{duration:o==null?void 0:o.duration}),Promise.resolve(!0)}function vi({nodeId:e,nextPosition:t,nodeLookup:n,nodeOrigin:r=[0,0],nodeExtent:s,onError:i}){const o=n.get(e),a=o.parentId?n.get(o.parentId):void 0,{x:c,y:l}=a?a.internals.positionAbsolute:{x:0,y:0},d=o.origin??r;let f=s;if(o.extent==="parent"&&!o.expandParent)if(!a)i==null||i("005",Ee.error005());else{const p=a.measured.width,g=a.measured.height;p&&g&&(f=[[c,l],[c+p,l+g]])}else a&&et(o.extent)&&(f=[[o.extent[0][0]+c,o.extent[0][1]+l],[o.extent[1][0]+c,o.extent[1][1]+l]]);const u=et(f)?Be(t,f,o.measured):t;return{position:{x:u.x-c+o.measured.width*d[0],y:u.y-l+o.measured.height*d[1]},positionAbsolute:u}}async function Pd({nodesToRemove:e=[],edgesToRemove:t=[],nodes:n,edges:r,onBeforeDelete:s}){const i=new Set(e.map(u=>u.id)),o=[];for(const u of n){if(u.deletable===!1)continue;const p=i.has(u.id),g=!p&&u.parentId&&o.find(m=>m.id===u.parentId);(p||g)&&o.push(u)}const a=new Set(t.map(u=>u.id)),c=r.filter(u=>u.deletable!==!1),d=Td(o,c);for(const u of c)a.has(u.id)&&!d.find(g=>g.id===u.id)&&d.push(u);if(!s)return{edges:d,nodes:o};const f=await s({nodes:o,edges:d});return typeof f=="boolean"?f?{edges:d,nodes:o}:{edges:[],nodes:[]}:f}const Qe=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),Be=(e={x:0,y:0},t,n)=>({x:Qe(e.x,t[0][0],t[1][0]-((n==null?void 0:n.width)??0)),y:Qe(e.y,t[0][1],t[1][1]-((n==null?void 0:n.height)??0))});function bi(e,t,n){const{width:r,height:s}=Se(n),{x:i,y:o}=n.internals.positionAbsolute;return Be(e,[[i,o],[i+r,o+s]],t)}const Ur=(e,t,n)=>e<t?Qe(Math.abs(e-t),1,t)/t:e>n?-Qe(Math.abs(e-n),1,t)/t:0,Ni=(e,t,n=15,r=40)=>{const s=Ur(e.x,r,t.width-r)*n,i=Ur(e.y,r,t.height-r)*n;return[s,i]},ln=(e,t)=>({x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),x2:Math.max(e.x2,t.x2),y2:Math.max(e.y2,t.y2)}),Un=({x:e,y:t,width:n,height:r})=>({x:e,y:t,x2:e+n,y2:t+r}),un=({x:e,y:t,x2:n,y2:r})=>({x:e,y:t,width:n-e,height:r-t}),Je=(e,t=[0,0])=>{var s,i;const{x:n,y:r}=fr(e)?e.internals.positionAbsolute:Ct(e,t);return{x:n,y:r,width:((s=e.measured)==null?void 0:s.width)??e.width??e.initialWidth??0,height:((i=e.measured)==null?void 0:i.height)??e.height??e.initialHeight??0}},en=(e,t=[0,0])=>{var s,i;const{x:n,y:r}=fr(e)?e.internals.positionAbsolute:Ct(e,t);return{x:n,y:r,x2:n+(((s=e.measured)==null?void 0:s.width)??e.width??e.initialWidth??0),y2:r+(((i=e.measured)==null?void 0:i.height)??e.height??e.initialHeight??0)}},_i=(e,t)=>un(ln(Un(e),Un(t))),Nt=(e,t)=>{const n=Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x)),r=Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y));return Math.ceil(n*r)},Zr=e=>he(e.width)&&he(e.height)&&he(e.x)&&he(e.y),he=e=>!isNaN(e)&&isFinite(e),Dd=(e,t)=>{},dn=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),Mt=({x:e,y:t},[n,r,s],i=!1,o=[1,1])=>{const a={x:(e-n)/s,y:(t-r)/s};return i?dn(a,o):a},Ei=({x:e,y:t},[n,r,s])=>({x:e*s+n,y:t*s+r}),hr=(e,t,n,r,s,i)=>{const o=t/(e.width*(1+i)),a=n/(e.height*(1+i)),c=Math.min(o,a),l=Qe(c,r,s),d=e.x+e.width/2,f=e.y+e.height/2,u=t/2-d*l,p=n/2-f*l;return{x:u,y:p,zoom:l}},tn=()=>{var e;return typeof navigator<"u"&&((e=navigator==null?void 0:navigator.userAgent)==null?void 0:e.indexOf("Mac"))>=0};function et(e){return e!==void 0&&e!=="parent"}function Se(e){var t,n;return{width:((t=e.measured)==null?void 0:t.width)??e.width??e.initialWidth??0,height:((n=e.measured)==null?void 0:n.height)??e.height??e.initialHeight??0}}function Si(e){var t,n;return(((t=e.measured)==null?void 0:t.width)??e.width??e.initialWidth)!==void 0&&(((n=e.measured)==null?void 0:n.height)??e.height??e.initialHeight)!==void 0}function ki(e,t={width:0,height:0},n,r,s){const i={...e},o=r.get(n);if(o){const a=o.origin||s;i.x+=o.internals.positionAbsolute.x-(t.width??0)*a[0],i.y+=o.internals.positionAbsolute.y-(t.height??0)*a[1]}return i}function ft(e,{snapGrid:t=[0,0],snapToGrid:n=!1,transform:r,containerBounds:s}){const{x:i,y:o}=ve(e),a=Mt({x:i-((s==null?void 0:s.left)??0),y:o-((s==null?void 0:s.top)??0)},r),{x:c,y:l}=n?dn(a,t):a;return{xSnapped:c,ySnapped:l,...a}}const fn=e=>({width:e.offsetWidth,height:e.offsetHeight}),Ci=e=>{var t;return((t=e.getRootNode)==null?void 0:t.call(e))||(window==null?void 0:window.document)},Rd=["INPUT","SELECT","TEXTAREA"];function Zn(e){var r,s,i;const t=((s=(r=e.composedPath)==null?void 0:r.call(e))==null?void 0:s[0])||e.target;return Rd.includes(t==null?void 0:t.nodeName)||((i=t==null?void 0:t.hasAttribute)==null?void 0:i.call(t,"contenteditable"))||!!(t!=null&&t.closest(".nokey"))}const ji=e=>"clientX"in e,ve=(e,t)=>{var i,o;const n=ji(e),r=n?e.clientX:(i=e.touches)==null?void 0:i[0].clientX,s=n?e.clientY:(o=e.touches)==null?void 0:o[0].clientY;return{x:r-((t==null?void 0:t.left)??0),y:s-((t==null?void 0:t.top)??0)}},Qr=(e,t,n,r,s)=>{const i=t.querySelectorAll(`.${e}`);return!i||!i.length?null:Array.from(i).map(o=>{const a=o.getBoundingClientRect();return{id:o.getAttribute("data-handleid"),type:e,nodeId:s,position:o.getAttribute("data-handlepos"),x:(a.left-n.left)/r,y:(a.top-n.top)/r,...fn(o)}})};function Mi({sourceX:e,sourceY:t,targetX:n,targetY:r,sourceControlX:s,sourceControlY:i,targetControlX:o,targetControlY:a}){const c=e*.125+s*.375+o*.375+n*.125,l=t*.125+i*.375+a*.375+r*.125,d=Math.abs(c-e),f=Math.abs(l-t);return[c,l,d,f]}function Dt(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function Jr({pos:e,x1:t,y1:n,x2:r,y2:s,c:i}){switch(e){case X.Left:return[t-Dt(t-r,i),n];case X.Right:return[t+Dt(r-t,i),n];case X.Top:return[t,n-Dt(n-s,i)];case X.Bottom:return[t,n+Dt(s-n,i)]}}function $i({sourceX:e,sourceY:t,sourcePosition:n=X.Bottom,targetX:r,targetY:s,targetPosition:i=X.Top,curvature:o=.25}){const[a,c]=Jr({pos:n,x1:e,y1:t,x2:r,y2:s,c:o}),[l,d]=Jr({pos:i,x1:r,y1:s,x2:e,y2:t,c:o}),[f,u,p,g]=Mi({sourceX:e,sourceY:t,targetX:r,targetY:s,sourceControlX:a,sourceControlY:c,targetControlX:l,targetControlY:d});return[`M${e},${t} C${a},${c} ${l},${d} ${r},${s}`,f,u,p,g]}function Ii({sourceX:e,sourceY:t,targetX:n,targetY:r}){const s=Math.abs(n-e)/2,i=n<e?n+s:n-s,o=Math.abs(r-t)/2,a=r<t?r+o:r-o;return[i,a,s,o]}function Hd({sourceNode:e,targetNode:t,selected:n=!1,zIndex:r=0,elevateOnSelect:s=!1}){if(!s)return r;const i=n||t.selected||e.selected,o=Math.max(e.internals.z||0,t.internals.z||0,1e3);return r+(i?o:0)}function Ld({sourceNode:e,targetNode:t,width:n,height:r,transform:s}){const i=ln(en(e),en(t));i.x===i.x2&&(i.x2+=1),i.y===i.y2&&(i.y2+=1);const o={x:-s[0]/s[2],y:-s[1]/s[2],width:n/s[2],height:r/s[2]};return Nt(o,un(i))>0}const Bd=({source:e,sourceHandle:t,target:n,targetHandle:r})=>`xy-edge__${e}${t||""}-${n}${r||""}`,Vd=(e,t)=>t.some(n=>n.source===e.source&&n.target===e.target&&(n.sourceHandle===e.sourceHandle||!n.sourceHandle&&!e.sourceHandle)&&(n.targetHandle===e.targetHandle||!n.targetHandle&&!e.targetHandle)),Fd=(e,t)=>{if(!e.source||!e.target)return t;let n;return yi(e)?n={...e}:n={...e,id:Bd(e)},Vd(n,t)?t:(n.sourceHandle===null&&delete n.sourceHandle,n.targetHandle===null&&delete n.targetHandle,t.concat(n))};function zi({sourceX:e,sourceY:t,targetX:n,targetY:r}){const[s,i,o,a]=Ii({sourceX:e,sourceY:t,targetX:n,targetY:r});return[`M ${e},${t}L ${n},${r}`,s,i,o,a]}const es={[X.Left]:{x:-1,y:0},[X.Right]:{x:1,y:0},[X.Top]:{x:0,y:-1},[X.Bottom]:{x:0,y:1}},Od=({source:e,sourcePosition:t=X.Bottom,target:n})=>t===X.Left||t===X.Right?e.x<n.x?{x:1,y:0}:{x:-1,y:0}:e.y<n.y?{x:0,y:1}:{x:0,y:-1},ts=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function Xd({source:e,sourcePosition:t=X.Bottom,target:n,targetPosition:r=X.Top,center:s,offset:i}){const o=es[t],a=es[r],c={x:e.x+o.x*i,y:e.y+o.y*i},l={x:n.x+a.x*i,y:n.y+a.y*i},d=Od({source:c,sourcePosition:t,target:l}),f=d.x!==0?"x":"y",u=d[f];let p=[],g,m;const b={x:0,y:0},y={x:0,y:0},[S,v,w,j]=Ii({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(o[f]*a[f]===-1){g=s.x??S,m=s.y??v;const k=[{x:g,y:c.y},{x:g,y:l.y}],$=[{x:c.x,y:m},{x:l.x,y:m}];o[f]===u?p=f==="x"?k:$:p=f==="x"?$:k}else{const k=[{x:c.x,y:l.y}],$=[{x:l.x,y:c.y}];if(f==="x"?p=o.x===u?$:k:p=o.y===u?k:$,t===r){const D=Math.abs(e[f]-n[f]);if(D<=i){const x=Math.min(i-1,i-D);o[f]===u?b[f]=(c[f]>e[f]?-1:1)*x:y[f]=(l[f]>n[f]?-1:1)*x}}if(t!==r){const D=f==="x"?"y":"x",x=o[f]===a[D],C=c[D]>l[D],_=c[D]<l[D];(o[f]===1&&(!x&&C||x&&_)||o[f]!==1&&(!x&&_||x&&C))&&(p=f==="x"?k:$)}const z={x:c.x+b.x,y:c.y+b.y},T={x:l.x+y.x,y:l.y+y.y},H=Math.max(Math.abs(z.x-p[0].x),Math.abs(T.x-p[0].x)),L=Math.max(Math.abs(z.y-p[0].y),Math.abs(T.y-p[0].y));H>=L?(g=(z.x+T.x)/2,m=p[0].y):(g=p[0].x,m=(z.y+T.y)/2)}return[[e,{x:c.x+b.x,y:c.y+b.y},...p,{x:l.x+y.x,y:l.y+y.y},n],g,m,w,j]}function qd(e,t,n,r){const s=Math.min(ts(e,t)/2,ts(t,n)/2,r),{x:i,y:o}=t;if(e.x===i&&i===n.x||e.y===o&&o===n.y)return`L${i} ${o}`;if(e.y===o){const l=e.x<n.x?-1:1,d=e.y<n.y?1:-1;return`L ${i+s*l},${o}Q ${i},${o} ${i},${o+s*d}`}const a=e.x<n.x?1:-1,c=e.y<n.y?-1:1;return`L ${i},${o+s*c}Q ${i},${o} ${i+s*a},${o}`}function Qn({sourceX:e,sourceY:t,sourcePosition:n=X.Bottom,targetX:r,targetY:s,targetPosition:i=X.Top,borderRadius:o=5,centerX:a,centerY:c,offset:l=20}){const[d,f,u,p,g]=Xd({source:{x:e,y:t},sourcePosition:n,target:{x:r,y:s},targetPosition:i,center:{x:a,y:c},offset:l});return[d.reduce((b,y,S)=>{let v="";return S>0&&S<d.length-1?v=qd(d[S-1],y,d[S+1],o):v=`${S===0?"M":"L"}${y.x} ${y.y}`,b+=v,b},""),f,u,p,g]}function ns(e){var t;return e&&!!(e.internals.handleBounds||(t=e.handles)!=null&&t.length)&&!!(e.measured.width||e.width||e.initialWidth)}function Yd(e){var f;const{sourceNode:t,targetNode:n}=e;if(!ns(t)||!ns(n))return null;const r=t.internals.handleBounds||rs(t.handles),s=n.internals.handleBounds||rs(n.handles),i=ss((r==null?void 0:r.source)??[],e.sourceHandle),o=ss(e.connectionMode===Ze.Strict?(s==null?void 0:s.target)??[]:((s==null?void 0:s.target)??[]).concat((s==null?void 0:s.source)??[]),e.targetHandle);if(!i||!o)return(f=e.onError)==null||f.call(e,"008",Ee.error008(i?"target":"source",{id:e.id,sourceHandle:e.sourceHandle,targetHandle:e.targetHandle})),null;const a=(i==null?void 0:i.position)||X.Bottom,c=(o==null?void 0:o.position)||X.Top,l=_t(t,i,a),d=_t(n,o,c);return{sourceX:l.x,sourceY:l.y,targetX:d.x,targetY:d.y,sourcePosition:a,targetPosition:c}}function rs(e){if(!e)return null;const t=[],n=[];for(const r of e)r.width=r.width??1,r.height=r.height??1,r.type==="source"?t.push(r):r.type==="target"&&n.push(r);return{source:t,target:n}}function _t(e,t,n=X.Left,r=!1){const s=((t==null?void 0:t.x)??0)+e.internals.positionAbsolute.x,i=((t==null?void 0:t.y)??0)+e.internals.positionAbsolute.y,{width:o,height:a}=t??Se(e);if(r)return{x:s+o/2,y:i+a/2};switch((t==null?void 0:t.position)??n){case X.Top:return{x:s+o/2,y:i};case X.Right:return{x:s+o,y:i+a/2};case X.Bottom:return{x:s+o/2,y:i+a};case X.Left:return{x:s,y:i+a/2}}}function ss(e,t){return e&&(t?e.find(n=>n.id===t):e[0])||null}function Jn(e,t){return e?typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(r=>`${r}=${e[r]}`).join("&")}`:""}function Wd(e,{id:t,defaultColor:n,defaultMarkerStart:r,defaultMarkerEnd:s}){const i=new Set;return e.reduce((o,a)=>([a.markerStart||r,a.markerEnd||s].forEach(c=>{if(c&&typeof c=="object"){const l=Jn(c,t);i.has(l)||(o.push({id:l,color:c.color||n,...c}),i.add(l))}}),o),[]).sort((o,a)=>o.id.localeCompare(a.id))}const pr={nodeOrigin:[0,0],nodeExtent:vt,elevateNodesOnSelect:!0,defaults:{}},Kd={...pr,checkEquality:!0};function gr(e,t){const n={...e};for(const r in t)t[r]!==void 0&&(n[r]=t[r]);return n}function Gd(e,t,n){const r=gr(pr,n);for(const s of e.values())if(s.parentId)mr(s,e,t,r);else{const i=Ct(s,r.nodeOrigin),o=et(s.extent)?s.extent:r.nodeExtent,a=Be(i,o,Se(s));s.internals.positionAbsolute=a}}function er(e,t,n,r){var a,c;const s=gr(Kd,r),i=new Map(t),o=s!=null&&s.elevateNodesOnSelect?1e3:0;t.clear(),n.clear();for(const l of e){let d=i.get(l.id);if(s.checkEquality&&l===(d==null?void 0:d.internals.userNode))t.set(l.id,d);else{const f=Ct(l,s.nodeOrigin),u=et(l.extent)?l.extent:s.nodeExtent,p=Be(f,u,Se(l));d={...s.defaults,...l,measured:{width:(a=l.measured)==null?void 0:a.width,height:(c=l.measured)==null?void 0:c.height},internals:{positionAbsolute:p,handleBounds:l.measured?d==null?void 0:d.internals.handleBounds:void 0,z:Ai(l,o),userNode:l}},t.set(l.id,d)}l.parentId&&mr(d,t,n,r)}}function Ud(e,t){if(!e.parentId)return;const n=t.get(e.parentId);n?n.set(e.id,e):t.set(e.parentId,new Map([[e.id,e]]))}function mr(e,t,n,r){const{elevateNodesOnSelect:s,nodeOrigin:i,nodeExtent:o}=gr(pr,r),a=e.parentId,c=t.get(a);if(!c){console.warn(`Parent node ${a} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}Ud(e,n);const l=s?1e3:0,{x:d,y:f,z:u}=Zd(e,c,i,o,l),{positionAbsolute:p}=e.internals,g=d!==p.x||f!==p.y;(g||u!==e.internals.z)&&(e.internals={...e.internals,positionAbsolute:g?{x:d,y:f}:p,z:u})}function Ai(e,t){return(he(e.zIndex)?e.zIndex:0)+(e.selected?t:0)}function Zd(e,t,n,r,s){const{x:i,y:o}=t.internals.positionAbsolute,a=Se(e),c=Ct(e,n),l=et(e.extent)?Be(c,e.extent,a):c;let d=Be({x:i+l.x,y:o+l.y},r,a);e.extent==="parent"&&(d=bi(d,a,t));const f=Ai(e,s),u=t.internals.z??0;return{x:d.x,y:d.y,z:u>f?u:f}}function xr(e,t,n,r=[0,0]){var o;const s=[],i=new Map;for(const a of e){const c=t.get(a.parentId);if(!c)continue;const l=((o=i.get(a.parentId))==null?void 0:o.expandedRect)??Je(c),d=_i(l,a.rect);i.set(a.parentId,{expandedRect:d,parent:c})}return i.size>0&&i.forEach(({expandedRect:a,parent:c},l)=>{var v;const d=c.internals.positionAbsolute,f=Se(c),u=c.origin??r,p=a.x<d.x?Math.round(Math.abs(d.x-a.x)):0,g=a.y<d.y?Math.round(Math.abs(d.y-a.y)):0,m=Math.max(f.width,Math.round(a.width)),b=Math.max(f.height,Math.round(a.height)),y=(m-f.width)*u[0],S=(b-f.height)*u[1];(p>0||g>0||y||S)&&(s.push({id:l,type:"position",position:{x:c.position.x-p+y,y:c.position.y-g+S}}),(v=n.get(l))==null||v.forEach(w=>{e.some(j=>j.id===w.id)||s.push({id:w.id,type:"position",position:{x:w.position.x+p,y:w.position.y+g}})})),(f.width<a.width||f.height<a.height||p||g)&&s.push({id:l,type:"dimensions",setAttributes:!0,dimensions:{width:m+(p?u[0]*p-y:0),height:b+(g?u[1]*g-S:0)}})}),s}function Qd(e,t,n,r,s,i){const o=r==null?void 0:r.querySelector(".xyflow__viewport");let a=!1;if(!o)return{changes:[],updatedInternals:a};const c=[],l=window.getComputedStyle(o),{m22:d}=new window.DOMMatrixReadOnly(l.transform),f=[];for(const u of e.values()){const p=t.get(u.id);if(p)if(p.hidden)p.internals={...p.internals,handleBounds:void 0},a=!0;else{const g=fn(u.nodeElement),m=p.measured.width!==g.width||p.measured.height!==g.height;if(!!(g.width&&g.height&&(m||!p.internals.handleBounds||u.force))){const y=u.nodeElement.getBoundingClientRect(),S=et(p.extent)?p.extent:i;let{positionAbsolute:v}=p.internals;p.parentId&&p.extent==="parent"?v=bi(v,g,t.get(p.parentId)):S&&(v=Be(v,S,g)),p.measured=g,p.internals={...p.internals,positionAbsolute:v,handleBounds:{source:Qr("source",u.nodeElement,y,d,p.id),target:Qr("target",u.nodeElement,y,d,p.id)}},p.parentId&&mr(p,t,n,{nodeOrigin:s}),a=!0,m&&(c.push({id:p.id,type:"dimensions",dimensions:g}),p.expandParent&&p.parentId&&f.push({id:p.id,parentId:p.parentId,rect:Je(p,s)}))}}}if(f.length>0){const u=xr(f,t,n,s);c.push(...u)}return{changes:c,updatedInternals:a}}async function Jd({delta:e,panZoom:t,transform:n,translateExtent:r,width:s,height:i}){if(!t||!e.x&&!e.y)return Promise.resolve(!1);const o=await t.setViewportConstrained({x:n[0]+e.x,y:n[1]+e.y,zoom:n[2]},[[0,0],[s,i]],r),a=!!o&&(o.x!==n[0]||o.y!==n[1]||o.k!==n[2]);return Promise.resolve(a)}function Ti(e,t,n){e.clear(),t.clear();for(const r of n){const{source:s,target:i,sourceHandle:o=null,targetHandle:a=null}=r,c=`${s}-source-${o}`,l=`${i}-target-${a}`,d=e.get(c)||new Map,f=e.get(l)||new Map,u={edgeId:r.id,source:s,target:i,sourceHandle:o,targetHandle:a};t.set(r.id,r),e.set(c,d.set(`${i}-${a}`,u)),e.set(l,f.set(`${s}-${o}`,u))}}function Pi(e,t){if(!e.parentId)return!1;const n=t.get(e.parentId);return n?n.selected?!0:Pi(n,t):!1}function is(e,t,n){let r=e;do{if(r!=null&&r.matches(t))return!0;if(r===n)return!1;r=r.parentElement}while(r);return!1}function ef(e,t,n,r){const s=new Map;for(const[i,o]of e)if((o.selected||o.id===r)&&(!o.parentId||!Pi(o,e))&&(o.draggable||t&&typeof o.draggable>"u")){const a=e.get(i);a&&s.set(i,{id:i,position:a.position||{x:0,y:0},distance:{x:n.x-a.internals.positionAbsolute.x,y:n.y-a.internals.positionAbsolute.y},extent:a.extent,parentId:a.parentId,origin:a.origin,expandParent:a.expandParent,internals:{positionAbsolute:a.internals.positionAbsolute||{x:0,y:0}},measured:{width:a.measured.width??0,height:a.measured.height??0}})}return s}function In({nodeId:e,dragItems:t,nodeLookup:n,dragging:r=!0}){var o,a,c;const s=[];for(const[l,d]of t){const f=(o=n.get(l))==null?void 0:o.internals.userNode;f&&s.push({...f,position:d.position,dragging:r})}if(!e)return[s[0],s];const i=(a=n.get(e))==null?void 0:a.internals.userNode;return[i?{...i,position:((c=t.get(e))==null?void 0:c.position)||i.position,dragging:r}:s[0],s]}function tf({onNodeMouseDown:e,getStoreItems:t,onDragStart:n,onDrag:r,onDragStop:s}){let i={x:null,y:null},o=0,a=new Map,c=!1,l={x:0,y:0},d=null,f=!1,u=null,p=!1;function g({noDragClassName:b,handleSelector:y,domNode:S,isSelectable:v,nodeId:w,nodeClickDistance:j=0}){u=ce(S);function P({x:T,y:H},L){const{nodeLookup:D,nodeExtent:x,snapGrid:C,snapToGrid:_,nodeOrigin:I,onNodeDrag:N,onSelectionDrag:E,onError:A,updateNodePositions:R}=t();i={x:T,y:H};let B=!1,q={x:0,y:0,x2:0,y2:0};if(a.size>1&&x){const F=jt(a);q=Un(F)}for(const[F,O]of a){if(!D.has(F))continue;let Y={x:T-O.distance.x,y:H-O.distance.y};_&&(Y=dn(Y,C));let K=[[x[0][0],x[0][1]],[x[1][0],x[1][1]]];if(a.size>1&&x&&!O.extent){const{positionAbsolute:Z}=O.internals,U=Z.x-q.x+x[0][0],W=Z.x+O.measured.width-q.x2+x[1][0],J=Z.y-q.y+x[0][1],ee=Z.y+O.measured.height-q.y2+x[1][1];K=[[U,J],[W,ee]]}const{position:V,positionAbsolute:G}=vi({nodeId:F,nextPosition:Y,nodeLookup:D,nodeExtent:K,nodeOrigin:I,onError:A});B=B||O.position.x!==V.x||O.position.y!==V.y,O.position=V,O.internals.positionAbsolute=G}if(B&&(R(a,!0),L&&(r||N||!w&&E))){const[F,O]=In({nodeId:w,dragItems:a,nodeLookup:D});r==null||r(L,a,F,O),N==null||N(L,F,O),w||E==null||E(L,O)}}async function k(){if(!d)return;const{transform:T,panBy:H,autoPanSpeed:L}=t(),[D,x]=Ni(l,d,L);(D!==0||x!==0)&&(i.x=(i.x??0)-D/T[2],i.y=(i.y??0)-x/T[2],await H({x:D,y:x})&&P(i,null)),o=requestAnimationFrame(k)}function $(T){var B;const{nodeLookup:H,multiSelectionActive:L,nodesDraggable:D,transform:x,snapGrid:C,snapToGrid:_,selectNodesOnDrag:I,onNodeDragStart:N,onSelectionDragStart:E,unselectNodesAndEdges:A}=t();f=!0,(!I||!v)&&!L&&w&&((B=H.get(w))!=null&&B.selected||A()),v&&I&&w&&(e==null||e(w));const R=ft(T.sourceEvent,{transform:x,snapGrid:C,snapToGrid:_,containerBounds:d});if(i=R,a=ef(H,D,R,w),a.size>0&&(n||N||!w&&E)){const[q,F]=In({nodeId:w,dragItems:a,nodeLookup:H});n==null||n(T.sourceEvent,a,q,F),N==null||N(T.sourceEvent,q,F),w||E==null||E(T.sourceEvent,F)}}const z=Js().clickDistance(j).on("start",T=>{const{domNode:H,nodeDragThreshold:L,transform:D,snapGrid:x,snapToGrid:C}=t();d=(H==null?void 0:H.getBoundingClientRect())||null,p=!1,L===0&&$(T),i=ft(T.sourceEvent,{transform:D,snapGrid:x,snapToGrid:C,containerBounds:d}),l=ve(T.sourceEvent,d)}).on("drag",T=>{const{autoPanOnNodeDrag:H,transform:L,snapGrid:D,snapToGrid:x,nodeDragThreshold:C,nodeLookup:_}=t(),I=ft(T.sourceEvent,{transform:L,snapGrid:D,snapToGrid:x,containerBounds:d});if((T.sourceEvent.type==="touchmove"&&T.sourceEvent.touches.length>1||w&&!_.has(w))&&(p=!0),!p){if(!c&&H&&f&&(c=!0,k()),!f){const N=I.xSnapped-(i.x??0),E=I.ySnapped-(i.y??0);Math.sqrt(N*N+E*E)>C&&$(T)}(i.x!==I.xSnapped||i.y!==I.ySnapped)&&a&&f&&(l=ve(T.sourceEvent,d),P(I,T.sourceEvent))}}).on("end",T=>{if(!(!f||p)&&(c=!1,f=!1,cancelAnimationFrame(o),a.size>0)){const{nodeLookup:H,updateNodePositions:L,onNodeDragStop:D,onSelectionDragStop:x}=t();if(L(a,!1),s||D||!w&&x){const[C,_]=In({nodeId:w,dragItems:a,nodeLookup:H,dragging:!1});s==null||s(T.sourceEvent,a,C,_),D==null||D(T.sourceEvent,C,_),w||x==null||x(T.sourceEvent,_)}}}).filter(T=>{const H=T.target;return!T.button&&(!b||!is(H,`.${b}`,S))&&(!y||is(H,y,S))});u.call(z)}function m(){u==null||u.on(".drag",null)}return{update:g,destroy:m}}function nf(e,t,n){const r=[],s={x:e.x-n,y:e.y-n,width:n*2,height:n*2};for(const i of t.values())Nt(s,Je(i))>0&&r.push(i);return r}const rf=250;function sf(e,t,n,r){var a,c;let s=[],i=1/0;const o=nf(e,n,t+rf);for(const l of o){const d=[...((a=l.internals.handleBounds)==null?void 0:a.source)??[],...((c=l.internals.handleBounds)==null?void 0:c.target)??[]];for(const f of d){if(r.nodeId===f.nodeId&&r.type===f.type&&r.id===f.id)continue;const{x:u,y:p}=_t(l,f,f.position,!0),g=Math.sqrt(Math.pow(u-e.x,2)+Math.pow(p-e.y,2));g>t||(g<i?(s=[{...f,x:u,y:p}],i=g):g===i&&s.push({...f,x:u,y:p}))}}if(!s.length)return null;if(s.length>1){const l=r.type==="source"?"target":"source";return s.find(d=>d.type===l)??s[0]}return s[0]}function Di(e,t,n,r,s,i=!1){var l,d,f;const o=r.get(e);if(!o)return null;const a=s==="strict"?(l=o.internals.handleBounds)==null?void 0:l[t]:[...((d=o.internals.handleBounds)==null?void 0:d.source)??[],...((f=o.internals.handleBounds)==null?void 0:f.target)??[]],c=(n?a==null?void 0:a.find(u=>u.id===n):a==null?void 0:a[0])??null;return c&&i?{...c,..._t(o,c,c.position,!0)}:c}function Ri(e,t){return e||(t!=null&&t.classList.contains("target")?"target":t!=null&&t.classList.contains("source")?"source":null)}function of(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}const Hi=()=>!0;function af(e,{connectionMode:t,connectionRadius:n,handleId:r,nodeId:s,edgeUpdaterType:i,isTarget:o,domNode:a,nodeLookup:c,lib:l,autoPanOnConnect:d,flowId:f,panBy:u,cancelConnection:p,onConnectStart:g,onConnect:m,onConnectEnd:b,isValidConnection:y=Hi,onReconnectEnd:S,updateConnection:v,getTransform:w,getFromHandle:j,autoPanSpeed:P}){const k=Ci(e.target);let $=0,z;const{x:T,y:H}=ve(e),L=k==null?void 0:k.elementFromPoint(T,H),D=Ri(i,L),x=a==null?void 0:a.getBoundingClientRect();if(!x||!D)return;const C=Di(s,D,r,c,t);if(!C)return;let _=ve(e,x),I=!1,N=null,E=!1,A=null;function R(){if(!d||!x)return;const[G,Z]=Ni(_,x,P);u({x:G,y:Z}),$=requestAnimationFrame(R)}const B={...C,nodeId:s,type:D,position:C.position},q=c.get(s),O={inProgress:!0,isValid:null,from:_t(q,B,X.Left,!0),fromHandle:B,fromPosition:B.position,fromNode:q,to:_,toHandle:null,toPosition:Gr[B.position],toNode:null};v(O);let Y=O;g==null||g(e,{nodeId:s,handleId:r,handleType:D});function K(G){if(!j()||!B){V(G);return}const Z=w();_=ve(G,x),z=sf(Mt(_,Z,!1,[1,1]),n,c,B),I||(R(),I=!0);const U=Li(G,{handle:z,connectionMode:t,fromNodeId:s,fromHandleId:r,fromType:o?"target":"source",isValidConnection:y,doc:k,lib:l,flowId:f,nodeLookup:c});A=U.handleDomNode,N=U.connection,E=of(!!z,U.isValid);const W={...Y,isValid:E,to:z&&E?Ei({x:z.x,y:z.y},Z):_,toHandle:U.toHandle,toPosition:E&&U.toHandle?U.toHandle.position:Gr[B.position],toNode:U.toHandle?c.get(U.toHandle.nodeId):null};E&&z&&Y.toHandle&&W.toHandle&&Y.toHandle.type===W.toHandle.type&&Y.toHandle.nodeId===W.toHandle.nodeId&&Y.toHandle.id===W.toHandle.id&&Y.to.x===W.to.x&&Y.to.y===W.to.y||(v(W),Y=W)}function V(G){(z||A)&&N&&E&&(m==null||m(N));const{inProgress:Z,...U}=Y,W={...U,toPosition:Y.toHandle?Y.toPosition:null};b==null||b(G,W),i&&(S==null||S(G,W)),p(),cancelAnimationFrame($),I=!1,E=!1,N=null,A=null,k.removeEventListener("mousemove",K),k.removeEventListener("mouseup",V),k.removeEventListener("touchmove",K),k.removeEventListener("touchend",V)}k.addEventListener("mousemove",K),k.addEventListener("mouseup",V),k.addEventListener("touchmove",K),k.addEventListener("touchend",V)}function Li(e,{handle:t,connectionMode:n,fromNodeId:r,fromHandleId:s,fromType:i,doc:o,lib:a,flowId:c,isValidConnection:l=Hi,nodeLookup:d}){const f=i==="target",u=t?o.querySelector(`.${a}-flow__handle[data-id="${c}-${t==null?void 0:t.nodeId}-${t==null?void 0:t.id}-${t==null?void 0:t.type}"]`):null,{x:p,y:g}=ve(e),m=o.elementFromPoint(p,g),b=m!=null&&m.classList.contains(`${a}-flow__handle`)?m:u,y={handleDomNode:b,isValid:!1,connection:null,toHandle:null};if(b){const S=Ri(void 0,b),v=b.getAttribute("data-nodeid"),w=b.getAttribute("data-handleid"),j=b.classList.contains("connectable"),P=b.classList.contains("connectableend");if(!v||!S)return y;const k={source:f?v:r,sourceHandle:f?w:s,target:f?r:v,targetHandle:f?s:w};y.connection=k;const z=j&&P&&(n===Ze.Strict?f&&S==="source"||!f&&S==="target":v!==r||w!==s);y.isValid=z&&l(k),y.toHandle=Di(v,S,w,d,n,!1)}return y}const tr={onPointerDown:af,isValid:Li};function cf({domNode:e,panZoom:t,getTransform:n,getViewScale:r}){const s=ce(e);function i({translateExtent:a,width:c,height:l,zoomStep:d=10,pannable:f=!0,zoomable:u=!0,inversePan:p=!1}){const g=v=>{const w=n();if(v.sourceEvent.type!=="wheel"||!t)return;const j=-v.sourceEvent.deltaY*(v.sourceEvent.deltaMode===1?.05:v.sourceEvent.deltaMode?1:.002)*d,P=w[2]*Math.pow(2,j);t.scaleTo(P)};let m=[0,0];const b=v=>{(v.sourceEvent.type==="mousedown"||v.sourceEvent.type==="touchstart")&&(m=[v.sourceEvent.clientX??v.sourceEvent.touches[0].clientX,v.sourceEvent.clientY??v.sourceEvent.touches[0].clientY])},y=v=>{const w=n();if(v.sourceEvent.type!=="mousemove"&&v.sourceEvent.type!=="touchmove"||!t)return;const j=[v.sourceEvent.clientX??v.sourceEvent.touches[0].clientX,v.sourceEvent.clientY??v.sourceEvent.touches[0].clientY],P=[j[0]-m[0],j[1]-m[1]];m=j;const k=r()*Math.max(w[2],Math.log(w[2]))*(p?-1:1),$={x:w[0]-P[0]*k,y:w[1]-P[1]*k},z=[[0,0],[c,l]];t.setViewportConstrained({x:$.x,y:$.y,zoom:w[2]},z,a)},S=pi().on("start",b).on("zoom",f?y:null).on("zoom.wheel",u?g:null);s.call(S,{})}function o(){s.on("zoom",null)}return{update:i,destroy:o,pointer:de}}const lf=(e,t)=>e.x!==t.x||e.y!==t.y||e.zoom!==t.k,hn=e=>({x:e.x,y:e.y,zoom:e.k}),zn=({x:e,y:t,zoom:n})=>cn.translate(e,t).scale(n),Xe=(e,t)=>e.target.closest(`.${t}`),Bi=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),An=(e,t=0,n=()=>{})=>{const r=typeof t=="number"&&t>0;return r||n(),r?e.transition().duration(t).on("end",n):e},Vi=e=>{const t=e.ctrlKey&&tn()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function uf({zoomPanValues:e,noWheelClassName:t,d3Selection:n,d3Zoom:r,panOnScrollMode:s,panOnScrollSpeed:i,zoomOnPinch:o,onPanZoomStart:a,onPanZoom:c,onPanZoomEnd:l}){return d=>{if(Xe(d,t))return!1;d.preventDefault(),d.stopImmediatePropagation();const f=n.property("__zoom").k||1;if(d.ctrlKey&&o){const b=de(d),y=Vi(d),S=f*Math.pow(2,y);r.scaleTo(n,S,b,d);return}const u=d.deltaMode===1?20:1;let p=s===He.Vertical?0:d.deltaX*u,g=s===He.Horizontal?0:d.deltaY*u;!tn()&&d.shiftKey&&s!==He.Vertical&&(p=d.deltaY*u,g=0),r.translateBy(n,-(p/f)*i,-(g/f)*i,{internal:!0});const m=hn(n.property("__zoom"));clearTimeout(e.panScrollTimeout),e.isPanScrolling||(e.isPanScrolling=!0,a==null||a(d,m)),e.isPanScrolling&&(c==null||c(d,m),e.panScrollTimeout=setTimeout(()=>{l==null||l(d,m),e.isPanScrolling=!1},150))}}function df({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:n}){return function(r,s){if(!t&&r.type==="wheel"&&!r.ctrlKey||Xe(r,e))return null;r.preventDefault(),n.call(this,r,s)}}function ff({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:n}){return r=>{var i,o,a;if((i=r.sourceEvent)!=null&&i.internal)return;const s=hn(r.transform);e.mouseButton=((o=r.sourceEvent)==null?void 0:o.button)||0,e.isZoomingOrPanning=!0,e.prevViewport=s,((a=r.sourceEvent)==null?void 0:a.type)==="mousedown"&&t(!0),n&&(n==null||n(r.sourceEvent,s))}}function hf({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:r,onPanZoom:s}){return i=>{var o,a;e.usedRightMouseButton=!!(n&&Bi(t,e.mouseButton??0)),(o=i.sourceEvent)!=null&&o.sync||r([i.transform.x,i.transform.y,i.transform.k]),s&&!((a=i.sourceEvent)!=null&&a.internal)&&(s==null||s(i.sourceEvent,hn(i.transform)))}}function pf({zoomPanValues:e,panOnDrag:t,panOnScroll:n,onDraggingChange:r,onPanZoomEnd:s,onPaneContextMenu:i}){return o=>{var a;if(!((a=o.sourceEvent)!=null&&a.internal)&&(e.isZoomingOrPanning=!1,i&&Bi(t,e.mouseButton??0)&&!e.usedRightMouseButton&&o.sourceEvent&&i(o.sourceEvent),e.usedRightMouseButton=!1,r(!1),s&&lf(e.prevViewport,o.transform))){const c=hn(o.transform);e.prevViewport=c,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{s==null||s(o.sourceEvent,c)},n?150:0)}}}function gf({zoomActivationKeyPressed:e,zoomOnScroll:t,zoomOnPinch:n,panOnDrag:r,panOnScroll:s,zoomOnDoubleClick:i,userSelectionActive:o,noWheelClassName:a,noPanClassName:c,lib:l}){return d=>{var g;const f=e||t,u=n&&d.ctrlKey;if(d.button===1&&d.type==="mousedown"&&(Xe(d,`${l}-flow__node`)||Xe(d,`${l}-flow__edge`)))return!0;if(!r&&!f&&!s&&!i&&!n||o||Xe(d,a)&&d.type==="wheel"||Xe(d,c)&&(d.type!=="wheel"||s&&d.type==="wheel"&&!e)||!n&&d.ctrlKey&&d.type==="wheel")return!1;if(!n&&d.type==="touchstart"&&((g=d.touches)==null?void 0:g.length)>1)return d.preventDefault(),!1;if(!f&&!s&&!u&&d.type==="wheel"||!r&&(d.type==="mousedown"||d.type==="touchstart")||Array.isArray(r)&&!r.includes(d.button)&&d.type==="mousedown")return!1;const p=Array.isArray(r)&&r.includes(d.button)||!d.button||d.button<=1;return(!d.ctrlKey||d.type==="wheel")&&p}}function mf({domNode:e,minZoom:t,maxZoom:n,paneClickDistance:r,translateExtent:s,viewport:i,onPanZoom:o,onPanZoomStart:a,onPanZoomEnd:c,onDraggingChange:l}){const d={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{x:0,y:0,zoom:0},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},f=e.getBoundingClientRect(),u=pi().clickDistance(!he(r)||r<0?0:r).scaleExtent([t,n]).translateExtent(s),p=ce(e).call(u);v({x:i.x,y:i.y,zoom:Qe(i.zoom,t,n)},[[0,0],[f.width,f.height]],s);const g=p.on("wheel.zoom"),m=p.on("dblclick.zoom");u.wheelDelta(Vi);function b(L,D){return p?new Promise(x=>{u==null||u.transform(An(p,D==null?void 0:D.duration,()=>x(!0)),L)}):Promise.resolve(!1)}function y({noWheelClassName:L,noPanClassName:D,onPaneContextMenu:x,userSelectionActive:C,panOnScroll:_,panOnDrag:I,panOnScrollMode:N,panOnScrollSpeed:E,preventScrolling:A,zoomOnPinch:R,zoomOnScroll:B,zoomOnDoubleClick:q,zoomActivationKeyPressed:F,lib:O,onTransformChange:Y}){C&&!d.isZoomingOrPanning&&S();const V=_&&!F&&!C?uf({zoomPanValues:d,noWheelClassName:L,d3Selection:p,d3Zoom:u,panOnScrollMode:N,panOnScrollSpeed:E,zoomOnPinch:R,onPanZoomStart:a,onPanZoom:o,onPanZoomEnd:c}):df({noWheelClassName:L,preventScrolling:A,d3ZoomHandler:g});if(p.on("wheel.zoom",V,{passive:!1}),!C){const Z=ff({zoomPanValues:d,onDraggingChange:l,onPanZoomStart:a});u.on("start",Z);const U=hf({zoomPanValues:d,panOnDrag:I,onPaneContextMenu:!!x,onPanZoom:o,onTransformChange:Y});u.on("zoom",U);const W=pf({zoomPanValues:d,panOnDrag:I,panOnScroll:_,onPaneContextMenu:x,onPanZoomEnd:c,onDraggingChange:l});u.on("end",W)}const G=gf({zoomActivationKeyPressed:F,panOnDrag:I,zoomOnScroll:B,panOnScroll:_,zoomOnDoubleClick:q,zoomOnPinch:R,userSelectionActive:C,noPanClassName:D,noWheelClassName:L,lib:O});u.filter(G),q?p.on("dblclick.zoom",m):p.on("dblclick.zoom",null)}function S(){u.on("zoom",null)}async function v(L,D,x){const C=zn(L),_=u==null?void 0:u.constrain()(C,D,x);return _&&await b(_),new Promise(I=>I(_))}async function w(L,D){const x=zn(L);return await b(x,D),new Promise(C=>C(x))}function j(L){if(p){const D=zn(L),x=p.property("__zoom");(x.k!==L.zoom||x.x!==L.x||x.y!==L.y)&&(u==null||u.transform(p,D,null,{sync:!0}))}}function P(){const L=p?hi(p.node()):{x:0,y:0,k:1};return{x:L.x,y:L.y,zoom:L.k}}function k(L,D){return p?new Promise(x=>{u==null||u.scaleTo(An(p,D==null?void 0:D.duration,()=>x(!0)),L)}):Promise.resolve(!1)}function $(L,D){return p?new Promise(x=>{u==null||u.scaleBy(An(p,D==null?void 0:D.duration,()=>x(!0)),L)}):Promise.resolve(!1)}function z(L){u==null||u.scaleExtent(L)}function T(L){u==null||u.translateExtent(L)}function H(L){const D=!he(L)||L<0?0:L;u==null||u.clickDistance(D)}return{update:y,destroy:S,setViewport:w,setViewportConstrained:v,getViewport:P,scaleTo:k,scaleBy:$,setScaleExtent:z,setTranslateExtent:T,syncViewport:j,setClickDistance:H}}var ht;(function(e){e.Line="line",e.Handle="handle"})(ht||(ht={}));function xf({width:e,prevWidth:t,height:n,prevHeight:r,affectsX:s,affectsY:i}){const o=e-t,a=n-r,c=[o>0?1:o<0?-1:0,a>0?1:a<0?-1:0];return o&&s&&(c[0]=c[0]*-1),a&&i&&(c[1]=c[1]*-1),c}function yf(e){const t=e.includes("right")||e.includes("left"),n=e.includes("bottom")||e.includes("top"),r=e.includes("left"),s=e.includes("top");return{isHorizontal:t,isVertical:n,affectsX:r,affectsY:s}}function je(e,t){return Math.max(0,t-e)}function Me(e,t){return Math.max(0,e-t)}function Rt(e,t,n){return Math.max(0,t-e,e-n)}function os(e,t){return e?!t:t}function wf(e,t,n,r,s,i,o,a){let{affectsX:c,affectsY:l}=t;const{isHorizontal:d,isVertical:f}=t,u=d&&f,{xSnapped:p,ySnapped:g}=n,{minWidth:m,maxWidth:b,minHeight:y,maxHeight:S}=r,{x:v,y:w,width:j,height:P,aspectRatio:k}=e;let $=Math.floor(d?p-e.pointerX:0),z=Math.floor(f?g-e.pointerY:0);const T=j+(c?-$:$),H=P+(l?-z:z),L=-i[0]*j,D=-i[1]*P;let x=Rt(T,m,b),C=Rt(H,y,S);if(o){let N=0,E=0;c&&$<0?N=je(v+$+L,o[0][0]):!c&&$>0&&(N=Me(v+T+L,o[1][0])),l&&z<0?E=je(w+z+D,o[0][1]):!l&&z>0&&(E=Me(w+H+D,o[1][1])),x=Math.max(x,N),C=Math.max(C,E)}if(a){let N=0,E=0;c&&$>0?N=Me(v+$,a[0][0]):!c&&$<0&&(N=je(v+T,a[1][0])),l&&z>0?E=Me(w+z,a[0][1]):!l&&z<0&&(E=je(w+H,a[1][1])),x=Math.max(x,N),C=Math.max(C,E)}if(s){if(d){const N=Rt(T/k,y,S)*k;if(x=Math.max(x,N),o){let E=0;!c&&!l||c&&!l&&u?E=Me(w+D+T/k,o[1][1])*k:E=je(w+D+(c?$:-$)/k,o[0][1])*k,x=Math.max(x,E)}if(a){let E=0;!c&&!l||c&&!l&&u?E=je(w+T/k,a[1][1])*k:E=Me(w+(c?$:-$)/k,a[0][1])*k,x=Math.max(x,E)}}if(f){const N=Rt(H*k,m,b)/k;if(C=Math.max(C,N),o){let E=0;!c&&!l||l&&!c&&u?E=Me(v+H*k+L,o[1][0])/k:E=je(v+(l?z:-z)*k+L,o[0][0])/k,C=Math.max(C,E)}if(a){let E=0;!c&&!l||l&&!c&&u?E=je(v+H*k,a[1][0])/k:E=Me(v+(l?z:-z)*k,a[0][0])/k,C=Math.max(C,E)}}}z=z+(z<0?C:-C),$=$+($<0?x:-x),s&&(u?T>H*k?z=(os(c,l)?-$:$)/k:$=(os(c,l)?-z:z)*k:d?(z=$/k,l=c):($=z*k,c=l));const _=c?v+$:v,I=l?w+z:w;return{width:j+(c?-$:$),height:P+(l?-z:z),x:i[0]*$*(c?-1:1)+_,y:i[1]*z*(l?-1:1)+I}}const Fi={width:0,height:0,x:0,y:0},vf={...Fi,pointerX:0,pointerY:0,aspectRatio:1};function bf(e){return[[0,0],[e.measured.width,e.measured.height]]}function Nf(e,t,n){const r=t.position.x+e.position.x,s=t.position.y+e.position.y,i=e.measured.width??0,o=e.measured.height??0,a=n[0]*i,c=n[1]*o;return[[r-a,s-c],[r+i-a,s+o-c]]}function _f({domNode:e,nodeId:t,getStoreItems:n,onChange:r,onEnd:s}){const i=ce(e);function o({controlPosition:c,boundaries:l,keepAspectRatio:d,onResizeStart:f,onResize:u,onResizeEnd:p,shouldResize:g}){let m={...Fi},b={...vf};const y=yf(c);let S,v=null,w=[],j,P,k;const $=Js().on("start",z=>{const{nodeLookup:T,transform:H,snapGrid:L,snapToGrid:D,nodeOrigin:x,paneDomNode:C}=n();if(S=T.get(t),!S)return;v=(C==null?void 0:C.getBoundingClientRect())??null;const{xSnapped:_,ySnapped:I}=ft(z.sourceEvent,{transform:H,snapGrid:L,snapToGrid:D,containerBounds:v});m={width:S.measured.width??0,height:S.measured.height??0,x:S.position.x??0,y:S.position.y??0},b={...m,pointerX:_,pointerY:I,aspectRatio:m.width/m.height},j=void 0,S.parentId&&(S.extent==="parent"||S.expandParent)&&(j=T.get(S.parentId),P=j&&S.extent==="parent"?bf(j):void 0),w=[],k=void 0;for(const[N,E]of T)if(E.parentId===t&&(w.push({id:N,position:{...E.position},extent:E.extent}),E.extent==="parent"||E.expandParent)){const A=Nf(E,S,E.origin??x);k?k=[[Math.min(A[0][0],k[0][0]),Math.min(A[0][1],k[0][1])],[Math.max(A[1][0],k[1][0]),Math.max(A[1][1],k[1][1])]]:k=A}f==null||f(z,{...m})}).on("drag",z=>{const{transform:T,snapGrid:H,snapToGrid:L,nodeOrigin:D}=n(),x=ft(z.sourceEvent,{transform:T,snapGrid:H,snapToGrid:L,containerBounds:v}),C=[];if(!S)return;const{x:_,y:I,width:N,height:E}=m,A={},R=S.origin??D,{width:B,height:q,x:F,y:O}=wf(b,y,x,l,d,R,P,k),Y=B!==N,K=q!==E,V=F!==_&&Y,G=O!==I&&K;if(!V&&!G&&!Y&&!K)return;if((V||G||R[0]===1||R[1]===1)&&(A.x=V?F:m.x,A.y=G?O:m.y,m.x=A.x,m.y=A.y,w.length>0)){const J=F-_,ee=O-I;for(const ie of w)ie.position={x:ie.position.x-J+R[0]*(B-N),y:ie.position.y-ee+R[1]*(q-E)},C.push(ie)}if((Y||K)&&(A.width=Y?B:m.width,A.height=K?q:m.height,m.width=A.width,m.height=A.height),j&&S.expandParent){const J=R[0]*(A.width??0);A.x&&A.x<J&&(m.x=J,b.x=b.x-(A.x-J));const ee=R[1]*(A.height??0);A.y&&A.y<ee&&(m.y=ee,b.y=b.y-(A.y-ee))}const Z=xf({width:m.width,prevWidth:N,height:m.height,prevHeight:E,affectsX:y.affectsX,affectsY:y.affectsY}),U={...m,direction:Z};(g==null?void 0:g(z,U))!==!1&&(u==null||u(z,U),r(A,C))}).on("end",z=>{p==null||p(z,{...m}),s==null||s()});i.call($)}function a(){i.on(".drag",null)}return{update:o,destroy:a}}var Oi={exports:{}},Xi={},qi={exports:{}},Yi={};/**
|
|
2
|
-
* @license React
|
|
3
|
-
* use-sync-external-store-shim.production.js
|
|
4
|
-
*
|
|
5
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
6
|
-
*
|
|
7
|
-
* This source code is licensed under the MIT license found in the
|
|
8
|
-
* LICENSE file in the root directory of this source tree.
|
|
9
|
-
*/var tt=M;function Ef(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var Sf=typeof Object.is=="function"?Object.is:Ef,kf=tt.useState,Cf=tt.useEffect,jf=tt.useLayoutEffect,Mf=tt.useDebugValue;function $f(e,t){var n=t(),r=kf({inst:{value:n,getSnapshot:t}}),s=r[0].inst,i=r[1];return jf(function(){s.value=n,s.getSnapshot=t,Tn(s)&&i({inst:s})},[e,n,t]),Cf(function(){return Tn(s)&&i({inst:s}),e(function(){Tn(s)&&i({inst:s})})},[e]),Mf(n),n}function Tn(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!Sf(e,n)}catch{return!0}}function If(e,t){return t()}var zf=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?If:$f;Yi.useSyncExternalStore=tt.useSyncExternalStore!==void 0?tt.useSyncExternalStore:zf;qi.exports=Yi;var Af=qi.exports;/**
|
|
10
|
-
* @license React
|
|
11
|
-
* use-sync-external-store-shim/with-selector.production.js
|
|
12
|
-
*
|
|
13
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
14
|
-
*
|
|
15
|
-
* This source code is licensed under the MIT license found in the
|
|
16
|
-
* LICENSE file in the root directory of this source tree.
|
|
17
|
-
*/var pn=M,Tf=Af;function Pf(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var Df=typeof Object.is=="function"?Object.is:Pf,Rf=Tf.useSyncExternalStore,Hf=pn.useRef,Lf=pn.useEffect,Bf=pn.useMemo,Vf=pn.useDebugValue;Xi.useSyncExternalStoreWithSelector=function(e,t,n,r,s){var i=Hf(null);if(i.current===null){var o={hasValue:!1,value:null};i.current=o}else o=i.current;i=Bf(function(){function c(p){if(!l){if(l=!0,d=p,p=r(p),s!==void 0&&o.hasValue){var g=o.value;if(s(g,p))return f=g}return f=p}if(g=f,Df(d,p))return g;var m=r(p);return s!==void 0&&s(g,m)?(d=p,g):(d=p,f=m)}var l=!1,d,f,u=n===void 0?null:n;return[function(){return c(t())},u===null?void 0:function(){return c(u())}]},[t,n,r,s]);var a=Rf(e,i[0],i[1]);return Lf(function(){o.hasValue=!0,o.value=a},[a]),Vf(a),a};Oi.exports=Xi;var Ff=Oi.exports;const Of=Ha(Ff),Xf={},as=e=>{let t;const n=new Set,r=(d,f)=>{const u=typeof d=="function"?d(t):d;if(!Object.is(u,t)){const p=t;t=f??(typeof u!="object"||u===null)?u:Object.assign({},t,u),n.forEach(g=>g(t,p))}},s=()=>t,c={setState:r,getState:s,getInitialState:()=>l,subscribe:d=>(n.add(d),()=>n.delete(d)),destroy:()=>{(Xf?"production":void 0)!=="production"&&console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),n.clear()}},l=t=e(r,s,c);return c},qf=e=>e?as(e):as,{useDebugValue:Yf}=La,{useSyncExternalStoreWithSelector:Wf}=Of,Kf=e=>e;function Wi(e,t=Kf,n){const r=Wf(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return Yf(r),r}const cs=(e,t)=>{const n=qf(e),r=(s,i=t)=>Wi(n,s,i);return Object.assign(r,n),r},Gf=(e,t)=>e?cs(e,t):cs;function re(e,t){if(Object.is(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(const[r,s]of e)if(!Object.is(s,t.get(r)))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(const r of e)if(!t.has(r))return!1;return!0}const n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(const r of n)if(!Object.prototype.hasOwnProperty.call(t,r)||!Object.is(e[r],t[r]))return!1;return!0}const gn=M.createContext(null),Uf=gn.Provider,Ki=Ee.error001();function Q(e,t){const n=M.useContext(gn);if(n===null)throw new Error(Ki);return Wi(n,e,t)}function te(){const e=M.useContext(gn);if(e===null)throw new Error(Ki);return M.useMemo(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe}),[e])}const ls={display:"none"},Zf={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},Gi="react-flow__node-desc",Ui="react-flow__edge-desc",Qf="react-flow__aria-live",Jf=e=>e.ariaLiveMessage;function eh({rfId:e}){const t=Q(Jf);return h.jsx("div",{id:`${Qf}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:Zf,children:t})}function th({rfId:e,disableKeyboardA11y:t}){return h.jsxs(h.Fragment,{children:[h.jsxs("div",{id:`${Gi}-${e}`,style:ls,children:["Press enter or space to select a node.",!t&&"You can then use the arrow keys to move the node around."," Press delete to remove it and escape to cancel."," "]}),h.jsx("div",{id:`${Ui}-${e}`,style:ls,children:"Press enter or space to select an edge. You can then press delete to remove it or escape to cancel."}),!t&&h.jsx(eh,{rfId:e})]})}const nh=e=>e.userSelectionActive?"none":"all",yr=M.forwardRef(({position:e="top-left",children:t,className:n,style:r,...s},i)=>{const o=Q(nh),a=`${e}`.split("-");return h.jsx("div",{className:se(["react-flow__panel",n,...a]),style:{...r,pointerEvents:o},ref:i,...s,children:t})});function rh({proOptions:e,position:t="bottom-right"}){return e!=null&&e.hideAttribution?null:h.jsx(yr,{position:t,className:"react-flow__attribution","data-message":"Please only hide this attribution when you are subscribed to React Flow Pro: https://pro.reactflow.dev",children:h.jsx("a",{href:"https://reactflow.dev",target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution",children:"React Flow"})})}const sh=e=>{const t=[],n=[];for(const[,r]of e.nodeLookup)r.selected&&t.push(r.internals.userNode);for(const[,r]of e.edgeLookup)r.selected&&n.push(r);return{selectedNodes:t,selectedEdges:n}},Ht=e=>e.id;function ih(e,t){return re(e.selectedNodes.map(Ht),t.selectedNodes.map(Ht))&&re(e.selectedEdges.map(Ht),t.selectedEdges.map(Ht))}function oh({onSelectionChange:e}){const t=te(),{selectedNodes:n,selectedEdges:r}=Q(sh,ih);return M.useEffect(()=>{const s={nodes:n,edges:r};e==null||e(s),t.getState().onSelectionChangeHandlers.forEach(i=>i(s))},[n,r,e]),null}const ah=e=>!!e.onSelectionChangeHandlers;function ch({onSelectionChange:e}){const t=Q(ah);return e||t?h.jsx(oh,{onSelectionChange:e}):null}const Zi=[0,0],lh={x:0,y:0,zoom:1},uh=["nodes","edges","defaultNodes","defaultEdges","onConnect","onConnectStart","onConnectEnd","onClickConnectStart","onClickConnectEnd","nodesDraggable","nodesConnectable","nodesFocusable","edgesFocusable","edgesReconnectable","elevateNodesOnSelect","elevateEdgesOnSelect","minZoom","maxZoom","nodeExtent","onNodesChange","onEdgesChange","elementsSelectable","connectionMode","snapGrid","snapToGrid","translateExtent","connectOnClick","defaultEdgeOptions","fitView","fitViewOptions","onNodesDelete","onEdgesDelete","onDelete","onNodeDrag","onNodeDragStart","onNodeDragStop","onSelectionDrag","onSelectionDragStart","onSelectionDragStop","onMoveStart","onMove","onMoveEnd","noPanClassName","nodeOrigin","autoPanOnConnect","autoPanOnNodeDrag","onError","connectionRadius","isValidConnection","selectNodesOnDrag","nodeDragThreshold","onBeforeDelete","debug","autoPanSpeed","paneClickDistance"],us=[...uh,"rfId"],dh=e=>({setNodes:e.setNodes,setEdges:e.setEdges,setMinZoom:e.setMinZoom,setMaxZoom:e.setMaxZoom,setTranslateExtent:e.setTranslateExtent,setNodeExtent:e.setNodeExtent,reset:e.reset,setDefaultNodesAndEdges:e.setDefaultNodesAndEdges,setPaneClickDistance:e.setPaneClickDistance}),ds={translateExtent:vt,nodeOrigin:Zi,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1",paneClickDistance:0};function fh(e){const{setNodes:t,setEdges:n,setMinZoom:r,setMaxZoom:s,setTranslateExtent:i,setNodeExtent:o,reset:a,setDefaultNodesAndEdges:c,setPaneClickDistance:l}=Q(dh,re),d=te();M.useEffect(()=>(c(e.defaultNodes,e.defaultEdges),()=>{f.current=ds,a()}),[]);const f=M.useRef(ds);return M.useEffect(()=>{for(const u of us){const p=e[u],g=f.current[u];p!==g&&(typeof e[u]>"u"||(u==="nodes"?t(p):u==="edges"?n(p):u==="minZoom"?r(p):u==="maxZoom"?s(p):u==="translateExtent"?i(p):u==="nodeExtent"?o(p):u==="paneClickDistance"?l(p):u==="fitView"?d.setState({fitViewOnInit:p}):u==="fitViewOptions"?d.setState({fitViewOnInitOptions:p}):d.setState({[u]:p})))}f.current=e},us.map(u=>e[u])),null}function fs(){return typeof window>"u"||!window.matchMedia?null:window.matchMedia("(prefers-color-scheme: dark)")}function hh(e){var r;const[t,n]=M.useState(e==="system"?null:e);return M.useEffect(()=>{if(e!=="system"){n(e);return}const s=fs(),i=()=>n(s!=null&&s.matches?"dark":"light");return i(),s==null||s.addEventListener("change",i),()=>{s==null||s.removeEventListener("change",i)}},[e]),t!==null?t:(r=fs())!=null&&r.matches?"dark":"light"}const hs=typeof document<"u"?document:null;function Et(e=null,t={target:hs,actInsideInputWithModifier:!0}){const[n,r]=M.useState(!1),s=M.useRef(!1),i=M.useRef(new Set([])),[o,a]=M.useMemo(()=>{if(e!==null){const l=(Array.isArray(e)?e:[e]).filter(f=>typeof f=="string").map(f=>f.replace("+",`
|
|
18
|
-
`).replace(`
|
|
19
|
-
|
|
20
|
-
`,`
|
|
21
|
-
+`).split(`
|
|
22
|
-
`)),d=l.reduce((f,u)=>f.concat(...u),[]);return[l,d]}return[[],[]]},[e]);return M.useEffect(()=>{const c=(t==null?void 0:t.target)||hs;if(e!==null){const l=u=>{if(s.current=u.ctrlKey||u.metaKey||u.shiftKey,(!s.current||s.current&&!t.actInsideInputWithModifier)&&Zn(u))return!1;const g=gs(u.code,a);i.current.add(u[g]),ps(o,i.current,!1)&&(u.preventDefault(),r(!0))},d=u=>{if((!s.current||s.current&&!t.actInsideInputWithModifier)&&Zn(u))return!1;const g=gs(u.code,a);ps(o,i.current,!0)?(r(!1),i.current.clear()):i.current.delete(u[g]),u.key==="Meta"&&i.current.clear(),s.current=!1},f=()=>{i.current.clear(),r(!1)};return c==null||c.addEventListener("keydown",l),c==null||c.addEventListener("keyup",d),window.addEventListener("blur",f),window.addEventListener("contextmenu",f),()=>{c==null||c.removeEventListener("keydown",l),c==null||c.removeEventListener("keyup",d),window.removeEventListener("blur",f),window.removeEventListener("contextmenu",f)}}},[e,r]),n}function ps(e,t,n){return e.filter(r=>n||r.length===t.size).some(r=>r.every(s=>t.has(s)))}function gs(e,t){return t.includes(e)?"code":"key"}const ph=()=>{const e=te();return M.useMemo(()=>({zoomIn:t=>{const{panZoom:n}=e.getState();return n?n.scaleBy(1.2,{duration:t==null?void 0:t.duration}):Promise.resolve(!1)},zoomOut:t=>{const{panZoom:n}=e.getState();return n?n.scaleBy(1/1.2,{duration:t==null?void 0:t.duration}):Promise.resolve(!1)},zoomTo:(t,n)=>{const{panZoom:r}=e.getState();return r?r.scaleTo(t,{duration:n==null?void 0:n.duration}):Promise.resolve(!1)},getZoom:()=>e.getState().transform[2],setViewport:async(t,n)=>{const{transform:[r,s,i],panZoom:o}=e.getState();return o?(await o.setViewport({x:t.x??r,y:t.y??s,zoom:t.zoom??i},{duration:n==null?void 0:n.duration}),Promise.resolve(!0)):Promise.resolve(!1)},getViewport:()=>{const[t,n,r]=e.getState().transform;return{x:t,y:n,zoom:r}},fitView:t=>{const{nodeLookup:n,minZoom:r,maxZoom:s,panZoom:i,domNode:o}=e.getState();if(!i||!o)return Promise.resolve(!1);const a=Kn(n,t),{width:c,height:l}=fn(o);return Gn({nodes:a,width:c,height:l,minZoom:r,maxZoom:s,panZoom:i},t)},setCenter:async(t,n,r)=>{const{width:s,height:i,maxZoom:o,panZoom:a}=e.getState(),c=typeof(r==null?void 0:r.zoom)<"u"?r.zoom:o,l=s/2-t*c,d=i/2-n*c;return a?(await a.setViewport({x:l,y:d,zoom:c},{duration:r==null?void 0:r.duration}),Promise.resolve(!0)):Promise.resolve(!1)},fitBounds:async(t,n)=>{const{width:r,height:s,minZoom:i,maxZoom:o,panZoom:a}=e.getState(),c=hr(t,r,s,i,o,(n==null?void 0:n.padding)??.1);return a?(await a.setViewport(c,{duration:n==null?void 0:n.duration}),Promise.resolve(!0)):Promise.resolve(!1)},screenToFlowPosition:(t,n={snapToGrid:!0})=>{const{transform:r,snapGrid:s,domNode:i}=e.getState();if(!i)return t;const{x:o,y:a}=i.getBoundingClientRect(),c={x:t.x-o,y:t.y-a};return Mt(c,r,n.snapToGrid,s)},flowToScreenPosition:t=>{const{transform:n,domNode:r}=e.getState();if(!r)return t;const{x:s,y:i}=r.getBoundingClientRect(),o=Ei(t,n);return{x:o.x+s,y:o.y+i}}}),[])};function Qi(e,t){const n=[],r=new Map,s=[];for(const i of e)if(i.type==="add"){s.push(i);continue}else if(i.type==="remove"||i.type==="replace")r.set(i.id,[i]);else{const o=r.get(i.id);o?o.push(i):r.set(i.id,[i])}for(const i of t){const o=r.get(i.id);if(!o){n.push(i);continue}if(o[0].type==="remove")continue;if(o[0].type==="replace"){n.push({...o[0].item});continue}const a={...i};for(const c of o)gh(c,a);n.push(a)}return s.length&&s.forEach(i=>{i.index!==void 0?n.splice(i.index,0,{...i.item}):n.push({...i.item})}),n}function gh(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??(t.measured={}),t.measured.width=e.dimensions.width,t.measured.height=e.dimensions.height,e.setAttributes&&(t.width=e.dimensions.width,t.height=e.dimensions.height)),typeof e.resizing=="boolean"&&(t.resizing=e.resizing);break}}}function mh(e,t){return Qi(e,t)}function xh(e,t){return Qi(e,t)}function Pe(e,t){return{id:e,type:"select",selected:t}}function qe(e,t=new Set,n=!1){const r=[];for(const[s,i]of e){const o=t.has(s);!(i.selected===void 0&&!o)&&i.selected!==o&&(n&&(i.selected=o),r.push(Pe(i.id,o)))}return r}function ms({items:e=[],lookup:t}){var s;const n=[],r=new Map(e.map(i=>[i.id,i]));for(const[i,o]of e.entries()){const a=t.get(o.id),c=((s=a==null?void 0:a.internals)==null?void 0:s.userNode)??a;c!==void 0&&c!==o&&n.push({id:o.id,item:o,type:"replace"}),c===void 0&&n.push({item:o,type:"add",index:i})}for(const[i]of t)r.get(i)===void 0&&n.push({id:i,type:"remove"});return n}function xs(e){return{id:e.id,type:"remove"}}const ys=e=>zd(e),yh=e=>yi(e);function Ji(e){return M.forwardRef(e)}const wh=typeof window<"u"?M.useLayoutEffect:M.useEffect;function ws(e){const[t,n]=M.useState(BigInt(0)),[r]=M.useState(()=>vh(()=>n(s=>s+BigInt(1))));return wh(()=>{const s=r.get();s.length&&(e(s),r.reset())},[t]),r}function vh(e){let t=[];return{get:()=>t,reset:()=>{t=[]},push:n=>{t.push(n),e()}}}const eo=M.createContext(null);function bh({children:e}){const t=te(),n=M.useCallback(a=>{const{nodes:c=[],setNodes:l,hasDefaultNodes:d,onNodesChange:f,nodeLookup:u}=t.getState();let p=c;for(const g of a)p=typeof g=="function"?g(p):g;d?l(p):f&&f(ms({items:p,lookup:u}))},[]),r=ws(n),s=M.useCallback(a=>{const{edges:c=[],setEdges:l,hasDefaultEdges:d,onEdgesChange:f,edgeLookup:u}=t.getState();let p=c;for(const g of a)p=typeof g=="function"?g(p):g;d?l(p):f&&f(ms({items:p,lookup:u}))},[]),i=ws(s),o=M.useMemo(()=>({nodeQueue:r,edgeQueue:i}),[]);return h.jsx(eo.Provider,{value:o,children:e})}function Nh(){const e=M.useContext(eo);if(!e)throw new Error("useBatchContext must be used within a BatchProvider");return e}const _h=e=>!!e.panZoom;function wr(){const e=ph(),t=te(),n=Nh(),r=Q(_h),s=M.useMemo(()=>{const i=f=>t.getState().nodeLookup.get(f),o=f=>{n.nodeQueue.push(f)},a=f=>{n.edgeQueue.push(f)},c=f=>{var y,S;const{nodeLookup:u,nodeOrigin:p}=t.getState(),g=ys(f)?f:u.get(f.id),m=g.parentId?ki(g.position,g.measured,g.parentId,u,p):g.position,b={...g,position:m,width:((y=g.measured)==null?void 0:y.width)??g.width,height:((S=g.measured)==null?void 0:S.height)??g.height};return Je(b)},l=(f,u,p={replace:!1})=>{o(g=>g.map(m=>{if(m.id===f){const b=typeof u=="function"?u(m):u;return p.replace&&ys(b)?b:{...m,...b}}return m}))},d=(f,u,p={replace:!1})=>{a(g=>g.map(m=>{if(m.id===f){const b=typeof u=="function"?u(m):u;return p.replace&&yh(b)?b:{...m,...b}}return m}))};return{getNodes:()=>t.getState().nodes.map(f=>({...f})),getNode:f=>{var u;return(u=i(f))==null?void 0:u.internals.userNode},getInternalNode:i,getEdges:()=>{const{edges:f=[]}=t.getState();return f.map(u=>({...u}))},getEdge:f=>t.getState().edgeLookup.get(f),setNodes:o,setEdges:a,addNodes:f=>{const u=Array.isArray(f)?f:[f];n.nodeQueue.push(p=>[...p,...u])},addEdges:f=>{const u=Array.isArray(f)?f:[f];n.edgeQueue.push(p=>[...p,...u])},toObject:()=>{const{nodes:f=[],edges:u=[],transform:p}=t.getState(),[g,m,b]=p;return{nodes:f.map(y=>({...y})),edges:u.map(y=>({...y})),viewport:{x:g,y:m,zoom:b}}},deleteElements:async({nodes:f=[],edges:u=[]})=>{const{nodes:p,edges:g,onNodesDelete:m,onEdgesDelete:b,triggerNodeChanges:y,triggerEdgeChanges:S,onDelete:v,onBeforeDelete:w}=t.getState(),{nodes:j,edges:P}=await Pd({nodesToRemove:f,edgesToRemove:u,nodes:p,edges:g,onBeforeDelete:w}),k=P.length>0,$=j.length>0;if(k){const z=P.map(xs);b==null||b(P),S(z)}if($){const z=j.map(xs);m==null||m(j),y(z)}return($||k)&&(v==null||v({nodes:j,edges:P})),{deletedNodes:j,deletedEdges:P}},getIntersectingNodes:(f,u=!0,p)=>{const g=Zr(f),m=g?f:c(f),b=p!==void 0;return m?(p||t.getState().nodes).filter(y=>{const S=t.getState().nodeLookup.get(y.id);if(S&&!g&&(y.id===f.id||!S.internals.positionAbsolute))return!1;const v=Je(b?y:S),w=Nt(v,m);return u&&w>0||w>=m.width*m.height}):[]},isNodeIntersecting:(f,u,p=!0)=>{const m=Zr(f)?f:c(f);if(!m)return!1;const b=Nt(m,u);return p&&b>0||b>=m.width*m.height},updateNode:l,updateNodeData:(f,u,p={replace:!1})=>{l(f,g=>{const m=typeof u=="function"?u(g):u;return p.replace?{...g,data:m}:{...g,data:{...g.data,...m}}},p)},updateEdge:d,updateEdgeData:(f,u,p={replace:!1})=>{d(f,g=>{const m=typeof u=="function"?u(g):u;return p.replace?{...g,data:m}:{...g,data:{...g.data,...m}}},p)},getNodesBounds:f=>{const{nodeLookup:u,nodeOrigin:p}=t.getState();return Ad(f,{nodeLookup:u,nodeOrigin:p})},getHandleConnections:({type:f,id:u,nodeId:p})=>{var g;return Array.from(((g=t.getState().connectionLookup.get(`${p}-${f}-${u??null}`))==null?void 0:g.values())??[])}}},[]);return M.useMemo(()=>({...s,...e,viewportInitialized:r}),[r])}const vs=e=>e.selected,Eh={actInsideInputWithModifier:!1},Sh=typeof window<"u"?window:void 0;function kh({deleteKeyCode:e,multiSelectionKeyCode:t}){const n=te(),{deleteElements:r}=wr(),s=Et(e,Eh),i=Et(t,{target:Sh});M.useEffect(()=>{if(s){const{edges:o,nodes:a}=n.getState();r({nodes:a.filter(vs),edges:o.filter(vs)}),n.setState({nodesSelectionActive:!1})}},[s]),M.useEffect(()=>{n.setState({multiSelectionActive:i})},[i])}function Ch(e){const t=te();M.useEffect(()=>{const n=()=>{var s,i;if(!e.current)return!1;const r=fn(e.current);(r.height===0||r.width===0)&&((i=(s=t.getState()).onError)==null||i.call(s,"004",Ee.error004())),t.setState({width:r.width||500,height:r.height||500})};if(e.current){n(),window.addEventListener("resize",n);const r=new ResizeObserver(()=>n());return r.observe(e.current),()=>{window.removeEventListener("resize",n),r&&e.current&&r.unobserve(e.current)}}},[])}const mn={position:"absolute",width:"100%",height:"100%",top:0,left:0},jh=e=>({userSelectionActive:e.userSelectionActive,lib:e.lib});function Mh({onPaneContextMenu:e,zoomOnScroll:t=!0,zoomOnPinch:n=!0,panOnScroll:r=!1,panOnScrollSpeed:s=.5,panOnScrollMode:i=He.Free,zoomOnDoubleClick:o=!0,panOnDrag:a=!0,defaultViewport:c,translateExtent:l,minZoom:d,maxZoom:f,zoomActivationKeyCode:u,preventScrolling:p=!0,children:g,noWheelClassName:m,noPanClassName:b,onViewportChange:y,isControlledViewport:S,paneClickDistance:v}){const w=te(),j=M.useRef(null),{userSelectionActive:P,lib:k}=Q(jh,re),$=Et(u),z=M.useRef();Ch(j);const T=M.useCallback(H=>{y==null||y({x:H[0],y:H[1],zoom:H[2]}),S||w.setState({transform:H})},[y,S]);return M.useEffect(()=>{if(j.current){z.current=mf({domNode:j.current,minZoom:d,maxZoom:f,translateExtent:l,viewport:c,paneClickDistance:v,onDraggingChange:x=>w.setState({paneDragging:x}),onPanZoomStart:(x,C)=>{const{onViewportChangeStart:_,onMoveStart:I}=w.getState();I==null||I(x,C),_==null||_(C)},onPanZoom:(x,C)=>{const{onViewportChange:_,onMove:I}=w.getState();I==null||I(x,C),_==null||_(C)},onPanZoomEnd:(x,C)=>{const{onViewportChangeEnd:_,onMoveEnd:I}=w.getState();I==null||I(x,C),_==null||_(C)}});const{x:H,y:L,zoom:D}=z.current.getViewport();return w.setState({panZoom:z.current,transform:[H,L,D],domNode:j.current.closest(".react-flow")}),()=>{var x;(x=z.current)==null||x.destroy()}}},[]),M.useEffect(()=>{var H;(H=z.current)==null||H.update({onPaneContextMenu:e,zoomOnScroll:t,zoomOnPinch:n,panOnScroll:r,panOnScrollSpeed:s,panOnScrollMode:i,zoomOnDoubleClick:o,panOnDrag:a,zoomActivationKeyPressed:$,preventScrolling:p,noPanClassName:b,userSelectionActive:P,noWheelClassName:m,lib:k,onTransformChange:T})},[e,t,n,r,s,i,o,a,$,p,b,P,m,k,T]),h.jsx("div",{className:"react-flow__renderer",ref:j,style:mn,children:g})}const $h=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function Ih(){const{userSelectionActive:e,userSelectionRect:t}=Q($h,re);return e&&t?h.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 Pn=(e,t)=>n=>{n.target===t.current&&(e==null||e(n))},zh=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,dragging:e.paneDragging});function Ah({isSelecting:e,selectionKeyPressed:t,selectionMode:n=bt.Full,panOnDrag:r,selectionOnDrag:s,onSelectionStart:i,onSelectionEnd:o,onPaneClick:a,onPaneContextMenu:c,onPaneScroll:l,onPaneMouseEnter:d,onPaneMouseMove:f,onPaneMouseLeave:u,children:p}){const g=M.useRef(null),m=te(),b=M.useRef(0),y=M.useRef(0),S=M.useRef(),v=M.useRef(new Map),{userSelectionActive:w,elementsSelectable:j,dragging:P}=Q(zh,re),k=j&&(e||w),$=M.useRef(!1),z=M.useRef(!1),T=()=>{m.setState({userSelectionActive:!1,userSelectionRect:null}),b.current=0,y.current=0},H=N=>{if($.current){$.current=!1;return}a==null||a(N),m.getState().resetSelectedElements(),m.setState({nodesSelectionActive:!1})},L=N=>{if(Array.isArray(r)&&(r!=null&&r.includes(2))){N.preventDefault();return}c==null||c(N)},D=l?N=>l(N):void 0,x=N=>{var F,O,Y,K;const{resetSelectedElements:E,domNode:A,edgeLookup:R}=m.getState();if(S.current=A==null?void 0:A.getBoundingClientRect(),!j||!e||N.button!==0||N.target!==g.current||!S.current)return;(O=(F=N.target)==null?void 0:F.setPointerCapture)==null||O.call(F,N.pointerId),z.current=!0,$.current=!1,v.current=new Map;for(const[V,G]of R)v.current.set(G.source,((Y=v.current.get(G.source))==null?void 0:Y.add(V))||new Set([V])),v.current.set(G.target,((K=v.current.get(G.target))==null?void 0:K.add(V))||new Set([V]));const{x:B,y:q}=ve(N.nativeEvent,S.current);E(),m.setState({userSelectionRect:{width:0,height:0,startX:B,startY:q,x:B,y:q}}),i==null||i(N)},C=N=>{const{userSelectionRect:E,edgeLookup:A,transform:R,nodeLookup:B,triggerNodeChanges:q,triggerEdgeChanges:F}=m.getState();if(!S.current||!E)return;$.current=!0;const{x:O,y:Y}=ve(N.nativeEvent,S.current),{startX:K,startY:V}=E,G={startX:K,startY:V,x:O<K?O:K,y:Y<V?Y:V,width:Math.abs(O-K),height:Math.abs(Y-V)},Z=wi(B,G,R,n===bt.Partial,!0),U=new Set,W=new Set;for(const J of Z){W.add(J.id);const ee=v.current.get(J.id);if(ee)for(const ie of ee)U.add(ie)}if(b.current!==W.size){b.current=W.size;const J=qe(B,W,!0);q(J)}if(y.current!==U.size){y.current=U.size;const J=qe(A,U);F(J)}m.setState({userSelectionRect:G,userSelectionActive:!0,nodesSelectionActive:!1})},_=N=>{var A,R;if(N.button!==0||!z.current)return;(R=(A=N.target)==null?void 0:A.releasePointerCapture)==null||R.call(A,N.pointerId);const{userSelectionRect:E}=m.getState();!w&&E&&N.target===g.current&&(H==null||H(N)),b.current>0&&m.setState({nodesSelectionActive:!0}),T(),o==null||o(N),(t||s)&&($.current=!1),z.current=!1},I=r===!0||Array.isArray(r)&&r.includes(0);return h.jsxs("div",{className:se(["react-flow__pane",{draggable:I,dragging:P,selection:e}]),onClick:k?void 0:Pn(H,g),onContextMenu:Pn(L,g),onWheel:Pn(D,g),onPointerEnter:k?void 0:d,onPointerDown:k?x:f,onPointerMove:k?C:f,onPointerUp:k?_:void 0,onPointerLeave:u,ref:g,style:mn,children:[p,h.jsx(Ih,{})]})}function nr({id:e,store:t,unselect:n=!1,nodeRef:r}){const{addSelectedNodes:s,unselectNodesAndEdges:i,multiSelectionActive:o,nodeLookup:a,onError:c}=t.getState(),l=a.get(e);if(!l){c==null||c("012",Ee.error012(e));return}t.setState({nodesSelectionActive:!1}),l.selected?(n||l.selected&&o)&&(i({nodes:[l],edges:[]}),requestAnimationFrame(()=>{var d;return(d=r==null?void 0:r.current)==null?void 0:d.blur()})):s([e])}function to({nodeRef:e,disabled:t=!1,noDragClassName:n,handleSelector:r,nodeId:s,isSelectable:i,nodeClickDistance:o}){const a=te(),[c,l]=M.useState(!1),d=M.useRef();return M.useEffect(()=>{d.current=tf({getStoreItems:()=>a.getState(),onNodeMouseDown:f=>{nr({id:f,store:a,nodeRef:e})},onDragStart:()=>{l(!0)},onDragStop:()=>{l(!1)}})},[]),M.useEffect(()=>{var f,u;if(t)(f=d.current)==null||f.destroy();else if(e.current)return(u=d.current)==null||u.update({noDragClassName:n,handleSelector:r,domNode:e.current,isSelectable:i,nodeId:s,nodeClickDistance:o}),()=>{var p;(p=d.current)==null||p.destroy()}},[n,r,t,i,e,s]),c}const Th=e=>t=>t.selected&&(t.draggable||e&&typeof t.draggable>"u");function no(){const e=te();return M.useCallback(n=>{const{nodeExtent:r,snapToGrid:s,snapGrid:i,nodesDraggable:o,onError:a,updateNodePositions:c,nodeLookup:l,nodeOrigin:d}=e.getState(),f=new Map,u=Th(o),p=s?i[0]:5,g=s?i[1]:5,m=n.direction.x*p*n.factor,b=n.direction.y*g*n.factor;for(const[,y]of l){if(!u(y))continue;let S={x:y.internals.positionAbsolute.x+m,y:y.internals.positionAbsolute.y+b};s&&(S=dn(S,i));const{position:v,positionAbsolute:w}=vi({nodeId:y.id,nextPosition:S,nodeLookup:l,nodeExtent:r,nodeOrigin:d,onError:a});y.position=v,y.internals.positionAbsolute=w,f.set(y.id,y)}c(f)},[])}const vr=M.createContext(null),Ph=vr.Provider;vr.Consumer;const ro=()=>M.useContext(vr),Dh=e=>({connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName,rfId:e.rfId}),Rh=(e,t,n)=>r=>{const{connectionClickStartHandle:s,connectionMode:i,connection:o}=r,{fromHandle:a,toHandle:c,isValid:l}=o,d=(c==null?void 0:c.nodeId)===e&&(c==null?void 0:c.id)===t&&(c==null?void 0:c.type)===n;return{connectingFrom:(a==null?void 0:a.nodeId)===e&&(a==null?void 0:a.id)===t&&(a==null?void 0:a.type)===n,connectingTo:d,clickConnecting:(s==null?void 0:s.nodeId)===e&&(s==null?void 0:s.id)===t&&(s==null?void 0:s.type)===n,isPossibleEndHandle:i===Ze.Strict?(a==null?void 0:a.type)!==n:e!==(a==null?void 0:a.nodeId)||t!==(a==null?void 0:a.id),connectionInProcess:!!a,valid:d&&l}};function Hh({type:e="source",position:t=X.Top,isValidConnection:n,isConnectable:r=!0,isConnectableStart:s=!0,isConnectableEnd:i=!0,id:o,onConnect:a,children:c,className:l,onMouseDown:d,onTouchStart:f,...u},p){var x,C;const g=o||null,m=e==="target",b=te(),y=ro(),{connectOnClick:S,noPanClassName:v,rfId:w}=Q(Dh,re),{connectingFrom:j,connectingTo:P,clickConnecting:k,isPossibleEndHandle:$,connectionInProcess:z,valid:T}=Q(Rh(y,g,e),re);y||(C=(x=b.getState()).onError)==null||C.call(x,"010",Ee.error010());const H=_=>{const{defaultEdgeOptions:I,onConnect:N,hasDefaultEdges:E}=b.getState(),A={...I,..._};if(E){const{edges:R,setEdges:B}=b.getState();B(Fd(A,R))}N==null||N(A),a==null||a(A)},L=_=>{if(!y)return;const I=ji(_.nativeEvent);if(s&&(I&&_.button===0||!I)){const N=b.getState();tr.onPointerDown(_.nativeEvent,{autoPanOnConnect:N.autoPanOnConnect,connectionMode:N.connectionMode,connectionRadius:N.connectionRadius,domNode:N.domNode,nodeLookup:N.nodeLookup,lib:N.lib,isTarget:m,handleId:g,nodeId:y,flowId:N.rfId,panBy:N.panBy,cancelConnection:N.cancelConnection,onConnectStart:N.onConnectStart,onConnectEnd:N.onConnectEnd,updateConnection:N.updateConnection,onConnect:H,isValidConnection:n||N.isValidConnection,getTransform:()=>b.getState().transform,getFromHandle:()=>b.getState().connection.fromHandle,autoPanSpeed:N.autoPanSpeed})}I?d==null||d(_):f==null||f(_)},D=_=>{const{onClickConnectStart:I,onClickConnectEnd:N,connectionClickStartHandle:E,connectionMode:A,isValidConnection:R,lib:B,rfId:q,nodeLookup:F,connection:O}=b.getState();if(!y||!E&&!s)return;if(!E){I==null||I(_.nativeEvent,{nodeId:y,handleId:g,handleType:e}),b.setState({connectionClickStartHandle:{nodeId:y,type:e,id:g}});return}const Y=Ci(_.target),K=n||R,{connection:V,isValid:G}=tr.isValid(_.nativeEvent,{handle:{nodeId:y,id:g,type:e},connectionMode:A,fromNodeId:E.nodeId,fromHandleId:E.id||null,fromType:E.type,isValidConnection:K,flowId:q,doc:Y,lib:B,nodeLookup:F});G&&V&&H(V);const Z=structuredClone(O);delete Z.inProgress,Z.toPosition=Z.toHandle?Z.toHandle.position:null,N==null||N(_,Z),b.setState({connectionClickStartHandle:null})};return h.jsx("div",{"data-handleid":g,"data-nodeid":y,"data-handlepos":t,"data-id":`${w}-${y}-${g}-${e}`,className:se(["react-flow__handle",`react-flow__handle-${t}`,"nodrag",v,l,{source:!m,target:m,connectable:r,connectablestart:s,connectableend:i,clickconnecting:k,connectingfrom:j,connectingto:P,valid:T,connectionindicator:r&&(!z||$)&&(z?i:s)}]),onMouseDown:L,onTouchStart:L,onClick:S?D:void 0,ref:p,...u,children:c})}const Te=M.memo(Ji(Hh));function Lh({data:e,isConnectable:t,sourcePosition:n=X.Bottom}){return h.jsxs(h.Fragment,{children:[e==null?void 0:e.label,h.jsx(Te,{type:"source",position:n,isConnectable:t})]})}function Bh({data:e,isConnectable:t,targetPosition:n=X.Top,sourcePosition:r=X.Bottom}){return h.jsxs(h.Fragment,{children:[h.jsx(Te,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label,h.jsx(Te,{type:"source",position:r,isConnectable:t})]})}function Vh(){return null}function Fh({data:e,isConnectable:t,targetPosition:n=X.Top}){return h.jsxs(h.Fragment,{children:[h.jsx(Te,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label]})}const nn={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},bs={input:Lh,default:Bh,output:Fh,group:Vh};function Oh(e){var t,n,r,s;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??((r=e.style)==null?void 0:r.width),height:e.height??((s=e.style)==null?void 0:s.height)}}const Xh=e=>{const{width:t,height:n,x:r,y:s}=jt(e.nodeLookup,{filter:i=>!!i.selected});return{width:he(t)?t:null,height:he(n)?n:null,userSelectionActive:e.userSelectionActive,transformString:`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]}) translate(${r}px,${s}px)`}};function qh({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:n}){const r=te(),{width:s,height:i,transformString:o,userSelectionActive:a}=Q(Xh,re),c=no(),l=M.useRef(null);if(M.useEffect(()=>{var u;n||(u=l.current)==null||u.focus({preventScroll:!0})},[n]),to({nodeRef:l}),a||!s||!i)return null;const d=e?u=>{const p=r.getState().nodes.filter(g=>g.selected);e(u,p)}:void 0,f=u=>{Object.prototype.hasOwnProperty.call(nn,u.key)&&(u.preventDefault(),c({direction:nn[u.key],factor:u.shiftKey?4:1}))};return h.jsx("div",{className:se(["react-flow__nodesselection","react-flow__container",t]),style:{transform:o},children:h.jsx("div",{ref:l,className:"react-flow__nodesselection-rect",onContextMenu:d,tabIndex:n?void 0:-1,onKeyDown:n?void 0:f,style:{width:s,height:i}})})}const Ns=typeof window<"u"?window:void 0,Yh=e=>({nodesSelectionActive:e.nodesSelectionActive,userSelectionActive:e.userSelectionActive});function so({children:e,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:s,onPaneContextMenu:i,onPaneScroll:o,paneClickDistance:a,deleteKeyCode:c,selectionKeyCode:l,selectionOnDrag:d,selectionMode:f,onSelectionStart:u,onSelectionEnd:p,multiSelectionKeyCode:g,panActivationKeyCode:m,zoomActivationKeyCode:b,elementsSelectable:y,zoomOnScroll:S,zoomOnPinch:v,panOnScroll:w,panOnScrollSpeed:j,panOnScrollMode:P,zoomOnDoubleClick:k,panOnDrag:$,defaultViewport:z,translateExtent:T,minZoom:H,maxZoom:L,preventScrolling:D,onSelectionContextMenu:x,noWheelClassName:C,noPanClassName:_,disableKeyboardA11y:I,onViewportChange:N,isControlledViewport:E}){const{nodesSelectionActive:A,userSelectionActive:R}=Q(Yh),B=Et(l,{target:Ns}),q=Et(m,{target:Ns}),F=q||$,O=q||w,Y=d&&F!==!0,K=B||R||Y;return kh({deleteKeyCode:c,multiSelectionKeyCode:g}),h.jsx(Mh,{onPaneContextMenu:i,elementsSelectable:y,zoomOnScroll:S,zoomOnPinch:v,panOnScroll:O,panOnScrollSpeed:j,panOnScrollMode:P,zoomOnDoubleClick:k,panOnDrag:!B&&F,defaultViewport:z,translateExtent:T,minZoom:H,maxZoom:L,zoomActivationKeyCode:b,preventScrolling:D,noWheelClassName:C,noPanClassName:_,onViewportChange:N,isControlledViewport:E,paneClickDistance:a,children:h.jsxs(Ah,{onSelectionStart:u,onSelectionEnd:p,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:s,onPaneContextMenu:i,onPaneScroll:o,panOnDrag:F,isSelecting:!!K,selectionMode:f,selectionKeyPressed:B,selectionOnDrag:Y,children:[e,A&&h.jsx(qh,{onSelectionContextMenu:x,noPanClassName:_,disableKeyboardA11y:I})]})})}so.displayName="FlowRenderer";const Wh=M.memo(so),Kh=e=>t=>e?wi(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 Gh(e){return Q(M.useCallback(Kh(e),[e]),re)}const Uh=e=>e.updateNodeInternals;function Zh(){const e=Q(Uh),[t]=M.useState(()=>typeof ResizeObserver>"u"?null:new ResizeObserver(n=>{const r=new Map;n.forEach(s=>{const i=s.target.getAttribute("data-id");r.set(i,{id:i,nodeElement:s.target,force:!0})}),e(r)}));return M.useEffect(()=>()=>{t==null||t.disconnect()},[t]),t}function Qh({node:e,nodeType:t,hasDimensions:n,resizeObserver:r}){const s=te(),i=M.useRef(null),o=M.useRef(null),a=M.useRef(e.sourcePosition),c=M.useRef(e.targetPosition),l=M.useRef(t),d=n&&!!e.internals.handleBounds;return M.useEffect(()=>{i.current&&!e.hidden&&(!d||o.current!==i.current)&&(o.current&&(r==null||r.unobserve(o.current)),r==null||r.observe(i.current),o.current=i.current)},[d,e.hidden]),M.useEffect(()=>()=>{o.current&&(r==null||r.unobserve(o.current),o.current=null)},[]),M.useEffect(()=>{if(i.current){const f=l.current!==t,u=a.current!==e.sourcePosition,p=c.current!==e.targetPosition;(f||u||p)&&(l.current=t,a.current=e.sourcePosition,c.current=e.targetPosition,s.getState().updateNodeInternals(new Map([[e.id,{id:e.id,nodeElement:i.current,force:!0}]])))}},[e.id,t,e.sourcePosition,e.targetPosition]),i}function Jh({id:e,onClick:t,onMouseEnter:n,onMouseMove:r,onMouseLeave:s,onContextMenu:i,onDoubleClick:o,nodesDraggable:a,elementsSelectable:c,nodesConnectable:l,nodesFocusable:d,resizeObserver:f,noDragClassName:u,noPanClassName:p,disableKeyboardA11y:g,rfId:m,nodeTypes:b,nodeExtent:y,nodeClickDistance:S,onError:v}){const{node:w,internals:j,isParent:P}=Q(V=>{const G=V.nodeLookup.get(e),Z=V.parentLookup.has(e);return{node:G,internals:G.internals,isParent:Z}},re);let k=w.type||"default",$=(b==null?void 0:b[k])||bs[k];$===void 0&&(v==null||v("003",Ee.error003(k)),k="default",$=bs.default);const z=!!(w.draggable||a&&typeof w.draggable>"u"),T=!!(w.selectable||c&&typeof w.selectable>"u"),H=!!(w.connectable||l&&typeof w.connectable>"u"),L=!!(w.focusable||d&&typeof w.focusable>"u"),D=te(),x=Si(w),C=Qh({node:w,nodeType:k,hasDimensions:x,resizeObserver:f}),_=to({nodeRef:C,disabled:w.hidden||!z,noDragClassName:u,handleSelector:w.dragHandle,nodeId:e,isSelectable:T,nodeClickDistance:S}),I=no();if(w.hidden)return null;const N=Se(w),E=Oh(w),A=T||z||t||n||r||s,R=n?V=>n(V,{...j.userNode}):void 0,B=r?V=>r(V,{...j.userNode}):void 0,q=s?V=>s(V,{...j.userNode}):void 0,F=i?V=>i(V,{...j.userNode}):void 0,O=o?V=>o(V,{...j.userNode}):void 0,Y=V=>{const{selectNodesOnDrag:G,nodeDragThreshold:Z}=D.getState();T&&(!G||!z||Z>0)&&nr({id:e,store:D,nodeRef:C}),t&&t(V,{...j.userNode})},K=V=>{if(!(Zn(V.nativeEvent)||g))if(gi.includes(V.key)&&T){const G=V.key==="Escape";nr({id:e,store:D,unselect:G,nodeRef:C})}else z&&w.selected&&Object.prototype.hasOwnProperty.call(nn,V.key)&&(V.preventDefault(),D.setState({ariaLiveMessage:`Moved selected node ${V.key.replace("Arrow","").toLowerCase()}. New position, x: ${~~j.positionAbsolute.x}, y: ${~~j.positionAbsolute.y}`}),I({direction:nn[V.key],factor:V.shiftKey?4:1}))};return h.jsx("div",{className:se(["react-flow__node",`react-flow__node-${k}`,{[p]:z},w.className,{selected:w.selected,selectable:T,parent:P,draggable:z,dragging:_}]),ref:C,style:{zIndex:j.z,transform:`translate(${j.positionAbsolute.x}px,${j.positionAbsolute.y}px)`,pointerEvents:A?"all":"none",visibility:x?"visible":"hidden",...w.style,...E},"data-id":e,"data-testid":`rf__node-${e}`,onMouseEnter:R,onMouseMove:B,onMouseLeave:q,onContextMenu:F,onClick:Y,onDoubleClick:O,onKeyDown:L?K:void 0,tabIndex:L?0:void 0,role:L?"button":void 0,"aria-describedby":g?void 0:`${Gi}-${m}`,"aria-label":w.ariaLabel,children:h.jsx(Ph,{value:e,children:h.jsx($,{id:e,data:w.data,type:k,positionAbsoluteX:j.positionAbsolute.x,positionAbsoluteY:j.positionAbsolute.y,selected:w.selected,selectable:T,draggable:z,deletable:w.deletable??!0,isConnectable:H,sourcePosition:w.sourcePosition,targetPosition:w.targetPosition,dragging:_,dragHandle:w.dragHandle,zIndex:j.z,parentId:w.parentId,...N})})})}const e0=e=>({nodesDraggable:e.nodesDraggable,nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,onError:e.onError});function io(e){const{nodesDraggable:t,nodesConnectable:n,nodesFocusable:r,elementsSelectable:s,onError:i}=Q(e0,re),o=Gh(e.onlyRenderVisibleElements),a=Zh();return h.jsx("div",{className:"react-flow__nodes",style:mn,children:o.map(c=>h.jsx(Jh,{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:a,nodesDraggable:t,nodesConnectable:n,nodesFocusable:r,elementsSelectable:s,nodeClickDistance:e.nodeClickDistance,onError:i},c))})}io.displayName="NodeRenderer";const t0=M.memo(io);function n0(e){return Q(M.useCallback(n=>{if(!e)return n.edges.map(s=>s.id);const r=[];if(n.width&&n.height)for(const s of n.edges){const i=n.nodeLookup.get(s.source),o=n.nodeLookup.get(s.target);i&&o&&Ld({sourceNode:i,targetNode:o,width:n.width,height:n.height,transform:n.transform})&&r.push(s.id)}return r},[e]),re)}const r0=({color:e="none",strokeWidth:t=1})=>h.jsx("polyline",{style:{stroke:e,strokeWidth:t},strokeLinecap:"round",strokeLinejoin:"round",fill:"none",points:"-5,-4 0,0 -5,4"}),s0=({color:e="none",strokeWidth:t=1})=>h.jsx("polyline",{style:{stroke:e,fill:e,strokeWidth:t},strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"}),_s={[Jt.Arrow]:r0,[Jt.ArrowClosed]:s0};function i0(e){const t=te();return M.useMemo(()=>{var s,i;return Object.prototype.hasOwnProperty.call(_s,e)?_s[e]:((i=(s=t.getState()).onError)==null||i.call(s,"009",Ee.error009(e)),null)},[e])}const o0=({id:e,type:t,color:n,width:r=12.5,height:s=12.5,markerUnits:i="strokeWidth",strokeWidth:o,orient:a="auto-start-reverse"})=>{const c=i0(t);return c?h.jsx("marker",{className:"react-flow__arrowhead",id:e,markerWidth:`${r}`,markerHeight:`${s}`,viewBox:"-10 -10 20 20",markerUnits:i,orient:a,refX:"0",refY:"0",children:h.jsx(c,{color:n,strokeWidth:o})}):null},oo=({defaultColor:e,rfId:t})=>{const n=Q(i=>i.edges),r=Q(i=>i.defaultEdgeOptions),s=M.useMemo(()=>Wd(n,{id:t,defaultColor:e,defaultMarkerStart:r==null?void 0:r.markerStart,defaultMarkerEnd:r==null?void 0:r.markerEnd}),[n,r,t,e]);return s.length?h.jsx("svg",{className:"react-flow__marker",children:h.jsx("defs",{children:s.map(i=>h.jsx(o0,{id:i.id,type:i.type,color:i.color,width:i.width,height:i.height,markerUnits:i.markerUnits,strokeWidth:i.strokeWidth,orient:i.orient},i.id))})}):null};oo.displayName="MarkerDefinitions";var a0=M.memo(oo);function ao({x:e,y:t,label:n,labelStyle:r={},labelShowBg:s=!0,labelBgStyle:i={},labelBgPadding:o=[2,4],labelBgBorderRadius:a=2,children:c,className:l,...d}){const[f,u]=M.useState({x:1,y:0,width:0,height:0}),p=se(["react-flow__edge-textwrapper",l]),g=M.useRef(null);return M.useEffect(()=>{if(g.current){const m=g.current.getBBox();u({x:m.x,y:m.y,width:m.width,height:m.height})}},[n]),typeof n>"u"||!n?null:h.jsxs("g",{transform:`translate(${e-f.width/2} ${t-f.height/2})`,className:p,visibility:f.width?"visible":"hidden",...d,children:[s&&h.jsx("rect",{width:f.width+2*o[0],x:-o[0],y:-o[1],height:f.height+2*o[1],className:"react-flow__edge-textbg",style:i,rx:a,ry:a}),h.jsx("text",{className:"react-flow__edge-text",y:f.height/2,dy:"0.3em",ref:g,style:r,children:n}),c]})}ao.displayName="EdgeText";const c0=M.memo(ao);function xn({path:e,labelX:t,labelY:n,label:r,labelStyle:s,labelShowBg:i,labelBgStyle:o,labelBgPadding:a,labelBgBorderRadius:c,interactionWidth:l=20,...d}){return h.jsxs(h.Fragment,{children:[h.jsx("path",{...d,d:e,fill:"none",className:se(["react-flow__edge-path",d.className])}),l&&h.jsx("path",{d:e,fill:"none",strokeOpacity:0,strokeWidth:l,className:"react-flow__edge-interaction"}),r&&he(t)&&he(n)?h.jsx(c0,{x:t,y:n,label:r,labelStyle:s,labelShowBg:i,labelBgStyle:o,labelBgPadding:a,labelBgBorderRadius:c}):null]})}function Es({pos:e,x1:t,y1:n,x2:r,y2:s}){return e===X.Left||e===X.Right?[.5*(t+r),n]:[t,.5*(n+s)]}function co({sourceX:e,sourceY:t,sourcePosition:n=X.Bottom,targetX:r,targetY:s,targetPosition:i=X.Top}){const[o,a]=Es({pos:n,x1:e,y1:t,x2:r,y2:s}),[c,l]=Es({pos:i,x1:r,y1:s,x2:e,y2:t}),[d,f,u,p]=Mi({sourceX:e,sourceY:t,targetX:r,targetY:s,sourceControlX:o,sourceControlY:a,targetControlX:c,targetControlY:l});return[`M${e},${t} C${o},${a} ${c},${l} ${r},${s}`,d,f,u,p]}function lo(e){return M.memo(({id:t,sourceX:n,sourceY:r,targetX:s,targetY:i,sourcePosition:o=X.Bottom,targetPosition:a=X.Top,label:c,labelStyle:l,labelShowBg:d,labelBgStyle:f,labelBgPadding:u,labelBgBorderRadius:p,style:g,markerEnd:m,markerStart:b,interactionWidth:y})=>{const[S,v,w]=co({sourceX:n,sourceY:r,sourcePosition:o,targetX:s,targetY:i,targetPosition:a}),j=e.isInternal?void 0:t;return h.jsx(xn,{id:j,path:S,labelX:v,labelY:w,label:c,labelStyle:l,labelShowBg:d,labelBgStyle:f,labelBgPadding:u,labelBgBorderRadius:p,style:g,markerEnd:m,markerStart:b,interactionWidth:y})})}const l0=lo({isInternal:!1}),uo=lo({isInternal:!0});l0.displayName="SimpleBezierEdge";uo.displayName="SimpleBezierEdgeInternal";function fo(e){return M.memo(({id:t,sourceX:n,sourceY:r,targetX:s,targetY:i,label:o,labelStyle:a,labelShowBg:c,labelBgStyle:l,labelBgPadding:d,labelBgBorderRadius:f,style:u,sourcePosition:p=X.Bottom,targetPosition:g=X.Top,markerEnd:m,markerStart:b,pathOptions:y,interactionWidth:S})=>{const[v,w,j]=Qn({sourceX:n,sourceY:r,sourcePosition:p,targetX:s,targetY:i,targetPosition:g,borderRadius:y==null?void 0:y.borderRadius,offset:y==null?void 0:y.offset}),P=e.isInternal?void 0:t;return h.jsx(xn,{id:P,path:v,labelX:w,labelY:j,label:o,labelStyle:a,labelShowBg:c,labelBgStyle:l,labelBgPadding:d,labelBgBorderRadius:f,style:u,markerEnd:m,markerStart:b,interactionWidth:S})})}const ho=fo({isInternal:!1}),po=fo({isInternal:!0});ho.displayName="SmoothStepEdge";po.displayName="SmoothStepEdgeInternal";function go(e){return M.memo(({id:t,...n})=>{var s;const r=e.isInternal?void 0:t;return h.jsx(ho,{...n,id:r,pathOptions:M.useMemo(()=>{var i;return{borderRadius:0,offset:(i=n.pathOptions)==null?void 0:i.offset}},[(s=n.pathOptions)==null?void 0:s.offset])})})}const u0=go({isInternal:!1}),mo=go({isInternal:!0});u0.displayName="StepEdge";mo.displayName="StepEdgeInternal";function xo(e){return M.memo(({id:t,sourceX:n,sourceY:r,targetX:s,targetY:i,label:o,labelStyle:a,labelShowBg:c,labelBgStyle:l,labelBgPadding:d,labelBgBorderRadius:f,style:u,markerEnd:p,markerStart:g,interactionWidth:m})=>{const[b,y,S]=zi({sourceX:n,sourceY:r,targetX:s,targetY:i}),v=e.isInternal?void 0:t;return h.jsx(xn,{id:v,path:b,labelX:y,labelY:S,label:o,labelStyle:a,labelShowBg:c,labelBgStyle:l,labelBgPadding:d,labelBgBorderRadius:f,style:u,markerEnd:p,markerStart:g,interactionWidth:m})})}const d0=xo({isInternal:!1}),yo=xo({isInternal:!0});d0.displayName="StraightEdge";yo.displayName="StraightEdgeInternal";function wo(e){return M.memo(({id:t,sourceX:n,sourceY:r,targetX:s,targetY:i,sourcePosition:o=X.Bottom,targetPosition:a=X.Top,label:c,labelStyle:l,labelShowBg:d,labelBgStyle:f,labelBgPadding:u,labelBgBorderRadius:p,style:g,markerEnd:m,markerStart:b,pathOptions:y,interactionWidth:S})=>{const[v,w,j]=$i({sourceX:n,sourceY:r,sourcePosition:o,targetX:s,targetY:i,targetPosition:a,curvature:y==null?void 0:y.curvature}),P=e.isInternal?void 0:t;return h.jsx(xn,{id:P,path:v,labelX:w,labelY:j,label:c,labelStyle:l,labelShowBg:d,labelBgStyle:f,labelBgPadding:u,labelBgBorderRadius:p,style:g,markerEnd:m,markerStart:b,interactionWidth:S})})}const f0=wo({isInternal:!1}),vo=wo({isInternal:!0});f0.displayName="BezierEdge";vo.displayName="BezierEdgeInternal";const Ss={default:vo,straight:yo,step:mo,smoothstep:po,simplebezier:uo},ks={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null},h0=(e,t,n)=>n===X.Left?e-t:n===X.Right?e+t:e,p0=(e,t,n)=>n===X.Top?e-t:n===X.Bottom?e+t:e,Cs="react-flow__edgeupdater";function js({position:e,centerX:t,centerY:n,radius:r=10,onMouseDown:s,onMouseEnter:i,onMouseOut:o,type:a}){return h.jsx("circle",{onMouseDown:s,onMouseEnter:i,onMouseOut:o,className:se([Cs,`${Cs}-${a}`]),cx:h0(t,r,e),cy:p0(n,r,e),r,stroke:"transparent",fill:"transparent"})}function g0({isReconnectable:e,reconnectRadius:t,edge:n,sourceX:r,sourceY:s,targetX:i,targetY:o,sourcePosition:a,targetPosition:c,onReconnect:l,onReconnectStart:d,onReconnectEnd:f,setReconnecting:u,setUpdateHover:p}){const g=te(),m=(w,j)=>{if(w.button!==0)return;const{autoPanOnConnect:P,domNode:k,isValidConnection:$,connectionMode:z,connectionRadius:T,lib:H,onConnectStart:L,onConnectEnd:D,cancelConnection:x,nodeLookup:C,rfId:_,panBy:I,updateConnection:N}=g.getState(),E=j.type==="target";u(!0),d==null||d(w,n,j.type);const A=(B,q)=>{u(!1),f==null||f(B,n,j.type,q)},R=B=>l==null?void 0:l(n,B);tr.onPointerDown(w.nativeEvent,{autoPanOnConnect:P,connectionMode:z,connectionRadius:T,domNode:k,handleId:j.id,nodeId:j.nodeId,nodeLookup:C,isTarget:E,edgeUpdaterType:j.type,lib:H,flowId:_,cancelConnection:x,panBy:I,isValidConnection:$,onConnect:R,onConnectStart:L,onConnectEnd:D,onReconnectEnd:A,updateConnection:N,getTransform:()=>g.getState().transform,getFromHandle:()=>g.getState().connection.fromHandle})},b=w=>m(w,{nodeId:n.target,id:n.targetHandle??null,type:"target"}),y=w=>m(w,{nodeId:n.source,id:n.sourceHandle??null,type:"source"}),S=()=>p(!0),v=()=>p(!1);return h.jsxs(h.Fragment,{children:[(e===!0||e==="source")&&h.jsx(js,{position:a,centerX:r,centerY:s,radius:t,onMouseDown:b,onMouseEnter:S,onMouseOut:v,type:"source"}),(e===!0||e==="target")&&h.jsx(js,{position:c,centerX:i,centerY:o,radius:t,onMouseDown:y,onMouseEnter:S,onMouseOut:v,type:"target"})]})}function m0({id:e,edgesFocusable:t,edgesReconnectable:n,elementsSelectable:r,onClick:s,onDoubleClick:i,onContextMenu:o,onMouseEnter:a,onMouseMove:c,onMouseLeave:l,reconnectRadius:d,onReconnect:f,onReconnectStart:u,onReconnectEnd:p,rfId:g,edgeTypes:m,noPanClassName:b,onError:y,disableKeyboardA11y:S}){let v=Q(W=>W.edgeLookup.get(e));const w=Q(W=>W.defaultEdgeOptions);v=w?{...w,...v}:v;let j=v.type||"default",P=(m==null?void 0:m[j])||Ss[j];P===void 0&&(y==null||y("011",Ee.error011(j)),j="default",P=Ss.default);const k=!!(v.focusable||t&&typeof v.focusable>"u"),$=typeof f<"u"&&(v.reconnectable||n&&typeof v.reconnectable>"u"),z=!!(v.selectable||r&&typeof v.selectable>"u"),T=M.useRef(null),[H,L]=M.useState(!1),[D,x]=M.useState(!1),C=te(),{zIndex:_,sourceX:I,sourceY:N,targetX:E,targetY:A,sourcePosition:R,targetPosition:B}=Q(M.useCallback(W=>{const J=W.nodeLookup.get(v.source),ee=W.nodeLookup.get(v.target);if(!J||!ee)return{zIndex:v.zIndex,...ks};const ie=Yd({id:e,sourceNode:J,targetNode:ee,sourceHandle:v.sourceHandle||null,targetHandle:v.targetHandle||null,connectionMode:W.connectionMode,onError:y});return{zIndex:Hd({selected:v.selected,zIndex:v.zIndex,sourceNode:J,targetNode:ee,elevateOnSelect:W.elevateEdgesOnSelect}),...ie||ks}},[v.source,v.target,v.sourceHandle,v.targetHandle,v.selected,v.zIndex]),re),q=M.useMemo(()=>v.markerStart?`url('#${Jn(v.markerStart,g)}')`:void 0,[v.markerStart,g]),F=M.useMemo(()=>v.markerEnd?`url('#${Jn(v.markerEnd,g)}')`:void 0,[v.markerEnd,g]);if(v.hidden||I===null||N===null||E===null||A===null)return null;const O=W=>{var ke;const{addSelectedEdges:J,unselectNodesAndEdges:ee,multiSelectionActive:ie}=C.getState();z&&(C.setState({nodesSelectionActive:!1}),v.selected&&ie?(ee({nodes:[],edges:[v]}),(ke=T.current)==null||ke.blur()):J([e])),s&&s(W,v)},Y=i?W=>{i(W,{...v})}:void 0,K=o?W=>{o(W,{...v})}:void 0,V=a?W=>{a(W,{...v})}:void 0,G=c?W=>{c(W,{...v})}:void 0,Z=l?W=>{l(W,{...v})}:void 0,U=W=>{var J;if(!S&&gi.includes(W.key)&&z){const{unselectNodesAndEdges:ee,addSelectedEdges:ie}=C.getState();W.key==="Escape"?((J=T.current)==null||J.blur(),ee({edges:[v]})):ie([e])}};return h.jsx("svg",{style:{zIndex:_},children:h.jsxs("g",{className:se(["react-flow__edge",`react-flow__edge-${j}`,v.className,b,{selected:v.selected,animated:v.animated,inactive:!z&&!s,updating:H,selectable:z}]),onClick:O,onDoubleClick:Y,onContextMenu:K,onMouseEnter:V,onMouseMove:G,onMouseLeave:Z,onKeyDown:k?U:void 0,tabIndex:k?0:void 0,role:k?"button":"img","data-id":e,"data-testid":`rf__edge-${e}`,"aria-label":v.ariaLabel===null?void 0:v.ariaLabel||`Edge from ${v.source} to ${v.target}`,"aria-describedby":k?`${Ui}-${g}`:void 0,ref:T,children:[!D&&h.jsx(P,{id:e,source:v.source,target:v.target,type:v.type,selected:v.selected,animated:v.animated,selectable:z,deletable:v.deletable??!0,label:v.label,labelStyle:v.labelStyle,labelShowBg:v.labelShowBg,labelBgStyle:v.labelBgStyle,labelBgPadding:v.labelBgPadding,labelBgBorderRadius:v.labelBgBorderRadius,sourceX:I,sourceY:N,targetX:E,targetY:A,sourcePosition:R,targetPosition:B,data:v.data,style:v.style,sourceHandleId:v.sourceHandle,targetHandleId:v.targetHandle,markerStart:q,markerEnd:F,pathOptions:"pathOptions"in v?v.pathOptions:void 0,interactionWidth:v.interactionWidth}),$&&h.jsx(g0,{edge:v,isReconnectable:$,reconnectRadius:d,onReconnect:f,onReconnectStart:u,onReconnectEnd:p,sourceX:I,sourceY:N,targetX:E,targetY:A,sourcePosition:R,targetPosition:B,setUpdateHover:L,setReconnecting:x})]})})}const x0=e=>({edgesFocusable:e.edgesFocusable,edgesReconnectable:e.edgesReconnectable,elementsSelectable:e.elementsSelectable,connectionMode:e.connectionMode,onError:e.onError});function bo({defaultMarkerColor:e,onlyRenderVisibleElements:t,rfId:n,edgeTypes:r,noPanClassName:s,onReconnect:i,onEdgeContextMenu:o,onEdgeMouseEnter:a,onEdgeMouseMove:c,onEdgeMouseLeave:l,onEdgeClick:d,reconnectRadius:f,onEdgeDoubleClick:u,onReconnectStart:p,onReconnectEnd:g,disableKeyboardA11y:m}){const{edgesFocusable:b,edgesReconnectable:y,elementsSelectable:S,onError:v}=Q(x0,re),w=n0(t);return h.jsxs("div",{className:"react-flow__edges",children:[h.jsx(a0,{defaultColor:e,rfId:n}),w.map(j=>h.jsx(m0,{id:j,edgesFocusable:b,edgesReconnectable:y,elementsSelectable:S,noPanClassName:s,onReconnect:i,onContextMenu:o,onMouseEnter:a,onMouseMove:c,onMouseLeave:l,onClick:d,reconnectRadius:f,onDoubleClick:u,onReconnectStart:p,onReconnectEnd:g,rfId:n,onError:v,edgeTypes:r,disableKeyboardA11y:m},j))]})}bo.displayName="EdgeRenderer";const y0=M.memo(bo),w0=e=>`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`;function v0({children:e}){const t=Q(w0);return h.jsx("div",{className:"react-flow__viewport xyflow__viewport react-flow__container",style:{transform:t},children:e})}function b0(e){const t=wr(),n=M.useRef(!1);M.useEffect(()=>{!n.current&&t.viewportInitialized&&e&&(setTimeout(()=>e(t),1),n.current=!0)},[e,t.viewportInitialized])}const N0=e=>{var t;return(t=e.panZoom)==null?void 0:t.syncViewport};function _0(e){const t=Q(N0),n=te();return M.useEffect(()=>{e&&(t==null||t(e),n.setState({transform:[e.x,e.y,e.zoom]}))},[e,t]),null}function E0(e){return e.connection.inProgress?{...e.connection,to:Mt(e.connection.to,e.transform)}:{...e.connection}}function S0(e){return E0}function k0(e){const t=S0();return Q(t,re)}const C0=e=>({nodesConnectable:e.nodesConnectable,isValid:e.connection.isValid,inProgress:e.connection.inProgress,width:e.width,height:e.height});function j0({containerStyle:e,style:t,type:n,component:r}){const{nodesConnectable:s,width:i,height:o,isValid:a,inProgress:c}=Q(C0,re);return!(i&&s&&c)?null:h.jsx("svg",{style:e,width:i,height:o,className:"react-flow__connectionline react-flow__container",children:h.jsx("g",{className:se(["react-flow__connection",xi(a)]),children:h.jsx(No,{style:t,type:n,CustomComponent:r,isValid:a})})})}const No=({style:e,type:t=Ie.Bezier,CustomComponent:n,isValid:r})=>{const{inProgress:s,from:i,fromNode:o,fromHandle:a,fromPosition:c,to:l,toNode:d,toHandle:f,toPosition:u}=k0();if(!s)return;if(n)return h.jsx(n,{connectionLineType:t,connectionLineStyle:e,fromNode:o,fromHandle:a,fromX:i.x,fromY:i.y,toX:l.x,toY:l.y,fromPosition:c,toPosition:u,connectionStatus:xi(r),toNode:d,toHandle:f});let p="";const g={sourceX:i.x,sourceY:i.y,sourcePosition:c,targetX:l.x,targetY:l.y,targetPosition:u};switch(t){case Ie.Bezier:[p]=$i(g);break;case Ie.SimpleBezier:[p]=co(g);break;case Ie.Step:[p]=Qn({...g,borderRadius:0});break;case Ie.SmoothStep:[p]=Qn(g);break;default:[p]=zi(g)}return h.jsx("path",{d:p,fill:"none",className:"react-flow__connection-path",style:e})};No.displayName="ConnectionLine";const M0={};function Ms(e=M0){M.useRef(e),te(),M.useEffect(()=>{},[e])}function $0(){te(),M.useRef(!1),M.useEffect(()=>{},[])}function _o({nodeTypes:e,edgeTypes:t,onInit:n,onNodeClick:r,onEdgeClick:s,onNodeDoubleClick:i,onEdgeDoubleClick:o,onNodeMouseEnter:a,onNodeMouseMove:c,onNodeMouseLeave:l,onNodeContextMenu:d,onSelectionContextMenu:f,onSelectionStart:u,onSelectionEnd:p,connectionLineType:g,connectionLineStyle:m,connectionLineComponent:b,connectionLineContainerStyle:y,selectionKeyCode:S,selectionOnDrag:v,selectionMode:w,multiSelectionKeyCode:j,panActivationKeyCode:P,zoomActivationKeyCode:k,deleteKeyCode:$,onlyRenderVisibleElements:z,elementsSelectable:T,defaultViewport:H,translateExtent:L,minZoom:D,maxZoom:x,preventScrolling:C,defaultMarkerColor:_,zoomOnScroll:I,zoomOnPinch:N,panOnScroll:E,panOnScrollSpeed:A,panOnScrollMode:R,zoomOnDoubleClick:B,panOnDrag:q,onPaneClick:F,onPaneMouseEnter:O,onPaneMouseMove:Y,onPaneMouseLeave:K,onPaneScroll:V,onPaneContextMenu:G,paneClickDistance:Z,nodeClickDistance:U,onEdgeContextMenu:W,onEdgeMouseEnter:J,onEdgeMouseMove:ee,onEdgeMouseLeave:ie,reconnectRadius:ke,onReconnect:yn,onReconnectStart:wn,onReconnectEnd:vn,noDragClassName:nt,noWheelClassName:bn,noPanClassName:rt,disableKeyboardA11y:st,nodeExtent:Nn,rfId:it,viewport:ot,onViewportChange:$t}){return Ms(e),Ms(t),$0(),b0(n),_0(ot),h.jsx(Wh,{onPaneClick:F,onPaneMouseEnter:O,onPaneMouseMove:Y,onPaneMouseLeave:K,onPaneContextMenu:G,onPaneScroll:V,paneClickDistance:Z,deleteKeyCode:$,selectionKeyCode:S,selectionOnDrag:v,selectionMode:w,onSelectionStart:u,onSelectionEnd:p,multiSelectionKeyCode:j,panActivationKeyCode:P,zoomActivationKeyCode:k,elementsSelectable:T,zoomOnScroll:I,zoomOnPinch:N,zoomOnDoubleClick:B,panOnScroll:E,panOnScrollSpeed:A,panOnScrollMode:R,panOnDrag:q,defaultViewport:H,translateExtent:L,minZoom:D,maxZoom:x,onSelectionContextMenu:f,preventScrolling:C,noDragClassName:nt,noWheelClassName:bn,noPanClassName:rt,disableKeyboardA11y:st,onViewportChange:$t,isControlledViewport:!!ot,children:h.jsxs(v0,{children:[h.jsx(y0,{edgeTypes:t,onEdgeClick:s,onEdgeDoubleClick:o,onReconnect:yn,onReconnectStart:wn,onReconnectEnd:vn,onlyRenderVisibleElements:z,onEdgeContextMenu:W,onEdgeMouseEnter:J,onEdgeMouseMove:ee,onEdgeMouseLeave:ie,reconnectRadius:ke,defaultMarkerColor:_,noPanClassName:rt,disableKeyboardA11y:st,rfId:it}),h.jsx(j0,{style:m,type:g,component:b,containerStyle:y}),h.jsx("div",{className:"react-flow__edgelabel-renderer"}),h.jsx(t0,{nodeTypes:e,onNodeClick:r,onNodeDoubleClick:i,onNodeMouseEnter:a,onNodeMouseMove:c,onNodeMouseLeave:l,onNodeContextMenu:d,nodeClickDistance:U,onlyRenderVisibleElements:z,noPanClassName:rt,noDragClassName:nt,disableKeyboardA11y:st,nodeExtent:Nn,rfId:it}),h.jsx("div",{className:"react-flow__viewport-portal"})]})})}_o.displayName="GraphView";const I0=M.memo(_o),$s=({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:s,height:i,fitView:o,nodeOrigin:a,nodeExtent:c}={})=>{const l=new Map,d=new Map,f=new Map,u=new Map,p=r??t??[],g=n??e??[],m=a??[0,0],b=c??vt;Ti(f,u,p),er(g,l,d,{nodeOrigin:m,nodeExtent:b,elevateNodesOnSelect:!1});let y=[0,0,1];if(o&&s&&i){const S=jt(l,{filter:P=>!!((P.width||P.initialWidth)&&(P.height||P.initialHeight))}),{x:v,y:w,zoom:j}=hr(S,s,i,.5,2,.1);y=[v,w,j]}return{rfId:"1",width:0,height:0,transform:y,nodes:g,nodeLookup:l,parentLookup:d,edges:p,edgeLookup:u,connectionLookup:f,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:n!==void 0,hasDefaultEdges:r!==void 0,panZoom:null,minZoom:.5,maxZoom:2,translateExtent:vt,nodeExtent:b,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:Ze.Strict,domNode:null,paneDragging:!1,noPanClassName:"nopan",nodeOrigin:m,nodeDragThreshold:1,snapGrid:[15,15],snapToGrid:!1,nodesDraggable:!0,nodesConnectable:!0,nodesFocusable:!0,edgesFocusable:!0,edgesReconnectable:!0,elementsSelectable:!0,elevateNodesOnSelect:!0,elevateEdgesOnSelect:!1,fitViewOnInit:!1,fitViewDone:!1,fitViewOnInitOptions:void 0,selectNodesOnDrag:!0,multiSelectionActive:!1,connection:{...mi},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanSpeed:15,connectionRadius:20,onError:Dd,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:"react",debug:!1}},z0=({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:s,height:i,fitView:o,nodeOrigin:a,nodeExtent:c})=>Gf((l,d)=>({...$s({nodes:e,edges:t,width:s,height:i,fitView:o,nodeOrigin:a,nodeExtent:c,defaultNodes:n,defaultEdges:r}),setNodes:f=>{const{nodeLookup:u,parentLookup:p,nodeOrigin:g,elevateNodesOnSelect:m}=d();er(f,u,p,{nodeOrigin:g,nodeExtent:c,elevateNodesOnSelect:m,checkEquality:!0}),l({nodes:f})},setEdges:f=>{const{connectionLookup:u,edgeLookup:p}=d();Ti(u,p,f),l({edges:f})},setDefaultNodesAndEdges:(f,u)=>{if(f){const{setNodes:p}=d();p(f),l({hasDefaultNodes:!0})}if(u){const{setEdges:p}=d();p(u),l({hasDefaultEdges:!0})}},updateNodeInternals:(f,u={triggerFitView:!0})=>{const{triggerNodeChanges:p,nodeLookup:g,parentLookup:m,fitViewOnInit:b,fitViewDone:y,fitViewOnInitOptions:S,domNode:v,nodeOrigin:w,nodeExtent:j,debug:P,fitViewSync:k}=d(),{changes:$,updatedInternals:z}=Qd(f,g,m,v,w,j);if(z){if(Gd(g,m,{nodeOrigin:w,nodeExtent:j}),u.triggerFitView){let T=y;!y&&b&&(T=k({...S,nodes:S==null?void 0:S.nodes})),l({fitViewDone:T})}else l({});($==null?void 0:$.length)>0&&(P&&console.log("React Flow: trigger node changes",$),p==null||p($))}},updateNodePositions:(f,u=!1)=>{const p=[],g=[];for(const[m,b]of f){const y=!!(b!=null&&b.expandParent&&(b!=null&&b.parentId)&&(b!=null&&b.position)),S={id:m,type:"position",position:y?{x:Math.max(0,b.position.x),y:Math.max(0,b.position.y)}:b.position,dragging:u};y&&p.push({id:m,parentId:b.parentId,rect:{...b.internals.positionAbsolute,width:b.measured.width,height:b.measured.height}}),g.push(S)}if(p.length>0){const{nodeLookup:m,parentLookup:b,nodeOrigin:y}=d(),S=xr(p,m,b,y);g.push(...S)}d().triggerNodeChanges(g)},triggerNodeChanges:f=>{const{onNodesChange:u,setNodes:p,nodes:g,hasDefaultNodes:m,debug:b}=d();if(f!=null&&f.length){if(m){const y=mh(f,g);p(y)}b&&console.log("React Flow: trigger node changes",f),u==null||u(f)}},triggerEdgeChanges:f=>{const{onEdgesChange:u,setEdges:p,edges:g,hasDefaultEdges:m,debug:b}=d();if(f!=null&&f.length){if(m){const y=xh(f,g);p(y)}b&&console.log("React Flow: trigger edge changes",f),u==null||u(f)}},addSelectedNodes:f=>{const{multiSelectionActive:u,edgeLookup:p,nodeLookup:g,triggerNodeChanges:m,triggerEdgeChanges:b}=d();if(u){const y=f.map(S=>Pe(S,!0));m(y);return}m(qe(g,new Set([...f]),!0)),b(qe(p))},addSelectedEdges:f=>{const{multiSelectionActive:u,edgeLookup:p,nodeLookup:g,triggerNodeChanges:m,triggerEdgeChanges:b}=d();if(u){const y=f.map(S=>Pe(S,!0));b(y);return}b(qe(p,new Set([...f]))),m(qe(g,new Set,!0))},unselectNodesAndEdges:({nodes:f,edges:u}={})=>{const{edges:p,nodes:g,nodeLookup:m,triggerNodeChanges:b,triggerEdgeChanges:y}=d(),S=f||g,v=u||p,w=S.map(P=>{const k=m.get(P.id);return k&&(k.selected=!1),Pe(P.id,!1)}),j=v.map(P=>Pe(P.id,!1));b(w),y(j)},setMinZoom:f=>{const{panZoom:u,maxZoom:p}=d();u==null||u.setScaleExtent([f,p]),l({minZoom:f})},setMaxZoom:f=>{const{panZoom:u,minZoom:p}=d();u==null||u.setScaleExtent([p,f]),l({maxZoom:f})},setTranslateExtent:f=>{var u;(u=d().panZoom)==null||u.setTranslateExtent(f),l({translateExtent:f})},setPaneClickDistance:f=>{var u;(u=d().panZoom)==null||u.setClickDistance(f)},resetSelectedElements:()=>{const{edges:f,nodes:u,triggerNodeChanges:p,triggerEdgeChanges:g}=d(),m=u.reduce((y,S)=>S.selected?[...y,Pe(S.id,!1)]:y,[]),b=f.reduce((y,S)=>S.selected?[...y,Pe(S.id,!1)]:y,[]);p(m),g(b)},setNodeExtent:f=>{const{nodes:u,nodeLookup:p,parentLookup:g,nodeOrigin:m,elevateNodesOnSelect:b,nodeExtent:y}=d();f[0][0]===y[0][0]&&f[0][1]===y[0][1]&&f[1][0]===y[1][0]&&f[1][1]===y[1][1]||(er(u,p,g,{nodeOrigin:m,nodeExtent:f,elevateNodesOnSelect:b,checkEquality:!1}),l({nodeExtent:f}))},panBy:f=>{const{transform:u,width:p,height:g,panZoom:m,translateExtent:b}=d();return Jd({delta:f,panZoom:m,transform:u,translateExtent:b,width:p,height:g})},fitView:f=>{const{panZoom:u,width:p,height:g,minZoom:m,maxZoom:b,nodeLookup:y}=d();if(!u)return Promise.resolve(!1);const S=Kn(y,f);return Gn({nodes:S,width:p,height:g,panZoom:u,minZoom:m,maxZoom:b},f)},fitViewSync:f=>{const{panZoom:u,width:p,height:g,minZoom:m,maxZoom:b,nodeLookup:y}=d();if(!u)return!1;const S=Kn(y,f);return Gn({nodes:S,width:p,height:g,panZoom:u,minZoom:m,maxZoom:b},f),S.size>0},cancelConnection:()=>{l({connection:{...mi}})},updateConnection:f=>{l({connection:f})},reset:()=>l({...$s()})}),Object.is);function A0({initialNodes:e,initialEdges:t,defaultNodes:n,defaultEdges:r,initialWidth:s,initialHeight:i,fitView:o,nodeOrigin:a,nodeExtent:c,children:l}){const[d]=M.useState(()=>z0({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:s,height:i,fitView:o,nodeOrigin:a,nodeExtent:c}));return h.jsx(Uf,{value:d,children:h.jsx(bh,{children:l})})}function T0({children:e,nodes:t,edges:n,defaultNodes:r,defaultEdges:s,width:i,height:o,fitView:a,nodeOrigin:c,nodeExtent:l}){return M.useContext(gn)?h.jsx(h.Fragment,{children:e}):h.jsx(A0,{initialNodes:t,initialEdges:n,defaultNodes:r,defaultEdges:s,initialWidth:i,initialHeight:o,fitView:a,nodeOrigin:c,nodeExtent:l,children:e})}const P0={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0};function D0({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,className:s,nodeTypes:i,edgeTypes:o,onNodeClick:a,onEdgeClick:c,onInit:l,onMove:d,onMoveStart:f,onMoveEnd:u,onConnect:p,onConnectStart:g,onConnectEnd:m,onClickConnectStart:b,onClickConnectEnd:y,onNodeMouseEnter:S,onNodeMouseMove:v,onNodeMouseLeave:w,onNodeContextMenu:j,onNodeDoubleClick:P,onNodeDragStart:k,onNodeDrag:$,onNodeDragStop:z,onNodesDelete:T,onEdgesDelete:H,onDelete:L,onSelectionChange:D,onSelectionDragStart:x,onSelectionDrag:C,onSelectionDragStop:_,onSelectionContextMenu:I,onSelectionStart:N,onSelectionEnd:E,onBeforeDelete:A,connectionMode:R,connectionLineType:B=Ie.Bezier,connectionLineStyle:q,connectionLineComponent:F,connectionLineContainerStyle:O,deleteKeyCode:Y="Backspace",selectionKeyCode:K="Shift",selectionOnDrag:V=!1,selectionMode:G=bt.Full,panActivationKeyCode:Z="Space",multiSelectionKeyCode:U=tn()?"Meta":"Control",zoomActivationKeyCode:W=tn()?"Meta":"Control",snapToGrid:J,snapGrid:ee,onlyRenderVisibleElements:ie=!1,selectNodesOnDrag:ke,nodesDraggable:yn,nodesConnectable:wn,nodesFocusable:vn,nodeOrigin:nt=Zi,edgesFocusable:bn,edgesReconnectable:rt,elementsSelectable:st=!0,defaultViewport:Nn=lh,minZoom:it=.5,maxZoom:ot=2,translateExtent:$t=vt,preventScrolling:$o=!0,nodeExtent:_n,defaultMarkerColor:Io="#b1b1b7",zoomOnScroll:zo=!0,zoomOnPinch:Ao=!0,panOnScroll:To=!1,panOnScrollSpeed:Po=.5,panOnScrollMode:Do=He.Free,zoomOnDoubleClick:Ro=!0,panOnDrag:Ho=!0,onPaneClick:Lo,onPaneMouseEnter:Bo,onPaneMouseMove:Vo,onPaneMouseLeave:Fo,onPaneScroll:Oo,onPaneContextMenu:Xo,paneClickDistance:br=0,nodeClickDistance:qo=0,children:Yo,onReconnect:Wo,onReconnectStart:Ko,onReconnectEnd:Go,onEdgeContextMenu:Uo,onEdgeDoubleClick:Zo,onEdgeMouseEnter:Qo,onEdgeMouseMove:Jo,onEdgeMouseLeave:ea,reconnectRadius:ta=10,onNodesChange:na,onEdgesChange:ra,noDragClassName:sa="nodrag",noWheelClassName:ia="nowheel",noPanClassName:Nr="nopan",fitView:_r,fitViewOptions:oa,connectOnClick:aa,attributionPosition:ca,proOptions:la,defaultEdgeOptions:ua,elevateNodesOnSelect:da,elevateEdgesOnSelect:fa,disableKeyboardA11y:Er=!1,autoPanOnConnect:ha,autoPanOnNodeDrag:pa,autoPanSpeed:ga,connectionRadius:ma,isValidConnection:xa,onError:ya,style:wa,id:Sr,nodeDragThreshold:va,viewport:ba,onViewportChange:Na,width:_a,height:Ea,colorMode:Sa="light",debug:ka,...Ca},ja){const En=Sr||"1",Ma=hh(Sa);return h.jsx("div",{"data-testid":"rf__wrapper",...Ca,style:{...wa,...P0},ref:ja,className:se(["react-flow",s,Ma]),id:Sr,children:h.jsxs(T0,{nodes:e,edges:t,width:_a,height:Ea,fitView:_r,nodeOrigin:nt,nodeExtent:_n,children:[h.jsx(I0,{onInit:l,onNodeClick:a,onEdgeClick:c,onNodeMouseEnter:S,onNodeMouseMove:v,onNodeMouseLeave:w,onNodeContextMenu:j,onNodeDoubleClick:P,nodeTypes:i,edgeTypes:o,connectionLineType:B,connectionLineStyle:q,connectionLineComponent:F,connectionLineContainerStyle:O,selectionKeyCode:K,selectionOnDrag:V,selectionMode:G,deleteKeyCode:Y,multiSelectionKeyCode:U,panActivationKeyCode:Z,zoomActivationKeyCode:W,onlyRenderVisibleElements:ie,defaultViewport:Nn,translateExtent:$t,minZoom:it,maxZoom:ot,preventScrolling:$o,zoomOnScroll:zo,zoomOnPinch:Ao,zoomOnDoubleClick:Ro,panOnScroll:To,panOnScrollSpeed:Po,panOnScrollMode:Do,panOnDrag:Ho,onPaneClick:Lo,onPaneMouseEnter:Bo,onPaneMouseMove:Vo,onPaneMouseLeave:Fo,onPaneScroll:Oo,onPaneContextMenu:Xo,paneClickDistance:br,nodeClickDistance:qo,onSelectionContextMenu:I,onSelectionStart:N,onSelectionEnd:E,onReconnect:Wo,onReconnectStart:Ko,onReconnectEnd:Go,onEdgeContextMenu:Uo,onEdgeDoubleClick:Zo,onEdgeMouseEnter:Qo,onEdgeMouseMove:Jo,onEdgeMouseLeave:ea,reconnectRadius:ta,defaultMarkerColor:Io,noDragClassName:sa,noWheelClassName:ia,noPanClassName:Nr,rfId:En,disableKeyboardA11y:Er,nodeExtent:_n,viewport:ba,onViewportChange:Na}),h.jsx(fh,{nodes:e,edges:t,defaultNodes:n,defaultEdges:r,onConnect:p,onConnectStart:g,onConnectEnd:m,onClickConnectStart:b,onClickConnectEnd:y,nodesDraggable:yn,nodesConnectable:wn,nodesFocusable:vn,edgesFocusable:bn,edgesReconnectable:rt,elementsSelectable:st,elevateNodesOnSelect:da,elevateEdgesOnSelect:fa,minZoom:it,maxZoom:ot,nodeExtent:_n,onNodesChange:na,onEdgesChange:ra,snapToGrid:J,snapGrid:ee,connectionMode:R,translateExtent:$t,connectOnClick:aa,defaultEdgeOptions:ua,fitView:_r,fitViewOptions:oa,onNodesDelete:T,onEdgesDelete:H,onDelete:L,onNodeDragStart:k,onNodeDrag:$,onNodeDragStop:z,onSelectionDrag:C,onSelectionDragStart:x,onSelectionDragStop:_,onMove:d,onMoveStart:f,onMoveEnd:u,noPanClassName:Nr,nodeOrigin:nt,rfId:En,autoPanOnConnect:ha,autoPanOnNodeDrag:pa,autoPanSpeed:ga,onError:ya,connectionRadius:ma,isValidConnection:xa,selectNodesOnDrag:ke,nodeDragThreshold:va,onBeforeDelete:A,paneClickDistance:br,debug:ka}),h.jsx(ch,{onSelectionChange:D}),Yo,h.jsx(rh,{proOptions:la,position:ca}),h.jsx(th,{rfId:En,disableKeyboardA11y:Er})]})})}var R0=Ji(D0);function H0({dimensions:e,lineWidth:t,variant:n,className:r}){return h.jsx("path",{strokeWidth:t,d:`M${e[0]/2} 0 V${e[1]} M0 ${e[1]/2} H${e[0]}`,className:se(["react-flow__background-pattern",n,r])})}function L0({radius:e,className:t}){return h.jsx("circle",{cx:e,cy:e,r:e,className:se(["react-flow__background-pattern","dots",t])})}var be;(function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"})(be||(be={}));const B0={[be.Dots]:1,[be.Lines]:1,[be.Cross]:6},V0=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function Eo({id:e,variant:t=be.Dots,gap:n=20,size:r,lineWidth:s=1,offset:i=0,color:o,bgColor:a,style:c,className:l,patternClassName:d}){const f=M.useRef(null),{transform:u,patternId:p}=Q(V0,re),g=r||B0[t],m=t===be.Dots,b=t===be.Cross,y=Array.isArray(n)?n:[n,n],S=[y[0]*u[2]||1,y[1]*u[2]||1],v=g*u[2],w=Array.isArray(i)?i:[i,i],j=b?[v,v]:S,P=[w[0]*u[2]||1+j[0]/2,w[1]*u[2]||1+j[1]/2],k=`${p}${e||""}`;return h.jsxs("svg",{className:se(["react-flow__background",l]),style:{...c,...mn,"--xy-background-color-props":a,"--xy-background-pattern-color-props":o},ref:f,"data-testid":"rf__background",children:[h.jsx("pattern",{id:k,x:u[0]%S[0],y:u[1]%S[1],width:S[0],height:S[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${P[0]},-${P[1]})`,children:m?h.jsx(L0,{radius:v/2,className:d}):h.jsx(H0,{dimensions:j,lineWidth:s,variant:t,className:d})}),h.jsx("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${k})`})]})}Eo.displayName="Background";const F0=M.memo(Eo);function O0(){return h.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",children:h.jsx("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"})})}function X0(){return h.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5",children:h.jsx("path",{d:"M0 0h32v4.2H0z"})})}function q0(){return h.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30",children:h.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 Y0(){return h.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:h.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 W0(){return h.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:h.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 Lt({children:e,className:t,...n}){return h.jsx("button",{type:"button",className:se(["react-flow__controls-button",t]),...n,children:e})}const K0=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom});function So({style:e,showZoom:t=!0,showFitView:n=!0,showInteractive:r=!0,fitViewOptions:s,onZoomIn:i,onZoomOut:o,onFitView:a,onInteractiveChange:c,className:l,children:d,position:f="bottom-left",orientation:u="vertical","aria-label":p="React Flow controls"}){const g=te(),{isInteractive:m,minZoomReached:b,maxZoomReached:y}=Q(K0,re),{zoomIn:S,zoomOut:v,fitView:w}=wr(),j=()=>{S(),i==null||i()},P=()=>{v(),o==null||o()},k=()=>{w(s),a==null||a()},$=()=>{g.setState({nodesDraggable:!m,nodesConnectable:!m,elementsSelectable:!m}),c==null||c(!m)},z=u==="horizontal"?"horizontal":"vertical";return h.jsxs(yr,{className:se(["react-flow__controls",z,l]),position:f,style:e,"data-testid":"rf__controls","aria-label":p,children:[t&&h.jsxs(h.Fragment,{children:[h.jsx(Lt,{onClick:j,className:"react-flow__controls-zoomin",title:"zoom in","aria-label":"zoom in",disabled:y,children:h.jsx(O0,{})}),h.jsx(Lt,{onClick:P,className:"react-flow__controls-zoomout",title:"zoom out","aria-label":"zoom out",disabled:b,children:h.jsx(X0,{})})]}),n&&h.jsx(Lt,{className:"react-flow__controls-fitview",onClick:k,title:"fit view","aria-label":"fit view",children:h.jsx(q0,{})}),r&&h.jsx(Lt,{className:"react-flow__controls-interactive",onClick:$,title:"toggle interactivity","aria-label":"toggle interactivity",children:m?h.jsx(W0,{}):h.jsx(Y0,{})}),d]})}So.displayName="Controls";const G0=M.memo(So);function U0({id:e,x:t,y:n,width:r,height:s,style:i,color:o,strokeColor:a,strokeWidth:c,className:l,borderRadius:d,shapeRendering:f,selected:u,onClick:p}){const{background:g,backgroundColor:m}=i||{},b=o||g||m;return h.jsx("rect",{className:se(["react-flow__minimap-node",{selected:u},l]),x:t,y:n,rx:d,ry:d,width:r,height:s,style:{fill:b,stroke:a,strokeWidth:c},shapeRendering:f,onClick:p?y=>p(y,e):void 0})}const Z0=M.memo(U0),Q0=e=>e.nodes.map(t=>t.id),Dn=e=>e instanceof Function?e:()=>e;function J0({nodeStrokeColor:e,nodeColor:t,nodeClassName:n="",nodeBorderRadius:r=5,nodeStrokeWidth:s,nodeComponent:i=Z0,onClick:o}){const a=Q(Q0,re),c=Dn(t),l=Dn(e),d=Dn(n),f=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return h.jsx(h.Fragment,{children:a.map(u=>h.jsx(tp,{id:u,nodeColorFunc:c,nodeStrokeColorFunc:l,nodeClassNameFunc:d,nodeBorderRadius:r,nodeStrokeWidth:s,NodeComponent:i,onClick:o,shapeRendering:f},u))})}function ep({id:e,nodeColorFunc:t,nodeStrokeColorFunc:n,nodeClassNameFunc:r,nodeBorderRadius:s,nodeStrokeWidth:i,shapeRendering:o,NodeComponent:a,onClick:c}){const{node:l,x:d,y:f,width:u,height:p}=Q(g=>{const m=g.nodeLookup.get(e),{x:b,y}=m.internals.positionAbsolute,{width:S,height:v}=Se(m);return{node:m,x:b,y,width:S,height:v}},re);return!l||l.hidden||!Si(l)?null:h.jsx(a,{x:d,y:f,width:u,height:p,style:l.style,selected:!!l.selected,className:r(l),color:t(l),borderRadius:s,strokeColor:n(l),strokeWidth:i,shapeRendering:o,onClick:c,id:l.id})}const tp=M.memo(ep);var np=M.memo(J0);const rp=200,sp=150,ip=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?_i(jt(e.nodeLookup),t):t,rfId:e.rfId,panZoom:e.panZoom,translateExtent:e.translateExtent,flowWidth:e.width,flowHeight:e.height}},op="react-flow__minimap-desc";function ko({style:e,className:t,nodeStrokeColor:n,nodeColor:r,nodeClassName:s="",nodeBorderRadius:i=5,nodeStrokeWidth:o,nodeComponent:a,bgColor:c,maskColor:l,maskStrokeColor:d,maskStrokeWidth:f,position:u="bottom-right",onClick:p,onNodeClick:g,pannable:m=!1,zoomable:b=!1,ariaLabel:y="React Flow mini map",inversePan:S,zoomStep:v=10,offsetScale:w=5}){const j=te(),P=M.useRef(null),{boundingRect:k,viewBB:$,rfId:z,panZoom:T,translateExtent:H,flowWidth:L,flowHeight:D}=Q(ip,re),x=(e==null?void 0:e.width)??rp,C=(e==null?void 0:e.height)??sp,_=k.width/x,I=k.height/C,N=Math.max(_,I),E=N*x,A=N*C,R=w*N,B=k.x-(E-k.width)/2-R,q=k.y-(A-k.height)/2-R,F=E+R*2,O=A+R*2,Y=`${op}-${z}`,K=M.useRef(0),V=M.useRef();K.current=N,M.useEffect(()=>{if(P.current&&T)return V.current=cf({domNode:P.current,panZoom:T,getTransform:()=>j.getState().transform,getViewScale:()=>K.current}),()=>{var U;(U=V.current)==null||U.destroy()}},[T]),M.useEffect(()=>{var U;(U=V.current)==null||U.update({translateExtent:H,width:L,height:D,inversePan:S,pannable:m,zoomStep:v,zoomable:b})},[m,b,S,v,H,L,D]);const G=p?U=>{var ee;const[W,J]=((ee=V.current)==null?void 0:ee.pointer(U))||[0,0];p(U,{x:W,y:J})}:void 0,Z=g?M.useCallback((U,W)=>{const J=j.getState().nodeLookup.get(W);g(U,J)},[]):void 0;return h.jsx(yr,{position:u,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 d=="string"?d:void 0,"--xy-minimap-mask-stroke-width-props":typeof f=="number"?f*N:void 0,"--xy-minimap-node-background-color-props":typeof r=="string"?r:void 0,"--xy-minimap-node-stroke-color-props":typeof n=="string"?n:void 0,"--xy-minimap-node-stroke-width-props":typeof o=="string"?o:void 0},className:se(["react-flow__minimap",t]),"data-testid":"rf__minimap",children:h.jsxs("svg",{width:x,height:C,viewBox:`${B} ${q} ${F} ${O}`,className:"react-flow__minimap-svg",role:"img","aria-labelledby":Y,ref:P,onClick:G,children:[y&&h.jsx("title",{id:Y,children:y}),h.jsx(np,{onClick:Z,nodeColor:r,nodeStrokeColor:n,nodeBorderRadius:i,nodeClassName:s,nodeStrokeWidth:o,nodeComponent:a}),h.jsx("path",{className:"react-flow__minimap-mask",d:`M${B-R},${q-R}h${F+R*2}v${O+R*2}h${-F-R*2}z
|
|
23
|
-
M${$.x},${$.y}h${$.width}v${$.height}h${-$.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}ko.displayName="MiniMap";M.memo(ko);function ap({nodeId:e,position:t,variant:n=ht.Handle,className:r,style:s={},children:i,color:o,minWidth:a=10,minHeight:c=10,maxWidth:l=Number.MAX_VALUE,maxHeight:d=Number.MAX_VALUE,keepAspectRatio:f=!1,shouldResize:u,onResizeStart:p,onResize:g,onResizeEnd:m}){const b=ro(),y=typeof e=="string"?e:b,S=te(),v=M.useRef(null),w=n===ht.Line?"right":"bottom-right",j=t??w,P=M.useRef(null);M.useEffect(()=>{if(!(!v.current||!y))return P.current||(P.current=_f({domNode:v.current,nodeId:y,getStoreItems:()=>{const{nodeLookup:T,transform:H,snapGrid:L,snapToGrid:D,nodeOrigin:x,domNode:C}=S.getState();return{nodeLookup:T,transform:H,snapGrid:L,snapToGrid:D,nodeOrigin:x,paneDomNode:C}},onChange:(T,H)=>{const{triggerNodeChanges:L,nodeLookup:D,parentLookup:x,nodeOrigin:C}=S.getState(),_=[],I={x:T.x,y:T.y},N=D.get(y);if(N&&N.expandParent&&N.parentId){const E=N.origin??C,A=T.width??N.measured.width,R=T.height??N.measured.height,B={id:N.id,parentId:N.parentId,rect:{width:A,height:R,...ki({x:T.x??N.position.x,y:T.y??N.position.y},{width:A,height:R},N.parentId,D,E)}},q=xr([B],D,x,C);_.push(...q),I.x=T.x?Math.max(E[0]*A,T.x):void 0,I.y=T.y?Math.max(E[1]*R,T.y):void 0}if(I.x!==void 0&&I.y!==void 0){const E={id:y,type:"position",position:{...I}};_.push(E)}if(T.width!==void 0&&T.height!==void 0){const E={id:y,type:"dimensions",resizing:!0,setAttributes:!0,dimensions:{width:T.width,height:T.height}};_.push(E)}for(const E of H){const A={...E,type:"position"};_.push(A)}L(_)},onEnd:()=>{const T={id:y,type:"dimensions",resizing:!1};S.getState().triggerNodeChanges([T])}})),P.current.update({controlPosition:j,boundaries:{minWidth:a,minHeight:c,maxWidth:l,maxHeight:d},keepAspectRatio:f,onResizeStart:p,onResize:g,onResizeEnd:m,shouldResize:u}),()=>{var T;(T=P.current)==null||T.destroy()}},[j,a,c,l,d,f,p,g,m,u]);const k=j.split("-"),$=n===ht.Line?"borderColor":"backgroundColor",z=o?{...s,[$]:o}:s;return h.jsx("div",{className:se(["react-flow__resize-control","nodrag",...k,n,r]),ref:v,style:z,children:i})}M.memo(ap);const cp=new Set;function lp(e){return e.startsWith("signal:child:")}function up(e){const t=M.useMemo(()=>[...e].sort(),[e]),n=Ba({queries:t.map(s=>({queryKey:["run",s],queryFn:()=>ue.run(s)}))}),r={};return t.forEach((s,i)=>{var a;const o=(a=n[i])==null?void 0:a.data;o&&(r[s]=o)}),r}function dp({data:e}){const t=e.status==="failed",n=e.status==="pending"||e.status==="running",r=!!e.childRunId,s=r?Va:Ts(e.kind),i=t?{rail:"bg-red-400",badge:"bg-red-500/15 text-red-300",pill:"bg-red-500/20 text-red-300"}:n?{rail:"bg-amber-400",badge:"bg-amber-500/15 text-amber-300",pill:"bg-amber-500/20 text-amber-300"}:{rail:"bg-emerald-400",badge:"bg-emerald-500/15 text-emerald-300",pill:"bg-emerald-500/20 text-emerald-300"};return h.jsxs("div",{title:r?Hn.child:Hn[e.kind]??e.kind,className:`group relative w-[208px] cursor-pointer overflow-hidden rounded-xl border bg-[var(--panel)]/95 shadow-lg backdrop-blur transition-all duration-150 hover:-translate-y-0.5 ${e.selected?"border-emerald-400/60 ring-2 ring-emerald-400/30":t?"border-red-500/40 hover:border-red-400/60":r?"border-indigo-500/40 hover:border-indigo-400/60":"border-[var(--line)] hover:border-zinc-600"}`,children:[h.jsx("span",{className:`absolute inset-y-0 left-0 w-[3px] ${i.rail} ${n?"animate-pulse":""}`}),h.jsx(Te,{type:"target",position:X.Left,className:"!border-0 !bg-zinc-600"}),h.jsxs("div",{className:"py-2.5 pl-3.5 pr-3",children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("span",{className:`grid h-5 w-5 shrink-0 place-items-center rounded ${i.badge}`,children:h.jsx(s,{width:12,height:12})}),h.jsx("span",{className:"truncate text-[13px] font-medium text-zinc-100",children:e.name}),h.jsx("span",{className:`ml-auto grid h-4 w-4 shrink-0 place-items-center rounded-full ${i.pill} ${n?"animate-pulse":""}`,children:t?h.jsx(Ke,{width:9,height:9}):n?h.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-current"}):h.jsx(Ds,{width:9,height:9})})]}),h.jsxs("div",{className:"mono mt-1.5 flex items-center gap-1.5 text-[10px] text-zinc-500",children:[r?h.jsxs("span",{className:"flex items-center gap-1",children:[h.jsx("button",{type:"button",onClick:o=>{var a;o.stopPropagation(),e.childRunId&&((a=e.onToggleChild)==null||a.call(e,e.childRunId))},title:e.childExpanded?"Collapse child flow":"Expand child flow inline",className:"grid h-4 w-4 place-items-center rounded border border-indigo-500/30 bg-indigo-500/10 text-indigo-300 transition-colors hover:border-indigo-400/60 hover:bg-indigo-500/20 hover:text-indigo-200",children:h.jsx("span",{className:"inline-block text-[9px] transition-transform",style:{transform:e.childExpanded?"rotate(90deg)":"rotate(0deg)"},children:"▸"})}),h.jsx("button",{type:"button",onClick:o=>{var a;o.stopPropagation(),e.childRunId&&((a=e.onOpenRun)==null||a.call(e,e.childRunId))},title:"Open the child run",className:"rounded border border-indigo-500/30 bg-indigo-500/10 px-1 text-indigo-300 transition-colors hover:border-indigo-400/60 hover:bg-indigo-500/20 hover:text-indigo-200",children:"child ↗"})]}):h.jsx("span",{className:"rounded border border-[var(--line)] px-1 text-zinc-400",children:e.kind}),e.attempts>1&&h.jsxs("span",{className:"flex items-center gap-0.5 text-amber-300",children:[h.jsx(Ps,{width:9,height:9}),e.attempts]}),e.workerGroup&&h.jsxs("span",{className:"truncate",children:["@",e.workerGroup]}),h.jsxs("span",{className:"tnum ml-auto text-zinc-400",children:["#",e.seq,e.duration&&h.jsxs("span",{className:"text-zinc-600",children:[" · ",e.duration]})]})]}),e.subs&&h.jsxs("div",{className:"mono mt-1.5 flex items-center gap-2 border-t border-[var(--line)] pt-1.5 text-[10px]",children:[e.subs.ok>0&&h.jsxs("span",{className:"text-emerald-300",children:[e.subs.ok," ok"]}),e.subs.failed>0&&h.jsxs("span",{className:"text-red-300",children:[e.subs.failed," failed"]}),e.subs.skipped>0&&h.jsxs("span",{className:"text-amber-300",children:[e.subs.skipped," skipped"]})]})]}),h.jsx(Te,{type:"source",position:X.Right,className:"!border-0 !bg-zinc-600"})]})}function fp({data:e}){const t=e.status==="running"||e.status==="awaiting";return h.jsxs("div",{className:`s-${e.status} flex items-center gap-2 rounded-full border border-current/30 bg-[var(--panel)] px-3.5 py-1.5`,children:[h.jsx(Te,{type:"target",position:X.Left,className:"!border-0 !bg-zinc-600"}),h.jsx("span",{className:`dot ${t?"pulse":""}`}),h.jsx("span",{className:"mono text-[11px] uppercase tracking-wider",children:e.label}),h.jsx(Te,{type:"source",position:X.Right,className:"!border-0 !bg-zinc-600"})]})}const hp={step:dp,terminal:fp};function pp(e){var n;const t=(n=e.events)==null?void 0:n.filter(r=>r.status);if(!(!t||t.length===0))return{ok:t.filter(r=>r.status==="ok").length,failed:t.filter(r=>r.status==="failed").length,skipped:t.filter(r=>r.status==="skipped").length}}function gp({run:e,timeline:t,selectedKey:n,onSelect:r,onOpenRun:s,fmtDuration:i,expanded:o,onToggleChild:a}){const c=o??cp,l=M.useMemo(()=>{const g=new Set(c);for(const m of t){const b=Rn(m);b!==void 0&&g.add(b)}return g},[c,t]),d=up(l),{nodes:f,edges:u}=(()=>{const b=[],y=[],S=e.status==="running"||e.status==="suspended",v=(z,T,H)=>({id:`${z}->${T}`,source:z,target:T,style:{stroke:H?"#f87171":"var(--line)",strokeWidth:1.5}}),w=(z,T)=>({id:`${z}=>${T}`,source:z,target:T,style:{stroke:"#818cf8",strokeWidth:1.5,strokeDasharray:"4 3"}});function j(z,T,H,L,D){var N;let x=H,C,_,I=!1;for(const E of z){const A=`${L}s${E.seq}`,R=Rn(E),B=R!==void 0&&c.has(R),q=R!==void 0?((N=d[R])==null?void 0:N.run.workflow)??"child workflow":E.name;b.push({id:A,type:"step",draggable:!1,position:{x,y:T*150},data:{seq:E.seq,name:q,kind:E.kind,status:E.status,workerGroup:E.workerGroup,attempts:E.attempts,duration:i(E.startedAt,E.finishedAt),subs:pp(E),selected:n===`${E.runId}#${E.seq}`,childRunId:R,onOpenRun:s,childExpanded:B,onToggleChild:a,depth:T,step:E,laneRun:D}}),C===void 0&&(C=A),_!==void 0&&y.push(v(_,A,I));const F=R!==void 0&&B?d[R]:void 0;if(F){const O=j(F.timeline,T+1,x+248,`${R}:`,F.run);O.firstId!==void 0&&y.push(w(A,O.firstId)),lp(E.name)&&O.connectorId!==void 0?_=O.connectorId:_=A,x=Math.max(x+248,O.nextX)}else _=A,x+=248;I=E.status==="failed"}return{firstId:C,connectorId:_,nextX:x}}const P=248;b.push({id:"start",type:"terminal",position:{x:0,y:0},draggable:!1,data:{status:"running",label:e.workflow}});const k=j(t,0,P,"",e);k.firstId!==void 0&&y.push({id:"start->first",source:"start",target:k.firstId});const $=sr(e,t);return b.push({id:"end",type:"terminal",position:{x:Math.max(k.nextX,P),y:0},draggable:!1,data:{status:$,label:$}}),y.push({id:"exit->end",source:k.connectorId??"start",target:"end",animated:S,style:{stroke:S?"var(--accent)":"var(--line)",strokeWidth:S?2:1.5}}),{nodes:b,edges:y}})(),p=M.useCallback((g,m)=>{if(m.type!=="step")return;const b=m.data;b.step&&b.laneRun&&r(b.step,b.laneRun)},[r]);return h.jsxs(R0,{nodes:f,edges:u,nodeTypes:hp,onNodeClick:p,fitView:!0,fitViewOptions:{padding:.3,maxZoom:1.1},proOptions:{hideAttribution:!0},nodesConnectable:!1,nodesDraggable:!1,panOnScroll:!0,minZoom:.3,children:[h.jsx(F0,{variant:be.Dots,gap:22,size:1,color:"#1c1c22"}),h.jsx(G0,{showInteractive:!1,position:"bottom-right"})]})}function Co({className:e}){return h.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.8,strokeLinecap:"round",strokeLinejoin:"round",className:e,role:"img","aria-label":"durable",children:[h.jsx("title",{children:"durable"}),h.jsx("path",{d:"M12 2.5 21.5 12 12 21.5 2.5 12z",opacity:.35}),h.jsx("circle",{cx:"6.4",cy:"12",r:"1.7",fill:"currentColor",stroke:"none"}),h.jsx("circle",{cx:"12",cy:"12",r:"1.7",fill:"currentColor",stroke:"none"}),h.jsx("circle",{cx:"17.6",cy:"12",r:"1.7",fill:"currentColor",stroke:"none"}),h.jsx("path",{d:"M8.1 12h2.2M13.7 12h2.2"})]})}const mp=["pending","running","suspended","completed","failed","cancelling","cancelled","dead"];function xp(e){const t=Date.now()-new Date(e).getTime(),n=Math.round(t/1e3);if(n<60)return`${n}s ago`;const r=Math.round(n/60);if(r<60)return`${r}m ago`;const s=Math.round(r/60);return s<24?`${s}h ago`:`${Math.round(s/24)}d ago`}function yp(e,t){const n=new Date(t).getTime()-new Date(e).getTime();return n<1e3?`${n}ms`:n<6e4?`${(n/1e3).toFixed(1)}s`:`${(n/6e4).toFixed(1)}m`}function jo({status:e}){const t=e==="running"||e==="awaiting"||e==="cancelling";return h.jsx("span",{className:`dot s-${e} ${t?"pulse":""}`,"aria-hidden":!0})}function Mo({status:e}){return h.jsxs("span",{className:`s-${e} inline-flex items-center gap-1.5 text-[11px] uppercase tracking-wider`,children:[h.jsx(jo,{status:e}),e]})}function wp({counts:e,filter:t,onFilter:n}){const r=Object.values(e).reduce((i,o)=>i+o,0),s=(i,o,a)=>h.jsxs("button",{type:"button",onClick:()=>n(i),className:`group flex items-center gap-2 rounded-md border px-2.5 py-1 text-xs transition-colors ${t===i?"border-zinc-600 bg-zinc-900 text-zinc-100":"border-transparent text-zinc-500 hover:text-zinc-300"}`,children:[i!=="all"&&h.jsx(jo,{status:i}),h.jsx("span",{className:"uppercase tracking-wide",children:o}),h.jsx("span",{className:"mono tnum text-zinc-600",children:a})]},i);return h.jsxs("header",{className:"z-10 flex items-center gap-4 border-b border-[var(--line)] px-5 py-3",children:[h.jsxs("div",{className:"flex items-center gap-2.5",children:[h.jsx("div",{className:"grid h-7 w-7 place-items-center rounded-md border border-emerald-500/30 bg-emerald-500/10",children:h.jsx(Co,{className:"h-4 w-4 text-emerald-400"})}),h.jsxs("div",{className:"leading-none",children:[h.jsx("div",{className:"text-sm font-semibold tracking-tight",children:"durable"}),h.jsx("div",{className:"mono text-[10px] uppercase tracking-[0.2em] text-zinc-600",children:"control plane"})]})]}),h.jsxs("div",{className:"ml-2 flex flex-wrap items-center gap-1",children:[s("all","all",r),mp.map(i=>s(i,i,e[i]??0))]}),h.jsx(vp,{}),h.jsxs("div",{className:"flex items-center gap-2 text-xs text-zinc-500",children:[h.jsx("span",{className:"dot s-completed pulse","aria-hidden":!0}),"live"]})]})}function vp(){const{data:e}=pt({queryKey:["workers"],queryFn:()=>ue.workers(),refetchInterval:1e4});return!e||e.length===0?null:h.jsx("div",{className:"ml-auto flex flex-wrap items-center gap-1.5",children:e.map(t=>{const n=t.liveWorkers.length,r=t.depth>0&&n===0;return h.jsxs("span",{title:`${t.group}: ${n} live worker(s), ${t.depth} queued${r?" — NO worker consuming":""}`,className:`mono flex items-center gap-1 rounded border px-1.5 py-0.5 text-[10px] ${r?"border-rose-500/50 bg-rose-500/15 text-rose-300":"border-[var(--line)] bg-zinc-800/40 text-zinc-400"}`,children:[h.jsx("span",{className:`dot ${r?"s-failed":n>0?"s-completed":""}`,"aria-hidden":!0}),t.group,h.jsxs("span",{className:"tnum text-zinc-500",children:[n,"w",t.depth>0?` ${t.depth}q`:""]})]},t.group)})})}function bp({runs:e,selected:t,onSelect:n,onSelectTag:r}){return e.length===0?h.jsx("div",{className:"p-6 text-sm text-zinc-600",children:"No runs yet."}):h.jsx("ul",{className:"divide-y divide-[var(--line-soft)]",children:e.map(s=>h.jsx("li",{children:h.jsxs("button",{type:"button",onClick:()=>n(s.id),className:`flex w-full flex-col gap-1 px-4 py-3 text-left transition-colors ${t===s.id?"bg-zinc-900":"hover:bg-zinc-900/50"}`,children:[h.jsxs("div",{className:"flex items-center justify-between gap-2",children:[h.jsxs("span",{className:"flex min-w-0 items-center gap-1.5",children:[h.jsx("span",{className:"truncate text-sm font-medium text-zinc-200",children:s.workflow}),s.id.startsWith("dlq:")&&h.jsx("span",{className:"mono shrink-0 rounded border border-rose-500/40 bg-rose-500/10 px-1 text-[9px] uppercase tracking-wider text-rose-300",children:"dlq"})]}),h.jsx(Mo,{status:sr(s)})]}),h.jsxs("div",{className:"flex items-center justify-between gap-2",children:[h.jsx("span",{className:"mono truncate text-[11px] text-zinc-600",children:s.id}),h.jsx("span",{className:"shrink-0 text-[11px] text-zinc-600",children:xp(s.updatedAt)})]}),s.tags&&s.tags.length>0&&h.jsx("div",{className:"flex flex-wrap gap-1",children:s.tags.map(i=>h.jsxs("span",{onClick:o=>{o.stopPropagation(),r(i)},className:"mono cursor-pointer rounded border border-[var(--line)] bg-zinc-800/40 px-1.5 text-[10px] text-zinc-400 hover:border-zinc-500 hover:text-zinc-200",children:["#",i]},i))})]})},s.id))})}function Np({id:e,onOpenRun:t}){var _,I;const n=rr(),{data:r}=pt({queryKey:["run",e],queryFn:async()=>Ka(n.getQueryData(["run",e]),await ue.run(e)),refetchInterval:N=>{var A;const E=(A=N.state.data)==null?void 0:A.run.status;return E==="running"||E==="suspended"?1500:!1}}),s=(r==null?void 0:r.run.status)==="dead"?`dlq:${e}`:void 0,{data:i}=pt({queryKey:["run",s],queryFn:()=>ue.run(s),enabled:!!s,retry:!1}),o=()=>{n.invalidateQueries({queryKey:["run",e]}),n.invalidateQueries({queryKey:["runs"]})},a=r==null?void 0:r.run.status,c=a==="running"||a==="suspended";M.useEffect(()=>{if(c)return ue.streamRun(e,N=>{if(N.type==="step.progress"&&N.event&&N.seq!=null){const E=N.seq,A=N.event;n.setQueryData(["run",e],R=>R&&{...R,timeline:R.timeline.map(B=>B.seq===E?{...B,events:[...B.events??[],A]}:B)});return}n.invalidateQueries({queryKey:["run",e]})})},[e,c,n]);const l=lt({mutationFn:()=>ue.retry(e),onSuccess:o}),d=lt({mutationFn:N=>ue.cancel(e,N!==void 0?{compensate:N}:{}),onSuccess:o}),f=lt({mutationFn:()=>ue.continue(e),onSuccess:o}),u=lt({mutationFn:N=>ue.retryWithInput(e,N),onSuccess:N=>{n.invalidateQueries({queryKey:["runs"]}),t(N.runId)}}),p=()=>{const N=JSON.stringify((r==null?void 0:r.run.input)??{},null,2),E=window.prompt("Fix the input, then replay as a fresh run:",N);if(E!=null)try{u.mutate(JSON.parse(E))}catch{window.alert("Invalid JSON")}},[g,m]=M.useState(),[b,y]=M.useState(!1),[S,v]=M.useState(new Set),[w,j]=M.useState(240);function P(N){N.preventDefault(),N.currentTarget.setPointerCapture(N.pointerId);const E=R=>j(B=>Math.max(120,Math.min(720,B-R.movementY))),A=()=>{window.removeEventListener("pointermove",E),window.removeEventListener("pointerup",A)};window.addEventListener("pointermove",E),window.addEventListener("pointerup",A)}function k(N){v(E=>{const A=new Set(E);return A.has(N)?A.delete(N):A.add(N),A})}if(!r)return h.jsx("div",{className:"p-8 text-sm text-zinc-600",children:"Loading run…"});const{run:$,timeline:z}=r,T=$.id.startsWith("dlq:"),H=T?{id:$.id.slice(4),title:"Dead-letter handler",subtitle:`started because run ${$.id.slice(4)} was dead-lettered`,cta:"open dead run →"}:i?{id:`dlq:${$.id}`,title:"Dead-lettered",subtitle:"this run exceeded recovery and was routed to a DLQ handler",cta:"open DLQ handler →"}:void 0,L=$.status==="failed"||$.status==="suspended",D=$.status==="running"||$.status==="suspended",x=z.some(N=>N.status==="pending"&&N.kind==="signal"&&N.name.startsWith("breakpoint")),C=g?`${g.step.runId}#${g.step.seq}`:void 0;return h.jsxs("div",{className:"flex h-full flex-col",children:[h.jsxs("div",{className:"flex items-start justify-between gap-4 border-b border-[var(--line)] px-7 py-5",children:[h.jsxs("div",{className:"min-w-0",children:[h.jsxs("div",{className:"flex items-center gap-3",children:[h.jsx("h2",{className:"text-lg font-semibold tracking-tight",children:$.workflow}),T&&h.jsx("span",{className:"mono rounded border border-rose-500/40 bg-rose-500/10 px-1.5 py-0.5 text-[10px] uppercase tracking-wider text-rose-300",children:"dlq"}),h.jsx(Mo,{status:sr($,z)}),h.jsxs("span",{className:"mono rounded border border-[var(--line)] px-1.5 py-0.5 text-[10px] text-zinc-500",children:["v",$.workflowVersion]}),h.jsxs("span",{className:"mono tnum text-[11px] text-zinc-600",children:[z.length," ",z.length===1?"step":"steps"]})]}),h.jsx("div",{className:"mono mt-1 truncate text-[11px] text-zinc-600",children:$.id}),$.tags&&$.tags.length>0&&h.jsx("div",{className:"mt-1.5 flex flex-wrap gap-1",children:$.tags.map(N=>h.jsxs("span",{className:"mono rounded border border-[var(--line)] bg-zinc-800/40 px-1.5 text-[10px] text-zinc-400",children:["#",N]},N))}),$.searchAttributes&&Object.keys($.searchAttributes).length>0&&h.jsx("div",{className:"mt-1.5 flex flex-wrap gap-1",children:Object.entries($.searchAttributes).map(([N,E])=>h.jsxs("span",{className:"mono rounded border border-indigo-500/30 bg-indigo-500/10 px-1.5 text-[10px] text-indigo-300",title:"search attribute",children:[N,"=",String(E)]},N))}),(_=r==null?void 0:r.children)!=null&&_.length?h.jsxs("div",{className:"mt-1.5 flex flex-wrap items-center gap-1",children:[h.jsx("span",{className:"text-[10px] text-zinc-600",children:"children:"}),(I=r.children)==null?void 0:I.map(N=>h.jsx("span",{onClick:()=>t(N),className:"mono cursor-pointer rounded border border-[var(--line)] bg-zinc-800/40 px-1.5 text-[10px] text-zinc-400 hover:border-zinc-500 hover:text-zinc-200",children:N},N))]}):null]}),h.jsxs("div",{className:"flex shrink-0 gap-2",children:[h.jsx("button",{type:"button",onClick:()=>y(!0),className:"mono rounded-md border border-[var(--line)] px-2.5 py-1.5 text-xs text-zinc-400 transition-colors hover:bg-zinc-800 hover:text-zinc-100",title:"Run input / output",children:"{ }"}),x&&h.jsxs("button",{type:"button",disabled:f.isPending,onClick:()=>f.mutate(),className:"flex items-center gap-1.5 rounded-md border border-amber-500/40 bg-amber-500/15 px-3 py-1.5 text-xs font-medium uppercase tracking-wide text-amber-200 transition-colors enabled:hover:bg-amber-500/25 disabled:opacity-30",children:[h.jsx(Fa,{width:12,height:12}),"Continue"]}),h.jsxs("button",{type:"button",disabled:!L||l.isPending,onClick:()=>l.mutate(),className:"flex items-center gap-1.5 rounded-md border border-emerald-500/30 bg-emerald-500/10 px-3 py-1.5 text-xs font-medium uppercase tracking-wide text-emerald-300 transition-colors enabled:hover:bg-emerald-500/20 disabled:opacity-30",children:[h.jsx(kn,{width:12,height:12}),"Retry"]}),($.status==="dead"||$.status==="failed")&&h.jsxs("button",{type:"button",disabled:u.isPending,onClick:p,title:"Edit the input and re-run as a fresh linked run",className:"flex items-center gap-1.5 rounded-md border border-indigo-500/30 bg-indigo-500/10 px-3 py-1.5 text-xs font-medium uppercase tracking-wide text-indigo-300 transition-colors enabled:hover:bg-indigo-500/20 disabled:opacity-30",children:[h.jsx(kn,{width:12,height:12}),"Fix & replay"]}),D&&h.jsxs("button",{type:"button",disabled:d.isPending,onClick:()=>d.mutate(!0),title:"Cancel and run saga compensations (undo completed steps in reverse)",className:"flex items-center gap-1.5 rounded-md border border-amber-600/30 px-3 py-1.5 text-xs font-medium uppercase tracking-wide text-amber-300/90 transition-colors enabled:hover:bg-amber-900/20 disabled:opacity-30",children:[h.jsx(kn,{width:12,height:12}),"Cancel + Undo"]}),h.jsxs("button",{type:"button",disabled:!D||d.isPending,onClick:()=>d.mutate(!1),className:"flex items-center gap-1.5 rounded-md border border-zinc-700 px-3 py-1.5 text-xs font-medium uppercase tracking-wide text-zinc-300 transition-colors enabled:hover:bg-zinc-800 disabled:opacity-30",children:[h.jsx(Ke,{width:12,height:12}),"Cancel"]})]})]}),H&&h.jsxs("div",{className:"flex items-center gap-3 border-b border-rose-500/30 bg-rose-500/10 px-7 py-3",children:[h.jsx("span",{className:"grid h-7 w-7 shrink-0 place-items-center rounded-md border border-rose-500/40 bg-rose-500/15 text-sm text-rose-300","aria-hidden":!0,children:"⚠"}),h.jsxs("div",{className:"min-w-0 flex-1",children:[h.jsx("div",{className:"text-[13px] font-medium text-rose-200",children:H.title}),h.jsx("div",{className:"mono truncate text-[11px] text-rose-300/70",children:H.subtitle})]}),h.jsx("button",{type:"button",onClick:()=>t(H.id),className:"mono shrink-0 rounded-md border border-rose-500/40 bg-rose-500/15 px-2.5 py-1.5 text-[11px] text-rose-200 transition-colors hover:bg-rose-500/25",children:H.cta})]}),h.jsxs("div",{className:"relative grid min-h-0 flex-1",style:{gridTemplateRows:z.length>0?`1fr ${w}px`:"1fr"},children:[h.jsxs("div",{className:"relative min-h-0",children:[z.length===0?h.jsx("div",{className:"grid h-full place-items-center text-sm text-zinc-600",children:"No steps recorded yet."}):h.jsx(gp,{run:$,timeline:z,selectedKey:C,onSelect:(N,E)=>m({step:N,run:E}),onOpenRun:t,fmtDuration:yp,expanded:S,onToggleChild:k}),($.status==="failed"||$.status==="cancelled")&&$.error&&h.jsx("div",{className:"mono absolute inset-x-6 bottom-6 rounded-lg border border-red-500/20 bg-red-500/10 px-3 py-2 text-xs text-red-300 backdrop-blur",children:$.error.message})]}),z.length>0&&h.jsxs("div",{className:"relative min-h-0 overflow-hidden border-t border-[var(--line)] bg-black/20",children:[h.jsx("div",{onPointerDown:P,className:"absolute inset-x-0 top-0 z-10 h-1.5 -translate-y-1/2 cursor-row-resize hover:bg-emerald-500/40",title:"Drag to resize"}),h.jsx(Oa,{run:$,timeline:z,selectedKey:C,onSelect:(N,E)=>m({step:N,run:E}),onOpenRun:t,expanded:S,onToggleChild:k})]}),g&&h.jsx(ec,{step:g.step,run:g.run,onClose:()=>m(void 0),onOpenRun:t}),b&&h.jsx(tc,{run:$,onClose:()=>y(!1)})]})]})}function Is(){if(typeof window>"u")return;const e=window.location.hash.match(/^#\/run\/(.+)$/),t=e==null?void 0:e[1];return t?decodeURIComponent(t):void 0}function _p(){const[e,t]=M.useState("all"),[n,r]=M.useState(""),[s,i]=M.useState(""),[o,a]=M.useState(()=>Is()),c=M.useCallback(m=>{if(a(m),typeof window>"u")return;const b=m?`#/run/${encodeURIComponent(m)}`:"",y=b||window.location.pathname+window.location.search;window.location.hash!==b&&window.history.pushState(null,"",y)},[]);M.useEffect(()=>{const m=()=>a(Is());return window.addEventListener("hashchange",m),window.addEventListener("popstate",m),()=>{window.removeEventListener("hashchange",m),window.removeEventListener("popstate",m)}},[]);const l=rr(),d=s.split(",").map(m=>m.trim()).filter(Boolean),{data:f=[]}=pt({queryKey:["runs",n,d.join("|")],queryFn:()=>ue.runs(void 0,n||void 0,d.length?d:void 0),refetchInterval:3e3}),u=lt({mutationFn:m=>ue.bulk(m,{status:e!=="all"?e:void 0,tag:n||void 0,attr:d.length?d:void 0}),onSuccess:()=>l.invalidateQueries({queryKey:["runs"]})}),p=f.reduce((m,b)=>(m[b.status]=(m[b.status]??0)+1,m),{}),g=e==="all"?f:f.filter(m=>m.status===e);return h.jsxs(h.Fragment,{children:[h.jsx("div",{className:"app-bg"}),h.jsxs("div",{className:"relative z-10 flex h-full flex-col",children:[h.jsx(wp,{counts:p,filter:e,onFilter:t}),h.jsxs("div",{className:"grid min-h-0 flex-1 grid-cols-[minmax(300px,360px)_1fr]",children:[h.jsxs("aside",{className:"flex min-h-0 flex-col border-r border-[var(--line)]",children:[h.jsxs("div",{className:"border-b border-[var(--line)] p-2",children:[h.jsxs("div",{className:"flex items-center gap-1.5 rounded-md border border-[var(--line)] px-2",children:[h.jsx("span",{className:"text-zinc-600",children:"#"}),h.jsx("input",{value:n,onChange:m=>r(m.target.value),placeholder:"filter by tag…",className:"mono w-full bg-transparent py-1.5 text-xs text-zinc-200 placeholder:text-zinc-600 focus:outline-none"}),n&&h.jsx("button",{type:"button",onClick:()=>r(""),className:"text-zinc-600 hover:text-zinc-300",title:"clear tag filter",children:h.jsx(Ke,{width:12,height:12})})]}),h.jsxs("div",{className:"mt-1.5 flex items-center gap-1.5 rounded-md border border-[var(--line)] px-2",children:[h.jsx("span",{className:"text-zinc-600",children:"⛃"}),h.jsx("input",{value:s,onChange:m=>i(m.target.value),placeholder:"attrs e.g. amount:gte:200, tier:eq:pro",title:"Typed search attributes: comma-separated key:op:value (ops eq ne gt gte lt lte)",className:"mono w-full bg-transparent py-1.5 text-xs text-zinc-200 placeholder:text-zinc-600 focus:outline-none"}),s&&h.jsx("button",{type:"button",onClick:()=>i(""),className:"text-zinc-600 hover:text-zinc-300",title:"clear attribute filter",children:h.jsx(Ke,{width:12,height:12})})]})]}),(e!=="all"||n||d.length>0)&&g.length>0&&h.jsxs("div",{className:"flex items-center gap-2 border-b border-[var(--line)] px-3 py-1.5",children:[h.jsxs("span",{className:"mono text-[10px] text-zinc-500",children:[g.length," ",e!=="all"?e:""," ",n&&`#${n}`,d.length>0&&` ⛃${d.length}`]}),h.jsx("button",{type:"button",disabled:u.isPending,onClick:()=>u.mutate("retry"),className:"mono ml-auto rounded border border-emerald-500/30 bg-emerald-500/10 px-1.5 py-0.5 text-[10px] text-emerald-300 transition-colors hover:bg-emerald-500/20 disabled:opacity-40",children:"retry all"}),h.jsx("button",{type:"button",disabled:u.isPending,onClick:()=>u.mutate("cancel"),className:"mono rounded border border-rose-500/30 bg-rose-500/10 px-1.5 py-0.5 text-[10px] text-rose-300 transition-colors hover:bg-rose-500/20 disabled:opacity-40",children:"cancel all"})]}),h.jsx("div",{className:"min-h-0 flex-1 overflow-auto",children:h.jsx(bp,{runs:g,selected:o,onSelect:c,onSelectTag:r})})]}),h.jsx("main",{className:"min-h-0",children:o?h.jsx(Np,{id:o,onOpenRun:c},o):h.jsx("div",{className:"grid h-full place-items-center text-center",children:h.jsxs("div",{className:"flex flex-col items-center",children:[h.jsx(Co,{className:"h-10 w-10 text-zinc-800"}),h.jsx("p",{className:"mt-3 text-sm text-zinc-600",children:"Select a run to see its timeline."})]})})})]})]})]})}const Ep=new Xa({defaultOptions:{queries:{refetchInterval:2e3,refetchOnWindowFocus:!1}}});qa(document.getElementById("root")).render(h.jsx(M.StrictMode,{children:h.jsx(Ya,{client:Ep,children:h.jsx(_p,{})})}));
|