@dudousxd/nestjs-durable-dashboard 0.29.5 → 0.29.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/durable-client.d.ts +7 -5
- package/dist/client/durable-client.d.ts.map +1 -1
- package/dist/client/durable-client.js +28 -16
- package/dist/client/durable-client.js.map +1 -1
- package/dist/spa/assets/{index-CL-J6Vls.js → index-B8Ij4B8D.js} +8 -8
- package/dist/spa/assets/{index-Cp4sRb-7.js → index-CBmp6c1z.js} +1 -1
- package/dist/spa/assets/{preview-kbw168tZ.js → preview-UGBJkOkg.js} +1 -1
- package/dist/spa/index.html +2 -2
- package/dist/spa/preview.html +2 -2
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
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),Ve=(e,t,n,r)=>($n(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),qe=(e,t,n)=>($n(e,t,"access private method"),n);import{S as La,s as Ha,h as zr,g as Fa,n as Os,u as an,r as M,a as Oa,b as Ba,c as Xt,i as Bs,j as c,K as On,X as Ge,B as Vs,d as Va,e as we,R as qa,C as qs,f as Xa,k as oe,l as Ya,m as Wa,o as Ka,p as Ga,q as Ua,t as Za,v as ar,P as Qa,w as Mn,x as Ja,Q as ec,y as tc,z as nc}from"./index-CL-J6Vls.js";var Ae,Pe,ae,ye,_e,Ft,Bn,Fs,rc=(Fs=class extends La{constructor(t,n){super();Be(this,_e);Be(this,Ae);Be(this,Pe);Be(this,ae);Be(this,ye);Ve(this,Ae,t),this.setOptions(n),this.bindMethods(),qe(this,_e,Ft).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,Ae).defaultMutationOptions(t),Ha(this.options,n)||ne(this,Ae).getMutationCache().notify({type:"observerOptionsUpdated",mutation:ne(this,ae),observer:this}),n!=null&&n.mutationKey&&this.options.mutationKey&&zr(n.mutationKey)!==zr(this.options.mutationKey)?this.reset():((r=ne(this,ae))==null?void 0:r.state.status)==="pending"&&ne(this,ae).setOptions(this.options)}onUnsubscribe(){var t;this.hasListeners()||(t=ne(this,ae))==null||t.removeObserver(this)}onMutationUpdate(t){qe(this,_e,Ft).call(this),qe(this,_e,Bn).call(this,t)}getCurrentResult(){return ne(this,Pe)}reset(){var t;(t=ne(this,ae))==null||t.removeObserver(this),Ve(this,ae,void 0),qe(this,_e,Ft).call(this),qe(this,_e,Bn).call(this)}mutate(t,n){var r;return Ve(this,ye,n),(r=ne(this,ae))==null||r.removeObserver(this),Ve(this,ae,ne(this,Ae).getMutationCache().build(ne(this,Ae),this.options)),ne(this,ae).addObserver(this),ne(this,ae).execute(t)}},Ae=new WeakMap,Pe=new WeakMap,ae=new WeakMap,ye=new WeakMap,_e=new WeakSet,Ft=function(){var n;const t=((n=ne(this,ae))==null?void 0:n.state)??Fa();Ve(this,Pe,{...t,isPending:t.status==="pending",isSuccess:t.status==="success",isError:t.status==="error",isIdle:t.status==="idle",mutate:this.mutate,reset:this.reset})},Bn=function(t){Os.batch(()=>{var n,r,s,i,o,a,l,u;if(ne(this,ye)&&this.hasListeners()){const d=ne(this,Pe).variables,f=ne(this,Pe).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,Pe))})})},Fs);function ut(e,t){const n=an(),[r]=M.useState(()=>new rc(n,e));M.useEffect(()=>{r.setOptions(e)},[r,e]);const s=M.useSyncExternalStore(M.useCallback(o=>r.subscribe(Os.batchCalls(o)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),i=M.useCallback((o,a)=>{r.mutate(o,a).catch(Oa)},[r]);if(s.error&&Ba(r.options.throwOnError,[s.error]))throw s.error;return{...s,mutate:i,mutateAsync:s.mutate}}const Ir="compensate:";function sc(e){return e.startsWith(Ir)?e.slice(Ir.length):e}function ic(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 oc(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 ac(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 cc(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 lc(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 uc(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"},dc={debug:"text-zinc-500",info:"text-zinc-300",warn:"text-amber-300",error:"text-red-300"},fc=["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 ${dc[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]=M.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 hc({events:e}){const{subs:t,stepLogs:n}=Va(e),r=fc.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 pc({value:e}){const[t,n]=M.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(pc,{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 Ce({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 gc({id:e,onOpenRun:t}){const{data:n}=we({queryKey:["run",e],queryFn:()=>oe.run(e)}),[r,s]=M.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 mc({step:e,run:t,onClose:n,onOpenRun:r}){const s=Xt(e),[i,o]=M.useState(!1),a=e.status==="failed",l=e.status==="pending"||e.status==="running",u=Bs(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," · ",On[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(Ge,{})})]}),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(Ce,{k:"seq",v:`#${e.seq}`}),f>=1&&c.jsx(Ce,{k:"queued",v:c.jsx("span",{className:"text-sky-300",children:Wt(f)})}),c.jsx(Ce,{k:"duration",v:l?c.jsx("span",{className:"text-amber-300",children:"running…"}):Ar(e.startedAt,e.finishedAt)}),c.jsx(Ce,{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(Ce,{k:"worker",v:`@${e.workerGroup}`}),c.jsx(Ce,{k:"started",v:Pr(e.startedAt)}),c.jsx(Ce,{k:"finished",v:Pr(e.finishedAt)}),c.jsx(Ce,{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(hc,{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(gc,{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 xc({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(Ge,{})})]}),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 yc={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 Ot(n)}function Ot(e){this._=e}function wc(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}})}Ot.prototype=cn.prototype={constructor:Ot,on:function(e,t){var n=this._,r=wc(e+"",n),s,i=-1,o=r.length;if(arguments.length<2){for(;++i<o;)if((s=(e=r[i]).type)&&(s=bc(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 Ot(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 bc(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]=yc,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 vc(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 Nc(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function Ws(e){var t=ln(e);return(t.local?Nc:vc)(t)}function _c(){}function lr(e){return e==null?_c:function(){return this.querySelector(e)}}function kc(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 Sc(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function Ec(){return[]}function Ks(e){return e==null?Ec:function(){return this.querySelectorAll(e)}}function jc(e){return function(){return Sc(e.apply(this,arguments))}}function Cc(e){typeof e=="function"?e=jc(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 $c=Array.prototype.find;function Mc(e){return function(){return $c.call(this.children,e)}}function zc(){return this.firstElementChild}function Ic(e){return this.select(e==null?zc:Mc(typeof e=="function"?e:Us(e)))}var Ac=Array.prototype.filter;function Pc(){return Array.from(this.children)}function Tc(e){return function(){return Ac.call(this.children,e)}}function Dc(e){return this.selectAll(e==null?Pc:Tc(typeof e=="function"?e:Us(e)))}function Rc(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 Lc(){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 Hc(e){return function(){return e}}function Fc(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 Vc(e,t){if(!arguments.length)return Array.from(this,Bc);var n=t?Oc:Fc,r=this._parents,s=this._groups;typeof e!="function"&&(e=Hc(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=qc(e.call(d,d&&d.__data__,u,r)),m=p.length,x=a[u]=new Array(m),v=o[u]=new Array(m),y=l[u]=new Array(h);n(d,f,x,v,y,p,t);for(var N=0,b=0,w,$;N<m;++N)if(w=x[N]){for(N>=b&&(b=N+1);!($=v[b])&&++b<m;);w._next=$||null}}return o=new ue(o,r),o._enter=a,o._exit=l,o}function qc(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function Xc(){return new ue(this._exit||this._groups.map(Zs),this._parents)}function Yc(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 Wc(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,m=0;m<f;++m)(p=u[m]||d[m])&&(h[m]=p);for(;l<s;++l)a[l]=n[l];return new ue(a,this._parents)}function Kc(){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 Gc(e){e||(e=Uc);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 Uc(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function Zc(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function Qc(){return Array.from(this)}function Jc(){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 el(){let e=0;for(const t of this)++e;return e}function tl(){return!this.node()}function nl(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 rl(e){return function(){this.removeAttribute(e)}}function sl(e){return function(){this.removeAttributeNS(e.space,e.local)}}function il(e,t){return function(){this.setAttribute(e,t)}}function ol(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function al(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function cl(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 ll(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?sl:rl:typeof t=="function"?n.local?cl:al:n.local?ol:il)(n,t))}function Qs(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function ul(e){return function(){this.style.removeProperty(e)}}function dl(e,t,n){return function(){this.style.setProperty(e,t,n)}}function fl(e,t,n){return function(){var r=t.apply(this,arguments);r==null?this.style.removeProperty(e):this.style.setProperty(e,r,n)}}function hl(e,t,n){return arguments.length>1?this.each((t==null?ul:typeof t=="function"?fl:dl)(e,t,n??"")):Ue(this.node(),e)}function Ue(e,t){return e.style.getPropertyValue(t)||Qs(e).getComputedStyle(e,null).getPropertyValue(t)}function pl(e){return function(){delete this[e]}}function gl(e,t){return function(){this[e]=t}}function ml(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function xl(e,t){return arguments.length>1?this.each((t==null?pl:typeof t=="function"?ml:gl)(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 yl(e){return function(){ti(this,e)}}function wl(e){return function(){ni(this,e)}}function bl(e,t){return function(){(t.apply(this,arguments)?ti:ni)(this,e)}}function vl(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"?bl:t?yl:wl)(n,t))}function Nl(){this.textContent=""}function _l(e){return function(){this.textContent=e}}function kl(e){return function(){var t=e.apply(this,arguments);this.textContent=t??""}}function Sl(e){return arguments.length?this.each(e==null?Nl:(typeof e=="function"?kl:_l)(e)):this.node().textContent}function El(){this.innerHTML=""}function jl(e){return function(){this.innerHTML=e}}function Cl(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??""}}function $l(e){return arguments.length?this.each(e==null?El:(typeof e=="function"?Cl:jl)(e)):this.node().innerHTML}function Ml(){this.nextSibling&&this.parentNode.appendChild(this)}function zl(){return this.each(Ml)}function Il(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function Al(){return this.each(Il)}function Pl(e){var t=typeof e=="function"?e:Ws(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function Tl(){return null}function Dl(e,t){var n=typeof e=="function"?e:Ws(e),r=t==null?Tl:typeof t=="function"?t:lr(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),r.apply(this,arguments)||null)})}function Rl(){var e=this.parentNode;e&&e.removeChild(this)}function Ll(){return this.each(Rl)}function Hl(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Fl(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Ol(e){return this.select(e?Fl:Hl)}function Bl(e){return arguments.length?this.property("__data__",e):this.node().__data__}function Vl(e){return function(t){e.call(this,t,this.__data__)}}function ql(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 Xl(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 Yl(e,t,n){return function(){var r=this.__on,s,i=Vl(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 Wl(e,t,n){var r=ql(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?Yl:Xl,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 Kl(e,t){return function(){return ri(this,e,t)}}function Gl(e,t){return function(){return ri(this,e,t.apply(this,arguments))}}function Ul(e,t){return this.each((typeof t=="function"?Gl:Kl)(e,t))}function*Zl(){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 Ql(){return this}ue.prototype=St.prototype={constructor:ue,select:kc,selectAll:Cc,selectChild:Ic,selectChildren:Dc,filter:Rc,data:Vc,enter:Lc,exit:Xc,join:Yc,merge:Wc,selection:Ql,order:Kc,sort:Gc,call:Zc,nodes:Qc,node:Jc,size:el,empty:tl,each:nl,attr:ll,style:hl,property:xl,classed:vl,text:Sl,html:$l,raise:zl,lower:Al,append:Pl,insert:Dl,remove:Ll,clone:Ol,datum:Bl,on:Wl,dispatch:Ul,[Symbol.iterator]:Zl};function le(e){return typeof e=="string"?new ue([[document.querySelector(e)]],[document.documentElement]):new ue([[e]],si)}function Jl(e){let t;for(;t=e.sourceEvent;)e=t;return e}function de(e,t){if(e=Jl(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 eu={passive:!1},gt={capture:!0,passive:!1};function zn(e){e.stopImmediatePropagation()}function We(e){e.preventDefault(),e.stopImmediatePropagation()}function ii(e){var t=e.document.documentElement,n=le(e).on("dragstart.drag",We,gt);"onselectstart"in t?n.on("selectstart.drag",We,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",We,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 tu(e){return!e.ctrlKey&&!e.button}function nu(){return this.parentNode}function ru(e,t){return t??{x:e.x,y:e.y}}function su(){return navigator.maxTouchPoints||"ontouchstart"in this}function ai(){var e=tu,t=nu,n=ru,r=su,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",v).on("touchmove.drag",y,eu).on("touchend.drag touchcancel.drag",N).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function p(w,$){if(!(d||!e.call(this,w,$))){var D=b(this,t.call(this,w,$),w,$,"mouse");D&&(le(w.view).on("mousemove.drag",m,gt).on("mouseup.drag",x,gt),ii(w.view),zn(w),u=!1,a=w.clientX,l=w.clientY,D("start",w))}}function m(w){if(We(w),!u){var $=w.clientX-a,D=w.clientY-l;u=$*$+D*D>f}s.mouse("drag",w)}function x(w){le(w.view).on("mousemove.drag mouseup.drag",null),oi(w.view,u),We(w),s.mouse("end",w)}function v(w,$){if(e.call(this,w,$)){var D=w.changedTouches,C=t.call(this,w,$),T=D.length,P,E;for(P=0;P<T;++P)(E=b(this,C,w,$,D[P].identifier,D[P]))&&(zn(w),E("start",w,D[P]))}}function y(w){var $=w.changedTouches,D=$.length,C,T;for(C=0;C<D;++C)(T=s[$[C].identifier])&&(We(w),T("drag",w,$[C]))}function N(w){var $=w.changedTouches,D=$.length,C,T;for(d&&clearTimeout(d),d=setTimeout(function(){d=null},500),C=0;C<D;++C)(T=s[$[C].identifier])&&(zn(w),T("end",w,$[C]))}function b(w,$,D,C,T,P){var E=i.copy(),O=de(P||D,$),L,A,g;if((g=n.call(w,new Xn("beforestart",{sourceEvent:D,target:h,identifier:T,active:o,x:O[0],y:O[1],dx:0,dy:0,dispatch:E}),C))!=null)return L=g.x-O[0]||0,A=g.y-O[1]||0,function S(_,z,k){var j=O,I;switch(_){case"start":s[T]=S,I=o++;break;case"end":delete s[T],--o;case"drag":O=de(k||z,$),I=o;break}E.call(_,w,new Xn(_,{sourceEvent:z,subject:g,target:h,identifier:T,active:I,x:O[0]+L,y:O[1]+A,dx:O[0]-j[0],dy:O[1]-j[1],dispatch:E}),C)}}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,Ke="\\s*([+-]?\\d+)\\s*",xt="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",ge="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",iu=/^#([0-9a-f]{3,8})$/,ou=new RegExp(`^rgb\\(${Ke},${Ke},${Ke}\\)$`),au=new RegExp(`^rgb\\(${ge},${ge},${ge}\\)$`),cu=new RegExp(`^rgba\\(${Ke},${Ke},${Ke},${xt}\\)$`),lu=new RegExp(`^rgba\\(${ge},${ge},${ge},${xt}\\)$`),uu=new RegExp(`^hsl\\(${xt},${ge},${ge}\\)$`),du=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:fu,formatHsl:hu,formatRgb:Fr,toString:Fr});function Hr(){return this.rgb().formatHex()}function fu(){return this.rgb().formatHex8()}function hu(){return li(this).formatHsl()}function Fr(){return this.rgb().formatRgb()}function yt(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=iu.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?Or(t):n===3?new ce(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=ou.exec(e))?new ce(t[1],t[2],t[3],1):(t=au.exec(e))?new ce(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=cu.exec(e))?It(t[1],t[2],t[3],t[4]):(t=lu.exec(e))?It(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=uu.exec(e))?qr(t[1],t[2]/100,t[3]/100,1):(t=du.exec(e))?qr(t[1],t[2]/100,t[3]/100,t[4]):Lr.hasOwnProperty(e)?Or(Lr[e]):e==="transparent"?new ce(NaN,NaN,NaN,0):null}function Or(e){return new ce(e>>16&255,e>>8&255,e&255,1)}function It(e,t,n,r){return r<=0&&(e=t=n=NaN),new ce(e,t,n,r)}function pu(e){return e instanceof Et||(e=yt(e)),e?(e=e.rgb(),new ce(e.r,e.g,e.b,e.opacity)):new ce}function Yn(e,t,n,r){return arguments.length===1?pu(e):new ce(e,t,n,r??1)}function ce(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}dr(ce,Yn,ci(Et,{brighter(e){return e=e==null?Ut:Math.pow(Ut,e),new ce(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?mt:Math.pow(mt,e),new ce(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new ce(Le(this.r),Le(this.g),Le(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:Br,formatHex:Br,formatHex8:gu,formatRgb:Vr,toString:Vr}));function Br(){return`#${Re(this.r)}${Re(this.g)}${Re(this.b)}`}function gu(){return`#${Re(this.r)}${Re(this.g)}${Re(this.b)}${Re((isNaN(this.opacity)?1:this.opacity)*255)}`}function Vr(){const e=Zt(this.opacity);return`${e===1?"rgb(":"rgba("}${Le(this.r)}, ${Le(this.g)}, ${Le(this.b)}${e===1?")":`, ${e})`}`}function Zt(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function Le(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function Re(e){return e=Le(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 mu(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,mu,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 ce(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 xu(e,t){return function(n){return e+n*t}}function yu(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 wu(e){return(e=+e)==1?di:function(t,n){return n-t?yu(t,n,e):ui(isNaN(t)?n:t)}}function di(e,t){var n=t-e;return n?xu(e,n):ui(isNaN(e)?t:e)}const Yr=function e(t){var n=wu(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 ze(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 bu(e){return function(){return e}}function vu(e){return function(t){return e(t)+""}}function Nu(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:ze(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]?vu(l[0].x):bu(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 _u(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 ku(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,m){if(u!==f||d!==h){var x=p.push("translate(",null,t,null,n);m.push({i:x-4,x:ze(u,f)},{i:x-2,x:ze(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:ze(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:ze(u,d)}):d&&f.push(s(f)+"skewX("+d+r)}function l(u,d,f,h,p,m){if(u!==f||d!==h){var x=p.push(s(p)+"scale(",null,",",null,")");m.push({i:x-4,x:ze(u,f)},{i:x-2,x:ze(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 m=-1,x=h.length,v;++m<x;)f[(v=h[m]).i]=v.x(p);return f.join("")}}}var Su=hi(_u,"px, ","px)","deg)"),Eu=hi(ku,", ",")",")"),ju=1e-12;function Kr(e){return((e=Math.exp(e))+1/e)/2}function Cu(e){return((e=Math.exp(e))-1/e)/2}function $u(e){return((e=Math.exp(2*e))-1)/(e+1)}const Mu=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,m=f-l,x=p*p+m*m,v,y;if(x<ju)y=Math.log(h/u)/t,v=function(C){return[a+C*p,l+C*m,u*Math.exp(t*C*y)]};else{var N=Math.sqrt(x),b=(h*h-u*u+r*x)/(2*u*n*N),w=(h*h-u*u-r*x)/(2*h*n*N),$=Math.log(Math.sqrt(b*b+1)-b),D=Math.log(Math.sqrt(w*w+1)-w);y=(D-$)/t,v=function(C){var T=C*y,P=Kr($),E=u/(n*N)*(P*$u(t*T+$)-Cu($));return[a+E*p,l+E*m,u*P/Kr(t*T+$)]}}return v.duration=y*1e3*t/Math.SQRT2,v}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,Fe=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 Fe||(gi(zu),Fe=wt.now()+un)}function zu(){Fe=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 Iu(){fr(),++Ze;for(var e=Qt,t;e;)(t=Fe-e._time)>=0&&e._call.call(void 0,t),e=e._next;--Ze}function Gr(){Fe=(Jt=wt.now())+un,Ze=dt=0;try{Iu()}finally{Ze=0,Pu(),Fe=0}}function Au(){var e=wt.now(),t=e-Jt;t>pi&&(un-=t,Jt=e)}function Pu(){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-Fe;t>24?(e<1/0&&(dt=setTimeout(Gr,e-wt.now()-un)),ct&&(ct=clearInterval(ct))):(ct||(Jt=wt.now(),ct=setInterval(Au,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 Tu=cn("start","end","cancel","interrupt"),Du=[],xi=0,Zr=1,Un=2,Bt=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;Ru(e,n,{name:t,index:r,group:s,on:Tu,tween:Du,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>Bt)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 Ru(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===Bt)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===Bt&&(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=Bt,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 Lu(e){return this.each(function(){qt(this,e)})}function Hu(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 Fu(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?Hu:Fu)(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"?ze:t instanceof yt?Yr:(n=yt(t))?(t=n,Yr):Nu)(e,t)}function Bu(e){return function(){this.removeAttribute(e)}}function Vu(e){return function(){this.removeAttributeNS(e.space,e.local)}}function qu(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 Xu(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 Yu(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 Wu(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 Ku(e,t){var n=ln(e),r=n==="transform"?Eu:yi;return this.attrTween(e,typeof t=="function"?(n.local?Wu:Yu)(n,r,pr(this,"attr."+e,t)):t==null?(n.local?Vu:Bu)(n):(n.local?Xu:qu)(n,r,t))}function Gu(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function Uu(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function Zu(e,t){var n,r;function s(){var i=t.apply(this,arguments);return i!==r&&(n=(r=i)&&Uu(e,i)),n}return s._value=t,s}function Qu(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 Ju(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?Zu:Qu)(r,t))}function ed(e,t){return function(){hr(this,e).delay=+t.apply(this,arguments)}}function td(e,t){return t=+t,function(){hr(this,e).delay=t}}function nd(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?ed:td)(t,e)):pe(this.node(),t).delay}function rd(e,t){return function(){me(this,e).duration=+t.apply(this,arguments)}}function sd(e,t){return t=+t,function(){me(this,e).duration=t}}function id(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?rd:sd)(t,e)):pe(this.node(),t).duration}function od(e,t){if(typeof t!="function")throw new Error;return function(){me(this,e).ease=t}}function ad(e){var t=this._id;return arguments.length?this.each(od(t,e)):pe(this.node(),t).ease}function cd(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!="function")throw new Error;me(this,e).ease=n}}function ld(e){if(typeof e!="function")throw new Error;return this.each(cd(this._id,e))}function ud(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 ke(r,this._parents,this._name,this._id)}function dd(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 ke(o,this._parents,this._name,this._id)}function fd(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 hd(e,t,n){var r,s,i=fd(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 pd(e,t){var n=this._id;return arguments.length<2?pe(this.node(),n).on.on(e):this.each(hd(n,e,t))}function gd(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function md(){return this.on("end.remove",gd(this._id))}function xd(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 ke(i,this._parents,t,n)}function yd(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,m=pe(d,n),x=0,v=h.length;x<v;++x)(p=h[x])&&dn(p,t,n,x,h,m);i.push(h),o.push(d)}return new ke(i,o,t,n)}var wd=St.prototype.constructor;function bd(){return new wd(this._groups,this._parents)}function vd(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 Nd(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 _d(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 kd(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 Sd(e,t,n){var r=(e+="")=="transform"?Su:yi;return t==null?this.styleTween(e,vd(e,r)).on("end.style."+e,wi(e)):typeof t=="function"?this.styleTween(e,_d(e,r,pr(this,"style."+e,t))).each(kd(this._id,e)):this.styleTween(e,Nd(e,r,t),n).on("end.style."+e,null)}function Ed(e,t,n){return function(r){this.style.setProperty(e,t.call(this,r),n)}}function jd(e,t,n){var r,s;function i(){var o=t.apply(this,arguments);return o!==s&&(r=(s=o)&&Ed(e,o,n)),r}return i._value=t,i}function Cd(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,jd(e,t,n??""))}function $d(e){return function(){this.textContent=e}}function Md(e){return function(){var t=e(this);this.textContent=t??""}}function zd(e){return this.tween("text",typeof e=="function"?Md(pr(this,"text",e)):$d(e==null?"":e+""))}function Id(e){return function(t){this.textContent=e.call(this,t)}}function Ad(e){var t,n;function r(){var s=e.apply(this,arguments);return s!==n&&(t=(n=s)&&Id(s)),t}return r._value=e,r}function Pd(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,Ad(e))}function Td(){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 ke(r,this._parents,e,n)}function Dd(){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 Rd=0;function ke(e,t,n,r){this._groups=e,this._parents=t,this._name=n,this._id=r}function bi(){return++Rd}var xe=St.prototype;ke.prototype={constructor:ke,select:xd,selectAll:yd,selectChild:xe.selectChild,selectChildren:xe.selectChildren,filter:ud,merge:dd,selection:bd,transition:Td,call:xe.call,nodes:xe.nodes,node:xe.node,size:xe.size,empty:xe.empty,each:xe.each,on:pd,attr:Ku,attrTween:Ju,style:Sd,styleTween:Cd,text:zd,textTween:Pd,remove:md,tween:Ou,delay:nd,duration:id,ease:ad,easeVarying:ld,end:Dd,[Symbol.iterator]:xe[Symbol.iterator]};function Ld(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var Hd={time:null,delay:0,duration:250,ease:Ld};function Fd(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 ke?(t=e._id,e=e._name):(t=bi(),(n=Hd).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||Fd(l,t));return new ke(r,this._parents,e,t)}St.prototype.interrupt=Lu;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 be(e,t,n){this.k=e,this.x=t,this.y=n}be.prototype={constructor:be,scale:function(e){return e===1?this:new be(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new be(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 be(1,0,0);vi.prototype=be.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 Vd(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function qd(){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 Xd(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function Yd(){return navigator.maxTouchPoints||"ontouchstart"in this}function Wd(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=Vd,t=qd,n=Wd,r=Xd,s=Yd,i=[0,1/0],o=[[-1/0,-1/0],[1/0,1/0]],a=250,l=Mu,u=cn("start","zoom","end"),d,f,h,p=500,m=150,x=0,v=10;function y(g){g.property("__zoom",Jr).on("wheel.zoom",T,{passive:!1}).on("mousedown.zoom",P).on("dblclick.zoom",E).filter(s).on("touchstart.zoom",O).on("touchmove.zoom",L).on("touchend.zoom touchcancel.zoom",A).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}y.transform=function(g,S,_,z){var k=g.selection?g.selection():g;k.property("__zoom",Jr),g!==k?$(g,S,_,z):k.interrupt().each(function(){D(this,arguments).event(z).start().zoom(null,typeof S=="function"?S.apply(this,arguments):S).end()})},y.scaleBy=function(g,S,_,z){y.scaleTo(g,function(){var k=this.__zoom.k,j=typeof S=="function"?S.apply(this,arguments):S;return k*j},_,z)},y.scaleTo=function(g,S,_,z){y.transform(g,function(){var k=t.apply(this,arguments),j=this.__zoom,I=_==null?w(k):typeof _=="function"?_.apply(this,arguments):_,H=j.invert(I),B=typeof S=="function"?S.apply(this,arguments):S;return n(b(N(j,B),I,H),k,o)},_,z)},y.translateBy=function(g,S,_,z){y.transform(g,function(){return n(this.__zoom.translate(typeof S=="function"?S.apply(this,arguments):S,typeof _=="function"?_.apply(this,arguments):_),t.apply(this,arguments),o)},null,z)},y.translateTo=function(g,S,_,z,k){y.transform(g,function(){var j=t.apply(this,arguments),I=this.__zoom,H=z==null?w(j):typeof z=="function"?z.apply(this,arguments):z;return n(fn.translate(H[0],H[1]).scale(I.k).translate(typeof S=="function"?-S.apply(this,arguments):-S,typeof _=="function"?-_.apply(this,arguments):-_),j,o)},z,k)};function N(g,S){return S=Math.max(i[0],Math.min(i[1],S)),S===g.k?g:new be(S,g.x,g.y)}function b(g,S,_){var z=S[0]-_[0]*g.k,k=S[1]-_[1]*g.k;return z===g.x&&k===g.y?g:new be(g.k,z,k)}function w(g){return[(+g[0][0]+ +g[1][0])/2,(+g[0][1]+ +g[1][1])/2]}function $(g,S,_,z){g.on("start.zoom",function(){D(this,arguments).event(z).start()}).on("interrupt.zoom end.zoom",function(){D(this,arguments).event(z).end()}).tween("zoom",function(){var k=this,j=arguments,I=D(k,j).event(z),H=t.apply(k,j),B=_==null?w(H):typeof _=="function"?_.apply(k,j):_,Y=Math.max(H[1][0]-H[0][0],H[1][1]-H[0][1]),X=k.__zoom,V=typeof S=="function"?S.apply(k,j):S,R=l(X.invert(B).concat(Y/X.k),V.invert(B).concat(Y/V.k));return function(q){if(q===1)q=V;else{var F=R(q),W=Y/F[2];q=new be(W,B[0]-F[0]*W,B[1]-F[1]*W)}I.zoom(null,q)}})}function D(g,S,_){return!_&&g.__zooming||new C(g,S)}function C(g,S){this.that=g,this.args=S,this.active=0,this.sourceEvent=null,this.extent=t.apply(g,S),this.taps=0}C.prototype={event:function(g){return g&&(this.sourceEvent=g),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(g,S){return this.mouse&&g!=="mouse"&&(this.mouse[1]=S.invert(this.mouse[0])),this.touch0&&g!=="touch"&&(this.touch0[1]=S.invert(this.touch0[0])),this.touch1&&g!=="touch"&&(this.touch1[1]=S.invert(this.touch1[0])),this.that.__zoom=S,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(g){var S=le(this.that).datum();u.call(g,this.that,new Bd(g,{sourceEvent:this.sourceEvent,target:y,transform:this.that.__zoom,dispatch:u}),S)}};function T(g,...S){if(!e.apply(this,arguments))return;var _=D(this,S).event(g),z=this.__zoom,k=Math.max(i[0],Math.min(i[1],z.k*Math.pow(2,r.apply(this,arguments)))),j=de(g);if(_.wheel)(_.mouse[0][0]!==j[0]||_.mouse[0][1]!==j[1])&&(_.mouse[1]=z.invert(_.mouse[0]=j)),clearTimeout(_.wheel);else{if(z.k===k)return;_.mouse=[j,z.invert(j)],qt(this),_.start()}lt(g),_.wheel=setTimeout(I,m),_.zoom("mouse",n(b(N(z,k),_.mouse[0],_.mouse[1]),_.extent,o));function I(){_.wheel=null,_.end()}}function P(g,...S){if(h||!e.apply(this,arguments))return;var _=g.currentTarget,z=D(this,S,!0).event(g),k=le(g.view).on("mousemove.zoom",B,!0).on("mouseup.zoom",Y,!0),j=de(g,_),I=g.clientX,H=g.clientY;ii(g.view),Pn(g),z.mouse=[j,this.__zoom.invert(j)],qt(this),z.start();function B(X){if(lt(X),!z.moved){var V=X.clientX-I,R=X.clientY-H;z.moved=V*V+R*R>x}z.event(X).zoom("mouse",n(b(z.that.__zoom,z.mouse[0]=de(X,_),z.mouse[1]),z.extent,o))}function Y(X){k.on("mousemove.zoom mouseup.zoom",null),oi(X.view,z.moved),lt(X),z.event(X).end()}}function E(g,...S){if(e.apply(this,arguments)){var _=this.__zoom,z=de(g.changedTouches?g.changedTouches[0]:g,this),k=_.invert(z),j=_.k*(g.shiftKey?.5:2),I=n(b(N(_,j),z,k),t.apply(this,S),o);lt(g),a>0?le(this).transition().duration(a).call($,I,z,g):le(this).call(y.transform,I,z,g)}}function O(g,...S){if(e.apply(this,arguments)){var _=g.touches,z=_.length,k=D(this,S,g.changedTouches.length===z).event(g),j,I,H,B;for(Pn(g),I=0;I<z;++I)H=_[I],B=de(H,this),B=[B,this.__zoom.invert(B),H.identifier],k.touch0?!k.touch1&&k.touch0[2]!==B[2]&&(k.touch1=B,k.taps=0):(k.touch0=B,j=!0,k.taps=1+!!d);d&&(d=clearTimeout(d)),j&&(k.taps<2&&(f=B[0],d=setTimeout(function(){d=null},p)),qt(this),k.start())}}function L(g,...S){if(this.__zooming){var _=D(this,S).event(g),z=g.changedTouches,k=z.length,j,I,H,B;for(lt(g),j=0;j<k;++j)I=z[j],H=de(I,this),_.touch0&&_.touch0[2]===I.identifier?_.touch0[0]=H:_.touch1&&_.touch1[2]===I.identifier&&(_.touch1[0]=H);if(I=_.that.__zoom,_.touch1){var Y=_.touch0[0],X=_.touch0[1],V=_.touch1[0],R=_.touch1[1],q=(q=V[0]-Y[0])*q+(q=V[1]-Y[1])*q,F=(F=R[0]-X[0])*F+(F=R[1]-X[1])*F;I=N(I,Math.sqrt(q/F)),H=[(Y[0]+V[0])/2,(Y[1]+V[1])/2],B=[(X[0]+R[0])/2,(X[1]+R[1])/2]}else if(_.touch0)H=_.touch0[0],B=_.touch0[1];else return;_.zoom("touch",n(b(I,H,B),_.extent,o))}}function A(g,...S){if(this.__zooming){var _=D(this,S).event(g),z=g.changedTouches,k=z.length,j,I;for(Pn(g),h&&clearTimeout(h),h=setTimeout(function(){h=null},p),j=0;j<k;++j)I=z[j],_.touch0&&_.touch0[2]===I.identifier?delete _.touch0:_.touch1&&_.touch1[2]===I.identifier&&delete _.touch1;if(_.touch1&&!_.touch0&&(_.touch0=_.touch1,delete _.touch1),_.touch0)_.touch0[1]=this.__zoom.invert(_.touch0[0]);else if(_.end(),_.taps===2&&(I=de(I,this),Math.hypot(f[0]-I[0],f[1]-I[1])<v)){var H=le(this).on("dblclick.zoom");H&&H.apply(this,arguments)}}}return y.wheelDelta=function(g){return arguments.length?(r=typeof g=="function"?g:Tt(+g),y):r},y.filter=function(g){return arguments.length?(e=typeof g=="function"?g:Tt(!!g),y):e},y.touchable=function(g){return arguments.length?(s=typeof g=="function"?g:Tt(!!g),y):s},y.extent=function(g){return arguments.length?(t=typeof g=="function"?g:Tt([[+g[0][0],+g[0][1]],[+g[1][0],+g[1][1]]]),y):t},y.scaleExtent=function(g){return arguments.length?(i[0]=+g[0],i[1]=+g[1],y):[i[0],i[1]]},y.translateExtent=function(g){return arguments.length?(o[0][0]=+g[0][0],o[1][0]=+g[1][0],o[0][1]=+g[0][1],o[1][1]=+g[1][1],y):[[o[0][0],o[0][1]],[o[1][0],o[1][1]]]},y.constrain=function(g){return arguments.length?(n=g,y):n},y.duration=function(g){return arguments.length?(a=+g,y):a},y.interpolate=function(g){return arguments.length?(l=g,y):l},y.on=function(){var g=u.on.apply(u,arguments);return g===u?y:g},y.clickDistance=function(g){return arguments.length?(x=(g=+g)*g,y):Math.sqrt(x)},y.tapDistance=function(g){return arguments.length?(v=+g,y):v},y}const Se={error001:()=>"[React Flow]: Seems like you have not used zustand provider as an ancestor. Help: https://reactflow.dev/error#001",error002:()=>"It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.",error003:e=>`Node type "${e}" not found. Using fallback type "default".`,error004:()=>"The React Flow parent container needs a width and a height to render the graph.",error005:()=>"Only child nodes can use a parent extent.",error006:()=>"Can't create edge. An edge needs a source and a target.",error007:e=>`The old edge with id=${e} does not exist.`,error009:e=>`Marker type "${e}" doesn't exist.`,error008:(e,{id:t,sourceHandle:n,targetHandle:r})=>`Couldn't create edge for ${e} handle id: "${e==="source"?n:r}", edge id: ${t}.`,error010:()=>"Handle: No node id found. Make sure to only use a Handle inside a custom Node.",error011:e=>`Edge type "${e}" not found. Using fallback type "default".`,error012:e=>`Node with id "${e}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`,error013:(e="react")=>`It seems that you haven't loaded the styles. Please import '@xyflow/${e}/dist/style.css' or base.css to make sure everything is working properly.`},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 He;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(He||(He={}));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 Ie;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(Ie||(Ie={}));var tn;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(tn||(tn={}));var K;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(K||(K={}));const es={[K.Left]:K.Right,[K.Right]:K.Left,[K.Top]:K.Bottom,[K.Bottom]:K.Top};function Si(e){return e===null?null:e?"valid":"invalid"}const Ei=e=>"id"in e&&"source"in e&&"target"in e,Kd=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}=Ee(e),s=e.origin??t,i=n*s[0],o=r*s[1];return{x:e.position.x-i,y:e.position.y-o}},Gd=(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,m=d.height??u.height??u.initialHeight??null,x=Nt(a,et(u)),v=(p??0)*(m??0),y=i&&x>0;(!u.internals.handleBounds||y||x>=v||u.dragging)&&l.push(u)}return l},Ud=(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",Se.error005());else{const p=a.measured.width,m=a.measured.height;p&&m&&(f=[[l,u],[l+p,u+m]])}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 Zd({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),m=!p&&h.parentId&&o.find(x=>x.id===h.parentId);(p||m)&&o.push(h)}const a=new Set(t.map(h=>h.id)),l=r.filter(h=>h.deletable!==!1),d=Ud(o,l);for(const h of l)a.has(h.id)&&!d.find(m=>m.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}=Ee(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),Qd=(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 Ee(e){var t,n;return{width:((t=e.measured)==null?void 0:t.width)??e.width??e.initialWidth??0,height:((n=e.measured)==null?void 0:n.height)??e.height??e.initialHeight??0}}function 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}=ve(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)},Jd=["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 Jd.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,ve=(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 K.Left:return[t-Dt(t-r,i),n];case K.Right:return[t+Dt(r-t,i),n];case K.Top:return[t,n-Dt(n-s,i)];case K.Bottom:return[t,n+Dt(s-n,i)]}}function Li({sourceX:e,sourceY:t,sourcePosition:n=K.Bottom,targetX:r,targetY:s,targetPosition:i=K.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,m]=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,m]}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 ef({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 tf({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 nf=({source:e,sourceHandle:t,target:n,targetHandle:r})=>`xy-edge__${e}${t||""}-${n}${r||""}`,rf=(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)),sf=(e,t)=>{if(!e.source||!e.target)return t;let n;return Ei(e)?n={...e}:n={...e,id:nf(e)},rf(n,t)?t:(n.sourceHandle===null&&delete n.sourceHandle,n.targetHandle===null&&delete n.targetHandle,t.concat(n))};function Fi({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={[K.Left]:{x:-1,y:0},[K.Right]:{x:1,y:0},[K.Top]:{x:0,y:-1},[K.Bottom]:{x:0,y:1}},of=({source:e,sourcePosition:t=K.Bottom,target:n})=>t===K.Left||t===K.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 af({source:e,sourcePosition:t=K.Bottom,target:n,targetPosition:r=K.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=of({source:l,sourcePosition:t,target:u}),f=d.x!==0?"x":"y",h=d[f];let p=[],m,x;const v={x:0,y:0},y={x:0,y:0},[N,b,w,$]=Hi({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(o[f]*a[f]===-1){m=s.x??N,x=s.y??b;const C=[{x:m,y:l.y},{x:m,y:u.y}],T=[{x:l.x,y:x},{x:u.x,y:x}];o[f]===h?p=f==="x"?C:T:p=f==="x"?T:C}else{const C=[{x:l.x,y:u.y}],T=[{x:u.x,y:l.y}];if(f==="x"?p=o.x===h?T:C:p=o.y===h?C:T,t===r){const A=Math.abs(e[f]-n[f]);if(A<=i){const g=Math.min(i-1,i-A);o[f]===h?v[f]=(l[f]>e[f]?-1:1)*g:y[f]=(u[f]>n[f]?-1:1)*g}}if(t!==r){const A=f==="x"?"y":"x",g=o[f]===a[A],S=l[A]>u[A],_=l[A]<u[A];(o[f]===1&&(!g&&S||g&&_)||o[f]!==1&&(!g&&_||g&&S))&&(p=f==="x"?C:T)}const P={x:l.x+v.x,y:l.y+v.y},E={x:u.x+y.x,y:u.y+y.y},O=Math.max(Math.abs(P.x-p[0].x),Math.abs(E.x-p[0].x)),L=Math.max(Math.abs(P.y-p[0].y),Math.abs(E.y-p[0].y));O>=L?(m=(P.x+E.x)/2,x=p[0].y):(m=p[0].x,x=(P.y+E.y)/2)}return[[e,{x:l.x+v.x,y:l.y+v.y},...p,{x:u.x+y.x,y:u.y+y.y},n],m,x,w,$]}function cf(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=K.Bottom,targetX:r,targetY:s,targetPosition:i=K.Top,borderRadius:o=5,centerX:a,centerY:l,offset:u=20}){const[d,f,h,p,m]=af({source:{x:e,y:t},sourcePosition:n,target:{x:r,y:s},targetPosition:i,center:{x:a,y:l},offset:u});return[d.reduce((v,y,N)=>{let b="";return N>0&&N<d.length-1?b=cf(d[N-1],y,d[N+1],o):b=`${N===0?"M":"L"}${y.x} ${y.y}`,v+=b,v},""),f,h,p,m]}function as(e){var t;return e&&!!(e.internals.handleBounds||(t=e.handles)!=null&&t.length)&&!!(e.measured.width||e.width||e.initialWidth)}function lf(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",Se.error008(i?"target":"source",{id:e.id,sourceHandle:e.sourceHandle,targetHandle:e.targetHandle})),null;const a=(i==null?void 0:i.position)||K.Bottom,l=(o==null?void 0:o.position)||K.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=K.Left,r=!1){const s=((t==null?void 0:t.x)??0)+e.internals.positionAbsolute.x,i=((t==null?void 0:t.y)??0)+e.internals.positionAbsolute.y,{width:o,height:a}=t??Ee(e);if(r)return{x:s+o/2,y:i+a/2};switch((t==null?void 0:t.position)??n){case K.Top:return{x:s+o/2,y:i};case K.Right:return{x:s+o,y:i+a/2};case K.Bottom:return{x:s+o/2,y:i+a};case K.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 uf(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:{}},df={...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 ff(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,Ee(s));s.internals.positionAbsolute=a}}function sr(e,t,n,r){var a,l;const s=yr(df,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,Ee(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:Oi(u,o),userNode:u}},t.set(u.id,d)}u.parentId&&wr(d,t,n,r)}}function hf(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}hf(e,n);const u=s?1e3:0,{x:d,y:f,z:h}=pf(e,l,i,o,u),{positionAbsolute:p}=e.internals,m=d!==p.x||f!==p.y;(m||h!==e.internals.z)&&(e.internals={...e.internals,positionAbsolute:m?{x:d,y:f}:p,z:h})}function Oi(e,t){return(he(e.zIndex)?e.zIndex:0)+(e.selected?t:0)}function pf(e,t,n,r,s){const{x:i,y:o}=t.internals.positionAbsolute,a=Ee(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=Oi(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 b;const d=l.internals.positionAbsolute,f=Ee(l),h=l.origin??r,p=a.x<d.x?Math.round(Math.abs(d.x-a.x)):0,m=a.y<d.y?Math.round(Math.abs(d.y-a.y)):0,x=Math.max(f.width,Math.round(a.width)),v=Math.max(f.height,Math.round(a.height)),y=(x-f.width)*h[0],N=(v-f.height)*h[1];(p>0||m>0||y||N)&&(s.push({id:u,type:"position",position:{x:l.position.x-p+y,y:l.position.y-m+N}}),(b=n.get(u))==null||b.forEach(w=>{e.some($=>$.id===w.id)||s.push({id:w.id,type:"position",position:{x:w.position.x+p,y:w.position.y+m}})})),(f.width<a.width||f.height<a.height||p||m)&&s.push({id:u,type:"dimensions",setAttributes:!0,dimensions:{width:x+(p?h[0]*p-y:0),height:v+(m?h[1]*m-N:0)}})}),s}function gf(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 m=mn(h.nodeElement),x=p.measured.width!==m.width||p.measured.height!==m.height;if(!!(m.width&&m.height&&(x||!p.internals.handleBounds||h.force))){const y=h.nodeElement.getBoundingClientRect(),N=tt(p.extent)?p.extent:i;let{positionAbsolute:b}=p.internals;p.parentId&&p.extent==="parent"?b=$i(b,m,t.get(p.parentId)):N&&(b=Oe(b,N,m)),p.measured=m,p.internals={...p.internals,positionAbsolute:b,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:m}),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 mf({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 Bi(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 xf(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 yf({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 m({noDragClassName:v,handleSelector:y,domNode:N,isSelectable:b,nodeId:w,nodeClickDistance:$=0}){h=le(N);function D({x:E,y:O},L){const{nodeLookup:A,nodeExtent:g,snapGrid:S,snapToGrid:_,nodeOrigin:z,onNodeDrag:k,onSelectionDrag:j,onError:I,updateNodePositions:H}=t();i={x:E,y:O};let B=!1,Y={x:0,y:0,x2:0,y2:0};if(a.size>1&&g){const X=Ct(a);Y=er(X)}for(const[X,V]of a){if(!A.has(X))continue;let R={x:E-V.distance.x,y:O-V.distance.y};_&&(R=gn(R,S));let q=[[g[0][0],g[0][1]],[g[1][0],g[1][1]]];if(a.size>1&&g&&!V.extent){const{positionAbsolute:U}=V.internals,Z=U.x-Y.x+g[0][0],G=U.x+V.measured.width-Y.x2+g[1][0],J=U.y-Y.y+g[0][1],ee=U.y+V.measured.height-Y.y2+g[1][1];q=[[Z,J],[G,ee]]}const{position:F,positionAbsolute:W}=Ci({nodeId:X,nextPosition:R,nodeLookup:A,nodeExtent:q,nodeOrigin:z,onError:I});B=B||V.position.x!==F.x||V.position.y!==F.y,V.position=F,V.internals.positionAbsolute=W}if(B&&(H(a,!0),L&&(r||k||!w&&j))){const[X,V]=Tn({nodeId:w,dragItems:a,nodeLookup:A});r==null||r(L,a,X,V),k==null||k(L,X,V),w||j==null||j(L,V)}}async function C(){if(!d)return;const{transform:E,panBy:O,autoPanSpeed:L}=t(),[A,g]=Mi(u,d,L);(A!==0||g!==0)&&(i.x=(i.x??0)-A/E[2],i.y=(i.y??0)-g/E[2],await O({x:A,y:g})&&D(i,null)),o=requestAnimationFrame(C)}function T(E){var B;const{nodeLookup:O,multiSelectionActive:L,nodesDraggable:A,transform:g,snapGrid:S,snapToGrid:_,selectNodesOnDrag:z,onNodeDragStart:k,onSelectionDragStart:j,unselectNodesAndEdges:I}=t();f=!0,(!z||!b)&&!L&&w&&((B=O.get(w))!=null&&B.selected||I()),b&&z&&w&&(e==null||e(w));const H=ht(E.sourceEvent,{transform:g,snapGrid:S,snapToGrid:_,containerBounds:d});if(i=H,a=xf(O,A,H,w),a.size>0&&(n||k||!w&&j)){const[Y,X]=Tn({nodeId:w,dragItems:a,nodeLookup:O});n==null||n(E.sourceEvent,a,Y,X),k==null||k(E.sourceEvent,Y,X),w||j==null||j(E.sourceEvent,X)}}const P=ai().clickDistance($).on("start",E=>{const{domNode:O,nodeDragThreshold:L,transform:A,snapGrid:g,snapToGrid:S}=t();d=(O==null?void 0:O.getBoundingClientRect())||null,p=!1,L===0&&T(E),i=ht(E.sourceEvent,{transform:A,snapGrid:g,snapToGrid:S,containerBounds:d}),u=ve(E.sourceEvent,d)}).on("drag",E=>{const{autoPanOnNodeDrag:O,transform:L,snapGrid:A,snapToGrid:g,nodeDragThreshold:S,nodeLookup:_}=t(),z=ht(E.sourceEvent,{transform:L,snapGrid:A,snapToGrid:g,containerBounds:d});if((E.sourceEvent.type==="touchmove"&&E.sourceEvent.touches.length>1||w&&!_.has(w))&&(p=!0),!p){if(!l&&O&&f&&(l=!0,C()),!f){const k=z.xSnapped-(i.x??0),j=z.ySnapped-(i.y??0);Math.sqrt(k*k+j*j)>S&&T(E)}(i.x!==z.xSnapped||i.y!==z.ySnapped)&&a&&f&&(u=ve(E.sourceEvent,d),D(z,E.sourceEvent))}}).on("end",E=>{if(!(!f||p)&&(l=!1,f=!1,cancelAnimationFrame(o),a.size>0)){const{nodeLookup:O,updateNodePositions:L,onNodeDragStop:A,onSelectionDragStop:g}=t();if(L(a,!1),s||A||!w&&g){const[S,_]=Tn({nodeId:w,dragItems:a,nodeLookup:O,dragging:!1});s==null||s(E.sourceEvent,a,S,_),A==null||A(E.sourceEvent,S,_),w||g==null||g(E.sourceEvent,_)}}}).filter(E=>{const O=E.target;return!E.button&&(!v||!us(O,`.${v}`,N))&&(!y||us(O,y,N))});h.call(P)}function x(){h==null||h.on(".drag",null)}return{update:m,destroy:x}}function wf(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 bf=250;function vf(e,t,n,r){var a,l;let s=[],i=1/0;const o=wf(e,n,t+bf);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),m=Math.sqrt(Math.pow(h-e.x,2)+Math.pow(p-e.y,2));m>t||(m<i?(s=[{...f,x:h,y:p}],i=m):m===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 Nf(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}const Yi=()=>!0;function _f(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:m,onConnect:x,onConnectEnd:v,isValidConnection:y=Yi,onReconnectEnd:N,updateConnection:b,getTransform:w,getFromHandle:$,autoPanSpeed:D}){const C=Ti(e.target);let T=0,P;const{x:E,y:O}=ve(e),L=C==null?void 0:C.elementFromPoint(E,O),A=Xi(i,L),g=a==null?void 0:a.getBoundingClientRect();if(!g||!A)return;const S=qi(s,A,r,l,t);if(!S)return;let _=ve(e,g),z=!1,k=null,j=!1,I=null;function H(){if(!d||!g)return;const[W,U]=Mi(_,g,D);h({x:W,y:U}),T=requestAnimationFrame(H)}const B={...S,nodeId:s,type:A,position:S.position},Y=l.get(s),V={inProgress:!0,isValid:null,from:_t(Y,B,K.Left,!0),fromHandle:B,fromPosition:B.position,fromNode:Y,to:_,toHandle:null,toPosition:es[B.position],toNode:null};b(V);let R=V;m==null||m(e,{nodeId:s,handleId:r,handleType:A});function q(W){if(!$()||!B){F(W);return}const U=w();_=ve(W,g),P=vf($t(_,U,!1,[1,1]),n,l,B),z||(H(),z=!0);const Z=Wi(W,{handle:P,connectionMode:t,fromNodeId:s,fromHandleId:r,fromType:o?"target":"source",isValidConnection:y,doc:C,lib:u,flowId:f,nodeLookup:l});I=Z.handleDomNode,k=Z.connection,j=Nf(!!P,Z.isValid);const G={...R,isValid:j,to:P&&j?Ii({x:P.x,y:P.y},U):_,toHandle:Z.toHandle,toPosition:j&&Z.toHandle?Z.toHandle.position:es[B.position],toNode:Z.toHandle?l.get(Z.toHandle.nodeId):null};j&&P&&R.toHandle&&G.toHandle&&R.toHandle.type===G.toHandle.type&&R.toHandle.nodeId===G.toHandle.nodeId&&R.toHandle.id===G.toHandle.id&&R.to.x===G.to.x&&R.to.y===G.to.y||(b(G),R=G)}function F(W){(P||I)&&k&&j&&(x==null||x(k));const{inProgress:U,...Z}=R,G={...Z,toPosition:R.toHandle?R.toPosition:null};v==null||v(W,G),i&&(N==null||N(W,G)),p(),cancelAnimationFrame(T),z=!1,j=!1,k=null,I=null,C.removeEventListener("mousemove",q),C.removeEventListener("mouseup",F),C.removeEventListener("touchmove",q),C.removeEventListener("touchend",F)}C.addEventListener("mousemove",q),C.addEventListener("mouseup",F),C.addEventListener("touchmove",q),C.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:m}=ve(e),x=o.elementFromPoint(p,m),v=x!=null&&x.classList.contains(`${a}-flow__handle`)?x:h,y={handleDomNode:v,isValid:!1,connection:null,toHandle:null};if(v){const N=Xi(void 0,v),b=v.getAttribute("data-nodeid"),w=v.getAttribute("data-handleid"),$=v.classList.contains("connectable"),D=v.classList.contains("connectableend");if(!b||!N)return y;const C={source:f?b:r,sourceHandle:f?w:s,target:f?r:b,targetHandle:f?s:w};y.connection=C;const P=$&&D&&(n===Qe.Strict?f&&N==="source"||!f&&N==="target":b!==r||w!==s);y.isValid=P&&u(C),y.toHandle=qi(b,N,w,d,n,!1)}return y}const ir={onPointerDown:_f,isValid:Wi};function kf({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 m=b=>{const w=n();if(b.sourceEvent.type!=="wheel"||!t)return;const $=-b.sourceEvent.deltaY*(b.sourceEvent.deltaMode===1?.05:b.sourceEvent.deltaMode?1:.002)*d,D=w[2]*Math.pow(2,$);t.scaleTo(D)};let x=[0,0];const v=b=>{(b.sourceEvent.type==="mousedown"||b.sourceEvent.type==="touchstart")&&(x=[b.sourceEvent.clientX??b.sourceEvent.touches[0].clientX,b.sourceEvent.clientY??b.sourceEvent.touches[0].clientY])},y=b=>{const w=n();if(b.sourceEvent.type!=="mousemove"&&b.sourceEvent.type!=="touchmove"||!t)return;const $=[b.sourceEvent.clientX??b.sourceEvent.touches[0].clientX,b.sourceEvent.clientY??b.sourceEvent.touches[0].clientY],D=[$[0]-x[0],$[1]-x[1]];x=$;const C=r()*Math.max(w[2],Math.log(w[2]))*(p?-1:1),T={x:w[0]-D[0]*C,y:w[1]-D[1]*C},P=[[0,0],[l,u]];t.setViewportConstrained({x:T.x,y:T.y,zoom:w[2]},P,a)},N=Ni().on("start",v).on("zoom",f?y:null).on("zoom.wheel",h?m:null);s.call(N,{})}function o(){s.on("zoom",null)}return{update:i,destroy:o,pointer:de}}const Sf=(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),Xe=(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 Ef({zoomPanValues:e,noWheelClassName:t,d3Selection:n,d3Zoom:r,panOnScrollMode:s,panOnScrollSpeed:i,zoomOnPinch:o,onPanZoomStart:a,onPanZoom:l,onPanZoomEnd:u}){return d=>{if(Xe(d,t))return!1;d.preventDefault(),d.stopImmediatePropagation();const f=n.property("__zoom").k||1;if(d.ctrlKey&&o){const v=de(d),y=Gi(d),N=f*Math.pow(2,y);r.scaleTo(n,N,v,d);return}const h=d.deltaMode===1?20:1;let p=s===He.Vertical?0:d.deltaX*h,m=s===He.Horizontal?0:d.deltaY*h;!rn()&&d.shiftKey&&s!==He.Vertical&&(p=d.deltaY*h,m=0),r.translateBy(n,-(p/f)*i,-(m/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 jf({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:n}){return function(r,s){if(!t&&r.type==="wheel"&&!r.ctrlKey||Xe(r,e))return null;r.preventDefault(),n.call(this,r,s)}}function Cf({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 $f({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 Mf({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&&Sf(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 zf({zoomActivationKeyPressed:e,zoomOnScroll:t,zoomOnPinch:n,panOnDrag:r,panOnScroll:s,zoomOnDoubleClick:i,userSelectionActive:o,noWheelClassName:a,noPanClassName:l,lib:u}){return d=>{var m;const f=e||t,h=n&&d.ctrlKey;if(d.button===1&&d.type==="mousedown"&&(Xe(d,`${u}-flow__node`)||Xe(d,`${u}-flow__edge`)))return!0;if(!r&&!f&&!s&&!i&&!n||o||Xe(d,a)&&d.type==="wheel"||Xe(d,l)&&(d.type!=="wheel"||s&&d.type==="wheel"&&!e)||!n&&d.ctrlKey&&d.type==="wheel")return!1;if(!n&&d.type==="touchstart"&&((m=d.touches)==null?void 0:m.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 If({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);b({x:i.x,y:i.y,zoom:Je(i.zoom,t,n)},[[0,0],[f.width,f.height]],s);const m=p.on("wheel.zoom"),x=p.on("dblclick.zoom");h.wheelDelta(Gi);function v(L,A){return p?new Promise(g=>{h==null||h.transform(Rn(p,A==null?void 0:A.duration,()=>g(!0)),L)}):Promise.resolve(!1)}function y({noWheelClassName:L,noPanClassName:A,onPaneContextMenu:g,userSelectionActive:S,panOnScroll:_,panOnDrag:z,panOnScrollMode:k,panOnScrollSpeed:j,preventScrolling:I,zoomOnPinch:H,zoomOnScroll:B,zoomOnDoubleClick:Y,zoomActivationKeyPressed:X,lib:V,onTransformChange:R}){S&&!d.isZoomingOrPanning&&N();const F=_&&!X&&!S?Ef({zoomPanValues:d,noWheelClassName:L,d3Selection:p,d3Zoom:h,panOnScrollMode:k,panOnScrollSpeed:j,zoomOnPinch:H,onPanZoomStart:a,onPanZoom:o,onPanZoomEnd:l}):jf({noWheelClassName:L,preventScrolling:I,d3ZoomHandler:m});if(p.on("wheel.zoom",F,{passive:!1}),!S){const U=Cf({zoomPanValues:d,onDraggingChange:u,onPanZoomStart:a});h.on("start",U);const Z=$f({zoomPanValues:d,panOnDrag:z,onPaneContextMenu:!!g,onPanZoom:o,onTransformChange:R});h.on("zoom",Z);const G=Mf({zoomPanValues:d,panOnDrag:z,panOnScroll:_,onPaneContextMenu:g,onPanZoomEnd:l,onDraggingChange:u});h.on("end",G)}const W=zf({zoomActivationKeyPressed:X,panOnDrag:z,zoomOnScroll:B,panOnScroll:_,zoomOnDoubleClick:Y,zoomOnPinch:H,userSelectionActive:S,noPanClassName:A,noWheelClassName:L,lib:V});h.filter(W),Y?p.on("dblclick.zoom",x):p.on("dblclick.zoom",null)}function N(){h.on("zoom",null)}async function b(L,A,g){const S=Dn(L),_=h==null?void 0:h.constrain()(S,A,g);return _&&await v(_),new Promise(z=>z(_))}async function w(L,A){const g=Dn(L);return await v(g,A),new Promise(S=>S(g))}function $(L){if(p){const A=Dn(L),g=p.property("__zoom");(g.k!==L.zoom||g.x!==L.x||g.y!==L.y)&&(h==null||h.transform(p,A,null,{sync:!0}))}}function D(){const L=p?vi(p.node()):{x:0,y:0,k:1};return{x:L.x,y:L.y,zoom:L.k}}function C(L,A){return p?new Promise(g=>{h==null||h.scaleTo(Rn(p,A==null?void 0:A.duration,()=>g(!0)),L)}):Promise.resolve(!1)}function T(L,A){return p?new Promise(g=>{h==null||h.scaleBy(Rn(p,A==null?void 0:A.duration,()=>g(!0)),L)}):Promise.resolve(!1)}function P(L){h==null||h.scaleExtent(L)}function E(L){h==null||h.translateExtent(L)}function O(L){const A=!he(L)||L<0?0:L;h==null||h.clickDistance(A)}return{update:y,destroy:N,setViewport:w,setViewportConstrained:b,getViewport:D,scaleTo:C,scaleBy:T,setScaleExtent:P,setTranslateExtent:E,syncViewport:$,setClickDistance:O}}var pt;(function(e){e.Line="line",e.Handle="handle"})(pt||(pt={}));function Af({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 Pf(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 $e(e,t){return Math.max(0,t-e)}function Me(e,t){return Math.max(0,e-t)}function Rt(e,t,n){return Math.max(0,t-e,e-n)}function ds(e,t){return e?!t:t}function Tf(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:m}=n,{minWidth:x,maxWidth:v,minHeight:y,maxHeight:N}=r,{x:b,y:w,width:$,height:D,aspectRatio:C}=e;let T=Math.floor(d?p-e.pointerX:0),P=Math.floor(f?m-e.pointerY:0);const E=$+(l?-T:T),O=D+(u?-P:P),L=-i[0]*$,A=-i[1]*D;let g=Rt(E,x,v),S=Rt(O,y,N);if(o){let k=0,j=0;l&&T<0?k=$e(b+T+L,o[0][0]):!l&&T>0&&(k=Me(b+E+L,o[1][0])),u&&P<0?j=$e(w+P+A,o[0][1]):!u&&P>0&&(j=Me(w+O+A,o[1][1])),g=Math.max(g,k),S=Math.max(S,j)}if(a){let k=0,j=0;l&&T>0?k=Me(b+T,a[0][0]):!l&&T<0&&(k=$e(b+E,a[1][0])),u&&P>0?j=Me(w+P,a[0][1]):!u&&P<0&&(j=$e(w+O,a[1][1])),g=Math.max(g,k),S=Math.max(S,j)}if(s){if(d){const k=Rt(E/C,y,N)*C;if(g=Math.max(g,k),o){let j=0;!l&&!u||l&&!u&&h?j=Me(w+A+E/C,o[1][1])*C:j=$e(w+A+(l?T:-T)/C,o[0][1])*C,g=Math.max(g,j)}if(a){let j=0;!l&&!u||l&&!u&&h?j=$e(w+E/C,a[1][1])*C:j=Me(w+(l?T:-T)/C,a[0][1])*C,g=Math.max(g,j)}}if(f){const k=Rt(O*C,x,v)/C;if(S=Math.max(S,k),o){let j=0;!l&&!u||u&&!l&&h?j=Me(b+O*C+L,o[1][0])/C:j=$e(b+(u?P:-P)*C+L,o[0][0])/C,S=Math.max(S,j)}if(a){let j=0;!l&&!u||u&&!l&&h?j=$e(b+O*C,a[1][0])/C:j=Me(b+(u?P:-P)*C,a[0][0])/C,S=Math.max(S,j)}}}P=P+(P<0?S:-S),T=T+(T<0?g:-g),s&&(h?E>O*C?P=(ds(l,u)?-T:T)/C:T=(ds(l,u)?-P:P)*C:d?(P=T/C,u=l):(T=P*C,l=u));const _=l?b+T:b,z=u?w+P:w;return{width:$+(l?-T:T),height:D+(u?-P:P),x:i[0]*T*(l?-1:1)+_,y:i[1]*P*(u?-1:1)+z}}const Ui={width:0,height:0,x:0,y:0},Df={...Ui,pointerX:0,pointerY:0,aspectRatio:1};function Rf(e){return[[0,0],[e.measured.width,e.measured.height]]}function Lf(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 Hf({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:m}){let x={...Ui},v={...Df};const y=Pf(l);let N,b=null,w=[],$,D,C;const T=ai().on("start",P=>{const{nodeLookup:E,transform:O,snapGrid:L,snapToGrid:A,nodeOrigin:g,paneDomNode:S}=n();if(N=E.get(t),!N)return;b=(S==null?void 0:S.getBoundingClientRect())??null;const{xSnapped:_,ySnapped:z}=ht(P.sourceEvent,{transform:O,snapGrid:L,snapToGrid:A,containerBounds:b});x={width:N.measured.width??0,height:N.measured.height??0,x:N.position.x??0,y:N.position.y??0},v={...x,pointerX:_,pointerY:z,aspectRatio:x.width/x.height},$=void 0,N.parentId&&(N.extent==="parent"||N.expandParent)&&($=E.get(N.parentId),D=$&&N.extent==="parent"?Rf($):void 0),w=[],C=void 0;for(const[k,j]of E)if(j.parentId===t&&(w.push({id:k,position:{...j.position},extent:j.extent}),j.extent==="parent"||j.expandParent)){const I=Lf(j,N,j.origin??g);C?C=[[Math.min(I[0][0],C[0][0]),Math.min(I[0][1],C[0][1])],[Math.max(I[1][0],C[1][0]),Math.max(I[1][1],C[1][1])]]:C=I}f==null||f(P,{...x})}).on("drag",P=>{const{transform:E,snapGrid:O,snapToGrid:L,nodeOrigin:A}=n(),g=ht(P.sourceEvent,{transform:E,snapGrid:O,snapToGrid:L,containerBounds:b}),S=[];if(!N)return;const{x:_,y:z,width:k,height:j}=x,I={},H=N.origin??A,{width:B,height:Y,x:X,y:V}=Tf(v,y,g,u,d,H,D,C),R=B!==k,q=Y!==j,F=X!==_&&R,W=V!==z&&q;if(!F&&!W&&!R&&!q)return;if((F||W||H[0]===1||H[1]===1)&&(I.x=F?X:x.x,I.y=W?V:x.y,x.x=I.x,x.y=I.y,w.length>0)){const J=X-_,ee=V-z;for(const ie of w)ie.position={x:ie.position.x-J+H[0]*(B-k),y:ie.position.y-ee+H[1]*(Y-j)},S.push(ie)}if((R||q)&&(I.width=R?B:x.width,I.height=q?Y:x.height,x.width=I.width,x.height=I.height),$&&N.expandParent){const J=H[0]*(I.width??0);I.x&&I.x<J&&(x.x=J,v.x=v.x-(I.x-J));const ee=H[1]*(I.height??0);I.y&&I.y<ee&&(x.y=ee,v.y=v.y-(I.y-ee))}const U=Af({width:x.width,prevWidth:k,height:x.height,prevHeight:j,affectsX:y.affectsX,affectsY:y.affectsY}),Z={...x,direction:U};(m==null?void 0:m(P,Z))!==!1&&(h==null||h(P,Z),r(I,S))}).on("end",P=>{p==null||p(P,{...x}),s==null||s()});i.call(T)}function a(){i.on(".drag",null)}return{update:o,destroy:a}}var Zi={exports:{}},Qi={},Ji={exports:{}},eo={};/**
|
|
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),Ve=(e,t,n,r)=>($n(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),qe=(e,t,n)=>($n(e,t,"access private method"),n);import{S as La,s as Ha,h as zr,g as Fa,n as Os,u as an,r as M,a as Oa,b as Ba,c as Xt,i as Bs,j as c,K as On,X as Ge,B as Vs,d as Va,e as we,R as qa,C as qs,f as Xa,k as oe,l as Ya,m as Wa,o as Ka,p as Ga,q as Ua,t as Za,v as ar,P as Qa,w as Mn,x as Ja,Q as ec,y as tc,z as nc}from"./index-B8Ij4B8D.js";var Ae,Pe,ae,ye,_e,Ft,Bn,Fs,rc=(Fs=class extends La{constructor(t,n){super();Be(this,_e);Be(this,Ae);Be(this,Pe);Be(this,ae);Be(this,ye);Ve(this,Ae,t),this.setOptions(n),this.bindMethods(),qe(this,_e,Ft).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,Ae).defaultMutationOptions(t),Ha(this.options,n)||ne(this,Ae).getMutationCache().notify({type:"observerOptionsUpdated",mutation:ne(this,ae),observer:this}),n!=null&&n.mutationKey&&this.options.mutationKey&&zr(n.mutationKey)!==zr(this.options.mutationKey)?this.reset():((r=ne(this,ae))==null?void 0:r.state.status)==="pending"&&ne(this,ae).setOptions(this.options)}onUnsubscribe(){var t;this.hasListeners()||(t=ne(this,ae))==null||t.removeObserver(this)}onMutationUpdate(t){qe(this,_e,Ft).call(this),qe(this,_e,Bn).call(this,t)}getCurrentResult(){return ne(this,Pe)}reset(){var t;(t=ne(this,ae))==null||t.removeObserver(this),Ve(this,ae,void 0),qe(this,_e,Ft).call(this),qe(this,_e,Bn).call(this)}mutate(t,n){var r;return Ve(this,ye,n),(r=ne(this,ae))==null||r.removeObserver(this),Ve(this,ae,ne(this,Ae).getMutationCache().build(ne(this,Ae),this.options)),ne(this,ae).addObserver(this),ne(this,ae).execute(t)}},Ae=new WeakMap,Pe=new WeakMap,ae=new WeakMap,ye=new WeakMap,_e=new WeakSet,Ft=function(){var n;const t=((n=ne(this,ae))==null?void 0:n.state)??Fa();Ve(this,Pe,{...t,isPending:t.status==="pending",isSuccess:t.status==="success",isError:t.status==="error",isIdle:t.status==="idle",mutate:this.mutate,reset:this.reset})},Bn=function(t){Os.batch(()=>{var n,r,s,i,o,a,l,u;if(ne(this,ye)&&this.hasListeners()){const d=ne(this,Pe).variables,f=ne(this,Pe).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,Pe))})})},Fs);function ut(e,t){const n=an(),[r]=M.useState(()=>new rc(n,e));M.useEffect(()=>{r.setOptions(e)},[r,e]);const s=M.useSyncExternalStore(M.useCallback(o=>r.subscribe(Os.batchCalls(o)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),i=M.useCallback((o,a)=>{r.mutate(o,a).catch(Oa)},[r]);if(s.error&&Ba(r.options.throwOnError,[s.error]))throw s.error;return{...s,mutate:i,mutateAsync:s.mutate}}const Ir="compensate:";function sc(e){return e.startsWith(Ir)?e.slice(Ir.length):e}function ic(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 oc(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 ac(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 cc(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 lc(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 uc(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"},dc={debug:"text-zinc-500",info:"text-zinc-300",warn:"text-amber-300",error:"text-red-300"},fc=["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 ${dc[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]=M.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 hc({events:e}){const{subs:t,stepLogs:n}=Va(e),r=fc.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 pc({value:e}){const[t,n]=M.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(pc,{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 Ce({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 gc({id:e,onOpenRun:t}){const{data:n}=we({queryKey:["run",e],queryFn:()=>oe.run(e)}),[r,s]=M.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 mc({step:e,run:t,onClose:n,onOpenRun:r}){const s=Xt(e),[i,o]=M.useState(!1),a=e.status==="failed",l=e.status==="pending"||e.status==="running",u=Bs(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," · ",On[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(Ge,{})})]}),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(Ce,{k:"seq",v:`#${e.seq}`}),f>=1&&c.jsx(Ce,{k:"queued",v:c.jsx("span",{className:"text-sky-300",children:Wt(f)})}),c.jsx(Ce,{k:"duration",v:l?c.jsx("span",{className:"text-amber-300",children:"running…"}):Ar(e.startedAt,e.finishedAt)}),c.jsx(Ce,{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(Ce,{k:"worker",v:`@${e.workerGroup}`}),c.jsx(Ce,{k:"started",v:Pr(e.startedAt)}),c.jsx(Ce,{k:"finished",v:Pr(e.finishedAt)}),c.jsx(Ce,{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(hc,{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(gc,{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 xc({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(Ge,{})})]}),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 yc={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 Ot(n)}function Ot(e){this._=e}function wc(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}})}Ot.prototype=cn.prototype={constructor:Ot,on:function(e,t){var n=this._,r=wc(e+"",n),s,i=-1,o=r.length;if(arguments.length<2){for(;++i<o;)if((s=(e=r[i]).type)&&(s=bc(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 Ot(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 bc(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]=yc,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 vc(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 Nc(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function Ws(e){var t=ln(e);return(t.local?Nc:vc)(t)}function _c(){}function lr(e){return e==null?_c:function(){return this.querySelector(e)}}function kc(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 Sc(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function Ec(){return[]}function Ks(e){return e==null?Ec:function(){return this.querySelectorAll(e)}}function jc(e){return function(){return Sc(e.apply(this,arguments))}}function Cc(e){typeof e=="function"?e=jc(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 $c=Array.prototype.find;function Mc(e){return function(){return $c.call(this.children,e)}}function zc(){return this.firstElementChild}function Ic(e){return this.select(e==null?zc:Mc(typeof e=="function"?e:Us(e)))}var Ac=Array.prototype.filter;function Pc(){return Array.from(this.children)}function Tc(e){return function(){return Ac.call(this.children,e)}}function Dc(e){return this.selectAll(e==null?Pc:Tc(typeof e=="function"?e:Us(e)))}function Rc(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 Lc(){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 Hc(e){return function(){return e}}function Fc(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 Vc(e,t){if(!arguments.length)return Array.from(this,Bc);var n=t?Oc:Fc,r=this._parents,s=this._groups;typeof e!="function"&&(e=Hc(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=qc(e.call(d,d&&d.__data__,u,r)),m=p.length,x=a[u]=new Array(m),v=o[u]=new Array(m),y=l[u]=new Array(h);n(d,f,x,v,y,p,t);for(var N=0,b=0,w,$;N<m;++N)if(w=x[N]){for(N>=b&&(b=N+1);!($=v[b])&&++b<m;);w._next=$||null}}return o=new ue(o,r),o._enter=a,o._exit=l,o}function qc(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function Xc(){return new ue(this._exit||this._groups.map(Zs),this._parents)}function Yc(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 Wc(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,m=0;m<f;++m)(p=u[m]||d[m])&&(h[m]=p);for(;l<s;++l)a[l]=n[l];return new ue(a,this._parents)}function Kc(){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 Gc(e){e||(e=Uc);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 Uc(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function Zc(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function Qc(){return Array.from(this)}function Jc(){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 el(){let e=0;for(const t of this)++e;return e}function tl(){return!this.node()}function nl(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 rl(e){return function(){this.removeAttribute(e)}}function sl(e){return function(){this.removeAttributeNS(e.space,e.local)}}function il(e,t){return function(){this.setAttribute(e,t)}}function ol(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function al(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function cl(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 ll(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?sl:rl:typeof t=="function"?n.local?cl:al:n.local?ol:il)(n,t))}function Qs(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function ul(e){return function(){this.style.removeProperty(e)}}function dl(e,t,n){return function(){this.style.setProperty(e,t,n)}}function fl(e,t,n){return function(){var r=t.apply(this,arguments);r==null?this.style.removeProperty(e):this.style.setProperty(e,r,n)}}function hl(e,t,n){return arguments.length>1?this.each((t==null?ul:typeof t=="function"?fl:dl)(e,t,n??"")):Ue(this.node(),e)}function Ue(e,t){return e.style.getPropertyValue(t)||Qs(e).getComputedStyle(e,null).getPropertyValue(t)}function pl(e){return function(){delete this[e]}}function gl(e,t){return function(){this[e]=t}}function ml(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function xl(e,t){return arguments.length>1?this.each((t==null?pl:typeof t=="function"?ml:gl)(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 yl(e){return function(){ti(this,e)}}function wl(e){return function(){ni(this,e)}}function bl(e,t){return function(){(t.apply(this,arguments)?ti:ni)(this,e)}}function vl(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"?bl:t?yl:wl)(n,t))}function Nl(){this.textContent=""}function _l(e){return function(){this.textContent=e}}function kl(e){return function(){var t=e.apply(this,arguments);this.textContent=t??""}}function Sl(e){return arguments.length?this.each(e==null?Nl:(typeof e=="function"?kl:_l)(e)):this.node().textContent}function El(){this.innerHTML=""}function jl(e){return function(){this.innerHTML=e}}function Cl(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??""}}function $l(e){return arguments.length?this.each(e==null?El:(typeof e=="function"?Cl:jl)(e)):this.node().innerHTML}function Ml(){this.nextSibling&&this.parentNode.appendChild(this)}function zl(){return this.each(Ml)}function Il(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function Al(){return this.each(Il)}function Pl(e){var t=typeof e=="function"?e:Ws(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function Tl(){return null}function Dl(e,t){var n=typeof e=="function"?e:Ws(e),r=t==null?Tl:typeof t=="function"?t:lr(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),r.apply(this,arguments)||null)})}function Rl(){var e=this.parentNode;e&&e.removeChild(this)}function Ll(){return this.each(Rl)}function Hl(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Fl(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Ol(e){return this.select(e?Fl:Hl)}function Bl(e){return arguments.length?this.property("__data__",e):this.node().__data__}function Vl(e){return function(t){e.call(this,t,this.__data__)}}function ql(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 Xl(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 Yl(e,t,n){return function(){var r=this.__on,s,i=Vl(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 Wl(e,t,n){var r=ql(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?Yl:Xl,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 Kl(e,t){return function(){return ri(this,e,t)}}function Gl(e,t){return function(){return ri(this,e,t.apply(this,arguments))}}function Ul(e,t){return this.each((typeof t=="function"?Gl:Kl)(e,t))}function*Zl(){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 Ql(){return this}ue.prototype=St.prototype={constructor:ue,select:kc,selectAll:Cc,selectChild:Ic,selectChildren:Dc,filter:Rc,data:Vc,enter:Lc,exit:Xc,join:Yc,merge:Wc,selection:Ql,order:Kc,sort:Gc,call:Zc,nodes:Qc,node:Jc,size:el,empty:tl,each:nl,attr:ll,style:hl,property:xl,classed:vl,text:Sl,html:$l,raise:zl,lower:Al,append:Pl,insert:Dl,remove:Ll,clone:Ol,datum:Bl,on:Wl,dispatch:Ul,[Symbol.iterator]:Zl};function le(e){return typeof e=="string"?new ue([[document.querySelector(e)]],[document.documentElement]):new ue([[e]],si)}function Jl(e){let t;for(;t=e.sourceEvent;)e=t;return e}function de(e,t){if(e=Jl(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 eu={passive:!1},gt={capture:!0,passive:!1};function zn(e){e.stopImmediatePropagation()}function We(e){e.preventDefault(),e.stopImmediatePropagation()}function ii(e){var t=e.document.documentElement,n=le(e).on("dragstart.drag",We,gt);"onselectstart"in t?n.on("selectstart.drag",We,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",We,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 tu(e){return!e.ctrlKey&&!e.button}function nu(){return this.parentNode}function ru(e,t){return t??{x:e.x,y:e.y}}function su(){return navigator.maxTouchPoints||"ontouchstart"in this}function ai(){var e=tu,t=nu,n=ru,r=su,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",v).on("touchmove.drag",y,eu).on("touchend.drag touchcancel.drag",N).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function p(w,$){if(!(d||!e.call(this,w,$))){var D=b(this,t.call(this,w,$),w,$,"mouse");D&&(le(w.view).on("mousemove.drag",m,gt).on("mouseup.drag",x,gt),ii(w.view),zn(w),u=!1,a=w.clientX,l=w.clientY,D("start",w))}}function m(w){if(We(w),!u){var $=w.clientX-a,D=w.clientY-l;u=$*$+D*D>f}s.mouse("drag",w)}function x(w){le(w.view).on("mousemove.drag mouseup.drag",null),oi(w.view,u),We(w),s.mouse("end",w)}function v(w,$){if(e.call(this,w,$)){var D=w.changedTouches,C=t.call(this,w,$),T=D.length,P,E;for(P=0;P<T;++P)(E=b(this,C,w,$,D[P].identifier,D[P]))&&(zn(w),E("start",w,D[P]))}}function y(w){var $=w.changedTouches,D=$.length,C,T;for(C=0;C<D;++C)(T=s[$[C].identifier])&&(We(w),T("drag",w,$[C]))}function N(w){var $=w.changedTouches,D=$.length,C,T;for(d&&clearTimeout(d),d=setTimeout(function(){d=null},500),C=0;C<D;++C)(T=s[$[C].identifier])&&(zn(w),T("end",w,$[C]))}function b(w,$,D,C,T,P){var E=i.copy(),O=de(P||D,$),L,A,g;if((g=n.call(w,new Xn("beforestart",{sourceEvent:D,target:h,identifier:T,active:o,x:O[0],y:O[1],dx:0,dy:0,dispatch:E}),C))!=null)return L=g.x-O[0]||0,A=g.y-O[1]||0,function S(_,z,k){var j=O,I;switch(_){case"start":s[T]=S,I=o++;break;case"end":delete s[T],--o;case"drag":O=de(k||z,$),I=o;break}E.call(_,w,new Xn(_,{sourceEvent:z,subject:g,target:h,identifier:T,active:I,x:O[0]+L,y:O[1]+A,dx:O[0]-j[0],dy:O[1]-j[1],dispatch:E}),C)}}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,Ke="\\s*([+-]?\\d+)\\s*",xt="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",ge="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",iu=/^#([0-9a-f]{3,8})$/,ou=new RegExp(`^rgb\\(${Ke},${Ke},${Ke}\\)$`),au=new RegExp(`^rgb\\(${ge},${ge},${ge}\\)$`),cu=new RegExp(`^rgba\\(${Ke},${Ke},${Ke},${xt}\\)$`),lu=new RegExp(`^rgba\\(${ge},${ge},${ge},${xt}\\)$`),uu=new RegExp(`^hsl\\(${xt},${ge},${ge}\\)$`),du=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:fu,formatHsl:hu,formatRgb:Fr,toString:Fr});function Hr(){return this.rgb().formatHex()}function fu(){return this.rgb().formatHex8()}function hu(){return li(this).formatHsl()}function Fr(){return this.rgb().formatRgb()}function yt(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=iu.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?Or(t):n===3?new ce(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=ou.exec(e))?new ce(t[1],t[2],t[3],1):(t=au.exec(e))?new ce(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=cu.exec(e))?It(t[1],t[2],t[3],t[4]):(t=lu.exec(e))?It(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=uu.exec(e))?qr(t[1],t[2]/100,t[3]/100,1):(t=du.exec(e))?qr(t[1],t[2]/100,t[3]/100,t[4]):Lr.hasOwnProperty(e)?Or(Lr[e]):e==="transparent"?new ce(NaN,NaN,NaN,0):null}function Or(e){return new ce(e>>16&255,e>>8&255,e&255,1)}function It(e,t,n,r){return r<=0&&(e=t=n=NaN),new ce(e,t,n,r)}function pu(e){return e instanceof Et||(e=yt(e)),e?(e=e.rgb(),new ce(e.r,e.g,e.b,e.opacity)):new ce}function Yn(e,t,n,r){return arguments.length===1?pu(e):new ce(e,t,n,r??1)}function ce(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}dr(ce,Yn,ci(Et,{brighter(e){return e=e==null?Ut:Math.pow(Ut,e),new ce(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?mt:Math.pow(mt,e),new ce(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new ce(Le(this.r),Le(this.g),Le(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:Br,formatHex:Br,formatHex8:gu,formatRgb:Vr,toString:Vr}));function Br(){return`#${Re(this.r)}${Re(this.g)}${Re(this.b)}`}function gu(){return`#${Re(this.r)}${Re(this.g)}${Re(this.b)}${Re((isNaN(this.opacity)?1:this.opacity)*255)}`}function Vr(){const e=Zt(this.opacity);return`${e===1?"rgb(":"rgba("}${Le(this.r)}, ${Le(this.g)}, ${Le(this.b)}${e===1?")":`, ${e})`}`}function Zt(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function Le(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function Re(e){return e=Le(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 mu(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,mu,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 ce(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 xu(e,t){return function(n){return e+n*t}}function yu(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 wu(e){return(e=+e)==1?di:function(t,n){return n-t?yu(t,n,e):ui(isNaN(t)?n:t)}}function di(e,t){var n=t-e;return n?xu(e,n):ui(isNaN(e)?t:e)}const Yr=function e(t){var n=wu(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 ze(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 bu(e){return function(){return e}}function vu(e){return function(t){return e(t)+""}}function Nu(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:ze(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]?vu(l[0].x):bu(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 _u(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 ku(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,m){if(u!==f||d!==h){var x=p.push("translate(",null,t,null,n);m.push({i:x-4,x:ze(u,f)},{i:x-2,x:ze(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:ze(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:ze(u,d)}):d&&f.push(s(f)+"skewX("+d+r)}function l(u,d,f,h,p,m){if(u!==f||d!==h){var x=p.push(s(p)+"scale(",null,",",null,")");m.push({i:x-4,x:ze(u,f)},{i:x-2,x:ze(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 m=-1,x=h.length,v;++m<x;)f[(v=h[m]).i]=v.x(p);return f.join("")}}}var Su=hi(_u,"px, ","px)","deg)"),Eu=hi(ku,", ",")",")"),ju=1e-12;function Kr(e){return((e=Math.exp(e))+1/e)/2}function Cu(e){return((e=Math.exp(e))-1/e)/2}function $u(e){return((e=Math.exp(2*e))-1)/(e+1)}const Mu=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,m=f-l,x=p*p+m*m,v,y;if(x<ju)y=Math.log(h/u)/t,v=function(C){return[a+C*p,l+C*m,u*Math.exp(t*C*y)]};else{var N=Math.sqrt(x),b=(h*h-u*u+r*x)/(2*u*n*N),w=(h*h-u*u-r*x)/(2*h*n*N),$=Math.log(Math.sqrt(b*b+1)-b),D=Math.log(Math.sqrt(w*w+1)-w);y=(D-$)/t,v=function(C){var T=C*y,P=Kr($),E=u/(n*N)*(P*$u(t*T+$)-Cu($));return[a+E*p,l+E*m,u*P/Kr(t*T+$)]}}return v.duration=y*1e3*t/Math.SQRT2,v}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,Fe=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 Fe||(gi(zu),Fe=wt.now()+un)}function zu(){Fe=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 Iu(){fr(),++Ze;for(var e=Qt,t;e;)(t=Fe-e._time)>=0&&e._call.call(void 0,t),e=e._next;--Ze}function Gr(){Fe=(Jt=wt.now())+un,Ze=dt=0;try{Iu()}finally{Ze=0,Pu(),Fe=0}}function Au(){var e=wt.now(),t=e-Jt;t>pi&&(un-=t,Jt=e)}function Pu(){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-Fe;t>24?(e<1/0&&(dt=setTimeout(Gr,e-wt.now()-un)),ct&&(ct=clearInterval(ct))):(ct||(Jt=wt.now(),ct=setInterval(Au,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 Tu=cn("start","end","cancel","interrupt"),Du=[],xi=0,Zr=1,Un=2,Bt=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;Ru(e,n,{name:t,index:r,group:s,on:Tu,tween:Du,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>Bt)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 Ru(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===Bt)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===Bt&&(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=Bt,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 Lu(e){return this.each(function(){qt(this,e)})}function Hu(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 Fu(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?Hu:Fu)(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"?ze:t instanceof yt?Yr:(n=yt(t))?(t=n,Yr):Nu)(e,t)}function Bu(e){return function(){this.removeAttribute(e)}}function Vu(e){return function(){this.removeAttributeNS(e.space,e.local)}}function qu(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 Xu(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 Yu(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 Wu(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 Ku(e,t){var n=ln(e),r=n==="transform"?Eu:yi;return this.attrTween(e,typeof t=="function"?(n.local?Wu:Yu)(n,r,pr(this,"attr."+e,t)):t==null?(n.local?Vu:Bu)(n):(n.local?Xu:qu)(n,r,t))}function Gu(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function Uu(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function Zu(e,t){var n,r;function s(){var i=t.apply(this,arguments);return i!==r&&(n=(r=i)&&Uu(e,i)),n}return s._value=t,s}function Qu(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 Ju(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?Zu:Qu)(r,t))}function ed(e,t){return function(){hr(this,e).delay=+t.apply(this,arguments)}}function td(e,t){return t=+t,function(){hr(this,e).delay=t}}function nd(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?ed:td)(t,e)):pe(this.node(),t).delay}function rd(e,t){return function(){me(this,e).duration=+t.apply(this,arguments)}}function sd(e,t){return t=+t,function(){me(this,e).duration=t}}function id(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?rd:sd)(t,e)):pe(this.node(),t).duration}function od(e,t){if(typeof t!="function")throw new Error;return function(){me(this,e).ease=t}}function ad(e){var t=this._id;return arguments.length?this.each(od(t,e)):pe(this.node(),t).ease}function cd(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!="function")throw new Error;me(this,e).ease=n}}function ld(e){if(typeof e!="function")throw new Error;return this.each(cd(this._id,e))}function ud(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 ke(r,this._parents,this._name,this._id)}function dd(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 ke(o,this._parents,this._name,this._id)}function fd(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 hd(e,t,n){var r,s,i=fd(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 pd(e,t){var n=this._id;return arguments.length<2?pe(this.node(),n).on.on(e):this.each(hd(n,e,t))}function gd(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function md(){return this.on("end.remove",gd(this._id))}function xd(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 ke(i,this._parents,t,n)}function yd(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,m=pe(d,n),x=0,v=h.length;x<v;++x)(p=h[x])&&dn(p,t,n,x,h,m);i.push(h),o.push(d)}return new ke(i,o,t,n)}var wd=St.prototype.constructor;function bd(){return new wd(this._groups,this._parents)}function vd(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 Nd(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 _d(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 kd(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 Sd(e,t,n){var r=(e+="")=="transform"?Su:yi;return t==null?this.styleTween(e,vd(e,r)).on("end.style."+e,wi(e)):typeof t=="function"?this.styleTween(e,_d(e,r,pr(this,"style."+e,t))).each(kd(this._id,e)):this.styleTween(e,Nd(e,r,t),n).on("end.style."+e,null)}function Ed(e,t,n){return function(r){this.style.setProperty(e,t.call(this,r),n)}}function jd(e,t,n){var r,s;function i(){var o=t.apply(this,arguments);return o!==s&&(r=(s=o)&&Ed(e,o,n)),r}return i._value=t,i}function Cd(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,jd(e,t,n??""))}function $d(e){return function(){this.textContent=e}}function Md(e){return function(){var t=e(this);this.textContent=t??""}}function zd(e){return this.tween("text",typeof e=="function"?Md(pr(this,"text",e)):$d(e==null?"":e+""))}function Id(e){return function(t){this.textContent=e.call(this,t)}}function Ad(e){var t,n;function r(){var s=e.apply(this,arguments);return s!==n&&(t=(n=s)&&Id(s)),t}return r._value=e,r}function Pd(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,Ad(e))}function Td(){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 ke(r,this._parents,e,n)}function Dd(){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 Rd=0;function ke(e,t,n,r){this._groups=e,this._parents=t,this._name=n,this._id=r}function bi(){return++Rd}var xe=St.prototype;ke.prototype={constructor:ke,select:xd,selectAll:yd,selectChild:xe.selectChild,selectChildren:xe.selectChildren,filter:ud,merge:dd,selection:bd,transition:Td,call:xe.call,nodes:xe.nodes,node:xe.node,size:xe.size,empty:xe.empty,each:xe.each,on:pd,attr:Ku,attrTween:Ju,style:Sd,styleTween:Cd,text:zd,textTween:Pd,remove:md,tween:Ou,delay:nd,duration:id,ease:ad,easeVarying:ld,end:Dd,[Symbol.iterator]:xe[Symbol.iterator]};function Ld(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var Hd={time:null,delay:0,duration:250,ease:Ld};function Fd(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 ke?(t=e._id,e=e._name):(t=bi(),(n=Hd).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||Fd(l,t));return new ke(r,this._parents,e,t)}St.prototype.interrupt=Lu;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 be(e,t,n){this.k=e,this.x=t,this.y=n}be.prototype={constructor:be,scale:function(e){return e===1?this:new be(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new be(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 be(1,0,0);vi.prototype=be.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 Vd(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function qd(){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 Xd(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function Yd(){return navigator.maxTouchPoints||"ontouchstart"in this}function Wd(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=Vd,t=qd,n=Wd,r=Xd,s=Yd,i=[0,1/0],o=[[-1/0,-1/0],[1/0,1/0]],a=250,l=Mu,u=cn("start","zoom","end"),d,f,h,p=500,m=150,x=0,v=10;function y(g){g.property("__zoom",Jr).on("wheel.zoom",T,{passive:!1}).on("mousedown.zoom",P).on("dblclick.zoom",E).filter(s).on("touchstart.zoom",O).on("touchmove.zoom",L).on("touchend.zoom touchcancel.zoom",A).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}y.transform=function(g,S,_,z){var k=g.selection?g.selection():g;k.property("__zoom",Jr),g!==k?$(g,S,_,z):k.interrupt().each(function(){D(this,arguments).event(z).start().zoom(null,typeof S=="function"?S.apply(this,arguments):S).end()})},y.scaleBy=function(g,S,_,z){y.scaleTo(g,function(){var k=this.__zoom.k,j=typeof S=="function"?S.apply(this,arguments):S;return k*j},_,z)},y.scaleTo=function(g,S,_,z){y.transform(g,function(){var k=t.apply(this,arguments),j=this.__zoom,I=_==null?w(k):typeof _=="function"?_.apply(this,arguments):_,H=j.invert(I),B=typeof S=="function"?S.apply(this,arguments):S;return n(b(N(j,B),I,H),k,o)},_,z)},y.translateBy=function(g,S,_,z){y.transform(g,function(){return n(this.__zoom.translate(typeof S=="function"?S.apply(this,arguments):S,typeof _=="function"?_.apply(this,arguments):_),t.apply(this,arguments),o)},null,z)},y.translateTo=function(g,S,_,z,k){y.transform(g,function(){var j=t.apply(this,arguments),I=this.__zoom,H=z==null?w(j):typeof z=="function"?z.apply(this,arguments):z;return n(fn.translate(H[0],H[1]).scale(I.k).translate(typeof S=="function"?-S.apply(this,arguments):-S,typeof _=="function"?-_.apply(this,arguments):-_),j,o)},z,k)};function N(g,S){return S=Math.max(i[0],Math.min(i[1],S)),S===g.k?g:new be(S,g.x,g.y)}function b(g,S,_){var z=S[0]-_[0]*g.k,k=S[1]-_[1]*g.k;return z===g.x&&k===g.y?g:new be(g.k,z,k)}function w(g){return[(+g[0][0]+ +g[1][0])/2,(+g[0][1]+ +g[1][1])/2]}function $(g,S,_,z){g.on("start.zoom",function(){D(this,arguments).event(z).start()}).on("interrupt.zoom end.zoom",function(){D(this,arguments).event(z).end()}).tween("zoom",function(){var k=this,j=arguments,I=D(k,j).event(z),H=t.apply(k,j),B=_==null?w(H):typeof _=="function"?_.apply(k,j):_,Y=Math.max(H[1][0]-H[0][0],H[1][1]-H[0][1]),X=k.__zoom,V=typeof S=="function"?S.apply(k,j):S,R=l(X.invert(B).concat(Y/X.k),V.invert(B).concat(Y/V.k));return function(q){if(q===1)q=V;else{var F=R(q),W=Y/F[2];q=new be(W,B[0]-F[0]*W,B[1]-F[1]*W)}I.zoom(null,q)}})}function D(g,S,_){return!_&&g.__zooming||new C(g,S)}function C(g,S){this.that=g,this.args=S,this.active=0,this.sourceEvent=null,this.extent=t.apply(g,S),this.taps=0}C.prototype={event:function(g){return g&&(this.sourceEvent=g),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(g,S){return this.mouse&&g!=="mouse"&&(this.mouse[1]=S.invert(this.mouse[0])),this.touch0&&g!=="touch"&&(this.touch0[1]=S.invert(this.touch0[0])),this.touch1&&g!=="touch"&&(this.touch1[1]=S.invert(this.touch1[0])),this.that.__zoom=S,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(g){var S=le(this.that).datum();u.call(g,this.that,new Bd(g,{sourceEvent:this.sourceEvent,target:y,transform:this.that.__zoom,dispatch:u}),S)}};function T(g,...S){if(!e.apply(this,arguments))return;var _=D(this,S).event(g),z=this.__zoom,k=Math.max(i[0],Math.min(i[1],z.k*Math.pow(2,r.apply(this,arguments)))),j=de(g);if(_.wheel)(_.mouse[0][0]!==j[0]||_.mouse[0][1]!==j[1])&&(_.mouse[1]=z.invert(_.mouse[0]=j)),clearTimeout(_.wheel);else{if(z.k===k)return;_.mouse=[j,z.invert(j)],qt(this),_.start()}lt(g),_.wheel=setTimeout(I,m),_.zoom("mouse",n(b(N(z,k),_.mouse[0],_.mouse[1]),_.extent,o));function I(){_.wheel=null,_.end()}}function P(g,...S){if(h||!e.apply(this,arguments))return;var _=g.currentTarget,z=D(this,S,!0).event(g),k=le(g.view).on("mousemove.zoom",B,!0).on("mouseup.zoom",Y,!0),j=de(g,_),I=g.clientX,H=g.clientY;ii(g.view),Pn(g),z.mouse=[j,this.__zoom.invert(j)],qt(this),z.start();function B(X){if(lt(X),!z.moved){var V=X.clientX-I,R=X.clientY-H;z.moved=V*V+R*R>x}z.event(X).zoom("mouse",n(b(z.that.__zoom,z.mouse[0]=de(X,_),z.mouse[1]),z.extent,o))}function Y(X){k.on("mousemove.zoom mouseup.zoom",null),oi(X.view,z.moved),lt(X),z.event(X).end()}}function E(g,...S){if(e.apply(this,arguments)){var _=this.__zoom,z=de(g.changedTouches?g.changedTouches[0]:g,this),k=_.invert(z),j=_.k*(g.shiftKey?.5:2),I=n(b(N(_,j),z,k),t.apply(this,S),o);lt(g),a>0?le(this).transition().duration(a).call($,I,z,g):le(this).call(y.transform,I,z,g)}}function O(g,...S){if(e.apply(this,arguments)){var _=g.touches,z=_.length,k=D(this,S,g.changedTouches.length===z).event(g),j,I,H,B;for(Pn(g),I=0;I<z;++I)H=_[I],B=de(H,this),B=[B,this.__zoom.invert(B),H.identifier],k.touch0?!k.touch1&&k.touch0[2]!==B[2]&&(k.touch1=B,k.taps=0):(k.touch0=B,j=!0,k.taps=1+!!d);d&&(d=clearTimeout(d)),j&&(k.taps<2&&(f=B[0],d=setTimeout(function(){d=null},p)),qt(this),k.start())}}function L(g,...S){if(this.__zooming){var _=D(this,S).event(g),z=g.changedTouches,k=z.length,j,I,H,B;for(lt(g),j=0;j<k;++j)I=z[j],H=de(I,this),_.touch0&&_.touch0[2]===I.identifier?_.touch0[0]=H:_.touch1&&_.touch1[2]===I.identifier&&(_.touch1[0]=H);if(I=_.that.__zoom,_.touch1){var Y=_.touch0[0],X=_.touch0[1],V=_.touch1[0],R=_.touch1[1],q=(q=V[0]-Y[0])*q+(q=V[1]-Y[1])*q,F=(F=R[0]-X[0])*F+(F=R[1]-X[1])*F;I=N(I,Math.sqrt(q/F)),H=[(Y[0]+V[0])/2,(Y[1]+V[1])/2],B=[(X[0]+R[0])/2,(X[1]+R[1])/2]}else if(_.touch0)H=_.touch0[0],B=_.touch0[1];else return;_.zoom("touch",n(b(I,H,B),_.extent,o))}}function A(g,...S){if(this.__zooming){var _=D(this,S).event(g),z=g.changedTouches,k=z.length,j,I;for(Pn(g),h&&clearTimeout(h),h=setTimeout(function(){h=null},p),j=0;j<k;++j)I=z[j],_.touch0&&_.touch0[2]===I.identifier?delete _.touch0:_.touch1&&_.touch1[2]===I.identifier&&delete _.touch1;if(_.touch1&&!_.touch0&&(_.touch0=_.touch1,delete _.touch1),_.touch0)_.touch0[1]=this.__zoom.invert(_.touch0[0]);else if(_.end(),_.taps===2&&(I=de(I,this),Math.hypot(f[0]-I[0],f[1]-I[1])<v)){var H=le(this).on("dblclick.zoom");H&&H.apply(this,arguments)}}}return y.wheelDelta=function(g){return arguments.length?(r=typeof g=="function"?g:Tt(+g),y):r},y.filter=function(g){return arguments.length?(e=typeof g=="function"?g:Tt(!!g),y):e},y.touchable=function(g){return arguments.length?(s=typeof g=="function"?g:Tt(!!g),y):s},y.extent=function(g){return arguments.length?(t=typeof g=="function"?g:Tt([[+g[0][0],+g[0][1]],[+g[1][0],+g[1][1]]]),y):t},y.scaleExtent=function(g){return arguments.length?(i[0]=+g[0],i[1]=+g[1],y):[i[0],i[1]]},y.translateExtent=function(g){return arguments.length?(o[0][0]=+g[0][0],o[1][0]=+g[1][0],o[0][1]=+g[0][1],o[1][1]=+g[1][1],y):[[o[0][0],o[0][1]],[o[1][0],o[1][1]]]},y.constrain=function(g){return arguments.length?(n=g,y):n},y.duration=function(g){return arguments.length?(a=+g,y):a},y.interpolate=function(g){return arguments.length?(l=g,y):l},y.on=function(){var g=u.on.apply(u,arguments);return g===u?y:g},y.clickDistance=function(g){return arguments.length?(x=(g=+g)*g,y):Math.sqrt(x)},y.tapDistance=function(g){return arguments.length?(v=+g,y):v},y}const Se={error001:()=>"[React Flow]: Seems like you have not used zustand provider as an ancestor. Help: https://reactflow.dev/error#001",error002:()=>"It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.",error003:e=>`Node type "${e}" not found. Using fallback type "default".`,error004:()=>"The React Flow parent container needs a width and a height to render the graph.",error005:()=>"Only child nodes can use a parent extent.",error006:()=>"Can't create edge. An edge needs a source and a target.",error007:e=>`The old edge with id=${e} does not exist.`,error009:e=>`Marker type "${e}" doesn't exist.`,error008:(e,{id:t,sourceHandle:n,targetHandle:r})=>`Couldn't create edge for ${e} handle id: "${e==="source"?n:r}", edge id: ${t}.`,error010:()=>"Handle: No node id found. Make sure to only use a Handle inside a custom Node.",error011:e=>`Edge type "${e}" not found. Using fallback type "default".`,error012:e=>`Node with id "${e}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`,error013:(e="react")=>`It seems that you haven't loaded the styles. Please import '@xyflow/${e}/dist/style.css' or base.css to make sure everything is working properly.`},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 He;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(He||(He={}));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 Ie;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(Ie||(Ie={}));var tn;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(tn||(tn={}));var K;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(K||(K={}));const es={[K.Left]:K.Right,[K.Right]:K.Left,[K.Top]:K.Bottom,[K.Bottom]:K.Top};function Si(e){return e===null?null:e?"valid":"invalid"}const Ei=e=>"id"in e&&"source"in e&&"target"in e,Kd=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}=Ee(e),s=e.origin??t,i=n*s[0],o=r*s[1];return{x:e.position.x-i,y:e.position.y-o}},Gd=(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,m=d.height??u.height??u.initialHeight??null,x=Nt(a,et(u)),v=(p??0)*(m??0),y=i&&x>0;(!u.internals.handleBounds||y||x>=v||u.dragging)&&l.push(u)}return l},Ud=(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",Se.error005());else{const p=a.measured.width,m=a.measured.height;p&&m&&(f=[[l,u],[l+p,u+m]])}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 Zd({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),m=!p&&h.parentId&&o.find(x=>x.id===h.parentId);(p||m)&&o.push(h)}const a=new Set(t.map(h=>h.id)),l=r.filter(h=>h.deletable!==!1),d=Ud(o,l);for(const h of l)a.has(h.id)&&!d.find(m=>m.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}=Ee(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),Qd=(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 Ee(e){var t,n;return{width:((t=e.measured)==null?void 0:t.width)??e.width??e.initialWidth??0,height:((n=e.measured)==null?void 0:n.height)??e.height??e.initialHeight??0}}function 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}=ve(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)},Jd=["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 Jd.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,ve=(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 K.Left:return[t-Dt(t-r,i),n];case K.Right:return[t+Dt(r-t,i),n];case K.Top:return[t,n-Dt(n-s,i)];case K.Bottom:return[t,n+Dt(s-n,i)]}}function Li({sourceX:e,sourceY:t,sourcePosition:n=K.Bottom,targetX:r,targetY:s,targetPosition:i=K.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,m]=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,m]}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 ef({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 tf({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 nf=({source:e,sourceHandle:t,target:n,targetHandle:r})=>`xy-edge__${e}${t||""}-${n}${r||""}`,rf=(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)),sf=(e,t)=>{if(!e.source||!e.target)return t;let n;return Ei(e)?n={...e}:n={...e,id:nf(e)},rf(n,t)?t:(n.sourceHandle===null&&delete n.sourceHandle,n.targetHandle===null&&delete n.targetHandle,t.concat(n))};function Fi({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={[K.Left]:{x:-1,y:0},[K.Right]:{x:1,y:0},[K.Top]:{x:0,y:-1},[K.Bottom]:{x:0,y:1}},of=({source:e,sourcePosition:t=K.Bottom,target:n})=>t===K.Left||t===K.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 af({source:e,sourcePosition:t=K.Bottom,target:n,targetPosition:r=K.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=of({source:l,sourcePosition:t,target:u}),f=d.x!==0?"x":"y",h=d[f];let p=[],m,x;const v={x:0,y:0},y={x:0,y:0},[N,b,w,$]=Hi({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(o[f]*a[f]===-1){m=s.x??N,x=s.y??b;const C=[{x:m,y:l.y},{x:m,y:u.y}],T=[{x:l.x,y:x},{x:u.x,y:x}];o[f]===h?p=f==="x"?C:T:p=f==="x"?T:C}else{const C=[{x:l.x,y:u.y}],T=[{x:u.x,y:l.y}];if(f==="x"?p=o.x===h?T:C:p=o.y===h?C:T,t===r){const A=Math.abs(e[f]-n[f]);if(A<=i){const g=Math.min(i-1,i-A);o[f]===h?v[f]=(l[f]>e[f]?-1:1)*g:y[f]=(u[f]>n[f]?-1:1)*g}}if(t!==r){const A=f==="x"?"y":"x",g=o[f]===a[A],S=l[A]>u[A],_=l[A]<u[A];(o[f]===1&&(!g&&S||g&&_)||o[f]!==1&&(!g&&_||g&&S))&&(p=f==="x"?C:T)}const P={x:l.x+v.x,y:l.y+v.y},E={x:u.x+y.x,y:u.y+y.y},O=Math.max(Math.abs(P.x-p[0].x),Math.abs(E.x-p[0].x)),L=Math.max(Math.abs(P.y-p[0].y),Math.abs(E.y-p[0].y));O>=L?(m=(P.x+E.x)/2,x=p[0].y):(m=p[0].x,x=(P.y+E.y)/2)}return[[e,{x:l.x+v.x,y:l.y+v.y},...p,{x:u.x+y.x,y:u.y+y.y},n],m,x,w,$]}function cf(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=K.Bottom,targetX:r,targetY:s,targetPosition:i=K.Top,borderRadius:o=5,centerX:a,centerY:l,offset:u=20}){const[d,f,h,p,m]=af({source:{x:e,y:t},sourcePosition:n,target:{x:r,y:s},targetPosition:i,center:{x:a,y:l},offset:u});return[d.reduce((v,y,N)=>{let b="";return N>0&&N<d.length-1?b=cf(d[N-1],y,d[N+1],o):b=`${N===0?"M":"L"}${y.x} ${y.y}`,v+=b,v},""),f,h,p,m]}function as(e){var t;return e&&!!(e.internals.handleBounds||(t=e.handles)!=null&&t.length)&&!!(e.measured.width||e.width||e.initialWidth)}function lf(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",Se.error008(i?"target":"source",{id:e.id,sourceHandle:e.sourceHandle,targetHandle:e.targetHandle})),null;const a=(i==null?void 0:i.position)||K.Bottom,l=(o==null?void 0:o.position)||K.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=K.Left,r=!1){const s=((t==null?void 0:t.x)??0)+e.internals.positionAbsolute.x,i=((t==null?void 0:t.y)??0)+e.internals.positionAbsolute.y,{width:o,height:a}=t??Ee(e);if(r)return{x:s+o/2,y:i+a/2};switch((t==null?void 0:t.position)??n){case K.Top:return{x:s+o/2,y:i};case K.Right:return{x:s+o,y:i+a/2};case K.Bottom:return{x:s+o/2,y:i+a};case K.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 uf(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:{}},df={...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 ff(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,Ee(s));s.internals.positionAbsolute=a}}function sr(e,t,n,r){var a,l;const s=yr(df,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,Ee(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:Oi(u,o),userNode:u}},t.set(u.id,d)}u.parentId&&wr(d,t,n,r)}}function hf(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}hf(e,n);const u=s?1e3:0,{x:d,y:f,z:h}=pf(e,l,i,o,u),{positionAbsolute:p}=e.internals,m=d!==p.x||f!==p.y;(m||h!==e.internals.z)&&(e.internals={...e.internals,positionAbsolute:m?{x:d,y:f}:p,z:h})}function Oi(e,t){return(he(e.zIndex)?e.zIndex:0)+(e.selected?t:0)}function pf(e,t,n,r,s){const{x:i,y:o}=t.internals.positionAbsolute,a=Ee(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=Oi(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 b;const d=l.internals.positionAbsolute,f=Ee(l),h=l.origin??r,p=a.x<d.x?Math.round(Math.abs(d.x-a.x)):0,m=a.y<d.y?Math.round(Math.abs(d.y-a.y)):0,x=Math.max(f.width,Math.round(a.width)),v=Math.max(f.height,Math.round(a.height)),y=(x-f.width)*h[0],N=(v-f.height)*h[1];(p>0||m>0||y||N)&&(s.push({id:u,type:"position",position:{x:l.position.x-p+y,y:l.position.y-m+N}}),(b=n.get(u))==null||b.forEach(w=>{e.some($=>$.id===w.id)||s.push({id:w.id,type:"position",position:{x:w.position.x+p,y:w.position.y+m}})})),(f.width<a.width||f.height<a.height||p||m)&&s.push({id:u,type:"dimensions",setAttributes:!0,dimensions:{width:x+(p?h[0]*p-y:0),height:v+(m?h[1]*m-N:0)}})}),s}function gf(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 m=mn(h.nodeElement),x=p.measured.width!==m.width||p.measured.height!==m.height;if(!!(m.width&&m.height&&(x||!p.internals.handleBounds||h.force))){const y=h.nodeElement.getBoundingClientRect(),N=tt(p.extent)?p.extent:i;let{positionAbsolute:b}=p.internals;p.parentId&&p.extent==="parent"?b=$i(b,m,t.get(p.parentId)):N&&(b=Oe(b,N,m)),p.measured=m,p.internals={...p.internals,positionAbsolute:b,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:m}),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 mf({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 Bi(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 xf(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 yf({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 m({noDragClassName:v,handleSelector:y,domNode:N,isSelectable:b,nodeId:w,nodeClickDistance:$=0}){h=le(N);function D({x:E,y:O},L){const{nodeLookup:A,nodeExtent:g,snapGrid:S,snapToGrid:_,nodeOrigin:z,onNodeDrag:k,onSelectionDrag:j,onError:I,updateNodePositions:H}=t();i={x:E,y:O};let B=!1,Y={x:0,y:0,x2:0,y2:0};if(a.size>1&&g){const X=Ct(a);Y=er(X)}for(const[X,V]of a){if(!A.has(X))continue;let R={x:E-V.distance.x,y:O-V.distance.y};_&&(R=gn(R,S));let q=[[g[0][0],g[0][1]],[g[1][0],g[1][1]]];if(a.size>1&&g&&!V.extent){const{positionAbsolute:U}=V.internals,Z=U.x-Y.x+g[0][0],G=U.x+V.measured.width-Y.x2+g[1][0],J=U.y-Y.y+g[0][1],ee=U.y+V.measured.height-Y.y2+g[1][1];q=[[Z,J],[G,ee]]}const{position:F,positionAbsolute:W}=Ci({nodeId:X,nextPosition:R,nodeLookup:A,nodeExtent:q,nodeOrigin:z,onError:I});B=B||V.position.x!==F.x||V.position.y!==F.y,V.position=F,V.internals.positionAbsolute=W}if(B&&(H(a,!0),L&&(r||k||!w&&j))){const[X,V]=Tn({nodeId:w,dragItems:a,nodeLookup:A});r==null||r(L,a,X,V),k==null||k(L,X,V),w||j==null||j(L,V)}}async function C(){if(!d)return;const{transform:E,panBy:O,autoPanSpeed:L}=t(),[A,g]=Mi(u,d,L);(A!==0||g!==0)&&(i.x=(i.x??0)-A/E[2],i.y=(i.y??0)-g/E[2],await O({x:A,y:g})&&D(i,null)),o=requestAnimationFrame(C)}function T(E){var B;const{nodeLookup:O,multiSelectionActive:L,nodesDraggable:A,transform:g,snapGrid:S,snapToGrid:_,selectNodesOnDrag:z,onNodeDragStart:k,onSelectionDragStart:j,unselectNodesAndEdges:I}=t();f=!0,(!z||!b)&&!L&&w&&((B=O.get(w))!=null&&B.selected||I()),b&&z&&w&&(e==null||e(w));const H=ht(E.sourceEvent,{transform:g,snapGrid:S,snapToGrid:_,containerBounds:d});if(i=H,a=xf(O,A,H,w),a.size>0&&(n||k||!w&&j)){const[Y,X]=Tn({nodeId:w,dragItems:a,nodeLookup:O});n==null||n(E.sourceEvent,a,Y,X),k==null||k(E.sourceEvent,Y,X),w||j==null||j(E.sourceEvent,X)}}const P=ai().clickDistance($).on("start",E=>{const{domNode:O,nodeDragThreshold:L,transform:A,snapGrid:g,snapToGrid:S}=t();d=(O==null?void 0:O.getBoundingClientRect())||null,p=!1,L===0&&T(E),i=ht(E.sourceEvent,{transform:A,snapGrid:g,snapToGrid:S,containerBounds:d}),u=ve(E.sourceEvent,d)}).on("drag",E=>{const{autoPanOnNodeDrag:O,transform:L,snapGrid:A,snapToGrid:g,nodeDragThreshold:S,nodeLookup:_}=t(),z=ht(E.sourceEvent,{transform:L,snapGrid:A,snapToGrid:g,containerBounds:d});if((E.sourceEvent.type==="touchmove"&&E.sourceEvent.touches.length>1||w&&!_.has(w))&&(p=!0),!p){if(!l&&O&&f&&(l=!0,C()),!f){const k=z.xSnapped-(i.x??0),j=z.ySnapped-(i.y??0);Math.sqrt(k*k+j*j)>S&&T(E)}(i.x!==z.xSnapped||i.y!==z.ySnapped)&&a&&f&&(u=ve(E.sourceEvent,d),D(z,E.sourceEvent))}}).on("end",E=>{if(!(!f||p)&&(l=!1,f=!1,cancelAnimationFrame(o),a.size>0)){const{nodeLookup:O,updateNodePositions:L,onNodeDragStop:A,onSelectionDragStop:g}=t();if(L(a,!1),s||A||!w&&g){const[S,_]=Tn({nodeId:w,dragItems:a,nodeLookup:O,dragging:!1});s==null||s(E.sourceEvent,a,S,_),A==null||A(E.sourceEvent,S,_),w||g==null||g(E.sourceEvent,_)}}}).filter(E=>{const O=E.target;return!E.button&&(!v||!us(O,`.${v}`,N))&&(!y||us(O,y,N))});h.call(P)}function x(){h==null||h.on(".drag",null)}return{update:m,destroy:x}}function wf(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 bf=250;function vf(e,t,n,r){var a,l;let s=[],i=1/0;const o=wf(e,n,t+bf);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),m=Math.sqrt(Math.pow(h-e.x,2)+Math.pow(p-e.y,2));m>t||(m<i?(s=[{...f,x:h,y:p}],i=m):m===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 Nf(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}const Yi=()=>!0;function _f(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:m,onConnect:x,onConnectEnd:v,isValidConnection:y=Yi,onReconnectEnd:N,updateConnection:b,getTransform:w,getFromHandle:$,autoPanSpeed:D}){const C=Ti(e.target);let T=0,P;const{x:E,y:O}=ve(e),L=C==null?void 0:C.elementFromPoint(E,O),A=Xi(i,L),g=a==null?void 0:a.getBoundingClientRect();if(!g||!A)return;const S=qi(s,A,r,l,t);if(!S)return;let _=ve(e,g),z=!1,k=null,j=!1,I=null;function H(){if(!d||!g)return;const[W,U]=Mi(_,g,D);h({x:W,y:U}),T=requestAnimationFrame(H)}const B={...S,nodeId:s,type:A,position:S.position},Y=l.get(s),V={inProgress:!0,isValid:null,from:_t(Y,B,K.Left,!0),fromHandle:B,fromPosition:B.position,fromNode:Y,to:_,toHandle:null,toPosition:es[B.position],toNode:null};b(V);let R=V;m==null||m(e,{nodeId:s,handleId:r,handleType:A});function q(W){if(!$()||!B){F(W);return}const U=w();_=ve(W,g),P=vf($t(_,U,!1,[1,1]),n,l,B),z||(H(),z=!0);const Z=Wi(W,{handle:P,connectionMode:t,fromNodeId:s,fromHandleId:r,fromType:o?"target":"source",isValidConnection:y,doc:C,lib:u,flowId:f,nodeLookup:l});I=Z.handleDomNode,k=Z.connection,j=Nf(!!P,Z.isValid);const G={...R,isValid:j,to:P&&j?Ii({x:P.x,y:P.y},U):_,toHandle:Z.toHandle,toPosition:j&&Z.toHandle?Z.toHandle.position:es[B.position],toNode:Z.toHandle?l.get(Z.toHandle.nodeId):null};j&&P&&R.toHandle&&G.toHandle&&R.toHandle.type===G.toHandle.type&&R.toHandle.nodeId===G.toHandle.nodeId&&R.toHandle.id===G.toHandle.id&&R.to.x===G.to.x&&R.to.y===G.to.y||(b(G),R=G)}function F(W){(P||I)&&k&&j&&(x==null||x(k));const{inProgress:U,...Z}=R,G={...Z,toPosition:R.toHandle?R.toPosition:null};v==null||v(W,G),i&&(N==null||N(W,G)),p(),cancelAnimationFrame(T),z=!1,j=!1,k=null,I=null,C.removeEventListener("mousemove",q),C.removeEventListener("mouseup",F),C.removeEventListener("touchmove",q),C.removeEventListener("touchend",F)}C.addEventListener("mousemove",q),C.addEventListener("mouseup",F),C.addEventListener("touchmove",q),C.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:m}=ve(e),x=o.elementFromPoint(p,m),v=x!=null&&x.classList.contains(`${a}-flow__handle`)?x:h,y={handleDomNode:v,isValid:!1,connection:null,toHandle:null};if(v){const N=Xi(void 0,v),b=v.getAttribute("data-nodeid"),w=v.getAttribute("data-handleid"),$=v.classList.contains("connectable"),D=v.classList.contains("connectableend");if(!b||!N)return y;const C={source:f?b:r,sourceHandle:f?w:s,target:f?r:b,targetHandle:f?s:w};y.connection=C;const P=$&&D&&(n===Qe.Strict?f&&N==="source"||!f&&N==="target":b!==r||w!==s);y.isValid=P&&u(C),y.toHandle=qi(b,N,w,d,n,!1)}return y}const ir={onPointerDown:_f,isValid:Wi};function kf({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 m=b=>{const w=n();if(b.sourceEvent.type!=="wheel"||!t)return;const $=-b.sourceEvent.deltaY*(b.sourceEvent.deltaMode===1?.05:b.sourceEvent.deltaMode?1:.002)*d,D=w[2]*Math.pow(2,$);t.scaleTo(D)};let x=[0,0];const v=b=>{(b.sourceEvent.type==="mousedown"||b.sourceEvent.type==="touchstart")&&(x=[b.sourceEvent.clientX??b.sourceEvent.touches[0].clientX,b.sourceEvent.clientY??b.sourceEvent.touches[0].clientY])},y=b=>{const w=n();if(b.sourceEvent.type!=="mousemove"&&b.sourceEvent.type!=="touchmove"||!t)return;const $=[b.sourceEvent.clientX??b.sourceEvent.touches[0].clientX,b.sourceEvent.clientY??b.sourceEvent.touches[0].clientY],D=[$[0]-x[0],$[1]-x[1]];x=$;const C=r()*Math.max(w[2],Math.log(w[2]))*(p?-1:1),T={x:w[0]-D[0]*C,y:w[1]-D[1]*C},P=[[0,0],[l,u]];t.setViewportConstrained({x:T.x,y:T.y,zoom:w[2]},P,a)},N=Ni().on("start",v).on("zoom",f?y:null).on("zoom.wheel",h?m:null);s.call(N,{})}function o(){s.on("zoom",null)}return{update:i,destroy:o,pointer:de}}const Sf=(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),Xe=(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 Ef({zoomPanValues:e,noWheelClassName:t,d3Selection:n,d3Zoom:r,panOnScrollMode:s,panOnScrollSpeed:i,zoomOnPinch:o,onPanZoomStart:a,onPanZoom:l,onPanZoomEnd:u}){return d=>{if(Xe(d,t))return!1;d.preventDefault(),d.stopImmediatePropagation();const f=n.property("__zoom").k||1;if(d.ctrlKey&&o){const v=de(d),y=Gi(d),N=f*Math.pow(2,y);r.scaleTo(n,N,v,d);return}const h=d.deltaMode===1?20:1;let p=s===He.Vertical?0:d.deltaX*h,m=s===He.Horizontal?0:d.deltaY*h;!rn()&&d.shiftKey&&s!==He.Vertical&&(p=d.deltaY*h,m=0),r.translateBy(n,-(p/f)*i,-(m/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 jf({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:n}){return function(r,s){if(!t&&r.type==="wheel"&&!r.ctrlKey||Xe(r,e))return null;r.preventDefault(),n.call(this,r,s)}}function Cf({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 $f({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 Mf({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&&Sf(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 zf({zoomActivationKeyPressed:e,zoomOnScroll:t,zoomOnPinch:n,panOnDrag:r,panOnScroll:s,zoomOnDoubleClick:i,userSelectionActive:o,noWheelClassName:a,noPanClassName:l,lib:u}){return d=>{var m;const f=e||t,h=n&&d.ctrlKey;if(d.button===1&&d.type==="mousedown"&&(Xe(d,`${u}-flow__node`)||Xe(d,`${u}-flow__edge`)))return!0;if(!r&&!f&&!s&&!i&&!n||o||Xe(d,a)&&d.type==="wheel"||Xe(d,l)&&(d.type!=="wheel"||s&&d.type==="wheel"&&!e)||!n&&d.ctrlKey&&d.type==="wheel")return!1;if(!n&&d.type==="touchstart"&&((m=d.touches)==null?void 0:m.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 If({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);b({x:i.x,y:i.y,zoom:Je(i.zoom,t,n)},[[0,0],[f.width,f.height]],s);const m=p.on("wheel.zoom"),x=p.on("dblclick.zoom");h.wheelDelta(Gi);function v(L,A){return p?new Promise(g=>{h==null||h.transform(Rn(p,A==null?void 0:A.duration,()=>g(!0)),L)}):Promise.resolve(!1)}function y({noWheelClassName:L,noPanClassName:A,onPaneContextMenu:g,userSelectionActive:S,panOnScroll:_,panOnDrag:z,panOnScrollMode:k,panOnScrollSpeed:j,preventScrolling:I,zoomOnPinch:H,zoomOnScroll:B,zoomOnDoubleClick:Y,zoomActivationKeyPressed:X,lib:V,onTransformChange:R}){S&&!d.isZoomingOrPanning&&N();const F=_&&!X&&!S?Ef({zoomPanValues:d,noWheelClassName:L,d3Selection:p,d3Zoom:h,panOnScrollMode:k,panOnScrollSpeed:j,zoomOnPinch:H,onPanZoomStart:a,onPanZoom:o,onPanZoomEnd:l}):jf({noWheelClassName:L,preventScrolling:I,d3ZoomHandler:m});if(p.on("wheel.zoom",F,{passive:!1}),!S){const U=Cf({zoomPanValues:d,onDraggingChange:u,onPanZoomStart:a});h.on("start",U);const Z=$f({zoomPanValues:d,panOnDrag:z,onPaneContextMenu:!!g,onPanZoom:o,onTransformChange:R});h.on("zoom",Z);const G=Mf({zoomPanValues:d,panOnDrag:z,panOnScroll:_,onPaneContextMenu:g,onPanZoomEnd:l,onDraggingChange:u});h.on("end",G)}const W=zf({zoomActivationKeyPressed:X,panOnDrag:z,zoomOnScroll:B,panOnScroll:_,zoomOnDoubleClick:Y,zoomOnPinch:H,userSelectionActive:S,noPanClassName:A,noWheelClassName:L,lib:V});h.filter(W),Y?p.on("dblclick.zoom",x):p.on("dblclick.zoom",null)}function N(){h.on("zoom",null)}async function b(L,A,g){const S=Dn(L),_=h==null?void 0:h.constrain()(S,A,g);return _&&await v(_),new Promise(z=>z(_))}async function w(L,A){const g=Dn(L);return await v(g,A),new Promise(S=>S(g))}function $(L){if(p){const A=Dn(L),g=p.property("__zoom");(g.k!==L.zoom||g.x!==L.x||g.y!==L.y)&&(h==null||h.transform(p,A,null,{sync:!0}))}}function D(){const L=p?vi(p.node()):{x:0,y:0,k:1};return{x:L.x,y:L.y,zoom:L.k}}function C(L,A){return p?new Promise(g=>{h==null||h.scaleTo(Rn(p,A==null?void 0:A.duration,()=>g(!0)),L)}):Promise.resolve(!1)}function T(L,A){return p?new Promise(g=>{h==null||h.scaleBy(Rn(p,A==null?void 0:A.duration,()=>g(!0)),L)}):Promise.resolve(!1)}function P(L){h==null||h.scaleExtent(L)}function E(L){h==null||h.translateExtent(L)}function O(L){const A=!he(L)||L<0?0:L;h==null||h.clickDistance(A)}return{update:y,destroy:N,setViewport:w,setViewportConstrained:b,getViewport:D,scaleTo:C,scaleBy:T,setScaleExtent:P,setTranslateExtent:E,syncViewport:$,setClickDistance:O}}var pt;(function(e){e.Line="line",e.Handle="handle"})(pt||(pt={}));function Af({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 Pf(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 $e(e,t){return Math.max(0,t-e)}function Me(e,t){return Math.max(0,e-t)}function Rt(e,t,n){return Math.max(0,t-e,e-n)}function ds(e,t){return e?!t:t}function Tf(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:m}=n,{minWidth:x,maxWidth:v,minHeight:y,maxHeight:N}=r,{x:b,y:w,width:$,height:D,aspectRatio:C}=e;let T=Math.floor(d?p-e.pointerX:0),P=Math.floor(f?m-e.pointerY:0);const E=$+(l?-T:T),O=D+(u?-P:P),L=-i[0]*$,A=-i[1]*D;let g=Rt(E,x,v),S=Rt(O,y,N);if(o){let k=0,j=0;l&&T<0?k=$e(b+T+L,o[0][0]):!l&&T>0&&(k=Me(b+E+L,o[1][0])),u&&P<0?j=$e(w+P+A,o[0][1]):!u&&P>0&&(j=Me(w+O+A,o[1][1])),g=Math.max(g,k),S=Math.max(S,j)}if(a){let k=0,j=0;l&&T>0?k=Me(b+T,a[0][0]):!l&&T<0&&(k=$e(b+E,a[1][0])),u&&P>0?j=Me(w+P,a[0][1]):!u&&P<0&&(j=$e(w+O,a[1][1])),g=Math.max(g,k),S=Math.max(S,j)}if(s){if(d){const k=Rt(E/C,y,N)*C;if(g=Math.max(g,k),o){let j=0;!l&&!u||l&&!u&&h?j=Me(w+A+E/C,o[1][1])*C:j=$e(w+A+(l?T:-T)/C,o[0][1])*C,g=Math.max(g,j)}if(a){let j=0;!l&&!u||l&&!u&&h?j=$e(w+E/C,a[1][1])*C:j=Me(w+(l?T:-T)/C,a[0][1])*C,g=Math.max(g,j)}}if(f){const k=Rt(O*C,x,v)/C;if(S=Math.max(S,k),o){let j=0;!l&&!u||u&&!l&&h?j=Me(b+O*C+L,o[1][0])/C:j=$e(b+(u?P:-P)*C+L,o[0][0])/C,S=Math.max(S,j)}if(a){let j=0;!l&&!u||u&&!l&&h?j=$e(b+O*C,a[1][0])/C:j=Me(b+(u?P:-P)*C,a[0][0])/C,S=Math.max(S,j)}}}P=P+(P<0?S:-S),T=T+(T<0?g:-g),s&&(h?E>O*C?P=(ds(l,u)?-T:T)/C:T=(ds(l,u)?-P:P)*C:d?(P=T/C,u=l):(T=P*C,l=u));const _=l?b+T:b,z=u?w+P:w;return{width:$+(l?-T:T),height:D+(u?-P:P),x:i[0]*T*(l?-1:1)+_,y:i[1]*P*(u?-1:1)+z}}const Ui={width:0,height:0,x:0,y:0},Df={...Ui,pointerX:0,pointerY:0,aspectRatio:1};function Rf(e){return[[0,0],[e.measured.width,e.measured.height]]}function Lf(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 Hf({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:m}){let x={...Ui},v={...Df};const y=Pf(l);let N,b=null,w=[],$,D,C;const T=ai().on("start",P=>{const{nodeLookup:E,transform:O,snapGrid:L,snapToGrid:A,nodeOrigin:g,paneDomNode:S}=n();if(N=E.get(t),!N)return;b=(S==null?void 0:S.getBoundingClientRect())??null;const{xSnapped:_,ySnapped:z}=ht(P.sourceEvent,{transform:O,snapGrid:L,snapToGrid:A,containerBounds:b});x={width:N.measured.width??0,height:N.measured.height??0,x:N.position.x??0,y:N.position.y??0},v={...x,pointerX:_,pointerY:z,aspectRatio:x.width/x.height},$=void 0,N.parentId&&(N.extent==="parent"||N.expandParent)&&($=E.get(N.parentId),D=$&&N.extent==="parent"?Rf($):void 0),w=[],C=void 0;for(const[k,j]of E)if(j.parentId===t&&(w.push({id:k,position:{...j.position},extent:j.extent}),j.extent==="parent"||j.expandParent)){const I=Lf(j,N,j.origin??g);C?C=[[Math.min(I[0][0],C[0][0]),Math.min(I[0][1],C[0][1])],[Math.max(I[1][0],C[1][0]),Math.max(I[1][1],C[1][1])]]:C=I}f==null||f(P,{...x})}).on("drag",P=>{const{transform:E,snapGrid:O,snapToGrid:L,nodeOrigin:A}=n(),g=ht(P.sourceEvent,{transform:E,snapGrid:O,snapToGrid:L,containerBounds:b}),S=[];if(!N)return;const{x:_,y:z,width:k,height:j}=x,I={},H=N.origin??A,{width:B,height:Y,x:X,y:V}=Tf(v,y,g,u,d,H,D,C),R=B!==k,q=Y!==j,F=X!==_&&R,W=V!==z&&q;if(!F&&!W&&!R&&!q)return;if((F||W||H[0]===1||H[1]===1)&&(I.x=F?X:x.x,I.y=W?V:x.y,x.x=I.x,x.y=I.y,w.length>0)){const J=X-_,ee=V-z;for(const ie of w)ie.position={x:ie.position.x-J+H[0]*(B-k),y:ie.position.y-ee+H[1]*(Y-j)},S.push(ie)}if((R||q)&&(I.width=R?B:x.width,I.height=q?Y:x.height,x.width=I.width,x.height=I.height),$&&N.expandParent){const J=H[0]*(I.width??0);I.x&&I.x<J&&(x.x=J,v.x=v.x-(I.x-J));const ee=H[1]*(I.height??0);I.y&&I.y<ee&&(x.y=ee,v.y=v.y-(I.y-ee))}const U=Af({width:x.width,prevWidth:k,height:x.height,prevHeight:j,affectsX:y.affectsX,affectsY:y.affectsY}),Z={...x,direction:U};(m==null?void 0:m(P,Z))!==!1&&(h==null||h(P,Z),r(I,S))}).on("end",P=>{p==null||p(P,{...x}),s==null||s()});i.call(T)}function a(){i.on(".drag",null)}return{update:o,destroy:a}}var Zi={exports:{}},Qi={},Ji={exports:{}},eo={};/**
|
|
2
2
|
* @license React
|
|
3
3
|
* use-sync-external-store-shim.production.js
|
|
4
4
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Q as o,y as l,j as a,r as i,z as c,R as m}from"./index-
|
|
1
|
+
import{Q as o,y as l,j as a,r as i,z as c,R as m}from"./index-B8Ij4B8D.js";const e=n=>new Date(n).toISOString(),t=Date.parse("2026-06-22T14:00:00.000Z"),p="gather:1",u=[{name:"handle_AF_FLEET",start:2e3,end:8200},{name:"handle_MEL",start:2120,end:6900},{name:"handle_METADATA",start:2050,end:5400},{name:"handle_MVR",start:2300,end:9600,failed:!0},{name:"handle_SCHED_MX",start:2080,end:7300},{name:"handle_SUBWO",start:2260,end:8900},{name:"handle_UTIL",start:2010,end:4700}],h=u.map((n,d)=>({runId:"mock-run",seq:2+d,name:n.name,kind:"remote",status:n.failed?"failed":"completed",parallelGroup:p,attempts:1,workerGroup:"gather",startedAt:e(t+n.start),finishedAt:e(t+n.end),...n.failed?{error:{message:"MVR lookup timed out after 7s"}}:{}})),f=[{runId:"mock-run",seq:1,name:"setup",kind:"local",status:"completed",attempts:1,startedAt:e(t+0),finishedAt:e(t+1800)},...h,{runId:"mock-run",seq:9,name:"finalize",kind:"local",status:"completed",attempts:1,startedAt:e(t+9700),finishedAt:e(t+11200)}],s={run:{id:"mock-run",workflow:"gatherAircraftData",workflowVersion:"1",status:"completed",createdAt:e(t),updatedAt:e(t+11200)},timeline:f},x=new o({defaultOptions:{queries:{refetchInterval:!1,refetchOnWindowFocus:!1}}}),r=()=>{};l(document.getElementById("root")).render(a.jsx(i.StrictMode,{children:a.jsxs(c,{client:x,children:[a.jsx("div",{className:"app-bg"}),a.jsxs("div",{className:"relative z-10 mx-auto max-w-3xl p-8",children:[a.jsx("div",{className:"mb-3 mono text-[10px] uppercase tracking-[0.2em] text-zinc-500",children:"preview · parallel-fan timeline"}),a.jsx("div",{className:"rounded-lg border border-[var(--line)] bg-[var(--panel)] p-2",children:a.jsx(m,{run:s.run,timeline:s.timeline,depth:0,selectedKey:void 0,onSelect:r,onOpenRun:r,expanded:new Set,onToggleChild:r})})]})]})}));
|
package/dist/spa/index.html
CHANGED
|
@@ -10,8 +10,8 @@
|
|
|
10
10
|
rel="stylesheet"
|
|
11
11
|
/>
|
|
12
12
|
<title>durable · control plane</title>
|
|
13
|
-
<script type="module" crossorigin src="/durable/assets/index-
|
|
14
|
-
<link rel="modulepreload" crossorigin href="/durable/assets/index-
|
|
13
|
+
<script type="module" crossorigin src="/durable/assets/index-CBmp6c1z.js"></script>
|
|
14
|
+
<link rel="modulepreload" crossorigin href="/durable/assets/index-B8Ij4B8D.js">
|
|
15
15
|
<link rel="stylesheet" crossorigin href="/durable/assets/index-BZvGo5bE.css">
|
|
16
16
|
<link rel="stylesheet" crossorigin href="/durable/assets/index-B2Kz5wtG.css">
|
|
17
17
|
</head>
|