@dudousxd/nestjs-durable-dashboard 0.25.0 → 0.26.1
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/client/group-by-partition.d.ts +21 -0
- package/dist/client/group-by-partition.d.ts.map +1 -0
- package/dist/client/group-by-partition.js +47 -0
- package/dist/client/group-by-partition.js.map +1 -0
- package/dist/client/pivot-by-worker.d.ts +24 -0
- package/dist/client/pivot-by-worker.d.ts.map +1 -0
- package/dist/client/pivot-by-worker.js +55 -0
- package/dist/client/pivot-by-worker.js.map +1 -0
- package/dist/client/queue-partition.d.ts +10 -0
- package/dist/client/queue-partition.d.ts.map +1 -0
- package/dist/client/queue-partition.js +16 -0
- package/dist/client/queue-partition.js.map +1 -0
- package/dist/client/summarize-health.d.ts +19 -0
- package/dist/client/summarize-health.d.ts.map +1 -0
- package/dist/client/summarize-health.js +22 -0
- package/dist/client/summarize-health.js.map +1 -0
- package/dist/spa/assets/index-BBid4ZlR.js +23 -0
- package/dist/spa/assets/index-EHrCNmbR.css +1 -0
- package/dist/spa/assets/{preview-B6V1trqM.js → preview-7bqvrLcS.js} +1 -1
- package/dist/spa/index.html +3 -3
- package/dist/spa/preview.html +3 -3
- package/package.json +1 -1
- package/dist/spa/assets/index-5kwYNGTJ.css +0 -1
- package/dist/spa/assets/index-DLFzyBlt.js +0 -23
- /package/dist/spa/assets/{index-CeRgaeH7.js → index-zpcKYdTD.js} +0 -0
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
var jr=e=>{throw TypeError(e)};var Cn=(e,t,n)=>t.has(e)||jr("Cannot "+n);var ne=(e,t,n)=>(Cn(e,t,"read from private field"),n?n.call(e):t.get(e)),Fe=(e,t,n)=>t.has(e)?jr("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),Oe=(e,t,n,r)=>(Cn(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),Ve=(e,t,n)=>(Cn(e,t,"access private method"),n);import{S as Ia,s as Aa,h as Cr,g as Pa,n as Ps,u as on,r as M,a as Ta,b as Da,c as qt,i as Ts,j as l,K as Bn,X as Ke,B as Ds,d as Ra,e as pt,R as Ha,C as Rs,f as La,k as ue,l as Ba,m as Fa,o as ir,p as Oa,q as Va,t as Xa,P as qa,v as Mn,w as Ya,Q as Wa,x as Ka,y as Ga}from"./index-zpcKYdTD.js";var Ie,Ae,oe,ye,Ne,Bt,Fn,As,Ua=(As=class extends Ia{constructor(t,n){super();Fe(this,Ne);Fe(this,Ie);Fe(this,Ae);Fe(this,oe);Fe(this,ye);Oe(this,Ie,t),this.setOptions(n),this.bindMethods(),Ve(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,Ie).defaultMutationOptions(t),Aa(this.options,n)||ne(this,Ie).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){Ve(this,Ne,Bt).call(this),Ve(this,Ne,Fn).call(this,t)}getCurrentResult(){return ne(this,Ae)}reset(){var t;(t=ne(this,oe))==null||t.removeObserver(this),Oe(this,oe,void 0),Ve(this,Ne,Bt).call(this),Ve(this,Ne,Fn).call(this)}mutate(t,n){var r;return Oe(this,ye,n),(r=ne(this,oe))==null||r.removeObserver(this),Oe(this,oe,ne(this,Ie).getMutationCache().build(ne(this,Ie),this.options)),ne(this,oe).addObserver(this),ne(this,oe).execute(t)}},Ie=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)??Pa();Oe(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})},Fn=function(t){Ps.batch(()=>{var n,r,s,i,o,a,c,u;if(ne(this,ye)&&this.hasListeners()){const d=ne(this,Ae).variables,h=ne(this,Ae).context;(t==null?void 0:t.type)==="success"?((r=(n=ne(this,ye)).onSuccess)==null||r.call(n,t.data,d,h),(i=(s=ne(this,ye)).onSettled)==null||i.call(s,t.data,null,d,h)):(t==null?void 0:t.type)==="error"&&((a=(o=ne(this,ye)).onError)==null||a.call(o,t.error,d,h),(u=(c=ne(this,ye)).onSettled)==null||u.call(c,void 0,t.error,d,h))}this.listeners.forEach(d=>{d(ne(this,Ae))})})},As);function lt(e,t){const n=on(),[r]=M.useState(()=>new Ua(n,e));M.useEffect(()=>{r.setOptions(e)},[r,e]);const s=M.useSyncExternalStore(M.useCallback(o=>r.subscribe(Ps.batchCalls(o)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),i=M.useCallback((o,a)=>{r.mutate(o,a).catch(Ta)},[r]);if(s.error&&Da(r.options.throwOnError,[s.error]))throw s.error;return{...s,mutate:i,mutateAsync:s.mutate}}function Yt(e){const t=e.lastIndexOf("@");return t===-1?"default":e.slice(t+1)}function Za(e){const t=e.lastIndexOf("@");return t===-1?e:e.slice(0,t)}function Qa(e){const t=new Map;for(const r of e){const s=Yt(r.group),i=t.get(s);i?i.push(r):t.set(s,[r])}return[...t.entries()].map(([r,s])=>{const i=new Set;let o=0,a=0;for(const c of s){o+=c.depth,c.depth>0&&c.liveWorkers.length===0&&(a+=1);for(const u of c.liveWorkers)i.add(u.instanceId)}return{partition:r,workerCount:i.size,handlerCount:s.length,totalDepth:o,starvedCount:a}}).sort((r,s)=>r.partition==="default"?-1:s.partition==="default"?1:r.partition.localeCompare(s.partition))}function Ja(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 ec(e){var n,r;const t=new Map;for(const s of e)for(const i of s.liveWorkers){const o=Za(i.group),a=t.get(i.instanceId);if(a===void 0){t.set(i.instanceId,{instanceId:i.instanceId,partition:Yt(i.group),runtime:(n=i.status)==null?void 0:n.runtime,handlers:new Set([o]),status:i.status,lastBeatAt:i.lastBeatAt});continue}a.handlers.add(o),i.lastBeatAt>=a.lastBeatAt&&(a.lastBeatAt=i.lastBeatAt,a.partition=Yt(i.group),a.runtime=(r=i.status)==null?void 0:r.runtime,a.status=i.status)}return[...t.values()].map(s=>({instanceId:s.instanceId,partition:s.partition,runtime:s.runtime,handlers:[...s.handlers].sort((i,o)=>i.localeCompare(o)),status:s.status,lastBeatAt:s.lastBeatAt})).sort((s,i)=>s.partition!==i.partition?s.partition==="default"?-1:i.partition==="default"?1:s.partition.localeCompare(i.partition):s.instanceId.localeCompare(i.instanceId))}function tc(e){const t=new Set;for(const r of e)for(const s of r.liveWorkers)t.add(s.instanceId);const n=e.filter(r=>r.depth>0&&r.liveWorkers.length===0).sort((r,s)=>s.depth-r.depth);return{queueCount:e.length,workerCount:t.size,starved:n,allDraining:n.length===0}}function Wt(e){return e<1e3?`${Math.round(e)}ms`:e<6e4?`${(e/1e3).toFixed(2)}s`:`${(e/6e4).toFixed(2)}m`}function Mr(e,t){return Wt(new Date(t).getTime()-new Date(e).getTime())}function $r(e){return or(new Date(e).getTime())}function or(e){return new Date(e).toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit",second:"2-digit",fractionalSecondDigits:3})}const Hs={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"},nc={debug:"text-zinc-500",info:"text-zinc-300",warn:"text-amber-300",error:"text-red-300"},rc=["ok","failed","skipped"];function Ls({e}){return l.jsxs("div",{className:"flex gap-2 py-0.5",children:[l.jsx("span",{className:"shrink-0 text-zinc-600 tnum",children:or(e.at)}),l.jsx("span",{className:`shrink-0 uppercase ${nc[e.level]}`,children:e.level}),l.jsx("span",{className:"min-w-0 break-words text-zinc-300",children:e.message})]})}function zr({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?Hs[e.status]:"border-amber-500/25 bg-amber-500/10 text-amber-300";return l.jsxs("li",{className:`rounded-md border ${o}`,children:[l.jsxs("button",{type:"button",disabled:!r,onClick:()=>i(u=>!u),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:[l.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[r&&l.jsx("span",{className:`text-[9px] text-zinc-500 transition-transform duration-150 ${s?"":"-rotate-90"}`,children:"▼"}),l.jsx("span",{className:"mono truncate text-zinc-200",children:e.name}),t&&e.group&&l.jsx("span",{className:"mono shrink-0 text-[10px] uppercase tracking-wider text-zinc-500",children:e.group})]}),l.jsxs("span",{className:"mono flex shrink-0 items-center gap-2 text-[10px] uppercase tracking-wider",children:[e.durationMs!==void 0&&l.jsx("span",{className:"tnum text-zinc-400",children:Wt(e.durationMs)}),l.jsx("span",{children:e.status??"running"})]})]}),s&&l.jsxs("div",{className:"border-t border-[var(--line)]/60 px-2.5 py-2",children:[e.phases.length>0&&l.jsx("ul",{className:"mono mb-2 flex flex-col gap-0.5 text-[10.5px]",children:e.phases.map((u,d)=>l.jsxs("li",{className:"flex gap-2",children:[l.jsx("span",{className:"shrink-0 text-zinc-600 tnum",children:or(u.at)}),l.jsx("span",{className:"text-zinc-400",children:u.phase}),e.startedAt!==void 0&&l.jsxs("span",{className:"text-zinc-600 tnum",children:["+",Wt(u.at-e.startedAt)]})]},`${u.at}-${u.phase}-${d}`))}),((c=e.terminal)==null?void 0:c.message)&&e.terminal.message!==e.name&&l.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&&l.jsx("div",{className:"mono flex flex-col gap-0.5 text-[11px]",children:e.logs.map((u,d)=>l.jsx(Ls,{e:u},`${u.at}-${d}`))})]})]})}function sc({events:e}){const{subs:t,stepLogs:n}=Ra(e),r=rc.map(i=>[i,t.filter(o=>o.status===i).length]).filter(([,i])=>i>0),s=t.some(i=>i.group);return l.jsxs(l.Fragment,{children:[t.length>0&&l.jsxs("section",{className:"rise",children:[l.jsxs("div",{className:"mb-1.5 flex items-center justify-between",children:[l.jsxs("span",{className:"mono text-[10px] uppercase tracking-[0.18em] text-zinc-500",children:["sub-processes · ",t.length]}),l.jsx("span",{className:"mono flex gap-2 text-[10px] uppercase tracking-wider",children:r.map(([i,o])=>l.jsxs("span",{className:Hs[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])=>l.jsxs("div",{className:"mb-2",children:[l.jsx("div",{className:"mono mb-1 text-[10px] uppercase tracking-wider text-zinc-500",children:i}),l.jsx("ul",{className:"flex flex-col gap-1",children:o.map(a=>l.jsx(zr,{sub:a,showGroup:!1},a.id))})]},i)):l.jsx("ul",{className:"flex flex-col gap-1",children:t.map(i=>l.jsx(zr,{sub:i},i.id))})]}),n.length>0&&l.jsxs("section",{className:"rise",children:[l.jsxs("div",{className:"mono mb-1.5 text-[10px] uppercase tracking-[0.18em] text-zinc-500",children:["logs · ",n.length]}),l.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)=>l.jsx(Ls,{e:i},`${i.at}-${o}`))})]})]})}function ic({value:e}){const[t,n]=M.useState(!1);return l.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?l.jsx(Rs,{width:11,height:11}):l.jsx(La,{width:11,height:11}),t?"copied":"copy"]})}function Kt({label:e,value:t}){const n=typeof t=="string"?t:JSON.stringify(t,null,2);return l.jsxs("section",{className:"rise",children:[l.jsxs("div",{className:"mb-1.5 flex items-center justify-between",children:[l.jsx("span",{className:"mono text-[10px] uppercase tracking-[0.18em] text-zinc-500",children:e}),l.jsx(ic,{value:n})]}),l.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 je({k:e,v:t,mono:n=!0}){return l.jsxs("div",{className:"flex items-baseline justify-between gap-3 py-1.5",children:[l.jsx("span",{className:"mono shrink-0 text-[10px] uppercase tracking-[0.16em] text-zinc-600",children:e}),l.jsx("span",{className:`truncate text-right text-[12px] text-zinc-200 ${n?"mono tnum":""}`,children:t})]})}function oc({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?l.jsxs("div",{className:"mono px-2 py-2 text-[10px] text-zinc-600",children:["no steps recorded yet — child ",n.run.status]}):l.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:l.jsx(Ha,{run:n.run,timeline:n.timeline,depth:0,onSelect:()=>{},onOpenRun:t??(()=>{}),expanded:r,onToggleChild:i})}):l.jsx("div",{className:"mono px-2 py-2 text-[10px] text-zinc-600",children:"loading child run…"})}function ac({step:e,run:t,onClose:n,onOpenRun:r}){const s=qt(e),[i,o]=M.useState(!1),a=e.status==="failed",c=e.status==="pending"||e.status==="running",u=Ts(e.kind),d=Mr(t.createdAt,e.startedAt),h=e.enqueuedAt?new Date(e.startedAt).getTime()-new Date(e.enqueuedAt).getTime():0;return l.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:[l.jsxs("div",{className:"flex items-start justify-between gap-3 border-b border-[var(--line)] px-5 py-4",children:[l.jsxs("div",{className:"min-w-0",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.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:l.jsx(u,{width:13,height:13})}),l.jsx("h3",{className:"truncate text-[15px] font-semibold tracking-tight text-zinc-50",children:e.name})]}),l.jsxs("div",{className:`mono mt-1 text-[11px] uppercase tracking-wider s-${e.status}`,children:[e.status," · ",Bn[e.kind]??e.kind]})]}),l.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:l.jsx(Ke,{})})]}),l.jsxs("div",{className:"flex min-h-0 flex-1 flex-col gap-4 overflow-auto px-5 py-4",children:[l.jsxs("div",{className:"rounded-lg border border-[var(--line)] bg-black/20 px-3.5 py-1",children:[l.jsx(je,{k:"seq",v:`#${e.seq}`}),h>=1&&l.jsx(je,{k:"queued",v:l.jsx("span",{className:"text-sky-300",children:Wt(h)})}),l.jsx(je,{k:"duration",v:c?l.jsx("span",{className:"text-amber-300",children:"running…"}):Mr(e.startedAt,e.finishedAt)}),l.jsx(je,{k:"attempts",v:l.jsxs("span",{className:e.attempts>1?"text-amber-300":"",children:[e.attempts>1&&l.jsx(Ds,{width:11,height:11,className:"mr-1 inline"}),e.attempts]})}),e.workerGroup&&l.jsx(je,{k:"worker",v:`@${e.workerGroup}`}),l.jsx(je,{k:"started",v:$r(e.startedAt)}),l.jsx(je,{k:"finished",v:$r(e.finishedAt)}),l.jsx(je,{k:"offset",v:`+${d}`})]}),a&&e.error&&l.jsxs("section",{className:"rise",children:[l.jsx("div",{className:"mono mb-1.5 text-[10px] uppercase tracking-[0.18em] text-red-400/80",children:"error"}),l.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&&l.jsx(sc,{events:e.events}),s&&l.jsxs("section",{className:"rise",children:[l.jsxs("div",{className:"mb-1.5 flex items-center justify-between",children:[l.jsx("span",{className:"mono text-[10px] uppercase tracking-[0.18em] text-zinc-500",children:"child run"}),r&&l.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 ↗"})]}),l.jsxs("button",{type:"button",onClick:()=>o(f=>!f),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:[l.jsx("span",{className:"inline-block text-[9px] text-indigo-300 transition-transform",style:{transform:i?"rotate(90deg)":"rotate(0deg)"},children:"▸"}),l.jsx("span",{className:"mono truncate text-[11px] text-indigo-300",children:s})]}),i&&l.jsx(oc,{id:s,onOpenRun:r})]}),e.input!==void 0&&l.jsx(Kt,{label:"input",value:e.input}),e.output!==void 0&&l.jsx(Kt,{label:"output",value:e.output})]})]})}function cc({run:e,onClose:t}){const n=e.input===void 0&&e.output===void 0&&!e.error;return l.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:[l.jsxs("div",{className:"flex items-start justify-between gap-3 border-b border-[var(--line)] px-5 py-4",children:[l.jsxs("div",{className:"min-w-0",children:[l.jsx("h3",{className:"truncate text-[15px] font-semibold tracking-tight text-zinc-50",children:e.workflow}),l.jsxs("div",{className:`mono mt-1 text-[11px] uppercase tracking-wider s-${e.status}`,children:["run · ",e.status]})]}),l.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:l.jsx(Ke,{})})]}),l.jsxs("div",{className:"flex min-h-0 flex-1 flex-col gap-4 overflow-auto px-5 py-4",children:[e.error&&l.jsxs("section",{className:"rise",children:[l.jsx("div",{className:"mono mb-1.5 text-[10px] uppercase tracking-[0.18em] text-red-400/80",children:"error"}),l.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&&l.jsx(Kt,{label:"input",value:e.input}),e.output!==void 0&&l.jsx(Kt,{label:"output",value:e.output}),n&&l.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 lc={value:()=>{}};function an(){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 Ft(n)}function Ft(e){this._=e}function uc(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}})}Ft.prototype=an.prototype={constructor:Ft,on:function(e,t){var n=this._,r=uc(e+"",n),s,i=-1,o=r.length;if(arguments.length<2){for(;++i<o;)if((s=(e=r[i]).type)&&(s=dc(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 Ft(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 dc(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]=lc,e=e.slice(0,r).concat(e.slice(r+1));break}return n!=null&&e.push({name:t,value:n}),e}var On="http://www.w3.org/1999/xhtml";const Ar={svg:"http://www.w3.org/2000/svg",xhtml:On,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function cn(e){var t=e+="",n=t.indexOf(":");return n>=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),Ar.hasOwnProperty(t)?{space:Ar[t],local:e}:e}function fc(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===On&&t.documentElement.namespaceURI===On?t.createElement(e):t.createElementNS(n,e)}}function hc(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function Bs(e){var t=cn(e);return(t.local?hc:fc)(t)}function pc(){}function ar(e){return e==null?pc:function(){return this.querySelector(e)}}function gc(e){typeof e!="function"&&(e=ar(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,u,d=0;d<o;++d)(c=i[d])&&(u=e.call(c,c.__data__,d,i))&&("__data__"in c&&(u.__data__=c.__data__),a[d]=u);return new le(r,this._parents)}function mc(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function xc(){return[]}function Fs(e){return e==null?xc:function(){return this.querySelectorAll(e)}}function yc(e){return function(){return mc(e.apply(this,arguments))}}function wc(e){typeof e=="function"?e=yc(e):e=Fs(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,u=0;u<a;++u)(c=o[u])&&(r.push(e.call(c,c.__data__,u,o)),s.push(c));return new le(r,s)}function Os(e){return function(){return this.matches(e)}}function Vs(e){return function(t){return t.matches(e)}}var vc=Array.prototype.find;function bc(e){return function(){return vc.call(this.children,e)}}function Nc(){return this.firstElementChild}function _c(e){return this.select(e==null?Nc:bc(typeof e=="function"?e:Vs(e)))}var Sc=Array.prototype.filter;function Ec(){return Array.from(this.children)}function kc(e){return function(){return Sc.call(this.children,e)}}function jc(e){return this.selectAll(e==null?Ec:kc(typeof e=="function"?e:Vs(e)))}function Cc(e){typeof e!="function"&&(e=Os(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,u=0;u<o;++u)(c=i[u])&&e.call(c,c.__data__,u,i)&&a.push(c);return new le(r,this._parents)}function Xs(e){return new Array(e.length)}function Mc(){return new le(this._enter||this._groups.map(Xs),this._parents)}function Gt(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}Gt.prototype={constructor:Gt,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 zc(e,t,n,r,s,i){for(var o=0,a,c=t.length,u=i.length;o<u;++o)(a=t[o])?(a.__data__=i[o],r[o]=a):n[o]=new Gt(e,i[o]);for(;o<c;++o)(a=t[o])&&(s[o]=a)}function Ic(e,t,n,r,s,i,o){var a,c,u=new Map,d=t.length,h=i.length,f=new Array(d),p;for(a=0;a<d;++a)(c=t[a])&&(f[a]=p=o.call(c,c.__data__,a,t)+"",u.has(p)?s[a]=c:u.set(p,c));for(a=0;a<h;++a)p=o.call(e,i[a],a,i)+"",(c=u.get(p))?(r[a]=c,c.__data__=i[a],u.delete(p)):n[a]=new Gt(e,i[a]);for(a=0;a<d;++a)(c=t[a])&&u.get(f[a])===c&&(s[a]=c)}function Ac(e){return e.__data__}function Pc(e,t){if(!arguments.length)return Array.from(this,Ac);var n=t?Ic:zc,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),u=0;u<i;++u){var d=r[u],h=s[u],f=h.length,p=Tc(e.call(d,d&&d.__data__,u,r)),g=p.length,x=a[u]=new Array(g),v=o[u]=new Array(g),y=c[u]=new Array(f);n(d,h,x,v,y,p,t);for(var S=0,b=0,w,C;S<g;++S)if(w=x[S]){for(S>=b&&(b=S+1);!(C=v[b])&&++b<g;);w._next=C||null}}return o=new le(o,r),o._enter=a,o._exit=c,o}function Tc(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function Dc(){return new le(this._exit||this._groups.map(Xs),this._parents)}function Rc(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 Hc(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 u=n[c],d=r[c],h=u.length,f=a[c]=new Array(h),p,g=0;g<h;++g)(p=u[g]||d[g])&&(f[g]=p);for(;c<s;++c)a[c]=n[c];return new le(a,this._parents)}function Lc(){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 Bc(e){e||(e=Fc);function t(h,f){return h&&f?e(h.__data__,f.__data__):!h-!f}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),u,d=0;d<a;++d)(u=o[d])&&(c[d]=u);c.sort(t)}return new le(s,this._parents).order()}function Fc(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function Oc(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function Vc(){return Array.from(this)}function Xc(){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 qc(){let e=0;for(const t of this)++e;return e}function Yc(){return!this.node()}function Wc(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 Kc(e){return function(){this.removeAttribute(e)}}function Gc(e){return function(){this.removeAttributeNS(e.space,e.local)}}function Uc(e,t){return function(){this.setAttribute(e,t)}}function Zc(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 Jc(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 el(e,t){var n=cn(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?Gc:Kc:typeof t=="function"?n.local?Jc:Qc:n.local?Zc:Uc)(n,t))}function qs(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function tl(e){return function(){this.style.removeProperty(e)}}function nl(e,t,n){return function(){this.style.setProperty(e,t,n)}}function rl(e,t,n){return function(){var r=t.apply(this,arguments);r==null?this.style.removeProperty(e):this.style.setProperty(e,r,n)}}function sl(e,t,n){return arguments.length>1?this.each((t==null?tl:typeof t=="function"?rl:nl)(e,t,n??"")):Ge(this.node(),e)}function Ge(e,t){return e.style.getPropertyValue(t)||qs(e).getComputedStyle(e,null).getPropertyValue(t)}function il(e){return function(){delete this[e]}}function ol(e,t){return function(){this[e]=t}}function al(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function cl(e,t){return arguments.length>1?this.each((t==null?il:typeof t=="function"?al:ol)(e,t)):this.node()[e]}function Ys(e){return e.trim().split(/^|\s+/)}function cr(e){return e.classList||new Ws(e)}function Ws(e){this._node=e,this._names=Ys(e.getAttribute("class")||"")}Ws.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 Ks(e,t){for(var n=cr(e),r=-1,s=t.length;++r<s;)n.add(t[r])}function Gs(e,t){for(var n=cr(e),r=-1,s=t.length;++r<s;)n.remove(t[r])}function ll(e){return function(){Ks(this,e)}}function ul(e){return function(){Gs(this,e)}}function dl(e,t){return function(){(t.apply(this,arguments)?Ks:Gs)(this,e)}}function fl(e,t){var n=Ys(e+"");if(arguments.length<2){for(var r=cr(this.node()),s=-1,i=n.length;++s<i;)if(!r.contains(n[s]))return!1;return!0}return this.each((typeof t=="function"?dl:t?ll:ul)(n,t))}function hl(){this.textContent=""}function pl(e){return function(){this.textContent=e}}function gl(e){return function(){var t=e.apply(this,arguments);this.textContent=t??""}}function ml(e){return arguments.length?this.each(e==null?hl:(typeof e=="function"?gl:pl)(e)):this.node().textContent}function xl(){this.innerHTML=""}function yl(e){return function(){this.innerHTML=e}}function wl(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??""}}function vl(e){return arguments.length?this.each(e==null?xl:(typeof e=="function"?wl:yl)(e)):this.node().innerHTML}function bl(){this.nextSibling&&this.parentNode.appendChild(this)}function Nl(){return this.each(bl)}function _l(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function Sl(){return this.each(_l)}function El(e){var t=typeof e=="function"?e:Bs(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function kl(){return null}function jl(e,t){var n=typeof e=="function"?e:Bs(e),r=t==null?kl:typeof t=="function"?t:ar(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),r.apply(this,arguments)||null)})}function Cl(){var e=this.parentNode;e&&e.removeChild(this)}function Ml(){return this.each(Cl)}function $l(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function zl(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Il(e){return this.select(e?zl:$l)}function Al(e){return arguments.length?this.property("__data__",e):this.node().__data__}function Pl(e){return function(t){e.call(this,t,this.__data__)}}function Tl(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 Dl(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 Rl(e,t,n){return function(){var r=this.__on,s,i=Pl(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 Hl(e,t,n){var r=Tl(e+""),s,i=r.length,o;if(arguments.length<2){var a=this.node().__on;if(a){for(var c=0,u=a.length,d;c<u;++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?Rl:Dl,s=0;s<i;++s)this.each(a(r[s],t,n));return this}function Us(e,t,n){var r=qs(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 Ll(e,t){return function(){return Us(this,e,t)}}function Bl(e,t){return function(){return Us(this,e,t.apply(this,arguments))}}function Fl(e,t){return this.each((typeof t=="function"?Bl:Ll)(e,t))}function*Ol(){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 Zs=[null];function le(e,t){this._groups=e,this._parents=t}function Et(){return new le([[document.documentElement]],Zs)}function Vl(){return this}le.prototype=Et.prototype={constructor:le,select:gc,selectAll:wc,selectChild:_c,selectChildren:jc,filter:Cc,data:Pc,enter:Mc,exit:Dc,join:Rc,merge:Hc,selection:Vl,order:Lc,sort:Bc,call:Oc,nodes:Vc,node:Xc,size:qc,empty:Yc,each:Wc,attr:el,style:sl,property:cl,classed:fl,text:ml,html:vl,raise:Nl,lower:Sl,append:El,insert:jl,remove:Ml,clone:Il,datum:Al,on:Hl,dispatch:Fl,[Symbol.iterator]:Ol};function ce(e){return typeof e=="string"?new le([[document.querySelector(e)]],[document.documentElement]):new le([[e]],Zs)}function Xl(e){let t;for(;t=e.sourceEvent;)e=t;return e}function de(e,t){if(e=Xl(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 ql={passive:!1},gt={capture:!0,passive:!1};function $n(e){e.stopImmediatePropagation()}function Ye(e){e.preventDefault(),e.stopImmediatePropagation()}function Qs(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 Js(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 zt=e=>()=>e;function Vn(e,{sourceEvent:t,subject:n,target:r,identifier:s,active:i,x:o,y:a,dx:c,dy:u,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:u,enumerable:!0,configurable:!0},_:{value:d}})}Vn.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function Yl(e){return!e.ctrlKey&&!e.button}function Wl(){return this.parentNode}function Kl(e,t){return t??{x:e.x,y:e.y}}function Gl(){return navigator.maxTouchPoints||"ontouchstart"in this}function ei(){var e=Yl,t=Wl,n=Kl,r=Gl,s={},i=an("start","drag","end"),o=0,a,c,u,d,h=0;function f(w){w.on("mousedown.drag",p).filter(r).on("touchstart.drag",v).on("touchmove.drag",y,ql).on("touchend.drag touchcancel.drag",S).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function p(w,C){if(!(d||!e.call(this,w,C))){var R=b(this,t.call(this,w,C),w,C,"mouse");R&&(ce(w.view).on("mousemove.drag",g,gt).on("mouseup.drag",x,gt),Qs(w.view),$n(w),u=!1,a=w.clientX,c=w.clientY,R("start",w))}}function g(w){if(Ye(w),!u){var C=w.clientX-a,R=w.clientY-c;u=C*C+R*R>h}s.mouse("drag",w)}function x(w){ce(w.view).on("mousemove.drag mouseup.drag",null),Js(w.view,u),Ye(w),s.mouse("end",w)}function v(w,C){if(e.call(this,w,C)){var R=w.changedTouches,j=t.call(this,w,C),z=R.length,A,P;for(A=0;A<z;++A)(P=b(this,j,w,C,R[A].identifier,R[A]))&&($n(w),P("start",w,R[A]))}}function y(w){var C=w.changedTouches,R=C.length,j,z;for(j=0;j<R;++j)(z=s[C[j].identifier])&&(Ye(w),z("drag",w,C[j]))}function S(w){var C=w.changedTouches,R=C.length,j,z;for(d&&clearTimeout(d),d=setTimeout(function(){d=null},500),j=0;j<R;++j)(z=s[C[j].identifier])&&($n(w),z("end",w,C[j]))}function b(w,C,R,j,z,A){var P=i.copy(),L=de(A||R,C),T,D,m;if((m=n.call(w,new Vn("beforestart",{sourceEvent:R,target:f,identifier:z,active:o,x:L[0],y:L[1],dx:0,dy:0,dispatch:P}),j))!=null)return T=m.x-L[0]||0,D=m.y-L[1]||0,function k(_,I,N){var E=L,$;switch(_){case"start":s[z]=k,$=o++;break;case"end":delete s[z],--o;case"drag":L=de(N||I,C),$=o;break}P.call(_,w,new Vn(_,{sourceEvent:I,subject:m,target:f,identifier:z,active:$,x:L[0]+T,y:L[1]+D,dx:L[0]-E[0],dy:L[1]-E[1],dispatch:P}),j)}}return f.filter=function(w){return arguments.length?(e=typeof w=="function"?w:zt(!!w),f):e},f.container=function(w){return arguments.length?(t=typeof w=="function"?w:zt(w),f):t},f.subject=function(w){return arguments.length?(n=typeof w=="function"?w:zt(w),f):n},f.touchable=function(w){return arguments.length?(r=typeof w=="function"?w:zt(!!w),f):r},f.on=function(){var w=i.on.apply(i,arguments);return w===i?f:w},f.clickDistance=function(w){return arguments.length?(h=(w=+w)*w,f):Math.sqrt(h)},f}function lr(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function ti(e,t){var n=Object.create(e.prototype);for(var r in t)n[r]=t[r];return n}function kt(){}var mt=.7,Ut=1/mt,We="\\s*([+-]?\\d+)\\s*",xt="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",ge="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",Ul=/^#([0-9a-f]{3,8})$/,Zl=new RegExp(`^rgb\\(${We},${We},${We}\\)$`),Ql=new RegExp(`^rgb\\(${ge},${ge},${ge}\\)$`),Jl=new RegExp(`^rgba\\(${We},${We},${We},${xt}\\)$`),eu=new RegExp(`^rgba\\(${ge},${ge},${ge},${xt}\\)$`),tu=new RegExp(`^hsl\\(${xt},${ge},${ge}\\)$`),nu=new RegExp(`^hsla\\(${xt},${ge},${ge},${xt}\\)$`),Pr={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};lr(kt,yt,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:Tr,formatHex:Tr,formatHex8:ru,formatHsl:su,formatRgb:Dr,toString:Dr});function Tr(){return this.rgb().formatHex()}function ru(){return this.rgb().formatHex8()}function su(){return ni(this).formatHsl()}function Dr(){return this.rgb().formatRgb()}function yt(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=Ul.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?Rr(t):n===3?new ae(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?It(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?It(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=Zl.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=Jl.exec(e))?It(t[1],t[2],t[3],t[4]):(t=eu.exec(e))?It(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=tu.exec(e))?Br(t[1],t[2]/100,t[3]/100,1):(t=nu.exec(e))?Br(t[1],t[2]/100,t[3]/100,t[4]):Pr.hasOwnProperty(e)?Rr(Pr[e]):e==="transparent"?new ae(NaN,NaN,NaN,0):null}function Rr(e){return new ae(e>>16&255,e>>8&255,e&255,1)}function It(e,t,n,r){return r<=0&&(e=t=n=NaN),new ae(e,t,n,r)}function iu(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 Xn(e,t,n,r){return arguments.length===1?iu(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}lr(ae,Xn,ti(kt,{brighter(e){return e=e==null?Ut:Math.pow(Ut,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),Zt(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:Hr,formatHex:Hr,formatHex8:ou,formatRgb:Lr,toString:Lr}));function Hr(){return`#${De(this.r)}${De(this.g)}${De(this.b)}`}function ou(){return`#${De(this.r)}${De(this.g)}${De(this.b)}${De((isNaN(this.opacity)?1:this.opacity)*255)}`}function Lr(){const e=Zt(this.opacity);return`${e===1?"rgb(":"rgba("}${Re(this.r)}, ${Re(this.g)}, ${Re(this.b)}${e===1?")":`, ${e})`}`}function Zt(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 Br(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 ni(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 au(e,t,n,r){return arguments.length===1?ni(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}lr(fe,au,ti(kt,{brighter(e){return e=e==null?Ut:Math.pow(Ut,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(zn(e>=240?e-240:e+120,s,r),zn(e,s,r),zn(e<120?e+240:e-120,s,r),this.opacity)},clamp(){return new fe(Fr(this.h),At(this.s),At(this.l),Zt(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=Zt(this.opacity);return`${e===1?"hsl(":"hsla("}${Fr(this.h)}, ${At(this.s)*100}%, ${At(this.l)*100}%${e===1?")":`, ${e})`}`}}));function Fr(e){return e=(e||0)%360,e<0?e+360:e}function At(e){return Math.max(0,Math.min(1,e||0))}function zn(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 ri=e=>()=>e;function cu(e,t){return function(n){return e+n*t}}function lu(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 uu(e){return(e=+e)==1?si:function(t,n){return n-t?lu(t,n,e):ri(isNaN(t)?n:t)}}function si(e,t){var n=t-e;return n?cu(e,n):ri(isNaN(e)?t:e)}const Or=function e(t){var n=uu(t);function r(s,i){var o=n((s=Xn(s)).r,(i=Xn(i)).r),a=n(s.g,i.g),c=n(s.b,i.b),u=si(s.opacity,i.opacity);return function(d){return s.r=o(d),s.g=a(d),s.b=c(d),s.opacity=u(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 qn=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,In=new RegExp(qn.source,"g");function du(e){return function(){return e}}function fu(e){return function(t){return e(t)+""}}function hu(e,t){var n=qn.lastIndex=In.lastIndex=0,r,s,i,o=-1,a=[],c=[];for(e=e+"",t=t+"";(r=qn.exec(e))&&(s=In.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=In.lastIndex;return n<t.length&&(i=t.slice(n),a[o]?a[o]+=i:a[++o]=i),a.length<2?c[0]?fu(c[0].x):du(t):(t=c.length,function(u){for(var d=0,h;d<t;++d)a[(h=c[d]).i]=h.x(u);return a.join("")})}var Vr=180/Math.PI,Yn={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function ii(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)*Vr,skewX:Math.atan(c)*Vr,scaleX:o,scaleY:a}}var Pt;function pu(e){const t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?Yn:ii(t.a,t.b,t.c,t.d,t.e,t.f)}function gu(e){return e==null||(Pt||(Pt=document.createElementNS("http://www.w3.org/2000/svg","g")),Pt.setAttribute("transform",e),!(e=Pt.transform.baseVal.consolidate()))?Yn:(e=e.matrix,ii(e.a,e.b,e.c,e.d,e.e,e.f))}function oi(e,t,n,r){function s(u){return u.length?u.pop()+" ":""}function i(u,d,h,f,p,g){if(u!==h||d!==f){var x=p.push("translate(",null,t,null,n);g.push({i:x-4,x:$e(u,h)},{i:x-2,x:$e(d,f)})}else(h||f)&&p.push("translate("+h+t+f+n)}function o(u,d,h,f){u!==d?(u-d>180?d+=360:d-u>180&&(u+=360),f.push({i:h.push(s(h)+"rotate(",null,r)-2,x:$e(u,d)})):d&&h.push(s(h)+"rotate("+d+r)}function a(u,d,h,f){u!==d?f.push({i:h.push(s(h)+"skewX(",null,r)-2,x:$e(u,d)}):d&&h.push(s(h)+"skewX("+d+r)}function c(u,d,h,f,p,g){if(u!==h||d!==f){var x=p.push(s(p)+"scale(",null,",",null,")");g.push({i:x-4,x:$e(u,h)},{i:x-2,x:$e(d,f)})}else(h!==1||f!==1)&&p.push(s(p)+"scale("+h+","+f+")")}return function(u,d){var h=[],f=[];return u=e(u),d=e(d),i(u.translateX,u.translateY,d.translateX,d.translateY,h,f),o(u.rotate,d.rotate,h,f),a(u.skewX,d.skewX,h,f),c(u.scaleX,u.scaleY,d.scaleX,d.scaleY,h,f),u=d=null,function(p){for(var g=-1,x=f.length,v;++g<x;)h[(v=f[g]).i]=v.x(p);return h.join("")}}}var mu=oi(pu,"px, ","px)","deg)"),xu=oi(gu,", ",")",")"),yu=1e-12;function Xr(e){return((e=Math.exp(e))+1/e)/2}function wu(e){return((e=Math.exp(e))-1/e)/2}function vu(e){return((e=Math.exp(2*e))-1)/(e+1)}const bu=function e(t,n,r){function s(i,o){var a=i[0],c=i[1],u=i[2],d=o[0],h=o[1],f=o[2],p=d-a,g=h-c,x=p*p+g*g,v,y;if(x<yu)y=Math.log(f/u)/t,v=function(j){return[a+j*p,c+j*g,u*Math.exp(t*j*y)]};else{var S=Math.sqrt(x),b=(f*f-u*u+r*x)/(2*u*n*S),w=(f*f-u*u-r*x)/(2*f*n*S),C=Math.log(Math.sqrt(b*b+1)-b),R=Math.log(Math.sqrt(w*w+1)-w);y=(R-C)/t,v=function(j){var z=j*y,A=Xr(C),P=u/(n*S)*(A*vu(t*z+C)-wu(C));return[a+P*p,c+P*g,u*A/Xr(t*z+C)]}}return v.duration=y*1e3*t/Math.SQRT2,v}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,ai=1e3,Qt,dt,Jt=0,Le=0,ln=0,wt=typeof performance=="object"&&performance.now?performance:Date,ci=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function ur(){return Le||(ci(Nu),Le=wt.now()+ln)}function Nu(){Le=0}function en(){this._call=this._time=this._next=null}en.prototype=li.prototype={constructor:en,restart:function(e,t,n){if(typeof e!="function")throw new TypeError("callback is not a function");n=(n==null?ur():+n)+(t==null?0:+t),!this._next&&dt!==this&&(dt?dt._next=this:Qt=this,dt=this),this._call=e,this._time=n,Wn()},stop:function(){this._call&&(this._call=null,this._time=1/0,Wn())}};function li(e,t,n){var r=new en;return r.restart(e,t,n),r}function _u(){ur(),++Ue;for(var e=Qt,t;e;)(t=Le-e._time)>=0&&e._call.call(void 0,t),e=e._next;--Ue}function qr(){Le=(Jt=wt.now())+ln,Ue=ut=0;try{_u()}finally{Ue=0,Eu(),Le=0}}function Su(){var e=wt.now(),t=e-Jt;t>ai&&(ln-=t,Jt=e)}function Eu(){for(var e,t=Qt,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:Qt=n);dt=e,Wn(r)}function Wn(e){if(!Ue){ut&&(ut=clearTimeout(ut));var t=e-Le;t>24?(e<1/0&&(ut=setTimeout(qr,e-wt.now()-ln)),at&&(at=clearInterval(at))):(at||(Jt=wt.now(),at=setInterval(Su,ai)),Ue=1,ci(qr))}}function Yr(e,t,n){var r=new en;return t=t==null?0:+t,r.restart(s=>{r.stop(),e(s+t)},t,n),r}var ku=an("start","end","cancel","interrupt"),ju=[],ui=0,Wr=1,Kn=2,Ot=3,Kr=4,Gn=5,Vt=6;function un(e,t,n,r,s,i){var o=e.__transition;if(!o)e.__transition={};else if(n in o)return;Cu(e,n,{name:t,index:r,group:s,on:ku,tween:ju,time:i.time,delay:i.delay,duration:i.duration,ease:i.ease,timer:null,state:ui})}function dr(e,t){var n=pe(e,t);if(n.state>ui)throw new Error("too late; already scheduled");return n}function me(e,t){var n=pe(e,t);if(n.state>Ot)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 Cu(e,t,n){var r=e.__transition,s;r[t]=n,n.timer=li(i,0,n.time);function i(u){n.state=Wr,n.timer.restart(o,n.delay,n.time),n.delay<=u&&o(u-n.delay)}function o(u){var d,h,f,p;if(n.state!==Wr)return c();for(d in r)if(p=r[d],p.name===n.name){if(p.state===Ot)return Yr(o);p.state===Kr?(p.state=Vt,p.timer.stop(),p.on.call("interrupt",e,e.__data__,p.index,p.group),delete r[d]):+d<t&&(p.state=Vt,p.timer.stop(),p.on.call("cancel",e,e.__data__,p.index,p.group),delete r[d])}if(Yr(function(){n.state===Ot&&(n.state=Kr,n.timer.restart(a,n.delay,n.time),a(u))}),n.state=Kn,n.on.call("start",e,e.__data__,n.index,n.group),n.state===Kn){for(n.state=Ot,s=new Array(f=n.tween.length),d=0,h=-1;d<f;++d)(p=n.tween[d].value.call(e,e.__data__,n.index,n.group))&&(s[++h]=p);s.length=h+1}}function a(u){for(var d=u<n.duration?n.ease.call(null,u/n.duration):(n.timer.restart(c),n.state=Gn,1),h=-1,f=s.length;++h<f;)s[h].call(e,d);n.state===Gn&&(n.on.call("end",e,e.__data__,n.index,n.group),c())}function c(){n.state=Vt,n.timer.stop(),delete r[t];for(var u 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>Kn&&r.state<Gn,r.state=Vt,r.timer.stop(),r.on.call(s?"interrupt":"cancel",e,e.__data__,r.index,r.group),delete n[o]}i&&delete e.__transition}}function Mu(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 zu(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,u=s.length;c<u;++c)if(s[c].name===t){s[c]=a;break}c===u&&s.push(a)}i.tween=s}}function Iu(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:zu)(n,e,t))}function fr(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 di(e,t){var n;return(typeof t=="number"?$e:t instanceof yt?Or:(n=yt(t))?(t=n,Or):hu)(e,t)}function Au(e){return function(){this.removeAttribute(e)}}function Pu(e){return function(){this.removeAttributeNS(e.space,e.local)}}function Tu(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 Du(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 Ru(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 Hu(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 Lu(e,t){var n=cn(e),r=n==="transform"?xu:di;return this.attrTween(e,typeof t=="function"?(n.local?Hu:Ru)(n,r,fr(this,"attr."+e,t)):t==null?(n.local?Pu:Au)(n):(n.local?Du:Tu)(n,r,t))}function Bu(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function Fu(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function Ou(e,t){var n,r;function s(){var i=t.apply(this,arguments);return i!==r&&(n=(r=i)&&Fu(e,i)),n}return s._value=t,s}function Vu(e,t){var n,r;function s(){var i=t.apply(this,arguments);return i!==r&&(n=(r=i)&&Bu(e,i)),n}return s._value=t,s}function Xu(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=cn(e);return this.tween(n,(r.local?Ou:Vu)(r,t))}function qu(e,t){return function(){dr(this,e).delay=+t.apply(this,arguments)}}function Yu(e,t){return t=+t,function(){dr(this,e).delay=t}}function Wu(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?qu:Yu)(t,e)):pe(this.node(),t).delay}function Ku(e,t){return function(){me(this,e).duration=+t.apply(this,arguments)}}function Gu(e,t){return t=+t,function(){me(this,e).duration=t}}function Uu(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?Ku:Gu)(t,e)):pe(this.node(),t).duration}function Zu(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(Zu(t,e)):pe(this.node(),t).ease}function Ju(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!="function")throw new Error;me(this,e).ease=n}}function ed(e){if(typeof e!="function")throw new Error;return this.each(Ju(this._id,e))}function td(e){typeof e!="function"&&(e=Os(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,u=0;u<o;++u)(c=i[u])&&e.call(c,c.__data__,u,i)&&a.push(c);return new _e(r,this._parents,this._name,this._id)}function nd(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],u=n[a],d=c.length,h=o[a]=new Array(d),f,p=0;p<d;++p)(f=c[p]||u[p])&&(h[p]=f);for(;a<r;++a)o[a]=t[a];return new _e(o,this._parents,this._name,this._id)}function rd(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 sd(e,t,n){var r,s,i=rd(t)?dr:me;return function(){var o=i(this,e),a=o.on;a!==r&&(s=(r=a).copy()).on(t,n),o.on=s}}function id(e,t){var n=this._id;return arguments.length<2?pe(this.node(),n).on.on(e):this.each(sd(n,e,t))}function od(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function ad(){return this.on("end.remove",od(this._id))}function cd(e){var t=this._name,n=this._id;typeof e!="function"&&(e=ar(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,u=i[o]=new Array(c),d,h,f=0;f<c;++f)(d=a[f])&&(h=e.call(d,d.__data__,f,a))&&("__data__"in d&&(h.__data__=d.__data__),u[f]=h,un(u[f],t,n,f,u,pe(d,n)));return new _e(i,this._parents,t,n)}function ld(e){var t=this._name,n=this._id;typeof e!="function"&&(e=Fs(e));for(var r=this._groups,s=r.length,i=[],o=[],a=0;a<s;++a)for(var c=r[a],u=c.length,d,h=0;h<u;++h)if(d=c[h]){for(var f=e.call(d,d.__data__,h,c),p,g=pe(d,n),x=0,v=f.length;x<v;++x)(p=f[x])&&un(p,t,n,x,f,g);i.push(f),o.push(d)}return new _e(i,o,t,n)}var ud=Et.prototype.constructor;function dd(){return new ud(this._groups,this._parents)}function fd(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 fi(e){return function(){this.style.removeProperty(e)}}function hd(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 pd(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 gd(e,t){var n,r,s,i="style."+t,o="end."+i,a;return function(){var c=me(this,e),u=c.on,d=c.value[i]==null?a||(a=fi(t)):void 0;(u!==n||s!==d)&&(r=(n=u).copy()).on(o,s=d),c.on=r}}function md(e,t,n){var r=(e+="")=="transform"?mu:di;return t==null?this.styleTween(e,fd(e,r)).on("end.style."+e,fi(e)):typeof t=="function"?this.styleTween(e,pd(e,r,fr(this,"style."+e,t))).each(gd(this._id,e)):this.styleTween(e,hd(e,r,t),n).on("end.style."+e,null)}function xd(e,t,n){return function(r){this.style.setProperty(e,t.call(this,r),n)}}function yd(e,t,n){var r,s;function i(){var o=t.apply(this,arguments);return o!==s&&(r=(s=o)&&xd(e,o,n)),r}return i._value=t,i}function wd(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,yd(e,t,n??""))}function vd(e){return function(){this.textContent=e}}function bd(e){return function(){var t=e(this);this.textContent=t??""}}function Nd(e){return this.tween("text",typeof e=="function"?bd(fr(this,"text",e)):vd(e==null?"":e+""))}function _d(e){return function(t){this.textContent=e.call(this,t)}}function Sd(e){var t,n;function r(){var s=e.apply(this,arguments);return s!==n&&(t=(n=s)&&_d(s)),t}return r._value=e,r}function Ed(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,Sd(e))}function kd(){for(var e=this._name,t=this._id,n=hi(),r=this._groups,s=r.length,i=0;i<s;++i)for(var o=r[i],a=o.length,c,u=0;u<a;++u)if(c=o[u]){var d=pe(c,t);un(c,e,n,u,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 jd(){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 u=me(this,r),d=u.on;d!==e&&(t=(e=d).copy(),t._.cancel.push(a),t._.interrupt.push(a),t._.end.push(c)),u.on=t}),s===0&&i()})}var Cd=0;function _e(e,t,n,r){this._groups=e,this._parents=t,this._name=n,this._id=r}function hi(){return++Cd}var xe=Et.prototype;_e.prototype={constructor:_e,select:cd,selectAll:ld,selectChild:xe.selectChild,selectChildren:xe.selectChildren,filter:td,merge:nd,selection:dd,transition:kd,call:xe.call,nodes:xe.nodes,node:xe.node,size:xe.size,empty:xe.empty,each:xe.each,on:id,attr:Lu,attrTween:Xu,style:md,styleTween:wd,text:Nd,textTween:Ed,remove:ad,tween:Iu,delay:Wu,duration:Uu,ease:Qu,easeVarying:ed,end:jd,[Symbol.iterator]:xe[Symbol.iterator]};function Md(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var $d={time:null,delay:0,duration:250,ease:Md};function zd(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 Id(e){var t,n;e instanceof _e?(t=e._id,e=e._name):(t=hi(),(n=$d).time=ur(),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,u=0;u<a;++u)(c=o[u])&&un(c,e,t,u,o,n||zd(c,t));return new _e(r,this._parents,e,t)}Et.prototype.interrupt=Mu;Et.prototype.transition=Id;const Tt=e=>()=>e;function Ad(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 dn=new we(1,0,0);pi.prototype=we.prototype;function pi(e){for(;!e.__zoom;)if(!(e=e.parentNode))return dn;return e.__zoom}function An(e){e.stopImmediatePropagation()}function ct(e){e.preventDefault(),e.stopImmediatePropagation()}function Pd(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function Td(){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 Gr(){return this.__zoom||dn}function Dd(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function Rd(){return navigator.maxTouchPoints||"ontouchstart"in this}function Hd(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 gi(){var e=Pd,t=Td,n=Hd,r=Dd,s=Rd,i=[0,1/0],o=[[-1/0,-1/0],[1/0,1/0]],a=250,c=bu,u=an("start","zoom","end"),d,h,f,p=500,g=150,x=0,v=10;function y(m){m.property("__zoom",Gr).on("wheel.zoom",z,{passive:!1}).on("mousedown.zoom",A).on("dblclick.zoom",P).filter(s).on("touchstart.zoom",L).on("touchmove.zoom",T).on("touchend.zoom touchcancel.zoom",D).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}y.transform=function(m,k,_,I){var N=m.selection?m.selection():m;N.property("__zoom",Gr),m!==N?C(m,k,_,I):N.interrupt().each(function(){R(this,arguments).event(I).start().zoom(null,typeof k=="function"?k.apply(this,arguments):k).end()})},y.scaleBy=function(m,k,_,I){y.scaleTo(m,function(){var N=this.__zoom.k,E=typeof k=="function"?k.apply(this,arguments):k;return N*E},_,I)},y.scaleTo=function(m,k,_,I){y.transform(m,function(){var N=t.apply(this,arguments),E=this.__zoom,$=_==null?w(N):typeof _=="function"?_.apply(this,arguments):_,H=E.invert($),B=typeof k=="function"?k.apply(this,arguments):k;return n(b(S(E,B),$,H),N,o)},_,I)},y.translateBy=function(m,k,_,I){y.transform(m,function(){return n(this.__zoom.translate(typeof k=="function"?k.apply(this,arguments):k,typeof _=="function"?_.apply(this,arguments):_),t.apply(this,arguments),o)},null,I)},y.translateTo=function(m,k,_,I,N){y.transform(m,function(){var E=t.apply(this,arguments),$=this.__zoom,H=I==null?w(E):typeof I=="function"?I.apply(this,arguments):I;return n(dn.translate(H[0],H[1]).scale($.k).translate(typeof k=="function"?-k.apply(this,arguments):-k,typeof _=="function"?-_.apply(this,arguments):-_),E,o)},I,N)};function S(m,k){return k=Math.max(i[0],Math.min(i[1],k)),k===m.k?m:new we(k,m.x,m.y)}function b(m,k,_){var I=k[0]-_[0]*m.k,N=k[1]-_[1]*m.k;return I===m.x&&N===m.y?m:new we(m.k,I,N)}function w(m){return[(+m[0][0]+ +m[1][0])/2,(+m[0][1]+ +m[1][1])/2]}function C(m,k,_,I){m.on("start.zoom",function(){R(this,arguments).event(I).start()}).on("interrupt.zoom end.zoom",function(){R(this,arguments).event(I).end()}).tween("zoom",function(){var N=this,E=arguments,$=R(N,E).event(I),H=t.apply(N,E),B=_==null?w(H):typeof _=="function"?_.apply(N,E):_,q=Math.max(H[1][0]-H[0][0],H[1][1]-H[0][1]),O=N.__zoom,V=typeof k=="function"?k.apply(N,E):k,X=c(O.invert(B).concat(q/O.k),V.invert(B).concat(q/V.k));return function(K){if(K===1)K=V;else{var F=X(K),W=q/F[2];K=new we(W,B[0]-F[0]*W,B[1]-F[1]*W)}$.zoom(null,K)}})}function R(m,k,_){return!_&&m.__zooming||new j(m,k)}function j(m,k){this.that=m,this.args=k,this.active=0,this.sourceEvent=null,this.extent=t.apply(m,k),this.taps=0}j.prototype={event:function(m){return m&&(this.sourceEvent=m),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(m,k){return this.mouse&&m!=="mouse"&&(this.mouse[1]=k.invert(this.mouse[0])),this.touch0&&m!=="touch"&&(this.touch0[1]=k.invert(this.touch0[0])),this.touch1&&m!=="touch"&&(this.touch1[1]=k.invert(this.touch1[0])),this.that.__zoom=k,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(m){var k=ce(this.that).datum();u.call(m,this.that,new Ad(m,{sourceEvent:this.sourceEvent,target:y,transform:this.that.__zoom,dispatch:u}),k)}};function z(m,...k){if(!e.apply(this,arguments))return;var _=R(this,k).event(m),I=this.__zoom,N=Math.max(i[0],Math.min(i[1],I.k*Math.pow(2,r.apply(this,arguments)))),E=de(m);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(m),_.wheel=setTimeout($,g),_.zoom("mouse",n(b(S(I,N),_.mouse[0],_.mouse[1]),_.extent,o));function $(){_.wheel=null,_.end()}}function A(m,...k){if(f||!e.apply(this,arguments))return;var _=m.currentTarget,I=R(this,k,!0).event(m),N=ce(m.view).on("mousemove.zoom",B,!0).on("mouseup.zoom",q,!0),E=de(m,_),$=m.clientX,H=m.clientY;Qs(m.view),An(m),I.mouse=[E,this.__zoom.invert(E)],Xt(this),I.start();function B(O){if(ct(O),!I.moved){var V=O.clientX-$,X=O.clientY-H;I.moved=V*V+X*X>x}I.event(O).zoom("mouse",n(b(I.that.__zoom,I.mouse[0]=de(O,_),I.mouse[1]),I.extent,o))}function q(O){N.on("mousemove.zoom mouseup.zoom",null),Js(O.view,I.moved),ct(O),I.event(O).end()}}function P(m,...k){if(e.apply(this,arguments)){var _=this.__zoom,I=de(m.changedTouches?m.changedTouches[0]:m,this),N=_.invert(I),E=_.k*(m.shiftKey?.5:2),$=n(b(S(_,E),I,N),t.apply(this,k),o);ct(m),a>0?ce(this).transition().duration(a).call(C,$,I,m):ce(this).call(y.transform,$,I,m)}}function L(m,...k){if(e.apply(this,arguments)){var _=m.touches,I=_.length,N=R(this,k,m.changedTouches.length===I).event(m),E,$,H,B;for(An(m),$=0;$<I;++$)H=_[$],B=de(H,this),B=[B,this.__zoom.invert(B),H.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&&(h=B[0],d=setTimeout(function(){d=null},p)),Xt(this),N.start())}}function T(m,...k){if(this.__zooming){var _=R(this,k).event(m),I=m.changedTouches,N=I.length,E,$,H,B;for(ct(m),E=0;E<N;++E)$=I[E],H=de($,this),_.touch0&&_.touch0[2]===$.identifier?_.touch0[0]=H:_.touch1&&_.touch1[2]===$.identifier&&(_.touch1[0]=H);if($=_.that.__zoom,_.touch1){var q=_.touch0[0],O=_.touch0[1],V=_.touch1[0],X=_.touch1[1],K=(K=V[0]-q[0])*K+(K=V[1]-q[1])*K,F=(F=X[0]-O[0])*F+(F=X[1]-O[1])*F;$=S($,Math.sqrt(K/F)),H=[(q[0]+V[0])/2,(q[1]+V[1])/2],B=[(O[0]+X[0])/2,(O[1]+X[1])/2]}else if(_.touch0)H=_.touch0[0],B=_.touch0[1];else return;_.zoom("touch",n(b($,H,B),_.extent,o))}}function D(m,...k){if(this.__zooming){var _=R(this,k).event(m),I=m.changedTouches,N=I.length,E,$;for(An(m),f&&clearTimeout(f),f=setTimeout(function(){f=null},p),E=0;E<N;++E)$=I[E],_.touch0&&_.touch0[2]===$.identifier?delete _.touch0:_.touch1&&_.touch1[2]===$.identifier&&delete _.touch1;if(_.touch1&&!_.touch0&&(_.touch0=_.touch1,delete _.touch1),_.touch0)_.touch0[1]=this.__zoom.invert(_.touch0[0]);else if(_.end(),_.taps===2&&($=de($,this),Math.hypot(h[0]-$[0],h[1]-$[1])<v)){var H=ce(this).on("dblclick.zoom");H&&H.apply(this,arguments)}}}return y.wheelDelta=function(m){return arguments.length?(r=typeof m=="function"?m:Tt(+m),y):r},y.filter=function(m){return arguments.length?(e=typeof m=="function"?m:Tt(!!m),y):e},y.touchable=function(m){return arguments.length?(s=typeof m=="function"?m:Tt(!!m),y):s},y.extent=function(m){return arguments.length?(t=typeof m=="function"?m:Tt([[+m[0][0],+m[0][1]],[+m[1][0],+m[1][1]]]),y):t},y.scaleExtent=function(m){return arguments.length?(i[0]=+m[0],i[1]=+m[1],y):[i[0],i[1]]},y.translateExtent=function(m){return arguments.length?(o[0][0]=+m[0][0],o[1][0]=+m[1][0],o[0][1]=+m[0][1],o[1][1]=+m[1][1],y):[[o[0][0],o[0][1]],[o[1][0],o[1][1]]]},y.constrain=function(m){return arguments.length?(n=m,y):n},y.duration=function(m){return arguments.length?(a=+m,y):a},y.interpolate=function(m){return arguments.length?(c=m,y):c},y.on=function(){var m=u.on.apply(u,arguments);return m===u?y:m},y.clickDistance=function(m){return arguments.length?(x=(m=+m)*m,y):Math.sqrt(x)},y.tapDistance=function(m){return arguments.length?(v=+m,y):v},y}const Se={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]],mi=["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 xi={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null};var ze;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(ze||(ze={}));var tn;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(tn||(tn={}));var Y;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(Y||(Y={}));const Ur={[Y.Left]:Y.Right,[Y.Right]:Y.Left,[Y.Top]:Y.Bottom,[Y.Bottom]:Y.Top};function yi(e){return e===null?null:e?"valid":"invalid"}const wi=e=>"id"in e&&"source"in e&&"target"in e,Ld=e=>"id"in e&&"position"in e&&!("source"in e)&&!("target"in e),hr=e=>"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e),jt=(e,t=[0,0])=>{const{width:n,height:r}=Ee(e),s=e.origin??t,i=n*s[0],o=r*s[1];return{x:e.position.x-i,y:e.position.y-o}},Bd=(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):hr(s)?s:t.nodeLookup.get(s.id));const a=o?nn(o,t.nodeOrigin):{x:0,y:0,x2:0,y2:0};return fn(r,a)},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return hn(n)},Ct=(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=nn(r);n=fn(n,s)}}),hn(n)},vi=(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 u of e.values()){const{measured:d,selectable:h=!0,hidden:f=!1}=u;if(o&&!h||f)continue;const p=d.width??u.width??u.initialWidth??null,g=d.height??u.height??u.initialHeight??null,x=Nt(a,Je(u)),v=(p??0)*(g??0),y=i&&x>0;(!u.internals.handleBounds||y||x>=v||u.dragging)&&c.push(u)}return c},Fd=(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 Un(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 Zn({nodes:e,width:t,height:n,panZoom:r,minZoom:s,maxZoom:i},o){if(e.size===0)return Promise.resolve(!1);const a=Ct(e),c=pr(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 bi({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:u}=a?a.internals.positionAbsolute:{x:0,y:0},d=o.origin??r;let h=s;if(o.extent==="parent"&&!o.expandParent)if(!a)i==null||i("005",Se.error005());else{const p=a.measured.width,g=a.measured.height;p&&g&&(h=[[c,u],[c+p,u+g]])}else a&&et(o.extent)&&(h=[[o.extent[0][0]+c,o.extent[0][1]+u],[o.extent[1][0]+c,o.extent[1][1]+u]]);const f=et(h)?Be(t,h,o.measured):t;return{position:{x:f.x-c+o.measured.width*d[0],y:f.y-u+o.measured.height*d[1]},positionAbsolute:f}}async function Od({nodesToRemove:e=[],edgesToRemove:t=[],nodes:n,edges:r,onBeforeDelete:s}){const i=new Set(e.map(f=>f.id)),o=[];for(const f of n){if(f.deletable===!1)continue;const p=i.has(f.id),g=!p&&f.parentId&&o.find(x=>x.id===f.parentId);(p||g)&&o.push(f)}const a=new Set(t.map(f=>f.id)),c=r.filter(f=>f.deletable!==!1),d=Fd(o,c);for(const f of c)a.has(f.id)&&!d.find(g=>g.id===f.id)&&d.push(f);if(!s)return{edges:d,nodes:o};const h=await s({nodes:o,edges:d});return typeof h=="boolean"?h?{edges:d,nodes:o}:{edges:[],nodes:[]}:h}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 Ni(e,t,n){const{width:r,height:s}=Ee(n),{x:i,y:o}=n.internals.positionAbsolute;return Be(e,[[i,o],[i+r,o+s]],t)}const Zr=(e,t,n)=>e<t?Qe(Math.abs(e-t),1,t)/t:e>n?-Qe(Math.abs(e-n),1,t)/t:0,_i=(e,t,n=15,r=40)=>{const s=Zr(e.x,r,t.width-r)*n,i=Zr(e.y,r,t.height-r)*n;return[s,i]},fn=(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)}),Qn=({x:e,y:t,width:n,height:r})=>({x:e,y:t,x2:e+n,y2:t+r}),hn=({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}=hr(e)?e.internals.positionAbsolute:jt(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}},nn=(e,t=[0,0])=>{var s,i;const{x:n,y:r}=hr(e)?e.internals.positionAbsolute:jt(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)}},Si=(e,t)=>hn(fn(Qn(e),Qn(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)},Qr=e=>he(e.width)&&he(e.height)&&he(e.x)&&he(e.y),he=e=>!isNaN(e)&&isFinite(e),Vd=(e,t)=>{},pn=(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?pn(a,o):a},Ei=({x:e,y:t},[n,r,s])=>({x:e*s+n,y:t*s+r}),pr=(e,t,n,r,s,i)=>{const o=t/(e.width*(1+i)),a=n/(e.height*(1+i)),c=Math.min(o,a),u=Qe(c,r,s),d=e.x+e.width/2,h=e.y+e.height/2,f=t/2-d*u,p=n/2-h*u;return{x:f,y:p,zoom:u}},rn=()=>{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 Ee(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 ki(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 ji(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:u}=n?pn(a,t):a;return{xSnapped:c,ySnapped:u,...a}}const gn=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)},Xd=["INPUT","SELECT","TEXTAREA"];function Jn(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 Xd.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 Mi=e=>"clientX"in e,ve=(e,t)=>{var i,o;const n=Mi(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)}},Jr=(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,...gn(o)}})};function $i({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,u=t*.125+i*.375+a*.375+r*.125,d=Math.abs(c-e),h=Math.abs(u-t);return[c,u,d,h]}function Dt(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function es({pos:e,x1:t,y1:n,x2:r,y2:s,c:i}){switch(e){case Y.Left:return[t-Dt(t-r,i),n];case Y.Right:return[t+Dt(r-t,i),n];case Y.Top:return[t,n-Dt(n-s,i)];case Y.Bottom:return[t,n+Dt(s-n,i)]}}function zi({sourceX:e,sourceY:t,sourcePosition:n=Y.Bottom,targetX:r,targetY:s,targetPosition:i=Y.Top,curvature:o=.25}){const[a,c]=es({pos:n,x1:e,y1:t,x2:r,y2:s,c:o}),[u,d]=es({pos:i,x1:r,y1:s,x2:e,y2:t,c:o}),[h,f,p,g]=$i({sourceX:e,sourceY:t,targetX:r,targetY:s,sourceControlX:a,sourceControlY:c,targetControlX:u,targetControlY:d});return[`M${e},${t} C${a},${c} ${u},${d} ${r},${s}`,h,f,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 qd({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 Yd({sourceNode:e,targetNode:t,width:n,height:r,transform:s}){const i=fn(nn(e),nn(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,hn(i))>0}const Wd=({source:e,sourceHandle:t,target:n,targetHandle:r})=>`xy-edge__${e}${t||""}-${n}${r||""}`,Kd=(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)),Gd=(e,t)=>{if(!e.source||!e.target)return t;let n;return wi(e)?n={...e}:n={...e,id:Wd(e)},Kd(n,t)?t:(n.sourceHandle===null&&delete n.sourceHandle,n.targetHandle===null&&delete n.targetHandle,t.concat(n))};function Ai({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 ts={[Y.Left]:{x:-1,y:0},[Y.Right]:{x:1,y:0},[Y.Top]:{x:0,y:-1},[Y.Bottom]:{x:0,y:1}},Ud=({source:e,sourcePosition:t=Y.Bottom,target:n})=>t===Y.Left||t===Y.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},ns=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function Zd({source:e,sourcePosition:t=Y.Bottom,target:n,targetPosition:r=Y.Top,center:s,offset:i}){const o=ts[t],a=ts[r],c={x:e.x+o.x*i,y:e.y+o.y*i},u={x:n.x+a.x*i,y:n.y+a.y*i},d=Ud({source:c,sourcePosition:t,target:u}),h=d.x!==0?"x":"y",f=d[h];let p=[],g,x;const v={x:0,y:0},y={x:0,y:0},[S,b,w,C]=Ii({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(o[h]*a[h]===-1){g=s.x??S,x=s.y??b;const j=[{x:g,y:c.y},{x:g,y:u.y}],z=[{x:c.x,y:x},{x:u.x,y:x}];o[h]===f?p=h==="x"?j:z:p=h==="x"?z:j}else{const j=[{x:c.x,y:u.y}],z=[{x:u.x,y:c.y}];if(h==="x"?p=o.x===f?z:j:p=o.y===f?j:z,t===r){const D=Math.abs(e[h]-n[h]);if(D<=i){const m=Math.min(i-1,i-D);o[h]===f?v[h]=(c[h]>e[h]?-1:1)*m:y[h]=(u[h]>n[h]?-1:1)*m}}if(t!==r){const D=h==="x"?"y":"x",m=o[h]===a[D],k=c[D]>u[D],_=c[D]<u[D];(o[h]===1&&(!m&&k||m&&_)||o[h]!==1&&(!m&&_||m&&k))&&(p=h==="x"?j:z)}const A={x:c.x+v.x,y:c.y+v.y},P={x:u.x+y.x,y:u.y+y.y},L=Math.max(Math.abs(A.x-p[0].x),Math.abs(P.x-p[0].x)),T=Math.max(Math.abs(A.y-p[0].y),Math.abs(P.y-p[0].y));L>=T?(g=(A.x+P.x)/2,x=p[0].y):(g=p[0].x,x=(A.y+P.y)/2)}return[[e,{x:c.x+v.x,y:c.y+v.y},...p,{x:u.x+y.x,y:u.y+y.y},n],g,x,w,C]}function Qd(e,t,n,r){const s=Math.min(ns(e,t)/2,ns(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 u=e.x<n.x?-1:1,d=e.y<n.y?1:-1;return`L ${i+s*u},${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 er({sourceX:e,sourceY:t,sourcePosition:n=Y.Bottom,targetX:r,targetY:s,targetPosition:i=Y.Top,borderRadius:o=5,centerX:a,centerY:c,offset:u=20}){const[d,h,f,p,g]=Zd({source:{x:e,y:t},sourcePosition:n,target:{x:r,y:s},targetPosition:i,center:{x:a,y:c},offset:u});return[d.reduce((v,y,S)=>{let b="";return S>0&&S<d.length-1?b=Qd(d[S-1],y,d[S+1],o):b=`${S===0?"M":"L"}${y.x} ${y.y}`,v+=b,v},""),h,f,p,g]}function rs(e){var t;return e&&!!(e.internals.handleBounds||(t=e.handles)!=null&&t.length)&&!!(e.measured.width||e.width||e.initialWidth)}function Jd(e){var h;const{sourceNode:t,targetNode:n}=e;if(!rs(t)||!rs(n))return null;const r=t.internals.handleBounds||ss(t.handles),s=n.internals.handleBounds||ss(n.handles),i=is((r==null?void 0:r.source)??[],e.sourceHandle),o=is(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(h=e.onError)==null||h.call(e,"008",Se.error008(i?"target":"source",{id:e.id,sourceHandle:e.sourceHandle,targetHandle:e.targetHandle})),null;const a=(i==null?void 0:i.position)||Y.Bottom,c=(o==null?void 0:o.position)||Y.Top,u=_t(t,i,a),d=_t(n,o,c);return{sourceX:u.x,sourceY:u.y,targetX:d.x,targetY:d.y,sourcePosition:a,targetPosition:c}}function ss(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=Y.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??Ee(e);if(r)return{x:s+o/2,y:i+a/2};switch((t==null?void 0:t.position)??n){case Y.Top:return{x:s+o/2,y:i};case Y.Right:return{x:s+o,y:i+a/2};case Y.Bottom:return{x:s+o/2,y:i+a};case Y.Left:return{x:s,y:i+a/2}}}function is(e,t){return e&&(t?e.find(n=>n.id===t):e[0])||null}function tr(e,t){return e?typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(r=>`${r}=${e[r]}`).join("&")}`:""}function ef(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 u=tr(c,t);i.has(u)||(o.push({id:u,color:c.color||n,...c}),i.add(u))}}),o),[]).sort((o,a)=>o.id.localeCompare(a.id))}const gr={nodeOrigin:[0,0],nodeExtent:vt,elevateNodesOnSelect:!0,defaults:{}},tf={...gr,checkEquality:!0};function mr(e,t){const n={...e};for(const r in t)t[r]!==void 0&&(n[r]=t[r]);return n}function nf(e,t,n){const r=mr(gr,n);for(const s of e.values())if(s.parentId)xr(s,e,t,r);else{const i=jt(s,r.nodeOrigin),o=et(s.extent)?s.extent:r.nodeExtent,a=Be(i,o,Ee(s));s.internals.positionAbsolute=a}}function nr(e,t,n,r){var a,c;const s=mr(tf,r),i=new Map(t),o=s!=null&&s.elevateNodesOnSelect?1e3:0;t.clear(),n.clear();for(const u of e){let d=i.get(u.id);if(s.checkEquality&&u===(d==null?void 0:d.internals.userNode))t.set(u.id,d);else{const h=jt(u,s.nodeOrigin),f=et(u.extent)?u.extent:s.nodeExtent,p=Be(h,f,Ee(u));d={...s.defaults,...u,measured:{width:(a=u.measured)==null?void 0:a.width,height:(c=u.measured)==null?void 0:c.height},internals:{positionAbsolute:p,handleBounds:u.measured?d==null?void 0:d.internals.handleBounds:void 0,z:Pi(u,o),userNode:u}},t.set(u.id,d)}u.parentId&&xr(d,t,n,r)}}function rf(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 xr(e,t,n,r){const{elevateNodesOnSelect:s,nodeOrigin:i,nodeExtent:o}=mr(gr,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}rf(e,n);const u=s?1e3:0,{x:d,y:h,z:f}=sf(e,c,i,o,u),{positionAbsolute:p}=e.internals,g=d!==p.x||h!==p.y;(g||f!==e.internals.z)&&(e.internals={...e.internals,positionAbsolute:g?{x:d,y:h}:p,z:f})}function Pi(e,t){return(he(e.zIndex)?e.zIndex:0)+(e.selected?t:0)}function sf(e,t,n,r,s){const{x:i,y:o}=t.internals.positionAbsolute,a=Ee(e),c=jt(e,n),u=et(e.extent)?Be(c,e.extent,a):c;let d=Be({x:i+u.x,y:o+u.y},r,a);e.extent==="parent"&&(d=Ni(d,a,t));const h=Pi(e,s),f=t.internals.z??0;return{x:d.x,y:d.y,z:f>h?f:h}}function yr(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 u=((o=i.get(a.parentId))==null?void 0:o.expandedRect)??Je(c),d=Si(u,a.rect);i.set(a.parentId,{expandedRect:d,parent:c})}return i.size>0&&i.forEach(({expandedRect:a,parent:c},u)=>{var b;const d=c.internals.positionAbsolute,h=Ee(c),f=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,x=Math.max(h.width,Math.round(a.width)),v=Math.max(h.height,Math.round(a.height)),y=(x-h.width)*f[0],S=(v-h.height)*f[1];(p>0||g>0||y||S)&&(s.push({id:u,type:"position",position:{x:c.position.x-p+y,y:c.position.y-g+S}}),(b=n.get(u))==null||b.forEach(w=>{e.some(C=>C.id===w.id)||s.push({id:w.id,type:"position",position:{x:w.position.x+p,y:w.position.y+g}})})),(h.width<a.width||h.height<a.height||p||g)&&s.push({id:u,type:"dimensions",setAttributes:!0,dimensions:{width:x+(p?f[0]*p-y:0),height:v+(g?f[1]*g-S:0)}})}),s}function of(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=[],u=window.getComputedStyle(o),{m22:d}=new window.DOMMatrixReadOnly(u.transform),h=[];for(const f of e.values()){const p=t.get(f.id);if(p)if(p.hidden)p.internals={...p.internals,handleBounds:void 0},a=!0;else{const g=gn(f.nodeElement),x=p.measured.width!==g.width||p.measured.height!==g.height;if(!!(g.width&&g.height&&(x||!p.internals.handleBounds||f.force))){const y=f.nodeElement.getBoundingClientRect(),S=et(p.extent)?p.extent:i;let{positionAbsolute:b}=p.internals;p.parentId&&p.extent==="parent"?b=Ni(b,g,t.get(p.parentId)):S&&(b=Be(b,S,g)),p.measured=g,p.internals={...p.internals,positionAbsolute:b,handleBounds:{source:Jr("source",f.nodeElement,y,d,p.id),target:Jr("target",f.nodeElement,y,d,p.id)}},p.parentId&&xr(p,t,n,{nodeOrigin:s}),a=!0,x&&(c.push({id:p.id,type:"dimensions",dimensions:g}),p.expandParent&&p.parentId&&h.push({id:p.id,parentId:p.parentId,rect:Je(p,s)}))}}}if(h.length>0){const f=yr(h,t,n,s);c.push(...f)}return{changes:c,updatedInternals:a}}async function af({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}`,u=`${i}-target-${a}`,d=e.get(c)||new Map,h=e.get(u)||new Map,f={edgeId:r.id,source:s,target:i,sourceHandle:o,targetHandle:a};t.set(r.id,r),e.set(c,d.set(`${i}-${a}`,f)),e.set(u,h.set(`${s}-${o}`,f))}}function Di(e,t){if(!e.parentId)return!1;const n=t.get(e.parentId);return n?n.selected?!0:Di(n,t):!1}function os(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 cf(e,t,n,r){const s=new Map;for(const[i,o]of e)if((o.selected||o.id===r)&&(!o.parentId||!Di(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 Pn({nodeId:e,dragItems:t,nodeLookup:n,dragging:r=!0}){var o,a,c;const s=[];for(const[u,d]of t){const h=(o=n.get(u))==null?void 0:o.internals.userNode;h&&s.push({...h,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 lf({onNodeMouseDown:e,getStoreItems:t,onDragStart:n,onDrag:r,onDragStop:s}){let i={x:null,y:null},o=0,a=new Map,c=!1,u={x:0,y:0},d=null,h=!1,f=null,p=!1;function g({noDragClassName:v,handleSelector:y,domNode:S,isSelectable:b,nodeId:w,nodeClickDistance:C=0}){f=ce(S);function R({x:P,y:L},T){const{nodeLookup:D,nodeExtent:m,snapGrid:k,snapToGrid:_,nodeOrigin:I,onNodeDrag:N,onSelectionDrag:E,onError:$,updateNodePositions:H}=t();i={x:P,y:L};let B=!1,q={x:0,y:0,x2:0,y2:0};if(a.size>1&&m){const O=Ct(a);q=Qn(O)}for(const[O,V]of a){if(!D.has(O))continue;let X={x:P-V.distance.x,y:L-V.distance.y};_&&(X=pn(X,k));let K=[[m[0][0],m[0][1]],[m[1][0],m[1][1]]];if(a.size>1&&m&&!V.extent){const{positionAbsolute:Z}=V.internals,U=Z.x-q.x+m[0][0],G=Z.x+V.measured.width-q.x2+m[1][0],J=Z.y-q.y+m[0][1],ee=Z.y+V.measured.height-q.y2+m[1][1];K=[[U,J],[G,ee]]}const{position:F,positionAbsolute:W}=bi({nodeId:O,nextPosition:X,nodeLookup:D,nodeExtent:K,nodeOrigin:I,onError:$});B=B||V.position.x!==F.x||V.position.y!==F.y,V.position=F,V.internals.positionAbsolute=W}if(B&&(H(a,!0),T&&(r||N||!w&&E))){const[O,V]=Pn({nodeId:w,dragItems:a,nodeLookup:D});r==null||r(T,a,O,V),N==null||N(T,O,V),w||E==null||E(T,V)}}async function j(){if(!d)return;const{transform:P,panBy:L,autoPanSpeed:T}=t(),[D,m]=_i(u,d,T);(D!==0||m!==0)&&(i.x=(i.x??0)-D/P[2],i.y=(i.y??0)-m/P[2],await L({x:D,y:m})&&R(i,null)),o=requestAnimationFrame(j)}function z(P){var B;const{nodeLookup:L,multiSelectionActive:T,nodesDraggable:D,transform:m,snapGrid:k,snapToGrid:_,selectNodesOnDrag:I,onNodeDragStart:N,onSelectionDragStart:E,unselectNodesAndEdges:$}=t();h=!0,(!I||!b)&&!T&&w&&((B=L.get(w))!=null&&B.selected||$()),b&&I&&w&&(e==null||e(w));const H=ft(P.sourceEvent,{transform:m,snapGrid:k,snapToGrid:_,containerBounds:d});if(i=H,a=cf(L,D,H,w),a.size>0&&(n||N||!w&&E)){const[q,O]=Pn({nodeId:w,dragItems:a,nodeLookup:L});n==null||n(P.sourceEvent,a,q,O),N==null||N(P.sourceEvent,q,O),w||E==null||E(P.sourceEvent,O)}}const A=ei().clickDistance(C).on("start",P=>{const{domNode:L,nodeDragThreshold:T,transform:D,snapGrid:m,snapToGrid:k}=t();d=(L==null?void 0:L.getBoundingClientRect())||null,p=!1,T===0&&z(P),i=ft(P.sourceEvent,{transform:D,snapGrid:m,snapToGrid:k,containerBounds:d}),u=ve(P.sourceEvent,d)}).on("drag",P=>{const{autoPanOnNodeDrag:L,transform:T,snapGrid:D,snapToGrid:m,nodeDragThreshold:k,nodeLookup:_}=t(),I=ft(P.sourceEvent,{transform:T,snapGrid:D,snapToGrid:m,containerBounds:d});if((P.sourceEvent.type==="touchmove"&&P.sourceEvent.touches.length>1||w&&!_.has(w))&&(p=!0),!p){if(!c&&L&&h&&(c=!0,j()),!h){const N=I.xSnapped-(i.x??0),E=I.ySnapped-(i.y??0);Math.sqrt(N*N+E*E)>k&&z(P)}(i.x!==I.xSnapped||i.y!==I.ySnapped)&&a&&h&&(u=ve(P.sourceEvent,d),R(I,P.sourceEvent))}}).on("end",P=>{if(!(!h||p)&&(c=!1,h=!1,cancelAnimationFrame(o),a.size>0)){const{nodeLookup:L,updateNodePositions:T,onNodeDragStop:D,onSelectionDragStop:m}=t();if(T(a,!1),s||D||!w&&m){const[k,_]=Pn({nodeId:w,dragItems:a,nodeLookup:L,dragging:!1});s==null||s(P.sourceEvent,a,k,_),D==null||D(P.sourceEvent,k,_),w||m==null||m(P.sourceEvent,_)}}}).filter(P=>{const L=P.target;return!P.button&&(!v||!os(L,`.${v}`,S))&&(!y||os(L,y,S))});f.call(A)}function x(){f==null||f.on(".drag",null)}return{update:g,destroy:x}}function uf(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 df=250;function ff(e,t,n,r){var a,c;let s=[],i=1/0;const o=uf(e,n,t+df);for(const u of o){const d=[...((a=u.internals.handleBounds)==null?void 0:a.source)??[],...((c=u.internals.handleBounds)==null?void 0:c.target)??[]];for(const h of d){if(r.nodeId===h.nodeId&&r.type===h.type&&r.id===h.id)continue;const{x:f,y:p}=_t(u,h,h.position,!0),g=Math.sqrt(Math.pow(f-e.x,2)+Math.pow(p-e.y,2));g>t||(g<i?(s=[{...h,x:f,y:p}],i=g):g===i&&s.push({...h,x:f,y:p}))}}if(!s.length)return null;if(s.length>1){const u=r.type==="source"?"target":"source";return s.find(d=>d.type===u)??s[0]}return s[0]}function Ri(e,t,n,r,s,i=!1){var u,d,h;const o=r.get(e);if(!o)return null;const a=s==="strict"?(u=o.internals.handleBounds)==null?void 0:u[t]:[...((d=o.internals.handleBounds)==null?void 0:d.source)??[],...((h=o.internals.handleBounds)==null?void 0:h.target)??[]],c=(n?a==null?void 0:a.find(f=>f.id===n):a==null?void 0:a[0])??null;return c&&i?{...c,..._t(o,c,c.position,!0)}:c}function Hi(e,t){return e||(t!=null&&t.classList.contains("target")?"target":t!=null&&t.classList.contains("source")?"source":null)}function hf(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}const Li=()=>!0;function pf(e,{connectionMode:t,connectionRadius:n,handleId:r,nodeId:s,edgeUpdaterType:i,isTarget:o,domNode:a,nodeLookup:c,lib:u,autoPanOnConnect:d,flowId:h,panBy:f,cancelConnection:p,onConnectStart:g,onConnect:x,onConnectEnd:v,isValidConnection:y=Li,onReconnectEnd:S,updateConnection:b,getTransform:w,getFromHandle:C,autoPanSpeed:R}){const j=Ci(e.target);let z=0,A;const{x:P,y:L}=ve(e),T=j==null?void 0:j.elementFromPoint(P,L),D=Hi(i,T),m=a==null?void 0:a.getBoundingClientRect();if(!m||!D)return;const k=Ri(s,D,r,c,t);if(!k)return;let _=ve(e,m),I=!1,N=null,E=!1,$=null;function H(){if(!d||!m)return;const[W,Z]=_i(_,m,R);f({x:W,y:Z}),z=requestAnimationFrame(H)}const B={...k,nodeId:s,type:D,position:k.position},q=c.get(s),V={inProgress:!0,isValid:null,from:_t(q,B,Y.Left,!0),fromHandle:B,fromPosition:B.position,fromNode:q,to:_,toHandle:null,toPosition:Ur[B.position],toNode:null};b(V);let X=V;g==null||g(e,{nodeId:s,handleId:r,handleType:D});function K(W){if(!C()||!B){F(W);return}const Z=w();_=ve(W,m),A=ff(Mt(_,Z,!1,[1,1]),n,c,B),I||(H(),I=!0);const U=Bi(W,{handle:A,connectionMode:t,fromNodeId:s,fromHandleId:r,fromType:o?"target":"source",isValidConnection:y,doc:j,lib:u,flowId:h,nodeLookup:c});$=U.handleDomNode,N=U.connection,E=hf(!!A,U.isValid);const G={...X,isValid:E,to:A&&E?Ei({x:A.x,y:A.y},Z):_,toHandle:U.toHandle,toPosition:E&&U.toHandle?U.toHandle.position:Ur[B.position],toNode:U.toHandle?c.get(U.toHandle.nodeId):null};E&&A&&X.toHandle&&G.toHandle&&X.toHandle.type===G.toHandle.type&&X.toHandle.nodeId===G.toHandle.nodeId&&X.toHandle.id===G.toHandle.id&&X.to.x===G.to.x&&X.to.y===G.to.y||(b(G),X=G)}function F(W){(A||$)&&N&&E&&(x==null||x(N));const{inProgress:Z,...U}=X,G={...U,toPosition:X.toHandle?X.toPosition:null};v==null||v(W,G),i&&(S==null||S(W,G)),p(),cancelAnimationFrame(z),I=!1,E=!1,N=null,$=null,j.removeEventListener("mousemove",K),j.removeEventListener("mouseup",F),j.removeEventListener("touchmove",K),j.removeEventListener("touchend",F)}j.addEventListener("mousemove",K),j.addEventListener("mouseup",F),j.addEventListener("touchmove",K),j.addEventListener("touchend",F)}function Bi(e,{handle:t,connectionMode:n,fromNodeId:r,fromHandleId:s,fromType:i,doc:o,lib:a,flowId:c,isValidConnection:u=Li,nodeLookup:d}){const h=i==="target",f=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),x=o.elementFromPoint(p,g),v=x!=null&&x.classList.contains(`${a}-flow__handle`)?x:f,y={handleDomNode:v,isValid:!1,connection:null,toHandle:null};if(v){const S=Hi(void 0,v),b=v.getAttribute("data-nodeid"),w=v.getAttribute("data-handleid"),C=v.classList.contains("connectable"),R=v.classList.contains("connectableend");if(!b||!S)return y;const j={source:h?b:r,sourceHandle:h?w:s,target:h?r:b,targetHandle:h?s:w};y.connection=j;const A=C&&R&&(n===Ze.Strict?h&&S==="source"||!h&&S==="target":b!==r||w!==s);y.isValid=A&&u(j),y.toHandle=Ri(b,S,w,d,n,!1)}return y}const rr={onPointerDown:pf,isValid:Bi};function gf({domNode:e,panZoom:t,getTransform:n,getViewScale:r}){const s=ce(e);function i({translateExtent:a,width:c,height:u,zoomStep:d=10,pannable:h=!0,zoomable:f=!0,inversePan:p=!1}){const g=b=>{const w=n();if(b.sourceEvent.type!=="wheel"||!t)return;const C=-b.sourceEvent.deltaY*(b.sourceEvent.deltaMode===1?.05:b.sourceEvent.deltaMode?1:.002)*d,R=w[2]*Math.pow(2,C);t.scaleTo(R)};let x=[0,0];const v=b=>{(b.sourceEvent.type==="mousedown"||b.sourceEvent.type==="touchstart")&&(x=[b.sourceEvent.clientX??b.sourceEvent.touches[0].clientX,b.sourceEvent.clientY??b.sourceEvent.touches[0].clientY])},y=b=>{const w=n();if(b.sourceEvent.type!=="mousemove"&&b.sourceEvent.type!=="touchmove"||!t)return;const C=[b.sourceEvent.clientX??b.sourceEvent.touches[0].clientX,b.sourceEvent.clientY??b.sourceEvent.touches[0].clientY],R=[C[0]-x[0],C[1]-x[1]];x=C;const j=r()*Math.max(w[2],Math.log(w[2]))*(p?-1:1),z={x:w[0]-R[0]*j,y:w[1]-R[1]*j},A=[[0,0],[c,u]];t.setViewportConstrained({x:z.x,y:z.y,zoom:w[2]},A,a)},S=gi().on("start",v).on("zoom",h?y:null).on("zoom.wheel",f?g:null);s.call(S,{})}function o(){s.on("zoom",null)}return{update:i,destroy:o,pointer:de}}const mf=(e,t)=>e.x!==t.x||e.y!==t.y||e.zoom!==t.k,mn=e=>({x:e.x,y:e.y,zoom:e.k}),Tn=({x:e,y:t,zoom:n})=>dn.translate(e,t).scale(n),Xe=(e,t)=>e.target.closest(`.${t}`),Fi=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),Dn=(e,t=0,n=()=>{})=>{const r=typeof t=="number"&&t>0;return r||n(),r?e.transition().duration(t).on("end",n):e},Oi=e=>{const t=e.ctrlKey&&rn()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function xf({zoomPanValues:e,noWheelClassName:t,d3Selection:n,d3Zoom:r,panOnScrollMode:s,panOnScrollSpeed:i,zoomOnPinch:o,onPanZoomStart:a,onPanZoom:c,onPanZoomEnd:u}){return d=>{if(Xe(d,t))return!1;d.preventDefault(),d.stopImmediatePropagation();const h=n.property("__zoom").k||1;if(d.ctrlKey&&o){const v=de(d),y=Oi(d),S=h*Math.pow(2,y);r.scaleTo(n,S,v,d);return}const f=d.deltaMode===1?20:1;let p=s===He.Vertical?0:d.deltaX*f,g=s===He.Horizontal?0:d.deltaY*f;!rn()&&d.shiftKey&&s!==He.Vertical&&(p=d.deltaY*f,g=0),r.translateBy(n,-(p/h)*i,-(g/h)*i,{internal:!0});const x=mn(n.property("__zoom"));clearTimeout(e.panScrollTimeout),e.isPanScrolling||(e.isPanScrolling=!0,a==null||a(d,x)),e.isPanScrolling&&(c==null||c(d,x),e.panScrollTimeout=setTimeout(()=>{u==null||u(d,x),e.isPanScrolling=!1},150))}}function yf({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 wf({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:n}){return r=>{var i,o,a;if((i=r.sourceEvent)!=null&&i.internal)return;const s=mn(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 vf({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:r,onPanZoom:s}){return i=>{var o,a;e.usedRightMouseButton=!!(n&&Fi(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,mn(i.transform)))}}function bf({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&&Fi(t,e.mouseButton??0)&&!e.usedRightMouseButton&&o.sourceEvent&&i(o.sourceEvent),e.usedRightMouseButton=!1,r(!1),s&&mf(e.prevViewport,o.transform))){const c=mn(o.transform);e.prevViewport=c,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{s==null||s(o.sourceEvent,c)},n?150:0)}}}function Nf({zoomActivationKeyPressed:e,zoomOnScroll:t,zoomOnPinch:n,panOnDrag:r,panOnScroll:s,zoomOnDoubleClick:i,userSelectionActive:o,noWheelClassName:a,noPanClassName:c,lib:u}){return d=>{var g;const h=e||t,f=n&&d.ctrlKey;if(d.button===1&&d.type==="mousedown"&&(Xe(d,`${u}-flow__node`)||Xe(d,`${u}-flow__edge`)))return!0;if(!r&&!h&&!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(!h&&!s&&!f&&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 _f({domNode:e,minZoom:t,maxZoom:n,paneClickDistance:r,translateExtent:s,viewport:i,onPanZoom:o,onPanZoomStart:a,onPanZoomEnd:c,onDraggingChange:u}){const d={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{x:0,y:0,zoom:0},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},h=e.getBoundingClientRect(),f=gi().clickDistance(!he(r)||r<0?0:r).scaleExtent([t,n]).translateExtent(s),p=ce(e).call(f);b({x:i.x,y:i.y,zoom:Qe(i.zoom,t,n)},[[0,0],[h.width,h.height]],s);const g=p.on("wheel.zoom"),x=p.on("dblclick.zoom");f.wheelDelta(Oi);function v(T,D){return p?new Promise(m=>{f==null||f.transform(Dn(p,D==null?void 0:D.duration,()=>m(!0)),T)}):Promise.resolve(!1)}function y({noWheelClassName:T,noPanClassName:D,onPaneContextMenu:m,userSelectionActive:k,panOnScroll:_,panOnDrag:I,panOnScrollMode:N,panOnScrollSpeed:E,preventScrolling:$,zoomOnPinch:H,zoomOnScroll:B,zoomOnDoubleClick:q,zoomActivationKeyPressed:O,lib:V,onTransformChange:X}){k&&!d.isZoomingOrPanning&&S();const F=_&&!O&&!k?xf({zoomPanValues:d,noWheelClassName:T,d3Selection:p,d3Zoom:f,panOnScrollMode:N,panOnScrollSpeed:E,zoomOnPinch:H,onPanZoomStart:a,onPanZoom:o,onPanZoomEnd:c}):yf({noWheelClassName:T,preventScrolling:$,d3ZoomHandler:g});if(p.on("wheel.zoom",F,{passive:!1}),!k){const Z=wf({zoomPanValues:d,onDraggingChange:u,onPanZoomStart:a});f.on("start",Z);const U=vf({zoomPanValues:d,panOnDrag:I,onPaneContextMenu:!!m,onPanZoom:o,onTransformChange:X});f.on("zoom",U);const G=bf({zoomPanValues:d,panOnDrag:I,panOnScroll:_,onPaneContextMenu:m,onPanZoomEnd:c,onDraggingChange:u});f.on("end",G)}const W=Nf({zoomActivationKeyPressed:O,panOnDrag:I,zoomOnScroll:B,panOnScroll:_,zoomOnDoubleClick:q,zoomOnPinch:H,userSelectionActive:k,noPanClassName:D,noWheelClassName:T,lib:V});f.filter(W),q?p.on("dblclick.zoom",x):p.on("dblclick.zoom",null)}function S(){f.on("zoom",null)}async function b(T,D,m){const k=Tn(T),_=f==null?void 0:f.constrain()(k,D,m);return _&&await v(_),new Promise(I=>I(_))}async function w(T,D){const m=Tn(T);return await v(m,D),new Promise(k=>k(m))}function C(T){if(p){const D=Tn(T),m=p.property("__zoom");(m.k!==T.zoom||m.x!==T.x||m.y!==T.y)&&(f==null||f.transform(p,D,null,{sync:!0}))}}function R(){const T=p?pi(p.node()):{x:0,y:0,k:1};return{x:T.x,y:T.y,zoom:T.k}}function j(T,D){return p?new Promise(m=>{f==null||f.scaleTo(Dn(p,D==null?void 0:D.duration,()=>m(!0)),T)}):Promise.resolve(!1)}function z(T,D){return p?new Promise(m=>{f==null||f.scaleBy(Dn(p,D==null?void 0:D.duration,()=>m(!0)),T)}):Promise.resolve(!1)}function A(T){f==null||f.scaleExtent(T)}function P(T){f==null||f.translateExtent(T)}function L(T){const D=!he(T)||T<0?0:T;f==null||f.clickDistance(D)}return{update:y,destroy:S,setViewport:w,setViewportConstrained:b,getViewport:R,scaleTo:j,scaleBy:z,setScaleExtent:A,setTranslateExtent:P,syncViewport:C,setClickDistance:L}}var ht;(function(e){e.Line="line",e.Handle="handle"})(ht||(ht={}));function Sf({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 Ef(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 Ce(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 as(e,t){return e?!t:t}function kf(e,t,n,r,s,i,o,a){let{affectsX:c,affectsY:u}=t;const{isHorizontal:d,isVertical:h}=t,f=d&&h,{xSnapped:p,ySnapped:g}=n,{minWidth:x,maxWidth:v,minHeight:y,maxHeight:S}=r,{x:b,y:w,width:C,height:R,aspectRatio:j}=e;let z=Math.floor(d?p-e.pointerX:0),A=Math.floor(h?g-e.pointerY:0);const P=C+(c?-z:z),L=R+(u?-A:A),T=-i[0]*C,D=-i[1]*R;let m=Rt(P,x,v),k=Rt(L,y,S);if(o){let N=0,E=0;c&&z<0?N=Ce(b+z+T,o[0][0]):!c&&z>0&&(N=Me(b+P+T,o[1][0])),u&&A<0?E=Ce(w+A+D,o[0][1]):!u&&A>0&&(E=Me(w+L+D,o[1][1])),m=Math.max(m,N),k=Math.max(k,E)}if(a){let N=0,E=0;c&&z>0?N=Me(b+z,a[0][0]):!c&&z<0&&(N=Ce(b+P,a[1][0])),u&&A>0?E=Me(w+A,a[0][1]):!u&&A<0&&(E=Ce(w+L,a[1][1])),m=Math.max(m,N),k=Math.max(k,E)}if(s){if(d){const N=Rt(P/j,y,S)*j;if(m=Math.max(m,N),o){let E=0;!c&&!u||c&&!u&&f?E=Me(w+D+P/j,o[1][1])*j:E=Ce(w+D+(c?z:-z)/j,o[0][1])*j,m=Math.max(m,E)}if(a){let E=0;!c&&!u||c&&!u&&f?E=Ce(w+P/j,a[1][1])*j:E=Me(w+(c?z:-z)/j,a[0][1])*j,m=Math.max(m,E)}}if(h){const N=Rt(L*j,x,v)/j;if(k=Math.max(k,N),o){let E=0;!c&&!u||u&&!c&&f?E=Me(b+L*j+T,o[1][0])/j:E=Ce(b+(u?A:-A)*j+T,o[0][0])/j,k=Math.max(k,E)}if(a){let E=0;!c&&!u||u&&!c&&f?E=Ce(b+L*j,a[1][0])/j:E=Me(b+(u?A:-A)*j,a[0][0])/j,k=Math.max(k,E)}}}A=A+(A<0?k:-k),z=z+(z<0?m:-m),s&&(f?P>L*j?A=(as(c,u)?-z:z)/j:z=(as(c,u)?-A:A)*j:d?(A=z/j,u=c):(z=A*j,c=u));const _=c?b+z:b,I=u?w+A:w;return{width:C+(c?-z:z),height:R+(u?-A:A),x:i[0]*z*(c?-1:1)+_,y:i[1]*A*(u?-1:1)+I}}const Vi={width:0,height:0,x:0,y:0},jf={...Vi,pointerX:0,pointerY:0,aspectRatio:1};function Cf(e){return[[0,0],[e.measured.width,e.measured.height]]}function Mf(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:u,keepAspectRatio:d,onResizeStart:h,onResize:f,onResizeEnd:p,shouldResize:g}){let x={...Vi},v={...jf};const y=Ef(c);let S,b=null,w=[],C,R,j;const z=ei().on("start",A=>{const{nodeLookup:P,transform:L,snapGrid:T,snapToGrid:D,nodeOrigin:m,paneDomNode:k}=n();if(S=P.get(t),!S)return;b=(k==null?void 0:k.getBoundingClientRect())??null;const{xSnapped:_,ySnapped:I}=ft(A.sourceEvent,{transform:L,snapGrid:T,snapToGrid:D,containerBounds:b});x={width:S.measured.width??0,height:S.measured.height??0,x:S.position.x??0,y:S.position.y??0},v={...x,pointerX:_,pointerY:I,aspectRatio:x.width/x.height},C=void 0,S.parentId&&(S.extent==="parent"||S.expandParent)&&(C=P.get(S.parentId),R=C&&S.extent==="parent"?Cf(C):void 0),w=[],j=void 0;for(const[N,E]of P)if(E.parentId===t&&(w.push({id:N,position:{...E.position},extent:E.extent}),E.extent==="parent"||E.expandParent)){const $=Mf(E,S,E.origin??m);j?j=[[Math.min($[0][0],j[0][0]),Math.min($[0][1],j[0][1])],[Math.max($[1][0],j[1][0]),Math.max($[1][1],j[1][1])]]:j=$}h==null||h(A,{...x})}).on("drag",A=>{const{transform:P,snapGrid:L,snapToGrid:T,nodeOrigin:D}=n(),m=ft(A.sourceEvent,{transform:P,snapGrid:L,snapToGrid:T,containerBounds:b}),k=[];if(!S)return;const{x:_,y:I,width:N,height:E}=x,$={},H=S.origin??D,{width:B,height:q,x:O,y:V}=kf(v,y,m,u,d,H,R,j),X=B!==N,K=q!==E,F=O!==_&&X,W=V!==I&&K;if(!F&&!W&&!X&&!K)return;if((F||W||H[0]===1||H[1]===1)&&($.x=F?O:x.x,$.y=W?V:x.y,x.x=$.x,x.y=$.y,w.length>0)){const J=O-_,ee=V-I;for(const ie of w)ie.position={x:ie.position.x-J+H[0]*(B-N),y:ie.position.y-ee+H[1]*(q-E)},k.push(ie)}if((X||K)&&($.width=X?B:x.width,$.height=K?q:x.height,x.width=$.width,x.height=$.height),C&&S.expandParent){const J=H[0]*($.width??0);$.x&&$.x<J&&(x.x=J,v.x=v.x-($.x-J));const ee=H[1]*($.height??0);$.y&&$.y<ee&&(x.y=ee,v.y=v.y-($.y-ee))}const Z=Sf({width:x.width,prevWidth:N,height:x.height,prevHeight:E,affectsX:y.affectsX,affectsY:y.affectsY}),U={...x,direction:Z};(g==null?void 0:g(A,U))!==!1&&(f==null||f(A,U),r($,k))}).on("end",A=>{p==null||p(A,{...x}),s==null||s()});i.call(z)}function a(){i.on(".drag",null)}return{update:o,destroy:a}}var Xi={exports:{}},qi={},Yi={exports:{}},Wi={};/**
|
|
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 zf(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var If=typeof Object.is=="function"?Object.is:zf,Af=tt.useState,Pf=tt.useEffect,Tf=tt.useLayoutEffect,Df=tt.useDebugValue;function Rf(e,t){var n=t(),r=Af({inst:{value:n,getSnapshot:t}}),s=r[0].inst,i=r[1];return Tf(function(){s.value=n,s.getSnapshot=t,Rn(s)&&i({inst:s})},[e,n,t]),Pf(function(){return Rn(s)&&i({inst:s}),e(function(){Rn(s)&&i({inst:s})})},[e]),Df(n),n}function Rn(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!If(e,n)}catch{return!0}}function Hf(e,t){return t()}var Lf=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?Hf:Rf;Wi.useSyncExternalStore=tt.useSyncExternalStore!==void 0?tt.useSyncExternalStore:Lf;Yi.exports=Wi;var Bf=Yi.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 xn=M,Ff=Bf;function Of(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var Vf=typeof Object.is=="function"?Object.is:Of,Xf=Ff.useSyncExternalStore,qf=xn.useRef,Yf=xn.useEffect,Wf=xn.useMemo,Kf=xn.useDebugValue;qi.useSyncExternalStoreWithSelector=function(e,t,n,r,s){var i=qf(null);if(i.current===null){var o={hasValue:!1,value:null};i.current=o}else o=i.current;i=Wf(function(){function c(p){if(!u){if(u=!0,d=p,p=r(p),s!==void 0&&o.hasValue){var g=o.value;if(s(g,p))return h=g}return h=p}if(g=h,Vf(d,p))return g;var x=r(p);return s!==void 0&&s(g,x)?(d=p,g):(d=p,h=x)}var u=!1,d,h,f=n===void 0?null:n;return[function(){return c(t())},f===null?void 0:function(){return c(f())}]},[t,n,r,s]);var a=Xf(e,i[0],i[1]);return Yf(function(){o.hasValue=!0,o.value=a},[a]),Kf(a),a};Xi.exports=qi;var Gf=Xi.exports;const Uf=Ba(Gf),Zf={},cs=e=>{let t;const n=new Set,r=(d,h)=>{const f=typeof d=="function"?d(t):d;if(!Object.is(f,t)){const p=t;t=h??(typeof f!="object"||f===null)?f:Object.assign({},t,f),n.forEach(g=>g(t,p))}},s=()=>t,c={setState:r,getState:s,getInitialState:()=>u,subscribe:d=>(n.add(d),()=>n.delete(d)),destroy:()=>{(Zf?"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()}},u=t=e(r,s,c);return c},Qf=e=>e?cs(e):cs,{useDebugValue:Jf}=Fa,{useSyncExternalStoreWithSelector:eh}=Uf,th=e=>e;function Ki(e,t=th,n){const r=eh(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return Jf(r),r}const ls=(e,t)=>{const n=Qf(e),r=(s,i=t)=>Ki(n,s,i);return Object.assign(r,n),r},nh=(e,t)=>e?ls(e,t):ls;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 yn=M.createContext(null),rh=yn.Provider,Gi=Se.error001();function Q(e,t){const n=M.useContext(yn);if(n===null)throw new Error(Gi);return Ki(n,e,t)}function te(){const e=M.useContext(yn);if(e===null)throw new Error(Gi);return M.useMemo(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe}),[e])}const us={display:"none"},sh={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},Ui="react-flow__node-desc",Zi="react-flow__edge-desc",ih="react-flow__aria-live",oh=e=>e.ariaLiveMessage;function ah({rfId:e}){const t=Q(oh);return l.jsx("div",{id:`${ih}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:sh,children:t})}function ch({rfId:e,disableKeyboardA11y:t}){return l.jsxs(l.Fragment,{children:[l.jsxs("div",{id:`${Ui}-${e}`,style:us,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."," "]}),l.jsx("div",{id:`${Zi}-${e}`,style:us,children:"Press enter or space to select an edge. You can then press delete to remove it or escape to cancel."}),!t&&l.jsx(ah,{rfId:e})]})}const lh=e=>e.userSelectionActive?"none":"all",wr=M.forwardRef(({position:e="top-left",children:t,className:n,style:r,...s},i)=>{const o=Q(lh),a=`${e}`.split("-");return l.jsx("div",{className:se(["react-flow__panel",n,...a]),style:{...r,pointerEvents:o},ref:i,...s,children:t})});function uh({proOptions:e,position:t="bottom-right"}){return e!=null&&e.hideAttribution?null:l.jsx(wr,{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:l.jsx("a",{href:"https://reactflow.dev",target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution",children:"React Flow"})})}const dh=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 fh(e,t){return re(e.selectedNodes.map(Ht),t.selectedNodes.map(Ht))&&re(e.selectedEdges.map(Ht),t.selectedEdges.map(Ht))}function hh({onSelectionChange:e}){const t=te(),{selectedNodes:n,selectedEdges:r}=Q(dh,fh);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 ph=e=>!!e.onSelectionChangeHandlers;function gh({onSelectionChange:e}){const t=Q(ph);return e||t?l.jsx(hh,{onSelectionChange:e}):null}const Qi=[0,0],mh={x:0,y:0,zoom:1},xh=["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"],ds=[...xh,"rfId"],yh=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}),fs={translateExtent:vt,nodeOrigin:Qi,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1",paneClickDistance:0};function wh(e){const{setNodes:t,setEdges:n,setMinZoom:r,setMaxZoom:s,setTranslateExtent:i,setNodeExtent:o,reset:a,setDefaultNodesAndEdges:c,setPaneClickDistance:u}=Q(yh,re),d=te();M.useEffect(()=>(c(e.defaultNodes,e.defaultEdges),()=>{h.current=fs,a()}),[]);const h=M.useRef(fs);return M.useEffect(()=>{for(const f of ds){const p=e[f],g=h.current[f];p!==g&&(typeof e[f]>"u"||(f==="nodes"?t(p):f==="edges"?n(p):f==="minZoom"?r(p):f==="maxZoom"?s(p):f==="translateExtent"?i(p):f==="nodeExtent"?o(p):f==="paneClickDistance"?u(p):f==="fitView"?d.setState({fitViewOnInit:p}):f==="fitViewOptions"?d.setState({fitViewOnInitOptions:p}):d.setState({[f]:p})))}h.current=e},ds.map(f=>e[f])),null}function hs(){return typeof window>"u"||!window.matchMedia?null:window.matchMedia("(prefers-color-scheme: dark)")}function vh(e){var r;const[t,n]=M.useState(e==="system"?null:e);return M.useEffect(()=>{if(e!=="system"){n(e);return}const s=hs(),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=hs())!=null&&r.matches?"dark":"light"}const ps=typeof document<"u"?document:null;function St(e=null,t={target:ps,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 u=(Array.isArray(e)?e:[e]).filter(h=>typeof h=="string").map(h=>h.replace("+",`
|
|
18
|
+
`).replace(`
|
|
19
|
+
|
|
20
|
+
`,`
|
|
21
|
+
+`).split(`
|
|
22
|
+
`)),d=u.reduce((h,f)=>h.concat(...f),[]);return[u,d]}return[[],[]]},[e]);return M.useEffect(()=>{const c=(t==null?void 0:t.target)||ps;if(e!==null){const u=f=>{if(s.current=f.ctrlKey||f.metaKey||f.shiftKey,(!s.current||s.current&&!t.actInsideInputWithModifier)&&Jn(f))return!1;const g=ms(f.code,a);i.current.add(f[g]),gs(o,i.current,!1)&&(f.preventDefault(),r(!0))},d=f=>{if((!s.current||s.current&&!t.actInsideInputWithModifier)&&Jn(f))return!1;const g=ms(f.code,a);gs(o,i.current,!0)?(r(!1),i.current.clear()):i.current.delete(f[g]),f.key==="Meta"&&i.current.clear(),s.current=!1},h=()=>{i.current.clear(),r(!1)};return c==null||c.addEventListener("keydown",u),c==null||c.addEventListener("keyup",d),window.addEventListener("blur",h),window.addEventListener("contextmenu",h),()=>{c==null||c.removeEventListener("keydown",u),c==null||c.removeEventListener("keyup",d),window.removeEventListener("blur",h),window.removeEventListener("contextmenu",h)}}},[e,r]),n}function gs(e,t,n){return e.filter(r=>n||r.length===t.size).some(r=>r.every(s=>t.has(s)))}function ms(e,t){return t.includes(e)?"code":"key"}const bh=()=>{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=Un(n,t),{width:c,height:u}=gn(o);return Zn({nodes:a,width:c,height:u,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,u=s/2-t*c,d=i/2-n*c;return a?(await a.setViewport({x:u,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=pr(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 Ji(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)Nh(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 Nh(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 _h(e,t){return Ji(e,t)}function Sh(e,t){return Ji(e,t)}function Te(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(Te(i.id,o)))}return r}function xs({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 ys(e){return{id:e.id,type:"remove"}}const ws=e=>Ld(e),Eh=e=>wi(e);function eo(e){return M.forwardRef(e)}const kh=typeof window<"u"?M.useLayoutEffect:M.useEffect;function vs(e){const[t,n]=M.useState(BigInt(0)),[r]=M.useState(()=>jh(()=>n(s=>s+BigInt(1))));return kh(()=>{const s=r.get();s.length&&(e(s),r.reset())},[t]),r}function jh(e){let t=[];return{get:()=>t,reset:()=>{t=[]},push:n=>{t.push(n),e()}}}const to=M.createContext(null);function Ch({children:e}){const t=te(),n=M.useCallback(a=>{const{nodes:c=[],setNodes:u,hasDefaultNodes:d,onNodesChange:h,nodeLookup:f}=t.getState();let p=c;for(const g of a)p=typeof g=="function"?g(p):g;d?u(p):h&&h(xs({items:p,lookup:f}))},[]),r=vs(n),s=M.useCallback(a=>{const{edges:c=[],setEdges:u,hasDefaultEdges:d,onEdgesChange:h,edgeLookup:f}=t.getState();let p=c;for(const g of a)p=typeof g=="function"?g(p):g;d?u(p):h&&h(xs({items:p,lookup:f}))},[]),i=vs(s),o=M.useMemo(()=>({nodeQueue:r,edgeQueue:i}),[]);return l.jsx(to.Provider,{value:o,children:e})}function Mh(){const e=M.useContext(to);if(!e)throw new Error("useBatchContext must be used within a BatchProvider");return e}const $h=e=>!!e.panZoom;function vr(){const e=bh(),t=te(),n=Mh(),r=Q($h),s=M.useMemo(()=>{const i=h=>t.getState().nodeLookup.get(h),o=h=>{n.nodeQueue.push(h)},a=h=>{n.edgeQueue.push(h)},c=h=>{var y,S;const{nodeLookup:f,nodeOrigin:p}=t.getState(),g=ws(h)?h:f.get(h.id),x=g.parentId?ji(g.position,g.measured,g.parentId,f,p):g.position,v={...g,position:x,width:((y=g.measured)==null?void 0:y.width)??g.width,height:((S=g.measured)==null?void 0:S.height)??g.height};return Je(v)},u=(h,f,p={replace:!1})=>{o(g=>g.map(x=>{if(x.id===h){const v=typeof f=="function"?f(x):f;return p.replace&&ws(v)?v:{...x,...v}}return x}))},d=(h,f,p={replace:!1})=>{a(g=>g.map(x=>{if(x.id===h){const v=typeof f=="function"?f(x):f;return p.replace&&Eh(v)?v:{...x,...v}}return x}))};return{getNodes:()=>t.getState().nodes.map(h=>({...h})),getNode:h=>{var f;return(f=i(h))==null?void 0:f.internals.userNode},getInternalNode:i,getEdges:()=>{const{edges:h=[]}=t.getState();return h.map(f=>({...f}))},getEdge:h=>t.getState().edgeLookup.get(h),setNodes:o,setEdges:a,addNodes:h=>{const f=Array.isArray(h)?h:[h];n.nodeQueue.push(p=>[...p,...f])},addEdges:h=>{const f=Array.isArray(h)?h:[h];n.edgeQueue.push(p=>[...p,...f])},toObject:()=>{const{nodes:h=[],edges:f=[],transform:p}=t.getState(),[g,x,v]=p;return{nodes:h.map(y=>({...y})),edges:f.map(y=>({...y})),viewport:{x:g,y:x,zoom:v}}},deleteElements:async({nodes:h=[],edges:f=[]})=>{const{nodes:p,edges:g,onNodesDelete:x,onEdgesDelete:v,triggerNodeChanges:y,triggerEdgeChanges:S,onDelete:b,onBeforeDelete:w}=t.getState(),{nodes:C,edges:R}=await Od({nodesToRemove:h,edgesToRemove:f,nodes:p,edges:g,onBeforeDelete:w}),j=R.length>0,z=C.length>0;if(j){const A=R.map(ys);v==null||v(R),S(A)}if(z){const A=C.map(ys);x==null||x(C),y(A)}return(z||j)&&(b==null||b({nodes:C,edges:R})),{deletedNodes:C,deletedEdges:R}},getIntersectingNodes:(h,f=!0,p)=>{const g=Qr(h),x=g?h:c(h),v=p!==void 0;return x?(p||t.getState().nodes).filter(y=>{const S=t.getState().nodeLookup.get(y.id);if(S&&!g&&(y.id===h.id||!S.internals.positionAbsolute))return!1;const b=Je(v?y:S),w=Nt(b,x);return f&&w>0||w>=x.width*x.height}):[]},isNodeIntersecting:(h,f,p=!0)=>{const x=Qr(h)?h:c(h);if(!x)return!1;const v=Nt(x,f);return p&&v>0||v>=x.width*x.height},updateNode:u,updateNodeData:(h,f,p={replace:!1})=>{u(h,g=>{const x=typeof f=="function"?f(g):f;return p.replace?{...g,data:x}:{...g,data:{...g.data,...x}}},p)},updateEdge:d,updateEdgeData:(h,f,p={replace:!1})=>{d(h,g=>{const x=typeof f=="function"?f(g):f;return p.replace?{...g,data:x}:{...g,data:{...g.data,...x}}},p)},getNodesBounds:h=>{const{nodeLookup:f,nodeOrigin:p}=t.getState();return Bd(h,{nodeLookup:f,nodeOrigin:p})},getHandleConnections:({type:h,id:f,nodeId:p})=>{var g;return Array.from(((g=t.getState().connectionLookup.get(`${p}-${h}-${f??null}`))==null?void 0:g.values())??[])}}},[]);return M.useMemo(()=>({...s,...e,viewportInitialized:r}),[r])}const bs=e=>e.selected,zh={actInsideInputWithModifier:!1},Ih=typeof window<"u"?window:void 0;function Ah({deleteKeyCode:e,multiSelectionKeyCode:t}){const n=te(),{deleteElements:r}=vr(),s=St(e,zh),i=St(t,{target:Ih});M.useEffect(()=>{if(s){const{edges:o,nodes:a}=n.getState();r({nodes:a.filter(bs),edges:o.filter(bs)}),n.setState({nodesSelectionActive:!1})}},[s]),M.useEffect(()=>{n.setState({multiSelectionActive:i})},[i])}function Ph(e){const t=te();M.useEffect(()=>{const n=()=>{var s,i;if(!e.current)return!1;const r=gn(e.current);(r.height===0||r.width===0)&&((i=(s=t.getState()).onError)==null||i.call(s,"004",Se.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 wn={position:"absolute",width:"100%",height:"100%",top:0,left:0},Th=e=>({userSelectionActive:e.userSelectionActive,lib:e.lib});function Dh({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:u,minZoom:d,maxZoom:h,zoomActivationKeyCode:f,preventScrolling:p=!0,children:g,noWheelClassName:x,noPanClassName:v,onViewportChange:y,isControlledViewport:S,paneClickDistance:b}){const w=te(),C=M.useRef(null),{userSelectionActive:R,lib:j}=Q(Th,re),z=St(f),A=M.useRef();Ph(C);const P=M.useCallback(L=>{y==null||y({x:L[0],y:L[1],zoom:L[2]}),S||w.setState({transform:L})},[y,S]);return M.useEffect(()=>{if(C.current){A.current=_f({domNode:C.current,minZoom:d,maxZoom:h,translateExtent:u,viewport:c,paneClickDistance:b,onDraggingChange:m=>w.setState({paneDragging:m}),onPanZoomStart:(m,k)=>{const{onViewportChangeStart:_,onMoveStart:I}=w.getState();I==null||I(m,k),_==null||_(k)},onPanZoom:(m,k)=>{const{onViewportChange:_,onMove:I}=w.getState();I==null||I(m,k),_==null||_(k)},onPanZoomEnd:(m,k)=>{const{onViewportChangeEnd:_,onMoveEnd:I}=w.getState();I==null||I(m,k),_==null||_(k)}});const{x:L,y:T,zoom:D}=A.current.getViewport();return w.setState({panZoom:A.current,transform:[L,T,D],domNode:C.current.closest(".react-flow")}),()=>{var m;(m=A.current)==null||m.destroy()}}},[]),M.useEffect(()=>{var L;(L=A.current)==null||L.update({onPaneContextMenu:e,zoomOnScroll:t,zoomOnPinch:n,panOnScroll:r,panOnScrollSpeed:s,panOnScrollMode:i,zoomOnDoubleClick:o,panOnDrag:a,zoomActivationKeyPressed:z,preventScrolling:p,noPanClassName:v,userSelectionActive:R,noWheelClassName:x,lib:j,onTransformChange:P})},[e,t,n,r,s,i,o,a,z,p,v,R,x,j,P]),l.jsx("div",{className:"react-flow__renderer",ref:C,style:wn,children:g})}const Rh=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function Hh(){const{userSelectionActive:e,userSelectionRect:t}=Q(Rh,re);return e&&t?l.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 Hn=(e,t)=>n=>{n.target===t.current&&(e==null||e(n))},Lh=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,dragging:e.paneDragging});function Bh({isSelecting:e,selectionKeyPressed:t,selectionMode:n=bt.Full,panOnDrag:r,selectionOnDrag:s,onSelectionStart:i,onSelectionEnd:o,onPaneClick:a,onPaneContextMenu:c,onPaneScroll:u,onPaneMouseEnter:d,onPaneMouseMove:h,onPaneMouseLeave:f,children:p}){const g=M.useRef(null),x=te(),v=M.useRef(0),y=M.useRef(0),S=M.useRef(),b=M.useRef(new Map),{userSelectionActive:w,elementsSelectable:C,dragging:R}=Q(Lh,re),j=C&&(e||w),z=M.useRef(!1),A=M.useRef(!1),P=()=>{x.setState({userSelectionActive:!1,userSelectionRect:null}),v.current=0,y.current=0},L=N=>{if(z.current){z.current=!1;return}a==null||a(N),x.getState().resetSelectedElements(),x.setState({nodesSelectionActive:!1})},T=N=>{if(Array.isArray(r)&&(r!=null&&r.includes(2))){N.preventDefault();return}c==null||c(N)},D=u?N=>u(N):void 0,m=N=>{var O,V,X,K;const{resetSelectedElements:E,domNode:$,edgeLookup:H}=x.getState();if(S.current=$==null?void 0:$.getBoundingClientRect(),!C||!e||N.button!==0||N.target!==g.current||!S.current)return;(V=(O=N.target)==null?void 0:O.setPointerCapture)==null||V.call(O,N.pointerId),A.current=!0,z.current=!1,b.current=new Map;for(const[F,W]of H)b.current.set(W.source,((X=b.current.get(W.source))==null?void 0:X.add(F))||new Set([F])),b.current.set(W.target,((K=b.current.get(W.target))==null?void 0:K.add(F))||new Set([F]));const{x:B,y:q}=ve(N.nativeEvent,S.current);E(),x.setState({userSelectionRect:{width:0,height:0,startX:B,startY:q,x:B,y:q}}),i==null||i(N)},k=N=>{const{userSelectionRect:E,edgeLookup:$,transform:H,nodeLookup:B,triggerNodeChanges:q,triggerEdgeChanges:O}=x.getState();if(!S.current||!E)return;z.current=!0;const{x:V,y:X}=ve(N.nativeEvent,S.current),{startX:K,startY:F}=E,W={startX:K,startY:F,x:V<K?V:K,y:X<F?X:F,width:Math.abs(V-K),height:Math.abs(X-F)},Z=vi(B,W,H,n===bt.Partial,!0),U=new Set,G=new Set;for(const J of Z){G.add(J.id);const ee=b.current.get(J.id);if(ee)for(const ie of ee)U.add(ie)}if(v.current!==G.size){v.current=G.size;const J=qe(B,G,!0);q(J)}if(y.current!==U.size){y.current=U.size;const J=qe($,U);O(J)}x.setState({userSelectionRect:W,userSelectionActive:!0,nodesSelectionActive:!1})},_=N=>{var $,H;if(N.button!==0||!A.current)return;(H=($=N.target)==null?void 0:$.releasePointerCapture)==null||H.call($,N.pointerId);const{userSelectionRect:E}=x.getState();!w&&E&&N.target===g.current&&(L==null||L(N)),v.current>0&&x.setState({nodesSelectionActive:!0}),P(),o==null||o(N),(t||s)&&(z.current=!1),A.current=!1},I=r===!0||Array.isArray(r)&&r.includes(0);return l.jsxs("div",{className:se(["react-flow__pane",{draggable:I,dragging:R,selection:e}]),onClick:j?void 0:Hn(L,g),onContextMenu:Hn(T,g),onWheel:Hn(D,g),onPointerEnter:j?void 0:d,onPointerDown:j?m:h,onPointerMove:j?k:h,onPointerUp:j?_:void 0,onPointerLeave:f,ref:g,style:wn,children:[p,l.jsx(Hh,{})]})}function sr({id:e,store:t,unselect:n=!1,nodeRef:r}){const{addSelectedNodes:s,unselectNodesAndEdges:i,multiSelectionActive:o,nodeLookup:a,onError:c}=t.getState(),u=a.get(e);if(!u){c==null||c("012",Se.error012(e));return}t.setState({nodesSelectionActive:!1}),u.selected?(n||u.selected&&o)&&(i({nodes:[u],edges:[]}),requestAnimationFrame(()=>{var d;return(d=r==null?void 0:r.current)==null?void 0:d.blur()})):s([e])}function no({nodeRef:e,disabled:t=!1,noDragClassName:n,handleSelector:r,nodeId:s,isSelectable:i,nodeClickDistance:o}){const a=te(),[c,u]=M.useState(!1),d=M.useRef();return M.useEffect(()=>{d.current=lf({getStoreItems:()=>a.getState(),onNodeMouseDown:h=>{sr({id:h,store:a,nodeRef:e})},onDragStart:()=>{u(!0)},onDragStop:()=>{u(!1)}})},[]),M.useEffect(()=>{var h,f;if(t)(h=d.current)==null||h.destroy();else if(e.current)return(f=d.current)==null||f.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 Fh=e=>t=>t.selected&&(t.draggable||e&&typeof t.draggable>"u");function ro(){const e=te();return M.useCallback(n=>{const{nodeExtent:r,snapToGrid:s,snapGrid:i,nodesDraggable:o,onError:a,updateNodePositions:c,nodeLookup:u,nodeOrigin:d}=e.getState(),h=new Map,f=Fh(o),p=s?i[0]:5,g=s?i[1]:5,x=n.direction.x*p*n.factor,v=n.direction.y*g*n.factor;for(const[,y]of u){if(!f(y))continue;let S={x:y.internals.positionAbsolute.x+x,y:y.internals.positionAbsolute.y+v};s&&(S=pn(S,i));const{position:b,positionAbsolute:w}=bi({nodeId:y.id,nextPosition:S,nodeLookup:u,nodeExtent:r,nodeOrigin:d,onError:a});y.position=b,y.internals.positionAbsolute=w,h.set(y.id,y)}c(h)},[])}const br=M.createContext(null),Oh=br.Provider;br.Consumer;const so=()=>M.useContext(br),Vh=e=>({connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName,rfId:e.rfId}),Xh=(e,t,n)=>r=>{const{connectionClickStartHandle:s,connectionMode:i,connection:o}=r,{fromHandle:a,toHandle:c,isValid:u}=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&&u}};function qh({type:e="source",position:t=Y.Top,isValidConnection:n,isConnectable:r=!0,isConnectableStart:s=!0,isConnectableEnd:i=!0,id:o,onConnect:a,children:c,className:u,onMouseDown:d,onTouchStart:h,...f},p){var m,k;const g=o||null,x=e==="target",v=te(),y=so(),{connectOnClick:S,noPanClassName:b,rfId:w}=Q(Vh,re),{connectingFrom:C,connectingTo:R,clickConnecting:j,isPossibleEndHandle:z,connectionInProcess:A,valid:P}=Q(Xh(y,g,e),re);y||(k=(m=v.getState()).onError)==null||k.call(m,"010",Se.error010());const L=_=>{const{defaultEdgeOptions:I,onConnect:N,hasDefaultEdges:E}=v.getState(),$={...I,..._};if(E){const{edges:H,setEdges:B}=v.getState();B(Gd($,H))}N==null||N($),a==null||a($)},T=_=>{if(!y)return;const I=Mi(_.nativeEvent);if(s&&(I&&_.button===0||!I)){const N=v.getState();rr.onPointerDown(_.nativeEvent,{autoPanOnConnect:N.autoPanOnConnect,connectionMode:N.connectionMode,connectionRadius:N.connectionRadius,domNode:N.domNode,nodeLookup:N.nodeLookup,lib:N.lib,isTarget:x,handleId:g,nodeId:y,flowId:N.rfId,panBy:N.panBy,cancelConnection:N.cancelConnection,onConnectStart:N.onConnectStart,onConnectEnd:N.onConnectEnd,updateConnection:N.updateConnection,onConnect:L,isValidConnection:n||N.isValidConnection,getTransform:()=>v.getState().transform,getFromHandle:()=>v.getState().connection.fromHandle,autoPanSpeed:N.autoPanSpeed})}I?d==null||d(_):h==null||h(_)},D=_=>{const{onClickConnectStart:I,onClickConnectEnd:N,connectionClickStartHandle:E,connectionMode:$,isValidConnection:H,lib:B,rfId:q,nodeLookup:O,connection:V}=v.getState();if(!y||!E&&!s)return;if(!E){I==null||I(_.nativeEvent,{nodeId:y,handleId:g,handleType:e}),v.setState({connectionClickStartHandle:{nodeId:y,type:e,id:g}});return}const X=Ci(_.target),K=n||H,{connection:F,isValid:W}=rr.isValid(_.nativeEvent,{handle:{nodeId:y,id:g,type:e},connectionMode:$,fromNodeId:E.nodeId,fromHandleId:E.id||null,fromType:E.type,isValidConnection:K,flowId:q,doc:X,lib:B,nodeLookup:O});W&&F&&L(F);const Z=structuredClone(V);delete Z.inProgress,Z.toPosition=Z.toHandle?Z.toHandle.position:null,N==null||N(_,Z),v.setState({connectionClickStartHandle:null})};return l.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",b,u,{source:!x,target:x,connectable:r,connectablestart:s,connectableend:i,clickconnecting:j,connectingfrom:C,connectingto:R,valid:P,connectionindicator:r&&(!A||z)&&(A?i:s)}]),onMouseDown:T,onTouchStart:T,onClick:S?D:void 0,ref:p,...f,children:c})}const Pe=M.memo(eo(qh));function Yh({data:e,isConnectable:t,sourcePosition:n=Y.Bottom}){return l.jsxs(l.Fragment,{children:[e==null?void 0:e.label,l.jsx(Pe,{type:"source",position:n,isConnectable:t})]})}function Wh({data:e,isConnectable:t,targetPosition:n=Y.Top,sourcePosition:r=Y.Bottom}){return l.jsxs(l.Fragment,{children:[l.jsx(Pe,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label,l.jsx(Pe,{type:"source",position:r,isConnectable:t})]})}function Kh(){return null}function Gh({data:e,isConnectable:t,targetPosition:n=Y.Top}){return l.jsxs(l.Fragment,{children:[l.jsx(Pe,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label]})}const sn={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},Ns={input:Yh,default:Wh,output:Gh,group:Kh};function Uh(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 Zh=e=>{const{width:t,height:n,x:r,y:s}=Ct(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(Zh,re),c=ro(),u=M.useRef(null);if(M.useEffect(()=>{var f;n||(f=u.current)==null||f.focus({preventScroll:!0})},[n]),no({nodeRef:u}),a||!s||!i)return null;const d=e?f=>{const p=r.getState().nodes.filter(g=>g.selected);e(f,p)}:void 0,h=f=>{Object.prototype.hasOwnProperty.call(sn,f.key)&&(f.preventDefault(),c({direction:sn[f.key],factor:f.shiftKey?4:1}))};return l.jsx("div",{className:se(["react-flow__nodesselection","react-flow__container",t]),style:{transform:o},children:l.jsx("div",{ref:u,className:"react-flow__nodesselection-rect",onContextMenu:d,tabIndex:n?void 0:-1,onKeyDown:n?void 0:h,style:{width:s,height:i}})})}const _s=typeof window<"u"?window:void 0,Jh=e=>({nodesSelectionActive:e.nodesSelectionActive,userSelectionActive:e.userSelectionActive});function io({children:e,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:s,onPaneContextMenu:i,onPaneScroll:o,paneClickDistance:a,deleteKeyCode:c,selectionKeyCode:u,selectionOnDrag:d,selectionMode:h,onSelectionStart:f,onSelectionEnd:p,multiSelectionKeyCode:g,panActivationKeyCode:x,zoomActivationKeyCode:v,elementsSelectable:y,zoomOnScroll:S,zoomOnPinch:b,panOnScroll:w,panOnScrollSpeed:C,panOnScrollMode:R,zoomOnDoubleClick:j,panOnDrag:z,defaultViewport:A,translateExtent:P,minZoom:L,maxZoom:T,preventScrolling:D,onSelectionContextMenu:m,noWheelClassName:k,noPanClassName:_,disableKeyboardA11y:I,onViewportChange:N,isControlledViewport:E}){const{nodesSelectionActive:$,userSelectionActive:H}=Q(Jh),B=St(u,{target:_s}),q=St(x,{target:_s}),O=q||z,V=q||w,X=d&&O!==!0,K=B||H||X;return Ah({deleteKeyCode:c,multiSelectionKeyCode:g}),l.jsx(Dh,{onPaneContextMenu:i,elementsSelectable:y,zoomOnScroll:S,zoomOnPinch:b,panOnScroll:V,panOnScrollSpeed:C,panOnScrollMode:R,zoomOnDoubleClick:j,panOnDrag:!B&&O,defaultViewport:A,translateExtent:P,minZoom:L,maxZoom:T,zoomActivationKeyCode:v,preventScrolling:D,noWheelClassName:k,noPanClassName:_,onViewportChange:N,isControlledViewport:E,paneClickDistance:a,children:l.jsxs(Bh,{onSelectionStart:f,onSelectionEnd:p,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:s,onPaneContextMenu:i,onPaneScroll:o,panOnDrag:O,isSelecting:!!K,selectionMode:h,selectionKeyPressed:B,selectionOnDrag:X,children:[e,$&&l.jsx(Qh,{onSelectionContextMenu:m,noPanClassName:_,disableKeyboardA11y:I})]})})}io.displayName="FlowRenderer";const e0=M.memo(io),t0=e=>t=>e?vi(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 n0(e){return Q(M.useCallback(t0(e),[e]),re)}const r0=e=>e.updateNodeInternals;function s0(){const e=Q(r0),[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 i0({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),u=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 h=u.current!==t,f=a.current!==e.sourcePosition,p=c.current!==e.targetPosition;(h||f||p)&&(u.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 o0({id:e,onClick:t,onMouseEnter:n,onMouseMove:r,onMouseLeave:s,onContextMenu:i,onDoubleClick:o,nodesDraggable:a,elementsSelectable:c,nodesConnectable:u,nodesFocusable:d,resizeObserver:h,noDragClassName:f,noPanClassName:p,disableKeyboardA11y:g,rfId:x,nodeTypes:v,nodeExtent:y,nodeClickDistance:S,onError:b}){const{node:w,internals:C,isParent:R}=Q(F=>{const W=F.nodeLookup.get(e),Z=F.parentLookup.has(e);return{node:W,internals:W.internals,isParent:Z}},re);let j=w.type||"default",z=(v==null?void 0:v[j])||Ns[j];z===void 0&&(b==null||b("003",Se.error003(j)),j="default",z=Ns.default);const A=!!(w.draggable||a&&typeof w.draggable>"u"),P=!!(w.selectable||c&&typeof w.selectable>"u"),L=!!(w.connectable||u&&typeof w.connectable>"u"),T=!!(w.focusable||d&&typeof w.focusable>"u"),D=te(),m=ki(w),k=i0({node:w,nodeType:j,hasDimensions:m,resizeObserver:h}),_=no({nodeRef:k,disabled:w.hidden||!A,noDragClassName:f,handleSelector:w.dragHandle,nodeId:e,isSelectable:P,nodeClickDistance:S}),I=ro();if(w.hidden)return null;const N=Ee(w),E=Uh(w),$=P||A||t||n||r||s,H=n?F=>n(F,{...C.userNode}):void 0,B=r?F=>r(F,{...C.userNode}):void 0,q=s?F=>s(F,{...C.userNode}):void 0,O=i?F=>i(F,{...C.userNode}):void 0,V=o?F=>o(F,{...C.userNode}):void 0,X=F=>{const{selectNodesOnDrag:W,nodeDragThreshold:Z}=D.getState();P&&(!W||!A||Z>0)&&sr({id:e,store:D,nodeRef:k}),t&&t(F,{...C.userNode})},K=F=>{if(!(Jn(F.nativeEvent)||g))if(mi.includes(F.key)&&P){const W=F.key==="Escape";sr({id:e,store:D,unselect:W,nodeRef:k})}else A&&w.selected&&Object.prototype.hasOwnProperty.call(sn,F.key)&&(F.preventDefault(),D.setState({ariaLiveMessage:`Moved selected node ${F.key.replace("Arrow","").toLowerCase()}. New position, x: ${~~C.positionAbsolute.x}, y: ${~~C.positionAbsolute.y}`}),I({direction:sn[F.key],factor:F.shiftKey?4:1}))};return l.jsx("div",{className:se(["react-flow__node",`react-flow__node-${j}`,{[p]:A},w.className,{selected:w.selected,selectable:P,parent:R,draggable:A,dragging:_}]),ref:k,style:{zIndex:C.z,transform:`translate(${C.positionAbsolute.x}px,${C.positionAbsolute.y}px)`,pointerEvents:$?"all":"none",visibility:m?"visible":"hidden",...w.style,...E},"data-id":e,"data-testid":`rf__node-${e}`,onMouseEnter:H,onMouseMove:B,onMouseLeave:q,onContextMenu:O,onClick:X,onDoubleClick:V,onKeyDown:T?K:void 0,tabIndex:T?0:void 0,role:T?"button":void 0,"aria-describedby":g?void 0:`${Ui}-${x}`,"aria-label":w.ariaLabel,children:l.jsx(Oh,{value:e,children:l.jsx(z,{id:e,data:w.data,type:j,positionAbsoluteX:C.positionAbsolute.x,positionAbsoluteY:C.positionAbsolute.y,selected:w.selected,selectable:P,draggable:A,deletable:w.deletable??!0,isConnectable:L,sourcePosition:w.sourcePosition,targetPosition:w.targetPosition,dragging:_,dragHandle:w.dragHandle,zIndex:C.z,parentId:w.parentId,...N})})})}const a0=e=>({nodesDraggable:e.nodesDraggable,nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,onError:e.onError});function oo(e){const{nodesDraggable:t,nodesConnectable:n,nodesFocusable:r,elementsSelectable:s,onError:i}=Q(a0,re),o=n0(e.onlyRenderVisibleElements),a=s0();return l.jsx("div",{className:"react-flow__nodes",style:wn,children:o.map(c=>l.jsx(o0,{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))})}oo.displayName="NodeRenderer";const c0=M.memo(oo);function l0(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&&Yd({sourceNode:i,targetNode:o,width:n.width,height:n.height,transform:n.transform})&&r.push(s.id)}return r},[e]),re)}const u0=({color:e="none",strokeWidth:t=1})=>l.jsx("polyline",{style:{stroke:e,strokeWidth:t},strokeLinecap:"round",strokeLinejoin:"round",fill:"none",points:"-5,-4 0,0 -5,4"}),d0=({color:e="none",strokeWidth:t=1})=>l.jsx("polyline",{style:{stroke:e,fill:e,strokeWidth:t},strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"}),Ss={[tn.Arrow]:u0,[tn.ArrowClosed]:d0};function f0(e){const t=te();return M.useMemo(()=>{var s,i;return Object.prototype.hasOwnProperty.call(Ss,e)?Ss[e]:((i=(s=t.getState()).onError)==null||i.call(s,"009",Se.error009(e)),null)},[e])}const h0=({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=f0(t);return c?l.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:l.jsx(c,{color:n,strokeWidth:o})}):null},ao=({defaultColor:e,rfId:t})=>{const n=Q(i=>i.edges),r=Q(i=>i.defaultEdgeOptions),s=M.useMemo(()=>ef(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?l.jsx("svg",{className:"react-flow__marker",children:l.jsx("defs",{children:s.map(i=>l.jsx(h0,{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};ao.displayName="MarkerDefinitions";var p0=M.memo(ao);function co({x:e,y:t,label:n,labelStyle:r={},labelShowBg:s=!0,labelBgStyle:i={},labelBgPadding:o=[2,4],labelBgBorderRadius:a=2,children:c,className:u,...d}){const[h,f]=M.useState({x:1,y:0,width:0,height:0}),p=se(["react-flow__edge-textwrapper",u]),g=M.useRef(null);return M.useEffect(()=>{if(g.current){const x=g.current.getBBox();f({x:x.x,y:x.y,width:x.width,height:x.height})}},[n]),typeof n>"u"||!n?null:l.jsxs("g",{transform:`translate(${e-h.width/2} ${t-h.height/2})`,className:p,visibility:h.width?"visible":"hidden",...d,children:[s&&l.jsx("rect",{width:h.width+2*o[0],x:-o[0],y:-o[1],height:h.height+2*o[1],className:"react-flow__edge-textbg",style:i,rx:a,ry:a}),l.jsx("text",{className:"react-flow__edge-text",y:h.height/2,dy:"0.3em",ref:g,style:r,children:n}),c]})}co.displayName="EdgeText";const g0=M.memo(co);function vn({path:e,labelX:t,labelY:n,label:r,labelStyle:s,labelShowBg:i,labelBgStyle:o,labelBgPadding:a,labelBgBorderRadius:c,interactionWidth:u=20,...d}){return l.jsxs(l.Fragment,{children:[l.jsx("path",{...d,d:e,fill:"none",className:se(["react-flow__edge-path",d.className])}),u&&l.jsx("path",{d:e,fill:"none",strokeOpacity:0,strokeWidth:u,className:"react-flow__edge-interaction"}),r&&he(t)&&he(n)?l.jsx(g0,{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===Y.Left||e===Y.Right?[.5*(t+r),n]:[t,.5*(n+s)]}function lo({sourceX:e,sourceY:t,sourcePosition:n=Y.Bottom,targetX:r,targetY:s,targetPosition:i=Y.Top}){const[o,a]=Es({pos:n,x1:e,y1:t,x2:r,y2:s}),[c,u]=Es({pos:i,x1:r,y1:s,x2:e,y2:t}),[d,h,f,p]=$i({sourceX:e,sourceY:t,targetX:r,targetY:s,sourceControlX:o,sourceControlY:a,targetControlX:c,targetControlY:u});return[`M${e},${t} C${o},${a} ${c},${u} ${r},${s}`,d,h,f,p]}function uo(e){return M.memo(({id:t,sourceX:n,sourceY:r,targetX:s,targetY:i,sourcePosition:o=Y.Bottom,targetPosition:a=Y.Top,label:c,labelStyle:u,labelShowBg:d,labelBgStyle:h,labelBgPadding:f,labelBgBorderRadius:p,style:g,markerEnd:x,markerStart:v,interactionWidth:y})=>{const[S,b,w]=lo({sourceX:n,sourceY:r,sourcePosition:o,targetX:s,targetY:i,targetPosition:a}),C=e.isInternal?void 0:t;return l.jsx(vn,{id:C,path:S,labelX:b,labelY:w,label:c,labelStyle:u,labelShowBg:d,labelBgStyle:h,labelBgPadding:f,labelBgBorderRadius:p,style:g,markerEnd:x,markerStart:v,interactionWidth:y})})}const m0=uo({isInternal:!1}),fo=uo({isInternal:!0});m0.displayName="SimpleBezierEdge";fo.displayName="SimpleBezierEdgeInternal";function ho(e){return M.memo(({id:t,sourceX:n,sourceY:r,targetX:s,targetY:i,label:o,labelStyle:a,labelShowBg:c,labelBgStyle:u,labelBgPadding:d,labelBgBorderRadius:h,style:f,sourcePosition:p=Y.Bottom,targetPosition:g=Y.Top,markerEnd:x,markerStart:v,pathOptions:y,interactionWidth:S})=>{const[b,w,C]=er({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}),R=e.isInternal?void 0:t;return l.jsx(vn,{id:R,path:b,labelX:w,labelY:C,label:o,labelStyle:a,labelShowBg:c,labelBgStyle:u,labelBgPadding:d,labelBgBorderRadius:h,style:f,markerEnd:x,markerStart:v,interactionWidth:S})})}const po=ho({isInternal:!1}),go=ho({isInternal:!0});po.displayName="SmoothStepEdge";go.displayName="SmoothStepEdgeInternal";function mo(e){return M.memo(({id:t,...n})=>{var s;const r=e.isInternal?void 0:t;return l.jsx(po,{...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 x0=mo({isInternal:!1}),xo=mo({isInternal:!0});x0.displayName="StepEdge";xo.displayName="StepEdgeInternal";function yo(e){return M.memo(({id:t,sourceX:n,sourceY:r,targetX:s,targetY:i,label:o,labelStyle:a,labelShowBg:c,labelBgStyle:u,labelBgPadding:d,labelBgBorderRadius:h,style:f,markerEnd:p,markerStart:g,interactionWidth:x})=>{const[v,y,S]=Ai({sourceX:n,sourceY:r,targetX:s,targetY:i}),b=e.isInternal?void 0:t;return l.jsx(vn,{id:b,path:v,labelX:y,labelY:S,label:o,labelStyle:a,labelShowBg:c,labelBgStyle:u,labelBgPadding:d,labelBgBorderRadius:h,style:f,markerEnd:p,markerStart:g,interactionWidth:x})})}const y0=yo({isInternal:!1}),wo=yo({isInternal:!0});y0.displayName="StraightEdge";wo.displayName="StraightEdgeInternal";function vo(e){return M.memo(({id:t,sourceX:n,sourceY:r,targetX:s,targetY:i,sourcePosition:o=Y.Bottom,targetPosition:a=Y.Top,label:c,labelStyle:u,labelShowBg:d,labelBgStyle:h,labelBgPadding:f,labelBgBorderRadius:p,style:g,markerEnd:x,markerStart:v,pathOptions:y,interactionWidth:S})=>{const[b,w,C]=zi({sourceX:n,sourceY:r,sourcePosition:o,targetX:s,targetY:i,targetPosition:a,curvature:y==null?void 0:y.curvature}),R=e.isInternal?void 0:t;return l.jsx(vn,{id:R,path:b,labelX:w,labelY:C,label:c,labelStyle:u,labelShowBg:d,labelBgStyle:h,labelBgPadding:f,labelBgBorderRadius:p,style:g,markerEnd:x,markerStart:v,interactionWidth:S})})}const w0=vo({isInternal:!1}),bo=vo({isInternal:!0});w0.displayName="BezierEdge";bo.displayName="BezierEdgeInternal";const ks={default:bo,straight:wo,step:xo,smoothstep:go,simplebezier:fo},js={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null},v0=(e,t,n)=>n===Y.Left?e-t:n===Y.Right?e+t:e,b0=(e,t,n)=>n===Y.Top?e-t:n===Y.Bottom?e+t:e,Cs="react-flow__edgeupdater";function Ms({position:e,centerX:t,centerY:n,radius:r=10,onMouseDown:s,onMouseEnter:i,onMouseOut:o,type:a}){return l.jsx("circle",{onMouseDown:s,onMouseEnter:i,onMouseOut:o,className:se([Cs,`${Cs}-${a}`]),cx:v0(t,r,e),cy:b0(n,r,e),r,stroke:"transparent",fill:"transparent"})}function N0({isReconnectable:e,reconnectRadius:t,edge:n,sourceX:r,sourceY:s,targetX:i,targetY:o,sourcePosition:a,targetPosition:c,onReconnect:u,onReconnectStart:d,onReconnectEnd:h,setReconnecting:f,setUpdateHover:p}){const g=te(),x=(w,C)=>{if(w.button!==0)return;const{autoPanOnConnect:R,domNode:j,isValidConnection:z,connectionMode:A,connectionRadius:P,lib:L,onConnectStart:T,onConnectEnd:D,cancelConnection:m,nodeLookup:k,rfId:_,panBy:I,updateConnection:N}=g.getState(),E=C.type==="target";f(!0),d==null||d(w,n,C.type);const $=(B,q)=>{f(!1),h==null||h(B,n,C.type,q)},H=B=>u==null?void 0:u(n,B);rr.onPointerDown(w.nativeEvent,{autoPanOnConnect:R,connectionMode:A,connectionRadius:P,domNode:j,handleId:C.id,nodeId:C.nodeId,nodeLookup:k,isTarget:E,edgeUpdaterType:C.type,lib:L,flowId:_,cancelConnection:m,panBy:I,isValidConnection:z,onConnect:H,onConnectStart:T,onConnectEnd:D,onReconnectEnd:$,updateConnection:N,getTransform:()=>g.getState().transform,getFromHandle:()=>g.getState().connection.fromHandle})},v=w=>x(w,{nodeId:n.target,id:n.targetHandle??null,type:"target"}),y=w=>x(w,{nodeId:n.source,id:n.sourceHandle??null,type:"source"}),S=()=>p(!0),b=()=>p(!1);return l.jsxs(l.Fragment,{children:[(e===!0||e==="source")&&l.jsx(Ms,{position:a,centerX:r,centerY:s,radius:t,onMouseDown:v,onMouseEnter:S,onMouseOut:b,type:"source"}),(e===!0||e==="target")&&l.jsx(Ms,{position:c,centerX:i,centerY:o,radius:t,onMouseDown:y,onMouseEnter:S,onMouseOut:b,type:"target"})]})}function _0({id:e,edgesFocusable:t,edgesReconnectable:n,elementsSelectable:r,onClick:s,onDoubleClick:i,onContextMenu:o,onMouseEnter:a,onMouseMove:c,onMouseLeave:u,reconnectRadius:d,onReconnect:h,onReconnectStart:f,onReconnectEnd:p,rfId:g,edgeTypes:x,noPanClassName:v,onError:y,disableKeyboardA11y:S}){let b=Q(G=>G.edgeLookup.get(e));const w=Q(G=>G.defaultEdgeOptions);b=w?{...w,...b}:b;let C=b.type||"default",R=(x==null?void 0:x[C])||ks[C];R===void 0&&(y==null||y("011",Se.error011(C)),C="default",R=ks.default);const j=!!(b.focusable||t&&typeof b.focusable>"u"),z=typeof h<"u"&&(b.reconnectable||n&&typeof b.reconnectable>"u"),A=!!(b.selectable||r&&typeof b.selectable>"u"),P=M.useRef(null),[L,T]=M.useState(!1),[D,m]=M.useState(!1),k=te(),{zIndex:_,sourceX:I,sourceY:N,targetX:E,targetY:$,sourcePosition:H,targetPosition:B}=Q(M.useCallback(G=>{const J=G.nodeLookup.get(b.source),ee=G.nodeLookup.get(b.target);if(!J||!ee)return{zIndex:b.zIndex,...js};const ie=Jd({id:e,sourceNode:J,targetNode:ee,sourceHandle:b.sourceHandle||null,targetHandle:b.targetHandle||null,connectionMode:G.connectionMode,onError:y});return{zIndex:qd({selected:b.selected,zIndex:b.zIndex,sourceNode:J,targetNode:ee,elevateOnSelect:G.elevateEdgesOnSelect}),...ie||js}},[b.source,b.target,b.sourceHandle,b.targetHandle,b.selected,b.zIndex]),re),q=M.useMemo(()=>b.markerStart?`url('#${tr(b.markerStart,g)}')`:void 0,[b.markerStart,g]),O=M.useMemo(()=>b.markerEnd?`url('#${tr(b.markerEnd,g)}')`:void 0,[b.markerEnd,g]);if(b.hidden||I===null||N===null||E===null||$===null)return null;const V=G=>{var ke;const{addSelectedEdges:J,unselectNodesAndEdges:ee,multiSelectionActive:ie}=k.getState();A&&(k.setState({nodesSelectionActive:!1}),b.selected&&ie?(ee({nodes:[],edges:[b]}),(ke=P.current)==null||ke.blur()):J([e])),s&&s(G,b)},X=i?G=>{i(G,{...b})}:void 0,K=o?G=>{o(G,{...b})}:void 0,F=a?G=>{a(G,{...b})}:void 0,W=c?G=>{c(G,{...b})}:void 0,Z=u?G=>{u(G,{...b})}:void 0,U=G=>{var J;if(!S&&mi.includes(G.key)&&A){const{unselectNodesAndEdges:ee,addSelectedEdges:ie}=k.getState();G.key==="Escape"?((J=P.current)==null||J.blur(),ee({edges:[b]})):ie([e])}};return l.jsx("svg",{style:{zIndex:_},children:l.jsxs("g",{className:se(["react-flow__edge",`react-flow__edge-${C}`,b.className,v,{selected:b.selected,animated:b.animated,inactive:!A&&!s,updating:L,selectable:A}]),onClick:V,onDoubleClick:X,onContextMenu:K,onMouseEnter:F,onMouseMove:W,onMouseLeave:Z,onKeyDown:j?U:void 0,tabIndex:j?0:void 0,role:j?"button":"img","data-id":e,"data-testid":`rf__edge-${e}`,"aria-label":b.ariaLabel===null?void 0:b.ariaLabel||`Edge from ${b.source} to ${b.target}`,"aria-describedby":j?`${Zi}-${g}`:void 0,ref:P,children:[!D&&l.jsx(R,{id:e,source:b.source,target:b.target,type:b.type,selected:b.selected,animated:b.animated,selectable:A,deletable:b.deletable??!0,label:b.label,labelStyle:b.labelStyle,labelShowBg:b.labelShowBg,labelBgStyle:b.labelBgStyle,labelBgPadding:b.labelBgPadding,labelBgBorderRadius:b.labelBgBorderRadius,sourceX:I,sourceY:N,targetX:E,targetY:$,sourcePosition:H,targetPosition:B,data:b.data,style:b.style,sourceHandleId:b.sourceHandle,targetHandleId:b.targetHandle,markerStart:q,markerEnd:O,pathOptions:"pathOptions"in b?b.pathOptions:void 0,interactionWidth:b.interactionWidth}),z&&l.jsx(N0,{edge:b,isReconnectable:z,reconnectRadius:d,onReconnect:h,onReconnectStart:f,onReconnectEnd:p,sourceX:I,sourceY:N,targetX:E,targetY:$,sourcePosition:H,targetPosition:B,setUpdateHover:T,setReconnecting:m})]})})}const S0=e=>({edgesFocusable:e.edgesFocusable,edgesReconnectable:e.edgesReconnectable,elementsSelectable:e.elementsSelectable,connectionMode:e.connectionMode,onError:e.onError});function No({defaultMarkerColor:e,onlyRenderVisibleElements:t,rfId:n,edgeTypes:r,noPanClassName:s,onReconnect:i,onEdgeContextMenu:o,onEdgeMouseEnter:a,onEdgeMouseMove:c,onEdgeMouseLeave:u,onEdgeClick:d,reconnectRadius:h,onEdgeDoubleClick:f,onReconnectStart:p,onReconnectEnd:g,disableKeyboardA11y:x}){const{edgesFocusable:v,edgesReconnectable:y,elementsSelectable:S,onError:b}=Q(S0,re),w=l0(t);return l.jsxs("div",{className:"react-flow__edges",children:[l.jsx(p0,{defaultColor:e,rfId:n}),w.map(C=>l.jsx(_0,{id:C,edgesFocusable:v,edgesReconnectable:y,elementsSelectable:S,noPanClassName:s,onReconnect:i,onContextMenu:o,onMouseEnter:a,onMouseMove:c,onMouseLeave:u,onClick:d,reconnectRadius:h,onDoubleClick:f,onReconnectStart:p,onReconnectEnd:g,rfId:n,onError:b,edgeTypes:r,disableKeyboardA11y:x},C))]})}No.displayName="EdgeRenderer";const E0=M.memo(No),k0=e=>`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`;function j0({children:e}){const t=Q(k0);return l.jsx("div",{className:"react-flow__viewport xyflow__viewport react-flow__container",style:{transform:t},children:e})}function C0(e){const t=vr(),n=M.useRef(!1);M.useEffect(()=>{!n.current&&t.viewportInitialized&&e&&(setTimeout(()=>e(t),1),n.current=!0)},[e,t.viewportInitialized])}const M0=e=>{var t;return(t=e.panZoom)==null?void 0:t.syncViewport};function $0(e){const t=Q(M0),n=te();return M.useEffect(()=>{e&&(t==null||t(e),n.setState({transform:[e.x,e.y,e.zoom]}))},[e,t]),null}function z0(e){return e.connection.inProgress?{...e.connection,to:Mt(e.connection.to,e.transform)}:{...e.connection}}function I0(e){return z0}function A0(e){const t=I0();return Q(t,re)}const P0=e=>({nodesConnectable:e.nodesConnectable,isValid:e.connection.isValid,inProgress:e.connection.inProgress,width:e.width,height:e.height});function T0({containerStyle:e,style:t,type:n,component:r}){const{nodesConnectable:s,width:i,height:o,isValid:a,inProgress:c}=Q(P0,re);return!(i&&s&&c)?null:l.jsx("svg",{style:e,width:i,height:o,className:"react-flow__connectionline react-flow__container",children:l.jsx("g",{className:se(["react-flow__connection",yi(a)]),children:l.jsx(_o,{style:t,type:n,CustomComponent:r,isValid:a})})})}const _o=({style:e,type:t=ze.Bezier,CustomComponent:n,isValid:r})=>{const{inProgress:s,from:i,fromNode:o,fromHandle:a,fromPosition:c,to:u,toNode:d,toHandle:h,toPosition:f}=A0();if(!s)return;if(n)return l.jsx(n,{connectionLineType:t,connectionLineStyle:e,fromNode:o,fromHandle:a,fromX:i.x,fromY:i.y,toX:u.x,toY:u.y,fromPosition:c,toPosition:f,connectionStatus:yi(r),toNode:d,toHandle:h});let p="";const g={sourceX:i.x,sourceY:i.y,sourcePosition:c,targetX:u.x,targetY:u.y,targetPosition:f};switch(t){case ze.Bezier:[p]=zi(g);break;case ze.SimpleBezier:[p]=lo(g);break;case ze.Step:[p]=er({...g,borderRadius:0});break;case ze.SmoothStep:[p]=er(g);break;default:[p]=Ai(g)}return l.jsx("path",{d:p,fill:"none",className:"react-flow__connection-path",style:e})};_o.displayName="ConnectionLine";const D0={};function $s(e=D0){M.useRef(e),te(),M.useEffect(()=>{},[e])}function R0(){te(),M.useRef(!1),M.useEffect(()=>{},[])}function So({nodeTypes:e,edgeTypes:t,onInit:n,onNodeClick:r,onEdgeClick:s,onNodeDoubleClick:i,onEdgeDoubleClick:o,onNodeMouseEnter:a,onNodeMouseMove:c,onNodeMouseLeave:u,onNodeContextMenu:d,onSelectionContextMenu:h,onSelectionStart:f,onSelectionEnd:p,connectionLineType:g,connectionLineStyle:x,connectionLineComponent:v,connectionLineContainerStyle:y,selectionKeyCode:S,selectionOnDrag:b,selectionMode:w,multiSelectionKeyCode:C,panActivationKeyCode:R,zoomActivationKeyCode:j,deleteKeyCode:z,onlyRenderVisibleElements:A,elementsSelectable:P,defaultViewport:L,translateExtent:T,minZoom:D,maxZoom:m,preventScrolling:k,defaultMarkerColor:_,zoomOnScroll:I,zoomOnPinch:N,panOnScroll:E,panOnScrollSpeed:$,panOnScrollMode:H,zoomOnDoubleClick:B,panOnDrag:q,onPaneClick:O,onPaneMouseEnter:V,onPaneMouseMove:X,onPaneMouseLeave:K,onPaneScroll:F,onPaneContextMenu:W,paneClickDistance:Z,nodeClickDistance:U,onEdgeContextMenu:G,onEdgeMouseEnter:J,onEdgeMouseMove:ee,onEdgeMouseLeave:ie,reconnectRadius:ke,onReconnect:bn,onReconnectStart:Nn,onReconnectEnd:_n,noDragClassName:nt,noWheelClassName:Sn,noPanClassName:rt,disableKeyboardA11y:st,nodeExtent:En,rfId:it,viewport:ot,onViewportChange:$t}){return $s(e),$s(t),R0(),C0(n),$0(ot),l.jsx(e0,{onPaneClick:O,onPaneMouseEnter:V,onPaneMouseMove:X,onPaneMouseLeave:K,onPaneContextMenu:W,onPaneScroll:F,paneClickDistance:Z,deleteKeyCode:z,selectionKeyCode:S,selectionOnDrag:b,selectionMode:w,onSelectionStart:f,onSelectionEnd:p,multiSelectionKeyCode:C,panActivationKeyCode:R,zoomActivationKeyCode:j,elementsSelectable:P,zoomOnScroll:I,zoomOnPinch:N,zoomOnDoubleClick:B,panOnScroll:E,panOnScrollSpeed:$,panOnScrollMode:H,panOnDrag:q,defaultViewport:L,translateExtent:T,minZoom:D,maxZoom:m,onSelectionContextMenu:h,preventScrolling:k,noDragClassName:nt,noWheelClassName:Sn,noPanClassName:rt,disableKeyboardA11y:st,onViewportChange:$t,isControlledViewport:!!ot,children:l.jsxs(j0,{children:[l.jsx(E0,{edgeTypes:t,onEdgeClick:s,onEdgeDoubleClick:o,onReconnect:bn,onReconnectStart:Nn,onReconnectEnd:_n,onlyRenderVisibleElements:A,onEdgeContextMenu:G,onEdgeMouseEnter:J,onEdgeMouseMove:ee,onEdgeMouseLeave:ie,reconnectRadius:ke,defaultMarkerColor:_,noPanClassName:rt,disableKeyboardA11y:st,rfId:it}),l.jsx(T0,{style:x,type:g,component:v,containerStyle:y}),l.jsx("div",{className:"react-flow__edgelabel-renderer"}),l.jsx(c0,{nodeTypes:e,onNodeClick:r,onNodeDoubleClick:i,onNodeMouseEnter:a,onNodeMouseMove:c,onNodeMouseLeave:u,onNodeContextMenu:d,nodeClickDistance:U,onlyRenderVisibleElements:A,noPanClassName:rt,noDragClassName:nt,disableKeyboardA11y:st,nodeExtent:En,rfId:it}),l.jsx("div",{className:"react-flow__viewport-portal"})]})})}So.displayName="GraphView";const H0=M.memo(So),zs=({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:s,height:i,fitView:o,nodeOrigin:a,nodeExtent:c}={})=>{const u=new Map,d=new Map,h=new Map,f=new Map,p=r??t??[],g=n??e??[],x=a??[0,0],v=c??vt;Ti(h,f,p),nr(g,u,d,{nodeOrigin:x,nodeExtent:v,elevateNodesOnSelect:!1});let y=[0,0,1];if(o&&s&&i){const S=Ct(u,{filter:R=>!!((R.width||R.initialWidth)&&(R.height||R.initialHeight))}),{x:b,y:w,zoom:C}=pr(S,s,i,.5,2,.1);y=[b,w,C]}return{rfId:"1",width:0,height:0,transform:y,nodes:g,nodeLookup:u,parentLookup:d,edges:p,edgeLookup:f,connectionLookup:h,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:n!==void 0,hasDefaultEdges:r!==void 0,panZoom:null,minZoom:.5,maxZoom:2,translateExtent:vt,nodeExtent:v,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:Ze.Strict,domNode:null,paneDragging:!1,noPanClassName:"nopan",nodeOrigin:x,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:{...xi},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanSpeed:15,connectionRadius:20,onError:Vd,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:"react",debug:!1}},L0=({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:s,height:i,fitView:o,nodeOrigin:a,nodeExtent:c})=>nh((u,d)=>({...zs({nodes:e,edges:t,width:s,height:i,fitView:o,nodeOrigin:a,nodeExtent:c,defaultNodes:n,defaultEdges:r}),setNodes:h=>{const{nodeLookup:f,parentLookup:p,nodeOrigin:g,elevateNodesOnSelect:x}=d();nr(h,f,p,{nodeOrigin:g,nodeExtent:c,elevateNodesOnSelect:x,checkEquality:!0}),u({nodes:h})},setEdges:h=>{const{connectionLookup:f,edgeLookup:p}=d();Ti(f,p,h),u({edges:h})},setDefaultNodesAndEdges:(h,f)=>{if(h){const{setNodes:p}=d();p(h),u({hasDefaultNodes:!0})}if(f){const{setEdges:p}=d();p(f),u({hasDefaultEdges:!0})}},updateNodeInternals:(h,f={triggerFitView:!0})=>{const{triggerNodeChanges:p,nodeLookup:g,parentLookup:x,fitViewOnInit:v,fitViewDone:y,fitViewOnInitOptions:S,domNode:b,nodeOrigin:w,nodeExtent:C,debug:R,fitViewSync:j}=d(),{changes:z,updatedInternals:A}=of(h,g,x,b,w,C);if(A){if(nf(g,x,{nodeOrigin:w,nodeExtent:C}),f.triggerFitView){let P=y;!y&&v&&(P=j({...S,nodes:S==null?void 0:S.nodes})),u({fitViewDone:P})}else u({});(z==null?void 0:z.length)>0&&(R&&console.log("React Flow: trigger node changes",z),p==null||p(z))}},updateNodePositions:(h,f=!1)=>{const p=[],g=[];for(const[x,v]of h){const y=!!(v!=null&&v.expandParent&&(v!=null&&v.parentId)&&(v!=null&&v.position)),S={id:x,type:"position",position:y?{x:Math.max(0,v.position.x),y:Math.max(0,v.position.y)}:v.position,dragging:f};y&&p.push({id:x,parentId:v.parentId,rect:{...v.internals.positionAbsolute,width:v.measured.width,height:v.measured.height}}),g.push(S)}if(p.length>0){const{nodeLookup:x,parentLookup:v,nodeOrigin:y}=d(),S=yr(p,x,v,y);g.push(...S)}d().triggerNodeChanges(g)},triggerNodeChanges:h=>{const{onNodesChange:f,setNodes:p,nodes:g,hasDefaultNodes:x,debug:v}=d();if(h!=null&&h.length){if(x){const y=_h(h,g);p(y)}v&&console.log("React Flow: trigger node changes",h),f==null||f(h)}},triggerEdgeChanges:h=>{const{onEdgesChange:f,setEdges:p,edges:g,hasDefaultEdges:x,debug:v}=d();if(h!=null&&h.length){if(x){const y=Sh(h,g);p(y)}v&&console.log("React Flow: trigger edge changes",h),f==null||f(h)}},addSelectedNodes:h=>{const{multiSelectionActive:f,edgeLookup:p,nodeLookup:g,triggerNodeChanges:x,triggerEdgeChanges:v}=d();if(f){const y=h.map(S=>Te(S,!0));x(y);return}x(qe(g,new Set([...h]),!0)),v(qe(p))},addSelectedEdges:h=>{const{multiSelectionActive:f,edgeLookup:p,nodeLookup:g,triggerNodeChanges:x,triggerEdgeChanges:v}=d();if(f){const y=h.map(S=>Te(S,!0));v(y);return}v(qe(p,new Set([...h]))),x(qe(g,new Set,!0))},unselectNodesAndEdges:({nodes:h,edges:f}={})=>{const{edges:p,nodes:g,nodeLookup:x,triggerNodeChanges:v,triggerEdgeChanges:y}=d(),S=h||g,b=f||p,w=S.map(R=>{const j=x.get(R.id);return j&&(j.selected=!1),Te(R.id,!1)}),C=b.map(R=>Te(R.id,!1));v(w),y(C)},setMinZoom:h=>{const{panZoom:f,maxZoom:p}=d();f==null||f.setScaleExtent([h,p]),u({minZoom:h})},setMaxZoom:h=>{const{panZoom:f,minZoom:p}=d();f==null||f.setScaleExtent([p,h]),u({maxZoom:h})},setTranslateExtent:h=>{var f;(f=d().panZoom)==null||f.setTranslateExtent(h),u({translateExtent:h})},setPaneClickDistance:h=>{var f;(f=d().panZoom)==null||f.setClickDistance(h)},resetSelectedElements:()=>{const{edges:h,nodes:f,triggerNodeChanges:p,triggerEdgeChanges:g}=d(),x=f.reduce((y,S)=>S.selected?[...y,Te(S.id,!1)]:y,[]),v=h.reduce((y,S)=>S.selected?[...y,Te(S.id,!1)]:y,[]);p(x),g(v)},setNodeExtent:h=>{const{nodes:f,nodeLookup:p,parentLookup:g,nodeOrigin:x,elevateNodesOnSelect:v,nodeExtent:y}=d();h[0][0]===y[0][0]&&h[0][1]===y[0][1]&&h[1][0]===y[1][0]&&h[1][1]===y[1][1]||(nr(f,p,g,{nodeOrigin:x,nodeExtent:h,elevateNodesOnSelect:v,checkEquality:!1}),u({nodeExtent:h}))},panBy:h=>{const{transform:f,width:p,height:g,panZoom:x,translateExtent:v}=d();return af({delta:h,panZoom:x,transform:f,translateExtent:v,width:p,height:g})},fitView:h=>{const{panZoom:f,width:p,height:g,minZoom:x,maxZoom:v,nodeLookup:y}=d();if(!f)return Promise.resolve(!1);const S=Un(y,h);return Zn({nodes:S,width:p,height:g,panZoom:f,minZoom:x,maxZoom:v},h)},fitViewSync:h=>{const{panZoom:f,width:p,height:g,minZoom:x,maxZoom:v,nodeLookup:y}=d();if(!f)return!1;const S=Un(y,h);return Zn({nodes:S,width:p,height:g,panZoom:f,minZoom:x,maxZoom:v},h),S.size>0},cancelConnection:()=>{u({connection:{...xi}})},updateConnection:h=>{u({connection:h})},reset:()=>u({...zs()})}),Object.is);function B0({initialNodes:e,initialEdges:t,defaultNodes:n,defaultEdges:r,initialWidth:s,initialHeight:i,fitView:o,nodeOrigin:a,nodeExtent:c,children:u}){const[d]=M.useState(()=>L0({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:s,height:i,fitView:o,nodeOrigin:a,nodeExtent:c}));return l.jsx(rh,{value:d,children:l.jsx(Ch,{children:u})})}function F0({children:e,nodes:t,edges:n,defaultNodes:r,defaultEdges:s,width:i,height:o,fitView:a,nodeOrigin:c,nodeExtent:u}){return M.useContext(yn)?l.jsx(l.Fragment,{children:e}):l.jsx(B0,{initialNodes:t,initialEdges:n,defaultNodes:r,defaultEdges:s,initialWidth:i,initialHeight:o,fitView:a,nodeOrigin:c,nodeExtent:u,children:e})}const O0={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0};function V0({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,className:s,nodeTypes:i,edgeTypes:o,onNodeClick:a,onEdgeClick:c,onInit:u,onMove:d,onMoveStart:h,onMoveEnd:f,onConnect:p,onConnectStart:g,onConnectEnd:x,onClickConnectStart:v,onClickConnectEnd:y,onNodeMouseEnter:S,onNodeMouseMove:b,onNodeMouseLeave:w,onNodeContextMenu:C,onNodeDoubleClick:R,onNodeDragStart:j,onNodeDrag:z,onNodeDragStop:A,onNodesDelete:P,onEdgesDelete:L,onDelete:T,onSelectionChange:D,onSelectionDragStart:m,onSelectionDrag:k,onSelectionDragStop:_,onSelectionContextMenu:I,onSelectionStart:N,onSelectionEnd:E,onBeforeDelete:$,connectionMode:H,connectionLineType:B=ze.Bezier,connectionLineStyle:q,connectionLineComponent:O,connectionLineContainerStyle:V,deleteKeyCode:X="Backspace",selectionKeyCode:K="Shift",selectionOnDrag:F=!1,selectionMode:W=bt.Full,panActivationKeyCode:Z="Space",multiSelectionKeyCode:U=rn()?"Meta":"Control",zoomActivationKeyCode:G=rn()?"Meta":"Control",snapToGrid:J,snapGrid:ee,onlyRenderVisibleElements:ie=!1,selectNodesOnDrag:ke,nodesDraggable:bn,nodesConnectable:Nn,nodesFocusable:_n,nodeOrigin:nt=Qi,edgesFocusable:Sn,edgesReconnectable:rt,elementsSelectable:st=!0,defaultViewport:En=mh,minZoom:it=.5,maxZoom:ot=2,translateExtent:$t=vt,preventScrolling:Io=!0,nodeExtent:kn,defaultMarkerColor:Ao="#b1b1b7",zoomOnScroll:Po=!0,zoomOnPinch:To=!0,panOnScroll:Do=!1,panOnScrollSpeed:Ro=.5,panOnScrollMode:Ho=He.Free,zoomOnDoubleClick:Lo=!0,panOnDrag:Bo=!0,onPaneClick:Fo,onPaneMouseEnter:Oo,onPaneMouseMove:Vo,onPaneMouseLeave:Xo,onPaneScroll:qo,onPaneContextMenu:Yo,paneClickDistance:Nr=0,nodeClickDistance:Wo=0,children:Ko,onReconnect:Go,onReconnectStart:Uo,onReconnectEnd:Zo,onEdgeContextMenu:Qo,onEdgeDoubleClick:Jo,onEdgeMouseEnter:ea,onEdgeMouseMove:ta,onEdgeMouseLeave:na,reconnectRadius:ra=10,onNodesChange:sa,onEdgesChange:ia,noDragClassName:oa="nodrag",noWheelClassName:aa="nowheel",noPanClassName:_r="nopan",fitView:Sr,fitViewOptions:ca,connectOnClick:la,attributionPosition:ua,proOptions:da,defaultEdgeOptions:fa,elevateNodesOnSelect:ha,elevateEdgesOnSelect:pa,disableKeyboardA11y:Er=!1,autoPanOnConnect:ga,autoPanOnNodeDrag:ma,autoPanSpeed:xa,connectionRadius:ya,isValidConnection:wa,onError:va,style:ba,id:kr,nodeDragThreshold:Na,viewport:_a,onViewportChange:Sa,width:Ea,height:ka,colorMode:ja="light",debug:Ca,...Ma},$a){const jn=kr||"1",za=vh(ja);return l.jsx("div",{"data-testid":"rf__wrapper",...Ma,style:{...ba,...O0},ref:$a,className:se(["react-flow",s,za]),id:kr,children:l.jsxs(F0,{nodes:e,edges:t,width:Ea,height:ka,fitView:Sr,nodeOrigin:nt,nodeExtent:kn,children:[l.jsx(H0,{onInit:u,onNodeClick:a,onEdgeClick:c,onNodeMouseEnter:S,onNodeMouseMove:b,onNodeMouseLeave:w,onNodeContextMenu:C,onNodeDoubleClick:R,nodeTypes:i,edgeTypes:o,connectionLineType:B,connectionLineStyle:q,connectionLineComponent:O,connectionLineContainerStyle:V,selectionKeyCode:K,selectionOnDrag:F,selectionMode:W,deleteKeyCode:X,multiSelectionKeyCode:U,panActivationKeyCode:Z,zoomActivationKeyCode:G,onlyRenderVisibleElements:ie,defaultViewport:En,translateExtent:$t,minZoom:it,maxZoom:ot,preventScrolling:Io,zoomOnScroll:Po,zoomOnPinch:To,zoomOnDoubleClick:Lo,panOnScroll:Do,panOnScrollSpeed:Ro,panOnScrollMode:Ho,panOnDrag:Bo,onPaneClick:Fo,onPaneMouseEnter:Oo,onPaneMouseMove:Vo,onPaneMouseLeave:Xo,onPaneScroll:qo,onPaneContextMenu:Yo,paneClickDistance:Nr,nodeClickDistance:Wo,onSelectionContextMenu:I,onSelectionStart:N,onSelectionEnd:E,onReconnect:Go,onReconnectStart:Uo,onReconnectEnd:Zo,onEdgeContextMenu:Qo,onEdgeDoubleClick:Jo,onEdgeMouseEnter:ea,onEdgeMouseMove:ta,onEdgeMouseLeave:na,reconnectRadius:ra,defaultMarkerColor:Ao,noDragClassName:oa,noWheelClassName:aa,noPanClassName:_r,rfId:jn,disableKeyboardA11y:Er,nodeExtent:kn,viewport:_a,onViewportChange:Sa}),l.jsx(wh,{nodes:e,edges:t,defaultNodes:n,defaultEdges:r,onConnect:p,onConnectStart:g,onConnectEnd:x,onClickConnectStart:v,onClickConnectEnd:y,nodesDraggable:bn,nodesConnectable:Nn,nodesFocusable:_n,edgesFocusable:Sn,edgesReconnectable:rt,elementsSelectable:st,elevateNodesOnSelect:ha,elevateEdgesOnSelect:pa,minZoom:it,maxZoom:ot,nodeExtent:kn,onNodesChange:sa,onEdgesChange:ia,snapToGrid:J,snapGrid:ee,connectionMode:H,translateExtent:$t,connectOnClick:la,defaultEdgeOptions:fa,fitView:Sr,fitViewOptions:ca,onNodesDelete:P,onEdgesDelete:L,onDelete:T,onNodeDragStart:j,onNodeDrag:z,onNodeDragStop:A,onSelectionDrag:k,onSelectionDragStart:m,onSelectionDragStop:_,onMove:d,onMoveStart:h,onMoveEnd:f,noPanClassName:_r,nodeOrigin:nt,rfId:jn,autoPanOnConnect:ga,autoPanOnNodeDrag:ma,autoPanSpeed:xa,onError:va,connectionRadius:ya,isValidConnection:wa,selectNodesOnDrag:ke,nodeDragThreshold:Na,onBeforeDelete:$,paneClickDistance:Nr,debug:Ca}),l.jsx(gh,{onSelectionChange:D}),Ko,l.jsx(uh,{proOptions:da,position:ua}),l.jsx(ch,{rfId:jn,disableKeyboardA11y:Er})]})})}var X0=eo(V0);function q0({dimensions:e,lineWidth:t,variant:n,className:r}){return l.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 Y0({radius:e,className:t}){return l.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 W0={[be.Dots]:1,[be.Lines]:1,[be.Cross]:6},K0=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:u,patternClassName:d}){const h=M.useRef(null),{transform:f,patternId:p}=Q(K0,re),g=r||W0[t],x=t===be.Dots,v=t===be.Cross,y=Array.isArray(n)?n:[n,n],S=[y[0]*f[2]||1,y[1]*f[2]||1],b=g*f[2],w=Array.isArray(i)?i:[i,i],C=v?[b,b]:S,R=[w[0]*f[2]||1+C[0]/2,w[1]*f[2]||1+C[1]/2],j=`${p}${e||""}`;return l.jsxs("svg",{className:se(["react-flow__background",u]),style:{...c,...wn,"--xy-background-color-props":a,"--xy-background-pattern-color-props":o},ref:h,"data-testid":"rf__background",children:[l.jsx("pattern",{id:j,x:f[0]%S[0],y:f[1]%S[1],width:S[0],height:S[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${R[0]},-${R[1]})`,children:x?l.jsx(Y0,{radius:b/2,className:d}):l.jsx(q0,{dimensions:C,lineWidth:s,variant:t,className:d})}),l.jsx("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${j})`})]})}Eo.displayName="Background";const G0=M.memo(Eo);function U0(){return l.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",children:l.jsx("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"})})}function Z0(){return l.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5",children:l.jsx("path",{d:"M0 0h32v4.2H0z"})})}function Q0(){return l.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30",children:l.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 J0(){return l.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:l.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 ep(){return l.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:l.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 l.jsx("button",{type:"button",className:se(["react-flow__controls-button",t]),...n,children:e})}const tp=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom});function ko({style:e,showZoom:t=!0,showFitView:n=!0,showInteractive:r=!0,fitViewOptions:s,onZoomIn:i,onZoomOut:o,onFitView:a,onInteractiveChange:c,className:u,children:d,position:h="bottom-left",orientation:f="vertical","aria-label":p="React Flow controls"}){const g=te(),{isInteractive:x,minZoomReached:v,maxZoomReached:y}=Q(tp,re),{zoomIn:S,zoomOut:b,fitView:w}=vr(),C=()=>{S(),i==null||i()},R=()=>{b(),o==null||o()},j=()=>{w(s),a==null||a()},z=()=>{g.setState({nodesDraggable:!x,nodesConnectable:!x,elementsSelectable:!x}),c==null||c(!x)},A=f==="horizontal"?"horizontal":"vertical";return l.jsxs(wr,{className:se(["react-flow__controls",A,u]),position:h,style:e,"data-testid":"rf__controls","aria-label":p,children:[t&&l.jsxs(l.Fragment,{children:[l.jsx(Lt,{onClick:C,className:"react-flow__controls-zoomin",title:"zoom in","aria-label":"zoom in",disabled:y,children:l.jsx(U0,{})}),l.jsx(Lt,{onClick:R,className:"react-flow__controls-zoomout",title:"zoom out","aria-label":"zoom out",disabled:v,children:l.jsx(Z0,{})})]}),n&&l.jsx(Lt,{className:"react-flow__controls-fitview",onClick:j,title:"fit view","aria-label":"fit view",children:l.jsx(Q0,{})}),r&&l.jsx(Lt,{className:"react-flow__controls-interactive",onClick:z,title:"toggle interactivity","aria-label":"toggle interactivity",children:x?l.jsx(ep,{}):l.jsx(J0,{})}),d]})}ko.displayName="Controls";const np=M.memo(ko);function rp({id:e,x:t,y:n,width:r,height:s,style:i,color:o,strokeColor:a,strokeWidth:c,className:u,borderRadius:d,shapeRendering:h,selected:f,onClick:p}){const{background:g,backgroundColor:x}=i||{},v=o||g||x;return l.jsx("rect",{className:se(["react-flow__minimap-node",{selected:f},u]),x:t,y:n,rx:d,ry:d,width:r,height:s,style:{fill:v,stroke:a,strokeWidth:c},shapeRendering:h,onClick:p?y=>p(y,e):void 0})}const sp=M.memo(rp),ip=e=>e.nodes.map(t=>t.id),Ln=e=>e instanceof Function?e:()=>e;function op({nodeStrokeColor:e,nodeColor:t,nodeClassName:n="",nodeBorderRadius:r=5,nodeStrokeWidth:s,nodeComponent:i=sp,onClick:o}){const a=Q(ip,re),c=Ln(t),u=Ln(e),d=Ln(n),h=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return l.jsx(l.Fragment,{children:a.map(f=>l.jsx(cp,{id:f,nodeColorFunc:c,nodeStrokeColorFunc:u,nodeClassNameFunc:d,nodeBorderRadius:r,nodeStrokeWidth:s,NodeComponent:i,onClick:o,shapeRendering:h},f))})}function ap({id:e,nodeColorFunc:t,nodeStrokeColorFunc:n,nodeClassNameFunc:r,nodeBorderRadius:s,nodeStrokeWidth:i,shapeRendering:o,NodeComponent:a,onClick:c}){const{node:u,x:d,y:h,width:f,height:p}=Q(g=>{const x=g.nodeLookup.get(e),{x:v,y}=x.internals.positionAbsolute,{width:S,height:b}=Ee(x);return{node:x,x:v,y,width:S,height:b}},re);return!u||u.hidden||!ki(u)?null:l.jsx(a,{x:d,y:h,width:f,height:p,style:u.style,selected:!!u.selected,className:r(u),color:t(u),borderRadius:s,strokeColor:n(u),strokeWidth:i,shapeRendering:o,onClick:c,id:u.id})}const cp=M.memo(ap);var lp=M.memo(op);const up=200,dp=150,fp=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?Si(Ct(e.nodeLookup),t):t,rfId:e.rfId,panZoom:e.panZoom,translateExtent:e.translateExtent,flowWidth:e.width,flowHeight:e.height}},hp="react-flow__minimap-desc";function jo({style:e,className:t,nodeStrokeColor:n,nodeColor:r,nodeClassName:s="",nodeBorderRadius:i=5,nodeStrokeWidth:o,nodeComponent:a,bgColor:c,maskColor:u,maskStrokeColor:d,maskStrokeWidth:h,position:f="bottom-right",onClick:p,onNodeClick:g,pannable:x=!1,zoomable:v=!1,ariaLabel:y="React Flow mini map",inversePan:S,zoomStep:b=10,offsetScale:w=5}){const C=te(),R=M.useRef(null),{boundingRect:j,viewBB:z,rfId:A,panZoom:P,translateExtent:L,flowWidth:T,flowHeight:D}=Q(fp,re),m=(e==null?void 0:e.width)??up,k=(e==null?void 0:e.height)??dp,_=j.width/m,I=j.height/k,N=Math.max(_,I),E=N*m,$=N*k,H=w*N,B=j.x-(E-j.width)/2-H,q=j.y-($-j.height)/2-H,O=E+H*2,V=$+H*2,X=`${hp}-${A}`,K=M.useRef(0),F=M.useRef();K.current=N,M.useEffect(()=>{if(R.current&&P)return F.current=gf({domNode:R.current,panZoom:P,getTransform:()=>C.getState().transform,getViewScale:()=>K.current}),()=>{var U;(U=F.current)==null||U.destroy()}},[P]),M.useEffect(()=>{var U;(U=F.current)==null||U.update({translateExtent:L,width:T,height:D,inversePan:S,pannable:x,zoomStep:b,zoomable:v})},[x,v,S,b,L,T,D]);const W=p?U=>{var ee;const[G,J]=((ee=F.current)==null?void 0:ee.pointer(U))||[0,0];p(U,{x:G,y:J})}:void 0,Z=g?M.useCallback((U,G)=>{const J=C.getState().nodeLookup.get(G);g(U,J)},[]):void 0;return l.jsx(wr,{position:f,style:{...e,"--xy-minimap-background-color-props":typeof c=="string"?c:void 0,"--xy-minimap-mask-background-color-props":typeof u=="string"?u:void 0,"--xy-minimap-mask-stroke-color-props":typeof d=="string"?d:void 0,"--xy-minimap-mask-stroke-width-props":typeof h=="number"?h*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:l.jsxs("svg",{width:m,height:k,viewBox:`${B} ${q} ${O} ${V}`,className:"react-flow__minimap-svg",role:"img","aria-labelledby":X,ref:R,onClick:W,children:[y&&l.jsx("title",{id:X,children:y}),l.jsx(lp,{onClick:Z,nodeColor:r,nodeStrokeColor:n,nodeBorderRadius:i,nodeClassName:s,nodeStrokeWidth:o,nodeComponent:a}),l.jsx("path",{className:"react-flow__minimap-mask",d:`M${B-H},${q-H}h${O+H*2}v${V+H*2}h${-O-H*2}z
|
|
23
|
+
M${z.x},${z.y}h${z.width}v${z.height}h${-z.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}jo.displayName="MiniMap";M.memo(jo);function pp({nodeId:e,position:t,variant:n=ht.Handle,className:r,style:s={},children:i,color:o,minWidth:a=10,minHeight:c=10,maxWidth:u=Number.MAX_VALUE,maxHeight:d=Number.MAX_VALUE,keepAspectRatio:h=!1,shouldResize:f,onResizeStart:p,onResize:g,onResizeEnd:x}){const v=so(),y=typeof e=="string"?e:v,S=te(),b=M.useRef(null),w=n===ht.Line?"right":"bottom-right",C=t??w,R=M.useRef(null);M.useEffect(()=>{if(!(!b.current||!y))return R.current||(R.current=$f({domNode:b.current,nodeId:y,getStoreItems:()=>{const{nodeLookup:P,transform:L,snapGrid:T,snapToGrid:D,nodeOrigin:m,domNode:k}=S.getState();return{nodeLookup:P,transform:L,snapGrid:T,snapToGrid:D,nodeOrigin:m,paneDomNode:k}},onChange:(P,L)=>{const{triggerNodeChanges:T,nodeLookup:D,parentLookup:m,nodeOrigin:k}=S.getState(),_=[],I={x:P.x,y:P.y},N=D.get(y);if(N&&N.expandParent&&N.parentId){const E=N.origin??k,$=P.width??N.measured.width,H=P.height??N.measured.height,B={id:N.id,parentId:N.parentId,rect:{width:$,height:H,...ji({x:P.x??N.position.x,y:P.y??N.position.y},{width:$,height:H},N.parentId,D,E)}},q=yr([B],D,m,k);_.push(...q),I.x=P.x?Math.max(E[0]*$,P.x):void 0,I.y=P.y?Math.max(E[1]*H,P.y):void 0}if(I.x!==void 0&&I.y!==void 0){const E={id:y,type:"position",position:{...I}};_.push(E)}if(P.width!==void 0&&P.height!==void 0){const E={id:y,type:"dimensions",resizing:!0,setAttributes:!0,dimensions:{width:P.width,height:P.height}};_.push(E)}for(const E of L){const $={...E,type:"position"};_.push($)}T(_)},onEnd:()=>{const P={id:y,type:"dimensions",resizing:!1};S.getState().triggerNodeChanges([P])}})),R.current.update({controlPosition:C,boundaries:{minWidth:a,minHeight:c,maxWidth:u,maxHeight:d},keepAspectRatio:h,onResizeStart:p,onResize:g,onResizeEnd:x,shouldResize:f}),()=>{var P;(P=R.current)==null||P.destroy()}},[C,a,c,u,d,h,p,g,x,f]);const j=C.split("-"),z=n===ht.Line?"borderColor":"backgroundColor",A=o?{...s,[z]:o}:s;return l.jsx("div",{className:se(["react-flow__resize-control","nodrag",...j,n,r]),ref:b,style:A,children:i})}M.memo(pp);const gp=new Set;function mp(e){return e.startsWith("signal:child:")}function xp(e){const t=on(),n=(()=>{const i=new Set(e),o=[...e];for(;o.length>0;){const a=o.shift();if(a===void 0)continue;const c=t.getQueryData(["run",a]);if(c!==void 0)for(const u of c.timeline){const d=qt(u);d!==void 0&&!i.has(d)&&(i.add(d),o.push(d))}}return[...i].sort()})(),r=Oa({queries:n.map(i=>({queryKey:["run",i],queryFn:()=>ue.run(i)}))}),s={};return n.forEach((i,o)=>{var c;const a=(c=r[o])==null?void 0:c.data;a&&(s[i]=a)}),s}function yp({data:e}){const t=e.status==="failed",n=e.status==="pending"||e.status==="running",r=!!e.childRunId,s=!!e.collapsed,i=r&&!s,o=i?Xa:Ts(e.kind),a=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 l.jsxs("div",{title:i?Bn.child:Bn[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":i?"border-indigo-500/40 hover:border-indigo-400/60":"border-[var(--line)] hover:border-zinc-600"}`,children:[l.jsx("span",{className:`absolute inset-y-0 left-0 w-[3px] ${a.rail} ${n?"animate-pulse":""}`}),l.jsx(Pe,{type:"target",position:Y.Left,className:"!border-0 !bg-zinc-600"}),l.jsxs("div",{className:"py-2.5 pl-3.5 pr-3",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("span",{className:`grid h-5 w-5 shrink-0 place-items-center rounded ${a.badge}`,children:l.jsx(o,{width:12,height:12})}),l.jsx("span",{className:"truncate text-[13px] font-medium text-zinc-100",children:e.name}),l.jsx("span",{className:`ml-auto grid h-4 w-4 shrink-0 place-items-center rounded-full ${a.pill} ${n?"animate-pulse":""}`,children:t?l.jsx(Ke,{width:9,height:9}):n?l.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-current"}):l.jsx(Rs,{width:9,height:9})})]}),l.jsxs("div",{className:"mono mt-1.5 flex items-center gap-1.5 text-[10px] text-zinc-500",children:[r?l.jsxs("span",{className:"flex items-center gap-1",children:[!s&&l.jsx("button",{type:"button",onClick:c=>{var u;c.stopPropagation(),e.childRunId&&((u=e.onToggleChild)==null||u.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:l.jsx("span",{className:"inline-block text-[9px] transition-transform",style:{transform:e.childExpanded?"rotate(90deg)":"rotate(0deg)"},children:"▸"})}),l.jsx("button",{type:"button",onClick:c=>{var u;c.stopPropagation(),e.childRunId&&((u=e.onOpenRun)==null||u.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 ↗"})]}):l.jsx("span",{className:"rounded border border-[var(--line)] px-1 text-zinc-400",children:e.kind}),e.attempts>1&&l.jsxs("span",{className:"flex items-center gap-0.5 text-amber-300",children:[l.jsx(Ds,{width:9,height:9}),e.attempts]}),e.workerGroup&&l.jsxs("span",{className:"truncate",children:["@",e.workerGroup]}),l.jsxs("span",{className:"tnum ml-auto text-zinc-400",children:["#",e.seq,e.duration&&l.jsxs("span",{className:"text-zinc-600",children:[" · ",e.duration]})]})]}),e.subs&&l.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&&l.jsxs("span",{className:"text-emerald-300",children:[e.subs.ok," ok"]}),e.subs.failed>0&&l.jsxs("span",{className:"text-red-300",children:[e.subs.failed," failed"]}),e.subs.skipped>0&&l.jsxs("span",{className:"text-amber-300",children:[e.subs.skipped," skipped"]})]})]}),l.jsx(Pe,{type:"source",position:Y.Right,className:"!border-0 !bg-zinc-600"})]})}function wp({data:e}){const t=e.status==="running"||e.status==="awaiting";return l.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:[l.jsx(Pe,{type:"target",position:Y.Left,className:"!border-0 !bg-zinc-600"}),l.jsx("span",{className:`dot ${t?"pulse":""}`}),l.jsx("span",{className:"mono text-[11px] uppercase tracking-wider",children:e.label}),l.jsx(Pe,{type:"source",position:Y.Right,className:"!border-0 !bg-zinc-600"})]})}const vp={step:yp,terminal:wp};function bp(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 Np({run:e,timeline:t,selectedKey:n,onSelect:r,onOpenRun:s,fmtDuration:i,expanded:o,onToggleChild:a}){const c=o??gp,u=M.useMemo(()=>{const g=new Set(c);for(const x of t){const v=qt(x);v!==void 0&&g.add(v)}return g},[c,t]),d=xp(u),{nodes:h,edges:f}=(()=>{const y=[],S=[],b=e.status==="running"||e.status==="suspended",w=(T,D,m)=>({id:`${T}->${D}`,source:T,target:D,style:{stroke:m?"#f87171":"var(--line)",strokeWidth:1.5}}),C=(T,D)=>({id:`${T}=>${D}`,source:T,target:D,style:{stroke:"#818cf8",strokeWidth:1.5,strokeDasharray:"4 3"}});function R(T,D,m,k,_,I){const N=`${_}s${T.seq}`,E=qt(T),$=E!==void 0?d[E]:void 0,H=$!==void 0&&$.timeline.length===1&&$.timeline[0]?{step:$.timeline[0],run:$.run}:void 0,B=H!==void 0,q=!B&&E!==void 0&&c.has(E),O=H?H.step:T,V=H?H.run:I,X=H?H.step.name:E!==void 0?($==null?void 0:$.run.workflow)??"child workflow":T.name,K=O.status==="failed";y.push({id:N,type:"step",draggable:!1,position:{x:D,y:m},data:{seq:O.seq,name:X,kind:O.kind,status:O.status,workerGroup:O.workerGroup,attempts:O.attempts,duration:i(O.startedAt,O.finishedAt),subs:bp(O),selected:n===`${O.runId}#${O.seq}`,childRunId:E,onOpenRun:s,childExpanded:q,onToggleChild:a,collapsed:B,depth:k,step:O,laneRun:V}});const F=q?$:void 0;if(F){const W=j(F.timeline,k+1,D+248,m+150,`${E}:`,F.run);for(const U of W.firstIds)S.push(C(N,U));const Z=mp(T.name)&&W.connectors.length>0?W.connectors:[{id:N,failed:K}];return{id:N,exits:Z,nextX:Math.max(D+248,W.nextX),bottomY:Math.max(m,W.bottomY)}}return{id:N,exits:[{id:N,failed:K}],nextX:D+248,bottomY:m}}function j(T,D,m,k,_,I){let N=m;const E=[];let $=[],H=k;for(const B of Va(T)){const q=B.kind==="single"?[B.step]:B.steps,O=E.length===0,V=[];let X=k,K=N;for(const F of q){const W=R(F,N,X,D,_,I);O&&E.push(W.id);for(const Z of $)S.push(w(Z.id,W.id,Z.failed));V.push(...W.exits),K=Math.max(K,W.nextX),X=W.bottomY+96}$=V,N=K,H=Math.max(H,X-96)}return{firstIds:E,connectors:$,nextX:N,bottomY:H}}const z=248;y.push({id:"start",type:"terminal",position:{x:0,y:0},draggable:!1,data:{status:"running",label:e.workflow}});const A=j(t,0,z,0,"",e);for(const T of A.firstIds)S.push({id:`start->${T}`,source:"start",target:T});const P=ir(e,t);y.push({id:"end",type:"terminal",position:{x:Math.max(A.nextX,z),y:0},draggable:!1,data:{status:P,label:P}});const L=A.connectors.length>0?A.connectors:[{id:"start",failed:!1}];for(const T of L)S.push({id:`${T.id}->end`,source:T.id,target:"end",animated:b,style:{stroke:b?"var(--accent)":"var(--line)",strokeWidth:b?2:1.5}});return{nodes:y,edges:S}})(),p=M.useCallback((g,x)=>{if(x.type!=="step")return;const v=x.data;v.step&&v.laneRun&&r(v.step,v.laneRun)},[r]);return l.jsxs(X0,{nodes:h,edges:f,nodeTypes:vp,onNodeClick:p,fitView:!0,fitViewOptions:{padding:.3,maxZoom:1.1},proOptions:{hideAttribution:!0},nodesConnectable:!1,nodesDraggable:!1,panOnScroll:!0,minZoom:.3,children:[l.jsx(G0,{variant:be.Dots,gap:22,size:1,color:"#1c1c22"}),l.jsx(np,{showInteractive:!1,position:"bottom-right"})]})}function Co({className:e}){return l.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:[l.jsx("title",{children:"durable"}),l.jsx("path",{d:"M12 2.5 21.5 12 12 21.5 2.5 12z",opacity:.35}),l.jsx("circle",{cx:"6.4",cy:"12",r:"1.7",fill:"currentColor",stroke:"none"}),l.jsx("circle",{cx:"12",cy:"12",r:"1.7",fill:"currentColor",stroke:"none"}),l.jsx("circle",{cx:"17.6",cy:"12",r:"1.7",fill:"currentColor",stroke:"none"}),l.jsx("path",{d:"M8.1 12h2.2M13.7 12h2.2"})]})}const _p=["pending","running","suspended","completed","failed","cancelling","cancelled","dead"];function Sp(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 Ep(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 Mo({status:e}){const t=e==="running"||e==="awaiting"||e==="cancelling";return l.jsx("span",{className:`dot s-${e} ${t?"pulse":""}`,"aria-hidden":!0})}function $o({status:e}){return l.jsxs("span",{className:`s-${e} inline-flex items-center gap-1.5 text-[11px] uppercase tracking-wider`,children:[l.jsx(Mo,{status:e}),e]})}function kp({counts:e,filter:t,onFilter:n}){const r=Object.values(e).reduce((i,o)=>i+o,0),s=(i,o,a)=>l.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"&&l.jsx(Mo,{status:i}),l.jsx("span",{className:"uppercase tracking-wide",children:o}),l.jsx("span",{className:"mono tnum text-zinc-600",children:a})]},i);return l.jsxs("header",{className:"z-10 flex items-center gap-4 border-b border-[var(--line)] px-5 py-3",children:[l.jsxs("div",{className:"flex items-center gap-2.5",children:[l.jsx("div",{className:"grid h-7 w-7 place-items-center rounded-md border border-emerald-500/30 bg-emerald-500/10",children:l.jsx(Co,{className:"h-4 w-4 text-emerald-400"})}),l.jsxs("div",{className:"leading-none",children:[l.jsx("div",{className:"text-sm font-semibold tracking-tight",children:"durable"}),l.jsx("div",{className:"mono text-[10px] uppercase tracking-[0.2em] text-zinc-600",children:"control plane"})]})]}),l.jsxs("div",{className:"ml-2 flex flex-wrap items-center gap-1",children:[s("all","all",r),_p.map(i=>s(i,i,e[i]??0))]}),l.jsx(Mp,{}),l.jsxs("div",{className:"flex items-center gap-2 text-xs text-zinc-500",children:[l.jsx("span",{className:"dot s-completed pulse","aria-hidden":!0}),"live"]})]})}function jp(e){const t=Math.max(0,Math.round((Date.now()-e)/1e3));if(t<60)return`${t}s ago`;const n=Math.round(t/60);if(n<60)return`${n}m ago`;const r=Math.round(n/60);return r<24?`${r}h ago`:`${Math.round(r/24)}d ago`}function zo({status:e}){const t=e==null?void 0:e.concurrency;if(!e||!t)return l.jsx("span",{className:"mono text-[9px] text-zinc-600",children:"no status"});const n=t.limit>0&&e.inFlight>=t.limit*.8;return l.jsxs("div",{className:"flex flex-col gap-1",children:[l.jsxs("div",{className:"mono flex flex-wrap items-center gap-x-3 gap-y-0.5 text-[10px] text-zinc-500",children:[l.jsx("span",{className:`shrink-0 rounded border px-1 text-[9px] uppercase tracking-wider ${t.mode==="adaptive"?"border-sky-500/40 bg-sky-500/10 text-sky-300":"border-zinc-600/50 bg-zinc-800/60 text-zinc-400"}`,children:t.mode==="adaptive"?`adaptive ${t.min??1}–${t.max??32}`:"fixed"}),l.jsxs("span",{className:n?"text-amber-300":"text-zinc-400",children:["in-flight"," ",l.jsxs("span",{className:"tnum",children:[e.inFlight,"/",t.limit]})]}),typeof e.rssPct=="number"&&l.jsxs("span",{className:e.rssPct>=85?"text-rose-300":"",children:["ram ",l.jsxs("span",{className:"tnum",children:[Math.round(e.rssPct),"%"]})]}),typeof e.cpuPct=="number"&&l.jsxs("span",{children:["cpu ",l.jsxs("span",{className:"tnum",children:[Math.round(e.cpuPct),"%"]})]}),typeof e.throughputPerMin=="number"&&l.jsxs("span",{children:[l.jsx("span",{className:"tnum",children:Math.round(e.throughputPerMin)}),"/min"]}),typeof e.p95Ms=="number"&&l.jsxs("span",{children:["p95 ",l.jsxs("span",{className:"tnum",children:[Math.round(e.p95Ms),"ms"]})]})]}),e.lastAdjust&&l.jsxs("div",{className:"mono text-[10px] text-zinc-500",children:[e.lastAdjust.reason," ",l.jsxs("span",{className:"tnum text-zinc-400",children:[e.lastAdjust.from,"→",e.lastAdjust.to]})," ",jp(e.lastAdjust.at)]})]})}function Cp({workers:e}){return l.jsx("div",{className:"flex flex-col divide-y divide-[var(--line-soft)]",children:e.map(t=>l.jsxs("div",{className:"flex flex-col gap-1 px-2.5 py-2",children:[l.jsx("span",{className:"mono truncate text-[10px] text-zinc-400",children:t.instanceId}),l.jsx(zo,{status:t.status})]},t.instanceId))})}function Mp(){const{data:e}=pt({queryKey:["workers"],queryFn:()=>ue.workers(),refetchInterval:1e4}),[t,n]=M.useState("workers");if(!e||e.length===0)return null;const r=tc(e);return l.jsxs("div",{className:"ml-auto flex flex-nowrap items-center gap-1.5",children:[l.jsx("div",{className:"flex items-center gap-0.5 rounded border border-[var(--line)] bg-zinc-900/60 p-0.5",children:["workers","partitions","alerts"].map(s=>l.jsxs("button",{type:"button",onClick:()=>n(s),className:`mono rounded px-1.5 py-0.5 text-[10px] ${t===s?"bg-zinc-700 text-zinc-100":"text-zinc-500 hover:text-zinc-300"}`,children:[s==="workers"?"pods":s==="partitions"?"parts":"alerts",s==="alerts"&&r.starved.length>0&&l.jsx("span",{className:"tnum ml-1 rounded bg-rose-500/80 px-1 text-[9px] text-white",children:r.starved.length})]},s))}),l.jsxs("div",{className:"flex w-[300px] flex-nowrap items-center justify-end gap-1.5",children:[t==="workers"&&l.jsx($p,{workers:ec(e)}),t==="partitions"&&l.jsx(zp,{groups:e}),t==="alerts"&&l.jsx(Ip,{summary:r})]})]})}function $p({workers:e}){const[t,n]=M.useState(void 0);return l.jsx(l.Fragment,{children:e.map(r=>{var a;const s=t===r.instanceId,i=(a=r.status)==null?void 0:a.concurrency,o=r.status&&i?`${r.status.inFlight}/${i.limit}`:void 0;return l.jsxs("div",{className:"relative",children:[l.jsxs("button",{type:"button",onClick:()=>n(s?void 0:r.instanceId),title:`${r.instanceId} — ${r.handlers.length} handler(s) on ${r.partition}`,className:`mono flex max-w-[220px] items-center gap-1 rounded border px-1.5 py-0.5 text-[10px] hover:border-zinc-500 ${s?"border-zinc-500 bg-zinc-800 text-zinc-200":"border-[var(--line)] bg-zinc-800/40 text-zinc-400"}`,children:[l.jsx("span",{className:`dot ${r.status?"s-completed":""}`,"aria-hidden":!0}),l.jsx("span",{className:"truncate",children:r.instanceId}),r.partition!=="default"&&l.jsxs("span",{className:"shrink-0 text-zinc-500",children:["@",r.partition]}),l.jsxs("span",{className:"tnum shrink-0 text-zinc-500",children:[r.handlers.length,"h",o?` · ${o}`:""]})]}),s&&l.jsxs("div",{className:"absolute right-0 top-full z-20 mt-1 w-72 rounded-md border border-[var(--line)] bg-zinc-950/95 shadow-xl backdrop-blur",children:[l.jsxs("div",{className:"mono flex items-center justify-between gap-2 border-b border-[var(--line)] px-2.5 py-1.5 text-[10px] text-zinc-500",children:[l.jsx("span",{className:"truncate text-zinc-300",children:r.instanceId}),l.jsxs("span",{className:"shrink-0",children:[r.runtime??"node"," · ",r.partition]})]}),l.jsx("div",{className:"px-2.5 py-2",children:l.jsx(zo,{status:r.status})}),l.jsxs("div",{className:"max-h-48 overflow-auto border-t border-[var(--line-soft)] px-2.5 py-1.5",children:[l.jsxs("div",{className:"mono mb-1 text-[9px] uppercase tracking-wider text-zinc-600",children:[r.handlers.length," handlers"]}),r.handlers.map(c=>l.jsx("div",{className:"mono truncate text-[10px] text-zinc-400",children:c},c))]})]})]},r.instanceId)})})}function zp({groups:e}){const[t,n]=M.useState(void 0),r=Qa(e);function s(i){const o=new Map;for(const a of e)if(Yt(a.group)===i)for(const c of a.liveWorkers)o.has(c.instanceId)||o.set(c.instanceId,c);return[...o.values()]}return l.jsx(l.Fragment,{children:r.map(i=>{const o=i.starvedCount>0,a=t===i.partition;return l.jsxs("div",{className:"relative",children:[l.jsxs("button",{type:"button",disabled:i.workerCount===0,onClick:()=>n(a?void 0:i.partition),title:`${i.partition}: ${i.workerCount} worker(s), ${i.handlerCount} handler(s), ${i.totalDepth} queued${o?`, ${i.starvedCount} starved`:""}`,className:`mono flex items-center gap-1 rounded border px-1.5 py-0.5 text-[10px] ${o?"border-rose-500/50 bg-rose-500/15 text-rose-300":a?"border-zinc-500 bg-zinc-800 text-zinc-200":"border-[var(--line)] bg-zinc-800/40 text-zinc-400"} ${i.workerCount>0?"cursor-pointer hover:border-zinc-500":"cursor-default"}`,children:[l.jsx("span",{className:`dot ${o?"s-failed":i.workerCount>0?"s-completed":""}`,"aria-hidden":!0}),i.partition,l.jsxs("span",{className:"tnum text-zinc-500",children:[i.workerCount,"w ",i.handlerCount,"h",i.totalDepth>0?` ${i.totalDepth}q`:"",o?` ${i.starvedCount}!`:""]})]}),a&&i.workerCount>0&&l.jsxs("div",{className:"absolute right-0 top-full z-20 mt-1 w-72 rounded-md border border-[var(--line)] bg-zinc-950/95 shadow-xl backdrop-blur",children:[l.jsxs("div",{className:"mono flex items-center justify-between border-b border-[var(--line)] px-2.5 py-1.5 text-[10px] text-zinc-500",children:[l.jsx("span",{className:"text-zinc-300",children:i.partition}),l.jsxs("span",{className:"tnum",children:[i.workerCount," worker(s) · ",i.totalDepth," queued"]})]}),l.jsx(Cp,{workers:s(i.partition)})]})]},i.partition)})})}function Ip({summary:e}){return l.jsxs(l.Fragment,{children:[l.jsxs("span",{className:"mono tnum text-[10px] text-zinc-500",children:[e.queueCount," queues · ",e.workerCount," workers ·"," ",e.allDraining?l.jsx("span",{className:"text-emerald-400",children:"all draining"}):l.jsxs("span",{className:"text-rose-300",children:[e.starved.length," starved"]})]}),e.starved.map(t=>l.jsxs("span",{title:`${t.group}: ${t.depth} queued, no worker consuming`,className:"mono flex items-center gap-1 rounded border border-rose-500/50 bg-rose-500/15 px-1.5 py-0.5 text-[10px] text-rose-300",children:[l.jsx("span",{className:"dot s-failed","aria-hidden":!0}),l.jsx("span",{className:"max-w-[180px] truncate",children:t.group}),l.jsxs("span",{className:"tnum shrink-0",children:[t.depth,"q · 0w"]})]},t.group))]})}function Ap(){return l.jsx("ul",{className:"divide-y divide-[var(--line-soft)]","aria-hidden":!0,children:[0,1,2,3,4,5].map(e=>l.jsxs("li",{className:"flex flex-col gap-2 px-4 py-3",children:[l.jsxs("div",{className:"flex items-center justify-between gap-2",children:[l.jsx("div",{className:"h-3.5 w-32 animate-pulse rounded bg-zinc-800"}),l.jsx("div",{className:"h-3 w-16 animate-pulse rounded bg-zinc-800/70"})]}),l.jsx("div",{className:"h-2.5 w-48 animate-pulse rounded bg-zinc-800/50"})]},e))})}function Pp({runs:e,loading:t,selected:n,onSelect:r,onSelectTag:s}){return t&&e.length===0?l.jsx(Ap,{}):e.length===0?l.jsx("div",{className:"p-6 text-sm text-zinc-600",children:"No runs yet."}):l.jsx("ul",{className:"divide-y divide-[var(--line-soft)]",children:e.map(i=>l.jsx("li",{children:l.jsxs("button",{type:"button",onClick:()=>r(i.id),className:`flex w-full flex-col gap-1 px-4 py-3 text-left transition-colors ${n===i.id?"bg-zinc-900":"hover:bg-zinc-900/50"}`,children:[l.jsxs("div",{className:"flex items-center justify-between gap-2",children:[l.jsxs("span",{className:"flex min-w-0 items-center gap-1.5",children:[l.jsx("span",{className:"truncate text-sm font-medium text-zinc-200",children:i.workflow}),i.id.startsWith("dlq:")&&l.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"})]}),l.jsx($o,{status:ir(i)})]}),l.jsxs("div",{className:"flex items-center justify-between gap-2",children:[l.jsx("span",{className:"mono truncate text-[11px] text-zinc-600",children:i.id}),l.jsx("span",{className:"shrink-0 text-[11px] text-zinc-600",children:Sp(i.updatedAt)})]}),i.tags&&i.tags.length>0&&l.jsx("div",{className:"flex flex-wrap gap-1",children:i.tags.map(o=>l.jsxs("span",{onClick:a=>{a.stopPropagation(),s(o)},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:["#",o]},o))})]})},i.id))})}function Tp({id:e,onOpenRun:t}){var _,I;const n=on(),{data:r}=pt({queryKey:["run",e],queryFn:async()=>Ja(n.getQueryData(["run",e]),await ue.run(e)),refetchInterval:N=>{var $;const E=($=N.state.data)==null?void 0:$.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,$=N.event;n.setQueryData(["run",e],H=>H&&{...H,timeline:H.timeline.map(B=>B.seq===E?{...B,events:[...B.events??[],$]}:B)});return}n.invalidateQueries({queryKey:["run",e]})})},[e,c,n]);const u=lt({mutationFn:()=>ue.retry(e),onSuccess:o}),d=lt({mutationFn:N=>ue.cancel(e,N!==void 0?{compensate:N}:{}),onSuccess:o}),h=lt({mutationFn:()=>ue.continue(e),onSuccess:o}),f=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{f.mutate(JSON.parse(E))}catch{window.alert("Invalid JSON")}},[g,x]=M.useState(),[v,y]=M.useState(!1),[S,b]=M.useState(new Set),[w,C]=M.useState(240);function R(N){N.preventDefault(),N.currentTarget.setPointerCapture(N.pointerId);const E=H=>C(B=>Math.max(120,Math.min(720,B-H.movementY))),$=()=>{window.removeEventListener("pointermove",E),window.removeEventListener("pointerup",$)};window.addEventListener("pointermove",E),window.addEventListener("pointerup",$)}function j(N){b(E=>{const $=new Set(E);return $.has(N)?$.delete(N):$.add(N),$})}if(!r)return l.jsx("div",{className:"p-8 text-sm text-zinc-600",children:"Loading run…"});const{run:z,timeline:A}=r,P=z.id.startsWith("dlq:"),L=P?{id:z.id.slice(4),title:"Dead-letter handler",subtitle:`started because run ${z.id.slice(4)} was dead-lettered`,cta:"open dead run →"}:i?{id:`dlq:${z.id}`,title:"Dead-lettered",subtitle:"this run exceeded recovery and was routed to a DLQ handler",cta:"open DLQ handler →"}:void 0,T=z.status==="failed"||z.status==="suspended",D=z.status==="running"||z.status==="suspended",m=A.some(N=>N.status==="pending"&&N.kind==="signal"&&N.name.startsWith("breakpoint")),k=g?`${g.step.runId}#${g.step.seq}`:void 0;return l.jsxs("div",{className:"flex h-full flex-col",children:[l.jsxs("div",{className:"flex items-start justify-between gap-4 border-b border-[var(--line)] px-7 py-5",children:[l.jsxs("div",{className:"min-w-0",children:[l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsx("h2",{className:"text-lg font-semibold tracking-tight",children:z.workflow}),P&&l.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"}),l.jsx($o,{status:ir(z,A)}),l.jsxs("span",{className:"mono rounded border border-[var(--line)] px-1.5 py-0.5 text-[10px] text-zinc-500",children:["v",z.workflowVersion]}),l.jsxs("span",{className:"mono tnum text-[11px] text-zinc-600",children:[A.length," ",A.length===1?"step":"steps"]})]}),l.jsx("div",{className:"mono mt-1 truncate text-[11px] text-zinc-600",children:z.id}),z.tags&&z.tags.length>0&&l.jsx("div",{className:"mt-1.5 flex flex-wrap gap-1",children:z.tags.map(N=>l.jsxs("span",{className:"mono rounded border border-[var(--line)] bg-zinc-800/40 px-1.5 text-[10px] text-zinc-400",children:["#",N]},N))}),z.searchAttributes&&Object.keys(z.searchAttributes).length>0&&l.jsx("div",{className:"mt-1.5 flex flex-wrap gap-1",children:Object.entries(z.searchAttributes).map(([N,E])=>l.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?l.jsxs("div",{className:"mt-1.5 flex flex-wrap items-center gap-1",children:[l.jsx("span",{className:"text-[10px] text-zinc-600",children:"children:"}),(I=r.children)==null?void 0:I.map(N=>l.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]}),l.jsxs("div",{className:"flex shrink-0 gap-2",children:[l.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:"{ }"}),m&&l.jsxs("button",{type:"button",disabled:h.isPending,onClick:()=>h.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:[l.jsx(qa,{width:12,height:12}),"Continue"]}),l.jsxs("button",{type:"button",disabled:!T||u.isPending,onClick:()=>u.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:[l.jsx(Mn,{width:12,height:12}),"Retry"]}),(z.status==="dead"||z.status==="failed")&&l.jsxs("button",{type:"button",disabled:f.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:[l.jsx(Mn,{width:12,height:12}),"Fix & replay"]}),D&&l.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:[l.jsx(Mn,{width:12,height:12}),"Cancel + Undo"]}),l.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:[l.jsx(Ke,{width:12,height:12}),"Cancel"]})]})]}),L&&l.jsxs("div",{className:"flex items-center gap-3 border-b border-rose-500/30 bg-rose-500/10 px-7 py-3",children:[l.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:"⚠"}),l.jsxs("div",{className:"min-w-0 flex-1",children:[l.jsx("div",{className:"text-[13px] font-medium text-rose-200",children:L.title}),l.jsx("div",{className:"mono truncate text-[11px] text-rose-300/70",children:L.subtitle})]}),l.jsx("button",{type:"button",onClick:()=>t(L.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:L.cta})]}),l.jsxs("div",{className:"relative grid min-h-0 flex-1",style:{gridTemplateRows:A.length>0?`1fr ${w}px`:"1fr"},children:[l.jsxs("div",{className:"relative min-h-0",children:[A.length===0?l.jsx("div",{className:"grid h-full place-items-center text-sm text-zinc-600",children:"No steps recorded yet."}):l.jsx(Np,{run:z,timeline:A,selectedKey:k,onSelect:(N,E)=>x({step:N,run:E}),onOpenRun:t,fmtDuration:Ep,expanded:S,onToggleChild:j}),(z.status==="failed"||z.status==="cancelled")&&z.error&&l.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:z.error.message})]}),A.length>0&&l.jsxs("div",{className:"relative min-h-0 overflow-hidden border-t border-[var(--line)] bg-black/20",children:[l.jsx("div",{onPointerDown:R,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"}),l.jsx(Ya,{run:z,timeline:A,selectedKey:k,onSelect:(N,E)=>x({step:N,run:E}),onOpenRun:t,expanded:S,onToggleChild:j})]}),g&&l.jsx(ac,{step:g.step,run:g.run,onClose:()=>x(void 0),onOpenRun:t}),v&&l.jsx(cc,{run:z,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 Dp(){const[e,t]=M.useState("all"),[n,r]=M.useState(""),[s,i]=M.useState(""),[o,a]=M.useState(()=>Is()),c=M.useCallback(v=>{if(a(v),typeof window>"u")return;const y=v?`#/run/${encodeURIComponent(v)}`:"",S=y||window.location.pathname+window.location.search;window.location.hash!==y&&window.history.pushState(null,"",S)},[]);M.useEffect(()=>{const v=()=>a(Is());return window.addEventListener("hashchange",v),window.addEventListener("popstate",v),()=>{window.removeEventListener("hashchange",v),window.removeEventListener("popstate",v)}},[]);const u=on(),d=s.split(",").map(v=>v.trim()).filter(Boolean),{data:h=[],isPending:f}=pt({queryKey:["runs",n,d.join("|")],queryFn:()=>ue.runs(void 0,n||void 0,d.length?d:void 0),refetchInterval:3e3}),p=lt({mutationFn:v=>ue.bulk(v,{status:e!=="all"?e:void 0,tag:n||void 0,attr:d.length?d:void 0}),onSuccess:()=>u.invalidateQueries({queryKey:["runs"]})}),g=h.reduce((v,y)=>(v[y.status]=(v[y.status]??0)+1,v),{}),x=e==="all"?h:h.filter(v=>v.status===e);return l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"app-bg"}),l.jsxs("div",{className:"relative z-10 flex h-full flex-col",children:[l.jsx(kp,{counts:g,filter:e,onFilter:t}),l.jsxs("div",{className:"grid min-h-0 flex-1 grid-cols-[minmax(300px,360px)_1fr]",children:[l.jsxs("aside",{className:"flex min-h-0 flex-col border-r border-[var(--line)]",children:[l.jsxs("div",{className:"border-b border-[var(--line)] p-2",children:[l.jsxs("div",{className:"flex items-center gap-1.5 rounded-md border border-[var(--line)] px-2",children:[l.jsx("span",{className:"text-zinc-600",children:"#"}),l.jsx("input",{value:n,onChange:v=>r(v.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&&l.jsx("button",{type:"button",onClick:()=>r(""),className:"text-zinc-600 hover:text-zinc-300",title:"clear tag filter",children:l.jsx(Ke,{width:12,height:12})})]}),l.jsxs("div",{className:"mt-1.5 flex items-center gap-1.5 rounded-md border border-[var(--line)] px-2",children:[l.jsx("span",{className:"text-zinc-600",children:"⛃"}),l.jsx("input",{value:s,onChange:v=>i(v.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&&l.jsx("button",{type:"button",onClick:()=>i(""),className:"text-zinc-600 hover:text-zinc-300",title:"clear attribute filter",children:l.jsx(Ke,{width:12,height:12})})]})]}),(e!=="all"||n||d.length>0)&&x.length>0&&l.jsxs("div",{className:"flex items-center gap-2 border-b border-[var(--line)] px-3 py-1.5",children:[l.jsxs("span",{className:"mono text-[10px] text-zinc-500",children:[x.length," ",e!=="all"?e:""," ",n&&`#${n}`,d.length>0&&` ⛃${d.length}`]}),l.jsx("button",{type:"button",disabled:p.isPending,onClick:()=>p.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"}),l.jsx("button",{type:"button",disabled:p.isPending,onClick:()=>p.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"})]}),l.jsx("div",{className:"min-h-0 flex-1 overflow-auto",children:l.jsx(Pp,{runs:x,loading:f,selected:o,onSelect:c,onSelectTag:r})})]}),l.jsx("main",{className:"min-h-0",children:o?l.jsx(Tp,{id:o,onOpenRun:c},o):l.jsx("div",{className:"grid h-full place-items-center text-center",children:l.jsxs("div",{className:"flex flex-col items-center",children:[l.jsx(Co,{className:"h-10 w-10 text-zinc-800"}),l.jsx("p",{className:"mt-3 text-sm text-zinc-600",children:"Select a run to see its timeline."})]})})})]})]})]})}const Rp=new Wa({defaultOptions:{queries:{refetchInterval:2e3,refetchOnWindowFocus:!1}}});Ka(document.getElementById("root")).render(l.jsx(M.StrictMode,{children:l.jsx(Ga,{client:Rp,children:l.jsx(Dp,{})})}));
|