@owox/web 0.31.0-next-20260805164607 → 0.31.0
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/assets/{ModelCanvas-BKbWq-mR.js → ModelCanvas-B3mLkYki.js} +2 -2
- package/dist/assets/{RelationshipCanvas-j6bBgQbJ.js → RelationshipCanvas-DclL-ubu.js} +1 -1
- package/dist/assets/{erd-card-BrXYWEzQ.js → erd-card-CzRH59fS.js} +1 -1
- package/dist/assets/index-CAz55S73.js +1417 -0
- package/dist/assets/{index-WPu5BZlZ.js → index-Cy8YfGgG.js} +1 -1
- package/dist/index.html +1 -1
- package/package.json +3 -12
- package/dist/assets/index-DfxbkXTR.js +0 -1417
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-
|
|
2
|
-
import{r as k,j as h,q as Dn,t as Rn,v as Ne,P as Lt,d as St,D as je,e as Tt,f as ge,w as Pn,L as Mn,x as An,y as Fn,T as Dt,a as Rt,z as $n,H as Hn,b as Pt,A as Gn,I as Vn,E as Bn,F as Un,G as zn,K as Yn,s as G,_ as Wn,J as Mt,c as he,S as Qn,h as Je,g as qn}from"./index-DfxbkXTR.js";import{n as Kn,p as Jn,q as Xn,W as Zn,l as Ae,o as er,B as tr,D as Fe,r as nr,s as rr,t as ir,d as At,P as fe,k as ke,H as Xe,S as Ze,E as or,a as sr,j as ar,N as lr,R as dr,u as ur,b as Oe,g as cr,c as et,e as tt,v as hr,w as fr,f as gr,L as pr,Z as mr,h as br,i as vr,M as wr,m as Er}from"./erd-card-BrXYWEzQ.js";const xr=[{value:"horizontal",label:"Horizontal"},{value:"vertical",label:"Vertical"}];function yr(e){return e==="vertical"?"vertical":"horizontal"}var Ft=Object.defineProperty,_r=(e,t,n)=>t in e?Ft(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Nr=(e,t)=>{for(var n in t)Ft(e,n,{get:t[n],enumerable:!0})},jr=(e,t,n)=>_r(e,t+"",n),$t={};Nr($t,{Graph:()=>H,alg:()=>He,json:()=>Gt,version:()=>Ir});var kr=Object.defineProperty,Ht=(e,t)=>{for(var n in t)kr(e,n,{get:t[n],enumerable:!0})},H=class{constructor(e){this._isDirected=!0,this._isMultigraph=!1,this._isCompound=!1,this._nodes={},this._in={},this._preds={},this._out={},this._sucs={},this._edgeObjs={},this._edgeLabels={},this._nodeCount=0,this._edgeCount=0,this._defaultNodeLabelFn=()=>{},this._defaultEdgeLabelFn=()=>{},e&&(this._isDirected="directed"in e?e.directed:!0,this._isMultigraph="multigraph"in e?e.multigraph:!1,this._isCompound="compound"in e?e.compound:!1),this._isCompound&&(this._parent={},this._children={},this._children["\0"]={})}isDirected(){return this._isDirected}isMultigraph(){return this._isMultigraph}isCompound(){return this._isCompound}setGraph(e){return this._label=e,this}graph(){return this._label}setDefaultNodeLabel(e){return typeof e!="function"?this._defaultNodeLabelFn=()=>e:this._defaultNodeLabelFn=e,this}nodeCount(){return this._nodeCount}nodes(){return Object.keys(this._nodes)}sources(){return this.nodes().filter(e=>Object.keys(this._in[e]).length===0)}sinks(){return this.nodes().filter(e=>Object.keys(this._out[e]).length===0)}setNodes(e,t){return e.forEach(n=>{t!==void 0?this.setNode(n,t):this.setNode(n)}),this}setNode(e,t){return e in this._nodes?(arguments.length>1&&(this._nodes[e]=t),this):(this._nodes[e]=arguments.length>1?t:this._defaultNodeLabelFn(e),this._isCompound&&(this._parent[e]="\0",this._children[e]={},this._children["\0"][e]=!0),this._in[e]={},this._preds[e]={},this._out[e]={},this._sucs[e]={},++this._nodeCount,this)}node(e){return this._nodes[e]}hasNode(e){return e in this._nodes}removeNode(e){if(e in this._nodes){let t=n=>this.removeEdge(this._edgeObjs[n]);delete this._nodes[e],this._isCompound&&(this._removeFromParentsChildList(e),delete this._parent[e],this.children(e).forEach(n=>{this.setParent(n)}),delete this._children[e]),Object.keys(this._in[e]).forEach(t),delete this._in[e],delete this._preds[e],Object.keys(this._out[e]).forEach(t),delete this._out[e],delete this._sucs[e],--this._nodeCount}return this}setParent(e,t){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(t===void 0)t="\0";else{t+="";for(let n=t;n!==void 0;n=this.parent(n))if(n===e)throw new Error("Setting "+t+" as parent of "+e+" would create a cycle");this.setNode(t)}return this.setNode(e),this._removeFromParentsChildList(e),this._parent[e]=t,this._children[t][e]=!0,this}parent(e){if(this._isCompound){let t=this._parent[e];if(t!=="\0")return t}}children(e="\0"){if(this._isCompound){let t=this._children[e];if(t)return Object.keys(t)}else{if(e==="\0")return this.nodes();if(this.hasNode(e))return[]}return[]}predecessors(e){let t=this._preds[e];if(t)return Object.keys(t)}successors(e){let t=this._sucs[e];if(t)return Object.keys(t)}neighbors(e){let t=this.predecessors(e);if(t){let n=new Set(t);for(let r of this.successors(e))n.add(r);return Array.from(n.values())}}isLeaf(e){let t;return this.isDirected()?t=this.successors(e):t=this.neighbors(e),t.length===0}filterNodes(e){let t=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});t.setGraph(this.graph()),Object.entries(this._nodes).forEach(([i,o])=>{e(i)&&t.setNode(i,o)}),Object.values(this._edgeObjs).forEach(i=>{t.hasNode(i.v)&&t.hasNode(i.w)&&t.setEdge(i,this.edge(i))});let n={},r=i=>{let o=this.parent(i);return!o||t.hasNode(o)?(n[i]=o??void 0,o??void 0):o in n?n[o]:r(o)};return this._isCompound&&t.nodes().forEach(i=>t.setParent(i,r(i))),t}setDefaultEdgeLabel(e){return typeof e!="function"?this._defaultEdgeLabelFn=()=>e:this._defaultEdgeLabelFn=e,this}edgeCount(){return this._edgeCount}edges(){return Object.values(this._edgeObjs)}setPath(e,t){return e.reduce((n,r)=>(t!==void 0?this.setEdge(n,r,t):this.setEdge(n,r),r)),this}setEdge(e,t,n,r){let i,o,s,a,l=!1;typeof e=="object"&&e!==null&&"v"in e?(i=e.v,o=e.w,s=e.name,arguments.length===2&&(a=t,l=!0)):(i=e,o=t,s=r,arguments.length>2&&(a=n,l=!0)),i=""+i,o=""+o,s!==void 0&&(s=""+s);let d=oe(this._isDirected,i,o,s);if(d in this._edgeLabels)return l&&(this._edgeLabels[d]=a),this;if(s!==void 0&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(i),this.setNode(o),this._edgeLabels[d]=l?a:this._defaultEdgeLabelFn(i,o,s);let u=Or(this._isDirected,i,o,s);return i=u.v,o=u.w,Object.freeze(u),this._edgeObjs[d]=u,nt(this._preds[o],i),nt(this._sucs[i],o),this._in[o][d]=u,this._out[i][d]=u,this._edgeCount++,this}edge(e,t,n){let r=arguments.length===1?Ie(this._isDirected,e):oe(this._isDirected,e,t,n);return this._edgeLabels[r]}edgeAsObj(e,t,n){let r=arguments.length===1?this.edge(e):this.edge(e,t,n);return typeof r!="object"?{label:r}:r}hasEdge(e,t,n){return(arguments.length===1?Ie(this._isDirected,e):oe(this._isDirected,e,t,n))in this._edgeLabels}removeEdge(e,t,n){let r=arguments.length===1?Ie(this._isDirected,e):oe(this._isDirected,e,t,n),i=this._edgeObjs[r];if(i){let o=i.v,s=i.w;delete this._edgeLabels[r],delete this._edgeObjs[r],rt(this._preds[s],o),rt(this._sucs[o],s),delete this._in[s][r],delete this._out[o][r],this._edgeCount--}return this}inEdges(e,t){return this.isDirected()?this.filterEdges(this._in[e],e,t):this.nodeEdges(e,t)}outEdges(e,t){return this.isDirected()?this.filterEdges(this._out[e],e,t):this.nodeEdges(e,t)}nodeEdges(e,t){if(e in this._nodes)return this.filterEdges({...this._in[e],...this._out[e]},e,t)}_removeFromParentsChildList(e){delete this._children[this._parent[e]][e]}filterEdges(e,t,n){if(!e)return;let r=Object.values(e);return n?r.filter(i=>i.v===t&&i.w===n||i.v===n&&i.w===t):r}};function nt(e,t){e[t]?e[t]++:e[t]=1}function rt(e,t){e[t]!==void 0&&!--e[t]&&delete e[t]}function oe(e,t,n,r){let i=""+t,o=""+n;if(!e&&i>o){let s=i;i=o,o=s}return i+""+o+""+(r===void 0?"\0":r)}function Or(e,t,n,r){let i=""+t,o=""+n;if(!e&&i>o){let a=i;i=o,o=a}let s={v:i,w:o};return r&&(s.name=r),s}function Ie(e,t){return oe(e,t.v,t.w,t.name)}var Ir="4.0.1",Gt={};Ht(Gt,{read:()=>Tr,write:()=>Cr});function Cr(e){let t={options:{directed:e.isDirected(),multigraph:e.isMultigraph(),compound:e.isCompound()},nodes:Lr(e),edges:Sr(e)},n=e.graph();return n!==void 0&&(t.value=structuredClone(n)),t}function Lr(e){return e.nodes().map(t=>{let n=e.node(t),r=e.parent(t),i={v:t};return n!==void 0&&(i.value=n),r!==void 0&&(i.parent=r),i})}function Sr(e){return e.edges().map(t=>{let n=e.edge(t),r={v:t.v,w:t.w};return t.name!==void 0&&(r.name=t.name),n!==void 0&&(r.value=n),r})}function Tr(e){let t=new H(e.options);return e.value!==void 0&&t.setGraph(e.value),e.nodes.forEach(n=>{t.setNode(n.v,n.value),n.parent&&t.setParent(n.v,n.parent)}),e.edges.forEach(n=>{t.setEdge({v:n.v,w:n.w,name:n.name},n.value)}),t}var He={};Ht(He,{CycleException:()=>be,bellmanFord:()=>Vt,components:()=>Pr,dijkstra:()=>me,dijkstraAll:()=>Fr,findCycles:()=>$r,floydWarshall:()=>Gr,isAcyclic:()=>Br,postorder:()=>zr,preorder:()=>Yr,prim:()=>Wr,shortestPaths:()=>Qr,tarjan:()=>Ut,topsort:()=>zt});var Dr=()=>1;function Vt(e,t,n,r){return Rr(e,String(t),n||Dr,r||function(i){return e.outEdges(i)})}function Rr(e,t,n,r){let i={},o,s=0,a=e.nodes(),l=function(c){let f=n(c);i[c.v].distance+f<i[c.w].distance&&(i[c.w]={distance:i[c.v].distance+f,predecessor:c.v},o=!0)},d=function(){a.forEach(function(c){r(c).forEach(function(f){let p=f.v===c?f.v:f.w,v=p===f.v?f.w:f.v;l({v:p,w:v})})})};a.forEach(function(c){let f=c===t?0:Number.POSITIVE_INFINITY;i[c]={distance:f,predecessor:""}});let u=a.length;for(let c=1;c<u&&(o=!1,s++,d(),!!o);c++);if(s===u-1&&(o=!1,d(),o))throw new Error("The graph contains a negative weight cycle");return i}function Pr(e){let t={},n=[],r;function i(o){o in t||(t[o]=!0,r.push(o),e.successors(o).forEach(i),e.predecessors(o).forEach(i))}return e.nodes().forEach(function(o){r=[],i(o),r.length&&n.push(r)}),n}var Bt=class{constructor(){this._arr=[],this._keyIndices={}}size(){return this._arr.length}keys(){return this._arr.map(e=>e.key)}has(e){return e in this._keyIndices}priority(e){let t=this._keyIndices[e];if(t!==void 0)return this._arr[t].priority}min(){if(this.size()===0)throw new Error("Queue underflow");return this._arr[0].key}add(e,t){let n=this._keyIndices,r=String(e);if(!(r in n)){let i=this._arr,o=i.length;return n[r]=o,i.push({key:r,priority:t}),this._decrease(o),!0}return!1}removeMin(){this._swap(0,this._arr.length-1);let e=this._arr.pop();return delete this._keyIndices[e.key],this._heapify(0),e.key}decrease(e,t){let n=this._keyIndices[e];if(n===void 0)throw new Error(`Key not found: ${e}`);let r=this._arr[n].priority;if(t>r)throw new Error(`New priority is greater than current priority. Key: ${e} Old: ${r} New: ${t}`);this._arr[n].priority=t,this._decrease(n)}_heapify(e){let t=this._arr,n=2*e,r=n+1,i=e;n<t.length&&(i=t[n].priority<t[i].priority?n:i,r<t.length&&(i=t[r].priority<t[i].priority?r:i),i!==e&&(this._swap(e,i),this._heapify(i)))}_decrease(e){let t=this._arr,n=t[e].priority,r;for(;e!==0&&(r=e>>1,!(t[r].priority<n));)this._swap(e,r),e=r}_swap(e,t){let n=this._arr,r=this._keyIndices,i=n[e],o=n[t];n[e]=o,n[t]=i,r[o.key]=e,r[i.key]=t}},Mr=()=>1;function me(e,t,n,r){let i=function(o){return e.outEdges(o)};return Ar(e,String(t),n||Mr,r||i)}function Ar(e,t,n,r){let i={},o=new Bt,s,a,l=function(d){let u=d.v!==s?d.v:d.w,c=i[u],f=n(d),p=a.distance+f;if(f<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+d+" Weight: "+f);p<c.distance&&(c.distance=p,c.predecessor=s,o.decrease(u,p))};for(e.nodes().forEach(function(d){let u=d===t?0:Number.POSITIVE_INFINITY;i[d]={distance:u,predecessor:""},o.add(d,u)});o.size()>0&&(s=o.removeMin(),a=i[s],a.distance!==Number.POSITIVE_INFINITY);)r(s).forEach(l);return i}function Fr(e,t,n){return e.nodes().reduce(function(r,i){return r[i]=me(e,i,t,n),r},{})}function Ut(e){let t=0,n=[],r={},i=[];function o(s){let a=r[s]={onStack:!0,lowlink:t,index:t++};if(n.push(s),e.successors(s).forEach(function(l){l in r?r[l].onStack&&(a.lowlink=Math.min(a.lowlink,r[l].index)):(o(l),a.lowlink=Math.min(a.lowlink,r[l].lowlink))}),a.lowlink===a.index){let l=[],d;do d=n.pop(),r[d].onStack=!1,l.push(d);while(s!==d);i.push(l)}}return e.nodes().forEach(function(s){s in r||o(s)}),i}function $r(e){return Ut(e).filter(function(t){return t.length>1||t.length===1&&e.hasEdge(t[0],t[0])})}var Hr=()=>1;function Gr(e,t,n){return Vr(e,t||Hr,n||function(r){return e.outEdges(r)})}function Vr(e,t,n){let r={},i=e.nodes();return i.forEach(function(o){r[o]={},r[o][o]={distance:0,predecessor:""},i.forEach(function(s){o!==s&&(r[o][s]={distance:Number.POSITIVE_INFINITY,predecessor:""})}),n(o).forEach(function(s){let a=s.v===o?s.w:s.v,l=t(s);r[o][a]={distance:l,predecessor:o}})}),i.forEach(function(o){let s=r[o];i.forEach(function(a){let l=r[a];i.forEach(function(d){let u=l[o],c=s[d],f=l[d],p=u.distance+c.distance;p<f.distance&&(f.distance=p,f.predecessor=c.predecessor)})})}),r}var be=class extends Error{constructor(...e){super(...e)}};function zt(e){let t={},n={},r=[];function i(o){if(o in n)throw new be;o in t||(n[o]=!0,t[o]=!0,e.predecessors(o).forEach(i),delete n[o],r.push(o))}if(e.sinks().forEach(i),Object.keys(t).length!==e.nodeCount())throw new be;return r}function Br(e){try{zt(e)}catch(t){if(t instanceof be)return!1;throw t}return!0}function Ur(e,t,n,r,i){Array.isArray(t)||(t=[t]);let o=(a=>{var l;return(l=e.isDirected()?e.successors(a):e.neighbors(a))!=null?l:[]}),s={};return t.forEach(function(a){if(!e.hasNode(a))throw new Error("Graph does not have node: "+a);i=Yt(e,a,n==="post",s,o,r,i)}),i}function Yt(e,t,n,r,i,o,s){return t in r||(r[t]=!0,n||(s=o(s,t)),i(t).forEach(function(a){s=Yt(e,a,n,r,i,o,s)}),n&&(s=o(s,t))),s}function Wt(e,t,n){return Ur(e,t,n,function(r,i){return r.push(i),r},[])}function zr(e,t){return Wt(e,t,"post")}function Yr(e,t){return Wt(e,t,"pre")}function Wr(e,t){let n=new H,r={},i=new Bt,o;function s(l){let d=l.v===o?l.w:l.v,u=i.priority(d);if(u!==void 0){let c=t(l);c<u&&(r[d]=o,i.decrease(d,c))}}if(e.nodeCount()===0)return n;e.nodes().forEach(function(l){i.add(l,Number.POSITIVE_INFINITY),n.setNode(l)}),i.decrease(e.nodes()[0],0);let a=!1;for(;i.size()>0;){if(o=i.removeMin(),o in r)n.setEdge(o,r[o]);else{if(a)throw new Error("Input graph is not connected: "+e);a=!0}e.nodeEdges(o).forEach(s)}return n}function Qr(e,t,n,r){return qr(e,t,n,r??(i=>{let o=e.outEdges(i);return o??[]}))}function qr(e,t,n,r){if(n===void 0)return me(e,t,n,r);let i=!1,o=e.nodes();for(let s=0;s<o.length;s++){let a=r(o[s]);for(let l=0;l<a.length;l++){let d=a[l],u=d.v===o[s]?d.v:d.w,c=u===d.v?d.w:d.v;n({v:u,w:c})<0&&(i=!0)}if(i)return Vt(e,t,n,r)}return me(e,t,n,r)}function ne(e,t,n,r){let i=r;for(;e.hasNode(i);)i=Ge(r);return n.dummy=t,e.setNode(i,n),i}function Kr(e){let t=new H().setGraph(e.graph());return e.nodes().forEach(n=>t.setNode(n,e.node(n))),e.edges().forEach(n=>{let r=t.edge(n.v,n.w)||{weight:0,minlen:1},i=e.edge(n);t.setEdge(n.v,n.w,{weight:r.weight+i.weight,minlen:Math.max(r.minlen,i.minlen)})}),t}function Qt(e){let t=new H({multigraph:e.isMultigraph()}).setGraph(e.graph());return e.nodes().forEach(n=>{e.children(n).length||t.setNode(n,e.node(n))}),e.edges().forEach(n=>{t.setEdge(n,e.edge(n))}),t}function it(e,t){let n=e.x,r=e.y,i=t.x-n,o=t.y-r,s=e.width/2,a=e.height/2;if(!i&&!o)throw new Error("Not possible to find intersection inside of the rectangle");let l,d;return Math.abs(o)*s>Math.abs(i)*a?(o<0&&(a=-a),l=a*i/o,d=a):(i<0&&(s=-s),l=s,d=s*o/i),{x:n+l,y:r+d}}function ae(e){let t=se(Kt(e)+1).map(()=>[]);return e.nodes().forEach(n=>{let r=e.node(n),i=r.rank;i!==void 0&&(t[i]||(t[i]=[]),t[i][r.order]=n)}),t}function Jr(e){let t=e.nodes().map(r=>{let i=e.node(r).rank;return i===void 0?Number.MAX_VALUE:i}),n=z(Math.min,t);e.nodes().forEach(r=>{let i=e.node(r);Object.hasOwn(i,"rank")&&(i.rank-=n)})}function Xr(e){let t=e.nodes().map(s=>e.node(s).rank).filter(s=>s!==void 0),n=z(Math.min,t),r=[];e.nodes().forEach(s=>{let a=e.node(s).rank-n;r[a]||(r[a]=[]),r[a].push(s)});let i=0,o=e.graph().nodeRankFactor;Array.from(r).forEach((s,a)=>{s===void 0&&a%o!==0?--i:s!==void 0&&i&&s.forEach(l=>e.node(l).rank+=i)})}function ot(e,t,n,r){let i={width:0,height:0};return arguments.length>=4&&(i.rank=n,i.order=r),ne(e,"border",i,t)}function Zr(e,t=qt){let n=[];for(let r=0;r<e.length;r+=t){let i=e.slice(r,r+t);n.push(i)}return n}var qt=65535;function z(e,t){if(t.length>qt){let n=Zr(t);return e(...n.map(r=>e(...r)))}else return e(...t)}function Kt(e){let t=e.nodes().map(n=>{let r=e.node(n).rank;return r===void 0?Number.MIN_VALUE:r});return z(Math.max,t)}function ei(e,t){let n={lhs:[],rhs:[]};return e.forEach(r=>{t(r)?n.lhs.push(r):n.rhs.push(r)}),n}function ti(e,t){let n=Date.now();try{return t()}finally{console.log(e+" time: "+(Date.now()-n)+"ms")}}function Jt(e,t){return t()}var ni=0;function Ge(e){let t=++ni;return e+(""+t)}function se(e,t,n=1){t==null&&(t=e,e=0);let r=o=>o<t;n<0&&(r=o=>t<o);let i=[];for(let o=e;r(o);o+=n)i.push(o);return i}function ve(e,t){let n={};for(let r of t)e[r]!==void 0&&(n[r]=e[r]);return n}function Ee(e,t){let n;return typeof t=="string"?n=r=>r[t]:n=t,Object.entries(e).reduce((r,[i,o])=>(r[i]=n(o,i),r),{})}function ri(e,t){return e.reduce((n,r,i)=>(n[r]=t[i],n),{})}var xe="\0";function Xt(e,t,n){var r,i,o,s,a,l;if(!(e&&t&&n&&t.dummy==="edge"&&n.dummy==="edge"&&t.edgeObj&&n.edgeObj&&e[t.edgeObj.v]&&e[n.edgeObj.v]&&e[t.edgeObj.w]&&e[n.edgeObj.w]))return 0;let d=!0;t.edgeObj.w===n.edgeObj.w&&(d=!1);let u=d?(i=(r=e[t.edgeObj.v])==null?void 0:r.rank)!=null?i:NaN+1:(s=(o=e[t.edgeObj.w])==null?void 0:o.rank)!=null?s:NaN-1,c=Object.entries(e).find(N=>{var g,m;return((g=N[1].edgeObj)==null?void 0:g.v)===t.edgeObj.v&&((m=N[1].edgeObj)==null?void 0:m.w)===t.edgeObj.w&&N[1].rank===u}),f=Object.entries(e).find(N=>{var g,m;return((g=N[1].edgeObj)==null?void 0:g.v)===n.edgeObj.v&&((m=N[1].edgeObj)==null?void 0:m.w)===n.edgeObj.w&&N[1].rank===u});if(!c||!f)return 0;let p=(a=c[1].order)!=null?a:NaN,v=(l=f[1].order)!=null?l:NaN;return isNaN(p-v)?0:p-v}var ii="3.1.0",oi=class{constructor(){jr(this,"_sentinel");let e={};e._next=e._prev=e,this._sentinel=e}dequeue(){let e=this._sentinel,t=e._prev;if(t!==e)return st(t),t}enqueue(e){let t=this._sentinel;e._prev&&e._next&&st(e),e._next=t._next,t._next._prev=e,t._next=e,e._prev=t}toString(){let e=[],t=this._sentinel,n=t._prev;for(;n!==t;)e.push(JSON.stringify(n,si)),n=n._prev;return"["+e.join(", ")+"]"}};function st(e){e._prev._next=e._next,e._next._prev=e._prev,delete e._next,delete e._prev}function si(e,t){if(e!=="_next"&&e!=="_prev")return t}var ai=oi,li=()=>1;function di(e,t){if(e.nodeCount()<=1)return[];let n=ci(e,t||li);return ui(n.graph,n.buckets,n.zeroIdx).flatMap(r=>e.outEdges(r.v,r.w)||[])}function ui(e,t,n){var r;let i=[],o=t[t.length-1],s=t[0],a;for(;e.nodeCount();){for(;a=s.dequeue();)Ce(e,t,n,a);for(;a=o.dequeue();)Ce(e,t,n,a);if(e.nodeCount()){for(let l=t.length-2;l>0;--l)if(a=(r=t[l])==null?void 0:r.dequeue(),a){i=i.concat(Ce(e,t,n,a,!0)||[]);break}}}return i}function Ce(e,t,n,r,i){let o=[],s=i?o:void 0;return(e.inEdges(r.v)||[]).forEach(a=>{let l=e.edge(a),d=e.node(a.v);i&&o.push({v:a.v,w:a.w}),d.out-=l,$e(t,n,d)}),(e.outEdges(r.v)||[]).forEach(a=>{let l=e.edge(a),d=a.w,u=e.node(d);u.in-=l,$e(t,n,u)}),e.removeNode(r.v),s}function ci(e,t){let n=new H,r=0,i=0;e.nodes().forEach(a=>{n.setNode(a,{v:a,in:0,out:0})}),e.edges().forEach(a=>{let l=n.edge(a.v,a.w)||0,d=t(a),u=l+d;n.setEdge(a.v,a.w,u);let c=n.node(a.v),f=n.node(a.w);i=Math.max(i,c.out+=d),r=Math.max(r,f.in+=d)});let o=hi(i+r+3).map(()=>new ai),s=r+1;return n.nodes().forEach(a=>{$e(o,s,n.node(a))}),{graph:n,buckets:o,zeroIdx:s}}function $e(e,t,n){var r,i,o;n.out?n.in?(o=e[n.out-n.in+t])==null||o.enqueue(n):(i=e[e.length-1])==null||i.enqueue(n):(r=e[0])==null||r.enqueue(n)}function hi(e){let t=[];for(let n=0;n<e;n++)t.push(n);return t}function fi(e,t){(e.graph().acyclicer==="greedy"?di(e,n(e)):gi(e,t??null)).forEach(r=>{let i=e.edge(r);e.removeEdge(r),i.forwardName=r.name,i.reversed=!0,e.setEdge(r.w,r.v,i,Ge("rev"))});function n(r){return i=>r.edge(i).weight}}function gi(e,t){let n=[],r={},i={};function o(l){Object.hasOwn(i,l)||(i[l]=!0,r[l]=!0,e.outEdges(l).forEach(d=>{Object.hasOwn(r,d.w)?n.push(d):o(d.w)}),delete r[l])}function s(l){var d;Object.hasOwn(i,l)||(i[l]=!0,r[l]=!0,(d=e.outEdges(l))==null||d.forEach(u=>{var c,f;Object.hasOwn(r,u.w)||((c=t.node(l))==null?void 0:c.rank)>((f=t.node(u.w))==null?void 0:f.rank)&&mi(e,u.w,u)?n.push(u):s(u.w)}),delete r[l])}let a=o;return t&&typeof t.node=="function"&&(a=s),e.sources().forEach(a),e.nodes().forEach(a),n}function pi(e){e.edges().forEach(t=>{let n=e.edge(t);if(n.reversed){e.removeEdge(t);let r=n.forwardName;delete n.reversed,delete n.forwardName,e.setEdge(t.w,t.v,n,r)}})}function mi(e,t,n){let r=new Set;function i(o){var s;if(e.sources().includes(o))return!0;r.add(o);for(let a of(s=e.inEdges(o))!=null?s:[])if(!(a.v===n.v&&a.w===n.w)&&!r.has(a.v)&&i(a.v))return!0;return!1}return i(t)}function bi(e){e.graph().dummyChains=[],e.edges().forEach(t=>vi(e,t))}function vi(e,t){let n=t.v,r=e.node(n).rank,i=t.w,o=e.node(i).rank,s=t.name,a=e.edge(t),l=a.labelRank;if(o===r+1)return;e.removeEdge(t);let d,u,c;for(c=0,++r;r<o;++c,++r)a.points=[],u={width:0,height:0,edgeLabel:a,edgeObj:t,rank:r},d=ne(e,"edge",u,"_d"),r===l&&(u.width=a.width,u.height=a.height,u.dummy="edge-label",u.labelpos=a.labelpos),e.setEdge(n,d,{weight:a.weight},s),c===0&&e.graph().dummyChains.push(d),n=d;e.setEdge(n,i,{weight:a.weight},s)}function wi(e){e.graph().dummyChains.forEach(t=>{let n=e.node(t),r=n.edgeLabel,i;for(e.setEdge(n.edgeObj,r);n.dummy;)i=e.successors(t)[0],e.removeNode(t),r.points.push({x:n.x,y:n.y}),n.dummy==="edge-label"&&(r.x=n.x,r.y=n.y,r.width=n.width,r.height=n.height),t=i,n=e.node(t)})}function Ve(e){let t={};function n(r){let i=e.node(r);if(Object.hasOwn(t,r))return i.rank;t[r]=!0;let o=e.outEdges(r),s=o?o.map(l=>l==null?Number.POSITIVE_INFINITY:n(l.w)-e.edge(l).minlen):[],a=z(Math.min,s);return a===Number.POSITIVE_INFINITY&&(a=0),i.rank=a}e.sources().forEach(n)}function te(e,t){return e.node(t.w).rank-e.node(t.v).rank-e.edge(t).minlen}var Zt=Ei;function Ei(e){let t=new H({directed:!1}),n=e.nodes();if(n.length===0)throw new Error("Graph must have at least one node");let r=n[0],i=e.nodeCount();t.setNode(r,{});let o,s;for(;xi(t,e)<i&&(o=yi(t,e),!!o);)s=t.hasNode(o.v)?te(e,o):-te(e,o),_i(t,e,s);return t}function xi(e,t){function n(r){let i=t.nodeEdges(r);i&&i.forEach(o=>{let s=o.v,a=r===s?o.w:s;!e.hasNode(a)&&!te(t,o)&&(e.setNode(a,{}),e.setEdge(r,a,{}),n(a))})}return e.nodes().forEach(n),e.nodeCount()}function yi(e,t){return t.edges().reduce((n,r)=>{let i=Number.POSITIVE_INFINITY;return e.hasNode(r.v)!==e.hasNode(r.w)&&(i=te(t,r)),i<n[0]?[i,r]:n},[Number.POSITIVE_INFINITY,null])[1]}function _i(e,t,n){e.nodes().forEach(r=>t.node(r).rank+=n)}var{preorder:Ni,postorder:ji}=He,ki=K;K.initLowLimValues=Ue;K.initCutValues=Be;K.calcCutValue=en;K.leaveEdge=nn;K.enterEdge=rn;K.exchangeEdges=on;function K(e){e=Kr(e),Ve(e);let t=Zt(e);Ue(t),Be(t,e);let n,r;for(;n=nn(t);)r=rn(t,e,n),on(t,e,n,r)}function Be(e,t){let n=ji(e,e.nodes());n=n.slice(0,n.length-1),n.forEach(r=>Oi(e,t,r))}function Oi(e,t,n){let r=e.node(n).parent,i=e.edge(n,r);i.cutvalue=en(e,t,n)}function en(e,t,n){let r=e.node(n).parent,i=!0,o=t.edge(n,r),s=0;o||(i=!1,o=t.edge(r,n)),s=o.weight;let a=t.nodeEdges(n);return a&&a.forEach(l=>{let d=l.v===n,u=d?l.w:l.v;if(u!==r){let c=d===i,f=t.edge(l).weight;if(s+=c?f:-f,Ci(e,n,u)){let p=e.edge(n,u).cutvalue;s+=c?-p:p}}}),s}function Ue(e,t){arguments.length<2&&(t=e.nodes()[0]),tn(e,{},1,t)}function tn(e,t,n,r,i){let o=n,s=e.node(r);t[r]=!0;let a=e.neighbors(r);return a&&a.forEach(l=>{Object.hasOwn(t,l)||(n=tn(e,t,n,l,r))}),s.low=o,s.lim=n++,i?s.parent=i:delete s.parent,n}function nn(e){return e.edges().find(t=>e.edge(t).cutvalue<0)}function rn(e,t,n){let r=n.v,i=n.w;t.hasEdge(r,i)||(r=n.w,i=n.v);let o=e.node(r),s=e.node(i),a=o,l=!1;return o.lim>s.lim&&(a=s,l=!0),t.edges().filter(d=>l===at(e,e.node(d.v),a)&&l!==at(e,e.node(d.w),a)).reduce((d,u)=>te(t,u)<te(t,d)?u:d)}function on(e,t,n,r){let i=n.v,o=n.w;e.removeEdge(i,o),e.setEdge(r.v,r.w,{}),Ue(e),Be(e,t),Ii(e,t)}function Ii(e,t){let n=e.nodes().find(i=>!e.node(i).parent);if(!n)return;let r=Ni(e,[n]);r=r.slice(1),r.forEach(i=>{let o=e.node(i).parent,s=t.edge(i,o),a=!1;s||(s=t.edge(o,i),a=!0),t.node(i).rank=t.node(o).rank+(a?s.minlen:-s.minlen)})}function Ci(e,t,n){return e.hasEdge(t,n)}function at(e,t,n){return n.low<=t.lim&&t.lim<=n.lim}var Li=Si;function Si(e){let t=e.graph().ranker;if(typeof t=="function")return t(e);switch(t){case"network-simplex":lt(e);break;case"tight-tree":Di(e);break;case"longest-path":Ti(e);break;case"none":break;default:lt(e)}}var Ti=Ve;function Di(e){Ve(e),Zt(e)}function lt(e){ki(e)}var Ri=Pi;function Pi(e){let t=Ai(e),n=e.graph();Array.isArray(n.dummyChains)&&n.dummyChains.forEach(r=>{let i=e.node(r),o=i.edgeObj,s=Mi(e,t,o.v,o.w),a=s.path,l=s.lca,d=0,u=a[d],c=!0;for(;r!==o.w;){if(i=e.node(r),c){for(;(u=a[d])!==l&&e.node(u).maxRank<i.rank;)d++;u===l&&(c=!1)}if(!c){for(;d<a.length-1&&e.node(a[d+1]).minRank<=i.rank;)d++;u=a[d]}u!==void 0&&e.setParent(r,u),r=e.successors(r)[0]}})}function Mi(e,t,n,r){let i=[],o=[],s=Math.min(t[n].low,t[r].low),a=Math.max(t[n].lim,t[r].lim),l;l=n;do l=e.parent(l),i.push(l);while(l&&(t[l].low>s||a>t[l].lim));let d=l,u=r;for(;(u=e.parent(u))!==d;)o.push(u);return{path:i.concat(o.reverse()),lca:d}}function Ai(e){let t={},n=0;function r(i){let o=n;e.children(i).forEach(r),t[i]={low:o,lim:n++}}return e.children(xe).forEach(r),t}function Fi(e){let t=ne(e,"root",{},"_root"),n=$i(e),r=Object.values(n),i=z(Math.max,r)-1,o=2*i+1;e.graph().nestingRoot=t,e.edges().forEach(a=>e.edge(a).minlen*=o);let s=Hi(e)+1;e.children(xe).forEach(a=>{sn(e,t,o,s,i,n,a)}),e.graph().nodeRankFactor=o}function sn(e,t,n,r,i,o,s){var a;let l=e.children(s);if(!l.length){s!==t&&e.setEdge(t,s,{weight:0,minlen:n});return}let d=ot(e,"_bt"),u=ot(e,"_bb"),c=e.node(s);e.setParent(d,s),c.borderTop=d,e.setParent(u,s),c.borderBottom=u,l.forEach(f=>{var p;sn(e,t,n,r,i,o,f);let v=e.node(f),N=v.borderTop?v.borderTop:f,g=v.borderBottom?v.borderBottom:f,m=v.borderTop?r:2*r,b=N!==g?1:i-((p=o[s])!=null?p:0)+1;e.setEdge(d,N,{weight:m,minlen:b,nestingEdge:!0}),e.setEdge(g,u,{weight:m,minlen:b,nestingEdge:!0})}),e.parent(s)||e.setEdge(t,d,{weight:0,minlen:i+((a=o[s])!=null?a:0)})}function $i(e){let t={};function n(r,i){let o=e.children(r);o&&o.length&&o.forEach(s=>n(s,i+1)),t[r]=i}return e.children(xe).forEach(r=>n(r,1)),t}function Hi(e){return e.edges().reduce((t,n)=>t+e.edge(n).weight,0)}function Gi(e){let t=e.graph();e.removeNode(t.nestingRoot),delete t.nestingRoot,e.edges().forEach(n=>{e.edge(n).nestingEdge&&e.removeEdge(n)})}var Vi=Bi;function Bi(e){function t(n){let r=e.children(n),i=e.node(n);if(r.length&&r.forEach(t),i&&Object.hasOwn(i,"minRank")){i.borderLeft=[],i.borderRight=[];for(let o=i.minRank,s=i.maxRank+1;o<s;++o)dt(e,"borderLeft","_bl",n,i,o),dt(e,"borderRight","_br",n,i,o)}}e.children(xe).forEach(t)}function dt(e,t,n,r,i,o){let s={width:0,height:0,rank:o,borderType:t},a=i[t][o-1],l=ne(e,"border",s,n);i[t][o]=l,e.setParent(l,r),a&&e.setEdge(a,l,{weight:1})}function Ui(e){var t;let n=(t=e.graph().rankdir)==null?void 0:t.toLowerCase();(n==="lr"||n==="rl")&&an(e)}function zi(e){var t;let n=(t=e.graph().rankdir)==null?void 0:t.toLowerCase();(n==="bt"||n==="rl")&&Yi(e),(n==="lr"||n==="rl")&&(Wi(e),an(e))}function an(e){e.nodes().forEach(t=>ut(e.node(t))),e.edges().forEach(t=>ut(e.edge(t)))}function ut(e){let t=e.width;e.width=e.height,e.height=t}function Yi(e){e.nodes().forEach(t=>Le(e.node(t))),e.edges().forEach(t=>{var n;let r=e.edge(t);(n=r.points)==null||n.forEach(Le),Object.hasOwn(r,"y")&&Le(r)})}function Le(e){e.y=-e.y}function Wi(e){e.nodes().forEach(t=>Se(e.node(t))),e.edges().forEach(t=>{var n;let r=e.edge(t);(n=r.points)==null||n.forEach(Se),Object.hasOwn(r,"x")&&Se(r)})}function Se(e){let t=e.x;e.x=e.y,e.y=t}function Qi(e,t=null){let n={},r=e.nodes().filter(d=>!e.children(d).length),i=r.map(d=>e.node(d).rank),o=z(Math.max,i),s=se(o+1).map(()=>[]);function a(d){if(n[d])return;n[d]=!0;let u=e.node(d);s[u.rank].push(d);let c=e.successors(d);c&&[...c].sort((f,p)=>l(f,p)).forEach(a)}r.sort((d,u)=>e.node(d).rank-e.node(u).rank).forEach(a);function l(d,u){let c=e.node(d),f=e.node(u);return Xt(t,c,f)}return s}function qi(e,t){let n=0;for(let r=1;r<t.length;++r)n+=Ki(e,t[r-1],t[r]);return n}function Ki(e,t,n){let r=ri(n,n.map((d,u)=>u)),i=t.flatMap(d=>{let u=e.outEdges(d);return u?u.map(c=>({pos:r[c.w],weight:e.edge(c).weight})).sort((c,f)=>c.pos-f.pos):[]}),o=1;for(;o<n.length;)o<<=1;let s=2*o-1;o-=1;let a=new Array(s).fill(0),l=0;return i.forEach(d=>{let u=d.pos+o;a[u]+=d.weight;let c=0;for(;u>0;)u%2&&(c+=a[u+1]),u=u-1>>1,a[u]+=d.weight;l+=d.weight*c}),l}function Ji(e,t=[]){return t.map(n=>{let r=e.inEdges(n);if(!r||!r.length)return{v:n};{let i=r.reduce((o,s)=>{let a=e.edge(s),l=e.node(s.v);return{sum:o.sum+a.weight*l.order,weight:o.weight+a.weight}},{sum:0,weight:0});return{v:n,barycenter:i.sum/i.weight,weight:i.weight}}})}function Xi(e,t){let n={};e.forEach((i,o)=>{let s={indegree:0,in:[],out:[],vs:[i.v],i:o};i.barycenter!==void 0&&(s.barycenter=i.barycenter,s.weight=i.weight),n[i.v]=s}),t.edges().forEach(i=>{let o=n[i.v],s=n[i.w];o!==void 0&&s!==void 0&&(s.indegree++,o.out.push(s))});let r=Object.values(n).filter(i=>!i.indegree);return Zi(r)}function Zi(e){let t=[];function n(i){return o=>{o.merged||(o.barycenter===void 0||i.barycenter===void 0||o.barycenter>=i.barycenter)&&eo(i,o)}}function r(i){return o=>{o.in.push(i),--o.indegree===0&&e.push(o)}}for(;e.length;){let i=e.pop();t.push(i),i.in.reverse().forEach(n(i)),i.out.forEach(r(i))}return t.filter(i=>!i.merged).map(i=>ve(i,["vs","i","barycenter","weight"]))}function eo(e,t){let n=0,r=0;e.weight&&(n+=e.barycenter*e.weight,r+=e.weight),t.weight&&(n+=t.barycenter*t.weight,r+=t.weight),e.vs=t.vs.concat(e.vs),e.barycenter=n/r,e.weight=r,e.i=Math.min(t.i,e.i),t.merged=!0}function to(e,t,n,r,i){let o={},s=null,a=null,l=i;typeof t=="boolean"?(l=t,o={}):t&&(o=t,s=n??null,a=r??null);let d=ei(e,m=>Object.hasOwn(m,"barycenter")),u=d.lhs,c=d.rhs.sort((m,b)=>b.i-m.i),f=[],p=0,v=0,N=0;u.sort(no(a,s,!!l));for(let[m,b]of Object.entries(o)){let w=u.findIndex(O=>O.vs[0]===m);u.splice(w+1,0,b)}N=ct(f,c,N),u.forEach(m=>{N+=m.vs.length,f.push(m.vs),p+=m.barycenter*m.weight,v+=m.weight,N=ct(f,c,N)});let g={vs:f.flat(1)};return v&&(g.barycenter=p/v,g.weight=v),g}function ct(e,t,n){let r;for(;t.length&&(r=t[t.length-1]).i<=n;)t.pop(),e.push(r.vs),n++;return n}function no(e,t,n){return(r,i)=>{if(r.barycenter<i.barycenter)return-1;if(r.barycenter>i.barycenter)return 1;if(e&&(typeof r.vs[0]=="string"||typeof i.vs[0]=="string")){let o=e.node(r.vs[0]),s=e.node(i.vs[0]),a=Xt(t,o,s);if(a!==0)return a}return n?i.i-r.i:r.i-i.i}}function ln(e,t,n,r,i){var o,s,a,l,d,u,c,f,p,v,N;let g=null,m=i;typeof r=="boolean"?(m=r,g=null):r!==void 0&&(g=r);let b=e.children(t),w=e.node(t),O=w?w.borderLeft:void 0,S=w?w.borderRight:void 0,j={};O&&(b=b.filter(y=>y!==O&&y!==S));let R=Ji(e,b);R.forEach(y=>{if(e.children(y.v).length){let{result:_}=ln(e,y.v,n,g,m);j[y.v]=_,Object.hasOwn(_,"barycenter")&&io(y,_)}});let D=Xi(R,n);ro(D,j);let F={},A=!1;for(let y=0;y<D.length;y++)for(let _=y+1;_<D.length;_++)if(!(!D[y]||!D[_]||!((o=D[y])!=null&&o.barycenter)||!((s=D[_])!=null&&s.barycenter))&&((a=D[y])==null?void 0:a.barycenter)===D[_].barycenter){let M=(d=(l=D[y])==null?void 0:l.vs[0])!=null?d:"",V=(c=(u=D[_])==null?void 0:u.vs[0])!=null?c:"",Y=e.node(M),I=e.node(V);if(Y.dummy==="edge"&&I.dummy==="edge"&&((f=Y.edgeObj)==null?void 0:f.v)===((p=I.edgeObj)==null?void 0:p.v)&&((v=Y.edgeObj)==null?void 0:v.w)===((N=I.edgeObj)==null?void 0:N.w))if(Y.edgeLabel.reversed){F[V]=D[y],D.splice(y,1),y--;break}else F[M]=D[_],D.splice(_,1),_--;else A=!0}let P=to(D,F,g,e,m);if(O&&S){P.vs=[O,P.vs,S].flat(1);let y=e.predecessors(O);if(y&&y.length){let _=e.node(y[0]),M=e.predecessors(S),V=e.node(M[0]);Object.hasOwn(P,"barycenter")||(P.barycenter=0,P.weight=0),P.barycenter=(P.barycenter*P.weight+_.order+V.order)/(P.weight+2),P.weight+=2}}return Object.defineProperty(P,"result",{value:P,enumerable:!1,configurable:!0,writable:!0}),Object.defineProperty(P,"usedBias",{value:A,enumerable:!1,configurable:!0,writable:!0}),P}function ro(e,t){e.forEach(n=>{n.vs=n.vs.flatMap(r=>t[r]?t[r].vs:r)})}function io(e,t){e.barycenter!==void 0?(e.barycenter=(e.barycenter*e.weight+t.barycenter*t.weight)/(e.weight+t.weight),e.weight+=t.weight):(e.barycenter=t.barycenter,e.weight=t.weight)}function oo(e,t,n,r){r||(r=e.nodes());let i=so(e),o=new H({compound:!0}).setGraph({root:i}).setDefaultNodeLabel(s=>e.node(s));return r.forEach(s=>{let a=e.node(s),l=e.parent(s);if(a.rank===t||a.minRank<=t&&t<=a.maxRank){o.setNode(s),o.setParent(s,l||i);let d=e[n](s);d&&d.forEach(u=>{let c=u.v===s?u.w:u.v,f=o.edge(c,s),p=f!==void 0?f.weight:0;o.setEdge(c,s,{weight:e.edge(u).weight+p})}),Object.hasOwn(a,"minRank")&&o.setNode(s,{borderLeft:a.borderLeft[t],borderRight:a.borderRight[t]})}}),o}function so(e){let t;for(;e.hasNode(t=Ge("_root")););return t}function ao(e,t,n){let r={},i;n.forEach(o=>{let s=e.parent(o),a,l;for(;s;){if(a=e.parent(s),a?(l=r[a],r[a]=s):(l=i,i=s),l&&l!==s){t.setEdge(l,s);return}s=a}})}function dn(e,t={},n=null){if(typeof t.customOrder=="function"){t.customOrder(e,dn);return}let r=Kt(e),i=ht(e,se(1,r+1),"inEdges"),o=ht(e,se(r-1,-1,-1),"outEdges"),s=Qi(e,n);if(ft(e,s),t.disableOptimalOrderHeuristic)return;let a=Number.POSITIVE_INFINITY,l,d=t.constraints||[];for(let u=0,c=0;c<4;++u,++c){lo(u%2?i:o,u%4>=2,d,n),s=ae(e);let f=qi(e,s);f<a?(c=0,l=Object.assign({},s),a=f):f===a&&(l=structuredClone(s))}ft(e,l)}function ht(e,t,n){let r=new Map,i=(o,s)=>{r.has(o)||r.set(o,[]),r.get(o).push(s)};for(let o of e.nodes()){let s=e.node(o);if(typeof s.rank=="number"&&i(s.rank,o),typeof s.minRank=="number"&&typeof s.maxRank=="number")for(let a=s.minRank;a<=s.maxRank;a++)a!==s.rank&&i(a,o)}return t.map(function(o){return oo(e,o,n,r.get(o)||[])})}function lo(e,t,n,r){let i=!0,o=new H;e.forEach(function(s){n.forEach(u=>o.setEdge(u.left,u.right));let a=s.graph().root,{result:l,usedBias:d}=ln(s,a,o,r,i);t&&d&&(i=!i),l.vs.forEach((u,c)=>s.node(u).order=c),ao(s,o,l.vs)})}function ft(e,t){Object.values(t).forEach(n=>n.forEach((r,i)=>e.node(r).order=i))}function uo(e,t){let n={};function r(i,o){let s=0,a=0,l=i.length,d=o[o.length-1];return o.forEach((u,c)=>{let f=ho(e,u),p=f?e.node(f).order:l;(f||u===d)&&(o.slice(a,c+1).forEach(v=>{let N=e.predecessors(v);N&&N.forEach(g=>{let m=e.node(g),b=m.order;(b<s||p<b)&&!(m.dummy&&e.node(v).dummy)&&un(n,g,v)})}),a=c+1,s=p)}),o}return t.length&&t.reduce(r),n}function co(e,t){let n={};function r(o,s,a,l,d){se(s,a).forEach(u=>{let c=o[u];if(c!==void 0&&e.node(c).dummy){let f=e.predecessors(c);f&&f.forEach(p=>{if(p===void 0)return;let v=e.node(p);v.dummy&&(v.order<l||v.order>d)&&un(n,p,c)})}})}function i(o,s){let a=-1,l=-1,d=0;return s.forEach((u,c)=>{if(e.node(u).dummy==="border"){let f=e.predecessors(u);if(f&&f.length){let p=f[0];if(p===void 0)return;l=e.node(p).order,r(s,d,c,a,l),d=c,a=l}}r(s,d,s.length,l,o.length)}),s}return t.length&&t.reduce(i),n}function ho(e,t){if(e.node(t).dummy){let n=e.predecessors(t);if(n)return n.find(r=>e.node(r).dummy)}}function un(e,t,n){if(t>n){let i=t;t=n,n=i}let r=e[t];r||(e[t]=r={}),r[n]=!0}function fo(e,t,n){if(t>n){let i=t;t=n,n=i}let r=e[t];return r!==void 0&&Object.hasOwn(r,n)}function go(e,t,n,r,i){let o={},s={},a={};return t.forEach(l=>{l.forEach((d,u)=>{o[d]=d,s[d]=d,a[d]=u})}),t.forEach(l=>{let d=-1,u=-1,c=!1,f=l,p=l.findIndex(v=>(i==null?void 0:i.includes(v))||gt(v,e,i));p>0&&(f=[l[p],...l.slice(0,p),...l.slice(p+1)],c=!0),f.forEach(v=>{var N;let g=r(v);if(g&&g.length){i!=null&&i.includes(v)&&(g=g.filter(w=>gt(w,e,i)));let m=g.sort((w,O)=>{let S=a[w],j=a[O];return(S!==void 0?S:0)-(j!==void 0?j:0)}),b=(m.length-1)/2;for(let w=Math.floor(b),O=Math.ceil(b);w<=O;++w){let S=m[w];if(S===void 0)continue;let j=a[S];if(j!==void 0&&s[v]===v&&d<j&&a[S]!==u&&!fo(n,v,S)){let R=o[S];R!==void 0&&(s[S]=v,s[v]=o[v]=R,d=j,c&&(d=-1,u=(N=a[S])!=null?N:-1,c=!1))}}}})}),{root:o,align:s}}function po(e,t,n,r,i=!1){let o={},s=mo(e,t,n,i),a=i?"borderLeft":"borderRight";function l(p,v){let N=s.nodes().slice(),g={},m=N.pop();for(;m;){if(g[m])p(m);else{g[m]=!0,N.push(m);for(let b of v(m))N.push(b)}m=N.pop()}}function d(p){let v=s.inEdges(p);v?o[p]=v.reduce((N,g)=>{var m;let b=(m=o[g.v])!=null?m:0,w=s.edge(g);return Math.max(N,b+(w!==void 0?w:0))},0):o[p]=0}function u(p){let v=s.outEdges(p),N=Number.POSITIVE_INFINITY;v&&(N=v.reduce((m,b)=>{let w=o[b.w],O=s.edge(b);return Math.min(m,(w!==void 0?w:0)-(O!==void 0?O:0))},Number.POSITIVE_INFINITY));let g=e.node(p);N!==Number.POSITIVE_INFINITY&&g.borderType!==a&&(o[p]=Math.max(o[p]!==void 0?o[p]:0,N))}function c(p){return s.predecessors(p)||[]}function f(p){return s.successors(p)||[]}return l(d,c),l(u,f),Object.keys(r).forEach(p=>{var v;let N=n[p];N!==void 0&&(o[p]=(v=o[N])!=null?v:0)}),o}function mo(e,t,n,r){let i=new H,o=e.graph(),s=xo(o.nodesep,o.edgesep,r);return t.forEach(a=>{let l;a.forEach(d=>{let u=n[d];if(u!==void 0){if(i.setNode(u),l!==void 0){let c=n[l];if(c!==void 0){let f=i.edge(c,u);i.setEdge(c,u,Math.max(s(e,d,l),f||0))}}l=d}})}),i}function bo(e,t){return Object.values(t).reduce((n,r)=>{let i=Number.NEGATIVE_INFINITY,o=Number.POSITIVE_INFINITY;Object.entries(r).forEach(([a,l])=>{let d=yo(e,a)/2;i=Math.max(l+d,i),o=Math.min(l-d,o)});let s=i-o;return s<n[0]&&(n=[s,r]),n},[Number.POSITIVE_INFINITY,null])[1]}function vo(e,t){let n=Object.values(t),r=z(Math.min,n),i=z(Math.max,n);["u","d"].forEach(o=>{["l","r"].forEach(s=>{let a=o+s,l=e[a];if(!l||l===t)return;let d=Object.values(l),u=r-z(Math.min,d);s!=="l"&&(u=i-z(Math.max,d)),u&&(e[a]=Ee(l,c=>c+u))})})}function wo(e,t=void 0){let n=e.ul;return n?Ee(n,(r,i)=>{var o,s;if(t){let l=t.toLowerCase(),d=e[l];if(d&&d[i]!==void 0)return d[i]}let a=Object.values(e).map(l=>{let d=l[i];return d!==void 0?d:0}).sort((l,d)=>l-d);return(((o=a[1])!=null?o:0)+((s=a[2])!=null?s:0))/2}):{}}function Eo(e,t){let n=ae(e),r=Object.assign(uo(e,n),co(e,n)),i={},o;["u","d"].forEach(a=>{o=a==="u"?n:Object.values(n).reverse(),["l","r"].forEach(l=>{l==="r"&&(o=o.map(c=>Object.values(c).reverse()));let d=go(e,o,r,c=>(a==="u"?e.predecessors(c):e.successors(c))||[],t),u=po(e,o,d.root,d.align,l==="r");l==="r"&&(u=Ee(u,c=>-c)),i[a+l]=u})});let s=bo(e,i);return vo(i,s),wo(i,e.graph().align)}function xo(e,t,n){return(r,i,o)=>{let s=r.node(i),a=r.node(o),l=0,d;if(l+=s.width/2,Object.hasOwn(s,"labelpos"))switch(s.labelpos.toLowerCase()){case"l":d=-s.width/2;break;case"r":d=s.width/2;break}if(d&&(l+=n?d:-d),d=void 0,l+=(s.dummy?t:e)/2,l+=(a.dummy?t:e)/2,l+=a.width/2,Object.hasOwn(a,"labelpos"))switch(a.labelpos.toLowerCase()){case"l":d=a.width/2;break;case"r":d=-a.width/2;break}return d&&(l+=n?d:-d),l}}function yo(e,t){return e.node(t).width}function gt(e,t,n){var r;if(!n)return!1;let i=(r=t.node(e))==null?void 0:r.edgeObj;if(!i||t.node(e).edgeLabel.reversed)return!1;let o=n.indexOf(i==null?void 0:i.v),s=n.indexOf(i==null?void 0:i.w);return o!==-1&&s!==-1&&o===(s+1)%n.length||o===(s-1)%n.length}function _o(e,t){e=Qt(e),No(e),Object.entries(Eo(e,t)).forEach(([n,r])=>e.node(n).x=r)}function No(e){let t=ae(e),n=e.graph(),r=n.ranksep,i=n.rankalign,o=0;t.forEach(s=>{let a=s.reduce((l,d)=>{var u;let c=(u=e.node(d).height)!=null?u:0;return l>c?l:c},0);s.forEach(l=>{let d=e.node(l);i==="top"?d.y=o+d.height/2:i==="bottom"?d.y=o+a-d.height/2:d.y=o+a/2}),o+=a+r})}var Te=null,De=null;function jo(e,t={}){return cn(e,Jt,t),e}function pt(e,t,n){let r=t;for(;r!==void 0;){let i=e.parent(r);if(i===n)return r;r=i}}function cn(e,t,n){let r=e.nodes().filter(g=>e.children(g).length),i={};r.forEach(g=>{let m=e.node(g);if(m&&m.rankdir){let b=new H({multigraph:!0,compound:!0});b.setGraph({rankdir:m.rankdir});let w=e.children(g);w.forEach(y=>{let _={...e.node(y)};b.setNode(y,_);let M=e.parent(y);M&&M!==g&&w.includes(M)&&b.setParent(y,M)});let O=new Set;e.edges().forEach(y=>{let _=pt(e,y.v,g),M=pt(e,y.w,g);if(_&&M&&_!==M){let V=`${_}\0${M}`;O.has(V)||(O.add(V),b.setEdge(_,M,{...e.edge(y)}))}}),cn(b,t,n);let S=wt(b);mt(S,t,n),bt(b,S);let j=1/0,R=1/0,D=-1/0,F=-1/0;b.nodes().forEach(y=>{if(y===g)return;let _=b.node(y);_&&typeof _.x=="number"&&typeof _.y=="number"&&typeof _.width=="number"&&typeof _.height=="number"&&(j=Math.min(j,_.x-_.width/2),D=Math.max(D,_.x+_.width/2),R=Math.min(R,_.y-_.height/2),F=Math.max(F,_.y+_.height/2))}),(!isFinite(j)||!isFinite(R)||!isFinite(D)||!isFinite(F))&&(j=R=0,D=F=0);let A=D-j,P=F-R;i[g]={minX:j,minY:R,maxX:D,maxY:F,width:A,height:P,offsetX:j,offsetY:R},m._dagreClusterSubgraph=b}});let o=[],s=g=>{let m=[],b=(e.children(g)||[]).filter(w=>w!==g);for(;b.length>0;){let w=b.shift();m.push(w),(e.children(w)||[]).filter(O=>O!==w).forEach(O=>b.push(O))}return m},a=new Map;r.forEach(g=>{let m=e.node(g);m&&m.rankdir&&i[g]&&a.set(g,(e.children(g)||[]).filter(b=>b!==g))});let l=new Set([...a.values()].flat()),d=new Map;a.forEach((g,m)=>{l.has(m)||d.set(m,s(m))});let u=new Set([...d.values()].flat()),c=g=>{for(let[m,b]of d)if(b.includes(g))return m;return g},f=[];e.edges().forEach(g=>{(u.has(g.v)||u.has(g.w))&&f.push({edge:g,label:e.edge(g)})});let p=new Map;u.forEach(g=>{let m=e.parent(g);p.set(g,typeof m=="string"?m:void 0)}),d.forEach((g,m)=>{let b=e.node(m),w=[];g.forEach(j=>{let R=e.node(j);R&&(w.push({id:j,node:R,parent:p.get(j)}),e.removeNode(j))});let O=f.filter(({edge:j})=>g.includes(j.v)||g.includes(j.w)),S=i[m];b&&(o.push({clusterId:m,subgraph:b._dagreClusterSubgraph,bounds:S,children:g,removedNodes:w,removedEdges:O}),b.width=S.width,b.height=S.height)});let v=new Set;f.forEach(({edge:g,label:m})=>{let b=c(g.v),w=c(g.w);if(b!==w&&e.hasNode(b)&&e.hasNode(w)){let O=`${b}\0${w}`;v.has(O)||(v.add(O),e.setEdge(b,w,{...m,width:0,height:0}))}});let N=wt(e);mt(N,t,n),bt(e,N),v.forEach(g=>{let m=g.indexOf("\0"),b=g.slice(0,m),w=g.slice(m+1);e.hasEdge(b,w)&&e.removeEdge(b,w)}),o.forEach(({clusterId:g,subgraph:m,bounds:b,removedNodes:w,removedEdges:O})=>{var S,j;let R=e.node(g),D=(S=R==null?void 0:R.x)!=null?S:0,F=(j=R==null?void 0:R.y)!=null?j:0,A=(b.minX+b.maxX)/2,P=(b.minY+b.maxY)/2;w.forEach(({id:y,node:_,parent:M})=>{e.setNode(y,_),M!==void 0&&e.setParent(y,M)}),O.forEach(({edge:y,label:_})=>{e.setEdge(y,_)}),m.nodes().forEach(y=>{if(y===g)return;let _=m.node(y),M=e.node(y);M&&_&&typeof _.x=="number"&&typeof _.y=="number"&&(M.x=D+(_.x-A),M.y=F+(_.y-P))}),delete R._dagreClusterSubgraph}),r.forEach(g=>{var m,b;let w=e.node(g),O=i[g];if(w&&w.rankdir&&w._dagreClusterSubgraph&&O){let S=w._dagreClusterSubgraph,j=(m=w.x)!=null?m:0,R=(b=w.y)!=null?b:0,D=(O.minX+O.maxX)/2,F=(O.minY+O.maxY)/2;S.nodes().forEach(A=>{if(A===g)return;let P=S.node(A),y=e.node(A);if(y&&P&&typeof P.x=="number"&&typeof P.y=="number"){let _=P.x-D,M=P.y-F;y.x=j+_,y.y=R+M}}),delete w._dagreClusterSubgraph}})}function mt(e,t,n){(n==null?void 0:n.useDynamic)===!1&&(Te=null,De=null),t(" makeSpaceForEdgeLabels",()=>Do(e)),t(" removeSelfEdges",()=>Vo(e)),t(" acyclic",()=>fi(e,Te)),t(" nestingGraph.run",()=>Fi(e)),t(" rank",()=>Li(Qt(e))),t(" injectEdgeLabelProxies",()=>Ro(e)),t(" removeEmptyRanks",()=>Xr(e)),t(" nestingGraph.cleanup",()=>Gi(e)),t(" normalizeRanks",()=>Jr(e)),t(" assignRankMinMax",()=>Po(e)),t(" removeEdgeLabelProxies",()=>Mo(e)),t(" normalize.run",()=>bi(e)),t(" parentDummyChains",()=>Ri(e)),t(" addBorderSegments",()=>Vi(e)),t(" order",()=>dn(e,n,De)),t(" insertSelfEdges",()=>Bo(e)),t(" adjustCoordinateSystem",()=>Ui(e)),t(" position",()=>_o(e,n.corePath)),t(" positionSelfEdges",()=>Uo(e)),De=JSON.parse(JSON.stringify(e._nodes)),t(" removeBorderNodes",()=>Go(e)),t(" normalize.undo",()=>wi(e)),t(" fixupEdgeLabelCoords",()=>$o(e)),t(" undoCoordinateSystem",()=>zi(e)),t(" translateGraph",()=>Ao(e)),t(" assignNodeIntersects",()=>Fo(e)),t(" reversePoints",()=>Ho(e)),t(" acyclic.undo",()=>pi(e)),Te=e}function bt(e,t){e.nodes().forEach(n=>{let r=e.node(n),i=t.node(n);r&&(r.x=i.x,r.y=i.y,r.order=i.order,r.rank=i.rank,t.children(n).length&&(r.width=i.width,r.height=i.height))}),e.edges().forEach(n=>{let r=e.edge(n),i=t.edge(n);r.points=i.points,Object.hasOwn(i,"x")&&(r.x=i.x,r.y=i.y)}),e.graph().width=t.graph().width,e.graph().height=t.graph().height}var ko=["nodesep","edgesep","ranksep","marginx","marginy"],Oo={ranksep:50,edgesep:20,nodesep:50,rankdir:"TB",rankalign:"center"},Io=["acyclicer","ranker","rankdir","align","rankalign"],Co=["width","height","rank"],vt={width:0,height:0},Lo=["minlen","weight","width","height","labeloffset"],So={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},To=["labelpos"];function wt(e){let t=new H({multigraph:!0,compound:!0}),n=Pe(e.graph());return t.setGraph(Object.assign({},Oo,Re(n,ko),ve(n,Io))),e.nodes().forEach(r=>{let i=Pe(e.node(r)),o=Re(i,Co);Object.keys(vt).forEach(a=>{o[a]===void 0&&(o[a]=vt[a])}),t.setNode(r,o);let s=e.parent(r);s!==void 0&&t.setParent(r,s)}),e.edges().forEach(r=>{let i=Pe(e.edge(r));t.setEdge(r,Object.assign({},So,Re(i,Lo),ve(i,To)))}),t}function Do(e){let t=e.graph();t.ranksep/=2,e.edges().forEach(n=>{var r;let i=e.edge(n);i.minlen*=2,((r=i.labelpos)!=null?r:"r").toLowerCase()!=="c"&&(t.rankdir==="TB"||t.rankdir==="BT"?i.width+=i.labeloffset:i.height+=i.labeloffset)})}function Ro(e){e.edges().forEach(t=>{let n=e.edge(t);if(n.width&&n.height){let r=e.node(t.v),i={rank:(e.node(t.w).rank-r.rank)/2+r.rank,e:t};ne(e,"edge-proxy",i,"_ep")}})}function Po(e){let t=0;e.nodes().forEach(n=>{let r=e.node(n);r.borderTop&&(r.minRank=e.node(r.borderTop).rank,r.maxRank=e.node(r.borderBottom).rank,t=Math.max(t,r.maxRank))}),e.graph().maxRank=t}function Mo(e){e.nodes().forEach(t=>{let n=e.node(t);if(n.dummy==="edge-proxy"){let r=n;e.edge(r.e).labelRank=n.rank,e.removeNode(t)}})}function Ao(e){let t=Number.POSITIVE_INFINITY,n=0,r=Number.POSITIVE_INFINITY,i=0,o=e.graph(),s=o.marginx||0,a=o.marginy||0;function l(d){let u=d.x,c=d.y,f=d.width,p=d.height;t=Math.min(t,u-f/2),n=Math.max(n,u+f/2),r=Math.min(r,c-p/2),i=Math.max(i,c+p/2)}e.nodes().forEach(d=>l(e.node(d))),e.edges().forEach(d=>{let u=e.edge(d);Object.hasOwn(u,"x")&&l(u)}),t-=s,r-=a,e.nodes().forEach(d=>{let u=e.node(d);u.x-=t,u.y-=r}),e.edges().forEach(d=>{let u=e.edge(d);u.points.forEach(c=>{c.x-=t,c.y-=r}),Object.hasOwn(u,"x")&&(u.x-=t),Object.hasOwn(u,"y")&&(u.y-=r)}),o.width=n-t+s,o.height=i-r+a}function Fo(e){e.edges().forEach(t=>{if(t.v===t.w)return;let n=e.edge(t),r=e.node(t.v),i=e.node(t.w),o,s;n.points?(o=n.points[0],s=n.points[n.points.length-1]):(n.points=[],o=i,s=r),n.points.unshift(it(r,o)),n.points.push(it(i,s))})}function $o(e){e.edges().forEach(t=>{let n=e.edge(t);if(Object.hasOwn(n,"x"))switch((n.labelpos==="l"||n.labelpos==="r")&&(n.width-=n.labeloffset),n.labelpos){case"l":n.x-=n.width/2+n.labeloffset;break;case"r":n.x+=n.width/2+n.labeloffset;break}})}function Ho(e){e.edges().forEach(t=>{let n=e.edge(t);n.reversed&&n.points.reverse()})}function Go(e){e.nodes().forEach(t=>{if(e.children(t).length){let n=e.node(t),r=e.node(n.borderTop),i=e.node(n.borderBottom),o=e.node(n.borderLeft[n.borderLeft.length-1]),s=e.node(n.borderRight[n.borderRight.length-1]);n.width=Math.abs(s.x-o.x),n.height=Math.abs(i.y-r.y),n.x=o.x+n.width/2,n.y=r.y+n.height/2}}),e.nodes().forEach(t=>{e.node(t).dummy==="border"&&e.removeNode(t)})}function Vo(e){e.edges().forEach(t=>{if(t.v===t.w){let n=e.node(t.v);n.selfEdges||(n.selfEdges=[]),n.selfEdges.push({e:t,label:e.edge(t)}),e.removeEdge(t)}})}function Bo(e){ae(e).forEach(t=>{let n=0;t.forEach((r,i)=>{let o=e.node(r);typeof o.rank!="number"&&(o.rank=0),o.order=i+n,(o.selfEdges||[]).forEach(s=>{ne(e,"selfedge",{width:s.label.width,height:s.label.height,rank:o.rank,order:i+ ++n,e:s.e,edgeLabel:s.label},"_se"),(!Array.isArray(s.label.points)||s.label.points.length!==7)&&(s.label.points=[{x:0,y:-10},{x:0,y:-10},{x:0,y:0},{x:0,y:10},{x:0,y:10},{x:0,y:0},{x:0,y:0}])}),delete o.selfEdges})})}function Uo(e){e.nodes().forEach(t=>{let n=e.node(t),r=i=>typeof i=="number"&&isFinite(i);if(n.dummy==="selfedge"){let i=n,o=e.node(i.e.v),s=r(o==null?void 0:o.x)?o.x:0,a=r(o==null?void 0:o.y)?o.y:0,l=r(o==null?void 0:o.width)?o.width:0,d=r(o==null?void 0:o.height)?o.height:0,u=r(n.x)?n.x:s,c=r(n.y)?n.y:a,f=l/2,p=d/2;i.edgeLabel.points=[{x:u+f,y:c-p},{x:u+f,y:c-p},{x:u,y:c},{x:u-f,y:c+p},{x:u-f,y:c+p},{x:u,y:c},{x:u,y:c}],i.edgeLabel.x=u,i.edgeLabel.y=c,e.setEdge(i.e,i.edgeLabel),e.removeNode(t)}else n&&Array.isArray(n.selfEdges)&&n.selfEdges.forEach(i=>{if(!Array.isArray(i.label.points)||i.label.points.length!==7){let o=r(n.x)?n.x:0,s=r(n.y)?n.y:0,a=r(n.width)?n.width:0,l=r(n.height)?n.height:0,d=a/2,u=l/2;i.label.points=[{x:o+d,y:s-u},{x:o+d,y:s-u},{x:o,y:s},{x:o-d,y:s+u},{x:o-d,y:s+u},{x:o,y:s},{x:o,y:s}]}})})}function Re(e,t){return Ee(ve(e,t),Number)}function Pe(e){let t={};return e&&Object.entries(e).forEach(([n,r])=>{typeof n=="string"&&(n=n.toLowerCase()),t[n]=r}),t}function zo(e){let t=ae(e),n=new H({compound:!0,multigraph:!0}).setGraph({});return e.nodes().forEach(r=>{n.setNode(r,{label:r}),n.setParent(r,"layer"+e.node(r).rank)}),e.edges().forEach(r=>n.setEdge(r.v,r.w,{},r.name)),t.forEach((r,i)=>{let o="layer"+i;n.setNode(o,{rank:"same"}),r.reduce((s,a)=>(n.setEdge(s,a,{style:"invis"}),a))}),n}var Yo={graphlib:$t,version:ii,layout:jo,debug:zo,util:{time:ti,notime:Jt}},Et=Yo;/*! For license information please see dagre.esm.js.LEGAL.txt */const xt=80;function Wo(e,t){const n=new Map,r=Math.ceil(Math.sqrt(e.length)),{maxWidth:i,maxHeight:o}=e.reduce((s,a)=>({maxWidth:Math.max(s.maxWidth,a.width),maxHeight:Math.max(s.maxHeight,a.height)}),{maxWidth:0,maxHeight:0});return e.forEach((s,a)=>{const l=a%r,d=Math.floor(a/r),u=t==="horizontal"?l:d,c=t==="horizontal"?d:l;n.set(s.id,{x:u*(i+xt),y:c*(o+xt)})}),n}function Qo(e,t,n){const r=new Map,i=new Map,o=new Map;if(e.length===0)return{positions:r,routes:i,labelPositions:o};const s=new Et.graphlib.Graph({multigraph:!0});s.setGraph({rankdir:n==="horizontal"?"LR":"TB"}),s.setDefaultEdgeLabel(()=>({}));for(const a of e)s.setNode(a.id,{width:a.width,height:a.height});for(const a of t){const l=a.label?{width:a.label.width,height:a.label.height,labelpos:"c"}:{};s.setEdge(a.sourceId,a.targetId,l,a.id)}try{Et.layout(s)}catch(a){if(!(a instanceof RangeError))throw a;return{positions:Wo(e,n),routes:i,labelPositions:o}}for(const a of s.nodes()){const l=s.node(a);l.x===void 0||l.y===void 0||r.set(a,{x:l.x-l.width/2,y:l.y-l.height/2})}for(const a of t){const l=s.edge({v:a.sourceId,w:a.targetId,name:a.id}),d=(l.points??[]).slice(1,-1);d.length>0&&i.set(a.id,d),l.x!==void 0&&l.y!==void 0&&o.set(a.id,{x:l.x,y:l.y})}return{positions:r,routes:i,labelPositions:o}}const qo=(e,t)=>[e,t].sort().join("->"),Ko=56;function Jo(e,t=Ko){const n=new Map;for(const i of e){if(i.sourceId===i.targetId)continue;const o=qo(i.sourceId,i.targetId),s=n.get(o);s?s.push(i):n.set(o,[i])}const r=new Map;for(const i of e)i.sourceId===i.targetId&&r.set(i.id,0);for(const i of n.values()){const o=[...i].sort((a,l)=>a.id.localeCompare(l.id)),s=o.length;o.forEach((a,l)=>{r.set(a.id,(l-(s-1)/2)*t)})}return r}const Xo=212,yt=116,Zo=256,es=88,ts=26,ns=26,rs=4;function ze(e){return e==="erd"?Zo:Xo}function is(e){return[...e.filter(t=>t.isPrimaryKey),...e.filter(t=>!t.isPrimaryKey)]}function hn(e){const t=e.filter(n=>n.isPrimaryKey).length;return Math.min(e.length,Math.max(rs,t))}function fn(e,t,n=!1,r=!1){const i=(n?-36:0)+(r?-30:0);if(t!=="erd")return yt+i;const o=e.fields??[];if(o.length===0)return yt+i;const s=hn(o),a=o.length>s;return es+i+s*ts+(a?ns:0)}const le=["source","fields","status"],we={source:!1,fields:!1,status:!1},os={source:!0,fields:!0,status:!0};function ss(e){return le.includes(e)}function as(e){if(e===null)return we;const t={...we};for(const n of e.split(",")){const r=n.trim();ss(r)&&(t[r]=!0)}return t}function Me(e){return le.filter(t=>e[t]).join(",")}function ls(e,t){return{...e,[t]:!e[t]}}function _t(e){return le.every(t=>!e[t])}function Nt(e){return le.every(t=>e[t])}function ds(e,t,n,r,i,o){let s,a,l,d;if(o==="vertical"){const u=Math.max(40,Math.abs(r-t)*.3);s=e+i,a=t+u,l=n+i,d=r-u}else{const u=Math.max(40,Math.abs(n-e)*.3);s=e+u,a=t+i,l=n-u,d=r+i}return{path:`M ${e} ${t} C ${s} ${a}, ${l} ${d}, ${n} ${r}`,labelX:(e+3*s+3*l+n)/8,labelY:(t+3*a+3*d+r)/8}}function us({id:e,sourceX:t,sourceY:n,targetX:r,targetY:i,sourcePosition:o,targetPosition:s,selected:a,data:l}){const{bowOffset:d,warning:u,joinLabel:c,dimmed:f,direction:p,bidirectional:v}=l;let N;if(d!==0)N=ds(t,n,r,i,d,p);else{const[w,O,S]=Kn({sourceX:t,sourceY:n,sourcePosition:o,targetX:r,targetY:i,targetPosition:s});N={path:w,labelX:O,labelY:S}}const g=u?Zn:a?Ae:er,m=k.useId(),b=Jn("mc-arrow",m);return h.jsxs(h.Fragment,{children:[h.jsx(Xn,{markerId:b,color:g,withStart:v}),h.jsx(tr,{id:e,path:N.path,markerEnd:`url(#${b}-end)`,markerStart:v?`url(#${b}-start)`:void 0,style:{stroke:g,strokeWidth:a?rr:ir,strokeDasharray:u?nr:void 0,opacity:f?Fe:1,transition:"opacity 0.2s, stroke 0.2s"}}),c.length>0&&h.jsx("foreignObject",{x:N.labelX,y:N.labelY,width:1,height:1,style:{overflow:"visible"},children:h.jsx("div",{style:{transform:"translate(-50%, -50%)",width:"max-content",background:"var(--background)",border:`1px solid ${a?"var(--primary)":"var(--border)"}`,borderRadius:8,padding:"3px 8px",fontSize:11,fontWeight:600,lineHeight:1.5,color:"var(--foreground)",pointerEvents:"none",opacity:f?Fe:1,transition:"opacity 0.2s",boxShadow:"0 1px 3px 0 rgba(0,0,0,0.08)"},children:c.map(w=>h.jsx("div",{children:w},w))})})]})}const cs=100,hs=200;function ee(e,t){return`${e} ${t}${e===1?"":"s"}`}function fs({dataMartTitle:e,summary:t,onOpenQuality:n,onRunQuality:r}){const[i,o]=k.useState(!1),[s,a]=k.useState(!1),l=k.useRef(null),d=k.useRef(null),u=k.useRef(null),c=k.useRef(null),f=k.useRef(null),p=k.useRef(!1),v=k.useRef(!1),N=k.useRef(!1),g=Dn(t),m=g.icon,b=[{count:t.errorChecks,singular:"execution error",tone:"error",icon:Rn},{count:t.errorFindings,singular:"critical finding",tone:"error",icon:Ne},{count:t.warningFindings,singular:"warning finding",tone:"warning",icon:Ne},{count:t.noticeFindings,singular:"notice finding",tone:"notice",icon:Ne}].filter(I=>I.count>0),w=(t.state==="ISSUES"||t.state==="EXECUTION_FAILED")&&b.length>0,O=b.map(I=>ee(I.count,I.singular)).join(", "),S=`Open Data Quality for ${e}: ${g.label}${w?`, ${O}`:""}`,j=g.isActive,R=t.state==="QUEUED"?"Queued":t.state==="RUNNING"?"Started":"Last checked";function D(){c.current!==null&&(clearTimeout(c.current),c.current=null)}function F(){f.current!==null&&(clearTimeout(f.current),f.current=null)}function A(){D(),F()}function P(){F(),!(i||p.current||c.current!==null)&&(c.current=setTimeout(()=>{c.current=null,!p.current&&o(!0)},cs))}function y(){D(),!(!i||p.current||f.current!==null)&&(f.current=setTimeout(()=>{f.current=null,!p.current&&o(!1)},hs))}function _(I){if(I.stopPropagation(),I.preventDefault(),A(),p.current&&i){p.current=!1,o(!1);return}p.current=!0,o(!0),I.detail===0&&queueMicrotask(()=>{var $;($=u.current)==null||$.focus()})}function M(I){if(A(),I){p.current=!0,o(!0);return}p.current=!1,o(!1)}function V(I){I.stopPropagation(),I.preventDefault(),n()}async function Y(I){if(I.stopPropagation(),I.preventDefault(),!(j||s)){a(!0);try{await r()}finally{a(!1)}}}return k.useEffect(()=>()=>{c.current!==null&&clearTimeout(c.current),f.current!==null&&clearTimeout(f.current)},[]),k.useEffect(()=>{if(!i)return;function I($){var J,W;const B=$.target;B instanceof Node&&((J=l.current)!=null&&J.contains(B)||(W=d.current)!=null&&W.contains(B)||(c.current!==null&&(clearTimeout(c.current),c.current=null),f.current!==null&&(clearTimeout(f.current),f.current=null),p.current=!1,o(!1)))}return document.addEventListener("pointerdown",I,!0),()=>{document.removeEventListener("pointerdown",I,!0)}},[i]),h.jsxs(Lt,{open:i,onOpenChange:M,children:[h.jsx(St,{asChild:!0,children:h.jsx("button",{ref:l,type:"button",className:`${w?"":je[g.tone]} -ml-0.5 inline-flex shrink-0 cursor-pointer items-center rounded p-0.5 transition-colors ${w?"gap-1.5":""}`,"aria-label":S,onPointerDown:I=>{I.stopPropagation()},onPointerEnter:()=>{P()},onPointerLeave:()=>{y()},onFocus:()=>{if(N.current){N.current=!1;return}P()},onBlur:()=>{y()},onClick:_,children:w?b.map(I=>{const $=ee(I.count,I.singular),B=I.icon;return h.jsxs("span",{role:"img","aria-label":$,className:`${je[I.tone]} inline-flex items-center gap-0.5`,children:[h.jsx(B,{className:"size-4","aria-hidden":!0}),h.jsx("span",{className:"leading-none font-medium tabular-nums",children:I.count})]},I.singular)}):h.jsx(m,{className:`size-4 ${t.state==="RUNNING"?"animate-spin":""}`,"aria-hidden":!0})})}),h.jsxs(Tt,{ref:d,side:"top",align:"center",role:"region","aria-label":`Data Quality checks for ${e}`,className:"w-72 max-w-72 p-3 text-xs sm:w-72 sm:max-w-72",onOpenAutoFocus:I=>{I.preventDefault()},onCloseAutoFocus:I=>{var $;I.preventDefault(),v.current&&(v.current=!1,N.current=!0,($=l.current)==null||$.focus({preventScroll:!0}),queueMicrotask(()=>{N.current=!1}))},onEscapeKeyDown:()=>{v.current=!0},onPointerEnter:()=>{F()},onPointerLeave:()=>{y()},onPointerDown:I=>{I.stopPropagation()},children:[h.jsxs("div",{className:"border-border flex items-center justify-between gap-3 border-b pb-2",children:[h.jsx(ge,{className:"text-sm font-semibold whitespace-nowrap",children:"Data Quality checks"}),h.jsx("span",{className:`${je[g.tone]} shrink-0 font-medium whitespace-nowrap`,children:g.label})]}),h.jsxs("div",{className:"text-muted-foreground space-y-1 py-2",children:[t.enabledChecks>0&&h.jsxs("p",{children:[t.enabledChecks," enabled"]}),j?h.jsx("p",{children:"Terminal results will be available after this run finishes."}):h.jsxs(h.Fragment,{children:[t.passedChecks>0&&h.jsxs("p",{children:[t.passedChecks," passed"]}),t.notApplicableChecks>0&&h.jsxs("p",{children:[t.notApplicableChecks," not applicable"]}),t.errorChecks>0&&h.jsx("p",{children:ee(t.errorChecks,"execution error")}),t.errorFindings>0&&h.jsx("p",{children:ee(t.errorFindings,"critical finding")}),t.warningFindings>0&&h.jsx("p",{children:ee(t.warningFindings,"warning finding")}),t.noticeFindings>0&&h.jsx("p",{children:ee(t.noticeFindings,"notice finding")})]}),t.lastRunAt&&h.jsx("p",{className:"text-foreground pt-2 pb-1 font-medium",children:`${R} ${Pn(t.lastRunAt)}`})]}),h.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[h.jsx("button",{ref:u,type:"button",className:"border-input bg-background hover:bg-muted inline-flex cursor-pointer items-center justify-center rounded-md border px-3 py-1.5 font-medium transition-colors","aria-label":`Open Data Quality page for ${e}`,onPointerDown:I=>{I.stopPropagation()},onClick:V,children:"Open"}),h.jsxs("button",{type:"button",className:"bg-primary text-primary-foreground hover:bg-primary/90 inline-flex cursor-pointer items-center justify-center gap-1.5 rounded-md px-3 py-1.5 font-medium transition-colors disabled:cursor-not-allowed disabled:opacity-50","aria-label":`Run Quality for ${e}`,title:j?"A Data Quality run is already active":void 0,disabled:j||s,onPointerDown:I=>{I.stopPropagation()},onClick:I=>{Y(I)},children:[s?h.jsx(Mn,{className:"size-3.5 animate-spin","aria-hidden":"true"}):h.jsx(An,{className:"size-3.5","aria-hidden":"true"}),s?"Starting…":"Run checks"]})]})]})]})}function gs({dataMartTitle:e,block:t,isChecking:n=!1}){const r=n?"checking…":Fn(t);return h.jsxs(Dt,{children:[h.jsx(Rt,{asChild:!0,children:h.jsx("button",{type:"button",className:`nodrag inline-flex cursor-default items-center rounded p-0.5 transition-colors ${n||t!=null&&t.dataLastUpdatedAt?"text-muted-foreground hover:text-foreground":"text-muted-foreground/50 hover:text-muted-foreground"}`,"aria-label":`Data Last Updated for ${e}: ${r}`,onPointerDown:i=>{i.stopPropagation()},children:n?h.jsx($n,{className:"h-3.5 w-3.5 animate-spin","aria-hidden":"true"}):h.jsx(Hn,{className:"h-3.5 w-3.5","aria-hidden":"true"})})}),h.jsx(Pt,{side:"top",align:"start",role:"tooltip",className:"max-w-xs",children:n?h.jsx("div",{className:"text-xs",children:"Checking Data Last Updated…"}):t?h.jsx(Gn,{block:t}):h.jsx("div",{className:"text-xs",children:"Data Last Updated has not been checked yet. Use Actions → Check Data Last Updated to measure the visible Data Marts."})})]})}function ps({field:e}){return h.jsxs("div",{className:"border-border/50 flex items-center gap-2 border-b px-3.5 py-1.5 text-[11.5px] last:border-b-0",style:{opacity:e.isHidden?.5:1},title:e.isHidden?`${e.alias} (hidden from reporting)`:e.alias,children:[e.isPrimaryKey?h.jsx(Yn,{className:"h-3 w-3 shrink-0",style:{color:ar},"aria-label":"Primary key"}):h.jsx("span",{className:"w-3 shrink-0"}),h.jsx("span",{className:"text-foreground flex-1 truncate",children:e.alias}),h.jsx("span",{className:"text-muted-foreground shrink-0 font-mono text-[10px] tracking-tight",children:e.type})]})}function ms({data:e,selected:t}){const[n,r]=k.useState(!1),i=At(e.definitionType),o=e.viewMode==="erd",s=e.fields,a=o&&s.length>0,l=e.objectLabels??we,d=!l.source,u=!l.fields,c=!l.status,f=l.source&&l.fields&&l.status,p=is(s),v=hn(s),N=n?p:p.slice(0,v),g=p.length-v,m=e.direction==="vertical"?fe.Top:fe.Left,b=e.direction==="vertical"?fe.Bottom:fe.Right,w=`Open ${e.title} in new tab`;function O(j){j.stopPropagation(),j.preventDefault(),e.onOpenExternal()}function S(j){j.stopPropagation(),j.preventDefault(),r(R=>!R)}return h.jsxs("div",{className:"bg-background relative flex cursor-grab flex-col overflow-hidden rounded-xl border shadow-sm active:cursor-grabbing",style:{width:ze(e.viewMode),borderColor:e.highlighted?ke:t?Ae:void 0,boxShadow:e.highlighted?`0 0 0 3px ${ke}40, 0 0 12px ${ke}60`:t?`0 0 0 1px ${Ae}`:void 0,opacity:e.dimmed?Fe:1,filter:e.dimmed?"grayscale(0.8)":void 0,animation:e.highlighted?"node-pulse 1.5s ease-in-out infinite":void 0,transition:"opacity 0.2s, filter 0.2s"},children:[e.hasIncoming&&h.jsx(Xe,{type:"target",position:m,isConnectable:!1,style:Ze}),h.jsxs("div",{className:`flex items-center gap-2 px-3.5 pt-3 ${f?"pb-3":"pb-1"}`,children:[d&&h.jsx("span",{className:"h-4 w-1 shrink-0 rounded-sm",style:{background:i},"aria-hidden":"true"}),h.jsx("span",{className:"text-foreground flex-1 truncate text-[13px] font-semibold",title:e.title,children:e.title}),c&&h.jsx(or,{isDraft:e.isDraft}),e.description&&h.jsxs(Dt,{children:[h.jsx(Rt,{asChild:!0,children:h.jsx("button",{type:"button",className:"text-muted-foreground hover:text-foreground nodrag inline-flex cursor-default rounded p-0.5 transition-colors","aria-label":`Description for ${e.title}`,onPointerDown:j=>{j.stopPropagation()},children:h.jsx(Vn,{className:"h-3.5 w-3.5","aria-hidden":"true"})})}),h.jsx(Pt,{side:"top",align:"center",role:"tooltip",className:"max-w-xs",children:e.description})]}),h.jsx("button",{type:"button",className:"text-muted-foreground hover:text-foreground nodrag shrink-0 cursor-pointer rounded p-0.5 transition-colors",onPointerDown:j=>{j.stopPropagation()},onClick:O,title:w,"aria-label":w,children:h.jsx(Bn,{className:"h-3.5 w-3.5","aria-hidden":"true"})})]}),d&&h.jsx("div",{className:"text-muted-foreground flex items-center gap-2 px-3.5 pt-1 text-[11px]",children:h.jsx(sr,{type:e.definitionType})}),!f&&h.jsxs("div",{className:"text-muted-foreground flex items-center gap-1 px-3.5 pt-1 pb-3 text-[11px]",children:[h.jsx(fs,{dataMartTitle:e.title,summary:e.qualitySummary,onOpenQuality:e.onOpenQuality,onRunQuality:e.onRunQuality}),h.jsx(gs,{dataMartTitle:e.title,block:e.dataLastUpdated,isChecking:e.isCheckingDataLastUpdated}),u&&h.jsxs("span",{className:"ml-auto shrink-0",children:[e.fieldCount," field",e.fieldCount!==1?"s":""]})]}),a&&h.jsxs("div",{className:"border-t",children:[N.map(j=>h.jsx(ps,{field:j},j.name)),g>0&&h.jsx("button",{type:"button",className:"text-muted-foreground hover:text-foreground hover:bg-muted nodrag flex w-full items-center justify-center gap-1 border-t py-1.5 text-[11px] font-medium transition-colors",onPointerDown:j=>{j.stopPropagation()},onClick:S,children:n?h.jsxs(h.Fragment,{children:[h.jsx(Un,{className:"h-3 w-3"})," Show less"]}):h.jsxs(h.Fragment,{children:[h.jsx(zn,{className:"h-3 w-3"})," +",g," more field",g!==1?"s":""]})})]}),e.hasOutgoing&&h.jsx(Xe,{type:"source",position:b,isConnectable:!1,style:Ze})]})}const jt="model-canvas-layout",kt="model-canvas-show-join-fields",Ot="model-canvas-view-mode",It="model-canvas-object-labels",bs="model-canvas-positions";function pe(e){return`${bs}:${e}`}function vs(e){if(!e)return{};const t=G.get(pe(e),"json");if(!t)return{};const n={};for(const[r,i]of Object.entries(t)){const o=i;o&&typeof o.x=="number"&&typeof o.y=="number"&&(n[r]={x:o.x,y:o.y})}return n}const ws={source:{label:"Input source",helper:"The source badge (VIEW / TABLE / SQL / CONNECTOR) and its accent stripe"},fields:{label:"Field count",helper:"The field count shown on each object"},status:{label:"Status dot",helper:"The published/draft status dot in the card header"}},Es=[{value:"compact",label:"Compact"},{value:"erd",label:"Detailed"}],ie=.2,xs=6.6,ys=18,_s=16.5,Ns=8,js=150;function ks(e){return e.length===0?void 0:{width:Math.max(...e.map(n=>n.length))*xs+ys,height:e.length*_s+Ns}}const Os={modelCanvasNode:ms},Is={modelCanvasEdge:us};function Cs(e){return JSON.stringify(e.map(({id:t,title:n,status:r,description:i,fieldCount:o,definitionType:s,fields:a})=>({id:t,title:n,status:r,description:i,fieldCount:o,definitionType:s,fields:a})))}function Ls(e){return JSON.stringify(e)}function Ct(e,t){const n=t(e),r=k.useRef({signature:n,value:e});return r.current.signature!==n&&(r.current={signature:n,value:e}),r.current.value}function Ss(e){const{node:t,highlight:n,viewMode:r,objectLabels:i}=e,o=i.source,s=i.source&&i.fields&&i.status;return{id:t.id,type:"modelCanvasNode",position:e.position,width:ze(r),height:fn(t,r,o,s),draggable:!0,selectable:!1,focusable:!1,deletable:!1,style:Er,data:{title:t.title,isDraft:t.status===Mt.DRAFT,fieldCount:t.fieldCount,description:t.description,definitionType:t.definitionType??null,fields:t.fields??[],viewMode:r,objectLabels:i,dataLastUpdated:t.dataLastUpdated,isCheckingDataLastUpdated:e.isCheckingDataLastUpdated,hasIncoming:e.hasIncoming,hasOutgoing:e.hasOutgoing,highlighted:n.highlighted,dimmed:n.dimmed,direction:e.direction,onOpenExternal:e.onOpenExternal,qualitySummary:t.qualitySummary,onOpenQuality:e.onOpenQuality,onRunQuality:e.onRunQuality}}}function Ts(e){return e.joinConditions.map(t=>`${t.sourceFieldName} = ${t.targetFieldName}`)}function Ds(e){const{edge:t,warning:n}=e;return{id:t.id,type:"modelCanvasEdge",source:t.sourceId,target:t.targetId,focusable:!1,selectable:!0,deletable:!1,data:{bowOffset:e.bowOffset,warning:n,joinLabel:e.joinLabel,dimmed:e.dimmed,direction:e.direction,bidirectional:t.bidirectional}}}function Rs({nodes:e,edges:t,searchQuery:n,onOpenDataMart:r,onOpenQuality:i,onRunQuality:o,isCheckingDataLastUpdated:s=!1,storageId:a,storageTitle:l,exportApiRef:d}){const u=ur(),c=Oe(E=>E.width),f=Oe(E=>E.height),p=Oe(E=>E.domNode),v=k.useRef(r);v.current=r;const N=k.useRef(i);N.current=i;const g=k.useRef(o);g.current=o;const m=k.useRef(e);m.current=e;const b=k.useRef(n);b.current=n;const w=k.useRef(s);w.current=s;const[O,S]=k.useState(()=>yr(G.get(jt))),[j,R]=k.useState(()=>G.get(Ot)==="erd"?"erd":"compact"),[D,F]=k.useState(()=>G.get(kt,"boolean")??!1),[A,P]=k.useState(()=>as(G.get(It))),y=k.useRef(null),_=k.useRef(a);(y.current===null||_.current!==a)&&(_.current=a,y.current=vs(a));const[M,V]=k.useState(0),[Y,I]=k.useState(!1),[$,B]=k.useState([]),[J,W]=k.useState([]),Ye=k.useMemo(()=>cr($),[$]),X=Ct(e,Cs),Q=Ct(t,Ls);k.useImperativeHandle(d,()=>({exportCanvas:async E=>{const{exportModelCanvas:L}=await Wn(async()=>{const{exportModelCanvas:C}=await import("./index-WPu5BZlZ.js");return{exportModelCanvas:C}},__vite__mapDeps([0,1,2,3,4]));return L(E,{viewport:(p==null?void 0:p.querySelector(".react-flow__viewport"))??null,flowNodes:$,nodes:e,edges:t,storageTitle:l})}}),[p,$,e,t,l]),k.useEffect(()=>{const E=new Set(Q.map(x=>x.targetId)),L=new Set(Q.map(x=>x.sourceId)),C=new Map(X.map(x=>[x.id,x.status===Mt.DRAFT])),T=et(X,b.current,x=>x.id,x=>x.title),U=A.source,Z=X.map(x=>({id:x.id,width:ze(j),height:fn(x,j,U)})),re=D?new Map(Q.map(x=>[x.id,Ts(x)])):new Map,de=Q.map(x=>({id:x.id,sourceId:x.sourceId,targetId:x.targetId,label:ks(re.get(x.id)??[])})),{positions:ue}=Qo(Z,de,O),kn=Jo(Q),On=new Set(X.map(x=>x.id)),We=Object.entries(y.current??{}),ce=Object.fromEntries(We.filter(([x])=>On.has(x)));We.length!==Object.keys(ce).length&&(y.current=ce,_.current&&G.set(pe(_.current),ce));const In=new Map(m.current.map(x=>[x.id,x.qualitySummary])),Cn=new Map(m.current.map(x=>[x.id,x.dataLastUpdated]));B(X.map(x=>Ss({node:{...x,qualitySummary:In.get(x.id)??x.qualitySummary,dataLastUpdated:Cn.get(x.id)??x.dataLastUpdated},position:ce[x.id]??ue.get(x.id)??{x:0,y:0},hasIncoming:E.has(x.id),hasOutgoing:L.has(x.id),highlight:T.get(x.id)??tt,direction:O,viewMode:j,objectLabels:A,onOpenExternal:()=>{v.current(x.id)},onOpenQuality:()=>{N.current(x.id)},onRunQuality:()=>g.current(x.id),isCheckingDataLastUpdated:w.current}))),W(Q.map(x=>{var qe,Ke;const Sn=((qe=T.get(x.sourceId))==null?void 0:qe.dimmed)??!1,Tn=((Ke=T.get(x.targetId))==null?void 0:Ke.dimmed)??!1;return Ds({edge:x,joinLabel:re.get(x.id)??[],bowOffset:kn.get(x.id)??0,warning:x.joinNotConfigured||(C.get(x.sourceId)??!1)||(C.get(x.targetId)??!1),dimmed:Sn&&Tn,direction:O})})),I(!0);const Qe=[...T.entries()].filter(([,x])=>x.highlighted).map(([x])=>x),Ln=requestAnimationFrame(()=>{u.fitView(Qe.length>0?{nodes:Qe.map(x=>({id:x})),duration:300,padding:ie}:{padding:ie,duration:300})});return()=>{cancelAnimationFrame(Ln)}},[X,Q,O,M,j,D,A,u]);const gn=k.useCallback(E=>{B(L=>hr(E,L))},[]),pn=k.useCallback(E=>{W(L=>fr(E,L))},[]),[q,ye]=k.useState(null),mn=k.useCallback((E,L)=>{ye(C=>C===L.id?null:L.id),W(C=>C.some(T=>T.selected)?C.map(T=>T.selected?{...T,selected:!1}:T):C)},[]),bn=k.useCallback(()=>{ye(null)},[]),vn=k.useCallback(()=>{ye(null)},[]),wn=k.useMemo(()=>q?$.map(E=>E.id===q?{...E,selected:!0}:E):$,[$,q]),En=k.useMemo(()=>q?J.map(E=>E.source===q||E.target===q?{...E,selected:!0}:E):J,[J,q]),xn=k.useCallback((E,L)=>{const C=y.current??{};C[L.id]={x:L.position.x,y:L.position.y},y.current=C,_.current&&G.set(pe(_.current),C)},[]);k.useEffect(()=>{const E=new Map(e.map(C=>[C.id,C.qualitySummary])),L=new Map(e.map(C=>[C.id,C.dataLastUpdated]));B(C=>C.map(T=>{const U=E.get(T.id)??T.data.qualitySummary,Z=L.has(T.id)?L.get(T.id)??null:T.data.dataLastUpdated;return T.data.qualitySummary!==U||T.data.dataLastUpdated!==Z?{...T,data:{...T.data,qualitySummary:U,dataLastUpdated:Z}}:T}))},[e]),k.useEffect(()=>{B(E=>E.map(L=>L.data.isCheckingDataLastUpdated===s?L:{...L,data:{...L.data,isCheckingDataLastUpdated:s}}))},[s]),k.useEffect(()=>{const E=et(m.current,n,C=>C.id,C=>C.title);B(C=>C.map(T=>{const U=E.get(T.id)??tt;return T.data.highlighted===U.highlighted&&T.data.dimmed===U.dimmed?T:{...T,data:{...T.data,...U}}})),W(C=>C.map(T=>{var de,ue;const U=((de=E.get(T.source))==null?void 0:de.dimmed)??!1,Z=((ue=E.get(T.target))==null?void 0:ue.dimmed)??!1,re=U&&Z;return T.data.dimmed===re?T:{...T,data:{...T.data,dimmed:re}}}));const L=[...E.entries()].filter(([,C])=>C.highlighted).map(([C])=>C);L.length>0&&u.fitView({nodes:L.map(C=>({id:C})),duration:300,padding:ie})},[n,u]);const yn=k.useCallback(E=>{S(E),G.set(jt,E),y.current={},_.current&&G.remove(pe(_.current)),V(L=>L+1)},[]),_e=k.useCallback(E=>{P(L=>Me(L)===Me(E)?L:(G.set(It,Me(E)),E))},[]),_n=k.useCallback(E=>{R(E),G.set(Ot,E)},[]),Nn=k.useCallback(E=>{F(E),G.set(kt,E)},[]),jn=k.useCallback((E,L)=>{if(c===0||f===0)return;const C=gr(L,Ye,c,f,js);C.x===L.x&&C.y===L.y||u.setViewport(C)},[Ye,f,c,u]);return h.jsxs(h.Fragment,{children:[h.jsxs("div",{className:"absolute top-3 right-3 z-10 flex flex-col gap-1.5",children:[h.jsx(he,{variant:"outline",size:"icon",className:"h-12 w-12",onClick:()=>{u.fitView({padding:ie,duration:300})},"aria-label":"Fit to view",children:h.jsx(pr,{className:"h-6 w-6"})}),h.jsx(he,{variant:"outline",size:"icon",className:"h-12 w-12",onClick:()=>{u.zoomIn({duration:150})},"aria-label":"Zoom in",children:h.jsx(mr,{className:"h-6 w-6"})}),h.jsx(he,{variant:"outline",size:"icon",className:"h-12 w-12",onClick:()=>{u.zoomOut({duration:150})},"aria-label":"Zoom out",children:h.jsx(br,{className:"h-6 w-6"})}),h.jsxs(Lt,{children:[h.jsx(St,{asChild:!0,children:h.jsx(he,{variant:"outline",size:"icon",className:"h-12 w-12","aria-label":"Canvas settings",children:h.jsx(Qn,{className:"h-6 w-6"})})}),h.jsxs(Tt,{align:"end",side:"left",className:"w-56",children:[h.jsx(ge,{children:"View"}),h.jsx("div",{role:"radiogroup","aria-label":"Card view mode",className:"bg-muted mt-2 grid grid-cols-2 gap-0.5 rounded-md p-0.5",children:Es.map(E=>h.jsx("button",{type:"button",role:"radio","aria-checked":j===E.value,className:`rounded px-2 py-1 text-sm transition-colors ${j===E.value?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,onClick:()=>{_n(E.value)},children:E.label},E.value))}),h.jsx(ge,{className:"mt-3 border-t pt-3",children:"Layout algorithm"}),h.jsx("div",{role:"radiogroup","aria-label":"Layout algorithm",className:"mt-2 space-y-0.5",children:xr.map(E=>h.jsxs("button",{type:"button",role:"radio","aria-checked":O===E.value,className:"hover:bg-muted flex w-full items-center justify-between rounded px-2 py-1.5 text-left text-sm",onClick:()=>{yn(E.value)},children:[h.jsx("span",{children:E.label}),O===E.value&&h.jsx(Je,{className:"h-4 w-4"})]},E.value))}),h.jsxs("div",{className:"mt-3 flex items-center justify-between gap-2 border-t pt-3",children:[h.jsx("label",{htmlFor:"model-canvas-show-join-fields",className:"text-sm",children:"Show join fields"}),h.jsx(qn,{id:"model-canvas-show-join-fields",checked:D,onCheckedChange:Nn})]}),h.jsx(ge,{className:"mt-3 border-t pt-3",children:"Object labels"}),h.jsx("p",{className:"text-muted-foreground mt-1 text-xs leading-snug",children:"Tick what every object shows — untick to hide it."}),h.jsx("div",{className:"mt-2 space-y-0.5",children:le.map(E=>{const L=ws[E],C=!A[E];return h.jsxs("button",{type:"button",role:"checkbox","aria-checked":C,className:"hover:bg-muted flex w-full items-start gap-2 rounded px-2 py-1.5 text-left",onClick:()=>{_e(ls(A,E))},children:[h.jsx("span",{className:`mt-0.5 flex h-3.5 w-3.5 shrink-0 items-center justify-center rounded-sm border transition-colors ${C?"border-primary bg-primary text-primary-foreground":"border-input bg-background text-transparent"}`,"aria-hidden":"true",children:h.jsx(Je,{className:"h-2.5 w-2.5",strokeWidth:3.5})}),h.jsxs("span",{className:"flex min-w-0 flex-col",children:[h.jsx("span",{className:`text-sm font-medium ${C?"text-foreground":"text-muted-foreground"}`,children:L.label}),h.jsx("span",{className:"text-muted-foreground text-xs leading-snug",children:L.helper})]})]},E)})}),h.jsxs("div",{className:"mt-1 space-y-0.5 border-t pt-1",children:[h.jsxs("button",{type:"button","aria-pressed":_t(A),className:`flex w-full items-center gap-2 rounded px-2 py-1.5 text-left text-sm font-medium ${_t(A)?"bg-primary/10 text-primary":"text-foreground hover:bg-muted"}`,onClick:()=>{_e(we)},children:[h.jsx("span",{className:"w-4 shrink-0 text-center font-bold","aria-hidden":"true",children:"≡"}),"Check all — show everything"]}),h.jsxs("button",{type:"button","aria-pressed":Nt(A),className:`flex w-full items-center gap-2 rounded px-2 py-1.5 text-left text-sm font-medium ${Nt(A)?"bg-primary/10 text-primary":"text-foreground hover:bg-muted"}`,onClick:()=>{_e(os)},children:[h.jsx("span",{className:"w-4 shrink-0 text-center font-bold","aria-hidden":"true",children:"⊘"}),"Uncheck all — title only"]})]})]})]})]}),Y&&h.jsx(vr,{nodes:wn,edges:En,nodeTypes:Os,edgeTypes:Is,onNodesChange:gn,onEdgesChange:pn,onNodeDragStop:xn,onNodeClick:mn,onEdgeClick:vn,onPaneClick:bn,deleteKeyCode:null,nodesDraggable:!0,nodesConnectable:!1,elementsSelectable:!0,edgesFocusable:!1,minZoom:.05,maxZoom:2,onMove:jn,fitView:!0,fitViewOptions:{padding:ie},proOptions:{hideAttribution:!0},style:{width:"100%",height:"100%"},children:h.jsx(wr,{pannable:!0,zoomable:!0,style:{width:140,height:100},nodeColor:E=>At(E.data.definitionType)})})]})}function As({nodes:e,edges:t,searchQuery:n,onOpenDataMart:r,onOpenQuality:i,onRunQuality:o,isCheckingDataLastUpdated:s,storageId:a,storageTitle:l,exportApiRef:d,className:u,style:c}){return e.length===0?null:h.jsxs("div",{className:`relative overflow-hidden rounded-lg border ${u??""}`,style:c??{height:480},children:[h.jsx("style",{children:lr}),h.jsx(dr,{children:h.jsx(Rs,{nodes:e,edges:t,searchQuery:n,onOpenDataMart:r,onOpenQuality:i,onRunQuality:o,isCheckingDataLastUpdated:s,storageId:a,storageTitle:l,exportApiRef:d})})]})}export{As as default};
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-Cy8YfGgG.js","assets/erd-card-CzRH59fS.js","assets/index-CAz55S73.js","assets/index-D13201SI.css","assets/erd-card-BnuhLJ6X.css"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{r as k,j as h,q as Dn,t as Rn,v as Ne,P as Lt,d as St,D as je,e as Tt,f as ge,w as Pn,L as Mn,x as An,y as Fn,T as Dt,a as Rt,z as $n,H as Hn,b as Pt,A as Gn,I as Vn,E as Bn,F as Un,G as zn,K as Yn,s as G,_ as Wn,J as Mt,c as he,S as Qn,h as Je,g as qn}from"./index-CAz55S73.js";import{n as Kn,p as Jn,q as Xn,W as Zn,l as Ae,o as er,B as tr,D as Fe,r as nr,s as rr,t as ir,d as At,P as fe,k as ke,H as Xe,S as Ze,E as or,a as sr,j as ar,N as lr,R as dr,u as ur,b as Oe,g as cr,c as et,e as tt,v as hr,w as fr,f as gr,L as pr,Z as mr,h as br,i as vr,M as wr,m as Er}from"./erd-card-CzRH59fS.js";const xr=[{value:"horizontal",label:"Horizontal"},{value:"vertical",label:"Vertical"}];function yr(e){return e==="vertical"?"vertical":"horizontal"}var Ft=Object.defineProperty,_r=(e,t,n)=>t in e?Ft(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Nr=(e,t)=>{for(var n in t)Ft(e,n,{get:t[n],enumerable:!0})},jr=(e,t,n)=>_r(e,t+"",n),$t={};Nr($t,{Graph:()=>H,alg:()=>He,json:()=>Gt,version:()=>Ir});var kr=Object.defineProperty,Ht=(e,t)=>{for(var n in t)kr(e,n,{get:t[n],enumerable:!0})},H=class{constructor(e){this._isDirected=!0,this._isMultigraph=!1,this._isCompound=!1,this._nodes={},this._in={},this._preds={},this._out={},this._sucs={},this._edgeObjs={},this._edgeLabels={},this._nodeCount=0,this._edgeCount=0,this._defaultNodeLabelFn=()=>{},this._defaultEdgeLabelFn=()=>{},e&&(this._isDirected="directed"in e?e.directed:!0,this._isMultigraph="multigraph"in e?e.multigraph:!1,this._isCompound="compound"in e?e.compound:!1),this._isCompound&&(this._parent={},this._children={},this._children["\0"]={})}isDirected(){return this._isDirected}isMultigraph(){return this._isMultigraph}isCompound(){return this._isCompound}setGraph(e){return this._label=e,this}graph(){return this._label}setDefaultNodeLabel(e){return typeof e!="function"?this._defaultNodeLabelFn=()=>e:this._defaultNodeLabelFn=e,this}nodeCount(){return this._nodeCount}nodes(){return Object.keys(this._nodes)}sources(){return this.nodes().filter(e=>Object.keys(this._in[e]).length===0)}sinks(){return this.nodes().filter(e=>Object.keys(this._out[e]).length===0)}setNodes(e,t){return e.forEach(n=>{t!==void 0?this.setNode(n,t):this.setNode(n)}),this}setNode(e,t){return e in this._nodes?(arguments.length>1&&(this._nodes[e]=t),this):(this._nodes[e]=arguments.length>1?t:this._defaultNodeLabelFn(e),this._isCompound&&(this._parent[e]="\0",this._children[e]={},this._children["\0"][e]=!0),this._in[e]={},this._preds[e]={},this._out[e]={},this._sucs[e]={},++this._nodeCount,this)}node(e){return this._nodes[e]}hasNode(e){return e in this._nodes}removeNode(e){if(e in this._nodes){let t=n=>this.removeEdge(this._edgeObjs[n]);delete this._nodes[e],this._isCompound&&(this._removeFromParentsChildList(e),delete this._parent[e],this.children(e).forEach(n=>{this.setParent(n)}),delete this._children[e]),Object.keys(this._in[e]).forEach(t),delete this._in[e],delete this._preds[e],Object.keys(this._out[e]).forEach(t),delete this._out[e],delete this._sucs[e],--this._nodeCount}return this}setParent(e,t){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(t===void 0)t="\0";else{t+="";for(let n=t;n!==void 0;n=this.parent(n))if(n===e)throw new Error("Setting "+t+" as parent of "+e+" would create a cycle");this.setNode(t)}return this.setNode(e),this._removeFromParentsChildList(e),this._parent[e]=t,this._children[t][e]=!0,this}parent(e){if(this._isCompound){let t=this._parent[e];if(t!=="\0")return t}}children(e="\0"){if(this._isCompound){let t=this._children[e];if(t)return Object.keys(t)}else{if(e==="\0")return this.nodes();if(this.hasNode(e))return[]}return[]}predecessors(e){let t=this._preds[e];if(t)return Object.keys(t)}successors(e){let t=this._sucs[e];if(t)return Object.keys(t)}neighbors(e){let t=this.predecessors(e);if(t){let n=new Set(t);for(let r of this.successors(e))n.add(r);return Array.from(n.values())}}isLeaf(e){let t;return this.isDirected()?t=this.successors(e):t=this.neighbors(e),t.length===0}filterNodes(e){let t=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});t.setGraph(this.graph()),Object.entries(this._nodes).forEach(([i,o])=>{e(i)&&t.setNode(i,o)}),Object.values(this._edgeObjs).forEach(i=>{t.hasNode(i.v)&&t.hasNode(i.w)&&t.setEdge(i,this.edge(i))});let n={},r=i=>{let o=this.parent(i);return!o||t.hasNode(o)?(n[i]=o??void 0,o??void 0):o in n?n[o]:r(o)};return this._isCompound&&t.nodes().forEach(i=>t.setParent(i,r(i))),t}setDefaultEdgeLabel(e){return typeof e!="function"?this._defaultEdgeLabelFn=()=>e:this._defaultEdgeLabelFn=e,this}edgeCount(){return this._edgeCount}edges(){return Object.values(this._edgeObjs)}setPath(e,t){return e.reduce((n,r)=>(t!==void 0?this.setEdge(n,r,t):this.setEdge(n,r),r)),this}setEdge(e,t,n,r){let i,o,s,a,l=!1;typeof e=="object"&&e!==null&&"v"in e?(i=e.v,o=e.w,s=e.name,arguments.length===2&&(a=t,l=!0)):(i=e,o=t,s=r,arguments.length>2&&(a=n,l=!0)),i=""+i,o=""+o,s!==void 0&&(s=""+s);let d=oe(this._isDirected,i,o,s);if(d in this._edgeLabels)return l&&(this._edgeLabels[d]=a),this;if(s!==void 0&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(i),this.setNode(o),this._edgeLabels[d]=l?a:this._defaultEdgeLabelFn(i,o,s);let u=Or(this._isDirected,i,o,s);return i=u.v,o=u.w,Object.freeze(u),this._edgeObjs[d]=u,nt(this._preds[o],i),nt(this._sucs[i],o),this._in[o][d]=u,this._out[i][d]=u,this._edgeCount++,this}edge(e,t,n){let r=arguments.length===1?Ie(this._isDirected,e):oe(this._isDirected,e,t,n);return this._edgeLabels[r]}edgeAsObj(e,t,n){let r=arguments.length===1?this.edge(e):this.edge(e,t,n);return typeof r!="object"?{label:r}:r}hasEdge(e,t,n){return(arguments.length===1?Ie(this._isDirected,e):oe(this._isDirected,e,t,n))in this._edgeLabels}removeEdge(e,t,n){let r=arguments.length===1?Ie(this._isDirected,e):oe(this._isDirected,e,t,n),i=this._edgeObjs[r];if(i){let o=i.v,s=i.w;delete this._edgeLabels[r],delete this._edgeObjs[r],rt(this._preds[s],o),rt(this._sucs[o],s),delete this._in[s][r],delete this._out[o][r],this._edgeCount--}return this}inEdges(e,t){return this.isDirected()?this.filterEdges(this._in[e],e,t):this.nodeEdges(e,t)}outEdges(e,t){return this.isDirected()?this.filterEdges(this._out[e],e,t):this.nodeEdges(e,t)}nodeEdges(e,t){if(e in this._nodes)return this.filterEdges({...this._in[e],...this._out[e]},e,t)}_removeFromParentsChildList(e){delete this._children[this._parent[e]][e]}filterEdges(e,t,n){if(!e)return;let r=Object.values(e);return n?r.filter(i=>i.v===t&&i.w===n||i.v===n&&i.w===t):r}};function nt(e,t){e[t]?e[t]++:e[t]=1}function rt(e,t){e[t]!==void 0&&!--e[t]&&delete e[t]}function oe(e,t,n,r){let i=""+t,o=""+n;if(!e&&i>o){let s=i;i=o,o=s}return i+""+o+""+(r===void 0?"\0":r)}function Or(e,t,n,r){let i=""+t,o=""+n;if(!e&&i>o){let a=i;i=o,o=a}let s={v:i,w:o};return r&&(s.name=r),s}function Ie(e,t){return oe(e,t.v,t.w,t.name)}var Ir="4.0.1",Gt={};Ht(Gt,{read:()=>Tr,write:()=>Cr});function Cr(e){let t={options:{directed:e.isDirected(),multigraph:e.isMultigraph(),compound:e.isCompound()},nodes:Lr(e),edges:Sr(e)},n=e.graph();return n!==void 0&&(t.value=structuredClone(n)),t}function Lr(e){return e.nodes().map(t=>{let n=e.node(t),r=e.parent(t),i={v:t};return n!==void 0&&(i.value=n),r!==void 0&&(i.parent=r),i})}function Sr(e){return e.edges().map(t=>{let n=e.edge(t),r={v:t.v,w:t.w};return t.name!==void 0&&(r.name=t.name),n!==void 0&&(r.value=n),r})}function Tr(e){let t=new H(e.options);return e.value!==void 0&&t.setGraph(e.value),e.nodes.forEach(n=>{t.setNode(n.v,n.value),n.parent&&t.setParent(n.v,n.parent)}),e.edges.forEach(n=>{t.setEdge({v:n.v,w:n.w,name:n.name},n.value)}),t}var He={};Ht(He,{CycleException:()=>be,bellmanFord:()=>Vt,components:()=>Pr,dijkstra:()=>me,dijkstraAll:()=>Fr,findCycles:()=>$r,floydWarshall:()=>Gr,isAcyclic:()=>Br,postorder:()=>zr,preorder:()=>Yr,prim:()=>Wr,shortestPaths:()=>Qr,tarjan:()=>Ut,topsort:()=>zt});var Dr=()=>1;function Vt(e,t,n,r){return Rr(e,String(t),n||Dr,r||function(i){return e.outEdges(i)})}function Rr(e,t,n,r){let i={},o,s=0,a=e.nodes(),l=function(c){let f=n(c);i[c.v].distance+f<i[c.w].distance&&(i[c.w]={distance:i[c.v].distance+f,predecessor:c.v},o=!0)},d=function(){a.forEach(function(c){r(c).forEach(function(f){let p=f.v===c?f.v:f.w,v=p===f.v?f.w:f.v;l({v:p,w:v})})})};a.forEach(function(c){let f=c===t?0:Number.POSITIVE_INFINITY;i[c]={distance:f,predecessor:""}});let u=a.length;for(let c=1;c<u&&(o=!1,s++,d(),!!o);c++);if(s===u-1&&(o=!1,d(),o))throw new Error("The graph contains a negative weight cycle");return i}function Pr(e){let t={},n=[],r;function i(o){o in t||(t[o]=!0,r.push(o),e.successors(o).forEach(i),e.predecessors(o).forEach(i))}return e.nodes().forEach(function(o){r=[],i(o),r.length&&n.push(r)}),n}var Bt=class{constructor(){this._arr=[],this._keyIndices={}}size(){return this._arr.length}keys(){return this._arr.map(e=>e.key)}has(e){return e in this._keyIndices}priority(e){let t=this._keyIndices[e];if(t!==void 0)return this._arr[t].priority}min(){if(this.size()===0)throw new Error("Queue underflow");return this._arr[0].key}add(e,t){let n=this._keyIndices,r=String(e);if(!(r in n)){let i=this._arr,o=i.length;return n[r]=o,i.push({key:r,priority:t}),this._decrease(o),!0}return!1}removeMin(){this._swap(0,this._arr.length-1);let e=this._arr.pop();return delete this._keyIndices[e.key],this._heapify(0),e.key}decrease(e,t){let n=this._keyIndices[e];if(n===void 0)throw new Error(`Key not found: ${e}`);let r=this._arr[n].priority;if(t>r)throw new Error(`New priority is greater than current priority. Key: ${e} Old: ${r} New: ${t}`);this._arr[n].priority=t,this._decrease(n)}_heapify(e){let t=this._arr,n=2*e,r=n+1,i=e;n<t.length&&(i=t[n].priority<t[i].priority?n:i,r<t.length&&(i=t[r].priority<t[i].priority?r:i),i!==e&&(this._swap(e,i),this._heapify(i)))}_decrease(e){let t=this._arr,n=t[e].priority,r;for(;e!==0&&(r=e>>1,!(t[r].priority<n));)this._swap(e,r),e=r}_swap(e,t){let n=this._arr,r=this._keyIndices,i=n[e],o=n[t];n[e]=o,n[t]=i,r[o.key]=e,r[i.key]=t}},Mr=()=>1;function me(e,t,n,r){let i=function(o){return e.outEdges(o)};return Ar(e,String(t),n||Mr,r||i)}function Ar(e,t,n,r){let i={},o=new Bt,s,a,l=function(d){let u=d.v!==s?d.v:d.w,c=i[u],f=n(d),p=a.distance+f;if(f<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+d+" Weight: "+f);p<c.distance&&(c.distance=p,c.predecessor=s,o.decrease(u,p))};for(e.nodes().forEach(function(d){let u=d===t?0:Number.POSITIVE_INFINITY;i[d]={distance:u,predecessor:""},o.add(d,u)});o.size()>0&&(s=o.removeMin(),a=i[s],a.distance!==Number.POSITIVE_INFINITY);)r(s).forEach(l);return i}function Fr(e,t,n){return e.nodes().reduce(function(r,i){return r[i]=me(e,i,t,n),r},{})}function Ut(e){let t=0,n=[],r={},i=[];function o(s){let a=r[s]={onStack:!0,lowlink:t,index:t++};if(n.push(s),e.successors(s).forEach(function(l){l in r?r[l].onStack&&(a.lowlink=Math.min(a.lowlink,r[l].index)):(o(l),a.lowlink=Math.min(a.lowlink,r[l].lowlink))}),a.lowlink===a.index){let l=[],d;do d=n.pop(),r[d].onStack=!1,l.push(d);while(s!==d);i.push(l)}}return e.nodes().forEach(function(s){s in r||o(s)}),i}function $r(e){return Ut(e).filter(function(t){return t.length>1||t.length===1&&e.hasEdge(t[0],t[0])})}var Hr=()=>1;function Gr(e,t,n){return Vr(e,t||Hr,n||function(r){return e.outEdges(r)})}function Vr(e,t,n){let r={},i=e.nodes();return i.forEach(function(o){r[o]={},r[o][o]={distance:0,predecessor:""},i.forEach(function(s){o!==s&&(r[o][s]={distance:Number.POSITIVE_INFINITY,predecessor:""})}),n(o).forEach(function(s){let a=s.v===o?s.w:s.v,l=t(s);r[o][a]={distance:l,predecessor:o}})}),i.forEach(function(o){let s=r[o];i.forEach(function(a){let l=r[a];i.forEach(function(d){let u=l[o],c=s[d],f=l[d],p=u.distance+c.distance;p<f.distance&&(f.distance=p,f.predecessor=c.predecessor)})})}),r}var be=class extends Error{constructor(...e){super(...e)}};function zt(e){let t={},n={},r=[];function i(o){if(o in n)throw new be;o in t||(n[o]=!0,t[o]=!0,e.predecessors(o).forEach(i),delete n[o],r.push(o))}if(e.sinks().forEach(i),Object.keys(t).length!==e.nodeCount())throw new be;return r}function Br(e){try{zt(e)}catch(t){if(t instanceof be)return!1;throw t}return!0}function Ur(e,t,n,r,i){Array.isArray(t)||(t=[t]);let o=(a=>{var l;return(l=e.isDirected()?e.successors(a):e.neighbors(a))!=null?l:[]}),s={};return t.forEach(function(a){if(!e.hasNode(a))throw new Error("Graph does not have node: "+a);i=Yt(e,a,n==="post",s,o,r,i)}),i}function Yt(e,t,n,r,i,o,s){return t in r||(r[t]=!0,n||(s=o(s,t)),i(t).forEach(function(a){s=Yt(e,a,n,r,i,o,s)}),n&&(s=o(s,t))),s}function Wt(e,t,n){return Ur(e,t,n,function(r,i){return r.push(i),r},[])}function zr(e,t){return Wt(e,t,"post")}function Yr(e,t){return Wt(e,t,"pre")}function Wr(e,t){let n=new H,r={},i=new Bt,o;function s(l){let d=l.v===o?l.w:l.v,u=i.priority(d);if(u!==void 0){let c=t(l);c<u&&(r[d]=o,i.decrease(d,c))}}if(e.nodeCount()===0)return n;e.nodes().forEach(function(l){i.add(l,Number.POSITIVE_INFINITY),n.setNode(l)}),i.decrease(e.nodes()[0],0);let a=!1;for(;i.size()>0;){if(o=i.removeMin(),o in r)n.setEdge(o,r[o]);else{if(a)throw new Error("Input graph is not connected: "+e);a=!0}e.nodeEdges(o).forEach(s)}return n}function Qr(e,t,n,r){return qr(e,t,n,r??(i=>{let o=e.outEdges(i);return o??[]}))}function qr(e,t,n,r){if(n===void 0)return me(e,t,n,r);let i=!1,o=e.nodes();for(let s=0;s<o.length;s++){let a=r(o[s]);for(let l=0;l<a.length;l++){let d=a[l],u=d.v===o[s]?d.v:d.w,c=u===d.v?d.w:d.v;n({v:u,w:c})<0&&(i=!0)}if(i)return Vt(e,t,n,r)}return me(e,t,n,r)}function ne(e,t,n,r){let i=r;for(;e.hasNode(i);)i=Ge(r);return n.dummy=t,e.setNode(i,n),i}function Kr(e){let t=new H().setGraph(e.graph());return e.nodes().forEach(n=>t.setNode(n,e.node(n))),e.edges().forEach(n=>{let r=t.edge(n.v,n.w)||{weight:0,minlen:1},i=e.edge(n);t.setEdge(n.v,n.w,{weight:r.weight+i.weight,minlen:Math.max(r.minlen,i.minlen)})}),t}function Qt(e){let t=new H({multigraph:e.isMultigraph()}).setGraph(e.graph());return e.nodes().forEach(n=>{e.children(n).length||t.setNode(n,e.node(n))}),e.edges().forEach(n=>{t.setEdge(n,e.edge(n))}),t}function it(e,t){let n=e.x,r=e.y,i=t.x-n,o=t.y-r,s=e.width/2,a=e.height/2;if(!i&&!o)throw new Error("Not possible to find intersection inside of the rectangle");let l,d;return Math.abs(o)*s>Math.abs(i)*a?(o<0&&(a=-a),l=a*i/o,d=a):(i<0&&(s=-s),l=s,d=s*o/i),{x:n+l,y:r+d}}function ae(e){let t=se(Kt(e)+1).map(()=>[]);return e.nodes().forEach(n=>{let r=e.node(n),i=r.rank;i!==void 0&&(t[i]||(t[i]=[]),t[i][r.order]=n)}),t}function Jr(e){let t=e.nodes().map(r=>{let i=e.node(r).rank;return i===void 0?Number.MAX_VALUE:i}),n=z(Math.min,t);e.nodes().forEach(r=>{let i=e.node(r);Object.hasOwn(i,"rank")&&(i.rank-=n)})}function Xr(e){let t=e.nodes().map(s=>e.node(s).rank).filter(s=>s!==void 0),n=z(Math.min,t),r=[];e.nodes().forEach(s=>{let a=e.node(s).rank-n;r[a]||(r[a]=[]),r[a].push(s)});let i=0,o=e.graph().nodeRankFactor;Array.from(r).forEach((s,a)=>{s===void 0&&a%o!==0?--i:s!==void 0&&i&&s.forEach(l=>e.node(l).rank+=i)})}function ot(e,t,n,r){let i={width:0,height:0};return arguments.length>=4&&(i.rank=n,i.order=r),ne(e,"border",i,t)}function Zr(e,t=qt){let n=[];for(let r=0;r<e.length;r+=t){let i=e.slice(r,r+t);n.push(i)}return n}var qt=65535;function z(e,t){if(t.length>qt){let n=Zr(t);return e(...n.map(r=>e(...r)))}else return e(...t)}function Kt(e){let t=e.nodes().map(n=>{let r=e.node(n).rank;return r===void 0?Number.MIN_VALUE:r});return z(Math.max,t)}function ei(e,t){let n={lhs:[],rhs:[]};return e.forEach(r=>{t(r)?n.lhs.push(r):n.rhs.push(r)}),n}function ti(e,t){let n=Date.now();try{return t()}finally{console.log(e+" time: "+(Date.now()-n)+"ms")}}function Jt(e,t){return t()}var ni=0;function Ge(e){let t=++ni;return e+(""+t)}function se(e,t,n=1){t==null&&(t=e,e=0);let r=o=>o<t;n<0&&(r=o=>t<o);let i=[];for(let o=e;r(o);o+=n)i.push(o);return i}function ve(e,t){let n={};for(let r of t)e[r]!==void 0&&(n[r]=e[r]);return n}function Ee(e,t){let n;return typeof t=="string"?n=r=>r[t]:n=t,Object.entries(e).reduce((r,[i,o])=>(r[i]=n(o,i),r),{})}function ri(e,t){return e.reduce((n,r,i)=>(n[r]=t[i],n),{})}var xe="\0";function Xt(e,t,n){var r,i,o,s,a,l;if(!(e&&t&&n&&t.dummy==="edge"&&n.dummy==="edge"&&t.edgeObj&&n.edgeObj&&e[t.edgeObj.v]&&e[n.edgeObj.v]&&e[t.edgeObj.w]&&e[n.edgeObj.w]))return 0;let d=!0;t.edgeObj.w===n.edgeObj.w&&(d=!1);let u=d?(i=(r=e[t.edgeObj.v])==null?void 0:r.rank)!=null?i:NaN+1:(s=(o=e[t.edgeObj.w])==null?void 0:o.rank)!=null?s:NaN-1,c=Object.entries(e).find(N=>{var g,m;return((g=N[1].edgeObj)==null?void 0:g.v)===t.edgeObj.v&&((m=N[1].edgeObj)==null?void 0:m.w)===t.edgeObj.w&&N[1].rank===u}),f=Object.entries(e).find(N=>{var g,m;return((g=N[1].edgeObj)==null?void 0:g.v)===n.edgeObj.v&&((m=N[1].edgeObj)==null?void 0:m.w)===n.edgeObj.w&&N[1].rank===u});if(!c||!f)return 0;let p=(a=c[1].order)!=null?a:NaN,v=(l=f[1].order)!=null?l:NaN;return isNaN(p-v)?0:p-v}var ii="3.1.0",oi=class{constructor(){jr(this,"_sentinel");let e={};e._next=e._prev=e,this._sentinel=e}dequeue(){let e=this._sentinel,t=e._prev;if(t!==e)return st(t),t}enqueue(e){let t=this._sentinel;e._prev&&e._next&&st(e),e._next=t._next,t._next._prev=e,t._next=e,e._prev=t}toString(){let e=[],t=this._sentinel,n=t._prev;for(;n!==t;)e.push(JSON.stringify(n,si)),n=n._prev;return"["+e.join(", ")+"]"}};function st(e){e._prev._next=e._next,e._next._prev=e._prev,delete e._next,delete e._prev}function si(e,t){if(e!=="_next"&&e!=="_prev")return t}var ai=oi,li=()=>1;function di(e,t){if(e.nodeCount()<=1)return[];let n=ci(e,t||li);return ui(n.graph,n.buckets,n.zeroIdx).flatMap(r=>e.outEdges(r.v,r.w)||[])}function ui(e,t,n){var r;let i=[],o=t[t.length-1],s=t[0],a;for(;e.nodeCount();){for(;a=s.dequeue();)Ce(e,t,n,a);for(;a=o.dequeue();)Ce(e,t,n,a);if(e.nodeCount()){for(let l=t.length-2;l>0;--l)if(a=(r=t[l])==null?void 0:r.dequeue(),a){i=i.concat(Ce(e,t,n,a,!0)||[]);break}}}return i}function Ce(e,t,n,r,i){let o=[],s=i?o:void 0;return(e.inEdges(r.v)||[]).forEach(a=>{let l=e.edge(a),d=e.node(a.v);i&&o.push({v:a.v,w:a.w}),d.out-=l,$e(t,n,d)}),(e.outEdges(r.v)||[]).forEach(a=>{let l=e.edge(a),d=a.w,u=e.node(d);u.in-=l,$e(t,n,u)}),e.removeNode(r.v),s}function ci(e,t){let n=new H,r=0,i=0;e.nodes().forEach(a=>{n.setNode(a,{v:a,in:0,out:0})}),e.edges().forEach(a=>{let l=n.edge(a.v,a.w)||0,d=t(a),u=l+d;n.setEdge(a.v,a.w,u);let c=n.node(a.v),f=n.node(a.w);i=Math.max(i,c.out+=d),r=Math.max(r,f.in+=d)});let o=hi(i+r+3).map(()=>new ai),s=r+1;return n.nodes().forEach(a=>{$e(o,s,n.node(a))}),{graph:n,buckets:o,zeroIdx:s}}function $e(e,t,n){var r,i,o;n.out?n.in?(o=e[n.out-n.in+t])==null||o.enqueue(n):(i=e[e.length-1])==null||i.enqueue(n):(r=e[0])==null||r.enqueue(n)}function hi(e){let t=[];for(let n=0;n<e;n++)t.push(n);return t}function fi(e,t){(e.graph().acyclicer==="greedy"?di(e,n(e)):gi(e,t??null)).forEach(r=>{let i=e.edge(r);e.removeEdge(r),i.forwardName=r.name,i.reversed=!0,e.setEdge(r.w,r.v,i,Ge("rev"))});function n(r){return i=>r.edge(i).weight}}function gi(e,t){let n=[],r={},i={};function o(l){Object.hasOwn(i,l)||(i[l]=!0,r[l]=!0,e.outEdges(l).forEach(d=>{Object.hasOwn(r,d.w)?n.push(d):o(d.w)}),delete r[l])}function s(l){var d;Object.hasOwn(i,l)||(i[l]=!0,r[l]=!0,(d=e.outEdges(l))==null||d.forEach(u=>{var c,f;Object.hasOwn(r,u.w)||((c=t.node(l))==null?void 0:c.rank)>((f=t.node(u.w))==null?void 0:f.rank)&&mi(e,u.w,u)?n.push(u):s(u.w)}),delete r[l])}let a=o;return t&&typeof t.node=="function"&&(a=s),e.sources().forEach(a),e.nodes().forEach(a),n}function pi(e){e.edges().forEach(t=>{let n=e.edge(t);if(n.reversed){e.removeEdge(t);let r=n.forwardName;delete n.reversed,delete n.forwardName,e.setEdge(t.w,t.v,n,r)}})}function mi(e,t,n){let r=new Set;function i(o){var s;if(e.sources().includes(o))return!0;r.add(o);for(let a of(s=e.inEdges(o))!=null?s:[])if(!(a.v===n.v&&a.w===n.w)&&!r.has(a.v)&&i(a.v))return!0;return!1}return i(t)}function bi(e){e.graph().dummyChains=[],e.edges().forEach(t=>vi(e,t))}function vi(e,t){let n=t.v,r=e.node(n).rank,i=t.w,o=e.node(i).rank,s=t.name,a=e.edge(t),l=a.labelRank;if(o===r+1)return;e.removeEdge(t);let d,u,c;for(c=0,++r;r<o;++c,++r)a.points=[],u={width:0,height:0,edgeLabel:a,edgeObj:t,rank:r},d=ne(e,"edge",u,"_d"),r===l&&(u.width=a.width,u.height=a.height,u.dummy="edge-label",u.labelpos=a.labelpos),e.setEdge(n,d,{weight:a.weight},s),c===0&&e.graph().dummyChains.push(d),n=d;e.setEdge(n,i,{weight:a.weight},s)}function wi(e){e.graph().dummyChains.forEach(t=>{let n=e.node(t),r=n.edgeLabel,i;for(e.setEdge(n.edgeObj,r);n.dummy;)i=e.successors(t)[0],e.removeNode(t),r.points.push({x:n.x,y:n.y}),n.dummy==="edge-label"&&(r.x=n.x,r.y=n.y,r.width=n.width,r.height=n.height),t=i,n=e.node(t)})}function Ve(e){let t={};function n(r){let i=e.node(r);if(Object.hasOwn(t,r))return i.rank;t[r]=!0;let o=e.outEdges(r),s=o?o.map(l=>l==null?Number.POSITIVE_INFINITY:n(l.w)-e.edge(l).minlen):[],a=z(Math.min,s);return a===Number.POSITIVE_INFINITY&&(a=0),i.rank=a}e.sources().forEach(n)}function te(e,t){return e.node(t.w).rank-e.node(t.v).rank-e.edge(t).minlen}var Zt=Ei;function Ei(e){let t=new H({directed:!1}),n=e.nodes();if(n.length===0)throw new Error("Graph must have at least one node");let r=n[0],i=e.nodeCount();t.setNode(r,{});let o,s;for(;xi(t,e)<i&&(o=yi(t,e),!!o);)s=t.hasNode(o.v)?te(e,o):-te(e,o),_i(t,e,s);return t}function xi(e,t){function n(r){let i=t.nodeEdges(r);i&&i.forEach(o=>{let s=o.v,a=r===s?o.w:s;!e.hasNode(a)&&!te(t,o)&&(e.setNode(a,{}),e.setEdge(r,a,{}),n(a))})}return e.nodes().forEach(n),e.nodeCount()}function yi(e,t){return t.edges().reduce((n,r)=>{let i=Number.POSITIVE_INFINITY;return e.hasNode(r.v)!==e.hasNode(r.w)&&(i=te(t,r)),i<n[0]?[i,r]:n},[Number.POSITIVE_INFINITY,null])[1]}function _i(e,t,n){e.nodes().forEach(r=>t.node(r).rank+=n)}var{preorder:Ni,postorder:ji}=He,ki=K;K.initLowLimValues=Ue;K.initCutValues=Be;K.calcCutValue=en;K.leaveEdge=nn;K.enterEdge=rn;K.exchangeEdges=on;function K(e){e=Kr(e),Ve(e);let t=Zt(e);Ue(t),Be(t,e);let n,r;for(;n=nn(t);)r=rn(t,e,n),on(t,e,n,r)}function Be(e,t){let n=ji(e,e.nodes());n=n.slice(0,n.length-1),n.forEach(r=>Oi(e,t,r))}function Oi(e,t,n){let r=e.node(n).parent,i=e.edge(n,r);i.cutvalue=en(e,t,n)}function en(e,t,n){let r=e.node(n).parent,i=!0,o=t.edge(n,r),s=0;o||(i=!1,o=t.edge(r,n)),s=o.weight;let a=t.nodeEdges(n);return a&&a.forEach(l=>{let d=l.v===n,u=d?l.w:l.v;if(u!==r){let c=d===i,f=t.edge(l).weight;if(s+=c?f:-f,Ci(e,n,u)){let p=e.edge(n,u).cutvalue;s+=c?-p:p}}}),s}function Ue(e,t){arguments.length<2&&(t=e.nodes()[0]),tn(e,{},1,t)}function tn(e,t,n,r,i){let o=n,s=e.node(r);t[r]=!0;let a=e.neighbors(r);return a&&a.forEach(l=>{Object.hasOwn(t,l)||(n=tn(e,t,n,l,r))}),s.low=o,s.lim=n++,i?s.parent=i:delete s.parent,n}function nn(e){return e.edges().find(t=>e.edge(t).cutvalue<0)}function rn(e,t,n){let r=n.v,i=n.w;t.hasEdge(r,i)||(r=n.w,i=n.v);let o=e.node(r),s=e.node(i),a=o,l=!1;return o.lim>s.lim&&(a=s,l=!0),t.edges().filter(d=>l===at(e,e.node(d.v),a)&&l!==at(e,e.node(d.w),a)).reduce((d,u)=>te(t,u)<te(t,d)?u:d)}function on(e,t,n,r){let i=n.v,o=n.w;e.removeEdge(i,o),e.setEdge(r.v,r.w,{}),Ue(e),Be(e,t),Ii(e,t)}function Ii(e,t){let n=e.nodes().find(i=>!e.node(i).parent);if(!n)return;let r=Ni(e,[n]);r=r.slice(1),r.forEach(i=>{let o=e.node(i).parent,s=t.edge(i,o),a=!1;s||(s=t.edge(o,i),a=!0),t.node(i).rank=t.node(o).rank+(a?s.minlen:-s.minlen)})}function Ci(e,t,n){return e.hasEdge(t,n)}function at(e,t,n){return n.low<=t.lim&&t.lim<=n.lim}var Li=Si;function Si(e){let t=e.graph().ranker;if(typeof t=="function")return t(e);switch(t){case"network-simplex":lt(e);break;case"tight-tree":Di(e);break;case"longest-path":Ti(e);break;case"none":break;default:lt(e)}}var Ti=Ve;function Di(e){Ve(e),Zt(e)}function lt(e){ki(e)}var Ri=Pi;function Pi(e){let t=Ai(e),n=e.graph();Array.isArray(n.dummyChains)&&n.dummyChains.forEach(r=>{let i=e.node(r),o=i.edgeObj,s=Mi(e,t,o.v,o.w),a=s.path,l=s.lca,d=0,u=a[d],c=!0;for(;r!==o.w;){if(i=e.node(r),c){for(;(u=a[d])!==l&&e.node(u).maxRank<i.rank;)d++;u===l&&(c=!1)}if(!c){for(;d<a.length-1&&e.node(a[d+1]).minRank<=i.rank;)d++;u=a[d]}u!==void 0&&e.setParent(r,u),r=e.successors(r)[0]}})}function Mi(e,t,n,r){let i=[],o=[],s=Math.min(t[n].low,t[r].low),a=Math.max(t[n].lim,t[r].lim),l;l=n;do l=e.parent(l),i.push(l);while(l&&(t[l].low>s||a>t[l].lim));let d=l,u=r;for(;(u=e.parent(u))!==d;)o.push(u);return{path:i.concat(o.reverse()),lca:d}}function Ai(e){let t={},n=0;function r(i){let o=n;e.children(i).forEach(r),t[i]={low:o,lim:n++}}return e.children(xe).forEach(r),t}function Fi(e){let t=ne(e,"root",{},"_root"),n=$i(e),r=Object.values(n),i=z(Math.max,r)-1,o=2*i+1;e.graph().nestingRoot=t,e.edges().forEach(a=>e.edge(a).minlen*=o);let s=Hi(e)+1;e.children(xe).forEach(a=>{sn(e,t,o,s,i,n,a)}),e.graph().nodeRankFactor=o}function sn(e,t,n,r,i,o,s){var a;let l=e.children(s);if(!l.length){s!==t&&e.setEdge(t,s,{weight:0,minlen:n});return}let d=ot(e,"_bt"),u=ot(e,"_bb"),c=e.node(s);e.setParent(d,s),c.borderTop=d,e.setParent(u,s),c.borderBottom=u,l.forEach(f=>{var p;sn(e,t,n,r,i,o,f);let v=e.node(f),N=v.borderTop?v.borderTop:f,g=v.borderBottom?v.borderBottom:f,m=v.borderTop?r:2*r,b=N!==g?1:i-((p=o[s])!=null?p:0)+1;e.setEdge(d,N,{weight:m,minlen:b,nestingEdge:!0}),e.setEdge(g,u,{weight:m,minlen:b,nestingEdge:!0})}),e.parent(s)||e.setEdge(t,d,{weight:0,minlen:i+((a=o[s])!=null?a:0)})}function $i(e){let t={};function n(r,i){let o=e.children(r);o&&o.length&&o.forEach(s=>n(s,i+1)),t[r]=i}return e.children(xe).forEach(r=>n(r,1)),t}function Hi(e){return e.edges().reduce((t,n)=>t+e.edge(n).weight,0)}function Gi(e){let t=e.graph();e.removeNode(t.nestingRoot),delete t.nestingRoot,e.edges().forEach(n=>{e.edge(n).nestingEdge&&e.removeEdge(n)})}var Vi=Bi;function Bi(e){function t(n){let r=e.children(n),i=e.node(n);if(r.length&&r.forEach(t),i&&Object.hasOwn(i,"minRank")){i.borderLeft=[],i.borderRight=[];for(let o=i.minRank,s=i.maxRank+1;o<s;++o)dt(e,"borderLeft","_bl",n,i,o),dt(e,"borderRight","_br",n,i,o)}}e.children(xe).forEach(t)}function dt(e,t,n,r,i,o){let s={width:0,height:0,rank:o,borderType:t},a=i[t][o-1],l=ne(e,"border",s,n);i[t][o]=l,e.setParent(l,r),a&&e.setEdge(a,l,{weight:1})}function Ui(e){var t;let n=(t=e.graph().rankdir)==null?void 0:t.toLowerCase();(n==="lr"||n==="rl")&&an(e)}function zi(e){var t;let n=(t=e.graph().rankdir)==null?void 0:t.toLowerCase();(n==="bt"||n==="rl")&&Yi(e),(n==="lr"||n==="rl")&&(Wi(e),an(e))}function an(e){e.nodes().forEach(t=>ut(e.node(t))),e.edges().forEach(t=>ut(e.edge(t)))}function ut(e){let t=e.width;e.width=e.height,e.height=t}function Yi(e){e.nodes().forEach(t=>Le(e.node(t))),e.edges().forEach(t=>{var n;let r=e.edge(t);(n=r.points)==null||n.forEach(Le),Object.hasOwn(r,"y")&&Le(r)})}function Le(e){e.y=-e.y}function Wi(e){e.nodes().forEach(t=>Se(e.node(t))),e.edges().forEach(t=>{var n;let r=e.edge(t);(n=r.points)==null||n.forEach(Se),Object.hasOwn(r,"x")&&Se(r)})}function Se(e){let t=e.x;e.x=e.y,e.y=t}function Qi(e,t=null){let n={},r=e.nodes().filter(d=>!e.children(d).length),i=r.map(d=>e.node(d).rank),o=z(Math.max,i),s=se(o+1).map(()=>[]);function a(d){if(n[d])return;n[d]=!0;let u=e.node(d);s[u.rank].push(d);let c=e.successors(d);c&&[...c].sort((f,p)=>l(f,p)).forEach(a)}r.sort((d,u)=>e.node(d).rank-e.node(u).rank).forEach(a);function l(d,u){let c=e.node(d),f=e.node(u);return Xt(t,c,f)}return s}function qi(e,t){let n=0;for(let r=1;r<t.length;++r)n+=Ki(e,t[r-1],t[r]);return n}function Ki(e,t,n){let r=ri(n,n.map((d,u)=>u)),i=t.flatMap(d=>{let u=e.outEdges(d);return u?u.map(c=>({pos:r[c.w],weight:e.edge(c).weight})).sort((c,f)=>c.pos-f.pos):[]}),o=1;for(;o<n.length;)o<<=1;let s=2*o-1;o-=1;let a=new Array(s).fill(0),l=0;return i.forEach(d=>{let u=d.pos+o;a[u]+=d.weight;let c=0;for(;u>0;)u%2&&(c+=a[u+1]),u=u-1>>1,a[u]+=d.weight;l+=d.weight*c}),l}function Ji(e,t=[]){return t.map(n=>{let r=e.inEdges(n);if(!r||!r.length)return{v:n};{let i=r.reduce((o,s)=>{let a=e.edge(s),l=e.node(s.v);return{sum:o.sum+a.weight*l.order,weight:o.weight+a.weight}},{sum:0,weight:0});return{v:n,barycenter:i.sum/i.weight,weight:i.weight}}})}function Xi(e,t){let n={};e.forEach((i,o)=>{let s={indegree:0,in:[],out:[],vs:[i.v],i:o};i.barycenter!==void 0&&(s.barycenter=i.barycenter,s.weight=i.weight),n[i.v]=s}),t.edges().forEach(i=>{let o=n[i.v],s=n[i.w];o!==void 0&&s!==void 0&&(s.indegree++,o.out.push(s))});let r=Object.values(n).filter(i=>!i.indegree);return Zi(r)}function Zi(e){let t=[];function n(i){return o=>{o.merged||(o.barycenter===void 0||i.barycenter===void 0||o.barycenter>=i.barycenter)&&eo(i,o)}}function r(i){return o=>{o.in.push(i),--o.indegree===0&&e.push(o)}}for(;e.length;){let i=e.pop();t.push(i),i.in.reverse().forEach(n(i)),i.out.forEach(r(i))}return t.filter(i=>!i.merged).map(i=>ve(i,["vs","i","barycenter","weight"]))}function eo(e,t){let n=0,r=0;e.weight&&(n+=e.barycenter*e.weight,r+=e.weight),t.weight&&(n+=t.barycenter*t.weight,r+=t.weight),e.vs=t.vs.concat(e.vs),e.barycenter=n/r,e.weight=r,e.i=Math.min(t.i,e.i),t.merged=!0}function to(e,t,n,r,i){let o={},s=null,a=null,l=i;typeof t=="boolean"?(l=t,o={}):t&&(o=t,s=n??null,a=r??null);let d=ei(e,m=>Object.hasOwn(m,"barycenter")),u=d.lhs,c=d.rhs.sort((m,b)=>b.i-m.i),f=[],p=0,v=0,N=0;u.sort(no(a,s,!!l));for(let[m,b]of Object.entries(o)){let w=u.findIndex(O=>O.vs[0]===m);u.splice(w+1,0,b)}N=ct(f,c,N),u.forEach(m=>{N+=m.vs.length,f.push(m.vs),p+=m.barycenter*m.weight,v+=m.weight,N=ct(f,c,N)});let g={vs:f.flat(1)};return v&&(g.barycenter=p/v,g.weight=v),g}function ct(e,t,n){let r;for(;t.length&&(r=t[t.length-1]).i<=n;)t.pop(),e.push(r.vs),n++;return n}function no(e,t,n){return(r,i)=>{if(r.barycenter<i.barycenter)return-1;if(r.barycenter>i.barycenter)return 1;if(e&&(typeof r.vs[0]=="string"||typeof i.vs[0]=="string")){let o=e.node(r.vs[0]),s=e.node(i.vs[0]),a=Xt(t,o,s);if(a!==0)return a}return n?i.i-r.i:r.i-i.i}}function ln(e,t,n,r,i){var o,s,a,l,d,u,c,f,p,v,N;let g=null,m=i;typeof r=="boolean"?(m=r,g=null):r!==void 0&&(g=r);let b=e.children(t),w=e.node(t),O=w?w.borderLeft:void 0,S=w?w.borderRight:void 0,j={};O&&(b=b.filter(y=>y!==O&&y!==S));let R=Ji(e,b);R.forEach(y=>{if(e.children(y.v).length){let{result:_}=ln(e,y.v,n,g,m);j[y.v]=_,Object.hasOwn(_,"barycenter")&&io(y,_)}});let D=Xi(R,n);ro(D,j);let F={},A=!1;for(let y=0;y<D.length;y++)for(let _=y+1;_<D.length;_++)if(!(!D[y]||!D[_]||!((o=D[y])!=null&&o.barycenter)||!((s=D[_])!=null&&s.barycenter))&&((a=D[y])==null?void 0:a.barycenter)===D[_].barycenter){let M=(d=(l=D[y])==null?void 0:l.vs[0])!=null?d:"",V=(c=(u=D[_])==null?void 0:u.vs[0])!=null?c:"",Y=e.node(M),I=e.node(V);if(Y.dummy==="edge"&&I.dummy==="edge"&&((f=Y.edgeObj)==null?void 0:f.v)===((p=I.edgeObj)==null?void 0:p.v)&&((v=Y.edgeObj)==null?void 0:v.w)===((N=I.edgeObj)==null?void 0:N.w))if(Y.edgeLabel.reversed){F[V]=D[y],D.splice(y,1),y--;break}else F[M]=D[_],D.splice(_,1),_--;else A=!0}let P=to(D,F,g,e,m);if(O&&S){P.vs=[O,P.vs,S].flat(1);let y=e.predecessors(O);if(y&&y.length){let _=e.node(y[0]),M=e.predecessors(S),V=e.node(M[0]);Object.hasOwn(P,"barycenter")||(P.barycenter=0,P.weight=0),P.barycenter=(P.barycenter*P.weight+_.order+V.order)/(P.weight+2),P.weight+=2}}return Object.defineProperty(P,"result",{value:P,enumerable:!1,configurable:!0,writable:!0}),Object.defineProperty(P,"usedBias",{value:A,enumerable:!1,configurable:!0,writable:!0}),P}function ro(e,t){e.forEach(n=>{n.vs=n.vs.flatMap(r=>t[r]?t[r].vs:r)})}function io(e,t){e.barycenter!==void 0?(e.barycenter=(e.barycenter*e.weight+t.barycenter*t.weight)/(e.weight+t.weight),e.weight+=t.weight):(e.barycenter=t.barycenter,e.weight=t.weight)}function oo(e,t,n,r){r||(r=e.nodes());let i=so(e),o=new H({compound:!0}).setGraph({root:i}).setDefaultNodeLabel(s=>e.node(s));return r.forEach(s=>{let a=e.node(s),l=e.parent(s);if(a.rank===t||a.minRank<=t&&t<=a.maxRank){o.setNode(s),o.setParent(s,l||i);let d=e[n](s);d&&d.forEach(u=>{let c=u.v===s?u.w:u.v,f=o.edge(c,s),p=f!==void 0?f.weight:0;o.setEdge(c,s,{weight:e.edge(u).weight+p})}),Object.hasOwn(a,"minRank")&&o.setNode(s,{borderLeft:a.borderLeft[t],borderRight:a.borderRight[t]})}}),o}function so(e){let t;for(;e.hasNode(t=Ge("_root")););return t}function ao(e,t,n){let r={},i;n.forEach(o=>{let s=e.parent(o),a,l;for(;s;){if(a=e.parent(s),a?(l=r[a],r[a]=s):(l=i,i=s),l&&l!==s){t.setEdge(l,s);return}s=a}})}function dn(e,t={},n=null){if(typeof t.customOrder=="function"){t.customOrder(e,dn);return}let r=Kt(e),i=ht(e,se(1,r+1),"inEdges"),o=ht(e,se(r-1,-1,-1),"outEdges"),s=Qi(e,n);if(ft(e,s),t.disableOptimalOrderHeuristic)return;let a=Number.POSITIVE_INFINITY,l,d=t.constraints||[];for(let u=0,c=0;c<4;++u,++c){lo(u%2?i:o,u%4>=2,d,n),s=ae(e);let f=qi(e,s);f<a?(c=0,l=Object.assign({},s),a=f):f===a&&(l=structuredClone(s))}ft(e,l)}function ht(e,t,n){let r=new Map,i=(o,s)=>{r.has(o)||r.set(o,[]),r.get(o).push(s)};for(let o of e.nodes()){let s=e.node(o);if(typeof s.rank=="number"&&i(s.rank,o),typeof s.minRank=="number"&&typeof s.maxRank=="number")for(let a=s.minRank;a<=s.maxRank;a++)a!==s.rank&&i(a,o)}return t.map(function(o){return oo(e,o,n,r.get(o)||[])})}function lo(e,t,n,r){let i=!0,o=new H;e.forEach(function(s){n.forEach(u=>o.setEdge(u.left,u.right));let a=s.graph().root,{result:l,usedBias:d}=ln(s,a,o,r,i);t&&d&&(i=!i),l.vs.forEach((u,c)=>s.node(u).order=c),ao(s,o,l.vs)})}function ft(e,t){Object.values(t).forEach(n=>n.forEach((r,i)=>e.node(r).order=i))}function uo(e,t){let n={};function r(i,o){let s=0,a=0,l=i.length,d=o[o.length-1];return o.forEach((u,c)=>{let f=ho(e,u),p=f?e.node(f).order:l;(f||u===d)&&(o.slice(a,c+1).forEach(v=>{let N=e.predecessors(v);N&&N.forEach(g=>{let m=e.node(g),b=m.order;(b<s||p<b)&&!(m.dummy&&e.node(v).dummy)&&un(n,g,v)})}),a=c+1,s=p)}),o}return t.length&&t.reduce(r),n}function co(e,t){let n={};function r(o,s,a,l,d){se(s,a).forEach(u=>{let c=o[u];if(c!==void 0&&e.node(c).dummy){let f=e.predecessors(c);f&&f.forEach(p=>{if(p===void 0)return;let v=e.node(p);v.dummy&&(v.order<l||v.order>d)&&un(n,p,c)})}})}function i(o,s){let a=-1,l=-1,d=0;return s.forEach((u,c)=>{if(e.node(u).dummy==="border"){let f=e.predecessors(u);if(f&&f.length){let p=f[0];if(p===void 0)return;l=e.node(p).order,r(s,d,c,a,l),d=c,a=l}}r(s,d,s.length,l,o.length)}),s}return t.length&&t.reduce(i),n}function ho(e,t){if(e.node(t).dummy){let n=e.predecessors(t);if(n)return n.find(r=>e.node(r).dummy)}}function un(e,t,n){if(t>n){let i=t;t=n,n=i}let r=e[t];r||(e[t]=r={}),r[n]=!0}function fo(e,t,n){if(t>n){let i=t;t=n,n=i}let r=e[t];return r!==void 0&&Object.hasOwn(r,n)}function go(e,t,n,r,i){let o={},s={},a={};return t.forEach(l=>{l.forEach((d,u)=>{o[d]=d,s[d]=d,a[d]=u})}),t.forEach(l=>{let d=-1,u=-1,c=!1,f=l,p=l.findIndex(v=>(i==null?void 0:i.includes(v))||gt(v,e,i));p>0&&(f=[l[p],...l.slice(0,p),...l.slice(p+1)],c=!0),f.forEach(v=>{var N;let g=r(v);if(g&&g.length){i!=null&&i.includes(v)&&(g=g.filter(w=>gt(w,e,i)));let m=g.sort((w,O)=>{let S=a[w],j=a[O];return(S!==void 0?S:0)-(j!==void 0?j:0)}),b=(m.length-1)/2;for(let w=Math.floor(b),O=Math.ceil(b);w<=O;++w){let S=m[w];if(S===void 0)continue;let j=a[S];if(j!==void 0&&s[v]===v&&d<j&&a[S]!==u&&!fo(n,v,S)){let R=o[S];R!==void 0&&(s[S]=v,s[v]=o[v]=R,d=j,c&&(d=-1,u=(N=a[S])!=null?N:-1,c=!1))}}}})}),{root:o,align:s}}function po(e,t,n,r,i=!1){let o={},s=mo(e,t,n,i),a=i?"borderLeft":"borderRight";function l(p,v){let N=s.nodes().slice(),g={},m=N.pop();for(;m;){if(g[m])p(m);else{g[m]=!0,N.push(m);for(let b of v(m))N.push(b)}m=N.pop()}}function d(p){let v=s.inEdges(p);v?o[p]=v.reduce((N,g)=>{var m;let b=(m=o[g.v])!=null?m:0,w=s.edge(g);return Math.max(N,b+(w!==void 0?w:0))},0):o[p]=0}function u(p){let v=s.outEdges(p),N=Number.POSITIVE_INFINITY;v&&(N=v.reduce((m,b)=>{let w=o[b.w],O=s.edge(b);return Math.min(m,(w!==void 0?w:0)-(O!==void 0?O:0))},Number.POSITIVE_INFINITY));let g=e.node(p);N!==Number.POSITIVE_INFINITY&&g.borderType!==a&&(o[p]=Math.max(o[p]!==void 0?o[p]:0,N))}function c(p){return s.predecessors(p)||[]}function f(p){return s.successors(p)||[]}return l(d,c),l(u,f),Object.keys(r).forEach(p=>{var v;let N=n[p];N!==void 0&&(o[p]=(v=o[N])!=null?v:0)}),o}function mo(e,t,n,r){let i=new H,o=e.graph(),s=xo(o.nodesep,o.edgesep,r);return t.forEach(a=>{let l;a.forEach(d=>{let u=n[d];if(u!==void 0){if(i.setNode(u),l!==void 0){let c=n[l];if(c!==void 0){let f=i.edge(c,u);i.setEdge(c,u,Math.max(s(e,d,l),f||0))}}l=d}})}),i}function bo(e,t){return Object.values(t).reduce((n,r)=>{let i=Number.NEGATIVE_INFINITY,o=Number.POSITIVE_INFINITY;Object.entries(r).forEach(([a,l])=>{let d=yo(e,a)/2;i=Math.max(l+d,i),o=Math.min(l-d,o)});let s=i-o;return s<n[0]&&(n=[s,r]),n},[Number.POSITIVE_INFINITY,null])[1]}function vo(e,t){let n=Object.values(t),r=z(Math.min,n),i=z(Math.max,n);["u","d"].forEach(o=>{["l","r"].forEach(s=>{let a=o+s,l=e[a];if(!l||l===t)return;let d=Object.values(l),u=r-z(Math.min,d);s!=="l"&&(u=i-z(Math.max,d)),u&&(e[a]=Ee(l,c=>c+u))})})}function wo(e,t=void 0){let n=e.ul;return n?Ee(n,(r,i)=>{var o,s;if(t){let l=t.toLowerCase(),d=e[l];if(d&&d[i]!==void 0)return d[i]}let a=Object.values(e).map(l=>{let d=l[i];return d!==void 0?d:0}).sort((l,d)=>l-d);return(((o=a[1])!=null?o:0)+((s=a[2])!=null?s:0))/2}):{}}function Eo(e,t){let n=ae(e),r=Object.assign(uo(e,n),co(e,n)),i={},o;["u","d"].forEach(a=>{o=a==="u"?n:Object.values(n).reverse(),["l","r"].forEach(l=>{l==="r"&&(o=o.map(c=>Object.values(c).reverse()));let d=go(e,o,r,c=>(a==="u"?e.predecessors(c):e.successors(c))||[],t),u=po(e,o,d.root,d.align,l==="r");l==="r"&&(u=Ee(u,c=>-c)),i[a+l]=u})});let s=bo(e,i);return vo(i,s),wo(i,e.graph().align)}function xo(e,t,n){return(r,i,o)=>{let s=r.node(i),a=r.node(o),l=0,d;if(l+=s.width/2,Object.hasOwn(s,"labelpos"))switch(s.labelpos.toLowerCase()){case"l":d=-s.width/2;break;case"r":d=s.width/2;break}if(d&&(l+=n?d:-d),d=void 0,l+=(s.dummy?t:e)/2,l+=(a.dummy?t:e)/2,l+=a.width/2,Object.hasOwn(a,"labelpos"))switch(a.labelpos.toLowerCase()){case"l":d=a.width/2;break;case"r":d=-a.width/2;break}return d&&(l+=n?d:-d),l}}function yo(e,t){return e.node(t).width}function gt(e,t,n){var r;if(!n)return!1;let i=(r=t.node(e))==null?void 0:r.edgeObj;if(!i||t.node(e).edgeLabel.reversed)return!1;let o=n.indexOf(i==null?void 0:i.v),s=n.indexOf(i==null?void 0:i.w);return o!==-1&&s!==-1&&o===(s+1)%n.length||o===(s-1)%n.length}function _o(e,t){e=Qt(e),No(e),Object.entries(Eo(e,t)).forEach(([n,r])=>e.node(n).x=r)}function No(e){let t=ae(e),n=e.graph(),r=n.ranksep,i=n.rankalign,o=0;t.forEach(s=>{let a=s.reduce((l,d)=>{var u;let c=(u=e.node(d).height)!=null?u:0;return l>c?l:c},0);s.forEach(l=>{let d=e.node(l);i==="top"?d.y=o+d.height/2:i==="bottom"?d.y=o+a-d.height/2:d.y=o+a/2}),o+=a+r})}var Te=null,De=null;function jo(e,t={}){return cn(e,Jt,t),e}function pt(e,t,n){let r=t;for(;r!==void 0;){let i=e.parent(r);if(i===n)return r;r=i}}function cn(e,t,n){let r=e.nodes().filter(g=>e.children(g).length),i={};r.forEach(g=>{let m=e.node(g);if(m&&m.rankdir){let b=new H({multigraph:!0,compound:!0});b.setGraph({rankdir:m.rankdir});let w=e.children(g);w.forEach(y=>{let _={...e.node(y)};b.setNode(y,_);let M=e.parent(y);M&&M!==g&&w.includes(M)&&b.setParent(y,M)});let O=new Set;e.edges().forEach(y=>{let _=pt(e,y.v,g),M=pt(e,y.w,g);if(_&&M&&_!==M){let V=`${_}\0${M}`;O.has(V)||(O.add(V),b.setEdge(_,M,{...e.edge(y)}))}}),cn(b,t,n);let S=wt(b);mt(S,t,n),bt(b,S);let j=1/0,R=1/0,D=-1/0,F=-1/0;b.nodes().forEach(y=>{if(y===g)return;let _=b.node(y);_&&typeof _.x=="number"&&typeof _.y=="number"&&typeof _.width=="number"&&typeof _.height=="number"&&(j=Math.min(j,_.x-_.width/2),D=Math.max(D,_.x+_.width/2),R=Math.min(R,_.y-_.height/2),F=Math.max(F,_.y+_.height/2))}),(!isFinite(j)||!isFinite(R)||!isFinite(D)||!isFinite(F))&&(j=R=0,D=F=0);let A=D-j,P=F-R;i[g]={minX:j,minY:R,maxX:D,maxY:F,width:A,height:P,offsetX:j,offsetY:R},m._dagreClusterSubgraph=b}});let o=[],s=g=>{let m=[],b=(e.children(g)||[]).filter(w=>w!==g);for(;b.length>0;){let w=b.shift();m.push(w),(e.children(w)||[]).filter(O=>O!==w).forEach(O=>b.push(O))}return m},a=new Map;r.forEach(g=>{let m=e.node(g);m&&m.rankdir&&i[g]&&a.set(g,(e.children(g)||[]).filter(b=>b!==g))});let l=new Set([...a.values()].flat()),d=new Map;a.forEach((g,m)=>{l.has(m)||d.set(m,s(m))});let u=new Set([...d.values()].flat()),c=g=>{for(let[m,b]of d)if(b.includes(g))return m;return g},f=[];e.edges().forEach(g=>{(u.has(g.v)||u.has(g.w))&&f.push({edge:g,label:e.edge(g)})});let p=new Map;u.forEach(g=>{let m=e.parent(g);p.set(g,typeof m=="string"?m:void 0)}),d.forEach((g,m)=>{let b=e.node(m),w=[];g.forEach(j=>{let R=e.node(j);R&&(w.push({id:j,node:R,parent:p.get(j)}),e.removeNode(j))});let O=f.filter(({edge:j})=>g.includes(j.v)||g.includes(j.w)),S=i[m];b&&(o.push({clusterId:m,subgraph:b._dagreClusterSubgraph,bounds:S,children:g,removedNodes:w,removedEdges:O}),b.width=S.width,b.height=S.height)});let v=new Set;f.forEach(({edge:g,label:m})=>{let b=c(g.v),w=c(g.w);if(b!==w&&e.hasNode(b)&&e.hasNode(w)){let O=`${b}\0${w}`;v.has(O)||(v.add(O),e.setEdge(b,w,{...m,width:0,height:0}))}});let N=wt(e);mt(N,t,n),bt(e,N),v.forEach(g=>{let m=g.indexOf("\0"),b=g.slice(0,m),w=g.slice(m+1);e.hasEdge(b,w)&&e.removeEdge(b,w)}),o.forEach(({clusterId:g,subgraph:m,bounds:b,removedNodes:w,removedEdges:O})=>{var S,j;let R=e.node(g),D=(S=R==null?void 0:R.x)!=null?S:0,F=(j=R==null?void 0:R.y)!=null?j:0,A=(b.minX+b.maxX)/2,P=(b.minY+b.maxY)/2;w.forEach(({id:y,node:_,parent:M})=>{e.setNode(y,_),M!==void 0&&e.setParent(y,M)}),O.forEach(({edge:y,label:_})=>{e.setEdge(y,_)}),m.nodes().forEach(y=>{if(y===g)return;let _=m.node(y),M=e.node(y);M&&_&&typeof _.x=="number"&&typeof _.y=="number"&&(M.x=D+(_.x-A),M.y=F+(_.y-P))}),delete R._dagreClusterSubgraph}),r.forEach(g=>{var m,b;let w=e.node(g),O=i[g];if(w&&w.rankdir&&w._dagreClusterSubgraph&&O){let S=w._dagreClusterSubgraph,j=(m=w.x)!=null?m:0,R=(b=w.y)!=null?b:0,D=(O.minX+O.maxX)/2,F=(O.minY+O.maxY)/2;S.nodes().forEach(A=>{if(A===g)return;let P=S.node(A),y=e.node(A);if(y&&P&&typeof P.x=="number"&&typeof P.y=="number"){let _=P.x-D,M=P.y-F;y.x=j+_,y.y=R+M}}),delete w._dagreClusterSubgraph}})}function mt(e,t,n){(n==null?void 0:n.useDynamic)===!1&&(Te=null,De=null),t(" makeSpaceForEdgeLabels",()=>Do(e)),t(" removeSelfEdges",()=>Vo(e)),t(" acyclic",()=>fi(e,Te)),t(" nestingGraph.run",()=>Fi(e)),t(" rank",()=>Li(Qt(e))),t(" injectEdgeLabelProxies",()=>Ro(e)),t(" removeEmptyRanks",()=>Xr(e)),t(" nestingGraph.cleanup",()=>Gi(e)),t(" normalizeRanks",()=>Jr(e)),t(" assignRankMinMax",()=>Po(e)),t(" removeEdgeLabelProxies",()=>Mo(e)),t(" normalize.run",()=>bi(e)),t(" parentDummyChains",()=>Ri(e)),t(" addBorderSegments",()=>Vi(e)),t(" order",()=>dn(e,n,De)),t(" insertSelfEdges",()=>Bo(e)),t(" adjustCoordinateSystem",()=>Ui(e)),t(" position",()=>_o(e,n.corePath)),t(" positionSelfEdges",()=>Uo(e)),De=JSON.parse(JSON.stringify(e._nodes)),t(" removeBorderNodes",()=>Go(e)),t(" normalize.undo",()=>wi(e)),t(" fixupEdgeLabelCoords",()=>$o(e)),t(" undoCoordinateSystem",()=>zi(e)),t(" translateGraph",()=>Ao(e)),t(" assignNodeIntersects",()=>Fo(e)),t(" reversePoints",()=>Ho(e)),t(" acyclic.undo",()=>pi(e)),Te=e}function bt(e,t){e.nodes().forEach(n=>{let r=e.node(n),i=t.node(n);r&&(r.x=i.x,r.y=i.y,r.order=i.order,r.rank=i.rank,t.children(n).length&&(r.width=i.width,r.height=i.height))}),e.edges().forEach(n=>{let r=e.edge(n),i=t.edge(n);r.points=i.points,Object.hasOwn(i,"x")&&(r.x=i.x,r.y=i.y)}),e.graph().width=t.graph().width,e.graph().height=t.graph().height}var ko=["nodesep","edgesep","ranksep","marginx","marginy"],Oo={ranksep:50,edgesep:20,nodesep:50,rankdir:"TB",rankalign:"center"},Io=["acyclicer","ranker","rankdir","align","rankalign"],Co=["width","height","rank"],vt={width:0,height:0},Lo=["minlen","weight","width","height","labeloffset"],So={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},To=["labelpos"];function wt(e){let t=new H({multigraph:!0,compound:!0}),n=Pe(e.graph());return t.setGraph(Object.assign({},Oo,Re(n,ko),ve(n,Io))),e.nodes().forEach(r=>{let i=Pe(e.node(r)),o=Re(i,Co);Object.keys(vt).forEach(a=>{o[a]===void 0&&(o[a]=vt[a])}),t.setNode(r,o);let s=e.parent(r);s!==void 0&&t.setParent(r,s)}),e.edges().forEach(r=>{let i=Pe(e.edge(r));t.setEdge(r,Object.assign({},So,Re(i,Lo),ve(i,To)))}),t}function Do(e){let t=e.graph();t.ranksep/=2,e.edges().forEach(n=>{var r;let i=e.edge(n);i.minlen*=2,((r=i.labelpos)!=null?r:"r").toLowerCase()!=="c"&&(t.rankdir==="TB"||t.rankdir==="BT"?i.width+=i.labeloffset:i.height+=i.labeloffset)})}function Ro(e){e.edges().forEach(t=>{let n=e.edge(t);if(n.width&&n.height){let r=e.node(t.v),i={rank:(e.node(t.w).rank-r.rank)/2+r.rank,e:t};ne(e,"edge-proxy",i,"_ep")}})}function Po(e){let t=0;e.nodes().forEach(n=>{let r=e.node(n);r.borderTop&&(r.minRank=e.node(r.borderTop).rank,r.maxRank=e.node(r.borderBottom).rank,t=Math.max(t,r.maxRank))}),e.graph().maxRank=t}function Mo(e){e.nodes().forEach(t=>{let n=e.node(t);if(n.dummy==="edge-proxy"){let r=n;e.edge(r.e).labelRank=n.rank,e.removeNode(t)}})}function Ao(e){let t=Number.POSITIVE_INFINITY,n=0,r=Number.POSITIVE_INFINITY,i=0,o=e.graph(),s=o.marginx||0,a=o.marginy||0;function l(d){let u=d.x,c=d.y,f=d.width,p=d.height;t=Math.min(t,u-f/2),n=Math.max(n,u+f/2),r=Math.min(r,c-p/2),i=Math.max(i,c+p/2)}e.nodes().forEach(d=>l(e.node(d))),e.edges().forEach(d=>{let u=e.edge(d);Object.hasOwn(u,"x")&&l(u)}),t-=s,r-=a,e.nodes().forEach(d=>{let u=e.node(d);u.x-=t,u.y-=r}),e.edges().forEach(d=>{let u=e.edge(d);u.points.forEach(c=>{c.x-=t,c.y-=r}),Object.hasOwn(u,"x")&&(u.x-=t),Object.hasOwn(u,"y")&&(u.y-=r)}),o.width=n-t+s,o.height=i-r+a}function Fo(e){e.edges().forEach(t=>{if(t.v===t.w)return;let n=e.edge(t),r=e.node(t.v),i=e.node(t.w),o,s;n.points?(o=n.points[0],s=n.points[n.points.length-1]):(n.points=[],o=i,s=r),n.points.unshift(it(r,o)),n.points.push(it(i,s))})}function $o(e){e.edges().forEach(t=>{let n=e.edge(t);if(Object.hasOwn(n,"x"))switch((n.labelpos==="l"||n.labelpos==="r")&&(n.width-=n.labeloffset),n.labelpos){case"l":n.x-=n.width/2+n.labeloffset;break;case"r":n.x+=n.width/2+n.labeloffset;break}})}function Ho(e){e.edges().forEach(t=>{let n=e.edge(t);n.reversed&&n.points.reverse()})}function Go(e){e.nodes().forEach(t=>{if(e.children(t).length){let n=e.node(t),r=e.node(n.borderTop),i=e.node(n.borderBottom),o=e.node(n.borderLeft[n.borderLeft.length-1]),s=e.node(n.borderRight[n.borderRight.length-1]);n.width=Math.abs(s.x-o.x),n.height=Math.abs(i.y-r.y),n.x=o.x+n.width/2,n.y=r.y+n.height/2}}),e.nodes().forEach(t=>{e.node(t).dummy==="border"&&e.removeNode(t)})}function Vo(e){e.edges().forEach(t=>{if(t.v===t.w){let n=e.node(t.v);n.selfEdges||(n.selfEdges=[]),n.selfEdges.push({e:t,label:e.edge(t)}),e.removeEdge(t)}})}function Bo(e){ae(e).forEach(t=>{let n=0;t.forEach((r,i)=>{let o=e.node(r);typeof o.rank!="number"&&(o.rank=0),o.order=i+n,(o.selfEdges||[]).forEach(s=>{ne(e,"selfedge",{width:s.label.width,height:s.label.height,rank:o.rank,order:i+ ++n,e:s.e,edgeLabel:s.label},"_se"),(!Array.isArray(s.label.points)||s.label.points.length!==7)&&(s.label.points=[{x:0,y:-10},{x:0,y:-10},{x:0,y:0},{x:0,y:10},{x:0,y:10},{x:0,y:0},{x:0,y:0}])}),delete o.selfEdges})})}function Uo(e){e.nodes().forEach(t=>{let n=e.node(t),r=i=>typeof i=="number"&&isFinite(i);if(n.dummy==="selfedge"){let i=n,o=e.node(i.e.v),s=r(o==null?void 0:o.x)?o.x:0,a=r(o==null?void 0:o.y)?o.y:0,l=r(o==null?void 0:o.width)?o.width:0,d=r(o==null?void 0:o.height)?o.height:0,u=r(n.x)?n.x:s,c=r(n.y)?n.y:a,f=l/2,p=d/2;i.edgeLabel.points=[{x:u+f,y:c-p},{x:u+f,y:c-p},{x:u,y:c},{x:u-f,y:c+p},{x:u-f,y:c+p},{x:u,y:c},{x:u,y:c}],i.edgeLabel.x=u,i.edgeLabel.y=c,e.setEdge(i.e,i.edgeLabel),e.removeNode(t)}else n&&Array.isArray(n.selfEdges)&&n.selfEdges.forEach(i=>{if(!Array.isArray(i.label.points)||i.label.points.length!==7){let o=r(n.x)?n.x:0,s=r(n.y)?n.y:0,a=r(n.width)?n.width:0,l=r(n.height)?n.height:0,d=a/2,u=l/2;i.label.points=[{x:o+d,y:s-u},{x:o+d,y:s-u},{x:o,y:s},{x:o-d,y:s+u},{x:o-d,y:s+u},{x:o,y:s},{x:o,y:s}]}})})}function Re(e,t){return Ee(ve(e,t),Number)}function Pe(e){let t={};return e&&Object.entries(e).forEach(([n,r])=>{typeof n=="string"&&(n=n.toLowerCase()),t[n]=r}),t}function zo(e){let t=ae(e),n=new H({compound:!0,multigraph:!0}).setGraph({});return e.nodes().forEach(r=>{n.setNode(r,{label:r}),n.setParent(r,"layer"+e.node(r).rank)}),e.edges().forEach(r=>n.setEdge(r.v,r.w,{},r.name)),t.forEach((r,i)=>{let o="layer"+i;n.setNode(o,{rank:"same"}),r.reduce((s,a)=>(n.setEdge(s,a,{style:"invis"}),a))}),n}var Yo={graphlib:$t,version:ii,layout:jo,debug:zo,util:{time:ti,notime:Jt}},Et=Yo;/*! For license information please see dagre.esm.js.LEGAL.txt */const xt=80;function Wo(e,t){const n=new Map,r=Math.ceil(Math.sqrt(e.length)),{maxWidth:i,maxHeight:o}=e.reduce((s,a)=>({maxWidth:Math.max(s.maxWidth,a.width),maxHeight:Math.max(s.maxHeight,a.height)}),{maxWidth:0,maxHeight:0});return e.forEach((s,a)=>{const l=a%r,d=Math.floor(a/r),u=t==="horizontal"?l:d,c=t==="horizontal"?d:l;n.set(s.id,{x:u*(i+xt),y:c*(o+xt)})}),n}function Qo(e,t,n){const r=new Map,i=new Map,o=new Map;if(e.length===0)return{positions:r,routes:i,labelPositions:o};const s=new Et.graphlib.Graph({multigraph:!0});s.setGraph({rankdir:n==="horizontal"?"LR":"TB"}),s.setDefaultEdgeLabel(()=>({}));for(const a of e)s.setNode(a.id,{width:a.width,height:a.height});for(const a of t){const l=a.label?{width:a.label.width,height:a.label.height,labelpos:"c"}:{};s.setEdge(a.sourceId,a.targetId,l,a.id)}try{Et.layout(s)}catch(a){if(!(a instanceof RangeError))throw a;return{positions:Wo(e,n),routes:i,labelPositions:o}}for(const a of s.nodes()){const l=s.node(a);l.x===void 0||l.y===void 0||r.set(a,{x:l.x-l.width/2,y:l.y-l.height/2})}for(const a of t){const l=s.edge({v:a.sourceId,w:a.targetId,name:a.id}),d=(l.points??[]).slice(1,-1);d.length>0&&i.set(a.id,d),l.x!==void 0&&l.y!==void 0&&o.set(a.id,{x:l.x,y:l.y})}return{positions:r,routes:i,labelPositions:o}}const qo=(e,t)=>[e,t].sort().join("->"),Ko=56;function Jo(e,t=Ko){const n=new Map;for(const i of e){if(i.sourceId===i.targetId)continue;const o=qo(i.sourceId,i.targetId),s=n.get(o);s?s.push(i):n.set(o,[i])}const r=new Map;for(const i of e)i.sourceId===i.targetId&&r.set(i.id,0);for(const i of n.values()){const o=[...i].sort((a,l)=>a.id.localeCompare(l.id)),s=o.length;o.forEach((a,l)=>{r.set(a.id,(l-(s-1)/2)*t)})}return r}const Xo=212,yt=116,Zo=256,es=88,ts=26,ns=26,rs=4;function ze(e){return e==="erd"?Zo:Xo}function is(e){return[...e.filter(t=>t.isPrimaryKey),...e.filter(t=>!t.isPrimaryKey)]}function hn(e){const t=e.filter(n=>n.isPrimaryKey).length;return Math.min(e.length,Math.max(rs,t))}function fn(e,t,n=!1,r=!1){const i=(n?-36:0)+(r?-30:0);if(t!=="erd")return yt+i;const o=e.fields??[];if(o.length===0)return yt+i;const s=hn(o),a=o.length>s;return es+i+s*ts+(a?ns:0)}const le=["source","fields","status"],we={source:!1,fields:!1,status:!1},os={source:!0,fields:!0,status:!0};function ss(e){return le.includes(e)}function as(e){if(e===null)return we;const t={...we};for(const n of e.split(",")){const r=n.trim();ss(r)&&(t[r]=!0)}return t}function Me(e){return le.filter(t=>e[t]).join(",")}function ls(e,t){return{...e,[t]:!e[t]}}function _t(e){return le.every(t=>!e[t])}function Nt(e){return le.every(t=>e[t])}function ds(e,t,n,r,i,o){let s,a,l,d;if(o==="vertical"){const u=Math.max(40,Math.abs(r-t)*.3);s=e+i,a=t+u,l=n+i,d=r-u}else{const u=Math.max(40,Math.abs(n-e)*.3);s=e+u,a=t+i,l=n-u,d=r+i}return{path:`M ${e} ${t} C ${s} ${a}, ${l} ${d}, ${n} ${r}`,labelX:(e+3*s+3*l+n)/8,labelY:(t+3*a+3*d+r)/8}}function us({id:e,sourceX:t,sourceY:n,targetX:r,targetY:i,sourcePosition:o,targetPosition:s,selected:a,data:l}){const{bowOffset:d,warning:u,joinLabel:c,dimmed:f,direction:p,bidirectional:v}=l;let N;if(d!==0)N=ds(t,n,r,i,d,p);else{const[w,O,S]=Kn({sourceX:t,sourceY:n,sourcePosition:o,targetX:r,targetY:i,targetPosition:s});N={path:w,labelX:O,labelY:S}}const g=u?Zn:a?Ae:er,m=k.useId(),b=Jn("mc-arrow",m);return h.jsxs(h.Fragment,{children:[h.jsx(Xn,{markerId:b,color:g,withStart:v}),h.jsx(tr,{id:e,path:N.path,markerEnd:`url(#${b}-end)`,markerStart:v?`url(#${b}-start)`:void 0,style:{stroke:g,strokeWidth:a?rr:ir,strokeDasharray:u?nr:void 0,opacity:f?Fe:1,transition:"opacity 0.2s, stroke 0.2s"}}),c.length>0&&h.jsx("foreignObject",{x:N.labelX,y:N.labelY,width:1,height:1,style:{overflow:"visible"},children:h.jsx("div",{style:{transform:"translate(-50%, -50%)",width:"max-content",background:"var(--background)",border:`1px solid ${a?"var(--primary)":"var(--border)"}`,borderRadius:8,padding:"3px 8px",fontSize:11,fontWeight:600,lineHeight:1.5,color:"var(--foreground)",pointerEvents:"none",opacity:f?Fe:1,transition:"opacity 0.2s",boxShadow:"0 1px 3px 0 rgba(0,0,0,0.08)"},children:c.map(w=>h.jsx("div",{children:w},w))})})]})}const cs=100,hs=200;function ee(e,t){return`${e} ${t}${e===1?"":"s"}`}function fs({dataMartTitle:e,summary:t,onOpenQuality:n,onRunQuality:r}){const[i,o]=k.useState(!1),[s,a]=k.useState(!1),l=k.useRef(null),d=k.useRef(null),u=k.useRef(null),c=k.useRef(null),f=k.useRef(null),p=k.useRef(!1),v=k.useRef(!1),N=k.useRef(!1),g=Dn(t),m=g.icon,b=[{count:t.errorChecks,singular:"execution error",tone:"error",icon:Rn},{count:t.errorFindings,singular:"critical finding",tone:"error",icon:Ne},{count:t.warningFindings,singular:"warning finding",tone:"warning",icon:Ne},{count:t.noticeFindings,singular:"notice finding",tone:"notice",icon:Ne}].filter(I=>I.count>0),w=(t.state==="ISSUES"||t.state==="EXECUTION_FAILED")&&b.length>0,O=b.map(I=>ee(I.count,I.singular)).join(", "),S=`Open Data Quality for ${e}: ${g.label}${w?`, ${O}`:""}`,j=g.isActive,R=t.state==="QUEUED"?"Queued":t.state==="RUNNING"?"Started":"Last checked";function D(){c.current!==null&&(clearTimeout(c.current),c.current=null)}function F(){f.current!==null&&(clearTimeout(f.current),f.current=null)}function A(){D(),F()}function P(){F(),!(i||p.current||c.current!==null)&&(c.current=setTimeout(()=>{c.current=null,!p.current&&o(!0)},cs))}function y(){D(),!(!i||p.current||f.current!==null)&&(f.current=setTimeout(()=>{f.current=null,!p.current&&o(!1)},hs))}function _(I){if(I.stopPropagation(),I.preventDefault(),A(),p.current&&i){p.current=!1,o(!1);return}p.current=!0,o(!0),I.detail===0&&queueMicrotask(()=>{var $;($=u.current)==null||$.focus()})}function M(I){if(A(),I){p.current=!0,o(!0);return}p.current=!1,o(!1)}function V(I){I.stopPropagation(),I.preventDefault(),n()}async function Y(I){if(I.stopPropagation(),I.preventDefault(),!(j||s)){a(!0);try{await r()}finally{a(!1)}}}return k.useEffect(()=>()=>{c.current!==null&&clearTimeout(c.current),f.current!==null&&clearTimeout(f.current)},[]),k.useEffect(()=>{if(!i)return;function I($){var J,W;const B=$.target;B instanceof Node&&((J=l.current)!=null&&J.contains(B)||(W=d.current)!=null&&W.contains(B)||(c.current!==null&&(clearTimeout(c.current),c.current=null),f.current!==null&&(clearTimeout(f.current),f.current=null),p.current=!1,o(!1)))}return document.addEventListener("pointerdown",I,!0),()=>{document.removeEventListener("pointerdown",I,!0)}},[i]),h.jsxs(Lt,{open:i,onOpenChange:M,children:[h.jsx(St,{asChild:!0,children:h.jsx("button",{ref:l,type:"button",className:`${w?"":je[g.tone]} -ml-0.5 inline-flex shrink-0 cursor-pointer items-center rounded p-0.5 transition-colors ${w?"gap-1.5":""}`,"aria-label":S,onPointerDown:I=>{I.stopPropagation()},onPointerEnter:()=>{P()},onPointerLeave:()=>{y()},onFocus:()=>{if(N.current){N.current=!1;return}P()},onBlur:()=>{y()},onClick:_,children:w?b.map(I=>{const $=ee(I.count,I.singular),B=I.icon;return h.jsxs("span",{role:"img","aria-label":$,className:`${je[I.tone]} inline-flex items-center gap-0.5`,children:[h.jsx(B,{className:"size-4","aria-hidden":!0}),h.jsx("span",{className:"leading-none font-medium tabular-nums",children:I.count})]},I.singular)}):h.jsx(m,{className:`size-4 ${t.state==="RUNNING"?"animate-spin":""}`,"aria-hidden":!0})})}),h.jsxs(Tt,{ref:d,side:"top",align:"center",role:"region","aria-label":`Data Quality checks for ${e}`,className:"w-72 max-w-72 p-3 text-xs sm:w-72 sm:max-w-72",onOpenAutoFocus:I=>{I.preventDefault()},onCloseAutoFocus:I=>{var $;I.preventDefault(),v.current&&(v.current=!1,N.current=!0,($=l.current)==null||$.focus({preventScroll:!0}),queueMicrotask(()=>{N.current=!1}))},onEscapeKeyDown:()=>{v.current=!0},onPointerEnter:()=>{F()},onPointerLeave:()=>{y()},onPointerDown:I=>{I.stopPropagation()},children:[h.jsxs("div",{className:"border-border flex items-center justify-between gap-3 border-b pb-2",children:[h.jsx(ge,{className:"text-sm font-semibold whitespace-nowrap",children:"Data Quality checks"}),h.jsx("span",{className:`${je[g.tone]} shrink-0 font-medium whitespace-nowrap`,children:g.label})]}),h.jsxs("div",{className:"text-muted-foreground space-y-1 py-2",children:[t.enabledChecks>0&&h.jsxs("p",{children:[t.enabledChecks," enabled"]}),j?h.jsx("p",{children:"Terminal results will be available after this run finishes."}):h.jsxs(h.Fragment,{children:[t.passedChecks>0&&h.jsxs("p",{children:[t.passedChecks," passed"]}),t.notApplicableChecks>0&&h.jsxs("p",{children:[t.notApplicableChecks," not applicable"]}),t.errorChecks>0&&h.jsx("p",{children:ee(t.errorChecks,"execution error")}),t.errorFindings>0&&h.jsx("p",{children:ee(t.errorFindings,"critical finding")}),t.warningFindings>0&&h.jsx("p",{children:ee(t.warningFindings,"warning finding")}),t.noticeFindings>0&&h.jsx("p",{children:ee(t.noticeFindings,"notice finding")})]}),t.lastRunAt&&h.jsx("p",{className:"text-foreground pt-2 pb-1 font-medium",children:`${R} ${Pn(t.lastRunAt)}`})]}),h.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[h.jsx("button",{ref:u,type:"button",className:"border-input bg-background hover:bg-muted inline-flex cursor-pointer items-center justify-center rounded-md border px-3 py-1.5 font-medium transition-colors","aria-label":`Open Data Quality page for ${e}`,onPointerDown:I=>{I.stopPropagation()},onClick:V,children:"Open"}),h.jsxs("button",{type:"button",className:"bg-primary text-primary-foreground hover:bg-primary/90 inline-flex cursor-pointer items-center justify-center gap-1.5 rounded-md px-3 py-1.5 font-medium transition-colors disabled:cursor-not-allowed disabled:opacity-50","aria-label":`Run Quality for ${e}`,title:j?"A Data Quality run is already active":void 0,disabled:j||s,onPointerDown:I=>{I.stopPropagation()},onClick:I=>{Y(I)},children:[s?h.jsx(Mn,{className:"size-3.5 animate-spin","aria-hidden":"true"}):h.jsx(An,{className:"size-3.5","aria-hidden":"true"}),s?"Starting…":"Run checks"]})]})]})]})}function gs({dataMartTitle:e,block:t,isChecking:n=!1}){const r=n?"checking…":Fn(t);return h.jsxs(Dt,{children:[h.jsx(Rt,{asChild:!0,children:h.jsx("button",{type:"button",className:`nodrag inline-flex cursor-default items-center rounded p-0.5 transition-colors ${n||t!=null&&t.dataLastUpdatedAt?"text-muted-foreground hover:text-foreground":"text-muted-foreground/50 hover:text-muted-foreground"}`,"aria-label":`Data Last Updated for ${e}: ${r}`,onPointerDown:i=>{i.stopPropagation()},children:n?h.jsx($n,{className:"h-3.5 w-3.5 animate-spin","aria-hidden":"true"}):h.jsx(Hn,{className:"h-3.5 w-3.5","aria-hidden":"true"})})}),h.jsx(Pt,{side:"top",align:"start",role:"tooltip",className:"max-w-xs",children:n?h.jsx("div",{className:"text-xs",children:"Checking Data Last Updated…"}):t?h.jsx(Gn,{block:t}):h.jsx("div",{className:"text-xs",children:"Data Last Updated has not been checked yet. Use Actions → Check Data Last Updated to measure the visible Data Marts."})})]})}function ps({field:e}){return h.jsxs("div",{className:"border-border/50 flex items-center gap-2 border-b px-3.5 py-1.5 text-[11.5px] last:border-b-0",style:{opacity:e.isHidden?.5:1},title:e.isHidden?`${e.alias} (hidden from reporting)`:e.alias,children:[e.isPrimaryKey?h.jsx(Yn,{className:"h-3 w-3 shrink-0",style:{color:ar},"aria-label":"Primary key"}):h.jsx("span",{className:"w-3 shrink-0"}),h.jsx("span",{className:"text-foreground flex-1 truncate",children:e.alias}),h.jsx("span",{className:"text-muted-foreground shrink-0 font-mono text-[10px] tracking-tight",children:e.type})]})}function ms({data:e,selected:t}){const[n,r]=k.useState(!1),i=At(e.definitionType),o=e.viewMode==="erd",s=e.fields,a=o&&s.length>0,l=e.objectLabels??we,d=!l.source,u=!l.fields,c=!l.status,f=l.source&&l.fields&&l.status,p=is(s),v=hn(s),N=n?p:p.slice(0,v),g=p.length-v,m=e.direction==="vertical"?fe.Top:fe.Left,b=e.direction==="vertical"?fe.Bottom:fe.Right,w=`Open ${e.title} in new tab`;function O(j){j.stopPropagation(),j.preventDefault(),e.onOpenExternal()}function S(j){j.stopPropagation(),j.preventDefault(),r(R=>!R)}return h.jsxs("div",{className:"bg-background relative flex cursor-grab flex-col overflow-hidden rounded-xl border shadow-sm active:cursor-grabbing",style:{width:ze(e.viewMode),borderColor:e.highlighted?ke:t?Ae:void 0,boxShadow:e.highlighted?`0 0 0 3px ${ke}40, 0 0 12px ${ke}60`:t?`0 0 0 1px ${Ae}`:void 0,opacity:e.dimmed?Fe:1,filter:e.dimmed?"grayscale(0.8)":void 0,animation:e.highlighted?"node-pulse 1.5s ease-in-out infinite":void 0,transition:"opacity 0.2s, filter 0.2s"},children:[e.hasIncoming&&h.jsx(Xe,{type:"target",position:m,isConnectable:!1,style:Ze}),h.jsxs("div",{className:`flex items-center gap-2 px-3.5 pt-3 ${f?"pb-3":"pb-1"}`,children:[d&&h.jsx("span",{className:"h-4 w-1 shrink-0 rounded-sm",style:{background:i},"aria-hidden":"true"}),h.jsx("span",{className:"text-foreground flex-1 truncate text-[13px] font-semibold",title:e.title,children:e.title}),c&&h.jsx(or,{isDraft:e.isDraft}),e.description&&h.jsxs(Dt,{children:[h.jsx(Rt,{asChild:!0,children:h.jsx("button",{type:"button",className:"text-muted-foreground hover:text-foreground nodrag inline-flex cursor-default rounded p-0.5 transition-colors","aria-label":`Description for ${e.title}`,onPointerDown:j=>{j.stopPropagation()},children:h.jsx(Vn,{className:"h-3.5 w-3.5","aria-hidden":"true"})})}),h.jsx(Pt,{side:"top",align:"center",role:"tooltip",className:"max-w-xs",children:e.description})]}),h.jsx("button",{type:"button",className:"text-muted-foreground hover:text-foreground nodrag shrink-0 cursor-pointer rounded p-0.5 transition-colors",onPointerDown:j=>{j.stopPropagation()},onClick:O,title:w,"aria-label":w,children:h.jsx(Bn,{className:"h-3.5 w-3.5","aria-hidden":"true"})})]}),d&&h.jsx("div",{className:"text-muted-foreground flex items-center gap-2 px-3.5 pt-1 text-[11px]",children:h.jsx(sr,{type:e.definitionType})}),!f&&h.jsxs("div",{className:"text-muted-foreground flex items-center gap-1 px-3.5 pt-1 pb-3 text-[11px]",children:[h.jsx(fs,{dataMartTitle:e.title,summary:e.qualitySummary,onOpenQuality:e.onOpenQuality,onRunQuality:e.onRunQuality}),h.jsx(gs,{dataMartTitle:e.title,block:e.dataLastUpdated,isChecking:e.isCheckingDataLastUpdated}),u&&h.jsxs("span",{className:"ml-auto shrink-0",children:[e.fieldCount," field",e.fieldCount!==1?"s":""]})]}),a&&h.jsxs("div",{className:"border-t",children:[N.map(j=>h.jsx(ps,{field:j},j.name)),g>0&&h.jsx("button",{type:"button",className:"text-muted-foreground hover:text-foreground hover:bg-muted nodrag flex w-full items-center justify-center gap-1 border-t py-1.5 text-[11px] font-medium transition-colors",onPointerDown:j=>{j.stopPropagation()},onClick:S,children:n?h.jsxs(h.Fragment,{children:[h.jsx(Un,{className:"h-3 w-3"})," Show less"]}):h.jsxs(h.Fragment,{children:[h.jsx(zn,{className:"h-3 w-3"})," +",g," more field",g!==1?"s":""]})})]}),e.hasOutgoing&&h.jsx(Xe,{type:"source",position:b,isConnectable:!1,style:Ze})]})}const jt="model-canvas-layout",kt="model-canvas-show-join-fields",Ot="model-canvas-view-mode",It="model-canvas-object-labels",bs="model-canvas-positions";function pe(e){return`${bs}:${e}`}function vs(e){if(!e)return{};const t=G.get(pe(e),"json");if(!t)return{};const n={};for(const[r,i]of Object.entries(t)){const o=i;o&&typeof o.x=="number"&&typeof o.y=="number"&&(n[r]={x:o.x,y:o.y})}return n}const ws={source:{label:"Input source",helper:"The source badge (VIEW / TABLE / SQL / CONNECTOR) and its accent stripe"},fields:{label:"Field count",helper:"The field count shown on each object"},status:{label:"Status dot",helper:"The published/draft status dot in the card header"}},Es=[{value:"compact",label:"Compact"},{value:"erd",label:"Detailed"}],ie=.2,xs=6.6,ys=18,_s=16.5,Ns=8,js=150;function ks(e){return e.length===0?void 0:{width:Math.max(...e.map(n=>n.length))*xs+ys,height:e.length*_s+Ns}}const Os={modelCanvasNode:ms},Is={modelCanvasEdge:us};function Cs(e){return JSON.stringify(e.map(({id:t,title:n,status:r,description:i,fieldCount:o,definitionType:s,fields:a})=>({id:t,title:n,status:r,description:i,fieldCount:o,definitionType:s,fields:a})))}function Ls(e){return JSON.stringify(e)}function Ct(e,t){const n=t(e),r=k.useRef({signature:n,value:e});return r.current.signature!==n&&(r.current={signature:n,value:e}),r.current.value}function Ss(e){const{node:t,highlight:n,viewMode:r,objectLabels:i}=e,o=i.source,s=i.source&&i.fields&&i.status;return{id:t.id,type:"modelCanvasNode",position:e.position,width:ze(r),height:fn(t,r,o,s),draggable:!0,selectable:!1,focusable:!1,deletable:!1,style:Er,data:{title:t.title,isDraft:t.status===Mt.DRAFT,fieldCount:t.fieldCount,description:t.description,definitionType:t.definitionType??null,fields:t.fields??[],viewMode:r,objectLabels:i,dataLastUpdated:t.dataLastUpdated,isCheckingDataLastUpdated:e.isCheckingDataLastUpdated,hasIncoming:e.hasIncoming,hasOutgoing:e.hasOutgoing,highlighted:n.highlighted,dimmed:n.dimmed,direction:e.direction,onOpenExternal:e.onOpenExternal,qualitySummary:t.qualitySummary,onOpenQuality:e.onOpenQuality,onRunQuality:e.onRunQuality}}}function Ts(e){return e.joinConditions.map(t=>`${t.sourceFieldName} = ${t.targetFieldName}`)}function Ds(e){const{edge:t,warning:n}=e;return{id:t.id,type:"modelCanvasEdge",source:t.sourceId,target:t.targetId,focusable:!1,selectable:!0,deletable:!1,data:{bowOffset:e.bowOffset,warning:n,joinLabel:e.joinLabel,dimmed:e.dimmed,direction:e.direction,bidirectional:t.bidirectional}}}function Rs({nodes:e,edges:t,searchQuery:n,onOpenDataMart:r,onOpenQuality:i,onRunQuality:o,isCheckingDataLastUpdated:s=!1,storageId:a,storageTitle:l,exportApiRef:d}){const u=ur(),c=Oe(E=>E.width),f=Oe(E=>E.height),p=Oe(E=>E.domNode),v=k.useRef(r);v.current=r;const N=k.useRef(i);N.current=i;const g=k.useRef(o);g.current=o;const m=k.useRef(e);m.current=e;const b=k.useRef(n);b.current=n;const w=k.useRef(s);w.current=s;const[O,S]=k.useState(()=>yr(G.get(jt))),[j,R]=k.useState(()=>G.get(Ot)==="erd"?"erd":"compact"),[D,F]=k.useState(()=>G.get(kt,"boolean")??!1),[A,P]=k.useState(()=>as(G.get(It))),y=k.useRef(null),_=k.useRef(a);(y.current===null||_.current!==a)&&(_.current=a,y.current=vs(a));const[M,V]=k.useState(0),[Y,I]=k.useState(!1),[$,B]=k.useState([]),[J,W]=k.useState([]),Ye=k.useMemo(()=>cr($),[$]),X=Ct(e,Cs),Q=Ct(t,Ls);k.useImperativeHandle(d,()=>({exportCanvas:async E=>{const{exportModelCanvas:L}=await Wn(async()=>{const{exportModelCanvas:C}=await import("./index-Cy8YfGgG.js");return{exportModelCanvas:C}},__vite__mapDeps([0,1,2,3,4]));return L(E,{viewport:(p==null?void 0:p.querySelector(".react-flow__viewport"))??null,flowNodes:$,nodes:e,edges:t,storageTitle:l})}}),[p,$,e,t,l]),k.useEffect(()=>{const E=new Set(Q.map(x=>x.targetId)),L=new Set(Q.map(x=>x.sourceId)),C=new Map(X.map(x=>[x.id,x.status===Mt.DRAFT])),T=et(X,b.current,x=>x.id,x=>x.title),U=A.source,Z=X.map(x=>({id:x.id,width:ze(j),height:fn(x,j,U)})),re=D?new Map(Q.map(x=>[x.id,Ts(x)])):new Map,de=Q.map(x=>({id:x.id,sourceId:x.sourceId,targetId:x.targetId,label:ks(re.get(x.id)??[])})),{positions:ue}=Qo(Z,de,O),kn=Jo(Q),On=new Set(X.map(x=>x.id)),We=Object.entries(y.current??{}),ce=Object.fromEntries(We.filter(([x])=>On.has(x)));We.length!==Object.keys(ce).length&&(y.current=ce,_.current&&G.set(pe(_.current),ce));const In=new Map(m.current.map(x=>[x.id,x.qualitySummary])),Cn=new Map(m.current.map(x=>[x.id,x.dataLastUpdated]));B(X.map(x=>Ss({node:{...x,qualitySummary:In.get(x.id)??x.qualitySummary,dataLastUpdated:Cn.get(x.id)??x.dataLastUpdated},position:ce[x.id]??ue.get(x.id)??{x:0,y:0},hasIncoming:E.has(x.id),hasOutgoing:L.has(x.id),highlight:T.get(x.id)??tt,direction:O,viewMode:j,objectLabels:A,onOpenExternal:()=>{v.current(x.id)},onOpenQuality:()=>{N.current(x.id)},onRunQuality:()=>g.current(x.id),isCheckingDataLastUpdated:w.current}))),W(Q.map(x=>{var qe,Ke;const Sn=((qe=T.get(x.sourceId))==null?void 0:qe.dimmed)??!1,Tn=((Ke=T.get(x.targetId))==null?void 0:Ke.dimmed)??!1;return Ds({edge:x,joinLabel:re.get(x.id)??[],bowOffset:kn.get(x.id)??0,warning:x.joinNotConfigured||(C.get(x.sourceId)??!1)||(C.get(x.targetId)??!1),dimmed:Sn&&Tn,direction:O})})),I(!0);const Qe=[...T.entries()].filter(([,x])=>x.highlighted).map(([x])=>x),Ln=requestAnimationFrame(()=>{u.fitView(Qe.length>0?{nodes:Qe.map(x=>({id:x})),duration:300,padding:ie}:{padding:ie,duration:300})});return()=>{cancelAnimationFrame(Ln)}},[X,Q,O,M,j,D,A,u]);const gn=k.useCallback(E=>{B(L=>hr(E,L))},[]),pn=k.useCallback(E=>{W(L=>fr(E,L))},[]),[q,ye]=k.useState(null),mn=k.useCallback((E,L)=>{ye(C=>C===L.id?null:L.id),W(C=>C.some(T=>T.selected)?C.map(T=>T.selected?{...T,selected:!1}:T):C)},[]),bn=k.useCallback(()=>{ye(null)},[]),vn=k.useCallback(()=>{ye(null)},[]),wn=k.useMemo(()=>q?$.map(E=>E.id===q?{...E,selected:!0}:E):$,[$,q]),En=k.useMemo(()=>q?J.map(E=>E.source===q||E.target===q?{...E,selected:!0}:E):J,[J,q]),xn=k.useCallback((E,L)=>{const C=y.current??{};C[L.id]={x:L.position.x,y:L.position.y},y.current=C,_.current&&G.set(pe(_.current),C)},[]);k.useEffect(()=>{const E=new Map(e.map(C=>[C.id,C.qualitySummary])),L=new Map(e.map(C=>[C.id,C.dataLastUpdated]));B(C=>C.map(T=>{const U=E.get(T.id)??T.data.qualitySummary,Z=L.has(T.id)?L.get(T.id)??null:T.data.dataLastUpdated;return T.data.qualitySummary!==U||T.data.dataLastUpdated!==Z?{...T,data:{...T.data,qualitySummary:U,dataLastUpdated:Z}}:T}))},[e]),k.useEffect(()=>{B(E=>E.map(L=>L.data.isCheckingDataLastUpdated===s?L:{...L,data:{...L.data,isCheckingDataLastUpdated:s}}))},[s]),k.useEffect(()=>{const E=et(m.current,n,C=>C.id,C=>C.title);B(C=>C.map(T=>{const U=E.get(T.id)??tt;return T.data.highlighted===U.highlighted&&T.data.dimmed===U.dimmed?T:{...T,data:{...T.data,...U}}})),W(C=>C.map(T=>{var de,ue;const U=((de=E.get(T.source))==null?void 0:de.dimmed)??!1,Z=((ue=E.get(T.target))==null?void 0:ue.dimmed)??!1,re=U&&Z;return T.data.dimmed===re?T:{...T,data:{...T.data,dimmed:re}}}));const L=[...E.entries()].filter(([,C])=>C.highlighted).map(([C])=>C);L.length>0&&u.fitView({nodes:L.map(C=>({id:C})),duration:300,padding:ie})},[n,u]);const yn=k.useCallback(E=>{S(E),G.set(jt,E),y.current={},_.current&&G.remove(pe(_.current)),V(L=>L+1)},[]),_e=k.useCallback(E=>{P(L=>Me(L)===Me(E)?L:(G.set(It,Me(E)),E))},[]),_n=k.useCallback(E=>{R(E),G.set(Ot,E)},[]),Nn=k.useCallback(E=>{F(E),G.set(kt,E)},[]),jn=k.useCallback((E,L)=>{if(c===0||f===0)return;const C=gr(L,Ye,c,f,js);C.x===L.x&&C.y===L.y||u.setViewport(C)},[Ye,f,c,u]);return h.jsxs(h.Fragment,{children:[h.jsxs("div",{className:"absolute top-3 right-3 z-10 flex flex-col gap-1.5",children:[h.jsx(he,{variant:"outline",size:"icon",className:"h-12 w-12",onClick:()=>{u.fitView({padding:ie,duration:300})},"aria-label":"Fit to view",children:h.jsx(pr,{className:"h-6 w-6"})}),h.jsx(he,{variant:"outline",size:"icon",className:"h-12 w-12",onClick:()=>{u.zoomIn({duration:150})},"aria-label":"Zoom in",children:h.jsx(mr,{className:"h-6 w-6"})}),h.jsx(he,{variant:"outline",size:"icon",className:"h-12 w-12",onClick:()=>{u.zoomOut({duration:150})},"aria-label":"Zoom out",children:h.jsx(br,{className:"h-6 w-6"})}),h.jsxs(Lt,{children:[h.jsx(St,{asChild:!0,children:h.jsx(he,{variant:"outline",size:"icon",className:"h-12 w-12","aria-label":"Canvas settings",children:h.jsx(Qn,{className:"h-6 w-6"})})}),h.jsxs(Tt,{align:"end",side:"left",className:"w-56",children:[h.jsx(ge,{children:"View"}),h.jsx("div",{role:"radiogroup","aria-label":"Card view mode",className:"bg-muted mt-2 grid grid-cols-2 gap-0.5 rounded-md p-0.5",children:Es.map(E=>h.jsx("button",{type:"button",role:"radio","aria-checked":j===E.value,className:`rounded px-2 py-1 text-sm transition-colors ${j===E.value?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,onClick:()=>{_n(E.value)},children:E.label},E.value))}),h.jsx(ge,{className:"mt-3 border-t pt-3",children:"Layout algorithm"}),h.jsx("div",{role:"radiogroup","aria-label":"Layout algorithm",className:"mt-2 space-y-0.5",children:xr.map(E=>h.jsxs("button",{type:"button",role:"radio","aria-checked":O===E.value,className:"hover:bg-muted flex w-full items-center justify-between rounded px-2 py-1.5 text-left text-sm",onClick:()=>{yn(E.value)},children:[h.jsx("span",{children:E.label}),O===E.value&&h.jsx(Je,{className:"h-4 w-4"})]},E.value))}),h.jsxs("div",{className:"mt-3 flex items-center justify-between gap-2 border-t pt-3",children:[h.jsx("label",{htmlFor:"model-canvas-show-join-fields",className:"text-sm",children:"Show join fields"}),h.jsx(qn,{id:"model-canvas-show-join-fields",checked:D,onCheckedChange:Nn})]}),h.jsx(ge,{className:"mt-3 border-t pt-3",children:"Object labels"}),h.jsx("p",{className:"text-muted-foreground mt-1 text-xs leading-snug",children:"Tick what every object shows — untick to hide it."}),h.jsx("div",{className:"mt-2 space-y-0.5",children:le.map(E=>{const L=ws[E],C=!A[E];return h.jsxs("button",{type:"button",role:"checkbox","aria-checked":C,className:"hover:bg-muted flex w-full items-start gap-2 rounded px-2 py-1.5 text-left",onClick:()=>{_e(ls(A,E))},children:[h.jsx("span",{className:`mt-0.5 flex h-3.5 w-3.5 shrink-0 items-center justify-center rounded-sm border transition-colors ${C?"border-primary bg-primary text-primary-foreground":"border-input bg-background text-transparent"}`,"aria-hidden":"true",children:h.jsx(Je,{className:"h-2.5 w-2.5",strokeWidth:3.5})}),h.jsxs("span",{className:"flex min-w-0 flex-col",children:[h.jsx("span",{className:`text-sm font-medium ${C?"text-foreground":"text-muted-foreground"}`,children:L.label}),h.jsx("span",{className:"text-muted-foreground text-xs leading-snug",children:L.helper})]})]},E)})}),h.jsxs("div",{className:"mt-1 space-y-0.5 border-t pt-1",children:[h.jsxs("button",{type:"button","aria-pressed":_t(A),className:`flex w-full items-center gap-2 rounded px-2 py-1.5 text-left text-sm font-medium ${_t(A)?"bg-primary/10 text-primary":"text-foreground hover:bg-muted"}`,onClick:()=>{_e(we)},children:[h.jsx("span",{className:"w-4 shrink-0 text-center font-bold","aria-hidden":"true",children:"≡"}),"Check all — show everything"]}),h.jsxs("button",{type:"button","aria-pressed":Nt(A),className:`flex w-full items-center gap-2 rounded px-2 py-1.5 text-left text-sm font-medium ${Nt(A)?"bg-primary/10 text-primary":"text-foreground hover:bg-muted"}`,onClick:()=>{_e(os)},children:[h.jsx("span",{className:"w-4 shrink-0 text-center font-bold","aria-hidden":"true",children:"⊘"}),"Uncheck all — title only"]})]})]})]})]}),Y&&h.jsx(vr,{nodes:wn,edges:En,nodeTypes:Os,edgeTypes:Is,onNodesChange:gn,onEdgesChange:pn,onNodeDragStop:xn,onNodeClick:mn,onEdgeClick:vn,onPaneClick:bn,deleteKeyCode:null,nodesDraggable:!0,nodesConnectable:!1,elementsSelectable:!0,edgesFocusable:!1,minZoom:.05,maxZoom:2,onMove:jn,fitView:!0,fitViewOptions:{padding:ie},proOptions:{hideAttribution:!0},style:{width:"100%",height:"100%"},children:h.jsx(wr,{pannable:!0,zoomable:!0,style:{width:140,height:100},nodeColor:E=>At(E.data.definitionType)})})]})}function As({nodes:e,edges:t,searchQuery:n,onOpenDataMart:r,onOpenQuality:i,onRunQuality:o,isCheckingDataLastUpdated:s,storageId:a,storageTitle:l,exportApiRef:d,className:u,style:c}){return e.length===0?null:h.jsxs("div",{className:`relative overflow-hidden rounded-lg border ${u??""}`,style:c??{height:480},children:[h.jsx("style",{children:lr}),h.jsx(dr,{children:h.jsx(Rs,{nodes:e,edges:t,searchQuery:n,onOpenDataMart:r,onOpenQuality:i,onRunQuality:o,isCheckingDataLastUpdated:s,storageId:a,storageTitle:l,exportApiRef:d})})]})}export{As as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{u as _e,r as o,j as e,C as Oe,N as ke,T as Re,a as Me,I as Pe,b as Te,E as Le,B as He,s as Y,p as Fe,c as H,M as Ge,P as Ke,d as We,S as Be,e as ze,f as he,g as Ze,R as Ye,h as $e,i as Ve,k as Ue,l as Je,m as Xe,n as ge,o as qe}from"./index-DfxbkXTR.js";import{N as Qe,R as et,d as we,E as pe,H as X,S as q,P as Q,a as tt,u as st,b as fe,g as at,c as it,e as nt,f as ot,L as rt,Z as lt,h as ct,i as dt,M as ut,O as ht,W as ne,j as gt,D as je,k as ee,l as se,m as pt,n as ft,o as mt,p as xt,q as bt,B as yt,r as Nt,s as Ct,t as wt}from"./erd-card-BrXYWEzQ.js";const V=3,jt=1e-4,St=1;function vt(t){return{min:Number.isFinite(t)&&t>0?Math.min(t,V):St,max:V}}function Et(t,i,l){if(!Number.isFinite(t)||t<=0)return null;const x=t*(1+i),u=Math.min(Math.max(x,l.min),l.max);return!Number.isFinite(u)||Math.abs(u-t)<jt?null:{zoom:u,delta:u/t-1}}const ae=240,ie=48,$=92,me="relationship-canvas-show-looped",xe="relationship-canvas-status-filter",Dt=280,te=24,It=.85,be=1/It-1,ye=.05,At=150,_t=gt;function Ne({data:t}){const i=Ve(t);if(!i)return null;const l=i.kind==="attention";return e.jsxs("span",{title:l?Ue:void 0,style:{position:"absolute",top:-18,right:4,display:"inline-flex",alignItems:"center",gap:2,fontSize:10,fontWeight:600,color:l?ht:ne,lineHeight:1,whiteSpace:"nowrap"},children:[l&&e.jsx(Je,{style:{width:12,height:12,color:_t}}),i.label]})}function Ce(t,i){return{width:ae,borderColor:t.highlighted?ee:Xe(t)?ne:i?se:void 0,boxShadow:t.highlighted?`0 0 0 3px ${ee}40, 0 0 12px ${ee}60`:i?`0 0 0 1px ${se}`:void 0,opacity:t.dimmed?je:1,filter:t.dimmed?"grayscale(0.8)":void 0,animation:t.highlighted?"node-pulse 1.5s ease-in-out infinite":void 0,transition:"opacity 0.2s, filter 0.2s",cursor:"pointer"}}function Ot({data:t,selected:i}){const l=we(t.definitionType);function x(d){d.stopPropagation(),d.preventDefault(),t.onOpenExternal()}if(t.isSource)return e.jsxs("div",{className:"bg-primary/5 relative flex items-center gap-2 rounded-xl border shadow-sm",style:{...Ce(t,i),height:ie,padding:"0 14px"},children:[e.jsx(Ne,{data:t}),e.jsx("span",{className:"h-4 w-1 shrink-0 rounded-sm",style:{background:l},"aria-hidden":"true"}),e.jsx("span",{className:"text-foreground flex-1 truncate text-[13px] font-semibold",title:t.label,children:t.label}),e.jsx(pe,{isDraft:t.isDraft,decorative:!0}),t.hasOutgoing&&e.jsx(X,{type:"source",position:Q.Right,isConnectable:!1,style:q})]});const u=`Open ${t.label} in new tab`;return e.jsxs("div",{title:t.isCycleStub?Oe:void 0,className:"bg-background relative flex flex-col rounded-xl border shadow-sm",style:Ce(t,i),children:[e.jsx(Ne,{data:t}),e.jsx(X,{type:"target",position:Q.Left,isConnectable:!1,style:q}),e.jsxs("div",{className:"flex items-center gap-2 px-3.5 pt-3 pb-1",children:[e.jsx("span",{className:"h-4 w-1 shrink-0 rounded-sm",style:{background:l},"aria-hidden":"true"}),e.jsx("span",{className:"text-foreground flex-1 truncate text-[13px] font-semibold",title:t.label,children:t.label}),e.jsx(pe,{isDraft:t.isDraft,decorative:!0}),!t.userHasAccess&&e.jsx(ke,{}),t.description&&e.jsxs(Re,{children:[e.jsx(Me,{asChild:!0,children:e.jsx("button",{type:"button",className:"text-muted-foreground hover:text-foreground inline-flex cursor-default rounded p-0.5 transition-colors","aria-label":`Description for ${t.label}`,onPointerDown:d=>{d.stopPropagation()},children:e.jsx(Pe,{className:"h-3.5 w-3.5","aria-hidden":"true"})})}),e.jsx(Te,{side:"top",align:"center",role:"tooltip",className:"max-w-xs",children:t.description})]}),e.jsx("button",{type:"button",className:"text-muted-foreground hover:text-foreground shrink-0 cursor-pointer rounded p-0.5 transition-colors",onPointerDown:d=>{d.stopPropagation()},onClick:x,title:u,"aria-label":u,children:e.jsx(Le,{className:"h-3.5 w-3.5","aria-hidden":"true"})})]}),e.jsxs("div",{className:"flex min-w-0 items-center gap-2 px-3.5 pt-1 pb-3",children:[e.jsx(tt,{type:t.definitionType}),t.targetAlias&&e.jsx(He,{variant:"secondary",className:"inline-block max-w-[90px] truncate px-1.5 py-0 text-[10px]",title:t.targetAlias,children:t.targetAlias}),e.jsxs("span",{className:"text-muted-foreground ml-auto shrink-0 text-[11px]",children:[t.fieldCount??0," field",t.fieldCount!==1?"s":""]})]}),t.hasOutgoing&&e.jsx(X,{type:"source",position:Q.Right,isConnectable:!1,style:q})]})}function kt({id:t,sourceX:i,sourceY:l,targetX:x,targetY:u,sourcePosition:d,targetPosition:v,selected:N,data:h}){const[D]=ft({sourceX:i,sourceY:l,sourcePosition:d,targetX:x,targetY:u,targetPosition:v}),C=h.warning?ne:N?se:mt,I=o.useId(),E=xt("rel-arrow",I);return e.jsxs(e.Fragment,{children:[e.jsx(bt,{markerId:E,color:C,withStart:!1}),e.jsx(yt,{id:t,path:D,markerEnd:`url(#${E}-end)`,style:{stroke:C,strokeWidth:N?Ct:wt,strokeDasharray:h.warning?Nt:void 0,opacity:h.dimmed?je:1,transition:"opacity 0.2s, stroke 0.2s"}})]})}const Rt={relationshipNode:Ot},Mt={relationshipEdge:kt};function Pt(t){return JSON.stringify([t.nodes.map(i=>[i.id,i.position.x,i.position.y,i.width,i.height,i.data.isSource,i.data.label,i.data.targetAlias,i.data.fieldCount,i.data.description,i.data.isDraft,i.data.isBlocked,i.data.isJoinNotConfigured,i.data.isCycleStub,i.data.isMissingPrimaryKey,i.data.userHasAccess,i.data.hasOutgoing]),t.edges.map(i=>[i.id,i.source,i.target,i.data.warning])])}function Tt({dataMartId:t,dataMartTitle:i,dataMartDescription:l,dataMartStatus:x,rootDefinitionType:u,definitionTypes:d,initialRelationships:v,graph:N,fieldCounts:h,showLooped:D,statusFilter:C,onOpenExternal:I}){let E=0;const A=(s,n)=>n&&!D||C!=="all"&&s!==C?(E++,!1):!0,w=new Map,_=[],g=new Set,b=x==="DRAFT";w.set(t,{dmId:t,title:i,description:l,depth:0,isSource:!0,isDraft:b,userHasAccess:!0});const y=new Map;y.set("",t);function k(s,n,c,p){const R=`path:${p}`;_.push({sourceId:s,targetId:R}),g.add(s),w.set(R,{dmId:n,...c}),y.set(p,R)}if(N)for(const s of N.nodes){const n=s.aliasPath.lastIndexOf("."),c=n===-1?"":s.aliasPath.slice(0,n),p=y.get(c);p&&A(s.relationship.targetDataMart.status,s.isCycleStub)&&k(p,s.relationship.targetDataMart.id,{title:s.relationship.targetDataMart.title,description:s.relationship.targetDataMart.description,depth:s.depth,isSource:!1,targetAlias:s.relationship.targetAlias,fieldCount:(h==null?void 0:h.get(s.relationship.id))??0,isDraft:s.relationship.targetDataMart.status==="DRAFT",isBlocked:s.isBlocked,isJoinNotConfigured:s.relationship.joinConditions.length===0,isCycleStub:s.isCycleStub,isMissingPrimaryKey:ge(s.relationship.targetDataMart.hasPrimaryKey,s.relationship.joinConditions.length),userHasAccess:s.relationship.targetDataMart.userHasAccess},s.aliasPath)}else for(const s of v)A(s.targetDataMart.status,s.targetDataMart.id===t)&&k(t,s.targetDataMart.id,{title:s.targetDataMart.title,description:s.targetDataMart.description,depth:1,isSource:!1,targetAlias:s.targetAlias,fieldCount:(h==null?void 0:h.get(s.id))??0,isDraft:s.targetDataMart.status==="DRAFT",isBlocked:b,isJoinNotConfigured:s.joinConditions.length===0,isCycleStub:s.targetDataMart.id===t,isMissingPrimaryKey:ge(s.targetDataMart.hasPrimaryKey,s.joinConditions.length),userHasAccess:s.targetDataMart.userHasAccess},s.targetAlias);const j=new Map,S=new Map;for(const[s,n]of w){S.set(s,n.isSource?ie:$);const c=j.get(n.depth)??[];j.has(n.depth)||j.set(n.depth,c),c.push(s)}const L=new Map,U=Math.max(...Array.from(j.keys()));for(let s=0;s<=U;s++){const n=j.get(s)??[];let c=0;for(const p of n)L.set(p,{x:s*(ae+Dt),y:c}),c+=(S.get(p)??$)+te;if(s===0&&n.length===1){const p=n[0],K=(j.get(1)??[]).reduce((W,M)=>W+(S.get(M)??$)+te,-te),f=S.get(p)??ie;L.set(p,{x:0,y:Math.max(0,K/2-f/2)})}}const F=[];for(const[s,n]of w)F.push({id:s,type:"relationshipNode",position:L.get(s)??{x:0,y:0},width:ae,height:S.get(s)??$,draggable:!1,selectable:!1,focusable:!1,style:pt,data:{isSource:n.isSource,label:n.title,targetAlias:n.targetAlias,fieldCount:n.fieldCount,description:n.description,definitionType:n.isSource?u:(d==null?void 0:d.get(n.dmId))??null,isDraft:n.isDraft??!1,isBlocked:n.isBlocked??!1,isJoinNotConfigured:n.isJoinNotConfigured??!1,isCycleStub:n.isCycleStub??!1,isMissingPrimaryKey:n.isMissingPrimaryKey??!1,userHasAccess:n.userHasAccess,hasOutgoing:g.has(s)&&!n.isCycleStub,highlighted:!1,dimmed:!1,onOpenExternal:()=>{I(n.dmId)}}});const G=[];for(const s of _){const n=w.get(s.sourceId),c=w.get(s.targetId);if(!n||!c)continue;const p=qe(n,c);G.push({id:`${s.sourceId}->${s.targetId}`,type:"relationshipEdge",source:s.sourceId,target:s.targetId,focusable:!1,selectable:!1,data:{warning:p,dimmed:!1}})}return{nodes:F,edges:G,filteredOutCount:E}}function Lt({dataMartId:t,dataMartTitle:i,dataMartDescription:l,dataMartStatus:x,dataMartDefinitionType:u,definitionTypes:d,relationships:v,relationshipGraph:N,connectedFieldCounts:h,searchQuery:D,onRequestFullscreen:C,onOpenExternal:I,showLooped:E,onShowLoopedChange:A,statusFilter:w,onStatusFilterChange:_}){const g=st(),b=fe(a=>a.width),y=fe(a=>a.height),k=o.useRef(!1),j=o.useRef(!1),[S,L]=o.useState({min:ye,max:V}),[U,F]=o.useState(()=>Y.get(me,"boolean")??!1),[G,s]=o.useState(()=>Fe(Y.get(xe))),n=E??U,c=w??G,p=o.useCallback(a=>{if(A){A(a);return}F(a),Y.set(me,a)},[A]),R=o.useCallback(a=>{if(_){_(a);return}s(a),Y.set(xe,a)},[_]),K=n||c!=="all",f=o.useMemo(()=>Tt({dataMartId:t,dataMartTitle:i,dataMartDescription:l,dataMartStatus:x,rootDefinitionType:u??null,definitionTypes:d,initialRelationships:v,graph:N,fieldCounts:h,showLooped:n,statusFilter:c,onOpenExternal:I}),[t,i,l,x,u,d,v,N,h,n,c,I]),[W,M]=o.useState(null),[P,B]=o.useState(null),z=o.useMemo(()=>Pt(f),[f]),oe=o.useMemo(()=>at(f.nodes),[f.nodes]),re=o.useRef(z);o.useEffect(()=>{re.current!==z&&(re.current=z,j.current=!1,B(null),M(null))},[z]);const O=o.useMemo(()=>it(f.nodes,D,a=>a.id,a=>a.data.label),[f.nodes,D]),Se=o.useMemo(()=>f.nodes.map(a=>{const r=O.get(a.id)??nt,m=a.id===P;return a.data.highlighted===r.highlighted&&a.data.dimmed===r.dimmed&&(a.selected??!1)===m?a:{...a,selected:m,data:{...a.data,...r}}}),[f.nodes,O,P]),ve=o.useMemo(()=>f.edges.map(a=>{var de,ue;const r=(((de=O.get(a.source))==null?void 0:de.dimmed)??!1)&&(((ue=O.get(a.target))==null?void 0:ue.dimmed)??!1),m=a.id===W||P!==null&&(a.source===P||a.target===P);return a.data.dimmed===r&&(a.selected??!1)===m?a:{...a,selected:m,data:{...a.data,dimmed:r}}}),[f.edges,O,W,P]),Ee=o.useCallback((a,r)=>{M(m=>m===r.id?null:r.id),B(null)},[]),De=o.useCallback((a,r)=>{B(m=>m===r.id?null:r.id),M(null)},[]),Ie=o.useCallback(()=>{M(null),B(null)},[]),le=o.useRef(O);le.current=O;const Z=o.useCallback(()=>{const a=[...le.current.entries()].filter(([,r])=>r.highlighted).map(([r])=>r);a.length!==0&&g.fitView({nodes:a.map(r=>({id:r})),duration:300,padding:be})},[g]),J=o.useCallback(()=>g.fitView({minZoom:ye,maxZoom:V,padding:be}).then(()=>{L(vt(g.getZoom()))}),[g]),T=o.useCallback(()=>{j.current=!0},[]);o.useEffect(()=>{b===0||y===0||j.current||J().then(()=>{k.current=!0,Z()})},[b,y,f,J,Z]),o.useEffect(()=>{k.current&&Z()},[O,Z]);const ce=o.useCallback(a=>{T();const r=Et(g.getZoom(),a,S);r&&g.zoomTo(r.zoom,{duration:150})},[T,g,S]),Ae=o.useCallback((a,r)=>{if(b===0||y===0)return;const m=ot(r,oe,b,y,At);m.x===r.x&&m.y===r.y||g.setViewport(m)},[oe,y,b,g]);return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"absolute top-3 right-3 z-10 flex items-start gap-2",children:e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(H,{variant:"outline",size:"icon",className:"h-12 w-12",onClick:()=>{T(),J()},"aria-label":"Fit to view",children:e.jsx(rt,{className:"h-6 w-6"})}),e.jsx(H,{variant:"outline",size:"icon",className:"h-12 w-12",onClick:()=>{ce(.25)},"aria-label":"Zoom in",children:e.jsx(lt,{className:"h-6 w-6"})}),e.jsx(H,{variant:"outline",size:"icon",className:"h-12 w-12",onClick:()=>{ce(-.25)},"aria-label":"Zoom out",children:e.jsx(ct,{className:"h-6 w-6"})}),C&&e.jsx(H,{variant:"outline",size:"icon",className:"h-12 w-12",onClick:C,"aria-label":"Expand diagram",children:e.jsx(Ge,{className:"h-6 w-6"})}),e.jsxs(Ke,{children:[e.jsx(We,{asChild:!0,children:e.jsxs(H,{variant:"outline",size:"icon",className:"relative h-12 w-12","aria-label":K?"Diagram filters (active)":"Diagram filters",children:[e.jsx(Be,{className:"h-6 w-6"}),K&&e.jsx("span",{className:"bg-primary absolute top-1.5 right-1.5 h-2 w-2 rounded-full","aria-hidden":"true"})]})}),e.jsxs(ze,{align:"end",side:"left",className:"w-56",children:[e.jsx(he,{children:"Filters"}),e.jsxs("div",{className:"mt-2 flex items-center justify-between gap-2",children:[e.jsx("label",{htmlFor:"relationship-canvas-show-looped",className:"text-sm",children:"Show looped Data Marts"}),e.jsx(Ze,{id:"relationship-canvas-show-looped",checked:n,onCheckedChange:p})]}),e.jsx(he,{className:"mt-3 border-t pt-3",children:"Status"}),e.jsx("div",{role:"radiogroup","aria-label":"Status filter",className:"mt-2 space-y-0.5",children:Ye.map(a=>e.jsxs("button",{type:"button",role:"radio","aria-checked":c===a.value,className:"hover:bg-muted flex w-full items-center justify-between rounded px-2 py-1.5 text-left text-sm",onClick:()=>{R(a.value)},children:[e.jsx("span",{children:a.label}),c===a.value&&e.jsx($e,{className:"h-4 w-4"})]},a.value))})]})]})]})}),e.jsxs("div",{className:"h-full w-full",onPointerDownCapture:T,onWheelCapture:T,children:[e.jsx(dt,{nodes:Se,edges:ve,nodeTypes:Rt,edgeTypes:Mt,nodesDraggable:!1,nodesConnectable:!1,elementsSelectable:!1,edgesFocusable:!1,zoomOnDoubleClick:!1,minZoom:S.min,maxZoom:S.max,onEdgeClick:Ee,onNodeClick:De,onPaneClick:Ie,deleteKeyCode:null,onMove:Ae,onMoveStart:a=>{a&&T()},proOptions:{hideAttribution:!0},style:{width:"100%",height:"100%"},children:e.jsx(ut,{pannable:!0,zoomable:!0,style:{width:140,height:100},nodeColor:a=>we(a.data.definitionType)})}),f.nodes.length===1&&f.filteredOutCount>0&&e.jsx("div",{className:"pointer-events-none absolute inset-x-0 bottom-6 flex justify-center",children:e.jsx("span",{className:"bg-background text-muted-foreground rounded-md border px-3 py-1.5 text-sm shadow-sm",children:"No related data marts match the current filters"})})]})]})}function Gt({dataMartId:t,dataMartTitle:i,dataMartDescription:l,dataMartStatus:x,dataMartDefinitionType:u,definitionTypes:d,relationships:v,relationshipGraph:N,connectedFieldCounts:h,searchQuery:D,onRequestFullscreen:C,showLooped:I,onShowLoopedChange:E,statusFilter:A,onStatusFilterChange:w,className:_,style:g}){const{scope:b}=_e(),y=o.useCallback(k=>{window.open(b(`/data-marts/${k}/data-setup`),"_blank","noopener,noreferrer")},[b]);return v.length===0?null:e.jsxs("div",{className:`relative overflow-hidden rounded-lg border ${_??""}`,style:g??{height:480},children:[e.jsx("style",{children:Qe}),e.jsx(et,{children:e.jsx(Lt,{dataMartId:t,dataMartTitle:i,dataMartDescription:l,dataMartStatus:x,dataMartDefinitionType:u,definitionTypes:d,relationships:v,relationshipGraph:N,connectedFieldCounts:h,searchQuery:D,onRequestFullscreen:C,onOpenExternal:y,showLooped:I,onShowLoopedChange:E,statusFilter:A,onStatusFilterChange:w})})]})}export{Gt as RelationshipCanvas,Ot as RelationshipFlowNode};
|
|
1
|
+
import{u as _e,r as o,j as e,C as Oe,N as ke,T as Re,a as Me,I as Pe,b as Te,E as Le,B as He,s as Y,p as Fe,c as H,M as Ge,P as Ke,d as We,S as Be,e as ze,f as he,g as Ze,R as Ye,h as $e,i as Ve,k as Ue,l as Je,m as Xe,n as ge,o as qe}from"./index-CAz55S73.js";import{N as Qe,R as et,d as we,E as pe,H as X,S as q,P as Q,a as tt,u as st,b as fe,g as at,c as it,e as nt,f as ot,L as rt,Z as lt,h as ct,i as dt,M as ut,O as ht,W as ne,j as gt,D as je,k as ee,l as se,m as pt,n as ft,o as mt,p as xt,q as bt,B as yt,r as Nt,s as Ct,t as wt}from"./erd-card-CzRH59fS.js";const V=3,jt=1e-4,St=1;function vt(t){return{min:Number.isFinite(t)&&t>0?Math.min(t,V):St,max:V}}function Et(t,i,l){if(!Number.isFinite(t)||t<=0)return null;const x=t*(1+i),u=Math.min(Math.max(x,l.min),l.max);return!Number.isFinite(u)||Math.abs(u-t)<jt?null:{zoom:u,delta:u/t-1}}const ae=240,ie=48,$=92,me="relationship-canvas-show-looped",xe="relationship-canvas-status-filter",Dt=280,te=24,It=.85,be=1/It-1,ye=.05,At=150,_t=gt;function Ne({data:t}){const i=Ve(t);if(!i)return null;const l=i.kind==="attention";return e.jsxs("span",{title:l?Ue:void 0,style:{position:"absolute",top:-18,right:4,display:"inline-flex",alignItems:"center",gap:2,fontSize:10,fontWeight:600,color:l?ht:ne,lineHeight:1,whiteSpace:"nowrap"},children:[l&&e.jsx(Je,{style:{width:12,height:12,color:_t}}),i.label]})}function Ce(t,i){return{width:ae,borderColor:t.highlighted?ee:Xe(t)?ne:i?se:void 0,boxShadow:t.highlighted?`0 0 0 3px ${ee}40, 0 0 12px ${ee}60`:i?`0 0 0 1px ${se}`:void 0,opacity:t.dimmed?je:1,filter:t.dimmed?"grayscale(0.8)":void 0,animation:t.highlighted?"node-pulse 1.5s ease-in-out infinite":void 0,transition:"opacity 0.2s, filter 0.2s",cursor:"pointer"}}function Ot({data:t,selected:i}){const l=we(t.definitionType);function x(d){d.stopPropagation(),d.preventDefault(),t.onOpenExternal()}if(t.isSource)return e.jsxs("div",{className:"bg-primary/5 relative flex items-center gap-2 rounded-xl border shadow-sm",style:{...Ce(t,i),height:ie,padding:"0 14px"},children:[e.jsx(Ne,{data:t}),e.jsx("span",{className:"h-4 w-1 shrink-0 rounded-sm",style:{background:l},"aria-hidden":"true"}),e.jsx("span",{className:"text-foreground flex-1 truncate text-[13px] font-semibold",title:t.label,children:t.label}),e.jsx(pe,{isDraft:t.isDraft,decorative:!0}),t.hasOutgoing&&e.jsx(X,{type:"source",position:Q.Right,isConnectable:!1,style:q})]});const u=`Open ${t.label} in new tab`;return e.jsxs("div",{title:t.isCycleStub?Oe:void 0,className:"bg-background relative flex flex-col rounded-xl border shadow-sm",style:Ce(t,i),children:[e.jsx(Ne,{data:t}),e.jsx(X,{type:"target",position:Q.Left,isConnectable:!1,style:q}),e.jsxs("div",{className:"flex items-center gap-2 px-3.5 pt-3 pb-1",children:[e.jsx("span",{className:"h-4 w-1 shrink-0 rounded-sm",style:{background:l},"aria-hidden":"true"}),e.jsx("span",{className:"text-foreground flex-1 truncate text-[13px] font-semibold",title:t.label,children:t.label}),e.jsx(pe,{isDraft:t.isDraft,decorative:!0}),!t.userHasAccess&&e.jsx(ke,{}),t.description&&e.jsxs(Re,{children:[e.jsx(Me,{asChild:!0,children:e.jsx("button",{type:"button",className:"text-muted-foreground hover:text-foreground inline-flex cursor-default rounded p-0.5 transition-colors","aria-label":`Description for ${t.label}`,onPointerDown:d=>{d.stopPropagation()},children:e.jsx(Pe,{className:"h-3.5 w-3.5","aria-hidden":"true"})})}),e.jsx(Te,{side:"top",align:"center",role:"tooltip",className:"max-w-xs",children:t.description})]}),e.jsx("button",{type:"button",className:"text-muted-foreground hover:text-foreground shrink-0 cursor-pointer rounded p-0.5 transition-colors",onPointerDown:d=>{d.stopPropagation()},onClick:x,title:u,"aria-label":u,children:e.jsx(Le,{className:"h-3.5 w-3.5","aria-hidden":"true"})})]}),e.jsxs("div",{className:"flex min-w-0 items-center gap-2 px-3.5 pt-1 pb-3",children:[e.jsx(tt,{type:t.definitionType}),t.targetAlias&&e.jsx(He,{variant:"secondary",className:"inline-block max-w-[90px] truncate px-1.5 py-0 text-[10px]",title:t.targetAlias,children:t.targetAlias}),e.jsxs("span",{className:"text-muted-foreground ml-auto shrink-0 text-[11px]",children:[t.fieldCount??0," field",t.fieldCount!==1?"s":""]})]}),t.hasOutgoing&&e.jsx(X,{type:"source",position:Q.Right,isConnectable:!1,style:q})]})}function kt({id:t,sourceX:i,sourceY:l,targetX:x,targetY:u,sourcePosition:d,targetPosition:v,selected:N,data:h}){const[D]=ft({sourceX:i,sourceY:l,sourcePosition:d,targetX:x,targetY:u,targetPosition:v}),C=h.warning?ne:N?se:mt,I=o.useId(),E=xt("rel-arrow",I);return e.jsxs(e.Fragment,{children:[e.jsx(bt,{markerId:E,color:C,withStart:!1}),e.jsx(yt,{id:t,path:D,markerEnd:`url(#${E}-end)`,style:{stroke:C,strokeWidth:N?Ct:wt,strokeDasharray:h.warning?Nt:void 0,opacity:h.dimmed?je:1,transition:"opacity 0.2s, stroke 0.2s"}})]})}const Rt={relationshipNode:Ot},Mt={relationshipEdge:kt};function Pt(t){return JSON.stringify([t.nodes.map(i=>[i.id,i.position.x,i.position.y,i.width,i.height,i.data.isSource,i.data.label,i.data.targetAlias,i.data.fieldCount,i.data.description,i.data.isDraft,i.data.isBlocked,i.data.isJoinNotConfigured,i.data.isCycleStub,i.data.isMissingPrimaryKey,i.data.userHasAccess,i.data.hasOutgoing]),t.edges.map(i=>[i.id,i.source,i.target,i.data.warning])])}function Tt({dataMartId:t,dataMartTitle:i,dataMartDescription:l,dataMartStatus:x,rootDefinitionType:u,definitionTypes:d,initialRelationships:v,graph:N,fieldCounts:h,showLooped:D,statusFilter:C,onOpenExternal:I}){let E=0;const A=(s,n)=>n&&!D||C!=="all"&&s!==C?(E++,!1):!0,w=new Map,_=[],g=new Set,b=x==="DRAFT";w.set(t,{dmId:t,title:i,description:l,depth:0,isSource:!0,isDraft:b,userHasAccess:!0});const y=new Map;y.set("",t);function k(s,n,c,p){const R=`path:${p}`;_.push({sourceId:s,targetId:R}),g.add(s),w.set(R,{dmId:n,...c}),y.set(p,R)}if(N)for(const s of N.nodes){const n=s.aliasPath.lastIndexOf("."),c=n===-1?"":s.aliasPath.slice(0,n),p=y.get(c);p&&A(s.relationship.targetDataMart.status,s.isCycleStub)&&k(p,s.relationship.targetDataMart.id,{title:s.relationship.targetDataMart.title,description:s.relationship.targetDataMart.description,depth:s.depth,isSource:!1,targetAlias:s.relationship.targetAlias,fieldCount:(h==null?void 0:h.get(s.relationship.id))??0,isDraft:s.relationship.targetDataMart.status==="DRAFT",isBlocked:s.isBlocked,isJoinNotConfigured:s.relationship.joinConditions.length===0,isCycleStub:s.isCycleStub,isMissingPrimaryKey:ge(s.relationship.targetDataMart.hasPrimaryKey,s.relationship.joinConditions.length),userHasAccess:s.relationship.targetDataMart.userHasAccess},s.aliasPath)}else for(const s of v)A(s.targetDataMart.status,s.targetDataMart.id===t)&&k(t,s.targetDataMart.id,{title:s.targetDataMart.title,description:s.targetDataMart.description,depth:1,isSource:!1,targetAlias:s.targetAlias,fieldCount:(h==null?void 0:h.get(s.id))??0,isDraft:s.targetDataMart.status==="DRAFT",isBlocked:b,isJoinNotConfigured:s.joinConditions.length===0,isCycleStub:s.targetDataMart.id===t,isMissingPrimaryKey:ge(s.targetDataMart.hasPrimaryKey,s.joinConditions.length),userHasAccess:s.targetDataMart.userHasAccess},s.targetAlias);const j=new Map,S=new Map;for(const[s,n]of w){S.set(s,n.isSource?ie:$);const c=j.get(n.depth)??[];j.has(n.depth)||j.set(n.depth,c),c.push(s)}const L=new Map,U=Math.max(...Array.from(j.keys()));for(let s=0;s<=U;s++){const n=j.get(s)??[];let c=0;for(const p of n)L.set(p,{x:s*(ae+Dt),y:c}),c+=(S.get(p)??$)+te;if(s===0&&n.length===1){const p=n[0],K=(j.get(1)??[]).reduce((W,M)=>W+(S.get(M)??$)+te,-te),f=S.get(p)??ie;L.set(p,{x:0,y:Math.max(0,K/2-f/2)})}}const F=[];for(const[s,n]of w)F.push({id:s,type:"relationshipNode",position:L.get(s)??{x:0,y:0},width:ae,height:S.get(s)??$,draggable:!1,selectable:!1,focusable:!1,style:pt,data:{isSource:n.isSource,label:n.title,targetAlias:n.targetAlias,fieldCount:n.fieldCount,description:n.description,definitionType:n.isSource?u:(d==null?void 0:d.get(n.dmId))??null,isDraft:n.isDraft??!1,isBlocked:n.isBlocked??!1,isJoinNotConfigured:n.isJoinNotConfigured??!1,isCycleStub:n.isCycleStub??!1,isMissingPrimaryKey:n.isMissingPrimaryKey??!1,userHasAccess:n.userHasAccess,hasOutgoing:g.has(s)&&!n.isCycleStub,highlighted:!1,dimmed:!1,onOpenExternal:()=>{I(n.dmId)}}});const G=[];for(const s of _){const n=w.get(s.sourceId),c=w.get(s.targetId);if(!n||!c)continue;const p=qe(n,c);G.push({id:`${s.sourceId}->${s.targetId}`,type:"relationshipEdge",source:s.sourceId,target:s.targetId,focusable:!1,selectable:!1,data:{warning:p,dimmed:!1}})}return{nodes:F,edges:G,filteredOutCount:E}}function Lt({dataMartId:t,dataMartTitle:i,dataMartDescription:l,dataMartStatus:x,dataMartDefinitionType:u,definitionTypes:d,relationships:v,relationshipGraph:N,connectedFieldCounts:h,searchQuery:D,onRequestFullscreen:C,onOpenExternal:I,showLooped:E,onShowLoopedChange:A,statusFilter:w,onStatusFilterChange:_}){const g=st(),b=fe(a=>a.width),y=fe(a=>a.height),k=o.useRef(!1),j=o.useRef(!1),[S,L]=o.useState({min:ye,max:V}),[U,F]=o.useState(()=>Y.get(me,"boolean")??!1),[G,s]=o.useState(()=>Fe(Y.get(xe))),n=E??U,c=w??G,p=o.useCallback(a=>{if(A){A(a);return}F(a),Y.set(me,a)},[A]),R=o.useCallback(a=>{if(_){_(a);return}s(a),Y.set(xe,a)},[_]),K=n||c!=="all",f=o.useMemo(()=>Tt({dataMartId:t,dataMartTitle:i,dataMartDescription:l,dataMartStatus:x,rootDefinitionType:u??null,definitionTypes:d,initialRelationships:v,graph:N,fieldCounts:h,showLooped:n,statusFilter:c,onOpenExternal:I}),[t,i,l,x,u,d,v,N,h,n,c,I]),[W,M]=o.useState(null),[P,B]=o.useState(null),z=o.useMemo(()=>Pt(f),[f]),oe=o.useMemo(()=>at(f.nodes),[f.nodes]),re=o.useRef(z);o.useEffect(()=>{re.current!==z&&(re.current=z,j.current=!1,B(null),M(null))},[z]);const O=o.useMemo(()=>it(f.nodes,D,a=>a.id,a=>a.data.label),[f.nodes,D]),Se=o.useMemo(()=>f.nodes.map(a=>{const r=O.get(a.id)??nt,m=a.id===P;return a.data.highlighted===r.highlighted&&a.data.dimmed===r.dimmed&&(a.selected??!1)===m?a:{...a,selected:m,data:{...a.data,...r}}}),[f.nodes,O,P]),ve=o.useMemo(()=>f.edges.map(a=>{var de,ue;const r=(((de=O.get(a.source))==null?void 0:de.dimmed)??!1)&&(((ue=O.get(a.target))==null?void 0:ue.dimmed)??!1),m=a.id===W||P!==null&&(a.source===P||a.target===P);return a.data.dimmed===r&&(a.selected??!1)===m?a:{...a,selected:m,data:{...a.data,dimmed:r}}}),[f.edges,O,W,P]),Ee=o.useCallback((a,r)=>{M(m=>m===r.id?null:r.id),B(null)},[]),De=o.useCallback((a,r)=>{B(m=>m===r.id?null:r.id),M(null)},[]),Ie=o.useCallback(()=>{M(null),B(null)},[]),le=o.useRef(O);le.current=O;const Z=o.useCallback(()=>{const a=[...le.current.entries()].filter(([,r])=>r.highlighted).map(([r])=>r);a.length!==0&&g.fitView({nodes:a.map(r=>({id:r})),duration:300,padding:be})},[g]),J=o.useCallback(()=>g.fitView({minZoom:ye,maxZoom:V,padding:be}).then(()=>{L(vt(g.getZoom()))}),[g]),T=o.useCallback(()=>{j.current=!0},[]);o.useEffect(()=>{b===0||y===0||j.current||J().then(()=>{k.current=!0,Z()})},[b,y,f,J,Z]),o.useEffect(()=>{k.current&&Z()},[O,Z]);const ce=o.useCallback(a=>{T();const r=Et(g.getZoom(),a,S);r&&g.zoomTo(r.zoom,{duration:150})},[T,g,S]),Ae=o.useCallback((a,r)=>{if(b===0||y===0)return;const m=ot(r,oe,b,y,At);m.x===r.x&&m.y===r.y||g.setViewport(m)},[oe,y,b,g]);return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"absolute top-3 right-3 z-10 flex items-start gap-2",children:e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(H,{variant:"outline",size:"icon",className:"h-12 w-12",onClick:()=>{T(),J()},"aria-label":"Fit to view",children:e.jsx(rt,{className:"h-6 w-6"})}),e.jsx(H,{variant:"outline",size:"icon",className:"h-12 w-12",onClick:()=>{ce(.25)},"aria-label":"Zoom in",children:e.jsx(lt,{className:"h-6 w-6"})}),e.jsx(H,{variant:"outline",size:"icon",className:"h-12 w-12",onClick:()=>{ce(-.25)},"aria-label":"Zoom out",children:e.jsx(ct,{className:"h-6 w-6"})}),C&&e.jsx(H,{variant:"outline",size:"icon",className:"h-12 w-12",onClick:C,"aria-label":"Expand diagram",children:e.jsx(Ge,{className:"h-6 w-6"})}),e.jsxs(Ke,{children:[e.jsx(We,{asChild:!0,children:e.jsxs(H,{variant:"outline",size:"icon",className:"relative h-12 w-12","aria-label":K?"Diagram filters (active)":"Diagram filters",children:[e.jsx(Be,{className:"h-6 w-6"}),K&&e.jsx("span",{className:"bg-primary absolute top-1.5 right-1.5 h-2 w-2 rounded-full","aria-hidden":"true"})]})}),e.jsxs(ze,{align:"end",side:"left",className:"w-56",children:[e.jsx(he,{children:"Filters"}),e.jsxs("div",{className:"mt-2 flex items-center justify-between gap-2",children:[e.jsx("label",{htmlFor:"relationship-canvas-show-looped",className:"text-sm",children:"Show looped Data Marts"}),e.jsx(Ze,{id:"relationship-canvas-show-looped",checked:n,onCheckedChange:p})]}),e.jsx(he,{className:"mt-3 border-t pt-3",children:"Status"}),e.jsx("div",{role:"radiogroup","aria-label":"Status filter",className:"mt-2 space-y-0.5",children:Ye.map(a=>e.jsxs("button",{type:"button",role:"radio","aria-checked":c===a.value,className:"hover:bg-muted flex w-full items-center justify-between rounded px-2 py-1.5 text-left text-sm",onClick:()=>{R(a.value)},children:[e.jsx("span",{children:a.label}),c===a.value&&e.jsx($e,{className:"h-4 w-4"})]},a.value))})]})]})]})}),e.jsxs("div",{className:"h-full w-full",onPointerDownCapture:T,onWheelCapture:T,children:[e.jsx(dt,{nodes:Se,edges:ve,nodeTypes:Rt,edgeTypes:Mt,nodesDraggable:!1,nodesConnectable:!1,elementsSelectable:!1,edgesFocusable:!1,zoomOnDoubleClick:!1,minZoom:S.min,maxZoom:S.max,onEdgeClick:Ee,onNodeClick:De,onPaneClick:Ie,deleteKeyCode:null,onMove:Ae,onMoveStart:a=>{a&&T()},proOptions:{hideAttribution:!0},style:{width:"100%",height:"100%"},children:e.jsx(ut,{pannable:!0,zoomable:!0,style:{width:140,height:100},nodeColor:a=>we(a.data.definitionType)})}),f.nodes.length===1&&f.filteredOutCount>0&&e.jsx("div",{className:"pointer-events-none absolute inset-x-0 bottom-6 flex justify-center",children:e.jsx("span",{className:"bg-background text-muted-foreground rounded-md border px-3 py-1.5 text-sm shadow-sm",children:"No related data marts match the current filters"})})]})]})}function Gt({dataMartId:t,dataMartTitle:i,dataMartDescription:l,dataMartStatus:x,dataMartDefinitionType:u,definitionTypes:d,relationships:v,relationshipGraph:N,connectedFieldCounts:h,searchQuery:D,onRequestFullscreen:C,showLooped:I,onShowLoopedChange:E,statusFilter:A,onStatusFilterChange:w,className:_,style:g}){const{scope:b}=_e(),y=o.useCallback(k=>{window.open(b(`/data-marts/${k}/data-setup`),"_blank","noopener,noreferrer")},[b]);return v.length===0?null:e.jsxs("div",{className:`relative overflow-hidden rounded-lg border ${_??""}`,style:g??{height:480},children:[e.jsx("style",{children:Qe}),e.jsx(et,{children:e.jsx(Lt,{dataMartId:t,dataMartTitle:i,dataMartDescription:l,dataMartStatus:x,dataMartDefinitionType:u,definitionTypes:d,relationships:v,relationshipGraph:N,connectedFieldCounts:h,searchQuery:D,onRequestFullscreen:C,onOpenExternal:y,showLooped:I,onShowLoopedChange:E,statusFilter:A,onStatusFilterChange:w})})]})}export{Gt as RelationshipCanvas,Ot as RelationshipFlowNode};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{O as Fn,Q as ga,U as pa,r as D,j as I,V as ie,W as ma}from"./index-
|
|
1
|
+
import{O as Fn,Q as ga,U as pa,r as D,j as I,V as ie,W as ma}from"./index-CAz55S73.js";/**
|
|
2
2
|
* @license lucide-react v0.475.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|