From 29cfdd61bfe7eaeb327149edbd0b91180cd9407c Mon Sep 17 00:00:00 2001 From: Daniele Pala Date: Wed, 30 Dec 2020 23:01:38 +0100 Subject: [PATCH] update diagram controls to bootstrap 5 --- dist/cimdraw.min.js | 2 +- js/cimDiagramControls.riot | 30 +++++++++++++----------------- 2 files changed, 14 insertions(+), 18 deletions(-) diff --git a/dist/cimdraw.min.js b/dist/cimdraw.min.js index 0aa8fd1..7cf28bb 100644 --- a/dist/cimdraw.min.js +++ b/dist/cimdraw.min.js @@ -1,2 +1,2 @@ /* Riot v5.0.0, @license MIT */ -var t,e;function rotate(e,t){let n=d3.select("svg").node(),r=n.createSVGPoint();if(r.x=e.x,r.y=e.y,0===t)return r;let i=n.createSVGTransform();return i.setRotate(t,0,0),r.matrixTransform(i.matrix)}function rotateTerm(e,t){let n=e.getTargets([t],"Terminal.ConductingEquipment")[0],r=n.x,i=n.y,o=rotate({x:t.x-r,y:t.y-i},t.rotation);return{x:r+o.x,y:i+o.y}}function addToDiagram(e,t,n){let r=d3.pointer(t,d3.select("svg").node()),i=d3.zoomTransform(d3.select("svg").node()),o=i.x,a=i.y,s=i.k;n.x=(r[0]-o)/s,n.px=n.x,n.y=(r[1]-a)/s,n.py=n.y;let l=[{x:0,y:0,seq:1}];"cim:ACLineSegment"!==n.nodeName&&"cim:BusbarSection"!==n.nodeName||l.push({x:150,y:0,seq:2}),e.addToActiveDiagram(n,l)}function calcLineData(e,t){let n="ConnectivityNode",r="ConnectivityNode.Terminals";"BUS_BRANCH"===e.getMode()&&(n="TopologicalNode",r="TopologicalNode.Terminal"),t.x=void 0,t.y=void 0,t.rotation=0;let i=[],o=0,a=0,s=e.getEquipments(t).filter((e=>void 0!==e.lineData||"BusbarSection"===e.localName)),l=s.filter((e=>"BusbarSection"===e.localName))[0],c=e.getDiagramObjects([t]);if(0===c.length){if(void 0!==l){c=e.getDiagramObjects([l]);let n=e.getAttribute(c[0],"cim:DiagramObject.rotation");void 0!==n&&(t.rotation=parseInt(n.innerHTML))}else if(s.length>0){let e=[];for(let t of s){let n=t.x+t.lineData[t.lineData.length-1].x,r=t.y+t.lineData[t.lineData.length-1].y;e.push({x:t.x+t.lineData[0].x,y:t.y+t.lineData[0].y,eq:t},{x:n,y:r,eq:t})}let t=1/0,n=e[0],r=e[0];for(let i of e)for(let o of e){if(i.eq===o.eq)continue;let e=distance2(i,o);e0){for(let t of u){let n=e.getAttribute(t,"cim:DiagramObjectPoint.sequenceNumber");n=void 0===n?1:parseInt(n.innerHTML),i.push({x:parseFloat(e.getAttribute(t,"cim:DiagramObjectPoint.xPosition").innerHTML),y:parseFloat(e.getAttribute(t,"cim:DiagramObjectPoint.yPosition").innerHTML),seq:n})}i.sort((function(e,t){return e.seq-t.seq})),t.x=i[0].x,t.y=i[0].y;for(let e of i)e.x=e.x-t.x,e.y=e.y-t.y}else{if(i.push({x:0,y:0,seq:1}),t.nodeName==="cim:"+n){let n=e.getTargets([t],r);void 0!==e.getTargets(n,"Terminal.ConductingEquipment").filter((e=>"cim:BusbarSection"===e.nodeName))[0]&&i.push({x:150,y:0,seq:2})}t.x=o,t.y=a,e.addToActiveDiagram(t,i)}return t.lineData=i,i}function distance2(e,t){let n=e.x-t.x,r=e.y-t.y;return n*n+r*r}function closestPoint(e,t){let n=d3.line().x((function(e){return e.x})).y((function(e){return e.y})),r=d3.select(document.createElementNS("http://www.w3.org/2000/svg","svg")).append("path").attr("d",n(e.lineData)).node();if(null===r)return[0,0];let i,o,a=r.getTotalLength(),s=8,l=1/0;if(0===a)return[0,0];if(void 0===t.x||void 0===t.y)return[0,0];for(let t=0;t<=a;t+=s){let n=r.getPointAtLength(t);0!==e.rotation&&(n=rotate(n,e.rotation));let a=c(n);a.5;){let t=o-s;if(t>=0){let n=r.getPointAtLength(t);0!==e.rotation&&(n=rotate(n,e.rotation));let a=c(n);if(ae.matches('[data-bs-toggle="popover"]')));for(let e of t){let t=bootstrap.Popover.getInstance(e);null!==t&&t.hide()}}function showPopovers(e){let t=[];t=void 0===e?document.querySelectorAll('[data-bs-toggle="popover"]'):e.filter((e=>e.matches('[data-bs-toggle="popover"]')));for(let e of t){let t=bootstrap.Popover.getInstance(e);null!==t&&t.show()}}function disposePopovers(e){let t=[];t=void 0===e?document.querySelectorAll('[data-bs-toggle="popover"]'):e.filter((e=>e.matches('[data-bs-toggle="popover"]')));for(let e of t){let t=bootstrap.Popover.getInstance(e);null!==t&&t.dispose()}}function exportToMatpower(e){let t="function mpc = cim\n",n="100",r=[],i=topologyProcessor(e);r="NODE_BREAKER"===e.getMode()?i.calcTopology():e.getObjects(["cim:TopologicalNode"])["cim:TopologicalNode"],t+="% MATPOWER Case Format : Version 2\n",t+="mpc.version = '2';\n",t+="% system MVA base\n",t=t+"mpc.baseMVA = "+"100;\n",t+="% bus data\n",t+="mpc.bus = [\n",t+="%bus_i\ttype\tPd\tQd\tGs\tBs\tarea\tVm\tVa\tbaseKV\tzone\tVmax\tVmin\n";let o=new Map;for(let n in r){let a=e.ID(r[n]),s=1,l=u(e.getTargets([r[n]],"TopologicalNode.BaseVoltage")[0],"cim:BaseVoltage.nominalVoltage","0"),c=parseInt(n)+1,f=i.getTerminals(r[n]),d=e.getTargets(f,"Terminal.ConductingEquipment"),h=d.filter((t=>!0===e.schema.isA("EnergyConsumer",t))),p=d.filter((t=>!0===e.schema.isA("ShuntCompensator",t))),m=d.filter((t=>!0===e.schema.isA("SynchronousMachine",t))),g=d.filter((t=>!0===e.schema.isA("AsynchronousMachine",t))),b=(e.getTargets(f,"Terminal.TransformerEnd"),0),v=0,y=1;h.forEach((function(e){b+=parseFloat(u(e,"cim:EnergyConsumer.p","0.0")),v+=parseFloat(u(e,"cim:EnergyConsumer.q","0.0"))})),g.forEach((function(e){b+=parseFloat(u(e,"cim:RotatingMachine.p","0")),v+=parseFloat(u(e,"cim:RotatingMachine.q","0"))}));let _=0,w=0;if(p.forEach((function(e){let t=parseFloat(u(e,"cim:ShuntCompensator.sections","0.0")),n=parseFloat(u(e,"cim:LinearShuntCompensator.gPerSection","0.0")),r=parseFloat(u(e,"cim:LinearShuntCompensator.bPerSection","0.0"));_+=n*t,w+=r*t})),_=_*l*l,w=w*l*l,m.length>0||p.length>0){if(p.length>0){let t=i.getTerminals(p[0]),n=(e.getTargets(t,"Terminal.TopologicalNode"),e.getTargets([p[0]],"RegulatingCondEq.RegulatingControl")[0]);if(void 0!==n){s=2;let e=u(n,"cim:RegulatingControl.targetValue",l);y=parseFloat(e)/parseFloat(l)}}if(m.length>0){void 0!==e.getTargets([m[0]],"RegulatingCondEq.RegulatingControl")[0]&&(s=2)}}m.filter((function(e){return parseInt(u(e,"cim:SynchronousMachine.referencePriority","0"))>0})).length>0&&(s=3),t=t+c+"\t",t=t+s+"\t",t=t+b+"\t",t=t+v+"\t",t=t+_+"\t",t=t+w+"\t",t=t+1+"\t",t=t+y+"\t",t=t+0+"\t",t=t+l+"\t",t=t+1+"\t",t=t+1.1+"\t",t=t+.9+";\t",t=t+"%Node ("+a+")",t+="\n",o.set(r[n],c)}t+="];\n";let a=e.getObjects(["cim:SynchronousMachine"])["cim:SynchronousMachine"],s=e.getObjects(["cim:EquivalentInjection"])["cim:EquivalentInjection"];t+="% generator data\n",t+="mpc.gen = [\n",t+="%bus\tPg\tQg\tQmax\tQmin\tVg\tmBase\tstatus\tPmax\tPmin\tPc1\tPc2\tQc1min\tQc1max\tQc2min\tQc2max\tramp_agc\tramp_10\tramp_30\tramp_q\tapf\n",a.forEach((function(r){let a={};a.genUUID=e.ID(r);let s=i.getTerminals(r),l=e.getTargets(s,"Terminal.TopologicalNode"),f=e.getTargets([r],"RotatingMachine.GeneratingUnit")[0],d=e.getTargets([r],"RegulatingCondEq.RegulatingControl")[0];l.forEach((function(i){if(a.busNum=o.get(i),a.p=-1*parseFloat(u(r,"cim:RotatingMachine.p","0")),a.q=-1*parseFloat(u(r,"cim:RotatingMachine.q","0")),a.qmax=parseFloat(u(r,"cim:SynchronousMachine.maxQ","0")),a.qmin=parseFloat(u(r,"cim:SynchronousMachine.minQ","0")),a.vg=1,void 0!==d){let t=u(e.getTargets([i],"TopologicalNode.BaseVoltage")[0],"cim:BaseVoltage.nominalVoltage","0"),n=u(d,"cim:RegulatingControl.targetValue",t);a.vg=parseFloat(n)/parseFloat(t)}a.mbase=parseFloat(u(r,"cim:SynchronousMachine.ratedS",n)),a.pmax=parseFloat(u(f,"cim:GeneratingUnit.maxOperatingP","0")),a.pmin=parseFloat(u(f,"cim:GeneratingUnit.minOperatingP","0")),t+=c(a)}))})),s.forEach((function(r){let a={};a.genUUID=e.ID(r);let s=i.getTerminals(r),l=e.getTargets(s,"Terminal.TopologicalNode"),f=u(r,"cim:EquivalentInjection.regulationStatus","false");l.forEach((function(i){if(a.busNum=o.get(i),a.p=-1*parseFloat(u(r,"cim:EquivalentInjection.p","0")),a.q=-1*parseFloat(u(r,"cim:EquivalentInjection.q","0")),a.qmax=parseFloat(u(r,"cim:EquivalentInjection.maxQ","0")),a.qmin=parseFloat(u(r,"cim:EquivalentInjection.minQ","0")),a.vg=1,"true"===f){let t=u(e.getTargets([i],"TopologicalNode.BaseVoltage")[0],"cim:BaseVoltage.nominalVoltage","0"),n=u(r,"cim:EquivalentInjection.regulationTarget",t);a.vg=parseFloat(n)/parseFloat(t)}a.mbase=n,a.pmax=parseFloat(u(r,"cim:EquivalentInjection.maxP","0")),a.pmin=parseFloat(u(r,"cim:EquivalentInjection.minP","0")),t+=c(a)}))})),t+="];\n";let l=e.getObjects(["cim:ACLineSegment"])["cim:ACLineSegment"];return t+="% branch data\n",t+="mpc.branch = [\n",t+="%fbus\ttbus\tr\tx\tb\trateA\trateB\trateC\tratio\tangle\tstatus\tangmin\tangmax\n",l.forEach((function(r){let a=e.ID(r),s=i.getTerminals(r),l=e.getTargets(s,"Terminal.TopologicalNode");if(2===l.length){let i=u(e.getTargets(l,"TopologicalNode.BaseVoltage")[0],"cim:BaseVoltage.nominalVoltage","0"),s=parseFloat(i)*parseFloat(i)/parseFloat(n),c=u(r,"cim:ACLineSegment.r","0"),f=u(r,"cim:ACLineSegment.x","0"),d=u(r,"cim:ACLineSegment.bch","0"),h=parseFloat(c)/s,p=parseFloat(f)/s,m=parseFloat(d)*s;t=t+o.get(l[0])+"\t",t=t+o.get(l[1])+"\t",t=t+h+"\t",t=t+p+"\t",t=t+m+"\t",t=t+0+"\t",t=t+0+"\t",t=t+0+"\t",t=t+0+"\t",t=t+0+"\t",t=t+1+"\t",t+="-360\t",t+="360;\t",t=t+"%AC line segment ("+a+")",t+="\n"}})),e.getObjects(["cim:PowerTransformer"])["cim:PowerTransformer"].forEach((function(r){let a=e.ID(r),s=e.getTargets([r],"PowerTransformer.PowerTransformerEnd");if(2===s.length){let r=s[0],l=s[1],c=u(r,"cim:PowerTransformerEnd.r","0"),f=u(r,"cim:PowerTransformerEnd.x","0");"0"===c&&"0"===f&&(l=s[0],r=s[1],c=u(r,"cim:PowerTransformerEnd.r","0"),f=u(r,"cim:PowerTransformerEnd.x","0"));let d=u(r,"cim:PowerTransformerEnd.b","0"),h=i.getTerminals(r),p=e.getTargets(h,"Terminal.TopologicalNode")[0],m=i.getTerminals(l),g=e.getTargets(m,"Terminal.TopologicalNode")[0];if(1===h.length&&1===m.length&&void 0!==p&&void 0!==g){let i=u(e.getTargets([p],"TopologicalNode.BaseVoltage")[0],"cim:BaseVoltage.nominalVoltage","0"),s=u(e.getTargets([g],"TopologicalNode.BaseVoltage")[0],"cim:BaseVoltage.nominalVoltage","0"),h=u(r,"cim:PowerTransformerEnd.ratedU",i),m=u(l,"cim:PowerTransformerEnd.ratedU",s),b=parseFloat(i)*parseFloat(i)/parseFloat(n),v=parseFloat(c)/b,y=parseFloat(f)/b,_=parseFloat(d)*b,w=e.getTargets([r],"TransformerEnd.RatioTapChanger"),x=parseFloat(s)*parseFloat(h)/(parseFloat(i)*parseFloat(m)),T=!1;if(0===w.length&&(w=e.getTargets([l],"TransformerEnd.RatioTapChanger"),T=!0),w.length>0){let e=u(w[0],"cim:TapChanger.neutralStep","0"),t=u(w[0],"cim:TapChanger.step",e),n=u(w[0],"cim:RatioTapChanger.stepVoltageIncrement","0"),r=(parseFloat(t)-parseFloat(e))*parseFloat(n);r/=100,r=1+r,!0===T&&(r=1/r),x*=r}t=t+o.get(p)+"\t",t=t+o.get(g)+"\t",t=t+v+"\t",t=t+y+"\t",t=t+_+"\t",t=t+0+"\t",t=t+0+"\t",t=t+0+"\t",t=t+x+"\t",t=t+0+"\t",t=t+1+"\t",t+="-360\t",t+="360;\t",t=t+"%Two-winding transformer ("+a+")",t+="\n"}}if(3===s.length){let r=s[0],l=s[1],c=s[2],m=u(r,"cim:PowerTransformerEnd.r","0"),g=u(l,"cim:PowerTransformerEnd.r","0"),b=u(c,"cim:PowerTransformerEnd.r","0"),v=u(r,"cim:PowerTransformerEnd.x","0"),y=u(l,"cim:PowerTransformerEnd.x","0"),_=u(c,"cim:PowerTransformerEnd.x","0"),w=u(r,"cim:PowerTransformerEnd.b","0"),x=u(l,"cim:PowerTransformerEnd.b","0"),T=u(c,"cim:PowerTransformerEnd.b","0"),A=i.getTerminals(r),E=i.getTerminals(l),k=i.getTerminals(c),S=e.getTargets(A,"Terminal.TopologicalNode")[0],M=e.getTargets(E,"Terminal.TopologicalNode")[0],C=e.getTargets(k,"Terminal.TopologicalNode")[0];if(1===A.length&&1===E.length&&1===k.length){let i=e.getTargets([S],"TopologicalNode.BaseVoltage")[0],s=e.getTargets([M],"TopologicalNode.BaseVoltage")[0],A=e.getTargets([C],"TopologicalNode.BaseVoltage")[0],E=u(i,"cim:BaseVoltage.nominalVoltage","0"),k=u(s,"cim:BaseVoltage.nominalVoltage","0"),N=u(A,"cim:BaseVoltage.nominalVoltage","0"),D=u(r,"cim:PowerTransformerEnd.ratedU",E),L=u(l,"cim:PowerTransformerEnd.ratedU",k),O=u(c,"cim:PowerTransformerEnd.ratedU",N),I=parseFloat(E)*parseFloat(E)/parseFloat(n),B=parseFloat(k)*parseFloat(k)/parseFloat(n),P=parseFloat(N)*parseFloat(N)/parseFloat(n),j=parseFloat(m)/I,R=parseFloat(g)/B,z=parseFloat(b)/P,F=parseFloat(v)/I,q=parseFloat(y)/B,U=parseFloat(_)/P,H=parseFloat(w)*I,V=parseFloat(x)*B,G=parseFloat(T)*P,W=f(j,F),Y=f(R,q),Z=f(z,U),K=d(d(h(W,Y),h(Y,Z)),h(Z,W)),X=h(K,p(Z)),Q=h(K,p(W)),$=h(K,p(Y)),J=parseFloat(k)*parseFloat(D)/(parseFloat(E)*parseFloat(L)),ee=parseFloat(N)*parseFloat(L)/(parseFloat(k)*parseFloat(O)),te=parseFloat(E)*parseFloat(O)/(parseFloat(N)*parseFloat(D));t=t+o.get(S)+"\t",t=t+o.get(M)+"\t",t=t+X.re+"\t",t=t+X.im+"\t",t=t+H+"\t",t=t+0+"\t",t=t+0+"\t",t=t+0+"\t",t=t+J+"\t",t=t+0+"\t",t=t+1+"\t",t+="-360\t",t+="360;\t",t=t+"%Three-winding transformer branch 1-2 ("+a+")",t+="\n",t=t+o.get(M)+"\t",t=t+o.get(C)+"\t",t=t+Q.re+"\t",t=t+Q.im+"\t",t=t+V+"\t",t=t+0+"\t",t=t+0+"\t",t=t+0+"\t",t=t+ee+"\t",t=t+0+"\t",t=t+1+"\t",t+="-360\t",t+="360;\t",t=t+"%Three-winding transformer branch 2-3 ("+a+")",t+="\n",t=t+o.get(C)+"\t",t=t+o.get(S)+"\t",t=t+$.re+"\t",t=t+$.im+"\t",t=t+G+"\t",t=t+0+"\t",t=t+0+"\t",t=t+0+"\t",t=t+te+"\t",t=t+0+"\t",t=t+1+"\t",t+="-360\t",t+="360;\t",t=t+"%Three-winding transformer branch 3-1 ("+a+")",t+="\n"}}})),t+="];\n",t;function c(e){let t="";return t=t+e.busNum+"\t",t=t+e.p+"\t",t=t+e.q+"\t",t=t+e.qmax+"\t",t=t+e.qmin+"\t",t=t+e.vg+"\t",t=t+e.mbase+"\t",t=t+1+"\t",t=t+e.pmax+"\t",t=t+e.pmin+"\t",t=t+0+"\t",t=t+0+"\t",t=t+0+"\t",t=t+0+"\t",t=t+0+"\t",t=t+0+"\t",t=t+0+"\t",t=t+0+"\t",t=t+0+"\t",t=t+0+"\t",t=t+0+";\t",t=t+"%Generator ("+e.genUUID+")",t+="\n",t}function u(t,n,r){let i=e.getAttribute(t,n);return i=void 0===i?r:i.textContent,i}function f(e,t){return{re:e,im:t}}function d(e,t){return{re:e.re+t.re,im:e.im+t.im}}function h(e,t){return{re:e.re*t.re-e.im*t.im,im:e.re*t.im+e.im*t.re}}function p(e){const t=e.re*e.re+e.im*e.im;return{re:e.re/t,im:-e.im/t}}}!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).d3=e.d3||{})}(this,(function(e){"use strict";function t(e,t){return et?1:e>=t?0:NaN}function n(e){let n=e,r=e;function i(e,t,n,i){for(null==n&&(n=0),null==i&&(i=e.length);n>>1;r(e[o],t)<0?n=o+1:i=o}return n}return 1===e.length&&(n=(t,n)=>e(t)-n,r=function(e){return(n,r)=>t(e(n),r)}(e)),{left:i,center:function(e,t,r,o){null==r&&(r=0),null==o&&(o=e.length);const a=i(e,t,r,o-1);return a>r&&n(e[a-1],t)>-n(e[a],t)?a-1:a},right:function(e,t,n,i){for(null==n&&(n=0),null==i&&(i=e.length);n>>1;r(e[o],t)>0?i=o:n=o+1}return n}}}function r(e){return null===e?NaN:+e}const i=n(t),o=i.right,a=i.left,s=n(r).center;function l(e,t){let n=0;if(void 0===t)for(let t of e)null!=t&&(t=+t)>=t&&++n;else{let r=-1;for(let i of e)null!=(i=t(i,++r,e))&&(i=+i)>=i&&++n}return n}function c(e){return 0|e.length}function u(e){return!(e>0)}function f(e){return"object"!=typeof e||"length"in e?e:Array.from(e)}function d(e,t){let n,r=0,i=0,o=0;if(void 0===t)for(let t of e)null!=t&&(t=+t)>=t&&(n=t-i,i+=n/++r,o+=n*(t-i));else{let a=-1;for(let s of e)null!=(s=t(s,++a,e))&&(s=+s)>=s&&(n=s-i,i+=n/++r,o+=n*(s-i))}if(r>1)return o/(r-1)}function h(e,t){const n=d(e,t);return n?Math.sqrt(n):n}function p(e,t){let n,r;if(void 0===t)for(const t of e)null!=t&&(void 0===n?t>=t&&(n=r=t):(n>t&&(n=t),r=o&&(n=r=o):(n>o&&(n=o),r0){for(o=e[--i];i>0&&(t=o,n=e[--i],o=t+n,r=n-(o-t),!r););i>0&&(r<0&&e[i-1]<0||r>0&&e[i-1]>0)&&(n=2*r,t=o+n,n==t-o&&(o=t))}return o}}function g(e){return e}function b(e){if(1!==e.length)throw new Error("duplicate key");return e[0]}function v(e,t,n,r){return function e(i,o){if(o>=r.length)return n(i);const a=new Map,s=r[o++];let l=-1;for(const e of i){const t=s(e,++l,i),n=a.get(t);n?n.push(e):a.set(t,[e])}for(const[t,n]of a)a.set(t,e(n,o));return t(a)}(e,0)}var y=Array.prototype.slice;function _(e){return function(){return e}}var w=Math.sqrt(50),x=Math.sqrt(10),T=Math.sqrt(2);function A(e,t,n){var r,i,o,a,s=-1;if(n=+n,(e=+e)==(t=+t)&&n>0)return[e];if((r=t0)for(e=Math.ceil(e/a),t=Math.floor(t/a),o=new Array(i=Math.ceil(t-e+1));++s=0?(o>=w?10:o>=x?5:o>=T?2:1)*Math.pow(10,i):-Math.pow(10,-i)/(o>=w?10:o>=x?5:o>=T?2:1)}function k(e,t,n){var r=Math.abs(t-e)/Math.max(0,n),i=Math.pow(10,Math.floor(Math.log(r)/Math.LN10)),o=r/i;return o>=w?i*=10:o>=x?i*=5:o>=T&&(i*=2),t0?(e=Math.floor(e/i)*i,t=Math.ceil(t/i)*i):i<0&&(e=Math.ceil(e*i)/i,t=Math.floor(t*i)/i),r=i}}function M(e){return Math.ceil(Math.log(l(e))/Math.LN2)+1}function C(){var e=g,t=p,n=M;function r(r){Array.isArray(r)||(r=Array.from(r));var i,a,s=r.length,l=new Array(s);for(i=0;i0?f=(Math.floor(f/e)+1)*e:e<0&&(f=(Math.ceil(f*e)+1)/e))}else d.pop()}for(var h=d.length;d[0]<=u;)d.shift(),--h;for(;d[h-1]>f;)d.pop(),--h;var m,g=new Array(h+1);for(i=0;i<=h;++i)(m=g[i]=[]).x0=i>0?d[i-1]:u,m.x1=i=t)&&(n=t);else{let r=-1;for(let i of e)null!=(i=t(i,++r,e))&&(n=i)&&(n=i)}return n}function D(e,t){let n;if(void 0===t)for(const t of e)null!=t&&(n>t||void 0===n&&t>=t)&&(n=t);else{let r=-1;for(let i of e)null!=(i=t(i,++r,e))&&(n>i||void 0===n&&i>=i)&&(n=i)}return n}function L(e,n,r=0,i=e.length-1,o=t){for(;i>r;){if(i-r>600){const t=i-r+1,a=n-r+1,s=Math.log(t),l=.5*Math.exp(2*s/3),c=.5*Math.sqrt(s*l*(t-l)/t)*(a-t/2<0?-1:1);L(e,n,Math.max(r,Math.floor(n-a*l/t+c)),Math.min(i,Math.floor(n+(t-a)*l/t+c)),o)}const t=e[n];let a=r,s=i;for(O(e,r,n),o(e[i],t)>0&&O(e,r,i);a0;)--s}0===o(e[r],t)?O(e,r,s):(++s,O(e,s,i)),s<=n&&(r=s+1),n<=s&&(i=s-1)}return e}function O(e,t,n){const r=e[t];e[t]=e[n],e[n]=r}function I(e,t,n){if(r=(e=Float64Array.from(function*(e,t){if(void 0===t)for(let t of e)null!=t&&(t=+t)>=t&&(yield t);else{let n=-1;for(let r of e)null!=(r=t(r,++n,e))&&(r=+r)>=r&&(yield r)}}(e,n))).length){if((t=+t)<=0||r<2)return D(e);if(t>=1)return N(e);var r,i=(r-1)*t,o=Math.floor(i),a=N(L(e,o).subarray(0,o+1));return a+(D(e.subarray(o+1))-a)*(i-o)}}function B(e,t,n=r){if(i=e.length){if((t=+t)<=0||i<2)return+n(e[0],0,e);if(t>=1)return+n(e[i-1],i-1,e);var i,o=(i-1)*t,a=Math.floor(o),s=+n(e[a],a,e);return s+(+n(e[a+1],a+1,e)-s)*(o-a)}}function P(e,t){let n,r=-1,i=-1;if(void 0===t)for(const t of e)++i,null!=t&&(n=t)&&(n=t,r=i);else for(let o of e)null!=(o=t(o,++i,e))&&(n=o)&&(n=o,r=i);return r}function j(e){return Array.from(function*(e){for(const t of e)yield*t}(e))}function R(e,t){let n,r=-1,i=-1;if(void 0===t)for(const t of e)++i,null!=t&&(n>t||void 0===n&&t>=t)&&(n=t,r=i);else for(let o of e)null!=(o=t(o,++i,e))&&(n>o||void 0===n&&o>=o)&&(n=o,r=i);return r}function z(e,t){return[e,t]}function F(e,t){return Array.from(t,(t=>e[t]))}function q(e,t,n){e=+e,t=+t,n=(i=arguments.length)<2?(t=e,e=0,1):i<3?1:+n;for(var r=-1,i=0|Math.max(0,Math.ceil((t-e)/n)),o=new Array(i);++r+e(t)}function te(e){var t=Math.max(0,e.bandwidth()-1)/2;return e.round()&&(t=Math.round(t)),function(n){return+e(n)+t}}function ne(){return!this.__axis}function re(e,t){var n=[],r=null,i=null,o=6,a=6,s=3,l=1===e||4===e?-1:1,c=4===e||2===e?"x":"y",u=1===e||3===e?$:J;function f(f){var d=null==r?t.ticks?t.ticks.apply(t,n):t.domain():r,h=null==i?t.tickFormat?t.tickFormat.apply(t,n):X:i,p=Math.max(o,0)+s,m=t.range(),g=+m[0]+.5,b=+m[m.length-1]+.5,v=(t.bandwidth?te:ee)(t.copy()),y=f.selection?f.selection():f,_=y.selectAll(".domain").data([null]),w=y.selectAll(".tick").data(d,t).order(),x=w.exit(),T=w.enter().append("g").attr("class","tick"),A=w.select("line"),E=w.select("text");_=_.merge(_.enter().insert("path",".tick").attr("class","domain").attr("stroke","currentColor")),w=w.merge(T),A=A.merge(T.append("line").attr("stroke","currentColor").attr(c+"2",l*o)),E=E.merge(T.append("text").attr("fill","currentColor").attr(c,l*p).attr("dy",1===e?"0em":3===e?"0.71em":"0.32em")),f!==y&&(_=_.transition(f),w=w.transition(f),A=A.transition(f),E=E.transition(f),x=x.transition(f).attr("opacity",Q).attr("transform",(function(e){return isFinite(e=v(e))?u(e):this.getAttribute("transform")})),T.attr("opacity",Q).attr("transform",(function(e){var t=this.parentNode.__axis;return u(t&&isFinite(t=t(e))?t:v(e))}))),x.remove(),_.attr("d",4===e||2==e?a?"M"+l*a+","+g+"H0.5V"+b+"H"+l*a:"M0.5,"+g+"V"+b:a?"M"+g+","+l*a+"V0.5H"+b+"V"+l*a:"M"+g+",0.5H"+b),w.attr("opacity",1).attr("transform",(function(e){return u(v(e))})),A.attr(c+"2",l*o),E.attr(c,l*p).text(h),y.filter(ne).attr("fill","none").attr("font-size",10).attr("font-family","sans-serif").attr("text-anchor",2===e?"start":4===e?"end":"middle"),y.each((function(){this.__axis=v}))}return f.scale=function(e){return arguments.length?(t=e,f):t},f.ticks=function(){return n=K.call(arguments),f},f.tickArguments=function(e){return arguments.length?(n=null==e?[]:K.call(e),f):n.slice()},f.tickValues=function(e){return arguments.length?(r=null==e?null:K.call(e),f):r&&r.slice()},f.tickFormat=function(e){return arguments.length?(i=e,f):i},f.tickSize=function(e){return arguments.length?(o=a=+e,f):o},f.tickSizeInner=function(e){return arguments.length?(o=+e,f):o},f.tickSizeOuter=function(e){return arguments.length?(a=+e,f):a},f.tickPadding=function(e){return arguments.length?(s=+e,f):s},f}var ie={value:()=>{}};function oe(){for(var e,t=0,n=arguments.length,r={};t=0&&(n=e.slice(r+1),e=e.slice(0,r)),e&&!t.hasOwnProperty(e))throw new Error("unknown type: "+e);return{type:e,name:n}}))}function le(e,t){for(var n,r=0,i=e.length;r0)for(var n,r,i=new Array(n),o=0;o=0&&"xmlns"!==(t=e.slice(0,n))&&(e=e.slice(n+1)),fe.hasOwnProperty(t)?{space:fe[t],local:e}:e}function he(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===ue&&t.documentElement.namespaceURI===ue?t.createElement(e):t.createElementNS(n,e)}}function pe(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function me(e){var t=de(e);return(t.local?pe:he)(t)}function ge(){}function be(e){return null==e?ge:function(){return this.querySelector(e)}}function ve(e){return"object"==typeof e&&"length"in e?e:Array.from(e)}function ye(){return[]}function _e(e){return null==e?ye:function(){return this.querySelectorAll(e)}}function we(e){return function(){return this.matches(e)}}function xe(e){return function(t){return t.matches(e)}}var Te=Array.prototype.find;function Ae(){return this.firstElementChild}var Ee=Array.prototype.filter;function ke(){return this.children}function Se(e){return new Array(e.length)}function Me(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}function Ce(e){return function(){return e}}function Ne(e,t,n,r,i,o){for(var a,s=0,l=t.length,c=o.length;st?1:e>=t?0:NaN}function Ie(e){return function(){this.removeAttribute(e)}}function Be(e){return function(){this.removeAttributeNS(e.space,e.local)}}function Pe(e,t){return function(){this.setAttribute(e,t)}}function je(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function Re(e,t){return function(){var n=t.apply(this,arguments);null==n?this.removeAttribute(e):this.setAttribute(e,n)}}function ze(e,t){return function(){var n=t.apply(this,arguments);null==n?this.removeAttributeNS(e.space,e.local):this.setAttributeNS(e.space,e.local,n)}}function Fe(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function qe(e){return function(){this.style.removeProperty(e)}}function Ue(e,t,n){return function(){this.style.setProperty(e,t,n)}}function He(e,t,n){return function(){var r=t.apply(this,arguments);null==r?this.style.removeProperty(e):this.style.setProperty(e,r,n)}}function Ve(e,t){return e.style.getPropertyValue(t)||Fe(e).getComputedStyle(e,null).getPropertyValue(t)}function Ge(e){return function(){delete this[e]}}function We(e,t){return function(){this[e]=t}}function Ye(e,t){return function(){var n=t.apply(this,arguments);null==n?delete this[e]:this[e]=n}}function Ze(e){return e.trim().split(/^|\s+/)}function Ke(e){return e.classList||new Xe(e)}function Xe(e){this._node=e,this._names=Ze(e.getAttribute("class")||"")}function Qe(e,t){for(var n=Ke(e),r=-1,i=t.length;++r=0&&(t=e.slice(n+1),e=e.slice(0,n)),{type:e,name:t}}))}function mt(e){return function(){var t=this.__on;if(t){for(var n,r=0,i=-1,o=t.length;r=0&&(this._names.splice(t,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(e){return this._names.indexOf(e)>=0}};var _t=[null];function wt(e,t){this._groups=e,this._parents=t}function xt(){return new wt([[document.documentElement]],_t)}function Tt(e){return"string"==typeof e?new wt([[document.querySelector(e)]],[document.documentElement]):new wt([[e]],_t)}wt.prototype=xt.prototype={constructor:wt,select:function(e){"function"!=typeof e&&(e=be(e));for(var t=this._groups,n=t.length,r=new Array(n),i=0;i=w&&(w=_+1);!(y=g[w])&&++w=0;)(r=i[o])&&(a&&4^r.compareDocumentPosition(a)&&a.parentNode.insertBefore(r,a),a=r);return this},sort:function(e){function t(t,n){return t&&n?e(t.__data__,n.__data__):!t-!n}e||(e=Oe);for(var n=this._groups,r=n.length,i=new Array(r),o=0;o1?this.each((null==t?qe:"function"==typeof t?He:Ue)(e,t,null==n?"":n)):Ve(this.node(),e)},property:function(e,t){return arguments.length>1?this.each((null==t?Ge:"function"==typeof t?Ye:We)(e,t)):this.node()[e]},classed:function(e,t){var n=Ze(e+"");if(arguments.length<2){for(var r=Ke(this.node()),i=-1,o=n.length;++i()=>e;function It(e,{sourceEvent:t,subject:n,target:r,identifier:i,active:o,x:a,y:s,dx:l,dy:c,dispatch:u}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},subject:{value:n,enumerable:!0,configurable:!0},target:{value:r,enumerable:!0,configurable:!0},identifier:{value:i,enumerable:!0,configurable:!0},active:{value:o,enumerable:!0,configurable:!0},x:{value:a,enumerable:!0,configurable:!0},y:{value:s,enumerable:!0,configurable:!0},dx:{value:l,enumerable:!0,configurable:!0},dy:{value:c,enumerable:!0,configurable:!0},_:{value:u}})}function Bt(e){return!e.ctrlKey&&!e.button}function Pt(){return this.parentNode}function jt(e,t){return null==t?{x:e.x,y:e.y}:t}function Rt(){return navigator.maxTouchPoints||"ontouchstart"in this}function zt(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function Ft(e,t){var n=Object.create(e.prototype);for(var r in t)n[r]=t[r];return n}function qt(){}It.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};var Ut=.7,Ht=1/Ut,Vt="\\s*([+-]?\\d+)\\s*",Gt="\\s*([+-]?\\d*\\.?\\d+(?:[eE][+-]?\\d+)?)\\s*",Wt="\\s*([+-]?\\d*\\.?\\d+(?:[eE][+-]?\\d+)?)%\\s*",Yt=/^#([0-9a-f]{3,8})$/,Zt=new RegExp("^rgb\\("+[Vt,Vt,Vt]+"\\)$"),Kt=new RegExp("^rgb\\("+[Wt,Wt,Wt]+"\\)$"),Xt=new RegExp("^rgba\\("+[Vt,Vt,Vt,Gt]+"\\)$"),Qt=new RegExp("^rgba\\("+[Wt,Wt,Wt,Gt]+"\\)$"),$t=new RegExp("^hsl\\("+[Gt,Wt,Wt]+"\\)$"),Jt=new RegExp("^hsla\\("+[Gt,Wt,Wt,Gt]+"\\)$"),en={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};function tn(){return this.rgb().formatHex()}function nn(){return this.rgb().formatRgb()}function rn(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=Yt.exec(e))?(n=t[1].length,t=parseInt(t[1],16),6===n?on(t):3===n?new cn(t>>8&15|t>>4&240,t>>4&15|240&t,(15&t)<<4|15&t,1):8===n?an(t>>24&255,t>>16&255,t>>8&255,(255&t)/255):4===n?an(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|240&t,((15&t)<<4|15&t)/255):null):(t=Zt.exec(e))?new cn(t[1],t[2],t[3],1):(t=Kt.exec(e))?new cn(255*t[1]/100,255*t[2]/100,255*t[3]/100,1):(t=Xt.exec(e))?an(t[1],t[2],t[3],t[4]):(t=Qt.exec(e))?an(255*t[1]/100,255*t[2]/100,255*t[3]/100,t[4]):(t=$t.exec(e))?hn(t[1],t[2]/100,t[3]/100,1):(t=Jt.exec(e))?hn(t[1],t[2]/100,t[3]/100,t[4]):en.hasOwnProperty(e)?on(en[e]):"transparent"===e?new cn(NaN,NaN,NaN,0):null}function on(e){return new cn(e>>16&255,e>>8&255,255&e,1)}function an(e,t,n,r){return r<=0&&(e=t=n=NaN),new cn(e,t,n,r)}function sn(e){return e instanceof qt||(e=rn(e)),e?new cn((e=e.rgb()).r,e.g,e.b,e.opacity):new cn}function ln(e,t,n,r){return 1===arguments.length?sn(e):new cn(e,t,n,null==r?1:r)}function cn(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}function un(){return"#"+dn(this.r)+dn(this.g)+dn(this.b)}function fn(){var e=this.opacity;return(1===(e=isNaN(e)?1:Math.max(0,Math.min(1,e)))?"rgb(":"rgba(")+Math.max(0,Math.min(255,Math.round(this.r)||0))+", "+Math.max(0,Math.min(255,Math.round(this.g)||0))+", "+Math.max(0,Math.min(255,Math.round(this.b)||0))+(1===e?")":", "+e+")")}function dn(e){return((e=Math.max(0,Math.min(255,Math.round(e)||0)))<16?"0":"")+e.toString(16)}function hn(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new gn(e,t,n,r)}function pn(e){if(e instanceof gn)return new gn(e.h,e.s,e.l,e.opacity);if(e instanceof qt||(e=rn(e)),!e)return new gn;if(e instanceof gn)return e;var t=(e=e.rgb()).r/255,n=e.g/255,r=e.b/255,i=Math.min(t,n,r),o=Math.max(t,n,r),a=NaN,s=o-i,l=(o+i)/2;return s?(a=t===o?(n-r)/s+6*(n0&&l<1?0:a,new gn(a,s,l,e.opacity)}function mn(e,t,n,r){return 1===arguments.length?pn(e):new gn(e,t,n,null==r?1:r)}function gn(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}function bn(e,t,n){return 255*(e<60?t+(n-t)*e/60:e<180?n:e<240?t+(n-t)*(240-e)/60:t)}zt(qt,rn,{copy:function(e){return Object.assign(new this.constructor,this,e)},displayable:function(){return this.rgb().displayable()},hex:tn,formatHex:tn,formatHsl:function(){return pn(this).formatHsl()},formatRgb:nn,toString:nn}),zt(cn,ln,Ft(qt,{brighter:function(e){return e=null==e?Ht:Math.pow(Ht,e),new cn(this.r*e,this.g*e,this.b*e,this.opacity)},darker:function(e){return e=null==e?Ut:Math.pow(Ut,e),new cn(this.r*e,this.g*e,this.b*e,this.opacity)},rgb:function(){return this},displayable:function(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:un,formatHex:un,formatRgb:fn,toString:fn})),zt(gn,mn,Ft(qt,{brighter:function(e){return e=null==e?Ht:Math.pow(Ht,e),new gn(this.h,this.s,this.l*e,this.opacity)},darker:function(e){return e=null==e?Ut:Math.pow(Ut,e),new gn(this.h,this.s,this.l*e,this.opacity)},rgb:function(){var e=this.h%360+360*(this.h<0),t=isNaN(e)||isNaN(this.s)?0:this.s,n=this.l,r=n+(n<.5?n:1-n)*t,i=2*n-r;return new cn(bn(e>=240?e-240:e+120,i,r),bn(e,i,r),bn(e<120?e+240:e-120,i,r),this.opacity)},displayable:function(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl:function(){var e=this.opacity;return(1===(e=isNaN(e)?1:Math.max(0,Math.min(1,e)))?"hsl(":"hsla(")+(this.h||0)+", "+100*(this.s||0)+"%, "+100*(this.l||0)+"%"+(1===e?")":", "+e+")")}}));const vn=Math.PI/180,yn=180/Math.PI,_n=.96422,wn=.82521,xn=4/29,Tn=6/29,An=3*Tn*Tn;function En(e){if(e instanceof Sn)return new Sn(e.l,e.a,e.b,e.opacity);if(e instanceof In)return Bn(e);e instanceof cn||(e=sn(e));var t,n,r=Dn(e.r),i=Dn(e.g),o=Dn(e.b),a=Mn((.2225045*r+.7168786*i+.0606169*o)/1);return r===i&&i===o?t=n=a:(t=Mn((.4360747*r+.3850649*i+.1430804*o)/_n),n=Mn((.0139322*r+.0971045*i+.7141733*o)/wn)),new Sn(116*a-16,500*(t-a),200*(a-n),e.opacity)}function kn(e,t,n,r){return 1===arguments.length?En(e):new Sn(e,t,n,null==r?1:r)}function Sn(e,t,n,r){this.l=+e,this.a=+t,this.b=+n,this.opacity=+r}function Mn(e){return e>.008856451679035631?Math.pow(e,1/3):e/An+xn}function Cn(e){return e>Tn?e*e*e:An*(e-xn)}function Nn(e){return 255*(e<=.0031308?12.92*e:1.055*Math.pow(e,1/2.4)-.055)}function Dn(e){return(e/=255)<=.04045?e/12.92:Math.pow((e+.055)/1.055,2.4)}function Ln(e){if(e instanceof In)return new In(e.h,e.c,e.l,e.opacity);if(e instanceof Sn||(e=En(e)),0===e.a&&0===e.b)return new In(NaN,0=1?(n=1,t-1):Math.floor(n*t),i=e[r],o=e[r+1],a=r>0?e[r-1]:2*i-o,s=r()=>e;function Qn(e,t){return function(n){return e+n*t}}function $n(e,t){var n=t-e;return n?Qn(e,n>180||n<-180?n-360*Math.round(n/360):n):Xn(isNaN(e)?t:e)}function Jn(e,t){var n=t-e;return n?Qn(e,n):Xn(isNaN(e)?t:e)}var er=function e(t){var n=function(e){return 1==(e=+e)?Jn:function(t,n){return n-t?function(e,t,n){return e=Math.pow(e,n),t=Math.pow(t,n)-e,n=1/n,function(r){return Math.pow(e+r*t,n)}}(t,n,e):Xn(isNaN(t)?n:t)}}(t);function r(e,t){var r=n((e=ln(e)).r,(t=ln(t)).r),i=n(e.g,t.g),o=n(e.b,t.b),a=Jn(e.opacity,t.opacity);return function(t){return e.r=r(t),e.g=i(t),e.b=o(t),e.opacity=a(t),e+""}}return r.gamma=e,r}(1);function tr(e){return function(t){var n,r,i=t.length,o=new Array(i),a=new Array(i),s=new Array(i);for(n=0;no&&(i=t.slice(o,i),s[a]?s[a]+=i:s[++a]=i),(n=n[0])===(r=r[0])?s[a]?s[a]+=r:s[++a]=r:(s[++a]=null,l.push({i:a,x:lr(n,r)})),o=fr.lastIndex;return o180?t+=360:t-e>180&&(e+=360),o.push({i:n.push(i(n)+"rotate(",null,r)-2,x:lr(e,t)})):t&&n.push(i(n)+"rotate("+t+r)}(o.rotate,a.rotate,s,l),function(e,t,n,o){e!==t?o.push({i:n.push(i(n)+"skewX(",null,r)-2,x:lr(e,t)}):t&&n.push(i(n)+"skewX("+t+r)}(o.skewX,a.skewX,s,l),function(e,t,n,r,o,a){if(e!==n||t!==r){var s=o.push(i(o)+"scale(",null,",",null,")");a.push({i:s-4,x:lr(e,n)},{i:s-2,x:lr(t,r)})}else 1===n&&1===r||o.push(i(o)+"scale("+n+","+r+")")}(o.scaleX,o.scaleY,a.scaleX,a.scaleY,s,l),o=a=null,function(e){for(var t,n=-1,r=l.length;++n=0&&t._call.call(null,e),t=t._next;--Pr}function Kr(){Fr=(zr=Ur.now())+qr,Pr=jr=0;try{Zr()}finally{Pr=0,function(){for(var e,t,n=Ir,r=1/0;n;)n._call?(r>n._time&&(r=n._time),e=n,n=n._next):(t=n._next,n._next=null,n=e?e._next=t:Ir=t);Br=e,Qr(r)}(),Fr=0}}function Xr(){var e=Ur.now(),t=e-zr;t>1e3&&(qr-=t,zr=e)}function Qr(e){Pr||(jr&&(jr=clearTimeout(jr)),e-Fr>24?(e<1/0&&(jr=setTimeout(Kr,e-Ur.now()-qr)),Rr&&(Rr=clearInterval(Rr))):(Rr||(zr=Ur.now(),Rr=setInterval(Xr,1e3)),Pr=1,Hr(Kr)))}function $r(e,t,n){var r=new Wr;return t=null==t?0:+t,r.restart((n=>{r.stop(),e(n+t)}),t,n),r}Wr.prototype=Yr.prototype={constructor:Wr,restart:function(e,t,n){if("function"!=typeof e)throw new TypeError("callback is not a function");n=(null==n?Vr():+n)+(null==t?0:+t),this._next||Br===this||(Br?Br._next=this:Ir=this,Br=this),this._call=e,this._time=n,Qr()},stop:function(){this._call&&(this._call=null,this._time=1/0,Qr())}};var Jr=oe("start","end","cancel","interrupt"),ei=[];function ti(e,t,n,r,i,o){var a=e.__transition;if(a){if(n in a)return}else e.__transition={};!function(e,t,n){var r,i=e.__transition;function o(l){var c,u,f,d;if(1!==n.state)return s();for(c in i)if((d=i[c]).name===n.name){if(3===d.state)return $r(o);4===d.state?(d.state=6,d.timer.stop(),d.on.call("interrupt",e,e.__data__,d.index,d.group),delete i[c]):+c0)throw new Error("too late; already scheduled");return n}function ri(e,t){var n=ii(e,t);if(n.state>3)throw new Error("too late; already running");return n}function ii(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function oi(e,t){var n,r,i,o=e.__transition,a=!0;if(o){for(i in t=null==t?null:t+"",o)(n=o[i]).name===t?(r=n.state>2&&n.state<5,n.state=6,n.timer.stop(),n.on.call(r?"interrupt":"cancel",e,e.__data__,n.index,n.group),delete o[i]):a=!1;a&&delete e.__transition}}function ai(e,t){var n,r;return function(){var i=ri(this,e),o=i.tween;if(o!==n)for(var a=0,s=(r=n=o).length;a=0&&(e=e.slice(0,t)),!e||"start"===e}))}(t)?ni:ri;return function(){var a=o(this,e),s=a.on;s!==r&&(i=(r=s).copy()).on(t,n),a.on=i}}var ki=xt.prototype.constructor;function Si(e){return function(){this.style.removeProperty(e)}}function Mi(e,t,n){return function(r){this.style.setProperty(e,t.call(this,r),n)}}function Ci(e,t,n){var r,i;function o(){var o=t.apply(this,arguments);return o!==i&&(r=(i=o)&&Mi(e,o,n)),r}return o._value=t,o}function Ni(e){return function(t){this.textContent=e.call(this,t)}}function Di(e){var t,n;function r(){var r=e.apply(this,arguments);return r!==n&&(t=(n=r)&&Ni(r)),t}return r._value=e,r}var Li=0;function Oi(e,t,n,r){this._groups=e,this._parents=t,this._name=n,this._id=r}function Ii(e){return xt().transition(e)}function Bi(){return++Li}var Pi=xt.prototype;function ji(e){return((e*=2)<=1?e*e:--e*(2-e)+1)/2}function Ri(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}Oi.prototype=Ii.prototype={constructor:Oi,select:function(e){var t=this._name,n=this._id;"function"!=typeof e&&(e=be(e));for(var r=this._groups,i=r.length,o=new Array(i),a=0;a()=>e;function lo(e,{sourceEvent:t,target:n,selection:r,mode:i,dispatch:o}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},selection:{value:r,enumerable:!0,configurable:!0},mode:{value:i,enumerable:!0,configurable:!0},_:{value:o}})}function co(e){e.stopImmediatePropagation()}function uo(e){e.preventDefault(),e.stopImmediatePropagation()}var fo={name:"drag"},ho={name:"space"},po={name:"handle"},mo={name:"center"};const{abs:go,max:bo,min:vo}=Math;function yo(e){return[+e[0],+e[1]]}function _o(e){return[yo(e[0]),yo(e[1])]}var wo={name:"x",handles:["w","e"].map(Co),input:function(e,t){return null==e?null:[[+e[0],t[0][1]],[+e[1],t[1][1]]]},output:function(e){return e&&[e[0][0],e[1][0]]}},xo={name:"y",handles:["n","s"].map(Co),input:function(e,t){return null==e?null:[[t[0][0],+e[0]],[t[1][0],+e[1]]]},output:function(e){return e&&[e[0][1],e[1][1]]}},To={name:"xy",handles:["n","w","e","s","nw","ne","sw","se"].map(Co),input:function(e){return null==e?null:_o(e)},output:function(e){return e}},Ao={overlay:"crosshair",selection:"move",n:"ns-resize",e:"ew-resize",s:"ns-resize",w:"ew-resize",nw:"nwse-resize",ne:"nesw-resize",se:"nwse-resize",sw:"nesw-resize"},Eo={e:"w",w:"e",nw:"ne",ne:"nw",se:"sw",sw:"se"},ko={n:"s",s:"n",nw:"sw",ne:"se",se:"ne",sw:"nw"},So={overlay:1,selection:1,n:null,e:1,s:null,w:-1,nw:-1,ne:1,se:1,sw:-1},Mo={overlay:1,selection:1,n:-1,e:null,s:1,w:null,nw:-1,ne:-1,se:1,sw:1};function Co(e){return{type:e}}function No(e){return!e.ctrlKey&&!e.button}function Do(){var e=this.ownerSVGElement||this;return e.hasAttribute("viewBox")?[[(e=e.viewBox.baseVal).x,e.y],[e.x+e.width,e.y+e.height]]:[[0,0],[e.width.baseVal.value,e.height.baseVal.value]]}function Lo(){return navigator.maxTouchPoints||"ontouchstart"in this}function Oo(e){for(;!e.__brush;)if(!(e=e.parentNode))return;return e.__brush}function Io(e){return e[0][0]===e[1][0]||e[0][1]===e[1][1]}function Bo(e){var t,n=Do,r=No,i=Lo,o=!0,a=oe("start","brush","end"),s=6;function l(t){var n=t.property("__brush",m).selectAll(".overlay").data([Co("overlay")]);n.enter().append("rect").attr("class","overlay").attr("pointer-events","all").attr("cursor",Ao.overlay).merge(n).each((function(){var e=Oo(this).extent;Tt(this).attr("x",e[0][0]).attr("y",e[0][1]).attr("width",e[1][0]-e[0][0]).attr("height",e[1][1]-e[0][1])})),t.selectAll(".selection").data([Co("selection")]).enter().append("rect").attr("class","selection").attr("cursor",Ao.selection).attr("fill","#777").attr("fill-opacity",.3).attr("stroke","#fff").attr("shape-rendering","crispEdges");var r=t.selectAll(".handle").data(e.handles,(function(e){return e.type}));r.exit().remove(),r.enter().append("rect").attr("class",(function(e){return"handle handle--"+e.type})).attr("cursor",(function(e){return Ao[e.type]})),t.each(c).attr("fill","none").attr("pointer-events","all").on("mousedown.brush",d).filter(i).on("touchstart.brush",d).on("touchmove.brush",h).on("touchend.brush touchcancel.brush",p).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function c(){var e=Tt(this),t=Oo(this).selection;t?(e.selectAll(".selection").style("display",null).attr("x",t[0][0]).attr("y",t[0][1]).attr("width",t[1][0]-t[0][0]).attr("height",t[1][1]-t[0][1]),e.selectAll(".handle").style("display",null).attr("x",(function(e){return"e"===e.type[e.type.length-1]?t[1][0]-s/2:t[0][0]-s/2})).attr("y",(function(e){return"s"===e.type[0]?t[1][1]-s/2:t[0][1]-s/2})).attr("width",(function(e){return"n"===e.type||"s"===e.type?t[1][0]-t[0][0]+s:s})).attr("height",(function(e){return"e"===e.type||"w"===e.type?t[1][1]-t[0][1]+s:s}))):e.selectAll(".selection,.handle").style("display","none").attr("x",null).attr("y",null).attr("width",null).attr("height",null)}function u(e,t,n){var r=e.__brush.emitter;return!r||n&&r.clean?new f(e,t,n):r}function f(e,t,n){this.that=e,this.args=t,this.state=e.__brush,this.active=0,this.clean=n}function d(n){if((!t||n.touches)&&r.apply(this,arguments)){var i,a,s,l,f,d,h,p,m,g,b,v=this,y=n.target.__data__.type,_="selection"===(o&&n.metaKey?y="overlay":y)?fo:o&&n.altKey?mo:po,w=e===xo?null:So[y],x=e===wo?null:Mo[y],T=Oo(v),A=T.extent,E=T.selection,k=A[0][0],S=A[0][1],M=A[1][0],C=A[1][1],N=0,D=0,L=w&&x&&o&&n.shiftKey,O=Array.from(n.touches||[n],(e=>{const t=e.identifier;return(e=Mt(e,v)).point0=e.slice(),e.identifier=t,e}));if("overlay"===y){E&&(m=!0);const t=[O[0],O[1]||O[0]];T.selection=E=[[i=e===xo?k:vo(t[0][0],t[1][0]),s=e===wo?S:vo(t[0][1],t[1][1])],[f=e===xo?M:bo(t[0][0],t[1][0]),h=e===wo?C:bo(t[0][1],t[1][1])]],O.length>1&&z()}else i=E[0][0],s=E[0][1],f=E[1][0],h=E[1][1];a=i,l=s,d=f,p=h;var I=Tt(v).attr("pointer-events","none"),B=I.selectAll(".overlay").attr("cursor",Ao[y]);oi(v);var P=u(v,arguments,!0).beforestart();if(n.touches)P.moved=R,P.ended=F;else{var j=Tt(n.view).on("mousemove.brush",R,!0).on("mouseup.brush",F,!0);o&&j.on("keydown.brush",q,!0).on("keyup.brush",U,!0),Dt(n.view)}c.call(v),P.start(n,_.name)}function R(e){for(const t of e.changedTouches||[e])for(const e of O)e.identifier===t.identifier&&(e.cur=Mt(t,v));if(L&&!g&&!b&&1===O.length){const e=O[0];go(e.cur[0]-e[0])>go(e.cur[1]-e[1])?b=!0:g=!0}for(const e of O)e.cur&&(e[0]=e.cur[0],e[1]=e.cur[1]);m=!0,uo(e),z(e)}function z(e){const t=O[0],n=t.point0;var r;switch(N=t[0]-n[0],D=t[1]-n[1],_){case ho:case fo:w&&(N=bo(k-i,vo(M-f,N)),a=i+N,d=f+N),x&&(D=bo(S-s,vo(C-h,D)),l=s+D,p=h+D);break;case po:O[1]?(w&&(a=bo(k,vo(M,O[0][0])),d=bo(k,vo(M,O[1][0])),w=1),x&&(l=bo(S,vo(C,O[0][1])),p=bo(S,vo(C,O[1][1])),x=1)):(w<0?(N=bo(k-i,vo(M-i,N)),a=i+N,d=f):w>0&&(N=bo(k-f,vo(M-f,N)),a=i,d=f+N),x<0?(D=bo(S-s,vo(C-s,D)),l=s+D,p=h):x>0&&(D=bo(S-h,vo(C-h,D)),l=s,p=h+D));break;case mo:w&&(a=bo(k,vo(M,i-N*w)),d=bo(k,vo(M,f+N*w))),x&&(l=bo(S,vo(C,s-D*x)),p=bo(S,vo(C,h+D*x)))}d0&&(i=a-N),x<0?h=p-D:x>0&&(s=l-D),_=ho,B.attr("cursor",Ao.selection),z());break;default:return}uo(e)}function U(e){switch(e.keyCode){case 16:L&&(g=b=L=!1,z());break;case 18:_===mo&&(w<0?f=d:w>0&&(i=a),x<0?h=p:x>0&&(s=l),_=po,z());break;case 32:_===ho&&(e.altKey?(w&&(f=d-N*w,i=a+N*w),x&&(h=p-D*x,s=l+D*x),_=mo):(w<0?f=d:w>0&&(i=a),x<0?h=p:x>0&&(s=l),_=po),B.attr("cursor",Ao[y]),z());break;default:return}uo(e)}}function h(e){u(this,arguments).moved(e)}function p(e){u(this,arguments).ended(e)}function m(){var t=this.__brush||{selection:null};return t.extent=_o(n.apply(this,arguments)),t.dim=e,t}return l.move=function(t,n){t.tween?t.on("start.brush",(function(e){u(this,arguments).beforestart().start(e)})).on("interrupt.brush end.brush",(function(e){u(this,arguments).end(e)})).tween("brush",(function(){var t=this,r=t.__brush,i=u(t,arguments),o=r.selection,a=e.input("function"==typeof n?n.apply(this,arguments):n,r.extent),s=hr(o,a);function l(e){r.selection=1===e&&null===a?null:s(e),c.call(t),i.brush()}return null!==o&&null!==a?l:l(1)})):t.each((function(){var t=this,r=arguments,i=t.__brush,o=e.input("function"==typeof n?n.apply(t,r):n,i.extent),a=u(t,r).beforestart();oi(t),i.selection=null===o?null:o,c.call(t),a.start().brush().end()}))},l.clear=function(e){l.move(e,null)},f.prototype={beforestart:function(){return 1==++this.active&&(this.state.emitter=this,this.starting=!0),this},start:function(e,t){return this.starting?(this.starting=!1,this.emit("start",e,t)):this.emit("brush",e),this},brush:function(e,t){return this.emit("brush",e,t),this},end:function(e,t){return 0==--this.active&&(delete this.state.emitter,this.emit("end",e,t)),this},emit:function(t,n,r){var i=Tt(this.that).datum();a.call(t,this.that,new lo(t,{sourceEvent:n,target:l,selection:e.output(this.state.selection),mode:r,dispatch:a}),i)}},l.extent=function(e){return arguments.length?(n="function"==typeof e?e:so(_o(e)),l):n},l.filter=function(e){return arguments.length?(r="function"==typeof e?e:so(!!e),l):r},l.touchable=function(e){return arguments.length?(i="function"==typeof e?e:so(!!e),l):i},l.handleSize=function(e){return arguments.length?(s=+e,l):s},l.keyModifiers=function(e){return arguments.length?(o=!!e,l):o},l.on=function(){var e=a.on.apply(a,arguments);return e===a?l:e},l}var Po=Math.abs,jo=Math.cos,Ro=Math.sin,zo=Math.PI,Fo=zo/2,qo=2*zo,Uo=Math.max,Ho=1e-12;function Vo(e,t){return Array.from({length:t-e},((t,n)=>e+n))}function Go(e){return function(t,n){return e(t.source.value+t.target.value,n.source.value+n.target.value)}}function Wo(e,t){var n=0,r=null,i=null,o=null;function a(a){var s,l=a.length,c=new Array(l),u=Vo(0,l),f=new Array(l*l),d=new Array(l),h=0;a=Float64Array.from({length:l*l},t?(e,t)=>a[t%l][t/l|0]:(e,t)=>a[t/l|0][t%l]);for(let t=0;tr(c[e],c[t])));for(const n of u){const r=t;if(e){const e=Vo(1+~l,l).filter((e=>e<0?a[~e*l+n]:a[n*l+e]));i&&e.sort(((e,t)=>i(e<0?-a[~e*l+n]:a[n*l+e],t<0?-a[~t*l+n]:a[n*l+t])));for(const r of e)r<0?(f[~r*l+n]||(f[~r*l+n]={source:null,target:null})).target={index:n,startAngle:t,endAngle:t+=a[~r*l+n]*h,value:a[~r*l+n]}:(f[n*l+r]||(f[n*l+r]={source:null,target:null})).source={index:n,startAngle:t,endAngle:t+=a[n*l+r]*h,value:a[n*l+r]};d[n]={index:n,startAngle:r,endAngle:t,value:c[n]}}else{const e=Vo(0,l).filter((e=>a[n*l+e]||a[e*l+n]));i&&e.sort(((e,t)=>i(a[n*l+e],a[n*l+t])));for(const r of e){let e;if(nKo)if(Math.abs(u*s-l*c)>Ko&&i){var d=n-o,h=r-a,p=s*s+l*l,m=d*d+h*h,g=Math.sqrt(p),b=Math.sqrt(f),v=i*Math.tan((Yo-Math.acos((p+f-m)/(2*g*b)))/2),y=v/b,_=v/g;Math.abs(y-1)>Ko&&(this._+="L"+(e+y*c)+","+(t+y*u)),this._+="A"+i+","+i+",0,0,"+ +(u*d>c*h)+","+(this._x1=e+_*s)+","+(this._y1=t+_*l)}else this._+="L"+(this._x1=e)+","+(this._y1=t)},arc:function(e,t,n,r,i,o){e=+e,t=+t,o=!!o;var a=(n=+n)*Math.cos(r),s=n*Math.sin(r),l=e+a,c=t+s,u=1^o,f=o?r-i:i-r;if(n<0)throw new Error("negative radius: "+n);null===this._x1?this._+="M"+l+","+c:(Math.abs(this._x1-l)>Ko||Math.abs(this._y1-c)>Ko)&&(this._+="L"+l+","+c),n&&(f<0&&(f=f%Zo+Zo),f>Xo?this._+="A"+n+","+n+",0,1,"+u+","+(e-a)+","+(t-s)+"A"+n+","+n+",0,1,"+u+","+(this._x1=l)+","+(this._y1=c):f>Ko&&(this._+="A"+n+","+n+",0,"+ +(f>=Yo)+","+u+","+(this._x1=e+n*Math.cos(i))+","+(this._y1=t+n*Math.sin(i))))},rect:function(e,t,n,r){this._+="M"+(this._x0=this._x1=+e)+","+(this._y0=this._y1=+t)+"h"+ +n+"v"+ +r+"h"+-n+"Z"},toString:function(){return this._}};var Jo=Array.prototype.slice;function ea(e){return function(){return e}}function ta(e){return e.source}function na(e){return e.target}function ra(e){return e.radius}function ia(e){return e.startAngle}function oa(e){return e.endAngle}function aa(){return 0}function sa(){return 10}function la(e){var t=ta,n=na,r=ra,i=ra,o=ia,a=oa,s=aa,l=null;function c(){var c,u=t.apply(this,arguments),f=n.apply(this,arguments),d=s.apply(this,arguments)/2,h=Jo.call(arguments),p=+r.apply(this,(h[0]=u,h)),m=o.apply(this,h)-Fo,g=a.apply(this,h)-Fo,b=+i.apply(this,(h[0]=f,h)),v=o.apply(this,h)-Fo,y=a.apply(this,h)-Fo;if(l||(l=c=$o()),d>Ho&&(Po(g-m)>2*d+Ho?g>m?(m+=d,g-=d):(m-=d,g+=d):m=g=(m+g)/2,Po(y-v)>2*d+Ho?y>v?(v+=d,y-=d):(v-=d,y+=d):v=y=(v+y)/2),l.moveTo(p*jo(m),p*Ro(m)),l.arc(0,0,p,m,g),m!==v||g!==y)if(e){var _=+e.apply(this,arguments),w=b-_,x=(v+y)/2;l.quadraticCurveTo(0,0,w*jo(v),w*Ro(v)),l.lineTo(b*jo(x),b*Ro(x)),l.lineTo(w*jo(y),w*Ro(y))}else l.quadraticCurveTo(0,0,b*jo(v),b*Ro(v)),l.arc(0,0,b,v,y);if(l.quadraticCurveTo(0,0,p*jo(m),p*Ro(m)),l.closePath(),c)return l=null,c+""||null}return e&&(c.headRadius=function(t){return arguments.length?(e="function"==typeof t?t:ea(+t),c):e}),c.radius=function(e){return arguments.length?(r=i="function"==typeof e?e:ea(+e),c):r},c.sourceRadius=function(e){return arguments.length?(r="function"==typeof e?e:ea(+e),c):r},c.targetRadius=function(e){return arguments.length?(i="function"==typeof e?e:ea(+e),c):i},c.startAngle=function(e){return arguments.length?(o="function"==typeof e?e:ea(+e),c):o},c.endAngle=function(e){return arguments.length?(a="function"==typeof e?e:ea(+e),c):a},c.padAngle=function(e){return arguments.length?(s="function"==typeof e?e:ea(+e),c):s},c.source=function(e){return arguments.length?(t=e,c):t},c.target=function(e){return arguments.length?(n=e,c):n},c.context=function(e){return arguments.length?(l=null==e?null:e,c):l},c}var ca=Array.prototype.slice;function ua(e,t){return e-t}var fa=e=>()=>e;function da(e,t){for(var n,r=-1,i=t.length;++rr!=h>r&&n<(d-c)*(r-u)/(h-u)+c&&(i=-i)}return i}function pa(e,t,n){var r,i,o,a;return function(e,t,n){return(t[0]-e[0])*(n[1]-e[1])==(n[0]-e[0])*(t[1]-e[1])}(e,t,n)&&(i=e[r=+(e[0]===t[0])],o=n[r],a=t[r],i<=o&&o<=a||a<=o&&o<=i)}function ma(){}var ga=[[],[[[1,1.5],[.5,1]]],[[[1.5,1],[1,1.5]]],[[[1.5,1],[.5,1]]],[[[1,.5],[1.5,1]]],[[[1,1.5],[.5,1]],[[1,.5],[1.5,1]]],[[[1,.5],[1,1.5]]],[[[1,.5],[.5,1]]],[[[.5,1],[1,.5]]],[[[1,1.5],[1,.5]]],[[[.5,1],[1,.5]],[[1.5,1],[1,1.5]]],[[[1.5,1],[1,.5]]],[[[.5,1],[1.5,1]]],[[[1,1.5],[1.5,1]]],[[[.5,1],[1,1.5]]],[]];function ba(){var e=1,t=1,n=M,r=s;function i(e){var t=n(e);if(Array.isArray(t))t=t.slice().sort(ua);else{var r=p(e),i=r[0],a=r[1];t=k(i,a,t),t=q(Math.floor(i/t)*t,Math.floor(a/t)*t,t)}return t.map((function(t){return o(e,t)}))}function o(n,i){var o=[],s=[];return function(n,r,i){var o,s,l,c,u,f,d=new Array,h=new Array;for(o=s=-1,c=n[0]>=r,ga[c<<1].forEach(p);++o=r,ga[l|c<<1].forEach(p);for(ga[c<<0].forEach(p);++s=r,u=n[s*e]>=r,ga[c<<1|u<<2].forEach(p);++o=r,f=u,u=n[s*e+o+1]>=r,ga[l|c<<1|u<<2|f<<3].forEach(p);ga[c|u<<3].forEach(p)}for(o=-1,u=n[s*e]>=r,ga[u<<2].forEach(p);++o=r,ga[u<<2|f<<3].forEach(p);function p(e){var t,n,r=[e[0][0]+o,e[0][1]+s],l=[e[1][0]+o,e[1][1]+s],c=a(r),u=a(l);(t=h[c])?(n=d[u])?(delete h[t.end],delete d[n.start],t===n?(t.ring.push(l),i(t.ring)):d[t.start]=h[n.end]={start:t.start,end:n.end,ring:t.ring.concat(n.ring)}):(delete h[t.end],t.ring.push(l),h[t.end=u]=t):(t=d[u])?(n=h[c])?(delete d[t.start],delete h[n.end],t===n?(t.ring.push(l),i(t.ring)):d[n.start]=h[t.end]={start:n.start,end:t.end,ring:n.ring.concat(t.ring)}):(delete d[t.start],t.ring.unshift(r),d[t.start=c]=t):d[c]=h[u]={start:c,end:u,ring:[r,l]}}ga[u<<3].forEach(p)}(n,i,(function(e){r(e,n,i),function(e){for(var t=0,n=e.length,r=e[n-1][1]*e[0][0]-e[n-1][0]*e[0][1];++t0?o.push([e]):s.push(e)})),s.forEach((function(e){for(var t,n=0,r=o.length;n0&&a0&&s=0&&o>=0))throw new Error("invalid size");return e=r,t=o,i},i.thresholds=function(e){return arguments.length?(n="function"==typeof e?e:Array.isArray(e)?fa(ca.call(e)):fa(e),i):n},i.smooth=function(e){return arguments.length?(r=e?s:ma,i):r===s},i}function va(e,t,n){for(var r=e.width,i=e.height,o=1+(n<<1),a=0;a=n&&(s>=o&&(l-=e.data[s-o+a*r]),t.data[s-n+a*r]=l/Math.min(s+1,r-1+o-s,o))}function ya(e,t,n){for(var r=e.width,i=e.height,o=1+(n<<1),a=0;a=n&&(s>=o&&(l-=e.data[a+(s-o)*r]),t.data[a+(s-n)*r]=l/Math.min(s+1,i-1+o-s,o))}function _a(e){return e[0]}function wa(e){return e[1]}function xa(){return 1}const Ta=Math.pow(2,-52),Aa=new Uint32Array(512);class Ea{static from(e,t=Oa,n=Ia){const r=e.length,i=new Float64Array(2*r);for(let o=0;o>1;if(t>0&&"number"!=typeof e[0])throw new Error("Expected coords to contain numbers.");this.coords=e;const n=Math.max(2*t-5,0);this._triangles=new Uint32Array(3*n),this._halfedges=new Int32Array(3*n),this._hashSize=Math.ceil(Math.sqrt(t)),this._hullPrev=new Uint32Array(t),this._hullNext=new Uint32Array(t),this._hullTri=new Uint32Array(t),this._hullHash=new Int32Array(this._hashSize).fill(-1),this._ids=new Uint32Array(t),this._dists=new Float64Array(t),this.update()}update(){const{coords:e,_hullPrev:t,_hullNext:n,_hullTri:r,_hullHash:i}=this,o=e.length>>1;let a=1/0,s=1/0,l=-1/0,c=-1/0;for(let t=0;tl&&(l=n),r>c&&(c=r),this._ids[t]=t}const u=(a+l)/2,f=(s+c)/2;let d,h,p,m=1/0;for(let t=0;t0&&(h=t,m=n)}let v=e[2*h],y=e[2*h+1],_=1/0;for(let t=0;tr&&(t[n++]=i,r=this._dists[i])}return this.hull=t.subarray(0,n),this.triangles=new Uint32Array(0),void(this.halfedges=new Uint32Array(0))}if(Ma(g,b,v,y,w,x)){const e=h,t=v,n=y;h=p,v=w,y=x,p=e,w=t,x=n}const T=function(e,t,n,r,i,o){const a=n-e,s=r-t,l=i-e,c=o-t,u=a*a+s*s,f=l*l+c*c,d=.5/(a*c-s*l);return{x:e+(c*u-s*f)*d,y:t+(a*f-l*u)*d}}(g,b,v,y,w,x);this._cx=T.x,this._cy=T.y;for(let t=0;t0&&Math.abs(c-o)<=Ta&&Math.abs(u-a)<=Ta)continue;if(o=c,a=u,l===d||l===h||l===p)continue;let f=0;for(let e=0,t=this._hashKey(c,u);e0?3-n:1+n)/4}(e-this._cx,t-this._cy)*this._hashSize)%this._hashSize}_legalize(e){const{_triangles:t,_halfedges:n,coords:r}=this;let i=0,o=0;for(;;){const a=n[e],s=e-e%3;if(o=s+(e+2)%3,-1===a){if(0===i)break;e=Aa[--i];continue}const l=a-a%3,c=s+(e+1)%3,u=l+(a+2)%3,f=t[o],d=t[e],h=t[c],p=t[u];if(Ca(r[2*f],r[2*f+1],r[2*d],r[2*d+1],r[2*h],r[2*h+1],r[2*p],r[2*p+1])){t[e]=p,t[a]=f;const r=n[u];if(-1===r){let t=this._hullStart;do{if(this._hullTri[t]===u){this._hullTri[t]=e;break}t=this._hullPrev[t]}while(t!==this._hullStart)}this._link(e,r),this._link(a,n[o]),this._link(o,u);const s=l+(a+1)%3;i=33306690738754716e-32*Math.abs(a+s)?a-s:0}function Ma(e,t,n,r,i,o){return(Sa(i,o,e,t,n,r)||Sa(e,t,n,r,i,o)||Sa(n,r,i,o,e,t))<0}function Ca(e,t,n,r,i,o,a,s){const l=e-a,c=t-s,u=n-a,f=r-s,d=i-a,h=o-s,p=u*u+f*f,m=d*d+h*h;return l*(f*m-p*h)-c*(u*m-p*d)+(l*l+c*c)*(u*h-f*d)<0}function Na(e,t,n,r,i,o){const a=n-e,s=r-t,l=i-e,c=o-t,u=a*a+s*s,f=l*l+c*c,d=.5/(a*c-s*l),h=(c*u-s*f)*d,p=(a*f-l*u)*d;return h*h+p*p}function Da(e,t,n,r){if(r-n<=20)for(let i=n+1;i<=r;i++){const r=e[i],o=t[r];let a=i-1;for(;a>=n&&t[e[a]]>o;)e[a+1]=e[a--];e[a+1]=r}else{let i=n+1,o=r;La(e,n+r>>1,i),t[e[n]]>t[e[r]]&&La(e,n,r),t[e[i]]>t[e[r]]&&La(e,i,r),t[e[n]]>t[e[i]]&&La(e,n,i);const a=e[i],s=t[a];for(;;){do{i++}while(t[e[i]]s);if(o=o-n?(Da(e,t,i,r),Da(e,t,n,o-1)):(Da(e,t,n,o-1),Da(e,t,i,r))}}function La(e,t,n){const r=e[t];e[t]=e[n],e[n]=r}function Oa(e){return e[0]}function Ia(e){return e[1]}const Ba=1e-6;class Pa{constructor(){this._x0=this._y0=this._x1=this._y1=null,this._=""}moveTo(e,t){this._+=`M${this._x0=this._x1=+e},${this._y0=this._y1=+t}`}closePath(){null!==this._x1&&(this._x1=this._x0,this._y1=this._y0,this._+="Z")}lineTo(e,t){this._+=`L${this._x1=+e},${this._y1=+t}`}arc(e,t,n){const r=(e=+e)+(n=+n),i=t=+t;if(n<0)throw new Error("negative radius");null===this._x1?this._+=`M${r},${i}`:(Math.abs(this._x1-r)>Ba||Math.abs(this._y1-i)>Ba)&&(this._+="L"+r+","+i),n&&(this._+=`A${n},${n},0,1,1,${e-n},${t}A${n},${n},0,1,1,${this._x1=r},${this._y1=i}`)}rect(e,t,n,r){this._+=`M${this._x0=this._x1=+e},${this._y0=this._y1=+t}h${+n}v${+r}h${-n}Z`}value(){return this._||null}}class ja{constructor(){this._=[]}moveTo(e,t){this._.push([e,t])}closePath(){this._.push(this._[0].slice())}lineTo(e,t){this._.push([e,t])}value(){return this._.length?this._:null}}class Ra{constructor(e,[t,n,r,i]=[0,0,960,500]){if(!((r=+r)>=(t=+t)&&(i=+i)>=(n=+n)))throw new Error("invalid bounds");this.delaunay=e,this._circumcenters=new Float64Array(2*e.points.length),this.vectors=new Float64Array(2*e.points.length),this.xmax=r,this.xmin=t,this.ymax=i,this.ymin=n,this._init()}update(){return this.delaunay.update(),this._init(),this}_init(){const{delaunay:{points:e,hull:t,triangles:n},vectors:r}=this,i=this.circumcenters=this._circumcenters.subarray(0,n.length/3*2);for(let t,r,o=0,a=0,s=n.length;o1;)i-=2;for(let e=2;e4)for(let e=0;e0){if(t>=this.ymax)return null;(i=(this.ymax-t)/r)0){if(e>=this.xmax)return null;(i=(this.xmax-e)/n)this.xmax?2:0)|(tthis.ymax?8:0)}}const za=2*Math.PI,Fa=Math.pow;function qa(e){return e[0]}function Ua(e){return e[1]}function Ha(e,t,n){return[e+Math.sin(e+t)*n,t+Math.cos(e-t)*n]}class Va{static from(e,t=qa,n=Ua,r){return new Va("length"in e?function(e,t,n,r){const i=e.length,o=new Float64Array(2*i);for(let a=0;a2&&function(e){const{triangles:t,coords:n}=e;for(let e=0;e1e-10)return!1}return!0}(e)){this.collinear=Int32Array.from({length:t.length/2},((e,t)=>t)).sort(((e,n)=>t[2*e]-t[2*n]||t[2*e+1]-t[2*n+1]));const e=this.collinear[0],n=this.collinear[this.collinear.length-1],r=[t[2*e],t[2*e+1],t[2*n],t[2*n+1]],i=1e-8*Math.hypot(r[3]-r[1],r[2]-r[0]);for(let e=0,n=t.length/2;e0&&(this.triangles=new Int32Array(3).fill(-1),this.halfedges=new Int32Array(3).fill(-1),this.triangles[0]=r[0],this.triangles[1]=r[1],this.triangles[2]=r[1],o[r[0]]=1,2===r.length&&(o[r[1]]=0))}voronoi(e){return new Ra(this,e)}*neighbors(e){const{inedges:t,hull:n,_hullIndex:r,halfedges:i,triangles:o,collinear:a}=this;if(a){const t=a.indexOf(e);return t>0&&(yield a[t-1]),void(t=0&&i!==n&&i!==r;)n=i;return i}_step(e,t,n){const{inedges:r,hull:i,_hullIndex:o,halfedges:a,triangles:s,points:l}=this;if(-1===r[e]||!l.length)return(e+1)%(l.length>>1);let c=e,u=Fa(t-l[2*e],2)+Fa(n-l[2*e+1],2);const f=r[e];let d=f;do{let r=s[d];const f=Fa(t-l[2*r],2)+Fa(n-l[2*r+1],2);if(f=o?l=!0:10===(r=e.charCodeAt(a++))?c=!0:13===r&&(c=!0,10===e.charCodeAt(a)&&++a),e.slice(i+1,t-1).replace(/""/g,'"')}for(;a9999?"+"+Ka(e,6):Ka(e,4)}(e.getUTCFullYear())+"-"+Ka(e.getUTCMonth()+1,2)+"-"+Ka(e.getUTCDate(),2)+(i?"T"+Ka(t,2)+":"+Ka(n,2)+":"+Ka(r,2)+"."+Ka(i,3)+"Z":r?"T"+Ka(t,2)+":"+Ka(n,2)+":"+Ka(r,2)+"Z":n||t?"T"+Ka(t,2)+":"+Ka(n,2)+"Z":"")}(e):t.test(e+="")?'"'+e.replace(/"/g,'""')+'"':e}return{parse:function(e,t){var n,i,o=r(e,(function(e,r){if(n)return n(e,r-1);i=e,n=t?function(e,t){var n=Ya(e);return function(r,i){return t(n(r),i,e)}}(e,t):Ya(e)}));return o.columns=i||[],o},parseRows:r,format:function(t,n){return null==n&&(n=Za(t)),[n.map(a).join(e)].concat(i(t,n)).join("\n")},formatBody:function(e,t){return null==t&&(t=Za(e)),i(e,t).join("\n")},formatRows:function(e){return e.map(o).join("\n")},formatRow:o,formatValue:a}}var Qa=Xa(","),$a=Qa.parse,Ja=Qa.parseRows,es=Qa.format,ts=Qa.formatBody,ns=Qa.formatRows,rs=Qa.formatRow,is=Qa.formatValue,os=Xa("\t"),as=os.parse,ss=os.parseRows,ls=os.format,cs=os.formatBody,us=os.formatRows,fs=os.formatRow,ds=os.formatValue;const hs=new Date("2019-01-01T00:00").getHours()||new Date("2019-07-01T00:00").getHours();function ps(e){if(!e.ok)throw new Error(e.status+" "+e.statusText);return e.blob()}function ms(e){if(!e.ok)throw new Error(e.status+" "+e.statusText);return e.arrayBuffer()}function gs(e){if(!e.ok)throw new Error(e.status+" "+e.statusText);return e.text()}function bs(e,t){return fetch(e,t).then(gs)}function vs(e){return function(t,n,r){return 2===arguments.length&&"function"==typeof n&&(r=n,n=void 0),bs(t,n).then((function(t){return e(t,r)}))}}var ys=vs($a),_s=vs(as);function ws(e){if(!e.ok)throw new Error(e.status+" "+e.statusText);if(204!==e.status&&205!==e.status)return e.json()}function xs(e){return(t,n)=>bs(t,n).then((t=>(new DOMParser).parseFromString(t,e)))}var Ts=xs("application/xml"),As=xs("text/html"),Es=xs("image/svg+xml");function ks(e,t,n,r){if(isNaN(t)||isNaN(n))return e;var i,o,a,s,l,c,u,f,d,h=e._root,p={data:r},m=e._x0,g=e._y0,b=e._x1,v=e._y1;if(!h)return e._root=p,e;for(;h.length;)if((c=t>=(o=(m+b)/2))?m=o:b=o,(u=n>=(a=(g+v)/2))?g=a:v=a,i=h,!(h=h[f=u<<1|c]))return i[f]=p,e;if(s=+e._x.call(null,h.data),l=+e._y.call(null,h.data),t===s&&n===l)return p.next=h,i?i[f]=p:e._root=p,e;do{i=i?i[f]=new Array(4):e._root=new Array(4),(c=t>=(o=(m+b)/2))?m=o:b=o,(u=n>=(a=(g+v)/2))?g=a:v=a}while((f=u<<1|c)==(d=(l>=a)<<1|s>=o));return i[d]=h,i[f]=p,e}function Ss(e,t,n,r,i){this.node=e,this.x0=t,this.y0=n,this.x1=r,this.y1=i}function Ms(e){return e[0]}function Cs(e){return e[1]}function Ns(e,t,n){var r=new Ds(null==t?Ms:t,null==n?Cs:n,NaN,NaN,NaN,NaN);return null==e?r:r.addAll(e)}function Ds(e,t,n,r,i,o){this._x=e,this._y=t,this._x0=n,this._y0=r,this._x1=i,this._y1=o,this._root=void 0}function Ls(e){for(var t={data:e.data},n=t;e=e.next;)n=n.next={data:e.data};return t}var Os=Ns.prototype=Ds.prototype;function Is(e){return function(){return e}}function Bs(e){return 1e-6*(e()-.5)}function Ps(e){return e.x+e.vx}function js(e){return e.y+e.vy}function Rs(e){return e.index}function zs(e,t){var n=e.get(t);if(!n)throw new Error("node not found: "+t);return n}Os.copy=function(){var e,t,n=new Ds(this._x,this._y,this._x0,this._y0,this._x1,this._y1),r=this._root;if(!r)return n;if(!r.length)return n._root=Ls(r),n;for(e=[{source:r,target:n._root=new Array(4)}];r=e.pop();)for(var i=0;i<4;++i)(t=r.source[i])&&(t.length?e.push({source:t,target:r.target[i]=new Array(4)}):r.target[i]=Ls(t));return n},Os.add=function(e){const t=+this._x.call(null,e),n=+this._y.call(null,e);return ks(this.cover(t,n),t,n,e)},Os.addAll=function(e){var t,n,r,i,o=e.length,a=new Array(o),s=new Array(o),l=1/0,c=1/0,u=-1/0,f=-1/0;for(n=0;nu&&(u=r),if&&(f=i));if(l>u||c>f)return this;for(this.cover(l,c).cover(u,f),n=0;ne||e>=i||r>t||t>=o;)switch(s=(td||(o=l.y0)>h||(a=l.x1)=b)<<1|e>=g)&&(l=p[p.length-1],p[p.length-1]=p[p.length-1-c],p[p.length-1-c]=l)}else{var v=e-+this._x.call(null,m.data),y=t-+this._y.call(null,m.data),_=v*v+y*y;if(_=(s=(p+g)/2))?p=s:g=s,(u=a>=(l=(m+b)/2))?m=l:b=l,t=h,!(h=h[f=u<<1|c]))return this;if(!h.length)break;(t[f+1&3]||t[f+2&3]||t[f+3&3])&&(n=t,d=f)}for(;h.data!==e;)if(r=h,!(h=h.next))return this;return(i=h.next)&&delete h.next,r?(i?r.next=i:delete r.next,this):t?(i?t[f]=i:delete t[f],(h=t[0]||t[1]||t[2]||t[3])&&h===(t[3]||t[2]||t[1]||t[0])&&!h.length&&(n?n[d]=h:this._root=h),this):(this._root=i,this)},Os.removeAll=function(e){for(var t=0,n=e.length;t1?r[0]+r.slice(2):r,+e.slice(n+1)]}function Gs(e){return(e=Vs(Math.abs(e)))?e[1]:NaN}var Ws,Ys=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function Zs(e){if(!(t=Ys.exec(e)))throw new Error("invalid format: "+e);var t;return new Ks({fill:t[1],align:t[2],sign:t[3],symbol:t[4],zero:t[5],width:t[6],comma:t[7],precision:t[8]&&t[8].slice(1),trim:t[9],type:t[10]})}function Ks(e){this.fill=void 0===e.fill?" ":e.fill+"",this.align=void 0===e.align?">":e.align+"",this.sign=void 0===e.sign?"-":e.sign+"",this.symbol=void 0===e.symbol?"":e.symbol+"",this.zero=!!e.zero,this.width=void 0===e.width?void 0:+e.width,this.comma=!!e.comma,this.precision=void 0===e.precision?void 0:+e.precision,this.trim=!!e.trim,this.type=void 0===e.type?"":e.type+""}function Xs(e,t){var n=Vs(e,t);if(!n)return e+"";var r=n[0],i=n[1];return i<0?"0."+new Array(-i).join("0")+r:r.length>i+1?r.slice(0,i+1)+"."+r.slice(i+1):r+new Array(i-r.length+2).join("0")}Zs.prototype=Ks.prototype,Ks.prototype.toString=function(){return this.fill+this.align+this.sign+this.symbol+(this.zero?"0":"")+(void 0===this.width?"":Math.max(1,0|this.width))+(this.comma?",":"")+(void 0===this.precision?"":"."+Math.max(0,0|this.precision))+(this.trim?"~":"")+this.type};var Qs={"%":(e,t)=>(100*e).toFixed(t),b:e=>Math.round(e).toString(2),c:e=>e+"",d:function(e){return Math.abs(e=Math.round(e))>=1e21?e.toLocaleString("en").replace(/,/g,""):e.toString(10)},e:(e,t)=>e.toExponential(t),f:(e,t)=>e.toFixed(t),g:(e,t)=>e.toPrecision(t),o:e=>Math.round(e).toString(8),p:(e,t)=>Xs(100*e,t),r:Xs,s:function(e,t){var n=Vs(e,t);if(!n)return e+"";var r=n[0],i=n[1],o=i-(Ws=3*Math.max(-8,Math.min(8,Math.floor(i/3))))+1,a=r.length;return o===a?r:o>a?r+new Array(o-a+1).join("0"):o>0?r.slice(0,o)+"."+r.slice(o):"0."+new Array(1-o).join("0")+Vs(e,Math.max(0,t+o-1))[0]},X:e=>Math.round(e).toString(16).toUpperCase(),x:e=>Math.round(e).toString(16)};function $s(e){return e}var Js,el=Array.prototype.map,tl=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function nl(e){var t,n,r=void 0===e.grouping||void 0===e.thousands?$s:(t=el.call(e.grouping,Number),n=e.thousands+"",function(e,r){for(var i=e.length,o=[],a=0,s=t[0],l=0;i>0&&s>0&&(l+s+1>r&&(s=Math.max(1,r-l)),o.push(e.substring(i-=s,i+s)),!((l+=s+1)>r));)s=t[a=(a+1)%t.length];return o.reverse().join(n)}),i=void 0===e.currency?"":e.currency[0]+"",o=void 0===e.currency?"":e.currency[1]+"",a=void 0===e.decimal?".":e.decimal+"",s=void 0===e.numerals?$s:function(e){return function(t){return t.replace(/[0-9]/g,(function(t){return e[+t]}))}}(el.call(e.numerals,String)),l=void 0===e.percent?"%":e.percent+"",c=void 0===e.minus?"−":e.minus+"",u=void 0===e.nan?"NaN":e.nan+"";function f(e){var t=(e=Zs(e)).fill,n=e.align,f=e.sign,d=e.symbol,h=e.zero,p=e.width,m=e.comma,g=e.precision,b=e.trim,v=e.type;"n"===v?(m=!0,v="g"):Qs[v]||(void 0===g&&(g=12),b=!0,v="g"),(h||"0"===t&&"="===n)&&(h=!0,t="0",n="=");var y="$"===d?i:"#"===d&&/[boxX]/.test(v)?"0"+v.toLowerCase():"",_="$"===d?o:/[%p]/.test(v)?l:"",w=Qs[v],x=/[defgprs%]/.test(v);function T(e){var i,o,l,d=y,T=_;if("c"===v)T=w(e)+T,e="";else{var A=(e=+e)<0||1/e<0;if(e=isNaN(e)?u:w(Math.abs(e),g),b&&(e=function(e){e:for(var t,n=e.length,r=1,i=-1;r0&&(i=0)}return i>0?e.slice(0,i)+e.slice(t+1):e}(e)),A&&0==+e&&"+"!==f&&(A=!1),d=(A?"("===f?f:c:"-"===f||"("===f?"":f)+d,T=("s"===v?tl[8+Ws/3]:"")+T+(A&&"("===f?")":""),x)for(i=-1,o=e.length;++i(l=e.charCodeAt(i))||l>57){T=(46===l?a+e.slice(i+1):e.slice(i))+T,e=e.slice(0,i);break}}m&&!h&&(e=r(e,1/0));var E=d.length+e.length+T.length,k=E>1)+d+e+T+k.slice(E);break;default:e=k+d+e+T}return s(e)}return g=void 0===g?6:/[gprs]/.test(v)?Math.max(1,Math.min(21,g)):Math.max(0,Math.min(20,g)),T.toString=function(){return e+""},T}return{format:f,formatPrefix:function(e,t){var n=f(((e=Zs(e)).type="f",e)),r=3*Math.max(-8,Math.min(8,Math.floor(Gs(t)/3))),i=Math.pow(10,-r),o=tl[8+r/3];return function(e){return n(i*e)+o}}}}function rl(t){return Js=nl(t),e.format=Js.format,e.formatPrefix=Js.formatPrefix,Js}function il(e){return Math.max(0,-Gs(Math.abs(e)))}function ol(e,t){return Math.max(0,3*Math.max(-8,Math.min(8,Math.floor(Gs(t)/3)))-Gs(Math.abs(e)))}function al(e,t){return e=Math.abs(e),t=Math.abs(t)-e,Math.max(0,Gs(t)-Gs(e))+1}rl({thousands:",",grouping:[3],currency:["$",""]});var sl=1e-6,ll=1e-12,cl=Math.PI,ul=cl/2,fl=cl/4,dl=2*cl,hl=180/cl,pl=cl/180,ml=Math.abs,gl=Math.atan,bl=Math.atan2,vl=Math.cos,yl=Math.ceil,_l=Math.exp,wl=Math.hypot,xl=Math.log,Tl=Math.pow,Al=Math.sin,El=Math.sign||function(e){return e>0?1:e<0?-1:0},kl=Math.sqrt,Sl=Math.tan;function Ml(e){return e>1?0:e<-1?cl:Math.acos(e)}function Cl(e){return e>1?ul:e<-1?-ul:Math.asin(e)}function Nl(e){return(e=Al(e/2))*e}function Dl(){}function Ll(e,t){e&&Il.hasOwnProperty(e.type)&&Il[e.type](e,t)}var Ol={Feature:function(e,t){Ll(e.geometry,t)},FeatureCollection:function(e,t){for(var n=e.features,r=-1,i=n.length;++r=0?1:-1,i=r*n,o=vl(t=(t*=pl)/2+fl),a=Al(t),s=Ul*a,l=ql*o+s*vl(i),c=s*r*Al(i);ec.add(bl(c,l)),Fl=e,ql=o,Ul=a}function sc(e){return[bl(e[1],e[0]),Cl(e[2])]}function lc(e){var t=e[0],n=e[1],r=vl(n);return[r*vl(t),r*Al(t),Al(n)]}function cc(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]}function uc(e,t){return[e[1]*t[2]-e[2]*t[1],e[2]*t[0]-e[0]*t[2],e[0]*t[1]-e[1]*t[0]]}function fc(e,t){e[0]+=t[0],e[1]+=t[1],e[2]+=t[2]}function dc(e,t){return[e[0]*t,e[1]*t,e[2]*t]}function hc(e){var t=kl(e[0]*e[0]+e[1]*e[1]+e[2]*e[2]);e[0]/=t,e[1]/=t,e[2]/=t}var pc,mc,gc,bc,vc,yc,_c,wc,xc,Tc,Ac,Ec,kc,Sc,Mc,Cc,Nc={point:Dc,lineStart:Oc,lineEnd:Ic,polygonStart:function(){Nc.point=Bc,Nc.lineStart=Pc,Nc.lineEnd=jc,Ql=new m,nc.polygonStart()},polygonEnd:function(){nc.polygonEnd(),Nc.point=Dc,Nc.lineStart=Oc,Nc.lineEnd=Ic,ec<0?(Hl=-(Gl=180),Vl=-(Wl=90)):Ql>sl?Wl=90:Ql<-1e-6&&(Vl=-90),Jl[0]=Hl,Jl[1]=Gl},sphere:function(){Hl=-(Gl=180),Vl=-(Wl=90)}};function Dc(e,t){$l.push(Jl=[Hl=e,Gl=e]),tWl&&(Wl=t)}function Lc(e,t){var n=lc([e*pl,t*pl]);if(Xl){var r=uc(Xl,n),i=uc([r[1],-r[0],0],r);hc(i),i=sc(i);var o,a=e-Yl,s=a>0?1:-1,l=i[0]*hl*s,c=ml(a)>180;c^(s*YlWl&&(Wl=o):c^(s*Yl<(l=(l+360)%360-180)&&lWl&&(Wl=t)),c?eRc(Hl,Gl)&&(Gl=e):Rc(e,Gl)>Rc(Hl,Gl)&&(Hl=e):Gl>=Hl?(eGl&&(Gl=e)):e>Yl?Rc(Hl,e)>Rc(Hl,Gl)&&(Gl=e):Rc(e,Gl)>Rc(Hl,Gl)&&(Hl=e)}else $l.push(Jl=[Hl=e,Gl=e]);tWl&&(Wl=t),Xl=n,Yl=e}function Oc(){Nc.point=Lc}function Ic(){Jl[0]=Hl,Jl[1]=Gl,Nc.point=Dc,Xl=null}function Bc(e,t){if(Xl){var n=e-Yl;Ql.add(ml(n)>180?n+(n>0?360:-360):n)}else Zl=e,Kl=t;nc.point(e,t),Lc(e,t)}function Pc(){nc.lineStart()}function jc(){Bc(Zl,Kl),nc.lineEnd(),ml(Ql)>sl&&(Hl=-(Gl=180)),Jl[0]=Hl,Jl[1]=Gl,Xl=null}function Rc(e,t){return(t-=e)<0?t+360:t}function zc(e,t){return e[0]-t[0]}function Fc(e,t){return e[0]<=e[1]?e[0]<=t&&t<=e[1]:tcl?e+Math.round(-e/dl)*dl:e,t]}function tu(e,t,n){return(e%=dl)?t||n?Jc(ru(e),iu(t,n)):ru(e):t||n?iu(t,n):eu}function nu(e){return function(t,n){return[(t+=e)>cl?t-dl:t<-cl?t+dl:t,n]}}function ru(e){var t=nu(e);return t.invert=nu(-e),t}function iu(e,t){var n=vl(e),r=Al(e),i=vl(t),o=Al(t);function a(e,t){var a=vl(t),s=vl(e)*a,l=Al(e)*a,c=Al(t),u=c*n+s*r;return[bl(l*i-u*o,s*n-c*r),Cl(u*i+l*o)]}return a.invert=function(e,t){var a=vl(t),s=vl(e)*a,l=Al(e)*a,c=Al(t),u=c*i-l*o;return[bl(l*i+c*o,s*n+u*r),Cl(u*n-s*r)]},a}function ou(e){function t(t){return(t=e(t[0]*pl,t[1]*pl))[0]*=hl,t[1]*=hl,t}return e=tu(e[0]*pl,e[1]*pl,e.length>2?e[2]*pl:0),t.invert=function(t){return(t=e.invert(t[0]*pl,t[1]*pl))[0]*=hl,t[1]*=hl,t},t}function au(e,t,n,r,i,o){if(n){var a=vl(t),s=Al(t),l=r*n;null==i?(i=t+r*dl,o=t-l/2):(i=su(a,i),o=su(a,o),(r>0?io)&&(i+=r*dl));for(var c,u=i;r>0?u>o:u1&&t.push(t.pop().concat(t.shift()))},result:function(){var n=t;return t=[],e=null,n}}}function cu(e,t){return ml(e[0]-t[0])=0;--o)i.point((u=c[o])[0],u[1]);else r(d.x,d.p.x,-1,i);d=d.p}c=(d=d.o).z,h=!h}while(!d.v);i.lineEnd()}}}function du(e){if(t=e.length){for(var t,n,r=0,i=e[0];++r=0?1:-1,S=k*E,M=S>cl,C=b*T;if(l.add(bl(C*k*Al(S),v*A+C*vl(S))),a+=M?E+k*dl:E,M^p>=n^w>=n){var N=uc(lc(h),lc(_));hc(N);var D=uc(o,N);hc(D);var L=(M^E>=0?-1:1)*Cl(D[2]);(r>L||r===L&&(N[0]||N[1]))&&(s+=M^E>=0?1:-1)}}return(a<-1e-6||a0){for(f||(i.polygonStart(),f=!0),i.lineStart(),e=0;e1&&2&l&&d.push(d.pop().concat(d.shift())),a.push(d.filter(gu))}return d}}function gu(e){return e.length>1}function bu(e,t){return((e=e.x)[0]<0?e[1]-ul-sl:ul-e[1])-((t=t.x)[0]<0?t[1]-ul-sl:ul-t[1])}eu.invert=eu;var vu=mu((function(){return!0}),(function(e){var t,n=NaN,r=NaN,i=NaN;return{lineStart:function(){e.lineStart(),t=1},point:function(o,a){var s=o>0?cl:-cl,l=ml(o-n);ml(l-cl)0?ul:-ul),e.point(i,r),e.lineEnd(),e.lineStart(),e.point(s,r),e.point(o,r),t=0):i!==s&&l>=cl&&(ml(n-i)sl?gl((Al(t)*(o=vl(r))*Al(n)-Al(r)*(i=vl(t))*Al(e))/(i*o*a)):(t+r)/2}(n,r,o,a),e.point(i,r),e.lineEnd(),e.lineStart(),e.point(s,r),t=0),e.point(n=o,r=a),i=s},lineEnd:function(){e.lineEnd(),n=r=NaN},clean:function(){return 2-t}}}),(function(e,t,n,r){var i;if(null==e)i=n*ul,r.point(-cl,i),r.point(0,i),r.point(cl,i),r.point(cl,0),r.point(cl,-i),r.point(0,-i),r.point(-cl,-i),r.point(-cl,0),r.point(-cl,i);else if(ml(e[0]-t[0])>sl){var o=e[0]0,i=ml(t)>sl;function o(e,n){return vl(e)*vl(n)>t}function a(e,n,r){var i=[1,0,0],o=uc(lc(e),lc(n)),a=cc(o,o),s=o[0],l=a-s*s;if(!l)return!r&&e;var c=t*a/l,u=-t*s/l,f=uc(i,o),d=dc(i,c);fc(d,dc(o,u));var h=f,p=cc(d,h),m=cc(h,h),g=p*p-m*(cc(d,d)-1);if(!(g<0)){var b=kl(g),v=dc(h,(-p-b)/m);if(fc(v,d),v=sc(v),!r)return v;var y,_=e[0],w=n[0],x=e[1],T=n[1];w<_&&(y=_,_=w,w=y);var A=w-_,E=ml(A-cl)0^v[1]<(ml(v[0]-_)cl^(_<=v[0]&&v[0]<=w)){var k=dc(h,(-p+b)/m);return fc(k,d),[v,sc(k)]}}}function s(t,n){var i=r?e:cl-e,o=0;return t<-i?o|=1:t>i&&(o|=2),n<-i?o|=4:n>i&&(o|=8),o}return mu(o,(function(e){var t,n,l,c,u;return{lineStart:function(){c=l=!1,u=1},point:function(f,d){var h,p=[f,d],m=o(f,d),g=r?m?0:s(f,d):m?s(f+(f<0?cl:-cl),d):0;if(!t&&(c=l=m)&&e.lineStart(),m!==l&&(!(h=a(t,p))||cu(t,h)||cu(p,h))&&(p[2]=1),m!==l)u=0,m?(e.lineStart(),h=a(p,t),e.point(h[0],h[1])):(h=a(t,p),e.point(h[0],h[1],2),e.lineEnd()),t=h;else if(i&&t&&r^m){var b;g&n||!(b=a(p,t,!0))||(u=0,r?(e.lineStart(),e.point(b[0][0],b[0][1]),e.point(b[1][0],b[1][1]),e.lineEnd()):(e.point(b[1][0],b[1][1]),e.lineEnd(),e.lineStart(),e.point(b[0][0],b[0][1],3)))}!m||t&&cu(t,p)||e.point(p[0],p[1]),t=p,l=m,n=g},lineEnd:function(){l&&e.lineEnd(),t=null},clean:function(){return u|(c&&l)<<1}}}),(function(t,r,i,o){au(o,e,n,i,t,r)}),r?[0,-e]:[-cl,e-cl])}var _u,wu,xu,Tu,Au=1e9,Eu=-Au;function ku(e,t,n,r){function i(i,o){return e<=i&&i<=n&&t<=o&&o<=r}function o(i,o,s,c){var u=0,f=0;if(null==i||(u=a(i,s))!==(f=a(o,s))||l(i,o)<0^s>0)do{c.point(0===u||3===u?e:n,u>1?r:t)}while((u=(u+s+4)%4)!==f);else c.point(o[0],o[1])}function a(r,i){return ml(r[0]-e)0?0:3:ml(r[0]-n)0?2:1:ml(r[1]-t)0?1:0:i>0?3:2}function s(e,t){return l(e.x,t.x)}function l(e,t){var n=a(e,1),r=a(t,1);return n!==r?n-r:0===n?t[1]-e[1]:1===n?e[0]-t[0]:2===n?e[1]-t[1]:t[0]-e[0]}return function(a){var l,c,u,f,d,h,p,m,g,b,v,y=a,_=lu(),w={point:x,lineStart:function(){w.point=T,c&&c.push(u=[]),b=!0,g=!1,p=m=NaN},lineEnd:function(){l&&(T(f,d),h&&g&&_.rejoin(),l.push(_.result())),w.point=x,g&&y.lineEnd()},polygonStart:function(){y=_,l=[],c=[],v=!0},polygonEnd:function(){var t=function(){for(var t=0,n=0,i=c.length;nr&&(d-o)*(r-a)>(h-a)*(e-o)&&++t:h<=r&&(d-o)*(r-a)<(h-a)*(e-o)&&--t;return t}(),n=v&&t,i=(l=j(l)).length;(n||i)&&(a.polygonStart(),n&&(a.lineStart(),o(null,null,1,a),a.lineEnd()),i&&fu(l,s,t,o,a),a.polygonEnd()),y=a,l=c=u=null}};function x(e,t){i(e,t)&&y.point(e,t)}function T(o,a){var s=i(o,a);if(c&&u.push([o,a]),b)f=o,d=a,h=s,b=!1,s&&(y.lineStart(),y.point(o,a));else if(s&&g)y.point(o,a);else{var l=[p=Math.max(Eu,Math.min(Au,p)),m=Math.max(Eu,Math.min(Au,m))],_=[o=Math.max(Eu,Math.min(Au,o)),a=Math.max(Eu,Math.min(Au,a))];!function(e,t,n,r,i,o){var a,s=e[0],l=e[1],c=0,u=1,f=t[0]-s,d=t[1]-l;if(a=n-s,f||!(a>0)){if(a/=f,f<0){if(a0){if(a>u)return;a>c&&(c=a)}if(a=i-s,f||!(a<0)){if(a/=f,f<0){if(a>u)return;a>c&&(c=a)}else if(f>0){if(a0)){if(a/=d,d<0){if(a0){if(a>u)return;a>c&&(c=a)}if(a=o-l,d||!(a<0)){if(a/=d,d<0){if(a>u)return;a>c&&(c=a)}else if(d>0){if(a0&&(e[0]=s+c*f,e[1]=l+c*d),u<1&&(t[0]=s+u*f,t[1]=l+u*d),!0}}}}}(l,_,e,t,n,r)?s&&(y.lineStart(),y.point(o,a),v=!1):(g||(y.lineStart(),y.point(l[0],l[1])),y.point(_[0],_[1]),s||y.lineEnd(),v=!1)}p=o,m=a,g=s}return w}}var Su={sphere:Dl,point:Dl,lineStart:function(){Su.point=Cu,Su.lineEnd=Mu},lineEnd:Dl,polygonStart:Dl,polygonEnd:Dl};function Mu(){Su.point=Su.lineEnd=Dl}function Cu(e,t){wu=e*=pl,xu=Al(t*=pl),Tu=vl(t),Su.point=Nu}function Nu(e,t){e*=pl;var n=Al(t*=pl),r=vl(t),i=ml(e-wu),o=vl(i),a=r*Al(i),s=Tu*n-xu*r*o,l=xu*n+Tu*r*o;_u.add(bl(kl(a*a+s*s),l)),wu=e,xu=n,Tu=r}function Du(e){return _u=new m,jl(e,Su),+_u}var Lu=[null,null],Ou={type:"LineString",coordinates:Lu};function Iu(e,t){return Lu[0]=e,Lu[1]=t,Du(Ou)}var Bu={Feature:function(e,t){return ju(e.geometry,t)},FeatureCollection:function(e,t){for(var n=e.features,r=-1,i=n.length;++r0&&(i=Iu(e[o],e[o-1]))>0&&n<=i&&r<=i&&(n+r-i)*(1-Math.pow((n-r)/i,2))sl})).map(l)).concat(q(yl(o/h)*h,i,h).filter((function(e){return ml(e%m)>sl})).map(c))}return b.lines=function(){return v().map((function(e){return{type:"LineString",coordinates:e}}))},b.outline=function(){return{type:"Polygon",coordinates:[u(r).concat(f(a).slice(1),u(n).reverse().slice(1),f(s).reverse().slice(1))]}},b.extent=function(e){return arguments.length?b.extentMajor(e).extentMinor(e):b.extentMinor()},b.extentMajor=function(e){return arguments.length?(r=+e[0][0],n=+e[1][0],s=+e[0][1],a=+e[1][1],r>n&&(e=r,r=n,n=e),s>a&&(e=s,s=a,a=e),b.precision(g)):[[r,s],[n,a]]},b.extentMinor=function(n){return arguments.length?(t=+n[0][0],e=+n[1][0],o=+n[0][1],i=+n[1][1],t>e&&(n=t,t=e,e=n),o>i&&(n=o,o=i,i=n),b.precision(g)):[[t,o],[e,i]]},b.step=function(e){return arguments.length?b.stepMajor(e).stepMinor(e):b.stepMinor()},b.stepMajor=function(e){return arguments.length?(p=+e[0],m=+e[1],b):[p,m]},b.stepMinor=function(e){return arguments.length?(d=+e[0],h=+e[1],b):[d,h]},b.precision=function(d){return arguments.length?(g=+d,l=Hu(o,i,90),c=Vu(t,e,g),u=Hu(s,a,90),f=Vu(r,n,g),b):g},b.extentMajor([[-180,-89.999999],[180,89.999999]]).extentMinor([[-180,-80.000001],[180,80.000001]])}var Wu,Yu,Zu,Ku,Xu=e=>e,Qu=new m,$u=new m,Ju={point:Dl,lineStart:Dl,lineEnd:Dl,polygonStart:function(){Ju.lineStart=ef,Ju.lineEnd=rf},polygonEnd:function(){Ju.lineStart=Ju.lineEnd=Ju.point=Dl,Qu.add(ml($u)),$u=new m},result:function(){var e=Qu/2;return Qu=new m,e}};function ef(){Ju.point=tf}function tf(e,t){Ju.point=nf,Wu=Zu=e,Yu=Ku=t}function nf(e,t){$u.add(Ku*e-Zu*t),Zu=e,Ku=t}function rf(){nf(Wu,Yu)}var of,af,sf,lf,cf=1/0,uf=cf,ff=-cf,df=ff,hf={point:function(e,t){eff&&(ff=e),tdf&&(df=t)},lineStart:Dl,lineEnd:Dl,polygonStart:Dl,polygonEnd:Dl,result:function(){var e=[[cf,uf],[ff,df]];return ff=df=-(uf=cf=1/0),e}},pf=0,mf=0,gf=0,bf=0,vf=0,yf=0,_f=0,wf=0,xf=0,Tf={point:Af,lineStart:Ef,lineEnd:Mf,polygonStart:function(){Tf.lineStart=Cf,Tf.lineEnd=Nf},polygonEnd:function(){Tf.point=Af,Tf.lineStart=Ef,Tf.lineEnd=Mf},result:function(){var e=xf?[_f/xf,wf/xf]:yf?[bf/yf,vf/yf]:gf?[pf/gf,mf/gf]:[NaN,NaN];return pf=mf=gf=bf=vf=yf=_f=wf=xf=0,e}};function Af(e,t){pf+=e,mf+=t,++gf}function Ef(){Tf.point=kf}function kf(e,t){Tf.point=Sf,Af(sf=e,lf=t)}function Sf(e,t){var n=e-sf,r=t-lf,i=kl(n*n+r*r);bf+=i*(sf+e)/2,vf+=i*(lf+t)/2,yf+=i,Af(sf=e,lf=t)}function Mf(){Tf.point=Af}function Cf(){Tf.point=Df}function Nf(){Lf(of,af)}function Df(e,t){Tf.point=Lf,Af(of=sf=e,af=lf=t)}function Lf(e,t){var n=e-sf,r=t-lf,i=kl(n*n+r*r);bf+=i*(sf+e)/2,vf+=i*(lf+t)/2,yf+=i,_f+=(i=lf*e-sf*t)*(sf+e),wf+=i*(lf+t),xf+=3*i,Af(sf=e,lf=t)}function Of(e){this._context=e}Of.prototype={_radius:4.5,pointRadius:function(e){return this._radius=e,this},polygonStart:function(){this._line=0},polygonEnd:function(){this._line=NaN},lineStart:function(){this._point=0},lineEnd:function(){0===this._line&&this._context.closePath(),this._point=NaN},point:function(e,t){switch(this._point){case 0:this._context.moveTo(e,t),this._point=1;break;case 1:this._context.lineTo(e,t);break;default:this._context.moveTo(e+this._radius,t),this._context.arc(e,t,this._radius,0,dl)}},result:Dl};var If,Bf,Pf,jf,Rf,zf=new m,Ff={point:Dl,lineStart:function(){Ff.point=qf},lineEnd:function(){If&&Uf(Bf,Pf),Ff.point=Dl},polygonStart:function(){If=!0},polygonEnd:function(){If=null},result:function(){var e=+zf;return zf=new m,e}};function qf(e,t){Ff.point=Uf,Bf=jf=e,Pf=Rf=t}function Uf(e,t){jf-=e,Rf-=t,zf.add(kl(jf*jf+Rf*Rf)),jf=e,Rf=t}function Hf(){this._string=[]}function Vf(e){return"m0,"+e+"a"+e+","+e+" 0 1,1 0,"+-2*e+"a"+e+","+e+" 0 1,1 0,"+2*e+"z"}function Gf(e){return function(t){var n=new Wf;for(var r in e)n[r]=e[r];return n.stream=t,n}}function Wf(){}function Yf(e,t,n){var r=e.clipExtent&&e.clipExtent();return e.scale(150).translate([0,0]),null!=r&&e.clipExtent(null),jl(n,e.stream(hf)),t(hf.result()),null!=r&&e.clipExtent(r),e}function Zf(e,t,n){return Yf(e,(function(n){var r=t[1][0]-t[0][0],i=t[1][1]-t[0][1],o=Math.min(r/(n[1][0]-n[0][0]),i/(n[1][1]-n[0][1])),a=+t[0][0]+(r-o*(n[1][0]+n[0][0]))/2,s=+t[0][1]+(i-o*(n[1][1]+n[0][1]))/2;e.scale(150*o).translate([a,s])}),n)}function Kf(e,t,n){return Zf(e,[[0,0],t],n)}function Xf(e,t,n){return Yf(e,(function(n){var r=+t,i=r/(n[1][0]-n[0][0]),o=(r-i*(n[1][0]+n[0][0]))/2,a=-i*n[0][1];e.scale(150*i).translate([o,a])}),n)}function Qf(e,t,n){return Yf(e,(function(n){var r=+t,i=r/(n[1][1]-n[0][1]),o=-i*n[0][0],a=(r-i*(n[1][1]+n[0][1]))/2;e.scale(150*i).translate([o,a])}),n)}Hf.prototype={_radius:4.5,_circle:Vf(4.5),pointRadius:function(e){return(e=+e)!==this._radius&&(this._radius=e,this._circle=null),this},polygonStart:function(){this._line=0},polygonEnd:function(){this._line=NaN},lineStart:function(){this._point=0},lineEnd:function(){0===this._line&&this._string.push("Z"),this._point=NaN},point:function(e,t){switch(this._point){case 0:this._string.push("M",e,",",t),this._point=1;break;case 1:this._string.push("L",e,",",t);break;default:null==this._circle&&(this._circle=Vf(this._radius)),this._string.push("M",e,",",t,this._circle)}},result:function(){if(this._string.length){var e=this._string.join("");return this._string=[],e}return null}},Wf.prototype={constructor:Wf,point:function(e,t){this.stream.point(e,t)},sphere:function(){this.stream.sphere()},lineStart:function(){this.stream.lineStart()},lineEnd:function(){this.stream.lineEnd()},polygonStart:function(){this.stream.polygonStart()},polygonEnd:function(){this.stream.polygonEnd()}};var $f=vl(30*pl);function Jf(e,t){return+t?function(e,t){function n(r,i,o,a,s,l,c,u,f,d,h,p,m,g){var b=c-r,v=u-i,y=b*b+v*v;if(y>4*t&&m--){var _=a+d,w=s+h,x=l+p,T=kl(_*_+w*w+x*x),A=Cl(x/=T),E=ml(ml(x)-1)t||ml((b*C+v*N)/y-.5)>.3||a*d+s*h+l*p<$f)&&(n(r,i,o,a,s,l,S,M,E,_/=T,w/=T,x,m,g),g.point(S,M),n(S,M,E,_,w,x,c,u,f,d,h,p,m,g))}}return function(t){var r,i,o,a,s,l,c,u,f,d,h,p,m={point:g,lineStart:b,lineEnd:y,polygonStart:function(){t.polygonStart(),m.lineStart=_},polygonEnd:function(){t.polygonEnd(),m.lineStart=b}};function g(n,r){n=e(n,r),t.point(n[0],n[1])}function b(){u=NaN,m.point=v,t.lineStart()}function v(r,i){var o=lc([r,i]),a=e(r,i);n(u,f,c,d,h,p,u=a[0],f=a[1],c=r,d=o[0],h=o[1],p=o[2],16,t),t.point(u,f)}function y(){m.point=g,t.lineEnd()}function _(){b(),m.point=w,m.lineEnd=x}function w(e,t){v(r=e,t),i=u,o=f,a=d,s=h,l=p,m.point=v}function x(){n(u,f,c,d,h,p,i,o,r,a,s,l,16,t),m.lineEnd=y,y()}return m}}(e,t):function(e){return Gf({point:function(t,n){t=e(t,n),this.stream.point(t[0],t[1])}})}(e)}var ed=Gf({point:function(e,t){this.stream.point(e*pl,t*pl)}});function td(e,t,n,r,i,o){if(!o)return function(e,t,n,r,i){function o(o,a){return[t+e*(o*=r),n-e*(a*=i)]}return o.invert=function(o,a){return[(o-t)/e*r,(n-a)/e*i]},o}(e,t,n,r,i);var a=vl(o),s=Al(o),l=a*e,c=s*e,u=a/e,f=s/e,d=(s*n-a*t)/e,h=(s*t+a*n)/e;function p(e,o){return[l*(e*=r)-c*(o*=i)+t,n-c*e-l*o]}return p.invert=function(e,t){return[r*(u*e-f*t+d),i*(h-f*e-u*t)]},p}function nd(e){return rd((function(){return e}))()}function rd(e){var t,n,r,i,o,a,s,l,c,u,f=150,d=480,h=250,p=0,m=0,g=0,b=0,v=0,y=0,_=1,w=1,x=null,T=vu,A=null,E=Xu,k=.5;function S(e){return l(e[0]*pl,e[1]*pl)}function M(e){return(e=l.invert(e[0],e[1]))&&[e[0]*hl,e[1]*hl]}function C(){var e=td(f,0,0,_,w,y).apply(null,t(p,m)),r=td(f,d-e[0],h-e[1],_,w,y);return n=tu(g,b,v),s=Jc(t,r),l=Jc(n,s),a=Jf(s,k),N()}function N(){return c=u=null,S}return S.stream=function(e){return c&&u===e?c:c=ed(function(e){return Gf({point:function(t,n){var r=e(t,n);return this.stream.point(r[0],r[1])}})}(n)(T(a(E(u=e)))))},S.preclip=function(e){return arguments.length?(T=e,x=void 0,N()):T},S.postclip=function(e){return arguments.length?(E=e,A=r=i=o=null,N()):E},S.clipAngle=function(e){return arguments.length?(T=+e?yu(x=e*pl):(x=null,vu),N()):x*hl},S.clipExtent=function(e){return arguments.length?(E=null==e?(A=r=i=o=null,Xu):ku(A=+e[0][0],r=+e[0][1],i=+e[1][0],o=+e[1][1]),N()):null==A?null:[[A,r],[i,o]]},S.scale=function(e){return arguments.length?(f=+e,C()):f},S.translate=function(e){return arguments.length?(d=+e[0],h=+e[1],C()):[d,h]},S.center=function(e){return arguments.length?(p=e[0]%360*pl,m=e[1]%360*pl,C()):[p*hl,m*hl]},S.rotate=function(e){return arguments.length?(g=e[0]%360*pl,b=e[1]%360*pl,v=e.length>2?e[2]%360*pl:0,C()):[g*hl,b*hl,v*hl]},S.angle=function(e){return arguments.length?(y=e%360*pl,C()):y*hl},S.reflectX=function(e){return arguments.length?(_=e?-1:1,C()):_<0},S.reflectY=function(e){return arguments.length?(w=e?-1:1,C()):w<0},S.precision=function(e){return arguments.length?(a=Jf(s,k=e*e),N()):kl(k)},S.fitExtent=function(e,t){return Zf(S,e,t)},S.fitSize=function(e,t){return Kf(S,e,t)},S.fitWidth=function(e,t){return Xf(S,e,t)},S.fitHeight=function(e,t){return Qf(S,e,t)},function(){return t=e.apply(this,arguments),S.invert=t.invert&&M,C()}}function id(e){var t=0,n=cl/3,r=rd(e),i=r(t,n);return i.parallels=function(e){return arguments.length?r(t=e[0]*pl,n=e[1]*pl):[t*hl,n*hl]},i}function od(e,t){var n=Al(e),r=(n+Al(t))/2;if(ml(r)0?t<-ul+sl&&(t=-ul+sl):t>ul-sl&&(t=ul-sl);var n=i/Tl(pd(t),r);return[n*Al(r*e),i-n*vl(r*e)]}return o.invert=function(e,t){var n=i-t,o=El(r)*kl(e*e+n*n),a=bl(e,ml(n))*El(n);return n*r<0&&(a-=cl*El(e)*El(n)),[a/r,2*gl(Tl(i/o,1/r))-ul]},o}function gd(e,t){return[e,t]}function bd(e,t){var n=vl(e),r=e===t?Al(e):(n-vl(t))/(t-e),i=n/r+e;if(ml(r)=0;)t+=n[r].value;else t=1;e.value=t}function Od(e,t){e instanceof Map?(e=[void 0,e],void 0===t&&(t=Bd)):void 0===t&&(t=Id);for(var n,r,i,o,a,s=new Rd(e),l=[s];n=l.pop();)if((i=t(n.data))&&(a=(i=Array.from(i)).length))for(n.children=i,o=a-1;o>=0;--o)l.push(r=i[o]=new Rd(i[o])),r.parent=n,r.depth=n.depth+1;return s.eachBefore(jd)}function Id(e){return e.children}function Bd(e){return Array.isArray(e)?e[1]:null}function Pd(e){void 0!==e.data.value&&(e.value=e.data.value),e.data=e.data.data}function jd(e){var t=0;do{e.height=t}while((e=e.parent)&&e.height<++t)}function Rd(e){this.data=e,this.depth=this.height=0,this.parent=null}function zd(e){for(var t,n,r=0,i=(e=function(e){for(var t,n,r=e.length;r;)n=Math.random()*r--|0,t=e[r],e[r]=e[n],e[n]=t;return e}(Array.from(e))).length,o=[];r0&&n*n>r*r+i*i}function Hd(e,t){for(var n=0;n(a*=a)?(r=(c+a-i)/(2*c),o=Math.sqrt(Math.max(0,a/c-r*r)),n.x=e.x-r*s-o*l,n.y=e.y-r*l+o*s):(r=(c+i-a)/(2*c),o=Math.sqrt(Math.max(0,i/c-r*r)),n.x=t.x+r*s-o*l,n.y=t.y+r*l+o*s)):(n.x=t.x+n.r,n.y=t.y)}function Zd(e,t){var n=e.r+t.r-1e-6,r=t.x-e.x,i=t.y-e.y;return n>0&&n*n>r*r+i*i}function Kd(e){var t=e._,n=e.next._,r=t.r+n.r,i=(t.x*n.r+n.x*t.r)/r,o=(t.y*n.r+n.y*t.r)/r;return i*i+o*o}function Xd(e){this._=e,this.next=null,this.previous=null}function Qd(e){if(!(i=(e=function(e){return"object"==typeof e&&"length"in e?e:Array.from(e)}(e)).length))return 0;var t,n,r,i,o,a,s,l,c,u,f;if((t=e[0]).x=0,t.y=0,!(i>1))return t.r;if(n=e[1],t.x=-n.r,n.x=t.r,n.y=0,!(i>2))return t.r+n.r;Yd(n,t,r=e[2]),t=new Xd(t),n=new Xd(n),r=new Xd(r),t.next=r.previous=n,n.next=t.previous=r,r.next=n.previous=t;e:for(s=3;ssl&&--i>0);return[e/(.8707+(o=r*r)*(o*(o*o*o*(.003971-.001529*o)-.013791)-.131979)),r]},kd.invert=cd(Cl),Sd.invert=cd((function(e){return 2*gl(e)})),Md.invert=function(e,t){return[-t,2*gl(_l(e))-ul]},Rd.prototype=Od.prototype={constructor:Rd,count:function(){return this.eachAfter(Ld)},each:function(e,t){let n=-1;for(const r of this)e.call(t,r,++n,this);return this},eachAfter:function(e,t){for(var n,r,i,o=this,a=[o],s=[],l=-1;o=a.pop();)if(s.push(o),n=o.children)for(r=0,i=n.length;r=0;--r)o.push(n[r]);return this},find:function(e,t){let n=-1;for(const r of this)if(e.call(t,r,++n,this))return r},sum:function(e){return this.eachAfter((function(t){for(var n=+e(t.data)||0,r=t.children,i=r&&r.length;--i>=0;)n+=r[i].value;t.value=n}))},sort:function(e){return this.eachBefore((function(t){t.children&&t.children.sort(e)}))},path:function(e){for(var t=this,n=function(e,t){if(e===t)return e;var n=e.ancestors(),r=t.ancestors(),i=null;for(e=n.pop(),t=r.pop();e===t;)i=e,e=n.pop(),t=r.pop();return i}(t,e),r=[t];t!==n;)t=t.parent,r.push(t);for(var i=r.length;e!==n;)r.splice(i,0,e),e=e.parent;return r},ancestors:function(){for(var e=this,t=[e];e=e.parent;)t.push(e);return t},descendants:function(){return Array.from(this)},leaves:function(){var e=[];return this.eachBefore((function(t){t.children||e.push(t)})),e},links:function(){var e=this,t=[];return e.each((function(n){n!==e&&t.push({source:n.parent,target:n})})),t},copy:function(){return Od(this).eachBefore(Pd)},[Symbol.iterator]:function*(){var e,t,n,r,i=this,o=[i];do{for(e=o.reverse(),o=[];i=e.pop();)if(yield i,t=i.children)for(n=0,r=t.length;nd&&(d=s),g=u*u*m,(h=Math.max(d/g,g/f))>p){u-=s;break}p=h}b.push(a={value:u,dice:l1?t:1)},n}(yh),xh=function e(t){function n(e,n,r,i,o){if((a=e._squarify)&&a.ratio===t)for(var a,s,l,c,u,f=-1,d=a.length,h=e.value;++f1?t:1)},n}(yh);function Th(e,t,n){return(t[0]-e[0])*(n[1]-e[1])-(t[1]-e[1])*(n[0]-e[0])}function Ah(e,t){return e[0]-t[0]||e[1]-t[1]}function Eh(e){const t=e.length,n=[0,1];let r,i=2;for(r=2;r1&&Th(e[n[i-2]],e[n[i-1]],e[r])<=0;)--i;n[i++]=r}return n.slice(0,i)}var kh=Math.random,Sh=function e(t){function n(e,n){return e=null==e?0:+e,n=null==n?1:+n,1===arguments.length?(n=e,e=0):n-=e,function(){return t()*n+e}}return n.source=e,n}(kh),Mh=function e(t){function n(e,n){return arguments.length<2&&(n=e,e=0),e=Math.floor(e),n=Math.floor(n)-e,function(){return Math.floor(t()*n+e)}}return n.source=e,n}(kh),Ch=function e(t){function n(e,n){var r,i;return e=null==e?0:+e,n=null==n?1:+n,function(){var o;if(null!=r)o=r,r=null;else do{r=2*t()-1,o=2*t()-1,i=r*r+o*o}while(!i||i>1);return e+n*o*Math.sqrt(-2*Math.log(i)/i)}}return n.source=e,n}(kh),Nh=function e(t){var n=Ch.source(t);function r(){var e=n.apply(this,arguments);return function(){return Math.exp(e())}}return r.source=e,r}(kh),Dh=function e(t){function n(e){return(e=+e)<=0?()=>0:function(){for(var n=0,r=e;r>1;--r)n+=t();return n+r*t()}}return n.source=e,n}(kh),Lh=function e(t){var n=Dh.source(t);function r(e){if(0==(e=+e))return t;var r=n(e);return function(){return r()/e}}return r.source=e,r}(kh),Oh=function e(t){function n(e){return function(){return-Math.log1p(-t())/e}}return n.source=e,n}(kh),Ih=function e(t){function n(e){if((e=+e)<0)throw new RangeError("invalid alpha");return e=1/-e,function(){return Math.pow(1-t(),e)}}return n.source=e,n}(kh),Bh=function e(t){function n(e){if((e=+e)<0||e>1)throw new RangeError("invalid p");return function(){return Math.floor(t()+e)}}return n.source=e,n}(kh),Ph=function e(t){function n(e){if((e=+e)<0||e>1)throw new RangeError("invalid p");return 0===e?()=>1/0:1===e?()=>1:(e=Math.log1p(-e),function(){return 1+Math.floor(Math.log1p(-t())/e)})}return n.source=e,n}(kh),jh=function e(t){var n=Ch.source(t)();function r(e,r){if((e=+e)<0)throw new RangeError("invalid k");if(0===e)return()=>0;if(r=null==r?1:+r,1===e)return()=>-Math.log1p(-t())*r;var i=(e<1?e+1:e)-1/3,o=1/(3*Math.sqrt(i)),a=e<1?()=>Math.pow(t(),1/e):()=>1;return function(){do{do{var e=n(),s=1+o*e}while(s<=0);s*=s*s;var l=1-t()}while(l>=1-.0331*e*e*e*e&&Math.log(l)>=.5*e*e+i*(1-s+Math.log(s)));return i*s*a()*r}}return r.source=e,r}(kh),Rh=function e(t){var n=jh.source(t);function r(e,t){var r=n(e),i=n(t);return function(){var e=r();return 0===e?0:e/(e+i())}}return r.source=e,r}(kh),zh=function e(t){var n=Ph.source(t),r=Rh.source(t);function i(e,t){return e=+e,(t=+t)>=1?()=>e:t<=0?()=>0:function(){for(var i=0,o=e,a=t;o*a>16&&o*(1-a)>16;){var s=Math.floor((o+1)*a),l=r(s,o-s+1)();l<=a?(i+=s,o-=s,a=(a-l)/(1-l)):(o=s-1,a/=l)}for(var c=a<.5,u=n(c?a:1-a),f=u(),d=0;f<=o;++d)f+=u();return i+(c?d:o-d)}}return i.source=e,i}(kh),Fh=function e(t){function n(e,n,r){var i;return 0==(e=+e)?i=e=>-Math.log(e):(e=1/e,i=t=>Math.pow(t,e)),n=null==n?0:+n,r=null==r?1:+r,function(){return n+r*i(-Math.log1p(-t()))}}return n.source=e,n}(kh),qh=function e(t){function n(e,n){return e=null==e?0:+e,n=null==n?1:+n,function(){return e+n*Math.tan(Math.PI*t())}}return n.source=e,n}(kh),Uh=function e(t){function n(e,n){return e=null==e?0:+e,n=null==n?1:+n,function(){var r=t();return e+n*Math.log(r/(1-r))}}return n.source=e,n}(kh),Hh=function e(t){var n=jh.source(t),r=zh.source(t);function i(e){return function(){for(var i=0,o=e;o>16;){var a=Math.floor(.875*o),s=n(a)();if(s>o)return i+r(a-1,o/s)();i+=a,o-=s}for(var l=-Math.log1p(-t()),c=0;l<=o;++c)l-=Math.log1p(-t());return i+c}}return i.source=e,i}(kh);const Vh=1/4294967296;function Gh(e,t){switch(arguments.length){case 0:break;case 1:this.range(e);break;default:this.range(t).domain(e)}return this}function Wh(e,t){switch(arguments.length){case 0:break;case 1:"function"==typeof e?this.interpolator(e):this.range(e);break;default:this.domain(e),"function"==typeof t?this.interpolator(t):this.range(t)}return this}const Yh=Symbol("implicit");function Zh(){var e=new Map,t=[],n=[],r=Yh;function i(i){var o=i+"",a=e.get(o);if(!a){if(r!==Yh)return r;e.set(o,a=t.push(i))}return n[(a-1)%n.length]}return i.domain=function(n){if(!arguments.length)return t.slice();t=[],e=new Map;for(const r of n){const n=r+"";e.has(n)||e.set(n,t.push(r))}return i},i.range=function(e){return arguments.length?(n=Array.from(e),i):n.slice()},i.unknown=function(e){return arguments.length?(r=e,i):r},i.copy=function(){return Zh(t,n).unknown(r)},Gh.apply(i,arguments),i}function Kh(){var e,t,n=Zh().unknown(void 0),r=n.domain,i=n.range,o=0,a=1,s=!1,l=0,c=0,u=.5;function f(){var n=r().length,f=at&&(n=e,e=t,t=n),function(n){return Math.max(e,Math.min(t,n))}}(a[0],a[e-1])),r=e>2?np:tp,i=o=null,f}function f(t){return isNaN(t=+t)?n:(i||(i=r(a.map(e),s,l)))(e(c(t)))}return f.invert=function(n){return c(t((o||(o=r(s,a.map(e),lr)))(n)))},f.domain=function(e){return arguments.length?(a=Array.from(e,Qh),u()):a.slice()},f.range=function(e){return arguments.length?(s=Array.from(e),u()):s.slice()},f.rangeRound=function(e){return s=Array.from(e),l=pr,u()},f.clamp=function(e){return arguments.length?(c=!!e||Jh,u()):c!==Jh},f.interpolate=function(e){return arguments.length?(l=e,u()):l},f.unknown=function(e){return arguments.length?(n=e,f):n},function(n,r){return e=n,t=r,u()}}function op(){return ip()(Jh,Jh)}function ap(t,n,r,i){var o,a=k(t,n,r);switch((i=Zs(null==i?",f":i)).type){case"s":var s=Math.max(Math.abs(t),Math.abs(n));return null!=i.precision||isNaN(o=ol(a,s))||(i.precision=o),e.formatPrefix(i,s);case"":case"e":case"g":case"p":case"r":null!=i.precision||isNaN(o=al(a,Math.max(Math.abs(t),Math.abs(n))))||(i.precision=o-("e"===i.type));break;case"f":case"%":null!=i.precision||isNaN(o=il(a))||(i.precision=o-2*("%"===i.type))}return e.format(i)}function sp(e){var t=e.domain;return e.ticks=function(e){var n=t();return A(n[0],n[n.length-1],null==e?10:e)},e.tickFormat=function(e,n){var r=t();return ap(r[0],r[r.length-1],null==e?10:e,n)},e.nice=function(n){null==n&&(n=10);var r,i,o=t(),a=0,s=o.length-1,l=o[a],c=o[s],u=10;for(c0;){if((i=E(l,c,n))===r)return o[a]=l,o[s]=c,t(o);if(i>0)l=Math.floor(l/i)*i,c=Math.ceil(c/i)*i;else{if(!(i<0))break;l=Math.ceil(l*i)/i,c=Math.floor(c*i)/i}r=i}return e},e}function lp(e,t){var n,r=0,i=(e=e.slice()).length-1,o=e[r],a=e[i];return a0){for(;d<=h;++d)for(u=1,c=r(d);ul)break;m.push(f)}}else for(;d<=h;++d)for(u=a-1,c=r(d);u>=1;--u)if(!((f=c*u)l)break;m.push(f)}2*m.length0))return s;do{s.push(a=new Date(+n)),t(n,o),e(n)}while(a=t)for(;e(t),!n(t);)t.setTime(t-1)}),(function(e,r){if(e>=e)if(r<0)for(;++r<=0;)for(;t(e,-1),!n(e););else for(;--r>=0;)for(;t(e,1),!n(e););}))},n&&(i.count=function(t,r){return kp.setTime(+t),Sp.setTime(+r),e(kp),e(Sp),Math.floor(n(kp,Sp))},i.every=function(e){return e=Math.floor(e),isFinite(e)&&e>0?e>1?i.filter(r?function(t){return r(t)%e==0}:function(t){return i.count(0,t)%e==0}):i:null}),i}var Cp=Mp((function(){}),(function(e,t){e.setTime(+e+t)}),(function(e,t){return t-e}));Cp.every=function(e){return e=Math.floor(e),isFinite(e)&&e>0?e>1?Mp((function(t){t.setTime(Math.floor(t/e)*e)}),(function(t,n){t.setTime(+t+n*e)}),(function(t,n){return(n-t)/e})):Cp:null};var Np=Cp.range,Dp=1e3,Lp=6e4,Op=36e5,Ip=864e5,Bp=6048e5,Pp=Mp((function(e){e.setTime(e-e.getMilliseconds())}),(function(e,t){e.setTime(+e+t*Dp)}),(function(e,t){return(t-e)/Dp}),(function(e){return e.getUTCSeconds()})),jp=Pp.range,Rp=Mp((function(e){e.setTime(e-e.getMilliseconds()-e.getSeconds()*Dp)}),(function(e,t){e.setTime(+e+t*Lp)}),(function(e,t){return(t-e)/Lp}),(function(e){return e.getMinutes()})),zp=Rp.range,Fp=Mp((function(e){e.setTime(e-e.getMilliseconds()-e.getSeconds()*Dp-e.getMinutes()*Lp)}),(function(e,t){e.setTime(+e+t*Op)}),(function(e,t){return(t-e)/Op}),(function(e){return e.getHours()})),qp=Fp.range,Up=Mp((e=>e.setHours(0,0,0,0)),((e,t)=>e.setDate(e.getDate()+t)),((e,t)=>(t-e-(t.getTimezoneOffset()-e.getTimezoneOffset())*Lp)/Ip),(e=>e.getDate()-1)),Hp=Up.range;function Vp(e){return Mp((function(t){t.setDate(t.getDate()-(t.getDay()+7-e)%7),t.setHours(0,0,0,0)}),(function(e,t){e.setDate(e.getDate()+7*t)}),(function(e,t){return(t-e-(t.getTimezoneOffset()-e.getTimezoneOffset())*Lp)/Bp}))}var Gp=Vp(0),Wp=Vp(1),Yp=Vp(2),Zp=Vp(3),Kp=Vp(4),Xp=Vp(5),Qp=Vp(6),$p=Gp.range,Jp=Wp.range,em=Yp.range,tm=Zp.range,nm=Kp.range,rm=Xp.range,im=Qp.range,om=Mp((function(e){e.setDate(1),e.setHours(0,0,0,0)}),(function(e,t){e.setMonth(e.getMonth()+t)}),(function(e,t){return t.getMonth()-e.getMonth()+12*(t.getFullYear()-e.getFullYear())}),(function(e){return e.getMonth()})),am=om.range,sm=Mp((function(e){e.setMonth(0,1),e.setHours(0,0,0,0)}),(function(e,t){e.setFullYear(e.getFullYear()+t)}),(function(e,t){return t.getFullYear()-e.getFullYear()}),(function(e){return e.getFullYear()}));sm.every=function(e){return isFinite(e=Math.floor(e))&&e>0?Mp((function(t){t.setFullYear(Math.floor(t.getFullYear()/e)*e),t.setMonth(0,1),t.setHours(0,0,0,0)}),(function(t,n){t.setFullYear(t.getFullYear()+n*e)})):null};var lm=sm.range,cm=Mp((function(e){e.setUTCSeconds(0,0)}),(function(e,t){e.setTime(+e+t*Lp)}),(function(e,t){return(t-e)/Lp}),(function(e){return e.getUTCMinutes()})),um=cm.range,fm=Mp((function(e){e.setUTCMinutes(0,0,0)}),(function(e,t){e.setTime(+e+t*Op)}),(function(e,t){return(t-e)/Op}),(function(e){return e.getUTCHours()})),dm=fm.range,hm=Mp((function(e){e.setUTCHours(0,0,0,0)}),(function(e,t){e.setUTCDate(e.getUTCDate()+t)}),(function(e,t){return(t-e)/Ip}),(function(e){return e.getUTCDate()-1})),pm=hm.range;function mm(e){return Mp((function(t){t.setUTCDate(t.getUTCDate()-(t.getUTCDay()+7-e)%7),t.setUTCHours(0,0,0,0)}),(function(e,t){e.setUTCDate(e.getUTCDate()+7*t)}),(function(e,t){return(t-e)/Bp}))}var gm=mm(0),bm=mm(1),vm=mm(2),ym=mm(3),_m=mm(4),wm=mm(5),xm=mm(6),Tm=gm.range,Am=bm.range,Em=vm.range,km=ym.range,Sm=_m.range,Mm=wm.range,Cm=xm.range,Nm=Mp((function(e){e.setUTCDate(1),e.setUTCHours(0,0,0,0)}),(function(e,t){e.setUTCMonth(e.getUTCMonth()+t)}),(function(e,t){return t.getUTCMonth()-e.getUTCMonth()+12*(t.getUTCFullYear()-e.getUTCFullYear())}),(function(e){return e.getUTCMonth()})),Dm=Nm.range,Lm=Mp((function(e){e.setUTCMonth(0,1),e.setUTCHours(0,0,0,0)}),(function(e,t){e.setUTCFullYear(e.getUTCFullYear()+t)}),(function(e,t){return t.getUTCFullYear()-e.getUTCFullYear()}),(function(e){return e.getUTCFullYear()}));Lm.every=function(e){return isFinite(e=Math.floor(e))&&e>0?Mp((function(t){t.setUTCFullYear(Math.floor(t.getUTCFullYear()/e)*e),t.setUTCMonth(0,1),t.setUTCHours(0,0,0,0)}),(function(t,n){t.setUTCFullYear(t.getUTCFullYear()+n*e)})):null};var Om=Lm.range;function Im(e){if(0<=e.y&&e.y<100){var t=new Date(-1,e.m,e.d,e.H,e.M,e.S,e.L);return t.setFullYear(e.y),t}return new Date(e.y,e.m,e.d,e.H,e.M,e.S,e.L)}function Bm(e){if(0<=e.y&&e.y<100){var t=new Date(Date.UTC(-1,e.m,e.d,e.H,e.M,e.S,e.L));return t.setUTCFullYear(e.y),t}return new Date(Date.UTC(e.y,e.m,e.d,e.H,e.M,e.S,e.L))}function Pm(e,t,n){return{y:e,m:t,d:n,H:0,M:0,S:0,L:0}}function jm(e){var t=e.dateTime,n=e.date,r=e.time,i=e.periods,o=e.days,a=e.shortDays,s=e.months,l=e.shortMonths,c=Gm(i),u=Wm(i),f=Gm(o),d=Wm(o),h=Gm(a),p=Wm(a),m=Gm(s),g=Wm(s),b=Gm(l),v=Wm(l),y={a:function(e){return a[e.getDay()]},A:function(e){return o[e.getDay()]},b:function(e){return l[e.getMonth()]},B:function(e){return s[e.getMonth()]},c:null,d:hg,e:hg,f:vg,g:Cg,G:Dg,H:pg,I:mg,j:gg,L:bg,m:yg,M:_g,p:function(e){return i[+(e.getHours()>=12)]},q:function(e){return 1+~~(e.getMonth()/3)},Q:eb,s:tb,S:wg,u:xg,U:Tg,V:Eg,w:kg,W:Sg,x:null,X:null,y:Mg,Y:Ng,Z:Lg,"%":Jg},_={a:function(e){return a[e.getUTCDay()]},A:function(e){return o[e.getUTCDay()]},b:function(e){return l[e.getUTCMonth()]},B:function(e){return s[e.getUTCMonth()]},c:null,d:Og,e:Og,f:Rg,g:Kg,G:Qg,H:Ig,I:Bg,j:Pg,L:jg,m:zg,M:Fg,p:function(e){return i[+(e.getUTCHours()>=12)]},q:function(e){return 1+~~(e.getUTCMonth()/3)},Q:eb,s:tb,S:qg,u:Ug,U:Hg,V:Gg,w:Wg,W:Yg,x:null,X:null,y:Zg,Y:Xg,Z:$g,"%":Jg},w={a:function(e,t,n){var r=h.exec(t.slice(n));return r?(e.w=p.get(r[0].toLowerCase()),n+r[0].length):-1},A:function(e,t,n){var r=f.exec(t.slice(n));return r?(e.w=d.get(r[0].toLowerCase()),n+r[0].length):-1},b:function(e,t,n){var r=b.exec(t.slice(n));return r?(e.m=v.get(r[0].toLowerCase()),n+r[0].length):-1},B:function(e,t,n){var r=m.exec(t.slice(n));return r?(e.m=g.get(r[0].toLowerCase()),n+r[0].length):-1},c:function(e,n,r){return A(e,t,n,r)},d:rg,e:rg,f:cg,g:Jm,G:$m,H:og,I:og,j:ig,L:lg,m:ng,M:ag,p:function(e,t,n){var r=c.exec(t.slice(n));return r?(e.p=u.get(r[0].toLowerCase()),n+r[0].length):-1},q:tg,Q:fg,s:dg,S:sg,u:Zm,U:Km,V:Xm,w:Ym,W:Qm,x:function(e,t,r){return A(e,n,t,r)},X:function(e,t,n){return A(e,r,t,n)},y:Jm,Y:$m,Z:eg,"%":ug};function x(e,t){return function(n){var r,i,o,a=[],s=-1,l=0,c=e.length;for(n instanceof Date||(n=new Date(+n));++s53)return null;"w"in o||(o.w=1),"Z"in o?(i=(r=Bm(Pm(o.y,0,1))).getUTCDay(),r=i>4||0===i?bm.ceil(r):bm(r),r=hm.offset(r,7*(o.V-1)),o.y=r.getUTCFullYear(),o.m=r.getUTCMonth(),o.d=r.getUTCDate()+(o.w+6)%7):(i=(r=Im(Pm(o.y,0,1))).getDay(),r=i>4||0===i?Wp.ceil(r):Wp(r),r=Up.offset(r,7*(o.V-1)),o.y=r.getFullYear(),o.m=r.getMonth(),o.d=r.getDate()+(o.w+6)%7)}else("W"in o||"U"in o)&&("w"in o||(o.w="u"in o?o.u%7:"W"in o?1:0),i="Z"in o?Bm(Pm(o.y,0,1)).getUTCDay():Im(Pm(o.y,0,1)).getDay(),o.m=0,o.d="W"in o?(o.w+6)%7+7*o.W-(i+5)%7:o.w+7*o.U-(i+6)%7);return"Z"in o?(o.H+=o.Z/100|0,o.M+=o.Z%100,Bm(o)):Im(o)}}function A(e,t,n,r){for(var i,o,a=0,s=t.length,l=n.length;a=l)return-1;if(37===(i=t.charCodeAt(a++))){if(i=t.charAt(a++),!(o=w[i in zm?t.charAt(a++):i])||(r=o(e,n,r))<0)return-1}else if(i!=n.charCodeAt(r++))return-1}return r}return y.x=x(n,y),y.X=x(r,y),y.c=x(t,y),_.x=x(n,_),_.X=x(r,_),_.c=x(t,_),{format:function(e){var t=x(e+="",y);return t.toString=function(){return e},t},parse:function(e){var t=T(e+="",!1);return t.toString=function(){return e},t},utcFormat:function(e){var t=x(e+="",_);return t.toString=function(){return e},t},utcParse:function(e){var t=T(e+="",!0);return t.toString=function(){return e},t}}}var Rm,zm={"-":"",_:" ",0:"0"},Fm=/^\s*\d+/,qm=/^%/,Um=/[\\^$*+?|[\]().{}]/g;function Hm(e,t,n){var r=e<0?"-":"",i=(r?-e:e)+"",o=i.length;return r+(o[e.toLowerCase(),t])))}function Ym(e,t,n){var r=Fm.exec(t.slice(n,n+1));return r?(e.w=+r[0],n+r[0].length):-1}function Zm(e,t,n){var r=Fm.exec(t.slice(n,n+1));return r?(e.u=+r[0],n+r[0].length):-1}function Km(e,t,n){var r=Fm.exec(t.slice(n,n+2));return r?(e.U=+r[0],n+r[0].length):-1}function Xm(e,t,n){var r=Fm.exec(t.slice(n,n+2));return r?(e.V=+r[0],n+r[0].length):-1}function Qm(e,t,n){var r=Fm.exec(t.slice(n,n+2));return r?(e.W=+r[0],n+r[0].length):-1}function $m(e,t,n){var r=Fm.exec(t.slice(n,n+4));return r?(e.y=+r[0],n+r[0].length):-1}function Jm(e,t,n){var r=Fm.exec(t.slice(n,n+2));return r?(e.y=+r[0]+(+r[0]>68?1900:2e3),n+r[0].length):-1}function eg(e,t,n){var r=/^(Z)|([+-]\d\d)(?::?(\d\d))?/.exec(t.slice(n,n+6));return r?(e.Z=r[1]?0:-(r[2]+(r[3]||"00")),n+r[0].length):-1}function tg(e,t,n){var r=Fm.exec(t.slice(n,n+1));return r?(e.q=3*r[0]-3,n+r[0].length):-1}function ng(e,t,n){var r=Fm.exec(t.slice(n,n+2));return r?(e.m=r[0]-1,n+r[0].length):-1}function rg(e,t,n){var r=Fm.exec(t.slice(n,n+2));return r?(e.d=+r[0],n+r[0].length):-1}function ig(e,t,n){var r=Fm.exec(t.slice(n,n+3));return r?(e.m=0,e.d=+r[0],n+r[0].length):-1}function og(e,t,n){var r=Fm.exec(t.slice(n,n+2));return r?(e.H=+r[0],n+r[0].length):-1}function ag(e,t,n){var r=Fm.exec(t.slice(n,n+2));return r?(e.M=+r[0],n+r[0].length):-1}function sg(e,t,n){var r=Fm.exec(t.slice(n,n+2));return r?(e.S=+r[0],n+r[0].length):-1}function lg(e,t,n){var r=Fm.exec(t.slice(n,n+3));return r?(e.L=+r[0],n+r[0].length):-1}function cg(e,t,n){var r=Fm.exec(t.slice(n,n+6));return r?(e.L=Math.floor(r[0]/1e3),n+r[0].length):-1}function ug(e,t,n){var r=qm.exec(t.slice(n,n+1));return r?n+r[0].length:-1}function fg(e,t,n){var r=Fm.exec(t.slice(n));return r?(e.Q=+r[0],n+r[0].length):-1}function dg(e,t,n){var r=Fm.exec(t.slice(n));return r?(e.s=+r[0],n+r[0].length):-1}function hg(e,t){return Hm(e.getDate(),t,2)}function pg(e,t){return Hm(e.getHours(),t,2)}function mg(e,t){return Hm(e.getHours()%12||12,t,2)}function gg(e,t){return Hm(1+Up.count(sm(e),e),t,3)}function bg(e,t){return Hm(e.getMilliseconds(),t,3)}function vg(e,t){return bg(e,t)+"000"}function yg(e,t){return Hm(e.getMonth()+1,t,2)}function _g(e,t){return Hm(e.getMinutes(),t,2)}function wg(e,t){return Hm(e.getSeconds(),t,2)}function xg(e){var t=e.getDay();return 0===t?7:t}function Tg(e,t){return Hm(Gp.count(sm(e)-1,e),t,2)}function Ag(e){var t=e.getDay();return t>=4||0===t?Kp(e):Kp.ceil(e)}function Eg(e,t){return e=Ag(e),Hm(Kp.count(sm(e),e)+(4===sm(e).getDay()),t,2)}function kg(e){return e.getDay()}function Sg(e,t){return Hm(Wp.count(sm(e)-1,e),t,2)}function Mg(e,t){return Hm(e.getFullYear()%100,t,2)}function Cg(e,t){return Hm((e=Ag(e)).getFullYear()%100,t,2)}function Ng(e,t){return Hm(e.getFullYear()%1e4,t,4)}function Dg(e,t){var n=e.getDay();return Hm((e=n>=4||0===n?Kp(e):Kp.ceil(e)).getFullYear()%1e4,t,4)}function Lg(e){var t=e.getTimezoneOffset();return(t>0?"-":(t*=-1,"+"))+Hm(t/60|0,"0",2)+Hm(t%60,"0",2)}function Og(e,t){return Hm(e.getUTCDate(),t,2)}function Ig(e,t){return Hm(e.getUTCHours(),t,2)}function Bg(e,t){return Hm(e.getUTCHours()%12||12,t,2)}function Pg(e,t){return Hm(1+hm.count(Lm(e),e),t,3)}function jg(e,t){return Hm(e.getUTCMilliseconds(),t,3)}function Rg(e,t){return jg(e,t)+"000"}function zg(e,t){return Hm(e.getUTCMonth()+1,t,2)}function Fg(e,t){return Hm(e.getUTCMinutes(),t,2)}function qg(e,t){return Hm(e.getUTCSeconds(),t,2)}function Ug(e){var t=e.getUTCDay();return 0===t?7:t}function Hg(e,t){return Hm(gm.count(Lm(e)-1,e),t,2)}function Vg(e){var t=e.getUTCDay();return t>=4||0===t?_m(e):_m.ceil(e)}function Gg(e,t){return e=Vg(e),Hm(_m.count(Lm(e),e)+(4===Lm(e).getUTCDay()),t,2)}function Wg(e){return e.getUTCDay()}function Yg(e,t){return Hm(bm.count(Lm(e)-1,e),t,2)}function Zg(e,t){return Hm(e.getUTCFullYear()%100,t,2)}function Kg(e,t){return Hm((e=Vg(e)).getUTCFullYear()%100,t,2)}function Xg(e,t){return Hm(e.getUTCFullYear()%1e4,t,4)}function Qg(e,t){var n=e.getUTCDay();return Hm((e=n>=4||0===n?_m(e):_m.ceil(e)).getUTCFullYear()%1e4,t,4)}function $g(){return"+0000"}function Jg(){return"%"}function eb(e){return+e}function tb(e){return Math.floor(+e/1e3)}function nb(t){return Rm=jm(t),e.timeFormat=Rm.format,e.timeParse=Rm.parse,e.utcFormat=Rm.utcFormat,e.utcParse=Rm.utcParse,Rm}nb({dateTime:"%x, %X",date:"%-m/%-d/%Y",time:"%-I:%M:%S %p",periods:["AM","PM"],days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],shortDays:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],shortMonths:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]});var rb="%Y-%m-%dT%H:%M:%S.%LZ",ib=Date.prototype.toISOString?function(e){return e.toISOString()}:e.utcFormat(rb),ob=+new Date("2000-01-01T00:00:00.000Z")?function(e){var t=new Date(e);return isNaN(t)?null:t}:e.utcParse(rb),ab=31536e6;function sb(e){return new Date(e)}function lb(e){return e instanceof Date?+e:+new Date(+e)}function cb(e,t,r,i,o,a,s,l,c){var u=op(),f=u.invert,d=u.domain,h=c(".%L"),p=c(":%S"),m=c("%I:%M"),g=c("%I %p"),b=c("%a %d"),v=c("%b %d"),y=c("%B"),_=c("%Y"),w=[[s,1,1e3],[s,5,5e3],[s,15,15e3],[s,30,3e4],[a,1,6e4],[a,5,3e5],[a,15,9e5],[a,30,18e5],[o,1,36e5],[o,3,108e5],[o,6,216e5],[o,12,432e5],[i,1,864e5],[i,2,1728e5],[r,1,6048e5],[t,1,2592e6],[t,3,7776e6],[e,1,ab]];function x(n){return(s(n)nr(e[e.length-1]),Sb=new Array(3).concat("d8b365f5f5f55ab4ac","a6611adfc27d80cdc1018571","a6611adfc27df5f5f580cdc1018571","8c510ad8b365f6e8c3c7eae55ab4ac01665e","8c510ad8b365f6e8c3f5f5f5c7eae55ab4ac01665e","8c510abf812ddfc27df6e8c3c7eae580cdc135978f01665e","8c510abf812ddfc27df6e8c3f5f5f5c7eae580cdc135978f01665e","5430058c510abf812ddfc27df6e8c3c7eae580cdc135978f01665e003c30","5430058c510abf812ddfc27df6e8c3f5f5f5c7eae580cdc135978f01665e003c30").map(mb),Mb=kb(Sb),Cb=new Array(3).concat("af8dc3f7f7f77fbf7b","7b3294c2a5cfa6dba0008837","7b3294c2a5cff7f7f7a6dba0008837","762a83af8dc3e7d4e8d9f0d37fbf7b1b7837","762a83af8dc3e7d4e8f7f7f7d9f0d37fbf7b1b7837","762a839970abc2a5cfe7d4e8d9f0d3a6dba05aae611b7837","762a839970abc2a5cfe7d4e8f7f7f7d9f0d3a6dba05aae611b7837","40004b762a839970abc2a5cfe7d4e8d9f0d3a6dba05aae611b783700441b","40004b762a839970abc2a5cfe7d4e8f7f7f7d9f0d3a6dba05aae611b783700441b").map(mb),Nb=kb(Cb),Db=new Array(3).concat("e9a3c9f7f7f7a1d76a","d01c8bf1b6dab8e1864dac26","d01c8bf1b6daf7f7f7b8e1864dac26","c51b7de9a3c9fde0efe6f5d0a1d76a4d9221","c51b7de9a3c9fde0eff7f7f7e6f5d0a1d76a4d9221","c51b7dde77aef1b6dafde0efe6f5d0b8e1867fbc414d9221","c51b7dde77aef1b6dafde0eff7f7f7e6f5d0b8e1867fbc414d9221","8e0152c51b7dde77aef1b6dafde0efe6f5d0b8e1867fbc414d9221276419","8e0152c51b7dde77aef1b6dafde0eff7f7f7e6f5d0b8e1867fbc414d9221276419").map(mb),Lb=kb(Db),Ob=new Array(3).concat("998ec3f7f7f7f1a340","5e3c99b2abd2fdb863e66101","5e3c99b2abd2f7f7f7fdb863e66101","542788998ec3d8daebfee0b6f1a340b35806","542788998ec3d8daebf7f7f7fee0b6f1a340b35806","5427888073acb2abd2d8daebfee0b6fdb863e08214b35806","5427888073acb2abd2d8daebf7f7f7fee0b6fdb863e08214b35806","2d004b5427888073acb2abd2d8daebfee0b6fdb863e08214b358067f3b08","2d004b5427888073acb2abd2d8daebf7f7f7fee0b6fdb863e08214b358067f3b08").map(mb),Ib=kb(Ob),Bb=new Array(3).concat("ef8a62f7f7f767a9cf","ca0020f4a58292c5de0571b0","ca0020f4a582f7f7f792c5de0571b0","b2182bef8a62fddbc7d1e5f067a9cf2166ac","b2182bef8a62fddbc7f7f7f7d1e5f067a9cf2166ac","b2182bd6604df4a582fddbc7d1e5f092c5de4393c32166ac","b2182bd6604df4a582fddbc7f7f7f7d1e5f092c5de4393c32166ac","67001fb2182bd6604df4a582fddbc7d1e5f092c5de4393c32166ac053061","67001fb2182bd6604df4a582fddbc7f7f7f7d1e5f092c5de4393c32166ac053061").map(mb),Pb=kb(Bb),jb=new Array(3).concat("ef8a62ffffff999999","ca0020f4a582bababa404040","ca0020f4a582ffffffbababa404040","b2182bef8a62fddbc7e0e0e09999994d4d4d","b2182bef8a62fddbc7ffffffe0e0e09999994d4d4d","b2182bd6604df4a582fddbc7e0e0e0bababa8787874d4d4d","b2182bd6604df4a582fddbc7ffffffe0e0e0bababa8787874d4d4d","67001fb2182bd6604df4a582fddbc7e0e0e0bababa8787874d4d4d1a1a1a","67001fb2182bd6604df4a582fddbc7ffffffe0e0e0bababa8787874d4d4d1a1a1a").map(mb),Rb=kb(jb),zb=new Array(3).concat("fc8d59ffffbf91bfdb","d7191cfdae61abd9e92c7bb6","d7191cfdae61ffffbfabd9e92c7bb6","d73027fc8d59fee090e0f3f891bfdb4575b4","d73027fc8d59fee090ffffbfe0f3f891bfdb4575b4","d73027f46d43fdae61fee090e0f3f8abd9e974add14575b4","d73027f46d43fdae61fee090ffffbfe0f3f8abd9e974add14575b4","a50026d73027f46d43fdae61fee090e0f3f8abd9e974add14575b4313695","a50026d73027f46d43fdae61fee090ffffbfe0f3f8abd9e974add14575b4313695").map(mb),Fb=kb(zb),qb=new Array(3).concat("fc8d59ffffbf91cf60","d7191cfdae61a6d96a1a9641","d7191cfdae61ffffbfa6d96a1a9641","d73027fc8d59fee08bd9ef8b91cf601a9850","d73027fc8d59fee08bffffbfd9ef8b91cf601a9850","d73027f46d43fdae61fee08bd9ef8ba6d96a66bd631a9850","d73027f46d43fdae61fee08bffffbfd9ef8ba6d96a66bd631a9850","a50026d73027f46d43fdae61fee08bd9ef8ba6d96a66bd631a9850006837","a50026d73027f46d43fdae61fee08bffffbfd9ef8ba6d96a66bd631a9850006837").map(mb),Ub=kb(qb),Hb=new Array(3).concat("fc8d59ffffbf99d594","d7191cfdae61abdda42b83ba","d7191cfdae61ffffbfabdda42b83ba","d53e4ffc8d59fee08be6f59899d5943288bd","d53e4ffc8d59fee08bffffbfe6f59899d5943288bd","d53e4ff46d43fdae61fee08be6f598abdda466c2a53288bd","d53e4ff46d43fdae61fee08bffffbfe6f598abdda466c2a53288bd","9e0142d53e4ff46d43fdae61fee08be6f598abdda466c2a53288bd5e4fa2","9e0142d53e4ff46d43fdae61fee08bffffbfe6f598abdda466c2a53288bd5e4fa2").map(mb),Vb=kb(Hb),Gb=new Array(3).concat("e5f5f999d8c92ca25f","edf8fbb2e2e266c2a4238b45","edf8fbb2e2e266c2a42ca25f006d2c","edf8fbccece699d8c966c2a42ca25f006d2c","edf8fbccece699d8c966c2a441ae76238b45005824","f7fcfde5f5f9ccece699d8c966c2a441ae76238b45005824","f7fcfde5f5f9ccece699d8c966c2a441ae76238b45006d2c00441b").map(mb),Wb=kb(Gb),Yb=new Array(3).concat("e0ecf49ebcda8856a7","edf8fbb3cde38c96c688419d","edf8fbb3cde38c96c68856a7810f7c","edf8fbbfd3e69ebcda8c96c68856a7810f7c","edf8fbbfd3e69ebcda8c96c68c6bb188419d6e016b","f7fcfde0ecf4bfd3e69ebcda8c96c68c6bb188419d6e016b","f7fcfde0ecf4bfd3e69ebcda8c96c68c6bb188419d810f7c4d004b").map(mb),Zb=kb(Yb),Kb=new Array(3).concat("e0f3dba8ddb543a2ca","f0f9e8bae4bc7bccc42b8cbe","f0f9e8bae4bc7bccc443a2ca0868ac","f0f9e8ccebc5a8ddb57bccc443a2ca0868ac","f0f9e8ccebc5a8ddb57bccc44eb3d32b8cbe08589e","f7fcf0e0f3dbccebc5a8ddb57bccc44eb3d32b8cbe08589e","f7fcf0e0f3dbccebc5a8ddb57bccc44eb3d32b8cbe0868ac084081").map(mb),Xb=kb(Kb),Qb=new Array(3).concat("fee8c8fdbb84e34a33","fef0d9fdcc8afc8d59d7301f","fef0d9fdcc8afc8d59e34a33b30000","fef0d9fdd49efdbb84fc8d59e34a33b30000","fef0d9fdd49efdbb84fc8d59ef6548d7301f990000","fff7ecfee8c8fdd49efdbb84fc8d59ef6548d7301f990000","fff7ecfee8c8fdd49efdbb84fc8d59ef6548d7301fb300007f0000").map(mb),$b=kb(Qb),Jb=new Array(3).concat("ece2f0a6bddb1c9099","f6eff7bdc9e167a9cf02818a","f6eff7bdc9e167a9cf1c9099016c59","f6eff7d0d1e6a6bddb67a9cf1c9099016c59","f6eff7d0d1e6a6bddb67a9cf3690c002818a016450","fff7fbece2f0d0d1e6a6bddb67a9cf3690c002818a016450","fff7fbece2f0d0d1e6a6bddb67a9cf3690c002818a016c59014636").map(mb),ev=kb(Jb),tv=new Array(3).concat("ece7f2a6bddb2b8cbe","f1eef6bdc9e174a9cf0570b0","f1eef6bdc9e174a9cf2b8cbe045a8d","f1eef6d0d1e6a6bddb74a9cf2b8cbe045a8d","f1eef6d0d1e6a6bddb74a9cf3690c00570b0034e7b","fff7fbece7f2d0d1e6a6bddb74a9cf3690c00570b0034e7b","fff7fbece7f2d0d1e6a6bddb74a9cf3690c00570b0045a8d023858").map(mb),nv=kb(tv),rv=new Array(3).concat("e7e1efc994c7dd1c77","f1eef6d7b5d8df65b0ce1256","f1eef6d7b5d8df65b0dd1c77980043","f1eef6d4b9dac994c7df65b0dd1c77980043","f1eef6d4b9dac994c7df65b0e7298ace125691003f","f7f4f9e7e1efd4b9dac994c7df65b0e7298ace125691003f","f7f4f9e7e1efd4b9dac994c7df65b0e7298ace125698004367001f").map(mb),iv=kb(rv),ov=new Array(3).concat("fde0ddfa9fb5c51b8a","feebe2fbb4b9f768a1ae017e","feebe2fbb4b9f768a1c51b8a7a0177","feebe2fcc5c0fa9fb5f768a1c51b8a7a0177","feebe2fcc5c0fa9fb5f768a1dd3497ae017e7a0177","fff7f3fde0ddfcc5c0fa9fb5f768a1dd3497ae017e7a0177","fff7f3fde0ddfcc5c0fa9fb5f768a1dd3497ae017e7a017749006a").map(mb),av=kb(ov),sv=new Array(3).concat("edf8b17fcdbb2c7fb8","ffffcca1dab441b6c4225ea8","ffffcca1dab441b6c42c7fb8253494","ffffccc7e9b47fcdbb41b6c42c7fb8253494","ffffccc7e9b47fcdbb41b6c41d91c0225ea80c2c84","ffffd9edf8b1c7e9b47fcdbb41b6c41d91c0225ea80c2c84","ffffd9edf8b1c7e9b47fcdbb41b6c41d91c0225ea8253494081d58").map(mb),lv=kb(sv),cv=new Array(3).concat("f7fcb9addd8e31a354","ffffccc2e69978c679238443","ffffccc2e69978c67931a354006837","ffffccd9f0a3addd8e78c67931a354006837","ffffccd9f0a3addd8e78c67941ab5d238443005a32","ffffe5f7fcb9d9f0a3addd8e78c67941ab5d238443005a32","ffffe5f7fcb9d9f0a3addd8e78c67941ab5d238443006837004529").map(mb),uv=kb(cv),fv=new Array(3).concat("fff7bcfec44fd95f0e","ffffd4fed98efe9929cc4c02","ffffd4fed98efe9929d95f0e993404","ffffd4fee391fec44ffe9929d95f0e993404","ffffd4fee391fec44ffe9929ec7014cc4c028c2d04","ffffe5fff7bcfee391fec44ffe9929ec7014cc4c028c2d04","ffffe5fff7bcfee391fec44ffe9929ec7014cc4c02993404662506").map(mb),dv=kb(fv),hv=new Array(3).concat("ffeda0feb24cf03b20","ffffb2fecc5cfd8d3ce31a1c","ffffb2fecc5cfd8d3cf03b20bd0026","ffffb2fed976feb24cfd8d3cf03b20bd0026","ffffb2fed976feb24cfd8d3cfc4e2ae31a1cb10026","ffffccffeda0fed976feb24cfd8d3cfc4e2ae31a1cb10026","ffffccffeda0fed976feb24cfd8d3cfc4e2ae31a1cbd0026800026").map(mb),pv=kb(hv),mv=new Array(3).concat("deebf79ecae13182bd","eff3ffbdd7e76baed62171b5","eff3ffbdd7e76baed63182bd08519c","eff3ffc6dbef9ecae16baed63182bd08519c","eff3ffc6dbef9ecae16baed64292c62171b5084594","f7fbffdeebf7c6dbef9ecae16baed64292c62171b5084594","f7fbffdeebf7c6dbef9ecae16baed64292c62171b508519c08306b").map(mb),gv=kb(mv),bv=new Array(3).concat("e5f5e0a1d99b31a354","edf8e9bae4b374c476238b45","edf8e9bae4b374c47631a354006d2c","edf8e9c7e9c0a1d99b74c47631a354006d2c","edf8e9c7e9c0a1d99b74c47641ab5d238b45005a32","f7fcf5e5f5e0c7e9c0a1d99b74c47641ab5d238b45005a32","f7fcf5e5f5e0c7e9c0a1d99b74c47641ab5d238b45006d2c00441b").map(mb),vv=kb(bv),yv=new Array(3).concat("f0f0f0bdbdbd636363","f7f7f7cccccc969696525252","f7f7f7cccccc969696636363252525","f7f7f7d9d9d9bdbdbd969696636363252525","f7f7f7d9d9d9bdbdbd969696737373525252252525","fffffff0f0f0d9d9d9bdbdbd969696737373525252252525","fffffff0f0f0d9d9d9bdbdbd969696737373525252252525000000").map(mb),_v=kb(yv),wv=new Array(3).concat("efedf5bcbddc756bb1","f2f0f7cbc9e29e9ac86a51a3","f2f0f7cbc9e29e9ac8756bb154278f","f2f0f7dadaebbcbddc9e9ac8756bb154278f","f2f0f7dadaebbcbddc9e9ac8807dba6a51a34a1486","fcfbfdefedf5dadaebbcbddc9e9ac8807dba6a51a34a1486","fcfbfdefedf5dadaebbcbddc9e9ac8807dba6a51a354278f3f007d").map(mb),xv=kb(wv),Tv=new Array(3).concat("fee0d2fc9272de2d26","fee5d9fcae91fb6a4acb181d","fee5d9fcae91fb6a4ade2d26a50f15","fee5d9fcbba1fc9272fb6a4ade2d26a50f15","fee5d9fcbba1fc9272fb6a4aef3b2ccb181d99000d","fff5f0fee0d2fcbba1fc9272fb6a4aef3b2ccb181d99000d","fff5f0fee0d2fcbba1fc9272fb6a4aef3b2ccb181da50f1567000d").map(mb),Av=kb(Tv),Ev=new Array(3).concat("fee6cefdae6be6550d","feeddefdbe85fd8d3cd94701","feeddefdbe85fd8d3ce6550da63603","feeddefdd0a2fdae6bfd8d3ce6550da63603","feeddefdd0a2fdae6bfd8d3cf16913d948018c2d04","fff5ebfee6cefdd0a2fdae6bfd8d3cf16913d948018c2d04","fff5ebfee6cefdd0a2fdae6bfd8d3cf16913d94801a636037f2704").map(mb),kv=kb(Ev),Sv=Lr(Gn(300,.5,0),Gn(-240,.5,1)),Mv=Lr(Gn(-100,.75,.35),Gn(80,1.5,.8)),Cv=Lr(Gn(260,.75,.35),Gn(80,1.5,.8)),Nv=Gn(),Dv=ln(),Lv=Math.PI/3,Ov=2*Math.PI/3;function Iv(e){var t=e.length;return function(n){return e[Math.max(0,Math.min(t-1,Math.floor(n*t)))]}}var Bv=Iv(mb("44015444025645045745055946075a46085c460a5d460b5e470d60470e6147106347116447136548146748166848176948186a481a6c481b6d481c6e481d6f481f70482071482173482374482475482576482677482878482979472a7a472c7a472d7b472e7c472f7d46307e46327e46337f463480453581453781453882443983443a83443b84433d84433e85423f854240864241864142874144874045884046883f47883f48893e49893e4a893e4c8a3d4d8a3d4e8a3c4f8a3c508b3b518b3b528b3a538b3a548c39558c39568c38588c38598c375a8c375b8d365c8d365d8d355e8d355f8d34608d34618d33628d33638d32648e32658e31668e31678e31688e30698e306a8e2f6b8e2f6c8e2e6d8e2e6e8e2e6f8e2d708e2d718e2c718e2c728e2c738e2b748e2b758e2a768e2a778e2a788e29798e297a8e297b8e287c8e287d8e277e8e277f8e27808e26818e26828e26828e25838e25848e25858e24868e24878e23888e23898e238a8d228b8d228c8d228d8d218e8d218f8d21908d21918c20928c20928c20938c1f948c1f958b1f968b1f978b1f988b1f998a1f9a8a1e9b8a1e9c891e9d891f9e891f9f881fa0881fa1881fa1871fa28720a38620a48621a58521a68522a78522a88423a98324aa8325ab8225ac8226ad8127ad8128ae8029af7f2ab07f2cb17e2db27d2eb37c2fb47c31b57b32b67a34b67935b77937b87838b9773aba763bbb753dbc743fbc7340bd7242be7144bf7046c06f48c16e4ac16d4cc26c4ec36b50c46a52c56954c56856c66758c7655ac8645cc8635ec96260ca6063cb5f65cb5e67cc5c69cd5b6ccd5a6ece5870cf5773d05675d05477d1537ad1517cd2507fd34e81d34d84d44b86d54989d5488bd6468ed64590d74393d74195d84098d83e9bd93c9dd93ba0da39a2da37a5db36a8db34aadc32addc30b0dd2fb2dd2db5de2bb8de29bade28bddf26c0df25c2df23c5e021c8e020cae11fcde11dd0e11cd2e21bd5e21ad8e219dae319dde318dfe318e2e418e5e419e7e419eae51aece51befe51cf1e51df4e61ef6e620f8e621fbe723fde725")),Pv=Iv(mb("00000401000501010601010802010902020b02020d03030f03031204041405041606051806051a07061c08071e0907200a08220b09240c09260d0a290e0b2b100b2d110c2f120d31130d34140e36150e38160f3b180f3d19103f1a10421c10441d11471e114920114b21114e22115024125325125527125829115a2a115c2c115f2d11612f116331116533106734106936106b38106c390f6e3b0f703d0f713f0f72400f74420f75440f764510774710784910784a10794c117a4e117b4f127b51127c52137c54137d56147d57157e59157e5a167e5c167f5d177f5f187f601880621980641a80651a80671b80681c816a1c816b1d816d1d816e1e81701f81721f817320817521817621817822817922827b23827c23827e24828025828125818326818426818627818827818928818b29818c29818e2a81902a81912b81932b80942c80962c80982d80992d809b2e7f9c2e7f9e2f7fa02f7fa1307ea3307ea5317ea6317da8327daa337dab337cad347cae347bb0357bb2357bb3367ab5367ab73779b83779ba3878bc3978bd3977bf3a77c03a76c23b75c43c75c53c74c73d73c83e73ca3e72cc3f71cd4071cf4070d0416fd2426fd3436ed5446dd6456cd8456cd9466bdb476adc4869de4968df4a68e04c67e24d66e34e65e44f64e55064e75263e85362e95462ea5661eb5760ec5860ed5a5fee5b5eef5d5ef05f5ef1605df2625df2645cf3655cf4675cf4695cf56b5cf66c5cf66e5cf7705cf7725cf8745cf8765cf9785df9795df97b5dfa7d5efa7f5efa815ffb835ffb8560fb8761fc8961fc8a62fc8c63fc8e64fc9065fd9266fd9467fd9668fd9869fd9a6afd9b6bfe9d6cfe9f6dfea16efea36ffea571fea772fea973feaa74feac76feae77feb078feb27afeb47bfeb67cfeb77efeb97ffebb81febd82febf84fec185fec287fec488fec68afec88cfeca8dfecc8ffecd90fecf92fed194fed395fed597fed799fed89afdda9cfddc9efddea0fde0a1fde2a3fde3a5fde5a7fde7a9fde9aafdebacfcecaefceeb0fcf0b2fcf2b4fcf4b6fcf6b8fcf7b9fcf9bbfcfbbdfcfdbf")),jv=Iv(mb("00000401000501010601010802010a02020c02020e03021004031204031405041706041907051b08051d09061f0a07220b07240c08260d08290e092b10092d110a30120a32140b34150b37160b39180c3c190c3e1b0c411c0c431e0c451f0c48210c4a230c4c240c4f260c51280b53290b552b0b572d0b592f0a5b310a5c320a5e340a5f3609613809623909633b09643d09653e0966400a67420a68440a68450a69470b6a490b6a4a0c6b4c0c6b4d0d6c4f0d6c510e6c520e6d540f6d550f6d57106e59106e5a116e5c126e5d126e5f136e61136e62146e64156e65156e67166e69166e6a176e6c186e6d186e6f196e71196e721a6e741a6e751b6e771c6d781c6d7a1d6d7c1d6d7d1e6d7f1e6c801f6c82206c84206b85216b87216b88226a8a226a8c23698d23698f24699025689225689326679526679727669827669a28659b29649d29649f2a63a02a63a22b62a32c61a52c60a62d60a82e5fa92e5eab2f5ead305dae305cb0315bb1325ab3325ab43359b63458b73557b93556ba3655bc3754bd3853bf3952c03a51c13a50c33b4fc43c4ec63d4dc73e4cc83f4bca404acb4149cc4248ce4347cf4446d04545d24644d34743d44842d54a41d74b3fd84c3ed94d3dda4e3cdb503bdd513ade5238df5337e05536e15635e25734e35933e45a31e55c30e65d2fe75e2ee8602de9612bea632aeb6429eb6628ec6726ed6925ee6a24ef6c23ef6e21f06f20f1711ff1731df2741cf3761bf37819f47918f57b17f57d15f67e14f68013f78212f78410f8850ff8870ef8890cf98b0bf98c0af98e09fa9008fa9207fa9407fb9606fb9706fb9906fb9b06fb9d07fc9f07fca108fca309fca50afca60cfca80dfcaa0ffcac11fcae12fcb014fcb216fcb418fbb61afbb81dfbba1ffbbc21fbbe23fac026fac228fac42afac62df9c72ff9c932f9cb35f8cd37f8cf3af7d13df7d340f6d543f6d746f5d949f5db4cf4dd4ff4df53f4e156f3e35af3e55df2e661f2e865f2ea69f1ec6df1ed71f1ef75f1f179f2f27df2f482f3f586f3f68af4f88ef5f992f6fa96f8fb9af9fc9dfafda1fcffa4")),Rv=Iv(mb("0d088710078813078916078a19068c1b068d1d068e20068f2206902406912605912805922a05932c05942e05952f059631059733059735049837049938049a3a049a3c049b3e049c3f049c41049d43039e44039e46039f48039f4903a04b03a14c02a14e02a25002a25102a35302a35502a45601a45801a45901a55b01a55c01a65e01a66001a66100a76300a76400a76600a76700a86900a86a00a86c00a86e00a86f00a87100a87201a87401a87501a87701a87801a87a02a87b02a87d03a87e03a88004a88104a78305a78405a78606a68707a68808a68a09a58b0aa58d0ba58e0ca48f0da4910ea3920fa39410a29511a19613a19814a099159f9a169f9c179e9d189d9e199da01a9ca11b9ba21d9aa31e9aa51f99a62098a72197a82296aa2395ab2494ac2694ad2793ae2892b02991b12a90b22b8fb32c8eb42e8db52f8cb6308bb7318ab83289ba3388bb3488bc3587bd3786be3885bf3984c03a83c13b82c23c81c33d80c43e7fc5407ec6417dc7427cc8437bc9447aca457acb4679cc4778cc4977cd4a76ce4b75cf4c74d04d73d14e72d24f71d35171d45270d5536fd5546ed6556dd7566cd8576bd9586ada5a6ada5b69db5c68dc5d67dd5e66de5f65de6164df6263e06363e16462e26561e26660e3685fe4695ee56a5de56b5de66c5ce76e5be76f5ae87059e97158e97257ea7457eb7556eb7655ec7754ed7953ed7a52ee7b51ef7c51ef7e50f07f4ff0804ef1814df1834cf2844bf3854bf3874af48849f48948f58b47f58c46f68d45f68f44f79044f79143f79342f89441f89540f9973ff9983ef99a3efa9b3dfa9c3cfa9e3bfb9f3afba139fba238fca338fca537fca636fca835fca934fdab33fdac33fdae32fdaf31fdb130fdb22ffdb42ffdb52efeb72dfeb82cfeba2cfebb2bfebd2afebe2afec029fdc229fdc328fdc527fdc627fdc827fdca26fdcb26fccd25fcce25fcd025fcd225fbd324fbd524fbd724fad824fada24f9dc24f9dd25f8df25f8e125f7e225f7e425f6e626f6e826f5e926f5eb27f4ed27f3ee27f3f027f2f227f1f426f1f525f0f724f0f921"));function zv(e){return function(){return e}}var Fv=Math.abs,qv=Math.atan2,Uv=Math.cos,Hv=Math.max,Vv=Math.min,Gv=Math.sin,Wv=Math.sqrt,Yv=1e-12,Zv=Math.PI,Kv=Zv/2,Xv=2*Zv;function Qv(e){return e>1?0:e<-1?Zv:Math.acos(e)}function $v(e){return e>=1?Kv:e<=-1?-Kv:Math.asin(e)}function Jv(e){return e.innerRadius}function ey(e){return e.outerRadius}function ty(e){return e.startAngle}function ny(e){return e.endAngle}function ry(e){return e&&e.padAngle}function iy(e,t,n,r,i,o,a,s){var l=n-e,c=r-t,u=a-i,f=s-o,d=f*l-u*c;if(!(d*dN*N+D*D&&(A=k,E=S),{cx:A,cy:E,x01:-u,y01:-f,x11:A*(i/w-1),y11:E*(i/w-1)}}var ay=Array.prototype.slice;function sy(e){return"object"==typeof e&&"length"in e?e:Array.from(e)}function ly(e){this._context=e}function cy(e){return new ly(e)}function uy(e){return e[0]}function fy(e){return e[1]}function dy(e,t){var n=zv(!0),r=null,i=cy,o=null;function a(a){var s,l,c,u=(a=sy(a)).length,f=!1;for(null==r&&(o=i(c=$o())),s=0;s<=u;++s)!(s=u;--f)s.point(g[f],b[f]);s.lineEnd(),s.areaEnd()}m&&(g[c]=+e(d,c,l),b[c]=+t(d,c,l),s.point(r?+r(d,c,l):g[c],n?+n(d,c,l):b[c]))}if(h)return s=null,h+""||null}function c(){return dy().defined(i).curve(a).context(o)}return e="function"==typeof e?e:void 0===e?uy:zv(+e),t="function"==typeof t?t:zv(void 0===t?0:+t),n="function"==typeof n?n:void 0===n?fy:zv(+n),l.x=function(t){return arguments.length?(e="function"==typeof t?t:zv(+t),r=null,l):e},l.x0=function(t){return arguments.length?(e="function"==typeof t?t:zv(+t),l):e},l.x1=function(e){return arguments.length?(r=null==e?null:"function"==typeof e?e:zv(+e),l):r},l.y=function(e){return arguments.length?(t="function"==typeof e?e:zv(+e),n=null,l):t},l.y0=function(e){return arguments.length?(t="function"==typeof e?e:zv(+e),l):t},l.y1=function(e){return arguments.length?(n=null==e?null:"function"==typeof e?e:zv(+e),l):n},l.lineX0=l.lineY0=function(){return c().x(e).y(t)},l.lineY1=function(){return c().x(e).y(n)},l.lineX1=function(){return c().x(r).y(t)},l.defined=function(e){return arguments.length?(i="function"==typeof e?e:zv(!!e),l):i},l.curve=function(e){return arguments.length?(a=e,null!=o&&(s=a(o)),l):a},l.context=function(e){return arguments.length?(null==e?o=s=null:s=a(o=e),l):o},l}function py(e,t){return te?1:t>=e?0:NaN}function my(e){return e}ly.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._point=0},lineEnd:function(){(this._line||0!==this._line&&1===this._point)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;default:this._context.lineTo(e,t)}}};var gy=vy(cy);function by(e){this._curve=e}function vy(e){function t(t){return new by(e(t))}return t._curve=e,t}function yy(e){var t=e.curve;return e.angle=e.x,delete e.x,e.radius=e.y,delete e.y,e.curve=function(e){return arguments.length?t(vy(e)):t()._curve},e}function _y(){return yy(dy().curve(gy))}function wy(){var e=hy().curve(gy),t=e.curve,n=e.lineX0,r=e.lineX1,i=e.lineY0,o=e.lineY1;return e.angle=e.x,delete e.x,e.startAngle=e.x0,delete e.x0,e.endAngle=e.x1,delete e.x1,e.radius=e.y,delete e.y,e.innerRadius=e.y0,delete e.y0,e.outerRadius=e.y1,delete e.y1,e.lineStartAngle=function(){return yy(n())},delete e.lineX0,e.lineEndAngle=function(){return yy(r())},delete e.lineX1,e.lineInnerRadius=function(){return yy(i())},delete e.lineY0,e.lineOuterRadius=function(){return yy(o())},delete e.lineY1,e.curve=function(e){return arguments.length?t(vy(e)):t()._curve},e}function xy(e,t){return[(t=+t)*Math.cos(e-=Math.PI/2),t*Math.sin(e)]}function Ty(e){return e.source}function Ay(e){return e.target}function Ey(e){var t=Ty,n=Ay,r=uy,i=fy,o=null;function a(){var a,s=ay.call(arguments),l=t.apply(this,s),c=n.apply(this,s);if(o||(o=a=$o()),e(o,+r.apply(this,(s[0]=l,s)),+i.apply(this,s),+r.apply(this,(s[0]=c,s)),+i.apply(this,s)),a)return o=null,a+""||null}return a.source=function(e){return arguments.length?(t=e,a):t},a.target=function(e){return arguments.length?(n=e,a):n},a.x=function(e){return arguments.length?(r="function"==typeof e?e:zv(+e),a):r},a.y=function(e){return arguments.length?(i="function"==typeof e?e:zv(+e),a):i},a.context=function(e){return arguments.length?(o=null==e?null:e,a):o},a}function ky(e,t,n,r,i){e.moveTo(t,n),e.bezierCurveTo(t=(t+r)/2,n,t,i,r,i)}function Sy(e,t,n,r,i){e.moveTo(t,n),e.bezierCurveTo(t,n=(n+i)/2,r,n,r,i)}function My(e,t,n,r,i){var o=xy(t,n),a=xy(t,n=(n+i)/2),s=xy(r,n),l=xy(r,i);e.moveTo(o[0],o[1]),e.bezierCurveTo(a[0],a[1],s[0],s[1],l[0],l[1])}by.prototype={areaStart:function(){this._curve.areaStart()},areaEnd:function(){this._curve.areaEnd()},lineStart:function(){this._curve.lineStart()},lineEnd:function(){this._curve.lineEnd()},point:function(e,t){this._curve.point(t*Math.sin(e),t*-Math.cos(e))}};var Cy={draw:function(e,t){var n=Math.sqrt(t/Zv);e.moveTo(n,0),e.arc(0,0,n,0,Xv)}},Ny={draw:function(e,t){var n=Math.sqrt(t/5)/2;e.moveTo(-3*n,-n),e.lineTo(-n,-n),e.lineTo(-n,-3*n),e.lineTo(n,-3*n),e.lineTo(n,-n),e.lineTo(3*n,-n),e.lineTo(3*n,n),e.lineTo(n,n),e.lineTo(n,3*n),e.lineTo(-n,3*n),e.lineTo(-n,n),e.lineTo(-3*n,n),e.closePath()}},Dy=Math.sqrt(1/3),Ly=2*Dy,Oy={draw:function(e,t){var n=Math.sqrt(t/Ly),r=n*Dy;e.moveTo(0,-n),e.lineTo(r,0),e.lineTo(0,n),e.lineTo(-r,0),e.closePath()}},Iy=Math.sin(Zv/10)/Math.sin(7*Zv/10),By=Math.sin(Xv/10)*Iy,Py=-Math.cos(Xv/10)*Iy,jy={draw:function(e,t){var n=Math.sqrt(.8908130915292852*t),r=By*n,i=Py*n;e.moveTo(0,-n),e.lineTo(r,i);for(var o=1;o<5;++o){var a=Xv*o/5,s=Math.cos(a),l=Math.sin(a);e.lineTo(l*n,-s*n),e.lineTo(s*r-l*i,l*r+s*i)}e.closePath()}},Ry={draw:function(e,t){var n=Math.sqrt(t),r=-n/2;e.rect(r,r,n,n)}},zy=Math.sqrt(3),Fy={draw:function(e,t){var n=-Math.sqrt(t/(3*zy));e.moveTo(0,2*n),e.lineTo(-zy*n,-n),e.lineTo(zy*n,-n),e.closePath()}},qy=-.5,Uy=Math.sqrt(3)/2,Hy=1/Math.sqrt(12),Vy=3*(Hy/2+1),Gy={draw:function(e,t){var n=Math.sqrt(t/Vy),r=n/2,i=n*Hy,o=r,a=n*Hy+n,s=-o,l=a;e.moveTo(r,i),e.lineTo(o,a),e.lineTo(s,l),e.lineTo(qy*r-Uy*i,Uy*r+qy*i),e.lineTo(qy*o-Uy*a,Uy*o+qy*a),e.lineTo(qy*s-Uy*l,Uy*s+qy*l),e.lineTo(qy*r+Uy*i,qy*i-Uy*r),e.lineTo(qy*o+Uy*a,qy*a-Uy*o),e.lineTo(qy*s+Uy*l,qy*l-Uy*s),e.closePath()}},Wy=[Cy,Ny,Oy,Ry,jy,Fy,Gy];function Yy(){}function Zy(e,t,n){e._context.bezierCurveTo((2*e._x0+e._x1)/3,(2*e._y0+e._y1)/3,(e._x0+2*e._x1)/3,(e._y0+2*e._y1)/3,(e._x0+4*e._x1+t)/6,(e._y0+4*e._y1+n)/6)}function Ky(e){this._context=e}function Xy(e){this._context=e}function Qy(e){this._context=e}function $y(e,t){this._basis=new Ky(e),this._beta=t}Ky.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=NaN,this._point=0},lineEnd:function(){switch(this._point){case 3:Zy(this,this._x1,this._y1);case 2:this._context.lineTo(this._x1,this._y1)}(this._line||0!==this._line&&1===this._point)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;break;case 2:this._point=3,this._context.lineTo((5*this._x0+this._x1)/6,(5*this._y0+this._y1)/6);default:Zy(this,e,t)}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t}},Xy.prototype={areaStart:Yy,areaEnd:Yy,lineStart:function(){this._x0=this._x1=this._x2=this._x3=this._x4=this._y0=this._y1=this._y2=this._y3=this._y4=NaN,this._point=0},lineEnd:function(){switch(this._point){case 1:this._context.moveTo(this._x2,this._y2),this._context.closePath();break;case 2:this._context.moveTo((this._x2+2*this._x3)/3,(this._y2+2*this._y3)/3),this._context.lineTo((this._x3+2*this._x2)/3,(this._y3+2*this._y2)/3),this._context.closePath();break;case 3:this.point(this._x2,this._y2),this.point(this._x3,this._y3),this.point(this._x4,this._y4)}},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._x2=e,this._y2=t;break;case 1:this._point=2,this._x3=e,this._y3=t;break;case 2:this._point=3,this._x4=e,this._y4=t,this._context.moveTo((this._x0+4*this._x1+e)/6,(this._y0+4*this._y1+t)/6);break;default:Zy(this,e,t)}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t}},Qy.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=NaN,this._point=0},lineEnd:function(){(this._line||0!==this._line&&3===this._point)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1;break;case 1:this._point=2;break;case 2:this._point=3;var n=(this._x0+4*this._x1+e)/6,r=(this._y0+4*this._y1+t)/6;this._line?this._context.lineTo(n,r):this._context.moveTo(n,r);break;case 3:this._point=4;default:Zy(this,e,t)}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t}},$y.prototype={lineStart:function(){this._x=[],this._y=[],this._basis.lineStart()},lineEnd:function(){var e=this._x,t=this._y,n=e.length-1;if(n>0)for(var r,i=e[0],o=t[0],a=e[n]-i,s=t[n]-o,l=-1;++l<=n;)r=l/n,this._basis.point(this._beta*e[l]+(1-this._beta)*(i+r*a),this._beta*t[l]+(1-this._beta)*(o+r*s));this._x=this._y=null,this._basis.lineEnd()},point:function(e,t){this._x.push(+e),this._y.push(+t)}};var Jy=function e(t){function n(e){return 1===t?new Ky(e):new $y(e,t)}return n.beta=function(t){return e(+t)},n}(.85);function e_(e,t,n){e._context.bezierCurveTo(e._x1+e._k*(e._x2-e._x0),e._y1+e._k*(e._y2-e._y0),e._x2+e._k*(e._x1-t),e._y2+e._k*(e._y1-n),e._x2,e._y2)}function t_(e,t){this._context=e,this._k=(1-t)/6}t_.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._x2=this._y0=this._y1=this._y2=NaN,this._point=0},lineEnd:function(){switch(this._point){case 2:this._context.lineTo(this._x2,this._y2);break;case 3:e_(this,this._x1,this._y1)}(this._line||0!==this._line&&1===this._point)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2,this._x1=e,this._y1=t;break;case 2:this._point=3;default:e_(this,e,t)}this._x0=this._x1,this._x1=this._x2,this._x2=e,this._y0=this._y1,this._y1=this._y2,this._y2=t}};var n_=function e(t){function n(e){return new t_(e,t)}return n.tension=function(t){return e(+t)},n}(0);function r_(e,t){this._context=e,this._k=(1-t)/6}r_.prototype={areaStart:Yy,areaEnd:Yy,lineStart:function(){this._x0=this._x1=this._x2=this._x3=this._x4=this._x5=this._y0=this._y1=this._y2=this._y3=this._y4=this._y5=NaN,this._point=0},lineEnd:function(){switch(this._point){case 1:this._context.moveTo(this._x3,this._y3),this._context.closePath();break;case 2:this._context.lineTo(this._x3,this._y3),this._context.closePath();break;case 3:this.point(this._x3,this._y3),this.point(this._x4,this._y4),this.point(this._x5,this._y5)}},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._x3=e,this._y3=t;break;case 1:this._point=2,this._context.moveTo(this._x4=e,this._y4=t);break;case 2:this._point=3,this._x5=e,this._y5=t;break;default:e_(this,e,t)}this._x0=this._x1,this._x1=this._x2,this._x2=e,this._y0=this._y1,this._y1=this._y2,this._y2=t}};var i_=function e(t){function n(e){return new r_(e,t)}return n.tension=function(t){return e(+t)},n}(0);function o_(e,t){this._context=e,this._k=(1-t)/6}o_.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._x2=this._y0=this._y1=this._y2=NaN,this._point=0},lineEnd:function(){(this._line||0!==this._line&&3===this._point)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1;break;case 1:this._point=2;break;case 2:this._point=3,this._line?this._context.lineTo(this._x2,this._y2):this._context.moveTo(this._x2,this._y2);break;case 3:this._point=4;default:e_(this,e,t)}this._x0=this._x1,this._x1=this._x2,this._x2=e,this._y0=this._y1,this._y1=this._y2,this._y2=t}};var a_=function e(t){function n(e){return new o_(e,t)}return n.tension=function(t){return e(+t)},n}(0);function s_(e,t,n){var r=e._x1,i=e._y1,o=e._x2,a=e._y2;if(e._l01_a>Yv){var s=2*e._l01_2a+3*e._l01_a*e._l12_a+e._l12_2a,l=3*e._l01_a*(e._l01_a+e._l12_a);r=(r*s-e._x0*e._l12_2a+e._x2*e._l01_2a)/l,i=(i*s-e._y0*e._l12_2a+e._y2*e._l01_2a)/l}if(e._l23_a>Yv){var c=2*e._l23_2a+3*e._l23_a*e._l12_a+e._l12_2a,u=3*e._l23_a*(e._l23_a+e._l12_a);o=(o*c+e._x1*e._l23_2a-t*e._l12_2a)/u,a=(a*c+e._y1*e._l23_2a-n*e._l12_2a)/u}e._context.bezierCurveTo(r,i,o,a,e._x2,e._y2)}function l_(e,t){this._context=e,this._alpha=t}l_.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._x2=this._y0=this._y1=this._y2=NaN,this._l01_a=this._l12_a=this._l23_a=this._l01_2a=this._l12_2a=this._l23_2a=this._point=0},lineEnd:function(){switch(this._point){case 2:this._context.lineTo(this._x2,this._y2);break;case 3:this.point(this._x2,this._y2)}(this._line||0!==this._line&&1===this._point)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){if(e=+e,t=+t,this._point){var n=this._x2-e,r=this._y2-t;this._l23_a=Math.sqrt(this._l23_2a=Math.pow(n*n+r*r,this._alpha))}switch(this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;break;case 2:this._point=3;default:s_(this,e,t)}this._l01_a=this._l12_a,this._l12_a=this._l23_a,this._l01_2a=this._l12_2a,this._l12_2a=this._l23_2a,this._x0=this._x1,this._x1=this._x2,this._x2=e,this._y0=this._y1,this._y1=this._y2,this._y2=t}};var c_=function e(t){function n(e){return t?new l_(e,t):new t_(e,0)}return n.alpha=function(t){return e(+t)},n}(.5);function u_(e,t){this._context=e,this._alpha=t}u_.prototype={areaStart:Yy,areaEnd:Yy,lineStart:function(){this._x0=this._x1=this._x2=this._x3=this._x4=this._x5=this._y0=this._y1=this._y2=this._y3=this._y4=this._y5=NaN,this._l01_a=this._l12_a=this._l23_a=this._l01_2a=this._l12_2a=this._l23_2a=this._point=0},lineEnd:function(){switch(this._point){case 1:this._context.moveTo(this._x3,this._y3),this._context.closePath();break;case 2:this._context.lineTo(this._x3,this._y3),this._context.closePath();break;case 3:this.point(this._x3,this._y3),this.point(this._x4,this._y4),this.point(this._x5,this._y5)}},point:function(e,t){if(e=+e,t=+t,this._point){var n=this._x2-e,r=this._y2-t;this._l23_a=Math.sqrt(this._l23_2a=Math.pow(n*n+r*r,this._alpha))}switch(this._point){case 0:this._point=1,this._x3=e,this._y3=t;break;case 1:this._point=2,this._context.moveTo(this._x4=e,this._y4=t);break;case 2:this._point=3,this._x5=e,this._y5=t;break;default:s_(this,e,t)}this._l01_a=this._l12_a,this._l12_a=this._l23_a,this._l01_2a=this._l12_2a,this._l12_2a=this._l23_2a,this._x0=this._x1,this._x1=this._x2,this._x2=e,this._y0=this._y1,this._y1=this._y2,this._y2=t}};var f_=function e(t){function n(e){return t?new u_(e,t):new r_(e,0)}return n.alpha=function(t){return e(+t)},n}(.5);function d_(e,t){this._context=e,this._alpha=t}d_.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._x2=this._y0=this._y1=this._y2=NaN,this._l01_a=this._l12_a=this._l23_a=this._l01_2a=this._l12_2a=this._l23_2a=this._point=0},lineEnd:function(){(this._line||0!==this._line&&3===this._point)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){if(e=+e,t=+t,this._point){var n=this._x2-e,r=this._y2-t;this._l23_a=Math.sqrt(this._l23_2a=Math.pow(n*n+r*r,this._alpha))}switch(this._point){case 0:this._point=1;break;case 1:this._point=2;break;case 2:this._point=3,this._line?this._context.lineTo(this._x2,this._y2):this._context.moveTo(this._x2,this._y2);break;case 3:this._point=4;default:s_(this,e,t)}this._l01_a=this._l12_a,this._l12_a=this._l23_a,this._l01_2a=this._l12_2a,this._l12_2a=this._l23_2a,this._x0=this._x1,this._x1=this._x2,this._x2=e,this._y0=this._y1,this._y1=this._y2,this._y2=t}};var h_=function e(t){function n(e){return t?new d_(e,t):new o_(e,0)}return n.alpha=function(t){return e(+t)},n}(.5);function p_(e){this._context=e}function m_(e){return e<0?-1:1}function g_(e,t,n){var r=e._x1-e._x0,i=t-e._x1,o=(e._y1-e._y0)/(r||i<0&&-0),a=(n-e._y1)/(i||r<0&&-0),s=(o*i+a*r)/(r+i);return(m_(o)+m_(a))*Math.min(Math.abs(o),Math.abs(a),.5*Math.abs(s))||0}function b_(e,t){var n=e._x1-e._x0;return n?(3*(e._y1-e._y0)/n-t)/2:t}function v_(e,t,n){var r=e._x0,i=e._y0,o=e._x1,a=e._y1,s=(o-r)/3;e._context.bezierCurveTo(r+s,i+s*t,o-s,a-s*n,o,a)}function y_(e){this._context=e}function __(e){this._context=new w_(e)}function w_(e){this._context=e}function x_(e){this._context=e}function T_(e){var t,n,r=e.length-1,i=new Array(r),o=new Array(r),a=new Array(r);for(i[0]=0,o[0]=2,a[0]=e[0]+2*e[1],t=1;t=0;--t)i[t]=(a[t]-i[t+1])/o[t];for(o[r-1]=(e[r]+i[r-1])/2,t=0;t1)for(var n,r,i,o=1,a=e[t[0]],s=a.length;o=0;)n[t]=t;return n}function S_(e,t){return e[t]}function M_(e){const t=[];return t.key=e,t}function C_(e){var t=e.map(N_);return k_(e).sort((function(e,n){return t[e]-t[n]}))}function N_(e){for(var t,n=-1,r=0,i=e.length,o=-1/0;++no&&(o=t,r=n);return r}function D_(e){var t=e.map(L_);return k_(e).sort((function(e,n){return t[e]-t[n]}))}function L_(e){for(var t,n=0,r=-1,i=e.length;++r=0&&(this._t=1-this._t,this._line=1-this._line)},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;default:if(this._t<=0)this._context.lineTo(this._x,t),this._context.lineTo(e,t);else{var n=this._x*(1-this._t)+e*this._t;this._context.lineTo(n,this._y),this._context.lineTo(n,t)}}this._x=e,this._y=t}};var O_=e=>()=>e;function I_(e,{sourceEvent:t,target:n,transform:r,dispatch:i}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:r,enumerable:!0,configurable:!0},_:{value:i}})}function B_(e,t,n){this.k=e,this.x=t,this.y=n}B_.prototype={constructor:B_,scale:function(e){return 1===e?this:new B_(this.k*e,this.x,this.y)},translate:function(e,t){return 0===e&0===t?this:new B_(this.k,this.x+this.k*e,this.y+this.k*t)},apply:function(e){return[e[0]*this.k+this.x,e[1]*this.k+this.y]},applyX:function(e){return e*this.k+this.x},applyY:function(e){return e*this.k+this.y},invert:function(e){return[(e[0]-this.x)/this.k,(e[1]-this.y)/this.k]},invertX:function(e){return(e-this.x)/this.k},invertY:function(e){return(e-this.y)/this.k},rescaleX:function(e){return e.copy().domain(e.range().map(this.invertX,this).map(e.invert,e))},rescaleY:function(e){return e.copy().domain(e.range().map(this.invertY,this).map(e.invert,e))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var P_=new B_(1,0,0);function j_(e){for(;!e.__zoom;)if(!(e=e.parentNode))return P_;return e.__zoom}function R_(e){e.stopImmediatePropagation()}function z_(e){e.preventDefault(),e.stopImmediatePropagation()}function F_(e){return!(e.ctrlKey&&"wheel"!==e.type||e.button)}function q_(){var e=this;return e instanceof SVGElement?(e=e.ownerSVGElement||e).hasAttribute("viewBox")?[[(e=e.viewBox.baseVal).x,e.y],[e.x+e.width,e.y+e.height]]:[[0,0],[e.width.baseVal.value,e.height.baseVal.value]]:[[0,0],[e.clientWidth,e.clientHeight]]}function U_(){return this.__zoom||P_}function H_(e){return-e.deltaY*(1===e.deltaMode?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function V_(){return navigator.maxTouchPoints||"ontouchstart"in this}function G_(e,t,n){var r=e.invertX(t[0][0])-n[0][0],i=e.invertX(t[1][0])-n[1][0],o=e.invertY(t[0][1])-n[0][1],a=e.invertY(t[1][1])-n[1][1];return e.translate(i>r?(r+i)/2:Math.min(0,r)||Math.max(0,i),a>o?(o+a)/2:Math.min(0,o)||Math.max(0,a))}j_.prototype=B_.prototype,e.Adder=m,e.Delaunay=Va,e.FormatSpecifier=Ks,e.Voronoi=Ra,e.active=function(e,t){var n,r,i=e.__transition;if(i)for(r in t=null==t?null:t+"",i)if((n=i[r]).state>1&&n.name===t)return new Oi([[e]],ao,t,+r);return null},e.arc=function(){var e=Jv,t=ey,n=zv(0),r=null,i=ty,o=ny,a=ry,s=null;function l(){var l,c,u=+e.apply(this,arguments),f=+t.apply(this,arguments),d=i.apply(this,arguments)-Kv,h=o.apply(this,arguments)-Kv,p=Fv(h-d),m=h>d;if(s||(s=l=$o()),fYv)if(p>Xv-Yv)s.moveTo(f*Uv(d),f*Gv(d)),s.arc(0,0,f,d,h,!m),u>Yv&&(s.moveTo(u*Uv(h),u*Gv(h)),s.arc(0,0,u,h,d,m));else{var g,b,v=d,y=h,_=d,w=h,x=p,T=p,A=a.apply(this,arguments)/2,E=A>Yv&&(r?+r.apply(this,arguments):Wv(u*u+f*f)),k=Vv(Fv(f-u)/2,+n.apply(this,arguments)),S=k,M=k;if(E>Yv){var C=$v(E/u*Gv(A)),N=$v(E/f*Gv(A));(x-=2*C)>Yv?(_+=C*=m?1:-1,w-=C):(x=0,_=w=(d+h)/2),(T-=2*N)>Yv?(v+=N*=m?1:-1,y-=N):(T=0,v=y=(d+h)/2)}var D=f*Uv(v),L=f*Gv(v),O=u*Uv(w),I=u*Gv(w);if(k>Yv){var B,P=f*Uv(y),j=f*Gv(y),R=u*Uv(_),z=u*Gv(_);if(pYv?M>Yv?(g=oy(R,z,D,L,f,M,m),b=oy(P,j,O,I,f,M,m),s.moveTo(g.cx+g.x01,g.cy+g.y01),MYv&&x>Yv?S>Yv?(g=oy(O,I,P,j,u,-S,m),b=oy(D,L,R,z,u,-S,m),s.lineTo(g.cx+g.x01,g.cy+g.y01),S>a,c=i+2*s>>a,u=fa(20);function f(r){var i=new Float32Array(l*c),f=new Float32Array(l*c);r.forEach((function(r,o,u){var f=+e(r,o,u)+s>>a,d=+t(r,o,u)+s>>a,h=+n(r,o,u);f>=0&&f=0&&d>a),ya({width:l,height:c,data:f},{width:l,height:c,data:i},o>>a),va({width:l,height:c,data:i},{width:l,height:c,data:f},o>>a),ya({width:l,height:c,data:f},{width:l,height:c,data:i},o>>a),va({width:l,height:c,data:i},{width:l,height:c,data:f},o>>a),ya({width:l,height:c,data:f},{width:l,height:c,data:i},o>>a);var h=u(i);if(!Array.isArray(h)){var p=N(i);h=k(0,p,h),(h=q(0,Math.floor(p/h)*h,h)).shift()}return ba().thresholds(h).size([l,c])(i).map(d)}function d(e){return e.value*=Math.pow(2,-2*a),e.coordinates.forEach(h),e}function h(e){e.forEach(p)}function p(e){e.forEach(m)}function m(e){e[0]=e[0]*Math.pow(2,a)-s,e[1]=e[1]*Math.pow(2,a)-s}function g(){return l=r+2*(s=3*o)>>a,c=i+2*s>>a,f}return f.x=function(t){return arguments.length?(e="function"==typeof t?t:fa(+t),f):e},f.y=function(e){return arguments.length?(t="function"==typeof e?e:fa(+e),f):t},f.weight=function(e){return arguments.length?(n="function"==typeof e?e:fa(+e),f):n},f.size=function(e){if(!arguments.length)return[r,i];var t=+e[0],n=+e[1];if(!(t>=0&&n>=0))throw new Error("invalid size");return r=t,i=n,g()},f.cellSize=function(e){if(!arguments.length)return 1<=1))throw new Error("invalid cell size");return a=Math.floor(Math.log(e)/Math.LN2),g()},f.thresholds=function(e){return arguments.length?(u="function"==typeof e?e:Array.isArray(e)?fa(ca.call(e)):fa(e),f):u},f.bandwidth=function(e){if(!arguments.length)return Math.sqrt(o*(o+1));if(!((e=+e)>=0))throw new Error("invalid bandwidth");return o=Math.round((Math.sqrt(4*e*e+1)-1)/2),g()},f},e.contours=ba,e.count=l,e.create=function(e){return Tt(me(e).call(document.documentElement))},e.creator=me,e.cross=function(...e){const t="function"==typeof e[e.length-1]&&function(e){return t=>e(...t)}(e.pop()),n=(e=e.map(f)).map(c),r=e.length-1,i=new Array(r+1).fill(0),o=[];if(r<0||n.some(u))return o;for(;;){o.push(i.map(((t,n)=>e[n][t])));let a=r;for(;++i[a]===n[a];){if(0===a)return t?o.map(t):o;i[a--]=0}}},e.csv=ys,e.csvFormat=es,e.csvFormatBody=ts,e.csvFormatRow=rs,e.csvFormatRows=ns,e.csvFormatValue=is,e.csvParse=$a,e.csvParseRows=Ja,e.cubehelix=Gn,e.cumsum=function(e,t){var n=0,r=0;return Float64Array.from(e,void 0===t?e=>n+=+e||0:i=>n+=+t(i,r++,e)||0)},e.curveBasis=function(e){return new Ky(e)},e.curveBasisClosed=function(e){return new Xy(e)},e.curveBasisOpen=function(e){return new Qy(e)},e.curveBundle=Jy,e.curveCardinal=n_,e.curveCardinalClosed=i_,e.curveCardinalOpen=a_,e.curveCatmullRom=c_,e.curveCatmullRomClosed=f_,e.curveCatmullRomOpen=h_,e.curveLinear=cy,e.curveLinearClosed=function(e){return new p_(e)},e.curveMonotoneX=function(e){return new y_(e)},e.curveMonotoneY=function(e){return new __(e)},e.curveNatural=function(e){return new x_(e)},e.curveStep=function(e){return new A_(e,.5)},e.curveStepAfter=function(e){return new A_(e,1)},e.curveStepBefore=function(e){return new A_(e,0)},e.descending=function(e,t){return te?1:t>=e?0:NaN},e.deviation=h,e.difference=function(e,...t){e=new Set(e);for(const n of t)for(const t of n)e.delete(t);return e},e.disjoint=function(e,t){const n=t[Symbol.iterator](),r=new Set;for(const t of e){if(r.has(t))return!1;let e,i;for(;({value:e,done:i}=n.next())&&!i;){if(Object.is(t,e))return!1;r.add(e)}}return!0},e.dispatch=oe,e.drag=function(){var e,t,n,r,i=Bt,o=Pt,a=jt,s=Rt,l={},c=oe("start","drag","end"),u=0,f=0;function d(e){e.on("mousedown.drag",h).filter(s).on("touchstart.drag",g).on("touchmove.drag",b).on("touchend.drag touchcancel.drag",v).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function h(a,s){if(!r&&i.call(this,a,s)){var l=y(this,o.call(this,a,s),a,s,"mouse");l&&(Tt(a.view).on("mousemove.drag",p,!0).on("mouseup.drag",m,!0),Dt(a.view),Ct(a),n=!1,e=a.clientX,t=a.clientY,l("start",a))}}function p(r){if(Nt(r),!n){var i=r.clientX-e,o=r.clientY-t;n=i*i+o*o>f}l.mouse("drag",r)}function m(e){Tt(e.view).on("mousemove.drag mouseup.drag",null),Lt(e.view,n),Nt(e),l.mouse("end",e)}function g(e,t){if(i.call(this,e,t)){var n,r,a=e.changedTouches,s=o.call(this,e,t),l=a.length;for(n=0;n+e,e.easePoly=qi,e.easePolyIn=zi,e.easePolyInOut=qi,e.easePolyOut=Fi,e.easeQuad=ji,e.easeQuadIn=function(e){return e*e},e.easeQuadInOut=ji,e.easeQuadOut=function(e){return e*(2-e)},e.easeSin=Vi,e.easeSinIn=function(e){return 1==+e?1:1-Math.cos(e*Hi)},e.easeSinInOut=Vi,e.easeSinOut=function(e){return Math.sin(e*Hi)},e.every=function(e,t){if("function"!=typeof t)throw new TypeError("test is not a function");let n=-1;for(const r of e)if(!t(r,++n,e))return!1;return!0},e.extent=p,e.filter=function(e,t){if("function"!=typeof t)throw new TypeError("test is not a function");const n=[];let r=-1;for(const i of e)t(i,++r,e)&&n.push(i);return n},e.forceCenter=function(e,t){var n,r=1;function i(){var i,o,a=n.length,s=0,l=0;for(i=0;ic+p||ou+p||al.index){var m=c-s.x-s.vx,g=u-s.y-s.vy,b=m*m+g*g;be.r&&(e.r=e[t].r)}function l(){if(t){var r,i,o=t.length;for(n=new Array(o),r=0;r[s(e,t,r),e])));for(a=0,i=new Array(c);a=s)){(e.data!==t||e.next)&&(0===f&&(p+=(f=Bs(n))*f),0===d&&(p+=(d=Bs(n))*d),p(e=(1664525*e+1013904223)%Fs)/Fs}();function f(){d(),c.call("tick",t),n1?(null==n?s.delete(e):s.set(e,p(n)),t):s.get(e)},find:function(t,n,r){var i,o,a,s,l,c=0,u=e.length;for(null==r?r=1/0:r*=r,c=0;c1?(c.on(e,n),t):c.on(e)}}},e.forceX=function(e){var t,n,r,i=Is(.1);function o(e){for(var i,o=0,a=t.length;o=.12&&i<.234&&r>=-.425&&r<-.214?s:i>=.166&&i<.234&&r>=-.214&&r<-.115?l:a).invert(e)},u.stream=function(n){return e&&t===n?e:(r=[a.stream(t=n),s.stream(n),l.stream(n)],i=r.length,e={point:function(e,t){for(var n=-1;++nRc(r[0],r[1])&&(r[1]=i[1]),Rc(i[0],r[1])>Rc(r[0],r[1])&&(r[0]=i[0])):o.push(r=i);for(a=-1/0,t=0,r=o[n=o.length-1];t<=n;r=i,++t)i=o[t],(s=Rc(r[1],i[0]))>a&&(a=s,Hl=i[0],Gl=r[1])}return $l=Jl=null,Hl===1/0||Vl===1/0?[[NaN,NaN],[NaN,NaN]]:[[Hl,Vl],[Gl,Wl]]},e.geoCentroid=function(e){pc=mc=gc=bc=vc=yc=_c=wc=0,xc=new m,Tc=new m,Ac=new m,jl(e,qc);var t=+xc,n=+Tc,r=+Ac,i=wl(t,n,r);return i2?e[2]+90:90]):[(e=n())[0],e[1],e[2]-90]},n([0,0,90]).scale(159.155)},e.geoTransverseMercatorRaw=Md,e.gray=function(e,t){return new Sn(e,0,0,null==t?1:t)},e.greatest=function(e,n=t){let r,i=!1;if(1===n.length){let o;for(const a of e){const e=n(a);(i?t(e,o)>0:0===t(e,e))&&(r=a,o=e,i=!0)}}else for(const t of e)(i?n(t,r)>0:0===n(t,t))&&(r=t,i=!0);return r},e.greatestIndex=function(e,n=t){if(1===n.length)return P(e,n);let r,i=-1,o=-1;for(const t of e)++o,(i<0?0===n(t,t):n(t,r)>0)&&(r=t,i=o);return i},e.group=function(e,...t){return v(e,g,g,t)},e.groups=function(e,...t){return v(e,Array.from,g,t)},e.hcl=On,e.hierarchy=Od,e.histogram=C,e.hsl=mn,e.html=As,e.image=function(e,t){return new Promise((function(n,r){var i=new Image;for(var o in t)i[o]=t[o];i.onerror=r,i.onload=function(){n(i)},i.src=e}))},e.index=function(e,...t){return v(e,g,b,t)},e.indexes=function(e,...t){return v(e,Array.from,b,t)},e.interpolate=hr,e.interpolateArray=function(e,t){return(or(t)?ir:ar)(e,t)},e.interpolateBasis=Zn,e.interpolateBasisClosed=Kn,e.interpolateBlues=gv,e.interpolateBrBG=Mb,e.interpolateBuGn=Wb,e.interpolateBuPu=Zb,e.interpolateCividis=function(e){return e=Math.max(0,Math.min(1,e)),"rgb("+Math.max(0,Math.min(255,Math.round(-4.54-e*(35.34-e*(2381.73-e*(6402.7-e*(7024.72-2710.57*e)))))))+", "+Math.max(0,Math.min(255,Math.round(32.49+e*(170.73+e*(52.82-e*(131.46-e*(176.58-67.37*e)))))))+", "+Math.max(0,Math.min(255,Math.round(81.24+e*(442.36-e*(2482.43-e*(6167.24-e*(6614.94-2475.67*e)))))))+")"},e.interpolateCool=Cv,e.interpolateCubehelix=Dr,e.interpolateCubehelixDefault=Sv,e.interpolateCubehelixLong=Lr,e.interpolateDate=sr,e.interpolateDiscrete=function(e){var t=e.length;return function(n){return e[Math.max(0,Math.min(t-1,Math.floor(n*t)))]}},e.interpolateGnBu=Xb,e.interpolateGreens=vv,e.interpolateGreys=_v,e.interpolateHcl=Mr,e.interpolateHclLong=Cr,e.interpolateHsl=Er,e.interpolateHslLong=kr,e.interpolateHue=function(e,t){var n=$n(+e,+t);return function(e){var t=n(e);return t-360*Math.floor(t/360)}},e.interpolateInferno=jv,e.interpolateLab=function(e,t){var n=Jn((e=kn(e)).l,(t=kn(t)).l),r=Jn(e.a,t.a),i=Jn(e.b,t.b),o=Jn(e.opacity,t.opacity);return function(t){return e.l=n(t),e.a=r(t),e.b=i(t),e.opacity=o(t),e+""}},e.interpolateMagma=Pv,e.interpolateNumber=lr,e.interpolateNumberArray=ir,e.interpolateObject=cr,e.interpolateOrRd=$b,e.interpolateOranges=kv,e.interpolatePRGn=Nb,e.interpolatePiYG=Lb,e.interpolatePlasma=Rv,e.interpolatePuBu=nv,e.interpolatePuBuGn=ev,e.interpolatePuOr=Ib,e.interpolatePuRd=iv,e.interpolatePurples=xv,e.interpolateRainbow=function(e){(e<0||e>1)&&(e-=Math.floor(e));var t=Math.abs(e-.5);return Nv.h=360*e-100,Nv.s=1.5-1.5*t,Nv.l=.8-.9*t,Nv+""},e.interpolateRdBu=Pb,e.interpolateRdGy=Rb,e.interpolateRdPu=av,e.interpolateRdYlBu=Fb,e.interpolateRdYlGn=Ub,e.interpolateReds=Av,e.interpolateRgb=er,e.interpolateRgbBasis=nr,e.interpolateRgbBasisClosed=rr,e.interpolateRound=pr,e.interpolateSinebow=function(e){var t;return e=(.5-e)*Math.PI,Dv.r=255*(t=Math.sin(e))*t,Dv.g=255*(t=Math.sin(e+Lv))*t,Dv.b=255*(t=Math.sin(e+Ov))*t,Dv+""},e.interpolateSpectral=Vb,e.interpolateString=dr,e.interpolateTransformCss=_r,e.interpolateTransformSvg=wr,e.interpolateTurbo=function(e){return e=Math.max(0,Math.min(1,e)),"rgb("+Math.max(0,Math.min(255,Math.round(34.61+e*(1172.33-e*(10793.56-e*(33300.12-e*(38394.49-14825.05*e)))))))+", "+Math.max(0,Math.min(255,Math.round(23.31+e*(557.33+e*(1225.33-e*(3574.96-e*(1073.77+707.56*e)))))))+", "+Math.max(0,Math.min(255,Math.round(27.2+e*(3211.1-e*(15327.97-e*(27814-e*(22569.18-6838.66*e)))))))+")"},e.interpolateViridis=Bv,e.interpolateWarm=Mv,e.interpolateYlGn=uv,e.interpolateYlGnBu=lv,e.interpolateYlOrBr=dv,e.interpolateYlOrRd=pv,e.interpolateZoom=Tr,e.interrupt=oi,e.intersection=function(e,...t){e=new Set(e),t=t.map(Y);e:for(const n of e)for(const r of t)if(!r.has(n)){e.delete(n);continue e}return e},e.interval=function(e,t,n){var r=new Wr,i=t;return null==t?(r.restart(e,t,n),r):(r._restart=r.restart,r.restart=function(e,t,n){t=+t,n=null==n?Vr():+n,r._restart((function o(a){a+=i,r._restart(o,i+=t,n),e(a)}),t,n)},r.restart(e,t,n),r)},e.isoFormat=ib,e.isoParse=ob,e.json=function(e,t){return fetch(e,t).then(ws)},e.lab=kn,e.lch=function(e,t,n,r){return 1===arguments.length?Ln(e):new In(n,t,e,null==r?1:r)},e.least=function(e,n=t){let r,i=!1;if(1===n.length){let o;for(const a of e){const e=n(a);(i?t(e,o)<0:0===t(e,e))&&(r=a,o=e,i=!0)}}else for(const t of e)(i?n(t,r)<0:0===n(t,t))&&(r=t,i=!0);return r},e.leastIndex=U,e.line=dy,e.lineRadial=_y,e.linkHorizontal=function(){return Ey(ky)},e.linkRadial=function(){var e=Ey(My);return e.angle=e.x,delete e.x,e.radius=e.y,delete e.y,e},e.linkVertical=function(){return Ey(Sy)},e.local=Et,e.map=function(e,t){if("function"!=typeof e[Symbol.iterator])throw new TypeError("values is not iterable");if("function"!=typeof t)throw new TypeError("mapper is not a function");return Array.from(e,((n,r)=>t(n,r,e)))},e.matcher=we,e.max=N,e.maxIndex=P,e.mean=function(e,t){let n=0,r=0;if(void 0===t)for(let t of e)null!=t&&(t=+t)>=t&&(++n,r+=t);else{let i=-1;for(let o of e)null!=(o=t(o,++i,e))&&(o=+o)>=o&&(++n,r+=o)}if(n)return r/n},e.median=function(e,t){return I(e,.5,t)},e.merge=j,e.min=D,e.minIndex=R,e.namespace=de,e.namespaces=fe,e.nice=S,e.now=Vr,e.pack=function(){var e=null,t=1,n=1,r=eh;function i(i){return i.x=t/2,i.y=n/2,e?i.eachBefore(rh(e)).eachAfter(ih(r,.5)).eachBefore(oh(1)):i.eachBefore(rh(nh)).eachAfter(ih(eh,1)).eachAfter(ih(r,i.r/Math.min(t,n))).eachBefore(oh(Math.min(t,n)/(2*i.r))),i}return i.radius=function(t){return arguments.length?(e=$d(t),i):e},i.size=function(e){return arguments.length?(t=+e[0],n=+e[1],i):[t,n]},i.padding=function(e){return arguments.length?(r="function"==typeof e?e:th(+e),i):r},i},e.packEnclose=zd,e.packSiblings=function(e){return Qd(e),e},e.pairs=function(e,t=z){const n=[];let r,i=!1;for(const o of e)i&&n.push(t(r,o)),r=o,i=!0;return n},e.partition=function(){var e=1,t=1,n=0,r=!1;function i(i){var o=i.height+1;return i.x0=i.y0=n,i.x1=e,i.y1=t/o,i.eachBefore(function(e,t){return function(r){r.children&&sh(r,r.x0,e*(r.depth+1)/t,r.x1,e*(r.depth+2)/t);var i=r.x0,o=r.y0,a=r.x1-n,s=r.y1-n;a0&&(h+=f);for(null!=t?p.sort((function(e,n){return t(m[e],m[n])})):null!=n&&p.sort((function(e,t){return n(a[e],a[t])})),s=0,c=h?(b-d*y)/h:0;s0?f*c:0)+y,m[l]={data:a[l],index:s,value:f,startAngle:g,endAngle:u,padAngle:v};return m}return a.value=function(t){return arguments.length?(e="function"==typeof t?t:zv(+t),a):e},a.sortValues=function(e){return arguments.length?(t=e,n=null,a):t},a.sort=function(e){return arguments.length?(n=e,t=null,a):n},a.startAngle=function(e){return arguments.length?(r="function"==typeof e?e:zv(+e),a):r},a.endAngle=function(e){return arguments.length?(i="function"==typeof e?e:zv(+e),a):i},a.padAngle=function(e){return arguments.length?(o="function"==typeof e?e:zv(+e),a):o},a},e.piecewise=Or,e.pointRadial=xy,e.pointer=Mt,e.pointers=function(e,t){return e.target&&(e=St(e),void 0===t&&(t=e.currentTarget),e=e.touches||[e]),Array.from(e,(e=>Mt(e,t)))},e.polygonArea=function(e){for(var t,n=-1,r=e.length,i=e[r-1],o=0;++ns!=c>s&&a<(l-n)*(s-r)/(c-r)+n&&(u=!u),l=n,c=r;return u},e.polygonHull=function(e){if((n=e.length)<3)return null;var t,n,r=new Array(n),i=new Array(n);for(t=0;t=0;--t)c.push(e[r[o[t]][2]]);for(t=+s;t(t=1664525*t+1013904223|0,Vh*(t>>>0))},e.randomLogNormal=Nh,e.randomLogistic=Uh,e.randomNormal=Ch,e.randomPareto=Ih,e.randomPoisson=Hh,e.randomUniform=Sh,e.randomWeibull=Fh,e.range=q,e.reduce=function(e,t,n){if("function"!=typeof t)throw new TypeError("reducer is not a function");const r=e[Symbol.iterator]();let i,o,a=-1;if(arguments.length<3){if(({done:i,value:n}=r.next()),i)return;++a}for(;({done:i,value:o}=r.next()),!i;)n=t(n,o,++a,e);return n},e.reverse=function(e){if("function"!=typeof e[Symbol.iterator])throw new TypeError("values is not iterable");return Array.from(e).reverse()},e.rgb=ln,e.ribbon=function(){return la()},e.ribbonArrow=function(){return la(sa)},e.rollup=function(e,t,...n){return v(e,g,t,n)},e.rollups=function(e,t,...n){return v(e,Array.from,t,n)},e.scaleBand=Kh,e.scaleDiverging=function e(){var t=sp(hb()(Jh));return t.copy=function(){return fb(t,e())},Wh.apply(t,arguments)},e.scaleDivergingLog=function e(){var t=mp(hb()).domain([.1,1,10]);return t.copy=function(){return fb(t,e()).base(t.base())},Wh.apply(t,arguments)},e.scaleDivergingPow=pb,e.scaleDivergingSqrt=function(){return pb.apply(null,arguments).exponent(.5)},e.scaleDivergingSymlog=function e(){var t=vp(hb());return t.copy=function(){return fb(t,e()).constant(t.constant())},Wh.apply(t,arguments)},e.scaleIdentity=function e(t){var n;function r(e){return isNaN(e=+e)?n:e}return r.invert=r,r.domain=r.range=function(e){return arguments.length?(t=Array.from(e,Qh),r):t.slice()},r.unknown=function(e){return arguments.length?(n=e,r):n},r.copy=function(){return e(t).unknown(n)},t=arguments.length?Array.from(t,Qh):[0,1],sp(r)},e.scaleImplicit=Yh,e.scaleLinear=function e(){var t=op();return t.copy=function(){return rp(t,e())},Gh.apply(t,arguments),sp(t)},e.scaleLog=function e(){var t=mp(ip()).domain([1,10]);return t.copy=function(){return rp(t,e()).base(t.base())},Gh.apply(t,arguments),t},e.scaleOrdinal=Zh,e.scalePoint=function(){return Xh(Kh.apply(null,arguments).paddingInner(1))},e.scalePow=Tp,e.scaleQuantile=function e(){var n,r=[],i=[],a=[];function s(){var e=0,t=Math.max(1,i.length);for(a=new Array(t-1);++e0?a[t-1]:r[0],t=i?[a[i-1],r]:[a[t-1],a[t]]},l.unknown=function(e){return arguments.length?(t=e,l):l},l.thresholds=function(){return a.slice()},l.copy=function(){return e().domain([n,r]).range(s).unknown(t)},Gh.apply(sp(l),arguments)},e.scaleRadial=function e(){var t,n=op(),r=[0,1],i=!1;function o(e){var r=Ep(n(e));return isNaN(r)?t:i?Math.round(r):r}return o.invert=function(e){return n.invert(Ap(e))},o.domain=function(e){return arguments.length?(n.domain(e),o):n.domain()},o.range=function(e){return arguments.length?(n.range((r=Array.from(e,Qh)).map(Ap)),o):r.slice()},o.rangeRound=function(e){return o.range(e).round(!0)},o.round=function(e){return arguments.length?(i=!!e,o):i},o.clamp=function(e){return arguments.length?(n.clamp(e),o):n.clamp()},o.unknown=function(e){return arguments.length?(t=e,o):t},o.copy=function(){return e(n.domain(),r).round(i).clamp(n.clamp()).unknown(t)},Gh.apply(o,arguments),sp(o)},e.scaleSequential=function e(){var t=sp(ub()(Jh));return t.copy=function(){return fb(t,e())},Wh.apply(t,arguments)},e.scaleSequentialLog=function e(){var t=mp(ub()).domain([1,10]);return t.copy=function(){return fb(t,e()).base(t.base())},Wh.apply(t,arguments)},e.scaleSequentialPow=db,e.scaleSequentialQuantile=function e(){var n=[],r=Jh;function i(e){if(!isNaN(e=+e))return r((o(n,e,1)-1)/(n.length-1))}return i.domain=function(e){if(!arguments.length)return n.slice();n=[];for(let t of e)null==t||isNaN(t=+t)||n.push(t);return n.sort(t),i},i.interpolator=function(e){return arguments.length?(r=e,i):r},i.range=function(){return n.map(((e,t)=>r(t/(n.length-1))))},i.quantiles=function(e){return Array.from({length:e+1},((t,r)=>I(n,r/e)))},i.copy=function(){return e(r).domain(n)},Wh.apply(i,arguments)},e.scaleSequentialSqrt=function(){return db.apply(null,arguments).exponent(.5)},e.scaleSequentialSymlog=function e(){var t=vp(ub());return t.copy=function(){return fb(t,e()).constant(t.constant())},Wh.apply(t,arguments)},e.scaleSqrt=function(){return Tp.apply(null,arguments).exponent(.5)},e.scaleSymlog=function e(){var t=vp(ip());return t.copy=function(){return rp(t,e()).constant(t.constant())},Gh.apply(t,arguments)},e.scaleThreshold=function e(){var t,n=[.5],r=[0,1],i=1;function a(e){return e<=e?r[o(n,e,0,i)]:t}return a.domain=function(e){return arguments.length?(n=Array.from(e),i=Math.min(n.length,r.length-1),a):n.slice()},a.range=function(e){return arguments.length?(r=Array.from(e),i=Math.min(n.length,r.length-1),a):r.slice()},a.invertExtent=function(e){var t=r.indexOf(e);return[n[t-1],n[t]]},a.unknown=function(e){return arguments.length?(t=e,a):t},a.copy=function(){return e().domain(n).range(r).unknown(t)},Gh.apply(a,arguments)},e.scaleTime=function(){return Gh.apply(cb(sm,om,Gp,Up,Fp,Rp,Pp,Cp,e.timeFormat).domain([new Date(2e3,0,1),new Date(2e3,0,2)]),arguments)},e.scaleUtc=function(){return Gh.apply(cb(Lm,Nm,gm,hm,fm,cm,Pp,Cp,e.utcFormat).domain([Date.UTC(2e3,0,1),Date.UTC(2e3,0,2)]),arguments)},e.scan=function(e,t){const n=U(e,t);return n<0?void 0:n},e.schemeAccent=bb,e.schemeBlues=mv,e.schemeBrBG=Sb,e.schemeBuGn=Gb,e.schemeBuPu=Yb,e.schemeCategory10=gb,e.schemeDark2=vb,e.schemeGnBu=Kb,e.schemeGreens=bv,e.schemeGreys=yv,e.schemeOrRd=Qb,e.schemeOranges=Ev,e.schemePRGn=Cb,e.schemePaired=yb,e.schemePastel1=_b,e.schemePastel2=wb,e.schemePiYG=Db,e.schemePuBu=tv,e.schemePuBuGn=Jb,e.schemePuOr=Ob,e.schemePuRd=rv,e.schemePurples=wv,e.schemeRdBu=Bb,e.schemeRdGy=jb,e.schemeRdPu=ov,e.schemeRdYlBu=zb,e.schemeRdYlGn=qb,e.schemeReds=Tv,e.schemeSet1=xb,e.schemeSet2=Tb,e.schemeSet3=Ab,e.schemeSpectral=Hb,e.schemeTableau10=Eb,e.schemeYlGn=cv,e.schemeYlGnBu=sv,e.schemeYlOrBr=fv,e.schemeYlOrRd=hv,e.select=Tt,e.selectAll=function(e){return"string"==typeof e?new wt([document.querySelectorAll(e)],[document.documentElement]):new wt([null==e?[]:ve(e)],_t)},e.selection=xt,e.selector=be,e.selectorAll=_e,e.shuffle=H,e.shuffler=V,e.some=function(e,t){if("function"!=typeof t)throw new TypeError("test is not a function");let n=-1;for(const r of e)if(t(r,++n,e))return!0;return!1},e.sort=function(e,n=t){if("function"!=typeof e[Symbol.iterator])throw new TypeError("values is not iterable");return e=Array.from(e),1===n.length?(n=e.map(n),F(e,e.map(((e,t)=>t)).sort(((e,r)=>t(n[e],n[r]))))):e.sort(n)},e.stack=function(){var e=zv([]),t=k_,n=E_,r=S_;function i(i){var o,a,s=Array.from(e.apply(this,arguments),M_),l=s.length,c=-1;for(const e of i)for(o=0,++c;o0)for(var n,r,i,o,a,s,l=0,c=e[t[0]].length;l0?(r[0]=o,r[1]=o+=i):i<0?(r[1]=a,r[0]=a+=i):(r[0]=0,r[1]=i)},e.stackOffsetExpand=function(e,t){if((r=e.length)>0){for(var n,r,i,o=0,a=e[0].length;o0){for(var n,r=0,i=e[t[0]],o=i.length;r0&&(r=(n=e[t[0]]).length)>0){for(var n,r,i,o=0,a=1;a0)throw new Error("cycle");return o}return n.id=function(t){return arguments.length?(e=Jd(t),n):e},n.parentId=function(e){return arguments.length?(t=Jd(e),n):t},n},e.style=Ve,e.subset=function(e,t){return Z(t,e)},e.sum=function(e,t){let n=0;if(void 0===t)for(let t of e)(t=+t)&&(n+=t);else{let r=-1;for(let i of e)(i=+t(i,++r,e))&&(n+=i)}return n},e.superset=Z,e.svg=Es,e.symbol=function(e,t){var n=null;function r(){var r;if(n||(n=r=$o()),e.apply(this,arguments).draw(n,+t.apply(this,arguments)),r)return n=null,r+""||null}return e="function"==typeof e?e:zv(e||Cy),t="function"==typeof t?t:zv(void 0===t?64:+t),r.type=function(t){return arguments.length?(e="function"==typeof t?t:zv(t),r):e},r.size=function(e){return arguments.length?(t="function"==typeof e?e:zv(+e),r):t},r.context=function(e){return arguments.length?(n=null==e?null:e,r):n},r},e.symbolCircle=Cy,e.symbolCross=Ny,e.symbolDiamond=Oy,e.symbolSquare=Ry,e.symbolStar=jy,e.symbolTriangle=Fy,e.symbolWye=Gy,e.symbols=Wy,e.text=bs,e.thresholdFreedmanDiaconis=function(e,t,n){return Math.ceil((n-t)/(2*(I(e,.75)-I(e,.25))*Math.pow(l(e),-1/3)))},e.thresholdScott=function(e,t,n){return Math.ceil((n-t)/(3.5*h(e)*Math.pow(l(e),-1/3)))},e.thresholdSturges=M,e.tickFormat=ap,e.tickIncrement=E,e.tickStep=k,e.ticks=A,e.timeDay=Up,e.timeDays=Hp,e.timeFormatDefaultLocale=nb,e.timeFormatLocale=jm,e.timeFriday=Xp,e.timeFridays=rm,e.timeHour=Fp,e.timeHours=qp,e.timeInterval=Mp,e.timeMillisecond=Cp,e.timeMilliseconds=Np,e.timeMinute=Rp,e.timeMinutes=zp,e.timeMonday=Wp,e.timeMondays=Jp,e.timeMonth=om,e.timeMonths=am,e.timeSaturday=Qp,e.timeSaturdays=im,e.timeSecond=Pp,e.timeSeconds=jp,e.timeSunday=Gp,e.timeSundays=$p,e.timeThursday=Kp,e.timeThursdays=nm,e.timeTuesday=Yp,e.timeTuesdays=em,e.timeWednesday=Zp,e.timeWednesdays=tm,e.timeWeek=Gp,e.timeWeeks=$p,e.timeYear=sm,e.timeYears=lm,e.timeout=$r,e.timer=Yr,e.timerFlush=Zr,e.transition=Ii,e.transpose=G,e.tree=function(){var e=dh,t=1,n=1,r=null;function i(i){var l=function(e){for(var t,n,r,i,o,a=new bh(e,0),s=[a];t=s.pop();)if(r=t._.children)for(t.children=new Array(o=r.length),i=o-1;i>=0;--i)s.push(n=t.children[i]=new bh(r[i],i)),n.parent=t;return(a.parent=new bh(null,0)).children=[a],a}(i);if(l.eachAfter(o),l.parent.m=-l.z,l.eachBefore(a),r)i.eachBefore(s);else{var c=i,u=i,f=i;i.eachBefore((function(e){e.xu.x&&(u=e),e.depth>f.depth&&(f=e)}));var d=c===u?1:e(c,u)/2,h=d-c.x,p=t/(u.x+d+h),m=n/(f.depth||1);i.eachBefore((function(e){e.x=(e.x+h)*p,e.y=e.depth*m}))}return i}function o(t){var n=t.children,r=t.parent.children,i=t.i?r[t.i-1]:null;if(n){!function(e){for(var t,n=0,r=0,i=e.children,o=i.length;--o>=0;)(t=i[o]).z+=n,t.m+=n,n+=t.s+(r+=t.c)}(t);var o=(n[0].z+n[n.length-1].z)/2;i?(t.z=i.z+e(t._,i._),t.m=t.z-o):t.z=o}else i&&(t.z=i.z+e(t._,i._));t.parent.A=function(t,n,r){if(n){for(var i,o=t,a=t,s=n,l=o.parent.children[0],c=o.m,u=a.m,f=s.m,d=l.m;s=ph(s),o=hh(o),s&&o;)l=hh(l),(a=ph(a)).a=t,(i=s.z+f-o.z-c+e(s._,o._))>0&&(mh(gh(s,t,r),t,i),c+=i,u+=i),f+=s.m,c+=o.m,d+=l.m,u+=a.m;s&&!ph(a)&&(a.t=s,a.m+=f-u),o&&!hh(l)&&(l.t=o,l.m+=c-d,r=t)}return r}(t,i,t.parent.A||r[0])}function a(e){e._.x=e.z+e.parent.m,e.m+=e.parent.m}function s(e){e.x*=t,e.y=e.depth*n}return i.separation=function(t){return arguments.length?(e=t,i):e},i.size=function(e){return arguments.length?(r=!1,t=+e[0],n=+e[1],i):r?null:[t,n]},i.nodeSize=function(e){return arguments.length?(r=!0,t=+e[0],n=+e[1],i):r?[t,n]:null},i},e.treemap=function(){var e=wh,t=!1,n=1,r=1,i=[0],o=eh,a=eh,s=eh,l=eh,c=eh;function u(e){return e.x0=e.y0=0,e.x1=n,e.y1=r,e.eachBefore(f),i=[0],t&&e.eachBefore(ah),e}function f(t){var n=i[t.depth],r=t.x0+n,u=t.y0+n,f=t.x1-n,d=t.y1-n;f=n-1){var u=s[t];return u.x0=i,u.y0=o,u.x1=a,void(u.y1=l)}for(var f=c[t],d=r/2+f,h=t+1,p=n-1;h>>1;c[m]l-o){var v=r?(i*b+a*g)/r:a;e(t,h,g,i,o,v,l),e(h,n,b,v,o,a,l)}else{var y=r?(o*b+l*g)/r:l;e(t,h,g,i,o,a,y),e(h,n,b,i,y,a,l)}}(0,l,e.value,t,n,r,i)},e.treemapDice=sh,e.treemapResquarify=xh,e.treemapSlice=vh,e.treemapSliceDice=function(e,t,n,r,i){(1&e.depth?vh:sh)(e,t,n,r,i)},e.treemapSquarify=wh,e.tsv=_s,e.tsvFormat=ls,e.tsvFormatBody=cs,e.tsvFormatRow=fs,e.tsvFormatRows=us,e.tsvFormatValue=ds,e.tsvParse=as,e.tsvParseRows=ss,e.union=function(...e){const t=new Set;for(const n of e)for(const e of n)t.add(e);return t},e.utcDay=hm,e.utcDays=pm,e.utcFriday=wm,e.utcFridays=Mm,e.utcHour=fm,e.utcHours=dm,e.utcMillisecond=Cp,e.utcMilliseconds=Np,e.utcMinute=cm,e.utcMinutes=um,e.utcMonday=bm,e.utcMondays=Am,e.utcMonth=Nm,e.utcMonths=Dm,e.utcSaturday=xm,e.utcSaturdays=Cm,e.utcSecond=Pp,e.utcSeconds=jp,e.utcSunday=gm,e.utcSundays=Tm,e.utcThursday=_m,e.utcThursdays=Sm,e.utcTuesday=vm,e.utcTuesdays=Em,e.utcWednesday=ym,e.utcWednesdays=km,e.utcWeek=gm,e.utcWeeks=Tm,e.utcYear=Lm,e.utcYears=Om,e.variance=d,e.version="6.3.0",e.window=Fe,e.xml=Ts,e.zip=function(){return G(arguments)},e.zoom=function(){var e,t,n,r=F_,i=q_,o=G_,a=H_,s=V_,l=[0,1/0],c=[[-1/0,-1/0],[1/0,1/0]],u=250,f=Tr,d=oe("start","zoom","end"),h=500,p=0,m=10;function g(e){e.property("__zoom",U_).on("wheel.zoom",T).on("mousedown.zoom",A).on("dblclick.zoom",E).filter(s).on("touchstart.zoom",k).on("touchmove.zoom",S).on("touchend.zoom touchcancel.zoom",M).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function b(e,t){return(t=Math.max(l[0],Math.min(l[1],t)))===e.k?e:new B_(t,e.x,e.y)}function v(e,t,n){var r=t[0]-n[0]*e.k,i=t[1]-n[1]*e.k;return r===e.x&&i===e.y?e:new B_(e.k,r,i)}function y(e){return[(+e[0][0]+ +e[1][0])/2,(+e[0][1]+ +e[1][1])/2]}function _(e,t,n,r){e.on("start.zoom",(function(){w(this,arguments).event(r).start()})).on("interrupt.zoom end.zoom",(function(){w(this,arguments).event(r).end()})).tween("zoom",(function(){var e=this,o=arguments,a=w(e,o).event(r),s=i.apply(e,o),l=null==n?y(s):"function"==typeof n?n.apply(e,o):n,c=Math.max(s[1][0]-s[0][0],s[1][1]-s[0][1]),u=e.__zoom,d="function"==typeof t?t.apply(e,o):t,h=f(u.invert(l).concat(c/u.k),d.invert(l).concat(c/d.k));return function(e){if(1===e)e=d;else{var t=h(e),n=c/t[2];e=new B_(n,l[0]-t[0]*n,l[1]-t[1]*n)}a.zoom(null,e)}}))}function w(e,t,n){return!n&&e.__zooming||new x(e,t)}function x(e,t){this.that=e,this.args=t,this.active=0,this.sourceEvent=null,this.extent=i.apply(e,t),this.taps=0}function T(e,...t){if(r.apply(this,arguments)){var n=w(this,t).event(e),i=this.__zoom,s=Math.max(l[0],Math.min(l[1],i.k*Math.pow(2,a.apply(this,arguments)))),u=Mt(e);if(n.wheel)n.mouse[0][0]===u[0]&&n.mouse[0][1]===u[1]||(n.mouse[1]=i.invert(n.mouse[0]=u)),clearTimeout(n.wheel);else{if(i.k===s)return;n.mouse=[u,i.invert(u)],oi(this),n.start()}z_(e),n.wheel=setTimeout(f,150),n.zoom("mouse",o(v(b(i,s),n.mouse[0],n.mouse[1]),n.extent,c))}function f(){n.wheel=null,n.end()}}function A(e,...t){if(!n&&r.apply(this,arguments)){var i=w(this,t,!0).event(e),a=Tt(e.view).on("mousemove.zoom",d,!0).on("mouseup.zoom",h,!0),s=Mt(e,l),l=e.currentTarget,u=e.clientX,f=e.clientY;Dt(e.view),R_(e),i.mouse=[s,this.__zoom.invert(s)],oi(this),i.start()}function d(e){if(z_(e),!i.moved){var t=e.clientX-u,n=e.clientY-f;i.moved=t*t+n*n>p}i.event(e).zoom("mouse",o(v(i.that.__zoom,i.mouse[0]=Mt(e,l),i.mouse[1]),i.extent,c))}function h(e){a.on("mousemove.zoom mouseup.zoom",null),Lt(e.view,i.moved),z_(e),i.event(e).end()}}function E(e,...t){if(r.apply(this,arguments)){var n=this.__zoom,a=Mt(e.changedTouches?e.changedTouches[0]:e,this),s=n.invert(a),l=n.k*(e.shiftKey?.5:2),f=o(v(b(n,l),a,s),i.apply(this,t),c);z_(e),u>0?Tt(this).transition().duration(u).call(_,f,a,e):Tt(this).call(g.transform,f,a,e)}}function k(n,...i){if(r.apply(this,arguments)){var o,a,s,l,c=n.touches,u=c.length,f=w(this,i,n.changedTouches.length===u).event(n);for(R_(n),a=0;a>2,s=(3&t)<<4|n>>4,l=1>6:64,c=2>4,n=(15&a)<<4|(s=o.indexOf(e.charAt(c++)))>>2,r=(3&s)<<6|(l=o.indexOf(e.charAt(c++))),d[u++]=t,64!==s&&(d[u++]=n),64!==l&&(d[u++]=r);return d}},{"./support":30,"./utils":32}],2:[function(e,t,n){"use strict";var r=e("./external"),i=e("./stream/DataWorker"),o=e("./stream/DataLengthProbe"),a=e("./stream/Crc32Probe");function s(e,t,n,r,i){this.compressedSize=e,this.uncompressedSize=t,this.crc32=n,this.compression=r,this.compressedContent=i}o=e("./stream/DataLengthProbe"),s.prototype={getContentWorker:function(){var e=new i(r.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new o("data_length")),t=this;return e.on("end",(function(){if(this.streamInfo.data_length!==t.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")})),e},getCompressedWorker:function(){return new i(r.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}},s.createWorkerFrom=function(e,t,n){return e.pipe(new a).pipe(new o("uncompressedSize")).pipe(t.compressWorker(n)).pipe(new o("compressedSize")).withStreamInfo("compression",t)},t.exports=s},{"./external":6,"./stream/Crc32Probe":25,"./stream/DataLengthProbe":26,"./stream/DataWorker":27}],3:[function(e,t,n){"use strict";var r=e("./stream/GenericWorker");n.STORE={magic:"\0\0",compressWorker:function(e){return new r("STORE compression")},uncompressWorker:function(){return new r("STORE decompression")}},n.DEFLATE=e("./flate")},{"./flate":7,"./stream/GenericWorker":28}],4:[function(e,t,n){"use strict";var r=e("./utils"),i=function(){for(var e,t=[],n=0;n<256;n++){e=n;for(var r=0;r<8;r++)e=1&e?3988292384^e>>>1:e>>>1;t[n]=e}return t}();t.exports=function(e,t){return void 0!==e&&e.length?"string"!==r.getTypeOf(e)?function(e,t,n,r){var o=i,a=0+n;e^=-1;for(var s=0;s>>8^o[255&(e^t[s])];return-1^e}(0|t,e,e.length):function(e,t,n,r){var o=i,a=0+n;e^=-1;for(var s=0;s>>8^o[255&(e^t.charCodeAt(s))];return-1^e}(0|t,e,e.length):0}},{"./utils":32}],5:[function(e,t,n){"use strict";n.base64=!1,n.binary=!1,n.dir=!1,n.createFolders=!0,n.date=null,n.compression=null,n.compressionOptions=null,n.comment=null,n.unixPermissions=null,n.dosPermissions=null},{}],6:[function(e,t,n){"use strict";var r;r="undefined"!=typeof Promise?Promise:e("lie"),t.exports={Promise:r}},{lie:37}],7:[function(e,t,n){"use strict";var r="undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint16Array&&"undefined"!=typeof Uint32Array,i=e("pako"),o=e("./utils"),a=e("./stream/GenericWorker"),s=r?"uint8array":"array";function l(e,t){a.call(this,"FlateWorker/"+e),this._pako=null,this._pakoAction=e,this._pakoOptions=t,this.meta={}}n.magic="\b\0",o.inherits(l,a),l.prototype.processChunk=function(e){this.meta=e.meta,null===this._pako&&this._createPako(),this._pako.push(o.transformTo(s,e.data),!1)},l.prototype.flush=function(){a.prototype.flush.call(this),null===this._pako&&this._createPako(),this._pako.push([],!0)},l.prototype.cleanUp=function(){a.prototype.cleanUp.call(this),this._pako=null},l.prototype._createPako=function(){this._pako=new i[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var e=this;this._pako.onData=function(t){e.push({data:t,meta:e.meta})}},n.compressWorker=function(e){return new l("Deflate",e)},n.uncompressWorker=function(){return new l("Inflate",{})}},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(e,t,n){"use strict";function r(e,t){var n,r="";for(n=0;n>>=8;return r}function i(e,t,n,i,a,u){var f,d,h=e.file,p=e.compression,m=u!==s.utf8encode,g=o.transformTo("string",u(h.name)),b=o.transformTo("string",s.utf8encode(h.name)),v=h.comment,y=o.transformTo("string",u(v)),_=o.transformTo("string",s.utf8encode(v)),w=b.length!==h.name.length,x=_.length!==v.length,T="",A="",E="",k=h.dir,S=h.date,M={crc32:0,compressedSize:0,uncompressedSize:0};t&&!n||(M.crc32=e.crc32,M.compressedSize=e.compressedSize,M.uncompressedSize=e.uncompressedSize);var C=0;t&&(C|=8),m||!w&&!x||(C|=2048);var N=0,D=0;k&&(N|=16),"UNIX"===a?(D=798,N|=function(e,t){var n=e;return e||(n=t?16893:33204),(65535&n)<<16}(h.unixPermissions,k)):(D=20,N|=function(e){return 63&(e||0)}(h.dosPermissions)),f=S.getUTCHours(),f<<=6,f|=S.getUTCMinutes(),f<<=5,f|=S.getUTCSeconds()/2,d=S.getUTCFullYear()-1980,d<<=4,d|=S.getUTCMonth()+1,d<<=5,d|=S.getUTCDate(),w&&(A=r(1,1)+r(l(g),4)+b,T+="up"+r(A.length,2)+A),x&&(E=r(1,1)+r(l(y),4)+_,T+="uc"+r(E.length,2)+E);var L="";return L+="\n\0",L+=r(C,2),L+=p.magic,L+=r(f,2),L+=r(d,2),L+=r(M.crc32,4),L+=r(M.compressedSize,4),L+=r(M.uncompressedSize,4),L+=r(g.length,2),L+=r(T.length,2),{fileRecord:c.LOCAL_FILE_HEADER+L+g+T,dirRecord:c.CENTRAL_FILE_HEADER+r(D,2)+L+r(y.length,2)+"\0\0\0\0"+r(N,4)+r(i,4)+g+T+y}}var o=e("../utils"),a=e("../stream/GenericWorker"),s=e("../utf8"),l=e("../crc32"),c=e("../signature");function u(e,t,n,r){a.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=t,this.zipPlatform=n,this.encodeFileName=r,this.streamFiles=e,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}o.inherits(u,a),u.prototype.push=function(e){var t=e.meta.percent||0,n=this.entriesCount,r=this._sources.length;this.accumulate?this.contentBuffer.push(e):(this.bytesWritten+=e.data.length,a.prototype.push.call(this,{data:e.data,meta:{currentFile:this.currentFile,percent:n?(t+100*(n-r-1))/n:100}}))},u.prototype.openedSource=function(e){this.currentSourceOffset=this.bytesWritten,this.currentFile=e.file.name;var t=this.streamFiles&&!e.file.dir;if(t){var n=i(e,t,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:n.fileRecord,meta:{percent:0}})}else this.accumulate=!0},u.prototype.closedSource=function(e){this.accumulate=!1;var t=this.streamFiles&&!e.file.dir,n=i(e,t,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(n.dirRecord),t)this.push({data:function(e){return c.DATA_DESCRIPTOR+r(e.crc32,4)+r(e.compressedSize,4)+r(e.uncompressedSize,4)}(e),meta:{percent:100}});else for(this.push({data:n.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},u.prototype.flush=function(){for(var e=this.bytesWritten,t=0;t=this.index;t--)n=(n<<8)+this.byteAt(t);return this.index+=e,n},readString:function(e){return r.transformTo("string",this.readData(e))},readData:function(e){},lastIndexOfSignature:function(e){},readAndCheckSignature:function(e){},readDate:function(){var e=this.readInt(4);return new Date(Date.UTC(1980+(e>>25&127),(e>>21&15)-1,e>>16&31,e>>11&31,e>>5&63,(31&e)<<1))}},t.exports=i},{"../utils":32}],19:[function(e,t,n){"use strict";var r=e("./Uint8ArrayReader");function i(e){r.call(this,e)}e("../utils").inherits(i,r),i.prototype.readData=function(e){this.checkOffset(e);var t=this.data.slice(this.zero+this.index,this.zero+this.index+e);return this.index+=e,t},t.exports=i},{"../utils":32,"./Uint8ArrayReader":21}],20:[function(e,t,n){"use strict";var r=e("./DataReader");function i(e){r.call(this,e)}e("../utils").inherits(i,r),i.prototype.byteAt=function(e){return this.data.charCodeAt(this.zero+e)},i.prototype.lastIndexOfSignature=function(e){return this.data.lastIndexOf(e)-this.zero},i.prototype.readAndCheckSignature=function(e){return e===this.readData(4)},i.prototype.readData=function(e){this.checkOffset(e);var t=this.data.slice(this.zero+this.index,this.zero+this.index+e);return this.index+=e,t},t.exports=i},{"../utils":32,"./DataReader":18}],21:[function(e,t,n){"use strict";var r=e("./ArrayReader");function i(e){r.call(this,e)}e("../utils").inherits(i,r),i.prototype.readData=function(e){if(this.checkOffset(e),0===e)return new Uint8Array(0);var t=this.data.subarray(this.zero+this.index,this.zero+this.index+e);return this.index+=e,t},t.exports=i},{"../utils":32,"./ArrayReader":17}],22:[function(e,t,n){"use strict";var r=e("../utils"),i=e("../support"),o=e("./ArrayReader"),a=e("./StringReader"),s=e("./NodeBufferReader"),l=e("./Uint8ArrayReader");t.exports=function(e){var t=r.getTypeOf(e);return r.checkSupport(t),"string"!==t||i.uint8array?"nodebuffer"===t?new s(e):i.uint8array?new l(r.transformTo("uint8array",e)):new o(r.transformTo("array",e)):new a(e)}},{"../support":30,"../utils":32,"./ArrayReader":17,"./NodeBufferReader":19,"./StringReader":20,"./Uint8ArrayReader":21}],23:[function(e,t,n){"use strict";n.LOCAL_FILE_HEADER="PK",n.CENTRAL_FILE_HEADER="PK",n.CENTRAL_DIRECTORY_END="PK",n.ZIP64_CENTRAL_DIRECTORY_LOCATOR="PK",n.ZIP64_CENTRAL_DIRECTORY_END="PK",n.DATA_DESCRIPTOR="PK\b"},{}],24:[function(e,t,n){"use strict";var r=e("./GenericWorker"),i=e("../utils");function o(e){r.call(this,"ConvertWorker to "+e),this.destType=e}i.inherits(o,r),o.prototype.processChunk=function(e){this.push({data:i.transformTo(this.destType,e.data),meta:e.meta})},t.exports=o},{"../utils":32,"./GenericWorker":28}],25:[function(e,t,n){"use strict";var r=e("./GenericWorker"),i=e("../crc32");function o(){r.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0)}e("../utils").inherits(o,r),o.prototype.processChunk=function(e){this.streamInfo.crc32=i(e.data,this.streamInfo.crc32||0),this.push(e)},t.exports=o},{"../crc32":4,"../utils":32,"./GenericWorker":28}],26:[function(e,t,n){"use strict";var r=e("../utils"),i=e("./GenericWorker");function o(e){i.call(this,"DataLengthProbe for "+e),this.propName=e,this.withStreamInfo(e,0)}r.inherits(o,i),o.prototype.processChunk=function(e){if(e){var t=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=t+e.data.length}i.prototype.processChunk.call(this,e)},t.exports=o},{"../utils":32,"./GenericWorker":28}],27:[function(e,t,n){"use strict";var r=e("../utils"),i=e("./GenericWorker");function o(e){i.call(this,"DataWorker");var t=this;this.dataIsReady=!1,this.index=0,this.max=0,this.data=null,this.type="",this._tickScheduled=!1,e.then((function(e){t.dataIsReady=!0,t.data=e,t.max=e&&e.length||0,t.type=r.getTypeOf(e),t.isPaused||t._tickAndRepeat()}),(function(e){t.error(e)}))}r.inherits(o,i),o.prototype.cleanUp=function(){i.prototype.cleanUp.call(this),this.data=null},o.prototype.resume=function(){return!!i.prototype.resume.call(this)&&(!this._tickScheduled&&this.dataIsReady&&(this._tickScheduled=!0,r.delay(this._tickAndRepeat,[],this)),!0)},o.prototype._tickAndRepeat=function(){this._tickScheduled=!1,this.isPaused||this.isFinished||(this._tick(),this.isFinished||(r.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0))},o.prototype._tick=function(){if(this.isPaused||this.isFinished)return!1;var e=null,t=Math.min(this.max,this.index+16384);if(this.index>=this.max)return this.end();switch(this.type){case"string":e=this.data.substring(this.index,t);break;case"uint8array":e=this.data.subarray(this.index,t);break;case"array":case"nodebuffer":e=this.data.slice(this.index,t)}return this.index=t,this.push({data:e,meta:{percent:this.max?this.index/this.max*100:0}})},t.exports=o},{"../utils":32,"./GenericWorker":28}],28:[function(e,t,n){"use strict";function r(e){this.name=e||"default",this.streamInfo={},this.generatedError=null,this.extraStreamInfo={},this.isPaused=!0,this.isFinished=!1,this.isLocked=!1,this._listeners={data:[],end:[],error:[]},this.previous=null}r.prototype={push:function(e){this.emit("data",e)},end:function(){if(this.isFinished)return!1;this.flush();try{this.emit("end"),this.cleanUp(),this.isFinished=!0}catch(e){this.emit("error",e)}return!0},error:function(e){return!this.isFinished&&(this.isPaused?this.generatedError=e:(this.isFinished=!0,this.emit("error",e),this.previous&&this.previous.error(e),this.cleanUp()),!0)},on:function(e,t){return this._listeners[e].push(t),this},cleanUp:function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[]},emit:function(e,t){if(this._listeners[e])for(var n=0;n "+e:e}},t.exports=r},{}],29:[function(e,t,n){"use strict";var r=e("../utils"),i=e("./ConvertWorker"),o=e("./GenericWorker"),a=e("../base64"),s=e("../support"),l=e("../external"),c=null;if(s.nodestream)try{c=e("../nodejs/NodejsStreamOutputAdapter")}catch(e){}function u(e,t,n){var a=t;switch(t){case"blob":case"arraybuffer":a="uint8array";break;case"base64":a="string"}try{this._internalType=a,this._outputType=t,this._mimeType=n,r.checkSupport(a),this._worker=e.pipe(new i(a)),e.lock()}catch(e){this._worker=new o("error"),this._worker.error(e)}}u.prototype={accumulate:function(e){return function(e,t){return new l.Promise((function(n,i){var o=[],s=e._internalType,l=e._outputType,c=e._mimeType;e.on("data",(function(e,n){o.push(e),t&&t(n)})).on("error",(function(e){o=[],i(e)})).on("end",(function(){try{var e=function(e,t,n){switch(e){case"blob":return r.newBlob(r.transformTo("arraybuffer",t),n);case"base64":return a.encode(t);default:return r.transformTo(e,t)}}(l,function(e,t){var n,r=0,i=null,o=0;for(n=0;n>>6:(n<65536?t[a++]=224|n>>>12:(t[a++]=240|n>>>18,t[a++]=128|n>>>12&63),t[a++]=128|n>>>6&63),t[a++]=128|63&n);return t}(e)},n.utf8decode=function(e){return i.nodebuffer?r.transformTo("nodebuffer",e).toString("utf-8"):function(e){var t,n,i,o,a=e.length,l=new Array(2*a);for(t=n=0;t>10&1023,l[n++]=56320|1023&i)}return l.length!==n&&(l.subarray?l=l.subarray(0,n):l.length=n),r.applyFromCharCode(l)}(e=r.transformTo(i.uint8array?"uint8array":"array",e))},r.inherits(c,a),c.prototype.processChunk=function(e){var t=r.transformTo(i.uint8array?"uint8array":"array",e.data);if(this.leftOver&&this.leftOver.length){if(i.uint8array){var o=t;(t=new Uint8Array(o.length+this.leftOver.length)).set(this.leftOver,0),t.set(o,this.leftOver.length)}else t=this.leftOver.concat(t);this.leftOver=null}var a=function(e,t){var n;for((t=t||e.length)>e.length&&(t=e.length),n=t-1;0<=n&&128==(192&e[n]);)n--;return n<0||0===n?t:n+s[e[n]]>t?n:t}(t),l=t;a!==t.length&&(i.uint8array?(l=t.subarray(0,a),this.leftOver=t.subarray(a,t.length)):(l=t.slice(0,a),this.leftOver=t.slice(a,t.length))),this.push({data:n.utf8decode(l),meta:e.meta})},c.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:n.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},n.Utf8DecodeWorker=c,r.inherits(u,a),u.prototype.processChunk=function(e){this.push({data:n.utf8encode(e.data),meta:e.meta})},n.Utf8EncodeWorker=u},{"./nodejsUtils":14,"./stream/GenericWorker":28,"./support":30,"./utils":32}],32:[function(e,t,n){"use strict";var r=e("./support"),i=e("./base64"),o=e("./nodejsUtils"),a=e("set-immediate-shim"),s=e("./external");function l(e){return e}function c(e,t){for(var n=0;n>8;this.dir=!!(16&this.externalFileAttributes),0==e&&(this.dosPermissions=63&this.externalFileAttributes),3==e&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||"/"!==this.fileNameStr.slice(-1)||(this.dir=!0)},parseZIP64ExtraField:function(e){if(this.extraFields[1]){var t=r(this.extraFields[1].value);this.uncompressedSize===i.MAX_VALUE_32BITS&&(this.uncompressedSize=t.readInt(8)),this.compressedSize===i.MAX_VALUE_32BITS&&(this.compressedSize=t.readInt(8)),this.localHeaderOffset===i.MAX_VALUE_32BITS&&(this.localHeaderOffset=t.readInt(8)),this.diskNumberStart===i.MAX_VALUE_32BITS&&(this.diskNumberStart=t.readInt(4))}},readExtraFields:function(e){var t,n,r,i=e.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});e.index>>6:(n<65536?t[a++]=224|n>>>12:(t[a++]=240|n>>>18,t[a++]=128|n>>>12&63),t[a++]=128|n>>>6&63),t[a++]=128|63&n);return t},n.buf2binstring=function(e){return l(e,e.length)},n.binstring2buf=function(e){for(var t=new r.Buf8(e.length),n=0,i=t.length;n>10&1023,c[r++]=56320|1023&i)}return l(c,r)},n.utf8border=function(e,t){var n;for((t=t||e.length)>e.length&&(t=e.length),n=t-1;0<=n&&128==(192&e[n]);)n--;return n<0||0===n?t:n+a[e[n]]>t?n:t}},{"./common":41}],43:[function(e,t,n){"use strict";t.exports=function(e,t,n,r){for(var i=65535&e|0,o=e>>>16&65535|0,a=0;0!==n;){for(n-=a=2e3>>1:e>>>1;t[n]=e}return t}();t.exports=function(e,t,n,i){var o=r,a=i+n;e^=-1;for(var s=i;s>>8^o[255&(e^t[s])];return-1^e}},{}],46:[function(e,t,n){"use strict";var r,i=e("../utils/common"),o=e("./trees"),a=e("./adler32"),s=e("./crc32"),l=e("./messages"),c=-2,u=258,f=262,d=113;function h(e,t){return e.msg=l[t],t}function p(e){return(e<<1)-(4e.avail_out&&(n=e.avail_out),0!==n&&(i.arraySet(e.output,t.pending_buf,t.pending_out,n,e.next_out),e.next_out+=n,t.pending_out+=n,e.total_out+=n,e.avail_out-=n,t.pending-=n,0===t.pending&&(t.pending_out=0))}function b(e,t){o._tr_flush_block(e,0<=e.block_start?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,g(e.strm)}function v(e,t){e.pending_buf[e.pending++]=t}function y(e,t){e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=255&t}function _(e,t){var n,r,i=e.max_chain_length,o=e.strstart,a=e.prev_length,s=e.nice_match,l=e.strstart>e.w_size-f?e.strstart-(e.w_size-f):0,c=e.window,d=e.w_mask,h=e.prev,p=e.strstart+u,m=c[o+a-1],g=c[o+a];e.prev_length>=e.good_match&&(i>>=2),s>e.lookahead&&(s=e.lookahead);do{if(c[(n=t)+a]===g&&c[n+a-1]===m&&c[n]===c[o]&&c[++n]===c[o+1]){o+=2,n++;do{}while(c[++o]===c[++n]&&c[++o]===c[++n]&&c[++o]===c[++n]&&c[++o]===c[++n]&&c[++o]===c[++n]&&c[++o]===c[++n]&&c[++o]===c[++n]&&c[++o]===c[++n]&&ol&&0!=--i);return a<=e.lookahead?a:e.lookahead}function w(e){var t,n,r,o,l,c,u,d,h,p,m=e.w_size;do{if(o=e.window_size-e.lookahead-e.strstart,e.strstart>=m+(m-f)){for(i.arraySet(e.window,e.window,m,m,0),e.match_start-=m,e.strstart-=m,e.block_start-=m,t=n=e.hash_size;r=e.head[--t],e.head[t]=m<=r?r-m:0,--n;);for(t=n=m;r=e.prev[--t],e.prev[t]=m<=r?r-m:0,--n;);o+=m}if(0===e.strm.avail_in)break;if(c=e.strm,u=e.window,d=e.strstart+e.lookahead,p=void 0,(h=o)<(p=c.avail_in)&&(p=h),n=0===p?0:(c.avail_in-=p,i.arraySet(u,c.input,c.next_in,p,d),1===c.state.wrap?c.adler=a(c.adler,u,p,d):2===c.state.wrap&&(c.adler=s(c.adler,u,p,d)),c.next_in+=p,c.total_in+=p,p),e.lookahead+=n,e.lookahead+e.insert>=3)for(l=e.strstart-e.insert,e.ins_h=e.window[l],e.ins_h=(e.ins_h<=3&&(e.ins_h=(e.ins_h<=3)if(r=o._tr_tally(e,e.strstart-e.match_start,e.match_length-3),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=3){for(e.match_length--;e.strstart++,e.ins_h=(e.ins_h<=3&&(e.ins_h=(e.ins_h<=3&&e.match_length<=e.prev_length){for(i=e.strstart+e.lookahead-3,r=o._tr_tally(e,e.strstart-1-e.prev_match,e.prev_length-3),e.lookahead-=e.prev_length-1,e.prev_length-=2;++e.strstart<=i&&(e.ins_h=(e.ins_h<e.pending_buf_size-5&&(n=e.pending_buf_size-5);;){if(e.lookahead<=1){if(w(e),0===e.lookahead&&0===t)return 1;if(0===e.lookahead)break}e.strstart+=e.lookahead,e.lookahead=0;var r=e.block_start+n;if((0===e.strstart||e.strstart>=r)&&(e.lookahead=e.strstart-r,e.strstart=r,b(e,!1),0===e.strm.avail_out))return 1;if(e.strstart-e.block_start>=e.w_size-f&&(b(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,4===t?(b(e,!0),0===e.strm.avail_out?3:4):(e.strstart>e.block_start&&(b(e,!1),e.strm.avail_out),1)})),new A(4,4,8,4,x),new A(4,5,16,8,x),new A(4,6,32,32,x),new A(4,4,16,16,T),new A(8,16,32,32,T),new A(8,16,128,128,T),new A(8,32,128,256,T),new A(32,128,258,1024,T),new A(32,258,258,4096,T)],n.deflateInit=function(e,t){return M(e,t,8,15,8,0)},n.deflateInit2=M,n.deflateReset=S,n.deflateResetKeep=k,n.deflateSetHeader=function(e,t){return e&&e.state?2!==e.state.wrap?c:(e.state.gzhead=t,0):c},n.deflate=function(e,t){var n,i,a,l;if(!e||!e.state||5>8&255),v(i,i.gzhead.time>>16&255),v(i,i.gzhead.time>>24&255),v(i,9===i.level?2:2<=i.strategy||i.level<2?4:0),v(i,255&i.gzhead.os),i.gzhead.extra&&i.gzhead.extra.length&&(v(i,255&i.gzhead.extra.length),v(i,i.gzhead.extra.length>>8&255)),i.gzhead.hcrc&&(e.adler=s(e.adler,i.pending_buf,i.pending,0)),i.gzindex=0,i.status=69):(v(i,0),v(i,0),v(i,0),v(i,0),v(i,0),v(i,9===i.level?2:2<=i.strategy||i.level<2?4:0),v(i,3),i.status=d);else{var f=8+(i.w_bits-8<<4)<<8;f|=(2<=i.strategy||i.level<2?0:i.level<6?1:6===i.level?2:3)<<6,0!==i.strstart&&(f|=32),f+=31-f%31,i.status=d,y(i,f),0!==i.strstart&&(y(i,e.adler>>>16),y(i,65535&e.adler)),e.adler=1}if(69===i.status)if(i.gzhead.extra){for(a=i.pending;i.gzindex<(65535&i.gzhead.extra.length)&&(i.pending!==i.pending_buf_size||(i.gzhead.hcrc&&i.pending>a&&(e.adler=s(e.adler,i.pending_buf,i.pending-a,a)),g(e),a=i.pending,i.pending!==i.pending_buf_size));)v(i,255&i.gzhead.extra[i.gzindex]),i.gzindex++;i.gzhead.hcrc&&i.pending>a&&(e.adler=s(e.adler,i.pending_buf,i.pending-a,a)),i.gzindex===i.gzhead.extra.length&&(i.gzindex=0,i.status=73)}else i.status=73;if(73===i.status)if(i.gzhead.name){a=i.pending;do{if(i.pending===i.pending_buf_size&&(i.gzhead.hcrc&&i.pending>a&&(e.adler=s(e.adler,i.pending_buf,i.pending-a,a)),g(e),a=i.pending,i.pending===i.pending_buf_size)){l=1;break}l=i.gzindexa&&(e.adler=s(e.adler,i.pending_buf,i.pending-a,a)),0===l&&(i.gzindex=0,i.status=91)}else i.status=91;if(91===i.status)if(i.gzhead.comment){a=i.pending;do{if(i.pending===i.pending_buf_size&&(i.gzhead.hcrc&&i.pending>a&&(e.adler=s(e.adler,i.pending_buf,i.pending-a,a)),g(e),a=i.pending,i.pending===i.pending_buf_size)){l=1;break}l=i.gzindexa&&(e.adler=s(e.adler,i.pending_buf,i.pending-a,a)),0===l&&(i.status=103)}else i.status=103;if(103===i.status&&(i.gzhead.hcrc?(i.pending+2>i.pending_buf_size&&g(e),i.pending+2<=i.pending_buf_size&&(v(i,255&e.adler),v(i,e.adler>>8&255),e.adler=0,i.status=d)):i.status=d),0!==i.pending){if(g(e),0===e.avail_out)return i.last_flush=-1,0}else if(0===e.avail_in&&p(t)<=p(n)&&4!==t)return h(e,-5);if(666===i.status&&0!==e.avail_in)return h(e,-5);if(0!==e.avail_in||0!==i.lookahead||0!==t&&666!==i.status){var _=2===i.strategy?function(e,t){for(var n;;){if(0===e.lookahead&&(w(e),0===e.lookahead)){if(0===t)return 1;break}if(e.match_length=0,n=o._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,n&&(b(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,4===t?(b(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(b(e,!1),0===e.strm.avail_out)?1:2}(i,t):3===i.strategy?function(e,t){for(var n,r,i,a,s=e.window;;){if(e.lookahead<=u){if(w(e),e.lookahead<=u&&0===t)return 1;if(0===e.lookahead)break}if(e.match_length=0,e.lookahead>=3&&0e.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=3?(n=o._tr_tally(e,1,e.match_length-3),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(n=o._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),n&&(b(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,4===t?(b(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(b(e,!1),0===e.strm.avail_out)?1:2}(i,t):r[i.level].func(i,t);if(3!==_&&4!==_||(i.status=666),1===_||3===_)return 0===e.avail_out&&(i.last_flush=-1),0;if(2===_&&(1===t?o._tr_align(i):5!==t&&(o._tr_stored_block(i,0,0,!1),3===t&&(m(i.head),0===i.lookahead&&(i.strstart=0,i.block_start=0,i.insert=0))),g(e),0===e.avail_out))return i.last_flush=-1,0}return 4!==t?0:i.wrap<=0?1:(2===i.wrap?(v(i,255&e.adler),v(i,e.adler>>8&255),v(i,e.adler>>16&255),v(i,e.adler>>24&255),v(i,255&e.total_in),v(i,e.total_in>>8&255),v(i,e.total_in>>16&255),v(i,e.total_in>>24&255)):(y(i,e.adler>>>16),y(i,65535&e.adler)),g(e),0=n.w_size&&(0===s&&(m(n.head),n.strstart=0,n.block_start=0,n.insert=0),d=new i.Buf8(n.w_size),i.arraySet(d,t,h-n.w_size,n.w_size,0),t=d,h=n.w_size),l=e.avail_in,u=e.next_in,f=e.input,e.avail_in=h,e.next_in=0,e.input=t,w(n);n.lookahead>=3;){for(r=n.strstart,o=n.lookahead-2;n.ins_h=(n.ins_h<>>=_=y>>>24,p-=_,0==(_=y>>>16&255))k[o++]=65535&y;else{if(!(16&_)){if(0==(64&_)){y=m[(65535&y)+(h&(1<<_)-1)];continue t}if(32&_){n.mode=12;break e}e.msg="invalid literal/length code",n.mode=30;break e}w=65535&y,(_&=15)&&(p<_&&(h+=E[r++]<>>=_,p-=_),p<15&&(h+=E[r++]<>>=_=y>>>24,p-=_,!(16&(_=y>>>16&255))){if(0==(64&_)){y=g[(65535&y)+(h&(1<<_)-1)];continue n}e.msg="invalid distance code",n.mode=30;break e}if(x=65535&y,p<(_&=15)&&(h+=E[r++]<>>=_,p-=_,(_=o-a)>3,h&=(1<<(p-=w<<3))-1,e.next_in=r,e.next_out=o,e.avail_in=r>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24)}function u(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new r.Buf16(320),this.work=new r.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function f(e){var t;return e&&e.state?(t=e.state,e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=1&t.wrap),t.mode=1,t.last=0,t.havedict=0,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new r.Buf32(852),t.distcode=t.distdyn=new r.Buf32(592),t.sane=1,t.back=-1,0):l}function d(e){var t;return e&&e.state?((t=e.state).wsize=0,t.whave=0,t.wnext=0,f(e)):l}function h(e,t){var n,r;return e&&e.state?(r=e.state,t<0?(n=0,t=-t):(n=1+(t>>4),t<48&&(t&=15)),t&&(t<8||15=a.wsize?(r.arraySet(a.window,t,n-a.wsize,a.wsize,0),a.wnext=0,a.whave=a.wsize):(i<(o=a.wsize-a.wnext)&&(o=i),r.arraySet(a.window,t,n-i,o,a.wnext),(i-=o)?(r.arraySet(a.window,t,n-i,i,0),a.wnext=i,a.whave=a.wsize):(a.wnext+=o,a.wnext===a.wsize&&(a.wnext=0),a.whave>>8&255,n.check=o(n.check,P,2,0),b=g=0,n.mode=2;break}if(n.flags=0,n.head&&(n.head.done=!1),!(1&n.wrap)||(((255&g)<<8)+(g>>8))%31){e.msg="incorrect header check",n.mode=30;break}if(8!=(15&g)){e.msg="unknown compression method",n.mode=30;break}if(b-=4,D=8+(15&(g>>>=4)),0===n.wbits)n.wbits=D;else if(D>n.wbits){e.msg="invalid window size",n.mode=30;break}n.dmax=1<>8&1),512&n.flags&&(P[0]=255&g,P[1]=g>>>8&255,n.check=o(n.check,P,2,0)),b=g=0,n.mode=3;case 3:for(;b<32;){if(0===p)break e;p--,g+=u[d++]<>>8&255,P[2]=g>>>16&255,P[3]=g>>>24&255,n.check=o(n.check,P,4,0)),b=g=0,n.mode=4;case 4:for(;b<16;){if(0===p)break e;p--,g+=u[d++]<>8),512&n.flags&&(P[0]=255&g,P[1]=g>>>8&255,n.check=o(n.check,P,2,0)),b=g=0,n.mode=5;case 5:if(1024&n.flags){for(;b<16;){if(0===p)break e;p--,g+=u[d++]<>>8&255,n.check=o(n.check,P,2,0)),b=g=0}else n.head&&(n.head.extra=null);n.mode=6;case 6:if(1024&n.flags&&(p<(x=n.length)&&(x=p),x&&(n.head&&(D=n.head.extra_len-n.length,n.head.extra||(n.head.extra=new Array(n.head.extra_len)),r.arraySet(n.head.extra,u,d,x,D)),512&n.flags&&(n.check=o(n.check,u,x,d)),p-=x,d+=x,n.length-=x),n.length))break e;n.length=0,n.mode=7;case 7:if(2048&n.flags){if(0===p)break e;for(x=0;D=u[d+x++],n.head&&D&&n.length<65536&&(n.head.name+=String.fromCharCode(D)),D&&x>9&1,n.head.done=!0),e.adler=n.check=0,n.mode=12;break;case 10:for(;b<32;){if(0===p)break e;p--,g+=u[d++]<>>=7&b,b-=7&b,n.mode=27;break}for(;b<3;){if(0===p)break e;p--,g+=u[d++]<>>=1)){case 0:n.mode=14;break;case 1:if(v(n),n.mode=20,6!==t)break;g>>>=2,b-=2;break e;case 2:n.mode=17;break;case 3:e.msg="invalid block type",n.mode=30}g>>>=2,b-=2;break;case 14:for(g>>>=7&b,b-=7&b;b<32;){if(0===p)break e;p--,g+=u[d++]<>>16^65535)){e.msg="invalid stored block lengths",n.mode=30;break}if(n.length=65535&g,b=g=0,n.mode=15,6===t)break e;case 15:n.mode=16;case 16:if(x=n.length){if(p>>=5,b-=5,n.ndist=1+(31&g),g>>>=5,b-=5,n.ncode=4+(15&g),g>>>=4,b-=4,286>>=3,b-=3}for(;n.have<19;)n.lens[j[n.have++]]=0;if(n.lencode=n.lendyn,n.lenbits=7,O={bits:n.lenbits},L=s(0,n.lens,0,19,n.lencode,0,n.work,O),n.lenbits=O.bits,L){e.msg="invalid code lengths set",n.mode=30;break}n.have=0,n.mode=19;case 19:for(;n.have>>16&255,S=65535&B,!((E=B>>>24)<=b);){if(0===p)break e;p--,g+=u[d++]<>>=E,b-=E,n.lens[n.have++]=S;else{if(16===S){for(I=E+2;b>>=E,b-=E,0===n.have){e.msg="invalid bit length repeat",n.mode=30;break}D=n.lens[n.have-1],x=3+(3&g),g>>>=2,b-=2}else if(17===S){for(I=E+3;b>>=E)),g>>>=3,b-=3}else{for(I=E+7;b>>=E)),g>>>=7,b-=7}if(n.have+x>n.nlen+n.ndist){e.msg="invalid bit length repeat",n.mode=30;break}for(;x--;)n.lens[n.have++]=D}}if(30===n.mode)break;if(0===n.lens[256]){e.msg="invalid code -- missing end-of-block",n.mode=30;break}if(n.lenbits=9,O={bits:n.lenbits},L=s(1,n.lens,0,n.nlen,n.lencode,0,n.work,O),n.lenbits=O.bits,L){e.msg="invalid literal/lengths set",n.mode=30;break}if(n.distbits=6,n.distcode=n.distdyn,O={bits:n.distbits},L=s(2,n.lens,n.nlen,n.ndist,n.distcode,0,n.work,O),n.distbits=O.bits,L){e.msg="invalid distances set",n.mode=30;break}if(n.mode=20,6===t)break e;case 20:n.mode=21;case 21:if(6<=p&&258<=m){e.next_out=h,e.avail_out=m,e.next_in=d,e.avail_in=p,n.hold=g,n.bits=b,a(e,w),h=e.next_out,f=e.output,m=e.avail_out,d=e.next_in,u=e.input,p=e.avail_in,g=n.hold,b=n.bits,12===n.mode&&(n.back=-1);break}for(n.back=0;k=(B=n.lencode[g&(1<>>16&255,S=65535&B,!((E=B>>>24)<=b);){if(0===p)break e;p--,g+=u[d++]<>M)])>>>16&255,S=65535&B,!(M+(E=B>>>24)<=b);){if(0===p)break e;p--,g+=u[d++]<>>=M,b-=M,n.back+=M}if(g>>>=E,b-=E,n.back+=E,n.length=S,0===k){n.mode=26;break}if(32&k){n.back=-1,n.mode=12;break}if(64&k){e.msg="invalid literal/length code",n.mode=30;break}n.extra=15&k,n.mode=22;case 22:if(n.extra){for(I=n.extra;b>>=n.extra,b-=n.extra,n.back+=n.extra}n.was=n.length,n.mode=23;case 23:for(;k=(B=n.distcode[g&(1<>>16&255,S=65535&B,!((E=B>>>24)<=b);){if(0===p)break e;p--,g+=u[d++]<>M)])>>>16&255,S=65535&B,!(M+(E=B>>>24)<=b);){if(0===p)break e;p--,g+=u[d++]<>>=M,b-=M,n.back+=M}if(g>>>=E,b-=E,n.back+=E,64&k){e.msg="invalid distance code",n.mode=30;break}n.offset=S,n.extra=15&k,n.mode=24;case 24:if(n.extra){for(I=n.extra;b>>=n.extra,b-=n.extra,n.back+=n.extra}if(n.offset>n.dmax){e.msg="invalid distance too far back",n.mode=30;break}n.mode=25;case 25:if(0===m)break e;if(x=w-m,n.offset>x){if((x=n.offset-x)>n.whave&&n.sane){e.msg="invalid distance too far back",n.mode=30;break}T=x>n.wnext?(x-=n.wnext,n.wsize-x):n.wnext-x,x>n.length&&(x=n.length),A=n.window}else A=f,T=h-n.offset,x=n.length;for(mv?(_=j[R+f[A]],O[I+f[A]]):(_=96,0),h=1<>C)+(p-=h)]=y<<24|_<<16|w|0,0!==p;);for(h=1<>=1;if(0!==h?(L&=h-1,L+=h):L=0,A++,0==--B[T]){if(T===k)break;T=t[n+f[A]]}if(S>>7)]}function E(e,t){e.pending_buf[e.pending++]=255&t,e.pending_buf[e.pending++]=t>>>8&255}function k(e,t,n){e.bi_valid>16-n?(e.bi_buf|=t<>16-e.bi_valid,e.bi_valid+=n-16):(e.bi_buf|=t<>>=1,n<<=1,0<--t;);return n>>>1}function C(e,t,n){var r,i,o=new Array(16),a=0;for(r=1;r<=l;r++)o[r]=a=a+n[r-1]<<1;for(i=0;i<=t;i++){var s=e[2*i+1];0!==s&&(e[2*i]=M(o[s]++,s))}}function N(e){var t;for(t=0;t>1;1<=n;n--)O(e,o,n);for(i=c;n=e.heap[1],e.heap[1]=e.heap[e.heap_len--],O(e,o,1),r=e.heap[1],e.heap[--e.heap_max]=n,e.heap[--e.heap_max]=r,o[2*i]=o[2*n]+o[2*r],e.depth[i]=(e.depth[n]>=e.depth[r]?e.depth[n]:e.depth[r])+1,o[2*n+1]=o[2*r+1]=i,e.heap[1]=i++,O(e,o,1),2<=e.heap_len;);e.heap[--e.heap_max]=e.heap[1],function(e,t){var n,r,i,o,a,s,c=t.dyn_tree,u=t.max_code,f=t.stat_desc.static_tree,d=t.stat_desc.has_stree,h=t.stat_desc.extra_bits,p=t.stat_desc.extra_base,m=t.stat_desc.max_length,g=0;for(o=0;o<=l;o++)e.bl_count[o]=0;for(c[2*e.heap[e.heap_max]+1]=0,n=e.heap_max+1;n<573;n++)m<(o=c[2*c[2*(r=e.heap[n])+1]+1]+1)&&(o=m,g++),c[2*r+1]=o,u>=7;r>>=1)if(1&n&&0!==e.dyn_ltree[2*t])return 0;if(0!==e.dyn_ltree[18]||0!==e.dyn_ltree[20]||0!==e.dyn_ltree[26])return 1;for(t=32;t>>3,(a=e.static_len+3+7>>>3)<=i&&(i=a)):i=a=n+5,n+4<=i&&-1!==t?z(e,t,n,r):4===e.strategy||a===i?(k(e,2+(r?1:0),3),I(e,h,p)):(k(e,4+(r?1:0),3),function(e,t,n,r){var i;for(k(e,t-257,5),k(e,n-1,5),k(e,r-4,4),i=0;i>>8&255,e.pending_buf[e.d_buf+2*e.last_lit+1]=255&t,e.pending_buf[e.l_buf+e.last_lit]=255&n,e.last_lit++,0===t?e.dyn_ltree[2*n]++:(e.matches++,t--,e.dyn_ltree[2*(g[n]+o+1)]++,e.dyn_dtree[2*A(t)]++),e.last_lit===e.lit_bufsize-1},n._tr_align=function(e){k(e,2,3),S(e,256,h),function(e){16===e.bi_valid?(E(e,e.bi_buf),e.bi_buf=0,e.bi_valid=0):8<=e.bi_valid&&(e.pending_buf[e.pending++]=255&e.bi_buf,e.bi_buf>>=8,e.bi_valid-=8)}(e)}},{"../utils/common":41}],53:[function(e,t,n){"use strict";t.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}},{}],54:[function(e,t,n){"use strict";t.exports="function"==typeof setImmediate?setImmediate:function(){var e=[].slice.apply(arguments);e.splice(1,0,0),setTimeout.apply(null,e)}},{}]},{},[10])(10)})),function(e,t){if("object"==typeof module&&module.exports){var n=require("d3");module.exports=t(n)}else if("function"==typeof define&&define.amd){try{n=require("d3")}catch(t){n=e.d3}n.contextMenu=t(n),define([],(function(){return n.contextMenu}))}else e.d3&&(e.d3.contextMenu=t(e.d3))}(this,(function(e){var t={noop:function(){},isFn:function(e){return"function"==typeof e},const:function(e){return function(){return e}},toFactory:function(e,n){return e=void 0===e?n:e,t.isFn(e)?e:t.const(e)}},n=null,r=function(){n&&(e.select(".d3-context-menu").remove(),e.select("body").on("mousedown.d3-context-menu",null),n.boundCloseCallback(),n=null)};return function(i,o){if("close"===i)return r();i=t.toFactory(i);var a=(o=t.isFn(o)?{onOpen:o}:o||{}).onOpen||t.noop,s=o.onClose||t.noop,l=t.toFactory(o.position),c=t.toFactory(o.theme,"d3-context-menu-theme");return function(o,u){var f,d=this;if(void 0===e.event?(f=o,u,void 0):(f=e.event,o,u),r(),n={boundCloseCallback:s.bind(d,o,u)},e.selectAll(".d3-context-menu").data([1]).enter().append("div").attr("class","d3-context-menu "+c.bind(d)(o,u)),e.select("body").on("mousedown.d3-context-menu",r),e.select("body").on("click.d3-context-menu",r),e.selectAll(".d3-context-menu").on("contextmenu",(function(){r(),f.preventDefault(),f.stopPropagation()})).append("ul").call((function n(a,s,l=0){var c=function(e){return t.toFactory(e).call(s,o,u)};a.selectAll("li").data((function(e){var t=0===l?i:e.children;return c(t)})).enter().append("li").each((function(t){var i=!!c(t.divider),a=!!c(t.disabled),f=!!c(t.children),d=!!t.action,h=i?"
":c(t.title),p=e.select(this).classed("is-divider",i).classed("is-disabled",a).classed("is-header",!f&&!d).classed("is-parent",f).html(h).on("click",(function(){!a&&d&&(t.action.call(s,o,u),r())}));if(f){var m=p.append("ul").classed("is-children",!0);n(m,s,++l)}}))}),d),!1!==a.bind(d)(o,u)){var h=l.bind(d)(o,u),p=document.documentElement,m=window.innerWidth||p.clientWidth,g=window.innerHeight||p.clientHeight,b="left",v="right",y=h?h.left:f.pageX-2;f.pageX>m/2&&(b="right",v="left",y=h?m-h.left:m-f.pageX-2);var _="top",w="bottom",x=h?h.top:f.pageY-2;f.pageY>g/2&&(_="bottom",w="top",x=h?g-h.top:g-f.pageY-2),e.select(".d3-context-menu").style(b,y+"px").style(v,null).style(_,x+"px").style(w,null).style("display","block"),f.preventDefault(),f.stopPropagation()}}}})),function(e,t){const n="*",r=Object.defineProperties,i=Object.entries,o=(e,t)=>(n,r)=>(e.has(n)?e.get(n).add(r):e.set(n,(new Set).add(r)),t),a=(e,t)=>(r,i)=>{if(r!==n||i)if(i){const t=e.get(r);t&&(t.delete(i),0===t.size&&e.delete(r))}else e.delete(r);else e.clear();return t},s=(e,t)=>(e,n)=>t.on(e,(function r(...i){t.off(e,r),n.apply(t,i)})),l=(e,t)=>(r,...i)=>{const o=e.get(r);return o&&o.forEach((e=>e.apply(t,i))),e.get(n)&&r!==n&&t.trigger(n,r,...i),t},c=function(e){const t=new Map;return r(e=e||{},i({on:o,off:a,one:s,trigger:l}).reduce(((n,[r,i])=>(n[r]={value:i(t,e),enumerable:!1,writable:!1,configurable:!1},n)),{})),e};"object"==typeof exports?module.exports=c:"function"==typeof r&&r.amd?r((function(){return c})):e.observable=c}("undefined"!=typeof window?window:void 0),t=this,e=function(e){"use strict";function t(e){return e.replace(/-(\w)/g,((e,t)=>t.toUpperCase()))}function n(e,t){e.firstChild&&(t.appendChild(e.firstChild),n(e,t))}function r(e){Array.from(e).forEach(i)}const i=e=>e&&e.parentNode&&e.parentNode.removeChild(e),o=(e,t)=>t&&t.parentNode&&t.parentNode.insertBefore(e,t);var a={EACH:0,IF:1,SIMPLE:2,TAG:3,SLOT:4},s={ATTRIBUTE:0,EVENT:1,TEXT:2,VALUE:3};function l(e,t){return typeof e===t}function c(e){const t=e.ownerSVGElement;return!!t||null===t}function u(e){return!h(e.content)}function f(e){return l(e,"function")}function d(e){return!h(e)&&l(e,"object")}function h(e){return null==e}const p=Symbol("unmount"),m=Object.seal({nodes:[],mount(e,t){return this.update(e,t)},update(e,t){const{placeholder:n,nodes:r,childrenMap:a}=this,s=e===p?null:this.evaluate(e),l=s?Array.from(s):[],{newChildrenMap:c,batches:u,futureNodes:f}=(n.parentNode,function(e,t,n,r){const{condition:i,template:o,childrenMap:a,itemName:s,getKey:l,indexName:c,root:u,isTemplateTag:f}=r,d=new Map,h=[],p=[];return e.forEach(((e,r)=>{const m=function(e,t){let{itemName:n,indexName:r,index:i,item:o}=t;return e[n]=o,r&&(e[r]=i),e}(Object.create(t),{itemName:s,indexName:c,index:r,item:e}),g=l?l(m):r,b=a.get(g);if(function(e,t){return!!e&&!1===Boolean(e(t))}(i,m))return;const v=b?b.template:o.clone(),y=b?v.el:u.cloneNode(),_=!b,w=f&&_?function(e){const t=e.dom.cloneNode(!0);return{avoidDOMInjection:!0,fragment:t,children:Array.from(t.childNodes)}}(v):{};if(_?h.push((()=>v.mount(y,m,n,w))):h.push((()=>v.update(m,n))),f){const e=w.children||v.children;p.push(...e)}else p.push(y);a.delete(g),d.set(g,{template:v,context:m,index:r})})),{newChildrenMap:d,batches:h,futureNodes:p}}(l,e,t,this));return((e,t,n,r,a)=>{const s=n.length;let l=t.length,c=s,u=0,f=0,d=null;for(;ue-f){const i=r(t[u],0);for(;f{if(r<0){const n=e.pop();if(n){const{template:e,context:r}=n;e.unmount(r,t,null)}}return n}}(Array.from(a.values()),t),n),u.forEach((e=>e())),this.childrenMap=c,this.nodes=f,this},unmount(e,t){return this.update(p,t),this}}),g=Object.seal({mount(e,t){return this.update(e,t)},update(e,t){const n=!!this.evaluate(e),r=!this.value&&n,i=this.value&&!n,a=()=>{const n=this.node.cloneNode();o(n,this.placeholder),this.template=this.template.clone(),this.template.mount(n,e,t)};switch(!0){case r:a();break;case i:this.unmount(e);break;default:n&&this.template.update(e,t)}return this.value=n,this},unmount(e,t){return this.template.unmount(e,t,!0),this}});function b(e){throw new Error(e)}function v(e){return e.reduce(((e,n)=>{const{value:r,type:i}=n;switch(!0){case!n.name&&0===i:return Object.assign({},e,r);case 3===i:e.value=n.value;break;default:e[t(n.name)]=n.value}return e}),{})}const y="undefined"==typeof Element?{}:Element.prototype,_=function(e){const t=new Map,n=n=>(t.has(n)||t.set(n,e.call(this,n)))&&t.get(n);return n.cache=t,n}((e=>y.hasOwnProperty(e)));const w=/^on/,x={handleEvent(e){this[e.type](e)}},T=new WeakMap;function A(e){return h(e)?"":e}const E=(e,t)=>{const n=e.childNodes[t];if(n.nodeType===Node.COMMENT_NODE){const t=document.createTextNode("");return e.replaceChild(t,n),t}return n};var k={0:function e(t,n,r,i){let{name:o}=n;if(!o)return i&&function(e,t,n){const r=t?Object.keys(t):[];Object.keys(n).filter((e=>!r.includes(e))).forEach((t=>e.removeAttribute(t)))}(t,r,i),void(r&&function(t,n){Object.entries(n).forEach((n=>{let[r,i]=n;return e(t,{name:r},i)}))}(t,r));!_(o)&&(function(e){return l(e,"boolean")}(r)||d(r)||f(r))&&(t[o]=r),t[function(e){return h(e)||!1===e||""===e||d(e)||f(e)?"removeAttribute":"setAttribute"}(r)](o,function(e,t){return!0===t?e:t}(o,r))},1:function(e,t,n){let{name:r}=t;const i=r.replace(w,""),o=T.get(e)||(e=>{const t=Object.create(x);return T.set(e,t),t})(e),[a,s]=(e=>Array.isArray(e)?e:[e,!1])(n),l=o[i],c=a&&!l;l&&!a&&e.removeEventListener(i,o),c&&e.addEventListener(i,o,s),o[i]=a},2:function(e,t,n){e.data=A(n)},3:function(e,t,n){e.value=A(n)}};const S=Object.seal({mount(e){return this.value=this.evaluate(e),M(this,this.value),this},update(e){const t=this.evaluate(e);return this.value!==t&&(M(this,t),this.value=t),this},unmount(){return 1===this.type&&M(this,null),this}});function M(e,t){return k[e.type](e.node,e,t,e.value)}function C(e,t){return Object.assign({},S,t,{node:2===t.type?E(e,t.childNodeIndex):e})}const N=new Map,D=Symbol("riot-component"),L=new Set,O="is",I="mount",B="update",P="unmount",j="shouldUpdate",R="onBeforeMount",z="onMounted",F="onBeforeUpdate",q="onUpdated",U="onBeforeUnmount",H="onUnmounted",V="props",G="state",W="slots",Y="root",Z=Symbol.for("pure"),K=Symbol("parent"),X=Symbol("attributes"),Q=Symbol("template");var $=Object.freeze({__proto__:null,COMPONENTS_IMPLEMENTATION_MAP:N,DOM_COMPONENT_INSTANCE_PROPERTY:D,PLUGINS_SET:L,IS_DIRECTIVE:O,VALUE_ATTRIBUTE:"value",MOUNT_METHOD_KEY:I,UPDATE_METHOD_KEY:B,UNMOUNT_METHOD_KEY:P,SHOULD_UPDATE_KEY:j,ON_BEFORE_MOUNT_KEY:R,ON_MOUNTED_KEY:z,ON_BEFORE_UPDATE_KEY:F,ON_UPDATED_KEY:q,ON_BEFORE_UNMOUNT_KEY:U,ON_UNMOUNTED_KEY:H,PROPS_KEY:V,STATE_KEY:G,SLOTS_KEY:W,ROOT_KEY:Y,IS_PURE_SYMBOL:Z,PARENT_KEY_SYMBOL:K,ATTRIBUTES_KEY_SYMBOL:X,TEMPLATE_KEY_SYMBOL:Q});const J=(e,t)=>e[K]||t,ee=Object.seal({attributes:[],getTemplateScope(e,t){return function(e,t,n){if(!e||!e.length)return n;const r=e.map((e=>Object.assign({},e,{value:e.evaluate(t)})));return Object.assign(Object.create(n||null),v(r))}(this.attributes,e,t)},mount(e,t){const n=!!e.slots&&e.slots.find((e=>{let{id:t}=e;return t===this.name})),{parentNode:r}=this.node,o=J(e,t);return this.template=n&&ce(n.html,n.bindings).createDOM(r),this.template&&(this.template.mount(this.node,this.getTemplateScope(e,o),o),this.template.children=te(this.node)),i(this.node),this},update(e,t){if(this.template){const n=J(e,t);this.template.update(this.getTemplateScope(e,n),n)}return this},unmount(e,t,n){return this.template&&this.template.unmount(this.getTemplateScope(e,t),null,n),this}});function te(e,t){void 0===t&&(t=[]);const n=e.firstChild;return n?(o(n,e),[n,...te(e)]):t}function ne(e){return e.reduce(((e,t)=>{let{bindings:n}=t;return e.concat(n)}),[])}const re=Object.seal({mount(e){return this.update(e)},update(e,t){const n=this.evaluate(e);return n===this.name?this.tag.update(e):(this.unmount(e,t,!0),this.name=n,this.tag=function(e,t,n){return void 0===t&&(t=[]),void 0===n&&(n=[]),e?e({slots:t,attributes:n}):ce(function(e){return e.reduce(((e,t)=>e+t.html),"")}(t),[...ne(t),{expressions:n.map((e=>Object.assign({type:0},e)))}])}(this.getComponent(n),this.slots,this.attributes),this.tag.mount(this.node,e)),this},unmount(e,t,n){return this.tag&&this.tag.unmount(n),this}});var ie={1:function(e,t){let{evaluate:n,template:r}=t;const a=document.createTextNode("");return o(a,e),i(e),Object.assign({},g,{node:e,evaluate:n,placeholder:a,template:r.createDOM(e)})},2:function(e,t){let{expressions:n}=t;return Object.assign({},(r=n.map((t=>C(e,t))),["mount","update","unmount"].reduce(((e,t)=>Object.assign({},e,{[t]:e=>r.map((n=>n[t](e)))&&undefined})),{})));var r},0:function(e,t){let{evaluate:n,condition:r,itemName:a,indexName:s,getKey:l,template:c}=t;const f=document.createTextNode(""),d=e.cloneNode();return o(f,e),i(e),Object.assign({},m,{childrenMap:new Map,node:e,root:d,condition:r,evaluate:n,isTemplateTag:u(d),template:c.createDOM(e),getKey:l,indexName:s,itemName:a,placeholder:f})},3:function(e,t){let{evaluate:n,getComponent:r,slots:i,attributes:o}=t;return Object.assign({},re,{node:e,evaluate:n,slots:i,attributes:o,getComponent:r})},4:function(e,t){let{name:n,attributes:r}=t;return Object.assign({},ee,{attributes:r,node:e,name:n})}};function oe(e,t){return e.map((e=>2===e.type?Object.assign({},e,{childNodeIndex:e.childNodeIndex+t}):e))}function ae(e,t,n){const{selector:r,type:i,redundantAttribute:o,expressions:a}=t,s=r?e.querySelector(r):e;o&&s.removeAttribute(o);const l=a||[];return(ie[i]||ie[2])(s,Object.assign({},t,{expressions:n&&!r?oe(l,n):l}))}function se(e,t){switch(!0){case c(e):n(t,e);break;case u(e):e.parentNode.replaceChild(t,e);break;default:e.appendChild(t)}}const le=Object.freeze({createDOM(e){return this.dom=this.dom||function(e,t){return t&&("string"==typeof t?function(e,t){return c(e)?function(e,t){return t.ownerDocument.importNode((new window.DOMParser).parseFromString(`${e}`,"application/xml").documentElement,!0)}(t,e):function(e,t){const n=u(t)?t:document.createElement("template");return n.innerHTML=e,n.content}(t,e)}(e,t):t)}(e,this.html),this},mount(e,t,n,r){if(void 0===r&&(r={}),!e)throw new Error("Please provide DOM node to mount properly your template");this.el&&this.unmount(t);const{fragment:i,children:o,avoidDOMInjection:a}=r,{parentNode:s}=o?o[0]:e,l=u(e),c=l?Math.max(Array.from(s.childNodes).indexOf(e),0):null;return this.isTemplateTag=l,this.createDOM(e),this.dom&&(this.fragment=i||this.dom.cloneNode(!0)),this.el=this.isTemplateTag?s:e,this.children=this.isTemplateTag?o||Array.from(this.fragment.childNodes):null,!a&&this.fragment&&se(e,this.fragment),this.bindings=this.bindingsData.map((e=>ae(this.el,e,c))),this.bindings.forEach((e=>e.mount(t,n))),this},update(e,t){return this.bindings.forEach((n=>n.update(e,t))),this},unmount(e,t,n){if(this.el){switch(this.bindings.forEach((r=>r.unmount(e,t,n))),!0){case this.children&&null!==n:r(this.children);break;case!0===n:i(this.el);break;case null!==n:r(this.el.childNodes)}this.el=null}return this},clone(){return Object.assign({},this,{el:null})}});function ce(e,t){return void 0===t&&(t=[]),Object.assign({},le,{html:e,bindingsData:t})}var ue=Object.freeze({__proto__:null,template:ce,createBinding:ae,createExpression:C,bindingTypes:a,expressionTypes:s});function fe(){return this}function de(e){return f(e)?e.prototype&&e.prototype.constructor?new e:e():e}function he(e,t,n,r){return void 0===r&&(r={}),Object.defineProperty(e,t,Object.assign({value:n,enumerable:!1,writable:!1,configurable:!0},r)),e}function pe(e,t,n){return Object.entries(t).forEach((t=>{let[r,i]=t;he(e,r,i,n)})),e}function me(e,t){return Object.entries(t).forEach((t=>{let[n,r]=t;e[n]||(e[n]=r)})),e}function ge(e){return Array.isArray(e)?e:/^\[object (HTMLCollection|NodeList|Object)\]$/.test(Object.prototype.toString.call(e))&&"number"==typeof e.length?Array.from(e):[e]}function be(e,t){return ge("string"==typeof e?(t||document).querySelectorAll(e):e)}const ve=e=>1===e.length?e[0]:e;function ye(e,t,n){const r="object"==typeof t?t:{[t]:n},i=Object.keys(r);return ge(e).forEach((e=>{i.forEach((t=>e.setAttribute(t,r[t])))})),e}const _e=new Map;var we,xe={CSS_BY_NAME:_e,add(e,t){return _e.has(e)||(_e.set(e,t),this.inject()),this},inject(){return(we||(ye(we=be("style[riot]")[0]||document.createElement("style"),"type","text/css"),we.parentNode||document.head.appendChild(we),we)).innerHTML=[..._e.values()].join("\n"),this},remove(e){return _e.has(e)&&(_e.delete(e),this.inject()),this}};function Te(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;rve(r.map((t=>e.getAttribute(t)))))))}(e,t)}(e,O)||e.tagName.toLowerCase()}const Ee=Object.freeze({$(e){return be(e,this.root)[0]},$$(e){return be(e,this.root)}}),ke=Object.freeze({[I]:fe,[B]:fe,[P]:fe}),Se=Object.freeze({[j]:fe,[R]:fe,[z]:fe,[F]:fe,[q]:fe,[U]:fe,[H]:fe}),Me=Object.assign({},ke,{clone:fe,createDOM:fe});function Ce(e,n){return void 0===n&&(n={}),Object.assign({},function(e){return Array.from(e.attributes).reduce(((e,n)=>(e[t(n.name)]=n.value,e)),{})}(e),de(n))}const Ne=(e,t)=>e[D]=t;function De(e){return[I,B,P].reduce(((t,n)=>(t[n]=e(n),t)),{})}function Le(e){let{css:t,template:n,exports:r,name:i}=e;const o=n?function(e,t){return e(ce,s,a,(e=>t[e]||N.get(e)))}(n,r?(void 0===(l=r.components)&&(l={}),Object.entries(de(l)).reduce(((e,t)=>{let[n,r]=t;var i;return e[(i=n,i.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase())]=Le(r),e}),{})):{}):Me;var l;return e=>{let{slots:a,attributes:s,props:l}=e;if(r&&r[Z])return function(e,t){let{slots:n,attributes:r,props:i,css:o,template:a}=t;a&&b("Pure components can not have html"),o&&b("Pure components do not have css");const s=me(e({slots:n,attributes:r,props:i}),ke);return De((e=>function(){for(var t=arguments.length,n=new Array(t),r=0;ru.mount(e,n,t),update:(e,t)=>u.update(t,e),unmount:e=>u.unmount(e)}}}function Oe(e){let{css:t,template:n,componentAPI:r,name:i}=e;return t&&i&&xe.add(i,t),Te(Be)(pe(me(r,Object.assign({},Se,{[G]:{}})),Object.assign({[W]:null,[Y]:null},Ee,{name:i,css:t,template:n})))}function Ie(e,t){return Object.assign({},e,de(t))}function Be(e,t){let{slots:n,attributes:r,props:i}=t;return o=function(e){return[...L].reduce(((e,t)=>t(e)||e),e)}(pe(Object.create(e),{mount(t,o,a){return void 0===o&&(o={}),this[X]=function(e,t){void 0===t&&(t=[]);const n=t.map((t=>C(e,t))),r={};return Object.assign(r,Object.assign({expressions:n},De((e=>t=>(n.forEach((n=>n[e](t))),r)))))}(t,r).mount(a),he(this,V,Object.freeze(Object.assign({},Ce(t,i),v(this[X].expressions)))),this.state=Ie(this.state,o),this[Q]=this.template.createDOM(t).clone(),Ne(t,this),e.name&&function(e,t){Ae(e)!==t&&ye(e,O,t)}(t,e.name),he(this,Y,t),he(this,W,n),this.onBeforeMount(this.props,this.state),this[K]=a,this[Q].mount(t,this,a),this.onMounted(this.props,this.state),this},update(e,t){void 0===e&&(e={}),t&&(this[K]=t,this[X].update(t));const n=v(this[X].expressions);if(!1!==this.shouldUpdate(n,this.props))return he(this,V,Object.freeze(Object.assign({},this.props,n))),this.state=Ie(this.state,e),this.onBeforeUpdate(this.props,this.state),this[Q].update(this,this[K]),this.onUpdated(this.props,this.state),this},unmount(e){return this.onBeforeUnmount(this.props,this.state),this[X].unmount(),this[Q].unmount(this,this[K],null===e?null:!e),this.onUnmounted(this.props,this.state),this}})),Object.keys(e).filter((t=>f(e[t]))).forEach((e=>{o[e]=o[e].bind(o)})),o;var o}const{DOM_COMPONENT_INSTANCE_PROPERTY:Pe,COMPONENTS_IMPLEMENTATION_MAP:je,PLUGINS_SET:Re}=$,ze={cssManager:xe,DOMBindings:ue,createComponent:Le,defineComponent:Oe,globals:$};e.__=ze,e.component=function(e){return function(t,n,r){let{slots:i,attributes:o,parentScope:a}=void 0===r?{}:r;return function(){for(var e=arguments.length,t=new Array(e),n=0;nfunction(){return e(t(...arguments))}))}((e=>e.mount(t,a)),(e=>e({props:n,slots:i,attributes:o})),Le)(e)}},e.install=function(e){return f(e)||b("Plugins must be of type function"),Re.has(e)&&b("This plugin was already installed"),Re.add(e),Re},e.mount=function(e,t,n){return be(e).map((e=>function(e,t,n){const r=n||Ae(e);return N.has(r)||b(`The component named "${r}" was never registered`),N.get(r)({props:t}).mount(e)}(e,t,n)))},e.pure=function(e){return f(e)||b('riot.pure accepts only arguments of type "function"'),e[Z]=!0,e},e.register=function(e,t){let{css:n,template:r,exports:i}=t;return je.has(e)&&b(`The component "${e}" was already registered`),je.set(e,Le({name:e,css:n,template:r,exports:i})),je},e.uninstall=function(e){return Re.has(e)||b("This plugin was never installed"),Re.delete(e),Re},e.unmount=function(e,t){return be(e).map((e=>(e[Pe]&&e[Pe].unmount(t),e)))},e.unregister=function(e){return je.has(e)||b(`The component "${e}" was never registered`),je.delete(e),xe.remove(e),je},e.version="v5.0.0",Object.defineProperty(e,"__esModule",{value:!0})},"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).riot={}),function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("./components/route-hoc.riot"),require("./components/router-hoc.riot")):"function"==typeof define&&define.amd?define(["exports","./components/route-hoc.riot","./components/router-hoc.riot"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).route={},e.routeHoc_riot,e.routerHoc_riot)}(this,(function(e,t,n){"use strict";function r(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var i=r(t),o=r(n);function a(e,t){void 0===t&&(t={});for(var n=function(e){for(var t=[],n=0;n=48&&l<=57||l>=65&&l<=90||l>=97&&l<=122||95===l))break;a+=e[s++]}if(!a)throw new TypeError("Missing parameter name at "+n);t.push({type:"NAME",index:n,value:a}),n=s}else t.push({type:"CLOSE",index:n,value:e[n++]});else t.push({type:"OPEN",index:n,value:e[n++]});else t.push({type:"ESCAPED_CHAR",index:n++,value:e[n++]});else t.push({type:"MODIFIER",index:n,value:e[n++]})}return t.push({type:"END",index:n,value:""}),t}(e),r=t.prefixes,i=void 0===r?"./":r,o="[^"+l(t.delimiter||"/#?")+"]+?",a=[],s=0,c=0,u="",f=function(e){if(c-1:void 0===x;i||(m+="(?:"+p+"(?="+h+"))?"),T||(m+="(?="+p+"|"+h+")")}return new RegExp(m,c(n))}(a(e,n),t,n)}function f(e,t,n){return e instanceof RegExp?function(e,t){if(!t)return e;var n=e.source.match(/\((?!\?)/g);if(n)for(var r=0;rfunction t(r,i){if(!r.length)return e(i);const[o,...a]=r,s="function"==typeof o?o(i):o,l=e=>t(a,e);if(null!=s){if(s===d)return;if(s.then)return s.then(l,n)}return Promise.resolve(l(s))}(t)))}h.cancel=()=>d,h.compose=function(){for(var e=arguments.length,t=new Array(e),n=0;n{n(t)===m&&e.delete(n)})),e}function v(e){throw new Error(e)}function y(){for(var e=arguments.length,t=new Array(e),n=0;nt=>e.add(t)&&l,u=e=>t=>e.delete(t)?l:v("Couldn't remove handler passed by reference");return Object.assign(l,{on:Object.freeze({value:c(r),error:c(i),end:c(o)}),off:Object.freeze({value:u(r),error:u(i),end:u(o)}),connect:c(a),push(e){const{value:t,done:n}=l.next(e);return n||t.then((e=>b(r,e)),(e=>b(i,e))),l},end:()=>(s.return(),b(o),[r,i,o,a].forEach((e=>e.clear())),l),fork:()=>y(...a),next(e){const t=s.next(e);return s.next(),t}})}y.install=function(e,t){return e&&"string"==typeof e||v("Please provide a name (as string) for your erre plugin"),t&&"function"==typeof t||v("Please provide a function for your erre plugin"),p.has(e)?v(`The ${e} is already part of the erre API, please provide a different name`):(y[e]=t,p.add(e)),y},y.install("cancel",h.cancel),y.install("off",(()=>m));const _="undefined"!=typeof process,w=e=>e.replace(k.base,""),x=e=>t=>C(t,e)?t:y.cancel(),T=e=>{if(!k.silentErrors)throw new Error(e)},A=e=>(e=>"string"==typeof e)(e)?e:y.cancel(),E=y(A).on.error(T),k={base:"",silentErrors:!1,sensitive:!1,strict:!1,end:!0,start:!0,delimiter:"/#?",encode:void 0,endsWith:void 0,prefixes:"./"},S=e=>Object.assign({},k,e),M=function(e,t,n){void 0===n&&(n={});const{base:r}=S(n),[,...i]=t.exec(e),o=function(){for(var e=arguments.length,t=new Array(e),n=0;n{const i=n.keys&&n.keys[r];return i&&(e[i.name]=t),e}),{}),o},C=(e,t)=>t.test(e),N=(e,t)=>[w,x(e),n=>M(n,e,t)];const D=(L=null,E.on.value((e=>L=e)),()=>L);var L;const O="popstate",I="click",B="/",P=/^.+?\/\/+[^/]+/;function j(e){return Array.isArray(e)?e:/^\[object (HTMLCollection|NodeList|Object)\]$/.test(Object.prototype.toString.call(e))&&"number"==typeof e.length?Array.from(e):[e]}function R(e,t,n,r,i){var o;e=j(e),(o=t,o.split(/\s/)).forEach((t=>{e.forEach((e=>e[r](t,n,i||!1)))}))}function z(e,t,n,r){return R(e,t,n,"addEventListener",r),e}function F(e,t,n,r){return R(e,t,n,"removeEventListener",r),e}const q=()=>"undefined"==typeof window?null:window,U=()=>"undefined"==typeof document?null:document,H=()=>{const e=q();return e?e.location:{}},V=e=>1===e.length?e[0]:e;function G(e,t){return function(e,t,n){const r="string"==typeof t?[t]:t;return V(j(e).map((e=>V(r.map((t=>e[n](t)))))))}(e,t,"hasAttribute")}const W=()=>E.push(Q(String(H().href))),Y=e=>{const t=e.includes(k.base)?e:k.base+e,n=H(),r="undefined"==typeof history?null:history,i=U();r&&t!==n.href&&r.pushState(null,i.title,t)},Z=e=>e&&!K(e)?Z(e.parentNode):e,K=e=>"A"===e.nodeName,X=e=>!e||!K(e)||G(e,"download")||!G(e,"href")||(e=>e.target&&"_self"!==e.target)(e)||-1===e.href.indexOf(H().href.match(P)[0]),Q=e=>e.replace(k.base,""),$=e=>{if((e=>e.which&&1!==e.which||e.metaKey||e.ctrlKey||e.shiftKey||e.defaultPrevented)(e))return;const t=Z(e.target);if(X(t)||(e=>e.split("#").length>1)(t.href)||!(e=>!k.base||e.includes(k.base))(t.href))return;const n=Q(t.href);E.push(n),e.preventDefault()};const J=e=>e[e.length-1]===B?e.substr(0,e.length-1):e,ee=e=>{const t=q().location,n=t?`${t.protocol}//${t.host}`:"",{pathname:r}=t||{};switch(!0){case!1===Boolean(e):return J(`${n}${r||""}`);case/(www|http(s)?:)/.test(e):return e;case"#"===e[0]:return`${n}${r&&r!==B?r:""}${e}`;case e===B:return J(n);default:return J(`${n}${i=e,i[0]===B?i:"/"+i}`)}var i};Object.defineProperty(e,"Route",{enumerable:!0,get:function(){return i.default}}),Object.defineProperty(e,"Router",{enumerable:!0,get:function(){return o.default}}),e.createURLStreamPipe=N,e.filterStrings=A,e.getCurrentRoute=D,e.initDomListeners=function(e){const t=q(),n=e||U();return t&&(z(t,O,W),z(n,I,$)),E.on.value(Y),()=>{t&&(F(t,O,W),F(n,I,$)),E.off.value(Y)}},e.match=C,e.route=function(e,t){const n=[],r=f(e,n,t),i=y(...N(r,Object.assign({},t,{keys:n})));return(o=E,a=i,o.on.value(a.push),a.on.end((()=>{o.off.value(a.push)})),a).on.error(T);var o,a},e.router=E,e.setBase=function(e){k.base=ee(e)},e.toPath=(e,t,n)=>s(e,S(n))(t),e.toRegexp=(e,t,n)=>f(e,t,S(n)),e.toURL=M,Object.defineProperty(e,"__esModule",{value:!0})})),function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e=e||self).cimDiagram=t()}(this,(function(){"use strict";const e=14,t=d3.scaleSequential([0,500],d3.interpolateTurbo);let n=null,r="ConnectivityNode",i="ConnectivityNode.Terminals",o="Terminal.ConnectivityNode";return{css:'cimdiagram .app-diagram,[is="cimdiagram"] .app-diagram{ max-height: 800px; } cimdiagram path.domain,[is="cimdiagram"] path.domain{ fill: none; stroke: black; } cimdiagram g.tick > line,[is="cimdiagram"] g.tick > line{ stroke: black; stroke-dasharray: 1 5; } cimdiagram svg,[is="cimdiagram"] svg{ width: 1200px; height: 800px; } cimdiagram line.highlight-x,[is="cimdiagram"] line.highlight-x,cimdiagram line.highlight-y,[is="cimdiagram"] line.highlight-y{ stroke: red; stroke-width: 1; } cimdiagram g.resize > rect,[is="cimdiagram"] g.resize > rect{ stroke: black; stroke-width: 2; }',exports:{onBeforeMount(e,t){n=this,n.props.dispatcher.on("showDiagram",(function(e,t,a){if(decodeURI(t)!==n.diagramName){"BUS_BRANCH"===n.props.model.getMode()&&(r="TopologicalNode",i="TopologicalNode.Terminal",o="Terminal.TopologicalNode"),n.render(t)}void 0!==a?(n.moveTo(a),n.props.dispatcher.trigger("moveTo",a)):n.props.dispatcher.trigger("deselect")})),n.props.dispatcher.on("transform",(function(){let e=d3.zoomTransform(d3.select("svg").node()),t=e.x,n=e.y,r=e.k,i=parseInt(d3.select("svg").style("width")),o=parseInt(d3.select("svg").style("height")),a=d3.scaleLinear().domain([-t/r,(i-t)/r]).range([0,i]),s=d3.scaleLinear().domain([-n/r,(o-n)/r]).range([0,o]),l=d3.axisRight(s),c=d3.axisBottom(a);d3.select("svg").select("#diagram-yAxis").call(l),d3.select("svg").select("#diagram-xAxis").call(c)})),n.props.model.on("setAttribute",(function(e,t,r){switch(t){case"cim:IdentifiedObject.name":{let t=e.localName,i=n.props.model.ID(e);if("cim:BusbarSection"===e.nodeName){let r=n.props.model.getNode(e);if(null===r)return;t=r.localName,i=n.props.model.ID(r)}d3.select("svg").selectAll("svg > g#diagram-main > g."+t+"s").select("#cimdiagram-"+i).select("text").html(r);break}case"cim:AnalogValue.value":{let t=n.props.model.getTargets([e],"AnalogValue.Analog"),r=n.props.model.getTargets(t,"Measurement.PowerSystemResource")[0];"cim:BusbarSection"===r.nodeName&&(r=n.props.model.getNode(r));let i=n.props.model.ID(r),o=d3.select("g#cimdiagram-"+i);n.createStatusInfo(o);break}case"cim:SvPowerFlow.p":case"cim:SvPowerFlow.q":{let t=n.props.model.getTargets([e],"SvPowerFlow.Terminal")[0];if(void 0!==t){let e=n.props.model.getTargets([t],"Terminal.ConductingEquipment")[0],r=n.props.model.ID(e),i=d3.select("g#cimdiagram-"+r);n.createStatusInfo(i)}break}case"cim:BaseVoltage.nominalVoltage":{n.drawLegend();const t=n.props.model.getTargets([e],"BaseVoltage.ConductingEquipment"),r=t.filter((function(e){return!0===n.props.model.schema.isA("ACLineSegment",e)}));n.drawACLines(r);let i=t.filter((function(e){return!0===n.props.model.schema.isA("BusbarSection",e)})).map((e=>n.props.model.getNode(e)));n.drawNodes(i);const o=n.props.model.getTargets([e],"BaseVoltage.TransformerEnds");for(const e of o){const t=n.getTermNode(e);null!==t&&n.handlePowerTransformerEnds(t)}break}}if("cim:Analog"===e.nodeName||"cim:Discrete"===e.nodeName){let t=n.props.model.getTargets([e],"Measurement.PowerSystemResource")[0];if(void 0!==t){"cim:BusbarSection"===t.nodeName&&(t=n.props.model.getNode(t));let e=n.props.model.ID(t),r=d3.select("g#cimdiagram-"+e);n.createStatusInfo(r)}}if("cim:OperationalLimitSet"===e.nodeName){let t=n.props.model.getTargets([e],"OperationalLimitSet.Equipment"),r=n.props.model.getTargets([e],"OperationalLimitSet.Terminal");if(t=t.concat(n.props.model.getTargets(r,"Terminal.ConductingEquipment"))[0],void 0!==t){"cim:BusbarSection"===t.nodeName&&(t=n.props.model.getNode(t));let e=n.props.model.ID(t),r=d3.select("g#cimdiagram-"+e);n.createStatusInfo(r)}}})),n.props.model.on("setEnum",(function(e,t,r){if("cim:Analog"===e.nodeName||"cim:Discrete"===e.nodeName){let t=n.props.model.getTargets([e],"Measurement.PowerSystemResource")[0];if(void 0!==t){"cim:BusbarSection"===t.nodeName&&(t=n.props.model.getNode(t));let e=n.props.model.ID(t),r=d3.select("g#cimdiagram-"+e);n.createStatusInfo(r)}}switch(t){case"cim:PowerTransformerEnd.connectionKind":{const t=n.getTermNode(e);null!==t&&n.handlePowerTransformerEnds(t);break}}})),n.props.model.on("updateActiveDiagram",(function(e){let t=null;switch(e.nodeName){case"cim:ACLineSegment":t=n.drawACLines([e])[0],n.createTerminals(t);break;case"cim:"+r:n.drawNodes([e])}let i=e.localName,o=n.props.model.ID(e),a=d3.select("svg").selectAll("svg > g#diagram-main > g."+i+"s").select("#cimdiagram-"+o);n.forceTick(a)})),n.props.model.on("addToActiveDiagram",(function(e){let t=null;switch(e.nodeName){case"cim:ACLineSegment":t=n.drawACLines([e])[1];break;case"cim:Breaker":t=n.drawBreakers([e]);break;case"cim:Disconnector":t=n.drawDisconnectors([e]);break;case"cim:LoadBreakSwitch":t=n.drawLoadBreakSwitches([e]);break;case"cim:Junction":t=n.drawJunctions([e]);break;case"cim:EnergySource":t=n.drawEnergySources([e]);break;case"cim:SynchronousMachine":t=n.drawSynchronousMachines([e]);break;case"cim:AsynchronousMachine":t=n.drawAsynchronousMachines([e]);break;case"cim:EnergyConsumer":t=n.drawEnergyConsumers([e]);break;case"cim:ConformLoad":t=n.drawConformLoads([e]);break;case"cim:NonConformLoad":t=n.drawNonConformLoads([e]);break;case"cim:EquivalentInjection":t=n.drawEquivalentInjections([e]);break;case"cim:LinearShuntCompensator":t=n.drawLinearCompensators([e]);break;case"cim:NonlinearShuntCompensator":t=n.drawNonlinearCompensators([e]);break;case"cim:PowerTransformer":t=n.drawPowerTransformers([e]);break;case"cim:"+r:t=n.drawNodes([e]),i(e,null)}if(null!==t&&function(t){let r=n.props.model.getTerminals([e]);for(let e of r){let t=n.props.model.getTargets([e],o)[0];if(void 0!==t){let e=n.props.model.getEquipments(t),r=e.filter((e=>"BusbarSection"===e.localName))[0];if(e=e.filter((e=>e!==r)),e.length>1){n.drawNodes([t]);let r=n.props.model.getTerminals(e);for(let e of r){if(n.props.model.getTargets([e],o)[0]===t){let r={source:t,target:e};n.createEdges([r])}}}}}n.createTerminals(t)}(t),"cim:BusbarSection"===e.nodeName){let r=n.props.model.getTargets([e],"ConductingEquipment.Terminals"),a=n.props.model.getTargets(r,o)[0];t=n.drawNodes([a]),i(a,e)}function i(e,t){let r=n.props.model.getEquipments(e).filter((e=>e!==t)),i=n.props.model.getTerminals(r);for(let t of i){if(void 0===t.x)continue;if(n.props.model.getTargets([t],o)[0]===e){let r={source:e,target:t};n.createEdges([r])}}}null!==t&&(n.forceTick(t),n.props.dispatcher.trigger("addToDiagram",t))})),n.props.model.on("addLink",(function(e,t,a){switch(t){case"cim:"+o:case"cim:"+i:{let t=void 0,i=void 0;if("cim:Terminal"===a.nodeName&&e.nodeName==="cim:"+r)t=e,i=a;else{if("cim:Terminal"!==e.nodeName||a.nodeName!=="cim:"+r)return;i=e,t=a}let o=d3.select("svg").selectAll("svg > g#diagram-main > g.edges > g").data().filter((e=>e.target===i))[0];if(void 0===o){let e=n.props.model.getTargets([i],"Terminal.ConductingEquipment");n.props.model.getDiagramObjects(e).length>0&&(o={source:t,target:i},n.createEdges([o]))}else o.source=t;let s=n.props.model.ID(t),l=d3.select("svg > g#diagram-main > g."+r+"s > g#cimdiagram-"+s);n.forceTick(l);break}case"cim:Terminal.SvPowerFlow":case"cim:SvPowerFlow.Terminal":{let t=a;if("cim:Terminal"===e.nodeName&&(t=e),void 0!==t){let e=n.props.model.getTargets([t],"Terminal.ConductingEquipment")[0],r=n.props.model.ID(e),i=d3.select("g#cimdiagram-"+r);n.createStatusInfo(i)}break}case"cim:Measurement.Terminal":case"cim:ACDCTerminal.Measurements":{let t=a;"cim:Terminal"===e.nodeName&&(t=e);let r=n.props.model.getTargets([t],"Terminal.ConductingEquipment")[0],i=n.props.model.ID(r),o=d3.select("g#cimdiagram-"+i);n.createStatusInfo(o);break}case"cim:Measurement.PowerSystemResource":case"cim:PowerSystemResource.Measurements":{let r=a;if("cim:PowerSystemResource.Measurements"===t&&(r=e),void 0!==r){"cim:BusbarSection"===r.nodeName&&(r=n.props.model.getNode(r));let e=n.props.model.ID(r),t=d3.select("g#cimdiagram-"+e);n.createStatusInfo(t)}break}case"cim:OperationalLimitSet.Terminal":case"cim:ACDCTerminal.OperationalLimitSet":{let t=a;"cim:Terminal"===e.nodeName&&(t=e);let r=n.props.model.getTargets([t],"Terminal.ConductingEquipment")[0],i=n.props.model.ID(r),o=d3.select("g#cimdiagram-"+i);n.createStatusInfo(o);break}case"cim:OperationalLimitSet.Equipment":case"cim:Equipment.OperationalLimitSet":{let r=a;if("cim:Equipment.OperationalLimitSet"===t&&(r=e),void 0!==r){"cim:BusbarSection"===r.nodeName&&(r=n.props.model.getNode(r));let e=n.props.model.ID(r),t=d3.select("g#cimdiagram-"+e);n.createStatusInfo(t)}break}case"cim:ConductingEquipment.BaseVoltage":case"cim:BaseVoltage.ConductingEquipment":case"cim:BaseVoltage.TransformerEnds":case"cim:TransformerEnd.BaseVoltage":n.updateColoring(e,t,a)}})),n.props.model.on("removeLink",(function(e,t,a){switch(t){case"cim:Measurement.PowerSystemResource":case"cim:PowerSystemResource.Measurements":{let r=a;if("cim:PowerSystemResource.Measurements"===t&&(r=e),void 0!==r){"cim:BusbarSection"===r.nodeName&&(r=n.props.model.getNode(r));let e=n.props.model.ID(r),t=d3.select("g#"+e);n.createStatusInfo(t)}break}case"cim:"+o:case"cim:"+i:{let t=void 0;if("cim:Terminal"===a.nodeName&&e.nodeName==="cim:"+r)t=a;else{if("cim:Terminal"!==e.nodeName||a.nodeName!=="cim:"+r)return;t=e}d3.select("svg").selectAll("svg > g#diagram-main > g.edges > g").filter((function(e){return e.target===t})).remove();break}case"cim:OperationalLimitSet.Terminal":case"cim:ACDCTerminal.OperationalLimitSet":{let t=a;"cim:Terminal"===e.nodeName&&(t=e);let r=n.props.model.getTargets([t],"Terminal.ConductingEquipment")[0];if(void 0!==r){let e=n.props.model.ID(r),t=d3.select("g#"+e);n.createStatusInfo(t)}break}case"cim:OperationalLimitSet.Equipment":case"cim:Equipment.OperationalLimitSet":{let r=a;if("cim:Equipment.OperationalLimitSet"===t&&(r=e),void 0!==r&&("cim:BusbarSection"===r.nodeName&&(r=n.props.model.getNode(r)),null!==r)){let e=n.props.model.ID(r),t=d3.select("g#"+e);n.createStatusInfo(t)}break}case"cim:ConductingEquipment.BaseVoltage":case"cim:BaseVoltage.ConductingEquipment":case"cim:BaseVoltage.TransformerEnds":case"cim:TransformerEnd.BaseVoltage":n.updateColoring(e,t,a)}})),n.props.model.on("deleteObject",(function(e,t){"BaseVoltage"===t&&n.drawLegend()}))},onMounted(){let e=d3.scaleLinear().domain([0,1200]).range([0,1200]),t=d3.scaleLinear().domain([0,800]).range([0,800]),r=d3.axisRight(t),i=d3.axisBottom(e);d3.select("svg").append("g").attr("id","diagram-yAxis").call(r),d3.select("svg").append("g").attr("id","diagram-xAxis").call(i),n.drawGrid(1)},render(e){let t=function*(e){d3.select("svg").select("g#diagram-main").selectAll("g:not(.edges)").remove(),n.props.model.selectDiagram(decodeURI(e)),n.diagramName=decodeURI(e);const t=n.props.model.getNodes();yield"DIAGRAM: extracted nodes";const r=n.props.model.getGraphicObjects(["cim:ACLineSegment","cim:Breaker","cim:Disconnector","cim:LoadBreakSwitch","cim:Junction","cim:EnergySource","cim:SynchronousMachine","cim:AsynchronousMachine","cim:EnergyConsumer","cim:ConformLoad","cim:NonConformLoad","cim:EquivalentInjection","cim:PowerTransformer","cim:BusbarSection","cim:LinearShuntCompensator","cim:NonlinearShuntCompensator"]),i=r["cim:ACLineSegment"],o=r["cim:Breaker"],a=r["cim:Disconnector"],s=r["cim:LoadBreakSwitch"],l=r["cim:Junction"],c=r["cim:EnergySource"],u=r["cim:SynchronousMachine"],f=r["cim:AsynchronousMachine"],d=r["cim:EnergyConsumer"],h=r["cim:ConformLoad"],p=r["cim:NonConformLoad"],m=r["cim:EquivalentInjection"],g=r["cim:PowerTransformer"],b=(r["cim:BusbarSection"],r["cim:LinearShuntCompensator"]),v=r["cim:NonlinearShuntCompensator"];yield"DIAGRAM: extracted equipments";const y=n.drawACLines(i)[1];yield"DIAGRAM: drawn acLines";const _=n.drawBreakers(o);yield"DIAGRAM: drawn breakers";const w=n.drawDisconnectors(a);yield"DIAGRAM: drawn disconnectors";const x=n.drawLoadBreakSwitches(s);yield"DIAGRAM: drawn load break switches";const T=n.drawJunctions(l);yield"DIAGRAM: drawn junctions";const A=n.drawEnergySources(c);yield"DIAGRAM: drawn energy sources";const E=n.drawSynchronousMachines(u);yield"DIAGRAM: drawn synchronous machines";const k=n.drawAsynchronousMachines(f);yield"DIAGRAM: drawn asynchronous machines";const S=n.drawEnergyConsumers(d);yield"DIAGRAM: drawn energy consumers";const M=n.drawConformLoads(h);yield"DIAGRAM: drawn conform loads";const C=n.drawNonConformLoads(p);yield"DIAGRAM: drawn non conform loads";const N=n.drawEquivalentInjections(m);yield"DIAGRAM: drawn equivalent injections";const D=n.drawPowerTransformers(g);yield"DIAGRAM: drawn power transformers";const L=n.drawLinearCompensators(b);yield"DIAGRAM: drawn linear shunt compensators";const O=n.drawNonlinearCompensators(v);yield"DIAGRAM: drawn nonlinear shunt compensators";const I=n.drawNodes(t);n.createStatusInfo(I),yield"DIAGRAM: drawn connectivity nodes",n.createTerminals(y),n.createStatusInfo(y),yield"DIAGRAM: drawn acline terminals",n.createTerminals(_),n.createStatusInfo(_),yield"DIAGRAM: drawn breaker terminals",n.createTerminals(w),n.createStatusInfo(w),yield"DIAGRAM: drawn disconnector terminals",n.createTerminals(x),n.createStatusInfo(x),yield"DIAGRAM: drawn load break switch terminals",n.createTerminals(T),n.createStatusInfo(T),yield"DIAGRAM: drawn junction terminals",n.createTerminals(A),n.createStatusInfo(A),yield"DIAGRAM: drawn energy source terminals",n.createTerminals(E),n.createStatusInfo(E),yield"DIAGRAM: drawn synchronous machine terminals",n.createTerminals(k),n.createStatusInfo(k),yield"DIAGRAM: drawn asynchronous machine terminals",n.createTerminals(S),n.createStatusInfo(S),yield"DIAGRAM: drawn energy consumer terminals",n.createTerminals(M),n.createStatusInfo(M),yield"DIAGRAM: drawn conform load terminals",n.createTerminals(C),n.createStatusInfo(C),yield"DIAGRAM: drawn non conform load terminals",n.createTerminals(N),n.createStatusInfo(N),yield"DIAGRAM: drawn equivalent injection terminals",n.createTerminals(D),n.createStatusInfo(D),yield"DIAGRAM: drawn power transformer terminals",n.createTerminals(L),n.createStatusInfo(L),yield"DIAGRAM: drawn linear shunt compensator terminals",n.createTerminals(O),n.createStatusInfo(O),yield"DIAGRAM: drawn nonlinear shunt compensator terminals",n.drawLegend(),d3.select("svg").on("dragover",(function(e){e.preventDefault()})).on("drop",(function(e){e.preventDefault();const t=e.dataTransfer.getData("text/plain");if(void 0===t)return;const r=n.props.model.getObject(t);if(void 0===r)return;n.props.model.getDiagramObjects([r]).length>0?n.moveTo(t):addToDiagram(n.props.model,e,r)})),n.forceTick(),n.props.dispatcher.trigger("render")}(e);!function e(){let r=t.next().value;void 0!==r?(document.getElementById("loadingDiagramMsg").innerHTML="
"+r,setTimeout(e,1)):n.props.dispatcher.trigger("loaded")}()},createEdges(e){let t=d3.select("svg").select("g > g.edges").selectAll("g.edge").data(e,(function(e){return e.source.attributes[0].value+e.target.attributes[0].value})).enter().append("g").attr("class","edge").attr("id",(function(e){return e.source.attributes[0].value+e.target.attributes[0].value})).append("path").attr("fill","none").attr("stroke","black").attr("stroke-width",1);n.props.dispatcher.trigger("createEdges",t)},createStatusInfo(e){e.attr("data-bs-toggle","popover"),e.filter((function(e){return n.props.model.schema.isA("Switch",e)})).selectAll("path").attr("fill",(function(e){let t=n.props.model.getTargets([e],"PowerSystemResource.Measurements")[0];return"0"===n.getDiscreteValue(t)?"white":"black"})),e.each((function(e){let t=[],i=[],o=[],a=n.props.model.getTargets([e],"TopologicalNode.SvVoltage"),s=n.props.model.getTerminals([e]);if(e.nodeName==="cim:"+r){let r=n.props.model.getBusbar(e);if(null===r)return;s=n.props.model.getTerminals([r]),t=n.props.model.getTargets([r],"PowerSystemResource.Measurements"),o=n.props.model.getTargets([r],"Equipment.OperationalLimitSet")}else t=n.props.model.getTargets([e],"PowerSystemResource.Measurements"),o=n.props.model.getTargets([e],"Equipment.OperationalLimitSet");o=o.concat(n.props.model.getTargets(s,"ACDCTerminal.OperationalLimitSet"));for(let e of s){let t=n.props.model.getTargets([e],"Terminal.SvPowerFlow");i=i.concat(t)}if(t.length>0||i.length>0||a.length>0||o.length>0){let e=n.createTooltip(t,i,a,o);disposePopovers([this]),new bootstrap.Popover(this,{title:"Element Status Info",content:e,container:"body",html:!0,trigger:"manual",delay:{show:200,hide:0},placement:"auto"})}else disposePopovers([this])}))},getDiscreteValue(e){let t="0";if(void 0!==e){let r=n.props.model.getTargets([e],"Discrete.DiscreteValues")[0];if(void 0!==r){let e=n.props.model.getAttribute(r,"cim:DiscreteValue.value");void 0!==e&&(t=e.textContent)}}return t},createTooltip(e,t,r,i){let o="";if(e.length>0){o+="Measurements

";let t=[];for(let r of e){let e="unnamed",i="ABC",o="",a="no unit",s=n.props.model.getAttribute(r,"cim:IdentifiedObject.name"),l=n.props.model.getEnum(r,"cim:Measurement.phases"),c=n.props.model.getEnum(r,"cim:Measurement.unitMultiplier"),u=n.props.model.getEnum(r,"cim:Measurement.unitSymbol");void 0!==s&&(e=s.textContent),void 0!==l&&(i=l),void 0!==c&&(o=c,"none"===o&&(o="")),void 0!==u&&(a=u);let f=n.props.model.getTargets([r],"Analog.AnalogValues")[0],d="",h="n.a.";void 0!==f?void 0!==n.props.model.getAttribute(f,"cim:AnalogValue.value")&&(h=n.props.model.getAttribute(f,"cim:AnalogValue.value").textContent,h=parseFloat(h).toFixed(2)):(h=n.getDiscreteValue(r),h=parseInt(h));let p=n.props.model.ID(r),m=window.location.hash.split("/");d=d+""+e+"",d=d+" (phase: "+i+")",d+=": ",d+=h,d=d+" ["+o+a+"]",d+="
",t.push(d)}t.sort();for(let e in t)o+=t[e]}if(t.length>0){""!==o&&(o+="
"),o+="Power flow results (Power)

";for(let e of t){let t=0,r=0;void 0!==n.props.model.getAttribute(e,"cim:SvPowerFlow.p")&&(t=n.props.model.getAttribute(e,"cim:SvPowerFlow.p").textContent),void 0!==n.props.model.getAttribute(e,"cim:SvPowerFlow.q")&&(r=n.props.model.getAttribute(e,"cim:SvPowerFlow.q").textContent);let i="Active Power: "+parseFloat(t).toFixed(2)+" [MW]";i+="
",i=i+"Reactive power: "+parseFloat(r).toFixed(2)+" [MVAr]",i+="
",o+=i}}if(r.length>0){""!==o&&(o+="
"),o+="Power flow results (Voltage)

";for(let e of r){let t=0,r=0;void 0!==n.props.model.getAttribute(e,"cim:SvVoltage.v")&&(t=n.props.model.getAttribute(e,"cim:SvVoltage.v").textContent),void 0!==n.props.model.getAttribute(e,"cim:SvVoltage.angle")&&(r=n.props.model.getAttribute(e,"cim:SvVoltage.angle").textContent);let i="Voltage magnitude: "+parseFloat(t).toFixed(2)+" [kV]";i+="
",i=i+"Voltage angle: "+parseFloat(r).toFixed(2)+" [deg]",i+="
",o+=i}}if(i.length>0){""!==o&&(o+="
"),o+="Operational limit sets

";for(let e of i){let t="unnamed",r=n.props.model.getAttribute(e,"cim:IdentifiedObject.name");void 0!==r&&(t=r.textContent);let i=n.props.model.ID(e),a=window.location.hash.split("/");o+=""+t+"
"}}return o},createSelection(e,t){let r=e+"s";d3.select("svg").select("g."+r).empty()&&d3.select("svg").select("g#diagram-main").append("g").attr("class",r);for(let e of t)calcLineData(n.props.model,e);let i=d3.select("svg").select("g."+r).selectAll("g."+e).data(t,(function(e){return n.props.model.ID(e)})),o=i.enter().append("g").attr("class",e).attr("id",(function(e){return"cimdiagram-"+n.props.model.ID(e)}));return[i,o]},drawACLines(e){const t=d3.line().x((function(e){return e.x})).y((function(e){return e.y})),r=n.createSelection("ACLineSegment",e),i=r[0],o=r[1];function a(e){e.attr("x",(function(e){let t=d3.select(this.parentNode).select("path").node();return t.getPointAtLength(t.getTotalLength()/2).x+2})).attr("y",(function(e){let t=d3.select(this.parentNode).select("path").node();return t.getPointAtLength(t.getTotalLength()/2).y-2})).text((function(e){let t=n.props.model.getAttribute(e,"cim:IdentifiedObject.name");return void 0!==t?t.innerHTML:""}))}return o.append("path").attr("d",(function(e){return 1===e.lineData.length&&e.lineData.push({x:150,y:0,seq:2}),t(e.lineData)})).attr("fill","none").attr("stroke",(function(e){return n.voltageColor(e,"darkred")})).attr("stroke-width",2),o.append("text").attr("class","cim-object-text").attr("font-size",3),a(i.select("text")),a(o.select("text")),i.select("path").attr("d",(function(e){return 1===e.lineData.length&&e.lineData.push({x:150,y:0,seq:2}),t(e.lineData)})).attr("fill","none").attr("stroke",(function(e){return n.voltageColor(e,"darkred")})).attr("stroke-width",2),[i,o]},drawBreakers:e=>n.drawSwitches(e,"Breaker","green"),drawDisconnectors:e=>n.drawSwitches(e,"Disconnector","blue"),drawLoadBreakSwitches:e=>n.drawSwitches(e,"LoadBreakSwitch","black"),drawJunctions:e=>n.drawSwitches(e,"Junction","red"),drawSwitches(e,t,r){let i=d3.line().x((function(e){return e.x})).y((function(e){return e.y})).curve(d3.curveLinearClosed),o=n.createSelection(t,e)[1];return o.append("path").attr("d",(function(e){return i([{x:-5,y:-5,seq:1},{x:5,y:-5,seq:2},{x:5,y:5,seq:3},{x:-5,y:5,seq:4}])})).attr("fill",(function(e){let t=n.props.model.getTargets([e],"PowerSystemResource.Measurements")[0];return"0"===n.getDiscreteValue(t)?"white":"black"})).attr("stroke",r).attr("stroke-width",1),o.append("text").attr("class","cim-object-text").style("text-anchor","end").attr("font-size",3).attr("x",-10).attr("y",0).text((function(e){let t=n.props.model.getAttribute(e,"cim:IdentifiedObject.name");return void 0!==t?t.innerHTML:""})),o},drawEnergySources:e=>n.drawGenerators(e,"EnergySource"),drawSynchronousMachines:e=>n.drawGenerators(e,"SynchronousMachine"),drawAsynchronousMachines:e=>n.drawGenerators(e,"AsynchronousMachine"),drawEnergyConsumers:e=>n.drawLoads(e,"EnergyConsumer"),drawConformLoads:e=>n.drawLoads(e,"ConformLoad"),drawNonConformLoads:e=>n.drawLoads(e,"NonConformLoad"),drawEquivalentInjections:e=>n.drawLoads(e,"EquivalentInjection"),drawLinearCompensators:e=>n.drawCompensators(e,"LinearShuntCompensator"),drawNonlinearCompensators:e=>n.drawCompensators(e,"NonlinearShuntCompensator"),drawGenerators(e,t){let r=n.createSelection(t,e)[1],i="G";const o=Math.round(15);return"AsynchronousMachine"===t&&(i="M"),r.append("circle").attr("r",12.5).attr("cx",0).attr("cy",0).attr("fill","white").attr("stroke","black").attr("stroke-width",1),r.append("text").attr("class","cim-object-text").style("text-anchor","middle").attr("font-size",3).attr("x",17.5).attr("y",0).text((function(e){let t=n.props.model.getAttribute(e,"cim:IdentifiedObject.name");return void 0!==t?t.innerHTML:""})),r.append("text").style("text-anchor","middle").attr("font-size",o).attr("x",0).attr("y",6.25).text(i),r},drawLoads(e,t){let r=d3.line().x((function(e){return e.x})).y((function(e){return e.y})).curve(d3.curveLinearClosed),i=n.createSelection(t,e)[1];return i.append("path").attr("d",(function(e){return r([{x:-15,y:-10,seq:1},{x:15,y:-10,seq:2},{x:0,y:10,seq:3}])})).attr("fill","white").attr("stroke","black").attr("stroke-width",2),i.append("text").attr("class","cim-object-text").style("text-anchor","middle").attr("font-size",3).attr("x",0).attr("y",20).text((function(e){let t=n.props.model.getAttribute(e,"cim:IdentifiedObject.name");return void 0!==t?t.innerHTML:""})),i},drawCompensators(e,t){let r=d3.line().x((function(e){return e.x})).y((function(e){return e.y})),i=n.createSelection(t,e)[1];return i.append("path").attr("d",(function(e){return r([{x:0,y:-10,seq:1},{x:0,y:-4,seq:2}])})).attr("fill","white").attr("stroke","black").attr("stroke-width",1),i.append("path").attr("d",(function(e){return r([{x:0,y:4,seq:1},{x:0,y:10,seq:2}])})).attr("fill","white").attr("stroke","black").attr("stroke-width",1),i.append("path").attr("d",(function(e){return r([{x:-15,y:-4,seq:1},{x:15,y:-4,seq:2}])})).attr("fill","white").attr("stroke","black").attr("stroke-width",4),i.append("path").attr("d",(function(e){return r([{x:-15,y:4,seq:1},{x:15,y:4,seq:2}])})).attr("fill","white").attr("stroke","black").attr("stroke-width",4),i.append("text").attr("class","cim-object-text").style("text-anchor","middle").attr("font-size",3).attr("x",0).attr("y",20).text((function(e){let t=n.props.model.getAttribute(e,"cim:IdentifiedObject.name");return void 0!==t?t.innerHTML:""})),i},drawPowerTransformers(t){const r=this.createSelection("PowerTransformer",t)[1],i=r.filter((function(e){return 2===n.props.model.getTargets([e],"PowerTransformer.PowerTransformerEnd").length})),o=r.filter((function(e){return 3===n.props.model.getTargets([e],"PowerTransformer.PowerTransformerEnd").length}));return i.append("circle").attr("r",e).attr("cx",0).attr("cy",11).attr("fill","white").attr("stroke","black").attr("stroke-width",1),o.append("circle").attr("r",e).attr("cx",-11).attr("cy",11).attr("fill","white").attr("stroke","black").attr("stroke-width",1),o.append("circle").attr("r",e).attr("cx",11).attr("cy",11).attr("fill","white").attr("stroke","black").attr("stroke-width",1),i.append("g").attr("class","TransformerEnd").attr("transform",d3.zoomIdentity.translate(0,-11)).append("circle").attr("r",e).attr("cx",0).attr("cy",0).attr("fill","white").attr("stroke","black").attr("stroke-width",1).attr("class","TransformerEndCircle"),i.append("g").attr("class","TransformerEnd").attr("transform",d3.zoomIdentity.translate(0,11)).append("circle").attr("r",e).attr("cx",0).attr("cy",0).attr("fill","white").attr("fill-opacity","0").attr("stroke","black").attr("stroke-width",1).attr("class","TransformerEndCircle"),o.append("g").attr("class","TransformerEnd").attr("transform",d3.zoomIdentity.translate(0,-11)).append("circle").attr("r",e).attr("cx",0).attr("cy",0).attr("fill","white").attr("stroke","black").attr("stroke-width",1).attr("class","TransformerEndCircle"),o.append("g").attr("class","TransformerEnd").attr("transform",d3.zoomIdentity.translate(-11,11)).append("circle").attr("r",e).attr("cx",0).attr("cy",0).attr("fill","white").attr("fill-opacity","0").attr("stroke","black").attr("stroke-width",1).attr("class","TransformerEndCircle"),o.append("g").attr("class","TransformerEnd").attr("transform",d3.zoomIdentity.translate(11,11)).append("circle").attr("r",e).attr("cx",0).attr("cy",0).attr("fill","white").attr("fill-opacity","0").attr("stroke","black").attr("stroke-width",1).attr("class","TransformerEndCircle"),r.append("text").attr("class","cim-object-text").style("text-anchor","end").attr("font-size",3).attr("x",-25).attr("y",0).text((function(e){const t=n.props.model.getAttribute(e,"cim:IdentifiedObject.name");return void 0!==t?t.innerHTML:""})),r},handlePowerTransformerEnds(e){const t=d3.select(e).datum(),r=d3.select(e.parentNode).datum(),i=n.props.model.getTargets([t],"Terminal.TransformerEnd"),o=t.x-r.x,a=t.y-r.y;let s=null,l=null;d3.select(e.parentNode).selectAll(":scope > g.TransformerEnd").each((function(){const e=this.transform.baseVal.consolidate();let t={e:0,f:0};null!==e&&(t=e.matrix);const n=t.e,r=t.f,i=(n-o)**2+(r-a)**2;(null===s||s>i)&&(s=i,l=d3.select(this))})),l.data(i),l.attr("id",(function(){return"cimdiagram-"+n.props.model.ID(i[0])})),l.select("circle.TransformerEndCircle").attr("stroke",(function(e){return n.voltageColor(e,"black")})),l.selectAll("path").remove();const c=n.props.model.getEnum(i[0],"cim:PowerTransformerEnd.connectionKind");if(void 0!==c){const e=.2,t=.4,n=[0,a*e],r=[0,a*t],i=t-e,o=i*Math.sqrt(3)/2,s=i/2,u=[a*-o,a*(e-s)],f=[a*o,a*(e-s)];c.startsWith("Y")&&(l.append("path").attr("d",d3.line()([r,n])).attr("stroke","black"),l.append("path").attr("d",d3.line()([n,u])).attr("stroke","black"),l.append("path").attr("d",d3.line()([n,f])).attr("stroke","black")),"D"===c&&l.append("path").attr("d",d3.line().curve(d3.curveLinearClosed)([r,u,f])).attr("stroke","black").attr("fill","white")}},createTerminals(t){let r=0,i=30,a="none";switch(t.size()>0&&(a=t.data()[0].nodeName),a){case"cim:Breaker":case"cim:Disconnector":case"cim:LoadBreakSwitch":r=-6,i=6;break;case"cim:EnergySource":case"cim:SynchronousMachine":case"cim:AsynchronousMachine":r=-13.5;break;case"cim:EnergyConsumer":case"cim:ConformLoad":case"cim:NonConformLoad":case"cim:EquivalentInjection":r=-11;break;case"cim:PowerTransformer":r=-26,i=26;break;case"cim:LinearShuntCompensator":case"cim:NonlinearShuntCompensator":r=-11;break;default:i=30}let s=[],l=t.selectAll("g.Terminal").data((function(e){return n.props.model.getTerminals([e])})),c=l.enter().append("g").each((function(t,l){let c=n.props.model.getTargets([t],o)[0],u=d3.select(this.parentNode).datum().lineData,f=u[0],d=u[u.length-1],h=d3.select(this.parentNode).datum().x,p=d3.select(this.parentNode).datum().y;1===u.length&&(f={x:0,y:r},d={x:0,y:i});let m=d3.select(this.parentNode).datum().rotation,g=n.props.model.getTerminals(d3.select(this.parentNode).data());if(void 0!==c&&2===g.length){let e=0,r=0;if(m>0){let t=rotate(f,m),n=rotate(d,m);e=Math.pow(h+t.x-c.x,2)+Math.pow(p+t.y-c.y,2),r=Math.pow(h+n.x-c.x,2)+Math.pow(p+n.y-c.y,2)}else e=Math.pow(h+f.x-c.x,2)+Math.pow(p+f.y-c.y,2),r=Math.pow(h+d.x-c.x,2)+Math.pow(p+d.y-c.y,2);re!==t))[0],u=n.props.model.getTargets([c],o)[0],f=c;if(void 0!==u){n.props.model.getEquipments(u).length>1&&(f=t)}c.x===t.x&&c.y===t.y&&(t.x===i+l.x&&t.y===a+l.y?(f.x=i+s.x,f.y=a+s.y):(f.x=i+l.x,f.y=a+l.y))}(g,t,0,h,p,f,d)}else 1===u.length?(t.x=h,3===g.length?(0===l&&(t.y=p+r),1===l&&(t.x=t.x-25+e,t.y=p+i),2===l&&(t.x=t.x+25-e,t.y=p+i)):t.y=p+r*(1-l)+i*l):(t.x=h+f.x*(1-l)+d.x*l,t.y=p+f.y*(1-l)+d.y*l);if(t.rotation=d3.select(this.parentNode).datum().rotation,void 0!==c&&void 0!==c.lineData){let e={source:c,target:t};s.push(e)}"cim:PowerTransformer"===a&&n.handlePowerTransformerEnds(this)})).attr("id",(function(e){return"cimdiagram-"+n.props.model.ID(e)})).attr("class",(function(e){return e.localName}));return n.createEdges(s),c.append("circle").attr("r",1).style("fill","black").attr("cx",(function(e,t){return d3.select(this.parentNode).datum().x-d3.select(this.parentNode.parentNode).datum().x})).attr("cy",(function(e,t){return d3.select(this.parentNode).datum().y-d3.select(this.parentNode.parentNode).datum().y})),l.each((function(e,t){let n=d3.select(this.parentNode).datum().x,r=d3.select(this.parentNode).datum().y,i=parseInt(d3.select(this.firstChild).attr("cx")),o=parseInt(d3.select(this.firstChild).attr("cy"));if(0===i&&0===o)e.x=n,e.y=r;else{let t=d3.select(this.parentNode).datum().lineData,i=t[t.length-1];e.x=n+i.x,e.y=r+i.y}})),l.selectAll("circle").attr("cx",(function(e,t){return d3.select(this.parentNode).datum().x-d3.select(this.parentNode.parentNode).datum().x})).attr("cy",(function(e,t){return d3.select(this.parentNode).datum().y-d3.select(this.parentNode.parentNode).datum().y})),c.each((function(){let e=d3.select(this).select("circle");d3.select(this).append("circle").attr("cx",e.attr("cx")).attr("cy",e.attr("cy")).attr("r",4).attr("stroke-width",0).attr("fill","steelblue").attr("fill-opacity","0.0").attr("class","big-circle").on("mouseout",(function(e,t){d3.select(this).attr("fill-opacity","0.0")}))})),c.on("mouseover",(function(e,t){0===d3.select(this).select("circle.selection-circle").size()&&d3.select(this).select("circle.big-circle").attr("fill-opacity","0.7")})),c},drawNodes(e){let t=d3.line().x((function(e){return e.x})).y((function(e){return e.y}));for(let t of e)calcLineData(n.props.model,t);d3.select("svg").select("g."+r+"s").empty()&&d3.select("svg").select("g#diagram-main").append("g").attr("class",r+"s");let i=d3.select("svg").select("g."+r+"s").selectAll("g."+r).data(e,(function(e){return n.props.model.ID(e)})),o=i.enter().append("g").attr("class",r).attr("id",(function(e){return"cimdiagram-"+n.props.model.ID(e)}));function a(e){e.attr("x",(function(e){let t=d3.select(this.parentNode).select("path").node();return t.getPointAtLength(t.getTotalLength()/2).x+2})).attr("y",(function(e){let t=d3.select(this.parentNode).select("path").node();return t.getPointAtLength(t.getTotalLength()/2).y-2})).text((function(e){let t=n.props.model.getBusbar(e);if(null!==t){let e=n.props.model.getAttribute(t,"cim:IdentifiedObject.name");if(void 0!==e)return e.innerHTML}return""}))}return i.select("path").attr("d",(function(e){let n=d3.select(this.parentNode).data()[0].lineData;return t(n)})).attr("stroke",(function(e){return n.voltageColor(n.props.model.getBusbar(e),"black")})),o.append("path").attr("d",(function(e){let n=d3.select(this.parentNode).data()[0].lineData;return t(n)})).attr("stroke",(function(e){return n.voltageColor(n.props.model.getBusbar(e),"black")})).attr("stroke-width",2).attr("fill","none"),o.filter((function(e){return null!==n.props.model.getBusbar(e)})).append("text").attr("class","cim-object-text").attr("font-size",3),a(o.select("text")),a(i.select("text")),o},moveTo(e){let t=n.props.model.getObject(e);if(void 0===t)return;if("cim:BusbarSection"===t.nodeName&&(t=n.props.model.getNode(t)),"cim:Substation"===t.nodeName||"cim:Line"===t.nodeName){let e=n.props.model.getTargets([t],"EquipmentContainer.Equipments");for(let r of e){if("cim:BusbarSection"===r.nodeName){let e=n.props.model.getNode(r);null!==e&&(r=e)}if(void 0!==r.x&&void 0!==r.y){t.x=r.x,t.y=r.y;break}}}if("cim:Analog"!==t.nodeName&&"cim:Discrete"!==t.nodeName||(t=n.props.model.getTargets([t],"Measurement.PowerSystemResource")[0],void 0!==t&&"cim:BusbarSection"===t.nodeName&&(t=n.props.model.getNode(t))),"cim:PowerTransformerEnd"===t.nodeName&&(t=n.props.model.getTargets([t],"PowerTransformerEnd.PowerTransformer")[0]),void 0===t.x||void 0===t.y)return;hidePopovers();let r=parseInt(d3.select("svg").style("width")),i=parseInt(d3.select("svg").style("height")),o=1*-t.x+r/2,a=1*-t.y+i/2,s=d3.transition().duration(750).ease(d3.easeLinear),l=d3.zoomIdentity.translate(o,a).scale(1);d3.selectAll("svg").select("g#diagram-main").transition(s).attr("transform",l),d3.zoom().transform(d3.selectAll("svg"),l),n.props.dispatcher.trigger("transform")},forceTick(e){0!==arguments.length&&void 0===e.alpha||(e=d3.select("svg").selectAll("svg > g#diagram-main > g:not(.edges) > g"));let t=d3.zoomTransform(d3.select("svg").node()),r=t.x,i=t.y,o=t.k;if(function(e){e.attr("transform",(function(e){return"translate("+e.x+","+e.y+") rotate("+e.rotation+")"})).selectAll("g.Terminal").each((function(e,t){e.x=d3.select(this.parentNode).datum().x+parseInt(d3.select(this.firstChild).attr("cx")),e.y=d3.select(this.parentNode).datum().y+parseInt(d3.select(this.firstChild).attr("cy"))})),e.selectAll("text.cim-object-text").attr("transform",(function(e){let t=0,n={x:0,y:0};switch(e.rotation%360==180&&(t=-1*e.rotation),e.nodeName){case"cim:Breaker":case"cim:Disconnector":case"cim:LoadBreakSwitch":case"cim:Junction":case"cim:PowerTransformer":n={x:0,y:0};break;default:n={x:d3.select(this).attr("x"),y:d3.select(this).attr("y")}}return"rotate("+t+","+n.x+","+n.y+")"})),e.selectAll("rect.selection-rect").attr("x",0).attr("y",0).attr("width",0).attr("height",0),e.selectAll("rect.selection-rect").attr("x",(function(e){return this.parentNode.getBBox().x})).attr("y",(function(e){return this.parentNode.getBBox().y})).attr("width",(function(e){return this.parentNode.getBBox().width})).attr("height",(function(e){return this.parentNode.getBBox().height})),e.selectAll("g.resize").selectAll("rect").attr("x",(function(e){return e[0].lineData.filter((t=>t.seq===e[1]))[0].x-2})).attr("y",(function(e){return e[0].lineData.filter((t=>t.seq===e[1]))[0].y-2}))}(e),1===arguments.length){let t=n.props.model.getTerminals(e.data()),a=d3.select("svg").selectAll("svg > g#diagram-main > g.edges > g").filter((function(n){return e.data().indexOf(n.source)>-1||t.indexOf(n.target)>-1}));n.updateEdges(r,i,o,a)}else n.updateEdges(r,i,o)},updateEdges(e,t,r,i){let o=d3.line().x((function(e){return e.x})).y((function(e){return e.y})).curve(d3.curveStepBefore);3===arguments.length&&(i=d3.select("svg").selectAll("svg > g#diagram-main > g.edges > g")),i.select("path").attr("d",(function(e){let t={x:e.source.x,y:e.source.y},r={x:e.target.x,y:e.target.y};return 0!==e.target.rotation&&(r=rotateTerm(n.props.model,e.target)),e.source.lineData.length>1?e.p=closestPoint(e.source,r):e.p=[0,0],t.x=t.x+e.p[0],t.y=t.y+e.p[1],o([t,r])})).attr("stroke-dasharray",(function(e){let t=n.props.model.getAttribute(e.target,"cim:ACDCTerminal.connected");return void 0!==t&&"false"===t.textContent?"5, 5":null}))},drawGrid(e){let t=parseInt(d3.select("svg").style("width"))/e,n=parseInt(d3.select("svg").style("height"))/e,r=d3.select("svg").select("g#diagram-grid");r.selectAll("*").remove();const i=25;for(let e=i;e<=n-i;e+=i)r.append("svg:line").attr("x1",0).attr("y1",e).attr("x2",t).attr("y2",e).attr("stroke-dasharray","1, 5").style("stroke","rgb(6,120,155)").style("stroke-width",1);for(let e=i;e<=t-i;e+=i)r.append("svg:line").attr("x1",e).attr("y1",0).attr("x2",e).attr("y2",n).attr("stroke-dasharray","1, 5").style("stroke","rgb(6,120,155)").style("stroke-width",1);r.attr("transform","scale("+e+")")},voltageColor(e,r){let i=r;if(null!=e){let r="ConductingEquipment.BaseVoltage";!0===n.props.model.schema.isA("TransformerEnd",e)&&(r="TransformerEnd.BaseVoltage");const o=n.props.model.getTargets([e],r)[0],a=n.props.model.getAttribute(o,"cim:BaseVoltage.nominalVoltage");if(void 0!==a&&""!==a.textContent){const e=a.textContent,n=parseFloat(e);i=t(n)}}return i},drawLegend(){let e=n.props.model.getObjects(["cim:BaseVoltage"])["cim:BaseVoltage"];d3.select("#legend-rect").attr("height",60+20*e.length),e.sort((function(e,t){const r=n.props.model.getAttribute(e,"cim:BaseVoltage.nominalVoltage"),i=n.props.model.getAttribute(t,"cim:BaseVoltage.nominalVoltage");if(void 0!==r&&void 0!==i){const e=r.textContent,t=parseFloat(e),n=i.textContent;return t
Legend
',[{type:n.TAG,getComponent:r,evaluate:function(e){return"cimdiagramcontrols"},slots:[],attributes:[{type:t.ATTRIBUTE,name:"model",evaluate:function(e){return e.props.model}},{type:t.ATTRIBUTE,name:"dispatcher",evaluate:function(e){return e.props.dispatcher}}],redundantAttribute:"expr0",selector:"[expr0]"}])},name:"cimdiagram"}})),function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e=e||self).cimDiagramControls=t()}(this,(function(){"use strict";let e=null,t="ConnectivityNode",n="ConnectivityNode.Terminals",r="Terminal.ConnectivityNode",i=d3.quadtree(),o=[],a=[],s=!1,l=!1,c=[{title:"Copy",action:function(t,n){let r=this;!0===e.props.model.schema.isA("TransformerEnd",d3.select(r).datum())&&(r=r.parentElement),-1===o.indexOf(r)&&(o.push(r),e.updateSelected());let i=d3.selectAll(o).data();for(let t of i)if("cim:ConnectivityNode"===t.nodeName){let n=e.props.model.getBusbar(t);null!==n&&(n.x=t.x,n.y=t.y,a.push(n))}else a.push(t)}},{title:"Rotate",action:function(t,n){let r=this;!0===e.props.model.schema.isA("TransformerEnd",d3.select(r).datum())&&(r=r.parentElement),-1===o.indexOf(r)&&(e.deselectAll(),o.push(r),e.updateSelected()),hidePopovers(o);let i=d3.selectAll(o);e.props.model.getTerminals(i.data()).forEach((function(e){e.rotation=(e.rotation+90)%360}));for(let t of i.data())t.rotation=(t.rotation+90)%360,e.props.model.updateActiveDiagram(t,t.lineData)}},{title:"Delete",action:function(t,n){let r=this;!0===e.props.model.schema.isA("TransformerEnd",d3.select(r).datum())&&(r=r.parentElement),e.deleteObject(r)}},{title:"Delete from current diagram",action:function(t,n){let r=this;!0===e.props.model.schema.isA("TransformerEnd",d3.select(r).datum())&&(r=r.parentElement),e.deleteFromDiagram(r)}},{title:"Show element info",action:function(t,n){let r=this;!0===e.props.model.schema.isA("TransformerEnd",d3.select(r).datum())&&(r=r.parentElement),-1===o.indexOf(r)&&(e.deselectAll(),o.push(r),e.updateSelected()),showPopovers(o)}},{title:"Add new operational limit set",action:function(t,n){e.addNewLimitSet(this,n)}}],u=c.concat([{title:"Add points",action:function(t,n){let r=e.status,i=this;e.disableAll(),e.deselectAll(),o.push(i),d3.select("svg").on("contextmenu.general",null),e.addDrawing(n,(function(t){let o=d3.select("svg"),a=o.selectAll("svg > #diagram-connect > path"),s=o.selectAll("svg > #diagram-connect > circle");switch(t.preventDefault(),e.addNewPoint(n),e.deleteFromDiagram(i),e.props.model.addToActiveDiagram(n,n.lineData),o.on("mousemove",null),a.attr("d",null),s.attr("transform","translate(0, 0)"),d3.select("svg > #diagram-connect > path").datum(null),o.on("contextmenu.add",null),o.on("click.add",null),r){case"DRAG":e.enableDrag();break;case"ZOOM":e.enableZoom();break;case"CONNECT":e.enableConnect();break;default:{let t=r.substring("ADD".length);t.startsWith("Multi")?(t=t.substring("Multi".length),e.enableAddMulti(t)):e.enableAdd(t);break}}d3.select("svg").on("contextmenu.general",d3.contextMenu(g))})),d3.select("svg").on("click.add",(function(){e.addNewPoint(n)}))}}]),f=[{title:"Delete point",action:function(t,n){let r=d3.selectAll(o).data().filter((e=>e===n[0]))[0];o=o.filter((e=>d3.select(e).datum()!==n[0])),e.deselectAll(),o.push(r),e.updateSelected(),e.deleteFromDiagram(this.parentNode),n[0].lineData=n[0].lineData.filter((e=>e.seq!==n[1]));for(let e of n[0].lineData)e.seq>n[1]&&(e.seq=e.seq-1);e.props.model.addToActiveDiagram(n[0],n[0].lineData)}}],d=[{title:"Add new operational limit set",action:function(t,n){e.addNewLimitSet(this,n)}},{title:"Add regulating control",action:function(t,n){e.addRegulatingControl(this,n)}},{title:"Add tap changer control",action:function(t,n){e.addTCControl(this,n)}}],h=d.concat([{title:"Add ratio tap changer",action:function(t,n){e.addTC(this,n)}}]),p=c.concat([{title:"Add ratio tap changer",action:function(t,n){e.addTC(this,n)}}]),m=[{title:"Delete",action:function(t,r){let i=e.getLinkedCNs([r.target])[0];if(void 0!==i){let t=e.props.model.ID(i.cn),n=d3.select("svg").selectAll("g#cimdiagram-"+t).node();e.deleteObject(n)}else e.props.model.removeLink(r.source,"cim:"+n,r.target)}}],g=[{title:"Paste",disabled:function(e,t){return a.length<1},action:function(t,n){if(a.length<1)return;let r=d3.pointer(t,d3.select("svg").node()),i=d3.zoomTransform(d3.select("svg").node()),o=(i.x,i.y,i.k,r[0]-a[0].x),s=r[1]-a[0].y,l=null;for(let t of a){let n=e.props.model.createObject(t.nodeName);for(let r of e.props.model.getAttributes(t)){let t=r.nodeName,i=r.textContent;e.props.model.setAttribute(n,t,i)}if(n.x=t.x+o,n.y=t.y+s,"cim:BusbarSection"===n.nodeName){let n=e.props.model.getNode(t);if(null===n)return;l=n.lineData}else l=t.lineData;e.props.model.addToActiveDiagram(n,l)}a=[]}}];const b=d3.drag().on("drag",(function(t,n){hidePopovers(o);const r={x:t.x,y:t.y,seq:n[1]},i=e.align(n[0],r,!0);!function(e,t,n){const r=e.lineData.filter((e=>e.seq===t))[0],i=rotate({x:n.x,y:n.y},-1*e.rotation);if(1!==r.seq)r.x=n.x,r.y=n.y;else{e.x=e.x+n.x,e.y=e.y+n.y;for(let t of e.lineData)1!==t.seq&&(t.x=t.x-i.x,t.y=t.y-i.y)}}(n[0],n[1],i),e.props.model.updateActiveDiagram(n[0],n[0].lineData)})).on("start",(function(t,n){e.removeFromQuadtree()})).on("end",(function(t,n){e.highlight(null),e.props.model.updateActiveDiagram(n[0],n[0].lineData),e.addToQuadtree(d3.selectAll(o))}));return{css:null,exports:{onBeforeMount(a,s){e=this,e.props.dispatcher.on("moveTo",(function(t){e.deselectAll();let n=e.props.model.getObject(t),r=null,i=null,a=null,s=null,l=null;if(void 0!==n){switch(n.nodeName){case"cim:Substation":case"cim:Line":r=e.props.model.getTargets([n],"EquipmentContainer.Equipments");for(let t of r)"cim:BusbarSection"===t.nodeName&&(a=e.props.model.getNode(t),null!==a&&(t=a)),l=d3.select("svg").select("#cimdiagram-"+e.props.model.ID(t)).node(),null!==l&&o.push(l);break;case"cim:Analog":case"cim:Discrete":i=e.props.model.getTargets([n],"Measurement.Terminal");for(let t of i)l=d3.select("svg").select("#cimdiagram-"+e.props.model.ID(t)).node(),null!==l&&o.push(l);break;case"cim:BusbarSection":a=e.props.model.getNode(n),s=e.props.model.ID(a),l=d3.select("svg").selectAll("g#cimdiagram-"+s).node(),o=[l];break;default:l=d3.select("svg").selectAll("g#cimdiagram-"+t).node(),o=[l]}e.updateSelected()}})),e.props.dispatcher.on("deselect",(function(){e.deselectAll()})),e.props.dispatcher.on("render",(function(){"BUS_BRANCH"===e.props.model.getMode()?(t="TopologicalNode",n="TopologicalNode.Terminal",r="Terminal.TopologicalNode"):(c.push({title:"Add new measurement",action:function(t,n){e.addNewMeasurement(this,n)}}),u.push({title:"Add new measurement",action:function(t,n){e.addNewMeasurement(this,n)}}),d.push({title:"Add new measurement",action:function(t,n){e.addNewMeasurement(this,n)}}));let o=d3.select("svg").selectAll("svg > g#diagram-main > g:not(.edges) > g");i.x((function(e){let t=d3.select(e.elm).datum(),n=t.lineData.filter((t=>t.seq===e.seq));return t.x+n[0].x})).y((function(e){let t=d3.select(e.elm).datum(),n=t.lineData.filter((t=>t.seq===e.seq));return t.y+n[0].y})),e.addToQuadtree(o);let a=d3.select("svg").selectAll("svg > g#diagram-main > g.edges > g");e.addContextMenu(o),d3.select("svg").on("contextmenu.general",d3.contextMenu(g)),a.on("contextmenu",d3.contextMenu(m)),e.disableZoom(),e.disableConnect(),e.enableDrag(),document.querySelector("#cim-diagram-controls").classList.remove("invisible");let s=null;d3.select("body").on("keydown",(function(t){void 0!==t&&t.ctrlKey&&(null===s&&(s=e.status),e.disableDrag(),e.disableZoom(),e.enableZoom())})).on("keyup",(function(t){if(17===t.keyCode){switch(e.disableZoom(),s){case"DRAG":e.enableDrag();break;case"ZOOM":e.enableZoom();break;default:e.status=s}s=null}27===t.keyCode&&d3.contextMenu("close")}))})),e.props.dispatcher.on("addToDiagram",(function(t){1===t.size()&&(e.addToQuadtree(t),"DRAG"===e.status&&(e.disableAll(),e.enableDrag()),e.addContextMenu(t))})),e.props.dispatcher.on("createEdges",(function(e){e.on("contextmenu",d3.contextMenu(m))}))},onMounted(){document.querySelector("#select").addEventListener("change",(function(){e.disableAll(),e.enableDrag()})),document.querySelector("#pan").addEventListener("change",(function(){e.disableAll(),e.enableZoom()})),document.querySelector("#connect").addEventListener("change",(function(){e.disableAll(),e.enableConnect()})),document.querySelector("#legendToggle").addEventListener("change",(function(){const e=d3.transition().duration(750).ease(d3.easeLinear);!1===this.checked?d3.select("#diagram-legend").transition(e).attr("transform",d3.zoomIdentity.translate(1200,50)):d3.select("#diagram-legend").transition(e).attr("transform",d3.zoomIdentity.translate(1050,50))}))},disableAll(){e.disableDrag(),e.disableZoom(),e.disableConnect(),e.disableAdd()},deselectAll(){d3.selectAll(o).selectAll("rect.selection-rect").remove(),d3.selectAll(o).selectAll("g.resize").remove(),d3.selectAll(o).selectAll("circle.selection-circle").remove(),o=[]},enableDrag(){let t=[];e.disableDrag(),d3.select(e.root).selectAll("#cim-diagram-controls > label:not(#selectLabel)").classed("active",!1),e.status="DRAG";let n=d3.drag().on("start",(function(n,r){if(d3.contextMenu("close"),-1===o.indexOf(this)&&e.deselectAll(),0===o.length&&(o.push(this),e.updateSelected()),e.removeFromQuadtree(),!0===e.props.model.schema.isA("ConductingEquipment",r)){let n=e.props.model.getTerminals([r]);t=e.getLinkedCNs(n)}let i=e.props.model.getTerminals(d3.selectAll(o).data());d3.select("svg").selectAll("svg > g#diagram-main > g.edges > g").filter((function(e){return d3.selectAll(o).data().indexOf(e.source)>-1||i.indexOf(e.target)>-1})).select("path").attr("stroke","green").attr("stroke-width","3")})).on("drag",(function(n,r){hidePopovers(o);let i=n.x-r.x,a=n.y-r.y,s={x:0,y:0};for(let t of o){let n=d3.select(t).data()[0];if(n.x=n.x+i,n.px=n.x,n.y=n.y+a,n.py=n.y,0===s.x&&0===s.y)for(let t of n.lineData){let r=e.align(n,t,!1);if(s={x:r.x-t.x,y:r.y-t.y},0!==s.x||0!==s.y){t.seq>1&&(s=rotate(s,n.rotation));break}}}for(let t of o){let n=d3.select(t).data()[0];l(n,null,s),e.props.model.updateActiveDiagram(n,n.lineData)}for(let n of t){let t={x:n.cnTerms[0].x,y:n.cnTerms[0].y},r={x:n.cnTerms[1].x,y:n.cnTerms[1].y};n.cnTerms[0].rotation>0&&(t=rotateTerm(e.props.model,n.cnTerms[0])),n.cnTerms[1].rotation>0&&(r=rotateTerm(e.props.model,n.cnTerms[1])),n.cn.x=(t.x+r.x)/2,n.cn.y=(t.y+r.y)/2,e.props.model.updateActiveDiagram(n.cn,n.cn.lineData)}function l(e,t,n){e.x=e.x+n.x,e.y=e.y+n.y,e.px=e.x,e.py=e.y}})).on("end",(function(n,r){e.addToQuadtree(d3.selectAll(o)),t=[];let i=e.props.model.getTerminals(d3.selectAll(o).data());d3.select("svg").selectAll("svg > g#diagram-main > g.edges > g").filter((function(e){return d3.selectAll(o).data().indexOf(e.source)>-1||i.indexOf(e.target)>-1})).select("path").attr("stroke","black").attr("stroke-width","1"),e.highlight("x",null),e.highlight("y",null)}));d3.select("svg").selectAll("svg > g#diagram-main > g:not(.edges) > g").call(n),d3.select("svg").select("g#diagram-brush").call(d3.brush().on("start",(function(){let t=window.location.hash.substring(1).split("/"),n=t[0]+"/"+t[1]+"/"+t[2];route.router.push(n),e.deselectAll(),hidePopovers(),d3.contextMenu("close")})).on("end",(function(t){d3.select("svg").select("g#diagram-brush").selectAll("*:not(.overlay)").style("display","none");let n=t.selection;if(null===n)return;e.deselectAll();let r=d3.zoomTransform(d3.select("svg").node()),a=r.x,s=r.y,l=r.k;o=e.search(i,(n[0][0]-a)/l,(n[0][1]-s)/l,(n[1][0]-a)/l,(n[1][1]-s)/l),e.updateSelected()})))},search(e,t,n,r,i){let o=new Set;return e.visit((function(e,a,s,l,c){if(!e.length)do{let a=e.data,s=d3.select(a.elm).datum();for(let e of s.lineData){let l=rotate(e,s.rotation),c=s.x+l.x,u=s.y+l.y;if(c>=t&&c=n&&u=r||s>=i||lo.indexOf(e.elm)>-1));i.removeAll(e)},updateSelected(){d3.selectAll(o).each((function(t){e.hover(this)})).selectAll("g.resize").call(b).filter((function(e){return e[0].lineData.length>2})).on("contextmenu",d3.contextMenu(f))},getLinkedCNs(t){let i=[],o=e.props.model.getTargets(t,r);for(let t of o){if(void 0===t.lineData)continue;if(t.lineData.length>1)continue;let r=e.props.model.getTargets([t],n);if(2===r.length){let e={cn:t,cnTerms:r};i.push(e)}}return i},disableDrag(){d3.select("svg").selectAll("svg > g#diagram-main > g:not(.edges) > g").on(".drag",null),d3.select("svg").select("g#diagram-brush").on(".brush",null),"DRAG"===e.status&&d3.select("svg").select("g#diagram-brush").call(d3.brush().move,null)},enableZoom(){e.status="ZOOM",hidePopovers(),d3.select("svg").selectAll("svg > g#diagram-main > g:not(.edges) > g").on("click.zoom",(function(t,n){let r=window.location.hash.substring(1).split("/"),i=r[0]+"/"+r[1]+"/"+r[2];route.router.push(i+"/"+e.props.model.ID(n))}));let t=d3.zoom();t.on("zoom",this.zooming),d3.select("svg").call(t)},disableZoom(){d3.select("svg").selectAll("svg > g#diagram-main > g:not(.edges) > g").on("click.zoom",null),d3.select("svg").on(".zoom",null)},zooming(t){d3.select("svg").select("g#diagram-main").attr("transform",t.transform),e.props.dispatcher.trigger("transform");let n=d3.select("svg > #diagram-connect > path").datum();if(void 0===n)return;let r=d3.line().x((function(e){return e.x})).y((function(e){return e.y})),i=d3.select("svg > #diagram-connect > path"),o=d3.zoomTransform(d3.select("svg").node()),a=d3.select("svg > #diagram-connect > circle").node().transform.baseVal.consolidate();if(null===a)return;let s=a.matrix,l=s.e-10,c=s.f-10,u=[],f=n.obj;if(void 0===f.lineData)u.push({x:f.x*o.k+o.x,y:f.y*o.k+o.y});else for(let e of f.lineData)u.push({x:(e.x+f.x)*o.k+o.x,y:(e.y+f.y)*o.k+o.y});u.push({x:l,y:c}),i.attr("d",(function(){return r(u)}))},enableConnect(){function n(t){d3.select("svg").selectAll("svg > #diagram-connect > path").attr("d",null),d3.select("svg").selectAll("svg > #diagram-connect > circle").attr("transform","translate(0, 0)");let n=d3.select("svg > #diagram-connect > path").datum();void 0!==n&&(d3.select("svg").on("mousemove",null),e.props.model.setLink(n.obj,"cim:"+r,t),d3.select("svg > #diagram-connect > path").datum(null))}e.deselectAll(),d3.select("body").on("keyup.connect",(function(t){27===t.keyCode&&(e.disableConnect(),e.enableConnect())})),d3.select(e.root).selectAll("#cim-diagram-controls > label:not(#connectLabel)").classed("active",!1),e.status="CONNECT",d3.select("svg").selectAll("svg > g#diagram-main > g:not(.edges) > g > g.Terminal").on("click",(function(n,i){let o=d3.line().x((function(e){return e.x})).y((function(e){return e.y})),a={x:i.x,y:i.y};i.rotation>0&&(a=rotateTerm(e.props.model,i));let s=d3.select("svg"),l=d3.select("svg > #diagram-connect > path"),c=d3.select("svg > #diagram-connect > circle"),u=l.datum();if(void 0!==u&&(u=u.obj),void 0!==u){let n=e.props.model.getTargets([i],r)[0];if(void 0===n)n=e.props.model.getTargets([u],r)[0];else{let n=e.getLinkedCNs([u]);for(let r of n){let n=e.props.model.ID(r.cn),i=d3.select("svg > g#diagram-main > g."+t+"s > g#cimdiagram-"+n).node();e.deleteObject(i)}}if(d3.select("svg").selectAll("svg > #diagram-connect > path").attr("d",null),d3.select("svg").selectAll("svg > #diagram-connect > circle").attr("transform","translate(0, 0)"),void 0===n){let r={x:u.x,y:u.y};u.rotation>0&&(r=rotateTerm(e.props.model,u)),n=e.props.model.createObject("cim:"+t),e.props.model.setAttribute(n,"cim:IdentifiedObject.name","new1"),n.x=(r.x+a.x)/2,n.y=(r.y+a.y)/2,e.props.model.addToActiveDiagram(n,[{x:0,y:0,seq:1}])}d3.select("svg").on("mousemove",null);let o="cim:"+r;e.props.model.setLink(u,o,n),e.props.model.setLink(i,o,n),l.datum(null)}else{s.on("mousemove",(function(e){let t=d3.pointer(e),n=d3.zoomTransform(d3.select("svg").node());c.attr("transform",(function(){return"translate("+(t[0]+10)+","+(t[1]+10)+")"})),l.attr("d",(function(){let e=a.x*n.k+n.x,r=a.y*n.k+n.y;return o([{x:e,y:r},{x:t[0],y:t[1]}])}))})),l.datum({obj:i})}})),d3.select("svg").selectAll("svg > g#diagram-main > g."+t+"s > g."+t).on("click",(function(e,t){n(t)})),d3.select("svg").selectAll("svg > g#diagram-main > g.edges > g").on("click",(function(e,t){n(t.source)}))},disableConnect(){d3.select("body").on("keyup.connect",null),d3.select("svg").selectAll("svg > g#diagram-main > g:not(.edges) > g > g.Terminal").on("click",null),d3.select("svg").selectAll("svg > g#diagram-main > g."+t+"s > g."+t).on("click",null),d3.select("svg").selectAll("svg > g#diagram-main > g.edges > g").on("click",null),d3.select("svg").on("mousemove",null),d3.select("svg > #diagram-connect > path").attr("d",null),d3.select("svg > #diagram-connect > circle").attr("transform","translate(0, 0)");let e=d3.select("svg > #diagram-connect > path").datum();void 0!==e&&"cim:Terminal"===e.nodeName&&d3.select("svg > #diagram-connect > path").datum(null)},enableAdd(t){let n="",r="";"object"==typeof t?(n=t.target.id,r=t.target.textContent):(n=t,r=d3.select("#"+n).text());let i=void 0;"Three-winding Transformer"===r&&(i={windNum:3}),e.disableAll(),d3.select(e.root).selectAll("#cim-diagram-controls > label").classed("active",!1),document.querySelector("cimDiagramControls").querySelectorAll("input").forEach((function(e){e.checked=!1})),document.querySelector("#addElement").textContent=r,e.status="ADD"+n,d3.select("svg").on("click.add",(function(t){if(!1===t.ctrlKey){let r=e.props.model.createObject("cim:"+n,i);addToDiagram(e.props.model,t,r)}}))},enableAddMulti(t){let n="",r="",i=d3.select("svg"),o=i.selectAll("svg > #diagram-connect > path"),a=i.selectAll("svg > #diagram-connect > circle");e.disableAll(),d3.select("svg").on("contextmenu.general",null),d3.select("body").on("keyup.addMulti",(function(n){27===n.keyCode&&(e.disableAdd(),e.enableAddMulti(t))})),"object"==typeof t?(n=t.target.id,r=t.target.textContent):(n=t,r=d3.select("#"+n).text()),d3.select(e.root).selectAll("#cim-diagram-controls > label").classed("active",!1),document.querySelector("cimDiagramControls").querySelectorAll("input").forEach((function(e){e.checked=!1})),document.querySelector("#addElement").textContent=r,e.status="ADDMulti"+n,d3.select("svg").on("click.add",(function(t){if(!1===t.ctrlKey)if(e.status==="ADDMulti"+n){s=e.props.model.createObject("cim:"+n);let r=d3.pointer(t),l=d3.zoomTransform(d3.select("svg").node()),c=l.x,u=l.y,f=l.k;s.x=Math.round((r[0]-c)/f),s.px=s.x,s.y=Math.round((r[1]-u)/f),s.py=s.y,s.lineData=[{x:0,y:0,seq:1}],s.rotation=0,e.addDrawing(s,(function(t){t.preventDefault(),e.addNewPoint(s),e.props.model.addToActiveDiagram(s,s.lineData),e.status="ADDMulti"+n,i.on("mousemove",null),o.attr("d",null),a.attr("transform","translate(0, 0)"),d3.select("svg > #diagram-connect > path").datum(null),i.on("contextmenu.add",null)}))}else e.addNewPoint(s)}));let s=void 0},addDrawing(t,n){e.status="ADDdrawing";let r=d3.select("svg");r.on("contextmenu.add",n),r.on("mousemove",(function(n){let i=d3.pointer(n),o=d3.zoomTransform(r.node()),a=(i[0]-o.x)/o.k,s=(i[1]-o.y)/o.k,l=rotate({x:a-t.x,y:s-t.y,seq:null},-1*t.rotation),c=rotate(e.align(t,l,!0),t.rotation);!function(e,n,i){let o=d3.zoomTransform(r.node()),a=r.selectAll("svg > #diagram-connect > path"),s=r.selectAll("svg > #diagram-connect > circle"),l=d3.line().x((function(e){return e.x})).y((function(e){return e.y}));s.attr("transform",(function(){return"translate("+((e.x+i.x)*o.k+o.x+10)+","+((e.y+i.y)*o.k+o.y+10)+")"})),a.attr("d",(function(){let n=[];for(let r of e.lineData){let i=rotate(r,t.rotation);n.push({x:(i.x+e.x)*o.k+o.x,y:(i.y+e.y)*o.k+o.y})}return n.push({x:(e.x+i.x)*o.k+o.x,y:(e.y+i.y)*o.k+o.y}),l(n)})),a.datum({obj:t,x:e.x+i.x,y:e.y+i.y})}(t,0,c)}))},addNewPoint(t){let n=d3.select("svg").selectAll("svg > #diagram-connect > path").datum(),r=n.x-t.x,i=n.y-t.y,o=t.lineData.length+1,a=rotate({x:r,y:i},-1*t.rotation);t.lineData.push({x:a.x,y:a.y,seq:o}),e.highlight(null)},align(t,n,r){let o=d3.zoomTransform(d3.select("svg").node()),a=!1,c=!1,u=rotate(n,t.rotation),f=t.x+u.x,d=t.y+u.y,h=u.x,p=u.y,m=f-250/o.k,g=d-250/o.k,b=f+250/o.k,v=d+250/o.k,y=e.search(i,m,g,b,v),_=d3.selectAll(y).data();!0===r&&_.push(t);for(let r of _)e:for(let i of r.lineData){if(r===t&&i.seq===n.seq)continue e;let u=rotate(i,r.rotation),m=u.x+r.x,g=u.y+r.y,b=f-m,v=d-g;if(Math.abs(b)<5){f=m,h=f-t.x;let n=m*o.k+o.x;e.highlight("x",n),a=!0,s=!0}if(Math.abs(v)<5){d=g,p=d-t.y;let n=g*o.k+o.y;e.highlight("y",n),c=!0,l=!0}}!1===a&&!0===s&&(e.highlight("x",null),s=!1),!1===c&&!0===l&&(e.highlight("y",null),l=!1);let w={x:h,y:p},x=rotate(w,-1*t.rotation);return 1===n.seq?w:x},highlight(e,t,n){let r=d3.select("svg").select("g#diagram-highlight"),i=null,o=null,a=null,s=null,l=parseInt(d3.select("svg").style("height")),c=parseInt(d3.select("svg").style("width")),u=2*Math.max(l,c);"x"===e?(i=t,o=-1*u,a=t,s=u,r.select("line.highlight-x").attr("x1",i).attr("y1",o).attr("x2",a).attr("y2",s)):"y"===e?(i=-1*u,o=t,a=u,s=t,r.select("line.highlight-y").attr("x1",i).attr("y1",o).attr("x2",a).attr("y2",s)):(r.select("line.highlight-x").attr("x1",i).attr("y1",o).attr("x2",a).attr("y2",s),r.select("line.highlight-y").attr("x1",i).attr("y1",o).attr("x2",a).attr("y2",s)),3===arguments.length?r.attr("transform","rotate("+n.val+","+n.x+","+n.y+")"):r.attr("transform",null)},disableAdd(){document.querySelector("#addElement").textContent="Insert element",d3.select("body").on("keyup.addMulti",null),d3.select("svg").on("click.add",null),d3.select("svg").on("contextmenu.add",null),d3.select("svg").on("contextmenu.general",d3.contextMenu(g)),d3.select("svg").on("mousemove",null),d3.select("svg > #diagram-connect > path").attr("d",null),d3.select("svg > #diagram-connect > circle").attr("transform","translate(0, 0)");let t=d3.select("svg > #diagram-connect > path").datum();if(void 0!==t){0===e.props.model.getDiagramObjects([t.obj]).length?e.props.model.deleteObject(t.obj):calcLineData(e.props.model,t.obj)}d3.select("svg > #diagram-connect > path").datum(null),e.highlight("x",null),e.highlight("y",null)},hover(e){let n=d3.select(e);n.filter("g:not(.ACLineSegment)").filter("g:not(."+t+")").filter("g:not(.Terminal)").each((function(e){d3.select(this).append("rect").attr("x",this.getBBox().x).attr("y",this.getBBox().y).attr("width",this.getBBox().width).attr("height",this.getBBox().height).attr("stroke","black").attr("stroke-width",2).attr("stroke-dasharray","5,5").attr("fill","none").attr("class","selection-rect")})),n.filter("g.ACLineSegment,g."+t).selectAll("g.resize").data((function(e){return e.lineData.map((t=>[e,t.seq]))})).enter().append("g").attr("class","resize").append("rect").attr("x",(function(e){return e[0].lineData.filter((t=>t.seq===e[1]))[0].x-2})).attr("y",(function(e){return e[0].lineData.filter((t=>t.seq===e[1]))[0].y-2})).attr("width",4).attr("height",4),n.filter("g.Terminal").each((function(e){let t=d3.select(this).select("circle");d3.select(this).append("circle").attr("cx",t.attr("cx")).attr("cy",t.attr("cy")).attr("r",8).attr("stroke-width",0).attr("fill","red").attr("fill-opacity","0.7").attr("class","selection-circle")}))},addNewMeasurement(n,r){e.deselectAll(),"cim:Terminal"!==r.nodeName&&(o.push(n),e.updateSelected());let i=null;if(i=!0===e.props.model.schema.isA("Switch",r)?e.props.model.createObject("cim:Discrete"):e.props.model.createObject("cim:Analog"),"cim:Terminal"===r.nodeName){let t=e.props.model.getTargets([r],"Terminal.ConductingEquipment")[0];e.props.model.setLink(i,"cim:Measurement.Terminal",r),e.props.model.setLink(i,"cim:Measurement.PowerSystemResource",t)}else if(r.nodeName==="cim:"+t){let t=e.props.model.getBusbar(r);null!==t&&e.props.model.setLink(i,"cim:Measurement.PowerSystemResource",t)}else e.props.model.setLink(i,"cim:Measurement.PowerSystemResource",r);e.props.model.addToActiveDiagram(i,[])},addNewLimitSet(n,r){e.deselectAll();let i=n,a=r;!0===e.props.model.schema.isA("TransformerEnd",d3.select(n).datum())&&(i=n.parentElement,a=d3.select(i).datum()),"cim:Terminal"!==a.nodeName&&(o.push(i),e.updateSelected());let s=e.props.model.createObject("cim:OperationalLimitSet");if("cim:Terminal"===a.nodeName){e.props.model.getTargets([a],"Terminal.ConductingEquipment")[0];e.props.model.setLink(s,"cim:OperationalLimitSet.Terminal",a)}else if(a.nodeName==="cim:"+t){let t=e.props.model.getBusbar(a);null!==t&&e.props.model.setLink(s,"cim:OperationalLimitSet.Equipment",t)}else e.props.model.setLink(s,"cim:OperationalLimitSet.Equipment",a);e.props.model.addToActiveDiagram(s,[])},addRegulatingControl(t,n){e.deselectAll();let r=e.props.model.createObject("cim:RegulatingControl");e.props.model.setLink(r,"cim:RegulatingControl.Terminal",n),e.props.model.addToActiveDiagram(r,[])},addTCControl(t,n){e.deselectAll();let r=e.props.model.createObject("cim:TapChangerControl");e.props.model.setLink(r,"cim:RegulatingControl.Terminal",n),e.props.model.addToActiveDiagram(r,[])},addTC(t,n){e.deselectAll();let r=n;if(!0===e.props.model.schema.isA("Terminal",n)&&(r=e.props.model.getTargets([n],"Terminal.TransformerEnd")[0]),0===e.props.model.getTargets([r],"TransformerEnd.RatioTapChanger").length){let t=e.props.model.createObject("cim:RatioTapChanger");e.props.model.setLink(t,"cim:RatioTapChanger.TransformerEnd",r),e.props.model.addToActiveDiagram(t,[])}},addContextMenu(e){e.filter("g:not(.ACLineSegment)").filter("g:not(."+t+")").filter("g:not(.PowerTransformer)").on("contextmenu",d3.contextMenu(c)),e.filter("g.ACLineSegment,g."+t).selectAll("path").on("contextmenu",(function(e,t){d3.contextMenu(u).bind(this.parentNode)(e,t),e.stopPropagation()})),e.filter("g:not(.PowerTransformer)").selectAll("g.Terminal").on("contextmenu",(function(e,t){d3.contextMenu(d).bind(this)(e,t),e.stopPropagation()})),e.filter("g.PowerTransformer").selectAll("g.Terminal").on("contextmenu",(function(e,t){d3.contextMenu(h).bind(this)(e,t),e.stopPropagation()})),e.filter("g.PowerTransformer").selectAll("g.TransformerEnd").on("contextmenu",(function(e,t){d3.contextMenu(p).bind(this)(e,t),e.stopPropagation()}))},deleteObject(t){let n=e.deleteSelection(t);e.props.model.deleteObjects(n.data())},deleteFromDiagram(t){let n=e.deleteSelection(t);for(let t of n.data())e.props.model.deleteFromDiagram(t)},deleteSelection(n){-1===o.indexOf(n)&&(e.deselectAll(),o.push(n));let r=d3.selectAll(o),i=e.props.model.getTerminals(r.data()),a=e.getLinkedCNs(i);for(let n of a){let r=e.props.model.ID(n.cn),i=d3.select("svg > g#diagram-main > g."+t+"s > g#cimdiagram-"+r).node();o.push(i)}return e.removeFromQuadtree(),r=d3.selectAll(o),disposePopovers(o),r.remove(),r}},template:function(e,t,n,r){return e('',[{redundantAttribute:"expr2",selector:"[expr2]",expressions:[{type:t.EVENT,name:"onclick",evaluate:function(e){return e.enableAddMulti}}]},{redundantAttribute:"expr3",selector:"[expr3]",expressions:[{type:t.EVENT,name:"onclick",evaluate:function(e){return e.enableAddMulti}}]},{redundantAttribute:"expr4",selector:"[expr4]",expressions:[{type:t.EVENT,name:"onclick",evaluate:function(e){return e.enableAdd}}]},{redundantAttribute:"expr5",selector:"[expr5]",expressions:[{type:t.EVENT,name:"onclick",evaluate:function(e){return e.enableAdd}}]},{redundantAttribute:"expr6",selector:"[expr6]",expressions:[{type:t.EVENT,name:"onclick",evaluate:function(e){return e.enableAdd}}]},{redundantAttribute:"expr7",selector:"[expr7]",expressions:[{type:t.EVENT,name:"onclick",evaluate:function(e){return e.enableAdd}}]},{redundantAttribute:"expr8",selector:"[expr8]",expressions:[{type:t.EVENT,name:"onclick",evaluate:function(e){return e.enableAdd}}]},{redundantAttribute:"expr9",selector:"[expr9]",expressions:[{type:t.EVENT,name:"onclick",evaluate:function(e){return e.enableAdd}}]},{redundantAttribute:"expr10",selector:"[expr10]",expressions:[{type:t.EVENT,name:"onclick",evaluate:function(e){return e.enableAdd}}]},{redundantAttribute:"expr11",selector:"[expr11]",expressions:[{type:t.EVENT,name:"onclick",evaluate:function(e){return e.enableAdd}}]},{redundantAttribute:"expr12",selector:"[expr12]",expressions:[{type:t.EVENT,name:"onclick",evaluate:function(e){return e.enableAdd}}]},{redundantAttribute:"expr13",selector:"[expr13]",expressions:[{type:t.EVENT,name:"onclick",evaluate:function(e){return e.enableAdd}}]},{redundantAttribute:"expr14",selector:"[expr14]",expressions:[{type:t.EVENT,name:"onclick",evaluate:function(e){return e.enableAdd}}]},{redundantAttribute:"expr15",selector:"[expr15]",expressions:[{type:t.EVENT,name:"onclick",evaluate:function(e){return e.enableAdd}}]},{redundantAttribute:"expr16",selector:"[expr16]",expressions:[{type:t.EVENT,name:"onclick",evaluate:function(e){return e.enableAdd}}]}])},name:"cimdiagramcontrols"}})),function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e=e||self).cimDraw=t()}(this,(function(){"use strict";let e=null;return{css:'cimdraw .center-block,[is="cimdraw"] .center-block{ text-align: center; } cimdraw nav.navbar,[is="cimdraw"] nav.navbar{ margin-bottom: 20px; } cimdraw .app-container,[is="cimdraw"] .app-container{ display: flex; flex-flow: row nowrap; } cimdraw .navbar-light .navbar-text,[is="cimdraw"] .navbar-light .navbar-text{ color: rgba(0,0,0,1); } cimdraw .navbar-light .navbar-nav .nav-link,[is="cimdraw"] .navbar-light .navbar-nav .nav-link{ color: rgba(0,0,0,1); } cimdraw .cim-content-center,[is="cimdraw"] .cim-content-center{ text-align: center; max-width: 700px; } cimdraw #upload-boundary,[is="cimdraw"] #upload-boundary{ display: none; }',exports:{onBeforeMount(t,n){e=this,e.state.cimModel=cimModel(),e.state.diagramsToLoad=2,e.state.dispatcher={},observable(e.state.dispatcher),e.state.cimModel.on("setMode",(function(e){document.getElementById("cim-mode").textContent="NODE_BREAKER"===e?"Mode: Operational":"Mode: Planning"}))},onMounted(){const t=new bootstrap.Modal(document.getElementById("cimModeModal")),n=new bootstrap.Modal(document.getElementById("loadingModal")),r=new bootstrap.Modal(document.getElementById("loadingFileModal")),i=new bootstrap.Modal(document.getElementById("boundaryModal")),o=new bootstrap.Modal(document.getElementById("newDiagramModal"));let a={},s=!1,l=window.location.pathname.substring(1);function c(t){u();const n=document.getElementById("cim-diagrams"),r=document.createElement("option");r.setAttribute("value","#"+t+"/createNew"),r.textContent="Generate a new diagram",n.appendChild(r);const i=e.state.cimModel.getDiagramList();for(let e in i){const r=document.createElement("option");r.setAttribute("value","#"+t+"/diagrams/"+i[e]),r.setAttribute("id",i[e]),r.textContent=i[e],n.appendChild(r)}0===i.length&&route.router.push(t+"/createNew")}function u(){const e=document.getElementById("cim-diagrams");for(;null!==e.firstChild;)e.removeChild(e.lastChild);const t=document.createElement("option");t.setAttribute("disabled","disabled"),t.setAttribute("selected","selected"),t.textContent="Select a diagram",e.appendChild(t)}-1===l.indexOf("index.html")&&(l+="index.html"),route.setBase(l+"#"),route.router.push(window.location.hash.replace("#","")),route.initDomListeners(),e.state.dispatcher.on("loaded",(function(){e.state.diagramsToLoad=e.state.diagramsToLoad-1,0===e.state.diagramsToLoad&&(n.hide(),document.getElementById("loadingDiagramMsg").textContent="loading diagram...",e.state.diagramsToLoad=2)})),document.getElementById("operational").addEventListener("change",(function(){e.state.cimModel.setMode("NODE_BREAKER")})),document.getElementById("planning").addEventListener("change",(function(){e.state.cimModel.setMode("BUS_BRANCH")})),document.getElementById("cim-create-new-container").addEventListener("click",(function(){a={name:"new1"},s=!0,t.show()})),document.getElementById("cim-file-modal-error").addEventListener("click",(function(){r.hide(),route.router.push("")})),document.getElementById("cim-boundary-modal-error").addEventListener("click",(function(){i.hide(),document.getElementById("boundaryMsg").textContent="loading boundary file..."})),document.getElementById("cim-create-new-modal").addEventListener("click",(function(){route.router.push(a.name+"/diagrams")})),document.getElementById("load-boundary").addEventListener("click",(function(){return document.getElementById("upload-boundary").click(),!1})),document.getElementById("upload-boundary").addEventListener("change",(function(){const t=this.files[0];function n(){e.state.cimModel.loadBoundary(t).then((function(e){const t=document.createElement("br");document.getElementById("boundaryMsg").append(t,"OK. "+e),document.getElementById("cim-boundary-modal-error-container").style.display=null})).catch((function(e){const t=document.createElement("br");document.getElementById("boundaryMsg").append(t,e),document.getElementById("cim-boundary-modal-error-container").style.display=null}))}document.getElementById("boundaryModal").removeEventListener("shown.bs.modal",n),document.getElementById("boundaryModal").addEventListener("shown.bs.modal",n),i.show()})),document.getElementById("cim-save").addEventListener("click",(function(t){const n=e.state.cimModel.save(),r=new Blob([n],{type:"text/xml"}),i=URL.createObjectURL(r);t.currentTarget.setAttribute("href",i)})),document.getElementById("cgmes-save").addEventListener("click",(function(t){e.state.cimModel.saveAsCGMES().then((function(e){const t=URL.createObjectURL(e);document.getElementById("cgmes-download").setAttribute("href",t),document.getElementById("cgmes-download").click()})).catch((function(e){console.log(e)}))})),document.getElementById("cim-export").addEventListener("click",(function(t){const n=e.state.cimModel.export(),r=new Blob([n],{type:"text/xml"}),i=URL.createObjectURL(r);t.currentTarget.setAttribute("href",i)})),document.getElementById("matpower-export").addEventListener("click",(function(t){const n=exportToMatpower(e.state.cimModel),r=new Blob([n],{type:"text/plain"}),i=URL.createObjectURL(r);t.currentTarget.setAttribute("href",i)})),document.getElementById("newDiagramBtn").addEventListener("click",(function(e){const t=document.getElementById("newDiagramName").value,n=window.location.hash.substring(1).split("/")[0]+"/diagrams/"+t;o.hide(),route.router.push(n)})),document.getElementById("loadingFileModal").addEventListener("shown.bs.modal",(function(t){if(void 0===a.name)return r.hide(),void route.router.push("");{document.getElementById("cim-filename").innerHTML="["+a.name+"]  ";let t=null;t=!1===s?e.state.cimModel.load(a):e.state.cimModel.newFile(a.name),t.then((function(){c(a.name),r.hide(),"new1"!==a.name&&function(){const t=e.state.cimModel.getObjects(["cim:ConnectivityNode","cim:TopologicalNode"]);let n=t["cim:ConnectivityNode"];const r=t["cim:TopologicalNode"];n=n.filter((function(t){return!1===e.state.cimModel.isBoundary(t)})),n.length>0||0===r.length?e.state.cimModel.setMode("NODE_BREAKER"):e.state.cimModel.setMode("BUS_BRANCH")}()})).catch((function(e){const t=document.createElement("br");document.getElementById("loadingFileMsg").append(t,e),document.getElementById("cim-file-modal-error-container").style.display=null}))}})),route.route("").on.value((function(e){document.getElementById("cim-local-file-component").style.display=null,document.getElementById("app-container").style.display="none",document.getElementById("cim-load-container").style.display="none",document.getElementById("cim-home-container").style.display="none",document.getElementById("cim-diagrams").style.display="none",document.getElementById("cim-mode").style.display="none",document.getElementById("cim-file-modal-error-container").style.display="none",document.getElementById("cim-boundary-modal-error-container").style.display="none",u(),document.getElementById("cim-filename").textContent="";document.getElementById("cim-file-input").addEventListener("change",(function(){a=this.files[0],s=!1;const e="#"+encodeURI(a.name)+"/diagrams";document.getElementById("cim-load").setAttribute("href",e),document.getElementById("cim-load-container").style.display=null}))})),route.route(":file/diagrams").on.value((function(n){document.getElementById("cim-home-container").style.display=null,document.getElementById("cim-diagrams").style.display=null,document.getElementById("cim-mode").style.display=null,document.getElementById("cim-local-file-component").style.display="none",document.getElementById("app-container").style.display="none",document.getElementById("cim-export").parentNode.classList.add("disabled"),t.hide();const i=document.getElementById("cim-filename").textContent;a.name!==i?(document.getElementById("loadingFileMsg").textContent="loading CIM network...",r.show(),e.state.dispatcher.trigger("diagrams")):c(a.name)})),route.route(":file/diagrams/:name").on.value((function(t){const r=t.params.file,i=t.params.name;if(void 0!==a.name){if(e.state.cimModel.activeDiagramName===decodeURI(i))return e.state.dispatcher.trigger("showDiagram",r,i),void(document.getElementById("app-container").style.display=null);document.getElementById("cim-local-file-component").style.display="none",document.getElementById("loadingDiagramMsg").textContent="loading diagram...",document.getElementById("loadingModal").addEventListener("shown.bs.modal",(function t(n){!function(t,n,r){e.state.cimModel.selectDiagram(decodeURI(n)),c(decodeURI(t)),document.getElementById(decodeURI(n)).setAttribute("selected",!0),document.getElementById("app-container").style.display=null,document.getElementById("cim-export").parentNode.classList.remove("disabled"),e.state.dispatcher.trigger("showDiagram",t,n,r)}(r,i),document.getElementById("loadingModal").removeEventListener("shown.bs.modal",t)})),n.show()}else route.router.push("")})),route.route(":file/diagrams/:name/:element").on.value((function(t){const n=t.params.file,r=t.params.name,i=t.params.element;document.getElementById("cim-local-file-component").style.display="none",e.state.dispatcher.trigger("showDiagram",n,r,i)})),route.route(":file/createNew").on.value((function(e){window.history.back(),o.show()}))}},template:function(e,t,n,r){return e('


',[{type:n.TAG,getComponent:r,evaluate:function(e){return"cimtopologyprocessor"},slots:[],attributes:[{type:t.ATTRIBUTE,name:"model",evaluate:function(e){return e.state.cimModel}},{type:t.ATTRIBUTE,name:"dispatcher",evaluate:function(e){return e.state.dispatcher}}],redundantAttribute:"expr17",selector:"[expr17]"},{type:n.TAG,getComponent:r,evaluate:function(e){return"cimtree"},slots:[],attributes:[{type:t.ATTRIBUTE,name:"model",evaluate:function(e){return e.state.cimModel}},{type:t.ATTRIBUTE,name:"dispatcher",evaluate:function(e){return e.state.dispatcher}}],redundantAttribute:"expr18",selector:"[expr18]"},{type:n.TAG,getComponent:r,evaluate:function(e){return"cimdiagram"},slots:[],attributes:[{type:t.ATTRIBUTE,name:"model",evaluate:function(e){return e.state.cimModel}},{type:t.ATTRIBUTE,name:"dispatcher",evaluate:function(e){return e.state.dispatcher}}],redundantAttribute:"expr19",selector:"[expr19]"}])},name:"cimdraw"}})),function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e=e||self).cimTopologyProcessor=t()}(this,(function(){"use strict";let e=null;return{css:'cimtopologyprocessor #cim-topology-processor,[is="cimtopologyprocessor"] #cim-topology-processor{ display: none }',exports:{onBeforeMount(t,n){e=this,t.dispatcher.on("diagrams",(function(){document.querySelector("#cim-topology-processor").style.display="flex"}))},run(t){const n=document.querySelector("#tpMsg"),r=document.getElementById("tpStatusModal"),i=new bootstrap.Modal(r);n.textContent="Loading...",i.show(),r.addEventListener("shown.bs.modal",(function(t){let r=topologyProcessor(e.props.model).calcTopology();n.textContent="Done ("+r.length+" nodes calculated)."}))}},template:function(e,t,n,r){return e('',[{redundantAttribute:"expr1",selector:"[expr1]",expressions:[{type:t.EVENT,name:"onclick",evaluate:function(e){return e.run}}]}])},name:"cimtopologyprocessor"}})),function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e=e||self).cimTree=t()}(this,(function(){"use strict";let e=null,t=d3.contextMenu([{title:"Delete",action:function(t,n){e.props.model.deleteObject(n)}}]),n=null;return{css:'cimtree .tree,[is="cimtree"] .tree{ display: flex; flex-flow: column; max-height: 800px; min-width: 500px; resize: horizontal; padding-top: 10px; overflow: auto; } cimtree .tab-content,[is="cimtree"] .tab-content{ overflow: scroll; } cimtree .cim-tree-attribute-name,[is="cimtree"] .cim-tree-attribute-name{ text-align: left; min-width: 200px; } cimtree .cim-tree-attribute-uom,[is="cimtree"] .cim-tree-attribute-uom{ width: 70px; } cimtree .cim-tree-btn-group,[is="cimtree"] .cim-tree-btn-group{ flex-grow: 1; } cimtree .cim-tree-dropdown-toggle,[is="cimtree"] .cim-tree-dropdown-toggle{ flex-grow: 1; } cimtree ul,[is="cimtree"] ul{ list-style-type: none; } cimtree #tree-link-dialog,[is="cimtree"] #tree-link-dialog{ max-width: 18rem; align-self: center; min-width: 90%; min-height: min-content; } cimtree #tree-link-dialog > .card-body,[is="cimtree"] #tree-link-dialog > .card-body{ text-align: center; } cimtree #tree-controls,[is="cimtree"] #tree-controls{ padding-bottom: 10px; align-self: center; flex-shrink: 0; width: 370px; } cimtree #cim-search-form,[is="cimtree"] #cim-search-form{ align-self: center; max-width: 600px; padding-right: 20px; padding-left: 20px; padding-bottom: 20px; } cimtree .list-group-item > div,[is="cimtree"] .list-group-item > div{ width: 100%; } cimtree .cim-tree-btn-group > .cimLinkBtn,[is="cimtree"] .cim-tree-btn-group > .cimLinkBtn{ flex-grow: 1; } cimtree .tree > .nav-tabs,[is="cimtree"] .tree > .nav-tabs{ flex-shrink: 0; } cimtree .cim-expand-object,[is="cimtree"] .cim-expand-object{ border: transparent; } cimtree .cim-expand-object:focus,[is="cimtree"] .cim-expand-object:focus{ box-shadow: initial; } cimtree .cim-expand-object:hover,[is="cimtree"] .cim-expand-object:hover{ color: #6c757d; background-color: transparent; } cimtree li.attribute > .input-group,[is="cimtree"] li.attribute > .input-group{ flex-wrap: nowrap }',exports:{onBeforeMount(t,n){e=this,e.state.mode="default",t.dispatcher.on("showDiagram",(function(t,n,r){decodeURI(n)!==e.state.diagramName&&(d3.drag().on("drag.end",null),e.render(n)),void 0!==r?e.moveTo(r):d3.select(".tree").selectAll(".btn-danger").classed("btn-danger",!1).classed("btn-primary",!0)}))},onMounted(){[].slice.call(document.querySelectorAll("#cim-tree-tabs a")).forEach((function(e){const t=new bootstrap.Tab(e);e.addEventListener("click",(function(e){e.preventDefault(),t.show()}))})),document.getElementById("cim-search-key").addEventListener("keyup",(function(t){if("Enter"===t.key){let t=document.getElementById("cim-search-case").classList.contains("active"),r=document.getElementById("cim-search-key").value;if(""===r)document.getElementById("cim-search-results").classList.add("d-none"),n=null;else{let i=[];document.getElementById("app-tree").querySelectorAll("ul:not(.CIM-object-list)").forEach((function(e){let n=null;n=!0===t?Array.prototype.filter.call(e.querySelectorAll("li.CIM-object>button.cim-object-btn"),(function(e){return e.textContent.indexOf(r)>=0})):Array.prototype.filter.call(e.querySelectorAll("li.CIM-object>button.cim-object-btn"),(function(e){let t=r.toLocaleLowerCase();return e.textContent.toLocaleLowerCase().indexOf(t)>=0})),i=i.concat(n)})),i=[...new Set(i)],document.getElementById("cim-search-results").classList.remove("d-none"),i.length>0?(document.querySelector("#cim-search-results").textContent="Result 1 of "+i.length,n={elements:d3.selectAll(i).data(),actualResult:0},e.moveTo(e.props.model.ID(n.elements[n.actualResult]))):document.querySelector("#cim-search-results").textContent="Text not found"}}})),document.getElementById("cim-search-next").addEventListener("click",(function(){if(null!==n&&n.actualResult0){n.actualResult=n.actualResult-1;let t=n.actualResult+1;document.querySelector("#cim-search-results").textContent="Result "+t+" of "+n.elements.length,e.moveTo(e.props.model.ID(n.elements[n.actualResult]))}})),document.getElementById("showAllObjects").addEventListener("change",(function(){e.createTree(this.checked)})),document.getElementById("sshInput").addEventListener("change",(function(){e.resetAttrs()})),document.querySelectorAll('a[data-bs-toggle="tab"]').forEach((t=>t.addEventListener("click",(function(t){e.goToBasePath()})))),e.props.model.on("addToActiveDiagram",(function(t){e.addNewObject(t)})),e.props.model.on("deleteObject",(function(t,n){e.deleteObject(t)})),e.props.model.on("deleteFromDiagram",(function(t){!1===document.getElementById("showAllObjects").checked&&e.deleteObject(t)})),e.props.model.on("setAttribute",(function(t,n,r){if("cim:IdentifiedObject.name"===n){t.localName;let n=d3.select("div.tree").selectAll("ul#"+e.props.model.ID(t));if(!1===n.empty()){d3.select(n.node().parentNode).select("button").html(r)}document.querySelectorAll('[cim-target="'+e.props.model.ID(t)+'"]').innerHTML=r}})),e.props.model.on("addLink",(function(t,n,r){let i=e.props.model.ID(t),o=d3.select(".tree").select("#"+i),a=o.selectAll("#cimRemoveBtn").filter((function(e){return e.attributes[0].value==="#"+n.split(":")[1]}));o.selectAll(".cimLinkBtn").filter((function(e){return e.attributes[0].value==="#"+n.split(":")[1]})).html((function(){return e.props.model.getAttribute(r,"cim:IdentifiedObject.name").textContent})).attr("cim-target",(function(){return e.props.model.ID(r)})).attr("disabled",null),o.selectAll("#cimTarget").attr("id",null),a.attr("disabled",null),"BUS_BRANCH"===e.props.model.getMode()&&"cim:BusbarSection"===t.nodeName&&"cim:ConductingEquipment.BaseVoltage"===n&&e.props.model.setLink(e.props.model.getNode(t),"cim:TopologicalNode.BaseVoltage",r)})),e.props.model.on("removeLink",(function(t,n,r){let i=e.props.model.ID(t),o=d3.select(".tree").select("#"+i),a=o.selectAll("#cimRemoveBtn").filter((function(e){return e.attributes[0].value==="#"+n.split(":")[1]})),s=o.selectAll(".cimLinkBtn").filter((function(e){return e.attributes[0].value==="#"+n.split(":")[1]}));a.attr("disabled","disabled"),s.html("none").attr("cim-target","none").attr("disabled","disabled")})),e.props.model.on("createdDiagram",(function(){e.state.diagramName=decodeURI(e.props.model.activeDiagramName),document.getElementById("showAllObjects").checked=!1,document.getElementById("showAllObjects").dispatchEvent(new MouseEvent("click"))})),e.props.model.on("setMode",(function(t){"BUS_BRANCH"===e.state.mode&&(document.getElementById("measurementsTab").style.display=null)}))},goToBasePath(){let e=window.location.hash.substring(1).split("/");if(e.length>3){let t=e[0]+"/"+e[1]+"/"+e[2];route.router.push(t)}},addNewObject(t){let n=d3.select("div.tree > div.tab-content > div.tab-pane > ul#CIMComponents"),r=d3.select("div.tree > div.tab-content > div.tab-pane > ul#CIMContainers"),i=d3.select("div.tree > div.tab-content > div.tab-pane > ul#CIMMeasurements"),o=d3.select("div.tree > div.tab-content > div.tab-pane > ul#CIMBases"),a=d3.select("div.tree > div.tab-content > div.tab-pane > ul#CIMCurvesAndRegs"),s=d3.select("div.tree > div.tab-content > div.tab-pane > ul#CIMLimits"),l=void 0,c=void 0,u=void 0,f=void 0,d=void 0;switch(t.nodeName){case"cim:ACLineSegment":e.elements(n,"ACLineSegment","AC Line Segments",[t]);break;case"cim:Breaker":e.elements(n,"Breaker","Breakers",[t]);break;case"cim:Disconnector":e.elements(n,"Disconnector","Disconnectors",[t]);break;case"cim:LoadBreakSwitch":e.elements(n,"LoadBreakSwitch","Load Break Switches",[t]);break;case"cim:Junction":e.elements(n,"Junction","Junctions",[t]);break;case"cim:EnergySource":l=e.createTopContainer(n,"Equivalent","Equivalents",[t]),e.elements(l,"EnergySource","Energy Sources",[t]);break;case"cim:SynchronousMachine":c=e.createTopContainer(n,"RotatingMachine","RotatingMachines",[t]),e.elements(c,"SynchronousMachine","Synchronous Machines",[t]);break;case"cim:AsynchronousMachine":c=e.createTopContainer(n,"RotatingMachine","RotatingMachines",[t]),e.elements(c,"AsynchronousMachine","Asynchronous Machines",[t]);break;case"cim:EnergyConsumer":u=e.createTopContainer(n,"Load","Loads",[t]),e.elements(u,"EnergyConsumer","Energy Consumers",[t]);break;case"cim:ConformLoad":u=e.createTopContainer(n,"Load","Loads",[t]),e.elements(u,"ConformLoad","Conform Loads",[t]);break;case"cim:NonConformLoad":u=e.createTopContainer(n,"Load","Loads",[t]),e.elements(u,"NonConformLoad","Non Conform Loads",[t]);break;case"cim:LinearShuntCompensator":f=e.createTopContainer(n,"Compensator","Compensators",[t]),e.elements(f,"LinearShuntCompensator","Linear",[t]);break;case"cim:NonlinearShuntCompensator":f=e.createTopContainer(n,"Compensator","Compensators",[t]),e.nlCompensators(f,[t]);break;case"cim:NonlinearShuntCompensatorPoint":let h=e.props.model.getTargets([t],"NonlinearShuntCompensatorPoint.NonlinearShuntCompensator"),p=e.props.model.ID(h[0]),m=n.selectAll("ul#"+p);e.nlCompensatorPoints(m,[t]);break;case"cim:PowerTransformer":e.powerTransformers(n,[t]);break;case"cim:RatioTapChanger":let g=e.props.model.getTargets([t],"RatioTapChanger.TransformerEnd"),b=e.props.model.ID(g[0]),v=n.selectAll("ul#"+b);e.tapChangers(v,[t]);break;case"cim:BusbarSection":e.elements(n,"BusbarSection","Nodes",[t]);break;case"cim:BaseVoltage":let y=e.elements(o,"BaseVoltage","Base Voltages",[t]);e.createDeleteMenu(y);break;case"cim:GeographicalRegion":e.geoRegions(r,[t]);break;case"cim:SubGeographicalRegion":let _=e.props.model.getTargets([t],"SubGeographicalRegion.Region"),w=e.props.model.ID(_[0]),x=r.selectAll("ul#"+w);e.subGeoRegions(x,[t]);break;case"cim:Substation":e.substations(r,[t]);break;case"cim:VoltageLevel":let T=e.props.model.getTargets([t],"VoltageLevel.Substation"),A=e.props.model.ID(T[0]),E=r.selectAll("ul#"+A);e.voltageLevels(E,[t]);break;case"cim:Bay":let k=e.props.model.getTargets([t],"Bay.VoltageLevel"),S=e.props.model.ID(k[0]),M=r.selectAll("ul#"+S);e.bays(M,[t]);break;case"cim:Line":let C=e.elements(r,"Line","Lines",[t]);e.createDeleteMenu(C);break;case"cim:GeneratingUnit":d=e.createTopContainer(r,"GeneralGeneratingUnit","Generating Units",[t]),e.elements(d,"GeneratingUnit","General Units",[t]);break;case"cim:ThermalGeneratingUnit":d=e.createTopContainer(r,"GeneralGeneratingUnit","Generating Units",[t]),e.elements(d,"ThermalGeneratingUnit","Thermal Units",[t]);break;case"cim:Analog":let N=e.elements(i,"Analog","Analogs",[t]);e.createDeleteMenu(N);break;case"cim:Discrete":let D=e.elements(i,"Discrete","Discretes",[t]);e.createDeleteMenu(D);break;case"cim:LoadResponseCharacteristic":let L=e.elements(a,"LoadResponseCharacteristic","Load Response Characteristics",[t]);e.createDeleteMenu(L);break;case"cim:TapChangerControl":let O=e.elements(a,"TapChangerControl","Tap Changer Controls",[t]);e.createDeleteMenu(O);break;case"cim:RegulatingControl":let I=e.elements(a,"RegulatingControl","Regulating Controls",[t]);e.createDeleteMenu(I);break;case"cim:OperationalLimitType":let B=e.elements(s,"OperationalLimitType","Operational Limit Types",[t]);e.createDeleteMenu(B);case"cim:OperationalLimitSet":e.limitSets(s,[t]);break;case"cim:VoltageLimit":case"cim:CurrentLimit":case"cim:ActivePowerLimit":case"cim:ApparentPowerLimit":let P=e.props.model.getTargets([t],"OperationalLimit.OperationalLimitSet"),j=e.props.model.ID(P[0]),R=s.selectAll("ul#"+j);e.limits(R,[t])}},createTree(t){let n=function*(t){d3.select("#app-tree").selectAll("#CIMComponents > li").remove(),d3.select("#app-tree").selectAll("#CIMContainers > li").remove(),d3.select("#app-tree").selectAll("#CIMMeasurements > li").remove(),d3.select("#app-tree").selectAll("#CIMBases > li").remove(),d3.select("#app-tree").selectAll("#CIMCurvesAndRegs > li").remove(),d3.select("#app-tree").selectAll("#CIMLimits > li").remove();let n=d3.select("div.tree > div.tab-content > div.tab-pane > ul#CIMComponents"),r=d3.select("div.tree > div.tab-content > div.tab-pane > ul#CIMContainers"),i=d3.select("div.tree > div.tab-content > div.tab-pane > ul#CIMMeasurements"),o=d3.select("div.tree > div.tab-content > div.tab-pane > ul#CIMBases"),a=d3.select("div.tree > div.tab-content > div.tab-pane > ul#CIMCurvesAndRegs"),s=d3.select("div.tree > div.tab-content > div.tab-pane > ul#CIMLimits"),l=["cim:Substation","cim:Line"],c=["cim:Analog","cim:Discrete"],u=["cim:GeneratingUnit","cim:ThermalGeneratingUnit"],f=null,d=null,h=null,p=null,m=null,g=null,b=null,v=e.props.model.getObjects,y=e.props.model.getObjects;!1===t&&(v=e.props.model.getGraphicObjects,y=e.props.model.getConnectors);if("BUS_BRANCH"===e.props.model.getMode()){let t=e.props.model.getObjects(["cim:BusbarSection","cim:TopologicalNode"]);0===t["cim:BusbarSection"].length&&t["cim:TopologicalNode"].forEach((function(t){let n=e.props.model.createObject("cim:BusbarSection",{node:t}),r=e.props.model.getAttribute(t,"cim:IdentifiedObject.name");void 0!==r&&e.props.model.setAttribute(n,"cim:IdentifiedObject.name",r.innerHTML)}))}let _=v(["cim:BusbarSection","cim:PowerTransformer","cim:ACLineSegment","cim:Breaker","cim:Disconnector","cim:LoadBreakSwitch","cim:Junction","cim:EnergySource","cim:EquivalentInjection","cim:SynchronousMachine","cim:AsynchronousMachine","cim:EnergyConsumer","cim:ConformLoad","cim:NonConformLoad","cim:LinearShuntCompensator","cim:NonlinearShuntCompensator"]);yield"TREE: extracted equipments",p=v(["cim:SubGeographicalRegion"])["cim:SubGeographicalRegion"],m=v(["cim:GeographicalRegion"])["cim:GeographicalRegion"],!1===t?(f=e.props.model.getLinkedObjects(l,["EquipmentContainer.Equipments","Substation.VoltageLevels/EquipmentContainer.Equipments","Substation.VoltageLevels/VoltageLevel.Bays/EquipmentContainer.Equipments"]),d=e.props.model.getLinkedObjects(c,["Measurement.PowerSystemResource"]),h=e.props.model.getLinkedObjects(u,["GeneratingUnit.RotatingMachine"]),p=p.concat(e.props.model.getTargets(f["cim:Substation"],"Substation.Region")),m=m.concat(e.props.model.getTargets(p,"SubGeographicalRegion.Region")),p=[...new Set(p)],m=[...new Set(m)],g=e.props.model.getLinkedObjects(["cim:LoadResponseCharacteristic"],["LoadResponseCharacteristic.EnergyConsumer"]),b=e.props.model.getLinkedObjects(["cim:OperationalLimitSet"],["OperationalLimitSet.Equipment","OperationalLimitSet.Terminal/Terminal.ConductingEquipment"])):(f=v(l),d=v(c),h=v(u),g=v(["cim:LoadResponseCharacteristic"]),b=v(["cim:OperationalLimitSet"]));let w=e.props.model.getObjects(["cim:BaseVoltage","cim:TapChangerControl","cim:RegulatingControl","cim:OperationalLimitType"]),x=y(["cim:BusbarSection"])["cim:BusbarSection"],T=_["cim:EnergySource"].concat(_["cim:EquivalentInjection"]),A=_["cim:SynchronousMachine"].concat(_["cim:AsynchronousMachine"]),E=_["cim:EnergyConsumer"].concat(_["cim:ConformLoad"]).concat(_["cim:NonConformLoad"]),k=_["cim:LinearShuntCompensator"].concat(_["cim:nonlinearShuntCompensator"]),S=e.elements(i,"Analog","Analogs",d["cim:Analog"]);e.createDeleteMenu(S);let M=e.elements(i,"Discrete","Discretes",d["cim:Discrete"]);e.createDeleteMenu(M);let C=e.elements(o,"BaseVoltage","Base Voltages",w["cim:BaseVoltage"]);e.createDeleteMenu(C),e.elements(n,"ACLineSegment","AC Line Segments",_["cim:ACLineSegment"]),e.elements(n,"Breaker","Breakers",_["cim:Breaker"]),e.elements(n,"Disconnector","Disconnectors",_["cim:Disconnector"]),e.elements(n,"LoadBreakSwitch","Load Break Switches",_["cim:LoadBreakSwitch"]),e.elements(n,"Junction","Junctions",_["cim:Junction"]);let N=e.createTopContainer(n,"Equivalent","Equivalents",T);e.elements(N,"EnergySource","Energy Sources",_["cim:EnergySource"]),e.elements(N,"EquivalentInjection","Equivalent Injections",_["cim:EquivalentInjection"]);let D=e.createTopContainer(n,"RotatingMachine","Rotating Machines",A);e.elements(D,"SynchronousMachine","Synchronous Machines",_["cim:SynchronousMachine"]),e.elements(D,"AsynchronousMachine","Asynchronous Machines",_["cim:AsynchronousMachine"]);let L=e.createTopContainer(n,"Load","Loads",E);e.elements(L,"EnergyConsumer","Energy Consumers",_["cim:EnergyConsumer"]),e.elements(L,"ConformLoad","Conform Loads",_["cim:ConformLoad"]),e.elements(L,"NonConformLoad","Non Conform Loads",_["cim:NonConformLoad"]);let O=e.createTopContainer(n,"Compensator","Compensators",k);e.elements(O,"LinearShuntCompensator","Linear",_["cim:LinearShuntCompensator"]),e.nlCompensators(O,_["cim:NonlinearShuntCompensator"]),e.elements(n,"BusbarSection","Nodes",x),e.powerTransformers(n,_["cim:PowerTransformer"]),e.geoRegions(r,m),e.substations(r,f["cim:Substation"]);let I=e.elements(r,"Line","Lines",f["cim:Line"]);e.createDeleteMenu(I);let B=e.createTopContainer(r,"GeneralGeneratingUnit","Generating Units",h["cim:GeneratingUnit"].concat(h["cim:ThermalGeneratingUnit"]));e.elements(B,"GeneratingUnit","General Units",h["cim:GeneratingUnit"]),e.elements(B,"ThermalGeneratingUnit","Thermal Units",h["cim:ThermalGeneratingUnit"]),e.elements(a,"LoadResponseCharacteristic","Load Response Characteristics",g["cim:LoadResponseCharacteristic"]);let P=e.elements(a,"TapChangerControl","Tap Changer Controls",w["cim:TapChangerControl"]);e.createDeleteMenu(P);let j=e.elements(a,"RegulatingControl","Regulating Controls",w["cim:RegulatingControl"]);e.createDeleteMenu(j);let R=e.elements(s,"OperationalLimitType","Operational Limit Types",w["cim:OperationalLimitType"]);e.createDeleteMenu(R),e.limitSets(s,b["cim:OperationalLimitSet"]),e.createAddButton(o,"BaseVoltage"),e.createAddButton(r,"Substation"),e.createAddButton(r,"GeographicalRegion"),e.createAddButton(r,"Line"),e.createAddButton(r,"GeneratingUnit"),e.createAddButton(r,"ThermalGeneratingUnit"),e.createAddButton(a,"LoadResponseCharacteristic"),e.createAddButton(s,"OperationalLimitType")}(t);!function t(){let r=n.next().value;void 0!==r?(document.getElementById("loadingDiagramMsg").innerHTML="
"+r,setTimeout(t,1)):e.props.dispatcher.trigger("loaded")}()},render(t){e.props.model.selectDiagram(decodeURI(t)),e.state.diagramName=decodeURI(t),document.getElementById("showAllObjects").checked=!0,document.getElementById("showAllObjects").dispatchEvent(new MouseEvent("click"))},geoRegions(t,n){let r=e.elements(t,"GeographicalRegion","Geographical Regions",n);r.each((function(t,n){let r=e.props.model.getTargets([t],"GeographicalRegion.Regions");e.subGeoRegions(d3.select(this),r),e.subAddButton(d3.select(this),"SubGeographicalRegion","cim:SubGeographicalRegion.Region")})),e.createDeleteMenu(r)},subGeoRegions(t,n){let r=t.data()[0],i=e.elements(t,e.props.model.ID(r)+"SubGeographicalRegion","Sub-Geographical Regions",n);e.createDeleteMenu(i)},substations(t,n){let r=e.elements(t,"Substation","Substations",n);r.each((function(t,n){let r=e.props.model.getTargets([t],"Substation.VoltageLevels");e.voltageLevels(d3.select(this),r),e.subAddButton(d3.select(this),"VoltageLevel","cim:VoltageLevel.Substation")})),e.createDeleteMenu(r)},voltageLevels(t,n){let r=t.data()[0],i=e.elements(t,e.props.model.ID(r)+"VoltageLevel","Voltage Levels",n);i.each((function(t,n){let r=e.props.model.getTargets([t],"VoltageLevel.Bays");e.bays(d3.select(this),r),e.subAddButton(d3.select(this),"Bay","cim:Bay.VoltageLevel")})),e.createDeleteMenu(i)},bays(t,n){let r=t.data()[0],i=e.elements(t,e.props.model.ID(r)+"Bay","Bays",n);e.createDeleteMenu(i)},powerTransformers(t,n){e.elements(t,"PowerTransformer","Transformers",n).each((function(t,n){let r=e.props.model.getTargets([t],"PowerTransformer.PowerTransformerEnd"),i=e.elements(d3.select(this),e.props.model.ID(t)+"PowerTransformerEnd","Transformer Windings",r);for(const e of i.nodes())e.parentNode.classList.add("CIM-subobject");i.each((function(t,n){let r=e.props.model.getTargets([t],"TransformerEnd.RatioTapChanger");e.tapChangers(d3.select(this),r)}))}))},nlCompensators(t,n){e.elements(t,"NonlinearShuntCompensator","Nonlinear",n).each((function(t,n){let r=e.props.model.getTargets([t],"NonlinearShuntCompensator.NonlinearShuntCompensatorPoints");e.nlCompensatorPoints(d3.select(this),r),e.subAddButton(d3.select(this),"NonlinearShuntCompensatorPoint","cim:NonlinearShuntCompensatorPoint.NonlinearShuntCompensator")}))},nlCompensatorPoints(t,n){let r=t.data()[0],i=e.elements(t,e.props.model.ID(r)+"NonlinearShuntCompensatorPoint","Points",n,!0);for(const e of i.nodes())e.parentNode.classList.add("CIM-subobject");e.createDeleteMenu(i)},tapChangers(t,n){let r=t.data()[0],i=e.elements(t,e.props.model.ID(r)+"RatioTapChanger","Ratio Tap Changer",n);for(const e of i.nodes())e.parentNode.classList.add("CIM-subobject");e.createDeleteMenu(i)},limitSets(t,n){let r=e.elements(t,"OperationalLimitSet","Operational Limit Sets",n);r.each((function(t,n){let r=e.props.model.getTargets([t],"OperationalLimitSet.OperationalLimitValue");e.limits(d3.select(this),r),e.subAddButton(d3.select(this),"VoltageLimit","cim:OperationalLimit.OperationalLimitSet"),e.subAddButton(d3.select(this),"CurrentLimit","cim:OperationalLimit.OperationalLimitSet"),e.subAddButton(d3.select(this),"ActivePowerLimit","cim:OperationalLimit.OperationalLimitSet"),e.subAddButton(d3.select(this),"ApparentPowerLimit","cim:OperationalLimit.OperationalLimitSet")})),e.createDeleteMenu(r)},limits(t,n){let r=t.data()[0],i=n.filter((t=>e.props.model.schema.isA("VoltageLimit",t))),o=n.filter((t=>e.props.model.schema.isA("CurrentLimit",t))),a=n.filter((t=>e.props.model.schema.isA("ActivePowerLimit",t))),s=n.filter((t=>e.props.model.schema.isA("ApparentPowerLimit",t))),l=e.elements(t,e.props.model.ID(r)+"VoltageLimit","Voltage limits",i),c=e.elements(t,e.props.model.ID(r)+"CurrentLimit","Current limits",o),u=e.elements(t,e.props.model.ID(r)+"ActivePowerLimit","Active power limits",a),f=e.elements(t,e.props.model.ID(r)+"ApparentPowerLimit","Apparent power limits",s);e.createDeleteMenu(l),e.createDeleteMenu(c),e.createDeleteMenu(u),e.createDeleteMenu(f)},createTopContainer(t,n,r,i){let o=t.select("li."+n+"s"),a=o.select("ul#"+n+"sList");if(o.empty()){o=t.append("li").attr("class",n+"s list-group-item d-flex justify-content-between cim-parent-container");let i=o.append("div");i.append("a").attr("class","btn btn-primary btn-sm").attr("role","button").attr("data-bs-toggle","collapse").attr("href","#"+n+"sList").html(r),o.append("h4").append("span").attr("class","badge bg-primary rounded-pill").html(0),a=i.append("ul").attr("id",n+"sList").attr("class","collapse"),o.on("click",(function(t){t.target===this&&e.goToBasePath()}))}return a},createAddButton(t,n){let r=t.select("li."+n+"s"),i=r.select("ul#"+n+"sList"),o=r.select("ul#"+n+"sList > button.cim-add-btn");!0===o.empty()&&(o=i.insert("li",":first-child").append("button").attr("class","btn btn-default btn-sm cim-add-btn").attr("type","submit"),o.html(' Add'),o.on("click.add",(function(){let t=e.props.model.createObject("cim:"+n);e.props.model.addToActiveDiagram(t,[])})))},subAddButton(t,n,r){let i=t.data()[0],o=e.props.model.ID(i)+n,a=t.select("li."+o+"s"),s=a.select("ul#"+o+"sList"),l=a.select("ul#"+o+"sList > button.cim-add-btn");!0===l.empty()&&(l=s.insert("li",":first-child").append("button").attr("class","btn btn-default btn-sm cim-add-btn").attr("type","submit"),l.html(' Add'),l.on("click.add",(function(){let t=e.props.model.createObject("cim:"+n);e.props.model.setLink(t,r,i),e.props.model.addToActiveDiagram(t,[])})))},createDeleteMenu(e){e.selectAll((function(){return this.parentNode.childNodes})).filter("button.cim-object-btn").on("contextmenu",t)},elements(t,n,r,i,o){let a=t.select("li."+n+"s"),s=a.select("ul#"+n+"sList");if(!0===a.empty()){a=t.append("li").attr("class",n+"s list-group-item d-flex justify-content-between"),a.append("div").append("a").attr("class","btn btn-primary btn-sm").attr("role","button").attr("data-bs-toggle","collapse").attr("href","#"+n+"sList").html(r),a.append("h4").append("span").attr("class","badge bg-primary rounded-pill").html(0),a.on("click",(function(t){t.target===this&&e.goToBasePath()})),s=a.select("div").append("ul").attr("id",n+"sList").attr("class","collapse")}let l=s.selectAll("li."+n).data(i,(function(t){return e.props.model.ID(t)})).enter().append("li").attr("class",n+" CIM-object").on("click",(function(t){t.target===this&&e.goToBasePath()}));l.append("a").attr("class","btn btn-outline-secondary btn-sm cim-expand-object").attr("role","button").attr("data-bs-toggle","collapse").attr("href",(function(t){return"#"+e.props.model.ID(t)})).on("click",(function(t,n){t.preventDefault();let r=d3.select(this.parentNode).select("ul");0===r.selectAll("li.attribute").size()&&e.generateAttrsAndLinks(r)})).html(''),l.append("button").attr("class","btn btn-primary btn-sm cim-object-btn").on("click",(function(t,n){let r=window.location.hash.substring(1).split("/"),i=r[0]+"/"+r[1]+"/"+r[2];window.location.hash.substring(1)!==i+"/"+e.props.model.ID(n)&&route.router.push(i+"/"+e.props.model.ID(n))})).html((function(t){let n=e.props.model.getAttribute(t,"cim:IdentifiedObject.name");return void 0!==n?n.innerHTML:"unnamed"})).attr("draggable","true").on("dragstart",(function(t,n){t.dataTransfer.setData("text/plain",e.props.model.ID(n))}));let c=l.append("ul").attr("id",(function(t){return e.props.model.ID(t)})).attr("class","collapse CIM-object-list"),u=parseInt(a.select(":scope > h4 > span").html());if(u+=c.size(),a.select(":scope > h4 > span").html(u),void 0===o||!1===o){let e=a.node().closest("li.cim-parent-container");for(;null!==e;){let t=e.querySelector(":scope>h4>span"),n=parseInt(t.innerHTML);n+=c.size(),t.innerHTML=n,e=e.parentNode.closest("li.cim-parent-container")}}return c},generateAttrsAndLinks(t){let n=a(!1===document.getElementById("sshInput").checked,"EQ");e.generateAttributes(n);let r=a(!0===document.getElementById("sshInput").checked,"SSH");e.generateAttributes(r);let i=s(!1===document.getElementById("sshInput").checked,"EQ");e.generateLinks(i);let o=s(!0===document.getElementById("sshInput").checked,"SSH");function a(n,r){return t.selectAll("li.attribute."+r).data((function(n){let i=e.props.model.schema.getSchemaAttributes(n.localName,r),o=t.selectAll("li.attribute > div > span.cim-tree-attribute-name").nodes().map((e=>e.textContent));return i=i.filter((function(e){let t=e.attributes[0].value.substring(1).split(".")[1];return o.indexOf(t)<0})),i.filter((e=>"#IdentifiedObject.mRID"!==e.attributes[0].value))})).enter().append("li").attr("class",l(n,r)).attr("title",(function(e){let t=e.attributes.getNamedItem("rdf:about").value.split(".")[1],n=[].filter.call(e.children,(function(e){return"rdfs:comment"===e.nodeName}));return n.length>0?t+" - "+n[0].textContent:t})).append("div").attr("class","input-group")}function s(n,r){return t.selectAll("li.link."+r).data((function(t){let n=["#NonlinearShuntCompensatorPoint.NonlinearShuntCompensator","#TransformerEnd.Terminal","#PowerTransformerEnd.PowerTransformer","#RatioTapChanger.TransformerEnd","#RegulatingControl.Terminal","#Measurement.Terminal","#Measurement.PowerSystemResource","#Discrete.ValueAliasSet","#OperationalLimitSet.Terminal","#OperationalLimitSet.Equipment","#OperationalLimit.OperationalLimitSet","#SubGeographicalRegion.Region","#VoltageLevel.Substation","#Bay.VoltageLevel"];return e.props.model.schema.getSchemaLinks(t.localName,r).filter((t=>"Yes"===e.props.model.getAttribute(t,"cims:AssociationUsed").textContent)).filter((e=>n.indexOf(e.attributes[0].value)<0))})).enter().append("li").attr("class",l(n,r)).attr("title",(function(e){let t=e.attributes.getNamedItem("rdf:about").value.split(".")[1],n=[].filter.call(e.children,(function(e){return"rdfs:comment"===e.nodeName}));return n.length>0?t+" - "+n[0].textContent:t})).append("div").attr("class","input-group")}function l(t,n){return function(r){let i="attribute "+n;!1===r.attributes.getNamedItem("rdf:about").value.startsWith("#")&&(i+=" entsoe");let o=null;return"EQ"===n&&(o=e.props.model.schema.getSchemaStereotype(r),null!==o&&(i=i+" "+o)),("Operation"===o&&"BUS_BRANCH"===e.props.model.getMode()||!1===t)&&(i+=" d-none"),i}}e.generateLinks(o)},generateAttributes(t){t.append("span").attr("class","input-group-text cim-tree-attribute-name").html((function(e){let t=e.attributes.getNamedItem("rdf:about").value.split(".")[1];return t.length>20&&(t=t.substring(0,20)+"..."),t})),t.filter((function(t){return"#String"===e.props.model.schema.getSchemaAttributeType(t)[0]})).append("input").attr("class","form-control").each(a).attr("type","text").on("input",l),t.filter((function(t){return"#Integer"===e.props.model.schema.getSchemaAttributeType(t)[0]})).append("input").attr("class","form-control").each((function(t){let n=d3.select(this.closest("ul")).data()[0],r=e.props.model.getAttribute(n,"cim:"+t.attributes[0].value.substring(1));void 0!==r?this.value=parseInt(r.innerHTML):d3.select(this).attr("placeholder","none")})).attr("type","number").on("input",l);let n=t.filter((function(t){let n=e.props.model.schema.getSchemaAttributeType(t);return"#Float"===n[0]||"#Decimal"===n[0]}));n.append("input").attr("class","form-control").each((function(t){let n=d3.select(this.closest("ul")).data()[0],r=e.props.model.getAttribute(n,"cim:"+t.attributes[0].value.substring(1));void 0!==r?this.value=parseFloat(r.innerHTML).toFixed(5):d3.select(this).attr("placeholder","none")})).attr("type","number").attr("step","0.00001").on("input",l),n.append("span").attr("class","input-group-text cim-tree-attribute-uom").html((function(t){let n=e.props.model.schema.getSchemaAttributeType(t);return"none"===n[2]?n[1]:n[2]+n[1]}));let r=t.filter((function(t){return"#Boolean"===e.props.model.schema.getSchemaAttributeType(t)[0]}));r.append("button").attr("type","button").attr("class","btn btn-outline-secondary dropdown-toggle cim-tree-dropdown-toggle").attr("data-bs-toggle","dropdown").attr("aria-expanded","false").append("span").attr("class","boolVal").each((function(t){let n=d3.select(this.closest("li.attribute").parentNode).data()[0],r=e.props.model.getAttribute(n,"cim:"+t.attributes[0].value.substring(1));void 0!==r?d3.select(this).text(r.innerHTML):d3.select(this).text("none")}));let i=r.append("ul").attr("class","dropdown-menu dropdown-menu-end");i.append("li").append("a").attr("class","dropdown-item").text("true").on("click",s),i.append("li").append("a").attr("class","dropdown-item").text("false").on("click",s),t.filter((function(t){return"#DateTime"===e.props.model.schema.getSchemaAttributeType(t)[0]})).append("input").attr("class","form-control").each(a).attr("type","datetime-local").on("input",l);let o=t.filter((function(t){return e.props.model.schema.isEnum(t)}));function a(t){let n=d3.select(this.closest("li.attribute").parentNode).data()[0],r=e.props.model.getAttribute(n,"cim:"+t.attributes[0].value.substring(1));void 0!==r?this.value=r.innerHTML:d3.select(this).attr("placeholder","none")}function s(t,n){let r=this.textContent;this.closest("div.input-group").querySelector(":scope>button>span.boolVal").textContent=r;let i=d3.select(this.closest("li.attribute").parentNode).data()[0],o="cim:"+n.attributes[0].value.substring(1);e.props.model.setAttribute(i,o,r)}function l(t,n){let r=d3.select(this.closest("ul")).data()[0],i=n.attributes.getNamedItem("rdf:about").value,o="cim:";!1===i.startsWith("#")&&(o="entsoe:"),i=i.substring(i.indexOf("#")+1);let a=o+i;e.props.model.setAttribute(r,a,this.value)}o.append("button").attr("type","button").attr("class","btn btn-outline-secondary dropdown-toggle cim-tree-dropdown-toggle").attr("data-bs-toggle","dropdown").attr("aria-expanded","false").append("span").attr("class","enumVal").each((function(t){let n=d3.select(this.closest("li.attribute").parentNode).data()[0],r=e.props.model.getEnum(n,"cim:"+t.attributes[0].value.substring(1));void 0!==r?d3.select(this).text(r):d3.select(this).text("none")})),o.append("ul").attr("class","dropdown-menu dropdown-menu-end").selectAll("li").data((function(t){return e.props.model.schema.getSchemaEnumValues(t)})).enter().append("li").append("a").on("click",(function(t,n){this.closest("div.input-group").querySelector(":scope>button>span.enumVal").textContent=n;let r=d3.select(this.closest("li.attribute").parentNode).data()[0],i=d3.select(this.closest("li.attribute")).data()[0],o="cim:"+i.attributes[0].value.substring(1),a=e.props.model.schema.getSchemaEnumName(i)+"."+n;e.props.model.setEnum(r,o,a)})).attr("class","dropdown-item").text((function(e){return e}))},generateLinks(t){t.attr("class","input-group").append("span").attr("class","input-group-text cim-tree-attribute-name").html((function(e){let t=e.attributes.getNamedItem("rdf:about").value.split(".")[1];return t.length>20&&(t=t.substring(0,20)+"..."),t}));let n=t.append("div").attr("class","btn-group cim-tree-btn-group");n.append("button").attr("class","btn btn-outline-secondary cimLinkBtn").attr("type","submit").on("click",(function(e,t){let n="#"+d3.select(this).attr("cim-target"),r=window.location.hash.substring(1).split("/"),i=r[0]+"/"+r[1]+"/"+r[2];route.router.push(i+"/"+n.substring(1))})).attr("cim-target",(function(t){let n=d3.select(this.closest("ul")).data()[0],r=e.props.model.getTargets([n],t.attributes[0].value.substring(1))[0];return void 0===r?"none":e.props.model.ID(r)})).html((function(t){let n=e.props.model.getObject(d3.select(this).attr("cim-target"));if(void 0===n)return d3.select(this).attr("disabled","disabled"),"none";let r=e.props.model.getAttribute(n,"cim:IdentifiedObject.name");return void 0!==r?r.innerHTML:"unnamed"})),n.append("button").attr("class","btn btn-outline-secondary").attr("type","submit").on("click",(function(t,n){let r=d3.select(this.parentNode),i=e.props.model.schema.getLinkRange(n),o=d3.select(".tree").selectAll(".tab-pane > .list-group > .list-group-item > div > ul"),a=o.filter((function(t){let n=!1,r=d3.select(this).select(".CIM-object");return r.size()>0&&(n=!0===e.props.model.schema.isA(i,r.datum())),n})),s=o.filter((function(t){let n=!0,r=d3.select(this).select(".CIM-object");return r.size()>0&&(n=!1===e.props.model.schema.isA(i,r.datum())),n}));e.enterSetLinkMode(r,a,s)})).html("change"),n.append("button").attr("class","btn btn-outline-secondary").attr("type","submit").attr("id","cimRemoveBtn").on("click",(function(t,n){let r=d3.select(this.closest("ul")).data()[0],i="cim:"+n.attributes[0].value.substring(1),o=e.props.model.getObject(this.parentNode.querySelector("[cim-target]").getAttribute("cim-target"));e.props.model.removeLink(r,i,o)})).html((function(){return void 0===e.props.model.getObject(this.parentNode.querySelector("[cim-target]").getAttribute("cim-target"))&&d3.select(this).attr("disabled","disabled"),"remove"}))},setLink(t,n){let r=d3.select(t.node().closest("ul")).data()[0],i=e.props.model.ID(r);if(null!==n){let i="cim:"+t.data()[0].attributes[0].value.substring(1);e.props.model.setLink(r,i,n)}let o=window.location.hash.substring(1).split("/"),a=o[0]+"/"+o[1]+"/"+o[2];route.router.push(a+"/"+i)},enterSetLinkMode(t,n,r){e.state.mode="setLinks",document.getElementById("tree-link-dialog").classList.remove("d-none"),document.getElementById("tree-controls").classList.add("d-none"),n.each((function(n){let r=d3.select(this).selectAll(".CIM-object");r.select("button.cim-object-btn").classed("btn-primary",!1).classed("btn-outline-dark",!0),r.insert("button",":first-child").attr("class","btn btn-outline-dark btn-sm cim-check-btn").attr("type","submit").on("click",(function(){d3.select(this.firstChild).attr("class","far fa-check-square");let n=d3.select(this).datum();e.setLink(t,n),e.exitSetLinkMode()})).append("span").attr("class","far fa-square"),r.selectAll("a.cim-expand-object").classed("d-none",!0)})),r.each((function(e){this.parentNode.parentNode.classList.add("d-none"),this.parentNode.parentNode.classList.remove("d-flex")})),document.querySelectorAll(".tab-content > .tab-pane > ul").forEach((function(e){const t=e.parentNode.getAttribute("id")+"Tab";0===e.querySelectorAll(":scope > li.d-flex").length?document.getElementById(t).classList.add("d-none"):bootstrap.Tab.getInstance(document.querySelector("#"+t)).show()})),d3.select("body").on("keyup.tree",(function(n){27===n.keyCode&&(e.exitSetLinkMode(),e.setLink(t,null))})),d3.select("#tree-link-dialog-cancel").on("click",(function(){e.exitSetLinkMode(),e.setLink(t,null)}))},exitSetLinkMode(){e.state.mode="default",document.getElementById("tree-link-dialog").classList.add("d-none"),document.getElementById("tree-controls").classList.remove("d-none"),d3.select(".tree").selectAll(".tab-pane > .list-group > .list-group-item > div > ul").each((function(e){let t=d3.select(this).selectAll(".CIM-object");t.selectAll("button.cim-check-btn").remove(),t.select("button.cim-object-btn").classed("btn-primary",!0).classed("btn-outline-dark",!1),t.selectAll("a.cim-expand-object").classed("d-none",!1),this.parentNode.parentNode.classList.add("d-flex"),this.parentNode.parentNode.classList.remove("d-none")})),document.querySelectorAll(".tab-content > .tab-pane > ul").forEach((function(e){const t=e.parentNode.getAttribute("id")+"Tab";document.getElementById(t).classList.remove("d-none")})),d3.select("body").on("keyup.tree",null),d3.select("#tree-link-dialog-cancel").on("click",null)},moveTo(t){if(void 0===t)return;let n=null,r=null,i=e.props.model.getObject(t);if(void 0===i)return;if("cim:ConnectivityNode"===i.nodeName||"cim:TopologicalNode"===i.nodeName){let n=e.props.model.getBusbar(i);if(null===n)return;t=e.props.model.ID(n)}if(r=d3.select(".tree").select("#"+t).node(),null===r)return;n=r.parentNode,d3.select(".tree").selectAll(".btn-danger").classed("btn-danger",!1).classed("btn-primary",!0);const o=n.closest("div.tab-pane").getAttribute("id")+"Tab";if(document.getElementById(o).classList.contains("active"))e.scrollTo("#"+t);else{document.querySelector("#"+o).addEventListener("shown.bs.tab",(function n(r){e.scrollTo("#"+t),this.removeEventListener("shown.bs.tab",n)}))}bootstrap.Tab.getInstance(document.querySelector("#"+o)).show(),d3.select(n).select("button.cim-object-btn").classed("btn-danger",!0).classed("btn-primary",!1)},deleteObject(e){let t=d3.select("div.tree").select("ul#"+e).node();if(null!==t){let e=t.parentNode;e.closest("li.list-group-item").querySelectorAll(":scope>h4>span").forEach((function(e){let t=parseInt(e.innerHTML);t-=1,e.innerHTML=t}));let n=e.closest("li.cim-parent-container");for(;null!==n;){let e=n.querySelector(":scope>h4>span"),t=parseInt(e.innerHTML);t-=1,e.innerHTML=t,n=n.parentNode.closest("li.cim-parent-container")}e.remove()}},scrollTo(t){let n=document.querySelector(t).parentNode.closest(".collapse:not(.show)");for(null===n&&i(t);null!==n;){function r(n){n.stopPropagation();let o=d3.select(this.parentNode).filter(".CIM-object").select("ul");0===o.selectAll("li.attribute").size()&&e.generateAttrsAndLinks(o),i(t),this.removeEventListener("shown.bs.collapse",r)}n.addEventListener("shown.bs.collapse",r);let o=bootstrap.Collapse.getInstance(n);null===o&&(o=new bootstrap.Collapse(n,{toggle:!1})),o.show(),n=n.parentNode.closest(".collapse:not(.show)")}function i(e){const t=document.getElementById("tab-content"),n=t.querySelector(e),r=t.getBoundingClientRect().top+document.body.scrollTop,i=n.parentNode.getBoundingClientRect().top+document.body.scrollTop;t.scrollTop=t.scrollTop+i-r}},resetAttrs(){!0===document.getElementById("sshInput").checked?(d3.select("#app-tree").selectAll("li.attribute:not(.SSH)").classed("d-none",!0),d3.select("#app-tree").selectAll("li.link:not(.SSH)").classed("d-none",!0),d3.select("#app-tree").selectAll("li.attribute.SSH").classed("d-none",!1),d3.select("#app-tree").selectAll("li.link.SSH").classed("d-none",!1)):(d3.select("#app-tree").selectAll("li.attribute:not(.SSH)").classed("d-none",!1),d3.select("#app-tree").selectAll("li.link:not(.SSH)").classed("d-none",!1),d3.select("#app-tree").selectAll("li.attribute.SSH").classed("d-none",!0),d3.select("#app-tree").selectAll("li.link.SSH").classed("d-none",!0))}},template:function(e,t,n,r){return e('
              ',[])},name:"cimtree"}})),function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).bootstrap=t()}(this,(function(){"use strict";function e(e,t){for(var n=0;n0,r._pointerEvent=Boolean(window.PointerEvent),r._addEventListeners(),r}r(i,e);var o=i.prototype;return o.next=function(){this._isSliding||this._slide("next")},o.nextWhenVisible=function(){!document.hidden&&m(this._element)&&this.next()},o.prev=function(){this._isSliding||this._slide("prev")},o.pause=function(e){e||(this._isPaused=!0),G.findOne(".carousel-item-next, .carousel-item-prev",this._element)&&(f(this._element),this.cycle(!0)),clearInterval(this._interval),this._interval=null},o.cycle=function(e){e||(this._isPaused=!1),this._interval&&(clearInterval(this._interval),this._interval=null),this._config&&this._config.interval&&!this._isPaused&&(this._updateInterval(),this._interval=setInterval((document.visibilityState?this.nextWhenVisible:this.next).bind(this),this._config.interval))},o.to=function(e){var t=this;this._activeElement=G.findOne(".active.carousel-item",this._element);var n=this._getItemIndex(this._activeElement);if(!(e>this._items.length-1||e<0))if(this._isSliding)j.one(this._element,"slid.bs.carousel",(function(){return t.to(e)}));else{if(n===e)return this.pause(),void this.cycle();var r=e>n?"next":"prev";this._slide(r,this._items[e])}},o.dispose=function(){e.prototype.dispose.call(this),j.off(this._element,".bs.carousel"),this._items=null,this._config=null,this._interval=null,this._isPaused=null,this._isSliding=null,this._activeElement=null,this._indicatorsElement=null},o._getConfig=function(e){return e=n({},Y,e),p(W,e,Z),e},o._handleSwipe=function(){var e=Math.abs(this.touchDeltaX);if(!(e<=40)){var t=e/this.touchDeltaX;this.touchDeltaX=0,t>0&&this.prev(),t<0&&this.next()}},o._addEventListeners=function(){var e=this;this._config.keyboard&&j.on(this._element,"keydown.bs.carousel",(function(t){return e._keydown(t)})),"hover"===this._config.pause&&(j.on(this._element,"mouseenter.bs.carousel",(function(t){return e.pause(t)})),j.on(this._element,"mouseleave.bs.carousel",(function(t){return e.cycle(t)}))),this._config.touch&&this._touchSupported&&this._addTouchEventListeners()},o._addTouchEventListeners=function(){var e=this,t=function(t){e._pointerEvent&&K[t.pointerType.toUpperCase()]?e.touchStartX=t.clientX:e._pointerEvent||(e.touchStartX=t.touches[0].clientX)},n=function(t){e._pointerEvent&&K[t.pointerType.toUpperCase()]&&(e.touchDeltaX=t.clientX-e.touchStartX),e._handleSwipe(),"hover"===e._config.pause&&(e.pause(),e.touchTimeout&&clearTimeout(e.touchTimeout),e.touchTimeout=setTimeout((function(t){return e.cycle(t)}),500+e._config.interval))};G.find(".carousel-item img",this._element).forEach((function(e){j.on(e,"dragstart.bs.carousel",(function(e){return e.preventDefault()}))})),this._pointerEvent?(j.on(this._element,"pointerdown.bs.carousel",(function(e){return t(e)})),j.on(this._element,"pointerup.bs.carousel",(function(e){return n(e)})),this._element.classList.add("pointer-event")):(j.on(this._element,"touchstart.bs.carousel",(function(e){return t(e)})),j.on(this._element,"touchmove.bs.carousel",(function(t){return function(t){t.touches&&t.touches.length>1?e.touchDeltaX=0:e.touchDeltaX=t.touches[0].clientX-e.touchStartX}(t)})),j.on(this._element,"touchend.bs.carousel",(function(e){return n(e)})))},o._keydown=function(e){if(!/input|textarea/i.test(e.target.tagName))switch(e.key){case"ArrowLeft":e.preventDefault(),this.prev();break;case"ArrowRight":e.preventDefault(),this.next()}},o._getItemIndex=function(e){return this._items=e&&e.parentNode?G.find(".carousel-item",e.parentNode):[],this._items.indexOf(e)},o._getItemByDirection=function(e,t){var n="next"===e,r="prev"===e,i=this._getItemIndex(t),o=this._items.length-1;if((r&&0===i||n&&i===o)&&!this._config.wrap)return t;var a=(i+("prev"===e?-1:1))%this._items.length;return-1===a?this._items[this._items.length-1]:this._items[a]},o._triggerSlideEvent=function(e,t){var n=this._getItemIndex(e),r=this._getItemIndex(G.findOne(".active.carousel-item",this._element));return j.trigger(this._element,"slide.bs.carousel",{relatedTarget:e,direction:t,from:r,to:n})},o._setActiveIndicatorElement=function(e){if(this._indicatorsElement){for(var t=G.find(".active",this._indicatorsElement),n=0;n0)for(var r=0;r=0}function ye(e){return((fe(e)?e.ownerDocument:e.document)||window.document).documentElement}function _e(e){return"html"===ce(e)?e:e.assignedSlot||e.parentNode||e.host||ye(e)}function we(e){if(!de(e)||"fixed"===be(e).position)return null;var t=e.offsetParent;if(t){var n=ye(t);if("body"===ce(t)&&"static"===be(t).position&&"static"!==be(n).position)return n}return t}function xe(e){for(var t=ue(e),n=we(e);n&&ve(n)&&"static"===be(n).position;)n=we(n);return n&&"body"===ce(n)&&"static"===be(n).position?t:n||function(e){for(var t=_e(e);de(t)&&["html","body"].indexOf(ce(t))<0;){var n=be(t);if("none"!==n.transform||"none"!==n.perspective||n.willChange&&"auto"!==n.willChange)return t;t=t.parentNode}return null}(e)||t}function Te(e){return["top","bottom"].indexOf(e)>=0?"x":"y"}function Ae(e,t,n){return Math.max(e,Math.min(t,n))}function Ee(e){return Object.assign(Object.assign({},{top:0,right:0,bottom:0,left:0}),e)}function ke(e,t){return t.reduce((function(t,n){return t[n]=e,t}),{})}var Se={name:"arrow",enabled:!0,phase:"main",fn:function(e){var t,n=e.state,r=e.name,i=n.elements.arrow,o=n.modifiersData.popperOffsets,a=pe(n.placement),s=Te(a),l=[ie,re].indexOf(a)>=0?"height":"width";if(i&&o){var c=n.modifiersData[r+"#persistent"].padding,u=me(i),f="y"===s?te:ie,d="y"===s?ne:re,h=n.rects.reference[l]+n.rects.reference[s]-o[s]-n.rects.popper[l],p=o[s]-n.rects.reference[s],m=xe(i),g=m?"y"===s?m.clientHeight||0:m.clientWidth||0:0,b=h/2-p/2,v=c[f],y=g-u[l]-c[d],_=g/2-u[l]/2+b,w=Ae(v,_,y),x=s;n.modifiersData[r]=((t={})[x]=w,t.centerOffset=w-_,t)}},effect:function(e){var t=e.state,n=e.options,r=e.name,i=n.element,o=void 0===i?"[data-popper-arrow]":i,a=n.padding,s=void 0===a?0:a;null!=o&&("string"!=typeof o||(o=t.elements.popper.querySelector(o)))&&ge(t.elements.popper,o)&&(t.elements.arrow=o,t.modifiersData[r+"#persistent"]={padding:Ee("number"!=typeof s?s:ke(s,oe))})},requires:["popperOffsets"],requiresIfExists:["preventOverflow"]},Me={top:"auto",right:"auto",bottom:"auto",left:"auto"};function Ce(e){var t,n=e.popper,r=e.popperRect,i=e.placement,o=e.offsets,a=e.position,s=e.gpuAcceleration,l=e.adaptive,c=function(e){var t=e.x,n=e.y,r=window.devicePixelRatio||1;return{x:Math.round(t*r)/r||0,y:Math.round(n*r)/r||0}}(o),u=c.x,f=c.y,d=o.hasOwnProperty("x"),h=o.hasOwnProperty("y"),p=ie,m=te,g=window;if(l){var b=xe(n);b===ue(n)&&(b=ye(n)),i===te&&(m=ne,f-=b.clientHeight-r.height,f*=s?1:-1),i===ie&&(p=re,u-=b.clientWidth-r.width,u*=s?1:-1)}var v,y=Object.assign({position:a},l&&Me);return s?Object.assign(Object.assign({},y),{},((v={})[m]=h?"0":"",v[p]=d?"0":"",v.transform=(g.devicePixelRatio||1)<2?"translate("+u+"px, "+f+"px)":"translate3d("+u+"px, "+f+"px, 0)",v)):Object.assign(Object.assign({},y),{},((t={})[m]=h?f+"px":"",t[p]=d?u+"px":"",t.transform="",t))}var Ne={name:"computeStyles",enabled:!0,phase:"beforeWrite",fn:function(e){var t=e.state,n=e.options,r=n.gpuAcceleration,i=void 0===r||r,o=n.adaptive,a=void 0===o||o,s={placement:pe(t.placement),popper:t.elements.popper,popperRect:t.rects.popper,gpuAcceleration:i};null!=t.modifiersData.popperOffsets&&(t.styles.popper=Object.assign(Object.assign({},t.styles.popper),Ce(Object.assign(Object.assign({},s),{},{offsets:t.modifiersData.popperOffsets,position:t.options.strategy,adaptive:a})))),null!=t.modifiersData.arrow&&(t.styles.arrow=Object.assign(Object.assign({},t.styles.arrow),Ce(Object.assign(Object.assign({},s),{},{offsets:t.modifiersData.arrow,position:"absolute",adaptive:!1})))),t.attributes.popper=Object.assign(Object.assign({},t.attributes.popper),{},{"data-popper-placement":t.placement})},data:{}},De={passive:!0},Le={name:"eventListeners",enabled:!0,phase:"write",fn:function(){},effect:function(e){var t=e.state,n=e.instance,r=e.options,i=r.scroll,o=void 0===i||i,a=r.resize,s=void 0===a||a,l=ue(t.elements.popper),c=[].concat(t.scrollParents.reference,t.scrollParents.popper);return o&&c.forEach((function(e){e.addEventListener("scroll",n.update,De)})),s&&l.addEventListener("resize",n.update,De),function(){o&&c.forEach((function(e){e.removeEventListener("scroll",n.update,De)})),s&&l.removeEventListener("resize",n.update,De)}},data:{}},Oe={left:"right",right:"left",bottom:"top",top:"bottom"};function Ie(e){return e.replace(/left|right|bottom|top/g,(function(e){return Oe[e]}))}var Be={start:"end",end:"start"};function Pe(e){return e.replace(/start|end/g,(function(e){return Be[e]}))}function je(e){var t=e.getBoundingClientRect();return{width:t.width,height:t.height,top:t.top,right:t.right,bottom:t.bottom,left:t.left,x:t.left,y:t.top}}function Re(e){var t=ue(e);return{scrollLeft:t.pageXOffset,scrollTop:t.pageYOffset}}function ze(e){return je(ye(e)).left+Re(e).scrollLeft}function Fe(e){var t=be(e),n=t.overflow,r=t.overflowX,i=t.overflowY;return/auto|scroll|overlay|hidden/.test(n+i+r)}function qe(e,t){void 0===t&&(t=[]);var n=function e(t){return["html","body","#document"].indexOf(ce(t))>=0?t.ownerDocument.body:de(t)&&Fe(t)?t:e(_e(t))}(e),r="body"===ce(n),i=ue(n),o=r?[i].concat(i.visualViewport||[],Fe(n)?n:[]):n,a=t.concat(o);return r?a:a.concat(qe(_e(o)))}function Ue(e){return Object.assign(Object.assign({},e),{},{left:e.x,top:e.y,right:e.x+e.width,bottom:e.y+e.height})}function He(e,t){return"viewport"===t?Ue(function(e){var t=ue(e),n=ye(e),r=t.visualViewport,i=n.clientWidth,o=n.clientHeight,a=0,s=0;return r&&(i=r.width,o=r.height,/^((?!chrome|android).)*safari/i.test(navigator.userAgent)||(a=r.offsetLeft,s=r.offsetTop)),{width:i,height:o,x:a+ze(e),y:s}}(e)):de(t)?function(e){var t=je(e);return t.top=t.top+e.clientTop,t.left=t.left+e.clientLeft,t.bottom=t.top+e.clientHeight,t.right=t.left+e.clientWidth,t.width=e.clientWidth,t.height=e.clientHeight,t.x=t.left,t.y=t.top,t}(t):Ue(function(e){var t=ye(e),n=Re(e),r=e.ownerDocument.body,i=Math.max(t.scrollWidth,t.clientWidth,r?r.scrollWidth:0,r?r.clientWidth:0),o=Math.max(t.scrollHeight,t.clientHeight,r?r.scrollHeight:0,r?r.clientHeight:0),a=-n.scrollLeft+ze(e),s=-n.scrollTop;return"rtl"===be(r||t).direction&&(a+=Math.max(t.clientWidth,r?r.clientWidth:0)-i),{width:i,height:o,x:a,y:s}}(ye(e)))}function Ve(e){return e.split("-")[1]}function Ge(e){var t,n=e.reference,r=e.element,i=e.placement,o=i?pe(i):null,a=i?Ve(i):null,s=n.x+n.width/2-r.width/2,l=n.y+n.height/2-r.height/2;switch(o){case te:t={x:s,y:n.y-r.height};break;case ne:t={x:s,y:n.y+n.height};break;case re:t={x:n.x+n.width,y:l};break;case ie:t={x:n.x-r.width,y:l};break;default:t={x:n.x,y:n.y}}var c=o?Te(o):null;if(null!=c){var u="y"===c?"height":"width";switch(a){case"start":t[c]=Math.floor(t[c])-Math.floor(n[u]/2-r[u]/2);break;case"end":t[c]=Math.floor(t[c])+Math.ceil(n[u]/2-r[u]/2)}}return t}function We(e,t){void 0===t&&(t={});var n=t,r=n.placement,i=void 0===r?e.placement:r,o=n.boundary,a=void 0===o?"clippingParents":o,s=n.rootBoundary,l=void 0===s?"viewport":s,c=n.elementContext,u=void 0===c?"popper":c,f=n.altBoundary,d=void 0!==f&&f,h=n.padding,p=void 0===h?0:h,m=Ee("number"!=typeof p?p:ke(p,oe)),g="popper"===u?"reference":"popper",b=e.elements.reference,v=e.rects.popper,y=e.elements[d?g:u],_=function(e,t,n){var r="clippingParents"===t?function(e){var t=qe(_e(e)),n=["absolute","fixed"].indexOf(be(e).position)>=0&&de(e)?xe(e):e;return fe(n)?t.filter((function(e){return fe(e)&&ge(e,n)&&"body"!==ce(e)})):[]}(e):[].concat(t),i=[].concat(r,[n]),o=i[0],a=i.reduce((function(t,n){var r=He(e,n);return t.top=Math.max(r.top,t.top),t.right=Math.min(r.right,t.right),t.bottom=Math.min(r.bottom,t.bottom),t.left=Math.max(r.left,t.left),t}),He(e,o));return a.width=a.right-a.left,a.height=a.bottom-a.top,a.x=a.left,a.y=a.top,a}(fe(y)?y:y.contextElement||ye(e.elements.popper),a,l),w=je(b),x=Ge({reference:w,element:v,strategy:"absolute",placement:i}),T=Ue(Object.assign(Object.assign({},v),x)),A="popper"===u?T:w,E={top:_.top-A.top+m.top,bottom:A.bottom-_.bottom+m.bottom,left:_.left-A.left+m.left,right:A.right-_.right+m.right},k=e.modifiersData.offset;if("popper"===u&&k){var S=k[i];Object.keys(E).forEach((function(e){var t=[re,ne].indexOf(e)>=0?1:-1,n=[te,ne].indexOf(e)>=0?"y":"x";E[e]+=S[n]*t}))}return E}var Ye={name:"flip",enabled:!0,phase:"main",fn:function(e){var t=e.state,n=e.options,r=e.name;if(!t.modifiersData[r]._skip){for(var i=n.mainAxis,o=void 0===i||i,a=n.altAxis,s=void 0===a||a,l=n.fallbackPlacements,c=n.padding,u=n.boundary,f=n.rootBoundary,d=n.altBoundary,h=n.flipVariations,p=void 0===h||h,m=n.allowedAutoPlacements,g=t.options.placement,b=pe(g),v=l||(b!==g&&p?function(e){if("auto"===pe(e))return[];var t=Ie(e);return[Pe(e),t,Pe(t)]}(g):[Ie(g)]),y=[g].concat(v).reduce((function(e,n){return e.concat("auto"===pe(n)?function(e,t){void 0===t&&(t={});var n=t,r=n.placement,i=n.boundary,o=n.rootBoundary,a=n.padding,s=n.flipVariations,l=n.allowedAutoPlacements,c=void 0===l?se:l,u=Ve(r),f=u?s?ae:ae.filter((function(e){return Ve(e)===u})):oe,d=f.filter((function(e){return c.indexOf(e)>=0}));0===d.length&&(d=f);var h=d.reduce((function(t,n){return t[n]=We(e,{placement:n,boundary:i,rootBoundary:o,padding:a})[pe(n)],t}),{});return Object.keys(h).sort((function(e,t){return h[e]-h[t]}))}(t,{placement:n,boundary:u,rootBoundary:f,padding:c,flipVariations:p,allowedAutoPlacements:m}):n)}),[]),_=t.rects.reference,w=t.rects.popper,x=new Map,T=!0,A=y[0],E=0;E=0,N=C?"width":"height",D=We(t,{placement:k,boundary:u,rootBoundary:f,altBoundary:d,padding:c}),L=C?M?re:ie:M?ne:te;_[N]>w[N]&&(L=Ie(L));var O=Ie(L),I=[];if(o&&I.push(D[S]<=0),s&&I.push(D[L]<=0,D[O]<=0),I.every((function(e){return e}))){A=k,T=!1;break}x.set(k,I)}if(T)for(var B=function(e){var t=y.find((function(t){var n=x.get(t);if(n)return n.slice(0,e).every((function(e){return e}))}));if(t)return A=t,"break"},P=p?3:1;P>0&&"break"!==B(P);P--);t.placement!==A&&(t.modifiersData[r]._skip=!0,t.placement=A,t.reset=!0)}},requiresIfExists:["offset"],data:{_skip:!1}};function Ze(e,t,n){return void 0===n&&(n={x:0,y:0}),{top:e.top-t.height-n.y,right:e.right-t.width+n.x,bottom:e.bottom-t.height+n.y,left:e.left-t.width-n.x}}function Ke(e){return[te,re,ne,ie].some((function(t){return e[t]>=0}))}var Xe={name:"hide",enabled:!0,phase:"main",requiresIfExists:["preventOverflow"],fn:function(e){var t=e.state,n=e.name,r=t.rects.reference,i=t.rects.popper,o=t.modifiersData.preventOverflow,a=We(t,{elementContext:"reference"}),s=We(t,{altBoundary:!0}),l=Ze(a,r),c=Ze(s,i,o),u=Ke(l),f=Ke(c);t.modifiersData[n]={referenceClippingOffsets:l,popperEscapeOffsets:c,isReferenceHidden:u,hasPopperEscaped:f},t.attributes.popper=Object.assign(Object.assign({},t.attributes.popper),{},{"data-popper-reference-hidden":u,"data-popper-escaped":f})}},Qe={name:"offset",enabled:!0,phase:"main",requires:["popperOffsets"],fn:function(e){var t=e.state,n=e.options,r=e.name,i=n.offset,o=void 0===i?[0,0]:i,a=se.reduce((function(e,n){return e[n]=function(e,t,n){var r=pe(e),i=[ie,te].indexOf(r)>=0?-1:1,o="function"==typeof n?n(Object.assign(Object.assign({},t),{},{placement:e})):n,a=o[0],s=o[1];return a=a||0,s=(s||0)*i,[ie,re].indexOf(r)>=0?{x:s,y:a}:{x:a,y:s}}(n,t.rects,o),e}),{}),s=a[t.placement],l=s.x,c=s.y;null!=t.modifiersData.popperOffsets&&(t.modifiersData.popperOffsets.x+=l,t.modifiersData.popperOffsets.y+=c),t.modifiersData[r]=a}},$e={name:"popperOffsets",enabled:!0,phase:"read",fn:function(e){var t=e.state,n=e.name;t.modifiersData[n]=Ge({reference:t.rects.reference,element:t.rects.popper,strategy:"absolute",placement:t.placement})},data:{}},Je={name:"preventOverflow",enabled:!0,phase:"main",fn:function(e){var t=e.state,n=e.options,r=e.name,i=n.mainAxis,o=void 0===i||i,a=n.altAxis,s=void 0!==a&&a,l=n.boundary,c=n.rootBoundary,u=n.altBoundary,f=n.padding,d=n.tether,h=void 0===d||d,p=n.tetherOffset,m=void 0===p?0:p,g=We(t,{boundary:l,rootBoundary:c,padding:f,altBoundary:u}),b=pe(t.placement),v=Ve(t.placement),y=!v,_=Te(b),w="x"===_?"y":"x",x=t.modifiersData.popperOffsets,T=t.rects.reference,A=t.rects.popper,E="function"==typeof m?m(Object.assign(Object.assign({},t.rects),{},{placement:t.placement})):m,k={x:0,y:0};if(x){if(o){var S="y"===_?te:ie,M="y"===_?ne:re,C="y"===_?"height":"width",N=x[_],D=x[_]+g[S],L=x[_]-g[M],O=h?-A[C]/2:0,I="start"===v?T[C]:A[C],B="start"===v?-A[C]:-T[C],P=t.elements.arrow,j=h&&P?me(P):{width:0,height:0},R=t.modifiersData["arrow#persistent"]?t.modifiersData["arrow#persistent"].padding:{top:0,right:0,bottom:0,left:0},z=R[S],F=R[M],q=Ae(0,T[C],j[C]),U=y?T[C]/2-O-q-z-E:I-q-z-E,H=y?-T[C]/2+O+q+F+E:B+q+F+E,V=t.elements.arrow&&xe(t.elements.arrow),G=V?"y"===_?V.clientTop||0:V.clientLeft||0:0,W=t.modifiersData.offset?t.modifiersData.offset[t.placement][_]:0,Y=x[_]+U-W-G,Z=x[_]+H-W,K=Ae(h?Math.min(D,Y):D,N,h?Math.max(L,Z):L);x[_]=K,k[_]=K-N}if(s){var X="x"===_?te:ie,Q="x"===_?ne:re,$=x[w],J=Ae($+g[X],$,$-g[Q]);x[w]=J,k[w]=J-$}t.modifiersData[r]=k}},requiresIfExists:["offset"]};function et(e,t,n){void 0===n&&(n=!1);var r,i,o=ye(t),a=je(e),s=de(t),l={scrollLeft:0,scrollTop:0},c={x:0,y:0};return(s||!s&&!n)&&(("body"!==ce(t)||Fe(o))&&(l=(r=t)!==ue(r)&&de(r)?{scrollLeft:(i=r).scrollLeft,scrollTop:i.scrollTop}:Re(r)),de(t)?((c=je(t)).x+=t.clientLeft,c.y+=t.clientTop):o&&(c.x=ze(o))),{x:a.left+l.scrollLeft-c.x,y:a.top+l.scrollTop-c.y,width:a.width,height:a.height}}var tt={placement:"bottom",modifiers:[],strategy:"absolute"};function nt(){for(var e=arguments.length,t=new Array(e),n=0;n0&&o--,"ArrowDown"===e.key&&odocument.documentElement.clientHeight;t||(this._element.style.overflowY="hidden"),this._element.classList.add("modal-static");var n=u(this._dialog);j.off(this._element,"transitionend"),j.one(this._element,"transitionend",(function(){e._element.classList.remove("modal-static"),t||(j.one(e._element,"transitionend",(function(){e._element.style.overflowY=""})),h(e._element,n))})),h(this._element,n),this._element.focus()}},o._adjustDialog=function(){var e=this._element.scrollHeight>document.documentElement.clientHeight;(!this._isBodyOverflowing&&e&&!_||this._isBodyOverflowing&&!e&&_)&&(this._element.style.paddingLeft=this._scrollbarWidth+"px"),(this._isBodyOverflowing&&!e&&!_||!this._isBodyOverflowing&&e&&_)&&(this._element.style.paddingRight=this._scrollbarWidth+"px")},o._resetAdjustments=function(){this._element.style.paddingLeft="",this._element.style.paddingRight=""},o._checkScrollbar=function(){var e=document.body.getBoundingClientRect();this._isBodyOverflowing=Math.round(e.left+e.right)
              ',trigger:"hover focus",title:"",delay:0,html:!1,selector:!1,placement:"top",container:!1,fallbackPlacements:null,boundary:"clippingParents",customClass:"",sanitize:!0,sanitizeFn:null,allowList:{"*":["class","dir","id","lang","role",/^aria-[\w-]*$/i],a:["target","href","title","rel"],area:[],b:[],br:[],col:[],code:[],div:[],em:[],hr:[],h1:[],h2:[],h3:[],h4:[],h5:[],h6:[],i:[],img:["src","srcset","alt","title","width","height"],li:[],ol:[],p:[],pre:[],s:[],small:[],span:[],sub:[],sup:[],strong:[],u:[],ul:[]},popperConfig:null},Lt={HIDE:"hide.bs.tooltip",HIDDEN:"hidden.bs.tooltip",SHOW:"show.bs.tooltip",SHOWN:"shown.bs.tooltip",INSERTED:"inserted.bs.tooltip",CLICK:"click.bs.tooltip",FOCUSIN:"focusin.bs.tooltip",FOCUSOUT:"focusout.bs.tooltip",MOUSEENTER:"mouseenter.bs.tooltip",MOUSELEAVE:"mouseleave.bs.tooltip"},Ot=function(e){function i(t,n){var r;if(void 0===st)throw new TypeError("Bootstrap's tooltips require Popper (https://popper.js.org)");return(r=e.call(this,t)||this)._isEnabled=!0,r._timeout=0,r._hoverState="",r._activeTrigger={},r._popper=null,r.config=r._getConfig(n),r.tip=null,r._setListeners(),r}r(i,e);var o=i.prototype;return o.enable=function(){this._isEnabled=!0},o.disable=function(){this._isEnabled=!1},o.toggleEnabled=function(){this._isEnabled=!this._isEnabled},o.toggle=function(e){if(this._isEnabled)if(e){var t=this.constructor.DATA_KEY,n=T(e.delegateTarget,t);n||(n=new this.constructor(e.delegateTarget,this._getDelegateConfig()),x(e.delegateTarget,t,n)),n._activeTrigger.click=!n._activeTrigger.click,n._isWithActiveTrigger()?n._enter(null,n):n._leave(null,n)}else{if(this.getTipElement().classList.contains("show"))return void this._leave(null,this);this._enter(null,this)}},o.dispose=function(){clearTimeout(this._timeout),j.off(this._element,this.constructor.EVENT_KEY),j.off(this._element.closest(".modal"),"hide.bs.modal",this._hideModalHandler),this.tip&&this.tip.parentNode.removeChild(this.tip),this._isEnabled=null,this._timeout=null,this._hoverState=null,this._activeTrigger=null,this._popper&&this._popper.destroy(),this._popper=null,this.config=null,this.tip=null,e.prototype.dispose.call(this)},o.show=function(){var e=this;if("none"===this._element.style.display)throw new Error("Please use show on visible elements");if(this.isWithContent()&&this._isEnabled){var t=j.trigger(this._element,this.constructor.Event.SHOW),n=function e(t){if(!document.documentElement.attachShadow)return null;if("function"==typeof t.getRootNode){var n=t.getRootNode();return n instanceof ShadowRoot?n:null}return t instanceof ShadowRoot?t:t.parentNode?e(t.parentNode):null}(this._element),r=null===n?this._element.ownerDocument.documentElement.contains(this._element):n.contains(this._element);if(t.defaultPrevented||!r)return;var i=this.getTipElement(),o=a(this.constructor.NAME);i.setAttribute("id",o),this._element.setAttribute("aria-describedby",o),this.setContent(),this.config.animation&&i.classList.add("fade");var s="function"==typeof this.config.placement?this.config.placement.call(this,i,this._element):this.config.placement,l=this._getAttachment(s);this._addAttachmentClass(l);var c=this._getContainer();x(i,this.constructor.DATA_KEY,this),this._element.ownerDocument.documentElement.contains(this.tip)||c.appendChild(i),j.trigger(this._element,this.constructor.Event.INSERTED),this._popper=at(this._element,i,this._getPopperConfig(l)),i.classList.add("show");var f,d,p="function"==typeof this.config.customClass?this.config.customClass():this.config.customClass;p&&(f=i.classList).add.apply(f,p.split(" ")),"ontouchstart"in document.documentElement&&(d=[]).concat.apply(d,document.body.children).forEach((function(e){j.on(e,"mouseover",(function(){}))}));var m=function(){var t=e._hoverState;e._hoverState=null,j.trigger(e._element,e.constructor.Event.SHOWN),"out"===t&&e._leave(null,e)};if(this.tip.classList.contains("fade")){var g=u(this.tip);j.one(this.tip,"transitionend",m),h(this.tip,g)}else m()}},o.hide=function(){var e=this;if(this._popper){var t=this.getTipElement(),n=function(){"show"!==e._hoverState&&t.parentNode&&t.parentNode.removeChild(t),e._cleanTipClass(),e._element.removeAttribute("aria-describedby"),j.trigger(e._element,e.constructor.Event.HIDDEN),e._popper&&(e._popper.destroy(),e._popper=null)};if(!j.trigger(this._element,this.constructor.Event.HIDE).defaultPrevented){var r;if(t.classList.remove("show"),"ontouchstart"in document.documentElement&&(r=[]).concat.apply(r,document.body.children).forEach((function(e){return j.off(e,"mouseover",g)})),this._activeTrigger.click=!1,this._activeTrigger.focus=!1,this._activeTrigger.hover=!1,this.tip.classList.contains("fade")){var i=u(t);j.one(t,"transitionend",n),h(t,i)}else n();this._hoverState=""}}},o.update=function(){null!==this._popper&&this._popper.update()},o.isWithContent=function(){return Boolean(this.getTitle())},o.getTipElement=function(){if(this.tip)return this.tip;var e=document.createElement("div");return e.innerHTML=this.config.template,this.tip=e.children[0],this.tip},o.setContent=function(){var e=this.getTipElement();this.setElementContent(G.findOne(".tooltip-inner",e),this.getTitle()),e.classList.remove("fade","show")},o.setElementContent=function(e,t){if(null!==e)return"object"==typeof t&&d(t)?(t.jquery&&(t=t[0]),void(this.config.html?t.parentNode!==e&&(e.innerHTML="",e.appendChild(t)):e.textContent=t.textContent)):void(this.config.html?(this.config.sanitize&&(t=Et(t,this.config.allowList,this.config.sanitizeFn)),e.innerHTML=t):e.textContent=t)},o.getTitle=function(){var e=this._element.getAttribute("data-bs-original-title");return e||(e="function"==typeof this.config.title?this.config.title.call(this._element):this.config.title),e},o.updateAttachment=function(e){return"right"===e?"end":"left"===e?"start":e},o._getPopperConfig=function(e){var t=this,r={name:"flip",options:{altBoundary:!0}};return this.config.fallbackPlacements&&(r.options.fallbackPlacements=this.config.fallbackPlacements),n({},{placement:e,modifiers:[r,{name:"preventOverflow",options:{rootBoundary:this.config.boundary}},{name:"arrow",options:{element:"."+this.constructor.NAME+"-arrow"}},{name:"onChange",enabled:!0,phase:"afterWrite",fn:function(e){return t._handlePopperPlacementChange(e)}}],onFirstUpdate:function(e){e.options.placement!==e.placement&&t._handlePopperPlacementChange(e)}},this.config.popperConfig)},o._addAttachmentClass=function(e){this.getTipElement().classList.add("bs-tooltip-"+this.updateAttachment(e))},o._getContainer=function(){return!1===this.config.container?document.body:d(this.config.container)?this.config.container:G.findOne(this.config.container)},o._getAttachment=function(e){return Nt[e.toUpperCase()]},o._setListeners=function(){var e=this;this.config.trigger.split(" ").forEach((function(t){if("click"===t)j.on(e._element,e.constructor.Event.CLICK,e.config.selector,(function(t){return e.toggle(t)}));else if("manual"!==t){var n="hover"===t?e.constructor.Event.MOUSEENTER:e.constructor.Event.FOCUSIN,r="hover"===t?e.constructor.Event.MOUSELEAVE:e.constructor.Event.FOCUSOUT;j.on(e._element,n,e.config.selector,(function(t){return e._enter(t)})),j.on(e._element,r,e.config.selector,(function(t){return e._leave(t)}))}})),this._hideModalHandler=function(){e._element&&e.hide()},j.on(this._element.closest(".modal"),"hide.bs.modal",this._hideModalHandler),this.config.selector?this.config=n({},this.config,{trigger:"manual",selector:""}):this._fixTitle()},o._fixTitle=function(){var e=this._element.getAttribute("title"),t=typeof this._element.getAttribute("data-bs-original-title");(e||"string"!==t)&&(this._element.setAttribute("data-bs-original-title",e||""),!e||this._element.getAttribute("aria-label")||this._element.textContent||this._element.setAttribute("aria-label",e),this._element.setAttribute("title",""))},o._enter=function(e,t){var n=this.constructor.DATA_KEY;(t=t||T(e.delegateTarget,n))||(t=new this.constructor(e.delegateTarget,this._getDelegateConfig()),x(e.delegateTarget,n,t)),e&&(t._activeTrigger["focusin"===e.type?"focus":"hover"]=!0),t.getTipElement().classList.contains("show")||"show"===t._hoverState?t._hoverState="show":(clearTimeout(t._timeout),t._hoverState="show",t.config.delay&&t.config.delay.show?t._timeout=setTimeout((function(){"show"===t._hoverState&&t.show()}),t.config.delay.show):t.show())},o._leave=function(e,t){var n=this.constructor.DATA_KEY;(t=t||T(e.delegateTarget,n))||(t=new this.constructor(e.delegateTarget,this._getDelegateConfig()),x(e.delegateTarget,n,t)),e&&(t._activeTrigger["focusout"===e.type?"focus":"hover"]=!1),t._isWithActiveTrigger()||(clearTimeout(t._timeout),t._hoverState="out",t.config.delay&&t.config.delay.hide?t._timeout=setTimeout((function(){"out"===t._hoverState&&t.hide()}),t.config.delay.hide):t.hide())},o._isWithActiveTrigger=function(){for(var e in this._activeTrigger)if(this._activeTrigger[e])return!0;return!1},o._getConfig=function(e){var t=V.getDataAttributes(this._element);return Object.keys(t).forEach((function(e){Mt.has(e)&&delete t[e]})),e&&"object"==typeof e.container&&e.container.jquery&&(e.container=e.container[0]),"number"==typeof(e=n({},this.constructor.Default,t,"object"==typeof e&&e?e:{})).delay&&(e.delay={show:e.delay,hide:e.delay}),"number"==typeof e.title&&(e.title=e.title.toString()),"number"==typeof e.content&&(e.content=e.content.toString()),p(kt,e,this.constructor.DefaultType),e.sanitize&&(e.template=Et(e.template,e.allowList,e.sanitizeFn)),e},o._getDelegateConfig=function(){var e={};if(this.config)for(var t in this.config)this.constructor.Default[t]!==this.config[t]&&(e[t]=this.config[t]);return e},o._cleanTipClass=function(){var e=this.getTipElement(),t=e.getAttribute("class").match(St);null!==t&&t.length>0&&t.map((function(e){return e.trim()})).forEach((function(t){return e.classList.remove(t)}))},o._handlePopperPlacementChange=function(e){var t=e.state;t&&(this.tip=t.elements.popper,this._cleanTipClass(),this._addAttachmentClass(this._getAttachment(t.placement)))},i.jQueryInterface=function(e){return this.each((function(){var t=T(this,"bs.tooltip"),n="object"==typeof e&&e;if((t||!/dispose|hide/.test(e))&&(t||(t=new i(this,n)),"string"==typeof e)){if(void 0===t[e])throw new TypeError('No method named "'+e+'"');t[e]()}}))},t(i,null,[{key:"Default",get:function(){return Dt}},{key:"NAME",get:function(){return kt}},{key:"DATA_KEY",get:function(){return"bs.tooltip"}},{key:"Event",get:function(){return Lt}},{key:"EVENT_KEY",get:function(){return".bs.tooltip"}},{key:"DefaultType",get:function(){return Ct}}]),i}(R);y((function(){var e=v();if(e){var t=e.fn[kt];e.fn[kt]=Ot.jQueryInterface,e.fn[kt].Constructor=Ot,e.fn[kt].noConflict=function(){return e.fn[kt]=t,Ot.jQueryInterface}}}));var It="popover",Bt=new RegExp("(^|\\s)bs-popover\\S+","g"),Pt=n({},Ot.Default,{placement:"right",trigger:"click",content:"",template:''}),jt=n({},Ot.DefaultType,{content:"(string|element|function)"}),Rt={HIDE:"hide.bs.popover",HIDDEN:"hidden.bs.popover",SHOW:"show.bs.popover",SHOWN:"shown.bs.popover",INSERTED:"inserted.bs.popover",CLICK:"click.bs.popover",FOCUSIN:"focusin.bs.popover",FOCUSOUT:"focusout.bs.popover",MOUSEENTER:"mouseenter.bs.popover",MOUSELEAVE:"mouseleave.bs.popover"},zt=function(e){function n(){return e.apply(this,arguments)||this}r(n,e);var i=n.prototype;return i.isWithContent=function(){return this.getTitle()||this._getContent()},i.setContent=function(){var e=this.getTipElement();this.setElementContent(G.findOne(".popover-header",e),this.getTitle());var t=this._getContent();"function"==typeof t&&(t=t.call(this._element)),this.setElementContent(G.findOne(".popover-body",e),t),e.classList.remove("fade","show")},i._addAttachmentClass=function(e){this.getTipElement().classList.add("bs-popover-"+this.updateAttachment(e))},i._getContent=function(){return this._element.getAttribute("data-bs-content")||this.config.content},i._cleanTipClass=function(){var e=this.getTipElement(),t=e.getAttribute("class").match(Bt);null!==t&&t.length>0&&t.map((function(e){return e.trim()})).forEach((function(t){return e.classList.remove(t)}))},n.jQueryInterface=function(e){return this.each((function(){var t=T(this,"bs.popover"),r="object"==typeof e?e:null;if((t||!/dispose|hide/.test(e))&&(t||(t=new n(this,r),x(this,"bs.popover",t)),"string"==typeof e)){if(void 0===t[e])throw new TypeError('No method named "'+e+'"');t[e]()}}))},t(n,null,[{key:"Default",get:function(){return Pt}},{key:"NAME",get:function(){return It}},{key:"DATA_KEY",get:function(){return"bs.popover"}},{key:"Event",get:function(){return Rt}},{key:"EVENT_KEY",get:function(){return".bs.popover"}},{key:"DefaultType",get:function(){return jt}}]),n}(Ot);y((function(){var e=v();if(e){var t=e.fn[It];e.fn[It]=zt.jQueryInterface,e.fn[It].Constructor=zt,e.fn[It].noConflict=function(){return e.fn[It]=t,zt.jQueryInterface}}}));var Ft="scrollspy",qt={offset:10,method:"auto",target:""},Ut={offset:"number",method:"string",target:"(string|element)"},Ht=function(e){function i(t,n){var r;return(r=e.call(this,t)||this)._scrollElement="BODY"===t.tagName?window:t,r._config=r._getConfig(n),r._selector=r._config.target+" .nav-link, "+r._config.target+" .list-group-item, "+r._config.target+" .dropdown-item",r._offsets=[],r._targets=[],r._activeTarget=null,r._scrollHeight=0,j.on(r._scrollElement,"scroll.bs.scrollspy",(function(e){return r._process(e)})),r.refresh(),r._process(),r}r(i,e);var o=i.prototype;return o.refresh=function(){var e=this,t=this._scrollElement===this._scrollElement.window?"offset":"position",n="auto"===this._config.method?t:this._config.method,r="position"===n?this._getScrollTop():0;this._offsets=[],this._targets=[],this._scrollHeight=this._getScrollHeight(),G.find(this._selector).map((function(e){var t=l(e),i=t?G.findOne(t):null;if(i){var o=i.getBoundingClientRect();if(o.width||o.height)return[V[n](i).top+r,t]}return null})).filter((function(e){return e})).sort((function(e,t){return e[0]-t[0]})).forEach((function(t){e._offsets.push(t[0]),e._targets.push(t[1])}))},o.dispose=function(){e.prototype.dispose.call(this),j.off(this._scrollElement,".bs.scrollspy"),this._scrollElement=null,this._config=null,this._selector=null,this._offsets=null,this._targets=null,this._activeTarget=null,this._scrollHeight=null},o._getConfig=function(e){if("string"!=typeof(e=n({},qt,"object"==typeof e&&e?e:{})).target&&d(e.target)){var t=e.target.id;t||(t=a(Ft),e.target.id=t),e.target="#"+t}return p(Ft,e,Ut),e},o._getScrollTop=function(){return this._scrollElement===window?this._scrollElement.pageYOffset:this._scrollElement.scrollTop},o._getScrollHeight=function(){return this._scrollElement.scrollHeight||Math.max(document.body.scrollHeight,document.documentElement.scrollHeight)},o._getOffsetHeight=function(){return this._scrollElement===window?window.innerHeight:this._scrollElement.getBoundingClientRect().height},o._process=function(){var e=this._getScrollTop()+this._config.offset,t=this._getScrollHeight(),n=this._config.offset+t-this._getOffsetHeight();if(this._scrollHeight!==t&&this.refresh(),e>=n){var r=this._targets[this._targets.length-1];this._activeTarget!==r&&this._activate(r)}else{if(this._activeTarget&&e0)return this._activeTarget=null,void this._clear();for(var i=this._offsets.length;i--;)this._activeTarget!==this._targets[i]&&e>=this._offsets[i]&&(void 0===this._offsets[i+1]||e li > .active":".active";t=(t=G.find(i,r))[t.length-1]}var o=null;if(t&&(o=j.trigger(t,"hide.bs.tab",{relatedTarget:this._element})),!(j.trigger(this._element,"show.bs.tab",{relatedTarget:t}).defaultPrevented||null!==o&&o.defaultPrevented)){this._activate(this._element,r);var a=function(){j.trigger(t,"hidden.bs.tab",{relatedTarget:e._element}),j.trigger(e._element,"shown.bs.tab",{relatedTarget:t})};n?this._activate(n,n.parentNode,a):a()}}},i._activate=function(e,t,n){var r=this,i=(!t||"UL"!==t.nodeName&&"OL"!==t.nodeName?G.children(t,".active"):G.find(":scope > li > .active",t))[0],o=n&&i&&i.classList.contains("fade"),a=function(){return r._transitionComplete(e,i,n)};if(i&&o){var s=u(i);i.classList.remove("show"),j.one(i,"transitionend",a),h(i,s)}else a()},i._transitionComplete=function(e,t,n){if(t){t.classList.remove("active");var r=G.findOne(":scope > .dropdown-menu .active",t.parentNode);r&&r.classList.remove("active"),"tab"===t.getAttribute("role")&&t.setAttribute("aria-selected",!1)}e.classList.add("active"),"tab"===e.getAttribute("role")&&e.setAttribute("aria-selected",!0),b(e),e.classList.contains("fade")&&e.classList.add("show"),e.parentNode&&e.parentNode.classList.contains("dropdown-menu")&&(e.closest(".dropdown")&&G.find(".dropdown-toggle").forEach((function(e){return e.classList.add("active")})),e.setAttribute("aria-expanded",!0)),n&&n()},n.jQueryInterface=function(e){return this.each((function(){var t=T(this,"bs.tab")||new n(this);if("string"==typeof e){if(void 0===t[e])throw new TypeError('No method named "'+e+'"');t[e]()}}))},t(n,null,[{key:"DATA_KEY",get:function(){return"bs.tab"}}]),n}(R);j.on(document,"click.bs.tab.data-api",'[data-bs-toggle="tab"], [data-bs-toggle="pill"], [data-bs-toggle="list"]',(function(e){e.preventDefault(),(T(this,"bs.tab")||new Vt(this)).show()})),y((function(){var e=v();if(e){var t=e.fn.tab;e.fn.tab=Vt.jQueryInterface,e.fn.tab.Constructor=Vt,e.fn.tab.noConflict=function(){return e.fn.tab=t,Vt.jQueryInterface}}}));var Gt={animation:"boolean",autohide:"boolean",delay:"number"},Wt={animation:!0,autohide:!0,delay:5e3},Yt=function(e){function i(t,n){var r;return(r=e.call(this,t)||this)._config=r._getConfig(n),r._timeout=null,r._setListeners(),r}r(i,e);var o=i.prototype;return o.show=function(){var e=this;if(!j.trigger(this._element,"show.bs.toast").defaultPrevented){this._clearTimeout(),this._config.animation&&this._element.classList.add("fade");var t=function(){e._element.classList.remove("showing"),e._element.classList.add("show"),j.trigger(e._element,"shown.bs.toast"),e._config.autohide&&(e._timeout=setTimeout((function(){e.hide()}),e._config.delay))};if(this._element.classList.remove("hide"),b(this._element),this._element.classList.add("showing"),this._config.animation){var n=u(this._element);j.one(this._element,"transitionend",t),h(this._element,n)}else t()}},o.hide=function(){var e=this;if(this._element.classList.contains("show")&&!j.trigger(this._element,"hide.bs.toast").defaultPrevented){var t=function(){e._element.classList.add("hide"),j.trigger(e._element,"hidden.bs.toast")};if(this._element.classList.remove("show"),this._config.animation){var n=u(this._element);j.one(this._element,"transitionend",t),h(this._element,n)}else t()}},o.dispose=function(){this._clearTimeout(),this._element.classList.contains("show")&&this._element.classList.remove("show"),j.off(this._element,"click.dismiss.bs.toast"),e.prototype.dispose.call(this),this._config=null},o._getConfig=function(e){return e=n({},Wt,V.getDataAttributes(this._element),"object"==typeof e&&e?e:{}),p("toast",e,this.constructor.DefaultType),e},o._setListeners=function(){var e=this;j.on(this._element,"click.dismiss.bs.toast",'[data-bs-dismiss="toast"]',(function(){return e.hide()}))},o._clearTimeout=function(){clearTimeout(this._timeout),this._timeout=null},i.jQueryInterface=function(e){return this.each((function(){var t=T(this,"bs.toast");if(t||(t=new i(this,"object"==typeof e&&e)),"string"==typeof e){if(void 0===t[e])throw new TypeError('No method named "'+e+'"');t[e](this)}}))},t(i,null,[{key:"DefaultType",get:function(){return Gt}},{key:"Default",get:function(){return Wt}},{key:"DATA_KEY",get:function(){return"bs.toast"}}]),i}(R);return y((function(){var e=v();if(e){var t=e.fn.toast;e.fn.toast=Yt.jQueryInterface,e.fn.toast.Constructor=Yt,e.fn.toast.noConflict=function(){return e.fn.toast=t,Yt.jQueryInterface}}})),{Alert:F,Button:q,Carousel:X,Collapse:ee,Dropdown:vt,Modal:wt,Popover:zt,ScrollSpy:Ht,Tab:Vt,Toast:Yt,Tooltip:Ot}}));"use strict";function cimModel(){const e="http://iec.ch/TC57/2013/CIM-schema-cim16#",t="http://entsoe.eu/CIM/SchemaExtension/3/1#",n="http://iec.ch/TC57/61970-552/ModelDescription/1#",r="http://www.w3.org/1999/02/22-rdf-syntax-ns#",i='';let o={all:null},a=new Map,s=new Map,l="NODE_BREAKER";function c(e){let t=new DOMParser,n=[],r=[],a=[],s=[],l=[],c=[],d=null,h=null;function p(e){return u(e).then((function(e){if(0===n.length||0===r.length||0===a.length||0===s.length||0===l.length||0===c.length||null===d||null===h){let t=[].filter.call(e.children[0].children,(function(e){return"md:FullModel"===e.nodeName}))[0];if(void 0===t)return Promise.reject("error: invalid CGMES file.");let i=x.getAttribute(t,"md:Model.profile");i.textContent.includes("Equipment")&&(!1===i.textContent.includes("Boundary")?n.push(e):d=e),i.textContent.includes("DiagramLayout")&&r.push(e),i.textContent.includes("StateVariables")&&a.push(e),i.textContent.includes("Topology")&&(!1===i.textContent.includes("Boundary")?s.push(e):h=e),i.textContent.includes("SteadyStateHypothesis")&&l.push(e),i.textContent.includes("GeographicalLocation")&&c.push(e)}return Promise.resolve()}))}return function(u){let m=[];return u.forEach((function(e,t){let n=t.async("blob").then(p).catch((function(e){return Promise.reject(e)}));m.push(n)})),Promise.all(m).then((function(){if(n.length>0&&!1===e){let e=t.parseFromString(i,"application/xml");for(let t of n)for(let n of t.children[0].children)"md:FullModel"!==n.nodeName&&e.children[0].appendChild(n.cloneNode(!0));for(let t of r)for(let n of t.children[0].children)"md:FullModel"!==n.nodeName&&e.children[0].appendChild(n.cloneNode(!0));for(let t of a)for(let n of t.children[0].children)"md:FullModel"!==n.nodeName&&e.children[0].appendChild(n.cloneNode(!0));for(let t of s)for(let n of t.children[0].children)"md:FullModel"!==n.nodeName&&e.children[0].appendChild(n.cloneNode(!0));for(let t of l)for(let n of t.children[0].children)"md:FullModel"!==n.nodeName&&e.children[0].appendChild(n.cloneNode(!0));for(let t of c)for(let n of t.children[0].children)"md:FullModel"!==n.nodeName&&e.children[0].appendChild(n.cloneNode(!0));if(null!==d)for(let t of d.children[0].children)"md:FullModel"!==t.nodeName&&e.children[0].appendChild(t.cloneNode(!0));if(null!==h)for(let t of h.children[0].children)"md:FullModel"!==t.nodeName&&e.children[0].appendChild(t.cloneNode(!0));return o.all=e,f()}if(null===o.all||!1===e)return Promise.reject("Invalid CGMES file: no equipment description found.");if(null!==d){let e=d.children[0].children,t=[].filter.call(e,(function(e){return"cim:ConnectivityNode"===e.nodeName})).filter((e=>x.isBoundary(e))).length;return x.updateModel(d),null!==h&&x.updateModel(h),Promise.resolve("Loaded "+t+" boundary nodes.")}return Promise.reject("Invalid boundary file: no equipment boundary file found.")})).catch((function(t){return!1===e&&x.clear(),Promise.reject(t)}))}}function u(e){const t=new FileReader;return new Promise((function(n,r){t.onerror=function(){t.abort(),r(new DOMException("problem parsing input file."))},t.onload=function(){let e=new DOMParser,i=t.result,o=e.parseFromString(i,"application/xml");o.children.length>0&&"rdf:RDF"!==o.children[0].nodeName&&r(new DOMException("invalid input file.")),n(o)},t.readAsText(e)}))}function f(){let e=d();for(let t in e){let n=e[t],r=x.ID(n);if(null!==r&&(a.set("#"+r,n),void 0!==n.attributes)){let e=x.getLinks(n);for(let t of e){let e=t.localName+t.attributes[0].value,r=s.get(e);void 0===r?s.set(e,[n]):r.push(n)}}}for(let t in e){let n=e[t],r=n.attributes.getNamedItem("rdf:about");if(null!==r){let e=a.get(r.value);if(void 0===e)continue;for(let t of x.getAttributes(n))e.appendChild(t.cloneNode(!0));for(let t of x.getLinks(n)){e.appendChild(t.cloneNode(!0));let n=t.localName+t.attributes[0].value,r=s.get(n);void 0===r?s.set(n,[e]):r.push(e)}n.remove()}}return x.schema.buildSchema()}function d(){let e=[];for(let t of Object.keys(o))void 0!==o[t]&&null!==o[t]&&(e=e.concat([...o[t].children[0].children]));return e}function h(t,n){let i=void 0;void 0!==n&&(i=n.uuid);let s=o.all,l=s.createElementNS(e,t);return s.children[0].appendChild(l),void 0!==i?l.setAttributeNS(r,"rdf:ID",i):l.setAttributeNS(r,"rdf:ID",y()),a.set("#"+x.ID(l),l),l}function p(e){let t=h("cim:Terminal");return m(t,"cim:Terminal.ConductingEquipment",e),x.setAttribute(t,"cim:ACDCTerminal.connected","true"),t}function m(t,n,i){if(x.getTargets([t],n).length>0)return;let o=t.ownerDocument.createElementNS(e,n);t.appendChild(o),o.setAttributeNS(r,"rdf:resource","#"+x.ID(i));let a=o.localName+o.attributes[0].value,l=s.get(a);void 0===l?s.set(a,[t]):l.push(t),x.trigger("addLink",t,n,i)}function g(e,t){let n=x.schema.schemaInvLinksMap.get(t),r=new Map,i=[];for(let o of e){let e=x.ID(o),l=x.getLink(o,"cim:"+t);for(let t of l){let n=a.get(t.attributes.getNamedItem("rdf:resource").value);if(void 0!==n){let t=x.ID(n);i.push({source:o,target:n}),r.set(e+t,1)}}let c=s.get(n+"#"+e);if(void 0!==c)for(let t of c){let n=x.ID(t);void 0===r.get(e+n)&&i.push({source:o,target:t})}}return i}function b(e){let t=[];if(0===arguments.length){let e=[];void 0!==x.activeDiagram&&(e=x.getTargets([x.activeDiagram],"Diagram.DiagramElements")),t=g(e,"DiagramObject.IdentifiedObject")}else if(void 0!==x.activeDiagram){let n=x.getTargets(e,"IdentifiedObject.DiagramObjects");n=g(n,"DiagramObject.Diagram").filter((e=>e.target===x.activeDiagram)).map((e=>e.source)),t=g(n,"DiagramObject.IdentifiedObject")}return t}function v(e){let t=[];if(0===arguments.length){if(void 0!==x.activeDiagram){t=g(b().map((e=>e.target)),"ConductingEquipment.Terminals")}}else if(void 0!==x.activeDiagram){t=g(b(e).map((e=>e.target)),"ConductingEquipment.Terminals")}else t=g(e,"ConductingEquipment.Terminals");return t}function y(){let e=(new Date).getTime();return"_"+"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(t){let n=(e+16*Math.random())%16|0;return e=Math.floor(e/16),("x"==t?n:3&n|8).toString(16)}))}function _(e){return[].filter.call(e.children,(function(e){let t=e.attributes.getNamedItem("rdf:resource");return 0!==e.attributes.length&&null!==t&&"#"!==t.value.charAt(0)}))}function w(e,t){return _(e).filter((e=>e.nodeName===t))[0]}let x={fileName:null,activeDiagramName:"none",schema:new cimSchema,load(e){let t=Promise.resolve();if(x.fileName!==e.name){if(x.fileName=e.name,!e.name.endsWith(".zip")){return u(e).then((function(e){return o.all=e,f()})).catch((function(e){return x.clear(),Promise.reject(e)}))}t=JSZip.loadAsync(e).then(c(!1)).catch((function(e){return x.clear(),Promise.reject(e)}))}return t},newFile(e){let t=new DOMParser;return o.all=t.parseFromString(i,"application/xml"),x.fileName=e,f()},updateModel(e){let t=e.children[0].children;for(let e of t){if("md:FullModel"===e.nodeName)continue;let t=e.attributes.getNamedItem("rdf:ID");if(null===t&&(t=e.attributes.getNamedItem("rdf:about")),null===t)continue;let n=t.value;n.startsWith("#")&&(n=n.substring(1));let r=x.getObject(n);void 0===r&&(r=x.createObject(e.nodeName,{uuid:n}))}for(let e of t){if("md:FullModel"===e.nodeName)continue;let t=e.attributes.getNamedItem("rdf:ID");if(null===t&&(t=e.attributes.getNamedItem("rdf:about")),null===t)continue;let n=t.value;n.startsWith("#")&&(n=n.substring(1));let r=x.getObject(n);if(void 0===r)continue;let i=x.getAttributes(e);for(let e of i)x.setAttribute(r,e.nodeName,e.innerHTML);let o=x.getLinks(e);for(let e of o){let t=e.attributes.getNamedItem("rdf:resource").value.substring(1);x.setLink(r,e.nodeName,x.getObject(t))}}},loadBoundary(e){let t=Promise.resolve();return t=e.name.endsWith(".zip")?JSZip.loadAsync(e).then(c(!0)).catch((function(e){return Promise.reject(e)})):Promise.reject("Error: not a boundary file."),t},loadRemote(e){let t=Promise.resolve();return x.fileName!==decodeURI(e).substring(1)&&(x.fileName=decodeURI(e).substring(1),t=d3.xml(e).then((function(e){return o.all=e,f()})).catch((function(e){return x.clear(),Promise.reject(e)}))),t},save(){if(null===o.all)throw new Error("error: no CIM file loaded.");let e="";return e=(new XMLSerializer).serializeToString(o.all),e},saveAsCGMES(){if(null===o.all)return Promise.reject("error: no CIM file loaded.");let e=new XMLSerializer,t=new JSZip,r=null,a=[];for(let e of o.all.children[0].children){x.getLinks(e).forEach((function(t){let n=x.schema.checkLink(e,t.nodeName);if(n!==t.nodeName){x.getTargets([e],t.localName).forEach((function(t){a.push({s:t,l:n,t:e})}))}}))}a.forEach((function(e){x.setLink(e.s,e.l,e.t)})),r=o.all.children[0].cloneNode(!0).children;let s=["http://entsoe.eu/CIM/EquipmentCore/3/1"];"NODE_BREAKER"===l&&s.push("http://entsoe.eu/CIM/EquipmentOperation/3/1");let c=m("EQ",s,r,[]),u=m("DL",["http://entsoe.eu/CIM/DiagramLayout/3/1"],r,[c]),f=m("SV",["http://entsoe.eu/CIM/StateVariables/4/1"],r,[c]),d=m("TP",["http://entsoe.eu/CIM/Topology/4/1"],r,[c]),h=m("SSH",["http://entsoe.eu/CIM/SteadyStateHypothesis/1/1"],r,[c]),p=m("GL",["http://entsoe.eu/CIM/GeographicalLocation/2/1"],r,[c]);return t.file("EQ.xml",e.serializeToString(c)),t.file("DL.xml",e.serializeToString(u)),t.file("SV.xml",e.serializeToString(f)),t.file("TP.xml",e.serializeToString(d)),t.file("SSH.xml",e.serializeToString(h)),t.file("GL.xml",e.serializeToString(p)),t.generateAsync({type:"blob",compression:"DEFLATE"});function m(e,t,r,o){let a=[].filter.call(r,(function(t){return null!==x.schema.getSchemaObject(t.localName,e)})),s=function(e,t){let r=(new DOMParser).parseFromString(i,"application/xml"),o=document.createElementNS(n,"md:FullModel");return r.children[0].appendChild(o),o.setAttribute("rdf:about","urn:uuid:"+y().substring(1)),e.forEach((function(e){let t=o.ownerDocument.createElementNS(n,"md:Model.profile");t.innerHTML=e,o.appendChild(t)})),t.forEach((function(e){let t=[].filter.call(e.children[0].children,(function(e){return"md:FullModel"===e.nodeName}))[0],n=o.ownerDocument.createElement("md:Model.DependentOn");n.setAttribute("rdf:resource",t.attributes.getNamedItem("rdf:about").value),o.appendChild(n)})),r}(t,o);return function(e,t,n){for(let r in t){let i=t[r].cloneNode();x.getAttributes(t[r]).forEach((function(e){void 0!==x.schema.getSchemaAttribute(i.localName,e.localName,n)&&i.appendChild(e)})),x.getLinks(t[r]).forEach((function(e){void 0!==x.schema.getSchemaLink(i.localName,e.localName,n)&&i.appendChild(e)})),_(t[r]).forEach((function(e){void 0!==x.schema.getSchemaAttribute(i.localName,e.localName,n)&&i.appendChild(e)}));let o=x.schema.isDescription(i,n),a=x.schema.isConcrete(i,n);if(!0===o&&null!==x.ID(i)){let e=x.ID(i);i.removeAttribute("rdf:ID");let t=i.ownerDocument.createAttribute("rdf:about");t.value="#"+e,i.setAttributeNode(t)}!0===a&&(!1===o||i.children.length>0)&&e.children[0].appendChild(i)}}(s,a,e),s}},export(){let e=new DOMParser,t=new XMLSerializer,n=e.parseFromString(i,"application/xml");if(void 0===x.activeDiagram)return t.serializeToString(n);n.children[0].appendChild(x.activeDiagram.cloneNode(!0));let r=x.getTargets([x.activeDiagram],"Diagram.DiagramElements");for(let e of r)n.children[0].appendChild(e.cloneNode(!0));let o=x.getTargets(r,"DiagramObject.IdentifiedObject");for(let e of o)n.children[0].appendChild(e.cloneNode(!0));let a=x.getTargets(r,"DiagramObject.DiagramObjectPoints");for(let e of a)n.children[0].appendChild(e.cloneNode(!0));let s=x.getTerminals(o);for(let e of s)n.children[0].appendChild(e.cloneNode(!0));let l=x.getNodes();for(let e of l)n.children[0].appendChild(e.cloneNode(!0));let c=x.getLinkedObjects(["cim:Substation","cim:Line"],["EquipmentContainer.Equipments"]),u=c["cim:Substation"];for(let e of u)n.children[0].appendChild(e.cloneNode(!0));let f=c["cim:Line"];for(let e of f)n.children[0].appendChild(e.cloneNode(!0));let d=x.getTargets(o,"ConductingEquipment.BaseVoltage");for(let e of d)n.children[0].appendChild(e.cloneNode(!0));let h=x.getTargets(o,"PowerTransformer.PowerTransformerEnd");for(let e of h)n.children[0].appendChild(e.cloneNode(!0));let p=x.getTargets(s,"ACDCTerminal.Measurements");for(let e of p)n.children[0].appendChild(e.cloneNode(!0));let m=x.getTargets(p,"Analog.AnalogValues");for(let e of m)n.children[0].appendChild(e.cloneNode(!0));return t.serializeToString(n)},getDiagramList:()=>x.getObjects(["cim:Diagram"])["cim:Diagram"].map((e=>(void 0===x.getAttribute(e,"cim:IdentifiedObject.name")&&x.setAttribute(e,"cim:IdentifiedObject.name","unnamed diagram"),x.getAttribute(e,"cim:IdentifiedObject.name")))).map((e=>e.textContent)),getObjects(e){let t={},n=d();for(let n of e)t[n]=[];return t=[].reduce.call(n,(function(e,t){return void 0!==e[t.nodeName]&&e[t.nodeName].push(t),e}),t),t},getSubObjects:e=>d().filter((function(t){return!0===x.schema.isA(e,t)})),getGraphicObjects(e){let t={},n=b().map((e=>e.target)),r=new Set(n);for(let n of e)t[n]=[];return t=[...r].reduce((function(e,t){return void 0!==e[t.nodeName]&&e[t.nodeName].push(t),e}),t),t},getNodes(){let e="cim:ConnectivityNode";"BUS_BRANCH"===l&&(e="cim:TopologicalNode");let t=x.getObjects([e])[e],n=x.getGraphicObjects([e])[e],r=t.filter((e=>-1===n.indexOf(e)));return r=r.filter((function(e){let t=x.getBusbar(e),n=x.getEquipments(e);return null!==t||n.length>1})),n.concat(r)},getConnectors(e){let t={};for(let n of e){let e=x.getObjects([n])[n],r=x.getGraphicObjects([n])[n],i=e.filter((e=>-1===r.indexOf(e)));i=i.filter((function(e){let t=x.getNode(e);if(null!==t){return x.getDiagramObjects([t]).length>0}return!1})),t[n]=r.concat(i)}return t},getLinkedObjects(e,t){let n={};for(let r of e)n[r]=x.getObjects([r])[r].filter((function(e){let n=[e],r=[];for(let r of t){let t=r.split("/"),i=[e];for(let e=0;e0}));return n},getTerminals(e){let t=v(e).map((e=>e.target));return t=[...new Set(t)],t},getObject:e=>a.get("#"+e),getAttributes(e){if(null!=e)return[].filter.call(e.children,(function(e){return 0===e.attributes.length}))},getAttribute(e,t){if(void 0===e)return;if(null===e)return;return x.getAttributes(e).filter((e=>e.nodeName===t))[0]},setAttribute(n,r,i){let o=x.getAttribute(n,r);if(void 0!==o)o.innerHTML=i;else{let a=e;r.startsWith("entsoe:")&&(a=t),o=n.ownerDocument.createElementNS(a,r),o.innerHTML=i,n.appendChild(o)}x.trigger("setAttribute",n,r,i)},setEnum(t,n,r){let i=w(t,n);if(void 0===i){i=t.ownerDocument.createElement(n);let e=t.ownerDocument.createAttribute("rdf:resource");e.nodeValue="#",i.setAttributeNode(e),t.appendChild(i)}i.attributes[0].value=e+r,x.trigger("setEnum",t,n,r)},createObject(e,t){let n=h(e,t);if(x.schema.isA("IdentifiedObject",n)&&x.setAttribute(n,"cim:IdentifiedObject.name","new1"),!1===x.schema.isA("ConductingEquipment",n))return x.trigger("createObject",n),n;let r=2,i=null;void 0!==t&&(void 0!==t.windNum&&(r=t.windNum),void 0!==t.node&&(i=t.node));let o=p(n),a=null,s=null;if("cim:ACLineSegment"!==e&&"cim:Breaker"!==e&&"cim:Disconnector"!==e&&"cim:LoadBreakSwitch"!==e&&"cim:Junction"!==e&&"cim:PowerTransformer"!==e||(a=p(n)),"cim:PowerTransformer"===e&&3===r&&(s=p(n)),"cim:BusbarSection"===e){let e="ConnectivityNode";"BUS_BRANCH"===l&&(e="TopologicalNode"),null===i&&(i=h("cim:"+e)),m(o,"cim:Terminal."+e,i)}if("cim:PowerTransformer"===e){let e=h("cim:PowerTransformerEnd"),t=h("cim:PowerTransformerEnd");if(x.setAttribute(e,"cim:IdentifiedObject.name","winding1"),x.setAttribute(t,"cim:IdentifiedObject.name","winding2"),m(n,"cim:PowerTransformer.PowerTransformerEnd",e),m(n,"cim:PowerTransformer.PowerTransformerEnd",t),m(e,"cim:TransformerEnd.Terminal",o),m(t,"cim:TransformerEnd.Terminal",a),3===r){let e=h("cim:PowerTransformerEnd");x.setAttribute(e,"cim:IdentifiedObject.name","winding3"),m(n,"cim:PowerTransformer.PowerTransformerEnd",e),m(e,"cim:TransformerEnd.Terminal",s)}}return x.trigger("createObject",n),n},deleteObjects(e){let t=[],n=[];for(let s of e){"cim:ConnectivityNode"!==s.nodeName&&"cim:TopologicalNode"!==s.nodeName||(n=n.concat(o(s))),"cim:BusbarSection"===s.nodeName&&(n=n.concat(i(s)));let e=x.getLinks(s);for(let i of e){let e=a.get(i.attributes.getNamedItem("rdf:resource").value),o=i.nodeName;void 0!==e&&(r(s,e)&&n.push(e),t.push({s:s,l:o,t:e}))}}for(let[i,o]of s){let s=i.split("#"),l="cim:"+s[0],c="#"+s[1],u=a.get(c);if(e.indexOf(u)>-1)for(let e of o)t.push({s:e,l:l,t:u}),r(u,e)&&n.push(e)}for(let e of t)x.removeLink(e.s,e.l,e.t);n.length>0&&x.deleteObjects(n);for(let t of e){let e=x.ID(t),n=t.localName;a.delete("#"+e),t.remove(),x.trigger("deleteObject",e,n)}function r(e,t){return!(!x.schema.isA("ConductingEquipment",e)||"cim:Terminal"!==t.nodeName)||("cim:DiagramObjectPoint"===t.nodeName||("cim:DiagramObjectPoint"!==e.nodeName&&"cim:DiagramObject"===t.nodeName||("cim:PowerTransformer"===e.nodeName&&"cim:PowerTransformerEnd"===t.nodeName||("cim:GeographicalRegion"===e.nodeName&&"cim:SubGeographicalRegion"===t.nodeName||("cim:SubGeographicalRegion"===e.nodeName&&"cim:Substation"===t.nodeName||("cim:Substation"===e.nodeName&&"cim:VoltageLevel"===t.nodeName||"cim:VoltageLevel"===e.nodeName&&"cim:Bay"===t.nodeName))))))}function i(e){let t="ConnectivityNode";if("BUS_BRANCH"===l&&(t="TopologicalNode"),"cim:BusbarSection"===e.nodeName){let n=x.getTargets([e],"ConductingEquipment.Terminals");return x.getTargets(n,"Terminal."+t)}return[]}function o(e){let t="ConnectivityNode.Terminals";"BUS_BRANCH"===l&&(t="TopologicalNode.Terminal");let n=x.getTargets([e],t);return x.getTargets(n,"Terminal.ConductingEquipment").filter((e=>"cim:BusbarSection"===e.nodeName))}},deleteObject(e){x.deleteObjects([e])},getNode(e){let t="ConnectivityNode";if("BUS_BRANCH"===l&&(t="TopologicalNode"),"cim:BusbarSection"===e.nodeName){let n=x.getTargets([e],"ConductingEquipment.Terminals"),r=x.getTargets(n,"Terminal."+t);return 0===r.length?null:r[0]}return null},getBusbar(e){let t="ConnectivityNode.Terminals";"BUS_BRANCH"===l&&(t="TopologicalNode.Terminal");let n=x.getTargets([e],t),r=x.getTargets(n,"Terminal.ConductingEquipment").filter((e=>"BusbarSection"===e.localName)),i=x.getDiagramObjects([e].concat(r));return r.length>0&&i.length>0?r[0]:null},deleteFromDiagram(e){let t=x.ID(e),n=x.getDiagramObjects([e]),r="ConnectivityNode";if("BUS_BRANCH"===l&&(r="TopologicalNode"),"BusbarSection"===e.localName){let t=x.getNode(e);n=n.concat(x.getDiagramObjects([t]))}if(e.localName===r){let t=x.getBusbar(e);null!==t&&(n=n.concat(x.getDiagramObjects([t])))}let i=x.getTargets(n,"DiagramObject.DiagramObjectPoints");for(let e of n)x.deleteObject(e);for(let e of i)x.deleteObject(e);x.trigger("deleteFromDiagram",t)},addToActiveDiagram(e,t){let n=h("cim:DiagramObject");for(let r of t){let t=h("cim:DiagramObjectPoint");x.setAttribute(t,"cim:DiagramObjectPoint.xPosition",r.x+e.x),x.setAttribute(t,"cim:DiagramObjectPoint.yPosition",r.y+e.y),x.setAttribute(t,"cim:DiagramObjectPoint.sequenceNumber",r.seq),m(t,"cim:DiagramObjectPoint.DiagramObject",n)}void 0!==e.rotation&&x.setAttribute(n,"cim:DiagramObject.rotation",e.rotation),m(n,"cim:DiagramObject.IdentifiedObject",e),m(n,"cim:DiagramObject.Diagram",x.activeDiagram),x.trigger("addToActiveDiagram",e)},updateActiveDiagram(e,t){let n=x.getDiagramObjects([e]);if(("cim:ConnectivityNode"===e.nodeName||"cim:TopologicalNode"===e.nodeName)&&0===n.length){let t=x.getEquipments(e).filter((e=>"BusbarSection"===e.localName))[0];void 0!==t&&(n=x.getDiagramObjects([t]))}for(let t of n)x.setAttribute(t,"cim:DiagramObject.rotation",e.rotation);let r=x.getTargets(n,"DiagramObject.DiagramObjectPoints");if(r.length>0){for(let t of r){let n=1,r=x.getAttribute(t,"cim:DiagramObjectPoint.sequenceNumber");void 0!==r&&(n=parseInt(r.innerHTML));let i=e.lineData.filter((e=>e.seq===n))[0];x.getAttribute(t,"cim:DiagramObjectPoint.xPosition").innerHTML=i.x+e.x,x.getAttribute(t,"cim:DiagramObjectPoint.yPosition").innerHTML=i.y+e.y}x.trigger("updateActiveDiagram",e)}else x.addToActiveDiagram(e,e.lineData)},getLinks:e=>[].filter.call(e.children,(function(e){let t=e.attributes.getNamedItem("rdf:resource");return 0!==e.attributes.length&&null!==t&&"#"===t.value.charAt(0)})),getLink:(e,t)=>x.getLinks(e).filter((e=>e.nodeName===t)),getEnum(e,t){let n=w(e,t),r=void 0;return void 0!==n&&(r=n.attributes.getNamedItem("rdf:resource").value.split("#")[1].split(".")[1]),r},setLink(e,t,n){let r=x.getTargets([e],t.split(":")[1]);for(let n of r)x.removeLink(e,t,n);m(e,t,n)},removeLink(e,t,n){i(x.getLink(e,t),e,n);let r=x.schema.schemaInvLinksMap.get(t.split(":")[1]);if(void 0!==r){i(x.getLink(n,"cim:"+r),n,e)}function i(e,t,n){for(let r of e){let e=r.attributes.getNamedItem("rdf:resource").value;if(e==="#"+x.ID(n)){let n=r.localName+e,i=s.get(n);r.remove(),1===i.length?s.delete(n):i.splice(i.indexOf(t),1)}}}x.trigger("removeLink",e,t,n)},getTargets(e,t){let n=g(e,t).map((e=>e.target));return[...new Set(n)]},getDiagramObjects(e){let t=b(e).map((e=>e.source));return[...new Set(t)]},getEquipments(e){let t="ConnectivityNode.Terminals";"BUS_BRANCH"===l&&(t="TopologicalNode.Terminal");let n=x.getTargets([e],t),r=x.getTargets(n,"Terminal.ConductingEquipment");return r=v(r).map((e=>e.source)),[...new Set(r)]},selectDiagram(e){e!==x.activeDiagramName&&(x.activeDiagramName=e,x.activeDiagram=x.getObjects(["cim:Diagram"])["cim:Diagram"].filter((e=>x.getAttribute(e,"cim:IdentifiedObject.name").textContent===x.activeDiagramName))[0]),void 0===x.activeDiagram&&(x.activeDiagram=h("cim:Diagram"),x.setAttribute(x.activeDiagram,"cim:IdentifiedObject.name",e),x.activeDiagramName=e,x.trigger("createdDiagram")),x.trigger("changedDiagram")},isBoundary(e){let t=!1,n=x.getAttribute(e,"entsoe:ConnectivityNode.boundaryPoint");return void 0!==n&&"true"===n.textContent&&(t=!0),t},getMode:()=>l,setMode(e){"NODE_BREAKER"!==e&&"BUS_BRANCH"!==e||(l=e),x.trigger("setMode",l)},ID(e){if(null==e)return null;if(void 0===e.attributes)return null;{let t=e.attributes.getNamedItem("rdf:ID");return null===t?null:t.value}},clear(){o.all=null,x.fileName=null,a=new Map,s=new Map}};return observable(x),x}function cimSchema(){let e={EQ:null,DL:null,SV:null,TP:null,SSH:null,GL:null};let t=new Map,n=new Map,r=new Map;function i(e,t){let n=[],r=o.getSchemaObject(e,t);if(null===r)return n;let a=[].filter.call(r.children,(function(e){return"rdfs:subClassOf"===e.nodeName}))[0];if(void 0!==a){let e=a.attributes[0].value.substring(1);n.push(e),n=n.concat(i(e,t))}return n}let o={schemaInvLinksMap:new Map,buildSchema(){return null===e.EQ?d3.xml("rdf-schema/EquipmentProfileCoreShortCircuitOperationRDFSAugmented-v2_4_15-16Feb2016.rdf").then((function(n){return e.EQ=n,t(e.EQ),d3.xml("rdf-schema/DiagramLayoutProfileRDFSAugmented-v2_4_15-16Feb2016.rdf")})).then((function(n){return e.DL=n,t(e.DL),d3.xml("rdf-schema/StateVariablesProfileRDFSAugmented-v2_4_15-16Feb2016.rdf")})).then((function(n){return e.SV=n,t(e.SV),d3.xml("rdf-schema/TopologyProfileRDFSAugmented-v2_4_15-16Feb2016.rdf")})).then((function(n){return e.TP=n,t(e.TP),d3.xml("rdf-schema/SteadyStateHypothesisProfileRDFSAugmented-v2_4_15-16Feb2016.rdf")})).then((function(n){return e.SSH=n,t(e.SSH),d3.xml("rdf-schema/GeographicalLocationProfileRDFSAugmented-v2_4_15-16Feb2016.rdf")})).then((function(n){e.GL=n,t(e.GL)})).catch((function(e){return Promise.reject(e)})):Promise.resolve();function t(e){let t=e.children[0].children;for(let e in t){let n=t[e];if(void 0===n.children)continue;let r=[].filter.call(n.children,(function(e){return"cims:inverseRoleName"===e.nodeName}))[0];void 0!==r&&o.schemaInvLinksMap.set(n.attributes[0].value.substring(1),r.attributes[0].value.substring(1))}}},getSchemaObject(t,n){let i=null;for(let o of Object.keys(e)){if(void 0!==n&&n!==o)continue;let a=r.get(o+t);if(void 0!==a){i=a;break}let s=e[o].children[0].children;if(a=[].filter.call(s,(function(e){return e.attributes[0].value==="#"+t}))[0],void 0!==a){i=a,r.set(o+t,a);break}}return i},getSchemaEnumValues(t,n){let r="EQ";void 0!==n&&(r=n);let i=[].filter.call(t.children,(function(e){return"rdfs:range"===e.nodeName}))[0].attributes.getNamedItem("rdf:resource").value.substring(1),o=e[r].children[0].children;return[].filter.call(o,(function(e){return e.attributes[0].value.startsWith("#"+i+".")})).map((e=>[].filter.call(e.children,(function(e){return"rdfs:label"===e.nodeName}))[0].textContent))},getSchemaEnumName:e=>[].filter.call(e.children,(function(e){return"rdfs:range"===e.nodeName}))[0].attributes.getNamedItem("rdf:resource").value.substring(1),getSchemaAttributes(n,r){let o=n,a="EQ";void 0!==r&&(a=r),o+=a;let s=t.get(o);if(void 0===s){let r=e[a].children[0].children;s=[].filter.call(r,(function(e){return e.attributes.getNamedItem("rdf:about").value.startsWith("#"+n+".")}));let l=i(n,a);for(let e in l)s=s.concat([].filter.call(r,(function(t){return t.attributes.getNamedItem("rdf:about").value.startsWith("#"+l[e]+".")})));s=s.filter((function(e){let t=e.attributes.getNamedItem("rdf:about").value;t=t.substring(t.indexOf("#"));let n=!1,r=t.split(".")[1];return void 0!==r&&(n=r.toLowerCase().charAt(0)===r.charAt(0)),n})),t.set(o,s)}return s},getSchemaAttribute:(e,t,n)=>o.getSchemaAttributes(e,n).filter((e=>e.attributes[0].value.substring(1)===t))[0],isEnum:e=>void 0===[].filter.call(e.children,(function(e){return"cims:dataType"===e.nodeName}))[0],getSchemaAttributeType(e){let t="none",n="none";if(o.isEnum(e))return["#Enum",t,n];let r=[].filter.call(e.children,(function(e){return"cims:dataType"===e.nodeName}))[0].attributes.getNamedItem("rdf:resource").value,i=o.getSchemaObject(r.substring(1));if("CIMDatatype"===[].filter.call(i.children,(function(e){return"cims:stereotype"===e.nodeName}))[0].textContent){let e=o.getSchemaObject(r.substring(1)+".value"),i=o.getSchemaObject(r.substring(1)+".unit"),a=o.getSchemaObject(r.substring(1)+".multiplier");if(r=[].filter.call(e.children,(function(e){return"cims:dataType"===e.nodeName}))[0].attributes.getNamedItem("rdf:resource").value,null!==i&&(t=[].filter.call(i.children,(function(e){return"cims:isFixed"===e.nodeName}))[0].attributes.getNamedItem("rdfs:Literal").value),null!==a){let e=[].filter.call(a.children,(function(e){return"cims:isFixed"===e.nodeName}))[0];void 0!==e&&(n=e.attributes.getNamedItem("rdfs:Literal").value)}}return[r,t,n]},getSchemaStereotype(e){let t=[].filter.call(e.children,(function(e){return"cims:stereotype"===e.nodeName&&""!==e.textContent}));return t.length>0?t[0].textContent:null},getSchemaLinks(t,r){let o=t;o+=void 0!==r?r:"EQ";let a=n.get(o);if(void 0===a){let s=e.EQ;void 0!==r&&(s=e[r]);let l=s.children[0].children;a=[].filter.call(l,(function(e){return e.attributes[0].value.startsWith("#"+t+".")}));let c=i(t);for(let e in c)a=a.concat([].filter.call(l,(function(t){return t.attributes[0].value.startsWith("#"+c[e]+".")})));a=a.filter((function(e){let t=!1,n=e.attributes[0].value.split(".")[1];return void 0!==n&&(t=n.toLowerCase().charAt(0)!==n.charAt(0)),t})),n.set(o,a)}return a},getAllSchemasLinks(t){let n=[];return Object.keys(e).forEach((function(e){n=n.concat(o.getSchemaLinks(t,e))})),n},getSchemaLink:(e,t,n)=>o.getSchemaLinks(e,n).filter((e=>e.attributes[0].value.substring(1)===t))[0],getAllSchemasLink:(e,t)=>o.getAllSchemasLinks(e).filter((e=>e.attributes[0].value.substring(1)===t))[0],isA:(e,t)=>t.localName===e||!(i(t.localName).indexOf(e)<0),isConcrete(e,t){let n=!1,r=o.getSchemaObject(e.localName,t);return[].filter.call(r.children,(function(e){return"cims:stereotype"===e.nodeName})).forEach((function(e){let t=e.attributes.getNamedItem("rdf:resource");if(null!==t){"http://iec.ch/TC57/NonStandard/UML#concrete"===t.value&&(n=!0)}})),n},isDescription(e,t){let n=!1,r=o.getSchemaObject(e.localName,t);return[].filter.call(r.children,(function(e){return"cims:stereotype"===e.nodeName})).forEach((function(e){"Description"===e.textContent&&(n=!0)})),n},checkLink(e,t){let n=t,r=o.getAllSchemasLink(e.localName,t.split(":")[1]);if(void 0!==r){if("No"===[].filter.call(r.children,(function(e){return"cims:AssociationUsed"===e.nodeName}))[0].textContent){n="cim:"+o.schemaInvLinksMap.get(t.split(":")[1])}}return n},getLinkDomain(e){if(void 0===e)return null;if(null===e)return null;let t=[].filter.call(e.children,(function(e){return"rdfs:domain"===e.nodeName}))[0];return void 0===t?null:t.attributes.getNamedItem("rdf:resource").value.substring(1)},getLinkRange(e){if(void 0===e)return null;if(null===e)return null;let t=[].filter.call(e.children,(function(e){return"rdfs:range"===e.nodeName}))[0];return void 0===t?null:t.attributes.getNamedItem("rdf:resource").value.substring(1)}};return o}function topologyProcessor(e){return{calcTopology(){let t=[],n=e.getObjects(["cim:TopologicalNode"])["cim:TopologicalNode"];"BUS_BRANCH"===e.getMode()&&n.forEach((function(t){let n=e.createObject("cim:ConnectivityNode");e.getTargets([t],"TopologicalNode.Terminal").forEach((function(t){e.setLink(t,"cim:Terminal.ConnectivityNode",n)}))})),e.deleteObjects(n),n=[];let r=[],i=e.getObjects(["cim:ConnectivityNode"])["cim:ConnectivityNode"];for(;i.length>0;){let e=o(i[0]);i=i.filter((t=>e.indexOf(t)<0)),r.push(e)}function o(t){let n=new Set,r=-1;for(n.add(t);r!==n.size;){r=n.size;let t=e.getTargets([...n],"ConnectivityNode.Terminals"),i=e.getTargets(t,"Terminal.ConductingEquipment").filter((function(t){return!0===e.schema.isA("Switch",t)}));i=i.filter((function(t){let n=!0,r=e.getAttribute(t,"cim:Switch.open");return void 0!==r&&(n="false"===r.textContent),n}));let o=e.getTargets(i,"ConductingEquipment.Terminals"),a=e.getTargets(o,"Terminal.ConnectivityNode");for(let e of a)n.add(e)}return[...n]}return r.forEach((function(n){let r=e.createObject("cim:TopologicalNode");n.forEach((function(t){e.setLink(t,"cim:ConnectivityNode.TopologicalNode",r)}));let i=e.getTargets(n,"ConnectivityNode.Terminals"),o=e.getTargets(i,"Terminal.ConductingEquipment"),a=e.getTargets(o,"ConductingEquipment.BaseVoltage");if(a.length>0)e.setLink(r,"cim:TopologicalNode.BaseVoltage",a[0]);else{let t=e.getTargets(i,"Terminal.TransformerEnd");if(a=e.getTargets(t,"TransformerEnd.BaseVoltage"),a.length>0)console.log(t),e.setLink(r,"cim:TopologicalNode.BaseVoltage",a[0]);else{let t=e.getTargets(o,"Equipment.EquipmentContainer"),n=t.filter((t=>e.schema.isA("VoltageLevel",t)));if(a=e.getTargets(n,"VoltageLevel.BaseVoltage"),a.length>0)e.setLink(r,"cim:TopologicalNode.BaseVoltage",a[0]);else{let i=t.filter((t=>e.schema.isA("Bay",t)));n=e.getTargets(i,"Bay.VoltageLevel"),a=e.getTargets(n,"VoltageLevel.BaseVoltage"),a.length>0&&e.setLink(r,"cim:TopologicalNode.BaseVoltage",a[0])}}}i.forEach((function(t){e.setLink(t,"cim:Terminal.TopologicalNode",r),void 0===e.getAttribute(t,"cim:ACDCTerminal.connected")&&e.setAttribute(t,"cim:ACDCTerminal.connected","true")})),t.push(r)})),t},getTerminals(t){let n=[];return n=e.schema.isA("TopologicalNode",t)?e.getTargets([t],"TopologicalNode.Terminal"):e.schema.isA("TransformerEnd",t)?e.getTargets([t],"TransformerEnd.Terminal"):e.getTargets([t],"ConductingEquipment.Terminals"),n=n.filter((function(t){let n=e.getAttribute(t,"cim:ACDCTerminal.connected");return void 0!==n&&"true"===n.textContent})),n}}} +var t,e;function rotate(e,t){let n=d3.select("svg").node(),r=n.createSVGPoint();if(r.x=e.x,r.y=e.y,0===t)return r;let i=n.createSVGTransform();return i.setRotate(t,0,0),r.matrixTransform(i.matrix)}function rotateTerm(e,t){let n=e.getTargets([t],"Terminal.ConductingEquipment")[0],r=n.x,i=n.y,o=rotate({x:t.x-r,y:t.y-i},t.rotation);return{x:r+o.x,y:i+o.y}}function addToDiagram(e,t,n){let r=d3.pointer(t,d3.select("svg").node()),i=d3.zoomTransform(d3.select("svg").node()),o=i.x,a=i.y,s=i.k;n.x=(r[0]-o)/s,n.px=n.x,n.y=(r[1]-a)/s,n.py=n.y;let l=[{x:0,y:0,seq:1}];"cim:ACLineSegment"!==n.nodeName&&"cim:BusbarSection"!==n.nodeName||l.push({x:150,y:0,seq:2}),e.addToActiveDiagram(n,l)}function calcLineData(e,t){let n="ConnectivityNode",r="ConnectivityNode.Terminals";"BUS_BRANCH"===e.getMode()&&(n="TopologicalNode",r="TopologicalNode.Terminal"),t.x=void 0,t.y=void 0,t.rotation=0;let i=[],o=0,a=0,s=e.getEquipments(t).filter((e=>void 0!==e.lineData||"BusbarSection"===e.localName)),l=s.filter((e=>"BusbarSection"===e.localName))[0],c=e.getDiagramObjects([t]);if(0===c.length){if(void 0!==l){c=e.getDiagramObjects([l]);let n=e.getAttribute(c[0],"cim:DiagramObject.rotation");void 0!==n&&(t.rotation=parseInt(n.innerHTML))}else if(s.length>0){let e=[];for(let t of s){let n=t.x+t.lineData[t.lineData.length-1].x,r=t.y+t.lineData[t.lineData.length-1].y;e.push({x:t.x+t.lineData[0].x,y:t.y+t.lineData[0].y,eq:t},{x:n,y:r,eq:t})}let t=1/0,n=e[0],r=e[0];for(let i of e)for(let o of e){if(i.eq===o.eq)continue;let e=distance2(i,o);e0){for(let t of u){let n=e.getAttribute(t,"cim:DiagramObjectPoint.sequenceNumber");n=void 0===n?1:parseInt(n.innerHTML),i.push({x:parseFloat(e.getAttribute(t,"cim:DiagramObjectPoint.xPosition").innerHTML),y:parseFloat(e.getAttribute(t,"cim:DiagramObjectPoint.yPosition").innerHTML),seq:n})}i.sort((function(e,t){return e.seq-t.seq})),t.x=i[0].x,t.y=i[0].y;for(let e of i)e.x=e.x-t.x,e.y=e.y-t.y}else{if(i.push({x:0,y:0,seq:1}),t.nodeName==="cim:"+n){let n=e.getTargets([t],r);void 0!==e.getTargets(n,"Terminal.ConductingEquipment").filter((e=>"cim:BusbarSection"===e.nodeName))[0]&&i.push({x:150,y:0,seq:2})}t.x=o,t.y=a,e.addToActiveDiagram(t,i)}return t.lineData=i,i}function distance2(e,t){let n=e.x-t.x,r=e.y-t.y;return n*n+r*r}function closestPoint(e,t){let n=d3.line().x((function(e){return e.x})).y((function(e){return e.y})),r=d3.select(document.createElementNS("http://www.w3.org/2000/svg","svg")).append("path").attr("d",n(e.lineData)).node();if(null===r)return[0,0];let i,o,a=r.getTotalLength(),s=8,l=1/0;if(0===a)return[0,0];if(void 0===t.x||void 0===t.y)return[0,0];for(let t=0;t<=a;t+=s){let n=r.getPointAtLength(t);0!==e.rotation&&(n=rotate(n,e.rotation));let a=c(n);a.5;){let t=o-s;if(t>=0){let n=r.getPointAtLength(t);0!==e.rotation&&(n=rotate(n,e.rotation));let a=c(n);if(ae.matches('[data-bs-toggle="popover"]')));for(let e of t){let t=bootstrap.Popover.getInstance(e);null!==t&&t.hide()}}function showPopovers(e){let t=[];t=void 0===e?document.querySelectorAll('[data-bs-toggle="popover"]'):e.filter((e=>e.matches('[data-bs-toggle="popover"]')));for(let e of t){let t=bootstrap.Popover.getInstance(e);null!==t&&t.show()}}function disposePopovers(e){let t=[];t=void 0===e?document.querySelectorAll('[data-bs-toggle="popover"]'):e.filter((e=>e.matches('[data-bs-toggle="popover"]')));for(let e of t){let t=bootstrap.Popover.getInstance(e);null!==t&&t.dispose()}}function exportToMatpower(e){let t="function mpc = cim\n",n="100",r=[],i=topologyProcessor(e);r="NODE_BREAKER"===e.getMode()?i.calcTopology():e.getObjects(["cim:TopologicalNode"])["cim:TopologicalNode"],t+="% MATPOWER Case Format : Version 2\n",t+="mpc.version = '2';\n",t+="% system MVA base\n",t=t+"mpc.baseMVA = "+"100;\n",t+="% bus data\n",t+="mpc.bus = [\n",t+="%bus_i\ttype\tPd\tQd\tGs\tBs\tarea\tVm\tVa\tbaseKV\tzone\tVmax\tVmin\n";let o=new Map;for(let n in r){let a=e.ID(r[n]),s=1,l=u(e.getTargets([r[n]],"TopologicalNode.BaseVoltage")[0],"cim:BaseVoltage.nominalVoltage","0"),c=parseInt(n)+1,f=i.getTerminals(r[n]),d=e.getTargets(f,"Terminal.ConductingEquipment"),h=d.filter((t=>!0===e.schema.isA("EnergyConsumer",t))),p=d.filter((t=>!0===e.schema.isA("ShuntCompensator",t))),m=d.filter((t=>!0===e.schema.isA("SynchronousMachine",t))),g=d.filter((t=>!0===e.schema.isA("AsynchronousMachine",t))),b=(e.getTargets(f,"Terminal.TransformerEnd"),0),v=0,y=1;h.forEach((function(e){b+=parseFloat(u(e,"cim:EnergyConsumer.p","0.0")),v+=parseFloat(u(e,"cim:EnergyConsumer.q","0.0"))})),g.forEach((function(e){b+=parseFloat(u(e,"cim:RotatingMachine.p","0")),v+=parseFloat(u(e,"cim:RotatingMachine.q","0"))}));let _=0,w=0;if(p.forEach((function(e){let t=parseFloat(u(e,"cim:ShuntCompensator.sections","0.0")),n=parseFloat(u(e,"cim:LinearShuntCompensator.gPerSection","0.0")),r=parseFloat(u(e,"cim:LinearShuntCompensator.bPerSection","0.0"));_+=n*t,w+=r*t})),_=_*l*l,w=w*l*l,m.length>0||p.length>0){if(p.length>0){let t=i.getTerminals(p[0]),n=(e.getTargets(t,"Terminal.TopologicalNode"),e.getTargets([p[0]],"RegulatingCondEq.RegulatingControl")[0]);if(void 0!==n){s=2;let e=u(n,"cim:RegulatingControl.targetValue",l);y=parseFloat(e)/parseFloat(l)}}if(m.length>0){void 0!==e.getTargets([m[0]],"RegulatingCondEq.RegulatingControl")[0]&&(s=2)}}m.filter((function(e){return parseInt(u(e,"cim:SynchronousMachine.referencePriority","0"))>0})).length>0&&(s=3),t=t+c+"\t",t=t+s+"\t",t=t+b+"\t",t=t+v+"\t",t=t+_+"\t",t=t+w+"\t",t=t+1+"\t",t=t+y+"\t",t=t+0+"\t",t=t+l+"\t",t=t+1+"\t",t=t+1.1+"\t",t=t+.9+";\t",t=t+"%Node ("+a+")",t+="\n",o.set(r[n],c)}t+="];\n";let a=e.getObjects(["cim:SynchronousMachine"])["cim:SynchronousMachine"],s=e.getObjects(["cim:EquivalentInjection"])["cim:EquivalentInjection"];t+="% generator data\n",t+="mpc.gen = [\n",t+="%bus\tPg\tQg\tQmax\tQmin\tVg\tmBase\tstatus\tPmax\tPmin\tPc1\tPc2\tQc1min\tQc1max\tQc2min\tQc2max\tramp_agc\tramp_10\tramp_30\tramp_q\tapf\n",a.forEach((function(r){let a={};a.genUUID=e.ID(r);let s=i.getTerminals(r),l=e.getTargets(s,"Terminal.TopologicalNode"),f=e.getTargets([r],"RotatingMachine.GeneratingUnit")[0],d=e.getTargets([r],"RegulatingCondEq.RegulatingControl")[0];l.forEach((function(i){if(a.busNum=o.get(i),a.p=-1*parseFloat(u(r,"cim:RotatingMachine.p","0")),a.q=-1*parseFloat(u(r,"cim:RotatingMachine.q","0")),a.qmax=parseFloat(u(r,"cim:SynchronousMachine.maxQ","0")),a.qmin=parseFloat(u(r,"cim:SynchronousMachine.minQ","0")),a.vg=1,void 0!==d){let t=u(e.getTargets([i],"TopologicalNode.BaseVoltage")[0],"cim:BaseVoltage.nominalVoltage","0"),n=u(d,"cim:RegulatingControl.targetValue",t);a.vg=parseFloat(n)/parseFloat(t)}a.mbase=parseFloat(u(r,"cim:SynchronousMachine.ratedS",n)),a.pmax=parseFloat(u(f,"cim:GeneratingUnit.maxOperatingP","0")),a.pmin=parseFloat(u(f,"cim:GeneratingUnit.minOperatingP","0")),t+=c(a)}))})),s.forEach((function(r){let a={};a.genUUID=e.ID(r);let s=i.getTerminals(r),l=e.getTargets(s,"Terminal.TopologicalNode"),f=u(r,"cim:EquivalentInjection.regulationStatus","false");l.forEach((function(i){if(a.busNum=o.get(i),a.p=-1*parseFloat(u(r,"cim:EquivalentInjection.p","0")),a.q=-1*parseFloat(u(r,"cim:EquivalentInjection.q","0")),a.qmax=parseFloat(u(r,"cim:EquivalentInjection.maxQ","0")),a.qmin=parseFloat(u(r,"cim:EquivalentInjection.minQ","0")),a.vg=1,"true"===f){let t=u(e.getTargets([i],"TopologicalNode.BaseVoltage")[0],"cim:BaseVoltage.nominalVoltage","0"),n=u(r,"cim:EquivalentInjection.regulationTarget",t);a.vg=parseFloat(n)/parseFloat(t)}a.mbase=n,a.pmax=parseFloat(u(r,"cim:EquivalentInjection.maxP","0")),a.pmin=parseFloat(u(r,"cim:EquivalentInjection.minP","0")),t+=c(a)}))})),t+="];\n";let l=e.getObjects(["cim:ACLineSegment"])["cim:ACLineSegment"];return t+="% branch data\n",t+="mpc.branch = [\n",t+="%fbus\ttbus\tr\tx\tb\trateA\trateB\trateC\tratio\tangle\tstatus\tangmin\tangmax\n",l.forEach((function(r){let a=e.ID(r),s=i.getTerminals(r),l=e.getTargets(s,"Terminal.TopologicalNode");if(2===l.length){let i=u(e.getTargets(l,"TopologicalNode.BaseVoltage")[0],"cim:BaseVoltage.nominalVoltage","0"),s=parseFloat(i)*parseFloat(i)/parseFloat(n),c=u(r,"cim:ACLineSegment.r","0"),f=u(r,"cim:ACLineSegment.x","0"),d=u(r,"cim:ACLineSegment.bch","0"),h=parseFloat(c)/s,p=parseFloat(f)/s,m=parseFloat(d)*s;t=t+o.get(l[0])+"\t",t=t+o.get(l[1])+"\t",t=t+h+"\t",t=t+p+"\t",t=t+m+"\t",t=t+0+"\t",t=t+0+"\t",t=t+0+"\t",t=t+0+"\t",t=t+0+"\t",t=t+1+"\t",t+="-360\t",t+="360;\t",t=t+"%AC line segment ("+a+")",t+="\n"}})),e.getObjects(["cim:PowerTransformer"])["cim:PowerTransformer"].forEach((function(r){let a=e.ID(r),s=e.getTargets([r],"PowerTransformer.PowerTransformerEnd");if(2===s.length){let r=s[0],l=s[1],c=u(r,"cim:PowerTransformerEnd.r","0"),f=u(r,"cim:PowerTransformerEnd.x","0");"0"===c&&"0"===f&&(l=s[0],r=s[1],c=u(r,"cim:PowerTransformerEnd.r","0"),f=u(r,"cim:PowerTransformerEnd.x","0"));let d=u(r,"cim:PowerTransformerEnd.b","0"),h=i.getTerminals(r),p=e.getTargets(h,"Terminal.TopologicalNode")[0],m=i.getTerminals(l),g=e.getTargets(m,"Terminal.TopologicalNode")[0];if(1===h.length&&1===m.length&&void 0!==p&&void 0!==g){let i=u(e.getTargets([p],"TopologicalNode.BaseVoltage")[0],"cim:BaseVoltage.nominalVoltage","0"),s=u(e.getTargets([g],"TopologicalNode.BaseVoltage")[0],"cim:BaseVoltage.nominalVoltage","0"),h=u(r,"cim:PowerTransformerEnd.ratedU",i),m=u(l,"cim:PowerTransformerEnd.ratedU",s),b=parseFloat(i)*parseFloat(i)/parseFloat(n),v=parseFloat(c)/b,y=parseFloat(f)/b,_=parseFloat(d)*b,w=e.getTargets([r],"TransformerEnd.RatioTapChanger"),x=parseFloat(s)*parseFloat(h)/(parseFloat(i)*parseFloat(m)),T=!1;if(0===w.length&&(w=e.getTargets([l],"TransformerEnd.RatioTapChanger"),T=!0),w.length>0){let e=u(w[0],"cim:TapChanger.neutralStep","0"),t=u(w[0],"cim:TapChanger.step",e),n=u(w[0],"cim:RatioTapChanger.stepVoltageIncrement","0"),r=(parseFloat(t)-parseFloat(e))*parseFloat(n);r/=100,r=1+r,!0===T&&(r=1/r),x*=r}t=t+o.get(p)+"\t",t=t+o.get(g)+"\t",t=t+v+"\t",t=t+y+"\t",t=t+_+"\t",t=t+0+"\t",t=t+0+"\t",t=t+0+"\t",t=t+x+"\t",t=t+0+"\t",t=t+1+"\t",t+="-360\t",t+="360;\t",t=t+"%Two-winding transformer ("+a+")",t+="\n"}}if(3===s.length){let r=s[0],l=s[1],c=s[2],m=u(r,"cim:PowerTransformerEnd.r","0"),g=u(l,"cim:PowerTransformerEnd.r","0"),b=u(c,"cim:PowerTransformerEnd.r","0"),v=u(r,"cim:PowerTransformerEnd.x","0"),y=u(l,"cim:PowerTransformerEnd.x","0"),_=u(c,"cim:PowerTransformerEnd.x","0"),w=u(r,"cim:PowerTransformerEnd.b","0"),x=u(l,"cim:PowerTransformerEnd.b","0"),T=u(c,"cim:PowerTransformerEnd.b","0"),A=i.getTerminals(r),E=i.getTerminals(l),k=i.getTerminals(c),S=e.getTargets(A,"Terminal.TopologicalNode")[0],M=e.getTargets(E,"Terminal.TopologicalNode")[0],C=e.getTargets(k,"Terminal.TopologicalNode")[0];if(1===A.length&&1===E.length&&1===k.length){let i=e.getTargets([S],"TopologicalNode.BaseVoltage")[0],s=e.getTargets([M],"TopologicalNode.BaseVoltage")[0],A=e.getTargets([C],"TopologicalNode.BaseVoltage")[0],E=u(i,"cim:BaseVoltage.nominalVoltage","0"),k=u(s,"cim:BaseVoltage.nominalVoltage","0"),N=u(A,"cim:BaseVoltage.nominalVoltage","0"),D=u(r,"cim:PowerTransformerEnd.ratedU",E),L=u(l,"cim:PowerTransformerEnd.ratedU",k),O=u(c,"cim:PowerTransformerEnd.ratedU",N),I=parseFloat(E)*parseFloat(E)/parseFloat(n),B=parseFloat(k)*parseFloat(k)/parseFloat(n),P=parseFloat(N)*parseFloat(N)/parseFloat(n),j=parseFloat(m)/I,R=parseFloat(g)/B,z=parseFloat(b)/P,F=parseFloat(v)/I,q=parseFloat(y)/B,U=parseFloat(_)/P,H=parseFloat(w)*I,V=parseFloat(x)*B,G=parseFloat(T)*P,W=f(j,F),Y=f(R,q),Z=f(z,U),K=d(d(h(W,Y),h(Y,Z)),h(Z,W)),X=h(K,p(Z)),Q=h(K,p(W)),$=h(K,p(Y)),J=parseFloat(k)*parseFloat(D)/(parseFloat(E)*parseFloat(L)),ee=parseFloat(N)*parseFloat(L)/(parseFloat(k)*parseFloat(O)),te=parseFloat(E)*parseFloat(O)/(parseFloat(N)*parseFloat(D));t=t+o.get(S)+"\t",t=t+o.get(M)+"\t",t=t+X.re+"\t",t=t+X.im+"\t",t=t+H+"\t",t=t+0+"\t",t=t+0+"\t",t=t+0+"\t",t=t+J+"\t",t=t+0+"\t",t=t+1+"\t",t+="-360\t",t+="360;\t",t=t+"%Three-winding transformer branch 1-2 ("+a+")",t+="\n",t=t+o.get(M)+"\t",t=t+o.get(C)+"\t",t=t+Q.re+"\t",t=t+Q.im+"\t",t=t+V+"\t",t=t+0+"\t",t=t+0+"\t",t=t+0+"\t",t=t+ee+"\t",t=t+0+"\t",t=t+1+"\t",t+="-360\t",t+="360;\t",t=t+"%Three-winding transformer branch 2-3 ("+a+")",t+="\n",t=t+o.get(C)+"\t",t=t+o.get(S)+"\t",t=t+$.re+"\t",t=t+$.im+"\t",t=t+G+"\t",t=t+0+"\t",t=t+0+"\t",t=t+0+"\t",t=t+te+"\t",t=t+0+"\t",t=t+1+"\t",t+="-360\t",t+="360;\t",t=t+"%Three-winding transformer branch 3-1 ("+a+")",t+="\n"}}})),t+="];\n",t;function c(e){let t="";return t=t+e.busNum+"\t",t=t+e.p+"\t",t=t+e.q+"\t",t=t+e.qmax+"\t",t=t+e.qmin+"\t",t=t+e.vg+"\t",t=t+e.mbase+"\t",t=t+1+"\t",t=t+e.pmax+"\t",t=t+e.pmin+"\t",t=t+0+"\t",t=t+0+"\t",t=t+0+"\t",t=t+0+"\t",t=t+0+"\t",t=t+0+"\t",t=t+0+"\t",t=t+0+"\t",t=t+0+"\t",t=t+0+"\t",t=t+0+";\t",t=t+"%Generator ("+e.genUUID+")",t+="\n",t}function u(t,n,r){let i=e.getAttribute(t,n);return i=void 0===i?r:i.textContent,i}function f(e,t){return{re:e,im:t}}function d(e,t){return{re:e.re+t.re,im:e.im+t.im}}function h(e,t){return{re:e.re*t.re-e.im*t.im,im:e.re*t.im+e.im*t.re}}function p(e){const t=e.re*e.re+e.im*e.im;return{re:e.re/t,im:-e.im/t}}}!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).d3=e.d3||{})}(this,(function(e){"use strict";function t(e,t){return et?1:e>=t?0:NaN}function n(e){let n=e,r=e;function i(e,t,n,i){for(null==n&&(n=0),null==i&&(i=e.length);n>>1;r(e[o],t)<0?n=o+1:i=o}return n}return 1===e.length&&(n=(t,n)=>e(t)-n,r=function(e){return(n,r)=>t(e(n),r)}(e)),{left:i,center:function(e,t,r,o){null==r&&(r=0),null==o&&(o=e.length);const a=i(e,t,r,o-1);return a>r&&n(e[a-1],t)>-n(e[a],t)?a-1:a},right:function(e,t,n,i){for(null==n&&(n=0),null==i&&(i=e.length);n>>1;r(e[o],t)>0?i=o:n=o+1}return n}}}function r(e){return null===e?NaN:+e}const i=n(t),o=i.right,a=i.left,s=n(r).center;function l(e,t){let n=0;if(void 0===t)for(let t of e)null!=t&&(t=+t)>=t&&++n;else{let r=-1;for(let i of e)null!=(i=t(i,++r,e))&&(i=+i)>=i&&++n}return n}function c(e){return 0|e.length}function u(e){return!(e>0)}function f(e){return"object"!=typeof e||"length"in e?e:Array.from(e)}function d(e,t){let n,r=0,i=0,o=0;if(void 0===t)for(let t of e)null!=t&&(t=+t)>=t&&(n=t-i,i+=n/++r,o+=n*(t-i));else{let a=-1;for(let s of e)null!=(s=t(s,++a,e))&&(s=+s)>=s&&(n=s-i,i+=n/++r,o+=n*(s-i))}if(r>1)return o/(r-1)}function h(e,t){const n=d(e,t);return n?Math.sqrt(n):n}function p(e,t){let n,r;if(void 0===t)for(const t of e)null!=t&&(void 0===n?t>=t&&(n=r=t):(n>t&&(n=t),r=o&&(n=r=o):(n>o&&(n=o),r0){for(o=e[--i];i>0&&(t=o,n=e[--i],o=t+n,r=n-(o-t),!r););i>0&&(r<0&&e[i-1]<0||r>0&&e[i-1]>0)&&(n=2*r,t=o+n,n==t-o&&(o=t))}return o}}function g(e){return e}function b(e){if(1!==e.length)throw new Error("duplicate key");return e[0]}function v(e,t,n,r){return function e(i,o){if(o>=r.length)return n(i);const a=new Map,s=r[o++];let l=-1;for(const e of i){const t=s(e,++l,i),n=a.get(t);n?n.push(e):a.set(t,[e])}for(const[t,n]of a)a.set(t,e(n,o));return t(a)}(e,0)}var y=Array.prototype.slice;function _(e){return function(){return e}}var w=Math.sqrt(50),x=Math.sqrt(10),T=Math.sqrt(2);function A(e,t,n){var r,i,o,a,s=-1;if(n=+n,(e=+e)==(t=+t)&&n>0)return[e];if((r=t0)for(e=Math.ceil(e/a),t=Math.floor(t/a),o=new Array(i=Math.ceil(t-e+1));++s=0?(o>=w?10:o>=x?5:o>=T?2:1)*Math.pow(10,i):-Math.pow(10,-i)/(o>=w?10:o>=x?5:o>=T?2:1)}function k(e,t,n){var r=Math.abs(t-e)/Math.max(0,n),i=Math.pow(10,Math.floor(Math.log(r)/Math.LN10)),o=r/i;return o>=w?i*=10:o>=x?i*=5:o>=T&&(i*=2),t0?(e=Math.floor(e/i)*i,t=Math.ceil(t/i)*i):i<0&&(e=Math.ceil(e*i)/i,t=Math.floor(t*i)/i),r=i}}function M(e){return Math.ceil(Math.log(l(e))/Math.LN2)+1}function C(){var e=g,t=p,n=M;function r(r){Array.isArray(r)||(r=Array.from(r));var i,a,s=r.length,l=new Array(s);for(i=0;i0?f=(Math.floor(f/e)+1)*e:e<0&&(f=(Math.ceil(f*e)+1)/e))}else d.pop()}for(var h=d.length;d[0]<=u;)d.shift(),--h;for(;d[h-1]>f;)d.pop(),--h;var m,g=new Array(h+1);for(i=0;i<=h;++i)(m=g[i]=[]).x0=i>0?d[i-1]:u,m.x1=i=t)&&(n=t);else{let r=-1;for(let i of e)null!=(i=t(i,++r,e))&&(n=i)&&(n=i)}return n}function D(e,t){let n;if(void 0===t)for(const t of e)null!=t&&(n>t||void 0===n&&t>=t)&&(n=t);else{let r=-1;for(let i of e)null!=(i=t(i,++r,e))&&(n>i||void 0===n&&i>=i)&&(n=i)}return n}function L(e,n,r=0,i=e.length-1,o=t){for(;i>r;){if(i-r>600){const t=i-r+1,a=n-r+1,s=Math.log(t),l=.5*Math.exp(2*s/3),c=.5*Math.sqrt(s*l*(t-l)/t)*(a-t/2<0?-1:1);L(e,n,Math.max(r,Math.floor(n-a*l/t+c)),Math.min(i,Math.floor(n+(t-a)*l/t+c)),o)}const t=e[n];let a=r,s=i;for(O(e,r,n),o(e[i],t)>0&&O(e,r,i);a0;)--s}0===o(e[r],t)?O(e,r,s):(++s,O(e,s,i)),s<=n&&(r=s+1),n<=s&&(i=s-1)}return e}function O(e,t,n){const r=e[t];e[t]=e[n],e[n]=r}function I(e,t,n){if(r=(e=Float64Array.from(function*(e,t){if(void 0===t)for(let t of e)null!=t&&(t=+t)>=t&&(yield t);else{let n=-1;for(let r of e)null!=(r=t(r,++n,e))&&(r=+r)>=r&&(yield r)}}(e,n))).length){if((t=+t)<=0||r<2)return D(e);if(t>=1)return N(e);var r,i=(r-1)*t,o=Math.floor(i),a=N(L(e,o).subarray(0,o+1));return a+(D(e.subarray(o+1))-a)*(i-o)}}function B(e,t,n=r){if(i=e.length){if((t=+t)<=0||i<2)return+n(e[0],0,e);if(t>=1)return+n(e[i-1],i-1,e);var i,o=(i-1)*t,a=Math.floor(o),s=+n(e[a],a,e);return s+(+n(e[a+1],a+1,e)-s)*(o-a)}}function P(e,t){let n,r=-1,i=-1;if(void 0===t)for(const t of e)++i,null!=t&&(n=t)&&(n=t,r=i);else for(let o of e)null!=(o=t(o,++i,e))&&(n=o)&&(n=o,r=i);return r}function j(e){return Array.from(function*(e){for(const t of e)yield*t}(e))}function R(e,t){let n,r=-1,i=-1;if(void 0===t)for(const t of e)++i,null!=t&&(n>t||void 0===n&&t>=t)&&(n=t,r=i);else for(let o of e)null!=(o=t(o,++i,e))&&(n>o||void 0===n&&o>=o)&&(n=o,r=i);return r}function z(e,t){return[e,t]}function F(e,t){return Array.from(t,(t=>e[t]))}function q(e,t,n){e=+e,t=+t,n=(i=arguments.length)<2?(t=e,e=0,1):i<3?1:+n;for(var r=-1,i=0|Math.max(0,Math.ceil((t-e)/n)),o=new Array(i);++r+e(t)}function te(e){var t=Math.max(0,e.bandwidth()-1)/2;return e.round()&&(t=Math.round(t)),function(n){return+e(n)+t}}function ne(){return!this.__axis}function re(e,t){var n=[],r=null,i=null,o=6,a=6,s=3,l=1===e||4===e?-1:1,c=4===e||2===e?"x":"y",u=1===e||3===e?$:J;function f(f){var d=null==r?t.ticks?t.ticks.apply(t,n):t.domain():r,h=null==i?t.tickFormat?t.tickFormat.apply(t,n):X:i,p=Math.max(o,0)+s,m=t.range(),g=+m[0]+.5,b=+m[m.length-1]+.5,v=(t.bandwidth?te:ee)(t.copy()),y=f.selection?f.selection():f,_=y.selectAll(".domain").data([null]),w=y.selectAll(".tick").data(d,t).order(),x=w.exit(),T=w.enter().append("g").attr("class","tick"),A=w.select("line"),E=w.select("text");_=_.merge(_.enter().insert("path",".tick").attr("class","domain").attr("stroke","currentColor")),w=w.merge(T),A=A.merge(T.append("line").attr("stroke","currentColor").attr(c+"2",l*o)),E=E.merge(T.append("text").attr("fill","currentColor").attr(c,l*p).attr("dy",1===e?"0em":3===e?"0.71em":"0.32em")),f!==y&&(_=_.transition(f),w=w.transition(f),A=A.transition(f),E=E.transition(f),x=x.transition(f).attr("opacity",Q).attr("transform",(function(e){return isFinite(e=v(e))?u(e):this.getAttribute("transform")})),T.attr("opacity",Q).attr("transform",(function(e){var t=this.parentNode.__axis;return u(t&&isFinite(t=t(e))?t:v(e))}))),x.remove(),_.attr("d",4===e||2==e?a?"M"+l*a+","+g+"H0.5V"+b+"H"+l*a:"M0.5,"+g+"V"+b:a?"M"+g+","+l*a+"V0.5H"+b+"V"+l*a:"M"+g+",0.5H"+b),w.attr("opacity",1).attr("transform",(function(e){return u(v(e))})),A.attr(c+"2",l*o),E.attr(c,l*p).text(h),y.filter(ne).attr("fill","none").attr("font-size",10).attr("font-family","sans-serif").attr("text-anchor",2===e?"start":4===e?"end":"middle"),y.each((function(){this.__axis=v}))}return f.scale=function(e){return arguments.length?(t=e,f):t},f.ticks=function(){return n=K.call(arguments),f},f.tickArguments=function(e){return arguments.length?(n=null==e?[]:K.call(e),f):n.slice()},f.tickValues=function(e){return arguments.length?(r=null==e?null:K.call(e),f):r&&r.slice()},f.tickFormat=function(e){return arguments.length?(i=e,f):i},f.tickSize=function(e){return arguments.length?(o=a=+e,f):o},f.tickSizeInner=function(e){return arguments.length?(o=+e,f):o},f.tickSizeOuter=function(e){return arguments.length?(a=+e,f):a},f.tickPadding=function(e){return arguments.length?(s=+e,f):s},f}var ie={value:()=>{}};function oe(){for(var e,t=0,n=arguments.length,r={};t=0&&(n=e.slice(r+1),e=e.slice(0,r)),e&&!t.hasOwnProperty(e))throw new Error("unknown type: "+e);return{type:e,name:n}}))}function le(e,t){for(var n,r=0,i=e.length;r0)for(var n,r,i=new Array(n),o=0;o=0&&"xmlns"!==(t=e.slice(0,n))&&(e=e.slice(n+1)),fe.hasOwnProperty(t)?{space:fe[t],local:e}:e}function he(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===ue&&t.documentElement.namespaceURI===ue?t.createElement(e):t.createElementNS(n,e)}}function pe(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function me(e){var t=de(e);return(t.local?pe:he)(t)}function ge(){}function be(e){return null==e?ge:function(){return this.querySelector(e)}}function ve(e){return"object"==typeof e&&"length"in e?e:Array.from(e)}function ye(){return[]}function _e(e){return null==e?ye:function(){return this.querySelectorAll(e)}}function we(e){return function(){return this.matches(e)}}function xe(e){return function(t){return t.matches(e)}}var Te=Array.prototype.find;function Ae(){return this.firstElementChild}var Ee=Array.prototype.filter;function ke(){return this.children}function Se(e){return new Array(e.length)}function Me(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}function Ce(e){return function(){return e}}function Ne(e,t,n,r,i,o){for(var a,s=0,l=t.length,c=o.length;st?1:e>=t?0:NaN}function Ie(e){return function(){this.removeAttribute(e)}}function Be(e){return function(){this.removeAttributeNS(e.space,e.local)}}function Pe(e,t){return function(){this.setAttribute(e,t)}}function je(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function Re(e,t){return function(){var n=t.apply(this,arguments);null==n?this.removeAttribute(e):this.setAttribute(e,n)}}function ze(e,t){return function(){var n=t.apply(this,arguments);null==n?this.removeAttributeNS(e.space,e.local):this.setAttributeNS(e.space,e.local,n)}}function Fe(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function qe(e){return function(){this.style.removeProperty(e)}}function Ue(e,t,n){return function(){this.style.setProperty(e,t,n)}}function He(e,t,n){return function(){var r=t.apply(this,arguments);null==r?this.style.removeProperty(e):this.style.setProperty(e,r,n)}}function Ve(e,t){return e.style.getPropertyValue(t)||Fe(e).getComputedStyle(e,null).getPropertyValue(t)}function Ge(e){return function(){delete this[e]}}function We(e,t){return function(){this[e]=t}}function Ye(e,t){return function(){var n=t.apply(this,arguments);null==n?delete this[e]:this[e]=n}}function Ze(e){return e.trim().split(/^|\s+/)}function Ke(e){return e.classList||new Xe(e)}function Xe(e){this._node=e,this._names=Ze(e.getAttribute("class")||"")}function Qe(e,t){for(var n=Ke(e),r=-1,i=t.length;++r=0&&(t=e.slice(n+1),e=e.slice(0,n)),{type:e,name:t}}))}function mt(e){return function(){var t=this.__on;if(t){for(var n,r=0,i=-1,o=t.length;r=0&&(this._names.splice(t,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(e){return this._names.indexOf(e)>=0}};var _t=[null];function wt(e,t){this._groups=e,this._parents=t}function xt(){return new wt([[document.documentElement]],_t)}function Tt(e){return"string"==typeof e?new wt([[document.querySelector(e)]],[document.documentElement]):new wt([[e]],_t)}wt.prototype=xt.prototype={constructor:wt,select:function(e){"function"!=typeof e&&(e=be(e));for(var t=this._groups,n=t.length,r=new Array(n),i=0;i=w&&(w=_+1);!(y=g[w])&&++w=0;)(r=i[o])&&(a&&4^r.compareDocumentPosition(a)&&a.parentNode.insertBefore(r,a),a=r);return this},sort:function(e){function t(t,n){return t&&n?e(t.__data__,n.__data__):!t-!n}e||(e=Oe);for(var n=this._groups,r=n.length,i=new Array(r),o=0;o1?this.each((null==t?qe:"function"==typeof t?He:Ue)(e,t,null==n?"":n)):Ve(this.node(),e)},property:function(e,t){return arguments.length>1?this.each((null==t?Ge:"function"==typeof t?Ye:We)(e,t)):this.node()[e]},classed:function(e,t){var n=Ze(e+"");if(arguments.length<2){for(var r=Ke(this.node()),i=-1,o=n.length;++i()=>e;function It(e,{sourceEvent:t,subject:n,target:r,identifier:i,active:o,x:a,y:s,dx:l,dy:c,dispatch:u}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},subject:{value:n,enumerable:!0,configurable:!0},target:{value:r,enumerable:!0,configurable:!0},identifier:{value:i,enumerable:!0,configurable:!0},active:{value:o,enumerable:!0,configurable:!0},x:{value:a,enumerable:!0,configurable:!0},y:{value:s,enumerable:!0,configurable:!0},dx:{value:l,enumerable:!0,configurable:!0},dy:{value:c,enumerable:!0,configurable:!0},_:{value:u}})}function Bt(e){return!e.ctrlKey&&!e.button}function Pt(){return this.parentNode}function jt(e,t){return null==t?{x:e.x,y:e.y}:t}function Rt(){return navigator.maxTouchPoints||"ontouchstart"in this}function zt(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function Ft(e,t){var n=Object.create(e.prototype);for(var r in t)n[r]=t[r];return n}function qt(){}It.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};var Ut=.7,Ht=1/Ut,Vt="\\s*([+-]?\\d+)\\s*",Gt="\\s*([+-]?\\d*\\.?\\d+(?:[eE][+-]?\\d+)?)\\s*",Wt="\\s*([+-]?\\d*\\.?\\d+(?:[eE][+-]?\\d+)?)%\\s*",Yt=/^#([0-9a-f]{3,8})$/,Zt=new RegExp("^rgb\\("+[Vt,Vt,Vt]+"\\)$"),Kt=new RegExp("^rgb\\("+[Wt,Wt,Wt]+"\\)$"),Xt=new RegExp("^rgba\\("+[Vt,Vt,Vt,Gt]+"\\)$"),Qt=new RegExp("^rgba\\("+[Wt,Wt,Wt,Gt]+"\\)$"),$t=new RegExp("^hsl\\("+[Gt,Wt,Wt]+"\\)$"),Jt=new RegExp("^hsla\\("+[Gt,Wt,Wt,Gt]+"\\)$"),en={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};function tn(){return this.rgb().formatHex()}function nn(){return this.rgb().formatRgb()}function rn(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=Yt.exec(e))?(n=t[1].length,t=parseInt(t[1],16),6===n?on(t):3===n?new cn(t>>8&15|t>>4&240,t>>4&15|240&t,(15&t)<<4|15&t,1):8===n?an(t>>24&255,t>>16&255,t>>8&255,(255&t)/255):4===n?an(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|240&t,((15&t)<<4|15&t)/255):null):(t=Zt.exec(e))?new cn(t[1],t[2],t[3],1):(t=Kt.exec(e))?new cn(255*t[1]/100,255*t[2]/100,255*t[3]/100,1):(t=Xt.exec(e))?an(t[1],t[2],t[3],t[4]):(t=Qt.exec(e))?an(255*t[1]/100,255*t[2]/100,255*t[3]/100,t[4]):(t=$t.exec(e))?hn(t[1],t[2]/100,t[3]/100,1):(t=Jt.exec(e))?hn(t[1],t[2]/100,t[3]/100,t[4]):en.hasOwnProperty(e)?on(en[e]):"transparent"===e?new cn(NaN,NaN,NaN,0):null}function on(e){return new cn(e>>16&255,e>>8&255,255&e,1)}function an(e,t,n,r){return r<=0&&(e=t=n=NaN),new cn(e,t,n,r)}function sn(e){return e instanceof qt||(e=rn(e)),e?new cn((e=e.rgb()).r,e.g,e.b,e.opacity):new cn}function ln(e,t,n,r){return 1===arguments.length?sn(e):new cn(e,t,n,null==r?1:r)}function cn(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}function un(){return"#"+dn(this.r)+dn(this.g)+dn(this.b)}function fn(){var e=this.opacity;return(1===(e=isNaN(e)?1:Math.max(0,Math.min(1,e)))?"rgb(":"rgba(")+Math.max(0,Math.min(255,Math.round(this.r)||0))+", "+Math.max(0,Math.min(255,Math.round(this.g)||0))+", "+Math.max(0,Math.min(255,Math.round(this.b)||0))+(1===e?")":", "+e+")")}function dn(e){return((e=Math.max(0,Math.min(255,Math.round(e)||0)))<16?"0":"")+e.toString(16)}function hn(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new gn(e,t,n,r)}function pn(e){if(e instanceof gn)return new gn(e.h,e.s,e.l,e.opacity);if(e instanceof qt||(e=rn(e)),!e)return new gn;if(e instanceof gn)return e;var t=(e=e.rgb()).r/255,n=e.g/255,r=e.b/255,i=Math.min(t,n,r),o=Math.max(t,n,r),a=NaN,s=o-i,l=(o+i)/2;return s?(a=t===o?(n-r)/s+6*(n0&&l<1?0:a,new gn(a,s,l,e.opacity)}function mn(e,t,n,r){return 1===arguments.length?pn(e):new gn(e,t,n,null==r?1:r)}function gn(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}function bn(e,t,n){return 255*(e<60?t+(n-t)*e/60:e<180?n:e<240?t+(n-t)*(240-e)/60:t)}zt(qt,rn,{copy:function(e){return Object.assign(new this.constructor,this,e)},displayable:function(){return this.rgb().displayable()},hex:tn,formatHex:tn,formatHsl:function(){return pn(this).formatHsl()},formatRgb:nn,toString:nn}),zt(cn,ln,Ft(qt,{brighter:function(e){return e=null==e?Ht:Math.pow(Ht,e),new cn(this.r*e,this.g*e,this.b*e,this.opacity)},darker:function(e){return e=null==e?Ut:Math.pow(Ut,e),new cn(this.r*e,this.g*e,this.b*e,this.opacity)},rgb:function(){return this},displayable:function(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:un,formatHex:un,formatRgb:fn,toString:fn})),zt(gn,mn,Ft(qt,{brighter:function(e){return e=null==e?Ht:Math.pow(Ht,e),new gn(this.h,this.s,this.l*e,this.opacity)},darker:function(e){return e=null==e?Ut:Math.pow(Ut,e),new gn(this.h,this.s,this.l*e,this.opacity)},rgb:function(){var e=this.h%360+360*(this.h<0),t=isNaN(e)||isNaN(this.s)?0:this.s,n=this.l,r=n+(n<.5?n:1-n)*t,i=2*n-r;return new cn(bn(e>=240?e-240:e+120,i,r),bn(e,i,r),bn(e<120?e+240:e-120,i,r),this.opacity)},displayable:function(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl:function(){var e=this.opacity;return(1===(e=isNaN(e)?1:Math.max(0,Math.min(1,e)))?"hsl(":"hsla(")+(this.h||0)+", "+100*(this.s||0)+"%, "+100*(this.l||0)+"%"+(1===e?")":", "+e+")")}}));const vn=Math.PI/180,yn=180/Math.PI,_n=.96422,wn=.82521,xn=4/29,Tn=6/29,An=3*Tn*Tn;function En(e){if(e instanceof Sn)return new Sn(e.l,e.a,e.b,e.opacity);if(e instanceof In)return Bn(e);e instanceof cn||(e=sn(e));var t,n,r=Dn(e.r),i=Dn(e.g),o=Dn(e.b),a=Mn((.2225045*r+.7168786*i+.0606169*o)/1);return r===i&&i===o?t=n=a:(t=Mn((.4360747*r+.3850649*i+.1430804*o)/_n),n=Mn((.0139322*r+.0971045*i+.7141733*o)/wn)),new Sn(116*a-16,500*(t-a),200*(a-n),e.opacity)}function kn(e,t,n,r){return 1===arguments.length?En(e):new Sn(e,t,n,null==r?1:r)}function Sn(e,t,n,r){this.l=+e,this.a=+t,this.b=+n,this.opacity=+r}function Mn(e){return e>.008856451679035631?Math.pow(e,1/3):e/An+xn}function Cn(e){return e>Tn?e*e*e:An*(e-xn)}function Nn(e){return 255*(e<=.0031308?12.92*e:1.055*Math.pow(e,1/2.4)-.055)}function Dn(e){return(e/=255)<=.04045?e/12.92:Math.pow((e+.055)/1.055,2.4)}function Ln(e){if(e instanceof In)return new In(e.h,e.c,e.l,e.opacity);if(e instanceof Sn||(e=En(e)),0===e.a&&0===e.b)return new In(NaN,0=1?(n=1,t-1):Math.floor(n*t),i=e[r],o=e[r+1],a=r>0?e[r-1]:2*i-o,s=r()=>e;function Qn(e,t){return function(n){return e+n*t}}function $n(e,t){var n=t-e;return n?Qn(e,n>180||n<-180?n-360*Math.round(n/360):n):Xn(isNaN(e)?t:e)}function Jn(e,t){var n=t-e;return n?Qn(e,n):Xn(isNaN(e)?t:e)}var er=function e(t){var n=function(e){return 1==(e=+e)?Jn:function(t,n){return n-t?function(e,t,n){return e=Math.pow(e,n),t=Math.pow(t,n)-e,n=1/n,function(r){return Math.pow(e+r*t,n)}}(t,n,e):Xn(isNaN(t)?n:t)}}(t);function r(e,t){var r=n((e=ln(e)).r,(t=ln(t)).r),i=n(e.g,t.g),o=n(e.b,t.b),a=Jn(e.opacity,t.opacity);return function(t){return e.r=r(t),e.g=i(t),e.b=o(t),e.opacity=a(t),e+""}}return r.gamma=e,r}(1);function tr(e){return function(t){var n,r,i=t.length,o=new Array(i),a=new Array(i),s=new Array(i);for(n=0;no&&(i=t.slice(o,i),s[a]?s[a]+=i:s[++a]=i),(n=n[0])===(r=r[0])?s[a]?s[a]+=r:s[++a]=r:(s[++a]=null,l.push({i:a,x:lr(n,r)})),o=fr.lastIndex;return o180?t+=360:t-e>180&&(e+=360),o.push({i:n.push(i(n)+"rotate(",null,r)-2,x:lr(e,t)})):t&&n.push(i(n)+"rotate("+t+r)}(o.rotate,a.rotate,s,l),function(e,t,n,o){e!==t?o.push({i:n.push(i(n)+"skewX(",null,r)-2,x:lr(e,t)}):t&&n.push(i(n)+"skewX("+t+r)}(o.skewX,a.skewX,s,l),function(e,t,n,r,o,a){if(e!==n||t!==r){var s=o.push(i(o)+"scale(",null,",",null,")");a.push({i:s-4,x:lr(e,n)},{i:s-2,x:lr(t,r)})}else 1===n&&1===r||o.push(i(o)+"scale("+n+","+r+")")}(o.scaleX,o.scaleY,a.scaleX,a.scaleY,s,l),o=a=null,function(e){for(var t,n=-1,r=l.length;++n=0&&t._call.call(null,e),t=t._next;--Pr}function Kr(){Fr=(zr=Ur.now())+qr,Pr=jr=0;try{Zr()}finally{Pr=0,function(){for(var e,t,n=Ir,r=1/0;n;)n._call?(r>n._time&&(r=n._time),e=n,n=n._next):(t=n._next,n._next=null,n=e?e._next=t:Ir=t);Br=e,Qr(r)}(),Fr=0}}function Xr(){var e=Ur.now(),t=e-zr;t>1e3&&(qr-=t,zr=e)}function Qr(e){Pr||(jr&&(jr=clearTimeout(jr)),e-Fr>24?(e<1/0&&(jr=setTimeout(Kr,e-Ur.now()-qr)),Rr&&(Rr=clearInterval(Rr))):(Rr||(zr=Ur.now(),Rr=setInterval(Xr,1e3)),Pr=1,Hr(Kr)))}function $r(e,t,n){var r=new Wr;return t=null==t?0:+t,r.restart((n=>{r.stop(),e(n+t)}),t,n),r}Wr.prototype=Yr.prototype={constructor:Wr,restart:function(e,t,n){if("function"!=typeof e)throw new TypeError("callback is not a function");n=(null==n?Vr():+n)+(null==t?0:+t),this._next||Br===this||(Br?Br._next=this:Ir=this,Br=this),this._call=e,this._time=n,Qr()},stop:function(){this._call&&(this._call=null,this._time=1/0,Qr())}};var Jr=oe("start","end","cancel","interrupt"),ei=[];function ti(e,t,n,r,i,o){var a=e.__transition;if(a){if(n in a)return}else e.__transition={};!function(e,t,n){var r,i=e.__transition;function o(l){var c,u,f,d;if(1!==n.state)return s();for(c in i)if((d=i[c]).name===n.name){if(3===d.state)return $r(o);4===d.state?(d.state=6,d.timer.stop(),d.on.call("interrupt",e,e.__data__,d.index,d.group),delete i[c]):+c0)throw new Error("too late; already scheduled");return n}function ri(e,t){var n=ii(e,t);if(n.state>3)throw new Error("too late; already running");return n}function ii(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function oi(e,t){var n,r,i,o=e.__transition,a=!0;if(o){for(i in t=null==t?null:t+"",o)(n=o[i]).name===t?(r=n.state>2&&n.state<5,n.state=6,n.timer.stop(),n.on.call(r?"interrupt":"cancel",e,e.__data__,n.index,n.group),delete o[i]):a=!1;a&&delete e.__transition}}function ai(e,t){var n,r;return function(){var i=ri(this,e),o=i.tween;if(o!==n)for(var a=0,s=(r=n=o).length;a=0&&(e=e.slice(0,t)),!e||"start"===e}))}(t)?ni:ri;return function(){var a=o(this,e),s=a.on;s!==r&&(i=(r=s).copy()).on(t,n),a.on=i}}var ki=xt.prototype.constructor;function Si(e){return function(){this.style.removeProperty(e)}}function Mi(e,t,n){return function(r){this.style.setProperty(e,t.call(this,r),n)}}function Ci(e,t,n){var r,i;function o(){var o=t.apply(this,arguments);return o!==i&&(r=(i=o)&&Mi(e,o,n)),r}return o._value=t,o}function Ni(e){return function(t){this.textContent=e.call(this,t)}}function Di(e){var t,n;function r(){var r=e.apply(this,arguments);return r!==n&&(t=(n=r)&&Ni(r)),t}return r._value=e,r}var Li=0;function Oi(e,t,n,r){this._groups=e,this._parents=t,this._name=n,this._id=r}function Ii(e){return xt().transition(e)}function Bi(){return++Li}var Pi=xt.prototype;function ji(e){return((e*=2)<=1?e*e:--e*(2-e)+1)/2}function Ri(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}Oi.prototype=Ii.prototype={constructor:Oi,select:function(e){var t=this._name,n=this._id;"function"!=typeof e&&(e=be(e));for(var r=this._groups,i=r.length,o=new Array(i),a=0;a()=>e;function lo(e,{sourceEvent:t,target:n,selection:r,mode:i,dispatch:o}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},selection:{value:r,enumerable:!0,configurable:!0},mode:{value:i,enumerable:!0,configurable:!0},_:{value:o}})}function co(e){e.stopImmediatePropagation()}function uo(e){e.preventDefault(),e.stopImmediatePropagation()}var fo={name:"drag"},ho={name:"space"},po={name:"handle"},mo={name:"center"};const{abs:go,max:bo,min:vo}=Math;function yo(e){return[+e[0],+e[1]]}function _o(e){return[yo(e[0]),yo(e[1])]}var wo={name:"x",handles:["w","e"].map(Co),input:function(e,t){return null==e?null:[[+e[0],t[0][1]],[+e[1],t[1][1]]]},output:function(e){return e&&[e[0][0],e[1][0]]}},xo={name:"y",handles:["n","s"].map(Co),input:function(e,t){return null==e?null:[[t[0][0],+e[0]],[t[1][0],+e[1]]]},output:function(e){return e&&[e[0][1],e[1][1]]}},To={name:"xy",handles:["n","w","e","s","nw","ne","sw","se"].map(Co),input:function(e){return null==e?null:_o(e)},output:function(e){return e}},Ao={overlay:"crosshair",selection:"move",n:"ns-resize",e:"ew-resize",s:"ns-resize",w:"ew-resize",nw:"nwse-resize",ne:"nesw-resize",se:"nwse-resize",sw:"nesw-resize"},Eo={e:"w",w:"e",nw:"ne",ne:"nw",se:"sw",sw:"se"},ko={n:"s",s:"n",nw:"sw",ne:"se",se:"ne",sw:"nw"},So={overlay:1,selection:1,n:null,e:1,s:null,w:-1,nw:-1,ne:1,se:1,sw:-1},Mo={overlay:1,selection:1,n:-1,e:null,s:1,w:null,nw:-1,ne:-1,se:1,sw:1};function Co(e){return{type:e}}function No(e){return!e.ctrlKey&&!e.button}function Do(){var e=this.ownerSVGElement||this;return e.hasAttribute("viewBox")?[[(e=e.viewBox.baseVal).x,e.y],[e.x+e.width,e.y+e.height]]:[[0,0],[e.width.baseVal.value,e.height.baseVal.value]]}function Lo(){return navigator.maxTouchPoints||"ontouchstart"in this}function Oo(e){for(;!e.__brush;)if(!(e=e.parentNode))return;return e.__brush}function Io(e){return e[0][0]===e[1][0]||e[0][1]===e[1][1]}function Bo(e){var t,n=Do,r=No,i=Lo,o=!0,a=oe("start","brush","end"),s=6;function l(t){var n=t.property("__brush",m).selectAll(".overlay").data([Co("overlay")]);n.enter().append("rect").attr("class","overlay").attr("pointer-events","all").attr("cursor",Ao.overlay).merge(n).each((function(){var e=Oo(this).extent;Tt(this).attr("x",e[0][0]).attr("y",e[0][1]).attr("width",e[1][0]-e[0][0]).attr("height",e[1][1]-e[0][1])})),t.selectAll(".selection").data([Co("selection")]).enter().append("rect").attr("class","selection").attr("cursor",Ao.selection).attr("fill","#777").attr("fill-opacity",.3).attr("stroke","#fff").attr("shape-rendering","crispEdges");var r=t.selectAll(".handle").data(e.handles,(function(e){return e.type}));r.exit().remove(),r.enter().append("rect").attr("class",(function(e){return"handle handle--"+e.type})).attr("cursor",(function(e){return Ao[e.type]})),t.each(c).attr("fill","none").attr("pointer-events","all").on("mousedown.brush",d).filter(i).on("touchstart.brush",d).on("touchmove.brush",h).on("touchend.brush touchcancel.brush",p).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function c(){var e=Tt(this),t=Oo(this).selection;t?(e.selectAll(".selection").style("display",null).attr("x",t[0][0]).attr("y",t[0][1]).attr("width",t[1][0]-t[0][0]).attr("height",t[1][1]-t[0][1]),e.selectAll(".handle").style("display",null).attr("x",(function(e){return"e"===e.type[e.type.length-1]?t[1][0]-s/2:t[0][0]-s/2})).attr("y",(function(e){return"s"===e.type[0]?t[1][1]-s/2:t[0][1]-s/2})).attr("width",(function(e){return"n"===e.type||"s"===e.type?t[1][0]-t[0][0]+s:s})).attr("height",(function(e){return"e"===e.type||"w"===e.type?t[1][1]-t[0][1]+s:s}))):e.selectAll(".selection,.handle").style("display","none").attr("x",null).attr("y",null).attr("width",null).attr("height",null)}function u(e,t,n){var r=e.__brush.emitter;return!r||n&&r.clean?new f(e,t,n):r}function f(e,t,n){this.that=e,this.args=t,this.state=e.__brush,this.active=0,this.clean=n}function d(n){if((!t||n.touches)&&r.apply(this,arguments)){var i,a,s,l,f,d,h,p,m,g,b,v=this,y=n.target.__data__.type,_="selection"===(o&&n.metaKey?y="overlay":y)?fo:o&&n.altKey?mo:po,w=e===xo?null:So[y],x=e===wo?null:Mo[y],T=Oo(v),A=T.extent,E=T.selection,k=A[0][0],S=A[0][1],M=A[1][0],C=A[1][1],N=0,D=0,L=w&&x&&o&&n.shiftKey,O=Array.from(n.touches||[n],(e=>{const t=e.identifier;return(e=Mt(e,v)).point0=e.slice(),e.identifier=t,e}));if("overlay"===y){E&&(m=!0);const t=[O[0],O[1]||O[0]];T.selection=E=[[i=e===xo?k:vo(t[0][0],t[1][0]),s=e===wo?S:vo(t[0][1],t[1][1])],[f=e===xo?M:bo(t[0][0],t[1][0]),h=e===wo?C:bo(t[0][1],t[1][1])]],O.length>1&&z()}else i=E[0][0],s=E[0][1],f=E[1][0],h=E[1][1];a=i,l=s,d=f,p=h;var I=Tt(v).attr("pointer-events","none"),B=I.selectAll(".overlay").attr("cursor",Ao[y]);oi(v);var P=u(v,arguments,!0).beforestart();if(n.touches)P.moved=R,P.ended=F;else{var j=Tt(n.view).on("mousemove.brush",R,!0).on("mouseup.brush",F,!0);o&&j.on("keydown.brush",q,!0).on("keyup.brush",U,!0),Dt(n.view)}c.call(v),P.start(n,_.name)}function R(e){for(const t of e.changedTouches||[e])for(const e of O)e.identifier===t.identifier&&(e.cur=Mt(t,v));if(L&&!g&&!b&&1===O.length){const e=O[0];go(e.cur[0]-e[0])>go(e.cur[1]-e[1])?b=!0:g=!0}for(const e of O)e.cur&&(e[0]=e.cur[0],e[1]=e.cur[1]);m=!0,uo(e),z(e)}function z(e){const t=O[0],n=t.point0;var r;switch(N=t[0]-n[0],D=t[1]-n[1],_){case ho:case fo:w&&(N=bo(k-i,vo(M-f,N)),a=i+N,d=f+N),x&&(D=bo(S-s,vo(C-h,D)),l=s+D,p=h+D);break;case po:O[1]?(w&&(a=bo(k,vo(M,O[0][0])),d=bo(k,vo(M,O[1][0])),w=1),x&&(l=bo(S,vo(C,O[0][1])),p=bo(S,vo(C,O[1][1])),x=1)):(w<0?(N=bo(k-i,vo(M-i,N)),a=i+N,d=f):w>0&&(N=bo(k-f,vo(M-f,N)),a=i,d=f+N),x<0?(D=bo(S-s,vo(C-s,D)),l=s+D,p=h):x>0&&(D=bo(S-h,vo(C-h,D)),l=s,p=h+D));break;case mo:w&&(a=bo(k,vo(M,i-N*w)),d=bo(k,vo(M,f+N*w))),x&&(l=bo(S,vo(C,s-D*x)),p=bo(S,vo(C,h+D*x)))}d0&&(i=a-N),x<0?h=p-D:x>0&&(s=l-D),_=ho,B.attr("cursor",Ao.selection),z());break;default:return}uo(e)}function U(e){switch(e.keyCode){case 16:L&&(g=b=L=!1,z());break;case 18:_===mo&&(w<0?f=d:w>0&&(i=a),x<0?h=p:x>0&&(s=l),_=po,z());break;case 32:_===ho&&(e.altKey?(w&&(f=d-N*w,i=a+N*w),x&&(h=p-D*x,s=l+D*x),_=mo):(w<0?f=d:w>0&&(i=a),x<0?h=p:x>0&&(s=l),_=po),B.attr("cursor",Ao[y]),z());break;default:return}uo(e)}}function h(e){u(this,arguments).moved(e)}function p(e){u(this,arguments).ended(e)}function m(){var t=this.__brush||{selection:null};return t.extent=_o(n.apply(this,arguments)),t.dim=e,t}return l.move=function(t,n){t.tween?t.on("start.brush",(function(e){u(this,arguments).beforestart().start(e)})).on("interrupt.brush end.brush",(function(e){u(this,arguments).end(e)})).tween("brush",(function(){var t=this,r=t.__brush,i=u(t,arguments),o=r.selection,a=e.input("function"==typeof n?n.apply(this,arguments):n,r.extent),s=hr(o,a);function l(e){r.selection=1===e&&null===a?null:s(e),c.call(t),i.brush()}return null!==o&&null!==a?l:l(1)})):t.each((function(){var t=this,r=arguments,i=t.__brush,o=e.input("function"==typeof n?n.apply(t,r):n,i.extent),a=u(t,r).beforestart();oi(t),i.selection=null===o?null:o,c.call(t),a.start().brush().end()}))},l.clear=function(e){l.move(e,null)},f.prototype={beforestart:function(){return 1==++this.active&&(this.state.emitter=this,this.starting=!0),this},start:function(e,t){return this.starting?(this.starting=!1,this.emit("start",e,t)):this.emit("brush",e),this},brush:function(e,t){return this.emit("brush",e,t),this},end:function(e,t){return 0==--this.active&&(delete this.state.emitter,this.emit("end",e,t)),this},emit:function(t,n,r){var i=Tt(this.that).datum();a.call(t,this.that,new lo(t,{sourceEvent:n,target:l,selection:e.output(this.state.selection),mode:r,dispatch:a}),i)}},l.extent=function(e){return arguments.length?(n="function"==typeof e?e:so(_o(e)),l):n},l.filter=function(e){return arguments.length?(r="function"==typeof e?e:so(!!e),l):r},l.touchable=function(e){return arguments.length?(i="function"==typeof e?e:so(!!e),l):i},l.handleSize=function(e){return arguments.length?(s=+e,l):s},l.keyModifiers=function(e){return arguments.length?(o=!!e,l):o},l.on=function(){var e=a.on.apply(a,arguments);return e===a?l:e},l}var Po=Math.abs,jo=Math.cos,Ro=Math.sin,zo=Math.PI,Fo=zo/2,qo=2*zo,Uo=Math.max,Ho=1e-12;function Vo(e,t){return Array.from({length:t-e},((t,n)=>e+n))}function Go(e){return function(t,n){return e(t.source.value+t.target.value,n.source.value+n.target.value)}}function Wo(e,t){var n=0,r=null,i=null,o=null;function a(a){var s,l=a.length,c=new Array(l),u=Vo(0,l),f=new Array(l*l),d=new Array(l),h=0;a=Float64Array.from({length:l*l},t?(e,t)=>a[t%l][t/l|0]:(e,t)=>a[t/l|0][t%l]);for(let t=0;tr(c[e],c[t])));for(const n of u){const r=t;if(e){const e=Vo(1+~l,l).filter((e=>e<0?a[~e*l+n]:a[n*l+e]));i&&e.sort(((e,t)=>i(e<0?-a[~e*l+n]:a[n*l+e],t<0?-a[~t*l+n]:a[n*l+t])));for(const r of e)r<0?(f[~r*l+n]||(f[~r*l+n]={source:null,target:null})).target={index:n,startAngle:t,endAngle:t+=a[~r*l+n]*h,value:a[~r*l+n]}:(f[n*l+r]||(f[n*l+r]={source:null,target:null})).source={index:n,startAngle:t,endAngle:t+=a[n*l+r]*h,value:a[n*l+r]};d[n]={index:n,startAngle:r,endAngle:t,value:c[n]}}else{const e=Vo(0,l).filter((e=>a[n*l+e]||a[e*l+n]));i&&e.sort(((e,t)=>i(a[n*l+e],a[n*l+t])));for(const r of e){let e;if(nKo)if(Math.abs(u*s-l*c)>Ko&&i){var d=n-o,h=r-a,p=s*s+l*l,m=d*d+h*h,g=Math.sqrt(p),b=Math.sqrt(f),v=i*Math.tan((Yo-Math.acos((p+f-m)/(2*g*b)))/2),y=v/b,_=v/g;Math.abs(y-1)>Ko&&(this._+="L"+(e+y*c)+","+(t+y*u)),this._+="A"+i+","+i+",0,0,"+ +(u*d>c*h)+","+(this._x1=e+_*s)+","+(this._y1=t+_*l)}else this._+="L"+(this._x1=e)+","+(this._y1=t)},arc:function(e,t,n,r,i,o){e=+e,t=+t,o=!!o;var a=(n=+n)*Math.cos(r),s=n*Math.sin(r),l=e+a,c=t+s,u=1^o,f=o?r-i:i-r;if(n<0)throw new Error("negative radius: "+n);null===this._x1?this._+="M"+l+","+c:(Math.abs(this._x1-l)>Ko||Math.abs(this._y1-c)>Ko)&&(this._+="L"+l+","+c),n&&(f<0&&(f=f%Zo+Zo),f>Xo?this._+="A"+n+","+n+",0,1,"+u+","+(e-a)+","+(t-s)+"A"+n+","+n+",0,1,"+u+","+(this._x1=l)+","+(this._y1=c):f>Ko&&(this._+="A"+n+","+n+",0,"+ +(f>=Yo)+","+u+","+(this._x1=e+n*Math.cos(i))+","+(this._y1=t+n*Math.sin(i))))},rect:function(e,t,n,r){this._+="M"+(this._x0=this._x1=+e)+","+(this._y0=this._y1=+t)+"h"+ +n+"v"+ +r+"h"+-n+"Z"},toString:function(){return this._}};var Jo=Array.prototype.slice;function ea(e){return function(){return e}}function ta(e){return e.source}function na(e){return e.target}function ra(e){return e.radius}function ia(e){return e.startAngle}function oa(e){return e.endAngle}function aa(){return 0}function sa(){return 10}function la(e){var t=ta,n=na,r=ra,i=ra,o=ia,a=oa,s=aa,l=null;function c(){var c,u=t.apply(this,arguments),f=n.apply(this,arguments),d=s.apply(this,arguments)/2,h=Jo.call(arguments),p=+r.apply(this,(h[0]=u,h)),m=o.apply(this,h)-Fo,g=a.apply(this,h)-Fo,b=+i.apply(this,(h[0]=f,h)),v=o.apply(this,h)-Fo,y=a.apply(this,h)-Fo;if(l||(l=c=$o()),d>Ho&&(Po(g-m)>2*d+Ho?g>m?(m+=d,g-=d):(m-=d,g+=d):m=g=(m+g)/2,Po(y-v)>2*d+Ho?y>v?(v+=d,y-=d):(v-=d,y+=d):v=y=(v+y)/2),l.moveTo(p*jo(m),p*Ro(m)),l.arc(0,0,p,m,g),m!==v||g!==y)if(e){var _=+e.apply(this,arguments),w=b-_,x=(v+y)/2;l.quadraticCurveTo(0,0,w*jo(v),w*Ro(v)),l.lineTo(b*jo(x),b*Ro(x)),l.lineTo(w*jo(y),w*Ro(y))}else l.quadraticCurveTo(0,0,b*jo(v),b*Ro(v)),l.arc(0,0,b,v,y);if(l.quadraticCurveTo(0,0,p*jo(m),p*Ro(m)),l.closePath(),c)return l=null,c+""||null}return e&&(c.headRadius=function(t){return arguments.length?(e="function"==typeof t?t:ea(+t),c):e}),c.radius=function(e){return arguments.length?(r=i="function"==typeof e?e:ea(+e),c):r},c.sourceRadius=function(e){return arguments.length?(r="function"==typeof e?e:ea(+e),c):r},c.targetRadius=function(e){return arguments.length?(i="function"==typeof e?e:ea(+e),c):i},c.startAngle=function(e){return arguments.length?(o="function"==typeof e?e:ea(+e),c):o},c.endAngle=function(e){return arguments.length?(a="function"==typeof e?e:ea(+e),c):a},c.padAngle=function(e){return arguments.length?(s="function"==typeof e?e:ea(+e),c):s},c.source=function(e){return arguments.length?(t=e,c):t},c.target=function(e){return arguments.length?(n=e,c):n},c.context=function(e){return arguments.length?(l=null==e?null:e,c):l},c}var ca=Array.prototype.slice;function ua(e,t){return e-t}var fa=e=>()=>e;function da(e,t){for(var n,r=-1,i=t.length;++rr!=h>r&&n<(d-c)*(r-u)/(h-u)+c&&(i=-i)}return i}function pa(e,t,n){var r,i,o,a;return function(e,t,n){return(t[0]-e[0])*(n[1]-e[1])==(n[0]-e[0])*(t[1]-e[1])}(e,t,n)&&(i=e[r=+(e[0]===t[0])],o=n[r],a=t[r],i<=o&&o<=a||a<=o&&o<=i)}function ma(){}var ga=[[],[[[1,1.5],[.5,1]]],[[[1.5,1],[1,1.5]]],[[[1.5,1],[.5,1]]],[[[1,.5],[1.5,1]]],[[[1,1.5],[.5,1]],[[1,.5],[1.5,1]]],[[[1,.5],[1,1.5]]],[[[1,.5],[.5,1]]],[[[.5,1],[1,.5]]],[[[1,1.5],[1,.5]]],[[[.5,1],[1,.5]],[[1.5,1],[1,1.5]]],[[[1.5,1],[1,.5]]],[[[.5,1],[1.5,1]]],[[[1,1.5],[1.5,1]]],[[[.5,1],[1,1.5]]],[]];function ba(){var e=1,t=1,n=M,r=s;function i(e){var t=n(e);if(Array.isArray(t))t=t.slice().sort(ua);else{var r=p(e),i=r[0],a=r[1];t=k(i,a,t),t=q(Math.floor(i/t)*t,Math.floor(a/t)*t,t)}return t.map((function(t){return o(e,t)}))}function o(n,i){var o=[],s=[];return function(n,r,i){var o,s,l,c,u,f,d=new Array,h=new Array;for(o=s=-1,c=n[0]>=r,ga[c<<1].forEach(p);++o=r,ga[l|c<<1].forEach(p);for(ga[c<<0].forEach(p);++s=r,u=n[s*e]>=r,ga[c<<1|u<<2].forEach(p);++o=r,f=u,u=n[s*e+o+1]>=r,ga[l|c<<1|u<<2|f<<3].forEach(p);ga[c|u<<3].forEach(p)}for(o=-1,u=n[s*e]>=r,ga[u<<2].forEach(p);++o=r,ga[u<<2|f<<3].forEach(p);function p(e){var t,n,r=[e[0][0]+o,e[0][1]+s],l=[e[1][0]+o,e[1][1]+s],c=a(r),u=a(l);(t=h[c])?(n=d[u])?(delete h[t.end],delete d[n.start],t===n?(t.ring.push(l),i(t.ring)):d[t.start]=h[n.end]={start:t.start,end:n.end,ring:t.ring.concat(n.ring)}):(delete h[t.end],t.ring.push(l),h[t.end=u]=t):(t=d[u])?(n=h[c])?(delete d[t.start],delete h[n.end],t===n?(t.ring.push(l),i(t.ring)):d[n.start]=h[t.end]={start:n.start,end:t.end,ring:n.ring.concat(t.ring)}):(delete d[t.start],t.ring.unshift(r),d[t.start=c]=t):d[c]=h[u]={start:c,end:u,ring:[r,l]}}ga[u<<3].forEach(p)}(n,i,(function(e){r(e,n,i),function(e){for(var t=0,n=e.length,r=e[n-1][1]*e[0][0]-e[n-1][0]*e[0][1];++t0?o.push([e]):s.push(e)})),s.forEach((function(e){for(var t,n=0,r=o.length;n0&&a0&&s=0&&o>=0))throw new Error("invalid size");return e=r,t=o,i},i.thresholds=function(e){return arguments.length?(n="function"==typeof e?e:Array.isArray(e)?fa(ca.call(e)):fa(e),i):n},i.smooth=function(e){return arguments.length?(r=e?s:ma,i):r===s},i}function va(e,t,n){for(var r=e.width,i=e.height,o=1+(n<<1),a=0;a=n&&(s>=o&&(l-=e.data[s-o+a*r]),t.data[s-n+a*r]=l/Math.min(s+1,r-1+o-s,o))}function ya(e,t,n){for(var r=e.width,i=e.height,o=1+(n<<1),a=0;a=n&&(s>=o&&(l-=e.data[a+(s-o)*r]),t.data[a+(s-n)*r]=l/Math.min(s+1,i-1+o-s,o))}function _a(e){return e[0]}function wa(e){return e[1]}function xa(){return 1}const Ta=Math.pow(2,-52),Aa=new Uint32Array(512);class Ea{static from(e,t=Oa,n=Ia){const r=e.length,i=new Float64Array(2*r);for(let o=0;o>1;if(t>0&&"number"!=typeof e[0])throw new Error("Expected coords to contain numbers.");this.coords=e;const n=Math.max(2*t-5,0);this._triangles=new Uint32Array(3*n),this._halfedges=new Int32Array(3*n),this._hashSize=Math.ceil(Math.sqrt(t)),this._hullPrev=new Uint32Array(t),this._hullNext=new Uint32Array(t),this._hullTri=new Uint32Array(t),this._hullHash=new Int32Array(this._hashSize).fill(-1),this._ids=new Uint32Array(t),this._dists=new Float64Array(t),this.update()}update(){const{coords:e,_hullPrev:t,_hullNext:n,_hullTri:r,_hullHash:i}=this,o=e.length>>1;let a=1/0,s=1/0,l=-1/0,c=-1/0;for(let t=0;tl&&(l=n),r>c&&(c=r),this._ids[t]=t}const u=(a+l)/2,f=(s+c)/2;let d,h,p,m=1/0;for(let t=0;t0&&(h=t,m=n)}let v=e[2*h],y=e[2*h+1],_=1/0;for(let t=0;tr&&(t[n++]=i,r=this._dists[i])}return this.hull=t.subarray(0,n),this.triangles=new Uint32Array(0),void(this.halfedges=new Uint32Array(0))}if(Ma(g,b,v,y,w,x)){const e=h,t=v,n=y;h=p,v=w,y=x,p=e,w=t,x=n}const T=function(e,t,n,r,i,o){const a=n-e,s=r-t,l=i-e,c=o-t,u=a*a+s*s,f=l*l+c*c,d=.5/(a*c-s*l);return{x:e+(c*u-s*f)*d,y:t+(a*f-l*u)*d}}(g,b,v,y,w,x);this._cx=T.x,this._cy=T.y;for(let t=0;t0&&Math.abs(c-o)<=Ta&&Math.abs(u-a)<=Ta)continue;if(o=c,a=u,l===d||l===h||l===p)continue;let f=0;for(let e=0,t=this._hashKey(c,u);e0?3-n:1+n)/4}(e-this._cx,t-this._cy)*this._hashSize)%this._hashSize}_legalize(e){const{_triangles:t,_halfedges:n,coords:r}=this;let i=0,o=0;for(;;){const a=n[e],s=e-e%3;if(o=s+(e+2)%3,-1===a){if(0===i)break;e=Aa[--i];continue}const l=a-a%3,c=s+(e+1)%3,u=l+(a+2)%3,f=t[o],d=t[e],h=t[c],p=t[u];if(Ca(r[2*f],r[2*f+1],r[2*d],r[2*d+1],r[2*h],r[2*h+1],r[2*p],r[2*p+1])){t[e]=p,t[a]=f;const r=n[u];if(-1===r){let t=this._hullStart;do{if(this._hullTri[t]===u){this._hullTri[t]=e;break}t=this._hullPrev[t]}while(t!==this._hullStart)}this._link(e,r),this._link(a,n[o]),this._link(o,u);const s=l+(a+1)%3;i=33306690738754716e-32*Math.abs(a+s)?a-s:0}function Ma(e,t,n,r,i,o){return(Sa(i,o,e,t,n,r)||Sa(e,t,n,r,i,o)||Sa(n,r,i,o,e,t))<0}function Ca(e,t,n,r,i,o,a,s){const l=e-a,c=t-s,u=n-a,f=r-s,d=i-a,h=o-s,p=u*u+f*f,m=d*d+h*h;return l*(f*m-p*h)-c*(u*m-p*d)+(l*l+c*c)*(u*h-f*d)<0}function Na(e,t,n,r,i,o){const a=n-e,s=r-t,l=i-e,c=o-t,u=a*a+s*s,f=l*l+c*c,d=.5/(a*c-s*l),h=(c*u-s*f)*d,p=(a*f-l*u)*d;return h*h+p*p}function Da(e,t,n,r){if(r-n<=20)for(let i=n+1;i<=r;i++){const r=e[i],o=t[r];let a=i-1;for(;a>=n&&t[e[a]]>o;)e[a+1]=e[a--];e[a+1]=r}else{let i=n+1,o=r;La(e,n+r>>1,i),t[e[n]]>t[e[r]]&&La(e,n,r),t[e[i]]>t[e[r]]&&La(e,i,r),t[e[n]]>t[e[i]]&&La(e,n,i);const a=e[i],s=t[a];for(;;){do{i++}while(t[e[i]]s);if(o=o-n?(Da(e,t,i,r),Da(e,t,n,o-1)):(Da(e,t,n,o-1),Da(e,t,i,r))}}function La(e,t,n){const r=e[t];e[t]=e[n],e[n]=r}function Oa(e){return e[0]}function Ia(e){return e[1]}const Ba=1e-6;class Pa{constructor(){this._x0=this._y0=this._x1=this._y1=null,this._=""}moveTo(e,t){this._+=`M${this._x0=this._x1=+e},${this._y0=this._y1=+t}`}closePath(){null!==this._x1&&(this._x1=this._x0,this._y1=this._y0,this._+="Z")}lineTo(e,t){this._+=`L${this._x1=+e},${this._y1=+t}`}arc(e,t,n){const r=(e=+e)+(n=+n),i=t=+t;if(n<0)throw new Error("negative radius");null===this._x1?this._+=`M${r},${i}`:(Math.abs(this._x1-r)>Ba||Math.abs(this._y1-i)>Ba)&&(this._+="L"+r+","+i),n&&(this._+=`A${n},${n},0,1,1,${e-n},${t}A${n},${n},0,1,1,${this._x1=r},${this._y1=i}`)}rect(e,t,n,r){this._+=`M${this._x0=this._x1=+e},${this._y0=this._y1=+t}h${+n}v${+r}h${-n}Z`}value(){return this._||null}}class ja{constructor(){this._=[]}moveTo(e,t){this._.push([e,t])}closePath(){this._.push(this._[0].slice())}lineTo(e,t){this._.push([e,t])}value(){return this._.length?this._:null}}class Ra{constructor(e,[t,n,r,i]=[0,0,960,500]){if(!((r=+r)>=(t=+t)&&(i=+i)>=(n=+n)))throw new Error("invalid bounds");this.delaunay=e,this._circumcenters=new Float64Array(2*e.points.length),this.vectors=new Float64Array(2*e.points.length),this.xmax=r,this.xmin=t,this.ymax=i,this.ymin=n,this._init()}update(){return this.delaunay.update(),this._init(),this}_init(){const{delaunay:{points:e,hull:t,triangles:n},vectors:r}=this,i=this.circumcenters=this._circumcenters.subarray(0,n.length/3*2);for(let t,r,o=0,a=0,s=n.length;o1;)i-=2;for(let e=2;e4)for(let e=0;e0){if(t>=this.ymax)return null;(i=(this.ymax-t)/r)0){if(e>=this.xmax)return null;(i=(this.xmax-e)/n)this.xmax?2:0)|(tthis.ymax?8:0)}}const za=2*Math.PI,Fa=Math.pow;function qa(e){return e[0]}function Ua(e){return e[1]}function Ha(e,t,n){return[e+Math.sin(e+t)*n,t+Math.cos(e-t)*n]}class Va{static from(e,t=qa,n=Ua,r){return new Va("length"in e?function(e,t,n,r){const i=e.length,o=new Float64Array(2*i);for(let a=0;a2&&function(e){const{triangles:t,coords:n}=e;for(let e=0;e1e-10)return!1}return!0}(e)){this.collinear=Int32Array.from({length:t.length/2},((e,t)=>t)).sort(((e,n)=>t[2*e]-t[2*n]||t[2*e+1]-t[2*n+1]));const e=this.collinear[0],n=this.collinear[this.collinear.length-1],r=[t[2*e],t[2*e+1],t[2*n],t[2*n+1]],i=1e-8*Math.hypot(r[3]-r[1],r[2]-r[0]);for(let e=0,n=t.length/2;e0&&(this.triangles=new Int32Array(3).fill(-1),this.halfedges=new Int32Array(3).fill(-1),this.triangles[0]=r[0],this.triangles[1]=r[1],this.triangles[2]=r[1],o[r[0]]=1,2===r.length&&(o[r[1]]=0))}voronoi(e){return new Ra(this,e)}*neighbors(e){const{inedges:t,hull:n,_hullIndex:r,halfedges:i,triangles:o,collinear:a}=this;if(a){const t=a.indexOf(e);return t>0&&(yield a[t-1]),void(t=0&&i!==n&&i!==r;)n=i;return i}_step(e,t,n){const{inedges:r,hull:i,_hullIndex:o,halfedges:a,triangles:s,points:l}=this;if(-1===r[e]||!l.length)return(e+1)%(l.length>>1);let c=e,u=Fa(t-l[2*e],2)+Fa(n-l[2*e+1],2);const f=r[e];let d=f;do{let r=s[d];const f=Fa(t-l[2*r],2)+Fa(n-l[2*r+1],2);if(f=o?l=!0:10===(r=e.charCodeAt(a++))?c=!0:13===r&&(c=!0,10===e.charCodeAt(a)&&++a),e.slice(i+1,t-1).replace(/""/g,'"')}for(;a9999?"+"+Ka(e,6):Ka(e,4)}(e.getUTCFullYear())+"-"+Ka(e.getUTCMonth()+1,2)+"-"+Ka(e.getUTCDate(),2)+(i?"T"+Ka(t,2)+":"+Ka(n,2)+":"+Ka(r,2)+"."+Ka(i,3)+"Z":r?"T"+Ka(t,2)+":"+Ka(n,2)+":"+Ka(r,2)+"Z":n||t?"T"+Ka(t,2)+":"+Ka(n,2)+"Z":"")}(e):t.test(e+="")?'"'+e.replace(/"/g,'""')+'"':e}return{parse:function(e,t){var n,i,o=r(e,(function(e,r){if(n)return n(e,r-1);i=e,n=t?function(e,t){var n=Ya(e);return function(r,i){return t(n(r),i,e)}}(e,t):Ya(e)}));return o.columns=i||[],o},parseRows:r,format:function(t,n){return null==n&&(n=Za(t)),[n.map(a).join(e)].concat(i(t,n)).join("\n")},formatBody:function(e,t){return null==t&&(t=Za(e)),i(e,t).join("\n")},formatRows:function(e){return e.map(o).join("\n")},formatRow:o,formatValue:a}}var Qa=Xa(","),$a=Qa.parse,Ja=Qa.parseRows,es=Qa.format,ts=Qa.formatBody,ns=Qa.formatRows,rs=Qa.formatRow,is=Qa.formatValue,os=Xa("\t"),as=os.parse,ss=os.parseRows,ls=os.format,cs=os.formatBody,us=os.formatRows,fs=os.formatRow,ds=os.formatValue;const hs=new Date("2019-01-01T00:00").getHours()||new Date("2019-07-01T00:00").getHours();function ps(e){if(!e.ok)throw new Error(e.status+" "+e.statusText);return e.blob()}function ms(e){if(!e.ok)throw new Error(e.status+" "+e.statusText);return e.arrayBuffer()}function gs(e){if(!e.ok)throw new Error(e.status+" "+e.statusText);return e.text()}function bs(e,t){return fetch(e,t).then(gs)}function vs(e){return function(t,n,r){return 2===arguments.length&&"function"==typeof n&&(r=n,n=void 0),bs(t,n).then((function(t){return e(t,r)}))}}var ys=vs($a),_s=vs(as);function ws(e){if(!e.ok)throw new Error(e.status+" "+e.statusText);if(204!==e.status&&205!==e.status)return e.json()}function xs(e){return(t,n)=>bs(t,n).then((t=>(new DOMParser).parseFromString(t,e)))}var Ts=xs("application/xml"),As=xs("text/html"),Es=xs("image/svg+xml");function ks(e,t,n,r){if(isNaN(t)||isNaN(n))return e;var i,o,a,s,l,c,u,f,d,h=e._root,p={data:r},m=e._x0,g=e._y0,b=e._x1,v=e._y1;if(!h)return e._root=p,e;for(;h.length;)if((c=t>=(o=(m+b)/2))?m=o:b=o,(u=n>=(a=(g+v)/2))?g=a:v=a,i=h,!(h=h[f=u<<1|c]))return i[f]=p,e;if(s=+e._x.call(null,h.data),l=+e._y.call(null,h.data),t===s&&n===l)return p.next=h,i?i[f]=p:e._root=p,e;do{i=i?i[f]=new Array(4):e._root=new Array(4),(c=t>=(o=(m+b)/2))?m=o:b=o,(u=n>=(a=(g+v)/2))?g=a:v=a}while((f=u<<1|c)==(d=(l>=a)<<1|s>=o));return i[d]=h,i[f]=p,e}function Ss(e,t,n,r,i){this.node=e,this.x0=t,this.y0=n,this.x1=r,this.y1=i}function Ms(e){return e[0]}function Cs(e){return e[1]}function Ns(e,t,n){var r=new Ds(null==t?Ms:t,null==n?Cs:n,NaN,NaN,NaN,NaN);return null==e?r:r.addAll(e)}function Ds(e,t,n,r,i,o){this._x=e,this._y=t,this._x0=n,this._y0=r,this._x1=i,this._y1=o,this._root=void 0}function Ls(e){for(var t={data:e.data},n=t;e=e.next;)n=n.next={data:e.data};return t}var Os=Ns.prototype=Ds.prototype;function Is(e){return function(){return e}}function Bs(e){return 1e-6*(e()-.5)}function Ps(e){return e.x+e.vx}function js(e){return e.y+e.vy}function Rs(e){return e.index}function zs(e,t){var n=e.get(t);if(!n)throw new Error("node not found: "+t);return n}Os.copy=function(){var e,t,n=new Ds(this._x,this._y,this._x0,this._y0,this._x1,this._y1),r=this._root;if(!r)return n;if(!r.length)return n._root=Ls(r),n;for(e=[{source:r,target:n._root=new Array(4)}];r=e.pop();)for(var i=0;i<4;++i)(t=r.source[i])&&(t.length?e.push({source:t,target:r.target[i]=new Array(4)}):r.target[i]=Ls(t));return n},Os.add=function(e){const t=+this._x.call(null,e),n=+this._y.call(null,e);return ks(this.cover(t,n),t,n,e)},Os.addAll=function(e){var t,n,r,i,o=e.length,a=new Array(o),s=new Array(o),l=1/0,c=1/0,u=-1/0,f=-1/0;for(n=0;nu&&(u=r),if&&(f=i));if(l>u||c>f)return this;for(this.cover(l,c).cover(u,f),n=0;ne||e>=i||r>t||t>=o;)switch(s=(td||(o=l.y0)>h||(a=l.x1)=b)<<1|e>=g)&&(l=p[p.length-1],p[p.length-1]=p[p.length-1-c],p[p.length-1-c]=l)}else{var v=e-+this._x.call(null,m.data),y=t-+this._y.call(null,m.data),_=v*v+y*y;if(_=(s=(p+g)/2))?p=s:g=s,(u=a>=(l=(m+b)/2))?m=l:b=l,t=h,!(h=h[f=u<<1|c]))return this;if(!h.length)break;(t[f+1&3]||t[f+2&3]||t[f+3&3])&&(n=t,d=f)}for(;h.data!==e;)if(r=h,!(h=h.next))return this;return(i=h.next)&&delete h.next,r?(i?r.next=i:delete r.next,this):t?(i?t[f]=i:delete t[f],(h=t[0]||t[1]||t[2]||t[3])&&h===(t[3]||t[2]||t[1]||t[0])&&!h.length&&(n?n[d]=h:this._root=h),this):(this._root=i,this)},Os.removeAll=function(e){for(var t=0,n=e.length;t1?r[0]+r.slice(2):r,+e.slice(n+1)]}function Gs(e){return(e=Vs(Math.abs(e)))?e[1]:NaN}var Ws,Ys=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function Zs(e){if(!(t=Ys.exec(e)))throw new Error("invalid format: "+e);var t;return new Ks({fill:t[1],align:t[2],sign:t[3],symbol:t[4],zero:t[5],width:t[6],comma:t[7],precision:t[8]&&t[8].slice(1),trim:t[9],type:t[10]})}function Ks(e){this.fill=void 0===e.fill?" ":e.fill+"",this.align=void 0===e.align?">":e.align+"",this.sign=void 0===e.sign?"-":e.sign+"",this.symbol=void 0===e.symbol?"":e.symbol+"",this.zero=!!e.zero,this.width=void 0===e.width?void 0:+e.width,this.comma=!!e.comma,this.precision=void 0===e.precision?void 0:+e.precision,this.trim=!!e.trim,this.type=void 0===e.type?"":e.type+""}function Xs(e,t){var n=Vs(e,t);if(!n)return e+"";var r=n[0],i=n[1];return i<0?"0."+new Array(-i).join("0")+r:r.length>i+1?r.slice(0,i+1)+"."+r.slice(i+1):r+new Array(i-r.length+2).join("0")}Zs.prototype=Ks.prototype,Ks.prototype.toString=function(){return this.fill+this.align+this.sign+this.symbol+(this.zero?"0":"")+(void 0===this.width?"":Math.max(1,0|this.width))+(this.comma?",":"")+(void 0===this.precision?"":"."+Math.max(0,0|this.precision))+(this.trim?"~":"")+this.type};var Qs={"%":(e,t)=>(100*e).toFixed(t),b:e=>Math.round(e).toString(2),c:e=>e+"",d:function(e){return Math.abs(e=Math.round(e))>=1e21?e.toLocaleString("en").replace(/,/g,""):e.toString(10)},e:(e,t)=>e.toExponential(t),f:(e,t)=>e.toFixed(t),g:(e,t)=>e.toPrecision(t),o:e=>Math.round(e).toString(8),p:(e,t)=>Xs(100*e,t),r:Xs,s:function(e,t){var n=Vs(e,t);if(!n)return e+"";var r=n[0],i=n[1],o=i-(Ws=3*Math.max(-8,Math.min(8,Math.floor(i/3))))+1,a=r.length;return o===a?r:o>a?r+new Array(o-a+1).join("0"):o>0?r.slice(0,o)+"."+r.slice(o):"0."+new Array(1-o).join("0")+Vs(e,Math.max(0,t+o-1))[0]},X:e=>Math.round(e).toString(16).toUpperCase(),x:e=>Math.round(e).toString(16)};function $s(e){return e}var Js,el=Array.prototype.map,tl=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function nl(e){var t,n,r=void 0===e.grouping||void 0===e.thousands?$s:(t=el.call(e.grouping,Number),n=e.thousands+"",function(e,r){for(var i=e.length,o=[],a=0,s=t[0],l=0;i>0&&s>0&&(l+s+1>r&&(s=Math.max(1,r-l)),o.push(e.substring(i-=s,i+s)),!((l+=s+1)>r));)s=t[a=(a+1)%t.length];return o.reverse().join(n)}),i=void 0===e.currency?"":e.currency[0]+"",o=void 0===e.currency?"":e.currency[1]+"",a=void 0===e.decimal?".":e.decimal+"",s=void 0===e.numerals?$s:function(e){return function(t){return t.replace(/[0-9]/g,(function(t){return e[+t]}))}}(el.call(e.numerals,String)),l=void 0===e.percent?"%":e.percent+"",c=void 0===e.minus?"−":e.minus+"",u=void 0===e.nan?"NaN":e.nan+"";function f(e){var t=(e=Zs(e)).fill,n=e.align,f=e.sign,d=e.symbol,h=e.zero,p=e.width,m=e.comma,g=e.precision,b=e.trim,v=e.type;"n"===v?(m=!0,v="g"):Qs[v]||(void 0===g&&(g=12),b=!0,v="g"),(h||"0"===t&&"="===n)&&(h=!0,t="0",n="=");var y="$"===d?i:"#"===d&&/[boxX]/.test(v)?"0"+v.toLowerCase():"",_="$"===d?o:/[%p]/.test(v)?l:"",w=Qs[v],x=/[defgprs%]/.test(v);function T(e){var i,o,l,d=y,T=_;if("c"===v)T=w(e)+T,e="";else{var A=(e=+e)<0||1/e<0;if(e=isNaN(e)?u:w(Math.abs(e),g),b&&(e=function(e){e:for(var t,n=e.length,r=1,i=-1;r0&&(i=0)}return i>0?e.slice(0,i)+e.slice(t+1):e}(e)),A&&0==+e&&"+"!==f&&(A=!1),d=(A?"("===f?f:c:"-"===f||"("===f?"":f)+d,T=("s"===v?tl[8+Ws/3]:"")+T+(A&&"("===f?")":""),x)for(i=-1,o=e.length;++i(l=e.charCodeAt(i))||l>57){T=(46===l?a+e.slice(i+1):e.slice(i))+T,e=e.slice(0,i);break}}m&&!h&&(e=r(e,1/0));var E=d.length+e.length+T.length,k=E>1)+d+e+T+k.slice(E);break;default:e=k+d+e+T}return s(e)}return g=void 0===g?6:/[gprs]/.test(v)?Math.max(1,Math.min(21,g)):Math.max(0,Math.min(20,g)),T.toString=function(){return e+""},T}return{format:f,formatPrefix:function(e,t){var n=f(((e=Zs(e)).type="f",e)),r=3*Math.max(-8,Math.min(8,Math.floor(Gs(t)/3))),i=Math.pow(10,-r),o=tl[8+r/3];return function(e){return n(i*e)+o}}}}function rl(t){return Js=nl(t),e.format=Js.format,e.formatPrefix=Js.formatPrefix,Js}function il(e){return Math.max(0,-Gs(Math.abs(e)))}function ol(e,t){return Math.max(0,3*Math.max(-8,Math.min(8,Math.floor(Gs(t)/3)))-Gs(Math.abs(e)))}function al(e,t){return e=Math.abs(e),t=Math.abs(t)-e,Math.max(0,Gs(t)-Gs(e))+1}rl({thousands:",",grouping:[3],currency:["$",""]});var sl=1e-6,ll=1e-12,cl=Math.PI,ul=cl/2,fl=cl/4,dl=2*cl,hl=180/cl,pl=cl/180,ml=Math.abs,gl=Math.atan,bl=Math.atan2,vl=Math.cos,yl=Math.ceil,_l=Math.exp,wl=Math.hypot,xl=Math.log,Tl=Math.pow,Al=Math.sin,El=Math.sign||function(e){return e>0?1:e<0?-1:0},kl=Math.sqrt,Sl=Math.tan;function Ml(e){return e>1?0:e<-1?cl:Math.acos(e)}function Cl(e){return e>1?ul:e<-1?-ul:Math.asin(e)}function Nl(e){return(e=Al(e/2))*e}function Dl(){}function Ll(e,t){e&&Il.hasOwnProperty(e.type)&&Il[e.type](e,t)}var Ol={Feature:function(e,t){Ll(e.geometry,t)},FeatureCollection:function(e,t){for(var n=e.features,r=-1,i=n.length;++r=0?1:-1,i=r*n,o=vl(t=(t*=pl)/2+fl),a=Al(t),s=Ul*a,l=ql*o+s*vl(i),c=s*r*Al(i);ec.add(bl(c,l)),Fl=e,ql=o,Ul=a}function sc(e){return[bl(e[1],e[0]),Cl(e[2])]}function lc(e){var t=e[0],n=e[1],r=vl(n);return[r*vl(t),r*Al(t),Al(n)]}function cc(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]}function uc(e,t){return[e[1]*t[2]-e[2]*t[1],e[2]*t[0]-e[0]*t[2],e[0]*t[1]-e[1]*t[0]]}function fc(e,t){e[0]+=t[0],e[1]+=t[1],e[2]+=t[2]}function dc(e,t){return[e[0]*t,e[1]*t,e[2]*t]}function hc(e){var t=kl(e[0]*e[0]+e[1]*e[1]+e[2]*e[2]);e[0]/=t,e[1]/=t,e[2]/=t}var pc,mc,gc,bc,vc,yc,_c,wc,xc,Tc,Ac,Ec,kc,Sc,Mc,Cc,Nc={point:Dc,lineStart:Oc,lineEnd:Ic,polygonStart:function(){Nc.point=Bc,Nc.lineStart=Pc,Nc.lineEnd=jc,Ql=new m,nc.polygonStart()},polygonEnd:function(){nc.polygonEnd(),Nc.point=Dc,Nc.lineStart=Oc,Nc.lineEnd=Ic,ec<0?(Hl=-(Gl=180),Vl=-(Wl=90)):Ql>sl?Wl=90:Ql<-1e-6&&(Vl=-90),Jl[0]=Hl,Jl[1]=Gl},sphere:function(){Hl=-(Gl=180),Vl=-(Wl=90)}};function Dc(e,t){$l.push(Jl=[Hl=e,Gl=e]),tWl&&(Wl=t)}function Lc(e,t){var n=lc([e*pl,t*pl]);if(Xl){var r=uc(Xl,n),i=uc([r[1],-r[0],0],r);hc(i),i=sc(i);var o,a=e-Yl,s=a>0?1:-1,l=i[0]*hl*s,c=ml(a)>180;c^(s*YlWl&&(Wl=o):c^(s*Yl<(l=(l+360)%360-180)&&lWl&&(Wl=t)),c?eRc(Hl,Gl)&&(Gl=e):Rc(e,Gl)>Rc(Hl,Gl)&&(Hl=e):Gl>=Hl?(eGl&&(Gl=e)):e>Yl?Rc(Hl,e)>Rc(Hl,Gl)&&(Gl=e):Rc(e,Gl)>Rc(Hl,Gl)&&(Hl=e)}else $l.push(Jl=[Hl=e,Gl=e]);tWl&&(Wl=t),Xl=n,Yl=e}function Oc(){Nc.point=Lc}function Ic(){Jl[0]=Hl,Jl[1]=Gl,Nc.point=Dc,Xl=null}function Bc(e,t){if(Xl){var n=e-Yl;Ql.add(ml(n)>180?n+(n>0?360:-360):n)}else Zl=e,Kl=t;nc.point(e,t),Lc(e,t)}function Pc(){nc.lineStart()}function jc(){Bc(Zl,Kl),nc.lineEnd(),ml(Ql)>sl&&(Hl=-(Gl=180)),Jl[0]=Hl,Jl[1]=Gl,Xl=null}function Rc(e,t){return(t-=e)<0?t+360:t}function zc(e,t){return e[0]-t[0]}function Fc(e,t){return e[0]<=e[1]?e[0]<=t&&t<=e[1]:tcl?e+Math.round(-e/dl)*dl:e,t]}function tu(e,t,n){return(e%=dl)?t||n?Jc(ru(e),iu(t,n)):ru(e):t||n?iu(t,n):eu}function nu(e){return function(t,n){return[(t+=e)>cl?t-dl:t<-cl?t+dl:t,n]}}function ru(e){var t=nu(e);return t.invert=nu(-e),t}function iu(e,t){var n=vl(e),r=Al(e),i=vl(t),o=Al(t);function a(e,t){var a=vl(t),s=vl(e)*a,l=Al(e)*a,c=Al(t),u=c*n+s*r;return[bl(l*i-u*o,s*n-c*r),Cl(u*i+l*o)]}return a.invert=function(e,t){var a=vl(t),s=vl(e)*a,l=Al(e)*a,c=Al(t),u=c*i-l*o;return[bl(l*i+c*o,s*n+u*r),Cl(u*n-s*r)]},a}function ou(e){function t(t){return(t=e(t[0]*pl,t[1]*pl))[0]*=hl,t[1]*=hl,t}return e=tu(e[0]*pl,e[1]*pl,e.length>2?e[2]*pl:0),t.invert=function(t){return(t=e.invert(t[0]*pl,t[1]*pl))[0]*=hl,t[1]*=hl,t},t}function au(e,t,n,r,i,o){if(n){var a=vl(t),s=Al(t),l=r*n;null==i?(i=t+r*dl,o=t-l/2):(i=su(a,i),o=su(a,o),(r>0?io)&&(i+=r*dl));for(var c,u=i;r>0?u>o:u1&&t.push(t.pop().concat(t.shift()))},result:function(){var n=t;return t=[],e=null,n}}}function cu(e,t){return ml(e[0]-t[0])=0;--o)i.point((u=c[o])[0],u[1]);else r(d.x,d.p.x,-1,i);d=d.p}c=(d=d.o).z,h=!h}while(!d.v);i.lineEnd()}}}function du(e){if(t=e.length){for(var t,n,r=0,i=e[0];++r=0?1:-1,S=k*E,M=S>cl,C=b*T;if(l.add(bl(C*k*Al(S),v*A+C*vl(S))),a+=M?E+k*dl:E,M^p>=n^w>=n){var N=uc(lc(h),lc(_));hc(N);var D=uc(o,N);hc(D);var L=(M^E>=0?-1:1)*Cl(D[2]);(r>L||r===L&&(N[0]||N[1]))&&(s+=M^E>=0?1:-1)}}return(a<-1e-6||a0){for(f||(i.polygonStart(),f=!0),i.lineStart(),e=0;e1&&2&l&&d.push(d.pop().concat(d.shift())),a.push(d.filter(gu))}return d}}function gu(e){return e.length>1}function bu(e,t){return((e=e.x)[0]<0?e[1]-ul-sl:ul-e[1])-((t=t.x)[0]<0?t[1]-ul-sl:ul-t[1])}eu.invert=eu;var vu=mu((function(){return!0}),(function(e){var t,n=NaN,r=NaN,i=NaN;return{lineStart:function(){e.lineStart(),t=1},point:function(o,a){var s=o>0?cl:-cl,l=ml(o-n);ml(l-cl)0?ul:-ul),e.point(i,r),e.lineEnd(),e.lineStart(),e.point(s,r),e.point(o,r),t=0):i!==s&&l>=cl&&(ml(n-i)sl?gl((Al(t)*(o=vl(r))*Al(n)-Al(r)*(i=vl(t))*Al(e))/(i*o*a)):(t+r)/2}(n,r,o,a),e.point(i,r),e.lineEnd(),e.lineStart(),e.point(s,r),t=0),e.point(n=o,r=a),i=s},lineEnd:function(){e.lineEnd(),n=r=NaN},clean:function(){return 2-t}}}),(function(e,t,n,r){var i;if(null==e)i=n*ul,r.point(-cl,i),r.point(0,i),r.point(cl,i),r.point(cl,0),r.point(cl,-i),r.point(0,-i),r.point(-cl,-i),r.point(-cl,0),r.point(-cl,i);else if(ml(e[0]-t[0])>sl){var o=e[0]0,i=ml(t)>sl;function o(e,n){return vl(e)*vl(n)>t}function a(e,n,r){var i=[1,0,0],o=uc(lc(e),lc(n)),a=cc(o,o),s=o[0],l=a-s*s;if(!l)return!r&&e;var c=t*a/l,u=-t*s/l,f=uc(i,o),d=dc(i,c);fc(d,dc(o,u));var h=f,p=cc(d,h),m=cc(h,h),g=p*p-m*(cc(d,d)-1);if(!(g<0)){var b=kl(g),v=dc(h,(-p-b)/m);if(fc(v,d),v=sc(v),!r)return v;var y,_=e[0],w=n[0],x=e[1],T=n[1];w<_&&(y=_,_=w,w=y);var A=w-_,E=ml(A-cl)0^v[1]<(ml(v[0]-_)cl^(_<=v[0]&&v[0]<=w)){var k=dc(h,(-p+b)/m);return fc(k,d),[v,sc(k)]}}}function s(t,n){var i=r?e:cl-e,o=0;return t<-i?o|=1:t>i&&(o|=2),n<-i?o|=4:n>i&&(o|=8),o}return mu(o,(function(e){var t,n,l,c,u;return{lineStart:function(){c=l=!1,u=1},point:function(f,d){var h,p=[f,d],m=o(f,d),g=r?m?0:s(f,d):m?s(f+(f<0?cl:-cl),d):0;if(!t&&(c=l=m)&&e.lineStart(),m!==l&&(!(h=a(t,p))||cu(t,h)||cu(p,h))&&(p[2]=1),m!==l)u=0,m?(e.lineStart(),h=a(p,t),e.point(h[0],h[1])):(h=a(t,p),e.point(h[0],h[1],2),e.lineEnd()),t=h;else if(i&&t&&r^m){var b;g&n||!(b=a(p,t,!0))||(u=0,r?(e.lineStart(),e.point(b[0][0],b[0][1]),e.point(b[1][0],b[1][1]),e.lineEnd()):(e.point(b[1][0],b[1][1]),e.lineEnd(),e.lineStart(),e.point(b[0][0],b[0][1],3)))}!m||t&&cu(t,p)||e.point(p[0],p[1]),t=p,l=m,n=g},lineEnd:function(){l&&e.lineEnd(),t=null},clean:function(){return u|(c&&l)<<1}}}),(function(t,r,i,o){au(o,e,n,i,t,r)}),r?[0,-e]:[-cl,e-cl])}var _u,wu,xu,Tu,Au=1e9,Eu=-Au;function ku(e,t,n,r){function i(i,o){return e<=i&&i<=n&&t<=o&&o<=r}function o(i,o,s,c){var u=0,f=0;if(null==i||(u=a(i,s))!==(f=a(o,s))||l(i,o)<0^s>0)do{c.point(0===u||3===u?e:n,u>1?r:t)}while((u=(u+s+4)%4)!==f);else c.point(o[0],o[1])}function a(r,i){return ml(r[0]-e)0?0:3:ml(r[0]-n)0?2:1:ml(r[1]-t)0?1:0:i>0?3:2}function s(e,t){return l(e.x,t.x)}function l(e,t){var n=a(e,1),r=a(t,1);return n!==r?n-r:0===n?t[1]-e[1]:1===n?e[0]-t[0]:2===n?e[1]-t[1]:t[0]-e[0]}return function(a){var l,c,u,f,d,h,p,m,g,b,v,y=a,_=lu(),w={point:x,lineStart:function(){w.point=T,c&&c.push(u=[]),b=!0,g=!1,p=m=NaN},lineEnd:function(){l&&(T(f,d),h&&g&&_.rejoin(),l.push(_.result())),w.point=x,g&&y.lineEnd()},polygonStart:function(){y=_,l=[],c=[],v=!0},polygonEnd:function(){var t=function(){for(var t=0,n=0,i=c.length;nr&&(d-o)*(r-a)>(h-a)*(e-o)&&++t:h<=r&&(d-o)*(r-a)<(h-a)*(e-o)&&--t;return t}(),n=v&&t,i=(l=j(l)).length;(n||i)&&(a.polygonStart(),n&&(a.lineStart(),o(null,null,1,a),a.lineEnd()),i&&fu(l,s,t,o,a),a.polygonEnd()),y=a,l=c=u=null}};function x(e,t){i(e,t)&&y.point(e,t)}function T(o,a){var s=i(o,a);if(c&&u.push([o,a]),b)f=o,d=a,h=s,b=!1,s&&(y.lineStart(),y.point(o,a));else if(s&&g)y.point(o,a);else{var l=[p=Math.max(Eu,Math.min(Au,p)),m=Math.max(Eu,Math.min(Au,m))],_=[o=Math.max(Eu,Math.min(Au,o)),a=Math.max(Eu,Math.min(Au,a))];!function(e,t,n,r,i,o){var a,s=e[0],l=e[1],c=0,u=1,f=t[0]-s,d=t[1]-l;if(a=n-s,f||!(a>0)){if(a/=f,f<0){if(a0){if(a>u)return;a>c&&(c=a)}if(a=i-s,f||!(a<0)){if(a/=f,f<0){if(a>u)return;a>c&&(c=a)}else if(f>0){if(a0)){if(a/=d,d<0){if(a0){if(a>u)return;a>c&&(c=a)}if(a=o-l,d||!(a<0)){if(a/=d,d<0){if(a>u)return;a>c&&(c=a)}else if(d>0){if(a0&&(e[0]=s+c*f,e[1]=l+c*d),u<1&&(t[0]=s+u*f,t[1]=l+u*d),!0}}}}}(l,_,e,t,n,r)?s&&(y.lineStart(),y.point(o,a),v=!1):(g||(y.lineStart(),y.point(l[0],l[1])),y.point(_[0],_[1]),s||y.lineEnd(),v=!1)}p=o,m=a,g=s}return w}}var Su={sphere:Dl,point:Dl,lineStart:function(){Su.point=Cu,Su.lineEnd=Mu},lineEnd:Dl,polygonStart:Dl,polygonEnd:Dl};function Mu(){Su.point=Su.lineEnd=Dl}function Cu(e,t){wu=e*=pl,xu=Al(t*=pl),Tu=vl(t),Su.point=Nu}function Nu(e,t){e*=pl;var n=Al(t*=pl),r=vl(t),i=ml(e-wu),o=vl(i),a=r*Al(i),s=Tu*n-xu*r*o,l=xu*n+Tu*r*o;_u.add(bl(kl(a*a+s*s),l)),wu=e,xu=n,Tu=r}function Du(e){return _u=new m,jl(e,Su),+_u}var Lu=[null,null],Ou={type:"LineString",coordinates:Lu};function Iu(e,t){return Lu[0]=e,Lu[1]=t,Du(Ou)}var Bu={Feature:function(e,t){return ju(e.geometry,t)},FeatureCollection:function(e,t){for(var n=e.features,r=-1,i=n.length;++r0&&(i=Iu(e[o],e[o-1]))>0&&n<=i&&r<=i&&(n+r-i)*(1-Math.pow((n-r)/i,2))sl})).map(l)).concat(q(yl(o/h)*h,i,h).filter((function(e){return ml(e%m)>sl})).map(c))}return b.lines=function(){return v().map((function(e){return{type:"LineString",coordinates:e}}))},b.outline=function(){return{type:"Polygon",coordinates:[u(r).concat(f(a).slice(1),u(n).reverse().slice(1),f(s).reverse().slice(1))]}},b.extent=function(e){return arguments.length?b.extentMajor(e).extentMinor(e):b.extentMinor()},b.extentMajor=function(e){return arguments.length?(r=+e[0][0],n=+e[1][0],s=+e[0][1],a=+e[1][1],r>n&&(e=r,r=n,n=e),s>a&&(e=s,s=a,a=e),b.precision(g)):[[r,s],[n,a]]},b.extentMinor=function(n){return arguments.length?(t=+n[0][0],e=+n[1][0],o=+n[0][1],i=+n[1][1],t>e&&(n=t,t=e,e=n),o>i&&(n=o,o=i,i=n),b.precision(g)):[[t,o],[e,i]]},b.step=function(e){return arguments.length?b.stepMajor(e).stepMinor(e):b.stepMinor()},b.stepMajor=function(e){return arguments.length?(p=+e[0],m=+e[1],b):[p,m]},b.stepMinor=function(e){return arguments.length?(d=+e[0],h=+e[1],b):[d,h]},b.precision=function(d){return arguments.length?(g=+d,l=Hu(o,i,90),c=Vu(t,e,g),u=Hu(s,a,90),f=Vu(r,n,g),b):g},b.extentMajor([[-180,-89.999999],[180,89.999999]]).extentMinor([[-180,-80.000001],[180,80.000001]])}var Wu,Yu,Zu,Ku,Xu=e=>e,Qu=new m,$u=new m,Ju={point:Dl,lineStart:Dl,lineEnd:Dl,polygonStart:function(){Ju.lineStart=ef,Ju.lineEnd=rf},polygonEnd:function(){Ju.lineStart=Ju.lineEnd=Ju.point=Dl,Qu.add(ml($u)),$u=new m},result:function(){var e=Qu/2;return Qu=new m,e}};function ef(){Ju.point=tf}function tf(e,t){Ju.point=nf,Wu=Zu=e,Yu=Ku=t}function nf(e,t){$u.add(Ku*e-Zu*t),Zu=e,Ku=t}function rf(){nf(Wu,Yu)}var of,af,sf,lf,cf=1/0,uf=cf,ff=-cf,df=ff,hf={point:function(e,t){eff&&(ff=e),tdf&&(df=t)},lineStart:Dl,lineEnd:Dl,polygonStart:Dl,polygonEnd:Dl,result:function(){var e=[[cf,uf],[ff,df]];return ff=df=-(uf=cf=1/0),e}},pf=0,mf=0,gf=0,bf=0,vf=0,yf=0,_f=0,wf=0,xf=0,Tf={point:Af,lineStart:Ef,lineEnd:Mf,polygonStart:function(){Tf.lineStart=Cf,Tf.lineEnd=Nf},polygonEnd:function(){Tf.point=Af,Tf.lineStart=Ef,Tf.lineEnd=Mf},result:function(){var e=xf?[_f/xf,wf/xf]:yf?[bf/yf,vf/yf]:gf?[pf/gf,mf/gf]:[NaN,NaN];return pf=mf=gf=bf=vf=yf=_f=wf=xf=0,e}};function Af(e,t){pf+=e,mf+=t,++gf}function Ef(){Tf.point=kf}function kf(e,t){Tf.point=Sf,Af(sf=e,lf=t)}function Sf(e,t){var n=e-sf,r=t-lf,i=kl(n*n+r*r);bf+=i*(sf+e)/2,vf+=i*(lf+t)/2,yf+=i,Af(sf=e,lf=t)}function Mf(){Tf.point=Af}function Cf(){Tf.point=Df}function Nf(){Lf(of,af)}function Df(e,t){Tf.point=Lf,Af(of=sf=e,af=lf=t)}function Lf(e,t){var n=e-sf,r=t-lf,i=kl(n*n+r*r);bf+=i*(sf+e)/2,vf+=i*(lf+t)/2,yf+=i,_f+=(i=lf*e-sf*t)*(sf+e),wf+=i*(lf+t),xf+=3*i,Af(sf=e,lf=t)}function Of(e){this._context=e}Of.prototype={_radius:4.5,pointRadius:function(e){return this._radius=e,this},polygonStart:function(){this._line=0},polygonEnd:function(){this._line=NaN},lineStart:function(){this._point=0},lineEnd:function(){0===this._line&&this._context.closePath(),this._point=NaN},point:function(e,t){switch(this._point){case 0:this._context.moveTo(e,t),this._point=1;break;case 1:this._context.lineTo(e,t);break;default:this._context.moveTo(e+this._radius,t),this._context.arc(e,t,this._radius,0,dl)}},result:Dl};var If,Bf,Pf,jf,Rf,zf=new m,Ff={point:Dl,lineStart:function(){Ff.point=qf},lineEnd:function(){If&&Uf(Bf,Pf),Ff.point=Dl},polygonStart:function(){If=!0},polygonEnd:function(){If=null},result:function(){var e=+zf;return zf=new m,e}};function qf(e,t){Ff.point=Uf,Bf=jf=e,Pf=Rf=t}function Uf(e,t){jf-=e,Rf-=t,zf.add(kl(jf*jf+Rf*Rf)),jf=e,Rf=t}function Hf(){this._string=[]}function Vf(e){return"m0,"+e+"a"+e+","+e+" 0 1,1 0,"+-2*e+"a"+e+","+e+" 0 1,1 0,"+2*e+"z"}function Gf(e){return function(t){var n=new Wf;for(var r in e)n[r]=e[r];return n.stream=t,n}}function Wf(){}function Yf(e,t,n){var r=e.clipExtent&&e.clipExtent();return e.scale(150).translate([0,0]),null!=r&&e.clipExtent(null),jl(n,e.stream(hf)),t(hf.result()),null!=r&&e.clipExtent(r),e}function Zf(e,t,n){return Yf(e,(function(n){var r=t[1][0]-t[0][0],i=t[1][1]-t[0][1],o=Math.min(r/(n[1][0]-n[0][0]),i/(n[1][1]-n[0][1])),a=+t[0][0]+(r-o*(n[1][0]+n[0][0]))/2,s=+t[0][1]+(i-o*(n[1][1]+n[0][1]))/2;e.scale(150*o).translate([a,s])}),n)}function Kf(e,t,n){return Zf(e,[[0,0],t],n)}function Xf(e,t,n){return Yf(e,(function(n){var r=+t,i=r/(n[1][0]-n[0][0]),o=(r-i*(n[1][0]+n[0][0]))/2,a=-i*n[0][1];e.scale(150*i).translate([o,a])}),n)}function Qf(e,t,n){return Yf(e,(function(n){var r=+t,i=r/(n[1][1]-n[0][1]),o=-i*n[0][0],a=(r-i*(n[1][1]+n[0][1]))/2;e.scale(150*i).translate([o,a])}),n)}Hf.prototype={_radius:4.5,_circle:Vf(4.5),pointRadius:function(e){return(e=+e)!==this._radius&&(this._radius=e,this._circle=null),this},polygonStart:function(){this._line=0},polygonEnd:function(){this._line=NaN},lineStart:function(){this._point=0},lineEnd:function(){0===this._line&&this._string.push("Z"),this._point=NaN},point:function(e,t){switch(this._point){case 0:this._string.push("M",e,",",t),this._point=1;break;case 1:this._string.push("L",e,",",t);break;default:null==this._circle&&(this._circle=Vf(this._radius)),this._string.push("M",e,",",t,this._circle)}},result:function(){if(this._string.length){var e=this._string.join("");return this._string=[],e}return null}},Wf.prototype={constructor:Wf,point:function(e,t){this.stream.point(e,t)},sphere:function(){this.stream.sphere()},lineStart:function(){this.stream.lineStart()},lineEnd:function(){this.stream.lineEnd()},polygonStart:function(){this.stream.polygonStart()},polygonEnd:function(){this.stream.polygonEnd()}};var $f=vl(30*pl);function Jf(e,t){return+t?function(e,t){function n(r,i,o,a,s,l,c,u,f,d,h,p,m,g){var b=c-r,v=u-i,y=b*b+v*v;if(y>4*t&&m--){var _=a+d,w=s+h,x=l+p,T=kl(_*_+w*w+x*x),A=Cl(x/=T),E=ml(ml(x)-1)t||ml((b*C+v*N)/y-.5)>.3||a*d+s*h+l*p<$f)&&(n(r,i,o,a,s,l,S,M,E,_/=T,w/=T,x,m,g),g.point(S,M),n(S,M,E,_,w,x,c,u,f,d,h,p,m,g))}}return function(t){var r,i,o,a,s,l,c,u,f,d,h,p,m={point:g,lineStart:b,lineEnd:y,polygonStart:function(){t.polygonStart(),m.lineStart=_},polygonEnd:function(){t.polygonEnd(),m.lineStart=b}};function g(n,r){n=e(n,r),t.point(n[0],n[1])}function b(){u=NaN,m.point=v,t.lineStart()}function v(r,i){var o=lc([r,i]),a=e(r,i);n(u,f,c,d,h,p,u=a[0],f=a[1],c=r,d=o[0],h=o[1],p=o[2],16,t),t.point(u,f)}function y(){m.point=g,t.lineEnd()}function _(){b(),m.point=w,m.lineEnd=x}function w(e,t){v(r=e,t),i=u,o=f,a=d,s=h,l=p,m.point=v}function x(){n(u,f,c,d,h,p,i,o,r,a,s,l,16,t),m.lineEnd=y,y()}return m}}(e,t):function(e){return Gf({point:function(t,n){t=e(t,n),this.stream.point(t[0],t[1])}})}(e)}var ed=Gf({point:function(e,t){this.stream.point(e*pl,t*pl)}});function td(e,t,n,r,i,o){if(!o)return function(e,t,n,r,i){function o(o,a){return[t+e*(o*=r),n-e*(a*=i)]}return o.invert=function(o,a){return[(o-t)/e*r,(n-a)/e*i]},o}(e,t,n,r,i);var a=vl(o),s=Al(o),l=a*e,c=s*e,u=a/e,f=s/e,d=(s*n-a*t)/e,h=(s*t+a*n)/e;function p(e,o){return[l*(e*=r)-c*(o*=i)+t,n-c*e-l*o]}return p.invert=function(e,t){return[r*(u*e-f*t+d),i*(h-f*e-u*t)]},p}function nd(e){return rd((function(){return e}))()}function rd(e){var t,n,r,i,o,a,s,l,c,u,f=150,d=480,h=250,p=0,m=0,g=0,b=0,v=0,y=0,_=1,w=1,x=null,T=vu,A=null,E=Xu,k=.5;function S(e){return l(e[0]*pl,e[1]*pl)}function M(e){return(e=l.invert(e[0],e[1]))&&[e[0]*hl,e[1]*hl]}function C(){var e=td(f,0,0,_,w,y).apply(null,t(p,m)),r=td(f,d-e[0],h-e[1],_,w,y);return n=tu(g,b,v),s=Jc(t,r),l=Jc(n,s),a=Jf(s,k),N()}function N(){return c=u=null,S}return S.stream=function(e){return c&&u===e?c:c=ed(function(e){return Gf({point:function(t,n){var r=e(t,n);return this.stream.point(r[0],r[1])}})}(n)(T(a(E(u=e)))))},S.preclip=function(e){return arguments.length?(T=e,x=void 0,N()):T},S.postclip=function(e){return arguments.length?(E=e,A=r=i=o=null,N()):E},S.clipAngle=function(e){return arguments.length?(T=+e?yu(x=e*pl):(x=null,vu),N()):x*hl},S.clipExtent=function(e){return arguments.length?(E=null==e?(A=r=i=o=null,Xu):ku(A=+e[0][0],r=+e[0][1],i=+e[1][0],o=+e[1][1]),N()):null==A?null:[[A,r],[i,o]]},S.scale=function(e){return arguments.length?(f=+e,C()):f},S.translate=function(e){return arguments.length?(d=+e[0],h=+e[1],C()):[d,h]},S.center=function(e){return arguments.length?(p=e[0]%360*pl,m=e[1]%360*pl,C()):[p*hl,m*hl]},S.rotate=function(e){return arguments.length?(g=e[0]%360*pl,b=e[1]%360*pl,v=e.length>2?e[2]%360*pl:0,C()):[g*hl,b*hl,v*hl]},S.angle=function(e){return arguments.length?(y=e%360*pl,C()):y*hl},S.reflectX=function(e){return arguments.length?(_=e?-1:1,C()):_<0},S.reflectY=function(e){return arguments.length?(w=e?-1:1,C()):w<0},S.precision=function(e){return arguments.length?(a=Jf(s,k=e*e),N()):kl(k)},S.fitExtent=function(e,t){return Zf(S,e,t)},S.fitSize=function(e,t){return Kf(S,e,t)},S.fitWidth=function(e,t){return Xf(S,e,t)},S.fitHeight=function(e,t){return Qf(S,e,t)},function(){return t=e.apply(this,arguments),S.invert=t.invert&&M,C()}}function id(e){var t=0,n=cl/3,r=rd(e),i=r(t,n);return i.parallels=function(e){return arguments.length?r(t=e[0]*pl,n=e[1]*pl):[t*hl,n*hl]},i}function od(e,t){var n=Al(e),r=(n+Al(t))/2;if(ml(r)0?t<-ul+sl&&(t=-ul+sl):t>ul-sl&&(t=ul-sl);var n=i/Tl(pd(t),r);return[n*Al(r*e),i-n*vl(r*e)]}return o.invert=function(e,t){var n=i-t,o=El(r)*kl(e*e+n*n),a=bl(e,ml(n))*El(n);return n*r<0&&(a-=cl*El(e)*El(n)),[a/r,2*gl(Tl(i/o,1/r))-ul]},o}function gd(e,t){return[e,t]}function bd(e,t){var n=vl(e),r=e===t?Al(e):(n-vl(t))/(t-e),i=n/r+e;if(ml(r)=0;)t+=n[r].value;else t=1;e.value=t}function Od(e,t){e instanceof Map?(e=[void 0,e],void 0===t&&(t=Bd)):void 0===t&&(t=Id);for(var n,r,i,o,a,s=new Rd(e),l=[s];n=l.pop();)if((i=t(n.data))&&(a=(i=Array.from(i)).length))for(n.children=i,o=a-1;o>=0;--o)l.push(r=i[o]=new Rd(i[o])),r.parent=n,r.depth=n.depth+1;return s.eachBefore(jd)}function Id(e){return e.children}function Bd(e){return Array.isArray(e)?e[1]:null}function Pd(e){void 0!==e.data.value&&(e.value=e.data.value),e.data=e.data.data}function jd(e){var t=0;do{e.height=t}while((e=e.parent)&&e.height<++t)}function Rd(e){this.data=e,this.depth=this.height=0,this.parent=null}function zd(e){for(var t,n,r=0,i=(e=function(e){for(var t,n,r=e.length;r;)n=Math.random()*r--|0,t=e[r],e[r]=e[n],e[n]=t;return e}(Array.from(e))).length,o=[];r0&&n*n>r*r+i*i}function Hd(e,t){for(var n=0;n(a*=a)?(r=(c+a-i)/(2*c),o=Math.sqrt(Math.max(0,a/c-r*r)),n.x=e.x-r*s-o*l,n.y=e.y-r*l+o*s):(r=(c+i-a)/(2*c),o=Math.sqrt(Math.max(0,i/c-r*r)),n.x=t.x+r*s-o*l,n.y=t.y+r*l+o*s)):(n.x=t.x+n.r,n.y=t.y)}function Zd(e,t){var n=e.r+t.r-1e-6,r=t.x-e.x,i=t.y-e.y;return n>0&&n*n>r*r+i*i}function Kd(e){var t=e._,n=e.next._,r=t.r+n.r,i=(t.x*n.r+n.x*t.r)/r,o=(t.y*n.r+n.y*t.r)/r;return i*i+o*o}function Xd(e){this._=e,this.next=null,this.previous=null}function Qd(e){if(!(i=(e=function(e){return"object"==typeof e&&"length"in e?e:Array.from(e)}(e)).length))return 0;var t,n,r,i,o,a,s,l,c,u,f;if((t=e[0]).x=0,t.y=0,!(i>1))return t.r;if(n=e[1],t.x=-n.r,n.x=t.r,n.y=0,!(i>2))return t.r+n.r;Yd(n,t,r=e[2]),t=new Xd(t),n=new Xd(n),r=new Xd(r),t.next=r.previous=n,n.next=t.previous=r,r.next=n.previous=t;e:for(s=3;ssl&&--i>0);return[e/(.8707+(o=r*r)*(o*(o*o*o*(.003971-.001529*o)-.013791)-.131979)),r]},kd.invert=cd(Cl),Sd.invert=cd((function(e){return 2*gl(e)})),Md.invert=function(e,t){return[-t,2*gl(_l(e))-ul]},Rd.prototype=Od.prototype={constructor:Rd,count:function(){return this.eachAfter(Ld)},each:function(e,t){let n=-1;for(const r of this)e.call(t,r,++n,this);return this},eachAfter:function(e,t){for(var n,r,i,o=this,a=[o],s=[],l=-1;o=a.pop();)if(s.push(o),n=o.children)for(r=0,i=n.length;r=0;--r)o.push(n[r]);return this},find:function(e,t){let n=-1;for(const r of this)if(e.call(t,r,++n,this))return r},sum:function(e){return this.eachAfter((function(t){for(var n=+e(t.data)||0,r=t.children,i=r&&r.length;--i>=0;)n+=r[i].value;t.value=n}))},sort:function(e){return this.eachBefore((function(t){t.children&&t.children.sort(e)}))},path:function(e){for(var t=this,n=function(e,t){if(e===t)return e;var n=e.ancestors(),r=t.ancestors(),i=null;for(e=n.pop(),t=r.pop();e===t;)i=e,e=n.pop(),t=r.pop();return i}(t,e),r=[t];t!==n;)t=t.parent,r.push(t);for(var i=r.length;e!==n;)r.splice(i,0,e),e=e.parent;return r},ancestors:function(){for(var e=this,t=[e];e=e.parent;)t.push(e);return t},descendants:function(){return Array.from(this)},leaves:function(){var e=[];return this.eachBefore((function(t){t.children||e.push(t)})),e},links:function(){var e=this,t=[];return e.each((function(n){n!==e&&t.push({source:n.parent,target:n})})),t},copy:function(){return Od(this).eachBefore(Pd)},[Symbol.iterator]:function*(){var e,t,n,r,i=this,o=[i];do{for(e=o.reverse(),o=[];i=e.pop();)if(yield i,t=i.children)for(n=0,r=t.length;nd&&(d=s),g=u*u*m,(h=Math.max(d/g,g/f))>p){u-=s;break}p=h}b.push(a={value:u,dice:l1?t:1)},n}(yh),xh=function e(t){function n(e,n,r,i,o){if((a=e._squarify)&&a.ratio===t)for(var a,s,l,c,u,f=-1,d=a.length,h=e.value;++f1?t:1)},n}(yh);function Th(e,t,n){return(t[0]-e[0])*(n[1]-e[1])-(t[1]-e[1])*(n[0]-e[0])}function Ah(e,t){return e[0]-t[0]||e[1]-t[1]}function Eh(e){const t=e.length,n=[0,1];let r,i=2;for(r=2;r1&&Th(e[n[i-2]],e[n[i-1]],e[r])<=0;)--i;n[i++]=r}return n.slice(0,i)}var kh=Math.random,Sh=function e(t){function n(e,n){return e=null==e?0:+e,n=null==n?1:+n,1===arguments.length?(n=e,e=0):n-=e,function(){return t()*n+e}}return n.source=e,n}(kh),Mh=function e(t){function n(e,n){return arguments.length<2&&(n=e,e=0),e=Math.floor(e),n=Math.floor(n)-e,function(){return Math.floor(t()*n+e)}}return n.source=e,n}(kh),Ch=function e(t){function n(e,n){var r,i;return e=null==e?0:+e,n=null==n?1:+n,function(){var o;if(null!=r)o=r,r=null;else do{r=2*t()-1,o=2*t()-1,i=r*r+o*o}while(!i||i>1);return e+n*o*Math.sqrt(-2*Math.log(i)/i)}}return n.source=e,n}(kh),Nh=function e(t){var n=Ch.source(t);function r(){var e=n.apply(this,arguments);return function(){return Math.exp(e())}}return r.source=e,r}(kh),Dh=function e(t){function n(e){return(e=+e)<=0?()=>0:function(){for(var n=0,r=e;r>1;--r)n+=t();return n+r*t()}}return n.source=e,n}(kh),Lh=function e(t){var n=Dh.source(t);function r(e){if(0==(e=+e))return t;var r=n(e);return function(){return r()/e}}return r.source=e,r}(kh),Oh=function e(t){function n(e){return function(){return-Math.log1p(-t())/e}}return n.source=e,n}(kh),Ih=function e(t){function n(e){if((e=+e)<0)throw new RangeError("invalid alpha");return e=1/-e,function(){return Math.pow(1-t(),e)}}return n.source=e,n}(kh),Bh=function e(t){function n(e){if((e=+e)<0||e>1)throw new RangeError("invalid p");return function(){return Math.floor(t()+e)}}return n.source=e,n}(kh),Ph=function e(t){function n(e){if((e=+e)<0||e>1)throw new RangeError("invalid p");return 0===e?()=>1/0:1===e?()=>1:(e=Math.log1p(-e),function(){return 1+Math.floor(Math.log1p(-t())/e)})}return n.source=e,n}(kh),jh=function e(t){var n=Ch.source(t)();function r(e,r){if((e=+e)<0)throw new RangeError("invalid k");if(0===e)return()=>0;if(r=null==r?1:+r,1===e)return()=>-Math.log1p(-t())*r;var i=(e<1?e+1:e)-1/3,o=1/(3*Math.sqrt(i)),a=e<1?()=>Math.pow(t(),1/e):()=>1;return function(){do{do{var e=n(),s=1+o*e}while(s<=0);s*=s*s;var l=1-t()}while(l>=1-.0331*e*e*e*e&&Math.log(l)>=.5*e*e+i*(1-s+Math.log(s)));return i*s*a()*r}}return r.source=e,r}(kh),Rh=function e(t){var n=jh.source(t);function r(e,t){var r=n(e),i=n(t);return function(){var e=r();return 0===e?0:e/(e+i())}}return r.source=e,r}(kh),zh=function e(t){var n=Ph.source(t),r=Rh.source(t);function i(e,t){return e=+e,(t=+t)>=1?()=>e:t<=0?()=>0:function(){for(var i=0,o=e,a=t;o*a>16&&o*(1-a)>16;){var s=Math.floor((o+1)*a),l=r(s,o-s+1)();l<=a?(i+=s,o-=s,a=(a-l)/(1-l)):(o=s-1,a/=l)}for(var c=a<.5,u=n(c?a:1-a),f=u(),d=0;f<=o;++d)f+=u();return i+(c?d:o-d)}}return i.source=e,i}(kh),Fh=function e(t){function n(e,n,r){var i;return 0==(e=+e)?i=e=>-Math.log(e):(e=1/e,i=t=>Math.pow(t,e)),n=null==n?0:+n,r=null==r?1:+r,function(){return n+r*i(-Math.log1p(-t()))}}return n.source=e,n}(kh),qh=function e(t){function n(e,n){return e=null==e?0:+e,n=null==n?1:+n,function(){return e+n*Math.tan(Math.PI*t())}}return n.source=e,n}(kh),Uh=function e(t){function n(e,n){return e=null==e?0:+e,n=null==n?1:+n,function(){var r=t();return e+n*Math.log(r/(1-r))}}return n.source=e,n}(kh),Hh=function e(t){var n=jh.source(t),r=zh.source(t);function i(e){return function(){for(var i=0,o=e;o>16;){var a=Math.floor(.875*o),s=n(a)();if(s>o)return i+r(a-1,o/s)();i+=a,o-=s}for(var l=-Math.log1p(-t()),c=0;l<=o;++c)l-=Math.log1p(-t());return i+c}}return i.source=e,i}(kh);const Vh=1/4294967296;function Gh(e,t){switch(arguments.length){case 0:break;case 1:this.range(e);break;default:this.range(t).domain(e)}return this}function Wh(e,t){switch(arguments.length){case 0:break;case 1:"function"==typeof e?this.interpolator(e):this.range(e);break;default:this.domain(e),"function"==typeof t?this.interpolator(t):this.range(t)}return this}const Yh=Symbol("implicit");function Zh(){var e=new Map,t=[],n=[],r=Yh;function i(i){var o=i+"",a=e.get(o);if(!a){if(r!==Yh)return r;e.set(o,a=t.push(i))}return n[(a-1)%n.length]}return i.domain=function(n){if(!arguments.length)return t.slice();t=[],e=new Map;for(const r of n){const n=r+"";e.has(n)||e.set(n,t.push(r))}return i},i.range=function(e){return arguments.length?(n=Array.from(e),i):n.slice()},i.unknown=function(e){return arguments.length?(r=e,i):r},i.copy=function(){return Zh(t,n).unknown(r)},Gh.apply(i,arguments),i}function Kh(){var e,t,n=Zh().unknown(void 0),r=n.domain,i=n.range,o=0,a=1,s=!1,l=0,c=0,u=.5;function f(){var n=r().length,f=at&&(n=e,e=t,t=n),function(n){return Math.max(e,Math.min(t,n))}}(a[0],a[e-1])),r=e>2?np:tp,i=o=null,f}function f(t){return isNaN(t=+t)?n:(i||(i=r(a.map(e),s,l)))(e(c(t)))}return f.invert=function(n){return c(t((o||(o=r(s,a.map(e),lr)))(n)))},f.domain=function(e){return arguments.length?(a=Array.from(e,Qh),u()):a.slice()},f.range=function(e){return arguments.length?(s=Array.from(e),u()):s.slice()},f.rangeRound=function(e){return s=Array.from(e),l=pr,u()},f.clamp=function(e){return arguments.length?(c=!!e||Jh,u()):c!==Jh},f.interpolate=function(e){return arguments.length?(l=e,u()):l},f.unknown=function(e){return arguments.length?(n=e,f):n},function(n,r){return e=n,t=r,u()}}function op(){return ip()(Jh,Jh)}function ap(t,n,r,i){var o,a=k(t,n,r);switch((i=Zs(null==i?",f":i)).type){case"s":var s=Math.max(Math.abs(t),Math.abs(n));return null!=i.precision||isNaN(o=ol(a,s))||(i.precision=o),e.formatPrefix(i,s);case"":case"e":case"g":case"p":case"r":null!=i.precision||isNaN(o=al(a,Math.max(Math.abs(t),Math.abs(n))))||(i.precision=o-("e"===i.type));break;case"f":case"%":null!=i.precision||isNaN(o=il(a))||(i.precision=o-2*("%"===i.type))}return e.format(i)}function sp(e){var t=e.domain;return e.ticks=function(e){var n=t();return A(n[0],n[n.length-1],null==e?10:e)},e.tickFormat=function(e,n){var r=t();return ap(r[0],r[r.length-1],null==e?10:e,n)},e.nice=function(n){null==n&&(n=10);var r,i,o=t(),a=0,s=o.length-1,l=o[a],c=o[s],u=10;for(c0;){if((i=E(l,c,n))===r)return o[a]=l,o[s]=c,t(o);if(i>0)l=Math.floor(l/i)*i,c=Math.ceil(c/i)*i;else{if(!(i<0))break;l=Math.ceil(l*i)/i,c=Math.floor(c*i)/i}r=i}return e},e}function lp(e,t){var n,r=0,i=(e=e.slice()).length-1,o=e[r],a=e[i];return a0){for(;d<=h;++d)for(u=1,c=r(d);ul)break;m.push(f)}}else for(;d<=h;++d)for(u=a-1,c=r(d);u>=1;--u)if(!((f=c*u)l)break;m.push(f)}2*m.length0))return s;do{s.push(a=new Date(+n)),t(n,o),e(n)}while(a=t)for(;e(t),!n(t);)t.setTime(t-1)}),(function(e,r){if(e>=e)if(r<0)for(;++r<=0;)for(;t(e,-1),!n(e););else for(;--r>=0;)for(;t(e,1),!n(e););}))},n&&(i.count=function(t,r){return kp.setTime(+t),Sp.setTime(+r),e(kp),e(Sp),Math.floor(n(kp,Sp))},i.every=function(e){return e=Math.floor(e),isFinite(e)&&e>0?e>1?i.filter(r?function(t){return r(t)%e==0}:function(t){return i.count(0,t)%e==0}):i:null}),i}var Cp=Mp((function(){}),(function(e,t){e.setTime(+e+t)}),(function(e,t){return t-e}));Cp.every=function(e){return e=Math.floor(e),isFinite(e)&&e>0?e>1?Mp((function(t){t.setTime(Math.floor(t/e)*e)}),(function(t,n){t.setTime(+t+n*e)}),(function(t,n){return(n-t)/e})):Cp:null};var Np=Cp.range,Dp=1e3,Lp=6e4,Op=36e5,Ip=864e5,Bp=6048e5,Pp=Mp((function(e){e.setTime(e-e.getMilliseconds())}),(function(e,t){e.setTime(+e+t*Dp)}),(function(e,t){return(t-e)/Dp}),(function(e){return e.getUTCSeconds()})),jp=Pp.range,Rp=Mp((function(e){e.setTime(e-e.getMilliseconds()-e.getSeconds()*Dp)}),(function(e,t){e.setTime(+e+t*Lp)}),(function(e,t){return(t-e)/Lp}),(function(e){return e.getMinutes()})),zp=Rp.range,Fp=Mp((function(e){e.setTime(e-e.getMilliseconds()-e.getSeconds()*Dp-e.getMinutes()*Lp)}),(function(e,t){e.setTime(+e+t*Op)}),(function(e,t){return(t-e)/Op}),(function(e){return e.getHours()})),qp=Fp.range,Up=Mp((e=>e.setHours(0,0,0,0)),((e,t)=>e.setDate(e.getDate()+t)),((e,t)=>(t-e-(t.getTimezoneOffset()-e.getTimezoneOffset())*Lp)/Ip),(e=>e.getDate()-1)),Hp=Up.range;function Vp(e){return Mp((function(t){t.setDate(t.getDate()-(t.getDay()+7-e)%7),t.setHours(0,0,0,0)}),(function(e,t){e.setDate(e.getDate()+7*t)}),(function(e,t){return(t-e-(t.getTimezoneOffset()-e.getTimezoneOffset())*Lp)/Bp}))}var Gp=Vp(0),Wp=Vp(1),Yp=Vp(2),Zp=Vp(3),Kp=Vp(4),Xp=Vp(5),Qp=Vp(6),$p=Gp.range,Jp=Wp.range,em=Yp.range,tm=Zp.range,nm=Kp.range,rm=Xp.range,im=Qp.range,om=Mp((function(e){e.setDate(1),e.setHours(0,0,0,0)}),(function(e,t){e.setMonth(e.getMonth()+t)}),(function(e,t){return t.getMonth()-e.getMonth()+12*(t.getFullYear()-e.getFullYear())}),(function(e){return e.getMonth()})),am=om.range,sm=Mp((function(e){e.setMonth(0,1),e.setHours(0,0,0,0)}),(function(e,t){e.setFullYear(e.getFullYear()+t)}),(function(e,t){return t.getFullYear()-e.getFullYear()}),(function(e){return e.getFullYear()}));sm.every=function(e){return isFinite(e=Math.floor(e))&&e>0?Mp((function(t){t.setFullYear(Math.floor(t.getFullYear()/e)*e),t.setMonth(0,1),t.setHours(0,0,0,0)}),(function(t,n){t.setFullYear(t.getFullYear()+n*e)})):null};var lm=sm.range,cm=Mp((function(e){e.setUTCSeconds(0,0)}),(function(e,t){e.setTime(+e+t*Lp)}),(function(e,t){return(t-e)/Lp}),(function(e){return e.getUTCMinutes()})),um=cm.range,fm=Mp((function(e){e.setUTCMinutes(0,0,0)}),(function(e,t){e.setTime(+e+t*Op)}),(function(e,t){return(t-e)/Op}),(function(e){return e.getUTCHours()})),dm=fm.range,hm=Mp((function(e){e.setUTCHours(0,0,0,0)}),(function(e,t){e.setUTCDate(e.getUTCDate()+t)}),(function(e,t){return(t-e)/Ip}),(function(e){return e.getUTCDate()-1})),pm=hm.range;function mm(e){return Mp((function(t){t.setUTCDate(t.getUTCDate()-(t.getUTCDay()+7-e)%7),t.setUTCHours(0,0,0,0)}),(function(e,t){e.setUTCDate(e.getUTCDate()+7*t)}),(function(e,t){return(t-e)/Bp}))}var gm=mm(0),bm=mm(1),vm=mm(2),ym=mm(3),_m=mm(4),wm=mm(5),xm=mm(6),Tm=gm.range,Am=bm.range,Em=vm.range,km=ym.range,Sm=_m.range,Mm=wm.range,Cm=xm.range,Nm=Mp((function(e){e.setUTCDate(1),e.setUTCHours(0,0,0,0)}),(function(e,t){e.setUTCMonth(e.getUTCMonth()+t)}),(function(e,t){return t.getUTCMonth()-e.getUTCMonth()+12*(t.getUTCFullYear()-e.getUTCFullYear())}),(function(e){return e.getUTCMonth()})),Dm=Nm.range,Lm=Mp((function(e){e.setUTCMonth(0,1),e.setUTCHours(0,0,0,0)}),(function(e,t){e.setUTCFullYear(e.getUTCFullYear()+t)}),(function(e,t){return t.getUTCFullYear()-e.getUTCFullYear()}),(function(e){return e.getUTCFullYear()}));Lm.every=function(e){return isFinite(e=Math.floor(e))&&e>0?Mp((function(t){t.setUTCFullYear(Math.floor(t.getUTCFullYear()/e)*e),t.setUTCMonth(0,1),t.setUTCHours(0,0,0,0)}),(function(t,n){t.setUTCFullYear(t.getUTCFullYear()+n*e)})):null};var Om=Lm.range;function Im(e){if(0<=e.y&&e.y<100){var t=new Date(-1,e.m,e.d,e.H,e.M,e.S,e.L);return t.setFullYear(e.y),t}return new Date(e.y,e.m,e.d,e.H,e.M,e.S,e.L)}function Bm(e){if(0<=e.y&&e.y<100){var t=new Date(Date.UTC(-1,e.m,e.d,e.H,e.M,e.S,e.L));return t.setUTCFullYear(e.y),t}return new Date(Date.UTC(e.y,e.m,e.d,e.H,e.M,e.S,e.L))}function Pm(e,t,n){return{y:e,m:t,d:n,H:0,M:0,S:0,L:0}}function jm(e){var t=e.dateTime,n=e.date,r=e.time,i=e.periods,o=e.days,a=e.shortDays,s=e.months,l=e.shortMonths,c=Gm(i),u=Wm(i),f=Gm(o),d=Wm(o),h=Gm(a),p=Wm(a),m=Gm(s),g=Wm(s),b=Gm(l),v=Wm(l),y={a:function(e){return a[e.getDay()]},A:function(e){return o[e.getDay()]},b:function(e){return l[e.getMonth()]},B:function(e){return s[e.getMonth()]},c:null,d:hg,e:hg,f:vg,g:Cg,G:Dg,H:pg,I:mg,j:gg,L:bg,m:yg,M:_g,p:function(e){return i[+(e.getHours()>=12)]},q:function(e){return 1+~~(e.getMonth()/3)},Q:eb,s:tb,S:wg,u:xg,U:Tg,V:Eg,w:kg,W:Sg,x:null,X:null,y:Mg,Y:Ng,Z:Lg,"%":Jg},_={a:function(e){return a[e.getUTCDay()]},A:function(e){return o[e.getUTCDay()]},b:function(e){return l[e.getUTCMonth()]},B:function(e){return s[e.getUTCMonth()]},c:null,d:Og,e:Og,f:Rg,g:Kg,G:Qg,H:Ig,I:Bg,j:Pg,L:jg,m:zg,M:Fg,p:function(e){return i[+(e.getUTCHours()>=12)]},q:function(e){return 1+~~(e.getUTCMonth()/3)},Q:eb,s:tb,S:qg,u:Ug,U:Hg,V:Gg,w:Wg,W:Yg,x:null,X:null,y:Zg,Y:Xg,Z:$g,"%":Jg},w={a:function(e,t,n){var r=h.exec(t.slice(n));return r?(e.w=p.get(r[0].toLowerCase()),n+r[0].length):-1},A:function(e,t,n){var r=f.exec(t.slice(n));return r?(e.w=d.get(r[0].toLowerCase()),n+r[0].length):-1},b:function(e,t,n){var r=b.exec(t.slice(n));return r?(e.m=v.get(r[0].toLowerCase()),n+r[0].length):-1},B:function(e,t,n){var r=m.exec(t.slice(n));return r?(e.m=g.get(r[0].toLowerCase()),n+r[0].length):-1},c:function(e,n,r){return A(e,t,n,r)},d:rg,e:rg,f:cg,g:Jm,G:$m,H:og,I:og,j:ig,L:lg,m:ng,M:ag,p:function(e,t,n){var r=c.exec(t.slice(n));return r?(e.p=u.get(r[0].toLowerCase()),n+r[0].length):-1},q:tg,Q:fg,s:dg,S:sg,u:Zm,U:Km,V:Xm,w:Ym,W:Qm,x:function(e,t,r){return A(e,n,t,r)},X:function(e,t,n){return A(e,r,t,n)},y:Jm,Y:$m,Z:eg,"%":ug};function x(e,t){return function(n){var r,i,o,a=[],s=-1,l=0,c=e.length;for(n instanceof Date||(n=new Date(+n));++s53)return null;"w"in o||(o.w=1),"Z"in o?(i=(r=Bm(Pm(o.y,0,1))).getUTCDay(),r=i>4||0===i?bm.ceil(r):bm(r),r=hm.offset(r,7*(o.V-1)),o.y=r.getUTCFullYear(),o.m=r.getUTCMonth(),o.d=r.getUTCDate()+(o.w+6)%7):(i=(r=Im(Pm(o.y,0,1))).getDay(),r=i>4||0===i?Wp.ceil(r):Wp(r),r=Up.offset(r,7*(o.V-1)),o.y=r.getFullYear(),o.m=r.getMonth(),o.d=r.getDate()+(o.w+6)%7)}else("W"in o||"U"in o)&&("w"in o||(o.w="u"in o?o.u%7:"W"in o?1:0),i="Z"in o?Bm(Pm(o.y,0,1)).getUTCDay():Im(Pm(o.y,0,1)).getDay(),o.m=0,o.d="W"in o?(o.w+6)%7+7*o.W-(i+5)%7:o.w+7*o.U-(i+6)%7);return"Z"in o?(o.H+=o.Z/100|0,o.M+=o.Z%100,Bm(o)):Im(o)}}function A(e,t,n,r){for(var i,o,a=0,s=t.length,l=n.length;a=l)return-1;if(37===(i=t.charCodeAt(a++))){if(i=t.charAt(a++),!(o=w[i in zm?t.charAt(a++):i])||(r=o(e,n,r))<0)return-1}else if(i!=n.charCodeAt(r++))return-1}return r}return y.x=x(n,y),y.X=x(r,y),y.c=x(t,y),_.x=x(n,_),_.X=x(r,_),_.c=x(t,_),{format:function(e){var t=x(e+="",y);return t.toString=function(){return e},t},parse:function(e){var t=T(e+="",!1);return t.toString=function(){return e},t},utcFormat:function(e){var t=x(e+="",_);return t.toString=function(){return e},t},utcParse:function(e){var t=T(e+="",!0);return t.toString=function(){return e},t}}}var Rm,zm={"-":"",_:" ",0:"0"},Fm=/^\s*\d+/,qm=/^%/,Um=/[\\^$*+?|[\]().{}]/g;function Hm(e,t,n){var r=e<0?"-":"",i=(r?-e:e)+"",o=i.length;return r+(o[e.toLowerCase(),t])))}function Ym(e,t,n){var r=Fm.exec(t.slice(n,n+1));return r?(e.w=+r[0],n+r[0].length):-1}function Zm(e,t,n){var r=Fm.exec(t.slice(n,n+1));return r?(e.u=+r[0],n+r[0].length):-1}function Km(e,t,n){var r=Fm.exec(t.slice(n,n+2));return r?(e.U=+r[0],n+r[0].length):-1}function Xm(e,t,n){var r=Fm.exec(t.slice(n,n+2));return r?(e.V=+r[0],n+r[0].length):-1}function Qm(e,t,n){var r=Fm.exec(t.slice(n,n+2));return r?(e.W=+r[0],n+r[0].length):-1}function $m(e,t,n){var r=Fm.exec(t.slice(n,n+4));return r?(e.y=+r[0],n+r[0].length):-1}function Jm(e,t,n){var r=Fm.exec(t.slice(n,n+2));return r?(e.y=+r[0]+(+r[0]>68?1900:2e3),n+r[0].length):-1}function eg(e,t,n){var r=/^(Z)|([+-]\d\d)(?::?(\d\d))?/.exec(t.slice(n,n+6));return r?(e.Z=r[1]?0:-(r[2]+(r[3]||"00")),n+r[0].length):-1}function tg(e,t,n){var r=Fm.exec(t.slice(n,n+1));return r?(e.q=3*r[0]-3,n+r[0].length):-1}function ng(e,t,n){var r=Fm.exec(t.slice(n,n+2));return r?(e.m=r[0]-1,n+r[0].length):-1}function rg(e,t,n){var r=Fm.exec(t.slice(n,n+2));return r?(e.d=+r[0],n+r[0].length):-1}function ig(e,t,n){var r=Fm.exec(t.slice(n,n+3));return r?(e.m=0,e.d=+r[0],n+r[0].length):-1}function og(e,t,n){var r=Fm.exec(t.slice(n,n+2));return r?(e.H=+r[0],n+r[0].length):-1}function ag(e,t,n){var r=Fm.exec(t.slice(n,n+2));return r?(e.M=+r[0],n+r[0].length):-1}function sg(e,t,n){var r=Fm.exec(t.slice(n,n+2));return r?(e.S=+r[0],n+r[0].length):-1}function lg(e,t,n){var r=Fm.exec(t.slice(n,n+3));return r?(e.L=+r[0],n+r[0].length):-1}function cg(e,t,n){var r=Fm.exec(t.slice(n,n+6));return r?(e.L=Math.floor(r[0]/1e3),n+r[0].length):-1}function ug(e,t,n){var r=qm.exec(t.slice(n,n+1));return r?n+r[0].length:-1}function fg(e,t,n){var r=Fm.exec(t.slice(n));return r?(e.Q=+r[0],n+r[0].length):-1}function dg(e,t,n){var r=Fm.exec(t.slice(n));return r?(e.s=+r[0],n+r[0].length):-1}function hg(e,t){return Hm(e.getDate(),t,2)}function pg(e,t){return Hm(e.getHours(),t,2)}function mg(e,t){return Hm(e.getHours()%12||12,t,2)}function gg(e,t){return Hm(1+Up.count(sm(e),e),t,3)}function bg(e,t){return Hm(e.getMilliseconds(),t,3)}function vg(e,t){return bg(e,t)+"000"}function yg(e,t){return Hm(e.getMonth()+1,t,2)}function _g(e,t){return Hm(e.getMinutes(),t,2)}function wg(e,t){return Hm(e.getSeconds(),t,2)}function xg(e){var t=e.getDay();return 0===t?7:t}function Tg(e,t){return Hm(Gp.count(sm(e)-1,e),t,2)}function Ag(e){var t=e.getDay();return t>=4||0===t?Kp(e):Kp.ceil(e)}function Eg(e,t){return e=Ag(e),Hm(Kp.count(sm(e),e)+(4===sm(e).getDay()),t,2)}function kg(e){return e.getDay()}function Sg(e,t){return Hm(Wp.count(sm(e)-1,e),t,2)}function Mg(e,t){return Hm(e.getFullYear()%100,t,2)}function Cg(e,t){return Hm((e=Ag(e)).getFullYear()%100,t,2)}function Ng(e,t){return Hm(e.getFullYear()%1e4,t,4)}function Dg(e,t){var n=e.getDay();return Hm((e=n>=4||0===n?Kp(e):Kp.ceil(e)).getFullYear()%1e4,t,4)}function Lg(e){var t=e.getTimezoneOffset();return(t>0?"-":(t*=-1,"+"))+Hm(t/60|0,"0",2)+Hm(t%60,"0",2)}function Og(e,t){return Hm(e.getUTCDate(),t,2)}function Ig(e,t){return Hm(e.getUTCHours(),t,2)}function Bg(e,t){return Hm(e.getUTCHours()%12||12,t,2)}function Pg(e,t){return Hm(1+hm.count(Lm(e),e),t,3)}function jg(e,t){return Hm(e.getUTCMilliseconds(),t,3)}function Rg(e,t){return jg(e,t)+"000"}function zg(e,t){return Hm(e.getUTCMonth()+1,t,2)}function Fg(e,t){return Hm(e.getUTCMinutes(),t,2)}function qg(e,t){return Hm(e.getUTCSeconds(),t,2)}function Ug(e){var t=e.getUTCDay();return 0===t?7:t}function Hg(e,t){return Hm(gm.count(Lm(e)-1,e),t,2)}function Vg(e){var t=e.getUTCDay();return t>=4||0===t?_m(e):_m.ceil(e)}function Gg(e,t){return e=Vg(e),Hm(_m.count(Lm(e),e)+(4===Lm(e).getUTCDay()),t,2)}function Wg(e){return e.getUTCDay()}function Yg(e,t){return Hm(bm.count(Lm(e)-1,e),t,2)}function Zg(e,t){return Hm(e.getUTCFullYear()%100,t,2)}function Kg(e,t){return Hm((e=Vg(e)).getUTCFullYear()%100,t,2)}function Xg(e,t){return Hm(e.getUTCFullYear()%1e4,t,4)}function Qg(e,t){var n=e.getUTCDay();return Hm((e=n>=4||0===n?_m(e):_m.ceil(e)).getUTCFullYear()%1e4,t,4)}function $g(){return"+0000"}function Jg(){return"%"}function eb(e){return+e}function tb(e){return Math.floor(+e/1e3)}function nb(t){return Rm=jm(t),e.timeFormat=Rm.format,e.timeParse=Rm.parse,e.utcFormat=Rm.utcFormat,e.utcParse=Rm.utcParse,Rm}nb({dateTime:"%x, %X",date:"%-m/%-d/%Y",time:"%-I:%M:%S %p",periods:["AM","PM"],days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],shortDays:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],shortMonths:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]});var rb="%Y-%m-%dT%H:%M:%S.%LZ",ib=Date.prototype.toISOString?function(e){return e.toISOString()}:e.utcFormat(rb),ob=+new Date("2000-01-01T00:00:00.000Z")?function(e){var t=new Date(e);return isNaN(t)?null:t}:e.utcParse(rb),ab=31536e6;function sb(e){return new Date(e)}function lb(e){return e instanceof Date?+e:+new Date(+e)}function cb(e,t,r,i,o,a,s,l,c){var u=op(),f=u.invert,d=u.domain,h=c(".%L"),p=c(":%S"),m=c("%I:%M"),g=c("%I %p"),b=c("%a %d"),v=c("%b %d"),y=c("%B"),_=c("%Y"),w=[[s,1,1e3],[s,5,5e3],[s,15,15e3],[s,30,3e4],[a,1,6e4],[a,5,3e5],[a,15,9e5],[a,30,18e5],[o,1,36e5],[o,3,108e5],[o,6,216e5],[o,12,432e5],[i,1,864e5],[i,2,1728e5],[r,1,6048e5],[t,1,2592e6],[t,3,7776e6],[e,1,ab]];function x(n){return(s(n)nr(e[e.length-1]),Sb=new Array(3).concat("d8b365f5f5f55ab4ac","a6611adfc27d80cdc1018571","a6611adfc27df5f5f580cdc1018571","8c510ad8b365f6e8c3c7eae55ab4ac01665e","8c510ad8b365f6e8c3f5f5f5c7eae55ab4ac01665e","8c510abf812ddfc27df6e8c3c7eae580cdc135978f01665e","8c510abf812ddfc27df6e8c3f5f5f5c7eae580cdc135978f01665e","5430058c510abf812ddfc27df6e8c3c7eae580cdc135978f01665e003c30","5430058c510abf812ddfc27df6e8c3f5f5f5c7eae580cdc135978f01665e003c30").map(mb),Mb=kb(Sb),Cb=new Array(3).concat("af8dc3f7f7f77fbf7b","7b3294c2a5cfa6dba0008837","7b3294c2a5cff7f7f7a6dba0008837","762a83af8dc3e7d4e8d9f0d37fbf7b1b7837","762a83af8dc3e7d4e8f7f7f7d9f0d37fbf7b1b7837","762a839970abc2a5cfe7d4e8d9f0d3a6dba05aae611b7837","762a839970abc2a5cfe7d4e8f7f7f7d9f0d3a6dba05aae611b7837","40004b762a839970abc2a5cfe7d4e8d9f0d3a6dba05aae611b783700441b","40004b762a839970abc2a5cfe7d4e8f7f7f7d9f0d3a6dba05aae611b783700441b").map(mb),Nb=kb(Cb),Db=new Array(3).concat("e9a3c9f7f7f7a1d76a","d01c8bf1b6dab8e1864dac26","d01c8bf1b6daf7f7f7b8e1864dac26","c51b7de9a3c9fde0efe6f5d0a1d76a4d9221","c51b7de9a3c9fde0eff7f7f7e6f5d0a1d76a4d9221","c51b7dde77aef1b6dafde0efe6f5d0b8e1867fbc414d9221","c51b7dde77aef1b6dafde0eff7f7f7e6f5d0b8e1867fbc414d9221","8e0152c51b7dde77aef1b6dafde0efe6f5d0b8e1867fbc414d9221276419","8e0152c51b7dde77aef1b6dafde0eff7f7f7e6f5d0b8e1867fbc414d9221276419").map(mb),Lb=kb(Db),Ob=new Array(3).concat("998ec3f7f7f7f1a340","5e3c99b2abd2fdb863e66101","5e3c99b2abd2f7f7f7fdb863e66101","542788998ec3d8daebfee0b6f1a340b35806","542788998ec3d8daebf7f7f7fee0b6f1a340b35806","5427888073acb2abd2d8daebfee0b6fdb863e08214b35806","5427888073acb2abd2d8daebf7f7f7fee0b6fdb863e08214b35806","2d004b5427888073acb2abd2d8daebfee0b6fdb863e08214b358067f3b08","2d004b5427888073acb2abd2d8daebf7f7f7fee0b6fdb863e08214b358067f3b08").map(mb),Ib=kb(Ob),Bb=new Array(3).concat("ef8a62f7f7f767a9cf","ca0020f4a58292c5de0571b0","ca0020f4a582f7f7f792c5de0571b0","b2182bef8a62fddbc7d1e5f067a9cf2166ac","b2182bef8a62fddbc7f7f7f7d1e5f067a9cf2166ac","b2182bd6604df4a582fddbc7d1e5f092c5de4393c32166ac","b2182bd6604df4a582fddbc7f7f7f7d1e5f092c5de4393c32166ac","67001fb2182bd6604df4a582fddbc7d1e5f092c5de4393c32166ac053061","67001fb2182bd6604df4a582fddbc7f7f7f7d1e5f092c5de4393c32166ac053061").map(mb),Pb=kb(Bb),jb=new Array(3).concat("ef8a62ffffff999999","ca0020f4a582bababa404040","ca0020f4a582ffffffbababa404040","b2182bef8a62fddbc7e0e0e09999994d4d4d","b2182bef8a62fddbc7ffffffe0e0e09999994d4d4d","b2182bd6604df4a582fddbc7e0e0e0bababa8787874d4d4d","b2182bd6604df4a582fddbc7ffffffe0e0e0bababa8787874d4d4d","67001fb2182bd6604df4a582fddbc7e0e0e0bababa8787874d4d4d1a1a1a","67001fb2182bd6604df4a582fddbc7ffffffe0e0e0bababa8787874d4d4d1a1a1a").map(mb),Rb=kb(jb),zb=new Array(3).concat("fc8d59ffffbf91bfdb","d7191cfdae61abd9e92c7bb6","d7191cfdae61ffffbfabd9e92c7bb6","d73027fc8d59fee090e0f3f891bfdb4575b4","d73027fc8d59fee090ffffbfe0f3f891bfdb4575b4","d73027f46d43fdae61fee090e0f3f8abd9e974add14575b4","d73027f46d43fdae61fee090ffffbfe0f3f8abd9e974add14575b4","a50026d73027f46d43fdae61fee090e0f3f8abd9e974add14575b4313695","a50026d73027f46d43fdae61fee090ffffbfe0f3f8abd9e974add14575b4313695").map(mb),Fb=kb(zb),qb=new Array(3).concat("fc8d59ffffbf91cf60","d7191cfdae61a6d96a1a9641","d7191cfdae61ffffbfa6d96a1a9641","d73027fc8d59fee08bd9ef8b91cf601a9850","d73027fc8d59fee08bffffbfd9ef8b91cf601a9850","d73027f46d43fdae61fee08bd9ef8ba6d96a66bd631a9850","d73027f46d43fdae61fee08bffffbfd9ef8ba6d96a66bd631a9850","a50026d73027f46d43fdae61fee08bd9ef8ba6d96a66bd631a9850006837","a50026d73027f46d43fdae61fee08bffffbfd9ef8ba6d96a66bd631a9850006837").map(mb),Ub=kb(qb),Hb=new Array(3).concat("fc8d59ffffbf99d594","d7191cfdae61abdda42b83ba","d7191cfdae61ffffbfabdda42b83ba","d53e4ffc8d59fee08be6f59899d5943288bd","d53e4ffc8d59fee08bffffbfe6f59899d5943288bd","d53e4ff46d43fdae61fee08be6f598abdda466c2a53288bd","d53e4ff46d43fdae61fee08bffffbfe6f598abdda466c2a53288bd","9e0142d53e4ff46d43fdae61fee08be6f598abdda466c2a53288bd5e4fa2","9e0142d53e4ff46d43fdae61fee08bffffbfe6f598abdda466c2a53288bd5e4fa2").map(mb),Vb=kb(Hb),Gb=new Array(3).concat("e5f5f999d8c92ca25f","edf8fbb2e2e266c2a4238b45","edf8fbb2e2e266c2a42ca25f006d2c","edf8fbccece699d8c966c2a42ca25f006d2c","edf8fbccece699d8c966c2a441ae76238b45005824","f7fcfde5f5f9ccece699d8c966c2a441ae76238b45005824","f7fcfde5f5f9ccece699d8c966c2a441ae76238b45006d2c00441b").map(mb),Wb=kb(Gb),Yb=new Array(3).concat("e0ecf49ebcda8856a7","edf8fbb3cde38c96c688419d","edf8fbb3cde38c96c68856a7810f7c","edf8fbbfd3e69ebcda8c96c68856a7810f7c","edf8fbbfd3e69ebcda8c96c68c6bb188419d6e016b","f7fcfde0ecf4bfd3e69ebcda8c96c68c6bb188419d6e016b","f7fcfde0ecf4bfd3e69ebcda8c96c68c6bb188419d810f7c4d004b").map(mb),Zb=kb(Yb),Kb=new Array(3).concat("e0f3dba8ddb543a2ca","f0f9e8bae4bc7bccc42b8cbe","f0f9e8bae4bc7bccc443a2ca0868ac","f0f9e8ccebc5a8ddb57bccc443a2ca0868ac","f0f9e8ccebc5a8ddb57bccc44eb3d32b8cbe08589e","f7fcf0e0f3dbccebc5a8ddb57bccc44eb3d32b8cbe08589e","f7fcf0e0f3dbccebc5a8ddb57bccc44eb3d32b8cbe0868ac084081").map(mb),Xb=kb(Kb),Qb=new Array(3).concat("fee8c8fdbb84e34a33","fef0d9fdcc8afc8d59d7301f","fef0d9fdcc8afc8d59e34a33b30000","fef0d9fdd49efdbb84fc8d59e34a33b30000","fef0d9fdd49efdbb84fc8d59ef6548d7301f990000","fff7ecfee8c8fdd49efdbb84fc8d59ef6548d7301f990000","fff7ecfee8c8fdd49efdbb84fc8d59ef6548d7301fb300007f0000").map(mb),$b=kb(Qb),Jb=new Array(3).concat("ece2f0a6bddb1c9099","f6eff7bdc9e167a9cf02818a","f6eff7bdc9e167a9cf1c9099016c59","f6eff7d0d1e6a6bddb67a9cf1c9099016c59","f6eff7d0d1e6a6bddb67a9cf3690c002818a016450","fff7fbece2f0d0d1e6a6bddb67a9cf3690c002818a016450","fff7fbece2f0d0d1e6a6bddb67a9cf3690c002818a016c59014636").map(mb),ev=kb(Jb),tv=new Array(3).concat("ece7f2a6bddb2b8cbe","f1eef6bdc9e174a9cf0570b0","f1eef6bdc9e174a9cf2b8cbe045a8d","f1eef6d0d1e6a6bddb74a9cf2b8cbe045a8d","f1eef6d0d1e6a6bddb74a9cf3690c00570b0034e7b","fff7fbece7f2d0d1e6a6bddb74a9cf3690c00570b0034e7b","fff7fbece7f2d0d1e6a6bddb74a9cf3690c00570b0045a8d023858").map(mb),nv=kb(tv),rv=new Array(3).concat("e7e1efc994c7dd1c77","f1eef6d7b5d8df65b0ce1256","f1eef6d7b5d8df65b0dd1c77980043","f1eef6d4b9dac994c7df65b0dd1c77980043","f1eef6d4b9dac994c7df65b0e7298ace125691003f","f7f4f9e7e1efd4b9dac994c7df65b0e7298ace125691003f","f7f4f9e7e1efd4b9dac994c7df65b0e7298ace125698004367001f").map(mb),iv=kb(rv),ov=new Array(3).concat("fde0ddfa9fb5c51b8a","feebe2fbb4b9f768a1ae017e","feebe2fbb4b9f768a1c51b8a7a0177","feebe2fcc5c0fa9fb5f768a1c51b8a7a0177","feebe2fcc5c0fa9fb5f768a1dd3497ae017e7a0177","fff7f3fde0ddfcc5c0fa9fb5f768a1dd3497ae017e7a0177","fff7f3fde0ddfcc5c0fa9fb5f768a1dd3497ae017e7a017749006a").map(mb),av=kb(ov),sv=new Array(3).concat("edf8b17fcdbb2c7fb8","ffffcca1dab441b6c4225ea8","ffffcca1dab441b6c42c7fb8253494","ffffccc7e9b47fcdbb41b6c42c7fb8253494","ffffccc7e9b47fcdbb41b6c41d91c0225ea80c2c84","ffffd9edf8b1c7e9b47fcdbb41b6c41d91c0225ea80c2c84","ffffd9edf8b1c7e9b47fcdbb41b6c41d91c0225ea8253494081d58").map(mb),lv=kb(sv),cv=new Array(3).concat("f7fcb9addd8e31a354","ffffccc2e69978c679238443","ffffccc2e69978c67931a354006837","ffffccd9f0a3addd8e78c67931a354006837","ffffccd9f0a3addd8e78c67941ab5d238443005a32","ffffe5f7fcb9d9f0a3addd8e78c67941ab5d238443005a32","ffffe5f7fcb9d9f0a3addd8e78c67941ab5d238443006837004529").map(mb),uv=kb(cv),fv=new Array(3).concat("fff7bcfec44fd95f0e","ffffd4fed98efe9929cc4c02","ffffd4fed98efe9929d95f0e993404","ffffd4fee391fec44ffe9929d95f0e993404","ffffd4fee391fec44ffe9929ec7014cc4c028c2d04","ffffe5fff7bcfee391fec44ffe9929ec7014cc4c028c2d04","ffffe5fff7bcfee391fec44ffe9929ec7014cc4c02993404662506").map(mb),dv=kb(fv),hv=new Array(3).concat("ffeda0feb24cf03b20","ffffb2fecc5cfd8d3ce31a1c","ffffb2fecc5cfd8d3cf03b20bd0026","ffffb2fed976feb24cfd8d3cf03b20bd0026","ffffb2fed976feb24cfd8d3cfc4e2ae31a1cb10026","ffffccffeda0fed976feb24cfd8d3cfc4e2ae31a1cb10026","ffffccffeda0fed976feb24cfd8d3cfc4e2ae31a1cbd0026800026").map(mb),pv=kb(hv),mv=new Array(3).concat("deebf79ecae13182bd","eff3ffbdd7e76baed62171b5","eff3ffbdd7e76baed63182bd08519c","eff3ffc6dbef9ecae16baed63182bd08519c","eff3ffc6dbef9ecae16baed64292c62171b5084594","f7fbffdeebf7c6dbef9ecae16baed64292c62171b5084594","f7fbffdeebf7c6dbef9ecae16baed64292c62171b508519c08306b").map(mb),gv=kb(mv),bv=new Array(3).concat("e5f5e0a1d99b31a354","edf8e9bae4b374c476238b45","edf8e9bae4b374c47631a354006d2c","edf8e9c7e9c0a1d99b74c47631a354006d2c","edf8e9c7e9c0a1d99b74c47641ab5d238b45005a32","f7fcf5e5f5e0c7e9c0a1d99b74c47641ab5d238b45005a32","f7fcf5e5f5e0c7e9c0a1d99b74c47641ab5d238b45006d2c00441b").map(mb),vv=kb(bv),yv=new Array(3).concat("f0f0f0bdbdbd636363","f7f7f7cccccc969696525252","f7f7f7cccccc969696636363252525","f7f7f7d9d9d9bdbdbd969696636363252525","f7f7f7d9d9d9bdbdbd969696737373525252252525","fffffff0f0f0d9d9d9bdbdbd969696737373525252252525","fffffff0f0f0d9d9d9bdbdbd969696737373525252252525000000").map(mb),_v=kb(yv),wv=new Array(3).concat("efedf5bcbddc756bb1","f2f0f7cbc9e29e9ac86a51a3","f2f0f7cbc9e29e9ac8756bb154278f","f2f0f7dadaebbcbddc9e9ac8756bb154278f","f2f0f7dadaebbcbddc9e9ac8807dba6a51a34a1486","fcfbfdefedf5dadaebbcbddc9e9ac8807dba6a51a34a1486","fcfbfdefedf5dadaebbcbddc9e9ac8807dba6a51a354278f3f007d").map(mb),xv=kb(wv),Tv=new Array(3).concat("fee0d2fc9272de2d26","fee5d9fcae91fb6a4acb181d","fee5d9fcae91fb6a4ade2d26a50f15","fee5d9fcbba1fc9272fb6a4ade2d26a50f15","fee5d9fcbba1fc9272fb6a4aef3b2ccb181d99000d","fff5f0fee0d2fcbba1fc9272fb6a4aef3b2ccb181d99000d","fff5f0fee0d2fcbba1fc9272fb6a4aef3b2ccb181da50f1567000d").map(mb),Av=kb(Tv),Ev=new Array(3).concat("fee6cefdae6be6550d","feeddefdbe85fd8d3cd94701","feeddefdbe85fd8d3ce6550da63603","feeddefdd0a2fdae6bfd8d3ce6550da63603","feeddefdd0a2fdae6bfd8d3cf16913d948018c2d04","fff5ebfee6cefdd0a2fdae6bfd8d3cf16913d948018c2d04","fff5ebfee6cefdd0a2fdae6bfd8d3cf16913d94801a636037f2704").map(mb),kv=kb(Ev),Sv=Lr(Gn(300,.5,0),Gn(-240,.5,1)),Mv=Lr(Gn(-100,.75,.35),Gn(80,1.5,.8)),Cv=Lr(Gn(260,.75,.35),Gn(80,1.5,.8)),Nv=Gn(),Dv=ln(),Lv=Math.PI/3,Ov=2*Math.PI/3;function Iv(e){var t=e.length;return function(n){return e[Math.max(0,Math.min(t-1,Math.floor(n*t)))]}}var Bv=Iv(mb("44015444025645045745055946075a46085c460a5d460b5e470d60470e6147106347116447136548146748166848176948186a481a6c481b6d481c6e481d6f481f70482071482173482374482475482576482677482878482979472a7a472c7a472d7b472e7c472f7d46307e46327e46337f463480453581453781453882443983443a83443b84433d84433e85423f854240864241864142874144874045884046883f47883f48893e49893e4a893e4c8a3d4d8a3d4e8a3c4f8a3c508b3b518b3b528b3a538b3a548c39558c39568c38588c38598c375a8c375b8d365c8d365d8d355e8d355f8d34608d34618d33628d33638d32648e32658e31668e31678e31688e30698e306a8e2f6b8e2f6c8e2e6d8e2e6e8e2e6f8e2d708e2d718e2c718e2c728e2c738e2b748e2b758e2a768e2a778e2a788e29798e297a8e297b8e287c8e287d8e277e8e277f8e27808e26818e26828e26828e25838e25848e25858e24868e24878e23888e23898e238a8d228b8d228c8d228d8d218e8d218f8d21908d21918c20928c20928c20938c1f948c1f958b1f968b1f978b1f988b1f998a1f9a8a1e9b8a1e9c891e9d891f9e891f9f881fa0881fa1881fa1871fa28720a38620a48621a58521a68522a78522a88423a98324aa8325ab8225ac8226ad8127ad8128ae8029af7f2ab07f2cb17e2db27d2eb37c2fb47c31b57b32b67a34b67935b77937b87838b9773aba763bbb753dbc743fbc7340bd7242be7144bf7046c06f48c16e4ac16d4cc26c4ec36b50c46a52c56954c56856c66758c7655ac8645cc8635ec96260ca6063cb5f65cb5e67cc5c69cd5b6ccd5a6ece5870cf5773d05675d05477d1537ad1517cd2507fd34e81d34d84d44b86d54989d5488bd6468ed64590d74393d74195d84098d83e9bd93c9dd93ba0da39a2da37a5db36a8db34aadc32addc30b0dd2fb2dd2db5de2bb8de29bade28bddf26c0df25c2df23c5e021c8e020cae11fcde11dd0e11cd2e21bd5e21ad8e219dae319dde318dfe318e2e418e5e419e7e419eae51aece51befe51cf1e51df4e61ef6e620f8e621fbe723fde725")),Pv=Iv(mb("00000401000501010601010802010902020b02020d03030f03031204041405041606051806051a07061c08071e0907200a08220b09240c09260d0a290e0b2b100b2d110c2f120d31130d34140e36150e38160f3b180f3d19103f1a10421c10441d11471e114920114b21114e22115024125325125527125829115a2a115c2c115f2d11612f116331116533106734106936106b38106c390f6e3b0f703d0f713f0f72400f74420f75440f764510774710784910784a10794c117a4e117b4f127b51127c52137c54137d56147d57157e59157e5a167e5c167f5d177f5f187f601880621980641a80651a80671b80681c816a1c816b1d816d1d816e1e81701f81721f817320817521817621817822817922827b23827c23827e24828025828125818326818426818627818827818928818b29818c29818e2a81902a81912b81932b80942c80962c80982d80992d809b2e7f9c2e7f9e2f7fa02f7fa1307ea3307ea5317ea6317da8327daa337dab337cad347cae347bb0357bb2357bb3367ab5367ab73779b83779ba3878bc3978bd3977bf3a77c03a76c23b75c43c75c53c74c73d73c83e73ca3e72cc3f71cd4071cf4070d0416fd2426fd3436ed5446dd6456cd8456cd9466bdb476adc4869de4968df4a68e04c67e24d66e34e65e44f64e55064e75263e85362e95462ea5661eb5760ec5860ed5a5fee5b5eef5d5ef05f5ef1605df2625df2645cf3655cf4675cf4695cf56b5cf66c5cf66e5cf7705cf7725cf8745cf8765cf9785df9795df97b5dfa7d5efa7f5efa815ffb835ffb8560fb8761fc8961fc8a62fc8c63fc8e64fc9065fd9266fd9467fd9668fd9869fd9a6afd9b6bfe9d6cfe9f6dfea16efea36ffea571fea772fea973feaa74feac76feae77feb078feb27afeb47bfeb67cfeb77efeb97ffebb81febd82febf84fec185fec287fec488fec68afec88cfeca8dfecc8ffecd90fecf92fed194fed395fed597fed799fed89afdda9cfddc9efddea0fde0a1fde2a3fde3a5fde5a7fde7a9fde9aafdebacfcecaefceeb0fcf0b2fcf2b4fcf4b6fcf6b8fcf7b9fcf9bbfcfbbdfcfdbf")),jv=Iv(mb("00000401000501010601010802010a02020c02020e03021004031204031405041706041907051b08051d09061f0a07220b07240c08260d08290e092b10092d110a30120a32140b34150b37160b39180c3c190c3e1b0c411c0c431e0c451f0c48210c4a230c4c240c4f260c51280b53290b552b0b572d0b592f0a5b310a5c320a5e340a5f3609613809623909633b09643d09653e0966400a67420a68440a68450a69470b6a490b6a4a0c6b4c0c6b4d0d6c4f0d6c510e6c520e6d540f6d550f6d57106e59106e5a116e5c126e5d126e5f136e61136e62146e64156e65156e67166e69166e6a176e6c186e6d186e6f196e71196e721a6e741a6e751b6e771c6d781c6d7a1d6d7c1d6d7d1e6d7f1e6c801f6c82206c84206b85216b87216b88226a8a226a8c23698d23698f24699025689225689326679526679727669827669a28659b29649d29649f2a63a02a63a22b62a32c61a52c60a62d60a82e5fa92e5eab2f5ead305dae305cb0315bb1325ab3325ab43359b63458b73557b93556ba3655bc3754bd3853bf3952c03a51c13a50c33b4fc43c4ec63d4dc73e4cc83f4bca404acb4149cc4248ce4347cf4446d04545d24644d34743d44842d54a41d74b3fd84c3ed94d3dda4e3cdb503bdd513ade5238df5337e05536e15635e25734e35933e45a31e55c30e65d2fe75e2ee8602de9612bea632aeb6429eb6628ec6726ed6925ee6a24ef6c23ef6e21f06f20f1711ff1731df2741cf3761bf37819f47918f57b17f57d15f67e14f68013f78212f78410f8850ff8870ef8890cf98b0bf98c0af98e09fa9008fa9207fa9407fb9606fb9706fb9906fb9b06fb9d07fc9f07fca108fca309fca50afca60cfca80dfcaa0ffcac11fcae12fcb014fcb216fcb418fbb61afbb81dfbba1ffbbc21fbbe23fac026fac228fac42afac62df9c72ff9c932f9cb35f8cd37f8cf3af7d13df7d340f6d543f6d746f5d949f5db4cf4dd4ff4df53f4e156f3e35af3e55df2e661f2e865f2ea69f1ec6df1ed71f1ef75f1f179f2f27df2f482f3f586f3f68af4f88ef5f992f6fa96f8fb9af9fc9dfafda1fcffa4")),Rv=Iv(mb("0d088710078813078916078a19068c1b068d1d068e20068f2206902406912605912805922a05932c05942e05952f059631059733059735049837049938049a3a049a3c049b3e049c3f049c41049d43039e44039e46039f48039f4903a04b03a14c02a14e02a25002a25102a35302a35502a45601a45801a45901a55b01a55c01a65e01a66001a66100a76300a76400a76600a76700a86900a86a00a86c00a86e00a86f00a87100a87201a87401a87501a87701a87801a87a02a87b02a87d03a87e03a88004a88104a78305a78405a78606a68707a68808a68a09a58b0aa58d0ba58e0ca48f0da4910ea3920fa39410a29511a19613a19814a099159f9a169f9c179e9d189d9e199da01a9ca11b9ba21d9aa31e9aa51f99a62098a72197a82296aa2395ab2494ac2694ad2793ae2892b02991b12a90b22b8fb32c8eb42e8db52f8cb6308bb7318ab83289ba3388bb3488bc3587bd3786be3885bf3984c03a83c13b82c23c81c33d80c43e7fc5407ec6417dc7427cc8437bc9447aca457acb4679cc4778cc4977cd4a76ce4b75cf4c74d04d73d14e72d24f71d35171d45270d5536fd5546ed6556dd7566cd8576bd9586ada5a6ada5b69db5c68dc5d67dd5e66de5f65de6164df6263e06363e16462e26561e26660e3685fe4695ee56a5de56b5de66c5ce76e5be76f5ae87059e97158e97257ea7457eb7556eb7655ec7754ed7953ed7a52ee7b51ef7c51ef7e50f07f4ff0804ef1814df1834cf2844bf3854bf3874af48849f48948f58b47f58c46f68d45f68f44f79044f79143f79342f89441f89540f9973ff9983ef99a3efa9b3dfa9c3cfa9e3bfb9f3afba139fba238fca338fca537fca636fca835fca934fdab33fdac33fdae32fdaf31fdb130fdb22ffdb42ffdb52efeb72dfeb82cfeba2cfebb2bfebd2afebe2afec029fdc229fdc328fdc527fdc627fdc827fdca26fdcb26fccd25fcce25fcd025fcd225fbd324fbd524fbd724fad824fada24f9dc24f9dd25f8df25f8e125f7e225f7e425f6e626f6e826f5e926f5eb27f4ed27f3ee27f3f027f2f227f1f426f1f525f0f724f0f921"));function zv(e){return function(){return e}}var Fv=Math.abs,qv=Math.atan2,Uv=Math.cos,Hv=Math.max,Vv=Math.min,Gv=Math.sin,Wv=Math.sqrt,Yv=1e-12,Zv=Math.PI,Kv=Zv/2,Xv=2*Zv;function Qv(e){return e>1?0:e<-1?Zv:Math.acos(e)}function $v(e){return e>=1?Kv:e<=-1?-Kv:Math.asin(e)}function Jv(e){return e.innerRadius}function ey(e){return e.outerRadius}function ty(e){return e.startAngle}function ny(e){return e.endAngle}function ry(e){return e&&e.padAngle}function iy(e,t,n,r,i,o,a,s){var l=n-e,c=r-t,u=a-i,f=s-o,d=f*l-u*c;if(!(d*dN*N+D*D&&(A=k,E=S),{cx:A,cy:E,x01:-u,y01:-f,x11:A*(i/w-1),y11:E*(i/w-1)}}var ay=Array.prototype.slice;function sy(e){return"object"==typeof e&&"length"in e?e:Array.from(e)}function ly(e){this._context=e}function cy(e){return new ly(e)}function uy(e){return e[0]}function fy(e){return e[1]}function dy(e,t){var n=zv(!0),r=null,i=cy,o=null;function a(a){var s,l,c,u=(a=sy(a)).length,f=!1;for(null==r&&(o=i(c=$o())),s=0;s<=u;++s)!(s=u;--f)s.point(g[f],b[f]);s.lineEnd(),s.areaEnd()}m&&(g[c]=+e(d,c,l),b[c]=+t(d,c,l),s.point(r?+r(d,c,l):g[c],n?+n(d,c,l):b[c]))}if(h)return s=null,h+""||null}function c(){return dy().defined(i).curve(a).context(o)}return e="function"==typeof e?e:void 0===e?uy:zv(+e),t="function"==typeof t?t:zv(void 0===t?0:+t),n="function"==typeof n?n:void 0===n?fy:zv(+n),l.x=function(t){return arguments.length?(e="function"==typeof t?t:zv(+t),r=null,l):e},l.x0=function(t){return arguments.length?(e="function"==typeof t?t:zv(+t),l):e},l.x1=function(e){return arguments.length?(r=null==e?null:"function"==typeof e?e:zv(+e),l):r},l.y=function(e){return arguments.length?(t="function"==typeof e?e:zv(+e),n=null,l):t},l.y0=function(e){return arguments.length?(t="function"==typeof e?e:zv(+e),l):t},l.y1=function(e){return arguments.length?(n=null==e?null:"function"==typeof e?e:zv(+e),l):n},l.lineX0=l.lineY0=function(){return c().x(e).y(t)},l.lineY1=function(){return c().x(e).y(n)},l.lineX1=function(){return c().x(r).y(t)},l.defined=function(e){return arguments.length?(i="function"==typeof e?e:zv(!!e),l):i},l.curve=function(e){return arguments.length?(a=e,null!=o&&(s=a(o)),l):a},l.context=function(e){return arguments.length?(null==e?o=s=null:s=a(o=e),l):o},l}function py(e,t){return te?1:t>=e?0:NaN}function my(e){return e}ly.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._point=0},lineEnd:function(){(this._line||0!==this._line&&1===this._point)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;default:this._context.lineTo(e,t)}}};var gy=vy(cy);function by(e){this._curve=e}function vy(e){function t(t){return new by(e(t))}return t._curve=e,t}function yy(e){var t=e.curve;return e.angle=e.x,delete e.x,e.radius=e.y,delete e.y,e.curve=function(e){return arguments.length?t(vy(e)):t()._curve},e}function _y(){return yy(dy().curve(gy))}function wy(){var e=hy().curve(gy),t=e.curve,n=e.lineX0,r=e.lineX1,i=e.lineY0,o=e.lineY1;return e.angle=e.x,delete e.x,e.startAngle=e.x0,delete e.x0,e.endAngle=e.x1,delete e.x1,e.radius=e.y,delete e.y,e.innerRadius=e.y0,delete e.y0,e.outerRadius=e.y1,delete e.y1,e.lineStartAngle=function(){return yy(n())},delete e.lineX0,e.lineEndAngle=function(){return yy(r())},delete e.lineX1,e.lineInnerRadius=function(){return yy(i())},delete e.lineY0,e.lineOuterRadius=function(){return yy(o())},delete e.lineY1,e.curve=function(e){return arguments.length?t(vy(e)):t()._curve},e}function xy(e,t){return[(t=+t)*Math.cos(e-=Math.PI/2),t*Math.sin(e)]}function Ty(e){return e.source}function Ay(e){return e.target}function Ey(e){var t=Ty,n=Ay,r=uy,i=fy,o=null;function a(){var a,s=ay.call(arguments),l=t.apply(this,s),c=n.apply(this,s);if(o||(o=a=$o()),e(o,+r.apply(this,(s[0]=l,s)),+i.apply(this,s),+r.apply(this,(s[0]=c,s)),+i.apply(this,s)),a)return o=null,a+""||null}return a.source=function(e){return arguments.length?(t=e,a):t},a.target=function(e){return arguments.length?(n=e,a):n},a.x=function(e){return arguments.length?(r="function"==typeof e?e:zv(+e),a):r},a.y=function(e){return arguments.length?(i="function"==typeof e?e:zv(+e),a):i},a.context=function(e){return arguments.length?(o=null==e?null:e,a):o},a}function ky(e,t,n,r,i){e.moveTo(t,n),e.bezierCurveTo(t=(t+r)/2,n,t,i,r,i)}function Sy(e,t,n,r,i){e.moveTo(t,n),e.bezierCurveTo(t,n=(n+i)/2,r,n,r,i)}function My(e,t,n,r,i){var o=xy(t,n),a=xy(t,n=(n+i)/2),s=xy(r,n),l=xy(r,i);e.moveTo(o[0],o[1]),e.bezierCurveTo(a[0],a[1],s[0],s[1],l[0],l[1])}by.prototype={areaStart:function(){this._curve.areaStart()},areaEnd:function(){this._curve.areaEnd()},lineStart:function(){this._curve.lineStart()},lineEnd:function(){this._curve.lineEnd()},point:function(e,t){this._curve.point(t*Math.sin(e),t*-Math.cos(e))}};var Cy={draw:function(e,t){var n=Math.sqrt(t/Zv);e.moveTo(n,0),e.arc(0,0,n,0,Xv)}},Ny={draw:function(e,t){var n=Math.sqrt(t/5)/2;e.moveTo(-3*n,-n),e.lineTo(-n,-n),e.lineTo(-n,-3*n),e.lineTo(n,-3*n),e.lineTo(n,-n),e.lineTo(3*n,-n),e.lineTo(3*n,n),e.lineTo(n,n),e.lineTo(n,3*n),e.lineTo(-n,3*n),e.lineTo(-n,n),e.lineTo(-3*n,n),e.closePath()}},Dy=Math.sqrt(1/3),Ly=2*Dy,Oy={draw:function(e,t){var n=Math.sqrt(t/Ly),r=n*Dy;e.moveTo(0,-n),e.lineTo(r,0),e.lineTo(0,n),e.lineTo(-r,0),e.closePath()}},Iy=Math.sin(Zv/10)/Math.sin(7*Zv/10),By=Math.sin(Xv/10)*Iy,Py=-Math.cos(Xv/10)*Iy,jy={draw:function(e,t){var n=Math.sqrt(.8908130915292852*t),r=By*n,i=Py*n;e.moveTo(0,-n),e.lineTo(r,i);for(var o=1;o<5;++o){var a=Xv*o/5,s=Math.cos(a),l=Math.sin(a);e.lineTo(l*n,-s*n),e.lineTo(s*r-l*i,l*r+s*i)}e.closePath()}},Ry={draw:function(e,t){var n=Math.sqrt(t),r=-n/2;e.rect(r,r,n,n)}},zy=Math.sqrt(3),Fy={draw:function(e,t){var n=-Math.sqrt(t/(3*zy));e.moveTo(0,2*n),e.lineTo(-zy*n,-n),e.lineTo(zy*n,-n),e.closePath()}},qy=-.5,Uy=Math.sqrt(3)/2,Hy=1/Math.sqrt(12),Vy=3*(Hy/2+1),Gy={draw:function(e,t){var n=Math.sqrt(t/Vy),r=n/2,i=n*Hy,o=r,a=n*Hy+n,s=-o,l=a;e.moveTo(r,i),e.lineTo(o,a),e.lineTo(s,l),e.lineTo(qy*r-Uy*i,Uy*r+qy*i),e.lineTo(qy*o-Uy*a,Uy*o+qy*a),e.lineTo(qy*s-Uy*l,Uy*s+qy*l),e.lineTo(qy*r+Uy*i,qy*i-Uy*r),e.lineTo(qy*o+Uy*a,qy*a-Uy*o),e.lineTo(qy*s+Uy*l,qy*l-Uy*s),e.closePath()}},Wy=[Cy,Ny,Oy,Ry,jy,Fy,Gy];function Yy(){}function Zy(e,t,n){e._context.bezierCurveTo((2*e._x0+e._x1)/3,(2*e._y0+e._y1)/3,(e._x0+2*e._x1)/3,(e._y0+2*e._y1)/3,(e._x0+4*e._x1+t)/6,(e._y0+4*e._y1+n)/6)}function Ky(e){this._context=e}function Xy(e){this._context=e}function Qy(e){this._context=e}function $y(e,t){this._basis=new Ky(e),this._beta=t}Ky.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=NaN,this._point=0},lineEnd:function(){switch(this._point){case 3:Zy(this,this._x1,this._y1);case 2:this._context.lineTo(this._x1,this._y1)}(this._line||0!==this._line&&1===this._point)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;break;case 2:this._point=3,this._context.lineTo((5*this._x0+this._x1)/6,(5*this._y0+this._y1)/6);default:Zy(this,e,t)}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t}},Xy.prototype={areaStart:Yy,areaEnd:Yy,lineStart:function(){this._x0=this._x1=this._x2=this._x3=this._x4=this._y0=this._y1=this._y2=this._y3=this._y4=NaN,this._point=0},lineEnd:function(){switch(this._point){case 1:this._context.moveTo(this._x2,this._y2),this._context.closePath();break;case 2:this._context.moveTo((this._x2+2*this._x3)/3,(this._y2+2*this._y3)/3),this._context.lineTo((this._x3+2*this._x2)/3,(this._y3+2*this._y2)/3),this._context.closePath();break;case 3:this.point(this._x2,this._y2),this.point(this._x3,this._y3),this.point(this._x4,this._y4)}},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._x2=e,this._y2=t;break;case 1:this._point=2,this._x3=e,this._y3=t;break;case 2:this._point=3,this._x4=e,this._y4=t,this._context.moveTo((this._x0+4*this._x1+e)/6,(this._y0+4*this._y1+t)/6);break;default:Zy(this,e,t)}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t}},Qy.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=NaN,this._point=0},lineEnd:function(){(this._line||0!==this._line&&3===this._point)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1;break;case 1:this._point=2;break;case 2:this._point=3;var n=(this._x0+4*this._x1+e)/6,r=(this._y0+4*this._y1+t)/6;this._line?this._context.lineTo(n,r):this._context.moveTo(n,r);break;case 3:this._point=4;default:Zy(this,e,t)}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t}},$y.prototype={lineStart:function(){this._x=[],this._y=[],this._basis.lineStart()},lineEnd:function(){var e=this._x,t=this._y,n=e.length-1;if(n>0)for(var r,i=e[0],o=t[0],a=e[n]-i,s=t[n]-o,l=-1;++l<=n;)r=l/n,this._basis.point(this._beta*e[l]+(1-this._beta)*(i+r*a),this._beta*t[l]+(1-this._beta)*(o+r*s));this._x=this._y=null,this._basis.lineEnd()},point:function(e,t){this._x.push(+e),this._y.push(+t)}};var Jy=function e(t){function n(e){return 1===t?new Ky(e):new $y(e,t)}return n.beta=function(t){return e(+t)},n}(.85);function e_(e,t,n){e._context.bezierCurveTo(e._x1+e._k*(e._x2-e._x0),e._y1+e._k*(e._y2-e._y0),e._x2+e._k*(e._x1-t),e._y2+e._k*(e._y1-n),e._x2,e._y2)}function t_(e,t){this._context=e,this._k=(1-t)/6}t_.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._x2=this._y0=this._y1=this._y2=NaN,this._point=0},lineEnd:function(){switch(this._point){case 2:this._context.lineTo(this._x2,this._y2);break;case 3:e_(this,this._x1,this._y1)}(this._line||0!==this._line&&1===this._point)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2,this._x1=e,this._y1=t;break;case 2:this._point=3;default:e_(this,e,t)}this._x0=this._x1,this._x1=this._x2,this._x2=e,this._y0=this._y1,this._y1=this._y2,this._y2=t}};var n_=function e(t){function n(e){return new t_(e,t)}return n.tension=function(t){return e(+t)},n}(0);function r_(e,t){this._context=e,this._k=(1-t)/6}r_.prototype={areaStart:Yy,areaEnd:Yy,lineStart:function(){this._x0=this._x1=this._x2=this._x3=this._x4=this._x5=this._y0=this._y1=this._y2=this._y3=this._y4=this._y5=NaN,this._point=0},lineEnd:function(){switch(this._point){case 1:this._context.moveTo(this._x3,this._y3),this._context.closePath();break;case 2:this._context.lineTo(this._x3,this._y3),this._context.closePath();break;case 3:this.point(this._x3,this._y3),this.point(this._x4,this._y4),this.point(this._x5,this._y5)}},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._x3=e,this._y3=t;break;case 1:this._point=2,this._context.moveTo(this._x4=e,this._y4=t);break;case 2:this._point=3,this._x5=e,this._y5=t;break;default:e_(this,e,t)}this._x0=this._x1,this._x1=this._x2,this._x2=e,this._y0=this._y1,this._y1=this._y2,this._y2=t}};var i_=function e(t){function n(e){return new r_(e,t)}return n.tension=function(t){return e(+t)},n}(0);function o_(e,t){this._context=e,this._k=(1-t)/6}o_.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._x2=this._y0=this._y1=this._y2=NaN,this._point=0},lineEnd:function(){(this._line||0!==this._line&&3===this._point)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1;break;case 1:this._point=2;break;case 2:this._point=3,this._line?this._context.lineTo(this._x2,this._y2):this._context.moveTo(this._x2,this._y2);break;case 3:this._point=4;default:e_(this,e,t)}this._x0=this._x1,this._x1=this._x2,this._x2=e,this._y0=this._y1,this._y1=this._y2,this._y2=t}};var a_=function e(t){function n(e){return new o_(e,t)}return n.tension=function(t){return e(+t)},n}(0);function s_(e,t,n){var r=e._x1,i=e._y1,o=e._x2,a=e._y2;if(e._l01_a>Yv){var s=2*e._l01_2a+3*e._l01_a*e._l12_a+e._l12_2a,l=3*e._l01_a*(e._l01_a+e._l12_a);r=(r*s-e._x0*e._l12_2a+e._x2*e._l01_2a)/l,i=(i*s-e._y0*e._l12_2a+e._y2*e._l01_2a)/l}if(e._l23_a>Yv){var c=2*e._l23_2a+3*e._l23_a*e._l12_a+e._l12_2a,u=3*e._l23_a*(e._l23_a+e._l12_a);o=(o*c+e._x1*e._l23_2a-t*e._l12_2a)/u,a=(a*c+e._y1*e._l23_2a-n*e._l12_2a)/u}e._context.bezierCurveTo(r,i,o,a,e._x2,e._y2)}function l_(e,t){this._context=e,this._alpha=t}l_.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._x2=this._y0=this._y1=this._y2=NaN,this._l01_a=this._l12_a=this._l23_a=this._l01_2a=this._l12_2a=this._l23_2a=this._point=0},lineEnd:function(){switch(this._point){case 2:this._context.lineTo(this._x2,this._y2);break;case 3:this.point(this._x2,this._y2)}(this._line||0!==this._line&&1===this._point)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){if(e=+e,t=+t,this._point){var n=this._x2-e,r=this._y2-t;this._l23_a=Math.sqrt(this._l23_2a=Math.pow(n*n+r*r,this._alpha))}switch(this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;break;case 2:this._point=3;default:s_(this,e,t)}this._l01_a=this._l12_a,this._l12_a=this._l23_a,this._l01_2a=this._l12_2a,this._l12_2a=this._l23_2a,this._x0=this._x1,this._x1=this._x2,this._x2=e,this._y0=this._y1,this._y1=this._y2,this._y2=t}};var c_=function e(t){function n(e){return t?new l_(e,t):new t_(e,0)}return n.alpha=function(t){return e(+t)},n}(.5);function u_(e,t){this._context=e,this._alpha=t}u_.prototype={areaStart:Yy,areaEnd:Yy,lineStart:function(){this._x0=this._x1=this._x2=this._x3=this._x4=this._x5=this._y0=this._y1=this._y2=this._y3=this._y4=this._y5=NaN,this._l01_a=this._l12_a=this._l23_a=this._l01_2a=this._l12_2a=this._l23_2a=this._point=0},lineEnd:function(){switch(this._point){case 1:this._context.moveTo(this._x3,this._y3),this._context.closePath();break;case 2:this._context.lineTo(this._x3,this._y3),this._context.closePath();break;case 3:this.point(this._x3,this._y3),this.point(this._x4,this._y4),this.point(this._x5,this._y5)}},point:function(e,t){if(e=+e,t=+t,this._point){var n=this._x2-e,r=this._y2-t;this._l23_a=Math.sqrt(this._l23_2a=Math.pow(n*n+r*r,this._alpha))}switch(this._point){case 0:this._point=1,this._x3=e,this._y3=t;break;case 1:this._point=2,this._context.moveTo(this._x4=e,this._y4=t);break;case 2:this._point=3,this._x5=e,this._y5=t;break;default:s_(this,e,t)}this._l01_a=this._l12_a,this._l12_a=this._l23_a,this._l01_2a=this._l12_2a,this._l12_2a=this._l23_2a,this._x0=this._x1,this._x1=this._x2,this._x2=e,this._y0=this._y1,this._y1=this._y2,this._y2=t}};var f_=function e(t){function n(e){return t?new u_(e,t):new r_(e,0)}return n.alpha=function(t){return e(+t)},n}(.5);function d_(e,t){this._context=e,this._alpha=t}d_.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._x2=this._y0=this._y1=this._y2=NaN,this._l01_a=this._l12_a=this._l23_a=this._l01_2a=this._l12_2a=this._l23_2a=this._point=0},lineEnd:function(){(this._line||0!==this._line&&3===this._point)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){if(e=+e,t=+t,this._point){var n=this._x2-e,r=this._y2-t;this._l23_a=Math.sqrt(this._l23_2a=Math.pow(n*n+r*r,this._alpha))}switch(this._point){case 0:this._point=1;break;case 1:this._point=2;break;case 2:this._point=3,this._line?this._context.lineTo(this._x2,this._y2):this._context.moveTo(this._x2,this._y2);break;case 3:this._point=4;default:s_(this,e,t)}this._l01_a=this._l12_a,this._l12_a=this._l23_a,this._l01_2a=this._l12_2a,this._l12_2a=this._l23_2a,this._x0=this._x1,this._x1=this._x2,this._x2=e,this._y0=this._y1,this._y1=this._y2,this._y2=t}};var h_=function e(t){function n(e){return t?new d_(e,t):new o_(e,0)}return n.alpha=function(t){return e(+t)},n}(.5);function p_(e){this._context=e}function m_(e){return e<0?-1:1}function g_(e,t,n){var r=e._x1-e._x0,i=t-e._x1,o=(e._y1-e._y0)/(r||i<0&&-0),a=(n-e._y1)/(i||r<0&&-0),s=(o*i+a*r)/(r+i);return(m_(o)+m_(a))*Math.min(Math.abs(o),Math.abs(a),.5*Math.abs(s))||0}function b_(e,t){var n=e._x1-e._x0;return n?(3*(e._y1-e._y0)/n-t)/2:t}function v_(e,t,n){var r=e._x0,i=e._y0,o=e._x1,a=e._y1,s=(o-r)/3;e._context.bezierCurveTo(r+s,i+s*t,o-s,a-s*n,o,a)}function y_(e){this._context=e}function __(e){this._context=new w_(e)}function w_(e){this._context=e}function x_(e){this._context=e}function T_(e){var t,n,r=e.length-1,i=new Array(r),o=new Array(r),a=new Array(r);for(i[0]=0,o[0]=2,a[0]=e[0]+2*e[1],t=1;t=0;--t)i[t]=(a[t]-i[t+1])/o[t];for(o[r-1]=(e[r]+i[r-1])/2,t=0;t1)for(var n,r,i,o=1,a=e[t[0]],s=a.length;o=0;)n[t]=t;return n}function S_(e,t){return e[t]}function M_(e){const t=[];return t.key=e,t}function C_(e){var t=e.map(N_);return k_(e).sort((function(e,n){return t[e]-t[n]}))}function N_(e){for(var t,n=-1,r=0,i=e.length,o=-1/0;++no&&(o=t,r=n);return r}function D_(e){var t=e.map(L_);return k_(e).sort((function(e,n){return t[e]-t[n]}))}function L_(e){for(var t,n=0,r=-1,i=e.length;++r=0&&(this._t=1-this._t,this._line=1-this._line)},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;default:if(this._t<=0)this._context.lineTo(this._x,t),this._context.lineTo(e,t);else{var n=this._x*(1-this._t)+e*this._t;this._context.lineTo(n,this._y),this._context.lineTo(n,t)}}this._x=e,this._y=t}};var O_=e=>()=>e;function I_(e,{sourceEvent:t,target:n,transform:r,dispatch:i}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:r,enumerable:!0,configurable:!0},_:{value:i}})}function B_(e,t,n){this.k=e,this.x=t,this.y=n}B_.prototype={constructor:B_,scale:function(e){return 1===e?this:new B_(this.k*e,this.x,this.y)},translate:function(e,t){return 0===e&0===t?this:new B_(this.k,this.x+this.k*e,this.y+this.k*t)},apply:function(e){return[e[0]*this.k+this.x,e[1]*this.k+this.y]},applyX:function(e){return e*this.k+this.x},applyY:function(e){return e*this.k+this.y},invert:function(e){return[(e[0]-this.x)/this.k,(e[1]-this.y)/this.k]},invertX:function(e){return(e-this.x)/this.k},invertY:function(e){return(e-this.y)/this.k},rescaleX:function(e){return e.copy().domain(e.range().map(this.invertX,this).map(e.invert,e))},rescaleY:function(e){return e.copy().domain(e.range().map(this.invertY,this).map(e.invert,e))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var P_=new B_(1,0,0);function j_(e){for(;!e.__zoom;)if(!(e=e.parentNode))return P_;return e.__zoom}function R_(e){e.stopImmediatePropagation()}function z_(e){e.preventDefault(),e.stopImmediatePropagation()}function F_(e){return!(e.ctrlKey&&"wheel"!==e.type||e.button)}function q_(){var e=this;return e instanceof SVGElement?(e=e.ownerSVGElement||e).hasAttribute("viewBox")?[[(e=e.viewBox.baseVal).x,e.y],[e.x+e.width,e.y+e.height]]:[[0,0],[e.width.baseVal.value,e.height.baseVal.value]]:[[0,0],[e.clientWidth,e.clientHeight]]}function U_(){return this.__zoom||P_}function H_(e){return-e.deltaY*(1===e.deltaMode?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function V_(){return navigator.maxTouchPoints||"ontouchstart"in this}function G_(e,t,n){var r=e.invertX(t[0][0])-n[0][0],i=e.invertX(t[1][0])-n[1][0],o=e.invertY(t[0][1])-n[0][1],a=e.invertY(t[1][1])-n[1][1];return e.translate(i>r?(r+i)/2:Math.min(0,r)||Math.max(0,i),a>o?(o+a)/2:Math.min(0,o)||Math.max(0,a))}j_.prototype=B_.prototype,e.Adder=m,e.Delaunay=Va,e.FormatSpecifier=Ks,e.Voronoi=Ra,e.active=function(e,t){var n,r,i=e.__transition;if(i)for(r in t=null==t?null:t+"",i)if((n=i[r]).state>1&&n.name===t)return new Oi([[e]],ao,t,+r);return null},e.arc=function(){var e=Jv,t=ey,n=zv(0),r=null,i=ty,o=ny,a=ry,s=null;function l(){var l,c,u=+e.apply(this,arguments),f=+t.apply(this,arguments),d=i.apply(this,arguments)-Kv,h=o.apply(this,arguments)-Kv,p=Fv(h-d),m=h>d;if(s||(s=l=$o()),fYv)if(p>Xv-Yv)s.moveTo(f*Uv(d),f*Gv(d)),s.arc(0,0,f,d,h,!m),u>Yv&&(s.moveTo(u*Uv(h),u*Gv(h)),s.arc(0,0,u,h,d,m));else{var g,b,v=d,y=h,_=d,w=h,x=p,T=p,A=a.apply(this,arguments)/2,E=A>Yv&&(r?+r.apply(this,arguments):Wv(u*u+f*f)),k=Vv(Fv(f-u)/2,+n.apply(this,arguments)),S=k,M=k;if(E>Yv){var C=$v(E/u*Gv(A)),N=$v(E/f*Gv(A));(x-=2*C)>Yv?(_+=C*=m?1:-1,w-=C):(x=0,_=w=(d+h)/2),(T-=2*N)>Yv?(v+=N*=m?1:-1,y-=N):(T=0,v=y=(d+h)/2)}var D=f*Uv(v),L=f*Gv(v),O=u*Uv(w),I=u*Gv(w);if(k>Yv){var B,P=f*Uv(y),j=f*Gv(y),R=u*Uv(_),z=u*Gv(_);if(pYv?M>Yv?(g=oy(R,z,D,L,f,M,m),b=oy(P,j,O,I,f,M,m),s.moveTo(g.cx+g.x01,g.cy+g.y01),MYv&&x>Yv?S>Yv?(g=oy(O,I,P,j,u,-S,m),b=oy(D,L,R,z,u,-S,m),s.lineTo(g.cx+g.x01,g.cy+g.y01),S>a,c=i+2*s>>a,u=fa(20);function f(r){var i=new Float32Array(l*c),f=new Float32Array(l*c);r.forEach((function(r,o,u){var f=+e(r,o,u)+s>>a,d=+t(r,o,u)+s>>a,h=+n(r,o,u);f>=0&&f=0&&d>a),ya({width:l,height:c,data:f},{width:l,height:c,data:i},o>>a),va({width:l,height:c,data:i},{width:l,height:c,data:f},o>>a),ya({width:l,height:c,data:f},{width:l,height:c,data:i},o>>a),va({width:l,height:c,data:i},{width:l,height:c,data:f},o>>a),ya({width:l,height:c,data:f},{width:l,height:c,data:i},o>>a);var h=u(i);if(!Array.isArray(h)){var p=N(i);h=k(0,p,h),(h=q(0,Math.floor(p/h)*h,h)).shift()}return ba().thresholds(h).size([l,c])(i).map(d)}function d(e){return e.value*=Math.pow(2,-2*a),e.coordinates.forEach(h),e}function h(e){e.forEach(p)}function p(e){e.forEach(m)}function m(e){e[0]=e[0]*Math.pow(2,a)-s,e[1]=e[1]*Math.pow(2,a)-s}function g(){return l=r+2*(s=3*o)>>a,c=i+2*s>>a,f}return f.x=function(t){return arguments.length?(e="function"==typeof t?t:fa(+t),f):e},f.y=function(e){return arguments.length?(t="function"==typeof e?e:fa(+e),f):t},f.weight=function(e){return arguments.length?(n="function"==typeof e?e:fa(+e),f):n},f.size=function(e){if(!arguments.length)return[r,i];var t=+e[0],n=+e[1];if(!(t>=0&&n>=0))throw new Error("invalid size");return r=t,i=n,g()},f.cellSize=function(e){if(!arguments.length)return 1<=1))throw new Error("invalid cell size");return a=Math.floor(Math.log(e)/Math.LN2),g()},f.thresholds=function(e){return arguments.length?(u="function"==typeof e?e:Array.isArray(e)?fa(ca.call(e)):fa(e),f):u},f.bandwidth=function(e){if(!arguments.length)return Math.sqrt(o*(o+1));if(!((e=+e)>=0))throw new Error("invalid bandwidth");return o=Math.round((Math.sqrt(4*e*e+1)-1)/2),g()},f},e.contours=ba,e.count=l,e.create=function(e){return Tt(me(e).call(document.documentElement))},e.creator=me,e.cross=function(...e){const t="function"==typeof e[e.length-1]&&function(e){return t=>e(...t)}(e.pop()),n=(e=e.map(f)).map(c),r=e.length-1,i=new Array(r+1).fill(0),o=[];if(r<0||n.some(u))return o;for(;;){o.push(i.map(((t,n)=>e[n][t])));let a=r;for(;++i[a]===n[a];){if(0===a)return t?o.map(t):o;i[a--]=0}}},e.csv=ys,e.csvFormat=es,e.csvFormatBody=ts,e.csvFormatRow=rs,e.csvFormatRows=ns,e.csvFormatValue=is,e.csvParse=$a,e.csvParseRows=Ja,e.cubehelix=Gn,e.cumsum=function(e,t){var n=0,r=0;return Float64Array.from(e,void 0===t?e=>n+=+e||0:i=>n+=+t(i,r++,e)||0)},e.curveBasis=function(e){return new Ky(e)},e.curveBasisClosed=function(e){return new Xy(e)},e.curveBasisOpen=function(e){return new Qy(e)},e.curveBundle=Jy,e.curveCardinal=n_,e.curveCardinalClosed=i_,e.curveCardinalOpen=a_,e.curveCatmullRom=c_,e.curveCatmullRomClosed=f_,e.curveCatmullRomOpen=h_,e.curveLinear=cy,e.curveLinearClosed=function(e){return new p_(e)},e.curveMonotoneX=function(e){return new y_(e)},e.curveMonotoneY=function(e){return new __(e)},e.curveNatural=function(e){return new x_(e)},e.curveStep=function(e){return new A_(e,.5)},e.curveStepAfter=function(e){return new A_(e,1)},e.curveStepBefore=function(e){return new A_(e,0)},e.descending=function(e,t){return te?1:t>=e?0:NaN},e.deviation=h,e.difference=function(e,...t){e=new Set(e);for(const n of t)for(const t of n)e.delete(t);return e},e.disjoint=function(e,t){const n=t[Symbol.iterator](),r=new Set;for(const t of e){if(r.has(t))return!1;let e,i;for(;({value:e,done:i}=n.next())&&!i;){if(Object.is(t,e))return!1;r.add(e)}}return!0},e.dispatch=oe,e.drag=function(){var e,t,n,r,i=Bt,o=Pt,a=jt,s=Rt,l={},c=oe("start","drag","end"),u=0,f=0;function d(e){e.on("mousedown.drag",h).filter(s).on("touchstart.drag",g).on("touchmove.drag",b).on("touchend.drag touchcancel.drag",v).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function h(a,s){if(!r&&i.call(this,a,s)){var l=y(this,o.call(this,a,s),a,s,"mouse");l&&(Tt(a.view).on("mousemove.drag",p,!0).on("mouseup.drag",m,!0),Dt(a.view),Ct(a),n=!1,e=a.clientX,t=a.clientY,l("start",a))}}function p(r){if(Nt(r),!n){var i=r.clientX-e,o=r.clientY-t;n=i*i+o*o>f}l.mouse("drag",r)}function m(e){Tt(e.view).on("mousemove.drag mouseup.drag",null),Lt(e.view,n),Nt(e),l.mouse("end",e)}function g(e,t){if(i.call(this,e,t)){var n,r,a=e.changedTouches,s=o.call(this,e,t),l=a.length;for(n=0;n+e,e.easePoly=qi,e.easePolyIn=zi,e.easePolyInOut=qi,e.easePolyOut=Fi,e.easeQuad=ji,e.easeQuadIn=function(e){return e*e},e.easeQuadInOut=ji,e.easeQuadOut=function(e){return e*(2-e)},e.easeSin=Vi,e.easeSinIn=function(e){return 1==+e?1:1-Math.cos(e*Hi)},e.easeSinInOut=Vi,e.easeSinOut=function(e){return Math.sin(e*Hi)},e.every=function(e,t){if("function"!=typeof t)throw new TypeError("test is not a function");let n=-1;for(const r of e)if(!t(r,++n,e))return!1;return!0},e.extent=p,e.filter=function(e,t){if("function"!=typeof t)throw new TypeError("test is not a function");const n=[];let r=-1;for(const i of e)t(i,++r,e)&&n.push(i);return n},e.forceCenter=function(e,t){var n,r=1;function i(){var i,o,a=n.length,s=0,l=0;for(i=0;ic+p||ou+p||al.index){var m=c-s.x-s.vx,g=u-s.y-s.vy,b=m*m+g*g;be.r&&(e.r=e[t].r)}function l(){if(t){var r,i,o=t.length;for(n=new Array(o),r=0;r[s(e,t,r),e])));for(a=0,i=new Array(c);a=s)){(e.data!==t||e.next)&&(0===f&&(p+=(f=Bs(n))*f),0===d&&(p+=(d=Bs(n))*d),p(e=(1664525*e+1013904223)%Fs)/Fs}();function f(){d(),c.call("tick",t),n1?(null==n?s.delete(e):s.set(e,p(n)),t):s.get(e)},find:function(t,n,r){var i,o,a,s,l,c=0,u=e.length;for(null==r?r=1/0:r*=r,c=0;c1?(c.on(e,n),t):c.on(e)}}},e.forceX=function(e){var t,n,r,i=Is(.1);function o(e){for(var i,o=0,a=t.length;o=.12&&i<.234&&r>=-.425&&r<-.214?s:i>=.166&&i<.234&&r>=-.214&&r<-.115?l:a).invert(e)},u.stream=function(n){return e&&t===n?e:(r=[a.stream(t=n),s.stream(n),l.stream(n)],i=r.length,e={point:function(e,t){for(var n=-1;++nRc(r[0],r[1])&&(r[1]=i[1]),Rc(i[0],r[1])>Rc(r[0],r[1])&&(r[0]=i[0])):o.push(r=i);for(a=-1/0,t=0,r=o[n=o.length-1];t<=n;r=i,++t)i=o[t],(s=Rc(r[1],i[0]))>a&&(a=s,Hl=i[0],Gl=r[1])}return $l=Jl=null,Hl===1/0||Vl===1/0?[[NaN,NaN],[NaN,NaN]]:[[Hl,Vl],[Gl,Wl]]},e.geoCentroid=function(e){pc=mc=gc=bc=vc=yc=_c=wc=0,xc=new m,Tc=new m,Ac=new m,jl(e,qc);var t=+xc,n=+Tc,r=+Ac,i=wl(t,n,r);return i2?e[2]+90:90]):[(e=n())[0],e[1],e[2]-90]},n([0,0,90]).scale(159.155)},e.geoTransverseMercatorRaw=Md,e.gray=function(e,t){return new Sn(e,0,0,null==t?1:t)},e.greatest=function(e,n=t){let r,i=!1;if(1===n.length){let o;for(const a of e){const e=n(a);(i?t(e,o)>0:0===t(e,e))&&(r=a,o=e,i=!0)}}else for(const t of e)(i?n(t,r)>0:0===n(t,t))&&(r=t,i=!0);return r},e.greatestIndex=function(e,n=t){if(1===n.length)return P(e,n);let r,i=-1,o=-1;for(const t of e)++o,(i<0?0===n(t,t):n(t,r)>0)&&(r=t,i=o);return i},e.group=function(e,...t){return v(e,g,g,t)},e.groups=function(e,...t){return v(e,Array.from,g,t)},e.hcl=On,e.hierarchy=Od,e.histogram=C,e.hsl=mn,e.html=As,e.image=function(e,t){return new Promise((function(n,r){var i=new Image;for(var o in t)i[o]=t[o];i.onerror=r,i.onload=function(){n(i)},i.src=e}))},e.index=function(e,...t){return v(e,g,b,t)},e.indexes=function(e,...t){return v(e,Array.from,b,t)},e.interpolate=hr,e.interpolateArray=function(e,t){return(or(t)?ir:ar)(e,t)},e.interpolateBasis=Zn,e.interpolateBasisClosed=Kn,e.interpolateBlues=gv,e.interpolateBrBG=Mb,e.interpolateBuGn=Wb,e.interpolateBuPu=Zb,e.interpolateCividis=function(e){return e=Math.max(0,Math.min(1,e)),"rgb("+Math.max(0,Math.min(255,Math.round(-4.54-e*(35.34-e*(2381.73-e*(6402.7-e*(7024.72-2710.57*e)))))))+", "+Math.max(0,Math.min(255,Math.round(32.49+e*(170.73+e*(52.82-e*(131.46-e*(176.58-67.37*e)))))))+", "+Math.max(0,Math.min(255,Math.round(81.24+e*(442.36-e*(2482.43-e*(6167.24-e*(6614.94-2475.67*e)))))))+")"},e.interpolateCool=Cv,e.interpolateCubehelix=Dr,e.interpolateCubehelixDefault=Sv,e.interpolateCubehelixLong=Lr,e.interpolateDate=sr,e.interpolateDiscrete=function(e){var t=e.length;return function(n){return e[Math.max(0,Math.min(t-1,Math.floor(n*t)))]}},e.interpolateGnBu=Xb,e.interpolateGreens=vv,e.interpolateGreys=_v,e.interpolateHcl=Mr,e.interpolateHclLong=Cr,e.interpolateHsl=Er,e.interpolateHslLong=kr,e.interpolateHue=function(e,t){var n=$n(+e,+t);return function(e){var t=n(e);return t-360*Math.floor(t/360)}},e.interpolateInferno=jv,e.interpolateLab=function(e,t){var n=Jn((e=kn(e)).l,(t=kn(t)).l),r=Jn(e.a,t.a),i=Jn(e.b,t.b),o=Jn(e.opacity,t.opacity);return function(t){return e.l=n(t),e.a=r(t),e.b=i(t),e.opacity=o(t),e+""}},e.interpolateMagma=Pv,e.interpolateNumber=lr,e.interpolateNumberArray=ir,e.interpolateObject=cr,e.interpolateOrRd=$b,e.interpolateOranges=kv,e.interpolatePRGn=Nb,e.interpolatePiYG=Lb,e.interpolatePlasma=Rv,e.interpolatePuBu=nv,e.interpolatePuBuGn=ev,e.interpolatePuOr=Ib,e.interpolatePuRd=iv,e.interpolatePurples=xv,e.interpolateRainbow=function(e){(e<0||e>1)&&(e-=Math.floor(e));var t=Math.abs(e-.5);return Nv.h=360*e-100,Nv.s=1.5-1.5*t,Nv.l=.8-.9*t,Nv+""},e.interpolateRdBu=Pb,e.interpolateRdGy=Rb,e.interpolateRdPu=av,e.interpolateRdYlBu=Fb,e.interpolateRdYlGn=Ub,e.interpolateReds=Av,e.interpolateRgb=er,e.interpolateRgbBasis=nr,e.interpolateRgbBasisClosed=rr,e.interpolateRound=pr,e.interpolateSinebow=function(e){var t;return e=(.5-e)*Math.PI,Dv.r=255*(t=Math.sin(e))*t,Dv.g=255*(t=Math.sin(e+Lv))*t,Dv.b=255*(t=Math.sin(e+Ov))*t,Dv+""},e.interpolateSpectral=Vb,e.interpolateString=dr,e.interpolateTransformCss=_r,e.interpolateTransformSvg=wr,e.interpolateTurbo=function(e){return e=Math.max(0,Math.min(1,e)),"rgb("+Math.max(0,Math.min(255,Math.round(34.61+e*(1172.33-e*(10793.56-e*(33300.12-e*(38394.49-14825.05*e)))))))+", "+Math.max(0,Math.min(255,Math.round(23.31+e*(557.33+e*(1225.33-e*(3574.96-e*(1073.77+707.56*e)))))))+", "+Math.max(0,Math.min(255,Math.round(27.2+e*(3211.1-e*(15327.97-e*(27814-e*(22569.18-6838.66*e)))))))+")"},e.interpolateViridis=Bv,e.interpolateWarm=Mv,e.interpolateYlGn=uv,e.interpolateYlGnBu=lv,e.interpolateYlOrBr=dv,e.interpolateYlOrRd=pv,e.interpolateZoom=Tr,e.interrupt=oi,e.intersection=function(e,...t){e=new Set(e),t=t.map(Y);e:for(const n of e)for(const r of t)if(!r.has(n)){e.delete(n);continue e}return e},e.interval=function(e,t,n){var r=new Wr,i=t;return null==t?(r.restart(e,t,n),r):(r._restart=r.restart,r.restart=function(e,t,n){t=+t,n=null==n?Vr():+n,r._restart((function o(a){a+=i,r._restart(o,i+=t,n),e(a)}),t,n)},r.restart(e,t,n),r)},e.isoFormat=ib,e.isoParse=ob,e.json=function(e,t){return fetch(e,t).then(ws)},e.lab=kn,e.lch=function(e,t,n,r){return 1===arguments.length?Ln(e):new In(n,t,e,null==r?1:r)},e.least=function(e,n=t){let r,i=!1;if(1===n.length){let o;for(const a of e){const e=n(a);(i?t(e,o)<0:0===t(e,e))&&(r=a,o=e,i=!0)}}else for(const t of e)(i?n(t,r)<0:0===n(t,t))&&(r=t,i=!0);return r},e.leastIndex=U,e.line=dy,e.lineRadial=_y,e.linkHorizontal=function(){return Ey(ky)},e.linkRadial=function(){var e=Ey(My);return e.angle=e.x,delete e.x,e.radius=e.y,delete e.y,e},e.linkVertical=function(){return Ey(Sy)},e.local=Et,e.map=function(e,t){if("function"!=typeof e[Symbol.iterator])throw new TypeError("values is not iterable");if("function"!=typeof t)throw new TypeError("mapper is not a function");return Array.from(e,((n,r)=>t(n,r,e)))},e.matcher=we,e.max=N,e.maxIndex=P,e.mean=function(e,t){let n=0,r=0;if(void 0===t)for(let t of e)null!=t&&(t=+t)>=t&&(++n,r+=t);else{let i=-1;for(let o of e)null!=(o=t(o,++i,e))&&(o=+o)>=o&&(++n,r+=o)}if(n)return r/n},e.median=function(e,t){return I(e,.5,t)},e.merge=j,e.min=D,e.minIndex=R,e.namespace=de,e.namespaces=fe,e.nice=S,e.now=Vr,e.pack=function(){var e=null,t=1,n=1,r=eh;function i(i){return i.x=t/2,i.y=n/2,e?i.eachBefore(rh(e)).eachAfter(ih(r,.5)).eachBefore(oh(1)):i.eachBefore(rh(nh)).eachAfter(ih(eh,1)).eachAfter(ih(r,i.r/Math.min(t,n))).eachBefore(oh(Math.min(t,n)/(2*i.r))),i}return i.radius=function(t){return arguments.length?(e=$d(t),i):e},i.size=function(e){return arguments.length?(t=+e[0],n=+e[1],i):[t,n]},i.padding=function(e){return arguments.length?(r="function"==typeof e?e:th(+e),i):r},i},e.packEnclose=zd,e.packSiblings=function(e){return Qd(e),e},e.pairs=function(e,t=z){const n=[];let r,i=!1;for(const o of e)i&&n.push(t(r,o)),r=o,i=!0;return n},e.partition=function(){var e=1,t=1,n=0,r=!1;function i(i){var o=i.height+1;return i.x0=i.y0=n,i.x1=e,i.y1=t/o,i.eachBefore(function(e,t){return function(r){r.children&&sh(r,r.x0,e*(r.depth+1)/t,r.x1,e*(r.depth+2)/t);var i=r.x0,o=r.y0,a=r.x1-n,s=r.y1-n;a0&&(h+=f);for(null!=t?p.sort((function(e,n){return t(m[e],m[n])})):null!=n&&p.sort((function(e,t){return n(a[e],a[t])})),s=0,c=h?(b-d*y)/h:0;s0?f*c:0)+y,m[l]={data:a[l],index:s,value:f,startAngle:g,endAngle:u,padAngle:v};return m}return a.value=function(t){return arguments.length?(e="function"==typeof t?t:zv(+t),a):e},a.sortValues=function(e){return arguments.length?(t=e,n=null,a):t},a.sort=function(e){return arguments.length?(n=e,t=null,a):n},a.startAngle=function(e){return arguments.length?(r="function"==typeof e?e:zv(+e),a):r},a.endAngle=function(e){return arguments.length?(i="function"==typeof e?e:zv(+e),a):i},a.padAngle=function(e){return arguments.length?(o="function"==typeof e?e:zv(+e),a):o},a},e.piecewise=Or,e.pointRadial=xy,e.pointer=Mt,e.pointers=function(e,t){return e.target&&(e=St(e),void 0===t&&(t=e.currentTarget),e=e.touches||[e]),Array.from(e,(e=>Mt(e,t)))},e.polygonArea=function(e){for(var t,n=-1,r=e.length,i=e[r-1],o=0;++ns!=c>s&&a<(l-n)*(s-r)/(c-r)+n&&(u=!u),l=n,c=r;return u},e.polygonHull=function(e){if((n=e.length)<3)return null;var t,n,r=new Array(n),i=new Array(n);for(t=0;t=0;--t)c.push(e[r[o[t]][2]]);for(t=+s;t(t=1664525*t+1013904223|0,Vh*(t>>>0))},e.randomLogNormal=Nh,e.randomLogistic=Uh,e.randomNormal=Ch,e.randomPareto=Ih,e.randomPoisson=Hh,e.randomUniform=Sh,e.randomWeibull=Fh,e.range=q,e.reduce=function(e,t,n){if("function"!=typeof t)throw new TypeError("reducer is not a function");const r=e[Symbol.iterator]();let i,o,a=-1;if(arguments.length<3){if(({done:i,value:n}=r.next()),i)return;++a}for(;({done:i,value:o}=r.next()),!i;)n=t(n,o,++a,e);return n},e.reverse=function(e){if("function"!=typeof e[Symbol.iterator])throw new TypeError("values is not iterable");return Array.from(e).reverse()},e.rgb=ln,e.ribbon=function(){return la()},e.ribbonArrow=function(){return la(sa)},e.rollup=function(e,t,...n){return v(e,g,t,n)},e.rollups=function(e,t,...n){return v(e,Array.from,t,n)},e.scaleBand=Kh,e.scaleDiverging=function e(){var t=sp(hb()(Jh));return t.copy=function(){return fb(t,e())},Wh.apply(t,arguments)},e.scaleDivergingLog=function e(){var t=mp(hb()).domain([.1,1,10]);return t.copy=function(){return fb(t,e()).base(t.base())},Wh.apply(t,arguments)},e.scaleDivergingPow=pb,e.scaleDivergingSqrt=function(){return pb.apply(null,arguments).exponent(.5)},e.scaleDivergingSymlog=function e(){var t=vp(hb());return t.copy=function(){return fb(t,e()).constant(t.constant())},Wh.apply(t,arguments)},e.scaleIdentity=function e(t){var n;function r(e){return isNaN(e=+e)?n:e}return r.invert=r,r.domain=r.range=function(e){return arguments.length?(t=Array.from(e,Qh),r):t.slice()},r.unknown=function(e){return arguments.length?(n=e,r):n},r.copy=function(){return e(t).unknown(n)},t=arguments.length?Array.from(t,Qh):[0,1],sp(r)},e.scaleImplicit=Yh,e.scaleLinear=function e(){var t=op();return t.copy=function(){return rp(t,e())},Gh.apply(t,arguments),sp(t)},e.scaleLog=function e(){var t=mp(ip()).domain([1,10]);return t.copy=function(){return rp(t,e()).base(t.base())},Gh.apply(t,arguments),t},e.scaleOrdinal=Zh,e.scalePoint=function(){return Xh(Kh.apply(null,arguments).paddingInner(1))},e.scalePow=Tp,e.scaleQuantile=function e(){var n,r=[],i=[],a=[];function s(){var e=0,t=Math.max(1,i.length);for(a=new Array(t-1);++e0?a[t-1]:r[0],t=i?[a[i-1],r]:[a[t-1],a[t]]},l.unknown=function(e){return arguments.length?(t=e,l):l},l.thresholds=function(){return a.slice()},l.copy=function(){return e().domain([n,r]).range(s).unknown(t)},Gh.apply(sp(l),arguments)},e.scaleRadial=function e(){var t,n=op(),r=[0,1],i=!1;function o(e){var r=Ep(n(e));return isNaN(r)?t:i?Math.round(r):r}return o.invert=function(e){return n.invert(Ap(e))},o.domain=function(e){return arguments.length?(n.domain(e),o):n.domain()},o.range=function(e){return arguments.length?(n.range((r=Array.from(e,Qh)).map(Ap)),o):r.slice()},o.rangeRound=function(e){return o.range(e).round(!0)},o.round=function(e){return arguments.length?(i=!!e,o):i},o.clamp=function(e){return arguments.length?(n.clamp(e),o):n.clamp()},o.unknown=function(e){return arguments.length?(t=e,o):t},o.copy=function(){return e(n.domain(),r).round(i).clamp(n.clamp()).unknown(t)},Gh.apply(o,arguments),sp(o)},e.scaleSequential=function e(){var t=sp(ub()(Jh));return t.copy=function(){return fb(t,e())},Wh.apply(t,arguments)},e.scaleSequentialLog=function e(){var t=mp(ub()).domain([1,10]);return t.copy=function(){return fb(t,e()).base(t.base())},Wh.apply(t,arguments)},e.scaleSequentialPow=db,e.scaleSequentialQuantile=function e(){var n=[],r=Jh;function i(e){if(!isNaN(e=+e))return r((o(n,e,1)-1)/(n.length-1))}return i.domain=function(e){if(!arguments.length)return n.slice();n=[];for(let t of e)null==t||isNaN(t=+t)||n.push(t);return n.sort(t),i},i.interpolator=function(e){return arguments.length?(r=e,i):r},i.range=function(){return n.map(((e,t)=>r(t/(n.length-1))))},i.quantiles=function(e){return Array.from({length:e+1},((t,r)=>I(n,r/e)))},i.copy=function(){return e(r).domain(n)},Wh.apply(i,arguments)},e.scaleSequentialSqrt=function(){return db.apply(null,arguments).exponent(.5)},e.scaleSequentialSymlog=function e(){var t=vp(ub());return t.copy=function(){return fb(t,e()).constant(t.constant())},Wh.apply(t,arguments)},e.scaleSqrt=function(){return Tp.apply(null,arguments).exponent(.5)},e.scaleSymlog=function e(){var t=vp(ip());return t.copy=function(){return rp(t,e()).constant(t.constant())},Gh.apply(t,arguments)},e.scaleThreshold=function e(){var t,n=[.5],r=[0,1],i=1;function a(e){return e<=e?r[o(n,e,0,i)]:t}return a.domain=function(e){return arguments.length?(n=Array.from(e),i=Math.min(n.length,r.length-1),a):n.slice()},a.range=function(e){return arguments.length?(r=Array.from(e),i=Math.min(n.length,r.length-1),a):r.slice()},a.invertExtent=function(e){var t=r.indexOf(e);return[n[t-1],n[t]]},a.unknown=function(e){return arguments.length?(t=e,a):t},a.copy=function(){return e().domain(n).range(r).unknown(t)},Gh.apply(a,arguments)},e.scaleTime=function(){return Gh.apply(cb(sm,om,Gp,Up,Fp,Rp,Pp,Cp,e.timeFormat).domain([new Date(2e3,0,1),new Date(2e3,0,2)]),arguments)},e.scaleUtc=function(){return Gh.apply(cb(Lm,Nm,gm,hm,fm,cm,Pp,Cp,e.utcFormat).domain([Date.UTC(2e3,0,1),Date.UTC(2e3,0,2)]),arguments)},e.scan=function(e,t){const n=U(e,t);return n<0?void 0:n},e.schemeAccent=bb,e.schemeBlues=mv,e.schemeBrBG=Sb,e.schemeBuGn=Gb,e.schemeBuPu=Yb,e.schemeCategory10=gb,e.schemeDark2=vb,e.schemeGnBu=Kb,e.schemeGreens=bv,e.schemeGreys=yv,e.schemeOrRd=Qb,e.schemeOranges=Ev,e.schemePRGn=Cb,e.schemePaired=yb,e.schemePastel1=_b,e.schemePastel2=wb,e.schemePiYG=Db,e.schemePuBu=tv,e.schemePuBuGn=Jb,e.schemePuOr=Ob,e.schemePuRd=rv,e.schemePurples=wv,e.schemeRdBu=Bb,e.schemeRdGy=jb,e.schemeRdPu=ov,e.schemeRdYlBu=zb,e.schemeRdYlGn=qb,e.schemeReds=Tv,e.schemeSet1=xb,e.schemeSet2=Tb,e.schemeSet3=Ab,e.schemeSpectral=Hb,e.schemeTableau10=Eb,e.schemeYlGn=cv,e.schemeYlGnBu=sv,e.schemeYlOrBr=fv,e.schemeYlOrRd=hv,e.select=Tt,e.selectAll=function(e){return"string"==typeof e?new wt([document.querySelectorAll(e)],[document.documentElement]):new wt([null==e?[]:ve(e)],_t)},e.selection=xt,e.selector=be,e.selectorAll=_e,e.shuffle=H,e.shuffler=V,e.some=function(e,t){if("function"!=typeof t)throw new TypeError("test is not a function");let n=-1;for(const r of e)if(t(r,++n,e))return!0;return!1},e.sort=function(e,n=t){if("function"!=typeof e[Symbol.iterator])throw new TypeError("values is not iterable");return e=Array.from(e),1===n.length?(n=e.map(n),F(e,e.map(((e,t)=>t)).sort(((e,r)=>t(n[e],n[r]))))):e.sort(n)},e.stack=function(){var e=zv([]),t=k_,n=E_,r=S_;function i(i){var o,a,s=Array.from(e.apply(this,arguments),M_),l=s.length,c=-1;for(const e of i)for(o=0,++c;o0)for(var n,r,i,o,a,s,l=0,c=e[t[0]].length;l0?(r[0]=o,r[1]=o+=i):i<0?(r[1]=a,r[0]=a+=i):(r[0]=0,r[1]=i)},e.stackOffsetExpand=function(e,t){if((r=e.length)>0){for(var n,r,i,o=0,a=e[0].length;o0){for(var n,r=0,i=e[t[0]],o=i.length;r0&&(r=(n=e[t[0]]).length)>0){for(var n,r,i,o=0,a=1;a0)throw new Error("cycle");return o}return n.id=function(t){return arguments.length?(e=Jd(t),n):e},n.parentId=function(e){return arguments.length?(t=Jd(e),n):t},n},e.style=Ve,e.subset=function(e,t){return Z(t,e)},e.sum=function(e,t){let n=0;if(void 0===t)for(let t of e)(t=+t)&&(n+=t);else{let r=-1;for(let i of e)(i=+t(i,++r,e))&&(n+=i)}return n},e.superset=Z,e.svg=Es,e.symbol=function(e,t){var n=null;function r(){var r;if(n||(n=r=$o()),e.apply(this,arguments).draw(n,+t.apply(this,arguments)),r)return n=null,r+""||null}return e="function"==typeof e?e:zv(e||Cy),t="function"==typeof t?t:zv(void 0===t?64:+t),r.type=function(t){return arguments.length?(e="function"==typeof t?t:zv(t),r):e},r.size=function(e){return arguments.length?(t="function"==typeof e?e:zv(+e),r):t},r.context=function(e){return arguments.length?(n=null==e?null:e,r):n},r},e.symbolCircle=Cy,e.symbolCross=Ny,e.symbolDiamond=Oy,e.symbolSquare=Ry,e.symbolStar=jy,e.symbolTriangle=Fy,e.symbolWye=Gy,e.symbols=Wy,e.text=bs,e.thresholdFreedmanDiaconis=function(e,t,n){return Math.ceil((n-t)/(2*(I(e,.75)-I(e,.25))*Math.pow(l(e),-1/3)))},e.thresholdScott=function(e,t,n){return Math.ceil((n-t)/(3.5*h(e)*Math.pow(l(e),-1/3)))},e.thresholdSturges=M,e.tickFormat=ap,e.tickIncrement=E,e.tickStep=k,e.ticks=A,e.timeDay=Up,e.timeDays=Hp,e.timeFormatDefaultLocale=nb,e.timeFormatLocale=jm,e.timeFriday=Xp,e.timeFridays=rm,e.timeHour=Fp,e.timeHours=qp,e.timeInterval=Mp,e.timeMillisecond=Cp,e.timeMilliseconds=Np,e.timeMinute=Rp,e.timeMinutes=zp,e.timeMonday=Wp,e.timeMondays=Jp,e.timeMonth=om,e.timeMonths=am,e.timeSaturday=Qp,e.timeSaturdays=im,e.timeSecond=Pp,e.timeSeconds=jp,e.timeSunday=Gp,e.timeSundays=$p,e.timeThursday=Kp,e.timeThursdays=nm,e.timeTuesday=Yp,e.timeTuesdays=em,e.timeWednesday=Zp,e.timeWednesdays=tm,e.timeWeek=Gp,e.timeWeeks=$p,e.timeYear=sm,e.timeYears=lm,e.timeout=$r,e.timer=Yr,e.timerFlush=Zr,e.transition=Ii,e.transpose=G,e.tree=function(){var e=dh,t=1,n=1,r=null;function i(i){var l=function(e){for(var t,n,r,i,o,a=new bh(e,0),s=[a];t=s.pop();)if(r=t._.children)for(t.children=new Array(o=r.length),i=o-1;i>=0;--i)s.push(n=t.children[i]=new bh(r[i],i)),n.parent=t;return(a.parent=new bh(null,0)).children=[a],a}(i);if(l.eachAfter(o),l.parent.m=-l.z,l.eachBefore(a),r)i.eachBefore(s);else{var c=i,u=i,f=i;i.eachBefore((function(e){e.xu.x&&(u=e),e.depth>f.depth&&(f=e)}));var d=c===u?1:e(c,u)/2,h=d-c.x,p=t/(u.x+d+h),m=n/(f.depth||1);i.eachBefore((function(e){e.x=(e.x+h)*p,e.y=e.depth*m}))}return i}function o(t){var n=t.children,r=t.parent.children,i=t.i?r[t.i-1]:null;if(n){!function(e){for(var t,n=0,r=0,i=e.children,o=i.length;--o>=0;)(t=i[o]).z+=n,t.m+=n,n+=t.s+(r+=t.c)}(t);var o=(n[0].z+n[n.length-1].z)/2;i?(t.z=i.z+e(t._,i._),t.m=t.z-o):t.z=o}else i&&(t.z=i.z+e(t._,i._));t.parent.A=function(t,n,r){if(n){for(var i,o=t,a=t,s=n,l=o.parent.children[0],c=o.m,u=a.m,f=s.m,d=l.m;s=ph(s),o=hh(o),s&&o;)l=hh(l),(a=ph(a)).a=t,(i=s.z+f-o.z-c+e(s._,o._))>0&&(mh(gh(s,t,r),t,i),c+=i,u+=i),f+=s.m,c+=o.m,d+=l.m,u+=a.m;s&&!ph(a)&&(a.t=s,a.m+=f-u),o&&!hh(l)&&(l.t=o,l.m+=c-d,r=t)}return r}(t,i,t.parent.A||r[0])}function a(e){e._.x=e.z+e.parent.m,e.m+=e.parent.m}function s(e){e.x*=t,e.y=e.depth*n}return i.separation=function(t){return arguments.length?(e=t,i):e},i.size=function(e){return arguments.length?(r=!1,t=+e[0],n=+e[1],i):r?null:[t,n]},i.nodeSize=function(e){return arguments.length?(r=!0,t=+e[0],n=+e[1],i):r?[t,n]:null},i},e.treemap=function(){var e=wh,t=!1,n=1,r=1,i=[0],o=eh,a=eh,s=eh,l=eh,c=eh;function u(e){return e.x0=e.y0=0,e.x1=n,e.y1=r,e.eachBefore(f),i=[0],t&&e.eachBefore(ah),e}function f(t){var n=i[t.depth],r=t.x0+n,u=t.y0+n,f=t.x1-n,d=t.y1-n;f=n-1){var u=s[t];return u.x0=i,u.y0=o,u.x1=a,void(u.y1=l)}for(var f=c[t],d=r/2+f,h=t+1,p=n-1;h>>1;c[m]l-o){var v=r?(i*b+a*g)/r:a;e(t,h,g,i,o,v,l),e(h,n,b,v,o,a,l)}else{var y=r?(o*b+l*g)/r:l;e(t,h,g,i,o,a,y),e(h,n,b,i,y,a,l)}}(0,l,e.value,t,n,r,i)},e.treemapDice=sh,e.treemapResquarify=xh,e.treemapSlice=vh,e.treemapSliceDice=function(e,t,n,r,i){(1&e.depth?vh:sh)(e,t,n,r,i)},e.treemapSquarify=wh,e.tsv=_s,e.tsvFormat=ls,e.tsvFormatBody=cs,e.tsvFormatRow=fs,e.tsvFormatRows=us,e.tsvFormatValue=ds,e.tsvParse=as,e.tsvParseRows=ss,e.union=function(...e){const t=new Set;for(const n of e)for(const e of n)t.add(e);return t},e.utcDay=hm,e.utcDays=pm,e.utcFriday=wm,e.utcFridays=Mm,e.utcHour=fm,e.utcHours=dm,e.utcMillisecond=Cp,e.utcMilliseconds=Np,e.utcMinute=cm,e.utcMinutes=um,e.utcMonday=bm,e.utcMondays=Am,e.utcMonth=Nm,e.utcMonths=Dm,e.utcSaturday=xm,e.utcSaturdays=Cm,e.utcSecond=Pp,e.utcSeconds=jp,e.utcSunday=gm,e.utcSundays=Tm,e.utcThursday=_m,e.utcThursdays=Sm,e.utcTuesday=vm,e.utcTuesdays=Em,e.utcWednesday=ym,e.utcWednesdays=km,e.utcWeek=gm,e.utcWeeks=Tm,e.utcYear=Lm,e.utcYears=Om,e.variance=d,e.version="6.3.0",e.window=Fe,e.xml=Ts,e.zip=function(){return G(arguments)},e.zoom=function(){var e,t,n,r=F_,i=q_,o=G_,a=H_,s=V_,l=[0,1/0],c=[[-1/0,-1/0],[1/0,1/0]],u=250,f=Tr,d=oe("start","zoom","end"),h=500,p=0,m=10;function g(e){e.property("__zoom",U_).on("wheel.zoom",T).on("mousedown.zoom",A).on("dblclick.zoom",E).filter(s).on("touchstart.zoom",k).on("touchmove.zoom",S).on("touchend.zoom touchcancel.zoom",M).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function b(e,t){return(t=Math.max(l[0],Math.min(l[1],t)))===e.k?e:new B_(t,e.x,e.y)}function v(e,t,n){var r=t[0]-n[0]*e.k,i=t[1]-n[1]*e.k;return r===e.x&&i===e.y?e:new B_(e.k,r,i)}function y(e){return[(+e[0][0]+ +e[1][0])/2,(+e[0][1]+ +e[1][1])/2]}function _(e,t,n,r){e.on("start.zoom",(function(){w(this,arguments).event(r).start()})).on("interrupt.zoom end.zoom",(function(){w(this,arguments).event(r).end()})).tween("zoom",(function(){var e=this,o=arguments,a=w(e,o).event(r),s=i.apply(e,o),l=null==n?y(s):"function"==typeof n?n.apply(e,o):n,c=Math.max(s[1][0]-s[0][0],s[1][1]-s[0][1]),u=e.__zoom,d="function"==typeof t?t.apply(e,o):t,h=f(u.invert(l).concat(c/u.k),d.invert(l).concat(c/d.k));return function(e){if(1===e)e=d;else{var t=h(e),n=c/t[2];e=new B_(n,l[0]-t[0]*n,l[1]-t[1]*n)}a.zoom(null,e)}}))}function w(e,t,n){return!n&&e.__zooming||new x(e,t)}function x(e,t){this.that=e,this.args=t,this.active=0,this.sourceEvent=null,this.extent=i.apply(e,t),this.taps=0}function T(e,...t){if(r.apply(this,arguments)){var n=w(this,t).event(e),i=this.__zoom,s=Math.max(l[0],Math.min(l[1],i.k*Math.pow(2,a.apply(this,arguments)))),u=Mt(e);if(n.wheel)n.mouse[0][0]===u[0]&&n.mouse[0][1]===u[1]||(n.mouse[1]=i.invert(n.mouse[0]=u)),clearTimeout(n.wheel);else{if(i.k===s)return;n.mouse=[u,i.invert(u)],oi(this),n.start()}z_(e),n.wheel=setTimeout(f,150),n.zoom("mouse",o(v(b(i,s),n.mouse[0],n.mouse[1]),n.extent,c))}function f(){n.wheel=null,n.end()}}function A(e,...t){if(!n&&r.apply(this,arguments)){var i=w(this,t,!0).event(e),a=Tt(e.view).on("mousemove.zoom",d,!0).on("mouseup.zoom",h,!0),s=Mt(e,l),l=e.currentTarget,u=e.clientX,f=e.clientY;Dt(e.view),R_(e),i.mouse=[s,this.__zoom.invert(s)],oi(this),i.start()}function d(e){if(z_(e),!i.moved){var t=e.clientX-u,n=e.clientY-f;i.moved=t*t+n*n>p}i.event(e).zoom("mouse",o(v(i.that.__zoom,i.mouse[0]=Mt(e,l),i.mouse[1]),i.extent,c))}function h(e){a.on("mousemove.zoom mouseup.zoom",null),Lt(e.view,i.moved),z_(e),i.event(e).end()}}function E(e,...t){if(r.apply(this,arguments)){var n=this.__zoom,a=Mt(e.changedTouches?e.changedTouches[0]:e,this),s=n.invert(a),l=n.k*(e.shiftKey?.5:2),f=o(v(b(n,l),a,s),i.apply(this,t),c);z_(e),u>0?Tt(this).transition().duration(u).call(_,f,a,e):Tt(this).call(g.transform,f,a,e)}}function k(n,...i){if(r.apply(this,arguments)){var o,a,s,l,c=n.touches,u=c.length,f=w(this,i,n.changedTouches.length===u).event(n);for(R_(n),a=0;a>2,s=(3&t)<<4|n>>4,l=1>6:64,c=2>4,n=(15&a)<<4|(s=o.indexOf(e.charAt(c++)))>>2,r=(3&s)<<6|(l=o.indexOf(e.charAt(c++))),d[u++]=t,64!==s&&(d[u++]=n),64!==l&&(d[u++]=r);return d}},{"./support":30,"./utils":32}],2:[function(e,t,n){"use strict";var r=e("./external"),i=e("./stream/DataWorker"),o=e("./stream/DataLengthProbe"),a=e("./stream/Crc32Probe");function s(e,t,n,r,i){this.compressedSize=e,this.uncompressedSize=t,this.crc32=n,this.compression=r,this.compressedContent=i}o=e("./stream/DataLengthProbe"),s.prototype={getContentWorker:function(){var e=new i(r.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new o("data_length")),t=this;return e.on("end",(function(){if(this.streamInfo.data_length!==t.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")})),e},getCompressedWorker:function(){return new i(r.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}},s.createWorkerFrom=function(e,t,n){return e.pipe(new a).pipe(new o("uncompressedSize")).pipe(t.compressWorker(n)).pipe(new o("compressedSize")).withStreamInfo("compression",t)},t.exports=s},{"./external":6,"./stream/Crc32Probe":25,"./stream/DataLengthProbe":26,"./stream/DataWorker":27}],3:[function(e,t,n){"use strict";var r=e("./stream/GenericWorker");n.STORE={magic:"\0\0",compressWorker:function(e){return new r("STORE compression")},uncompressWorker:function(){return new r("STORE decompression")}},n.DEFLATE=e("./flate")},{"./flate":7,"./stream/GenericWorker":28}],4:[function(e,t,n){"use strict";var r=e("./utils"),i=function(){for(var e,t=[],n=0;n<256;n++){e=n;for(var r=0;r<8;r++)e=1&e?3988292384^e>>>1:e>>>1;t[n]=e}return t}();t.exports=function(e,t){return void 0!==e&&e.length?"string"!==r.getTypeOf(e)?function(e,t,n,r){var o=i,a=0+n;e^=-1;for(var s=0;s>>8^o[255&(e^t[s])];return-1^e}(0|t,e,e.length):function(e,t,n,r){var o=i,a=0+n;e^=-1;for(var s=0;s>>8^o[255&(e^t.charCodeAt(s))];return-1^e}(0|t,e,e.length):0}},{"./utils":32}],5:[function(e,t,n){"use strict";n.base64=!1,n.binary=!1,n.dir=!1,n.createFolders=!0,n.date=null,n.compression=null,n.compressionOptions=null,n.comment=null,n.unixPermissions=null,n.dosPermissions=null},{}],6:[function(e,t,n){"use strict";var r;r="undefined"!=typeof Promise?Promise:e("lie"),t.exports={Promise:r}},{lie:37}],7:[function(e,t,n){"use strict";var r="undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint16Array&&"undefined"!=typeof Uint32Array,i=e("pako"),o=e("./utils"),a=e("./stream/GenericWorker"),s=r?"uint8array":"array";function l(e,t){a.call(this,"FlateWorker/"+e),this._pako=null,this._pakoAction=e,this._pakoOptions=t,this.meta={}}n.magic="\b\0",o.inherits(l,a),l.prototype.processChunk=function(e){this.meta=e.meta,null===this._pako&&this._createPako(),this._pako.push(o.transformTo(s,e.data),!1)},l.prototype.flush=function(){a.prototype.flush.call(this),null===this._pako&&this._createPako(),this._pako.push([],!0)},l.prototype.cleanUp=function(){a.prototype.cleanUp.call(this),this._pako=null},l.prototype._createPako=function(){this._pako=new i[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var e=this;this._pako.onData=function(t){e.push({data:t,meta:e.meta})}},n.compressWorker=function(e){return new l("Deflate",e)},n.uncompressWorker=function(){return new l("Inflate",{})}},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(e,t,n){"use strict";function r(e,t){var n,r="";for(n=0;n>>=8;return r}function i(e,t,n,i,a,u){var f,d,h=e.file,p=e.compression,m=u!==s.utf8encode,g=o.transformTo("string",u(h.name)),b=o.transformTo("string",s.utf8encode(h.name)),v=h.comment,y=o.transformTo("string",u(v)),_=o.transformTo("string",s.utf8encode(v)),w=b.length!==h.name.length,x=_.length!==v.length,T="",A="",E="",k=h.dir,S=h.date,M={crc32:0,compressedSize:0,uncompressedSize:0};t&&!n||(M.crc32=e.crc32,M.compressedSize=e.compressedSize,M.uncompressedSize=e.uncompressedSize);var C=0;t&&(C|=8),m||!w&&!x||(C|=2048);var N=0,D=0;k&&(N|=16),"UNIX"===a?(D=798,N|=function(e,t){var n=e;return e||(n=t?16893:33204),(65535&n)<<16}(h.unixPermissions,k)):(D=20,N|=function(e){return 63&(e||0)}(h.dosPermissions)),f=S.getUTCHours(),f<<=6,f|=S.getUTCMinutes(),f<<=5,f|=S.getUTCSeconds()/2,d=S.getUTCFullYear()-1980,d<<=4,d|=S.getUTCMonth()+1,d<<=5,d|=S.getUTCDate(),w&&(A=r(1,1)+r(l(g),4)+b,T+="up"+r(A.length,2)+A),x&&(E=r(1,1)+r(l(y),4)+_,T+="uc"+r(E.length,2)+E);var L="";return L+="\n\0",L+=r(C,2),L+=p.magic,L+=r(f,2),L+=r(d,2),L+=r(M.crc32,4),L+=r(M.compressedSize,4),L+=r(M.uncompressedSize,4),L+=r(g.length,2),L+=r(T.length,2),{fileRecord:c.LOCAL_FILE_HEADER+L+g+T,dirRecord:c.CENTRAL_FILE_HEADER+r(D,2)+L+r(y.length,2)+"\0\0\0\0"+r(N,4)+r(i,4)+g+T+y}}var o=e("../utils"),a=e("../stream/GenericWorker"),s=e("../utf8"),l=e("../crc32"),c=e("../signature");function u(e,t,n,r){a.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=t,this.zipPlatform=n,this.encodeFileName=r,this.streamFiles=e,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}o.inherits(u,a),u.prototype.push=function(e){var t=e.meta.percent||0,n=this.entriesCount,r=this._sources.length;this.accumulate?this.contentBuffer.push(e):(this.bytesWritten+=e.data.length,a.prototype.push.call(this,{data:e.data,meta:{currentFile:this.currentFile,percent:n?(t+100*(n-r-1))/n:100}}))},u.prototype.openedSource=function(e){this.currentSourceOffset=this.bytesWritten,this.currentFile=e.file.name;var t=this.streamFiles&&!e.file.dir;if(t){var n=i(e,t,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:n.fileRecord,meta:{percent:0}})}else this.accumulate=!0},u.prototype.closedSource=function(e){this.accumulate=!1;var t=this.streamFiles&&!e.file.dir,n=i(e,t,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(n.dirRecord),t)this.push({data:function(e){return c.DATA_DESCRIPTOR+r(e.crc32,4)+r(e.compressedSize,4)+r(e.uncompressedSize,4)}(e),meta:{percent:100}});else for(this.push({data:n.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},u.prototype.flush=function(){for(var e=this.bytesWritten,t=0;t=this.index;t--)n=(n<<8)+this.byteAt(t);return this.index+=e,n},readString:function(e){return r.transformTo("string",this.readData(e))},readData:function(e){},lastIndexOfSignature:function(e){},readAndCheckSignature:function(e){},readDate:function(){var e=this.readInt(4);return new Date(Date.UTC(1980+(e>>25&127),(e>>21&15)-1,e>>16&31,e>>11&31,e>>5&63,(31&e)<<1))}},t.exports=i},{"../utils":32}],19:[function(e,t,n){"use strict";var r=e("./Uint8ArrayReader");function i(e){r.call(this,e)}e("../utils").inherits(i,r),i.prototype.readData=function(e){this.checkOffset(e);var t=this.data.slice(this.zero+this.index,this.zero+this.index+e);return this.index+=e,t},t.exports=i},{"../utils":32,"./Uint8ArrayReader":21}],20:[function(e,t,n){"use strict";var r=e("./DataReader");function i(e){r.call(this,e)}e("../utils").inherits(i,r),i.prototype.byteAt=function(e){return this.data.charCodeAt(this.zero+e)},i.prototype.lastIndexOfSignature=function(e){return this.data.lastIndexOf(e)-this.zero},i.prototype.readAndCheckSignature=function(e){return e===this.readData(4)},i.prototype.readData=function(e){this.checkOffset(e);var t=this.data.slice(this.zero+this.index,this.zero+this.index+e);return this.index+=e,t},t.exports=i},{"../utils":32,"./DataReader":18}],21:[function(e,t,n){"use strict";var r=e("./ArrayReader");function i(e){r.call(this,e)}e("../utils").inherits(i,r),i.prototype.readData=function(e){if(this.checkOffset(e),0===e)return new Uint8Array(0);var t=this.data.subarray(this.zero+this.index,this.zero+this.index+e);return this.index+=e,t},t.exports=i},{"../utils":32,"./ArrayReader":17}],22:[function(e,t,n){"use strict";var r=e("../utils"),i=e("../support"),o=e("./ArrayReader"),a=e("./StringReader"),s=e("./NodeBufferReader"),l=e("./Uint8ArrayReader");t.exports=function(e){var t=r.getTypeOf(e);return r.checkSupport(t),"string"!==t||i.uint8array?"nodebuffer"===t?new s(e):i.uint8array?new l(r.transformTo("uint8array",e)):new o(r.transformTo("array",e)):new a(e)}},{"../support":30,"../utils":32,"./ArrayReader":17,"./NodeBufferReader":19,"./StringReader":20,"./Uint8ArrayReader":21}],23:[function(e,t,n){"use strict";n.LOCAL_FILE_HEADER="PK",n.CENTRAL_FILE_HEADER="PK",n.CENTRAL_DIRECTORY_END="PK",n.ZIP64_CENTRAL_DIRECTORY_LOCATOR="PK",n.ZIP64_CENTRAL_DIRECTORY_END="PK",n.DATA_DESCRIPTOR="PK\b"},{}],24:[function(e,t,n){"use strict";var r=e("./GenericWorker"),i=e("../utils");function o(e){r.call(this,"ConvertWorker to "+e),this.destType=e}i.inherits(o,r),o.prototype.processChunk=function(e){this.push({data:i.transformTo(this.destType,e.data),meta:e.meta})},t.exports=o},{"../utils":32,"./GenericWorker":28}],25:[function(e,t,n){"use strict";var r=e("./GenericWorker"),i=e("../crc32");function o(){r.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0)}e("../utils").inherits(o,r),o.prototype.processChunk=function(e){this.streamInfo.crc32=i(e.data,this.streamInfo.crc32||0),this.push(e)},t.exports=o},{"../crc32":4,"../utils":32,"./GenericWorker":28}],26:[function(e,t,n){"use strict";var r=e("../utils"),i=e("./GenericWorker");function o(e){i.call(this,"DataLengthProbe for "+e),this.propName=e,this.withStreamInfo(e,0)}r.inherits(o,i),o.prototype.processChunk=function(e){if(e){var t=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=t+e.data.length}i.prototype.processChunk.call(this,e)},t.exports=o},{"../utils":32,"./GenericWorker":28}],27:[function(e,t,n){"use strict";var r=e("../utils"),i=e("./GenericWorker");function o(e){i.call(this,"DataWorker");var t=this;this.dataIsReady=!1,this.index=0,this.max=0,this.data=null,this.type="",this._tickScheduled=!1,e.then((function(e){t.dataIsReady=!0,t.data=e,t.max=e&&e.length||0,t.type=r.getTypeOf(e),t.isPaused||t._tickAndRepeat()}),(function(e){t.error(e)}))}r.inherits(o,i),o.prototype.cleanUp=function(){i.prototype.cleanUp.call(this),this.data=null},o.prototype.resume=function(){return!!i.prototype.resume.call(this)&&(!this._tickScheduled&&this.dataIsReady&&(this._tickScheduled=!0,r.delay(this._tickAndRepeat,[],this)),!0)},o.prototype._tickAndRepeat=function(){this._tickScheduled=!1,this.isPaused||this.isFinished||(this._tick(),this.isFinished||(r.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0))},o.prototype._tick=function(){if(this.isPaused||this.isFinished)return!1;var e=null,t=Math.min(this.max,this.index+16384);if(this.index>=this.max)return this.end();switch(this.type){case"string":e=this.data.substring(this.index,t);break;case"uint8array":e=this.data.subarray(this.index,t);break;case"array":case"nodebuffer":e=this.data.slice(this.index,t)}return this.index=t,this.push({data:e,meta:{percent:this.max?this.index/this.max*100:0}})},t.exports=o},{"../utils":32,"./GenericWorker":28}],28:[function(e,t,n){"use strict";function r(e){this.name=e||"default",this.streamInfo={},this.generatedError=null,this.extraStreamInfo={},this.isPaused=!0,this.isFinished=!1,this.isLocked=!1,this._listeners={data:[],end:[],error:[]},this.previous=null}r.prototype={push:function(e){this.emit("data",e)},end:function(){if(this.isFinished)return!1;this.flush();try{this.emit("end"),this.cleanUp(),this.isFinished=!0}catch(e){this.emit("error",e)}return!0},error:function(e){return!this.isFinished&&(this.isPaused?this.generatedError=e:(this.isFinished=!0,this.emit("error",e),this.previous&&this.previous.error(e),this.cleanUp()),!0)},on:function(e,t){return this._listeners[e].push(t),this},cleanUp:function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[]},emit:function(e,t){if(this._listeners[e])for(var n=0;n "+e:e}},t.exports=r},{}],29:[function(e,t,n){"use strict";var r=e("../utils"),i=e("./ConvertWorker"),o=e("./GenericWorker"),a=e("../base64"),s=e("../support"),l=e("../external"),c=null;if(s.nodestream)try{c=e("../nodejs/NodejsStreamOutputAdapter")}catch(e){}function u(e,t,n){var a=t;switch(t){case"blob":case"arraybuffer":a="uint8array";break;case"base64":a="string"}try{this._internalType=a,this._outputType=t,this._mimeType=n,r.checkSupport(a),this._worker=e.pipe(new i(a)),e.lock()}catch(e){this._worker=new o("error"),this._worker.error(e)}}u.prototype={accumulate:function(e){return function(e,t){return new l.Promise((function(n,i){var o=[],s=e._internalType,l=e._outputType,c=e._mimeType;e.on("data",(function(e,n){o.push(e),t&&t(n)})).on("error",(function(e){o=[],i(e)})).on("end",(function(){try{var e=function(e,t,n){switch(e){case"blob":return r.newBlob(r.transformTo("arraybuffer",t),n);case"base64":return a.encode(t);default:return r.transformTo(e,t)}}(l,function(e,t){var n,r=0,i=null,o=0;for(n=0;n>>6:(n<65536?t[a++]=224|n>>>12:(t[a++]=240|n>>>18,t[a++]=128|n>>>12&63),t[a++]=128|n>>>6&63),t[a++]=128|63&n);return t}(e)},n.utf8decode=function(e){return i.nodebuffer?r.transformTo("nodebuffer",e).toString("utf-8"):function(e){var t,n,i,o,a=e.length,l=new Array(2*a);for(t=n=0;t>10&1023,l[n++]=56320|1023&i)}return l.length!==n&&(l.subarray?l=l.subarray(0,n):l.length=n),r.applyFromCharCode(l)}(e=r.transformTo(i.uint8array?"uint8array":"array",e))},r.inherits(c,a),c.prototype.processChunk=function(e){var t=r.transformTo(i.uint8array?"uint8array":"array",e.data);if(this.leftOver&&this.leftOver.length){if(i.uint8array){var o=t;(t=new Uint8Array(o.length+this.leftOver.length)).set(this.leftOver,0),t.set(o,this.leftOver.length)}else t=this.leftOver.concat(t);this.leftOver=null}var a=function(e,t){var n;for((t=t||e.length)>e.length&&(t=e.length),n=t-1;0<=n&&128==(192&e[n]);)n--;return n<0||0===n?t:n+s[e[n]]>t?n:t}(t),l=t;a!==t.length&&(i.uint8array?(l=t.subarray(0,a),this.leftOver=t.subarray(a,t.length)):(l=t.slice(0,a),this.leftOver=t.slice(a,t.length))),this.push({data:n.utf8decode(l),meta:e.meta})},c.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:n.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},n.Utf8DecodeWorker=c,r.inherits(u,a),u.prototype.processChunk=function(e){this.push({data:n.utf8encode(e.data),meta:e.meta})},n.Utf8EncodeWorker=u},{"./nodejsUtils":14,"./stream/GenericWorker":28,"./support":30,"./utils":32}],32:[function(e,t,n){"use strict";var r=e("./support"),i=e("./base64"),o=e("./nodejsUtils"),a=e("set-immediate-shim"),s=e("./external");function l(e){return e}function c(e,t){for(var n=0;n>8;this.dir=!!(16&this.externalFileAttributes),0==e&&(this.dosPermissions=63&this.externalFileAttributes),3==e&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||"/"!==this.fileNameStr.slice(-1)||(this.dir=!0)},parseZIP64ExtraField:function(e){if(this.extraFields[1]){var t=r(this.extraFields[1].value);this.uncompressedSize===i.MAX_VALUE_32BITS&&(this.uncompressedSize=t.readInt(8)),this.compressedSize===i.MAX_VALUE_32BITS&&(this.compressedSize=t.readInt(8)),this.localHeaderOffset===i.MAX_VALUE_32BITS&&(this.localHeaderOffset=t.readInt(8)),this.diskNumberStart===i.MAX_VALUE_32BITS&&(this.diskNumberStart=t.readInt(4))}},readExtraFields:function(e){var t,n,r,i=e.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});e.index>>6:(n<65536?t[a++]=224|n>>>12:(t[a++]=240|n>>>18,t[a++]=128|n>>>12&63),t[a++]=128|n>>>6&63),t[a++]=128|63&n);return t},n.buf2binstring=function(e){return l(e,e.length)},n.binstring2buf=function(e){for(var t=new r.Buf8(e.length),n=0,i=t.length;n>10&1023,c[r++]=56320|1023&i)}return l(c,r)},n.utf8border=function(e,t){var n;for((t=t||e.length)>e.length&&(t=e.length),n=t-1;0<=n&&128==(192&e[n]);)n--;return n<0||0===n?t:n+a[e[n]]>t?n:t}},{"./common":41}],43:[function(e,t,n){"use strict";t.exports=function(e,t,n,r){for(var i=65535&e|0,o=e>>>16&65535|0,a=0;0!==n;){for(n-=a=2e3>>1:e>>>1;t[n]=e}return t}();t.exports=function(e,t,n,i){var o=r,a=i+n;e^=-1;for(var s=i;s>>8^o[255&(e^t[s])];return-1^e}},{}],46:[function(e,t,n){"use strict";var r,i=e("../utils/common"),o=e("./trees"),a=e("./adler32"),s=e("./crc32"),l=e("./messages"),c=-2,u=258,f=262,d=113;function h(e,t){return e.msg=l[t],t}function p(e){return(e<<1)-(4e.avail_out&&(n=e.avail_out),0!==n&&(i.arraySet(e.output,t.pending_buf,t.pending_out,n,e.next_out),e.next_out+=n,t.pending_out+=n,e.total_out+=n,e.avail_out-=n,t.pending-=n,0===t.pending&&(t.pending_out=0))}function b(e,t){o._tr_flush_block(e,0<=e.block_start?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,g(e.strm)}function v(e,t){e.pending_buf[e.pending++]=t}function y(e,t){e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=255&t}function _(e,t){var n,r,i=e.max_chain_length,o=e.strstart,a=e.prev_length,s=e.nice_match,l=e.strstart>e.w_size-f?e.strstart-(e.w_size-f):0,c=e.window,d=e.w_mask,h=e.prev,p=e.strstart+u,m=c[o+a-1],g=c[o+a];e.prev_length>=e.good_match&&(i>>=2),s>e.lookahead&&(s=e.lookahead);do{if(c[(n=t)+a]===g&&c[n+a-1]===m&&c[n]===c[o]&&c[++n]===c[o+1]){o+=2,n++;do{}while(c[++o]===c[++n]&&c[++o]===c[++n]&&c[++o]===c[++n]&&c[++o]===c[++n]&&c[++o]===c[++n]&&c[++o]===c[++n]&&c[++o]===c[++n]&&c[++o]===c[++n]&&ol&&0!=--i);return a<=e.lookahead?a:e.lookahead}function w(e){var t,n,r,o,l,c,u,d,h,p,m=e.w_size;do{if(o=e.window_size-e.lookahead-e.strstart,e.strstart>=m+(m-f)){for(i.arraySet(e.window,e.window,m,m,0),e.match_start-=m,e.strstart-=m,e.block_start-=m,t=n=e.hash_size;r=e.head[--t],e.head[t]=m<=r?r-m:0,--n;);for(t=n=m;r=e.prev[--t],e.prev[t]=m<=r?r-m:0,--n;);o+=m}if(0===e.strm.avail_in)break;if(c=e.strm,u=e.window,d=e.strstart+e.lookahead,p=void 0,(h=o)<(p=c.avail_in)&&(p=h),n=0===p?0:(c.avail_in-=p,i.arraySet(u,c.input,c.next_in,p,d),1===c.state.wrap?c.adler=a(c.adler,u,p,d):2===c.state.wrap&&(c.adler=s(c.adler,u,p,d)),c.next_in+=p,c.total_in+=p,p),e.lookahead+=n,e.lookahead+e.insert>=3)for(l=e.strstart-e.insert,e.ins_h=e.window[l],e.ins_h=(e.ins_h<=3&&(e.ins_h=(e.ins_h<=3)if(r=o._tr_tally(e,e.strstart-e.match_start,e.match_length-3),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=3){for(e.match_length--;e.strstart++,e.ins_h=(e.ins_h<=3&&(e.ins_h=(e.ins_h<=3&&e.match_length<=e.prev_length){for(i=e.strstart+e.lookahead-3,r=o._tr_tally(e,e.strstart-1-e.prev_match,e.prev_length-3),e.lookahead-=e.prev_length-1,e.prev_length-=2;++e.strstart<=i&&(e.ins_h=(e.ins_h<e.pending_buf_size-5&&(n=e.pending_buf_size-5);;){if(e.lookahead<=1){if(w(e),0===e.lookahead&&0===t)return 1;if(0===e.lookahead)break}e.strstart+=e.lookahead,e.lookahead=0;var r=e.block_start+n;if((0===e.strstart||e.strstart>=r)&&(e.lookahead=e.strstart-r,e.strstart=r,b(e,!1),0===e.strm.avail_out))return 1;if(e.strstart-e.block_start>=e.w_size-f&&(b(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,4===t?(b(e,!0),0===e.strm.avail_out?3:4):(e.strstart>e.block_start&&(b(e,!1),e.strm.avail_out),1)})),new A(4,4,8,4,x),new A(4,5,16,8,x),new A(4,6,32,32,x),new A(4,4,16,16,T),new A(8,16,32,32,T),new A(8,16,128,128,T),new A(8,32,128,256,T),new A(32,128,258,1024,T),new A(32,258,258,4096,T)],n.deflateInit=function(e,t){return M(e,t,8,15,8,0)},n.deflateInit2=M,n.deflateReset=S,n.deflateResetKeep=k,n.deflateSetHeader=function(e,t){return e&&e.state?2!==e.state.wrap?c:(e.state.gzhead=t,0):c},n.deflate=function(e,t){var n,i,a,l;if(!e||!e.state||5>8&255),v(i,i.gzhead.time>>16&255),v(i,i.gzhead.time>>24&255),v(i,9===i.level?2:2<=i.strategy||i.level<2?4:0),v(i,255&i.gzhead.os),i.gzhead.extra&&i.gzhead.extra.length&&(v(i,255&i.gzhead.extra.length),v(i,i.gzhead.extra.length>>8&255)),i.gzhead.hcrc&&(e.adler=s(e.adler,i.pending_buf,i.pending,0)),i.gzindex=0,i.status=69):(v(i,0),v(i,0),v(i,0),v(i,0),v(i,0),v(i,9===i.level?2:2<=i.strategy||i.level<2?4:0),v(i,3),i.status=d);else{var f=8+(i.w_bits-8<<4)<<8;f|=(2<=i.strategy||i.level<2?0:i.level<6?1:6===i.level?2:3)<<6,0!==i.strstart&&(f|=32),f+=31-f%31,i.status=d,y(i,f),0!==i.strstart&&(y(i,e.adler>>>16),y(i,65535&e.adler)),e.adler=1}if(69===i.status)if(i.gzhead.extra){for(a=i.pending;i.gzindex<(65535&i.gzhead.extra.length)&&(i.pending!==i.pending_buf_size||(i.gzhead.hcrc&&i.pending>a&&(e.adler=s(e.adler,i.pending_buf,i.pending-a,a)),g(e),a=i.pending,i.pending!==i.pending_buf_size));)v(i,255&i.gzhead.extra[i.gzindex]),i.gzindex++;i.gzhead.hcrc&&i.pending>a&&(e.adler=s(e.adler,i.pending_buf,i.pending-a,a)),i.gzindex===i.gzhead.extra.length&&(i.gzindex=0,i.status=73)}else i.status=73;if(73===i.status)if(i.gzhead.name){a=i.pending;do{if(i.pending===i.pending_buf_size&&(i.gzhead.hcrc&&i.pending>a&&(e.adler=s(e.adler,i.pending_buf,i.pending-a,a)),g(e),a=i.pending,i.pending===i.pending_buf_size)){l=1;break}l=i.gzindexa&&(e.adler=s(e.adler,i.pending_buf,i.pending-a,a)),0===l&&(i.gzindex=0,i.status=91)}else i.status=91;if(91===i.status)if(i.gzhead.comment){a=i.pending;do{if(i.pending===i.pending_buf_size&&(i.gzhead.hcrc&&i.pending>a&&(e.adler=s(e.adler,i.pending_buf,i.pending-a,a)),g(e),a=i.pending,i.pending===i.pending_buf_size)){l=1;break}l=i.gzindexa&&(e.adler=s(e.adler,i.pending_buf,i.pending-a,a)),0===l&&(i.status=103)}else i.status=103;if(103===i.status&&(i.gzhead.hcrc?(i.pending+2>i.pending_buf_size&&g(e),i.pending+2<=i.pending_buf_size&&(v(i,255&e.adler),v(i,e.adler>>8&255),e.adler=0,i.status=d)):i.status=d),0!==i.pending){if(g(e),0===e.avail_out)return i.last_flush=-1,0}else if(0===e.avail_in&&p(t)<=p(n)&&4!==t)return h(e,-5);if(666===i.status&&0!==e.avail_in)return h(e,-5);if(0!==e.avail_in||0!==i.lookahead||0!==t&&666!==i.status){var _=2===i.strategy?function(e,t){for(var n;;){if(0===e.lookahead&&(w(e),0===e.lookahead)){if(0===t)return 1;break}if(e.match_length=0,n=o._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,n&&(b(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,4===t?(b(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(b(e,!1),0===e.strm.avail_out)?1:2}(i,t):3===i.strategy?function(e,t){for(var n,r,i,a,s=e.window;;){if(e.lookahead<=u){if(w(e),e.lookahead<=u&&0===t)return 1;if(0===e.lookahead)break}if(e.match_length=0,e.lookahead>=3&&0e.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=3?(n=o._tr_tally(e,1,e.match_length-3),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(n=o._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),n&&(b(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,4===t?(b(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(b(e,!1),0===e.strm.avail_out)?1:2}(i,t):r[i.level].func(i,t);if(3!==_&&4!==_||(i.status=666),1===_||3===_)return 0===e.avail_out&&(i.last_flush=-1),0;if(2===_&&(1===t?o._tr_align(i):5!==t&&(o._tr_stored_block(i,0,0,!1),3===t&&(m(i.head),0===i.lookahead&&(i.strstart=0,i.block_start=0,i.insert=0))),g(e),0===e.avail_out))return i.last_flush=-1,0}return 4!==t?0:i.wrap<=0?1:(2===i.wrap?(v(i,255&e.adler),v(i,e.adler>>8&255),v(i,e.adler>>16&255),v(i,e.adler>>24&255),v(i,255&e.total_in),v(i,e.total_in>>8&255),v(i,e.total_in>>16&255),v(i,e.total_in>>24&255)):(y(i,e.adler>>>16),y(i,65535&e.adler)),g(e),0=n.w_size&&(0===s&&(m(n.head),n.strstart=0,n.block_start=0,n.insert=0),d=new i.Buf8(n.w_size),i.arraySet(d,t,h-n.w_size,n.w_size,0),t=d,h=n.w_size),l=e.avail_in,u=e.next_in,f=e.input,e.avail_in=h,e.next_in=0,e.input=t,w(n);n.lookahead>=3;){for(r=n.strstart,o=n.lookahead-2;n.ins_h=(n.ins_h<>>=_=y>>>24,p-=_,0==(_=y>>>16&255))k[o++]=65535&y;else{if(!(16&_)){if(0==(64&_)){y=m[(65535&y)+(h&(1<<_)-1)];continue t}if(32&_){n.mode=12;break e}e.msg="invalid literal/length code",n.mode=30;break e}w=65535&y,(_&=15)&&(p<_&&(h+=E[r++]<>>=_,p-=_),p<15&&(h+=E[r++]<>>=_=y>>>24,p-=_,!(16&(_=y>>>16&255))){if(0==(64&_)){y=g[(65535&y)+(h&(1<<_)-1)];continue n}e.msg="invalid distance code",n.mode=30;break e}if(x=65535&y,p<(_&=15)&&(h+=E[r++]<>>=_,p-=_,(_=o-a)>3,h&=(1<<(p-=w<<3))-1,e.next_in=r,e.next_out=o,e.avail_in=r>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24)}function u(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new r.Buf16(320),this.work=new r.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function f(e){var t;return e&&e.state?(t=e.state,e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=1&t.wrap),t.mode=1,t.last=0,t.havedict=0,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new r.Buf32(852),t.distcode=t.distdyn=new r.Buf32(592),t.sane=1,t.back=-1,0):l}function d(e){var t;return e&&e.state?((t=e.state).wsize=0,t.whave=0,t.wnext=0,f(e)):l}function h(e,t){var n,r;return e&&e.state?(r=e.state,t<0?(n=0,t=-t):(n=1+(t>>4),t<48&&(t&=15)),t&&(t<8||15=a.wsize?(r.arraySet(a.window,t,n-a.wsize,a.wsize,0),a.wnext=0,a.whave=a.wsize):(i<(o=a.wsize-a.wnext)&&(o=i),r.arraySet(a.window,t,n-i,o,a.wnext),(i-=o)?(r.arraySet(a.window,t,n-i,i,0),a.wnext=i,a.whave=a.wsize):(a.wnext+=o,a.wnext===a.wsize&&(a.wnext=0),a.whave>>8&255,n.check=o(n.check,P,2,0),b=g=0,n.mode=2;break}if(n.flags=0,n.head&&(n.head.done=!1),!(1&n.wrap)||(((255&g)<<8)+(g>>8))%31){e.msg="incorrect header check",n.mode=30;break}if(8!=(15&g)){e.msg="unknown compression method",n.mode=30;break}if(b-=4,D=8+(15&(g>>>=4)),0===n.wbits)n.wbits=D;else if(D>n.wbits){e.msg="invalid window size",n.mode=30;break}n.dmax=1<>8&1),512&n.flags&&(P[0]=255&g,P[1]=g>>>8&255,n.check=o(n.check,P,2,0)),b=g=0,n.mode=3;case 3:for(;b<32;){if(0===p)break e;p--,g+=u[d++]<>>8&255,P[2]=g>>>16&255,P[3]=g>>>24&255,n.check=o(n.check,P,4,0)),b=g=0,n.mode=4;case 4:for(;b<16;){if(0===p)break e;p--,g+=u[d++]<>8),512&n.flags&&(P[0]=255&g,P[1]=g>>>8&255,n.check=o(n.check,P,2,0)),b=g=0,n.mode=5;case 5:if(1024&n.flags){for(;b<16;){if(0===p)break e;p--,g+=u[d++]<>>8&255,n.check=o(n.check,P,2,0)),b=g=0}else n.head&&(n.head.extra=null);n.mode=6;case 6:if(1024&n.flags&&(p<(x=n.length)&&(x=p),x&&(n.head&&(D=n.head.extra_len-n.length,n.head.extra||(n.head.extra=new Array(n.head.extra_len)),r.arraySet(n.head.extra,u,d,x,D)),512&n.flags&&(n.check=o(n.check,u,x,d)),p-=x,d+=x,n.length-=x),n.length))break e;n.length=0,n.mode=7;case 7:if(2048&n.flags){if(0===p)break e;for(x=0;D=u[d+x++],n.head&&D&&n.length<65536&&(n.head.name+=String.fromCharCode(D)),D&&x>9&1,n.head.done=!0),e.adler=n.check=0,n.mode=12;break;case 10:for(;b<32;){if(0===p)break e;p--,g+=u[d++]<>>=7&b,b-=7&b,n.mode=27;break}for(;b<3;){if(0===p)break e;p--,g+=u[d++]<>>=1)){case 0:n.mode=14;break;case 1:if(v(n),n.mode=20,6!==t)break;g>>>=2,b-=2;break e;case 2:n.mode=17;break;case 3:e.msg="invalid block type",n.mode=30}g>>>=2,b-=2;break;case 14:for(g>>>=7&b,b-=7&b;b<32;){if(0===p)break e;p--,g+=u[d++]<>>16^65535)){e.msg="invalid stored block lengths",n.mode=30;break}if(n.length=65535&g,b=g=0,n.mode=15,6===t)break e;case 15:n.mode=16;case 16:if(x=n.length){if(p>>=5,b-=5,n.ndist=1+(31&g),g>>>=5,b-=5,n.ncode=4+(15&g),g>>>=4,b-=4,286>>=3,b-=3}for(;n.have<19;)n.lens[j[n.have++]]=0;if(n.lencode=n.lendyn,n.lenbits=7,O={bits:n.lenbits},L=s(0,n.lens,0,19,n.lencode,0,n.work,O),n.lenbits=O.bits,L){e.msg="invalid code lengths set",n.mode=30;break}n.have=0,n.mode=19;case 19:for(;n.have>>16&255,S=65535&B,!((E=B>>>24)<=b);){if(0===p)break e;p--,g+=u[d++]<>>=E,b-=E,n.lens[n.have++]=S;else{if(16===S){for(I=E+2;b>>=E,b-=E,0===n.have){e.msg="invalid bit length repeat",n.mode=30;break}D=n.lens[n.have-1],x=3+(3&g),g>>>=2,b-=2}else if(17===S){for(I=E+3;b>>=E)),g>>>=3,b-=3}else{for(I=E+7;b>>=E)),g>>>=7,b-=7}if(n.have+x>n.nlen+n.ndist){e.msg="invalid bit length repeat",n.mode=30;break}for(;x--;)n.lens[n.have++]=D}}if(30===n.mode)break;if(0===n.lens[256]){e.msg="invalid code -- missing end-of-block",n.mode=30;break}if(n.lenbits=9,O={bits:n.lenbits},L=s(1,n.lens,0,n.nlen,n.lencode,0,n.work,O),n.lenbits=O.bits,L){e.msg="invalid literal/lengths set",n.mode=30;break}if(n.distbits=6,n.distcode=n.distdyn,O={bits:n.distbits},L=s(2,n.lens,n.nlen,n.ndist,n.distcode,0,n.work,O),n.distbits=O.bits,L){e.msg="invalid distances set",n.mode=30;break}if(n.mode=20,6===t)break e;case 20:n.mode=21;case 21:if(6<=p&&258<=m){e.next_out=h,e.avail_out=m,e.next_in=d,e.avail_in=p,n.hold=g,n.bits=b,a(e,w),h=e.next_out,f=e.output,m=e.avail_out,d=e.next_in,u=e.input,p=e.avail_in,g=n.hold,b=n.bits,12===n.mode&&(n.back=-1);break}for(n.back=0;k=(B=n.lencode[g&(1<>>16&255,S=65535&B,!((E=B>>>24)<=b);){if(0===p)break e;p--,g+=u[d++]<>M)])>>>16&255,S=65535&B,!(M+(E=B>>>24)<=b);){if(0===p)break e;p--,g+=u[d++]<>>=M,b-=M,n.back+=M}if(g>>>=E,b-=E,n.back+=E,n.length=S,0===k){n.mode=26;break}if(32&k){n.back=-1,n.mode=12;break}if(64&k){e.msg="invalid literal/length code",n.mode=30;break}n.extra=15&k,n.mode=22;case 22:if(n.extra){for(I=n.extra;b>>=n.extra,b-=n.extra,n.back+=n.extra}n.was=n.length,n.mode=23;case 23:for(;k=(B=n.distcode[g&(1<>>16&255,S=65535&B,!((E=B>>>24)<=b);){if(0===p)break e;p--,g+=u[d++]<>M)])>>>16&255,S=65535&B,!(M+(E=B>>>24)<=b);){if(0===p)break e;p--,g+=u[d++]<>>=M,b-=M,n.back+=M}if(g>>>=E,b-=E,n.back+=E,64&k){e.msg="invalid distance code",n.mode=30;break}n.offset=S,n.extra=15&k,n.mode=24;case 24:if(n.extra){for(I=n.extra;b>>=n.extra,b-=n.extra,n.back+=n.extra}if(n.offset>n.dmax){e.msg="invalid distance too far back",n.mode=30;break}n.mode=25;case 25:if(0===m)break e;if(x=w-m,n.offset>x){if((x=n.offset-x)>n.whave&&n.sane){e.msg="invalid distance too far back",n.mode=30;break}T=x>n.wnext?(x-=n.wnext,n.wsize-x):n.wnext-x,x>n.length&&(x=n.length),A=n.window}else A=f,T=h-n.offset,x=n.length;for(mv?(_=j[R+f[A]],O[I+f[A]]):(_=96,0),h=1<>C)+(p-=h)]=y<<24|_<<16|w|0,0!==p;);for(h=1<>=1;if(0!==h?(L&=h-1,L+=h):L=0,A++,0==--B[T]){if(T===k)break;T=t[n+f[A]]}if(S>>7)]}function E(e,t){e.pending_buf[e.pending++]=255&t,e.pending_buf[e.pending++]=t>>>8&255}function k(e,t,n){e.bi_valid>16-n?(e.bi_buf|=t<>16-e.bi_valid,e.bi_valid+=n-16):(e.bi_buf|=t<>>=1,n<<=1,0<--t;);return n>>>1}function C(e,t,n){var r,i,o=new Array(16),a=0;for(r=1;r<=l;r++)o[r]=a=a+n[r-1]<<1;for(i=0;i<=t;i++){var s=e[2*i+1];0!==s&&(e[2*i]=M(o[s]++,s))}}function N(e){var t;for(t=0;t>1;1<=n;n--)O(e,o,n);for(i=c;n=e.heap[1],e.heap[1]=e.heap[e.heap_len--],O(e,o,1),r=e.heap[1],e.heap[--e.heap_max]=n,e.heap[--e.heap_max]=r,o[2*i]=o[2*n]+o[2*r],e.depth[i]=(e.depth[n]>=e.depth[r]?e.depth[n]:e.depth[r])+1,o[2*n+1]=o[2*r+1]=i,e.heap[1]=i++,O(e,o,1),2<=e.heap_len;);e.heap[--e.heap_max]=e.heap[1],function(e,t){var n,r,i,o,a,s,c=t.dyn_tree,u=t.max_code,f=t.stat_desc.static_tree,d=t.stat_desc.has_stree,h=t.stat_desc.extra_bits,p=t.stat_desc.extra_base,m=t.stat_desc.max_length,g=0;for(o=0;o<=l;o++)e.bl_count[o]=0;for(c[2*e.heap[e.heap_max]+1]=0,n=e.heap_max+1;n<573;n++)m<(o=c[2*c[2*(r=e.heap[n])+1]+1]+1)&&(o=m,g++),c[2*r+1]=o,u>=7;r>>=1)if(1&n&&0!==e.dyn_ltree[2*t])return 0;if(0!==e.dyn_ltree[18]||0!==e.dyn_ltree[20]||0!==e.dyn_ltree[26])return 1;for(t=32;t>>3,(a=e.static_len+3+7>>>3)<=i&&(i=a)):i=a=n+5,n+4<=i&&-1!==t?z(e,t,n,r):4===e.strategy||a===i?(k(e,2+(r?1:0),3),I(e,h,p)):(k(e,4+(r?1:0),3),function(e,t,n,r){var i;for(k(e,t-257,5),k(e,n-1,5),k(e,r-4,4),i=0;i>>8&255,e.pending_buf[e.d_buf+2*e.last_lit+1]=255&t,e.pending_buf[e.l_buf+e.last_lit]=255&n,e.last_lit++,0===t?e.dyn_ltree[2*n]++:(e.matches++,t--,e.dyn_ltree[2*(g[n]+o+1)]++,e.dyn_dtree[2*A(t)]++),e.last_lit===e.lit_bufsize-1},n._tr_align=function(e){k(e,2,3),S(e,256,h),function(e){16===e.bi_valid?(E(e,e.bi_buf),e.bi_buf=0,e.bi_valid=0):8<=e.bi_valid&&(e.pending_buf[e.pending++]=255&e.bi_buf,e.bi_buf>>=8,e.bi_valid-=8)}(e)}},{"../utils/common":41}],53:[function(e,t,n){"use strict";t.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}},{}],54:[function(e,t,n){"use strict";t.exports="function"==typeof setImmediate?setImmediate:function(){var e=[].slice.apply(arguments);e.splice(1,0,0),setTimeout.apply(null,e)}},{}]},{},[10])(10)})),function(e,t){if("object"==typeof module&&module.exports){var n=require("d3");module.exports=t(n)}else if("function"==typeof define&&define.amd){try{n=require("d3")}catch(t){n=e.d3}n.contextMenu=t(n),define([],(function(){return n.contextMenu}))}else e.d3&&(e.d3.contextMenu=t(e.d3))}(this,(function(e){var t={noop:function(){},isFn:function(e){return"function"==typeof e},const:function(e){return function(){return e}},toFactory:function(e,n){return e=void 0===e?n:e,t.isFn(e)?e:t.const(e)}},n=null,r=function(){n&&(e.select(".d3-context-menu").remove(),e.select("body").on("mousedown.d3-context-menu",null),n.boundCloseCallback(),n=null)};return function(i,o){if("close"===i)return r();i=t.toFactory(i);var a=(o=t.isFn(o)?{onOpen:o}:o||{}).onOpen||t.noop,s=o.onClose||t.noop,l=t.toFactory(o.position),c=t.toFactory(o.theme,"d3-context-menu-theme");return function(o,u){var f,d=this;if(void 0===e.event?(f=o,u,void 0):(f=e.event,o,u),r(),n={boundCloseCallback:s.bind(d,o,u)},e.selectAll(".d3-context-menu").data([1]).enter().append("div").attr("class","d3-context-menu "+c.bind(d)(o,u)),e.select("body").on("mousedown.d3-context-menu",r),e.select("body").on("click.d3-context-menu",r),e.selectAll(".d3-context-menu").on("contextmenu",(function(){r(),f.preventDefault(),f.stopPropagation()})).append("ul").call((function n(a,s,l=0){var c=function(e){return t.toFactory(e).call(s,o,u)};a.selectAll("li").data((function(e){var t=0===l?i:e.children;return c(t)})).enter().append("li").each((function(t){var i=!!c(t.divider),a=!!c(t.disabled),f=!!c(t.children),d=!!t.action,h=i?"
              ":c(t.title),p=e.select(this).classed("is-divider",i).classed("is-disabled",a).classed("is-header",!f&&!d).classed("is-parent",f).html(h).on("click",(function(){!a&&d&&(t.action.call(s,o,u),r())}));if(f){var m=p.append("ul").classed("is-children",!0);n(m,s,++l)}}))}),d),!1!==a.bind(d)(o,u)){var h=l.bind(d)(o,u),p=document.documentElement,m=window.innerWidth||p.clientWidth,g=window.innerHeight||p.clientHeight,b="left",v="right",y=h?h.left:f.pageX-2;f.pageX>m/2&&(b="right",v="left",y=h?m-h.left:m-f.pageX-2);var _="top",w="bottom",x=h?h.top:f.pageY-2;f.pageY>g/2&&(_="bottom",w="top",x=h?g-h.top:g-f.pageY-2),e.select(".d3-context-menu").style(b,y+"px").style(v,null).style(_,x+"px").style(w,null).style("display","block"),f.preventDefault(),f.stopPropagation()}}}})),function(e,t){const n="*",r=Object.defineProperties,i=Object.entries,o=(e,t)=>(n,r)=>(e.has(n)?e.get(n).add(r):e.set(n,(new Set).add(r)),t),a=(e,t)=>(r,i)=>{if(r!==n||i)if(i){const t=e.get(r);t&&(t.delete(i),0===t.size&&e.delete(r))}else e.delete(r);else e.clear();return t},s=(e,t)=>(e,n)=>t.on(e,(function r(...i){t.off(e,r),n.apply(t,i)})),l=(e,t)=>(r,...i)=>{const o=e.get(r);return o&&o.forEach((e=>e.apply(t,i))),e.get(n)&&r!==n&&t.trigger(n,r,...i),t},c=function(e){const t=new Map;return r(e=e||{},i({on:o,off:a,one:s,trigger:l}).reduce(((n,[r,i])=>(n[r]={value:i(t,e),enumerable:!1,writable:!1,configurable:!1},n)),{})),e};"object"==typeof exports?module.exports=c:"function"==typeof r&&r.amd?r((function(){return c})):e.observable=c}("undefined"!=typeof window?window:void 0),t=this,e=function(e){"use strict";function t(e){return e.replace(/-(\w)/g,((e,t)=>t.toUpperCase()))}function n(e,t){e.firstChild&&(t.appendChild(e.firstChild),n(e,t))}function r(e){Array.from(e).forEach(i)}const i=e=>e&&e.parentNode&&e.parentNode.removeChild(e),o=(e,t)=>t&&t.parentNode&&t.parentNode.insertBefore(e,t);var a={EACH:0,IF:1,SIMPLE:2,TAG:3,SLOT:4},s={ATTRIBUTE:0,EVENT:1,TEXT:2,VALUE:3};function l(e,t){return typeof e===t}function c(e){const t=e.ownerSVGElement;return!!t||null===t}function u(e){return!h(e.content)}function f(e){return l(e,"function")}function d(e){return!h(e)&&l(e,"object")}function h(e){return null==e}const p=Symbol("unmount"),m=Object.seal({nodes:[],mount(e,t){return this.update(e,t)},update(e,t){const{placeholder:n,nodes:r,childrenMap:a}=this,s=e===p?null:this.evaluate(e),l=s?Array.from(s):[],{newChildrenMap:c,batches:u,futureNodes:f}=(n.parentNode,function(e,t,n,r){const{condition:i,template:o,childrenMap:a,itemName:s,getKey:l,indexName:c,root:u,isTemplateTag:f}=r,d=new Map,h=[],p=[];return e.forEach(((e,r)=>{const m=function(e,t){let{itemName:n,indexName:r,index:i,item:o}=t;return e[n]=o,r&&(e[r]=i),e}(Object.create(t),{itemName:s,indexName:c,index:r,item:e}),g=l?l(m):r,b=a.get(g);if(function(e,t){return!!e&&!1===Boolean(e(t))}(i,m))return;const v=b?b.template:o.clone(),y=b?v.el:u.cloneNode(),_=!b,w=f&&_?function(e){const t=e.dom.cloneNode(!0);return{avoidDOMInjection:!0,fragment:t,children:Array.from(t.childNodes)}}(v):{};if(_?h.push((()=>v.mount(y,m,n,w))):h.push((()=>v.update(m,n))),f){const e=w.children||v.children;p.push(...e)}else p.push(y);a.delete(g),d.set(g,{template:v,context:m,index:r})})),{newChildrenMap:d,batches:h,futureNodes:p}}(l,e,t,this));return((e,t,n,r,a)=>{const s=n.length;let l=t.length,c=s,u=0,f=0,d=null;for(;ue-f){const i=r(t[u],0);for(;f{if(r<0){const n=e.pop();if(n){const{template:e,context:r}=n;e.unmount(r,t,null)}}return n}}(Array.from(a.values()),t),n),u.forEach((e=>e())),this.childrenMap=c,this.nodes=f,this},unmount(e,t){return this.update(p,t),this}}),g=Object.seal({mount(e,t){return this.update(e,t)},update(e,t){const n=!!this.evaluate(e),r=!this.value&&n,i=this.value&&!n,a=()=>{const n=this.node.cloneNode();o(n,this.placeholder),this.template=this.template.clone(),this.template.mount(n,e,t)};switch(!0){case r:a();break;case i:this.unmount(e);break;default:n&&this.template.update(e,t)}return this.value=n,this},unmount(e,t){return this.template.unmount(e,t,!0),this}});function b(e){throw new Error(e)}function v(e){return e.reduce(((e,n)=>{const{value:r,type:i}=n;switch(!0){case!n.name&&0===i:return Object.assign({},e,r);case 3===i:e.value=n.value;break;default:e[t(n.name)]=n.value}return e}),{})}const y="undefined"==typeof Element?{}:Element.prototype,_=function(e){const t=new Map,n=n=>(t.has(n)||t.set(n,e.call(this,n)))&&t.get(n);return n.cache=t,n}((e=>y.hasOwnProperty(e)));const w=/^on/,x={handleEvent(e){this[e.type](e)}},T=new WeakMap;function A(e){return h(e)?"":e}const E=(e,t)=>{const n=e.childNodes[t];if(n.nodeType===Node.COMMENT_NODE){const t=document.createTextNode("");return e.replaceChild(t,n),t}return n};var k={0:function e(t,n,r,i){let{name:o}=n;if(!o)return i&&function(e,t,n){const r=t?Object.keys(t):[];Object.keys(n).filter((e=>!r.includes(e))).forEach((t=>e.removeAttribute(t)))}(t,r,i),void(r&&function(t,n){Object.entries(n).forEach((n=>{let[r,i]=n;return e(t,{name:r},i)}))}(t,r));!_(o)&&(function(e){return l(e,"boolean")}(r)||d(r)||f(r))&&(t[o]=r),t[function(e){return h(e)||!1===e||""===e||d(e)||f(e)?"removeAttribute":"setAttribute"}(r)](o,function(e,t){return!0===t?e:t}(o,r))},1:function(e,t,n){let{name:r}=t;const i=r.replace(w,""),o=T.get(e)||(e=>{const t=Object.create(x);return T.set(e,t),t})(e),[a,s]=(e=>Array.isArray(e)?e:[e,!1])(n),l=o[i],c=a&&!l;l&&!a&&e.removeEventListener(i,o),c&&e.addEventListener(i,o,s),o[i]=a},2:function(e,t,n){e.data=A(n)},3:function(e,t,n){e.value=A(n)}};const S=Object.seal({mount(e){return this.value=this.evaluate(e),M(this,this.value),this},update(e){const t=this.evaluate(e);return this.value!==t&&(M(this,t),this.value=t),this},unmount(){return 1===this.type&&M(this,null),this}});function M(e,t){return k[e.type](e.node,e,t,e.value)}function C(e,t){return Object.assign({},S,t,{node:2===t.type?E(e,t.childNodeIndex):e})}const N=new Map,D=Symbol("riot-component"),L=new Set,O="is",I="mount",B="update",P="unmount",j="shouldUpdate",R="onBeforeMount",z="onMounted",F="onBeforeUpdate",q="onUpdated",U="onBeforeUnmount",H="onUnmounted",V="props",G="state",W="slots",Y="root",Z=Symbol.for("pure"),K=Symbol("parent"),X=Symbol("attributes"),Q=Symbol("template");var $=Object.freeze({__proto__:null,COMPONENTS_IMPLEMENTATION_MAP:N,DOM_COMPONENT_INSTANCE_PROPERTY:D,PLUGINS_SET:L,IS_DIRECTIVE:O,VALUE_ATTRIBUTE:"value",MOUNT_METHOD_KEY:I,UPDATE_METHOD_KEY:B,UNMOUNT_METHOD_KEY:P,SHOULD_UPDATE_KEY:j,ON_BEFORE_MOUNT_KEY:R,ON_MOUNTED_KEY:z,ON_BEFORE_UPDATE_KEY:F,ON_UPDATED_KEY:q,ON_BEFORE_UNMOUNT_KEY:U,ON_UNMOUNTED_KEY:H,PROPS_KEY:V,STATE_KEY:G,SLOTS_KEY:W,ROOT_KEY:Y,IS_PURE_SYMBOL:Z,PARENT_KEY_SYMBOL:K,ATTRIBUTES_KEY_SYMBOL:X,TEMPLATE_KEY_SYMBOL:Q});const J=(e,t)=>e[K]||t,ee=Object.seal({attributes:[],getTemplateScope(e,t){return function(e,t,n){if(!e||!e.length)return n;const r=e.map((e=>Object.assign({},e,{value:e.evaluate(t)})));return Object.assign(Object.create(n||null),v(r))}(this.attributes,e,t)},mount(e,t){const n=!!e.slots&&e.slots.find((e=>{let{id:t}=e;return t===this.name})),{parentNode:r}=this.node,o=J(e,t);return this.template=n&&ce(n.html,n.bindings).createDOM(r),this.template&&(this.template.mount(this.node,this.getTemplateScope(e,o),o),this.template.children=te(this.node)),i(this.node),this},update(e,t){if(this.template){const n=J(e,t);this.template.update(this.getTemplateScope(e,n),n)}return this},unmount(e,t,n){return this.template&&this.template.unmount(this.getTemplateScope(e,t),null,n),this}});function te(e,t){void 0===t&&(t=[]);const n=e.firstChild;return n?(o(n,e),[n,...te(e)]):t}function ne(e){return e.reduce(((e,t)=>{let{bindings:n}=t;return e.concat(n)}),[])}const re=Object.seal({mount(e){return this.update(e)},update(e,t){const n=this.evaluate(e);return n===this.name?this.tag.update(e):(this.unmount(e,t,!0),this.name=n,this.tag=function(e,t,n){return void 0===t&&(t=[]),void 0===n&&(n=[]),e?e({slots:t,attributes:n}):ce(function(e){return e.reduce(((e,t)=>e+t.html),"")}(t),[...ne(t),{expressions:n.map((e=>Object.assign({type:0},e)))}])}(this.getComponent(n),this.slots,this.attributes),this.tag.mount(this.node,e)),this},unmount(e,t,n){return this.tag&&this.tag.unmount(n),this}});var ie={1:function(e,t){let{evaluate:n,template:r}=t;const a=document.createTextNode("");return o(a,e),i(e),Object.assign({},g,{node:e,evaluate:n,placeholder:a,template:r.createDOM(e)})},2:function(e,t){let{expressions:n}=t;return Object.assign({},(r=n.map((t=>C(e,t))),["mount","update","unmount"].reduce(((e,t)=>Object.assign({},e,{[t]:e=>r.map((n=>n[t](e)))&&undefined})),{})));var r},0:function(e,t){let{evaluate:n,condition:r,itemName:a,indexName:s,getKey:l,template:c}=t;const f=document.createTextNode(""),d=e.cloneNode();return o(f,e),i(e),Object.assign({},m,{childrenMap:new Map,node:e,root:d,condition:r,evaluate:n,isTemplateTag:u(d),template:c.createDOM(e),getKey:l,indexName:s,itemName:a,placeholder:f})},3:function(e,t){let{evaluate:n,getComponent:r,slots:i,attributes:o}=t;return Object.assign({},re,{node:e,evaluate:n,slots:i,attributes:o,getComponent:r})},4:function(e,t){let{name:n,attributes:r}=t;return Object.assign({},ee,{attributes:r,node:e,name:n})}};function oe(e,t){return e.map((e=>2===e.type?Object.assign({},e,{childNodeIndex:e.childNodeIndex+t}):e))}function ae(e,t,n){const{selector:r,type:i,redundantAttribute:o,expressions:a}=t,s=r?e.querySelector(r):e;o&&s.removeAttribute(o);const l=a||[];return(ie[i]||ie[2])(s,Object.assign({},t,{expressions:n&&!r?oe(l,n):l}))}function se(e,t){switch(!0){case c(e):n(t,e);break;case u(e):e.parentNode.replaceChild(t,e);break;default:e.appendChild(t)}}const le=Object.freeze({createDOM(e){return this.dom=this.dom||function(e,t){return t&&("string"==typeof t?function(e,t){return c(e)?function(e,t){return t.ownerDocument.importNode((new window.DOMParser).parseFromString(`${e}`,"application/xml").documentElement,!0)}(t,e):function(e,t){const n=u(t)?t:document.createElement("template");return n.innerHTML=e,n.content}(t,e)}(e,t):t)}(e,this.html),this},mount(e,t,n,r){if(void 0===r&&(r={}),!e)throw new Error("Please provide DOM node to mount properly your template");this.el&&this.unmount(t);const{fragment:i,children:o,avoidDOMInjection:a}=r,{parentNode:s}=o?o[0]:e,l=u(e),c=l?Math.max(Array.from(s.childNodes).indexOf(e),0):null;return this.isTemplateTag=l,this.createDOM(e),this.dom&&(this.fragment=i||this.dom.cloneNode(!0)),this.el=this.isTemplateTag?s:e,this.children=this.isTemplateTag?o||Array.from(this.fragment.childNodes):null,!a&&this.fragment&&se(e,this.fragment),this.bindings=this.bindingsData.map((e=>ae(this.el,e,c))),this.bindings.forEach((e=>e.mount(t,n))),this},update(e,t){return this.bindings.forEach((n=>n.update(e,t))),this},unmount(e,t,n){if(this.el){switch(this.bindings.forEach((r=>r.unmount(e,t,n))),!0){case this.children&&null!==n:r(this.children);break;case!0===n:i(this.el);break;case null!==n:r(this.el.childNodes)}this.el=null}return this},clone(){return Object.assign({},this,{el:null})}});function ce(e,t){return void 0===t&&(t=[]),Object.assign({},le,{html:e,bindingsData:t})}var ue=Object.freeze({__proto__:null,template:ce,createBinding:ae,createExpression:C,bindingTypes:a,expressionTypes:s});function fe(){return this}function de(e){return f(e)?e.prototype&&e.prototype.constructor?new e:e():e}function he(e,t,n,r){return void 0===r&&(r={}),Object.defineProperty(e,t,Object.assign({value:n,enumerable:!1,writable:!1,configurable:!0},r)),e}function pe(e,t,n){return Object.entries(t).forEach((t=>{let[r,i]=t;he(e,r,i,n)})),e}function me(e,t){return Object.entries(t).forEach((t=>{let[n,r]=t;e[n]||(e[n]=r)})),e}function ge(e){return Array.isArray(e)?e:/^\[object (HTMLCollection|NodeList|Object)\]$/.test(Object.prototype.toString.call(e))&&"number"==typeof e.length?Array.from(e):[e]}function be(e,t){return ge("string"==typeof e?(t||document).querySelectorAll(e):e)}const ve=e=>1===e.length?e[0]:e;function ye(e,t,n){const r="object"==typeof t?t:{[t]:n},i=Object.keys(r);return ge(e).forEach((e=>{i.forEach((t=>e.setAttribute(t,r[t])))})),e}const _e=new Map;var we,xe={CSS_BY_NAME:_e,add(e,t){return _e.has(e)||(_e.set(e,t),this.inject()),this},inject(){return(we||(ye(we=be("style[riot]")[0]||document.createElement("style"),"type","text/css"),we.parentNode||document.head.appendChild(we),we)).innerHTML=[..._e.values()].join("\n"),this},remove(e){return _e.has(e)&&(_e.delete(e),this.inject()),this}};function Te(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;rve(r.map((t=>e.getAttribute(t)))))))}(e,t)}(e,O)||e.tagName.toLowerCase()}const Ee=Object.freeze({$(e){return be(e,this.root)[0]},$$(e){return be(e,this.root)}}),ke=Object.freeze({[I]:fe,[B]:fe,[P]:fe}),Se=Object.freeze({[j]:fe,[R]:fe,[z]:fe,[F]:fe,[q]:fe,[U]:fe,[H]:fe}),Me=Object.assign({},ke,{clone:fe,createDOM:fe});function Ce(e,n){return void 0===n&&(n={}),Object.assign({},function(e){return Array.from(e.attributes).reduce(((e,n)=>(e[t(n.name)]=n.value,e)),{})}(e),de(n))}const Ne=(e,t)=>e[D]=t;function De(e){return[I,B,P].reduce(((t,n)=>(t[n]=e(n),t)),{})}function Le(e){let{css:t,template:n,exports:r,name:i}=e;const o=n?function(e,t){return e(ce,s,a,(e=>t[e]||N.get(e)))}(n,r?(void 0===(l=r.components)&&(l={}),Object.entries(de(l)).reduce(((e,t)=>{let[n,r]=t;var i;return e[(i=n,i.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase())]=Le(r),e}),{})):{}):Me;var l;return e=>{let{slots:a,attributes:s,props:l}=e;if(r&&r[Z])return function(e,t){let{slots:n,attributes:r,props:i,css:o,template:a}=t;a&&b("Pure components can not have html"),o&&b("Pure components do not have css");const s=me(e({slots:n,attributes:r,props:i}),ke);return De((e=>function(){for(var t=arguments.length,n=new Array(t),r=0;ru.mount(e,n,t),update:(e,t)=>u.update(t,e),unmount:e=>u.unmount(e)}}}function Oe(e){let{css:t,template:n,componentAPI:r,name:i}=e;return t&&i&&xe.add(i,t),Te(Be)(pe(me(r,Object.assign({},Se,{[G]:{}})),Object.assign({[W]:null,[Y]:null},Ee,{name:i,css:t,template:n})))}function Ie(e,t){return Object.assign({},e,de(t))}function Be(e,t){let{slots:n,attributes:r,props:i}=t;return o=function(e){return[...L].reduce(((e,t)=>t(e)||e),e)}(pe(Object.create(e),{mount(t,o,a){return void 0===o&&(o={}),this[X]=function(e,t){void 0===t&&(t=[]);const n=t.map((t=>C(e,t))),r={};return Object.assign(r,Object.assign({expressions:n},De((e=>t=>(n.forEach((n=>n[e](t))),r)))))}(t,r).mount(a),he(this,V,Object.freeze(Object.assign({},Ce(t,i),v(this[X].expressions)))),this.state=Ie(this.state,o),this[Q]=this.template.createDOM(t).clone(),Ne(t,this),e.name&&function(e,t){Ae(e)!==t&&ye(e,O,t)}(t,e.name),he(this,Y,t),he(this,W,n),this.onBeforeMount(this.props,this.state),this[K]=a,this[Q].mount(t,this,a),this.onMounted(this.props,this.state),this},update(e,t){void 0===e&&(e={}),t&&(this[K]=t,this[X].update(t));const n=v(this[X].expressions);if(!1!==this.shouldUpdate(n,this.props))return he(this,V,Object.freeze(Object.assign({},this.props,n))),this.state=Ie(this.state,e),this.onBeforeUpdate(this.props,this.state),this[Q].update(this,this[K]),this.onUpdated(this.props,this.state),this},unmount(e){return this.onBeforeUnmount(this.props,this.state),this[X].unmount(),this[Q].unmount(this,this[K],null===e?null:!e),this.onUnmounted(this.props,this.state),this}})),Object.keys(e).filter((t=>f(e[t]))).forEach((e=>{o[e]=o[e].bind(o)})),o;var o}const{DOM_COMPONENT_INSTANCE_PROPERTY:Pe,COMPONENTS_IMPLEMENTATION_MAP:je,PLUGINS_SET:Re}=$,ze={cssManager:xe,DOMBindings:ue,createComponent:Le,defineComponent:Oe,globals:$};e.__=ze,e.component=function(e){return function(t,n,r){let{slots:i,attributes:o,parentScope:a}=void 0===r?{}:r;return function(){for(var e=arguments.length,t=new Array(e),n=0;nfunction(){return e(t(...arguments))}))}((e=>e.mount(t,a)),(e=>e({props:n,slots:i,attributes:o})),Le)(e)}},e.install=function(e){return f(e)||b("Plugins must be of type function"),Re.has(e)&&b("This plugin was already installed"),Re.add(e),Re},e.mount=function(e,t,n){return be(e).map((e=>function(e,t,n){const r=n||Ae(e);return N.has(r)||b(`The component named "${r}" was never registered`),N.get(r)({props:t}).mount(e)}(e,t,n)))},e.pure=function(e){return f(e)||b('riot.pure accepts only arguments of type "function"'),e[Z]=!0,e},e.register=function(e,t){let{css:n,template:r,exports:i}=t;return je.has(e)&&b(`The component "${e}" was already registered`),je.set(e,Le({name:e,css:n,template:r,exports:i})),je},e.uninstall=function(e){return Re.has(e)||b("This plugin was never installed"),Re.delete(e),Re},e.unmount=function(e,t){return be(e).map((e=>(e[Pe]&&e[Pe].unmount(t),e)))},e.unregister=function(e){return je.has(e)||b(`The component "${e}" was never registered`),je.delete(e),xe.remove(e),je},e.version="v5.0.0",Object.defineProperty(e,"__esModule",{value:!0})},"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).riot={}),function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("./components/route-hoc.riot"),require("./components/router-hoc.riot")):"function"==typeof define&&define.amd?define(["exports","./components/route-hoc.riot","./components/router-hoc.riot"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).route={},e.routeHoc_riot,e.routerHoc_riot)}(this,(function(e,t,n){"use strict";function r(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var i=r(t),o=r(n);function a(e,t){void 0===t&&(t={});for(var n=function(e){for(var t=[],n=0;n=48&&l<=57||l>=65&&l<=90||l>=97&&l<=122||95===l))break;a+=e[s++]}if(!a)throw new TypeError("Missing parameter name at "+n);t.push({type:"NAME",index:n,value:a}),n=s}else t.push({type:"CLOSE",index:n,value:e[n++]});else t.push({type:"OPEN",index:n,value:e[n++]});else t.push({type:"ESCAPED_CHAR",index:n++,value:e[n++]});else t.push({type:"MODIFIER",index:n,value:e[n++]})}return t.push({type:"END",index:n,value:""}),t}(e),r=t.prefixes,i=void 0===r?"./":r,o="[^"+l(t.delimiter||"/#?")+"]+?",a=[],s=0,c=0,u="",f=function(e){if(c-1:void 0===x;i||(m+="(?:"+p+"(?="+h+"))?"),T||(m+="(?="+p+"|"+h+")")}return new RegExp(m,c(n))}(a(e,n),t,n)}function f(e,t,n){return e instanceof RegExp?function(e,t){if(!t)return e;var n=e.source.match(/\((?!\?)/g);if(n)for(var r=0;rfunction t(r,i){if(!r.length)return e(i);const[o,...a]=r,s="function"==typeof o?o(i):o,l=e=>t(a,e);if(null!=s){if(s===d)return;if(s.then)return s.then(l,n)}return Promise.resolve(l(s))}(t)))}h.cancel=()=>d,h.compose=function(){for(var e=arguments.length,t=new Array(e),n=0;n{n(t)===m&&e.delete(n)})),e}function v(e){throw new Error(e)}function y(){for(var e=arguments.length,t=new Array(e),n=0;nt=>e.add(t)&&l,u=e=>t=>e.delete(t)?l:v("Couldn't remove handler passed by reference");return Object.assign(l,{on:Object.freeze({value:c(r),error:c(i),end:c(o)}),off:Object.freeze({value:u(r),error:u(i),end:u(o)}),connect:c(a),push(e){const{value:t,done:n}=l.next(e);return n||t.then((e=>b(r,e)),(e=>b(i,e))),l},end:()=>(s.return(),b(o),[r,i,o,a].forEach((e=>e.clear())),l),fork:()=>y(...a),next(e){const t=s.next(e);return s.next(),t}})}y.install=function(e,t){return e&&"string"==typeof e||v("Please provide a name (as string) for your erre plugin"),t&&"function"==typeof t||v("Please provide a function for your erre plugin"),p.has(e)?v(`The ${e} is already part of the erre API, please provide a different name`):(y[e]=t,p.add(e)),y},y.install("cancel",h.cancel),y.install("off",(()=>m));const _="undefined"!=typeof process,w=e=>e.replace(k.base,""),x=e=>t=>C(t,e)?t:y.cancel(),T=e=>{if(!k.silentErrors)throw new Error(e)},A=e=>(e=>"string"==typeof e)(e)?e:y.cancel(),E=y(A).on.error(T),k={base:"",silentErrors:!1,sensitive:!1,strict:!1,end:!0,start:!0,delimiter:"/#?",encode:void 0,endsWith:void 0,prefixes:"./"},S=e=>Object.assign({},k,e),M=function(e,t,n){void 0===n&&(n={});const{base:r}=S(n),[,...i]=t.exec(e),o=function(){for(var e=arguments.length,t=new Array(e),n=0;n{const i=n.keys&&n.keys[r];return i&&(e[i.name]=t),e}),{}),o},C=(e,t)=>t.test(e),N=(e,t)=>[w,x(e),n=>M(n,e,t)];const D=(L=null,E.on.value((e=>L=e)),()=>L);var L;const O="popstate",I="click",B="/",P=/^.+?\/\/+[^/]+/;function j(e){return Array.isArray(e)?e:/^\[object (HTMLCollection|NodeList|Object)\]$/.test(Object.prototype.toString.call(e))&&"number"==typeof e.length?Array.from(e):[e]}function R(e,t,n,r,i){var o;e=j(e),(o=t,o.split(/\s/)).forEach((t=>{e.forEach((e=>e[r](t,n,i||!1)))}))}function z(e,t,n,r){return R(e,t,n,"addEventListener",r),e}function F(e,t,n,r){return R(e,t,n,"removeEventListener",r),e}const q=()=>"undefined"==typeof window?null:window,U=()=>"undefined"==typeof document?null:document,H=()=>{const e=q();return e?e.location:{}},V=e=>1===e.length?e[0]:e;function G(e,t){return function(e,t,n){const r="string"==typeof t?[t]:t;return V(j(e).map((e=>V(r.map((t=>e[n](t)))))))}(e,t,"hasAttribute")}const W=()=>E.push(Q(String(H().href))),Y=e=>{const t=e.includes(k.base)?e:k.base+e,n=H(),r="undefined"==typeof history?null:history,i=U();r&&t!==n.href&&r.pushState(null,i.title,t)},Z=e=>e&&!K(e)?Z(e.parentNode):e,K=e=>"A"===e.nodeName,X=e=>!e||!K(e)||G(e,"download")||!G(e,"href")||(e=>e.target&&"_self"!==e.target)(e)||-1===e.href.indexOf(H().href.match(P)[0]),Q=e=>e.replace(k.base,""),$=e=>{if((e=>e.which&&1!==e.which||e.metaKey||e.ctrlKey||e.shiftKey||e.defaultPrevented)(e))return;const t=Z(e.target);if(X(t)||(e=>e.split("#").length>1)(t.href)||!(e=>!k.base||e.includes(k.base))(t.href))return;const n=Q(t.href);E.push(n),e.preventDefault()};const J=e=>e[e.length-1]===B?e.substr(0,e.length-1):e,ee=e=>{const t=q().location,n=t?`${t.protocol}//${t.host}`:"",{pathname:r}=t||{};switch(!0){case!1===Boolean(e):return J(`${n}${r||""}`);case/(www|http(s)?:)/.test(e):return e;case"#"===e[0]:return`${n}${r&&r!==B?r:""}${e}`;case e===B:return J(n);default:return J(`${n}${i=e,i[0]===B?i:"/"+i}`)}var i};Object.defineProperty(e,"Route",{enumerable:!0,get:function(){return i.default}}),Object.defineProperty(e,"Router",{enumerable:!0,get:function(){return o.default}}),e.createURLStreamPipe=N,e.filterStrings=A,e.getCurrentRoute=D,e.initDomListeners=function(e){const t=q(),n=e||U();return t&&(z(t,O,W),z(n,I,$)),E.on.value(Y),()=>{t&&(F(t,O,W),F(n,I,$)),E.off.value(Y)}},e.match=C,e.route=function(e,t){const n=[],r=f(e,n,t),i=y(...N(r,Object.assign({},t,{keys:n})));return(o=E,a=i,o.on.value(a.push),a.on.end((()=>{o.off.value(a.push)})),a).on.error(T);var o,a},e.router=E,e.setBase=function(e){k.base=ee(e)},e.toPath=(e,t,n)=>s(e,S(n))(t),e.toRegexp=(e,t,n)=>f(e,t,S(n)),e.toURL=M,Object.defineProperty(e,"__esModule",{value:!0})})),function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e=e||self).cimDiagram=t()}(this,(function(){"use strict";const e=14,t=d3.scaleSequential([0,500],d3.interpolateTurbo);let n=null,r="ConnectivityNode",i="ConnectivityNode.Terminals",o="Terminal.ConnectivityNode";return{css:'cimdiagram .app-diagram,[is="cimdiagram"] .app-diagram{ max-height: 800px; } cimdiagram path.domain,[is="cimdiagram"] path.domain{ fill: none; stroke: black; } cimdiagram g.tick > line,[is="cimdiagram"] g.tick > line{ stroke: black; stroke-dasharray: 1 5; } cimdiagram svg,[is="cimdiagram"] svg{ width: 1200px; height: 800px; } cimdiagram line.highlight-x,[is="cimdiagram"] line.highlight-x,cimdiagram line.highlight-y,[is="cimdiagram"] line.highlight-y{ stroke: red; stroke-width: 1; } cimdiagram g.resize > rect,[is="cimdiagram"] g.resize > rect{ stroke: black; stroke-width: 2; }',exports:{onBeforeMount(e,t){n=this,n.props.dispatcher.on("showDiagram",(function(e,t,a){if(decodeURI(t)!==n.diagramName){"BUS_BRANCH"===n.props.model.getMode()&&(r="TopologicalNode",i="TopologicalNode.Terminal",o="Terminal.TopologicalNode"),n.render(t)}void 0!==a?(n.moveTo(a),n.props.dispatcher.trigger("moveTo",a)):n.props.dispatcher.trigger("deselect")})),n.props.dispatcher.on("transform",(function(){let e=d3.zoomTransform(d3.select("svg").node()),t=e.x,n=e.y,r=e.k,i=parseInt(d3.select("svg").style("width")),o=parseInt(d3.select("svg").style("height")),a=d3.scaleLinear().domain([-t/r,(i-t)/r]).range([0,i]),s=d3.scaleLinear().domain([-n/r,(o-n)/r]).range([0,o]),l=d3.axisRight(s),c=d3.axisBottom(a);d3.select("svg").select("#diagram-yAxis").call(l),d3.select("svg").select("#diagram-xAxis").call(c)})),n.props.model.on("setAttribute",(function(e,t,r){switch(t){case"cim:IdentifiedObject.name":{let t=e.localName,i=n.props.model.ID(e);if("cim:BusbarSection"===e.nodeName){let r=n.props.model.getNode(e);if(null===r)return;t=r.localName,i=n.props.model.ID(r)}d3.select("svg").selectAll("svg > g#diagram-main > g."+t+"s").select("#cimdiagram-"+i).select("text").html(r);break}case"cim:AnalogValue.value":{let t=n.props.model.getTargets([e],"AnalogValue.Analog"),r=n.props.model.getTargets(t,"Measurement.PowerSystemResource")[0];"cim:BusbarSection"===r.nodeName&&(r=n.props.model.getNode(r));let i=n.props.model.ID(r),o=d3.select("g#cimdiagram-"+i);n.createStatusInfo(o);break}case"cim:SvPowerFlow.p":case"cim:SvPowerFlow.q":{let t=n.props.model.getTargets([e],"SvPowerFlow.Terminal")[0];if(void 0!==t){let e=n.props.model.getTargets([t],"Terminal.ConductingEquipment")[0],r=n.props.model.ID(e),i=d3.select("g#cimdiagram-"+r);n.createStatusInfo(i)}break}case"cim:BaseVoltage.nominalVoltage":{n.drawLegend();const t=n.props.model.getTargets([e],"BaseVoltage.ConductingEquipment"),r=t.filter((function(e){return!0===n.props.model.schema.isA("ACLineSegment",e)}));n.drawACLines(r);let i=t.filter((function(e){return!0===n.props.model.schema.isA("BusbarSection",e)})).map((e=>n.props.model.getNode(e)));n.drawNodes(i);const o=n.props.model.getTargets([e],"BaseVoltage.TransformerEnds");for(const e of o){const t=n.getTermNode(e);null!==t&&n.handlePowerTransformerEnds(t)}break}}if("cim:Analog"===e.nodeName||"cim:Discrete"===e.nodeName){let t=n.props.model.getTargets([e],"Measurement.PowerSystemResource")[0];if(void 0!==t){"cim:BusbarSection"===t.nodeName&&(t=n.props.model.getNode(t));let e=n.props.model.ID(t),r=d3.select("g#cimdiagram-"+e);n.createStatusInfo(r)}}if("cim:OperationalLimitSet"===e.nodeName){let t=n.props.model.getTargets([e],"OperationalLimitSet.Equipment"),r=n.props.model.getTargets([e],"OperationalLimitSet.Terminal");if(t=t.concat(n.props.model.getTargets(r,"Terminal.ConductingEquipment"))[0],void 0!==t){"cim:BusbarSection"===t.nodeName&&(t=n.props.model.getNode(t));let e=n.props.model.ID(t),r=d3.select("g#cimdiagram-"+e);n.createStatusInfo(r)}}})),n.props.model.on("setEnum",(function(e,t,r){if("cim:Analog"===e.nodeName||"cim:Discrete"===e.nodeName){let t=n.props.model.getTargets([e],"Measurement.PowerSystemResource")[0];if(void 0!==t){"cim:BusbarSection"===t.nodeName&&(t=n.props.model.getNode(t));let e=n.props.model.ID(t),r=d3.select("g#cimdiagram-"+e);n.createStatusInfo(r)}}switch(t){case"cim:PowerTransformerEnd.connectionKind":{const t=n.getTermNode(e);null!==t&&n.handlePowerTransformerEnds(t);break}}})),n.props.model.on("updateActiveDiagram",(function(e){let t=null;switch(e.nodeName){case"cim:ACLineSegment":t=n.drawACLines([e])[0],n.createTerminals(t);break;case"cim:"+r:n.drawNodes([e])}let i=e.localName,o=n.props.model.ID(e),a=d3.select("svg").selectAll("svg > g#diagram-main > g."+i+"s").select("#cimdiagram-"+o);n.forceTick(a)})),n.props.model.on("addToActiveDiagram",(function(e){let t=null;switch(e.nodeName){case"cim:ACLineSegment":t=n.drawACLines([e])[1];break;case"cim:Breaker":t=n.drawBreakers([e]);break;case"cim:Disconnector":t=n.drawDisconnectors([e]);break;case"cim:LoadBreakSwitch":t=n.drawLoadBreakSwitches([e]);break;case"cim:Junction":t=n.drawJunctions([e]);break;case"cim:EnergySource":t=n.drawEnergySources([e]);break;case"cim:SynchronousMachine":t=n.drawSynchronousMachines([e]);break;case"cim:AsynchronousMachine":t=n.drawAsynchronousMachines([e]);break;case"cim:EnergyConsumer":t=n.drawEnergyConsumers([e]);break;case"cim:ConformLoad":t=n.drawConformLoads([e]);break;case"cim:NonConformLoad":t=n.drawNonConformLoads([e]);break;case"cim:EquivalentInjection":t=n.drawEquivalentInjections([e]);break;case"cim:LinearShuntCompensator":t=n.drawLinearCompensators([e]);break;case"cim:NonlinearShuntCompensator":t=n.drawNonlinearCompensators([e]);break;case"cim:PowerTransformer":t=n.drawPowerTransformers([e]);break;case"cim:"+r:t=n.drawNodes([e]),i(e,null)}if(null!==t&&function(t){let r=n.props.model.getTerminals([e]);for(let e of r){let t=n.props.model.getTargets([e],o)[0];if(void 0!==t){let e=n.props.model.getEquipments(t),r=e.filter((e=>"BusbarSection"===e.localName))[0];if(e=e.filter((e=>e!==r)),e.length>1){n.drawNodes([t]);let r=n.props.model.getTerminals(e);for(let e of r){if(n.props.model.getTargets([e],o)[0]===t){let r={source:t,target:e};n.createEdges([r])}}}}}n.createTerminals(t)}(t),"cim:BusbarSection"===e.nodeName){let r=n.props.model.getTargets([e],"ConductingEquipment.Terminals"),a=n.props.model.getTargets(r,o)[0];t=n.drawNodes([a]),i(a,e)}function i(e,t){let r=n.props.model.getEquipments(e).filter((e=>e!==t)),i=n.props.model.getTerminals(r);for(let t of i){if(void 0===t.x)continue;if(n.props.model.getTargets([t],o)[0]===e){let r={source:e,target:t};n.createEdges([r])}}}null!==t&&(n.forceTick(t),n.props.dispatcher.trigger("addToDiagram",t))})),n.props.model.on("addLink",(function(e,t,a){switch(t){case"cim:"+o:case"cim:"+i:{let t=void 0,i=void 0;if("cim:Terminal"===a.nodeName&&e.nodeName==="cim:"+r)t=e,i=a;else{if("cim:Terminal"!==e.nodeName||a.nodeName!=="cim:"+r)return;i=e,t=a}let o=d3.select("svg").selectAll("svg > g#diagram-main > g.edges > g").data().filter((e=>e.target===i))[0];if(void 0===o){let e=n.props.model.getTargets([i],"Terminal.ConductingEquipment");n.props.model.getDiagramObjects(e).length>0&&(o={source:t,target:i},n.createEdges([o]))}else o.source=t;let s=n.props.model.ID(t),l=d3.select("svg > g#diagram-main > g."+r+"s > g#cimdiagram-"+s);n.forceTick(l);break}case"cim:Terminal.SvPowerFlow":case"cim:SvPowerFlow.Terminal":{let t=a;if("cim:Terminal"===e.nodeName&&(t=e),void 0!==t){let e=n.props.model.getTargets([t],"Terminal.ConductingEquipment")[0],r=n.props.model.ID(e),i=d3.select("g#cimdiagram-"+r);n.createStatusInfo(i)}break}case"cim:Measurement.Terminal":case"cim:ACDCTerminal.Measurements":{let t=a;"cim:Terminal"===e.nodeName&&(t=e);let r=n.props.model.getTargets([t],"Terminal.ConductingEquipment")[0],i=n.props.model.ID(r),o=d3.select("g#cimdiagram-"+i);n.createStatusInfo(o);break}case"cim:Measurement.PowerSystemResource":case"cim:PowerSystemResource.Measurements":{let r=a;if("cim:PowerSystemResource.Measurements"===t&&(r=e),void 0!==r){"cim:BusbarSection"===r.nodeName&&(r=n.props.model.getNode(r));let e=n.props.model.ID(r),t=d3.select("g#cimdiagram-"+e);n.createStatusInfo(t)}break}case"cim:OperationalLimitSet.Terminal":case"cim:ACDCTerminal.OperationalLimitSet":{let t=a;"cim:Terminal"===e.nodeName&&(t=e);let r=n.props.model.getTargets([t],"Terminal.ConductingEquipment")[0],i=n.props.model.ID(r),o=d3.select("g#cimdiagram-"+i);n.createStatusInfo(o);break}case"cim:OperationalLimitSet.Equipment":case"cim:Equipment.OperationalLimitSet":{let r=a;if("cim:Equipment.OperationalLimitSet"===t&&(r=e),void 0!==r){"cim:BusbarSection"===r.nodeName&&(r=n.props.model.getNode(r));let e=n.props.model.ID(r),t=d3.select("g#cimdiagram-"+e);n.createStatusInfo(t)}break}case"cim:ConductingEquipment.BaseVoltage":case"cim:BaseVoltage.ConductingEquipment":case"cim:BaseVoltage.TransformerEnds":case"cim:TransformerEnd.BaseVoltage":n.updateColoring(e,t,a)}})),n.props.model.on("removeLink",(function(e,t,a){switch(t){case"cim:Measurement.PowerSystemResource":case"cim:PowerSystemResource.Measurements":{let r=a;if("cim:PowerSystemResource.Measurements"===t&&(r=e),void 0!==r){"cim:BusbarSection"===r.nodeName&&(r=n.props.model.getNode(r));let e=n.props.model.ID(r),t=d3.select("g#"+e);n.createStatusInfo(t)}break}case"cim:"+o:case"cim:"+i:{let t=void 0;if("cim:Terminal"===a.nodeName&&e.nodeName==="cim:"+r)t=a;else{if("cim:Terminal"!==e.nodeName||a.nodeName!=="cim:"+r)return;t=e}d3.select("svg").selectAll("svg > g#diagram-main > g.edges > g").filter((function(e){return e.target===t})).remove();break}case"cim:OperationalLimitSet.Terminal":case"cim:ACDCTerminal.OperationalLimitSet":{let t=a;"cim:Terminal"===e.nodeName&&(t=e);let r=n.props.model.getTargets([t],"Terminal.ConductingEquipment")[0];if(void 0!==r){let e=n.props.model.ID(r),t=d3.select("g#"+e);n.createStatusInfo(t)}break}case"cim:OperationalLimitSet.Equipment":case"cim:Equipment.OperationalLimitSet":{let r=a;if("cim:Equipment.OperationalLimitSet"===t&&(r=e),void 0!==r&&("cim:BusbarSection"===r.nodeName&&(r=n.props.model.getNode(r)),null!==r)){let e=n.props.model.ID(r),t=d3.select("g#"+e);n.createStatusInfo(t)}break}case"cim:ConductingEquipment.BaseVoltage":case"cim:BaseVoltage.ConductingEquipment":case"cim:BaseVoltage.TransformerEnds":case"cim:TransformerEnd.BaseVoltage":n.updateColoring(e,t,a)}})),n.props.model.on("deleteObject",(function(e,t){"BaseVoltage"===t&&n.drawLegend()}))},onMounted(){let e=d3.scaleLinear().domain([0,1200]).range([0,1200]),t=d3.scaleLinear().domain([0,800]).range([0,800]),r=d3.axisRight(t),i=d3.axisBottom(e);d3.select("svg").append("g").attr("id","diagram-yAxis").call(r),d3.select("svg").append("g").attr("id","diagram-xAxis").call(i),n.drawGrid(1)},render(e){let t=function*(e){d3.select("svg").select("g#diagram-main").selectAll("g:not(.edges)").remove(),n.props.model.selectDiagram(decodeURI(e)),n.diagramName=decodeURI(e);const t=n.props.model.getNodes();yield"DIAGRAM: extracted nodes";const r=n.props.model.getGraphicObjects(["cim:ACLineSegment","cim:Breaker","cim:Disconnector","cim:LoadBreakSwitch","cim:Junction","cim:EnergySource","cim:SynchronousMachine","cim:AsynchronousMachine","cim:EnergyConsumer","cim:ConformLoad","cim:NonConformLoad","cim:EquivalentInjection","cim:PowerTransformer","cim:BusbarSection","cim:LinearShuntCompensator","cim:NonlinearShuntCompensator"]),i=r["cim:ACLineSegment"],o=r["cim:Breaker"],a=r["cim:Disconnector"],s=r["cim:LoadBreakSwitch"],l=r["cim:Junction"],c=r["cim:EnergySource"],u=r["cim:SynchronousMachine"],f=r["cim:AsynchronousMachine"],d=r["cim:EnergyConsumer"],h=r["cim:ConformLoad"],p=r["cim:NonConformLoad"],m=r["cim:EquivalentInjection"],g=r["cim:PowerTransformer"],b=(r["cim:BusbarSection"],r["cim:LinearShuntCompensator"]),v=r["cim:NonlinearShuntCompensator"];yield"DIAGRAM: extracted equipments";const y=n.drawACLines(i)[1];yield"DIAGRAM: drawn acLines";const _=n.drawBreakers(o);yield"DIAGRAM: drawn breakers";const w=n.drawDisconnectors(a);yield"DIAGRAM: drawn disconnectors";const x=n.drawLoadBreakSwitches(s);yield"DIAGRAM: drawn load break switches";const T=n.drawJunctions(l);yield"DIAGRAM: drawn junctions";const A=n.drawEnergySources(c);yield"DIAGRAM: drawn energy sources";const E=n.drawSynchronousMachines(u);yield"DIAGRAM: drawn synchronous machines";const k=n.drawAsynchronousMachines(f);yield"DIAGRAM: drawn asynchronous machines";const S=n.drawEnergyConsumers(d);yield"DIAGRAM: drawn energy consumers";const M=n.drawConformLoads(h);yield"DIAGRAM: drawn conform loads";const C=n.drawNonConformLoads(p);yield"DIAGRAM: drawn non conform loads";const N=n.drawEquivalentInjections(m);yield"DIAGRAM: drawn equivalent injections";const D=n.drawPowerTransformers(g);yield"DIAGRAM: drawn power transformers";const L=n.drawLinearCompensators(b);yield"DIAGRAM: drawn linear shunt compensators";const O=n.drawNonlinearCompensators(v);yield"DIAGRAM: drawn nonlinear shunt compensators";const I=n.drawNodes(t);n.createStatusInfo(I),yield"DIAGRAM: drawn connectivity nodes",n.createTerminals(y),n.createStatusInfo(y),yield"DIAGRAM: drawn acline terminals",n.createTerminals(_),n.createStatusInfo(_),yield"DIAGRAM: drawn breaker terminals",n.createTerminals(w),n.createStatusInfo(w),yield"DIAGRAM: drawn disconnector terminals",n.createTerminals(x),n.createStatusInfo(x),yield"DIAGRAM: drawn load break switch terminals",n.createTerminals(T),n.createStatusInfo(T),yield"DIAGRAM: drawn junction terminals",n.createTerminals(A),n.createStatusInfo(A),yield"DIAGRAM: drawn energy source terminals",n.createTerminals(E),n.createStatusInfo(E),yield"DIAGRAM: drawn synchronous machine terminals",n.createTerminals(k),n.createStatusInfo(k),yield"DIAGRAM: drawn asynchronous machine terminals",n.createTerminals(S),n.createStatusInfo(S),yield"DIAGRAM: drawn energy consumer terminals",n.createTerminals(M),n.createStatusInfo(M),yield"DIAGRAM: drawn conform load terminals",n.createTerminals(C),n.createStatusInfo(C),yield"DIAGRAM: drawn non conform load terminals",n.createTerminals(N),n.createStatusInfo(N),yield"DIAGRAM: drawn equivalent injection terminals",n.createTerminals(D),n.createStatusInfo(D),yield"DIAGRAM: drawn power transformer terminals",n.createTerminals(L),n.createStatusInfo(L),yield"DIAGRAM: drawn linear shunt compensator terminals",n.createTerminals(O),n.createStatusInfo(O),yield"DIAGRAM: drawn nonlinear shunt compensator terminals",n.drawLegend(),d3.select("svg").on("dragover",(function(e){e.preventDefault()})).on("drop",(function(e){e.preventDefault();const t=e.dataTransfer.getData("text/plain");if(void 0===t)return;const r=n.props.model.getObject(t);if(void 0===r)return;n.props.model.getDiagramObjects([r]).length>0?n.moveTo(t):addToDiagram(n.props.model,e,r)})),n.forceTick(),n.props.dispatcher.trigger("render")}(e);!function e(){let r=t.next().value;void 0!==r?(document.getElementById("loadingDiagramMsg").innerHTML="
              "+r,setTimeout(e,1)):n.props.dispatcher.trigger("loaded")}()},createEdges(e){let t=d3.select("svg").select("g > g.edges").selectAll("g.edge").data(e,(function(e){return e.source.attributes[0].value+e.target.attributes[0].value})).enter().append("g").attr("class","edge").attr("id",(function(e){return e.source.attributes[0].value+e.target.attributes[0].value})).append("path").attr("fill","none").attr("stroke","black").attr("stroke-width",1);n.props.dispatcher.trigger("createEdges",t)},createStatusInfo(e){e.attr("data-bs-toggle","popover"),e.filter((function(e){return n.props.model.schema.isA("Switch",e)})).selectAll("path").attr("fill",(function(e){let t=n.props.model.getTargets([e],"PowerSystemResource.Measurements")[0];return"0"===n.getDiscreteValue(t)?"white":"black"})),e.each((function(e){let t=[],i=[],o=[],a=n.props.model.getTargets([e],"TopologicalNode.SvVoltage"),s=n.props.model.getTerminals([e]);if(e.nodeName==="cim:"+r){let r=n.props.model.getBusbar(e);if(null===r)return;s=n.props.model.getTerminals([r]),t=n.props.model.getTargets([r],"PowerSystemResource.Measurements"),o=n.props.model.getTargets([r],"Equipment.OperationalLimitSet")}else t=n.props.model.getTargets([e],"PowerSystemResource.Measurements"),o=n.props.model.getTargets([e],"Equipment.OperationalLimitSet");o=o.concat(n.props.model.getTargets(s,"ACDCTerminal.OperationalLimitSet"));for(let e of s){let t=n.props.model.getTargets([e],"Terminal.SvPowerFlow");i=i.concat(t)}if(t.length>0||i.length>0||a.length>0||o.length>0){let e=n.createTooltip(t,i,a,o);disposePopovers([this]),new bootstrap.Popover(this,{title:"Element Status Info",content:e,container:"body",html:!0,trigger:"manual",delay:{show:200,hide:0},placement:"auto"})}else disposePopovers([this])}))},getDiscreteValue(e){let t="0";if(void 0!==e){let r=n.props.model.getTargets([e],"Discrete.DiscreteValues")[0];if(void 0!==r){let e=n.props.model.getAttribute(r,"cim:DiscreteValue.value");void 0!==e&&(t=e.textContent)}}return t},createTooltip(e,t,r,i){let o="";if(e.length>0){o+="Measurements

              ";let t=[];for(let r of e){let e="unnamed",i="ABC",o="",a="no unit",s=n.props.model.getAttribute(r,"cim:IdentifiedObject.name"),l=n.props.model.getEnum(r,"cim:Measurement.phases"),c=n.props.model.getEnum(r,"cim:Measurement.unitMultiplier"),u=n.props.model.getEnum(r,"cim:Measurement.unitSymbol");void 0!==s&&(e=s.textContent),void 0!==l&&(i=l),void 0!==c&&(o=c,"none"===o&&(o="")),void 0!==u&&(a=u);let f=n.props.model.getTargets([r],"Analog.AnalogValues")[0],d="",h="n.a.";void 0!==f?void 0!==n.props.model.getAttribute(f,"cim:AnalogValue.value")&&(h=n.props.model.getAttribute(f,"cim:AnalogValue.value").textContent,h=parseFloat(h).toFixed(2)):(h=n.getDiscreteValue(r),h=parseInt(h));let p=n.props.model.ID(r),m=window.location.hash.split("/");d=d+""+e+"",d=d+" (phase: "+i+")",d+=": ",d+=h,d=d+" ["+o+a+"]",d+="
              ",t.push(d)}t.sort();for(let e in t)o+=t[e]}if(t.length>0){""!==o&&(o+="
              "),o+="Power flow results (Power)

              ";for(let e of t){let t=0,r=0;void 0!==n.props.model.getAttribute(e,"cim:SvPowerFlow.p")&&(t=n.props.model.getAttribute(e,"cim:SvPowerFlow.p").textContent),void 0!==n.props.model.getAttribute(e,"cim:SvPowerFlow.q")&&(r=n.props.model.getAttribute(e,"cim:SvPowerFlow.q").textContent);let i="Active Power: "+parseFloat(t).toFixed(2)+" [MW]";i+="
              ",i=i+"Reactive power: "+parseFloat(r).toFixed(2)+" [MVAr]",i+="
              ",o+=i}}if(r.length>0){""!==o&&(o+="
              "),o+="Power flow results (Voltage)

              ";for(let e of r){let t=0,r=0;void 0!==n.props.model.getAttribute(e,"cim:SvVoltage.v")&&(t=n.props.model.getAttribute(e,"cim:SvVoltage.v").textContent),void 0!==n.props.model.getAttribute(e,"cim:SvVoltage.angle")&&(r=n.props.model.getAttribute(e,"cim:SvVoltage.angle").textContent);let i="Voltage magnitude: "+parseFloat(t).toFixed(2)+" [kV]";i+="
              ",i=i+"Voltage angle: "+parseFloat(r).toFixed(2)+" [deg]",i+="
              ",o+=i}}if(i.length>0){""!==o&&(o+="
              "),o+="Operational limit sets

              ";for(let e of i){let t="unnamed",r=n.props.model.getAttribute(e,"cim:IdentifiedObject.name");void 0!==r&&(t=r.textContent);let i=n.props.model.ID(e),a=window.location.hash.split("/");o+=""+t+"
              "}}return o},createSelection(e,t){let r=e+"s";d3.select("svg").select("g."+r).empty()&&d3.select("svg").select("g#diagram-main").append("g").attr("class",r);for(let e of t)calcLineData(n.props.model,e);let i=d3.select("svg").select("g."+r).selectAll("g."+e).data(t,(function(e){return n.props.model.ID(e)})),o=i.enter().append("g").attr("class",e).attr("id",(function(e){return"cimdiagram-"+n.props.model.ID(e)}));return[i,o]},drawACLines(e){const t=d3.line().x((function(e){return e.x})).y((function(e){return e.y})),r=n.createSelection("ACLineSegment",e),i=r[0],o=r[1];function a(e){e.attr("x",(function(e){let t=d3.select(this.parentNode).select("path").node();return t.getPointAtLength(t.getTotalLength()/2).x+2})).attr("y",(function(e){let t=d3.select(this.parentNode).select("path").node();return t.getPointAtLength(t.getTotalLength()/2).y-2})).text((function(e){let t=n.props.model.getAttribute(e,"cim:IdentifiedObject.name");return void 0!==t?t.innerHTML:""}))}return o.append("path").attr("d",(function(e){return 1===e.lineData.length&&e.lineData.push({x:150,y:0,seq:2}),t(e.lineData)})).attr("fill","none").attr("stroke",(function(e){return n.voltageColor(e,"darkred")})).attr("stroke-width",2),o.append("text").attr("class","cim-object-text").attr("font-size",3),a(i.select("text")),a(o.select("text")),i.select("path").attr("d",(function(e){return 1===e.lineData.length&&e.lineData.push({x:150,y:0,seq:2}),t(e.lineData)})).attr("fill","none").attr("stroke",(function(e){return n.voltageColor(e,"darkred")})).attr("stroke-width",2),[i,o]},drawBreakers:e=>n.drawSwitches(e,"Breaker","green"),drawDisconnectors:e=>n.drawSwitches(e,"Disconnector","blue"),drawLoadBreakSwitches:e=>n.drawSwitches(e,"LoadBreakSwitch","black"),drawJunctions:e=>n.drawSwitches(e,"Junction","red"),drawSwitches(e,t,r){let i=d3.line().x((function(e){return e.x})).y((function(e){return e.y})).curve(d3.curveLinearClosed),o=n.createSelection(t,e)[1];return o.append("path").attr("d",(function(e){return i([{x:-5,y:-5,seq:1},{x:5,y:-5,seq:2},{x:5,y:5,seq:3},{x:-5,y:5,seq:4}])})).attr("fill",(function(e){let t=n.props.model.getTargets([e],"PowerSystemResource.Measurements")[0];return"0"===n.getDiscreteValue(t)?"white":"black"})).attr("stroke",r).attr("stroke-width",1),o.append("text").attr("class","cim-object-text").style("text-anchor","end").attr("font-size",3).attr("x",-10).attr("y",0).text((function(e){let t=n.props.model.getAttribute(e,"cim:IdentifiedObject.name");return void 0!==t?t.innerHTML:""})),o},drawEnergySources:e=>n.drawGenerators(e,"EnergySource"),drawSynchronousMachines:e=>n.drawGenerators(e,"SynchronousMachine"),drawAsynchronousMachines:e=>n.drawGenerators(e,"AsynchronousMachine"),drawEnergyConsumers:e=>n.drawLoads(e,"EnergyConsumer"),drawConformLoads:e=>n.drawLoads(e,"ConformLoad"),drawNonConformLoads:e=>n.drawLoads(e,"NonConformLoad"),drawEquivalentInjections:e=>n.drawLoads(e,"EquivalentInjection"),drawLinearCompensators:e=>n.drawCompensators(e,"LinearShuntCompensator"),drawNonlinearCompensators:e=>n.drawCompensators(e,"NonlinearShuntCompensator"),drawGenerators(e,t){let r=n.createSelection(t,e)[1],i="G";const o=Math.round(15);return"AsynchronousMachine"===t&&(i="M"),r.append("circle").attr("r",12.5).attr("cx",0).attr("cy",0).attr("fill","white").attr("stroke","black").attr("stroke-width",1),r.append("text").attr("class","cim-object-text").style("text-anchor","middle").attr("font-size",3).attr("x",17.5).attr("y",0).text((function(e){let t=n.props.model.getAttribute(e,"cim:IdentifiedObject.name");return void 0!==t?t.innerHTML:""})),r.append("text").style("text-anchor","middle").attr("font-size",o).attr("x",0).attr("y",6.25).text(i),r},drawLoads(e,t){let r=d3.line().x((function(e){return e.x})).y((function(e){return e.y})).curve(d3.curveLinearClosed),i=n.createSelection(t,e)[1];return i.append("path").attr("d",(function(e){return r([{x:-15,y:-10,seq:1},{x:15,y:-10,seq:2},{x:0,y:10,seq:3}])})).attr("fill","white").attr("stroke","black").attr("stroke-width",2),i.append("text").attr("class","cim-object-text").style("text-anchor","middle").attr("font-size",3).attr("x",0).attr("y",20).text((function(e){let t=n.props.model.getAttribute(e,"cim:IdentifiedObject.name");return void 0!==t?t.innerHTML:""})),i},drawCompensators(e,t){let r=d3.line().x((function(e){return e.x})).y((function(e){return e.y})),i=n.createSelection(t,e)[1];return i.append("path").attr("d",(function(e){return r([{x:0,y:-10,seq:1},{x:0,y:-4,seq:2}])})).attr("fill","white").attr("stroke","black").attr("stroke-width",1),i.append("path").attr("d",(function(e){return r([{x:0,y:4,seq:1},{x:0,y:10,seq:2}])})).attr("fill","white").attr("stroke","black").attr("stroke-width",1),i.append("path").attr("d",(function(e){return r([{x:-15,y:-4,seq:1},{x:15,y:-4,seq:2}])})).attr("fill","white").attr("stroke","black").attr("stroke-width",4),i.append("path").attr("d",(function(e){return r([{x:-15,y:4,seq:1},{x:15,y:4,seq:2}])})).attr("fill","white").attr("stroke","black").attr("stroke-width",4),i.append("text").attr("class","cim-object-text").style("text-anchor","middle").attr("font-size",3).attr("x",0).attr("y",20).text((function(e){let t=n.props.model.getAttribute(e,"cim:IdentifiedObject.name");return void 0!==t?t.innerHTML:""})),i},drawPowerTransformers(t){const r=this.createSelection("PowerTransformer",t)[1],i=r.filter((function(e){return 2===n.props.model.getTargets([e],"PowerTransformer.PowerTransformerEnd").length})),o=r.filter((function(e){return 3===n.props.model.getTargets([e],"PowerTransformer.PowerTransformerEnd").length}));return i.append("circle").attr("r",e).attr("cx",0).attr("cy",11).attr("fill","white").attr("stroke","black").attr("stroke-width",1),o.append("circle").attr("r",e).attr("cx",-11).attr("cy",11).attr("fill","white").attr("stroke","black").attr("stroke-width",1),o.append("circle").attr("r",e).attr("cx",11).attr("cy",11).attr("fill","white").attr("stroke","black").attr("stroke-width",1),i.append("g").attr("class","TransformerEnd").attr("transform",d3.zoomIdentity.translate(0,-11)).append("circle").attr("r",e).attr("cx",0).attr("cy",0).attr("fill","white").attr("stroke","black").attr("stroke-width",1).attr("class","TransformerEndCircle"),i.append("g").attr("class","TransformerEnd").attr("transform",d3.zoomIdentity.translate(0,11)).append("circle").attr("r",e).attr("cx",0).attr("cy",0).attr("fill","white").attr("fill-opacity","0").attr("stroke","black").attr("stroke-width",1).attr("class","TransformerEndCircle"),o.append("g").attr("class","TransformerEnd").attr("transform",d3.zoomIdentity.translate(0,-11)).append("circle").attr("r",e).attr("cx",0).attr("cy",0).attr("fill","white").attr("stroke","black").attr("stroke-width",1).attr("class","TransformerEndCircle"),o.append("g").attr("class","TransformerEnd").attr("transform",d3.zoomIdentity.translate(-11,11)).append("circle").attr("r",e).attr("cx",0).attr("cy",0).attr("fill","white").attr("fill-opacity","0").attr("stroke","black").attr("stroke-width",1).attr("class","TransformerEndCircle"),o.append("g").attr("class","TransformerEnd").attr("transform",d3.zoomIdentity.translate(11,11)).append("circle").attr("r",e).attr("cx",0).attr("cy",0).attr("fill","white").attr("fill-opacity","0").attr("stroke","black").attr("stroke-width",1).attr("class","TransformerEndCircle"),r.append("text").attr("class","cim-object-text").style("text-anchor","end").attr("font-size",3).attr("x",-25).attr("y",0).text((function(e){const t=n.props.model.getAttribute(e,"cim:IdentifiedObject.name");return void 0!==t?t.innerHTML:""})),r},handlePowerTransformerEnds(e){const t=d3.select(e).datum(),r=d3.select(e.parentNode).datum(),i=n.props.model.getTargets([t],"Terminal.TransformerEnd"),o=t.x-r.x,a=t.y-r.y;let s=null,l=null;d3.select(e.parentNode).selectAll(":scope > g.TransformerEnd").each((function(){const e=this.transform.baseVal.consolidate();let t={e:0,f:0};null!==e&&(t=e.matrix);const n=t.e,r=t.f,i=(n-o)**2+(r-a)**2;(null===s||s>i)&&(s=i,l=d3.select(this))})),l.data(i),l.attr("id",(function(){return"cimdiagram-"+n.props.model.ID(i[0])})),l.select("circle.TransformerEndCircle").attr("stroke",(function(e){return n.voltageColor(e,"black")})),l.selectAll("path").remove();const c=n.props.model.getEnum(i[0],"cim:PowerTransformerEnd.connectionKind");if(void 0!==c){const e=.2,t=.4,n=[0,a*e],r=[0,a*t],i=t-e,o=i*Math.sqrt(3)/2,s=i/2,u=[a*-o,a*(e-s)],f=[a*o,a*(e-s)];c.startsWith("Y")&&(l.append("path").attr("d",d3.line()([r,n])).attr("stroke","black"),l.append("path").attr("d",d3.line()([n,u])).attr("stroke","black"),l.append("path").attr("d",d3.line()([n,f])).attr("stroke","black")),"D"===c&&l.append("path").attr("d",d3.line().curve(d3.curveLinearClosed)([r,u,f])).attr("stroke","black").attr("fill","white")}},createTerminals(t){let r=0,i=30,a="none";switch(t.size()>0&&(a=t.data()[0].nodeName),a){case"cim:Breaker":case"cim:Disconnector":case"cim:LoadBreakSwitch":r=-6,i=6;break;case"cim:EnergySource":case"cim:SynchronousMachine":case"cim:AsynchronousMachine":r=-13.5;break;case"cim:EnergyConsumer":case"cim:ConformLoad":case"cim:NonConformLoad":case"cim:EquivalentInjection":r=-11;break;case"cim:PowerTransformer":r=-26,i=26;break;case"cim:LinearShuntCompensator":case"cim:NonlinearShuntCompensator":r=-11;break;default:i=30}let s=[],l=t.selectAll("g.Terminal").data((function(e){return n.props.model.getTerminals([e])})),c=l.enter().append("g").each((function(t,l){let c=n.props.model.getTargets([t],o)[0],u=d3.select(this.parentNode).datum().lineData,f=u[0],d=u[u.length-1],h=d3.select(this.parentNode).datum().x,p=d3.select(this.parentNode).datum().y;1===u.length&&(f={x:0,y:r},d={x:0,y:i});let m=d3.select(this.parentNode).datum().rotation,g=n.props.model.getTerminals(d3.select(this.parentNode).data());if(void 0!==c&&2===g.length){let e=0,r=0;if(m>0){let t=rotate(f,m),n=rotate(d,m);e=Math.pow(h+t.x-c.x,2)+Math.pow(p+t.y-c.y,2),r=Math.pow(h+n.x-c.x,2)+Math.pow(p+n.y-c.y,2)}else e=Math.pow(h+f.x-c.x,2)+Math.pow(p+f.y-c.y,2),r=Math.pow(h+d.x-c.x,2)+Math.pow(p+d.y-c.y,2);re!==t))[0],u=n.props.model.getTargets([c],o)[0],f=c;if(void 0!==u){n.props.model.getEquipments(u).length>1&&(f=t)}c.x===t.x&&c.y===t.y&&(t.x===i+l.x&&t.y===a+l.y?(f.x=i+s.x,f.y=a+s.y):(f.x=i+l.x,f.y=a+l.y))}(g,t,0,h,p,f,d)}else 1===u.length?(t.x=h,3===g.length?(0===l&&(t.y=p+r),1===l&&(t.x=t.x-25+e,t.y=p+i),2===l&&(t.x=t.x+25-e,t.y=p+i)):t.y=p+r*(1-l)+i*l):(t.x=h+f.x*(1-l)+d.x*l,t.y=p+f.y*(1-l)+d.y*l);if(t.rotation=d3.select(this.parentNode).datum().rotation,void 0!==c&&void 0!==c.lineData){let e={source:c,target:t};s.push(e)}"cim:PowerTransformer"===a&&n.handlePowerTransformerEnds(this)})).attr("id",(function(e){return"cimdiagram-"+n.props.model.ID(e)})).attr("class",(function(e){return e.localName}));return n.createEdges(s),c.append("circle").attr("r",1).style("fill","black").attr("cx",(function(e,t){return d3.select(this.parentNode).datum().x-d3.select(this.parentNode.parentNode).datum().x})).attr("cy",(function(e,t){return d3.select(this.parentNode).datum().y-d3.select(this.parentNode.parentNode).datum().y})),l.each((function(e,t){let n=d3.select(this.parentNode).datum().x,r=d3.select(this.parentNode).datum().y,i=parseInt(d3.select(this.firstChild).attr("cx")),o=parseInt(d3.select(this.firstChild).attr("cy"));if(0===i&&0===o)e.x=n,e.y=r;else{let t=d3.select(this.parentNode).datum().lineData,i=t[t.length-1];e.x=n+i.x,e.y=r+i.y}})),l.selectAll("circle").attr("cx",(function(e,t){return d3.select(this.parentNode).datum().x-d3.select(this.parentNode.parentNode).datum().x})).attr("cy",(function(e,t){return d3.select(this.parentNode).datum().y-d3.select(this.parentNode.parentNode).datum().y})),c.each((function(){let e=d3.select(this).select("circle");d3.select(this).append("circle").attr("cx",e.attr("cx")).attr("cy",e.attr("cy")).attr("r",4).attr("stroke-width",0).attr("fill","steelblue").attr("fill-opacity","0.0").attr("class","big-circle").on("mouseout",(function(e,t){d3.select(this).attr("fill-opacity","0.0")}))})),c.on("mouseover",(function(e,t){0===d3.select(this).select("circle.selection-circle").size()&&d3.select(this).select("circle.big-circle").attr("fill-opacity","0.7")})),c},drawNodes(e){let t=d3.line().x((function(e){return e.x})).y((function(e){return e.y}));for(let t of e)calcLineData(n.props.model,t);d3.select("svg").select("g."+r+"s").empty()&&d3.select("svg").select("g#diagram-main").append("g").attr("class",r+"s");let i=d3.select("svg").select("g."+r+"s").selectAll("g."+r).data(e,(function(e){return n.props.model.ID(e)})),o=i.enter().append("g").attr("class",r).attr("id",(function(e){return"cimdiagram-"+n.props.model.ID(e)}));function a(e){e.attr("x",(function(e){let t=d3.select(this.parentNode).select("path").node();return t.getPointAtLength(t.getTotalLength()/2).x+2})).attr("y",(function(e){let t=d3.select(this.parentNode).select("path").node();return t.getPointAtLength(t.getTotalLength()/2).y-2})).text((function(e){let t=n.props.model.getBusbar(e);if(null!==t){let e=n.props.model.getAttribute(t,"cim:IdentifiedObject.name");if(void 0!==e)return e.innerHTML}return""}))}return i.select("path").attr("d",(function(e){let n=d3.select(this.parentNode).data()[0].lineData;return t(n)})).attr("stroke",(function(e){return n.voltageColor(n.props.model.getBusbar(e),"black")})),o.append("path").attr("d",(function(e){let n=d3.select(this.parentNode).data()[0].lineData;return t(n)})).attr("stroke",(function(e){return n.voltageColor(n.props.model.getBusbar(e),"black")})).attr("stroke-width",2).attr("fill","none"),o.filter((function(e){return null!==n.props.model.getBusbar(e)})).append("text").attr("class","cim-object-text").attr("font-size",3),a(o.select("text")),a(i.select("text")),o},moveTo(e){let t=n.props.model.getObject(e);if(void 0===t)return;if("cim:BusbarSection"===t.nodeName&&(t=n.props.model.getNode(t)),"cim:Substation"===t.nodeName||"cim:Line"===t.nodeName){let e=n.props.model.getTargets([t],"EquipmentContainer.Equipments");for(let r of e){if("cim:BusbarSection"===r.nodeName){let e=n.props.model.getNode(r);null!==e&&(r=e)}if(void 0!==r.x&&void 0!==r.y){t.x=r.x,t.y=r.y;break}}}if("cim:Analog"!==t.nodeName&&"cim:Discrete"!==t.nodeName||(t=n.props.model.getTargets([t],"Measurement.PowerSystemResource")[0],void 0!==t&&"cim:BusbarSection"===t.nodeName&&(t=n.props.model.getNode(t))),"cim:PowerTransformerEnd"===t.nodeName&&(t=n.props.model.getTargets([t],"PowerTransformerEnd.PowerTransformer")[0]),void 0===t.x||void 0===t.y)return;hidePopovers();let r=parseInt(d3.select("svg").style("width")),i=parseInt(d3.select("svg").style("height")),o=1*-t.x+r/2,a=1*-t.y+i/2,s=d3.transition().duration(750).ease(d3.easeLinear),l=d3.zoomIdentity.translate(o,a).scale(1);d3.selectAll("svg").select("g#diagram-main").transition(s).attr("transform",l),d3.zoom().transform(d3.selectAll("svg"),l),n.props.dispatcher.trigger("transform")},forceTick(e){0!==arguments.length&&void 0===e.alpha||(e=d3.select("svg").selectAll("svg > g#diagram-main > g:not(.edges) > g"));let t=d3.zoomTransform(d3.select("svg").node()),r=t.x,i=t.y,o=t.k;if(function(e){e.attr("transform",(function(e){return"translate("+e.x+","+e.y+") rotate("+e.rotation+")"})).selectAll("g.Terminal").each((function(e,t){e.x=d3.select(this.parentNode).datum().x+parseInt(d3.select(this.firstChild).attr("cx")),e.y=d3.select(this.parentNode).datum().y+parseInt(d3.select(this.firstChild).attr("cy"))})),e.selectAll("text.cim-object-text").attr("transform",(function(e){let t=0,n={x:0,y:0};switch(e.rotation%360==180&&(t=-1*e.rotation),e.nodeName){case"cim:Breaker":case"cim:Disconnector":case"cim:LoadBreakSwitch":case"cim:Junction":case"cim:PowerTransformer":n={x:0,y:0};break;default:n={x:d3.select(this).attr("x"),y:d3.select(this).attr("y")}}return"rotate("+t+","+n.x+","+n.y+")"})),e.selectAll("rect.selection-rect").attr("x",0).attr("y",0).attr("width",0).attr("height",0),e.selectAll("rect.selection-rect").attr("x",(function(e){return this.parentNode.getBBox().x})).attr("y",(function(e){return this.parentNode.getBBox().y})).attr("width",(function(e){return this.parentNode.getBBox().width})).attr("height",(function(e){return this.parentNode.getBBox().height})),e.selectAll("g.resize").selectAll("rect").attr("x",(function(e){return e[0].lineData.filter((t=>t.seq===e[1]))[0].x-2})).attr("y",(function(e){return e[0].lineData.filter((t=>t.seq===e[1]))[0].y-2}))}(e),1===arguments.length){let t=n.props.model.getTerminals(e.data()),a=d3.select("svg").selectAll("svg > g#diagram-main > g.edges > g").filter((function(n){return e.data().indexOf(n.source)>-1||t.indexOf(n.target)>-1}));n.updateEdges(r,i,o,a)}else n.updateEdges(r,i,o)},updateEdges(e,t,r,i){let o=d3.line().x((function(e){return e.x})).y((function(e){return e.y})).curve(d3.curveStepBefore);3===arguments.length&&(i=d3.select("svg").selectAll("svg > g#diagram-main > g.edges > g")),i.select("path").attr("d",(function(e){let t={x:e.source.x,y:e.source.y},r={x:e.target.x,y:e.target.y};return 0!==e.target.rotation&&(r=rotateTerm(n.props.model,e.target)),e.source.lineData.length>1?e.p=closestPoint(e.source,r):e.p=[0,0],t.x=t.x+e.p[0],t.y=t.y+e.p[1],o([t,r])})).attr("stroke-dasharray",(function(e){let t=n.props.model.getAttribute(e.target,"cim:ACDCTerminal.connected");return void 0!==t&&"false"===t.textContent?"5, 5":null}))},drawGrid(e){let t=parseInt(d3.select("svg").style("width"))/e,n=parseInt(d3.select("svg").style("height"))/e,r=d3.select("svg").select("g#diagram-grid");r.selectAll("*").remove();const i=25;for(let e=i;e<=n-i;e+=i)r.append("svg:line").attr("x1",0).attr("y1",e).attr("x2",t).attr("y2",e).attr("stroke-dasharray","1, 5").style("stroke","rgb(6,120,155)").style("stroke-width",1);for(let e=i;e<=t-i;e+=i)r.append("svg:line").attr("x1",e).attr("y1",0).attr("x2",e).attr("y2",n).attr("stroke-dasharray","1, 5").style("stroke","rgb(6,120,155)").style("stroke-width",1);r.attr("transform","scale("+e+")")},voltageColor(e,r){let i=r;if(null!=e){let r="ConductingEquipment.BaseVoltage";!0===n.props.model.schema.isA("TransformerEnd",e)&&(r="TransformerEnd.BaseVoltage");const o=n.props.model.getTargets([e],r)[0],a=n.props.model.getAttribute(o,"cim:BaseVoltage.nominalVoltage");if(void 0!==a&&""!==a.textContent){const e=a.textContent,n=parseFloat(e);i=t(n)}}return i},drawLegend(){let e=n.props.model.getObjects(["cim:BaseVoltage"])["cim:BaseVoltage"];d3.select("#legend-rect").attr("height",60+20*e.length),e.sort((function(e,t){const r=n.props.model.getAttribute(e,"cim:BaseVoltage.nominalVoltage"),i=n.props.model.getAttribute(t,"cim:BaseVoltage.nominalVoltage");if(void 0!==r&&void 0!==i){const e=r.textContent,t=parseFloat(e),n=i.textContent;return t
              Legend
              ',[{type:n.TAG,getComponent:r,evaluate:function(e){return"cimdiagramcontrols"},slots:[],attributes:[{type:t.ATTRIBUTE,name:"model",evaluate:function(e){return e.props.model}},{type:t.ATTRIBUTE,name:"dispatcher",evaluate:function(e){return e.props.dispatcher}}],redundantAttribute:"expr0",selector:"[expr0]"}])},name:"cimdiagram"}})),function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e=e||self).cimDiagramControls=t()}(this,(function(){"use strict";let e=null,t="ConnectivityNode",n="ConnectivityNode.Terminals",r="Terminal.ConnectivityNode",i=d3.quadtree(),o=[],a=[],s=!1,l=!1,c=[{title:"Copy",action:function(t,n){let r=this;!0===e.props.model.schema.isA("TransformerEnd",d3.select(r).datum())&&(r=r.parentElement),-1===o.indexOf(r)&&(o.push(r),e.updateSelected());let i=d3.selectAll(o).data();for(let t of i)if("cim:ConnectivityNode"===t.nodeName){let n=e.props.model.getBusbar(t);null!==n&&(n.x=t.x,n.y=t.y,a.push(n))}else a.push(t)}},{title:"Rotate",action:function(t,n){let r=this;!0===e.props.model.schema.isA("TransformerEnd",d3.select(r).datum())&&(r=r.parentElement),-1===o.indexOf(r)&&(e.deselectAll(),o.push(r),e.updateSelected()),hidePopovers(o);let i=d3.selectAll(o);e.props.model.getTerminals(i.data()).forEach((function(e){e.rotation=(e.rotation+90)%360}));for(let t of i.data())t.rotation=(t.rotation+90)%360,e.props.model.updateActiveDiagram(t,t.lineData)}},{title:"Delete",action:function(t,n){let r=this;!0===e.props.model.schema.isA("TransformerEnd",d3.select(r).datum())&&(r=r.parentElement),e.deleteObject(r)}},{title:"Delete from current diagram",action:function(t,n){let r=this;!0===e.props.model.schema.isA("TransformerEnd",d3.select(r).datum())&&(r=r.parentElement),e.deleteFromDiagram(r)}},{title:"Show element info",action:function(t,n){let r=this;!0===e.props.model.schema.isA("TransformerEnd",d3.select(r).datum())&&(r=r.parentElement),-1===o.indexOf(r)&&(e.deselectAll(),o.push(r),e.updateSelected()),showPopovers(o)}},{title:"Add new operational limit set",action:function(t,n){e.addNewLimitSet(this,n)}}],u=c.concat([{title:"Add points",action:function(t,n){let r=e.status,i=this;e.disableAll(),e.deselectAll(),o.push(i),d3.select("svg").on("contextmenu.general",null),e.addDrawing(n,(function(t){let o=d3.select("svg"),a=o.selectAll("svg > #diagram-connect > path"),s=o.selectAll("svg > #diagram-connect > circle");switch(t.preventDefault(),e.addNewPoint(n),e.deleteFromDiagram(i),e.props.model.addToActiveDiagram(n,n.lineData),o.on("mousemove",null),a.attr("d",null),s.attr("transform","translate(0, 0)"),d3.select("svg > #diagram-connect > path").datum(null),o.on("contextmenu.add",null),o.on("click.add",null),r){case"DRAG":e.enableDrag();break;case"ZOOM":e.enableZoom();break;case"CONNECT":e.enableConnect();break;default:{let t=r.substring("ADD".length);t.startsWith("Multi")?(t=t.substring("Multi".length),e.enableAddMulti(t)):e.enableAdd(t);break}}d3.select("svg").on("contextmenu.general",d3.contextMenu(g))})),d3.select("svg").on("click.add",(function(){e.addNewPoint(n)}))}}]),f=[{title:"Delete point",action:function(t,n){let r=d3.selectAll(o).data().filter((e=>e===n[0]))[0];o=o.filter((e=>d3.select(e).datum()!==n[0])),e.deselectAll(),o.push(r),e.updateSelected(),e.deleteFromDiagram(this.parentNode),n[0].lineData=n[0].lineData.filter((e=>e.seq!==n[1]));for(let e of n[0].lineData)e.seq>n[1]&&(e.seq=e.seq-1);e.props.model.addToActiveDiagram(n[0],n[0].lineData)}}],d=[{title:"Add new operational limit set",action:function(t,n){e.addNewLimitSet(this,n)}},{title:"Add regulating control",action:function(t,n){e.addRegulatingControl(this,n)}},{title:"Add tap changer control",action:function(t,n){e.addTCControl(this,n)}}],h=d.concat([{title:"Add ratio tap changer",action:function(t,n){e.addTC(this,n)}}]),p=c.concat([{title:"Add ratio tap changer",action:function(t,n){e.addTC(this,n)}}]),m=[{title:"Delete",action:function(t,r){let i=e.getLinkedCNs([r.target])[0];if(void 0!==i){let t=e.props.model.ID(i.cn),n=d3.select("svg").selectAll("g#cimdiagram-"+t).node();e.deleteObject(n)}else e.props.model.removeLink(r.source,"cim:"+n,r.target)}}],g=[{title:"Paste",disabled:function(e,t){return a.length<1},action:function(t,n){if(a.length<1)return;let r=d3.pointer(t,d3.select("svg").node()),i=d3.zoomTransform(d3.select("svg").node()),o=(i.x,i.y,i.k,r[0]-a[0].x),s=r[1]-a[0].y,l=null;for(let t of a){let n=e.props.model.createObject(t.nodeName);for(let r of e.props.model.getAttributes(t)){let t=r.nodeName,i=r.textContent;e.props.model.setAttribute(n,t,i)}if(n.x=t.x+o,n.y=t.y+s,"cim:BusbarSection"===n.nodeName){let n=e.props.model.getNode(t);if(null===n)return;l=n.lineData}else l=t.lineData;e.props.model.addToActiveDiagram(n,l)}a=[]}}];const b=d3.drag().on("drag",(function(t,n){hidePopovers(o);const r={x:t.x,y:t.y,seq:n[1]},i=e.align(n[0],r,!0);!function(e,t,n){const r=e.lineData.filter((e=>e.seq===t))[0],i=rotate({x:n.x,y:n.y},-1*e.rotation);if(1!==r.seq)r.x=n.x,r.y=n.y;else{e.x=e.x+n.x,e.y=e.y+n.y;for(let t of e.lineData)1!==t.seq&&(t.x=t.x-i.x,t.y=t.y-i.y)}}(n[0],n[1],i),e.props.model.updateActiveDiagram(n[0],n[0].lineData)})).on("start",(function(t,n){e.removeFromQuadtree()})).on("end",(function(t,n){e.highlight(null),e.props.model.updateActiveDiagram(n[0],n[0].lineData),e.addToQuadtree(d3.selectAll(o))}));return{css:null,exports:{onBeforeMount(a,s){e=this,e.props.dispatcher.on("moveTo",(function(t){e.deselectAll();let n=e.props.model.getObject(t),r=null,i=null,a=null,s=null,l=null;if(void 0!==n){switch(n.nodeName){case"cim:Substation":case"cim:Line":r=e.props.model.getTargets([n],"EquipmentContainer.Equipments");for(let t of r)"cim:BusbarSection"===t.nodeName&&(a=e.props.model.getNode(t),null!==a&&(t=a)),l=d3.select("svg").select("#cimdiagram-"+e.props.model.ID(t)).node(),null!==l&&o.push(l);break;case"cim:Analog":case"cim:Discrete":i=e.props.model.getTargets([n],"Measurement.Terminal");for(let t of i)l=d3.select("svg").select("#cimdiagram-"+e.props.model.ID(t)).node(),null!==l&&o.push(l);break;case"cim:BusbarSection":a=e.props.model.getNode(n),s=e.props.model.ID(a),l=d3.select("svg").selectAll("g#cimdiagram-"+s).node(),o=[l];break;default:l=d3.select("svg").selectAll("g#cimdiagram-"+t).node(),o=[l]}e.updateSelected()}})),e.props.dispatcher.on("deselect",(function(){e.deselectAll()})),e.props.dispatcher.on("render",(function(){"BUS_BRANCH"===e.props.model.getMode()?(t="TopologicalNode",n="TopologicalNode.Terminal",r="Terminal.TopologicalNode"):(c.push({title:"Add new measurement",action:function(t,n){e.addNewMeasurement(this,n)}}),u.push({title:"Add new measurement",action:function(t,n){e.addNewMeasurement(this,n)}}),d.push({title:"Add new measurement",action:function(t,n){e.addNewMeasurement(this,n)}}));let o=d3.select("svg").selectAll("svg > g#diagram-main > g:not(.edges) > g");i.x((function(e){let t=d3.select(e.elm).datum(),n=t.lineData.filter((t=>t.seq===e.seq));return t.x+n[0].x})).y((function(e){let t=d3.select(e.elm).datum(),n=t.lineData.filter((t=>t.seq===e.seq));return t.y+n[0].y})),e.addToQuadtree(o);let a=d3.select("svg").selectAll("svg > g#diagram-main > g.edges > g");e.addContextMenu(o),d3.select("svg").on("contextmenu.general",d3.contextMenu(g)),a.on("contextmenu",d3.contextMenu(m)),e.disableZoom(),e.disableConnect(),e.enableDrag(),document.querySelector("#cim-diagram-controls").classList.remove("invisible"),document.querySelector("#cim-diagram-insert").classList.remove("invisible"),document.querySelector("#cim-diagram-legend").classList.remove("invisible");let s=null;d3.select("body").on("keydown",(function(t){void 0!==t&&t.ctrlKey&&(null===s&&(s=e.status),e.disableDrag(),e.disableZoom(),e.enableZoom())})).on("keyup",(function(t){if(17===t.keyCode){switch(e.disableZoom(),s){case"DRAG":e.enableDrag();break;case"ZOOM":e.enableZoom();break;default:e.status=s}s=null}27===t.keyCode&&d3.contextMenu("close")}))})),e.props.dispatcher.on("addToDiagram",(function(t){1===t.size()&&(e.addToQuadtree(t),"DRAG"===e.status&&(e.disableAll(),e.enableDrag()),e.addContextMenu(t))})),e.props.dispatcher.on("createEdges",(function(e){e.on("contextmenu",d3.contextMenu(m))}))},onMounted(){document.querySelector("#select").addEventListener("change",(function(){e.disableAll(),e.enableDrag()})),document.querySelector("#pan").addEventListener("change",(function(){e.disableAll(),e.enableZoom()})),document.querySelector("#connect").addEventListener("change",(function(){e.disableAll(),e.enableConnect()})),document.querySelector("#legendToggle").addEventListener("change",(function(){const e=d3.transition().duration(750).ease(d3.easeLinear);!1===this.checked?d3.select("#diagram-legend").transition(e).attr("transform",d3.zoomIdentity.translate(1200,50)):d3.select("#diagram-legend").transition(e).attr("transform",d3.zoomIdentity.translate(1050,50))}))},disableAll(){e.disableDrag(),e.disableZoom(),e.disableConnect(),e.disableAdd()},deselectAll(){d3.selectAll(o).selectAll("rect.selection-rect").remove(),d3.selectAll(o).selectAll("g.resize").remove(),d3.selectAll(o).selectAll("circle.selection-circle").remove(),o=[]},enableDrag(){let t=[];e.disableDrag(),e.status="DRAG";let n=d3.drag().on("start",(function(n,r){if(d3.contextMenu("close"),-1===o.indexOf(this)&&e.deselectAll(),0===o.length&&(o.push(this),e.updateSelected()),e.removeFromQuadtree(),!0===e.props.model.schema.isA("ConductingEquipment",r)){let n=e.props.model.getTerminals([r]);t=e.getLinkedCNs(n)}let i=e.props.model.getTerminals(d3.selectAll(o).data());d3.select("svg").selectAll("svg > g#diagram-main > g.edges > g").filter((function(e){return d3.selectAll(o).data().indexOf(e.source)>-1||i.indexOf(e.target)>-1})).select("path").attr("stroke","green").attr("stroke-width","3")})).on("drag",(function(n,r){hidePopovers(o);let i=n.x-r.x,a=n.y-r.y,s={x:0,y:0};for(let t of o){let n=d3.select(t).data()[0];if(n.x=n.x+i,n.px=n.x,n.y=n.y+a,n.py=n.y,0===s.x&&0===s.y)for(let t of n.lineData){let r=e.align(n,t,!1);if(s={x:r.x-t.x,y:r.y-t.y},0!==s.x||0!==s.y){t.seq>1&&(s=rotate(s,n.rotation));break}}}for(let t of o){let n=d3.select(t).data()[0];l(n,null,s),e.props.model.updateActiveDiagram(n,n.lineData)}for(let n of t){let t={x:n.cnTerms[0].x,y:n.cnTerms[0].y},r={x:n.cnTerms[1].x,y:n.cnTerms[1].y};n.cnTerms[0].rotation>0&&(t=rotateTerm(e.props.model,n.cnTerms[0])),n.cnTerms[1].rotation>0&&(r=rotateTerm(e.props.model,n.cnTerms[1])),n.cn.x=(t.x+r.x)/2,n.cn.y=(t.y+r.y)/2,e.props.model.updateActiveDiagram(n.cn,n.cn.lineData)}function l(e,t,n){e.x=e.x+n.x,e.y=e.y+n.y,e.px=e.x,e.py=e.y}})).on("end",(function(n,r){e.addToQuadtree(d3.selectAll(o)),t=[];let i=e.props.model.getTerminals(d3.selectAll(o).data());d3.select("svg").selectAll("svg > g#diagram-main > g.edges > g").filter((function(e){return d3.selectAll(o).data().indexOf(e.source)>-1||i.indexOf(e.target)>-1})).select("path").attr("stroke","black").attr("stroke-width","1"),e.highlight("x",null),e.highlight("y",null)}));d3.select("svg").selectAll("svg > g#diagram-main > g:not(.edges) > g").call(n),d3.select("svg").select("g#diagram-brush").call(d3.brush().on("start",(function(){let t=window.location.hash.substring(1).split("/"),n=t[0]+"/"+t[1]+"/"+t[2];route.router.push(n),e.deselectAll(),hidePopovers(),d3.contextMenu("close")})).on("end",(function(t){d3.select("svg").select("g#diagram-brush").selectAll("*:not(.overlay)").style("display","none");let n=t.selection;if(null===n)return;e.deselectAll();let r=d3.zoomTransform(d3.select("svg").node()),a=r.x,s=r.y,l=r.k;o=e.search(i,(n[0][0]-a)/l,(n[0][1]-s)/l,(n[1][0]-a)/l,(n[1][1]-s)/l),e.updateSelected()})))},search(e,t,n,r,i){let o=new Set;return e.visit((function(e,a,s,l,c){if(!e.length)do{let a=e.data,s=d3.select(a.elm).datum();for(let e of s.lineData){let l=rotate(e,s.rotation),c=s.x+l.x,u=s.y+l.y;if(c>=t&&c=n&&u=r||s>=i||lo.indexOf(e.elm)>-1));i.removeAll(e)},updateSelected(){d3.selectAll(o).each((function(t){e.hover(this)})).selectAll("g.resize").call(b).filter((function(e){return e[0].lineData.length>2})).on("contextmenu",d3.contextMenu(f))},getLinkedCNs(t){let i=[],o=e.props.model.getTargets(t,r);for(let t of o){if(void 0===t.lineData)continue;if(t.lineData.length>1)continue;let r=e.props.model.getTargets([t],n);if(2===r.length){let e={cn:t,cnTerms:r};i.push(e)}}return i},disableDrag(){d3.select("svg").selectAll("svg > g#diagram-main > g:not(.edges) > g").on(".drag",null),d3.select("svg").select("g#diagram-brush").on(".brush",null),"DRAG"===e.status&&d3.select("svg").select("g#diagram-brush").call(d3.brush().move,null)},enableZoom(){e.status="ZOOM",hidePopovers(),d3.select("svg").selectAll("svg > g#diagram-main > g:not(.edges) > g").on("click.zoom",(function(t,n){let r=window.location.hash.substring(1).split("/"),i=r[0]+"/"+r[1]+"/"+r[2];route.router.push(i+"/"+e.props.model.ID(n))}));let t=d3.zoom();t.on("zoom",this.zooming),d3.select("svg").call(t)},disableZoom(){d3.select("svg").selectAll("svg > g#diagram-main > g:not(.edges) > g").on("click.zoom",null),d3.select("svg").on(".zoom",null)},zooming(t){d3.select("svg").select("g#diagram-main").attr("transform",t.transform),e.props.dispatcher.trigger("transform");let n=d3.select("svg > #diagram-connect > path").datum();if(void 0===n)return;let r=d3.line().x((function(e){return e.x})).y((function(e){return e.y})),i=d3.select("svg > #diagram-connect > path"),o=d3.zoomTransform(d3.select("svg").node()),a=d3.select("svg > #diagram-connect > circle").node().transform.baseVal.consolidate();if(null===a)return;let s=a.matrix,l=s.e-10,c=s.f-10,u=[],f=n.obj;if(void 0===f.lineData)u.push({x:f.x*o.k+o.x,y:f.y*o.k+o.y});else for(let e of f.lineData)u.push({x:(e.x+f.x)*o.k+o.x,y:(e.y+f.y)*o.k+o.y});u.push({x:l,y:c}),i.attr("d",(function(){return r(u)}))},enableConnect(){function n(t){d3.select("svg").selectAll("svg > #diagram-connect > path").attr("d",null),d3.select("svg").selectAll("svg > #diagram-connect > circle").attr("transform","translate(0, 0)");let n=d3.select("svg > #diagram-connect > path").datum();void 0!==n&&(d3.select("svg").on("mousemove",null),e.props.model.setLink(n.obj,"cim:"+r,t),d3.select("svg > #diagram-connect > path").datum(null))}e.deselectAll(),d3.select("body").on("keyup.connect",(function(t){27===t.keyCode&&(e.disableConnect(),e.enableConnect())})),e.status="CONNECT",d3.select("svg").selectAll("svg > g#diagram-main > g:not(.edges) > g > g.Terminal").on("click",(function(n,i){let o=d3.line().x((function(e){return e.x})).y((function(e){return e.y})),a={x:i.x,y:i.y};i.rotation>0&&(a=rotateTerm(e.props.model,i));let s=d3.select("svg"),l=d3.select("svg > #diagram-connect > path"),c=d3.select("svg > #diagram-connect > circle"),u=l.datum();if(void 0!==u&&(u=u.obj),void 0!==u){let n=e.props.model.getTargets([i],r)[0];if(void 0===n)n=e.props.model.getTargets([u],r)[0];else{let n=e.getLinkedCNs([u]);for(let r of n){let n=e.props.model.ID(r.cn),i=d3.select("svg > g#diagram-main > g."+t+"s > g#cimdiagram-"+n).node();e.deleteObject(i)}}if(d3.select("svg").selectAll("svg > #diagram-connect > path").attr("d",null),d3.select("svg").selectAll("svg > #diagram-connect > circle").attr("transform","translate(0, 0)"),void 0===n){let r={x:u.x,y:u.y};u.rotation>0&&(r=rotateTerm(e.props.model,u)),n=e.props.model.createObject("cim:"+t),e.props.model.setAttribute(n,"cim:IdentifiedObject.name","new1"),n.x=(r.x+a.x)/2,n.y=(r.y+a.y)/2,e.props.model.addToActiveDiagram(n,[{x:0,y:0,seq:1}])}d3.select("svg").on("mousemove",null);let o="cim:"+r;e.props.model.setLink(u,o,n),e.props.model.setLink(i,o,n),l.datum(null)}else{s.on("mousemove",(function(e){let t=d3.pointer(e),n=d3.zoomTransform(d3.select("svg").node());c.attr("transform",(function(){return"translate("+(t[0]+10)+","+(t[1]+10)+")"})),l.attr("d",(function(){let e=a.x*n.k+n.x,r=a.y*n.k+n.y;return o([{x:e,y:r},{x:t[0],y:t[1]}])}))})),l.datum({obj:i})}})),d3.select("svg").selectAll("svg > g#diagram-main > g."+t+"s > g."+t).on("click",(function(e,t){n(t)})),d3.select("svg").selectAll("svg > g#diagram-main > g.edges > g").on("click",(function(e,t){n(t.source)}))},disableConnect(){d3.select("body").on("keyup.connect",null),d3.select("svg").selectAll("svg > g#diagram-main > g:not(.edges) > g > g.Terminal").on("click",null),d3.select("svg").selectAll("svg > g#diagram-main > g."+t+"s > g."+t).on("click",null),d3.select("svg").selectAll("svg > g#diagram-main > g.edges > g").on("click",null),d3.select("svg").on("mousemove",null),d3.select("svg > #diagram-connect > path").attr("d",null),d3.select("svg > #diagram-connect > circle").attr("transform","translate(0, 0)");let e=d3.select("svg > #diagram-connect > path").datum();void 0!==e&&"cim:Terminal"===e.nodeName&&d3.select("svg > #diagram-connect > path").datum(null)},enableAdd(t){let n="",r="";"object"==typeof t?(n=t.target.id,r=t.target.textContent):(n=t,r=d3.select("#"+n).text());let i=void 0;"Three-winding Transformer"===r&&(i={windNum:3}),e.disableAll(),document.querySelector("cimDiagramControls").querySelectorAll("input").forEach((function(e){e.checked=!1})),document.querySelector("#addElement").textContent=r,e.status="ADD"+n,d3.select("svg").on("click.add",(function(t){if(!1===t.ctrlKey){let r=e.props.model.createObject("cim:"+n,i);addToDiagram(e.props.model,t,r)}}))},enableAddMulti(t){let n="",r="",i=d3.select("svg"),o=i.selectAll("svg > #diagram-connect > path"),a=i.selectAll("svg > #diagram-connect > circle");e.disableAll(),d3.select("svg").on("contextmenu.general",null),d3.select("body").on("keyup.addMulti",(function(n){27===n.keyCode&&(e.disableAdd(),e.enableAddMulti(t))})),"object"==typeof t?(n=t.target.id,r=t.target.textContent):(n=t,r=d3.select("#"+n).text()),document.querySelector("cimDiagramControls").querySelectorAll("input").forEach((function(e){e.checked=!1})),document.querySelector("#addElement").textContent=r,e.status="ADDMulti"+n,d3.select("svg").on("click.add",(function(t){if(!1===t.ctrlKey)if(e.status==="ADDMulti"+n){s=e.props.model.createObject("cim:"+n);let r=d3.pointer(t),l=d3.zoomTransform(d3.select("svg").node()),c=l.x,u=l.y,f=l.k;s.x=Math.round((r[0]-c)/f),s.px=s.x,s.y=Math.round((r[1]-u)/f),s.py=s.y,s.lineData=[{x:0,y:0,seq:1}],s.rotation=0,e.addDrawing(s,(function(t){t.preventDefault(),e.addNewPoint(s),e.props.model.addToActiveDiagram(s,s.lineData),e.status="ADDMulti"+n,i.on("mousemove",null),o.attr("d",null),a.attr("transform","translate(0, 0)"),d3.select("svg > #diagram-connect > path").datum(null),i.on("contextmenu.add",null)}))}else e.addNewPoint(s)}));let s=void 0},addDrawing(t,n){e.status="ADDdrawing";let r=d3.select("svg");r.on("contextmenu.add",n),r.on("mousemove",(function(n){let i=d3.pointer(n),o=d3.zoomTransform(r.node()),a=(i[0]-o.x)/o.k,s=(i[1]-o.y)/o.k,l=rotate({x:a-t.x,y:s-t.y,seq:null},-1*t.rotation),c=rotate(e.align(t,l,!0),t.rotation);!function(e,n,i){let o=d3.zoomTransform(r.node()),a=r.selectAll("svg > #diagram-connect > path"),s=r.selectAll("svg > #diagram-connect > circle"),l=d3.line().x((function(e){return e.x})).y((function(e){return e.y}));s.attr("transform",(function(){return"translate("+((e.x+i.x)*o.k+o.x+10)+","+((e.y+i.y)*o.k+o.y+10)+")"})),a.attr("d",(function(){let n=[];for(let r of e.lineData){let i=rotate(r,t.rotation);n.push({x:(i.x+e.x)*o.k+o.x,y:(i.y+e.y)*o.k+o.y})}return n.push({x:(e.x+i.x)*o.k+o.x,y:(e.y+i.y)*o.k+o.y}),l(n)})),a.datum({obj:t,x:e.x+i.x,y:e.y+i.y})}(t,0,c)}))},addNewPoint(t){let n=d3.select("svg").selectAll("svg > #diagram-connect > path").datum(),r=n.x-t.x,i=n.y-t.y,o=t.lineData.length+1,a=rotate({x:r,y:i},-1*t.rotation);t.lineData.push({x:a.x,y:a.y,seq:o}),e.highlight(null)},align(t,n,r){let o=d3.zoomTransform(d3.select("svg").node()),a=!1,c=!1,u=rotate(n,t.rotation),f=t.x+u.x,d=t.y+u.y,h=u.x,p=u.y,m=f-250/o.k,g=d-250/o.k,b=f+250/o.k,v=d+250/o.k,y=e.search(i,m,g,b,v),_=d3.selectAll(y).data();!0===r&&_.push(t);for(let r of _)e:for(let i of r.lineData){if(r===t&&i.seq===n.seq)continue e;let u=rotate(i,r.rotation),m=u.x+r.x,g=u.y+r.y,b=f-m,v=d-g;if(Math.abs(b)<5){f=m,h=f-t.x;let n=m*o.k+o.x;e.highlight("x",n),a=!0,s=!0}if(Math.abs(v)<5){d=g,p=d-t.y;let n=g*o.k+o.y;e.highlight("y",n),c=!0,l=!0}}!1===a&&!0===s&&(e.highlight("x",null),s=!1),!1===c&&!0===l&&(e.highlight("y",null),l=!1);let w={x:h,y:p},x=rotate(w,-1*t.rotation);return 1===n.seq?w:x},highlight(e,t,n){let r=d3.select("svg").select("g#diagram-highlight"),i=null,o=null,a=null,s=null,l=parseInt(d3.select("svg").style("height")),c=parseInt(d3.select("svg").style("width")),u=2*Math.max(l,c);"x"===e?(i=t,o=-1*u,a=t,s=u,r.select("line.highlight-x").attr("x1",i).attr("y1",o).attr("x2",a).attr("y2",s)):"y"===e?(i=-1*u,o=t,a=u,s=t,r.select("line.highlight-y").attr("x1",i).attr("y1",o).attr("x2",a).attr("y2",s)):(r.select("line.highlight-x").attr("x1",i).attr("y1",o).attr("x2",a).attr("y2",s),r.select("line.highlight-y").attr("x1",i).attr("y1",o).attr("x2",a).attr("y2",s)),3===arguments.length?r.attr("transform","rotate("+n.val+","+n.x+","+n.y+")"):r.attr("transform",null)},disableAdd(){document.querySelector("#addElement").textContent="Insert element",d3.select("body").on("keyup.addMulti",null),d3.select("svg").on("click.add",null),d3.select("svg").on("contextmenu.add",null),d3.select("svg").on("contextmenu.general",d3.contextMenu(g)),d3.select("svg").on("mousemove",null),d3.select("svg > #diagram-connect > path").attr("d",null),d3.select("svg > #diagram-connect > circle").attr("transform","translate(0, 0)");let t=d3.select("svg > #diagram-connect > path").datum();if(void 0!==t){0===e.props.model.getDiagramObjects([t.obj]).length?e.props.model.deleteObject(t.obj):calcLineData(e.props.model,t.obj)}d3.select("svg > #diagram-connect > path").datum(null),e.highlight("x",null),e.highlight("y",null)},hover(e){let n=d3.select(e);n.filter("g:not(.ACLineSegment)").filter("g:not(."+t+")").filter("g:not(.Terminal)").each((function(e){d3.select(this).append("rect").attr("x",this.getBBox().x).attr("y",this.getBBox().y).attr("width",this.getBBox().width).attr("height",this.getBBox().height).attr("stroke","black").attr("stroke-width",2).attr("stroke-dasharray","5,5").attr("fill","none").attr("class","selection-rect")})),n.filter("g.ACLineSegment,g."+t).selectAll("g.resize").data((function(e){return e.lineData.map((t=>[e,t.seq]))})).enter().append("g").attr("class","resize").append("rect").attr("x",(function(e){return e[0].lineData.filter((t=>t.seq===e[1]))[0].x-2})).attr("y",(function(e){return e[0].lineData.filter((t=>t.seq===e[1]))[0].y-2})).attr("width",4).attr("height",4),n.filter("g.Terminal").each((function(e){let t=d3.select(this).select("circle");d3.select(this).append("circle").attr("cx",t.attr("cx")).attr("cy",t.attr("cy")).attr("r",8).attr("stroke-width",0).attr("fill","red").attr("fill-opacity","0.7").attr("class","selection-circle")}))},addNewMeasurement(n,r){e.deselectAll(),"cim:Terminal"!==r.nodeName&&(o.push(n),e.updateSelected());let i=null;if(i=!0===e.props.model.schema.isA("Switch",r)?e.props.model.createObject("cim:Discrete"):e.props.model.createObject("cim:Analog"),"cim:Terminal"===r.nodeName){let t=e.props.model.getTargets([r],"Terminal.ConductingEquipment")[0];e.props.model.setLink(i,"cim:Measurement.Terminal",r),e.props.model.setLink(i,"cim:Measurement.PowerSystemResource",t)}else if(r.nodeName==="cim:"+t){let t=e.props.model.getBusbar(r);null!==t&&e.props.model.setLink(i,"cim:Measurement.PowerSystemResource",t)}else e.props.model.setLink(i,"cim:Measurement.PowerSystemResource",r);e.props.model.addToActiveDiagram(i,[])},addNewLimitSet(n,r){e.deselectAll();let i=n,a=r;!0===e.props.model.schema.isA("TransformerEnd",d3.select(n).datum())&&(i=n.parentElement,a=d3.select(i).datum()),"cim:Terminal"!==a.nodeName&&(o.push(i),e.updateSelected());let s=e.props.model.createObject("cim:OperationalLimitSet");if("cim:Terminal"===a.nodeName){e.props.model.getTargets([a],"Terminal.ConductingEquipment")[0];e.props.model.setLink(s,"cim:OperationalLimitSet.Terminal",a)}else if(a.nodeName==="cim:"+t){let t=e.props.model.getBusbar(a);null!==t&&e.props.model.setLink(s,"cim:OperationalLimitSet.Equipment",t)}else e.props.model.setLink(s,"cim:OperationalLimitSet.Equipment",a);e.props.model.addToActiveDiagram(s,[])},addRegulatingControl(t,n){e.deselectAll();let r=e.props.model.createObject("cim:RegulatingControl");e.props.model.setLink(r,"cim:RegulatingControl.Terminal",n),e.props.model.addToActiveDiagram(r,[])},addTCControl(t,n){e.deselectAll();let r=e.props.model.createObject("cim:TapChangerControl");e.props.model.setLink(r,"cim:RegulatingControl.Terminal",n),e.props.model.addToActiveDiagram(r,[])},addTC(t,n){e.deselectAll();let r=n;if(!0===e.props.model.schema.isA("Terminal",n)&&(r=e.props.model.getTargets([n],"Terminal.TransformerEnd")[0]),0===e.props.model.getTargets([r],"TransformerEnd.RatioTapChanger").length){let t=e.props.model.createObject("cim:RatioTapChanger");e.props.model.setLink(t,"cim:RatioTapChanger.TransformerEnd",r),e.props.model.addToActiveDiagram(t,[])}},addContextMenu(e){e.filter("g:not(.ACLineSegment)").filter("g:not(."+t+")").filter("g:not(.PowerTransformer)").on("contextmenu",d3.contextMenu(c)),e.filter("g.ACLineSegment,g."+t).selectAll("path").on("contextmenu",(function(e,t){d3.contextMenu(u).bind(this.parentNode)(e,t),e.stopPropagation()})),e.filter("g:not(.PowerTransformer)").selectAll("g.Terminal").on("contextmenu",(function(e,t){d3.contextMenu(d).bind(this)(e,t),e.stopPropagation()})),e.filter("g.PowerTransformer").selectAll("g.Terminal").on("contextmenu",(function(e,t){d3.contextMenu(h).bind(this)(e,t),e.stopPropagation()})),e.filter("g.PowerTransformer").selectAll("g.TransformerEnd").on("contextmenu",(function(e,t){d3.contextMenu(p).bind(this)(e,t),e.stopPropagation()}))},deleteObject(t){let n=e.deleteSelection(t);e.props.model.deleteObjects(n.data())},deleteFromDiagram(t){let n=e.deleteSelection(t);for(let t of n.data())e.props.model.deleteFromDiagram(t)},deleteSelection(n){-1===o.indexOf(n)&&(e.deselectAll(),o.push(n));let r=d3.selectAll(o),i=e.props.model.getTerminals(r.data()),a=e.getLinkedCNs(i);for(let n of a){let r=e.props.model.ID(n.cn),i=d3.select("svg > g#diagram-main > g."+t+"s > g#cimdiagram-"+r).node();o.push(i)}return e.removeFromQuadtree(),r=d3.selectAll(o),disposePopovers(o),r.remove(),r}},template:function(e,t,n,r){return e('',[{redundantAttribute:"expr5",selector:"[expr5]",expressions:[{type:t.EVENT,name:"onclick",evaluate:function(e){return e.enableAddMulti}}]},{redundantAttribute:"expr6",selector:"[expr6]",expressions:[{type:t.EVENT,name:"onclick",evaluate:function(e){return e.enableAddMulti}}]},{redundantAttribute:"expr7",selector:"[expr7]",expressions:[{type:t.EVENT,name:"onclick",evaluate:function(e){return e.enableAdd}}]},{redundantAttribute:"expr8",selector:"[expr8]",expressions:[{type:t.EVENT,name:"onclick",evaluate:function(e){return e.enableAdd}}]},{redundantAttribute:"expr9",selector:"[expr9]",expressions:[{type:t.EVENT,name:"onclick",evaluate:function(e){return e.enableAdd}}]},{redundantAttribute:"expr10",selector:"[expr10]",expressions:[{type:t.EVENT,name:"onclick",evaluate:function(e){return e.enableAdd}}]},{redundantAttribute:"expr11",selector:"[expr11]",expressions:[{type:t.EVENT,name:"onclick",evaluate:function(e){return e.enableAdd}}]},{redundantAttribute:"expr12",selector:"[expr12]",expressions:[{type:t.EVENT,name:"onclick",evaluate:function(e){return e.enableAdd}}]},{redundantAttribute:"expr13",selector:"[expr13]",expressions:[{type:t.EVENT,name:"onclick",evaluate:function(e){return e.enableAdd}}]},{redundantAttribute:"expr14",selector:"[expr14]",expressions:[{type:t.EVENT,name:"onclick",evaluate:function(e){return e.enableAdd}}]},{redundantAttribute:"expr15",selector:"[expr15]",expressions:[{type:t.EVENT,name:"onclick",evaluate:function(e){return e.enableAdd}}]},{redundantAttribute:"expr16",selector:"[expr16]",expressions:[{type:t.EVENT,name:"onclick",evaluate:function(e){return e.enableAdd}}]},{redundantAttribute:"expr17",selector:"[expr17]",expressions:[{type:t.EVENT,name:"onclick",evaluate:function(e){return e.enableAdd}}]},{redundantAttribute:"expr18",selector:"[expr18]",expressions:[{type:t.EVENT,name:"onclick",evaluate:function(e){return e.enableAdd}}]},{redundantAttribute:"expr19",selector:"[expr19]",expressions:[{type:t.EVENT,name:"onclick",evaluate:function(e){return e.enableAdd}}]}])},name:"cimdiagramcontrols"}})),function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e=e||self).cimDraw=t()}(this,(function(){"use strict";let e=null;return{css:'cimdraw .center-block,[is="cimdraw"] .center-block{ text-align: center; } cimdraw nav.navbar,[is="cimdraw"] nav.navbar{ margin-bottom: 20px; } cimdraw .app-container,[is="cimdraw"] .app-container{ display: flex; flex-flow: row nowrap; } cimdraw .navbar-light .navbar-text,[is="cimdraw"] .navbar-light .navbar-text{ color: rgba(0,0,0,1); } cimdraw .navbar-light .navbar-nav .nav-link,[is="cimdraw"] .navbar-light .navbar-nav .nav-link{ color: rgba(0,0,0,1); } cimdraw .cim-content-center,[is="cimdraw"] .cim-content-center{ text-align: center; max-width: 700px; } cimdraw #upload-boundary,[is="cimdraw"] #upload-boundary{ display: none; }',exports:{onBeforeMount(t,n){e=this,e.state.cimModel=cimModel(),e.state.diagramsToLoad=2,e.state.dispatcher={},observable(e.state.dispatcher),e.state.cimModel.on("setMode",(function(e){document.getElementById("cim-mode").textContent="NODE_BREAKER"===e?"Mode: Operational":"Mode: Planning"}))},onMounted(){const t=new bootstrap.Modal(document.getElementById("cimModeModal")),n=new bootstrap.Modal(document.getElementById("loadingModal")),r=new bootstrap.Modal(document.getElementById("loadingFileModal")),i=new bootstrap.Modal(document.getElementById("boundaryModal")),o=new bootstrap.Modal(document.getElementById("newDiagramModal"));let a={},s=!1,l=window.location.pathname.substring(1);function c(t){u();const n=document.getElementById("cim-diagrams"),r=document.createElement("option");r.setAttribute("value","#"+t+"/createNew"),r.textContent="Generate a new diagram",n.appendChild(r);const i=e.state.cimModel.getDiagramList();for(let e in i){const r=document.createElement("option");r.setAttribute("value","#"+t+"/diagrams/"+i[e]),r.setAttribute("id",i[e]),r.textContent=i[e],n.appendChild(r)}0===i.length&&route.router.push(t+"/createNew")}function u(){const e=document.getElementById("cim-diagrams");for(;null!==e.firstChild;)e.removeChild(e.lastChild);const t=document.createElement("option");t.setAttribute("disabled","disabled"),t.setAttribute("selected","selected"),t.textContent="Select a diagram",e.appendChild(t)}-1===l.indexOf("index.html")&&(l+="index.html"),route.setBase(l+"#"),route.router.push(window.location.hash.replace("#","")),route.initDomListeners(),e.state.dispatcher.on("loaded",(function(){e.state.diagramsToLoad=e.state.diagramsToLoad-1,0===e.state.diagramsToLoad&&(n.hide(),document.getElementById("loadingDiagramMsg").textContent="loading diagram...",e.state.diagramsToLoad=2)})),document.getElementById("operational").addEventListener("change",(function(){e.state.cimModel.setMode("NODE_BREAKER")})),document.getElementById("planning").addEventListener("change",(function(){e.state.cimModel.setMode("BUS_BRANCH")})),document.getElementById("cim-create-new-container").addEventListener("click",(function(){a={name:"new1"},s=!0,t.show()})),document.getElementById("cim-file-modal-error").addEventListener("click",(function(){r.hide(),route.router.push("")})),document.getElementById("cim-boundary-modal-error").addEventListener("click",(function(){i.hide(),document.getElementById("boundaryMsg").textContent="loading boundary file..."})),document.getElementById("cim-create-new-modal").addEventListener("click",(function(){route.router.push(a.name+"/diagrams")})),document.getElementById("load-boundary").addEventListener("click",(function(){return document.getElementById("upload-boundary").click(),!1})),document.getElementById("upload-boundary").addEventListener("change",(function(){const t=this.files[0];function n(){e.state.cimModel.loadBoundary(t).then((function(e){const t=document.createElement("br");document.getElementById("boundaryMsg").append(t,"OK. "+e),document.getElementById("cim-boundary-modal-error-container").style.display=null})).catch((function(e){const t=document.createElement("br");document.getElementById("boundaryMsg").append(t,e),document.getElementById("cim-boundary-modal-error-container").style.display=null}))}document.getElementById("boundaryModal").removeEventListener("shown.bs.modal",n),document.getElementById("boundaryModal").addEventListener("shown.bs.modal",n),i.show()})),document.getElementById("cim-save").addEventListener("click",(function(t){const n=e.state.cimModel.save(),r=new Blob([n],{type:"text/xml"}),i=URL.createObjectURL(r);t.currentTarget.setAttribute("href",i)})),document.getElementById("cgmes-save").addEventListener("click",(function(t){e.state.cimModel.saveAsCGMES().then((function(e){const t=URL.createObjectURL(e);document.getElementById("cgmes-download").setAttribute("href",t),document.getElementById("cgmes-download").click()})).catch((function(e){console.log(e)}))})),document.getElementById("cim-export").addEventListener("click",(function(t){const n=e.state.cimModel.export(),r=new Blob([n],{type:"text/xml"}),i=URL.createObjectURL(r);t.currentTarget.setAttribute("href",i)})),document.getElementById("matpower-export").addEventListener("click",(function(t){const n=exportToMatpower(e.state.cimModel),r=new Blob([n],{type:"text/plain"}),i=URL.createObjectURL(r);t.currentTarget.setAttribute("href",i)})),document.getElementById("newDiagramBtn").addEventListener("click",(function(e){const t=document.getElementById("newDiagramName").value,n=window.location.hash.substring(1).split("/")[0]+"/diagrams/"+t;o.hide(),route.router.push(n)})),document.getElementById("loadingFileModal").addEventListener("shown.bs.modal",(function(t){if(void 0===a.name)return r.hide(),void route.router.push("");{document.getElementById("cim-filename").innerHTML="["+a.name+"]  ";let t=null;t=!1===s?e.state.cimModel.load(a):e.state.cimModel.newFile(a.name),t.then((function(){c(a.name),r.hide(),"new1"!==a.name&&function(){const t=e.state.cimModel.getObjects(["cim:ConnectivityNode","cim:TopologicalNode"]);let n=t["cim:ConnectivityNode"];const r=t["cim:TopologicalNode"];n=n.filter((function(t){return!1===e.state.cimModel.isBoundary(t)})),n.length>0||0===r.length?e.state.cimModel.setMode("NODE_BREAKER"):e.state.cimModel.setMode("BUS_BRANCH")}()})).catch((function(e){const t=document.createElement("br");document.getElementById("loadingFileMsg").append(t,e),document.getElementById("cim-file-modal-error-container").style.display=null}))}})),route.route("").on.value((function(e){document.getElementById("cim-local-file-component").style.display=null,document.getElementById("app-container").style.display="none",document.getElementById("cim-load-container").style.display="none",document.getElementById("cim-home-container").style.display="none",document.getElementById("cim-diagrams").style.display="none",document.getElementById("cim-mode").style.display="none",document.getElementById("cim-file-modal-error-container").style.display="none",document.getElementById("cim-boundary-modal-error-container").style.display="none",u(),document.getElementById("cim-filename").textContent="";document.getElementById("cim-file-input").addEventListener("change",(function(){a=this.files[0],s=!1;const e="#"+encodeURI(a.name)+"/diagrams";document.getElementById("cim-load").setAttribute("href",e),document.getElementById("cim-load-container").style.display=null}))})),route.route(":file/diagrams").on.value((function(n){document.getElementById("cim-home-container").style.display=null,document.getElementById("cim-diagrams").style.display=null,document.getElementById("cim-mode").style.display=null,document.getElementById("cim-local-file-component").style.display="none",document.getElementById("app-container").style.display="none",document.getElementById("cim-export").parentNode.classList.add("disabled"),t.hide();const i=document.getElementById("cim-filename").textContent;a.name!==i?(document.getElementById("loadingFileMsg").textContent="loading CIM network...",r.show(),e.state.dispatcher.trigger("diagrams")):c(a.name)})),route.route(":file/diagrams/:name").on.value((function(t){const r=t.params.file,i=t.params.name;if(void 0!==a.name){if(e.state.cimModel.activeDiagramName===decodeURI(i))return e.state.dispatcher.trigger("showDiagram",r,i),void(document.getElementById("app-container").style.display=null);document.getElementById("cim-local-file-component").style.display="none",document.getElementById("loadingDiagramMsg").textContent="loading diagram...",document.getElementById("loadingModal").addEventListener("shown.bs.modal",(function t(n){!function(t,n,r){e.state.cimModel.selectDiagram(decodeURI(n)),c(decodeURI(t)),document.getElementById(decodeURI(n)).setAttribute("selected",!0),document.getElementById("app-container").style.display=null,document.getElementById("cim-export").parentNode.classList.remove("disabled"),e.state.dispatcher.trigger("showDiagram",t,n,r)}(r,i),document.getElementById("loadingModal").removeEventListener("shown.bs.modal",t)})),n.show()}else route.router.push("")})),route.route(":file/diagrams/:name/:element").on.value((function(t){const n=t.params.file,r=t.params.name,i=t.params.element;document.getElementById("cim-local-file-component").style.display="none",e.state.dispatcher.trigger("showDiagram",n,r,i)})),route.route(":file/createNew").on.value((function(e){window.history.back(),o.show()}))}},template:function(e,t,n,r){return e('


              ',[{type:n.TAG,getComponent:r,evaluate:function(e){return"cimtopologyprocessor"},slots:[],attributes:[{type:t.ATTRIBUTE,name:"model",evaluate:function(e){return e.state.cimModel}},{type:t.ATTRIBUTE,name:"dispatcher",evaluate:function(e){return e.state.dispatcher}}],redundantAttribute:"expr2",selector:"[expr2]"},{type:n.TAG,getComponent:r,evaluate:function(e){return"cimtree"},slots:[],attributes:[{type:t.ATTRIBUTE,name:"model",evaluate:function(e){return e.state.cimModel}},{type:t.ATTRIBUTE,name:"dispatcher",evaluate:function(e){return e.state.dispatcher}}],redundantAttribute:"expr3",selector:"[expr3]"},{type:n.TAG,getComponent:r,evaluate:function(e){return"cimdiagram"},slots:[],attributes:[{type:t.ATTRIBUTE,name:"model",evaluate:function(e){return e.state.cimModel}},{type:t.ATTRIBUTE,name:"dispatcher",evaluate:function(e){return e.state.dispatcher}}],redundantAttribute:"expr4",selector:"[expr4]"}])},name:"cimdraw"}})),function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e=e||self).cimTopologyProcessor=t()}(this,(function(){"use strict";let e=null;return{css:'cimtopologyprocessor #cim-topology-processor,[is="cimtopologyprocessor"] #cim-topology-processor{ display: none }',exports:{onBeforeMount(t,n){e=this,t.dispatcher.on("diagrams",(function(){document.querySelector("#cim-topology-processor").style.display="flex"}))},run(t){const n=document.querySelector("#tpMsg"),r=document.getElementById("tpStatusModal"),i=new bootstrap.Modal(r);n.textContent="Loading...",i.show(),r.addEventListener("shown.bs.modal",(function(t){let r=topologyProcessor(e.props.model).calcTopology();n.textContent="Done ("+r.length+" nodes calculated)."}))}},template:function(e,t,n,r){return e('',[{redundantAttribute:"expr1",selector:"[expr1]",expressions:[{type:t.EVENT,name:"onclick",evaluate:function(e){return e.run}}]}])},name:"cimtopologyprocessor"}})),function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e=e||self).cimTree=t()}(this,(function(){"use strict";let e=null,t=d3.contextMenu([{title:"Delete",action:function(t,n){e.props.model.deleteObject(n)}}]),n=null;return{css:'cimtree .tree,[is="cimtree"] .tree{ display: flex; flex-flow: column; max-height: 800px; min-width: 500px; resize: horizontal; padding-top: 10px; overflow: auto; } cimtree .tab-content,[is="cimtree"] .tab-content{ overflow: scroll; } cimtree .cim-tree-attribute-name,[is="cimtree"] .cim-tree-attribute-name{ text-align: left; min-width: 200px; } cimtree .cim-tree-attribute-uom,[is="cimtree"] .cim-tree-attribute-uom{ width: 70px; } cimtree .cim-tree-btn-group,[is="cimtree"] .cim-tree-btn-group{ flex-grow: 1; } cimtree .cim-tree-dropdown-toggle,[is="cimtree"] .cim-tree-dropdown-toggle{ flex-grow: 1; } cimtree ul,[is="cimtree"] ul{ list-style-type: none; } cimtree #tree-link-dialog,[is="cimtree"] #tree-link-dialog{ max-width: 18rem; align-self: center; min-width: 90%; min-height: min-content; } cimtree #tree-link-dialog > .card-body,[is="cimtree"] #tree-link-dialog > .card-body{ text-align: center; } cimtree #tree-controls,[is="cimtree"] #tree-controls{ padding-bottom: 10px; align-self: center; flex-shrink: 0; width: 370px; } cimtree #cim-search-form,[is="cimtree"] #cim-search-form{ align-self: center; max-width: 600px; padding-right: 20px; padding-left: 20px; padding-bottom: 20px; } cimtree .list-group-item > div,[is="cimtree"] .list-group-item > div{ width: 100%; } cimtree .cim-tree-btn-group > .cimLinkBtn,[is="cimtree"] .cim-tree-btn-group > .cimLinkBtn{ flex-grow: 1; } cimtree .tree > .nav-tabs,[is="cimtree"] .tree > .nav-tabs{ flex-shrink: 0; } cimtree .cim-expand-object,[is="cimtree"] .cim-expand-object{ border: transparent; } cimtree .cim-expand-object:focus,[is="cimtree"] .cim-expand-object:focus{ box-shadow: initial; } cimtree .cim-expand-object:hover,[is="cimtree"] .cim-expand-object:hover{ color: #6c757d; background-color: transparent; } cimtree li.attribute > .input-group,[is="cimtree"] li.attribute > .input-group{ flex-wrap: nowrap }',exports:{onBeforeMount(t,n){e=this,e.state.mode="default",t.dispatcher.on("showDiagram",(function(t,n,r){decodeURI(n)!==e.state.diagramName&&(d3.drag().on("drag.end",null),e.render(n)),void 0!==r?e.moveTo(r):d3.select(".tree").selectAll(".btn-danger").classed("btn-danger",!1).classed("btn-primary",!0)}))},onMounted(){[].slice.call(document.querySelectorAll("#cim-tree-tabs a")).forEach((function(e){const t=new bootstrap.Tab(e);e.addEventListener("click",(function(e){e.preventDefault(),t.show()}))})),document.getElementById("cim-search-key").addEventListener("keyup",(function(t){if("Enter"===t.key){let t=document.getElementById("cim-search-case").classList.contains("active"),r=document.getElementById("cim-search-key").value;if(""===r)document.getElementById("cim-search-results").classList.add("d-none"),n=null;else{let i=[];document.getElementById("app-tree").querySelectorAll("ul:not(.CIM-object-list)").forEach((function(e){let n=null;n=!0===t?Array.prototype.filter.call(e.querySelectorAll("li.CIM-object>button.cim-object-btn"),(function(e){return e.textContent.indexOf(r)>=0})):Array.prototype.filter.call(e.querySelectorAll("li.CIM-object>button.cim-object-btn"),(function(e){let t=r.toLocaleLowerCase();return e.textContent.toLocaleLowerCase().indexOf(t)>=0})),i=i.concat(n)})),i=[...new Set(i)],document.getElementById("cim-search-results").classList.remove("d-none"),i.length>0?(document.querySelector("#cim-search-results").textContent="Result 1 of "+i.length,n={elements:d3.selectAll(i).data(),actualResult:0},e.moveTo(e.props.model.ID(n.elements[n.actualResult]))):document.querySelector("#cim-search-results").textContent="Text not found"}}})),document.getElementById("cim-search-next").addEventListener("click",(function(){if(null!==n&&n.actualResult0){n.actualResult=n.actualResult-1;let t=n.actualResult+1;document.querySelector("#cim-search-results").textContent="Result "+t+" of "+n.elements.length,e.moveTo(e.props.model.ID(n.elements[n.actualResult]))}})),document.getElementById("showAllObjects").addEventListener("change",(function(){e.createTree(this.checked)})),document.getElementById("sshInput").addEventListener("change",(function(){e.resetAttrs()})),document.querySelectorAll('a[data-bs-toggle="tab"]').forEach((t=>t.addEventListener("click",(function(t){e.goToBasePath()})))),e.props.model.on("addToActiveDiagram",(function(t){e.addNewObject(t)})),e.props.model.on("deleteObject",(function(t,n){e.deleteObject(t)})),e.props.model.on("deleteFromDiagram",(function(t){!1===document.getElementById("showAllObjects").checked&&e.deleteObject(t)})),e.props.model.on("setAttribute",(function(t,n,r){if("cim:IdentifiedObject.name"===n){t.localName;let n=d3.select("div.tree").selectAll("ul#"+e.props.model.ID(t));if(!1===n.empty()){d3.select(n.node().parentNode).select("button").html(r)}document.querySelectorAll('[cim-target="'+e.props.model.ID(t)+'"]').innerHTML=r}})),e.props.model.on("addLink",(function(t,n,r){let i=e.props.model.ID(t),o=d3.select(".tree").select("#"+i),a=o.selectAll("#cimRemoveBtn").filter((function(e){return e.attributes[0].value==="#"+n.split(":")[1]}));o.selectAll(".cimLinkBtn").filter((function(e){return e.attributes[0].value==="#"+n.split(":")[1]})).html((function(){return e.props.model.getAttribute(r,"cim:IdentifiedObject.name").textContent})).attr("cim-target",(function(){return e.props.model.ID(r)})).attr("disabled",null),o.selectAll("#cimTarget").attr("id",null),a.attr("disabled",null),"BUS_BRANCH"===e.props.model.getMode()&&"cim:BusbarSection"===t.nodeName&&"cim:ConductingEquipment.BaseVoltage"===n&&e.props.model.setLink(e.props.model.getNode(t),"cim:TopologicalNode.BaseVoltage",r)})),e.props.model.on("removeLink",(function(t,n,r){let i=e.props.model.ID(t),o=d3.select(".tree").select("#"+i),a=o.selectAll("#cimRemoveBtn").filter((function(e){return e.attributes[0].value==="#"+n.split(":")[1]})),s=o.selectAll(".cimLinkBtn").filter((function(e){return e.attributes[0].value==="#"+n.split(":")[1]}));a.attr("disabled","disabled"),s.html("none").attr("cim-target","none").attr("disabled","disabled")})),e.props.model.on("createdDiagram",(function(){e.state.diagramName=decodeURI(e.props.model.activeDiagramName),document.getElementById("showAllObjects").checked=!1,document.getElementById("showAllObjects").dispatchEvent(new MouseEvent("click"))})),e.props.model.on("setMode",(function(t){"BUS_BRANCH"===e.state.mode&&(document.getElementById("measurementsTab").style.display=null)}))},goToBasePath(){let e=window.location.hash.substring(1).split("/");if(e.length>3){let t=e[0]+"/"+e[1]+"/"+e[2];route.router.push(t)}},addNewObject(t){let n=d3.select("div.tree > div.tab-content > div.tab-pane > ul#CIMComponents"),r=d3.select("div.tree > div.tab-content > div.tab-pane > ul#CIMContainers"),i=d3.select("div.tree > div.tab-content > div.tab-pane > ul#CIMMeasurements"),o=d3.select("div.tree > div.tab-content > div.tab-pane > ul#CIMBases"),a=d3.select("div.tree > div.tab-content > div.tab-pane > ul#CIMCurvesAndRegs"),s=d3.select("div.tree > div.tab-content > div.tab-pane > ul#CIMLimits"),l=void 0,c=void 0,u=void 0,f=void 0,d=void 0;switch(t.nodeName){case"cim:ACLineSegment":e.elements(n,"ACLineSegment","AC Line Segments",[t]);break;case"cim:Breaker":e.elements(n,"Breaker","Breakers",[t]);break;case"cim:Disconnector":e.elements(n,"Disconnector","Disconnectors",[t]);break;case"cim:LoadBreakSwitch":e.elements(n,"LoadBreakSwitch","Load Break Switches",[t]);break;case"cim:Junction":e.elements(n,"Junction","Junctions",[t]);break;case"cim:EnergySource":l=e.createTopContainer(n,"Equivalent","Equivalents",[t]),e.elements(l,"EnergySource","Energy Sources",[t]);break;case"cim:SynchronousMachine":c=e.createTopContainer(n,"RotatingMachine","RotatingMachines",[t]),e.elements(c,"SynchronousMachine","Synchronous Machines",[t]);break;case"cim:AsynchronousMachine":c=e.createTopContainer(n,"RotatingMachine","RotatingMachines",[t]),e.elements(c,"AsynchronousMachine","Asynchronous Machines",[t]);break;case"cim:EnergyConsumer":u=e.createTopContainer(n,"Load","Loads",[t]),e.elements(u,"EnergyConsumer","Energy Consumers",[t]);break;case"cim:ConformLoad":u=e.createTopContainer(n,"Load","Loads",[t]),e.elements(u,"ConformLoad","Conform Loads",[t]);break;case"cim:NonConformLoad":u=e.createTopContainer(n,"Load","Loads",[t]),e.elements(u,"NonConformLoad","Non Conform Loads",[t]);break;case"cim:LinearShuntCompensator":f=e.createTopContainer(n,"Compensator","Compensators",[t]),e.elements(f,"LinearShuntCompensator","Linear",[t]);break;case"cim:NonlinearShuntCompensator":f=e.createTopContainer(n,"Compensator","Compensators",[t]),e.nlCompensators(f,[t]);break;case"cim:NonlinearShuntCompensatorPoint":let h=e.props.model.getTargets([t],"NonlinearShuntCompensatorPoint.NonlinearShuntCompensator"),p=e.props.model.ID(h[0]),m=n.selectAll("ul#"+p);e.nlCompensatorPoints(m,[t]);break;case"cim:PowerTransformer":e.powerTransformers(n,[t]);break;case"cim:RatioTapChanger":let g=e.props.model.getTargets([t],"RatioTapChanger.TransformerEnd"),b=e.props.model.ID(g[0]),v=n.selectAll("ul#"+b);e.tapChangers(v,[t]);break;case"cim:BusbarSection":e.elements(n,"BusbarSection","Nodes",[t]);break;case"cim:BaseVoltage":let y=e.elements(o,"BaseVoltage","Base Voltages",[t]);e.createDeleteMenu(y);break;case"cim:GeographicalRegion":e.geoRegions(r,[t]);break;case"cim:SubGeographicalRegion":let _=e.props.model.getTargets([t],"SubGeographicalRegion.Region"),w=e.props.model.ID(_[0]),x=r.selectAll("ul#"+w);e.subGeoRegions(x,[t]);break;case"cim:Substation":e.substations(r,[t]);break;case"cim:VoltageLevel":let T=e.props.model.getTargets([t],"VoltageLevel.Substation"),A=e.props.model.ID(T[0]),E=r.selectAll("ul#"+A);e.voltageLevels(E,[t]);break;case"cim:Bay":let k=e.props.model.getTargets([t],"Bay.VoltageLevel"),S=e.props.model.ID(k[0]),M=r.selectAll("ul#"+S);e.bays(M,[t]);break;case"cim:Line":let C=e.elements(r,"Line","Lines",[t]);e.createDeleteMenu(C);break;case"cim:GeneratingUnit":d=e.createTopContainer(r,"GeneralGeneratingUnit","Generating Units",[t]),e.elements(d,"GeneratingUnit","General Units",[t]);break;case"cim:ThermalGeneratingUnit":d=e.createTopContainer(r,"GeneralGeneratingUnit","Generating Units",[t]),e.elements(d,"ThermalGeneratingUnit","Thermal Units",[t]);break;case"cim:Analog":let N=e.elements(i,"Analog","Analogs",[t]);e.createDeleteMenu(N);break;case"cim:Discrete":let D=e.elements(i,"Discrete","Discretes",[t]);e.createDeleteMenu(D);break;case"cim:LoadResponseCharacteristic":let L=e.elements(a,"LoadResponseCharacteristic","Load Response Characteristics",[t]);e.createDeleteMenu(L);break;case"cim:TapChangerControl":let O=e.elements(a,"TapChangerControl","Tap Changer Controls",[t]);e.createDeleteMenu(O);break;case"cim:RegulatingControl":let I=e.elements(a,"RegulatingControl","Regulating Controls",[t]);e.createDeleteMenu(I);break;case"cim:OperationalLimitType":let B=e.elements(s,"OperationalLimitType","Operational Limit Types",[t]);e.createDeleteMenu(B);case"cim:OperationalLimitSet":e.limitSets(s,[t]);break;case"cim:VoltageLimit":case"cim:CurrentLimit":case"cim:ActivePowerLimit":case"cim:ApparentPowerLimit":let P=e.props.model.getTargets([t],"OperationalLimit.OperationalLimitSet"),j=e.props.model.ID(P[0]),R=s.selectAll("ul#"+j);e.limits(R,[t])}},createTree(t){let n=function*(t){d3.select("#app-tree").selectAll("#CIMComponents > li").remove(),d3.select("#app-tree").selectAll("#CIMContainers > li").remove(),d3.select("#app-tree").selectAll("#CIMMeasurements > li").remove(),d3.select("#app-tree").selectAll("#CIMBases > li").remove(),d3.select("#app-tree").selectAll("#CIMCurvesAndRegs > li").remove(),d3.select("#app-tree").selectAll("#CIMLimits > li").remove();let n=d3.select("div.tree > div.tab-content > div.tab-pane > ul#CIMComponents"),r=d3.select("div.tree > div.tab-content > div.tab-pane > ul#CIMContainers"),i=d3.select("div.tree > div.tab-content > div.tab-pane > ul#CIMMeasurements"),o=d3.select("div.tree > div.tab-content > div.tab-pane > ul#CIMBases"),a=d3.select("div.tree > div.tab-content > div.tab-pane > ul#CIMCurvesAndRegs"),s=d3.select("div.tree > div.tab-content > div.tab-pane > ul#CIMLimits"),l=["cim:Substation","cim:Line"],c=["cim:Analog","cim:Discrete"],u=["cim:GeneratingUnit","cim:ThermalGeneratingUnit"],f=null,d=null,h=null,p=null,m=null,g=null,b=null,v=e.props.model.getObjects,y=e.props.model.getObjects;!1===t&&(v=e.props.model.getGraphicObjects,y=e.props.model.getConnectors);if("BUS_BRANCH"===e.props.model.getMode()){let t=e.props.model.getObjects(["cim:BusbarSection","cim:TopologicalNode"]);0===t["cim:BusbarSection"].length&&t["cim:TopologicalNode"].forEach((function(t){let n=e.props.model.createObject("cim:BusbarSection",{node:t}),r=e.props.model.getAttribute(t,"cim:IdentifiedObject.name");void 0!==r&&e.props.model.setAttribute(n,"cim:IdentifiedObject.name",r.innerHTML)}))}let _=v(["cim:BusbarSection","cim:PowerTransformer","cim:ACLineSegment","cim:Breaker","cim:Disconnector","cim:LoadBreakSwitch","cim:Junction","cim:EnergySource","cim:EquivalentInjection","cim:SynchronousMachine","cim:AsynchronousMachine","cim:EnergyConsumer","cim:ConformLoad","cim:NonConformLoad","cim:LinearShuntCompensator","cim:NonlinearShuntCompensator"]);yield"TREE: extracted equipments",p=v(["cim:SubGeographicalRegion"])["cim:SubGeographicalRegion"],m=v(["cim:GeographicalRegion"])["cim:GeographicalRegion"],!1===t?(f=e.props.model.getLinkedObjects(l,["EquipmentContainer.Equipments","Substation.VoltageLevels/EquipmentContainer.Equipments","Substation.VoltageLevels/VoltageLevel.Bays/EquipmentContainer.Equipments"]),d=e.props.model.getLinkedObjects(c,["Measurement.PowerSystemResource"]),h=e.props.model.getLinkedObjects(u,["GeneratingUnit.RotatingMachine"]),p=p.concat(e.props.model.getTargets(f["cim:Substation"],"Substation.Region")),m=m.concat(e.props.model.getTargets(p,"SubGeographicalRegion.Region")),p=[...new Set(p)],m=[...new Set(m)],g=e.props.model.getLinkedObjects(["cim:LoadResponseCharacteristic"],["LoadResponseCharacteristic.EnergyConsumer"]),b=e.props.model.getLinkedObjects(["cim:OperationalLimitSet"],["OperationalLimitSet.Equipment","OperationalLimitSet.Terminal/Terminal.ConductingEquipment"])):(f=v(l),d=v(c),h=v(u),g=v(["cim:LoadResponseCharacteristic"]),b=v(["cim:OperationalLimitSet"]));let w=e.props.model.getObjects(["cim:BaseVoltage","cim:TapChangerControl","cim:RegulatingControl","cim:OperationalLimitType"]),x=y(["cim:BusbarSection"])["cim:BusbarSection"],T=_["cim:EnergySource"].concat(_["cim:EquivalentInjection"]),A=_["cim:SynchronousMachine"].concat(_["cim:AsynchronousMachine"]),E=_["cim:EnergyConsumer"].concat(_["cim:ConformLoad"]).concat(_["cim:NonConformLoad"]),k=_["cim:LinearShuntCompensator"].concat(_["cim:nonlinearShuntCompensator"]),S=e.elements(i,"Analog","Analogs",d["cim:Analog"]);e.createDeleteMenu(S);let M=e.elements(i,"Discrete","Discretes",d["cim:Discrete"]);e.createDeleteMenu(M);let C=e.elements(o,"BaseVoltage","Base Voltages",w["cim:BaseVoltage"]);e.createDeleteMenu(C),e.elements(n,"ACLineSegment","AC Line Segments",_["cim:ACLineSegment"]),e.elements(n,"Breaker","Breakers",_["cim:Breaker"]),e.elements(n,"Disconnector","Disconnectors",_["cim:Disconnector"]),e.elements(n,"LoadBreakSwitch","Load Break Switches",_["cim:LoadBreakSwitch"]),e.elements(n,"Junction","Junctions",_["cim:Junction"]);let N=e.createTopContainer(n,"Equivalent","Equivalents",T);e.elements(N,"EnergySource","Energy Sources",_["cim:EnergySource"]),e.elements(N,"EquivalentInjection","Equivalent Injections",_["cim:EquivalentInjection"]);let D=e.createTopContainer(n,"RotatingMachine","Rotating Machines",A);e.elements(D,"SynchronousMachine","Synchronous Machines",_["cim:SynchronousMachine"]),e.elements(D,"AsynchronousMachine","Asynchronous Machines",_["cim:AsynchronousMachine"]);let L=e.createTopContainer(n,"Load","Loads",E);e.elements(L,"EnergyConsumer","Energy Consumers",_["cim:EnergyConsumer"]),e.elements(L,"ConformLoad","Conform Loads",_["cim:ConformLoad"]),e.elements(L,"NonConformLoad","Non Conform Loads",_["cim:NonConformLoad"]);let O=e.createTopContainer(n,"Compensator","Compensators",k);e.elements(O,"LinearShuntCompensator","Linear",_["cim:LinearShuntCompensator"]),e.nlCompensators(O,_["cim:NonlinearShuntCompensator"]),e.elements(n,"BusbarSection","Nodes",x),e.powerTransformers(n,_["cim:PowerTransformer"]),e.geoRegions(r,m),e.substations(r,f["cim:Substation"]);let I=e.elements(r,"Line","Lines",f["cim:Line"]);e.createDeleteMenu(I);let B=e.createTopContainer(r,"GeneralGeneratingUnit","Generating Units",h["cim:GeneratingUnit"].concat(h["cim:ThermalGeneratingUnit"]));e.elements(B,"GeneratingUnit","General Units",h["cim:GeneratingUnit"]),e.elements(B,"ThermalGeneratingUnit","Thermal Units",h["cim:ThermalGeneratingUnit"]),e.elements(a,"LoadResponseCharacteristic","Load Response Characteristics",g["cim:LoadResponseCharacteristic"]);let P=e.elements(a,"TapChangerControl","Tap Changer Controls",w["cim:TapChangerControl"]);e.createDeleteMenu(P);let j=e.elements(a,"RegulatingControl","Regulating Controls",w["cim:RegulatingControl"]);e.createDeleteMenu(j);let R=e.elements(s,"OperationalLimitType","Operational Limit Types",w["cim:OperationalLimitType"]);e.createDeleteMenu(R),e.limitSets(s,b["cim:OperationalLimitSet"]),e.createAddButton(o,"BaseVoltage"),e.createAddButton(r,"Substation"),e.createAddButton(r,"GeographicalRegion"),e.createAddButton(r,"Line"),e.createAddButton(r,"GeneratingUnit"),e.createAddButton(r,"ThermalGeneratingUnit"),e.createAddButton(a,"LoadResponseCharacteristic"),e.createAddButton(s,"OperationalLimitType")}(t);!function t(){let r=n.next().value;void 0!==r?(document.getElementById("loadingDiagramMsg").innerHTML="
              "+r,setTimeout(t,1)):e.props.dispatcher.trigger("loaded")}()},render(t){e.props.model.selectDiagram(decodeURI(t)),e.state.diagramName=decodeURI(t),document.getElementById("showAllObjects").checked=!0,document.getElementById("showAllObjects").dispatchEvent(new MouseEvent("click"))},geoRegions(t,n){let r=e.elements(t,"GeographicalRegion","Geographical Regions",n);r.each((function(t,n){let r=e.props.model.getTargets([t],"GeographicalRegion.Regions");e.subGeoRegions(d3.select(this),r),e.subAddButton(d3.select(this),"SubGeographicalRegion","cim:SubGeographicalRegion.Region")})),e.createDeleteMenu(r)},subGeoRegions(t,n){let r=t.data()[0],i=e.elements(t,e.props.model.ID(r)+"SubGeographicalRegion","Sub-Geographical Regions",n);e.createDeleteMenu(i)},substations(t,n){let r=e.elements(t,"Substation","Substations",n);r.each((function(t,n){let r=e.props.model.getTargets([t],"Substation.VoltageLevels");e.voltageLevels(d3.select(this),r),e.subAddButton(d3.select(this),"VoltageLevel","cim:VoltageLevel.Substation")})),e.createDeleteMenu(r)},voltageLevels(t,n){let r=t.data()[0],i=e.elements(t,e.props.model.ID(r)+"VoltageLevel","Voltage Levels",n);i.each((function(t,n){let r=e.props.model.getTargets([t],"VoltageLevel.Bays");e.bays(d3.select(this),r),e.subAddButton(d3.select(this),"Bay","cim:Bay.VoltageLevel")})),e.createDeleteMenu(i)},bays(t,n){let r=t.data()[0],i=e.elements(t,e.props.model.ID(r)+"Bay","Bays",n);e.createDeleteMenu(i)},powerTransformers(t,n){e.elements(t,"PowerTransformer","Transformers",n).each((function(t,n){let r=e.props.model.getTargets([t],"PowerTransformer.PowerTransformerEnd"),i=e.elements(d3.select(this),e.props.model.ID(t)+"PowerTransformerEnd","Transformer Windings",r);for(const e of i.nodes())e.parentNode.classList.add("CIM-subobject");i.each((function(t,n){let r=e.props.model.getTargets([t],"TransformerEnd.RatioTapChanger");e.tapChangers(d3.select(this),r)}))}))},nlCompensators(t,n){e.elements(t,"NonlinearShuntCompensator","Nonlinear",n).each((function(t,n){let r=e.props.model.getTargets([t],"NonlinearShuntCompensator.NonlinearShuntCompensatorPoints");e.nlCompensatorPoints(d3.select(this),r),e.subAddButton(d3.select(this),"NonlinearShuntCompensatorPoint","cim:NonlinearShuntCompensatorPoint.NonlinearShuntCompensator")}))},nlCompensatorPoints(t,n){let r=t.data()[0],i=e.elements(t,e.props.model.ID(r)+"NonlinearShuntCompensatorPoint","Points",n,!0);for(const e of i.nodes())e.parentNode.classList.add("CIM-subobject");e.createDeleteMenu(i)},tapChangers(t,n){let r=t.data()[0],i=e.elements(t,e.props.model.ID(r)+"RatioTapChanger","Ratio Tap Changer",n);for(const e of i.nodes())e.parentNode.classList.add("CIM-subobject");e.createDeleteMenu(i)},limitSets(t,n){let r=e.elements(t,"OperationalLimitSet","Operational Limit Sets",n);r.each((function(t,n){let r=e.props.model.getTargets([t],"OperationalLimitSet.OperationalLimitValue");e.limits(d3.select(this),r),e.subAddButton(d3.select(this),"VoltageLimit","cim:OperationalLimit.OperationalLimitSet"),e.subAddButton(d3.select(this),"CurrentLimit","cim:OperationalLimit.OperationalLimitSet"),e.subAddButton(d3.select(this),"ActivePowerLimit","cim:OperationalLimit.OperationalLimitSet"),e.subAddButton(d3.select(this),"ApparentPowerLimit","cim:OperationalLimit.OperationalLimitSet")})),e.createDeleteMenu(r)},limits(t,n){let r=t.data()[0],i=n.filter((t=>e.props.model.schema.isA("VoltageLimit",t))),o=n.filter((t=>e.props.model.schema.isA("CurrentLimit",t))),a=n.filter((t=>e.props.model.schema.isA("ActivePowerLimit",t))),s=n.filter((t=>e.props.model.schema.isA("ApparentPowerLimit",t))),l=e.elements(t,e.props.model.ID(r)+"VoltageLimit","Voltage limits",i),c=e.elements(t,e.props.model.ID(r)+"CurrentLimit","Current limits",o),u=e.elements(t,e.props.model.ID(r)+"ActivePowerLimit","Active power limits",a),f=e.elements(t,e.props.model.ID(r)+"ApparentPowerLimit","Apparent power limits",s);e.createDeleteMenu(l),e.createDeleteMenu(c),e.createDeleteMenu(u),e.createDeleteMenu(f)},createTopContainer(t,n,r,i){let o=t.select("li."+n+"s"),a=o.select("ul#"+n+"sList");if(o.empty()){o=t.append("li").attr("class",n+"s list-group-item d-flex justify-content-between cim-parent-container");let i=o.append("div");i.append("a").attr("class","btn btn-primary btn-sm").attr("role","button").attr("data-bs-toggle","collapse").attr("href","#"+n+"sList").html(r),o.append("h4").append("span").attr("class","badge bg-primary rounded-pill").html(0),a=i.append("ul").attr("id",n+"sList").attr("class","collapse"),o.on("click",(function(t){t.target===this&&e.goToBasePath()}))}return a},createAddButton(t,n){let r=t.select("li."+n+"s"),i=r.select("ul#"+n+"sList"),o=r.select("ul#"+n+"sList > button.cim-add-btn");!0===o.empty()&&(o=i.insert("li",":first-child").append("button").attr("class","btn btn-default btn-sm cim-add-btn").attr("type","submit"),o.html(' Add'),o.on("click.add",(function(){let t=e.props.model.createObject("cim:"+n);e.props.model.addToActiveDiagram(t,[])})))},subAddButton(t,n,r){let i=t.data()[0],o=e.props.model.ID(i)+n,a=t.select("li."+o+"s"),s=a.select("ul#"+o+"sList"),l=a.select("ul#"+o+"sList > button.cim-add-btn");!0===l.empty()&&(l=s.insert("li",":first-child").append("button").attr("class","btn btn-default btn-sm cim-add-btn").attr("type","submit"),l.html(' Add'),l.on("click.add",(function(){let t=e.props.model.createObject("cim:"+n);e.props.model.setLink(t,r,i),e.props.model.addToActiveDiagram(t,[])})))},createDeleteMenu(e){e.selectAll((function(){return this.parentNode.childNodes})).filter("button.cim-object-btn").on("contextmenu",t)},elements(t,n,r,i,o){let a=t.select("li."+n+"s"),s=a.select("ul#"+n+"sList");if(!0===a.empty()){a=t.append("li").attr("class",n+"s list-group-item d-flex justify-content-between"),a.append("div").append("a").attr("class","btn btn-primary btn-sm").attr("role","button").attr("data-bs-toggle","collapse").attr("href","#"+n+"sList").html(r),a.append("h4").append("span").attr("class","badge bg-primary rounded-pill").html(0),a.on("click",(function(t){t.target===this&&e.goToBasePath()})),s=a.select("div").append("ul").attr("id",n+"sList").attr("class","collapse")}let l=s.selectAll("li."+n).data(i,(function(t){return e.props.model.ID(t)})).enter().append("li").attr("class",n+" CIM-object").on("click",(function(t){t.target===this&&e.goToBasePath()}));l.append("a").attr("class","btn btn-outline-secondary btn-sm cim-expand-object").attr("role","button").attr("data-bs-toggle","collapse").attr("href",(function(t){return"#"+e.props.model.ID(t)})).on("click",(function(t,n){t.preventDefault();let r=d3.select(this.parentNode).select("ul");0===r.selectAll("li.attribute").size()&&e.generateAttrsAndLinks(r)})).html(''),l.append("button").attr("class","btn btn-primary btn-sm cim-object-btn").on("click",(function(t,n){let r=window.location.hash.substring(1).split("/"),i=r[0]+"/"+r[1]+"/"+r[2];window.location.hash.substring(1)!==i+"/"+e.props.model.ID(n)&&route.router.push(i+"/"+e.props.model.ID(n))})).html((function(t){let n=e.props.model.getAttribute(t,"cim:IdentifiedObject.name");return void 0!==n?n.innerHTML:"unnamed"})).attr("draggable","true").on("dragstart",(function(t,n){t.dataTransfer.setData("text/plain",e.props.model.ID(n))}));let c=l.append("ul").attr("id",(function(t){return e.props.model.ID(t)})).attr("class","collapse CIM-object-list"),u=parseInt(a.select(":scope > h4 > span").html());if(u+=c.size(),a.select(":scope > h4 > span").html(u),void 0===o||!1===o){let e=a.node().closest("li.cim-parent-container");for(;null!==e;){let t=e.querySelector(":scope>h4>span"),n=parseInt(t.innerHTML);n+=c.size(),t.innerHTML=n,e=e.parentNode.closest("li.cim-parent-container")}}return c},generateAttrsAndLinks(t){let n=a(!1===document.getElementById("sshInput").checked,"EQ");e.generateAttributes(n);let r=a(!0===document.getElementById("sshInput").checked,"SSH");e.generateAttributes(r);let i=s(!1===document.getElementById("sshInput").checked,"EQ");e.generateLinks(i);let o=s(!0===document.getElementById("sshInput").checked,"SSH");function a(n,r){return t.selectAll("li.attribute."+r).data((function(n){let i=e.props.model.schema.getSchemaAttributes(n.localName,r),o=t.selectAll("li.attribute > div > span.cim-tree-attribute-name").nodes().map((e=>e.textContent));return i=i.filter((function(e){let t=e.attributes[0].value.substring(1).split(".")[1];return o.indexOf(t)<0})),i.filter((e=>"#IdentifiedObject.mRID"!==e.attributes[0].value))})).enter().append("li").attr("class",l(n,r)).attr("title",(function(e){let t=e.attributes.getNamedItem("rdf:about").value.split(".")[1],n=[].filter.call(e.children,(function(e){return"rdfs:comment"===e.nodeName}));return n.length>0?t+" - "+n[0].textContent:t})).append("div").attr("class","input-group")}function s(n,r){return t.selectAll("li.link."+r).data((function(t){let n=["#NonlinearShuntCompensatorPoint.NonlinearShuntCompensator","#TransformerEnd.Terminal","#PowerTransformerEnd.PowerTransformer","#RatioTapChanger.TransformerEnd","#RegulatingControl.Terminal","#Measurement.Terminal","#Measurement.PowerSystemResource","#Discrete.ValueAliasSet","#OperationalLimitSet.Terminal","#OperationalLimitSet.Equipment","#OperationalLimit.OperationalLimitSet","#SubGeographicalRegion.Region","#VoltageLevel.Substation","#Bay.VoltageLevel"];return e.props.model.schema.getSchemaLinks(t.localName,r).filter((t=>"Yes"===e.props.model.getAttribute(t,"cims:AssociationUsed").textContent)).filter((e=>n.indexOf(e.attributes[0].value)<0))})).enter().append("li").attr("class",l(n,r)).attr("title",(function(e){let t=e.attributes.getNamedItem("rdf:about").value.split(".")[1],n=[].filter.call(e.children,(function(e){return"rdfs:comment"===e.nodeName}));return n.length>0?t+" - "+n[0].textContent:t})).append("div").attr("class","input-group")}function l(t,n){return function(r){let i="attribute "+n;!1===r.attributes.getNamedItem("rdf:about").value.startsWith("#")&&(i+=" entsoe");let o=null;return"EQ"===n&&(o=e.props.model.schema.getSchemaStereotype(r),null!==o&&(i=i+" "+o)),("Operation"===o&&"BUS_BRANCH"===e.props.model.getMode()||!1===t)&&(i+=" d-none"),i}}e.generateLinks(o)},generateAttributes(t){t.append("span").attr("class","input-group-text cim-tree-attribute-name").html((function(e){let t=e.attributes.getNamedItem("rdf:about").value.split(".")[1];return t.length>20&&(t=t.substring(0,20)+"..."),t})),t.filter((function(t){return"#String"===e.props.model.schema.getSchemaAttributeType(t)[0]})).append("input").attr("class","form-control").each(a).attr("type","text").on("input",l),t.filter((function(t){return"#Integer"===e.props.model.schema.getSchemaAttributeType(t)[0]})).append("input").attr("class","form-control").each((function(t){let n=d3.select(this.closest("ul")).data()[0],r=e.props.model.getAttribute(n,"cim:"+t.attributes[0].value.substring(1));void 0!==r?this.value=parseInt(r.innerHTML):d3.select(this).attr("placeholder","none")})).attr("type","number").on("input",l);let n=t.filter((function(t){let n=e.props.model.schema.getSchemaAttributeType(t);return"#Float"===n[0]||"#Decimal"===n[0]}));n.append("input").attr("class","form-control").each((function(t){let n=d3.select(this.closest("ul")).data()[0],r=e.props.model.getAttribute(n,"cim:"+t.attributes[0].value.substring(1));void 0!==r?this.value=parseFloat(r.innerHTML).toFixed(5):d3.select(this).attr("placeholder","none")})).attr("type","number").attr("step","0.00001").on("input",l),n.append("span").attr("class","input-group-text cim-tree-attribute-uom").html((function(t){let n=e.props.model.schema.getSchemaAttributeType(t);return"none"===n[2]?n[1]:n[2]+n[1]}));let r=t.filter((function(t){return"#Boolean"===e.props.model.schema.getSchemaAttributeType(t)[0]}));r.append("button").attr("type","button").attr("class","btn btn-outline-secondary dropdown-toggle cim-tree-dropdown-toggle").attr("data-bs-toggle","dropdown").attr("aria-expanded","false").append("span").attr("class","boolVal").each((function(t){let n=d3.select(this.closest("li.attribute").parentNode).data()[0],r=e.props.model.getAttribute(n,"cim:"+t.attributes[0].value.substring(1));void 0!==r?d3.select(this).text(r.innerHTML):d3.select(this).text("none")}));let i=r.append("ul").attr("class","dropdown-menu dropdown-menu-end");i.append("li").append("a").attr("class","dropdown-item").text("true").on("click",s),i.append("li").append("a").attr("class","dropdown-item").text("false").on("click",s),t.filter((function(t){return"#DateTime"===e.props.model.schema.getSchemaAttributeType(t)[0]})).append("input").attr("class","form-control").each(a).attr("type","datetime-local").on("input",l);let o=t.filter((function(t){return e.props.model.schema.isEnum(t)}));function a(t){let n=d3.select(this.closest("li.attribute").parentNode).data()[0],r=e.props.model.getAttribute(n,"cim:"+t.attributes[0].value.substring(1));void 0!==r?this.value=r.innerHTML:d3.select(this).attr("placeholder","none")}function s(t,n){let r=this.textContent;this.closest("div.input-group").querySelector(":scope>button>span.boolVal").textContent=r;let i=d3.select(this.closest("li.attribute").parentNode).data()[0],o="cim:"+n.attributes[0].value.substring(1);e.props.model.setAttribute(i,o,r)}function l(t,n){let r=d3.select(this.closest("ul")).data()[0],i=n.attributes.getNamedItem("rdf:about").value,o="cim:";!1===i.startsWith("#")&&(o="entsoe:"),i=i.substring(i.indexOf("#")+1);let a=o+i;e.props.model.setAttribute(r,a,this.value)}o.append("button").attr("type","button").attr("class","btn btn-outline-secondary dropdown-toggle cim-tree-dropdown-toggle").attr("data-bs-toggle","dropdown").attr("aria-expanded","false").append("span").attr("class","enumVal").each((function(t){let n=d3.select(this.closest("li.attribute").parentNode).data()[0],r=e.props.model.getEnum(n,"cim:"+t.attributes[0].value.substring(1));void 0!==r?d3.select(this).text(r):d3.select(this).text("none")})),o.append("ul").attr("class","dropdown-menu dropdown-menu-end").selectAll("li").data((function(t){return e.props.model.schema.getSchemaEnumValues(t)})).enter().append("li").append("a").on("click",(function(t,n){this.closest("div.input-group").querySelector(":scope>button>span.enumVal").textContent=n;let r=d3.select(this.closest("li.attribute").parentNode).data()[0],i=d3.select(this.closest("li.attribute")).data()[0],o="cim:"+i.attributes[0].value.substring(1),a=e.props.model.schema.getSchemaEnumName(i)+"."+n;e.props.model.setEnum(r,o,a)})).attr("class","dropdown-item").text((function(e){return e}))},generateLinks(t){t.attr("class","input-group").append("span").attr("class","input-group-text cim-tree-attribute-name").html((function(e){let t=e.attributes.getNamedItem("rdf:about").value.split(".")[1];return t.length>20&&(t=t.substring(0,20)+"..."),t}));let n=t.append("div").attr("class","btn-group cim-tree-btn-group");n.append("button").attr("class","btn btn-outline-secondary cimLinkBtn").attr("type","submit").on("click",(function(e,t){let n="#"+d3.select(this).attr("cim-target"),r=window.location.hash.substring(1).split("/"),i=r[0]+"/"+r[1]+"/"+r[2];route.router.push(i+"/"+n.substring(1))})).attr("cim-target",(function(t){let n=d3.select(this.closest("ul")).data()[0],r=e.props.model.getTargets([n],t.attributes[0].value.substring(1))[0];return void 0===r?"none":e.props.model.ID(r)})).html((function(t){let n=e.props.model.getObject(d3.select(this).attr("cim-target"));if(void 0===n)return d3.select(this).attr("disabled","disabled"),"none";let r=e.props.model.getAttribute(n,"cim:IdentifiedObject.name");return void 0!==r?r.innerHTML:"unnamed"})),n.append("button").attr("class","btn btn-outline-secondary").attr("type","submit").on("click",(function(t,n){let r=d3.select(this.parentNode),i=e.props.model.schema.getLinkRange(n),o=d3.select(".tree").selectAll(".tab-pane > .list-group > .list-group-item > div > ul"),a=o.filter((function(t){let n=!1,r=d3.select(this).select(".CIM-object");return r.size()>0&&(n=!0===e.props.model.schema.isA(i,r.datum())),n})),s=o.filter((function(t){let n=!0,r=d3.select(this).select(".CIM-object");return r.size()>0&&(n=!1===e.props.model.schema.isA(i,r.datum())),n}));e.enterSetLinkMode(r,a,s)})).html("change"),n.append("button").attr("class","btn btn-outline-secondary").attr("type","submit").attr("id","cimRemoveBtn").on("click",(function(t,n){let r=d3.select(this.closest("ul")).data()[0],i="cim:"+n.attributes[0].value.substring(1),o=e.props.model.getObject(this.parentNode.querySelector("[cim-target]").getAttribute("cim-target"));e.props.model.removeLink(r,i,o)})).html((function(){return void 0===e.props.model.getObject(this.parentNode.querySelector("[cim-target]").getAttribute("cim-target"))&&d3.select(this).attr("disabled","disabled"),"remove"}))},setLink(t,n){let r=d3.select(t.node().closest("ul")).data()[0],i=e.props.model.ID(r);if(null!==n){let i="cim:"+t.data()[0].attributes[0].value.substring(1);e.props.model.setLink(r,i,n)}let o=window.location.hash.substring(1).split("/"),a=o[0]+"/"+o[1]+"/"+o[2];route.router.push(a+"/"+i)},enterSetLinkMode(t,n,r){e.state.mode="setLinks",document.getElementById("tree-link-dialog").classList.remove("d-none"),document.getElementById("tree-controls").classList.add("d-none"),n.each((function(n){let r=d3.select(this).selectAll(".CIM-object");r.select("button.cim-object-btn").classed("btn-primary",!1).classed("btn-outline-dark",!0),r.insert("button",":first-child").attr("class","btn btn-outline-dark btn-sm cim-check-btn").attr("type","submit").on("click",(function(){d3.select(this.firstChild).attr("class","far fa-check-square");let n=d3.select(this).datum();e.setLink(t,n),e.exitSetLinkMode()})).append("span").attr("class","far fa-square"),r.selectAll("a.cim-expand-object").classed("d-none",!0)})),r.each((function(e){this.parentNode.parentNode.classList.add("d-none"),this.parentNode.parentNode.classList.remove("d-flex")})),document.querySelectorAll(".tab-content > .tab-pane > ul").forEach((function(e){const t=e.parentNode.getAttribute("id")+"Tab";0===e.querySelectorAll(":scope > li.d-flex").length?document.getElementById(t).classList.add("d-none"):bootstrap.Tab.getInstance(document.querySelector("#"+t)).show()})),d3.select("body").on("keyup.tree",(function(n){27===n.keyCode&&(e.exitSetLinkMode(),e.setLink(t,null))})),d3.select("#tree-link-dialog-cancel").on("click",(function(){e.exitSetLinkMode(),e.setLink(t,null)}))},exitSetLinkMode(){e.state.mode="default",document.getElementById("tree-link-dialog").classList.add("d-none"),document.getElementById("tree-controls").classList.remove("d-none"),d3.select(".tree").selectAll(".tab-pane > .list-group > .list-group-item > div > ul").each((function(e){let t=d3.select(this).selectAll(".CIM-object");t.selectAll("button.cim-check-btn").remove(),t.select("button.cim-object-btn").classed("btn-primary",!0).classed("btn-outline-dark",!1),t.selectAll("a.cim-expand-object").classed("d-none",!1),this.parentNode.parentNode.classList.add("d-flex"),this.parentNode.parentNode.classList.remove("d-none")})),document.querySelectorAll(".tab-content > .tab-pane > ul").forEach((function(e){const t=e.parentNode.getAttribute("id")+"Tab";document.getElementById(t).classList.remove("d-none")})),d3.select("body").on("keyup.tree",null),d3.select("#tree-link-dialog-cancel").on("click",null)},moveTo(t){if(void 0===t)return;let n=null,r=null,i=e.props.model.getObject(t);if(void 0===i)return;if("cim:ConnectivityNode"===i.nodeName||"cim:TopologicalNode"===i.nodeName){let n=e.props.model.getBusbar(i);if(null===n)return;t=e.props.model.ID(n)}if(r=d3.select(".tree").select("#"+t).node(),null===r)return;n=r.parentNode,d3.select(".tree").selectAll(".btn-danger").classed("btn-danger",!1).classed("btn-primary",!0);const o=n.closest("div.tab-pane").getAttribute("id")+"Tab";if(document.getElementById(o).classList.contains("active"))e.scrollTo("#"+t);else{document.querySelector("#"+o).addEventListener("shown.bs.tab",(function n(r){e.scrollTo("#"+t),this.removeEventListener("shown.bs.tab",n)}))}bootstrap.Tab.getInstance(document.querySelector("#"+o)).show(),d3.select(n).select("button.cim-object-btn").classed("btn-danger",!0).classed("btn-primary",!1)},deleteObject(e){let t=d3.select("div.tree").select("ul#"+e).node();if(null!==t){let e=t.parentNode;e.closest("li.list-group-item").querySelectorAll(":scope>h4>span").forEach((function(e){let t=parseInt(e.innerHTML);t-=1,e.innerHTML=t}));let n=e.closest("li.cim-parent-container");for(;null!==n;){let e=n.querySelector(":scope>h4>span"),t=parseInt(e.innerHTML);t-=1,e.innerHTML=t,n=n.parentNode.closest("li.cim-parent-container")}e.remove()}},scrollTo(t){let n=document.querySelector(t).parentNode.closest(".collapse:not(.show)");for(null===n&&i(t);null!==n;){function r(n){n.stopPropagation();let o=d3.select(this.parentNode).filter(".CIM-object").select("ul");0===o.selectAll("li.attribute").size()&&e.generateAttrsAndLinks(o),i(t),this.removeEventListener("shown.bs.collapse",r)}n.addEventListener("shown.bs.collapse",r);let o=bootstrap.Collapse.getInstance(n);null===o&&(o=new bootstrap.Collapse(n,{toggle:!1})),o.show(),n=n.parentNode.closest(".collapse:not(.show)")}function i(e){const t=document.getElementById("tab-content"),n=t.querySelector(e),r=t.getBoundingClientRect().top+document.body.scrollTop,i=n.parentNode.getBoundingClientRect().top+document.body.scrollTop;t.scrollTop=t.scrollTop+i-r}},resetAttrs(){!0===document.getElementById("sshInput").checked?(d3.select("#app-tree").selectAll("li.attribute:not(.SSH)").classed("d-none",!0),d3.select("#app-tree").selectAll("li.link:not(.SSH)").classed("d-none",!0),d3.select("#app-tree").selectAll("li.attribute.SSH").classed("d-none",!1),d3.select("#app-tree").selectAll("li.link.SSH").classed("d-none",!1)):(d3.select("#app-tree").selectAll("li.attribute:not(.SSH)").classed("d-none",!1),d3.select("#app-tree").selectAll("li.link:not(.SSH)").classed("d-none",!1),d3.select("#app-tree").selectAll("li.attribute.SSH").classed("d-none",!0),d3.select("#app-tree").selectAll("li.link.SSH").classed("d-none",!0))}},template:function(e,t,n,r){return e('
                          ',[])},name:"cimtree"}})),function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).bootstrap=t()}(this,(function(){"use strict";function e(e,t){for(var n=0;n0,r._pointerEvent=Boolean(window.PointerEvent),r._addEventListeners(),r}r(i,e);var o=i.prototype;return o.next=function(){this._isSliding||this._slide("next")},o.nextWhenVisible=function(){!document.hidden&&m(this._element)&&this.next()},o.prev=function(){this._isSliding||this._slide("prev")},o.pause=function(e){e||(this._isPaused=!0),G.findOne(".carousel-item-next, .carousel-item-prev",this._element)&&(f(this._element),this.cycle(!0)),clearInterval(this._interval),this._interval=null},o.cycle=function(e){e||(this._isPaused=!1),this._interval&&(clearInterval(this._interval),this._interval=null),this._config&&this._config.interval&&!this._isPaused&&(this._updateInterval(),this._interval=setInterval((document.visibilityState?this.nextWhenVisible:this.next).bind(this),this._config.interval))},o.to=function(e){var t=this;this._activeElement=G.findOne(".active.carousel-item",this._element);var n=this._getItemIndex(this._activeElement);if(!(e>this._items.length-1||e<0))if(this._isSliding)j.one(this._element,"slid.bs.carousel",(function(){return t.to(e)}));else{if(n===e)return this.pause(),void this.cycle();var r=e>n?"next":"prev";this._slide(r,this._items[e])}},o.dispose=function(){e.prototype.dispose.call(this),j.off(this._element,".bs.carousel"),this._items=null,this._config=null,this._interval=null,this._isPaused=null,this._isSliding=null,this._activeElement=null,this._indicatorsElement=null},o._getConfig=function(e){return e=n({},Y,e),p(W,e,Z),e},o._handleSwipe=function(){var e=Math.abs(this.touchDeltaX);if(!(e<=40)){var t=e/this.touchDeltaX;this.touchDeltaX=0,t>0&&this.prev(),t<0&&this.next()}},o._addEventListeners=function(){var e=this;this._config.keyboard&&j.on(this._element,"keydown.bs.carousel",(function(t){return e._keydown(t)})),"hover"===this._config.pause&&(j.on(this._element,"mouseenter.bs.carousel",(function(t){return e.pause(t)})),j.on(this._element,"mouseleave.bs.carousel",(function(t){return e.cycle(t)}))),this._config.touch&&this._touchSupported&&this._addTouchEventListeners()},o._addTouchEventListeners=function(){var e=this,t=function(t){e._pointerEvent&&K[t.pointerType.toUpperCase()]?e.touchStartX=t.clientX:e._pointerEvent||(e.touchStartX=t.touches[0].clientX)},n=function(t){e._pointerEvent&&K[t.pointerType.toUpperCase()]&&(e.touchDeltaX=t.clientX-e.touchStartX),e._handleSwipe(),"hover"===e._config.pause&&(e.pause(),e.touchTimeout&&clearTimeout(e.touchTimeout),e.touchTimeout=setTimeout((function(t){return e.cycle(t)}),500+e._config.interval))};G.find(".carousel-item img",this._element).forEach((function(e){j.on(e,"dragstart.bs.carousel",(function(e){return e.preventDefault()}))})),this._pointerEvent?(j.on(this._element,"pointerdown.bs.carousel",(function(e){return t(e)})),j.on(this._element,"pointerup.bs.carousel",(function(e){return n(e)})),this._element.classList.add("pointer-event")):(j.on(this._element,"touchstart.bs.carousel",(function(e){return t(e)})),j.on(this._element,"touchmove.bs.carousel",(function(t){return function(t){t.touches&&t.touches.length>1?e.touchDeltaX=0:e.touchDeltaX=t.touches[0].clientX-e.touchStartX}(t)})),j.on(this._element,"touchend.bs.carousel",(function(e){return n(e)})))},o._keydown=function(e){if(!/input|textarea/i.test(e.target.tagName))switch(e.key){case"ArrowLeft":e.preventDefault(),this.prev();break;case"ArrowRight":e.preventDefault(),this.next()}},o._getItemIndex=function(e){return this._items=e&&e.parentNode?G.find(".carousel-item",e.parentNode):[],this._items.indexOf(e)},o._getItemByDirection=function(e,t){var n="next"===e,r="prev"===e,i=this._getItemIndex(t),o=this._items.length-1;if((r&&0===i||n&&i===o)&&!this._config.wrap)return t;var a=(i+("prev"===e?-1:1))%this._items.length;return-1===a?this._items[this._items.length-1]:this._items[a]},o._triggerSlideEvent=function(e,t){var n=this._getItemIndex(e),r=this._getItemIndex(G.findOne(".active.carousel-item",this._element));return j.trigger(this._element,"slide.bs.carousel",{relatedTarget:e,direction:t,from:r,to:n})},o._setActiveIndicatorElement=function(e){if(this._indicatorsElement){for(var t=G.find(".active",this._indicatorsElement),n=0;n0)for(var r=0;r=0}function ye(e){return((fe(e)?e.ownerDocument:e.document)||window.document).documentElement}function _e(e){return"html"===ce(e)?e:e.assignedSlot||e.parentNode||e.host||ye(e)}function we(e){if(!de(e)||"fixed"===be(e).position)return null;var t=e.offsetParent;if(t){var n=ye(t);if("body"===ce(t)&&"static"===be(t).position&&"static"!==be(n).position)return n}return t}function xe(e){for(var t=ue(e),n=we(e);n&&ve(n)&&"static"===be(n).position;)n=we(n);return n&&"body"===ce(n)&&"static"===be(n).position?t:n||function(e){for(var t=_e(e);de(t)&&["html","body"].indexOf(ce(t))<0;){var n=be(t);if("none"!==n.transform||"none"!==n.perspective||n.willChange&&"auto"!==n.willChange)return t;t=t.parentNode}return null}(e)||t}function Te(e){return["top","bottom"].indexOf(e)>=0?"x":"y"}function Ae(e,t,n){return Math.max(e,Math.min(t,n))}function Ee(e){return Object.assign(Object.assign({},{top:0,right:0,bottom:0,left:0}),e)}function ke(e,t){return t.reduce((function(t,n){return t[n]=e,t}),{})}var Se={name:"arrow",enabled:!0,phase:"main",fn:function(e){var t,n=e.state,r=e.name,i=n.elements.arrow,o=n.modifiersData.popperOffsets,a=pe(n.placement),s=Te(a),l=[ie,re].indexOf(a)>=0?"height":"width";if(i&&o){var c=n.modifiersData[r+"#persistent"].padding,u=me(i),f="y"===s?te:ie,d="y"===s?ne:re,h=n.rects.reference[l]+n.rects.reference[s]-o[s]-n.rects.popper[l],p=o[s]-n.rects.reference[s],m=xe(i),g=m?"y"===s?m.clientHeight||0:m.clientWidth||0:0,b=h/2-p/2,v=c[f],y=g-u[l]-c[d],_=g/2-u[l]/2+b,w=Ae(v,_,y),x=s;n.modifiersData[r]=((t={})[x]=w,t.centerOffset=w-_,t)}},effect:function(e){var t=e.state,n=e.options,r=e.name,i=n.element,o=void 0===i?"[data-popper-arrow]":i,a=n.padding,s=void 0===a?0:a;null!=o&&("string"!=typeof o||(o=t.elements.popper.querySelector(o)))&&ge(t.elements.popper,o)&&(t.elements.arrow=o,t.modifiersData[r+"#persistent"]={padding:Ee("number"!=typeof s?s:ke(s,oe))})},requires:["popperOffsets"],requiresIfExists:["preventOverflow"]},Me={top:"auto",right:"auto",bottom:"auto",left:"auto"};function Ce(e){var t,n=e.popper,r=e.popperRect,i=e.placement,o=e.offsets,a=e.position,s=e.gpuAcceleration,l=e.adaptive,c=function(e){var t=e.x,n=e.y,r=window.devicePixelRatio||1;return{x:Math.round(t*r)/r||0,y:Math.round(n*r)/r||0}}(o),u=c.x,f=c.y,d=o.hasOwnProperty("x"),h=o.hasOwnProperty("y"),p=ie,m=te,g=window;if(l){var b=xe(n);b===ue(n)&&(b=ye(n)),i===te&&(m=ne,f-=b.clientHeight-r.height,f*=s?1:-1),i===ie&&(p=re,u-=b.clientWidth-r.width,u*=s?1:-1)}var v,y=Object.assign({position:a},l&&Me);return s?Object.assign(Object.assign({},y),{},((v={})[m]=h?"0":"",v[p]=d?"0":"",v.transform=(g.devicePixelRatio||1)<2?"translate("+u+"px, "+f+"px)":"translate3d("+u+"px, "+f+"px, 0)",v)):Object.assign(Object.assign({},y),{},((t={})[m]=h?f+"px":"",t[p]=d?u+"px":"",t.transform="",t))}var Ne={name:"computeStyles",enabled:!0,phase:"beforeWrite",fn:function(e){var t=e.state,n=e.options,r=n.gpuAcceleration,i=void 0===r||r,o=n.adaptive,a=void 0===o||o,s={placement:pe(t.placement),popper:t.elements.popper,popperRect:t.rects.popper,gpuAcceleration:i};null!=t.modifiersData.popperOffsets&&(t.styles.popper=Object.assign(Object.assign({},t.styles.popper),Ce(Object.assign(Object.assign({},s),{},{offsets:t.modifiersData.popperOffsets,position:t.options.strategy,adaptive:a})))),null!=t.modifiersData.arrow&&(t.styles.arrow=Object.assign(Object.assign({},t.styles.arrow),Ce(Object.assign(Object.assign({},s),{},{offsets:t.modifiersData.arrow,position:"absolute",adaptive:!1})))),t.attributes.popper=Object.assign(Object.assign({},t.attributes.popper),{},{"data-popper-placement":t.placement})},data:{}},De={passive:!0},Le={name:"eventListeners",enabled:!0,phase:"write",fn:function(){},effect:function(e){var t=e.state,n=e.instance,r=e.options,i=r.scroll,o=void 0===i||i,a=r.resize,s=void 0===a||a,l=ue(t.elements.popper),c=[].concat(t.scrollParents.reference,t.scrollParents.popper);return o&&c.forEach((function(e){e.addEventListener("scroll",n.update,De)})),s&&l.addEventListener("resize",n.update,De),function(){o&&c.forEach((function(e){e.removeEventListener("scroll",n.update,De)})),s&&l.removeEventListener("resize",n.update,De)}},data:{}},Oe={left:"right",right:"left",bottom:"top",top:"bottom"};function Ie(e){return e.replace(/left|right|bottom|top/g,(function(e){return Oe[e]}))}var Be={start:"end",end:"start"};function Pe(e){return e.replace(/start|end/g,(function(e){return Be[e]}))}function je(e){var t=e.getBoundingClientRect();return{width:t.width,height:t.height,top:t.top,right:t.right,bottom:t.bottom,left:t.left,x:t.left,y:t.top}}function Re(e){var t=ue(e);return{scrollLeft:t.pageXOffset,scrollTop:t.pageYOffset}}function ze(e){return je(ye(e)).left+Re(e).scrollLeft}function Fe(e){var t=be(e),n=t.overflow,r=t.overflowX,i=t.overflowY;return/auto|scroll|overlay|hidden/.test(n+i+r)}function qe(e,t){void 0===t&&(t=[]);var n=function e(t){return["html","body","#document"].indexOf(ce(t))>=0?t.ownerDocument.body:de(t)&&Fe(t)?t:e(_e(t))}(e),r="body"===ce(n),i=ue(n),o=r?[i].concat(i.visualViewport||[],Fe(n)?n:[]):n,a=t.concat(o);return r?a:a.concat(qe(_e(o)))}function Ue(e){return Object.assign(Object.assign({},e),{},{left:e.x,top:e.y,right:e.x+e.width,bottom:e.y+e.height})}function He(e,t){return"viewport"===t?Ue(function(e){var t=ue(e),n=ye(e),r=t.visualViewport,i=n.clientWidth,o=n.clientHeight,a=0,s=0;return r&&(i=r.width,o=r.height,/^((?!chrome|android).)*safari/i.test(navigator.userAgent)||(a=r.offsetLeft,s=r.offsetTop)),{width:i,height:o,x:a+ze(e),y:s}}(e)):de(t)?function(e){var t=je(e);return t.top=t.top+e.clientTop,t.left=t.left+e.clientLeft,t.bottom=t.top+e.clientHeight,t.right=t.left+e.clientWidth,t.width=e.clientWidth,t.height=e.clientHeight,t.x=t.left,t.y=t.top,t}(t):Ue(function(e){var t=ye(e),n=Re(e),r=e.ownerDocument.body,i=Math.max(t.scrollWidth,t.clientWidth,r?r.scrollWidth:0,r?r.clientWidth:0),o=Math.max(t.scrollHeight,t.clientHeight,r?r.scrollHeight:0,r?r.clientHeight:0),a=-n.scrollLeft+ze(e),s=-n.scrollTop;return"rtl"===be(r||t).direction&&(a+=Math.max(t.clientWidth,r?r.clientWidth:0)-i),{width:i,height:o,x:a,y:s}}(ye(e)))}function Ve(e){return e.split("-")[1]}function Ge(e){var t,n=e.reference,r=e.element,i=e.placement,o=i?pe(i):null,a=i?Ve(i):null,s=n.x+n.width/2-r.width/2,l=n.y+n.height/2-r.height/2;switch(o){case te:t={x:s,y:n.y-r.height};break;case ne:t={x:s,y:n.y+n.height};break;case re:t={x:n.x+n.width,y:l};break;case ie:t={x:n.x-r.width,y:l};break;default:t={x:n.x,y:n.y}}var c=o?Te(o):null;if(null!=c){var u="y"===c?"height":"width";switch(a){case"start":t[c]=Math.floor(t[c])-Math.floor(n[u]/2-r[u]/2);break;case"end":t[c]=Math.floor(t[c])+Math.ceil(n[u]/2-r[u]/2)}}return t}function We(e,t){void 0===t&&(t={});var n=t,r=n.placement,i=void 0===r?e.placement:r,o=n.boundary,a=void 0===o?"clippingParents":o,s=n.rootBoundary,l=void 0===s?"viewport":s,c=n.elementContext,u=void 0===c?"popper":c,f=n.altBoundary,d=void 0!==f&&f,h=n.padding,p=void 0===h?0:h,m=Ee("number"!=typeof p?p:ke(p,oe)),g="popper"===u?"reference":"popper",b=e.elements.reference,v=e.rects.popper,y=e.elements[d?g:u],_=function(e,t,n){var r="clippingParents"===t?function(e){var t=qe(_e(e)),n=["absolute","fixed"].indexOf(be(e).position)>=0&&de(e)?xe(e):e;return fe(n)?t.filter((function(e){return fe(e)&&ge(e,n)&&"body"!==ce(e)})):[]}(e):[].concat(t),i=[].concat(r,[n]),o=i[0],a=i.reduce((function(t,n){var r=He(e,n);return t.top=Math.max(r.top,t.top),t.right=Math.min(r.right,t.right),t.bottom=Math.min(r.bottom,t.bottom),t.left=Math.max(r.left,t.left),t}),He(e,o));return a.width=a.right-a.left,a.height=a.bottom-a.top,a.x=a.left,a.y=a.top,a}(fe(y)?y:y.contextElement||ye(e.elements.popper),a,l),w=je(b),x=Ge({reference:w,element:v,strategy:"absolute",placement:i}),T=Ue(Object.assign(Object.assign({},v),x)),A="popper"===u?T:w,E={top:_.top-A.top+m.top,bottom:A.bottom-_.bottom+m.bottom,left:_.left-A.left+m.left,right:A.right-_.right+m.right},k=e.modifiersData.offset;if("popper"===u&&k){var S=k[i];Object.keys(E).forEach((function(e){var t=[re,ne].indexOf(e)>=0?1:-1,n=[te,ne].indexOf(e)>=0?"y":"x";E[e]+=S[n]*t}))}return E}var Ye={name:"flip",enabled:!0,phase:"main",fn:function(e){var t=e.state,n=e.options,r=e.name;if(!t.modifiersData[r]._skip){for(var i=n.mainAxis,o=void 0===i||i,a=n.altAxis,s=void 0===a||a,l=n.fallbackPlacements,c=n.padding,u=n.boundary,f=n.rootBoundary,d=n.altBoundary,h=n.flipVariations,p=void 0===h||h,m=n.allowedAutoPlacements,g=t.options.placement,b=pe(g),v=l||(b!==g&&p?function(e){if("auto"===pe(e))return[];var t=Ie(e);return[Pe(e),t,Pe(t)]}(g):[Ie(g)]),y=[g].concat(v).reduce((function(e,n){return e.concat("auto"===pe(n)?function(e,t){void 0===t&&(t={});var n=t,r=n.placement,i=n.boundary,o=n.rootBoundary,a=n.padding,s=n.flipVariations,l=n.allowedAutoPlacements,c=void 0===l?se:l,u=Ve(r),f=u?s?ae:ae.filter((function(e){return Ve(e)===u})):oe,d=f.filter((function(e){return c.indexOf(e)>=0}));0===d.length&&(d=f);var h=d.reduce((function(t,n){return t[n]=We(e,{placement:n,boundary:i,rootBoundary:o,padding:a})[pe(n)],t}),{});return Object.keys(h).sort((function(e,t){return h[e]-h[t]}))}(t,{placement:n,boundary:u,rootBoundary:f,padding:c,flipVariations:p,allowedAutoPlacements:m}):n)}),[]),_=t.rects.reference,w=t.rects.popper,x=new Map,T=!0,A=y[0],E=0;E=0,N=C?"width":"height",D=We(t,{placement:k,boundary:u,rootBoundary:f,altBoundary:d,padding:c}),L=C?M?re:ie:M?ne:te;_[N]>w[N]&&(L=Ie(L));var O=Ie(L),I=[];if(o&&I.push(D[S]<=0),s&&I.push(D[L]<=0,D[O]<=0),I.every((function(e){return e}))){A=k,T=!1;break}x.set(k,I)}if(T)for(var B=function(e){var t=y.find((function(t){var n=x.get(t);if(n)return n.slice(0,e).every((function(e){return e}))}));if(t)return A=t,"break"},P=p?3:1;P>0&&"break"!==B(P);P--);t.placement!==A&&(t.modifiersData[r]._skip=!0,t.placement=A,t.reset=!0)}},requiresIfExists:["offset"],data:{_skip:!1}};function Ze(e,t,n){return void 0===n&&(n={x:0,y:0}),{top:e.top-t.height-n.y,right:e.right-t.width+n.x,bottom:e.bottom-t.height+n.y,left:e.left-t.width-n.x}}function Ke(e){return[te,re,ne,ie].some((function(t){return e[t]>=0}))}var Xe={name:"hide",enabled:!0,phase:"main",requiresIfExists:["preventOverflow"],fn:function(e){var t=e.state,n=e.name,r=t.rects.reference,i=t.rects.popper,o=t.modifiersData.preventOverflow,a=We(t,{elementContext:"reference"}),s=We(t,{altBoundary:!0}),l=Ze(a,r),c=Ze(s,i,o),u=Ke(l),f=Ke(c);t.modifiersData[n]={referenceClippingOffsets:l,popperEscapeOffsets:c,isReferenceHidden:u,hasPopperEscaped:f},t.attributes.popper=Object.assign(Object.assign({},t.attributes.popper),{},{"data-popper-reference-hidden":u,"data-popper-escaped":f})}},Qe={name:"offset",enabled:!0,phase:"main",requires:["popperOffsets"],fn:function(e){var t=e.state,n=e.options,r=e.name,i=n.offset,o=void 0===i?[0,0]:i,a=se.reduce((function(e,n){return e[n]=function(e,t,n){var r=pe(e),i=[ie,te].indexOf(r)>=0?-1:1,o="function"==typeof n?n(Object.assign(Object.assign({},t),{},{placement:e})):n,a=o[0],s=o[1];return a=a||0,s=(s||0)*i,[ie,re].indexOf(r)>=0?{x:s,y:a}:{x:a,y:s}}(n,t.rects,o),e}),{}),s=a[t.placement],l=s.x,c=s.y;null!=t.modifiersData.popperOffsets&&(t.modifiersData.popperOffsets.x+=l,t.modifiersData.popperOffsets.y+=c),t.modifiersData[r]=a}},$e={name:"popperOffsets",enabled:!0,phase:"read",fn:function(e){var t=e.state,n=e.name;t.modifiersData[n]=Ge({reference:t.rects.reference,element:t.rects.popper,strategy:"absolute",placement:t.placement})},data:{}},Je={name:"preventOverflow",enabled:!0,phase:"main",fn:function(e){var t=e.state,n=e.options,r=e.name,i=n.mainAxis,o=void 0===i||i,a=n.altAxis,s=void 0!==a&&a,l=n.boundary,c=n.rootBoundary,u=n.altBoundary,f=n.padding,d=n.tether,h=void 0===d||d,p=n.tetherOffset,m=void 0===p?0:p,g=We(t,{boundary:l,rootBoundary:c,padding:f,altBoundary:u}),b=pe(t.placement),v=Ve(t.placement),y=!v,_=Te(b),w="x"===_?"y":"x",x=t.modifiersData.popperOffsets,T=t.rects.reference,A=t.rects.popper,E="function"==typeof m?m(Object.assign(Object.assign({},t.rects),{},{placement:t.placement})):m,k={x:0,y:0};if(x){if(o){var S="y"===_?te:ie,M="y"===_?ne:re,C="y"===_?"height":"width",N=x[_],D=x[_]+g[S],L=x[_]-g[M],O=h?-A[C]/2:0,I="start"===v?T[C]:A[C],B="start"===v?-A[C]:-T[C],P=t.elements.arrow,j=h&&P?me(P):{width:0,height:0},R=t.modifiersData["arrow#persistent"]?t.modifiersData["arrow#persistent"].padding:{top:0,right:0,bottom:0,left:0},z=R[S],F=R[M],q=Ae(0,T[C],j[C]),U=y?T[C]/2-O-q-z-E:I-q-z-E,H=y?-T[C]/2+O+q+F+E:B+q+F+E,V=t.elements.arrow&&xe(t.elements.arrow),G=V?"y"===_?V.clientTop||0:V.clientLeft||0:0,W=t.modifiersData.offset?t.modifiersData.offset[t.placement][_]:0,Y=x[_]+U-W-G,Z=x[_]+H-W,K=Ae(h?Math.min(D,Y):D,N,h?Math.max(L,Z):L);x[_]=K,k[_]=K-N}if(s){var X="x"===_?te:ie,Q="x"===_?ne:re,$=x[w],J=Ae($+g[X],$,$-g[Q]);x[w]=J,k[w]=J-$}t.modifiersData[r]=k}},requiresIfExists:["offset"]};function et(e,t,n){void 0===n&&(n=!1);var r,i,o=ye(t),a=je(e),s=de(t),l={scrollLeft:0,scrollTop:0},c={x:0,y:0};return(s||!s&&!n)&&(("body"!==ce(t)||Fe(o))&&(l=(r=t)!==ue(r)&&de(r)?{scrollLeft:(i=r).scrollLeft,scrollTop:i.scrollTop}:Re(r)),de(t)?((c=je(t)).x+=t.clientLeft,c.y+=t.clientTop):o&&(c.x=ze(o))),{x:a.left+l.scrollLeft-c.x,y:a.top+l.scrollTop-c.y,width:a.width,height:a.height}}var tt={placement:"bottom",modifiers:[],strategy:"absolute"};function nt(){for(var e=arguments.length,t=new Array(e),n=0;n0&&o--,"ArrowDown"===e.key&&odocument.documentElement.clientHeight;t||(this._element.style.overflowY="hidden"),this._element.classList.add("modal-static");var n=u(this._dialog);j.off(this._element,"transitionend"),j.one(this._element,"transitionend",(function(){e._element.classList.remove("modal-static"),t||(j.one(e._element,"transitionend",(function(){e._element.style.overflowY=""})),h(e._element,n))})),h(this._element,n),this._element.focus()}},o._adjustDialog=function(){var e=this._element.scrollHeight>document.documentElement.clientHeight;(!this._isBodyOverflowing&&e&&!_||this._isBodyOverflowing&&!e&&_)&&(this._element.style.paddingLeft=this._scrollbarWidth+"px"),(this._isBodyOverflowing&&!e&&!_||!this._isBodyOverflowing&&e&&_)&&(this._element.style.paddingRight=this._scrollbarWidth+"px")},o._resetAdjustments=function(){this._element.style.paddingLeft="",this._element.style.paddingRight=""},o._checkScrollbar=function(){var e=document.body.getBoundingClientRect();this._isBodyOverflowing=Math.round(e.left+e.right)
                          ',trigger:"hover focus",title:"",delay:0,html:!1,selector:!1,placement:"top",container:!1,fallbackPlacements:null,boundary:"clippingParents",customClass:"",sanitize:!0,sanitizeFn:null,allowList:{"*":["class","dir","id","lang","role",/^aria-[\w-]*$/i],a:["target","href","title","rel"],area:[],b:[],br:[],col:[],code:[],div:[],em:[],hr:[],h1:[],h2:[],h3:[],h4:[],h5:[],h6:[],i:[],img:["src","srcset","alt","title","width","height"],li:[],ol:[],p:[],pre:[],s:[],small:[],span:[],sub:[],sup:[],strong:[],u:[],ul:[]},popperConfig:null},Lt={HIDE:"hide.bs.tooltip",HIDDEN:"hidden.bs.tooltip",SHOW:"show.bs.tooltip",SHOWN:"shown.bs.tooltip",INSERTED:"inserted.bs.tooltip",CLICK:"click.bs.tooltip",FOCUSIN:"focusin.bs.tooltip",FOCUSOUT:"focusout.bs.tooltip",MOUSEENTER:"mouseenter.bs.tooltip",MOUSELEAVE:"mouseleave.bs.tooltip"},Ot=function(e){function i(t,n){var r;if(void 0===st)throw new TypeError("Bootstrap's tooltips require Popper (https://popper.js.org)");return(r=e.call(this,t)||this)._isEnabled=!0,r._timeout=0,r._hoverState="",r._activeTrigger={},r._popper=null,r.config=r._getConfig(n),r.tip=null,r._setListeners(),r}r(i,e);var o=i.prototype;return o.enable=function(){this._isEnabled=!0},o.disable=function(){this._isEnabled=!1},o.toggleEnabled=function(){this._isEnabled=!this._isEnabled},o.toggle=function(e){if(this._isEnabled)if(e){var t=this.constructor.DATA_KEY,n=T(e.delegateTarget,t);n||(n=new this.constructor(e.delegateTarget,this._getDelegateConfig()),x(e.delegateTarget,t,n)),n._activeTrigger.click=!n._activeTrigger.click,n._isWithActiveTrigger()?n._enter(null,n):n._leave(null,n)}else{if(this.getTipElement().classList.contains("show"))return void this._leave(null,this);this._enter(null,this)}},o.dispose=function(){clearTimeout(this._timeout),j.off(this._element,this.constructor.EVENT_KEY),j.off(this._element.closest(".modal"),"hide.bs.modal",this._hideModalHandler),this.tip&&this.tip.parentNode.removeChild(this.tip),this._isEnabled=null,this._timeout=null,this._hoverState=null,this._activeTrigger=null,this._popper&&this._popper.destroy(),this._popper=null,this.config=null,this.tip=null,e.prototype.dispose.call(this)},o.show=function(){var e=this;if("none"===this._element.style.display)throw new Error("Please use show on visible elements");if(this.isWithContent()&&this._isEnabled){var t=j.trigger(this._element,this.constructor.Event.SHOW),n=function e(t){if(!document.documentElement.attachShadow)return null;if("function"==typeof t.getRootNode){var n=t.getRootNode();return n instanceof ShadowRoot?n:null}return t instanceof ShadowRoot?t:t.parentNode?e(t.parentNode):null}(this._element),r=null===n?this._element.ownerDocument.documentElement.contains(this._element):n.contains(this._element);if(t.defaultPrevented||!r)return;var i=this.getTipElement(),o=a(this.constructor.NAME);i.setAttribute("id",o),this._element.setAttribute("aria-describedby",o),this.setContent(),this.config.animation&&i.classList.add("fade");var s="function"==typeof this.config.placement?this.config.placement.call(this,i,this._element):this.config.placement,l=this._getAttachment(s);this._addAttachmentClass(l);var c=this._getContainer();x(i,this.constructor.DATA_KEY,this),this._element.ownerDocument.documentElement.contains(this.tip)||c.appendChild(i),j.trigger(this._element,this.constructor.Event.INSERTED),this._popper=at(this._element,i,this._getPopperConfig(l)),i.classList.add("show");var f,d,p="function"==typeof this.config.customClass?this.config.customClass():this.config.customClass;p&&(f=i.classList).add.apply(f,p.split(" ")),"ontouchstart"in document.documentElement&&(d=[]).concat.apply(d,document.body.children).forEach((function(e){j.on(e,"mouseover",(function(){}))}));var m=function(){var t=e._hoverState;e._hoverState=null,j.trigger(e._element,e.constructor.Event.SHOWN),"out"===t&&e._leave(null,e)};if(this.tip.classList.contains("fade")){var g=u(this.tip);j.one(this.tip,"transitionend",m),h(this.tip,g)}else m()}},o.hide=function(){var e=this;if(this._popper){var t=this.getTipElement(),n=function(){"show"!==e._hoverState&&t.parentNode&&t.parentNode.removeChild(t),e._cleanTipClass(),e._element.removeAttribute("aria-describedby"),j.trigger(e._element,e.constructor.Event.HIDDEN),e._popper&&(e._popper.destroy(),e._popper=null)};if(!j.trigger(this._element,this.constructor.Event.HIDE).defaultPrevented){var r;if(t.classList.remove("show"),"ontouchstart"in document.documentElement&&(r=[]).concat.apply(r,document.body.children).forEach((function(e){return j.off(e,"mouseover",g)})),this._activeTrigger.click=!1,this._activeTrigger.focus=!1,this._activeTrigger.hover=!1,this.tip.classList.contains("fade")){var i=u(t);j.one(t,"transitionend",n),h(t,i)}else n();this._hoverState=""}}},o.update=function(){null!==this._popper&&this._popper.update()},o.isWithContent=function(){return Boolean(this.getTitle())},o.getTipElement=function(){if(this.tip)return this.tip;var e=document.createElement("div");return e.innerHTML=this.config.template,this.tip=e.children[0],this.tip},o.setContent=function(){var e=this.getTipElement();this.setElementContent(G.findOne(".tooltip-inner",e),this.getTitle()),e.classList.remove("fade","show")},o.setElementContent=function(e,t){if(null!==e)return"object"==typeof t&&d(t)?(t.jquery&&(t=t[0]),void(this.config.html?t.parentNode!==e&&(e.innerHTML="",e.appendChild(t)):e.textContent=t.textContent)):void(this.config.html?(this.config.sanitize&&(t=Et(t,this.config.allowList,this.config.sanitizeFn)),e.innerHTML=t):e.textContent=t)},o.getTitle=function(){var e=this._element.getAttribute("data-bs-original-title");return e||(e="function"==typeof this.config.title?this.config.title.call(this._element):this.config.title),e},o.updateAttachment=function(e){return"right"===e?"end":"left"===e?"start":e},o._getPopperConfig=function(e){var t=this,r={name:"flip",options:{altBoundary:!0}};return this.config.fallbackPlacements&&(r.options.fallbackPlacements=this.config.fallbackPlacements),n({},{placement:e,modifiers:[r,{name:"preventOverflow",options:{rootBoundary:this.config.boundary}},{name:"arrow",options:{element:"."+this.constructor.NAME+"-arrow"}},{name:"onChange",enabled:!0,phase:"afterWrite",fn:function(e){return t._handlePopperPlacementChange(e)}}],onFirstUpdate:function(e){e.options.placement!==e.placement&&t._handlePopperPlacementChange(e)}},this.config.popperConfig)},o._addAttachmentClass=function(e){this.getTipElement().classList.add("bs-tooltip-"+this.updateAttachment(e))},o._getContainer=function(){return!1===this.config.container?document.body:d(this.config.container)?this.config.container:G.findOne(this.config.container)},o._getAttachment=function(e){return Nt[e.toUpperCase()]},o._setListeners=function(){var e=this;this.config.trigger.split(" ").forEach((function(t){if("click"===t)j.on(e._element,e.constructor.Event.CLICK,e.config.selector,(function(t){return e.toggle(t)}));else if("manual"!==t){var n="hover"===t?e.constructor.Event.MOUSEENTER:e.constructor.Event.FOCUSIN,r="hover"===t?e.constructor.Event.MOUSELEAVE:e.constructor.Event.FOCUSOUT;j.on(e._element,n,e.config.selector,(function(t){return e._enter(t)})),j.on(e._element,r,e.config.selector,(function(t){return e._leave(t)}))}})),this._hideModalHandler=function(){e._element&&e.hide()},j.on(this._element.closest(".modal"),"hide.bs.modal",this._hideModalHandler),this.config.selector?this.config=n({},this.config,{trigger:"manual",selector:""}):this._fixTitle()},o._fixTitle=function(){var e=this._element.getAttribute("title"),t=typeof this._element.getAttribute("data-bs-original-title");(e||"string"!==t)&&(this._element.setAttribute("data-bs-original-title",e||""),!e||this._element.getAttribute("aria-label")||this._element.textContent||this._element.setAttribute("aria-label",e),this._element.setAttribute("title",""))},o._enter=function(e,t){var n=this.constructor.DATA_KEY;(t=t||T(e.delegateTarget,n))||(t=new this.constructor(e.delegateTarget,this._getDelegateConfig()),x(e.delegateTarget,n,t)),e&&(t._activeTrigger["focusin"===e.type?"focus":"hover"]=!0),t.getTipElement().classList.contains("show")||"show"===t._hoverState?t._hoverState="show":(clearTimeout(t._timeout),t._hoverState="show",t.config.delay&&t.config.delay.show?t._timeout=setTimeout((function(){"show"===t._hoverState&&t.show()}),t.config.delay.show):t.show())},o._leave=function(e,t){var n=this.constructor.DATA_KEY;(t=t||T(e.delegateTarget,n))||(t=new this.constructor(e.delegateTarget,this._getDelegateConfig()),x(e.delegateTarget,n,t)),e&&(t._activeTrigger["focusout"===e.type?"focus":"hover"]=!1),t._isWithActiveTrigger()||(clearTimeout(t._timeout),t._hoverState="out",t.config.delay&&t.config.delay.hide?t._timeout=setTimeout((function(){"out"===t._hoverState&&t.hide()}),t.config.delay.hide):t.hide())},o._isWithActiveTrigger=function(){for(var e in this._activeTrigger)if(this._activeTrigger[e])return!0;return!1},o._getConfig=function(e){var t=V.getDataAttributes(this._element);return Object.keys(t).forEach((function(e){Mt.has(e)&&delete t[e]})),e&&"object"==typeof e.container&&e.container.jquery&&(e.container=e.container[0]),"number"==typeof(e=n({},this.constructor.Default,t,"object"==typeof e&&e?e:{})).delay&&(e.delay={show:e.delay,hide:e.delay}),"number"==typeof e.title&&(e.title=e.title.toString()),"number"==typeof e.content&&(e.content=e.content.toString()),p(kt,e,this.constructor.DefaultType),e.sanitize&&(e.template=Et(e.template,e.allowList,e.sanitizeFn)),e},o._getDelegateConfig=function(){var e={};if(this.config)for(var t in this.config)this.constructor.Default[t]!==this.config[t]&&(e[t]=this.config[t]);return e},o._cleanTipClass=function(){var e=this.getTipElement(),t=e.getAttribute("class").match(St);null!==t&&t.length>0&&t.map((function(e){return e.trim()})).forEach((function(t){return e.classList.remove(t)}))},o._handlePopperPlacementChange=function(e){var t=e.state;t&&(this.tip=t.elements.popper,this._cleanTipClass(),this._addAttachmentClass(this._getAttachment(t.placement)))},i.jQueryInterface=function(e){return this.each((function(){var t=T(this,"bs.tooltip"),n="object"==typeof e&&e;if((t||!/dispose|hide/.test(e))&&(t||(t=new i(this,n)),"string"==typeof e)){if(void 0===t[e])throw new TypeError('No method named "'+e+'"');t[e]()}}))},t(i,null,[{key:"Default",get:function(){return Dt}},{key:"NAME",get:function(){return kt}},{key:"DATA_KEY",get:function(){return"bs.tooltip"}},{key:"Event",get:function(){return Lt}},{key:"EVENT_KEY",get:function(){return".bs.tooltip"}},{key:"DefaultType",get:function(){return Ct}}]),i}(R);y((function(){var e=v();if(e){var t=e.fn[kt];e.fn[kt]=Ot.jQueryInterface,e.fn[kt].Constructor=Ot,e.fn[kt].noConflict=function(){return e.fn[kt]=t,Ot.jQueryInterface}}}));var It="popover",Bt=new RegExp("(^|\\s)bs-popover\\S+","g"),Pt=n({},Ot.Default,{placement:"right",trigger:"click",content:"",template:''}),jt=n({},Ot.DefaultType,{content:"(string|element|function)"}),Rt={HIDE:"hide.bs.popover",HIDDEN:"hidden.bs.popover",SHOW:"show.bs.popover",SHOWN:"shown.bs.popover",INSERTED:"inserted.bs.popover",CLICK:"click.bs.popover",FOCUSIN:"focusin.bs.popover",FOCUSOUT:"focusout.bs.popover",MOUSEENTER:"mouseenter.bs.popover",MOUSELEAVE:"mouseleave.bs.popover"},zt=function(e){function n(){return e.apply(this,arguments)||this}r(n,e);var i=n.prototype;return i.isWithContent=function(){return this.getTitle()||this._getContent()},i.setContent=function(){var e=this.getTipElement();this.setElementContent(G.findOne(".popover-header",e),this.getTitle());var t=this._getContent();"function"==typeof t&&(t=t.call(this._element)),this.setElementContent(G.findOne(".popover-body",e),t),e.classList.remove("fade","show")},i._addAttachmentClass=function(e){this.getTipElement().classList.add("bs-popover-"+this.updateAttachment(e))},i._getContent=function(){return this._element.getAttribute("data-bs-content")||this.config.content},i._cleanTipClass=function(){var e=this.getTipElement(),t=e.getAttribute("class").match(Bt);null!==t&&t.length>0&&t.map((function(e){return e.trim()})).forEach((function(t){return e.classList.remove(t)}))},n.jQueryInterface=function(e){return this.each((function(){var t=T(this,"bs.popover"),r="object"==typeof e?e:null;if((t||!/dispose|hide/.test(e))&&(t||(t=new n(this,r),x(this,"bs.popover",t)),"string"==typeof e)){if(void 0===t[e])throw new TypeError('No method named "'+e+'"');t[e]()}}))},t(n,null,[{key:"Default",get:function(){return Pt}},{key:"NAME",get:function(){return It}},{key:"DATA_KEY",get:function(){return"bs.popover"}},{key:"Event",get:function(){return Rt}},{key:"EVENT_KEY",get:function(){return".bs.popover"}},{key:"DefaultType",get:function(){return jt}}]),n}(Ot);y((function(){var e=v();if(e){var t=e.fn[It];e.fn[It]=zt.jQueryInterface,e.fn[It].Constructor=zt,e.fn[It].noConflict=function(){return e.fn[It]=t,zt.jQueryInterface}}}));var Ft="scrollspy",qt={offset:10,method:"auto",target:""},Ut={offset:"number",method:"string",target:"(string|element)"},Ht=function(e){function i(t,n){var r;return(r=e.call(this,t)||this)._scrollElement="BODY"===t.tagName?window:t,r._config=r._getConfig(n),r._selector=r._config.target+" .nav-link, "+r._config.target+" .list-group-item, "+r._config.target+" .dropdown-item",r._offsets=[],r._targets=[],r._activeTarget=null,r._scrollHeight=0,j.on(r._scrollElement,"scroll.bs.scrollspy",(function(e){return r._process(e)})),r.refresh(),r._process(),r}r(i,e);var o=i.prototype;return o.refresh=function(){var e=this,t=this._scrollElement===this._scrollElement.window?"offset":"position",n="auto"===this._config.method?t:this._config.method,r="position"===n?this._getScrollTop():0;this._offsets=[],this._targets=[],this._scrollHeight=this._getScrollHeight(),G.find(this._selector).map((function(e){var t=l(e),i=t?G.findOne(t):null;if(i){var o=i.getBoundingClientRect();if(o.width||o.height)return[V[n](i).top+r,t]}return null})).filter((function(e){return e})).sort((function(e,t){return e[0]-t[0]})).forEach((function(t){e._offsets.push(t[0]),e._targets.push(t[1])}))},o.dispose=function(){e.prototype.dispose.call(this),j.off(this._scrollElement,".bs.scrollspy"),this._scrollElement=null,this._config=null,this._selector=null,this._offsets=null,this._targets=null,this._activeTarget=null,this._scrollHeight=null},o._getConfig=function(e){if("string"!=typeof(e=n({},qt,"object"==typeof e&&e?e:{})).target&&d(e.target)){var t=e.target.id;t||(t=a(Ft),e.target.id=t),e.target="#"+t}return p(Ft,e,Ut),e},o._getScrollTop=function(){return this._scrollElement===window?this._scrollElement.pageYOffset:this._scrollElement.scrollTop},o._getScrollHeight=function(){return this._scrollElement.scrollHeight||Math.max(document.body.scrollHeight,document.documentElement.scrollHeight)},o._getOffsetHeight=function(){return this._scrollElement===window?window.innerHeight:this._scrollElement.getBoundingClientRect().height},o._process=function(){var e=this._getScrollTop()+this._config.offset,t=this._getScrollHeight(),n=this._config.offset+t-this._getOffsetHeight();if(this._scrollHeight!==t&&this.refresh(),e>=n){var r=this._targets[this._targets.length-1];this._activeTarget!==r&&this._activate(r)}else{if(this._activeTarget&&e0)return this._activeTarget=null,void this._clear();for(var i=this._offsets.length;i--;)this._activeTarget!==this._targets[i]&&e>=this._offsets[i]&&(void 0===this._offsets[i+1]||e li > .active":".active";t=(t=G.find(i,r))[t.length-1]}var o=null;if(t&&(o=j.trigger(t,"hide.bs.tab",{relatedTarget:this._element})),!(j.trigger(this._element,"show.bs.tab",{relatedTarget:t}).defaultPrevented||null!==o&&o.defaultPrevented)){this._activate(this._element,r);var a=function(){j.trigger(t,"hidden.bs.tab",{relatedTarget:e._element}),j.trigger(e._element,"shown.bs.tab",{relatedTarget:t})};n?this._activate(n,n.parentNode,a):a()}}},i._activate=function(e,t,n){var r=this,i=(!t||"UL"!==t.nodeName&&"OL"!==t.nodeName?G.children(t,".active"):G.find(":scope > li > .active",t))[0],o=n&&i&&i.classList.contains("fade"),a=function(){return r._transitionComplete(e,i,n)};if(i&&o){var s=u(i);i.classList.remove("show"),j.one(i,"transitionend",a),h(i,s)}else a()},i._transitionComplete=function(e,t,n){if(t){t.classList.remove("active");var r=G.findOne(":scope > .dropdown-menu .active",t.parentNode);r&&r.classList.remove("active"),"tab"===t.getAttribute("role")&&t.setAttribute("aria-selected",!1)}e.classList.add("active"),"tab"===e.getAttribute("role")&&e.setAttribute("aria-selected",!0),b(e),e.classList.contains("fade")&&e.classList.add("show"),e.parentNode&&e.parentNode.classList.contains("dropdown-menu")&&(e.closest(".dropdown")&&G.find(".dropdown-toggle").forEach((function(e){return e.classList.add("active")})),e.setAttribute("aria-expanded",!0)),n&&n()},n.jQueryInterface=function(e){return this.each((function(){var t=T(this,"bs.tab")||new n(this);if("string"==typeof e){if(void 0===t[e])throw new TypeError('No method named "'+e+'"');t[e]()}}))},t(n,null,[{key:"DATA_KEY",get:function(){return"bs.tab"}}]),n}(R);j.on(document,"click.bs.tab.data-api",'[data-bs-toggle="tab"], [data-bs-toggle="pill"], [data-bs-toggle="list"]',(function(e){e.preventDefault(),(T(this,"bs.tab")||new Vt(this)).show()})),y((function(){var e=v();if(e){var t=e.fn.tab;e.fn.tab=Vt.jQueryInterface,e.fn.tab.Constructor=Vt,e.fn.tab.noConflict=function(){return e.fn.tab=t,Vt.jQueryInterface}}}));var Gt={animation:"boolean",autohide:"boolean",delay:"number"},Wt={animation:!0,autohide:!0,delay:5e3},Yt=function(e){function i(t,n){var r;return(r=e.call(this,t)||this)._config=r._getConfig(n),r._timeout=null,r._setListeners(),r}r(i,e);var o=i.prototype;return o.show=function(){var e=this;if(!j.trigger(this._element,"show.bs.toast").defaultPrevented){this._clearTimeout(),this._config.animation&&this._element.classList.add("fade");var t=function(){e._element.classList.remove("showing"),e._element.classList.add("show"),j.trigger(e._element,"shown.bs.toast"),e._config.autohide&&(e._timeout=setTimeout((function(){e.hide()}),e._config.delay))};if(this._element.classList.remove("hide"),b(this._element),this._element.classList.add("showing"),this._config.animation){var n=u(this._element);j.one(this._element,"transitionend",t),h(this._element,n)}else t()}},o.hide=function(){var e=this;if(this._element.classList.contains("show")&&!j.trigger(this._element,"hide.bs.toast").defaultPrevented){var t=function(){e._element.classList.add("hide"),j.trigger(e._element,"hidden.bs.toast")};if(this._element.classList.remove("show"),this._config.animation){var n=u(this._element);j.one(this._element,"transitionend",t),h(this._element,n)}else t()}},o.dispose=function(){this._clearTimeout(),this._element.classList.contains("show")&&this._element.classList.remove("show"),j.off(this._element,"click.dismiss.bs.toast"),e.prototype.dispose.call(this),this._config=null},o._getConfig=function(e){return e=n({},Wt,V.getDataAttributes(this._element),"object"==typeof e&&e?e:{}),p("toast",e,this.constructor.DefaultType),e},o._setListeners=function(){var e=this;j.on(this._element,"click.dismiss.bs.toast",'[data-bs-dismiss="toast"]',(function(){return e.hide()}))},o._clearTimeout=function(){clearTimeout(this._timeout),this._timeout=null},i.jQueryInterface=function(e){return this.each((function(){var t=T(this,"bs.toast");if(t||(t=new i(this,"object"==typeof e&&e)),"string"==typeof e){if(void 0===t[e])throw new TypeError('No method named "'+e+'"');t[e](this)}}))},t(i,null,[{key:"DefaultType",get:function(){return Gt}},{key:"Default",get:function(){return Wt}},{key:"DATA_KEY",get:function(){return"bs.toast"}}]),i}(R);return y((function(){var e=v();if(e){var t=e.fn.toast;e.fn.toast=Yt.jQueryInterface,e.fn.toast.Constructor=Yt,e.fn.toast.noConflict=function(){return e.fn.toast=t,Yt.jQueryInterface}}})),{Alert:F,Button:q,Carousel:X,Collapse:ee,Dropdown:vt,Modal:wt,Popover:zt,ScrollSpy:Ht,Tab:Vt,Toast:Yt,Tooltip:Ot}}));"use strict";function cimModel(){const e="http://iec.ch/TC57/2013/CIM-schema-cim16#",t="http://entsoe.eu/CIM/SchemaExtension/3/1#",n="http://iec.ch/TC57/61970-552/ModelDescription/1#",r="http://www.w3.org/1999/02/22-rdf-syntax-ns#",i='';let o={all:null},a=new Map,s=new Map,l="NODE_BREAKER";function c(e){let t=new DOMParser,n=[],r=[],a=[],s=[],l=[],c=[],d=null,h=null;function p(e){return u(e).then((function(e){if(0===n.length||0===r.length||0===a.length||0===s.length||0===l.length||0===c.length||null===d||null===h){let t=[].filter.call(e.children[0].children,(function(e){return"md:FullModel"===e.nodeName}))[0];if(void 0===t)return Promise.reject("error: invalid CGMES file.");let i=x.getAttribute(t,"md:Model.profile");i.textContent.includes("Equipment")&&(!1===i.textContent.includes("Boundary")?n.push(e):d=e),i.textContent.includes("DiagramLayout")&&r.push(e),i.textContent.includes("StateVariables")&&a.push(e),i.textContent.includes("Topology")&&(!1===i.textContent.includes("Boundary")?s.push(e):h=e),i.textContent.includes("SteadyStateHypothesis")&&l.push(e),i.textContent.includes("GeographicalLocation")&&c.push(e)}return Promise.resolve()}))}return function(u){let m=[];return u.forEach((function(e,t){let n=t.async("blob").then(p).catch((function(e){return Promise.reject(e)}));m.push(n)})),Promise.all(m).then((function(){if(n.length>0&&!1===e){let e=t.parseFromString(i,"application/xml");for(let t of n)for(let n of t.children[0].children)"md:FullModel"!==n.nodeName&&e.children[0].appendChild(n.cloneNode(!0));for(let t of r)for(let n of t.children[0].children)"md:FullModel"!==n.nodeName&&e.children[0].appendChild(n.cloneNode(!0));for(let t of a)for(let n of t.children[0].children)"md:FullModel"!==n.nodeName&&e.children[0].appendChild(n.cloneNode(!0));for(let t of s)for(let n of t.children[0].children)"md:FullModel"!==n.nodeName&&e.children[0].appendChild(n.cloneNode(!0));for(let t of l)for(let n of t.children[0].children)"md:FullModel"!==n.nodeName&&e.children[0].appendChild(n.cloneNode(!0));for(let t of c)for(let n of t.children[0].children)"md:FullModel"!==n.nodeName&&e.children[0].appendChild(n.cloneNode(!0));if(null!==d)for(let t of d.children[0].children)"md:FullModel"!==t.nodeName&&e.children[0].appendChild(t.cloneNode(!0));if(null!==h)for(let t of h.children[0].children)"md:FullModel"!==t.nodeName&&e.children[0].appendChild(t.cloneNode(!0));return o.all=e,f()}if(null===o.all||!1===e)return Promise.reject("Invalid CGMES file: no equipment description found.");if(null!==d){let e=d.children[0].children,t=[].filter.call(e,(function(e){return"cim:ConnectivityNode"===e.nodeName})).filter((e=>x.isBoundary(e))).length;return x.updateModel(d),null!==h&&x.updateModel(h),Promise.resolve("Loaded "+t+" boundary nodes.")}return Promise.reject("Invalid boundary file: no equipment boundary file found.")})).catch((function(t){return!1===e&&x.clear(),Promise.reject(t)}))}}function u(e){const t=new FileReader;return new Promise((function(n,r){t.onerror=function(){t.abort(),r(new DOMException("problem parsing input file."))},t.onload=function(){let e=new DOMParser,i=t.result,o=e.parseFromString(i,"application/xml");o.children.length>0&&"rdf:RDF"!==o.children[0].nodeName&&r(new DOMException("invalid input file.")),n(o)},t.readAsText(e)}))}function f(){let e=d();for(let t in e){let n=e[t],r=x.ID(n);if(null!==r&&(a.set("#"+r,n),void 0!==n.attributes)){let e=x.getLinks(n);for(let t of e){let e=t.localName+t.attributes[0].value,r=s.get(e);void 0===r?s.set(e,[n]):r.push(n)}}}for(let t in e){let n=e[t],r=n.attributes.getNamedItem("rdf:about");if(null!==r){let e=a.get(r.value);if(void 0===e)continue;for(let t of x.getAttributes(n))e.appendChild(t.cloneNode(!0));for(let t of x.getLinks(n)){e.appendChild(t.cloneNode(!0));let n=t.localName+t.attributes[0].value,r=s.get(n);void 0===r?s.set(n,[e]):r.push(e)}n.remove()}}return x.schema.buildSchema()}function d(){let e=[];for(let t of Object.keys(o))void 0!==o[t]&&null!==o[t]&&(e=e.concat([...o[t].children[0].children]));return e}function h(t,n){let i=void 0;void 0!==n&&(i=n.uuid);let s=o.all,l=s.createElementNS(e,t);return s.children[0].appendChild(l),void 0!==i?l.setAttributeNS(r,"rdf:ID",i):l.setAttributeNS(r,"rdf:ID",y()),a.set("#"+x.ID(l),l),l}function p(e){let t=h("cim:Terminal");return m(t,"cim:Terminal.ConductingEquipment",e),x.setAttribute(t,"cim:ACDCTerminal.connected","true"),t}function m(t,n,i){if(x.getTargets([t],n).length>0)return;let o=t.ownerDocument.createElementNS(e,n);t.appendChild(o),o.setAttributeNS(r,"rdf:resource","#"+x.ID(i));let a=o.localName+o.attributes[0].value,l=s.get(a);void 0===l?s.set(a,[t]):l.push(t),x.trigger("addLink",t,n,i)}function g(e,t){let n=x.schema.schemaInvLinksMap.get(t),r=new Map,i=[];for(let o of e){let e=x.ID(o),l=x.getLink(o,"cim:"+t);for(let t of l){let n=a.get(t.attributes.getNamedItem("rdf:resource").value);if(void 0!==n){let t=x.ID(n);i.push({source:o,target:n}),r.set(e+t,1)}}let c=s.get(n+"#"+e);if(void 0!==c)for(let t of c){let n=x.ID(t);void 0===r.get(e+n)&&i.push({source:o,target:t})}}return i}function b(e){let t=[];if(0===arguments.length){let e=[];void 0!==x.activeDiagram&&(e=x.getTargets([x.activeDiagram],"Diagram.DiagramElements")),t=g(e,"DiagramObject.IdentifiedObject")}else if(void 0!==x.activeDiagram){let n=x.getTargets(e,"IdentifiedObject.DiagramObjects");n=g(n,"DiagramObject.Diagram").filter((e=>e.target===x.activeDiagram)).map((e=>e.source)),t=g(n,"DiagramObject.IdentifiedObject")}return t}function v(e){let t=[];if(0===arguments.length){if(void 0!==x.activeDiagram){t=g(b().map((e=>e.target)),"ConductingEquipment.Terminals")}}else if(void 0!==x.activeDiagram){t=g(b(e).map((e=>e.target)),"ConductingEquipment.Terminals")}else t=g(e,"ConductingEquipment.Terminals");return t}function y(){let e=(new Date).getTime();return"_"+"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(t){let n=(e+16*Math.random())%16|0;return e=Math.floor(e/16),("x"==t?n:3&n|8).toString(16)}))}function _(e){return[].filter.call(e.children,(function(e){let t=e.attributes.getNamedItem("rdf:resource");return 0!==e.attributes.length&&null!==t&&"#"!==t.value.charAt(0)}))}function w(e,t){return _(e).filter((e=>e.nodeName===t))[0]}let x={fileName:null,activeDiagramName:"none",schema:new cimSchema,load(e){let t=Promise.resolve();if(x.fileName!==e.name){if(x.fileName=e.name,!e.name.endsWith(".zip")){return u(e).then((function(e){return o.all=e,f()})).catch((function(e){return x.clear(),Promise.reject(e)}))}t=JSZip.loadAsync(e).then(c(!1)).catch((function(e){return x.clear(),Promise.reject(e)}))}return t},newFile(e){let t=new DOMParser;return o.all=t.parseFromString(i,"application/xml"),x.fileName=e,f()},updateModel(e){let t=e.children[0].children;for(let e of t){if("md:FullModel"===e.nodeName)continue;let t=e.attributes.getNamedItem("rdf:ID");if(null===t&&(t=e.attributes.getNamedItem("rdf:about")),null===t)continue;let n=t.value;n.startsWith("#")&&(n=n.substring(1));let r=x.getObject(n);void 0===r&&(r=x.createObject(e.nodeName,{uuid:n}))}for(let e of t){if("md:FullModel"===e.nodeName)continue;let t=e.attributes.getNamedItem("rdf:ID");if(null===t&&(t=e.attributes.getNamedItem("rdf:about")),null===t)continue;let n=t.value;n.startsWith("#")&&(n=n.substring(1));let r=x.getObject(n);if(void 0===r)continue;let i=x.getAttributes(e);for(let e of i)x.setAttribute(r,e.nodeName,e.innerHTML);let o=x.getLinks(e);for(let e of o){let t=e.attributes.getNamedItem("rdf:resource").value.substring(1);x.setLink(r,e.nodeName,x.getObject(t))}}},loadBoundary(e){let t=Promise.resolve();return t=e.name.endsWith(".zip")?JSZip.loadAsync(e).then(c(!0)).catch((function(e){return Promise.reject(e)})):Promise.reject("Error: not a boundary file."),t},loadRemote(e){let t=Promise.resolve();return x.fileName!==decodeURI(e).substring(1)&&(x.fileName=decodeURI(e).substring(1),t=d3.xml(e).then((function(e){return o.all=e,f()})).catch((function(e){return x.clear(),Promise.reject(e)}))),t},save(){if(null===o.all)throw new Error("error: no CIM file loaded.");let e="";return e=(new XMLSerializer).serializeToString(o.all),e},saveAsCGMES(){if(null===o.all)return Promise.reject("error: no CIM file loaded.");let e=new XMLSerializer,t=new JSZip,r=null,a=[];for(let e of o.all.children[0].children){x.getLinks(e).forEach((function(t){let n=x.schema.checkLink(e,t.nodeName);if(n!==t.nodeName){x.getTargets([e],t.localName).forEach((function(t){a.push({s:t,l:n,t:e})}))}}))}a.forEach((function(e){x.setLink(e.s,e.l,e.t)})),r=o.all.children[0].cloneNode(!0).children;let s=["http://entsoe.eu/CIM/EquipmentCore/3/1"];"NODE_BREAKER"===l&&s.push("http://entsoe.eu/CIM/EquipmentOperation/3/1");let c=m("EQ",s,r,[]),u=m("DL",["http://entsoe.eu/CIM/DiagramLayout/3/1"],r,[c]),f=m("SV",["http://entsoe.eu/CIM/StateVariables/4/1"],r,[c]),d=m("TP",["http://entsoe.eu/CIM/Topology/4/1"],r,[c]),h=m("SSH",["http://entsoe.eu/CIM/SteadyStateHypothesis/1/1"],r,[c]),p=m("GL",["http://entsoe.eu/CIM/GeographicalLocation/2/1"],r,[c]);return t.file("EQ.xml",e.serializeToString(c)),t.file("DL.xml",e.serializeToString(u)),t.file("SV.xml",e.serializeToString(f)),t.file("TP.xml",e.serializeToString(d)),t.file("SSH.xml",e.serializeToString(h)),t.file("GL.xml",e.serializeToString(p)),t.generateAsync({type:"blob",compression:"DEFLATE"});function m(e,t,r,o){let a=[].filter.call(r,(function(t){return null!==x.schema.getSchemaObject(t.localName,e)})),s=function(e,t){let r=(new DOMParser).parseFromString(i,"application/xml"),o=document.createElementNS(n,"md:FullModel");return r.children[0].appendChild(o),o.setAttribute("rdf:about","urn:uuid:"+y().substring(1)),e.forEach((function(e){let t=o.ownerDocument.createElementNS(n,"md:Model.profile");t.innerHTML=e,o.appendChild(t)})),t.forEach((function(e){let t=[].filter.call(e.children[0].children,(function(e){return"md:FullModel"===e.nodeName}))[0],n=o.ownerDocument.createElement("md:Model.DependentOn");n.setAttribute("rdf:resource",t.attributes.getNamedItem("rdf:about").value),o.appendChild(n)})),r}(t,o);return function(e,t,n){for(let r in t){let i=t[r].cloneNode();x.getAttributes(t[r]).forEach((function(e){void 0!==x.schema.getSchemaAttribute(i.localName,e.localName,n)&&i.appendChild(e)})),x.getLinks(t[r]).forEach((function(e){void 0!==x.schema.getSchemaLink(i.localName,e.localName,n)&&i.appendChild(e)})),_(t[r]).forEach((function(e){void 0!==x.schema.getSchemaAttribute(i.localName,e.localName,n)&&i.appendChild(e)}));let o=x.schema.isDescription(i,n),a=x.schema.isConcrete(i,n);if(!0===o&&null!==x.ID(i)){let e=x.ID(i);i.removeAttribute("rdf:ID");let t=i.ownerDocument.createAttribute("rdf:about");t.value="#"+e,i.setAttributeNode(t)}!0===a&&(!1===o||i.children.length>0)&&e.children[0].appendChild(i)}}(s,a,e),s}},export(){let e=new DOMParser,t=new XMLSerializer,n=e.parseFromString(i,"application/xml");if(void 0===x.activeDiagram)return t.serializeToString(n);n.children[0].appendChild(x.activeDiagram.cloneNode(!0));let r=x.getTargets([x.activeDiagram],"Diagram.DiagramElements");for(let e of r)n.children[0].appendChild(e.cloneNode(!0));let o=x.getTargets(r,"DiagramObject.IdentifiedObject");for(let e of o)n.children[0].appendChild(e.cloneNode(!0));let a=x.getTargets(r,"DiagramObject.DiagramObjectPoints");for(let e of a)n.children[0].appendChild(e.cloneNode(!0));let s=x.getTerminals(o);for(let e of s)n.children[0].appendChild(e.cloneNode(!0));let l=x.getNodes();for(let e of l)n.children[0].appendChild(e.cloneNode(!0));let c=x.getLinkedObjects(["cim:Substation","cim:Line"],["EquipmentContainer.Equipments"]),u=c["cim:Substation"];for(let e of u)n.children[0].appendChild(e.cloneNode(!0));let f=c["cim:Line"];for(let e of f)n.children[0].appendChild(e.cloneNode(!0));let d=x.getTargets(o,"ConductingEquipment.BaseVoltage");for(let e of d)n.children[0].appendChild(e.cloneNode(!0));let h=x.getTargets(o,"PowerTransformer.PowerTransformerEnd");for(let e of h)n.children[0].appendChild(e.cloneNode(!0));let p=x.getTargets(s,"ACDCTerminal.Measurements");for(let e of p)n.children[0].appendChild(e.cloneNode(!0));let m=x.getTargets(p,"Analog.AnalogValues");for(let e of m)n.children[0].appendChild(e.cloneNode(!0));return t.serializeToString(n)},getDiagramList:()=>x.getObjects(["cim:Diagram"])["cim:Diagram"].map((e=>(void 0===x.getAttribute(e,"cim:IdentifiedObject.name")&&x.setAttribute(e,"cim:IdentifiedObject.name","unnamed diagram"),x.getAttribute(e,"cim:IdentifiedObject.name")))).map((e=>e.textContent)),getObjects(e){let t={},n=d();for(let n of e)t[n]=[];return t=[].reduce.call(n,(function(e,t){return void 0!==e[t.nodeName]&&e[t.nodeName].push(t),e}),t),t},getSubObjects:e=>d().filter((function(t){return!0===x.schema.isA(e,t)})),getGraphicObjects(e){let t={},n=b().map((e=>e.target)),r=new Set(n);for(let n of e)t[n]=[];return t=[...r].reduce((function(e,t){return void 0!==e[t.nodeName]&&e[t.nodeName].push(t),e}),t),t},getNodes(){let e="cim:ConnectivityNode";"BUS_BRANCH"===l&&(e="cim:TopologicalNode");let t=x.getObjects([e])[e],n=x.getGraphicObjects([e])[e],r=t.filter((e=>-1===n.indexOf(e)));return r=r.filter((function(e){let t=x.getBusbar(e),n=x.getEquipments(e);return null!==t||n.length>1})),n.concat(r)},getConnectors(e){let t={};for(let n of e){let e=x.getObjects([n])[n],r=x.getGraphicObjects([n])[n],i=e.filter((e=>-1===r.indexOf(e)));i=i.filter((function(e){let t=x.getNode(e);if(null!==t){return x.getDiagramObjects([t]).length>0}return!1})),t[n]=r.concat(i)}return t},getLinkedObjects(e,t){let n={};for(let r of e)n[r]=x.getObjects([r])[r].filter((function(e){let n=[e],r=[];for(let r of t){let t=r.split("/"),i=[e];for(let e=0;e0}));return n},getTerminals(e){let t=v(e).map((e=>e.target));return t=[...new Set(t)],t},getObject:e=>a.get("#"+e),getAttributes(e){if(null!=e)return[].filter.call(e.children,(function(e){return 0===e.attributes.length}))},getAttribute(e,t){if(void 0===e)return;if(null===e)return;return x.getAttributes(e).filter((e=>e.nodeName===t))[0]},setAttribute(n,r,i){let o=x.getAttribute(n,r);if(void 0!==o)o.innerHTML=i;else{let a=e;r.startsWith("entsoe:")&&(a=t),o=n.ownerDocument.createElementNS(a,r),o.innerHTML=i,n.appendChild(o)}x.trigger("setAttribute",n,r,i)},setEnum(t,n,r){let i=w(t,n);if(void 0===i){i=t.ownerDocument.createElement(n);let e=t.ownerDocument.createAttribute("rdf:resource");e.nodeValue="#",i.setAttributeNode(e),t.appendChild(i)}i.attributes[0].value=e+r,x.trigger("setEnum",t,n,r)},createObject(e,t){let n=h(e,t);if(x.schema.isA("IdentifiedObject",n)&&x.setAttribute(n,"cim:IdentifiedObject.name","new1"),!1===x.schema.isA("ConductingEquipment",n))return x.trigger("createObject",n),n;let r=2,i=null;void 0!==t&&(void 0!==t.windNum&&(r=t.windNum),void 0!==t.node&&(i=t.node));let o=p(n),a=null,s=null;if("cim:ACLineSegment"!==e&&"cim:Breaker"!==e&&"cim:Disconnector"!==e&&"cim:LoadBreakSwitch"!==e&&"cim:Junction"!==e&&"cim:PowerTransformer"!==e||(a=p(n)),"cim:PowerTransformer"===e&&3===r&&(s=p(n)),"cim:BusbarSection"===e){let e="ConnectivityNode";"BUS_BRANCH"===l&&(e="TopologicalNode"),null===i&&(i=h("cim:"+e)),m(o,"cim:Terminal."+e,i)}if("cim:PowerTransformer"===e){let e=h("cim:PowerTransformerEnd"),t=h("cim:PowerTransformerEnd");if(x.setAttribute(e,"cim:IdentifiedObject.name","winding1"),x.setAttribute(t,"cim:IdentifiedObject.name","winding2"),m(n,"cim:PowerTransformer.PowerTransformerEnd",e),m(n,"cim:PowerTransformer.PowerTransformerEnd",t),m(e,"cim:TransformerEnd.Terminal",o),m(t,"cim:TransformerEnd.Terminal",a),3===r){let e=h("cim:PowerTransformerEnd");x.setAttribute(e,"cim:IdentifiedObject.name","winding3"),m(n,"cim:PowerTransformer.PowerTransformerEnd",e),m(e,"cim:TransformerEnd.Terminal",s)}}return x.trigger("createObject",n),n},deleteObjects(e){let t=[],n=[];for(let s of e){"cim:ConnectivityNode"!==s.nodeName&&"cim:TopologicalNode"!==s.nodeName||(n=n.concat(o(s))),"cim:BusbarSection"===s.nodeName&&(n=n.concat(i(s)));let e=x.getLinks(s);for(let i of e){let e=a.get(i.attributes.getNamedItem("rdf:resource").value),o=i.nodeName;void 0!==e&&(r(s,e)&&n.push(e),t.push({s:s,l:o,t:e}))}}for(let[i,o]of s){let s=i.split("#"),l="cim:"+s[0],c="#"+s[1],u=a.get(c);if(e.indexOf(u)>-1)for(let e of o)t.push({s:e,l:l,t:u}),r(u,e)&&n.push(e)}for(let e of t)x.removeLink(e.s,e.l,e.t);n.length>0&&x.deleteObjects(n);for(let t of e){let e=x.ID(t),n=t.localName;a.delete("#"+e),t.remove(),x.trigger("deleteObject",e,n)}function r(e,t){return!(!x.schema.isA("ConductingEquipment",e)||"cim:Terminal"!==t.nodeName)||("cim:DiagramObjectPoint"===t.nodeName||("cim:DiagramObjectPoint"!==e.nodeName&&"cim:DiagramObject"===t.nodeName||("cim:PowerTransformer"===e.nodeName&&"cim:PowerTransformerEnd"===t.nodeName||("cim:GeographicalRegion"===e.nodeName&&"cim:SubGeographicalRegion"===t.nodeName||("cim:SubGeographicalRegion"===e.nodeName&&"cim:Substation"===t.nodeName||("cim:Substation"===e.nodeName&&"cim:VoltageLevel"===t.nodeName||"cim:VoltageLevel"===e.nodeName&&"cim:Bay"===t.nodeName))))))}function i(e){let t="ConnectivityNode";if("BUS_BRANCH"===l&&(t="TopologicalNode"),"cim:BusbarSection"===e.nodeName){let n=x.getTargets([e],"ConductingEquipment.Terminals");return x.getTargets(n,"Terminal."+t)}return[]}function o(e){let t="ConnectivityNode.Terminals";"BUS_BRANCH"===l&&(t="TopologicalNode.Terminal");let n=x.getTargets([e],t);return x.getTargets(n,"Terminal.ConductingEquipment").filter((e=>"cim:BusbarSection"===e.nodeName))}},deleteObject(e){x.deleteObjects([e])},getNode(e){let t="ConnectivityNode";if("BUS_BRANCH"===l&&(t="TopologicalNode"),"cim:BusbarSection"===e.nodeName){let n=x.getTargets([e],"ConductingEquipment.Terminals"),r=x.getTargets(n,"Terminal."+t);return 0===r.length?null:r[0]}return null},getBusbar(e){let t="ConnectivityNode.Terminals";"BUS_BRANCH"===l&&(t="TopologicalNode.Terminal");let n=x.getTargets([e],t),r=x.getTargets(n,"Terminal.ConductingEquipment").filter((e=>"BusbarSection"===e.localName)),i=x.getDiagramObjects([e].concat(r));return r.length>0&&i.length>0?r[0]:null},deleteFromDiagram(e){let t=x.ID(e),n=x.getDiagramObjects([e]),r="ConnectivityNode";if("BUS_BRANCH"===l&&(r="TopologicalNode"),"BusbarSection"===e.localName){let t=x.getNode(e);n=n.concat(x.getDiagramObjects([t]))}if(e.localName===r){let t=x.getBusbar(e);null!==t&&(n=n.concat(x.getDiagramObjects([t])))}let i=x.getTargets(n,"DiagramObject.DiagramObjectPoints");for(let e of n)x.deleteObject(e);for(let e of i)x.deleteObject(e);x.trigger("deleteFromDiagram",t)},addToActiveDiagram(e,t){let n=h("cim:DiagramObject");for(let r of t){let t=h("cim:DiagramObjectPoint");x.setAttribute(t,"cim:DiagramObjectPoint.xPosition",r.x+e.x),x.setAttribute(t,"cim:DiagramObjectPoint.yPosition",r.y+e.y),x.setAttribute(t,"cim:DiagramObjectPoint.sequenceNumber",r.seq),m(t,"cim:DiagramObjectPoint.DiagramObject",n)}void 0!==e.rotation&&x.setAttribute(n,"cim:DiagramObject.rotation",e.rotation),m(n,"cim:DiagramObject.IdentifiedObject",e),m(n,"cim:DiagramObject.Diagram",x.activeDiagram),x.trigger("addToActiveDiagram",e)},updateActiveDiagram(e,t){let n=x.getDiagramObjects([e]);if(("cim:ConnectivityNode"===e.nodeName||"cim:TopologicalNode"===e.nodeName)&&0===n.length){let t=x.getEquipments(e).filter((e=>"BusbarSection"===e.localName))[0];void 0!==t&&(n=x.getDiagramObjects([t]))}for(let t of n)x.setAttribute(t,"cim:DiagramObject.rotation",e.rotation);let r=x.getTargets(n,"DiagramObject.DiagramObjectPoints");if(r.length>0){for(let t of r){let n=1,r=x.getAttribute(t,"cim:DiagramObjectPoint.sequenceNumber");void 0!==r&&(n=parseInt(r.innerHTML));let i=e.lineData.filter((e=>e.seq===n))[0];x.getAttribute(t,"cim:DiagramObjectPoint.xPosition").innerHTML=i.x+e.x,x.getAttribute(t,"cim:DiagramObjectPoint.yPosition").innerHTML=i.y+e.y}x.trigger("updateActiveDiagram",e)}else x.addToActiveDiagram(e,e.lineData)},getLinks:e=>[].filter.call(e.children,(function(e){let t=e.attributes.getNamedItem("rdf:resource");return 0!==e.attributes.length&&null!==t&&"#"===t.value.charAt(0)})),getLink:(e,t)=>x.getLinks(e).filter((e=>e.nodeName===t)),getEnum(e,t){let n=w(e,t),r=void 0;return void 0!==n&&(r=n.attributes.getNamedItem("rdf:resource").value.split("#")[1].split(".")[1]),r},setLink(e,t,n){let r=x.getTargets([e],t.split(":")[1]);for(let n of r)x.removeLink(e,t,n);m(e,t,n)},removeLink(e,t,n){i(x.getLink(e,t),e,n);let r=x.schema.schemaInvLinksMap.get(t.split(":")[1]);if(void 0!==r){i(x.getLink(n,"cim:"+r),n,e)}function i(e,t,n){for(let r of e){let e=r.attributes.getNamedItem("rdf:resource").value;if(e==="#"+x.ID(n)){let n=r.localName+e,i=s.get(n);r.remove(),1===i.length?s.delete(n):i.splice(i.indexOf(t),1)}}}x.trigger("removeLink",e,t,n)},getTargets(e,t){let n=g(e,t).map((e=>e.target));return[...new Set(n)]},getDiagramObjects(e){let t=b(e).map((e=>e.source));return[...new Set(t)]},getEquipments(e){let t="ConnectivityNode.Terminals";"BUS_BRANCH"===l&&(t="TopologicalNode.Terminal");let n=x.getTargets([e],t),r=x.getTargets(n,"Terminal.ConductingEquipment");return r=v(r).map((e=>e.source)),[...new Set(r)]},selectDiagram(e){e!==x.activeDiagramName&&(x.activeDiagramName=e,x.activeDiagram=x.getObjects(["cim:Diagram"])["cim:Diagram"].filter((e=>x.getAttribute(e,"cim:IdentifiedObject.name").textContent===x.activeDiagramName))[0]),void 0===x.activeDiagram&&(x.activeDiagram=h("cim:Diagram"),x.setAttribute(x.activeDiagram,"cim:IdentifiedObject.name",e),x.activeDiagramName=e,x.trigger("createdDiagram")),x.trigger("changedDiagram")},isBoundary(e){let t=!1,n=x.getAttribute(e,"entsoe:ConnectivityNode.boundaryPoint");return void 0!==n&&"true"===n.textContent&&(t=!0),t},getMode:()=>l,setMode(e){"NODE_BREAKER"!==e&&"BUS_BRANCH"!==e||(l=e),x.trigger("setMode",l)},ID(e){if(null==e)return null;if(void 0===e.attributes)return null;{let t=e.attributes.getNamedItem("rdf:ID");return null===t?null:t.value}},clear(){o.all=null,x.fileName=null,a=new Map,s=new Map}};return observable(x),x}function cimSchema(){let e={EQ:null,DL:null,SV:null,TP:null,SSH:null,GL:null};let t=new Map,n=new Map,r=new Map;function i(e,t){let n=[],r=o.getSchemaObject(e,t);if(null===r)return n;let a=[].filter.call(r.children,(function(e){return"rdfs:subClassOf"===e.nodeName}))[0];if(void 0!==a){let e=a.attributes[0].value.substring(1);n.push(e),n=n.concat(i(e,t))}return n}let o={schemaInvLinksMap:new Map,buildSchema(){return null===e.EQ?d3.xml("rdf-schema/EquipmentProfileCoreShortCircuitOperationRDFSAugmented-v2_4_15-16Feb2016.rdf").then((function(n){return e.EQ=n,t(e.EQ),d3.xml("rdf-schema/DiagramLayoutProfileRDFSAugmented-v2_4_15-16Feb2016.rdf")})).then((function(n){return e.DL=n,t(e.DL),d3.xml("rdf-schema/StateVariablesProfileRDFSAugmented-v2_4_15-16Feb2016.rdf")})).then((function(n){return e.SV=n,t(e.SV),d3.xml("rdf-schema/TopologyProfileRDFSAugmented-v2_4_15-16Feb2016.rdf")})).then((function(n){return e.TP=n,t(e.TP),d3.xml("rdf-schema/SteadyStateHypothesisProfileRDFSAugmented-v2_4_15-16Feb2016.rdf")})).then((function(n){return e.SSH=n,t(e.SSH),d3.xml("rdf-schema/GeographicalLocationProfileRDFSAugmented-v2_4_15-16Feb2016.rdf")})).then((function(n){e.GL=n,t(e.GL)})).catch((function(e){return Promise.reject(e)})):Promise.resolve();function t(e){let t=e.children[0].children;for(let e in t){let n=t[e];if(void 0===n.children)continue;let r=[].filter.call(n.children,(function(e){return"cims:inverseRoleName"===e.nodeName}))[0];void 0!==r&&o.schemaInvLinksMap.set(n.attributes[0].value.substring(1),r.attributes[0].value.substring(1))}}},getSchemaObject(t,n){let i=null;for(let o of Object.keys(e)){if(void 0!==n&&n!==o)continue;let a=r.get(o+t);if(void 0!==a){i=a;break}let s=e[o].children[0].children;if(a=[].filter.call(s,(function(e){return e.attributes[0].value==="#"+t}))[0],void 0!==a){i=a,r.set(o+t,a);break}}return i},getSchemaEnumValues(t,n){let r="EQ";void 0!==n&&(r=n);let i=[].filter.call(t.children,(function(e){return"rdfs:range"===e.nodeName}))[0].attributes.getNamedItem("rdf:resource").value.substring(1),o=e[r].children[0].children;return[].filter.call(o,(function(e){return e.attributes[0].value.startsWith("#"+i+".")})).map((e=>[].filter.call(e.children,(function(e){return"rdfs:label"===e.nodeName}))[0].textContent))},getSchemaEnumName:e=>[].filter.call(e.children,(function(e){return"rdfs:range"===e.nodeName}))[0].attributes.getNamedItem("rdf:resource").value.substring(1),getSchemaAttributes(n,r){let o=n,a="EQ";void 0!==r&&(a=r),o+=a;let s=t.get(o);if(void 0===s){let r=e[a].children[0].children;s=[].filter.call(r,(function(e){return e.attributes.getNamedItem("rdf:about").value.startsWith("#"+n+".")}));let l=i(n,a);for(let e in l)s=s.concat([].filter.call(r,(function(t){return t.attributes.getNamedItem("rdf:about").value.startsWith("#"+l[e]+".")})));s=s.filter((function(e){let t=e.attributes.getNamedItem("rdf:about").value;t=t.substring(t.indexOf("#"));let n=!1,r=t.split(".")[1];return void 0!==r&&(n=r.toLowerCase().charAt(0)===r.charAt(0)),n})),t.set(o,s)}return s},getSchemaAttribute:(e,t,n)=>o.getSchemaAttributes(e,n).filter((e=>e.attributes[0].value.substring(1)===t))[0],isEnum:e=>void 0===[].filter.call(e.children,(function(e){return"cims:dataType"===e.nodeName}))[0],getSchemaAttributeType(e){let t="none",n="none";if(o.isEnum(e))return["#Enum",t,n];let r=[].filter.call(e.children,(function(e){return"cims:dataType"===e.nodeName}))[0].attributes.getNamedItem("rdf:resource").value,i=o.getSchemaObject(r.substring(1));if("CIMDatatype"===[].filter.call(i.children,(function(e){return"cims:stereotype"===e.nodeName}))[0].textContent){let e=o.getSchemaObject(r.substring(1)+".value"),i=o.getSchemaObject(r.substring(1)+".unit"),a=o.getSchemaObject(r.substring(1)+".multiplier");if(r=[].filter.call(e.children,(function(e){return"cims:dataType"===e.nodeName}))[0].attributes.getNamedItem("rdf:resource").value,null!==i&&(t=[].filter.call(i.children,(function(e){return"cims:isFixed"===e.nodeName}))[0].attributes.getNamedItem("rdfs:Literal").value),null!==a){let e=[].filter.call(a.children,(function(e){return"cims:isFixed"===e.nodeName}))[0];void 0!==e&&(n=e.attributes.getNamedItem("rdfs:Literal").value)}}return[r,t,n]},getSchemaStereotype(e){let t=[].filter.call(e.children,(function(e){return"cims:stereotype"===e.nodeName&&""!==e.textContent}));return t.length>0?t[0].textContent:null},getSchemaLinks(t,r){let o=t;o+=void 0!==r?r:"EQ";let a=n.get(o);if(void 0===a){let s=e.EQ;void 0!==r&&(s=e[r]);let l=s.children[0].children;a=[].filter.call(l,(function(e){return e.attributes[0].value.startsWith("#"+t+".")}));let c=i(t);for(let e in c)a=a.concat([].filter.call(l,(function(t){return t.attributes[0].value.startsWith("#"+c[e]+".")})));a=a.filter((function(e){let t=!1,n=e.attributes[0].value.split(".")[1];return void 0!==n&&(t=n.toLowerCase().charAt(0)!==n.charAt(0)),t})),n.set(o,a)}return a},getAllSchemasLinks(t){let n=[];return Object.keys(e).forEach((function(e){n=n.concat(o.getSchemaLinks(t,e))})),n},getSchemaLink:(e,t,n)=>o.getSchemaLinks(e,n).filter((e=>e.attributes[0].value.substring(1)===t))[0],getAllSchemasLink:(e,t)=>o.getAllSchemasLinks(e).filter((e=>e.attributes[0].value.substring(1)===t))[0],isA:(e,t)=>t.localName===e||!(i(t.localName).indexOf(e)<0),isConcrete(e,t){let n=!1,r=o.getSchemaObject(e.localName,t);return[].filter.call(r.children,(function(e){return"cims:stereotype"===e.nodeName})).forEach((function(e){let t=e.attributes.getNamedItem("rdf:resource");if(null!==t){"http://iec.ch/TC57/NonStandard/UML#concrete"===t.value&&(n=!0)}})),n},isDescription(e,t){let n=!1,r=o.getSchemaObject(e.localName,t);return[].filter.call(r.children,(function(e){return"cims:stereotype"===e.nodeName})).forEach((function(e){"Description"===e.textContent&&(n=!0)})),n},checkLink(e,t){let n=t,r=o.getAllSchemasLink(e.localName,t.split(":")[1]);if(void 0!==r){if("No"===[].filter.call(r.children,(function(e){return"cims:AssociationUsed"===e.nodeName}))[0].textContent){n="cim:"+o.schemaInvLinksMap.get(t.split(":")[1])}}return n},getLinkDomain(e){if(void 0===e)return null;if(null===e)return null;let t=[].filter.call(e.children,(function(e){return"rdfs:domain"===e.nodeName}))[0];return void 0===t?null:t.attributes.getNamedItem("rdf:resource").value.substring(1)},getLinkRange(e){if(void 0===e)return null;if(null===e)return null;let t=[].filter.call(e.children,(function(e){return"rdfs:range"===e.nodeName}))[0];return void 0===t?null:t.attributes.getNamedItem("rdf:resource").value.substring(1)}};return o}function topologyProcessor(e){return{calcTopology(){let t=[],n=e.getObjects(["cim:TopologicalNode"])["cim:TopologicalNode"];"BUS_BRANCH"===e.getMode()&&n.forEach((function(t){let n=e.createObject("cim:ConnectivityNode");e.getTargets([t],"TopologicalNode.Terminal").forEach((function(t){e.setLink(t,"cim:Terminal.ConnectivityNode",n)}))})),e.deleteObjects(n),n=[];let r=[],i=e.getObjects(["cim:ConnectivityNode"])["cim:ConnectivityNode"];for(;i.length>0;){let e=o(i[0]);i=i.filter((t=>e.indexOf(t)<0)),r.push(e)}function o(t){let n=new Set,r=-1;for(n.add(t);r!==n.size;){r=n.size;let t=e.getTargets([...n],"ConnectivityNode.Terminals"),i=e.getTargets(t,"Terminal.ConductingEquipment").filter((function(t){return!0===e.schema.isA("Switch",t)}));i=i.filter((function(t){let n=!0,r=e.getAttribute(t,"cim:Switch.open");return void 0!==r&&(n="false"===r.textContent),n}));let o=e.getTargets(i,"ConductingEquipment.Terminals"),a=e.getTargets(o,"Terminal.ConnectivityNode");for(let e of a)n.add(e)}return[...n]}return r.forEach((function(n){let r=e.createObject("cim:TopologicalNode");n.forEach((function(t){e.setLink(t,"cim:ConnectivityNode.TopologicalNode",r)}));let i=e.getTargets(n,"ConnectivityNode.Terminals"),o=e.getTargets(i,"Terminal.ConductingEquipment"),a=e.getTargets(o,"ConductingEquipment.BaseVoltage");if(a.length>0)e.setLink(r,"cim:TopologicalNode.BaseVoltage",a[0]);else{let t=e.getTargets(i,"Terminal.TransformerEnd");if(a=e.getTargets(t,"TransformerEnd.BaseVoltage"),a.length>0)console.log(t),e.setLink(r,"cim:TopologicalNode.BaseVoltage",a[0]);else{let t=e.getTargets(o,"Equipment.EquipmentContainer"),n=t.filter((t=>e.schema.isA("VoltageLevel",t)));if(a=e.getTargets(n,"VoltageLevel.BaseVoltage"),a.length>0)e.setLink(r,"cim:TopologicalNode.BaseVoltage",a[0]);else{let i=t.filter((t=>e.schema.isA("Bay",t)));n=e.getTargets(i,"Bay.VoltageLevel"),a=e.getTargets(n,"VoltageLevel.BaseVoltage"),a.length>0&&e.setLink(r,"cim:TopologicalNode.BaseVoltage",a[0])}}}i.forEach((function(t){e.setLink(t,"cim:Terminal.TopologicalNode",r),void 0===e.getAttribute(t,"cim:ACDCTerminal.connected")&&e.setAttribute(t,"cim:ACDCTerminal.connected","true")})),t.push(r)})),t},getTerminals(t){let n=[];return n=e.schema.isA("TopologicalNode",t)?e.getTargets([t],"TopologicalNode.Terminal"):e.schema.isA("TransformerEnd",t)?e.getTargets([t],"TransformerEnd.Terminal"):e.getTargets([t],"ConductingEquipment.Terminals"),n=n.filter((function(t){let n=e.getAttribute(t,"cim:ACDCTerminal.connected");return void 0!==n&&"true"===n.textContent})),n}}} diff --git a/js/cimDiagramControls.riot b/js/cimDiagramControls.riot index d5eac73..d3df997 100644 --- a/js/cimDiagramControls.riot +++ b/js/cimDiagramControls.riot @@ -23,23 +23,22 @@
                          -