import{D as vt,J as Ut,Oa as bt,b as Wt,c as Ft,eb as St,fb as wt,gb as Lt,h as X,hb as At,ib as Et,jb as Tt,kb as Ct,l as _t,lb as Mt,nb as Q,pb as Ot}from"./chunk-VNKGKUEF.js";import{h as ot}from"./chunk-3NXJ7VWC.js";function G(t,r){let s;if(r===void 0)for(let u of t)u!=null&&(s=u)&&(s=u);else{let u=-1;for(let c of t)(c=r(c,++u,t))!=null&&(s=c)&&(s=c)}return s}function B(t,r){let s;if(r===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=r(c,++u,t))!=null&&(s>c||s===void 0&&c>=c)&&(s=c)}return s}function V(t,r){let s=0;if(r===void 0)for(let u of t)(u=+u)&&(s+=u);else{let u=-1;for(let c of t)(c=+r(c,++u,t))&&(s+=c)}return s}function qt(t){return t.target.depth}function st(t){return t.depth}function it(t,r){return r-1-t.height}function K(t,r){return t.sourceLinks.length?t.depth:r-1}function at(t){return t.targetLinks.length?t.depth:t.sourceLinks.length?B(t.sourceLinks,qt)-1:0}function W(t){return function(){return t}}function It(t,r){return J(t.source,r.source)||t.index-r.index}function Nt(t,r){return J(t.target,r.target)||t.index-r.index}function J(t,r){return t.y0-r.y0}function lt(t){return t.value}function Yt(t){return t.index}function Ht(t){return t.nodes}function Xt(t){return t.links}function Pt(t,r){let s=t.get(r);if(!s)throw new Error("missing: "+r);return s}function Rt({nodes:t}){for(let r of t){let s=r.y0,u=s;for(let c of r.sourceLinks)c.y0=s+c.width/2,s+=c.width;for(let c of r.targetLinks)c.y1=u+c.width/2,u+=c.width}}function Z(){let t=0,r=0,s=1,u=1,c=24,x=8,p,y=Yt,o=K,a,f,m=Ht,v=Xt,d=6;function k(){let n={nodes:m.apply(null,arguments),links:v.apply(null,arguments)};return A(n),L(n),E(n),M(n),b(n),Rt(n),n}k.update=function(n){return Rt(n),n},k.nodeId=function(n){return arguments.length?(y=typeof n=="function"?n:W(n),k):y},k.nodeAlign=function(n){return arguments.length?(o=typeof n=="function"?n:W(n),k):o},k.nodeSort=function(n){return arguments.length?(a=n,k):a},k.nodeWidth=function(n){return arguments.length?(c=+n,k):c},k.nodePadding=function(n){return arguments.length?(x=p=+n,k):x},k.nodes=function(n){return arguments.length?(m=typeof n=="function"?n:W(n),k):m},k.links=function(n){return arguments.length?(v=typeof n=="function"?n:W(n),k):v},k.linkSort=function(n){return arguments.length?(f=n,k):f},k.size=function(n){return arguments.length?(t=r=0,s=+n[0],u=+n[1],k):[s-t,u-r]},k.extent=function(n){return arguments.length?(t=+n[0][0],s=+n[1][0],r=+n[0][1],u=+n[1][1],k):[[t,r],[s,u]]},k.iterations=function(n){return arguments.length?(d=+n,k):d};function A({nodes:n,links:h}){for(let[l,i]of n.entries())i.index=l,i.sourceLinks=[],i.targetLinks=[];let e=new Map(n.map((l,i)=>[y(l,i,n),l]));for(let[l,i]of h.entries()){i.index=l;let{source:g,target:_}=i;typeof g!="object"&&(g=i.source=Pt(e,g)),typeof _!="object"&&(_=i.target=Pt(e,_)),g.sourceLinks.push(i),_.targetLinks.push(i)}if(f!=null)for(let{sourceLinks:l,targetLinks:i}of n)l.sort(f),i.sort(f)}function L({nodes:n}){for(let h of n)h.value=h.fixedValue===void 0?Math.max(V(h.sourceLinks,lt),V(h.targetLinks,lt)):h.fixedValue}function E({nodes:n}){let h=n.length,e=new Set(n),l=new Set,i=0;for(;e.size;){for(let g of e){g.depth=i;for(let{target:_}of g.sourceLinks)l.add(_)}if(++i>h)throw new Error("circular link");e=l,l=new Set}}function M({nodes:n}){let h=n.length,e=new Set(n),l=new Set,i=0;for(;e.size;){for(let g of e){g.height=i;for(let{source:_}of g.targetLinks)l.add(_)}if(++i>h)throw new Error("circular link");e=l,l=new Set}}function N({nodes:n}){let h=G(n,i=>i.depth)+1,e=(s-t-c)/(h-1),l=new Array(h);for(let i of n){let g=Math.max(0,Math.min(h-1,Math.floor(o.call(null,i,h))));i.layer=g,i.x0=t+g*e,i.x1=i.x0+c,l[g]?l[g].push(i):l[g]=[i]}if(a)for(let i of l)i.sort(a);return l}function z(n){let h=B(n,e=>(u-r-(e.length-1)*p)/V(e,lt));for(let e of n){let l=r;for(let i of e){i.y0=l,i.y1=l+i.value*h,l=i.y1+p;for(let g of i.sourceLinks)g.width=g.value*h}l=(u-l+p)/(e.length+1);for(let i=0;ie.length)-1)),z(h);for(let e=0;e0))continue;let q=(U/j-_.y0)*h;_.y0+=q,_.y1+=q,S(_)}a===void 0&&g.sort(J),O(g,e)}}function P(n,h,e){for(let l=n.length,i=l-2;i>=0;--i){let g=n[i];for(let _ of g){let U=0,j=0;for(let{target:Y,value:rt}of _.sourceLinks){let H=rt*(Y.layer-_.layer);U+=R(_,Y)*H,j+=H}if(!(j>0))continue;let q=(U/j-_.y0)*h;_.y0+=q,_.y1+=q,S(_)}a===void 0&&g.sort(J),O(g,e)}}function O(n,h){let e=n.length>>1,l=n[e];D(n,l.y0-p,e-1,h),I(n,l.y1+p,e+1,h),D(n,u,n.length-1,h),I(n,r,0,h)}function I(n,h,e,l){for(;e1e-6&&(i.y0+=g,i.y1+=g),h=i.y1+p}}function D(n,h,e,l){for(;e>=0;--e){let i=n[e],g=(i.y1-h)*l;g>1e-6&&(i.y0-=g,i.y1-=g),h=i.y0-p}}function S({sourceLinks:n,targetLinks:h}){if(f===void 0){for(let{source:{sourceLinks:e}}of h)e.sort(Nt);for(let{target:{targetLinks:e}}of n)e.sort(It)}}function T(n){if(f===void 0)for(let{sourceLinks:h,targetLinks:e}of n)h.sort(Nt),e.sort(It)}function w(n,h){let e=n.y0-(n.sourceLinks.length-1)*p/2;for(let{target:l,width:i}of n.sourceLinks){if(l===h)break;e+=i+p}for(let{source:l,width:i}of h.targetLinks){if(l===n)break;e-=i}return e}function R(n,h){let e=h.y0-(h.targetLinks.length-1)*p/2;for(let{source:l,width:i}of h.targetLinks){if(l===n)break;e+=i+p}for(let{target:l,width:i}of n.sourceLinks){if(l===h)break;e-=i}return e}return k}var ut=Math.PI,ft=2*ut,$=1e-6,Gt=ft-$;function ct(){this._x0=this._y0=this._x1=this._y1=null,this._=""}function zt(){return new ct}ct.prototype=zt.prototype={constructor:ct,moveTo:function(t,r){this._+="M"+(this._x0=this._x1=+t)+","+(this._y0=this._y1=+r)},closePath:function(){this._x1!==null&&(this._x1=this._x0,this._y1=this._y0,this._+="Z")},lineTo:function(t,r){this._+="L"+(this._x1=+t)+","+(this._y1=+r)},quadraticCurveTo:function(t,r,s,u){this._+="Q"+ +t+","+ +r+","+(this._x1=+s)+","+(this._y1=+u)},bezierCurveTo:function(t,r,s,u,c,x){this._+="C"+ +t+","+ +r+","+ +s+","+ +u+","+(this._x1=+c)+","+(this._y1=+x)},arcTo:function(t,r,s,u,c){t=+t,r=+r,s=+s,u=+u,c=+c;var x=this._x1,p=this._y1,y=s-t,o=u-r,a=x-t,f=p-r,m=a*a+f*f;if(c<0)throw new Error("negative radius: "+c);if(this._x1===null)this._+="M"+(this._x1=t)+","+(this._y1=r);else if(m>$)if(!(Math.abs(f*y-o*a)>$)||!c)this._+="L"+(this._x1=t)+","+(this._y1=r);else{var v=s-x,d=u-p,k=y*y+o*o,A=v*v+d*d,L=Math.sqrt(k),E=Math.sqrt(m),M=c*Math.tan((ut-Math.acos((k+m-A)/(2*L*E)))/2),N=M/E,z=M/L;Math.abs(N-1)>$&&(this._+="L"+(t+N*a)+","+(r+N*f)),this._+="A"+c+","+c+",0,0,"+ +(f*v>a*d)+","+(this._x1=t+z*y)+","+(this._y1=r+z*o)}},arc:function(t,r,s,u,c,x){t=+t,r=+r,s=+s,x=!!x;var p=s*Math.cos(u),y=s*Math.sin(u),o=t+p,a=r+y,f=1^x,m=x?u-c:c-u;if(s<0)throw new Error("negative radius: "+s);this._x1===null?this._+="M"+o+","+a:(Math.abs(this._x1-o)>$||Math.abs(this._y1-a)>$)&&(this._+="L"+o+","+a),s&&(m<0&&(m=m%ft+ft),m>Gt?this._+="A"+s+","+s+",0,1,"+f+","+(t-p)+","+(r-y)+"A"+s+","+s+",0,1,"+f+","+(this._x1=o)+","+(this._y1=a):m>$&&(this._+="A"+s+","+s+",0,"+ +(m>=ut)+","+f+","+(this._x1=t+s*Math.cos(c))+","+(this._y1=r+s*Math.sin(c))))},rect:function(t,r,s,u){this._+="M"+(this._x0=this._x1=+t)+","+(this._y0=this._y1=+r)+"h"+ +s+"v"+ +u+"h"+-s+"Z"},toString:function(){return this._}};var ht=zt;function dt(t){return function(){return t}}function Dt(t){return t[0]}function jt(t){return t[1]}var $t=Array.prototype.slice;function Kt(t){return t.source}function Qt(t){return t.target}function Jt(t){var r=Kt,s=Qt,u=Dt,c=jt,x=null;function p(){var y,o=$t.call(arguments),a=r.apply(this,o),f=s.apply(this,o);if(x||(x=y=ht()),t(x,+u.apply(this,(o[0]=a,o)),+c.apply(this,o),+u.apply(this,(o[0]=f,o)),+c.apply(this,o)),y)return x=null,y+""||null}return p.source=function(y){return arguments.length?(r=y,p):r},p.target=function(y){return arguments.length?(s=y,p):s},p.x=function(y){return arguments.length?(u=typeof y=="function"?y:dt(+y),p):u},p.y=function(y){return arguments.length?(c=typeof y=="function"?y:dt(+y),p):c},p.context=function(y){return arguments.length?(x=y==null?null:y,p):x},p}function Zt(t,r,s,u,c){t.moveTo(r,s),t.bezierCurveTo(r=(r+u)/2,s,r,c,u,c)}function pt(){return Jt(Zt)}function te(t){return[t.source.x1,t.y0]}function ee(t){return[t.target.x0,t.y1]}function yt(){return pt().source(te).target(ee)}var Ze=ot(Wt(),1),tn=ot(Ft(),1),en=ot(Ut(),1);var mt=function(){var t=function(y,o,a,f){for(a=a||{},f=y.length;f--;a[y[f]]=o);return a},r=[1,9],s=[1,10],u=[1,5,10,12],c={trace:function(){},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:function(o,a,f,m,v,d,k){var A=d.length-1;switch(v){case 7:let L=m.findOrCreateNode(d[A-4].trim().replaceAll('""','"')),E=m.findOrCreateNode(d[A-2].trim().replaceAll('""','"')),M=parseFloat(d[A].trim());m.addLink(L,E,M);break;case 8:case 9:case 11:this.$=d[A];break;case 10:this.$=d[A-1];break}},table:[{3:1,4:[1,2]},{1:[3]},{5:[1,3]},{6:4,8:5,15:6,16:7,17:8,18:r,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:r,20:s},{15:18,16:7,17:8,18:r,20:s},{18:[1,19]},t(s,[2,3]),{12:[1,20]},t(u,[2,10]),{15:21,16:7,17:8,18:r,20:s},t([1,5,10],[2,7])],defaultActions:{11:[2,1],12:[2,5]},parseError:function(o,a){if(a.recoverable)this.trace(o);else{var f=new Error(o);throw f.hash=a,f}},parse:function(o){var a=this,f=[0],m=[],v=[null],d=[],k=this.table,A="",L=0,E=0,M=2,N=1,z=d.slice.call(arguments,1),b=Object.create(this.lexer),C={yy:{}};for(var P in this.yy)Object.prototype.hasOwnProperty.call(this.yy,P)&&(C.yy[P]=this.yy[P]);b.setInput(o,C.yy),C.yy.lexer=b,C.yy.parser=this,typeof b.yylloc=="undefined"&&(b.yylloc={});var O=b.yylloc;d.push(O);var I=b.options&&b.options.ranges;typeof C.yy.parseError=="function"?this.parseError=C.yy.parseError:this.parseError=Object.getPrototypeOf(this).parseError;function D(){var _;return _=m.pop()||b.lex()||N,typeof _!="number"&&(_ instanceof Array&&(m=_,_=m.pop()),_=a.symbols_[_]||_),_}for(var S,T,w,R,n={},h,e,l,i;;){if(T=f[f.length-1],this.defaultActions[T]?w=this.defaultActions[T]:((S===null||typeof S=="undefined")&&(S=D()),w=k[T]&&k[T][S]),typeof w=="undefined"||!w.length||!w[0]){var g="";i=[];for(h in k[T])this.terminals_[h]&&h>M&&i.push("'"+this.terminals_[h]+"'");b.showPosition?g="Parse error on line "+(L+1)+`: `+b.showPosition()+` Expecting `+i.join(", ")+", got '"+(this.terminals_[S]||S)+"'":g="Parse error on line "+(L+1)+": Unexpected "+(S==N?"end of input":"'"+(this.terminals_[S]||S)+"'"),this.parseError(g,{text:b.match,token:this.terminals_[S]||S,line:b.yylineno,loc:O,expected:i})}if(w[0]instanceof Array&&w.length>1)throw new Error("Parse Error: multiple actions possible at state: "+T+", token: "+S);switch(w[0]){case 1:f.push(S),v.push(b.yytext),d.push(b.yylloc),f.push(w[1]),S=null,E=b.yyleng,A=b.yytext,L=b.yylineno,O=b.yylloc;break;case 2:if(e=this.productions_[w[1]][1],n.$=v[v.length-e],n._$={first_line:d[d.length-(e||1)].first_line,last_line:d[d.length-1].last_line,first_column:d[d.length-(e||1)].first_column,last_column:d[d.length-1].last_column},I&&(n._$.range=[d[d.length-(e||1)].range[0],d[d.length-1].range[1]]),R=this.performAction.apply(n,[A,E,L,C.yy,w[1],v,d].concat(z)),typeof R!="undefined")return R;e&&(f=f.slice(0,-1*e*2),v=v.slice(0,-1*e),d=d.slice(0,-1*e)),f.push(this.productions_[w[1]][0]),v.push(n.$),d.push(n._$),l=k[f[f.length-2]][f[f.length-1]],f.push(l);break;case 3:return!0}}return!0}},x=function(){var y={EOF:1,parseError:function(a,f){if(this.yy.parser)this.yy.parser.parseError(a,f);else throw new Error(a)},setInput:function(o,a){return this.yy=a||this.yy||{},this._input=o,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},input:function(){var o=this._input[0];this.yytext+=o,this.yyleng++,this.offset++,this.match+=o,this.matched+=o;var a=o.match(/(?:\r\n?|\n).*/g);return a?(this.yylineno++,this.yylloc.last_line++):this.yylloc.last_column++,this.options.ranges&&this.yylloc.range[1]++,this._input=this._input.slice(1),o},unput:function(o){var a=o.length,f=o.split(/(?:\r\n?|\n)/g);this._input=o+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-a),this.offset-=a;var m=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),f.length-1&&(this.yylineno-=f.length-1);var v=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:f?(f.length===m.length?this.yylloc.first_column:0)+m[m.length-f.length].length-f[0].length:this.yylloc.first_column-a},this.options.ranges&&(this.yylloc.range=[v[0],v[0]+this.yyleng-a]),this.yyleng=this.yytext.length,this},more:function(){return this._more=!0,this},reject: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},less:function(o){this.unput(this.match.slice(o))},pastInput:function(){var o=this.matched.substr(0,this.matched.length-this.match.length);return(o.length>20?"...":"")+o.substr(-20).replace(/\n/g,"")},upcomingInput:function(){var o=this.match;return o.length<20&&(o+=this._input.substr(0,20-o.length)),(o.substr(0,20)+(o.length>20?"...":"")).replace(/\n/g,"")},showPosition:function(){var o=this.pastInput(),a=new Array(o.length+1).join("-");return o+this.upcomingInput()+` `+a+"^"},test_match:function(o,a){var f,m,v;if(this.options.backtrack_lexer&&(v={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&&(v.yylloc.range=this.yylloc.range.slice(0))),m=o[0].match(/(?:\r\n?|\n).*/g),m&&(this.yylineno+=m.length),this.yylloc={first_line:this.yylloc.last_line,last_line:this.yylineno+1,first_column:this.yylloc.last_column,last_column:m?m[m.length-1].length-m[m.length-1].match(/\r?\n?/)[0].length:this.yylloc.last_column+o[0].length},this.yytext+=o[0],this.match+=o[0],this.matches=o,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(o[0].length),this.matched+=o[0],f=this.performAction.call(this,this.yy,this,a,this.conditionStack[this.conditionStack.length-1]),this.done&&this._input&&(this.done=!1),f)return f;if(this._backtrack){for(var d in v)this[d]=v[d];return!1}return!1},next:function(){if(this.done)return this.EOF;this._input||(this.done=!0);var o,a,f,m;this._more||(this.yytext="",this.match="");for(var v=this._currentRules(),d=0;da[0].length)){if(a=f,m=d,this.options.backtrack_lexer){if(o=this.test_match(f,v[d]),o!==!1)return o;if(this._backtrack){a=!1;continue}else return!1}else if(!this.options.flex)break}return a?(o=this.test_match(a,v[m]),o!==!1?o:!1):this._input===""?this.EOF:this.parseError("Lexical error on line "+(this.yylineno+1)+`. Unrecognized text. `+this.showPosition(),{text:"",token:null,line:this.yylineno})},lex:function(){var a=this.next();return a||this.lex()},begin:function(a){this.conditionStack.push(a)},popState:function(){var a=this.conditionStack.length-1;return a>0?this.conditionStack.pop():this.conditionStack[0]},_currentRules:function(){return this.conditionStack.length&&this.conditionStack[this.conditionStack.length-1]?this.conditions[this.conditionStack[this.conditionStack.length-1]].rules:this.conditions.INITIAL.rules},topState:function(a){return a=this.conditionStack.length-1-Math.abs(a||0),a>=0?this.conditionStack[a]:"INITIAL"},pushState:function(a){this.begin(a)},stateStackSize:function(){return this.conditionStack.length},options:{"case-insensitive":!0},performAction:function(a,f,m,v){switch(m){case 0:return this.pushState("csv"),4;case 1:return 10;case 2:return 5;case 3:return 12;case 4:return this.pushState("escaped_text"),18;case 5:return 20;case 6:return this.popState("escaped_text"),18;case 7:return 19}},rules:[/^(?:sankey-beta\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:[1,2,3,4,5,6,7],inclusive:!1},escaped_text:{rules:[6,7],inclusive:!1},INITIAL:{rules:[0,1,2,3,4,5,6,7],inclusive:!0}}};return y}();c.lexer=x;function p(){this.yy={}}return p.prototype=c,c.Parser=p,new p}();mt.parser=mt;var tt=mt,et=[],nt=[],F={},ne=()=>{et=[],nt=[],F={},wt()},gt=class{constructor(r,s,u=0){this.source=r,this.target=s,this.value=u}},re=(t,r,s)=>{et.push(new gt(t,r,s))},xt=class{constructor(r){this.ID=r}},oe=t=>(t=bt.sanitizeText(t,Q()),F[t]||(F[t]=new xt(t),nt.push(F[t])),F[t]),se=()=>nt,ie=()=>et,ae=()=>({nodes:nt.map(t=>({id:t.ID})),links:et.map(t=>({source:t.source.ID,target:t.target.ID,value:t.value}))}),le={nodesMap:F,getConfig:()=>Q().sankey,getNodes:se,getLinks:ie,getGraph:ae,addLink:re,findOrCreateNode:oe,getAccTitle:At,setAccTitle:Lt,getAccDescription:Tt,setAccDescription:Et,getDiagramTitle:Mt,setDiagramTitle:Ct,clear:ne},Vt=class kt{static next(r){return new kt(r+ ++kt.count)}constructor(r){this.id=r,this.href=`#${r}`}toString(){return"url("+this.href+")"}};Vt.count=0;var Bt=Vt,ue={left:st,right:it,center:at,justify:K},fe=function(t,r,s,u){var D,S,T,w,R,n,h;let{securityLevel:c,sankey:x}=Q(),p=Ot.sankey,y;c==="sandbox"&&(y=X("#i"+r));let o=c==="sandbox"?X(y.nodes()[0].contentDocument.body):X("body"),a=c==="sandbox"?o.select(`[id="${r}"]`):X(`[id="${r}"]`),f=(D=x==null?void 0:x.width)!=null?D:p.width,m=(S=x==null?void 0:x.height)!=null?S:p.width,v=(T=x==null?void 0:x.useMaxWidth)!=null?T:p.useMaxWidth,d=(w=x==null?void 0:x.nodeAlignment)!=null?w:p.nodeAlignment,k=(R=x==null?void 0:x.prefix)!=null?R:p.prefix,A=(n=x==null?void 0:x.suffix)!=null?n:p.suffix,L=(h=x==null?void 0:x.showValues)!=null?h:p.showValues,E=u.db.getGraph(),M=ue[d];Z().nodeId(e=>e.id).nodeWidth(10).nodePadding(10+(L?15:0)).nodeAlign(M).extent([[0,0],[f,m]])(E);let b=_t(vt);a.append("g").attr("class","nodes").selectAll(".node").data(E.nodes).join("g").attr("class","node").attr("id",e=>(e.uid=Bt.next("node-")).id).attr("transform",function(e){return"translate("+e.x0+","+e.y0+")"}).attr("x",e=>e.x0).attr("y",e=>e.y0).append("rect").attr("height",e=>e.y1-e.y0).attr("width",e=>e.x1-e.x0).attr("fill",e=>b(e.id));let C=({id:e,value:l})=>L?`${e} ${k}${Math.round(l*100)/100}${A}`:e;a.append("g").attr("class","node-labels").attr("font-family","sans-serif").attr("font-size",14).selectAll("text").data(E.nodes).join("text").attr("x",e=>e.x0(e.y1+e.y0)/2).attr("dy",`${L?"0":"0.35"}em`).attr("text-anchor",e=>e.x0(l.uid=Bt.next("linearGradient-")).id).attr("gradientUnits","userSpaceOnUse").attr("x1",l=>l.source.x1).attr("x2",l=>l.target.x0);e.append("stop").attr("offset","0%").attr("stop-color",l=>b(l.source.id)),e.append("stop").attr("offset","100%").attr("stop-color",l=>b(l.target.id))}let I;switch(O){case"gradient":I=e=>e.uid;break;case"source":I=e=>b(e.source.id);break;case"target":I=e=>b(e.target.id);break;default:I=O}P.append("path").attr("d",yt()).attr("stroke",I).attr("stroke-width",e=>Math.max(1,e.width)),St(void 0,a,0,v)},ce={draw:fe},he=t=>t.replaceAll(/^[^\S\n\r]+|[^\S\n\r]+$/g,"").replaceAll(/([\n\r])+/g,` `).trim(),de=tt.parse.bind(tt);tt.parse=t=>de(he(t));var nn={parser:tt,db:le,renderer:ce};export{nn as diagram};