@dudousxd/nestjs-durable-dashboard 0.29.3 → 0.29.5

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