41 lines
24 KiB
JavaScript
41 lines
24 KiB
JavaScript
import{G as _t,P as bt,S as vt,T as St,U as Lt,V as wt,W as Et,X as At,Y as Tt,_ as X,aa as Ct}from"./chunk-67TQ5CYL.mjs";import{E as Mt,h as G,m as Nt}from"./chunk-7W6UQGC5.mjs";import{a as e}from"./chunk-AQ6EADP3.mjs";var lt=(function(){var t=e(function(g,a,l,h){for(l=l||{},h=g.length;h--;l[g[h]]=a);return l},"o"),o=[1,9],s=[1,10],u=[1,5,10,12],c={trace:e(function(){},"trace"),yy:{},symbols_:{error:2,start:3,SANKEY:4,NEWLINE:5,csv:6,opt_eof:7,record:8,csv_tail:9,EOF:10,"field[source]":11,COMMA:12,"field[target]":13,"field[value]":14,field:15,escaped:16,non_escaped:17,DQUOTE:18,ESCAPED_TEXT:19,NON_ESCAPED_TEXT:20,$accept:0,$end:1},terminals_:{2:"error",4:"SANKEY",5:"NEWLINE",10:"EOF",11:"field[source]",12:"COMMA",13:"field[target]",14:"field[value]",18:"DQUOTE",19:"ESCAPED_TEXT",20:"NON_ESCAPED_TEXT"},productions_:[0,[3,4],[6,2],[9,2],[9,0],[7,1],[7,0],[8,5],[15,1],[15,1],[16,3],[17,1]],performAction:e(function(a,l,h,x,k,p,b){var A=p.length-1;switch(k){case 7:let E=x.findOrCreateNode(p[A-4].trim().replaceAll('""','"')),C=x.findOrCreateNode(p[A-2].trim().replaceAll('""','"')),N=parseFloat(p[A].trim());x.addLink(E,C,N);break;case 8:case 9:case 11:this.$=p[A];break;case 10:this.$=p[A-1];break}},"anonymous"),table:[{3:1,4:[1,2]},{1:[3]},{5:[1,3]},{6:4,8:5,15:6,16:7,17:8,18:o,20:s},{1:[2,6],7:11,10:[1,12]},t(s,[2,4],{9:13,5:[1,14]}),{12:[1,15]},t(u,[2,8]),t(u,[2,9]),{19:[1,16]},t(u,[2,11]),{1:[2,1]},{1:[2,5]},t(s,[2,2]),{6:17,8:5,15:6,16:7,17:8,18:o,20:s},{15:18,16:7,17:8,18:o,20:s},{18:[1,19]},t(s,[2,3]),{12:[1,20]},t(u,[2,10]),{15:21,16:7,17:8,18:o,20:s},t([1,5,10],[2,7])],defaultActions:{11:[2,1],12:[2,5]},parseError:e(function(a,l){if(l.recoverable)this.trace(a);else{var h=new Error(a);throw h.hash=l,h}},"parseError"),parse:e(function(a){var l=this,h=[0],x=[],k=[null],p=[],b=this.table,A="",E=0,C=0,N=0,M=2,P=1,D=p.slice.call(arguments,1),S=Object.create(this.lexer),O={yy:{}};for(var z in this.yy)Object.prototype.hasOwnProperty.call(this.yy,z)&&(O.yy[z]=this.yy[z]);S.setInput(a,O.yy),O.yy.lexer=S,O.yy.parser=this,typeof S.yylloc>"u"&&(S.yylloc={});var $=S.yylloc;p.push($);var I=S.options&&S.options.ranges;typeof O.yy.parseError=="function"?this.parseError=O.yy.parseError:this.parseError=Object.getPrototypeOf(this).parseError;function q(w){h.length=h.length-2*w,k.length=k.length-w,p.length=p.length-w}e(q,"popStack");function W(){var w;return w=x.pop()||S.lex()||P,typeof w!="number"&&(w instanceof Array&&(x=w,w=x.pop()),w=l.symbols_[w]||w),w}e(W,"lex");for(var L,R,n,f,d,r,i={},m,v,B,T;;){if(n=h[h.length-1],this.defaultActions[n]?f=this.defaultActions[n]:((L===null||typeof L>"u")&&(L=W()),f=b[n]&&b[n][L]),typeof f>"u"||!f.length||!f[0]){var j="";T=[];for(m in b[n])this.terminals_[m]&&m>M&&T.push("'"+this.terminals_[m]+"'");S.showPosition?j="Parse error on line "+(E+1)+`:
|
|
`+S.showPosition()+`
|
|
Expecting `+T.join(", ")+", got '"+(this.terminals_[L]||L)+"'":j="Parse error on line "+(E+1)+": Unexpected "+(L==P?"end of input":"'"+(this.terminals_[L]||L)+"'"),this.parseError(j,{text:S.match,token:this.terminals_[L]||L,line:S.yylineno,loc:$,expected:T})}if(f[0]instanceof Array&&f.length>1)throw new Error("Parse Error: multiple actions possible at state: "+n+", token: "+L);switch(f[0]){case 1:h.push(L),k.push(S.yytext),p.push(S.yylloc),h.push(f[1]),L=null,R?(L=R,R=null):(C=S.yyleng,A=S.yytext,E=S.yylineno,$=S.yylloc,N>0&&N--);break;case 2:if(v=this.productions_[f[1]][1],i.$=k[k.length-v],i._$={first_line:p[p.length-(v||1)].first_line,last_line:p[p.length-1].last_line,first_column:p[p.length-(v||1)].first_column,last_column:p[p.length-1].last_column},I&&(i._$.range=[p[p.length-(v||1)].range[0],p[p.length-1].range[1]]),r=this.performAction.apply(i,[A,C,E,O.yy,f[1],k,p].concat(D)),typeof r<"u")return r;v&&(h=h.slice(0,-1*v*2),k=k.slice(0,-1*v),p=p.slice(0,-1*v)),h.push(this.productions_[f[1]][0]),k.push(i.$),p.push(i._$),B=b[h[h.length-2]][h[h.length-1]],h.push(B);break;case 3:return!0}}return!0},"parse")},_=(function(){var g={EOF:1,parseError:e(function(l,h){if(this.yy.parser)this.yy.parser.parseError(l,h);else throw new Error(l)},"parseError"),setInput:e(function(a,l){return this.yy=l||this.yy||{},this._input=a,this._more=this._backtrack=this.done=!1,this.yylineno=this.yyleng=0,this.yytext=this.matched=this.match="",this.conditionStack=["INITIAL"],this.yylloc={first_line:1,first_column:0,last_line:1,last_column:0},this.options.ranges&&(this.yylloc.range=[0,0]),this.offset=0,this},"setInput"),input:e(function(){var a=this._input[0];this.yytext+=a,this.yyleng++,this.offset++,this.match+=a,this.matched+=a;var l=a.match(/(?:\r\n?|\n).*/g);return l?(this.yylineno++,this.yylloc.last_line++):this.yylloc.last_column++,this.options.ranges&&this.yylloc.range[1]++,this._input=this._input.slice(1),a},"input"),unput:e(function(a){var l=a.length,h=a.split(/(?:\r\n?|\n)/g);this._input=a+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-l),this.offset-=l;var x=this.match.split(/(?:\r\n?|\n)/g);this.match=this.match.substr(0,this.match.length-1),this.matched=this.matched.substr(0,this.matched.length-1),h.length-1&&(this.yylineno-=h.length-1);var k=this.yylloc.range;return this.yylloc={first_line:this.yylloc.first_line,last_line:this.yylineno+1,first_column:this.yylloc.first_column,last_column:h?(h.length===x.length?this.yylloc.first_column:0)+x[x.length-h.length].length-h[0].length:this.yylloc.first_column-l},this.options.ranges&&(this.yylloc.range=[k[0],k[0]+this.yyleng-l]),this.yyleng=this.yytext.length,this},"unput"),more:e(function(){return this._more=!0,this},"more"),reject:e(function(){if(this.options.backtrack_lexer)this._backtrack=!0;else return this.parseError("Lexical error on line "+(this.yylineno+1)+`. You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).
|
|
`+this.showPosition(),{text:"",token:null,line:this.yylineno});return this},"reject"),less:e(function(a){this.unput(this.match.slice(a))},"less"),pastInput:e(function(){var a=this.matched.substr(0,this.matched.length-this.match.length);return(a.length>20?"...":"")+a.substr(-20).replace(/\n/g,"")},"pastInput"),upcomingInput:e(function(){var a=this.match;return a.length<20&&(a+=this._input.substr(0,20-a.length)),(a.substr(0,20)+(a.length>20?"...":"")).replace(/\n/g,"")},"upcomingInput"),showPosition:e(function(){var a=this.pastInput(),l=new Array(a.length+1).join("-");return a+this.upcomingInput()+`
|
|
`+l+"^"},"showPosition"),test_match:e(function(a,l){var h,x,k;if(this.options.backtrack_lexer&&(k={yylineno:this.yylineno,yylloc:{first_line:this.yylloc.first_line,last_line:this.last_line,first_column:this.yylloc.first_column,last_column:this.yylloc.last_column},yytext:this.yytext,match:this.match,matches:this.matches,matched:this.matched,yyleng:this.yyleng,offset:this.offset,_more:this._more,_input:this._input,yy:this.yy,conditionStack:this.conditionStack.slice(0),done:this.done},this.options.ranges&&(k.yylloc.range=this.yylloc.range.slice(0))),x=a[0].match(/(?:\r\n?|\n).*/g),x&&(this.yylineno+=x.length),this.yylloc={first_line:this.yylloc.last_line,last_line:this.yylineno+1,first_column:this.yylloc.last_column,last_column:x?x[x.length-1].length-x[x.length-1].match(/\r?\n?/)[0].length:this.yylloc.last_column+a[0].length},this.yytext+=a[0],this.match+=a[0],this.matches=a,this.yyleng=this.yytext.length,this.options.ranges&&(this.yylloc.range=[this.offset,this.offset+=this.yyleng]),this._more=!1,this._backtrack=!1,this._input=this._input.slice(a[0].length),this.matched+=a[0],h=this.performAction.call(this,this.yy,this,l,this.conditionStack[this.conditionStack.length-1]),this.done&&this._input&&(this.done=!1),h)return h;if(this._backtrack){for(var p in k)this[p]=k[p];return!1}return!1},"test_match"),next:e(function(){if(this.done)return this.EOF;this._input||(this.done=!0);var a,l,h,x;this._more||(this.yytext="",this.match="");for(var k=this._currentRules(),p=0;p<k.length;p++)if(h=this._input.match(this.rules[k[p]]),h&&(!l||h[0].length>l[0].length)){if(l=h,x=p,this.options.backtrack_lexer){if(a=this.test_match(h,k[p]),a!==!1)return a;if(this._backtrack){l=!1;continue}else return!1}else if(!this.options.flex)break}return l?(a=this.test_match(l,k[x]),a!==!1?a:!1):this._input===""?this.EOF:this.parseError("Lexical error on line "+(this.yylineno+1)+`. Unrecognized text.
|
|
`+this.showPosition(),{text:"",token:null,line:this.yylineno})},"next"),lex:e(function(){var l=this.next();return l||this.lex()},"lex"),begin:e(function(l){this.conditionStack.push(l)},"begin"),popState:e(function(){var l=this.conditionStack.length-1;return l>0?this.conditionStack.pop():this.conditionStack[0]},"popState"),_currentRules:e(function(){return this.conditionStack.length&&this.conditionStack[this.conditionStack.length-1]?this.conditions[this.conditionStack[this.conditionStack.length-1]].rules:this.conditions.INITIAL.rules},"_currentRules"),topState:e(function(l){return l=this.conditionStack.length-1-Math.abs(l||0),l>=0?this.conditionStack[l]:"INITIAL"},"topState"),pushState:e(function(l){this.begin(l)},"pushState"),stateStackSize:e(function(){return this.conditionStack.length},"stateStackSize"),options:{"case-insensitive":!0},performAction:e(function(l,h,x,k){var p=k;switch(x){case 0:return this.pushState("csv"),4;break;case 1:return this.pushState("csv"),4;break;case 2:return 10;case 3:return 5;case 4:return 12;case 5:return this.pushState("escaped_text"),18;break;case 6:return 20;case 7:return this.popState("escaped_text"),18;break;case 8:return 19}},"anonymous"),rules:[/^(?:sankey-beta\b)/i,/^(?:sankey\b)/i,/^(?:$)/i,/^(?:((\u000D\u000A)|(\u000A)))/i,/^(?:(\u002C))/i,/^(?:(\u0022))/i,/^(?:([\u0020-\u0021\u0023-\u002B\u002D-\u007E])*)/i,/^(?:(\u0022)(?!(\u0022)))/i,/^(?:(([\u0020-\u0021\u0023-\u002B\u002D-\u007E])|(\u002C)|(\u000D)|(\u000A)|(\u0022)(\u0022))*)/i],conditions:{csv:{rules:[2,3,4,5,6,7,8],inclusive:!1},escaped_text:{rules:[7,8],inclusive:!1},INITIAL:{rules:[0,1,2,3,4,5,6,7,8],inclusive:!0}}};return g})();c.lexer=_;function y(){this.yy={}}return e(y,"Parser"),y.prototype=c,c.Parser=y,new y})();lt.parser=lt;var J=lt;var et=[],nt=[],tt=new Map,Ht=e(()=>{et=[],nt=[],tt=new Map,vt()},"clear"),ut=class{constructor(o,s,u=0){this.source=o;this.target=s;this.value=u}static{e(this,"SankeyLink")}},Yt=e((t,o,s)=>{et.push(new ut(t,o,s))},"addLink"),ft=class{constructor(o){this.ID=o}static{e(this,"SankeyNode")}},qt=e(t=>{t=_t.sanitizeText(t,X());let o=tt.get(t);return o===void 0&&(o=new ft(t),tt.set(t,o),nt.push(o)),o},"findOrCreateNode"),Ut=e(()=>nt,"getNodes"),Xt=e(()=>et,"getLinks"),Gt=e(()=>({nodes:nt.map(t=>({id:t.ID})),links:et.map(t=>({source:t.source.ID,target:t.target.ID,value:t.value}))}),"getGraph"),Ot={nodesMap:tt,getConfig:e(()=>X().sankey,"getConfig"),getNodes:Ut,getLinks:Xt,getGraph:Gt,addLink:Yt,findOrCreateNode:qt,getAccTitle:Lt,setAccTitle:St,getAccDescription:Et,setAccDescription:wt,getDiagramTitle:Tt,setDiagramTitle:At,clear:Ht};function Q(t,o){let s;if(o===void 0)for(let u of t)u!=null&&(s<u||s===void 0&&u>=u)&&(s=u);else{let u=-1;for(let c of t)(c=o(c,++u,t))!=null&&(s<c||s===void 0&&c>=c)&&(s=c)}return s}e(Q,"max");function F(t,o){let s;if(o===void 0)for(let u of t)u!=null&&(s>u||s===void 0&&u>=u)&&(s=u);else{let u=-1;for(let c of t)(c=o(c,++u,t))!=null&&(s>c||s===void 0&&c>=c)&&(s=c)}return s}e(F,"min");function H(t,o){let s=0;if(o===void 0)for(let u of t)(u=+u)&&(s+=u);else{let u=-1;for(let c of t)(c=+o(c,++u,t))&&(s+=c)}return s}e(H,"sum");function Jt(t){return t.target.depth}e(Jt,"targetDepth");function ct(t){return t.depth}e(ct,"left");function ht(t,o){return o-1-t.height}e(ht,"right");function K(t,o){return t.sourceLinks.length?t.depth:o-1}e(K,"justify");function dt(t){return t.targetLinks.length?t.depth:t.sourceLinks.length?F(t.sourceLinks,Jt)-1:0}e(dt,"center");function Y(t){return function(){return t}}e(Y,"constant");function It(t,o){return rt(t.source,o.source)||t.index-o.index}e(It,"ascendingSourceBreadth");function Pt(t,o){return rt(t.target,o.target)||t.index-o.index}e(Pt,"ascendingTargetBreadth");function rt(t,o){return t.y0-o.y0}e(rt,"ascendingBreadth");function pt(t){return t.value}e(pt,"value");function Qt(t){return t.index}e(Qt,"defaultId");function Kt(t){return t.nodes}e(Kt,"defaultNodes");function Zt(t){return t.links}e(Zt,"defaultLinks");function Dt(t,o){let s=t.get(o);if(!s)throw new Error("missing: "+o);return s}e(Dt,"find");function Rt({nodes:t}){for(let o of t){let s=o.y0,u=s;for(let c of o.sourceLinks)c.y0=s+c.width/2,s+=c.width;for(let c of o.targetLinks)c.y1=u+c.width/2,u+=c.width}}e(Rt,"computeLinkBreadths");function ot(){let t=0,o=0,s=1,u=1,c=24,_=8,y,g=Qt,a=K,l,h,x=Kt,k=Zt,p=6;function b(){let n={nodes:x.apply(null,arguments),links:k.apply(null,arguments)};return A(n),E(n),C(n),N(n),D(n),Rt(n),n}e(b,"sankey"),b.update=function(n){return Rt(n),n},b.nodeId=function(n){return arguments.length?(g=typeof n=="function"?n:Y(n),b):g},b.nodeAlign=function(n){return arguments.length?(a=typeof n=="function"?n:Y(n),b):a},b.nodeSort=function(n){return arguments.length?(l=n,b):l},b.nodeWidth=function(n){return arguments.length?(c=+n,b):c},b.nodePadding=function(n){return arguments.length?(_=y=+n,b):_},b.nodes=function(n){return arguments.length?(x=typeof n=="function"?n:Y(n),b):x},b.links=function(n){return arguments.length?(k=typeof n=="function"?n:Y(n),b):k},b.linkSort=function(n){return arguments.length?(h=n,b):h},b.size=function(n){return arguments.length?(t=o=0,s=+n[0],u=+n[1],b):[s-t,u-o]},b.extent=function(n){return arguments.length?(t=+n[0][0],s=+n[1][0],o=+n[0][1],u=+n[1][1],b):[[t,o],[s,u]]},b.iterations=function(n){return arguments.length?(p=+n,b):p};function A({nodes:n,links:f}){for(let[r,i]of n.entries())i.index=r,i.sourceLinks=[],i.targetLinks=[];let d=new Map(n.map((r,i)=>[g(r,i,n),r]));for(let[r,i]of f.entries()){i.index=r;let{source:m,target:v}=i;typeof m!="object"&&(m=i.source=Dt(d,m)),typeof v!="object"&&(v=i.target=Dt(d,v)),m.sourceLinks.push(i),v.targetLinks.push(i)}if(h!=null)for(let{sourceLinks:r,targetLinks:i}of n)r.sort(h),i.sort(h)}e(A,"computeNodeLinks");function E({nodes:n}){for(let f of n)f.value=f.fixedValue===void 0?Math.max(H(f.sourceLinks,pt),H(f.targetLinks,pt)):f.fixedValue}e(E,"computeNodeValues");function C({nodes:n}){let f=n.length,d=new Set(n),r=new Set,i=0;for(;d.size;){for(let m of d){m.depth=i;for(let{target:v}of m.sourceLinks)r.add(v)}if(++i>f)throw new Error("circular link");d=r,r=new Set}}e(C,"computeNodeDepths");function N({nodes:n}){let f=n.length,d=new Set(n),r=new Set,i=0;for(;d.size;){for(let m of d){m.height=i;for(let{source:v}of m.targetLinks)r.add(v)}if(++i>f)throw new Error("circular link");d=r,r=new Set}}e(N,"computeNodeHeights");function M({nodes:n}){let f=Q(n,i=>i.depth)+1,d=(s-t-c)/(f-1),r=new Array(f);for(let i of n){let m=Math.max(0,Math.min(f-1,Math.floor(a.call(null,i,f))));i.layer=m,i.x0=t+m*d,i.x1=i.x0+c,r[m]?r[m].push(i):r[m]=[i]}if(l)for(let i of r)i.sort(l);return r}e(M,"computeNodeLayers");function P(n){let f=F(n,d=>(u-o-(d.length-1)*y)/H(d,pt));for(let d of n){let r=o;for(let i of d){i.y0=r,i.y1=r+i.value*f,r=i.y1+y;for(let m of i.sourceLinks)m.width=m.value*f}r=(u-r+y)/(d.length+1);for(let i=0;i<d.length;++i){let m=d[i];m.y0+=r*(i+1),m.y1+=r*(i+1)}W(d)}}e(P,"initializeNodeBreadths");function D(n){let f=M(n);y=Math.min(_,(u-o)/(Q(f,d=>d.length)-1)),P(f);for(let d=0;d<p;++d){let r=Math.pow(.99,d),i=Math.max(1-r,(d+1)/p);O(f,r,i),S(f,r,i)}}e(D,"computeNodeBreadths");function S(n,f,d){for(let r=1,i=n.length;r<i;++r){let m=n[r];for(let v of m){let B=0,T=0;for(let{source:w,value:at}of v.targetLinks){let U=at*(v.layer-w.layer);B+=L(w,v)*U,T+=U}if(!(T>0))continue;let j=(B/T-v.y0)*f;v.y0+=j,v.y1+=j,q(v)}l===void 0&&m.sort(rt),z(m,d)}}e(S,"relaxLeftToRight");function O(n,f,d){for(let r=n.length,i=r-2;i>=0;--i){let m=n[i];for(let v of m){let B=0,T=0;for(let{target:w,value:at}of v.sourceLinks){let U=at*(w.layer-v.layer);B+=R(v,w)*U,T+=U}if(!(T>0))continue;let j=(B/T-v.y0)*f;v.y0+=j,v.y1+=j,q(v)}l===void 0&&m.sort(rt),z(m,d)}}e(O,"relaxRightToLeft");function z(n,f){let d=n.length>>1,r=n[d];I(n,r.y0-y,d-1,f),$(n,r.y1+y,d+1,f),I(n,u,n.length-1,f),$(n,o,0,f)}e(z,"resolveCollisions");function $(n,f,d,r){for(;d<n.length;++d){let i=n[d],m=(f-i.y0)*r;m>1e-6&&(i.y0+=m,i.y1+=m),f=i.y1+y}}e($,"resolveCollisionsTopToBottom");function I(n,f,d,r){for(;d>=0;--d){let i=n[d],m=(i.y1-f)*r;m>1e-6&&(i.y0-=m,i.y1-=m),f=i.y0-y}}e(I,"resolveCollisionsBottomToTop");function q({sourceLinks:n,targetLinks:f}){if(h===void 0){for(let{source:{sourceLinks:d}}of f)d.sort(Pt);for(let{target:{targetLinks:d}}of n)d.sort(It)}}e(q,"reorderNodeLinks");function W(n){if(h===void 0)for(let{sourceLinks:f,targetLinks:d}of n)f.sort(Pt),d.sort(It)}e(W,"reorderLinks");function L(n,f){let d=n.y0-(n.sourceLinks.length-1)*y/2;for(let{target:r,width:i}of n.sourceLinks){if(r===f)break;d+=i+y}for(let{source:r,width:i}of f.targetLinks){if(r===n)break;d-=i}return d}e(L,"targetTop");function R(n,f){let d=f.y0-(f.targetLinks.length-1)*y/2;for(let{source:r,width:i}of f.targetLinks){if(r===n)break;d+=i+y}for(let{target:r,width:i}of n.sourceLinks){if(r===f)break;d-=i}return d}return e(R,"sourceTop"),b}e(ot,"Sankey");var yt=Math.PI,mt=2*yt,V=1e-6,te=mt-V;function gt(){this._x0=this._y0=this._x1=this._y1=null,this._=""}e(gt,"Path");function jt(){return new gt}e(jt,"path");gt.prototype=jt.prototype={constructor:gt,moveTo:e(function(t,o){this._+="M"+(this._x0=this._x1=+t)+","+(this._y0=this._y1=+o)},"moveTo"),closePath:e(function(){this._x1!==null&&(this._x1=this._x0,this._y1=this._y0,this._+="Z")},"closePath"),lineTo:e(function(t,o){this._+="L"+(this._x1=+t)+","+(this._y1=+o)},"lineTo"),quadraticCurveTo:e(function(t,o,s,u){this._+="Q"+ +t+","+ +o+","+(this._x1=+s)+","+(this._y1=+u)},"quadraticCurveTo"),bezierCurveTo:e(function(t,o,s,u,c,_){this._+="C"+ +t+","+ +o+","+ +s+","+ +u+","+(this._x1=+c)+","+(this._y1=+_)},"bezierCurveTo"),arcTo:e(function(t,o,s,u,c){t=+t,o=+o,s=+s,u=+u,c=+c;var _=this._x1,y=this._y1,g=s-t,a=u-o,l=_-t,h=y-o,x=l*l+h*h;if(c<0)throw new Error("negative radius: "+c);if(this._x1===null)this._+="M"+(this._x1=t)+","+(this._y1=o);else if(x>V)if(!(Math.abs(h*g-a*l)>V)||!c)this._+="L"+(this._x1=t)+","+(this._y1=o);else{var k=s-_,p=u-y,b=g*g+a*a,A=k*k+p*p,E=Math.sqrt(b),C=Math.sqrt(x),N=c*Math.tan((yt-Math.acos((b+x-A)/(2*E*C)))/2),M=N/C,P=N/E;Math.abs(M-1)>V&&(this._+="L"+(t+M*l)+","+(o+M*h)),this._+="A"+c+","+c+",0,0,"+ +(h*k>l*p)+","+(this._x1=t+P*g)+","+(this._y1=o+P*a)}},"arcTo"),arc:e(function(t,o,s,u,c,_){t=+t,o=+o,s=+s,_=!!_;var y=s*Math.cos(u),g=s*Math.sin(u),a=t+y,l=o+g,h=1^_,x=_?u-c:c-u;if(s<0)throw new Error("negative radius: "+s);this._x1===null?this._+="M"+a+","+l:(Math.abs(this._x1-a)>V||Math.abs(this._y1-l)>V)&&(this._+="L"+a+","+l),s&&(x<0&&(x=x%mt+mt),x>te?this._+="A"+s+","+s+",0,1,"+h+","+(t-y)+","+(o-g)+"A"+s+","+s+",0,1,"+h+","+(this._x1=a)+","+(this._y1=l):x>V&&(this._+="A"+s+","+s+",0,"+ +(x>=yt)+","+h+","+(this._x1=t+s*Math.cos(c))+","+(this._y1=o+s*Math.sin(c))))},"arc"),rect:e(function(t,o,s,u){this._+="M"+(this._x0=this._x1=+t)+","+(this._y0=this._y1=+o)+"h"+ +s+"v"+ +u+"h"+-s+"Z"},"rect"),toString:e(function(){return this._},"toString")};var xt=jt;function it(t){return e(function(){return t},"constant")}e(it,"default");function zt(t){return t[0]}e(zt,"x");function $t(t){return t[1]}e($t,"y");var Bt=Array.prototype.slice;function ee(t){return t.source}e(ee,"linkSource");function ne(t){return t.target}e(ne,"linkTarget");function re(t){var o=ee,s=ne,u=zt,c=$t,_=null;function y(){var g,a=Bt.call(arguments),l=o.apply(this,a),h=s.apply(this,a);if(_||(_=g=xt()),t(_,+u.apply(this,(a[0]=l,a)),+c.apply(this,a),+u.apply(this,(a[0]=h,a)),+c.apply(this,a)),g)return _=null,g+""||null}return e(y,"link"),y.source=function(g){return arguments.length?(o=g,y):o},y.target=function(g){return arguments.length?(s=g,y):s},y.x=function(g){return arguments.length?(u=typeof g=="function"?g:it(+g),y):u},y.y=function(g){return arguments.length?(c=typeof g=="function"?g:it(+g),y):c},y.context=function(g){return arguments.length?(_=g??null,y):_},y}e(re,"link");function oe(t,o,s,u,c){t.moveTo(o,s),t.bezierCurveTo(o=(o+u)/2,s,o,c,u,c)}e(oe,"curveHorizontal");function kt(){return re(oe)}e(kt,"linkHorizontal");function ie(t){return[t.source.x1,t.y0]}e(ie,"horizontalSource");function se(t){return[t.target.x0,t.y1]}e(se,"horizontalTarget");function st(){return kt().source(ie).target(se)}e(st,"default");var Z=class t{static{e(this,"Uid")}static{this.count=0}static next(o){return new t(o+ ++t.count)}constructor(o){this.id=o,this.href=`#${o}`}toString(){return"url("+this.href+")"}};var ae={left:ct,right:ht,center:dt,justify:K},le=e(t=>{let o=0,s=0;for(let u of t){let c=u.value??0;c>o&&(o=c,s=u.layer??0)}return s},"findCentralNodeLayer"),ue=e(function(t,o,s,u){let{securityLevel:c,sankey:_}=X(),y=Ct.sankey,g;c==="sandbox"&&(g=G("#i"+o));let a=c==="sandbox"?G(g.nodes()[0].contentDocument.body):G("body"),l=c==="sandbox"?a.select(`[id="${o}"]`):G(`[id="${o}"]`),h=_?.width??y.width,x=_?.height??y.width,k=_?.useMaxWidth??y.useMaxWidth,p=_?.nodeAlignment??y.nodeAlignment,b=_?.prefix??y.prefix,A=_?.suffix??y.suffix,E=_?.showValues??y.showValues,C=_?.nodeWidth??y.nodeWidth??10,N=_?.nodePadding??y.nodePadding??12,M=_?.labelStyle??y.labelStyle??"legacy",P=_?.nodeColors??{},D=u.db.getGraph(),S=ae[p];ot().nodeId(r=>r.id).nodeWidth(C).nodePadding(N+(E?15:0)).nodeAlign(S).extent([[0,0],[h,x]])(D);let z=le(D.nodes),$=Nt(Mt),I=e(r=>P[r]??$(r),"getNodeColor");l.append("g").attr("class","nodes").selectAll(".node").data(D.nodes).join("g").attr("class","node").attr("id",r=>(r.uid=Z.next("node-")).id).attr("transform",function(r){return"translate("+r.x0+","+r.y0+")"}).attr("x",r=>r.x0).attr("y",r=>r.y0).append("rect").attr("height",r=>r.y1-r.y0).attr("width",r=>r.x1-r.x0).attr("fill",r=>I(r.id));let q=e(({id:r,value:i})=>E?`${r}
|
|
${b}${Math.round(i*100)/100}${A}`:r,"getText"),W=e(r=>M==="outlined"?(r.layer??0)<z?{x:r.x0-6,anchor:"end"}:{x:r.x1+6,anchor:"start"}:r.x0<h/2?{x:r.x1+6,anchor:"start"}:{x:r.x0-6,anchor:"end"},"getLabelPosition"),L=l.append("g").attr("class","node-labels").attr("font-size",14),R=e(r=>L.selectAll(r?`.${r}`:"text").data(D.nodes).join("text").attr("class",r??null).attr("x",i=>W(i).x).attr("y",i=>(i.y1+i.y0)/2).attr("dy",`${E?"0":"0.35"}em`).attr("text-anchor",i=>W(i).anchor).text(q),"appendLabel");M==="outlined"?(R("sankey-label-bg"),R("sankey-label-fg")):R();let n=l.append("g").attr("class","links").attr("fill","none").attr("stroke-opacity",.5).selectAll(".link").data(D.links).join("g").attr("class","link").style("mix-blend-mode","multiply"),f=_?.linkColor??"gradient";if(f==="gradient"){let r=n.append("linearGradient").attr("id",i=>(i.uid=Z.next("linearGradient-")).id).attr("gradientUnits","userSpaceOnUse").attr("x1",i=>i.source.x1).attr("x2",i=>i.target.x0);r.append("stop").attr("offset","0%").attr("stop-color",i=>I(i.source.id)),r.append("stop").attr("offset","100%").attr("stop-color",i=>I(i.target.id))}let d;switch(f){case"gradient":d=e(r=>r.uid,"coloring");break;case"source":d=e(r=>I(r.source.id),"coloring");break;case"target":d=e(r=>I(r.target.id),"coloring");break;default:d=f}n.append("path").attr("d",st()).attr("stroke",d).attr("stroke-width",r=>Math.max(1,r.width)),bt(void 0,l,0,k)},"draw"),Vt={draw:ue};var Wt=e(t=>t.replaceAll(/^[^\S\n\r]+|[^\S\n\r]+$/g,"").replaceAll(/([\n\r])+/g,`
|
|
`).trim(),"prepareTextForParsing");var fe=e(t=>`.label {
|
|
font-family: ${t.fontFamily};
|
|
}
|
|
|
|
.node-labels {
|
|
font-family: ${t.fontFamily};
|
|
}
|
|
|
|
/* Outlined label style - background stroke for better readability */
|
|
.sankey-label-bg {
|
|
stroke: ${t.mainBkg||t.background||"#fff"};
|
|
stroke-width: 4px;
|
|
stroke-linejoin: round;
|
|
paint-order: stroke;
|
|
}
|
|
|
|
/* Foreground label text */
|
|
.sankey-label-fg {
|
|
fill: ${t.textColor};
|
|
}
|
|
|
|
/* Node styling */
|
|
.node rect {
|
|
shape-rendering: crispEdges;
|
|
}
|
|
|
|
/* Link styling */
|
|
.link {
|
|
fill: none;
|
|
stroke-opacity: 0.5;
|
|
mix-blend-mode: multiply;
|
|
}
|
|
`,"getStyles"),Ft=fe;var ce=J.parse.bind(J);J.parse=t=>ce(Wt(t));var Nn={styles:Ft,parser:J,db:Ot,renderer:Vt};export{Nn as diagram};
|