diff --git a/python/inspectus/static/css/charts.css b/python/inspectus/static/css/charts.css index dbe40c5..9ac3e59 100644 --- a/python/inspectus/static/css/charts.css +++ b/python/inspectus/static/css/charts.css @@ -1 +1,140 @@ -.attention-visualization{color:#000;background-color:#fff}.attention-visualization .menu{background-color:#eee;color:#000}.attention-visualization .menu pre{color:#000;background-color:#eee}.attention-visualization svg text{fill:#000}.attention-visualization.dark-theme{color:#fff;background-color:#000}.attention-visualization.dark-theme .menu{background-color:#333;color:#fff}.attention-visualization.dark-theme .menu pre{color:#fff;background-color:#333}.attention-visualization.dark-theme svg text{fill:#fff}.attention-visualization{font-family:"Roboto Light","Ubuntu Light","Ubuntu",monospace;overflow-y:scroll}.attention-visualization .title{padding-top:10px;padding-bottom:5px;font-size:.8rem}.attention-visualization .title.inline{display:inline-block}.attention-visualization .select-container{padding-top:10px;padding-bottom:5px}.attention-visualization .select-container select{margin-left:10px}.attention-visualization .double-select{display:flex;flex-direction:row;gap:30px}.attention-visualization .double-select .select-container{width:fit-content}.attention-visualization .matrix{margin-bottom:20px}.attention-visualization .matrix .label text{dominant-baseline:central;text-anchor:end;font-family:monospace}.attention-visualization .text-tokens{margin-bottom:10px}.attention-visualization .text-tokens .token{font-family:monospace;display:inline-block;white-space:pre;padding:2px 5px;user-select:none;cursor:pointer;margin-bottom:10px;background-clip:padding-box !important}.attention-visualization .text-tokens .token.new-line{opacity:.6}.attention-visualization .token-value-container{padding-bottom:100px;width:calc(100% - 20px)}.attention-visualization .token-value-container.padding-less .token{border-left:none !important;padding:0;margin-bottom:3px}.attention-visualization .dimension-values{margin-bottom:20px}.attention-visualization .dimension-values .value{font-family:monospace;white-space:pre;display:inline-block;margin:2px;padding:3px 5px;font-size:10px;text-align:center;user-select:none;cursor:pointer;width:3rem}.attention-visualization .hover-container{position:relative;display:inline-block}.attention-visualization .menu{display:none;position:absolute;width:max-content;box-shadow:0px 8px 16px 0px rgba(0,0,0,.2);z-index:1;min-width:100px;max-width:50vw;padding:5px;white-space:nowrap}.attention-visualization .menu pre{background-color:rgba(0,0,0,0);text-wrap:wrap}.attention-visualization .menu.right-align{right:0;left:auto}.attention-visualization .hover-container:hover .menu{display:block}.attention-visualization .hover-container:hover{border:1px solid #878686} +/*!***********************************************************************************************************!*\ + !*** css ./node_modules/css-loader/dist/cjs.js!./node_modules/sass-loader/dist/cjs.js!./scss/charts.scss ***! + \***********************************************************************************************************/ +.attention-visualization { + color: #000000; + background-color: #ffffff; +} +.attention-visualization .menu { + background-color: #eee; + color: #000000; +} +.attention-visualization .menu pre { + color: #000000; + background-color: #eee; +} +.attention-visualization svg text { + fill: #000000; +} +.attention-visualization.dark-theme { + color: #ffffff; + background-color: #000000; +} +.attention-visualization.dark-theme .menu { + background-color: #333; + color: #ffffff; +} +.attention-visualization.dark-theme .menu pre { + color: #ffffff; + background-color: #333; +} +.attention-visualization.dark-theme svg text { + fill: #ffffff; +} + +.attention-visualization { + font-family: "Roboto Light", "Ubuntu Light", "Ubuntu", monospace; + overflow-y: scroll; +} +.attention-visualization .title { + padding-top: 10px; + padding-bottom: 5px; + font-size: 0.8rem; +} +.attention-visualization .title.inline { + display: inline-block; +} +.attention-visualization .select-container { + padding-top: 10px; + padding-bottom: 5px; +} +.attention-visualization .select-container select { + margin-left: 10px; +} +.attention-visualization .double-select { + display: flex; + flex-direction: row; + gap: 30px; +} +.attention-visualization .double-select .select-container { + width: fit-content; +} +.attention-visualization .matrix { + margin-bottom: 20px; +} +.attention-visualization .matrix .label text { + dominant-baseline: central; + text-anchor: end; + font-family: monospace; +} +.attention-visualization .text-tokens { + margin-bottom: 10px; +} +.attention-visualization .text-tokens .token { + font-family: monospace; + display: inline-block; + white-space: pre; + padding: 2px 5px; + user-select: none; + cursor: pointer; + margin-bottom: 10px; + background-clip: padding-box !important; +} +.attention-visualization .text-tokens .token.new-line { + opacity: 0.6; +} +.attention-visualization .token-value-container { + padding-bottom: 100px; + width: calc(100% - 20px); +} +.attention-visualization .token-value-container.padding-less .token { + border-left: none !important; + padding: 0; + margin-bottom: 3px; +} +.attention-visualization .dimension-values { + margin-bottom: 20px; +} +.attention-visualization .dimension-values .value { + font-family: monospace; + white-space: pre; + display: inline-block; + margin: 2px; + padding: 3px 5px; + font-size: 10px; + text-align: center; + user-select: none; + cursor: pointer; + width: 3rem; +} +.attention-visualization .hover-container { + position: relative; + display: inline-block; +} +.attention-visualization .menu { + display: none; + position: absolute; + width: max-content; + box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2); + z-index: 1; + min-width: 100px; + max-width: 50vw; + padding: 5px; + white-space: nowrap; +} +.attention-visualization .menu pre { + background-color: transparent; + text-wrap: wrap; +} +.attention-visualization .menu.right-align { + right: 0; + left: auto; +} +.attention-visualization .hover-container:hover .menu { + display: block; +} +.attention-visualization .hover-container:hover { + border: 1px solid #878686; +} + +/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiLi4vY3NzL2NoYXJ0cy5jc3MiLCJtYXBwaW5ncyI6Ijs7O0FBQUE7RUFDRTtFQUNBO0FBQ0Y7QUFBRTtFQUNFO0VBQ0E7QUFFSjtBQUFJO0VBQ0U7RUFDQTtBQUVOO0FBR0k7RUFDRTtBQUROO0FBS0U7RUFDRTtFQUNBO0FBSEo7QUFLSTtFQUNFO0VBQ0E7QUFITjtBQUtNO0VBQ0U7RUFDQTtBQUhSO0FBUU07RUFDRTtBQU5SOztBQWFBO0VBQ0U7RUFDQTtBQVZGO0FBWUU7RUFDRTtFQUNBO0VBQ0E7QUFWSjtBQVlJO0VBQ0k7QUFWUjtBQWNFO0VBQ0U7RUFDQTtBQVpKO0FBY0k7RUFDRTtBQVpOO0FBZ0JFO0VBQ0U7RUFDQTtFQUNBO0FBZEo7QUFnQkk7RUFDRTtBQWROO0FBa0JFO0VBU0U7QUF4Qko7QUFpQk07RUFDRTtFQUNBO0VBQ0E7QUFmUjtBQXNCRTtFQWlCRTtBQXBDSjtBQXFCSTtFQUNFO0VBQ0E7R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hY2tncm91bmQtY29sb3I6ICMzMzM7XG4gICAgICBjb2xvcjogI2ZmZmZmZjtcblxuICAgICAgcHJlIHtcbiAgICAgICAgY29sb3I6ICNmZmZmZmY7XG4gICAgICAgIGJhY2tncm91bmQtY29sb3I6ICMzMzM7XG4gICAgICB9XG4gICAgfVxuXG4gICAgc3ZnIHtcbiAgICAgIHRleHQge1xuICAgICAgICBmaWxsOiAjZmZmZmZmO1xuICAgICAgfVxuICAgIH1cbiAgfVxufVxuXG5cbi5hdHRlbnRpb24tdmlzdWFsaXphdGlvbiB7XG4gIGZvbnQtZmFtaWx5OiBcIlJvYm90byBMaWdodFwiLCBcIlVidW50dSBMaWdodFwiLCBcIlVidW50dVwiLCBtb25vc3BhY2U7XG4gIG92ZXJmbG93LXk6IHNjcm9sbDtcblxuICAudGl0bGUge1xuICAgIHBhZGRpbmctdG9wOiAxMHB4O1xuICAgIHBhZGRpbmctYm90dG9tOiA1cHg7XG4gICAgZm9udC1zaXplOiAwLjhyZW07XG5cbiAgICAmLmlubGluZSB7XG4gICAgICAgIGRpc3BsYXk6IGlubGluZS1ibG9jaztcbiAgICB9XG4gIH1cblxuICAuc2VsZWN0LWNvbnRhaW5lciB7XG4gICAgcGFkZGluZy10b3A6IDEwcHg7XG4gICAgcGFkZGluZy1ib3R0b206IDVweDtcblxuICAgIHNlbGVjdCB7XG4gICAgICBtYXJnaW4tbGVmdDogMTBweDtcbiAgICB9XG4gIH1cblxuICAuZG91YmxlLXNlbGVjdCB7XG4gICAgZGlzcGxheTogZmxleDtcbiAgICBmbGV4LWRpcmVjdGlvbjogcm93O1xuICAgIGdhcDogMzBweDtcblxuICAgIC5zZWxlY3QtY29udGFpbmVyIHtcbiAgICAgIHdpZHRoOiBmaXQtY29udGVudDtcbiAgICB9XG4gIH1cblxuICAubWF0cml4IHtcbiAgICAubGFiZWwge1xuICAgICAgdGV4dCB7XG4gICAgICAgIGRvbWluYW50LWJhc2VsaW5lOiBjZW50cmFsO1xuICAgICAgICB0ZXh0LWFuY2hvcjogZW5kO1xuICAgICAgICBmb250LWZhbWlseTogbW9ub3NwYWNlO1xuICAgICAgfVxuICAgIH1cblxuICAgIG1hcmdpbi1ib3R0b206IDIwcHg7XG4gIH1cblxuICAudGV4dC10b2tlbnMge1xuXG4gICAgLnRva2VuIHtcbiAgICAgIGZvbnQtZmFtaWx5OiBtb25vc3BhY2U7XG4gICAgICBkaXNwbGF5OiBpbmxpbmUtYmxvY2s7XG4gICAgICB3aGl0ZS1zcGFjZTogcHJlO1xuICAgICAgcGFkZGluZzogMnB4IDVweDtcbiAgICAgIHVzZXItc2VsZWN0OiBub25lO1xuICAgICAgY3Vyc29yOiBwb2ludGVyO1xuICAgICAgbWFyZ2luLWJvdHRvbTogMTBweDtcbiAgICAgIGJhY2tncm91bmQtY2xpcDogcGFkZGluZy1ib3ggIWltcG9ydGFudDtcblxuICAgICAgJi5uZXctbGluZSB7XG4gICAgICAgIG9wYWNpdHk6IDAuNjtcbiAgICAgIH1cbiAgICB9XG5cbiAgICBtYXJnaW4tYm90dG9tOiAxMHB4O1xuICB9XG5cbiAgLnRva2VuLXZhbHVlLWNvbnRhaW5lciB7XG4gICAgcGFkZGluZy1ib3R0b206IDEwMHB4O1xuICAgIHdpZHRoOiBjYWxjKDEwMCUgLSAyMHB4KTtcblxuICAgICYucGFkZGluZy1sZXNzIHtcbiAgICAgIC50b2tlbiB7XG4gICAgICAgIGJvcmRlci1sZWZ0OiBub25lICFpbXBvcnRhbnQ7XG4gICAgICAgIHBhZGRpbmc6IDA7XG4gICAgICAgIG1hcmdpbi1ib3R0b206IDNweDtcbiAgICAgIH1cbiAgICB9XG4gIH1cblxuICAuZGltZW5zaW9uLXZhbHVlcyB7XG4gICAgbWFyZ2luLWJvdHRvbTogMjBweDtcblxuICAgIC52YWx1ZSB7XG4gICAgICBmb250LWZhbWlseTogbW9ub3NwYWNlO1xuICAgICAgd2hpdGUtc3BhY2U6IHByZTtcbiAgICAgIGRpc3BsYXk6IGlubGluZS1ibG9jaztcbiAgICAgIG1hcmdpbjogMnB4O1xuICAgICAgcGFkZGluZzogM3B4IDVweDtcbiAgICAgIGZvbnQtc2l6ZTogMTBweDtcbiAgICAgIHRleHQtYWxpZ246IGNlbnRlcjtcbiAgICAgIHVzZXItc2VsZWN0OiBub25lO1xuICAgICAgY3Vyc29yOiBwb2ludGVyO1xuICAgICAgd2lkdGg6IDNyZW07XG4gICAgfVxuICB9XG4gIFxuICAuaG92ZXItY29udGFpbmVyIHtcbiAgICBwb3NpdGlvbjogcmVsYXRpdmU7XG4gICAgZGlzcGxheTogaW5saW5lLWJsb2NrO1xuICB9XG4gIFxuICAubWVudSB7XG4gICAgZGlzcGxheTogbm9uZTtcbiAgICBwb3NpdGlvbjogYWJzb2x1dGU7XG4gICAgd2lkdGg6IG1heC1jb250ZW50O1xuICAgIGJveC1zaGFkb3c6IDBweCA4cHggMTZweCAwcHggcmdiYSgwLDAsMCwwLjIpO1xuICAgIHotaW5kZXg6IDE7XG4gICAgbWluLXdpZHRoOiAxMDBweDtcbiAgICBtYXgtd2lkdGg6IDUwdnc7XG4gICAgcGFkZGluZzogNXB4O1xuICAgIHdoaXRlLXNwYWNlOiBub3dyYXA7XG5cbiAgICBwcmUge1xuICAgICAgYmFja2dyb3VuZC1jb2xvcjogdHJhbnNwYXJlbnQ7XG4gICAgICB0ZXh0LXdyYXA6IHdyYXA7XG4gICAgfVxuICB9XG5cbiAgLm1lbnUucmlnaHQtYWxpZ24ge1xuICAgIHJpZ2h0OiAwO1xuICAgIGxlZnQ6IGF1dG87XG4gIH1cbiAgXG4gIC5ob3Zlci1jb250YWluZXI6aG92ZXIgLm1lbnUge2Rpc3BsYXk6IGJsb2NrO31cblxuICAuaG92ZXItY29udGFpbmVyOmhvdmVyIHtcbiAgICBib3JkZXI6IDFweCBzb2xpZCAjODc4Njg2O1xuICB9XG59Il0sIm5hbWVzIjpbXSwic291cmNlUm9vdCI6IiJ9*/ \ No newline at end of file diff --git a/python/inspectus/static/js/charts.js b/python/inspectus/static/js/charts.js index 2f3f992..ee74e2d 100644 --- a/python/inspectus/static/js/charts.js +++ b/python/inspectus/static/js/charts.js @@ -1 +1,22226 @@ -(()=>{var t={470:function(t,n){!function(t){"use strict";function n(t,n){return null==t||null==n?NaN:tn?1:t>=n?0:NaN}function e(t){let e=t,r=t,i=t;function o(t,n,e=0,o=t.length){if(e>>1;i(t[r],n)<0?e=r+1:o=r}while(et(n)-e,r=n,i=(e,r)=>n(t(e),r)),{left:o,center:function(t,n,r=0,i=t.length){const a=o(t,n,r,i-1);return a>r&&e(t[a-1],n)>-e(t[a],n)?a-1:a},right:function(t,n,e=0,o=t.length){if(e>>1;i(t[r],n)<=0?e=r+1:o=r}while(e=n&&++e;else{let r=-1;for(let i of t)null!=(i=n(i,++r,t))&&(i=+i)>=i&&++e}return e}function l(t){return 0|t.length}function f(t){return!(t>0)}function h(t){return"object"!=typeof t||"length"in t?t:Array.from(t)}function d(t,n){let e,r=0,i=0,o=0;if(void 0===n)for(let n of t)null!=n&&(n=+n)>=n&&(e=n-i,i+=e/++r,o+=e*(n-i));else{let a=-1;for(let u of t)null!=(u=n(u,++a,t))&&(u=+u)>=u&&(e=u-i,i+=e/++r,o+=e*(u-i))}if(r>1)return o/(r-1)}function p(t,n){const e=d(t,n);return e?Math.sqrt(e):e}function g(t,n){let e,r;if(void 0===n)for(const n of t)null!=n&&(void 0===e?n>=n&&(e=r=n):(e>n&&(e=n),r=o&&(e=r=o):(e>o&&(e=o),r0){for(o=t[--i];i>0&&(n=o,e=t[--i],o=n+e,r=e-(o-n),!r););i>0&&(r<0&&t[i-1]<0||r>0&&t[i-1]>0)&&(e=2*r,n=o+e,e==n-o&&(o=n))}return o}}class m extends Map{constructor(t,n=w){if(super(),Object.defineProperties(this,{_intern:{value:new Map},_key:{value:n}}),null!=t)for(const[n,e]of t)this.set(n,e)}get(t){return super.get(_(this,t))}has(t){return super.has(_(this,t))}set(t,n){return super.set(b(this,t),n)}delete(t){return super.delete(x(this,t))}}class v extends Set{constructor(t,n=w){if(super(),Object.defineProperties(this,{_intern:{value:new Map},_key:{value:n}}),null!=t)for(const n of t)this.add(n)}has(t){return super.has(_(this,t))}add(t){return super.add(b(this,t))}delete(t){return super.delete(x(this,t))}}function _({_intern:t,_key:n},e){const r=n(e);return t.has(r)?t.get(r):e}function b({_intern:t,_key:n},e){const r=n(e);return t.has(r)?t.get(r):(t.set(r,e),e)}function x({_intern:t,_key:n},e){const r=n(e);return t.has(r)&&(e=t.get(r),t.delete(r)),e}function w(t){return null!==t&&"object"==typeof t?t.valueOf():t}function M(t){return t}function k(t,...n){return N(t,M,M,n)}function T(t,...n){return N(t,Array.from,M,n)}function A(t,n){for(let e=1,r=n.length;et.pop().map((([n,e])=>[...t,n,e]))));return t}function S(t,n,...e){return N(t,M,n,e)}function E(t,n,...e){return N(t,Array.from,n,e)}function C(t){if(1!==t.length)throw new Error("duplicate key");return t[0]}function N(t,n,e,r){return function t(i,o){if(o>=r.length)return e(i);const a=new m,u=r[o++];let s=-1;for(const t of i){const n=u(t,++s,i),e=a.get(n);e?e.push(t):a.set(n,[t])}for(const[n,e]of a)a.set(n,t(e,o));return n(a)}(t,0)}function P(t,n){return Array.from(n,(n=>t[n]))}function D(t,...n){if("function"!=typeof t[Symbol.iterator])throw new TypeError("values is not iterable");t=Array.from(t);let[e]=n;if(e&&2!==e.length||n.length>1){const r=Uint32Array.from(t,((t,n)=>n));return n.length>1?(n=n.map((n=>t.map(n))),r.sort(((t,e)=>{for(const r of n){const n=L(r[t],r[e]);if(n)return n}}))):(e=t.map(e),r.sort(((t,n)=>L(e[t],e[n])))),P(t,r)}return t.sort(z(e))}function z(t=n){if(t===n)return L;if("function"!=typeof t)throw new TypeError("compare is not a function");return(n,e)=>{const r=t(n,e);return r||0===r?r:(0===t(e,e))-(0===t(n,n))}}function L(t,n){return(null==t||!(t>=t))-(null==n||!(n>=n))||(tn?1:0)}var H=Array.prototype.slice;function R(t){return()=>t}var B=Math.sqrt(50),I=Math.sqrt(10),q=Math.sqrt(2);function F(t,n,e){var r,i,o,a,u=-1;if(e=+e,(t=+t)==(n=+n)&&e>0)return[t];if((r=n0){let e=Math.round(t/a),r=Math.round(n/a);for(e*an&&--r,o=new Array(i=r-e+1);++un&&--r,o=new Array(i=r-e+1);++u=0?(o>=B?10:o>=I?5:o>=q?2:1)*Math.pow(10,i):-Math.pow(10,-i)/(o>=B?10:o>=I?5:o>=q?2:1)}function U(t,n,e){var r=Math.abs(n-t)/Math.max(0,e),i=Math.pow(10,Math.floor(Math.log(r)/Math.LN10)),o=r/i;return o>=B?i*=10:o>=I?i*=5:o>=q&&(i*=2),n0?(t=Math.floor(t/i)*i,n=Math.ceil(n/i)*i):i<0&&(t=Math.ceil(t*i)/i,n=Math.floor(n*i)/i),r=i}}function G(t){return Math.ceil(Math.log(c(t))/Math.LN2)+1}function V(){var t=M,n=g,e=G;function r(r){Array.isArray(r)||(r=Array.from(r));var i,o,a=r.length,u=new Array(a);for(i=0;i=f)if(t>=f&&n===g){const t=O(l,f,e);isFinite(t)&&(t>0?f=(Math.floor(f/t)+1)*t:t<0&&(f=(Math.ceil(f*-t)+1)/-t))}else h.pop()}for(var d=h.length;h[0]<=l;)h.shift(),--d;for(;h[d-1]>f;)h.pop(),--d;var p,y=new Array(d+1);for(i=0;i<=d;++i)(p=y[i]=[]).x0=i>0?h[i-1]:l,p.x1=i=n)&&(e=n);else{let r=-1;for(let i of t)null!=(i=n(i,++r,t))&&(e=i)&&(e=i)}return e}function $(t,n){let e;if(void 0===n)for(const n of t)null!=n&&(e>n||void 0===e&&n>=n)&&(e=n);else{let r=-1;for(let i of t)null!=(i=n(i,++r,t))&&(e>i||void 0===e&&i>=i)&&(e=i)}return e}function X(t,n,e=0,r=t.length-1,i){for(i=void 0===i?L:z(i);r>e;){if(r-e>600){const o=r-e+1,a=n-e+1,u=Math.log(o),s=.5*Math.exp(2*u/3),c=.5*Math.sqrt(u*s*(o-s)/o)*(a-o/2<0?-1:1);X(t,n,Math.max(e,Math.floor(n-a*s/o+c)),Math.min(r,Math.floor(n+(o-a)*s/o+c)),i)}const o=t[n];let a=e,u=r;for(W(t,e,n),i(t[r],o)>0&&W(t,e,r);a0;)--u}0===i(t[e],o)?W(t,e,u):(++u,W(t,u,r)),u<=n&&(e=u+1),n<=u&&(r=u-1)}return t}function W(t,n,e){const r=t[n];t[n]=t[e],t[e]=r}function Z(t,n,e){if(r=(t=Float64Array.from(function*(t,n){if(void 0===n)for(let n of t)null!=n&&(n=+n)>=n&&(yield n);else{let e=-1;for(let r of t)null!=(r=n(r,++e,t))&&(r=+r)>=r&&(yield r)}}(t,e))).length){if((n=+n)<=0||r<2)return $(t);if(n>=1)return j(t);var r,i=(r-1)*n,o=Math.floor(i),a=j(X(t,o).subarray(0,o+1));return a+($(t.subarray(o+1))-a)*(i-o)}}function K(t,n,e=r){if(i=t.length){if((n=+n)<=0||i<2)return+e(t[0],0,t);if(n>=1)return+e(t[i-1],i-1,t);var i,o=(i-1)*n,a=Math.floor(o),u=+e(t[a],a,t);return u+(+e(t[a+1],a+1,t)-u)*(o-a)}}function Q(t,n){let e,r=-1,i=-1;if(void 0===n)for(const n of t)++i,null!=n&&(e=n)&&(e=n,r=i);else for(let o of t)null!=(o=n(o,++i,t))&&(e=o)&&(e=o,r=i);return r}function J(t){return Array.from(function*(t){for(const n of t)yield*n}(t))}function tt(t,n){let e,r=-1,i=-1;if(void 0===n)for(const n of t)++i,null!=n&&(e>n||void 0===e&&n>=n)&&(e=n,r=i);else for(let o of t)null!=(o=n(o,++i,t))&&(e>o||void 0===e&&o>=o)&&(e=o,r=i);return r}function nt(t,n){return[t,n]}function et(t,n,e){t=+t,n=+n,e=(i=arguments.length)<2?(n=t,t=0,1):i<3?1:+e;for(var r=-1,i=0|Math.max(0,Math.ceil((n-t)/e)),o=new Array(i);++r+t(n)}function bt(t,n){return n=Math.max(0,t.bandwidth()-2*n)/2,t.round()&&(n=Math.round(n)),e=>+t(e)+n}function xt(){return!this.__axis}function wt(t,n){var e=[],r=null,i=null,o=6,a=6,u=3,s="undefined"!=typeof window&&window.devicePixelRatio>1?0:.5,c=t===ht||t===gt?-1:1,l=t===gt||t===dt?"x":"y",f=t===ht||t===pt?mt:vt;function h(h){var d=null==r?n.ticks?n.ticks.apply(n,e):n.domain():r,p=null==i?n.tickFormat?n.tickFormat.apply(n,e):ft:i,g=Math.max(o,0)+u,y=n.range(),m=+y[0]+s,v=+y[y.length-1]+s,_=(n.bandwidth?bt:_t)(n.copy(),s),b=h.selection?h.selection():h,x=b.selectAll(".domain").data([null]),w=b.selectAll(".tick").data(d,n).order(),M=w.exit(),k=w.enter().append("g").attr("class","tick"),T=w.select("line"),A=w.select("text");x=x.merge(x.enter().insert("path",".tick").attr("class","domain").attr("stroke","currentColor")),w=w.merge(k),T=T.merge(k.append("line").attr("stroke","currentColor").attr(l+"2",c*o)),A=A.merge(k.append("text").attr("fill","currentColor").attr(l,c*g).attr("dy",t===ht?"0em":t===pt?"0.71em":"0.32em")),h!==b&&(x=x.transition(h),w=w.transition(h),T=T.transition(h),A=A.transition(h),M=M.transition(h).attr("opacity",yt).attr("transform",(function(t){return isFinite(t=_(t))?f(t+s):this.getAttribute("transform")})),k.attr("opacity",yt).attr("transform",(function(t){var n=this.parentNode.__axis;return f((n&&isFinite(n=n(t))?n:_(t))+s)}))),M.remove(),x.attr("d",t===gt||t===dt?a?"M"+c*a+","+m+"H"+s+"V"+v+"H"+c*a:"M"+s+","+m+"V"+v:a?"M"+m+","+c*a+"V"+s+"H"+v+"V"+c*a:"M"+m+","+s+"H"+v),w.attr("opacity",1).attr("transform",(function(t){return f(_(t)+s)})),T.attr(l+"2",c*o),A.attr(l,c*g).text(p),b.filter(xt).attr("fill","none").attr("font-size",10).attr("font-family","sans-serif").attr("text-anchor",t===dt?"start":t===gt?"end":"middle"),b.each((function(){this.__axis=_}))}return h.scale=function(t){return arguments.length?(n=t,h):n},h.ticks=function(){return e=Array.from(arguments),h},h.tickArguments=function(t){return arguments.length?(e=null==t?[]:Array.from(t),h):e.slice()},h.tickValues=function(t){return arguments.length?(r=null==t?null:Array.from(t),h):r&&r.slice()},h.tickFormat=function(t){return arguments.length?(i=t,h):i},h.tickSize=function(t){return arguments.length?(o=a=+t,h):o},h.tickSizeInner=function(t){return arguments.length?(o=+t,h):o},h.tickSizeOuter=function(t){return arguments.length?(a=+t,h):a},h.tickPadding=function(t){return arguments.length?(u=+t,h):u},h.offset=function(t){return arguments.length?(s=+t,h):s},h}var Mt={value:()=>{}};function kt(){for(var t,n=0,e=arguments.length,r={};n=0&&(n=t.slice(e+1),t=t.slice(0,e)),t&&!r.hasOwnProperty(t))throw new Error("unknown type: "+t);return{type:t,name:n}}))),a=-1,u=o.length;if(!(arguments.length<2)){if(null!=n&&"function"!=typeof n)throw new Error("invalid callback: "+n);for(;++a0)for(var e,r,i=new Array(e),o=0;o=0&&"xmlns"!==(n=t.slice(0,e))&&(t=t.slice(e+1)),Ct.hasOwnProperty(n)?{space:Ct[n],local:t}:t}function Pt(t){return function(){var n=this.ownerDocument,e=this.namespaceURI;return e===Et&&n.documentElement.namespaceURI===Et?n.createElement(t):n.createElementNS(e,t)}}function Dt(t){return function(){return this.ownerDocument.createElementNS(t.space,t.local)}}function zt(t){var n=Nt(t);return(n.local?Dt:Pt)(n)}function Lt(){}function Ht(t){return null==t?Lt:function(){return this.querySelector(t)}}function Rt(t){return null==t?[]:Array.isArray(t)?t:Array.from(t)}function Bt(){return[]}function It(t){return null==t?Bt:function(){return this.querySelectorAll(t)}}function qt(t){return function(){return this.matches(t)}}function Ft(t){return function(n){return n.matches(t)}}var Ot=Array.prototype.find;function Ut(){return this.firstElementChild}var Yt=Array.prototype.filter;function Gt(){return Array.from(this.children)}function Vt(t){return new Array(t.length)}function jt(t,n){this.ownerDocument=t.ownerDocument,this.namespaceURI=t.namespaceURI,this._next=null,this._parent=t,this.__data__=n}function $t(t,n,e,r,i,o){for(var a,u=0,s=n.length,c=o.length;un?1:t>=n?0:NaN}function Qt(t){return function(){this.removeAttribute(t)}}function Jt(t){return function(){this.removeAttributeNS(t.space,t.local)}}function tn(t,n){return function(){this.setAttribute(t,n)}}function nn(t,n){return function(){this.setAttributeNS(t.space,t.local,n)}}function en(t,n){return function(){var e=n.apply(this,arguments);null==e?this.removeAttribute(t):this.setAttribute(t,e)}}function rn(t,n){return function(){var e=n.apply(this,arguments);null==e?this.removeAttributeNS(t.space,t.local):this.setAttributeNS(t.space,t.local,e)}}function on(t){return t.ownerDocument&&t.ownerDocument.defaultView||t.document&&t||t.defaultView}function an(t){return function(){this.style.removeProperty(t)}}function un(t,n,e){return function(){this.style.setProperty(t,n,e)}}function sn(t,n,e){return function(){var r=n.apply(this,arguments);null==r?this.style.removeProperty(t):this.style.setProperty(t,r,e)}}function cn(t,n){return t.style.getPropertyValue(n)||on(t).getComputedStyle(t,null).getPropertyValue(n)}function ln(t){return function(){delete this[t]}}function fn(t,n){return function(){this[t]=n}}function hn(t,n){return function(){var e=n.apply(this,arguments);null==e?delete this[t]:this[t]=e}}function dn(t){return t.trim().split(/^|\s+/)}function pn(t){return t.classList||new gn(t)}function gn(t){this._node=t,this._names=dn(t.getAttribute("class")||"")}function yn(t,n){for(var e=pn(t),r=-1,i=n.length;++r=0&&(this._names.splice(n,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(t){return this._names.indexOf(t)>=0}};var In=[null];function qn(t,n){this._groups=t,this._parents=n}function Fn(){return new qn([[document.documentElement]],In)}function On(t){return"string"==typeof t?new qn([[document.querySelector(t)]],[document.documentElement]):new qn([[t]],In)}qn.prototype=Fn.prototype={constructor:qn,select:function(t){"function"!=typeof t&&(t=Ht(t));for(var n=this._groups,e=n.length,r=new Array(e),i=0;i=b&&(b=_+1);!(v=y[b])&&++b=0;)(r=i[o])&&(a&&4^r.compareDocumentPosition(a)&&a.parentNode.insertBefore(r,a),a=r);return this},sort:function(t){function n(n,e){return n&&e?t(n.__data__,e.__data__):!n-!e}t||(t=Kt);for(var e=this._groups,r=e.length,i=new Array(r),o=0;o1?this.each((null==n?an:"function"==typeof n?sn:un)(t,n,null==e?"":e)):cn(this.node(),t)},property:function(t,n){return arguments.length>1?this.each((null==n?ln:"function"==typeof n?hn:fn)(t,n)):this.node()[t]},classed:function(t,n){var e=dn(t+"");if(arguments.length<2){for(var r=pn(this.node()),i=-1,o=e.length;++i=0&&(n=t.slice(e+1),t=t.slice(0,e)),{type:t,name:n}}))}(t+""),a=o.length;if(!(arguments.length<2)){for(u=n?Ln:zn,r=0;r()=>t;function te(t,{sourceEvent:n,subject:e,target:r,identifier:i,active:o,x:a,y:u,dx:s,dy:c,dispatch:l}){Object.defineProperties(this,{type:{value:t,enumerable:!0,configurable:!0},sourceEvent:{value:n,enumerable:!0,configurable:!0},subject:{value:e,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:u,enumerable:!0,configurable:!0},dx:{value:s,enumerable:!0,configurable:!0},dy:{value:c,enumerable:!0,configurable:!0},_:{value:l}})}function ne(t){return!t.ctrlKey&&!t.button}function ee(){return this.parentNode}function re(t,n){return null==n?{x:t.x,y:t.y}:n}function ie(){return navigator.maxTouchPoints||"ontouchstart"in this}function oe(t,n,e){t.prototype=n.prototype=e,e.constructor=t}function ae(t,n){var e=Object.create(t.prototype);for(var r in n)e[r]=n[r];return e}function ue(){}te.prototype.on=function(){var t=this._.on.apply(this._,arguments);return t===this._?this:t};var se=.7,ce=1/se,le="\\s*([+-]?\\d+)\\s*",fe="\\s*([+-]?\\d*\\.?\\d+(?:[eE][+-]?\\d+)?)\\s*",he="\\s*([+-]?\\d*\\.?\\d+(?:[eE][+-]?\\d+)?)%\\s*",de=/^#([0-9a-f]{3,8})$/,pe=new RegExp("^rgb\\("+[le,le,le]+"\\)$"),ge=new RegExp("^rgb\\("+[he,he,he]+"\\)$"),ye=new RegExp("^rgba\\("+[le,le,le,fe]+"\\)$"),me=new RegExp("^rgba\\("+[he,he,he,fe]+"\\)$"),ve=new RegExp("^hsl\\("+[fe,he,he]+"\\)$"),_e=new RegExp("^hsla\\("+[fe,he,he,fe]+"\\)$"),be={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 xe(){return this.rgb().formatHex()}function we(){return this.rgb().formatRgb()}function Me(t){var n,e;return t=(t+"").trim().toLowerCase(),(n=de.exec(t))?(e=n[1].length,n=parseInt(n[1],16),6===e?ke(n):3===e?new Ee(n>>8&15|n>>4&240,n>>4&15|240&n,(15&n)<<4|15&n,1):8===e?Te(n>>24&255,n>>16&255,n>>8&255,(255&n)/255):4===e?Te(n>>12&15|n>>8&240,n>>8&15|n>>4&240,n>>4&15|240&n,((15&n)<<4|15&n)/255):null):(n=pe.exec(t))?new Ee(n[1],n[2],n[3],1):(n=ge.exec(t))?new Ee(255*n[1]/100,255*n[2]/100,255*n[3]/100,1):(n=ye.exec(t))?Te(n[1],n[2],n[3],n[4]):(n=me.exec(t))?Te(255*n[1]/100,255*n[2]/100,255*n[3]/100,n[4]):(n=ve.exec(t))?De(n[1],n[2]/100,n[3]/100,1):(n=_e.exec(t))?De(n[1],n[2]/100,n[3]/100,n[4]):be.hasOwnProperty(t)?ke(be[t]):"transparent"===t?new Ee(NaN,NaN,NaN,0):null}function ke(t){return new Ee(t>>16&255,t>>8&255,255&t,1)}function Te(t,n,e,r){return r<=0&&(t=n=e=NaN),new Ee(t,n,e,r)}function Ae(t){return t instanceof ue||(t=Me(t)),t?new Ee((t=t.rgb()).r,t.g,t.b,t.opacity):new Ee}function Se(t,n,e,r){return 1===arguments.length?Ae(t):new Ee(t,n,e,null==r?1:r)}function Ee(t,n,e,r){this.r=+t,this.g=+n,this.b=+e,this.opacity=+r}function Ce(){return"#"+Pe(this.r)+Pe(this.g)+Pe(this.b)}function Ne(){var t=this.opacity;return(1===(t=isNaN(t)?1:Math.max(0,Math.min(1,t)))?"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===t?")":", "+t+")")}function Pe(t){return((t=Math.max(0,Math.min(255,Math.round(t)||0)))<16?"0":"")+t.toString(16)}function De(t,n,e,r){return r<=0?t=n=e=NaN:e<=0||e>=1?t=n=NaN:n<=0&&(t=NaN),new He(t,n,e,r)}function ze(t){if(t instanceof He)return new He(t.h,t.s,t.l,t.opacity);if(t instanceof ue||(t=Me(t)),!t)return new He;if(t instanceof He)return t;var n=(t=t.rgb()).r/255,e=t.g/255,r=t.b/255,i=Math.min(n,e,r),o=Math.max(n,e,r),a=NaN,u=o-i,s=(o+i)/2;return u?(a=n===o?(e-r)/u+6*(e0&&s<1?0:a,new He(a,u,s,t.opacity)}function Le(t,n,e,r){return 1===arguments.length?ze(t):new He(t,n,e,null==r?1:r)}function He(t,n,e,r){this.h=+t,this.s=+n,this.l=+e,this.opacity=+r}function Re(t,n,e){return 255*(t<60?n+(e-n)*t/60:t<180?e:t<240?n+(e-n)*(240-t)/60:n)}oe(ue,Me,{copy:function(t){return Object.assign(new this.constructor,this,t)},displayable:function(){return this.rgb().displayable()},hex:xe,formatHex:xe,formatHsl:function(){return ze(this).formatHsl()},formatRgb:we,toString:we}),oe(Ee,Se,ae(ue,{brighter:function(t){return t=null==t?ce:Math.pow(ce,t),new Ee(this.r*t,this.g*t,this.b*t,this.opacity)},darker:function(t){return t=null==t?se:Math.pow(se,t),new Ee(this.r*t,this.g*t,this.b*t,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:Ce,formatHex:Ce,formatRgb:Ne,toString:Ne})),oe(He,Le,ae(ue,{brighter:function(t){return t=null==t?ce:Math.pow(ce,t),new He(this.h,this.s,this.l*t,this.opacity)},darker:function(t){return t=null==t?se:Math.pow(se,t),new He(this.h,this.s,this.l*t,this.opacity)},rgb:function(){var t=this.h%360+360*(this.h<0),n=isNaN(t)||isNaN(this.s)?0:this.s,e=this.l,r=e+(e<.5?e:1-e)*n,i=2*e-r;return new Ee(Re(t>=240?t-240:t+120,i,r),Re(t,i,r),Re(t<120?t+240:t-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 t=this.opacity;return(1===(t=isNaN(t)?1:Math.max(0,Math.min(1,t)))?"hsl(":"hsla(")+(this.h||0)+", "+100*(this.s||0)+"%, "+100*(this.l||0)+"%"+(1===t?")":", "+t+")")}}));const Be=Math.PI/180,Ie=180/Math.PI,qe=.96422,Fe=1,Oe=.82521,Ue=4/29,Ye=6/29,Ge=3*Ye*Ye,Ve=Ye*Ye*Ye;function je(t){if(t instanceof Xe)return new Xe(t.l,t.a,t.b,t.opacity);if(t instanceof nr)return er(t);t instanceof Ee||(t=Ae(t));var n,e,r=Qe(t.r),i=Qe(t.g),o=Qe(t.b),a=We((.2225045*r+.7168786*i+.0606169*o)/Fe);return r===i&&i===o?n=e=a:(n=We((.4360747*r+.3850649*i+.1430804*o)/qe),e=We((.0139322*r+.0971045*i+.7141733*o)/Oe)),new Xe(116*a-16,500*(n-a),200*(a-e),t.opacity)}function $e(t,n,e,r){return 1===arguments.length?je(t):new Xe(t,n,e,null==r?1:r)}function Xe(t,n,e,r){this.l=+t,this.a=+n,this.b=+e,this.opacity=+r}function We(t){return t>Ve?Math.pow(t,1/3):t/Ge+Ue}function Ze(t){return t>Ye?t*t*t:Ge*(t-Ue)}function Ke(t){return 255*(t<=.0031308?12.92*t:1.055*Math.pow(t,1/2.4)-.055)}function Qe(t){return(t/=255)<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)}function Je(t){if(t instanceof nr)return new nr(t.h,t.c,t.l,t.opacity);if(t instanceof Xe||(t=je(t)),0===t.a&&0===t.b)return new nr(NaN,0=1?(e=1,n-1):Math.floor(e*n),i=t[r],o=t[r+1],a=r>0?t[r-1]:2*i-o,u=r()=>t;function mr(t,n){return function(e){return t+e*n}}function vr(t,n){var e=n-t;return e?mr(t,e>180||e<-180?e-360*Math.round(e/360):e):yr(isNaN(t)?n:t)}function _r(t){return 1==(t=+t)?br:function(n,e){return e-n?function(t,n,e){return t=Math.pow(t,e),n=Math.pow(n,e)-t,e=1/e,function(r){return Math.pow(t+r*n,e)}}(n,e,t):yr(isNaN(n)?e:n)}}function br(t,n){var e=n-t;return e?mr(t,e):yr(isNaN(t)?n:t)}var xr=function t(n){var e=_r(n);function r(t,n){var r=e((t=Se(t)).r,(n=Se(n)).r),i=e(t.g,n.g),o=e(t.b,n.b),a=br(t.opacity,n.opacity);return function(n){return t.r=r(n),t.g=i(n),t.b=o(n),t.opacity=a(n),t+""}}return r.gamma=t,r}(1);function wr(t){return function(n){var e,r,i=n.length,o=new Array(i),a=new Array(i),u=new Array(i);for(e=0;eo&&(i=n.slice(o,i),u[a]?u[a]+=i:u[++a]=i),(e=e[0])===(r=r[0])?u[a]?u[a]+=r:u[++a]=r:(u[++a]=null,s.push({i:a,x:Cr(e,r)})),o=Dr.lastIndex;return o180?n+=360:n-t>180&&(t+=360),o.push({i:e.push(i(e)+"rotate(",null,r)-2,x:Cr(t,n)})):n&&e.push(i(e)+"rotate("+n+r)}(o.rotate,a.rotate,u,s),function(t,n,e,o){t!==n?o.push({i:e.push(i(e)+"skewX(",null,r)-2,x:Cr(t,n)}):n&&e.push(i(e)+"skewX("+n+r)}(o.skewX,a.skewX,u,s),function(t,n,e,r,o,a){if(t!==e||n!==r){var u=o.push(i(o)+"scale(",null,",",null,")");a.push({i:u-4,x:Cr(t,e)},{i:u-2,x:Cr(n,r)})}else 1===e&&1===r||o.push(i(o)+"scale("+e+","+r+")")}(o.scaleX,o.scaleY,a.scaleX,a.scaleY,u,s),o=a=null,function(t){for(var n,e=-1,r=s.length;++e=0&&n._call.call(void 0,t),n=n._next;--ri}function mi(){si=(ui=li.now())+ci,ri=ii=0;try{yi()}finally{ri=0,function(){for(var t,n,e=ni,r=1/0;e;)e._call?(r>e._time&&(r=e._time),t=e,e=e._next):(n=e._next,e._next=null,e=t?t._next=n:ni=n);ei=t,_i(r)}(),si=0}}function vi(){var t=li.now(),n=t-ui;n>ai&&(ci-=n,ui=t)}function _i(t){ri||(ii&&(ii=clearTimeout(ii)),t-si>24?(t<1/0&&(ii=setTimeout(mi,t-li.now()-ci)),oi&&(oi=clearInterval(oi))):(oi||(ui=li.now(),oi=setInterval(vi,ai)),ri=1,fi(mi)))}function bi(t,n,e){var r=new pi;return n=null==n?0:+n,r.restart((e=>{r.stop(),t(e+n)}),n,e),r}pi.prototype=gi.prototype={constructor:pi,restart:function(t,n,e){if("function"!=typeof t)throw new TypeError("callback is not a function");e=(null==e?hi():+e)+(null==n?0:+n),this._next||ei===this||(ei?ei._next=this:ni=this,ei=this),this._call=t,this._time=e,_i()},stop:function(){this._call&&(this._call=null,this._time=1/0,_i())}};var xi=kt("start","end","cancel","interrupt"),wi=[],Mi=0,ki=1,Ti=2,Ai=3,Si=4,Ei=5,Ci=6;function Ni(t,n,e,r,i,o){var a=t.__transition;if(a){if(e in a)return}else t.__transition={};!function(t,n,e){var r,i=t.__transition;function o(t){e.state=ki,e.timer.restart(a,e.delay,e.time),e.delay<=t&&a(t-e.delay)}function a(o){var c,l,f,h;if(e.state!==ki)return s();for(c in i)if((h=i[c]).name===e.name){if(h.state===Ai)return bi(a);h.state===Si?(h.state=Ci,h.timer.stop(),h.on.call("interrupt",t,t.__data__,h.index,h.group),delete i[c]):+cMi)throw new Error("too late; already scheduled");return e}function Di(t,n){var e=zi(t,n);if(e.state>Ai)throw new Error("too late; already running");return e}function zi(t,n){var e=t.__transition;if(!e||!(e=e[n]))throw new Error("transition not found");return e}function Li(t,n){var e,r,i,o=t.__transition,a=!0;if(o){for(i in n=null==n?null:n+"",o)(e=o[i]).name===n?(r=e.state>Ti&&e.state=0&&(t=t.slice(0,n)),!t||"start"===t}))}(n)?Pi:Di;return function(){var a=o(this,t),u=a.on;u!==r&&(i=(r=u).copy()).on(n,e),a.on=i}}(e,t,n))},attr:function(t,n){var e=Nt(t),r="transform"===e?Ur:Ii;return this.attrTween(t,"function"==typeof n?(e.local?Gi:Yi)(e,r,Bi(this,"attr."+t,n)):null==n?(e.local?Fi:qi)(e):(e.local?Ui:Oi)(e,r,n))},attrTween:function(t,n){var e="attr."+t;if(arguments.length<2)return(e=this.tween(e))&&e._value;if(null==n)return this.tween(e,null);if("function"!=typeof n)throw new Error;var r=Nt(t);return this.tween(e,(r.local?Vi:ji)(r,n))},style:function(t,n,e){var r="transform"==(t+="")?Or:Ii;return null==n?this.styleTween(t,function(t,n){var e,r,i;return function(){var o=cn(this,t),a=(this.style.removeProperty(t),cn(this,t));return o===a?null:o===e&&a===r?i:i=n(e=o,r=a)}}(t,r)).on("end.style."+t,Qi(t)):"function"==typeof n?this.styleTween(t,function(t,n,e){var r,i,o;return function(){var a=cn(this,t),u=e(this),s=u+"";return null==u&&(this.style.removeProperty(t),s=u=cn(this,t)),a===s?null:a===r&&s===i?o:(i=s,o=n(r=a,u))}}(t,r,Bi(this,"style."+t,n))).each(function(t,n){var e,r,i,o,a="style."+n,u="end."+a;return function(){var s=Di(this,t),c=s.on,l=null==s.value[a]?o||(o=Qi(n)):void 0;c===e&&i===l||(r=(e=c).copy()).on(u,i=l),s.on=r}}(this._id,t)):this.styleTween(t,function(t,n,e){var r,i,o=e+"";return function(){var a=cn(this,t);return a===o?null:a===r?i:i=n(r=a,e)}}(t,r,n),e).on("end.style."+t,null)},styleTween:function(t,n,e){var r="style."+(t+="");if(arguments.length<2)return(r=this.tween(r))&&r._value;if(null==n)return this.tween(r,null);if("function"!=typeof n)throw new Error;return this.tween(r,function(t,n,e){var r,i;function o(){var o=n.apply(this,arguments);return o!==i&&(r=(i=o)&&function(t,n,e){return function(r){this.style.setProperty(t,n.call(this,r),e)}}(t,o,e)),r}return o._value=n,o}(t,n,null==e?"":e))},text:function(t){return this.tween("text","function"==typeof t?function(t){return function(){var n=t(this);this.textContent=null==n?"":n}}(Bi(this,"text",t)):function(t){return function(){this.textContent=t}}(null==t?"":t+""))},textTween:function(t){var n="text";if(arguments.length<1)return(n=this.tween(n))&&n._value;if(null==t)return this.tween(n,null);if("function"!=typeof t)throw new Error;return this.tween(n,function(t){var n,e;function r(){var r=t.apply(this,arguments);return r!==e&&(n=(e=r)&&function(t){return function(n){this.textContent=t.call(this,n)}}(r)),n}return r._value=t,r}(t))},remove:function(){return this.on("end.remove",function(t){return function(){var n=this.parentNode;for(var e in this.__transition)if(+e!==t)return;n&&n.removeChild(this)}}(this._id))},tween:function(t,n){var e=this._id;if(t+="",arguments.length<2){for(var r,i=zi(this.node(),e).tween,o=0,a=i.length;o()=>t;function qo(t,{sourceEvent:n,target:e,selection:r,mode:i,dispatch:o}){Object.defineProperties(this,{type:{value:t,enumerable:!0,configurable:!0},sourceEvent:{value:n,enumerable:!0,configurable:!0},target:{value:e,enumerable:!0,configurable:!0},selection:{value:r,enumerable:!0,configurable:!0},mode:{value:i,enumerable:!0,configurable:!0},_:{value:o}})}function Fo(t){t.preventDefault(),t.stopImmediatePropagation()}var Oo={name:"drag"},Uo={name:"space"},Yo={name:"handle"},Go={name:"center"};const{abs:Vo,max:jo,min:$o}=Math;function Xo(t){return[+t[0],+t[1]]}function Wo(t){return[Xo(t[0]),Xo(t[1])]}var Zo={name:"x",handles:["w","e"].map(ia),input:function(t,n){return null==t?null:[[+t[0],n[0][1]],[+t[1],n[1][1]]]},output:function(t){return t&&[t[0][0],t[1][0]]}},Ko={name:"y",handles:["n","s"].map(ia),input:function(t,n){return null==t?null:[[n[0][0],+t[0]],[n[1][0],+t[1]]]},output:function(t){return t&&[t[0][1],t[1][1]]}},Qo={name:"xy",handles:["n","w","e","s","nw","ne","sw","se"].map(ia),input:function(t){return null==t?null:Wo(t)},output:function(t){return t}},Jo={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"},ta={e:"w",w:"e",nw:"ne",ne:"nw",se:"sw",sw:"se"},na={n:"s",s:"n",nw:"sw",ne:"se",se:"ne",sw:"nw"},ea={overlay:1,selection:1,n:null,e:1,s:null,w:-1,nw:-1,ne:1,se:1,sw:-1},ra={overlay:1,selection:1,n:-1,e:null,s:1,w:null,nw:-1,ne:-1,se:1,sw:1};function ia(t){return{type:t}}function oa(t){return!t.ctrlKey&&!t.button}function aa(){var t=this.ownerSVGElement||this;return t.hasAttribute("viewBox")?[[(t=t.viewBox.baseVal).x,t.y],[t.x+t.width,t.y+t.height]]:[[0,0],[t.width.baseVal.value,t.height.baseVal.value]]}function ua(){return navigator.maxTouchPoints||"ontouchstart"in this}function sa(t){for(;!t.__brush;)if(!(t=t.parentNode))return;return t.__brush}function ca(t){var n,e=aa,r=oa,i=ua,o=!0,a=kt("start","brush","end"),u=6;function s(n){var e=n.property("__brush",g).selectAll(".overlay").data([ia("overlay")]);e.enter().append("rect").attr("class","overlay").attr("pointer-events","all").attr("cursor",Jo.overlay).merge(e).each((function(){var t=sa(this).extent;On(this).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])})),n.selectAll(".selection").data([ia("selection")]).enter().append("rect").attr("class","selection").attr("cursor",Jo.selection).attr("fill","#777").attr("fill-opacity",.3).attr("stroke","#fff").attr("shape-rendering","crispEdges");var r=n.selectAll(".handle").data(t.handles,(function(t){return t.type}));r.exit().remove(),r.enter().append("rect").attr("class",(function(t){return"handle handle--"+t.type})).attr("cursor",(function(t){return Jo[t.type]})),n.each(c).attr("fill","none").attr("pointer-events","all").on("mousedown.brush",h).filter(i).on("touchstart.brush",h).on("touchmove.brush",d).on("touchend.brush touchcancel.brush",p).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function c(){var t=On(this),n=sa(this).selection;n?(t.selectAll(".selection").style("display",null).attr("x",n[0][0]).attr("y",n[0][1]).attr("width",n[1][0]-n[0][0]).attr("height",n[1][1]-n[0][1]),t.selectAll(".handle").style("display",null).attr("x",(function(t){return"e"===t.type[t.type.length-1]?n[1][0]-u/2:n[0][0]-u/2})).attr("y",(function(t){return"s"===t.type[0]?n[1][1]-u/2:n[0][1]-u/2})).attr("width",(function(t){return"n"===t.type||"s"===t.type?n[1][0]-n[0][0]+u:u})).attr("height",(function(t){return"e"===t.type||"w"===t.type?n[1][1]-n[0][1]+u:u}))):t.selectAll(".selection,.handle").style("display","none").attr("x",null).attr("y",null).attr("width",null).attr("height",null)}function l(t,n,e){var r=t.__brush.emitter;return!r||e&&r.clean?new f(t,n,e):r}function f(t,n,e){this.that=t,this.args=n,this.state=t.__brush,this.active=0,this.clean=e}function h(e){if((!n||e.touches)&&r.apply(this,arguments)){var i,a,u,s,f,h,d,p,g,y,m,v=this,_=e.target.__data__.type,b="selection"===(o&&e.metaKey?_="overlay":_)?Oo:o&&e.altKey?Go:Yo,x=t===Ko?null:ea[_],w=t===Zo?null:ra[_],M=sa(v),k=M.extent,T=M.selection,A=k[0][0],S=k[0][1],E=k[1][0],C=k[1][1],N=0,P=0,D=x&&w&&o&&e.shiftKey,z=Array.from(e.touches||[e],(t=>{const n=t.identifier;return(t=jn(t,v)).point0=t.slice(),t.identifier=n,t}));Li(v);var L=l(v,arguments,!0).beforestart();if("overlay"===_){T&&(g=!0);const n=[z[0],z[1]||z[0]];M.selection=T=[[i=t===Ko?A:$o(n[0][0],n[1][0]),u=t===Zo?S:$o(n[0][1],n[1][1])],[f=t===Ko?E:jo(n[0][0],n[1][0]),d=t===Zo?C:jo(n[0][1],n[1][1])]],z.length>1&&q(e)}else i=T[0][0],u=T[0][1],f=T[1][0],d=T[1][1];a=i,s=u,h=f,p=d;var H=On(v).attr("pointer-events","none"),R=H.selectAll(".overlay").attr("cursor",Jo[_]);if(e.touches)L.moved=I,L.ended=F;else{var B=On(e.view).on("mousemove.brush",I,!0).on("mouseup.brush",F,!0);o&&B.on("keydown.brush",(function(t){switch(t.keyCode){case 16:D=x&&w;break;case 18:b===Yo&&(x&&(f=h-N*x,i=a+N*x),w&&(d=p-P*w,u=s+P*w),b=Go,q(t));break;case 32:b!==Yo&&b!==Go||(x<0?f=h-N:x>0&&(i=a-N),w<0?d=p-P:w>0&&(u=s-P),b=Uo,R.attr("cursor",Jo.selection),q(t));break;default:return}Fo(t)}),!0).on("keyup.brush",(function(t){switch(t.keyCode){case 16:D&&(y=m=D=!1,q(t));break;case 18:b===Go&&(x<0?f=h:x>0&&(i=a),w<0?d=p:w>0&&(u=s),b=Yo,q(t));break;case 32:b===Uo&&(t.altKey?(x&&(f=h-N*x,i=a+N*x),w&&(d=p-P*w,u=s+P*w),b=Go):(x<0?f=h:x>0&&(i=a),w<0?d=p:w>0&&(u=s),b=Yo),R.attr("cursor",Jo[_]),q(t));break;default:return}Fo(t)}),!0),Kn(e.view)}c.call(v),L.start(e,b.name)}function I(t){for(const n of t.changedTouches||[t])for(const t of z)t.identifier===n.identifier&&(t.cur=jn(n,v));if(D&&!y&&!m&&1===z.length){const t=z[0];Vo(t.cur[0]-t[0])>Vo(t.cur[1]-t[1])?m=!0:y=!0}for(const t of z)t.cur&&(t[0]=t.cur[0],t[1]=t.cur[1]);g=!0,Fo(t),q(t)}function q(t){const n=z[0],e=n.point0;var r;switch(N=n[0]-e[0],P=n[1]-e[1],b){case Uo:case Oo:x&&(N=jo(A-i,$o(E-f,N)),a=i+N,h=f+N),w&&(P=jo(S-u,$o(C-d,P)),s=u+P,p=d+P);break;case Yo:z[1]?(x&&(a=jo(A,$o(E,z[0][0])),h=jo(A,$o(E,z[1][0])),x=1),w&&(s=jo(S,$o(C,z[0][1])),p=jo(S,$o(C,z[1][1])),w=1)):(x<0?(N=jo(A-i,$o(E-i,N)),a=i+N,h=f):x>0&&(N=jo(A-f,$o(E-f,N)),a=i,h=f+N),w<0?(P=jo(S-u,$o(C-u,P)),s=u+P,p=d):w>0&&(P=jo(S-d,$o(C-d,P)),s=u,p=d+P));break;case Go:x&&(a=jo(A,$o(E,i-N*x)),h=jo(A,$o(E,f+N*x))),w&&(s=jo(S,$o(C,u-P*w)),p=jo(S,$o(C,d+P*w)))}ht+e))}function _a(t,n){var e=0,r=null,i=null,o=null;function a(a){var u,s=a.length,c=new Array(s),l=va(0,s),f=new Array(s*s),h=new Array(s),d=0;a=Float64Array.from({length:s*s},n?(t,n)=>a[n%s][n/s|0]:(t,n)=>a[n/s|0][n%s]);for(let n=0;nr(c[t],c[n])));for(const e of l){const r=n;if(t){const t=va(1+~s,s).filter((t=>t<0?a[~t*s+e]:a[e*s+t]));i&&t.sort(((t,n)=>i(t<0?-a[~t*s+e]:a[e*s+t],n<0?-a[~n*s+e]:a[e*s+n])));for(const r of t)r<0?(f[~r*s+e]||(f[~r*s+e]={source:null,target:null})).target={index:e,startAngle:n,endAngle:n+=a[~r*s+e]*d,value:a[~r*s+e]}:(f[e*s+r]||(f[e*s+r]={source:null,target:null})).source={index:e,startAngle:n,endAngle:n+=a[e*s+r]*d,value:a[e*s+r]};h[e]={index:e,startAngle:r,endAngle:n,value:c[e]}}else{const t=va(0,s).filter((t=>a[e*s+t]||a[t*s+e]));i&&t.sort(((t,n)=>i(a[e*s+t],a[e*s+n])));for(const r of t){let t;if(ewa)if(Math.abs(l*u-s*c)>wa&&i){var h=e-o,d=r-a,p=u*u+s*s,g=h*h+d*d,y=Math.sqrt(p),m=Math.sqrt(f),v=i*Math.tan((ba-Math.acos((p+f-g)/(2*y*m)))/2),_=v/m,b=v/y;Math.abs(_-1)>wa&&(this._+="L"+(t+_*c)+","+(n+_*l)),this._+="A"+i+","+i+",0,0,"+ +(l*h>c*d)+","+(this._x1=t+b*u)+","+(this._y1=n+b*s)}else this._+="L"+(this._x1=t)+","+(this._y1=n)},arc:function(t,n,e,r,i,o){t=+t,n=+n,o=!!o;var a=(e=+e)*Math.cos(r),u=e*Math.sin(r),s=t+a,c=n+u,l=1^o,f=o?r-i:i-r;if(e<0)throw new Error("negative radius: "+e);null===this._x1?this._+="M"+s+","+c:(Math.abs(this._x1-s)>wa||Math.abs(this._y1-c)>wa)&&(this._+="L"+s+","+c),e&&(f<0&&(f=f%xa+xa),f>Ma?this._+="A"+e+","+e+",0,1,"+l+","+(t-a)+","+(n-u)+"A"+e+","+e+",0,1,"+l+","+(this._x1=s)+","+(this._y1=c):f>wa&&(this._+="A"+e+","+e+",0,"+ +(f>=ba)+","+l+","+(this._x1=t+e*Math.cos(i))+","+(this._y1=n+e*Math.sin(i))))},rect:function(t,n,e,r){this._+="M"+(this._x0=this._x1=+t)+","+(this._y0=this._y1=+n)+"h"+ +e+"v"+ +r+"h"+-e+"Z"},toString:function(){return this._}};var Aa=Array.prototype.slice;function Sa(t){return function(){return t}}function Ea(t){return t.source}function Ca(t){return t.target}function Na(t){return t.radius}function Pa(t){return t.startAngle}function Da(t){return t.endAngle}function za(){return 0}function La(){return 10}function Ha(t){var n=Ea,e=Ca,r=Na,i=Na,o=Pa,a=Da,u=za,s=null;function c(){var c,l=n.apply(this,arguments),f=e.apply(this,arguments),h=u.apply(this,arguments)/2,d=Aa.call(arguments),p=+r.apply(this,(d[0]=l,d)),g=o.apply(this,d)-pa,y=a.apply(this,d)-pa,m=+i.apply(this,(d[0]=f,d)),v=o.apply(this,d)-pa,_=a.apply(this,d)-pa;if(s||(s=c=Ta()),h>ma&&(la(y-g)>2*h+ma?y>g?(g+=h,y-=h):(g-=h,y+=h):g=y=(g+y)/2,la(_-v)>2*h+ma?_>v?(v+=h,_-=h):(v-=h,_+=h):v=_=(v+_)/2),s.moveTo(p*fa(g),p*ha(g)),s.arc(0,0,p,g,y),g!==v||y!==_)if(t){var b=m-+t.apply(this,arguments),x=(v+_)/2;s.quadraticCurveTo(0,0,b*fa(v),b*ha(v)),s.lineTo(m*fa(x),m*ha(x)),s.lineTo(b*fa(_),b*ha(_))}else s.quadraticCurveTo(0,0,m*fa(v),m*ha(v)),s.arc(0,0,m,v,_);if(s.quadraticCurveTo(0,0,p*fa(g),p*ha(g)),s.closePath(),c)return s=null,c+""||null}return t&&(c.headRadius=function(n){return arguments.length?(t="function"==typeof n?n:Sa(+n),c):t}),c.radius=function(t){return arguments.length?(r=i="function"==typeof t?t:Sa(+t),c):r},c.sourceRadius=function(t){return arguments.length?(r="function"==typeof t?t:Sa(+t),c):r},c.targetRadius=function(t){return arguments.length?(i="function"==typeof t?t:Sa(+t),c):i},c.startAngle=function(t){return arguments.length?(o="function"==typeof t?t:Sa(+t),c):o},c.endAngle=function(t){return arguments.length?(a="function"==typeof t?t:Sa(+t),c):a},c.padAngle=function(t){return arguments.length?(u="function"==typeof t?t:Sa(+t),c):u},c.source=function(t){return arguments.length?(n=t,c):n},c.target=function(t){return arguments.length?(e=t,c):e},c.context=function(t){return arguments.length?(s=null==t?null:t,c):s},c}var Ra=Array.prototype.slice;function Ba(t,n){return t-n}var Ia=t=>()=>t;function qa(t,n){for(var e,r=-1,i=n.length;++rr!=d>r&&e<(h-c)*(r-l)/(d-l)+c&&(i=-i)}return i}function Oa(t,n,e){var r,i,o,a;return function(t,n,e){return(n[0]-t[0])*(e[1]-t[1])==(e[0]-t[0])*(n[1]-t[1])}(t,n,e)&&(i=t[r=+(t[0]===n[0])],o=e[r],a=n[r],i<=o&&o<=a||a<=o&&o<=i)}function Ua(){}var Ya=[[],[[[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 Ga(){var t=1,n=1,e=G,r=u;function i(t){var n=e(t);if(Array.isArray(n))n=n.slice().sort(Ba);else{const e=g(t),r=U(e[0],e[1],n);n=F(Math.floor(e[0]/r)*r,Math.floor(e[1]/r-1)*r,n)}return n.map((n=>o(t,n)))}function o(e,i){var o=[],u=[];return function(e,r,i){var o,u,s,c,l,f,h=new Array,d=new Array;for(o=u=-1,c=e[0]>=r,Ya[c<<1].forEach(p);++o=r,Ya[s|c<<1].forEach(p);for(Ya[0|c].forEach(p);++u=r,l=e[u*t]>=r,Ya[c<<1|l<<2].forEach(p);++o=r,f=l,l=e[u*t+o+1]>=r,Ya[s|c<<1|l<<2|f<<3].forEach(p);Ya[c|l<<3].forEach(p)}for(o=-1,l=e[u*t]>=r,Ya[l<<2].forEach(p);++o=r,Ya[l<<2|f<<3].forEach(p);function p(t){var n,e,r=[t[0][0]+o,t[0][1]+u],s=[t[1][0]+o,t[1][1]+u],c=a(r),l=a(s);(n=d[c])?(e=h[l])?(delete d[n.end],delete h[e.start],n===e?(n.ring.push(s),i(n.ring)):h[n.start]=d[e.end]={start:n.start,end:e.end,ring:n.ring.concat(e.ring)}):(delete d[n.end],n.ring.push(s),d[n.end=l]=n):(n=h[l])?(e=d[c])?(delete h[n.start],delete d[e.end],n===e?(n.ring.push(s),i(n.ring)):h[e.start]=d[n.end]={start:e.start,end:n.end,ring:e.ring.concat(n.ring)}):(delete h[n.start],n.ring.unshift(r),h[n.start=c]=n):h[c]=d[l]={start:c,end:l,ring:[r,s]}}Ya[l<<3].forEach(p)}(e,i,(function(t){r(t,e,i),function(t){for(var n=0,e=t.length,r=t[e-1][1]*t[0][0]-t[e-1][0]*t[0][1];++n0?o.push([t]):u.push(t)})),u.forEach((function(t){for(var n,e=0,r=o.length;e0&&a0&&u=0&&o>=0))throw new Error("invalid size");return t=r,n=o,i},i.thresholds=function(t){return arguments.length?(e="function"==typeof t?t:Array.isArray(t)?Ia(Ra.call(t)):Ia(t),i):e},i.smooth=function(t){return arguments.length?(r=t?u:Ua,i):r===u},i}function Va(t,n,e){for(var r=t.width,i=t.height,o=1+(e<<1),a=0;a=e&&(u>=o&&(s-=t.data[u-o+a*r]),n.data[u-e+a*r]=s/Math.min(u+1,r-1+o-u,o))}function ja(t,n,e){for(var r=t.width,i=t.height,o=1+(e<<1),a=0;a=e&&(u>=o&&(s-=t.data[a+(u-o)*r]),n.data[a+(u-e)*r]=s/Math.min(u+1,i-1+o-u,o))}function $a(t){return t[0]}function Xa(t){return t[1]}function Wa(){return 1}const Za=134217729,Ka=33306690738754706e-32;function Qa(t,n,e,r,i){let o,a,u,s,c=n[0],l=r[0],f=0,h=0;l>c==l>-c?(o=c,c=n[++f]):(o=l,l=r[++h]);let d=0;if(fc==l>-c?(a=c+o,u=o-(a-c),c=n[++f]):(a=l+o,u=o-(a-l),l=r[++h]),o=a,0!==u&&(i[d++]=u);fc==l>-c?(a=o+c,s=a-o,u=o-(a-s)+(c-s),c=n[++f]):(a=o+l,s=a-o,u=o-(a-s)+(l-s),l=r[++h]),o=a,0!==u&&(i[d++]=u);for(;f0!=u>0)return s;const c=Math.abs(a+u);return Math.abs(s)>=33306690738754716e-32*c?s:-function(t,n,e,r,i,o,a){let u,s,c,l,f,h,d,p,g,y,m,v,_,b,x,w,M,k;const T=t-i,A=e-i,S=n-o,E=r-o;b=T*E,h=Za*T,d=h-(h-T),p=T-d,h=Za*E,g=h-(h-E),y=E-g,x=p*y-(b-d*g-p*g-d*y),w=S*A,h=Za*S,d=h-(h-S),p=S-d,h=Za*A,g=h-(h-A),y=A-g,M=p*y-(w-d*g-p*g-d*y),m=x-M,f=x-m,eu[0]=x-(m+f)+(f-M),v=b+m,f=v-b,_=b-(v-f)+(m-f),m=_-w,f=_-m,eu[1]=_-(m+f)+(f-w),k=v+m,f=k-v,eu[2]=v-(k-f)+(m-f),eu[3]=k;let C=function(t,n){let e=n[0];for(let r=1;r=N||-C>=N)return C;if(f=t-T,u=t-(T+f)+(f-i),f=e-A,c=e-(A+f)+(f-i),f=n-S,s=n-(S+f)+(f-o),f=r-E,l=r-(E+f)+(f-o),0===u&&0===s&&0===c&&0===l)return C;if(N=nu*a+Ka*Math.abs(C),C+=T*l+E*u-(S*c+A*s),C>=N||-C>=N)return C;b=u*E,h=Za*u,d=h-(h-u),p=u-d,h=Za*E,g=h-(h-E),y=E-g,x=p*y-(b-d*g-p*g-d*y),w=s*A,h=Za*s,d=h-(h-s),p=s-d,h=Za*A,g=h-(h-A),y=A-g,M=p*y-(w-d*g-p*g-d*y),m=x-M,f=x-m,au[0]=x-(m+f)+(f-M),v=b+m,f=v-b,_=b-(v-f)+(m-f),m=_-w,f=_-m,au[1]=_-(m+f)+(f-w),k=v+m,f=k-v,au[2]=v-(k-f)+(m-f),au[3]=k;const P=Qa(4,eu,4,au,ru);b=T*l,h=Za*T,d=h-(h-T),p=T-d,h=Za*l,g=h-(h-l),y=l-g,x=p*y-(b-d*g-p*g-d*y),w=S*c,h=Za*S,d=h-(h-S),p=S-d,h=Za*c,g=h-(h-c),y=c-g,M=p*y-(w-d*g-p*g-d*y),m=x-M,f=x-m,au[0]=x-(m+f)+(f-M),v=b+m,f=v-b,_=b-(v-f)+(m-f),m=_-w,f=_-m,au[1]=_-(m+f)+(f-w),k=v+m,f=k-v,au[2]=v-(k-f)+(m-f),au[3]=k;const D=Qa(P,ru,4,au,iu);b=u*l,h=Za*u,d=h-(h-u),p=u-d,h=Za*l,g=h-(h-l),y=l-g,x=p*y-(b-d*g-p*g-d*y),w=s*c,h=Za*s,d=h-(h-s),p=s-d,h=Za*c,g=h-(h-c),y=c-g,M=p*y-(w-d*g-p*g-d*y),m=x-M,f=x-m,au[0]=x-(m+f)+(f-M),v=b+m,f=v-b,_=b-(v-f)+(m-f),m=_-w,f=_-m,au[1]=_-(m+f)+(f-w),k=v+m,f=k-v,au[2]=v-(k-f)+(m-f),au[3]=k;const z=Qa(D,iu,4,au,ou);return ou[z-1]}(t,n,e,r,i,o,c)}const su=Math.pow(2,-52),cu=new Uint32Array(512);class lu{static from(t,n=yu,e=mu){const r=t.length,i=new Float64Array(2*r);for(let o=0;o>1;if(n>0&&"number"!=typeof t[0])throw new Error("Expected coords to contain numbers.");this.coords=t;const e=Math.max(2*n-5,0);this._triangles=new Uint32Array(3*e),this._halfedges=new Int32Array(3*e),this._hashSize=Math.ceil(Math.sqrt(n)),this._hullPrev=new Uint32Array(n),this._hullNext=new Uint32Array(n),this._hullTri=new Uint32Array(n),this._hullHash=new Int32Array(this._hashSize).fill(-1),this._ids=new Uint32Array(n),this._dists=new Float64Array(n),this.update()}update(){const{coords:t,_hullPrev:n,_hullNext:e,_hullTri:r,_hullHash:i}=this,o=t.length>>1;let a=1/0,u=1/0,s=-1/0,c=-1/0;for(let n=0;ns&&(s=e),r>c&&(c=r),this._ids[n]=n}const l=(a+s)/2,f=(u+c)/2;let h,d,p,g=1/0;for(let n=0;n0&&(d=n,g=e)}let v=t[2*d],_=t[2*d+1],b=1/0;for(let n=0;nr&&(n[e++]=i,r=this._dists[i])}return this.hull=n.subarray(0,e),this.triangles=new Uint32Array(0),void(this.halfedges=new Uint32Array(0))}if(uu(y,m,v,_,x,w)<0){const t=d,n=v,e=_;d=p,v=x,_=w,p=t,x=n,w=e}const M=function(t,n,e,r,i,o){const a=e-t,u=r-n,s=i-t,c=o-n,l=a*a+u*u,f=s*s+c*c,h=.5/(a*c-u*s);return{x:t+(c*l-u*f)*h,y:n+(a*f-s*l)*h}}(y,m,v,_,x,w);this._cx=M.x,this._cy=M.y;for(let n=0;n0&&Math.abs(c-o)<=su&&Math.abs(l-a)<=su)continue;if(o=c,a=l,s===h||s===d||s===p)continue;let f=0;for(let t=0,n=this._hashKey(c,l);t=0;)if(y=g,y===f){y=-1;break}if(-1===y)continue;let m=this._addTriangle(y,s,e[y],-1,-1,r[y]);r[s]=this._legalize(m+2),r[y]=m,k++;let v=e[y];for(;g=e[v],uu(c,l,t[2*v],t[2*v+1],t[2*g],t[2*g+1])<0;)m=this._addTriangle(v,s,g,r[s],-1,r[v]),r[s]=this._legalize(m+2),e[v]=v,k--,v=g;if(y===f)for(;g=n[y],uu(c,l,t[2*g],t[2*g+1],t[2*y],t[2*y+1])<0;)m=this._addTriangle(g,s,y,-1,r[y],r[g]),this._legalize(m+2),r[g]=m,e[y]=y,k--,y=g;this._hullStart=n[s]=y,e[y]=n[v]=s,e[s]=v,i[this._hashKey(c,l)]=s,i[this._hashKey(t[2*y],t[2*y+1])]=y}this.hull=new Uint32Array(k);for(let t=0,n=this._hullStart;t0?3-e:1+e)/4}(t-this._cx,n-this._cy)*this._hashSize)%this._hashSize}_legalize(t){const{_triangles:n,_halfedges:e,coords:r}=this;let i=0,o=0;for(;;){const a=e[t],u=t-t%3;if(o=u+(t+2)%3,-1===a){if(0===i)break;t=cu[--i];continue}const s=a-a%3,c=u+(t+1)%3,l=s+(a+2)%3,f=n[o],h=n[t],d=n[c],p=n[l];if(hu(r[2*f],r[2*f+1],r[2*h],r[2*h+1],r[2*d],r[2*d+1],r[2*p],r[2*p+1])){n[t]=p,n[a]=f;const r=e[l];if(-1===r){let n=this._hullStart;do{if(this._hullTri[n]===l){this._hullTri[n]=t;break}n=this._hullPrev[n]}while(n!==this._hullStart)}this._link(t,r),this._link(a,e[o]),this._link(o,l);const u=s+(a+1)%3;i=e&&n[t[a]]>o;)t[a+1]=t[a--];t[a+1]=r}else{let i=e+1,o=r;gu(t,e+r>>1,i),n[t[e]]>n[t[r]]&&gu(t,e,r),n[t[i]]>n[t[r]]&&gu(t,i,r),n[t[e]]>n[t[i]]&&gu(t,e,i);const a=t[i],u=n[a];for(;;){do{i++}while(n[t[i]]u);if(o=o-e?(pu(t,n,i,r),pu(t,n,e,o-1)):(pu(t,n,e,o-1),pu(t,n,i,r))}}function gu(t,n,e){const r=t[n];t[n]=t[e],t[e]=r}function yu(t){return t[0]}function mu(t){return t[1]}const vu=1e-6;class _u{constructor(){this._x0=this._y0=this._x1=this._y1=null,this._=""}moveTo(t,n){this._+=`M${this._x0=this._x1=+t},${this._y0=this._y1=+n}`}closePath(){null!==this._x1&&(this._x1=this._x0,this._y1=this._y0,this._+="Z")}lineTo(t,n){this._+=`L${this._x1=+t},${this._y1=+n}`}arc(t,n,e){const r=(t=+t)+(e=+e),i=n=+n;if(e<0)throw new Error("negative radius");null===this._x1?this._+=`M${r},${i}`:(Math.abs(this._x1-r)>vu||Math.abs(this._y1-i)>vu)&&(this._+="L"+r+","+i),e&&(this._+=`A${e},${e},0,1,1,${t-e},${n}A${e},${e},0,1,1,${this._x1=r},${this._y1=i}`)}rect(t,n,e,r){this._+=`M${this._x0=this._x1=+t},${this._y0=this._y1=+n}h${+e}v${+r}h${-e}Z`}value(){return this._||null}}class bu{constructor(){this._=[]}moveTo(t,n){this._.push([t,n])}closePath(){this._.push(this._[0].slice())}lineTo(t,n){this._.push([t,n])}value(){return this._.length?this._:null}}class xu{constructor(t,[n,e,r,i]=[0,0,960,500]){if(!((r=+r)>=(n=+n)&&(i=+i)>=(e=+e)))throw new Error("invalid bounds");this.delaunay=t,this._circumcenters=new Float64Array(2*t.points.length),this.vectors=new Float64Array(2*t.points.length),this.xmax=r,this.xmin=n,this.ymax=i,this.ymin=e,this._init()}update(){return this.delaunay.update(),this._init(),this}_init(){const{delaunay:{points:t,hull:n,triangles:e},vectors:r}=this,i=this.circumcenters=this._circumcenters.subarray(0,e.length/3*2);for(let n,r,o=0,a=0,u=e.length;o1;)i-=2;for(let t=2;t4)for(let t=0;t0){if(n>=this.ymax)return null;(i=(this.ymax-n)/r)0){if(t>=this.xmax)return null;(i=(this.xmax-t)/e)this.xmax?2:0)|(nthis.ymax?8:0)}}const wu=2*Math.PI,Mu=Math.pow;function ku(t){return t[0]}function Tu(t){return t[1]}function Au(t,n,e){return[t+Math.sin(t+n)*e,n+Math.cos(t-n)*e]}class Su{static from(t,n=ku,e=Tu,r){return new Su("length"in t?function(t,n,e,r){const i=t.length,o=new Float64Array(2*i);for(let a=0;a2&&function(t){const{triangles:n,coords:e}=t;for(let t=0;t1e-10)return!1}return!0}(t)){this.collinear=Int32Array.from({length:n.length/2},((t,n)=>n)).sort(((t,e)=>n[2*t]-n[2*e]||n[2*t+1]-n[2*e+1]));const t=this.collinear[0],e=this.collinear[this.collinear.length-1],r=[n[2*t],n[2*t+1],n[2*e],n[2*e+1]],i=1e-8*Math.hypot(r[3]-r[1],r[2]-r[0]);for(let t=0,e=n.length/2;t0&&(this.triangles=new Int32Array(3).fill(-1),this.halfedges=new Int32Array(3).fill(-1),this.triangles[0]=r[0],o[r[0]]=1,2===r.length&&(o[r[1]]=0,this.triangles[1]=r[1],this.triangles[2]=r[1]))}voronoi(t){return new xu(this,t)}*neighbors(t){const{inedges:n,hull:e,_hullIndex:r,halfedges:i,triangles:o,collinear:a}=this;if(a){const n=a.indexOf(t);return n>0&&(yield a[n-1]),void(n=0&&i!==e&&i!==r;)e=i;return i}_step(t,n,e){const{inedges:r,hull:i,_hullIndex:o,halfedges:a,triangles:u,points:s}=this;if(-1===r[t]||!s.length)return(t+1)%(s.length>>1);let c=t,l=Mu(n-s[2*t],2)+Mu(e-s[2*t+1],2);const f=r[t];let h=f;do{let r=u[h];const f=Mu(n-s[2*r],2)+Mu(e-s[2*r+1],2);if(f9999?"+"+Hu(t,6):Hu(t,4)}(t.getUTCFullYear())+"-"+Hu(t.getUTCMonth()+1,2)+"-"+Hu(t.getUTCDate(),2)+(i?"T"+Hu(n,2)+":"+Hu(e,2)+":"+Hu(r,2)+"."+Hu(i,3)+"Z":r?"T"+Hu(n,2)+":"+Hu(e,2)+":"+Hu(r,2)+"Z":e||n?"T"+Hu(n,2)+":"+Hu(e,2)+"Z":"")}function Bu(t){var n=new RegExp('["'+t+"\n\r]"),e=t.charCodeAt(0);function r(t,n){var r,i=[],o=t.length,a=0,u=0,s=o<=0,c=!1;function l(){if(s)return Cu;if(c)return c=!1,Eu;var n,r,i=a;if(t.charCodeAt(i)===Nu){for(;a++=o?s=!0:(r=t.charCodeAt(a++))===Pu?c=!0:r===Du&&(c=!0,t.charCodeAt(a)===Pu&&++a),t.slice(i+1,n-1).replace(/""/g,'"')}for(;ais(n,e).then((n=>(new DOMParser).parseFromString(n,t)))}var ls=cs("application/xml"),fs=cs("text/html"),hs=cs("image/svg+xml");function ds(t,n,e,r){if(isNaN(n)||isNaN(e))return t;var i,o,a,u,s,c,l,f,h,d=t._root,p={data:r},g=t._x0,y=t._y0,m=t._x1,v=t._y1;if(!d)return t._root=p,t;for(;d.length;)if((c=n>=(o=(g+m)/2))?g=o:m=o,(l=e>=(a=(y+v)/2))?y=a:v=a,i=d,!(d=d[f=l<<1|c]))return i[f]=p,t;if(u=+t._x.call(null,d.data),s=+t._y.call(null,d.data),n===u&&e===s)return p.next=d,i?i[f]=p:t._root=p,t;do{i=i?i[f]=new Array(4):t._root=new Array(4),(c=n>=(o=(g+m)/2))?g=o:m=o,(l=e>=(a=(y+v)/2))?y=a:v=a}while((f=l<<1|c)==(h=(s>=a)<<1|u>=o));return i[h]=d,i[f]=p,t}function ps(t,n,e,r,i){this.node=t,this.x0=n,this.y0=e,this.x1=r,this.y1=i}function gs(t){return t[0]}function ys(t){return t[1]}function ms(t,n,e){var r=new vs(null==n?gs:n,null==e?ys:e,NaN,NaN,NaN,NaN);return null==t?r:r.addAll(t)}function vs(t,n,e,r,i,o){this._x=t,this._y=n,this._x0=e,this._y0=r,this._x1=i,this._y1=o,this._root=void 0}function _s(t){for(var n={data:t.data},e=n;t=t.next;)e=e.next={data:t.data};return n}var bs=ms.prototype=vs.prototype;function xs(t){return function(){return t}}function ws(t){return 1e-6*(t()-.5)}function Ms(t){return t.x+t.vx}function ks(t){return t.y+t.vy}function Ts(t){return t.index}function As(t,n){var e=t.get(n);if(!e)throw new Error("node not found: "+n);return e}bs.copy=function(){var t,n,e=new vs(this._x,this._y,this._x0,this._y0,this._x1,this._y1),r=this._root;if(!r)return e;if(!r.length)return e._root=_s(r),e;for(t=[{source:r,target:e._root=new Array(4)}];r=t.pop();)for(var i=0;i<4;++i)(n=r.source[i])&&(n.length?t.push({source:n,target:r.target[i]=new Array(4)}):r.target[i]=_s(n));return e},bs.add=function(t){const n=+this._x.call(null,t),e=+this._y.call(null,t);return ds(this.cover(n,e),n,e,t)},bs.addAll=function(t){var n,e,r,i,o=t.length,a=new Array(o),u=new Array(o),s=1/0,c=1/0,l=-1/0,f=-1/0;for(e=0;el&&(l=r),if&&(f=i));if(s>l||c>f)return this;for(this.cover(s,c).cover(l,f),e=0;et||t>=i||r>n||n>=o;)switch(u=(nh||(o=s.y0)>d||(a=s.x1)=m)<<1|t>=y)&&(s=p[p.length-1],p[p.length-1]=p[p.length-1-c],p[p.length-1-c]=s)}else{var v=t-+this._x.call(null,g.data),_=n-+this._y.call(null,g.data),b=v*v+_*_;if(b=(u=(p+y)/2))?p=u:y=u,(l=a>=(s=(g+m)/2))?g=s:m=s,n=d,!(d=d[f=l<<1|c]))return this;if(!d.length)break;(n[f+1&3]||n[f+2&3]||n[f+3&3])&&(e=n,h=f)}for(;d.data!==t;)if(r=d,!(d=d.next))return this;return(i=d.next)&&delete d.next,r?(i?r.next=i:delete r.next,this):n?(i?n[f]=i:delete n[f],(d=n[0]||n[1]||n[2]||n[3])&&d===(n[3]||n[2]||n[1]||n[0])&&!d.length&&(e?e[h]=d:this._root=d),this):(this._root=i,this)},bs.removeAll=function(t){for(var n=0,e=t.length;n1?r[0]+r.slice(2):r,+t.slice(e+1)]}function Ls(t){return(t=zs(Math.abs(t)))?t[1]:NaN}var Hs,Rs=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function Bs(t){if(!(n=Rs.exec(t)))throw new Error("invalid format: "+t);var n;return new Is({fill:n[1],align:n[2],sign:n[3],symbol:n[4],zero:n[5],width:n[6],comma:n[7],precision:n[8]&&n[8].slice(1),trim:n[9],type:n[10]})}function Is(t){this.fill=void 0===t.fill?" ":t.fill+"",this.align=void 0===t.align?">":t.align+"",this.sign=void 0===t.sign?"-":t.sign+"",this.symbol=void 0===t.symbol?"":t.symbol+"",this.zero=!!t.zero,this.width=void 0===t.width?void 0:+t.width,this.comma=!!t.comma,this.precision=void 0===t.precision?void 0:+t.precision,this.trim=!!t.trim,this.type=void 0===t.type?"":t.type+""}function qs(t,n){var e=zs(t,n);if(!e)return t+"";var r=e[0],i=e[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")}Bs.prototype=Is.prototype,Is.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 Fs={"%":(t,n)=>(100*t).toFixed(n),b:t=>Math.round(t).toString(2),c:t=>t+"",d:function(t){return Math.abs(t=Math.round(t))>=1e21?t.toLocaleString("en").replace(/,/g,""):t.toString(10)},e:(t,n)=>t.toExponential(n),f:(t,n)=>t.toFixed(n),g:(t,n)=>t.toPrecision(n),o:t=>Math.round(t).toString(8),p:(t,n)=>qs(100*t,n),r:qs,s:function(t,n){var e=zs(t,n);if(!e)return t+"";var r=e[0],i=e[1],o=i-(Hs=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")+zs(t,Math.max(0,n+o-1))[0]},X:t=>Math.round(t).toString(16).toUpperCase(),x:t=>Math.round(t).toString(16)};function Os(t){return t}var Us,Ys=Array.prototype.map,Gs=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function Vs(t){var n,e,r=void 0===t.grouping||void 0===t.thousands?Os:(n=Ys.call(t.grouping,Number),e=t.thousands+"",function(t,r){for(var i=t.length,o=[],a=0,u=n[0],s=0;i>0&&u>0&&(s+u+1>r&&(u=Math.max(1,r-s)),o.push(t.substring(i-=u,i+u)),!((s+=u+1)>r));)u=n[a=(a+1)%n.length];return o.reverse().join(e)}),i=void 0===t.currency?"":t.currency[0]+"",o=void 0===t.currency?"":t.currency[1]+"",a=void 0===t.decimal?".":t.decimal+"",u=void 0===t.numerals?Os:function(t){return function(n){return n.replace(/[0-9]/g,(function(n){return t[+n]}))}}(Ys.call(t.numerals,String)),s=void 0===t.percent?"%":t.percent+"",c=void 0===t.minus?"−":t.minus+"",l=void 0===t.nan?"NaN":t.nan+"";function f(t){var n=(t=Bs(t)).fill,e=t.align,f=t.sign,h=t.symbol,d=t.zero,p=t.width,g=t.comma,y=t.precision,m=t.trim,v=t.type;"n"===v?(g=!0,v="g"):Fs[v]||(void 0===y&&(y=12),m=!0,v="g"),(d||"0"===n&&"="===e)&&(d=!0,n="0",e="=");var _="$"===h?i:"#"===h&&/[boxX]/.test(v)?"0"+v.toLowerCase():"",b="$"===h?o:/[%p]/.test(v)?s:"",x=Fs[v],w=/[defgprs%]/.test(v);function M(t){var i,o,s,h=_,M=b;if("c"===v)M=x(t)+M,t="";else{var k=(t=+t)<0||1/t<0;if(t=isNaN(t)?l:x(Math.abs(t),y),m&&(t=function(t){t:for(var n,e=t.length,r=1,i=-1;r0&&(i=0)}return i>0?t.slice(0,i)+t.slice(n+1):t}(t)),k&&0==+t&&"+"!==f&&(k=!1),h=(k?"("===f?f:c:"-"===f||"("===f?"":f)+h,M=("s"===v?Gs[8+Hs/3]:"")+M+(k&&"("===f?")":""),w)for(i=-1,o=t.length;++i(s=t.charCodeAt(i))||s>57){M=(46===s?a+t.slice(i+1):t.slice(i))+M,t=t.slice(0,i);break}}g&&!d&&(t=r(t,1/0));var T=h.length+t.length+M.length,A=T>1)+h+t+M+A.slice(T);break;default:t=A+h+t+M}return u(t)}return y=void 0===y?6:/[gprs]/.test(v)?Math.max(1,Math.min(21,y)):Math.max(0,Math.min(20,y)),M.toString=function(){return t+""},M}return{format:f,formatPrefix:function(t,n){var e=f(((t=Bs(t)).type="f",t)),r=3*Math.max(-8,Math.min(8,Math.floor(Ls(n)/3))),i=Math.pow(10,-r),o=Gs[8+r/3];return function(t){return e(i*t)+o}}}}function js(n){return Us=Vs(n),t.format=Us.format,t.formatPrefix=Us.formatPrefix,Us}function $s(t){return Math.max(0,-Ls(Math.abs(t)))}function Xs(t,n){return Math.max(0,3*Math.max(-8,Math.min(8,Math.floor(Ls(n)/3)))-Ls(Math.abs(t)))}function Ws(t,n){return t=Math.abs(t),n=Math.abs(n)-t,Math.max(0,Ls(n)-Ls(t))+1}t.format=void 0,t.formatPrefix=void 0,js({thousands:",",grouping:[3],currency:["$",""]});var Zs=1e-6,Ks=1e-12,Qs=Math.PI,Js=Qs/2,tc=Qs/4,nc=2*Qs,ec=180/Qs,rc=Qs/180,ic=Math.abs,oc=Math.atan,ac=Math.atan2,uc=Math.cos,sc=Math.ceil,cc=Math.exp,lc=Math.hypot,fc=Math.log,hc=Math.pow,dc=Math.sin,pc=Math.sign||function(t){return t>0?1:t<0?-1:0},gc=Math.sqrt,yc=Math.tan;function mc(t){return t>1?0:t<-1?Qs:Math.acos(t)}function vc(t){return t>1?Js:t<-1?-Js:Math.asin(t)}function _c(t){return(t=dc(t/2))*t}function bc(){}function xc(t,n){t&&Mc.hasOwnProperty(t.type)&&Mc[t.type](t,n)}var wc={Feature:function(t,n){xc(t.geometry,n)},FeatureCollection:function(t,n){for(var e=t.features,r=-1,i=e.length;++r=0?1:-1,i=r*e,o=uc(n=(n*=rc)/2+tc),a=dc(n),u=Pc*a,s=Nc*o+u*uc(i),c=u*r*dc(i);Yc.add(ac(c,s)),Cc=t,Nc=o,Pc=a}function Zc(t){return[ac(t[1],t[0]),vc(t[2])]}function Kc(t){var n=t[0],e=t[1],r=uc(e);return[r*uc(n),r*dc(n),dc(e)]}function Qc(t,n){return t[0]*n[0]+t[1]*n[1]+t[2]*n[2]}function Jc(t,n){return[t[1]*n[2]-t[2]*n[1],t[2]*n[0]-t[0]*n[2],t[0]*n[1]-t[1]*n[0]]}function tl(t,n){t[0]+=n[0],t[1]+=n[1],t[2]+=n[2]}function nl(t,n){return[t[0]*n,t[1]*n,t[2]*n]}function el(t){var n=gc(t[0]*t[0]+t[1]*t[1]+t[2]*t[2]);t[0]/=n,t[1]/=n,t[2]/=n}var rl,il,ol,al,ul,sl,cl,ll,fl,hl,dl,pl,gl,yl,ml,vl,_l={point:bl,lineStart:wl,lineEnd:Ml,polygonStart:function(){_l.point=kl,_l.lineStart=Tl,_l.lineEnd=Al,Fc=new y,Vc.polygonStart()},polygonEnd:function(){Vc.polygonEnd(),_l.point=bl,_l.lineStart=wl,_l.lineEnd=Ml,Yc<0?(Dc=-(Lc=180),zc=-(Hc=90)):Fc>Zs?Hc=90:Fc<-Zs&&(zc=-90),Uc[0]=Dc,Uc[1]=Lc},sphere:function(){Dc=-(Lc=180),zc=-(Hc=90)}};function bl(t,n){Oc.push(Uc=[Dc=t,Lc=t]),nHc&&(Hc=n)}function xl(t,n){var e=Kc([t*rc,n*rc]);if(qc){var r=Jc(qc,e),i=Jc([r[1],-r[0],0],r);el(i),i=Zc(i);var o,a=t-Rc,u=a>0?1:-1,s=i[0]*ec*u,c=ic(a)>180;c^(u*RcHc&&(Hc=o):c^(u*Rc<(s=(s+360)%360-180)&&sHc&&(Hc=n)),c?tSl(Dc,Lc)&&(Lc=t):Sl(t,Lc)>Sl(Dc,Lc)&&(Dc=t):Lc>=Dc?(tLc&&(Lc=t)):t>Rc?Sl(Dc,t)>Sl(Dc,Lc)&&(Lc=t):Sl(t,Lc)>Sl(Dc,Lc)&&(Dc=t)}else Oc.push(Uc=[Dc=t,Lc=t]);nHc&&(Hc=n),qc=e,Rc=t}function wl(){_l.point=xl}function Ml(){Uc[0]=Dc,Uc[1]=Lc,_l.point=bl,qc=null}function kl(t,n){if(qc){var e=t-Rc;Fc.add(ic(e)>180?e+(e>0?360:-360):e)}else Bc=t,Ic=n;Vc.point(t,n),xl(t,n)}function Tl(){Vc.lineStart()}function Al(){kl(Bc,Ic),Vc.lineEnd(),ic(Fc)>Zs&&(Dc=-(Lc=180)),Uc[0]=Dc,Uc[1]=Lc,qc=null}function Sl(t,n){return(n-=t)<0?n+360:n}function El(t,n){return t[0]-n[0]}function Cl(t,n){return t[0]<=t[1]?t[0]<=n&&n<=t[1]:nQs?t+Math.round(-t/nc)*nc:t,n]}function Gl(t,n,e){return(t%=nc)?n||e?Ul(jl(t),$l(n,e)):jl(t):n||e?$l(n,e):Yl}function Vl(t){return function(n,e){return[(n+=t)>Qs?n-nc:n<-Qs?n+nc:n,e]}}function jl(t){var n=Vl(t);return n.invert=Vl(-t),n}function $l(t,n){var e=uc(t),r=dc(t),i=uc(n),o=dc(n);function a(t,n){var a=uc(n),u=uc(t)*a,s=dc(t)*a,c=dc(n),l=c*e+u*r;return[ac(s*i-l*o,u*e-c*r),vc(l*i+s*o)]}return a.invert=function(t,n){var a=uc(n),u=uc(t)*a,s=dc(t)*a,c=dc(n),l=c*i-s*o;return[ac(s*i+c*o,u*e+l*r),vc(l*e-u*r)]},a}function Xl(t){function n(n){return(n=t(n[0]*rc,n[1]*rc))[0]*=ec,n[1]*=ec,n}return t=Gl(t[0]*rc,t[1]*rc,t.length>2?t[2]*rc:0),n.invert=function(n){return(n=t.invert(n[0]*rc,n[1]*rc))[0]*=ec,n[1]*=ec,n},n}function Wl(t,n,e,r,i,o){if(e){var a=uc(n),u=dc(n),s=r*e;null==i?(i=n+r*nc,o=n-s/2):(i=Zl(a,i),o=Zl(a,o),(r>0?io)&&(i+=r*nc));for(var c,l=i;r>0?l>o:l1&&n.push(n.pop().concat(n.shift()))},result:function(){var e=n;return n=[],t=null,e}}}function Ql(t,n){return ic(t[0]-n[0])=0;--o)i.point((l=c[o])[0],l[1]);else r(h.x,h.p.x,-1,i);h=h.p}c=(h=h.o).z,d=!d}while(!h.v);i.lineEnd()}}}function nf(t){if(n=t.length){for(var n,e,r=0,i=t[0];++r=0?1:-1,S=A*T,E=S>Qs,C=m*M;if(s.add(ac(C*A*dc(S),v*k+C*uc(S))),a+=E?T+A*nc:T,E^p>=e^x>=e){var N=Jc(Kc(d),Kc(b));el(N);var P=Jc(o,N);el(P);var D=(E^T>=0?-1:1)*vc(P[2]);(r>D||r===D&&(N[0]||N[1]))&&(u+=E^T>=0?1:-1)}}return(a<-Zs||a0){for(f||(i.polygonStart(),f=!0),i.lineStart(),t=0;t1&&2&s&&h.push(h.pop().concat(h.shift())),a.push(h.filter(af))}return h}}function af(t){return t.length>1}function uf(t,n){return((t=t.x)[0]<0?t[1]-Js-Zs:Js-t[1])-((n=n.x)[0]<0?n[1]-Js-Zs:Js-n[1])}Yl.invert=Yl;var sf=of((function(){return!0}),(function(t){var n,e=NaN,r=NaN,i=NaN;return{lineStart:function(){t.lineStart(),n=1},point:function(o,a){var u=o>0?Qs:-Qs,s=ic(o-e);ic(s-Qs)0?Js:-Js),t.point(i,r),t.lineEnd(),t.lineStart(),t.point(u,r),t.point(o,r),n=0):i!==u&&s>=Qs&&(ic(e-i)Zs?oc((dc(n)*(o=uc(r))*dc(e)-dc(r)*(i=uc(n))*dc(t))/(i*o*a)):(n+r)/2}(e,r,o,a),t.point(i,r),t.lineEnd(),t.lineStart(),t.point(u,r),n=0),t.point(e=o,r=a),i=u},lineEnd:function(){t.lineEnd(),e=r=NaN},clean:function(){return 2-n}}}),(function(t,n,e,r){var i;if(null==t)i=e*Js,r.point(-Qs,i),r.point(0,i),r.point(Qs,i),r.point(Qs,0),r.point(Qs,-i),r.point(0,-i),r.point(-Qs,-i),r.point(-Qs,0),r.point(-Qs,i);else if(ic(t[0]-n[0])>Zs){var o=t[0]0,i=ic(n)>Zs;function o(t,e){return uc(t)*uc(e)>n}function a(t,e,r){var i=[1,0,0],o=Jc(Kc(t),Kc(e)),a=Qc(o,o),u=o[0],s=a-u*u;if(!s)return!r&&t;var c=n*a/s,l=-n*u/s,f=Jc(i,o),h=nl(i,c);tl(h,nl(o,l));var d=f,p=Qc(h,d),g=Qc(d,d),y=p*p-g*(Qc(h,h)-1);if(!(y<0)){var m=gc(y),v=nl(d,(-p-m)/g);if(tl(v,h),v=Zc(v),!r)return v;var _,b=t[0],x=e[0],w=t[1],M=e[1];x0^v[1]<(ic(v[0]-b)Qs^(b<=v[0]&&v[0]<=x)){var A=nl(d,(-p+m)/g);return tl(A,h),[v,Zc(A)]}}}function u(n,e){var i=r?t:Qs-t,o=0;return n<-i?o|=1:n>i&&(o|=2),e<-i?o|=4:e>i&&(o|=8),o}return of(o,(function(t){var n,e,s,c,l;return{lineStart:function(){c=s=!1,l=1},point:function(f,h){var d,p=[f,h],g=o(f,h),y=r?g?0:u(f,h):g?u(f+(f<0?Qs:-Qs),h):0;if(!n&&(c=s=g)&&t.lineStart(),g!==s&&(!(d=a(n,p))||Ql(n,d)||Ql(p,d))&&(p[2]=1),g!==s)l=0,g?(t.lineStart(),d=a(p,n),t.point(d[0],d[1])):(d=a(n,p),t.point(d[0],d[1],2),t.lineEnd()),n=d;else if(i&&n&&r^g){var m;y&e||!(m=a(p,n,!0))||(l=0,r?(t.lineStart(),t.point(m[0][0],m[0][1]),t.point(m[1][0],m[1][1]),t.lineEnd()):(t.point(m[1][0],m[1][1]),t.lineEnd(),t.lineStart(),t.point(m[0][0],m[0][1],3)))}!g||n&&Ql(n,p)||t.point(p[0],p[1]),n=p,s=g,e=y},lineEnd:function(){s&&t.lineEnd(),n=null},clean:function(){return l|(c&&s)<<1}}}),(function(n,r,i,o){Wl(o,t,e,i,n,r)}),r?[0,-t]:[-Qs,t-Qs])}var lf,ff,hf,df,pf=1e9,gf=-pf;function yf(t,n,e,r){function i(i,o){return t<=i&&i<=e&&n<=o&&o<=r}function o(i,o,u,c){var l=0,f=0;if(null==i||(l=a(i,u))!==(f=a(o,u))||s(i,o)<0^u>0)do{c.point(0===l||3===l?t:e,l>1?r:n)}while((l=(l+u+4)%4)!==f);else c.point(o[0],o[1])}function a(r,i){return ic(r[0]-t)0?0:3:ic(r[0]-e)0?2:1:ic(r[1]-n)0?1:0:i>0?3:2}function u(t,n){return s(t.x,n.x)}function s(t,n){var e=a(t,1),r=a(n,1);return e!==r?e-r:0===e?n[1]-t[1]:1===e?t[0]-n[0]:2===e?t[1]-n[1]:n[0]-t[0]}return function(a){var s,c,l,f,h,d,p,g,y,m,v,_=a,b=Kl(),x={point:w,lineStart:function(){x.point=M,c&&c.push(l=[]),m=!0,y=!1,p=g=NaN},lineEnd:function(){s&&(M(f,h),d&&y&&b.rejoin(),s.push(b.result())),x.point=w,y&&_.lineEnd()},polygonStart:function(){_=b,s=[],c=[],v=!0},polygonEnd:function(){var n=function(){for(var n=0,e=0,i=c.length;er&&(h-o)*(r-a)>(d-a)*(t-o)&&++n:d<=r&&(h-o)*(r-a)<(d-a)*(t-o)&&--n;return n}(),e=v&&n,i=(s=J(s)).length;(e||i)&&(a.polygonStart(),e&&(a.lineStart(),o(null,null,1,a),a.lineEnd()),i&&tf(s,u,n,o,a),a.polygonEnd()),_=a,s=c=l=null}};function w(t,n){i(t,n)&&_.point(t,n)}function M(o,a){var u=i(o,a);if(c&&l.push([o,a]),m)f=o,h=a,d=u,m=!1,u&&(_.lineStart(),_.point(o,a));else if(u&&y)_.point(o,a);else{var s=[p=Math.max(gf,Math.min(pf,p)),g=Math.max(gf,Math.min(pf,g))],b=[o=Math.max(gf,Math.min(pf,o)),a=Math.max(gf,Math.min(pf,a))];!function(t,n,e,r,i,o){var a,u=t[0],s=t[1],c=0,l=1,f=n[0]-u,h=n[1]-s;if(a=e-u,f||!(a>0)){if(a/=f,f<0){if(a0){if(a>l)return;a>c&&(c=a)}if(a=i-u,f||!(a<0)){if(a/=f,f<0){if(a>l)return;a>c&&(c=a)}else if(f>0){if(a0)){if(a/=h,h<0){if(a0){if(a>l)return;a>c&&(c=a)}if(a=o-s,h||!(a<0)){if(a/=h,h<0){if(a>l)return;a>c&&(c=a)}else if(h>0){if(a0&&(t[0]=u+c*f,t[1]=s+c*h),l<1&&(n[0]=u+l*f,n[1]=s+l*h),!0}}}}}(s,b,t,n,e,r)?u&&(_.lineStart(),_.point(o,a),v=!1):(y||(_.lineStart(),_.point(s[0],s[1])),_.point(b[0],b[1]),u||_.lineEnd(),v=!1)}p=o,g=a,y=u}return x}}var mf={sphere:bc,point:bc,lineStart:function(){mf.point=_f,mf.lineEnd=vf},lineEnd:bc,polygonStart:bc,polygonEnd:bc};function vf(){mf.point=mf.lineEnd=bc}function _f(t,n){ff=t*=rc,hf=dc(n*=rc),df=uc(n),mf.point=bf}function bf(t,n){t*=rc;var e=dc(n*=rc),r=uc(n),i=ic(t-ff),o=uc(i),a=r*dc(i),u=df*e-hf*r*o,s=hf*e+df*r*o;lf.add(ac(gc(a*a+u*u),s)),ff=t,hf=e,df=r}function xf(t){return lf=new y,Ac(t,mf),+lf}var wf=[null,null],Mf={type:"LineString",coordinates:wf};function kf(t,n){return wf[0]=t,wf[1]=n,xf(Mf)}var Tf={Feature:function(t,n){return Sf(t.geometry,n)},FeatureCollection:function(t,n){for(var e=t.features,r=-1,i=e.length;++r0&&(i=kf(t[o],t[o-1]))>0&&e<=i&&r<=i&&(e+r-i)*(1-Math.pow((e-r)/i,2))Zs})).map(s)).concat(et(sc(o/d)*d,i,d).filter((function(t){return ic(t%g)>Zs})).map(c))}return m.lines=function(){return v().map((function(t){return{type:"LineString",coordinates:t}}))},m.outline=function(){return{type:"Polygon",coordinates:[l(r).concat(f(a).slice(1),l(e).reverse().slice(1),f(u).reverse().slice(1))]}},m.extent=function(t){return arguments.length?m.extentMajor(t).extentMinor(t):m.extentMinor()},m.extentMajor=function(t){return arguments.length?(r=+t[0][0],e=+t[1][0],u=+t[0][1],a=+t[1][1],r>e&&(t=r,r=e,e=t),u>a&&(t=u,u=a,a=t),m.precision(y)):[[r,u],[e,a]]},m.extentMinor=function(e){return arguments.length?(n=+e[0][0],t=+e[1][0],o=+e[0][1],i=+e[1][1],n>t&&(e=n,n=t,t=e),o>i&&(e=o,o=i,i=e),m.precision(y)):[[n,o],[t,i]]},m.step=function(t){return arguments.length?m.stepMajor(t).stepMinor(t):m.stepMinor()},m.stepMajor=function(t){return arguments.length?(p=+t[0],g=+t[1],m):[p,g]},m.stepMinor=function(t){return arguments.length?(h=+t[0],d=+t[1],m):[h,d]},m.precision=function(h){return arguments.length?(y=+h,s=zf(o,i,90),c=Lf(n,t,y),l=zf(u,a,90),f=Lf(r,e,y),m):y},m.extentMajor([[-180,-90+Zs],[180,90-Zs]]).extentMinor([[-180,-80-Zs],[180,80+Zs]])}var Rf,Bf,If,qf,Ff=t=>t,Of=new y,Uf=new y,Yf={point:bc,lineStart:bc,lineEnd:bc,polygonStart:function(){Yf.lineStart=Gf,Yf.lineEnd=$f},polygonEnd:function(){Yf.lineStart=Yf.lineEnd=Yf.point=bc,Of.add(ic(Uf)),Uf=new y},result:function(){var t=Of/2;return Of=new y,t}};function Gf(){Yf.point=Vf}function Vf(t,n){Yf.point=jf,Rf=If=t,Bf=qf=n}function jf(t,n){Uf.add(qf*t-If*n),If=t,qf=n}function $f(){jf(Rf,Bf)}var Xf=Yf,Wf=1/0,Zf=Wf,Kf=-Wf,Qf=Kf;var Jf,th,nh,eh,rh={point:function(t,n){tKf&&(Kf=t),nQf&&(Qf=n)},lineStart:bc,lineEnd:bc,polygonStart:bc,polygonEnd:bc,result:function(){var t=[[Wf,Zf],[Kf,Qf]];return Kf=Qf=-(Zf=Wf=1/0),t}},ih=0,oh=0,ah=0,uh=0,sh=0,ch=0,lh=0,fh=0,hh=0,dh={point:ph,lineStart:gh,lineEnd:vh,polygonStart:function(){dh.lineStart=_h,dh.lineEnd=bh},polygonEnd:function(){dh.point=ph,dh.lineStart=gh,dh.lineEnd=vh},result:function(){var t=hh?[lh/hh,fh/hh]:ch?[uh/ch,sh/ch]:ah?[ih/ah,oh/ah]:[NaN,NaN];return ih=oh=ah=uh=sh=ch=lh=fh=hh=0,t}};function ph(t,n){ih+=t,oh+=n,++ah}function gh(){dh.point=yh}function yh(t,n){dh.point=mh,ph(nh=t,eh=n)}function mh(t,n){var e=t-nh,r=n-eh,i=gc(e*e+r*r);uh+=i*(nh+t)/2,sh+=i*(eh+n)/2,ch+=i,ph(nh=t,eh=n)}function vh(){dh.point=ph}function _h(){dh.point=xh}function bh(){wh(Jf,th)}function xh(t,n){dh.point=wh,ph(Jf=nh=t,th=eh=n)}function wh(t,n){var e=t-nh,r=n-eh,i=gc(e*e+r*r);uh+=i*(nh+t)/2,sh+=i*(eh+n)/2,ch+=i,lh+=(i=eh*t-nh*n)*(nh+t),fh+=i*(eh+n),hh+=3*i,ph(nh=t,eh=n)}var Mh=dh;function kh(t){this._context=t}kh.prototype={_radius:4.5,pointRadius:function(t){return this._radius=t,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(t,n){switch(this._point){case 0:this._context.moveTo(t,n),this._point=1;break;case 1:this._context.lineTo(t,n);break;default:this._context.moveTo(t+this._radius,n),this._context.arc(t,n,this._radius,0,nc)}},result:bc};var Th,Ah,Sh,Eh,Ch,Nh=new y,Ph={point:bc,lineStart:function(){Ph.point=Dh},lineEnd:function(){Th&&zh(Ah,Sh),Ph.point=bc},polygonStart:function(){Th=!0},polygonEnd:function(){Th=null},result:function(){var t=+Nh;return Nh=new y,t}};function Dh(t,n){Ph.point=zh,Ah=Eh=t,Sh=Ch=n}function zh(t,n){Eh-=t,Ch-=n,Nh.add(gc(Eh*Eh+Ch*Ch)),Eh=t,Ch=n}var Lh=Ph;function Hh(){this._string=[]}function Rh(t){return"m0,"+t+"a"+t+","+t+" 0 1,1 0,"+-2*t+"a"+t+","+t+" 0 1,1 0,"+2*t+"z"}function Bh(t){return function(n){var e=new Ih;for(var r in t)e[r]=t[r];return e.stream=n,e}}function Ih(){}function qh(t,n,e){var r=t.clipExtent&&t.clipExtent();return t.scale(150).translate([0,0]),null!=r&&t.clipExtent(null),Ac(e,t.stream(rh)),n(rh.result()),null!=r&&t.clipExtent(r),t}function Fh(t,n,e){return qh(t,(function(e){var r=n[1][0]-n[0][0],i=n[1][1]-n[0][1],o=Math.min(r/(e[1][0]-e[0][0]),i/(e[1][1]-e[0][1])),a=+n[0][0]+(r-o*(e[1][0]+e[0][0]))/2,u=+n[0][1]+(i-o*(e[1][1]+e[0][1]))/2;t.scale(150*o).translate([a,u])}),e)}function Oh(t,n,e){return Fh(t,[[0,0],n],e)}function Uh(t,n,e){return qh(t,(function(e){var r=+n,i=r/(e[1][0]-e[0][0]),o=(r-i*(e[1][0]+e[0][0]))/2,a=-i*e[0][1];t.scale(150*i).translate([o,a])}),e)}function Yh(t,n,e){return qh(t,(function(e){var r=+n,i=r/(e[1][1]-e[0][1]),o=-i*e[0][0],a=(r-i*(e[1][1]+e[0][1]))/2;t.scale(150*i).translate([o,a])}),e)}Hh.prototype={_radius:4.5,_circle:Rh(4.5),pointRadius:function(t){return(t=+t)!==this._radius&&(this._radius=t,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(t,n){switch(this._point){case 0:this._string.push("M",t,",",n),this._point=1;break;case 1:this._string.push("L",t,",",n);break;default:null==this._circle&&(this._circle=Rh(this._radius)),this._string.push("M",t,",",n,this._circle)}},result:function(){if(this._string.length){var t=this._string.join("");return this._string=[],t}return null}},Ih.prototype={constructor:Ih,point:function(t,n){this.stream.point(t,n)},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 Gh=16,Vh=uc(30*rc);function jh(t,n){return+n?function(t,n){function e(r,i,o,a,u,s,c,l,f,h,d,p,g,y){var m=c-r,v=l-i,_=m*m+v*v;if(_>4*n&&g--){var b=a+h,x=u+d,w=s+p,M=gc(b*b+x*x+w*w),k=vc(w/=M),T=ic(ic(w)-1)n||ic((m*C+v*N)/_-.5)>.3||a*h+u*d+s*p2?t[2]%360*rc:0,C()):[y*ec,m*ec,v*ec]},S.angle=function(t){return arguments.length?(_=t%360*rc,C()):_*ec},S.reflectX=function(t){return arguments.length?(b=t?-1:1,C()):b<0},S.reflectY=function(t){return arguments.length?(x=t?-1:1,C()):x<0},S.precision=function(t){return arguments.length?(a=jh(u,A=t*t),N()):gc(A)},S.fitExtent=function(t,n){return Fh(S,t,n)},S.fitSize=function(t,n){return Oh(S,t,n)},S.fitWidth=function(t,n){return Uh(S,t,n)},S.fitHeight=function(t,n){return Yh(S,t,n)},function(){return n=t.apply(this,arguments),S.invert=n.invert&&E,C()}}function Kh(t){var n=0,e=Qs/3,r=Zh(t),i=r(n,e);return i.parallels=function(t){return arguments.length?r(n=t[0]*rc,e=t[1]*rc):[n*ec,e*ec]},i}function Qh(t,n){var e=dc(t),r=(e+dc(n))/2;if(ic(r)0?n<-Js+Zs&&(n=-Js+Zs):n>Js-Zs&&(n=Js-Zs);var e=i/hc(ud(n),r);return[e*dc(r*t),i-e*uc(r*t)]}return o.invert=function(t,n){var e=i-n,o=pc(r)*gc(t*t+e*e),a=ac(t,ic(e))*pc(e);return e*r<0&&(a-=Qs*pc(t)*pc(e)),[a/r,2*oc(hc(i/o,1/r))-Js]},o}function cd(t,n){return[t,n]}function ld(t,n){var e=uc(t),r=t===n?dc(t):(e-uc(n))/(n-t),i=e/r+t;if(ic(r)=0;)n+=e[r].value;else n=1;t.value=n}function Ad(t,n){t instanceof Map?(t=[void 0,t],void 0===n&&(n=Ed)):void 0===n&&(n=Sd);for(var e,r,i,o,a,u=new Pd(t),s=[u];e=s.pop();)if((i=n(e.data))&&(a=(i=Array.from(i)).length))for(e.children=i,o=a-1;o>=0;--o)s.push(r=i[o]=new Pd(i[o])),r.parent=e,r.depth=e.depth+1;return u.eachBefore(Nd)}function Sd(t){return t.children}function Ed(t){return Array.isArray(t)?t[1]:null}function Cd(t){void 0!==t.data.value&&(t.value=t.data.value),t.data=t.data.data}function Nd(t){var n=0;do{t.height=n}while((t=t.parent)&&t.height<++n)}function Pd(t){this.data=t,this.depth=this.height=0,this.parent=null}function Dd(t){for(var n,e,r=0,i=(t=function(t){for(var n,e,r=t.length;r;)e=Math.random()*r--|0,n=t[r],t[r]=t[e],t[e]=n;return t}(Array.from(t))).length,o=[];r0&&e*e>r*r+i*i}function Rd(t,n){for(var e=0;e(a*=a)?(r=(c+a-i)/(2*c),o=Math.sqrt(Math.max(0,a/c-r*r)),e.x=t.x-r*u-o*s,e.y=t.y-r*s+o*u):(r=(c+i-a)/(2*c),o=Math.sqrt(Math.max(0,i/c-r*r)),e.x=n.x+r*u-o*s,e.y=n.y+r*s+o*u)):(e.x=n.x+e.r,e.y=n.y)}function Od(t,n){var e=t.r+n.r-1e-6,r=n.x-t.x,i=n.y-t.y;return e>0&&e*e>r*r+i*i}function Ud(t){var n=t._,e=t.next._,r=n.r+e.r,i=(n.x*e.r+e.x*n.r)/r,o=(n.y*e.r+e.y*n.r)/r;return i*i+o*o}function Yd(t){this._=t,this.next=null,this.previous=null}function Gd(t){if(!(i=(t=function(t){return"object"==typeof t&&"length"in t?t:Array.from(t)}(t)).length))return 0;var n,e,r,i,o,a,u,s,c,l,f;if((n=t[0]).x=0,n.y=0,!(i>1))return n.r;if(e=t[1],n.x=-e.r,e.x=n.r,e.y=0,!(i>2))return n.r+e.r;Fd(e,n,r=t[2]),n=new Yd(n),e=new Yd(e),r=new Yd(r),n.next=r.previous=e,e.next=n.previous=r,r.next=e.previous=n;t:for(u=3;uZs&&--i>0);return[t/(.8707+(o=r*r)*(o*(o*o*o*(.003971-.001529*o)-.013791)-.131979)),r]},_d.invert=ed(vc),bd.invert=ed((function(t){return 2*oc(t)})),xd.invert=function(t,n){return[-n,2*oc(cc(t))-Js]},Pd.prototype=Ad.prototype={constructor:Pd,count:function(){return this.eachAfter(Td)},each:function(t,n){let e=-1;for(const r of this)t.call(n,r,++e,this);return this},eachAfter:function(t,n){for(var e,r,i,o=this,a=[o],u=[],s=-1;o=a.pop();)if(u.push(o),e=o.children)for(r=0,i=e.length;r=0;--r)o.push(e[r]);return this},find:function(t,n){let e=-1;for(const r of this)if(t.call(n,r,++e,this))return r},sum:function(t){return this.eachAfter((function(n){for(var e=+t(n.data)||0,r=n.children,i=r&&r.length;--i>=0;)e+=r[i].value;n.value=e}))},sort:function(t){return this.eachBefore((function(n){n.children&&n.children.sort(t)}))},path:function(t){for(var n=this,e=function(t,n){if(t===n)return t;var e=t.ancestors(),r=n.ancestors(),i=null;for(t=e.pop(),n=r.pop();t===n;)i=t,t=e.pop(),n=r.pop();return i}(n,t),r=[n];n!==e;)n=n.parent,r.push(n);for(var i=r.length;t!==e;)r.splice(i,0,t),t=t.parent;return r},ancestors:function(){for(var t=this,n=[t];t=t.parent;)n.push(t);return n},descendants:function(){return Array.from(this)},leaves:function(){var t=[];return this.eachBefore((function(n){n.children||t.push(n)})),t},links:function(){var t=this,n=[];return t.each((function(e){e!==t&&n.push({source:e.parent,target:e})})),n},copy:function(){return Ad(this).eachBefore(Cd)},[Symbol.iterator]:function*(){var t,n,e,r,i=this,o=[i];do{for(t=o.reverse(),o=[];i=t.pop();)if(yield i,n=i.children)for(e=0,r=n.length;e1&&!up(t,n););return t.slice(0,n)}function up(t,n){if("/"===t[n]){let e=0;for(;n>0&&"\\"===t[--n];)++e;if(!(1&e))return!0}return!1}function sp(t,n){return t.parent===n.parent?1:2}function cp(t){var n=t.children;return n?n[0]:t.t}function lp(t){var n=t.children;return n?n[n.length-1]:t.t}function fp(t,n,e){var r=e/(n.i-t.i);n.c-=r,n.s+=e,t.c+=r,n.z+=e,n.m+=e}function hp(t,n,e){return t.a.parent===n.parent?t.a:e}function dp(t,n){this._=t,this.parent=null,this.children=null,this.A=null,this.a=this,this.z=0,this.m=0,this.c=0,this.s=0,this.t=null,this.i=n}function pp(t,n,e,r,i){for(var o,a=t.children,u=-1,s=a.length,c=t.value&&(i-e)/t.value;++uh&&(h=u),y=l*l*g,(d=Math.max(h/y,y/f))>p){l-=u;break}p=d}m.push(a={value:l,dice:s1?n:1)},e}(gp);var vp=function t(n){function e(t,e,r,i,o){if((a=t._squarify)&&a.ratio===n)for(var a,u,s,c,l,f=-1,h=a.length,d=t.value;++f1?n:1)},e}(gp);function _p(t,n,e){return(n[0]-t[0])*(e[1]-t[1])-(n[1]-t[1])*(e[0]-t[0])}function bp(t,n){return t[0]-n[0]||t[1]-n[1]}function xp(t){const n=t.length,e=[0,1];let r,i=2;for(r=2;r1&&_p(t[e[i-2]],t[e[i-1]],t[r])<=0;)--i;e[i++]=r}return e.slice(0,i)}var wp=Math.random,Mp=function t(n){function e(t,e){return t=null==t?0:+t,e=null==e?1:+e,1===arguments.length?(e=t,t=0):e-=t,function(){return n()*e+t}}return e.source=t,e}(wp),kp=function t(n){function e(t,e){return arguments.length<2&&(e=t,t=0),t=Math.floor(t),e=Math.floor(e)-t,function(){return Math.floor(n()*e+t)}}return e.source=t,e}(wp),Tp=function t(n){function e(t,e){var r,i;return t=null==t?0:+t,e=null==e?1:+e,function(){var o;if(null!=r)o=r,r=null;else do{r=2*n()-1,o=2*n()-1,i=r*r+o*o}while(!i||i>1);return t+e*o*Math.sqrt(-2*Math.log(i)/i)}}return e.source=t,e}(wp),Ap=function t(n){var e=Tp.source(n);function r(){var t=e.apply(this,arguments);return function(){return Math.exp(t())}}return r.source=t,r}(wp),Sp=function t(n){function e(t){return(t=+t)<=0?()=>0:function(){for(var e=0,r=t;r>1;--r)e+=n();return e+r*n()}}return e.source=t,e}(wp),Ep=function t(n){var e=Sp.source(n);function r(t){if(0==(t=+t))return n;var r=e(t);return function(){return r()/t}}return r.source=t,r}(wp),Cp=function t(n){function e(t){return function(){return-Math.log1p(-n())/t}}return e.source=t,e}(wp),Np=function t(n){function e(t){if((t=+t)<0)throw new RangeError("invalid alpha");return t=1/-t,function(){return Math.pow(1-n(),t)}}return e.source=t,e}(wp),Pp=function t(n){function e(t){if((t=+t)<0||t>1)throw new RangeError("invalid p");return function(){return Math.floor(n()+t)}}return e.source=t,e}(wp),Dp=function t(n){function e(t){if((t=+t)<0||t>1)throw new RangeError("invalid p");return 0===t?()=>1/0:1===t?()=>1:(t=Math.log1p(-t),function(){return 1+Math.floor(Math.log1p(-n())/t)})}return e.source=t,e}(wp),zp=function t(n){var e=Tp.source(n)();function r(t,r){if((t=+t)<0)throw new RangeError("invalid k");if(0===t)return()=>0;if(r=null==r?1:+r,1===t)return()=>-Math.log1p(-n())*r;var i=(t<1?t+1:t)-1/3,o=1/(3*Math.sqrt(i)),a=t<1?()=>Math.pow(n(),1/t):()=>1;return function(){do{do{var t=e(),u=1+o*t}while(u<=0);u*=u*u;var s=1-n()}while(s>=1-.0331*t*t*t*t&&Math.log(s)>=.5*t*t+i*(1-u+Math.log(u)));return i*u*a()*r}}return r.source=t,r}(wp),Lp=function t(n){var e=zp.source(n);function r(t,n){var r=e(t),i=e(n);return function(){var t=r();return 0===t?0:t/(t+i())}}return r.source=t,r}(wp),Hp=function t(n){var e=Dp.source(n),r=Lp.source(n);function i(t,n){return t=+t,(n=+n)>=1?()=>t:n<=0?()=>0:function(){for(var i=0,o=t,a=n;o*a>16&&o*(1-a)>16;){var u=Math.floor((o+1)*a),s=r(u,o-u+1)();s<=a?(i+=u,o-=u,a=(a-s)/(1-s)):(o=u-1,a/=s)}for(var c=a<.5,l=e(c?a:1-a),f=l(),h=0;f<=o;++h)f+=l();return i+(c?h:o-h)}}return i.source=t,i}(wp),Rp=function t(n){function e(t,e,r){var i;return 0==(t=+t)?i=t=>-Math.log(t):(t=1/t,i=n=>Math.pow(n,t)),e=null==e?0:+e,r=null==r?1:+r,function(){return e+r*i(-Math.log1p(-n()))}}return e.source=t,e}(wp),Bp=function t(n){function e(t,e){return t=null==t?0:+t,e=null==e?1:+e,function(){return t+e*Math.tan(Math.PI*n())}}return e.source=t,e}(wp),Ip=function t(n){function e(t,e){return t=null==t?0:+t,e=null==e?1:+e,function(){var r=n();return t+e*Math.log(r/(1-r))}}return e.source=t,e}(wp),qp=function t(n){var e=zp.source(n),r=Hp.source(n);function i(t){return function(){for(var i=0,o=t;o>16;){var a=Math.floor(.875*o),u=e(a)();if(u>o)return i+r(a-1,o/u)();i+=a,o-=u}for(var s=-Math.log1p(-n()),c=0;s<=o;++c)s-=Math.log1p(-n());return i+c}}return i.source=t,i}(wp);const Fp=1/4294967296;function Op(t,n){switch(arguments.length){case 0:break;case 1:this.range(t);break;default:this.range(n).domain(t)}return this}function Up(t,n){switch(arguments.length){case 0:break;case 1:"function"==typeof t?this.interpolator(t):this.range(t);break;default:this.domain(t),"function"==typeof n?this.interpolator(n):this.range(n)}return this}const Yp=Symbol("implicit");function Gp(){var t=new m,n=[],e=[],r=Yp;function i(i){let o=t.get(i);if(void 0===o){if(r!==Yp)return r;t.set(i,o=n.push(i)-1)}return e[o%e.length]}return i.domain=function(e){if(!arguments.length)return n.slice();n=[],t=new m;for(const r of e)t.has(r)||t.set(r,n.push(r)-1);return i},i.range=function(t){return arguments.length?(e=Array.from(t),i):e.slice()},i.unknown=function(t){return arguments.length?(r=t,i):r},i.copy=function(){return Gp(n,e).unknown(r)},Op.apply(i,arguments),i}function Vp(){var t,n,e=Gp().unknown(void 0),r=e.domain,i=e.range,o=0,a=1,u=!1,s=0,c=0,l=.5;function f(){var e=r().length,f=an&&(e=t,t=n,n=e),function(e){return Math.max(t,Math.min(n,e))}}(a[0],a[t-1])),r=t>2?Qp:Kp,i=o=null,f}function f(n){return null==n||isNaN(n=+n)?e:(i||(i=r(a.map(t),u,s)))(t(c(n)))}return f.invert=function(e){return c(n((o||(o=r(u,a.map(t),Cr)))(e)))},f.domain=function(t){return arguments.length?(a=Array.from(t,$p),l()):a.slice()},f.range=function(t){return arguments.length?(u=Array.from(t),l()):u.slice()},f.rangeRound=function(t){return u=Array.from(t),s=Hr,l()},f.clamp=function(t){return arguments.length?(c=!!t||Wp,l()):c!==Wp},f.interpolate=function(t){return arguments.length?(s=t,l()):s},f.unknown=function(t){return arguments.length?(e=t,f):e},function(e,r){return t=e,n=r,l()}}function ng(){return tg()(Wp,Wp)}function eg(n,e,r,i){var o,a=U(n,e,r);switch((i=Bs(null==i?",f":i)).type){case"s":var u=Math.max(Math.abs(n),Math.abs(e));return null!=i.precision||isNaN(o=Xs(a,u))||(i.precision=o),t.formatPrefix(i,u);case"":case"e":case"g":case"p":case"r":null!=i.precision||isNaN(o=Ws(a,Math.max(Math.abs(n),Math.abs(e))))||(i.precision=o-("e"===i.type));break;case"f":case"%":null!=i.precision||isNaN(o=$s(a))||(i.precision=o-2*("%"===i.type))}return t.format(i)}function rg(t){var n=t.domain;return t.ticks=function(t){var e=n();return F(e[0],e[e.length-1],null==t?10:t)},t.tickFormat=function(t,e){var r=n();return eg(r[0],r[r.length-1],null==t?10:t,e)},t.nice=function(e){null==e&&(e=10);var r,i,o=n(),a=0,u=o.length-1,s=o[a],c=o[u],l=10;for(c0;){if((i=O(s,c,e))===r)return o[a]=s,o[u]=c,n(o);if(i>0)s=Math.floor(s/i)*i,c=Math.ceil(c/i)*i;else{if(!(i<0))break;s=Math.ceil(s*i)/i,c=Math.floor(c*i)/i}r=i}return t},t}function ig(t,n){var e,r=0,i=(t=t.slice()).length-1,o=t[r],a=t[i];return a-t(-n,e)}function fg(n){const e=n(og,ag),r=e.domain;let i,o,a=10;function u(){return i=function(t){return t===Math.E?Math.log:10===t&&Math.log10||2===t&&Math.log2||(t=Math.log(t),n=>Math.log(n)/t)}(a),o=function(t){return 10===t?cg:t===Math.E?Math.exp:n=>Math.pow(t,n)}(a),r()[0]<0?(i=lg(i),o=lg(o),n(ug,sg)):n(og,ag),e}return e.base=function(t){return arguments.length?(a=+t,u()):a},e.domain=function(t){return arguments.length?(r(t),u()):r()},e.ticks=t=>{const n=r();let e=n[0],u=n[n.length-1];const s=u0){for(;f<=h;++f)for(c=1;cu)break;p.push(l)}}else for(;f<=h;++f)for(c=a-1;c>=1;--c)if(l=f>0?c/o(-f):c*o(f),!(lu)break;p.push(l)}2*p.length{if(null==n&&(n=10),null==r&&(r=10===a?"s":","),"function"!=typeof r&&(a%1||null!=(r=Bs(r)).precision||(r.trim=!0),r=t.format(r)),n===1/0)return r;const u=Math.max(1,a*n/e.ticks().length);return t=>{let n=t/o(Math.round(i(t)));return n*ar(ig(r(),{floor:t=>o(Math.floor(i(t))),ceil:t=>o(Math.ceil(i(t)))})),e}function hg(t){return function(n){return Math.sign(n)*Math.log1p(Math.abs(n/t))}}function dg(t){return function(n){return Math.sign(n)*Math.expm1(Math.abs(n))*t}}function pg(t){var n=1,e=t(hg(n),dg(n));return e.constant=function(e){return arguments.length?t(hg(n=+e),dg(n)):n},rg(e)}function gg(t){return function(n){return n<0?-Math.pow(-n,t):Math.pow(n,t)}}function yg(t){return t<0?-Math.sqrt(-t):Math.sqrt(t)}function mg(t){return t<0?-t*t:t*t}function vg(t){var n=t(Wp,Wp),e=1;return n.exponent=function(n){return arguments.length?1===(e=+n)?t(Wp,Wp):.5===e?t(yg,mg):t(gg(e),gg(1/e)):e},rg(n)}function _g(){var t=vg(tg());return t.copy=function(){return Jp(t,_g()).exponent(t.exponent())},Op.apply(t,arguments),t}function bg(t){return Math.sign(t)*t*t}var xg=new Date,wg=new Date;function Mg(t,n,e,r){function i(n){return t(n=0===arguments.length?new Date:new Date(+n)),n}return i.floor=function(n){return t(n=new Date(+n)),n},i.ceil=function(e){return t(e=new Date(e-1)),n(e,1),t(e),e},i.round=function(t){var n=i(t),e=i.ceil(t);return t-n0))return u;do{u.push(a=new Date(+e)),n(e,o),t(e)}while(a=n)for(;t(n),!e(n);)n.setTime(n-1)}),(function(t,r){if(t>=t)if(r<0)for(;++r<=0;)for(;n(t,-1),!e(t););else for(;--r>=0;)for(;n(t,1),!e(t););}))},e&&(i.count=function(n,r){return xg.setTime(+n),wg.setTime(+r),t(xg),t(wg),Math.floor(e(xg,wg))},i.every=function(t){return t=Math.floor(t),isFinite(t)&&t>0?t>1?i.filter(r?function(n){return r(n)%t==0}:function(n){return i.count(0,n)%t==0}):i:null}),i}var kg=Mg((function(){}),(function(t,n){t.setTime(+t+n)}),(function(t,n){return n-t}));kg.every=function(t){return t=Math.floor(t),isFinite(t)&&t>0?t>1?Mg((function(n){n.setTime(Math.floor(n/t)*t)}),(function(n,e){n.setTime(+n+e*t)}),(function(n,e){return(e-n)/t})):kg:null};var Tg=kg,Ag=kg.range;const Sg=1e3,Eg=6e4,Cg=36e5,Ng=864e5,Pg=6048e5,Dg=2592e6,zg=31536e6;var Lg=Mg((function(t){t.setTime(t-t.getMilliseconds())}),(function(t,n){t.setTime(+t+n*Sg)}),(function(t,n){return(n-t)/Sg}),(function(t){return t.getUTCSeconds()})),Hg=Lg,Rg=Lg.range,Bg=Mg((function(t){t.setTime(t-t.getMilliseconds()-t.getSeconds()*Sg)}),(function(t,n){t.setTime(+t+n*Eg)}),(function(t,n){return(n-t)/Eg}),(function(t){return t.getMinutes()})),Ig=Bg,qg=Bg.range,Fg=Mg((function(t){t.setTime(t-t.getMilliseconds()-t.getSeconds()*Sg-t.getMinutes()*Eg)}),(function(t,n){t.setTime(+t+n*Cg)}),(function(t,n){return(n-t)/Cg}),(function(t){return t.getHours()})),Og=Fg,Ug=Fg.range,Yg=Mg((t=>t.setHours(0,0,0,0)),((t,n)=>t.setDate(t.getDate()+n)),((t,n)=>(n-t-(n.getTimezoneOffset()-t.getTimezoneOffset())*Eg)/Ng),(t=>t.getDate()-1)),Gg=Yg,Vg=Yg.range;function jg(t){return Mg((function(n){n.setDate(n.getDate()-(n.getDay()+7-t)%7),n.setHours(0,0,0,0)}),(function(t,n){t.setDate(t.getDate()+7*n)}),(function(t,n){return(n-t-(n.getTimezoneOffset()-t.getTimezoneOffset())*Eg)/Pg}))}var $g=jg(0),Xg=jg(1),Wg=jg(2),Zg=jg(3),Kg=jg(4),Qg=jg(5),Jg=jg(6),ty=$g.range,ny=Xg.range,ey=Wg.range,ry=Zg.range,iy=Kg.range,oy=Qg.range,ay=Jg.range,uy=Mg((function(t){t.setDate(1),t.setHours(0,0,0,0)}),(function(t,n){t.setMonth(t.getMonth()+n)}),(function(t,n){return n.getMonth()-t.getMonth()+12*(n.getFullYear()-t.getFullYear())}),(function(t){return t.getMonth()})),sy=uy,cy=uy.range,ly=Mg((function(t){t.setMonth(0,1),t.setHours(0,0,0,0)}),(function(t,n){t.setFullYear(t.getFullYear()+n)}),(function(t,n){return n.getFullYear()-t.getFullYear()}),(function(t){return t.getFullYear()}));ly.every=function(t){return isFinite(t=Math.floor(t))&&t>0?Mg((function(n){n.setFullYear(Math.floor(n.getFullYear()/t)*t),n.setMonth(0,1),n.setHours(0,0,0,0)}),(function(n,e){n.setFullYear(n.getFullYear()+e*t)})):null};var fy=ly,hy=ly.range,dy=Mg((function(t){t.setUTCSeconds(0,0)}),(function(t,n){t.setTime(+t+n*Eg)}),(function(t,n){return(n-t)/Eg}),(function(t){return t.getUTCMinutes()})),py=dy,gy=dy.range,yy=Mg((function(t){t.setUTCMinutes(0,0,0)}),(function(t,n){t.setTime(+t+n*Cg)}),(function(t,n){return(n-t)/Cg}),(function(t){return t.getUTCHours()})),my=yy,vy=yy.range,_y=Mg((function(t){t.setUTCHours(0,0,0,0)}),(function(t,n){t.setUTCDate(t.getUTCDate()+n)}),(function(t,n){return(n-t)/Ng}),(function(t){return t.getUTCDate()-1})),by=_y,xy=_y.range;function wy(t){return Mg((function(n){n.setUTCDate(n.getUTCDate()-(n.getUTCDay()+7-t)%7),n.setUTCHours(0,0,0,0)}),(function(t,n){t.setUTCDate(t.getUTCDate()+7*n)}),(function(t,n){return(n-t)/Pg}))}var My=wy(0),ky=wy(1),Ty=wy(2),Ay=wy(3),Sy=wy(4),Ey=wy(5),Cy=wy(6),Ny=My.range,Py=ky.range,Dy=Ty.range,zy=Ay.range,Ly=Sy.range,Hy=Ey.range,Ry=Cy.range,By=Mg((function(t){t.setUTCDate(1),t.setUTCHours(0,0,0,0)}),(function(t,n){t.setUTCMonth(t.getUTCMonth()+n)}),(function(t,n){return n.getUTCMonth()-t.getUTCMonth()+12*(n.getUTCFullYear()-t.getUTCFullYear())}),(function(t){return t.getUTCMonth()})),Iy=By,qy=By.range,Fy=Mg((function(t){t.setUTCMonth(0,1),t.setUTCHours(0,0,0,0)}),(function(t,n){t.setUTCFullYear(t.getUTCFullYear()+n)}),(function(t,n){return n.getUTCFullYear()-t.getUTCFullYear()}),(function(t){return t.getUTCFullYear()}));Fy.every=function(t){return isFinite(t=Math.floor(t))&&t>0?Mg((function(n){n.setUTCFullYear(Math.floor(n.getUTCFullYear()/t)*t),n.setUTCMonth(0,1),n.setUTCHours(0,0,0,0)}),(function(n,e){n.setUTCFullYear(n.getUTCFullYear()+e*t)})):null};var Oy=Fy,Uy=Fy.range;function Yy(t,n,r,i,o,a){const u=[[Hg,1,Sg],[Hg,5,5e3],[Hg,15,15e3],[Hg,30,3e4],[a,1,Eg],[a,5,3e5],[a,15,9e5],[a,30,18e5],[o,1,Cg],[o,3,108e5],[o,6,216e5],[o,12,432e5],[i,1,Ng],[i,2,1728e5],[r,1,Pg],[n,1,Dg],[n,3,7776e6],[t,1,zg]];function s(n,r,i){const o=Math.abs(r-n)/i,a=e((([,,t])=>t)).right(u,o);if(a===u.length)return t.every(U(n/zg,r/zg,i));if(0===a)return Tg.every(Math.max(U(n,r,i),1));const[s,c]=u[o/u[a-1][2]=12)]},q:function(t){return 1+~~(t.getMonth()/3)},Q:pv,s:gv,S:Hm,u:Rm,U:Bm,V:qm,w:Fm,W:Om,x:null,X:null,y:Um,Y:Gm,Z:jm,"%":dv},b={a:function(t){return a[t.getUTCDay()]},A:function(t){return o[t.getUTCDay()]},b:function(t){return s[t.getUTCMonth()]},B:function(t){return u[t.getUTCMonth()]},c:null,d:$m,e:$m,f:Qm,g:cv,G:fv,H:Xm,I:Wm,j:Zm,L:Km,m:Jm,M:tv,p:function(t){return i[+(t.getUTCHours()>=12)]},q:function(t){return 1+~~(t.getUTCMonth()/3)},Q:pv,s:gv,S:nv,u:ev,U:rv,V:ov,w:av,W:uv,x:null,X:null,y:sv,Y:lv,Z:hv,"%":dv},x={a:function(t,n,e){var r=d.exec(n.slice(e));return r?(t.w=p.get(r[0].toLowerCase()),e+r[0].length):-1},A:function(t,n,e){var r=f.exec(n.slice(e));return r?(t.w=h.get(r[0].toLowerCase()),e+r[0].length):-1},b:function(t,n,e){var r=m.exec(n.slice(e));return r?(t.m=v.get(r[0].toLowerCase()),e+r[0].length):-1},B:function(t,n,e){var r=g.exec(n.slice(e));return r?(t.m=y.get(r[0].toLowerCase()),e+r[0].length):-1},c:function(t,e,r){return k(t,n,e,r)},d:mm,e:mm,f:Mm,g:dm,G:hm,H:_m,I:_m,j:vm,L:wm,m:ym,M:bm,p:function(t,n,e){var r=c.exec(n.slice(e));return r?(t.p=l.get(r[0].toLowerCase()),e+r[0].length):-1},q:gm,Q:Tm,s:Am,S:xm,u:sm,U:cm,V:lm,w:um,W:fm,x:function(t,n,r){return k(t,e,n,r)},X:function(t,n,e){return k(t,r,n,e)},y:dm,Y:hm,Z:pm,"%":km};function w(t,n){return function(e){var r,i,o,a=[],u=-1,s=0,c=t.length;for(e instanceof Date||(e=new Date(+e));++u53)return null;"w"in o||(o.w=1),"Z"in o?(i=(r=Wy(Zy(o.y,0,1))).getUTCDay(),r=i>4||0===i?ky.ceil(r):ky(r),r=by.offset(r,7*(o.V-1)),o.y=r.getUTCFullYear(),o.m=r.getUTCMonth(),o.d=r.getUTCDate()+(o.w+6)%7):(i=(r=Xy(Zy(o.y,0,1))).getDay(),r=i>4||0===i?Xg.ceil(r):Xg(r),r=Gg.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?Wy(Zy(o.y,0,1)).getUTCDay():Xy(Zy(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,Wy(o)):Xy(o)}}function k(t,n,e,r){for(var i,o,a=0,u=n.length,s=e.length;a=s)return-1;if(37===(i=n.charCodeAt(a++))){if(i=n.charAt(a++),!(o=x[i in Jy?n.charAt(a++):i])||(r=o(t,e,r))<0)return-1}else if(i!=e.charCodeAt(r++))return-1}return r}return _.x=w(e,_),_.X=w(r,_),_.c=w(n,_),b.x=w(e,b),b.X=w(r,b),b.c=w(n,b),{format:function(t){var n=w(t+="",_);return n.toString=function(){return t},n},parse:function(t){var n=M(t+="",!1);return n.toString=function(){return t},n},utcFormat:function(t){var n=w(t+="",b);return n.toString=function(){return t},n},utcParse:function(t){var n=M(t+="",!0);return n.toString=function(){return t},n}}}var Qy,Jy={"-":"",_:" ",0:"0"},tm=/^\s*\d+/,nm=/^%/,em=/[\\^$*+?|[\]().{}]/g;function rm(t,n,e){var r=t<0?"-":"",i=(r?-t:t)+"",o=i.length;return r+(o[t.toLowerCase(),n])))}function um(t,n,e){var r=tm.exec(n.slice(e,e+1));return r?(t.w=+r[0],e+r[0].length):-1}function sm(t,n,e){var r=tm.exec(n.slice(e,e+1));return r?(t.u=+r[0],e+r[0].length):-1}function cm(t,n,e){var r=tm.exec(n.slice(e,e+2));return r?(t.U=+r[0],e+r[0].length):-1}function lm(t,n,e){var r=tm.exec(n.slice(e,e+2));return r?(t.V=+r[0],e+r[0].length):-1}function fm(t,n,e){var r=tm.exec(n.slice(e,e+2));return r?(t.W=+r[0],e+r[0].length):-1}function hm(t,n,e){var r=tm.exec(n.slice(e,e+4));return r?(t.y=+r[0],e+r[0].length):-1}function dm(t,n,e){var r=tm.exec(n.slice(e,e+2));return r?(t.y=+r[0]+(+r[0]>68?1900:2e3),e+r[0].length):-1}function pm(t,n,e){var r=/^(Z)|([+-]\d\d)(?::?(\d\d))?/.exec(n.slice(e,e+6));return r?(t.Z=r[1]?0:-(r[2]+(r[3]||"00")),e+r[0].length):-1}function gm(t,n,e){var r=tm.exec(n.slice(e,e+1));return r?(t.q=3*r[0]-3,e+r[0].length):-1}function ym(t,n,e){var r=tm.exec(n.slice(e,e+2));return r?(t.m=r[0]-1,e+r[0].length):-1}function mm(t,n,e){var r=tm.exec(n.slice(e,e+2));return r?(t.d=+r[0],e+r[0].length):-1}function vm(t,n,e){var r=tm.exec(n.slice(e,e+3));return r?(t.m=0,t.d=+r[0],e+r[0].length):-1}function _m(t,n,e){var r=tm.exec(n.slice(e,e+2));return r?(t.H=+r[0],e+r[0].length):-1}function bm(t,n,e){var r=tm.exec(n.slice(e,e+2));return r?(t.M=+r[0],e+r[0].length):-1}function xm(t,n,e){var r=tm.exec(n.slice(e,e+2));return r?(t.S=+r[0],e+r[0].length):-1}function wm(t,n,e){var r=tm.exec(n.slice(e,e+3));return r?(t.L=+r[0],e+r[0].length):-1}function Mm(t,n,e){var r=tm.exec(n.slice(e,e+6));return r?(t.L=Math.floor(r[0]/1e3),e+r[0].length):-1}function km(t,n,e){var r=nm.exec(n.slice(e,e+1));return r?e+r[0].length:-1}function Tm(t,n,e){var r=tm.exec(n.slice(e));return r?(t.Q=+r[0],e+r[0].length):-1}function Am(t,n,e){var r=tm.exec(n.slice(e));return r?(t.s=+r[0],e+r[0].length):-1}function Sm(t,n){return rm(t.getDate(),n,2)}function Em(t,n){return rm(t.getHours(),n,2)}function Cm(t,n){return rm(t.getHours()%12||12,n,2)}function Nm(t,n){return rm(1+Gg.count(fy(t),t),n,3)}function Pm(t,n){return rm(t.getMilliseconds(),n,3)}function Dm(t,n){return Pm(t,n)+"000"}function zm(t,n){return rm(t.getMonth()+1,n,2)}function Lm(t,n){return rm(t.getMinutes(),n,2)}function Hm(t,n){return rm(t.getSeconds(),n,2)}function Rm(t){var n=t.getDay();return 0===n?7:n}function Bm(t,n){return rm($g.count(fy(t)-1,t),n,2)}function Im(t){var n=t.getDay();return n>=4||0===n?Kg(t):Kg.ceil(t)}function qm(t,n){return t=Im(t),rm(Kg.count(fy(t),t)+(4===fy(t).getDay()),n,2)}function Fm(t){return t.getDay()}function Om(t,n){return rm(Xg.count(fy(t)-1,t),n,2)}function Um(t,n){return rm(t.getFullYear()%100,n,2)}function Ym(t,n){return rm((t=Im(t)).getFullYear()%100,n,2)}function Gm(t,n){return rm(t.getFullYear()%1e4,n,4)}function Vm(t,n){var e=t.getDay();return rm((t=e>=4||0===e?Kg(t):Kg.ceil(t)).getFullYear()%1e4,n,4)}function jm(t){var n=t.getTimezoneOffset();return(n>0?"-":(n*=-1,"+"))+rm(n/60|0,"0",2)+rm(n%60,"0",2)}function $m(t,n){return rm(t.getUTCDate(),n,2)}function Xm(t,n){return rm(t.getUTCHours(),n,2)}function Wm(t,n){return rm(t.getUTCHours()%12||12,n,2)}function Zm(t,n){return rm(1+by.count(Oy(t),t),n,3)}function Km(t,n){return rm(t.getUTCMilliseconds(),n,3)}function Qm(t,n){return Km(t,n)+"000"}function Jm(t,n){return rm(t.getUTCMonth()+1,n,2)}function tv(t,n){return rm(t.getUTCMinutes(),n,2)}function nv(t,n){return rm(t.getUTCSeconds(),n,2)}function ev(t){var n=t.getUTCDay();return 0===n?7:n}function rv(t,n){return rm(My.count(Oy(t)-1,t),n,2)}function iv(t){var n=t.getUTCDay();return n>=4||0===n?Sy(t):Sy.ceil(t)}function ov(t,n){return t=iv(t),rm(Sy.count(Oy(t),t)+(4===Oy(t).getUTCDay()),n,2)}function av(t){return t.getUTCDay()}function uv(t,n){return rm(ky.count(Oy(t)-1,t),n,2)}function sv(t,n){return rm(t.getUTCFullYear()%100,n,2)}function cv(t,n){return rm((t=iv(t)).getUTCFullYear()%100,n,2)}function lv(t,n){return rm(t.getUTCFullYear()%1e4,n,4)}function fv(t,n){var e=t.getUTCDay();return rm((t=e>=4||0===e?Sy(t):Sy.ceil(t)).getUTCFullYear()%1e4,n,4)}function hv(){return"+0000"}function dv(){return"%"}function pv(t){return+t}function gv(t){return Math.floor(+t/1e3)}function yv(n){return Qy=Ky(n),t.timeFormat=Qy.format,t.timeParse=Qy.parse,t.utcFormat=Qy.utcFormat,t.utcParse=Qy.utcParse,Qy}t.timeFormat=void 0,t.timeParse=void 0,t.utcFormat=void 0,t.utcParse=void 0,yv({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 mv="%Y-%m-%dT%H:%M:%S.%LZ";var vv=Date.prototype.toISOString?function(t){return t.toISOString()}:t.utcFormat(mv),_v=vv;var bv=+new Date("2000-01-01T00:00:00.000Z")?function(t){var n=new Date(t);return isNaN(n)?null:n}:t.utcParse(mv),xv=bv;function wv(t){return new Date(t)}function Mv(t){return t instanceof Date?+t:+new Date(+t)}function kv(t,n,e,r,i,o,a,u,s,c){var l=ng(),f=l.invert,h=l.domain,d=c(".%L"),p=c(":%S"),g=c("%I:%M"),y=c("%I %p"),m=c("%a %d"),v=c("%b %d"),_=c("%B"),b=c("%Y");function x(t){return(s(t)Mr(t[t.length-1]),Uv=new Array(3).concat("d8b365f5f5f55ab4ac","a6611adfc27d80cdc1018571","a6611adfc27df5f5f580cdc1018571","8c510ad8b365f6e8c3c7eae55ab4ac01665e","8c510ad8b365f6e8c3f5f5f5c7eae55ab4ac01665e","8c510abf812ddfc27df6e8c3c7eae580cdc135978f01665e","8c510abf812ddfc27df6e8c3f5f5f5c7eae580cdc135978f01665e","5430058c510abf812ddfc27df6e8c3c7eae580cdc135978f01665e003c30","5430058c510abf812ddfc27df6e8c3f5f5f5c7eae580cdc135978f01665e003c30").map(Nv),Yv=Ov(Uv),Gv=new Array(3).concat("af8dc3f7f7f77fbf7b","7b3294c2a5cfa6dba0008837","7b3294c2a5cff7f7f7a6dba0008837","762a83af8dc3e7d4e8d9f0d37fbf7b1b7837","762a83af8dc3e7d4e8f7f7f7d9f0d37fbf7b1b7837","762a839970abc2a5cfe7d4e8d9f0d3a6dba05aae611b7837","762a839970abc2a5cfe7d4e8f7f7f7d9f0d3a6dba05aae611b7837","40004b762a839970abc2a5cfe7d4e8d9f0d3a6dba05aae611b783700441b","40004b762a839970abc2a5cfe7d4e8f7f7f7d9f0d3a6dba05aae611b783700441b").map(Nv),Vv=Ov(Gv),jv=new Array(3).concat("e9a3c9f7f7f7a1d76a","d01c8bf1b6dab8e1864dac26","d01c8bf1b6daf7f7f7b8e1864dac26","c51b7de9a3c9fde0efe6f5d0a1d76a4d9221","c51b7de9a3c9fde0eff7f7f7e6f5d0a1d76a4d9221","c51b7dde77aef1b6dafde0efe6f5d0b8e1867fbc414d9221","c51b7dde77aef1b6dafde0eff7f7f7e6f5d0b8e1867fbc414d9221","8e0152c51b7dde77aef1b6dafde0efe6f5d0b8e1867fbc414d9221276419","8e0152c51b7dde77aef1b6dafde0eff7f7f7e6f5d0b8e1867fbc414d9221276419").map(Nv),$v=Ov(jv),Xv=new Array(3).concat("998ec3f7f7f7f1a340","5e3c99b2abd2fdb863e66101","5e3c99b2abd2f7f7f7fdb863e66101","542788998ec3d8daebfee0b6f1a340b35806","542788998ec3d8daebf7f7f7fee0b6f1a340b35806","5427888073acb2abd2d8daebfee0b6fdb863e08214b35806","5427888073acb2abd2d8daebf7f7f7fee0b6fdb863e08214b35806","2d004b5427888073acb2abd2d8daebfee0b6fdb863e08214b358067f3b08","2d004b5427888073acb2abd2d8daebf7f7f7fee0b6fdb863e08214b358067f3b08").map(Nv),Wv=Ov(Xv),Zv=new Array(3).concat("ef8a62f7f7f767a9cf","ca0020f4a58292c5de0571b0","ca0020f4a582f7f7f792c5de0571b0","b2182bef8a62fddbc7d1e5f067a9cf2166ac","b2182bef8a62fddbc7f7f7f7d1e5f067a9cf2166ac","b2182bd6604df4a582fddbc7d1e5f092c5de4393c32166ac","b2182bd6604df4a582fddbc7f7f7f7d1e5f092c5de4393c32166ac","67001fb2182bd6604df4a582fddbc7d1e5f092c5de4393c32166ac053061","67001fb2182bd6604df4a582fddbc7f7f7f7d1e5f092c5de4393c32166ac053061").map(Nv),Kv=Ov(Zv),Qv=new Array(3).concat("ef8a62ffffff999999","ca0020f4a582bababa404040","ca0020f4a582ffffffbababa404040","b2182bef8a62fddbc7e0e0e09999994d4d4d","b2182bef8a62fddbc7ffffffe0e0e09999994d4d4d","b2182bd6604df4a582fddbc7e0e0e0bababa8787874d4d4d","b2182bd6604df4a582fddbc7ffffffe0e0e0bababa8787874d4d4d","67001fb2182bd6604df4a582fddbc7e0e0e0bababa8787874d4d4d1a1a1a","67001fb2182bd6604df4a582fddbc7ffffffe0e0e0bababa8787874d4d4d1a1a1a").map(Nv),Jv=Ov(Qv),t_=new Array(3).concat("fc8d59ffffbf91bfdb","d7191cfdae61abd9e92c7bb6","d7191cfdae61ffffbfabd9e92c7bb6","d73027fc8d59fee090e0f3f891bfdb4575b4","d73027fc8d59fee090ffffbfe0f3f891bfdb4575b4","d73027f46d43fdae61fee090e0f3f8abd9e974add14575b4","d73027f46d43fdae61fee090ffffbfe0f3f8abd9e974add14575b4","a50026d73027f46d43fdae61fee090e0f3f8abd9e974add14575b4313695","a50026d73027f46d43fdae61fee090ffffbfe0f3f8abd9e974add14575b4313695").map(Nv),n_=Ov(t_),e_=new Array(3).concat("fc8d59ffffbf91cf60","d7191cfdae61a6d96a1a9641","d7191cfdae61ffffbfa6d96a1a9641","d73027fc8d59fee08bd9ef8b91cf601a9850","d73027fc8d59fee08bffffbfd9ef8b91cf601a9850","d73027f46d43fdae61fee08bd9ef8ba6d96a66bd631a9850","d73027f46d43fdae61fee08bffffbfd9ef8ba6d96a66bd631a9850","a50026d73027f46d43fdae61fee08bd9ef8ba6d96a66bd631a9850006837","a50026d73027f46d43fdae61fee08bffffbfd9ef8ba6d96a66bd631a9850006837").map(Nv),r_=Ov(e_),i_=new Array(3).concat("fc8d59ffffbf99d594","d7191cfdae61abdda42b83ba","d7191cfdae61ffffbfabdda42b83ba","d53e4ffc8d59fee08be6f59899d5943288bd","d53e4ffc8d59fee08bffffbfe6f59899d5943288bd","d53e4ff46d43fdae61fee08be6f598abdda466c2a53288bd","d53e4ff46d43fdae61fee08bffffbfe6f598abdda466c2a53288bd","9e0142d53e4ff46d43fdae61fee08be6f598abdda466c2a53288bd5e4fa2","9e0142d53e4ff46d43fdae61fee08bffffbfe6f598abdda466c2a53288bd5e4fa2").map(Nv),o_=Ov(i_),a_=new Array(3).concat("e5f5f999d8c92ca25f","edf8fbb2e2e266c2a4238b45","edf8fbb2e2e266c2a42ca25f006d2c","edf8fbccece699d8c966c2a42ca25f006d2c","edf8fbccece699d8c966c2a441ae76238b45005824","f7fcfde5f5f9ccece699d8c966c2a441ae76238b45005824","f7fcfde5f5f9ccece699d8c966c2a441ae76238b45006d2c00441b").map(Nv),u_=Ov(a_),s_=new Array(3).concat("e0ecf49ebcda8856a7","edf8fbb3cde38c96c688419d","edf8fbb3cde38c96c68856a7810f7c","edf8fbbfd3e69ebcda8c96c68856a7810f7c","edf8fbbfd3e69ebcda8c96c68c6bb188419d6e016b","f7fcfde0ecf4bfd3e69ebcda8c96c68c6bb188419d6e016b","f7fcfde0ecf4bfd3e69ebcda8c96c68c6bb188419d810f7c4d004b").map(Nv),c_=Ov(s_),l_=new Array(3).concat("e0f3dba8ddb543a2ca","f0f9e8bae4bc7bccc42b8cbe","f0f9e8bae4bc7bccc443a2ca0868ac","f0f9e8ccebc5a8ddb57bccc443a2ca0868ac","f0f9e8ccebc5a8ddb57bccc44eb3d32b8cbe08589e","f7fcf0e0f3dbccebc5a8ddb57bccc44eb3d32b8cbe08589e","f7fcf0e0f3dbccebc5a8ddb57bccc44eb3d32b8cbe0868ac084081").map(Nv),f_=Ov(l_),h_=new Array(3).concat("fee8c8fdbb84e34a33","fef0d9fdcc8afc8d59d7301f","fef0d9fdcc8afc8d59e34a33b30000","fef0d9fdd49efdbb84fc8d59e34a33b30000","fef0d9fdd49efdbb84fc8d59ef6548d7301f990000","fff7ecfee8c8fdd49efdbb84fc8d59ef6548d7301f990000","fff7ecfee8c8fdd49efdbb84fc8d59ef6548d7301fb300007f0000").map(Nv),d_=Ov(h_),p_=new Array(3).concat("ece2f0a6bddb1c9099","f6eff7bdc9e167a9cf02818a","f6eff7bdc9e167a9cf1c9099016c59","f6eff7d0d1e6a6bddb67a9cf1c9099016c59","f6eff7d0d1e6a6bddb67a9cf3690c002818a016450","fff7fbece2f0d0d1e6a6bddb67a9cf3690c002818a016450","fff7fbece2f0d0d1e6a6bddb67a9cf3690c002818a016c59014636").map(Nv),g_=Ov(p_),y_=new Array(3).concat("ece7f2a6bddb2b8cbe","f1eef6bdc9e174a9cf0570b0","f1eef6bdc9e174a9cf2b8cbe045a8d","f1eef6d0d1e6a6bddb74a9cf2b8cbe045a8d","f1eef6d0d1e6a6bddb74a9cf3690c00570b0034e7b","fff7fbece7f2d0d1e6a6bddb74a9cf3690c00570b0034e7b","fff7fbece7f2d0d1e6a6bddb74a9cf3690c00570b0045a8d023858").map(Nv),m_=Ov(y_),v_=new Array(3).concat("e7e1efc994c7dd1c77","f1eef6d7b5d8df65b0ce1256","f1eef6d7b5d8df65b0dd1c77980043","f1eef6d4b9dac994c7df65b0dd1c77980043","f1eef6d4b9dac994c7df65b0e7298ace125691003f","f7f4f9e7e1efd4b9dac994c7df65b0e7298ace125691003f","f7f4f9e7e1efd4b9dac994c7df65b0e7298ace125698004367001f").map(Nv),__=Ov(v_),b_=new Array(3).concat("fde0ddfa9fb5c51b8a","feebe2fbb4b9f768a1ae017e","feebe2fbb4b9f768a1c51b8a7a0177","feebe2fcc5c0fa9fb5f768a1c51b8a7a0177","feebe2fcc5c0fa9fb5f768a1dd3497ae017e7a0177","fff7f3fde0ddfcc5c0fa9fb5f768a1dd3497ae017e7a0177","fff7f3fde0ddfcc5c0fa9fb5f768a1dd3497ae017e7a017749006a").map(Nv),x_=Ov(b_),w_=new Array(3).concat("edf8b17fcdbb2c7fb8","ffffcca1dab441b6c4225ea8","ffffcca1dab441b6c42c7fb8253494","ffffccc7e9b47fcdbb41b6c42c7fb8253494","ffffccc7e9b47fcdbb41b6c41d91c0225ea80c2c84","ffffd9edf8b1c7e9b47fcdbb41b6c41d91c0225ea80c2c84","ffffd9edf8b1c7e9b47fcdbb41b6c41d91c0225ea8253494081d58").map(Nv),M_=Ov(w_),k_=new Array(3).concat("f7fcb9addd8e31a354","ffffccc2e69978c679238443","ffffccc2e69978c67931a354006837","ffffccd9f0a3addd8e78c67931a354006837","ffffccd9f0a3addd8e78c67941ab5d238443005a32","ffffe5f7fcb9d9f0a3addd8e78c67941ab5d238443005a32","ffffe5f7fcb9d9f0a3addd8e78c67941ab5d238443006837004529").map(Nv),T_=Ov(k_),A_=new Array(3).concat("fff7bcfec44fd95f0e","ffffd4fed98efe9929cc4c02","ffffd4fed98efe9929d95f0e993404","ffffd4fee391fec44ffe9929d95f0e993404","ffffd4fee391fec44ffe9929ec7014cc4c028c2d04","ffffe5fff7bcfee391fec44ffe9929ec7014cc4c028c2d04","ffffe5fff7bcfee391fec44ffe9929ec7014cc4c02993404662506").map(Nv),S_=Ov(A_),E_=new Array(3).concat("ffeda0feb24cf03b20","ffffb2fecc5cfd8d3ce31a1c","ffffb2fecc5cfd8d3cf03b20bd0026","ffffb2fed976feb24cfd8d3cf03b20bd0026","ffffb2fed976feb24cfd8d3cfc4e2ae31a1cb10026","ffffccffeda0fed976feb24cfd8d3cfc4e2ae31a1cb10026","ffffccffeda0fed976feb24cfd8d3cfc4e2ae31a1cbd0026800026").map(Nv),C_=Ov(E_),N_=new Array(3).concat("deebf79ecae13182bd","eff3ffbdd7e76baed62171b5","eff3ffbdd7e76baed63182bd08519c","eff3ffc6dbef9ecae16baed63182bd08519c","eff3ffc6dbef9ecae16baed64292c62171b5084594","f7fbffdeebf7c6dbef9ecae16baed64292c62171b5084594","f7fbffdeebf7c6dbef9ecae16baed64292c62171b508519c08306b").map(Nv),P_=Ov(N_),D_=new Array(3).concat("e5f5e0a1d99b31a354","edf8e9bae4b374c476238b45","edf8e9bae4b374c47631a354006d2c","edf8e9c7e9c0a1d99b74c47631a354006d2c","edf8e9c7e9c0a1d99b74c47641ab5d238b45005a32","f7fcf5e5f5e0c7e9c0a1d99b74c47641ab5d238b45005a32","f7fcf5e5f5e0c7e9c0a1d99b74c47641ab5d238b45006d2c00441b").map(Nv),z_=Ov(D_),L_=new Array(3).concat("f0f0f0bdbdbd636363","f7f7f7cccccc969696525252","f7f7f7cccccc969696636363252525","f7f7f7d9d9d9bdbdbd969696636363252525","f7f7f7d9d9d9bdbdbd969696737373525252252525","fffffff0f0f0d9d9d9bdbdbd969696737373525252252525","fffffff0f0f0d9d9d9bdbdbd969696737373525252252525000000").map(Nv),H_=Ov(L_),R_=new Array(3).concat("efedf5bcbddc756bb1","f2f0f7cbc9e29e9ac86a51a3","f2f0f7cbc9e29e9ac8756bb154278f","f2f0f7dadaebbcbddc9e9ac8756bb154278f","f2f0f7dadaebbcbddc9e9ac8807dba6a51a34a1486","fcfbfdefedf5dadaebbcbddc9e9ac8807dba6a51a34a1486","fcfbfdefedf5dadaebbcbddc9e9ac8807dba6a51a354278f3f007d").map(Nv),B_=Ov(R_),I_=new Array(3).concat("fee0d2fc9272de2d26","fee5d9fcae91fb6a4acb181d","fee5d9fcae91fb6a4ade2d26a50f15","fee5d9fcbba1fc9272fb6a4ade2d26a50f15","fee5d9fcbba1fc9272fb6a4aef3b2ccb181d99000d","fff5f0fee0d2fcbba1fc9272fb6a4aef3b2ccb181d99000d","fff5f0fee0d2fcbba1fc9272fb6a4aef3b2ccb181da50f1567000d").map(Nv),q_=Ov(I_),F_=new Array(3).concat("fee6cefdae6be6550d","feeddefdbe85fd8d3cd94701","feeddefdbe85fd8d3ce6550da63603","feeddefdd0a2fdae6bfd8d3ce6550da63603","feeddefdd0a2fdae6bfd8d3cf16913d948018c2d04","fff5ebfee6cefdd0a2fdae6bfd8d3cf16913d948018c2d04","fff5ebfee6cefdd0a2fdae6bfd8d3cf16913d94801a636037f2704").map(Nv),O_=Ov(F_);var U_=Jr(fr(300,.5,0),fr(-240,.5,1)),Y_=Jr(fr(-100,.75,.35),fr(80,1.5,.8)),G_=Jr(fr(260,.75,.35),fr(80,1.5,.8)),V_=fr();var j_=Se(),$_=Math.PI/3,X_=2*Math.PI/3;function W_(t){var n=t.length;return function(e){return t[Math.max(0,Math.min(n-1,Math.floor(e*n)))]}}var Z_=W_(Nv("44015444025645045745055946075a46085c460a5d460b5e470d60470e6147106347116447136548146748166848176948186a481a6c481b6d481c6e481d6f481f70482071482173482374482475482576482677482878482979472a7a472c7a472d7b472e7c472f7d46307e46327e46337f463480453581453781453882443983443a83443b84433d84433e85423f854240864241864142874144874045884046883f47883f48893e49893e4a893e4c8a3d4d8a3d4e8a3c4f8a3c508b3b518b3b528b3a538b3a548c39558c39568c38588c38598c375a8c375b8d365c8d365d8d355e8d355f8d34608d34618d33628d33638d32648e32658e31668e31678e31688e30698e306a8e2f6b8e2f6c8e2e6d8e2e6e8e2e6f8e2d708e2d718e2c718e2c728e2c738e2b748e2b758e2a768e2a778e2a788e29798e297a8e297b8e287c8e287d8e277e8e277f8e27808e26818e26828e26828e25838e25848e25858e24868e24878e23888e23898e238a8d228b8d228c8d228d8d218e8d218f8d21908d21918c20928c20928c20938c1f948c1f958b1f968b1f978b1f988b1f998a1f9a8a1e9b8a1e9c891e9d891f9e891f9f881fa0881fa1881fa1871fa28720a38620a48621a58521a68522a78522a88423a98324aa8325ab8225ac8226ad8127ad8128ae8029af7f2ab07f2cb17e2db27d2eb37c2fb47c31b57b32b67a34b67935b77937b87838b9773aba763bbb753dbc743fbc7340bd7242be7144bf7046c06f48c16e4ac16d4cc26c4ec36b50c46a52c56954c56856c66758c7655ac8645cc8635ec96260ca6063cb5f65cb5e67cc5c69cd5b6ccd5a6ece5870cf5773d05675d05477d1537ad1517cd2507fd34e81d34d84d44b86d54989d5488bd6468ed64590d74393d74195d84098d83e9bd93c9dd93ba0da39a2da37a5db36a8db34aadc32addc30b0dd2fb2dd2db5de2bb8de29bade28bddf26c0df25c2df23c5e021c8e020cae11fcde11dd0e11cd2e21bd5e21ad8e219dae319dde318dfe318e2e418e5e419e7e419eae51aece51befe51cf1e51df4e61ef6e620f8e621fbe723fde725")),K_=W_(Nv("00000401000501010601010802010902020b02020d03030f03031204041405041606051806051a07061c08071e0907200a08220b09240c09260d0a290e0b2b100b2d110c2f120d31130d34140e36150e38160f3b180f3d19103f1a10421c10441d11471e114920114b21114e22115024125325125527125829115a2a115c2c115f2d11612f116331116533106734106936106b38106c390f6e3b0f703d0f713f0f72400f74420f75440f764510774710784910784a10794c117a4e117b4f127b51127c52137c54137d56147d57157e59157e5a167e5c167f5d177f5f187f601880621980641a80651a80671b80681c816a1c816b1d816d1d816e1e81701f81721f817320817521817621817822817922827b23827c23827e24828025828125818326818426818627818827818928818b29818c29818e2a81902a81912b81932b80942c80962c80982d80992d809b2e7f9c2e7f9e2f7fa02f7fa1307ea3307ea5317ea6317da8327daa337dab337cad347cae347bb0357bb2357bb3367ab5367ab73779b83779ba3878bc3978bd3977bf3a77c03a76c23b75c43c75c53c74c73d73c83e73ca3e72cc3f71cd4071cf4070d0416fd2426fd3436ed5446dd6456cd8456cd9466bdb476adc4869de4968df4a68e04c67e24d66e34e65e44f64e55064e75263e85362e95462ea5661eb5760ec5860ed5a5fee5b5eef5d5ef05f5ef1605df2625df2645cf3655cf4675cf4695cf56b5cf66c5cf66e5cf7705cf7725cf8745cf8765cf9785df9795df97b5dfa7d5efa7f5efa815ffb835ffb8560fb8761fc8961fc8a62fc8c63fc8e64fc9065fd9266fd9467fd9668fd9869fd9a6afd9b6bfe9d6cfe9f6dfea16efea36ffea571fea772fea973feaa74feac76feae77feb078feb27afeb47bfeb67cfeb77efeb97ffebb81febd82febf84fec185fec287fec488fec68afec88cfeca8dfecc8ffecd90fecf92fed194fed395fed597fed799fed89afdda9cfddc9efddea0fde0a1fde2a3fde3a5fde5a7fde7a9fde9aafdebacfcecaefceeb0fcf0b2fcf2b4fcf4b6fcf6b8fcf7b9fcf9bbfcfbbdfcfdbf")),Q_=W_(Nv("00000401000501010601010802010a02020c02020e03021004031204031405041706041907051b08051d09061f0a07220b07240c08260d08290e092b10092d110a30120a32140b34150b37160b39180c3c190c3e1b0c411c0c431e0c451f0c48210c4a230c4c240c4f260c51280b53290b552b0b572d0b592f0a5b310a5c320a5e340a5f3609613809623909633b09643d09653e0966400a67420a68440a68450a69470b6a490b6a4a0c6b4c0c6b4d0d6c4f0d6c510e6c520e6d540f6d550f6d57106e59106e5a116e5c126e5d126e5f136e61136e62146e64156e65156e67166e69166e6a176e6c186e6d186e6f196e71196e721a6e741a6e751b6e771c6d781c6d7a1d6d7c1d6d7d1e6d7f1e6c801f6c82206c84206b85216b87216b88226a8a226a8c23698d23698f24699025689225689326679526679727669827669a28659b29649d29649f2a63a02a63a22b62a32c61a52c60a62d60a82e5fa92e5eab2f5ead305dae305cb0315bb1325ab3325ab43359b63458b73557b93556ba3655bc3754bd3853bf3952c03a51c13a50c33b4fc43c4ec63d4dc73e4cc83f4bca404acb4149cc4248ce4347cf4446d04545d24644d34743d44842d54a41d74b3fd84c3ed94d3dda4e3cdb503bdd513ade5238df5337e05536e15635e25734e35933e45a31e55c30e65d2fe75e2ee8602de9612bea632aeb6429eb6628ec6726ed6925ee6a24ef6c23ef6e21f06f20f1711ff1731df2741cf3761bf37819f47918f57b17f57d15f67e14f68013f78212f78410f8850ff8870ef8890cf98b0bf98c0af98e09fa9008fa9207fa9407fb9606fb9706fb9906fb9b06fb9d07fc9f07fca108fca309fca50afca60cfca80dfcaa0ffcac11fcae12fcb014fcb216fcb418fbb61afbb81dfbba1ffbbc21fbbe23fac026fac228fac42afac62df9c72ff9c932f9cb35f8cd37f8cf3af7d13df7d340f6d543f6d746f5d949f5db4cf4dd4ff4df53f4e156f3e35af3e55df2e661f2e865f2ea69f1ec6df1ed71f1ef75f1f179f2f27df2f482f3f586f3f68af4f88ef5f992f6fa96f8fb9af9fc9dfafda1fcffa4")),J_=W_(Nv("0d088710078813078916078a19068c1b068d1d068e20068f2206902406912605912805922a05932c05942e05952f059631059733059735049837049938049a3a049a3c049b3e049c3f049c41049d43039e44039e46039f48039f4903a04b03a14c02a14e02a25002a25102a35302a35502a45601a45801a45901a55b01a55c01a65e01a66001a66100a76300a76400a76600a76700a86900a86a00a86c00a86e00a86f00a87100a87201a87401a87501a87701a87801a87a02a87b02a87d03a87e03a88004a88104a78305a78405a78606a68707a68808a68a09a58b0aa58d0ba58e0ca48f0da4910ea3920fa39410a29511a19613a19814a099159f9a169f9c179e9d189d9e199da01a9ca11b9ba21d9aa31e9aa51f99a62098a72197a82296aa2395ab2494ac2694ad2793ae2892b02991b12a90b22b8fb32c8eb42e8db52f8cb6308bb7318ab83289ba3388bb3488bc3587bd3786be3885bf3984c03a83c13b82c23c81c33d80c43e7fc5407ec6417dc7427cc8437bc9447aca457acb4679cc4778cc4977cd4a76ce4b75cf4c74d04d73d14e72d24f71d35171d45270d5536fd5546ed6556dd7566cd8576bd9586ada5a6ada5b69db5c68dc5d67dd5e66de5f65de6164df6263e06363e16462e26561e26660e3685fe4695ee56a5de56b5de66c5ce76e5be76f5ae87059e97158e97257ea7457eb7556eb7655ec7754ed7953ed7a52ee7b51ef7c51ef7e50f07f4ff0804ef1814df1834cf2844bf3854bf3874af48849f48948f58b47f58c46f68d45f68f44f79044f79143f79342f89441f89540f9973ff9983ef99a3efa9b3dfa9c3cfa9e3bfb9f3afba139fba238fca338fca537fca636fca835fca934fdab33fdac33fdae32fdaf31fdb130fdb22ffdb42ffdb52efeb72dfeb82cfeba2cfebb2bfebd2afebe2afec029fdc229fdc328fdc527fdc627fdc827fdca26fdcb26fccd25fcce25fcd025fcd225fbd324fbd524fbd724fad824fada24f9dc24f9dd25f8df25f8e125f7e225f7e425f6e626f6e826f5e926f5eb27f4ed27f3ee27f3f027f2f227f1f426f1f525f0f724f0f921"));function tb(t){return function(){return t}}var nb=Math.abs,eb=Math.atan2,rb=Math.cos,ib=Math.max,ob=Math.min,ab=Math.sin,ub=Math.sqrt,sb=1e-12,cb=Math.PI,lb=cb/2,fb=2*cb;function hb(t){return t>=1?lb:t<=-1?-lb:Math.asin(t)}function db(t){return t.innerRadius}function pb(t){return t.outerRadius}function gb(t){return t.startAngle}function yb(t){return t.endAngle}function mb(t){return t&&t.padAngle}function vb(t,n,e,r,i,o,a){var u=t-e,s=n-r,c=(a?o:-o)/ub(u*u+s*s),l=c*s,f=-c*u,h=t+l,d=n+f,p=e+l,g=r+f,y=(h+p)/2,m=(d+g)/2,v=p-h,_=g-d,b=v*v+_*_,x=i-o,w=h*g-p*d,M=(_<0?-1:1)*ub(ib(0,x*x*b-w*w)),k=(w*_-v*M)/b,T=(-w*v-_*M)/b,A=(w*_+v*M)/b,S=(-w*v+_*M)/b,E=k-y,C=T-m,N=A-y,P=S-m;return E*E+C*C>N*N+P*P&&(k=A,T=S),{cx:k,cy:T,x01:-l,y01:-f,x11:k*(i/x-1),y11:T*(i/x-1)}}var _b=Array.prototype.slice;function bb(t){return"object"==typeof t&&"length"in t?t:Array.from(t)}function xb(t){this._context=t}function wb(t){return new xb(t)}function Mb(t){return t[0]}function kb(t){return t[1]}function Tb(t,n){var e=tb(!0),r=null,i=wb,o=null;function a(a){var u,s,c,l=(a=bb(a)).length,f=!1;for(null==r&&(o=i(c=Ta())),u=0;u<=l;++u)!(u=l;--f)u.point(y[f],m[f]);u.lineEnd(),u.areaEnd()}g&&(y[c]=+t(h,c,s),m[c]=+n(h,c,s),u.point(r?+r(h,c,s):y[c],e?+e(h,c,s):m[c]))}if(d)return u=null,d+""||null}function c(){return Tb().defined(i).curve(a).context(o)}return t="function"==typeof t?t:void 0===t?Mb:tb(+t),n="function"==typeof n?n:tb(void 0===n?0:+n),e="function"==typeof e?e:void 0===e?kb:tb(+e),s.x=function(n){return arguments.length?(t="function"==typeof n?n:tb(+n),r=null,s):t},s.x0=function(n){return arguments.length?(t="function"==typeof n?n:tb(+n),s):t},s.x1=function(t){return arguments.length?(r=null==t?null:"function"==typeof t?t:tb(+t),s):r},s.y=function(t){return arguments.length?(n="function"==typeof t?t:tb(+t),e=null,s):n},s.y0=function(t){return arguments.length?(n="function"==typeof t?t:tb(+t),s):n},s.y1=function(t){return arguments.length?(e=null==t?null:"function"==typeof t?t:tb(+t),s):e},s.lineX0=s.lineY0=function(){return c().x(t).y(n)},s.lineY1=function(){return c().x(t).y(e)},s.lineX1=function(){return c().x(r).y(n)},s.defined=function(t){return arguments.length?(i="function"==typeof t?t:tb(!!t),s):i},s.curve=function(t){return arguments.length?(a=t,null!=o&&(u=a(o)),s):a},s.context=function(t){return arguments.length?(null==t?o=u=null:u=a(o=t),s):o},s}function Sb(t,n){return nt?1:n>=t?0:NaN}function Eb(t){return t}xb.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(t,n){switch(t=+t,n=+n,this._point){case 0:this._point=1,this._line?this._context.lineTo(t,n):this._context.moveTo(t,n);break;case 1:this._point=2;default:this._context.lineTo(t,n)}}};var Cb=Pb(wb);function Nb(t){this._curve=t}function Pb(t){function n(n){return new Nb(t(n))}return n._curve=t,n}function Db(t){var n=t.curve;return t.angle=t.x,delete t.x,t.radius=t.y,delete t.y,t.curve=function(t){return arguments.length?n(Pb(t)):n()._curve},t}function zb(){return Db(Tb().curve(Cb))}function Lb(){var t=Ab().curve(Cb),n=t.curve,e=t.lineX0,r=t.lineX1,i=t.lineY0,o=t.lineY1;return t.angle=t.x,delete t.x,t.startAngle=t.x0,delete t.x0,t.endAngle=t.x1,delete t.x1,t.radius=t.y,delete t.y,t.innerRadius=t.y0,delete t.y0,t.outerRadius=t.y1,delete t.y1,t.lineStartAngle=function(){return Db(e())},delete t.lineX0,t.lineEndAngle=function(){return Db(r())},delete t.lineX1,t.lineInnerRadius=function(){return Db(i())},delete t.lineY0,t.lineOuterRadius=function(){return Db(o())},delete t.lineY1,t.curve=function(t){return arguments.length?n(Pb(t)):n()._curve},t}function Hb(t,n){return[(n=+n)*Math.cos(t-=Math.PI/2),n*Math.sin(t)]}function Rb(t){return t.source}function Bb(t){return t.target}function Ib(t){var n=Rb,e=Bb,r=Mb,i=kb,o=null;function a(){var a,u=_b.call(arguments),s=n.apply(this,u),c=e.apply(this,u);if(o||(o=a=Ta()),t(o,+r.apply(this,(u[0]=s,u)),+i.apply(this,u),+r.apply(this,(u[0]=c,u)),+i.apply(this,u)),a)return o=null,a+""||null}return a.source=function(t){return arguments.length?(n=t,a):n},a.target=function(t){return arguments.length?(e=t,a):e},a.x=function(t){return arguments.length?(r="function"==typeof t?t:tb(+t),a):r},a.y=function(t){return arguments.length?(i="function"==typeof t?t:tb(+t),a):i},a.context=function(t){return arguments.length?(o=null==t?null:t,a):o},a}function qb(t,n,e,r,i){t.moveTo(n,e),t.bezierCurveTo(n=(n+r)/2,e,n,i,r,i)}function Fb(t,n,e,r,i){t.moveTo(n,e),t.bezierCurveTo(n,e=(e+i)/2,r,e,r,i)}function Ob(t,n,e,r,i){var o=Hb(n,e),a=Hb(n,e=(e+i)/2),u=Hb(r,e),s=Hb(r,i);t.moveTo(o[0],o[1]),t.bezierCurveTo(a[0],a[1],u[0],u[1],s[0],s[1])}Nb.prototype={areaStart:function(){this._curve.areaStart()},areaEnd:function(){this._curve.areaEnd()},lineStart:function(){this._curve.lineStart()},lineEnd:function(){this._curve.lineEnd()},point:function(t,n){this._curve.point(n*Math.sin(t),n*-Math.cos(t))}};var Ub={draw:function(t,n){var e=Math.sqrt(n/cb);t.moveTo(e,0),t.arc(0,0,e,0,fb)}},Yb={draw:function(t,n){var e=Math.sqrt(n/5)/2;t.moveTo(-3*e,-e),t.lineTo(-e,-e),t.lineTo(-e,-3*e),t.lineTo(e,-3*e),t.lineTo(e,-e),t.lineTo(3*e,-e),t.lineTo(3*e,e),t.lineTo(e,e),t.lineTo(e,3*e),t.lineTo(-e,3*e),t.lineTo(-e,e),t.lineTo(-3*e,e),t.closePath()}},Gb=Math.sqrt(1/3),Vb=2*Gb,jb={draw:function(t,n){var e=Math.sqrt(n/Vb),r=e*Gb;t.moveTo(0,-e),t.lineTo(r,0),t.lineTo(0,e),t.lineTo(-r,0),t.closePath()}},$b=Math.sin(cb/10)/Math.sin(7*cb/10),Xb=Math.sin(fb/10)*$b,Wb=-Math.cos(fb/10)*$b,Zb={draw:function(t,n){var e=Math.sqrt(.8908130915292852*n),r=Xb*e,i=Wb*e;t.moveTo(0,-e),t.lineTo(r,i);for(var o=1;o<5;++o){var a=fb*o/5,u=Math.cos(a),s=Math.sin(a);t.lineTo(s*e,-u*e),t.lineTo(u*r-s*i,s*r+u*i)}t.closePath()}},Kb={draw:function(t,n){var e=Math.sqrt(n),r=-e/2;t.rect(r,r,e,e)}},Qb=Math.sqrt(3),Jb={draw:function(t,n){var e=-Math.sqrt(n/(3*Qb));t.moveTo(0,2*e),t.lineTo(-Qb*e,-e),t.lineTo(Qb*e,-e),t.closePath()}},tx=-.5,nx=Math.sqrt(3)/2,ex=1/Math.sqrt(12),rx=3*(ex/2+1),ix={draw:function(t,n){var e=Math.sqrt(n/rx),r=e/2,i=e*ex,o=r,a=e*ex+e,u=-o,s=a;t.moveTo(r,i),t.lineTo(o,a),t.lineTo(u,s),t.lineTo(tx*r-nx*i,nx*r+tx*i),t.lineTo(tx*o-nx*a,nx*o+tx*a),t.lineTo(tx*u-nx*s,nx*u+tx*s),t.lineTo(tx*r+nx*i,tx*i-nx*r),t.lineTo(tx*o+nx*a,tx*a-nx*o),t.lineTo(tx*u+nx*s,tx*s-nx*u),t.closePath()}},ox=[Ub,Yb,jb,Kb,Zb,Jb,ix];function ax(){}function ux(t,n,e){t._context.bezierCurveTo((2*t._x0+t._x1)/3,(2*t._y0+t._y1)/3,(t._x0+2*t._x1)/3,(t._y0+2*t._y1)/3,(t._x0+4*t._x1+n)/6,(t._y0+4*t._y1+e)/6)}function sx(t){this._context=t}function cx(t){this._context=t}function lx(t){this._context=t}sx.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:ux(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(t,n){switch(t=+t,n=+n,this._point){case 0:this._point=1,this._line?this._context.lineTo(t,n):this._context.moveTo(t,n);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:ux(this,t,n)}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=n}},cx.prototype={areaStart:ax,areaEnd:ax,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(t,n){switch(t=+t,n=+n,this._point){case 0:this._point=1,this._x2=t,this._y2=n;break;case 1:this._point=2,this._x3=t,this._y3=n;break;case 2:this._point=3,this._x4=t,this._y4=n,this._context.moveTo((this._x0+4*this._x1+t)/6,(this._y0+4*this._y1+n)/6);break;default:ux(this,t,n)}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=n}},lx.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(t,n){switch(t=+t,n=+n,this._point){case 0:this._point=1;break;case 1:this._point=2;break;case 2:this._point=3;var e=(this._x0+4*this._x1+t)/6,r=(this._y0+4*this._y1+n)/6;this._line?this._context.lineTo(e,r):this._context.moveTo(e,r);break;case 3:this._point=4;default:ux(this,t,n)}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=n}};class fx{constructor(t,n){this._context=t,this._x=n}areaStart(){this._line=0}areaEnd(){this._line=NaN}lineStart(){this._point=0}lineEnd(){(this._line||0!==this._line&&1===this._point)&&this._context.closePath(),this._line=1-this._line}point(t,n){switch(t=+t,n=+n,this._point){case 0:this._point=1,this._line?this._context.lineTo(t,n):this._context.moveTo(t,n);break;case 1:this._point=2;default:this._x?this._context.bezierCurveTo(this._x0=(this._x0+t)/2,this._y0,this._x0,n,t,n):this._context.bezierCurveTo(this._x0,this._y0=(this._y0+n)/2,t,this._y0,t,n)}this._x0=t,this._y0=n}}function hx(t,n){this._basis=new sx(t),this._beta=n}hx.prototype={lineStart:function(){this._x=[],this._y=[],this._basis.lineStart()},lineEnd:function(){var t=this._x,n=this._y,e=t.length-1;if(e>0)for(var r,i=t[0],o=n[0],a=t[e]-i,u=n[e]-o,s=-1;++s<=e;)r=s/e,this._basis.point(this._beta*t[s]+(1-this._beta)*(i+r*a),this._beta*n[s]+(1-this._beta)*(o+r*u));this._x=this._y=null,this._basis.lineEnd()},point:function(t,n){this._x.push(+t),this._y.push(+n)}};var dx=function t(n){function e(t){return 1===n?new sx(t):new hx(t,n)}return e.beta=function(n){return t(+n)},e}(.85);function px(t,n,e){t._context.bezierCurveTo(t._x1+t._k*(t._x2-t._x0),t._y1+t._k*(t._y2-t._y0),t._x2+t._k*(t._x1-n),t._y2+t._k*(t._y1-e),t._x2,t._y2)}function gx(t,n){this._context=t,this._k=(1-n)/6}gx.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:px(this,this._x1,this._y1)}(this._line||0!==this._line&&1===this._point)&&this._context.closePath(),this._line=1-this._line},point:function(t,n){switch(t=+t,n=+n,this._point){case 0:this._point=1,this._line?this._context.lineTo(t,n):this._context.moveTo(t,n);break;case 1:this._point=2,this._x1=t,this._y1=n;break;case 2:this._point=3;default:px(this,t,n)}this._x0=this._x1,this._x1=this._x2,this._x2=t,this._y0=this._y1,this._y1=this._y2,this._y2=n}};var yx=function t(n){function e(t){return new gx(t,n)}return e.tension=function(n){return t(+n)},e}(0);function mx(t,n){this._context=t,this._k=(1-n)/6}mx.prototype={areaStart:ax,areaEnd:ax,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(t,n){switch(t=+t,n=+n,this._point){case 0:this._point=1,this._x3=t,this._y3=n;break;case 1:this._point=2,this._context.moveTo(this._x4=t,this._y4=n);break;case 2:this._point=3,this._x5=t,this._y5=n;break;default:px(this,t,n)}this._x0=this._x1,this._x1=this._x2,this._x2=t,this._y0=this._y1,this._y1=this._y2,this._y2=n}};var vx=function t(n){function e(t){return new mx(t,n)}return e.tension=function(n){return t(+n)},e}(0);function _x(t,n){this._context=t,this._k=(1-n)/6}_x.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(t,n){switch(t=+t,n=+n,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:px(this,t,n)}this._x0=this._x1,this._x1=this._x2,this._x2=t,this._y0=this._y1,this._y1=this._y2,this._y2=n}};var bx=function t(n){function e(t){return new _x(t,n)}return e.tension=function(n){return t(+n)},e}(0);function xx(t,n,e){var r=t._x1,i=t._y1,o=t._x2,a=t._y2;if(t._l01_a>sb){var u=2*t._l01_2a+3*t._l01_a*t._l12_a+t._l12_2a,s=3*t._l01_a*(t._l01_a+t._l12_a);r=(r*u-t._x0*t._l12_2a+t._x2*t._l01_2a)/s,i=(i*u-t._y0*t._l12_2a+t._y2*t._l01_2a)/s}if(t._l23_a>sb){var c=2*t._l23_2a+3*t._l23_a*t._l12_a+t._l12_2a,l=3*t._l23_a*(t._l23_a+t._l12_a);o=(o*c+t._x1*t._l23_2a-n*t._l12_2a)/l,a=(a*c+t._y1*t._l23_2a-e*t._l12_2a)/l}t._context.bezierCurveTo(r,i,o,a,t._x2,t._y2)}function wx(t,n){this._context=t,this._alpha=n}wx.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(t,n){if(t=+t,n=+n,this._point){var e=this._x2-t,r=this._y2-n;this._l23_a=Math.sqrt(this._l23_2a=Math.pow(e*e+r*r,this._alpha))}switch(this._point){case 0:this._point=1,this._line?this._context.lineTo(t,n):this._context.moveTo(t,n);break;case 1:this._point=2;break;case 2:this._point=3;default:xx(this,t,n)}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=t,this._y0=this._y1,this._y1=this._y2,this._y2=n}};var Mx=function t(n){function e(t){return n?new wx(t,n):new gx(t,0)}return e.alpha=function(n){return t(+n)},e}(.5);function kx(t,n){this._context=t,this._alpha=n}kx.prototype={areaStart:ax,areaEnd:ax,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(t,n){if(t=+t,n=+n,this._point){var e=this._x2-t,r=this._y2-n;this._l23_a=Math.sqrt(this._l23_2a=Math.pow(e*e+r*r,this._alpha))}switch(this._point){case 0:this._point=1,this._x3=t,this._y3=n;break;case 1:this._point=2,this._context.moveTo(this._x4=t,this._y4=n);break;case 2:this._point=3,this._x5=t,this._y5=n;break;default:xx(this,t,n)}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=t,this._y0=this._y1,this._y1=this._y2,this._y2=n}};var Tx=function t(n){function e(t){return n?new kx(t,n):new mx(t,0)}return e.alpha=function(n){return t(+n)},e}(.5);function Ax(t,n){this._context=t,this._alpha=n}Ax.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(t,n){if(t=+t,n=+n,this._point){var e=this._x2-t,r=this._y2-n;this._l23_a=Math.sqrt(this._l23_2a=Math.pow(e*e+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:xx(this,t,n)}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=t,this._y0=this._y1,this._y1=this._y2,this._y2=n}};var Sx=function t(n){function e(t){return n?new Ax(t,n):new _x(t,0)}return e.alpha=function(n){return t(+n)},e}(.5);function Ex(t){this._context=t}function Cx(t){return t<0?-1:1}function Nx(t,n,e){var r=t._x1-t._x0,i=n-t._x1,o=(t._y1-t._y0)/(r||i<0&&-0),a=(e-t._y1)/(i||r<0&&-0),u=(o*i+a*r)/(r+i);return(Cx(o)+Cx(a))*Math.min(Math.abs(o),Math.abs(a),.5*Math.abs(u))||0}function Px(t,n){var e=t._x1-t._x0;return e?(3*(t._y1-t._y0)/e-n)/2:n}function Dx(t,n,e){var r=t._x0,i=t._y0,o=t._x1,a=t._y1,u=(o-r)/3;t._context.bezierCurveTo(r+u,i+u*n,o-u,a-u*e,o,a)}function zx(t){this._context=t}function Lx(t){this._context=new Hx(t)}function Hx(t){this._context=t}function Rx(t){this._context=t}function Bx(t){var n,e,r=t.length-1,i=new Array(r),o=new Array(r),a=new Array(r);for(i[0]=0,o[0]=2,a[0]=t[0]+2*t[1],n=1;n=0;--n)i[n]=(a[n]-i[n+1])/o[n];for(o[r-1]=(t[r]+i[r-1])/2,n=0;n1)for(var e,r,i,o=1,a=t[n[0]],u=a.length;o=0;)e[n]=n;return e}function Ox(t,n){return t[n]}function Ux(t){const n=[];return n.key=t,n}function Yx(t){var n=t.map(Gx);return Fx(t).sort((function(t,e){return n[t]-n[e]}))}function Gx(t){for(var n,e=-1,r=0,i=t.length,o=-1/0;++eo&&(o=n,r=e);return r}function Vx(t){var n=t.map(jx);return Fx(t).sort((function(t,e){return n[t]-n[e]}))}function jx(t){for(var n,e=0,r=-1,i=t.length;++r=0&&(this._t=1-this._t,this._line=1-this._line)},point:function(t,n){switch(t=+t,n=+n,this._point){case 0:this._point=1,this._line?this._context.lineTo(t,n):this._context.moveTo(t,n);break;case 1:this._point=2;default:if(this._t<=0)this._context.lineTo(this._x,n),this._context.lineTo(t,n);else{var e=this._x*(1-this._t)+t*this._t;this._context.lineTo(e,this._y),this._context.lineTo(e,n)}}this._x=t,this._y=n}};var $x=t=>()=>t;function Xx(t,{sourceEvent:n,target:e,transform:r,dispatch:i}){Object.defineProperties(this,{type:{value:t,enumerable:!0,configurable:!0},sourceEvent:{value:n,enumerable:!0,configurable:!0},target:{value:e,enumerable:!0,configurable:!0},transform:{value:r,enumerable:!0,configurable:!0},_:{value:i}})}function Wx(t,n,e){this.k=t,this.x=n,this.y=e}Wx.prototype={constructor:Wx,scale:function(t){return 1===t?this:new Wx(this.k*t,this.x,this.y)},translate:function(t,n){return 0===t&0===n?this:new Wx(this.k,this.x+this.k*t,this.y+this.k*n)},apply:function(t){return[t[0]*this.k+this.x,t[1]*this.k+this.y]},applyX:function(t){return t*this.k+this.x},applyY:function(t){return t*this.k+this.y},invert:function(t){return[(t[0]-this.x)/this.k,(t[1]-this.y)/this.k]},invertX:function(t){return(t-this.x)/this.k},invertY:function(t){return(t-this.y)/this.k},rescaleX:function(t){return t.copy().domain(t.range().map(this.invertX,this).map(t.invert,t))},rescaleY:function(t){return t.copy().domain(t.range().map(this.invertY,this).map(t.invert,t))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var Zx=new Wx(1,0,0);function Kx(t){for(;!t.__zoom;)if(!(t=t.parentNode))return Zx;return t.__zoom}function Qx(t){t.stopImmediatePropagation()}function Jx(t){t.preventDefault(),t.stopImmediatePropagation()}function tw(t){return!(t.ctrlKey&&"wheel"!==t.type||t.button)}function nw(){var t=this;return t instanceof SVGElement?(t=t.ownerSVGElement||t).hasAttribute("viewBox")?[[(t=t.viewBox.baseVal).x,t.y],[t.x+t.width,t.y+t.height]]:[[0,0],[t.width.baseVal.value,t.height.baseVal.value]]:[[0,0],[t.clientWidth,t.clientHeight]]}function ew(){return this.__zoom||Zx}function rw(t){return-t.deltaY*(1===t.deltaMode?.05:t.deltaMode?1:.002)*(t.ctrlKey?10:1)}function iw(){return navigator.maxTouchPoints||"ontouchstart"in this}function ow(t,n,e){var r=t.invertX(n[0][0])-e[0][0],i=t.invertX(n[1][0])-e[1][0],o=t.invertY(n[0][1])-e[0][1],a=t.invertY(n[1][1])-e[1][1];return t.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))}Kx.prototype=Wx.prototype,t.Adder=y,t.Delaunay=Su,t.FormatSpecifier=Is,t.InternMap=m,t.InternSet=v,t.Node=Pd,t.Voronoi=xu,t.ZoomTransform=Wx,t.active=function(t,n){var e,r,i=t.__transition;if(i)for(r in n=null==n?null:n+"",i)if((e=i[r]).state>ki&&e.name===n)return new to([[t]],Bo,n,+r);return null},t.arc=function(){var t=db,n=pb,e=tb(0),r=null,i=gb,o=yb,a=mb,u=null;function s(){var s,c,l=+t.apply(this,arguments),f=+n.apply(this,arguments),h=i.apply(this,arguments)-lb,d=o.apply(this,arguments)-lb,p=nb(d-h),g=d>h;if(u||(u=s=Ta()),fsb)if(p>fb-sb)u.moveTo(f*rb(h),f*ab(h)),u.arc(0,0,f,h,d,!g),l>sb&&(u.moveTo(l*rb(d),l*ab(d)),u.arc(0,0,l,d,h,g));else{var y,m,v=h,_=d,b=h,x=d,w=p,M=p,k=a.apply(this,arguments)/2,T=k>sb&&(r?+r.apply(this,arguments):ub(l*l+f*f)),A=ob(nb(f-l)/2,+e.apply(this,arguments)),S=A,E=A;if(T>sb){var C=hb(T/l*ab(k)),N=hb(T/f*ab(k));(w-=2*C)>sb?(b+=C*=g?1:-1,x-=C):(w=0,b=x=(h+d)/2),(M-=2*N)>sb?(v+=N*=g?1:-1,_-=N):(M=0,v=_=(h+d)/2)}var P=f*rb(v),D=f*ab(v),z=l*rb(x),L=l*ab(x);if(A>sb){var H,R=f*rb(_),B=f*ab(_),I=l*rb(b),q=l*ab(b);if(p1?0:t<-1?cb:Math.acos(t)}((F*U+O*Y)/(ub(F*F+O*O)*ub(U*U+Y*Y)))/2),V=ub(H[0]*H[0]+H[1]*H[1]);S=ob(A,(l-V)/(G-1)),E=ob(A,(f-V)/(G+1))}}M>sb?E>sb?(y=vb(I,q,P,D,f,E,g),m=vb(R,B,z,L,f,E,g),u.moveTo(y.cx+y.x01,y.cy+y.y01),Esb&&w>sb?S>sb?(y=vb(z,L,R,B,l,-S,g),m=vb(P,D,I,q,l,-S,g),u.lineTo(y.cx+y.x01,y.cy+y.y01),S>a,c=i+2*u>>a,l=Ia(20);function f(r){var i=new Float32Array(s*c),f=new Float32Array(s*c),d=Math.pow(2,-a);r.forEach((function(r,o,a){var l=(t(r,o,a)+u)*d,f=(n(r,o,a)+u)*d,h=+e(r,o,a);if(l>=0&&l=0&&f>a),ja({width:s,height:c,data:f},{width:s,height:c,data:i},o>>a),Va({width:s,height:c,data:i},{width:s,height:c,data:f},o>>a),ja({width:s,height:c,data:f},{width:s,height:c,data:i},o>>a),Va({width:s,height:c,data:i},{width:s,height:c,data:f},o>>a),ja({width:s,height:c,data:f},{width:s,height:c,data:i},o>>a);var p=l(i);if(!Array.isArray(p)){var g=j(i);p=U(0,g,p),(p=et(0,Math.floor(g/p)*p,p)).shift()}return Ga().thresholds(p).size([s,c])(i).map(h)}function h(t){return t.value*=Math.pow(2,-2*a),t.coordinates.forEach(d),t}function d(t){t.forEach(p)}function p(t){t.forEach(g)}function g(t){t[0]=t[0]*Math.pow(2,a)-u,t[1]=t[1]*Math.pow(2,a)-u}function y(){return s=r+2*(u=3*o)>>a,c=i+2*u>>a,f}return f.x=function(n){return arguments.length?(t="function"==typeof n?n:Ia(+n),f):t},f.y=function(t){return arguments.length?(n="function"==typeof t?t:Ia(+t),f):n},f.weight=function(t){return arguments.length?(e="function"==typeof t?t:Ia(+t),f):e},f.size=function(t){if(!arguments.length)return[r,i];var n=+t[0],e=+t[1];if(!(n>=0&&e>=0))throw new Error("invalid size");return r=n,i=e,y()},f.cellSize=function(t){if(!arguments.length)return 1<=1))throw new Error("invalid cell size");return a=Math.floor(Math.log(t)/Math.LN2),y()},f.thresholds=function(t){return arguments.length?(l="function"==typeof t?t:Array.isArray(t)?Ia(Ra.call(t)):Ia(t),f):l},f.bandwidth=function(t){if(!arguments.length)return Math.sqrt(o*(o+1));if(!((t=+t)>=0))throw new Error("invalid bandwidth");return o=Math.round((Math.sqrt(4*t*t+1)-1)/2),y()},f},t.contours=Ga,t.count=c,t.create=function(t){return On(zt(t).call(document.documentElement))},t.creator=zt,t.cross=function(...t){const n="function"==typeof t[t.length-1]&&function(t){return n=>t(...n)}(t.pop()),e=(t=t.map(h)).map(l),r=t.length-1,i=new Array(r+1).fill(0),o=[];if(r<0||e.some(f))return o;for(;;){o.push(i.map(((n,e)=>t[e][n])));let a=r;for(;++i[a]===e[a];){if(0===a)return n?o.map(n):o;i[a--]=0}}},t.csv=as,t.csvFormat=Ou,t.csvFormatBody=Uu,t.csvFormatRow=Gu,t.csvFormatRows=Yu,t.csvFormatValue=Vu,t.csvParse=qu,t.csvParseRows=Fu,t.cubehelix=fr,t.cumsum=function(t,n){var e=0,r=0;return Float64Array.from(t,void 0===n?t=>e+=+t||0:i=>e+=+n(i,r++,t)||0)},t.curveBasis=function(t){return new sx(t)},t.curveBasisClosed=function(t){return new cx(t)},t.curveBasisOpen=function(t){return new lx(t)},t.curveBumpX=function(t){return new fx(t,!0)},t.curveBumpY=function(t){return new fx(t,!1)},t.curveBundle=dx,t.curveCardinal=yx,t.curveCardinalClosed=vx,t.curveCardinalOpen=bx,t.curveCatmullRom=Mx,t.curveCatmullRomClosed=Tx,t.curveCatmullRomOpen=Sx,t.curveLinear=wb,t.curveLinearClosed=function(t){return new Ex(t)},t.curveMonotoneX=function(t){return new zx(t)},t.curveMonotoneY=function(t){return new Lx(t)},t.curveNatural=function(t){return new Rx(t)},t.curveStep=function(t){return new Ix(t,.5)},t.curveStepAfter=function(t){return new Ix(t,1)},t.curveStepBefore=function(t){return new Ix(t,0)},t.descending=function(t,n){return null==t||null==n?NaN:nt?1:n>=t?0:NaN},t.deviation=p,t.difference=function(t,...n){t=new v(t);for(const e of n)for(const n of e)t.delete(n);return t},t.disjoint=function(t,n){const e=n[Symbol.iterator](),r=new v;for(const n of t){if(r.has(n))return!1;let t,i;for(;({value:t,done:i}=e.next())&&!i;){if(Object.is(n,t))return!1;r.add(t)}}return!0},t.dispatch=kt,t.drag=function(){var t,n,e,r,i=ne,o=ee,a=re,u=ie,s={},c=kt("start","drag","end"),l=0,f=0;function h(t){t.on("mousedown.drag",d).filter(u).on("touchstart.drag",y).on("touchmove.drag",m,$n).on("touchend.drag touchcancel.drag",v).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function d(a,u){if(!r&&i.call(this,a,u)){var s=_(this,o.call(this,a,u),a,u,"mouse");s&&(On(a.view).on("mousemove.drag",p,Xn).on("mouseup.drag",g,Xn),Kn(a.view),Wn(a),e=!1,t=a.clientX,n=a.clientY,s("start",a))}}function p(r){if(Zn(r),!e){var i=r.clientX-t,o=r.clientY-n;e=i*i+o*o>f}s.mouse("drag",r)}function g(t){On(t.view).on("mousemove.drag mouseup.drag",null),Qn(t.view,e),Zn(t),s.mouse("end",t)}function y(t,n){if(i.call(this,t,n)){var e,r,a=t.changedTouches,u=o.call(this,t,n),s=a.length;for(e=0;e+t,t.easePoly=so,t.easePolyIn=ao,t.easePolyInOut=so,t.easePolyOut=uo,t.easeQuad=io,t.easeQuadIn=function(t){return t*t},t.easeQuadInOut=io,t.easeQuadOut=function(t){return t*(2-t)},t.easeSin=fo,t.easeSinIn=function(t){return 1==+t?1:1-Math.cos(t*lo)},t.easeSinInOut=fo,t.easeSinOut=function(t){return Math.sin(t*lo)},t.every=function(t,n){if("function"!=typeof n)throw new TypeError("test is not a function");let e=-1;for(const r of t)if(!n(r,++e,t))return!1;return!0},t.extent=g,t.fcumsum=function(t,n){const e=new y;let r=-1;return Float64Array.from(t,void 0===n?t=>e.add(+t||0):i=>e.add(+n(i,++r,t)||0))},t.filter=function(t,n){if("function"!=typeof n)throw new TypeError("test is not a function");const e=[];let r=-1;for(const i of t)n(i,++r,t)&&e.push(i);return e},t.flatGroup=function(t,...n){return A(T(t,...n),n)},t.flatRollup=function(t,n,...e){return A(E(t,n,...e),e)},t.forceCenter=function(t,n){var e,r=1;function i(){var i,o,a=e.length,u=0,s=0;for(i=0;ic+p||ol+p||as.index){var g=c-u.x-u.vx,y=l-u.y-u.vy,m=g*g+y*y;mt.r&&(t.r=t[n].r)}function s(){if(n){var r,i,o=n.length;for(e=new Array(o),r=0;r[u(t,n,r),t])));for(a=0,i=new Array(c);a=u)){(t.data!==n||t.next)&&(0===f&&(p+=(f=ws(e))*f),0===h&&(p+=(h=ws(e))*h),p(t=(Ss*t+Es)%Cs)/Cs}();function f(){h(),c.call("tick",n),e1?(null==e?u.delete(t):u.set(t,p(e)),n):u.get(t)},find:function(n,e,r){var i,o,a,u,s,c=0,l=t.length;for(null==r?r=1/0:r*=r,c=0;c1?(c.on(t,e),n):c.on(t)}}},t.forceX=function(t){var n,e,r,i=xs(.1);function o(t){for(var i,o=0,a=n.length;o=.12&&i<.234&&r>=-.425&&r<-.214?u:i>=.166&&i<.234&&r>=-.214&&r<-.115?s:a).invert(t)},l.stream=function(e){return t&&n===e?t:(r=[a.stream(n=e),u.stream(e),s.stream(e)],i=r.length,t={point:function(t,n){for(var e=-1;++eSl(r[0],r[1])&&(r[1]=i[1]),Sl(i[0],r[1])>Sl(r[0],r[1])&&(r[0]=i[0])):o.push(r=i);for(a=-1/0,n=0,r=o[e=o.length-1];n<=e;r=i,++n)i=o[n],(u=Sl(r[1],i[0]))>a&&(a=u,Dc=i[0],Lc=r[1])}return Oc=Uc=null,Dc===1/0||zc===1/0?[[NaN,NaN],[NaN,NaN]]:[[Dc,zc],[Lc,Hc]]},t.geoCentroid=function(t){rl=il=ol=al=ul=sl=cl=ll=0,fl=new y,hl=new y,dl=new y,Ac(t,Nl);var n=+fl,e=+hl,r=+dl,i=lc(n,e,r);return i2?t[2]+90:90]):[(t=e())[0],t[1],t[2]-90]},e([0,0,90]).scale(159.155)},t.geoTransverseMercatorRaw=xd,t.gray=function(t,n){return new Xe(t,0,0,null==n?1:n)},t.greatest=function(t,e=n){let r,i=!1;if(1===e.length){let o;for(const a of t){const t=e(a);(i?n(t,o)>0:0===n(t,t))&&(r=a,o=t,i=!0)}}else for(const n of t)(i?e(n,r)>0:0===e(n,n))&&(r=n,i=!0);return r},t.greatestIndex=function(t,e=n){if(1===e.length)return Q(t,e);let r,i=-1,o=-1;for(const n of t)++o,(i<0?0===e(n,n):e(n,r)>0)&&(r=n,i=o);return i},t.group=k,t.groupSort=function(t,e,r){return(2!==e.length?D(S(t,e,r),(([t,e],[r,i])=>n(e,i)||n(t,r))):D(k(t,r),(([t,r],[i,o])=>e(r,o)||n(t,i)))).map((([t])=>t))},t.groups=T,t.hcl=tr,t.hierarchy=Ad,t.histogram=V,t.hsl=Le,t.html=fs,t.image=function(t,n){return new Promise((function(e,r){var i=new Image;for(var o in n)i[o]=n[o];i.onerror=r,i.onload=function(){e(i)},i.src=t}))},t.index=function(t,...n){return N(t,M,C,n)},t.indexes=function(t,...n){return N(t,Array.from,C,n)},t.interpolate=Lr,t.interpolateArray=function(t,n){return(Ar(n)?Tr:Sr)(t,n)},t.interpolateBasis=pr,t.interpolateBasisClosed=gr,t.interpolateBlues=P_,t.interpolateBrBG=Yv,t.interpolateBuGn=u_,t.interpolateBuPu=c_,t.interpolateCividis=function(t){return t=Math.max(0,Math.min(1,t)),"rgb("+Math.max(0,Math.min(255,Math.round(-4.54-t*(35.34-t*(2381.73-t*(6402.7-t*(7024.72-2710.57*t)))))))+", "+Math.max(0,Math.min(255,Math.round(32.49+t*(170.73+t*(52.82-t*(131.46-t*(176.58-67.37*t)))))))+", "+Math.max(0,Math.min(255,Math.round(81.24+t*(442.36-t*(2482.43-t*(6167.24-t*(6614.94-2475.67*t)))))))+")"},t.interpolateCool=G_,t.interpolateCubehelix=Qr,t.interpolateCubehelixDefault=U_,t.interpolateCubehelixLong=Jr,t.interpolateDate=Er,t.interpolateDiscrete=function(t){var n=t.length;return function(e){return t[Math.max(0,Math.min(n-1,Math.floor(e*n)))]}},t.interpolateGnBu=f_,t.interpolateGreens=z_,t.interpolateGreys=H_,t.interpolateHcl=Wr,t.interpolateHclLong=Zr,t.interpolateHsl=jr,t.interpolateHslLong=$r,t.interpolateHue=function(t,n){var e=vr(+t,+n);return function(t){var n=e(t);return n-360*Math.floor(n/360)}},t.interpolateInferno=Q_,t.interpolateLab=function(t,n){var e=br((t=$e(t)).l,(n=$e(n)).l),r=br(t.a,n.a),i=br(t.b,n.b),o=br(t.opacity,n.opacity);return function(n){return t.l=e(n),t.a=r(n),t.b=i(n),t.opacity=o(n),t+""}},t.interpolateMagma=K_,t.interpolateNumber=Cr,t.interpolateNumberArray=Tr,t.interpolateObject=Nr,t.interpolateOrRd=d_,t.interpolateOranges=O_,t.interpolatePRGn=Vv,t.interpolatePiYG=$v,t.interpolatePlasma=J_,t.interpolatePuBu=m_,t.interpolatePuBuGn=g_,t.interpolatePuOr=Wv,t.interpolatePuRd=__,t.interpolatePurples=B_,t.interpolateRainbow=function(t){(t<0||t>1)&&(t-=Math.floor(t));var n=Math.abs(t-.5);return V_.h=360*t-100,V_.s=1.5-1.5*n,V_.l=.8-.9*n,V_+""},t.interpolateRdBu=Kv,t.interpolateRdGy=Jv,t.interpolateRdPu=x_,t.interpolateRdYlBu=n_,t.interpolateRdYlGn=r_,t.interpolateReds=q_,t.interpolateRgb=xr,t.interpolateRgbBasis=Mr,t.interpolateRgbBasisClosed=kr,t.interpolateRound=Hr,t.interpolateSinebow=function(t){var n;return t=(.5-t)*Math.PI,j_.r=255*(n=Math.sin(t))*n,j_.g=255*(n=Math.sin(t+$_))*n,j_.b=255*(n=Math.sin(t+X_))*n,j_+""},t.interpolateSpectral=o_,t.interpolateString=zr,t.interpolateTransformCss=Or,t.interpolateTransformSvg=Ur,t.interpolateTurbo=function(t){return t=Math.max(0,Math.min(1,t)),"rgb("+Math.max(0,Math.min(255,Math.round(34.61+t*(1172.33-t*(10793.56-t*(33300.12-t*(38394.49-14825.05*t)))))))+", "+Math.max(0,Math.min(255,Math.round(23.31+t*(557.33+t*(1225.33-t*(3574.96-t*(1073.77+707.56*t)))))))+", "+Math.max(0,Math.min(255,Math.round(27.2+t*(3211.1-t*(15327.97-t*(27814-t*(22569.18-6838.66*t)))))))+")"},t.interpolateViridis=Z_,t.interpolateWarm=Y_,t.interpolateYlGn=T_,t.interpolateYlGnBu=M_,t.interpolateYlOrBr=S_,t.interpolateYlOrRd=C_,t.interpolateZoom=Gr,t.interrupt=Li,t.intersection=function(t,...n){t=new v(t),n=n.map(st);t:for(const e of t)for(const r of n)if(!r.has(e)){t.delete(e);continue t}return t},t.interval=function(t,n,e){var r=new pi,i=n;return null==n?(r.restart(t,n,e),r):(r._restart=r.restart,r.restart=function(t,n,e){n=+n,e=null==e?hi():+e,r._restart((function o(a){a+=i,r._restart(o,i+=n,e),t(a)}),n,e)},r.restart(t,n,e),r)},t.isoFormat=_v,t.isoParse=xv,t.json=function(t,n){return fetch(t,n).then(ss)},t.lab=$e,t.lch=function(t,n,e,r){return 1===arguments.length?Je(t):new nr(e,n,t,null==r?1:r)},t.least=function(t,e=n){let r,i=!1;if(1===e.length){let o;for(const a of t){const t=e(a);(i?n(t,o)<0:0===n(t,t))&&(r=a,o=t,i=!0)}}else for(const n of t)(i?e(n,r)<0:0===e(n,n))&&(r=n,i=!0);return r},t.leastIndex=rt,t.line=Tb,t.lineRadial=zb,t.linkHorizontal=function(){return Ib(qb)},t.linkRadial=function(){var t=Ib(Ob);return t.angle=t.x,delete t.x,t.radius=t.y,delete t.y,t},t.linkVertical=function(){return Ib(Fb)},t.local=Yn,t.map=function(t,n){if("function"!=typeof t[Symbol.iterator])throw new TypeError("values is not iterable");if("function"!=typeof n)throw new TypeError("mapper is not a function");return Array.from(t,((e,r)=>n(e,r,t)))},t.matcher=qt,t.max=j,t.maxIndex=Q,t.mean=function(t,n){let e=0,r=0;if(void 0===n)for(let n of t)null!=n&&(n=+n)>=n&&(++e,r+=n);else{let i=-1;for(let o of t)null!=(o=n(o,++i,t))&&(o=+o)>=o&&(++e,r+=o)}if(e)return r/e},t.median=function(t,n){return Z(t,.5,n)},t.merge=J,t.min=$,t.minIndex=tt,t.mode=function(t,n){const e=new m;if(void 0===n)for(let n of t)null!=n&&n>=n&&e.set(n,(e.get(n)||0)+1);else{let r=-1;for(let i of t)null!=(i=n(i,++r,t))&&i>=i&&e.set(i,(e.get(i)||0)+1)}let r,i=0;for(const[t,n]of e)n>i&&(i=n,r=t);return r},t.namespace=Nt,t.namespaces=Ct,t.nice=Y,t.now=hi,t.pack=function(){var t=null,n=1,e=1,r=$d;function i(i){return i.x=n/2,i.y=e/2,t?i.eachBefore(Zd(t)).eachAfter(Kd(r,.5)).eachBefore(Qd(1)):i.eachBefore(Zd(Wd)).eachAfter(Kd($d,1)).eachAfter(Kd(r,i.r/Math.min(n,e))).eachBefore(Qd(Math.min(n,e)/(2*i.r))),i}return i.radius=function(n){return arguments.length?(t=Vd(n),i):t},i.size=function(t){return arguments.length?(n=+t[0],e=+t[1],i):[n,e]},i.padding=function(t){return arguments.length?(r="function"==typeof t?t:Xd(+t),i):r},i},t.packEnclose=Dd,t.packSiblings=function(t){return Gd(t),t},t.pairs=function(t,n=nt){const e=[];let r,i=!1;for(const o of t)i&&e.push(n(r,o)),r=o,i=!0;return e},t.partition=function(){var t=1,n=1,e=0,r=!1;function i(i){var o=i.height+1;return i.x0=i.y0=e,i.x1=t,i.y1=n/o,i.eachBefore(function(t,n){return function(r){r.children&&tp(r,r.x0,t*(r.depth+1)/n,r.x1,t*(r.depth+2)/n);var i=r.x0,o=r.y0,a=r.x1-e,u=r.y1-e;a0&&(d+=f);for(null!=n?p.sort((function(t,e){return n(g[t],g[e])})):null!=e&&p.sort((function(t,n){return e(a[t],a[n])})),u=0,c=d?(m-h*_)/d:0;u0?f*c:0)+_,g[s]={data:a[s],index:u,value:f,startAngle:y,endAngle:l,padAngle:v};return g}return a.value=function(n){return arguments.length?(t="function"==typeof n?n:tb(+n),a):t},a.sortValues=function(t){return arguments.length?(n=t,e=null,a):n},a.sort=function(t){return arguments.length?(e=t,n=null,a):e},a.startAngle=function(t){return arguments.length?(r="function"==typeof t?t:tb(+t),a):r},a.endAngle=function(t){return arguments.length?(i="function"==typeof t?t:tb(+t),a):i},a.padAngle=function(t){return arguments.length?(o="function"==typeof t?t:tb(+t),a):o},a},t.piecewise=ti,t.pointRadial=Hb,t.pointer=jn,t.pointers=function(t,n){return t.target&&(t=Vn(t),void 0===n&&(n=t.currentTarget),t=t.touches||[t]),Array.from(t,(t=>jn(t,n)))},t.polygonArea=function(t){for(var n,e=-1,r=t.length,i=t[r-1],o=0;++eu!=c>u&&a<(s-e)*(u-r)/(c-r)+e&&(l=!l),s=e,c=r;return l},t.polygonHull=function(t){if((e=t.length)<3)return null;var n,e,r=new Array(e),i=new Array(e);for(n=0;n=0;--n)c.push(t[r[o[n]][2]]);for(n=+u;n(n=1664525*n+1013904223|0,Fp*(n>>>0))},t.randomLogNormal=Ap,t.randomLogistic=Ip,t.randomNormal=Tp,t.randomPareto=Np,t.randomPoisson=qp,t.randomUniform=Mp,t.randomWeibull=Rp,t.range=et,t.rank=function(t,e=n){if("function"!=typeof t[Symbol.iterator])throw new TypeError("values is not iterable");let r=Array.from(t);const i=new Float64Array(r.length);2!==e.length&&(r=r.map(e),e=n);const o=(t,n)=>e(r[t],r[n]);let a,u;return Uint32Array.from(r,((t,n)=>n)).sort(e===n?(t,n)=>L(r[t],r[n]):z(o)).forEach(((t,n)=>{const e=o(t,void 0===a?t:a);e>=0?((void 0===a||e>0)&&(a=t,u=n),i[t]=u):i[t]=NaN})),i},t.reduce=function(t,n,e){if("function"!=typeof n)throw new TypeError("reducer is not a function");const r=t[Symbol.iterator]();let i,o,a=-1;if(arguments.length<3){if(({done:i,value:e}=r.next()),i)return;++a}for(;({done:i,value:o}=r.next()),!i;)e=n(e,o,++a,t);return e},t.reverse=function(t){if("function"!=typeof t[Symbol.iterator])throw new TypeError("values is not iterable");return Array.from(t).reverse()},t.rgb=Se,t.ribbon=function(){return Ha()},t.ribbonArrow=function(){return Ha(La)},t.rollup=S,t.rollups=E,t.scaleBand=Vp,t.scaleDiverging=function t(){var n=rg(Ev()(Wp));return n.copy=function(){return Av(n,t())},Up.apply(n,arguments)},t.scaleDivergingLog=function t(){var n=fg(Ev()).domain([.1,1,10]);return n.copy=function(){return Av(n,t()).base(n.base())},Up.apply(n,arguments)},t.scaleDivergingPow=Cv,t.scaleDivergingSqrt=function(){return Cv.apply(null,arguments).exponent(.5)},t.scaleDivergingSymlog=function t(){var n=pg(Ev());return n.copy=function(){return Av(n,t()).constant(n.constant())},Up.apply(n,arguments)},t.scaleIdentity=function t(n){var e;function r(t){return null==t||isNaN(t=+t)?e:t}return r.invert=r,r.domain=r.range=function(t){return arguments.length?(n=Array.from(t,$p),r):n.slice()},r.unknown=function(t){return arguments.length?(e=t,r):e},r.copy=function(){return t(n).unknown(e)},n=arguments.length?Array.from(n,$p):[0,1],rg(r)},t.scaleImplicit=Yp,t.scaleLinear=function t(){var n=ng();return n.copy=function(){return Jp(n,t())},Op.apply(n,arguments),rg(n)},t.scaleLog=function t(){const n=fg(tg()).domain([1,10]);return n.copy=()=>Jp(n,t()).base(n.base()),Op.apply(n,arguments),n},t.scaleOrdinal=Gp,t.scalePoint=function(){return jp(Vp.apply(null,arguments).paddingInner(1))},t.scalePow=_g,t.scaleQuantile=function t(){var e,r=[],i=[],o=[];function a(){var t=0,n=Math.max(1,i.length);for(o=new Array(n-1);++t0?o[n-1]:r[0],n=i?[o[i-1],r]:[o[n-1],o[n]]},u.unknown=function(t){return arguments.length?(n=t,u):u},u.thresholds=function(){return o.slice()},u.copy=function(){return t().domain([e,r]).range(a).unknown(n)},Op.apply(rg(u),arguments)},t.scaleRadial=function t(){var n,e=ng(),r=[0,1],i=!1;function o(t){var r=function(t){return Math.sign(t)*Math.sqrt(Math.abs(t))}(e(t));return isNaN(r)?n:i?Math.round(r):r}return o.invert=function(t){return e.invert(bg(t))},o.domain=function(t){return arguments.length?(e.domain(t),o):e.domain()},o.range=function(t){return arguments.length?(e.range((r=Array.from(t,$p)).map(bg)),o):r.slice()},o.rangeRound=function(t){return o.range(t).round(!0)},o.round=function(t){return arguments.length?(i=!!t,o):i},o.clamp=function(t){return arguments.length?(e.clamp(t),o):e.clamp()},o.unknown=function(t){return arguments.length?(n=t,o):n},o.copy=function(){return t(e.domain(),r).round(i).clamp(e.clamp()).unknown(n)},Op.apply(o,arguments),rg(o)},t.scaleSequential=function t(){var n=rg(Tv()(Wp));return n.copy=function(){return Av(n,t())},Up.apply(n,arguments)},t.scaleSequentialLog=function t(){var n=fg(Tv()).domain([1,10]);return n.copy=function(){return Av(n,t()).base(n.base())},Up.apply(n,arguments)},t.scaleSequentialPow=Sv,t.scaleSequentialQuantile=function t(){var e=[],r=Wp;function i(t){if(null!=t&&!isNaN(t=+t))return r((s(e,t,1)-1)/(e.length-1))}return i.domain=function(t){if(!arguments.length)return e.slice();e=[];for(let n of t)null==n||isNaN(n=+n)||e.push(n);return e.sort(n),i},i.interpolator=function(t){return arguments.length?(r=t,i):r},i.range=function(){return e.map(((t,n)=>r(n/(e.length-1))))},i.quantiles=function(t){return Array.from({length:t+1},((n,r)=>Z(e,r/t)))},i.copy=function(){return t(r).domain(e)},Up.apply(i,arguments)},t.scaleSequentialSqrt=function(){return Sv.apply(null,arguments).exponent(.5)},t.scaleSequentialSymlog=function t(){var n=pg(Tv());return n.copy=function(){return Av(n,t()).constant(n.constant())},Up.apply(n,arguments)},t.scaleSqrt=function(){return _g.apply(null,arguments).exponent(.5)},t.scaleSymlog=function t(){var n=pg(tg());return n.copy=function(){return Jp(n,t()).constant(n.constant())},Op.apply(n,arguments)},t.scaleThreshold=function t(){var n,e=[.5],r=[0,1],i=1;function o(t){return null!=t&&t<=t?r[s(e,t,0,i)]:n}return o.domain=function(t){return arguments.length?(e=Array.from(t),i=Math.min(e.length,r.length-1),o):e.slice()},o.range=function(t){return arguments.length?(r=Array.from(t),i=Math.min(e.length,r.length-1),o):r.slice()},o.invertExtent=function(t){var n=r.indexOf(t);return[e[n-1],e[n]]},o.unknown=function(t){return arguments.length?(n=t,o):n},o.copy=function(){return t().domain(e).range(r).unknown(n)},Op.apply(o,arguments)},t.scaleTime=function(){return Op.apply(kv(jy,$y,fy,sy,$g,Gg,Og,Ig,Hg,t.timeFormat).domain([new Date(2e3,0,1),new Date(2e3,0,2)]),arguments)},t.scaleUtc=function(){return Op.apply(kv(Gy,Vy,Oy,Iy,My,by,my,py,Hg,t.utcFormat).domain([Date.UTC(2e3,0,1),Date.UTC(2e3,0,2)]),arguments)},t.scan=function(t,n){const e=rt(t,n);return e<0?void 0:e},t.schemeAccent=Dv,t.schemeBlues=N_,t.schemeBrBG=Uv,t.schemeBuGn=a_,t.schemeBuPu=s_,t.schemeCategory10=Pv,t.schemeDark2=zv,t.schemeGnBu=l_,t.schemeGreens=D_,t.schemeGreys=L_,t.schemeOrRd=h_,t.schemeOranges=F_,t.schemePRGn=Gv,t.schemePaired=Lv,t.schemePastel1=Hv,t.schemePastel2=Rv,t.schemePiYG=jv,t.schemePuBu=y_,t.schemePuBuGn=p_,t.schemePuOr=Xv,t.schemePuRd=v_,t.schemePurples=R_,t.schemeRdBu=Zv,t.schemeRdGy=Qv,t.schemeRdPu=b_,t.schemeRdYlBu=t_,t.schemeRdYlGn=e_,t.schemeReds=I_,t.schemeSet1=Bv,t.schemeSet2=Iv,t.schemeSet3=qv,t.schemeSpectral=i_,t.schemeTableau10=Fv,t.schemeYlGn=k_,t.schemeYlGnBu=w_,t.schemeYlOrBr=A_,t.schemeYlOrRd=E_,t.select=On,t.selectAll=function(t){return"string"==typeof t?new qn([document.querySelectorAll(t)],[document.documentElement]):new qn([Rt(t)],In)},t.selection=Fn,t.selector=Ht,t.selectorAll=It,t.shuffle=it,t.shuffler=ot,t.some=function(t,n){if("function"!=typeof n)throw new TypeError("test is not a function");let e=-1;for(const r of t)if(n(r,++e,t))return!0;return!1},t.sort=D,t.stack=function(){var t=tb([]),n=Fx,e=qx,r=Ox;function i(i){var o,a,u=Array.from(t.apply(this,arguments),Ux),s=u.length,c=-1;for(const t of i)for(o=0,++c;o0)for(var e,r,i,o,a,u,s=0,c=t[n[0]].length;s0?(r[0]=o,r[1]=o+=i):i<0?(r[1]=a,r[0]=a+=i):(r[0]=0,r[1]=i)},t.stackOffsetExpand=function(t,n){if((r=t.length)>0){for(var e,r,i,o=0,a=t[0].length;o0){for(var e,r=0,i=t[n[0]],o=i.length;r0&&(r=(e=t[n[0]]).length)>0){for(var e,r,i,o=0,a=1;afunction(t){let n=(t=`${t}`).length;return up(t,n-1)&&!up(t,n-2)&&(t=t.slice(0,-1)),"/"===t[0]?t:`/${t}`}(t(n,e,r)))),e=n.map(ap),i=new Set(n).add("");for(const t of e)i.has(t)||(i.add(t),n.push(t),e.push(ap(t)),h.push(rp));d=(t,e)=>n[e],p=(t,n)=>e[n]}for(a=0,i=h.length;a=0&&(c=h[t]).data===rp;--t)c.data=null}if(u.parent=np,u.eachBefore((function(t){t.depth=t.parent.depth+1,--i})).eachBefore(Nd),u.parent=null,i>0)throw new Error("cycle");return u}return r.id=function(t){return arguments.length?(n=Vd(t),r):n},r.parentId=function(t){return arguments.length?(e=Vd(t),r):e},r.path=function(n){return arguments.length?(t=Vd(n),r):t},r},t.style=cn,t.subset=function(t,n){return ct(n,t)},t.sum=function(t,n){let e=0;if(void 0===n)for(let n of t)(n=+n)&&(e+=n);else{let r=-1;for(let i of t)(i=+n(i,++r,t))&&(e+=i)}return e},t.superset=ct,t.svg=hs,t.symbol=function(t,n){var e=null;function r(){var r;if(e||(e=r=Ta()),t.apply(this,arguments).draw(e,+n.apply(this,arguments)),r)return e=null,r+""||null}return t="function"==typeof t?t:tb(t||Ub),n="function"==typeof n?n:tb(void 0===n?64:+n),r.type=function(n){return arguments.length?(t="function"==typeof n?n:tb(n),r):t},r.size=function(t){return arguments.length?(n="function"==typeof t?t:tb(+t),r):n},r.context=function(t){return arguments.length?(e=null==t?null:t,r):e},r},t.symbolCircle=Ub,t.symbolCross=Yb,t.symbolDiamond=jb,t.symbolSquare=Kb,t.symbolStar=Zb,t.symbolTriangle=Jb,t.symbolWye=ix,t.symbols=ox,t.text=is,t.thresholdFreedmanDiaconis=function(t,n,e){return Math.ceil((e-n)/(2*(Z(t,.75)-Z(t,.25))*Math.pow(c(t),-1/3)))},t.thresholdScott=function(t,n,e){return Math.ceil((e-n)/(3.5*p(t)*Math.pow(c(t),-1/3)))},t.thresholdSturges=G,t.tickFormat=eg,t.tickIncrement=O,t.tickStep=U,t.ticks=F,t.timeDay=Gg,t.timeDays=Vg,t.timeFormatDefaultLocale=yv,t.timeFormatLocale=Ky,t.timeFriday=Qg,t.timeFridays=oy,t.timeHour=Og,t.timeHours=Ug,t.timeInterval=Mg,t.timeMillisecond=Tg,t.timeMilliseconds=Ag,t.timeMinute=Ig,t.timeMinutes=qg,t.timeMonday=Xg,t.timeMondays=ny,t.timeMonth=sy,t.timeMonths=cy,t.timeSaturday=Jg,t.timeSaturdays=ay,t.timeSecond=Hg,t.timeSeconds=Rg,t.timeSunday=$g,t.timeSundays=ty,t.timeThursday=Kg,t.timeThursdays=iy,t.timeTickInterval=$y,t.timeTicks=jy,t.timeTuesday=Wg,t.timeTuesdays=ey,t.timeWednesday=Zg,t.timeWednesdays=ry,t.timeWeek=$g,t.timeWeeks=ty,t.timeYear=fy,t.timeYears=hy,t.timeout=bi,t.timer=gi,t.timerFlush=yi,t.transition=no,t.transpose=at,t.tree=function(){var t=sp,n=1,e=1,r=null;function i(i){var s=function(t){for(var n,e,r,i,o,a=new dp(t,0),u=[a];n=u.pop();)if(r=n._.children)for(n.children=new Array(o=r.length),i=o-1;i>=0;--i)u.push(e=n.children[i]=new dp(r[i],i)),e.parent=n;return(a.parent=new dp(null,0)).children=[a],a}(i);if(s.eachAfter(o),s.parent.m=-s.z,s.eachBefore(a),r)i.eachBefore(u);else{var c=i,l=i,f=i;i.eachBefore((function(t){t.xl.x&&(l=t),t.depth>f.depth&&(f=t)}));var h=c===l?1:t(c,l)/2,d=h-c.x,p=n/(l.x+h+d),g=e/(f.depth||1);i.eachBefore((function(t){t.x=(t.x+d)*p,t.y=t.depth*g}))}return i}function o(n){var e=n.children,r=n.parent.children,i=n.i?r[n.i-1]:null;if(e){!function(t){for(var n,e=0,r=0,i=t.children,o=i.length;--o>=0;)(n=i[o]).z+=e,n.m+=e,e+=n.s+(r+=n.c)}(n);var o=(e[0].z+e[e.length-1].z)/2;i?(n.z=i.z+t(n._,i._),n.m=n.z-o):n.z=o}else i&&(n.z=i.z+t(n._,i._));n.parent.A=function(n,e,r){if(e){for(var i,o=n,a=n,u=e,s=o.parent.children[0],c=o.m,l=a.m,f=u.m,h=s.m;u=lp(u),o=cp(o),u&&o;)s=cp(s),(a=lp(a)).a=n,(i=u.z+f-o.z-c+t(u._,o._))>0&&(fp(hp(u,n,r),n,i),c+=i,l+=i),f+=u.m,c+=o.m,h+=s.m,l+=a.m;u&&!lp(a)&&(a.t=u,a.m+=f-l),o&&!cp(s)&&(s.t=o,s.m+=c-h,r=n)}return r}(n,i,n.parent.A||r[0])}function a(t){t._.x=t.z+t.parent.m,t.m+=t.parent.m}function u(t){t.x*=n,t.y=t.depth*e}return i.separation=function(n){return arguments.length?(t=n,i):t},i.size=function(t){return arguments.length?(r=!1,n=+t[0],e=+t[1],i):r?null:[n,e]},i.nodeSize=function(t){return arguments.length?(r=!0,n=+t[0],e=+t[1],i):r?[n,e]:null},i},t.treemap=function(){var t=mp,n=!1,e=1,r=1,i=[0],o=$d,a=$d,u=$d,s=$d,c=$d;function l(t){return t.x0=t.y0=0,t.x1=e,t.y1=r,t.eachBefore(f),i=[0],n&&t.eachBefore(Jd),t}function f(n){var e=i[n.depth],r=n.x0+e,l=n.y0+e,f=n.x1-e,h=n.y1-e;f=e-1){var l=u[n];return l.x0=i,l.y0=o,l.x1=a,void(l.y1=s)}for(var f=c[n],h=r/2+f,d=n+1,p=e-1;d>>1;c[g]s-o){var v=r?(i*m+a*y)/r:a;t(n,d,y,i,o,v,s),t(d,e,m,v,o,a,s)}else{var _=r?(o*m+s*y)/r:s;t(n,d,y,i,o,a,_),t(d,e,m,i,_,a,s)}}(0,s,t.value,n,e,r,i)},t.treemapDice=tp,t.treemapResquarify=vp,t.treemapSlice=pp,t.treemapSliceDice=function(t,n,e,r,i){(1&t.depth?pp:tp)(t,n,e,r,i)},t.treemapSquarify=mp,t.tsv=us,t.tsvFormat=Wu,t.tsvFormatBody=Zu,t.tsvFormatRow=Qu,t.tsvFormatRows=Ku,t.tsvFormatValue=Ju,t.tsvParse=$u,t.tsvParseRows=Xu,t.union=function(...t){const n=new v;for(const e of t)for(const t of e)n.add(t);return n},t.utcDay=by,t.utcDays=xy,t.utcFriday=Ey,t.utcFridays=Hy,t.utcHour=my,t.utcHours=vy,t.utcMillisecond=Tg,t.utcMilliseconds=Ag,t.utcMinute=py,t.utcMinutes=gy,t.utcMonday=ky,t.utcMondays=Py,t.utcMonth=Iy,t.utcMonths=qy,t.utcSaturday=Cy,t.utcSaturdays=Ry,t.utcSecond=Hg,t.utcSeconds=Rg,t.utcSunday=My,t.utcSundays=Ny,t.utcThursday=Sy,t.utcThursdays=Ly,t.utcTickInterval=Vy,t.utcTicks=Gy,t.utcTuesday=Ty,t.utcTuesdays=Dy,t.utcWednesday=Ay,t.utcWednesdays=zy,t.utcWeek=My,t.utcWeeks=Ny,t.utcYear=Oy,t.utcYears=Uy,t.variance=d,t.version="7.2.1",t.window=on,t.xml=ls,t.zip=function(){return at(arguments)},t.zoom=function(){var t,n,e,r=tw,i=nw,o=ow,a=rw,u=iw,s=[0,1/0],c=[[-1/0,-1/0],[1/0,1/0]],l=250,f=Gr,h=kt("start","zoom","end"),d=500,p=150,g=0,y=10;function m(t){t.property("__zoom",ew).on("wheel.zoom",k,{passive:!1}).on("mousedown.zoom",T).on("dblclick.zoom",A).filter(u).on("touchstart.zoom",S).on("touchmove.zoom",E).on("touchend.zoom touchcancel.zoom",C).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function v(t,n){return(n=Math.max(s[0],Math.min(s[1],n)))===t.k?t:new Wx(n,t.x,t.y)}function _(t,n,e){var r=n[0]-e[0]*t.k,i=n[1]-e[1]*t.k;return r===t.x&&i===t.y?t:new Wx(t.k,r,i)}function b(t){return[(+t[0][0]+ +t[1][0])/2,(+t[0][1]+ +t[1][1])/2]}function x(t,n,e,r){t.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 t=this,o=arguments,a=w(t,o).event(r),u=i.apply(t,o),s=null==e?b(u):"function"==typeof e?e.apply(t,o):e,c=Math.max(u[1][0]-u[0][0],u[1][1]-u[0][1]),l=t.__zoom,h="function"==typeof n?n.apply(t,o):n,d=f(l.invert(s).concat(c/l.k),h.invert(s).concat(c/h.k));return function(t){if(1===t)t=h;else{var n=d(t),e=c/n[2];t=new Wx(e,s[0]-n[0]*e,s[1]-n[1]*e)}a.zoom(null,t)}}))}function w(t,n,e){return!e&&t.__zooming||new M(t,n)}function M(t,n){this.that=t,this.args=n,this.active=0,this.sourceEvent=null,this.extent=i.apply(t,n),this.taps=0}function k(t,...n){if(r.apply(this,arguments)){var e=w(this,n).event(t),i=this.__zoom,u=Math.max(s[0],Math.min(s[1],i.k*Math.pow(2,a.apply(this,arguments)))),l=jn(t);if(e.wheel)e.mouse[0][0]===l[0]&&e.mouse[0][1]===l[1]||(e.mouse[1]=i.invert(e.mouse[0]=l)),clearTimeout(e.wheel);else{if(i.k===u)return;e.mouse=[l,i.invert(l)],Li(this),e.start()}Jx(t),e.wheel=setTimeout((function(){e.wheel=null,e.end()}),p),e.zoom("mouse",o(_(v(i,u),e.mouse[0],e.mouse[1]),e.extent,c))}}function T(t,...n){if(!e&&r.apply(this,arguments)){var i=t.currentTarget,a=w(this,n,!0).event(t),u=On(t.view).on("mousemove.zoom",(function(t){if(Jx(t),!a.moved){var n=t.clientX-l,e=t.clientY-f;a.moved=n*n+e*e>g}a.event(t).zoom("mouse",o(_(a.that.__zoom,a.mouse[0]=jn(t,i),a.mouse[1]),a.extent,c))}),!0).on("mouseup.zoom",(function(t){u.on("mousemove.zoom mouseup.zoom",null),Qn(t.view,a.moved),Jx(t),a.event(t).end()}),!0),s=jn(t,i),l=t.clientX,f=t.clientY;Kn(t.view),Qx(t),a.mouse=[s,this.__zoom.invert(s)],Li(this),a.start()}}function A(t,...n){if(r.apply(this,arguments)){var e=this.__zoom,a=jn(t.changedTouches?t.changedTouches[0]:t,this),u=e.invert(a),s=e.k*(t.shiftKey?.5:2),f=o(_(v(e,s),a,u),i.apply(this,n),c);Jx(t),l>0?On(this).transition().duration(l).call(x,f,a,t):On(this).call(m.transform,f,a,t)}}function S(e,...i){if(r.apply(this,arguments)){var o,a,u,s,c=e.touches,l=c.length,f=w(this,i,e.changedTouches.length===l).event(e);for(Qx(e),a=0;a{"use strict";var t;!function(t){t.AttentionMatrix="attention_matrix",t.SrcTokenHeatmap="query_token_heatmap",t.DestTokenHeatmap="key_token_heatmap",t.DimensionHeatmap="dimension_heatmap",t.TokenDimHeatmap="token_dim_heatmap",t.LineGrid="line_grid",t.TokenLoss="token_loss"}(t||(t={}));class n{constructor(t){this.chart_types=t.chart_types,this.src_tokens=t.src_tokens,this.tgt_tokens=t.tgt_tokens,this.dimensions=[];for(let n in t.dimensions)this.dimensions.push({name:t.dimensions[n].name});this.attention=[];for(let n in t.attention){let e=i(t.attention[n].values,t.attention[n].shape);this.attention.push({values:e,info:t.attention[n].info})}}}function r(t,n){if(1===n.length)return t;let e=[],i=n[0];n=n.slice(1);let o=t.length/i;for(let a=0;a2)throw Error("Invalid Definition: "+t);return e.length>1&&(n.classes=e.slice(1)),n}const l={h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0};let f=function(){function t(t,n){for(let e in n){let r=n[e];null!=r?t.style.setProperty(e,r):t.style.removeProperty(e)}}function n(t,n){for(let e in n){let r=e.split("|");for(let i of r)t.addEventListener(i,n[e],!1)}}function e(t,n){for(let e in n)t[e]=n[e]}let r;function i(t,n){null!=n.id&&(t.id=n.id);for(let e of n.classes)t.classList.add(e)}function a(t,n){if(null!=n.id&&(t.id=n.id),n.classes.length>0){let e=n.classes.join(" ");t.setAttribute("class",e)}}return function(){let t=o.document.createElementNS("http://www.w3.org/2000/svg","g");r=t.classList?i:a}(),function i(...a){let f,h=function(t){let n={def:null,text:null,attrs:null,func:null,parent:null};if(0==t.length)n.def=c("div");else if("string"==typeof t[0]){let e=t[0];if(function(t){if(null!=l[t])return!0;for(let n of t)if(n.toLowerCase()!==n||n.toUpperCase()===n)return!1;return!0}(e)&&t.length>1&&"string"==typeof t[1]){const n=t[1];n.length>1&&("."===n[0]||"#"===n[0])&&(e+=n,t=t.slice(1))}n.def=c(e),t=t.slice(1)}for(let e of t)switch(typeof e){case"function":n.func=e;break;case"object":e instanceof HTMLElement||e instanceof SVGElement?n.parent=e:n.attrs=e;break;case"string":n.text=e}return n}(a),d=h.parent;if(null!=this&&null!=this._elem){if(null!=d)throw Error("Cannot set a parent within a context");d=this._elem}if(null==h.def)f=d;else{let i=h.def.tag,a=s[u[i]];f=null!=a?o.document.createElementNS(a,i):o.document.createElement(i),null!=h.def&&r(f,h.def),null!=h.attrs&&function(r,i){for(let o in i){let a=i[o];switch(o){case"style":t(r,a);break;case"on":n(r,a);break;case"data":e(r,a);break;default:null!=a?r.setAttribute(o,a):r.removeAttribute(o)}}}(f,h.attrs),null!=d&&d.appendChild(f)}if(null!=h.func){let t={_elem:f};h.func(i.bind(t))}else null!=h.text&&(f.textContent=h.text);return f}}();class h{}class d extends h{constructor(t){super(),this.token=t}addClickHandler(t,n,e){this.handler=e,this.type=t,this.idx=n}render(t,n){let e={"font-size":t/2+"px"};return n&&(e["writing-mode"]="tb"),f("text",this.token,{style:e})}}function p(t,n){let e=[];for(let r=0;r{this.handler(t,n,e)},this.srcTokens=t,this.dstTokens=n,this.attentions=p(t.length,n.length),this.srcTokenElems=[];for(let n=0;n{t=n("g",".grid",{transform:`translate(${this.leftLabelsMargin}, ${this.topLabelsMargin})`}),this.srcLabels=[],n("g",".src_labels",{transform:`translate(${this.leftLabelsMargin-this.labelCellGap}, ${this.topLabelsMargin+this.cellSize/2})`},(t=>{for(let n=0;n{for(let n=0;n{t.preventDefault(),t.stopPropagation(),this.handler(this.type,this.idx,t.shiftKey)},this.token=t,this.selected=!0,this.plotColors=n}render(){return this.elem=f("div",".token",this.token),this.elem.addEventListener("click",this.onClick),this.elem}addClickHandler(t,n,e){this.handler=e,this.type=t,this.idx=n}setAttn(n){this.selected?(this.elem.style.setProperty("background",this.plotColors.getInterpolatedColor(.8*n,"src"==this.type?t.SrcTokenHeatmap:t.DestTokenHeatmap)),this.elem.style.setProperty("border-left",`3px solid ${_(this.plotColors.getInterpolatedColor(1-.8*n,"src"==this.type?t.SrcTokenHeatmap:t.DestTokenHeatmap),.5)}`)):(this.elem.style.setProperty("background",this.plotColors.getInterpolatedSecondaryColor(.8*n)),this.elem.style.setProperty("border-left",`3px solid ${_(this.plotColors.getInterpolatedSecondaryColor(1-.8*n),.5)}`)),this.elem.style.setProperty("color",this.plotColors.getFilledTextColor()),this.elem.title=n.toExponential()}setSelection(t){this.selected=t}}class M{constructor(t,n,e){this.tokens=t,this.title=n,this.plotColors=e,this.tokenViews=[];for(let t=0;t{t("div.title",this.title)}));for(let n=0;n{t.preventDefault(),t.stopPropagation(),this.handler(this.type,this.idx,t.shiftKey)},this.value=t,this.selected=!0,this.plotColors=n}render(){return this.elem=f("div",".value",this.value),this.elem.addEventListener("click",this.onClick),this.elem}addClickHandler(t,n,e){this.handler=e,this.type=t,this.idx=n}set background(t){this.elem.style.background=t}setAttn(n){this.selected?this.elem.style.setProperty("background",this.plotColors.getInterpolatedColor(.8*n,t.DimensionHeatmap)):this.elem.style.setProperty("background",this.plotColors.getInterpolatedSecondaryColor(.8*n)),this.elem.style.setProperty("color",this.plotColors.getFilledTextColor()),this.elem.title=n.toExponential()}setSelection(t){this.selected=t}}class T{constructor(t,n,e){this.values=t,this.name=n,this.plotColors=e,this.valueViews={};for(let t of this.values){let n=new k(t,this.plotColors);this.valueViews[t]=n}}addClickHandler(t,n){for(let e=0;e{var n;t("div",".dimension-name.title",`${n=this.name,n.split(" ").map((t=>t.charAt(0).toUpperCase()+t.slice(1))).join(" ")}`)}));for(let n=0;n{this.handler(t,n,e)},this.onDimSelect=t=>{t.preventDefault(),t.stopPropagation(),this.selectedDimension=this.dimSelectElem.value,this.renderChart(),this.tokenDim=this.handler(this.selectedDimension),this.renderAttention()},this.tokens=t,this.dimensions=n,this.handler=e,this.plotColors=r,this.tokenElems=[];for(let n=0;n{t("div",".select-container",(t=>{t("div.title.inline","Dimension",{for:"token-dim-heatmap-select"}),this.dimSelectElem=t("select","#token-dim-heatmap-select",{on:{change:this.onDimSelect}},(t=>{for(let n in this.dimensions)t("option",n,{value:n})}))}))})),this.dimSelectElem.value=this.selectedDimension,this.renderChart(),this.elem}renderChart(){let t;null!=this.chartElem&&(this.chartElem.remove(),this.chartElem=null);let n=this.dimensions[this.selectedDimension],e={width:this.cellSize*n.values.length+this.leftLabelsMargin,height:this.cellSize*this.tokens.length,viewBox:`0 0 ${this.cellSize*n.values.length+this.leftLabelsMargin} ${this.cellSize*this.tokens.length} `};this.chartElem=f("svg",".matrix",e,(n=>{t=n("g",".grid",{transform:`translate(${this.leftLabelsMargin}, 0)`});let e=[];n("g",".token_labels",{transform:`translate(${this.leftLabelsMargin-this.labelCellGap}, ${this.cellSize/2})`},(t=>{for(let n=0;n{t.preventDefault(),t.stopPropagation(),console.log("click",this.dims);for(let t of this.dims)this.handler(t.d,t.v,!1)},this.height=e,this.width=r,this.nSrc=t,this.nDst=n}render(){this.elem=f("g",".lines",{on:{click:this.onClick}},(t=>{this.bgLines=t("g"),this.fgLines=t("g")})),this.lines=[];for(let t=0;t{t.preventDefault(),t.stopPropagation(),this.dim1=this.dimSelectElem1.value,this.renderChart(),this.attentions=this.dimChangeHandler(this.dim1,this.dim2),this.renderSelection(),this.renderAttention()},this.onDim2Select=t=>{t.preventDefault(),t.stopPropagation(),this.dim2=this.dimSelectElem2.value,this.renderChart(),this.attentions=this.dimChangeHandler(this.dim1,this.dim2),this.renderSelection(),this.renderAttention()},this.srcTokens=t,this.dstTokens=n,this.dimChangeHandler=r,this.dimensions=e,this.dim1="null",this.dim2="null",this.cellWidth=80,this.cellHeight=100,this.cellMargin=10}addClickHandler(t){this.selectHanlder=t}render(){return this.elem=f("div",".line-grid",(t=>{t("div.double-select",(t=>{t("div",".select-container",(t=>{t("label.title.inline","Y Dimension",{for:"line-grid-dim2-select"}),this.dimSelectElem1=t("select","#line-grid-dim2-select",{on:{change:this.onDim1Select}},(t=>{for(let n in this.dimensions)t("option",n,{value:n});t("option","None",{value:"null"})}))})),t("div",".select-container",(t=>{t("label.title.inline","X Dimension",{for:"line-grid-dim1-select"}),this.dimSelectElem2=t("select","#line-grid-dim1-select",{on:{change:this.onDim2Select}},(t=>{for(let n in this.dimensions)t("option",n,{value:n});t("option","None",{value:"null"})}))}))}))})),this.dimSelectElem1.value=this.dim1,this.dimSelectElem2.value=this.dim2,this.renderChart(),this.elem}renderChart(){null!=this.chartElem&&(this.chartElem.remove(),this.chartElem=null);let t=v(this.dim1,this.dimensions),n=v(this.dim2,this.dimensions),e={width:this.cellWidth*n.length+this.cellMargin*(n.length-1),height:this.cellHeight*t.length+this.cellMargin*(t.length-1),viewBox:`0 0 ${this.cellWidth*n.length+this.cellMargin*(n.length-1)} ${this.cellHeight*t.length+this.cellMargin*(t.length-1)}`};this.cellLayers=[],this.chartElem=f("svg",".matrix",e,(e=>{for(let r=0;r{for(let e=0;e{if(e)this.selected[t][n]=!0!==this.selected[t][n];else if(!0===this.selected[t][n])if(this.getSelectedCount(t)>1){for(let n in this.selected[t])this.selected[t][n]=!1;this.selected[t][n]=!0}else for(let n in this.selected[t])this.selected[t][n]=!0;else{for(let n in this.selected[t])this.selected[t][n]=!1;this.selected[t][n]=!0}this.renderAttention()},this.onLineGridDimChange=(t,n)=>this.calcGridAttentionAttention(t,n),this.onTokenHeatmapDimChange=t=>this.calcTokenDimsAttention(t),this.attentions=e,this.srcTokens=new D(r),this.dstTokens=new D(i),this.chartTypes=o,this.dimensions=n,this.dimensionsMap={};for(let t of this.dimensions)this.dimensionsMap[t.name]=t;this.attentionMatrixView=new x(this.srcTokens,this.dstTokens,a),this.srcTokenHeatmap=new M(this.srcTokens,"Query Tokens",a),this.dstTokenHeatmap=new M(this.dstTokens,"Key Tokens",a),this.srcTokenHeatmap.addClickHandler("src",this.onSelected),this.dstTokenHeatmap.addClickHandler("dst",this.onSelected),this.selected={};for(let t of n){let n={};for(let r of e)!0!==n[r.info[t.name]]&&(n[r.info[t.name]]=!0);this.selected[t.name]={},t.values=[];for(let e in n)this.selected[t.name][e]=!0,t.values.push(e)}this.selected.src={};for(let t=0;tn&&this.menu.classList.add("right-align")}render(){return f("div",".hover-container",(t=>{this.elem=t("pre",".token"+(this.isNewLine?".new-line":""),this.token.replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\v/g,"\\v")),this.elem.style.setProperty("color",this.colors.getFilledTextColor()),this.menu=t("div",".menu",(t=>{for(let n=0;n{t("div",`${this.values[n].name}: ${this.values[n].value.toExponential()}`)}));t("hr"),null!=this.info&&t("pre",this.info)}))}))}setValue(n){let e=this.values.find((t=>t.name===n));if(null==e)return;let r=e.normalizedValue;this.elem.style.setProperty("background",this.colors.getInterpolatedColor(r,t.TokenLoss))}}class B{constructor(t,n,e,r=!0){this.onSelectChange=()=>{this.selectedMetric=this.selectElem.value;for(let t=0;t{t("div.title","Token Visualization"),t("div.title",(t=>{this.selectElem=t("select",(t=>{}))}))}));for(let n=0;n({name:o[e],value:n[t],normalizedValue:i[e][t],info:s[t]})));h[t]={values:n,info:s[t]}}let d=new B(e,h,f,a),p=document.createElement("div");p.className="attention-visualization"+("light"===c?"":" dark-theme"),p.appendChild(d.render()),document.getElementById(n).appendChild(p),d.updateMenuPosition()}})()})(); \ No newline at end of file +/******/ (() => { // webpackBootstrap +/******/ var __webpack_modules__ = ({ + +/***/ "./lib/d3/d3.js": +/*!**********************!*\ + !*** ./lib/d3/d3.js ***! + \**********************/ +/***/ (function(__unused_webpack_module, exports) { + +// https://d3js.org v7.2.1 Copyright 2010-2021 Mike Bostock +(function (global, factory) { + true ? factory(exports) : +0; +})(this, (function (exports) { 'use strict'; + +var version = "7.2.1"; + +function ascending$3(a, b) { + return a == null || b == null ? NaN : a < b ? -1 : a > b ? 1 : a >= b ? 0 : NaN; +} + +function bisector(f) { + let delta = f; + let compare1 = f; + let compare2 = f; + + if (f.length !== 2) { + delta = (d, x) => f(d) - x; + compare1 = ascending$3; + compare2 = (d, x) => ascending$3(f(d), x); + } + + function left(a, x, lo = 0, hi = a.length) { + if (lo < hi) { + if (compare1(x, x) !== 0) return hi; + do { + const mid = (lo + hi) >>> 1; + if (compare2(a[mid], x) < 0) lo = mid + 1; + else hi = mid; + } while (lo < hi); + } + return lo; + } + + function right(a, x, lo = 0, hi = a.length) { + if (lo < hi) { + if (compare1(x, x) !== 0) return hi; + do { + const mid = (lo + hi) >>> 1; + if (compare2(a[mid], x) <= 0) lo = mid + 1; + else hi = mid; + } while (lo < hi); + } + return lo; + } + + function center(a, x, lo = 0, hi = a.length) { + const i = left(a, x, lo, hi - 1); + return i > lo && delta(a[i - 1], x) > -delta(a[i], x) ? i - 1 : i; + } + + return {left, center, right}; +} + +function number$3(x) { + return x === null ? NaN : +x; +} + +function* numbers(values, valueof) { + if (valueof === undefined) { + for (let value of values) { + if (value != null && (value = +value) >= value) { + yield value; + } + } + } else { + let index = -1; + for (let value of values) { + if ((value = valueof(value, ++index, values)) != null && (value = +value) >= value) { + yield value; + } + } + } +} + +const ascendingBisect = bisector(ascending$3); +const bisectRight = ascendingBisect.right; +const bisectLeft = ascendingBisect.left; +const bisectCenter = bisector(number$3).center; +var bisect = bisectRight; + +function count$1(values, valueof) { + let count = 0; + if (valueof === undefined) { + for (let value of values) { + if (value != null && (value = +value) >= value) { + ++count; + } + } + } else { + let index = -1; + for (let value of values) { + if ((value = valueof(value, ++index, values)) != null && (value = +value) >= value) { + ++count; + } + } + } + return count; +} + +function length$3(array) { + return array.length | 0; +} + +function empty$2(length) { + return !(length > 0); +} + +function arrayify(values) { + return typeof values !== "object" || "length" in values ? values : Array.from(values); +} + +function reducer(reduce) { + return values => reduce(...values); +} + +function cross$2(...values) { + const reduce = typeof values[values.length - 1] === "function" && reducer(values.pop()); + values = values.map(arrayify); + const lengths = values.map(length$3); + const j = values.length - 1; + const index = new Array(j + 1).fill(0); + const product = []; + if (j < 0 || lengths.some(empty$2)) return product; + while (true) { + product.push(index.map((j, i) => values[i][j])); + let i = j; + while (++index[i] === lengths[i]) { + if (i === 0) return reduce ? product.map(reduce) : product; + index[i--] = 0; + } + } +} + +function cumsum(values, valueof) { + var sum = 0, index = 0; + return Float64Array.from(values, valueof === undefined + ? v => (sum += +v || 0) + : v => (sum += +valueof(v, index++, values) || 0)); +} + +function descending$2(a, b) { + return a == null || b == null ? NaN + : b < a ? -1 + : b > a ? 1 + : b >= a ? 0 + : NaN; +} + +function variance(values, valueof) { + let count = 0; + let delta; + let mean = 0; + let sum = 0; + if (valueof === undefined) { + for (let value of values) { + if (value != null && (value = +value) >= value) { + delta = value - mean; + mean += delta / ++count; + sum += delta * (value - mean); + } + } + } else { + let index = -1; + for (let value of values) { + if ((value = valueof(value, ++index, values)) != null && (value = +value) >= value) { + delta = value - mean; + mean += delta / ++count; + sum += delta * (value - mean); + } + } + } + if (count > 1) return sum / (count - 1); +} + +function deviation(values, valueof) { + const v = variance(values, valueof); + return v ? Math.sqrt(v) : v; +} + +function extent$1(values, valueof) { + let min; + let max; + if (valueof === undefined) { + for (const value of values) { + if (value != null) { + if (min === undefined) { + if (value >= value) min = max = value; + } else { + if (min > value) min = value; + if (max < value) max = value; + } + } + } + } else { + let index = -1; + for (let value of values) { + if ((value = valueof(value, ++index, values)) != null) { + if (min === undefined) { + if (value >= value) min = max = value; + } else { + if (min > value) min = value; + if (max < value) max = value; + } + } + } + } + return [min, max]; +} + +// https://github.com/python/cpython/blob/a74eea238f5baba15797e2e8b570d153bc8690a7/Modules/mathmodule.c#L1423 +class Adder { + constructor() { + this._partials = new Float64Array(32); + this._n = 0; + } + add(x) { + const p = this._partials; + let i = 0; + for (let j = 0; j < this._n && j < 32; j++) { + const y = p[j], + hi = x + y, + lo = Math.abs(x) < Math.abs(y) ? x - (hi - y) : y - (hi - x); + if (lo) p[i++] = lo; + x = hi; + } + p[i] = x; + this._n = i + 1; + return this; + } + valueOf() { + const p = this._partials; + let n = this._n, x, y, lo, hi = 0; + if (n > 0) { + hi = p[--n]; + while (n > 0) { + x = hi; + y = p[--n]; + hi = x + y; + lo = y - (hi - x); + if (lo) break; + } + if (n > 0 && ((lo < 0 && p[n - 1] < 0) || (lo > 0 && p[n - 1] > 0))) { + y = lo * 2; + x = hi + y; + if (y == x - hi) hi = x; + } + } + return hi; + } +} + +function fsum(values, valueof) { + const adder = new Adder(); + if (valueof === undefined) { + for (let value of values) { + if (value = +value) { + adder.add(value); + } + } + } else { + let index = -1; + for (let value of values) { + if (value = +valueof(value, ++index, values)) { + adder.add(value); + } + } + } + return +adder; +} + +function fcumsum(values, valueof) { + const adder = new Adder(); + let index = -1; + return Float64Array.from(values, valueof === undefined + ? v => adder.add(+v || 0) + : v => adder.add(+valueof(v, ++index, values) || 0) + ); +} + +class InternMap extends Map { + constructor(entries, key = keyof) { + super(); + Object.defineProperties(this, {_intern: {value: new Map()}, _key: {value: key}}); + if (entries != null) for (const [key, value] of entries) this.set(key, value); + } + get(key) { + return super.get(intern_get(this, key)); + } + has(key) { + return super.has(intern_get(this, key)); + } + set(key, value) { + return super.set(intern_set(this, key), value); + } + delete(key) { + return super.delete(intern_delete(this, key)); + } +} + +class InternSet extends Set { + constructor(values, key = keyof) { + super(); + Object.defineProperties(this, {_intern: {value: new Map()}, _key: {value: key}}); + if (values != null) for (const value of values) this.add(value); + } + has(value) { + return super.has(intern_get(this, value)); + } + add(value) { + return super.add(intern_set(this, value)); + } + delete(value) { + return super.delete(intern_delete(this, value)); + } +} + +function intern_get({_intern, _key}, value) { + const key = _key(value); + return _intern.has(key) ? _intern.get(key) : value; +} + +function intern_set({_intern, _key}, value) { + const key = _key(value); + if (_intern.has(key)) return _intern.get(key); + _intern.set(key, value); + return value; +} + +function intern_delete({_intern, _key}, value) { + const key = _key(value); + if (_intern.has(key)) { + value = _intern.get(key); + _intern.delete(key); + } + return value; +} + +function keyof(value) { + return value !== null && typeof value === "object" ? value.valueOf() : value; +} + +function identity$9(x) { + return x; +} + +function group(values, ...keys) { + return nest(values, identity$9, identity$9, keys); +} + +function groups(values, ...keys) { + return nest(values, Array.from, identity$9, keys); +} + +function flatten$1(groups, keys) { + for (let i = 1, n = keys.length; i < n; ++i) { + groups = groups.flatMap(g => g.pop().map(([key, value]) => [...g, key, value])); + } + return groups; +} + +function flatGroup(values, ...keys) { + return flatten$1(groups(values, ...keys), keys); +} + +function flatRollup(values, reduce, ...keys) { + return flatten$1(rollups(values, reduce, ...keys), keys); +} + +function rollup(values, reduce, ...keys) { + return nest(values, identity$9, reduce, keys); +} + +function rollups(values, reduce, ...keys) { + return nest(values, Array.from, reduce, keys); +} + +function index$4(values, ...keys) { + return nest(values, identity$9, unique, keys); +} + +function indexes(values, ...keys) { + return nest(values, Array.from, unique, keys); +} + +function unique(values) { + if (values.length !== 1) throw new Error("duplicate key"); + return values[0]; +} + +function nest(values, map, reduce, keys) { + return (function regroup(values, i) { + if (i >= keys.length) return reduce(values); + const groups = new InternMap(); + const keyof = keys[i++]; + let index = -1; + for (const value of values) { + const key = keyof(value, ++index, values); + const group = groups.get(key); + if (group) group.push(value); + else groups.set(key, [value]); + } + for (const [key, values] of groups) { + groups.set(key, regroup(values, i)); + } + return map(groups); + })(values, 0); +} + +function permute(source, keys) { + return Array.from(keys, key => source[key]); +} + +function sort(values, ...F) { + if (typeof values[Symbol.iterator] !== "function") throw new TypeError("values is not iterable"); + values = Array.from(values); + let [f] = F; + if ((f && f.length !== 2) || F.length > 1) { + const index = Uint32Array.from(values, (d, i) => i); + if (F.length > 1) { + F = F.map(f => values.map(f)); + index.sort((i, j) => { + for (const f of F) { + const c = ascendingDefined(f[i], f[j]); + if (c) return c; + } + }); + } else { + f = values.map(f); + index.sort((i, j) => ascendingDefined(f[i], f[j])); + } + return permute(values, index); + } + return values.sort(compareDefined(f)); +} + +function compareDefined(compare = ascending$3) { + if (compare === ascending$3) return ascendingDefined; + if (typeof compare !== "function") throw new TypeError("compare is not a function"); + return (a, b) => { + const x = compare(a, b); + if (x || x === 0) return x; + return (compare(b, b) === 0) - (compare(a, a) === 0); + }; +} + +function ascendingDefined(a, b) { + return (a == null || !(a >= a)) - (b == null || !(b >= b)) || (a < b ? -1 : a > b ? 1 : 0); +} + +function groupSort(values, reduce, key) { + return (reduce.length !== 2 + ? sort(rollup(values, reduce, key), (([ak, av], [bk, bv]) => ascending$3(av, bv) || ascending$3(ak, bk))) + : sort(group(values, key), (([ak, av], [bk, bv]) => reduce(av, bv) || ascending$3(ak, bk)))) + .map(([key]) => key); +} + +var array$5 = Array.prototype; + +var slice$3 = array$5.slice; + +function constant$b(x) { + return () => x; +} + +var e10 = Math.sqrt(50), + e5 = Math.sqrt(10), + e2 = Math.sqrt(2); + +function ticks(start, stop, count) { + var reverse, + i = -1, + n, + ticks, + step; + + stop = +stop, start = +start, count = +count; + if (start === stop && count > 0) return [start]; + if (reverse = stop < start) n = start, start = stop, stop = n; + if ((step = tickIncrement(start, stop, count)) === 0 || !isFinite(step)) return []; + + if (step > 0) { + let r0 = Math.round(start / step), r1 = Math.round(stop / step); + if (r0 * step < start) ++r0; + if (r1 * step > stop) --r1; + ticks = new Array(n = r1 - r0 + 1); + while (++i < n) ticks[i] = (r0 + i) * step; + } else { + step = -step; + let r0 = Math.round(start * step), r1 = Math.round(stop * step); + if (r0 / step < start) ++r0; + if (r1 / step > stop) --r1; + ticks = new Array(n = r1 - r0 + 1); + while (++i < n) ticks[i] = (r0 + i) / step; + } + + if (reverse) ticks.reverse(); + + return ticks; +} + +function tickIncrement(start, stop, count) { + var step = (stop - start) / Math.max(0, count), + power = Math.floor(Math.log(step) / Math.LN10), + error = step / Math.pow(10, power); + return power >= 0 + ? (error >= e10 ? 10 : error >= e5 ? 5 : error >= e2 ? 2 : 1) * Math.pow(10, power) + : -Math.pow(10, -power) / (error >= e10 ? 10 : error >= e5 ? 5 : error >= e2 ? 2 : 1); +} + +function tickStep(start, stop, count) { + var step0 = Math.abs(stop - start) / Math.max(0, count), + step1 = Math.pow(10, Math.floor(Math.log(step0) / Math.LN10)), + error = step0 / step1; + if (error >= e10) step1 *= 10; + else if (error >= e5) step1 *= 5; + else if (error >= e2) step1 *= 2; + return stop < start ? -step1 : step1; +} + +function nice$1(start, stop, count) { + let prestep; + while (true) { + const step = tickIncrement(start, stop, count); + if (step === prestep || step === 0 || !isFinite(step)) { + return [start, stop]; + } else if (step > 0) { + start = Math.floor(start / step) * step; + stop = Math.ceil(stop / step) * step; + } else if (step < 0) { + start = Math.ceil(start * step) / step; + stop = Math.floor(stop * step) / step; + } + prestep = step; + } +} + +function thresholdSturges(values) { + return Math.ceil(Math.log(count$1(values)) / Math.LN2) + 1; +} + +function bin() { + var value = identity$9, + domain = extent$1, + threshold = thresholdSturges; + + function histogram(data) { + if (!Array.isArray(data)) data = Array.from(data); + + var i, + n = data.length, + x, + values = new Array(n); + + for (i = 0; i < n; ++i) { + values[i] = value(data[i], i, data); + } + + var xz = domain(values), + x0 = xz[0], + x1 = xz[1], + tz = threshold(values, x0, x1); + + // Convert number of thresholds into uniform thresholds, and nice the + // default domain accordingly. + if (!Array.isArray(tz)) { + const max = x1, tn = +tz; + if (domain === extent$1) [x0, x1] = nice$1(x0, x1, tn); + tz = ticks(x0, x1, tn); + + // If the last threshold is coincident with the domain’s upper bound, the + // last bin will be zero-width. If the default domain is used, and this + // last threshold is coincident with the maximum input value, we can + // extend the niced upper bound by one tick to ensure uniform bin widths; + // otherwise, we simply remove the last threshold. Note that we don’t + // coerce values or the domain to numbers, and thus must be careful to + // compare order (>=) rather than strict equality (===)! + if (tz[tz.length - 1] >= x1) { + if (max >= x1 && domain === extent$1) { + const step = tickIncrement(x0, x1, tn); + if (isFinite(step)) { + if (step > 0) { + x1 = (Math.floor(x1 / step) + 1) * step; + } else if (step < 0) { + x1 = (Math.ceil(x1 * -step) + 1) / -step; + } + } + } else { + tz.pop(); + } + } + } + + // Remove any thresholds outside the domain. + var m = tz.length; + while (tz[0] <= x0) tz.shift(), --m; + while (tz[m - 1] > x1) tz.pop(), --m; + + var bins = new Array(m + 1), + bin; + + // Initialize bins. + for (i = 0; i <= m; ++i) { + bin = bins[i] = []; + bin.x0 = i > 0 ? tz[i - 1] : x0; + bin.x1 = i < m ? tz[i] : x1; + } + + // Assign data to bins by value, ignoring any outside the domain. + for (i = 0; i < n; ++i) { + x = values[i]; + if (x != null && x0 <= x && x <= x1) { + bins[bisect(tz, x, 0, m)].push(data[i]); + } + } + + return bins; + } + + histogram.value = function(_) { + return arguments.length ? (value = typeof _ === "function" ? _ : constant$b(_), histogram) : value; + }; + + histogram.domain = function(_) { + return arguments.length ? (domain = typeof _ === "function" ? _ : constant$b([_[0], _[1]]), histogram) : domain; + }; + + histogram.thresholds = function(_) { + return arguments.length ? (threshold = typeof _ === "function" ? _ : Array.isArray(_) ? constant$b(slice$3.call(_)) : constant$b(_), histogram) : threshold; + }; + + return histogram; +} + +function max$3(values, valueof) { + let max; + if (valueof === undefined) { + for (const value of values) { + if (value != null + && (max < value || (max === undefined && value >= value))) { + max = value; + } + } + } else { + let index = -1; + for (let value of values) { + if ((value = valueof(value, ++index, values)) != null + && (max < value || (max === undefined && value >= value))) { + max = value; + } + } + } + return max; +} + +function min$2(values, valueof) { + let min; + if (valueof === undefined) { + for (const value of values) { + if (value != null + && (min > value || (min === undefined && value >= value))) { + min = value; + } + } + } else { + let index = -1; + for (let value of values) { + if ((value = valueof(value, ++index, values)) != null + && (min > value || (min === undefined && value >= value))) { + min = value; + } + } + } + return min; +} + +// Based on https://github.com/mourner/quickselect +// ISC license, Copyright 2018 Vladimir Agafonkin. +function quickselect(array, k, left = 0, right = array.length - 1, compare) { + compare = compare === undefined ? ascendingDefined : compareDefined(compare); + + while (right > left) { + if (right - left > 600) { + const n = right - left + 1; + const m = k - left + 1; + const z = Math.log(n); + const s = 0.5 * Math.exp(2 * z / 3); + const sd = 0.5 * Math.sqrt(z * s * (n - s) / n) * (m - n / 2 < 0 ? -1 : 1); + const newLeft = Math.max(left, Math.floor(k - m * s / n + sd)); + const newRight = Math.min(right, Math.floor(k + (n - m) * s / n + sd)); + quickselect(array, k, newLeft, newRight, compare); + } + + const t = array[k]; + let i = left; + let j = right; + + swap$1(array, left, k); + if (compare(array[right], t) > 0) swap$1(array, left, right); + + while (i < j) { + swap$1(array, i, j), ++i, --j; + while (compare(array[i], t) < 0) ++i; + while (compare(array[j], t) > 0) --j; + } + + if (compare(array[left], t) === 0) swap$1(array, left, j); + else ++j, swap$1(array, j, right); + + if (j <= k) left = j + 1; + if (k <= j) right = j - 1; + } + return array; +} + +function swap$1(array, i, j) { + const t = array[i]; + array[i] = array[j]; + array[j] = t; +} + +function quantile$1(values, p, valueof) { + values = Float64Array.from(numbers(values, valueof)); + if (!(n = values.length)) return; + if ((p = +p) <= 0 || n < 2) return min$2(values); + if (p >= 1) return max$3(values); + var n, + i = (n - 1) * p, + i0 = Math.floor(i), + value0 = max$3(quickselect(values, i0).subarray(0, i0 + 1)), + value1 = min$2(values.subarray(i0 + 1)); + return value0 + (value1 - value0) * (i - i0); +} + +function quantileSorted(values, p, valueof = number$3) { + if (!(n = values.length)) return; + if ((p = +p) <= 0 || n < 2) return +valueof(values[0], 0, values); + if (p >= 1) return +valueof(values[n - 1], n - 1, values); + var n, + i = (n - 1) * p, + i0 = Math.floor(i), + value0 = +valueof(values[i0], i0, values), + value1 = +valueof(values[i0 + 1], i0 + 1, values); + return value0 + (value1 - value0) * (i - i0); +} + +function thresholdFreedmanDiaconis(values, min, max) { + return Math.ceil((max - min) / (2 * (quantile$1(values, 0.75) - quantile$1(values, 0.25)) * Math.pow(count$1(values), -1 / 3))); +} + +function thresholdScott(values, min, max) { + return Math.ceil((max - min) / (3.5 * deviation(values) * Math.pow(count$1(values), -1 / 3))); +} + +function maxIndex(values, valueof) { + let max; + let maxIndex = -1; + let index = -1; + if (valueof === undefined) { + for (const value of values) { + ++index; + if (value != null + && (max < value || (max === undefined && value >= value))) { + max = value, maxIndex = index; + } + } + } else { + for (let value of values) { + if ((value = valueof(value, ++index, values)) != null + && (max < value || (max === undefined && value >= value))) { + max = value, maxIndex = index; + } + } + } + return maxIndex; +} + +function mean(values, valueof) { + let count = 0; + let sum = 0; + if (valueof === undefined) { + for (let value of values) { + if (value != null && (value = +value) >= value) { + ++count, sum += value; + } + } + } else { + let index = -1; + for (let value of values) { + if ((value = valueof(value, ++index, values)) != null && (value = +value) >= value) { + ++count, sum += value; + } + } + } + if (count) return sum / count; +} + +function median(values, valueof) { + return quantile$1(values, 0.5, valueof); +} + +function* flatten(arrays) { + for (const array of arrays) { + yield* array; + } +} + +function merge(arrays) { + return Array.from(flatten(arrays)); +} + +function minIndex(values, valueof) { + let min; + let minIndex = -1; + let index = -1; + if (valueof === undefined) { + for (const value of values) { + ++index; + if (value != null + && (min > value || (min === undefined && value >= value))) { + min = value, minIndex = index; + } + } + } else { + for (let value of values) { + if ((value = valueof(value, ++index, values)) != null + && (min > value || (min === undefined && value >= value))) { + min = value, minIndex = index; + } + } + } + return minIndex; +} + +function mode(values, valueof) { + const counts = new InternMap(); + if (valueof === undefined) { + for (let value of values) { + if (value != null && value >= value) { + counts.set(value, (counts.get(value) || 0) + 1); + } + } + } else { + let index = -1; + for (let value of values) { + if ((value = valueof(value, ++index, values)) != null && value >= value) { + counts.set(value, (counts.get(value) || 0) + 1); + } + } + } + let modeValue; + let modeCount = 0; + for (const [value, count] of counts) { + if (count > modeCount) { + modeCount = count; + modeValue = value; + } + } + return modeValue; +} + +function pairs(values, pairof = pair) { + const pairs = []; + let previous; + let first = false; + for (const value of values) { + if (first) pairs.push(pairof(previous, value)); + previous = value; + first = true; + } + return pairs; +} + +function pair(a, b) { + return [a, b]; +} + +function range$2(start, stop, step) { + start = +start, stop = +stop, step = (n = arguments.length) < 2 ? (stop = start, start = 0, 1) : n < 3 ? 1 : +step; + + var i = -1, + n = Math.max(0, Math.ceil((stop - start) / step)) | 0, + range = new Array(n); + + while (++i < n) { + range[i] = start + i * step; + } + + return range; +} + +function rank(values, valueof = ascending$3) { + if (typeof values[Symbol.iterator] !== "function") throw new TypeError("values is not iterable"); + let V = Array.from(values); + const R = new Float64Array(V.length); + if (valueof.length !== 2) V = V.map(valueof), valueof = ascending$3; + const compareIndex = (i, j) => valueof(V[i], V[j]); + let k, r; + Uint32Array + .from(V, (_, i) => i) + .sort(valueof === ascending$3 ? (i, j) => ascendingDefined(V[i], V[j]) : compareDefined(compareIndex)) + .forEach((j, i) => { + const c = compareIndex(j, k === undefined ? j : k); + if (c >= 0) { + if (k === undefined || c > 0) k = j, r = i; + R[j] = r; + } else { + R[j] = NaN; + } + }); + return R; +} + +function least(values, compare = ascending$3) { + let min; + let defined = false; + if (compare.length === 1) { + let minValue; + for (const element of values) { + const value = compare(element); + if (defined + ? ascending$3(value, minValue) < 0 + : ascending$3(value, value) === 0) { + min = element; + minValue = value; + defined = true; + } + } + } else { + for (const value of values) { + if (defined + ? compare(value, min) < 0 + : compare(value, value) === 0) { + min = value; + defined = true; + } + } + } + return min; +} + +function leastIndex(values, compare = ascending$3) { + if (compare.length === 1) return minIndex(values, compare); + let minValue; + let min = -1; + let index = -1; + for (const value of values) { + ++index; + if (min < 0 + ? compare(value, value) === 0 + : compare(value, minValue) < 0) { + minValue = value; + min = index; + } + } + return min; +} + +function greatest(values, compare = ascending$3) { + let max; + let defined = false; + if (compare.length === 1) { + let maxValue; + for (const element of values) { + const value = compare(element); + if (defined + ? ascending$3(value, maxValue) > 0 + : ascending$3(value, value) === 0) { + max = element; + maxValue = value; + defined = true; + } + } + } else { + for (const value of values) { + if (defined + ? compare(value, max) > 0 + : compare(value, value) === 0) { + max = value; + defined = true; + } + } + } + return max; +} + +function greatestIndex(values, compare = ascending$3) { + if (compare.length === 1) return maxIndex(values, compare); + let maxValue; + let max = -1; + let index = -1; + for (const value of values) { + ++index; + if (max < 0 + ? compare(value, value) === 0 + : compare(value, maxValue) > 0) { + maxValue = value; + max = index; + } + } + return max; +} + +function scan(values, compare) { + const index = leastIndex(values, compare); + return index < 0 ? undefined : index; +} + +var shuffle$1 = shuffler(Math.random); + +function shuffler(random) { + return function shuffle(array, i0 = 0, i1 = array.length) { + let m = i1 - (i0 = +i0); + while (m) { + const i = random() * m-- | 0, t = array[m + i0]; + array[m + i0] = array[i + i0]; + array[i + i0] = t; + } + return array; + }; +} + +function sum$2(values, valueof) { + let sum = 0; + if (valueof === undefined) { + for (let value of values) { + if (value = +value) { + sum += value; + } + } + } else { + let index = -1; + for (let value of values) { + if (value = +valueof(value, ++index, values)) { + sum += value; + } + } + } + return sum; +} + +function transpose(matrix) { + if (!(n = matrix.length)) return []; + for (var i = -1, m = min$2(matrix, length$2), transpose = new Array(m); ++i < m;) { + for (var j = -1, n, row = transpose[i] = new Array(n); ++j < n;) { + row[j] = matrix[j][i]; + } + } + return transpose; +} + +function length$2(d) { + return d.length; +} + +function zip() { + return transpose(arguments); +} + +function every(values, test) { + if (typeof test !== "function") throw new TypeError("test is not a function"); + let index = -1; + for (const value of values) { + if (!test(value, ++index, values)) { + return false; + } + } + return true; +} + +function some(values, test) { + if (typeof test !== "function") throw new TypeError("test is not a function"); + let index = -1; + for (const value of values) { + if (test(value, ++index, values)) { + return true; + } + } + return false; +} + +function filter$1(values, test) { + if (typeof test !== "function") throw new TypeError("test is not a function"); + const array = []; + let index = -1; + for (const value of values) { + if (test(value, ++index, values)) { + array.push(value); + } + } + return array; +} + +function map$1(values, mapper) { + if (typeof values[Symbol.iterator] !== "function") throw new TypeError("values is not iterable"); + if (typeof mapper !== "function") throw new TypeError("mapper is not a function"); + return Array.from(values, (value, index) => mapper(value, index, values)); +} + +function reduce(values, reducer, value) { + if (typeof reducer !== "function") throw new TypeError("reducer is not a function"); + const iterator = values[Symbol.iterator](); + let done, next, index = -1; + if (arguments.length < 3) { + ({done, value} = iterator.next()); + if (done) return; + ++index; + } + while (({done, value: next} = iterator.next()), !done) { + value = reducer(value, next, ++index, values); + } + return value; +} + +function reverse$1(values) { + if (typeof values[Symbol.iterator] !== "function") throw new TypeError("values is not iterable"); + return Array.from(values).reverse(); +} + +function difference(values, ...others) { + values = new InternSet(values); + for (const other of others) { + for (const value of other) { + values.delete(value); + } + } + return values; +} + +function disjoint(values, other) { + const iterator = other[Symbol.iterator](), set = new InternSet(); + for (const v of values) { + if (set.has(v)) return false; + let value, done; + while (({value, done} = iterator.next())) { + if (done) break; + if (Object.is(v, value)) return false; + set.add(value); + } + } + return true; +} + +function intersection(values, ...others) { + values = new InternSet(values); + others = others.map(set$2); + out: for (const value of values) { + for (const other of others) { + if (!other.has(value)) { + values.delete(value); + continue out; + } + } + } + return values; +} + +function set$2(values) { + return values instanceof InternSet ? values : new InternSet(values); +} + +function superset(values, other) { + const iterator = values[Symbol.iterator](), set = new Set(); + for (const o of other) { + const io = intern(o); + if (set.has(io)) continue; + let value, done; + while (({value, done} = iterator.next())) { + if (done) return false; + const ivalue = intern(value); + set.add(ivalue); + if (Object.is(io, ivalue)) break; + } + } + return true; +} + +function intern(value) { + return value !== null && typeof value === "object" ? value.valueOf() : value; +} + +function subset(values, other) { + return superset(other, values); +} + +function union(...others) { + const set = new InternSet(); + for (const other of others) { + for (const o of other) { + set.add(o); + } + } + return set; +} + +function identity$8(x) { + return x; +} + +var top = 1, + right = 2, + bottom = 3, + left = 4, + epsilon$6 = 1e-6; + +function translateX(x) { + return "translate(" + x + ",0)"; +} + +function translateY(y) { + return "translate(0," + y + ")"; +} + +function number$2(scale) { + return d => +scale(d); +} + +function center$1(scale, offset) { + offset = Math.max(0, scale.bandwidth() - offset * 2) / 2; + if (scale.round()) offset = Math.round(offset); + return d => +scale(d) + offset; +} + +function entering() { + return !this.__axis; +} + +function axis(orient, scale) { + var tickArguments = [], + tickValues = null, + tickFormat = null, + tickSizeInner = 6, + tickSizeOuter = 6, + tickPadding = 3, + offset = typeof window !== "undefined" && window.devicePixelRatio > 1 ? 0 : 0.5, + k = orient === top || orient === left ? -1 : 1, + x = orient === left || orient === right ? "x" : "y", + transform = orient === top || orient === bottom ? translateX : translateY; + + function axis(context) { + var values = tickValues == null ? (scale.ticks ? scale.ticks.apply(scale, tickArguments) : scale.domain()) : tickValues, + format = tickFormat == null ? (scale.tickFormat ? scale.tickFormat.apply(scale, tickArguments) : identity$8) : tickFormat, + spacing = Math.max(tickSizeInner, 0) + tickPadding, + range = scale.range(), + range0 = +range[0] + offset, + range1 = +range[range.length - 1] + offset, + position = (scale.bandwidth ? center$1 : number$2)(scale.copy(), offset), + selection = context.selection ? context.selection() : context, + path = selection.selectAll(".domain").data([null]), + tick = selection.selectAll(".tick").data(values, scale).order(), + tickExit = tick.exit(), + tickEnter = tick.enter().append("g").attr("class", "tick"), + line = tick.select("line"), + text = tick.select("text"); + + path = path.merge(path.enter().insert("path", ".tick") + .attr("class", "domain") + .attr("stroke", "currentColor")); + + tick = tick.merge(tickEnter); + + line = line.merge(tickEnter.append("line") + .attr("stroke", "currentColor") + .attr(x + "2", k * tickSizeInner)); + + text = text.merge(tickEnter.append("text") + .attr("fill", "currentColor") + .attr(x, k * spacing) + .attr("dy", orient === top ? "0em" : orient === bottom ? "0.71em" : "0.32em")); + + if (context !== selection) { + path = path.transition(context); + tick = tick.transition(context); + line = line.transition(context); + text = text.transition(context); + + tickExit = tickExit.transition(context) + .attr("opacity", epsilon$6) + .attr("transform", function(d) { return isFinite(d = position(d)) ? transform(d + offset) : this.getAttribute("transform"); }); + + tickEnter + .attr("opacity", epsilon$6) + .attr("transform", function(d) { var p = this.parentNode.__axis; return transform((p && isFinite(p = p(d)) ? p : position(d)) + offset); }); + } + + tickExit.remove(); + + path + .attr("d", orient === left || orient === right + ? (tickSizeOuter ? "M" + k * tickSizeOuter + "," + range0 + "H" + offset + "V" + range1 + "H" + k * tickSizeOuter : "M" + offset + "," + range0 + "V" + range1) + : (tickSizeOuter ? "M" + range0 + "," + k * tickSizeOuter + "V" + offset + "H" + range1 + "V" + k * tickSizeOuter : "M" + range0 + "," + offset + "H" + range1)); + + tick + .attr("opacity", 1) + .attr("transform", function(d) { return transform(position(d) + offset); }); + + line + .attr(x + "2", k * tickSizeInner); + + text + .attr(x, k * spacing) + .text(format); + + selection.filter(entering) + .attr("fill", "none") + .attr("font-size", 10) + .attr("font-family", "sans-serif") + .attr("text-anchor", orient === right ? "start" : orient === left ? "end" : "middle"); + + selection + .each(function() { this.__axis = position; }); + } + + axis.scale = function(_) { + return arguments.length ? (scale = _, axis) : scale; + }; + + axis.ticks = function() { + return tickArguments = Array.from(arguments), axis; + }; + + axis.tickArguments = function(_) { + return arguments.length ? (tickArguments = _ == null ? [] : Array.from(_), axis) : tickArguments.slice(); + }; + + axis.tickValues = function(_) { + return arguments.length ? (tickValues = _ == null ? null : Array.from(_), axis) : tickValues && tickValues.slice(); + }; + + axis.tickFormat = function(_) { + return arguments.length ? (tickFormat = _, axis) : tickFormat; + }; + + axis.tickSize = function(_) { + return arguments.length ? (tickSizeInner = tickSizeOuter = +_, axis) : tickSizeInner; + }; + + axis.tickSizeInner = function(_) { + return arguments.length ? (tickSizeInner = +_, axis) : tickSizeInner; + }; + + axis.tickSizeOuter = function(_) { + return arguments.length ? (tickSizeOuter = +_, axis) : tickSizeOuter; + }; + + axis.tickPadding = function(_) { + return arguments.length ? (tickPadding = +_, axis) : tickPadding; + }; + + axis.offset = function(_) { + return arguments.length ? (offset = +_, axis) : offset; + }; + + return axis; +} + +function axisTop(scale) { + return axis(top, scale); +} + +function axisRight(scale) { + return axis(right, scale); +} + +function axisBottom(scale) { + return axis(bottom, scale); +} + +function axisLeft(scale) { + return axis(left, scale); +} + +var noop$3 = {value: () => {}}; + +function dispatch() { + for (var i = 0, n = arguments.length, _ = {}, t; i < n; ++i) { + if (!(t = arguments[i] + "") || (t in _) || /[\s.]/.test(t)) throw new Error("illegal type: " + t); + _[t] = []; + } + return new Dispatch(_); +} + +function Dispatch(_) { + this._ = _; +} + +function parseTypenames$1(typenames, types) { + return typenames.trim().split(/^|\s+/).map(function(t) { + var name = "", i = t.indexOf("."); + if (i >= 0) name = t.slice(i + 1), t = t.slice(0, i); + if (t && !types.hasOwnProperty(t)) throw new Error("unknown type: " + t); + return {type: t, name: name}; + }); +} + +Dispatch.prototype = dispatch.prototype = { + constructor: Dispatch, + on: function(typename, callback) { + var _ = this._, + T = parseTypenames$1(typename + "", _), + t, + i = -1, + n = T.length; + + // If no callback was specified, return the callback of the given type and name. + if (arguments.length < 2) { + while (++i < n) if ((t = (typename = T[i]).type) && (t = get$1(_[t], typename.name))) return t; + return; + } + + // If a type was specified, set the callback for the given type and name. + // Otherwise, if a null callback was specified, remove callbacks of the given name. + if (callback != null && typeof callback !== "function") throw new Error("invalid callback: " + callback); + while (++i < n) { + if (t = (typename = T[i]).type) _[t] = set$1(_[t], typename.name, callback); + else if (callback == null) for (t in _) _[t] = set$1(_[t], typename.name, null); + } + + return this; + }, + copy: function() { + var copy = {}, _ = this._; + for (var t in _) copy[t] = _[t].slice(); + return new Dispatch(copy); + }, + call: function(type, that) { + if ((n = arguments.length - 2) > 0) for (var args = new Array(n), i = 0, n, t; i < n; ++i) args[i] = arguments[i + 2]; + if (!this._.hasOwnProperty(type)) throw new Error("unknown type: " + type); + for (t = this._[type], i = 0, n = t.length; i < n; ++i) t[i].value.apply(that, args); + }, + apply: function(type, that, args) { + if (!this._.hasOwnProperty(type)) throw new Error("unknown type: " + type); + for (var t = this._[type], i = 0, n = t.length; i < n; ++i) t[i].value.apply(that, args); + } +}; + +function get$1(type, name) { + for (var i = 0, n = type.length, c; i < n; ++i) { + if ((c = type[i]).name === name) { + return c.value; + } + } +} + +function set$1(type, name, callback) { + for (var i = 0, n = type.length; i < n; ++i) { + if (type[i].name === name) { + type[i] = noop$3, type = type.slice(0, i).concat(type.slice(i + 1)); + break; + } + } + if (callback != null) type.push({name: name, value: callback}); + return type; +} + +var xhtml = "http://www.w3.org/1999/xhtml"; + +var namespaces = { + svg: "http://www.w3.org/2000/svg", + xhtml: xhtml, + xlink: "http://www.w3.org/1999/xlink", + xml: "http://www.w3.org/XML/1998/namespace", + xmlns: "http://www.w3.org/2000/xmlns/" +}; + +function namespace(name) { + var prefix = name += "", i = prefix.indexOf(":"); + if (i >= 0 && (prefix = name.slice(0, i)) !== "xmlns") name = name.slice(i + 1); + return namespaces.hasOwnProperty(prefix) ? {space: namespaces[prefix], local: name} : name; // eslint-disable-line no-prototype-builtins +} + +function creatorInherit(name) { + return function() { + var document = this.ownerDocument, + uri = this.namespaceURI; + return uri === xhtml && document.documentElement.namespaceURI === xhtml + ? document.createElement(name) + : document.createElementNS(uri, name); + }; +} + +function creatorFixed(fullname) { + return function() { + return this.ownerDocument.createElementNS(fullname.space, fullname.local); + }; +} + +function creator(name) { + var fullname = namespace(name); + return (fullname.local + ? creatorFixed + : creatorInherit)(fullname); +} + +function none$2() {} + +function selector(selector) { + return selector == null ? none$2 : function() { + return this.querySelector(selector); + }; +} + +function selection_select(select) { + if (typeof select !== "function") select = selector(select); + + for (var groups = this._groups, m = groups.length, subgroups = new Array(m), j = 0; j < m; ++j) { + for (var group = groups[j], n = group.length, subgroup = subgroups[j] = new Array(n), node, subnode, i = 0; i < n; ++i) { + if ((node = group[i]) && (subnode = select.call(node, node.__data__, i, group))) { + if ("__data__" in node) subnode.__data__ = node.__data__; + subgroup[i] = subnode; + } + } + } + + return new Selection$1(subgroups, this._parents); +} + +// Given something array like (or null), returns something that is strictly an +// array. This is used to ensure that array-like objects passed to d3.selectAll +// or selection.selectAll are converted into proper arrays when creating a +// selection; we don’t ever want to create a selection backed by a live +// HTMLCollection or NodeList. However, note that selection.selectAll will use a +// static NodeList as a group, since it safely derived from querySelectorAll. +function array$4(x) { + return x == null ? [] : Array.isArray(x) ? x : Array.from(x); +} + +function empty$1() { + return []; +} + +function selectorAll(selector) { + return selector == null ? empty$1 : function() { + return this.querySelectorAll(selector); + }; +} + +function arrayAll(select) { + return function() { + return array$4(select.apply(this, arguments)); + }; +} + +function selection_selectAll(select) { + if (typeof select === "function") select = arrayAll(select); + else select = selectorAll(select); + + for (var groups = this._groups, m = groups.length, subgroups = [], parents = [], j = 0; j < m; ++j) { + for (var group = groups[j], n = group.length, node, i = 0; i < n; ++i) { + if (node = group[i]) { + subgroups.push(select.call(node, node.__data__, i, group)); + parents.push(node); + } + } + } + + return new Selection$1(subgroups, parents); +} + +function matcher(selector) { + return function() { + return this.matches(selector); + }; +} + +function childMatcher(selector) { + return function(node) { + return node.matches(selector); + }; +} + +var find$1 = Array.prototype.find; + +function childFind(match) { + return function() { + return find$1.call(this.children, match); + }; +} + +function childFirst() { + return this.firstElementChild; +} + +function selection_selectChild(match) { + return this.select(match == null ? childFirst + : childFind(typeof match === "function" ? match : childMatcher(match))); +} + +var filter = Array.prototype.filter; + +function children() { + return Array.from(this.children); +} + +function childrenFilter(match) { + return function() { + return filter.call(this.children, match); + }; +} + +function selection_selectChildren(match) { + return this.selectAll(match == null ? children + : childrenFilter(typeof match === "function" ? match : childMatcher(match))); +} + +function selection_filter(match) { + if (typeof match !== "function") match = matcher(match); + + for (var groups = this._groups, m = groups.length, subgroups = new Array(m), j = 0; j < m; ++j) { + for (var group = groups[j], n = group.length, subgroup = subgroups[j] = [], node, i = 0; i < n; ++i) { + if ((node = group[i]) && match.call(node, node.__data__, i, group)) { + subgroup.push(node); + } + } + } + + return new Selection$1(subgroups, this._parents); +} + +function sparse(update) { + return new Array(update.length); +} + +function selection_enter() { + return new Selection$1(this._enter || this._groups.map(sparse), this._parents); +} + +function EnterNode(parent, datum) { + this.ownerDocument = parent.ownerDocument; + this.namespaceURI = parent.namespaceURI; + this._next = null; + this._parent = parent; + this.__data__ = datum; +} + +EnterNode.prototype = { + constructor: EnterNode, + appendChild: function(child) { return this._parent.insertBefore(child, this._next); }, + insertBefore: function(child, next) { return this._parent.insertBefore(child, next); }, + querySelector: function(selector) { return this._parent.querySelector(selector); }, + querySelectorAll: function(selector) { return this._parent.querySelectorAll(selector); } +}; + +function constant$a(x) { + return function() { + return x; + }; +} + +function bindIndex(parent, group, enter, update, exit, data) { + var i = 0, + node, + groupLength = group.length, + dataLength = data.length; + + // Put any non-null nodes that fit into update. + // Put any null nodes into enter. + // Put any remaining data into enter. + for (; i < dataLength; ++i) { + if (node = group[i]) { + node.__data__ = data[i]; + update[i] = node; + } else { + enter[i] = new EnterNode(parent, data[i]); + } + } + + // Put any non-null nodes that don’t fit into exit. + for (; i < groupLength; ++i) { + if (node = group[i]) { + exit[i] = node; + } + } +} + +function bindKey(parent, group, enter, update, exit, data, key) { + var i, + node, + nodeByKeyValue = new Map, + groupLength = group.length, + dataLength = data.length, + keyValues = new Array(groupLength), + keyValue; + + // Compute the key for each node. + // If multiple nodes have the same key, the duplicates are added to exit. + for (i = 0; i < groupLength; ++i) { + if (node = group[i]) { + keyValues[i] = keyValue = key.call(node, node.__data__, i, group) + ""; + if (nodeByKeyValue.has(keyValue)) { + exit[i] = node; + } else { + nodeByKeyValue.set(keyValue, node); + } + } + } + + // Compute the key for each datum. + // If there a node associated with this key, join and add it to update. + // If there is not (or the key is a duplicate), add it to enter. + for (i = 0; i < dataLength; ++i) { + keyValue = key.call(parent, data[i], i, data) + ""; + if (node = nodeByKeyValue.get(keyValue)) { + update[i] = node; + node.__data__ = data[i]; + nodeByKeyValue.delete(keyValue); + } else { + enter[i] = new EnterNode(parent, data[i]); + } + } + + // Add any remaining nodes that were not bound to data to exit. + for (i = 0; i < groupLength; ++i) { + if ((node = group[i]) && (nodeByKeyValue.get(keyValues[i]) === node)) { + exit[i] = node; + } + } +} + +function datum(node) { + return node.__data__; +} + +function selection_data(value, key) { + if (!arguments.length) return Array.from(this, datum); + + var bind = key ? bindKey : bindIndex, + parents = this._parents, + groups = this._groups; + + if (typeof value !== "function") value = constant$a(value); + + for (var m = groups.length, update = new Array(m), enter = new Array(m), exit = new Array(m), j = 0; j < m; ++j) { + var parent = parents[j], + group = groups[j], + groupLength = group.length, + data = arraylike(value.call(parent, parent && parent.__data__, j, parents)), + dataLength = data.length, + enterGroup = enter[j] = new Array(dataLength), + updateGroup = update[j] = new Array(dataLength), + exitGroup = exit[j] = new Array(groupLength); + + bind(parent, group, enterGroup, updateGroup, exitGroup, data, key); + + // Now connect the enter nodes to their following update node, such that + // appendChild can insert the materialized enter node before this node, + // rather than at the end of the parent node. + for (var i0 = 0, i1 = 0, previous, next; i0 < dataLength; ++i0) { + if (previous = enterGroup[i0]) { + if (i0 >= i1) i1 = i0 + 1; + while (!(next = updateGroup[i1]) && ++i1 < dataLength); + previous._next = next || null; + } + } + } + + update = new Selection$1(update, parents); + update._enter = enter; + update._exit = exit; + return update; +} + +// Given some data, this returns an array-like view of it: an object that +// exposes a length property and allows numeric indexing. Note that unlike +// selectAll, this isn’t worried about “live” collections because the resulting +// array will only be used briefly while data is being bound. (It is possible to +// cause the data to change while iterating by using a key function, but please +// don’t; we’d rather avoid a gratuitous copy.) +function arraylike(data) { + return typeof data === "object" && "length" in data + ? data // Array, TypedArray, NodeList, array-like + : Array.from(data); // Map, Set, iterable, string, or anything else +} + +function selection_exit() { + return new Selection$1(this._exit || this._groups.map(sparse), this._parents); +} + +function selection_join(onenter, onupdate, onexit) { + var enter = this.enter(), update = this, exit = this.exit(); + if (typeof onenter === "function") { + enter = onenter(enter); + if (enter) enter = enter.selection(); + } else { + enter = enter.append(onenter + ""); + } + if (onupdate != null) { + update = onupdate(update); + if (update) update = update.selection(); + } + if (onexit == null) exit.remove(); else onexit(exit); + return enter && update ? enter.merge(update).order() : update; +} + +function selection_merge(context) { + var selection = context.selection ? context.selection() : context; + + for (var groups0 = this._groups, groups1 = selection._groups, m0 = groups0.length, m1 = groups1.length, m = Math.min(m0, m1), merges = new Array(m0), j = 0; j < m; ++j) { + for (var group0 = groups0[j], group1 = groups1[j], n = group0.length, merge = merges[j] = new Array(n), node, i = 0; i < n; ++i) { + if (node = group0[i] || group1[i]) { + merge[i] = node; + } + } + } + + for (; j < m0; ++j) { + merges[j] = groups0[j]; + } + + return new Selection$1(merges, this._parents); +} + +function selection_order() { + + for (var groups = this._groups, j = -1, m = groups.length; ++j < m;) { + for (var group = groups[j], i = group.length - 1, next = group[i], node; --i >= 0;) { + if (node = group[i]) { + if (next && node.compareDocumentPosition(next) ^ 4) next.parentNode.insertBefore(node, next); + next = node; + } + } + } + + return this; +} + +function selection_sort(compare) { + if (!compare) compare = ascending$2; + + function compareNode(a, b) { + return a && b ? compare(a.__data__, b.__data__) : !a - !b; + } + + for (var groups = this._groups, m = groups.length, sortgroups = new Array(m), j = 0; j < m; ++j) { + for (var group = groups[j], n = group.length, sortgroup = sortgroups[j] = new Array(n), node, i = 0; i < n; ++i) { + if (node = group[i]) { + sortgroup[i] = node; + } + } + sortgroup.sort(compareNode); + } + + return new Selection$1(sortgroups, this._parents).order(); +} + +function ascending$2(a, b) { + return a < b ? -1 : a > b ? 1 : a >= b ? 0 : NaN; +} + +function selection_call() { + var callback = arguments[0]; + arguments[0] = this; + callback.apply(null, arguments); + return this; +} + +function selection_nodes() { + return Array.from(this); +} + +function selection_node() { + + for (var groups = this._groups, j = 0, m = groups.length; j < m; ++j) { + for (var group = groups[j], i = 0, n = group.length; i < n; ++i) { + var node = group[i]; + if (node) return node; + } + } + + return null; +} + +function selection_size() { + let size = 0; + for (const node of this) ++size; // eslint-disable-line no-unused-vars + return size; +} + +function selection_empty() { + return !this.node(); +} + +function selection_each(callback) { + + for (var groups = this._groups, j = 0, m = groups.length; j < m; ++j) { + for (var group = groups[j], i = 0, n = group.length, node; i < n; ++i) { + if (node = group[i]) callback.call(node, node.__data__, i, group); + } + } + + return this; +} + +function attrRemove$1(name) { + return function() { + this.removeAttribute(name); + }; +} + +function attrRemoveNS$1(fullname) { + return function() { + this.removeAttributeNS(fullname.space, fullname.local); + }; +} + +function attrConstant$1(name, value) { + return function() { + this.setAttribute(name, value); + }; +} + +function attrConstantNS$1(fullname, value) { + return function() { + this.setAttributeNS(fullname.space, fullname.local, value); + }; +} + +function attrFunction$1(name, value) { + return function() { + var v = value.apply(this, arguments); + if (v == null) this.removeAttribute(name); + else this.setAttribute(name, v); + }; +} + +function attrFunctionNS$1(fullname, value) { + return function() { + var v = value.apply(this, arguments); + if (v == null) this.removeAttributeNS(fullname.space, fullname.local); + else this.setAttributeNS(fullname.space, fullname.local, v); + }; +} + +function selection_attr(name, value) { + var fullname = namespace(name); + + if (arguments.length < 2) { + var node = this.node(); + return fullname.local + ? node.getAttributeNS(fullname.space, fullname.local) + : node.getAttribute(fullname); + } + + return this.each((value == null + ? (fullname.local ? attrRemoveNS$1 : attrRemove$1) : (typeof value === "function" + ? (fullname.local ? attrFunctionNS$1 : attrFunction$1) + : (fullname.local ? attrConstantNS$1 : attrConstant$1)))(fullname, value)); +} + +function defaultView(node) { + return (node.ownerDocument && node.ownerDocument.defaultView) // node is a Node + || (node.document && node) // node is a Window + || node.defaultView; // node is a Document +} + +function styleRemove$1(name) { + return function() { + this.style.removeProperty(name); + }; +} + +function styleConstant$1(name, value, priority) { + return function() { + this.style.setProperty(name, value, priority); + }; +} + +function styleFunction$1(name, value, priority) { + return function() { + var v = value.apply(this, arguments); + if (v == null) this.style.removeProperty(name); + else this.style.setProperty(name, v, priority); + }; +} + +function selection_style(name, value, priority) { + return arguments.length > 1 + ? this.each((value == null + ? styleRemove$1 : typeof value === "function" + ? styleFunction$1 + : styleConstant$1)(name, value, priority == null ? "" : priority)) + : styleValue(this.node(), name); +} + +function styleValue(node, name) { + return node.style.getPropertyValue(name) + || defaultView(node).getComputedStyle(node, null).getPropertyValue(name); +} + +function propertyRemove(name) { + return function() { + delete this[name]; + }; +} + +function propertyConstant(name, value) { + return function() { + this[name] = value; + }; +} + +function propertyFunction(name, value) { + return function() { + var v = value.apply(this, arguments); + if (v == null) delete this[name]; + else this[name] = v; + }; +} + +function selection_property(name, value) { + return arguments.length > 1 + ? this.each((value == null + ? propertyRemove : typeof value === "function" + ? propertyFunction + : propertyConstant)(name, value)) + : this.node()[name]; +} + +function classArray(string) { + return string.trim().split(/^|\s+/); +} + +function classList(node) { + return node.classList || new ClassList(node); +} + +function ClassList(node) { + this._node = node; + this._names = classArray(node.getAttribute("class") || ""); +} + +ClassList.prototype = { + add: function(name) { + var i = this._names.indexOf(name); + if (i < 0) { + this._names.push(name); + this._node.setAttribute("class", this._names.join(" ")); + } + }, + remove: function(name) { + var i = this._names.indexOf(name); + if (i >= 0) { + this._names.splice(i, 1); + this._node.setAttribute("class", this._names.join(" ")); + } + }, + contains: function(name) { + return this._names.indexOf(name) >= 0; + } +}; + +function classedAdd(node, names) { + var list = classList(node), i = -1, n = names.length; + while (++i < n) list.add(names[i]); +} + +function classedRemove(node, names) { + var list = classList(node), i = -1, n = names.length; + while (++i < n) list.remove(names[i]); +} + +function classedTrue(names) { + return function() { + classedAdd(this, names); + }; +} + +function classedFalse(names) { + return function() { + classedRemove(this, names); + }; +} + +function classedFunction(names, value) { + return function() { + (value.apply(this, arguments) ? classedAdd : classedRemove)(this, names); + }; +} + +function selection_classed(name, value) { + var names = classArray(name + ""); + + if (arguments.length < 2) { + var list = classList(this.node()), i = -1, n = names.length; + while (++i < n) if (!list.contains(names[i])) return false; + return true; + } + + return this.each((typeof value === "function" + ? classedFunction : value + ? classedTrue + : classedFalse)(names, value)); +} + +function textRemove() { + this.textContent = ""; +} + +function textConstant$1(value) { + return function() { + this.textContent = value; + }; +} + +function textFunction$1(value) { + return function() { + var v = value.apply(this, arguments); + this.textContent = v == null ? "" : v; + }; +} + +function selection_text(value) { + return arguments.length + ? this.each(value == null + ? textRemove : (typeof value === "function" + ? textFunction$1 + : textConstant$1)(value)) + : this.node().textContent; +} + +function htmlRemove() { + this.innerHTML = ""; +} + +function htmlConstant(value) { + return function() { + this.innerHTML = value; + }; +} + +function htmlFunction(value) { + return function() { + var v = value.apply(this, arguments); + this.innerHTML = v == null ? "" : v; + }; +} + +function selection_html(value) { + return arguments.length + ? this.each(value == null + ? htmlRemove : (typeof value === "function" + ? htmlFunction + : htmlConstant)(value)) + : this.node().innerHTML; +} + +function raise() { + if (this.nextSibling) this.parentNode.appendChild(this); +} + +function selection_raise() { + return this.each(raise); +} + +function lower() { + if (this.previousSibling) this.parentNode.insertBefore(this, this.parentNode.firstChild); +} + +function selection_lower() { + return this.each(lower); +} + +function selection_append(name) { + var create = typeof name === "function" ? name : creator(name); + return this.select(function() { + return this.appendChild(create.apply(this, arguments)); + }); +} + +function constantNull() { + return null; +} + +function selection_insert(name, before) { + var create = typeof name === "function" ? name : creator(name), + select = before == null ? constantNull : typeof before === "function" ? before : selector(before); + return this.select(function() { + return this.insertBefore(create.apply(this, arguments), select.apply(this, arguments) || null); + }); +} + +function remove() { + var parent = this.parentNode; + if (parent) parent.removeChild(this); +} + +function selection_remove() { + return this.each(remove); +} + +function selection_cloneShallow() { + var clone = this.cloneNode(false), parent = this.parentNode; + return parent ? parent.insertBefore(clone, this.nextSibling) : clone; +} + +function selection_cloneDeep() { + var clone = this.cloneNode(true), parent = this.parentNode; + return parent ? parent.insertBefore(clone, this.nextSibling) : clone; +} + +function selection_clone(deep) { + return this.select(deep ? selection_cloneDeep : selection_cloneShallow); +} + +function selection_datum(value) { + return arguments.length + ? this.property("__data__", value) + : this.node().__data__; +} + +function contextListener(listener) { + return function(event) { + listener.call(this, event, this.__data__); + }; +} + +function parseTypenames(typenames) { + return typenames.trim().split(/^|\s+/).map(function(t) { + var name = "", i = t.indexOf("."); + if (i >= 0) name = t.slice(i + 1), t = t.slice(0, i); + return {type: t, name: name}; + }); +} + +function onRemove(typename) { + return function() { + var on = this.__on; + if (!on) return; + for (var j = 0, i = -1, m = on.length, o; j < m; ++j) { + if (o = on[j], (!typename.type || o.type === typename.type) && o.name === typename.name) { + this.removeEventListener(o.type, o.listener, o.options); + } else { + on[++i] = o; + } + } + if (++i) on.length = i; + else delete this.__on; + }; +} + +function onAdd(typename, value, options) { + return function() { + var on = this.__on, o, listener = contextListener(value); + if (on) for (var j = 0, m = on.length; j < m; ++j) { + if ((o = on[j]).type === typename.type && o.name === typename.name) { + this.removeEventListener(o.type, o.listener, o.options); + this.addEventListener(o.type, o.listener = listener, o.options = options); + o.value = value; + return; + } + } + this.addEventListener(typename.type, listener, options); + o = {type: typename.type, name: typename.name, value: value, listener: listener, options: options}; + if (!on) this.__on = [o]; + else on.push(o); + }; +} + +function selection_on(typename, value, options) { + var typenames = parseTypenames(typename + ""), i, n = typenames.length, t; + + if (arguments.length < 2) { + var on = this.node().__on; + if (on) for (var j = 0, m = on.length, o; j < m; ++j) { + for (i = 0, o = on[j]; i < n; ++i) { + if ((t = typenames[i]).type === o.type && t.name === o.name) { + return o.value; + } + } + } + return; + } + + on = value ? onAdd : onRemove; + for (i = 0; i < n; ++i) this.each(on(typenames[i], value, options)); + return this; +} + +function dispatchEvent(node, type, params) { + var window = defaultView(node), + event = window.CustomEvent; + + if (typeof event === "function") { + event = new event(type, params); + } else { + event = window.document.createEvent("Event"); + if (params) event.initEvent(type, params.bubbles, params.cancelable), event.detail = params.detail; + else event.initEvent(type, false, false); + } + + node.dispatchEvent(event); +} + +function dispatchConstant(type, params) { + return function() { + return dispatchEvent(this, type, params); + }; +} + +function dispatchFunction(type, params) { + return function() { + return dispatchEvent(this, type, params.apply(this, arguments)); + }; +} + +function selection_dispatch(type, params) { + return this.each((typeof params === "function" + ? dispatchFunction + : dispatchConstant)(type, params)); +} + +function* selection_iterator() { + for (var groups = this._groups, j = 0, m = groups.length; j < m; ++j) { + for (var group = groups[j], i = 0, n = group.length, node; i < n; ++i) { + if (node = group[i]) yield node; + } + } +} + +var root$1 = [null]; + +function Selection$1(groups, parents) { + this._groups = groups; + this._parents = parents; +} + +function selection() { + return new Selection$1([[document.documentElement]], root$1); +} + +function selection_selection() { + return this; +} + +Selection$1.prototype = selection.prototype = { + constructor: Selection$1, + select: selection_select, + selectAll: selection_selectAll, + selectChild: selection_selectChild, + selectChildren: selection_selectChildren, + filter: selection_filter, + data: selection_data, + enter: selection_enter, + exit: selection_exit, + join: selection_join, + merge: selection_merge, + selection: selection_selection, + order: selection_order, + sort: selection_sort, + call: selection_call, + nodes: selection_nodes, + node: selection_node, + size: selection_size, + empty: selection_empty, + each: selection_each, + attr: selection_attr, + style: selection_style, + property: selection_property, + classed: selection_classed, + text: selection_text, + html: selection_html, + raise: selection_raise, + lower: selection_lower, + append: selection_append, + insert: selection_insert, + remove: selection_remove, + clone: selection_clone, + datum: selection_datum, + on: selection_on, + dispatch: selection_dispatch, + [Symbol.iterator]: selection_iterator +}; + +function select(selector) { + return typeof selector === "string" + ? new Selection$1([[document.querySelector(selector)]], [document.documentElement]) + : new Selection$1([[selector]], root$1); +} + +function create$1(name) { + return select(creator(name).call(document.documentElement)); +} + +var nextId = 0; + +function local$1() { + return new Local; +} + +function Local() { + this._ = "@" + (++nextId).toString(36); +} + +Local.prototype = local$1.prototype = { + constructor: Local, + get: function(node) { + var id = this._; + while (!(id in node)) if (!(node = node.parentNode)) return; + return node[id]; + }, + set: function(node, value) { + return node[this._] = value; + }, + remove: function(node) { + return this._ in node && delete node[this._]; + }, + toString: function() { + return this._; + } +}; + +function sourceEvent(event) { + let sourceEvent; + while (sourceEvent = event.sourceEvent) event = sourceEvent; + return event; +} + +function pointer(event, node) { + event = sourceEvent(event); + if (node === undefined) node = event.currentTarget; + if (node) { + var svg = node.ownerSVGElement || node; + if (svg.createSVGPoint) { + var point = svg.createSVGPoint(); + point.x = event.clientX, point.y = event.clientY; + point = point.matrixTransform(node.getScreenCTM().inverse()); + return [point.x, point.y]; + } + if (node.getBoundingClientRect) { + var rect = node.getBoundingClientRect(); + return [event.clientX - rect.left - node.clientLeft, event.clientY - rect.top - node.clientTop]; + } + } + return [event.pageX, event.pageY]; +} + +function pointers(events, node) { + if (events.target) { // i.e., instanceof Event, not TouchList or iterable + events = sourceEvent(events); + if (node === undefined) node = events.currentTarget; + events = events.touches || [events]; + } + return Array.from(events, event => pointer(event, node)); +} + +function selectAll(selector) { + return typeof selector === "string" + ? new Selection$1([document.querySelectorAll(selector)], [document.documentElement]) + : new Selection$1([array$4(selector)], root$1); +} + +// These are typically used in conjunction with noevent to ensure that we can +// preventDefault on the event. +const nonpassive = {passive: false}; +const nonpassivecapture = {capture: true, passive: false}; + +function nopropagation$2(event) { + event.stopImmediatePropagation(); +} + +function noevent$2(event) { + event.preventDefault(); + event.stopImmediatePropagation(); +} + +function dragDisable(view) { + var root = view.document.documentElement, + selection = select(view).on("dragstart.drag", noevent$2, nonpassivecapture); + if ("onselectstart" in root) { + selection.on("selectstart.drag", noevent$2, nonpassivecapture); + } else { + root.__noselect = root.style.MozUserSelect; + root.style.MozUserSelect = "none"; + } +} + +function yesdrag(view, noclick) { + var root = view.document.documentElement, + selection = select(view).on("dragstart.drag", null); + if (noclick) { + selection.on("click.drag", noevent$2, nonpassivecapture); + setTimeout(function() { selection.on("click.drag", null); }, 0); + } + if ("onselectstart" in root) { + selection.on("selectstart.drag", null); + } else { + root.style.MozUserSelect = root.__noselect; + delete root.__noselect; + } +} + +var constant$9 = x => () => x; + +function DragEvent(type, { + sourceEvent, + subject, + target, + identifier, + active, + x, y, dx, dy, + dispatch +}) { + Object.defineProperties(this, { + type: {value: type, enumerable: true, configurable: true}, + sourceEvent: {value: sourceEvent, enumerable: true, configurable: true}, + subject: {value: subject, enumerable: true, configurable: true}, + target: {value: target, enumerable: true, configurable: true}, + identifier: {value: identifier, enumerable: true, configurable: true}, + active: {value: active, enumerable: true, configurable: true}, + x: {value: x, enumerable: true, configurable: true}, + y: {value: y, enumerable: true, configurable: true}, + dx: {value: dx, enumerable: true, configurable: true}, + dy: {value: dy, enumerable: true, configurable: true}, + _: {value: dispatch} + }); +} + +DragEvent.prototype.on = function() { + var value = this._.on.apply(this._, arguments); + return value === this._ ? this : value; +}; + +// Ignore right-click, since that should open the context menu. +function defaultFilter$2(event) { + return !event.ctrlKey && !event.button; +} + +function defaultContainer() { + return this.parentNode; +} + +function defaultSubject(event, d) { + return d == null ? {x: event.x, y: event.y} : d; +} + +function defaultTouchable$2() { + return navigator.maxTouchPoints || ("ontouchstart" in this); +} + +function drag() { + var filter = defaultFilter$2, + container = defaultContainer, + subject = defaultSubject, + touchable = defaultTouchable$2, + gestures = {}, + listeners = dispatch("start", "drag", "end"), + active = 0, + mousedownx, + mousedowny, + mousemoving, + touchending, + clickDistance2 = 0; + + function drag(selection) { + selection + .on("mousedown.drag", mousedowned) + .filter(touchable) + .on("touchstart.drag", touchstarted) + .on("touchmove.drag", touchmoved, nonpassive) + .on("touchend.drag touchcancel.drag", touchended) + .style("touch-action", "none") + .style("-webkit-tap-highlight-color", "rgba(0,0,0,0)"); + } + + function mousedowned(event, d) { + if (touchending || !filter.call(this, event, d)) return; + var gesture = beforestart(this, container.call(this, event, d), event, d, "mouse"); + if (!gesture) return; + select(event.view) + .on("mousemove.drag", mousemoved, nonpassivecapture) + .on("mouseup.drag", mouseupped, nonpassivecapture); + dragDisable(event.view); + nopropagation$2(event); + mousemoving = false; + mousedownx = event.clientX; + mousedowny = event.clientY; + gesture("start", event); + } + + function mousemoved(event) { + noevent$2(event); + if (!mousemoving) { + var dx = event.clientX - mousedownx, dy = event.clientY - mousedowny; + mousemoving = dx * dx + dy * dy > clickDistance2; + } + gestures.mouse("drag", event); + } + + function mouseupped(event) { + select(event.view).on("mousemove.drag mouseup.drag", null); + yesdrag(event.view, mousemoving); + noevent$2(event); + gestures.mouse("end", event); + } + + function touchstarted(event, d) { + if (!filter.call(this, event, d)) return; + var touches = event.changedTouches, + c = container.call(this, event, d), + n = touches.length, i, gesture; + + for (i = 0; i < n; ++i) { + if (gesture = beforestart(this, c, event, d, touches[i].identifier, touches[i])) { + nopropagation$2(event); + gesture("start", event, touches[i]); + } + } + } + + function touchmoved(event) { + var touches = event.changedTouches, + n = touches.length, i, gesture; + + for (i = 0; i < n; ++i) { + if (gesture = gestures[touches[i].identifier]) { + noevent$2(event); + gesture("drag", event, touches[i]); + } + } + } + + function touchended(event) { + var touches = event.changedTouches, + n = touches.length, i, gesture; + + if (touchending) clearTimeout(touchending); + touchending = setTimeout(function() { touchending = null; }, 500); // Ghost clicks are delayed! + for (i = 0; i < n; ++i) { + if (gesture = gestures[touches[i].identifier]) { + nopropagation$2(event); + gesture("end", event, touches[i]); + } + } + } + + function beforestart(that, container, event, d, identifier, touch) { + var dispatch = listeners.copy(), + p = pointer(touch || event, container), dx, dy, + s; + + if ((s = subject.call(that, new DragEvent("beforestart", { + sourceEvent: event, + target: drag, + identifier, + active, + x: p[0], + y: p[1], + dx: 0, + dy: 0, + dispatch + }), d)) == null) return; + + dx = s.x - p[0] || 0; + dy = s.y - p[1] || 0; + + return function gesture(type, event, touch) { + var p0 = p, n; + switch (type) { + case "start": gestures[identifier] = gesture, n = active++; break; + case "end": delete gestures[identifier], --active; // falls through + case "drag": p = pointer(touch || event, container), n = active; break; + } + dispatch.call( + type, + that, + new DragEvent(type, { + sourceEvent: event, + subject: s, + target: drag, + identifier, + active: n, + x: p[0] + dx, + y: p[1] + dy, + dx: p[0] - p0[0], + dy: p[1] - p0[1], + dispatch + }), + d + ); + }; + } + + drag.filter = function(_) { + return arguments.length ? (filter = typeof _ === "function" ? _ : constant$9(!!_), drag) : filter; + }; + + drag.container = function(_) { + return arguments.length ? (container = typeof _ === "function" ? _ : constant$9(_), drag) : container; + }; + + drag.subject = function(_) { + return arguments.length ? (subject = typeof _ === "function" ? _ : constant$9(_), drag) : subject; + }; + + drag.touchable = function(_) { + return arguments.length ? (touchable = typeof _ === "function" ? _ : constant$9(!!_), drag) : touchable; + }; + + drag.on = function() { + var value = listeners.on.apply(listeners, arguments); + return value === listeners ? drag : value; + }; + + drag.clickDistance = function(_) { + return arguments.length ? (clickDistance2 = (_ = +_) * _, drag) : Math.sqrt(clickDistance2); + }; + + return drag; +} + +function define(constructor, factory, prototype) { + constructor.prototype = factory.prototype = prototype; + prototype.constructor = constructor; +} + +function extend(parent, definition) { + var prototype = Object.create(parent.prototype); + for (var key in definition) prototype[key] = definition[key]; + return prototype; +} + +function Color() {} + +var darker = 0.7; +var brighter = 1 / darker; + +var reI = "\\s*([+-]?\\d+)\\s*", + reN = "\\s*([+-]?\\d*\\.?\\d+(?:[eE][+-]?\\d+)?)\\s*", + reP = "\\s*([+-]?\\d*\\.?\\d+(?:[eE][+-]?\\d+)?)%\\s*", + reHex = /^#([0-9a-f]{3,8})$/, + reRgbInteger = new RegExp("^rgb\\(" + [reI, reI, reI] + "\\)$"), + reRgbPercent = new RegExp("^rgb\\(" + [reP, reP, reP] + "\\)$"), + reRgbaInteger = new RegExp("^rgba\\(" + [reI, reI, reI, reN] + "\\)$"), + reRgbaPercent = new RegExp("^rgba\\(" + [reP, reP, reP, reN] + "\\)$"), + reHslPercent = new RegExp("^hsl\\(" + [reN, reP, reP] + "\\)$"), + reHslaPercent = new RegExp("^hsla\\(" + [reN, reP, reP, reN] + "\\)$"); + +var named = { + aliceblue: 0xf0f8ff, + antiquewhite: 0xfaebd7, + aqua: 0x00ffff, + aquamarine: 0x7fffd4, + azure: 0xf0ffff, + beige: 0xf5f5dc, + bisque: 0xffe4c4, + black: 0x000000, + blanchedalmond: 0xffebcd, + blue: 0x0000ff, + blueviolet: 0x8a2be2, + brown: 0xa52a2a, + burlywood: 0xdeb887, + cadetblue: 0x5f9ea0, + chartreuse: 0x7fff00, + chocolate: 0xd2691e, + coral: 0xff7f50, + cornflowerblue: 0x6495ed, + cornsilk: 0xfff8dc, + crimson: 0xdc143c, + cyan: 0x00ffff, + darkblue: 0x00008b, + darkcyan: 0x008b8b, + darkgoldenrod: 0xb8860b, + darkgray: 0xa9a9a9, + darkgreen: 0x006400, + darkgrey: 0xa9a9a9, + darkkhaki: 0xbdb76b, + darkmagenta: 0x8b008b, + darkolivegreen: 0x556b2f, + darkorange: 0xff8c00, + darkorchid: 0x9932cc, + darkred: 0x8b0000, + darksalmon: 0xe9967a, + darkseagreen: 0x8fbc8f, + darkslateblue: 0x483d8b, + darkslategray: 0x2f4f4f, + darkslategrey: 0x2f4f4f, + darkturquoise: 0x00ced1, + darkviolet: 0x9400d3, + deeppink: 0xff1493, + deepskyblue: 0x00bfff, + dimgray: 0x696969, + dimgrey: 0x696969, + dodgerblue: 0x1e90ff, + firebrick: 0xb22222, + floralwhite: 0xfffaf0, + forestgreen: 0x228b22, + fuchsia: 0xff00ff, + gainsboro: 0xdcdcdc, + ghostwhite: 0xf8f8ff, + gold: 0xffd700, + goldenrod: 0xdaa520, + gray: 0x808080, + green: 0x008000, + greenyellow: 0xadff2f, + grey: 0x808080, + honeydew: 0xf0fff0, + hotpink: 0xff69b4, + indianred: 0xcd5c5c, + indigo: 0x4b0082, + ivory: 0xfffff0, + khaki: 0xf0e68c, + lavender: 0xe6e6fa, + lavenderblush: 0xfff0f5, + lawngreen: 0x7cfc00, + lemonchiffon: 0xfffacd, + lightblue: 0xadd8e6, + lightcoral: 0xf08080, + lightcyan: 0xe0ffff, + lightgoldenrodyellow: 0xfafad2, + lightgray: 0xd3d3d3, + lightgreen: 0x90ee90, + lightgrey: 0xd3d3d3, + lightpink: 0xffb6c1, + lightsalmon: 0xffa07a, + lightseagreen: 0x20b2aa, + lightskyblue: 0x87cefa, + lightslategray: 0x778899, + lightslategrey: 0x778899, + lightsteelblue: 0xb0c4de, + lightyellow: 0xffffe0, + lime: 0x00ff00, + limegreen: 0x32cd32, + linen: 0xfaf0e6, + magenta: 0xff00ff, + maroon: 0x800000, + mediumaquamarine: 0x66cdaa, + mediumblue: 0x0000cd, + mediumorchid: 0xba55d3, + mediumpurple: 0x9370db, + mediumseagreen: 0x3cb371, + mediumslateblue: 0x7b68ee, + mediumspringgreen: 0x00fa9a, + mediumturquoise: 0x48d1cc, + mediumvioletred: 0xc71585, + midnightblue: 0x191970, + mintcream: 0xf5fffa, + mistyrose: 0xffe4e1, + moccasin: 0xffe4b5, + navajowhite: 0xffdead, + navy: 0x000080, + oldlace: 0xfdf5e6, + olive: 0x808000, + olivedrab: 0x6b8e23, + orange: 0xffa500, + orangered: 0xff4500, + orchid: 0xda70d6, + palegoldenrod: 0xeee8aa, + palegreen: 0x98fb98, + paleturquoise: 0xafeeee, + palevioletred: 0xdb7093, + papayawhip: 0xffefd5, + peachpuff: 0xffdab9, + peru: 0xcd853f, + pink: 0xffc0cb, + plum: 0xdda0dd, + powderblue: 0xb0e0e6, + purple: 0x800080, + rebeccapurple: 0x663399, + red: 0xff0000, + rosybrown: 0xbc8f8f, + royalblue: 0x4169e1, + saddlebrown: 0x8b4513, + salmon: 0xfa8072, + sandybrown: 0xf4a460, + seagreen: 0x2e8b57, + seashell: 0xfff5ee, + sienna: 0xa0522d, + silver: 0xc0c0c0, + skyblue: 0x87ceeb, + slateblue: 0x6a5acd, + slategray: 0x708090, + slategrey: 0x708090, + snow: 0xfffafa, + springgreen: 0x00ff7f, + steelblue: 0x4682b4, + tan: 0xd2b48c, + teal: 0x008080, + thistle: 0xd8bfd8, + tomato: 0xff6347, + turquoise: 0x40e0d0, + violet: 0xee82ee, + wheat: 0xf5deb3, + white: 0xffffff, + whitesmoke: 0xf5f5f5, + yellow: 0xffff00, + yellowgreen: 0x9acd32 +}; + +define(Color, color, { + copy: function(channels) { + return Object.assign(new this.constructor, this, channels); + }, + displayable: function() { + return this.rgb().displayable(); + }, + hex: color_formatHex, // Deprecated! Use color.formatHex. + formatHex: color_formatHex, + formatHsl: color_formatHsl, + formatRgb: color_formatRgb, + toString: color_formatRgb +}); + +function color_formatHex() { + return this.rgb().formatHex(); +} + +function color_formatHsl() { + return hslConvert(this).formatHsl(); +} + +function color_formatRgb() { + return this.rgb().formatRgb(); +} + +function color(format) { + var m, l; + format = (format + "").trim().toLowerCase(); + return (m = reHex.exec(format)) ? (l = m[1].length, m = parseInt(m[1], 16), l === 6 ? rgbn(m) // #ff0000 + : l === 3 ? new Rgb((m >> 8 & 0xf) | (m >> 4 & 0xf0), (m >> 4 & 0xf) | (m & 0xf0), ((m & 0xf) << 4) | (m & 0xf), 1) // #f00 + : l === 8 ? rgba(m >> 24 & 0xff, m >> 16 & 0xff, m >> 8 & 0xff, (m & 0xff) / 0xff) // #ff000000 + : l === 4 ? rgba((m >> 12 & 0xf) | (m >> 8 & 0xf0), (m >> 8 & 0xf) | (m >> 4 & 0xf0), (m >> 4 & 0xf) | (m & 0xf0), (((m & 0xf) << 4) | (m & 0xf)) / 0xff) // #f000 + : null) // invalid hex + : (m = reRgbInteger.exec(format)) ? new Rgb(m[1], m[2], m[3], 1) // rgb(255, 0, 0) + : (m = reRgbPercent.exec(format)) ? new Rgb(m[1] * 255 / 100, m[2] * 255 / 100, m[3] * 255 / 100, 1) // rgb(100%, 0%, 0%) + : (m = reRgbaInteger.exec(format)) ? rgba(m[1], m[2], m[3], m[4]) // rgba(255, 0, 0, 1) + : (m = reRgbaPercent.exec(format)) ? rgba(m[1] * 255 / 100, m[2] * 255 / 100, m[3] * 255 / 100, m[4]) // rgb(100%, 0%, 0%, 1) + : (m = reHslPercent.exec(format)) ? hsla(m[1], m[2] / 100, m[3] / 100, 1) // hsl(120, 50%, 50%) + : (m = reHslaPercent.exec(format)) ? hsla(m[1], m[2] / 100, m[3] / 100, m[4]) // hsla(120, 50%, 50%, 1) + : named.hasOwnProperty(format) ? rgbn(named[format]) // eslint-disable-line no-prototype-builtins + : format === "transparent" ? new Rgb(NaN, NaN, NaN, 0) + : null; +} + +function rgbn(n) { + return new Rgb(n >> 16 & 0xff, n >> 8 & 0xff, n & 0xff, 1); +} + +function rgba(r, g, b, a) { + if (a <= 0) r = g = b = NaN; + return new Rgb(r, g, b, a); +} + +function rgbConvert(o) { + if (!(o instanceof Color)) o = color(o); + if (!o) return new Rgb; + o = o.rgb(); + return new Rgb(o.r, o.g, o.b, o.opacity); +} + +function rgb(r, g, b, opacity) { + return arguments.length === 1 ? rgbConvert(r) : new Rgb(r, g, b, opacity == null ? 1 : opacity); +} + +function Rgb(r, g, b, opacity) { + this.r = +r; + this.g = +g; + this.b = +b; + this.opacity = +opacity; +} + +define(Rgb, rgb, extend(Color, { + brighter: function(k) { + k = k == null ? brighter : Math.pow(brighter, k); + return new Rgb(this.r * k, this.g * k, this.b * k, this.opacity); + }, + darker: function(k) { + k = k == null ? darker : Math.pow(darker, k); + return new Rgb(this.r * k, this.g * k, this.b * k, this.opacity); + }, + rgb: function() { + return this; + }, + displayable: function() { + return (-0.5 <= this.r && this.r < 255.5) + && (-0.5 <= this.g && this.g < 255.5) + && (-0.5 <= this.b && this.b < 255.5) + && (0 <= this.opacity && this.opacity <= 1); + }, + hex: rgb_formatHex, // Deprecated! Use color.formatHex. + formatHex: rgb_formatHex, + formatRgb: rgb_formatRgb, + toString: rgb_formatRgb +})); + +function rgb_formatHex() { + return "#" + hex(this.r) + hex(this.g) + hex(this.b); +} + +function rgb_formatRgb() { + var a = this.opacity; a = isNaN(a) ? 1 : Math.max(0, Math.min(1, a)); + return (a === 1 ? "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)) + + (a === 1 ? ")" : ", " + a + ")"); +} + +function hex(value) { + value = Math.max(0, Math.min(255, Math.round(value) || 0)); + return (value < 16 ? "0" : "") + value.toString(16); +} + +function hsla(h, s, l, a) { + if (a <= 0) h = s = l = NaN; + else if (l <= 0 || l >= 1) h = s = NaN; + else if (s <= 0) h = NaN; + return new Hsl(h, s, l, a); +} + +function hslConvert(o) { + if (o instanceof Hsl) return new Hsl(o.h, o.s, o.l, o.opacity); + if (!(o instanceof Color)) o = color(o); + if (!o) return new Hsl; + if (o instanceof Hsl) return o; + o = o.rgb(); + var r = o.r / 255, + g = o.g / 255, + b = o.b / 255, + min = Math.min(r, g, b), + max = Math.max(r, g, b), + h = NaN, + s = max - min, + l = (max + min) / 2; + if (s) { + if (r === max) h = (g - b) / s + (g < b) * 6; + else if (g === max) h = (b - r) / s + 2; + else h = (r - g) / s + 4; + s /= l < 0.5 ? max + min : 2 - max - min; + h *= 60; + } else { + s = l > 0 && l < 1 ? 0 : h; + } + return new Hsl(h, s, l, o.opacity); +} + +function hsl$2(h, s, l, opacity) { + return arguments.length === 1 ? hslConvert(h) : new Hsl(h, s, l, opacity == null ? 1 : opacity); +} + +function Hsl(h, s, l, opacity) { + this.h = +h; + this.s = +s; + this.l = +l; + this.opacity = +opacity; +} + +define(Hsl, hsl$2, extend(Color, { + brighter: function(k) { + k = k == null ? brighter : Math.pow(brighter, k); + return new Hsl(this.h, this.s, this.l * k, this.opacity); + }, + darker: function(k) { + k = k == null ? darker : Math.pow(darker, k); + return new Hsl(this.h, this.s, this.l * k, this.opacity); + }, + rgb: function() { + var h = this.h % 360 + (this.h < 0) * 360, + s = isNaN(h) || isNaN(this.s) ? 0 : this.s, + l = this.l, + m2 = l + (l < 0.5 ? l : 1 - l) * s, + m1 = 2 * l - m2; + return new Rgb( + hsl2rgb(h >= 240 ? h - 240 : h + 120, m1, m2), + hsl2rgb(h, m1, m2), + hsl2rgb(h < 120 ? h + 240 : h - 120, m1, m2), + 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 a = this.opacity; a = isNaN(a) ? 1 : Math.max(0, Math.min(1, a)); + return (a === 1 ? "hsl(" : "hsla(") + + (this.h || 0) + ", " + + (this.s || 0) * 100 + "%, " + + (this.l || 0) * 100 + "%" + + (a === 1 ? ")" : ", " + a + ")"); + } +})); + +/* From FvD 13.37, CSS Color Module Level 3 */ +function hsl2rgb(h, m1, m2) { + return (h < 60 ? m1 + (m2 - m1) * h / 60 + : h < 180 ? m2 + : h < 240 ? m1 + (m2 - m1) * (240 - h) / 60 + : m1) * 255; +} + +const radians$1 = Math.PI / 180; +const degrees$2 = 180 / Math.PI; + +// https://observablehq.com/@mbostock/lab-and-rgb +const K = 18, + Xn = 0.96422, + Yn = 1, + Zn = 0.82521, + t0$1 = 4 / 29, + t1$1 = 6 / 29, + t2 = 3 * t1$1 * t1$1, + t3 = t1$1 * t1$1 * t1$1; + +function labConvert(o) { + if (o instanceof Lab) return new Lab(o.l, o.a, o.b, o.opacity); + if (o instanceof Hcl) return hcl2lab(o); + if (!(o instanceof Rgb)) o = rgbConvert(o); + var r = rgb2lrgb(o.r), + g = rgb2lrgb(o.g), + b = rgb2lrgb(o.b), + y = xyz2lab((0.2225045 * r + 0.7168786 * g + 0.0606169 * b) / Yn), x, z; + if (r === g && g === b) x = z = y; else { + x = xyz2lab((0.4360747 * r + 0.3850649 * g + 0.1430804 * b) / Xn); + z = xyz2lab((0.0139322 * r + 0.0971045 * g + 0.7141733 * b) / Zn); + } + return new Lab(116 * y - 16, 500 * (x - y), 200 * (y - z), o.opacity); +} + +function gray(l, opacity) { + return new Lab(l, 0, 0, opacity == null ? 1 : opacity); +} + +function lab$1(l, a, b, opacity) { + return arguments.length === 1 ? labConvert(l) : new Lab(l, a, b, opacity == null ? 1 : opacity); +} + +function Lab(l, a, b, opacity) { + this.l = +l; + this.a = +a; + this.b = +b; + this.opacity = +opacity; +} + +define(Lab, lab$1, extend(Color, { + brighter: function(k) { + return new Lab(this.l + K * (k == null ? 1 : k), this.a, this.b, this.opacity); + }, + darker: function(k) { + return new Lab(this.l - K * (k == null ? 1 : k), this.a, this.b, this.opacity); + }, + rgb: function() { + var y = (this.l + 16) / 116, + x = isNaN(this.a) ? y : y + this.a / 500, + z = isNaN(this.b) ? y : y - this.b / 200; + x = Xn * lab2xyz(x); + y = Yn * lab2xyz(y); + z = Zn * lab2xyz(z); + return new Rgb( + lrgb2rgb( 3.1338561 * x - 1.6168667 * y - 0.4906146 * z), + lrgb2rgb(-0.9787684 * x + 1.9161415 * y + 0.0334540 * z), + lrgb2rgb( 0.0719453 * x - 0.2289914 * y + 1.4052427 * z), + this.opacity + ); + } +})); + +function xyz2lab(t) { + return t > t3 ? Math.pow(t, 1 / 3) : t / t2 + t0$1; +} + +function lab2xyz(t) { + return t > t1$1 ? t * t * t : t2 * (t - t0$1); +} + +function lrgb2rgb(x) { + return 255 * (x <= 0.0031308 ? 12.92 * x : 1.055 * Math.pow(x, 1 / 2.4) - 0.055); +} + +function rgb2lrgb(x) { + return (x /= 255) <= 0.04045 ? x / 12.92 : Math.pow((x + 0.055) / 1.055, 2.4); +} + +function hclConvert(o) { + if (o instanceof Hcl) return new Hcl(o.h, o.c, o.l, o.opacity); + if (!(o instanceof Lab)) o = labConvert(o); + if (o.a === 0 && o.b === 0) return new Hcl(NaN, 0 < o.l && o.l < 100 ? 0 : NaN, o.l, o.opacity); + var h = Math.atan2(o.b, o.a) * degrees$2; + return new Hcl(h < 0 ? h + 360 : h, Math.sqrt(o.a * o.a + o.b * o.b), o.l, o.opacity); +} + +function lch(l, c, h, opacity) { + return arguments.length === 1 ? hclConvert(l) : new Hcl(h, c, l, opacity == null ? 1 : opacity); +} + +function hcl$2(h, c, l, opacity) { + return arguments.length === 1 ? hclConvert(h) : new Hcl(h, c, l, opacity == null ? 1 : opacity); +} + +function Hcl(h, c, l, opacity) { + this.h = +h; + this.c = +c; + this.l = +l; + this.opacity = +opacity; +} + +function hcl2lab(o) { + if (isNaN(o.h)) return new Lab(o.l, 0, 0, o.opacity); + var h = o.h * radians$1; + return new Lab(o.l, Math.cos(h) * o.c, Math.sin(h) * o.c, o.opacity); +} + +define(Hcl, hcl$2, extend(Color, { + brighter: function(k) { + return new Hcl(this.h, this.c, this.l + K * (k == null ? 1 : k), this.opacity); + }, + darker: function(k) { + return new Hcl(this.h, this.c, this.l - K * (k == null ? 1 : k), this.opacity); + }, + rgb: function() { + return hcl2lab(this).rgb(); + } +})); + +var A = -0.14861, + B$1 = +1.78277, + C = -0.29227, + D$1 = -0.90649, + E = +1.97294, + ED = E * D$1, + EB = E * B$1, + BC_DA = B$1 * C - D$1 * A; + +function cubehelixConvert(o) { + if (o instanceof Cubehelix) return new Cubehelix(o.h, o.s, o.l, o.opacity); + if (!(o instanceof Rgb)) o = rgbConvert(o); + var r = o.r / 255, + g = o.g / 255, + b = o.b / 255, + l = (BC_DA * b + ED * r - EB * g) / (BC_DA + ED - EB), + bl = b - l, + k = (E * (g - l) - C * bl) / D$1, + s = Math.sqrt(k * k + bl * bl) / (E * l * (1 - l)), // NaN if l=0 or l=1 + h = s ? Math.atan2(k, bl) * degrees$2 - 120 : NaN; + return new Cubehelix(h < 0 ? h + 360 : h, s, l, o.opacity); +} + +function cubehelix$3(h, s, l, opacity) { + return arguments.length === 1 ? cubehelixConvert(h) : new Cubehelix(h, s, l, opacity == null ? 1 : opacity); +} + +function Cubehelix(h, s, l, opacity) { + this.h = +h; + this.s = +s; + this.l = +l; + this.opacity = +opacity; +} + +define(Cubehelix, cubehelix$3, extend(Color, { + brighter: function(k) { + k = k == null ? brighter : Math.pow(brighter, k); + return new Cubehelix(this.h, this.s, this.l * k, this.opacity); + }, + darker: function(k) { + k = k == null ? darker : Math.pow(darker, k); + return new Cubehelix(this.h, this.s, this.l * k, this.opacity); + }, + rgb: function() { + var h = isNaN(this.h) ? 0 : (this.h + 120) * radians$1, + l = +this.l, + a = isNaN(this.s) ? 0 : this.s * l * (1 - l), + cosh = Math.cos(h), + sinh = Math.sin(h); + return new Rgb( + 255 * (l + a * (A * cosh + B$1 * sinh)), + 255 * (l + a * (C * cosh + D$1 * sinh)), + 255 * (l + a * (E * cosh)), + this.opacity + ); + } +})); + +function basis$1(t1, v0, v1, v2, v3) { + var t2 = t1 * t1, t3 = t2 * t1; + return ((1 - 3 * t1 + 3 * t2 - t3) * v0 + + (4 - 6 * t2 + 3 * t3) * v1 + + (1 + 3 * t1 + 3 * t2 - 3 * t3) * v2 + + t3 * v3) / 6; +} + +function basis$2(values) { + var n = values.length - 1; + return function(t) { + var i = t <= 0 ? (t = 0) : t >= 1 ? (t = 1, n - 1) : Math.floor(t * n), + v1 = values[i], + v2 = values[i + 1], + v0 = i > 0 ? values[i - 1] : 2 * v1 - v2, + v3 = i < n - 1 ? values[i + 2] : 2 * v2 - v1; + return basis$1((t - i / n) * n, v0, v1, v2, v3); + }; +} + +function basisClosed$1(values) { + var n = values.length; + return function(t) { + var i = Math.floor(((t %= 1) < 0 ? ++t : t) * n), + v0 = values[(i + n - 1) % n], + v1 = values[i % n], + v2 = values[(i + 1) % n], + v3 = values[(i + 2) % n]; + return basis$1((t - i / n) * n, v0, v1, v2, v3); + }; +} + +var constant$8 = x => () => x; + +function linear$2(a, d) { + return function(t) { + return a + t * d; + }; +} + +function exponential$1(a, b, y) { + return a = Math.pow(a, y), b = Math.pow(b, y) - a, y = 1 / y, function(t) { + return Math.pow(a + t * b, y); + }; +} + +function hue$1(a, b) { + var d = b - a; + return d ? linear$2(a, d > 180 || d < -180 ? d - 360 * Math.round(d / 360) : d) : constant$8(isNaN(a) ? b : a); +} + +function gamma$1(y) { + return (y = +y) === 1 ? nogamma : function(a, b) { + return b - a ? exponential$1(a, b, y) : constant$8(isNaN(a) ? b : a); + }; +} + +function nogamma(a, b) { + var d = b - a; + return d ? linear$2(a, d) : constant$8(isNaN(a) ? b : a); +} + +var interpolateRgb = (function rgbGamma(y) { + var color = gamma$1(y); + + function rgb$1(start, end) { + var r = color((start = rgb(start)).r, (end = rgb(end)).r), + g = color(start.g, end.g), + b = color(start.b, end.b), + opacity = nogamma(start.opacity, end.opacity); + return function(t) { + start.r = r(t); + start.g = g(t); + start.b = b(t); + start.opacity = opacity(t); + return start + ""; + }; + } + + rgb$1.gamma = rgbGamma; + + return rgb$1; +})(1); + +function rgbSpline(spline) { + return function(colors) { + var n = colors.length, + r = new Array(n), + g = new Array(n), + b = new Array(n), + i, color; + for (i = 0; i < n; ++i) { + color = rgb(colors[i]); + r[i] = color.r || 0; + g[i] = color.g || 0; + b[i] = color.b || 0; + } + r = spline(r); + g = spline(g); + b = spline(b); + color.opacity = 1; + return function(t) { + color.r = r(t); + color.g = g(t); + color.b = b(t); + return color + ""; + }; + }; +} + +var rgbBasis = rgbSpline(basis$2); +var rgbBasisClosed = rgbSpline(basisClosed$1); + +function numberArray(a, b) { + if (!b) b = []; + var n = a ? Math.min(b.length, a.length) : 0, + c = b.slice(), + i; + return function(t) { + for (i = 0; i < n; ++i) c[i] = a[i] * (1 - t) + b[i] * t; + return c; + }; +} + +function isNumberArray(x) { + return ArrayBuffer.isView(x) && !(x instanceof DataView); +} + +function array$3(a, b) { + return (isNumberArray(b) ? numberArray : genericArray)(a, b); +} + +function genericArray(a, b) { + var nb = b ? b.length : 0, + na = a ? Math.min(nb, a.length) : 0, + x = new Array(na), + c = new Array(nb), + i; + + for (i = 0; i < na; ++i) x[i] = interpolate$2(a[i], b[i]); + for (; i < nb; ++i) c[i] = b[i]; + + return function(t) { + for (i = 0; i < na; ++i) c[i] = x[i](t); + return c; + }; +} + +function date$1(a, b) { + var d = new Date; + return a = +a, b = +b, function(t) { + return d.setTime(a * (1 - t) + b * t), d; + }; +} + +function interpolateNumber(a, b) { + return a = +a, b = +b, function(t) { + return a * (1 - t) + b * t; + }; +} + +function object$1(a, b) { + var i = {}, + c = {}, + k; + + if (a === null || typeof a !== "object") a = {}; + if (b === null || typeof b !== "object") b = {}; + + for (k in b) { + if (k in a) { + i[k] = interpolate$2(a[k], b[k]); + } else { + c[k] = b[k]; + } + } + + return function(t) { + for (k in i) c[k] = i[k](t); + return c; + }; +} + +var reA = /[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g, + reB = new RegExp(reA.source, "g"); + +function zero(b) { + return function() { + return b; + }; +} + +function one(b) { + return function(t) { + return b(t) + ""; + }; +} + +function interpolateString(a, b) { + var bi = reA.lastIndex = reB.lastIndex = 0, // scan index for next number in b + am, // current match in a + bm, // current match in b + bs, // string preceding current number in b, if any + i = -1, // index in s + s = [], // string constants and placeholders + q = []; // number interpolators + + // Coerce inputs to strings. + a = a + "", b = b + ""; + + // Interpolate pairs of numbers in a & b. + while ((am = reA.exec(a)) + && (bm = reB.exec(b))) { + if ((bs = bm.index) > bi) { // a string precedes the next number in b + bs = b.slice(bi, bs); + if (s[i]) s[i] += bs; // coalesce with previous string + else s[++i] = bs; + } + if ((am = am[0]) === (bm = bm[0])) { // numbers in a & b match + if (s[i]) s[i] += bm; // coalesce with previous string + else s[++i] = bm; + } else { // interpolate non-matching numbers + s[++i] = null; + q.push({i: i, x: interpolateNumber(am, bm)}); + } + bi = reB.lastIndex; + } + + // Add remains of b. + if (bi < b.length) { + bs = b.slice(bi); + if (s[i]) s[i] += bs; // coalesce with previous string + else s[++i] = bs; + } + + // Special optimization for only a single match. + // Otherwise, interpolate each of the numbers and rejoin the string. + return s.length < 2 ? (q[0] + ? one(q[0].x) + : zero(b)) + : (b = q.length, function(t) { + for (var i = 0, o; i < b; ++i) s[(o = q[i]).i] = o.x(t); + return s.join(""); + }); +} + +function interpolate$2(a, b) { + var t = typeof b, c; + return b == null || t === "boolean" ? constant$8(b) + : (t === "number" ? interpolateNumber + : t === "string" ? ((c = color(b)) ? (b = c, interpolateRgb) : interpolateString) + : b instanceof color ? interpolateRgb + : b instanceof Date ? date$1 + : isNumberArray(b) ? numberArray + : Array.isArray(b) ? genericArray + : typeof b.valueOf !== "function" && typeof b.toString !== "function" || isNaN(b) ? object$1 + : interpolateNumber)(a, b); +} + +function discrete(range) { + var n = range.length; + return function(t) { + return range[Math.max(0, Math.min(n - 1, Math.floor(t * n)))]; + }; +} + +function hue(a, b) { + var i = hue$1(+a, +b); + return function(t) { + var x = i(t); + return x - 360 * Math.floor(x / 360); + }; +} + +function interpolateRound(a, b) { + return a = +a, b = +b, function(t) { + return Math.round(a * (1 - t) + b * t); + }; +} + +var degrees$1 = 180 / Math.PI; + +var identity$7 = { + translateX: 0, + translateY: 0, + rotate: 0, + skewX: 0, + scaleX: 1, + scaleY: 1 +}; + +function decompose(a, b, c, d, e, f) { + var scaleX, scaleY, skewX; + if (scaleX = Math.sqrt(a * a + b * b)) a /= scaleX, b /= scaleX; + if (skewX = a * c + b * d) c -= a * skewX, d -= b * skewX; + if (scaleY = Math.sqrt(c * c + d * d)) c /= scaleY, d /= scaleY, skewX /= scaleY; + if (a * d < b * c) a = -a, b = -b, skewX = -skewX, scaleX = -scaleX; + return { + translateX: e, + translateY: f, + rotate: Math.atan2(b, a) * degrees$1, + skewX: Math.atan(skewX) * degrees$1, + scaleX: scaleX, + scaleY: scaleY + }; +} + +var svgNode; + +/* eslint-disable no-undef */ +function parseCss(value) { + const m = new (typeof DOMMatrix === "function" ? DOMMatrix : WebKitCSSMatrix)(value + ""); + return m.isIdentity ? identity$7 : decompose(m.a, m.b, m.c, m.d, m.e, m.f); +} + +function parseSvg(value) { + if (value == null) return identity$7; + if (!svgNode) svgNode = document.createElementNS("http://www.w3.org/2000/svg", "g"); + svgNode.setAttribute("transform", value); + if (!(value = svgNode.transform.baseVal.consolidate())) return identity$7; + value = value.matrix; + return decompose(value.a, value.b, value.c, value.d, value.e, value.f); +} + +function interpolateTransform(parse, pxComma, pxParen, degParen) { + + function pop(s) { + return s.length ? s.pop() + " " : ""; + } + + function translate(xa, ya, xb, yb, s, q) { + if (xa !== xb || ya !== yb) { + var i = s.push("translate(", null, pxComma, null, pxParen); + q.push({i: i - 4, x: interpolateNumber(xa, xb)}, {i: i - 2, x: interpolateNumber(ya, yb)}); + } else if (xb || yb) { + s.push("translate(" + xb + pxComma + yb + pxParen); + } + } + + function rotate(a, b, s, q) { + if (a !== b) { + if (a - b > 180) b += 360; else if (b - a > 180) a += 360; // shortest path + q.push({i: s.push(pop(s) + "rotate(", null, degParen) - 2, x: interpolateNumber(a, b)}); + } else if (b) { + s.push(pop(s) + "rotate(" + b + degParen); + } + } + + function skewX(a, b, s, q) { + if (a !== b) { + q.push({i: s.push(pop(s) + "skewX(", null, degParen) - 2, x: interpolateNumber(a, b)}); + } else if (b) { + s.push(pop(s) + "skewX(" + b + degParen); + } + } + + function scale(xa, ya, xb, yb, s, q) { + if (xa !== xb || ya !== yb) { + var i = s.push(pop(s) + "scale(", null, ",", null, ")"); + q.push({i: i - 4, x: interpolateNumber(xa, xb)}, {i: i - 2, x: interpolateNumber(ya, yb)}); + } else if (xb !== 1 || yb !== 1) { + s.push(pop(s) + "scale(" + xb + "," + yb + ")"); + } + } + + return function(a, b) { + var s = [], // string constants and placeholders + q = []; // number interpolators + a = parse(a), b = parse(b); + translate(a.translateX, a.translateY, b.translateX, b.translateY, s, q); + rotate(a.rotate, b.rotate, s, q); + skewX(a.skewX, b.skewX, s, q); + scale(a.scaleX, a.scaleY, b.scaleX, b.scaleY, s, q); + a = b = null; // gc + return function(t) { + var i = -1, n = q.length, o; + while (++i < n) s[(o = q[i]).i] = o.x(t); + return s.join(""); + }; + }; +} + +var interpolateTransformCss = interpolateTransform(parseCss, "px, ", "px)", "deg)"); +var interpolateTransformSvg = interpolateTransform(parseSvg, ", ", ")", ")"); + +var epsilon2$1 = 1e-12; + +function cosh(x) { + return ((x = Math.exp(x)) + 1 / x) / 2; +} + +function sinh(x) { + return ((x = Math.exp(x)) - 1 / x) / 2; +} + +function tanh(x) { + return ((x = Math.exp(2 * x)) - 1) / (x + 1); +} + +var interpolateZoom = (function zoomRho(rho, rho2, rho4) { + + // p0 = [ux0, uy0, w0] + // p1 = [ux1, uy1, w1] + function zoom(p0, p1) { + var ux0 = p0[0], uy0 = p0[1], w0 = p0[2], + ux1 = p1[0], uy1 = p1[1], w1 = p1[2], + dx = ux1 - ux0, + dy = uy1 - uy0, + d2 = dx * dx + dy * dy, + i, + S; + + // Special case for u0 ≅ u1. + if (d2 < epsilon2$1) { + S = Math.log(w1 / w0) / rho; + i = function(t) { + return [ + ux0 + t * dx, + uy0 + t * dy, + w0 * Math.exp(rho * t * S) + ]; + }; + } + + // General case. + else { + var d1 = Math.sqrt(d2), + b0 = (w1 * w1 - w0 * w0 + rho4 * d2) / (2 * w0 * rho2 * d1), + b1 = (w1 * w1 - w0 * w0 - rho4 * d2) / (2 * w1 * rho2 * d1), + r0 = Math.log(Math.sqrt(b0 * b0 + 1) - b0), + r1 = Math.log(Math.sqrt(b1 * b1 + 1) - b1); + S = (r1 - r0) / rho; + i = function(t) { + var s = t * S, + coshr0 = cosh(r0), + u = w0 / (rho2 * d1) * (coshr0 * tanh(rho * s + r0) - sinh(r0)); + return [ + ux0 + u * dx, + uy0 + u * dy, + w0 * coshr0 / cosh(rho * s + r0) + ]; + }; + } + + i.duration = S * 1000 * rho / Math.SQRT2; + + return i; + } + + zoom.rho = function(_) { + var _1 = Math.max(1e-3, +_), _2 = _1 * _1, _4 = _2 * _2; + return zoomRho(_1, _2, _4); + }; + + return zoom; +})(Math.SQRT2, 2, 4); + +function hsl(hue) { + return function(start, end) { + var h = hue((start = hsl$2(start)).h, (end = hsl$2(end)).h), + s = nogamma(start.s, end.s), + l = nogamma(start.l, end.l), + opacity = nogamma(start.opacity, end.opacity); + return function(t) { + start.h = h(t); + start.s = s(t); + start.l = l(t); + start.opacity = opacity(t); + return start + ""; + }; + } +} + +var hsl$1 = hsl(hue$1); +var hslLong = hsl(nogamma); + +function lab(start, end) { + var l = nogamma((start = lab$1(start)).l, (end = lab$1(end)).l), + a = nogamma(start.a, end.a), + b = nogamma(start.b, end.b), + opacity = nogamma(start.opacity, end.opacity); + return function(t) { + start.l = l(t); + start.a = a(t); + start.b = b(t); + start.opacity = opacity(t); + return start + ""; + }; +} + +function hcl(hue) { + return function(start, end) { + var h = hue((start = hcl$2(start)).h, (end = hcl$2(end)).h), + c = nogamma(start.c, end.c), + l = nogamma(start.l, end.l), + opacity = nogamma(start.opacity, end.opacity); + return function(t) { + start.h = h(t); + start.c = c(t); + start.l = l(t); + start.opacity = opacity(t); + return start + ""; + }; + } +} + +var hcl$1 = hcl(hue$1); +var hclLong = hcl(nogamma); + +function cubehelix$1(hue) { + return (function cubehelixGamma(y) { + y = +y; + + function cubehelix(start, end) { + var h = hue((start = cubehelix$3(start)).h, (end = cubehelix$3(end)).h), + s = nogamma(start.s, end.s), + l = nogamma(start.l, end.l), + opacity = nogamma(start.opacity, end.opacity); + return function(t) { + start.h = h(t); + start.s = s(t); + start.l = l(Math.pow(t, y)); + start.opacity = opacity(t); + return start + ""; + }; + } + + cubehelix.gamma = cubehelixGamma; + + return cubehelix; + })(1); +} + +var cubehelix$2 = cubehelix$1(hue$1); +var cubehelixLong = cubehelix$1(nogamma); + +function piecewise(interpolate, values) { + if (values === undefined) values = interpolate, interpolate = interpolate$2; + var i = 0, n = values.length - 1, v = values[0], I = new Array(n < 0 ? 0 : n); + while (i < n) I[i] = interpolate(v, v = values[++i]); + return function(t) { + var i = Math.max(0, Math.min(n - 1, Math.floor(t *= n))); + return I[i](t - i); + }; +} + +function quantize$1(interpolator, n) { + var samples = new Array(n); + for (var i = 0; i < n; ++i) samples[i] = interpolator(i / (n - 1)); + return samples; +} + +var frame = 0, // is an animation frame pending? + timeout$1 = 0, // is a timeout pending? + interval$1 = 0, // are any timers active? + pokeDelay = 1000, // how frequently we check for clock skew + taskHead, + taskTail, + clockLast = 0, + clockNow = 0, + clockSkew = 0, + clock = typeof performance === "object" && performance.now ? performance : Date, + setFrame = typeof window === "object" && window.requestAnimationFrame ? window.requestAnimationFrame.bind(window) : function(f) { setTimeout(f, 17); }; + +function now() { + return clockNow || (setFrame(clearNow), clockNow = clock.now() + clockSkew); +} + +function clearNow() { + clockNow = 0; +} + +function Timer() { + this._call = + this._time = + this._next = null; +} + +Timer.prototype = timer.prototype = { + constructor: Timer, + restart: function(callback, delay, time) { + if (typeof callback !== "function") throw new TypeError("callback is not a function"); + time = (time == null ? now() : +time) + (delay == null ? 0 : +delay); + if (!this._next && taskTail !== this) { + if (taskTail) taskTail._next = this; + else taskHead = this; + taskTail = this; + } + this._call = callback; + this._time = time; + sleep(); + }, + stop: function() { + if (this._call) { + this._call = null; + this._time = Infinity; + sleep(); + } + } +}; + +function timer(callback, delay, time) { + var t = new Timer; + t.restart(callback, delay, time); + return t; +} + +function timerFlush() { + now(); // Get the current time, if not already set. + ++frame; // Pretend we’ve set an alarm, if we haven’t already. + var t = taskHead, e; + while (t) { + if ((e = clockNow - t._time) >= 0) t._call.call(undefined, e); + t = t._next; + } + --frame; +} + +function wake() { + clockNow = (clockLast = clock.now()) + clockSkew; + frame = timeout$1 = 0; + try { + timerFlush(); + } finally { + frame = 0; + nap(); + clockNow = 0; + } +} + +function poke() { + var now = clock.now(), delay = now - clockLast; + if (delay > pokeDelay) clockSkew -= delay, clockLast = now; +} + +function nap() { + var t0, t1 = taskHead, t2, time = Infinity; + while (t1) { + if (t1._call) { + if (time > t1._time) time = t1._time; + t0 = t1, t1 = t1._next; + } else { + t2 = t1._next, t1._next = null; + t1 = t0 ? t0._next = t2 : taskHead = t2; + } + } + taskTail = t0; + sleep(time); +} + +function sleep(time) { + if (frame) return; // Soonest alarm already set, or will be. + if (timeout$1) timeout$1 = clearTimeout(timeout$1); + var delay = time - clockNow; // Strictly less than if we recomputed clockNow. + if (delay > 24) { + if (time < Infinity) timeout$1 = setTimeout(wake, time - clock.now() - clockSkew); + if (interval$1) interval$1 = clearInterval(interval$1); + } else { + if (!interval$1) clockLast = clock.now(), interval$1 = setInterval(poke, pokeDelay); + frame = 1, setFrame(wake); + } +} + +function timeout(callback, delay, time) { + var t = new Timer; + delay = delay == null ? 0 : +delay; + t.restart(elapsed => { + t.stop(); + callback(elapsed + delay); + }, delay, time); + return t; +} + +function interval(callback, delay, time) { + var t = new Timer, total = delay; + if (delay == null) return t.restart(callback, delay, time), t; + t._restart = t.restart; + t.restart = function(callback, delay, time) { + delay = +delay, time = time == null ? now() : +time; + t._restart(function tick(elapsed) { + elapsed += total; + t._restart(tick, total += delay, time); + callback(elapsed); + }, delay, time); + }; + t.restart(callback, delay, time); + return t; +} + +var emptyOn = dispatch("start", "end", "cancel", "interrupt"); +var emptyTween = []; + +var CREATED = 0; +var SCHEDULED = 1; +var STARTING = 2; +var STARTED = 3; +var RUNNING = 4; +var ENDING = 5; +var ENDED = 6; + +function schedule(node, name, id, index, group, timing) { + var schedules = node.__transition; + if (!schedules) node.__transition = {}; + else if (id in schedules) return; + create(node, id, { + name: name, + index: index, // For context during callback. + group: group, // For context during callback. + on: emptyOn, + tween: emptyTween, + time: timing.time, + delay: timing.delay, + duration: timing.duration, + ease: timing.ease, + timer: null, + state: CREATED + }); +} + +function init(node, id) { + var schedule = get(node, id); + if (schedule.state > CREATED) throw new Error("too late; already scheduled"); + return schedule; +} + +function set(node, id) { + var schedule = get(node, id); + if (schedule.state > STARTED) throw new Error("too late; already running"); + return schedule; +} + +function get(node, id) { + var schedule = node.__transition; + if (!schedule || !(schedule = schedule[id])) throw new Error("transition not found"); + return schedule; +} + +function create(node, id, self) { + var schedules = node.__transition, + tween; + + // Initialize the self timer when the transition is created. + // Note the actual delay is not known until the first callback! + schedules[id] = self; + self.timer = timer(schedule, 0, self.time); + + function schedule(elapsed) { + self.state = SCHEDULED; + self.timer.restart(start, self.delay, self.time); + + // If the elapsed delay is less than our first sleep, start immediately. + if (self.delay <= elapsed) start(elapsed - self.delay); + } + + function start(elapsed) { + var i, j, n, o; + + // If the state is not SCHEDULED, then we previously errored on start. + if (self.state !== SCHEDULED) return stop(); + + for (i in schedules) { + o = schedules[i]; + if (o.name !== self.name) continue; + + // While this element already has a starting transition during this frame, + // defer starting an interrupting transition until that transition has a + // chance to tick (and possibly end); see d3/d3-transition#54! + if (o.state === STARTED) return timeout(start); + + // Interrupt the active transition, if any. + if (o.state === RUNNING) { + o.state = ENDED; + o.timer.stop(); + o.on.call("interrupt", node, node.__data__, o.index, o.group); + delete schedules[i]; + } + + // Cancel any pre-empted transitions. + else if (+i < id) { + o.state = ENDED; + o.timer.stop(); + o.on.call("cancel", node, node.__data__, o.index, o.group); + delete schedules[i]; + } + } + + // Defer the first tick to end of the current frame; see d3/d3#1576. + // Note the transition may be canceled after start and before the first tick! + // Note this must be scheduled before the start event; see d3/d3-transition#16! + // Assuming this is successful, subsequent callbacks go straight to tick. + timeout(function() { + if (self.state === STARTED) { + self.state = RUNNING; + self.timer.restart(tick, self.delay, self.time); + tick(elapsed); + } + }); + + // Dispatch the start event. + // Note this must be done before the tween are initialized. + self.state = STARTING; + self.on.call("start", node, node.__data__, self.index, self.group); + if (self.state !== STARTING) return; // interrupted + self.state = STARTED; + + // Initialize the tween, deleting null tween. + tween = new Array(n = self.tween.length); + for (i = 0, j = -1; i < n; ++i) { + if (o = self.tween[i].value.call(node, node.__data__, self.index, self.group)) { + tween[++j] = o; + } + } + tween.length = j + 1; + } + + function tick(elapsed) { + var t = elapsed < self.duration ? self.ease.call(null, elapsed / self.duration) : (self.timer.restart(stop), self.state = ENDING, 1), + i = -1, + n = tween.length; + + while (++i < n) { + tween[i].call(node, t); + } + + // Dispatch the end event. + if (self.state === ENDING) { + self.on.call("end", node, node.__data__, self.index, self.group); + stop(); + } + } + + function stop() { + self.state = ENDED; + self.timer.stop(); + delete schedules[id]; + for (var i in schedules) return; // eslint-disable-line no-unused-vars + delete node.__transition; + } +} + +function interrupt(node, name) { + var schedules = node.__transition, + schedule, + active, + empty = true, + i; + + if (!schedules) return; + + name = name == null ? null : name + ""; + + for (i in schedules) { + if ((schedule = schedules[i]).name !== name) { empty = false; continue; } + active = schedule.state > STARTING && schedule.state < ENDING; + schedule.state = ENDED; + schedule.timer.stop(); + schedule.on.call(active ? "interrupt" : "cancel", node, node.__data__, schedule.index, schedule.group); + delete schedules[i]; + } + + if (empty) delete node.__transition; +} + +function selection_interrupt(name) { + return this.each(function() { + interrupt(this, name); + }); +} + +function tweenRemove(id, name) { + var tween0, tween1; + return function() { + var schedule = set(this, id), + tween = schedule.tween; + + // If this node shared tween with the previous node, + // just assign the updated shared tween and we’re done! + // Otherwise, copy-on-write. + if (tween !== tween0) { + tween1 = tween0 = tween; + for (var i = 0, n = tween1.length; i < n; ++i) { + if (tween1[i].name === name) { + tween1 = tween1.slice(); + tween1.splice(i, 1); + break; + } + } + } + + schedule.tween = tween1; + }; +} + +function tweenFunction(id, name, value) { + var tween0, tween1; + if (typeof value !== "function") throw new Error; + return function() { + var schedule = set(this, id), + tween = schedule.tween; + + // If this node shared tween with the previous node, + // just assign the updated shared tween and we’re done! + // Otherwise, copy-on-write. + if (tween !== tween0) { + tween1 = (tween0 = tween).slice(); + for (var t = {name: name, value: value}, i = 0, n = tween1.length; i < n; ++i) { + if (tween1[i].name === name) { + tween1[i] = t; + break; + } + } + if (i === n) tween1.push(t); + } + + schedule.tween = tween1; + }; +} + +function transition_tween(name, value) { + var id = this._id; + + name += ""; + + if (arguments.length < 2) { + var tween = get(this.node(), id).tween; + for (var i = 0, n = tween.length, t; i < n; ++i) { + if ((t = tween[i]).name === name) { + return t.value; + } + } + return null; + } + + return this.each((value == null ? tweenRemove : tweenFunction)(id, name, value)); +} + +function tweenValue(transition, name, value) { + var id = transition._id; + + transition.each(function() { + var schedule = set(this, id); + (schedule.value || (schedule.value = {}))[name] = value.apply(this, arguments); + }); + + return function(node) { + return get(node, id).value[name]; + }; +} + +function interpolate$1(a, b) { + var c; + return (typeof b === "number" ? interpolateNumber + : b instanceof color ? interpolateRgb + : (c = color(b)) ? (b = c, interpolateRgb) + : interpolateString)(a, b); +} + +function attrRemove(name) { + return function() { + this.removeAttribute(name); + }; +} + +function attrRemoveNS(fullname) { + return function() { + this.removeAttributeNS(fullname.space, fullname.local); + }; +} + +function attrConstant(name, interpolate, value1) { + var string00, + string1 = value1 + "", + interpolate0; + return function() { + var string0 = this.getAttribute(name); + return string0 === string1 ? null + : string0 === string00 ? interpolate0 + : interpolate0 = interpolate(string00 = string0, value1); + }; +} + +function attrConstantNS(fullname, interpolate, value1) { + var string00, + string1 = value1 + "", + interpolate0; + return function() { + var string0 = this.getAttributeNS(fullname.space, fullname.local); + return string0 === string1 ? null + : string0 === string00 ? interpolate0 + : interpolate0 = interpolate(string00 = string0, value1); + }; +} + +function attrFunction(name, interpolate, value) { + var string00, + string10, + interpolate0; + return function() { + var string0, value1 = value(this), string1; + if (value1 == null) return void this.removeAttribute(name); + string0 = this.getAttribute(name); + string1 = value1 + ""; + return string0 === string1 ? null + : string0 === string00 && string1 === string10 ? interpolate0 + : (string10 = string1, interpolate0 = interpolate(string00 = string0, value1)); + }; +} + +function attrFunctionNS(fullname, interpolate, value) { + var string00, + string10, + interpolate0; + return function() { + var string0, value1 = value(this), string1; + if (value1 == null) return void this.removeAttributeNS(fullname.space, fullname.local); + string0 = this.getAttributeNS(fullname.space, fullname.local); + string1 = value1 + ""; + return string0 === string1 ? null + : string0 === string00 && string1 === string10 ? interpolate0 + : (string10 = string1, interpolate0 = interpolate(string00 = string0, value1)); + }; +} + +function transition_attr(name, value) { + var fullname = namespace(name), i = fullname === "transform" ? interpolateTransformSvg : interpolate$1; + return this.attrTween(name, typeof value === "function" + ? (fullname.local ? attrFunctionNS : attrFunction)(fullname, i, tweenValue(this, "attr." + name, value)) + : value == null ? (fullname.local ? attrRemoveNS : attrRemove)(fullname) + : (fullname.local ? attrConstantNS : attrConstant)(fullname, i, value)); +} + +function attrInterpolate(name, i) { + return function(t) { + this.setAttribute(name, i.call(this, t)); + }; +} + +function attrInterpolateNS(fullname, i) { + return function(t) { + this.setAttributeNS(fullname.space, fullname.local, i.call(this, t)); + }; +} + +function attrTweenNS(fullname, value) { + var t0, i0; + function tween() { + var i = value.apply(this, arguments); + if (i !== i0) t0 = (i0 = i) && attrInterpolateNS(fullname, i); + return t0; + } + tween._value = value; + return tween; +} + +function attrTween(name, value) { + var t0, i0; + function tween() { + var i = value.apply(this, arguments); + if (i !== i0) t0 = (i0 = i) && attrInterpolate(name, i); + return t0; + } + tween._value = value; + return tween; +} + +function transition_attrTween(name, value) { + var key = "attr." + name; + if (arguments.length < 2) return (key = this.tween(key)) && key._value; + if (value == null) return this.tween(key, null); + if (typeof value !== "function") throw new Error; + var fullname = namespace(name); + return this.tween(key, (fullname.local ? attrTweenNS : attrTween)(fullname, value)); +} + +function delayFunction(id, value) { + return function() { + init(this, id).delay = +value.apply(this, arguments); + }; +} + +function delayConstant(id, value) { + return value = +value, function() { + init(this, id).delay = value; + }; +} + +function transition_delay(value) { + var id = this._id; + + return arguments.length + ? this.each((typeof value === "function" + ? delayFunction + : delayConstant)(id, value)) + : get(this.node(), id).delay; +} + +function durationFunction(id, value) { + return function() { + set(this, id).duration = +value.apply(this, arguments); + }; +} + +function durationConstant(id, value) { + return value = +value, function() { + set(this, id).duration = value; + }; +} + +function transition_duration(value) { + var id = this._id; + + return arguments.length + ? this.each((typeof value === "function" + ? durationFunction + : durationConstant)(id, value)) + : get(this.node(), id).duration; +} + +function easeConstant(id, value) { + if (typeof value !== "function") throw new Error; + return function() { + set(this, id).ease = value; + }; +} + +function transition_ease(value) { + var id = this._id; + + return arguments.length + ? this.each(easeConstant(id, value)) + : get(this.node(), id).ease; +} + +function easeVarying(id, value) { + return function() { + var v = value.apply(this, arguments); + if (typeof v !== "function") throw new Error; + set(this, id).ease = v; + }; +} + +function transition_easeVarying(value) { + if (typeof value !== "function") throw new Error; + return this.each(easeVarying(this._id, value)); +} + +function transition_filter(match) { + if (typeof match !== "function") match = matcher(match); + + for (var groups = this._groups, m = groups.length, subgroups = new Array(m), j = 0; j < m; ++j) { + for (var group = groups[j], n = group.length, subgroup = subgroups[j] = [], node, i = 0; i < n; ++i) { + if ((node = group[i]) && match.call(node, node.__data__, i, group)) { + subgroup.push(node); + } + } + } + + return new Transition(subgroups, this._parents, this._name, this._id); +} + +function transition_merge(transition) { + if (transition._id !== this._id) throw new Error; + + for (var groups0 = this._groups, groups1 = transition._groups, m0 = groups0.length, m1 = groups1.length, m = Math.min(m0, m1), merges = new Array(m0), j = 0; j < m; ++j) { + for (var group0 = groups0[j], group1 = groups1[j], n = group0.length, merge = merges[j] = new Array(n), node, i = 0; i < n; ++i) { + if (node = group0[i] || group1[i]) { + merge[i] = node; + } + } + } + + for (; j < m0; ++j) { + merges[j] = groups0[j]; + } + + return new Transition(merges, this._parents, this._name, this._id); +} + +function start(name) { + return (name + "").trim().split(/^|\s+/).every(function(t) { + var i = t.indexOf("."); + if (i >= 0) t = t.slice(0, i); + return !t || t === "start"; + }); +} + +function onFunction(id, name, listener) { + var on0, on1, sit = start(name) ? init : set; + return function() { + var schedule = sit(this, id), + on = schedule.on; + + // If this node shared a dispatch with the previous node, + // just assign the updated shared dispatch and we’re done! + // Otherwise, copy-on-write. + if (on !== on0) (on1 = (on0 = on).copy()).on(name, listener); + + schedule.on = on1; + }; +} + +function transition_on(name, listener) { + var id = this._id; + + return arguments.length < 2 + ? get(this.node(), id).on.on(name) + : this.each(onFunction(id, name, listener)); +} + +function removeFunction(id) { + return function() { + var parent = this.parentNode; + for (var i in this.__transition) if (+i !== id) return; + if (parent) parent.removeChild(this); + }; +} + +function transition_remove() { + return this.on("end.remove", removeFunction(this._id)); +} + +function transition_select(select) { + var name = this._name, + id = this._id; + + if (typeof select !== "function") select = selector(select); + + for (var groups = this._groups, m = groups.length, subgroups = new Array(m), j = 0; j < m; ++j) { + for (var group = groups[j], n = group.length, subgroup = subgroups[j] = new Array(n), node, subnode, i = 0; i < n; ++i) { + if ((node = group[i]) && (subnode = select.call(node, node.__data__, i, group))) { + if ("__data__" in node) subnode.__data__ = node.__data__; + subgroup[i] = subnode; + schedule(subgroup[i], name, id, i, subgroup, get(node, id)); + } + } + } + + return new Transition(subgroups, this._parents, name, id); +} + +function transition_selectAll(select) { + var name = this._name, + id = this._id; + + if (typeof select !== "function") select = selectorAll(select); + + for (var groups = this._groups, m = groups.length, subgroups = [], parents = [], j = 0; j < m; ++j) { + for (var group = groups[j], n = group.length, node, i = 0; i < n; ++i) { + if (node = group[i]) { + for (var children = select.call(node, node.__data__, i, group), child, inherit = get(node, id), k = 0, l = children.length; k < l; ++k) { + if (child = children[k]) { + schedule(child, name, id, k, children, inherit); + } + } + subgroups.push(children); + parents.push(node); + } + } + } + + return new Transition(subgroups, parents, name, id); +} + +var Selection = selection.prototype.constructor; + +function transition_selection() { + return new Selection(this._groups, this._parents); +} + +function styleNull(name, interpolate) { + var string00, + string10, + interpolate0; + return function() { + var string0 = styleValue(this, name), + string1 = (this.style.removeProperty(name), styleValue(this, name)); + return string0 === string1 ? null + : string0 === string00 && string1 === string10 ? interpolate0 + : interpolate0 = interpolate(string00 = string0, string10 = string1); + }; +} + +function styleRemove(name) { + return function() { + this.style.removeProperty(name); + }; +} + +function styleConstant(name, interpolate, value1) { + var string00, + string1 = value1 + "", + interpolate0; + return function() { + var string0 = styleValue(this, name); + return string0 === string1 ? null + : string0 === string00 ? interpolate0 + : interpolate0 = interpolate(string00 = string0, value1); + }; +} + +function styleFunction(name, interpolate, value) { + var string00, + string10, + interpolate0; + return function() { + var string0 = styleValue(this, name), + value1 = value(this), + string1 = value1 + ""; + if (value1 == null) string1 = value1 = (this.style.removeProperty(name), styleValue(this, name)); + return string0 === string1 ? null + : string0 === string00 && string1 === string10 ? interpolate0 + : (string10 = string1, interpolate0 = interpolate(string00 = string0, value1)); + }; +} + +function styleMaybeRemove(id, name) { + var on0, on1, listener0, key = "style." + name, event = "end." + key, remove; + return function() { + var schedule = set(this, id), + on = schedule.on, + listener = schedule.value[key] == null ? remove || (remove = styleRemove(name)) : undefined; + + // If this node shared a dispatch with the previous node, + // just assign the updated shared dispatch and we’re done! + // Otherwise, copy-on-write. + if (on !== on0 || listener0 !== listener) (on1 = (on0 = on).copy()).on(event, listener0 = listener); + + schedule.on = on1; + }; +} + +function transition_style(name, value, priority) { + var i = (name += "") === "transform" ? interpolateTransformCss : interpolate$1; + return value == null ? this + .styleTween(name, styleNull(name, i)) + .on("end.style." + name, styleRemove(name)) + : typeof value === "function" ? this + .styleTween(name, styleFunction(name, i, tweenValue(this, "style." + name, value))) + .each(styleMaybeRemove(this._id, name)) + : this + .styleTween(name, styleConstant(name, i, value), priority) + .on("end.style." + name, null); +} + +function styleInterpolate(name, i, priority) { + return function(t) { + this.style.setProperty(name, i.call(this, t), priority); + }; +} + +function styleTween(name, value, priority) { + var t, i0; + function tween() { + var i = value.apply(this, arguments); + if (i !== i0) t = (i0 = i) && styleInterpolate(name, i, priority); + return t; + } + tween._value = value; + return tween; +} + +function transition_styleTween(name, value, priority) { + var key = "style." + (name += ""); + if (arguments.length < 2) return (key = this.tween(key)) && key._value; + if (value == null) return this.tween(key, null); + if (typeof value !== "function") throw new Error; + return this.tween(key, styleTween(name, value, priority == null ? "" : priority)); +} + +function textConstant(value) { + return function() { + this.textContent = value; + }; +} + +function textFunction(value) { + return function() { + var value1 = value(this); + this.textContent = value1 == null ? "" : value1; + }; +} + +function transition_text(value) { + return this.tween("text", typeof value === "function" + ? textFunction(tweenValue(this, "text", value)) + : textConstant(value == null ? "" : value + "")); +} + +function textInterpolate(i) { + return function(t) { + this.textContent = i.call(this, t); + }; +} + +function textTween(value) { + var t0, i0; + function tween() { + var i = value.apply(this, arguments); + if (i !== i0) t0 = (i0 = i) && textInterpolate(i); + return t0; + } + tween._value = value; + return tween; +} + +function transition_textTween(value) { + var key = "text"; + if (arguments.length < 1) return (key = this.tween(key)) && key._value; + if (value == null) return this.tween(key, null); + if (typeof value !== "function") throw new Error; + return this.tween(key, textTween(value)); +} + +function transition_transition() { + var name = this._name, + id0 = this._id, + id1 = newId(); + + for (var groups = this._groups, m = groups.length, j = 0; j < m; ++j) { + for (var group = groups[j], n = group.length, node, i = 0; i < n; ++i) { + if (node = group[i]) { + var inherit = get(node, id0); + schedule(node, name, id1, i, group, { + time: inherit.time + inherit.delay + inherit.duration, + delay: 0, + duration: inherit.duration, + ease: inherit.ease + }); + } + } + } + + return new Transition(groups, this._parents, name, id1); +} + +function transition_end() { + var on0, on1, that = this, id = that._id, size = that.size(); + return new Promise(function(resolve, reject) { + var cancel = {value: reject}, + end = {value: function() { if (--size === 0) resolve(); }}; + + that.each(function() { + var schedule = set(this, id), + on = schedule.on; + + // If this node shared a dispatch with the previous node, + // just assign the updated shared dispatch and we’re done! + // Otherwise, copy-on-write. + if (on !== on0) { + on1 = (on0 = on).copy(); + on1._.cancel.push(cancel); + on1._.interrupt.push(cancel); + on1._.end.push(end); + } + + schedule.on = on1; + }); + + // The selection was empty, resolve end immediately + if (size === 0) resolve(); + }); +} + +var id = 0; + +function Transition(groups, parents, name, id) { + this._groups = groups; + this._parents = parents; + this._name = name; + this._id = id; +} + +function transition(name) { + return selection().transition(name); +} + +function newId() { + return ++id; +} + +var selection_prototype = selection.prototype; + +Transition.prototype = transition.prototype = { + constructor: Transition, + select: transition_select, + selectAll: transition_selectAll, + selectChild: selection_prototype.selectChild, + selectChildren: selection_prototype.selectChildren, + filter: transition_filter, + merge: transition_merge, + selection: transition_selection, + transition: transition_transition, + call: selection_prototype.call, + nodes: selection_prototype.nodes, + node: selection_prototype.node, + size: selection_prototype.size, + empty: selection_prototype.empty, + each: selection_prototype.each, + on: transition_on, + attr: transition_attr, + attrTween: transition_attrTween, + style: transition_style, + styleTween: transition_styleTween, + text: transition_text, + textTween: transition_textTween, + remove: transition_remove, + tween: transition_tween, + delay: transition_delay, + duration: transition_duration, + ease: transition_ease, + easeVarying: transition_easeVarying, + end: transition_end, + [Symbol.iterator]: selection_prototype[Symbol.iterator] +}; + +const linear$1 = t => +t; + +function quadIn(t) { + return t * t; +} + +function quadOut(t) { + return t * (2 - t); +} + +function quadInOut(t) { + return ((t *= 2) <= 1 ? t * t : --t * (2 - t) + 1) / 2; +} + +function cubicIn(t) { + return t * t * t; +} + +function cubicOut(t) { + return --t * t * t + 1; +} + +function cubicInOut(t) { + return ((t *= 2) <= 1 ? t * t * t : (t -= 2) * t * t + 2) / 2; +} + +var exponent$1 = 3; + +var polyIn = (function custom(e) { + e = +e; + + function polyIn(t) { + return Math.pow(t, e); + } + + polyIn.exponent = custom; + + return polyIn; +})(exponent$1); + +var polyOut = (function custom(e) { + e = +e; + + function polyOut(t) { + return 1 - Math.pow(1 - t, e); + } + + polyOut.exponent = custom; + + return polyOut; +})(exponent$1); + +var polyInOut = (function custom(e) { + e = +e; + + function polyInOut(t) { + return ((t *= 2) <= 1 ? Math.pow(t, e) : 2 - Math.pow(2 - t, e)) / 2; + } + + polyInOut.exponent = custom; + + return polyInOut; +})(exponent$1); + +var pi$4 = Math.PI, + halfPi$3 = pi$4 / 2; + +function sinIn(t) { + return (+t === 1) ? 1 : 1 - Math.cos(t * halfPi$3); +} + +function sinOut(t) { + return Math.sin(t * halfPi$3); +} + +function sinInOut(t) { + return (1 - Math.cos(pi$4 * t)) / 2; +} + +// tpmt is two power minus ten times t scaled to [0,1] +function tpmt(x) { + return (Math.pow(2, -10 * x) - 0.0009765625) * 1.0009775171065494; +} + +function expIn(t) { + return tpmt(1 - +t); +} + +function expOut(t) { + return 1 - tpmt(t); +} + +function expInOut(t) { + return ((t *= 2) <= 1 ? tpmt(1 - t) : 2 - tpmt(t - 1)) / 2; +} + +function circleIn(t) { + return 1 - Math.sqrt(1 - t * t); +} + +function circleOut(t) { + return Math.sqrt(1 - --t * t); +} + +function circleInOut(t) { + return ((t *= 2) <= 1 ? 1 - Math.sqrt(1 - t * t) : Math.sqrt(1 - (t -= 2) * t) + 1) / 2; +} + +var b1 = 4 / 11, + b2 = 6 / 11, + b3 = 8 / 11, + b4 = 3 / 4, + b5 = 9 / 11, + b6 = 10 / 11, + b7 = 15 / 16, + b8 = 21 / 22, + b9 = 63 / 64, + b0 = 1 / b1 / b1; + +function bounceIn(t) { + return 1 - bounceOut(1 - t); +} + +function bounceOut(t) { + return (t = +t) < b1 ? b0 * t * t : t < b3 ? b0 * (t -= b2) * t + b4 : t < b6 ? b0 * (t -= b5) * t + b7 : b0 * (t -= b8) * t + b9; +} + +function bounceInOut(t) { + return ((t *= 2) <= 1 ? 1 - bounceOut(1 - t) : bounceOut(t - 1) + 1) / 2; +} + +var overshoot = 1.70158; + +var backIn = (function custom(s) { + s = +s; + + function backIn(t) { + return (t = +t) * t * (s * (t - 1) + t); + } + + backIn.overshoot = custom; + + return backIn; +})(overshoot); + +var backOut = (function custom(s) { + s = +s; + + function backOut(t) { + return --t * t * ((t + 1) * s + t) + 1; + } + + backOut.overshoot = custom; + + return backOut; +})(overshoot); + +var backInOut = (function custom(s) { + s = +s; + + function backInOut(t) { + return ((t *= 2) < 1 ? t * t * ((s + 1) * t - s) : (t -= 2) * t * ((s + 1) * t + s) + 2) / 2; + } + + backInOut.overshoot = custom; + + return backInOut; +})(overshoot); + +var tau$5 = 2 * Math.PI, + amplitude = 1, + period = 0.3; + +var elasticIn = (function custom(a, p) { + var s = Math.asin(1 / (a = Math.max(1, a))) * (p /= tau$5); + + function elasticIn(t) { + return a * tpmt(-(--t)) * Math.sin((s - t) / p); + } + + elasticIn.amplitude = function(a) { return custom(a, p * tau$5); }; + elasticIn.period = function(p) { return custom(a, p); }; + + return elasticIn; +})(amplitude, period); + +var elasticOut = (function custom(a, p) { + var s = Math.asin(1 / (a = Math.max(1, a))) * (p /= tau$5); + + function elasticOut(t) { + return 1 - a * tpmt(t = +t) * Math.sin((t + s) / p); + } + + elasticOut.amplitude = function(a) { return custom(a, p * tau$5); }; + elasticOut.period = function(p) { return custom(a, p); }; + + return elasticOut; +})(amplitude, period); + +var elasticInOut = (function custom(a, p) { + var s = Math.asin(1 / (a = Math.max(1, a))) * (p /= tau$5); + + function elasticInOut(t) { + return ((t = t * 2 - 1) < 0 + ? a * tpmt(-t) * Math.sin((s - t) / p) + : 2 - a * tpmt(t) * Math.sin((s + t) / p)) / 2; + } + + elasticInOut.amplitude = function(a) { return custom(a, p * tau$5); }; + elasticInOut.period = function(p) { return custom(a, p); }; + + return elasticInOut; +})(amplitude, period); + +var defaultTiming = { + time: null, // Set on use. + delay: 0, + duration: 250, + ease: cubicInOut +}; + +function inherit(node, id) { + var timing; + while (!(timing = node.__transition) || !(timing = timing[id])) { + if (!(node = node.parentNode)) { + throw new Error(`transition ${id} not found`); + } + } + return timing; +} + +function selection_transition(name) { + var id, + timing; + + if (name instanceof Transition) { + id = name._id, name = name._name; + } else { + id = newId(), (timing = defaultTiming).time = now(), name = name == null ? null : name + ""; + } + + for (var groups = this._groups, m = groups.length, j = 0; j < m; ++j) { + for (var group = groups[j], n = group.length, node, i = 0; i < n; ++i) { + if (node = group[i]) { + schedule(node, name, id, i, group, timing || inherit(node, id)); + } + } + } + + return new Transition(groups, this._parents, name, id); +} + +selection.prototype.interrupt = selection_interrupt; +selection.prototype.transition = selection_transition; + +var root = [null]; + +function active(node, name) { + var schedules = node.__transition, + schedule, + i; + + if (schedules) { + name = name == null ? null : name + ""; + for (i in schedules) { + if ((schedule = schedules[i]).state > SCHEDULED && schedule.name === name) { + return new Transition([[node]], root, name, +i); + } + } + } + + return null; +} + +var constant$7 = x => () => x; + +function BrushEvent(type, { + sourceEvent, + target, + selection, + mode, + dispatch +}) { + Object.defineProperties(this, { + type: {value: type, enumerable: true, configurable: true}, + sourceEvent: {value: sourceEvent, enumerable: true, configurable: true}, + target: {value: target, enumerable: true, configurable: true}, + selection: {value: selection, enumerable: true, configurable: true}, + mode: {value: mode, enumerable: true, configurable: true}, + _: {value: dispatch} + }); +} + +function nopropagation$1(event) { + event.stopImmediatePropagation(); +} + +function noevent$1(event) { + event.preventDefault(); + event.stopImmediatePropagation(); +} + +var MODE_DRAG = {name: "drag"}, + MODE_SPACE = {name: "space"}, + MODE_HANDLE = {name: "handle"}, + MODE_CENTER = {name: "center"}; + +const {abs: abs$3, max: max$2, min: min$1} = Math; + +function number1(e) { + return [+e[0], +e[1]]; +} + +function number2(e) { + return [number1(e[0]), number1(e[1])]; +} + +var X = { + name: "x", + handles: ["w", "e"].map(type), + input: function(x, e) { return x == null ? null : [[+x[0], e[0][1]], [+x[1], e[1][1]]]; }, + output: function(xy) { return xy && [xy[0][0], xy[1][0]]; } +}; + +var Y = { + name: "y", + handles: ["n", "s"].map(type), + input: function(y, e) { return y == null ? null : [[e[0][0], +y[0]], [e[1][0], +y[1]]]; }, + output: function(xy) { return xy && [xy[0][1], xy[1][1]]; } +}; + +var XY = { + name: "xy", + handles: ["n", "w", "e", "s", "nw", "ne", "sw", "se"].map(type), + input: function(xy) { return xy == null ? null : number2(xy); }, + output: function(xy) { return xy; } +}; + +var cursors = { + 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" +}; + +var flipX = { + e: "w", + w: "e", + nw: "ne", + ne: "nw", + se: "sw", + sw: "se" +}; + +var flipY = { + n: "s", + s: "n", + nw: "sw", + ne: "se", + se: "ne", + sw: "nw" +}; + +var signsX = { + overlay: +1, + selection: +1, + n: null, + e: +1, + s: null, + w: -1, + nw: -1, + ne: +1, + se: +1, + sw: -1 +}; + +var signsY = { + overlay: +1, + selection: +1, + n: -1, + e: null, + s: +1, + w: null, + nw: -1, + ne: -1, + se: +1, + sw: +1 +}; + +function type(t) { + return {type: t}; +} + +// Ignore right-click, since that should open the context menu. +function defaultFilter$1(event) { + return !event.ctrlKey && !event.button; +} + +function defaultExtent$1() { + var svg = this.ownerSVGElement || this; + if (svg.hasAttribute("viewBox")) { + svg = svg.viewBox.baseVal; + return [[svg.x, svg.y], [svg.x + svg.width, svg.y + svg.height]]; + } + return [[0, 0], [svg.width.baseVal.value, svg.height.baseVal.value]]; +} + +function defaultTouchable$1() { + return navigator.maxTouchPoints || ("ontouchstart" in this); +} + +// Like d3.local, but with the name “__brush” rather than auto-generated. +function local(node) { + while (!node.__brush) if (!(node = node.parentNode)) return; + return node.__brush; +} + +function empty(extent) { + return extent[0][0] === extent[1][0] + || extent[0][1] === extent[1][1]; +} + +function brushSelection(node) { + var state = node.__brush; + return state ? state.dim.output(state.selection) : null; +} + +function brushX() { + return brush$1(X); +} + +function brushY() { + return brush$1(Y); +} + +function brush() { + return brush$1(XY); +} + +function brush$1(dim) { + var extent = defaultExtent$1, + filter = defaultFilter$1, + touchable = defaultTouchable$1, + keys = true, + listeners = dispatch("start", "brush", "end"), + handleSize = 6, + touchending; + + function brush(group) { + var overlay = group + .property("__brush", initialize) + .selectAll(".overlay") + .data([type("overlay")]); + + overlay.enter().append("rect") + .attr("class", "overlay") + .attr("pointer-events", "all") + .attr("cursor", cursors.overlay) + .merge(overlay) + .each(function() { + var extent = local(this).extent; + select(this) + .attr("x", extent[0][0]) + .attr("y", extent[0][1]) + .attr("width", extent[1][0] - extent[0][0]) + .attr("height", extent[1][1] - extent[0][1]); + }); + + group.selectAll(".selection") + .data([type("selection")]) + .enter().append("rect") + .attr("class", "selection") + .attr("cursor", cursors.selection) + .attr("fill", "#777") + .attr("fill-opacity", 0.3) + .attr("stroke", "#fff") + .attr("shape-rendering", "crispEdges"); + + var handle = group.selectAll(".handle") + .data(dim.handles, function(d) { return d.type; }); + + handle.exit().remove(); + + handle.enter().append("rect") + .attr("class", function(d) { return "handle handle--" + d.type; }) + .attr("cursor", function(d) { return cursors[d.type]; }); + + group + .each(redraw) + .attr("fill", "none") + .attr("pointer-events", "all") + .on("mousedown.brush", started) + .filter(touchable) + .on("touchstart.brush", started) + .on("touchmove.brush", touchmoved) + .on("touchend.brush touchcancel.brush", touchended) + .style("touch-action", "none") + .style("-webkit-tap-highlight-color", "rgba(0,0,0,0)"); + } + + brush.move = function(group, selection, event) { + if (group.tween) { + group + .on("start.brush", function(event) { emitter(this, arguments).beforestart().start(event); }) + .on("interrupt.brush end.brush", function(event) { emitter(this, arguments).end(event); }) + .tween("brush", function() { + var that = this, + state = that.__brush, + emit = emitter(that, arguments), + selection0 = state.selection, + selection1 = dim.input(typeof selection === "function" ? selection.apply(this, arguments) : selection, state.extent), + i = interpolate$2(selection0, selection1); + + function tween(t) { + state.selection = t === 1 && selection1 === null ? null : i(t); + redraw.call(that); + emit.brush(); + } + + return selection0 !== null && selection1 !== null ? tween : tween(1); + }); + } else { + group + .each(function() { + var that = this, + args = arguments, + state = that.__brush, + selection1 = dim.input(typeof selection === "function" ? selection.apply(that, args) : selection, state.extent), + emit = emitter(that, args).beforestart(); + + interrupt(that); + state.selection = selection1 === null ? null : selection1; + redraw.call(that); + emit.start(event).brush(event).end(event); + }); + } + }; + + brush.clear = function(group, event) { + brush.move(group, null, event); + }; + + function redraw() { + var group = select(this), + selection = local(this).selection; + + if (selection) { + group.selectAll(".selection") + .style("display", null) + .attr("x", selection[0][0]) + .attr("y", selection[0][1]) + .attr("width", selection[1][0] - selection[0][0]) + .attr("height", selection[1][1] - selection[0][1]); + + group.selectAll(".handle") + .style("display", null) + .attr("x", function(d) { return d.type[d.type.length - 1] === "e" ? selection[1][0] - handleSize / 2 : selection[0][0] - handleSize / 2; }) + .attr("y", function(d) { return d.type[0] === "s" ? selection[1][1] - handleSize / 2 : selection[0][1] - handleSize / 2; }) + .attr("width", function(d) { return d.type === "n" || d.type === "s" ? selection[1][0] - selection[0][0] + handleSize : handleSize; }) + .attr("height", function(d) { return d.type === "e" || d.type === "w" ? selection[1][1] - selection[0][1] + handleSize : handleSize; }); + } + + else { + group.selectAll(".selection,.handle") + .style("display", "none") + .attr("x", null) + .attr("y", null) + .attr("width", null) + .attr("height", null); + } + } + + function emitter(that, args, clean) { + var emit = that.__brush.emitter; + return emit && (!clean || !emit.clean) ? emit : new Emitter(that, args, clean); + } + + function Emitter(that, args, clean) { + this.that = that; + this.args = args; + this.state = that.__brush; + this.active = 0; + this.clean = clean; + } + + Emitter.prototype = { + beforestart: function() { + if (++this.active === 1) this.state.emitter = this, this.starting = true; + return this; + }, + start: function(event, mode) { + if (this.starting) this.starting = false, this.emit("start", event, mode); + else this.emit("brush", event); + return this; + }, + brush: function(event, mode) { + this.emit("brush", event, mode); + return this; + }, + end: function(event, mode) { + if (--this.active === 0) delete this.state.emitter, this.emit("end", event, mode); + return this; + }, + emit: function(type, event, mode) { + var d = select(this.that).datum(); + listeners.call( + type, + this.that, + new BrushEvent(type, { + sourceEvent: event, + target: brush, + selection: dim.output(this.state.selection), + mode, + dispatch: listeners + }), + d + ); + } + }; + + function started(event) { + if (touchending && !event.touches) return; + if (!filter.apply(this, arguments)) return; + + var that = this, + type = event.target.__data__.type, + mode = (keys && event.metaKey ? type = "overlay" : type) === "selection" ? MODE_DRAG : (keys && event.altKey ? MODE_CENTER : MODE_HANDLE), + signX = dim === Y ? null : signsX[type], + signY = dim === X ? null : signsY[type], + state = local(that), + extent = state.extent, + selection = state.selection, + W = extent[0][0], w0, w1, + N = extent[0][1], n0, n1, + E = extent[1][0], e0, e1, + S = extent[1][1], s0, s1, + dx = 0, + dy = 0, + moving, + shifting = signX && signY && keys && event.shiftKey, + lockX, + lockY, + points = Array.from(event.touches || [event], t => { + const i = t.identifier; + t = pointer(t, that); + t.point0 = t.slice(); + t.identifier = i; + return t; + }); + + interrupt(that); + var emit = emitter(that, arguments, true).beforestart(); + + if (type === "overlay") { + if (selection) moving = true; + const pts = [points[0], points[1] || points[0]]; + state.selection = selection = [[ + w0 = dim === Y ? W : min$1(pts[0][0], pts[1][0]), + n0 = dim === X ? N : min$1(pts[0][1], pts[1][1]) + ], [ + e0 = dim === Y ? E : max$2(pts[0][0], pts[1][0]), + s0 = dim === X ? S : max$2(pts[0][1], pts[1][1]) + ]]; + if (points.length > 1) move(event); + } else { + w0 = selection[0][0]; + n0 = selection[0][1]; + e0 = selection[1][0]; + s0 = selection[1][1]; + } + + w1 = w0; + n1 = n0; + e1 = e0; + s1 = s0; + + var group = select(that) + .attr("pointer-events", "none"); + + var overlay = group.selectAll(".overlay") + .attr("cursor", cursors[type]); + + if (event.touches) { + emit.moved = moved; + emit.ended = ended; + } else { + var view = select(event.view) + .on("mousemove.brush", moved, true) + .on("mouseup.brush", ended, true); + if (keys) view + .on("keydown.brush", keydowned, true) + .on("keyup.brush", keyupped, true); + + dragDisable(event.view); + } + + redraw.call(that); + emit.start(event, mode.name); + + function moved(event) { + for (const p of event.changedTouches || [event]) { + for (const d of points) + if (d.identifier === p.identifier) d.cur = pointer(p, that); + } + if (shifting && !lockX && !lockY && points.length === 1) { + const point = points[0]; + if (abs$3(point.cur[0] - point[0]) > abs$3(point.cur[1] - point[1])) + lockY = true; + else + lockX = true; + } + for (const point of points) + if (point.cur) point[0] = point.cur[0], point[1] = point.cur[1]; + moving = true; + noevent$1(event); + move(event); + } + + function move(event) { + const point = points[0], point0 = point.point0; + var t; + + dx = point[0] - point0[0]; + dy = point[1] - point0[1]; + + switch (mode) { + case MODE_SPACE: + case MODE_DRAG: { + if (signX) dx = max$2(W - w0, min$1(E - e0, dx)), w1 = w0 + dx, e1 = e0 + dx; + if (signY) dy = max$2(N - n0, min$1(S - s0, dy)), n1 = n0 + dy, s1 = s0 + dy; + break; + } + case MODE_HANDLE: { + if (points[1]) { + if (signX) w1 = max$2(W, min$1(E, points[0][0])), e1 = max$2(W, min$1(E, points[1][0])), signX = 1; + if (signY) n1 = max$2(N, min$1(S, points[0][1])), s1 = max$2(N, min$1(S, points[1][1])), signY = 1; + } else { + if (signX < 0) dx = max$2(W - w0, min$1(E - w0, dx)), w1 = w0 + dx, e1 = e0; + else if (signX > 0) dx = max$2(W - e0, min$1(E - e0, dx)), w1 = w0, e1 = e0 + dx; + if (signY < 0) dy = max$2(N - n0, min$1(S - n0, dy)), n1 = n0 + dy, s1 = s0; + else if (signY > 0) dy = max$2(N - s0, min$1(S - s0, dy)), n1 = n0, s1 = s0 + dy; + } + break; + } + case MODE_CENTER: { + if (signX) w1 = max$2(W, min$1(E, w0 - dx * signX)), e1 = max$2(W, min$1(E, e0 + dx * signX)); + if (signY) n1 = max$2(N, min$1(S, n0 - dy * signY)), s1 = max$2(N, min$1(S, s0 + dy * signY)); + break; + } + } + + if (e1 < w1) { + signX *= -1; + t = w0, w0 = e0, e0 = t; + t = w1, w1 = e1, e1 = t; + if (type in flipX) overlay.attr("cursor", cursors[type = flipX[type]]); + } + + if (s1 < n1) { + signY *= -1; + t = n0, n0 = s0, s0 = t; + t = n1, n1 = s1, s1 = t; + if (type in flipY) overlay.attr("cursor", cursors[type = flipY[type]]); + } + + if (state.selection) selection = state.selection; // May be set by brush.move! + if (lockX) w1 = selection[0][0], e1 = selection[1][0]; + if (lockY) n1 = selection[0][1], s1 = selection[1][1]; + + if (selection[0][0] !== w1 + || selection[0][1] !== n1 + || selection[1][0] !== e1 + || selection[1][1] !== s1) { + state.selection = [[w1, n1], [e1, s1]]; + redraw.call(that); + emit.brush(event, mode.name); + } + } + + function ended(event) { + nopropagation$1(event); + if (event.touches) { + if (event.touches.length) return; + if (touchending) clearTimeout(touchending); + touchending = setTimeout(function() { touchending = null; }, 500); // Ghost clicks are delayed! + } else { + yesdrag(event.view, moving); + view.on("keydown.brush keyup.brush mousemove.brush mouseup.brush", null); + } + group.attr("pointer-events", "all"); + overlay.attr("cursor", cursors.overlay); + if (state.selection) selection = state.selection; // May be set by brush.move (on start)! + if (empty(selection)) state.selection = null, redraw.call(that); + emit.end(event, mode.name); + } + + function keydowned(event) { + switch (event.keyCode) { + case 16: { // SHIFT + shifting = signX && signY; + break; + } + case 18: { // ALT + if (mode === MODE_HANDLE) { + if (signX) e0 = e1 - dx * signX, w0 = w1 + dx * signX; + if (signY) s0 = s1 - dy * signY, n0 = n1 + dy * signY; + mode = MODE_CENTER; + move(event); + } + break; + } + case 32: { // SPACE; takes priority over ALT + if (mode === MODE_HANDLE || mode === MODE_CENTER) { + if (signX < 0) e0 = e1 - dx; else if (signX > 0) w0 = w1 - dx; + if (signY < 0) s0 = s1 - dy; else if (signY > 0) n0 = n1 - dy; + mode = MODE_SPACE; + overlay.attr("cursor", cursors.selection); + move(event); + } + break; + } + default: return; + } + noevent$1(event); + } + + function keyupped(event) { + switch (event.keyCode) { + case 16: { // SHIFT + if (shifting) { + lockX = lockY = shifting = false; + move(event); + } + break; + } + case 18: { // ALT + if (mode === MODE_CENTER) { + if (signX < 0) e0 = e1; else if (signX > 0) w0 = w1; + if (signY < 0) s0 = s1; else if (signY > 0) n0 = n1; + mode = MODE_HANDLE; + move(event); + } + break; + } + case 32: { // SPACE + if (mode === MODE_SPACE) { + if (event.altKey) { + if (signX) e0 = e1 - dx * signX, w0 = w1 + dx * signX; + if (signY) s0 = s1 - dy * signY, n0 = n1 + dy * signY; + mode = MODE_CENTER; + } else { + if (signX < 0) e0 = e1; else if (signX > 0) w0 = w1; + if (signY < 0) s0 = s1; else if (signY > 0) n0 = n1; + mode = MODE_HANDLE; + } + overlay.attr("cursor", cursors[type]); + move(event); + } + break; + } + default: return; + } + noevent$1(event); + } + } + + function touchmoved(event) { + emitter(this, arguments).moved(event); + } + + function touchended(event) { + emitter(this, arguments).ended(event); + } + + function initialize() { + var state = this.__brush || {selection: null}; + state.extent = number2(extent.apply(this, arguments)); + state.dim = dim; + return state; + } + + brush.extent = function(_) { + return arguments.length ? (extent = typeof _ === "function" ? _ : constant$7(number2(_)), brush) : extent; + }; + + brush.filter = function(_) { + return arguments.length ? (filter = typeof _ === "function" ? _ : constant$7(!!_), brush) : filter; + }; + + brush.touchable = function(_) { + return arguments.length ? (touchable = typeof _ === "function" ? _ : constant$7(!!_), brush) : touchable; + }; + + brush.handleSize = function(_) { + return arguments.length ? (handleSize = +_, brush) : handleSize; + }; + + brush.keyModifiers = function(_) { + return arguments.length ? (keys = !!_, brush) : keys; + }; + + brush.on = function() { + var value = listeners.on.apply(listeners, arguments); + return value === listeners ? brush : value; + }; + + return brush; +} + +var abs$2 = Math.abs; +var cos$2 = Math.cos; +var sin$2 = Math.sin; +var pi$3 = Math.PI; +var halfPi$2 = pi$3 / 2; +var tau$4 = pi$3 * 2; +var max$1 = Math.max; +var epsilon$5 = 1e-12; + +function range$1(i, j) { + return Array.from({length: j - i}, (_, k) => i + k); +} + +function compareValue(compare) { + return function(a, b) { + return compare( + a.source.value + a.target.value, + b.source.value + b.target.value + ); + }; +} + +function chord() { + return chord$1(false, false); +} + +function chordTranspose() { + return chord$1(false, true); +} + +function chordDirected() { + return chord$1(true, false); +} + +function chord$1(directed, transpose) { + var padAngle = 0, + sortGroups = null, + sortSubgroups = null, + sortChords = null; + + function chord(matrix) { + var n = matrix.length, + groupSums = new Array(n), + groupIndex = range$1(0, n), + chords = new Array(n * n), + groups = new Array(n), + k = 0, dx; + + matrix = Float64Array.from({length: n * n}, transpose + ? (_, i) => matrix[i % n][i / n | 0] + : (_, i) => matrix[i / n | 0][i % n]); + + // Compute the scaling factor from value to angle in [0, 2pi]. + for (let i = 0; i < n; ++i) { + let x = 0; + for (let j = 0; j < n; ++j) x += matrix[i * n + j] + directed * matrix[j * n + i]; + k += groupSums[i] = x; + } + k = max$1(0, tau$4 - padAngle * n) / k; + dx = k ? padAngle : tau$4 / n; + + // Compute the angles for each group and constituent chord. + { + let x = 0; + if (sortGroups) groupIndex.sort((a, b) => sortGroups(groupSums[a], groupSums[b])); + for (const i of groupIndex) { + const x0 = x; + if (directed) { + const subgroupIndex = range$1(~n + 1, n).filter(j => j < 0 ? matrix[~j * n + i] : matrix[i * n + j]); + if (sortSubgroups) subgroupIndex.sort((a, b) => sortSubgroups(a < 0 ? -matrix[~a * n + i] : matrix[i * n + a], b < 0 ? -matrix[~b * n + i] : matrix[i * n + b])); + for (const j of subgroupIndex) { + if (j < 0) { + const chord = chords[~j * n + i] || (chords[~j * n + i] = {source: null, target: null}); + chord.target = {index: i, startAngle: x, endAngle: x += matrix[~j * n + i] * k, value: matrix[~j * n + i]}; + } else { + const chord = chords[i * n + j] || (chords[i * n + j] = {source: null, target: null}); + chord.source = {index: i, startAngle: x, endAngle: x += matrix[i * n + j] * k, value: matrix[i * n + j]}; + } + } + groups[i] = {index: i, startAngle: x0, endAngle: x, value: groupSums[i]}; + } else { + const subgroupIndex = range$1(0, n).filter(j => matrix[i * n + j] || matrix[j * n + i]); + if (sortSubgroups) subgroupIndex.sort((a, b) => sortSubgroups(matrix[i * n + a], matrix[i * n + b])); + for (const j of subgroupIndex) { + let chord; + if (i < j) { + chord = chords[i * n + j] || (chords[i * n + j] = {source: null, target: null}); + chord.source = {index: i, startAngle: x, endAngle: x += matrix[i * n + j] * k, value: matrix[i * n + j]}; + } else { + chord = chords[j * n + i] || (chords[j * n + i] = {source: null, target: null}); + chord.target = {index: i, startAngle: x, endAngle: x += matrix[i * n + j] * k, value: matrix[i * n + j]}; + if (i === j) chord.source = chord.target; + } + if (chord.source && chord.target && chord.source.value < chord.target.value) { + const source = chord.source; + chord.source = chord.target; + chord.target = source; + } + } + groups[i] = {index: i, startAngle: x0, endAngle: x, value: groupSums[i]}; + } + x += dx; + } + } + + // Remove empty chords. + chords = Object.values(chords); + chords.groups = groups; + return sortChords ? chords.sort(sortChords) : chords; + } + + chord.padAngle = function(_) { + return arguments.length ? (padAngle = max$1(0, _), chord) : padAngle; + }; + + chord.sortGroups = function(_) { + return arguments.length ? (sortGroups = _, chord) : sortGroups; + }; + + chord.sortSubgroups = function(_) { + return arguments.length ? (sortSubgroups = _, chord) : sortSubgroups; + }; + + chord.sortChords = function(_) { + return arguments.length ? (_ == null ? sortChords = null : (sortChords = compareValue(_))._ = _, chord) : sortChords && sortChords._; + }; + + return chord; +} + +const pi$2 = Math.PI, + tau$3 = 2 * pi$2, + epsilon$4 = 1e-6, + tauEpsilon = tau$3 - epsilon$4; + +function Path$1() { + this._x0 = this._y0 = // start of current subpath + this._x1 = this._y1 = null; // end of current subpath + this._ = ""; +} + +function path() { + return new Path$1; +} + +Path$1.prototype = path.prototype = { + constructor: Path$1, + moveTo: function(x, y) { + this._ += "M" + (this._x0 = this._x1 = +x) + "," + (this._y0 = this._y1 = +y); + }, + closePath: function() { + if (this._x1 !== null) { + this._x1 = this._x0, this._y1 = this._y0; + this._ += "Z"; + } + }, + lineTo: function(x, y) { + this._ += "L" + (this._x1 = +x) + "," + (this._y1 = +y); + }, + quadraticCurveTo: function(x1, y1, x, y) { + this._ += "Q" + (+x1) + "," + (+y1) + "," + (this._x1 = +x) + "," + (this._y1 = +y); + }, + bezierCurveTo: function(x1, y1, x2, y2, x, y) { + this._ += "C" + (+x1) + "," + (+y1) + "," + (+x2) + "," + (+y2) + "," + (this._x1 = +x) + "," + (this._y1 = +y); + }, + arcTo: function(x1, y1, x2, y2, r) { + x1 = +x1, y1 = +y1, x2 = +x2, y2 = +y2, r = +r; + var x0 = this._x1, + y0 = this._y1, + x21 = x2 - x1, + y21 = y2 - y1, + x01 = x0 - x1, + y01 = y0 - y1, + l01_2 = x01 * x01 + y01 * y01; + + // Is the radius negative? Error. + if (r < 0) throw new Error("negative radius: " + r); + + // Is this path empty? Move to (x1,y1). + if (this._x1 === null) { + this._ += "M" + (this._x1 = x1) + "," + (this._y1 = y1); + } + + // Or, is (x1,y1) coincident with (x0,y0)? Do nothing. + else if (!(l01_2 > epsilon$4)); + + // Or, are (x0,y0), (x1,y1) and (x2,y2) collinear? + // Equivalently, is (x1,y1) coincident with (x2,y2)? + // Or, is the radius zero? Line to (x1,y1). + else if (!(Math.abs(y01 * x21 - y21 * x01) > epsilon$4) || !r) { + this._ += "L" + (this._x1 = x1) + "," + (this._y1 = y1); + } + + // Otherwise, draw an arc! + else { + var x20 = x2 - x0, + y20 = y2 - y0, + l21_2 = x21 * x21 + y21 * y21, + l20_2 = x20 * x20 + y20 * y20, + l21 = Math.sqrt(l21_2), + l01 = Math.sqrt(l01_2), + l = r * Math.tan((pi$2 - Math.acos((l21_2 + l01_2 - l20_2) / (2 * l21 * l01))) / 2), + t01 = l / l01, + t21 = l / l21; + + // If the start tangent is not coincident with (x0,y0), line to. + if (Math.abs(t01 - 1) > epsilon$4) { + this._ += "L" + (x1 + t01 * x01) + "," + (y1 + t01 * y01); + } + + this._ += "A" + r + "," + r + ",0,0," + (+(y01 * x20 > x01 * y20)) + "," + (this._x1 = x1 + t21 * x21) + "," + (this._y1 = y1 + t21 * y21); + } + }, + arc: function(x, y, r, a0, a1, ccw) { + x = +x, y = +y, r = +r, ccw = !!ccw; + var dx = r * Math.cos(a0), + dy = r * Math.sin(a0), + x0 = x + dx, + y0 = y + dy, + cw = 1 ^ ccw, + da = ccw ? a0 - a1 : a1 - a0; + + // Is the radius negative? Error. + if (r < 0) throw new Error("negative radius: " + r); + + // Is this path empty? Move to (x0,y0). + if (this._x1 === null) { + this._ += "M" + x0 + "," + y0; + } + + // Or, is (x0,y0) not coincident with the previous point? Line to (x0,y0). + else if (Math.abs(this._x1 - x0) > epsilon$4 || Math.abs(this._y1 - y0) > epsilon$4) { + this._ += "L" + x0 + "," + y0; + } + + // Is this arc empty? We’re done. + if (!r) return; + + // Does the angle go the wrong way? Flip the direction. + if (da < 0) da = da % tau$3 + tau$3; + + // Is this a complete circle? Draw two arcs to complete the circle. + if (da > tauEpsilon) { + this._ += "A" + r + "," + r + ",0,1," + cw + "," + (x - dx) + "," + (y - dy) + "A" + r + "," + r + ",0,1," + cw + "," + (this._x1 = x0) + "," + (this._y1 = y0); + } + + // Is this arc non-empty? Draw an arc! + else if (da > epsilon$4) { + this._ += "A" + r + "," + r + ",0," + (+(da >= pi$2)) + "," + cw + "," + (this._x1 = x + r * Math.cos(a1)) + "," + (this._y1 = y + r * Math.sin(a1)); + } + }, + rect: function(x, y, w, h) { + this._ += "M" + (this._x0 = this._x1 = +x) + "," + (this._y0 = this._y1 = +y) + "h" + (+w) + "v" + (+h) + "h" + (-w) + "Z"; + }, + toString: function() { + return this._; + } +}; + +var slice$2 = Array.prototype.slice; + +function constant$6(x) { + return function() { + return x; + }; +} + +function defaultSource$1(d) { + return d.source; +} + +function defaultTarget(d) { + return d.target; +} + +function defaultRadius$1(d) { + return d.radius; +} + +function defaultStartAngle(d) { + return d.startAngle; +} + +function defaultEndAngle(d) { + return d.endAngle; +} + +function defaultPadAngle() { + return 0; +} + +function defaultArrowheadRadius() { + return 10; +} + +function ribbon(headRadius) { + var source = defaultSource$1, + target = defaultTarget, + sourceRadius = defaultRadius$1, + targetRadius = defaultRadius$1, + startAngle = defaultStartAngle, + endAngle = defaultEndAngle, + padAngle = defaultPadAngle, + context = null; + + function ribbon() { + var buffer, + s = source.apply(this, arguments), + t = target.apply(this, arguments), + ap = padAngle.apply(this, arguments) / 2, + argv = slice$2.call(arguments), + sr = +sourceRadius.apply(this, (argv[0] = s, argv)), + sa0 = startAngle.apply(this, argv) - halfPi$2, + sa1 = endAngle.apply(this, argv) - halfPi$2, + tr = +targetRadius.apply(this, (argv[0] = t, argv)), + ta0 = startAngle.apply(this, argv) - halfPi$2, + ta1 = endAngle.apply(this, argv) - halfPi$2; + + if (!context) context = buffer = path(); + + if (ap > epsilon$5) { + if (abs$2(sa1 - sa0) > ap * 2 + epsilon$5) sa1 > sa0 ? (sa0 += ap, sa1 -= ap) : (sa0 -= ap, sa1 += ap); + else sa0 = sa1 = (sa0 + sa1) / 2; + if (abs$2(ta1 - ta0) > ap * 2 + epsilon$5) ta1 > ta0 ? (ta0 += ap, ta1 -= ap) : (ta0 -= ap, ta1 += ap); + else ta0 = ta1 = (ta0 + ta1) / 2; + } + + context.moveTo(sr * cos$2(sa0), sr * sin$2(sa0)); + context.arc(0, 0, sr, sa0, sa1); + if (sa0 !== ta0 || sa1 !== ta1) { + if (headRadius) { + var hr = +headRadius.apply(this, arguments), tr2 = tr - hr, ta2 = (ta0 + ta1) / 2; + context.quadraticCurveTo(0, 0, tr2 * cos$2(ta0), tr2 * sin$2(ta0)); + context.lineTo(tr * cos$2(ta2), tr * sin$2(ta2)); + context.lineTo(tr2 * cos$2(ta1), tr2 * sin$2(ta1)); + } else { + context.quadraticCurveTo(0, 0, tr * cos$2(ta0), tr * sin$2(ta0)); + context.arc(0, 0, tr, ta0, ta1); + } + } + context.quadraticCurveTo(0, 0, sr * cos$2(sa0), sr * sin$2(sa0)); + context.closePath(); + + if (buffer) return context = null, buffer + "" || null; + } + + if (headRadius) ribbon.headRadius = function(_) { + return arguments.length ? (headRadius = typeof _ === "function" ? _ : constant$6(+_), ribbon) : headRadius; + }; + + ribbon.radius = function(_) { + return arguments.length ? (sourceRadius = targetRadius = typeof _ === "function" ? _ : constant$6(+_), ribbon) : sourceRadius; + }; + + ribbon.sourceRadius = function(_) { + return arguments.length ? (sourceRadius = typeof _ === "function" ? _ : constant$6(+_), ribbon) : sourceRadius; + }; + + ribbon.targetRadius = function(_) { + return arguments.length ? (targetRadius = typeof _ === "function" ? _ : constant$6(+_), ribbon) : targetRadius; + }; + + ribbon.startAngle = function(_) { + return arguments.length ? (startAngle = typeof _ === "function" ? _ : constant$6(+_), ribbon) : startAngle; + }; + + ribbon.endAngle = function(_) { + return arguments.length ? (endAngle = typeof _ === "function" ? _ : constant$6(+_), ribbon) : endAngle; + }; + + ribbon.padAngle = function(_) { + return arguments.length ? (padAngle = typeof _ === "function" ? _ : constant$6(+_), ribbon) : padAngle; + }; + + ribbon.source = function(_) { + return arguments.length ? (source = _, ribbon) : source; + }; + + ribbon.target = function(_) { + return arguments.length ? (target = _, ribbon) : target; + }; + + ribbon.context = function(_) { + return arguments.length ? ((context = _ == null ? null : _), ribbon) : context; + }; + + return ribbon; +} + +function ribbon$1() { + return ribbon(); +} + +function ribbonArrow() { + return ribbon(defaultArrowheadRadius); +} + +var array$2 = Array.prototype; + +var slice$1 = array$2.slice; + +function ascending$1(a, b) { + return a - b; +} + +function area$3(ring) { + var i = 0, n = ring.length, area = ring[n - 1][1] * ring[0][0] - ring[n - 1][0] * ring[0][1]; + while (++i < n) area += ring[i - 1][1] * ring[i][0] - ring[i - 1][0] * ring[i][1]; + return area; +} + +var constant$5 = x => () => x; + +function contains$2(ring, hole) { + var i = -1, n = hole.length, c; + while (++i < n) if (c = ringContains(ring, hole[i])) return c; + return 0; +} + +function ringContains(ring, point) { + var x = point[0], y = point[1], contains = -1; + for (var i = 0, n = ring.length, j = n - 1; i < n; j = i++) { + var pi = ring[i], xi = pi[0], yi = pi[1], pj = ring[j], xj = pj[0], yj = pj[1]; + if (segmentContains(pi, pj, point)) return 0; + if (((yi > y) !== (yj > y)) && ((x < (xj - xi) * (y - yi) / (yj - yi) + xi))) contains = -contains; + } + return contains; +} + +function segmentContains(a, b, c) { + var i; return collinear$1(a, b, c) && within(a[i = +(a[0] === b[0])], c[i], b[i]); +} + +function collinear$1(a, b, c) { + return (b[0] - a[0]) * (c[1] - a[1]) === (c[0] - a[0]) * (b[1] - a[1]); +} + +function within(p, q, r) { + return p <= q && q <= r || r <= q && q <= p; +} + +function noop$2() {} + +var cases = [ + [], + [[[1.0, 1.5], [0.5, 1.0]]], + [[[1.5, 1.0], [1.0, 1.5]]], + [[[1.5, 1.0], [0.5, 1.0]]], + [[[1.0, 0.5], [1.5, 1.0]]], + [[[1.0, 1.5], [0.5, 1.0]], [[1.0, 0.5], [1.5, 1.0]]], + [[[1.0, 0.5], [1.0, 1.5]]], + [[[1.0, 0.5], [0.5, 1.0]]], + [[[0.5, 1.0], [1.0, 0.5]]], + [[[1.0, 1.5], [1.0, 0.5]]], + [[[0.5, 1.0], [1.0, 0.5]], [[1.5, 1.0], [1.0, 1.5]]], + [[[1.5, 1.0], [1.0, 0.5]]], + [[[0.5, 1.0], [1.5, 1.0]]], + [[[1.0, 1.5], [1.5, 1.0]]], + [[[0.5, 1.0], [1.0, 1.5]]], + [] +]; + +function contours() { + var dx = 1, + dy = 1, + threshold = thresholdSturges, + smooth = smoothLinear; + + function contours(values) { + var tz = threshold(values); + + // Convert number of thresholds into uniform thresholds. + if (!Array.isArray(tz)) { + const e = extent$1(values), ts = tickStep(e[0], e[1], tz); + tz = ticks(Math.floor(e[0] / ts) * ts, Math.floor(e[1] / ts - 1) * ts, tz); + } else { + tz = tz.slice().sort(ascending$1); + } + + return tz.map(value => contour(values, value)); + } + + // Accumulate, smooth contour rings, assign holes to exterior rings. + // Based on https://github.com/mbostock/shapefile/blob/v0.6.2/shp/polygon.js + function contour(values, value) { + var polygons = [], + holes = []; + + isorings(values, value, function(ring) { + smooth(ring, values, value); + if (area$3(ring) > 0) polygons.push([ring]); + else holes.push(ring); + }); + + holes.forEach(function(hole) { + for (var i = 0, n = polygons.length, polygon; i < n; ++i) { + if (contains$2((polygon = polygons[i])[0], hole) !== -1) { + polygon.push(hole); + return; + } + } + }); + + return { + type: "MultiPolygon", + value: value, + coordinates: polygons + }; + } + + // Marching squares with isolines stitched into rings. + // Based on https://github.com/topojson/topojson-client/blob/v3.0.0/src/stitch.js + function isorings(values, value, callback) { + var fragmentByStart = new Array, + fragmentByEnd = new Array, + x, y, t0, t1, t2, t3; + + // Special case for the first row (y = -1, t2 = t3 = 0). + x = y = -1; + t1 = values[0] >= value; + cases[t1 << 1].forEach(stitch); + while (++x < dx - 1) { + t0 = t1, t1 = values[x + 1] >= value; + cases[t0 | t1 << 1].forEach(stitch); + } + cases[t1 << 0].forEach(stitch); + + // General case for the intermediate rows. + while (++y < dy - 1) { + x = -1; + t1 = values[y * dx + dx] >= value; + t2 = values[y * dx] >= value; + cases[t1 << 1 | t2 << 2].forEach(stitch); + while (++x < dx - 1) { + t0 = t1, t1 = values[y * dx + dx + x + 1] >= value; + t3 = t2, t2 = values[y * dx + x + 1] >= value; + cases[t0 | t1 << 1 | t2 << 2 | t3 << 3].forEach(stitch); + } + cases[t1 | t2 << 3].forEach(stitch); + } + + // Special case for the last row (y = dy - 1, t0 = t1 = 0). + x = -1; + t2 = values[y * dx] >= value; + cases[t2 << 2].forEach(stitch); + while (++x < dx - 1) { + t3 = t2, t2 = values[y * dx + x + 1] >= value; + cases[t2 << 2 | t3 << 3].forEach(stitch); + } + cases[t2 << 3].forEach(stitch); + + function stitch(line) { + var start = [line[0][0] + x, line[0][1] + y], + end = [line[1][0] + x, line[1][1] + y], + startIndex = index(start), + endIndex = index(end), + f, g; + if (f = fragmentByEnd[startIndex]) { + if (g = fragmentByStart[endIndex]) { + delete fragmentByEnd[f.end]; + delete fragmentByStart[g.start]; + if (f === g) { + f.ring.push(end); + callback(f.ring); + } else { + fragmentByStart[f.start] = fragmentByEnd[g.end] = {start: f.start, end: g.end, ring: f.ring.concat(g.ring)}; + } + } else { + delete fragmentByEnd[f.end]; + f.ring.push(end); + fragmentByEnd[f.end = endIndex] = f; + } + } else if (f = fragmentByStart[endIndex]) { + if (g = fragmentByEnd[startIndex]) { + delete fragmentByStart[f.start]; + delete fragmentByEnd[g.end]; + if (f === g) { + f.ring.push(end); + callback(f.ring); + } else { + fragmentByStart[g.start] = fragmentByEnd[f.end] = {start: g.start, end: f.end, ring: g.ring.concat(f.ring)}; + } + } else { + delete fragmentByStart[f.start]; + f.ring.unshift(start); + fragmentByStart[f.start = startIndex] = f; + } + } else { + fragmentByStart[startIndex] = fragmentByEnd[endIndex] = {start: startIndex, end: endIndex, ring: [start, end]}; + } + } + } + + function index(point) { + return point[0] * 2 + point[1] * (dx + 1) * 4; + } + + function smoothLinear(ring, values, value) { + ring.forEach(function(point) { + var x = point[0], + y = point[1], + xt = x | 0, + yt = y | 0, + v0, + v1 = values[yt * dx + xt]; + if (x > 0 && x < dx && xt === x) { + v0 = values[yt * dx + xt - 1]; + point[0] = x + (value - v0) / (v1 - v0) - 0.5; + } + if (y > 0 && y < dy && yt === y) { + v0 = values[(yt - 1) * dx + xt]; + point[1] = y + (value - v0) / (v1 - v0) - 0.5; + } + }); + } + + contours.contour = contour; + + contours.size = function(_) { + if (!arguments.length) return [dx, dy]; + var _0 = Math.floor(_[0]), _1 = Math.floor(_[1]); + if (!(_0 >= 0 && _1 >= 0)) throw new Error("invalid size"); + return dx = _0, dy = _1, contours; + }; + + contours.thresholds = function(_) { + return arguments.length ? (threshold = typeof _ === "function" ? _ : Array.isArray(_) ? constant$5(slice$1.call(_)) : constant$5(_), contours) : threshold; + }; + + contours.smooth = function(_) { + return arguments.length ? (smooth = _ ? smoothLinear : noop$2, contours) : smooth === smoothLinear; + }; + + return contours; +} + +// TODO Optimize edge cases. +// TODO Optimize index calculation. +// TODO Optimize arguments. +function blurX(source, target, r) { + var n = source.width, + m = source.height, + w = (r << 1) + 1; + for (var j = 0; j < m; ++j) { + for (var i = 0, sr = 0; i < n + r; ++i) { + if (i < n) { + sr += source.data[i + j * n]; + } + if (i >= r) { + if (i >= w) { + sr -= source.data[i - w + j * n]; + } + target.data[i - r + j * n] = sr / Math.min(i + 1, n - 1 + w - i, w); + } + } + } +} + +// TODO Optimize edge cases. +// TODO Optimize index calculation. +// TODO Optimize arguments. +function blurY(source, target, r) { + var n = source.width, + m = source.height, + w = (r << 1) + 1; + for (var i = 0; i < n; ++i) { + for (var j = 0, sr = 0; j < m + r; ++j) { + if (j < m) { + sr += source.data[i + j * n]; + } + if (j >= r) { + if (j >= w) { + sr -= source.data[i + (j - w) * n]; + } + target.data[i + (j - r) * n] = sr / Math.min(j + 1, m - 1 + w - j, w); + } + } + } +} + +function defaultX$1(d) { + return d[0]; +} + +function defaultY$1(d) { + return d[1]; +} + +function defaultWeight() { + return 1; +} + +function density() { + var x = defaultX$1, + y = defaultY$1, + weight = defaultWeight, + dx = 960, + dy = 500, + r = 20, // blur radius + k = 2, // log2(grid cell size) + o = r * 3, // grid offset, to pad for blur + n = (dx + o * 2) >> k, // grid width + m = (dy + o * 2) >> k, // grid height + threshold = constant$5(20); + + function density(data) { + var values0 = new Float32Array(n * m), + values1 = new Float32Array(n * m), + pow2k = Math.pow(2, -k); + + data.forEach(function(d, i, data) { + var xi = (x(d, i, data) + o) * pow2k, + yi = (y(d, i, data) + o) * pow2k, + wi = +weight(d, i, data); + if (xi >= 0 && xi < n && yi >= 0 && yi < m) { + var x0 = Math.floor(xi), + y0 = Math.floor(yi), + xt = xi - x0 - 0.5, + yt = yi - y0 - 0.5; + values0[x0 + y0 * n] += (1 - xt) * (1 - yt) * wi; + values0[x0 + 1 + y0 * n] += xt * (1 - yt) * wi; + values0[x0 + 1 + (y0 + 1) * n] += xt * yt * wi; + values0[x0 + (y0 + 1) * n] += (1 - xt) * yt * wi; + } + }); + + // TODO Optimize. + blurX({width: n, height: m, data: values0}, {width: n, height: m, data: values1}, r >> k); + blurY({width: n, height: m, data: values1}, {width: n, height: m, data: values0}, r >> k); + blurX({width: n, height: m, data: values0}, {width: n, height: m, data: values1}, r >> k); + blurY({width: n, height: m, data: values1}, {width: n, height: m, data: values0}, r >> k); + blurX({width: n, height: m, data: values0}, {width: n, height: m, data: values1}, r >> k); + blurY({width: n, height: m, data: values1}, {width: n, height: m, data: values0}, r >> k); + + var tz = threshold(values0); + + // Convert number of thresholds into uniform thresholds. + if (!Array.isArray(tz)) { + var stop = max$3(values0); + tz = tickStep(0, stop, tz); + tz = range$2(0, Math.floor(stop / tz) * tz, tz); + tz.shift(); + } + + return contours() + .thresholds(tz) + .size([n, m]) + (values0) + .map(transform); + } + + function transform(geometry) { + geometry.value *= Math.pow(2, -2 * k); // Density in points per square pixel. + geometry.coordinates.forEach(transformPolygon); + return geometry; + } + + function transformPolygon(coordinates) { + coordinates.forEach(transformRing); + } + + function transformRing(coordinates) { + coordinates.forEach(transformPoint); + } + + // TODO Optimize. + function transformPoint(coordinates) { + coordinates[0] = coordinates[0] * Math.pow(2, k) - o; + coordinates[1] = coordinates[1] * Math.pow(2, k) - o; + } + + function resize() { + o = r * 3; + n = (dx + o * 2) >> k; + m = (dy + o * 2) >> k; + return density; + } + + density.x = function(_) { + return arguments.length ? (x = typeof _ === "function" ? _ : constant$5(+_), density) : x; + }; + + density.y = function(_) { + return arguments.length ? (y = typeof _ === "function" ? _ : constant$5(+_), density) : y; + }; + + density.weight = function(_) { + return arguments.length ? (weight = typeof _ === "function" ? _ : constant$5(+_), density) : weight; + }; + + density.size = function(_) { + if (!arguments.length) return [dx, dy]; + var _0 = +_[0], _1 = +_[1]; + if (!(_0 >= 0 && _1 >= 0)) throw new Error("invalid size"); + return dx = _0, dy = _1, resize(); + }; + + density.cellSize = function(_) { + if (!arguments.length) return 1 << k; + if (!((_ = +_) >= 1)) throw new Error("invalid cell size"); + return k = Math.floor(Math.log(_) / Math.LN2), resize(); + }; + + density.thresholds = function(_) { + return arguments.length ? (threshold = typeof _ === "function" ? _ : Array.isArray(_) ? constant$5(slice$1.call(_)) : constant$5(_), density) : threshold; + }; + + density.bandwidth = function(_) { + if (!arguments.length) return Math.sqrt(r * (r + 1)); + if (!((_ = +_) >= 0)) throw new Error("invalid bandwidth"); + return r = Math.round((Math.sqrt(4 * _ * _ + 1) - 1) / 2), resize(); + }; + + return density; +} + +const epsilon$3 = 1.1102230246251565e-16; +const splitter = 134217729; +const resulterrbound = (3 + 8 * epsilon$3) * epsilon$3; + +// fast_expansion_sum_zeroelim routine from oritinal code +function sum$1(elen, e, flen, f, h) { + let Q, Qnew, hh, bvirt; + let enow = e[0]; + let fnow = f[0]; + let eindex = 0; + let findex = 0; + if ((fnow > enow) === (fnow > -enow)) { + Q = enow; + enow = e[++eindex]; + } else { + Q = fnow; + fnow = f[++findex]; + } + let hindex = 0; + if (eindex < elen && findex < flen) { + if ((fnow > enow) === (fnow > -enow)) { + Qnew = enow + Q; + hh = Q - (Qnew - enow); + enow = e[++eindex]; + } else { + Qnew = fnow + Q; + hh = Q - (Qnew - fnow); + fnow = f[++findex]; + } + Q = Qnew; + if (hh !== 0) { + h[hindex++] = hh; + } + while (eindex < elen && findex < flen) { + if ((fnow > enow) === (fnow > -enow)) { + Qnew = Q + enow; + bvirt = Qnew - Q; + hh = Q - (Qnew - bvirt) + (enow - bvirt); + enow = e[++eindex]; + } else { + Qnew = Q + fnow; + bvirt = Qnew - Q; + hh = Q - (Qnew - bvirt) + (fnow - bvirt); + fnow = f[++findex]; + } + Q = Qnew; + if (hh !== 0) { + h[hindex++] = hh; + } + } + } + while (eindex < elen) { + Qnew = Q + enow; + bvirt = Qnew - Q; + hh = Q - (Qnew - bvirt) + (enow - bvirt); + enow = e[++eindex]; + Q = Qnew; + if (hh !== 0) { + h[hindex++] = hh; + } + } + while (findex < flen) { + Qnew = Q + fnow; + bvirt = Qnew - Q; + hh = Q - (Qnew - bvirt) + (fnow - bvirt); + fnow = f[++findex]; + Q = Qnew; + if (hh !== 0) { + h[hindex++] = hh; + } + } + if (Q !== 0 || hindex === 0) { + h[hindex++] = Q; + } + return hindex; +} + +function estimate(elen, e) { + let Q = e[0]; + for (let i = 1; i < elen; i++) Q += e[i]; + return Q; +} + +function vec(n) { + return new Float64Array(n); +} + +const ccwerrboundA = (3 + 16 * epsilon$3) * epsilon$3; +const ccwerrboundB = (2 + 12 * epsilon$3) * epsilon$3; +const ccwerrboundC = (9 + 64 * epsilon$3) * epsilon$3 * epsilon$3; + +const B = vec(4); +const C1 = vec(8); +const C2 = vec(12); +const D = vec(16); +const u = vec(4); + +function orient2dadapt(ax, ay, bx, by, cx, cy, detsum) { + let acxtail, acytail, bcxtail, bcytail; + let bvirt, c, ahi, alo, bhi, blo, _i, _j, _0, s1, s0, t1, t0, u3; + + const acx = ax - cx; + const bcx = bx - cx; + const acy = ay - cy; + const bcy = by - cy; + + s1 = acx * bcy; + c = splitter * acx; + ahi = c - (c - acx); + alo = acx - ahi; + c = splitter * bcy; + bhi = c - (c - bcy); + blo = bcy - bhi; + s0 = alo * blo - (s1 - ahi * bhi - alo * bhi - ahi * blo); + t1 = acy * bcx; + c = splitter * acy; + ahi = c - (c - acy); + alo = acy - ahi; + c = splitter * bcx; + bhi = c - (c - bcx); + blo = bcx - bhi; + t0 = alo * blo - (t1 - ahi * bhi - alo * bhi - ahi * blo); + _i = s0 - t0; + bvirt = s0 - _i; + B[0] = s0 - (_i + bvirt) + (bvirt - t0); + _j = s1 + _i; + bvirt = _j - s1; + _0 = s1 - (_j - bvirt) + (_i - bvirt); + _i = _0 - t1; + bvirt = _0 - _i; + B[1] = _0 - (_i + bvirt) + (bvirt - t1); + u3 = _j + _i; + bvirt = u3 - _j; + B[2] = _j - (u3 - bvirt) + (_i - bvirt); + B[3] = u3; + + let det = estimate(4, B); + let errbound = ccwerrboundB * detsum; + if (det >= errbound || -det >= errbound) { + return det; + } + + bvirt = ax - acx; + acxtail = ax - (acx + bvirt) + (bvirt - cx); + bvirt = bx - bcx; + bcxtail = bx - (bcx + bvirt) + (bvirt - cx); + bvirt = ay - acy; + acytail = ay - (acy + bvirt) + (bvirt - cy); + bvirt = by - bcy; + bcytail = by - (bcy + bvirt) + (bvirt - cy); + + if (acxtail === 0 && acytail === 0 && bcxtail === 0 && bcytail === 0) { + return det; + } + + errbound = ccwerrboundC * detsum + resulterrbound * Math.abs(det); + det += (acx * bcytail + bcy * acxtail) - (acy * bcxtail + bcx * acytail); + if (det >= errbound || -det >= errbound) return det; + + s1 = acxtail * bcy; + c = splitter * acxtail; + ahi = c - (c - acxtail); + alo = acxtail - ahi; + c = splitter * bcy; + bhi = c - (c - bcy); + blo = bcy - bhi; + s0 = alo * blo - (s1 - ahi * bhi - alo * bhi - ahi * blo); + t1 = acytail * bcx; + c = splitter * acytail; + ahi = c - (c - acytail); + alo = acytail - ahi; + c = splitter * bcx; + bhi = c - (c - bcx); + blo = bcx - bhi; + t0 = alo * blo - (t1 - ahi * bhi - alo * bhi - ahi * blo); + _i = s0 - t0; + bvirt = s0 - _i; + u[0] = s0 - (_i + bvirt) + (bvirt - t0); + _j = s1 + _i; + bvirt = _j - s1; + _0 = s1 - (_j - bvirt) + (_i - bvirt); + _i = _0 - t1; + bvirt = _0 - _i; + u[1] = _0 - (_i + bvirt) + (bvirt - t1); + u3 = _j + _i; + bvirt = u3 - _j; + u[2] = _j - (u3 - bvirt) + (_i - bvirt); + u[3] = u3; + const C1len = sum$1(4, B, 4, u, C1); + + s1 = acx * bcytail; + c = splitter * acx; + ahi = c - (c - acx); + alo = acx - ahi; + c = splitter * bcytail; + bhi = c - (c - bcytail); + blo = bcytail - bhi; + s0 = alo * blo - (s1 - ahi * bhi - alo * bhi - ahi * blo); + t1 = acy * bcxtail; + c = splitter * acy; + ahi = c - (c - acy); + alo = acy - ahi; + c = splitter * bcxtail; + bhi = c - (c - bcxtail); + blo = bcxtail - bhi; + t0 = alo * blo - (t1 - ahi * bhi - alo * bhi - ahi * blo); + _i = s0 - t0; + bvirt = s0 - _i; + u[0] = s0 - (_i + bvirt) + (bvirt - t0); + _j = s1 + _i; + bvirt = _j - s1; + _0 = s1 - (_j - bvirt) + (_i - bvirt); + _i = _0 - t1; + bvirt = _0 - _i; + u[1] = _0 - (_i + bvirt) + (bvirt - t1); + u3 = _j + _i; + bvirt = u3 - _j; + u[2] = _j - (u3 - bvirt) + (_i - bvirt); + u[3] = u3; + const C2len = sum$1(C1len, C1, 4, u, C2); + + s1 = acxtail * bcytail; + c = splitter * acxtail; + ahi = c - (c - acxtail); + alo = acxtail - ahi; + c = splitter * bcytail; + bhi = c - (c - bcytail); + blo = bcytail - bhi; + s0 = alo * blo - (s1 - ahi * bhi - alo * bhi - ahi * blo); + t1 = acytail * bcxtail; + c = splitter * acytail; + ahi = c - (c - acytail); + alo = acytail - ahi; + c = splitter * bcxtail; + bhi = c - (c - bcxtail); + blo = bcxtail - bhi; + t0 = alo * blo - (t1 - ahi * bhi - alo * bhi - ahi * blo); + _i = s0 - t0; + bvirt = s0 - _i; + u[0] = s0 - (_i + bvirt) + (bvirt - t0); + _j = s1 + _i; + bvirt = _j - s1; + _0 = s1 - (_j - bvirt) + (_i - bvirt); + _i = _0 - t1; + bvirt = _0 - _i; + u[1] = _0 - (_i + bvirt) + (bvirt - t1); + u3 = _j + _i; + bvirt = u3 - _j; + u[2] = _j - (u3 - bvirt) + (_i - bvirt); + u[3] = u3; + const Dlen = sum$1(C2len, C2, 4, u, D); + + return D[Dlen - 1]; +} + +function orient2d(ax, ay, bx, by, cx, cy) { + const detleft = (ay - cy) * (bx - cx); + const detright = (ax - cx) * (by - cy); + const det = detleft - detright; + + if (detleft === 0 || detright === 0 || (detleft > 0) !== (detright > 0)) return det; + + const detsum = Math.abs(detleft + detright); + if (Math.abs(det) >= ccwerrboundA * detsum) return det; + + return -orient2dadapt(ax, ay, bx, by, cx, cy, detsum); +} + +const EPSILON = Math.pow(2, -52); +const EDGE_STACK = new Uint32Array(512); + +class Delaunator { + + static from(points, getX = defaultGetX, getY = defaultGetY) { + const n = points.length; + const coords = new Float64Array(n * 2); + + for (let i = 0; i < n; i++) { + const p = points[i]; + coords[2 * i] = getX(p); + coords[2 * i + 1] = getY(p); + } + + return new Delaunator(coords); + } + + constructor(coords) { + const n = coords.length >> 1; + if (n > 0 && typeof coords[0] !== 'number') throw new Error('Expected coords to contain numbers.'); + + this.coords = coords; + + // arrays that will store the triangulation graph + const maxTriangles = Math.max(2 * n - 5, 0); + this._triangles = new Uint32Array(maxTriangles * 3); + this._halfedges = new Int32Array(maxTriangles * 3); + + // temporary arrays for tracking the edges of the advancing convex hull + this._hashSize = Math.ceil(Math.sqrt(n)); + this._hullPrev = new Uint32Array(n); // edge to prev edge + this._hullNext = new Uint32Array(n); // edge to next edge + this._hullTri = new Uint32Array(n); // edge to adjacent triangle + this._hullHash = new Int32Array(this._hashSize).fill(-1); // angular edge hash + + // temporary arrays for sorting points + this._ids = new Uint32Array(n); + this._dists = new Float64Array(n); + + this.update(); + } + + update() { + const {coords, _hullPrev: hullPrev, _hullNext: hullNext, _hullTri: hullTri, _hullHash: hullHash} = this; + const n = coords.length >> 1; + + // populate an array of point indices; calculate input data bbox + let minX = Infinity; + let minY = Infinity; + let maxX = -Infinity; + let maxY = -Infinity; + + for (let i = 0; i < n; i++) { + const x = coords[2 * i]; + const y = coords[2 * i + 1]; + if (x < minX) minX = x; + if (y < minY) minY = y; + if (x > maxX) maxX = x; + if (y > maxY) maxY = y; + this._ids[i] = i; + } + const cx = (minX + maxX) / 2; + const cy = (minY + maxY) / 2; + + let minDist = Infinity; + let i0, i1, i2; + + // pick a seed point close to the center + for (let i = 0; i < n; i++) { + const d = dist(cx, cy, coords[2 * i], coords[2 * i + 1]); + if (d < minDist) { + i0 = i; + minDist = d; + } + } + const i0x = coords[2 * i0]; + const i0y = coords[2 * i0 + 1]; + + minDist = Infinity; + + // find the point closest to the seed + for (let i = 0; i < n; i++) { + if (i === i0) continue; + const d = dist(i0x, i0y, coords[2 * i], coords[2 * i + 1]); + if (d < minDist && d > 0) { + i1 = i; + minDist = d; + } + } + let i1x = coords[2 * i1]; + let i1y = coords[2 * i1 + 1]; + + let minRadius = Infinity; + + // find the third point which forms the smallest circumcircle with the first two + for (let i = 0; i < n; i++) { + if (i === i0 || i === i1) continue; + const r = circumradius(i0x, i0y, i1x, i1y, coords[2 * i], coords[2 * i + 1]); + if (r < minRadius) { + i2 = i; + minRadius = r; + } + } + let i2x = coords[2 * i2]; + let i2y = coords[2 * i2 + 1]; + + if (minRadius === Infinity) { + // order collinear points by dx (or dy if all x are identical) + // and return the list as a hull + for (let i = 0; i < n; i++) { + this._dists[i] = (coords[2 * i] - coords[0]) || (coords[2 * i + 1] - coords[1]); + } + quicksort(this._ids, this._dists, 0, n - 1); + const hull = new Uint32Array(n); + let j = 0; + for (let i = 0, d0 = -Infinity; i < n; i++) { + const id = this._ids[i]; + if (this._dists[id] > d0) { + hull[j++] = id; + d0 = this._dists[id]; + } + } + this.hull = hull.subarray(0, j); + this.triangles = new Uint32Array(0); + this.halfedges = new Uint32Array(0); + return; + } + + // swap the order of the seed points for counter-clockwise orientation + if (orient2d(i0x, i0y, i1x, i1y, i2x, i2y) < 0) { + const i = i1; + const x = i1x; + const y = i1y; + i1 = i2; + i1x = i2x; + i1y = i2y; + i2 = i; + i2x = x; + i2y = y; + } + + const center = circumcenter(i0x, i0y, i1x, i1y, i2x, i2y); + this._cx = center.x; + this._cy = center.y; + + for (let i = 0; i < n; i++) { + this._dists[i] = dist(coords[2 * i], coords[2 * i + 1], center.x, center.y); + } + + // sort the points by distance from the seed triangle circumcenter + quicksort(this._ids, this._dists, 0, n - 1); + + // set up the seed triangle as the starting hull + this._hullStart = i0; + let hullSize = 3; + + hullNext[i0] = hullPrev[i2] = i1; + hullNext[i1] = hullPrev[i0] = i2; + hullNext[i2] = hullPrev[i1] = i0; + + hullTri[i0] = 0; + hullTri[i1] = 1; + hullTri[i2] = 2; + + hullHash.fill(-1); + hullHash[this._hashKey(i0x, i0y)] = i0; + hullHash[this._hashKey(i1x, i1y)] = i1; + hullHash[this._hashKey(i2x, i2y)] = i2; + + this.trianglesLen = 0; + this._addTriangle(i0, i1, i2, -1, -1, -1); + + for (let k = 0, xp, yp; k < this._ids.length; k++) { + const i = this._ids[k]; + const x = coords[2 * i]; + const y = coords[2 * i + 1]; + + // skip near-duplicate points + if (k > 0 && Math.abs(x - xp) <= EPSILON && Math.abs(y - yp) <= EPSILON) continue; + xp = x; + yp = y; + + // skip seed triangle points + if (i === i0 || i === i1 || i === i2) continue; + + // find a visible edge on the convex hull using edge hash + let start = 0; + for (let j = 0, key = this._hashKey(x, y); j < this._hashSize; j++) { + start = hullHash[(key + j) % this._hashSize]; + if (start !== -1 && start !== hullNext[start]) break; + } + + start = hullPrev[start]; + let e = start, q; + while (q = hullNext[e], orient2d(x, y, coords[2 * e], coords[2 * e + 1], coords[2 * q], coords[2 * q + 1]) >= 0) { + e = q; + if (e === start) { + e = -1; + break; + } + } + if (e === -1) continue; // likely a near-duplicate point; skip it + + // add the first triangle from the point + let t = this._addTriangle(e, i, hullNext[e], -1, -1, hullTri[e]); + + // recursively flip triangles from the point until they satisfy the Delaunay condition + hullTri[i] = this._legalize(t + 2); + hullTri[e] = t; // keep track of boundary triangles on the hull + hullSize++; + + // walk forward through the hull, adding more triangles and flipping recursively + let n = hullNext[e]; + while (q = hullNext[n], orient2d(x, y, coords[2 * n], coords[2 * n + 1], coords[2 * q], coords[2 * q + 1]) < 0) { + t = this._addTriangle(n, i, q, hullTri[i], -1, hullTri[n]); + hullTri[i] = this._legalize(t + 2); + hullNext[n] = n; // mark as removed + hullSize--; + n = q; + } + + // walk backward from the other side, adding more triangles and flipping + if (e === start) { + while (q = hullPrev[e], orient2d(x, y, coords[2 * q], coords[2 * q + 1], coords[2 * e], coords[2 * e + 1]) < 0) { + t = this._addTriangle(q, i, e, -1, hullTri[e], hullTri[q]); + this._legalize(t + 2); + hullTri[q] = t; + hullNext[e] = e; // mark as removed + hullSize--; + e = q; + } + } + + // update the hull indices + this._hullStart = hullPrev[i] = e; + hullNext[e] = hullPrev[n] = i; + hullNext[i] = n; + + // save the two new edges in the hash table + hullHash[this._hashKey(x, y)] = i; + hullHash[this._hashKey(coords[2 * e], coords[2 * e + 1])] = e; + } + + this.hull = new Uint32Array(hullSize); + for (let i = 0, e = this._hullStart; i < hullSize; i++) { + this.hull[i] = e; + e = hullNext[e]; + } + + // trim typed triangle mesh arrays + this.triangles = this._triangles.subarray(0, this.trianglesLen); + this.halfedges = this._halfedges.subarray(0, this.trianglesLen); + } + + _hashKey(x, y) { + return Math.floor(pseudoAngle(x - this._cx, y - this._cy) * this._hashSize) % this._hashSize; + } + + _legalize(a) { + const {_triangles: triangles, _halfedges: halfedges, coords} = this; + + let i = 0; + let ar = 0; + + // recursion eliminated with a fixed-size stack + while (true) { + const b = halfedges[a]; + + /* if the pair of triangles doesn't satisfy the Delaunay condition + * (p1 is inside the circumcircle of [p0, pl, pr]), flip them, + * then do the same check/flip recursively for the new pair of triangles + * + * pl pl + * /||\ / \ + * al/ || \bl al/ \a + * / || \ / \ + * / a||b \ flip /___ar___\ + * p0\ || /p1 => p0\---bl---/p1 + * \ || / \ / + * ar\ || /br b\ /br + * \||/ \ / + * pr pr + */ + const a0 = a - a % 3; + ar = a0 + (a + 2) % 3; + + if (b === -1) { // convex hull edge + if (i === 0) break; + a = EDGE_STACK[--i]; + continue; + } + + const b0 = b - b % 3; + const al = a0 + (a + 1) % 3; + const bl = b0 + (b + 2) % 3; + + const p0 = triangles[ar]; + const pr = triangles[a]; + const pl = triangles[al]; + const p1 = triangles[bl]; + + const illegal = inCircle( + coords[2 * p0], coords[2 * p0 + 1], + coords[2 * pr], coords[2 * pr + 1], + coords[2 * pl], coords[2 * pl + 1], + coords[2 * p1], coords[2 * p1 + 1]); + + if (illegal) { + triangles[a] = p1; + triangles[b] = p0; + + const hbl = halfedges[bl]; + + // edge swapped on the other side of the hull (rare); fix the halfedge reference + if (hbl === -1) { + let e = this._hullStart; + do { + if (this._hullTri[e] === bl) { + this._hullTri[e] = a; + break; + } + e = this._hullPrev[e]; + } while (e !== this._hullStart); + } + this._link(a, hbl); + this._link(b, halfedges[ar]); + this._link(ar, bl); + + const br = b0 + (b + 1) % 3; + + // don't worry about hitting the cap: it can only happen on extremely degenerate input + if (i < EDGE_STACK.length) { + EDGE_STACK[i++] = br; + } + } else { + if (i === 0) break; + a = EDGE_STACK[--i]; + } + } + + return ar; + } + + _link(a, b) { + this._halfedges[a] = b; + if (b !== -1) this._halfedges[b] = a; + } + + // add a new triangle given vertex indices and adjacent half-edge ids + _addTriangle(i0, i1, i2, a, b, c) { + const t = this.trianglesLen; + + this._triangles[t] = i0; + this._triangles[t + 1] = i1; + this._triangles[t + 2] = i2; + + this._link(t, a); + this._link(t + 1, b); + this._link(t + 2, c); + + this.trianglesLen += 3; + + return t; + } +} + +// monotonically increases with real angle, but doesn't need expensive trigonometry +function pseudoAngle(dx, dy) { + const p = dx / (Math.abs(dx) + Math.abs(dy)); + return (dy > 0 ? 3 - p : 1 + p) / 4; // [0..1] +} + +function dist(ax, ay, bx, by) { + const dx = ax - bx; + const dy = ay - by; + return dx * dx + dy * dy; +} + +function inCircle(ax, ay, bx, by, cx, cy, px, py) { + const dx = ax - px; + const dy = ay - py; + const ex = bx - px; + const ey = by - py; + const fx = cx - px; + const fy = cy - py; + + const ap = dx * dx + dy * dy; + const bp = ex * ex + ey * ey; + const cp = fx * fx + fy * fy; + + return dx * (ey * cp - bp * fy) - + dy * (ex * cp - bp * fx) + + ap * (ex * fy - ey * fx) < 0; +} + +function circumradius(ax, ay, bx, by, cx, cy) { + const dx = bx - ax; + const dy = by - ay; + const ex = cx - ax; + const ey = cy - ay; + + const bl = dx * dx + dy * dy; + const cl = ex * ex + ey * ey; + const d = 0.5 / (dx * ey - dy * ex); + + const x = (ey * bl - dy * cl) * d; + const y = (dx * cl - ex * bl) * d; + + return x * x + y * y; +} + +function circumcenter(ax, ay, bx, by, cx, cy) { + const dx = bx - ax; + const dy = by - ay; + const ex = cx - ax; + const ey = cy - ay; + + const bl = dx * dx + dy * dy; + const cl = ex * ex + ey * ey; + const d = 0.5 / (dx * ey - dy * ex); + + const x = ax + (ey * bl - dy * cl) * d; + const y = ay + (dx * cl - ex * bl) * d; + + return {x, y}; +} + +function quicksort(ids, dists, left, right) { + if (right - left <= 20) { + for (let i = left + 1; i <= right; i++) { + const temp = ids[i]; + const tempDist = dists[temp]; + let j = i - 1; + while (j >= left && dists[ids[j]] > tempDist) ids[j + 1] = ids[j--]; + ids[j + 1] = temp; + } + } else { + const median = (left + right) >> 1; + let i = left + 1; + let j = right; + swap(ids, median, i); + if (dists[ids[left]] > dists[ids[right]]) swap(ids, left, right); + if (dists[ids[i]] > dists[ids[right]]) swap(ids, i, right); + if (dists[ids[left]] > dists[ids[i]]) swap(ids, left, i); + + const temp = ids[i]; + const tempDist = dists[temp]; + while (true) { + do i++; while (dists[ids[i]] < tempDist); + do j--; while (dists[ids[j]] > tempDist); + if (j < i) break; + swap(ids, i, j); + } + ids[left + 1] = ids[j]; + ids[j] = temp; + + if (right - i + 1 >= j - left) { + quicksort(ids, dists, i, right); + quicksort(ids, dists, left, j - 1); + } else { + quicksort(ids, dists, left, j - 1); + quicksort(ids, dists, i, right); + } + } +} + +function swap(arr, i, j) { + const tmp = arr[i]; + arr[i] = arr[j]; + arr[j] = tmp; +} + +function defaultGetX(p) { + return p[0]; +} +function defaultGetY(p) { + return p[1]; +} + +const epsilon$2 = 1e-6; + +class Path { + constructor() { + this._x0 = this._y0 = // start of current subpath + this._x1 = this._y1 = null; // end of current subpath + this._ = ""; + } + moveTo(x, y) { + this._ += `M${this._x0 = this._x1 = +x},${this._y0 = this._y1 = +y}`; + } + closePath() { + if (this._x1 !== null) { + this._x1 = this._x0, this._y1 = this._y0; + this._ += "Z"; + } + } + lineTo(x, y) { + this._ += `L${this._x1 = +x},${this._y1 = +y}`; + } + arc(x, y, r) { + x = +x, y = +y, r = +r; + const x0 = x + r; + const y0 = y; + if (r < 0) throw new Error("negative radius"); + if (this._x1 === null) this._ += `M${x0},${y0}`; + else if (Math.abs(this._x1 - x0) > epsilon$2 || Math.abs(this._y1 - y0) > epsilon$2) this._ += "L" + x0 + "," + y0; + if (!r) return; + this._ += `A${r},${r},0,1,1,${x - r},${y}A${r},${r},0,1,1,${this._x1 = x0},${this._y1 = y0}`; + } + rect(x, y, w, h) { + this._ += `M${this._x0 = this._x1 = +x},${this._y0 = this._y1 = +y}h${+w}v${+h}h${-w}Z`; + } + value() { + return this._ || null; + } +} + +class Polygon { + constructor() { + this._ = []; + } + moveTo(x, y) { + this._.push([x, y]); + } + closePath() { + this._.push(this._[0].slice()); + } + lineTo(x, y) { + this._.push([x, y]); + } + value() { + return this._.length ? this._ : null; + } +} + +class Voronoi { + constructor(delaunay, [xmin, ymin, xmax, ymax] = [0, 0, 960, 500]) { + if (!((xmax = +xmax) >= (xmin = +xmin)) || !((ymax = +ymax) >= (ymin = +ymin))) throw new Error("invalid bounds"); + this.delaunay = delaunay; + this._circumcenters = new Float64Array(delaunay.points.length * 2); + this.vectors = new Float64Array(delaunay.points.length * 2); + this.xmax = xmax, this.xmin = xmin; + this.ymax = ymax, this.ymin = ymin; + this._init(); + } + update() { + this.delaunay.update(); + this._init(); + return this; + } + _init() { + const {delaunay: {points, hull, triangles}, vectors} = this; + + // Compute circumcenters. + const circumcenters = this.circumcenters = this._circumcenters.subarray(0, triangles.length / 3 * 2); + for (let i = 0, j = 0, n = triangles.length, x, y; i < n; i += 3, j += 2) { + const t1 = triangles[i] * 2; + const t2 = triangles[i + 1] * 2; + const t3 = triangles[i + 2] * 2; + const x1 = points[t1]; + const y1 = points[t1 + 1]; + const x2 = points[t2]; + const y2 = points[t2 + 1]; + const x3 = points[t3]; + const y3 = points[t3 + 1]; + + const dx = x2 - x1; + const dy = y2 - y1; + const ex = x3 - x1; + const ey = y3 - y1; + const ab = (dx * ey - dy * ex) * 2; + + if (Math.abs(ab) < 1e-9) { + // degenerate case (collinear diagram) + // almost equal points (degenerate triangle) + // the circumcenter is at the infinity, in a + // direction that is: + // 1. orthogonal to the halfedge. + let a = 1e9; + // 2. points away from the center; since the list of triangles starts + // in the center, the first point of the first triangle + // will be our reference + const r = triangles[0] * 2; + a *= Math.sign((points[r] - x1) * ey - (points[r + 1] - y1) * ex); + x = (x1 + x3) / 2 - a * ey; + y = (y1 + y3) / 2 + a * ex; + } else { + const d = 1 / ab; + const bl = dx * dx + dy * dy; + const cl = ex * ex + ey * ey; + x = x1 + (ey * bl - dy * cl) * d; + y = y1 + (dx * cl - ex * bl) * d; + } + circumcenters[j] = x; + circumcenters[j + 1] = y; + } + + // Compute exterior cell rays. + let h = hull[hull.length - 1]; + let p0, p1 = h * 4; + let x0, x1 = points[2 * h]; + let y0, y1 = points[2 * h + 1]; + vectors.fill(0); + for (let i = 0; i < hull.length; ++i) { + h = hull[i]; + p0 = p1, x0 = x1, y0 = y1; + p1 = h * 4, x1 = points[2 * h], y1 = points[2 * h + 1]; + vectors[p0 + 2] = vectors[p1] = y0 - y1; + vectors[p0 + 3] = vectors[p1 + 1] = x1 - x0; + } + } + render(context) { + const buffer = context == null ? context = new Path : undefined; + const {delaunay: {halfedges, inedges, hull}, circumcenters, vectors} = this; + if (hull.length <= 1) return null; + for (let i = 0, n = halfedges.length; i < n; ++i) { + const j = halfedges[i]; + if (j < i) continue; + const ti = Math.floor(i / 3) * 2; + const tj = Math.floor(j / 3) * 2; + const xi = circumcenters[ti]; + const yi = circumcenters[ti + 1]; + const xj = circumcenters[tj]; + const yj = circumcenters[tj + 1]; + this._renderSegment(xi, yi, xj, yj, context); + } + let h0, h1 = hull[hull.length - 1]; + for (let i = 0; i < hull.length; ++i) { + h0 = h1, h1 = hull[i]; + const t = Math.floor(inedges[h1] / 3) * 2; + const x = circumcenters[t]; + const y = circumcenters[t + 1]; + const v = h0 * 4; + const p = this._project(x, y, vectors[v + 2], vectors[v + 3]); + if (p) this._renderSegment(x, y, p[0], p[1], context); + } + return buffer && buffer.value(); + } + renderBounds(context) { + const buffer = context == null ? context = new Path : undefined; + context.rect(this.xmin, this.ymin, this.xmax - this.xmin, this.ymax - this.ymin); + return buffer && buffer.value(); + } + renderCell(i, context) { + const buffer = context == null ? context = new Path : undefined; + const points = this._clip(i); + if (points === null || !points.length) return; + context.moveTo(points[0], points[1]); + let n = points.length; + while (points[0] === points[n-2] && points[1] === points[n-1] && n > 1) n -= 2; + for (let i = 2; i < n; i += 2) { + if (points[i] !== points[i-2] || points[i+1] !== points[i-1]) + context.lineTo(points[i], points[i + 1]); + } + context.closePath(); + return buffer && buffer.value(); + } + *cellPolygons() { + const {delaunay: {points}} = this; + for (let i = 0, n = points.length / 2; i < n; ++i) { + const cell = this.cellPolygon(i); + if (cell) cell.index = i, yield cell; + } + } + cellPolygon(i) { + const polygon = new Polygon; + this.renderCell(i, polygon); + return polygon.value(); + } + _renderSegment(x0, y0, x1, y1, context) { + let S; + const c0 = this._regioncode(x0, y0); + const c1 = this._regioncode(x1, y1); + if (c0 === 0 && c1 === 0) { + context.moveTo(x0, y0); + context.lineTo(x1, y1); + } else if (S = this._clipSegment(x0, y0, x1, y1, c0, c1)) { + context.moveTo(S[0], S[1]); + context.lineTo(S[2], S[3]); + } + } + contains(i, x, y) { + if ((x = +x, x !== x) || (y = +y, y !== y)) return false; + return this.delaunay._step(i, x, y) === i; + } + *neighbors(i) { + const ci = this._clip(i); + if (ci) for (const j of this.delaunay.neighbors(i)) { + const cj = this._clip(j); + // find the common edge + if (cj) loop: for (let ai = 0, li = ci.length; ai < li; ai += 2) { + for (let aj = 0, lj = cj.length; aj < lj; aj += 2) { + if (ci[ai] == cj[aj] + && ci[ai + 1] == cj[aj + 1] + && ci[(ai + 2) % li] == cj[(aj + lj - 2) % lj] + && ci[(ai + 3) % li] == cj[(aj + lj - 1) % lj] + ) { + yield j; + break loop; + } + } + } + } + } + _cell(i) { + const {circumcenters, delaunay: {inedges, halfedges, triangles}} = this; + const e0 = inedges[i]; + if (e0 === -1) return null; // coincident point + const points = []; + let e = e0; + do { + const t = Math.floor(e / 3); + points.push(circumcenters[t * 2], circumcenters[t * 2 + 1]); + e = e % 3 === 2 ? e - 2 : e + 1; + if (triangles[e] !== i) break; // bad triangulation + e = halfedges[e]; + } while (e !== e0 && e !== -1); + return points; + } + _clip(i) { + // degenerate case (1 valid point: return the box) + if (i === 0 && this.delaunay.hull.length === 1) { + return [this.xmax, this.ymin, this.xmax, this.ymax, this.xmin, this.ymax, this.xmin, this.ymin]; + } + const points = this._cell(i); + if (points === null) return null; + const {vectors: V} = this; + const v = i * 4; + return V[v] || V[v + 1] + ? this._clipInfinite(i, points, V[v], V[v + 1], V[v + 2], V[v + 3]) + : this._clipFinite(i, points); + } + _clipFinite(i, points) { + const n = points.length; + let P = null; + let x0, y0, x1 = points[n - 2], y1 = points[n - 1]; + let c0, c1 = this._regioncode(x1, y1); + let e0, e1 = 0; + for (let j = 0; j < n; j += 2) { + x0 = x1, y0 = y1, x1 = points[j], y1 = points[j + 1]; + c0 = c1, c1 = this._regioncode(x1, y1); + if (c0 === 0 && c1 === 0) { + e0 = e1, e1 = 0; + if (P) P.push(x1, y1); + else P = [x1, y1]; + } else { + let S, sx0, sy0, sx1, sy1; + if (c0 === 0) { + if ((S = this._clipSegment(x0, y0, x1, y1, c0, c1)) === null) continue; + [sx0, sy0, sx1, sy1] = S; + } else { + if ((S = this._clipSegment(x1, y1, x0, y0, c1, c0)) === null) continue; + [sx1, sy1, sx0, sy0] = S; + e0 = e1, e1 = this._edgecode(sx0, sy0); + if (e0 && e1) this._edge(i, e0, e1, P, P.length); + if (P) P.push(sx0, sy0); + else P = [sx0, sy0]; + } + e0 = e1, e1 = this._edgecode(sx1, sy1); + if (e0 && e1) this._edge(i, e0, e1, P, P.length); + if (P) P.push(sx1, sy1); + else P = [sx1, sy1]; + } + } + if (P) { + e0 = e1, e1 = this._edgecode(P[0], P[1]); + if (e0 && e1) this._edge(i, e0, e1, P, P.length); + } else if (this.contains(i, (this.xmin + this.xmax) / 2, (this.ymin + this.ymax) / 2)) { + return [this.xmax, this.ymin, this.xmax, this.ymax, this.xmin, this.ymax, this.xmin, this.ymin]; + } + return P; + } + _clipSegment(x0, y0, x1, y1, c0, c1) { + while (true) { + if (c0 === 0 && c1 === 0) return [x0, y0, x1, y1]; + if (c0 & c1) return null; + let x, y, c = c0 || c1; + if (c & 0b1000) x = x0 + (x1 - x0) * (this.ymax - y0) / (y1 - y0), y = this.ymax; + else if (c & 0b0100) x = x0 + (x1 - x0) * (this.ymin - y0) / (y1 - y0), y = this.ymin; + else if (c & 0b0010) y = y0 + (y1 - y0) * (this.xmax - x0) / (x1 - x0), x = this.xmax; + else y = y0 + (y1 - y0) * (this.xmin - x0) / (x1 - x0), x = this.xmin; + if (c0) x0 = x, y0 = y, c0 = this._regioncode(x0, y0); + else x1 = x, y1 = y, c1 = this._regioncode(x1, y1); + } + } + _clipInfinite(i, points, vx0, vy0, vxn, vyn) { + let P = Array.from(points), p; + if (p = this._project(P[0], P[1], vx0, vy0)) P.unshift(p[0], p[1]); + if (p = this._project(P[P.length - 2], P[P.length - 1], vxn, vyn)) P.push(p[0], p[1]); + if (P = this._clipFinite(i, P)) { + for (let j = 0, n = P.length, c0, c1 = this._edgecode(P[n - 2], P[n - 1]); j < n; j += 2) { + c0 = c1, c1 = this._edgecode(P[j], P[j + 1]); + if (c0 && c1) j = this._edge(i, c0, c1, P, j), n = P.length; + } + } else if (this.contains(i, (this.xmin + this.xmax) / 2, (this.ymin + this.ymax) / 2)) { + P = [this.xmin, this.ymin, this.xmax, this.ymin, this.xmax, this.ymax, this.xmin, this.ymax]; + } + return P; + } + _edge(i, e0, e1, P, j) { + while (e0 !== e1) { + let x, y; + switch (e0) { + case 0b0101: e0 = 0b0100; continue; // top-left + case 0b0100: e0 = 0b0110, x = this.xmax, y = this.ymin; break; // top + case 0b0110: e0 = 0b0010; continue; // top-right + case 0b0010: e0 = 0b1010, x = this.xmax, y = this.ymax; break; // right + case 0b1010: e0 = 0b1000; continue; // bottom-right + case 0b1000: e0 = 0b1001, x = this.xmin, y = this.ymax; break; // bottom + case 0b1001: e0 = 0b0001; continue; // bottom-left + case 0b0001: e0 = 0b0101, x = this.xmin, y = this.ymin; break; // left + } + // Note: this implicitly checks for out of bounds: if P[j] or P[j+1] are + // undefined, the conditional statement will be executed. + if ((P[j] !== x || P[j + 1] !== y) && this.contains(i, x, y)) { + P.splice(j, 0, x, y), j += 2; + } + } + if (P.length > 4) { + for (let i = 0; i < P.length; i+= 2) { + const j = (i + 2) % P.length, k = (i + 4) % P.length; + if (P[i] === P[j] && P[j] === P[k] + || P[i + 1] === P[j + 1] && P[j + 1] === P[k + 1]) + P.splice(j, 2), i -= 2; + } + } + return j; + } + _project(x0, y0, vx, vy) { + let t = Infinity, c, x, y; + if (vy < 0) { // top + if (y0 <= this.ymin) return null; + if ((c = (this.ymin - y0) / vy) < t) y = this.ymin, x = x0 + (t = c) * vx; + } else if (vy > 0) { // bottom + if (y0 >= this.ymax) return null; + if ((c = (this.ymax - y0) / vy) < t) y = this.ymax, x = x0 + (t = c) * vx; + } + if (vx > 0) { // right + if (x0 >= this.xmax) return null; + if ((c = (this.xmax - x0) / vx) < t) x = this.xmax, y = y0 + (t = c) * vy; + } else if (vx < 0) { // left + if (x0 <= this.xmin) return null; + if ((c = (this.xmin - x0) / vx) < t) x = this.xmin, y = y0 + (t = c) * vy; + } + return [x, y]; + } + _edgecode(x, y) { + return (x === this.xmin ? 0b0001 + : x === this.xmax ? 0b0010 : 0b0000) + | (y === this.ymin ? 0b0100 + : y === this.ymax ? 0b1000 : 0b0000); + } + _regioncode(x, y) { + return (x < this.xmin ? 0b0001 + : x > this.xmax ? 0b0010 : 0b0000) + | (y < this.ymin ? 0b0100 + : y > this.ymax ? 0b1000 : 0b0000); + } +} + +const tau$2 = 2 * Math.PI, pow$2 = Math.pow; + +function pointX(p) { + return p[0]; +} + +function pointY(p) { + return p[1]; +} + +// A triangulation is collinear if all its triangles have a non-null area +function collinear(d) { + const {triangles, coords} = d; + for (let i = 0; i < triangles.length; i += 3) { + const a = 2 * triangles[i], + b = 2 * triangles[i + 1], + c = 2 * triangles[i + 2], + cross = (coords[c] - coords[a]) * (coords[b + 1] - coords[a + 1]) + - (coords[b] - coords[a]) * (coords[c + 1] - coords[a + 1]); + if (cross > 1e-10) return false; + } + return true; +} + +function jitter(x, y, r) { + return [x + Math.sin(x + y) * r, y + Math.cos(x - y) * r]; +} + +class Delaunay { + static from(points, fx = pointX, fy = pointY, that) { + return new Delaunay("length" in points + ? flatArray(points, fx, fy, that) + : Float64Array.from(flatIterable(points, fx, fy, that))); + } + constructor(points) { + this._delaunator = new Delaunator(points); + this.inedges = new Int32Array(points.length / 2); + this._hullIndex = new Int32Array(points.length / 2); + this.points = this._delaunator.coords; + this._init(); + } + update() { + this._delaunator.update(); + this._init(); + return this; + } + _init() { + const d = this._delaunator, points = this.points; + + // check for collinear + if (d.hull && d.hull.length > 2 && collinear(d)) { + this.collinear = Int32Array.from({length: points.length/2}, (_,i) => i) + .sort((i, j) => points[2 * i] - points[2 * j] || points[2 * i + 1] - points[2 * j + 1]); // for exact neighbors + const e = this.collinear[0], f = this.collinear[this.collinear.length - 1], + bounds = [ points[2 * e], points[2 * e + 1], points[2 * f], points[2 * f + 1] ], + r = 1e-8 * Math.hypot(bounds[3] - bounds[1], bounds[2] - bounds[0]); + for (let i = 0, n = points.length / 2; i < n; ++i) { + const p = jitter(points[2 * i], points[2 * i + 1], r); + points[2 * i] = p[0]; + points[2 * i + 1] = p[1]; + } + this._delaunator = new Delaunator(points); + } else { + delete this.collinear; + } + + const halfedges = this.halfedges = this._delaunator.halfedges; + const hull = this.hull = this._delaunator.hull; + const triangles = this.triangles = this._delaunator.triangles; + const inedges = this.inedges.fill(-1); + const hullIndex = this._hullIndex.fill(-1); + + // Compute an index from each point to an (arbitrary) incoming halfedge + // Used to give the first neighbor of each point; for this reason, + // on the hull we give priority to exterior halfedges + for (let e = 0, n = halfedges.length; e < n; ++e) { + const p = triangles[e % 3 === 2 ? e - 2 : e + 1]; + if (halfedges[e] === -1 || inedges[p] === -1) inedges[p] = e; + } + for (let i = 0, n = hull.length; i < n; ++i) { + hullIndex[hull[i]] = i; + } + + // degenerate case: 1 or 2 (distinct) points + if (hull.length <= 2 && hull.length > 0) { + this.triangles = new Int32Array(3).fill(-1); + this.halfedges = new Int32Array(3).fill(-1); + this.triangles[0] = hull[0]; + inedges[hull[0]] = 1; + if (hull.length === 2) { + inedges[hull[1]] = 0; + this.triangles[1] = hull[1]; + this.triangles[2] = hull[1]; + } + } + } + voronoi(bounds) { + return new Voronoi(this, bounds); + } + *neighbors(i) { + const {inedges, hull, _hullIndex, halfedges, triangles, collinear} = this; + + // degenerate case with several collinear points + if (collinear) { + const l = collinear.indexOf(i); + if (l > 0) yield collinear[l - 1]; + if (l < collinear.length - 1) yield collinear[l + 1]; + return; + } + + const e0 = inedges[i]; + if (e0 === -1) return; // coincident point + let e = e0, p0 = -1; + do { + yield p0 = triangles[e]; + e = e % 3 === 2 ? e - 2 : e + 1; + if (triangles[e] !== i) return; // bad triangulation + e = halfedges[e]; + if (e === -1) { + const p = hull[(_hullIndex[i] + 1) % hull.length]; + if (p !== p0) yield p; + return; + } + } while (e !== e0); + } + find(x, y, i = 0) { + if ((x = +x, x !== x) || (y = +y, y !== y)) return -1; + const i0 = i; + let c; + while ((c = this._step(i, x, y)) >= 0 && c !== i && c !== i0) i = c; + return c; + } + _step(i, x, y) { + const {inedges, hull, _hullIndex, halfedges, triangles, points} = this; + if (inedges[i] === -1 || !points.length) return (i + 1) % (points.length >> 1); + let c = i; + let dc = pow$2(x - points[i * 2], 2) + pow$2(y - points[i * 2 + 1], 2); + const e0 = inedges[i]; + let e = e0; + do { + let t = triangles[e]; + const dt = pow$2(x - points[t * 2], 2) + pow$2(y - points[t * 2 + 1], 2); + if (dt < dc) dc = dt, c = t; + e = e % 3 === 2 ? e - 2 : e + 1; + if (triangles[e] !== i) break; // bad triangulation + e = halfedges[e]; + if (e === -1) { + e = hull[(_hullIndex[i] + 1) % hull.length]; + if (e !== t) { + if (pow$2(x - points[e * 2], 2) + pow$2(y - points[e * 2 + 1], 2) < dc) return e; + } + break; + } + } while (e !== e0); + return c; + } + render(context) { + const buffer = context == null ? context = new Path : undefined; + const {points, halfedges, triangles} = this; + for (let i = 0, n = halfedges.length; i < n; ++i) { + const j = halfedges[i]; + if (j < i) continue; + const ti = triangles[i] * 2; + const tj = triangles[j] * 2; + context.moveTo(points[ti], points[ti + 1]); + context.lineTo(points[tj], points[tj + 1]); + } + this.renderHull(context); + return buffer && buffer.value(); + } + renderPoints(context, r) { + if (r === undefined && (!context || typeof context.moveTo !== "function")) r = context, context = null; + r = r == undefined ? 2 : +r; + const buffer = context == null ? context = new Path : undefined; + const {points} = this; + for (let i = 0, n = points.length; i < n; i += 2) { + const x = points[i], y = points[i + 1]; + context.moveTo(x + r, y); + context.arc(x, y, r, 0, tau$2); + } + return buffer && buffer.value(); + } + renderHull(context) { + const buffer = context == null ? context = new Path : undefined; + const {hull, points} = this; + const h = hull[0] * 2, n = hull.length; + context.moveTo(points[h], points[h + 1]); + for (let i = 1; i < n; ++i) { + const h = 2 * hull[i]; + context.lineTo(points[h], points[h + 1]); + } + context.closePath(); + return buffer && buffer.value(); + } + hullPolygon() { + const polygon = new Polygon; + this.renderHull(polygon); + return polygon.value(); + } + renderTriangle(i, context) { + const buffer = context == null ? context = new Path : undefined; + const {points, triangles} = this; + const t0 = triangles[i *= 3] * 2; + const t1 = triangles[i + 1] * 2; + const t2 = triangles[i + 2] * 2; + context.moveTo(points[t0], points[t0 + 1]); + context.lineTo(points[t1], points[t1 + 1]); + context.lineTo(points[t2], points[t2 + 1]); + context.closePath(); + return buffer && buffer.value(); + } + *trianglePolygons() { + const {triangles} = this; + for (let i = 0, n = triangles.length / 3; i < n; ++i) { + yield this.trianglePolygon(i); + } + } + trianglePolygon(i) { + const polygon = new Polygon; + this.renderTriangle(i, polygon); + return polygon.value(); + } +} + +function flatArray(points, fx, fy, that) { + const n = points.length; + const array = new Float64Array(n * 2); + for (let i = 0; i < n; ++i) { + const p = points[i]; + array[i * 2] = fx.call(that, p, i, points); + array[i * 2 + 1] = fy.call(that, p, i, points); + } + return array; +} + +function* flatIterable(points, fx, fy, that) { + let i = 0; + for (const p of points) { + yield fx.call(that, p, i, points); + yield fy.call(that, p, i, points); + ++i; + } +} + +var EOL = {}, + EOF = {}, + QUOTE = 34, + NEWLINE = 10, + RETURN = 13; + +function objectConverter(columns) { + return new Function("d", "return {" + columns.map(function(name, i) { + return JSON.stringify(name) + ": d[" + i + "] || \"\""; + }).join(",") + "}"); +} + +function customConverter(columns, f) { + var object = objectConverter(columns); + return function(row, i) { + return f(object(row), i, columns); + }; +} + +// Compute unique columns in order of discovery. +function inferColumns(rows) { + var columnSet = Object.create(null), + columns = []; + + rows.forEach(function(row) { + for (var column in row) { + if (!(column in columnSet)) { + columns.push(columnSet[column] = column); + } + } + }); + + return columns; +} + +function pad$1(value, width) { + var s = value + "", length = s.length; + return length < width ? new Array(width - length + 1).join(0) + s : s; +} + +function formatYear$1(year) { + return year < 0 ? "-" + pad$1(-year, 6) + : year > 9999 ? "+" + pad$1(year, 6) + : pad$1(year, 4); +} + +function formatDate(date) { + var hours = date.getUTCHours(), + minutes = date.getUTCMinutes(), + seconds = date.getUTCSeconds(), + milliseconds = date.getUTCMilliseconds(); + return isNaN(date) ? "Invalid Date" + : formatYear$1(date.getUTCFullYear()) + "-" + pad$1(date.getUTCMonth() + 1, 2) + "-" + pad$1(date.getUTCDate(), 2) + + (milliseconds ? "T" + pad$1(hours, 2) + ":" + pad$1(minutes, 2) + ":" + pad$1(seconds, 2) + "." + pad$1(milliseconds, 3) + "Z" + : seconds ? "T" + pad$1(hours, 2) + ":" + pad$1(minutes, 2) + ":" + pad$1(seconds, 2) + "Z" + : minutes || hours ? "T" + pad$1(hours, 2) + ":" + pad$1(minutes, 2) + "Z" + : ""); +} + +function dsvFormat(delimiter) { + var reFormat = new RegExp("[\"" + delimiter + "\n\r]"), + DELIMITER = delimiter.charCodeAt(0); + + function parse(text, f) { + var convert, columns, rows = parseRows(text, function(row, i) { + if (convert) return convert(row, i - 1); + columns = row, convert = f ? customConverter(row, f) : objectConverter(row); + }); + rows.columns = columns || []; + return rows; + } + + function parseRows(text, f) { + var rows = [], // output rows + N = text.length, + I = 0, // current character index + n = 0, // current line number + t, // current token + eof = N <= 0, // current token followed by EOF? + eol = false; // current token followed by EOL? + + // Strip the trailing newline. + if (text.charCodeAt(N - 1) === NEWLINE) --N; + if (text.charCodeAt(N - 1) === RETURN) --N; + + function token() { + if (eof) return EOF; + if (eol) return eol = false, EOL; + + // Unescape quotes. + var i, j = I, c; + if (text.charCodeAt(j) === QUOTE) { + while (I++ < N && text.charCodeAt(I) !== QUOTE || text.charCodeAt(++I) === QUOTE); + if ((i = I) >= N) eof = true; + else if ((c = text.charCodeAt(I++)) === NEWLINE) eol = true; + else if (c === RETURN) { eol = true; if (text.charCodeAt(I) === NEWLINE) ++I; } + return text.slice(j + 1, i - 1).replace(/""/g, "\""); + } + + // Find next delimiter or newline. + while (I < N) { + if ((c = text.charCodeAt(i = I++)) === NEWLINE) eol = true; + else if (c === RETURN) { eol = true; if (text.charCodeAt(I) === NEWLINE) ++I; } + else if (c !== DELIMITER) continue; + return text.slice(j, i); + } + + // Return last token before EOF. + return eof = true, text.slice(j, N); + } + + while ((t = token()) !== EOF) { + var row = []; + while (t !== EOL && t !== EOF) row.push(t), t = token(); + if (f && (row = f(row, n++)) == null) continue; + rows.push(row); + } + + return rows; + } + + function preformatBody(rows, columns) { + return rows.map(function(row) { + return columns.map(function(column) { + return formatValue(row[column]); + }).join(delimiter); + }); + } + + function format(rows, columns) { + if (columns == null) columns = inferColumns(rows); + return [columns.map(formatValue).join(delimiter)].concat(preformatBody(rows, columns)).join("\n"); + } + + function formatBody(rows, columns) { + if (columns == null) columns = inferColumns(rows); + return preformatBody(rows, columns).join("\n"); + } + + function formatRows(rows) { + return rows.map(formatRow).join("\n"); + } + + function formatRow(row) { + return row.map(formatValue).join(delimiter); + } + + function formatValue(value) { + return value == null ? "" + : value instanceof Date ? formatDate(value) + : reFormat.test(value += "") ? "\"" + value.replace(/"/g, "\"\"") + "\"" + : value; + } + + return { + parse: parse, + parseRows: parseRows, + format: format, + formatBody: formatBody, + formatRows: formatRows, + formatRow: formatRow, + formatValue: formatValue + }; +} + +var csv$1 = dsvFormat(","); + +var csvParse = csv$1.parse; +var csvParseRows = csv$1.parseRows; +var csvFormat = csv$1.format; +var csvFormatBody = csv$1.formatBody; +var csvFormatRows = csv$1.formatRows; +var csvFormatRow = csv$1.formatRow; +var csvFormatValue = csv$1.formatValue; + +var tsv$1 = dsvFormat("\t"); + +var tsvParse = tsv$1.parse; +var tsvParseRows = tsv$1.parseRows; +var tsvFormat = tsv$1.format; +var tsvFormatBody = tsv$1.formatBody; +var tsvFormatRows = tsv$1.formatRows; +var tsvFormatRow = tsv$1.formatRow; +var tsvFormatValue = tsv$1.formatValue; + +function autoType(object) { + for (var key in object) { + var value = object[key].trim(), number, m; + if (!value) value = null; + else if (value === "true") value = true; + else if (value === "false") value = false; + else if (value === "NaN") value = NaN; + else if (!isNaN(number = +value)) value = number; + else if (m = value.match(/^([-+]\d{2})?\d{4}(-\d{2}(-\d{2})?)?(T\d{2}:\d{2}(:\d{2}(\.\d{3})?)?(Z|[-+]\d{2}:\d{2})?)?$/)) { + if (fixtz && !!m[4] && !m[7]) value = value.replace(/-/g, "/").replace(/T/, " "); + value = new Date(value); + } + else continue; + object[key] = value; + } + return object; +} + +// https://github.com/d3/d3-dsv/issues/45 +const fixtz = new Date("2019-01-01T00:00").getHours() || new Date("2019-07-01T00:00").getHours(); + +function responseBlob(response) { + if (!response.ok) throw new Error(response.status + " " + response.statusText); + return response.blob(); +} + +function blob(input, init) { + return fetch(input, init).then(responseBlob); +} + +function responseArrayBuffer(response) { + if (!response.ok) throw new Error(response.status + " " + response.statusText); + return response.arrayBuffer(); +} + +function buffer(input, init) { + return fetch(input, init).then(responseArrayBuffer); +} + +function responseText(response) { + if (!response.ok) throw new Error(response.status + " " + response.statusText); + return response.text(); +} + +function text(input, init) { + return fetch(input, init).then(responseText); +} + +function dsvParse(parse) { + return function(input, init, row) { + if (arguments.length === 2 && typeof init === "function") row = init, init = undefined; + return text(input, init).then(function(response) { + return parse(response, row); + }); + }; +} + +function dsv(delimiter, input, init, row) { + if (arguments.length === 3 && typeof init === "function") row = init, init = undefined; + var format = dsvFormat(delimiter); + return text(input, init).then(function(response) { + return format.parse(response, row); + }); +} + +var csv = dsvParse(csvParse); +var tsv = dsvParse(tsvParse); + +function image(input, init) { + return new Promise(function(resolve, reject) { + var image = new Image; + for (var key in init) image[key] = init[key]; + image.onerror = reject; + image.onload = function() { resolve(image); }; + image.src = input; + }); +} + +function responseJson(response) { + if (!response.ok) throw new Error(response.status + " " + response.statusText); + if (response.status === 204 || response.status === 205) return; + return response.json(); +} + +function json(input, init) { + return fetch(input, init).then(responseJson); +} + +function parser(type) { + return (input, init) => text(input, init) + .then(text => (new DOMParser).parseFromString(text, type)); +} + +var xml = parser("application/xml"); + +var html = parser("text/html"); + +var svg = parser("image/svg+xml"); + +function center(x, y) { + var nodes, strength = 1; + + if (x == null) x = 0; + if (y == null) y = 0; + + function force() { + var i, + n = nodes.length, + node, + sx = 0, + sy = 0; + + for (i = 0; i < n; ++i) { + node = nodes[i], sx += node.x, sy += node.y; + } + + for (sx = (sx / n - x) * strength, sy = (sy / n - y) * strength, i = 0; i < n; ++i) { + node = nodes[i], node.x -= sx, node.y -= sy; + } + } + + force.initialize = function(_) { + nodes = _; + }; + + force.x = function(_) { + return arguments.length ? (x = +_, force) : x; + }; + + force.y = function(_) { + return arguments.length ? (y = +_, force) : y; + }; + + force.strength = function(_) { + return arguments.length ? (strength = +_, force) : strength; + }; + + return force; +} + +function tree_add(d) { + const x = +this._x.call(null, d), + y = +this._y.call(null, d); + return add(this.cover(x, y), x, y, d); +} + +function add(tree, x, y, d) { + if (isNaN(x) || isNaN(y)) return tree; // ignore invalid points + + var parent, + node = tree._root, + leaf = {data: d}, + x0 = tree._x0, + y0 = tree._y0, + x1 = tree._x1, + y1 = tree._y1, + xm, + ym, + xp, + yp, + right, + bottom, + i, + j; + + // If the tree is empty, initialize the root as a leaf. + if (!node) return tree._root = leaf, tree; + + // Find the existing leaf for the new point, or add it. + while (node.length) { + if (right = x >= (xm = (x0 + x1) / 2)) x0 = xm; else x1 = xm; + if (bottom = y >= (ym = (y0 + y1) / 2)) y0 = ym; else y1 = ym; + if (parent = node, !(node = node[i = bottom << 1 | right])) return parent[i] = leaf, tree; + } + + // Is the new point is exactly coincident with the existing point? + xp = +tree._x.call(null, node.data); + yp = +tree._y.call(null, node.data); + if (x === xp && y === yp) return leaf.next = node, parent ? parent[i] = leaf : tree._root = leaf, tree; + + // Otherwise, split the leaf node until the old and new point are separated. + do { + parent = parent ? parent[i] = new Array(4) : tree._root = new Array(4); + if (right = x >= (xm = (x0 + x1) / 2)) x0 = xm; else x1 = xm; + if (bottom = y >= (ym = (y0 + y1) / 2)) y0 = ym; else y1 = ym; + } while ((i = bottom << 1 | right) === (j = (yp >= ym) << 1 | (xp >= xm))); + return parent[j] = node, parent[i] = leaf, tree; +} + +function addAll(data) { + var d, i, n = data.length, + x, + y, + xz = new Array(n), + yz = new Array(n), + x0 = Infinity, + y0 = Infinity, + x1 = -Infinity, + y1 = -Infinity; + + // Compute the points and their extent. + for (i = 0; i < n; ++i) { + if (isNaN(x = +this._x.call(null, d = data[i])) || isNaN(y = +this._y.call(null, d))) continue; + xz[i] = x; + yz[i] = y; + if (x < x0) x0 = x; + if (x > x1) x1 = x; + if (y < y0) y0 = y; + if (y > y1) y1 = y; + } + + // If there were no (valid) points, abort. + if (x0 > x1 || y0 > y1) return this; + + // Expand the tree to cover the new points. + this.cover(x0, y0).cover(x1, y1); + + // Add the new points. + for (i = 0; i < n; ++i) { + add(this, xz[i], yz[i], data[i]); + } + + return this; +} + +function tree_cover(x, y) { + if (isNaN(x = +x) || isNaN(y = +y)) return this; // ignore invalid points + + var x0 = this._x0, + y0 = this._y0, + x1 = this._x1, + y1 = this._y1; + + // If the quadtree has no extent, initialize them. + // Integer extent are necessary so that if we later double the extent, + // the existing quadrant boundaries don’t change due to floating point error! + if (isNaN(x0)) { + x1 = (x0 = Math.floor(x)) + 1; + y1 = (y0 = Math.floor(y)) + 1; + } + + // Otherwise, double repeatedly to cover. + else { + var z = x1 - x0 || 1, + node = this._root, + parent, + i; + + while (x0 > x || x >= x1 || y0 > y || y >= y1) { + i = (y < y0) << 1 | (x < x0); + parent = new Array(4), parent[i] = node, node = parent, z *= 2; + switch (i) { + case 0: x1 = x0 + z, y1 = y0 + z; break; + case 1: x0 = x1 - z, y1 = y0 + z; break; + case 2: x1 = x0 + z, y0 = y1 - z; break; + case 3: x0 = x1 - z, y0 = y1 - z; break; + } + } + + if (this._root && this._root.length) this._root = node; + } + + this._x0 = x0; + this._y0 = y0; + this._x1 = x1; + this._y1 = y1; + return this; +} + +function tree_data() { + var data = []; + this.visit(function(node) { + if (!node.length) do data.push(node.data); while (node = node.next) + }); + return data; +} + +function tree_extent(_) { + return arguments.length + ? this.cover(+_[0][0], +_[0][1]).cover(+_[1][0], +_[1][1]) + : isNaN(this._x0) ? undefined : [[this._x0, this._y0], [this._x1, this._y1]]; +} + +function Quad(node, x0, y0, x1, y1) { + this.node = node; + this.x0 = x0; + this.y0 = y0; + this.x1 = x1; + this.y1 = y1; +} + +function tree_find(x, y, radius) { + var data, + x0 = this._x0, + y0 = this._y0, + x1, + y1, + x2, + y2, + x3 = this._x1, + y3 = this._y1, + quads = [], + node = this._root, + q, + i; + + if (node) quads.push(new Quad(node, x0, y0, x3, y3)); + if (radius == null) radius = Infinity; + else { + x0 = x - radius, y0 = y - radius; + x3 = x + radius, y3 = y + radius; + radius *= radius; + } + + while (q = quads.pop()) { + + // Stop searching if this quadrant can’t contain a closer node. + if (!(node = q.node) + || (x1 = q.x0) > x3 + || (y1 = q.y0) > y3 + || (x2 = q.x1) < x0 + || (y2 = q.y1) < y0) continue; + + // Bisect the current quadrant. + if (node.length) { + var xm = (x1 + x2) / 2, + ym = (y1 + y2) / 2; + + quads.push( + new Quad(node[3], xm, ym, x2, y2), + new Quad(node[2], x1, ym, xm, y2), + new Quad(node[1], xm, y1, x2, ym), + new Quad(node[0], x1, y1, xm, ym) + ); + + // Visit the closest quadrant first. + if (i = (y >= ym) << 1 | (x >= xm)) { + q = quads[quads.length - 1]; + quads[quads.length - 1] = quads[quads.length - 1 - i]; + quads[quads.length - 1 - i] = q; + } + } + + // Visit this point. (Visiting coincident points isn’t necessary!) + else { + var dx = x - +this._x.call(null, node.data), + dy = y - +this._y.call(null, node.data), + d2 = dx * dx + dy * dy; + if (d2 < radius) { + var d = Math.sqrt(radius = d2); + x0 = x - d, y0 = y - d; + x3 = x + d, y3 = y + d; + data = node.data; + } + } + } + + return data; +} + +function tree_remove(d) { + if (isNaN(x = +this._x.call(null, d)) || isNaN(y = +this._y.call(null, d))) return this; // ignore invalid points + + var parent, + node = this._root, + retainer, + previous, + next, + x0 = this._x0, + y0 = this._y0, + x1 = this._x1, + y1 = this._y1, + x, + y, + xm, + ym, + right, + bottom, + i, + j; + + // If the tree is empty, initialize the root as a leaf. + if (!node) return this; + + // Find the leaf node for the point. + // While descending, also retain the deepest parent with a non-removed sibling. + if (node.length) while (true) { + if (right = x >= (xm = (x0 + x1) / 2)) x0 = xm; else x1 = xm; + if (bottom = y >= (ym = (y0 + y1) / 2)) y0 = ym; else y1 = ym; + if (!(parent = node, node = node[i = bottom << 1 | right])) return this; + if (!node.length) break; + if (parent[(i + 1) & 3] || parent[(i + 2) & 3] || parent[(i + 3) & 3]) retainer = parent, j = i; + } + + // Find the point to remove. + while (node.data !== d) if (!(previous = node, node = node.next)) return this; + if (next = node.next) delete node.next; + + // If there are multiple coincident points, remove just the point. + if (previous) return (next ? previous.next = next : delete previous.next), this; + + // If this is the root point, remove it. + if (!parent) return this._root = next, this; + + // Remove this leaf. + next ? parent[i] = next : delete parent[i]; + + // If the parent now contains exactly one leaf, collapse superfluous parents. + if ((node = parent[0] || parent[1] || parent[2] || parent[3]) + && node === (parent[3] || parent[2] || parent[1] || parent[0]) + && !node.length) { + if (retainer) retainer[j] = node; + else this._root = node; + } + + return this; +} + +function removeAll(data) { + for (var i = 0, n = data.length; i < n; ++i) this.remove(data[i]); + return this; +} + +function tree_root() { + return this._root; +} + +function tree_size() { + var size = 0; + this.visit(function(node) { + if (!node.length) do ++size; while (node = node.next) + }); + return size; +} + +function tree_visit(callback) { + var quads = [], q, node = this._root, child, x0, y0, x1, y1; + if (node) quads.push(new Quad(node, this._x0, this._y0, this._x1, this._y1)); + while (q = quads.pop()) { + if (!callback(node = q.node, x0 = q.x0, y0 = q.y0, x1 = q.x1, y1 = q.y1) && node.length) { + var xm = (x0 + x1) / 2, ym = (y0 + y1) / 2; + if (child = node[3]) quads.push(new Quad(child, xm, ym, x1, y1)); + if (child = node[2]) quads.push(new Quad(child, x0, ym, xm, y1)); + if (child = node[1]) quads.push(new Quad(child, xm, y0, x1, ym)); + if (child = node[0]) quads.push(new Quad(child, x0, y0, xm, ym)); + } + } + return this; +} + +function tree_visitAfter(callback) { + var quads = [], next = [], q; + if (this._root) quads.push(new Quad(this._root, this._x0, this._y0, this._x1, this._y1)); + while (q = quads.pop()) { + var node = q.node; + if (node.length) { + var child, x0 = q.x0, y0 = q.y0, x1 = q.x1, y1 = q.y1, xm = (x0 + x1) / 2, ym = (y0 + y1) / 2; + if (child = node[0]) quads.push(new Quad(child, x0, y0, xm, ym)); + if (child = node[1]) quads.push(new Quad(child, xm, y0, x1, ym)); + if (child = node[2]) quads.push(new Quad(child, x0, ym, xm, y1)); + if (child = node[3]) quads.push(new Quad(child, xm, ym, x1, y1)); + } + next.push(q); + } + while (q = next.pop()) { + callback(q.node, q.x0, q.y0, q.x1, q.y1); + } + return this; +} + +function defaultX(d) { + return d[0]; +} + +function tree_x(_) { + return arguments.length ? (this._x = _, this) : this._x; +} + +function defaultY(d) { + return d[1]; +} + +function tree_y(_) { + return arguments.length ? (this._y = _, this) : this._y; +} + +function quadtree(nodes, x, y) { + var tree = new Quadtree(x == null ? defaultX : x, y == null ? defaultY : y, NaN, NaN, NaN, NaN); + return nodes == null ? tree : tree.addAll(nodes); +} + +function Quadtree(x, y, x0, y0, x1, y1) { + this._x = x; + this._y = y; + this._x0 = x0; + this._y0 = y0; + this._x1 = x1; + this._y1 = y1; + this._root = undefined; +} + +function leaf_copy(leaf) { + var copy = {data: leaf.data}, next = copy; + while (leaf = leaf.next) next = next.next = {data: leaf.data}; + return copy; +} + +var treeProto = quadtree.prototype = Quadtree.prototype; + +treeProto.copy = function() { + var copy = new Quadtree(this._x, this._y, this._x0, this._y0, this._x1, this._y1), + node = this._root, + nodes, + child; + + if (!node) return copy; + + if (!node.length) return copy._root = leaf_copy(node), copy; + + nodes = [{source: node, target: copy._root = new Array(4)}]; + while (node = nodes.pop()) { + for (var i = 0; i < 4; ++i) { + if (child = node.source[i]) { + if (child.length) nodes.push({source: child, target: node.target[i] = new Array(4)}); + else node.target[i] = leaf_copy(child); + } + } + } + + return copy; +}; + +treeProto.add = tree_add; +treeProto.addAll = addAll; +treeProto.cover = tree_cover; +treeProto.data = tree_data; +treeProto.extent = tree_extent; +treeProto.find = tree_find; +treeProto.remove = tree_remove; +treeProto.removeAll = removeAll; +treeProto.root = tree_root; +treeProto.size = tree_size; +treeProto.visit = tree_visit; +treeProto.visitAfter = tree_visitAfter; +treeProto.x = tree_x; +treeProto.y = tree_y; + +function constant$4(x) { + return function() { + return x; + }; +} + +function jiggle(random) { + return (random() - 0.5) * 1e-6; +} + +function x$3(d) { + return d.x + d.vx; +} + +function y$3(d) { + return d.y + d.vy; +} + +function collide(radius) { + var nodes, + radii, + random, + strength = 1, + iterations = 1; + + if (typeof radius !== "function") radius = constant$4(radius == null ? 1 : +radius); + + function force() { + var i, n = nodes.length, + tree, + node, + xi, + yi, + ri, + ri2; + + for (var k = 0; k < iterations; ++k) { + tree = quadtree(nodes, x$3, y$3).visitAfter(prepare); + for (i = 0; i < n; ++i) { + node = nodes[i]; + ri = radii[node.index], ri2 = ri * ri; + xi = node.x + node.vx; + yi = node.y + node.vy; + tree.visit(apply); + } + } + + function apply(quad, x0, y0, x1, y1) { + var data = quad.data, rj = quad.r, r = ri + rj; + if (data) { + if (data.index > node.index) { + var x = xi - data.x - data.vx, + y = yi - data.y - data.vy, + l = x * x + y * y; + if (l < r * r) { + if (x === 0) x = jiggle(random), l += x * x; + if (y === 0) y = jiggle(random), l += y * y; + l = (r - (l = Math.sqrt(l))) / l * strength; + node.vx += (x *= l) * (r = (rj *= rj) / (ri2 + rj)); + node.vy += (y *= l) * r; + data.vx -= x * (r = 1 - r); + data.vy -= y * r; + } + } + return; + } + return x0 > xi + r || x1 < xi - r || y0 > yi + r || y1 < yi - r; + } + } + + function prepare(quad) { + if (quad.data) return quad.r = radii[quad.data.index]; + for (var i = quad.r = 0; i < 4; ++i) { + if (quad[i] && quad[i].r > quad.r) { + quad.r = quad[i].r; + } + } + } + + function initialize() { + if (!nodes) return; + var i, n = nodes.length, node; + radii = new Array(n); + for (i = 0; i < n; ++i) node = nodes[i], radii[node.index] = +radius(node, i, nodes); + } + + force.initialize = function(_nodes, _random) { + nodes = _nodes; + random = _random; + initialize(); + }; + + force.iterations = function(_) { + return arguments.length ? (iterations = +_, force) : iterations; + }; + + force.strength = function(_) { + return arguments.length ? (strength = +_, force) : strength; + }; + + force.radius = function(_) { + return arguments.length ? (radius = typeof _ === "function" ? _ : constant$4(+_), initialize(), force) : radius; + }; + + return force; +} + +function index$3(d) { + return d.index; +} + +function find(nodeById, nodeId) { + var node = nodeById.get(nodeId); + if (!node) throw new Error("node not found: " + nodeId); + return node; +} + +function link$2(links) { + var id = index$3, + strength = defaultStrength, + strengths, + distance = constant$4(30), + distances, + nodes, + count, + bias, + random, + iterations = 1; + + if (links == null) links = []; + + function defaultStrength(link) { + return 1 / Math.min(count[link.source.index], count[link.target.index]); + } + + function force(alpha) { + for (var k = 0, n = links.length; k < iterations; ++k) { + for (var i = 0, link, source, target, x, y, l, b; i < n; ++i) { + link = links[i], source = link.source, target = link.target; + x = target.x + target.vx - source.x - source.vx || jiggle(random); + y = target.y + target.vy - source.y - source.vy || jiggle(random); + l = Math.sqrt(x * x + y * y); + l = (l - distances[i]) / l * alpha * strengths[i]; + x *= l, y *= l; + target.vx -= x * (b = bias[i]); + target.vy -= y * b; + source.vx += x * (b = 1 - b); + source.vy += y * b; + } + } + } + + function initialize() { + if (!nodes) return; + + var i, + n = nodes.length, + m = links.length, + nodeById = new Map(nodes.map((d, i) => [id(d, i, nodes), d])), + link; + + for (i = 0, count = new Array(n); i < m; ++i) { + link = links[i], link.index = i; + if (typeof link.source !== "object") link.source = find(nodeById, link.source); + if (typeof link.target !== "object") link.target = find(nodeById, link.target); + count[link.source.index] = (count[link.source.index] || 0) + 1; + count[link.target.index] = (count[link.target.index] || 0) + 1; + } + + for (i = 0, bias = new Array(m); i < m; ++i) { + link = links[i], bias[i] = count[link.source.index] / (count[link.source.index] + count[link.target.index]); + } + + strengths = new Array(m), initializeStrength(); + distances = new Array(m), initializeDistance(); + } + + function initializeStrength() { + if (!nodes) return; + + for (var i = 0, n = links.length; i < n; ++i) { + strengths[i] = +strength(links[i], i, links); + } + } + + function initializeDistance() { + if (!nodes) return; + + for (var i = 0, n = links.length; i < n; ++i) { + distances[i] = +distance(links[i], i, links); + } + } + + force.initialize = function(_nodes, _random) { + nodes = _nodes; + random = _random; + initialize(); + }; + + force.links = function(_) { + return arguments.length ? (links = _, initialize(), force) : links; + }; + + force.id = function(_) { + return arguments.length ? (id = _, force) : id; + }; + + force.iterations = function(_) { + return arguments.length ? (iterations = +_, force) : iterations; + }; + + force.strength = function(_) { + return arguments.length ? (strength = typeof _ === "function" ? _ : constant$4(+_), initializeStrength(), force) : strength; + }; + + force.distance = function(_) { + return arguments.length ? (distance = typeof _ === "function" ? _ : constant$4(+_), initializeDistance(), force) : distance; + }; + + return force; +} + +// https://en.wikipedia.org/wiki/Linear_congruential_generator#Parameters_in_common_use +const a$1 = 1664525; +const c$3 = 1013904223; +const m = 4294967296; // 2^32 + +function lcg$1() { + let s = 1; + return () => (s = (a$1 * s + c$3) % m) / m; +} + +function x$2(d) { + return d.x; +} + +function y$2(d) { + return d.y; +} + +var initialRadius = 10, + initialAngle = Math.PI * (3 - Math.sqrt(5)); + +function simulation(nodes) { + var simulation, + alpha = 1, + alphaMin = 0.001, + alphaDecay = 1 - Math.pow(alphaMin, 1 / 300), + alphaTarget = 0, + velocityDecay = 0.6, + forces = new Map(), + stepper = timer(step), + event = dispatch("tick", "end"), + random = lcg$1(); + + if (nodes == null) nodes = []; + + function step() { + tick(); + event.call("tick", simulation); + if (alpha < alphaMin) { + stepper.stop(); + event.call("end", simulation); + } + } + + function tick(iterations) { + var i, n = nodes.length, node; + + if (iterations === undefined) iterations = 1; + + for (var k = 0; k < iterations; ++k) { + alpha += (alphaTarget - alpha) * alphaDecay; + + forces.forEach(function(force) { + force(alpha); + }); + + for (i = 0; i < n; ++i) { + node = nodes[i]; + if (node.fx == null) node.x += node.vx *= velocityDecay; + else node.x = node.fx, node.vx = 0; + if (node.fy == null) node.y += node.vy *= velocityDecay; + else node.y = node.fy, node.vy = 0; + } + } + + return simulation; + } + + function initializeNodes() { + for (var i = 0, n = nodes.length, node; i < n; ++i) { + node = nodes[i], node.index = i; + if (node.fx != null) node.x = node.fx; + if (node.fy != null) node.y = node.fy; + if (isNaN(node.x) || isNaN(node.y)) { + var radius = initialRadius * Math.sqrt(0.5 + i), angle = i * initialAngle; + node.x = radius * Math.cos(angle); + node.y = radius * Math.sin(angle); + } + if (isNaN(node.vx) || isNaN(node.vy)) { + node.vx = node.vy = 0; + } + } + } + + function initializeForce(force) { + if (force.initialize) force.initialize(nodes, random); + return force; + } + + initializeNodes(); + + return simulation = { + tick: tick, + + restart: function() { + return stepper.restart(step), simulation; + }, + + stop: function() { + return stepper.stop(), simulation; + }, + + nodes: function(_) { + return arguments.length ? (nodes = _, initializeNodes(), forces.forEach(initializeForce), simulation) : nodes; + }, + + alpha: function(_) { + return arguments.length ? (alpha = +_, simulation) : alpha; + }, + + alphaMin: function(_) { + return arguments.length ? (alphaMin = +_, simulation) : alphaMin; + }, + + alphaDecay: function(_) { + return arguments.length ? (alphaDecay = +_, simulation) : +alphaDecay; + }, + + alphaTarget: function(_) { + return arguments.length ? (alphaTarget = +_, simulation) : alphaTarget; + }, + + velocityDecay: function(_) { + return arguments.length ? (velocityDecay = 1 - _, simulation) : 1 - velocityDecay; + }, + + randomSource: function(_) { + return arguments.length ? (random = _, forces.forEach(initializeForce), simulation) : random; + }, + + force: function(name, _) { + return arguments.length > 1 ? ((_ == null ? forces.delete(name) : forces.set(name, initializeForce(_))), simulation) : forces.get(name); + }, + + find: function(x, y, radius) { + var i = 0, + n = nodes.length, + dx, + dy, + d2, + node, + closest; + + if (radius == null) radius = Infinity; + else radius *= radius; + + for (i = 0; i < n; ++i) { + node = nodes[i]; + dx = x - node.x; + dy = y - node.y; + d2 = dx * dx + dy * dy; + if (d2 < radius) closest = node, radius = d2; + } + + return closest; + }, + + on: function(name, _) { + return arguments.length > 1 ? (event.on(name, _), simulation) : event.on(name); + } + }; +} + +function manyBody() { + var nodes, + node, + random, + alpha, + strength = constant$4(-30), + strengths, + distanceMin2 = 1, + distanceMax2 = Infinity, + theta2 = 0.81; + + function force(_) { + var i, n = nodes.length, tree = quadtree(nodes, x$2, y$2).visitAfter(accumulate); + for (alpha = _, i = 0; i < n; ++i) node = nodes[i], tree.visit(apply); + } + + function initialize() { + if (!nodes) return; + var i, n = nodes.length, node; + strengths = new Array(n); + for (i = 0; i < n; ++i) node = nodes[i], strengths[node.index] = +strength(node, i, nodes); + } + + function accumulate(quad) { + var strength = 0, q, c, weight = 0, x, y, i; + + // For internal nodes, accumulate forces from child quadrants. + if (quad.length) { + for (x = y = i = 0; i < 4; ++i) { + if ((q = quad[i]) && (c = Math.abs(q.value))) { + strength += q.value, weight += c, x += c * q.x, y += c * q.y; + } + } + quad.x = x / weight; + quad.y = y / weight; + } + + // For leaf nodes, accumulate forces from coincident quadrants. + else { + q = quad; + q.x = q.data.x; + q.y = q.data.y; + do strength += strengths[q.data.index]; + while (q = q.next); + } + + quad.value = strength; + } + + function apply(quad, x1, _, x2) { + if (!quad.value) return true; + + var x = quad.x - node.x, + y = quad.y - node.y, + w = x2 - x1, + l = x * x + y * y; + + // Apply the Barnes-Hut approximation if possible. + // Limit forces for very close nodes; randomize direction if coincident. + if (w * w / theta2 < l) { + if (l < distanceMax2) { + if (x === 0) x = jiggle(random), l += x * x; + if (y === 0) y = jiggle(random), l += y * y; + if (l < distanceMin2) l = Math.sqrt(distanceMin2 * l); + node.vx += x * quad.value * alpha / l; + node.vy += y * quad.value * alpha / l; + } + return true; + } + + // Otherwise, process points directly. + else if (quad.length || l >= distanceMax2) return; + + // Limit forces for very close nodes; randomize direction if coincident. + if (quad.data !== node || quad.next) { + if (x === 0) x = jiggle(random), l += x * x; + if (y === 0) y = jiggle(random), l += y * y; + if (l < distanceMin2) l = Math.sqrt(distanceMin2 * l); + } + + do if (quad.data !== node) { + w = strengths[quad.data.index] * alpha / l; + node.vx += x * w; + node.vy += y * w; + } while (quad = quad.next); + } + + force.initialize = function(_nodes, _random) { + nodes = _nodes; + random = _random; + initialize(); + }; + + force.strength = function(_) { + return arguments.length ? (strength = typeof _ === "function" ? _ : constant$4(+_), initialize(), force) : strength; + }; + + force.distanceMin = function(_) { + return arguments.length ? (distanceMin2 = _ * _, force) : Math.sqrt(distanceMin2); + }; + + force.distanceMax = function(_) { + return arguments.length ? (distanceMax2 = _ * _, force) : Math.sqrt(distanceMax2); + }; + + force.theta = function(_) { + return arguments.length ? (theta2 = _ * _, force) : Math.sqrt(theta2); + }; + + return force; +} + +function radial$1(radius, x, y) { + var nodes, + strength = constant$4(0.1), + strengths, + radiuses; + + if (typeof radius !== "function") radius = constant$4(+radius); + if (x == null) x = 0; + if (y == null) y = 0; + + function force(alpha) { + for (var i = 0, n = nodes.length; i < n; ++i) { + var node = nodes[i], + dx = node.x - x || 1e-6, + dy = node.y - y || 1e-6, + r = Math.sqrt(dx * dx + dy * dy), + k = (radiuses[i] - r) * strengths[i] * alpha / r; + node.vx += dx * k; + node.vy += dy * k; + } + } + + function initialize() { + if (!nodes) return; + var i, n = nodes.length; + strengths = new Array(n); + radiuses = new Array(n); + for (i = 0; i < n; ++i) { + radiuses[i] = +radius(nodes[i], i, nodes); + strengths[i] = isNaN(radiuses[i]) ? 0 : +strength(nodes[i], i, nodes); + } + } + + force.initialize = function(_) { + nodes = _, initialize(); + }; + + force.strength = function(_) { + return arguments.length ? (strength = typeof _ === "function" ? _ : constant$4(+_), initialize(), force) : strength; + }; + + force.radius = function(_) { + return arguments.length ? (radius = typeof _ === "function" ? _ : constant$4(+_), initialize(), force) : radius; + }; + + force.x = function(_) { + return arguments.length ? (x = +_, force) : x; + }; + + force.y = function(_) { + return arguments.length ? (y = +_, force) : y; + }; + + return force; +} + +function x$1(x) { + var strength = constant$4(0.1), + nodes, + strengths, + xz; + + if (typeof x !== "function") x = constant$4(x == null ? 0 : +x); + + function force(alpha) { + for (var i = 0, n = nodes.length, node; i < n; ++i) { + node = nodes[i], node.vx += (xz[i] - node.x) * strengths[i] * alpha; + } + } + + function initialize() { + if (!nodes) return; + var i, n = nodes.length; + strengths = new Array(n); + xz = new Array(n); + for (i = 0; i < n; ++i) { + strengths[i] = isNaN(xz[i] = +x(nodes[i], i, nodes)) ? 0 : +strength(nodes[i], i, nodes); + } + } + + force.initialize = function(_) { + nodes = _; + initialize(); + }; + + force.strength = function(_) { + return arguments.length ? (strength = typeof _ === "function" ? _ : constant$4(+_), initialize(), force) : strength; + }; + + force.x = function(_) { + return arguments.length ? (x = typeof _ === "function" ? _ : constant$4(+_), initialize(), force) : x; + }; + + return force; +} + +function y$1(y) { + var strength = constant$4(0.1), + nodes, + strengths, + yz; + + if (typeof y !== "function") y = constant$4(y == null ? 0 : +y); + + function force(alpha) { + for (var i = 0, n = nodes.length, node; i < n; ++i) { + node = nodes[i], node.vy += (yz[i] - node.y) * strengths[i] * alpha; + } + } + + function initialize() { + if (!nodes) return; + var i, n = nodes.length; + strengths = new Array(n); + yz = new Array(n); + for (i = 0; i < n; ++i) { + strengths[i] = isNaN(yz[i] = +y(nodes[i], i, nodes)) ? 0 : +strength(nodes[i], i, nodes); + } + } + + force.initialize = function(_) { + nodes = _; + initialize(); + }; + + force.strength = function(_) { + return arguments.length ? (strength = typeof _ === "function" ? _ : constant$4(+_), initialize(), force) : strength; + }; + + force.y = function(_) { + return arguments.length ? (y = typeof _ === "function" ? _ : constant$4(+_), initialize(), force) : y; + }; + + return force; +} + +function formatDecimal(x) { + return Math.abs(x = Math.round(x)) >= 1e21 + ? x.toLocaleString("en").replace(/,/g, "") + : x.toString(10); +} + +// Computes the decimal coefficient and exponent of the specified number x with +// significant digits p, where x is positive and p is in [1, 21] or undefined. +// For example, formatDecimalParts(1.23) returns ["123", 0]. +function formatDecimalParts(x, p) { + if ((i = (x = p ? x.toExponential(p - 1) : x.toExponential()).indexOf("e")) < 0) return null; // NaN, ±Infinity + var i, coefficient = x.slice(0, i); + + // The string returned by toExponential either has the form \d\.\d+e[-+]\d+ + // (e.g., 1.2e+3) or the form \de[-+]\d+ (e.g., 1e+3). + return [ + coefficient.length > 1 ? coefficient[0] + coefficient.slice(2) : coefficient, + +x.slice(i + 1) + ]; +} + +function exponent(x) { + return x = formatDecimalParts(Math.abs(x)), x ? x[1] : NaN; +} + +function formatGroup(grouping, thousands) { + return function(value, width) { + var i = value.length, + t = [], + j = 0, + g = grouping[0], + length = 0; + + while (i > 0 && g > 0) { + if (length + g + 1 > width) g = Math.max(1, width - length); + t.push(value.substring(i -= g, i + g)); + if ((length += g + 1) > width) break; + g = grouping[j = (j + 1) % grouping.length]; + } + + return t.reverse().join(thousands); + }; +} + +function formatNumerals(numerals) { + return function(value) { + return value.replace(/[0-9]/g, function(i) { + return numerals[+i]; + }); + }; +} + +// [[fill]align][sign][symbol][0][width][,][.precision][~][type] +var re = /^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i; + +function formatSpecifier(specifier) { + if (!(match = re.exec(specifier))) throw new Error("invalid format: " + specifier); + var match; + return new FormatSpecifier({ + fill: match[1], + align: match[2], + sign: match[3], + symbol: match[4], + zero: match[5], + width: match[6], + comma: match[7], + precision: match[8] && match[8].slice(1), + trim: match[9], + type: match[10] + }); +} + +formatSpecifier.prototype = FormatSpecifier.prototype; // instanceof + +function FormatSpecifier(specifier) { + this.fill = specifier.fill === undefined ? " " : specifier.fill + ""; + this.align = specifier.align === undefined ? ">" : specifier.align + ""; + this.sign = specifier.sign === undefined ? "-" : specifier.sign + ""; + this.symbol = specifier.symbol === undefined ? "" : specifier.symbol + ""; + this.zero = !!specifier.zero; + this.width = specifier.width === undefined ? undefined : +specifier.width; + this.comma = !!specifier.comma; + this.precision = specifier.precision === undefined ? undefined : +specifier.precision; + this.trim = !!specifier.trim; + this.type = specifier.type === undefined ? "" : specifier.type + ""; +} + +FormatSpecifier.prototype.toString = function() { + return this.fill + + this.align + + this.sign + + this.symbol + + (this.zero ? "0" : "") + + (this.width === undefined ? "" : Math.max(1, this.width | 0)) + + (this.comma ? "," : "") + + (this.precision === undefined ? "" : "." + Math.max(0, this.precision | 0)) + + (this.trim ? "~" : "") + + this.type; +}; + +// Trims insignificant zeros, e.g., replaces 1.2000k with 1.2k. +function formatTrim(s) { + out: for (var n = s.length, i = 1, i0 = -1, i1; i < n; ++i) { + switch (s[i]) { + case ".": i0 = i1 = i; break; + case "0": if (i0 === 0) i0 = i; i1 = i; break; + default: if (!+s[i]) break out; if (i0 > 0) i0 = 0; break; + } + } + return i0 > 0 ? s.slice(0, i0) + s.slice(i1 + 1) : s; +} + +var prefixExponent; + +function formatPrefixAuto(x, p) { + var d = formatDecimalParts(x, p); + if (!d) return x + ""; + var coefficient = d[0], + exponent = d[1], + i = exponent - (prefixExponent = Math.max(-8, Math.min(8, Math.floor(exponent / 3))) * 3) + 1, + n = coefficient.length; + return i === n ? coefficient + : i > n ? coefficient + new Array(i - n + 1).join("0") + : i > 0 ? coefficient.slice(0, i) + "." + coefficient.slice(i) + : "0." + new Array(1 - i).join("0") + formatDecimalParts(x, Math.max(0, p + i - 1))[0]; // less than 1y! +} + +function formatRounded(x, p) { + var d = formatDecimalParts(x, p); + if (!d) return x + ""; + var coefficient = d[0], + exponent = d[1]; + return exponent < 0 ? "0." + new Array(-exponent).join("0") + coefficient + : coefficient.length > exponent + 1 ? coefficient.slice(0, exponent + 1) + "." + coefficient.slice(exponent + 1) + : coefficient + new Array(exponent - coefficient.length + 2).join("0"); +} + +var formatTypes = { + "%": (x, p) => (x * 100).toFixed(p), + "b": (x) => Math.round(x).toString(2), + "c": (x) => x + "", + "d": formatDecimal, + "e": (x, p) => x.toExponential(p), + "f": (x, p) => x.toFixed(p), + "g": (x, p) => x.toPrecision(p), + "o": (x) => Math.round(x).toString(8), + "p": (x, p) => formatRounded(x * 100, p), + "r": formatRounded, + "s": formatPrefixAuto, + "X": (x) => Math.round(x).toString(16).toUpperCase(), + "x": (x) => Math.round(x).toString(16) +}; + +function identity$6(x) { + return x; +} + +var map = Array.prototype.map, + prefixes = ["y","z","a","f","p","n","\xB5","m","","k","M","G","T","P","E","Z","Y"]; + +function formatLocale$1(locale) { + var group = locale.grouping === undefined || locale.thousands === undefined ? identity$6 : formatGroup(map.call(locale.grouping, Number), locale.thousands + ""), + currencyPrefix = locale.currency === undefined ? "" : locale.currency[0] + "", + currencySuffix = locale.currency === undefined ? "" : locale.currency[1] + "", + decimal = locale.decimal === undefined ? "." : locale.decimal + "", + numerals = locale.numerals === undefined ? identity$6 : formatNumerals(map.call(locale.numerals, String)), + percent = locale.percent === undefined ? "%" : locale.percent + "", + minus = locale.minus === undefined ? "\u2212" : locale.minus + "", + nan = locale.nan === undefined ? "NaN" : locale.nan + ""; + + function newFormat(specifier) { + specifier = formatSpecifier(specifier); + + var fill = specifier.fill, + align = specifier.align, + sign = specifier.sign, + symbol = specifier.symbol, + zero = specifier.zero, + width = specifier.width, + comma = specifier.comma, + precision = specifier.precision, + trim = specifier.trim, + type = specifier.type; + + // The "n" type is an alias for ",g". + if (type === "n") comma = true, type = "g"; + + // The "" type, and any invalid type, is an alias for ".12~g". + else if (!formatTypes[type]) precision === undefined && (precision = 12), trim = true, type = "g"; + + // If zero fill is specified, padding goes after sign and before digits. + if (zero || (fill === "0" && align === "=")) zero = true, fill = "0", align = "="; + + // Compute the prefix and suffix. + // For SI-prefix, the suffix is lazily computed. + var prefix = symbol === "$" ? currencyPrefix : symbol === "#" && /[boxX]/.test(type) ? "0" + type.toLowerCase() : "", + suffix = symbol === "$" ? currencySuffix : /[%p]/.test(type) ? percent : ""; + + // What format function should we use? + // Is this an integer type? + // Can this type generate exponential notation? + var formatType = formatTypes[type], + maybeSuffix = /[defgprs%]/.test(type); + + // Set the default precision if not specified, + // or clamp the specified precision to the supported range. + // For significant precision, it must be in [1, 21]. + // For fixed precision, it must be in [0, 20]. + precision = precision === undefined ? 6 + : /[gprs]/.test(type) ? Math.max(1, Math.min(21, precision)) + : Math.max(0, Math.min(20, precision)); + + function format(value) { + var valuePrefix = prefix, + valueSuffix = suffix, + i, n, c; + + if (type === "c") { + valueSuffix = formatType(value) + valueSuffix; + value = ""; + } else { + value = +value; + + // Determine the sign. -0 is not less than 0, but 1 / -0 is! + var valueNegative = value < 0 || 1 / value < 0; + + // Perform the initial formatting. + value = isNaN(value) ? nan : formatType(Math.abs(value), precision); + + // Trim insignificant zeros. + if (trim) value = formatTrim(value); + + // If a negative value rounds to zero after formatting, and no explicit positive sign is requested, hide the sign. + if (valueNegative && +value === 0 && sign !== "+") valueNegative = false; + + // Compute the prefix and suffix. + valuePrefix = (valueNegative ? (sign === "(" ? sign : minus) : sign === "-" || sign === "(" ? "" : sign) + valuePrefix; + valueSuffix = (type === "s" ? prefixes[8 + prefixExponent / 3] : "") + valueSuffix + (valueNegative && sign === "(" ? ")" : ""); + + // Break the formatted value into the integer “value” part that can be + // grouped, and fractional or exponential “suffix” part that is not. + if (maybeSuffix) { + i = -1, n = value.length; + while (++i < n) { + if (c = value.charCodeAt(i), 48 > c || c > 57) { + valueSuffix = (c === 46 ? decimal + value.slice(i + 1) : value.slice(i)) + valueSuffix; + value = value.slice(0, i); + break; + } + } + } + } + + // If the fill character is not "0", grouping is applied before padding. + if (comma && !zero) value = group(value, Infinity); + + // Compute the padding. + var length = valuePrefix.length + value.length + valueSuffix.length, + padding = length < width ? new Array(width - length + 1).join(fill) : ""; + + // If the fill character is "0", grouping is applied after padding. + if (comma && zero) value = group(padding + value, padding.length ? width - valueSuffix.length : Infinity), padding = ""; + + // Reconstruct the final output based on the desired alignment. + switch (align) { + case "<": value = valuePrefix + value + valueSuffix + padding; break; + case "=": value = valuePrefix + padding + value + valueSuffix; break; + case "^": value = padding.slice(0, length = padding.length >> 1) + valuePrefix + value + valueSuffix + padding.slice(length); break; + default: value = padding + valuePrefix + value + valueSuffix; break; + } + + return numerals(value); + } + + format.toString = function() { + return specifier + ""; + }; + + return format; + } + + function formatPrefix(specifier, value) { + var f = newFormat((specifier = formatSpecifier(specifier), specifier.type = "f", specifier)), + e = Math.max(-8, Math.min(8, Math.floor(exponent(value) / 3))) * 3, + k = Math.pow(10, -e), + prefix = prefixes[8 + e / 3]; + return function(value) { + return f(k * value) + prefix; + }; + } + + return { + format: newFormat, + formatPrefix: formatPrefix + }; +} + +var locale$1; +exports.format = void 0; +exports.formatPrefix = void 0; + +defaultLocale$1({ + thousands: ",", + grouping: [3], + currency: ["$", ""] +}); + +function defaultLocale$1(definition) { + locale$1 = formatLocale$1(definition); + exports.format = locale$1.format; + exports.formatPrefix = locale$1.formatPrefix; + return locale$1; +} + +function precisionFixed(step) { + return Math.max(0, -exponent(Math.abs(step))); +} + +function precisionPrefix(step, value) { + return Math.max(0, Math.max(-8, Math.min(8, Math.floor(exponent(value) / 3))) * 3 - exponent(Math.abs(step))); +} + +function precisionRound(step, max) { + step = Math.abs(step), max = Math.abs(max) - step; + return Math.max(0, exponent(max) - exponent(step)) + 1; +} + +var epsilon$1 = 1e-6; +var epsilon2 = 1e-12; +var pi$1 = Math.PI; +var halfPi$1 = pi$1 / 2; +var quarterPi = pi$1 / 4; +var tau$1 = pi$1 * 2; + +var degrees = 180 / pi$1; +var radians = pi$1 / 180; + +var abs$1 = Math.abs; +var atan = Math.atan; +var atan2$1 = Math.atan2; +var cos$1 = Math.cos; +var ceil = Math.ceil; +var exp = Math.exp; +var hypot = Math.hypot; +var log$1 = Math.log; +var pow$1 = Math.pow; +var sin$1 = Math.sin; +var sign$1 = Math.sign || function(x) { return x > 0 ? 1 : x < 0 ? -1 : 0; }; +var sqrt$2 = Math.sqrt; +var tan = Math.tan; + +function acos$1(x) { + return x > 1 ? 0 : x < -1 ? pi$1 : Math.acos(x); +} + +function asin$1(x) { + return x > 1 ? halfPi$1 : x < -1 ? -halfPi$1 : Math.asin(x); +} + +function haversin(x) { + return (x = sin$1(x / 2)) * x; +} + +function noop$1() {} + +function streamGeometry(geometry, stream) { + if (geometry && streamGeometryType.hasOwnProperty(geometry.type)) { + streamGeometryType[geometry.type](geometry, stream); + } +} + +var streamObjectType = { + Feature: function(object, stream) { + streamGeometry(object.geometry, stream); + }, + FeatureCollection: function(object, stream) { + var features = object.features, i = -1, n = features.length; + while (++i < n) streamGeometry(features[i].geometry, stream); + } +}; + +var streamGeometryType = { + Sphere: function(object, stream) { + stream.sphere(); + }, + Point: function(object, stream) { + object = object.coordinates; + stream.point(object[0], object[1], object[2]); + }, + MultiPoint: function(object, stream) { + var coordinates = object.coordinates, i = -1, n = coordinates.length; + while (++i < n) object = coordinates[i], stream.point(object[0], object[1], object[2]); + }, + LineString: function(object, stream) { + streamLine(object.coordinates, stream, 0); + }, + MultiLineString: function(object, stream) { + var coordinates = object.coordinates, i = -1, n = coordinates.length; + while (++i < n) streamLine(coordinates[i], stream, 0); + }, + Polygon: function(object, stream) { + streamPolygon(object.coordinates, stream); + }, + MultiPolygon: function(object, stream) { + var coordinates = object.coordinates, i = -1, n = coordinates.length; + while (++i < n) streamPolygon(coordinates[i], stream); + }, + GeometryCollection: function(object, stream) { + var geometries = object.geometries, i = -1, n = geometries.length; + while (++i < n) streamGeometry(geometries[i], stream); + } +}; + +function streamLine(coordinates, stream, closed) { + var i = -1, n = coordinates.length - closed, coordinate; + stream.lineStart(); + while (++i < n) coordinate = coordinates[i], stream.point(coordinate[0], coordinate[1], coordinate[2]); + stream.lineEnd(); +} + +function streamPolygon(coordinates, stream) { + var i = -1, n = coordinates.length; + stream.polygonStart(); + while (++i < n) streamLine(coordinates[i], stream, 1); + stream.polygonEnd(); +} + +function geoStream(object, stream) { + if (object && streamObjectType.hasOwnProperty(object.type)) { + streamObjectType[object.type](object, stream); + } else { + streamGeometry(object, stream); + } +} + +var areaRingSum$1 = new Adder(); + +// hello? + +var areaSum$1 = new Adder(), + lambda00$2, + phi00$2, + lambda0$2, + cosPhi0$1, + sinPhi0$1; + +var areaStream$1 = { + point: noop$1, + lineStart: noop$1, + lineEnd: noop$1, + polygonStart: function() { + areaRingSum$1 = new Adder(); + areaStream$1.lineStart = areaRingStart$1; + areaStream$1.lineEnd = areaRingEnd$1; + }, + polygonEnd: function() { + var areaRing = +areaRingSum$1; + areaSum$1.add(areaRing < 0 ? tau$1 + areaRing : areaRing); + this.lineStart = this.lineEnd = this.point = noop$1; + }, + sphere: function() { + areaSum$1.add(tau$1); + } +}; + +function areaRingStart$1() { + areaStream$1.point = areaPointFirst$1; +} + +function areaRingEnd$1() { + areaPoint$1(lambda00$2, phi00$2); +} + +function areaPointFirst$1(lambda, phi) { + areaStream$1.point = areaPoint$1; + lambda00$2 = lambda, phi00$2 = phi; + lambda *= radians, phi *= radians; + lambda0$2 = lambda, cosPhi0$1 = cos$1(phi = phi / 2 + quarterPi), sinPhi0$1 = sin$1(phi); +} + +function areaPoint$1(lambda, phi) { + lambda *= radians, phi *= radians; + phi = phi / 2 + quarterPi; // half the angular distance from south pole + + // Spherical excess E for a spherical triangle with vertices: south pole, + // previous point, current point. Uses a formula derived from Cagnoli’s + // theorem. See Todhunter, Spherical Trig. (1871), Sec. 103, Eq. (2). + var dLambda = lambda - lambda0$2, + sdLambda = dLambda >= 0 ? 1 : -1, + adLambda = sdLambda * dLambda, + cosPhi = cos$1(phi), + sinPhi = sin$1(phi), + k = sinPhi0$1 * sinPhi, + u = cosPhi0$1 * cosPhi + k * cos$1(adLambda), + v = k * sdLambda * sin$1(adLambda); + areaRingSum$1.add(atan2$1(v, u)); + + // Advance the previous points. + lambda0$2 = lambda, cosPhi0$1 = cosPhi, sinPhi0$1 = sinPhi; +} + +function area$2(object) { + areaSum$1 = new Adder(); + geoStream(object, areaStream$1); + return areaSum$1 * 2; +} + +function spherical(cartesian) { + return [atan2$1(cartesian[1], cartesian[0]), asin$1(cartesian[2])]; +} + +function cartesian(spherical) { + var lambda = spherical[0], phi = spherical[1], cosPhi = cos$1(phi); + return [cosPhi * cos$1(lambda), cosPhi * sin$1(lambda), sin$1(phi)]; +} + +function cartesianDot(a, b) { + return a[0] * b[0] + a[1] * b[1] + a[2] * b[2]; +} + +function cartesianCross(a, b) { + return [a[1] * b[2] - a[2] * b[1], a[2] * b[0] - a[0] * b[2], a[0] * b[1] - a[1] * b[0]]; +} + +// TODO return a +function cartesianAddInPlace(a, b) { + a[0] += b[0], a[1] += b[1], a[2] += b[2]; +} + +function cartesianScale(vector, k) { + return [vector[0] * k, vector[1] * k, vector[2] * k]; +} + +// TODO return d +function cartesianNormalizeInPlace(d) { + var l = sqrt$2(d[0] * d[0] + d[1] * d[1] + d[2] * d[2]); + d[0] /= l, d[1] /= l, d[2] /= l; +} + +var lambda0$1, phi0, lambda1, phi1, // bounds + lambda2, // previous lambda-coordinate + lambda00$1, phi00$1, // first point + p0, // previous 3D point + deltaSum, + ranges, + range; + +var boundsStream$2 = { + point: boundsPoint$1, + lineStart: boundsLineStart, + lineEnd: boundsLineEnd, + polygonStart: function() { + boundsStream$2.point = boundsRingPoint; + boundsStream$2.lineStart = boundsRingStart; + boundsStream$2.lineEnd = boundsRingEnd; + deltaSum = new Adder(); + areaStream$1.polygonStart(); + }, + polygonEnd: function() { + areaStream$1.polygonEnd(); + boundsStream$2.point = boundsPoint$1; + boundsStream$2.lineStart = boundsLineStart; + boundsStream$2.lineEnd = boundsLineEnd; + if (areaRingSum$1 < 0) lambda0$1 = -(lambda1 = 180), phi0 = -(phi1 = 90); + else if (deltaSum > epsilon$1) phi1 = 90; + else if (deltaSum < -epsilon$1) phi0 = -90; + range[0] = lambda0$1, range[1] = lambda1; + }, + sphere: function() { + lambda0$1 = -(lambda1 = 180), phi0 = -(phi1 = 90); + } +}; + +function boundsPoint$1(lambda, phi) { + ranges.push(range = [lambda0$1 = lambda, lambda1 = lambda]); + if (phi < phi0) phi0 = phi; + if (phi > phi1) phi1 = phi; +} + +function linePoint(lambda, phi) { + var p = cartesian([lambda * radians, phi * radians]); + if (p0) { + var normal = cartesianCross(p0, p), + equatorial = [normal[1], -normal[0], 0], + inflection = cartesianCross(equatorial, normal); + cartesianNormalizeInPlace(inflection); + inflection = spherical(inflection); + var delta = lambda - lambda2, + sign = delta > 0 ? 1 : -1, + lambdai = inflection[0] * degrees * sign, + phii, + antimeridian = abs$1(delta) > 180; + if (antimeridian ^ (sign * lambda2 < lambdai && lambdai < sign * lambda)) { + phii = inflection[1] * degrees; + if (phii > phi1) phi1 = phii; + } else if (lambdai = (lambdai + 360) % 360 - 180, antimeridian ^ (sign * lambda2 < lambdai && lambdai < sign * lambda)) { + phii = -inflection[1] * degrees; + if (phii < phi0) phi0 = phii; + } else { + if (phi < phi0) phi0 = phi; + if (phi > phi1) phi1 = phi; + } + if (antimeridian) { + if (lambda < lambda2) { + if (angle(lambda0$1, lambda) > angle(lambda0$1, lambda1)) lambda1 = lambda; + } else { + if (angle(lambda, lambda1) > angle(lambda0$1, lambda1)) lambda0$1 = lambda; + } + } else { + if (lambda1 >= lambda0$1) { + if (lambda < lambda0$1) lambda0$1 = lambda; + if (lambda > lambda1) lambda1 = lambda; + } else { + if (lambda > lambda2) { + if (angle(lambda0$1, lambda) > angle(lambda0$1, lambda1)) lambda1 = lambda; + } else { + if (angle(lambda, lambda1) > angle(lambda0$1, lambda1)) lambda0$1 = lambda; + } + } + } + } else { + ranges.push(range = [lambda0$1 = lambda, lambda1 = lambda]); + } + if (phi < phi0) phi0 = phi; + if (phi > phi1) phi1 = phi; + p0 = p, lambda2 = lambda; +} + +function boundsLineStart() { + boundsStream$2.point = linePoint; +} + +function boundsLineEnd() { + range[0] = lambda0$1, range[1] = lambda1; + boundsStream$2.point = boundsPoint$1; + p0 = null; +} + +function boundsRingPoint(lambda, phi) { + if (p0) { + var delta = lambda - lambda2; + deltaSum.add(abs$1(delta) > 180 ? delta + (delta > 0 ? 360 : -360) : delta); + } else { + lambda00$1 = lambda, phi00$1 = phi; + } + areaStream$1.point(lambda, phi); + linePoint(lambda, phi); +} + +function boundsRingStart() { + areaStream$1.lineStart(); +} + +function boundsRingEnd() { + boundsRingPoint(lambda00$1, phi00$1); + areaStream$1.lineEnd(); + if (abs$1(deltaSum) > epsilon$1) lambda0$1 = -(lambda1 = 180); + range[0] = lambda0$1, range[1] = lambda1; + p0 = null; +} + +// Finds the left-right distance between two longitudes. +// This is almost the same as (lambda1 - lambda0 + 360°) % 360°, except that we want +// the distance between ±180° to be 360°. +function angle(lambda0, lambda1) { + return (lambda1 -= lambda0) < 0 ? lambda1 + 360 : lambda1; +} + +function rangeCompare(a, b) { + return a[0] - b[0]; +} + +function rangeContains(range, x) { + return range[0] <= range[1] ? range[0] <= x && x <= range[1] : x < range[0] || range[1] < x; +} + +function bounds(feature) { + var i, n, a, b, merged, deltaMax, delta; + + phi1 = lambda1 = -(lambda0$1 = phi0 = Infinity); + ranges = []; + geoStream(feature, boundsStream$2); + + // First, sort ranges by their minimum longitudes. + if (n = ranges.length) { + ranges.sort(rangeCompare); + + // Then, merge any ranges that overlap. + for (i = 1, a = ranges[0], merged = [a]; i < n; ++i) { + b = ranges[i]; + if (rangeContains(a, b[0]) || rangeContains(a, b[1])) { + if (angle(a[0], b[1]) > angle(a[0], a[1])) a[1] = b[1]; + if (angle(b[0], a[1]) > angle(a[0], a[1])) a[0] = b[0]; + } else { + merged.push(a = b); + } + } + + // Finally, find the largest gap between the merged ranges. + // The final bounding box will be the inverse of this gap. + for (deltaMax = -Infinity, n = merged.length - 1, i = 0, a = merged[n]; i <= n; a = b, ++i) { + b = merged[i]; + if ((delta = angle(a[1], b[0])) > deltaMax) deltaMax = delta, lambda0$1 = b[0], lambda1 = a[1]; + } + } + + ranges = range = null; + + return lambda0$1 === Infinity || phi0 === Infinity + ? [[NaN, NaN], [NaN, NaN]] + : [[lambda0$1, phi0], [lambda1, phi1]]; +} + +var W0, W1, + X0$1, Y0$1, Z0$1, + X1$1, Y1$1, Z1$1, + X2$1, Y2$1, Z2$1, + lambda00, phi00, // first point + x0$4, y0$4, z0; // previous point + +var centroidStream$1 = { + sphere: noop$1, + point: centroidPoint$1, + lineStart: centroidLineStart$1, + lineEnd: centroidLineEnd$1, + polygonStart: function() { + centroidStream$1.lineStart = centroidRingStart$1; + centroidStream$1.lineEnd = centroidRingEnd$1; + }, + polygonEnd: function() { + centroidStream$1.lineStart = centroidLineStart$1; + centroidStream$1.lineEnd = centroidLineEnd$1; + } +}; + +// Arithmetic mean of Cartesian vectors. +function centroidPoint$1(lambda, phi) { + lambda *= radians, phi *= radians; + var cosPhi = cos$1(phi); + centroidPointCartesian(cosPhi * cos$1(lambda), cosPhi * sin$1(lambda), sin$1(phi)); +} + +function centroidPointCartesian(x, y, z) { + ++W0; + X0$1 += (x - X0$1) / W0; + Y0$1 += (y - Y0$1) / W0; + Z0$1 += (z - Z0$1) / W0; +} + +function centroidLineStart$1() { + centroidStream$1.point = centroidLinePointFirst; +} + +function centroidLinePointFirst(lambda, phi) { + lambda *= radians, phi *= radians; + var cosPhi = cos$1(phi); + x0$4 = cosPhi * cos$1(lambda); + y0$4 = cosPhi * sin$1(lambda); + z0 = sin$1(phi); + centroidStream$1.point = centroidLinePoint; + centroidPointCartesian(x0$4, y0$4, z0); +} + +function centroidLinePoint(lambda, phi) { + lambda *= radians, phi *= radians; + var cosPhi = cos$1(phi), + x = cosPhi * cos$1(lambda), + y = cosPhi * sin$1(lambda), + z = sin$1(phi), + w = atan2$1(sqrt$2((w = y0$4 * z - z0 * y) * w + (w = z0 * x - x0$4 * z) * w + (w = x0$4 * y - y0$4 * x) * w), x0$4 * x + y0$4 * y + z0 * z); + W1 += w; + X1$1 += w * (x0$4 + (x0$4 = x)); + Y1$1 += w * (y0$4 + (y0$4 = y)); + Z1$1 += w * (z0 + (z0 = z)); + centroidPointCartesian(x0$4, y0$4, z0); +} + +function centroidLineEnd$1() { + centroidStream$1.point = centroidPoint$1; +} + +// See J. E. Brock, The Inertia Tensor for a Spherical Triangle, +// J. Applied Mechanics 42, 239 (1975). +function centroidRingStart$1() { + centroidStream$1.point = centroidRingPointFirst; +} + +function centroidRingEnd$1() { + centroidRingPoint(lambda00, phi00); + centroidStream$1.point = centroidPoint$1; +} + +function centroidRingPointFirst(lambda, phi) { + lambda00 = lambda, phi00 = phi; + lambda *= radians, phi *= radians; + centroidStream$1.point = centroidRingPoint; + var cosPhi = cos$1(phi); + x0$4 = cosPhi * cos$1(lambda); + y0$4 = cosPhi * sin$1(lambda); + z0 = sin$1(phi); + centroidPointCartesian(x0$4, y0$4, z0); +} + +function centroidRingPoint(lambda, phi) { + lambda *= radians, phi *= radians; + var cosPhi = cos$1(phi), + x = cosPhi * cos$1(lambda), + y = cosPhi * sin$1(lambda), + z = sin$1(phi), + cx = y0$4 * z - z0 * y, + cy = z0 * x - x0$4 * z, + cz = x0$4 * y - y0$4 * x, + m = hypot(cx, cy, cz), + w = asin$1(m), // line weight = angle + v = m && -w / m; // area weight multiplier + X2$1.add(v * cx); + Y2$1.add(v * cy); + Z2$1.add(v * cz); + W1 += w; + X1$1 += w * (x0$4 + (x0$4 = x)); + Y1$1 += w * (y0$4 + (y0$4 = y)); + Z1$1 += w * (z0 + (z0 = z)); + centroidPointCartesian(x0$4, y0$4, z0); +} + +function centroid$1(object) { + W0 = W1 = + X0$1 = Y0$1 = Z0$1 = + X1$1 = Y1$1 = Z1$1 = 0; + X2$1 = new Adder(); + Y2$1 = new Adder(); + Z2$1 = new Adder(); + geoStream(object, centroidStream$1); + + var x = +X2$1, + y = +Y2$1, + z = +Z2$1, + m = hypot(x, y, z); + + // If the area-weighted ccentroid is undefined, fall back to length-weighted ccentroid. + if (m < epsilon2) { + x = X1$1, y = Y1$1, z = Z1$1; + // If the feature has zero length, fall back to arithmetic mean of point vectors. + if (W1 < epsilon$1) x = X0$1, y = Y0$1, z = Z0$1; + m = hypot(x, y, z); + // If the feature still has an undefined ccentroid, then return. + if (m < epsilon2) return [NaN, NaN]; + } + + return [atan2$1(y, x) * degrees, asin$1(z / m) * degrees]; +} + +function constant$3(x) { + return function() { + return x; + }; +} + +function compose(a, b) { + + function compose(x, y) { + return x = a(x, y), b(x[0], x[1]); + } + + if (a.invert && b.invert) compose.invert = function(x, y) { + return x = b.invert(x, y), x && a.invert(x[0], x[1]); + }; + + return compose; +} + +function rotationIdentity(lambda, phi) { + return [abs$1(lambda) > pi$1 ? lambda + Math.round(-lambda / tau$1) * tau$1 : lambda, phi]; +} + +rotationIdentity.invert = rotationIdentity; + +function rotateRadians(deltaLambda, deltaPhi, deltaGamma) { + return (deltaLambda %= tau$1) ? (deltaPhi || deltaGamma ? compose(rotationLambda(deltaLambda), rotationPhiGamma(deltaPhi, deltaGamma)) + : rotationLambda(deltaLambda)) + : (deltaPhi || deltaGamma ? rotationPhiGamma(deltaPhi, deltaGamma) + : rotationIdentity); +} + +function forwardRotationLambda(deltaLambda) { + return function(lambda, phi) { + return lambda += deltaLambda, [lambda > pi$1 ? lambda - tau$1 : lambda < -pi$1 ? lambda + tau$1 : lambda, phi]; + }; +} + +function rotationLambda(deltaLambda) { + var rotation = forwardRotationLambda(deltaLambda); + rotation.invert = forwardRotationLambda(-deltaLambda); + return rotation; +} + +function rotationPhiGamma(deltaPhi, deltaGamma) { + var cosDeltaPhi = cos$1(deltaPhi), + sinDeltaPhi = sin$1(deltaPhi), + cosDeltaGamma = cos$1(deltaGamma), + sinDeltaGamma = sin$1(deltaGamma); + + function rotation(lambda, phi) { + var cosPhi = cos$1(phi), + x = cos$1(lambda) * cosPhi, + y = sin$1(lambda) * cosPhi, + z = sin$1(phi), + k = z * cosDeltaPhi + x * sinDeltaPhi; + return [ + atan2$1(y * cosDeltaGamma - k * sinDeltaGamma, x * cosDeltaPhi - z * sinDeltaPhi), + asin$1(k * cosDeltaGamma + y * sinDeltaGamma) + ]; + } + + rotation.invert = function(lambda, phi) { + var cosPhi = cos$1(phi), + x = cos$1(lambda) * cosPhi, + y = sin$1(lambda) * cosPhi, + z = sin$1(phi), + k = z * cosDeltaGamma - y * sinDeltaGamma; + return [ + atan2$1(y * cosDeltaGamma + z * sinDeltaGamma, x * cosDeltaPhi + k * sinDeltaPhi), + asin$1(k * cosDeltaPhi - x * sinDeltaPhi) + ]; + }; + + return rotation; +} + +function rotation(rotate) { + rotate = rotateRadians(rotate[0] * radians, rotate[1] * radians, rotate.length > 2 ? rotate[2] * radians : 0); + + function forward(coordinates) { + coordinates = rotate(coordinates[0] * radians, coordinates[1] * radians); + return coordinates[0] *= degrees, coordinates[1] *= degrees, coordinates; + } + + forward.invert = function(coordinates) { + coordinates = rotate.invert(coordinates[0] * radians, coordinates[1] * radians); + return coordinates[0] *= degrees, coordinates[1] *= degrees, coordinates; + }; + + return forward; +} + +// Generates a circle centered at [0°, 0°], with a given radius and precision. +function circleStream(stream, radius, delta, direction, t0, t1) { + if (!delta) return; + var cosRadius = cos$1(radius), + sinRadius = sin$1(radius), + step = direction * delta; + if (t0 == null) { + t0 = radius + direction * tau$1; + t1 = radius - step / 2; + } else { + t0 = circleRadius(cosRadius, t0); + t1 = circleRadius(cosRadius, t1); + if (direction > 0 ? t0 < t1 : t0 > t1) t0 += direction * tau$1; + } + for (var point, t = t0; direction > 0 ? t > t1 : t < t1; t -= step) { + point = spherical([cosRadius, -sinRadius * cos$1(t), -sinRadius * sin$1(t)]); + stream.point(point[0], point[1]); + } +} + +// Returns the signed angle of a cartesian point relative to [cosRadius, 0, 0]. +function circleRadius(cosRadius, point) { + point = cartesian(point), point[0] -= cosRadius; + cartesianNormalizeInPlace(point); + var radius = acos$1(-point[1]); + return ((-point[2] < 0 ? -radius : radius) + tau$1 - epsilon$1) % tau$1; +} + +function circle$2() { + var center = constant$3([0, 0]), + radius = constant$3(90), + precision = constant$3(6), + ring, + rotate, + stream = {point: point}; + + function point(x, y) { + ring.push(x = rotate(x, y)); + x[0] *= degrees, x[1] *= degrees; + } + + function circle() { + var c = center.apply(this, arguments), + r = radius.apply(this, arguments) * radians, + p = precision.apply(this, arguments) * radians; + ring = []; + rotate = rotateRadians(-c[0] * radians, -c[1] * radians, 0).invert; + circleStream(stream, r, p, 1); + c = {type: "Polygon", coordinates: [ring]}; + ring = rotate = null; + return c; + } + + circle.center = function(_) { + return arguments.length ? (center = typeof _ === "function" ? _ : constant$3([+_[0], +_[1]]), circle) : center; + }; + + circle.radius = function(_) { + return arguments.length ? (radius = typeof _ === "function" ? _ : constant$3(+_), circle) : radius; + }; + + circle.precision = function(_) { + return arguments.length ? (precision = typeof _ === "function" ? _ : constant$3(+_), circle) : precision; + }; + + return circle; +} + +function clipBuffer() { + var lines = [], + line; + return { + point: function(x, y, m) { + line.push([x, y, m]); + }, + lineStart: function() { + lines.push(line = []); + }, + lineEnd: noop$1, + rejoin: function() { + if (lines.length > 1) lines.push(lines.pop().concat(lines.shift())); + }, + result: function() { + var result = lines; + lines = []; + line = null; + return result; + } + }; +} + +function pointEqual(a, b) { + return abs$1(a[0] - b[0]) < epsilon$1 && abs$1(a[1] - b[1]) < epsilon$1; +} + +function Intersection(point, points, other, entry) { + this.x = point; + this.z = points; + this.o = other; // another intersection + this.e = entry; // is an entry? + this.v = false; // visited + this.n = this.p = null; // next & previous +} + +// A generalized polygon clipping algorithm: given a polygon that has been cut +// into its visible line segments, and rejoins the segments by interpolating +// along the clip edge. +function clipRejoin(segments, compareIntersection, startInside, interpolate, stream) { + var subject = [], + clip = [], + i, + n; + + segments.forEach(function(segment) { + if ((n = segment.length - 1) <= 0) return; + var n, p0 = segment[0], p1 = segment[n], x; + + if (pointEqual(p0, p1)) { + if (!p0[2] && !p1[2]) { + stream.lineStart(); + for (i = 0; i < n; ++i) stream.point((p0 = segment[i])[0], p0[1]); + stream.lineEnd(); + return; + } + // handle degenerate cases by moving the point + p1[0] += 2 * epsilon$1; + } + + subject.push(x = new Intersection(p0, segment, null, true)); + clip.push(x.o = new Intersection(p0, null, x, false)); + subject.push(x = new Intersection(p1, segment, null, false)); + clip.push(x.o = new Intersection(p1, null, x, true)); + }); + + if (!subject.length) return; + + clip.sort(compareIntersection); + link$1(subject); + link$1(clip); + + for (i = 0, n = clip.length; i < n; ++i) { + clip[i].e = startInside = !startInside; + } + + var start = subject[0], + points, + point; + + while (1) { + // Find first unvisited intersection. + var current = start, + isSubject = true; + while (current.v) if ((current = current.n) === start) return; + points = current.z; + stream.lineStart(); + do { + current.v = current.o.v = true; + if (current.e) { + if (isSubject) { + for (i = 0, n = points.length; i < n; ++i) stream.point((point = points[i])[0], point[1]); + } else { + interpolate(current.x, current.n.x, 1, stream); + } + current = current.n; + } else { + if (isSubject) { + points = current.p.z; + for (i = points.length - 1; i >= 0; --i) stream.point((point = points[i])[0], point[1]); + } else { + interpolate(current.x, current.p.x, -1, stream); + } + current = current.p; + } + current = current.o; + points = current.z; + isSubject = !isSubject; + } while (!current.v); + stream.lineEnd(); + } +} + +function link$1(array) { + if (!(n = array.length)) return; + var n, + i = 0, + a = array[0], + b; + while (++i < n) { + a.n = b = array[i]; + b.p = a; + a = b; + } + a.n = b = array[0]; + b.p = a; +} + +function longitude(point) { + return abs$1(point[0]) <= pi$1 ? point[0] : sign$1(point[0]) * ((abs$1(point[0]) + pi$1) % tau$1 - pi$1); +} + +function polygonContains(polygon, point) { + var lambda = longitude(point), + phi = point[1], + sinPhi = sin$1(phi), + normal = [sin$1(lambda), -cos$1(lambda), 0], + angle = 0, + winding = 0; + + var sum = new Adder(); + + if (sinPhi === 1) phi = halfPi$1 + epsilon$1; + else if (sinPhi === -1) phi = -halfPi$1 - epsilon$1; + + for (var i = 0, n = polygon.length; i < n; ++i) { + if (!(m = (ring = polygon[i]).length)) continue; + var ring, + m, + point0 = ring[m - 1], + lambda0 = longitude(point0), + phi0 = point0[1] / 2 + quarterPi, + sinPhi0 = sin$1(phi0), + cosPhi0 = cos$1(phi0); + + for (var j = 0; j < m; ++j, lambda0 = lambda1, sinPhi0 = sinPhi1, cosPhi0 = cosPhi1, point0 = point1) { + var point1 = ring[j], + lambda1 = longitude(point1), + phi1 = point1[1] / 2 + quarterPi, + sinPhi1 = sin$1(phi1), + cosPhi1 = cos$1(phi1), + delta = lambda1 - lambda0, + sign = delta >= 0 ? 1 : -1, + absDelta = sign * delta, + antimeridian = absDelta > pi$1, + k = sinPhi0 * sinPhi1; + + sum.add(atan2$1(k * sign * sin$1(absDelta), cosPhi0 * cosPhi1 + k * cos$1(absDelta))); + angle += antimeridian ? delta + sign * tau$1 : delta; + + // Are the longitudes either side of the point’s meridian (lambda), + // and are the latitudes smaller than the parallel (phi)? + if (antimeridian ^ lambda0 >= lambda ^ lambda1 >= lambda) { + var arc = cartesianCross(cartesian(point0), cartesian(point1)); + cartesianNormalizeInPlace(arc); + var intersection = cartesianCross(normal, arc); + cartesianNormalizeInPlace(intersection); + var phiArc = (antimeridian ^ delta >= 0 ? -1 : 1) * asin$1(intersection[2]); + if (phi > phiArc || phi === phiArc && (arc[0] || arc[1])) { + winding += antimeridian ^ delta >= 0 ? 1 : -1; + } + } + } + } + + // First, determine whether the South pole is inside or outside: + // + // It is inside if: + // * the polygon winds around it in a clockwise direction. + // * the polygon does not (cumulatively) wind around it, but has a negative + // (counter-clockwise) area. + // + // Second, count the (signed) number of times a segment crosses a lambda + // from the point to the South pole. If it is zero, then the point is the + // same side as the South pole. + + return (angle < -epsilon$1 || angle < epsilon$1 && sum < -epsilon2) ^ (winding & 1); +} + +function clip(pointVisible, clipLine, interpolate, start) { + return function(sink) { + var line = clipLine(sink), + ringBuffer = clipBuffer(), + ringSink = clipLine(ringBuffer), + polygonStarted = false, + polygon, + segments, + ring; + + var clip = { + point: point, + lineStart: lineStart, + lineEnd: lineEnd, + polygonStart: function() { + clip.point = pointRing; + clip.lineStart = ringStart; + clip.lineEnd = ringEnd; + segments = []; + polygon = []; + }, + polygonEnd: function() { + clip.point = point; + clip.lineStart = lineStart; + clip.lineEnd = lineEnd; + segments = merge(segments); + var startInside = polygonContains(polygon, start); + if (segments.length) { + if (!polygonStarted) sink.polygonStart(), polygonStarted = true; + clipRejoin(segments, compareIntersection, startInside, interpolate, sink); + } else if (startInside) { + if (!polygonStarted) sink.polygonStart(), polygonStarted = true; + sink.lineStart(); + interpolate(null, null, 1, sink); + sink.lineEnd(); + } + if (polygonStarted) sink.polygonEnd(), polygonStarted = false; + segments = polygon = null; + }, + sphere: function() { + sink.polygonStart(); + sink.lineStart(); + interpolate(null, null, 1, sink); + sink.lineEnd(); + sink.polygonEnd(); + } + }; + + function point(lambda, phi) { + if (pointVisible(lambda, phi)) sink.point(lambda, phi); + } + + function pointLine(lambda, phi) { + line.point(lambda, phi); + } + + function lineStart() { + clip.point = pointLine; + line.lineStart(); + } + + function lineEnd() { + clip.point = point; + line.lineEnd(); + } + + function pointRing(lambda, phi) { + ring.push([lambda, phi]); + ringSink.point(lambda, phi); + } + + function ringStart() { + ringSink.lineStart(); + ring = []; + } + + function ringEnd() { + pointRing(ring[0][0], ring[0][1]); + ringSink.lineEnd(); + + var clean = ringSink.clean(), + ringSegments = ringBuffer.result(), + i, n = ringSegments.length, m, + segment, + point; + + ring.pop(); + polygon.push(ring); + ring = null; + + if (!n) return; + + // No intersections. + if (clean & 1) { + segment = ringSegments[0]; + if ((m = segment.length - 1) > 0) { + if (!polygonStarted) sink.polygonStart(), polygonStarted = true; + sink.lineStart(); + for (i = 0; i < m; ++i) sink.point((point = segment[i])[0], point[1]); + sink.lineEnd(); + } + return; + } + + // Rejoin connected segments. + // TODO reuse ringBuffer.rejoin()? + if (n > 1 && clean & 2) ringSegments.push(ringSegments.pop().concat(ringSegments.shift())); + + segments.push(ringSegments.filter(validSegment)); + } + + return clip; + }; +} + +function validSegment(segment) { + return segment.length > 1; +} + +// Intersections are sorted along the clip edge. For both antimeridian cutting +// and circle clipping, the same comparison is used. +function compareIntersection(a, b) { + return ((a = a.x)[0] < 0 ? a[1] - halfPi$1 - epsilon$1 : halfPi$1 - a[1]) + - ((b = b.x)[0] < 0 ? b[1] - halfPi$1 - epsilon$1 : halfPi$1 - b[1]); +} + +var clipAntimeridian = clip( + function() { return true; }, + clipAntimeridianLine, + clipAntimeridianInterpolate, + [-pi$1, -halfPi$1] +); + +// Takes a line and cuts into visible segments. Return values: 0 - there were +// intersections or the line was empty; 1 - no intersections; 2 - there were +// intersections, and the first and last segments should be rejoined. +function clipAntimeridianLine(stream) { + var lambda0 = NaN, + phi0 = NaN, + sign0 = NaN, + clean; // no intersections + + return { + lineStart: function() { + stream.lineStart(); + clean = 1; + }, + point: function(lambda1, phi1) { + var sign1 = lambda1 > 0 ? pi$1 : -pi$1, + delta = abs$1(lambda1 - lambda0); + if (abs$1(delta - pi$1) < epsilon$1) { // line crosses a pole + stream.point(lambda0, phi0 = (phi0 + phi1) / 2 > 0 ? halfPi$1 : -halfPi$1); + stream.point(sign0, phi0); + stream.lineEnd(); + stream.lineStart(); + stream.point(sign1, phi0); + stream.point(lambda1, phi0); + clean = 0; + } else if (sign0 !== sign1 && delta >= pi$1) { // line crosses antimeridian + if (abs$1(lambda0 - sign0) < epsilon$1) lambda0 -= sign0 * epsilon$1; // handle degeneracies + if (abs$1(lambda1 - sign1) < epsilon$1) lambda1 -= sign1 * epsilon$1; + phi0 = clipAntimeridianIntersect(lambda0, phi0, lambda1, phi1); + stream.point(sign0, phi0); + stream.lineEnd(); + stream.lineStart(); + stream.point(sign1, phi0); + clean = 0; + } + stream.point(lambda0 = lambda1, phi0 = phi1); + sign0 = sign1; + }, + lineEnd: function() { + stream.lineEnd(); + lambda0 = phi0 = NaN; + }, + clean: function() { + return 2 - clean; // if intersections, rejoin first and last segments + } + }; +} + +function clipAntimeridianIntersect(lambda0, phi0, lambda1, phi1) { + var cosPhi0, + cosPhi1, + sinLambda0Lambda1 = sin$1(lambda0 - lambda1); + return abs$1(sinLambda0Lambda1) > epsilon$1 + ? atan((sin$1(phi0) * (cosPhi1 = cos$1(phi1)) * sin$1(lambda1) + - sin$1(phi1) * (cosPhi0 = cos$1(phi0)) * sin$1(lambda0)) + / (cosPhi0 * cosPhi1 * sinLambda0Lambda1)) + : (phi0 + phi1) / 2; +} + +function clipAntimeridianInterpolate(from, to, direction, stream) { + var phi; + if (from == null) { + phi = direction * halfPi$1; + stream.point(-pi$1, phi); + stream.point(0, phi); + stream.point(pi$1, phi); + stream.point(pi$1, 0); + stream.point(pi$1, -phi); + stream.point(0, -phi); + stream.point(-pi$1, -phi); + stream.point(-pi$1, 0); + stream.point(-pi$1, phi); + } else if (abs$1(from[0] - to[0]) > epsilon$1) { + var lambda = from[0] < to[0] ? pi$1 : -pi$1; + phi = direction * lambda / 2; + stream.point(-lambda, phi); + stream.point(0, phi); + stream.point(lambda, phi); + } else { + stream.point(to[0], to[1]); + } +} + +function clipCircle(radius) { + var cr = cos$1(radius), + delta = 6 * radians, + smallRadius = cr > 0, + notHemisphere = abs$1(cr) > epsilon$1; // TODO optimise for this common case + + function interpolate(from, to, direction, stream) { + circleStream(stream, radius, delta, direction, from, to); + } + + function visible(lambda, phi) { + return cos$1(lambda) * cos$1(phi) > cr; + } + + // Takes a line and cuts into visible segments. Return values used for polygon + // clipping: 0 - there were intersections or the line was empty; 1 - no + // intersections 2 - there were intersections, and the first and last segments + // should be rejoined. + function clipLine(stream) { + var point0, // previous point + c0, // code for previous point + v0, // visibility of previous point + v00, // visibility of first point + clean; // no intersections + return { + lineStart: function() { + v00 = v0 = false; + clean = 1; + }, + point: function(lambda, phi) { + var point1 = [lambda, phi], + point2, + v = visible(lambda, phi), + c = smallRadius + ? v ? 0 : code(lambda, phi) + : v ? code(lambda + (lambda < 0 ? pi$1 : -pi$1), phi) : 0; + if (!point0 && (v00 = v0 = v)) stream.lineStart(); + if (v !== v0) { + point2 = intersect(point0, point1); + if (!point2 || pointEqual(point0, point2) || pointEqual(point1, point2)) + point1[2] = 1; + } + if (v !== v0) { + clean = 0; + if (v) { + // outside going in + stream.lineStart(); + point2 = intersect(point1, point0); + stream.point(point2[0], point2[1]); + } else { + // inside going out + point2 = intersect(point0, point1); + stream.point(point2[0], point2[1], 2); + stream.lineEnd(); + } + point0 = point2; + } else if (notHemisphere && point0 && smallRadius ^ v) { + var t; + // If the codes for two points are different, or are both zero, + // and there this segment intersects with the small circle. + if (!(c & c0) && (t = intersect(point1, point0, true))) { + clean = 0; + if (smallRadius) { + stream.lineStart(); + stream.point(t[0][0], t[0][1]); + stream.point(t[1][0], t[1][1]); + stream.lineEnd(); + } else { + stream.point(t[1][0], t[1][1]); + stream.lineEnd(); + stream.lineStart(); + stream.point(t[0][0], t[0][1], 3); + } + } + } + if (v && (!point0 || !pointEqual(point0, point1))) { + stream.point(point1[0], point1[1]); + } + point0 = point1, v0 = v, c0 = c; + }, + lineEnd: function() { + if (v0) stream.lineEnd(); + point0 = null; + }, + // Rejoin first and last segments if there were intersections and the first + // and last points were visible. + clean: function() { + return clean | ((v00 && v0) << 1); + } + }; + } + + // Intersects the great circle between a and b with the clip circle. + function intersect(a, b, two) { + var pa = cartesian(a), + pb = cartesian(b); + + // We have two planes, n1.p = d1 and n2.p = d2. + // Find intersection line p(t) = c1 n1 + c2 n2 + t (n1 ⨯ n2). + var n1 = [1, 0, 0], // normal + n2 = cartesianCross(pa, pb), + n2n2 = cartesianDot(n2, n2), + n1n2 = n2[0], // cartesianDot(n1, n2), + determinant = n2n2 - n1n2 * n1n2; + + // Two polar points. + if (!determinant) return !two && a; + + var c1 = cr * n2n2 / determinant, + c2 = -cr * n1n2 / determinant, + n1xn2 = cartesianCross(n1, n2), + A = cartesianScale(n1, c1), + B = cartesianScale(n2, c2); + cartesianAddInPlace(A, B); + + // Solve |p(t)|^2 = 1. + var u = n1xn2, + w = cartesianDot(A, u), + uu = cartesianDot(u, u), + t2 = w * w - uu * (cartesianDot(A, A) - 1); + + if (t2 < 0) return; + + var t = sqrt$2(t2), + q = cartesianScale(u, (-w - t) / uu); + cartesianAddInPlace(q, A); + q = spherical(q); + + if (!two) return q; + + // Two intersection points. + var lambda0 = a[0], + lambda1 = b[0], + phi0 = a[1], + phi1 = b[1], + z; + + if (lambda1 < lambda0) z = lambda0, lambda0 = lambda1, lambda1 = z; + + var delta = lambda1 - lambda0, + polar = abs$1(delta - pi$1) < epsilon$1, + meridian = polar || delta < epsilon$1; + + if (!polar && phi1 < phi0) z = phi0, phi0 = phi1, phi1 = z; + + // Check that the first point is between a and b. + if (meridian + ? polar + ? phi0 + phi1 > 0 ^ q[1] < (abs$1(q[0] - lambda0) < epsilon$1 ? phi0 : phi1) + : phi0 <= q[1] && q[1] <= phi1 + : delta > pi$1 ^ (lambda0 <= q[0] && q[0] <= lambda1)) { + var q1 = cartesianScale(u, (-w + t) / uu); + cartesianAddInPlace(q1, A); + return [q, spherical(q1)]; + } + } + + // Generates a 4-bit vector representing the location of a point relative to + // the small circle's bounding box. + function code(lambda, phi) { + var r = smallRadius ? radius : pi$1 - radius, + code = 0; + if (lambda < -r) code |= 1; // left + else if (lambda > r) code |= 2; // right + if (phi < -r) code |= 4; // below + else if (phi > r) code |= 8; // above + return code; + } + + return clip(visible, clipLine, interpolate, smallRadius ? [0, -radius] : [-pi$1, radius - pi$1]); +} + +function clipLine(a, b, x0, y0, x1, y1) { + var ax = a[0], + ay = a[1], + bx = b[0], + by = b[1], + t0 = 0, + t1 = 1, + dx = bx - ax, + dy = by - ay, + r; + + r = x0 - ax; + if (!dx && r > 0) return; + r /= dx; + if (dx < 0) { + if (r < t0) return; + if (r < t1) t1 = r; + } else if (dx > 0) { + if (r > t1) return; + if (r > t0) t0 = r; + } + + r = x1 - ax; + if (!dx && r < 0) return; + r /= dx; + if (dx < 0) { + if (r > t1) return; + if (r > t0) t0 = r; + } else if (dx > 0) { + if (r < t0) return; + if (r < t1) t1 = r; + } + + r = y0 - ay; + if (!dy && r > 0) return; + r /= dy; + if (dy < 0) { + if (r < t0) return; + if (r < t1) t1 = r; + } else if (dy > 0) { + if (r > t1) return; + if (r > t0) t0 = r; + } + + r = y1 - ay; + if (!dy && r < 0) return; + r /= dy; + if (dy < 0) { + if (r > t1) return; + if (r > t0) t0 = r; + } else if (dy > 0) { + if (r < t0) return; + if (r < t1) t1 = r; + } + + if (t0 > 0) a[0] = ax + t0 * dx, a[1] = ay + t0 * dy; + if (t1 < 1) b[0] = ax + t1 * dx, b[1] = ay + t1 * dy; + return true; +} + +var clipMax = 1e9, clipMin = -clipMax; + +// TODO Use d3-polygon’s polygonContains here for the ring check? +// TODO Eliminate duplicate buffering in clipBuffer and polygon.push? + +function clipRectangle(x0, y0, x1, y1) { + + function visible(x, y) { + return x0 <= x && x <= x1 && y0 <= y && y <= y1; + } + + function interpolate(from, to, direction, stream) { + var a = 0, a1 = 0; + if (from == null + || (a = corner(from, direction)) !== (a1 = corner(to, direction)) + || comparePoint(from, to) < 0 ^ direction > 0) { + do stream.point(a === 0 || a === 3 ? x0 : x1, a > 1 ? y1 : y0); + while ((a = (a + direction + 4) % 4) !== a1); + } else { + stream.point(to[0], to[1]); + } + } + + function corner(p, direction) { + return abs$1(p[0] - x0) < epsilon$1 ? direction > 0 ? 0 : 3 + : abs$1(p[0] - x1) < epsilon$1 ? direction > 0 ? 2 : 1 + : abs$1(p[1] - y0) < epsilon$1 ? direction > 0 ? 1 : 0 + : direction > 0 ? 3 : 2; // abs(p[1] - y1) < epsilon + } + + function compareIntersection(a, b) { + return comparePoint(a.x, b.x); + } + + function comparePoint(a, b) { + var ca = corner(a, 1), + cb = corner(b, 1); + return ca !== cb ? ca - cb + : ca === 0 ? b[1] - a[1] + : ca === 1 ? a[0] - b[0] + : ca === 2 ? a[1] - b[1] + : b[0] - a[0]; + } + + return function(stream) { + var activeStream = stream, + bufferStream = clipBuffer(), + segments, + polygon, + ring, + x__, y__, v__, // first point + x_, y_, v_, // previous point + first, + clean; + + var clipStream = { + point: point, + lineStart: lineStart, + lineEnd: lineEnd, + polygonStart: polygonStart, + polygonEnd: polygonEnd + }; + + function point(x, y) { + if (visible(x, y)) activeStream.point(x, y); + } + + function polygonInside() { + var winding = 0; + + for (var i = 0, n = polygon.length; i < n; ++i) { + for (var ring = polygon[i], j = 1, m = ring.length, point = ring[0], a0, a1, b0 = point[0], b1 = point[1]; j < m; ++j) { + a0 = b0, a1 = b1, point = ring[j], b0 = point[0], b1 = point[1]; + if (a1 <= y1) { if (b1 > y1 && (b0 - a0) * (y1 - a1) > (b1 - a1) * (x0 - a0)) ++winding; } + else { if (b1 <= y1 && (b0 - a0) * (y1 - a1) < (b1 - a1) * (x0 - a0)) --winding; } + } + } + + return winding; + } + + // Buffer geometry within a polygon and then clip it en masse. + function polygonStart() { + activeStream = bufferStream, segments = [], polygon = [], clean = true; + } + + function polygonEnd() { + var startInside = polygonInside(), + cleanInside = clean && startInside, + visible = (segments = merge(segments)).length; + if (cleanInside || visible) { + stream.polygonStart(); + if (cleanInside) { + stream.lineStart(); + interpolate(null, null, 1, stream); + stream.lineEnd(); + } + if (visible) { + clipRejoin(segments, compareIntersection, startInside, interpolate, stream); + } + stream.polygonEnd(); + } + activeStream = stream, segments = polygon = ring = null; + } + + function lineStart() { + clipStream.point = linePoint; + if (polygon) polygon.push(ring = []); + first = true; + v_ = false; + x_ = y_ = NaN; + } + + // TODO rather than special-case polygons, simply handle them separately. + // Ideally, coincident intersection points should be jittered to avoid + // clipping issues. + function lineEnd() { + if (segments) { + linePoint(x__, y__); + if (v__ && v_) bufferStream.rejoin(); + segments.push(bufferStream.result()); + } + clipStream.point = point; + if (v_) activeStream.lineEnd(); + } + + function linePoint(x, y) { + var v = visible(x, y); + if (polygon) ring.push([x, y]); + if (first) { + x__ = x, y__ = y, v__ = v; + first = false; + if (v) { + activeStream.lineStart(); + activeStream.point(x, y); + } + } else { + if (v && v_) activeStream.point(x, y); + else { + var a = [x_ = Math.max(clipMin, Math.min(clipMax, x_)), y_ = Math.max(clipMin, Math.min(clipMax, y_))], + b = [x = Math.max(clipMin, Math.min(clipMax, x)), y = Math.max(clipMin, Math.min(clipMax, y))]; + if (clipLine(a, b, x0, y0, x1, y1)) { + if (!v_) { + activeStream.lineStart(); + activeStream.point(a[0], a[1]); + } + activeStream.point(b[0], b[1]); + if (!v) activeStream.lineEnd(); + clean = false; + } else if (v) { + activeStream.lineStart(); + activeStream.point(x, y); + clean = false; + } + } + } + x_ = x, y_ = y, v_ = v; + } + + return clipStream; + }; +} + +function extent() { + var x0 = 0, + y0 = 0, + x1 = 960, + y1 = 500, + cache, + cacheStream, + clip; + + return clip = { + stream: function(stream) { + return cache && cacheStream === stream ? cache : cache = clipRectangle(x0, y0, x1, y1)(cacheStream = stream); + }, + extent: function(_) { + return arguments.length ? (x0 = +_[0][0], y0 = +_[0][1], x1 = +_[1][0], y1 = +_[1][1], cache = cacheStream = null, clip) : [[x0, y0], [x1, y1]]; + } + }; +} + +var lengthSum$1, + lambda0, + sinPhi0, + cosPhi0; + +var lengthStream$1 = { + sphere: noop$1, + point: noop$1, + lineStart: lengthLineStart, + lineEnd: noop$1, + polygonStart: noop$1, + polygonEnd: noop$1 +}; + +function lengthLineStart() { + lengthStream$1.point = lengthPointFirst$1; + lengthStream$1.lineEnd = lengthLineEnd; +} + +function lengthLineEnd() { + lengthStream$1.point = lengthStream$1.lineEnd = noop$1; +} + +function lengthPointFirst$1(lambda, phi) { + lambda *= radians, phi *= radians; + lambda0 = lambda, sinPhi0 = sin$1(phi), cosPhi0 = cos$1(phi); + lengthStream$1.point = lengthPoint$1; +} + +function lengthPoint$1(lambda, phi) { + lambda *= radians, phi *= radians; + var sinPhi = sin$1(phi), + cosPhi = cos$1(phi), + delta = abs$1(lambda - lambda0), + cosDelta = cos$1(delta), + sinDelta = sin$1(delta), + x = cosPhi * sinDelta, + y = cosPhi0 * sinPhi - sinPhi0 * cosPhi * cosDelta, + z = sinPhi0 * sinPhi + cosPhi0 * cosPhi * cosDelta; + lengthSum$1.add(atan2$1(sqrt$2(x * x + y * y), z)); + lambda0 = lambda, sinPhi0 = sinPhi, cosPhi0 = cosPhi; +} + +function length$1(object) { + lengthSum$1 = new Adder(); + geoStream(object, lengthStream$1); + return +lengthSum$1; +} + +var coordinates = [null, null], + object = {type: "LineString", coordinates: coordinates}; + +function distance(a, b) { + coordinates[0] = a; + coordinates[1] = b; + return length$1(object); +} + +var containsObjectType = { + Feature: function(object, point) { + return containsGeometry(object.geometry, point); + }, + FeatureCollection: function(object, point) { + var features = object.features, i = -1, n = features.length; + while (++i < n) if (containsGeometry(features[i].geometry, point)) return true; + return false; + } +}; + +var containsGeometryType = { + Sphere: function() { + return true; + }, + Point: function(object, point) { + return containsPoint(object.coordinates, point); + }, + MultiPoint: function(object, point) { + var coordinates = object.coordinates, i = -1, n = coordinates.length; + while (++i < n) if (containsPoint(coordinates[i], point)) return true; + return false; + }, + LineString: function(object, point) { + return containsLine(object.coordinates, point); + }, + MultiLineString: function(object, point) { + var coordinates = object.coordinates, i = -1, n = coordinates.length; + while (++i < n) if (containsLine(coordinates[i], point)) return true; + return false; + }, + Polygon: function(object, point) { + return containsPolygon(object.coordinates, point); + }, + MultiPolygon: function(object, point) { + var coordinates = object.coordinates, i = -1, n = coordinates.length; + while (++i < n) if (containsPolygon(coordinates[i], point)) return true; + return false; + }, + GeometryCollection: function(object, point) { + var geometries = object.geometries, i = -1, n = geometries.length; + while (++i < n) if (containsGeometry(geometries[i], point)) return true; + return false; + } +}; + +function containsGeometry(geometry, point) { + return geometry && containsGeometryType.hasOwnProperty(geometry.type) + ? containsGeometryType[geometry.type](geometry, point) + : false; +} + +function containsPoint(coordinates, point) { + return distance(coordinates, point) === 0; +} + +function containsLine(coordinates, point) { + var ao, bo, ab; + for (var i = 0, n = coordinates.length; i < n; i++) { + bo = distance(coordinates[i], point); + if (bo === 0) return true; + if (i > 0) { + ab = distance(coordinates[i], coordinates[i - 1]); + if ( + ab > 0 && + ao <= ab && + bo <= ab && + (ao + bo - ab) * (1 - Math.pow((ao - bo) / ab, 2)) < epsilon2 * ab + ) + return true; + } + ao = bo; + } + return false; +} + +function containsPolygon(coordinates, point) { + return !!polygonContains(coordinates.map(ringRadians), pointRadians(point)); +} + +function ringRadians(ring) { + return ring = ring.map(pointRadians), ring.pop(), ring; +} + +function pointRadians(point) { + return [point[0] * radians, point[1] * radians]; +} + +function contains$1(object, point) { + return (object && containsObjectType.hasOwnProperty(object.type) + ? containsObjectType[object.type] + : containsGeometry)(object, point); +} + +function graticuleX(y0, y1, dy) { + var y = range$2(y0, y1 - epsilon$1, dy).concat(y1); + return function(x) { return y.map(function(y) { return [x, y]; }); }; +} + +function graticuleY(x0, x1, dx) { + var x = range$2(x0, x1 - epsilon$1, dx).concat(x1); + return function(y) { return x.map(function(x) { return [x, y]; }); }; +} + +function graticule() { + var x1, x0, X1, X0, + y1, y0, Y1, Y0, + dx = 10, dy = dx, DX = 90, DY = 360, + x, y, X, Y, + precision = 2.5; + + function graticule() { + return {type: "MultiLineString", coordinates: lines()}; + } + + function lines() { + return range$2(ceil(X0 / DX) * DX, X1, DX).map(X) + .concat(range$2(ceil(Y0 / DY) * DY, Y1, DY).map(Y)) + .concat(range$2(ceil(x0 / dx) * dx, x1, dx).filter(function(x) { return abs$1(x % DX) > epsilon$1; }).map(x)) + .concat(range$2(ceil(y0 / dy) * dy, y1, dy).filter(function(y) { return abs$1(y % DY) > epsilon$1; }).map(y)); + } + + graticule.lines = function() { + return lines().map(function(coordinates) { return {type: "LineString", coordinates: coordinates}; }); + }; + + graticule.outline = function() { + return { + type: "Polygon", + coordinates: [ + X(X0).concat( + Y(Y1).slice(1), + X(X1).reverse().slice(1), + Y(Y0).reverse().slice(1)) + ] + }; + }; + + graticule.extent = function(_) { + if (!arguments.length) return graticule.extentMinor(); + return graticule.extentMajor(_).extentMinor(_); + }; + + graticule.extentMajor = function(_) { + if (!arguments.length) return [[X0, Y0], [X1, Y1]]; + X0 = +_[0][0], X1 = +_[1][0]; + Y0 = +_[0][1], Y1 = +_[1][1]; + if (X0 > X1) _ = X0, X0 = X1, X1 = _; + if (Y0 > Y1) _ = Y0, Y0 = Y1, Y1 = _; + return graticule.precision(precision); + }; + + graticule.extentMinor = function(_) { + if (!arguments.length) return [[x0, y0], [x1, y1]]; + x0 = +_[0][0], x1 = +_[1][0]; + y0 = +_[0][1], y1 = +_[1][1]; + if (x0 > x1) _ = x0, x0 = x1, x1 = _; + if (y0 > y1) _ = y0, y0 = y1, y1 = _; + return graticule.precision(precision); + }; + + graticule.step = function(_) { + if (!arguments.length) return graticule.stepMinor(); + return graticule.stepMajor(_).stepMinor(_); + }; + + graticule.stepMajor = function(_) { + if (!arguments.length) return [DX, DY]; + DX = +_[0], DY = +_[1]; + return graticule; + }; + + graticule.stepMinor = function(_) { + if (!arguments.length) return [dx, dy]; + dx = +_[0], dy = +_[1]; + return graticule; + }; + + graticule.precision = function(_) { + if (!arguments.length) return precision; + precision = +_; + x = graticuleX(y0, y1, 90); + y = graticuleY(x0, x1, precision); + X = graticuleX(Y0, Y1, 90); + Y = graticuleY(X0, X1, precision); + return graticule; + }; + + return graticule + .extentMajor([[-180, -90 + epsilon$1], [180, 90 - epsilon$1]]) + .extentMinor([[-180, -80 - epsilon$1], [180, 80 + epsilon$1]]); +} + +function graticule10() { + return graticule()(); +} + +function interpolate(a, b) { + var x0 = a[0] * radians, + y0 = a[1] * radians, + x1 = b[0] * radians, + y1 = b[1] * radians, + cy0 = cos$1(y0), + sy0 = sin$1(y0), + cy1 = cos$1(y1), + sy1 = sin$1(y1), + kx0 = cy0 * cos$1(x0), + ky0 = cy0 * sin$1(x0), + kx1 = cy1 * cos$1(x1), + ky1 = cy1 * sin$1(x1), + d = 2 * asin$1(sqrt$2(haversin(y1 - y0) + cy0 * cy1 * haversin(x1 - x0))), + k = sin$1(d); + + var interpolate = d ? function(t) { + var B = sin$1(t *= d) / k, + A = sin$1(d - t) / k, + x = A * kx0 + B * kx1, + y = A * ky0 + B * ky1, + z = A * sy0 + B * sy1; + return [ + atan2$1(y, x) * degrees, + atan2$1(z, sqrt$2(x * x + y * y)) * degrees + ]; + } : function() { + return [x0 * degrees, y0 * degrees]; + }; + + interpolate.distance = d; + + return interpolate; +} + +var identity$5 = x => x; + +var areaSum = new Adder(), + areaRingSum = new Adder(), + x00$2, + y00$2, + x0$3, + y0$3; + +var areaStream = { + point: noop$1, + lineStart: noop$1, + lineEnd: noop$1, + polygonStart: function() { + areaStream.lineStart = areaRingStart; + areaStream.lineEnd = areaRingEnd; + }, + polygonEnd: function() { + areaStream.lineStart = areaStream.lineEnd = areaStream.point = noop$1; + areaSum.add(abs$1(areaRingSum)); + areaRingSum = new Adder(); + }, + result: function() { + var area = areaSum / 2; + areaSum = new Adder(); + return area; + } +}; + +function areaRingStart() { + areaStream.point = areaPointFirst; +} + +function areaPointFirst(x, y) { + areaStream.point = areaPoint; + x00$2 = x0$3 = x, y00$2 = y0$3 = y; +} + +function areaPoint(x, y) { + areaRingSum.add(y0$3 * x - x0$3 * y); + x0$3 = x, y0$3 = y; +} + +function areaRingEnd() { + areaPoint(x00$2, y00$2); +} + +var pathArea = areaStream; + +var x0$2 = Infinity, + y0$2 = x0$2, + x1 = -x0$2, + y1 = x1; + +var boundsStream = { + point: boundsPoint, + lineStart: noop$1, + lineEnd: noop$1, + polygonStart: noop$1, + polygonEnd: noop$1, + result: function() { + var bounds = [[x0$2, y0$2], [x1, y1]]; + x1 = y1 = -(y0$2 = x0$2 = Infinity); + return bounds; + } +}; + +function boundsPoint(x, y) { + if (x < x0$2) x0$2 = x; + if (x > x1) x1 = x; + if (y < y0$2) y0$2 = y; + if (y > y1) y1 = y; +} + +var boundsStream$1 = boundsStream; + +// TODO Enforce positive area for exterior, negative area for interior? + +var X0 = 0, + Y0 = 0, + Z0 = 0, + X1 = 0, + Y1 = 0, + Z1 = 0, + X2 = 0, + Y2 = 0, + Z2 = 0, + x00$1, + y00$1, + x0$1, + y0$1; + +var centroidStream = { + point: centroidPoint, + lineStart: centroidLineStart, + lineEnd: centroidLineEnd, + polygonStart: function() { + centroidStream.lineStart = centroidRingStart; + centroidStream.lineEnd = centroidRingEnd; + }, + polygonEnd: function() { + centroidStream.point = centroidPoint; + centroidStream.lineStart = centroidLineStart; + centroidStream.lineEnd = centroidLineEnd; + }, + result: function() { + var centroid = Z2 ? [X2 / Z2, Y2 / Z2] + : Z1 ? [X1 / Z1, Y1 / Z1] + : Z0 ? [X0 / Z0, Y0 / Z0] + : [NaN, NaN]; + X0 = Y0 = Z0 = + X1 = Y1 = Z1 = + X2 = Y2 = Z2 = 0; + return centroid; + } +}; + +function centroidPoint(x, y) { + X0 += x; + Y0 += y; + ++Z0; +} + +function centroidLineStart() { + centroidStream.point = centroidPointFirstLine; +} + +function centroidPointFirstLine(x, y) { + centroidStream.point = centroidPointLine; + centroidPoint(x0$1 = x, y0$1 = y); +} + +function centroidPointLine(x, y) { + var dx = x - x0$1, dy = y - y0$1, z = sqrt$2(dx * dx + dy * dy); + X1 += z * (x0$1 + x) / 2; + Y1 += z * (y0$1 + y) / 2; + Z1 += z; + centroidPoint(x0$1 = x, y0$1 = y); +} + +function centroidLineEnd() { + centroidStream.point = centroidPoint; +} + +function centroidRingStart() { + centroidStream.point = centroidPointFirstRing; +} + +function centroidRingEnd() { + centroidPointRing(x00$1, y00$1); +} + +function centroidPointFirstRing(x, y) { + centroidStream.point = centroidPointRing; + centroidPoint(x00$1 = x0$1 = x, y00$1 = y0$1 = y); +} + +function centroidPointRing(x, y) { + var dx = x - x0$1, + dy = y - y0$1, + z = sqrt$2(dx * dx + dy * dy); + + X1 += z * (x0$1 + x) / 2; + Y1 += z * (y0$1 + y) / 2; + Z1 += z; + + z = y0$1 * x - x0$1 * y; + X2 += z * (x0$1 + x); + Y2 += z * (y0$1 + y); + Z2 += z * 3; + centroidPoint(x0$1 = x, y0$1 = y); +} + +var pathCentroid = centroidStream; + +function PathContext(context) { + this._context = context; +} + +PathContext.prototype = { + _radius: 4.5, + pointRadius: function(_) { + return this._radius = _, this; + }, + polygonStart: function() { + this._line = 0; + }, + polygonEnd: function() { + this._line = NaN; + }, + lineStart: function() { + this._point = 0; + }, + lineEnd: function() { + if (this._line === 0) this._context.closePath(); + this._point = NaN; + }, + point: function(x, y) { + switch (this._point) { + case 0: { + this._context.moveTo(x, y); + this._point = 1; + break; + } + case 1: { + this._context.lineTo(x, y); + break; + } + default: { + this._context.moveTo(x + this._radius, y); + this._context.arc(x, y, this._radius, 0, tau$1); + break; + } + } + }, + result: noop$1 +}; + +var lengthSum = new Adder(), + lengthRing, + x00, + y00, + x0, + y0; + +var lengthStream = { + point: noop$1, + lineStart: function() { + lengthStream.point = lengthPointFirst; + }, + lineEnd: function() { + if (lengthRing) lengthPoint(x00, y00); + lengthStream.point = noop$1; + }, + polygonStart: function() { + lengthRing = true; + }, + polygonEnd: function() { + lengthRing = null; + }, + result: function() { + var length = +lengthSum; + lengthSum = new Adder(); + return length; + } +}; + +function lengthPointFirst(x, y) { + lengthStream.point = lengthPoint; + x00 = x0 = x, y00 = y0 = y; +} + +function lengthPoint(x, y) { + x0 -= x, y0 -= y; + lengthSum.add(sqrt$2(x0 * x0 + y0 * y0)); + x0 = x, y0 = y; +} + +var pathMeasure = lengthStream; + +function PathString() { + this._string = []; +} + +PathString.prototype = { + _radius: 4.5, + _circle: circle$1(4.5), + pointRadius: function(_) { + if ((_ = +_) !== this._radius) this._radius = _, this._circle = null; + return this; + }, + polygonStart: function() { + this._line = 0; + }, + polygonEnd: function() { + this._line = NaN; + }, + lineStart: function() { + this._point = 0; + }, + lineEnd: function() { + if (this._line === 0) this._string.push("Z"); + this._point = NaN; + }, + point: function(x, y) { + switch (this._point) { + case 0: { + this._string.push("M", x, ",", y); + this._point = 1; + break; + } + case 1: { + this._string.push("L", x, ",", y); + break; + } + default: { + if (this._circle == null) this._circle = circle$1(this._radius); + this._string.push("M", x, ",", y, this._circle); + break; + } + } + }, + result: function() { + if (this._string.length) { + var result = this._string.join(""); + this._string = []; + return result; + } else { + return null; + } + } +}; + +function circle$1(radius) { + return "m0," + radius + + "a" + radius + "," + radius + " 0 1,1 0," + -2 * radius + + "a" + radius + "," + radius + " 0 1,1 0," + 2 * radius + + "z"; +} + +function index$2(projection, context) { + var pointRadius = 4.5, + projectionStream, + contextStream; + + function path(object) { + if (object) { + if (typeof pointRadius === "function") contextStream.pointRadius(+pointRadius.apply(this, arguments)); + geoStream(object, projectionStream(contextStream)); + } + return contextStream.result(); + } + + path.area = function(object) { + geoStream(object, projectionStream(pathArea)); + return pathArea.result(); + }; + + path.measure = function(object) { + geoStream(object, projectionStream(pathMeasure)); + return pathMeasure.result(); + }; + + path.bounds = function(object) { + geoStream(object, projectionStream(boundsStream$1)); + return boundsStream$1.result(); + }; + + path.centroid = function(object) { + geoStream(object, projectionStream(pathCentroid)); + return pathCentroid.result(); + }; + + path.projection = function(_) { + return arguments.length ? (projectionStream = _ == null ? (projection = null, identity$5) : (projection = _).stream, path) : projection; + }; + + path.context = function(_) { + if (!arguments.length) return context; + contextStream = _ == null ? (context = null, new PathString) : new PathContext(context = _); + if (typeof pointRadius !== "function") contextStream.pointRadius(pointRadius); + return path; + }; + + path.pointRadius = function(_) { + if (!arguments.length) return pointRadius; + pointRadius = typeof _ === "function" ? _ : (contextStream.pointRadius(+_), +_); + return path; + }; + + return path.projection(projection).context(context); +} + +function transform$1(methods) { + return { + stream: transformer$3(methods) + }; +} + +function transformer$3(methods) { + return function(stream) { + var s = new TransformStream; + for (var key in methods) s[key] = methods[key]; + s.stream = stream; + return s; + }; +} + +function TransformStream() {} + +TransformStream.prototype = { + constructor: TransformStream, + point: function(x, y) { this.stream.point(x, y); }, + 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(); } +}; + +function fit(projection, fitBounds, object) { + var clip = projection.clipExtent && projection.clipExtent(); + projection.scale(150).translate([0, 0]); + if (clip != null) projection.clipExtent(null); + geoStream(object, projection.stream(boundsStream$1)); + fitBounds(boundsStream$1.result()); + if (clip != null) projection.clipExtent(clip); + return projection; +} + +function fitExtent(projection, extent, object) { + return fit(projection, function(b) { + var w = extent[1][0] - extent[0][0], + h = extent[1][1] - extent[0][1], + k = Math.min(w / (b[1][0] - b[0][0]), h / (b[1][1] - b[0][1])), + x = +extent[0][0] + (w - k * (b[1][0] + b[0][0])) / 2, + y = +extent[0][1] + (h - k * (b[1][1] + b[0][1])) / 2; + projection.scale(150 * k).translate([x, y]); + }, object); +} + +function fitSize(projection, size, object) { + return fitExtent(projection, [[0, 0], size], object); +} + +function fitWidth(projection, width, object) { + return fit(projection, function(b) { + var w = +width, + k = w / (b[1][0] - b[0][0]), + x = (w - k * (b[1][0] + b[0][0])) / 2, + y = -k * b[0][1]; + projection.scale(150 * k).translate([x, y]); + }, object); +} + +function fitHeight(projection, height, object) { + return fit(projection, function(b) { + var h = +height, + k = h / (b[1][1] - b[0][1]), + x = -k * b[0][0], + y = (h - k * (b[1][1] + b[0][1])) / 2; + projection.scale(150 * k).translate([x, y]); + }, object); +} + +var maxDepth = 16, // maximum depth of subdivision + cosMinDistance = cos$1(30 * radians); // cos(minimum angular distance) + +function resample(project, delta2) { + return +delta2 ? resample$1(project, delta2) : resampleNone(project); +} + +function resampleNone(project) { + return transformer$3({ + point: function(x, y) { + x = project(x, y); + this.stream.point(x[0], x[1]); + } + }); +} + +function resample$1(project, delta2) { + + function resampleLineTo(x0, y0, lambda0, a0, b0, c0, x1, y1, lambda1, a1, b1, c1, depth, stream) { + var dx = x1 - x0, + dy = y1 - y0, + d2 = dx * dx + dy * dy; + if (d2 > 4 * delta2 && depth--) { + var a = a0 + a1, + b = b0 + b1, + c = c0 + c1, + m = sqrt$2(a * a + b * b + c * c), + phi2 = asin$1(c /= m), + lambda2 = abs$1(abs$1(c) - 1) < epsilon$1 || abs$1(lambda0 - lambda1) < epsilon$1 ? (lambda0 + lambda1) / 2 : atan2$1(b, a), + p = project(lambda2, phi2), + x2 = p[0], + y2 = p[1], + dx2 = x2 - x0, + dy2 = y2 - y0, + dz = dy * dx2 - dx * dy2; + if (dz * dz / d2 > delta2 // perpendicular projected distance + || abs$1((dx * dx2 + dy * dy2) / d2 - 0.5) > 0.3 // midpoint close to an end + || a0 * a1 + b0 * b1 + c0 * c1 < cosMinDistance) { // angular distance + resampleLineTo(x0, y0, lambda0, a0, b0, c0, x2, y2, lambda2, a /= m, b /= m, c, depth, stream); + stream.point(x2, y2); + resampleLineTo(x2, y2, lambda2, a, b, c, x1, y1, lambda1, a1, b1, c1, depth, stream); + } + } + } + return function(stream) { + var lambda00, x00, y00, a00, b00, c00, // first point + lambda0, x0, y0, a0, b0, c0; // previous point + + var resampleStream = { + point: point, + lineStart: lineStart, + lineEnd: lineEnd, + polygonStart: function() { stream.polygonStart(); resampleStream.lineStart = ringStart; }, + polygonEnd: function() { stream.polygonEnd(); resampleStream.lineStart = lineStart; } + }; + + function point(x, y) { + x = project(x, y); + stream.point(x[0], x[1]); + } + + function lineStart() { + x0 = NaN; + resampleStream.point = linePoint; + stream.lineStart(); + } + + function linePoint(lambda, phi) { + var c = cartesian([lambda, phi]), p = project(lambda, phi); + resampleLineTo(x0, y0, lambda0, a0, b0, c0, x0 = p[0], y0 = p[1], lambda0 = lambda, a0 = c[0], b0 = c[1], c0 = c[2], maxDepth, stream); + stream.point(x0, y0); + } + + function lineEnd() { + resampleStream.point = point; + stream.lineEnd(); + } + + function ringStart() { + lineStart(); + resampleStream.point = ringPoint; + resampleStream.lineEnd = ringEnd; + } + + function ringPoint(lambda, phi) { + linePoint(lambda00 = lambda, phi), x00 = x0, y00 = y0, a00 = a0, b00 = b0, c00 = c0; + resampleStream.point = linePoint; + } + + function ringEnd() { + resampleLineTo(x0, y0, lambda0, a0, b0, c0, x00, y00, lambda00, a00, b00, c00, maxDepth, stream); + resampleStream.lineEnd = lineEnd; + lineEnd(); + } + + return resampleStream; + }; +} + +var transformRadians = transformer$3({ + point: function(x, y) { + this.stream.point(x * radians, y * radians); + } +}); + +function transformRotate(rotate) { + return transformer$3({ + point: function(x, y) { + var r = rotate(x, y); + return this.stream.point(r[0], r[1]); + } + }); +} + +function scaleTranslate(k, dx, dy, sx, sy) { + function transform(x, y) { + x *= sx; y *= sy; + return [dx + k * x, dy - k * y]; + } + transform.invert = function(x, y) { + return [(x - dx) / k * sx, (dy - y) / k * sy]; + }; + return transform; +} + +function scaleTranslateRotate(k, dx, dy, sx, sy, alpha) { + if (!alpha) return scaleTranslate(k, dx, dy, sx, sy); + var cosAlpha = cos$1(alpha), + sinAlpha = sin$1(alpha), + a = cosAlpha * k, + b = sinAlpha * k, + ai = cosAlpha / k, + bi = sinAlpha / k, + ci = (sinAlpha * dy - cosAlpha * dx) / k, + fi = (sinAlpha * dx + cosAlpha * dy) / k; + function transform(x, y) { + x *= sx; y *= sy; + return [a * x - b * y + dx, dy - b * x - a * y]; + } + transform.invert = function(x, y) { + return [sx * (ai * x - bi * y + ci), sy * (fi - bi * x - ai * y)]; + }; + return transform; +} + +function projection(project) { + return projectionMutator(function() { return project; })(); +} + +function projectionMutator(projectAt) { + var project, + k = 150, // scale + x = 480, y = 250, // translate + lambda = 0, phi = 0, // center + deltaLambda = 0, deltaPhi = 0, deltaGamma = 0, rotate, // pre-rotate + alpha = 0, // post-rotate angle + sx = 1, // reflectX + sy = 1, // reflectX + theta = null, preclip = clipAntimeridian, // pre-clip angle + x0 = null, y0, x1, y1, postclip = identity$5, // post-clip extent + delta2 = 0.5, // precision + projectResample, + projectTransform, + projectRotateTransform, + cache, + cacheStream; + + function projection(point) { + return projectRotateTransform(point[0] * radians, point[1] * radians); + } + + function invert(point) { + point = projectRotateTransform.invert(point[0], point[1]); + return point && [point[0] * degrees, point[1] * degrees]; + } + + projection.stream = function(stream) { + return cache && cacheStream === stream ? cache : cache = transformRadians(transformRotate(rotate)(preclip(projectResample(postclip(cacheStream = stream))))); + }; + + projection.preclip = function(_) { + return arguments.length ? (preclip = _, theta = undefined, reset()) : preclip; + }; + + projection.postclip = function(_) { + return arguments.length ? (postclip = _, x0 = y0 = x1 = y1 = null, reset()) : postclip; + }; + + projection.clipAngle = function(_) { + return arguments.length ? (preclip = +_ ? clipCircle(theta = _ * radians) : (theta = null, clipAntimeridian), reset()) : theta * degrees; + }; + + projection.clipExtent = function(_) { + return arguments.length ? (postclip = _ == null ? (x0 = y0 = x1 = y1 = null, identity$5) : clipRectangle(x0 = +_[0][0], y0 = +_[0][1], x1 = +_[1][0], y1 = +_[1][1]), reset()) : x0 == null ? null : [[x0, y0], [x1, y1]]; + }; + + projection.scale = function(_) { + return arguments.length ? (k = +_, recenter()) : k; + }; + + projection.translate = function(_) { + return arguments.length ? (x = +_[0], y = +_[1], recenter()) : [x, y]; + }; + + projection.center = function(_) { + return arguments.length ? (lambda = _[0] % 360 * radians, phi = _[1] % 360 * radians, recenter()) : [lambda * degrees, phi * degrees]; + }; + + projection.rotate = function(_) { + return arguments.length ? (deltaLambda = _[0] % 360 * radians, deltaPhi = _[1] % 360 * radians, deltaGamma = _.length > 2 ? _[2] % 360 * radians : 0, recenter()) : [deltaLambda * degrees, deltaPhi * degrees, deltaGamma * degrees]; + }; + + projection.angle = function(_) { + return arguments.length ? (alpha = _ % 360 * radians, recenter()) : alpha * degrees; + }; + + projection.reflectX = function(_) { + return arguments.length ? (sx = _ ? -1 : 1, recenter()) : sx < 0; + }; + + projection.reflectY = function(_) { + return arguments.length ? (sy = _ ? -1 : 1, recenter()) : sy < 0; + }; + + projection.precision = function(_) { + return arguments.length ? (projectResample = resample(projectTransform, delta2 = _ * _), reset()) : sqrt$2(delta2); + }; + + projection.fitExtent = function(extent, object) { + return fitExtent(projection, extent, object); + }; + + projection.fitSize = function(size, object) { + return fitSize(projection, size, object); + }; + + projection.fitWidth = function(width, object) { + return fitWidth(projection, width, object); + }; + + projection.fitHeight = function(height, object) { + return fitHeight(projection, height, object); + }; + + function recenter() { + var center = scaleTranslateRotate(k, 0, 0, sx, sy, alpha).apply(null, project(lambda, phi)), + transform = scaleTranslateRotate(k, x - center[0], y - center[1], sx, sy, alpha); + rotate = rotateRadians(deltaLambda, deltaPhi, deltaGamma); + projectTransform = compose(project, transform); + projectRotateTransform = compose(rotate, projectTransform); + projectResample = resample(projectTransform, delta2); + return reset(); + } + + function reset() { + cache = cacheStream = null; + return projection; + } + + return function() { + project = projectAt.apply(this, arguments); + projection.invert = project.invert && invert; + return recenter(); + }; +} + +function conicProjection(projectAt) { + var phi0 = 0, + phi1 = pi$1 / 3, + m = projectionMutator(projectAt), + p = m(phi0, phi1); + + p.parallels = function(_) { + return arguments.length ? m(phi0 = _[0] * radians, phi1 = _[1] * radians) : [phi0 * degrees, phi1 * degrees]; + }; + + return p; +} + +function cylindricalEqualAreaRaw(phi0) { + var cosPhi0 = cos$1(phi0); + + function forward(lambda, phi) { + return [lambda * cosPhi0, sin$1(phi) / cosPhi0]; + } + + forward.invert = function(x, y) { + return [x / cosPhi0, asin$1(y * cosPhi0)]; + }; + + return forward; +} + +function conicEqualAreaRaw(y0, y1) { + var sy0 = sin$1(y0), n = (sy0 + sin$1(y1)) / 2; + + // Are the parallels symmetrical around the Equator? + if (abs$1(n) < epsilon$1) return cylindricalEqualAreaRaw(y0); + + var c = 1 + sy0 * (2 * n - sy0), r0 = sqrt$2(c) / n; + + function project(x, y) { + var r = sqrt$2(c - 2 * n * sin$1(y)) / n; + return [r * sin$1(x *= n), r0 - r * cos$1(x)]; + } + + project.invert = function(x, y) { + var r0y = r0 - y, + l = atan2$1(x, abs$1(r0y)) * sign$1(r0y); + if (r0y * n < 0) + l -= pi$1 * sign$1(x) * sign$1(r0y); + return [l / n, asin$1((c - (x * x + r0y * r0y) * n * n) / (2 * n))]; + }; + + return project; +} + +function conicEqualArea() { + return conicProjection(conicEqualAreaRaw) + .scale(155.424) + .center([0, 33.6442]); +} + +function albers() { + return conicEqualArea() + .parallels([29.5, 45.5]) + .scale(1070) + .translate([480, 250]) + .rotate([96, 0]) + .center([-0.6, 38.7]); +} + +// The projections must have mutually exclusive clip regions on the sphere, +// as this will avoid emitting interleaving lines and polygons. +function multiplex(streams) { + var n = streams.length; + return { + point: function(x, y) { var i = -1; while (++i < n) streams[i].point(x, y); }, + sphere: function() { var i = -1; while (++i < n) streams[i].sphere(); }, + lineStart: function() { var i = -1; while (++i < n) streams[i].lineStart(); }, + lineEnd: function() { var i = -1; while (++i < n) streams[i].lineEnd(); }, + polygonStart: function() { var i = -1; while (++i < n) streams[i].polygonStart(); }, + polygonEnd: function() { var i = -1; while (++i < n) streams[i].polygonEnd(); } + }; +} + +// A composite projection for the United States, configured by default for +// 960×500. The projection also works quite well at 960×600 if you change the +// scale to 1285 and adjust the translate accordingly. The set of standard +// parallels for each region comes from USGS, which is published here: +// http://egsc.usgs.gov/isb/pubs/MapProjections/projections.html#albers +function albersUsa() { + var cache, + cacheStream, + lower48 = albers(), lower48Point, + alaska = conicEqualArea().rotate([154, 0]).center([-2, 58.5]).parallels([55, 65]), alaskaPoint, // EPSG:3338 + hawaii = conicEqualArea().rotate([157, 0]).center([-3, 19.9]).parallels([8, 18]), hawaiiPoint, // ESRI:102007 + point, pointStream = {point: function(x, y) { point = [x, y]; }}; + + function albersUsa(coordinates) { + var x = coordinates[0], y = coordinates[1]; + return point = null, + (lower48Point.point(x, y), point) + || (alaskaPoint.point(x, y), point) + || (hawaiiPoint.point(x, y), point); + } + + albersUsa.invert = function(coordinates) { + var k = lower48.scale(), + t = lower48.translate(), + x = (coordinates[0] - t[0]) / k, + y = (coordinates[1] - t[1]) / k; + return (y >= 0.120 && y < 0.234 && x >= -0.425 && x < -0.214 ? alaska + : y >= 0.166 && y < 0.234 && x >= -0.214 && x < -0.115 ? hawaii + : lower48).invert(coordinates); + }; + + albersUsa.stream = function(stream) { + return cache && cacheStream === stream ? cache : cache = multiplex([lower48.stream(cacheStream = stream), alaska.stream(stream), hawaii.stream(stream)]); + }; + + albersUsa.precision = function(_) { + if (!arguments.length) return lower48.precision(); + lower48.precision(_), alaska.precision(_), hawaii.precision(_); + return reset(); + }; + + albersUsa.scale = function(_) { + if (!arguments.length) return lower48.scale(); + lower48.scale(_), alaska.scale(_ * 0.35), hawaii.scale(_); + return albersUsa.translate(lower48.translate()); + }; + + albersUsa.translate = function(_) { + if (!arguments.length) return lower48.translate(); + var k = lower48.scale(), x = +_[0], y = +_[1]; + + lower48Point = lower48 + .translate(_) + .clipExtent([[x - 0.455 * k, y - 0.238 * k], [x + 0.455 * k, y + 0.238 * k]]) + .stream(pointStream); + + alaskaPoint = alaska + .translate([x - 0.307 * k, y + 0.201 * k]) + .clipExtent([[x - 0.425 * k + epsilon$1, y + 0.120 * k + epsilon$1], [x - 0.214 * k - epsilon$1, y + 0.234 * k - epsilon$1]]) + .stream(pointStream); + + hawaiiPoint = hawaii + .translate([x - 0.205 * k, y + 0.212 * k]) + .clipExtent([[x - 0.214 * k + epsilon$1, y + 0.166 * k + epsilon$1], [x - 0.115 * k - epsilon$1, y + 0.234 * k - epsilon$1]]) + .stream(pointStream); + + return reset(); + }; + + albersUsa.fitExtent = function(extent, object) { + return fitExtent(albersUsa, extent, object); + }; + + albersUsa.fitSize = function(size, object) { + return fitSize(albersUsa, size, object); + }; + + albersUsa.fitWidth = function(width, object) { + return fitWidth(albersUsa, width, object); + }; + + albersUsa.fitHeight = function(height, object) { + return fitHeight(albersUsa, height, object); + }; + + function reset() { + cache = cacheStream = null; + return albersUsa; + } + + return albersUsa.scale(1070); +} + +function azimuthalRaw(scale) { + return function(x, y) { + var cx = cos$1(x), + cy = cos$1(y), + k = scale(cx * cy); + if (k === Infinity) return [2, 0]; + return [ + k * cy * sin$1(x), + k * sin$1(y) + ]; + } +} + +function azimuthalInvert(angle) { + return function(x, y) { + var z = sqrt$2(x * x + y * y), + c = angle(z), + sc = sin$1(c), + cc = cos$1(c); + return [ + atan2$1(x * sc, z * cc), + asin$1(z && y * sc / z) + ]; + } +} + +var azimuthalEqualAreaRaw = azimuthalRaw(function(cxcy) { + return sqrt$2(2 / (1 + cxcy)); +}); + +azimuthalEqualAreaRaw.invert = azimuthalInvert(function(z) { + return 2 * asin$1(z / 2); +}); + +function azimuthalEqualArea() { + return projection(azimuthalEqualAreaRaw) + .scale(124.75) + .clipAngle(180 - 1e-3); +} + +var azimuthalEquidistantRaw = azimuthalRaw(function(c) { + return (c = acos$1(c)) && c / sin$1(c); +}); + +azimuthalEquidistantRaw.invert = azimuthalInvert(function(z) { + return z; +}); + +function azimuthalEquidistant() { + return projection(azimuthalEquidistantRaw) + .scale(79.4188) + .clipAngle(180 - 1e-3); +} + +function mercatorRaw(lambda, phi) { + return [lambda, log$1(tan((halfPi$1 + phi) / 2))]; +} + +mercatorRaw.invert = function(x, y) { + return [x, 2 * atan(exp(y)) - halfPi$1]; +}; + +function mercator() { + return mercatorProjection(mercatorRaw) + .scale(961 / tau$1); +} + +function mercatorProjection(project) { + var m = projection(project), + center = m.center, + scale = m.scale, + translate = m.translate, + clipExtent = m.clipExtent, + x0 = null, y0, x1, y1; // clip extent + + m.scale = function(_) { + return arguments.length ? (scale(_), reclip()) : scale(); + }; + + m.translate = function(_) { + return arguments.length ? (translate(_), reclip()) : translate(); + }; + + m.center = function(_) { + return arguments.length ? (center(_), reclip()) : center(); + }; + + m.clipExtent = function(_) { + return arguments.length ? ((_ == null ? x0 = y0 = x1 = y1 = null : (x0 = +_[0][0], y0 = +_[0][1], x1 = +_[1][0], y1 = +_[1][1])), reclip()) : x0 == null ? null : [[x0, y0], [x1, y1]]; + }; + + function reclip() { + var k = pi$1 * scale(), + t = m(rotation(m.rotate()).invert([0, 0])); + return clipExtent(x0 == null + ? [[t[0] - k, t[1] - k], [t[0] + k, t[1] + k]] : project === mercatorRaw + ? [[Math.max(t[0] - k, x0), y0], [Math.min(t[0] + k, x1), y1]] + : [[x0, Math.max(t[1] - k, y0)], [x1, Math.min(t[1] + k, y1)]]); + } + + return reclip(); +} + +function tany(y) { + return tan((halfPi$1 + y) / 2); +} + +function conicConformalRaw(y0, y1) { + var cy0 = cos$1(y0), + n = y0 === y1 ? sin$1(y0) : log$1(cy0 / cos$1(y1)) / log$1(tany(y1) / tany(y0)), + f = cy0 * pow$1(tany(y0), n) / n; + + if (!n) return mercatorRaw; + + function project(x, y) { + if (f > 0) { if (y < -halfPi$1 + epsilon$1) y = -halfPi$1 + epsilon$1; } + else { if (y > halfPi$1 - epsilon$1) y = halfPi$1 - epsilon$1; } + var r = f / pow$1(tany(y), n); + return [r * sin$1(n * x), f - r * cos$1(n * x)]; + } + + project.invert = function(x, y) { + var fy = f - y, r = sign$1(n) * sqrt$2(x * x + fy * fy), + l = atan2$1(x, abs$1(fy)) * sign$1(fy); + if (fy * n < 0) + l -= pi$1 * sign$1(x) * sign$1(fy); + return [l / n, 2 * atan(pow$1(f / r, 1 / n)) - halfPi$1]; + }; + + return project; +} + +function conicConformal() { + return conicProjection(conicConformalRaw) + .scale(109.5) + .parallels([30, 30]); +} + +function equirectangularRaw(lambda, phi) { + return [lambda, phi]; +} + +equirectangularRaw.invert = equirectangularRaw; + +function equirectangular() { + return projection(equirectangularRaw) + .scale(152.63); +} + +function conicEquidistantRaw(y0, y1) { + var cy0 = cos$1(y0), + n = y0 === y1 ? sin$1(y0) : (cy0 - cos$1(y1)) / (y1 - y0), + g = cy0 / n + y0; + + if (abs$1(n) < epsilon$1) return equirectangularRaw; + + function project(x, y) { + var gy = g - y, nx = n * x; + return [gy * sin$1(nx), g - gy * cos$1(nx)]; + } + + project.invert = function(x, y) { + var gy = g - y, + l = atan2$1(x, abs$1(gy)) * sign$1(gy); + if (gy * n < 0) + l -= pi$1 * sign$1(x) * sign$1(gy); + return [l / n, g - sign$1(n) * sqrt$2(x * x + gy * gy)]; + }; + + return project; +} + +function conicEquidistant() { + return conicProjection(conicEquidistantRaw) + .scale(131.154) + .center([0, 13.9389]); +} + +var A1 = 1.340264, + A2 = -0.081106, + A3 = 0.000893, + A4 = 0.003796, + M = sqrt$2(3) / 2, + iterations = 12; + +function equalEarthRaw(lambda, phi) { + var l = asin$1(M * sin$1(phi)), l2 = l * l, l6 = l2 * l2 * l2; + return [ + lambda * cos$1(l) / (M * (A1 + 3 * A2 * l2 + l6 * (7 * A3 + 9 * A4 * l2))), + l * (A1 + A2 * l2 + l6 * (A3 + A4 * l2)) + ]; +} + +equalEarthRaw.invert = function(x, y) { + var l = y, l2 = l * l, l6 = l2 * l2 * l2; + for (var i = 0, delta, fy, fpy; i < iterations; ++i) { + fy = l * (A1 + A2 * l2 + l6 * (A3 + A4 * l2)) - y; + fpy = A1 + 3 * A2 * l2 + l6 * (7 * A3 + 9 * A4 * l2); + l -= delta = fy / fpy, l2 = l * l, l6 = l2 * l2 * l2; + if (abs$1(delta) < epsilon2) break; + } + return [ + M * x * (A1 + 3 * A2 * l2 + l6 * (7 * A3 + 9 * A4 * l2)) / cos$1(l), + asin$1(sin$1(l) / M) + ]; +}; + +function equalEarth() { + return projection(equalEarthRaw) + .scale(177.158); +} + +function gnomonicRaw(x, y) { + var cy = cos$1(y), k = cos$1(x) * cy; + return [cy * sin$1(x) / k, sin$1(y) / k]; +} + +gnomonicRaw.invert = azimuthalInvert(atan); + +function gnomonic() { + return projection(gnomonicRaw) + .scale(144.049) + .clipAngle(60); +} + +function identity$4() { + var k = 1, tx = 0, ty = 0, sx = 1, sy = 1, // scale, translate and reflect + alpha = 0, ca, sa, // angle + x0 = null, y0, x1, y1, // clip extent + kx = 1, ky = 1, + transform = transformer$3({ + point: function(x, y) { + var p = projection([x, y]); + this.stream.point(p[0], p[1]); + } + }), + postclip = identity$5, + cache, + cacheStream; + + function reset() { + kx = k * sx; + ky = k * sy; + cache = cacheStream = null; + return projection; + } + + function projection (p) { + var x = p[0] * kx, y = p[1] * ky; + if (alpha) { + var t = y * ca - x * sa; + x = x * ca + y * sa; + y = t; + } + return [x + tx, y + ty]; + } + projection.invert = function(p) { + var x = p[0] - tx, y = p[1] - ty; + if (alpha) { + var t = y * ca + x * sa; + x = x * ca - y * sa; + y = t; + } + return [x / kx, y / ky]; + }; + projection.stream = function(stream) { + return cache && cacheStream === stream ? cache : cache = transform(postclip(cacheStream = stream)); + }; + projection.postclip = function(_) { + return arguments.length ? (postclip = _, x0 = y0 = x1 = y1 = null, reset()) : postclip; + }; + projection.clipExtent = function(_) { + return arguments.length ? (postclip = _ == null ? (x0 = y0 = x1 = y1 = null, identity$5) : clipRectangle(x0 = +_[0][0], y0 = +_[0][1], x1 = +_[1][0], y1 = +_[1][1]), reset()) : x0 == null ? null : [[x0, y0], [x1, y1]]; + }; + projection.scale = function(_) { + return arguments.length ? (k = +_, reset()) : k; + }; + projection.translate = function(_) { + return arguments.length ? (tx = +_[0], ty = +_[1], reset()) : [tx, ty]; + }; + projection.angle = function(_) { + return arguments.length ? (alpha = _ % 360 * radians, sa = sin$1(alpha), ca = cos$1(alpha), reset()) : alpha * degrees; + }; + projection.reflectX = function(_) { + return arguments.length ? (sx = _ ? -1 : 1, reset()) : sx < 0; + }; + projection.reflectY = function(_) { + return arguments.length ? (sy = _ ? -1 : 1, reset()) : sy < 0; + }; + projection.fitExtent = function(extent, object) { + return fitExtent(projection, extent, object); + }; + projection.fitSize = function(size, object) { + return fitSize(projection, size, object); + }; + projection.fitWidth = function(width, object) { + return fitWidth(projection, width, object); + }; + projection.fitHeight = function(height, object) { + return fitHeight(projection, height, object); + }; + + return projection; +} + +function naturalEarth1Raw(lambda, phi) { + var phi2 = phi * phi, phi4 = phi2 * phi2; + return [ + lambda * (0.8707 - 0.131979 * phi2 + phi4 * (-0.013791 + phi4 * (0.003971 * phi2 - 0.001529 * phi4))), + phi * (1.007226 + phi2 * (0.015085 + phi4 * (-0.044475 + 0.028874 * phi2 - 0.005916 * phi4))) + ]; +} + +naturalEarth1Raw.invert = function(x, y) { + var phi = y, i = 25, delta; + do { + var phi2 = phi * phi, phi4 = phi2 * phi2; + phi -= delta = (phi * (1.007226 + phi2 * (0.015085 + phi4 * (-0.044475 + 0.028874 * phi2 - 0.005916 * phi4))) - y) / + (1.007226 + phi2 * (0.015085 * 3 + phi4 * (-0.044475 * 7 + 0.028874 * 9 * phi2 - 0.005916 * 11 * phi4))); + } while (abs$1(delta) > epsilon$1 && --i > 0); + return [ + x / (0.8707 + (phi2 = phi * phi) * (-0.131979 + phi2 * (-0.013791 + phi2 * phi2 * phi2 * (0.003971 - 0.001529 * phi2)))), + phi + ]; +}; + +function naturalEarth1() { + return projection(naturalEarth1Raw) + .scale(175.295); +} + +function orthographicRaw(x, y) { + return [cos$1(y) * sin$1(x), sin$1(y)]; +} + +orthographicRaw.invert = azimuthalInvert(asin$1); + +function orthographic() { + return projection(orthographicRaw) + .scale(249.5) + .clipAngle(90 + epsilon$1); +} + +function stereographicRaw(x, y) { + var cy = cos$1(y), k = 1 + cos$1(x) * cy; + return [cy * sin$1(x) / k, sin$1(y) / k]; +} + +stereographicRaw.invert = azimuthalInvert(function(z) { + return 2 * atan(z); +}); + +function stereographic() { + return projection(stereographicRaw) + .scale(250) + .clipAngle(142); +} + +function transverseMercatorRaw(lambda, phi) { + return [log$1(tan((halfPi$1 + phi) / 2)), -lambda]; +} + +transverseMercatorRaw.invert = function(x, y) { + return [-y, 2 * atan(exp(x)) - halfPi$1]; +}; + +function transverseMercator() { + var m = mercatorProjection(transverseMercatorRaw), + center = m.center, + rotate = m.rotate; + + m.center = function(_) { + return arguments.length ? center([-_[1], _[0]]) : (_ = center(), [_[1], -_[0]]); + }; + + m.rotate = function(_) { + return arguments.length ? rotate([_[0], _[1], _.length > 2 ? _[2] + 90 : 90]) : (_ = rotate(), [_[0], _[1], _[2] - 90]); + }; + + return rotate([0, 0, 90]) + .scale(159.155); +} + +function defaultSeparation$1(a, b) { + return a.parent === b.parent ? 1 : 2; +} + +function meanX(children) { + return children.reduce(meanXReduce, 0) / children.length; +} + +function meanXReduce(x, c) { + return x + c.x; +} + +function maxY(children) { + return 1 + children.reduce(maxYReduce, 0); +} + +function maxYReduce(y, c) { + return Math.max(y, c.y); +} + +function leafLeft(node) { + var children; + while (children = node.children) node = children[0]; + return node; +} + +function leafRight(node) { + var children; + while (children = node.children) node = children[children.length - 1]; + return node; +} + +function cluster() { + var separation = defaultSeparation$1, + dx = 1, + dy = 1, + nodeSize = false; + + function cluster(root) { + var previousNode, + x = 0; + + // First walk, computing the initial x & y values. + root.eachAfter(function(node) { + var children = node.children; + if (children) { + node.x = meanX(children); + node.y = maxY(children); + } else { + node.x = previousNode ? x += separation(node, previousNode) : 0; + node.y = 0; + previousNode = node; + } + }); + + var left = leafLeft(root), + right = leafRight(root), + x0 = left.x - separation(left, right) / 2, + x1 = right.x + separation(right, left) / 2; + + // Second walk, normalizing x & y to the desired size. + return root.eachAfter(nodeSize ? function(node) { + node.x = (node.x - root.x) * dx; + node.y = (root.y - node.y) * dy; + } : function(node) { + node.x = (node.x - x0) / (x1 - x0) * dx; + node.y = (1 - (root.y ? node.y / root.y : 1)) * dy; + }); + } + + cluster.separation = function(x) { + return arguments.length ? (separation = x, cluster) : separation; + }; + + cluster.size = function(x) { + return arguments.length ? (nodeSize = false, dx = +x[0], dy = +x[1], cluster) : (nodeSize ? null : [dx, dy]); + }; + + cluster.nodeSize = function(x) { + return arguments.length ? (nodeSize = true, dx = +x[0], dy = +x[1], cluster) : (nodeSize ? [dx, dy] : null); + }; + + return cluster; +} + +function count(node) { + var sum = 0, + children = node.children, + i = children && children.length; + if (!i) sum = 1; + else while (--i >= 0) sum += children[i].value; + node.value = sum; +} + +function node_count() { + return this.eachAfter(count); +} + +function node_each(callback, that) { + let index = -1; + for (const node of this) { + callback.call(that, node, ++index, this); + } + return this; +} + +function node_eachBefore(callback, that) { + var node = this, nodes = [node], children, i, index = -1; + while (node = nodes.pop()) { + callback.call(that, node, ++index, this); + if (children = node.children) { + for (i = children.length - 1; i >= 0; --i) { + nodes.push(children[i]); + } + } + } + return this; +} + +function node_eachAfter(callback, that) { + var node = this, nodes = [node], next = [], children, i, n, index = -1; + while (node = nodes.pop()) { + next.push(node); + if (children = node.children) { + for (i = 0, n = children.length; i < n; ++i) { + nodes.push(children[i]); + } + } + } + while (node = next.pop()) { + callback.call(that, node, ++index, this); + } + return this; +} + +function node_find(callback, that) { + let index = -1; + for (const node of this) { + if (callback.call(that, node, ++index, this)) { + return node; + } + } +} + +function node_sum(value) { + return this.eachAfter(function(node) { + var sum = +value(node.data) || 0, + children = node.children, + i = children && children.length; + while (--i >= 0) sum += children[i].value; + node.value = sum; + }); +} + +function node_sort(compare) { + return this.eachBefore(function(node) { + if (node.children) { + node.children.sort(compare); + } + }); +} + +function node_path(end) { + var start = this, + ancestor = leastCommonAncestor(start, end), + nodes = [start]; + while (start !== ancestor) { + start = start.parent; + nodes.push(start); + } + var k = nodes.length; + while (end !== ancestor) { + nodes.splice(k, 0, end); + end = end.parent; + } + return nodes; +} + +function leastCommonAncestor(a, b) { + if (a === b) return a; + var aNodes = a.ancestors(), + bNodes = b.ancestors(), + c = null; + a = aNodes.pop(); + b = bNodes.pop(); + while (a === b) { + c = a; + a = aNodes.pop(); + b = bNodes.pop(); + } + return c; +} + +function node_ancestors() { + var node = this, nodes = [node]; + while (node = node.parent) { + nodes.push(node); + } + return nodes; +} + +function node_descendants() { + return Array.from(this); +} + +function node_leaves() { + var leaves = []; + this.eachBefore(function(node) { + if (!node.children) { + leaves.push(node); + } + }); + return leaves; +} + +function node_links() { + var root = this, links = []; + root.each(function(node) { + if (node !== root) { // Don’t include the root’s parent, if any. + links.push({source: node.parent, target: node}); + } + }); + return links; +} + +function* node_iterator() { + var node = this, current, next = [node], children, i, n; + do { + current = next.reverse(), next = []; + while (node = current.pop()) { + yield node; + if (children = node.children) { + for (i = 0, n = children.length; i < n; ++i) { + next.push(children[i]); + } + } + } + } while (next.length); +} + +function hierarchy(data, children) { + if (data instanceof Map) { + data = [undefined, data]; + if (children === undefined) children = mapChildren; + } else if (children === undefined) { + children = objectChildren; + } + + var root = new Node$1(data), + node, + nodes = [root], + child, + childs, + i, + n; + + while (node = nodes.pop()) { + if ((childs = children(node.data)) && (n = (childs = Array.from(childs)).length)) { + node.children = childs; + for (i = n - 1; i >= 0; --i) { + nodes.push(child = childs[i] = new Node$1(childs[i])); + child.parent = node; + child.depth = node.depth + 1; + } + } + } + + return root.eachBefore(computeHeight); +} + +function node_copy() { + return hierarchy(this).eachBefore(copyData); +} + +function objectChildren(d) { + return d.children; +} + +function mapChildren(d) { + return Array.isArray(d) ? d[1] : null; +} + +function copyData(node) { + if (node.data.value !== undefined) node.value = node.data.value; + node.data = node.data.data; +} + +function computeHeight(node) { + var height = 0; + do node.height = height; + while ((node = node.parent) && (node.height < ++height)); +} + +function Node$1(data) { + this.data = data; + this.depth = + this.height = 0; + this.parent = null; +} + +Node$1.prototype = hierarchy.prototype = { + constructor: Node$1, + count: node_count, + each: node_each, + eachAfter: node_eachAfter, + eachBefore: node_eachBefore, + find: node_find, + sum: node_sum, + sort: node_sort, + path: node_path, + ancestors: node_ancestors, + descendants: node_descendants, + leaves: node_leaves, + links: node_links, + copy: node_copy, + [Symbol.iterator]: node_iterator +}; + +function array$1(x) { + return typeof x === "object" && "length" in x + ? x // Array, TypedArray, NodeList, array-like + : Array.from(x); // Map, Set, iterable, string, or anything else +} + +function shuffle(array) { + var m = array.length, + t, + i; + + while (m) { + i = Math.random() * m-- | 0; + t = array[m]; + array[m] = array[i]; + array[i] = t; + } + + return array; +} + +function enclose(circles) { + var i = 0, n = (circles = shuffle(Array.from(circles))).length, B = [], p, e; + + while (i < n) { + p = circles[i]; + if (e && enclosesWeak(e, p)) ++i; + else e = encloseBasis(B = extendBasis(B, p)), i = 0; + } + + return e; +} + +function extendBasis(B, p) { + var i, j; + + if (enclosesWeakAll(p, B)) return [p]; + + // If we get here then B must have at least one element. + for (i = 0; i < B.length; ++i) { + if (enclosesNot(p, B[i]) + && enclosesWeakAll(encloseBasis2(B[i], p), B)) { + return [B[i], p]; + } + } + + // If we get here then B must have at least two elements. + for (i = 0; i < B.length - 1; ++i) { + for (j = i + 1; j < B.length; ++j) { + if (enclosesNot(encloseBasis2(B[i], B[j]), p) + && enclosesNot(encloseBasis2(B[i], p), B[j]) + && enclosesNot(encloseBasis2(B[j], p), B[i]) + && enclosesWeakAll(encloseBasis3(B[i], B[j], p), B)) { + return [B[i], B[j], p]; + } + } + } + + // If we get here then something is very wrong. + throw new Error; +} + +function enclosesNot(a, b) { + var dr = a.r - b.r, dx = b.x - a.x, dy = b.y - a.y; + return dr < 0 || dr * dr < dx * dx + dy * dy; +} + +function enclosesWeak(a, b) { + var dr = a.r - b.r + Math.max(a.r, b.r, 1) * 1e-9, dx = b.x - a.x, dy = b.y - a.y; + return dr > 0 && dr * dr > dx * dx + dy * dy; +} + +function enclosesWeakAll(a, B) { + for (var i = 0; i < B.length; ++i) { + if (!enclosesWeak(a, B[i])) { + return false; + } + } + return true; +} + +function encloseBasis(B) { + switch (B.length) { + case 1: return encloseBasis1(B[0]); + case 2: return encloseBasis2(B[0], B[1]); + case 3: return encloseBasis3(B[0], B[1], B[2]); + } +} + +function encloseBasis1(a) { + return { + x: a.x, + y: a.y, + r: a.r + }; +} + +function encloseBasis2(a, b) { + var x1 = a.x, y1 = a.y, r1 = a.r, + x2 = b.x, y2 = b.y, r2 = b.r, + x21 = x2 - x1, y21 = y2 - y1, r21 = r2 - r1, + l = Math.sqrt(x21 * x21 + y21 * y21); + return { + x: (x1 + x2 + x21 / l * r21) / 2, + y: (y1 + y2 + y21 / l * r21) / 2, + r: (l + r1 + r2) / 2 + }; +} + +function encloseBasis3(a, b, c) { + var x1 = a.x, y1 = a.y, r1 = a.r, + x2 = b.x, y2 = b.y, r2 = b.r, + x3 = c.x, y3 = c.y, r3 = c.r, + a2 = x1 - x2, + a3 = x1 - x3, + b2 = y1 - y2, + b3 = y1 - y3, + c2 = r2 - r1, + c3 = r3 - r1, + d1 = x1 * x1 + y1 * y1 - r1 * r1, + d2 = d1 - x2 * x2 - y2 * y2 + r2 * r2, + d3 = d1 - x3 * x3 - y3 * y3 + r3 * r3, + ab = a3 * b2 - a2 * b3, + xa = (b2 * d3 - b3 * d2) / (ab * 2) - x1, + xb = (b3 * c2 - b2 * c3) / ab, + ya = (a3 * d2 - a2 * d3) / (ab * 2) - y1, + yb = (a2 * c3 - a3 * c2) / ab, + A = xb * xb + yb * yb - 1, + B = 2 * (r1 + xa * xb + ya * yb), + C = xa * xa + ya * ya - r1 * r1, + r = -(A ? (B + Math.sqrt(B * B - 4 * A * C)) / (2 * A) : C / B); + return { + x: x1 + xa + xb * r, + y: y1 + ya + yb * r, + r: r + }; +} + +function place(b, a, c) { + var dx = b.x - a.x, x, a2, + dy = b.y - a.y, y, b2, + d2 = dx * dx + dy * dy; + if (d2) { + a2 = a.r + c.r, a2 *= a2; + b2 = b.r + c.r, b2 *= b2; + if (a2 > b2) { + x = (d2 + b2 - a2) / (2 * d2); + y = Math.sqrt(Math.max(0, b2 / d2 - x * x)); + c.x = b.x - x * dx - y * dy; + c.y = b.y - x * dy + y * dx; + } else { + x = (d2 + a2 - b2) / (2 * d2); + y = Math.sqrt(Math.max(0, a2 / d2 - x * x)); + c.x = a.x + x * dx - y * dy; + c.y = a.y + x * dy + y * dx; + } + } else { + c.x = a.x + c.r; + c.y = a.y; + } +} + +function intersects(a, b) { + var dr = a.r + b.r - 1e-6, dx = b.x - a.x, dy = b.y - a.y; + return dr > 0 && dr * dr > dx * dx + dy * dy; +} + +function score(node) { + var a = node._, + b = node.next._, + ab = a.r + b.r, + dx = (a.x * b.r + b.x * a.r) / ab, + dy = (a.y * b.r + b.y * a.r) / ab; + return dx * dx + dy * dy; +} + +function Node(circle) { + this._ = circle; + this.next = null; + this.previous = null; +} + +function packEnclose(circles) { + if (!(n = (circles = array$1(circles)).length)) return 0; + + var a, b, c, n, aa, ca, i, j, k, sj, sk; + + // Place the first circle. + a = circles[0], a.x = 0, a.y = 0; + if (!(n > 1)) return a.r; + + // Place the second circle. + b = circles[1], a.x = -b.r, b.x = a.r, b.y = 0; + if (!(n > 2)) return a.r + b.r; + + // Place the third circle. + place(b, a, c = circles[2]); + + // Initialize the front-chain using the first three circles a, b and c. + a = new Node(a), b = new Node(b), c = new Node(c); + a.next = c.previous = b; + b.next = a.previous = c; + c.next = b.previous = a; + + // Attempt to place each remaining circle… + pack: for (i = 3; i < n; ++i) { + place(a._, b._, c = circles[i]), c = new Node(c); + + // Find the closest intersecting circle on the front-chain, if any. + // “Closeness” is determined by linear distance along the front-chain. + // “Ahead” or “behind” is likewise determined by linear distance. + j = b.next, k = a.previous, sj = b._.r, sk = a._.r; + do { + if (sj <= sk) { + if (intersects(j._, c._)) { + b = j, a.next = b, b.previous = a, --i; + continue pack; + } + sj += j._.r, j = j.next; + } else { + if (intersects(k._, c._)) { + a = k, a.next = b, b.previous = a, --i; + continue pack; + } + sk += k._.r, k = k.previous; + } + } while (j !== k.next); + + // Success! Insert the new circle c between a and b. + c.previous = a, c.next = b, a.next = b.previous = b = c; + + // Compute the new closest circle pair to the centroid. + aa = score(a); + while ((c = c.next) !== b) { + if ((ca = score(c)) < aa) { + a = c, aa = ca; + } + } + b = a.next; + } + + // Compute the enclosing circle of the front chain. + a = [b._], c = b; while ((c = c.next) !== b) a.push(c._); c = enclose(a); + + // Translate the circles to put the enclosing circle around the origin. + for (i = 0; i < n; ++i) a = circles[i], a.x -= c.x, a.y -= c.y; + + return c.r; +} + +function siblings(circles) { + packEnclose(circles); + return circles; +} + +function optional(f) { + return f == null ? null : required(f); +} + +function required(f) { + if (typeof f !== "function") throw new Error; + return f; +} + +function constantZero() { + return 0; +} + +function constant$2(x) { + return function() { + return x; + }; +} + +function defaultRadius(d) { + return Math.sqrt(d.value); +} + +function index$1() { + var radius = null, + dx = 1, + dy = 1, + padding = constantZero; + + function pack(root) { + root.x = dx / 2, root.y = dy / 2; + if (radius) { + root.eachBefore(radiusLeaf(radius)) + .eachAfter(packChildren(padding, 0.5)) + .eachBefore(translateChild(1)); + } else { + root.eachBefore(radiusLeaf(defaultRadius)) + .eachAfter(packChildren(constantZero, 1)) + .eachAfter(packChildren(padding, root.r / Math.min(dx, dy))) + .eachBefore(translateChild(Math.min(dx, dy) / (2 * root.r))); + } + return root; + } + + pack.radius = function(x) { + return arguments.length ? (radius = optional(x), pack) : radius; + }; + + pack.size = function(x) { + return arguments.length ? (dx = +x[0], dy = +x[1], pack) : [dx, dy]; + }; + + pack.padding = function(x) { + return arguments.length ? (padding = typeof x === "function" ? x : constant$2(+x), pack) : padding; + }; + + return pack; +} + +function radiusLeaf(radius) { + return function(node) { + if (!node.children) { + node.r = Math.max(0, +radius(node) || 0); + } + }; +} + +function packChildren(padding, k) { + return function(node) { + if (children = node.children) { + var children, + i, + n = children.length, + r = padding(node) * k || 0, + e; + + if (r) for (i = 0; i < n; ++i) children[i].r += r; + e = packEnclose(children); + if (r) for (i = 0; i < n; ++i) children[i].r -= r; + node.r = e + r; + } + }; +} + +function translateChild(k) { + return function(node) { + var parent = node.parent; + node.r *= k; + if (parent) { + node.x = parent.x + k * node.x; + node.y = parent.y + k * node.y; + } + }; +} + +function roundNode(node) { + node.x0 = Math.round(node.x0); + node.y0 = Math.round(node.y0); + node.x1 = Math.round(node.x1); + node.y1 = Math.round(node.y1); +} + +function treemapDice(parent, x0, y0, x1, y1) { + var nodes = parent.children, + node, + i = -1, + n = nodes.length, + k = parent.value && (x1 - x0) / parent.value; + + while (++i < n) { + node = nodes[i], node.y0 = y0, node.y1 = y1; + node.x0 = x0, node.x1 = x0 += node.value * k; + } +} + +function partition() { + var dx = 1, + dy = 1, + padding = 0, + round = false; + + function partition(root) { + var n = root.height + 1; + root.x0 = + root.y0 = padding; + root.x1 = dx; + root.y1 = dy / n; + root.eachBefore(positionNode(dy, n)); + if (round) root.eachBefore(roundNode); + return root; + } + + function positionNode(dy, n) { + return function(node) { + if (node.children) { + treemapDice(node, node.x0, dy * (node.depth + 1) / n, node.x1, dy * (node.depth + 2) / n); + } + var x0 = node.x0, + y0 = node.y0, + x1 = node.x1 - padding, + y1 = node.y1 - padding; + if (x1 < x0) x0 = x1 = (x0 + x1) / 2; + if (y1 < y0) y0 = y1 = (y0 + y1) / 2; + node.x0 = x0; + node.y0 = y0; + node.x1 = x1; + node.y1 = y1; + }; + } + + partition.round = function(x) { + return arguments.length ? (round = !!x, partition) : round; + }; + + partition.size = function(x) { + return arguments.length ? (dx = +x[0], dy = +x[1], partition) : [dx, dy]; + }; + + partition.padding = function(x) { + return arguments.length ? (padding = +x, partition) : padding; + }; + + return partition; +} + +var preroot = {depth: -1}, + ambiguous = {}, + imputed = {}; + +function defaultId(d) { + return d.id; +} + +function defaultParentId(d) { + return d.parentId; +} + +function stratify() { + var id = defaultId, + parentId = defaultParentId, + path; + + function stratify(data) { + var nodes = Array.from(data), + currentId = id, + currentParentId = parentId, + n, + d, + i, + root, + parent, + node, + nodeId, + nodeKey, + nodeByKey = new Map; + + if (path != null) { + const I = nodes.map((d, i) => normalize$1(path(d, i, data))); + const P = I.map(parentof); + const S = new Set(I).add(""); + for (const i of P) { + if (!S.has(i)) { + S.add(i); + I.push(i); + P.push(parentof(i)); + nodes.push(imputed); + } + } + currentId = (_, i) => I[i]; + currentParentId = (_, i) => P[i]; + } + + for (i = 0, n = nodes.length; i < n; ++i) { + d = nodes[i], node = nodes[i] = new Node$1(d); + if ((nodeId = currentId(d, i, data)) != null && (nodeId += "")) { + nodeKey = node.id = nodeId; + nodeByKey.set(nodeKey, nodeByKey.has(nodeKey) ? ambiguous : node); + } + if ((nodeId = currentParentId(d, i, data)) != null && (nodeId += "")) { + node.parent = nodeId; + } + } + + for (i = 0; i < n; ++i) { + node = nodes[i]; + if (nodeId = node.parent) { + parent = nodeByKey.get(nodeId); + if (!parent) throw new Error("missing: " + nodeId); + if (parent === ambiguous) throw new Error("ambiguous: " + nodeId); + if (parent.children) parent.children.push(node); + else parent.children = [node]; + node.parent = parent; + } else { + if (root) throw new Error("multiple roots"); + root = node; + } + } + + if (!root) throw new Error("no root"); + + // When imputing internal nodes, only introduce roots if needed. + // Then replace the imputed marker data with null. + if (path != null) { + while (root.data === imputed && root.children.length === 1) { + root = root.children[0], --n; + } + for (let i = nodes.length - 1; i >= 0; --i) { + node = nodes[i]; + if (node.data !== imputed) break; + node.data = null; + } + } + + root.parent = preroot; + root.eachBefore(function(node) { node.depth = node.parent.depth + 1; --n; }).eachBefore(computeHeight); + root.parent = null; + if (n > 0) throw new Error("cycle"); + + return root; + } + + stratify.id = function(x) { + return arguments.length ? (id = optional(x), stratify) : id; + }; + + stratify.parentId = function(x) { + return arguments.length ? (parentId = optional(x), stratify) : parentId; + }; + + stratify.path = function(x) { + return arguments.length ? (path = optional(x), stratify) : path; + }; + + return stratify; +} + +// To normalize a path, we coerce to a string, strip the trailing slash if any +// (as long as the trailing slash is not immediately preceded by another slash), +// and add leading slash if missing. +function normalize$1(path) { + path = `${path}`; + let i = path.length; + if (slash(path, i - 1) && !slash(path, i - 2)) path = path.slice(0, -1); + return path[0] === "/" ? path : `/${path}`; +} + +// Walk backwards to find the first slash that is not the leading slash, e.g.: +// "/foo/bar" ⇥ "/foo", "/foo" ⇥ "/", "/" ↦ "". (The root is special-cased +// because the id of the root must be a truthy value.) +function parentof(path) { + let i = path.length; + if (i < 2) return ""; + while (--i > 1) if (slash(path, i)) break; + return path.slice(0, i); +} + +// Slashes can be escaped; to determine whether a slash is a path delimiter, we +// count the number of preceding backslashes escaping the forward slash: an odd +// number indicates an escaped forward slash. +function slash(path, i) { + if (path[i] === "/") { + let k = 0; + while (i > 0 && path[--i] === "\\") ++k; + if ((k & 1) === 0) return true; + } + return false; +} + +function defaultSeparation(a, b) { + return a.parent === b.parent ? 1 : 2; +} + +// function radialSeparation(a, b) { +// return (a.parent === b.parent ? 1 : 2) / a.depth; +// } + +// This function is used to traverse the left contour of a subtree (or +// subforest). It returns the successor of v on this contour. This successor is +// either given by the leftmost child of v or by the thread of v. The function +// returns null if and only if v is on the highest level of its subtree. +function nextLeft(v) { + var children = v.children; + return children ? children[0] : v.t; +} + +// This function works analogously to nextLeft. +function nextRight(v) { + var children = v.children; + return children ? children[children.length - 1] : v.t; +} + +// Shifts the current subtree rooted at w+. This is done by increasing +// prelim(w+) and mod(w+) by shift. +function moveSubtree(wm, wp, shift) { + var change = shift / (wp.i - wm.i); + wp.c -= change; + wp.s += shift; + wm.c += change; + wp.z += shift; + wp.m += shift; +} + +// All other shifts, applied to the smaller subtrees between w- and w+, are +// performed by this function. To prepare the shifts, we have to adjust +// change(w+), shift(w+), and change(w-). +function executeShifts(v) { + var shift = 0, + change = 0, + children = v.children, + i = children.length, + w; + while (--i >= 0) { + w = children[i]; + w.z += shift; + w.m += shift; + shift += w.s + (change += w.c); + } +} + +// If vi-’s ancestor is a sibling of v, returns vi-’s ancestor. Otherwise, +// returns the specified (default) ancestor. +function nextAncestor(vim, v, ancestor) { + return vim.a.parent === v.parent ? vim.a : ancestor; +} + +function TreeNode(node, i) { + this._ = node; + this.parent = null; + this.children = null; + this.A = null; // default ancestor + this.a = this; // ancestor + this.z = 0; // prelim + this.m = 0; // mod + this.c = 0; // change + this.s = 0; // shift + this.t = null; // thread + this.i = i; // number +} + +TreeNode.prototype = Object.create(Node$1.prototype); + +function treeRoot(root) { + var tree = new TreeNode(root, 0), + node, + nodes = [tree], + child, + children, + i, + n; + + while (node = nodes.pop()) { + if (children = node._.children) { + node.children = new Array(n = children.length); + for (i = n - 1; i >= 0; --i) { + nodes.push(child = node.children[i] = new TreeNode(children[i], i)); + child.parent = node; + } + } + } + + (tree.parent = new TreeNode(null, 0)).children = [tree]; + return tree; +} + +// Node-link tree diagram using the Reingold-Tilford "tidy" algorithm +function tree() { + var separation = defaultSeparation, + dx = 1, + dy = 1, + nodeSize = null; + + function tree(root) { + var t = treeRoot(root); + + // Compute the layout using Buchheim et al.’s algorithm. + t.eachAfter(firstWalk), t.parent.m = -t.z; + t.eachBefore(secondWalk); + + // If a fixed node size is specified, scale x and y. + if (nodeSize) root.eachBefore(sizeNode); + + // If a fixed tree size is specified, scale x and y based on the extent. + // Compute the left-most, right-most, and depth-most nodes for extents. + else { + var left = root, + right = root, + bottom = root; + root.eachBefore(function(node) { + if (node.x < left.x) left = node; + if (node.x > right.x) right = node; + if (node.depth > bottom.depth) bottom = node; + }); + var s = left === right ? 1 : separation(left, right) / 2, + tx = s - left.x, + kx = dx / (right.x + s + tx), + ky = dy / (bottom.depth || 1); + root.eachBefore(function(node) { + node.x = (node.x + tx) * kx; + node.y = node.depth * ky; + }); + } + + return root; + } + + // Computes a preliminary x-coordinate for v. Before that, FIRST WALK is + // applied recursively to the children of v, as well as the function + // APPORTION. After spacing out the children by calling EXECUTE SHIFTS, the + // node v is placed to the midpoint of its outermost children. + function firstWalk(v) { + var children = v.children, + siblings = v.parent.children, + w = v.i ? siblings[v.i - 1] : null; + if (children) { + executeShifts(v); + var midpoint = (children[0].z + children[children.length - 1].z) / 2; + if (w) { + v.z = w.z + separation(v._, w._); + v.m = v.z - midpoint; + } else { + v.z = midpoint; + } + } else if (w) { + v.z = w.z + separation(v._, w._); + } + v.parent.A = apportion(v, w, v.parent.A || siblings[0]); + } + + // Computes all real x-coordinates by summing up the modifiers recursively. + function secondWalk(v) { + v._.x = v.z + v.parent.m; + v.m += v.parent.m; + } + + // The core of the algorithm. Here, a new subtree is combined with the + // previous subtrees. Threads are used to traverse the inside and outside + // contours of the left and right subtree up to the highest common level. The + // vertices used for the traversals are vi+, vi-, vo-, and vo+, where the + // superscript o means outside and i means inside, the subscript - means left + // subtree and + means right subtree. For summing up the modifiers along the + // contour, we use respective variables si+, si-, so-, and so+. Whenever two + // nodes of the inside contours conflict, we compute the left one of the + // greatest uncommon ancestors using the function ANCESTOR and call MOVE + // SUBTREE to shift the subtree and prepare the shifts of smaller subtrees. + // Finally, we add a new thread (if necessary). + function apportion(v, w, ancestor) { + if (w) { + var vip = v, + vop = v, + vim = w, + vom = vip.parent.children[0], + sip = vip.m, + sop = vop.m, + sim = vim.m, + som = vom.m, + shift; + while (vim = nextRight(vim), vip = nextLeft(vip), vim && vip) { + vom = nextLeft(vom); + vop = nextRight(vop); + vop.a = v; + shift = vim.z + sim - vip.z - sip + separation(vim._, vip._); + if (shift > 0) { + moveSubtree(nextAncestor(vim, v, ancestor), v, shift); + sip += shift; + sop += shift; + } + sim += vim.m; + sip += vip.m; + som += vom.m; + sop += vop.m; + } + if (vim && !nextRight(vop)) { + vop.t = vim; + vop.m += sim - sop; + } + if (vip && !nextLeft(vom)) { + vom.t = vip; + vom.m += sip - som; + ancestor = v; + } + } + return ancestor; + } + + function sizeNode(node) { + node.x *= dx; + node.y = node.depth * dy; + } + + tree.separation = function(x) { + return arguments.length ? (separation = x, tree) : separation; + }; + + tree.size = function(x) { + return arguments.length ? (nodeSize = false, dx = +x[0], dy = +x[1], tree) : (nodeSize ? null : [dx, dy]); + }; + + tree.nodeSize = function(x) { + return arguments.length ? (nodeSize = true, dx = +x[0], dy = +x[1], tree) : (nodeSize ? [dx, dy] : null); + }; + + return tree; +} + +function treemapSlice(parent, x0, y0, x1, y1) { + var nodes = parent.children, + node, + i = -1, + n = nodes.length, + k = parent.value && (y1 - y0) / parent.value; + + while (++i < n) { + node = nodes[i], node.x0 = x0, node.x1 = x1; + node.y0 = y0, node.y1 = y0 += node.value * k; + } +} + +var phi = (1 + Math.sqrt(5)) / 2; + +function squarifyRatio(ratio, parent, x0, y0, x1, y1) { + var rows = [], + nodes = parent.children, + row, + nodeValue, + i0 = 0, + i1 = 0, + n = nodes.length, + dx, dy, + value = parent.value, + sumValue, + minValue, + maxValue, + newRatio, + minRatio, + alpha, + beta; + + while (i0 < n) { + dx = x1 - x0, dy = y1 - y0; + + // Find the next non-empty node. + do sumValue = nodes[i1++].value; while (!sumValue && i1 < n); + minValue = maxValue = sumValue; + alpha = Math.max(dy / dx, dx / dy) / (value * ratio); + beta = sumValue * sumValue * alpha; + minRatio = Math.max(maxValue / beta, beta / minValue); + + // Keep adding nodes while the aspect ratio maintains or improves. + for (; i1 < n; ++i1) { + sumValue += nodeValue = nodes[i1].value; + if (nodeValue < minValue) minValue = nodeValue; + if (nodeValue > maxValue) maxValue = nodeValue; + beta = sumValue * sumValue * alpha; + newRatio = Math.max(maxValue / beta, beta / minValue); + if (newRatio > minRatio) { sumValue -= nodeValue; break; } + minRatio = newRatio; + } + + // Position and record the row orientation. + rows.push(row = {value: sumValue, dice: dx < dy, children: nodes.slice(i0, i1)}); + if (row.dice) treemapDice(row, x0, y0, x1, value ? y0 += dy * sumValue / value : y1); + else treemapSlice(row, x0, y0, value ? x0 += dx * sumValue / value : x1, y1); + value -= sumValue, i0 = i1; + } + + return rows; +} + +var squarify = (function custom(ratio) { + + function squarify(parent, x0, y0, x1, y1) { + squarifyRatio(ratio, parent, x0, y0, x1, y1); + } + + squarify.ratio = function(x) { + return custom((x = +x) > 1 ? x : 1); + }; + + return squarify; +})(phi); + +function index() { + var tile = squarify, + round = false, + dx = 1, + dy = 1, + paddingStack = [0], + paddingInner = constantZero, + paddingTop = constantZero, + paddingRight = constantZero, + paddingBottom = constantZero, + paddingLeft = constantZero; + + function treemap(root) { + root.x0 = + root.y0 = 0; + root.x1 = dx; + root.y1 = dy; + root.eachBefore(positionNode); + paddingStack = [0]; + if (round) root.eachBefore(roundNode); + return root; + } + + function positionNode(node) { + var p = paddingStack[node.depth], + x0 = node.x0 + p, + y0 = node.y0 + p, + x1 = node.x1 - p, + y1 = node.y1 - p; + if (x1 < x0) x0 = x1 = (x0 + x1) / 2; + if (y1 < y0) y0 = y1 = (y0 + y1) / 2; + node.x0 = x0; + node.y0 = y0; + node.x1 = x1; + node.y1 = y1; + if (node.children) { + p = paddingStack[node.depth + 1] = paddingInner(node) / 2; + x0 += paddingLeft(node) - p; + y0 += paddingTop(node) - p; + x1 -= paddingRight(node) - p; + y1 -= paddingBottom(node) - p; + if (x1 < x0) x0 = x1 = (x0 + x1) / 2; + if (y1 < y0) y0 = y1 = (y0 + y1) / 2; + tile(node, x0, y0, x1, y1); + } + } + + treemap.round = function(x) { + return arguments.length ? (round = !!x, treemap) : round; + }; + + treemap.size = function(x) { + return arguments.length ? (dx = +x[0], dy = +x[1], treemap) : [dx, dy]; + }; + + treemap.tile = function(x) { + return arguments.length ? (tile = required(x), treemap) : tile; + }; + + treemap.padding = function(x) { + return arguments.length ? treemap.paddingInner(x).paddingOuter(x) : treemap.paddingInner(); + }; + + treemap.paddingInner = function(x) { + return arguments.length ? (paddingInner = typeof x === "function" ? x : constant$2(+x), treemap) : paddingInner; + }; + + treemap.paddingOuter = function(x) { + return arguments.length ? treemap.paddingTop(x).paddingRight(x).paddingBottom(x).paddingLeft(x) : treemap.paddingTop(); + }; + + treemap.paddingTop = function(x) { + return arguments.length ? (paddingTop = typeof x === "function" ? x : constant$2(+x), treemap) : paddingTop; + }; + + treemap.paddingRight = function(x) { + return arguments.length ? (paddingRight = typeof x === "function" ? x : constant$2(+x), treemap) : paddingRight; + }; + + treemap.paddingBottom = function(x) { + return arguments.length ? (paddingBottom = typeof x === "function" ? x : constant$2(+x), treemap) : paddingBottom; + }; + + treemap.paddingLeft = function(x) { + return arguments.length ? (paddingLeft = typeof x === "function" ? x : constant$2(+x), treemap) : paddingLeft; + }; + + return treemap; +} + +function binary(parent, x0, y0, x1, y1) { + var nodes = parent.children, + i, n = nodes.length, + sum, sums = new Array(n + 1); + + for (sums[0] = sum = i = 0; i < n; ++i) { + sums[i + 1] = sum += nodes[i].value; + } + + partition(0, n, parent.value, x0, y0, x1, y1); + + function partition(i, j, value, x0, y0, x1, y1) { + if (i >= j - 1) { + var node = nodes[i]; + node.x0 = x0, node.y0 = y0; + node.x1 = x1, node.y1 = y1; + return; + } + + var valueOffset = sums[i], + valueTarget = (value / 2) + valueOffset, + k = i + 1, + hi = j - 1; + + while (k < hi) { + var mid = k + hi >>> 1; + if (sums[mid] < valueTarget) k = mid + 1; + else hi = mid; + } + + if ((valueTarget - sums[k - 1]) < (sums[k] - valueTarget) && i + 1 < k) --k; + + var valueLeft = sums[k] - valueOffset, + valueRight = value - valueLeft; + + if ((x1 - x0) > (y1 - y0)) { + var xk = value ? (x0 * valueRight + x1 * valueLeft) / value : x1; + partition(i, k, valueLeft, x0, y0, xk, y1); + partition(k, j, valueRight, xk, y0, x1, y1); + } else { + var yk = value ? (y0 * valueRight + y1 * valueLeft) / value : y1; + partition(i, k, valueLeft, x0, y0, x1, yk); + partition(k, j, valueRight, x0, yk, x1, y1); + } + } +} + +function sliceDice(parent, x0, y0, x1, y1) { + (parent.depth & 1 ? treemapSlice : treemapDice)(parent, x0, y0, x1, y1); +} + +var resquarify = (function custom(ratio) { + + function resquarify(parent, x0, y0, x1, y1) { + if ((rows = parent._squarify) && (rows.ratio === ratio)) { + var rows, + row, + nodes, + i, + j = -1, + n, + m = rows.length, + value = parent.value; + + while (++j < m) { + row = rows[j], nodes = row.children; + for (i = row.value = 0, n = nodes.length; i < n; ++i) row.value += nodes[i].value; + if (row.dice) treemapDice(row, x0, y0, x1, value ? y0 += (y1 - y0) * row.value / value : y1); + else treemapSlice(row, x0, y0, value ? x0 += (x1 - x0) * row.value / value : x1, y1); + value -= row.value; + } + } else { + parent._squarify = rows = squarifyRatio(ratio, parent, x0, y0, x1, y1); + rows.ratio = ratio; + } + } + + resquarify.ratio = function(x) { + return custom((x = +x) > 1 ? x : 1); + }; + + return resquarify; +})(phi); + +function area$1(polygon) { + var i = -1, + n = polygon.length, + a, + b = polygon[n - 1], + area = 0; + + while (++i < n) { + a = b; + b = polygon[i]; + area += a[1] * b[0] - a[0] * b[1]; + } + + return area / 2; +} + +function centroid(polygon) { + var i = -1, + n = polygon.length, + x = 0, + y = 0, + a, + b = polygon[n - 1], + c, + k = 0; + + while (++i < n) { + a = b; + b = polygon[i]; + k += c = a[0] * b[1] - b[0] * a[1]; + x += (a[0] + b[0]) * c; + y += (a[1] + b[1]) * c; + } + + return k *= 3, [x / k, y / k]; +} + +// Returns the 2D cross product of AB and AC vectors, i.e., the z-component of +// the 3D cross product in a quadrant I Cartesian coordinate system (+x is +// right, +y is up). Returns a positive value if ABC is counter-clockwise, +// negative if clockwise, and zero if the points are collinear. +function cross$1(a, b, c) { + return (b[0] - a[0]) * (c[1] - a[1]) - (b[1] - a[1]) * (c[0] - a[0]); +} + +function lexicographicOrder(a, b) { + return a[0] - b[0] || a[1] - b[1]; +} + +// Computes the upper convex hull per the monotone chain algorithm. +// Assumes points.length >= 3, is sorted by x, unique in y. +// Returns an array of indices into points in left-to-right order. +function computeUpperHullIndexes(points) { + const n = points.length, + indexes = [0, 1]; + let size = 2, i; + + for (i = 2; i < n; ++i) { + while (size > 1 && cross$1(points[indexes[size - 2]], points[indexes[size - 1]], points[i]) <= 0) --size; + indexes[size++] = i; + } + + return indexes.slice(0, size); // remove popped points +} + +function hull(points) { + if ((n = points.length) < 3) return null; + + var i, + n, + sortedPoints = new Array(n), + flippedPoints = new Array(n); + + for (i = 0; i < n; ++i) sortedPoints[i] = [+points[i][0], +points[i][1], i]; + sortedPoints.sort(lexicographicOrder); + for (i = 0; i < n; ++i) flippedPoints[i] = [sortedPoints[i][0], -sortedPoints[i][1]]; + + var upperIndexes = computeUpperHullIndexes(sortedPoints), + lowerIndexes = computeUpperHullIndexes(flippedPoints); + + // Construct the hull polygon, removing possible duplicate endpoints. + var skipLeft = lowerIndexes[0] === upperIndexes[0], + skipRight = lowerIndexes[lowerIndexes.length - 1] === upperIndexes[upperIndexes.length - 1], + hull = []; + + // Add upper hull in right-to-l order. + // Then add lower hull in left-to-right order. + for (i = upperIndexes.length - 1; i >= 0; --i) hull.push(points[sortedPoints[upperIndexes[i]][2]]); + for (i = +skipLeft; i < lowerIndexes.length - skipRight; ++i) hull.push(points[sortedPoints[lowerIndexes[i]][2]]); + + return hull; +} + +function contains(polygon, point) { + var n = polygon.length, + p = polygon[n - 1], + x = point[0], y = point[1], + x0 = p[0], y0 = p[1], + x1, y1, + inside = false; + + for (var i = 0; i < n; ++i) { + p = polygon[i], x1 = p[0], y1 = p[1]; + if (((y1 > y) !== (y0 > y)) && (x < (x0 - x1) * (y - y1) / (y0 - y1) + x1)) inside = !inside; + x0 = x1, y0 = y1; + } + + return inside; +} + +function length(polygon) { + var i = -1, + n = polygon.length, + b = polygon[n - 1], + xa, + ya, + xb = b[0], + yb = b[1], + perimeter = 0; + + while (++i < n) { + xa = xb; + ya = yb; + b = polygon[i]; + xb = b[0]; + yb = b[1]; + xa -= xb; + ya -= yb; + perimeter += Math.hypot(xa, ya); + } + + return perimeter; +} + +var defaultSource = Math.random; + +var uniform = (function sourceRandomUniform(source) { + function randomUniform(min, max) { + min = min == null ? 0 : +min; + max = max == null ? 1 : +max; + if (arguments.length === 1) max = min, min = 0; + else max -= min; + return function() { + return source() * max + min; + }; + } + + randomUniform.source = sourceRandomUniform; + + return randomUniform; +})(defaultSource); + +var int = (function sourceRandomInt(source) { + function randomInt(min, max) { + if (arguments.length < 2) max = min, min = 0; + min = Math.floor(min); + max = Math.floor(max) - min; + return function() { + return Math.floor(source() * max + min); + }; + } + + randomInt.source = sourceRandomInt; + + return randomInt; +})(defaultSource); + +var normal = (function sourceRandomNormal(source) { + function randomNormal(mu, sigma) { + var x, r; + mu = mu == null ? 0 : +mu; + sigma = sigma == null ? 1 : +sigma; + return function() { + var y; + + // If available, use the second previously-generated uniform random. + if (x != null) y = x, x = null; + + // Otherwise, generate a new x and y. + else do { + x = source() * 2 - 1; + y = source() * 2 - 1; + r = x * x + y * y; + } while (!r || r > 1); + + return mu + sigma * y * Math.sqrt(-2 * Math.log(r) / r); + }; + } + + randomNormal.source = sourceRandomNormal; + + return randomNormal; +})(defaultSource); + +var logNormal = (function sourceRandomLogNormal(source) { + var N = normal.source(source); + + function randomLogNormal() { + var randomNormal = N.apply(this, arguments); + return function() { + return Math.exp(randomNormal()); + }; + } + + randomLogNormal.source = sourceRandomLogNormal; + + return randomLogNormal; +})(defaultSource); + +var irwinHall = (function sourceRandomIrwinHall(source) { + function randomIrwinHall(n) { + if ((n = +n) <= 0) return () => 0; + return function() { + for (var sum = 0, i = n; i > 1; --i) sum += source(); + return sum + i * source(); + }; + } + + randomIrwinHall.source = sourceRandomIrwinHall; + + return randomIrwinHall; +})(defaultSource); + +var bates = (function sourceRandomBates(source) { + var I = irwinHall.source(source); + + function randomBates(n) { + // use limiting distribution at n === 0 + if ((n = +n) === 0) return source; + var randomIrwinHall = I(n); + return function() { + return randomIrwinHall() / n; + }; + } + + randomBates.source = sourceRandomBates; + + return randomBates; +})(defaultSource); + +var exponential = (function sourceRandomExponential(source) { + function randomExponential(lambda) { + return function() { + return -Math.log1p(-source()) / lambda; + }; + } + + randomExponential.source = sourceRandomExponential; + + return randomExponential; +})(defaultSource); + +var pareto = (function sourceRandomPareto(source) { + function randomPareto(alpha) { + if ((alpha = +alpha) < 0) throw new RangeError("invalid alpha"); + alpha = 1 / -alpha; + return function() { + return Math.pow(1 - source(), alpha); + }; + } + + randomPareto.source = sourceRandomPareto; + + return randomPareto; +})(defaultSource); + +var bernoulli = (function sourceRandomBernoulli(source) { + function randomBernoulli(p) { + if ((p = +p) < 0 || p > 1) throw new RangeError("invalid p"); + return function() { + return Math.floor(source() + p); + }; + } + + randomBernoulli.source = sourceRandomBernoulli; + + return randomBernoulli; +})(defaultSource); + +var geometric = (function sourceRandomGeometric(source) { + function randomGeometric(p) { + if ((p = +p) < 0 || p > 1) throw new RangeError("invalid p"); + if (p === 0) return () => Infinity; + if (p === 1) return () => 1; + p = Math.log1p(-p); + return function() { + return 1 + Math.floor(Math.log1p(-source()) / p); + }; + } + + randomGeometric.source = sourceRandomGeometric; + + return randomGeometric; +})(defaultSource); + +var gamma = (function sourceRandomGamma(source) { + var randomNormal = normal.source(source)(); + + function randomGamma(k, theta) { + if ((k = +k) < 0) throw new RangeError("invalid k"); + // degenerate distribution if k === 0 + if (k === 0) return () => 0; + theta = theta == null ? 1 : +theta; + // exponential distribution if k === 1 + if (k === 1) return () => -Math.log1p(-source()) * theta; + + var d = (k < 1 ? k + 1 : k) - 1 / 3, + c = 1 / (3 * Math.sqrt(d)), + multiplier = k < 1 ? () => Math.pow(source(), 1 / k) : () => 1; + return function() { + do { + do { + var x = randomNormal(), + v = 1 + c * x; + } while (v <= 0); + v *= v * v; + var u = 1 - source(); + } while (u >= 1 - 0.0331 * x * x * x * x && Math.log(u) >= 0.5 * x * x + d * (1 - v + Math.log(v))); + return d * v * multiplier() * theta; + }; + } + + randomGamma.source = sourceRandomGamma; + + return randomGamma; +})(defaultSource); + +var beta = (function sourceRandomBeta(source) { + var G = gamma.source(source); + + function randomBeta(alpha, beta) { + var X = G(alpha), + Y = G(beta); + return function() { + var x = X(); + return x === 0 ? 0 : x / (x + Y()); + }; + } + + randomBeta.source = sourceRandomBeta; + + return randomBeta; +})(defaultSource); + +var binomial = (function sourceRandomBinomial(source) { + var G = geometric.source(source), + B = beta.source(source); + + function randomBinomial(n, p) { + n = +n; + if ((p = +p) >= 1) return () => n; + if (p <= 0) return () => 0; + return function() { + var acc = 0, nn = n, pp = p; + while (nn * pp > 16 && nn * (1 - pp) > 16) { + var i = Math.floor((nn + 1) * pp), + y = B(i, nn - i + 1)(); + if (y <= pp) { + acc += i; + nn -= i; + pp = (pp - y) / (1 - y); + } else { + nn = i - 1; + pp /= y; + } + } + var sign = pp < 0.5, + pFinal = sign ? pp : 1 - pp, + g = G(pFinal); + for (var s = g(), k = 0; s <= nn; ++k) s += g(); + return acc + (sign ? k : nn - k); + }; + } + + randomBinomial.source = sourceRandomBinomial; + + return randomBinomial; +})(defaultSource); + +var weibull = (function sourceRandomWeibull(source) { + function randomWeibull(k, a, b) { + var outerFunc; + if ((k = +k) === 0) { + outerFunc = x => -Math.log(x); + } else { + k = 1 / k; + outerFunc = x => Math.pow(x, k); + } + a = a == null ? 0 : +a; + b = b == null ? 1 : +b; + return function() { + return a + b * outerFunc(-Math.log1p(-source())); + }; + } + + randomWeibull.source = sourceRandomWeibull; + + return randomWeibull; +})(defaultSource); + +var cauchy = (function sourceRandomCauchy(source) { + function randomCauchy(a, b) { + a = a == null ? 0 : +a; + b = b == null ? 1 : +b; + return function() { + return a + b * Math.tan(Math.PI * source()); + }; + } + + randomCauchy.source = sourceRandomCauchy; + + return randomCauchy; +})(defaultSource); + +var logistic = (function sourceRandomLogistic(source) { + function randomLogistic(a, b) { + a = a == null ? 0 : +a; + b = b == null ? 1 : +b; + return function() { + var u = source(); + return a + b * Math.log(u / (1 - u)); + }; + } + + randomLogistic.source = sourceRandomLogistic; + + return randomLogistic; +})(defaultSource); + +var poisson = (function sourceRandomPoisson(source) { + var G = gamma.source(source), + B = binomial.source(source); + + function randomPoisson(lambda) { + return function() { + var acc = 0, l = lambda; + while (l > 16) { + var n = Math.floor(0.875 * l), + t = G(n)(); + if (t > l) return acc + B(n - 1, l / t)(); + acc += n; + l -= t; + } + for (var s = -Math.log1p(-source()), k = 0; s <= l; ++k) s -= Math.log1p(-source()); + return acc + k; + }; + } + + randomPoisson.source = sourceRandomPoisson; + + return randomPoisson; +})(defaultSource); + +// https://en.wikipedia.org/wiki/Linear_congruential_generator#Parameters_in_common_use +const mul = 0x19660D; +const inc = 0x3C6EF35F; +const eps = 1 / 0x100000000; + +function lcg(seed = Math.random()) { + let state = (0 <= seed && seed < 1 ? seed / eps : Math.abs(seed)) | 0; + return () => (state = mul * state + inc | 0, eps * (state >>> 0)); +} + +function initRange(domain, range) { + switch (arguments.length) { + case 0: break; + case 1: this.range(domain); break; + default: this.range(range).domain(domain); break; + } + return this; +} + +function initInterpolator(domain, interpolator) { + switch (arguments.length) { + case 0: break; + case 1: { + if (typeof domain === "function") this.interpolator(domain); + else this.range(domain); + break; + } + default: { + this.domain(domain); + if (typeof interpolator === "function") this.interpolator(interpolator); + else this.range(interpolator); + break; + } + } + return this; +} + +const implicit = Symbol("implicit"); + +function ordinal() { + var index = new InternMap(), + domain = [], + range = [], + unknown = implicit; + + function scale(d) { + let i = index.get(d); + if (i === undefined) { + if (unknown !== implicit) return unknown; + index.set(d, i = domain.push(d) - 1); + } + return range[i % range.length]; + } + + scale.domain = function(_) { + if (!arguments.length) return domain.slice(); + domain = [], index = new InternMap(); + for (const value of _) { + if (index.has(value)) continue; + index.set(value, domain.push(value) - 1); + } + return scale; + }; + + scale.range = function(_) { + return arguments.length ? (range = Array.from(_), scale) : range.slice(); + }; + + scale.unknown = function(_) { + return arguments.length ? (unknown = _, scale) : unknown; + }; + + scale.copy = function() { + return ordinal(domain, range).unknown(unknown); + }; + + initRange.apply(scale, arguments); + + return scale; +} + +function band() { + var scale = ordinal().unknown(undefined), + domain = scale.domain, + ordinalRange = scale.range, + r0 = 0, + r1 = 1, + step, + bandwidth, + round = false, + paddingInner = 0, + paddingOuter = 0, + align = 0.5; + + delete scale.unknown; + + function rescale() { + var n = domain().length, + reverse = r1 < r0, + start = reverse ? r1 : r0, + stop = reverse ? r0 : r1; + step = (stop - start) / Math.max(1, n - paddingInner + paddingOuter * 2); + if (round) step = Math.floor(step); + start += (stop - start - step * (n - paddingInner)) * align; + bandwidth = step * (1 - paddingInner); + if (round) start = Math.round(start), bandwidth = Math.round(bandwidth); + var values = range$2(n).map(function(i) { return start + step * i; }); + return ordinalRange(reverse ? values.reverse() : values); + } + + scale.domain = function(_) { + return arguments.length ? (domain(_), rescale()) : domain(); + }; + + scale.range = function(_) { + return arguments.length ? ([r0, r1] = _, r0 = +r0, r1 = +r1, rescale()) : [r0, r1]; + }; + + scale.rangeRound = function(_) { + return [r0, r1] = _, r0 = +r0, r1 = +r1, round = true, rescale(); + }; + + scale.bandwidth = function() { + return bandwidth; + }; + + scale.step = function() { + return step; + }; + + scale.round = function(_) { + return arguments.length ? (round = !!_, rescale()) : round; + }; + + scale.padding = function(_) { + return arguments.length ? (paddingInner = Math.min(1, paddingOuter = +_), rescale()) : paddingInner; + }; + + scale.paddingInner = function(_) { + return arguments.length ? (paddingInner = Math.min(1, _), rescale()) : paddingInner; + }; + + scale.paddingOuter = function(_) { + return arguments.length ? (paddingOuter = +_, rescale()) : paddingOuter; + }; + + scale.align = function(_) { + return arguments.length ? (align = Math.max(0, Math.min(1, _)), rescale()) : align; + }; + + scale.copy = function() { + return band(domain(), [r0, r1]) + .round(round) + .paddingInner(paddingInner) + .paddingOuter(paddingOuter) + .align(align); + }; + + return initRange.apply(rescale(), arguments); +} + +function pointish(scale) { + var copy = scale.copy; + + scale.padding = scale.paddingOuter; + delete scale.paddingInner; + delete scale.paddingOuter; + + scale.copy = function() { + return pointish(copy()); + }; + + return scale; +} + +function point$4() { + return pointish(band.apply(null, arguments).paddingInner(1)); +} + +function constants(x) { + return function() { + return x; + }; +} + +function number$1(x) { + return +x; +} + +var unit = [0, 1]; + +function identity$3(x) { + return x; +} + +function normalize(a, b) { + return (b -= (a = +a)) + ? function(x) { return (x - a) / b; } + : constants(isNaN(b) ? NaN : 0.5); +} + +function clamper(a, b) { + var t; + if (a > b) t = a, a = b, b = t; + return function(x) { return Math.max(a, Math.min(b, x)); }; +} + +// normalize(a, b)(x) takes a domain value x in [a,b] and returns the corresponding parameter t in [0,1]. +// interpolate(a, b)(t) takes a parameter t in [0,1] and returns the corresponding range value x in [a,b]. +function bimap(domain, range, interpolate) { + var d0 = domain[0], d1 = domain[1], r0 = range[0], r1 = range[1]; + if (d1 < d0) d0 = normalize(d1, d0), r0 = interpolate(r1, r0); + else d0 = normalize(d0, d1), r0 = interpolate(r0, r1); + return function(x) { return r0(d0(x)); }; +} + +function polymap(domain, range, interpolate) { + var j = Math.min(domain.length, range.length) - 1, + d = new Array(j), + r = new Array(j), + i = -1; + + // Reverse descending domains. + if (domain[j] < domain[0]) { + domain = domain.slice().reverse(); + range = range.slice().reverse(); + } + + while (++i < j) { + d[i] = normalize(domain[i], domain[i + 1]); + r[i] = interpolate(range[i], range[i + 1]); + } + + return function(x) { + var i = bisect(domain, x, 1, j) - 1; + return r[i](d[i](x)); + }; +} + +function copy$1(source, target) { + return target + .domain(source.domain()) + .range(source.range()) + .interpolate(source.interpolate()) + .clamp(source.clamp()) + .unknown(source.unknown()); +} + +function transformer$2() { + var domain = unit, + range = unit, + interpolate = interpolate$2, + transform, + untransform, + unknown, + clamp = identity$3, + piecewise, + output, + input; + + function rescale() { + var n = Math.min(domain.length, range.length); + if (clamp !== identity$3) clamp = clamper(domain[0], domain[n - 1]); + piecewise = n > 2 ? polymap : bimap; + output = input = null; + return scale; + } + + function scale(x) { + return x == null || isNaN(x = +x) ? unknown : (output || (output = piecewise(domain.map(transform), range, interpolate)))(transform(clamp(x))); + } + + scale.invert = function(y) { + return clamp(untransform((input || (input = piecewise(range, domain.map(transform), interpolateNumber)))(y))); + }; + + scale.domain = function(_) { + return arguments.length ? (domain = Array.from(_, number$1), rescale()) : domain.slice(); + }; + + scale.range = function(_) { + return arguments.length ? (range = Array.from(_), rescale()) : range.slice(); + }; + + scale.rangeRound = function(_) { + return range = Array.from(_), interpolate = interpolateRound, rescale(); + }; + + scale.clamp = function(_) { + return arguments.length ? (clamp = _ ? true : identity$3, rescale()) : clamp !== identity$3; + }; + + scale.interpolate = function(_) { + return arguments.length ? (interpolate = _, rescale()) : interpolate; + }; + + scale.unknown = function(_) { + return arguments.length ? (unknown = _, scale) : unknown; + }; + + return function(t, u) { + transform = t, untransform = u; + return rescale(); + }; +} + +function continuous() { + return transformer$2()(identity$3, identity$3); +} + +function tickFormat(start, stop, count, specifier) { + var step = tickStep(start, stop, count), + precision; + specifier = formatSpecifier(specifier == null ? ",f" : specifier); + switch (specifier.type) { + case "s": { + var value = Math.max(Math.abs(start), Math.abs(stop)); + if (specifier.precision == null && !isNaN(precision = precisionPrefix(step, value))) specifier.precision = precision; + return exports.formatPrefix(specifier, value); + } + case "": + case "e": + case "g": + case "p": + case "r": { + if (specifier.precision == null && !isNaN(precision = precisionRound(step, Math.max(Math.abs(start), Math.abs(stop))))) specifier.precision = precision - (specifier.type === "e"); + break; + } + case "f": + case "%": { + if (specifier.precision == null && !isNaN(precision = precisionFixed(step))) specifier.precision = precision - (specifier.type === "%") * 2; + break; + } + } + return exports.format(specifier); +} + +function linearish(scale) { + var domain = scale.domain; + + scale.ticks = function(count) { + var d = domain(); + return ticks(d[0], d[d.length - 1], count == null ? 10 : count); + }; + + scale.tickFormat = function(count, specifier) { + var d = domain(); + return tickFormat(d[0], d[d.length - 1], count == null ? 10 : count, specifier); + }; + + scale.nice = function(count) { + if (count == null) count = 10; + + var d = domain(); + var i0 = 0; + var i1 = d.length - 1; + var start = d[i0]; + var stop = d[i1]; + var prestep; + var step; + var maxIter = 10; + + if (stop < start) { + step = start, start = stop, stop = step; + step = i0, i0 = i1, i1 = step; + } + + while (maxIter-- > 0) { + step = tickIncrement(start, stop, count); + if (step === prestep) { + d[i0] = start; + d[i1] = stop; + return domain(d); + } else if (step > 0) { + start = Math.floor(start / step) * step; + stop = Math.ceil(stop / step) * step; + } else if (step < 0) { + start = Math.ceil(start * step) / step; + stop = Math.floor(stop * step) / step; + } else { + break; + } + prestep = step; + } + + return scale; + }; + + return scale; +} + +function linear() { + var scale = continuous(); + + scale.copy = function() { + return copy$1(scale, linear()); + }; + + initRange.apply(scale, arguments); + + return linearish(scale); +} + +function identity$2(domain) { + var unknown; + + function scale(x) { + return x == null || isNaN(x = +x) ? unknown : x; + } + + scale.invert = scale; + + scale.domain = scale.range = function(_) { + return arguments.length ? (domain = Array.from(_, number$1), scale) : domain.slice(); + }; + + scale.unknown = function(_) { + return arguments.length ? (unknown = _, scale) : unknown; + }; + + scale.copy = function() { + return identity$2(domain).unknown(unknown); + }; + + domain = arguments.length ? Array.from(domain, number$1) : [0, 1]; + + return linearish(scale); +} + +function nice(domain, interval) { + domain = domain.slice(); + + var i0 = 0, + i1 = domain.length - 1, + x0 = domain[i0], + x1 = domain[i1], + t; + + if (x1 < x0) { + t = i0, i0 = i1, i1 = t; + t = x0, x0 = x1, x1 = t; + } + + domain[i0] = interval.floor(x0); + domain[i1] = interval.ceil(x1); + return domain; +} + +function transformLog(x) { + return Math.log(x); +} + +function transformExp(x) { + return Math.exp(x); +} + +function transformLogn(x) { + return -Math.log(-x); +} + +function transformExpn(x) { + return -Math.exp(-x); +} + +function pow10(x) { + return isFinite(x) ? +("1e" + x) : x < 0 ? 0 : x; +} + +function powp(base) { + return base === 10 ? pow10 + : base === Math.E ? Math.exp + : x => Math.pow(base, x); +} + +function logp(base) { + return base === Math.E ? Math.log + : base === 10 && Math.log10 + || base === 2 && Math.log2 + || (base = Math.log(base), x => Math.log(x) / base); +} + +function reflect(f) { + return (x, k) => -f(-x, k); +} + +function loggish(transform) { + const scale = transform(transformLog, transformExp); + const domain = scale.domain; + let base = 10; + let logs; + let pows; + + function rescale() { + logs = logp(base), pows = powp(base); + if (domain()[0] < 0) { + logs = reflect(logs), pows = reflect(pows); + transform(transformLogn, transformExpn); + } else { + transform(transformLog, transformExp); + } + return scale; + } + + scale.base = function(_) { + return arguments.length ? (base = +_, rescale()) : base; + }; + + scale.domain = function(_) { + return arguments.length ? (domain(_), rescale()) : domain(); + }; + + scale.ticks = count => { + const d = domain(); + let u = d[0]; + let v = d[d.length - 1]; + const r = v < u; + + if (r) ([u, v] = [v, u]); + + let i = logs(u); + let j = logs(v); + let k; + let t; + const n = count == null ? 10 : +count; + let z = []; + + if (!(base % 1) && j - i < n) { + i = Math.floor(i), j = Math.ceil(j); + if (u > 0) for (; i <= j; ++i) { + for (k = 1; k < base; ++k) { + t = i < 0 ? k / pows(-i) : k * pows(i); + if (t < u) continue; + if (t > v) break; + z.push(t); + } + } else for (; i <= j; ++i) { + for (k = base - 1; k >= 1; --k) { + t = i > 0 ? k / pows(-i) : k * pows(i); + if (t < u) continue; + if (t > v) break; + z.push(t); + } + } + if (z.length * 2 < n) z = ticks(u, v, n); + } else { + z = ticks(i, j, Math.min(j - i, n)).map(pows); + } + return r ? z.reverse() : z; + }; + + scale.tickFormat = (count, specifier) => { + if (count == null) count = 10; + if (specifier == null) specifier = base === 10 ? "s" : ","; + if (typeof specifier !== "function") { + if (!(base % 1) && (specifier = formatSpecifier(specifier)).precision == null) specifier.trim = true; + specifier = exports.format(specifier); + } + if (count === Infinity) return specifier; + const k = Math.max(1, base * count / scale.ticks().length); // TODO fast estimate? + return d => { + let i = d / pows(Math.round(logs(d))); + if (i * base < base - 0.5) i *= base; + return i <= k ? specifier(d) : ""; + }; + }; + + scale.nice = () => { + return domain(nice(domain(), { + floor: x => pows(Math.floor(logs(x))), + ceil: x => pows(Math.ceil(logs(x))) + })); + }; + + return scale; +} + +function log() { + const scale = loggish(transformer$2()).domain([1, 10]); + scale.copy = () => copy$1(scale, log()).base(scale.base()); + initRange.apply(scale, arguments); + return scale; +} + +function transformSymlog(c) { + return function(x) { + return Math.sign(x) * Math.log1p(Math.abs(x / c)); + }; +} + +function transformSymexp(c) { + return function(x) { + return Math.sign(x) * Math.expm1(Math.abs(x)) * c; + }; +} + +function symlogish(transform) { + var c = 1, scale = transform(transformSymlog(c), transformSymexp(c)); + + scale.constant = function(_) { + return arguments.length ? transform(transformSymlog(c = +_), transformSymexp(c)) : c; + }; + + return linearish(scale); +} + +function symlog() { + var scale = symlogish(transformer$2()); + + scale.copy = function() { + return copy$1(scale, symlog()).constant(scale.constant()); + }; + + return initRange.apply(scale, arguments); +} + +function transformPow(exponent) { + return function(x) { + return x < 0 ? -Math.pow(-x, exponent) : Math.pow(x, exponent); + }; +} + +function transformSqrt(x) { + return x < 0 ? -Math.sqrt(-x) : Math.sqrt(x); +} + +function transformSquare(x) { + return x < 0 ? -x * x : x * x; +} + +function powish(transform) { + var scale = transform(identity$3, identity$3), + exponent = 1; + + function rescale() { + return exponent === 1 ? transform(identity$3, identity$3) + : exponent === 0.5 ? transform(transformSqrt, transformSquare) + : transform(transformPow(exponent), transformPow(1 / exponent)); + } + + scale.exponent = function(_) { + return arguments.length ? (exponent = +_, rescale()) : exponent; + }; + + return linearish(scale); +} + +function pow() { + var scale = powish(transformer$2()); + + scale.copy = function() { + return copy$1(scale, pow()).exponent(scale.exponent()); + }; + + initRange.apply(scale, arguments); + + return scale; +} + +function sqrt$1() { + return pow.apply(null, arguments).exponent(0.5); +} + +function square$1(x) { + return Math.sign(x) * x * x; +} + +function unsquare(x) { + return Math.sign(x) * Math.sqrt(Math.abs(x)); +} + +function radial() { + var squared = continuous(), + range = [0, 1], + round = false, + unknown; + + function scale(x) { + var y = unsquare(squared(x)); + return isNaN(y) ? unknown : round ? Math.round(y) : y; + } + + scale.invert = function(y) { + return squared.invert(square$1(y)); + }; + + scale.domain = function(_) { + return arguments.length ? (squared.domain(_), scale) : squared.domain(); + }; + + scale.range = function(_) { + return arguments.length ? (squared.range((range = Array.from(_, number$1)).map(square$1)), scale) : range.slice(); + }; + + scale.rangeRound = function(_) { + return scale.range(_).round(true); + }; + + scale.round = function(_) { + return arguments.length ? (round = !!_, scale) : round; + }; + + scale.clamp = function(_) { + return arguments.length ? (squared.clamp(_), scale) : squared.clamp(); + }; + + scale.unknown = function(_) { + return arguments.length ? (unknown = _, scale) : unknown; + }; + + scale.copy = function() { + return radial(squared.domain(), range) + .round(round) + .clamp(squared.clamp()) + .unknown(unknown); + }; + + initRange.apply(scale, arguments); + + return linearish(scale); +} + +function quantile() { + var domain = [], + range = [], + thresholds = [], + unknown; + + function rescale() { + var i = 0, n = Math.max(1, range.length); + thresholds = new Array(n - 1); + while (++i < n) thresholds[i - 1] = quantileSorted(domain, i / n); + return scale; + } + + function scale(x) { + return x == null || isNaN(x = +x) ? unknown : range[bisect(thresholds, x)]; + } + + scale.invertExtent = function(y) { + var i = range.indexOf(y); + return i < 0 ? [NaN, NaN] : [ + i > 0 ? thresholds[i - 1] : domain[0], + i < thresholds.length ? thresholds[i] : domain[domain.length - 1] + ]; + }; + + scale.domain = function(_) { + if (!arguments.length) return domain.slice(); + domain = []; + for (let d of _) if (d != null && !isNaN(d = +d)) domain.push(d); + domain.sort(ascending$3); + return rescale(); + }; + + scale.range = function(_) { + return arguments.length ? (range = Array.from(_), rescale()) : range.slice(); + }; + + scale.unknown = function(_) { + return arguments.length ? (unknown = _, scale) : unknown; + }; + + scale.quantiles = function() { + return thresholds.slice(); + }; + + scale.copy = function() { + return quantile() + .domain(domain) + .range(range) + .unknown(unknown); + }; + + return initRange.apply(scale, arguments); +} + +function quantize() { + var x0 = 0, + x1 = 1, + n = 1, + domain = [0.5], + range = [0, 1], + unknown; + + function scale(x) { + return x != null && x <= x ? range[bisect(domain, x, 0, n)] : unknown; + } + + function rescale() { + var i = -1; + domain = new Array(n); + while (++i < n) domain[i] = ((i + 1) * x1 - (i - n) * x0) / (n + 1); + return scale; + } + + scale.domain = function(_) { + return arguments.length ? ([x0, x1] = _, x0 = +x0, x1 = +x1, rescale()) : [x0, x1]; + }; + + scale.range = function(_) { + return arguments.length ? (n = (range = Array.from(_)).length - 1, rescale()) : range.slice(); + }; + + scale.invertExtent = function(y) { + var i = range.indexOf(y); + return i < 0 ? [NaN, NaN] + : i < 1 ? [x0, domain[0]] + : i >= n ? [domain[n - 1], x1] + : [domain[i - 1], domain[i]]; + }; + + scale.unknown = function(_) { + return arguments.length ? (unknown = _, scale) : scale; + }; + + scale.thresholds = function() { + return domain.slice(); + }; + + scale.copy = function() { + return quantize() + .domain([x0, x1]) + .range(range) + .unknown(unknown); + }; + + return initRange.apply(linearish(scale), arguments); +} + +function threshold() { + var domain = [0.5], + range = [0, 1], + unknown, + n = 1; + + function scale(x) { + return x != null && x <= x ? range[bisect(domain, x, 0, n)] : unknown; + } + + scale.domain = function(_) { + return arguments.length ? (domain = Array.from(_), n = Math.min(domain.length, range.length - 1), scale) : domain.slice(); + }; + + scale.range = function(_) { + return arguments.length ? (range = Array.from(_), n = Math.min(domain.length, range.length - 1), scale) : range.slice(); + }; + + scale.invertExtent = function(y) { + var i = range.indexOf(y); + return [domain[i - 1], domain[i]]; + }; + + scale.unknown = function(_) { + return arguments.length ? (unknown = _, scale) : unknown; + }; + + scale.copy = function() { + return threshold() + .domain(domain) + .range(range) + .unknown(unknown); + }; + + return initRange.apply(scale, arguments); +} + +var t0 = new Date, + t1 = new Date; + +function newInterval(floori, offseti, count, field) { + + function interval(date) { + return floori(date = arguments.length === 0 ? new Date : new Date(+date)), date; + } + + interval.floor = function(date) { + return floori(date = new Date(+date)), date; + }; + + interval.ceil = function(date) { + return floori(date = new Date(date - 1)), offseti(date, 1), floori(date), date; + }; + + interval.round = function(date) { + var d0 = interval(date), + d1 = interval.ceil(date); + return date - d0 < d1 - date ? d0 : d1; + }; + + interval.offset = function(date, step) { + return offseti(date = new Date(+date), step == null ? 1 : Math.floor(step)), date; + }; + + interval.range = function(start, stop, step) { + var range = [], previous; + start = interval.ceil(start); + step = step == null ? 1 : Math.floor(step); + if (!(start < stop) || !(step > 0)) return range; // also handles Invalid Date + do range.push(previous = new Date(+start)), offseti(start, step), floori(start); + while (previous < start && start < stop); + return range; + }; + + interval.filter = function(test) { + return newInterval(function(date) { + if (date >= date) while (floori(date), !test(date)) date.setTime(date - 1); + }, function(date, step) { + if (date >= date) { + if (step < 0) while (++step <= 0) { + while (offseti(date, -1), !test(date)) {} // eslint-disable-line no-empty + } else while (--step >= 0) { + while (offseti(date, +1), !test(date)) {} // eslint-disable-line no-empty + } + } + }); + }; + + if (count) { + interval.count = function(start, end) { + t0.setTime(+start), t1.setTime(+end); + floori(t0), floori(t1); + return Math.floor(count(t0, t1)); + }; + + interval.every = function(step) { + step = Math.floor(step); + return !isFinite(step) || !(step > 0) ? null + : !(step > 1) ? interval + : interval.filter(field + ? function(d) { return field(d) % step === 0; } + : function(d) { return interval.count(0, d) % step === 0; }); + }; + } + + return interval; +} + +var millisecond = newInterval(function() { + // noop +}, function(date, step) { + date.setTime(+date + step); +}, function(start, end) { + return end - start; +}); + +// An optimized implementation for this simple case. +millisecond.every = function(k) { + k = Math.floor(k); + if (!isFinite(k) || !(k > 0)) return null; + if (!(k > 1)) return millisecond; + return newInterval(function(date) { + date.setTime(Math.floor(date / k) * k); + }, function(date, step) { + date.setTime(+date + step * k); + }, function(start, end) { + return (end - start) / k; + }); +}; + +var millisecond$1 = millisecond; +var milliseconds = millisecond.range; + +const durationSecond = 1000; +const durationMinute = durationSecond * 60; +const durationHour = durationMinute * 60; +const durationDay = durationHour * 24; +const durationWeek = durationDay * 7; +const durationMonth = durationDay * 30; +const durationYear = durationDay * 365; + +var second = newInterval(function(date) { + date.setTime(date - date.getMilliseconds()); +}, function(date, step) { + date.setTime(+date + step * durationSecond); +}, function(start, end) { + return (end - start) / durationSecond; +}, function(date) { + return date.getUTCSeconds(); +}); + +var utcSecond = second; +var seconds = second.range; + +var minute = newInterval(function(date) { + date.setTime(date - date.getMilliseconds() - date.getSeconds() * durationSecond); +}, function(date, step) { + date.setTime(+date + step * durationMinute); +}, function(start, end) { + return (end - start) / durationMinute; +}, function(date) { + return date.getMinutes(); +}); + +var timeMinute = minute; +var minutes = minute.range; + +var hour = newInterval(function(date) { + date.setTime(date - date.getMilliseconds() - date.getSeconds() * durationSecond - date.getMinutes() * durationMinute); +}, function(date, step) { + date.setTime(+date + step * durationHour); +}, function(start, end) { + return (end - start) / durationHour; +}, function(date) { + return date.getHours(); +}); + +var timeHour = hour; +var hours = hour.range; + +var day = newInterval( + date => date.setHours(0, 0, 0, 0), + (date, step) => date.setDate(date.getDate() + step), + (start, end) => (end - start - (end.getTimezoneOffset() - start.getTimezoneOffset()) * durationMinute) / durationDay, + date => date.getDate() - 1 +); + +var timeDay = day; +var days = day.range; + +function weekday(i) { + return newInterval(function(date) { + date.setDate(date.getDate() - (date.getDay() + 7 - i) % 7); + date.setHours(0, 0, 0, 0); + }, function(date, step) { + date.setDate(date.getDate() + step * 7); + }, function(start, end) { + return (end - start - (end.getTimezoneOffset() - start.getTimezoneOffset()) * durationMinute) / durationWeek; + }); +} + +var sunday = weekday(0); +var monday = weekday(1); +var tuesday = weekday(2); +var wednesday = weekday(3); +var thursday = weekday(4); +var friday = weekday(5); +var saturday = weekday(6); + +var sundays = sunday.range; +var mondays = monday.range; +var tuesdays = tuesday.range; +var wednesdays = wednesday.range; +var thursdays = thursday.range; +var fridays = friday.range; +var saturdays = saturday.range; + +var month = newInterval(function(date) { + date.setDate(1); + date.setHours(0, 0, 0, 0); +}, function(date, step) { + date.setMonth(date.getMonth() + step); +}, function(start, end) { + return end.getMonth() - start.getMonth() + (end.getFullYear() - start.getFullYear()) * 12; +}, function(date) { + return date.getMonth(); +}); + +var timeMonth = month; +var months = month.range; + +var year = newInterval(function(date) { + date.setMonth(0, 1); + date.setHours(0, 0, 0, 0); +}, function(date, step) { + date.setFullYear(date.getFullYear() + step); +}, function(start, end) { + return end.getFullYear() - start.getFullYear(); +}, function(date) { + return date.getFullYear(); +}); + +// An optimized implementation for this simple case. +year.every = function(k) { + return !isFinite(k = Math.floor(k)) || !(k > 0) ? null : newInterval(function(date) { + date.setFullYear(Math.floor(date.getFullYear() / k) * k); + date.setMonth(0, 1); + date.setHours(0, 0, 0, 0); + }, function(date, step) { + date.setFullYear(date.getFullYear() + step * k); + }); +}; + +var timeYear = year; +var years = year.range; + +var utcMinute = newInterval(function(date) { + date.setUTCSeconds(0, 0); +}, function(date, step) { + date.setTime(+date + step * durationMinute); +}, function(start, end) { + return (end - start) / durationMinute; +}, function(date) { + return date.getUTCMinutes(); +}); + +var utcMinute$1 = utcMinute; +var utcMinutes = utcMinute.range; + +var utcHour = newInterval(function(date) { + date.setUTCMinutes(0, 0, 0); +}, function(date, step) { + date.setTime(+date + step * durationHour); +}, function(start, end) { + return (end - start) / durationHour; +}, function(date) { + return date.getUTCHours(); +}); + +var utcHour$1 = utcHour; +var utcHours = utcHour.range; + +var utcDay = newInterval(function(date) { + date.setUTCHours(0, 0, 0, 0); +}, function(date, step) { + date.setUTCDate(date.getUTCDate() + step); +}, function(start, end) { + return (end - start) / durationDay; +}, function(date) { + return date.getUTCDate() - 1; +}); + +var utcDay$1 = utcDay; +var utcDays = utcDay.range; + +function utcWeekday(i) { + return newInterval(function(date) { + date.setUTCDate(date.getUTCDate() - (date.getUTCDay() + 7 - i) % 7); + date.setUTCHours(0, 0, 0, 0); + }, function(date, step) { + date.setUTCDate(date.getUTCDate() + step * 7); + }, function(start, end) { + return (end - start) / durationWeek; + }); +} + +var utcSunday = utcWeekday(0); +var utcMonday = utcWeekday(1); +var utcTuesday = utcWeekday(2); +var utcWednesday = utcWeekday(3); +var utcThursday = utcWeekday(4); +var utcFriday = utcWeekday(5); +var utcSaturday = utcWeekday(6); + +var utcSundays = utcSunday.range; +var utcMondays = utcMonday.range; +var utcTuesdays = utcTuesday.range; +var utcWednesdays = utcWednesday.range; +var utcThursdays = utcThursday.range; +var utcFridays = utcFriday.range; +var utcSaturdays = utcSaturday.range; + +var utcMonth = newInterval(function(date) { + date.setUTCDate(1); + date.setUTCHours(0, 0, 0, 0); +}, function(date, step) { + date.setUTCMonth(date.getUTCMonth() + step); +}, function(start, end) { + return end.getUTCMonth() - start.getUTCMonth() + (end.getUTCFullYear() - start.getUTCFullYear()) * 12; +}, function(date) { + return date.getUTCMonth(); +}); + +var utcMonth$1 = utcMonth; +var utcMonths = utcMonth.range; + +var utcYear = newInterval(function(date) { + date.setUTCMonth(0, 1); + date.setUTCHours(0, 0, 0, 0); +}, function(date, step) { + date.setUTCFullYear(date.getUTCFullYear() + step); +}, function(start, end) { + return end.getUTCFullYear() - start.getUTCFullYear(); +}, function(date) { + return date.getUTCFullYear(); +}); + +// An optimized implementation for this simple case. +utcYear.every = function(k) { + return !isFinite(k = Math.floor(k)) || !(k > 0) ? null : newInterval(function(date) { + date.setUTCFullYear(Math.floor(date.getUTCFullYear() / k) * k); + date.setUTCMonth(0, 1); + date.setUTCHours(0, 0, 0, 0); + }, function(date, step) { + date.setUTCFullYear(date.getUTCFullYear() + step * k); + }); +}; + +var utcYear$1 = utcYear; +var utcYears = utcYear.range; + +function ticker(year, month, week, day, hour, minute) { + + const tickIntervals = [ + [utcSecond, 1, durationSecond], + [utcSecond, 5, 5 * durationSecond], + [utcSecond, 15, 15 * durationSecond], + [utcSecond, 30, 30 * durationSecond], + [minute, 1, durationMinute], + [minute, 5, 5 * durationMinute], + [minute, 15, 15 * durationMinute], + [minute, 30, 30 * durationMinute], + [ hour, 1, durationHour ], + [ hour, 3, 3 * durationHour ], + [ hour, 6, 6 * durationHour ], + [ hour, 12, 12 * durationHour ], + [ day, 1, durationDay ], + [ day, 2, 2 * durationDay ], + [ week, 1, durationWeek ], + [ month, 1, durationMonth ], + [ month, 3, 3 * durationMonth ], + [ year, 1, durationYear ] + ]; + + function ticks(start, stop, count) { + const reverse = stop < start; + if (reverse) [start, stop] = [stop, start]; + const interval = count && typeof count.range === "function" ? count : tickInterval(start, stop, count); + const ticks = interval ? interval.range(start, +stop + 1) : []; // inclusive stop + return reverse ? ticks.reverse() : ticks; + } + + function tickInterval(start, stop, count) { + const target = Math.abs(stop - start) / count; + const i = bisector(([,, step]) => step).right(tickIntervals, target); + if (i === tickIntervals.length) return year.every(tickStep(start / durationYear, stop / durationYear, count)); + if (i === 0) return millisecond$1.every(Math.max(tickStep(start, stop, count), 1)); + const [t, step] = tickIntervals[target / tickIntervals[i - 1][2] < tickIntervals[i][2] / target ? i - 1 : i]; + return t.every(step); + } + + return [ticks, tickInterval]; +} + +const [utcTicks, utcTickInterval] = ticker(utcYear$1, utcMonth$1, utcSunday, utcDay$1, utcHour$1, utcMinute$1); +const [timeTicks, timeTickInterval] = ticker(timeYear, timeMonth, sunday, timeDay, timeHour, timeMinute); + +function localDate(d) { + if (0 <= d.y && d.y < 100) { + var date = new Date(-1, d.m, d.d, d.H, d.M, d.S, d.L); + date.setFullYear(d.y); + return date; + } + return new Date(d.y, d.m, d.d, d.H, d.M, d.S, d.L); +} + +function utcDate(d) { + if (0 <= d.y && d.y < 100) { + var date = new Date(Date.UTC(-1, d.m, d.d, d.H, d.M, d.S, d.L)); + date.setUTCFullYear(d.y); + return date; + } + return new Date(Date.UTC(d.y, d.m, d.d, d.H, d.M, d.S, d.L)); +} + +function newDate(y, m, d) { + return {y: y, m: m, d: d, H: 0, M: 0, S: 0, L: 0}; +} + +function formatLocale(locale) { + var locale_dateTime = locale.dateTime, + locale_date = locale.date, + locale_time = locale.time, + locale_periods = locale.periods, + locale_weekdays = locale.days, + locale_shortWeekdays = locale.shortDays, + locale_months = locale.months, + locale_shortMonths = locale.shortMonths; + + var periodRe = formatRe(locale_periods), + periodLookup = formatLookup(locale_periods), + weekdayRe = formatRe(locale_weekdays), + weekdayLookup = formatLookup(locale_weekdays), + shortWeekdayRe = formatRe(locale_shortWeekdays), + shortWeekdayLookup = formatLookup(locale_shortWeekdays), + monthRe = formatRe(locale_months), + monthLookup = formatLookup(locale_months), + shortMonthRe = formatRe(locale_shortMonths), + shortMonthLookup = formatLookup(locale_shortMonths); + + var formats = { + "a": formatShortWeekday, + "A": formatWeekday, + "b": formatShortMonth, + "B": formatMonth, + "c": null, + "d": formatDayOfMonth, + "e": formatDayOfMonth, + "f": formatMicroseconds, + "g": formatYearISO, + "G": formatFullYearISO, + "H": formatHour24, + "I": formatHour12, + "j": formatDayOfYear, + "L": formatMilliseconds, + "m": formatMonthNumber, + "M": formatMinutes, + "p": formatPeriod, + "q": formatQuarter, + "Q": formatUnixTimestamp, + "s": formatUnixTimestampSeconds, + "S": formatSeconds, + "u": formatWeekdayNumberMonday, + "U": formatWeekNumberSunday, + "V": formatWeekNumberISO, + "w": formatWeekdayNumberSunday, + "W": formatWeekNumberMonday, + "x": null, + "X": null, + "y": formatYear, + "Y": formatFullYear, + "Z": formatZone, + "%": formatLiteralPercent + }; + + var utcFormats = { + "a": formatUTCShortWeekday, + "A": formatUTCWeekday, + "b": formatUTCShortMonth, + "B": formatUTCMonth, + "c": null, + "d": formatUTCDayOfMonth, + "e": formatUTCDayOfMonth, + "f": formatUTCMicroseconds, + "g": formatUTCYearISO, + "G": formatUTCFullYearISO, + "H": formatUTCHour24, + "I": formatUTCHour12, + "j": formatUTCDayOfYear, + "L": formatUTCMilliseconds, + "m": formatUTCMonthNumber, + "M": formatUTCMinutes, + "p": formatUTCPeriod, + "q": formatUTCQuarter, + "Q": formatUnixTimestamp, + "s": formatUnixTimestampSeconds, + "S": formatUTCSeconds, + "u": formatUTCWeekdayNumberMonday, + "U": formatUTCWeekNumberSunday, + "V": formatUTCWeekNumberISO, + "w": formatUTCWeekdayNumberSunday, + "W": formatUTCWeekNumberMonday, + "x": null, + "X": null, + "y": formatUTCYear, + "Y": formatUTCFullYear, + "Z": formatUTCZone, + "%": formatLiteralPercent + }; + + var parses = { + "a": parseShortWeekday, + "A": parseWeekday, + "b": parseShortMonth, + "B": parseMonth, + "c": parseLocaleDateTime, + "d": parseDayOfMonth, + "e": parseDayOfMonth, + "f": parseMicroseconds, + "g": parseYear, + "G": parseFullYear, + "H": parseHour24, + "I": parseHour24, + "j": parseDayOfYear, + "L": parseMilliseconds, + "m": parseMonthNumber, + "M": parseMinutes, + "p": parsePeriod, + "q": parseQuarter, + "Q": parseUnixTimestamp, + "s": parseUnixTimestampSeconds, + "S": parseSeconds, + "u": parseWeekdayNumberMonday, + "U": parseWeekNumberSunday, + "V": parseWeekNumberISO, + "w": parseWeekdayNumberSunday, + "W": parseWeekNumberMonday, + "x": parseLocaleDate, + "X": parseLocaleTime, + "y": parseYear, + "Y": parseFullYear, + "Z": parseZone, + "%": parseLiteralPercent + }; + + // These recursive directive definitions must be deferred. + formats.x = newFormat(locale_date, formats); + formats.X = newFormat(locale_time, formats); + formats.c = newFormat(locale_dateTime, formats); + utcFormats.x = newFormat(locale_date, utcFormats); + utcFormats.X = newFormat(locale_time, utcFormats); + utcFormats.c = newFormat(locale_dateTime, utcFormats); + + function newFormat(specifier, formats) { + return function(date) { + var string = [], + i = -1, + j = 0, + n = specifier.length, + c, + pad, + format; + + if (!(date instanceof Date)) date = new Date(+date); + + while (++i < n) { + if (specifier.charCodeAt(i) === 37) { + string.push(specifier.slice(j, i)); + if ((pad = pads[c = specifier.charAt(++i)]) != null) c = specifier.charAt(++i); + else pad = c === "e" ? " " : "0"; + if (format = formats[c]) c = format(date, pad); + string.push(c); + j = i + 1; + } + } + + string.push(specifier.slice(j, i)); + return string.join(""); + }; + } + + function newParse(specifier, Z) { + return function(string) { + var d = newDate(1900, undefined, 1), + i = parseSpecifier(d, specifier, string += "", 0), + week, day; + if (i != string.length) return null; + + // If a UNIX timestamp is specified, return it. + if ("Q" in d) return new Date(d.Q); + if ("s" in d) return new Date(d.s * 1000 + ("L" in d ? d.L : 0)); + + // If this is utcParse, never use the local timezone. + if (Z && !("Z" in d)) d.Z = 0; + + // The am-pm flag is 0 for AM, and 1 for PM. + if ("p" in d) d.H = d.H % 12 + d.p * 12; + + // If the month was not specified, inherit from the quarter. + if (d.m === undefined) d.m = "q" in d ? d.q : 0; + + // Convert day-of-week and week-of-year to day-of-year. + if ("V" in d) { + if (d.V < 1 || d.V > 53) return null; + if (!("w" in d)) d.w = 1; + if ("Z" in d) { + week = utcDate(newDate(d.y, 0, 1)), day = week.getUTCDay(); + week = day > 4 || day === 0 ? utcMonday.ceil(week) : utcMonday(week); + week = utcDay$1.offset(week, (d.V - 1) * 7); + d.y = week.getUTCFullYear(); + d.m = week.getUTCMonth(); + d.d = week.getUTCDate() + (d.w + 6) % 7; + } else { + week = localDate(newDate(d.y, 0, 1)), day = week.getDay(); + week = day > 4 || day === 0 ? monday.ceil(week) : monday(week); + week = timeDay.offset(week, (d.V - 1) * 7); + d.y = week.getFullYear(); + d.m = week.getMonth(); + d.d = week.getDate() + (d.w + 6) % 7; + } + } else if ("W" in d || "U" in d) { + if (!("w" in d)) d.w = "u" in d ? d.u % 7 : "W" in d ? 1 : 0; + day = "Z" in d ? utcDate(newDate(d.y, 0, 1)).getUTCDay() : localDate(newDate(d.y, 0, 1)).getDay(); + d.m = 0; + d.d = "W" in d ? (d.w + 6) % 7 + d.W * 7 - (day + 5) % 7 : d.w + d.U * 7 - (day + 6) % 7; + } + + // If a time zone is specified, all fields are interpreted as UTC and then + // offset according to the specified time zone. + if ("Z" in d) { + d.H += d.Z / 100 | 0; + d.M += d.Z % 100; + return utcDate(d); + } + + // Otherwise, all fields are in local time. + return localDate(d); + }; + } + + function parseSpecifier(d, specifier, string, j) { + var i = 0, + n = specifier.length, + m = string.length, + c, + parse; + + while (i < n) { + if (j >= m) return -1; + c = specifier.charCodeAt(i++); + if (c === 37) { + c = specifier.charAt(i++); + parse = parses[c in pads ? specifier.charAt(i++) : c]; + if (!parse || ((j = parse(d, string, j)) < 0)) return -1; + } else if (c != string.charCodeAt(j++)) { + return -1; + } + } + + return j; + } + + function parsePeriod(d, string, i) { + var n = periodRe.exec(string.slice(i)); + return n ? (d.p = periodLookup.get(n[0].toLowerCase()), i + n[0].length) : -1; + } + + function parseShortWeekday(d, string, i) { + var n = shortWeekdayRe.exec(string.slice(i)); + return n ? (d.w = shortWeekdayLookup.get(n[0].toLowerCase()), i + n[0].length) : -1; + } + + function parseWeekday(d, string, i) { + var n = weekdayRe.exec(string.slice(i)); + return n ? (d.w = weekdayLookup.get(n[0].toLowerCase()), i + n[0].length) : -1; + } + + function parseShortMonth(d, string, i) { + var n = shortMonthRe.exec(string.slice(i)); + return n ? (d.m = shortMonthLookup.get(n[0].toLowerCase()), i + n[0].length) : -1; + } + + function parseMonth(d, string, i) { + var n = monthRe.exec(string.slice(i)); + return n ? (d.m = monthLookup.get(n[0].toLowerCase()), i + n[0].length) : -1; + } + + function parseLocaleDateTime(d, string, i) { + return parseSpecifier(d, locale_dateTime, string, i); + } + + function parseLocaleDate(d, string, i) { + return parseSpecifier(d, locale_date, string, i); + } + + function parseLocaleTime(d, string, i) { + return parseSpecifier(d, locale_time, string, i); + } + + function formatShortWeekday(d) { + return locale_shortWeekdays[d.getDay()]; + } + + function formatWeekday(d) { + return locale_weekdays[d.getDay()]; + } + + function formatShortMonth(d) { + return locale_shortMonths[d.getMonth()]; + } + + function formatMonth(d) { + return locale_months[d.getMonth()]; + } + + function formatPeriod(d) { + return locale_periods[+(d.getHours() >= 12)]; + } + + function formatQuarter(d) { + return 1 + ~~(d.getMonth() / 3); + } + + function formatUTCShortWeekday(d) { + return locale_shortWeekdays[d.getUTCDay()]; + } + + function formatUTCWeekday(d) { + return locale_weekdays[d.getUTCDay()]; + } + + function formatUTCShortMonth(d) { + return locale_shortMonths[d.getUTCMonth()]; + } + + function formatUTCMonth(d) { + return locale_months[d.getUTCMonth()]; + } + + function formatUTCPeriod(d) { + return locale_periods[+(d.getUTCHours() >= 12)]; + } + + function formatUTCQuarter(d) { + return 1 + ~~(d.getUTCMonth() / 3); + } + + return { + format: function(specifier) { + var f = newFormat(specifier += "", formats); + f.toString = function() { return specifier; }; + return f; + }, + parse: function(specifier) { + var p = newParse(specifier += "", false); + p.toString = function() { return specifier; }; + return p; + }, + utcFormat: function(specifier) { + var f = newFormat(specifier += "", utcFormats); + f.toString = function() { return specifier; }; + return f; + }, + utcParse: function(specifier) { + var p = newParse(specifier += "", true); + p.toString = function() { return specifier; }; + return p; + } + }; +} + +var pads = {"-": "", "_": " ", "0": "0"}, + numberRe = /^\s*\d+/, // note: ignores next directive + percentRe = /^%/, + requoteRe = /[\\^$*+?|[\]().{}]/g; + +function pad(value, fill, width) { + var sign = value < 0 ? "-" : "", + string = (sign ? -value : value) + "", + length = string.length; + return sign + (length < width ? new Array(width - length + 1).join(fill) + string : string); +} + +function requote(s) { + return s.replace(requoteRe, "\\$&"); +} + +function formatRe(names) { + return new RegExp("^(?:" + names.map(requote).join("|") + ")", "i"); +} + +function formatLookup(names) { + return new Map(names.map((name, i) => [name.toLowerCase(), i])); +} + +function parseWeekdayNumberSunday(d, string, i) { + var n = numberRe.exec(string.slice(i, i + 1)); + return n ? (d.w = +n[0], i + n[0].length) : -1; +} + +function parseWeekdayNumberMonday(d, string, i) { + var n = numberRe.exec(string.slice(i, i + 1)); + return n ? (d.u = +n[0], i + n[0].length) : -1; +} + +function parseWeekNumberSunday(d, string, i) { + var n = numberRe.exec(string.slice(i, i + 2)); + return n ? (d.U = +n[0], i + n[0].length) : -1; +} + +function parseWeekNumberISO(d, string, i) { + var n = numberRe.exec(string.slice(i, i + 2)); + return n ? (d.V = +n[0], i + n[0].length) : -1; +} + +function parseWeekNumberMonday(d, string, i) { + var n = numberRe.exec(string.slice(i, i + 2)); + return n ? (d.W = +n[0], i + n[0].length) : -1; +} + +function parseFullYear(d, string, i) { + var n = numberRe.exec(string.slice(i, i + 4)); + return n ? (d.y = +n[0], i + n[0].length) : -1; +} + +function parseYear(d, string, i) { + var n = numberRe.exec(string.slice(i, i + 2)); + return n ? (d.y = +n[0] + (+n[0] > 68 ? 1900 : 2000), i + n[0].length) : -1; +} + +function parseZone(d, string, i) { + var n = /^(Z)|([+-]\d\d)(?::?(\d\d))?/.exec(string.slice(i, i + 6)); + return n ? (d.Z = n[1] ? 0 : -(n[2] + (n[3] || "00")), i + n[0].length) : -1; +} + +function parseQuarter(d, string, i) { + var n = numberRe.exec(string.slice(i, i + 1)); + return n ? (d.q = n[0] * 3 - 3, i + n[0].length) : -1; +} + +function parseMonthNumber(d, string, i) { + var n = numberRe.exec(string.slice(i, i + 2)); + return n ? (d.m = n[0] - 1, i + n[0].length) : -1; +} + +function parseDayOfMonth(d, string, i) { + var n = numberRe.exec(string.slice(i, i + 2)); + return n ? (d.d = +n[0], i + n[0].length) : -1; +} + +function parseDayOfYear(d, string, i) { + var n = numberRe.exec(string.slice(i, i + 3)); + return n ? (d.m = 0, d.d = +n[0], i + n[0].length) : -1; +} + +function parseHour24(d, string, i) { + var n = numberRe.exec(string.slice(i, i + 2)); + return n ? (d.H = +n[0], i + n[0].length) : -1; +} + +function parseMinutes(d, string, i) { + var n = numberRe.exec(string.slice(i, i + 2)); + return n ? (d.M = +n[0], i + n[0].length) : -1; +} + +function parseSeconds(d, string, i) { + var n = numberRe.exec(string.slice(i, i + 2)); + return n ? (d.S = +n[0], i + n[0].length) : -1; +} + +function parseMilliseconds(d, string, i) { + var n = numberRe.exec(string.slice(i, i + 3)); + return n ? (d.L = +n[0], i + n[0].length) : -1; +} + +function parseMicroseconds(d, string, i) { + var n = numberRe.exec(string.slice(i, i + 6)); + return n ? (d.L = Math.floor(n[0] / 1000), i + n[0].length) : -1; +} + +function parseLiteralPercent(d, string, i) { + var n = percentRe.exec(string.slice(i, i + 1)); + return n ? i + n[0].length : -1; +} + +function parseUnixTimestamp(d, string, i) { + var n = numberRe.exec(string.slice(i)); + return n ? (d.Q = +n[0], i + n[0].length) : -1; +} + +function parseUnixTimestampSeconds(d, string, i) { + var n = numberRe.exec(string.slice(i)); + return n ? (d.s = +n[0], i + n[0].length) : -1; +} + +function formatDayOfMonth(d, p) { + return pad(d.getDate(), p, 2); +} + +function formatHour24(d, p) { + return pad(d.getHours(), p, 2); +} + +function formatHour12(d, p) { + return pad(d.getHours() % 12 || 12, p, 2); +} + +function formatDayOfYear(d, p) { + return pad(1 + timeDay.count(timeYear(d), d), p, 3); +} + +function formatMilliseconds(d, p) { + return pad(d.getMilliseconds(), p, 3); +} + +function formatMicroseconds(d, p) { + return formatMilliseconds(d, p) + "000"; +} + +function formatMonthNumber(d, p) { + return pad(d.getMonth() + 1, p, 2); +} + +function formatMinutes(d, p) { + return pad(d.getMinutes(), p, 2); +} + +function formatSeconds(d, p) { + return pad(d.getSeconds(), p, 2); +} + +function formatWeekdayNumberMonday(d) { + var day = d.getDay(); + return day === 0 ? 7 : day; +} + +function formatWeekNumberSunday(d, p) { + return pad(sunday.count(timeYear(d) - 1, d), p, 2); +} + +function dISO(d) { + var day = d.getDay(); + return (day >= 4 || day === 0) ? thursday(d) : thursday.ceil(d); +} + +function formatWeekNumberISO(d, p) { + d = dISO(d); + return pad(thursday.count(timeYear(d), d) + (timeYear(d).getDay() === 4), p, 2); +} + +function formatWeekdayNumberSunday(d) { + return d.getDay(); +} + +function formatWeekNumberMonday(d, p) { + return pad(monday.count(timeYear(d) - 1, d), p, 2); +} + +function formatYear(d, p) { + return pad(d.getFullYear() % 100, p, 2); +} + +function formatYearISO(d, p) { + d = dISO(d); + return pad(d.getFullYear() % 100, p, 2); +} + +function formatFullYear(d, p) { + return pad(d.getFullYear() % 10000, p, 4); +} + +function formatFullYearISO(d, p) { + var day = d.getDay(); + d = (day >= 4 || day === 0) ? thursday(d) : thursday.ceil(d); + return pad(d.getFullYear() % 10000, p, 4); +} + +function formatZone(d) { + var z = d.getTimezoneOffset(); + return (z > 0 ? "-" : (z *= -1, "+")) + + pad(z / 60 | 0, "0", 2) + + pad(z % 60, "0", 2); +} + +function formatUTCDayOfMonth(d, p) { + return pad(d.getUTCDate(), p, 2); +} + +function formatUTCHour24(d, p) { + return pad(d.getUTCHours(), p, 2); +} + +function formatUTCHour12(d, p) { + return pad(d.getUTCHours() % 12 || 12, p, 2); +} + +function formatUTCDayOfYear(d, p) { + return pad(1 + utcDay$1.count(utcYear$1(d), d), p, 3); +} + +function formatUTCMilliseconds(d, p) { + return pad(d.getUTCMilliseconds(), p, 3); +} + +function formatUTCMicroseconds(d, p) { + return formatUTCMilliseconds(d, p) + "000"; +} + +function formatUTCMonthNumber(d, p) { + return pad(d.getUTCMonth() + 1, p, 2); +} + +function formatUTCMinutes(d, p) { + return pad(d.getUTCMinutes(), p, 2); +} + +function formatUTCSeconds(d, p) { + return pad(d.getUTCSeconds(), p, 2); +} + +function formatUTCWeekdayNumberMonday(d) { + var dow = d.getUTCDay(); + return dow === 0 ? 7 : dow; +} + +function formatUTCWeekNumberSunday(d, p) { + return pad(utcSunday.count(utcYear$1(d) - 1, d), p, 2); +} + +function UTCdISO(d) { + var day = d.getUTCDay(); + return (day >= 4 || day === 0) ? utcThursday(d) : utcThursday.ceil(d); +} + +function formatUTCWeekNumberISO(d, p) { + d = UTCdISO(d); + return pad(utcThursday.count(utcYear$1(d), d) + (utcYear$1(d).getUTCDay() === 4), p, 2); +} + +function formatUTCWeekdayNumberSunday(d) { + return d.getUTCDay(); +} + +function formatUTCWeekNumberMonday(d, p) { + return pad(utcMonday.count(utcYear$1(d) - 1, d), p, 2); +} + +function formatUTCYear(d, p) { + return pad(d.getUTCFullYear() % 100, p, 2); +} + +function formatUTCYearISO(d, p) { + d = UTCdISO(d); + return pad(d.getUTCFullYear() % 100, p, 2); +} + +function formatUTCFullYear(d, p) { + return pad(d.getUTCFullYear() % 10000, p, 4); +} + +function formatUTCFullYearISO(d, p) { + var day = d.getUTCDay(); + d = (day >= 4 || day === 0) ? utcThursday(d) : utcThursday.ceil(d); + return pad(d.getUTCFullYear() % 10000, p, 4); +} + +function formatUTCZone() { + return "+0000"; +} + +function formatLiteralPercent() { + return "%"; +} + +function formatUnixTimestamp(d) { + return +d; +} + +function formatUnixTimestampSeconds(d) { + return Math.floor(+d / 1000); +} + +var locale; +exports.timeFormat = void 0; +exports.timeParse = void 0; +exports.utcFormat = void 0; +exports.utcParse = void 0; + +defaultLocale({ + 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"] +}); + +function defaultLocale(definition) { + locale = formatLocale(definition); + exports.timeFormat = locale.format; + exports.timeParse = locale.parse; + exports.utcFormat = locale.utcFormat; + exports.utcParse = locale.utcParse; + return locale; +} + +var isoSpecifier = "%Y-%m-%dT%H:%M:%S.%LZ"; + +function formatIsoNative(date) { + return date.toISOString(); +} + +var formatIso = Date.prototype.toISOString + ? formatIsoNative + : exports.utcFormat(isoSpecifier); + +var formatIso$1 = formatIso; + +function parseIsoNative(string) { + var date = new Date(string); + return isNaN(date) ? null : date; +} + +var parseIso = +new Date("2000-01-01T00:00:00.000Z") + ? parseIsoNative + : exports.utcParse(isoSpecifier); + +var parseIso$1 = parseIso; + +function date(t) { + return new Date(t); +} + +function number(t) { + return t instanceof Date ? +t : +new Date(+t); +} + +function calendar(ticks, tickInterval, year, month, week, day, hour, minute, second, format) { + var scale = continuous(), + invert = scale.invert, + domain = scale.domain; + + var formatMillisecond = format(".%L"), + formatSecond = format(":%S"), + formatMinute = format("%I:%M"), + formatHour = format("%I %p"), + formatDay = format("%a %d"), + formatWeek = format("%b %d"), + formatMonth = format("%B"), + formatYear = format("%Y"); + + function tickFormat(date) { + return (second(date) < date ? formatMillisecond + : minute(date) < date ? formatSecond + : hour(date) < date ? formatMinute + : day(date) < date ? formatHour + : month(date) < date ? (week(date) < date ? formatDay : formatWeek) + : year(date) < date ? formatMonth + : formatYear)(date); + } + + scale.invert = function(y) { + return new Date(invert(y)); + }; + + scale.domain = function(_) { + return arguments.length ? domain(Array.from(_, number)) : domain().map(date); + }; + + scale.ticks = function(interval) { + var d = domain(); + return ticks(d[0], d[d.length - 1], interval == null ? 10 : interval); + }; + + scale.tickFormat = function(count, specifier) { + return specifier == null ? tickFormat : format(specifier); + }; + + scale.nice = function(interval) { + var d = domain(); + if (!interval || typeof interval.range !== "function") interval = tickInterval(d[0], d[d.length - 1], interval == null ? 10 : interval); + return interval ? domain(nice(d, interval)) : scale; + }; + + scale.copy = function() { + return copy$1(scale, calendar(ticks, tickInterval, year, month, week, day, hour, minute, second, format)); + }; + + return scale; +} + +function time() { + return initRange.apply(calendar(timeTicks, timeTickInterval, timeYear, timeMonth, sunday, timeDay, timeHour, timeMinute, utcSecond, exports.timeFormat).domain([new Date(2000, 0, 1), new Date(2000, 0, 2)]), arguments); +} + +function utcTime() { + return initRange.apply(calendar(utcTicks, utcTickInterval, utcYear$1, utcMonth$1, utcSunday, utcDay$1, utcHour$1, utcMinute$1, utcSecond, exports.utcFormat).domain([Date.UTC(2000, 0, 1), Date.UTC(2000, 0, 2)]), arguments); +} + +function transformer$1() { + var x0 = 0, + x1 = 1, + t0, + t1, + k10, + transform, + interpolator = identity$3, + clamp = false, + unknown; + + function scale(x) { + return x == null || isNaN(x = +x) ? unknown : interpolator(k10 === 0 ? 0.5 : (x = (transform(x) - t0) * k10, clamp ? Math.max(0, Math.min(1, x)) : x)); + } + + scale.domain = function(_) { + return arguments.length ? ([x0, x1] = _, t0 = transform(x0 = +x0), t1 = transform(x1 = +x1), k10 = t0 === t1 ? 0 : 1 / (t1 - t0), scale) : [x0, x1]; + }; + + scale.clamp = function(_) { + return arguments.length ? (clamp = !!_, scale) : clamp; + }; + + scale.interpolator = function(_) { + return arguments.length ? (interpolator = _, scale) : interpolator; + }; + + function range(interpolate) { + return function(_) { + var r0, r1; + return arguments.length ? ([r0, r1] = _, interpolator = interpolate(r0, r1), scale) : [interpolator(0), interpolator(1)]; + }; + } + + scale.range = range(interpolate$2); + + scale.rangeRound = range(interpolateRound); + + scale.unknown = function(_) { + return arguments.length ? (unknown = _, scale) : unknown; + }; + + return function(t) { + transform = t, t0 = t(x0), t1 = t(x1), k10 = t0 === t1 ? 0 : 1 / (t1 - t0); + return scale; + }; +} + +function copy(source, target) { + return target + .domain(source.domain()) + .interpolator(source.interpolator()) + .clamp(source.clamp()) + .unknown(source.unknown()); +} + +function sequential() { + var scale = linearish(transformer$1()(identity$3)); + + scale.copy = function() { + return copy(scale, sequential()); + }; + + return initInterpolator.apply(scale, arguments); +} + +function sequentialLog() { + var scale = loggish(transformer$1()).domain([1, 10]); + + scale.copy = function() { + return copy(scale, sequentialLog()).base(scale.base()); + }; + + return initInterpolator.apply(scale, arguments); +} + +function sequentialSymlog() { + var scale = symlogish(transformer$1()); + + scale.copy = function() { + return copy(scale, sequentialSymlog()).constant(scale.constant()); + }; + + return initInterpolator.apply(scale, arguments); +} + +function sequentialPow() { + var scale = powish(transformer$1()); + + scale.copy = function() { + return copy(scale, sequentialPow()).exponent(scale.exponent()); + }; + + return initInterpolator.apply(scale, arguments); +} + +function sequentialSqrt() { + return sequentialPow.apply(null, arguments).exponent(0.5); +} + +function sequentialQuantile() { + var domain = [], + interpolator = identity$3; + + function scale(x) { + if (x != null && !isNaN(x = +x)) return interpolator((bisect(domain, x, 1) - 1) / (domain.length - 1)); + } + + scale.domain = function(_) { + if (!arguments.length) return domain.slice(); + domain = []; + for (let d of _) if (d != null && !isNaN(d = +d)) domain.push(d); + domain.sort(ascending$3); + return scale; + }; + + scale.interpolator = function(_) { + return arguments.length ? (interpolator = _, scale) : interpolator; + }; + + scale.range = function() { + return domain.map((d, i) => interpolator(i / (domain.length - 1))); + }; + + scale.quantiles = function(n) { + return Array.from({length: n + 1}, (_, i) => quantile$1(domain, i / n)); + }; + + scale.copy = function() { + return sequentialQuantile(interpolator).domain(domain); + }; + + return initInterpolator.apply(scale, arguments); +} + +function transformer() { + var x0 = 0, + x1 = 0.5, + x2 = 1, + s = 1, + t0, + t1, + t2, + k10, + k21, + interpolator = identity$3, + transform, + clamp = false, + unknown; + + function scale(x) { + return isNaN(x = +x) ? unknown : (x = 0.5 + ((x = +transform(x)) - t1) * (s * x < s * t1 ? k10 : k21), interpolator(clamp ? Math.max(0, Math.min(1, x)) : x)); + } + + scale.domain = function(_) { + return arguments.length ? ([x0, x1, x2] = _, t0 = transform(x0 = +x0), t1 = transform(x1 = +x1), t2 = transform(x2 = +x2), k10 = t0 === t1 ? 0 : 0.5 / (t1 - t0), k21 = t1 === t2 ? 0 : 0.5 / (t2 - t1), s = t1 < t0 ? -1 : 1, scale) : [x0, x1, x2]; + }; + + scale.clamp = function(_) { + return arguments.length ? (clamp = !!_, scale) : clamp; + }; + + scale.interpolator = function(_) { + return arguments.length ? (interpolator = _, scale) : interpolator; + }; + + function range(interpolate) { + return function(_) { + var r0, r1, r2; + return arguments.length ? ([r0, r1, r2] = _, interpolator = piecewise(interpolate, [r0, r1, r2]), scale) : [interpolator(0), interpolator(0.5), interpolator(1)]; + }; + } + + scale.range = range(interpolate$2); + + scale.rangeRound = range(interpolateRound); + + scale.unknown = function(_) { + return arguments.length ? (unknown = _, scale) : unknown; + }; + + return function(t) { + transform = t, t0 = t(x0), t1 = t(x1), t2 = t(x2), k10 = t0 === t1 ? 0 : 0.5 / (t1 - t0), k21 = t1 === t2 ? 0 : 0.5 / (t2 - t1), s = t1 < t0 ? -1 : 1; + return scale; + }; +} + +function diverging$1() { + var scale = linearish(transformer()(identity$3)); + + scale.copy = function() { + return copy(scale, diverging$1()); + }; + + return initInterpolator.apply(scale, arguments); +} + +function divergingLog() { + var scale = loggish(transformer()).domain([0.1, 1, 10]); + + scale.copy = function() { + return copy(scale, divergingLog()).base(scale.base()); + }; + + return initInterpolator.apply(scale, arguments); +} + +function divergingSymlog() { + var scale = symlogish(transformer()); + + scale.copy = function() { + return copy(scale, divergingSymlog()).constant(scale.constant()); + }; + + return initInterpolator.apply(scale, arguments); +} + +function divergingPow() { + var scale = powish(transformer()); + + scale.copy = function() { + return copy(scale, divergingPow()).exponent(scale.exponent()); + }; + + return initInterpolator.apply(scale, arguments); +} + +function divergingSqrt() { + return divergingPow.apply(null, arguments).exponent(0.5); +} + +function colors(specifier) { + var n = specifier.length / 6 | 0, colors = new Array(n), i = 0; + while (i < n) colors[i] = "#" + specifier.slice(i * 6, ++i * 6); + return colors; +} + +var category10 = colors("1f77b4ff7f0e2ca02cd627289467bd8c564be377c27f7f7fbcbd2217becf"); + +var Accent = colors("7fc97fbeaed4fdc086ffff99386cb0f0027fbf5b17666666"); + +var Dark2 = colors("1b9e77d95f027570b3e7298a66a61ee6ab02a6761d666666"); + +var Paired = colors("a6cee31f78b4b2df8a33a02cfb9a99e31a1cfdbf6fff7f00cab2d66a3d9affff99b15928"); + +var Pastel1 = colors("fbb4aeb3cde3ccebc5decbe4fed9a6ffffcce5d8bdfddaecf2f2f2"); + +var Pastel2 = colors("b3e2cdfdcdaccbd5e8f4cae4e6f5c9fff2aef1e2cccccccc"); + +var Set1 = colors("e41a1c377eb84daf4a984ea3ff7f00ffff33a65628f781bf999999"); + +var Set2 = colors("66c2a5fc8d628da0cbe78ac3a6d854ffd92fe5c494b3b3b3"); + +var Set3 = colors("8dd3c7ffffb3bebadafb807280b1d3fdb462b3de69fccde5d9d9d9bc80bdccebc5ffed6f"); + +var Tableau10 = colors("4e79a7f28e2ce1575976b7b259a14fedc949af7aa1ff9da79c755fbab0ab"); + +var ramp$1 = scheme => rgbBasis(scheme[scheme.length - 1]); + +var scheme$q = new Array(3).concat( + "d8b365f5f5f55ab4ac", + "a6611adfc27d80cdc1018571", + "a6611adfc27df5f5f580cdc1018571", + "8c510ad8b365f6e8c3c7eae55ab4ac01665e", + "8c510ad8b365f6e8c3f5f5f5c7eae55ab4ac01665e", + "8c510abf812ddfc27df6e8c3c7eae580cdc135978f01665e", + "8c510abf812ddfc27df6e8c3f5f5f5c7eae580cdc135978f01665e", + "5430058c510abf812ddfc27df6e8c3c7eae580cdc135978f01665e003c30", + "5430058c510abf812ddfc27df6e8c3f5f5f5c7eae580cdc135978f01665e003c30" +).map(colors); + +var BrBG = ramp$1(scheme$q); + +var scheme$p = new Array(3).concat( + "af8dc3f7f7f77fbf7b", + "7b3294c2a5cfa6dba0008837", + "7b3294c2a5cff7f7f7a6dba0008837", + "762a83af8dc3e7d4e8d9f0d37fbf7b1b7837", + "762a83af8dc3e7d4e8f7f7f7d9f0d37fbf7b1b7837", + "762a839970abc2a5cfe7d4e8d9f0d3a6dba05aae611b7837", + "762a839970abc2a5cfe7d4e8f7f7f7d9f0d3a6dba05aae611b7837", + "40004b762a839970abc2a5cfe7d4e8d9f0d3a6dba05aae611b783700441b", + "40004b762a839970abc2a5cfe7d4e8f7f7f7d9f0d3a6dba05aae611b783700441b" +).map(colors); + +var PRGn = ramp$1(scheme$p); + +var scheme$o = new Array(3).concat( + "e9a3c9f7f7f7a1d76a", + "d01c8bf1b6dab8e1864dac26", + "d01c8bf1b6daf7f7f7b8e1864dac26", + "c51b7de9a3c9fde0efe6f5d0a1d76a4d9221", + "c51b7de9a3c9fde0eff7f7f7e6f5d0a1d76a4d9221", + "c51b7dde77aef1b6dafde0efe6f5d0b8e1867fbc414d9221", + "c51b7dde77aef1b6dafde0eff7f7f7e6f5d0b8e1867fbc414d9221", + "8e0152c51b7dde77aef1b6dafde0efe6f5d0b8e1867fbc414d9221276419", + "8e0152c51b7dde77aef1b6dafde0eff7f7f7e6f5d0b8e1867fbc414d9221276419" +).map(colors); + +var PiYG = ramp$1(scheme$o); + +var scheme$n = new Array(3).concat( + "998ec3f7f7f7f1a340", + "5e3c99b2abd2fdb863e66101", + "5e3c99b2abd2f7f7f7fdb863e66101", + "542788998ec3d8daebfee0b6f1a340b35806", + "542788998ec3d8daebf7f7f7fee0b6f1a340b35806", + "5427888073acb2abd2d8daebfee0b6fdb863e08214b35806", + "5427888073acb2abd2d8daebf7f7f7fee0b6fdb863e08214b35806", + "2d004b5427888073acb2abd2d8daebfee0b6fdb863e08214b358067f3b08", + "2d004b5427888073acb2abd2d8daebf7f7f7fee0b6fdb863e08214b358067f3b08" +).map(colors); + +var PuOr = ramp$1(scheme$n); + +var scheme$m = new Array(3).concat( + "ef8a62f7f7f767a9cf", + "ca0020f4a58292c5de0571b0", + "ca0020f4a582f7f7f792c5de0571b0", + "b2182bef8a62fddbc7d1e5f067a9cf2166ac", + "b2182bef8a62fddbc7f7f7f7d1e5f067a9cf2166ac", + "b2182bd6604df4a582fddbc7d1e5f092c5de4393c32166ac", + "b2182bd6604df4a582fddbc7f7f7f7d1e5f092c5de4393c32166ac", + "67001fb2182bd6604df4a582fddbc7d1e5f092c5de4393c32166ac053061", + "67001fb2182bd6604df4a582fddbc7f7f7f7d1e5f092c5de4393c32166ac053061" +).map(colors); + +var RdBu = ramp$1(scheme$m); + +var scheme$l = new Array(3).concat( + "ef8a62ffffff999999", + "ca0020f4a582bababa404040", + "ca0020f4a582ffffffbababa404040", + "b2182bef8a62fddbc7e0e0e09999994d4d4d", + "b2182bef8a62fddbc7ffffffe0e0e09999994d4d4d", + "b2182bd6604df4a582fddbc7e0e0e0bababa8787874d4d4d", + "b2182bd6604df4a582fddbc7ffffffe0e0e0bababa8787874d4d4d", + "67001fb2182bd6604df4a582fddbc7e0e0e0bababa8787874d4d4d1a1a1a", + "67001fb2182bd6604df4a582fddbc7ffffffe0e0e0bababa8787874d4d4d1a1a1a" +).map(colors); + +var RdGy = ramp$1(scheme$l); + +var scheme$k = new Array(3).concat( + "fc8d59ffffbf91bfdb", + "d7191cfdae61abd9e92c7bb6", + "d7191cfdae61ffffbfabd9e92c7bb6", + "d73027fc8d59fee090e0f3f891bfdb4575b4", + "d73027fc8d59fee090ffffbfe0f3f891bfdb4575b4", + "d73027f46d43fdae61fee090e0f3f8abd9e974add14575b4", + "d73027f46d43fdae61fee090ffffbfe0f3f8abd9e974add14575b4", + "a50026d73027f46d43fdae61fee090e0f3f8abd9e974add14575b4313695", + "a50026d73027f46d43fdae61fee090ffffbfe0f3f8abd9e974add14575b4313695" +).map(colors); + +var RdYlBu = ramp$1(scheme$k); + +var scheme$j = new Array(3).concat( + "fc8d59ffffbf91cf60", + "d7191cfdae61a6d96a1a9641", + "d7191cfdae61ffffbfa6d96a1a9641", + "d73027fc8d59fee08bd9ef8b91cf601a9850", + "d73027fc8d59fee08bffffbfd9ef8b91cf601a9850", + "d73027f46d43fdae61fee08bd9ef8ba6d96a66bd631a9850", + "d73027f46d43fdae61fee08bffffbfd9ef8ba6d96a66bd631a9850", + "a50026d73027f46d43fdae61fee08bd9ef8ba6d96a66bd631a9850006837", + "a50026d73027f46d43fdae61fee08bffffbfd9ef8ba6d96a66bd631a9850006837" +).map(colors); + +var RdYlGn = ramp$1(scheme$j); + +var scheme$i = new Array(3).concat( + "fc8d59ffffbf99d594", + "d7191cfdae61abdda42b83ba", + "d7191cfdae61ffffbfabdda42b83ba", + "d53e4ffc8d59fee08be6f59899d5943288bd", + "d53e4ffc8d59fee08bffffbfe6f59899d5943288bd", + "d53e4ff46d43fdae61fee08be6f598abdda466c2a53288bd", + "d53e4ff46d43fdae61fee08bffffbfe6f598abdda466c2a53288bd", + "9e0142d53e4ff46d43fdae61fee08be6f598abdda466c2a53288bd5e4fa2", + "9e0142d53e4ff46d43fdae61fee08bffffbfe6f598abdda466c2a53288bd5e4fa2" +).map(colors); + +var Spectral = ramp$1(scheme$i); + +var scheme$h = new Array(3).concat( + "e5f5f999d8c92ca25f", + "edf8fbb2e2e266c2a4238b45", + "edf8fbb2e2e266c2a42ca25f006d2c", + "edf8fbccece699d8c966c2a42ca25f006d2c", + "edf8fbccece699d8c966c2a441ae76238b45005824", + "f7fcfde5f5f9ccece699d8c966c2a441ae76238b45005824", + "f7fcfde5f5f9ccece699d8c966c2a441ae76238b45006d2c00441b" +).map(colors); + +var BuGn = ramp$1(scheme$h); + +var scheme$g = new Array(3).concat( + "e0ecf49ebcda8856a7", + "edf8fbb3cde38c96c688419d", + "edf8fbb3cde38c96c68856a7810f7c", + "edf8fbbfd3e69ebcda8c96c68856a7810f7c", + "edf8fbbfd3e69ebcda8c96c68c6bb188419d6e016b", + "f7fcfde0ecf4bfd3e69ebcda8c96c68c6bb188419d6e016b", + "f7fcfde0ecf4bfd3e69ebcda8c96c68c6bb188419d810f7c4d004b" +).map(colors); + +var BuPu = ramp$1(scheme$g); + +var scheme$f = new Array(3).concat( + "e0f3dba8ddb543a2ca", + "f0f9e8bae4bc7bccc42b8cbe", + "f0f9e8bae4bc7bccc443a2ca0868ac", + "f0f9e8ccebc5a8ddb57bccc443a2ca0868ac", + "f0f9e8ccebc5a8ddb57bccc44eb3d32b8cbe08589e", + "f7fcf0e0f3dbccebc5a8ddb57bccc44eb3d32b8cbe08589e", + "f7fcf0e0f3dbccebc5a8ddb57bccc44eb3d32b8cbe0868ac084081" +).map(colors); + +var GnBu = ramp$1(scheme$f); + +var scheme$e = new Array(3).concat( + "fee8c8fdbb84e34a33", + "fef0d9fdcc8afc8d59d7301f", + "fef0d9fdcc8afc8d59e34a33b30000", + "fef0d9fdd49efdbb84fc8d59e34a33b30000", + "fef0d9fdd49efdbb84fc8d59ef6548d7301f990000", + "fff7ecfee8c8fdd49efdbb84fc8d59ef6548d7301f990000", + "fff7ecfee8c8fdd49efdbb84fc8d59ef6548d7301fb300007f0000" +).map(colors); + +var OrRd = ramp$1(scheme$e); + +var scheme$d = new Array(3).concat( + "ece2f0a6bddb1c9099", + "f6eff7bdc9e167a9cf02818a", + "f6eff7bdc9e167a9cf1c9099016c59", + "f6eff7d0d1e6a6bddb67a9cf1c9099016c59", + "f6eff7d0d1e6a6bddb67a9cf3690c002818a016450", + "fff7fbece2f0d0d1e6a6bddb67a9cf3690c002818a016450", + "fff7fbece2f0d0d1e6a6bddb67a9cf3690c002818a016c59014636" +).map(colors); + +var PuBuGn = ramp$1(scheme$d); + +var scheme$c = new Array(3).concat( + "ece7f2a6bddb2b8cbe", + "f1eef6bdc9e174a9cf0570b0", + "f1eef6bdc9e174a9cf2b8cbe045a8d", + "f1eef6d0d1e6a6bddb74a9cf2b8cbe045a8d", + "f1eef6d0d1e6a6bddb74a9cf3690c00570b0034e7b", + "fff7fbece7f2d0d1e6a6bddb74a9cf3690c00570b0034e7b", + "fff7fbece7f2d0d1e6a6bddb74a9cf3690c00570b0045a8d023858" +).map(colors); + +var PuBu = ramp$1(scheme$c); + +var scheme$b = new Array(3).concat( + "e7e1efc994c7dd1c77", + "f1eef6d7b5d8df65b0ce1256", + "f1eef6d7b5d8df65b0dd1c77980043", + "f1eef6d4b9dac994c7df65b0dd1c77980043", + "f1eef6d4b9dac994c7df65b0e7298ace125691003f", + "f7f4f9e7e1efd4b9dac994c7df65b0e7298ace125691003f", + "f7f4f9e7e1efd4b9dac994c7df65b0e7298ace125698004367001f" +).map(colors); + +var PuRd = ramp$1(scheme$b); + +var scheme$a = new Array(3).concat( + "fde0ddfa9fb5c51b8a", + "feebe2fbb4b9f768a1ae017e", + "feebe2fbb4b9f768a1c51b8a7a0177", + "feebe2fcc5c0fa9fb5f768a1c51b8a7a0177", + "feebe2fcc5c0fa9fb5f768a1dd3497ae017e7a0177", + "fff7f3fde0ddfcc5c0fa9fb5f768a1dd3497ae017e7a0177", + "fff7f3fde0ddfcc5c0fa9fb5f768a1dd3497ae017e7a017749006a" +).map(colors); + +var RdPu = ramp$1(scheme$a); + +var scheme$9 = new Array(3).concat( + "edf8b17fcdbb2c7fb8", + "ffffcca1dab441b6c4225ea8", + "ffffcca1dab441b6c42c7fb8253494", + "ffffccc7e9b47fcdbb41b6c42c7fb8253494", + "ffffccc7e9b47fcdbb41b6c41d91c0225ea80c2c84", + "ffffd9edf8b1c7e9b47fcdbb41b6c41d91c0225ea80c2c84", + "ffffd9edf8b1c7e9b47fcdbb41b6c41d91c0225ea8253494081d58" +).map(colors); + +var YlGnBu = ramp$1(scheme$9); + +var scheme$8 = new Array(3).concat( + "f7fcb9addd8e31a354", + "ffffccc2e69978c679238443", + "ffffccc2e69978c67931a354006837", + "ffffccd9f0a3addd8e78c67931a354006837", + "ffffccd9f0a3addd8e78c67941ab5d238443005a32", + "ffffe5f7fcb9d9f0a3addd8e78c67941ab5d238443005a32", + "ffffe5f7fcb9d9f0a3addd8e78c67941ab5d238443006837004529" +).map(colors); + +var YlGn = ramp$1(scheme$8); + +var scheme$7 = new Array(3).concat( + "fff7bcfec44fd95f0e", + "ffffd4fed98efe9929cc4c02", + "ffffd4fed98efe9929d95f0e993404", + "ffffd4fee391fec44ffe9929d95f0e993404", + "ffffd4fee391fec44ffe9929ec7014cc4c028c2d04", + "ffffe5fff7bcfee391fec44ffe9929ec7014cc4c028c2d04", + "ffffe5fff7bcfee391fec44ffe9929ec7014cc4c02993404662506" +).map(colors); + +var YlOrBr = ramp$1(scheme$7); + +var scheme$6 = new Array(3).concat( + "ffeda0feb24cf03b20", + "ffffb2fecc5cfd8d3ce31a1c", + "ffffb2fecc5cfd8d3cf03b20bd0026", + "ffffb2fed976feb24cfd8d3cf03b20bd0026", + "ffffb2fed976feb24cfd8d3cfc4e2ae31a1cb10026", + "ffffccffeda0fed976feb24cfd8d3cfc4e2ae31a1cb10026", + "ffffccffeda0fed976feb24cfd8d3cfc4e2ae31a1cbd0026800026" +).map(colors); + +var YlOrRd = ramp$1(scheme$6); + +var scheme$5 = new Array(3).concat( + "deebf79ecae13182bd", + "eff3ffbdd7e76baed62171b5", + "eff3ffbdd7e76baed63182bd08519c", + "eff3ffc6dbef9ecae16baed63182bd08519c", + "eff3ffc6dbef9ecae16baed64292c62171b5084594", + "f7fbffdeebf7c6dbef9ecae16baed64292c62171b5084594", + "f7fbffdeebf7c6dbef9ecae16baed64292c62171b508519c08306b" +).map(colors); + +var Blues = ramp$1(scheme$5); + +var scheme$4 = new Array(3).concat( + "e5f5e0a1d99b31a354", + "edf8e9bae4b374c476238b45", + "edf8e9bae4b374c47631a354006d2c", + "edf8e9c7e9c0a1d99b74c47631a354006d2c", + "edf8e9c7e9c0a1d99b74c47641ab5d238b45005a32", + "f7fcf5e5f5e0c7e9c0a1d99b74c47641ab5d238b45005a32", + "f7fcf5e5f5e0c7e9c0a1d99b74c47641ab5d238b45006d2c00441b" +).map(colors); + +var Greens = ramp$1(scheme$4); + +var scheme$3 = new Array(3).concat( + "f0f0f0bdbdbd636363", + "f7f7f7cccccc969696525252", + "f7f7f7cccccc969696636363252525", + "f7f7f7d9d9d9bdbdbd969696636363252525", + "f7f7f7d9d9d9bdbdbd969696737373525252252525", + "fffffff0f0f0d9d9d9bdbdbd969696737373525252252525", + "fffffff0f0f0d9d9d9bdbdbd969696737373525252252525000000" +).map(colors); + +var Greys = ramp$1(scheme$3); + +var scheme$2 = new Array(3).concat( + "efedf5bcbddc756bb1", + "f2f0f7cbc9e29e9ac86a51a3", + "f2f0f7cbc9e29e9ac8756bb154278f", + "f2f0f7dadaebbcbddc9e9ac8756bb154278f", + "f2f0f7dadaebbcbddc9e9ac8807dba6a51a34a1486", + "fcfbfdefedf5dadaebbcbddc9e9ac8807dba6a51a34a1486", + "fcfbfdefedf5dadaebbcbddc9e9ac8807dba6a51a354278f3f007d" +).map(colors); + +var Purples = ramp$1(scheme$2); + +var scheme$1 = new Array(3).concat( + "fee0d2fc9272de2d26", + "fee5d9fcae91fb6a4acb181d", + "fee5d9fcae91fb6a4ade2d26a50f15", + "fee5d9fcbba1fc9272fb6a4ade2d26a50f15", + "fee5d9fcbba1fc9272fb6a4aef3b2ccb181d99000d", + "fff5f0fee0d2fcbba1fc9272fb6a4aef3b2ccb181d99000d", + "fff5f0fee0d2fcbba1fc9272fb6a4aef3b2ccb181da50f1567000d" +).map(colors); + +var Reds = ramp$1(scheme$1); + +var scheme = new Array(3).concat( + "fee6cefdae6be6550d", + "feeddefdbe85fd8d3cd94701", + "feeddefdbe85fd8d3ce6550da63603", + "feeddefdd0a2fdae6bfd8d3ce6550da63603", + "feeddefdd0a2fdae6bfd8d3cf16913d948018c2d04", + "fff5ebfee6cefdd0a2fdae6bfd8d3cf16913d948018c2d04", + "fff5ebfee6cefdd0a2fdae6bfd8d3cf16913d94801a636037f2704" +).map(colors); + +var Oranges = ramp$1(scheme); + +function cividis(t) { + t = Math.max(0, Math.min(1, t)); + return "rgb(" + + Math.max(0, Math.min(255, Math.round(-4.54 - t * (35.34 - t * (2381.73 - t * (6402.7 - t * (7024.72 - t * 2710.57))))))) + ", " + + Math.max(0, Math.min(255, Math.round(32.49 + t * (170.73 + t * (52.82 - t * (131.46 - t * (176.58 - t * 67.37))))))) + ", " + + Math.max(0, Math.min(255, Math.round(81.24 + t * (442.36 - t * (2482.43 - t * (6167.24 - t * (6614.94 - t * 2475.67))))))) + + ")"; +} + +var cubehelix = cubehelixLong(cubehelix$3(300, 0.5, 0.0), cubehelix$3(-240, 0.5, 1.0)); + +var warm = cubehelixLong(cubehelix$3(-100, 0.75, 0.35), cubehelix$3(80, 1.50, 0.8)); + +var cool = cubehelixLong(cubehelix$3(260, 0.75, 0.35), cubehelix$3(80, 1.50, 0.8)); + +var c$2 = cubehelix$3(); + +function rainbow(t) { + if (t < 0 || t > 1) t -= Math.floor(t); + var ts = Math.abs(t - 0.5); + c$2.h = 360 * t - 100; + c$2.s = 1.5 - 1.5 * ts; + c$2.l = 0.8 - 0.9 * ts; + return c$2 + ""; +} + +var c$1 = rgb(), + pi_1_3 = Math.PI / 3, + pi_2_3 = Math.PI * 2 / 3; + +function sinebow(t) { + var x; + t = (0.5 - t) * Math.PI; + c$1.r = 255 * (x = Math.sin(t)) * x; + c$1.g = 255 * (x = Math.sin(t + pi_1_3)) * x; + c$1.b = 255 * (x = Math.sin(t + pi_2_3)) * x; + return c$1 + ""; +} + +function turbo(t) { + t = Math.max(0, Math.min(1, t)); + return "rgb(" + + Math.max(0, Math.min(255, Math.round(34.61 + t * (1172.33 - t * (10793.56 - t * (33300.12 - t * (38394.49 - t * 14825.05))))))) + ", " + + Math.max(0, Math.min(255, Math.round(23.31 + t * (557.33 + t * (1225.33 - t * (3574.96 - t * (1073.77 + t * 707.56))))))) + ", " + + Math.max(0, Math.min(255, Math.round(27.2 + t * (3211.1 - t * (15327.97 - t * (27814 - t * (22569.18 - t * 6838.66))))))) + + ")"; +} + +function ramp(range) { + var n = range.length; + return function(t) { + return range[Math.max(0, Math.min(n - 1, Math.floor(t * n)))]; + }; +} + +var viridis = ramp(colors("44015444025645045745055946075a46085c460a5d460b5e470d60470e6147106347116447136548146748166848176948186a481a6c481b6d481c6e481d6f481f70482071482173482374482475482576482677482878482979472a7a472c7a472d7b472e7c472f7d46307e46327e46337f463480453581453781453882443983443a83443b84433d84433e85423f854240864241864142874144874045884046883f47883f48893e49893e4a893e4c8a3d4d8a3d4e8a3c4f8a3c508b3b518b3b528b3a538b3a548c39558c39568c38588c38598c375a8c375b8d365c8d365d8d355e8d355f8d34608d34618d33628d33638d32648e32658e31668e31678e31688e30698e306a8e2f6b8e2f6c8e2e6d8e2e6e8e2e6f8e2d708e2d718e2c718e2c728e2c738e2b748e2b758e2a768e2a778e2a788e29798e297a8e297b8e287c8e287d8e277e8e277f8e27808e26818e26828e26828e25838e25848e25858e24868e24878e23888e23898e238a8d228b8d228c8d228d8d218e8d218f8d21908d21918c20928c20928c20938c1f948c1f958b1f968b1f978b1f988b1f998a1f9a8a1e9b8a1e9c891e9d891f9e891f9f881fa0881fa1881fa1871fa28720a38620a48621a58521a68522a78522a88423a98324aa8325ab8225ac8226ad8127ad8128ae8029af7f2ab07f2cb17e2db27d2eb37c2fb47c31b57b32b67a34b67935b77937b87838b9773aba763bbb753dbc743fbc7340bd7242be7144bf7046c06f48c16e4ac16d4cc26c4ec36b50c46a52c56954c56856c66758c7655ac8645cc8635ec96260ca6063cb5f65cb5e67cc5c69cd5b6ccd5a6ece5870cf5773d05675d05477d1537ad1517cd2507fd34e81d34d84d44b86d54989d5488bd6468ed64590d74393d74195d84098d83e9bd93c9dd93ba0da39a2da37a5db36a8db34aadc32addc30b0dd2fb2dd2db5de2bb8de29bade28bddf26c0df25c2df23c5e021c8e020cae11fcde11dd0e11cd2e21bd5e21ad8e219dae319dde318dfe318e2e418e5e419e7e419eae51aece51befe51cf1e51df4e61ef6e620f8e621fbe723fde725")); + +var magma = ramp(colors("00000401000501010601010802010902020b02020d03030f03031204041405041606051806051a07061c08071e0907200a08220b09240c09260d0a290e0b2b100b2d110c2f120d31130d34140e36150e38160f3b180f3d19103f1a10421c10441d11471e114920114b21114e22115024125325125527125829115a2a115c2c115f2d11612f116331116533106734106936106b38106c390f6e3b0f703d0f713f0f72400f74420f75440f764510774710784910784a10794c117a4e117b4f127b51127c52137c54137d56147d57157e59157e5a167e5c167f5d177f5f187f601880621980641a80651a80671b80681c816a1c816b1d816d1d816e1e81701f81721f817320817521817621817822817922827b23827c23827e24828025828125818326818426818627818827818928818b29818c29818e2a81902a81912b81932b80942c80962c80982d80992d809b2e7f9c2e7f9e2f7fa02f7fa1307ea3307ea5317ea6317da8327daa337dab337cad347cae347bb0357bb2357bb3367ab5367ab73779b83779ba3878bc3978bd3977bf3a77c03a76c23b75c43c75c53c74c73d73c83e73ca3e72cc3f71cd4071cf4070d0416fd2426fd3436ed5446dd6456cd8456cd9466bdb476adc4869de4968df4a68e04c67e24d66e34e65e44f64e55064e75263e85362e95462ea5661eb5760ec5860ed5a5fee5b5eef5d5ef05f5ef1605df2625df2645cf3655cf4675cf4695cf56b5cf66c5cf66e5cf7705cf7725cf8745cf8765cf9785df9795df97b5dfa7d5efa7f5efa815ffb835ffb8560fb8761fc8961fc8a62fc8c63fc8e64fc9065fd9266fd9467fd9668fd9869fd9a6afd9b6bfe9d6cfe9f6dfea16efea36ffea571fea772fea973feaa74feac76feae77feb078feb27afeb47bfeb67cfeb77efeb97ffebb81febd82febf84fec185fec287fec488fec68afec88cfeca8dfecc8ffecd90fecf92fed194fed395fed597fed799fed89afdda9cfddc9efddea0fde0a1fde2a3fde3a5fde5a7fde7a9fde9aafdebacfcecaefceeb0fcf0b2fcf2b4fcf4b6fcf6b8fcf7b9fcf9bbfcfbbdfcfdbf")); + +var inferno = ramp(colors("00000401000501010601010802010a02020c02020e03021004031204031405041706041907051b08051d09061f0a07220b07240c08260d08290e092b10092d110a30120a32140b34150b37160b39180c3c190c3e1b0c411c0c431e0c451f0c48210c4a230c4c240c4f260c51280b53290b552b0b572d0b592f0a5b310a5c320a5e340a5f3609613809623909633b09643d09653e0966400a67420a68440a68450a69470b6a490b6a4a0c6b4c0c6b4d0d6c4f0d6c510e6c520e6d540f6d550f6d57106e59106e5a116e5c126e5d126e5f136e61136e62146e64156e65156e67166e69166e6a176e6c186e6d186e6f196e71196e721a6e741a6e751b6e771c6d781c6d7a1d6d7c1d6d7d1e6d7f1e6c801f6c82206c84206b85216b87216b88226a8a226a8c23698d23698f24699025689225689326679526679727669827669a28659b29649d29649f2a63a02a63a22b62a32c61a52c60a62d60a82e5fa92e5eab2f5ead305dae305cb0315bb1325ab3325ab43359b63458b73557b93556ba3655bc3754bd3853bf3952c03a51c13a50c33b4fc43c4ec63d4dc73e4cc83f4bca404acb4149cc4248ce4347cf4446d04545d24644d34743d44842d54a41d74b3fd84c3ed94d3dda4e3cdb503bdd513ade5238df5337e05536e15635e25734e35933e45a31e55c30e65d2fe75e2ee8602de9612bea632aeb6429eb6628ec6726ed6925ee6a24ef6c23ef6e21f06f20f1711ff1731df2741cf3761bf37819f47918f57b17f57d15f67e14f68013f78212f78410f8850ff8870ef8890cf98b0bf98c0af98e09fa9008fa9207fa9407fb9606fb9706fb9906fb9b06fb9d07fc9f07fca108fca309fca50afca60cfca80dfcaa0ffcac11fcae12fcb014fcb216fcb418fbb61afbb81dfbba1ffbbc21fbbe23fac026fac228fac42afac62df9c72ff9c932f9cb35f8cd37f8cf3af7d13df7d340f6d543f6d746f5d949f5db4cf4dd4ff4df53f4e156f3e35af3e55df2e661f2e865f2ea69f1ec6df1ed71f1ef75f1f179f2f27df2f482f3f586f3f68af4f88ef5f992f6fa96f8fb9af9fc9dfafda1fcffa4")); + +var plasma = ramp(colors("0d088710078813078916078a19068c1b068d1d068e20068f2206902406912605912805922a05932c05942e05952f059631059733059735049837049938049a3a049a3c049b3e049c3f049c41049d43039e44039e46039f48039f4903a04b03a14c02a14e02a25002a25102a35302a35502a45601a45801a45901a55b01a55c01a65e01a66001a66100a76300a76400a76600a76700a86900a86a00a86c00a86e00a86f00a87100a87201a87401a87501a87701a87801a87a02a87b02a87d03a87e03a88004a88104a78305a78405a78606a68707a68808a68a09a58b0aa58d0ba58e0ca48f0da4910ea3920fa39410a29511a19613a19814a099159f9a169f9c179e9d189d9e199da01a9ca11b9ba21d9aa31e9aa51f99a62098a72197a82296aa2395ab2494ac2694ad2793ae2892b02991b12a90b22b8fb32c8eb42e8db52f8cb6308bb7318ab83289ba3388bb3488bc3587bd3786be3885bf3984c03a83c13b82c23c81c33d80c43e7fc5407ec6417dc7427cc8437bc9447aca457acb4679cc4778cc4977cd4a76ce4b75cf4c74d04d73d14e72d24f71d35171d45270d5536fd5546ed6556dd7566cd8576bd9586ada5a6ada5b69db5c68dc5d67dd5e66de5f65de6164df6263e06363e16462e26561e26660e3685fe4695ee56a5de56b5de66c5ce76e5be76f5ae87059e97158e97257ea7457eb7556eb7655ec7754ed7953ed7a52ee7b51ef7c51ef7e50f07f4ff0804ef1814df1834cf2844bf3854bf3874af48849f48948f58b47f58c46f68d45f68f44f79044f79143f79342f89441f89540f9973ff9983ef99a3efa9b3dfa9c3cfa9e3bfb9f3afba139fba238fca338fca537fca636fca835fca934fdab33fdac33fdae32fdaf31fdb130fdb22ffdb42ffdb52efeb72dfeb82cfeba2cfebb2bfebd2afebe2afec029fdc229fdc328fdc527fdc627fdc827fdca26fdcb26fccd25fcce25fcd025fcd225fbd324fbd524fbd724fad824fada24f9dc24f9dd25f8df25f8e125f7e225f7e425f6e626f6e826f5e926f5eb27f4ed27f3ee27f3f027f2f227f1f426f1f525f0f724f0f921")); + +function constant$1(x) { + return function constant() { + return x; + }; +} + +var abs = Math.abs; +var atan2 = Math.atan2; +var cos = Math.cos; +var max = Math.max; +var min = Math.min; +var sin = Math.sin; +var sqrt = Math.sqrt; + +var epsilon = 1e-12; +var pi = Math.PI; +var halfPi = pi / 2; +var tau = 2 * pi; + +function acos(x) { + return x > 1 ? 0 : x < -1 ? pi : Math.acos(x); +} + +function asin(x) { + return x >= 1 ? halfPi : x <= -1 ? -halfPi : Math.asin(x); +} + +function arcInnerRadius(d) { + return d.innerRadius; +} + +function arcOuterRadius(d) { + return d.outerRadius; +} + +function arcStartAngle(d) { + return d.startAngle; +} + +function arcEndAngle(d) { + return d.endAngle; +} + +function arcPadAngle(d) { + return d && d.padAngle; // Note: optional! +} + +function intersect(x0, y0, x1, y1, x2, y2, x3, y3) { + var x10 = x1 - x0, y10 = y1 - y0, + x32 = x3 - x2, y32 = y3 - y2, + t = y32 * x10 - x32 * y10; + if (t * t < epsilon) return; + t = (x32 * (y0 - y2) - y32 * (x0 - x2)) / t; + return [x0 + t * x10, y0 + t * y10]; +} + +// Compute perpendicular offset line of length rc. +// http://mathworld.wolfram.com/Circle-LineIntersection.html +function cornerTangents(x0, y0, x1, y1, r1, rc, cw) { + var x01 = x0 - x1, + y01 = y0 - y1, + lo = (cw ? rc : -rc) / sqrt(x01 * x01 + y01 * y01), + ox = lo * y01, + oy = -lo * x01, + x11 = x0 + ox, + y11 = y0 + oy, + x10 = x1 + ox, + y10 = y1 + oy, + x00 = (x11 + x10) / 2, + y00 = (y11 + y10) / 2, + dx = x10 - x11, + dy = y10 - y11, + d2 = dx * dx + dy * dy, + r = r1 - rc, + D = x11 * y10 - x10 * y11, + d = (dy < 0 ? -1 : 1) * sqrt(max(0, r * r * d2 - D * D)), + cx0 = (D * dy - dx * d) / d2, + cy0 = (-D * dx - dy * d) / d2, + cx1 = (D * dy + dx * d) / d2, + cy1 = (-D * dx + dy * d) / d2, + dx0 = cx0 - x00, + dy0 = cy0 - y00, + dx1 = cx1 - x00, + dy1 = cy1 - y00; + + // Pick the closer of the two intersection points. + // TODO Is there a faster way to determine which intersection to use? + if (dx0 * dx0 + dy0 * dy0 > dx1 * dx1 + dy1 * dy1) cx0 = cx1, cy0 = cy1; + + return { + cx: cx0, + cy: cy0, + x01: -ox, + y01: -oy, + x11: cx0 * (r1 / r - 1), + y11: cy0 * (r1 / r - 1) + }; +} + +function arc() { + var innerRadius = arcInnerRadius, + outerRadius = arcOuterRadius, + cornerRadius = constant$1(0), + padRadius = null, + startAngle = arcStartAngle, + endAngle = arcEndAngle, + padAngle = arcPadAngle, + context = null; + + function arc() { + var buffer, + r, + r0 = +innerRadius.apply(this, arguments), + r1 = +outerRadius.apply(this, arguments), + a0 = startAngle.apply(this, arguments) - halfPi, + a1 = endAngle.apply(this, arguments) - halfPi, + da = abs(a1 - a0), + cw = a1 > a0; + + if (!context) context = buffer = path(); + + // Ensure that the outer radius is always larger than the inner radius. + if (r1 < r0) r = r1, r1 = r0, r0 = r; + + // Is it a point? + if (!(r1 > epsilon)) context.moveTo(0, 0); + + // Or is it a circle or annulus? + else if (da > tau - epsilon) { + context.moveTo(r1 * cos(a0), r1 * sin(a0)); + context.arc(0, 0, r1, a0, a1, !cw); + if (r0 > epsilon) { + context.moveTo(r0 * cos(a1), r0 * sin(a1)); + context.arc(0, 0, r0, a1, a0, cw); + } + } + + // Or is it a circular or annular sector? + else { + var a01 = a0, + a11 = a1, + a00 = a0, + a10 = a1, + da0 = da, + da1 = da, + ap = padAngle.apply(this, arguments) / 2, + rp = (ap > epsilon) && (padRadius ? +padRadius.apply(this, arguments) : sqrt(r0 * r0 + r1 * r1)), + rc = min(abs(r1 - r0) / 2, +cornerRadius.apply(this, arguments)), + rc0 = rc, + rc1 = rc, + t0, + t1; + + // Apply padding? Note that since r1 ≥ r0, da1 ≥ da0. + if (rp > epsilon) { + var p0 = asin(rp / r0 * sin(ap)), + p1 = asin(rp / r1 * sin(ap)); + if ((da0 -= p0 * 2) > epsilon) p0 *= (cw ? 1 : -1), a00 += p0, a10 -= p0; + else da0 = 0, a00 = a10 = (a0 + a1) / 2; + if ((da1 -= p1 * 2) > epsilon) p1 *= (cw ? 1 : -1), a01 += p1, a11 -= p1; + else da1 = 0, a01 = a11 = (a0 + a1) / 2; + } + + var x01 = r1 * cos(a01), + y01 = r1 * sin(a01), + x10 = r0 * cos(a10), + y10 = r0 * sin(a10); + + // Apply rounded corners? + if (rc > epsilon) { + var x11 = r1 * cos(a11), + y11 = r1 * sin(a11), + x00 = r0 * cos(a00), + y00 = r0 * sin(a00), + oc; + + // Restrict the corner radius according to the sector angle. + if (da < pi && (oc = intersect(x01, y01, x00, y00, x11, y11, x10, y10))) { + var ax = x01 - oc[0], + ay = y01 - oc[1], + bx = x11 - oc[0], + by = y11 - oc[1], + kc = 1 / sin(acos((ax * bx + ay * by) / (sqrt(ax * ax + ay * ay) * sqrt(bx * bx + by * by))) / 2), + lc = sqrt(oc[0] * oc[0] + oc[1] * oc[1]); + rc0 = min(rc, (r0 - lc) / (kc - 1)); + rc1 = min(rc, (r1 - lc) / (kc + 1)); + } + } + + // Is the sector collapsed to a line? + if (!(da1 > epsilon)) context.moveTo(x01, y01); + + // Does the sector’s outer ring have rounded corners? + else if (rc1 > epsilon) { + t0 = cornerTangents(x00, y00, x01, y01, r1, rc1, cw); + t1 = cornerTangents(x11, y11, x10, y10, r1, rc1, cw); + + context.moveTo(t0.cx + t0.x01, t0.cy + t0.y01); + + // Have the corners merged? + if (rc1 < rc) context.arc(t0.cx, t0.cy, rc1, atan2(t0.y01, t0.x01), atan2(t1.y01, t1.x01), !cw); + + // Otherwise, draw the two corners and the ring. + else { + context.arc(t0.cx, t0.cy, rc1, atan2(t0.y01, t0.x01), atan2(t0.y11, t0.x11), !cw); + context.arc(0, 0, r1, atan2(t0.cy + t0.y11, t0.cx + t0.x11), atan2(t1.cy + t1.y11, t1.cx + t1.x11), !cw); + context.arc(t1.cx, t1.cy, rc1, atan2(t1.y11, t1.x11), atan2(t1.y01, t1.x01), !cw); + } + } + + // Or is the outer ring just a circular arc? + else context.moveTo(x01, y01), context.arc(0, 0, r1, a01, a11, !cw); + + // Is there no inner ring, and it’s a circular sector? + // Or perhaps it’s an annular sector collapsed due to padding? + if (!(r0 > epsilon) || !(da0 > epsilon)) context.lineTo(x10, y10); + + // Does the sector’s inner ring (or point) have rounded corners? + else if (rc0 > epsilon) { + t0 = cornerTangents(x10, y10, x11, y11, r0, -rc0, cw); + t1 = cornerTangents(x01, y01, x00, y00, r0, -rc0, cw); + + context.lineTo(t0.cx + t0.x01, t0.cy + t0.y01); + + // Have the corners merged? + if (rc0 < rc) context.arc(t0.cx, t0.cy, rc0, atan2(t0.y01, t0.x01), atan2(t1.y01, t1.x01), !cw); + + // Otherwise, draw the two corners and the ring. + else { + context.arc(t0.cx, t0.cy, rc0, atan2(t0.y01, t0.x01), atan2(t0.y11, t0.x11), !cw); + context.arc(0, 0, r0, atan2(t0.cy + t0.y11, t0.cx + t0.x11), atan2(t1.cy + t1.y11, t1.cx + t1.x11), cw); + context.arc(t1.cx, t1.cy, rc0, atan2(t1.y11, t1.x11), atan2(t1.y01, t1.x01), !cw); + } + } + + // Or is the inner ring just a circular arc? + else context.arc(0, 0, r0, a10, a00, cw); + } + + context.closePath(); + + if (buffer) return context = null, buffer + "" || null; + } + + arc.centroid = function() { + var r = (+innerRadius.apply(this, arguments) + +outerRadius.apply(this, arguments)) / 2, + a = (+startAngle.apply(this, arguments) + +endAngle.apply(this, arguments)) / 2 - pi / 2; + return [cos(a) * r, sin(a) * r]; + }; + + arc.innerRadius = function(_) { + return arguments.length ? (innerRadius = typeof _ === "function" ? _ : constant$1(+_), arc) : innerRadius; + }; + + arc.outerRadius = function(_) { + return arguments.length ? (outerRadius = typeof _ === "function" ? _ : constant$1(+_), arc) : outerRadius; + }; + + arc.cornerRadius = function(_) { + return arguments.length ? (cornerRadius = typeof _ === "function" ? _ : constant$1(+_), arc) : cornerRadius; + }; + + arc.padRadius = function(_) { + return arguments.length ? (padRadius = _ == null ? null : typeof _ === "function" ? _ : constant$1(+_), arc) : padRadius; + }; + + arc.startAngle = function(_) { + return arguments.length ? (startAngle = typeof _ === "function" ? _ : constant$1(+_), arc) : startAngle; + }; + + arc.endAngle = function(_) { + return arguments.length ? (endAngle = typeof _ === "function" ? _ : constant$1(+_), arc) : endAngle; + }; + + arc.padAngle = function(_) { + return arguments.length ? (padAngle = typeof _ === "function" ? _ : constant$1(+_), arc) : padAngle; + }; + + arc.context = function(_) { + return arguments.length ? ((context = _ == null ? null : _), arc) : context; + }; + + return arc; +} + +var slice = Array.prototype.slice; + +function array(x) { + return typeof x === "object" && "length" in x + ? x // Array, TypedArray, NodeList, array-like + : Array.from(x); // Map, Set, iterable, string, or anything else +} + +function Linear(context) { + this._context = context; +} + +Linear.prototype = { + areaStart: function() { + this._line = 0; + }, + areaEnd: function() { + this._line = NaN; + }, + lineStart: function() { + this._point = 0; + }, + lineEnd: function() { + if (this._line || (this._line !== 0 && this._point === 1)) this._context.closePath(); + this._line = 1 - this._line; + }, + point: function(x, y) { + x = +x, y = +y; + switch (this._point) { + case 0: this._point = 1; this._line ? this._context.lineTo(x, y) : this._context.moveTo(x, y); break; + case 1: this._point = 2; // falls through + default: this._context.lineTo(x, y); break; + } + } +}; + +function curveLinear(context) { + return new Linear(context); +} + +function x(p) { + return p[0]; +} + +function y(p) { + return p[1]; +} + +function line(x$1, y$1) { + var defined = constant$1(true), + context = null, + curve = curveLinear, + output = null; + + x$1 = typeof x$1 === "function" ? x$1 : (x$1 === undefined) ? x : constant$1(x$1); + y$1 = typeof y$1 === "function" ? y$1 : (y$1 === undefined) ? y : constant$1(y$1); + + function line(data) { + var i, + n = (data = array(data)).length, + d, + defined0 = false, + buffer; + + if (context == null) output = curve(buffer = path()); + + for (i = 0; i <= n; ++i) { + if (!(i < n && defined(d = data[i], i, data)) === defined0) { + if (defined0 = !defined0) output.lineStart(); + else output.lineEnd(); + } + if (defined0) output.point(+x$1(d, i, data), +y$1(d, i, data)); + } + + if (buffer) return output = null, buffer + "" || null; + } + + line.x = function(_) { + return arguments.length ? (x$1 = typeof _ === "function" ? _ : constant$1(+_), line) : x$1; + }; + + line.y = function(_) { + return arguments.length ? (y$1 = typeof _ === "function" ? _ : constant$1(+_), line) : y$1; + }; + + line.defined = function(_) { + return arguments.length ? (defined = typeof _ === "function" ? _ : constant$1(!!_), line) : defined; + }; + + line.curve = function(_) { + return arguments.length ? (curve = _, context != null && (output = curve(context)), line) : curve; + }; + + line.context = function(_) { + return arguments.length ? (_ == null ? context = output = null : output = curve(context = _), line) : context; + }; + + return line; +} + +function area(x0, y0, y1) { + var x1 = null, + defined = constant$1(true), + context = null, + curve = curveLinear, + output = null; + + x0 = typeof x0 === "function" ? x0 : (x0 === undefined) ? x : constant$1(+x0); + y0 = typeof y0 === "function" ? y0 : (y0 === undefined) ? constant$1(0) : constant$1(+y0); + y1 = typeof y1 === "function" ? y1 : (y1 === undefined) ? y : constant$1(+y1); + + function area(data) { + var i, + j, + k, + n = (data = array(data)).length, + d, + defined0 = false, + buffer, + x0z = new Array(n), + y0z = new Array(n); + + if (context == null) output = curve(buffer = path()); + + for (i = 0; i <= n; ++i) { + if (!(i < n && defined(d = data[i], i, data)) === defined0) { + if (defined0 = !defined0) { + j = i; + output.areaStart(); + output.lineStart(); + } else { + output.lineEnd(); + output.lineStart(); + for (k = i - 1; k >= j; --k) { + output.point(x0z[k], y0z[k]); + } + output.lineEnd(); + output.areaEnd(); + } + } + if (defined0) { + x0z[i] = +x0(d, i, data), y0z[i] = +y0(d, i, data); + output.point(x1 ? +x1(d, i, data) : x0z[i], y1 ? +y1(d, i, data) : y0z[i]); + } + } + + if (buffer) return output = null, buffer + "" || null; + } + + function arealine() { + return line().defined(defined).curve(curve).context(context); + } + + area.x = function(_) { + return arguments.length ? (x0 = typeof _ === "function" ? _ : constant$1(+_), x1 = null, area) : x0; + }; + + area.x0 = function(_) { + return arguments.length ? (x0 = typeof _ === "function" ? _ : constant$1(+_), area) : x0; + }; + + area.x1 = function(_) { + return arguments.length ? (x1 = _ == null ? null : typeof _ === "function" ? _ : constant$1(+_), area) : x1; + }; + + area.y = function(_) { + return arguments.length ? (y0 = typeof _ === "function" ? _ : constant$1(+_), y1 = null, area) : y0; + }; + + area.y0 = function(_) { + return arguments.length ? (y0 = typeof _ === "function" ? _ : constant$1(+_), area) : y0; + }; + + area.y1 = function(_) { + return arguments.length ? (y1 = _ == null ? null : typeof _ === "function" ? _ : constant$1(+_), area) : y1; + }; + + area.lineX0 = + area.lineY0 = function() { + return arealine().x(x0).y(y0); + }; + + area.lineY1 = function() { + return arealine().x(x0).y(y1); + }; + + area.lineX1 = function() { + return arealine().x(x1).y(y0); + }; + + area.defined = function(_) { + return arguments.length ? (defined = typeof _ === "function" ? _ : constant$1(!!_), area) : defined; + }; + + area.curve = function(_) { + return arguments.length ? (curve = _, context != null && (output = curve(context)), area) : curve; + }; + + area.context = function(_) { + return arguments.length ? (_ == null ? context = output = null : output = curve(context = _), area) : context; + }; + + return area; +} + +function descending$1(a, b) { + return b < a ? -1 : b > a ? 1 : b >= a ? 0 : NaN; +} + +function identity$1(d) { + return d; +} + +function pie() { + var value = identity$1, + sortValues = descending$1, + sort = null, + startAngle = constant$1(0), + endAngle = constant$1(tau), + padAngle = constant$1(0); + + function pie(data) { + var i, + n = (data = array(data)).length, + j, + k, + sum = 0, + index = new Array(n), + arcs = new Array(n), + a0 = +startAngle.apply(this, arguments), + da = Math.min(tau, Math.max(-tau, endAngle.apply(this, arguments) - a0)), + a1, + p = Math.min(Math.abs(da) / n, padAngle.apply(this, arguments)), + pa = p * (da < 0 ? -1 : 1), + v; + + for (i = 0; i < n; ++i) { + if ((v = arcs[index[i] = i] = +value(data[i], i, data)) > 0) { + sum += v; + } + } + + // Optionally sort the arcs by previously-computed values or by data. + if (sortValues != null) index.sort(function(i, j) { return sortValues(arcs[i], arcs[j]); }); + else if (sort != null) index.sort(function(i, j) { return sort(data[i], data[j]); }); + + // Compute the arcs! They are stored in the original data's order. + for (i = 0, k = sum ? (da - n * pa) / sum : 0; i < n; ++i, a0 = a1) { + j = index[i], v = arcs[j], a1 = a0 + (v > 0 ? v * k : 0) + pa, arcs[j] = { + data: data[j], + index: i, + value: v, + startAngle: a0, + endAngle: a1, + padAngle: p + }; + } + + return arcs; + } + + pie.value = function(_) { + return arguments.length ? (value = typeof _ === "function" ? _ : constant$1(+_), pie) : value; + }; + + pie.sortValues = function(_) { + return arguments.length ? (sortValues = _, sort = null, pie) : sortValues; + }; + + pie.sort = function(_) { + return arguments.length ? (sort = _, sortValues = null, pie) : sort; + }; + + pie.startAngle = function(_) { + return arguments.length ? (startAngle = typeof _ === "function" ? _ : constant$1(+_), pie) : startAngle; + }; + + pie.endAngle = function(_) { + return arguments.length ? (endAngle = typeof _ === "function" ? _ : constant$1(+_), pie) : endAngle; + }; + + pie.padAngle = function(_) { + return arguments.length ? (padAngle = typeof _ === "function" ? _ : constant$1(+_), pie) : padAngle; + }; + + return pie; +} + +var curveRadialLinear = curveRadial$1(curveLinear); + +function Radial(curve) { + this._curve = curve; +} + +Radial.prototype = { + areaStart: function() { + this._curve.areaStart(); + }, + areaEnd: function() { + this._curve.areaEnd(); + }, + lineStart: function() { + this._curve.lineStart(); + }, + lineEnd: function() { + this._curve.lineEnd(); + }, + point: function(a, r) { + this._curve.point(r * Math.sin(a), r * -Math.cos(a)); + } +}; + +function curveRadial$1(curve) { + + function radial(context) { + return new Radial(curve(context)); + } + + radial._curve = curve; + + return radial; +} + +function lineRadial(l) { + var c = l.curve; + + l.angle = l.x, delete l.x; + l.radius = l.y, delete l.y; + + l.curve = function(_) { + return arguments.length ? c(curveRadial$1(_)) : c()._curve; + }; + + return l; +} + +function lineRadial$1() { + return lineRadial(line().curve(curveRadialLinear)); +} + +function areaRadial() { + var a = area().curve(curveRadialLinear), + c = a.curve, + x0 = a.lineX0, + x1 = a.lineX1, + y0 = a.lineY0, + y1 = a.lineY1; + + a.angle = a.x, delete a.x; + a.startAngle = a.x0, delete a.x0; + a.endAngle = a.x1, delete a.x1; + a.radius = a.y, delete a.y; + a.innerRadius = a.y0, delete a.y0; + a.outerRadius = a.y1, delete a.y1; + a.lineStartAngle = function() { return lineRadial(x0()); }, delete a.lineX0; + a.lineEndAngle = function() { return lineRadial(x1()); }, delete a.lineX1; + a.lineInnerRadius = function() { return lineRadial(y0()); }, delete a.lineY0; + a.lineOuterRadius = function() { return lineRadial(y1()); }, delete a.lineY1; + + a.curve = function(_) { + return arguments.length ? c(curveRadial$1(_)) : c()._curve; + }; + + return a; +} + +function pointRadial(x, y) { + return [(y = +y) * Math.cos(x -= Math.PI / 2), y * Math.sin(x)]; +} + +function linkSource(d) { + return d.source; +} + +function linkTarget(d) { + return d.target; +} + +function link(curve) { + var source = linkSource, + target = linkTarget, + x$1 = x, + y$1 = y, + context = null; + + function link() { + var buffer, argv = slice.call(arguments), s = source.apply(this, argv), t = target.apply(this, argv); + if (!context) context = buffer = path(); + curve(context, +x$1.apply(this, (argv[0] = s, argv)), +y$1.apply(this, argv), +x$1.apply(this, (argv[0] = t, argv)), +y$1.apply(this, argv)); + if (buffer) return context = null, buffer + "" || null; + } + + link.source = function(_) { + return arguments.length ? (source = _, link) : source; + }; + + link.target = function(_) { + return arguments.length ? (target = _, link) : target; + }; + + link.x = function(_) { + return arguments.length ? (x$1 = typeof _ === "function" ? _ : constant$1(+_), link) : x$1; + }; + + link.y = function(_) { + return arguments.length ? (y$1 = typeof _ === "function" ? _ : constant$1(+_), link) : y$1; + }; + + link.context = function(_) { + return arguments.length ? ((context = _ == null ? null : _), link) : context; + }; + + return link; +} + +function curveHorizontal(context, x0, y0, x1, y1) { + context.moveTo(x0, y0); + context.bezierCurveTo(x0 = (x0 + x1) / 2, y0, x0, y1, x1, y1); +} + +function curveVertical(context, x0, y0, x1, y1) { + context.moveTo(x0, y0); + context.bezierCurveTo(x0, y0 = (y0 + y1) / 2, x1, y0, x1, y1); +} + +function curveRadial(context, x0, y0, x1, y1) { + var p0 = pointRadial(x0, y0), + p1 = pointRadial(x0, y0 = (y0 + y1) / 2), + p2 = pointRadial(x1, y0), + p3 = pointRadial(x1, y1); + context.moveTo(p0[0], p0[1]); + context.bezierCurveTo(p1[0], p1[1], p2[0], p2[1], p3[0], p3[1]); +} + +function linkHorizontal() { + return link(curveHorizontal); +} + +function linkVertical() { + return link(curveVertical); +} + +function linkRadial() { + var l = link(curveRadial); + l.angle = l.x, delete l.x; + l.radius = l.y, delete l.y; + return l; +} + +var circle = { + draw: function(context, size) { + var r = Math.sqrt(size / pi); + context.moveTo(r, 0); + context.arc(0, 0, r, 0, tau); + } +}; + +var cross = { + draw: function(context, size) { + var r = Math.sqrt(size / 5) / 2; + context.moveTo(-3 * r, -r); + context.lineTo(-r, -r); + context.lineTo(-r, -3 * r); + context.lineTo(r, -3 * r); + context.lineTo(r, -r); + context.lineTo(3 * r, -r); + context.lineTo(3 * r, r); + context.lineTo(r, r); + context.lineTo(r, 3 * r); + context.lineTo(-r, 3 * r); + context.lineTo(-r, r); + context.lineTo(-3 * r, r); + context.closePath(); + } +}; + +var tan30 = Math.sqrt(1 / 3), + tan30_2 = tan30 * 2; + +var diamond = { + draw: function(context, size) { + var y = Math.sqrt(size / tan30_2), + x = y * tan30; + context.moveTo(0, -y); + context.lineTo(x, 0); + context.lineTo(0, y); + context.lineTo(-x, 0); + context.closePath(); + } +}; + +var ka = 0.89081309152928522810, + kr = Math.sin(pi / 10) / Math.sin(7 * pi / 10), + kx = Math.sin(tau / 10) * kr, + ky = -Math.cos(tau / 10) * kr; + +var star = { + draw: function(context, size) { + var r = Math.sqrt(size * ka), + x = kx * r, + y = ky * r; + context.moveTo(0, -r); + context.lineTo(x, y); + for (var i = 1; i < 5; ++i) { + var a = tau * i / 5, + c = Math.cos(a), + s = Math.sin(a); + context.lineTo(s * r, -c * r); + context.lineTo(c * x - s * y, s * x + c * y); + } + context.closePath(); + } +}; + +var square = { + draw: function(context, size) { + var w = Math.sqrt(size), + x = -w / 2; + context.rect(x, x, w, w); + } +}; + +var sqrt3 = Math.sqrt(3); + +var triangle = { + draw: function(context, size) { + var y = -Math.sqrt(size / (sqrt3 * 3)); + context.moveTo(0, y * 2); + context.lineTo(-sqrt3 * y, -y); + context.lineTo(sqrt3 * y, -y); + context.closePath(); + } +}; + +var c = -0.5, + s = Math.sqrt(3) / 2, + k = 1 / Math.sqrt(12), + a = (k / 2 + 1) * 3; + +var wye = { + draw: function(context, size) { + var r = Math.sqrt(size / a), + x0 = r / 2, + y0 = r * k, + x1 = x0, + y1 = r * k + r, + x2 = -x1, + y2 = y1; + context.moveTo(x0, y0); + context.lineTo(x1, y1); + context.lineTo(x2, y2); + context.lineTo(c * x0 - s * y0, s * x0 + c * y0); + context.lineTo(c * x1 - s * y1, s * x1 + c * y1); + context.lineTo(c * x2 - s * y2, s * x2 + c * y2); + context.lineTo(c * x0 + s * y0, c * y0 - s * x0); + context.lineTo(c * x1 + s * y1, c * y1 - s * x1); + context.lineTo(c * x2 + s * y2, c * y2 - s * x2); + context.closePath(); + } +}; + +var symbols = [ + circle, + cross, + diamond, + square, + star, + triangle, + wye +]; + +function symbol(type, size) { + var context = null; + type = typeof type === "function" ? type : constant$1(type || circle); + size = typeof size === "function" ? size : constant$1(size === undefined ? 64 : +size); + + function symbol() { + var buffer; + if (!context) context = buffer = path(); + type.apply(this, arguments).draw(context, +size.apply(this, arguments)); + if (buffer) return context = null, buffer + "" || null; + } + + symbol.type = function(_) { + return arguments.length ? (type = typeof _ === "function" ? _ : constant$1(_), symbol) : type; + }; + + symbol.size = function(_) { + return arguments.length ? (size = typeof _ === "function" ? _ : constant$1(+_), symbol) : size; + }; + + symbol.context = function(_) { + return arguments.length ? (context = _ == null ? null : _, symbol) : context; + }; + + return symbol; +} + +function noop() {} + +function point$3(that, x, y) { + that._context.bezierCurveTo( + (2 * that._x0 + that._x1) / 3, + (2 * that._y0 + that._y1) / 3, + (that._x0 + 2 * that._x1) / 3, + (that._y0 + 2 * that._y1) / 3, + (that._x0 + 4 * that._x1 + x) / 6, + (that._y0 + 4 * that._y1 + y) / 6 + ); +} + +function Basis(context) { + this._context = context; +} + +Basis.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: point$3(this, this._x1, this._y1); // falls through + case 2: this._context.lineTo(this._x1, this._y1); break; + } + if (this._line || (this._line !== 0 && this._point === 1)) this._context.closePath(); + this._line = 1 - this._line; + }, + point: function(x, y) { + x = +x, y = +y; + switch (this._point) { + case 0: this._point = 1; this._line ? this._context.lineTo(x, y) : this._context.moveTo(x, y); 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); // falls through + default: point$3(this, x, y); break; + } + this._x0 = this._x1, this._x1 = x; + this._y0 = this._y1, this._y1 = y; + } +}; + +function basis(context) { + return new Basis(context); +} + +function BasisClosed(context) { + this._context = context; +} + +BasisClosed.prototype = { + areaStart: noop, + areaEnd: noop, + 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); + break; + } + } + }, + point: function(x, y) { + x = +x, y = +y; + switch (this._point) { + case 0: this._point = 1; this._x2 = x, this._y2 = y; break; + case 1: this._point = 2; this._x3 = x, this._y3 = y; break; + case 2: this._point = 3; this._x4 = x, this._y4 = y; this._context.moveTo((this._x0 + 4 * this._x1 + x) / 6, (this._y0 + 4 * this._y1 + y) / 6); break; + default: point$3(this, x, y); break; + } + this._x0 = this._x1, this._x1 = x; + this._y0 = this._y1, this._y1 = y; + } +}; + +function basisClosed(context) { + return new BasisClosed(context); +} + +function BasisOpen(context) { + this._context = context; +} + +BasisOpen.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() { + if (this._line || (this._line !== 0 && this._point === 3)) this._context.closePath(); + this._line = 1 - this._line; + }, + point: function(x, y) { + x = +x, y = +y; + switch (this._point) { + case 0: this._point = 1; break; + case 1: this._point = 2; break; + case 2: this._point = 3; var x0 = (this._x0 + 4 * this._x1 + x) / 6, y0 = (this._y0 + 4 * this._y1 + y) / 6; this._line ? this._context.lineTo(x0, y0) : this._context.moveTo(x0, y0); break; + case 3: this._point = 4; // falls through + default: point$3(this, x, y); break; + } + this._x0 = this._x1, this._x1 = x; + this._y0 = this._y1, this._y1 = y; + } +}; + +function basisOpen(context) { + return new BasisOpen(context); +} + +class Bump { + constructor(context, x) { + this._context = context; + this._x = x; + } + areaStart() { + this._line = 0; + } + areaEnd() { + this._line = NaN; + } + lineStart() { + this._point = 0; + } + lineEnd() { + if (this._line || (this._line !== 0 && this._point === 1)) this._context.closePath(); + this._line = 1 - this._line; + } + point(x, y) { + x = +x, y = +y; + switch (this._point) { + case 0: { + this._point = 1; + if (this._line) this._context.lineTo(x, y); + else this._context.moveTo(x, y); + break; + } + case 1: this._point = 2; // falls through + default: { + if (this._x) this._context.bezierCurveTo(this._x0 = (this._x0 + x) / 2, this._y0, this._x0, y, x, y); + else this._context.bezierCurveTo(this._x0, this._y0 = (this._y0 + y) / 2, x, this._y0, x, y); + break; + } + } + this._x0 = x, this._y0 = y; + } +} + +function bumpX(context) { + return new Bump(context, true); +} + +function bumpY(context) { + return new Bump(context, false); +} + +function Bundle(context, beta) { + this._basis = new Basis(context); + this._beta = beta; +} + +Bundle.prototype = { + lineStart: function() { + this._x = []; + this._y = []; + this._basis.lineStart(); + }, + lineEnd: function() { + var x = this._x, + y = this._y, + j = x.length - 1; + + if (j > 0) { + var x0 = x[0], + y0 = y[0], + dx = x[j] - x0, + dy = y[j] - y0, + i = -1, + t; + + while (++i <= j) { + t = i / j; + this._basis.point( + this._beta * x[i] + (1 - this._beta) * (x0 + t * dx), + this._beta * y[i] + (1 - this._beta) * (y0 + t * dy) + ); + } + } + + this._x = this._y = null; + this._basis.lineEnd(); + }, + point: function(x, y) { + this._x.push(+x); + this._y.push(+y); + } +}; + +var bundle = (function custom(beta) { + + function bundle(context) { + return beta === 1 ? new Basis(context) : new Bundle(context, beta); + } + + bundle.beta = function(beta) { + return custom(+beta); + }; + + return bundle; +})(0.85); + +function point$2(that, x, y) { + that._context.bezierCurveTo( + that._x1 + that._k * (that._x2 - that._x0), + that._y1 + that._k * (that._y2 - that._y0), + that._x2 + that._k * (that._x1 - x), + that._y2 + that._k * (that._y1 - y), + that._x2, + that._y2 + ); +} + +function Cardinal(context, tension) { + this._context = context; + this._k = (1 - tension) / 6; +} + +Cardinal.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: point$2(this, this._x1, this._y1); break; + } + if (this._line || (this._line !== 0 && this._point === 1)) this._context.closePath(); + this._line = 1 - this._line; + }, + point: function(x, y) { + x = +x, y = +y; + switch (this._point) { + case 0: this._point = 1; this._line ? this._context.lineTo(x, y) : this._context.moveTo(x, y); break; + case 1: this._point = 2; this._x1 = x, this._y1 = y; break; + case 2: this._point = 3; // falls through + default: point$2(this, x, y); break; + } + this._x0 = this._x1, this._x1 = this._x2, this._x2 = x; + this._y0 = this._y1, this._y1 = this._y2, this._y2 = y; + } +}; + +var cardinal = (function custom(tension) { + + function cardinal(context) { + return new Cardinal(context, tension); + } + + cardinal.tension = function(tension) { + return custom(+tension); + }; + + return cardinal; +})(0); + +function CardinalClosed(context, tension) { + this._context = context; + this._k = (1 - tension) / 6; +} + +CardinalClosed.prototype = { + areaStart: noop, + areaEnd: noop, + 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); + break; + } + } + }, + point: function(x, y) { + x = +x, y = +y; + switch (this._point) { + case 0: this._point = 1; this._x3 = x, this._y3 = y; break; + case 1: this._point = 2; this._context.moveTo(this._x4 = x, this._y4 = y); break; + case 2: this._point = 3; this._x5 = x, this._y5 = y; break; + default: point$2(this, x, y); break; + } + this._x0 = this._x1, this._x1 = this._x2, this._x2 = x; + this._y0 = this._y1, this._y1 = this._y2, this._y2 = y; + } +}; + +var cardinalClosed = (function custom(tension) { + + function cardinal(context) { + return new CardinalClosed(context, tension); + } + + cardinal.tension = function(tension) { + return custom(+tension); + }; + + return cardinal; +})(0); + +function CardinalOpen(context, tension) { + this._context = context; + this._k = (1 - tension) / 6; +} + +CardinalOpen.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() { + if (this._line || (this._line !== 0 && this._point === 3)) this._context.closePath(); + this._line = 1 - this._line; + }, + point: function(x, y) { + x = +x, y = +y; + 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; // falls through + default: point$2(this, x, y); break; + } + this._x0 = this._x1, this._x1 = this._x2, this._x2 = x; + this._y0 = this._y1, this._y1 = this._y2, this._y2 = y; + } +}; + +var cardinalOpen = (function custom(tension) { + + function cardinal(context) { + return new CardinalOpen(context, tension); + } + + cardinal.tension = function(tension) { + return custom(+tension); + }; + + return cardinal; +})(0); + +function point$1(that, x, y) { + var x1 = that._x1, + y1 = that._y1, + x2 = that._x2, + y2 = that._y2; + + if (that._l01_a > epsilon) { + var a = 2 * that._l01_2a + 3 * that._l01_a * that._l12_a + that._l12_2a, + n = 3 * that._l01_a * (that._l01_a + that._l12_a); + x1 = (x1 * a - that._x0 * that._l12_2a + that._x2 * that._l01_2a) / n; + y1 = (y1 * a - that._y0 * that._l12_2a + that._y2 * that._l01_2a) / n; + } + + if (that._l23_a > epsilon) { + var b = 2 * that._l23_2a + 3 * that._l23_a * that._l12_a + that._l12_2a, + m = 3 * that._l23_a * (that._l23_a + that._l12_a); + x2 = (x2 * b + that._x1 * that._l23_2a - x * that._l12_2a) / m; + y2 = (y2 * b + that._y1 * that._l23_2a - y * that._l12_2a) / m; + } + + that._context.bezierCurveTo(x1, y1, x2, y2, that._x2, that._y2); +} + +function CatmullRom(context, alpha) { + this._context = context; + this._alpha = alpha; +} + +CatmullRom.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); break; + } + if (this._line || (this._line !== 0 && this._point === 1)) this._context.closePath(); + this._line = 1 - this._line; + }, + point: function(x, y) { + x = +x, y = +y; + + if (this._point) { + var x23 = this._x2 - x, + y23 = this._y2 - y; + this._l23_a = Math.sqrt(this._l23_2a = Math.pow(x23 * x23 + y23 * y23, this._alpha)); + } + + switch (this._point) { + case 0: this._point = 1; this._line ? this._context.lineTo(x, y) : this._context.moveTo(x, y); break; + case 1: this._point = 2; break; + case 2: this._point = 3; // falls through + default: point$1(this, x, y); break; + } + + 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 = x; + this._y0 = this._y1, this._y1 = this._y2, this._y2 = y; + } +}; + +var catmullRom = (function custom(alpha) { + + function catmullRom(context) { + return alpha ? new CatmullRom(context, alpha) : new Cardinal(context, 0); + } + + catmullRom.alpha = function(alpha) { + return custom(+alpha); + }; + + return catmullRom; +})(0.5); + +function CatmullRomClosed(context, alpha) { + this._context = context; + this._alpha = alpha; +} + +CatmullRomClosed.prototype = { + areaStart: noop, + areaEnd: noop, + 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); + break; + } + } + }, + point: function(x, y) { + x = +x, y = +y; + + if (this._point) { + var x23 = this._x2 - x, + y23 = this._y2 - y; + this._l23_a = Math.sqrt(this._l23_2a = Math.pow(x23 * x23 + y23 * y23, this._alpha)); + } + + switch (this._point) { + case 0: this._point = 1; this._x3 = x, this._y3 = y; break; + case 1: this._point = 2; this._context.moveTo(this._x4 = x, this._y4 = y); break; + case 2: this._point = 3; this._x5 = x, this._y5 = y; break; + default: point$1(this, x, y); break; + } + + 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 = x; + this._y0 = this._y1, this._y1 = this._y2, this._y2 = y; + } +}; + +var catmullRomClosed = (function custom(alpha) { + + function catmullRom(context) { + return alpha ? new CatmullRomClosed(context, alpha) : new CardinalClosed(context, 0); + } + + catmullRom.alpha = function(alpha) { + return custom(+alpha); + }; + + return catmullRom; +})(0.5); + +function CatmullRomOpen(context, alpha) { + this._context = context; + this._alpha = alpha; +} + +CatmullRomOpen.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() { + if (this._line || (this._line !== 0 && this._point === 3)) this._context.closePath(); + this._line = 1 - this._line; + }, + point: function(x, y) { + x = +x, y = +y; + + if (this._point) { + var x23 = this._x2 - x, + y23 = this._y2 - y; + this._l23_a = Math.sqrt(this._l23_2a = Math.pow(x23 * x23 + y23 * y23, 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; // falls through + default: point$1(this, x, y); break; + } + + 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 = x; + this._y0 = this._y1, this._y1 = this._y2, this._y2 = y; + } +}; + +var catmullRomOpen = (function custom(alpha) { + + function catmullRom(context) { + return alpha ? new CatmullRomOpen(context, alpha) : new CardinalOpen(context, 0); + } + + catmullRom.alpha = function(alpha) { + return custom(+alpha); + }; + + return catmullRom; +})(0.5); + +function LinearClosed(context) { + this._context = context; +} + +LinearClosed.prototype = { + areaStart: noop, + areaEnd: noop, + lineStart: function() { + this._point = 0; + }, + lineEnd: function() { + if (this._point) this._context.closePath(); + }, + point: function(x, y) { + x = +x, y = +y; + if (this._point) this._context.lineTo(x, y); + else this._point = 1, this._context.moveTo(x, y); + } +}; + +function linearClosed(context) { + return new LinearClosed(context); +} + +function sign(x) { + return x < 0 ? -1 : 1; +} + +// Calculate the slopes of the tangents (Hermite-type interpolation) based on +// the following paper: Steffen, M. 1990. A Simple Method for Monotonic +// Interpolation in One Dimension. Astronomy and Astrophysics, Vol. 239, NO. +// NOV(II), P. 443, 1990. +function slope3(that, x2, y2) { + var h0 = that._x1 - that._x0, + h1 = x2 - that._x1, + s0 = (that._y1 - that._y0) / (h0 || h1 < 0 && -0), + s1 = (y2 - that._y1) / (h1 || h0 < 0 && -0), + p = (s0 * h1 + s1 * h0) / (h0 + h1); + return (sign(s0) + sign(s1)) * Math.min(Math.abs(s0), Math.abs(s1), 0.5 * Math.abs(p)) || 0; +} + +// Calculate a one-sided slope. +function slope2(that, t) { + var h = that._x1 - that._x0; + return h ? (3 * (that._y1 - that._y0) / h - t) / 2 : t; +} + +// According to https://en.wikipedia.org/wiki/Cubic_Hermite_spline#Representations +// "you can express cubic Hermite interpolation in terms of cubic Bézier curves +// with respect to the four values p0, p0 + m0 / 3, p1 - m1 / 3, p1". +function point(that, t0, t1) { + var x0 = that._x0, + y0 = that._y0, + x1 = that._x1, + y1 = that._y1, + dx = (x1 - x0) / 3; + that._context.bezierCurveTo(x0 + dx, y0 + dx * t0, x1 - dx, y1 - dx * t1, x1, y1); +} + +function MonotoneX(context) { + this._context = context; +} + +MonotoneX.prototype = { + areaStart: function() { + this._line = 0; + }, + areaEnd: function() { + this._line = NaN; + }, + lineStart: function() { + this._x0 = this._x1 = + this._y0 = this._y1 = + this._t0 = NaN; + this._point = 0; + }, + lineEnd: function() { + switch (this._point) { + case 2: this._context.lineTo(this._x1, this._y1); break; + case 3: point(this, this._t0, slope2(this, this._t0)); break; + } + if (this._line || (this._line !== 0 && this._point === 1)) this._context.closePath(); + this._line = 1 - this._line; + }, + point: function(x, y) { + var t1 = NaN; + + x = +x, y = +y; + if (x === this._x1 && y === this._y1) return; // Ignore coincident points. + switch (this._point) { + case 0: this._point = 1; this._line ? this._context.lineTo(x, y) : this._context.moveTo(x, y); break; + case 1: this._point = 2; break; + case 2: this._point = 3; point(this, slope2(this, t1 = slope3(this, x, y)), t1); break; + default: point(this, this._t0, t1 = slope3(this, x, y)); break; + } + + this._x0 = this._x1, this._x1 = x; + this._y0 = this._y1, this._y1 = y; + this._t0 = t1; + } +}; + +function MonotoneY(context) { + this._context = new ReflectContext(context); +} + +(MonotoneY.prototype = Object.create(MonotoneX.prototype)).point = function(x, y) { + MonotoneX.prototype.point.call(this, y, x); +}; + +function ReflectContext(context) { + this._context = context; +} + +ReflectContext.prototype = { + moveTo: function(x, y) { this._context.moveTo(y, x); }, + closePath: function() { this._context.closePath(); }, + lineTo: function(x, y) { this._context.lineTo(y, x); }, + bezierCurveTo: function(x1, y1, x2, y2, x, y) { this._context.bezierCurveTo(y1, x1, y2, x2, y, x); } +}; + +function monotoneX(context) { + return new MonotoneX(context); +} + +function monotoneY(context) { + return new MonotoneY(context); +} + +function Natural(context) { + this._context = context; +} + +Natural.prototype = { + areaStart: function() { + this._line = 0; + }, + areaEnd: function() { + this._line = NaN; + }, + lineStart: function() { + this._x = []; + this._y = []; + }, + lineEnd: function() { + var x = this._x, + y = this._y, + n = x.length; + + if (n) { + this._line ? this._context.lineTo(x[0], y[0]) : this._context.moveTo(x[0], y[0]); + if (n === 2) { + this._context.lineTo(x[1], y[1]); + } else { + var px = controlPoints(x), + py = controlPoints(y); + for (var i0 = 0, i1 = 1; i1 < n; ++i0, ++i1) { + this._context.bezierCurveTo(px[0][i0], py[0][i0], px[1][i0], py[1][i0], x[i1], y[i1]); + } + } + } + + if (this._line || (this._line !== 0 && n === 1)) this._context.closePath(); + this._line = 1 - this._line; + this._x = this._y = null; + }, + point: function(x, y) { + this._x.push(+x); + this._y.push(+y); + } +}; + +// See https://www.particleincell.com/2012/bezier-splines/ for derivation. +function controlPoints(x) { + var i, + n = x.length - 1, + m, + a = new Array(n), + b = new Array(n), + r = new Array(n); + a[0] = 0, b[0] = 2, r[0] = x[0] + 2 * x[1]; + for (i = 1; i < n - 1; ++i) a[i] = 1, b[i] = 4, r[i] = 4 * x[i] + 2 * x[i + 1]; + a[n - 1] = 2, b[n - 1] = 7, r[n - 1] = 8 * x[n - 1] + x[n]; + for (i = 1; i < n; ++i) m = a[i] / b[i - 1], b[i] -= m, r[i] -= m * r[i - 1]; + a[n - 1] = r[n - 1] / b[n - 1]; + for (i = n - 2; i >= 0; --i) a[i] = (r[i] - a[i + 1]) / b[i]; + b[n - 1] = (x[n] + a[n - 1]) / 2; + for (i = 0; i < n - 1; ++i) b[i] = 2 * x[i + 1] - a[i + 1]; + return [a, b]; +} + +function natural(context) { + return new Natural(context); +} + +function Step(context, t) { + this._context = context; + this._t = t; +} + +Step.prototype = { + areaStart: function() { + this._line = 0; + }, + areaEnd: function() { + this._line = NaN; + }, + lineStart: function() { + this._x = this._y = NaN; + this._point = 0; + }, + lineEnd: function() { + if (0 < this._t && this._t < 1 && this._point === 2) this._context.lineTo(this._x, this._y); + if (this._line || (this._line !== 0 && this._point === 1)) this._context.closePath(); + if (this._line >= 0) this._t = 1 - this._t, this._line = 1 - this._line; + }, + point: function(x, y) { + x = +x, y = +y; + switch (this._point) { + case 0: this._point = 1; this._line ? this._context.lineTo(x, y) : this._context.moveTo(x, y); break; + case 1: this._point = 2; // falls through + default: { + if (this._t <= 0) { + this._context.lineTo(this._x, y); + this._context.lineTo(x, y); + } else { + var x1 = this._x * (1 - this._t) + x * this._t; + this._context.lineTo(x1, this._y); + this._context.lineTo(x1, y); + } + break; + } + } + this._x = x, this._y = y; + } +}; + +function step(context) { + return new Step(context, 0.5); +} + +function stepBefore(context) { + return new Step(context, 0); +} + +function stepAfter(context) { + return new Step(context, 1); +} + +function none$1(series, order) { + if (!((n = series.length) > 1)) return; + for (var i = 1, j, s0, s1 = series[order[0]], n, m = s1.length; i < n; ++i) { + s0 = s1, s1 = series[order[i]]; + for (j = 0; j < m; ++j) { + s1[j][1] += s1[j][0] = isNaN(s0[j][1]) ? s0[j][0] : s0[j][1]; + } + } +} + +function none(series) { + var n = series.length, o = new Array(n); + while (--n >= 0) o[n] = n; + return o; +} + +function stackValue(d, key) { + return d[key]; +} + +function stackSeries(key) { + const series = []; + series.key = key; + return series; +} + +function stack() { + var keys = constant$1([]), + order = none, + offset = none$1, + value = stackValue; + + function stack(data) { + var sz = Array.from(keys.apply(this, arguments), stackSeries), + i, n = sz.length, j = -1, + oz; + + for (const d of data) { + for (i = 0, ++j; i < n; ++i) { + (sz[i][j] = [0, +value(d, sz[i].key, j, data)]).data = d; + } + } + + for (i = 0, oz = array(order(sz)); i < n; ++i) { + sz[oz[i]].index = i; + } + + offset(sz, oz); + return sz; + } + + stack.keys = function(_) { + return arguments.length ? (keys = typeof _ === "function" ? _ : constant$1(Array.from(_)), stack) : keys; + }; + + stack.value = function(_) { + return arguments.length ? (value = typeof _ === "function" ? _ : constant$1(+_), stack) : value; + }; + + stack.order = function(_) { + return arguments.length ? (order = _ == null ? none : typeof _ === "function" ? _ : constant$1(Array.from(_)), stack) : order; + }; + + stack.offset = function(_) { + return arguments.length ? (offset = _ == null ? none$1 : _, stack) : offset; + }; + + return stack; +} + +function expand(series, order) { + if (!((n = series.length) > 0)) return; + for (var i, n, j = 0, m = series[0].length, y; j < m; ++j) { + for (y = i = 0; i < n; ++i) y += series[i][j][1] || 0; + if (y) for (i = 0; i < n; ++i) series[i][j][1] /= y; + } + none$1(series, order); +} + +function diverging(series, order) { + if (!((n = series.length) > 0)) return; + for (var i, j = 0, d, dy, yp, yn, n, m = series[order[0]].length; j < m; ++j) { + for (yp = yn = 0, i = 0; i < n; ++i) { + if ((dy = (d = series[order[i]][j])[1] - d[0]) > 0) { + d[0] = yp, d[1] = yp += dy; + } else if (dy < 0) { + d[1] = yn, d[0] = yn += dy; + } else { + d[0] = 0, d[1] = dy; + } + } + } +} + +function silhouette(series, order) { + if (!((n = series.length) > 0)) return; + for (var j = 0, s0 = series[order[0]], n, m = s0.length; j < m; ++j) { + for (var i = 0, y = 0; i < n; ++i) y += series[i][j][1] || 0; + s0[j][1] += s0[j][0] = -y / 2; + } + none$1(series, order); +} + +function wiggle(series, order) { + if (!((n = series.length) > 0) || !((m = (s0 = series[order[0]]).length) > 0)) return; + for (var y = 0, j = 1, s0, m, n; j < m; ++j) { + for (var i = 0, s1 = 0, s2 = 0; i < n; ++i) { + var si = series[order[i]], + sij0 = si[j][1] || 0, + sij1 = si[j - 1][1] || 0, + s3 = (sij0 - sij1) / 2; + for (var k = 0; k < i; ++k) { + var sk = series[order[k]], + skj0 = sk[j][1] || 0, + skj1 = sk[j - 1][1] || 0; + s3 += skj0 - skj1; + } + s1 += sij0, s2 += s3 * sij0; + } + s0[j - 1][1] += s0[j - 1][0] = y; + if (s1) y -= s2 / s1; + } + s0[j - 1][1] += s0[j - 1][0] = y; + none$1(series, order); +} + +function appearance(series) { + var peaks = series.map(peak); + return none(series).sort(function(a, b) { return peaks[a] - peaks[b]; }); +} + +function peak(series) { + var i = -1, j = 0, n = series.length, vi, vj = -Infinity; + while (++i < n) if ((vi = +series[i][1]) > vj) vj = vi, j = i; + return j; +} + +function ascending(series) { + var sums = series.map(sum); + return none(series).sort(function(a, b) { return sums[a] - sums[b]; }); +} + +function sum(series) { + var s = 0, i = -1, n = series.length, v; + while (++i < n) if (v = +series[i][1]) s += v; + return s; +} + +function descending(series) { + return ascending(series).reverse(); +} + +function insideOut(series) { + var n = series.length, + i, + j, + sums = series.map(sum), + order = appearance(series), + top = 0, + bottom = 0, + tops = [], + bottoms = []; + + for (i = 0; i < n; ++i) { + j = order[i]; + if (top < bottom) { + top += sums[j]; + tops.push(j); + } else { + bottom += sums[j]; + bottoms.push(j); + } + } + + return bottoms.reverse().concat(tops); +} + +function reverse(series) { + return none(series).reverse(); +} + +var constant = x => () => x; + +function ZoomEvent(type, { + sourceEvent, + target, + transform, + dispatch +}) { + Object.defineProperties(this, { + type: {value: type, enumerable: true, configurable: true}, + sourceEvent: {value: sourceEvent, enumerable: true, configurable: true}, + target: {value: target, enumerable: true, configurable: true}, + transform: {value: transform, enumerable: true, configurable: true}, + _: {value: dispatch} + }); +} + +function Transform(k, x, y) { + this.k = k; + this.x = x; + this.y = y; +} + +Transform.prototype = { + constructor: Transform, + scale: function(k) { + return k === 1 ? this : new Transform(this.k * k, this.x, this.y); + }, + translate: function(x, y) { + return x === 0 & y === 0 ? this : new Transform(this.k, this.x + this.k * x, this.y + this.k * y); + }, + apply: function(point) { + return [point[0] * this.k + this.x, point[1] * this.k + this.y]; + }, + applyX: function(x) { + return x * this.k + this.x; + }, + applyY: function(y) { + return y * this.k + this.y; + }, + invert: function(location) { + return [(location[0] - this.x) / this.k, (location[1] - this.y) / this.k]; + }, + invertX: function(x) { + return (x - this.x) / this.k; + }, + invertY: function(y) { + return (y - this.y) / this.k; + }, + rescaleX: function(x) { + return x.copy().domain(x.range().map(this.invertX, this).map(x.invert, x)); + }, + rescaleY: function(y) { + return y.copy().domain(y.range().map(this.invertY, this).map(y.invert, y)); + }, + toString: function() { + return "translate(" + this.x + "," + this.y + ") scale(" + this.k + ")"; + } +}; + +var identity = new Transform(1, 0, 0); + +transform.prototype = Transform.prototype; + +function transform(node) { + while (!node.__zoom) if (!(node = node.parentNode)) return identity; + return node.__zoom; +} + +function nopropagation(event) { + event.stopImmediatePropagation(); +} + +function noevent(event) { + event.preventDefault(); + event.stopImmediatePropagation(); +} + +// Ignore right-click, since that should open the context menu. +// except for pinch-to-zoom, which is sent as a wheel+ctrlKey event +function defaultFilter(event) { + return (!event.ctrlKey || event.type === 'wheel') && !event.button; +} + +function defaultExtent() { + var e = this; + if (e instanceof SVGElement) { + e = e.ownerSVGElement || e; + if (e.hasAttribute("viewBox")) { + e = e.viewBox.baseVal; + return [[e.x, e.y], [e.x + e.width, e.y + e.height]]; + } + return [[0, 0], [e.width.baseVal.value, e.height.baseVal.value]]; + } + return [[0, 0], [e.clientWidth, e.clientHeight]]; +} + +function defaultTransform() { + return this.__zoom || identity; +} + +function defaultWheelDelta(event) { + return -event.deltaY * (event.deltaMode === 1 ? 0.05 : event.deltaMode ? 1 : 0.002) * (event.ctrlKey ? 10 : 1); +} + +function defaultTouchable() { + return navigator.maxTouchPoints || ("ontouchstart" in this); +} + +function defaultConstrain(transform, extent, translateExtent) { + var dx0 = transform.invertX(extent[0][0]) - translateExtent[0][0], + dx1 = transform.invertX(extent[1][0]) - translateExtent[1][0], + dy0 = transform.invertY(extent[0][1]) - translateExtent[0][1], + dy1 = transform.invertY(extent[1][1]) - translateExtent[1][1]; + return transform.translate( + dx1 > dx0 ? (dx0 + dx1) / 2 : Math.min(0, dx0) || Math.max(0, dx1), + dy1 > dy0 ? (dy0 + dy1) / 2 : Math.min(0, dy0) || Math.max(0, dy1) + ); +} + +function zoom() { + var filter = defaultFilter, + extent = defaultExtent, + constrain = defaultConstrain, + wheelDelta = defaultWheelDelta, + touchable = defaultTouchable, + scaleExtent = [0, Infinity], + translateExtent = [[-Infinity, -Infinity], [Infinity, Infinity]], + duration = 250, + interpolate = interpolateZoom, + listeners = dispatch("start", "zoom", "end"), + touchstarting, + touchfirst, + touchending, + touchDelay = 500, + wheelDelay = 150, + clickDistance2 = 0, + tapDistance = 10; + + function zoom(selection) { + selection + .property("__zoom", defaultTransform) + .on("wheel.zoom", wheeled, {passive: false}) + .on("mousedown.zoom", mousedowned) + .on("dblclick.zoom", dblclicked) + .filter(touchable) + .on("touchstart.zoom", touchstarted) + .on("touchmove.zoom", touchmoved) + .on("touchend.zoom touchcancel.zoom", touchended) + .style("-webkit-tap-highlight-color", "rgba(0,0,0,0)"); + } + + zoom.transform = function(collection, transform, point, event) { + var selection = collection.selection ? collection.selection() : collection; + selection.property("__zoom", defaultTransform); + if (collection !== selection) { + schedule(collection, transform, point, event); + } else { + selection.interrupt().each(function() { + gesture(this, arguments) + .event(event) + .start() + .zoom(null, typeof transform === "function" ? transform.apply(this, arguments) : transform) + .end(); + }); + } + }; + + zoom.scaleBy = function(selection, k, p, event) { + zoom.scaleTo(selection, function() { + var k0 = this.__zoom.k, + k1 = typeof k === "function" ? k.apply(this, arguments) : k; + return k0 * k1; + }, p, event); + }; + + zoom.scaleTo = function(selection, k, p, event) { + zoom.transform(selection, function() { + var e = extent.apply(this, arguments), + t0 = this.__zoom, + p0 = p == null ? centroid(e) : typeof p === "function" ? p.apply(this, arguments) : p, + p1 = t0.invert(p0), + k1 = typeof k === "function" ? k.apply(this, arguments) : k; + return constrain(translate(scale(t0, k1), p0, p1), e, translateExtent); + }, p, event); + }; + + zoom.translateBy = function(selection, x, y, event) { + zoom.transform(selection, function() { + return constrain(this.__zoom.translate( + typeof x === "function" ? x.apply(this, arguments) : x, + typeof y === "function" ? y.apply(this, arguments) : y + ), extent.apply(this, arguments), translateExtent); + }, null, event); + }; + + zoom.translateTo = function(selection, x, y, p, event) { + zoom.transform(selection, function() { + var e = extent.apply(this, arguments), + t = this.__zoom, + p0 = p == null ? centroid(e) : typeof p === "function" ? p.apply(this, arguments) : p; + return constrain(identity.translate(p0[0], p0[1]).scale(t.k).translate( + typeof x === "function" ? -x.apply(this, arguments) : -x, + typeof y === "function" ? -y.apply(this, arguments) : -y + ), e, translateExtent); + }, p, event); + }; + + function scale(transform, k) { + k = Math.max(scaleExtent[0], Math.min(scaleExtent[1], k)); + return k === transform.k ? transform : new Transform(k, transform.x, transform.y); + } + + function translate(transform, p0, p1) { + var x = p0[0] - p1[0] * transform.k, y = p0[1] - p1[1] * transform.k; + return x === transform.x && y === transform.y ? transform : new Transform(transform.k, x, y); + } + + function centroid(extent) { + return [(+extent[0][0] + +extent[1][0]) / 2, (+extent[0][1] + +extent[1][1]) / 2]; + } + + function schedule(transition, transform, point, event) { + transition + .on("start.zoom", function() { gesture(this, arguments).event(event).start(); }) + .on("interrupt.zoom end.zoom", function() { gesture(this, arguments).event(event).end(); }) + .tween("zoom", function() { + var that = this, + args = arguments, + g = gesture(that, args).event(event), + e = extent.apply(that, args), + p = point == null ? centroid(e) : typeof point === "function" ? point.apply(that, args) : point, + w = Math.max(e[1][0] - e[0][0], e[1][1] - e[0][1]), + a = that.__zoom, + b = typeof transform === "function" ? transform.apply(that, args) : transform, + i = interpolate(a.invert(p).concat(w / a.k), b.invert(p).concat(w / b.k)); + return function(t) { + if (t === 1) t = b; // Avoid rounding error on end. + else { var l = i(t), k = w / l[2]; t = new Transform(k, p[0] - l[0] * k, p[1] - l[1] * k); } + g.zoom(null, t); + }; + }); + } + + function gesture(that, args, clean) { + return (!clean && that.__zooming) || new Gesture(that, args); + } + + function Gesture(that, args) { + this.that = that; + this.args = args; + this.active = 0; + this.sourceEvent = null; + this.extent = extent.apply(that, args); + this.taps = 0; + } + + Gesture.prototype = { + event: function(event) { + if (event) this.sourceEvent = event; + return this; + }, + start: function() { + if (++this.active === 1) { + this.that.__zooming = this; + this.emit("start"); + } + return this; + }, + zoom: function(key, transform) { + if (this.mouse && key !== "mouse") this.mouse[1] = transform.invert(this.mouse[0]); + if (this.touch0 && key !== "touch") this.touch0[1] = transform.invert(this.touch0[0]); + if (this.touch1 && key !== "touch") this.touch1[1] = transform.invert(this.touch1[0]); + this.that.__zoom = transform; + this.emit("zoom"); + return this; + }, + end: function() { + if (--this.active === 0) { + delete this.that.__zooming; + this.emit("end"); + } + return this; + }, + emit: function(type) { + var d = select(this.that).datum(); + listeners.call( + type, + this.that, + new ZoomEvent(type, { + sourceEvent: this.sourceEvent, + target: zoom, + type, + transform: this.that.__zoom, + dispatch: listeners + }), + d + ); + } + }; + + function wheeled(event, ...args) { + if (!filter.apply(this, arguments)) return; + var g = gesture(this, args).event(event), + t = this.__zoom, + k = Math.max(scaleExtent[0], Math.min(scaleExtent[1], t.k * Math.pow(2, wheelDelta.apply(this, arguments)))), + p = pointer(event); + + // If the mouse is in the same location as before, reuse it. + // If there were recent wheel events, reset the wheel idle timeout. + if (g.wheel) { + if (g.mouse[0][0] !== p[0] || g.mouse[0][1] !== p[1]) { + g.mouse[1] = t.invert(g.mouse[0] = p); + } + clearTimeout(g.wheel); + } + + // If this wheel event won’t trigger a transform change, ignore it. + else if (t.k === k) return; + + // Otherwise, capture the mouse point and location at the start. + else { + g.mouse = [p, t.invert(p)]; + interrupt(this); + g.start(); + } + + noevent(event); + g.wheel = setTimeout(wheelidled, wheelDelay); + g.zoom("mouse", constrain(translate(scale(t, k), g.mouse[0], g.mouse[1]), g.extent, translateExtent)); + + function wheelidled() { + g.wheel = null; + g.end(); + } + } + + function mousedowned(event, ...args) { + if (touchending || !filter.apply(this, arguments)) return; + var currentTarget = event.currentTarget, + g = gesture(this, args, true).event(event), + v = select(event.view).on("mousemove.zoom", mousemoved, true).on("mouseup.zoom", mouseupped, true), + p = pointer(event, currentTarget), + x0 = event.clientX, + y0 = event.clientY; + + dragDisable(event.view); + nopropagation(event); + g.mouse = [p, this.__zoom.invert(p)]; + interrupt(this); + g.start(); + + function mousemoved(event) { + noevent(event); + if (!g.moved) { + var dx = event.clientX - x0, dy = event.clientY - y0; + g.moved = dx * dx + dy * dy > clickDistance2; + } + g.event(event) + .zoom("mouse", constrain(translate(g.that.__zoom, g.mouse[0] = pointer(event, currentTarget), g.mouse[1]), g.extent, translateExtent)); + } + + function mouseupped(event) { + v.on("mousemove.zoom mouseup.zoom", null); + yesdrag(event.view, g.moved); + noevent(event); + g.event(event).end(); + } + } + + function dblclicked(event, ...args) { + if (!filter.apply(this, arguments)) return; + var t0 = this.__zoom, + p0 = pointer(event.changedTouches ? event.changedTouches[0] : event, this), + p1 = t0.invert(p0), + k1 = t0.k * (event.shiftKey ? 0.5 : 2), + t1 = constrain(translate(scale(t0, k1), p0, p1), extent.apply(this, args), translateExtent); + + noevent(event); + if (duration > 0) select(this).transition().duration(duration).call(schedule, t1, p0, event); + else select(this).call(zoom.transform, t1, p0, event); + } + + function touchstarted(event, ...args) { + if (!filter.apply(this, arguments)) return; + var touches = event.touches, + n = touches.length, + g = gesture(this, args, event.changedTouches.length === n).event(event), + started, i, t, p; + + nopropagation(event); + for (i = 0; i < n; ++i) { + t = touches[i], p = pointer(t, this); + p = [p, this.__zoom.invert(p), t.identifier]; + if (!g.touch0) g.touch0 = p, started = true, g.taps = 1 + !!touchstarting; + else if (!g.touch1 && g.touch0[2] !== p[2]) g.touch1 = p, g.taps = 0; + } + + if (touchstarting) touchstarting = clearTimeout(touchstarting); + + if (started) { + if (g.taps < 2) touchfirst = p[0], touchstarting = setTimeout(function() { touchstarting = null; }, touchDelay); + interrupt(this); + g.start(); + } + } + + function touchmoved(event, ...args) { + if (!this.__zooming) return; + var g = gesture(this, args).event(event), + touches = event.changedTouches, + n = touches.length, i, t, p, l; + + noevent(event); + for (i = 0; i < n; ++i) { + t = touches[i], p = pointer(t, this); + if (g.touch0 && g.touch0[2] === t.identifier) g.touch0[0] = p; + else if (g.touch1 && g.touch1[2] === t.identifier) g.touch1[0] = p; + } + t = g.that.__zoom; + if (g.touch1) { + var p0 = g.touch0[0], l0 = g.touch0[1], + p1 = g.touch1[0], l1 = g.touch1[1], + dp = (dp = p1[0] - p0[0]) * dp + (dp = p1[1] - p0[1]) * dp, + dl = (dl = l1[0] - l0[0]) * dl + (dl = l1[1] - l0[1]) * dl; + t = scale(t, Math.sqrt(dp / dl)); + p = [(p0[0] + p1[0]) / 2, (p0[1] + p1[1]) / 2]; + l = [(l0[0] + l1[0]) / 2, (l0[1] + l1[1]) / 2]; + } + else if (g.touch0) p = g.touch0[0], l = g.touch0[1]; + else return; + + g.zoom("touch", constrain(translate(t, p, l), g.extent, translateExtent)); + } + + function touchended(event, ...args) { + if (!this.__zooming) return; + var g = gesture(this, args).event(event), + touches = event.changedTouches, + n = touches.length, i, t; + + nopropagation(event); + if (touchending) clearTimeout(touchending); + touchending = setTimeout(function() { touchending = null; }, touchDelay); + for (i = 0; i < n; ++i) { + t = touches[i]; + if (g.touch0 && g.touch0[2] === t.identifier) delete g.touch0; + else if (g.touch1 && g.touch1[2] === t.identifier) delete g.touch1; + } + if (g.touch1 && !g.touch0) g.touch0 = g.touch1, delete g.touch1; + if (g.touch0) g.touch0[1] = this.__zoom.invert(g.touch0[0]); + else { + g.end(); + // If this was a dbltap, reroute to the (optional) dblclick.zoom handler. + if (g.taps === 2) { + t = pointer(t, this); + if (Math.hypot(touchfirst[0] - t[0], touchfirst[1] - t[1]) < tapDistance) { + var p = select(this).on("dblclick.zoom"); + if (p) p.apply(this, arguments); + } + } + } + } + + zoom.wheelDelta = function(_) { + return arguments.length ? (wheelDelta = typeof _ === "function" ? _ : constant(+_), zoom) : wheelDelta; + }; + + zoom.filter = function(_) { + return arguments.length ? (filter = typeof _ === "function" ? _ : constant(!!_), zoom) : filter; + }; + + zoom.touchable = function(_) { + return arguments.length ? (touchable = typeof _ === "function" ? _ : constant(!!_), zoom) : touchable; + }; + + zoom.extent = function(_) { + return arguments.length ? (extent = typeof _ === "function" ? _ : constant([[+_[0][0], +_[0][1]], [+_[1][0], +_[1][1]]]), zoom) : extent; + }; + + zoom.scaleExtent = function(_) { + return arguments.length ? (scaleExtent[0] = +_[0], scaleExtent[1] = +_[1], zoom) : [scaleExtent[0], scaleExtent[1]]; + }; + + zoom.translateExtent = function(_) { + return arguments.length ? (translateExtent[0][0] = +_[0][0], translateExtent[1][0] = +_[1][0], translateExtent[0][1] = +_[0][1], translateExtent[1][1] = +_[1][1], zoom) : [[translateExtent[0][0], translateExtent[0][1]], [translateExtent[1][0], translateExtent[1][1]]]; + }; + + zoom.constrain = function(_) { + return arguments.length ? (constrain = _, zoom) : constrain; + }; + + zoom.duration = function(_) { + return arguments.length ? (duration = +_, zoom) : duration; + }; + + zoom.interpolate = function(_) { + return arguments.length ? (interpolate = _, zoom) : interpolate; + }; + + zoom.on = function() { + var value = listeners.on.apply(listeners, arguments); + return value === listeners ? zoom : value; + }; + + zoom.clickDistance = function(_) { + return arguments.length ? (clickDistance2 = (_ = +_) * _, zoom) : Math.sqrt(clickDistance2); + }; + + zoom.tapDistance = function(_) { + return arguments.length ? (tapDistance = +_, zoom) : tapDistance; + }; + + return zoom; +} + +exports.Adder = Adder; +exports.Delaunay = Delaunay; +exports.FormatSpecifier = FormatSpecifier; +exports.InternMap = InternMap; +exports.InternSet = InternSet; +exports.Node = Node$1; +exports.Voronoi = Voronoi; +exports.ZoomTransform = Transform; +exports.active = active; +exports.arc = arc; +exports.area = area; +exports.areaRadial = areaRadial; +exports.ascending = ascending$3; +exports.autoType = autoType; +exports.axisBottom = axisBottom; +exports.axisLeft = axisLeft; +exports.axisRight = axisRight; +exports.axisTop = axisTop; +exports.bin = bin; +exports.bisect = bisect; +exports.bisectCenter = bisectCenter; +exports.bisectLeft = bisectLeft; +exports.bisectRight = bisectRight; +exports.bisector = bisector; +exports.blob = blob; +exports.brush = brush; +exports.brushSelection = brushSelection; +exports.brushX = brushX; +exports.brushY = brushY; +exports.buffer = buffer; +exports.chord = chord; +exports.chordDirected = chordDirected; +exports.chordTranspose = chordTranspose; +exports.cluster = cluster; +exports.color = color; +exports.contourDensity = density; +exports.contours = contours; +exports.count = count$1; +exports.create = create$1; +exports.creator = creator; +exports.cross = cross$2; +exports.csv = csv; +exports.csvFormat = csvFormat; +exports.csvFormatBody = csvFormatBody; +exports.csvFormatRow = csvFormatRow; +exports.csvFormatRows = csvFormatRows; +exports.csvFormatValue = csvFormatValue; +exports.csvParse = csvParse; +exports.csvParseRows = csvParseRows; +exports.cubehelix = cubehelix$3; +exports.cumsum = cumsum; +exports.curveBasis = basis; +exports.curveBasisClosed = basisClosed; +exports.curveBasisOpen = basisOpen; +exports.curveBumpX = bumpX; +exports.curveBumpY = bumpY; +exports.curveBundle = bundle; +exports.curveCardinal = cardinal; +exports.curveCardinalClosed = cardinalClosed; +exports.curveCardinalOpen = cardinalOpen; +exports.curveCatmullRom = catmullRom; +exports.curveCatmullRomClosed = catmullRomClosed; +exports.curveCatmullRomOpen = catmullRomOpen; +exports.curveLinear = curveLinear; +exports.curveLinearClosed = linearClosed; +exports.curveMonotoneX = monotoneX; +exports.curveMonotoneY = monotoneY; +exports.curveNatural = natural; +exports.curveStep = step; +exports.curveStepAfter = stepAfter; +exports.curveStepBefore = stepBefore; +exports.descending = descending$2; +exports.deviation = deviation; +exports.difference = difference; +exports.disjoint = disjoint; +exports.dispatch = dispatch; +exports.drag = drag; +exports.dragDisable = dragDisable; +exports.dragEnable = yesdrag; +exports.dsv = dsv; +exports.dsvFormat = dsvFormat; +exports.easeBack = backInOut; +exports.easeBackIn = backIn; +exports.easeBackInOut = backInOut; +exports.easeBackOut = backOut; +exports.easeBounce = bounceOut; +exports.easeBounceIn = bounceIn; +exports.easeBounceInOut = bounceInOut; +exports.easeBounceOut = bounceOut; +exports.easeCircle = circleInOut; +exports.easeCircleIn = circleIn; +exports.easeCircleInOut = circleInOut; +exports.easeCircleOut = circleOut; +exports.easeCubic = cubicInOut; +exports.easeCubicIn = cubicIn; +exports.easeCubicInOut = cubicInOut; +exports.easeCubicOut = cubicOut; +exports.easeElastic = elasticOut; +exports.easeElasticIn = elasticIn; +exports.easeElasticInOut = elasticInOut; +exports.easeElasticOut = elasticOut; +exports.easeExp = expInOut; +exports.easeExpIn = expIn; +exports.easeExpInOut = expInOut; +exports.easeExpOut = expOut; +exports.easeLinear = linear$1; +exports.easePoly = polyInOut; +exports.easePolyIn = polyIn; +exports.easePolyInOut = polyInOut; +exports.easePolyOut = polyOut; +exports.easeQuad = quadInOut; +exports.easeQuadIn = quadIn; +exports.easeQuadInOut = quadInOut; +exports.easeQuadOut = quadOut; +exports.easeSin = sinInOut; +exports.easeSinIn = sinIn; +exports.easeSinInOut = sinInOut; +exports.easeSinOut = sinOut; +exports.every = every; +exports.extent = extent$1; +exports.fcumsum = fcumsum; +exports.filter = filter$1; +exports.flatGroup = flatGroup; +exports.flatRollup = flatRollup; +exports.forceCenter = center; +exports.forceCollide = collide; +exports.forceLink = link$2; +exports.forceManyBody = manyBody; +exports.forceRadial = radial$1; +exports.forceSimulation = simulation; +exports.forceX = x$1; +exports.forceY = y$1; +exports.formatDefaultLocale = defaultLocale$1; +exports.formatLocale = formatLocale$1; +exports.formatSpecifier = formatSpecifier; +exports.fsum = fsum; +exports.geoAlbers = albers; +exports.geoAlbersUsa = albersUsa; +exports.geoArea = area$2; +exports.geoAzimuthalEqualArea = azimuthalEqualArea; +exports.geoAzimuthalEqualAreaRaw = azimuthalEqualAreaRaw; +exports.geoAzimuthalEquidistant = azimuthalEquidistant; +exports.geoAzimuthalEquidistantRaw = azimuthalEquidistantRaw; +exports.geoBounds = bounds; +exports.geoCentroid = centroid$1; +exports.geoCircle = circle$2; +exports.geoClipAntimeridian = clipAntimeridian; +exports.geoClipCircle = clipCircle; +exports.geoClipExtent = extent; +exports.geoClipRectangle = clipRectangle; +exports.geoConicConformal = conicConformal; +exports.geoConicConformalRaw = conicConformalRaw; +exports.geoConicEqualArea = conicEqualArea; +exports.geoConicEqualAreaRaw = conicEqualAreaRaw; +exports.geoConicEquidistant = conicEquidistant; +exports.geoConicEquidistantRaw = conicEquidistantRaw; +exports.geoContains = contains$1; +exports.geoDistance = distance; +exports.geoEqualEarth = equalEarth; +exports.geoEqualEarthRaw = equalEarthRaw; +exports.geoEquirectangular = equirectangular; +exports.geoEquirectangularRaw = equirectangularRaw; +exports.geoGnomonic = gnomonic; +exports.geoGnomonicRaw = gnomonicRaw; +exports.geoGraticule = graticule; +exports.geoGraticule10 = graticule10; +exports.geoIdentity = identity$4; +exports.geoInterpolate = interpolate; +exports.geoLength = length$1; +exports.geoMercator = mercator; +exports.geoMercatorRaw = mercatorRaw; +exports.geoNaturalEarth1 = naturalEarth1; +exports.geoNaturalEarth1Raw = naturalEarth1Raw; +exports.geoOrthographic = orthographic; +exports.geoOrthographicRaw = orthographicRaw; +exports.geoPath = index$2; +exports.geoProjection = projection; +exports.geoProjectionMutator = projectionMutator; +exports.geoRotation = rotation; +exports.geoStereographic = stereographic; +exports.geoStereographicRaw = stereographicRaw; +exports.geoStream = geoStream; +exports.geoTransform = transform$1; +exports.geoTransverseMercator = transverseMercator; +exports.geoTransverseMercatorRaw = transverseMercatorRaw; +exports.gray = gray; +exports.greatest = greatest; +exports.greatestIndex = greatestIndex; +exports.group = group; +exports.groupSort = groupSort; +exports.groups = groups; +exports.hcl = hcl$2; +exports.hierarchy = hierarchy; +exports.histogram = bin; +exports.hsl = hsl$2; +exports.html = html; +exports.image = image; +exports.index = index$4; +exports.indexes = indexes; +exports.interpolate = interpolate$2; +exports.interpolateArray = array$3; +exports.interpolateBasis = basis$2; +exports.interpolateBasisClosed = basisClosed$1; +exports.interpolateBlues = Blues; +exports.interpolateBrBG = BrBG; +exports.interpolateBuGn = BuGn; +exports.interpolateBuPu = BuPu; +exports.interpolateCividis = cividis; +exports.interpolateCool = cool; +exports.interpolateCubehelix = cubehelix$2; +exports.interpolateCubehelixDefault = cubehelix; +exports.interpolateCubehelixLong = cubehelixLong; +exports.interpolateDate = date$1; +exports.interpolateDiscrete = discrete; +exports.interpolateGnBu = GnBu; +exports.interpolateGreens = Greens; +exports.interpolateGreys = Greys; +exports.interpolateHcl = hcl$1; +exports.interpolateHclLong = hclLong; +exports.interpolateHsl = hsl$1; +exports.interpolateHslLong = hslLong; +exports.interpolateHue = hue; +exports.interpolateInferno = inferno; +exports.interpolateLab = lab; +exports.interpolateMagma = magma; +exports.interpolateNumber = interpolateNumber; +exports.interpolateNumberArray = numberArray; +exports.interpolateObject = object$1; +exports.interpolateOrRd = OrRd; +exports.interpolateOranges = Oranges; +exports.interpolatePRGn = PRGn; +exports.interpolatePiYG = PiYG; +exports.interpolatePlasma = plasma; +exports.interpolatePuBu = PuBu; +exports.interpolatePuBuGn = PuBuGn; +exports.interpolatePuOr = PuOr; +exports.interpolatePuRd = PuRd; +exports.interpolatePurples = Purples; +exports.interpolateRainbow = rainbow; +exports.interpolateRdBu = RdBu; +exports.interpolateRdGy = RdGy; +exports.interpolateRdPu = RdPu; +exports.interpolateRdYlBu = RdYlBu; +exports.interpolateRdYlGn = RdYlGn; +exports.interpolateReds = Reds; +exports.interpolateRgb = interpolateRgb; +exports.interpolateRgbBasis = rgbBasis; +exports.interpolateRgbBasisClosed = rgbBasisClosed; +exports.interpolateRound = interpolateRound; +exports.interpolateSinebow = sinebow; +exports.interpolateSpectral = Spectral; +exports.interpolateString = interpolateString; +exports.interpolateTransformCss = interpolateTransformCss; +exports.interpolateTransformSvg = interpolateTransformSvg; +exports.interpolateTurbo = turbo; +exports.interpolateViridis = viridis; +exports.interpolateWarm = warm; +exports.interpolateYlGn = YlGn; +exports.interpolateYlGnBu = YlGnBu; +exports.interpolateYlOrBr = YlOrBr; +exports.interpolateYlOrRd = YlOrRd; +exports.interpolateZoom = interpolateZoom; +exports.interrupt = interrupt; +exports.intersection = intersection; +exports.interval = interval; +exports.isoFormat = formatIso$1; +exports.isoParse = parseIso$1; +exports.json = json; +exports.lab = lab$1; +exports.lch = lch; +exports.least = least; +exports.leastIndex = leastIndex; +exports.line = line; +exports.lineRadial = lineRadial$1; +exports.linkHorizontal = linkHorizontal; +exports.linkRadial = linkRadial; +exports.linkVertical = linkVertical; +exports.local = local$1; +exports.map = map$1; +exports.matcher = matcher; +exports.max = max$3; +exports.maxIndex = maxIndex; +exports.mean = mean; +exports.median = median; +exports.merge = merge; +exports.min = min$2; +exports.minIndex = minIndex; +exports.mode = mode; +exports.namespace = namespace; +exports.namespaces = namespaces; +exports.nice = nice$1; +exports.now = now; +exports.pack = index$1; +exports.packEnclose = enclose; +exports.packSiblings = siblings; +exports.pairs = pairs; +exports.partition = partition; +exports.path = path; +exports.permute = permute; +exports.pie = pie; +exports.piecewise = piecewise; +exports.pointRadial = pointRadial; +exports.pointer = pointer; +exports.pointers = pointers; +exports.polygonArea = area$1; +exports.polygonCentroid = centroid; +exports.polygonContains = contains; +exports.polygonHull = hull; +exports.polygonLength = length; +exports.precisionFixed = precisionFixed; +exports.precisionPrefix = precisionPrefix; +exports.precisionRound = precisionRound; +exports.quadtree = quadtree; +exports.quantile = quantile$1; +exports.quantileSorted = quantileSorted; +exports.quantize = quantize$1; +exports.quickselect = quickselect; +exports.radialArea = areaRadial; +exports.radialLine = lineRadial$1; +exports.randomBates = bates; +exports.randomBernoulli = bernoulli; +exports.randomBeta = beta; +exports.randomBinomial = binomial; +exports.randomCauchy = cauchy; +exports.randomExponential = exponential; +exports.randomGamma = gamma; +exports.randomGeometric = geometric; +exports.randomInt = int; +exports.randomIrwinHall = irwinHall; +exports.randomLcg = lcg; +exports.randomLogNormal = logNormal; +exports.randomLogistic = logistic; +exports.randomNormal = normal; +exports.randomPareto = pareto; +exports.randomPoisson = poisson; +exports.randomUniform = uniform; +exports.randomWeibull = weibull; +exports.range = range$2; +exports.rank = rank; +exports.reduce = reduce; +exports.reverse = reverse$1; +exports.rgb = rgb; +exports.ribbon = ribbon$1; +exports.ribbonArrow = ribbonArrow; +exports.rollup = rollup; +exports.rollups = rollups; +exports.scaleBand = band; +exports.scaleDiverging = diverging$1; +exports.scaleDivergingLog = divergingLog; +exports.scaleDivergingPow = divergingPow; +exports.scaleDivergingSqrt = divergingSqrt; +exports.scaleDivergingSymlog = divergingSymlog; +exports.scaleIdentity = identity$2; +exports.scaleImplicit = implicit; +exports.scaleLinear = linear; +exports.scaleLog = log; +exports.scaleOrdinal = ordinal; +exports.scalePoint = point$4; +exports.scalePow = pow; +exports.scaleQuantile = quantile; +exports.scaleQuantize = quantize; +exports.scaleRadial = radial; +exports.scaleSequential = sequential; +exports.scaleSequentialLog = sequentialLog; +exports.scaleSequentialPow = sequentialPow; +exports.scaleSequentialQuantile = sequentialQuantile; +exports.scaleSequentialSqrt = sequentialSqrt; +exports.scaleSequentialSymlog = sequentialSymlog; +exports.scaleSqrt = sqrt$1; +exports.scaleSymlog = symlog; +exports.scaleThreshold = threshold; +exports.scaleTime = time; +exports.scaleUtc = utcTime; +exports.scan = scan; +exports.schemeAccent = Accent; +exports.schemeBlues = scheme$5; +exports.schemeBrBG = scheme$q; +exports.schemeBuGn = scheme$h; +exports.schemeBuPu = scheme$g; +exports.schemeCategory10 = category10; +exports.schemeDark2 = Dark2; +exports.schemeGnBu = scheme$f; +exports.schemeGreens = scheme$4; +exports.schemeGreys = scheme$3; +exports.schemeOrRd = scheme$e; +exports.schemeOranges = scheme; +exports.schemePRGn = scheme$p; +exports.schemePaired = Paired; +exports.schemePastel1 = Pastel1; +exports.schemePastel2 = Pastel2; +exports.schemePiYG = scheme$o; +exports.schemePuBu = scheme$c; +exports.schemePuBuGn = scheme$d; +exports.schemePuOr = scheme$n; +exports.schemePuRd = scheme$b; +exports.schemePurples = scheme$2; +exports.schemeRdBu = scheme$m; +exports.schemeRdGy = scheme$l; +exports.schemeRdPu = scheme$a; +exports.schemeRdYlBu = scheme$k; +exports.schemeRdYlGn = scheme$j; +exports.schemeReds = scheme$1; +exports.schemeSet1 = Set1; +exports.schemeSet2 = Set2; +exports.schemeSet3 = Set3; +exports.schemeSpectral = scheme$i; +exports.schemeTableau10 = Tableau10; +exports.schemeYlGn = scheme$8; +exports.schemeYlGnBu = scheme$9; +exports.schemeYlOrBr = scheme$7; +exports.schemeYlOrRd = scheme$6; +exports.select = select; +exports.selectAll = selectAll; +exports.selection = selection; +exports.selector = selector; +exports.selectorAll = selectorAll; +exports.shuffle = shuffle$1; +exports.shuffler = shuffler; +exports.some = some; +exports.sort = sort; +exports.stack = stack; +exports.stackOffsetDiverging = diverging; +exports.stackOffsetExpand = expand; +exports.stackOffsetNone = none$1; +exports.stackOffsetSilhouette = silhouette; +exports.stackOffsetWiggle = wiggle; +exports.stackOrderAppearance = appearance; +exports.stackOrderAscending = ascending; +exports.stackOrderDescending = descending; +exports.stackOrderInsideOut = insideOut; +exports.stackOrderNone = none; +exports.stackOrderReverse = reverse; +exports.stratify = stratify; +exports.style = styleValue; +exports.subset = subset; +exports.sum = sum$2; +exports.superset = superset; +exports.svg = svg; +exports.symbol = symbol; +exports.symbolCircle = circle; +exports.symbolCross = cross; +exports.symbolDiamond = diamond; +exports.symbolSquare = square; +exports.symbolStar = star; +exports.symbolTriangle = triangle; +exports.symbolWye = wye; +exports.symbols = symbols; +exports.text = text; +exports.thresholdFreedmanDiaconis = thresholdFreedmanDiaconis; +exports.thresholdScott = thresholdScott; +exports.thresholdSturges = thresholdSturges; +exports.tickFormat = tickFormat; +exports.tickIncrement = tickIncrement; +exports.tickStep = tickStep; +exports.ticks = ticks; +exports.timeDay = timeDay; +exports.timeDays = days; +exports.timeFormatDefaultLocale = defaultLocale; +exports.timeFormatLocale = formatLocale; +exports.timeFriday = friday; +exports.timeFridays = fridays; +exports.timeHour = timeHour; +exports.timeHours = hours; +exports.timeInterval = newInterval; +exports.timeMillisecond = millisecond$1; +exports.timeMilliseconds = milliseconds; +exports.timeMinute = timeMinute; +exports.timeMinutes = minutes; +exports.timeMonday = monday; +exports.timeMondays = mondays; +exports.timeMonth = timeMonth; +exports.timeMonths = months; +exports.timeSaturday = saturday; +exports.timeSaturdays = saturdays; +exports.timeSecond = utcSecond; +exports.timeSeconds = seconds; +exports.timeSunday = sunday; +exports.timeSundays = sundays; +exports.timeThursday = thursday; +exports.timeThursdays = thursdays; +exports.timeTickInterval = timeTickInterval; +exports.timeTicks = timeTicks; +exports.timeTuesday = tuesday; +exports.timeTuesdays = tuesdays; +exports.timeWednesday = wednesday; +exports.timeWednesdays = wednesdays; +exports.timeWeek = sunday; +exports.timeWeeks = sundays; +exports.timeYear = timeYear; +exports.timeYears = years; +exports.timeout = timeout; +exports.timer = timer; +exports.timerFlush = timerFlush; +exports.transition = transition; +exports.transpose = transpose; +exports.tree = tree; +exports.treemap = index; +exports.treemapBinary = binary; +exports.treemapDice = treemapDice; +exports.treemapResquarify = resquarify; +exports.treemapSlice = treemapSlice; +exports.treemapSliceDice = sliceDice; +exports.treemapSquarify = squarify; +exports.tsv = tsv; +exports.tsvFormat = tsvFormat; +exports.tsvFormatBody = tsvFormatBody; +exports.tsvFormatRow = tsvFormatRow; +exports.tsvFormatRows = tsvFormatRows; +exports.tsvFormatValue = tsvFormatValue; +exports.tsvParse = tsvParse; +exports.tsvParseRows = tsvParseRows; +exports.union = union; +exports.utcDay = utcDay$1; +exports.utcDays = utcDays; +exports.utcFriday = utcFriday; +exports.utcFridays = utcFridays; +exports.utcHour = utcHour$1; +exports.utcHours = utcHours; +exports.utcMillisecond = millisecond$1; +exports.utcMilliseconds = milliseconds; +exports.utcMinute = utcMinute$1; +exports.utcMinutes = utcMinutes; +exports.utcMonday = utcMonday; +exports.utcMondays = utcMondays; +exports.utcMonth = utcMonth$1; +exports.utcMonths = utcMonths; +exports.utcSaturday = utcSaturday; +exports.utcSaturdays = utcSaturdays; +exports.utcSecond = utcSecond; +exports.utcSeconds = seconds; +exports.utcSunday = utcSunday; +exports.utcSundays = utcSundays; +exports.utcThursday = utcThursday; +exports.utcThursdays = utcThursdays; +exports.utcTickInterval = utcTickInterval; +exports.utcTicks = utcTicks; +exports.utcTuesday = utcTuesday; +exports.utcTuesdays = utcTuesdays; +exports.utcWednesday = utcWednesday; +exports.utcWednesdays = utcWednesdays; +exports.utcWeek = utcSunday; +exports.utcWeeks = utcSundays; +exports.utcYear = utcYear$1; +exports.utcYears = utcYears; +exports.variance = variance; +exports.version = version; +exports.window = defaultView; +exports.xml = xml; +exports.zip = zip; +exports.zoom = zoom; +exports.zoomIdentity = identity; +exports.zoomTransform = transform; + +Object.defineProperty(exports, '__esModule', { value: true }); + +})); + + +/***/ }), + +/***/ "./src/attention_matrix_view.ts": +/*!**************************************!*\ + !*** ./src/attention_matrix_view.ts ***! + \**************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ AttentionMatrixView: () => (/* binding */ AttentionMatrixView) +/* harmony export */ }); +/* harmony import */ var _lib_weya_weya__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../lib/weya/weya */ "../../weya/weya.ts"); +/* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./utils */ "./src/utils.ts"); +/* harmony import */ var _types__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./types */ "./src/types.ts"); + + + +class CellView { + constructor(plotColors) { + this.plotColors = plotColors; + } + render(row, col, cellSize) { + this.elem = (0,_lib_weya_weya__WEBPACK_IMPORTED_MODULE_0__.Weya)('rect', '.cell', { + x: col * cellSize, + y: row * cellSize, + width: cellSize, + height: cellSize + }); + this.titleElem = document.createElementNS("http://www.w3.org/2000/svg", "title"); + this.elem.appendChild(this.titleElem); + return this.elem; + } + setAttn(value) { + if (this.selected) { + this.elem.style.setProperty('fill', this.plotColors.getInterpolatedColor(value, _types__WEBPACK_IMPORTED_MODULE_2__.ChartType.AttentionMatrix)); + } + else { + this.elem.style.setProperty('fill', this.plotColors.getInterpolatedSecondaryColor(value)); + } + this.titleElem.textContent = value.toExponential(); + } + setSelection(selected) { + this.selected = selected; + } +} +class AttentionMatrixView { + constructor(srcTokens, dstTokens, plotColors) { + this.onItemSelect = (type, idx, isMulti) => { + this.handler(type, idx, isMulti); + }; + this.srcTokens = srcTokens; + this.dstTokens = dstTokens; + this.attentions = (0,_utils__WEBPACK_IMPORTED_MODULE_1__.createMatrix)(srcTokens.length, dstTokens.length); + this.srcTokenElems = []; + for (let i = 0; i < srcTokens.length; ++i) { + let v = this.srcTokens.getTokenLabelView(i); + v.addClickHandler('src', i, this.onItemSelect); + this.srcTokenElems.push(v); + } + this.dstTokenElems = []; + for (let i = 0; i < dstTokens.length; ++i) { + let v = this.dstTokens.getTokenLabelView(i); + v.addClickHandler('dst', i, this.onItemSelect); + this.dstTokenElems.push(v); + } + this.cells = []; + for (let i = 0; i < srcTokens.length; ++i) { + this.cells.push([]); + for (let j = 0; j < dstTokens.length; ++j) { + this.cells[i].push(new CellView(plotColors)); + } + } + this.cellSize = 20; + this.topLabelsMargin = 50; + this.leftLabelsMargin = 50; + this.labelCellGap = 5; + } + render() { + let grid; + let svgAttrs = { + width: this.cellSize * this.dstTokens.length + this.leftLabelsMargin, + height: this.cellSize * this.srcTokens.length + this.leftLabelsMargin, + viewBox: `0 0 ${this.cellSize * this.dstTokens.length + this.leftLabelsMargin} ${this.cellSize * this.srcTokens.length + this.leftLabelsMargin}` + }; + let matrix = (0,_lib_weya_weya__WEBPACK_IMPORTED_MODULE_0__.Weya)('svg', '.matrix', svgAttrs, $ => { + grid = $('g', '.grid', { transform: `translate(${this.leftLabelsMargin}, ${this.topLabelsMargin})` }); + this.srcLabels = []; + $('g', '.src_labels', { transform: `translate(${this.leftLabelsMargin - this.labelCellGap}, ${this.topLabelsMargin + this.cellSize / 2})` }, $ => { + for (let i = 0; i < this.srcTokens.length; ++i) { + this.srcLabels.push($('g', '.label', { transform: `translate(0, ${this.cellSize * i})` })); + } + }); + for (let i = 0; i < this.srcTokens.length; ++i) { + this.srcLabels[i].appendChild(this.srcTokenElems[i].render(this.cellSize, false)); + } + this.dstLabels = []; + $('g', '.dst_labels', { transform: `translate(${this.leftLabelsMargin + this.cellSize / 2}, ${this.topLabelsMargin - this.labelCellGap})` }, $ => { + for (let i = 0; i < this.dstTokens.length; ++i) { + this.dstLabels.push($('g', '.label', { transform: `translate(${this.cellSize * i}, 0)` })); + } + }); + for (let i = 0; i < this.dstTokens.length; ++i) { + this.dstLabels[i].appendChild(this.dstTokenElems[i].render(this.cellSize, true)); + } + }); + for (let i = 0; i < this.srcTokens.length; ++i) { + for (let j = 0; j < this.dstTokens.length; ++j) { + grid.appendChild(this.cells[i][j].render(i, j, this.cellSize)); + } + } + return matrix; + } + setAttention(attn) { + for (let i = 0; i < this.srcTokens.length; ++i) { + for (let j = 0; j < this.dstTokens.length; ++j) { + this.cells[i][j].setAttn(attn[i][j]); + } + } + } + setSelection(src, dst) { + for (let i = 0; i < this.srcTokens.length; ++i) { + for (let j = 0; j < this.dstTokens.length; ++j) { + this.cells[i][j].setSelection(src[i] === true && dst[j] === true); + } + } + for (let i = 0; i < this.srcTokens.length; i++) { + this.srcLabels[i].style.setProperty('opacity', src[i] === true ? '1' : '0.6'); + this.srcLabels[i].style.setProperty('font-weight', src[i] === true ? 'bold' : 'normal'); + } + for (let i = 0; i < this.dstTokens.length; i++) { + this.dstLabels[i].style.setProperty('opacity', dst[i] === true ? '1' : '0.6'); + this.dstLabels[i].style.setProperty('font-weight', dst[i] === true ? 'bold' : 'normal'); + } + } +} + + +/***/ }), + +/***/ "./src/colors.ts": +/*!***********************!*\ + !*** ./src/colors.ts ***! + \***********************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ PlotColors: () => (/* binding */ PlotColors) +/* harmony export */ }); +/* harmony import */ var _lib_d3_d3__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../lib/d3/d3 */ "./lib/d3/d3.js"); +/* harmony import */ var _lib_d3_d3__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_lib_d3_d3__WEBPACK_IMPORTED_MODULE_0__); +/* harmony import */ var _types__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./types */ "./src/types.ts"); + + +class PlotColors { + constructor(theme) { + this.colorSchemes = { + [_types__WEBPACK_IMPORTED_MODULE_1__.ChartType.AttentionMatrix]: 'Blues', + [_types__WEBPACK_IMPORTED_MODULE_1__.ChartType.SrcTokenHeatmap]: 'Blues', + [_types__WEBPACK_IMPORTED_MODULE_1__.ChartType.DestTokenHeatmap]: 'Blues', + [_types__WEBPACK_IMPORTED_MODULE_1__.ChartType.TokenDimHeatmap]: 'Blues', + [_types__WEBPACK_IMPORTED_MODULE_1__.ChartType.DimensionHeatmap]: 'Blues', + [_types__WEBPACK_IMPORTED_MODULE_1__.ChartType.LineGrid]: 'Blues', + [_types__WEBPACK_IMPORTED_MODULE_1__.ChartType.TokenLoss]: 'Blues' + }; + if (theme === 'auto') { + this.theme = window.matchMedia('(prefers-color-scheme: light)').matches ? 'light' : 'dark'; + } + else { + this.theme = theme; + } + } + setColorScheme(scheme) { + for (let key in scheme) { + let s = scheme[key]; + switch (s.toLowerCase()) { + case 'blue': + s = 'blues'; + break; + case 'green': + s = 'greens'; + break; + case 'grey': + s = 'greys'; + break; + case 'orange': + s = 'oranges'; + break; + case 'purple': + s = 'purples'; + break; + case 'red': + s = 'reds'; + break; + } + this.colorSchemes[key] = s; + } + } + getBackgroundColor() { + if (this.theme === 'light') { + return _lib_d3_d3__WEBPACK_IMPORTED_MODULE_0__.interpolateGreys(0); + } + else { + return _lib_d3_d3__WEBPACK_IMPORTED_MODULE_0__.interpolateGreys(1); + } + } + getFilledTextColor() { + if (this.theme === 'light') { + return _lib_d3_d3__WEBPACK_IMPORTED_MODULE_0__.interpolateGreys(1); + } + else { + return _lib_d3_d3__WEBPACK_IMPORTED_MODULE_0__.interpolateGreys(0); + } + } + getInterpolatedSecondaryColor(value) { + if (this.theme === 'light') { + value = 1 - value; + } + return _lib_d3_d3__WEBPACK_IMPORTED_MODULE_0__.interpolateGreys(value); + } + getInterpolatedColor(value, chart) { + if (this.theme === 'dark') { + value = 0.3 + (1 - value) * 0.7; + } + else { + value = value * 0.8; + } + let color = this.colorSchemes[chart]; + switch (color.toLowerCase()) { + case 'blues': + return _lib_d3_d3__WEBPACK_IMPORTED_MODULE_0__.interpolateBlues(value); + case 'greens': + return _lib_d3_d3__WEBPACK_IMPORTED_MODULE_0__.interpolateGreens(value); + case 'greys': + return _lib_d3_d3__WEBPACK_IMPORTED_MODULE_0__.interpolateGreys(value); + case 'oranges': + return _lib_d3_d3__WEBPACK_IMPORTED_MODULE_0__.interpolateOranges(value); + case 'purples': + return _lib_d3_d3__WEBPACK_IMPORTED_MODULE_0__.interpolatePurples(value); + case 'reds': + return _lib_d3_d3__WEBPACK_IMPORTED_MODULE_0__.interpolateReds(value); + case 'bugn': + return _lib_d3_d3__WEBPACK_IMPORTED_MODULE_0__.interpolateBuGn(value); + case 'bupu': + return _lib_d3_d3__WEBPACK_IMPORTED_MODULE_0__.interpolateBuPu(value); + case 'gnbu': + return _lib_d3_d3__WEBPACK_IMPORTED_MODULE_0__.interpolateGnBu(value); + case 'orrd': + return _lib_d3_d3__WEBPACK_IMPORTED_MODULE_0__.interpolateOrRd(value); + case 'pubugn': + return _lib_d3_d3__WEBPACK_IMPORTED_MODULE_0__.interpolatePuBuGn(value); + case 'pubu': + return _lib_d3_d3__WEBPACK_IMPORTED_MODULE_0__.interpolatePuBu(value); + case 'purd': + return _lib_d3_d3__WEBPACK_IMPORTED_MODULE_0__.interpolatePuRd(value); + case 'rdpu': + return _lib_d3_d3__WEBPACK_IMPORTED_MODULE_0__.interpolateRdPu(value); + case 'ylgnbu': + return _lib_d3_d3__WEBPACK_IMPORTED_MODULE_0__.interpolateYlGnBu(value); + case 'ylgn': + return _lib_d3_d3__WEBPACK_IMPORTED_MODULE_0__.interpolateYlGn(value); + case 'ylorbr': + return _lib_d3_d3__WEBPACK_IMPORTED_MODULE_0__.interpolateYlOrBr(value); + case 'ylorrd': + return _lib_d3_d3__WEBPACK_IMPORTED_MODULE_0__.interpolateYlOrRd(value); + case 'cividis': + return _lib_d3_d3__WEBPACK_IMPORTED_MODULE_0__.interpolateCividis(value); + case 'viridis': + return _lib_d3_d3__WEBPACK_IMPORTED_MODULE_0__.interpolateViridis(value); + case 'inferno': + return _lib_d3_d3__WEBPACK_IMPORTED_MODULE_0__.interpolateInferno(value); + case 'magma': + return _lib_d3_d3__WEBPACK_IMPORTED_MODULE_0__.interpolateMagma(value); + case 'plasma': + return _lib_d3_d3__WEBPACK_IMPORTED_MODULE_0__.interpolatePlasma(value); + case 'warm': + return _lib_d3_d3__WEBPACK_IMPORTED_MODULE_0__.interpolateWarm(value); + case 'cool': + return _lib_d3_d3__WEBPACK_IMPORTED_MODULE_0__.interpolateCool(value); + case 'cubehelixdefault': + return _lib_d3_d3__WEBPACK_IMPORTED_MODULE_0__.interpolateCubehelixDefault(value); + case 'turbo': + return _lib_d3_d3__WEBPACK_IMPORTED_MODULE_0__.interpolateTurbo(value); + case 'brbg': + return _lib_d3_d3__WEBPACK_IMPORTED_MODULE_0__.interpolateBrBG(value); + case 'prgn': + return _lib_d3_d3__WEBPACK_IMPORTED_MODULE_0__.interpolatePRGn(value); + case 'piyg': + return _lib_d3_d3__WEBPACK_IMPORTED_MODULE_0__.interpolatePiYG(value); + case 'puor': + return _lib_d3_d3__WEBPACK_IMPORTED_MODULE_0__.interpolatePuOr(value); + case 'rdbu': + return _lib_d3_d3__WEBPACK_IMPORTED_MODULE_0__.interpolateRdBu(value); + case 'rdgy': + return _lib_d3_d3__WEBPACK_IMPORTED_MODULE_0__.interpolateRdGy(value); + case 'rdylbu': + return _lib_d3_d3__WEBPACK_IMPORTED_MODULE_0__.interpolateRdYlBu(value); + case 'rdylgn': + return _lib_d3_d3__WEBPACK_IMPORTED_MODULE_0__.interpolateRdYlGn(value); + case 'spectral': + return _lib_d3_d3__WEBPACK_IMPORTED_MODULE_0__.interpolateSpectral(value); + default: + return _lib_d3_d3__WEBPACK_IMPORTED_MODULE_0__.interpolateBlues(value); + } + } +} + + +/***/ }), + +/***/ "./src/controller.ts": +/*!***************************!*\ + !*** ./src/controller.ts ***! + \***************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ Controller: () => (/* binding */ Controller), +/* harmony export */ StringTokens: () => (/* binding */ StringTokens), +/* harmony export */ Tokens: () => (/* binding */ Tokens) +/* harmony export */ }); +/* harmony import */ var _token_label_view__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./token_label_view */ "./src/token_label_view.ts"); +/* harmony import */ var _lib_weya_weya__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../lib/weya/weya */ "../../weya/weya.ts"); +/* harmony import */ var _attention_matrix_view__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./attention_matrix_view */ "./src/attention_matrix_view.ts"); +/* harmony import */ var _token_heatmap__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./token_heatmap */ "./src/token_heatmap.ts"); +/* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./utils */ "./src/utils.ts"); +/* harmony import */ var _types__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./types */ "./src/types.ts"); +/* harmony import */ var _dimensions__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./dimensions */ "./src/dimensions.ts"); +/* harmony import */ var _token_dim_heatmap__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./token_dim_heatmap */ "./src/token_dim_heatmap.ts"); +/* harmony import */ var _line_grid__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./line_grid */ "./src/line_grid.ts"); + + + + + + + + + +class Tokens { +} +class StringTokens extends Tokens { + constructor(tokens) { + super(); + this.tokens = tokens.tokens; + } + getTokenLabelView(idx) { + return new _token_label_view__WEBPACK_IMPORTED_MODULE_0__.StringTokenLabelView(this.tokens[idx]); + } + get length() { + return this.tokens.length; + } +} +class Controller { + constructor(dimensions, attentions, srcTokens, dstTokens, chartTypes = [_types__WEBPACK_IMPORTED_MODULE_5__.ChartType.AttentionMatrix], plotColors) { + this.onSelected = (type, idx, isMulti) => { + if (isMulti) { + this.selected[type][idx] = this.selected[type][idx] !== true; + } + else { + if (this.selected[type][idx] === true) { + if (this.getSelectedCount(type) > 1) { + for (let i in this.selected[type]) { + this.selected[type][i] = false; + } + this.selected[type][idx] = true; + } + else { + for (let i in this.selected[type]) { + this.selected[type][i] = true; + } + } + } + else { + for (let i in this.selected[type]) { + this.selected[type][i] = false; + } + this.selected[type][idx] = true; + } + } + this.renderAttention(); + }; + this.onLineGridDimChange = (dim1, dim2) => { + return this.calcGridAttentionAttention(dim1, dim2); + }; + this.onTokenHeatmapDimChange = (selDim) => { + return this.calcTokenDimsAttention(selDim); + }; + this.attentions = attentions; + this.srcTokens = new StringTokens(srcTokens); + this.dstTokens = new StringTokens(dstTokens); + this.chartTypes = chartTypes; + this.dimensions = dimensions; + this.dimensionsMap = {}; + for (let d of this.dimensions) { + this.dimensionsMap[d.name] = d; + } + this.attentionMatrixView = new _attention_matrix_view__WEBPACK_IMPORTED_MODULE_2__.AttentionMatrixView(this.srcTokens, this.dstTokens, plotColors); + this.srcTokenHeatmap = new _token_heatmap__WEBPACK_IMPORTED_MODULE_3__.StringTokenHeatmap(this.srcTokens, "Query Tokens", plotColors); + this.dstTokenHeatmap = new _token_heatmap__WEBPACK_IMPORTED_MODULE_3__.StringTokenHeatmap(this.dstTokens, "Key Tokens", plotColors); + this.srcTokenHeatmap.addClickHandler('src', this.onSelected); + this.dstTokenHeatmap.addClickHandler('dst', this.onSelected); + this.selected = {}; + for (let dim of dimensions) { + let dimValues = {}; + for (let attn of attentions) { + if (dimValues[attn.info[dim.name]] !== true) { + dimValues[attn.info[dim.name]] = true; + } + } + this.selected[dim.name] = {}; + dim.values = []; + for (let dv in dimValues) { + this.selected[dim.name][dv] = true; + dim.values.push(dv); + } + } + this.selected['src'] = {}; + for (let i = 0; i < this.srcTokens.length; ++i) { + this.selected['src'][i] = true; + } + this.selected['dst'] = {}; + for (let i = 0; i < this.dstTokens.length; ++i) { + this.selected['dst'][i] = true; + } + this.dimensionHeatmaps = []; + for (let dim of dimensions) { + let values = []; + for (let v in this.selected[dim.name]) { + values.push(v); + } + let heatmap = new _dimensions__WEBPACK_IMPORTED_MODULE_6__.DimensionHeatmap(values, dim.name, plotColors); + heatmap.addClickHandler(dim.name, this.onSelected); + this.dimensionHeatmaps.push(heatmap); + } + this.tokenDimHeatmap = new _token_dim_heatmap__WEBPACK_IMPORTED_MODULE_7__.TokenDimHeatmapView(this.dstTokens, this.dimensionsMap, this.onTokenHeatmapDimChange, plotColors); + this.lineGridView = new _line_grid__WEBPACK_IMPORTED_MODULE_8__.LineGridView(this.srcTokens, this.dstTokens, this.dimensionsMap, this.onLineGridDimChange); + this.lineGridView.addClickHandler(this.onSelected); + } + calcAttnMatrix(filterTokens = false) { + let matrix = (0,_utils__WEBPACK_IMPORTED_MODULE_4__.createMatrix)(this.srcTokens.length, this.dstTokens.length); + for (let attn of this.attentions) { + let isSelected = true; + for (let dim in attn.info) { + if (this.selected[dim][attn.info[dim]] !== true) { + isSelected = false; + break; + } + } + if (!isSelected) { + continue; + } + for (let i = 0; i < this.srcTokens.length; ++i) { + for (let j = 0; j < this.dstTokens.length; ++j) { + matrix[i][j] += attn.values[i][j]; + } + } + } + if (filterTokens) { + for (let i = 0; i < this.srcTokens.length; ++i) { + for (let j = 0; j < this.dstTokens.length; ++j) { + if (!this.selected['src'][i] || !this.selected['dst'][j]) { + matrix[i][j] = 0.; + } + } + } + } + (0,_utils__WEBPACK_IMPORTED_MODULE_4__.maxNormalize2DArray)(matrix); + return matrix; + } + calcDstAttn(matrix) { + let dstAttn = []; + for (let j = 0; j < this.dstTokens.length; ++j) { + let val = 0.; + for (let i = 0; i < this.srcTokens.length; ++i) { + if (this.selected['src'][i] === true) { + val += matrix[i][j]; + } + } + dstAttn.push(val); + } + (0,_utils__WEBPACK_IMPORTED_MODULE_4__.maxNormalizeArray)(dstAttn); + return dstAttn; + } + calcSrcAttn(matrix) { + let srcAttn = []; + for (let i = 0; i < this.srcTokens.length; ++i) { + let val = 0.; + for (let j = 0; j < this.dstTokens.length; ++j) { + if (this.selected['dst'][j] === true) { + val += matrix[i][j]; + } + } + srcAttn.push(val); + } + (0,_utils__WEBPACK_IMPORTED_MODULE_4__.maxNormalizeArray)(srcAttn); + return srcAttn; + } + calcDimsAttention() { + let dims = {}; + for (let dim of this.dimensions) { + dims[dim.name] = {}; + } + for (let attn of this.attentions) { + let total = 0; + for (let i = 0; i < this.srcTokens.length; ++i) { + for (let j = 0; j < this.dstTokens.length; ++j) { + if (this.selected['src'][i] === true && this.selected['dst'][j] === true) { + total += attn.values[i][j]; + } + } + } + let notSelected = 0; + for (let dim in attn.info) { + if (this.selected[dim][attn.info[dim]] !== true) { + notSelected++; + } + } + for (let dim of this.dimensions) { + if (dims[dim.name][attn.info[dim.name]] == null) { + dims[dim.name][attn.info[dim.name]] = 0; + } + if (notSelected === 0) { + dims[dim.name][attn.info[dim.name]] += total; + } + else if (notSelected === 1 && this.selected[dim.name][attn.info[dim.name]] !== true) { + dims[dim.name][attn.info[dim.name]] += total; + } + } + } + for (let dim of this.dimensions) { + (0,_utils__WEBPACK_IMPORTED_MODULE_4__.maxNormalizeMap)(dims[dim.name]); + } + return dims; + } + calcTokenDimsAttention(selDim) { + let res = []; + let dv = (0,_utils__WEBPACK_IMPORTED_MODULE_4__.getDimValues)(selDim, this.dimensionsMap); + for (let j = 0; j < this.dstTokens.length; ++j) { + res.push({}); + for (let d of dv) { + res[j][d] = 0; + } + } + for (let attn of this.attentions) { + let notSelected = 0; + for (let dim in attn.info) { + if (this.selected[dim][attn.info[dim]] !== true) { + if (dim !== selDim) { + notSelected++; + } + } + } + if (notSelected !== 0) { + continue; + } + let dvSel = attn.info[selDim]; + if (dvSel == null) { + dvSel = 'null'; + } + for (let i = 0; i < this.srcTokens.length; ++i) { + for (let j = 0; j < this.dstTokens.length; ++j) { + if (this.selected['src'][i] === true) { + res[j][dvSel] += attn.values[i][j]; + } + } + } + } + (0,_utils__WEBPACK_IMPORTED_MODULE_4__.maxNormalizeArrayMap)(res); + return res; + } + calcGridAttentionAttention(dim1, dim2) { + let res = {}; + for (let dv1 of (0,_utils__WEBPACK_IMPORTED_MODULE_4__.getDimValues)(dim1, this.dimensionsMap)) { + res[dv1] = {}; + for (let dv2 of (0,_utils__WEBPACK_IMPORTED_MODULE_4__.getDimValues)(dim2, this.dimensionsMap)) { + res[dv1][dv2] = (0,_utils__WEBPACK_IMPORTED_MODULE_4__.createMatrix)(this.srcTokens.length, this.dstTokens.length); + } + } + for (let attn of this.attentions) { + let notSelected = 0; + for (let dim in attn.info) { + if (this.selected[dim][attn.info[dim]] !== true) { + if (dim !== dim1 && dim !== dim2) { + notSelected++; + } + } + } + if (notSelected !== 0) { + continue; + } + let dv1 = attn.info[dim1]; + let dv2 = attn.info[dim2]; + if (dv1 == null) { + dv1 = 'null'; + } + if (dv2 == null) { + dv2 = 'null'; + } + let arr = res[dv1][dv2]; + for (let i = 0; i < this.srcTokens.length; ++i) { + for (let j = 0; j < this.dstTokens.length; ++j) { + arr[i][j] += attn.values[i][j]; + } + } + } + for (let dv1 in res) { + for (let dv2 in res[dv1]) { + for (let i = 0; i < this.srcTokens.length; ++i) { + (0,_utils__WEBPACK_IMPORTED_MODULE_4__.normalizeArray)(res[dv1][dv2][i]); + } + } + } + return res; + } + getSelectedCount(type) { + let count = 0; + for (let i in this.selected[type]) { + if (this.selected[type][i] === true) { + count++; + } + } + return count; + } + renderAttention() { + let matrix = this.calcAttnMatrix(); + if (this.chartTypes.includes(_types__WEBPACK_IMPORTED_MODULE_5__.ChartType.AttentionMatrix)) { + this.attentionMatrixView.setSelection(this.selected['src'], this.selected['dst']); + this.attentionMatrixView.setAttention(this.calcAttnMatrix(true)); + } + if (this.chartTypes.includes(_types__WEBPACK_IMPORTED_MODULE_5__.ChartType.SrcTokenHeatmap)) { + this.srcTokenHeatmap.setSelection(this.selected['src']); + this.srcTokenHeatmap.setAttention(this.calcSrcAttn(matrix)); + } + if (this.chartTypes.includes(_types__WEBPACK_IMPORTED_MODULE_5__.ChartType.DestTokenHeatmap)) { + this.dstTokenHeatmap.setSelection(this.selected['dst']); + this.dstTokenHeatmap.setAttention(this.calcDstAttn(matrix)); + } + if (this.chartTypes.includes(_types__WEBPACK_IMPORTED_MODULE_5__.ChartType.DimensionHeatmap) && this.dimensions.length != 0) { + let dimsAttn = this.calcDimsAttention(); + for (let i = 0; i < this.dimensions.length; ++i) { + let name = this.dimensions[i].name; + this.dimensionHeatmaps[i].setSelection(this.selected[name]); + this.dimensionHeatmaps[i].setAttention(dimsAttn[name]); + } + } + if (this.chartTypes.includes(_types__WEBPACK_IMPORTED_MODULE_5__.ChartType.TokenDimHeatmap) && this.dimensions.length != 0) { + this.tokenDimHeatmap.setSelection(this.selected['dst']); + this.tokenDimHeatmap.setAttention(this.calcTokenDimsAttention(this.tokenDimHeatmap.selectedDimension)); + } + if (this.chartTypes.includes(_types__WEBPACK_IMPORTED_MODULE_5__.ChartType.LineGrid)) { + this.lineGridView.setSelection(this.selected); + this.lineGridView.setAttention(this.calcGridAttentionAttention(this.lineGridView.dim1, this.lineGridView.dim2)); + } + } + render(theme) { + let elem = (0,_lib_weya_weya__WEBPACK_IMPORTED_MODULE_1__.Weya)('div', '.attention-visualization'); + if (theme === 'auto') { + theme = window.matchMedia('(prefers-color-scheme: light)').matches ? 'light' : 'dark'; + } + if (theme === 'dark') { + elem.classList.add('dark-theme'); + } + if (this.chartTypes.includes(_types__WEBPACK_IMPORTED_MODULE_5__.ChartType.AttentionMatrix)) { + elem.appendChild(this.attentionMatrixView.render()); + } + if (this.chartTypes.includes(_types__WEBPACK_IMPORTED_MODULE_5__.ChartType.SrcTokenHeatmap)) { + elem.appendChild(this.srcTokenHeatmap.render()); + } + if (this.chartTypes.includes(_types__WEBPACK_IMPORTED_MODULE_5__.ChartType.DestTokenHeatmap)) { + elem.appendChild(this.dstTokenHeatmap.render()); + } + if (this.chartTypes.includes(_types__WEBPACK_IMPORTED_MODULE_5__.ChartType.DimensionHeatmap) && this.dimensions.length != 0) { + for (let i = 0; i < this.dimensions.length; ++i) { + elem.appendChild(this.dimensionHeatmaps[i].render()); + } + } + if (this.chartTypes.includes(_types__WEBPACK_IMPORTED_MODULE_5__.ChartType.TokenDimHeatmap) && this.dimensions.length != 0) { + elem.appendChild(this.tokenDimHeatmap.render()); + } + if (this.chartTypes.includes(_types__WEBPACK_IMPORTED_MODULE_5__.ChartType.LineGrid)) { + elem.appendChild(this.lineGridView.render()); + } + this.renderAttention(); + return elem; + } +} + + +/***/ }), + +/***/ "./src/data.ts": +/*!*********************!*\ + !*** ./src/data.ts ***! + \*********************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ ChartData: () => (/* binding */ ChartData) +/* harmony export */ }); +class ChartData { + constructor(data) { + this.chart_types = data.chart_types; + this.src_tokens = data.src_tokens; + this.tgt_tokens = data.tgt_tokens; + this.dimensions = []; + for (let index in data.dimensions) { + this.dimensions.push({ name: data.dimensions[index].name }); + } + this.attention = []; + for (let index in data.attention) { + let values = decodeB64(data.attention[index].values, data.attention[index].shape); + this.attention.push({ values: values, info: data.attention[index].info }); + } + } +} +function getListFromBinary(binaryString) { + let b64 = atob(binaryString); + const uint8Array = new Uint8Array(b64.length); + for (let i = 0; i < b64.length; i++) { + uint8Array[i] = b64.charCodeAt(i); + } + try { + let dataView = new DataView(uint8Array.buffer); + let floatArray = new Float32Array(dataView.byteLength / 4); + for (let i = 0; i < floatArray.length; i++) { + floatArray[i] = dataView.getFloat32(i * 4, true); + } + return floatArray; + } + catch (e) { + console.error("Error parsing binary data", e); + return new Float32Array(0); + } +} +function reshapeArray(data, shape) { + if (shape.length === 1) { + return data; + } + let result = []; + let size = shape[0]; + shape = shape.slice(1); + let length = data.length / size; + for (let i = 0; i < size; i++) { + result.push(reshapeArray(data.splice(0, length), shape)); + } + return result; +} +function decodeB64(input, shape) { + let array = getListFromBinary(input); + return reshapeArray(Array.from(array), shape); +} + + +/***/ }), + +/***/ "./src/dimensions.ts": +/*!***************************!*\ + !*** ./src/dimensions.ts ***! + \***************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ DimensionHeatmap: () => (/* binding */ DimensionHeatmap) +/* harmony export */ }); +/* harmony import */ var _lib_weya_weya__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../lib/weya/weya */ "../../weya/weya.ts"); +/* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./utils */ "./src/utils.ts"); +/* harmony import */ var _types__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./types */ "./src/types.ts"); + + + +class ValueView { + constructor(value, plotColors) { + this.onClick = (e) => { + e.preventDefault(); + e.stopPropagation(); + this.handler(this.type, this.idx, e.shiftKey); + }; + this.value = value; + this.selected = true; + this.plotColors = plotColors; + } + render() { + this.elem = (0,_lib_weya_weya__WEBPACK_IMPORTED_MODULE_0__.Weya)('div', '.value', this.value); + this.elem.addEventListener('click', this.onClick); + return this.elem; + } + addClickHandler(type, idx, handler) { + this.handler = handler; + this.type = type; + this.idx = idx; + } + set background(color) { + this.elem.style.background = color; + } + setAttn(value) { + if (this.selected) { + this.elem.style.setProperty('background', this.plotColors.getInterpolatedColor(value * 0.8, _types__WEBPACK_IMPORTED_MODULE_2__.ChartType.DimensionHeatmap)); + } + else { + this.elem.style.setProperty('background', this.plotColors.getInterpolatedSecondaryColor(value * 0.8)); + } + this.elem.style.setProperty('color', this.plotColors.getFilledTextColor()); + this.elem.title = value.toExponential(); + } + setSelection(selected) { + this.selected = selected; + } +} +class DimensionHeatmap { + constructor(values, name, plotColors) { + this.values = values; + this.name = name; + this.plotColors = plotColors; + this.valueViews = {}; + for (let v of this.values) { + let view = new ValueView(v, this.plotColors); + this.valueViews[v] = view; + } + } + addClickHandler(type, handler) { + for (let i = 0; i < this.values.length; ++i) { + this.valueViews[this.values[i]].addClickHandler(type, i, handler); + } + } + render() { + let elem = (0,_lib_weya_weya__WEBPACK_IMPORTED_MODULE_0__.Weya)('div', '.dimension-values', $ => { + $('div', '.dimension-name.title', `${(0,_utils__WEBPACK_IMPORTED_MODULE_1__.capitalizeFirstLetter)(this.name)}`); + }); + for (let i = 0; i < this.values.length; ++i) { + elem.appendChild(this.valueViews[this.values[i]].render()); + } + return elem; + } + setAttention(attn) { + for (let i = 0; i < this.values.length; ++i) { + this.valueViews[this.values[i]].setAttn(attn[this.values[i]]); + } + } + setSelection(selected) { + for (let i = 0; i < this.values.length; ++i) { + this.valueViews[this.values[i]].setSelection(selected[this.values[i]]); + } + } +} + + +/***/ }), + +/***/ "./src/line_grid.ts": +/*!**************************!*\ + !*** ./src/line_grid.ts ***! + \**************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ LineGridView: () => (/* binding */ LineGridView) +/* harmony export */ }); +/* harmony import */ var _lib_weya_weya__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../lib/weya/weya */ "../../weya/weya.ts"); +/* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./utils */ "./src/utils.ts"); + + +class LineView { + constructor() { + this.selected = true; + this.selectedCell = true; + } + render(r1, r2, width) { + this.elem = (0,_lib_weya_weya__WEBPACK_IMPORTED_MODULE_0__.Weya)('line', '.line', { + x1: 0, + y1: r1, + x2: width, + y2: r2 + }); + return this.elem; + } + setAttn(value) { + if (this.selected && this.selectedCell) { + this.elem.style.setProperty('stroke', `rgba(8, 50, 128, ${value})`); + } + else { + this.elem.style.setProperty('stroke', `rgba(128, 128, 128, ${value})`); + } + } + setSelectedCell(selected) { + this.selectedCell = selected; + } + setSelected(selected) { + this.selected = selected; + } +} +class LineCellView { + constructor(nSrc, nDst, height, width) { + this.onClick = (e) => { + e.preventDefault(); + e.stopPropagation(); + console.log('click', this.dims); + for (let d of this.dims) { + this.handler(d.d, d.v, false); + } + }; + this.height = height; + this.width = width; + this.nSrc = nSrc; + this.nDst = nDst; + } + render() { + this.elem = (0,_lib_weya_weya__WEBPACK_IMPORTED_MODULE_0__.Weya)('g', '.lines', { on: { 'click': this.onClick } }, $ => { + this.bgLines = $('g'); + this.fgLines = $('g'); + }); + this.lines = []; + for (let i = 0; i < this.nSrc; ++i) { + this.lines.push([]); + for (let j = 0; j < this.nDst; ++j) { + this.lines[i].push(new LineView()); + this.fgLines.appendChild(this.lines[i][j].render(i / this.nSrc * this.height, j / this.nDst * this.height, this.width)); + } + } + return this.elem; + } + addClickHandler(dim1, dv1, dim2, dv2, handler) { + this.handler = handler; + this.dims = []; + if (dim1 !== 'null') { + this.dims.push({ d: dim1, v: dv1 }); + } + if (dim2 !== 'null') { + this.dims.push({ d: dim2, v: dv2 }); + } + } + setAttn(attn) { + for (let i = 0; i < this.nSrc; ++i) { + for (let j = 0; j < this.nDst; ++j) { + this.lines[i][j].setAttn(attn[i][j]); + } + } + } + setSelection(selected) { + for (let i = 0; i < this.nSrc; ++i) { + for (let j = 0; j < this.nDst; ++j) { + this.lines[i][j].setSelectedCell(selected); + } + } + } + setSrcDstSelections(src, dst) { + for (let i = 0; i < this.nSrc; ++i) { + for (let j = 0; j < this.nDst; ++j) { + let selected = src[i] === true && dst[j] === true; + if (this.lines[i][j].selected === selected) { + continue; + } + this.lines[i][j].elem.remove(); + if (selected) { + this.fgLines.appendChild(this.lines[i][j].elem); + } + else { + this.bgLines.appendChild(this.lines[i][j].elem); + } + this.lines[i][j].setSelected(selected); + } + } + } +} +class LineGridView { + constructor(srcTokens, dstTokens, dimensions, handler) { + this.onDim1Select = (e) => { + e.preventDefault(); + e.stopPropagation(); + this.dim1 = this.dimSelectElem1.value; + this.renderChart(); + this.attentions = this.dimChangeHandler(this.dim1, this.dim2); + this.renderSelection(); + this.renderAttention(); + }; + this.onDim2Select = (e) => { + e.preventDefault(); + e.stopPropagation(); + this.dim2 = this.dimSelectElem2.value; + this.renderChart(); + this.attentions = this.dimChangeHandler(this.dim1, this.dim2); + this.renderSelection(); + this.renderAttention(); + }; + this.srcTokens = srcTokens; + this.dstTokens = dstTokens; + this.dimChangeHandler = handler; + this.dimensions = dimensions; + this.dim1 = 'null'; + this.dim2 = 'null'; + this.cellWidth = 80; + this.cellHeight = 100; + this.cellMargin = 10; + } + addClickHandler(handler) { + this.selectHanlder = handler; + } + render() { + this.elem = (0,_lib_weya_weya__WEBPACK_IMPORTED_MODULE_0__.Weya)('div', '.line-grid', $ => { + $('div.double-select', $ => { + $('div', '.select-container', $ => { + $('label.title.inline', 'Y Dimension', { for: 'line-grid-dim2-select' }); + this.dimSelectElem1 = $('select', '#line-grid-dim2-select', { on: { change: this.onDim1Select } }, $ => { + for (let d in this.dimensions) { + $('option', d, { value: d }); + } + $('option', 'None', { value: 'null' }); + }); + }); + $('div', '.select-container', $ => { + $('label.title.inline', 'X Dimension', { for: 'line-grid-dim1-select' }); + this.dimSelectElem2 = $('select', '#line-grid-dim1-select', { on: { change: this.onDim2Select } }, $ => { + for (let d in this.dimensions) { + $('option', d, { value: d }); + } + $('option', 'None', { value: 'null' }); + }); + }); + }); + }); + this.dimSelectElem1.value = this.dim1; + this.dimSelectElem2.value = this.dim2; + this.renderChart(); + return this.elem; + } + renderChart() { + if (this.chartElem != null) { + this.chartElem.remove(); + this.chartElem = null; + } + let dv1 = (0,_utils__WEBPACK_IMPORTED_MODULE_1__.getDimValues)(this.dim1, this.dimensions); + let dv2 = (0,_utils__WEBPACK_IMPORTED_MODULE_1__.getDimValues)(this.dim2, this.dimensions); + let svgAttrs = { + width: this.cellWidth * dv2.length + this.cellMargin * (dv2.length - 1), + height: this.cellHeight * dv1.length + this.cellMargin * (dv1.length - 1), + viewBox: `0 0 ${this.cellWidth * dv2.length + this.cellMargin * (dv2.length - 1)} ${this.cellHeight * dv1.length + this.cellMargin * (dv1.length - 1)}` + }; + this.cellLayers = []; + this.chartElem = (0,_lib_weya_weya__WEBPACK_IMPORTED_MODULE_0__.Weya)('svg', '.matrix', svgAttrs, $ => { + for (let i = 0; i < dv1.length; ++i) { + this.cellLayers.push([]); + $('g', { transform: `translate(0, ${i * (this.cellHeight + this.cellMargin)})` }, $ => { + for (let j = 0; j < dv2.length; ++j) { + this.cellLayers[i].push($('g', { transform: `translate(${j * (this.cellWidth + this.cellMargin)}, 0)` })); + } + }); + } + }); + this.elem.appendChild(this.chartElem); + this.cells = []; + for (let i = 0; i < dv1.length; ++i) { + this.cells.push([]); + for (let j = 0; j < dv2.length; ++j) { + this.cells[i].push(new LineCellView(this.srcTokens.length, this.dstTokens.length, this.cellHeight, this.cellWidth)); + this.cellLayers[i][j].appendChild(this.cells[i][j].render()); + this.cells[i][j].addClickHandler(this.dim1, dv1[i], this.dim2, dv2[j], this.selectHanlder); + } + } + } + renderAttention() { + let dv1 = (0,_utils__WEBPACK_IMPORTED_MODULE_1__.getDimValues)(this.dim1, this.dimensions); + let dv2 = (0,_utils__WEBPACK_IMPORTED_MODULE_1__.getDimValues)(this.dim2, this.dimensions); + for (let i = 0; i < dv1.length; ++i) { + for (let j = 0; j < dv2.length; ++j) { + this.cells[i][j].setAttn(this.attentions[dv1[i]][dv2[j]]); + } + } + } + setAttention(attn) { + this.attentions = attn; + this.renderAttention(); + } + setSelection(selected) { + this.selected = selected; + this.renderSelection(); + } + renderSelection() { + let selected = this.selected; + let dv1 = (0,_utils__WEBPACK_IMPORTED_MODULE_1__.getDimValues)(this.dim1, this.dimensions); + let dv2 = (0,_utils__WEBPACK_IMPORTED_MODULE_1__.getDimValues)(this.dim2, this.dimensions); + for (let i = 0; i < dv1.length; ++i) { + for (let j = 0; j < dv2.length; ++j) { + let s = true; + if (selected[this.dim1] != null) { + if (selected[this.dim1][dv1[i]] !== true) { + s = false; + } + } + if (selected[this.dim2] != null) { + if (selected[this.dim2][dv2[j]] !== true) { + s = false; + } + } + this.cells[i][j].setSelection(s); + this.cells[i][j].setSrcDstSelections(selected['src'], selected['dst']); + } + } + } +} + + +/***/ }), + +/***/ "./src/token_dim_heatmap.ts": +/*!**********************************!*\ + !*** ./src/token_dim_heatmap.ts ***! + \**********************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ TokenDimHeatmapView: () => (/* binding */ TokenDimHeatmapView) +/* harmony export */ }); +/* harmony import */ var _lib_weya_weya__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../lib/weya/weya */ "../../weya/weya.ts"); +/* harmony import */ var _types__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./types */ "./src/types.ts"); + + +class CellView { + constructor(plotColors) { + this.plotColors = plotColors; + } + render(row, col, cellSize) { + this.elem = (0,_lib_weya_weya__WEBPACK_IMPORTED_MODULE_0__.Weya)('rect', '.cell', { + x: col * cellSize, + y: row * cellSize, + width: cellSize, + height: cellSize + }); + this.titleElem = document.createElementNS("http://www.w3.org/2000/svg", "title"); + this.elem.appendChild(this.titleElem); + return this.elem; + } + setAttn(value) { + if (this.selected) { + this.elem.style.setProperty('fill', this.plotColors.getInterpolatedColor(value * 0.8, _types__WEBPACK_IMPORTED_MODULE_1__.ChartType.TokenDimHeatmap)); + } + else { + this.elem.style.setProperty('fill', this.plotColors.getInterpolatedSecondaryColor(value * 0.8)); + } + this.titleElem.textContent = value.toExponential(); + } + setSelection(selected) { + this.selected = selected; + } +} +class TokenDimHeatmapView { + constructor(tokens, dimensions, handler, plotColors) { + this.onItemSelect = (type, idx, isMulti) => { + this.handler(type, idx, isMulti); + }; + this.onDimSelect = (e) => { + e.preventDefault(); + e.stopPropagation(); + this.selectedDimension = this.dimSelectElem.value; + this.renderChart(); + this.tokenDim = this.handler(this.selectedDimension); + this.renderAttention(); + }; + this.tokens = tokens; + this.dimensions = dimensions; + this.handler = handler; + this.plotColors = plotColors; + this.tokenElems = []; + for (let i = 0; i < tokens.length; ++i) { + let v = this.tokens.getTokenLabelView(i); + v.addClickHandler('src', i, this.onItemSelect); + this.tokenElems.push(v); + } + this.cells = []; + for (let i = 0; i < tokens.length; ++i) { + this.cells.push([]); + } + this.cellSize = 20; + this.leftLabelsMargin = 50; + this.labelCellGap = 5; + for (let d in dimensions) { + this.selectedDimension = d; + } + } + render() { + this.elem = (0,_lib_weya_weya__WEBPACK_IMPORTED_MODULE_0__.Weya)('div', '.token-dim-heatmap', $ => { + $('div', '.select-container', $ => { + $('div.title.inline', 'Dimension', { for: 'token-dim-heatmap-select' }); + this.dimSelectElem = $('select', '#token-dim-heatmap-select', { on: { change: this.onDimSelect } }, $ => { + for (let d in this.dimensions) { + $('option', d, { value: d }); + } + }); + }); + }); + this.dimSelectElem.value = this.selectedDimension; + this.renderChart(); + return this.elem; + } + renderChart() { + if (this.chartElem != null) { + this.chartElem.remove(); + this.chartElem = null; + } + let grid; + let dim = this.dimensions[this.selectedDimension]; + let svgAttrs = { + width: this.cellSize * dim.values.length + this.leftLabelsMargin, + height: this.cellSize * this.tokens.length, + viewBox: `0 0 ${this.cellSize * dim.values.length + this.leftLabelsMargin} ${this.cellSize * this.tokens.length} ` + }; + this.chartElem = (0,_lib_weya_weya__WEBPACK_IMPORTED_MODULE_0__.Weya)('svg', '.matrix', svgAttrs, $ => { + grid = $('g', '.grid', { transform: `translate(${this.leftLabelsMargin}, 0)` }); + let labels = []; + $('g', '.token_labels', { transform: `translate(${this.leftLabelsMargin - this.labelCellGap}, ${this.cellSize / 2})` }, $ => { + for (let i = 0; i < this.tokens.length; ++i) { + labels.push($('g', '.label', { transform: `translate(0, ${this.cellSize * i})` })); + } + }); + for (let i = 0; i < this.tokens.length; ++i) { + labels[i].appendChild(this.tokenElems[i].render(this.cellSize, false)); + } + }); + this.cells = []; + for (let i = 0; i < this.tokens.length; ++i) { + this.cells.push([]); + for (let j = 0; j < dim.values.length; ++j) { + this.cells[i].push(new CellView(this.plotColors)); + grid.appendChild(this.cells[i][j].render(i, j, this.cellSize)); + } + } + this.elem.appendChild(this.chartElem); + } + setAttention(tokenDim) { + this.tokenDim = tokenDim; + this.renderAttention(); + } + setSelection(tokenSelect) { + this.selected = tokenSelect; + for (let i = 0; i < this.tokens.length; ++i) { + for (let j = 0; j < this.cells[i].length; ++j) { + this.cells[i][j].setSelection(tokenSelect[i] === true); + } + } + } + renderAttention() { + if (this.tokenDim == null) { + return; + } + let dim = this.dimensions[this.selectedDimension]; + for (let i = 0; i < this.tokens.length; ++i) { + for (let j = 0; j < dim.values.length; ++j) { + this.cells[i][j].setAttn(this.tokenDim[i][dim.values[j]]); + } + } + } +} + + +/***/ }), + +/***/ "./src/token_heatmap.ts": +/*!******************************!*\ + !*** ./src/token_heatmap.ts ***! + \******************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ StringTokenHeatmap: () => (/* binding */ StringTokenHeatmap) +/* harmony export */ }); +/* harmony import */ var _lib_weya_weya__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../lib/weya/weya */ "../../weya/weya.ts"); +/* harmony import */ var _types__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./types */ "./src/types.ts"); +/* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./utils */ "./src/utils.ts"); + + + +class TokenView { + constructor(token, plotColors) { + this.onClick = (e) => { + e.preventDefault(); + e.stopPropagation(); + this.handler(this.type, this.idx, e.shiftKey); + }; + this.token = token; + this.selected = true; + this.plotColors = plotColors; + } + render() { + this.elem = (0,_lib_weya_weya__WEBPACK_IMPORTED_MODULE_0__.Weya)('div', '.token', this.token); + this.elem.addEventListener('click', this.onClick); + return this.elem; + } + addClickHandler(type, idx, handler) { + this.handler = handler; + this.type = type; + this.idx = idx; + } + setAttn(value) { + if (this.selected) { + this.elem.style.setProperty('background', this.plotColors.getInterpolatedColor(value * 0.8, this.type == 'src' ? _types__WEBPACK_IMPORTED_MODULE_1__.ChartType.SrcTokenHeatmap : _types__WEBPACK_IMPORTED_MODULE_1__.ChartType.DestTokenHeatmap)); + this.elem.style.setProperty('border-left', `3px solid ${(0,_utils__WEBPACK_IMPORTED_MODULE_2__.setAlpha)(this.plotColors.getInterpolatedColor(1 - value * 0.8, this.type == 'src' ? _types__WEBPACK_IMPORTED_MODULE_1__.ChartType.SrcTokenHeatmap : _types__WEBPACK_IMPORTED_MODULE_1__.ChartType.DestTokenHeatmap), 0.5)}`); + } + else { + this.elem.style.setProperty('background', this.plotColors.getInterpolatedSecondaryColor(value * 0.8)); + this.elem.style.setProperty('border-left', `3px solid ${(0,_utils__WEBPACK_IMPORTED_MODULE_2__.setAlpha)(this.plotColors.getInterpolatedSecondaryColor(1 - value * 0.8), 0.5)}`); + } + this.elem.style.setProperty('color', this.plotColors.getFilledTextColor()); + this.elem.title = value.toExponential(); + } + setSelection(selected) { + this.selected = selected; + } +} +class StringTokenHeatmap { + constructor(tokens, title, plotColors) { + this.tokens = tokens; + this.title = title; + this.plotColors = plotColors; + this.tokenViews = []; + for (let i = 0; i < this.tokens.length; ++i) { + let view = new TokenView(this.tokens.tokens[i], this.plotColors); + this.tokenViews.push(view); + } + } + addClickHandler(type, handler) { + for (let i = 0; i < this.tokens.length; ++i) { + this.tokenViews[i].addClickHandler(type, i, handler); + } + } + render() { + let elem = (0,_lib_weya_weya__WEBPACK_IMPORTED_MODULE_0__.Weya)('div', '.src-tokens.text-tokens', $ => { + $('div.title', this.title); + }); + for (let i = 0; i < this.tokens.length; ++i) { + elem.appendChild(this.tokenViews[i].render()); + } + return elem; + } + setAttention(attn) { + for (let i = 0; i < this.tokens.length; ++i) { + this.tokenViews[i].setAttn(attn[i]); + } + } + setSelection(selected) { + for (let i = 0; i < this.tokens.length; ++i) { + this.tokenViews[i].setSelection(selected[i] === true); + } + } +} + + +/***/ }), + +/***/ "./src/token_label_view.ts": +/*!*********************************!*\ + !*** ./src/token_label_view.ts ***! + \*********************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ StringTokenLabelView: () => (/* binding */ StringTokenLabelView), +/* harmony export */ TokenLabelView: () => (/* binding */ TokenLabelView) +/* harmony export */ }); +/* harmony import */ var _lib_weya_weya__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../lib/weya/weya */ "../../weya/weya.ts"); + +class TokenLabelView { +} +class StringTokenLabelView extends TokenLabelView { + constructor(token) { + super(); + this.token = token; + } + addClickHandler(type, idx, handler) { + this.handler = handler; + this.type = type; + this.idx = idx; + } + render(cellSize, isVertical) { + let style = { 'font-size': `${cellSize / 2}px` }; + if (isVertical) { + style['writing-mode'] = 'tb'; + } + return (0,_lib_weya_weya__WEBPACK_IMPORTED_MODULE_0__.Weya)('text', this.token, { style: style }); + } +} + + +/***/ }), + +/***/ "./src/token_loss.ts": +/*!***************************!*\ + !*** ./src/token_loss.ts ***! + \***************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ StringTokenLoss: () => (/* binding */ StringTokenLoss) +/* harmony export */ }); +/* harmony import */ var _lib_weya_weya__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../lib/weya/weya */ "../../weya/weya.ts"); +/* harmony import */ var _types__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./types */ "./src/types.ts"); + + +class TokenView { + constructor(token, tokenData, colors) { + this.isNewLine = /^[\n\r\v]+$/.test(token); + this.token = token; + this.values = tokenData.values; + this.colors = colors; + this.info = tokenData.info; + } + updateMenuPosition() { + const rect = this.elem.getBoundingClientRect(); + const midPoint = window.innerWidth / 2; + if (rect.left > midPoint) { + this.menu.classList.add('right-align'); + } + } + render() { + return (0,_lib_weya_weya__WEBPACK_IMPORTED_MODULE_0__.Weya)('div', '.hover-container', $ => { + this.elem = $('pre', '.token' + (this.isNewLine ? '.new-line' : ''), this.token.replace(/\n/g, '\\n').replace(/\r/g, '\\r').replace(/\v/g, '\\v')); + this.elem.style.setProperty('color', this.colors.getFilledTextColor()); + this.menu = $('div', '.menu', $ => { + for (let i = 0; i < this.values.length; ++i) { + $('div', $ => { + $('div', `${this.values[i].name}: ${this.values[i].value.toExponential()}`); + }); + } + $('hr'); + if (this.info != null) { + $('pre', this.info); + } + }); + }); + } + setValue(name) { + let value = this.values.find(v => v.name === name); + if (value == null) { + return; + } + let normalizedValue = value.normalizedValue; + this.elem.style.setProperty('background', this.colors.getInterpolatedColor(normalizedValue, _types__WEBPACK_IMPORTED_MODULE_1__.ChartType.TokenLoss)); + } +} +class StringTokenLoss { + constructor(tokens, tokenData, colors, paddingLess = true) { + this.onSelectChange = () => { + this.selectedMetric = this.selectElem.value; + for (let i = 0; i < this.tokens.length; ++i) { + this.tokenViews[i].setValue(this.selectedMetric); + } + }; + this.tokens = tokens; + this.selectedMetric = tokenData[0].values[0].name; + this.tokenData = tokenData; + this.paddingLess = paddingLess; + this.tokenViews = []; + for (let i = 0; i < this.tokens.length; ++i) { + let view = new TokenView(this.tokens[i], this.tokenData[i], colors); + this.tokenViews.push(view); + } + } + updateMenuPosition() { + for (let i = 0; i < this.tokens.length; ++i) { + this.tokenViews[i].updateMenuPosition(); + } + } + render() { + let elem = (0,_lib_weya_weya__WEBPACK_IMPORTED_MODULE_0__.Weya)('div', '.src-tokens.text-tokens.token-value-container' + (this.paddingLess ? '.padding-less' : ''), $ => { + $('div.title', 'Token Visualization'); + $('div.title', $ => { + this.selectElem = $('select', $ => { + }); + }); + }); + for (let i = 0; i < this.tokens.length; ++i) { + elem.appendChild(this.tokenViews[i].render()); + if (this.tokenViews[i].isNewLine) { + elem.appendChild((0,_lib_weya_weya__WEBPACK_IMPORTED_MODULE_0__.Weya)('br')); + } + } + for (let i = 0; i < this.tokenData[0].values.length; ++i) { + this.selectElem.appendChild((0,_lib_weya_weya__WEBPACK_IMPORTED_MODULE_0__.Weya)('option', this.tokenData[0].values[i].name)); + } + this.selectElem.value = this.selectedMetric; + this.onSelectChange(); + this.selectElem.addEventListener('change', this.onSelectChange); + return elem; + } +} + + +/***/ }), + +/***/ "./src/types.ts": +/*!**********************!*\ + !*** ./src/types.ts ***! + \**********************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ ChartType: () => (/* binding */ ChartType) +/* harmony export */ }); +var ChartType; +(function (ChartType) { + ChartType["AttentionMatrix"] = "attention_matrix"; + ChartType["SrcTokenHeatmap"] = "query_token_heatmap"; + ChartType["DestTokenHeatmap"] = "key_token_heatmap"; + ChartType["DimensionHeatmap"] = "dimension_heatmap"; + ChartType["TokenDimHeatmap"] = "token_dim_heatmap"; + ChartType["LineGrid"] = "line_grid"; + ChartType["TokenLoss"] = "token_loss"; +})(ChartType || (ChartType = {})); + + +/***/ }), + +/***/ "./src/utils.ts": +/*!**********************!*\ + !*** ./src/utils.ts ***! + \**********************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ capitalizeFirstLetter: () => (/* binding */ capitalizeFirstLetter), +/* harmony export */ createMatrix: () => (/* binding */ createMatrix), +/* harmony export */ getDimValues: () => (/* binding */ getDimValues), +/* harmony export */ maxNormalize2DArray: () => (/* binding */ maxNormalize2DArray), +/* harmony export */ maxNormalizeArray: () => (/* binding */ maxNormalizeArray), +/* harmony export */ maxNormalizeArrayMap: () => (/* binding */ maxNormalizeArrayMap), +/* harmony export */ maxNormalizeMap: () => (/* binding */ maxNormalizeMap), +/* harmony export */ normalizeArray: () => (/* binding */ normalizeArray), +/* harmony export */ setAlpha: () => (/* binding */ setAlpha) +/* harmony export */ }); +function createMatrix(rows, cols) { + let matrix = []; + for (let i = 0; i < rows; ++i) { + let row = []; + for (let j = 0; j < cols; ++j) { + row.push(0.); + } + matrix.push(row); + } + return matrix; +} +function maxNormalize2DArray(arr) { + let max = 0; + for (let i = 0; i < arr.length; ++i) { + for (let j = 0; j < arr[i].length; ++j) { + max = Math.max(max, arr[i][j]); + } + } + if (max <= 0) { + return; + } + for (let i = 0; i < arr.length; ++i) { + for (let j = 0; j < arr[i].length; ++j) { + arr[i][j] /= max; + } + } +} +function normalizeArray(arr) { + let sum = 0; + for (let j = 0; j < arr.length; ++j) { + sum += arr[j]; + } + if (sum <= 0) { + return; + } + for (let j = 0; j < arr.length; ++j) { + arr[j] /= sum; + } +} +function maxNormalizeArray(arr) { + let max = 0; + for (let j = 0; j < arr.length; ++j) { + max = Math.max(max, arr[j]); + } + if (max <= 0) { + return; + } + for (let j = 0; j < arr.length; ++j) { + arr[j] /= max; + } +} +function maxNormalizeMap(arr) { + let max = 0; + for (let i in arr) { + max = Math.max(max, arr[i]); + } + if (max <= 0) { + return; + } + for (let i in arr) { + arr[i] /= max; + } +} +function maxNormalizeArrayMap(arr) { + let max = 0; + for (let d of arr) { + for (let i in d) { + max = Math.max(max, d[i]); + } + } + if (max <= 0) { + return; + } + for (let d of arr) { + for (let i in d) { + d[i] /= max; + } + } +} +function getDimValues(dim, dimensions) { + let d = dimensions[dim]; + if (d == null) { + return ['null']; + } + else { + return d.values; + } +} +function capitalizeFirstLetter(str) { + return str.split(' ') + .map(word => word.charAt(0).toUpperCase() + word.slice(1)) + .join(' '); +} +function setAlpha(d3Color, alpha) { + return d3Color.replace(')', `, ${alpha})`); +} + + +/***/ }), + +/***/ "../../weya/weya.ts": +/*!**************************!*\ + !*** ../../weya/weya.ts ***! + \**************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ Weya: () => (/* binding */ Weya) +/* harmony export */ }); +const API = { + document: document +}; +const TAGS = { + svg: "a altGlyph altGlyphDef altGlyphItem animate animateColor animateMotion animateTransform circle clipPath color-profile cursor defs desc ellipse feBlend feColorMatrix feComponentTransfer feComposite feConvolveMatrix feDiffuseLighting feDisplacementMap feDistantLight feFlood feFuncA feFuncB feFuncG feFuncR feGaussianBlur feImage feMerge feMergeNode feMorphology feOffset fePointLight feSpecularLighting feSpotLight feTile feTurbulence filter font font-face font-face-format font-face-name font-face-src font-face-uri foreignObject g glyph glyphRef hkern image line linearGradient marker mask metadata missing-glyph mpath path pattern polygon polyline radialGradient rect script set stop style svg symbol text textPath title tref tspan use view vkern switch foreignObject", + html: "a abbr address article aside audio b bdi bdo blockquote body button canvas caption cite code colgroup datalist dd del details dfn div dl dt em fieldset figcaption figure footer form h1 h2 h3 h4 h5 h6 head header hgroup html i iframe ins kbd label legend li main map mark menu meter nav noscript object ol optgroup option output p pre progress q rp rt ruby s samp script section select small span strong style sub summary sup table tbody td textarea tfoot th thead time title tr u ul video", + htmlVoid: "area base br col command embed hr img input keygen link meta param source track wbr" +}; +let TAGS_DICT = {}; +for (let ns in TAGS) { + let tags = TAGS[ns].split(" "); + for (let tag of tags) { + TAGS_DICT[tag] = ns; + } +} +const NAMESPACES = { + svg: "http://www.w3.org/2000/svg", + html: "http://www.w3.org/1999/xhtml", + htmlVoid: null +}; +function parseDefinition(str) { + let res = { + tag: '', + id: null, + classes: [] + }; + let parts = str.split("."); + let first = parts[0]; + let firstParts = first.split('#'); + res.tag = firstParts[0]; + if (firstParts.length == 2) { + res.id = firstParts[1]; + } + else if (firstParts.length > 2) { + throw Error("Invalid Definition: " + str); + } + if (parts.length > 1) { + res.classes = parts.slice(1); + } + return res; +} +const HEADER_TAGS = { h1: true, h2: true, h3: true, h4: true, h5: true, h6: true }; +function isValidTag(str) { + if (HEADER_TAGS[str] != null) { + return true; + } + for (let c of str) { + if (c.toLowerCase() !== c || c.toUpperCase() === c) + return false; + } + return true; +} +function getParameters(args) { + let params = { + def: null, + text: null, + attrs: null, + func: null, + parent: null + }; + if (args.length == 0) { + params.def = parseDefinition('div'); + } + else if (typeof args[0] == 'string') { + let arg0 = args[0]; + if (isValidTag(arg0) && args.length > 1 && (typeof args[1] == 'string')) { + const arg1 = args[1]; + if (arg1.length > 1 && (arg1[0] === '.' || arg1[0] === '#')) { + arg0 += arg1; + args = args.slice(1); + } + } + params.def = parseDefinition(arg0); + args = args.slice(1); + } + for (let arg of args) { + switch (typeof arg) { + case "function": + params.func = arg; + break; + case "object": + if (arg instanceof HTMLElement || arg instanceof SVGElement) { + params.parent = arg; + } + else { + params.attrs = arg; + } + break; + case "string": + params.text = arg; + } + } + return params; +} +function domAPICreate() { + function setStyles(elem, styles) { + for (let k in styles) { + let v = styles[k]; + if (v != null) { + elem.style.setProperty(k, v); + } + else { + elem.style.removeProperty(k); + } + } + } + function setEvents(elem, events) { + for (let k in events) { + let names = k.split('|'); + for (let name of names) { + elem.addEventListener(name, events[k], false); + } + } + } + function setData(elem, data) { + for (let k in data) { + elem[k] = data[k]; + } + } + function setAttributes(elem, attrs) { + for (let k in attrs) { + let v = attrs[k]; + switch (k) { + case "style": + setStyles(elem, v); + break; + case "on": + setEvents(elem, v); + break; + case "data": + setData(elem, v); + break; + default: + if (v != null) { + elem.setAttribute(k, v); + } + else { + elem.removeAttribute(k); + } + } + } + } + let setIdClass; + function setIdClassNew(elem, idClass) { + if (idClass.id != null) { + elem.id = idClass.id; + } + for (let c of idClass.classes) { + elem.classList.add(c); + } + } + function setIdClassFallback(elem, idClass) { + if (idClass.id != null) { + elem.id = idClass.id; + } + if (idClass.classes.length > 0) { + let className = idClass.classes.join(" "); + elem.setAttribute("class", className); + } + } + function switchIdClass() { + let elem = API.document.createElementNS("http://www.w3.org/2000/svg", "g"); + if (!elem.classList) { + setIdClass = setIdClassFallback; + } + else { + setIdClass = setIdClassNew; + } + } + switchIdClass(); + function append(...args) { + let params = getParameters(args); + let parent = params.parent; + if (this != null && this._elem != null) { + if (parent != null) { + throw Error("Cannot set a parent within a context"); + } + parent = this._elem; + } + let elem; + if (params.def == null) { + elem = parent; + } + else { + let tag = params.def.tag; + let ns = NAMESPACES[TAGS_DICT[tag]]; + if (ns != null) { + elem = API.document.createElementNS(ns, tag); + } + else { + elem = API.document.createElement(tag); + } + if (params.def != null) { + setIdClass(elem, params.def); + } + if (params.attrs != null) { + setAttributes(elem, params.attrs); + } + if (parent != null) { + parent.appendChild(elem); + } + } + if (params.func != null) { + let state = { + _elem: elem + }; + params.func(append.bind(state)); + } + else if (params.text != null) { + elem.textContent = params.text; + } + return elem; + } + return append; +} +let Weya = domAPICreate(); + + +/***/ }) + +/******/ }); +/************************************************************************/ +/******/ // The module cache +/******/ var __webpack_module_cache__ = {}; +/******/ +/******/ // The require function +/******/ function __webpack_require__(moduleId) { +/******/ // Check if module is in cache +/******/ var cachedModule = __webpack_module_cache__[moduleId]; +/******/ if (cachedModule !== undefined) { +/******/ return cachedModule.exports; +/******/ } +/******/ // Create a new module (and put it into the cache) +/******/ var module = __webpack_module_cache__[moduleId] = { +/******/ // no module.id needed +/******/ // no module.loaded needed +/******/ exports: {} +/******/ }; +/******/ +/******/ // Execute the module function +/******/ __webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__); +/******/ +/******/ // Return the exports of the module +/******/ return module.exports; +/******/ } +/******/ +/************************************************************************/ +/******/ /* webpack/runtime/compat get default export */ +/******/ (() => { +/******/ // getDefaultExport function for compatibility with non-harmony modules +/******/ __webpack_require__.n = (module) => { +/******/ var getter = module && module.__esModule ? +/******/ () => (module['default']) : +/******/ () => (module); +/******/ __webpack_require__.d(getter, { a: getter }); +/******/ return getter; +/******/ }; +/******/ })(); +/******/ +/******/ /* webpack/runtime/define property getters */ +/******/ (() => { +/******/ // define getter functions for harmony exports +/******/ __webpack_require__.d = (exports, definition) => { +/******/ for(var key in definition) { +/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { +/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); +/******/ } +/******/ } +/******/ }; +/******/ })(); +/******/ +/******/ /* webpack/runtime/hasOwnProperty shorthand */ +/******/ (() => { +/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop)) +/******/ })(); +/******/ +/******/ /* webpack/runtime/make namespace object */ +/******/ (() => { +/******/ // define __esModule on exports +/******/ __webpack_require__.r = (exports) => { +/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { +/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); +/******/ } +/******/ Object.defineProperty(exports, '__esModule', { value: true }); +/******/ }; +/******/ })(); +/******/ +/************************************************************************/ +var __webpack_exports__ = {}; +// This entry need to be wrapped in an IIFE because it need to be in strict mode. +(() => { +"use strict"; +var __webpack_exports__ = {}; +/*!***********************!*\ + !*** ./src/charts.ts ***! + \***********************/ +__webpack_require__.r(__webpack_exports__); +/* harmony import */ var _types__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./types */ "./src/types.ts"); +/* harmony import */ var _data__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./data */ "./src/data.ts"); +/* harmony import */ var _controller__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./controller */ "./src/controller.ts"); +/* harmony import */ var _colors__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./colors */ "./src/colors.ts"); +/* harmony import */ var _token_loss__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./token_loss */ "./src/token_loss.ts"); + + + + + +window["chartsEmbed"] = function (elemId, data, color, theme) { + let chartData = new _data__WEBPACK_IMPORTED_MODULE_1__.ChartData(data); + let plotColors = new _colors__WEBPACK_IMPORTED_MODULE_3__.PlotColors(theme); + plotColors.setColorScheme(color); + let chart = new _controller__WEBPACK_IMPORTED_MODULE_2__.Controller(chartData.dimensions, chartData.attention, { tokens: chartData.src_tokens }, { tokens: chartData.tgt_tokens }, data.chart_types, plotColors); + document.getElementById(elemId).appendChild(chart.render(theme)); +}; +window["chartsEmbedTest"] = function () { + let sample = {}; + let chartData = new _data__WEBPACK_IMPORTED_MODULE_1__.ChartData(sample); + let plotColors = new _colors__WEBPACK_IMPORTED_MODULE_3__.PlotColors('light'); + let chart = new _controller__WEBPACK_IMPORTED_MODULE_2__.Controller(chartData.dimensions, chartData.attention, { tokens: chartData.src_tokens }, { tokens: chartData.tgt_tokens }, [_types__WEBPACK_IMPORTED_MODULE_0__.ChartType.AttentionMatrix, _types__WEBPACK_IMPORTED_MODULE_0__.ChartType.SrcTokenHeatmap, _types__WEBPACK_IMPORTED_MODULE_0__.ChartType.TokenDimHeatmap, _types__WEBPACK_IMPORTED_MODULE_0__.ChartType.DimensionHeatmap, _types__WEBPACK_IMPORTED_MODULE_0__.ChartType.LineGrid], plotColors); + document.body.appendChild(chart.render('auto')); +}; +window["tokenViz"] = function (elemId, tokens, losses, normalizedLosses, valueNames, paddingLess, color, tokenInfo, theme) { + let colorScheme = {}; + colorScheme[_types__WEBPACK_IMPORTED_MODULE_0__.ChartType.TokenLoss] = color; + let colors = new _colors__WEBPACK_IMPORTED_MODULE_3__.PlotColors(theme); + colors.setColorScheme(colorScheme); + let tokenData = []; + for (let idx = 0; idx < losses[0].length; ++idx) { + let tokenValues = losses.map((loss, i) => ({ name: valueNames[i], value: loss[idx], + normalizedValue: normalizedLosses[i][idx], info: tokenInfo[idx] })); + tokenData[idx] = { + values: tokenValues, + info: tokenInfo[idx] + }; + } + let lossView = new _token_loss__WEBPACK_IMPORTED_MODULE_4__.StringTokenLoss(tokens, tokenData, colors, paddingLess); + let div = document.createElement('div'); + div.className = "attention-visualization" + (theme === 'light' ? '' : ' dark-theme'); + div.appendChild(lossView.render()); + document.getElementById(elemId).appendChild(div); + lossView.updateMenuPosition(); +}; + +})(); + +// This entry need to be wrapped in an IIFE because it need to be in strict mode. +(() => { +"use strict"; +/*!**************************!*\ + !*** ./scss/charts.scss ***! + \**************************/ +__webpack_require__.r(__webpack_exports__); +// extracted by mini-css-extract-plugin + +})(); + +/******/ })() +; +//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY2hhcnRzLmpzIiwibWFwcGluZ3MiOiI7Ozs7Ozs7OztBQUFBO0FBQ0E7QUFDQSxLQUE0RDtBQUM1RCxDQUNnSDtBQUNoSCxDQUFDLDhCQUE4Qjs7QUFFL0I7O0FBRUE7QUFDQTtBQUNBOztBQUVBO0FBQ0E7QUFDQTtBQUNBOztBQUVBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7O0FBRUE7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQSxRQUFRO0FBQ1I7QUFDQTtBQUNBOztBQUVBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0EsUUFBUTtBQUNSO0FBQ0E7QUFDQTs7QUFFQTtBQUNBO0FBQ0E7QUFDQTs7QUFFQSxVQUFVO0FBQ1Y7O0FBRUE7QUFDQTtBQUNBOztBQUVBO0FBQ0E7QUFDQTtBQU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SBwMVsyXSxcbiAgICAgICAgZHggPSB1eDEgLSB1eDAsXG4gICAgICAgIGR5ID0gdXkxIC0gdXkwLFxuICAgICAgICBkMiA9IGR4ICogZHggKyBkeSAqIGR5LFxuICAgICAgICBpLFxuICAgICAgICBTO1xuXG4gICAgLy8gU3BlY2lhbCBjYXNlIGZvciB1MCDiiYUgdTEuXG4gICAgaWYgKGQyIDwgZXBzaWxvbjIkMSkge1xuICAgICAgUyA9IE1hdGgubG9nKHcxIC8gdzApIC8gcmhvO1xuICAgICAgaSA9IGZ1bmN0aW9uKHQpIHtcbiAgICAgICAgcmV0dXJuIFtcbiAgICAgICAgICB1eDAgKyB0ICogZHgsXG4gICAgICAgICAgdXkwICsgdCAqIGR5LFxuICAgICAgICAgIHcwICogTWF0aC5leHAocmhvICogdCAqIFMpXG4gICAgICAgIF07XG4gICAgICB9O1xuICAgIH1cblxuICAgIC8vIEdlbmVyYWwgY2FzZS5cbiAgICBlbHNlIHtcbiAgICAgIHZhciBkMSA9IE1hdGguc3FydChkMiksXG4gICAgICAgICAgYjAgPSAodzEgKiB3MSAtIHcwICogdzAgKyByaG80ICogZDIpIC8gKDIgKiB3MCAqIHJobzIgKiBkMSksXG4gICAgICAgICAgYjEgPSAodzEgKiB3MSAtIHcwICogdzAgLSByaG80ICogZDIpIC8gKDIgKiB3MSAqIHJobzIgKiBkMSksXG4gICAgICAgICAgcjAgPSBNYXRoLmxvZyhNYXRoLnNxcnQoYjAgKiBiMCArIDEpIC0gYjApLFxuICAgICAgICAgIHIxID0gTWF0aC5sb2coTWF0aC5zcXJ0KGIxICogYjEgKyAxKSAtIGIxKTtcbiAgICAgIFMgPSAocjEgLSByMCkgLyByaG87XG4gICAgICBpID0gZnVuY3Rpb24odCkge1xuICAgICAgICB2YXIgcyA9IHQgKiBTLFxuICAgICAgICAgICAgY29zaHIwID0gY29zaChyMCksXG4gICAgICAgICAgICB1ID0gdzAgLyAocmhvMiAqIGQxKSAqIChjb3NocjAgKiB0YW5oKH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jdGlvbigpIHtcbiAgICAgICAgICAgIHZhciB0aGF0ID0gdGhpcyxcbiAgICAgICAgICAgICAgICBzdGF0ZSA9IHRoYXQuX19icnVzaCxcbiAgICAgICAgICAgICAgICBlbWl0ID0gZW1pdHRlcih0aGF0LCBhcmd1bWVudHMpLFxuICAgICAgICAgICAgICAgIHNlbGVjdGlvbjAgPSBzdGF0ZS5zZWxlY3Rpb24sXG4gICAgICAgICAgICAgICAgc2VsZWN0aW9uMSA9IGRpbS5pbnB1dCh0eXBlb2Ygc2VsZWN0aW9uID09PSBcImZ1bmN0aW9uXCIgPyBzZWxlY3Rpb24uYXBwbHkodGhpcywgYXJndW1lbnRzKSA6IHNlbGVjdGlvbiwgc3RhdGUuZXh0ZW50KSxcbiAgICAgICAgICAgICAgICBpID0gaW50ZXJwb2xhdGUkMihzZWxlY3Rpb24wLCBzZWxlY3Rpb24xKTtcblxuICAgICAgICAgICAgZnVuY3Rpb24gdHdlZW4odCkge1xuICAgICAgICAgICAgICBzdGF0ZS5zZWxlY3Rpb24gPSB0ID09PSAxICYmIHNlbGVjdGlvbjEgPT09IG51bGwgPyBudWxsIDogaSh0KTtcbiAgICAgICAgICAgICAgcmVkcmF3LmNhbGwodGhhdCk7XG4gICAgICAgICAgICAgIGVtaXQuYnJ1c2goKTtcbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgcmV0dXJuIHNlbGVjdGlvbjAgIT09IG51bGwgJiYgc2VsZWN0aW9uMSAhPT0gbnVsbCA/IHR3ZWVuIDogdHdlZW4oMSk7XG4gICAgICAgICAgfSk7XG4gICAgfSBlbHNlIHtcbiAgICAgIGdyb3VwXG4gICAgICAgICAgLmVhY2goZnVuY3Rpb24oKSB7XG4gICAgICAgICAgICB2YXIgdGhhdCA9IHRoaXMsXG4gICAgICAgICAgICAgICAgYXJncyA9IGFyZ3VtZW50cyxcbiAgICAgICAgICAgICAgICBzdGF0ZSA9IHRoYXQuX19icnVzaCxcbiAgICAgICAgICAgICAgICBzZWx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25YID4gMCkgdzAgPSB3MSAtIGR4O1xuICAgICAgICAgICAgaWYgKHNpZ25ZIDwgMCkgczAgPSBzMSAtIGR5OyBlbHNlIGlmIChzaWduWSA+IDApIG4wID0gbjEgLSBkeTtcbiAgICAgICAgICAgIG1vZGUgPSBNT0RFX1NQQUNFO1xuICAgICAgICAgICAgb3ZlcmxheS5hdHRyKFwiY3Vyc29yXCIsIGN1cnNvcnMuc2VsZWN0aW9uKTtcbiAgICAgICAgICAgIG1vdmUoZXZlbnQpO1xuICAgICAgICAgIH1cbiAgICAgICAgICBicmVhaztcbiAgICAgICAgfVxuICAgICAgICBkZWZhdWx0OiByZXR1cm47XG4gICAgICB9XG4gICAgICBub2V2ZW50JDEoZXZlbnQpO1xuICAgIH1cblxuICAgIGZ1bmN0aW9uIGtleXVwcGVkKGV2ZW50KSB7XG4gICAgICBzd2l0Y2ggKGV2ZW50LmtleUNvZGUpIHtcbiAgICAgICAgY2FzZSAxNjogeyAvLyBTSElGVFxuICAgICAgICAgIGlmIChzaGlmdGluZykge1xuICAgICAgICAgICAgbG9ja1ggPSBsb2NrWSA9IHNoaWZ0aW5nID0gZmFsc2U7XG4gICAgICAgICAgICBtb3ZlKGV2ZW50KTtcbiAgICAgICAgICB9XG4gICAgICAgICAgYnJlYWs7XG4gICAgICAgIH1cbiAgICAgICAgY2FzZSAxODogeyAvLyBBTFRcbiAgICAgICAgICBpZiAobW9kZSA9PT0gTU9ERV9DRU5URVIpIHtcbiAgICAgICAgICAgIGlmIChzaWduWCA8IDApIGUwID0gZTE7IGVsc2UgaWYgKHNpZ25YID4gMCkgdzAgPSB3MTtcbiAgICAgICAgICAgIGlmIChzaWduWSA8IDApIHMwID0gczE7IGVsc2UgaWYgKHNpZ25ZID4gMCkgbjAgPSBuMTtcbiAgICAgICAgICAgIG1vZGUgPSBNT0RFX0hBTkRMRTtcbiAgICAgICAgICAgIG1vdmUoZXZlbnQpO1xuICAgICAgICAgIH1cbiAgICAgICAgICBicmVhaztcbiAgICAgICAgfVxuICAgICAgICBjYXNlIDMyOiB7IC8vIFNQQUNFXG4gICAgICAgICAgaWYgKG1vZGUgPT09IE1PREVfU1BBQ0UpIHtcbiAgICAgICAgICAgIGlmIChldmVudC5hbHRLZXkpIHtcbiAgICAgICAgICAgICAgaWYgKHNpZ25YKSBlMCA9IGUxIC0gZHggKiBzaWduWCwgdzAgPSB3MSArIGR4ICogc2lnblg7XG4gICAgICAgICAgICAgIGlmIChzaWduWSkgczAgPSBzMSAtIGR5ICogc2lnblksIG4wID0gbjEgKyBkeSAqIHNpZ25ZO1xuICAgICAgICAgICAgICBtb2RlID0gTU9ERV9DRU5URVI7XG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICBpZiAoc2lnblggPCAwKSBlMCA9IGUxOyBlbHNlIGlmIChzaWduWCA+IDApIHcwID0gdzE7XG4gICAgICAgICAgICAgIGlmIChzaWduWSA8IDApIHMwID0gczE7IGVsc2UgaWYgKHNpZ25ZID4gMCkgbjAgPSBuMTtcbiAgICAgICAgICAgICAgbW9kZSA9IE1PREVfSEFORExFO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgb3ZlcmxheS5hdHRyKFwiY3Vyc29yXCIsIGN1cnNvcnNbdHlwZV0pO1xuICAgICAgICAgICAgbW92ZShldmVudCk7XG4gICAgICAgICAgfVxuICAgICAgICAgIGJyZWFrO1xuICAgICAgICB9XG4gICAgICAgIGRlZmF1bHQ6IHJldHVybjtcbiAgICAgIH1cbiAgICAgIG5vZXZlbnQkMShldmVudCk7XG4gICAgfVxuICB9XG5cbiAgZnVuY3Rpb24gdG91Y2htb3ZlZChldmVudCkge1xuICAgIGVtaXR0ZXIodGhpcywgYXJndW1lbnRzKS5tb3ZlZChldmVudCk7XG4gIH1cblxuICBmdW5jdGlvbiB0b3VjaGVuZGVkKGV2ZW50KSB7XG4gICAgZW1pdHRlcih0aGlzLCBhcmd1bWVudHMpLmVuZGVkKGV2ZW50KTtcbiAgfVxuXG4gIGZ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IG4pIC8gaztcbiAgICBkeCA9IGsgPyBwYWRBbmdsZSA6IHRhdSQ0IC8gbjtcblxuICAgIC8vIENvbXB1dGUgdGhlIGFuZ2xlcyBmb3IgZWFjaCBncm91cCBhbmQgY29uc3RpdHVlbnQgY2hvcmQuXG4gICAge1xuICAgICAgbGV0IHggPSAwO1xuICAgICAgaWYgKHNvcnRHcm91cHMpIGdyb3VwSW5kZXguc29ydCgoYSwgYikgPT4gc29ydEdyb3Vwcyhncm91cFN1bXNbYV0sIGdyb3VwU3Vtc1tiXSkpO1xuICAgICAgZm9yIChjb25zdCBpIG9mIGdyb3VwSW5kZXgpIHtcbiAgICAgICAgY29uc3QgeDAgPSB4O1xuICAgICAgICBpZiAoZGlyZWN0ZWQpIHtcbiAgICAgICAgICBjb25zdCBzdWJncm91cEluZGV4ID0gcmFuZ2UkMSh+biArIDEsIG4pLmZpbHRlcihqID0+IGogPCAwID8gbWF0cml4W35qICogbiArIGldIDogbWF0cml4W2kgKiBuICsgal0pO1xuICAgICAgICAgIGlmIChzb3J0U3ViZ3JvdXBzKSBzdWJncm91cEluZGV4LnNvcnQoKGEsIGIpID0+IHNvcnRTdWJncm91cHMoYSA8IDAgPyAtbWF0cml4W35hICogbiArIGldIDogbWF0cml4W2kgKiBuICsgYV0sIGIgPCAwID8gLW1hdHJpeFt+YiAqIG4gKyBpXSA6IG1hdHJpeFtpICogbiArIGJdKSk7XG4gICAgICAgICAgZm9yIChjb25zdCBqIG9mIHN1Ymdyb3VwSW5kZXgpIHtcbiAgICAgICAgICAgIGlmIChqIDwgMCkge1xuICAgICAgICAgICAgICBjb25zdCBjaG9yZCA9IGNob3Jkc1t+aiAqIG4gKyBpXSB8fCAoY2hvcmRzW35qICogbiArIGldID0ge3NvdXJjZTogbnVsbCwgdGFyZ2V0OiBudWxsfSk7XG4gICAgICAgICAgICAgIGNob3JkLnRhcmdldCA9IHtpbmRleDogaSwgc3RhcnRBbmdsZTogeCwgZW5kQW5nbGU6IHggKz0gbWF0cml4W35qICogbiArIGldICogaywgdmFsdWU6IG1hdHJpeFt+aiAqIG4gKyBpXX07XG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICBjb25zdCBjaG9yZCA9IGNob3Jkc1tpICogbiArIGpdIHx8IChjaG9yZHNbaSAqIG4gKyBqXSA9IHtzb3VyY2U6IG51bGwsIHRhcmdldDogbnVsbH0pO1xuICAgICAgICAgICAgICBjaG9yZC5zb3VyY2UgPSB7aW5kZXg6IGksIHN0YXJ0QW5nbGU6IHgsIGVuZEFuZ2xlOiB4ICs9IG1hdHJpeFtpICogbiArIGpdICogaywgdmFsdWU6IG1hdHJpeFtpICogbiArIGpdfTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICB9XG4gICAgICAgICAgZ3JvdXBzW2ldID0ge2luZGV4OiBpLCBzdGFydEFuZ2xlOiB4MCwgZW5kQW5nbGU6IHgsIHZhbHVlOiBncm91cFN1bXNbaV19O1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgIGNvbnN0IHN1Ymdyb3VwSW5kZXggPSByYW5nZSQxKDAsIG4pLmZpbHRlcihqID0+IG1hdHJpeFtpICogbiArIGpdIHx8IG1hdHJpeFtqICogbiArIGldKTtcbiAgICAgICAgICBpZiAoc29ydFN1Ymdyb3Vwcykgc3ViZ3JvdXBJbmRleC5zb3J0KChhLCBiKSA9PiBzb3J0U3ViZ3JvdXBzKG1hdHJpeFtpICogbiArIGFdLCBtYXRyaXhbaSAqIG4gKyBiXSkpO1xuICAgICAgICAgIGZvciAoY29uc3QgaiBvZiBzdWJncm91cEluZGV4KSB7XG4gICAgICAgICAgICBsZXQgY2hvcmQ7XG4gICAgICAgICAgICBpZiAoaSA8IGopIHtcbiAgICAgICAgICAgICAgY2hvcmQgPSBjaG9yZHNbaSAqIG4gKyBqXSB8fCAoY2hvcmRzW2kgKiBuICsgal0gPSB7c291cmNlOiBudWxsLCB0YXJnZXQ6IG51bGx9KTtcbiAgICAgICAgICAgICAgY2hvcmQuc291cmNlID0ge2luZGV4OiBpLCBzdGFydEFuZ2xlOiB4LCBlbmRBbmdsZTogeCArPSBtYXRyaXhbaSAqIG4gKyBqXSAqIGssIHZhbHVlOiBtYXRyaXhbaSAqIG4gKyBqXX07XG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICBjaG9yZCA9IGNob3Jkc1tqICogbiArIGldIHx8IChjaG9yZHNbaiAqIG4gKyBpXSA9IHtzb3VyY2U6IG51bGwsIHRhcmdldDogbnVsbH0pO1xuICAgICAgICAgICAgICBjaG9yZC50YXJnZXQgPSB7aW5kZXg6IGksIHN0YXJ0QW5nbGU6IHgsIGVuZEFuZ2xlOiB4ICs9IG1hdHJpeFtpICogbiArIGpdICogaywgdmFsdWU6IG1hdHJpeFtpICogbiArIGpdfTtcbiAgICAgICAgICAgICAgaWYgKGkgPT09IGopIGNob3JkLnNvdXJjZSA9IGNob3JkLnRhcmdldDtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGlmIChjaG9yZC5zb3VyY2UgJiYgY2hvcmQudGFyZ2V0ICYmIGNob3JkLnNvdXJjZS52YWx1ZSA8IGNob3JkLnRhcmdldC52YWx1ZSkge1xuICAgICAgICAgICAgICBjb25zdCBzb3VyY2UgPSBjaG9yZC5zb3VyY2U7XG4gICAgICAgICAgICAgIGNob3JkLnNvdXJjZSA9IGNob3JkLnRhcmdldDtcbiAgICAgICAgICAgICAgY2hvcmQudGFyZ2V0ID0gc291cmNlO1xuICAgICAgICAgICAgfVxuICAgICAgICAgIH1cbiAgICAgICAgICBncm91cHNbaV0gPSB7aW5kZXg6IGksIHN0YXJ0QW5nbGU6IHgwLCBlbmRBbmdsZTogeCwgdmFsdWU6IGdyb3VwU3Vtc1tpXX07XG4gICAgICAgIH1cbiAgICAgICAgeCArPSBkeDtcbiAgICAgIH1cbiAgICB9XG5cbiAgICAvLyBSZW1vdmUgZW1wdHkgY2hvcmRzLlxuICAgIGNob3JkcyA9IE9iamVjdC52YW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oICh4Mix5Mik/XG4gICAgLy8gT3IsIGlzIHRoZSByYWRpdXMgemVybz8gTGluZSB0byAoeDEseTEpLlxuICAgIGVsc2UgaWYgKCEoTWF0aC5hYnMoeTAxICogeDIxIC0geTIxICogeDAxKSA+IGVwc2lsb24kNCkgfHwgIXIpIHtcbiAgICAgIHRoaXMuXyArPSBcIkxcIiArICh0aGlzLl94MSA9IHgxKSArIFwiLFwiICsgKHRoaXMuX3kxID0geTEpO1xuICAgIH1cblxuICAgIC8vIE90aGVyd2lzZSwgZHJhdyBhbiBhcmMhXG4gICAgZWxzZSB7XG4gICAgICB2YXIgeDIwID0geDIgLSB4MCxcbiAgICAgICAgICB5MjAgPSB5MiAtIHkwLFxuICAgICAgICAgIGwyMV8yID0geDIxICogeDIxICsgeTIxICogeTIxLFxuICAgICAgICAgIGwyMF8yID0geDIwICogeDIwICsgeTIwICogeTIwLFxuICAgICAgICAgIGwyMSA9IE1hdGguc3FydChsMjFfMiksXG4gICAgICAgICAgbDAxID0gTWF0aC5zcXJ0KGwwMV8yKSxcbiAgICAgICAgICBsID0gciAqIE1hdGgudGFuKChwaSQyIC0gTWF0aC5hY29zKChsMjFfMiArIGwwMV8yIC0gbDIwXzIpIC8gKDIgKiBsMjEgKiBsMDEpKSkgLyAyKSxcbiAgICAgICAgICB0MDEgPSBsIC8gbDAxLFxuICAgICAgICAgIHQyMSA9IGwgLyBsMjE7XG5cbiAgICAgIC8vIElmIHRoZSBzdGFydCB0YW5nZW50IGlzIG5vdCBjb2luY2lkZW50IHdpdGggKHgwLHkwKSwgbGluZSB0by5cbiAgICAgIGlmIChNYXRoLmFicyh0MDEgLSAxKSA+IGVwc2lsb24kNCkge1xuICAgICAgICB0aGlzLl8gKz0gXCJMXCIgKyAoeDEgKyB0MDEgKiB4MDEpICsgXCIsXCIgKyAoeTEgKyB0MDEgKiB5MDEpO1xuICAgICAgfVxuXG4gICAgICB0aGlzLl8gKz0gXCJBXCIgKyByICsgXCIsXCIgKyByICsgXCI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LCBmbGVuLCBmLCBoKSB7XG4gICAgbGV0IFEsIFFuZXcsIGhoLCBidmlydDtcbiAgICBsZXQgZW5vdyA9IGVbMF07XG4gICAgbGV0IGZub3cgPSBmWzBdO1xuICAgIGxldCBlaW5kZXggPSAwO1xuICAgIGxldCBmaW5kZXggPSAwO1xuICAgIGlmICgoZm5vdyA+IGVub3cpID09PSAoZm5vdyA+IC1lbm93KSkge1xuICAgICAgICBRID0gZW5vdztcbiAgICAgICAgZW5vdyA9IGVbKytlaW5kZXhdO1xuICAgIH0gZWxzZSB7XG4gICAgICAgIFEgPSBmbm93O1xuICAgICAgICBmbm93ID0gZlsrK2ZpbmRleF07XG4gICAgfVxuICAgIGxldCBoaW5kZXggPSAwO1xuICAgIGlmIChlaW5kZXggPCBlbGVuICYmIGZpbmRleCA8IGZsZW4pIHtcbiAgICAgICAgaWYgKChmbm93ID4gZW5vdykgPT09IChmbm93ID4gLWVub3cpKSB7XG4gICAgICAgICAgICBRbmV3ID0gZW5vdyArIFE7XG4gICAgICAgICAgICBoaCA9IFEgLSAoUW5ldyAtIGVub3cpO1xuICAgICAgICAgICAgZW5vdyA9IGVbKytlaW5kZXhdO1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgUW5ldyA9IGZub3cgKyBRO1xuICAgICAgICAgICAgaGggPSBRIC0gKFFuZXcgLSBmbm93KTtcbiAgICAgICAgICAgIGZub3cgPSBmWysrZmluZGV4XTtcbiAgICAgICAgfVxuICAgICAgICBRID0gUW5ldztcbiAgICAgICAgaWYgKGhoICE9PSAwKSB7XG4gICAgICAgICAgICBoW2hpbmRleCsrXSA9IGhoO1xuICAgICAgICB9XG4gICAgICAgIHdoaWxlIChlaW5kZXggPCBlbGVuICYmIGZpbmRleCA8IGZsZW4pIHtcbiAgICAgICAgICAgIGlmICgoZm5vdyA+IGVub3cpID09PSAoZm5vdyA+IC1lbm93KSkge1xuICAgICAgICAgICAgICAgIFFuZXcgPSBRICsgZW5vdztcbiAgICAgICAgICAgICAgICBidmlydCA9IFFuZXcgLSBRO1xuICAgICAgICAgICAgICAgIGhoID0gUSAtIChRbmV3IC0gYnZpcnQpICsgKGVub3cgLSBidmlydCk7XG4gICAgICAgICAgICAgICAgZW5vdyA9IGVbKytlaW5kZXhdO1xuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICBRbmV3ID0gUSArIGZub3c7XG4gICAgICAgICAgICAgICAgYnZpcnQgPSBRbmV3IC0gUTtcbiAgICAgICAgICAgICAgICBoaCA9IFEgLSAoUW5ldyAtIGJ2aXJ0KSArIChmbm93IC0gYnZpcnQpO1xuICAgICAgICAgICAgICAgIGZub3cgPSBmWysrZmluZGV4XTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIFEgPSBRbmV3O1xuICAgICAgICAgICAgaWYgKGhoICE9PSAwKSB7XG4gICAgICAgICAgICAgICAgaFtoaW5kZXgrK10gPSBoaDtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgIH1cbiAgICB3aGlsZSAoZWluZGV4IDwgZWxlbikge1xuICAgICAgICBRbmV3ID0gUSArIGVub3c7XG4gICAgICAgIGJ2aXJ0ID0gUW5ldyAtIFE7XG4gICAgICAgIGhoID0gUSAtIChRbmV3IC0gYnZpcnQpICsgKGVub3cgLSBidmlydCk7XG4gICAgICAgIGVub3cgPSBlWysrZWluZGV4XTtcbiAgICAgICAgUSA9IFFuZXc7XG4gICAgICAgIGlmIChoaCAhPT0gMCkge1xuICAgICAgICAgICAgaFtoaW5kZXgrK10gPSBoaDtcbiAgICAgICAgfVxuICAgIH1cbiAgICB3aGlsZSAoZmluZGV4IDwgZmxlbikge1xuICAgICAgICBRbmV3ID0gUSArIGZub3c7XG4gICAgICAgIGJ2aXJ0ID0gUW5ldyAtIFE7XG4gICAgICAgIGhoID0gUSAtIChRbmV3IC0gYnZpcnQpICsgKGZub3cgLSBidmlydCk7XG4gICAgICAgIGZub3cgPSBmWysrZmluZGV4XTtcbiAgICAgICA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gICBjb25zdCBuID0gY29vcmRzLmxlbmd0aCA+PiAxO1xuXG4gICAgICAgIC8vIHBvcHVsYXRlIGFuIGFycmF5IG9mIHBvaW50IGluZGljZXM7IGNhbGN1bGF0ZSBpbnB1dCBkYXRhIGJib3hcbiAgICAgICAgbGV0IG1pblggPSBJbmZpbml0eTtcbiAgICAgICAgbGV0IG1pblkgPSBJbmZpbml0eTtcbiAgICAgICAgbGV0IG1heFggPSAtSW5maW5pdHk7XG4gICAgICAgIGxldCBtYXhZID0gLUluZmluaXR5O1xuXG4gICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgbjsgaSsrKSB7XG4gICAgICAgICAgICBjb25zdCB4ID0gY29vcmRzWzIgKiBpXTtcbiAgICAgICAgICAgIGNvbnN0IHkgPSBjb29yZHNbMiAqIGkgKyAxXTtcbiAgICAgICAgICAgIGlmICh4IDwgbWluWCkgbWluWCA9IHg7XG4gICAgICAgICAgICBpZiAoeSA8IG1pblkpIG1pblkgPSB5O1xuICAgICAgICAgICAgaWYgKHggPiBtYXhYKSBtYXhYID0geDtcbiAgICAgICAgICAgIGlmICh5ID4gbWF4WSkgbWF4WSA9IHk7XG4gICAgICAgICAgICB0aGlzLl9pZHNbaV0gPSBpO1xuICAgICAgICB9XG4gICAgICAgIGNvbnN0IGN4ID0gKG1pblggKyBtYXhYKSAvIDI7XG4gICAgICAgIGNvbnN0IGN5ID0gKG1pblkgKyBtYXhZKSAvIDI7XG5cbiAgICAgICAgbGV0IG1pbkRpc3QgPSBJbmZpbml0eTtcbiAgICAgICAgbGV0IGkwLCBpMSwgaTI7XG5cbiAgICAgICAgLy8gcGljayBhIHNlZWQgcG9pbnQgY2xvc2UgdG8gdGhlIGNlbnRlclxuICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IG47IGkrKykge1xuICAgICAgICAgICAgY29uc3QgZCA9IGRpc3QoY3gsIGN5LCBjb29yZHNbMiAqIGldLCBjb29yZHNbMiAqIGkgKyAxXSk7XG4gICAgICAgICAgICBpZiAoZCA8IG1pbkRpc3QpIHtcbiAgICAgICAgICAgICAgICBpMCA9IGk7XG4gICAgICAgICAgICAgICAgbWluRGlzdCA9IGQ7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgICAgY29uc3QgaTB4ID0gY29vcmRzWzIgKiBpMF07XG4gICAgICAgIGNvbnN0IGkweSA9IGNvb3Jkc1syICogaTAgKyAxXTtcblxuICAgICAgICBtaW5EaXN0ID0gSW5maW5pdHk7XG5cbiAgICAgICAgLy8gZmluZCB0aGUgcG9pbnQgY2xvc2VzdCB0byB0aGUgc2VlZFxuICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IG47IGkrKykge1xuICAgICAgICAgICAgaWYgKGkgPT09IGkwKSBjb250aW51ZTtcbiAgICAgICAgICAgIGNvbnN0IGQgPSBkaXN0KGkweCwgaTB5LCBjb29yZHNbMiAqIGldLCBjb29yZHNbMiAqIGkgKyAxXSk7XG4gICAgICAgICAgICBpZiAoZCA8IG1pbkRpc3QgJiYgZCA+IDApIHtcbiAgICAgICAgICAgICAgICBpMSA9IGk7XG4gICAgICAgICAgICAgICAgbWluRGlzdCA9IGQ7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgICAgbGV0IGkxeCA9IGNvb3Jkc1syICogaTFdO1xuICAgICAgICBsZXQgaTF5ID0gY29vcmRzWzIgKiBpMSArIDFdO1xuXG4gICAgICAgIGxldCBtaW5SYWRpdXMgPSBJbmZpbml0eTtcblxuICAgICAgICAvLyBmaW5kIHRoZSB0aGlyZCBwb2ludCB3aGljaCBmb3JtcyB0aGUgc21hbGxlc3QgY2lyY3VtY2lyY2xlIHdpdGggdGhlIGZpcnN0IHR3b1xuICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IG47IGkrKykge1xuICAgICAgICAgICAgaWYgKGkgPT09IGkwIHx8IGkgPT09IGkxKSBjb250aW51ZTtcbiAgICAgICAgICAgIGNvbnN0IHIgPSBjaXJjdW1yYWRpdXMoaTB4LCBpMHksIGkxeCwgaTF5LCBjb29yZHNbMiAqIGldLCBjb29yZHNbMiAqIGkgKyAxXSk7XG4gICAgICAgICAgICBpZiAociA8IG1pblJhZGl1cykge1xuICAgICAgICAgICAgICAgIGkyID0gaTtcbiAgICAgICAgICAgICAgICBtaW5SYWRpdXMgPSByO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICAgIGxldCBpMnggPSBjb29yZHNbMiAqIGkyXTtcbiAgICAgICAgbGV0IGkyeSA9IGNvb3Jkc1syICogaTIgKyAxXTtcblxuICAgICAgICBpZiAobWluUmFkaXVzID09PSBJbmZpbml0eSkge1xuICAgICAgICAgICAgLy8gb3JkZXIgY29sbGluZWFyIHBvaW50cyBieSBkeCAob3IgZHkgaWYgYWxsIHggYXJlIGlkZW50aWNhbClcbiAgICAgICAgICAgIC8vIGFuZCByZXR1cm4gdGhlIGxpc3QgYXMgYSBodWxsXG4gICAgICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IG47IGkrKykge1xuICAgICAgICAgICAgICAgIHRoaXMuX2Rpc3RzW2ldID0gKGNvb3Jkc1syICogaV0gLSBjb29yZHNbMF0pIHx8IChjb29yZHNbMiAqIGkgKyAxXSAtIGNvb3Jkc1sxXSk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBxdWlja3NvcnQodGhpcy5faWRzLCB0aGlzLl9kaXN0cywgMCwgbiAtIDEpO1xuICAgICAgICAgICAgY29uc3QgaHVsbCA9IG5ldyBVaW50MzJBcnJheShuKTtcbiAgICAgICAgICAgIGxldCBqID0gMDtcbiAgICAgICAgICAgIGZvciAobGV0IGkgPSAwLCBkMCA9IC1JbmZpbml0eTsgaSA8IG47IGkrKykge1xuICAgICAgICAgICAgICAgIGNvbnN0IGlkID0gdGhpcy5faWRzW2ldO1xuICAgICAgICAgICAgICAgIGlmICh0aGlzLl9kaXN0c1tpZF0gPiBkMCkge1xuICAgICAgICAgICAgICAgICAgICBodWxsW2orK10gPSBpZDtcbiAgICAgICAgICAgICAgICAgICAgZDAgPSB0aGlzLl9kaXN0c1tpZF07XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICAgICAgdGhpcy5odWxsID0gaHVsbC5zdWJhcnJheSgwLCBqKTtcbiAgICAgICAgICAgIHRoaXMudHJpYW5nbGVzID0gbmV3IFVpbnQzMkFycmF5KDApO1xuICAgICAgICAgICAgdGhpcy5oYWxmZWRnZXMgPSBuZXcgVWludDMyQXJyYXkoMCk7XG4gICAgICAgICAgICByZXR1cm47XG4gICAgICAgIH1cblxuICAgICAgICAvLyBzd2FwIHRoZSBvcmRlciBvZiB0aGUgc2VlZCBwb2ludHMgZm9yIGNvdW50ZXItY2xvY2t3aXNlIG9yaWVudGF0aW9uXG4gICAgICAgIGlmIChvcmllbnQyZChpMHgsIGkweSwgaTF4LCBpMXksIGkyeCwgaTJ5KSA8IDApIHtcbiAgICAgICAgICAgIGNvbnN0IGkgPSBpMTtcbiAgICAgICAgICAgIGNvbnN0IHggPSBpMXg7XG4gICAgICAgICAgICBjb25zdCB5ID0gaTF5O1xuICAgICAgICAgICAgaTEgPSBpMjtcbiAgICAgICAgICAgIGkxeCA9IGkyeDtcbiAgICAgICAgICAgIGkxeSA9IGkyeTtcbiAgICAgICAgICAgIGkyID0gaTtcbiAgICAgICAgICAgIGkyeCA9IHg7XG4gICAgICAgICAgICBpMnkgPSB5O1xuICAgICAgICB9XG5cbiAgICAgICAgY29uc3QgY2VudGVyID0gY2lyY3VtY2VudGVyKGkweCwgaTB5LCBpMXgsIGkxeSwgaTJ4LCBpMnkpO1xuICAgICAgICB0aGlzLl9jeCA9IGNlbnRlci54O1xuICAgICAgICB0aGlzLl9jeSA9IGNlbnRlci55O1xuXG4gICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgbjsgaSsrKSB7XG4gICAgICAgICAgICB0aGlzLl9kaXN0c1tpXSA9IGRpc3QoY29vcmRzWzIgKiBpXSwgY29vcmRzWzIgK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srKykge1xuICAgICAgICAgICAgY29uc3QgaSA9IHRoaXMuX2lkc1trXTtcbiAgICAgICAgICAgIGNvbnN0IHggPSBjb29yZHNbMiAqIGldO1xuICAgICAgICAgICAgY29uc3QgeSA9IGNvb3Jkc1syICogaSArIDFdO1xuXG4gICAgICAgICAgICAvLyBza2lwIG5lYXItZHVwbGljYXRlIHBvaW50c1xuICAgICAgICAgICAgaWYgKGsgPiAwICYmIE1hdGguYWJzKHggLSB4cCkgPD0gRVBTSUxPTiAmJiBNYXRoLmFicyh5IC0geXApIDw9IEVQU0lMT04pIGNvbnRpbnVlO1xuICAgICAgICAgICAgeHAgPSB4O1xuICAgICAgICAgICAgeXAgPSB5O1xuXG4gICAgICAgICAgICAvLyBza2lwIHNlZWQgdHJpYW5nbGUgcG9pbnRzXG4gICAgICAgICAgICBpZiAoaSA9PT0gaTAgfHwgaSA9PT0gaTEgfHwgaSA9PT0gaTIpIGNvbnRpbnVlO1xuXG4gICAgICAgICAgICAvLyBmaW5kIGEgdmlzaWJsZSBlZGdlIG9uIHRoZSBjb252ZXggaHVsbCB1c2luZyBlZGdlIGhhc2hcbiAgICAgICAgICAgIGxldCBzdGFydCA9IDA7XG4gICAgICAgICAgICBmb3IgKGxldCBqID0gMCwga2V5ID0gdGhpcy5faGFzaEtleSh4LCB5KTsgaiA8IHRoaXMuX2hhc2hTaXplOyBqKyspIHtcbiAgICAgICAgICAgICAgICBzdGFydCA9IGh1bGxIYXNoWyhrZXkgKyBqKSAlIHRoaXMuX2hhc2hTaXplXTtcbiAgICAgICAgICAgICAgICBpZiAoc3RhcnQgIT09IC0xICYmIHN0YXJ0ICE9PSBodWxsTmV4dFtzdGFydF0pIGJyZWFrO1xuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICBzdGFydCA9IGh1bGxQcmV2W3N0YXJ0XTtcbiAgICAgICAgICAgIGxldCBlID0gc3RhcnQsIHE7XG4gICAgICAgICAgICB3aGlsZSAocSA9IGh1bGxOZXh0W2VdLCBv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V07XG4gICAgICAgICAgICB3aGlsZSAocSA9IGh1bGxOZXh0W25dLCBvcmllbnQyZCh4LCB5LCBjb29yZHNbMiAqIG5dLCBjb29yZHNbMiAqIG4gKyAxXSwgY29vcmRzWzIgKiBxXSwgY29vcmRzWzIgKiBxICsgMV0pIDwgMCkge1xuICAgICAgICAgICAgICAgIHQgPSB0aGlzLl9hZGRUcmlhbmdsZShuLCBpLCBxLCBodWxsVHJpW2ldLCAtMSwgaHVsbFRyaVtuXSk7XG4gICAgICAgICAgICAgICAgaHVsbFRyaVtpXSA9IHRoaXMuX2xlZ2FsaXplKHQgKyAyKTtcbiAgICAgICAgICAgICAgICBodWxsTmV4dFtuXSA9IG47IC8vIG1hcmsgYXMgcmVtb3ZlZFxuICAgICAgICAgICAgICAgIGh1bGxTaXplLS07XG4gICAgICAgICAgICAgICAgbiA9IHE7XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIC8vIHdhbGsgYmFja3dhcmQgZnJvbSB0aGUgb3RoZXIgc2lkZSwgYWRkaW5nIG1vcmUgdHJpYW5nbGVzIGFuZCBmbGlwcGluZ1xuICAgICAgICAgICAgaWYgKGUgPT09IHN0YXJ0KSB7XG4gICAgICAgICAgICAgICAgd2hpbGUgKHEgPSBodWxsUHJldltlXSwgb3JpZW50MmQoeCwgeSwgY29vcmRzWzIgKiBxXSwgY29vcmRzWzIgKiBxICsgMV0sIGNvb3Jkc1syICogZV0sIGNvb3Jkc1syICogZSArIDFdKSA8IDApIHtcbiAgICAgICAgICAgICAgICAgICAgdCA9IHRoaXMuX2FkZFRyaWFuZ2xlKHEsIGksIGUsIC0xLCBodWxsVHJpW2VdLCBodWxsVHJpW3FdKTtcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5fbGVnYWxpemUodCArIDIpO1xuICAgICAgICAgICAgICAgICAgICBodWxsVHJpW3FdID0gdDtcbiAgICAgICAgICAgICAgICAgICAgaHVsbE5leHRbZV0gPSBlOyAvLyBtYXJrIGFzIHJlbW92ZWRcbiAgICAgICAgICAgICAgICAgICAgaHVsbFNpemUtLTtcbiAgICAgICAgICAgICAgICAgICAgZSA9IHE7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAvLyB1cGRhdGUgdGhlIGh1bGwgaW5kaWNlc1xuICAgICAgICAgICAgdGhpcy5faHVsbFN0YXJ0ID0gaHVsbFByZXZbaV0gPSBlO1xuICAgICAgICAgICAgaHVsbE5leHRbZV0gPSBodWxsUHJldltuXSA9IGk7XG4gICAgICAgICAgICBodWxsTmV4dFtpXSA9IG47XG5cbiAgICAgICAgICAgIC8vIHNhdmUgdGhlIHR3byBuZXcgZWRnZXMgaW4gdGhlIGhhc2ggdGFibGVcbiAgICAgICAgICAgIGh1bGxIYXNoW3RoaXMuX2hhc2hLZXkoeCwgeSldID0gaTtcbiAgICAgICAgICAgIGh1bGxIYXNoW3RoaXMuX2hhc2hLZXkoY29vcmRzWzIgKiBlXSwgY29vcmRzWzIgKiBlICsgMV0pXSA9IGU7XG4gICAgICAgIH1cblxuICAgICAgICB0aGlzLmh1bGwgPSBuZXcgVWludDMyQXJyYXkoaHVsbFNpemUpO1xuICAgICAgICBmb3IgKGxldCBpID0gMCwgZSA9IHRoaXMuX2h1bGxTdGFydDsgaSA8IGh1bGxTaXplOyBpKyspIHtcbiAgICAgICAgICAgIHRoaXMuaHVsbFtpXSA9IGU7XG4gICAgICAgICAgICBlID0gaHVsbE5leHRbZV07XG4gICAgICAgIH1cblxuICAgICAgICAvLyB0cmltIHR5cGVkIHRyaWFuZ2xlIG1lc2ggYXJyYXlzXG4gICAgICAgIHRoaXMudHJpYW5nbGVzID0gdGhpcy5fdHJpYW5nbGVzLnN1YmFycmF5KDAsIHRoaXMudHJpYW5nbGVzTGVuKTtcbiAgICAgICAgdGhpcy5oYWxmZWRnZXMgPSB0aGlzLl9oYWxmZWRnZXMuc3ViYXJyYXkoMCwgdGhpcy50cmlhbmdsZXNMZW4pO1xuICAgIH1cblxuICAgIF9oYXNoS2V5KHgsIHkpIHtcbiAgICAgICAgcmV0dXJuIE1hdGguZmxvb3IocHNldWRvQW5nbGUoeCAtIHRoaXMuX2N4LCB5IC0gdGhpcy5fY3kpICogdGhpcy5faGFzaFNpemUpICUgdGhpcy5faGFzaFNpemU7XG4gICAgfVxuXG4gICAgX2xlZ2FsaXplKGEpIHtcbiAgICAgICAgY29uc3Qge190cmlhbmdsZXM6IHRyaWFuZ2xlcywgX2hhbGZlZGdlczogaGFsZmVkZ2VzLCBjb29yZHN9ID0gdGhpcztcblxuICAgICAgICBsZXQgaSA9IDA7XG4gICAgICAgIGxldCBhciA9IDA7XG5cbiAgICAgICAgLy8gcmVjdXJzaW9uIGVsaW1pbmF0ZWQgd2l0aCBhIGZpeGVkLXNpemUgc3RhY2tcbiAgICAgICAgd2hpbGUgKHRydWUpIHtcbiAgICAgICAgICAgIGNvbnN0IGIgPSBoYWxmZWRnZXNbYV07XG5cbiAgICAgICAgICAgIC8qIGlmIHRoZSBwYWlyIG9mIHRyaWFuZ2xlcyBkb2Vzbid0IHNhdGlzZnkgdGhlIERlbGF1bmF5IGNvbmRpdGlvblxuICAgICAgICAgICAgICogKHAxIGlzIGluc2lkZSB0aGUgY2lyY3VtY2lyY2xlIG9mIFtwMCwgcGwsIHByXSksIGZsaXAgdGhlbSxcbiAgICAgICAgICAgICAqIHRoZW4gZG8gdGhlIHNhbWUgY2hlY2svZmxpcCByZWN1cnNpdmVseSBmb3IgdGhlIG5ldyBwYWlyIG9mIHRyaWFuZ2xlc1xuICAgICAgICAgICAgICpcbiAgICAgICAgICAgICAqICAgICAgICAgICBwbCAgICAgICAgICAgICAgICAgICAgcGxcbiAgICAgICAgICAgICAqICAgICAgICAgIC98fFxcICAgICAgICAgICAgICAgICAgLyAgXFxcbiAgICAgICAgICAgICAqICAgICAgIGFsLyB8fCBcXGJsICAgICAgICAgICAgYWwvICAgIFxcYVxuICAgICAgICAgICAgICogICAgICAgIC8gIHx8ICBcXCAgICAgICAgICAgICAgLyAgICAgIFxcXG4gICAgICAgICAgICAgKiAgICAgICAvICBhfHxiICBcXCAgICBmbGlwICAgIC9fX19hcl9fX1xcXG4gICAgICAgICAgICAgKiAgICAgcDBcXCAgIHx8ICAgL3AxICAgPT4gICBwMFxcLS0tYmwtLS0vcDFcbiAgICAgICAgICAgICAqICAgICAgICBcXCAgfHwgIC8gICAgICAgICAgICAgIFxcICAgICAgL1xuICAgICAgICAgICAgICogICAgICAgYXJcXCB8fCAvYnIgICAgICAgICAgICAgYlxcICAgIC9iclxuICAgICAgICAgICAgICogICAgICAgICAgXFx8fC8gICAgICAgICAgICAgICAgICBcXCAgL1xuICAgICAgICAgICAgICogICAgICAgICAgIHByICAgICAgICAgICAgICAgICAgICBwclxuICAgICAgICAgICAgICovXG4gICAgICAgICAgICBjb25zdCBhMCA9IGEgLSBhICUgMztcbiAgICAgICAgICAgIGFyID0gYTAgKyAoYSArIDIpICUgMztcblxuICAgICAgICAgICAgaWYgKGIgPT09IC0xKSB7IC8vIGNvbnZleCBodWxsIGVkZ2VcbiAgICAgICAgICAgICAgICBpZiAoaSA9PT0gMCkgYnJlYWs7XG4gICAgICAgICAgICAgICAgYSA9IEVER0VfU1RBQ0tbLS1pXTtcbiAgICAgICAgICAgICAgICBjb250aW51ZTtcbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgY29uc3QgYjAgPSBiIC0gYiAlIDM7XG4gICAgICAgICAgICBjb25zdCBhbCA9IGEwICsgKGEgKyAxKSAlIDM7XG4gICAgICAgICAgICBjb25zdCBibCA9IGIwICsgKGIgKyAyKSAlIDM7XG5cbiAgICAgICAgICAgIGNvbnN0IHAwID0gdHJpYW5nbGVzW2FyXTtcbiAgICAgICAgICAgIGNvbnN0IHByID0gdHJpYW5nbGVzW2FdO1xuICAgICAgICAgICAgY29uc3QgcGwgPSB0cmlhbmdsZXNbYWxdO1xuICAgICAgICAgICAgY29uc3QgcDEgPSB0cmlhbmdsZXNbYmxdO1xuXG4gICAgICAgICAgICBjb25zdCBpbGxlZ2FsID0gaW5DaXJjbGUoXG4gICAgICAgICAgICAgICAgY29vcmRzWzIgKiBwMF0sIGNvb3Jkc1syICogcDAgKyAxXSxcbiAgICAgICAgICAgICAgICBjb29yZHNbMiAqIHByXSwgY29vcmRzWzIgKiBwciArIDFdLFxuICAgICAgICAgICAgICAgIGNvb3Jkc1syICogcGxdLCBjb29yZHNbMiAqIHBsICsgMV0sXG4gICAgICAgICAgICAgICAgY29vcmRzWzIgKiBwMV0sIGNvb3Jkc1syICogcDEgKyAxXSk7XG5cbiAgICAgICAgICAgIGlmIChpbGxlZ2FsKSB7XG4gICAgICAgICAgICAgICAgdHJpYW5nbGVzW2FdID0gcDE7XG4gICAgICAgICAgICAgICAgdHJpYW5nbGVzW2JdID0gcDA7XG5cbiAgICAgICAgICAgICAgICBjb25zdCBoYmwgPSBoYWxmZWRnZXNbYmxdO1xuXG4gICAgICAgICAgICAgICAgLy8gZWRnZSBzd2FwcGVkIG9uIHRoZSBvdGhlciBzaWRlIG9mIHRoZSBodWxsIChyYXJlKTsgZml4IHRoZSBoYWxmZWRnZSByZWZlcmVuY2VcbiAgICAgICAgICAgICAgICBpZiAoaGJsID09PSAtMSkge1xuICAgICAgICAgICAgICAgICAgICBsZXQgZSA9IHRoaXMuX2h1bGxTdGFydDtcbiAgICAgICAgICAgICAgICAgICAgZG8ge1xuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuX2h1bGxUcmlbZV0gPT09IGJsKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5faHVsbFRyaVtlXSA9IGE7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgICAgICBlID0gdGhpcy5faHVsbFByZXZbZV07XG4gICAgICAgICAgICAgICAgICAgIH0gd2hpbGUgKGUgIT09IHRoaXMuX2h1bGxTdGFydCk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIHRoaXMuX2xpbmsoYSwgaGJsKTtcbiAgICAgICAgICAgICAgICB0aGlzLl9saW5rKGIsIGhhbGZlZGdlc1thcl0pO1xuICAgICAgICAgICAgICAgIHRoaXMuX2xpbmsoYXIsIGJsKTtcblxuICAgICAgICAgICAgICAgIGNvbnN0IGJyID0gYjAgKyAoYiArIDEpICUgMztcblxuICAgICAgICAgICAgICAgIC8vIGRvbid0IHdvcnJ5IGFib3V0IGhpdHRpbmcgdGhlIGNhcDogaXQgY2FuIG9ubHkgaGFwcGVuIG9uIGV4dHJlbWVseSBkZWdlbmVyYXRlIGlucHV0XG4gICAgICAgICAgICAgICAgaWYgKGkgPCBFREdFX1NUQUNLLmxlbmd0aCkge1xuICAgICAgICAgICAgICAgICAgICBFREdFX1NUQUNLW2krK10gPSBicjtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgIGlmIChpID09PSAwKSBicmVhaztcbiAgICAgICAgICAgICAgICBhID0gRURHRV9TVEFDS1stLWldO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG5cbiAgICAgICAgcmV0dXJuIGFyO1xuICAgIH1cblxuICAgIF9saW5rKGEsIGIpIHtcbiAgICAgICAgdGhpcy5faGFsZmVkZ2VzW2FdID0gYjtcbiAgICAgICAgaWYgKGIgIT09IC0xKSB0aGlzLl9oYWxmZWRnZXNbYl0gPSBhO1xuICAgIH1cblxuICAgIC8vIGFkZCBhIG5ldyB0cmlhbmdsZSBnaXZlbiB2ZXJ0ZXggaW5kaWNlcyBhbmQgYWRqYWNlbnQgaGFsZi1lZGdlIGlkc1xuICAgIF9hZGRUcmlhbmdsZShpMCwgaTEsIGkyLCBhLCBiLCBjKSB7XG4gICAgICAgIGNvbnN0IHQgPSB0aGlzLnRyaWFuZ2xlc0xlbjtcblxuICAgICAgICB0aGlzLl90cmlhbmdsZXNbdF0gPSBpMDtcbiAgIC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25vZGUuaW5kZXhdLCByaTIgPSByaSAqIHJpO1xuICAgICAgICB4aSA9IG5vZGUueCArIG5vZGUudng7XG4gICAgICAgIHlpID0gbm9kZS55ICsgbm9kZS52eTtcbiAgICAgICAgdHJlZS52aXNpdChhcHBseSk7XG4gICAgICB9XG4gICAgfVxuXG4gICAgZnVuY3Rpb24gYXBwbHkocXVhZCwgeDAsIHkwLCB4MSwgeTEpIHtcbiAgICAgIHZhciBkYXRhID0gcXVhZC5kYXRhLCByaiA9IHF1YWQuciwgciA9IHJpICsgcmo7XG4gICAgICBpZiAoZGF0YSkge1xuICAgICAgICBpZiAoZGF0YS5pbmRleCA+IG5vZGUuaW5kZXgpIHtcbiAgICAgICAgICB2YXIgeCA9IHhpIC0gZGF0YS54IC0gZGF0YS52eCxcbiAgICAgICAgICAgICAgeSA9IHlpIC0gZGF0YS55IC0gZGF0YS52eSxcbiAgICAgICAgICAgICAgbCA9IHggKiB4ICsgeSAqIHk7XG4gICAgICAgICAgaWYgKGwgPCByICogcikge1xuICAgICAgICAgICAgaWYgKHggPT09IDApIHggPSBqaWdnbGUocmFuZG9tKSwgbCArPSB4ICogeDtcbiAgICAgICAgICAgIGlmICh5ID09PSAwKSB5ID0gamlnZ2xlKHJhbmRvbSksIGwgKz0geSAqIHk7XG4gICAgICAgICAgICBsID0gKHIgLSAobCA9IE1hdGguc3FydChsKSkpIC8gbCAqIHN0cmVuZ3RoO1xuICAgICAgICAgICAgbm9kZS52eCArPSAoeCAqPSBsKSAqIChyID0gKHJqICo9IHJqKSAvIChyaTIgKyByaikpO1xuICAgICAgICAgICAgbm9kZS52eSArPSAoeSAqPSBsKSAqIHI7XG4gICAgICAgICAgICBkYXRhLnZ4IC09IHggKiAociA9IDEgLSByKTtcbiAgICAgICAgICAgIGRhdGEudnkgLT0geSAqIHI7XG4gICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICAgIHJldHVybjtcbiAgICAgIH1cbiAgICAgIHJldHVybiB4MCA+IHhpICsgciB8f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mICghKG0gPSAocmluZyA9IHBvbHlnb25baV0pLmxlbmd0aCkpIGNvbnRpbnVlO1xuICAgIHZhciByaW5nLFxuICAgICAgICBtLFxuICAgICAgICBwb2ludDAgPSByaW5nW20gLSAxXSxcbiAgICAgICAgbGFtYmRhMCA9IGxvbmdpdHVkZShwb2ludDApLFxuICAgICAgICBwaGkwID0gcG9pbnQwWzFdIC8gMiArIHF1YXJ0ZXJQaSxcbiAgICAgICAgc2luUGhpMCA9IHNpbiQxKHBoaTApLFxuICAgICAgICBjb3NQaGkwID0gY29zJDEocGhpMCk7XG5cbiAgICBmb3IgKHZhciBqID0gMDsgaiA8IG07ICsraiwgbGFtYmRhMCA9IGxhbWJkYTEsIHNpblBoaTAgPSBzaW5QaGkxLCBjb3NQaGkwID0gY29zUGhpMSwgcG9pbnQwID0gcG9pbnQxKSB7XG4gICAgICB2YXIgcG9pbnQxID0gcmluZ1tqXSxcbiAgICAgICAgICBsYW1iZGExID0gbG9uZ2l0dWRlKHBvaW50MSksXG4gICAgICAgICAgcGhpMSA9IHBvaW50MVsxXSAvIDIgKyBxdWFydGVyUGksXG4gICAgICAgICAgc2luUGhpMSA9IHNpbiQxKHBoaTEpLFxuICAgICAgICAgIGNvc1BoaTEgPSBjb3MkMShwaGkxKSxcbiAgICAgICAgICBkZWx0YSA9IGxhbWJkYTEgLSBsYW1iZGEwLFxuICAgICAgICAgIHNpZ24gPSBkZWx0YSA+PSAwID8gMSA6IC0xLFxuICAgICAgICAgIGFic0RlbHRhID0gc2lnbiAqIGRlbHRhLFxuICAgICAgICAgIGFudGltZXJpZGlhbiA9IGFic0RlbHRhID4gcGkkMSxcbiAgICAgICAgICBrID0gc2luUGhpMCAqIHNpblBoaTE7XG5cbiAgICAgIHN1bS5hZGQoYXRhbjIkMShrICogc2lnbiAqIHNpbiQxKGFic0RlbHRhKSwgY29zUGhpMCAqIGNvc1BoaTEgKyBrICogY29zJDEoYWJzRGVsdGEpKSk7XG4gICAgICBhbmdsZSArPSBh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GZ1bmN0aW9uIHJpbmdTdGFydCgpIHtcbiAgICAgIHJpbmdTaW5rLmxpbmVTdGFydCgpO1xuICAgICAgcmluZyA9IFtdO1xuICAgIH1cblxuICAgIGZ1bmN0aW9uIHJpbmdFbmQoKSB7XG4gICAgICBwb2ludFJpbmcocmluZ1swXVswXSwgcmluZ1swXVsxXSk7XG4gICAgICByaW5nU2luay5saW5lRW5kKCk7XG5cbiAgICAgIHZhciBjbGVhbiA9IHJpbmdTaW5rLmNsZWFuKCksXG4gICAgICAgICAgcmluZ1NlZ21lbnRzID0gcmluZ0J1ZmZlci5yZXN1bHQoKSxcbiAgICAgICAgICBpLCBuID0gcmluZ1NlZ21lbnRzLmxlbmd0aCwgbSxcbiAgICAgICAgICBzZWdtZW50LFxuICAgICAgICAgIHBvaW50O1xuXG4gICAgICByaW5nLnBvcCgpO1xuICAgICAgcG9seWdvbi5wdXNoKHJpbmcpO1xuICAgICAgcmluZyA9IG51bGw7XG5cbiAgICAgIGlmICghbikgcmV0dXJuO1xuXG4gICAgICAvLyBObyBpbnRlcnNlY3Rpb25zLlxuICAgICAgaWYgKGNsZWFuICYgMSkge1xuICAgICAgICBzZWdtZW50ID0gcmluZ1NlZ21lbnRzWzBdO1xuICAgICAgICBpZiAoKG0gPSBzZWdtZW50Lmxlbmd0aCAtIDEpID4gMCkge1xuICAgICAgICAgIGlmICghcG9seWdvblN0YXJ0ZWQpIHNpbmsucG9seWdvblN0YXJ0KCksIHBvbHlnb25TdGFydGVkID0gdHJ1ZTtcbiAgICAgICAgICBzaW5rLmxpbmVTdGFydCgpO1xuICAgICAgICAgIGZvciAoaSA9IDA7IGkgPCBtOyArK2kpIHNpbmsucG9pbnQoKHBvaW50ID0gc2VnbWVudFtpXSlbMF0sIHBvaW50WzFdKTtcbiAgICAgICAgICBzaW5rLmxpbmVFbmQoKTtcbiAgICAgICAgfVxuICAgICAgICByZXR1cm47XG4gICAgICB9XG5cbiAgICAgIC8vIFJlam9pbiBjb25uZWN0ZW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WJkYSA8IDAgPyBwaSQxIDogLXBpJDEpLCBwaGkpIDogMDtcbiAgICAgICAgaWYgKCFwb2ludDAgJiYgKHYwMCA9IHYwID0gdikpIHN0cmVhbS5saW5lU3RhcnQoKTtcbiAgICAgICAgaWYgKHYgIT09IHYwKSB7XG4gICAgICAgICAgcG9pbnQyID0gaW50ZXJzZWN0KHBvaW50MCwgcG9pbnQxKTtcbiAgICAgICAgICBpZiAoIXBvaW50MiB8fCBwb2ludEVxdWFsKHBvaW50MCwgcG9pbnQyKSB8fCBwb2ludEVxdWFsKHBvaW50MSwgcG9pbnQyKSlcbiAgICAgICAgICAgIHBvaW50MVsyXSA9IDE7XG4gICAgICAgIH1cbiAgICAgICAgaWYgKHYgIT09IHYwKSB7XG4gICAgICAgICAgY2xlYW4gPSAwO1xuICAgICAgICAgIGlmICh2KSB7XG4gICAgICAgICAgICAvLyBvdXRzaWRlIGdvaW5nIGluXG4gICAgICAgICAgICBzdHJlYW0ubGluZVN0YXJ0KCk7XG4gICAgICAgICAgICBwb2ludDIgPSBpbnRlcnNlY3QocG9pbnQxLCBwb2ludDApO1xuICAgICAgICAgICAgc3RyZWFtLnBvaW50KHBvaW50MlswXSwgcG9pbnQyWzFdKTtcbiAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgLy8gaW5zaWRlIGdvaW5nIG91dFxuICAgICAgICAgICAgcG9pbnQyID0gaW50ZXJzZWN0KHBvaW50MCwgcG9pbnQxKTtcbiAgICAgICAgICAgIHN0cmVhbS5wb2ludChwb2ludDJbMF0sIHBvaW50MlsxXSwgMik7XG4gICAgICAgICAgICBzdHJlYW0ubGluZUVuZCgpO1xuICAgICAgICAgIH1cbiAgICAgICAgICBwb2ludDAgPSBwb2ludDI7XG4gICAgICAgIH0gZWxzZSBpZiAobm90SGVtaXNwaGVyZSAmJiBwb2ludDAgJiYgc21hbGxSYWRpdXMgXiB2KSB7XG4gICAgICAgICAgdmFyIHQ7XG4gICAgICAgICAgLy8gSWYgdGhlIGNvZGVzIGZvciB0d28gcG9pbnRzIGFyZSBkaWZmZXJlbnQsIG9yIGFyZSBib3RoIHplcm8sXG4gICAgICAgICAgLy8gYW5kIHRoZXJlIHRoaXMgc2VnbWVudCBpbnRlcnNlY3RzIHdpdGggdGhlIHNtYWxsIGNpcmNsZS5cbiAgICAgICAgICBpZiAoIShjICYgYzApICYmICh0ID0gaW50ZXJzZWN0KHBvaW50MSwgcG9pbnQwLCB0cnVlKSkpIHtcbiAgICAgICAgICAgIGNsZWFuID0gMDtcbiAgICAgICAgICAgIGlmIChzbWFsbFJhZGl1cykge1xuICAgICAgICAgICAgICBzdHJlYW0ubGluZVN0YXJ0KCk7XG4gICAgICAgICAgICAgIHN0cmVhbS5wb2ludCh0WzBdWzBdLCB0WzBdWzFdKTtcbiAgICAgICAgICAgICAgc3RyZWFtLnBvaW50KHRbMV1bMF0sIHRbMV1bMV0pO1xuICAgICAgICAgICAgICBzdHJlYW0ubGluZUVuZCgpO1xuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgc3RyZWFtLnBvaW50KHRbMV1bMF0sIHRbMV1bMV0pO1xuICAgICAgICAgICAgICBzdHJlYW0ubGluZUVuZCgpO1xuICAgICAgICAgICAgICBzdHJlYW0ubGluZVN0YXJ0KCk7XG4gICAgICAgICAgICAgIHN0cmVhbS5wb2ludCh0WzBdWzBdLCB0WzBdWzFdLCAzKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgICAgaWYgKHYgJiYgKCFwb2ludDAgfHwgIXBvaW50RXF1YWwocG9pbnQwLCBwb2ludDEpKSkge1xuICAgICAgICAgIHN0cmVhbS5wb2ludChwb2ludDFbMF0sIHBvaW50MVsxXSk7XG4gICAgICAgIH1cbiAgICAgICAgcG9pbnQwID0gcG9pbnQxLCB2MCA9IHYsIGMwID0gYztcbiAgICAgIH0sXG4gICAgICBsaW5lRW5kOiBmdW5jdGlvbigpIHtcbiAgICAgICAg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TEpIDwgZXBzaWxvblxuICB9XG5cbiAgZnVuY3Rpb24gY29tcGFyZUludGVyc2VjdGlvbihhLCBiKSB7XG4gICAgcmV0dXJuIGNvbXBhcmVQb2ludChhLngsIGIueCk7XG4gIH1cblxuICBmdW5jdGlvbiBjb21wYXJlUG9pbnQoYSwgYikge1xuICAgIHZhciBjYSA9IGNvcm5lcihhLCAxKSxcbiAgICAgICAgY2IgPSBjb3JuZXIoYiwgMSk7XG4gICAgcmV0dXJuIGNhICE9PSBjYiA/IGNhIC0gY2JcbiAgICAgICAgOiBjYSA9PT0gMCA/IGJbMV0gLSBhWzFdXG4gICAgICAgIDogY2EgPT09IDEgPyBhWzBdIC0gYlswXVxuICAgICAgICA6IGNhID09PSAyID8gYVsxXSAtIGJbMV1cbiAgICAgICAgOiBiWzBdIC0gYVswXTtcbiAgfVxuXG4gIHJldHVybiBmdW5jdGlvbihzdHJlYW0pIHtcbiAgICB2YXIgYWN0aXZlU3RyZWFtID0gc3RyZWFtLFxuICAgICAgICBidWZmZXJTdHJlYW0gPSBjbGlwQnVmZmVyKCksXG4gICAgICAgIHNlZ21lbnRzLFxuICAgICAgICBwb2x5Z29uLFxuICAgICAgICByaW5nLFxuICAgICAgICB4X18sIHlfXywgdl9fLCAvLyBmaXJzdCBwb2ludFxuICAgICAgICB4XywgeV8sIHZfLCAvLyBwcmV2aW91cyBwb2ludFxuICAgICAgICBmaXJzdCxcbiAgICAgICAgY2xlYW47XG5cbiAgICB2YXIgY2xpcFN0cmVhbSA9IHtcbiAgICAgIHBvaW50OiBwb2ludCxcbiAgICAgIGxpbmVTdGFydDogbGluZVN0YXJ0LFxuICAgICAgbGluZUVuZDogbGluZUVuZCxcbiAgICAgIHBvbHlnb25TdGFydDogcG9seWdvblN0YXJ0LFxuICAgICAgcG9seWdvbkVuZDogcG9seWdvbkVuZFxuICAgIH07XG5cbiAgICBmdW5jdGlvbiBwb2ludCh4LCB5KSB7XG4gICAgICBpZiAodmlzaWJsZSh4LCB5KS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GgubWF4KGNsaXBNaW4sIE1hdGgubWluKGNsaXBNYXgsIHlfKSldLFxuICAgICAgICAgICAgICBiID0gW3ggPSBNYXRoLm1heChjbGlwTWluLCBNYXRoLm1pbihjbGlwTWF4LCB4KSksIHkgPSBNYXRoLm1heChjbGlwTWluLCBNYXRoLm1pbihjbGlwTWF4LCB5KSldO1xuICAgICAgICAgIGlmIChjbGlwTGluZShhLCBiLCB4MCwgeTAsIHgxLCB5MSkpIHtcbiAgICAgICAgICAgIGlmICghdl8pIHtcbiAgICAgICAgICAgICAgYWN0aXZlU3RyZWFtLmxpbmVTdGFydCgpO1xuICAgICAgICAgICAgICBhY3RpdmVTdHJlYW0ucG9pbnQoYVswXSwgYVsxXSk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBhY3RpdmVTdHJlYW0ucG9pbnQoYlswXSwgYlsxXSk7XG4gICAgICAgICAgICBpZiAoIXYpIGFjdGl2ZVN0cmVhbS5saW5lRW5kKCk7XG4gICAgICAgICAgICBjbGVhbiA9IGZhbHNlO1xuICAgICAgICAgIH0gZWxzZSBpZiAodikge1xuICAgICAgICAgICAgYWN0aXZlU3RyZWFtLmxpbmVTdGFydCgpO1xuICAgICAgICAgICAgYWN0aXZlU3RyZWFtLnBvaW50KHgsIHkpO1xuICAgICAgICAgICAgY2xlYW4gPSBmYWxzZTtcbiAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgIH1cbiAgICAgIHhfID0geCwgeV8gPSB5LCB2XyA9IHY7XG4gICAgfVxuXG4gICAgcmV0dXJuIGNsaXBTdHJlYW07XG4gIH07XG59XG5cbmZ1bmN0aW9uIGV4dGVudCgpIHtcbiAgdmFyIHgwID0gMCxcbiAgICAgIHkwID0gMCxcbiAgICAgIHgxID0gOTYwLFxuICAgICAgeTEgPSA1MDAsXG4gICAgICBjYWNoZSxcbiAgICAgIGNhY2hlU3RyZWFtLFxuICAgICAgY2xpcDtcblxuICByZXR1cm4gY2xpcCA9IHtcbiAgICBzdHJlYW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iAgICBpZiAoIWFyZ3VtZW50cy5sZW5ndGgpIHJldHVybiBwcmVjaXNpb247XG4gICAgcHJlY2lzaW9uID0gK187XG4gICAgeCA9IGdyYXRpY3VsZVgoeTAsIHkxLCA5MCk7XG4gICAgeSA9IGdyYXRpY3VsZVkoeDAsIHgxLCBwcmVjaXNpb24pO1xuICAgIFggPSBncmF0aWN1bGVYKFkwLCBZMSwgOTApO1xuICAgIFkgPSBncmF0aWN1bGVZKFgwLCBYMSwgcHJlY2lzaW9uKTtcbiAgICByZXR1cm4gZ3JhdGljdWxlO1xuICB9O1xuXG4gIHJldHVybiBncmF0aWN1bGVcbiAgICAgIC5leHRlbnRNYWpvcihbWy0xODAsIC05MCArIGVwc2lsb24kMV0sIFsxODAsIDkwIC0gZXBzaWxvbiQxXV0pXG4gICAgICAuZXh0ZW50TWlub3IoW1stMTgwLCAtODAgLSBlcHNpbG9uJDFdLCBbMTgwLCA4MCArIGVwc2lsb24kMV1dKTtcbn1cblxuZnVuY3Rpb24gZ3JhdGljdWxlMTAoKSB7XG4gIHJldHVybiBncmF0aWN1bGUoKSgpO1xufVxuXG5mdW5jdGlvbiBpbnRlcnBvbGF0ZShhLCBiKSB7XG4gIHZhciB4MCA9IGFbMF0gKiByYWRpYW5zLFxuICAgICAgeTAgPSBhWzFdICogcmFkaWFucyxcbiAgICAgIHgxID0gYlswXSAqIHJhZGlhbnMsXG4gICAgICB5MSA9IGJbMV0gKiByYWRpYW5zLFxuICAgICAgY3kwID0gY29zJDEoeTApLFxuICAgICAgc3kwID0gc2luJDEoeTApLFxuICAgICAgY3kxID0gY29zJDEoeTEpLFxuICAgICAgc3kxID0gc2luJDEoeTEpLFxuICAgICAga3gwID0gY3kwICogY29zJDEoeDApLFxuICAgICAga3kwID0gY3kwICogc2luJDEoeDApLFxuICAgICAga3gxID0gY3kxICogY29zJDEoeDEpLFxuICAgICAga3kxID0gY3kxICogc2luJDEoeDEpLFxuICAgICAgZCA9IDIgKiBhc2luJDEoc3FydC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gICAgYTMgPSB4MSAtIHgzLFxuICAgICAgYjIgPSB5MSAtIHkyLFxuICAgICAgYjMgPSB5MSAtIHkzLFxuICAgICAgYzIgPSByMiAtIHIxLFxuICAgICAgYzMgPSByMyAtIHIxLFxuICAgICAgZDEgPSB4MSAqIHgxICsgeTEgKiB5MSAtIHIxICogcjEsXG4gICAgICBkMiA9IGQxIC0geDIgKiB4MiAtIHkyICogeTIgKyByMiAqIHIyLFxuICAgICAgZDMgPSBkMSAtIHgzICogeDMgLSB5MyAqIHkzICsgcjMgKiByMyxcbiAgICAgIGFiID0gYTMgKiBiMiAtIGEyICogYjMsXG4gICAgICB4YSA9IChiMiAqIGQzIC0gYjMgKiBkMikgLyAoYWIgKiAyKSAtIHgxLFxuICAgICAgeGIgPSAoYjMgKiBjMiAtIGIyICogYzMpIC8gYWIsXG4gICAgICB5YSA9IChhMyAqIGQyIC0gYTIgKiBkMykgLyAoYWIgKiAyKSAtIHkxLFxuICAgICAgeWIgPSAoYTIgKiBjMyAtIGEzICogYzIpIC8gYWIsXG4gICAgICBBID0geGIgKiB4YiArIHliICogeWIgLSAxLFxuICAgICAgQiA9IDIgKiAocjEgKyB4YSAqIHhiICsgeWEgKiB5YiksXG4gICAgICBDID0geGEgKiB4YSArIHlhICogeWEgLSByMSAqIHIxLFxuICAgICAgciA9IC0oQSA/IChCICsgTWF0aC5zcXJ0KEIgKiBCIC0gNCAqIEEgKiBDKSkgLyAoMiAqIEEpIDogQyAvIEIpO1xuICByZXR1cm4ge1xuICAgIHg6IHgxICsgeGEgKyB4YiAqIHIsXG4gICAgeTogeTEgKyB5YSArIHliICogcixcbiAgICByOiByXG4gIH07XG59XG5cbmZ1bmN0aW9uIHBsYWNlKGIsIGEsIGMpIHtcbiAgdmFyIGR4ID0gYi54IC0gYS54LCB4LCBhMixcbiAgICAgIGR5ID0gYi55IC0gYS55LCB5LCBiMixcbiAgICAgIGQyID0gZHggKiBkeCArIGR5ICogZHk7XG4gIGlmIChkMikge1xuICAg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Bub2RlLFxuICAgICAgICBub2RlSWQsXG4gICAgICAgIG5vZGVLZXksXG4gICAgICAgIG5vZGVCeUtleSA9IG5ldyBNYXA7XG5cbiAgICBpZiAocGF0aCAhPSBudWxsKSB7XG4gICAgICBjb25zdCBJID0gbm9kZXMubWFwKChkLCBpKSA9PiBub3JtYWxpemUkMShwYXRoKGQsIGksIGRhdGEpKSk7XG4gICAgICBjb25zdCBQID0gSS5tYXAocGFyZW50b2YpO1xuICAgICAgY29uc3QgUyA9IG5ldyBTZXQoSSkuYWRkKFwiXCIpO1xuICAgICAgZm9yIChjb25zdCBpIG9mIFApIHtcbiAgICAgICAgaWYgKCFTLmhhcyhpKSkge1xuICAgICAgICAgIFMuYWRkKGkpO1xuICAgICAgICAgIEkucHVzaChpKTtcbiAgICAgICAgICBQLnB1c2gocGFyZW50b2YoaSkpO1xuICAgICAgICAgIG5vZGVzLnB1c2goaW1wdXRlZCk7XG4gICAgICAgIH1cbiAgICAgIH1cbiAgICAgIGN1cnJlbnRJZCA9IChfLCBpKSA9PiBJW2ldO1xuICAgICAgY3VycmVudFBhcmVudElkID0gKF8sIGkpID0+IFBbaV07XG4gICAgfVxuXG4gICAgZm9yIChpID0gMCwgbiA9IG5vZGVzLmxlbmd0aDsgaSA8IG47ICsraSkge1xuICAgICAgZCA9IG5vZGVzW2ldLCBub2RlID0gbm9kZXNbaV0gPSBuZXcgTm9kZSQxKGQpO1xuICAgICAgaWYgKChub2RlSWQgPSBjdXJyZW50SWQoZCwgaSwgZGF0YSkpICE9IG51bGwgJiYgKG5vZGVJZCArPSBcIlwiKSkge1xuICAgICAgICBub2RlS2V5ID0gbm9kZS5pZCA9IG5vZGVJZDtcbiAgICAgICAgbm9kZUJ5S2V5LnNldChub2RlS2V5LCBub2RlQnlLZXkuaGFzKG5vZGVLZXkpID8gYW1iaWd1b3VzIDogbm9kZSk7XG4gICAgICB9XG4gICAgICBpZiAoKG5vZGVJZCA9IGN1cnJlbnRQYXJlbnRJZChkLCBpLC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dzKGkpO1xuICAgICAgICAgIGlmICh0IDwgdSkgY29udGludWU7XG4gICAgICAgICAgaWYgKHQgPiB2KSBicmVhaztcbiAgICAgICAgICB6LnB1c2godCk7XG4gICAgICAgIH1cbiAgICAgIH0gZWxzZSBmb3IgKDsgaSA8PSBqOyArK2kpIHtcbiAgICAgICAgZm9yIChrID0gYmFzZSAtIDE7IGsgPj0gMTsgLS1rKSB7XG4gICAgICAgICAgdCA9IGkgPiAwID8gayAvIHBvd3MoLWkpIDogayAqIHBvd3MoaSk7XG4gICAgICAgICAgaWYgKHQgPCB1KSBjb250aW51ZTtcbiAgICAgICAgICBpZiAodCA+IHYpIGJyZWFrO1xuICAgICAgICAgIHoucHVzaCh0KTtcbiAgICAgICAgfVxuICAgICAgfVxuICAgICAgaWYgKHoubGVuZ3RoICogMiA8IG4pIHogPSB0aWNrcyh1LCB2LCBuKTtcbiAgICB9IGVsc2Uge1xuICAgICAgeiA9IHRpY2tzKGksIGosIE1hdGgubWluKGogLSBpLCBuKSkubWFwKHBvd3MpO1xuICAgIH1cbiAgICByZXR1cm4gciA/IHoucmV2ZXJzZSgpIDogejtcbiAgfTtcblxuICBzY2FsZS50aWNrRm9ybWF0ID0gKGNvdW50LCBzcGVjaWZpZXIpID0+IHtcbiAgICBpZiAoY291bnQgPT0gbnVsbCkgY291bnQgPSAxMDtcbiAgICBpZiAoc3BlY2lmaWVyID09IG51bGwpIHNwZWNpZmllciA9IGJhc2UgPT09IDEwID8gXCJzXCIgOiBcIixcIjtcbiAgICBpZiAodHlwZW9mIHNwZWNpZmllciAhPT0gXCJmdW5jdGlvblwiKSB7XG4gICAgICBpZiAoIShiYXNlICUgMSkgJiYgKHNwZWNpZmllciA9IGZvcm1hdFNwZWNpZmllcihzcGVjaWZpZXIpKS5wcmVjaXNpb24gPT0gbnVsbCkgc3BlY2lmaWVyLnRyaW0gPSB0cnVlO1xuICAgICAgc3BlY2lmaWVyID0gZXhwb3J0cy5mb3JtYXQoc3BlY2lmaWVy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FxuICAgICAgICAgIGExMCA9IGExLFxuICAgICAgICAgIGRhMCA9IGRhLFxuICAgICAgICAgIGRhMSA9IGRhLFxuICAgICAgICAgIGFwID0gcGFkQW5nbGUuYXBwbHkodGhpcywgYXJndW1lbnRzKSAvIDIsXG4gICAgICAgICAgcnAgPSAoYXAgPiBlcHNpbG9uKSAmJiAocGFkUmFkaXVzID8gK3BhZFJhZGl1cy5hcHBseSh0aGlzLCBhcmd1bWVudHMpIDogc3FydChyMCAqIHIwICsgcjEgKiByMSkpLFxuICAgICAgICAgIHJjID0gbWluKGFicyhyMSAtIHIwKSAvIDIsICtjb3JuZXJSYWRpdXMuYXBwbHkodGhpcywgYXJndW1lbnRzKSksXG4gICAgICAgICAgcmMwID0gcmMsXG4gICAgICAgICAgcmMxID0gcmMsXG4gICAgICAgICAgdDAsXG4gICAgICAgICAgdDE7XG5cbiAgICAgIC8vIEFwcGx5IHBhZGRpbmc/IE5vdGUgdGhhdCBzaW5jZSByMSDiiaUgcjAsIGRhMSDiiaUgZGEwLlxuICAgICAgaWYgKHJwID4gZXBzaWxvbikge1xuICAgICAgICB2YXIgcDAgPSBhc2luKHJwIC8gcjAgKiBzaW4oYXApKSxcbiAgICAgICAgICAgIHAxID0gYXNpbihycCAvIHIxICogc2luKGFwKSk7XG4gICAgICAgIGlmICgoZGEwIC09IHAwICogMikgPiBlcHNpbG9uKSBwMCAqPSAoY3cgPyAxIDogLTEpLCBhMDAgKz0gcDAsIGExMCAtPSBwMDtcbiAgICAgICAgZWxzZSBkYTAgPSAwLCBhMDAgPSBhMTAgPSAoYTAgKyBhMSkgLyAyO1xuICAgICAgICBpZiAoKGRhMSAtPSBwMSAqIDIpID4gZXBzaWxvbikgcDEgKj0gKGN3ID8gMSA6IC0xKSwgYTAxICs9IHAxLCBhMTEgLT0gcDE7XG4gICAgICAgIGVsc2UgZGExID0gMCwgYTAxID0gYTExID0gKGEwICsgYTEpIC8gMjtcbiAgICAgIH1cblxuICAgICAgdmFyIHgwMSA9IHIxICogY29zKGEwMSksXG4gICAgICAgICAgeTAxID0gcjEgKiBzaW4oYTAxKSxcbiAgICAgICAgICB4MTAgPSByMCAqIGNvcyhhMTApLFxuICAgICAgICAgIHkxMCA9IHIwICogc2luKGExMCk7XG5cbiAgICAgIC8vIEFwcGx5IHJvdW5kZWQgY29ybmVycz9cbiAgICAgIGlmIChyYyA+IGVwc2lsb24pIHtcbiAgICAgICAgdmFyIHgxMSA9IHIxICogY29zKGExMSksXG4gICAgICAgICAgICB5MTEgPSByMSAqIHNpbihhMTEpLFxuICAgICAgICAgICAgeDAwID0gcjAgKiBjb3MoYTAwKSxcbiAgICAgICAgICAgIHkwMCA9IHIwICogc2luKGEwMCksXG4gICAgICAgICAgICBvYztcblxuICAgICAgICAvLyBSZXN0cmljdCB0aGUgY29ybmVyIHJhZGl1cyBhY2NvcmRpbmcgdG8gdGhlIHNlY3RvciBhbmdsZS5cbiAgICAgICAgaWYgKGRhIDwgcGkgJiYgKG9jID0gaW50ZXJzZWN0KHgwMSwgeTAxLCB4MDAsIHkwMCwgeDExLCB5MTEsIHgxMCwgeTEwKSkpIHtcbiAgICAgICAgICB2YXIgYXggPSB4MDEgLSBvY1swXSxcbiAgICAgICAgICAgICAgYXkgPSB5MDEgLSBvY1sxXSxcbiAgICAgICAgICAgICAgYnggPSB4MTEgLSBvY1swXSxcbiAgICAgICAgICAgICAgYnkgPSB5MTEgLSBvY1sxXSxcbiAgICAgICAgICAgICAga2MgPSAxIC8gc2luKGFjb3MoKGF4ICogYnggKyBheSAqIGJ5KSAvIChzcXJ0KGF4ICogYXggKyBheSAqIGF5KSAqIHNxcnQoYnggKiBieCArIGJ5ICogYnkpKSkgLyAyKSxcbiAgICAgICAgICAgICAgbGMgPSBzcXJ0KG9jWzBdICogb2NbMF0gKyBvY1sxXSAqIG9jWzFdKTtcbiAgICAgICAgICByYzAgPSBtaW4ocmMsIChyMCAtIGxjKSAvIChrYyAtIDEpKTtcbiAgICAgICAgICByYzEgPSBta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ICAgICBvdXRwdXQuYXJlYVN0YXJ0KCk7XG4gICAgICAgICAgb3V0cHV0LmxpbmVTdGFydCgpO1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgIG91dHB1dC5saW5lRW5kKCk7XG4gICAgICAgICAgb3V0cHV0LmxpbmVTdGFydCgpO1xuICAgICAgICAgIGZvciAoayA9IGkgLSAxOyBrID49IGo7IC0taykge1xuICAgICAgICAgICAgb3V0cHV0LnBvaW50KHgweltrXSwgeTB6W2tdKTtcbiAgICAgICAgICB9XG4gICAgICAgICAgb3V0cHV0LmxpbmVFbmQoKTtcbiAgICAgICAgICBvdXRwdXQuYXJlYUVuZCgpO1xuICAgICAgICB9XG4gICAgICB9XG4gICAgICBpZiAoZGVmaW5lZDApIHtcbiAgICAgICAgeDB6W2ldID0gK3gwKGQsIGksIGRhdGEpLCB5MHpbaV0gPSAreTAoZCwgaSwgZGF0YSk7XG4gICAgICAgIG91dHB1dC5wb2ludCh4MSA/ICt4MShkLCBpLCBkYXRhKSA6IHgweltpXSwgeTEgPyAreTEoZCwgaSwgZGF0YSkgOiB5MHpbaV0pO1xuICAgICAgfVxuICAgIH1cblxuICAgIGlmIChidWZmZXIpIHJldHVybiBvdXRwdXQgPSBudWxsLCBidWZmZXIgKyBcIlwiIHx8IG51bGw7XG4gIH1cblxuICBmdW5jdGlvbiBhcmVhbGluZSgpIHtcbiAgICByZXR1cm4gbGluZSgpLmRlZmluZWQoZGVmaW5lZCkuY3VydmUoY3VydmUpLmNvbnRleHQoY29udGV4dCk7XG4gIH1cblxuICBhcmVhLnggPSBmdW5jdGlvbihfKSB7XG4gICAgcmV0dXJuIGFyZ3VtZW50cy5sZW5ndGggPyAoeDAgPSB0eXBlb2YgXyA9PT0gXCJmdW5jdGlvblwiID8gXyA6IGNvbnN0YW50JDEoK18pLCB4MSA9IG51bGwsIGFyZWEpIDogeDA7XG4gIH07XG5cbiAgYXJlYS54MCA9IGZ1bmN0aW9uKF8pIHtcbiAgICByZXR1cm4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h0LmxpbmVUbyhyLCAtcik7XG4gICAgY29udGV4dC5saW5lVG8oMyAqIHIsIC1yKTtcbiAgICBjb250ZXh0LmxpbmVUbygzICogciwgcik7XG4gICAgY29udGV4dC5saW5lVG8ociwgcik7XG4gICAgY29udGV4dC5saW5lVG8ociwgMyAqIHIpO1xuICAgIGNvbnRleHQubGluZVRvKC1yLCAzICogcik7XG4gICAgY29udGV4dC5saW5lVG8oLXIsIHIpO1xuICAgIGNvbnRleHQubGluZVRvKC0zICogciwgcik7XG4gICAgY29udGV4dC5jbG9zZVBhdGgoKTtcbiAgfVxufTtcblxudmFyIHRhbjMwID0gTWF0aC5zcXJ0KDEgLyAzKSxcbiAgICB0YW4zMF8yID0gdGFuMzAgKiAyO1xuXG52YXIgZGlhbW9uZCA9IHtcbiAgZHJhdzogZnVuY3Rpb24oY29udGV4dCwgc2l6ZSkge1xuICAgIHZhciB5ID0gTWF0aC5zcXJ0KHNpemUgLyB0YW4zMF8yKSxcbiAgICAgICAgeCA9IHkgKiB0YW4zMDtcbiAgICBjb250ZXh0Lm1vdmVUbygwLCAteSk7XG4gICAgY29udGV4dC5saW5lVG8oeCwgMCk7XG4gICAgY29udGV4dC5saW5lVG8oMCwgeSk7XG4gICAgY29udGV4dC5saW5lVG8oLXgsIDApO1xuICAgIGNvbnRleHQuY2xvc2VQYXRoKCk7XG4gIH1cbn07XG5cbnZhciBrYSA9IDAuODkwODEzMDkxNTI5Mjg1MjI4MTAsXG4gICAga3IgPSBNYXRoLnNpbihwaSAvIDEwKSAvIE1hdGguc2luKDcgKiBwaSAvIDEwKSxcbiAgICBreCA9IE1hdGguc2luKHRhdSAvIDEwKSAqIGtyLFxuICAgIGt5ID0gLU1hdGguY29zKHRhdSAvIDEwKSAqIGtyO1xuXG52YXIgc3RhciA9IHtcbiAgZHJhdzogZnVuY3Rpb24oY29udGV4dCwgc2l6ZSkge1xuICAgIHZhciByID0gTWF0aC5zcXJ0KHNpemUgKiBrYSksXG4gICAgICAgIHggPS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ICAgICAgICAgYnJlYWtcbiAgICAgICAgICAgICAgICBjYXNlICdvcmFuZ2UnOlxuICAgICAgICAgICAgICAgICAgICBzID0gJ29yYW5nZXMnXG4gICAgICAgICAgICAgICAgICAgIGJyZWFrXG4gICAgICAgICAgICAgICAgY2FzZSAncHVycGxlJzpcbiAgICAgICAgICAgICAgICAgICAgcyA9ICdwdXJwbGVzJ1xuICAgICAgICAgICAgICAgICAgICBicmVha1xuICAgICAgICAgICAgICAgIGNhc2UgJ3JlZCc6XG4gICAgICAgICAgICAgICAgICAgIHMgPSAncmVkcydcbiAgICAgICAgICAgICAgICAgICAgYnJlYWtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHRoaXMuY29sb3JTY2hlbWVzW2tleV0gPSBzXG4gICAgICAgIH1cbiAgICB9XG5cbiAgICBwdWJsaWMgZ2V0QmFja2dyb3VuZENvbG9yKCkge1xuICAgICAgICBpZiAodGhpcy50aGVtZSA9PT0gJ2xpZ2h0Jykge1xuICAgICAgICAgICAgcmV0dXJuIGQzLmludGVycG9sYXRlR3JleXMoMClcbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIHJldHVybiBkMy5pbnRlcnBvbGF0ZUdyZXlzKDEpXG4gICAgICAgIH1cbiAgICB9XG5cbiAgICBwdWJsaWMgZ2V0RmlsbGVkVGV4dENvbG9yKCkge1xuICAgICAgICBpZiAodGhpcy50aGVtZSA9PT0gJ2xpZ2h0Jykge1xuICAgICAgICAgICAgcmV0dXJuIGQzLmludGVycG9sYXRlR3JleXMoMSlcbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIHJldHVybiBkMy5pbnRlcnBvbGF0ZUdyZXlzKDApXG4gICAgICAgIH1cbiAgICB9XG5cbiAgICBwdWJsaWMgZ2V0SW50ZXJwb2xhdGVkU2Vjb25kYXJ5Q29sb3IodmFsdWU6IG51bWJlcikge1xuICAgICAgICBpZiAodGhpcy50aGVtZSA9PT0gJ2xpZ2h0Jykge1xuICAgICAgICAgICAgdmFsdWUgPSAxIC0gdmFsdWVcbiAgICAgICAgfVxuXG4gICAgICAgIHJldHVybiBkMy5pbnRlcnBvbGF0ZUdyZXlzKHZhbHVlKVxuICAgIH1cblxuICAgIHB1YmxpYyBnZXRJbnRlcnBvbGF0ZWRDb2xvcih2YWx1ZTogbnVtYmVyLCBjaGFydDogc3RyaW5nKSB7XG4gICAgICAgIGlmICh0aGlzLnRoZW1lID09PSAnZGFyaycpIHtcbiAgICAgICAgICAgIHZhbHVlID0gMC4zICsgKDEgLSB2YWx1ZSkgKiAwLjdcbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIHZhbHVlID0gdmFsdWUgKiAwLjhcbiAgICAgICAgfVxuXG4gICAgICAgIGxldCBjb2xvciA9IHRoaXMuY29sb3JTY2hlbWVzW2NoYXJ0IGFzIENoYXJ0VHlwZV1cbiAgICAgICAgc3dpdGNoIChjb2xvci50b0xvd2VyQ2FzZSgpKSB7XG4gICAgICAgICAgICBjYXNlICdibHVlcyc6XG4gICAgICAgICAgICAgICAgcmV0dXJuIGQzLmludGVycG9sYXRlQmx1ZXModmFsdWUpXG4gICAgICAgICAgICBjYXNlICdncmVlbnMnOlxuICAgICAgICAgICAgICAgIHJldHVybiBkMy5pbnRlcnBvbGF0ZUdyZWVucyh2YWx1ZSlcbiAgICAgICAgICAgIGNhc2UgJ2dyZXlzJzpcbiAgICAgICAgICAgICAgICByZXR1cm4gZDMuaW50ZXJwb2xhdGVHcmV5cyh2YWx1ZSlcbiAgICAgICAgICAgIGNhc2UgJ29yYW5nZXMnOlxuICAgICAgICAgICAgICAgIHJldHVybiBkMy5pbnRlcnBvbGF0ZU9yYW5nZXModmFsdWUpXG4gICAgICAgICAgICBjYXNlICdwdXJwbGVzJzpcbiAgICAgICAgICAgICAgICByZXR1cm4gZDMuaW50ZXJwb2xhdGVQdXJwbGVzKHZhbHVlKVxuICAgICAgICAgICAgY2FzZSAncmVkcyc6XG4gICAgICAgICAgICAgICAgcmV0dXJuIGQzLmludGVycG9sYXRlUmVkcyh2YWx1ZSlcbiAgICAgICAgICAgIGNhc2UgJ2J1Z24nOlxuICAgICAgICAgICAgICAgIHJldHVybiBkMy5pbnRlcnBvbGF0ZUJ1R24odmFsdWUpXG4gICAgICAgICAgICBjYXNlICdidXB1JzpcbiAgICAgICAgICAgICAgICByZXR1cm4gZDMuaW50ZXJwb2xhdGVCdVB1KHZhbHVlKVxuICAgICAgICAgICAgY2FzZSAnZ25idSc6XG4gICAgICAgICAgICAgICAgcmV0dXJuIGQzLmludGVycG9sYXRlR25CdSh2YWx1ZSlcbiAgICAgICAgICAgIGNhc2UgJ29ycmQnOlxuICAgICAgICAgICAgICAgIHJldHVybiBkMy5pbnRlcnBvbGF0ZU9yUmQodmFsdWUpXG4gICAgICAgICAgICBjYXNlICdwdWJ1Z24nOlxuICAgICAgICAgICAgICAgIHJldHVybiBkMy5pbnRlcnBvbGF0ZVB1QnVHbih2YWx1ZSlcbiAgICAgICAgICAgIGNhc2UgJ3B1YnUnOlxuICAgICAgICAgICAgICAgIHJldHVybiBkMy5pbnRlcnBvbGF0ZVB1QnUodmFsdWUpXG4gICAgICAgICAgICBjYXNlICdwdXJkJzpcbiAgICAgICAgICAgICAgICByZXR1cm4gZDMuaW50ZXJwb2xhdGVQdVJkKHZhbHVlKVxuICAgICAgICAgICAgY2FzZSAncmRwdSc6XG4gICAgICAgICAgICAgICAgcmV0dXJuIGQzLmludGVycG9sYXRlUmRQdSh2YWx1ZSlcbiAgICAgICAgICAgIGNhc2UgJ3lsZ25idSc6XG4gICAgICAgICAgICAgICAgcmV0dXJuIGQzLmludGVycG9sYXRlWWxHbkJ1KHZhbHVlKVxuICAgICAgICAgICAgY2FzZSAneWxnbic6XG4gICAgICAgICAgICAgICAgcmV0dXJuIGQzLmludGVycG9sYXRlWWxHbih2YWx1ZSlcbiAgICAgICAgICAgIGNhc2UgJ3lsb3Jicic6XG4gICAgICAgICAgICAgICAgcmV0dXJuIGQzLmludGVycG9sYXRlWWxPckJyKHZhbHVlKVxuICAgICAgICAgICAgY2FzZSAneWxvcnJkJzpcbiAgICAgICAgICAgICAgICByZXR1cm4gZDMuaW50ZXJwb2xhdGVZbE9yUmQodmFsdWUpXG4gICAgICAgICAgICBjYXNlICdjaXZpZGlzJzpcbiAgICAgICAgICAgICAgICByZXR1cm4gZDMuaW50ZXJwb2xhdGVDaXZpZGlzKHZhbHVlKVxuICAgICAgICAgICAgY2FzZSAndmlyaWRpcyc6XG4gICAgICAgICAgICAgICAgcmV0dXJuIGQzLmludGVycG9sYXRlVmlyaWRpcyh2YWx1ZSlcbiAgICAgICAgICAgIGNhc2UgJ2luZmVybm8nOlxuICAgICAgICAgICAgICAgIHJldHVybiBkMy5pbnRlcnBvbGF0ZUluZmVybm8odmFsdWUpXG4gICAgICAgICAgICBjYXNlICdtYWdtYSc6XG4gICAgICAgICAgICAgICAgcmV0dXJuIGQzLmludGVycG9sYXRlTWFnbWEodmFsdWUpXG4gICAgICAgICAgICBjYXNlICdwbGFzbWEnOlxuICAgICAgICAgICAgICAgIHJldHVybiBkMy5pbnRlcnBvbGF0ZVBsYXNtYSh2YWx1ZSlcbiAgICAgICAgICAgIGNhc2UgJ3dhcm0nOlxuICAgICAgICAgICAgICAgIHJldHVybiBkMy5pbnRlcnBvbGF0ZVdhcm0odmFsdWUpXG4gICAgICAgICAgICBjYXNlICdjb29sJzpcbiAgICAgICAgICAgICAgICByZXR1cm4gZDMuaW50ZXJwb2xhdGVDb29sKHZhbHVlKVxuICAgICAgICAgICAgY2FzZSAnY3ViZWhlbGl4ZGVmYXVsdCc6XG4gICAgICAgICAgICAgICAgcmV0dXJuIGQzLmludGVycG9sYXRlQ3ViZWhlbGl4RGVmYXVsdCh2YWx1ZSlcbiAgICAgICAgICAgIGNhc2UgJ3R1cmJvJzpcbiAgICAgICAgICAgICAgICByZXR1cm4gZDMuaW50ZXJwb2xhdGVUdXJibyh2YWx1ZSlcbiAgICAgICAgICAgIGNhc2UgJ2JyYmcnOlxuICAgICAgICAgICAgICAgIHJldHVybiBkMy5pbnRlcnBvbGF0ZUJyQkcodmFsdWUpXG4gICAgICAgICAgICBjYXNlICdwcmduJzpcbiAgICAgICAgICAgICAgICByZXR1cm4gZDMuaW50ZXJwb2xhdGVQUkduKHZhbHVlKVxuICAgICAgICAgICAgY2FzZSAncGl5Zyc6XG4gICAgICAgICAgICAgICAgcmV0dXJuIGQzLmludGVycG9sYXRlUGlZRyh2YWx1ZSlcbiAgICAgICAgICAgIGNhc2UgJ3B1b3InOlxuICAgICAgICAgICAgICAgIHJldHVybiBkMy5pbnRlcnBvbGF0ZVB1T3IodmFsdWUpXG4gICAgICAgICAgICBjYXNlICdyZGJ1JzpcbiAgICAgICAgICAgICAgICByZXR1cm4gZDMuaW50ZXJwb2xhdGVSZEJ1KHZhbHVlKVxuICAgICAgICAgICAgY2FzZSAncmRneSc6XG4gICAgICAgICAgICAgICAgcmV0dXJuIGQzLmludGVycG9sYXRlUmRHeSh2YWx1ZSlcbiAgICAgICAgICAgIGNhc2UgJ3JkeWxidSc6XG4gICAgICAgICAgICAgICAgcmV0dXJuIGQzLmludGVycG9sYXRlUmRZbEJ1KHZhbHVlKVxuICAgICAgICAgICAgY2FzZSAncmR5bGduJzpcbiAgICAgICAgICAgICAgICByZXR1cm4gZDMuaW50ZXJwb2xhdGVSZFlsR24odmFsdWUpXG4gICAgICAgICAgICBjYXNlICdzcGVjdHJhbCc6XG4gICAgICAgICAgICAgICAgcmV0dXJuIGQzLmludGVycG9sYXRlU3BlY3RyYWwodmFsdWUpXG4gICAgICAgICAgICBkZWZhdWx0OlxuICAgICAgICAgICAgICAgIHJldHVybiBkMy5pbnRlcnBvbGF0ZUJsdWVzKHZhbHVlKVxuICAgICAgICB9XG4gICAgfVxufSIsImltcG9ydCB7U3RyaW5nVG9rZW5MYWJlbFZpZXcsIFRva2VuTGFiZWxWaWV3fSBmcm9tICcuL3Rva2VuX2xhYmVsX3ZpZXcnXG5pbXBvcnQge1d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vciAobGV0IGR2IGluIGRpbVZhbHVlcykge1xuICAgICAgICAgICAgICAgIHRoaXMuc2VsZWN0ZWRbZGltLm5hbWVdW2R2XSA9IHRydWVcbiAgICAgICAgICAgICAgICBkaW0udmFsdWVzLnB1c2goZHYpXG4gICAgICAgICAgICB9XG4gICAgICAgIH1cblxuICAgICAgICB0aGlzLnNlbGVjdGVkWydzcmMnXSA9IHt9XG4gICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgdGhpcy5zcmNUb2tlbnMubGVuZ3RoOyArK2kpIHtcbiAgICAgICAgICAgIHRoaXMuc2VsZWN0ZWRbJ3NyYyddW2ldID0gdHJ1ZVxuICAgICAgICB9XG5cbiAgICAgICAgdGhpcy5zZWxlY3RlZFsnZHN0J10gPSB7fVxuICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IHRoaXMuZHN0VG9rZW5zLmxlbmd0aDsgKytpKSB7XG4gICAgICAgICAgICB0aGlzLnNlbGVjdGVkWydkc3QnXVtpXSA9IHRydWVcbiAgICAgICAgfVxuXG4gICAgICAgIHRoaXMuZGltZW5zaW9uSGVhdG1hcHMgPSBbXVxuICAgICAgICBmb3IgKGxldCBkaW0gb2YgZGltZW5zaW9ucykge1xuICAgICAgICAgICAgbGV0IHZhbHVlcyA9IFtdXG4gICAgICAgICAgICBmb3IgKGxldCB2IGluIHRoaXMuc2VsZWN0ZWRbZGltLm5hbWVdKSB7XG4gICAgICAgICAgICAgICAgdmFsdWVzLnB1c2godilcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGxldCBoZWF0bWFwID0gbmV3IERpbWVuc2lvbkhlYXRtYXAodmFsdWVzLCBkaW0ubmFtZSwgcGxvdENvbG9ycylcblxuICAgICAgICAgICAgaGVhdG1hcC5hZGRDbGlja0hhbmRsZXIoZGltLm5hbWUsIHRoaXMub25TZWxlY3RlZClcbiAgICAgICAgICAgIHRoaXMuZGltZW5zaW9uSGVhdG1hcHMucHVzaChoZWF0bWFwKVxuICAgICAg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Ckge1xuICAgICAgICAgICAgICAgIGNvbnRpbnVlXG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgdGhpcy5zcmNUb2tlbnMubGVuZ3RoOyArK2kpIHtcbiAgICAgICAgICAgICAgICBmb3IgKGxldCBqID0gMDsgaiA8IHRoaXMuZHN0VG9rZW5zLmxlbmd0aDsgKytqKSB7XG4gICAgICAgICAgICAgICAgICAgIG1hdHJpeFtpXVtqXSArPSBhdHRuLnZhbHVlc1tpXVtqXVxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuXG4gICAgICAgIC8vIEZpbHRlciB0b2tlbnNcbiAgICAgICAgaWYgKGZpbHRlclRva2Vucykge1xuICAgICAgICAgICAgZm9yIChsZXQgaSA9IDA7IGkgPCB0aGlzLnNyY1Rva2Vucy5sZW5ndGg7ICsraSkge1xuICAgICAgICAgICAgICAgIGZvciAobGV0IGogPSAwOyBqIDwgdGhpcy5kc3RUb2tlbnMubGVuZ3RoOyArK2opIHtcbiAgICAgICAgICAgICAgICAgICAgaWYgKCF0aGlzLnNlbGVjdGVkWydzcmMnXVtpXSB8fCAhdGhpcy5zZWxlY3RlZFsnZHN0J11bal0pIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIG1hdHJpeFtpXVtqXSA9IDAuXG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cblxuICAgICAgICBtYXhOb3JtYWxpemUyREFycmF5KG1hdHJpeClcblxuICAgICAgICByZXR1cm4gbWF0cml4XG4gICAgfVxuXG4gICAgcHJpdmF0ZSBjYWxjRHN0QXR0bihtYXRyaXg6IG51bWJlcltdW10pOiBudW1iZXJbXSB7XG4gICAgICAgIGxldCBkc3RBdHRuID0gW11cbiAgICAgICAgZm9yIChsZXQgaiA9IDA7IGogPCB0aGlzLmRzdFRva2Vucy5sZW5ndGg7ICsraikge1xuICAgICAgICAgICAgbGV0IHZhbCA9IDAuXG4gICAgICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IHRoaXMuc3JjVG9rZW5zLmxlbmd0aDsgKytpKSB7XG4gICAgICAgICAgICAgICAgaWYgKHRoaXMuc2VsZWN0ZWRbJ3NyYyddW2ldID09PSB0cnVlKSB7XG4gICAgICAgICAgICAgICAgICAgIHZhbCArPSBtYXRyaXhbaV1bal1cbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBkc3RBdHRuLnB1c2godmFsKVxuICAgICAgICB9XG4gICAgICAgIG1heE5vcm1hbGl6ZUFycmF5KGRzdEF0dG4pXG5cbiAgICAgICAgcmV0dXJuIGRzdEF0dG5cbiAgICB9XG5cbiAgICBwcml2YXRlIGNhbGNTcmNBdHRuKG1hdHJpeDogbnVtYmVyW11bXSk6IG51bWJlcltdIHtcbiAgICAgICAgbGV0IHNyY0F0dG4gPSBbXVxuICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IHRoaXMuc3JjVG9rZW5zLmxlbmd0aDsgKytpKSB7XG4gICAgICAgICAgICBsZXQgdmFsID0gMC5cbiAgICAgICAgICAgIGZvciAobGV0IGogPSAwOyBqIDwgdGhpcy5kc3RUb2tlbnMubGVuZ3RoOyArK2opIHtcbiAgICAgICAgICAgICAgICBpZiAodGhpcy5zZWxlY3RlZFsnZHN0J11bal0gPT09IHRydWUpIHtcbiAgICAgICAgICAgICAgICAgICAgdmFsICs9IG1hdHJpeFtpXVtqXVxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHNyY0F0dG4ucHVzaCh2YWwpXG4gICAgICAgIH1cbiAgICAgICAgbWF4Tm9ybWFsaXplQXJyYXkoc3JjQXR0bilcblxuICAgICAgICByZXR1cm4gc3JjQXR0blxuICAgIH1cblxuICAgIHByaXZhdGUgY2FsY0RpbXNBdHRlbnRpb24oKTogeyBbdHlwZTogc3RyaW5nXTogeyBbdmFsdWU6IERpbVZhbHVlXTogbnVtYmVyIH0gfSB7XG4gICAgICAgIGxldCBkaW1zID0ge31cbiAgICAgICAgZm9yIChsZXQgZGltIG9mIHRoaXMuZGltZW5zaW9ucykge1xuICAgICAgICAgICAgZGltc1tkaW0ubmFtZV0gPSB7fVxuICAgICAgICB9XG5cbiAgICAgICAgZm9yIChsZXQgYXR0biBvZiB0aGlzLmF0dGVudGlvbnMpIHtcbiAgICAgICAgICAgIGxldCB0b3RhbCA9IDBcbiAgICAgICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgdGhpcy5zcmNUb2tlbnMubGVuZ3RoOyArK2kpIHtcbiAgICAgICAgICAgICAgICBmb3IgKGxldCBqID0gMDsgaiA8IHRoaXMuZHN0VG9rZW5zLmxlbmd0aDsgKytqKSB7XG4gICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLnNlbGVjdGVkWydzcmMnXVtpXSA9PT0gdHJ1ZSAmJiB0aGlzLnNlbGVjdGVkWydkc3QnXVtqXSA9PT0gdHJ1ZSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgdG90YWwgKz0gYXR0bi52YWx1ZXNbaV1bal1cbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgbGV0IG5vdFNlbGVjdGVkID0gMFxuICAgICAgICAgICAgZm9yIChsZXQgZGltIGluIGF0dG4uaW5mbykge1xuICAgICAgICAgICAgICAgIGlmICh0aGlzLnNlbGVjdGVkW2RpbV1bYXR0bi5pbmZvW2RpbV1dICE9PSB0cnVlKSB7XG4gICAgICAgICAgICAgICAgICAgIG5vdFNlbGVjdGVkKytcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIGZvciAobGV0IGRpbSBvZiB0aGlzLmRpbWVuc2lvbnMpIHtcbiAgICAgICAgICAgICAgICBpZiAoZGltc1tkaW0ubmFtZV1bYXR0bi5pbmZvW2RpbS5uYW1lXV0gPT0gbnVsbCkge1xuICAgICAgICAgICAgICAgICAgICBkaW1zW2RpbS5uYW1lXVthdHRuLmluZm9bZGltLm5hbWVdXSA9IDBcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgaWYgKG5vdFNlbGVjdGVkID09PSAwKSB7XG4gICAgICAgICAgICAgICAgICAgIGRpbXNbZGltLm5hbWVdW2F0dG4uaW5mb1tkaW0ubmFtZV1dICs9IHRvdGFsXG4gICAgICAgICAgICAgICAgfSBlbHNlIGlmIChub3RTZWxlY3RlZCA9PT0gMSAmJiB0aGlzLnNlbGVjdGVkW2RpbS5uYW1lXVthdHRuLmluZm9bZGltLm5hbWVdXSAhPT0gdHJ1ZSkge1xuICAgICAgICAgICAgICAgICAgICBkaW1zW2RpbS5uYW1lXVthdHRuLmluZm9bZGltLm5hbWVdXSArPSB0b3RhbFxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuXG4gICAgICAgIGZvciAobGV0IGRpbSBvZiB0aGlzLmRpbWVuc2lvbnMpIHtcbiAgICAgICAgICAgIG1heE5vcm1hbGl6ZU1hcChkaW1zW2RpbS5uYW1lXSlcbiAgICAgICAgfVxuXG4gICAgICAgIHJldHVybiBkaW1zXG4gICAgfVxuXG4gICAgcHJpdmF0ZSBjYWxjVG9rZW5EaW1zQXR0ZW50aW9uKHNlbERpbTogc3RyaW5nKTogeyBbdmFsdWU6IERpbVZhbHVlXTogbnVtYmVyIH1bXSB7XG4gICAgICAgIGxldCByZXMgPSBbXVxuICAgICAgICBsZXQgZHYgPSBnZXREaW1WYWx1ZXMoc2VsRGltLCB0aGlzLmRpbWVuc2lvbnNNYXApXG4gICAgICAgIGZvciAobGV0IGogPSAwOyBqIDwgdGhpcy5kc3RUb2tlbnMubGVuZ3RoOyArK2opIHtcbiAgICAgICAgICAgIHJlcy5wdXNoKHt9KVxuICAgICAgICAgICAgZm9yIChsZXQgZCBvZiBkdikge1xuICAgICAgICAgICAgICAgIHJlc1tqXVtkXSA9IDBcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuXG4gICAgICAgIGZvciAobGV0IGF0dG4gb2YgdGhpcy5hdHRlbnRpb25zKSB7XG4gICAgICAgICAgICBsZXQgbm90U2VsZWN0ZWQgPSAwXG4gICAgICAgICAgICBmb3IgKGxldCBkaW0gaW4gYXR0bi5pbmZvKSB7XG4gICAgICAgICAgICAgICAgaWYgKHRoaXMuc2VsZWN0ZWRbZGltXVthdHRuLmluZm9bZGltXV0gIT09IHRydWUpIHtcbiAgICAgICAgICAgICAgICAgICAgaWYgKGRpbSAhPT0gc2VsRGltKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBub3RTZWxlY3RlZCsrXG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIGlmIChub3RTZWxlY3RlZCAhPT0gMCkge1xuICAgICAgICAgICAgICAgIGNvbnRpbnVlXG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBsZXQgZHZTZWwgPSBhdHRuLmluZm9bc2VsRGltXVxuICAgICAgICAgICAgaWYgKGR2U2VsID09IG51bGwpIHtcbiAgICAgICAgICAgICAgICBkdlNlbCA9ICdudWxsJ1xuICAgICAgICAgICAgfVxuXG5cbiAgICAgICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgdGhpcy5zcmNUb2tlbnMubGVuZ3RoOyArK2kpIHtcbiAgICAgICAgICAgICAgICBmb3IgKGxldCBqID0gMDsgaiA8IHRoaXMuZHN0VG9rZW5zLmxlbmd0aDsgKytqKSB7XG4gICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLnNlbGVjdGVkWydzcmMnXVtpXSA9PT0gdHJ1ZSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgcmVzW2pdW2R2U2VsXSArPSBhdHRuLnZhbHVlc1tpXVtqXVxuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuXG4gICAgICAgIH1cblxuICAgICAgICBtYXhOb3JtYWxpemVBcnJheU1hcChyZXMpXG4gICAgICAgIHJldHVybiByZXNcbiAgICB9XG5cbiAgICBwcml2YXRlIGNhbGNHcmlkQXR0ZW50aW9uQXR0ZW50aW9uKGRpbTE6IHN0cmluZywgZGltMjogc3RyaW5nKTogR3JpZEF0dGVudGlvbiB7XG4gICAgICAgIGxldCByZXMgPSB7fVxuICAgICAgICBmb3IgKGxldCBkdjEgb2YgZ2V0RGltVmFsdWVzKGRpbTEsIHRoaXMuZGltZW5zaW9uc01hcCkpIHtcbiAgICAgICAgICAgIHJlc1tkdjFdID0ge31cbiAgICAgICAgICAgIGZvciAobGV0IGR2MiBvZiBnZXREaW1WYWx1ZXMoZGltMiwgdGhpcy5kaW1lbnNpb25zTWFwKSkge1xuICAgICAgICAgICAgICAgIHJlc1tkdjFdW2R2Ml0gPSBjcmVhdGVNYXRyaXgodGhpcy5zcmNUb2tlbnMubGVuZ3RoLCB0aGlzLmRzdFRva2Vucy5sZW5ndGgpXG4gICAgICAgICAgICB9XG4gICAgICAgIH1cblxuXG4gICAgICAgIGZvciAobGV0IGF0dG4gb2YgdGhpcy5hdHRlbnRpb25zKSB7XG4gICAgICAgICAgICBsZXQgbm90U2VsZWN0ZWQgPSAwXG4gICAgICAgICAgICBmb3IgKGxldCBkaW0gaW4gYXR0bi5pbmZvKSB7XG4gICAgICAgICAgICAgICAgaWYgKHRoaXMuc2VsZWN0ZWRbZGltXVthdHRuLmluZm9bZGltXV0gIT09IHRydWUpIHtcbiAgICAgICAgICAgICAgICAgICAgaWYgKGRpbSAhPT0gZGltMSAmJiBkaW0gIT09IGRpbTIpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIG5vdFNlbGVjdGVkKytcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgaWYgKG5vdFNlbGVjdGVkICE9PSAwKSB7XG4gICAgICAgICAgICAgICAgY29udGludWVcbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgbGV0IGR2MSA9IGF0dG4uaW5mb1tkaW0xXVxuICAgICAgICAgICAgbGV0IGR2MiA9IGF0dG4uaW5mb1tkaW0yXVxuICAgICAgICAgICAgaWYgKGR2MSA9PSBudWxsKSB7XG4gICAgICAgICAgICAgICAgZHYxID0gJ251bGwnXG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBpZiAoZHYyID09IG51bGwpIHtcbiAgICAgICAgICAgICAgICBkdjIgPSAnbnVsbCdcbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgbGV0IGFyciA9IHJlc1tkdjFdW2R2Ml1cblxuICAgICAgICAgICAgZm9yIChsZXQgaSA9IDA7IGkgPCB0aGlzLnNyY1Rva2Vucy5sZW5ndGg7ICsraSkge1xuICAgICAgICAgICAgICAgIGZvciAobGV0IGogPSAwOyBqIDwgdGhpcy5kc3RUb2tlbnMubGVuZ3RoOyArK2opIHtcbiAgICAgICAgICAgICAgICAgICAgYXJyW2ldW2pdICs9IGF0dG4udmFsdWVzW2ldW2pdXG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICB9XG5cbiAgICAgICAgZm9yIChsZXQgZHYxIGluIHJlcykge1xuICAgICAgICAgICAgZm9yIChsZXQgZHYyIGluIHJlc1tkdjFdKSB7XG5cbiAgICAgICAgICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IHRoaXMuc3JjVG9rZW5zLmxlbmd0aDsgKytpKSB7XG4gICAgICAgICAgICAgICAgICAgIG5vcm1hbGl6ZUFycmF5KHJlc1tkdjFdW2R2Ml1baV0pXG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICB9XG5cbiAgICAgICAgcmV0dXJuIHJlc1xuICAgIH1cblxuICAgIHByaXZhdGUgZ2V0U2VsZWN0ZWRDb3VudCh0eXBlOiBzdHJpbmcpIHtcbiAgICAgICAgbGV0IGNvdW50ID0gMFxuICAgICAgICBmb3IgKGxldCBpIGluIHRoaXMuc2VsZWN0ZWRbdHlwZV0pIHtcbiAgICAgICAgICAgIGlmICh0aGlzLnNlbGVjdGVkW3R5cGVdW2ldID09PSB0cnVlKSB7XG4gICAgICAgICAgICAgICAgY291bnQrK1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG5cbiAgICAgICAgcmV0dXJuIGNvdW50XG4gICAgfVxuXG4gICAgcHJpdmF0ZSBvblNlbGVjdGVkID0gKHR5cGU6IHN0cmluZywgaWR4OiBEaW1WYWx1ZSwgaXNNdWx0aTogYm9vbGVhbikgPT4ge1xuICAgICAgICBpZiAoaXNNdWx0aSkge1xuICAgICAgICAgICAgdGhpcy5zZWxlY3RlZFt0eXBlXVtpZHhdID0gdGhpcy5zZWxlY3RlZFt0eXBlXVtpZHhdICE9PSB0cnVlXG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICBpZiAodGhpcy5zZWxlY3RlZFt0eXBlXVtpZHhdID09PSB0cnVlKSB7XG4gICAgICAgICAgICAgICAgaWYgKHRoaXMuZ2V0U2VsZWN0ZWRDb3VudCh0eXBlKSA+IDEpIHtcbiAgICAgICAgICAgICAgICAgICAgZm9yIChsZXQgaSBpbiB0aGlzLnNlbGVjdGVkW3R5cGVdKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnNlbGVjdGVkW3R5cGVdW2ldID0gZmFsc2VcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICB0aGlzLnNlbGVjdGVkW3R5cGVdW2lkeF0gPSB0cnVlXG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgZm9yIChsZXQgaSBpbiB0aGlzLnNlbGVjdGVkW3R5cGVdKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnNlbGVjdGVkW3R5cGVdW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3IoblNyYzogbnVtYmVyLCBuRHN0OiBudW1iZXIsIGhlaWdodDogbnVtYmVyLCB3aWR0aDogbnVtYmVyKSB7XG4gICAgICAgIHRoaXMuaGVpZ2h0ID0gaGVpZ2h0O1xuICAgICAgICB0aGlzLndpZHRoID0gd2lkdGg7XG4gICAgICAgIHRoaXMublNyYyA9IG5TcmNcbiAgICAgICAgdGhpcy5uRHN0ID0gbkRzdFxuICAgIH1cblxuICAgIHJlbmRlcigpIHtcbiAgICAgICAgdGhpcy5lbGVtID0gJCgnZycsICcubGluZXMnLCB7b246IHsnY2xpY2snOiB0aGlzLm9uQ2xpY2t9fSwgJCA9PiB7XG4gICAgICAgICAgICB0aGlzLmJnTGluZXMgPSAkKCdnJylcbiAgICAgICAgICAgIHRoaXMuZmdMaW5lcyA9ICQoJ2cnKVxuICAgICAgICB9KVxuXG4gICAgICAgIHRoaXMubGluZXMgPSBbXVxuICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IHRoaXMublNyYzsgKytpKSB7XG4gICAgICAgICAgICB0aGlzLmxpbmVzLnB1c2goW10pXG4gICAgICAgICAgICBmb3IgKGxldCBqID0gMDsgaiA8IHRoaXMubkRzdDsgKytqKSB7XG4gICAgICAgICAgICAgICAgdGhpcy5saW5lc1tpXS5wdXNoKG5ldyBMaW5lVmlldygpKVxuICAgICAgICAgICAgICAgIHRoaXMuZmdMaW5lcy5hcHBlbmRDaGlsZCh0aGlzLmxpbmVzW2ldW2pdLnJlbmRlcihcbiAgICAgICAgICAgICAgICAgICAgaSAvIHRoaXMublNyYyAqIHRoaXMuaGVpZ2h0LFxuICAgICAgICAgICAgICAgICAgICBqIC8gdGhpcy5uRHN0ICogdGhpcy5oZWlnaHQsXG4gICAgICAgICAgICAgICAgICAgIHRoaXMud2lkdGgpKVxuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICAgIHJldHVybiB0aGlzLmVsZW1cbiAgICB9XG5cbiAgICBhZGRDbGlja0hhbmRsZXIoZGltMTogc3RyaW5nLCBkdjE6IERpbVZhbHVlLCBkaW0yOiBzdHJpbmcsIGR2MjogRGltVmFsdWUsIGhhbmRsZXI6IFNlbGVjdENhbGxiYWNrKSB7XG4gICAgICAgIHRoaXMuaGFuZGxlciA9IGhhbmRsZXJcbiAgICAgICAgdGhpcy5kaW1zID0gW11cbiAgICAgICAgaWYgKGRpbTEgIT09ICdudWxsJykge1xuICAgICAgICAgICAgdGhpcy5kaW1zLnB1c2goe2Q6IGRpbTEsIHY6IGR2MX0pXG4gICAgICAgIH1cbiAgICAgICAgaWYgKGRpbTIgIT09ICdudWxsJykge1xuICAgICAgICAgICAgdGhpcy5kaW1zLnB1c2goe2Q6IGRpbTIsIHY6IGR2Mn0pXG4gICAgICAgIH1cbiAgICB9XG5cbiAgICBvbkNsaWNrID0gKGU6IE1vdXNlRXZlbnQpID0+IHtcbiAgICAgICAgZS5wcmV2ZW50RGVmYXVsdCgpXG4gICAgICAgIGUuc3RvcFByb3BhZ2F0aW9uKClcblxuICAgICAgICBjb25zb2xlLmxvZygnY2xpY2snLCB0aGlzLmRpbXMpXG4gICAgICAgIGZvciAobGV0IGQgb2YgdGhpcy5kaW1zKSB7XG4gICAgICAgICAgICB0aGlzLmhhbmRsZXIoZC5kLCBkLnYsIGZhbHNlKVxuICAgICAgICB9XG4gICAgfVxuXG4gICAgc2V0QXR0bihhdHRuOiBudW1iZXJbXVtdKSB7XG4gICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgdGhpcy5uU3JjOyArK2kpIHtcbiAgICAgICAgICAgIGZvciAobGV0IGogPSAwOyBqIDwgdGhpcy5uRHN0OyArK2opIHtcbiAgICAgICAgICAgICAgICB0aGlzLmxpbmVzW2ldW2pdLnNldEF0dG4oYXR0bltpXVtqXSlcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgIH1cblxuICAgIHNldFNlbGVjdGlvbihzZWxlY3RlZDogYm9vbGVhbikge1xuICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IHRoaXMublNyYzsgKytpKSB7XG4gICAgICAgICAgICBmb3IgKGxldCBqID0gMDsgaiA8IHRoaXMubkRzdDsgKytqKSB7XG4gICAgICAgICAgICAgICAgdGhpcy5saW5lc1tpXVtqXS5zZXRTZWxlY3RlZENlbGwoc2VsZWN0ZWQpXG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICB9XG5cbiAgICBzZXRTcmNEc3RTZWxlY3Rpb25zKHNyYzogeyBbcDogRGltVmFsdWVdOiBib29sZWFuIH0sIGRzdDogeyBbcDogRGltVmFsdWVdOiBib29sZWFuIH0pIHtcbiAgICAgICAgZm9yIChsZXQgaSA9IDA7IGkgPCB0aGlzLm5TcmM7ICsraSkge1xuICAgICAgICAgICAgZm9yIChsZXQgaiA9IDA7IGogPCB0aGlzLm5Ec3Q7ICsraikge1xuICAgICAgICAgICAgICAgIGxldCBzZWxlY3RlZCA9IHNyY1tpXSA9PT0gdHJ1ZSAmJiBkc3Rbal0gPT09IHRydWVcbiAgICAgICAgICAgICAgICBpZiAodGhpcy5saW5lc1tpXVtqXS5zZWxlY3RlZCA9PT0gc2VsZWN0ZWQpIHtcbiAgICAgICAgICAgICAgICAgICAgY29udGludWVcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgdGhpcy5saW5lc1tpXVtqXS5lbGVtLnJlbW92ZSgpXG4gICAgICAgICAgICAgICAgaWYgKHNlbGVjdGVkKSB7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMuZmdMaW5lcy5hcHBlbmRDaGlsZCh0aGlzLmxpbmVzW2ldW2pdLmVsZW0pXG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5iZ0xpbmVzLmFwcGVuZENoaWxkKHRoaXMubGluZXNbaV1bal0uZWxlbSlcbiAgICAgICAgICAgICAgICB9XG5cbiAgICAgICAgICAgICAgICB0aGlzLmxpbmVzW2ldW2pdLnNldFNlbGVjdGVkKHNlbGVjdGV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NlbGVjdH19LCAkID0+IHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGxldCBkIGluIHRoaXMuZGltZW5zaW9ucykge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAkKCdvcHRpb24nLCBkLCB7dmFsdWU6IGR9KVxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAkKCdvcHRpb24nLCAnTm9uZScsIHt2YWx1ZTogJ251bGwnfSlcbiAgICAgICAgICAgICAgICAgICAgICAgIH0pXG4gICAgICAgICAgICAgICAgICAgIH0pXG4gICAgICAgICAgICAgICAgICAgICQoJ2RpdicsICcuc2VsZWN0LWNvbnRhaW5lcicsICQgPT4ge1xuICAgICAgICAgICAgICAgICAgICAgICAgJCgnbGFiZWwudGl0bGUuaW5saW5lJywgJ1ggRGltZW5zaW9uJywge2ZvcjogJ2xpbmUtZ3JpZC1kaW0xLXNlbGVjdCd9KVxuICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5kaW1TZWxlY3RFbGVtMiA9ICQoJ3NlbGVjdCcsICcjbGluZS1ncmlkLWRpbTEtc2VsZWN0Jywge29uOiB7Y2hhbmdlOiB0aGlzLm9uRGltMlNlbGVjdH19LCAkID0+IHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGxldCBkIGluIHRoaXMuZGltZW5zaW9ucykge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAkKCdvcHRpb24nLCBkLCB7dmFsdWU6IGR9KVxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAkKCdvcHRpb24nLCAnTm9uZScsIHt2YWx1ZTogJ251bGwnfSlcbiAgICAgICAgICAgICAgICAgICAgICAgIH0pXG4gICAgICAgICAgICAgICAgICAgIH0pXG4gICAgICAgICAgICAgICAgfSlcbiAgICAgICAgICAgIH0pXG5cbiAgICAgICAgdGhpcy5k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KiAodGhpcy5jZWxsSGVpZ2h0ICsgdGhpcy5jZWxsTWFyZ2luKX0pYH0sICQgPT4ge1xuICAgICAgICAgICAgICAgICAgICBmb3IgKGxldCBqID0gMDsgaiA8IGR2Mi5sZW5ndGg7ICsraikge1xuICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jZWxsTGF5ZXJzW2ldLnB1c2goJCgnZycsIHt0cmFuc2Zvcm06IGB0cmFuc2xhdGUoJHtqICogKHRoaXMuY2VsbFdpZHRoICsgdGhpcy5jZWxsTWFyZ2luKX0sIDApYH0pKVxuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfSlcbiAgICAgICAgICAgIH1cbiAgICAgICAgfSlcblxuICAgICAgICB0aGlzLmVsZW0uYXBwZW5kQ2hpbGQodGhpcy5jaGFydEVsZW0pXG5cbiAgICAgICAgdGhpcy5jZWxscyA9IFtdXG4gICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgZHYxLmxlbmd0aDsgKytpKSB7XG4gICAgICAgICAgICB0aGlzLmNlbGxzLnB1c2goW10pXG4gICAgICAgICAgICBmb3IgKGxldCBqID0gMDsgaiA8IGR2Mi5sZW5ndGg7ICsraikge1xuICAgICAgICAgICAgICAgIHRoaXMuY2VsbHNbaV0ucHVzaChuZXcgTGluZUNlbGxWaWV3KFxuICAgICAgICAgICAgICAgICAgICB0aGlzLnNyY1Rva2Vucy5sZW5ndGgsXG4gICAgICAgICAgICAgICAgICAgIHRoaXMuZHN0VG9rZW5zLmxlbmd0aCxcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5jZWxsSGVpZ2h0LCB0aGlzLmNlbGxXaWR0aCkpXG4gICAgICAgICAgICAgICAgdGhpcy5jZWxsTGF5ZXJzW2ldW2pdLmFwcGVuZENoaWxkKHRoaXMuY2VsbHNbaV1bal0ucmVuZGVyKCkpXG4gICAgICAgICAgICAgICAgdGhpcy5jZWxsc1tpXVtqXS5hZGRDbGlja0hhbmRsZXIodGhpcy5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cy5kaW1lbnNpb25zKVxuICAgICAgICBsZXQgZHYyID0gZ2V0RGltVmFsdWVzKHRoaXMuZGltMiwgdGhpcy5kaW1lbnNpb25zKVxuICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IGR2MS5sZW5ndGg7ICsraSkge1xuICAgICAgICAgICAgZm9yIChsZXQgaiA9IDA7IGogPCBkdjIubGVuZ3RoOyArK2opIHtcbiAgICAgICAgICAgICAgICBsZXQgcyA9IHRydWVcbiAgICAgICAgICAgICAgICBpZiAoc2VsZWN0ZWRbdGhpcy5kaW0xXSAhPSBudWxsKSB7XG4gICAgICAgICAgICAgICAgICAgIGlmIChzZWxlY3RlZFt0aGlzLmRpbTFdW2R2MVtpXV0gIT09IHRydWUpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHMgPSBmYWxzZVxuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIGlmIChzZWxlY3RlZFt0aGlzLmRpbTJdICE9IG51bGwpIHtcbiAgICAgICAgICAgICAgICAgICAgaWYgKHNlbGVjdGVkW3RoaXMuZGltMl1bZHYyW2pdXSAhPT0gdHJ1ZSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgcyA9IGZhbHNlXG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgdGhpcy5jZWxsc1tpXVtqXS5zZXRTZWxlY3Rpb24ocylcbiAgICAgICAgICAgICAgICB0aGlzLmNlbGxzW2ldW2pdLnNldFNyY0RzdFNlbGVjdGlvbnMoc2VsZWN0ZWRbJ3NyYyddLCBzZWxlY3RlZFsnZHN0J10pXG4gICAgICAgICAgICB9XG4gICAgICAgIH1cblxuICAgIH1cbn1cbiIsImltcG9ydCB7V2V5YSBhcyAkfSBmcm9tICcuLi9saWIvd2V5YS93ZXlhJ1xuaW1wb3J0IHtUb2tlbnN9IGZyb20gXCIuL2NvbnRyb2xsZXJcIjtcbm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pIHtcbiAgICAgICAgICAgIHRoaXMuY2VsbHMucHVzaChbXSlcbiAgICAgICAgfVxuXG4gICAgICAgIHRoaXMuY2VsbFNpemUgPSAyMFxuICAgICAgICB0aGlzLmxlZnRMYWJlbHNNYXJnaW4gPSA1MFxuICAgICAgICB0aGlzLmxhYmVsQ2VsbEdhcCA9IDVcblxuICAgICAgICBmb3IgKGxldCBkIGluIGRpbWVuc2lvbnMpIHtcbiAgICAgICAgICAgIHRoaXMuc2VsZWN0ZWREaW1lbnNpb24gPSBkXG4gICAgICAgIH1cbiAgICB9XG5cbiAgICBvbkl0ZW1TZWxlY3QgPSAodHlwZTogc3RyaW5nLCBpZHg6IG51bWJlciwgaXNNdWx0aTogYm9vbGVhbikgPT4ge1xuICAgICAgICB0aGlzLmhhbmRsZXIodHlwZSwgaWR4LCBpc011bHRpKVxuICAgIH1cblxuXG4gICAgcmVuZGVyKCkge1xuICAgICAgICB0aGlzLmVsZW0gPSAkKCdkaXYnLCAnLnRva2VuLWRpbS1oZWF0bWFwJyxcbiAgICAgICAgICAgICQgPT4ge1xuICAgICAgICAgICAgICAgICQoJ2RpdicsICcuc2VsZWN0LWNvbnRhaW5lcicsICQgPT4ge1xuICAgICAgICAgICAgICAgICAgICAkKCdkaXYudGl0bGUuaW5saW5lJywgJ0RpbWVuc2lvbicsIHtmb3I6ICd0b2tlbi1kaW0taGVhdG1hcC1zZWxlY3QnfSlcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5kaW1TZWxlY3RFbGVtID0gJCgnc2VsZWN0JywgJyN0b2tlbi1kaW0taGVhdG1hcC1zZWxlY3QnLCB7b246IHtjaGFuZ2U6IHRoaXMub25EaW1TZWxlY3R9fSwgJCA9PiB7XG4gICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGxldCBkIGluIHRoaXMuZGltZW5zaW9ucykge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICQoJ29wdGlvbicsIGQsIHt2YWx1ZTogZH0pXG4gICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIH0pXG4gICAgICAgICAgICAgICAgfSlcbiAgICAgICAgICAgIH0pXG5cbiAgICAgICAgdGhpcy5kaW1TZWxlY3RFbGVtLnZhbHVlID0gdGhpcy5zZWxlY3RlZERpbWVuc2lvblxuICAgICAgICB0aGlzLnJlbmRlckNoYXJ0KClcblxuICAgICAgICByZXR1cm4gdGhpcy5lbGVtXG4gICAgfVxuXG4gICAgb25EaW1TZWxlY3QgPSAoZTogRXZlbnQpID0+IHtcbiAgICAgICAgZS5wcmV2ZW50RGVmYXVsdCgpXG4gICAgICAgIGUuc3RvcFByb3BhZ2F0aW9uKClcblxuICAgICAgICB0aGlzLnNlbGVjdGVkRGltZW5zaW9uID0gdGhpcy5kaW1TZWxlY3RFbGVtLnZhbHVlXG5cbiAgICAgICAgdGhpcy5yZW5kZXJDaGFydCgpXG4gICAgICAgIHRoaXMudG9rZW5EaW0gPSB0aGlzLmhhbmRsZXIodGhpcy5zZWxlY3RlZERpbWVuc2lvbilcbiAgICAgICAgdGhpcy5yZW5kZXJBdHRlbnRpb24oKVxuICAgIH1cblxuICAgIHJlbmRlckNoYXJ0KCkge1xuICAgICAgICBpZiAodGhpcy5jaGFydEVsZW0gIT0gbnVsbCkge1xuICAgICAgICAgICAgdGhpcy5jaGFydEVsZW0ucmVtb3ZlKClcbiAgICAgICAgICAgIHRoaXMuY2hhcnRFbGVtID0gbnVsbFxuICAgICAgICB9XG5cbiAgICAgICAgbGV0IGdyaWQ6IFNWR0dFbGVtZW50XG4gICAgICAgIGxldCBkaW0gPSB0aGlzLmRpbWVuc2lvbnNbdGhpcy5zZWxlY3RlZERpbWVuc2lvbl1cbiAgICAgICAgbGV0IHN2Z0F0dHJzID0ge1xuICAgICAgICAgICAgd2lkdGg6IHRoaXMuY2VsbFNpemUgKiBkaW0udmFsdWVzLmxlbmd0aCArIHRoaXMubGVmdExhYmVsc01hcmdpbixcbiAgICAgICAgICAgIGhlaWdodDogdGhpcy5jZWxsU2l6ZSAqIHRoaXMudG9rZW5zLmxlbmd0aCxcbiAgICAgICAgICAgIHZpZXdCb3g6IGAwIDAgJHt0aGlzLmNlbGxTaXplICogZGltLnZhbHVlcy5sZW5ndGggKyB0aGlzLmxlZnRMYWJlbHNNYXJnaW59ICR7dGhpcy5jZWxsU2l6ZSAqIHRoaXMudG9rZW5zLmxlbmd0aH0gYFxuICAgICAgICB9XG4gICAgICAgIHRoaXMuY2hhcnRFbGVtID0gJCgnc3ZnJywgJy5tYXRyaXgnLCBzdmdBdHRycywgJCA9PiB7XG4gICAgICAgICAgICBncmlkID0gJCgnZycsICcuZ3JpZCcsXG4gICAgICAgICAgICAgICAge3RyYW5zZm9ybTogYHRyYW5zbGF0ZSgke3RoaXMubGVmdExhYmVsc01hcmdpbn0sIDApYH0pXG5cbiAgICAgICAgICAgIGxldCBsYWJlbHMgPSBbXVxuICAgICAgICAgICAgJCgnZycsICcudG9rZW5fbGFiZWxzJyxcbiAgICAgICAgICAgICAgICB7dHJhbnNmb3JtOiBgdHJhbnNsYXRlKCR7dGhpcy5sZWZ0TGFiZWxzTWFyZ2luIC0gdGhpcy5sYWJlbENlbGxHYXB9LCAke3RoaXMuY2VsbFNpemUgLyAyfSlgfSxcbiAgICAgICAgICAgICAgICAkID0+IHtcbiAgICAgICAgICAgICAgICAgICAgZm9yIChsZXQgaSA9IDA7IGkgPCB0aGlzLnRva2Vucy5sZW5ndGg7ICsraSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgbGFiZWxzLnB1c2goJCgnZycsICcubGFiZWwnLCB7dHJhbnNmb3JtOiBgdHJhbnNsYXRlKDAsICR7dGhpcy5jZWxsU2l6ZSAqIGl9KWB9KSlcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH0pXG5cbiAgICAgICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgdGhpcy50b2tlbnMubGVuZ3RoOyArK2kpIHtcbiAgICAgICAgICAgICAgICBsYWJlbHNbaV0uYXBwZW5kQ2hpbGQodGhpcy50b2tlbkVsZW1zW2ldLnJlbmRlcih0aGlzLmNlbGxTaXplLCBmYWxzZSkpXG4gICAgICAgICAgICB9XG4gICAgICAgIH0pXG5cbiAgICAgICAgdGhpcy5jZWxscyA9IFtdXG4gICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgdGhpcy50b2tlbnMubGVuZ3RoOyArK2kpIHtcbiAgICAgICAgICAgIHRoaXMuY2VsbHMucHVzaChbXSlcbiAgICAgICAgICAgIGZvciAobGV0IGogPSAwOyBqIDwgZGltLnZhbHVlcy5sZW5ndGg7ICsraikge1xuICAgICAgICAgICAgICAgIHRoaXMuY2VsbHNbaV0ucHVzaChuZXcgQ2VsbFZpZXcodGhpcy5wbG90Q29sb3JzKSlcbiAgICAgICAgICAgICAgICBncmlkLmFwcGVuZENoaWxkKHRoaXMuY2VsbHNbaV1bal0ucmVuZGVyKGksIGosIHRoaXMuY2VsbFNpemUpKVxuICAgICAgICAgICAgfVxuICAgICAgICB9XG5cbiAgICAgICAgdGhpcy5lbGVtLmFwcGVuZENoaWxkKHRoaXMuY2hhcnRFbGVtKVxuICAgIH1cblxuICAgIHNldEF0dGVudGlvbih0b2tlbkRpbTogeyBbdmFsdWU6IERpbVZhbHVlXTogbnVtYmVyIH1bXSkge1xuICAgICAgICB0aGlzLnRva2VuRGltID0gdG9rZW5EaW1cbiAgICAgICAgdGhpcy5yZW5kZXJBdHRlbnRpb24oKVxuICAgIH1cblxuICAgIHNldFNlbGVjdGlvbih0b2tlblNlbGVjdDogeyBbcDogRGltVmFsdWVdOiBib29sZWFuIH0pIHtcbiAgICAgICAgdGhpcy5zZWxlY3RlZCA9IHRva2VuU2VsZWN0XG4gICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgdGhpcy50b2tlbnMubGVuZ3RoOyArK2kpIHtcbiAgICAgICAgICAgIGZvciAobGV0IGogPSAwOyBqIDwgdGhpcy5jZWxsc1tpXS5sZW5ndGg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50b2tlblZpZXdzLnB1c2godmlldylcbiAgICAgICAgfVxuXG4gICAgfVxuXG4gICAgYWRkQ2xpY2tIYW5kbGVyKHR5cGU6IHN0cmluZywgaGFuZGxlcjogU2VsZWN0Q2FsbGJhY2spIHtcbiAgICAgICAgZm9yIChsZXQgaSA9IDA7IGkgPCB0aGlzLnRva2Vucy5sZW5ndGg7ICsraSkge1xuICAgICAgICAgICAgdGhpcy50b2tlblZpZXdzW2ldLmFkZENsaWNrSGFuZGxlcih0eXBlLCBpLCBoYW5kbGVyKVxuICAgICAgICB9XG4gICAgfVxuXG4gICAgcmVuZGVyKCkge1xuICAgICAgICBsZXQgZWxlbSA9ICQoJ2RpdicsICcuc3JjLXRva2Vucy50ZXh0LXRva2VucycsICQgPT4ge1xuICAgICAgICAgICAgJCgnZGl2LnRpdGxlJywgdGhpcy50aXRsZSlcbiAgICAgICAgfSlcbiAgICAgICAgZm9yIChsZXQgaSA9IDA7IGkgPCB0aGlzLnRva2Vucy5sZW5ndGg7ICsraSkge1xuICAgICAgICAgICAgZWxlbS5hcHBlbmRDaGlsZCh0aGlzLnRva2VuVmlld3NbaV0ucmVuZGVyKCkpXG4gICAgICAgIH1cblxuICAgICAgICByZXR1cm4gZWxlbVxuICAgIH1cblxuICAgIHNldEF0dGVudGlvbihhdHRuOiBudW1iZXJbXSkge1xuICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IHRoaXMudG9rZW5zLmxlbmd0aDsgKytpKSB7XG4gICAgICAgICAgICB0aGlzLnRva2VuVmlld3NbaV0uc2V0QXR0bihhdHRuW2ldKVxuICAgICAgICB9XG4gICAgfVxuXG4gICAgc2V0U2VsZWN0aW9uKHNlbGVjdGVkOiB7IFtwOiBEaW1WYWx1ZV06IGJvb2xlYW4gfSkge1xuICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IHRoaXMudG9rZW5zLmxlbmd0aDsgKytpKSB7XG4gICAgICAgICAgICB0aGlzLnRva2VuVmlld3NbaV0uc2V0U2V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JlcltdW10pIHtcbiAgICBsZXQgbWF4ID0gMFxuICAgIGZvciAobGV0IGkgPSAwOyBpIDwgYXJyLmxlbmd0aDsgKytpKSB7XG4gICAgICAgIGZvciAobGV0IGogPSAwOyBqIDwgYXJyW2ldLmxlbmd0aDsgKytqKSB7XG4gICAgICAgICAgICBtYXggPSBNYXRoLm1heChtYXgsIGFycltpXVtqXSlcbiAgICAgICAgfVxuICAgIH1cbiAgICBpZiAobWF4IDw9IDApIHtcbiAgICAgICAgcmV0dXJuXG4gICAgfVxuXG4gICAgZm9yIChsZXQgaSA9IDA7IGkgPCBhcnIubGVuZ3RoOyArK2kpIHtcbiAgICAgICAgZm9yIChsZXQgaiA9IDA7IGogPCBhcnJbaV0ubGVuZ3RoOyArK2opIHtcbiAgICAgICAgICAgIGFycltpXVtqXSAvPSBtYXhcbiAgICAgICAgfVxuICAgIH1cbn1cblxuZXhwb3J0IGZ1bmN0aW9uIG5vcm1hbGl6ZUFycmF5KGFycjogbnVtYmVyW10pIHtcbiAgICBsZXQgc3VtID0gMFxuICAgIGZvciAobGV0IGogPSAwOyBqIDwgYXJyLmxlbmd0aDsgKytqKSB7XG4gICAgICAgIHN1bSArPSBhcnJbal1cbiAgICB9XG4gICAgaWYgKHN1bSA8PSAwKSB7XG4gICAgICAgIHJldHVyblxuICAgIH1cblxuICAgIGZvciAobGV0IGogPSAwOyBqIDwgYXJyLmxlbmd0aDsgKytqKSB7XG4gICAgICAgIGFycltqXSAvPSBzdW1cbiAgICB9XG59XG5cbmV4cG9ydCBmdW5jdGlvbiBtYXhOb3JtYWxpemVBcnJheShhcnI6IG51bWJlcltdKSB7XG4gICAgbGV0IG1heCA9IDBcbiAgICBmb3IgKGxldCBqID0gMDsgaiA8IGFyci5sZW5ndGg7ICsraikge1xuICAgICAgICBtYXggPSBNYXRoLm1heChtYXgsIGFycltqXSlcbiAgICB9XG4gICAgaWYgKG1heCA8PSAwKSB7XG4gICAgICAgIHJldHVyblxuICAgIH1cblxuICAgIGZvciAobGV0IGogPSAwOyBqIDwgYXJyLmxlbmd0aDsgKytqKSB7XG4gICAgICAgIGFycltqXSAvPSBtYXhcbiAgICB9XG59XG5cbmV4cG9ydCBmdW5jdGlvbiBtYXhOb3JtYWxpemVNYXAoYXJyOiB7IFtuYW1lOiBzdHJpbmddOiBudW1iZXIgfSkge1xuICAgIGxldCBtYXggPSAwXG4gICAgZm9yIChsZXQgaSBpbiBhcnIpIHtcbiAgICAgICAgbWF4ID0gTWF0aC5tYXgobWF4LCBhcnJbaV0pXG4gICAgfVxuICAgIGlmIChtYXggPD0gMCkge1xuICAgICAgICByZXR1cm5cbiAgICB9XG5cbiAgICBmb3IgKGxldCBpIGluIGFycikge1xuICAgICAgICBhcnJbaV0gLz0gbWF4XG4gICAgfVxufVxuXG5leHBvcnQgZnVuY3Rpb24gbWF4Tm9ybWFsaXplQXJyYXlNYXAoYXJyOiB7IFtuYW1lOiBzdHJpbmddOiBudW1iZXIgfVtdKSB7XG4gICAgbGV0IG1heCA9IDBcbiAgICBmb3IgKGxldCBkIG9mIGFycikge1xuICAgICAgICBmb3IgKGxldCBpIGluIGQpIHtcbiAgICAgICAgICAgIG1heCA9IE1hdGgubWF4KG1heCwgZFtpXSlcbiAgICAgICAgfVxuICAgIH1cbiAgICBpZiAobWF4IDw9IDApIHtcbiAgICAgICAgcmV0dXJuXG4gICAgfVxuXG4gICAgZm9yIChsZXQgZCBvZiBhcnIpIHtcbiAgICAgICAgZm9yIChsZXQgaSBpbiBkKSB7XG4gICAgICAgICAgICBkW2ldIC89IG1heFxuICAgICAgICB9XG4gICAgfVxufVxuXG5leHBvcnQgZnVuY3Rpb24gZ2V0RGltVmFsdWVzKGRpbTogc3RyaW5nLCBkaW1lbnNpb25zOiBEaW1lbnNpb25zKSB7XG4gICAgbGV0IGQgPSBkaW1lbnNpb25zW2RpbV1cblxuICAgIGlmIChkID09IG51bGwpIHtcbiAgICAgICAgcmV0dXJuIFsnbnVsbCddXG4gICAgfSBlbHNlIHt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FyYW1ldGVycyA9IHtcbiAgICAgICAgZGVmOiBudWxsLFxuICAgICAgICB0ZXh0OiBudWxsLFxuICAgICAgICBhdHRyczogbnVsbCxcbiAgICAgICAgZnVuYzogbnVsbCxcbiAgICAgICAgcGFyZW50OiBudWxsXG4gICAgfVxuICAgIGlmIChhcmdzLmxlbmd0aCA9PSAwKSB7XG4gICAgICAgIHBhcmFtcy5kZWYgPSBwYXJzZURlZmluaXRpb24oJ2RpdicpXG4gICAgfSBlbHNlIGlmICh0eXBlb2YgYXJnc1swXSA9PSAnc3RyaW5nJykge1xuICAgICAgICBsZXQgYXJnMCA9IDxzdHJpbmc+YXJnc1swXVxuICAgICAgICBpZiAoaXNWYWxpZFRhZyhhcmcwKSAmJiBhcmdzLmxlbmd0aCA+IDEgJiYgKHR5cGVvZiBhcmdzWzFdID09ICdzdHJpbmcnKSkge1xuICAgICAgICAgICAgY29uc3QgYXJnMSA9IDxzdHJpbmc+YXJnc1sxXVxuICAgICAgICAgICAgaWYgKGFyZzEubGVuZ3RoID4gMSAmJiAoYXJnMVswXSA9PT0gJy4nIHx8IGFyZzFbMF0gPT09ICcjJykpIHtcbiAgICAgICAgICAgICAgICBhcmcwICs9IGFyZzFcbiAgICAgICAgICAgICAgICBhcmdzID0gYXJncy5zbGljZSgxKVxuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICAgIHBhcmFtcy5kZWYgPSBwYXJzZURlZmluaXRpb24oYXJnMClcbiAgICAgICAgYXJncyA9IGFyZ3Muc2xpY2UoMSlcbiAgICB9XG5cbiAgICBmb3IgKGxldCBhcmcgb2YgYXJncykge1xuICAgICAgICBzd2l0Y2ggKHR5cGVvZiBhcmcpIHtcbiAgICAgICAgICAgIGNhc2UgXCJmdW5jdGlvblwiOlxuICAgICAgICAgICAgICAgIHBhcmFtcy5mdW5jID0gYXJnIGFzIFdleWFUZW1wbGF0ZUZ1bmN0aW9uXG4gICAgICAgICAgICAgICAgYnJlYWtcbiAgICAgICAgICAgIGNhc2UgXCJvYmplY3RcIjpcbiAgICAgICAgICAgICAgICBpZiAoYXJnIGluc3RhbmNlb2YgSFRNTEVsZW1lbnQgfHwgYXJnIGluc3RhbmNlb2YgU1ZHRWxlbWVudCkge1xuICAgICAgICAgICAgICAgICAgICBwYXJhbXMucGFyZW50ID0gYXJnIGFzIFdleWFFbGVtZW50XG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgcGFyYW1zLmF0dHJzID0gYXJnIGFzIEF0dHJpYnV0ZXNJbnRlcmZhY2VcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgYnJlYWtcbiAgICAgICAgICAgIGNhc2UgXCJzdHJpbmdcIjpcbiAgICAgICAgICAgICAgICBwYXJhbXMudGV4dCA9IGFyZyBhcyBzdHJpbmdcbiAgICAgICAgfVxuICAgIH1cbiAgICByZXR1cm4gcGFyYW1zXG59XG5cbmZ1bmN0aW9uIGRvbUFQSUNyZWF0ZSgpOiBXZXlhRWxlbWVudEZ1bmN0aW9uIHtcbiAgICBmdW5jdGlvbiBzZXRTdHlsZXMoZWxlbTogV2V5YUVsZW1lbnQsIHN0eWxlczogU3R5bGVzSW50ZXJmYWNlKSB7XG4gICAgICAgIGZvciAobGV0IGsgaW4gc3R5bGVzKSB7XG4gICAgICAgICAgICBsZXQgdiA9IHN0eWxlc1trXVxuICAgICAgICAgICAgaWYgKHYgIT0gbnVsbCkge1xuICAgICAgICAgICAgICAgIGVsZW0uc3R5bGUuc2V0UHJvcGVydHkoaywgdilcbiAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgZWxlbS5zdHlsZS5yZW1vdmVQcm9wZXJ0eShrKVxuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgfVxuXG4gICAgZnVuY3Rpb24gc2V0RXZlbnRzKGVsZW06IFdleWFFbGVtZW50LCBldmVudHM6IEV2ZW50c0ludGVyZmFjZSkge1xuICAgICAgICBmb3IgKGxldCBrIGluIGV2ZW50cykge1xuICAgICAgICAgICAgbGV0IG5hbWVzID0gay5zcGxpdCgnfCcpXG4gICAgICAgICAgICBmb3IgKGxldCBuYW1lIG9mIG5hbWVzKSB7XG4gICAgICAgICAgICAgICAgZWxlbS5hZGRFdmVudExpc3RlbmVyKG5hbWUsIGV2ZW50c1trXSwgZmFsc2UpXG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICB9XG5cbiAgICBmdW5jdGlvbiBzZXREYXRhKGVsZW06IFdleWFFbGVtZW50LCBkYXRhOiBEYXRhSW50ZXJmYWNlKSB7XG4gICAgICAgIGZvciAobGV0IGsgaW4gZGF0YSkge1xuICAgICAgICAgICAgZWxlbVtrXSA9IGRhdGFba11cbiAgICAgICAgfVxuICAgIH1cblxuICAgIGZ1bmN0aW9uIHNldEF0dHJpYnV0ZXMoZWxlbTogV2V5YUVsZW1lbnQsIGF0dHJzOiBBdHRyaWJ1dGVzSW50ZXJmYWNlKSB7XG4gICAgICAgIGZvciAobGV0IGsgaW4gYXR0cnMpIHtcbiAgICAgICAgICAgIGxldCB2ID0gYXR0cnNba11cbiAgICAgICAgICAgIHN3aXRjaCAoaykge1xuICAgICAgICAgICAgICAgIGNhc2UgXCJzdHlsZVwiOlxuICAgICAgICAgICAgICAgICAgICBzZXRTdHlsZXMoZWxlbSwgdiBhcyBTdHlsZXNJbnRlcmZhY2UpXG4gICAgICAgICAgICAgICAgICAgIGJyZWFrXG4gICAgICAgICAgICAgICAgY2FzZSBcIm9uXCI6XG4gICAgICAgICAgICAgICAgICAgIHNldEV2ZW50cyhlbGVtLCB2IGFzIEV2ZW50c0ludGVyZmFjZSlcbiAgICAgICAgICAgICAgICAgICAgYnJlYWtcbiAgICAgICAgICAgICAgICBjYXNlIFwiZGF0YVwiOlxuICAgICAgICAgICAgICAgICAgICBzZXREYXRhKGVsZW0sIHYgYXMgRGF0YUludGVyZmFjZSlcbiAgICAgICAgICAgICAgICAgICAgYnJlYWtcbiAgICAgICAgICAgICAgICBkZWZhdWx0OlxuICAgICAgICAgICAgICAgICAgICBpZiAodiAhPSBudWxsKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBlbGVtLnNldEF0dHJpYnV0ZShrLCB2IGFzIHN0cmluZylcbiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGVsZW0ucmVtb3ZlQXR0cmlidXRlKGspXG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgIH1cblxuICAgIGxldCBzZXRJZENsYXNzOiB0eXBlb2Ygc2V0SWRDbGFzc05ld1xuXG4gICAgZnVuY3Rpb24gc2V0SWRDbGFzc05ldyhlbGVtOiBXZXlhRWxlbWVudCwgaWRDbGFzczogRWxlbURlZikge1xuICAgICAgICBpZiAoaWRDbGFzcy5pZCAhPSBudWxsKSB7XG4gICAgICAgICAgICBlbGVtLmlkID0gaWRDbGFzcy5pZFxuICAgICAgICB9XG4gICAgICAgIGZvciAobGV0IGMgb2YgaWRDbGFzcy5jbGFzc2VzKSB7XG4gICAgICAgICAgICBlbGVtLmNsYXNzTGlzdC5hZGQoYylcbiAgICAgICAgfVxuICAgIH1cblxuICAgIGZ1bmN0aW9uIHNldElkQ2xhc3NGYWxsYmFjayhlbGVtOiBXZXlhRWxlbWVudCwgaWRDbGFzczogRWxlbURlZikge1xuICAgICAgICBpZiAoaWRDbGFzcy5pZCAhPSBudWxsKSB7XG4gICAgICAgICAgICBlbGVtLmlkID0gaWRDbGFzcy5pZFxuICAgICAgICB9XG4gICAgICAgIGlmIChpZENsYXNzLmNsYXNzZXMubGVuZ3RoID4gMCkge1xuICAgICAgICAgICAgbGV0IGNsYXNzTmFtZSA9IGlkQ2xhc3MuY2xhc3Nlcy5qb2luKFwiIFwiKVxuICAgICAgICAgICAgZWxlbS5zZXRBdHRyaWJ1dGUoXCJjbGFzc1wiLCBjbGFzc05hbWUpXG4gICAgICAgIH1cbiAgICB9XG5cbiAgICBmdW5jdGlvbiBzd2l0Y2hJZENsYXNzKCkge1xuICAgICAgICBsZXQgZWxlbSA9IEFQSS5kb2N1bWVudC5jcmVhdGVFbGVtZW50TlMoXCJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2Z1wiLCBcImdcIilcbiAgICAgICAgaWYgKCFlbGVtLmNsYXNzTGlzdCkge1xuICAgICAgICAgICAgc2V0SWRDbGFzcyA9IHNldElkQ2xhc3NGYWxsYmFja1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgc2V0SWRDbGFzcyA9IHNldElkQ2xhc3NOZXdcbiAgICAgICAgfVxuICAgIH1cblxuICAgIHN3aXRjaElkQ2xhc3MoKVxuXG4gICAgZnVuY3Rpb24gYXBwZW5kKHRoaXM6IFdleWFDb250ZXh0LCAuLi5hcmdzOiBXZXlhRWxlbWVudEFyZ1tdKTogV2V5YUVsZW1lbnQge1xuICAgICAgICBsZXQgcGFyYW1zID0gZ2V0UGFyYW1ldGVycyhhcmdzKVxuXG4gICAgICAgIGxldCBwYXJlbnQgPSBwYXJhbXMucGFyZW50XG4gICAgICAgIGlmICh0aGlzICE9IG51bGwgJiYgdGhpcy5fZWxlbSAhPSBudWxsKSB7XG4gICAgICAgICAgICBpZiAocGFyZW50ICE9IG51bGwpIHtcbiAgICAgICAgICAgICAgICB0aHJvdyBFcnJvcihcIkNhbm5vdCBzZXQgYSBwYXJlbnQgd2l0aGluIGEgY29udGV4dFwiKVxuICAgICAgICAgICAgfVxuICAgICAgICAgICAgcGFyZW50ID0gdGhpcy5fZWxlbVxuICAgICAgICB9XG5cbiAgICAgICAgbGV0IGVsZW06IFdleWFFbGVtZW50XG5cbiAgICAgICAgaWYgKHBhcmFtcy5kZWYgPT0gbnVsbCkge1xuICAgICAgICAgICAgZWxlbSA9IHBhcmVudFxuICAgICAgICB9IGVsc2Uge1xuXG4gICAgICAgICAgICBsZXQgdGFnID0gcGFyYW1zLmRlZi50YWdcbiAgICAgICAgICAgIGxldCBucyA9IE5BTUVTUEFDRVNbVEFHU19ESUNUW3RhZ11dXG5cbiAgICAgICAgICAgIGlmIChucyAhPSBudWxsKSB7XG4gICAgICAgICAgICAgICAgZWxlbSA9IEFQSS5kb2N1bWVudC5jcmVhdGVFbGVtZW50TlMobnMsIHRhZykgYXMgV2V5YUVsZW1lbnRcbiAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgZWxlbSA9IEFQSS5kb2N1bWVudC5jcmVhdGVFbGVtZW50KHRhZylcbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgaWYgKHBhcmFtcy5kZWYgIT0gbnVsbCkge1xuICAgICAgICAgICAgICAgIHNldElkQ2xhc3MoZWxlbSwgcGFyYW1zLmRlZilcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGlmIChwYXJhbXMuYXR0cnMgIT0gbnVsbCkge1xuICAgICAgICAgICAgICAgIHNldEF0dHJpYnV0ZXMoZWxlbSwgcGFyYW1zLmF0dHJzKVxuICAgICAgICAgICAgfVxuICAgICAgICAgICAgaWYgKHBhcmVudCAhPSBudWxsKSB7XG4gICAgICAgICAgICAgICAgcGFyZW50LmFwcGVuZENoaWxkKGVsZW0pXG4gICAgICAgICAgICB9XG4gICAgICAgIH1cblxuICAgICAgICBpZiAocGFyYW1zLmZ1bmMgIT0gbnVsbCkge1xuICAgICAgICAgICAgbGV0IHN0YXRlOiBXZXlhQ29udGV4dCA9IHtcbiAgICAgICAgICAgICAgICBfZWxlbTogZWxlbVxuICAgICAgICAgICAgfVxuICAgICAgICAgICAgcGFyYW1zLmZ1bmMoYXBwZW5kLmJpbmQoc3RhdGUpKVxuICAgICAgICB9IGVsc2UgaWYgKHBhcmFtcy50ZXh0ICE9IG51bGwpIHtcbiAgICAgICAgICAgIGVsZW0udGV4dENvbnRlbnQgPSBwYXJhbXMudGV4dFxuICAgICAgICB9XG4gICAgICAgIHJldHVybiBlbGVtXG4gICAgfVxuXG4gICAgcmV0dXJuIDxXZ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3RyaW5nVG9rZW5Mb3NzKHRva2VucywgdG9rZW5EYXRhLCBjb2xvcnMsIHBhZGRpbmdMZXNzKVxuICAgIGxldCBkaXYgPSBkb2N1bWVudC5jcmVhdGVFbGVtZW50KCdkaXYnKTtcbiAgICBkaXYuY2xhc3NOYW1lID0gXCJhdHRlbnRpb24tdmlzdWFsaXphdGlvblwiICsgKHRoZW1lID09PSAnbGlnaHQnID8gJycgOiAnIGRhcmstdGhlbWUnKVxuICAgIGRpdi5hcHBlbmRDaGlsZChsb3NzVmlldy5yZW5kZXIoKSk7XG5cbiAgICBkb2N1bWVudC5nZXRFbGVtZW50QnlJZChlbGVtSWQpLmFwcGVuZENoaWxkKGRpdilcblxuICAgIGxvc3NWaWV3LnVwZGF0ZU1lbnVQb3NpdGlvbigpXG59XG4iLCIvLyBleHRyYWN0ZWQgYnkgbWluaS1jc3MtZXh0cmFjdC1wbHVnaW5cbmV4cG9ydCB7fTsiXSwibmFtZXMiOltdLCJzb3VyY2VSb290IjoiIn0= \ No newline at end of file diff --git a/ui/src/colors.ts b/ui/src/colors.ts index 5033dbe..567ed80 100644 --- a/ui/src/colors.ts +++ b/ui/src/colors.ts @@ -75,7 +75,7 @@ export class PlotColors { public getInterpolatedColor(value: number, chart: string) { if (this.theme === 'dark') { - value = 0.2 + (value) * 0.8 + value = 0.3 + (1 - value) * 0.7 } else { value = value * 0.8 }