diff --git a/Makefile b/Makefile
index d032459..20ccc14 100644
--- a/Makefile
+++ b/Makefile
@@ -45,13 +45,13 @@ test:
.PHONY: install
install: $(wildcard *.go)
- CGO_ENABLED=0 go install -v -ldflags '-w $(LDFLAGS)'
+ go install -v -ldflags '-w $(LDFLAGS)'
.PHONY: build
build: $(EXECUTABLE)
$(EXECUTABLE): $(SOURCES)
- CGO_ENABLED=0 go build -v -ldflags '-w $(LDFLAGS)' -o $@
+ go build -v -ldflags '-w $(LDFLAGS)' -o $@
.PHONY: docker
docker:
diff --git a/ana.go b/ana.go
index 06dbc89..0a3a066 100644
--- a/ana.go
+++ b/ana.go
@@ -1,9 +1,9 @@
package main
import (
- "github.com/dannyvankooten/ana/commands"
- "github.com/dannyvankooten/ana/count"
- "github.com/dannyvankooten/ana/datastore"
+ "github.com/dannyvankooten/ana/pkg/commands"
+ "github.com/dannyvankooten/ana/pkg/count"
+ "github.com/dannyvankooten/ana/pkg/datastore"
"github.com/joho/godotenv"
"github.com/robfig/cron"
"gopkg.in/alecthomas/kingpin.v2"
diff --git a/assets/dist/css/styles.css b/assets/dist/css/styles.css
new file mode 100644
index 0000000..996d027
--- /dev/null
+++ b/assets/dist/css/styles.css
@@ -0,0 +1,759 @@
+/*! normalize.css v5.0.0 | MIT License | github.com/necolas/normalize.css */
+/**
+ * 1. Change the default font family in all browsers (opinionated).
+ * 2. Correct the line height in all browsers.
+ * 3. Prevent adjustments of font size after orientation changes in
+ * IE on Windows Phone and in iOS.
+ */
+/* Document
+ ========================================================================== */
+html {
+ font-family: sans-serif;
+ /* 1 */
+ line-height: 1.15;
+ /* 2 */
+ -ms-text-size-adjust: 100%;
+ /* 3 */
+ -webkit-text-size-adjust: 100%;
+ /* 3 */ }
+
+/* Sections
+ ========================================================================== */
+/**
+ * Remove the margin in all browsers (opinionated).
+ */
+body {
+ margin: 0; }
+
+/**
+ * Add the correct display in IE 9-.
+ */
+article,
+aside,
+footer,
+header,
+nav,
+section {
+ display: block; }
+
+/**
+ * Correct the font size and margin on `h1` elements within `section` and
+ * `article` contexts in Chrome, Firefox, and Safari.
+ */
+h1 {
+ font-size: 2em;
+ margin: 0.67em 0; }
+
+/* Grouping content
+ ========================================================================== */
+/**
+ * Add the correct display in IE 9-.
+ * 1. Add the correct display in IE.
+ */
+figcaption,
+figure,
+main {
+ /* 1 */
+ display: block; }
+
+/**
+ * Add the correct margin in IE 8.
+ */
+figure {
+ margin: 1em 40px; }
+
+/**
+ * 1. Add the correct box sizing in Firefox.
+ * 2. Show the overflow in Edge and IE.
+ */
+hr {
+ box-sizing: content-box;
+ /* 1 */
+ height: 0;
+ /* 1 */
+ overflow: visible;
+ /* 2 */ }
+
+/**
+ * 1. Correct the inheritance and scaling of font size in all browsers.
+ * 2. Correct the odd `em` font sizing in all browsers.
+ */
+pre {
+ font-family: monospace, monospace;
+ /* 1 */
+ font-size: 1em;
+ /* 2 */ }
+
+/* Text-level semantics
+ ========================================================================== */
+/**
+ * 1. Remove the gray background on active links in IE 10.
+ * 2. Remove gaps in links underline in iOS 8+ and Safari 8+.
+ */
+a {
+ background-color: transparent;
+ /* 1 */
+ -webkit-text-decoration-skip: objects;
+ /* 2 */ }
+
+/**
+ * Remove the outline on focused links when they are also active or hovered
+ * in all browsers (opinionated).
+ */
+a:active,
+a:hover {
+ outline-width: 0; }
+
+/**
+ * 1. Remove the bottom border in Firefox 39-.
+ * 2. Add the correct text decoration in Chrome, Edge, IE, Opera, and Safari.
+ */
+abbr[title] {
+ border-bottom: none;
+ /* 1 */
+ text-decoration: underline;
+ /* 2 */
+ text-decoration: underline dotted;
+ /* 2 */ }
+
+/**
+ * Prevent the duplicate application of `bolder` by the next rule in Safari 6.
+ */
+b,
+strong {
+ font-weight: inherit; }
+
+/**
+ * Add the correct font weight in Chrome, Edge, and Safari.
+ */
+b,
+strong {
+ font-weight: bolder; }
+
+/**
+ * 1. Correct the inheritance and scaling of font size in all browsers.
+ * 2. Correct the odd `em` font sizing in all browsers.
+ */
+code,
+kbd,
+samp {
+ font-family: monospace, monospace;
+ /* 1 */
+ font-size: 1em;
+ /* 2 */ }
+
+/**
+ * Add the correct font style in Android 4.3-.
+ */
+dfn {
+ font-style: italic; }
+
+/**
+ * Add the correct background and color in IE 9-.
+ */
+mark {
+ background-color: #ff0;
+ color: #000; }
+
+/**
+ * Add the correct font size in all browsers.
+ */
+small {
+ font-size: 80%; }
+
+/**
+ * Prevent `sub` and `sup` elements from affecting the line height in
+ * all browsers.
+ */
+sub,
+sup {
+ font-size: 75%;
+ line-height: 0;
+ position: relative;
+ vertical-align: baseline; }
+
+sub {
+ bottom: -0.25em; }
+
+sup {
+ top: -0.5em; }
+
+/* Embedded content
+ ========================================================================== */
+/**
+ * Add the correct display in IE 9-.
+ */
+audio,
+video {
+ display: inline-block; }
+
+/**
+ * Add the correct display in iOS 4-7.
+ */
+audio:not([controls]) {
+ display: none;
+ height: 0; }
+
+/**
+ * Remove the border on images inside links in IE 10-.
+ */
+img {
+ border-style: none; }
+
+/**
+ * Hide the overflow in IE.
+ */
+svg:not(:root) {
+ overflow: hidden; }
+
+/* Forms
+ ========================================================================== */
+/**
+ * 1. Change the font styles in all browsers (opinionated).
+ * 2. Remove the margin in Firefox and Safari.
+ */
+button,
+input,
+optgroup,
+select,
+textarea {
+ font-family: sans-serif;
+ /* 1 */
+ font-size: 100%;
+ /* 1 */
+ line-height: 1.15;
+ /* 1 */
+ margin: 0;
+ /* 2 */ }
+
+/**
+ * Show the overflow in IE.
+ * 1. Show the overflow in Edge.
+ */
+button,
+input {
+ /* 1 */
+ overflow: visible; }
+
+/**
+ * Remove the inheritance of text transform in Edge, Firefox, and IE.
+ * 1. Remove the inheritance of text transform in Firefox.
+ */
+button,
+select {
+ /* 1 */
+ text-transform: none; }
+
+/**
+ * 1. Prevent a WebKit bug where (2) destroys native `audio` and `video`
+ * controls in Android 4.
+ * 2. Correct the inability to style clickable types in iOS and Safari.
+ */
+button,
+html [type="button"],
+[type="reset"],
+[type="submit"] {
+ -webkit-appearance: button;
+ /* 2 */ }
+
+/**
+ * Remove the inner border and padding in Firefox.
+ */
+button::-moz-focus-inner,
+[type="button"]::-moz-focus-inner,
+[type="reset"]::-moz-focus-inner,
+[type="submit"]::-moz-focus-inner {
+ border-style: none;
+ padding: 0; }
+
+/**
+ * Restore the focus styles unset by the previous rule.
+ */
+button:-moz-focusring,
+[type="button"]:-moz-focusring,
+[type="reset"]:-moz-focusring,
+[type="submit"]:-moz-focusring {
+ outline: 1px dotted ButtonText; }
+
+/**
+ * Change the border, margin, and padding in all browsers (opinionated).
+ */
+fieldset {
+ border: 1px solid #c0c0c0;
+ margin: 0 2px;
+ padding: 0.35em 0.625em 0.75em; }
+
+/**
+ * 1. Correct the text wrapping in Edge and IE.
+ * 2. Correct the color inheritance from `fieldset` elements in IE.
+ * 3. Remove the padding so developers are not caught out when they zero out
+ * `fieldset` elements in all browsers.
+ */
+legend {
+ box-sizing: border-box;
+ /* 1 */
+ color: inherit;
+ /* 2 */
+ display: table;
+ /* 1 */
+ max-width: 100%;
+ /* 1 */
+ padding: 0;
+ /* 3 */
+ white-space: normal;
+ /* 1 */ }
+
+/**
+ * 1. Add the correct display in IE 9-.
+ * 2. Add the correct vertical alignment in Chrome, Firefox, and Opera.
+ */
+progress {
+ display: inline-block;
+ /* 1 */
+ vertical-align: baseline;
+ /* 2 */ }
+
+/**
+ * Remove the default vertical scrollbar in IE.
+ */
+textarea {
+ overflow: auto; }
+
+/**
+ * 1. Add the correct box sizing in IE 10-.
+ * 2. Remove the padding in IE 10-.
+ */
+[type="checkbox"],
+[type="radio"] {
+ box-sizing: border-box;
+ /* 1 */
+ padding: 0;
+ /* 2 */ }
+
+/**
+ * Correct the cursor style of increment and decrement buttons in Chrome.
+ */
+[type="number"]::-webkit-inner-spin-button,
+[type="number"]::-webkit-outer-spin-button {
+ height: auto; }
+
+/**
+ * 1. Correct the odd appearance in Chrome and Safari.
+ * 2. Correct the outline style in Safari.
+ */
+[type="search"] {
+ -webkit-appearance: textfield;
+ /* 1 */
+ outline-offset: -2px;
+ /* 2 */ }
+
+/**
+ * Remove the inner padding and cancel buttons in Chrome and Safari on macOS.
+ */
+[type="search"]::-webkit-search-cancel-button,
+[type="search"]::-webkit-search-decoration {
+ -webkit-appearance: none; }
+
+/**
+ * 1. Correct the inability to style clickable types in iOS and Safari.
+ * 2. Change font properties to `inherit` in Safari.
+ */
+::-webkit-file-upload-button {
+ -webkit-appearance: button;
+ /* 1 */
+ font: inherit;
+ /* 2 */ }
+
+/* Interactive
+ ========================================================================== */
+/*
+ * Add the correct display in IE 9-.
+ * 1. Add the correct display in Edge, IE, and Firefox.
+ */
+details,
+menu {
+ display: block; }
+
+/*
+ * Add the correct display in all browsers.
+ */
+summary {
+ display: list-item; }
+
+/* Scripting
+ ========================================================================== */
+/**
+ * Add the correct display in IE 9-.
+ */
+canvas {
+ display: inline-block; }
+
+/**
+ * Add the correct display in IE.
+ */
+template {
+ display: none; }
+
+/* Hidden
+ ========================================================================== */
+/**
+ * Add the correct display in IE 10-.
+ */
+[hidden] {
+ display: none; }
+
+.pull-right {
+ float: right; }
+
+.pull-left {
+ float: left; }
+
+.cf:before,
+.cf:after {
+ content: " ";
+ /* 1 */
+ display: table;
+ /* 2 */ }
+
+.cf:after {
+ clear: both; }
+
+.tiny-margin {
+ margin-top: 10px;
+ margin-bottom: 10px; }
+
+.small-margin {
+ margin-top: 20px;
+ margin-bottom: 20px; }
+
+.medium-margin {
+ margin-top: 40px;
+ margin-bottom: 40px; }
+
+.no-margin {
+ margin: 0 !important; }
+
+.clear {
+ clear: both; }
+
+.big {
+ font-size: 32px; }
+
+.muted {
+ color: #888; }
+
+.italic {
+ font-style: italic; }
+
+.center-text {
+ text-align: center; }
+
+.positive {
+ color: limegreen; }
+ .positive:before {
+ content: "+"; }
+
+.negative {
+ color: orangered; }
+
+.inline {
+ display: inline-block; }
+
+.small-margin-right {
+ margin-right: 20px; }
+
+@media (min-width: 680px) {
+ .row {
+ margin-left: -10px;
+ margin-right: -10px; }
+ .row:before, .row:after {
+ content: " ";
+ display: table; }
+ .row:after {
+ clear: both; }
+ .col,
+ .col-1,
+ .col-2,
+ .col-3,
+ .col-4,
+ .col-5,
+ .col-6 {
+ float: left;
+ padding-left: 10px;
+ padding-right: 10px;
+ box-sizing: border-box; }
+ .col-1 {
+ width: 16.66667%; }
+ .col-2 {
+ width: 33.33333%; }
+ .col-3 {
+ width: 50%; }
+ .col-4 {
+ width: 66.66667%; }
+ .col-5 {
+ width: 83.33333%; }
+ .col-6 {
+ width: 100%; } }
+
+label {
+ font-weight: bold;
+ display: block;
+ margin-bottom: 2px; }
+
+input {
+ padding: 8px;
+ border: 1px solid #999;
+ min-width: 260px; }
+ input:focus {
+ border: 1px solid #33C3F0;
+ outline: 0; }
+
+input[type="checkbox"],
+input[type="radio"] {
+ min-width: auto;
+ vertical-align: middle;
+ width: 16px;
+ height: 16px; }
+
+button,
+input[type="submit"],
+input[type="button"],
+.button {
+ min-width: auto;
+ padding: 10px 20px;
+ cursor: pointer;
+ border: 0;
+ color: white;
+ background: #09F;
+ font-weight: bold; }
+ button.active, button:hover, button:focus,
+ input[type="submit"].active,
+ input[type="submit"]:hover,
+ input[type="submit"]:focus,
+ input[type="button"].active,
+ input[type="button"]:hover,
+ input[type="button"]:focus,
+ .button.active,
+ .button:hover,
+ .button:focus {
+ background: #005c99; }
+
+table {
+ width: 100%;
+ min-width: 100%;
+ border-collapse: collapse; }
+ table tbody > tr:nth-of-type(odd) {
+ background-color: #FAFAFA; }
+ table tbody > tr:hover {
+ background-color: #F6F6F6; }
+ table thead th {
+ border-top: 0;
+ border-bottom: 2px solid #ddd; }
+ table th {
+ color: #222; }
+ table th, table td {
+ text-align: left;
+ border-top: 1px solid #ddd;
+ padding: 8px; }
+
+* {
+ box-sizing: border-box; }
+
+body {
+ font-family: Raleway, HelveticaNeue, "Helvetica Neue", Helvetica, Arial, sans-serif;
+ font-size: 14px;
+ color: #444;
+ background: #f5f5f5; }
+
+h1, h2, h3, h4, h5 {
+ color: #111;
+ margin: 0; }
+ h1 small, h2 small, h3 small, h4 small, h5 small {
+ font-weight: normal;
+ font-style: italic;
+ color: #666; }
+
+h5 {
+ font-size: 15px; }
+
+a {
+ color: #09f;
+ text-decoration: none; }
+ a:hover, a:focus {
+ text-decoration: underline; }
+
+.container {
+ max-width: 1020px;
+ padding: 0 20px;
+ margin-left: auto;
+ margin-right: auto; }
+
+.header {
+ margin: 20px 0; }
+
+.header-bar {
+ background: black;
+ color: white;
+ margin-bottom: 20px;
+ padding: 12px 0;
+ line-height: 32px;
+ font-weight: bold; }
+ .header-bar h1, .header-bar h2, .header-bar h3, .header-bar a {
+ color: white; }
+ .header-bar .subtitle {
+ color: #BBB;
+ margin-left: 10px;
+ font-size: 20px; }
+
+.block {
+ width: auto;
+ background: white;
+ padding: 20px;
+ margin-bottom: 20px;
+ position: relative; }
+ .block h1, .block h2, .block h3 {
+ margin-bottom: 20px; }
+
+.block-float {
+ margin-right: 20px;
+ float: left; }
+
+.loading-overlay {
+ position: absolute;
+ background: rgba(255, 255, 255, 0.9);
+ width: 100%;
+ height: 100%;
+ z-index: 10;
+ font-weight: bold;
+ margin: -20px;
+ display: flex;
+ align-items: center;
+ justify-content: center; }
+ .loading-overlay div {
+ margin: 50px;
+ height: 28px;
+ width: 28px;
+ animation: rotate 0.8s infinite linear;
+ border: 8px solid #AAA;
+ border-right-color: transparent;
+ border-radius: 50%; }
+
+@keyframes rotate {
+ 0% {
+ transform: rotate(0deg); }
+ 100% {
+ transform: rotate(360deg); } }
+
+.count {
+ font-weight: bold;
+ font-size: 120%; }
+
+.notification {
+ top: 20px;
+ left: 0;
+ right: 0;
+ text-align: center;
+ position: fixed;
+ color: white; }
+ .notification div {
+ color: white;
+ display: inline-block;
+ padding: 6px 12px;
+ background: green; }
+ .notification .notification-error {
+ background: red; }
+
+h1 {
+ font-size: 28px; }
+
+h2 {
+ font-size: 24px; }
+
+h3 {
+ font-size: 20px; }
+
+h4 {
+ font-size: 16px; }
+
+small {
+ font-size: 70%; }
+
+.d3-tip span {
+ color: #ff00c7; }
+
+.domain {
+ display: none; }
+
+.axis line {
+ stroke-width: 1px;
+ stroke: #eee;
+ shape-rendering: crispedges; }
+
+.axis text {
+ fill: #888; }
+
+rect {
+ fill: #66b5ff;
+ fill-opacity: 0.5; }
+
+rect:hover {
+ fill-opacity: 1; }
+
+.sub-bar rect {
+ fill: #0069cc; }
+
+.d3-tip {
+ line-height: 1;
+ font-weight: bold;
+ padding: 12px;
+ background: rgba(0, 0, 0, 0.8);
+ color: #fff;
+ border-radius: 2px;
+ pointer-events: none; }
+
+/* Creates a small triangle extender for the tooltip */
+.d3-tip:after {
+ box-sizing: border-box;
+ display: inline;
+ font-size: 10px;
+ width: 100%;
+ line-height: 1;
+ color: rgba(0, 0, 0, 0.8);
+ position: absolute;
+ pointer-events: none; }
+
+.d3-tip h5 {
+ color: #CCC; }
+
+.d3-tip span {
+ color: lightgreen; }
+
+/* Northward tooltips */
+.d3-tip.n:after {
+ content: "\25BC";
+ margin: -1px 0 0 0;
+ top: 100%;
+ left: 0;
+ text-align: center; }
+
+/* Eastward tooltips */
+.d3-tip.e:after {
+ content: "\25C0";
+ margin: -4px 0 0 0;
+ top: 50%;
+ left: -8px; }
+
+/* Southward tooltips */
+.d3-tip.s:after {
+ content: "\25B2";
+ margin: 0 0 1px 0;
+ top: -8px;
+ left: 0;
+ text-align: center; }
+
+/* Westward tooltips */
+.d3-tip.w:after {
+ content: "\25B6";
+ margin: -4px 0 0 -1px;
+ top: 50%;
+ left: 100%; }
diff --git a/assets/img/country-flags/ad.png b/assets/dist/img/country-flags/ad.png
similarity index 100%
rename from assets/img/country-flags/ad.png
rename to assets/dist/img/country-flags/ad.png
diff --git a/assets/img/country-flags/ae.png b/assets/dist/img/country-flags/ae.png
similarity index 100%
rename from assets/img/country-flags/ae.png
rename to assets/dist/img/country-flags/ae.png
diff --git a/assets/img/country-flags/af.png b/assets/dist/img/country-flags/af.png
similarity index 100%
rename from assets/img/country-flags/af.png
rename to assets/dist/img/country-flags/af.png
diff --git a/assets/img/country-flags/ag.png b/assets/dist/img/country-flags/ag.png
similarity index 100%
rename from assets/img/country-flags/ag.png
rename to assets/dist/img/country-flags/ag.png
diff --git a/assets/img/country-flags/ai.png b/assets/dist/img/country-flags/ai.png
similarity index 100%
rename from assets/img/country-flags/ai.png
rename to assets/dist/img/country-flags/ai.png
diff --git a/assets/img/country-flags/al.png b/assets/dist/img/country-flags/al.png
similarity index 100%
rename from assets/img/country-flags/al.png
rename to assets/dist/img/country-flags/al.png
diff --git a/assets/img/country-flags/am.png b/assets/dist/img/country-flags/am.png
similarity index 100%
rename from assets/img/country-flags/am.png
rename to assets/dist/img/country-flags/am.png
diff --git a/assets/img/country-flags/ao.png b/assets/dist/img/country-flags/ao.png
similarity index 100%
rename from assets/img/country-flags/ao.png
rename to assets/dist/img/country-flags/ao.png
diff --git a/assets/img/country-flags/ar.png b/assets/dist/img/country-flags/ar.png
similarity index 100%
rename from assets/img/country-flags/ar.png
rename to assets/dist/img/country-flags/ar.png
diff --git a/assets/img/country-flags/as.png b/assets/dist/img/country-flags/as.png
similarity index 100%
rename from assets/img/country-flags/as.png
rename to assets/dist/img/country-flags/as.png
diff --git a/assets/img/country-flags/at.png b/assets/dist/img/country-flags/at.png
similarity index 100%
rename from assets/img/country-flags/at.png
rename to assets/dist/img/country-flags/at.png
diff --git a/assets/img/country-flags/au.png b/assets/dist/img/country-flags/au.png
similarity index 100%
rename from assets/img/country-flags/au.png
rename to assets/dist/img/country-flags/au.png
diff --git a/assets/img/country-flags/aw.png b/assets/dist/img/country-flags/aw.png
similarity index 100%
rename from assets/img/country-flags/aw.png
rename to assets/dist/img/country-flags/aw.png
diff --git a/assets/img/country-flags/ax.png b/assets/dist/img/country-flags/ax.png
similarity index 100%
rename from assets/img/country-flags/ax.png
rename to assets/dist/img/country-flags/ax.png
diff --git a/assets/img/country-flags/az.png b/assets/dist/img/country-flags/az.png
similarity index 100%
rename from assets/img/country-flags/az.png
rename to assets/dist/img/country-flags/az.png
diff --git a/assets/img/country-flags/ba.png b/assets/dist/img/country-flags/ba.png
similarity index 100%
rename from assets/img/country-flags/ba.png
rename to assets/dist/img/country-flags/ba.png
diff --git a/assets/img/country-flags/bb.png b/assets/dist/img/country-flags/bb.png
similarity index 100%
rename from assets/img/country-flags/bb.png
rename to assets/dist/img/country-flags/bb.png
diff --git a/assets/img/country-flags/bd.png b/assets/dist/img/country-flags/bd.png
similarity index 100%
rename from assets/img/country-flags/bd.png
rename to assets/dist/img/country-flags/bd.png
diff --git a/assets/img/country-flags/be.png b/assets/dist/img/country-flags/be.png
similarity index 100%
rename from assets/img/country-flags/be.png
rename to assets/dist/img/country-flags/be.png
diff --git a/assets/img/country-flags/bf.png b/assets/dist/img/country-flags/bf.png
similarity index 100%
rename from assets/img/country-flags/bf.png
rename to assets/dist/img/country-flags/bf.png
diff --git a/assets/img/country-flags/bg.png b/assets/dist/img/country-flags/bg.png
similarity index 100%
rename from assets/img/country-flags/bg.png
rename to assets/dist/img/country-flags/bg.png
diff --git a/assets/img/country-flags/bh.png b/assets/dist/img/country-flags/bh.png
similarity index 100%
rename from assets/img/country-flags/bh.png
rename to assets/dist/img/country-flags/bh.png
diff --git a/assets/img/country-flags/bi.png b/assets/dist/img/country-flags/bi.png
similarity index 100%
rename from assets/img/country-flags/bi.png
rename to assets/dist/img/country-flags/bi.png
diff --git a/assets/img/country-flags/bj.png b/assets/dist/img/country-flags/bj.png
similarity index 100%
rename from assets/img/country-flags/bj.png
rename to assets/dist/img/country-flags/bj.png
diff --git a/assets/img/country-flags/bm.png b/assets/dist/img/country-flags/bm.png
similarity index 100%
rename from assets/img/country-flags/bm.png
rename to assets/dist/img/country-flags/bm.png
diff --git a/assets/img/country-flags/bn.png b/assets/dist/img/country-flags/bn.png
similarity index 100%
rename from assets/img/country-flags/bn.png
rename to assets/dist/img/country-flags/bn.png
diff --git a/assets/img/country-flags/bo.png b/assets/dist/img/country-flags/bo.png
similarity index 100%
rename from assets/img/country-flags/bo.png
rename to assets/dist/img/country-flags/bo.png
diff --git a/assets/img/country-flags/br.png b/assets/dist/img/country-flags/br.png
similarity index 100%
rename from assets/img/country-flags/br.png
rename to assets/dist/img/country-flags/br.png
diff --git a/assets/img/country-flags/bs.png b/assets/dist/img/country-flags/bs.png
similarity index 100%
rename from assets/img/country-flags/bs.png
rename to assets/dist/img/country-flags/bs.png
diff --git a/assets/img/country-flags/bt.png b/assets/dist/img/country-flags/bt.png
similarity index 100%
rename from assets/img/country-flags/bt.png
rename to assets/dist/img/country-flags/bt.png
diff --git a/assets/img/country-flags/bw.png b/assets/dist/img/country-flags/bw.png
similarity index 100%
rename from assets/img/country-flags/bw.png
rename to assets/dist/img/country-flags/bw.png
diff --git a/assets/img/country-flags/by.png b/assets/dist/img/country-flags/by.png
similarity index 100%
rename from assets/img/country-flags/by.png
rename to assets/dist/img/country-flags/by.png
diff --git a/assets/img/country-flags/bz.png b/assets/dist/img/country-flags/bz.png
similarity index 100%
rename from assets/img/country-flags/bz.png
rename to assets/dist/img/country-flags/bz.png
diff --git a/assets/img/country-flags/ca.png b/assets/dist/img/country-flags/ca.png
similarity index 100%
rename from assets/img/country-flags/ca.png
rename to assets/dist/img/country-flags/ca.png
diff --git a/assets/img/country-flags/cc.png b/assets/dist/img/country-flags/cc.png
similarity index 100%
rename from assets/img/country-flags/cc.png
rename to assets/dist/img/country-flags/cc.png
diff --git a/assets/img/country-flags/cd.png b/assets/dist/img/country-flags/cd.png
similarity index 100%
rename from assets/img/country-flags/cd.png
rename to assets/dist/img/country-flags/cd.png
diff --git a/assets/img/country-flags/cf.png b/assets/dist/img/country-flags/cf.png
similarity index 100%
rename from assets/img/country-flags/cf.png
rename to assets/dist/img/country-flags/cf.png
diff --git a/assets/img/country-flags/cg.png b/assets/dist/img/country-flags/cg.png
similarity index 100%
rename from assets/img/country-flags/cg.png
rename to assets/dist/img/country-flags/cg.png
diff --git a/assets/img/country-flags/ch.png b/assets/dist/img/country-flags/ch.png
similarity index 100%
rename from assets/img/country-flags/ch.png
rename to assets/dist/img/country-flags/ch.png
diff --git a/assets/img/country-flags/ci.png b/assets/dist/img/country-flags/ci.png
similarity index 100%
rename from assets/img/country-flags/ci.png
rename to assets/dist/img/country-flags/ci.png
diff --git a/assets/img/country-flags/ck.png b/assets/dist/img/country-flags/ck.png
similarity index 100%
rename from assets/img/country-flags/ck.png
rename to assets/dist/img/country-flags/ck.png
diff --git a/assets/img/country-flags/cl.png b/assets/dist/img/country-flags/cl.png
similarity index 100%
rename from assets/img/country-flags/cl.png
rename to assets/dist/img/country-flags/cl.png
diff --git a/assets/img/country-flags/cm.png b/assets/dist/img/country-flags/cm.png
similarity index 100%
rename from assets/img/country-flags/cm.png
rename to assets/dist/img/country-flags/cm.png
diff --git a/assets/img/country-flags/cn.png b/assets/dist/img/country-flags/cn.png
similarity index 100%
rename from assets/img/country-flags/cn.png
rename to assets/dist/img/country-flags/cn.png
diff --git a/assets/img/country-flags/co.png b/assets/dist/img/country-flags/co.png
similarity index 100%
rename from assets/img/country-flags/co.png
rename to assets/dist/img/country-flags/co.png
diff --git a/assets/img/country-flags/cr.png b/assets/dist/img/country-flags/cr.png
similarity index 100%
rename from assets/img/country-flags/cr.png
rename to assets/dist/img/country-flags/cr.png
diff --git a/assets/img/country-flags/cu.png b/assets/dist/img/country-flags/cu.png
similarity index 100%
rename from assets/img/country-flags/cu.png
rename to assets/dist/img/country-flags/cu.png
diff --git a/assets/img/country-flags/cv.png b/assets/dist/img/country-flags/cv.png
similarity index 100%
rename from assets/img/country-flags/cv.png
rename to assets/dist/img/country-flags/cv.png
diff --git a/assets/img/country-flags/cw.png b/assets/dist/img/country-flags/cw.png
similarity index 100%
rename from assets/img/country-flags/cw.png
rename to assets/dist/img/country-flags/cw.png
diff --git a/assets/img/country-flags/cx.png b/assets/dist/img/country-flags/cx.png
similarity index 100%
rename from assets/img/country-flags/cx.png
rename to assets/dist/img/country-flags/cx.png
diff --git a/assets/img/country-flags/cy.png b/assets/dist/img/country-flags/cy.png
similarity index 100%
rename from assets/img/country-flags/cy.png
rename to assets/dist/img/country-flags/cy.png
diff --git a/assets/img/country-flags/cz.png b/assets/dist/img/country-flags/cz.png
similarity index 100%
rename from assets/img/country-flags/cz.png
rename to assets/dist/img/country-flags/cz.png
diff --git a/assets/img/country-flags/de.png b/assets/dist/img/country-flags/de.png
similarity index 100%
rename from assets/img/country-flags/de.png
rename to assets/dist/img/country-flags/de.png
diff --git a/assets/img/country-flags/dj.png b/assets/dist/img/country-flags/dj.png
similarity index 100%
rename from assets/img/country-flags/dj.png
rename to assets/dist/img/country-flags/dj.png
diff --git a/assets/img/country-flags/dk.png b/assets/dist/img/country-flags/dk.png
similarity index 100%
rename from assets/img/country-flags/dk.png
rename to assets/dist/img/country-flags/dk.png
diff --git a/assets/img/country-flags/dm.png b/assets/dist/img/country-flags/dm.png
similarity index 100%
rename from assets/img/country-flags/dm.png
rename to assets/dist/img/country-flags/dm.png
diff --git a/assets/img/country-flags/do.png b/assets/dist/img/country-flags/do.png
similarity index 100%
rename from assets/img/country-flags/do.png
rename to assets/dist/img/country-flags/do.png
diff --git a/assets/img/country-flags/dz.png b/assets/dist/img/country-flags/dz.png
similarity index 100%
rename from assets/img/country-flags/dz.png
rename to assets/dist/img/country-flags/dz.png
diff --git a/assets/img/country-flags/ec.png b/assets/dist/img/country-flags/ec.png
similarity index 100%
rename from assets/img/country-flags/ec.png
rename to assets/dist/img/country-flags/ec.png
diff --git a/assets/img/country-flags/ee.png b/assets/dist/img/country-flags/ee.png
similarity index 100%
rename from assets/img/country-flags/ee.png
rename to assets/dist/img/country-flags/ee.png
diff --git a/assets/img/country-flags/eg.png b/assets/dist/img/country-flags/eg.png
similarity index 100%
rename from assets/img/country-flags/eg.png
rename to assets/dist/img/country-flags/eg.png
diff --git a/assets/img/country-flags/er.png b/assets/dist/img/country-flags/er.png
similarity index 100%
rename from assets/img/country-flags/er.png
rename to assets/dist/img/country-flags/er.png
diff --git a/assets/img/country-flags/es.png b/assets/dist/img/country-flags/es.png
similarity index 100%
rename from assets/img/country-flags/es.png
rename to assets/dist/img/country-flags/es.png
diff --git a/assets/img/country-flags/et.png b/assets/dist/img/country-flags/et.png
similarity index 100%
rename from assets/img/country-flags/et.png
rename to assets/dist/img/country-flags/et.png
diff --git a/assets/img/country-flags/fi.png b/assets/dist/img/country-flags/fi.png
similarity index 100%
rename from assets/img/country-flags/fi.png
rename to assets/dist/img/country-flags/fi.png
diff --git a/assets/img/country-flags/fj.png b/assets/dist/img/country-flags/fj.png
similarity index 100%
rename from assets/img/country-flags/fj.png
rename to assets/dist/img/country-flags/fj.png
diff --git a/assets/img/country-flags/fk.png b/assets/dist/img/country-flags/fk.png
similarity index 100%
rename from assets/img/country-flags/fk.png
rename to assets/dist/img/country-flags/fk.png
diff --git a/assets/img/country-flags/fm.png b/assets/dist/img/country-flags/fm.png
similarity index 100%
rename from assets/img/country-flags/fm.png
rename to assets/dist/img/country-flags/fm.png
diff --git a/assets/img/country-flags/fo.png b/assets/dist/img/country-flags/fo.png
similarity index 100%
rename from assets/img/country-flags/fo.png
rename to assets/dist/img/country-flags/fo.png
diff --git a/assets/img/country-flags/fr.png b/assets/dist/img/country-flags/fr.png
similarity index 100%
rename from assets/img/country-flags/fr.png
rename to assets/dist/img/country-flags/fr.png
diff --git a/assets/img/country-flags/ga.png b/assets/dist/img/country-flags/ga.png
similarity index 100%
rename from assets/img/country-flags/ga.png
rename to assets/dist/img/country-flags/ga.png
diff --git a/assets/img/country-flags/gb.png b/assets/dist/img/country-flags/gb.png
similarity index 100%
rename from assets/img/country-flags/gb.png
rename to assets/dist/img/country-flags/gb.png
diff --git a/assets/img/country-flags/gd.png b/assets/dist/img/country-flags/gd.png
similarity index 100%
rename from assets/img/country-flags/gd.png
rename to assets/dist/img/country-flags/gd.png
diff --git a/assets/img/country-flags/ge.png b/assets/dist/img/country-flags/ge.png
similarity index 100%
rename from assets/img/country-flags/ge.png
rename to assets/dist/img/country-flags/ge.png
diff --git a/assets/img/country-flags/gg.png b/assets/dist/img/country-flags/gg.png
similarity index 100%
rename from assets/img/country-flags/gg.png
rename to assets/dist/img/country-flags/gg.png
diff --git a/assets/img/country-flags/gh.png b/assets/dist/img/country-flags/gh.png
similarity index 100%
rename from assets/img/country-flags/gh.png
rename to assets/dist/img/country-flags/gh.png
diff --git a/assets/img/country-flags/gi.png b/assets/dist/img/country-flags/gi.png
similarity index 100%
rename from assets/img/country-flags/gi.png
rename to assets/dist/img/country-flags/gi.png
diff --git a/assets/img/country-flags/gl.png b/assets/dist/img/country-flags/gl.png
similarity index 100%
rename from assets/img/country-flags/gl.png
rename to assets/dist/img/country-flags/gl.png
diff --git a/assets/img/country-flags/gm.png b/assets/dist/img/country-flags/gm.png
similarity index 100%
rename from assets/img/country-flags/gm.png
rename to assets/dist/img/country-flags/gm.png
diff --git a/assets/img/country-flags/gn.png b/assets/dist/img/country-flags/gn.png
similarity index 100%
rename from assets/img/country-flags/gn.png
rename to assets/dist/img/country-flags/gn.png
diff --git a/assets/img/country-flags/gq.png b/assets/dist/img/country-flags/gq.png
similarity index 100%
rename from assets/img/country-flags/gq.png
rename to assets/dist/img/country-flags/gq.png
diff --git a/assets/img/country-flags/gr.png b/assets/dist/img/country-flags/gr.png
similarity index 100%
rename from assets/img/country-flags/gr.png
rename to assets/dist/img/country-flags/gr.png
diff --git a/assets/img/country-flags/gs.png b/assets/dist/img/country-flags/gs.png
similarity index 100%
rename from assets/img/country-flags/gs.png
rename to assets/dist/img/country-flags/gs.png
diff --git a/assets/img/country-flags/gt.png b/assets/dist/img/country-flags/gt.png
similarity index 100%
rename from assets/img/country-flags/gt.png
rename to assets/dist/img/country-flags/gt.png
diff --git a/assets/img/country-flags/gu.png b/assets/dist/img/country-flags/gu.png
similarity index 100%
rename from assets/img/country-flags/gu.png
rename to assets/dist/img/country-flags/gu.png
diff --git a/assets/img/country-flags/gw.png b/assets/dist/img/country-flags/gw.png
similarity index 100%
rename from assets/img/country-flags/gw.png
rename to assets/dist/img/country-flags/gw.png
diff --git a/assets/img/country-flags/gy.png b/assets/dist/img/country-flags/gy.png
similarity index 100%
rename from assets/img/country-flags/gy.png
rename to assets/dist/img/country-flags/gy.png
diff --git a/assets/img/country-flags/hk.png b/assets/dist/img/country-flags/hk.png
similarity index 100%
rename from assets/img/country-flags/hk.png
rename to assets/dist/img/country-flags/hk.png
diff --git a/assets/img/country-flags/hn.png b/assets/dist/img/country-flags/hn.png
similarity index 100%
rename from assets/img/country-flags/hn.png
rename to assets/dist/img/country-flags/hn.png
diff --git a/assets/img/country-flags/hr.png b/assets/dist/img/country-flags/hr.png
similarity index 100%
rename from assets/img/country-flags/hr.png
rename to assets/dist/img/country-flags/hr.png
diff --git a/assets/img/country-flags/ht.png b/assets/dist/img/country-flags/ht.png
similarity index 100%
rename from assets/img/country-flags/ht.png
rename to assets/dist/img/country-flags/ht.png
diff --git a/assets/img/country-flags/hu.png b/assets/dist/img/country-flags/hu.png
similarity index 100%
rename from assets/img/country-flags/hu.png
rename to assets/dist/img/country-flags/hu.png
diff --git a/assets/img/country-flags/id.png b/assets/dist/img/country-flags/id.png
similarity index 100%
rename from assets/img/country-flags/id.png
rename to assets/dist/img/country-flags/id.png
diff --git a/assets/img/country-flags/ie.png b/assets/dist/img/country-flags/ie.png
similarity index 100%
rename from assets/img/country-flags/ie.png
rename to assets/dist/img/country-flags/ie.png
diff --git a/assets/img/country-flags/il.png b/assets/dist/img/country-flags/il.png
similarity index 100%
rename from assets/img/country-flags/il.png
rename to assets/dist/img/country-flags/il.png
diff --git a/assets/img/country-flags/im.png b/assets/dist/img/country-flags/im.png
similarity index 100%
rename from assets/img/country-flags/im.png
rename to assets/dist/img/country-flags/im.png
diff --git a/assets/img/country-flags/in.png b/assets/dist/img/country-flags/in.png
similarity index 100%
rename from assets/img/country-flags/in.png
rename to assets/dist/img/country-flags/in.png
diff --git a/assets/img/country-flags/io.png b/assets/dist/img/country-flags/io.png
similarity index 100%
rename from assets/img/country-flags/io.png
rename to assets/dist/img/country-flags/io.png
diff --git a/assets/img/country-flags/iq.png b/assets/dist/img/country-flags/iq.png
similarity index 100%
rename from assets/img/country-flags/iq.png
rename to assets/dist/img/country-flags/iq.png
diff --git a/assets/img/country-flags/ir.png b/assets/dist/img/country-flags/ir.png
similarity index 100%
rename from assets/img/country-flags/ir.png
rename to assets/dist/img/country-flags/ir.png
diff --git a/assets/img/country-flags/is.png b/assets/dist/img/country-flags/is.png
similarity index 100%
rename from assets/img/country-flags/is.png
rename to assets/dist/img/country-flags/is.png
diff --git a/assets/img/country-flags/it.png b/assets/dist/img/country-flags/it.png
similarity index 100%
rename from assets/img/country-flags/it.png
rename to assets/dist/img/country-flags/it.png
diff --git a/assets/img/country-flags/je.png b/assets/dist/img/country-flags/je.png
similarity index 100%
rename from assets/img/country-flags/je.png
rename to assets/dist/img/country-flags/je.png
diff --git a/assets/img/country-flags/jm.png b/assets/dist/img/country-flags/jm.png
similarity index 100%
rename from assets/img/country-flags/jm.png
rename to assets/dist/img/country-flags/jm.png
diff --git a/assets/img/country-flags/jo.png b/assets/dist/img/country-flags/jo.png
similarity index 100%
rename from assets/img/country-flags/jo.png
rename to assets/dist/img/country-flags/jo.png
diff --git a/assets/img/country-flags/jp.png b/assets/dist/img/country-flags/jp.png
similarity index 100%
rename from assets/img/country-flags/jp.png
rename to assets/dist/img/country-flags/jp.png
diff --git a/assets/img/country-flags/ke.png b/assets/dist/img/country-flags/ke.png
similarity index 100%
rename from assets/img/country-flags/ke.png
rename to assets/dist/img/country-flags/ke.png
diff --git a/assets/img/country-flags/kg.png b/assets/dist/img/country-flags/kg.png
similarity index 100%
rename from assets/img/country-flags/kg.png
rename to assets/dist/img/country-flags/kg.png
diff --git a/assets/img/country-flags/kh.png b/assets/dist/img/country-flags/kh.png
similarity index 100%
rename from assets/img/country-flags/kh.png
rename to assets/dist/img/country-flags/kh.png
diff --git a/assets/img/country-flags/ki.png b/assets/dist/img/country-flags/ki.png
similarity index 100%
rename from assets/img/country-flags/ki.png
rename to assets/dist/img/country-flags/ki.png
diff --git a/assets/img/country-flags/km.png b/assets/dist/img/country-flags/km.png
similarity index 100%
rename from assets/img/country-flags/km.png
rename to assets/dist/img/country-flags/km.png
diff --git a/assets/img/country-flags/kn.png b/assets/dist/img/country-flags/kn.png
similarity index 100%
rename from assets/img/country-flags/kn.png
rename to assets/dist/img/country-flags/kn.png
diff --git a/assets/img/country-flags/kp.png b/assets/dist/img/country-flags/kp.png
similarity index 100%
rename from assets/img/country-flags/kp.png
rename to assets/dist/img/country-flags/kp.png
diff --git a/assets/img/country-flags/kr.png b/assets/dist/img/country-flags/kr.png
similarity index 100%
rename from assets/img/country-flags/kr.png
rename to assets/dist/img/country-flags/kr.png
diff --git a/assets/img/country-flags/kw.png b/assets/dist/img/country-flags/kw.png
similarity index 100%
rename from assets/img/country-flags/kw.png
rename to assets/dist/img/country-flags/kw.png
diff --git a/assets/img/country-flags/ky.png b/assets/dist/img/country-flags/ky.png
similarity index 100%
rename from assets/img/country-flags/ky.png
rename to assets/dist/img/country-flags/ky.png
diff --git a/assets/img/country-flags/kz.png b/assets/dist/img/country-flags/kz.png
similarity index 100%
rename from assets/img/country-flags/kz.png
rename to assets/dist/img/country-flags/kz.png
diff --git a/assets/img/country-flags/la.png b/assets/dist/img/country-flags/la.png
similarity index 100%
rename from assets/img/country-flags/la.png
rename to assets/dist/img/country-flags/la.png
diff --git a/assets/img/country-flags/lb.png b/assets/dist/img/country-flags/lb.png
similarity index 100%
rename from assets/img/country-flags/lb.png
rename to assets/dist/img/country-flags/lb.png
diff --git a/assets/img/country-flags/lc.png b/assets/dist/img/country-flags/lc.png
similarity index 100%
rename from assets/img/country-flags/lc.png
rename to assets/dist/img/country-flags/lc.png
diff --git a/assets/img/country-flags/li.png b/assets/dist/img/country-flags/li.png
similarity index 100%
rename from assets/img/country-flags/li.png
rename to assets/dist/img/country-flags/li.png
diff --git a/assets/img/country-flags/lk.png b/assets/dist/img/country-flags/lk.png
similarity index 100%
rename from assets/img/country-flags/lk.png
rename to assets/dist/img/country-flags/lk.png
diff --git a/assets/img/country-flags/lr.png b/assets/dist/img/country-flags/lr.png
similarity index 100%
rename from assets/img/country-flags/lr.png
rename to assets/dist/img/country-flags/lr.png
diff --git a/assets/img/country-flags/ls.png b/assets/dist/img/country-flags/ls.png
similarity index 100%
rename from assets/img/country-flags/ls.png
rename to assets/dist/img/country-flags/ls.png
diff --git a/assets/img/country-flags/lt.png b/assets/dist/img/country-flags/lt.png
similarity index 100%
rename from assets/img/country-flags/lt.png
rename to assets/dist/img/country-flags/lt.png
diff --git a/assets/img/country-flags/lu.png b/assets/dist/img/country-flags/lu.png
similarity index 100%
rename from assets/img/country-flags/lu.png
rename to assets/dist/img/country-flags/lu.png
diff --git a/assets/img/country-flags/lv.png b/assets/dist/img/country-flags/lv.png
similarity index 100%
rename from assets/img/country-flags/lv.png
rename to assets/dist/img/country-flags/lv.png
diff --git a/assets/img/country-flags/ly.png b/assets/dist/img/country-flags/ly.png
similarity index 100%
rename from assets/img/country-flags/ly.png
rename to assets/dist/img/country-flags/ly.png
diff --git a/assets/img/country-flags/ma.png b/assets/dist/img/country-flags/ma.png
similarity index 100%
rename from assets/img/country-flags/ma.png
rename to assets/dist/img/country-flags/ma.png
diff --git a/assets/img/country-flags/mc.png b/assets/dist/img/country-flags/mc.png
similarity index 100%
rename from assets/img/country-flags/mc.png
rename to assets/dist/img/country-flags/mc.png
diff --git a/assets/img/country-flags/md.png b/assets/dist/img/country-flags/md.png
similarity index 100%
rename from assets/img/country-flags/md.png
rename to assets/dist/img/country-flags/md.png
diff --git a/assets/img/country-flags/me.png b/assets/dist/img/country-flags/me.png
similarity index 100%
rename from assets/img/country-flags/me.png
rename to assets/dist/img/country-flags/me.png
diff --git a/assets/img/country-flags/mg.png b/assets/dist/img/country-flags/mg.png
similarity index 100%
rename from assets/img/country-flags/mg.png
rename to assets/dist/img/country-flags/mg.png
diff --git a/assets/img/country-flags/mh.png b/assets/dist/img/country-flags/mh.png
similarity index 100%
rename from assets/img/country-flags/mh.png
rename to assets/dist/img/country-flags/mh.png
diff --git a/assets/img/country-flags/mk.png b/assets/dist/img/country-flags/mk.png
similarity index 100%
rename from assets/img/country-flags/mk.png
rename to assets/dist/img/country-flags/mk.png
diff --git a/assets/img/country-flags/ml.png b/assets/dist/img/country-flags/ml.png
similarity index 100%
rename from assets/img/country-flags/ml.png
rename to assets/dist/img/country-flags/ml.png
diff --git a/assets/img/country-flags/mm.png b/assets/dist/img/country-flags/mm.png
similarity index 100%
rename from assets/img/country-flags/mm.png
rename to assets/dist/img/country-flags/mm.png
diff --git a/assets/img/country-flags/mn.png b/assets/dist/img/country-flags/mn.png
similarity index 100%
rename from assets/img/country-flags/mn.png
rename to assets/dist/img/country-flags/mn.png
diff --git a/assets/img/country-flags/mo.png b/assets/dist/img/country-flags/mo.png
similarity index 100%
rename from assets/img/country-flags/mo.png
rename to assets/dist/img/country-flags/mo.png
diff --git a/assets/img/country-flags/mp.png b/assets/dist/img/country-flags/mp.png
similarity index 100%
rename from assets/img/country-flags/mp.png
rename to assets/dist/img/country-flags/mp.png
diff --git a/assets/img/country-flags/mq.png b/assets/dist/img/country-flags/mq.png
similarity index 100%
rename from assets/img/country-flags/mq.png
rename to assets/dist/img/country-flags/mq.png
diff --git a/assets/img/country-flags/mr.png b/assets/dist/img/country-flags/mr.png
similarity index 100%
rename from assets/img/country-flags/mr.png
rename to assets/dist/img/country-flags/mr.png
diff --git a/assets/img/country-flags/ms.png b/assets/dist/img/country-flags/ms.png
similarity index 100%
rename from assets/img/country-flags/ms.png
rename to assets/dist/img/country-flags/ms.png
diff --git a/assets/img/country-flags/mt.png b/assets/dist/img/country-flags/mt.png
similarity index 100%
rename from assets/img/country-flags/mt.png
rename to assets/dist/img/country-flags/mt.png
diff --git a/assets/img/country-flags/mu.png b/assets/dist/img/country-flags/mu.png
similarity index 100%
rename from assets/img/country-flags/mu.png
rename to assets/dist/img/country-flags/mu.png
diff --git a/assets/img/country-flags/mv.png b/assets/dist/img/country-flags/mv.png
similarity index 100%
rename from assets/img/country-flags/mv.png
rename to assets/dist/img/country-flags/mv.png
diff --git a/assets/img/country-flags/mw.png b/assets/dist/img/country-flags/mw.png
similarity index 100%
rename from assets/img/country-flags/mw.png
rename to assets/dist/img/country-flags/mw.png
diff --git a/assets/img/country-flags/mx.png b/assets/dist/img/country-flags/mx.png
similarity index 100%
rename from assets/img/country-flags/mx.png
rename to assets/dist/img/country-flags/mx.png
diff --git a/assets/img/country-flags/my.png b/assets/dist/img/country-flags/my.png
similarity index 100%
rename from assets/img/country-flags/my.png
rename to assets/dist/img/country-flags/my.png
diff --git a/assets/img/country-flags/mz.png b/assets/dist/img/country-flags/mz.png
similarity index 100%
rename from assets/img/country-flags/mz.png
rename to assets/dist/img/country-flags/mz.png
diff --git a/assets/img/country-flags/na.png b/assets/dist/img/country-flags/na.png
similarity index 100%
rename from assets/img/country-flags/na.png
rename to assets/dist/img/country-flags/na.png
diff --git a/assets/img/country-flags/nc.png b/assets/dist/img/country-flags/nc.png
similarity index 100%
rename from assets/img/country-flags/nc.png
rename to assets/dist/img/country-flags/nc.png
diff --git a/assets/img/country-flags/ne.png b/assets/dist/img/country-flags/ne.png
similarity index 100%
rename from assets/img/country-flags/ne.png
rename to assets/dist/img/country-flags/ne.png
diff --git a/assets/img/country-flags/nf.png b/assets/dist/img/country-flags/nf.png
similarity index 100%
rename from assets/img/country-flags/nf.png
rename to assets/dist/img/country-flags/nf.png
diff --git a/assets/img/country-flags/ng.png b/assets/dist/img/country-flags/ng.png
similarity index 100%
rename from assets/img/country-flags/ng.png
rename to assets/dist/img/country-flags/ng.png
diff --git a/assets/img/country-flags/ni.png b/assets/dist/img/country-flags/ni.png
similarity index 100%
rename from assets/img/country-flags/ni.png
rename to assets/dist/img/country-flags/ni.png
diff --git a/assets/img/country-flags/nl.png b/assets/dist/img/country-flags/nl.png
similarity index 100%
rename from assets/img/country-flags/nl.png
rename to assets/dist/img/country-flags/nl.png
diff --git a/assets/img/country-flags/no.png b/assets/dist/img/country-flags/no.png
similarity index 100%
rename from assets/img/country-flags/no.png
rename to assets/dist/img/country-flags/no.png
diff --git a/assets/img/country-flags/np.png b/assets/dist/img/country-flags/np.png
similarity index 100%
rename from assets/img/country-flags/np.png
rename to assets/dist/img/country-flags/np.png
diff --git a/assets/img/country-flags/nr.png b/assets/dist/img/country-flags/nr.png
similarity index 100%
rename from assets/img/country-flags/nr.png
rename to assets/dist/img/country-flags/nr.png
diff --git a/assets/img/country-flags/nu.png b/assets/dist/img/country-flags/nu.png
similarity index 100%
rename from assets/img/country-flags/nu.png
rename to assets/dist/img/country-flags/nu.png
diff --git a/assets/img/country-flags/nz.png b/assets/dist/img/country-flags/nz.png
similarity index 100%
rename from assets/img/country-flags/nz.png
rename to assets/dist/img/country-flags/nz.png
diff --git a/assets/img/country-flags/om.png b/assets/dist/img/country-flags/om.png
similarity index 100%
rename from assets/img/country-flags/om.png
rename to assets/dist/img/country-flags/om.png
diff --git a/assets/img/country-flags/pa.png b/assets/dist/img/country-flags/pa.png
similarity index 100%
rename from assets/img/country-flags/pa.png
rename to assets/dist/img/country-flags/pa.png
diff --git a/assets/img/country-flags/pe.png b/assets/dist/img/country-flags/pe.png
similarity index 100%
rename from assets/img/country-flags/pe.png
rename to assets/dist/img/country-flags/pe.png
diff --git a/assets/img/country-flags/pf.png b/assets/dist/img/country-flags/pf.png
similarity index 100%
rename from assets/img/country-flags/pf.png
rename to assets/dist/img/country-flags/pf.png
diff --git a/assets/img/country-flags/pg.png b/assets/dist/img/country-flags/pg.png
similarity index 100%
rename from assets/img/country-flags/pg.png
rename to assets/dist/img/country-flags/pg.png
diff --git a/assets/img/country-flags/ph.png b/assets/dist/img/country-flags/ph.png
similarity index 100%
rename from assets/img/country-flags/ph.png
rename to assets/dist/img/country-flags/ph.png
diff --git a/assets/img/country-flags/pk.png b/assets/dist/img/country-flags/pk.png
similarity index 100%
rename from assets/img/country-flags/pk.png
rename to assets/dist/img/country-flags/pk.png
diff --git a/assets/img/country-flags/pl.png b/assets/dist/img/country-flags/pl.png
similarity index 100%
rename from assets/img/country-flags/pl.png
rename to assets/dist/img/country-flags/pl.png
diff --git a/assets/img/country-flags/pn.png b/assets/dist/img/country-flags/pn.png
similarity index 100%
rename from assets/img/country-flags/pn.png
rename to assets/dist/img/country-flags/pn.png
diff --git a/assets/img/country-flags/pr.png b/assets/dist/img/country-flags/pr.png
similarity index 100%
rename from assets/img/country-flags/pr.png
rename to assets/dist/img/country-flags/pr.png
diff --git a/assets/img/country-flags/ps.png b/assets/dist/img/country-flags/ps.png
similarity index 100%
rename from assets/img/country-flags/ps.png
rename to assets/dist/img/country-flags/ps.png
diff --git a/assets/img/country-flags/pt.png b/assets/dist/img/country-flags/pt.png
similarity index 100%
rename from assets/img/country-flags/pt.png
rename to assets/dist/img/country-flags/pt.png
diff --git a/assets/img/country-flags/pw.png b/assets/dist/img/country-flags/pw.png
similarity index 100%
rename from assets/img/country-flags/pw.png
rename to assets/dist/img/country-flags/pw.png
diff --git a/assets/img/country-flags/py.png b/assets/dist/img/country-flags/py.png
similarity index 100%
rename from assets/img/country-flags/py.png
rename to assets/dist/img/country-flags/py.png
diff --git a/assets/img/country-flags/qa.png b/assets/dist/img/country-flags/qa.png
similarity index 100%
rename from assets/img/country-flags/qa.png
rename to assets/dist/img/country-flags/qa.png
diff --git a/assets/img/country-flags/re.png b/assets/dist/img/country-flags/re.png
similarity index 100%
rename from assets/img/country-flags/re.png
rename to assets/dist/img/country-flags/re.png
diff --git a/assets/img/country-flags/ro.png b/assets/dist/img/country-flags/ro.png
similarity index 100%
rename from assets/img/country-flags/ro.png
rename to assets/dist/img/country-flags/ro.png
diff --git a/assets/img/country-flags/rs.png b/assets/dist/img/country-flags/rs.png
similarity index 100%
rename from assets/img/country-flags/rs.png
rename to assets/dist/img/country-flags/rs.png
diff --git a/assets/img/country-flags/ru.png b/assets/dist/img/country-flags/ru.png
similarity index 100%
rename from assets/img/country-flags/ru.png
rename to assets/dist/img/country-flags/ru.png
diff --git a/assets/img/country-flags/rw.png b/assets/dist/img/country-flags/rw.png
similarity index 100%
rename from assets/img/country-flags/rw.png
rename to assets/dist/img/country-flags/rw.png
diff --git a/assets/img/country-flags/sa.png b/assets/dist/img/country-flags/sa.png
similarity index 100%
rename from assets/img/country-flags/sa.png
rename to assets/dist/img/country-flags/sa.png
diff --git a/assets/img/country-flags/sb.png b/assets/dist/img/country-flags/sb.png
similarity index 100%
rename from assets/img/country-flags/sb.png
rename to assets/dist/img/country-flags/sb.png
diff --git a/assets/img/country-flags/sc.png b/assets/dist/img/country-flags/sc.png
similarity index 100%
rename from assets/img/country-flags/sc.png
rename to assets/dist/img/country-flags/sc.png
diff --git a/assets/img/country-flags/sd.png b/assets/dist/img/country-flags/sd.png
similarity index 100%
rename from assets/img/country-flags/sd.png
rename to assets/dist/img/country-flags/sd.png
diff --git a/assets/img/country-flags/se.png b/assets/dist/img/country-flags/se.png
similarity index 100%
rename from assets/img/country-flags/se.png
rename to assets/dist/img/country-flags/se.png
diff --git a/assets/img/country-flags/sg.png b/assets/dist/img/country-flags/sg.png
similarity index 100%
rename from assets/img/country-flags/sg.png
rename to assets/dist/img/country-flags/sg.png
diff --git a/assets/img/country-flags/sh.png b/assets/dist/img/country-flags/sh.png
similarity index 100%
rename from assets/img/country-flags/sh.png
rename to assets/dist/img/country-flags/sh.png
diff --git a/assets/img/country-flags/si.png b/assets/dist/img/country-flags/si.png
similarity index 100%
rename from assets/img/country-flags/si.png
rename to assets/dist/img/country-flags/si.png
diff --git a/assets/img/country-flags/sk.png b/assets/dist/img/country-flags/sk.png
similarity index 100%
rename from assets/img/country-flags/sk.png
rename to assets/dist/img/country-flags/sk.png
diff --git a/assets/img/country-flags/sl.png b/assets/dist/img/country-flags/sl.png
similarity index 100%
rename from assets/img/country-flags/sl.png
rename to assets/dist/img/country-flags/sl.png
diff --git a/assets/img/country-flags/sm.png b/assets/dist/img/country-flags/sm.png
similarity index 100%
rename from assets/img/country-flags/sm.png
rename to assets/dist/img/country-flags/sm.png
diff --git a/assets/img/country-flags/sn.png b/assets/dist/img/country-flags/sn.png
similarity index 100%
rename from assets/img/country-flags/sn.png
rename to assets/dist/img/country-flags/sn.png
diff --git a/assets/img/country-flags/so.png b/assets/dist/img/country-flags/so.png
similarity index 100%
rename from assets/img/country-flags/so.png
rename to assets/dist/img/country-flags/so.png
diff --git a/assets/img/country-flags/sr.png b/assets/dist/img/country-flags/sr.png
similarity index 100%
rename from assets/img/country-flags/sr.png
rename to assets/dist/img/country-flags/sr.png
diff --git a/assets/img/country-flags/ss.png b/assets/dist/img/country-flags/ss.png
similarity index 100%
rename from assets/img/country-flags/ss.png
rename to assets/dist/img/country-flags/ss.png
diff --git a/assets/img/country-flags/st.png b/assets/dist/img/country-flags/st.png
similarity index 100%
rename from assets/img/country-flags/st.png
rename to assets/dist/img/country-flags/st.png
diff --git a/assets/img/country-flags/sv.png b/assets/dist/img/country-flags/sv.png
similarity index 100%
rename from assets/img/country-flags/sv.png
rename to assets/dist/img/country-flags/sv.png
diff --git a/assets/img/country-flags/sx.png b/assets/dist/img/country-flags/sx.png
similarity index 100%
rename from assets/img/country-flags/sx.png
rename to assets/dist/img/country-flags/sx.png
diff --git a/assets/img/country-flags/sy.png b/assets/dist/img/country-flags/sy.png
similarity index 100%
rename from assets/img/country-flags/sy.png
rename to assets/dist/img/country-flags/sy.png
diff --git a/assets/img/country-flags/sz.png b/assets/dist/img/country-flags/sz.png
similarity index 100%
rename from assets/img/country-flags/sz.png
rename to assets/dist/img/country-flags/sz.png
diff --git a/assets/img/country-flags/tc.png b/assets/dist/img/country-flags/tc.png
similarity index 100%
rename from assets/img/country-flags/tc.png
rename to assets/dist/img/country-flags/tc.png
diff --git a/assets/img/country-flags/td.png b/assets/dist/img/country-flags/td.png
similarity index 100%
rename from assets/img/country-flags/td.png
rename to assets/dist/img/country-flags/td.png
diff --git a/assets/img/country-flags/tf.png b/assets/dist/img/country-flags/tf.png
similarity index 100%
rename from assets/img/country-flags/tf.png
rename to assets/dist/img/country-flags/tf.png
diff --git a/assets/img/country-flags/tg.png b/assets/dist/img/country-flags/tg.png
similarity index 100%
rename from assets/img/country-flags/tg.png
rename to assets/dist/img/country-flags/tg.png
diff --git a/assets/img/country-flags/th.png b/assets/dist/img/country-flags/th.png
similarity index 100%
rename from assets/img/country-flags/th.png
rename to assets/dist/img/country-flags/th.png
diff --git a/assets/img/country-flags/tj.png b/assets/dist/img/country-flags/tj.png
similarity index 100%
rename from assets/img/country-flags/tj.png
rename to assets/dist/img/country-flags/tj.png
diff --git a/assets/img/country-flags/tk.png b/assets/dist/img/country-flags/tk.png
similarity index 100%
rename from assets/img/country-flags/tk.png
rename to assets/dist/img/country-flags/tk.png
diff --git a/assets/img/country-flags/tl.png b/assets/dist/img/country-flags/tl.png
similarity index 100%
rename from assets/img/country-flags/tl.png
rename to assets/dist/img/country-flags/tl.png
diff --git a/assets/img/country-flags/tm.png b/assets/dist/img/country-flags/tm.png
similarity index 100%
rename from assets/img/country-flags/tm.png
rename to assets/dist/img/country-flags/tm.png
diff --git a/assets/img/country-flags/tn.png b/assets/dist/img/country-flags/tn.png
similarity index 100%
rename from assets/img/country-flags/tn.png
rename to assets/dist/img/country-flags/tn.png
diff --git a/assets/img/country-flags/to.png b/assets/dist/img/country-flags/to.png
similarity index 100%
rename from assets/img/country-flags/to.png
rename to assets/dist/img/country-flags/to.png
diff --git a/assets/img/country-flags/tr.png b/assets/dist/img/country-flags/tr.png
similarity index 100%
rename from assets/img/country-flags/tr.png
rename to assets/dist/img/country-flags/tr.png
diff --git a/assets/img/country-flags/tt.png b/assets/dist/img/country-flags/tt.png
similarity index 100%
rename from assets/img/country-flags/tt.png
rename to assets/dist/img/country-flags/tt.png
diff --git a/assets/img/country-flags/tv.png b/assets/dist/img/country-flags/tv.png
similarity index 100%
rename from assets/img/country-flags/tv.png
rename to assets/dist/img/country-flags/tv.png
diff --git a/assets/img/country-flags/tw.png b/assets/dist/img/country-flags/tw.png
similarity index 100%
rename from assets/img/country-flags/tw.png
rename to assets/dist/img/country-flags/tw.png
diff --git a/assets/img/country-flags/tz.png b/assets/dist/img/country-flags/tz.png
similarity index 100%
rename from assets/img/country-flags/tz.png
rename to assets/dist/img/country-flags/tz.png
diff --git a/assets/img/country-flags/ua.png b/assets/dist/img/country-flags/ua.png
similarity index 100%
rename from assets/img/country-flags/ua.png
rename to assets/dist/img/country-flags/ua.png
diff --git a/assets/img/country-flags/ug.png b/assets/dist/img/country-flags/ug.png
similarity index 100%
rename from assets/img/country-flags/ug.png
rename to assets/dist/img/country-flags/ug.png
diff --git a/assets/img/country-flags/us.png b/assets/dist/img/country-flags/us.png
similarity index 100%
rename from assets/img/country-flags/us.png
rename to assets/dist/img/country-flags/us.png
diff --git a/assets/img/country-flags/uy.png b/assets/dist/img/country-flags/uy.png
similarity index 100%
rename from assets/img/country-flags/uy.png
rename to assets/dist/img/country-flags/uy.png
diff --git a/assets/img/country-flags/uz.png b/assets/dist/img/country-flags/uz.png
similarity index 100%
rename from assets/img/country-flags/uz.png
rename to assets/dist/img/country-flags/uz.png
diff --git a/assets/img/country-flags/va.png b/assets/dist/img/country-flags/va.png
similarity index 100%
rename from assets/img/country-flags/va.png
rename to assets/dist/img/country-flags/va.png
diff --git a/assets/img/country-flags/vc.png b/assets/dist/img/country-flags/vc.png
similarity index 100%
rename from assets/img/country-flags/vc.png
rename to assets/dist/img/country-flags/vc.png
diff --git a/assets/img/country-flags/ve.png b/assets/dist/img/country-flags/ve.png
similarity index 100%
rename from assets/img/country-flags/ve.png
rename to assets/dist/img/country-flags/ve.png
diff --git a/assets/img/country-flags/vg.png b/assets/dist/img/country-flags/vg.png
similarity index 100%
rename from assets/img/country-flags/vg.png
rename to assets/dist/img/country-flags/vg.png
diff --git a/assets/img/country-flags/vi.png b/assets/dist/img/country-flags/vi.png
similarity index 100%
rename from assets/img/country-flags/vi.png
rename to assets/dist/img/country-flags/vi.png
diff --git a/assets/img/country-flags/vn.png b/assets/dist/img/country-flags/vn.png
similarity index 100%
rename from assets/img/country-flags/vn.png
rename to assets/dist/img/country-flags/vn.png
diff --git a/assets/img/country-flags/vu.png b/assets/dist/img/country-flags/vu.png
similarity index 100%
rename from assets/img/country-flags/vu.png
rename to assets/dist/img/country-flags/vu.png
diff --git a/assets/img/country-flags/ws.png b/assets/dist/img/country-flags/ws.png
similarity index 100%
rename from assets/img/country-flags/ws.png
rename to assets/dist/img/country-flags/ws.png
diff --git a/assets/img/country-flags/ye.png b/assets/dist/img/country-flags/ye.png
similarity index 100%
rename from assets/img/country-flags/ye.png
rename to assets/dist/img/country-flags/ye.png
diff --git a/assets/img/country-flags/za.png b/assets/dist/img/country-flags/za.png
similarity index 100%
rename from assets/img/country-flags/za.png
rename to assets/dist/img/country-flags/za.png
diff --git a/assets/img/country-flags/zm.png b/assets/dist/img/country-flags/zm.png
similarity index 100%
rename from assets/img/country-flags/zm.png
rename to assets/dist/img/country-flags/zm.png
diff --git a/assets/img/country-flags/zw.png b/assets/dist/img/country-flags/zw.png
similarity index 100%
rename from assets/img/country-flags/zw.png
rename to assets/dist/img/country-flags/zw.png
diff --git a/assets/img/screenshot.png b/assets/dist/img/screenshot.png
similarity index 100%
rename from assets/img/screenshot.png
rename to assets/dist/img/screenshot.png
diff --git a/views/index.html b/assets/dist/index.html
similarity index 71%
rename from views/index.html
rename to assets/dist/index.html
index 6748aeb..deb91b5 100644
--- a/views/index.html
+++ b/assets/dist/index.html
@@ -2,13 +2,13 @@
Ana - open web analytics
-
+
-
+
diff --git a/assets/dist/js/script.js b/assets/dist/js/script.js
new file mode 100644
index 0000000..8178835
--- /dev/null
+++ b/assets/dist/js/script.js
@@ -0,0 +1,28466 @@
+(function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i 0 ? 'positive' : 'negative' },
+ percentage,
+ '%'
+ );
+ }
+ }, {
+ key: 'render',
+ value: function render() {
+ var loadingOverlay = this.state.loading ? (0, _preact.h)(
+ 'div',
+ { 'class': 'loading-overlay' },
+ (0, _preact.h)('div', null)
+ ) : '';
+ return (0, _preact.h)(
+ 'div',
+ { 'class': 'block center-text' },
+ loadingOverlay,
+ (0, _preact.h)(
+ 'h4',
+ { 'class': '' },
+ this.props.title
+ ),
+ (0, _preact.h)(
+ 'div',
+ { 'class': 'big tiny-margin' },
+ numbers.formatWithComma(this.state.count),
+ ' ',
+ this.renderPercentage()
+ )
+ );
+ }
+ }]);
+
+ return CountWidget;
+}(_preact.Component);
+
+exports.default = CountWidget;
+
+},{"../lib/client.js":12,"../lib/numbers.js":13,"preact":61}],2:[function(require,module,exports){
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+
+var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
+
+var _preact = require('preact');
+
+function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
+
+function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
+
+function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
+
+var availablePeriods = [{
+ id: 7,
+ label: 'Last 7 days'
+}, {
+ id: 30,
+ label: 'Last 30 days'
+}, {
+ id: 90,
+ label: 'Last quarter'
+}, {
+ id: 360,
+ label: 'Last year'
+}];
+
+var DatePicker = function (_Component) {
+ _inherits(DatePicker, _Component);
+
+ function DatePicker(props) {
+ _classCallCheck(this, DatePicker);
+
+ var _this = _possibleConstructorReturn(this, (DatePicker.__proto__ || Object.getPrototypeOf(DatePicker)).call(this, props));
+
+ _this.state = {
+ period: _this.props.period
+ };
+
+ _this.setPeriod = _this.setPeriod.bind(_this);
+ return _this;
+ }
+
+ _createClass(DatePicker, [{
+ key: 'setPeriod',
+ value: function setPeriod(e) {
+ var nextState = { period: parseInt(e.target.value) };
+ if (this.state.period != nextState.period) {
+ this.setState(nextState);
+ this.props.onChoose(this.state.period);
+ }
+ }
+ }, {
+ key: 'render',
+ value: function render() {
+ var _this2 = this;
+
+ var buttons = availablePeriods.map(function (p) {
+ var className = p.id == _this2.state.period ? 'active' : '';
+ return (0, _preact.h)(
+ 'button',
+ { value: p.id, 'class': className, onClick: _this2.setPeriod },
+ p.label
+ );
+ });
+
+ return (0, _preact.h)(
+ 'div',
+ { 'class': 'small-margin' },
+ buttons
+ );
+ }
+ }]);
+
+ return DatePicker;
+}(_preact.Component);
+
+exports.default = DatePicker;
+
+},{"preact":61}],3:[function(require,module,exports){
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+
+var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
+
+var _preact = require('preact');
+
+var _client = require('../lib/client.js');
+
+var _client2 = _interopRequireDefault(_client);
+
+var _numbers = require('../lib/numbers.js');
+
+var numbers = _interopRequireWildcard(_numbers);
+
+var _d = require('d3');
+
+var d3 = _interopRequireWildcard(_d);
+
+function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
+
+function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
+
+function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
+
+d3.tip = require('d3-tip');
+
+var dayInSeconds = 60 * 60 * 24;
+
+function Chart(element, showPrimary, showSecondary) {
+ var padt = 10,
+ padb = 20,
+ padr = 40,
+ padl = 40,
+ h = 300,
+ w = element.parentNode.clientWidth - padl - padr,
+ x = d3.scaleBand().range([0, w]).padding(0.2).round(true),
+ y = d3.scaleLinear().range([h, 0]),
+ yAxis = d3.axisLeft().scale(y).tickSize(-w + padl + padr),
+ xAxis = d3.axisBottom().scale(x),
+ primaryData = [],
+ secondaryData = [];
+
+ var pageviewTip = d3.tip().attr('class', 'd3-tip').html(function (d) {
+ return '' + d.Label + '
' + numbers.formatWithComma(d.Value) + '' + ' pageviews';
+ }).offset([-12, 0]);
+
+ var visitorTip = d3.tip().attr('class', 'd3-tip').html(function (d) {
+ return '' + d.Label + '
' + numbers.formatWithComma(d.Value) + '' + ' visitors';
+ }).offset([-12, 0]);
+
+ var graph = d3.select('#graph');
+ var vis = graph.append('svg').attr('width', w + padl + padr).attr('height', h + padt + padb).append('g').attr('transform', 'translate(' + padl + ',' + padt + ')');
+
+ vis.call(pageviewTip);
+ vis.call(visitorTip);
+
+ function setData(one, two) {
+ primaryData = one;
+ secondaryData = two;
+ }
+
+ function toggleBars(one, two) {
+ showPrimary = one;
+ showSecondary = two;
+ }
+
+ function draw() {
+ var max = d3.max(showPrimary ? primaryData : secondaryData, function (d) {
+ return d.Value;
+ });
+ var ticks = primaryData.length;
+ var xTick = Math.round(ticks / 7);
+
+ x.domain(primaryData.map(function (d) {
+ return d.Label;
+ }));
+ y.domain([0, max * 1.1]);
+
+ // clear all previous data
+ vis.selectAll('*').remove();
+
+ // axes
+ vis.append("g").attr("class", "y axis").call(yAxis);
+
+ vis.append("g").attr("class", "x axis").attr('transform', 'translate(0,' + h + ')').call(xAxis).selectAll('g').style('display', function (d, i) {
+ return i % xTick != 0 ? 'none' : 'block';
+ });
+
+ // bars
+ if (showPrimary) {
+ var bars = vis.selectAll('g.primary-bar').data(primaryData).enter().append('g').attr('class', 'primary-bar').attr('transform', function (d, i) {
+ return "translate(" + x(d.Label) + ", 0)";
+ });
+
+ bars.append('rect').attr('width', x.bandwidth()).attr('height', function (d) {
+ return h - y(d.Value);
+ }).attr('y', function (d) {
+ return y(d.Value);
+ }).on('mouseover', pageviewTip.show).on('mouseout', pageviewTip.hide);
+ }
+
+ if (showSecondary) {
+ var visitorBars = vis.selectAll('g.sub-bar').data(secondaryData).enter().append('g').attr('class', 'sub-bar').attr('transform', function (d, i) {
+ return "translate(" + (x(d.Label) + x.bandwidth() * 0.16667) + ", 0)";
+ });
+
+ visitorBars.append('rect').attr('width', x.bandwidth() * 0.66).attr('height', function (d) {
+ return h - y(d.Value);
+ }).attr('y', function (d) {
+ return y(d.Value);
+ }).on('mouseover', visitorTip.show).on('mouseout', visitorTip.hide);
+ }
+ }
+
+ return {
+ 'draw': draw,
+ 'setData': setData,
+ 'toggleBars': toggleBars
+ };
+}
+
+var Graph = function (_Component) {
+ _inherits(Graph, _Component);
+
+ function Graph(props) {
+ _classCallCheck(this, Graph);
+
+ var _this = _possibleConstructorReturn(this, (Graph.__proto__ || Object.getPrototypeOf(Graph)).call(this, props));
+
+ _this.fetchData = _this.fetchData.bind(_this);
+ _this.refreshChart = _this.refreshChart.bind(_this);
+ _this.data = {
+ visitors: null,
+ pageviews: null
+ };
+ return _this;
+ }
+
+ _createClass(Graph, [{
+ key: 'componentDidMount',
+ value: function componentDidMount() {
+ this.chart = new Chart(document.getElementById('graph'), this.props.showPageviews, this.props.showVisitors);
+ this.fetchData(this.props.period);
+ }
+ }, {
+ key: 'componentWillReceiveProps',
+ value: function componentWillReceiveProps(newProps) {
+ if (this.props.period != newProps.period) {
+ this.fetchData(newProps.period);
+ }
+
+ this.chart.toggleBars(newProps.showPageviews, newProps.showVisitors);
+ this.chart.draw();
+ }
+ }, {
+ key: 'shouldComponentUpdate',
+ value: function shouldComponentUpdate() {
+ return false;
+ }
+ }, {
+ key: 'refreshChart',
+ value: function refreshChart() {
+
+ if (this.data.visitors && this.data.pageviews) {
+ this.loadingIndicator.style.display = 'none';
+ this.chart.setData(this.data.pageviews, this.data.visitors);
+ this.chart.draw();
+ }
+ }
+ }, {
+ key: 'fetchData',
+ value: function fetchData(period) {
+ var _this2 = this;
+
+ var before = Math.round(+new Date() / 1000);
+ var after = before - period * dayInSeconds;
+ var group = period > 90 ? 'month' : 'day';
+ this.loadingIndicator.style.display = '';
+
+ _client2.default.request('pageviews/count/group/' + group + '?before=' + before + '&after=' + after).then(function (d) {
+ _this2.data.pageviews = d;
+ window.requestAnimationFrame(_this2.refreshChart);
+ });
+
+ _client2.default.request('visitors/count/group/' + group + '?before=' + before + '&after=' + after).then(function (d) {
+ _this2.data.visitors = d;
+ window.requestAnimationFrame(_this2.refreshChart);
+ });
+ }
+ }, {
+ key: 'render',
+ value: function render() {
+ var _this3 = this;
+
+ return (0, _preact.h)(
+ 'div',
+ null,
+ (0, _preact.h)(
+ 'div',
+ { 'class': 'loading-overlay', ref: function ref(el) {
+ _this3.loadingIndicator = el;
+ } },
+ (0, _preact.h)('div', null)
+ ),
+ (0, _preact.h)('div', { id: 'graph' })
+ );
+ }
+ }]);
+
+ return Graph;
+}(_preact.Component);
+
+exports.default = Graph;
+
+},{"../lib/client.js":12,"../lib/numbers.js":13,"d3":54,"d3-tip":50,"preact":61}],4:[function(require,module,exports){
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+
+var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
+
+var _preact = require('preact');
+
+var _Graph = require('./Graph.js');
+
+var _Graph2 = _interopRequireDefault(_Graph);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
+
+function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
+
+function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
+
+var GraphWidget = function (_Component) {
+ _inherits(GraphWidget, _Component);
+
+ function GraphWidget(props) {
+ _classCallCheck(this, GraphWidget);
+
+ var _this = _possibleConstructorReturn(this, (GraphWidget.__proto__ || Object.getPrototypeOf(GraphWidget)).call(this, props));
+
+ _this.state = {
+ showPageviews: true,
+ showVisitors: true
+ };
+ return _this;
+ }
+
+ _createClass(GraphWidget, [{
+ key: 'render',
+ value: function render() {
+ var _this2 = this;
+
+ return (0, _preact.h)(
+ 'div',
+ { 'class': 'block' },
+ (0, _preact.h)(
+ 'div',
+ { 'class': 'pull-right' },
+ (0, _preact.h)(
+ 'label',
+ { 'class': 'inline small-margin-right' },
+ (0, _preact.h)('input', { type: 'checkbox', checked: this.state.showPageviews, onchange: function onchange(e) {
+ return _this2.setState({ showPageviews: e.target.checked });
+ } }),
+ ' Pageviews'
+ ),
+ (0, _preact.h)(
+ 'label',
+ { 'class': 'inline' },
+ (0, _preact.h)('input', { type: 'checkbox', checked: this.state.showVisitors, onchange: function onchange(e) {
+ return _this2.setState({ showVisitors: e.target.checked });
+ } }),
+ ' Visitors'
+ )
+ ),
+ (0, _preact.h)(_Graph2.default, { period: this.props.period, showPageviews: this.state.showPageviews, showVisitors: this.state.showVisitors })
+ );
+ }
+ }]);
+
+ return GraphWidget;
+}(_preact.Component);
+
+exports.default = GraphWidget;
+
+},{"./Graph.js":3,"preact":61}],5:[function(require,module,exports){
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+
+var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
+
+var _preact = require('preact');
+
+var _LogoutButton = require('../components/LogoutButton.js');
+
+var _LogoutButton2 = _interopRequireDefault(_LogoutButton);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
+
+function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
+
+function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
+
+var HeaderBar = function (_Component) {
+ _inherits(HeaderBar, _Component);
+
+ function HeaderBar() {
+ _classCallCheck(this, HeaderBar);
+
+ return _possibleConstructorReturn(this, (HeaderBar.__proto__ || Object.getPrototypeOf(HeaderBar)).apply(this, arguments));
+ }
+
+ _createClass(HeaderBar, [{
+ key: 'render',
+ value: function render() {
+ var rightContent = this.props.showLogout ? (0, _preact.h)(_LogoutButton2.default, { onSuccess: this.props.onLogout }) : '';
+
+ return (0, _preact.h)(
+ 'header',
+ { 'class': 'header-bar cf' },
+ (0, _preact.h)(
+ 'div',
+ { 'class': 'container' },
+ (0, _preact.h)(
+ 'h1',
+ { 'class': 'pull-left title' },
+ 'Ana ',
+ (0, _preact.h)(
+ 'small',
+ { 'class': 'subtitle' },
+ 'open web analytics'
+ )
+ ),
+ (0, _preact.h)(
+ 'div',
+ { 'class': 'pull-right' },
+ rightContent
+ )
+ )
+ );
+ }
+ }]);
+
+ return HeaderBar;
+}(_preact.Component);
+
+exports.default = HeaderBar;
+
+},{"../components/LogoutButton.js":7,"preact":61}],6:[function(require,module,exports){
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+
+var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
+
+var _preact = require('preact');
+
+var _client = require('../lib/client.js');
+
+var _client2 = _interopRequireDefault(_client);
+
+var _Notification = require('../components/Notification.js');
+
+var _Notification2 = _interopRequireDefault(_Notification);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
+
+function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
+
+function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
+
+var LoginForm = function (_Component) {
+ _inherits(LoginForm, _Component);
+
+ function LoginForm(props) {
+ _classCallCheck(this, LoginForm);
+
+ var _this = _possibleConstructorReturn(this, (LoginForm.__proto__ || Object.getPrototypeOf(LoginForm)).call(this, props));
+
+ _this.handleSubmit = _this.handleSubmit.bind(_this);
+ _this.state = {
+ email: '',
+ password: '',
+ message: ''
+ };
+ return _this;
+ }
+
+ _createClass(LoginForm, [{
+ key: 'handleSubmit',
+ value: function handleSubmit(e) {
+ var _this2 = this;
+
+ e.preventDefault();
+
+ _client2.default.request('session', {
+ method: "POST",
+ data: {
+ email: this.state.email,
+ password: this.state.password
+ }
+ }).then(function (r) {
+ _this2.props.onSuccess();
+ }).catch(function (e) {
+ _this2.setState({
+ message: e.message,
+ password: ''
+ });
+ });
+ }
+ }, {
+ key: 'render',
+ value: function render() {
+ return (0, _preact.h)(
+ 'div',
+ { 'class': 'block' },
+ (0, _preact.h)(
+ 'h2',
+ null,
+ 'Login'
+ ),
+ (0, _preact.h)(
+ 'p',
+ null,
+ 'Please enter your credentials to access your Ana dashboard.'
+ ),
+ (0, _preact.h)(
+ 'form',
+ { method: 'POST', onSubmit: this.handleSubmit },
+ (0, _preact.h)(
+ 'div',
+ { 'class': 'small-margin' },
+ (0, _preact.h)(
+ 'label',
+ null,
+ 'Email address'
+ ),
+ (0, _preact.h)('input', { type: 'email', name: 'email', placeholder: 'Email address', value: this.state.email, onChange: this.linkState('email'), required: 'required' })
+ ),
+ (0, _preact.h)(
+ 'div',
+ { 'class': 'small-margin' },
+ (0, _preact.h)(
+ 'label',
+ null,
+ 'Password'
+ ),
+ (0, _preact.h)('input', { type: 'password', name: 'password', placeholder: '**********', value: this.state.password, onChange: this.linkState('password'), required: 'required' })
+ ),
+ (0, _preact.h)(
+ 'div',
+ { 'class': 'small-margin' },
+ (0, _preact.h)('input', { type: 'submit', value: 'Sign in' })
+ )
+ ),
+ (0, _preact.h)(_Notification2.default, { message: this.state.message, kind: '' })
+ );
+ }
+ }]);
+
+ return LoginForm;
+}(_preact.Component);
+
+exports.default = LoginForm;
+
+},{"../components/Notification.js":8,"../lib/client.js":12,"preact":61}],7:[function(require,module,exports){
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+
+var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
+
+var _preact = require('preact');
+
+var _client = require('../lib/client.js');
+
+var _client2 = _interopRequireDefault(_client);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
+
+function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
+
+function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
+
+var LogoutButton = function (_Component) {
+ _inherits(LogoutButton, _Component);
+
+ function LogoutButton(props) {
+ _classCallCheck(this, LogoutButton);
+
+ var _this = _possibleConstructorReturn(this, (LogoutButton.__proto__ || Object.getPrototypeOf(LogoutButton)).call(this, props));
+
+ _this.handleSubmit = _this.handleSubmit.bind(_this);
+ return _this;
+ }
+
+ _createClass(LogoutButton, [{
+ key: 'handleSubmit',
+ value: function handleSubmit(e) {
+ var _this2 = this;
+
+ e.preventDefault();
+
+ _client2.default.request('session', {
+ method: "DELETE"
+ }).then(function (r) {
+ _this2.props.onSuccess();
+ });
+ }
+ }, {
+ key: 'render',
+ value: function render() {
+ return (0, _preact.h)(
+ 'a',
+ { href: '#', onClick: this.handleSubmit },
+ 'Sign out'
+ );
+ }
+ }]);
+
+ return LogoutButton;
+}(_preact.Component);
+
+exports.default = LogoutButton;
+
+},{"../lib/client.js":12,"preact":61}],8:[function(require,module,exports){
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+
+var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
+
+var _preact = require('preact');
+
+function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
+
+function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
+
+function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
+
+var Notification = function (_Component) {
+ _inherits(Notification, _Component);
+
+ function Notification(props) {
+ _classCallCheck(this, Notification);
+
+ var _this = _possibleConstructorReturn(this, (Notification.__proto__ || Object.getPrototypeOf(Notification)).call(this, props));
+
+ _this.state = {
+ message: props.message,
+ kind: props.kind || 'error'
+ };
+ _this.timeout = 0;
+ return _this;
+ }
+
+ _createClass(Notification, [{
+ key: 'clearMessage',
+ value: function clearMessage() {
+ this.setState({ message: '' });
+ }
+ }, {
+ key: 'componentWillReceiveProps',
+ value: function componentWillReceiveProps(newProps) {
+ if (newProps.message != this.state.message) {
+ this.setState({ message: newProps.message, kind: newProps.kind || 'error' });
+ window.clearTimeout(this.timeout);
+ this.timeout = window.setTimeout(this.clearMessage.bind(this), 5000);
+ }
+ }
+ }, {
+ key: 'render',
+ value: function render() {
+ if (this.state.message === '') {
+ return '';
+ }
+
+ return (0, _preact.h)(
+ 'div',
+ { 'class': 'notification' },
+ (0, _preact.h)(
+ 'div',
+ { 'class': 'notification-' + this.state.kind },
+ this.state.message
+ )
+ );
+ }
+ }]);
+
+ return Notification;
+}(_preact.Component);
+
+exports.default = Notification;
+
+},{"preact":61}],9:[function(require,module,exports){
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+
+var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
+
+var _preact = require('preact');
+
+var _numbers = require('../lib/numbers.js');
+
+var numbers = _interopRequireWildcard(_numbers);
+
+var _client = require('../lib/client.js');
+
+var _client2 = _interopRequireDefault(_client);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
+
+function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
+
+function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
+
+function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
+
+var dayInSeconds = 60 * 60 * 24;
+
+var Pageviews = function (_Component) {
+ _inherits(Pageviews, _Component);
+
+ function Pageviews(props) {
+ _classCallCheck(this, Pageviews);
+
+ var _this = _possibleConstructorReturn(this, (Pageviews.__proto__ || Object.getPrototypeOf(Pageviews)).call(this, props));
+
+ _this.state = {
+ records: [],
+ loading: false
+ };
+ _this.fetchRecords = _this.fetchRecords.bind(_this);
+ return _this;
+ }
+
+ _createClass(Pageviews, [{
+ key: 'componentDidMount',
+ value: function componentDidMount() {
+ this.fetchRecords(this.props.period);
+ }
+ }, {
+ key: 'componentWillReceiveProps',
+ value: function componentWillReceiveProps(newProps) {
+ if (this.props.period != newProps.period) {
+ this.fetchRecords(newProps.period);
+ }
+ }
+ }, {
+ key: 'fetchRecords',
+ value: function fetchRecords(period) {
+ var _this2 = this;
+
+ var before = Math.round(+new Date() / 1000);
+ var after = before - period * dayInSeconds;
+ this.setState({ loading: true });
+
+ _client2.default.request('pageviews?before=' + before + '&after=' + after).then(function (d) {
+ _this2.setState({ loading: false, records: d });
+ }).catch(function (e) {
+ console.log(e);
+ });
+ }
+ }, {
+ key: 'render',
+ value: function render() {
+ var loadingOverlay = this.state.loading ? (0, _preact.h)(
+ 'div',
+ { 'class': 'loading-overlay' },
+ (0, _preact.h)('div', null)
+ ) : '';
+ var tableRows = this.state.records.map(function (p, i) {
+ return (0, _preact.h)(
+ 'tr',
+ null,
+ (0, _preact.h)(
+ 'td',
+ { 'class': 'muted' },
+ i + 1
+ ),
+ (0, _preact.h)(
+ 'td',
+ null,
+ (0, _preact.h)(
+ 'a',
+ { href: "//" + p.Hostname + p.Path },
+ p.Path.substring(0, 50),
+ p.Path.length > 50 ? '..' : ''
+ )
+ ),
+ (0, _preact.h)(
+ 'td',
+ null,
+ numbers.formatWithComma(p.Count)
+ ),
+ (0, _preact.h)(
+ 'td',
+ null,
+ numbers.formatWithComma(p.CountUnique)
+ )
+ );
+ });
+
+ return (0, _preact.h)(
+ 'div',
+ { 'class': 'block' },
+ loadingOverlay,
+ (0, _preact.h)(
+ 'h3',
+ null,
+ 'Pageviews'
+ ),
+ (0, _preact.h)(
+ 'table',
+ { 'class': 'table pageviews' },
+ (0, _preact.h)(
+ 'thead',
+ null,
+ (0, _preact.h)(
+ 'tr',
+ null,
+ (0, _preact.h)(
+ 'th',
+ null,
+ '#'
+ ),
+ (0, _preact.h)(
+ 'th',
+ null,
+ 'URL'
+ ),
+ (0, _preact.h)(
+ 'th',
+ null,
+ 'Pageviews'
+ ),
+ (0, _preact.h)(
+ 'th',
+ null,
+ 'Unique'
+ )
+ )
+ ),
+ (0, _preact.h)(
+ 'tbody',
+ null,
+ tableRows
+ )
+ )
+ );
+ }
+ }]);
+
+ return Pageviews;
+}(_preact.Component);
+
+exports.default = Pageviews;
+
+},{"../lib/client.js":12,"../lib/numbers.js":13,"preact":61}],10:[function(require,module,exports){
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+
+var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
+
+var _preact = require('preact');
+
+var _client = require('../lib/client.js');
+
+var _client2 = _interopRequireDefault(_client);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
+
+function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
+
+function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
+
+var Realtime = function (_Component) {
+ _inherits(Realtime, _Component);
+
+ function Realtime(props) {
+ _classCallCheck(this, Realtime);
+
+ var _this = _possibleConstructorReturn(this, (Realtime.__proto__ || Object.getPrototypeOf(Realtime)).call(this, props));
+
+ _this.state = {
+ count: 0
+ };
+ _this.fetchData = _this.fetchData.bind(_this);
+ _this.fetchData();
+ window.setInterval(_this.fetchData, 15000);
+ return _this;
+ }
+
+ _createClass(Realtime, [{
+ key: 'fetchData',
+ value: function fetchData() {
+ var _this2 = this;
+
+ _client2.default.request('visitors/count/realtime').then(function (d) {
+ _this2.setState({ count: d });
+ });
+ }
+ }, {
+ key: 'render',
+ value: function render() {
+ var visitors = this.state.count == 1 ? 'visitor' : 'visitors';
+ return (0, _preact.h)(
+ 'div',
+ { 'class': 'block block-float' },
+ (0, _preact.h)(
+ 'span',
+ { 'class': 'count' },
+ this.state.count
+ ),
+ ' ',
+ (0, _preact.h)(
+ 'span',
+ null,
+ visitors,
+ ' on the site right now.'
+ )
+ );
+ }
+ }]);
+
+ return Realtime;
+}(_preact.Component);
+
+exports.default = Realtime;
+
+},{"../lib/client.js":12,"preact":61}],11:[function(require,module,exports){
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+
+var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
+
+var _preact = require('preact');
+
+var _numbers = require('../lib/numbers.js');
+
+var numbers = _interopRequireWildcard(_numbers);
+
+var _client = require('../lib/client.js');
+
+var _client2 = _interopRequireDefault(_client);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
+
+function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
+
+function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
+
+function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
+
+var dayInSeconds = 60 * 60 * 24;
+
+var Table = function (_Component) {
+ _inherits(Table, _Component);
+
+ function Table(props) {
+ _classCallCheck(this, Table);
+
+ var _this = _possibleConstructorReturn(this, (Table.__proto__ || Object.getPrototypeOf(Table)).call(this, props));
+
+ _this.state = {
+ records: [],
+ limit: 5,
+ loading: true
+ };
+
+ _this.tableHeaders = props.headers.map(function (heading) {
+ return (0, _preact.h)(
+ 'th',
+ null,
+ heading
+ );
+ });
+ _this.fetchRecords = _this.fetchRecords.bind(_this);
+ _this.handleLimitChoice = _this.handleLimitChoice.bind(_this);
+ return _this;
+ }
+
+ _createClass(Table, [{
+ key: 'componentDidMount',
+ value: function componentDidMount() {
+ this.fetchRecords(this.props.period, this.state.limit);
+ }
+ }, {
+ key: 'labelCell',
+ value: function labelCell(p) {
+ if (this.props.labelCell) {
+ return this.props.labelCell(p);
+ }
+
+ return (0, _preact.h)(
+ 'td',
+ null,
+ p.Label.substring(0, 15)
+ );
+ }
+ }, {
+ key: 'componentWillReceiveProps',
+ value: function componentWillReceiveProps(newProps) {
+ if (this.props.period != newProps.period) {
+ this.fetchRecords(newProps.period, this.state.limit);
+ }
+ }
+ }, {
+ key: 'handleLimitChoice',
+ value: function handleLimitChoice(e) {
+ this.setState({ limit: parseInt(e.target.value) });
+ this.fetchRecords(this.props.period, this.state.limit);
+ }
+ }, {
+ key: 'fetchRecords',
+ value: function fetchRecords(period, limit) {
+ var _this2 = this;
+
+ this.setState({ loading: true });
+ var before = Math.round(+new Date() / 1000);
+ var after = before - period * dayInSeconds;
+
+ _client2.default.request(this.props.endpoint + '?before=' + before + '&after=' + after + '&limit=' + limit).then(function (d) {
+ _this2.setState({ loading: false, records: d });
+ }).catch(function (e) {
+ console.log(e);
+ });
+ }
+ }, {
+ key: 'render',
+ value: function render() {
+ var _this3 = this;
+
+ var tableRows = this.state.records.length > 0 ? this.state.records.map(function (p, i) {
+ return (0, _preact.h)(
+ 'tr',
+ null,
+ (0, _preact.h)(
+ 'td',
+ { 'class': 'muted' },
+ i + 1
+ ),
+ _this3.labelCell(p),
+ (0, _preact.h)(
+ 'td',
+ null,
+ numbers.formatWithComma(p.Value)
+ ),
+ (0, _preact.h)(
+ 'td',
+ null,
+ Math.round(p.PercentageValue),
+ '%'
+ )
+ );
+ }) : (0, _preact.h)(
+ 'tr',
+ null,
+ (0, _preact.h)(
+ 'td',
+ { colspan: '4', 'class': 'italic' },
+ 'Nothing here..'
+ )
+ );
+
+ var loadingOverlay = this.state.loading ? (0, _preact.h)(
+ 'div',
+ { 'class': 'loading-overlay' },
+ (0, _preact.h)('div', null)
+ ) : '';
+
+ return (0, _preact.h)(
+ 'div',
+ { 'class': 'block' },
+ loadingOverlay,
+ (0, _preact.h)(
+ 'div',
+ { 'class': 'clearfix' },
+ (0, _preact.h)(
+ 'h3',
+ { 'class': 'pull-left' },
+ this.props.title
+ ),
+ (0, _preact.h)(
+ 'div',
+ { 'class': 'pull-right' },
+ (0, _preact.h)(
+ 'select',
+ { onchange: this.handleLimitChoice },
+ (0, _preact.h)(
+ 'option',
+ null,
+ '5'
+ ),
+ (0, _preact.h)(
+ 'option',
+ null,
+ '20'
+ ),
+ (0, _preact.h)(
+ 'option',
+ null,
+ '100'
+ )
+ )
+ )
+ ),
+ (0, _preact.h)(
+ 'table',
+ null,
+ (0, _preact.h)(
+ 'thead',
+ null,
+ (0, _preact.h)(
+ 'tr',
+ null,
+ this.tableHeaders
+ )
+ ),
+ (0, _preact.h)(
+ 'tbody',
+ null,
+ tableRows
+ )
+ )
+ );
+ }
+ }]);
+
+ return Table;
+}(_preact.Component);
+
+exports.default = Table;
+
+},{"../lib/client.js":12,"../lib/numbers.js":13,"preact":61}],12:[function(require,module,exports){
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+var Client = {};
+Client.request = function (resource, args) {
+ args = args || {};
+ args.credentials = 'same-origin';
+ args.headers = args.headers || {};
+ args.headers['Accept'] = 'application/json';
+
+ if (args.method && args.method === 'POST') {
+ args.headers['Content-Type'] = 'application/json';
+
+ if (args.data) {
+ if (typeof args.data !== "string") {
+ args.data = JSON.stringify(args.data);
+ }
+ args.body = args.data;
+ delete args.data;
+ }
+ }
+
+ return fetch('/api/' + resource, args).then(parseJSON).then(checkData);
+};
+
+function parseJSON(r) {
+ return r.json();
+}
+
+function checkData(d) {
+ if (d.Error) {
+ throw new Error(d.Error);
+ }
+
+ return d.Data;
+}
+
+exports.default = Client;
+
+},{}],13:[function(require,module,exports){
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+function formatWithComma(nStr) {
+ nStr += '';
+
+ if (nStr.length < 4) {
+ return nStr;
+ }
+
+ var x = nStr.split('.');
+ var x1 = x[0];
+ var x2 = x.length > 1 ? '.' + x[1] : '';
+ var rgx = /(\d+)(\d{3})/;
+ while (rgx.test(x1)) {
+ x1 = x1.replace(rgx, '$1' + ',' + '$2');
+ }
+ return x1 + x2;
+}
+
+exports.formatWithComma = formatWithComma;
+
+},{}],14:[function(require,module,exports){
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+
+var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
+
+var _preact = require('preact');
+
+var _Pageviews = require('../components/Pageviews.js');
+
+var _Pageviews2 = _interopRequireDefault(_Pageviews);
+
+var _Realtime = require('../components/Realtime.js');
+
+var _Realtime2 = _interopRequireDefault(_Realtime);
+
+var _GraphWidget = require('../components/GraphWidget.js');
+
+var _GraphWidget2 = _interopRequireDefault(_GraphWidget);
+
+var _DatePicker = require('../components/DatePicker.js');
+
+var _DatePicker2 = _interopRequireDefault(_DatePicker);
+
+var _Table = require('../components/Table.js');
+
+var _Table2 = _interopRequireDefault(_Table);
+
+var _HeaderBar = require('../components/HeaderBar.js');
+
+var _HeaderBar2 = _interopRequireDefault(_HeaderBar);
+
+var _CountWidget = require('../components/CountWidget.js');
+
+var _CountWidget2 = _interopRequireDefault(_CountWidget);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
+
+function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
+
+function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
+
+function removeImgElement(e) {
+ e.target.parentNode.removeChild(e.target);
+}
+
+function formatCountryLabel(p) {
+ var src = "/static/img/country-flags/" + p.Label.toLowerCase() + ".png";
+
+ return (0, _preact.h)(
+ 'td',
+ null,
+ p.Label,
+ (0, _preact.h)('img', { height: '12', src: src, 'class': 'pull-right', onError: removeImgElement })
+ );
+}
+
+var Dashboard = function (_Component) {
+ _inherits(Dashboard, _Component);
+
+ function Dashboard(props) {
+ _classCallCheck(this, Dashboard);
+
+ var _this = _possibleConstructorReturn(this, (Dashboard.__proto__ || Object.getPrototypeOf(Dashboard)).call(this, props));
+
+ _this.state = {
+ period: parseInt(window.location.hash.substring(2)) || 7
+ };
+
+ _this.onPeriodChoose = _this.onPeriodChoose.bind(_this);
+ return _this;
+ }
+
+ _createClass(Dashboard, [{
+ key: 'onPeriodChoose',
+ value: function onPeriodChoose(p) {
+ this.setState({ period: p });
+ window.history.replaceState(this.state, null, '#!' + p);
+ }
+ }, {
+ key: 'render',
+ value: function render() {
+ return (0, _preact.h)(
+ 'div',
+ null,
+ (0, _preact.h)(_HeaderBar2.default, { showLogout: true, onLogout: this.props.onLogout }),
+ (0, _preact.h)(
+ 'div',
+ { 'class': 'container' },
+ (0, _preact.h)(_Realtime2.default, null),
+ (0, _preact.h)(
+ 'div',
+ { 'class': 'clear' },
+ (0, _preact.h)(_DatePicker2.default, { period: this.state.period, onChoose: this.onPeriodChoose })
+ ),
+ (0, _preact.h)(
+ 'div',
+ { 'class': 'row' },
+ (0, _preact.h)(
+ 'div',
+ { 'class': 'col-2' },
+ (0, _preact.h)(_CountWidget2.default, { title: 'Visitors', endpoint: 'visitors', period: this.state.period })
+ ),
+ (0, _preact.h)(
+ 'div',
+ { 'class': 'col-2' },
+ (0, _preact.h)(_CountWidget2.default, { title: 'Pageviews', endpoint: 'pageviews', period: this.state.period })
+ )
+ ),
+ (0, _preact.h)(_GraphWidget2.default, { period: this.state.period }),
+ (0, _preact.h)(
+ 'div',
+ { 'class': 'row' },
+ (0, _preact.h)(
+ 'div',
+ { 'class': 'col-4' },
+ (0, _preact.h)(_Pageviews2.default, { period: this.state.period })
+ ),
+ (0, _preact.h)(
+ 'div',
+ { 'class': 'col-2' },
+ (0, _preact.h)(_Table2.default, { period: this.state.period, endpoint: 'languages', title: 'Languages', headers: ["#", "Language", "Count", "%"] })
+ )
+ ),
+ (0, _preact.h)(
+ 'div',
+ { 'class': 'row' },
+ (0, _preact.h)(
+ 'div',
+ { 'class': 'col-2' },
+ (0, _preact.h)(_Table2.default, { period: this.state.period, endpoint: 'screen-resolutions', title: 'Screen Resolutions', headers: ["#", "Resolution", "Count", "%"] })
+ ),
+ (0, _preact.h)(
+ 'div',
+ { 'class': 'col-2' },
+ (0, _preact.h)(_Table2.default, { period: this.state.period, endpoint: 'referrers', title: 'Referrers', headers: ["#", "URL", "Count", "%"], labelCell: function labelCell(p) {
+ return (0, _preact.h)(
+ 'td',
+ null,
+ (0, _preact.h)(
+ 'a',
+ { href: "//" + p.Label },
+ p.Label.substring(0, 15).replace('https://', '').replace('http://', '')
+ )
+ );
+ } })
+ ),
+ (0, _preact.h)(
+ 'div',
+ { 'class': 'col-2' },
+ (0, _preact.h)(_Table2.default, { period: this.state.period, endpoint: 'browsers', title: 'Browsers', headers: ["#", "Browser", "Count", "%"], onAuthError: this.props.onLogout })
+ )
+ )
+ )
+ );
+ }
+ }]);
+
+ return Dashboard;
+}(_preact.Component);
+
+exports.default = Dashboard;
+
+},{"../components/CountWidget.js":1,"../components/DatePicker.js":2,"../components/GraphWidget.js":4,"../components/HeaderBar.js":5,"../components/Pageviews.js":9,"../components/Realtime.js":10,"../components/Table.js":11,"preact":61}],15:[function(require,module,exports){
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+
+var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
+
+var _preact = require('preact');
+
+var _LoginForm = require('../components/LoginForm.js');
+
+var _LoginForm2 = _interopRequireDefault(_LoginForm);
+
+var _HeaderBar = require('../components/HeaderBar.js');
+
+var _HeaderBar2 = _interopRequireDefault(_HeaderBar);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
+
+function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
+
+function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
+
+var Login = function (_Component) {
+ _inherits(Login, _Component);
+
+ function Login() {
+ _classCallCheck(this, Login);
+
+ return _possibleConstructorReturn(this, (Login.__proto__ || Object.getPrototypeOf(Login)).apply(this, arguments));
+ }
+
+ _createClass(Login, [{
+ key: 'render',
+ value: function render() {
+ return (0, _preact.h)(
+ 'div',
+ null,
+ (0, _preact.h)(_HeaderBar2.default, { showLogout: false }),
+ (0, _preact.h)(
+ 'div',
+ { 'class': 'container' },
+ (0, _preact.h)(_LoginForm2.default, { onSuccess: this.props.onLogin })
+ )
+ );
+ }
+ }]);
+
+ return Login;
+}(_preact.Component);
+
+exports.default = Login;
+
+},{"../components/HeaderBar.js":5,"../components/LoginForm.js":6,"preact":61}],16:[function(require,module,exports){
+'use strict';
+
+var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
+
+var _preact = require('preact');
+
+var _login = require('./pages/login.js');
+
+var _login2 = _interopRequireDefault(_login);
+
+var _dashboard = require('./pages/dashboard.js');
+
+var _dashboard2 = _interopRequireDefault(_dashboard);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
+
+function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
+
+function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
+
+var App = function (_Component) {
+ _inherits(App, _Component);
+
+ function App(props) {
+ _classCallCheck(this, App);
+
+ var _this = _possibleConstructorReturn(this, (App.__proto__ || Object.getPrototypeOf(App)).call(this, props));
+
+ _this.state = {
+ authenticated: document.cookie.indexOf('auth') > -1
+ };
+ return _this;
+ }
+
+ _createClass(App, [{
+ key: 'render',
+ value: function render() {
+ var _this2 = this;
+
+ // logged-in
+ if (this.state.authenticated) {
+ return (0, _preact.h)(_dashboard2.default, { onLogout: function onLogout() {
+ return _this2.setState({ authenticated: false });
+ } });
+ }
+
+ // logged-out
+ return (0, _preact.h)(_login2.default, { onLogin: function onLogin() {
+ return _this2.setState({ authenticated: true });
+ } });
+ }
+ }]);
+
+ return App;
+}(_preact.Component);
+
+(0, _preact.render)((0, _preact.h)(App, null), document.getElementById('root'));
+
+},{"./pages/dashboard.js":14,"./pages/login.js":15,"preact":61}],17:[function(require,module,exports){
+'use strict'
+
+exports.byteLength = byteLength
+exports.toByteArray = toByteArray
+exports.fromByteArray = fromByteArray
+
+var lookup = []
+var revLookup = []
+var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array
+
+var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
+for (var i = 0, len = code.length; i < len; ++i) {
+ lookup[i] = code[i]
+ revLookup[code.charCodeAt(i)] = i
+}
+
+// Support decoding URL-safe base64 strings, as Node.js does.
+// See: https://en.wikipedia.org/wiki/Base64#URL_applications
+revLookup['-'.charCodeAt(0)] = 62
+revLookup['_'.charCodeAt(0)] = 63
+
+function getLens (b64) {
+ var len = b64.length
+
+ if (len % 4 > 0) {
+ throw new Error('Invalid string. Length must be a multiple of 4')
+ }
+
+ // Trim off extra bytes after placeholder bytes are found
+ // See: https://github.com/beatgammit/base64-js/issues/42
+ var validLen = b64.indexOf('=')
+ if (validLen === -1) validLen = len
+
+ var placeHoldersLen = validLen === len
+ ? 0
+ : 4 - (validLen % 4)
+
+ return [validLen, placeHoldersLen]
+}
+
+// base64 is 4/3 + up to two characters of the original data
+function byteLength (b64) {
+ var lens = getLens(b64)
+ var validLen = lens[0]
+ var placeHoldersLen = lens[1]
+ return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen
+}
+
+function _byteLength (b64, validLen, placeHoldersLen) {
+ return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen
+}
+
+function toByteArray (b64) {
+ var tmp
+ var lens = getLens(b64)
+ var validLen = lens[0]
+ var placeHoldersLen = lens[1]
+
+ var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen))
+
+ var curByte = 0
+
+ // if there are placeholders, only get up to the last complete 4 chars
+ var len = placeHoldersLen > 0
+ ? validLen - 4
+ : validLen
+
+ for (var i = 0; i < len; i += 4) {
+ tmp =
+ (revLookup[b64.charCodeAt(i)] << 18) |
+ (revLookup[b64.charCodeAt(i + 1)] << 12) |
+ (revLookup[b64.charCodeAt(i + 2)] << 6) |
+ revLookup[b64.charCodeAt(i + 3)]
+ arr[curByte++] = (tmp >> 16) & 0xFF
+ arr[curByte++] = (tmp >> 8) & 0xFF
+ arr[curByte++] = tmp & 0xFF
+ }
+
+ if (placeHoldersLen === 2) {
+ tmp =
+ (revLookup[b64.charCodeAt(i)] << 2) |
+ (revLookup[b64.charCodeAt(i + 1)] >> 4)
+ arr[curByte++] = tmp & 0xFF
+ }
+
+ if (placeHoldersLen === 1) {
+ tmp =
+ (revLookup[b64.charCodeAt(i)] << 10) |
+ (revLookup[b64.charCodeAt(i + 1)] << 4) |
+ (revLookup[b64.charCodeAt(i + 2)] >> 2)
+ arr[curByte++] = (tmp >> 8) & 0xFF
+ arr[curByte++] = tmp & 0xFF
+ }
+
+ return arr
+}
+
+function tripletToBase64 (num) {
+ return lookup[num >> 18 & 0x3F] +
+ lookup[num >> 12 & 0x3F] +
+ lookup[num >> 6 & 0x3F] +
+ lookup[num & 0x3F]
+}
+
+function encodeChunk (uint8, start, end) {
+ var tmp
+ var output = []
+ for (var i = start; i < end; i += 3) {
+ tmp =
+ ((uint8[i] << 16) & 0xFF0000) +
+ ((uint8[i + 1] << 8) & 0xFF00) +
+ (uint8[i + 2] & 0xFF)
+ output.push(tripletToBase64(tmp))
+ }
+ return output.join('')
+}
+
+function fromByteArray (uint8) {
+ var tmp
+ var len = uint8.length
+ var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes
+ var parts = []
+ var maxChunkLength = 16383 // must be multiple of 3
+
+ // go through the array every three bytes, we'll deal with trailing stuff later
+ for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {
+ parts.push(encodeChunk(
+ uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength)
+ ))
+ }
+
+ // pad the end with zeros, but make sure to not forget the extra bytes
+ if (extraBytes === 1) {
+ tmp = uint8[len - 1]
+ parts.push(
+ lookup[tmp >> 2] +
+ lookup[(tmp << 4) & 0x3F] +
+ '=='
+ )
+ } else if (extraBytes === 2) {
+ tmp = (uint8[len - 2] << 8) + uint8[len - 1]
+ parts.push(
+ lookup[tmp >> 10] +
+ lookup[(tmp >> 4) & 0x3F] +
+ lookup[(tmp << 2) & 0x3F] +
+ '='
+ )
+ }
+
+ return parts.join('')
+}
+
+},{}],18:[function(require,module,exports){
+
+},{}],19:[function(require,module,exports){
+arguments[4][18][0].apply(exports,arguments)
+},{"dup":18}],20:[function(require,module,exports){
+(function (global){
+/*!
+ * The buffer module from node.js, for the browser.
+ *
+ * @author Feross Aboukhadijeh
+ * @license MIT
+ */
+/* eslint-disable no-proto */
+
+'use strict'
+
+var base64 = require('base64-js')
+var ieee754 = require('ieee754')
+var isArray = require('isarray')
+
+exports.Buffer = Buffer
+exports.SlowBuffer = SlowBuffer
+exports.INSPECT_MAX_BYTES = 50
+
+/**
+ * If `Buffer.TYPED_ARRAY_SUPPORT`:
+ * === true Use Uint8Array implementation (fastest)
+ * === false Use Object implementation (most compatible, even IE6)
+ *
+ * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+,
+ * Opera 11.6+, iOS 4.2+.
+ *
+ * Due to various browser bugs, sometimes the Object implementation will be used even
+ * when the browser supports typed arrays.
+ *
+ * Note:
+ *
+ * - Firefox 4-29 lacks support for adding new properties to `Uint8Array` instances,
+ * See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438.
+ *
+ * - Chrome 9-10 is missing the `TypedArray.prototype.subarray` function.
+ *
+ * - IE10 has a broken `TypedArray.prototype.subarray` function which returns arrays of
+ * incorrect length in some situations.
+
+ * We detect these buggy browsers and set `Buffer.TYPED_ARRAY_SUPPORT` to `false` so they
+ * get the Object implementation, which is slower but behaves correctly.
+ */
+Buffer.TYPED_ARRAY_SUPPORT = global.TYPED_ARRAY_SUPPORT !== undefined
+ ? global.TYPED_ARRAY_SUPPORT
+ : typedArraySupport()
+
+/*
+ * Export kMaxLength after typed array support is determined.
+ */
+exports.kMaxLength = kMaxLength()
+
+function typedArraySupport () {
+ try {
+ var arr = new Uint8Array(1)
+ arr.__proto__ = {__proto__: Uint8Array.prototype, foo: function () { return 42 }}
+ return arr.foo() === 42 && // typed array instances can be augmented
+ typeof arr.subarray === 'function' && // chrome 9-10 lack `subarray`
+ arr.subarray(1, 1).byteLength === 0 // ie10 has broken `subarray`
+ } catch (e) {
+ return false
+ }
+}
+
+function kMaxLength () {
+ return Buffer.TYPED_ARRAY_SUPPORT
+ ? 0x7fffffff
+ : 0x3fffffff
+}
+
+function createBuffer (that, length) {
+ if (kMaxLength() < length) {
+ throw new RangeError('Invalid typed array length')
+ }
+ if (Buffer.TYPED_ARRAY_SUPPORT) {
+ // Return an augmented `Uint8Array` instance, for best performance
+ that = new Uint8Array(length)
+ that.__proto__ = Buffer.prototype
+ } else {
+ // Fallback: Return an object instance of the Buffer class
+ if (that === null) {
+ that = new Buffer(length)
+ }
+ that.length = length
+ }
+
+ return that
+}
+
+/**
+ * The Buffer constructor returns instances of `Uint8Array` that have their
+ * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of
+ * `Uint8Array`, so the returned instances will have all the node `Buffer` methods
+ * and the `Uint8Array` methods. Square bracket notation works as expected -- it
+ * returns a single octet.
+ *
+ * The `Uint8Array` prototype remains unmodified.
+ */
+
+function Buffer (arg, encodingOrOffset, length) {
+ if (!Buffer.TYPED_ARRAY_SUPPORT && !(this instanceof Buffer)) {
+ return new Buffer(arg, encodingOrOffset, length)
+ }
+
+ // Common case.
+ if (typeof arg === 'number') {
+ if (typeof encodingOrOffset === 'string') {
+ throw new Error(
+ 'If encoding is specified then the first argument must be a string'
+ )
+ }
+ return allocUnsafe(this, arg)
+ }
+ return from(this, arg, encodingOrOffset, length)
+}
+
+Buffer.poolSize = 8192 // not used by this implementation
+
+// TODO: Legacy, not needed anymore. Remove in next major version.
+Buffer._augment = function (arr) {
+ arr.__proto__ = Buffer.prototype
+ return arr
+}
+
+function from (that, value, encodingOrOffset, length) {
+ if (typeof value === 'number') {
+ throw new TypeError('"value" argument must not be a number')
+ }
+
+ if (typeof ArrayBuffer !== 'undefined' && value instanceof ArrayBuffer) {
+ return fromArrayBuffer(that, value, encodingOrOffset, length)
+ }
+
+ if (typeof value === 'string') {
+ return fromString(that, value, encodingOrOffset)
+ }
+
+ return fromObject(that, value)
+}
+
+/**
+ * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError
+ * if value is a number.
+ * Buffer.from(str[, encoding])
+ * Buffer.from(array)
+ * Buffer.from(buffer)
+ * Buffer.from(arrayBuffer[, byteOffset[, length]])
+ **/
+Buffer.from = function (value, encodingOrOffset, length) {
+ return from(null, value, encodingOrOffset, length)
+}
+
+if (Buffer.TYPED_ARRAY_SUPPORT) {
+ Buffer.prototype.__proto__ = Uint8Array.prototype
+ Buffer.__proto__ = Uint8Array
+ if (typeof Symbol !== 'undefined' && Symbol.species &&
+ Buffer[Symbol.species] === Buffer) {
+ // Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97
+ Object.defineProperty(Buffer, Symbol.species, {
+ value: null,
+ configurable: true
+ })
+ }
+}
+
+function assertSize (size) {
+ if (typeof size !== 'number') {
+ throw new TypeError('"size" argument must be a number')
+ } else if (size < 0) {
+ throw new RangeError('"size" argument must not be negative')
+ }
+}
+
+function alloc (that, size, fill, encoding) {
+ assertSize(size)
+ if (size <= 0) {
+ return createBuffer(that, size)
+ }
+ if (fill !== undefined) {
+ // Only pay attention to encoding if it's a string. This
+ // prevents accidentally sending in a number that would
+ // be interpretted as a start offset.
+ return typeof encoding === 'string'
+ ? createBuffer(that, size).fill(fill, encoding)
+ : createBuffer(that, size).fill(fill)
+ }
+ return createBuffer(that, size)
+}
+
+/**
+ * Creates a new filled Buffer instance.
+ * alloc(size[, fill[, encoding]])
+ **/
+Buffer.alloc = function (size, fill, encoding) {
+ return alloc(null, size, fill, encoding)
+}
+
+function allocUnsafe (that, size) {
+ assertSize(size)
+ that = createBuffer(that, size < 0 ? 0 : checked(size) | 0)
+ if (!Buffer.TYPED_ARRAY_SUPPORT) {
+ for (var i = 0; i < size; ++i) {
+ that[i] = 0
+ }
+ }
+ return that
+}
+
+/**
+ * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance.
+ * */
+Buffer.allocUnsafe = function (size) {
+ return allocUnsafe(null, size)
+}
+/**
+ * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
+ */
+Buffer.allocUnsafeSlow = function (size) {
+ return allocUnsafe(null, size)
+}
+
+function fromString (that, string, encoding) {
+ if (typeof encoding !== 'string' || encoding === '') {
+ encoding = 'utf8'
+ }
+
+ if (!Buffer.isEncoding(encoding)) {
+ throw new TypeError('"encoding" must be a valid string encoding')
+ }
+
+ var length = byteLength(string, encoding) | 0
+ that = createBuffer(that, length)
+
+ var actual = that.write(string, encoding)
+
+ if (actual !== length) {
+ // Writing a hex string, for example, that contains invalid characters will
+ // cause everything after the first invalid character to be ignored. (e.g.
+ // 'abxxcd' will be treated as 'ab')
+ that = that.slice(0, actual)
+ }
+
+ return that
+}
+
+function fromArrayLike (that, array) {
+ var length = array.length < 0 ? 0 : checked(array.length) | 0
+ that = createBuffer(that, length)
+ for (var i = 0; i < length; i += 1) {
+ that[i] = array[i] & 255
+ }
+ return that
+}
+
+function fromArrayBuffer (that, array, byteOffset, length) {
+ array.byteLength // this throws if `array` is not a valid ArrayBuffer
+
+ if (byteOffset < 0 || array.byteLength < byteOffset) {
+ throw new RangeError('\'offset\' is out of bounds')
+ }
+
+ if (array.byteLength < byteOffset + (length || 0)) {
+ throw new RangeError('\'length\' is out of bounds')
+ }
+
+ if (byteOffset === undefined && length === undefined) {
+ array = new Uint8Array(array)
+ } else if (length === undefined) {
+ array = new Uint8Array(array, byteOffset)
+ } else {
+ array = new Uint8Array(array, byteOffset, length)
+ }
+
+ if (Buffer.TYPED_ARRAY_SUPPORT) {
+ // Return an augmented `Uint8Array` instance, for best performance
+ that = array
+ that.__proto__ = Buffer.prototype
+ } else {
+ // Fallback: Return an object instance of the Buffer class
+ that = fromArrayLike(that, array)
+ }
+ return that
+}
+
+function fromObject (that, obj) {
+ if (Buffer.isBuffer(obj)) {
+ var len = checked(obj.length) | 0
+ that = createBuffer(that, len)
+
+ if (that.length === 0) {
+ return that
+ }
+
+ obj.copy(that, 0, 0, len)
+ return that
+ }
+
+ if (obj) {
+ if ((typeof ArrayBuffer !== 'undefined' &&
+ obj.buffer instanceof ArrayBuffer) || 'length' in obj) {
+ if (typeof obj.length !== 'number' || isnan(obj.length)) {
+ return createBuffer(that, 0)
+ }
+ return fromArrayLike(that, obj)
+ }
+
+ if (obj.type === 'Buffer' && isArray(obj.data)) {
+ return fromArrayLike(that, obj.data)
+ }
+ }
+
+ throw new TypeError('First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.')
+}
+
+function checked (length) {
+ // Note: cannot use `length < kMaxLength()` here because that fails when
+ // length is NaN (which is otherwise coerced to zero.)
+ if (length >= kMaxLength()) {
+ throw new RangeError('Attempt to allocate Buffer larger than maximum ' +
+ 'size: 0x' + kMaxLength().toString(16) + ' bytes')
+ }
+ return length | 0
+}
+
+function SlowBuffer (length) {
+ if (+length != length) { // eslint-disable-line eqeqeq
+ length = 0
+ }
+ return Buffer.alloc(+length)
+}
+
+Buffer.isBuffer = function isBuffer (b) {
+ return !!(b != null && b._isBuffer)
+}
+
+Buffer.compare = function compare (a, b) {
+ if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) {
+ throw new TypeError('Arguments must be Buffers')
+ }
+
+ if (a === b) return 0
+
+ var x = a.length
+ var y = b.length
+
+ for (var i = 0, len = Math.min(x, y); i < len; ++i) {
+ if (a[i] !== b[i]) {
+ x = a[i]
+ y = b[i]
+ break
+ }
+ }
+
+ if (x < y) return -1
+ if (y < x) return 1
+ return 0
+}
+
+Buffer.isEncoding = function isEncoding (encoding) {
+ switch (String(encoding).toLowerCase()) {
+ case 'hex':
+ case 'utf8':
+ case 'utf-8':
+ case 'ascii':
+ case 'latin1':
+ case 'binary':
+ case 'base64':
+ case 'ucs2':
+ case 'ucs-2':
+ case 'utf16le':
+ case 'utf-16le':
+ return true
+ default:
+ return false
+ }
+}
+
+Buffer.concat = function concat (list, length) {
+ if (!isArray(list)) {
+ throw new TypeError('"list" argument must be an Array of Buffers')
+ }
+
+ if (list.length === 0) {
+ return Buffer.alloc(0)
+ }
+
+ var i
+ if (length === undefined) {
+ length = 0
+ for (i = 0; i < list.length; ++i) {
+ length += list[i].length
+ }
+ }
+
+ var buffer = Buffer.allocUnsafe(length)
+ var pos = 0
+ for (i = 0; i < list.length; ++i) {
+ var buf = list[i]
+ if (!Buffer.isBuffer(buf)) {
+ throw new TypeError('"list" argument must be an Array of Buffers')
+ }
+ buf.copy(buffer, pos)
+ pos += buf.length
+ }
+ return buffer
+}
+
+function byteLength (string, encoding) {
+ if (Buffer.isBuffer(string)) {
+ return string.length
+ }
+ if (typeof ArrayBuffer !== 'undefined' && typeof ArrayBuffer.isView === 'function' &&
+ (ArrayBuffer.isView(string) || string instanceof ArrayBuffer)) {
+ return string.byteLength
+ }
+ if (typeof string !== 'string') {
+ string = '' + string
+ }
+
+ var len = string.length
+ if (len === 0) return 0
+
+ // Use a for loop to avoid recursion
+ var loweredCase = false
+ for (;;) {
+ switch (encoding) {
+ case 'ascii':
+ case 'latin1':
+ case 'binary':
+ return len
+ case 'utf8':
+ case 'utf-8':
+ case undefined:
+ return utf8ToBytes(string).length
+ case 'ucs2':
+ case 'ucs-2':
+ case 'utf16le':
+ case 'utf-16le':
+ return len * 2
+ case 'hex':
+ return len >>> 1
+ case 'base64':
+ return base64ToBytes(string).length
+ default:
+ if (loweredCase) return utf8ToBytes(string).length // assume utf8
+ encoding = ('' + encoding).toLowerCase()
+ loweredCase = true
+ }
+ }
+}
+Buffer.byteLength = byteLength
+
+function slowToString (encoding, start, end) {
+ var loweredCase = false
+
+ // No need to verify that "this.length <= MAX_UINT32" since it's a read-only
+ // property of a typed array.
+
+ // This behaves neither like String nor Uint8Array in that we set start/end
+ // to their upper/lower bounds if the value passed is out of range.
+ // undefined is handled specially as per ECMA-262 6th Edition,
+ // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization.
+ if (start === undefined || start < 0) {
+ start = 0
+ }
+ // Return early if start > this.length. Done here to prevent potential uint32
+ // coercion fail below.
+ if (start > this.length) {
+ return ''
+ }
+
+ if (end === undefined || end > this.length) {
+ end = this.length
+ }
+
+ if (end <= 0) {
+ return ''
+ }
+
+ // Force coersion to uint32. This will also coerce falsey/NaN values to 0.
+ end >>>= 0
+ start >>>= 0
+
+ if (end <= start) {
+ return ''
+ }
+
+ if (!encoding) encoding = 'utf8'
+
+ while (true) {
+ switch (encoding) {
+ case 'hex':
+ return hexSlice(this, start, end)
+
+ case 'utf8':
+ case 'utf-8':
+ return utf8Slice(this, start, end)
+
+ case 'ascii':
+ return asciiSlice(this, start, end)
+
+ case 'latin1':
+ case 'binary':
+ return latin1Slice(this, start, end)
+
+ case 'base64':
+ return base64Slice(this, start, end)
+
+ case 'ucs2':
+ case 'ucs-2':
+ case 'utf16le':
+ case 'utf-16le':
+ return utf16leSlice(this, start, end)
+
+ default:
+ if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
+ encoding = (encoding + '').toLowerCase()
+ loweredCase = true
+ }
+ }
+}
+
+// The property is used by `Buffer.isBuffer` and `is-buffer` (in Safari 5-7) to detect
+// Buffer instances.
+Buffer.prototype._isBuffer = true
+
+function swap (b, n, m) {
+ var i = b[n]
+ b[n] = b[m]
+ b[m] = i
+}
+
+Buffer.prototype.swap16 = function swap16 () {
+ var len = this.length
+ if (len % 2 !== 0) {
+ throw new RangeError('Buffer size must be a multiple of 16-bits')
+ }
+ for (var i = 0; i < len; i += 2) {
+ swap(this, i, i + 1)
+ }
+ return this
+}
+
+Buffer.prototype.swap32 = function swap32 () {
+ var len = this.length
+ if (len % 4 !== 0) {
+ throw new RangeError('Buffer size must be a multiple of 32-bits')
+ }
+ for (var i = 0; i < len; i += 4) {
+ swap(this, i, i + 3)
+ swap(this, i + 1, i + 2)
+ }
+ return this
+}
+
+Buffer.prototype.swap64 = function swap64 () {
+ var len = this.length
+ if (len % 8 !== 0) {
+ throw new RangeError('Buffer size must be a multiple of 64-bits')
+ }
+ for (var i = 0; i < len; i += 8) {
+ swap(this, i, i + 7)
+ swap(this, i + 1, i + 6)
+ swap(this, i + 2, i + 5)
+ swap(this, i + 3, i + 4)
+ }
+ return this
+}
+
+Buffer.prototype.toString = function toString () {
+ var length = this.length | 0
+ if (length === 0) return ''
+ if (arguments.length === 0) return utf8Slice(this, 0, length)
+ return slowToString.apply(this, arguments)
+}
+
+Buffer.prototype.equals = function equals (b) {
+ if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')
+ if (this === b) return true
+ return Buffer.compare(this, b) === 0
+}
+
+Buffer.prototype.inspect = function inspect () {
+ var str = ''
+ var max = exports.INSPECT_MAX_BYTES
+ if (this.length > 0) {
+ str = this.toString('hex', 0, max).match(/.{2}/g).join(' ')
+ if (this.length > max) str += ' ... '
+ }
+ return ''
+}
+
+Buffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) {
+ if (!Buffer.isBuffer(target)) {
+ throw new TypeError('Argument must be a Buffer')
+ }
+
+ if (start === undefined) {
+ start = 0
+ }
+ if (end === undefined) {
+ end = target ? target.length : 0
+ }
+ if (thisStart === undefined) {
+ thisStart = 0
+ }
+ if (thisEnd === undefined) {
+ thisEnd = this.length
+ }
+
+ if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) {
+ throw new RangeError('out of range index')
+ }
+
+ if (thisStart >= thisEnd && start >= end) {
+ return 0
+ }
+ if (thisStart >= thisEnd) {
+ return -1
+ }
+ if (start >= end) {
+ return 1
+ }
+
+ start >>>= 0
+ end >>>= 0
+ thisStart >>>= 0
+ thisEnd >>>= 0
+
+ if (this === target) return 0
+
+ var x = thisEnd - thisStart
+ var y = end - start
+ var len = Math.min(x, y)
+
+ var thisCopy = this.slice(thisStart, thisEnd)
+ var targetCopy = target.slice(start, end)
+
+ for (var i = 0; i < len; ++i) {
+ if (thisCopy[i] !== targetCopy[i]) {
+ x = thisCopy[i]
+ y = targetCopy[i]
+ break
+ }
+ }
+
+ if (x < y) return -1
+ if (y < x) return 1
+ return 0
+}
+
+// Finds either the first index of `val` in `buffer` at offset >= `byteOffset`,
+// OR the last index of `val` in `buffer` at offset <= `byteOffset`.
+//
+// Arguments:
+// - buffer - a Buffer to search
+// - val - a string, Buffer, or number
+// - byteOffset - an index into `buffer`; will be clamped to an int32
+// - encoding - an optional encoding, relevant is val is a string
+// - dir - true for indexOf, false for lastIndexOf
+function bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) {
+ // Empty buffer means no match
+ if (buffer.length === 0) return -1
+
+ // Normalize byteOffset
+ if (typeof byteOffset === 'string') {
+ encoding = byteOffset
+ byteOffset = 0
+ } else if (byteOffset > 0x7fffffff) {
+ byteOffset = 0x7fffffff
+ } else if (byteOffset < -0x80000000) {
+ byteOffset = -0x80000000
+ }
+ byteOffset = +byteOffset // Coerce to Number.
+ if (isNaN(byteOffset)) {
+ // byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer
+ byteOffset = dir ? 0 : (buffer.length - 1)
+ }
+
+ // Normalize byteOffset: negative offsets start from the end of the buffer
+ if (byteOffset < 0) byteOffset = buffer.length + byteOffset
+ if (byteOffset >= buffer.length) {
+ if (dir) return -1
+ else byteOffset = buffer.length - 1
+ } else if (byteOffset < 0) {
+ if (dir) byteOffset = 0
+ else return -1
+ }
+
+ // Normalize val
+ if (typeof val === 'string') {
+ val = Buffer.from(val, encoding)
+ }
+
+ // Finally, search either indexOf (if dir is true) or lastIndexOf
+ if (Buffer.isBuffer(val)) {
+ // Special case: looking for empty string/buffer always fails
+ if (val.length === 0) {
+ return -1
+ }
+ return arrayIndexOf(buffer, val, byteOffset, encoding, dir)
+ } else if (typeof val === 'number') {
+ val = val & 0xFF // Search for a byte value [0-255]
+ if (Buffer.TYPED_ARRAY_SUPPORT &&
+ typeof Uint8Array.prototype.indexOf === 'function') {
+ if (dir) {
+ return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset)
+ } else {
+ return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset)
+ }
+ }
+ return arrayIndexOf(buffer, [ val ], byteOffset, encoding, dir)
+ }
+
+ throw new TypeError('val must be string, number or Buffer')
+}
+
+function arrayIndexOf (arr, val, byteOffset, encoding, dir) {
+ var indexSize = 1
+ var arrLength = arr.length
+ var valLength = val.length
+
+ if (encoding !== undefined) {
+ encoding = String(encoding).toLowerCase()
+ if (encoding === 'ucs2' || encoding === 'ucs-2' ||
+ encoding === 'utf16le' || encoding === 'utf-16le') {
+ if (arr.length < 2 || val.length < 2) {
+ return -1
+ }
+ indexSize = 2
+ arrLength /= 2
+ valLength /= 2
+ byteOffset /= 2
+ }
+ }
+
+ function read (buf, i) {
+ if (indexSize === 1) {
+ return buf[i]
+ } else {
+ return buf.readUInt16BE(i * indexSize)
+ }
+ }
+
+ var i
+ if (dir) {
+ var foundIndex = -1
+ for (i = byteOffset; i < arrLength; i++) {
+ if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {
+ if (foundIndex === -1) foundIndex = i
+ if (i - foundIndex + 1 === valLength) return foundIndex * indexSize
+ } else {
+ if (foundIndex !== -1) i -= i - foundIndex
+ foundIndex = -1
+ }
+ }
+ } else {
+ if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength
+ for (i = byteOffset; i >= 0; i--) {
+ var found = true
+ for (var j = 0; j < valLength; j++) {
+ if (read(arr, i + j) !== read(val, j)) {
+ found = false
+ break
+ }
+ }
+ if (found) return i
+ }
+ }
+
+ return -1
+}
+
+Buffer.prototype.includes = function includes (val, byteOffset, encoding) {
+ return this.indexOf(val, byteOffset, encoding) !== -1
+}
+
+Buffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) {
+ return bidirectionalIndexOf(this, val, byteOffset, encoding, true)
+}
+
+Buffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) {
+ return bidirectionalIndexOf(this, val, byteOffset, encoding, false)
+}
+
+function hexWrite (buf, string, offset, length) {
+ offset = Number(offset) || 0
+ var remaining = buf.length - offset
+ if (!length) {
+ length = remaining
+ } else {
+ length = Number(length)
+ if (length > remaining) {
+ length = remaining
+ }
+ }
+
+ // must be an even number of digits
+ var strLen = string.length
+ if (strLen % 2 !== 0) throw new TypeError('Invalid hex string')
+
+ if (length > strLen / 2) {
+ length = strLen / 2
+ }
+ for (var i = 0; i < length; ++i) {
+ var parsed = parseInt(string.substr(i * 2, 2), 16)
+ if (isNaN(parsed)) return i
+ buf[offset + i] = parsed
+ }
+ return i
+}
+
+function utf8Write (buf, string, offset, length) {
+ return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length)
+}
+
+function asciiWrite (buf, string, offset, length) {
+ return blitBuffer(asciiToBytes(string), buf, offset, length)
+}
+
+function latin1Write (buf, string, offset, length) {
+ return asciiWrite(buf, string, offset, length)
+}
+
+function base64Write (buf, string, offset, length) {
+ return blitBuffer(base64ToBytes(string), buf, offset, length)
+}
+
+function ucs2Write (buf, string, offset, length) {
+ return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length)
+}
+
+Buffer.prototype.write = function write (string, offset, length, encoding) {
+ // Buffer#write(string)
+ if (offset === undefined) {
+ encoding = 'utf8'
+ length = this.length
+ offset = 0
+ // Buffer#write(string, encoding)
+ } else if (length === undefined && typeof offset === 'string') {
+ encoding = offset
+ length = this.length
+ offset = 0
+ // Buffer#write(string, offset[, length][, encoding])
+ } else if (isFinite(offset)) {
+ offset = offset | 0
+ if (isFinite(length)) {
+ length = length | 0
+ if (encoding === undefined) encoding = 'utf8'
+ } else {
+ encoding = length
+ length = undefined
+ }
+ // legacy write(string, encoding, offset, length) - remove in v0.13
+ } else {
+ throw new Error(
+ 'Buffer.write(string, encoding, offset[, length]) is no longer supported'
+ )
+ }
+
+ var remaining = this.length - offset
+ if (length === undefined || length > remaining) length = remaining
+
+ if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) {
+ throw new RangeError('Attempt to write outside buffer bounds')
+ }
+
+ if (!encoding) encoding = 'utf8'
+
+ var loweredCase = false
+ for (;;) {
+ switch (encoding) {
+ case 'hex':
+ return hexWrite(this, string, offset, length)
+
+ case 'utf8':
+ case 'utf-8':
+ return utf8Write(this, string, offset, length)
+
+ case 'ascii':
+ return asciiWrite(this, string, offset, length)
+
+ case 'latin1':
+ case 'binary':
+ return latin1Write(this, string, offset, length)
+
+ case 'base64':
+ // Warning: maxLength not taken into account in base64Write
+ return base64Write(this, string, offset, length)
+
+ case 'ucs2':
+ case 'ucs-2':
+ case 'utf16le':
+ case 'utf-16le':
+ return ucs2Write(this, string, offset, length)
+
+ default:
+ if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
+ encoding = ('' + encoding).toLowerCase()
+ loweredCase = true
+ }
+ }
+}
+
+Buffer.prototype.toJSON = function toJSON () {
+ return {
+ type: 'Buffer',
+ data: Array.prototype.slice.call(this._arr || this, 0)
+ }
+}
+
+function base64Slice (buf, start, end) {
+ if (start === 0 && end === buf.length) {
+ return base64.fromByteArray(buf)
+ } else {
+ return base64.fromByteArray(buf.slice(start, end))
+ }
+}
+
+function utf8Slice (buf, start, end) {
+ end = Math.min(buf.length, end)
+ var res = []
+
+ var i = start
+ while (i < end) {
+ var firstByte = buf[i]
+ var codePoint = null
+ var bytesPerSequence = (firstByte > 0xEF) ? 4
+ : (firstByte > 0xDF) ? 3
+ : (firstByte > 0xBF) ? 2
+ : 1
+
+ if (i + bytesPerSequence <= end) {
+ var secondByte, thirdByte, fourthByte, tempCodePoint
+
+ switch (bytesPerSequence) {
+ case 1:
+ if (firstByte < 0x80) {
+ codePoint = firstByte
+ }
+ break
+ case 2:
+ secondByte = buf[i + 1]
+ if ((secondByte & 0xC0) === 0x80) {
+ tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F)
+ if (tempCodePoint > 0x7F) {
+ codePoint = tempCodePoint
+ }
+ }
+ break
+ case 3:
+ secondByte = buf[i + 1]
+ thirdByte = buf[i + 2]
+ if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) {
+ tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F)
+ if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) {
+ codePoint = tempCodePoint
+ }
+ }
+ break
+ case 4:
+ secondByte = buf[i + 1]
+ thirdByte = buf[i + 2]
+ fourthByte = buf[i + 3]
+ if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) {
+ tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F)
+ if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) {
+ codePoint = tempCodePoint
+ }
+ }
+ }
+ }
+
+ if (codePoint === null) {
+ // we did not generate a valid codePoint so insert a
+ // replacement char (U+FFFD) and advance only 1 byte
+ codePoint = 0xFFFD
+ bytesPerSequence = 1
+ } else if (codePoint > 0xFFFF) {
+ // encode to utf16 (surrogate pair dance)
+ codePoint -= 0x10000
+ res.push(codePoint >>> 10 & 0x3FF | 0xD800)
+ codePoint = 0xDC00 | codePoint & 0x3FF
+ }
+
+ res.push(codePoint)
+ i += bytesPerSequence
+ }
+
+ return decodeCodePointsArray(res)
+}
+
+// Based on http://stackoverflow.com/a/22747272/680742, the browser with
+// the lowest limit is Chrome, with 0x10000 args.
+// We go 1 magnitude less, for safety
+var MAX_ARGUMENTS_LENGTH = 0x1000
+
+function decodeCodePointsArray (codePoints) {
+ var len = codePoints.length
+ if (len <= MAX_ARGUMENTS_LENGTH) {
+ return String.fromCharCode.apply(String, codePoints) // avoid extra slice()
+ }
+
+ // Decode in chunks to avoid "call stack size exceeded".
+ var res = ''
+ var i = 0
+ while (i < len) {
+ res += String.fromCharCode.apply(
+ String,
+ codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)
+ )
+ }
+ return res
+}
+
+function asciiSlice (buf, start, end) {
+ var ret = ''
+ end = Math.min(buf.length, end)
+
+ for (var i = start; i < end; ++i) {
+ ret += String.fromCharCode(buf[i] & 0x7F)
+ }
+ return ret
+}
+
+function latin1Slice (buf, start, end) {
+ var ret = ''
+ end = Math.min(buf.length, end)
+
+ for (var i = start; i < end; ++i) {
+ ret += String.fromCharCode(buf[i])
+ }
+ return ret
+}
+
+function hexSlice (buf, start, end) {
+ var len = buf.length
+
+ if (!start || start < 0) start = 0
+ if (!end || end < 0 || end > len) end = len
+
+ var out = ''
+ for (var i = start; i < end; ++i) {
+ out += toHex(buf[i])
+ }
+ return out
+}
+
+function utf16leSlice (buf, start, end) {
+ var bytes = buf.slice(start, end)
+ var res = ''
+ for (var i = 0; i < bytes.length; i += 2) {
+ res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256)
+ }
+ return res
+}
+
+Buffer.prototype.slice = function slice (start, end) {
+ var len = this.length
+ start = ~~start
+ end = end === undefined ? len : ~~end
+
+ if (start < 0) {
+ start += len
+ if (start < 0) start = 0
+ } else if (start > len) {
+ start = len
+ }
+
+ if (end < 0) {
+ end += len
+ if (end < 0) end = 0
+ } else if (end > len) {
+ end = len
+ }
+
+ if (end < start) end = start
+
+ var newBuf
+ if (Buffer.TYPED_ARRAY_SUPPORT) {
+ newBuf = this.subarray(start, end)
+ newBuf.__proto__ = Buffer.prototype
+ } else {
+ var sliceLen = end - start
+ newBuf = new Buffer(sliceLen, undefined)
+ for (var i = 0; i < sliceLen; ++i) {
+ newBuf[i] = this[i + start]
+ }
+ }
+
+ return newBuf
+}
+
+/*
+ * Need to make sure that buffer isn't trying to write out of bounds.
+ */
+function checkOffset (offset, ext, length) {
+ if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint')
+ if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length')
+}
+
+Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) {
+ offset = offset | 0
+ byteLength = byteLength | 0
+ if (!noAssert) checkOffset(offset, byteLength, this.length)
+
+ var val = this[offset]
+ var mul = 1
+ var i = 0
+ while (++i < byteLength && (mul *= 0x100)) {
+ val += this[offset + i] * mul
+ }
+
+ return val
+}
+
+Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) {
+ offset = offset | 0
+ byteLength = byteLength | 0
+ if (!noAssert) {
+ checkOffset(offset, byteLength, this.length)
+ }
+
+ var val = this[offset + --byteLength]
+ var mul = 1
+ while (byteLength > 0 && (mul *= 0x100)) {
+ val += this[offset + --byteLength] * mul
+ }
+
+ return val
+}
+
+Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) {
+ if (!noAssert) checkOffset(offset, 1, this.length)
+ return this[offset]
+}
+
+Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) {
+ if (!noAssert) checkOffset(offset, 2, this.length)
+ return this[offset] | (this[offset + 1] << 8)
+}
+
+Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) {
+ if (!noAssert) checkOffset(offset, 2, this.length)
+ return (this[offset] << 8) | this[offset + 1]
+}
+
+Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) {
+ if (!noAssert) checkOffset(offset, 4, this.length)
+
+ return ((this[offset]) |
+ (this[offset + 1] << 8) |
+ (this[offset + 2] << 16)) +
+ (this[offset + 3] * 0x1000000)
+}
+
+Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) {
+ if (!noAssert) checkOffset(offset, 4, this.length)
+
+ return (this[offset] * 0x1000000) +
+ ((this[offset + 1] << 16) |
+ (this[offset + 2] << 8) |
+ this[offset + 3])
+}
+
+Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) {
+ offset = offset | 0
+ byteLength = byteLength | 0
+ if (!noAssert) checkOffset(offset, byteLength, this.length)
+
+ var val = this[offset]
+ var mul = 1
+ var i = 0
+ while (++i < byteLength && (mul *= 0x100)) {
+ val += this[offset + i] * mul
+ }
+ mul *= 0x80
+
+ if (val >= mul) val -= Math.pow(2, 8 * byteLength)
+
+ return val
+}
+
+Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) {
+ offset = offset | 0
+ byteLength = byteLength | 0
+ if (!noAssert) checkOffset(offset, byteLength, this.length)
+
+ var i = byteLength
+ var mul = 1
+ var val = this[offset + --i]
+ while (i > 0 && (mul *= 0x100)) {
+ val += this[offset + --i] * mul
+ }
+ mul *= 0x80
+
+ if (val >= mul) val -= Math.pow(2, 8 * byteLength)
+
+ return val
+}
+
+Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) {
+ if (!noAssert) checkOffset(offset, 1, this.length)
+ if (!(this[offset] & 0x80)) return (this[offset])
+ return ((0xff - this[offset] + 1) * -1)
+}
+
+Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) {
+ if (!noAssert) checkOffset(offset, 2, this.length)
+ var val = this[offset] | (this[offset + 1] << 8)
+ return (val & 0x8000) ? val | 0xFFFF0000 : val
+}
+
+Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) {
+ if (!noAssert) checkOffset(offset, 2, this.length)
+ var val = this[offset + 1] | (this[offset] << 8)
+ return (val & 0x8000) ? val | 0xFFFF0000 : val
+}
+
+Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) {
+ if (!noAssert) checkOffset(offset, 4, this.length)
+
+ return (this[offset]) |
+ (this[offset + 1] << 8) |
+ (this[offset + 2] << 16) |
+ (this[offset + 3] << 24)
+}
+
+Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) {
+ if (!noAssert) checkOffset(offset, 4, this.length)
+
+ return (this[offset] << 24) |
+ (this[offset + 1] << 16) |
+ (this[offset + 2] << 8) |
+ (this[offset + 3])
+}
+
+Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) {
+ if (!noAssert) checkOffset(offset, 4, this.length)
+ return ieee754.read(this, offset, true, 23, 4)
+}
+
+Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) {
+ if (!noAssert) checkOffset(offset, 4, this.length)
+ return ieee754.read(this, offset, false, 23, 4)
+}
+
+Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) {
+ if (!noAssert) checkOffset(offset, 8, this.length)
+ return ieee754.read(this, offset, true, 52, 8)
+}
+
+Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) {
+ if (!noAssert) checkOffset(offset, 8, this.length)
+ return ieee754.read(this, offset, false, 52, 8)
+}
+
+function checkInt (buf, value, offset, ext, max, min) {
+ if (!Buffer.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance')
+ if (value > max || value < min) throw new RangeError('"value" argument is out of bounds')
+ if (offset + ext > buf.length) throw new RangeError('Index out of range')
+}
+
+Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) {
+ value = +value
+ offset = offset | 0
+ byteLength = byteLength | 0
+ if (!noAssert) {
+ var maxBytes = Math.pow(2, 8 * byteLength) - 1
+ checkInt(this, value, offset, byteLength, maxBytes, 0)
+ }
+
+ var mul = 1
+ var i = 0
+ this[offset] = value & 0xFF
+ while (++i < byteLength && (mul *= 0x100)) {
+ this[offset + i] = (value / mul) & 0xFF
+ }
+
+ return offset + byteLength
+}
+
+Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) {
+ value = +value
+ offset = offset | 0
+ byteLength = byteLength | 0
+ if (!noAssert) {
+ var maxBytes = Math.pow(2, 8 * byteLength) - 1
+ checkInt(this, value, offset, byteLength, maxBytes, 0)
+ }
+
+ var i = byteLength - 1
+ var mul = 1
+ this[offset + i] = value & 0xFF
+ while (--i >= 0 && (mul *= 0x100)) {
+ this[offset + i] = (value / mul) & 0xFF
+ }
+
+ return offset + byteLength
+}
+
+Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) {
+ value = +value
+ offset = offset | 0
+ if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0)
+ if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)
+ this[offset] = (value & 0xff)
+ return offset + 1
+}
+
+function objectWriteUInt16 (buf, value, offset, littleEndian) {
+ if (value < 0) value = 0xffff + value + 1
+ for (var i = 0, j = Math.min(buf.length - offset, 2); i < j; ++i) {
+ buf[offset + i] = (value & (0xff << (8 * (littleEndian ? i : 1 - i)))) >>>
+ (littleEndian ? i : 1 - i) * 8
+ }
+}
+
+Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) {
+ value = +value
+ offset = offset | 0
+ if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
+ if (Buffer.TYPED_ARRAY_SUPPORT) {
+ this[offset] = (value & 0xff)
+ this[offset + 1] = (value >>> 8)
+ } else {
+ objectWriteUInt16(this, value, offset, true)
+ }
+ return offset + 2
+}
+
+Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) {
+ value = +value
+ offset = offset | 0
+ if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
+ if (Buffer.TYPED_ARRAY_SUPPORT) {
+ this[offset] = (value >>> 8)
+ this[offset + 1] = (value & 0xff)
+ } else {
+ objectWriteUInt16(this, value, offset, false)
+ }
+ return offset + 2
+}
+
+function objectWriteUInt32 (buf, value, offset, littleEndian) {
+ if (value < 0) value = 0xffffffff + value + 1
+ for (var i = 0, j = Math.min(buf.length - offset, 4); i < j; ++i) {
+ buf[offset + i] = (value >>> (littleEndian ? i : 3 - i) * 8) & 0xff
+ }
+}
+
+Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) {
+ value = +value
+ offset = offset | 0
+ if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
+ if (Buffer.TYPED_ARRAY_SUPPORT) {
+ this[offset + 3] = (value >>> 24)
+ this[offset + 2] = (value >>> 16)
+ this[offset + 1] = (value >>> 8)
+ this[offset] = (value & 0xff)
+ } else {
+ objectWriteUInt32(this, value, offset, true)
+ }
+ return offset + 4
+}
+
+Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) {
+ value = +value
+ offset = offset | 0
+ if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
+ if (Buffer.TYPED_ARRAY_SUPPORT) {
+ this[offset] = (value >>> 24)
+ this[offset + 1] = (value >>> 16)
+ this[offset + 2] = (value >>> 8)
+ this[offset + 3] = (value & 0xff)
+ } else {
+ objectWriteUInt32(this, value, offset, false)
+ }
+ return offset + 4
+}
+
+Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) {
+ value = +value
+ offset = offset | 0
+ if (!noAssert) {
+ var limit = Math.pow(2, 8 * byteLength - 1)
+
+ checkInt(this, value, offset, byteLength, limit - 1, -limit)
+ }
+
+ var i = 0
+ var mul = 1
+ var sub = 0
+ this[offset] = value & 0xFF
+ while (++i < byteLength && (mul *= 0x100)) {
+ if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {
+ sub = 1
+ }
+ this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
+ }
+
+ return offset + byteLength
+}
+
+Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) {
+ value = +value
+ offset = offset | 0
+ if (!noAssert) {
+ var limit = Math.pow(2, 8 * byteLength - 1)
+
+ checkInt(this, value, offset, byteLength, limit - 1, -limit)
+ }
+
+ var i = byteLength - 1
+ var mul = 1
+ var sub = 0
+ this[offset + i] = value & 0xFF
+ while (--i >= 0 && (mul *= 0x100)) {
+ if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {
+ sub = 1
+ }
+ this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
+ }
+
+ return offset + byteLength
+}
+
+Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) {
+ value = +value
+ offset = offset | 0
+ if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80)
+ if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)
+ if (value < 0) value = 0xff + value + 1
+ this[offset] = (value & 0xff)
+ return offset + 1
+}
+
+Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) {
+ value = +value
+ offset = offset | 0
+ if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
+ if (Buffer.TYPED_ARRAY_SUPPORT) {
+ this[offset] = (value & 0xff)
+ this[offset + 1] = (value >>> 8)
+ } else {
+ objectWriteUInt16(this, value, offset, true)
+ }
+ return offset + 2
+}
+
+Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) {
+ value = +value
+ offset = offset | 0
+ if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
+ if (Buffer.TYPED_ARRAY_SUPPORT) {
+ this[offset] = (value >>> 8)
+ this[offset + 1] = (value & 0xff)
+ } else {
+ objectWriteUInt16(this, value, offset, false)
+ }
+ return offset + 2
+}
+
+Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) {
+ value = +value
+ offset = offset | 0
+ if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
+ if (Buffer.TYPED_ARRAY_SUPPORT) {
+ this[offset] = (value & 0xff)
+ this[offset + 1] = (value >>> 8)
+ this[offset + 2] = (value >>> 16)
+ this[offset + 3] = (value >>> 24)
+ } else {
+ objectWriteUInt32(this, value, offset, true)
+ }
+ return offset + 4
+}
+
+Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) {
+ value = +value
+ offset = offset | 0
+ if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
+ if (value < 0) value = 0xffffffff + value + 1
+ if (Buffer.TYPED_ARRAY_SUPPORT) {
+ this[offset] = (value >>> 24)
+ this[offset + 1] = (value >>> 16)
+ this[offset + 2] = (value >>> 8)
+ this[offset + 3] = (value & 0xff)
+ } else {
+ objectWriteUInt32(this, value, offset, false)
+ }
+ return offset + 4
+}
+
+function checkIEEE754 (buf, value, offset, ext, max, min) {
+ if (offset + ext > buf.length) throw new RangeError('Index out of range')
+ if (offset < 0) throw new RangeError('Index out of range')
+}
+
+function writeFloat (buf, value, offset, littleEndian, noAssert) {
+ if (!noAssert) {
+ checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38)
+ }
+ ieee754.write(buf, value, offset, littleEndian, 23, 4)
+ return offset + 4
+}
+
+Buffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) {
+ return writeFloat(this, value, offset, true, noAssert)
+}
+
+Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) {
+ return writeFloat(this, value, offset, false, noAssert)
+}
+
+function writeDouble (buf, value, offset, littleEndian, noAssert) {
+ if (!noAssert) {
+ checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308)
+ }
+ ieee754.write(buf, value, offset, littleEndian, 52, 8)
+ return offset + 8
+}
+
+Buffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) {
+ return writeDouble(this, value, offset, true, noAssert)
+}
+
+Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) {
+ return writeDouble(this, value, offset, false, noAssert)
+}
+
+// copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)
+Buffer.prototype.copy = function copy (target, targetStart, start, end) {
+ if (!start) start = 0
+ if (!end && end !== 0) end = this.length
+ if (targetStart >= target.length) targetStart = target.length
+ if (!targetStart) targetStart = 0
+ if (end > 0 && end < start) end = start
+
+ // Copy 0 bytes; we're done
+ if (end === start) return 0
+ if (target.length === 0 || this.length === 0) return 0
+
+ // Fatal error conditions
+ if (targetStart < 0) {
+ throw new RangeError('targetStart out of bounds')
+ }
+ if (start < 0 || start >= this.length) throw new RangeError('sourceStart out of bounds')
+ if (end < 0) throw new RangeError('sourceEnd out of bounds')
+
+ // Are we oob?
+ if (end > this.length) end = this.length
+ if (target.length - targetStart < end - start) {
+ end = target.length - targetStart + start
+ }
+
+ var len = end - start
+ var i
+
+ if (this === target && start < targetStart && targetStart < end) {
+ // descending copy from end
+ for (i = len - 1; i >= 0; --i) {
+ target[i + targetStart] = this[i + start]
+ }
+ } else if (len < 1000 || !Buffer.TYPED_ARRAY_SUPPORT) {
+ // ascending copy from start
+ for (i = 0; i < len; ++i) {
+ target[i + targetStart] = this[i + start]
+ }
+ } else {
+ Uint8Array.prototype.set.call(
+ target,
+ this.subarray(start, start + len),
+ targetStart
+ )
+ }
+
+ return len
+}
+
+// Usage:
+// buffer.fill(number[, offset[, end]])
+// buffer.fill(buffer[, offset[, end]])
+// buffer.fill(string[, offset[, end]][, encoding])
+Buffer.prototype.fill = function fill (val, start, end, encoding) {
+ // Handle string cases:
+ if (typeof val === 'string') {
+ if (typeof start === 'string') {
+ encoding = start
+ start = 0
+ end = this.length
+ } else if (typeof end === 'string') {
+ encoding = end
+ end = this.length
+ }
+ if (val.length === 1) {
+ var code = val.charCodeAt(0)
+ if (code < 256) {
+ val = code
+ }
+ }
+ if (encoding !== undefined && typeof encoding !== 'string') {
+ throw new TypeError('encoding must be a string')
+ }
+ if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) {
+ throw new TypeError('Unknown encoding: ' + encoding)
+ }
+ } else if (typeof val === 'number') {
+ val = val & 255
+ }
+
+ // Invalid ranges are not set to a default, so can range check early.
+ if (start < 0 || this.length < start || this.length < end) {
+ throw new RangeError('Out of range index')
+ }
+
+ if (end <= start) {
+ return this
+ }
+
+ start = start >>> 0
+ end = end === undefined ? this.length : end >>> 0
+
+ if (!val) val = 0
+
+ var i
+ if (typeof val === 'number') {
+ for (i = start; i < end; ++i) {
+ this[i] = val
+ }
+ } else {
+ var bytes = Buffer.isBuffer(val)
+ ? val
+ : utf8ToBytes(new Buffer(val, encoding).toString())
+ var len = bytes.length
+ for (i = 0; i < end - start; ++i) {
+ this[i + start] = bytes[i % len]
+ }
+ }
+
+ return this
+}
+
+// HELPER FUNCTIONS
+// ================
+
+var INVALID_BASE64_RE = /[^+\/0-9A-Za-z-_]/g
+
+function base64clean (str) {
+ // Node strips out invalid characters like \n and \t from the string, base64-js does not
+ str = stringtrim(str).replace(INVALID_BASE64_RE, '')
+ // Node converts strings with length < 2 to ''
+ if (str.length < 2) return ''
+ // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not
+ while (str.length % 4 !== 0) {
+ str = str + '='
+ }
+ return str
+}
+
+function stringtrim (str) {
+ if (str.trim) return str.trim()
+ return str.replace(/^\s+|\s+$/g, '')
+}
+
+function toHex (n) {
+ if (n < 16) return '0' + n.toString(16)
+ return n.toString(16)
+}
+
+function utf8ToBytes (string, units) {
+ units = units || Infinity
+ var codePoint
+ var length = string.length
+ var leadSurrogate = null
+ var bytes = []
+
+ for (var i = 0; i < length; ++i) {
+ codePoint = string.charCodeAt(i)
+
+ // is surrogate component
+ if (codePoint > 0xD7FF && codePoint < 0xE000) {
+ // last char was a lead
+ if (!leadSurrogate) {
+ // no lead yet
+ if (codePoint > 0xDBFF) {
+ // unexpected trail
+ if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
+ continue
+ } else if (i + 1 === length) {
+ // unpaired lead
+ if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
+ continue
+ }
+
+ // valid lead
+ leadSurrogate = codePoint
+
+ continue
+ }
+
+ // 2 leads in a row
+ if (codePoint < 0xDC00) {
+ if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
+ leadSurrogate = codePoint
+ continue
+ }
+
+ // valid surrogate pair
+ codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000
+ } else if (leadSurrogate) {
+ // valid bmp char, but last char was a lead
+ if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
+ }
+
+ leadSurrogate = null
+
+ // encode utf8
+ if (codePoint < 0x80) {
+ if ((units -= 1) < 0) break
+ bytes.push(codePoint)
+ } else if (codePoint < 0x800) {
+ if ((units -= 2) < 0) break
+ bytes.push(
+ codePoint >> 0x6 | 0xC0,
+ codePoint & 0x3F | 0x80
+ )
+ } else if (codePoint < 0x10000) {
+ if ((units -= 3) < 0) break
+ bytes.push(
+ codePoint >> 0xC | 0xE0,
+ codePoint >> 0x6 & 0x3F | 0x80,
+ codePoint & 0x3F | 0x80
+ )
+ } else if (codePoint < 0x110000) {
+ if ((units -= 4) < 0) break
+ bytes.push(
+ codePoint >> 0x12 | 0xF0,
+ codePoint >> 0xC & 0x3F | 0x80,
+ codePoint >> 0x6 & 0x3F | 0x80,
+ codePoint & 0x3F | 0x80
+ )
+ } else {
+ throw new Error('Invalid code point')
+ }
+ }
+
+ return bytes
+}
+
+function asciiToBytes (str) {
+ var byteArray = []
+ for (var i = 0; i < str.length; ++i) {
+ // Node's code seems to be doing this and not & 0x7F..
+ byteArray.push(str.charCodeAt(i) & 0xFF)
+ }
+ return byteArray
+}
+
+function utf16leToBytes (str, units) {
+ var c, hi, lo
+ var byteArray = []
+ for (var i = 0; i < str.length; ++i) {
+ if ((units -= 2) < 0) break
+
+ c = str.charCodeAt(i)
+ hi = c >> 8
+ lo = c % 256
+ byteArray.push(lo)
+ byteArray.push(hi)
+ }
+
+ return byteArray
+}
+
+function base64ToBytes (str) {
+ return base64.toByteArray(base64clean(str))
+}
+
+function blitBuffer (src, dst, offset, length) {
+ for (var i = 0; i < length; ++i) {
+ if ((i + offset >= dst.length) || (i >= src.length)) break
+ dst[i + offset] = src[i]
+ }
+ return i
+}
+
+function isnan (val) {
+ return val !== val // eslint-disable-line no-self-compare
+}
+
+}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
+
+},{"base64-js":17,"ieee754":57,"isarray":60}],21:[function(require,module,exports){
+module.exports = {
+ "100": "Continue",
+ "101": "Switching Protocols",
+ "102": "Processing",
+ "200": "OK",
+ "201": "Created",
+ "202": "Accepted",
+ "203": "Non-Authoritative Information",
+ "204": "No Content",
+ "205": "Reset Content",
+ "206": "Partial Content",
+ "207": "Multi-Status",
+ "208": "Already Reported",
+ "226": "IM Used",
+ "300": "Multiple Choices",
+ "301": "Moved Permanently",
+ "302": "Found",
+ "303": "See Other",
+ "304": "Not Modified",
+ "305": "Use Proxy",
+ "307": "Temporary Redirect",
+ "308": "Permanent Redirect",
+ "400": "Bad Request",
+ "401": "Unauthorized",
+ "402": "Payment Required",
+ "403": "Forbidden",
+ "404": "Not Found",
+ "405": "Method Not Allowed",
+ "406": "Not Acceptable",
+ "407": "Proxy Authentication Required",
+ "408": "Request Timeout",
+ "409": "Conflict",
+ "410": "Gone",
+ "411": "Length Required",
+ "412": "Precondition Failed",
+ "413": "Payload Too Large",
+ "414": "URI Too Long",
+ "415": "Unsupported Media Type",
+ "416": "Range Not Satisfiable",
+ "417": "Expectation Failed",
+ "418": "I'm a teapot",
+ "421": "Misdirected Request",
+ "422": "Unprocessable Entity",
+ "423": "Locked",
+ "424": "Failed Dependency",
+ "425": "Unordered Collection",
+ "426": "Upgrade Required",
+ "428": "Precondition Required",
+ "429": "Too Many Requests",
+ "431": "Request Header Fields Too Large",
+ "451": "Unavailable For Legal Reasons",
+ "500": "Internal Server Error",
+ "501": "Not Implemented",
+ "502": "Bad Gateway",
+ "503": "Service Unavailable",
+ "504": "Gateway Timeout",
+ "505": "HTTP Version Not Supported",
+ "506": "Variant Also Negotiates",
+ "507": "Insufficient Storage",
+ "508": "Loop Detected",
+ "509": "Bandwidth Limit Exceeded",
+ "510": "Not Extended",
+ "511": "Network Authentication Required"
+}
+
+},{}],22:[function(require,module,exports){
+(function (Buffer){
+// Copyright Joyent, Inc. and other Node contributors.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to permit
+// persons to whom the Software is furnished to do so, subject to the
+// following conditions:
+//
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
+// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+// USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+// NOTE: These type checking functions intentionally don't use `instanceof`
+// because it is fragile and can be easily faked with `Object.create()`.
+
+function isArray(arg) {
+ if (Array.isArray) {
+ return Array.isArray(arg);
+ }
+ return objectToString(arg) === '[object Array]';
+}
+exports.isArray = isArray;
+
+function isBoolean(arg) {
+ return typeof arg === 'boolean';
+}
+exports.isBoolean = isBoolean;
+
+function isNull(arg) {
+ return arg === null;
+}
+exports.isNull = isNull;
+
+function isNullOrUndefined(arg) {
+ return arg == null;
+}
+exports.isNullOrUndefined = isNullOrUndefined;
+
+function isNumber(arg) {
+ return typeof arg === 'number';
+}
+exports.isNumber = isNumber;
+
+function isString(arg) {
+ return typeof arg === 'string';
+}
+exports.isString = isString;
+
+function isSymbol(arg) {
+ return typeof arg === 'symbol';
+}
+exports.isSymbol = isSymbol;
+
+function isUndefined(arg) {
+ return arg === void 0;
+}
+exports.isUndefined = isUndefined;
+
+function isRegExp(re) {
+ return objectToString(re) === '[object RegExp]';
+}
+exports.isRegExp = isRegExp;
+
+function isObject(arg) {
+ return typeof arg === 'object' && arg !== null;
+}
+exports.isObject = isObject;
+
+function isDate(d) {
+ return objectToString(d) === '[object Date]';
+}
+exports.isDate = isDate;
+
+function isError(e) {
+ return (objectToString(e) === '[object Error]' || e instanceof Error);
+}
+exports.isError = isError;
+
+function isFunction(arg) {
+ return typeof arg === 'function';
+}
+exports.isFunction = isFunction;
+
+function isPrimitive(arg) {
+ return arg === null ||
+ typeof arg === 'boolean' ||
+ typeof arg === 'number' ||
+ typeof arg === 'string' ||
+ typeof arg === 'symbol' || // ES6 symbol
+ typeof arg === 'undefined';
+}
+exports.isPrimitive = isPrimitive;
+
+exports.isBuffer = Buffer.isBuffer;
+
+function objectToString(o) {
+ return Object.prototype.toString.call(o);
+}
+
+}).call(this,{"isBuffer":require("../../is-buffer/index.js")})
+
+},{"../../is-buffer/index.js":59}],23:[function(require,module,exports){
+// https://d3js.org/d3-array/ Version 1.2.1. Copyright 2017 Mike Bostock.
+(function (global, factory) {
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
+ typeof define === 'function' && define.amd ? define(['exports'], factory) :
+ (factory((global.d3 = global.d3 || {})));
+}(this, (function (exports) { 'use strict';
+
+var ascending = function(a, b) {
+ return a < b ? -1 : a > b ? 1 : a >= b ? 0 : NaN;
+};
+
+var bisector = function(compare) {
+ if (compare.length === 1) compare = ascendingComparator(compare);
+ return {
+ left: function(a, x, lo, hi) {
+ if (lo == null) lo = 0;
+ if (hi == null) hi = a.length;
+ while (lo < hi) {
+ var mid = lo + hi >>> 1;
+ if (compare(a[mid], x) < 0) lo = mid + 1;
+ else hi = mid;
+ }
+ return lo;
+ },
+ right: function(a, x, lo, hi) {
+ if (lo == null) lo = 0;
+ if (hi == null) hi = a.length;
+ while (lo < hi) {
+ var mid = lo + hi >>> 1;
+ if (compare(a[mid], x) > 0) hi = mid;
+ else lo = mid + 1;
+ }
+ return lo;
+ }
+ };
+};
+
+function ascendingComparator(f) {
+ return function(d, x) {
+ return ascending(f(d), x);
+ };
+}
+
+var ascendingBisect = bisector(ascending);
+var bisectRight = ascendingBisect.right;
+var bisectLeft = ascendingBisect.left;
+
+var pairs = function(array, f) {
+ if (f == null) f = pair;
+ var i = 0, n = array.length - 1, p = array[0], pairs = new Array(n < 0 ? 0 : n);
+ while (i < n) pairs[i] = f(p, p = array[++i]);
+ return pairs;
+};
+
+function pair(a, b) {
+ return [a, b];
+}
+
+var cross = function(values0, values1, reduce) {
+ var n0 = values0.length,
+ n1 = values1.length,
+ values = new Array(n0 * n1),
+ i0,
+ i1,
+ i,
+ value0;
+
+ if (reduce == null) reduce = pair;
+
+ for (i0 = i = 0; i0 < n0; ++i0) {
+ for (value0 = values0[i0], i1 = 0; i1 < n1; ++i1, ++i) {
+ values[i] = reduce(value0, values1[i1]);
+ }
+ }
+
+ return values;
+};
+
+var descending = function(a, b) {
+ return b < a ? -1 : b > a ? 1 : b >= a ? 0 : NaN;
+};
+
+var number = function(x) {
+ return x === null ? NaN : +x;
+};
+
+var variance = function(values, valueof) {
+ var n = values.length,
+ m = 0,
+ i = -1,
+ mean = 0,
+ value,
+ delta,
+ sum = 0;
+
+ if (valueof == null) {
+ while (++i < n) {
+ if (!isNaN(value = number(values[i]))) {
+ delta = value - mean;
+ mean += delta / ++m;
+ sum += delta * (value - mean);
+ }
+ }
+ }
+
+ else {
+ while (++i < n) {
+ if (!isNaN(value = number(valueof(values[i], i, values)))) {
+ delta = value - mean;
+ mean += delta / ++m;
+ sum += delta * (value - mean);
+ }
+ }
+ }
+
+ if (m > 1) return sum / (m - 1);
+};
+
+var deviation = function(array, f) {
+ var v = variance(array, f);
+ return v ? Math.sqrt(v) : v;
+};
+
+var extent = function(values, valueof) {
+ var n = values.length,
+ i = -1,
+ value,
+ min,
+ max;
+
+ if (valueof == null) {
+ while (++i < n) { // Find the first comparable value.
+ if ((value = values[i]) != null && value >= value) {
+ min = max = value;
+ while (++i < n) { // Compare the remaining values.
+ if ((value = values[i]) != null) {
+ if (min > value) min = value;
+ if (max < value) max = value;
+ }
+ }
+ }
+ }
+ }
+
+ else {
+ while (++i < n) { // Find the first comparable value.
+ if ((value = valueof(values[i], i, values)) != null && value >= value) {
+ min = max = value;
+ while (++i < n) { // Compare the remaining values.
+ if ((value = valueof(values[i], i, values)) != null) {
+ if (min > value) min = value;
+ if (max < value) max = value;
+ }
+ }
+ }
+ }
+ }
+
+ return [min, max];
+};
+
+var array = Array.prototype;
+
+var slice = array.slice;
+var map = array.map;
+
+var constant = function(x) {
+ return function() {
+ return x;
+ };
+};
+
+var identity = function(x) {
+ return x;
+};
+
+var range = function(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;
+};
+
+var e10 = Math.sqrt(50);
+var e5 = Math.sqrt(10);
+var e2 = Math.sqrt(2);
+
+var ticks = function(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) {
+ start = Math.ceil(start / step);
+ stop = Math.floor(stop / step);
+ ticks = new Array(n = Math.ceil(stop - start + 1));
+ while (++i < n) ticks[i] = (start + i) * step;
+ } else {
+ start = Math.floor(start * step);
+ stop = Math.ceil(stop * step);
+ ticks = new Array(n = Math.ceil(start - stop + 1));
+ while (++i < n) ticks[i] = (start - 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;
+}
+
+var sturges = function(values) {
+ return Math.ceil(Math.log(values.length) / Math.LN2) + 1;
+};
+
+var histogram = function() {
+ var value = identity,
+ domain = extent,
+ threshold = sturges;
+
+ function histogram(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.
+ if (!Array.isArray(tz)) {
+ tz = tickStep(x0, x1, tz);
+ tz = range(Math.ceil(x0 / tz) * tz, Math.floor(x1 / tz) * tz, tz); // exclusive
+ }
+
+ // 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 (x0 <= x && x <= x1) {
+ bins[bisectRight(tz, x, 0, m)].push(data[i]);
+ }
+ }
+
+ return bins;
+ }
+
+ histogram.value = function(_) {
+ return arguments.length ? (value = typeof _ === "function" ? _ : constant(_), histogram) : value;
+ };
+
+ histogram.domain = function(_) {
+ return arguments.length ? (domain = typeof _ === "function" ? _ : constant([_[0], _[1]]), histogram) : domain;
+ };
+
+ histogram.thresholds = function(_) {
+ return arguments.length ? (threshold = typeof _ === "function" ? _ : Array.isArray(_) ? constant(slice.call(_)) : constant(_), histogram) : threshold;
+ };
+
+ return histogram;
+};
+
+var quantile = function(values, p, valueof) {
+ if (valueof == null) valueof = number;
+ 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);
+};
+
+var freedmanDiaconis = function(values, min, max) {
+ values = map.call(values, number).sort(ascending);
+ return Math.ceil((max - min) / (2 * (quantile(values, 0.75) - quantile(values, 0.25)) * Math.pow(values.length, -1 / 3)));
+};
+
+var scott = function(values, min, max) {
+ return Math.ceil((max - min) / (3.5 * deviation(values) * Math.pow(values.length, -1 / 3)));
+};
+
+var max = function(values, valueof) {
+ var n = values.length,
+ i = -1,
+ value,
+ max;
+
+ if (valueof == null) {
+ while (++i < n) { // Find the first comparable value.
+ if ((value = values[i]) != null && value >= value) {
+ max = value;
+ while (++i < n) { // Compare the remaining values.
+ if ((value = values[i]) != null && value > max) {
+ max = value;
+ }
+ }
+ }
+ }
+ }
+
+ else {
+ while (++i < n) { // Find the first comparable value.
+ if ((value = valueof(values[i], i, values)) != null && value >= value) {
+ max = value;
+ while (++i < n) { // Compare the remaining values.
+ if ((value = valueof(values[i], i, values)) != null && value > max) {
+ max = value;
+ }
+ }
+ }
+ }
+ }
+
+ return max;
+};
+
+var mean = function(values, valueof) {
+ var n = values.length,
+ m = n,
+ i = -1,
+ value,
+ sum = 0;
+
+ if (valueof == null) {
+ while (++i < n) {
+ if (!isNaN(value = number(values[i]))) sum += value;
+ else --m;
+ }
+ }
+
+ else {
+ while (++i < n) {
+ if (!isNaN(value = number(valueof(values[i], i, values)))) sum += value;
+ else --m;
+ }
+ }
+
+ if (m) return sum / m;
+};
+
+var median = function(values, valueof) {
+ var n = values.length,
+ i = -1,
+ value,
+ numbers = [];
+
+ if (valueof == null) {
+ while (++i < n) {
+ if (!isNaN(value = number(values[i]))) {
+ numbers.push(value);
+ }
+ }
+ }
+
+ else {
+ while (++i < n) {
+ if (!isNaN(value = number(valueof(values[i], i, values)))) {
+ numbers.push(value);
+ }
+ }
+ }
+
+ return quantile(numbers.sort(ascending), 0.5);
+};
+
+var merge = function(arrays) {
+ var n = arrays.length,
+ m,
+ i = -1,
+ j = 0,
+ merged,
+ array;
+
+ while (++i < n) j += arrays[i].length;
+ merged = new Array(j);
+
+ while (--n >= 0) {
+ array = arrays[n];
+ m = array.length;
+ while (--m >= 0) {
+ merged[--j] = array[m];
+ }
+ }
+
+ return merged;
+};
+
+var min = function(values, valueof) {
+ var n = values.length,
+ i = -1,
+ value,
+ min;
+
+ if (valueof == null) {
+ while (++i < n) { // Find the first comparable value.
+ if ((value = values[i]) != null && value >= value) {
+ min = value;
+ while (++i < n) { // Compare the remaining values.
+ if ((value = values[i]) != null && min > value) {
+ min = value;
+ }
+ }
+ }
+ }
+ }
+
+ else {
+ while (++i < n) { // Find the first comparable value.
+ if ((value = valueof(values[i], i, values)) != null && value >= value) {
+ min = value;
+ while (++i < n) { // Compare the remaining values.
+ if ((value = valueof(values[i], i, values)) != null && min > value) {
+ min = value;
+ }
+ }
+ }
+ }
+ }
+
+ return min;
+};
+
+var permute = function(array, indexes) {
+ var i = indexes.length, permutes = new Array(i);
+ while (i--) permutes[i] = array[indexes[i]];
+ return permutes;
+};
+
+var scan = function(values, compare) {
+ if (!(n = values.length)) return;
+ var n,
+ i = 0,
+ j = 0,
+ xi,
+ xj = values[j];
+
+ if (compare == null) compare = ascending;
+
+ while (++i < n) {
+ if (compare(xi = values[i], xj) < 0 || compare(xj, xj) !== 0) {
+ xj = xi, j = i;
+ }
+ }
+
+ if (compare(xj, xj) === 0) return j;
+};
+
+var shuffle = function(array, i0, i1) {
+ var m = (i1 == null ? array.length : i1) - (i0 = i0 == null ? 0 : +i0),
+ t,
+ i;
+
+ while (m) {
+ i = Math.random() * m-- | 0;
+ t = array[m + i0];
+ array[m + i0] = array[i + i0];
+ array[i + i0] = t;
+ }
+
+ return array;
+};
+
+var sum = function(values, valueof) {
+ var n = values.length,
+ i = -1,
+ value,
+ sum = 0;
+
+ if (valueof == null) {
+ while (++i < n) {
+ if (value = +values[i]) sum += value; // Note: zero and null are equivalent.
+ }
+ }
+
+ else {
+ while (++i < n) {
+ if (value = +valueof(values[i], i, values)) sum += value;
+ }
+ }
+
+ return sum;
+};
+
+var transpose = function(matrix) {
+ if (!(n = matrix.length)) return [];
+ for (var i = -1, m = min(matrix, length), 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(d) {
+ return d.length;
+}
+
+var zip = function() {
+ return transpose(arguments);
+};
+
+exports.bisect = bisectRight;
+exports.bisectRight = bisectRight;
+exports.bisectLeft = bisectLeft;
+exports.ascending = ascending;
+exports.bisector = bisector;
+exports.cross = cross;
+exports.descending = descending;
+exports.deviation = deviation;
+exports.extent = extent;
+exports.histogram = histogram;
+exports.thresholdFreedmanDiaconis = freedmanDiaconis;
+exports.thresholdScott = scott;
+exports.thresholdSturges = sturges;
+exports.max = max;
+exports.mean = mean;
+exports.median = median;
+exports.merge = merge;
+exports.min = min;
+exports.pairs = pairs;
+exports.permute = permute;
+exports.quantile = quantile;
+exports.range = range;
+exports.scan = scan;
+exports.shuffle = shuffle;
+exports.sum = sum;
+exports.ticks = ticks;
+exports.tickIncrement = tickIncrement;
+exports.tickStep = tickStep;
+exports.transpose = transpose;
+exports.variance = variance;
+exports.zip = zip;
+
+Object.defineProperty(exports, '__esModule', { value: true });
+
+})));
+
+},{}],24:[function(require,module,exports){
+// https://d3js.org/d3-axis/ Version 1.0.8. Copyright 2017 Mike Bostock.
+(function (global, factory) {
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
+ typeof define === 'function' && define.amd ? define(['exports'], factory) :
+ (factory((global.d3 = global.d3 || {})));
+}(this, (function (exports) { 'use strict';
+
+var slice = Array.prototype.slice;
+
+var identity = function(x) {
+ return x;
+};
+
+var top = 1;
+var right = 2;
+var bottom = 3;
+var left = 4;
+var epsilon = 1e-6;
+
+function translateX(x) {
+ return "translate(" + (x + 0.5) + ",0)";
+}
+
+function translateY(y) {
+ return "translate(0," + (y + 0.5) + ")";
+}
+
+function number(scale) {
+ return function(d) {
+ return +scale(d);
+ };
+}
+
+function center(scale) {
+ var offset = Math.max(0, scale.bandwidth() - 1) / 2; // Adjust for 0.5px offset.
+ if (scale.round()) offset = Math.round(offset);
+ return function(d) {
+ return +scale(d) + offset;
+ };
+}
+
+function entering() {
+ return !this.__axis;
+}
+
+function axis(orient, scale) {
+ var tickArguments = [],
+ tickValues = null,
+ tickFormat = null,
+ tickSizeInner = 6,
+ tickSizeOuter = 6,
+ tickPadding = 3,
+ 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) : tickFormat,
+ spacing = Math.max(tickSizeInner, 0) + tickPadding,
+ range = scale.range(),
+ range0 = +range[0] + 0.5,
+ range1 = +range[range.length - 1] + 0.5,
+ position = (scale.bandwidth ? center : number)(scale.copy()),
+ 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", "#000"));
+
+ tick = tick.merge(tickEnter);
+
+ line = line.merge(tickEnter.append("line")
+ .attr("stroke", "#000")
+ .attr(x + "2", k * tickSizeInner));
+
+ text = text.merge(tickEnter.append("text")
+ .attr("fill", "#000")
+ .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)
+ .attr("transform", function(d) { return isFinite(d = position(d)) ? transform(d) : this.getAttribute("transform"); });
+
+ tickEnter
+ .attr("opacity", epsilon)
+ .attr("transform", function(d) { var p = this.parentNode.__axis; return transform(p && isFinite(p = p(d)) ? p : position(d)); });
+ }
+
+ tickExit.remove();
+
+ path
+ .attr("d", orient === left || orient == right
+ ? "M" + k * tickSizeOuter + "," + range0 + "H0.5V" + range1 + "H" + k * tickSizeOuter
+ : "M" + range0 + "," + k * tickSizeOuter + "V0.5H" + range1 + "V" + k * tickSizeOuter);
+
+ tick
+ .attr("opacity", 1)
+ .attr("transform", function(d) { return transform(position(d)); });
+
+ 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 = slice.call(arguments), axis;
+ };
+
+ axis.tickArguments = function(_) {
+ return arguments.length ? (tickArguments = _ == null ? [] : slice.call(_), axis) : tickArguments.slice();
+ };
+
+ axis.tickValues = function(_) {
+ return arguments.length ? (tickValues = _ == null ? null : slice.call(_), 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;
+ };
+
+ 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);
+}
+
+exports.axisTop = axisTop;
+exports.axisRight = axisRight;
+exports.axisBottom = axisBottom;
+exports.axisLeft = axisLeft;
+
+Object.defineProperty(exports, '__esModule', { value: true });
+
+})));
+
+},{}],25:[function(require,module,exports){
+// https://d3js.org/d3-brush/ Version 1.0.4. Copyright 2017 Mike Bostock.
+(function (global, factory) {
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('d3-dispatch'), require('d3-drag'), require('d3-interpolate'), require('d3-selection'), require('d3-transition')) :
+ typeof define === 'function' && define.amd ? define(['exports', 'd3-dispatch', 'd3-drag', 'd3-interpolate', 'd3-selection', 'd3-transition'], factory) :
+ (factory((global.d3 = global.d3 || {}),global.d3,global.d3,global.d3,global.d3,global.d3));
+}(this, (function (exports,d3Dispatch,d3Drag,d3Interpolate,d3Selection,d3Transition) { 'use strict';
+
+var constant = function(x) {
+ return function() {
+ return x;
+ };
+};
+
+var BrushEvent = function(target, type, selection) {
+ this.target = target;
+ this.type = type;
+ this.selection = selection;
+};
+
+function nopropagation() {
+ d3Selection.event.stopImmediatePropagation();
+}
+
+var noevent = function() {
+ d3Selection.event.preventDefault();
+ d3Selection.event.stopImmediatePropagation();
+};
+
+var MODE_DRAG = {name: "drag"};
+var MODE_SPACE = {name: "space"};
+var MODE_HANDLE = {name: "handle"};
+var MODE_CENTER = {name: "center"};
+
+var X = {
+ name: "x",
+ handles: ["e", "w"].map(type),
+ input: function(x, e) { return x && [[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 && [[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", "e", "s", "w", "nw", "ne", "se", "sw"].map(type),
+ input: function(xy) { return 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() {
+ return !d3Selection.event.button;
+}
+
+function defaultExtent() {
+ var svg = this.ownerSVGElement || this;
+ return [[0, 0], [svg.width.baseVal.value, svg.height.baseVal.value]];
+}
+
+// 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);
+}
+
+var brush = function() {
+ return brush$1(XY);
+};
+
+function brush$1(dim) {
+ var extent = defaultExtent,
+ filter = defaultFilter,
+ listeners = d3Dispatch.dispatch(brush, "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;
+ d3Selection.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")
+ .style("-webkit-tap-highlight-color", "rgba(0,0,0,0)")
+ .on("mousedown.brush touchstart.brush", started);
+ }
+
+ brush.move = function(group, selection) {
+ if (group.selection) {
+ group
+ .on("start.brush", function() { emitter(this, arguments).beforestart().start(); })
+ .on("interrupt.brush end.brush", function() { emitter(this, arguments).end(); })
+ .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 = d3Interpolate.interpolate(selection0, selection1);
+
+ function tween(t) {
+ state.selection = t === 1 && empty(selection1) ? null : i(t);
+ redraw.call(that);
+ emit.brush();
+ }
+
+ return selection0 && selection1 ? 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();
+
+ d3Transition.interrupt(that);
+ state.selection = selection1 == null || empty(selection1) ? null : selection1;
+ redraw.call(that);
+ emit.start().brush().end();
+ });
+ }
+ };
+
+ function redraw() {
+ var group = d3Selection.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) {
+ return that.__brush.emitter || new Emitter(that, args);
+ }
+
+ function Emitter(that, args) {
+ this.that = that;
+ this.args = args;
+ this.state = that.__brush;
+ this.active = 0;
+ }
+
+ Emitter.prototype = {
+ beforestart: function() {
+ if (++this.active === 1) this.state.emitter = this, this.starting = true;
+ return this;
+ },
+ start: function() {
+ if (this.starting) this.starting = false, this.emit("start");
+ return this;
+ },
+ brush: function() {
+ this.emit("brush");
+ return this;
+ },
+ end: function() {
+ if (--this.active === 0) delete this.state.emitter, this.emit("end");
+ return this;
+ },
+ emit: function(type) {
+ d3Selection.customEvent(new BrushEvent(brush, type, dim.output(this.state.selection)), listeners.apply, listeners, [type, this.that, this.args]);
+ }
+ };
+
+ function started() {
+ if (d3Selection.event.touches) { if (d3Selection.event.changedTouches.length < d3Selection.event.touches.length) return noevent(); }
+ else if (touchending) return;
+ if (!filter.apply(this, arguments)) return;
+
+ var that = this,
+ type = d3Selection.event.target.__data__.type,
+ mode = (d3Selection.event.metaKey ? type = "overlay" : type) === "selection" ? MODE_DRAG : (d3Selection.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,
+ dy,
+ moving,
+ shifting = signX && signY && d3Selection.event.shiftKey,
+ lockX,
+ lockY,
+ point0 = d3Selection.mouse(that),
+ point = point0,
+ emit = emitter(that, arguments).beforestart();
+
+ if (type === "overlay") {
+ state.selection = selection = [
+ [w0 = dim === Y ? W : point0[0], n0 = dim === X ? N : point0[1]],
+ [e0 = dim === Y ? E : w0, s0 = dim === X ? S : n0]
+ ];
+ } 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 = d3Selection.select(that)
+ .attr("pointer-events", "none");
+
+ var overlay = group.selectAll(".overlay")
+ .attr("cursor", cursors[type]);
+
+ if (d3Selection.event.touches) {
+ group
+ .on("touchmove.brush", moved, true)
+ .on("touchend.brush touchcancel.brush", ended, true);
+ } else {
+ var view = d3Selection.select(d3Selection.event.view)
+ .on("keydown.brush", keydowned, true)
+ .on("keyup.brush", keyupped, true)
+ .on("mousemove.brush", moved, true)
+ .on("mouseup.brush", ended, true);
+
+ d3Drag.dragDisable(d3Selection.event.view);
+ }
+
+ nopropagation();
+ d3Transition.interrupt(that);
+ redraw.call(that);
+ emit.start();
+
+ function moved() {
+ var point1 = d3Selection.mouse(that);
+ if (shifting && !lockX && !lockY) {
+ if (Math.abs(point1[0] - point[0]) > Math.abs(point1[1] - point[1])) lockY = true;
+ else lockX = true;
+ }
+ point = point1;
+ moving = true;
+ noevent();
+ move();
+ }
+
+ function move() {
+ var t;
+
+ dx = point[0] - point0[0];
+ dy = point[1] - point0[1];
+
+ switch (mode) {
+ case MODE_SPACE:
+ case MODE_DRAG: {
+ if (signX) dx = Math.max(W - w0, Math.min(E - e0, dx)), w1 = w0 + dx, e1 = e0 + dx;
+ if (signY) dy = Math.max(N - n0, Math.min(S - s0, dy)), n1 = n0 + dy, s1 = s0 + dy;
+ break;
+ }
+ case MODE_HANDLE: {
+ if (signX < 0) dx = Math.max(W - w0, Math.min(E - w0, dx)), w1 = w0 + dx, e1 = e0;
+ else if (signX > 0) dx = Math.max(W - e0, Math.min(E - e0, dx)), w1 = w0, e1 = e0 + dx;
+ if (signY < 0) dy = Math.max(N - n0, Math.min(S - n0, dy)), n1 = n0 + dy, s1 = s0;
+ else if (signY > 0) dy = Math.max(N - s0, Math.min(S - s0, dy)), n1 = n0, s1 = s0 + dy;
+ break;
+ }
+ case MODE_CENTER: {
+ if (signX) w1 = Math.max(W, Math.min(E, w0 - dx * signX)), e1 = Math.max(W, Math.min(E, e0 + dx * signX));
+ if (signY) n1 = Math.max(N, Math.min(S, n0 - dy * signY)), s1 = Math.max(N, Math.min(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();
+ }
+ }
+
+ function ended() {
+ nopropagation();
+ if (d3Selection.event.touches) {
+ if (d3Selection.event.touches.length) return;
+ if (touchending) clearTimeout(touchending);
+ touchending = setTimeout(function() { touchending = null; }, 500); // Ghost clicks are delayed!
+ group.on("touchmove.brush touchend.brush touchcancel.brush", null);
+ } else {
+ d3Drag.dragEnable(d3Selection.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();
+ }
+
+ function keydowned() {
+ switch (d3Selection.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();
+ }
+ 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();
+ }
+ break;
+ }
+ default: return;
+ }
+ noevent();
+ }
+
+ function keyupped() {
+ switch (d3Selection.event.keyCode) {
+ case 16: { // SHIFT
+ if (shifting) {
+ lockX = lockY = shifting = false;
+ move();
+ }
+ 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();
+ }
+ break;
+ }
+ case 32: { // SPACE
+ if (mode === MODE_SPACE) {
+ if (d3Selection.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();
+ }
+ break;
+ }
+ default: return;
+ }
+ noevent();
+ }
+ }
+
+ function initialize() {
+ var state = this.__brush || {selection: null};
+ state.extent = extent.apply(this, arguments);
+ state.dim = dim;
+ return state;
+ }
+
+ brush.extent = function(_) {
+ return arguments.length ? (extent = typeof _ === "function" ? _ : constant([[+_[0][0], +_[0][1]], [+_[1][0], +_[1][1]]]), brush) : extent;
+ };
+
+ brush.filter = function(_) {
+ return arguments.length ? (filter = typeof _ === "function" ? _ : constant(!!_), brush) : filter;
+ };
+
+ brush.handleSize = function(_) {
+ return arguments.length ? (handleSize = +_, brush) : handleSize;
+ };
+
+ brush.on = function() {
+ var value = listeners.on.apply(listeners, arguments);
+ return value === listeners ? brush : value;
+ };
+
+ return brush;
+}
+
+exports.brush = brush;
+exports.brushX = brushX;
+exports.brushY = brushY;
+exports.brushSelection = brushSelection;
+
+Object.defineProperty(exports, '__esModule', { value: true });
+
+})));
+
+},{"d3-dispatch":29,"d3-drag":30,"d3-interpolate":37,"d3-selection":45,"d3-transition":51}],26:[function(require,module,exports){
+// https://d3js.org/d3-chord/ Version 1.0.4. Copyright 2017 Mike Bostock.
+(function (global, factory) {
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('d3-array'), require('d3-path')) :
+ typeof define === 'function' && define.amd ? define(['exports', 'd3-array', 'd3-path'], factory) :
+ (factory((global.d3 = global.d3 || {}),global.d3,global.d3));
+}(this, (function (exports,d3Array,d3Path) { 'use strict';
+
+var cos = Math.cos;
+var sin = Math.sin;
+var pi = Math.PI;
+var halfPi = pi / 2;
+var tau = pi * 2;
+var max = Math.max;
+
+function compareValue(compare) {
+ return function(a, b) {
+ return compare(
+ a.source.value + a.target.value,
+ b.source.value + b.target.value
+ );
+ };
+}
+
+var chord = function() {
+ var padAngle = 0,
+ sortGroups = null,
+ sortSubgroups = null,
+ sortChords = null;
+
+ function chord(matrix) {
+ var n = matrix.length,
+ groupSums = [],
+ groupIndex = d3Array.range(n),
+ subgroupIndex = [],
+ chords = [],
+ groups = chords.groups = new Array(n),
+ subgroups = new Array(n * n),
+ k,
+ x,
+ x0,
+ dx,
+ i,
+ j;
+
+ // Compute the sum.
+ k = 0, i = -1; while (++i < n) {
+ x = 0, j = -1; while (++j < n) {
+ x += matrix[i][j];
+ }
+ groupSums.push(x);
+ subgroupIndex.push(d3Array.range(n));
+ k += x;
+ }
+
+ // Sort groups…
+ if (sortGroups) groupIndex.sort(function(a, b) {
+ return sortGroups(groupSums[a], groupSums[b]);
+ });
+
+ // Sort subgroups…
+ if (sortSubgroups) subgroupIndex.forEach(function(d, i) {
+ d.sort(function(a, b) {
+ return sortSubgroups(matrix[i][a], matrix[i][b]);
+ });
+ });
+
+ // Convert the sum to scaling factor for [0, 2pi].
+ // TODO Allow start and end angle to be specified?
+ // TODO Allow padding to be specified as percentage?
+ k = max(0, tau - padAngle * n) / k;
+ dx = k ? padAngle : tau / n;
+
+ // Compute the start and end angle for each group and subgroup.
+ // Note: Opera has a bug reordering object literal properties!
+ x = 0, i = -1; while (++i < n) {
+ x0 = x, j = -1; while (++j < n) {
+ var di = groupIndex[i],
+ dj = subgroupIndex[di][j],
+ v = matrix[di][dj],
+ a0 = x,
+ a1 = x += v * k;
+ subgroups[dj * n + di] = {
+ index: di,
+ subindex: dj,
+ startAngle: a0,
+ endAngle: a1,
+ value: v
+ };
+ }
+ groups[di] = {
+ index: di,
+ startAngle: x0,
+ endAngle: x,
+ value: groupSums[di]
+ };
+ x += dx;
+ }
+
+ // Generate chords for each (non-empty) subgroup-subgroup link.
+ i = -1; while (++i < n) {
+ j = i - 1; while (++j < n) {
+ var source = subgroups[j * n + i],
+ target = subgroups[i * n + j];
+ if (source.value || target.value) {
+ chords.push(source.value < target.value
+ ? {source: target, target: source}
+ : {source: source, target: target});
+ }
+ }
+ }
+
+ return sortChords ? chords.sort(sortChords) : chords;
+ }
+
+ chord.padAngle = function(_) {
+ return arguments.length ? (padAngle = max(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;
+};
+
+var slice = Array.prototype.slice;
+
+var constant = function(x) {
+ return function() {
+ return x;
+ };
+};
+
+function defaultSource(d) {
+ return d.source;
+}
+
+function defaultTarget(d) {
+ return d.target;
+}
+
+function defaultRadius(d) {
+ return d.radius;
+}
+
+function defaultStartAngle(d) {
+ return d.startAngle;
+}
+
+function defaultEndAngle(d) {
+ return d.endAngle;
+}
+
+var ribbon = function() {
+ var source = defaultSource,
+ target = defaultTarget,
+ radius = defaultRadius,
+ startAngle = defaultStartAngle,
+ endAngle = defaultEndAngle,
+ context = null;
+
+ function ribbon() {
+ var buffer,
+ argv = slice.call(arguments),
+ s = source.apply(this, argv),
+ t = target.apply(this, argv),
+ sr = +radius.apply(this, (argv[0] = s, argv)),
+ sa0 = startAngle.apply(this, argv) - halfPi,
+ sa1 = endAngle.apply(this, argv) - halfPi,
+ sx0 = sr * cos(sa0),
+ sy0 = sr * sin(sa0),
+ tr = +radius.apply(this, (argv[0] = t, argv)),
+ ta0 = startAngle.apply(this, argv) - halfPi,
+ ta1 = endAngle.apply(this, argv) - halfPi;
+
+ if (!context) context = buffer = d3Path.path();
+
+ context.moveTo(sx0, sy0);
+ context.arc(0, 0, sr, sa0, sa1);
+ if (sa0 !== ta0 || sa1 !== ta1) { // TODO sr !== tr?
+ context.quadraticCurveTo(0, 0, tr * cos(ta0), tr * sin(ta0));
+ context.arc(0, 0, tr, ta0, ta1);
+ }
+ context.quadraticCurveTo(0, 0, sx0, sy0);
+ context.closePath();
+
+ if (buffer) return context = null, buffer + "" || null;
+ }
+
+ ribbon.radius = function(_) {
+ return arguments.length ? (radius = typeof _ === "function" ? _ : constant(+_), ribbon) : radius;
+ };
+
+ ribbon.startAngle = function(_) {
+ return arguments.length ? (startAngle = typeof _ === "function" ? _ : constant(+_), ribbon) : startAngle;
+ };
+
+ ribbon.endAngle = function(_) {
+ return arguments.length ? (endAngle = typeof _ === "function" ? _ : constant(+_), ribbon) : endAngle;
+ };
+
+ 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;
+};
+
+exports.chord = chord;
+exports.ribbon = ribbon;
+
+Object.defineProperty(exports, '__esModule', { value: true });
+
+})));
+
+},{"d3-array":23,"d3-path":38}],27:[function(require,module,exports){
+// https://d3js.org/d3-collection/ Version 1.0.4. Copyright 2017 Mike Bostock.
+(function (global, factory) {
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
+ typeof define === 'function' && define.amd ? define(['exports'], factory) :
+ (factory((global.d3 = global.d3 || {})));
+}(this, (function (exports) { 'use strict';
+
+var prefix = "$";
+
+function Map() {}
+
+Map.prototype = map.prototype = {
+ constructor: Map,
+ has: function(key) {
+ return (prefix + key) in this;
+ },
+ get: function(key) {
+ return this[prefix + key];
+ },
+ set: function(key, value) {
+ this[prefix + key] = value;
+ return this;
+ },
+ remove: function(key) {
+ var property = prefix + key;
+ return property in this && delete this[property];
+ },
+ clear: function() {
+ for (var property in this) if (property[0] === prefix) delete this[property];
+ },
+ keys: function() {
+ var keys = [];
+ for (var property in this) if (property[0] === prefix) keys.push(property.slice(1));
+ return keys;
+ },
+ values: function() {
+ var values = [];
+ for (var property in this) if (property[0] === prefix) values.push(this[property]);
+ return values;
+ },
+ entries: function() {
+ var entries = [];
+ for (var property in this) if (property[0] === prefix) entries.push({key: property.slice(1), value: this[property]});
+ return entries;
+ },
+ size: function() {
+ var size = 0;
+ for (var property in this) if (property[0] === prefix) ++size;
+ return size;
+ },
+ empty: function() {
+ for (var property in this) if (property[0] === prefix) return false;
+ return true;
+ },
+ each: function(f) {
+ for (var property in this) if (property[0] === prefix) f(this[property], property.slice(1), this);
+ }
+};
+
+function map(object, f) {
+ var map = new Map;
+
+ // Copy constructor.
+ if (object instanceof Map) object.each(function(value, key) { map.set(key, value); });
+
+ // Index array by numeric index or specified key function.
+ else if (Array.isArray(object)) {
+ var i = -1,
+ n = object.length,
+ o;
+
+ if (f == null) while (++i < n) map.set(i, object[i]);
+ else while (++i < n) map.set(f(o = object[i], i, object), o);
+ }
+
+ // Convert object to map.
+ else if (object) for (var key in object) map.set(key, object[key]);
+
+ return map;
+}
+
+var nest = function() {
+ var keys = [],
+ sortKeys = [],
+ sortValues,
+ rollup,
+ nest;
+
+ function apply(array, depth, createResult, setResult) {
+ if (depth >= keys.length) {
+ if (sortValues != null) array.sort(sortValues);
+ return rollup != null ? rollup(array) : array;
+ }
+
+ var i = -1,
+ n = array.length,
+ key = keys[depth++],
+ keyValue,
+ value,
+ valuesByKey = map(),
+ values,
+ result = createResult();
+
+ while (++i < n) {
+ if (values = valuesByKey.get(keyValue = key(value = array[i]) + "")) {
+ values.push(value);
+ } else {
+ valuesByKey.set(keyValue, [value]);
+ }
+ }
+
+ valuesByKey.each(function(values, key) {
+ setResult(result, key, apply(values, depth, createResult, setResult));
+ });
+
+ return result;
+ }
+
+ function entries(map$$1, depth) {
+ if (++depth > keys.length) return map$$1;
+ var array, sortKey = sortKeys[depth - 1];
+ if (rollup != null && depth >= keys.length) array = map$$1.entries();
+ else array = [], map$$1.each(function(v, k) { array.push({key: k, values: entries(v, depth)}); });
+ return sortKey != null ? array.sort(function(a, b) { return sortKey(a.key, b.key); }) : array;
+ }
+
+ return nest = {
+ object: function(array) { return apply(array, 0, createObject, setObject); },
+ map: function(array) { return apply(array, 0, createMap, setMap); },
+ entries: function(array) { return entries(apply(array, 0, createMap, setMap), 0); },
+ key: function(d) { keys.push(d); return nest; },
+ sortKeys: function(order) { sortKeys[keys.length - 1] = order; return nest; },
+ sortValues: function(order) { sortValues = order; return nest; },
+ rollup: function(f) { rollup = f; return nest; }
+ };
+};
+
+function createObject() {
+ return {};
+}
+
+function setObject(object, key, value) {
+ object[key] = value;
+}
+
+function createMap() {
+ return map();
+}
+
+function setMap(map$$1, key, value) {
+ map$$1.set(key, value);
+}
+
+function Set() {}
+
+var proto = map.prototype;
+
+Set.prototype = set.prototype = {
+ constructor: Set,
+ has: proto.has,
+ add: function(value) {
+ value += "";
+ this[prefix + value] = value;
+ return this;
+ },
+ remove: proto.remove,
+ clear: proto.clear,
+ values: proto.keys,
+ size: proto.size,
+ empty: proto.empty,
+ each: proto.each
+};
+
+function set(object, f) {
+ var set = new Set;
+
+ // Copy constructor.
+ if (object instanceof Set) object.each(function(value) { set.add(value); });
+
+ // Otherwise, assume it’s an array.
+ else if (object) {
+ var i = -1, n = object.length;
+ if (f == null) while (++i < n) set.add(object[i]);
+ else while (++i < n) set.add(f(object[i], i, object));
+ }
+
+ return set;
+}
+
+var keys = function(map) {
+ var keys = [];
+ for (var key in map) keys.push(key);
+ return keys;
+};
+
+var values = function(map) {
+ var values = [];
+ for (var key in map) values.push(map[key]);
+ return values;
+};
+
+var entries = function(map) {
+ var entries = [];
+ for (var key in map) entries.push({key: key, value: map[key]});
+ return entries;
+};
+
+exports.nest = nest;
+exports.set = set;
+exports.map = map;
+exports.keys = keys;
+exports.values = values;
+exports.entries = entries;
+
+Object.defineProperty(exports, '__esModule', { value: true });
+
+})));
+
+},{}],28:[function(require,module,exports){
+// https://d3js.org/d3-color/ Version 1.0.3. Copyright 2017 Mike Bostock.
+(function (global, factory) {
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
+ typeof define === 'function' && define.amd ? define(['exports'], factory) :
+ (factory((global.d3 = global.d3 || {})));
+}(this, (function (exports) { 'use strict';
+
+var define = function(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*";
+var reN = "\\s*([+-]?\\d*\\.?\\d+(?:[eE][+-]?\\d+)?)\\s*";
+var reP = "\\s*([+-]?\\d*\\.?\\d+(?:[eE][+-]?\\d+)?)%\\s*";
+var reHex3 = /^#([0-9a-f]{3})$/;
+var reHex6 = /^#([0-9a-f]{6})$/;
+var reRgbInteger = new RegExp("^rgb\\(" + [reI, reI, reI] + "\\)$");
+var reRgbPercent = new RegExp("^rgb\\(" + [reP, reP, reP] + "\\)$");
+var reRgbaInteger = new RegExp("^rgba\\(" + [reI, reI, reI, reN] + "\\)$");
+var reRgbaPercent = new RegExp("^rgba\\(" + [reP, reP, reP, reN] + "\\)$");
+var reHslPercent = new RegExp("^hsl\\(" + [reN, reP, reP] + "\\)$");
+var 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, {
+ displayable: function() {
+ return this.rgb().displayable();
+ },
+ toString: function() {
+ return this.rgb() + "";
+ }
+});
+
+function color(format) {
+ var m;
+ format = (format + "").trim().toLowerCase();
+ return (m = reHex3.exec(format)) ? (m = parseInt(m[1], 16), new Rgb((m >> 8 & 0xf) | (m >> 4 & 0x0f0), (m >> 4 & 0xf) | (m & 0xf0), ((m & 0xf) << 4) | (m & 0xf), 1)) // #f00
+ : (m = reHex6.exec(format)) ? rgbn(parseInt(m[1], 16)) // #ff0000
+ : (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])
+ : 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 <= this.r && this.r <= 255)
+ && (0 <= this.g && this.g <= 255)
+ && (0 <= this.b && this.b <= 255)
+ && (0 <= this.opacity && this.opacity <= 1);
+ },
+ toString: function() {
+ 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 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(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, 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);
+ }
+}));
+
+/* 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;
+}
+
+var deg2rad = Math.PI / 180;
+var rad2deg = 180 / Math.PI;
+
+var Kn = 18;
+var Xn = 0.950470;
+var Yn = 1;
+var Zn = 1.088830;
+var t0 = 4 / 29;
+var t1 = 6 / 29;
+var t2 = 3 * t1 * t1;
+var t3 = t1 * t1 * t1;
+
+function labConvert(o) {
+ if (o instanceof Lab) return new Lab(o.l, o.a, o.b, o.opacity);
+ if (o instanceof Hcl) {
+ var h = o.h * deg2rad;
+ return new Lab(o.l, Math.cos(h) * o.c, Math.sin(h) * o.c, o.opacity);
+ }
+ if (!(o instanceof Rgb)) o = rgbConvert(o);
+ var b = rgb2xyz(o.r),
+ a = rgb2xyz(o.g),
+ l = rgb2xyz(o.b),
+ x = xyz2lab((0.4124564 * b + 0.3575761 * a + 0.1804375 * l) / Xn),
+ y = xyz2lab((0.2126729 * b + 0.7151522 * a + 0.0721750 * l) / Yn),
+ z = xyz2lab((0.0193339 * b + 0.1191920 * a + 0.9503041 * l) / Zn);
+ return new Lab(116 * y - 16, 500 * (x - y), 200 * (y - z), o.opacity);
+}
+
+function lab(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, extend(Color, {
+ brighter: function(k) {
+ return new Lab(this.l + Kn * (k == null ? 1 : k), this.a, this.b, this.opacity);
+ },
+ darker: function(k) {
+ return new Lab(this.l - Kn * (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;
+ y = Yn * lab2xyz(y);
+ x = Xn * lab2xyz(x);
+ z = Zn * lab2xyz(z);
+ return new Rgb(
+ xyz2rgb( 3.2404542 * x - 1.5371385 * y - 0.4985314 * z), // D65 -> sRGB
+ xyz2rgb(-0.9692660 * x + 1.8760108 * y + 0.0415560 * z),
+ xyz2rgb( 0.0556434 * x - 0.2040259 * y + 1.0572252 * z),
+ this.opacity
+ );
+ }
+}));
+
+function xyz2lab(t) {
+ return t > t3 ? Math.pow(t, 1 / 3) : t / t2 + t0;
+}
+
+function lab2xyz(t) {
+ return t > t1 ? t * t * t : t2 * (t - t0);
+}
+
+function xyz2rgb(x) {
+ return 255 * (x <= 0.0031308 ? 12.92 * x : 1.055 * Math.pow(x, 1 / 2.4) - 0.055);
+}
+
+function rgb2xyz(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);
+ var h = Math.atan2(o.b, o.a) * rad2deg;
+ return new Hcl(h < 0 ? h + 360 : h, Math.sqrt(o.a * o.a + o.b * o.b), o.l, o.opacity);
+}
+
+function hcl(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;
+}
+
+define(Hcl, hcl, extend(Color, {
+ brighter: function(k) {
+ return new Hcl(this.h, this.c, this.l + Kn * (k == null ? 1 : k), this.opacity);
+ },
+ darker: function(k) {
+ return new Hcl(this.h, this.c, this.l - Kn * (k == null ? 1 : k), this.opacity);
+ },
+ rgb: function() {
+ return labConvert(this).rgb();
+ }
+}));
+
+var A = -0.14861;
+var B = +1.78277;
+var C = -0.29227;
+var D = -0.90649;
+var E = +1.97294;
+var ED = E * D;
+var EB = E * B;
+var BC_DA = B * C - D * 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,
+ s = Math.sqrt(k * k + bl * bl) / (E * l * (1 - l)), // NaN if l=0 or l=1
+ h = s ? Math.atan2(k, bl) * rad2deg - 120 : NaN;
+ return new Cubehelix(h < 0 ? h + 360 : h, s, l, o.opacity);
+}
+
+function cubehelix(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, 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) * deg2rad,
+ 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 * sinh)),
+ 255 * (l + a * (C * cosh + D * sinh)),
+ 255 * (l + a * (E * cosh)),
+ this.opacity
+ );
+ }
+}));
+
+exports.color = color;
+exports.rgb = rgb;
+exports.hsl = hsl;
+exports.lab = lab;
+exports.hcl = hcl;
+exports.cubehelix = cubehelix;
+
+Object.defineProperty(exports, '__esModule', { value: true });
+
+})));
+
+},{}],29:[function(require,module,exports){
+// https://d3js.org/d3-dispatch/ Version 1.0.3. Copyright 2017 Mike Bostock.
+(function (global, factory) {
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
+ typeof define === 'function' && define.amd ? define(['exports'], factory) :
+ (factory((global.d3 = global.d3 || {})));
+}(this, (function (exports) { 'use strict';
+
+var noop = {value: function() {}};
+
+function dispatch() {
+ for (var i = 0, n = arguments.length, _ = {}, t; i < n; ++i) {
+ if (!(t = arguments[i] + "") || (t in _)) throw new Error("illegal type: " + t);
+ _[t] = [];
+ }
+ return new Dispatch(_);
+}
+
+function Dispatch(_) {
+ this._ = _;
+}
+
+function parseTypenames(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(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(_[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(_[t], typename.name, callback);
+ else if (callback == null) for (t in _) _[t] = set(_[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(type, name) {
+ for (var i = 0, n = type.length, c; i < n; ++i) {
+ if ((c = type[i]).name === name) {
+ return c.value;
+ }
+ }
+}
+
+function set(type, name, callback) {
+ for (var i = 0, n = type.length; i < n; ++i) {
+ if (type[i].name === name) {
+ type[i] = noop, type = type.slice(0, i).concat(type.slice(i + 1));
+ break;
+ }
+ }
+ if (callback != null) type.push({name: name, value: callback});
+ return type;
+}
+
+exports.dispatch = dispatch;
+
+Object.defineProperty(exports, '__esModule', { value: true });
+
+})));
+
+},{}],30:[function(require,module,exports){
+// https://d3js.org/d3-drag/ Version 1.2.1. Copyright 2017 Mike Bostock.
+(function (global, factory) {
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('d3-dispatch'), require('d3-selection')) :
+ typeof define === 'function' && define.amd ? define(['exports', 'd3-dispatch', 'd3-selection'], factory) :
+ (factory((global.d3 = global.d3 || {}),global.d3,global.d3));
+}(this, (function (exports,d3Dispatch,d3Selection) { 'use strict';
+
+function nopropagation() {
+ d3Selection.event.stopImmediatePropagation();
+}
+
+var noevent = function() {
+ d3Selection.event.preventDefault();
+ d3Selection.event.stopImmediatePropagation();
+};
+
+var nodrag = function(view) {
+ var root = view.document.documentElement,
+ selection = d3Selection.select(view).on("dragstart.drag", noevent, true);
+ if ("onselectstart" in root) {
+ selection.on("selectstart.drag", noevent, true);
+ } else {
+ root.__noselect = root.style.MozUserSelect;
+ root.style.MozUserSelect = "none";
+ }
+};
+
+function yesdrag(view, noclick) {
+ var root = view.document.documentElement,
+ selection = d3Selection.select(view).on("dragstart.drag", null);
+ if (noclick) {
+ selection.on("click.drag", noevent, true);
+ 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 = function(x) {
+ return function() {
+ return x;
+ };
+};
+
+function DragEvent(target, type, subject, id, active, x, y, dx, dy, dispatch$$1) {
+ this.target = target;
+ this.type = type;
+ this.subject = subject;
+ this.identifier = id;
+ this.active = active;
+ this.x = x;
+ this.y = y;
+ this.dx = dx;
+ this.dy = dy;
+ this._ = dispatch$$1;
+}
+
+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() {
+ return !d3Selection.event.button;
+}
+
+function defaultContainer() {
+ return this.parentNode;
+}
+
+function defaultSubject(d) {
+ return d == null ? {x: d3Selection.event.x, y: d3Selection.event.y} : d;
+}
+
+function defaultTouchable() {
+ return "ontouchstart" in this;
+}
+
+var drag = function() {
+ var filter = defaultFilter,
+ container = defaultContainer,
+ subject = defaultSubject,
+ touchable = defaultTouchable,
+ gestures = {},
+ listeners = d3Dispatch.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)
+ .on("touchend.drag touchcancel.drag", touchended)
+ .style("touch-action", "none")
+ .style("-webkit-tap-highlight-color", "rgba(0,0,0,0)");
+ }
+
+ function mousedowned() {
+ if (touchending || !filter.apply(this, arguments)) return;
+ var gesture = beforestart("mouse", container.apply(this, arguments), d3Selection.mouse, this, arguments);
+ if (!gesture) return;
+ d3Selection.select(d3Selection.event.view).on("mousemove.drag", mousemoved, true).on("mouseup.drag", mouseupped, true);
+ nodrag(d3Selection.event.view);
+ nopropagation();
+ mousemoving = false;
+ mousedownx = d3Selection.event.clientX;
+ mousedowny = d3Selection.event.clientY;
+ gesture("start");
+ }
+
+ function mousemoved() {
+ noevent();
+ if (!mousemoving) {
+ var dx = d3Selection.event.clientX - mousedownx, dy = d3Selection.event.clientY - mousedowny;
+ mousemoving = dx * dx + dy * dy > clickDistance2;
+ }
+ gestures.mouse("drag");
+ }
+
+ function mouseupped() {
+ d3Selection.select(d3Selection.event.view).on("mousemove.drag mouseup.drag", null);
+ yesdrag(d3Selection.event.view, mousemoving);
+ noevent();
+ gestures.mouse("end");
+ }
+
+ function touchstarted() {
+ if (!filter.apply(this, arguments)) return;
+ var touches = d3Selection.event.changedTouches,
+ c = container.apply(this, arguments),
+ n = touches.length, i, gesture;
+
+ for (i = 0; i < n; ++i) {
+ if (gesture = beforestart(touches[i].identifier, c, d3Selection.touch, this, arguments)) {
+ nopropagation();
+ gesture("start");
+ }
+ }
+ }
+
+ function touchmoved() {
+ var touches = d3Selection.event.changedTouches,
+ n = touches.length, i, gesture;
+
+ for (i = 0; i < n; ++i) {
+ if (gesture = gestures[touches[i].identifier]) {
+ noevent();
+ gesture("drag");
+ }
+ }
+ }
+
+ function touchended() {
+ var touches = d3Selection.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();
+ gesture("end");
+ }
+ }
+ }
+
+ function beforestart(id, container, point, that, args) {
+ var p = point(container, id), s, dx, dy,
+ sublisteners = listeners.copy();
+
+ if (!d3Selection.customEvent(new DragEvent(drag, "beforestart", s, id, active, p[0], p[1], 0, 0, sublisteners), function() {
+ if ((d3Selection.event.subject = s = subject.apply(that, args)) == null) return false;
+ dx = s.x - p[0] || 0;
+ dy = s.y - p[1] || 0;
+ return true;
+ })) return;
+
+ return function gesture(type) {
+ var p0 = p, n;
+ switch (type) {
+ case "start": gestures[id] = gesture, n = active++; break;
+ case "end": delete gestures[id], --active; // nobreak
+ case "drag": p = point(container, id), n = active; break;
+ }
+ d3Selection.customEvent(new DragEvent(drag, type, s, id, n, p[0] + dx, p[1] + dy, p[0] - p0[0], p[1] - p0[1], sublisteners), sublisteners.apply, sublisteners, [type, that, args]);
+ };
+ }
+
+ drag.filter = function(_) {
+ return arguments.length ? (filter = typeof _ === "function" ? _ : constant(!!_), drag) : filter;
+ };
+
+ drag.container = function(_) {
+ return arguments.length ? (container = typeof _ === "function" ? _ : constant(_), drag) : container;
+ };
+
+ drag.subject = function(_) {
+ return arguments.length ? (subject = typeof _ === "function" ? _ : constant(_), drag) : subject;
+ };
+
+ drag.touchable = function(_) {
+ return arguments.length ? (touchable = typeof _ === "function" ? _ : constant(!!_), 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;
+};
+
+exports.drag = drag;
+exports.dragDisable = nodrag;
+exports.dragEnable = yesdrag;
+
+Object.defineProperty(exports, '__esModule', { value: true });
+
+})));
+
+},{"d3-dispatch":29,"d3-selection":45}],31:[function(require,module,exports){
+// https://d3js.org/d3-dsv/ Version 1.0.8. Copyright 2017 Mike Bostock.
+(function (global, factory) {
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
+ typeof define === 'function' && define.amd ? define(['exports'], factory) :
+ (factory((global.d3 = global.d3 || {})));
+}(this, (function (exports) { 'use strict';
+
+var EOL = {};
+var EOF = {};
+var QUOTE = 34;
+var NEWLINE = 10;
+var 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;
+}
+
+var dsv = function(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 format(rows, columns) {
+ if (columns == null) columns = inferColumns(rows);
+ return [columns.map(formatValue).join(delimiter)].concat(rows.map(function(row) {
+ return columns.map(function(column) {
+ return formatValue(row[column]);
+ }).join(delimiter);
+ })).join("\n");
+ }
+
+ function formatRows(rows) {
+ return rows.map(formatRow).join("\n");
+ }
+
+ function formatRow(row) {
+ return row.map(formatValue).join(delimiter);
+ }
+
+ function formatValue(text) {
+ return text == null ? ""
+ : reFormat.test(text += "") ? "\"" + text.replace(/"/g, "\"\"") + "\""
+ : text;
+ }
+
+ return {
+ parse: parse,
+ parseRows: parseRows,
+ format: format,
+ formatRows: formatRows
+ };
+};
+
+var csv = dsv(",");
+
+var csvParse = csv.parse;
+var csvParseRows = csv.parseRows;
+var csvFormat = csv.format;
+var csvFormatRows = csv.formatRows;
+
+var tsv = dsv("\t");
+
+var tsvParse = tsv.parse;
+var tsvParseRows = tsv.parseRows;
+var tsvFormat = tsv.format;
+var tsvFormatRows = tsv.formatRows;
+
+exports.dsvFormat = dsv;
+exports.csvParse = csvParse;
+exports.csvParseRows = csvParseRows;
+exports.csvFormat = csvFormat;
+exports.csvFormatRows = csvFormatRows;
+exports.tsvParse = tsvParse;
+exports.tsvParseRows = tsvParseRows;
+exports.tsvFormat = tsvFormat;
+exports.tsvFormatRows = tsvFormatRows;
+
+Object.defineProperty(exports, '__esModule', { value: true });
+
+})));
+
+},{}],32:[function(require,module,exports){
+// https://d3js.org/d3-ease/ Version 1.0.3. Copyright 2017 Mike Bostock.
+(function (global, factory) {
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
+ typeof define === 'function' && define.amd ? define(['exports'], factory) :
+ (factory((global.d3 = global.d3 || {})));
+}(this, (function (exports) { 'use strict';
+
+function linear(t) {
+ return +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 = 3;
+
+var polyIn = (function custom(e) {
+ e = +e;
+
+ function polyIn(t) {
+ return Math.pow(t, e);
+ }
+
+ polyIn.exponent = custom;
+
+ return polyIn;
+})(exponent);
+
+var polyOut = (function custom(e) {
+ e = +e;
+
+ function polyOut(t) {
+ return 1 - Math.pow(1 - t, e);
+ }
+
+ polyOut.exponent = custom;
+
+ return polyOut;
+})(exponent);
+
+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);
+
+var pi = Math.PI;
+var halfPi = pi / 2;
+
+function sinIn(t) {
+ return 1 - Math.cos(t * halfPi);
+}
+
+function sinOut(t) {
+ return Math.sin(t * halfPi);
+}
+
+function sinInOut(t) {
+ return (1 - Math.cos(pi * t)) / 2;
+}
+
+function expIn(t) {
+ return Math.pow(2, 10 * t - 10);
+}
+
+function expOut(t) {
+ return 1 - Math.pow(2, -10 * t);
+}
+
+function expInOut(t) {
+ return ((t *= 2) <= 1 ? Math.pow(2, 10 * t - 10) : 2 - Math.pow(2, 10 - 10 * t)) / 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;
+var b2 = 6 / 11;
+var b3 = 8 / 11;
+var b4 = 3 / 4;
+var b5 = 9 / 11;
+var b6 = 10 / 11;
+var b7 = 15 / 16;
+var b8 = 21 / 22;
+var b9 = 63 / 64;
+var 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 * ((s + 1) * t - s);
+ }
+
+ backIn.overshoot = custom;
+
+ return backIn;
+})(overshoot);
+
+var backOut = (function custom(s) {
+ s = +s;
+
+ function backOut(t) {
+ return --t * t * ((s + 1) * t + s) + 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 = 2 * Math.PI;
+var amplitude = 1;
+var period = 0.3;
+
+var elasticIn = (function custom(a, p) {
+ var s = Math.asin(1 / (a = Math.max(1, a))) * (p /= tau);
+
+ function elasticIn(t) {
+ return a * Math.pow(2, 10 * --t) * Math.sin((s - t) / p);
+ }
+
+ elasticIn.amplitude = function(a) { return custom(a, p * tau); };
+ 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);
+
+ function elasticOut(t) {
+ return 1 - a * Math.pow(2, -10 * (t = +t)) * Math.sin((t + s) / p);
+ }
+
+ elasticOut.amplitude = function(a) { return custom(a, p * tau); };
+ 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);
+
+ function elasticInOut(t) {
+ return ((t = t * 2 - 1) < 0
+ ? a * Math.pow(2, 10 * t) * Math.sin((s - t) / p)
+ : 2 - a * Math.pow(2, -10 * t) * Math.sin((s + t) / p)) / 2;
+ }
+
+ elasticInOut.amplitude = function(a) { return custom(a, p * tau); };
+ elasticInOut.period = function(p) { return custom(a, p); };
+
+ return elasticInOut;
+})(amplitude, period);
+
+exports.easeLinear = linear;
+exports.easeQuad = quadInOut;
+exports.easeQuadIn = quadIn;
+exports.easeQuadOut = quadOut;
+exports.easeQuadInOut = quadInOut;
+exports.easeCubic = cubicInOut;
+exports.easeCubicIn = cubicIn;
+exports.easeCubicOut = cubicOut;
+exports.easeCubicInOut = cubicInOut;
+exports.easePoly = polyInOut;
+exports.easePolyIn = polyIn;
+exports.easePolyOut = polyOut;
+exports.easePolyInOut = polyInOut;
+exports.easeSin = sinInOut;
+exports.easeSinIn = sinIn;
+exports.easeSinOut = sinOut;
+exports.easeSinInOut = sinInOut;
+exports.easeExp = expInOut;
+exports.easeExpIn = expIn;
+exports.easeExpOut = expOut;
+exports.easeExpInOut = expInOut;
+exports.easeCircle = circleInOut;
+exports.easeCircleIn = circleIn;
+exports.easeCircleOut = circleOut;
+exports.easeCircleInOut = circleInOut;
+exports.easeBounce = bounceOut;
+exports.easeBounceIn = bounceIn;
+exports.easeBounceOut = bounceOut;
+exports.easeBounceInOut = bounceInOut;
+exports.easeBack = backInOut;
+exports.easeBackIn = backIn;
+exports.easeBackOut = backOut;
+exports.easeBackInOut = backInOut;
+exports.easeElastic = elasticOut;
+exports.easeElasticIn = elasticIn;
+exports.easeElasticOut = elasticOut;
+exports.easeElasticInOut = elasticInOut;
+
+Object.defineProperty(exports, '__esModule', { value: true });
+
+})));
+
+},{}],33:[function(require,module,exports){
+// https://d3js.org/d3-force/ Version 1.1.0. Copyright 2017 Mike Bostock.
+(function (global, factory) {
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('d3-quadtree'), require('d3-collection'), require('d3-dispatch'), require('d3-timer')) :
+ typeof define === 'function' && define.amd ? define(['exports', 'd3-quadtree', 'd3-collection', 'd3-dispatch', 'd3-timer'], factory) :
+ (factory((global.d3 = global.d3 || {}),global.d3,global.d3,global.d3,global.d3));
+}(this, (function (exports,d3Quadtree,d3Collection,d3Dispatch,d3Timer) { 'use strict';
+
+var center = function(x, y) {
+ var nodes;
+
+ 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, sy = sy / n - y, 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;
+ };
+
+ return force;
+};
+
+var constant = function(x) {
+ return function() {
+ return x;
+ };
+};
+
+var jiggle = function() {
+ return (Math.random() - 0.5) * 1e-6;
+};
+
+function x(d) {
+ return d.x + d.vx;
+}
+
+function y(d) {
+ return d.y + d.vy;
+}
+
+var collide = function(radius) {
+ var nodes,
+ radii,
+ strength = 1,
+ iterations = 1;
+
+ if (typeof radius !== "function") radius = constant(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 = d3Quadtree.quadtree(nodes, x, y).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(), l += x * x;
+ if (y === 0) y = jiggle(), 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 = _;
+ 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(+_), initialize(), force) : radius;
+ };
+
+ return force;
+};
+
+function index(d) {
+ return d.index;
+}
+
+function find(nodeById, nodeId) {
+ var node = nodeById.get(nodeId);
+ if (!node) throw new Error("missing: " + nodeId);
+ return node;
+}
+
+var link = function(links) {
+ var id = index,
+ strength = defaultStrength,
+ strengths,
+ distance = constant(30),
+ distances,
+ nodes,
+ count,
+ bias,
+ 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();
+ y = target.y + target.vy - source.y - source.vy || jiggle();
+ 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 = d3Collection.map(nodes, id),
+ 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 = _;
+ 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(+_), initializeStrength(), force) : strength;
+ };
+
+ force.distance = function(_) {
+ return arguments.length ? (distance = typeof _ === "function" ? _ : constant(+_), initializeDistance(), force) : distance;
+ };
+
+ return force;
+};
+
+function x$1(d) {
+ return d.x;
+}
+
+function y$1(d) {
+ return d.y;
+}
+
+var initialRadius = 10;
+var initialAngle = Math.PI * (3 - Math.sqrt(5));
+
+var simulation = function(nodes) {
+ var simulation,
+ alpha = 1,
+ alphaMin = 0.001,
+ alphaDecay = 1 - Math.pow(alphaMin, 1 / 300),
+ alphaTarget = 0,
+ velocityDecay = 0.6,
+ forces = d3Collection.map(),
+ stepper = d3Timer.timer(step),
+ event = d3Dispatch.dispatch("tick", "end");
+
+ if (nodes == null) nodes = [];
+
+ function step() {
+ tick();
+ event.call("tick", simulation);
+ if (alpha < alphaMin) {
+ stepper.stop();
+ event.call("end", simulation);
+ }
+ }
+
+ function tick() {
+ var i, n = nodes.length, node;
+
+ alpha += (alphaTarget - alpha) * alphaDecay;
+
+ forces.each(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;
+ }
+ }
+
+ function initializeNodes() {
+ for (var i = 0, n = nodes.length, node; i < n; ++i) {
+ node = nodes[i], node.index = i;
+ if (isNaN(node.x) || isNaN(node.y)) {
+ var radius = initialRadius * Math.sqrt(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);
+ 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.each(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;
+ },
+
+ force: function(name, _) {
+ return arguments.length > 1 ? ((_ == null ? forces.remove(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);
+ }
+ };
+};
+
+var manyBody = function() {
+ var nodes,
+ node,
+ alpha,
+ strength = constant(-30),
+ strengths,
+ distanceMin2 = 1,
+ distanceMax2 = Infinity,
+ theta2 = 0.81;
+
+ function force(_) {
+ var i, n = nodes.length, tree = d3Quadtree.quadtree(nodes, x$1, y$1).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(), l += x * x;
+ if (y === 0) y = jiggle(), 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(), l += x * x;
+ if (y === 0) y = jiggle(), 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 = _;
+ initialize();
+ };
+
+ force.strength = function(_) {
+ return arguments.length ? (strength = typeof _ === "function" ? _ : constant(+_), 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;
+};
+
+var radial = function(radius, x, y) {
+ var nodes,
+ strength = constant(0.1),
+ strengths,
+ radiuses;
+
+ if (typeof radius !== "function") radius = constant(+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(+_), initialize(), force) : strength;
+ };
+
+ force.radius = function(_) {
+ return arguments.length ? (radius = typeof _ === "function" ? _ : constant(+_), initialize(), force) : radius;
+ };
+
+ force.x = function(_) {
+ return arguments.length ? (x = +_, force) : x;
+ };
+
+ force.y = function(_) {
+ return arguments.length ? (y = +_, force) : y;
+ };
+
+ return force;
+};
+
+var x$2 = function(x) {
+ var strength = constant(0.1),
+ nodes,
+ strengths,
+ xz;
+
+ if (typeof x !== "function") x = constant(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(+_), initialize(), force) : strength;
+ };
+
+ force.x = function(_) {
+ return arguments.length ? (x = typeof _ === "function" ? _ : constant(+_), initialize(), force) : x;
+ };
+
+ return force;
+};
+
+var y$2 = function(y) {
+ var strength = constant(0.1),
+ nodes,
+ strengths,
+ yz;
+
+ if (typeof y !== "function") y = constant(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(+_), initialize(), force) : strength;
+ };
+
+ force.y = function(_) {
+ return arguments.length ? (y = typeof _ === "function" ? _ : constant(+_), initialize(), force) : y;
+ };
+
+ return force;
+};
+
+exports.forceCenter = center;
+exports.forceCollide = collide;
+exports.forceLink = link;
+exports.forceManyBody = manyBody;
+exports.forceRadial = radial;
+exports.forceSimulation = simulation;
+exports.forceX = x$2;
+exports.forceY = y$2;
+
+Object.defineProperty(exports, '__esModule', { value: true });
+
+})));
+
+},{"d3-collection":27,"d3-dispatch":29,"d3-quadtree":40,"d3-timer":49}],34:[function(require,module,exports){
+// https://d3js.org/d3-format/ Version 1.2.2. Copyright 2018 Mike Bostock.
+(function (global, factory) {
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
+ typeof define === 'function' && define.amd ? define(['exports'], factory) :
+ (factory((global.d3 = global.d3 || {})));
+}(this, (function (exports) { 'use strict';
+
+// 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, formatDecimal(1.23) returns ["123", 0].
+var formatDecimal = function(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)
+ ];
+};
+
+var exponent = function(x) {
+ return x = formatDecimal(Math.abs(x)), x ? x[1] : NaN;
+};
+
+var formatGroup = function(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);
+ };
+};
+
+var formatNumerals = function(numerals) {
+ return function(value) {
+ return value.replace(/[0-9]/g, function(i) {
+ return numerals[+i];
+ });
+ };
+};
+
+var formatDefault = function(x, p) {
+ x = x.toPrecision(p);
+
+ out: for (var n = x.length, i = 1, i0 = -1, i1; i < n; ++i) {
+ switch (x[i]) {
+ case ".": i0 = i1 = i; break;
+ case "0": if (i0 === 0) i0 = i; i1 = i; break;
+ case "e": break out;
+ default: if (i0 > 0) i0 = 0; break;
+ }
+ }
+
+ return i0 > 0 ? x.slice(0, i0) + x.slice(i1 + 1) : x;
+};
+
+var prefixExponent;
+
+var formatPrefixAuto = function(x, p) {
+ var d = formatDecimal(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") + formatDecimal(x, Math.max(0, p + i - 1))[0]; // less than 1y!
+};
+
+var formatRounded = function(x, p) {
+ var d = formatDecimal(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 = {
+ "": formatDefault,
+ "%": function(x, p) { return (x * 100).toFixed(p); },
+ "b": function(x) { return Math.round(x).toString(2); },
+ "c": function(x) { return x + ""; },
+ "d": function(x) { return Math.round(x).toString(10); },
+ "e": function(x, p) { return x.toExponential(p); },
+ "f": function(x, p) { return x.toFixed(p); },
+ "g": function(x, p) { return x.toPrecision(p); },
+ "o": function(x) { return Math.round(x).toString(8); },
+ "p": function(x, p) { return formatRounded(x * 100, p); },
+ "r": formatRounded,
+ "s": formatPrefixAuto,
+ "X": function(x) { return Math.round(x).toString(16).toUpperCase(); },
+ "x": function(x) { return Math.round(x).toString(16); }
+};
+
+// [[fill]align][sign][symbol][0][width][,][.precision][type]
+var re = /^(?:(.)?([<>=^]))?([+\-\( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?([a-z%])?$/i;
+
+function formatSpecifier(specifier) {
+ return new FormatSpecifier(specifier);
+}
+
+formatSpecifier.prototype = FormatSpecifier.prototype; // instanceof
+
+function FormatSpecifier(specifier) {
+ if (!(match = re.exec(specifier))) throw new Error("invalid format: " + specifier);
+
+ var match,
+ fill = match[1] || " ",
+ align = match[2] || ">",
+ sign = match[3] || "-",
+ symbol = match[4] || "",
+ zero = !!match[5],
+ width = match[6] && +match[6],
+ comma = !!match[7],
+ precision = match[8] && +match[8].slice(1),
+ type = match[9] || "";
+
+ // The "n" type is an alias for ",g".
+ if (type === "n") comma = true, type = "g";
+
+ // Map invalid types to the default format.
+ else if (!formatTypes[type]) type = "";
+
+ // If zero fill is specified, padding goes after sign and before digits.
+ if (zero || (fill === "0" && align === "=")) zero = true, fill = "0", align = "=";
+
+ this.fill = fill;
+ this.align = align;
+ this.sign = sign;
+ this.symbol = symbol;
+ this.zero = zero;
+ this.width = width;
+ this.comma = comma;
+ this.precision = precision;
+ this.type = type;
+}
+
+FormatSpecifier.prototype.toString = function() {
+ return this.fill
+ + this.align
+ + this.sign
+ + this.symbol
+ + (this.zero ? "0" : "")
+ + (this.width == null ? "" : Math.max(1, this.width | 0))
+ + (this.comma ? "," : "")
+ + (this.precision == null ? "" : "." + Math.max(0, this.precision | 0))
+ + this.type;
+};
+
+var identity = function(x) {
+ return x;
+};
+
+var prefixes = ["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];
+
+var formatLocale = function(locale) {
+ var group = locale.grouping && locale.thousands ? formatGroup(locale.grouping, locale.thousands) : identity,
+ currency = locale.currency,
+ decimal = locale.decimal,
+ numerals = locale.numerals ? formatNumerals(locale.numerals) : identity,
+ percent = locale.percent || "%";
+
+ 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,
+ type = specifier.type;
+
+ // Compute the prefix and suffix.
+ // For SI-prefix, the suffix is lazily computed.
+ var prefix = symbol === "$" ? currency[0] : symbol === "#" && /[boxX]/.test(type) ? "0" + type.toLowerCase() : "",
+ suffix = symbol === "$" ? currency[1] : /[%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 = !type || /[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 == null ? (type ? 6 : 12)
+ : /[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;
+
+ // Perform the initial formatting.
+ var valueNegative = value < 0;
+ value = formatType(Math.abs(value), precision);
+
+ // If a negative value rounds to zero during formatting, treat as positive.
+ if (valueNegative && +value === 0) valueNegative = false;
+
+ // Compute the prefix and suffix.
+ valuePrefix = (valueNegative ? (sign === "(" ? sign : "-") : 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;
+
+
+
+defaultLocale({
+ decimal: ".",
+ thousands: ",",
+ grouping: [3],
+ currency: ["$", ""]
+});
+
+function defaultLocale(definition) {
+ locale = formatLocale(definition);
+ exports.format = locale.format;
+ exports.formatPrefix = locale.formatPrefix;
+ return locale;
+}
+
+var precisionFixed = function(step) {
+ return Math.max(0, -exponent(Math.abs(step)));
+};
+
+var precisionPrefix = function(step, value) {
+ return Math.max(0, Math.max(-8, Math.min(8, Math.floor(exponent(value) / 3))) * 3 - exponent(Math.abs(step)));
+};
+
+var precisionRound = function(step, max) {
+ step = Math.abs(step), max = Math.abs(max) - step;
+ return Math.max(0, exponent(max) - exponent(step)) + 1;
+};
+
+exports.formatDefaultLocale = defaultLocale;
+exports.formatLocale = formatLocale;
+exports.formatSpecifier = formatSpecifier;
+exports.precisionFixed = precisionFixed;
+exports.precisionPrefix = precisionPrefix;
+exports.precisionRound = precisionRound;
+
+Object.defineProperty(exports, '__esModule', { value: true });
+
+})));
+
+},{}],35:[function(require,module,exports){
+// https://d3js.org/d3-geo/ Version 1.9.1. Copyright 2017 Mike Bostock.
+(function (global, factory) {
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('d3-array')) :
+ typeof define === 'function' && define.amd ? define(['exports', 'd3-array'], factory) :
+ (factory((global.d3 = global.d3 || {}),global.d3));
+}(this, (function (exports,d3Array) { 'use strict';
+
+// Adds floating point numbers with twice the normal precision.
+// Reference: J. R. Shewchuk, Adaptive Precision Floating-Point Arithmetic and
+// Fast Robust Geometric Predicates, Discrete & Computational Geometry 18(3)
+// 305–363 (1997).
+// Code adapted from GeographicLib by Charles F. F. Karney,
+// http://geographiclib.sourceforge.net/
+
+var adder = function() {
+ return new Adder;
+};
+
+function Adder() {
+ this.reset();
+}
+
+Adder.prototype = {
+ constructor: Adder,
+ reset: function() {
+ this.s = // rounded value
+ this.t = 0; // exact error
+ },
+ add: function(y) {
+ add(temp, y, this.t);
+ add(this, temp.s, this.s);
+ if (this.s) this.t += temp.t;
+ else this.s = temp.t;
+ },
+ valueOf: function() {
+ return this.s;
+ }
+};
+
+var temp = new Adder;
+
+function add(adder, a, b) {
+ var x = adder.s = a + b,
+ bv = x - a,
+ av = x - bv;
+ adder.t = (a - av) + (b - bv);
+}
+
+var epsilon = 1e-6;
+var epsilon2 = 1e-12;
+var pi = Math.PI;
+var halfPi = pi / 2;
+var quarterPi = pi / 4;
+var tau = pi * 2;
+
+var degrees = 180 / pi;
+var radians = pi / 180;
+
+var abs = Math.abs;
+var atan = Math.atan;
+var atan2 = Math.atan2;
+var cos = Math.cos;
+var ceil = Math.ceil;
+var exp = Math.exp;
+
+var log = Math.log;
+var pow = Math.pow;
+var sin = Math.sin;
+var sign = Math.sign || function(x) { return x > 0 ? 1 : x < 0 ? -1 : 0; };
+var sqrt = Math.sqrt;
+var tan = Math.tan;
+
+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 haversin(x) {
+ return (x = sin(x / 2)) * x;
+}
+
+function noop() {}
+
+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();
+}
+
+var geoStream = function(object, stream) {
+ if (object && streamObjectType.hasOwnProperty(object.type)) {
+ streamObjectType[object.type](object, stream);
+ } else {
+ streamGeometry(object, stream);
+ }
+};
+
+var areaRingSum = adder();
+
+var areaSum = adder();
+var lambda00;
+var phi00;
+var lambda0;
+var cosPhi0;
+var sinPhi0;
+
+var areaStream = {
+ point: noop,
+ lineStart: noop,
+ lineEnd: noop,
+ polygonStart: function() {
+ areaRingSum.reset();
+ areaStream.lineStart = areaRingStart;
+ areaStream.lineEnd = areaRingEnd;
+ },
+ polygonEnd: function() {
+ var areaRing = +areaRingSum;
+ areaSum.add(areaRing < 0 ? tau + areaRing : areaRing);
+ this.lineStart = this.lineEnd = this.point = noop;
+ },
+ sphere: function() {
+ areaSum.add(tau);
+ }
+};
+
+function areaRingStart() {
+ areaStream.point = areaPointFirst;
+}
+
+function areaRingEnd() {
+ areaPoint(lambda00, phi00);
+}
+
+function areaPointFirst(lambda, phi) {
+ areaStream.point = areaPoint;
+ lambda00 = lambda, phi00 = phi;
+ lambda *= radians, phi *= radians;
+ lambda0 = lambda, cosPhi0 = cos(phi = phi / 2 + quarterPi), sinPhi0 = sin(phi);
+}
+
+function areaPoint(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,
+ sdLambda = dLambda >= 0 ? 1 : -1,
+ adLambda = sdLambda * dLambda,
+ cosPhi = cos(phi),
+ sinPhi = sin(phi),
+ k = sinPhi0 * sinPhi,
+ u = cosPhi0 * cosPhi + k * cos(adLambda),
+ v = k * sdLambda * sin(adLambda);
+ areaRingSum.add(atan2(v, u));
+
+ // Advance the previous points.
+ lambda0 = lambda, cosPhi0 = cosPhi, sinPhi0 = sinPhi;
+}
+
+var area = function(object) {
+ areaSum.reset();
+ geoStream(object, areaStream);
+ return areaSum * 2;
+};
+
+function spherical(cartesian) {
+ return [atan2(cartesian[1], cartesian[0]), asin(cartesian[2])];
+}
+
+function cartesian(spherical) {
+ var lambda = spherical[0], phi = spherical[1], cosPhi = cos(phi);
+ return [cosPhi * cos(lambda), cosPhi * sin(lambda), sin(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(d[0] * d[0] + d[1] * d[1] + d[2] * d[2]);
+ d[0] /= l, d[1] /= l, d[2] /= l;
+}
+
+var lambda0$1;
+var phi0;
+var lambda1;
+var phi1;
+var lambda2;
+var lambda00$1;
+var phi00$1;
+var p0;
+var deltaSum = adder();
+var ranges;
+var range$1;
+
+var boundsStream = {
+ point: boundsPoint,
+ lineStart: boundsLineStart,
+ lineEnd: boundsLineEnd,
+ polygonStart: function() {
+ boundsStream.point = boundsRingPoint;
+ boundsStream.lineStart = boundsRingStart;
+ boundsStream.lineEnd = boundsRingEnd;
+ deltaSum.reset();
+ areaStream.polygonStart();
+ },
+ polygonEnd: function() {
+ areaStream.polygonEnd();
+ boundsStream.point = boundsPoint;
+ boundsStream.lineStart = boundsLineStart;
+ boundsStream.lineEnd = boundsLineEnd;
+ if (areaRingSum < 0) lambda0$1 = -(lambda1 = 180), phi0 = -(phi1 = 90);
+ else if (deltaSum > epsilon) phi1 = 90;
+ else if (deltaSum < -epsilon) phi0 = -90;
+ range$1[0] = lambda0$1, range$1[1] = lambda1;
+ }
+};
+
+function boundsPoint(lambda, phi) {
+ ranges.push(range$1 = [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$$1 = delta > 0 ? 1 : -1,
+ lambdai = inflection[0] * degrees * sign$$1,
+ phii,
+ antimeridian = abs(delta) > 180;
+ if (antimeridian ^ (sign$$1 * lambda2 < lambdai && lambdai < sign$$1 * lambda)) {
+ phii = inflection[1] * degrees;
+ if (phii > phi1) phi1 = phii;
+ } else if (lambdai = (lambdai + 360) % 360 - 180, antimeridian ^ (sign$$1 * lambda2 < lambdai && lambdai < sign$$1 * 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$1 = [lambda0$1 = lambda, lambda1 = lambda]);
+ }
+ if (phi < phi0) phi0 = phi;
+ if (phi > phi1) phi1 = phi;
+ p0 = p, lambda2 = lambda;
+}
+
+function boundsLineStart() {
+ boundsStream.point = linePoint;
+}
+
+function boundsLineEnd() {
+ range$1[0] = lambda0$1, range$1[1] = lambda1;
+ boundsStream.point = boundsPoint;
+ p0 = null;
+}
+
+function boundsRingPoint(lambda, phi) {
+ if (p0) {
+ var delta = lambda - lambda2;
+ deltaSum.add(abs(delta) > 180 ? delta + (delta > 0 ? 360 : -360) : delta);
+ } else {
+ lambda00$1 = lambda, phi00$1 = phi;
+ }
+ areaStream.point(lambda, phi);
+ linePoint(lambda, phi);
+}
+
+function boundsRingStart() {
+ areaStream.lineStart();
+}
+
+function boundsRingEnd() {
+ boundsRingPoint(lambda00$1, phi00$1);
+ areaStream.lineEnd();
+ if (abs(deltaSum) > epsilon) lambda0$1 = -(lambda1 = 180);
+ range$1[0] = lambda0$1, range$1[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$$1, x) {
+ return range$$1[0] <= range$$1[1] ? range$$1[0] <= x && x <= range$$1[1] : x < range$$1[0] || range$$1[1] < x;
+}
+
+var bounds = function(feature) {
+ var i, n, a, b, merged, deltaMax, delta;
+
+ phi1 = lambda1 = -(lambda0$1 = phi0 = Infinity);
+ ranges = [];
+ geoStream(feature, boundsStream);
+
+ // 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$1 = null;
+
+ return lambda0$1 === Infinity || phi0 === Infinity
+ ? [[NaN, NaN], [NaN, NaN]]
+ : [[lambda0$1, phi0], [lambda1, phi1]];
+};
+
+var W0;
+var W1;
+var X0;
+var Y0;
+var Z0;
+var X1;
+var Y1;
+var Z1;
+var X2;
+var Y2;
+var Z2;
+var lambda00$2;
+var phi00$2;
+var x0;
+var y0;
+var z0; // previous point
+
+var centroidStream = {
+ sphere: noop,
+ point: centroidPoint,
+ lineStart: centroidLineStart,
+ lineEnd: centroidLineEnd,
+ polygonStart: function() {
+ centroidStream.lineStart = centroidRingStart;
+ centroidStream.lineEnd = centroidRingEnd;
+ },
+ polygonEnd: function() {
+ centroidStream.lineStart = centroidLineStart;
+ centroidStream.lineEnd = centroidLineEnd;
+ }
+};
+
+// Arithmetic mean of Cartesian vectors.
+function centroidPoint(lambda, phi) {
+ lambda *= radians, phi *= radians;
+ var cosPhi = cos(phi);
+ centroidPointCartesian(cosPhi * cos(lambda), cosPhi * sin(lambda), sin(phi));
+}
+
+function centroidPointCartesian(x, y, z) {
+ ++W0;
+ X0 += (x - X0) / W0;
+ Y0 += (y - Y0) / W0;
+ Z0 += (z - Z0) / W0;
+}
+
+function centroidLineStart() {
+ centroidStream.point = centroidLinePointFirst;
+}
+
+function centroidLinePointFirst(lambda, phi) {
+ lambda *= radians, phi *= radians;
+ var cosPhi = cos(phi);
+ x0 = cosPhi * cos(lambda);
+ y0 = cosPhi * sin(lambda);
+ z0 = sin(phi);
+ centroidStream.point = centroidLinePoint;
+ centroidPointCartesian(x0, y0, z0);
+}
+
+function centroidLinePoint(lambda, phi) {
+ lambda *= radians, phi *= radians;
+ var cosPhi = cos(phi),
+ x = cosPhi * cos(lambda),
+ y = cosPhi * sin(lambda),
+ z = sin(phi),
+ w = atan2(sqrt((w = y0 * z - z0 * y) * w + (w = z0 * x - x0 * z) * w + (w = x0 * y - y0 * x) * w), x0 * x + y0 * y + z0 * z);
+ W1 += w;
+ X1 += w * (x0 + (x0 = x));
+ Y1 += w * (y0 + (y0 = y));
+ Z1 += w * (z0 + (z0 = z));
+ centroidPointCartesian(x0, y0, z0);
+}
+
+function centroidLineEnd() {
+ centroidStream.point = centroidPoint;
+}
+
+// See J. E. Brock, The Inertia Tensor for a Spherical Triangle,
+// J. Applied Mechanics 42, 239 (1975).
+function centroidRingStart() {
+ centroidStream.point = centroidRingPointFirst;
+}
+
+function centroidRingEnd() {
+ centroidRingPoint(lambda00$2, phi00$2);
+ centroidStream.point = centroidPoint;
+}
+
+function centroidRingPointFirst(lambda, phi) {
+ lambda00$2 = lambda, phi00$2 = phi;
+ lambda *= radians, phi *= radians;
+ centroidStream.point = centroidRingPoint;
+ var cosPhi = cos(phi);
+ x0 = cosPhi * cos(lambda);
+ y0 = cosPhi * sin(lambda);
+ z0 = sin(phi);
+ centroidPointCartesian(x0, y0, z0);
+}
+
+function centroidRingPoint(lambda, phi) {
+ lambda *= radians, phi *= radians;
+ var cosPhi = cos(phi),
+ x = cosPhi * cos(lambda),
+ y = cosPhi * sin(lambda),
+ z = sin(phi),
+ cx = y0 * z - z0 * y,
+ cy = z0 * x - x0 * z,
+ cz = x0 * y - y0 * x,
+ m = sqrt(cx * cx + cy * cy + cz * cz),
+ w = asin(m), // line weight = angle
+ v = m && -w / m; // area weight multiplier
+ X2 += v * cx;
+ Y2 += v * cy;
+ Z2 += v * cz;
+ W1 += w;
+ X1 += w * (x0 + (x0 = x));
+ Y1 += w * (y0 + (y0 = y));
+ Z1 += w * (z0 + (z0 = z));
+ centroidPointCartesian(x0, y0, z0);
+}
+
+var centroid = function(object) {
+ W0 = W1 =
+ X0 = Y0 = Z0 =
+ X1 = Y1 = Z1 =
+ X2 = Y2 = Z2 = 0;
+ geoStream(object, centroidStream);
+
+ var x = X2,
+ y = Y2,
+ z = Z2,
+ m = x * x + y * y + z * z;
+
+ // If the area-weighted ccentroid is undefined, fall back to length-weighted ccentroid.
+ if (m < epsilon2) {
+ x = X1, y = Y1, z = Z1;
+ // If the feature has zero length, fall back to arithmetic mean of point vectors.
+ if (W1 < epsilon) x = X0, y = Y0, z = Z0;
+ m = x * x + y * y + z * z;
+ // If the feature still has an undefined ccentroid, then return.
+ if (m < epsilon2) return [NaN, NaN];
+ }
+
+ return [atan2(y, x) * degrees, asin(z / sqrt(m)) * degrees];
+};
+
+var constant = function(x) {
+ return function() {
+ return x;
+ };
+};
+
+var compose = function(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 [lambda > pi ? lambda - tau : lambda < -pi ? lambda + tau : lambda, phi];
+}
+
+rotationIdentity.invert = rotationIdentity;
+
+function rotateRadians(deltaLambda, deltaPhi, deltaGamma) {
+ return (deltaLambda %= tau) ? (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 ? lambda - tau : lambda < -pi ? lambda + tau : lambda, phi];
+ };
+}
+
+function rotationLambda(deltaLambda) {
+ var rotation = forwardRotationLambda(deltaLambda);
+ rotation.invert = forwardRotationLambda(-deltaLambda);
+ return rotation;
+}
+
+function rotationPhiGamma(deltaPhi, deltaGamma) {
+ var cosDeltaPhi = cos(deltaPhi),
+ sinDeltaPhi = sin(deltaPhi),
+ cosDeltaGamma = cos(deltaGamma),
+ sinDeltaGamma = sin(deltaGamma);
+
+ function rotation(lambda, phi) {
+ var cosPhi = cos(phi),
+ x = cos(lambda) * cosPhi,
+ y = sin(lambda) * cosPhi,
+ z = sin(phi),
+ k = z * cosDeltaPhi + x * sinDeltaPhi;
+ return [
+ atan2(y * cosDeltaGamma - k * sinDeltaGamma, x * cosDeltaPhi - z * sinDeltaPhi),
+ asin(k * cosDeltaGamma + y * sinDeltaGamma)
+ ];
+ }
+
+ rotation.invert = function(lambda, phi) {
+ var cosPhi = cos(phi),
+ x = cos(lambda) * cosPhi,
+ y = sin(lambda) * cosPhi,
+ z = sin(phi),
+ k = z * cosDeltaGamma - y * sinDeltaGamma;
+ return [
+ atan2(y * cosDeltaGamma + z * sinDeltaGamma, x * cosDeltaPhi + k * sinDeltaPhi),
+ asin(k * cosDeltaPhi - x * sinDeltaPhi)
+ ];
+ };
+
+ return rotation;
+}
+
+var rotation = function(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(radius),
+ sinRadius = sin(radius),
+ step = direction * delta;
+ if (t0 == null) {
+ t0 = radius + direction * tau;
+ t1 = radius - step / 2;
+ } else {
+ t0 = circleRadius(cosRadius, t0);
+ t1 = circleRadius(cosRadius, t1);
+ if (direction > 0 ? t0 < t1 : t0 > t1) t0 += direction * tau;
+ }
+ for (var point, t = t0; direction > 0 ? t > t1 : t < t1; t -= step) {
+ point = spherical([cosRadius, -sinRadius * cos(t), -sinRadius * sin(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(-point[1]);
+ return ((-point[2] < 0 ? -radius : radius) + tau - epsilon) % tau;
+}
+
+var circle = function() {
+ var center = constant([0, 0]),
+ radius = constant(90),
+ precision = constant(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([+_[0], +_[1]]), circle) : center;
+ };
+
+ circle.radius = function(_) {
+ return arguments.length ? (radius = typeof _ === "function" ? _ : constant(+_), circle) : radius;
+ };
+
+ circle.precision = function(_) {
+ return arguments.length ? (precision = typeof _ === "function" ? _ : constant(+_), circle) : precision;
+ };
+
+ return circle;
+};
+
+var clipBuffer = function() {
+ var lines = [],
+ line;
+ return {
+ point: function(x, y) {
+ line.push([x, y]);
+ },
+ lineStart: function() {
+ lines.push(line = []);
+ },
+ lineEnd: noop,
+ rejoin: function() {
+ if (lines.length > 1) lines.push(lines.pop().concat(lines.shift()));
+ },
+ result: function() {
+ var result = lines;
+ lines = [];
+ line = null;
+ return result;
+ }
+ };
+};
+
+var pointEqual = function(a, b) {
+ return abs(a[0] - b[0]) < epsilon && abs(a[1] - b[1]) < epsilon;
+};
+
+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.
+var clipRejoin = function(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 the first and last points of a segment are coincident, then treat as a
+ // closed ring. TODO if all rings are closed, then the winding order of the
+ // exterior ring should be checked.
+ if (pointEqual(p0, p1)) {
+ stream.lineStart();
+ for (i = 0; i < n; ++i) stream.point((p0 = segment[i])[0], p0[1]);
+ stream.lineEnd();
+ return;
+ }
+
+ 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(subject);
+ link(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(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;
+}
+
+var sum = adder();
+
+var polygonContains = function(polygon, point) {
+ var lambda = point[0],
+ phi = point[1],
+ normal = [sin(lambda), -cos(lambda), 0],
+ angle = 0,
+ winding = 0;
+
+ sum.reset();
+
+ 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 = point0[0],
+ phi0 = point0[1] / 2 + quarterPi,
+ sinPhi0 = sin(phi0),
+ cosPhi0 = cos(phi0);
+
+ for (var j = 0; j < m; ++j, lambda0 = lambda1, sinPhi0 = sinPhi1, cosPhi0 = cosPhi1, point0 = point1) {
+ var point1 = ring[j],
+ lambda1 = point1[0],
+ phi1 = point1[1] / 2 + quarterPi,
+ sinPhi1 = sin(phi1),
+ cosPhi1 = cos(phi1),
+ delta = lambda1 - lambda0,
+ sign$$1 = delta >= 0 ? 1 : -1,
+ absDelta = sign$$1 * delta,
+ antimeridian = absDelta > pi,
+ k = sinPhi0 * sinPhi1;
+
+ sum.add(atan2(k * sign$$1 * sin(absDelta), cosPhi0 * cosPhi1 + k * cos(absDelta)));
+ angle += antimeridian ? delta + sign$$1 * tau : 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(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 || angle < epsilon && sum < -epsilon) ^ (winding & 1);
+};
+
+var clip = function(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 = d3Array.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 - epsilon : halfPi - a[1])
+ - ((b = b.x)[0] < 0 ? b[1] - halfPi - epsilon : halfPi - b[1]);
+}
+
+var clipAntimeridian = clip(
+ function() { return true; },
+ clipAntimeridianLine,
+ clipAntimeridianInterpolate,
+ [-pi, -halfPi]
+);
+
+// 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 : -pi,
+ delta = abs(lambda1 - lambda0);
+ if (abs(delta - pi) < epsilon) { // line crosses a pole
+ stream.point(lambda0, phi0 = (phi0 + phi1) / 2 > 0 ? halfPi : -halfPi);
+ stream.point(sign0, phi0);
+ stream.lineEnd();
+ stream.lineStart();
+ stream.point(sign1, phi0);
+ stream.point(lambda1, phi0);
+ clean = 0;
+ } else if (sign0 !== sign1 && delta >= pi) { // line crosses antimeridian
+ if (abs(lambda0 - sign0) < epsilon) lambda0 -= sign0 * epsilon; // handle degeneracies
+ if (abs(lambda1 - sign1) < epsilon) lambda1 -= sign1 * epsilon;
+ 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(lambda0 - lambda1);
+ return abs(sinLambda0Lambda1) > epsilon
+ ? atan((sin(phi0) * (cosPhi1 = cos(phi1)) * sin(lambda1)
+ - sin(phi1) * (cosPhi0 = cos(phi0)) * sin(lambda0))
+ / (cosPhi0 * cosPhi1 * sinLambda0Lambda1))
+ : (phi0 + phi1) / 2;
+}
+
+function clipAntimeridianInterpolate(from, to, direction, stream) {
+ var phi;
+ if (from == null) {
+ phi = direction * halfPi;
+ stream.point(-pi, phi);
+ stream.point(0, phi);
+ stream.point(pi, phi);
+ stream.point(pi, 0);
+ stream.point(pi, -phi);
+ stream.point(0, -phi);
+ stream.point(-pi, -phi);
+ stream.point(-pi, 0);
+ stream.point(-pi, phi);
+ } else if (abs(from[0] - to[0]) > epsilon) {
+ var lambda = from[0] < to[0] ? pi : -pi;
+ phi = direction * lambda / 2;
+ stream.point(-lambda, phi);
+ stream.point(0, phi);
+ stream.point(lambda, phi);
+ } else {
+ stream.point(to[0], to[1]);
+ }
+}
+
+var clipCircle = function(radius) {
+ var cr = cos(radius),
+ delta = 6 * radians,
+ smallRadius = cr > 0,
+ notHemisphere = abs(cr) > epsilon; // 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(lambda) * cos(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 : -pi), phi) : 0;
+ if (!point0 && (v00 = v0 = v)) stream.lineStart();
+ // Handle degeneracies.
+ // TODO ignore if not clipping polygons.
+ if (v !== v0) {
+ point2 = intersect(point0, point1);
+ if (!point2 || pointEqual(point0, point2) || pointEqual(point1, point2)) {
+ point1[0] += epsilon;
+ point1[1] += epsilon;
+ v = visible(point1[0], point1[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]);
+ 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]);
+ }
+ }
+ }
+ 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(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(delta - pi) < epsilon,
+ meridian = polar || delta < epsilon;
+
+ 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(q[0] - lambda0) < epsilon ? phi0 : phi1)
+ : phi0 <= q[1] && q[1] <= phi1
+ : delta > pi ^ (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 - 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, radius - pi]);
+};
+
+var clipLine = function(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;
+var 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(p[0] - x0) < epsilon ? direction > 0 ? 0 : 3
+ : abs(p[0] - x1) < epsilon ? direction > 0 ? 2 : 1
+ : abs(p[1] - y0) < epsilon ? 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 = d3Array.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;
+ };
+}
+
+var extent = function() {
+ 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 = adder();
+var lambda0$2;
+var sinPhi0$1;
+var cosPhi0$1;
+
+var lengthStream = {
+ sphere: noop,
+ point: noop,
+ lineStart: lengthLineStart,
+ lineEnd: noop,
+ polygonStart: noop,
+ polygonEnd: noop
+};
+
+function lengthLineStart() {
+ lengthStream.point = lengthPointFirst;
+ lengthStream.lineEnd = lengthLineEnd;
+}
+
+function lengthLineEnd() {
+ lengthStream.point = lengthStream.lineEnd = noop;
+}
+
+function lengthPointFirst(lambda, phi) {
+ lambda *= radians, phi *= radians;
+ lambda0$2 = lambda, sinPhi0$1 = sin(phi), cosPhi0$1 = cos(phi);
+ lengthStream.point = lengthPoint;
+}
+
+function lengthPoint(lambda, phi) {
+ lambda *= radians, phi *= radians;
+ var sinPhi = sin(phi),
+ cosPhi = cos(phi),
+ delta = abs(lambda - lambda0$2),
+ cosDelta = cos(delta),
+ sinDelta = sin(delta),
+ x = cosPhi * sinDelta,
+ y = cosPhi0$1 * sinPhi - sinPhi0$1 * cosPhi * cosDelta,
+ z = sinPhi0$1 * sinPhi + cosPhi0$1 * cosPhi * cosDelta;
+ lengthSum.add(atan2(sqrt(x * x + y * y), z));
+ lambda0$2 = lambda, sinPhi0$1 = sinPhi, cosPhi0$1 = cosPhi;
+}
+
+var length = function(object) {
+ lengthSum.reset();
+ geoStream(object, lengthStream);
+ return +lengthSum;
+};
+
+var coordinates = [null, null];
+var object = {type: "LineString", coordinates: coordinates};
+
+var distance = function(a, b) {
+ coordinates[0] = a;
+ coordinates[1] = b;
+ return length(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 ab = distance(coordinates[0], coordinates[1]),
+ ao = distance(coordinates[0], point),
+ ob = distance(point, coordinates[1]);
+ return ao + ob <= ab + epsilon;
+}
+
+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];
+}
+
+var contains = function(object, point) {
+ return (object && containsObjectType.hasOwnProperty(object.type)
+ ? containsObjectType[object.type]
+ : containsGeometry)(object, point);
+};
+
+function graticuleX(y0, y1, dy) {
+ var y = d3Array.range(y0, y1 - epsilon, dy).concat(y1);
+ return function(x) { return y.map(function(y) { return [x, y]; }); };
+}
+
+function graticuleY(x0, x1, dx) {
+ var x = d3Array.range(x0, x1 - epsilon, 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 d3Array.range(ceil(X0 / DX) * DX, X1, DX).map(X)
+ .concat(d3Array.range(ceil(Y0 / DY) * DY, Y1, DY).map(Y))
+ .concat(d3Array.range(ceil(x0 / dx) * dx, x1, dx).filter(function(x) { return abs(x % DX) > epsilon; }).map(x))
+ .concat(d3Array.range(ceil(y0 / dy) * dy, y1, dy).filter(function(y) { return abs(y % DY) > epsilon; }).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], [180, 90 - epsilon]])
+ .extentMinor([[-180, -80 - epsilon], [180, 80 + epsilon]]);
+}
+
+function graticule10() {
+ return graticule()();
+}
+
+var interpolate = function(a, b) {
+ var x0 = a[0] * radians,
+ y0 = a[1] * radians,
+ x1 = b[0] * radians,
+ y1 = b[1] * radians,
+ cy0 = cos(y0),
+ sy0 = sin(y0),
+ cy1 = cos(y1),
+ sy1 = sin(y1),
+ kx0 = cy0 * cos(x0),
+ ky0 = cy0 * sin(x0),
+ kx1 = cy1 * cos(x1),
+ ky1 = cy1 * sin(x1),
+ d = 2 * asin(sqrt(haversin(y1 - y0) + cy0 * cy1 * haversin(x1 - x0))),
+ k = sin(d);
+
+ var interpolate = d ? function(t) {
+ var B = sin(t *= d) / k,
+ A = sin(d - t) / k,
+ x = A * kx0 + B * kx1,
+ y = A * ky0 + B * ky1,
+ z = A * sy0 + B * sy1;
+ return [
+ atan2(y, x) * degrees,
+ atan2(z, sqrt(x * x + y * y)) * degrees
+ ];
+ } : function() {
+ return [x0 * degrees, y0 * degrees];
+ };
+
+ interpolate.distance = d;
+
+ return interpolate;
+};
+
+var identity = function(x) {
+ return x;
+};
+
+var areaSum$1 = adder();
+var areaRingSum$1 = adder();
+var x00;
+var y00;
+var x0$1;
+var y0$1;
+
+var areaStream$1 = {
+ point: noop,
+ lineStart: noop,
+ lineEnd: noop,
+ polygonStart: function() {
+ areaStream$1.lineStart = areaRingStart$1;
+ areaStream$1.lineEnd = areaRingEnd$1;
+ },
+ polygonEnd: function() {
+ areaStream$1.lineStart = areaStream$1.lineEnd = areaStream$1.point = noop;
+ areaSum$1.add(abs(areaRingSum$1));
+ areaRingSum$1.reset();
+ },
+ result: function() {
+ var area = areaSum$1 / 2;
+ areaSum$1.reset();
+ return area;
+ }
+};
+
+function areaRingStart$1() {
+ areaStream$1.point = areaPointFirst$1;
+}
+
+function areaPointFirst$1(x, y) {
+ areaStream$1.point = areaPoint$1;
+ x00 = x0$1 = x, y00 = y0$1 = y;
+}
+
+function areaPoint$1(x, y) {
+ areaRingSum$1.add(y0$1 * x - x0$1 * y);
+ x0$1 = x, y0$1 = y;
+}
+
+function areaRingEnd$1() {
+ areaPoint$1(x00, y00);
+}
+
+var x0$2 = Infinity;
+var y0$2 = x0$2;
+var x1 = -x0$2;
+var y1 = x1;
+
+var boundsStream$1 = {
+ point: boundsPoint$1,
+ lineStart: noop,
+ lineEnd: noop,
+ polygonStart: noop,
+ polygonEnd: noop,
+ result: function() {
+ var bounds = [[x0$2, y0$2], [x1, y1]];
+ x1 = y1 = -(y0$2 = x0$2 = Infinity);
+ return bounds;
+ }
+};
+
+function boundsPoint$1(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;
+}
+
+// TODO Enforce positive area for exterior, negative area for interior?
+
+var X0$1 = 0;
+var Y0$1 = 0;
+var Z0$1 = 0;
+var X1$1 = 0;
+var Y1$1 = 0;
+var Z1$1 = 0;
+var X2$1 = 0;
+var Y2$1 = 0;
+var Z2$1 = 0;
+var x00$1;
+var y00$1;
+var x0$3;
+var y0$3;
+
+var centroidStream$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.point = centroidPoint$1;
+ centroidStream$1.lineStart = centroidLineStart$1;
+ centroidStream$1.lineEnd = centroidLineEnd$1;
+ },
+ result: function() {
+ var centroid = Z2$1 ? [X2$1 / Z2$1, Y2$1 / Z2$1]
+ : Z1$1 ? [X1$1 / Z1$1, Y1$1 / Z1$1]
+ : Z0$1 ? [X0$1 / Z0$1, Y0$1 / Z0$1]
+ : [NaN, NaN];
+ X0$1 = Y0$1 = Z0$1 =
+ X1$1 = Y1$1 = Z1$1 =
+ X2$1 = Y2$1 = Z2$1 = 0;
+ return centroid;
+ }
+};
+
+function centroidPoint$1(x, y) {
+ X0$1 += x;
+ Y0$1 += y;
+ ++Z0$1;
+}
+
+function centroidLineStart$1() {
+ centroidStream$1.point = centroidPointFirstLine;
+}
+
+function centroidPointFirstLine(x, y) {
+ centroidStream$1.point = centroidPointLine;
+ centroidPoint$1(x0$3 = x, y0$3 = y);
+}
+
+function centroidPointLine(x, y) {
+ var dx = x - x0$3, dy = y - y0$3, z = sqrt(dx * dx + dy * dy);
+ X1$1 += z * (x0$3 + x) / 2;
+ Y1$1 += z * (y0$3 + y) / 2;
+ Z1$1 += z;
+ centroidPoint$1(x0$3 = x, y0$3 = y);
+}
+
+function centroidLineEnd$1() {
+ centroidStream$1.point = centroidPoint$1;
+}
+
+function centroidRingStart$1() {
+ centroidStream$1.point = centroidPointFirstRing;
+}
+
+function centroidRingEnd$1() {
+ centroidPointRing(x00$1, y00$1);
+}
+
+function centroidPointFirstRing(x, y) {
+ centroidStream$1.point = centroidPointRing;
+ centroidPoint$1(x00$1 = x0$3 = x, y00$1 = y0$3 = y);
+}
+
+function centroidPointRing(x, y) {
+ var dx = x - x0$3,
+ dy = y - y0$3,
+ z = sqrt(dx * dx + dy * dy);
+
+ X1$1 += z * (x0$3 + x) / 2;
+ Y1$1 += z * (y0$3 + y) / 2;
+ Z1$1 += z;
+
+ z = y0$3 * x - x0$3 * y;
+ X2$1 += z * (x0$3 + x);
+ Y2$1 += z * (y0$3 + y);
+ Z2$1 += z * 3;
+ centroidPoint$1(x0$3 = x, y0$3 = y);
+}
+
+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);
+ break;
+ }
+ }
+ },
+ result: noop
+};
+
+var lengthSum$1 = adder();
+var lengthRing;
+var x00$2;
+var y00$2;
+var x0$4;
+var y0$4;
+
+var lengthStream$1 = {
+ point: noop,
+ lineStart: function() {
+ lengthStream$1.point = lengthPointFirst$1;
+ },
+ lineEnd: function() {
+ if (lengthRing) lengthPoint$1(x00$2, y00$2);
+ lengthStream$1.point = noop;
+ },
+ polygonStart: function() {
+ lengthRing = true;
+ },
+ polygonEnd: function() {
+ lengthRing = null;
+ },
+ result: function() {
+ var length = +lengthSum$1;
+ lengthSum$1.reset();
+ return length;
+ }
+};
+
+function lengthPointFirst$1(x, y) {
+ lengthStream$1.point = lengthPoint$1;
+ x00$2 = x0$4 = x, y00$2 = y0$4 = y;
+}
+
+function lengthPoint$1(x, y) {
+ x0$4 -= x, y0$4 -= y;
+ lengthSum$1.add(sqrt(x0$4 * x0$4 + y0$4 * y0$4));
+ x0$4 = x, y0$4 = y;
+}
+
+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";
+}
+
+var index = function(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(areaStream$1));
+ return areaStream$1.result();
+ };
+
+ path.measure = function(object) {
+ geoStream(object, projectionStream(lengthStream$1));
+ return lengthStream$1.result();
+ };
+
+ path.bounds = function(object) {
+ geoStream(object, projectionStream(boundsStream$1));
+ return boundsStream$1.result();
+ };
+
+ path.centroid = function(object) {
+ geoStream(object, projectionStream(centroidStream$1));
+ return centroidStream$1.result();
+ };
+
+ path.projection = function(_) {
+ return arguments.length ? (projectionStream = _ == null ? (projection = null, identity) : (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);
+};
+
+var transform = function(methods) {
+ return {
+ stream: transformer(methods)
+ };
+};
+
+function transformer(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;
+var cosMinDistance = cos(30 * radians); // cos(minimum angular distance)
+
+var resample = function(project, delta2) {
+ return +delta2 ? resample$1(project, delta2) : resampleNone(project);
+};
+
+function resampleNone(project) {
+ return transformer({
+ 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(a * a + b * b + c * c),
+ phi2 = asin(c /= m),
+ lambda2 = abs(abs(c) - 1) < epsilon || abs(lambda0 - lambda1) < epsilon ? (lambda0 + lambda1) / 2 : atan2(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((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({
+ point: function(x, y) {
+ this.stream.point(x * radians, y * radians);
+ }
+});
+
+function transformRotate(rotate) {
+ return transformer({
+ point: function(x, y) {
+ var r = rotate(x, y);
+ return this.stream.point(r[0], r[1]);
+ }
+ });
+}
+
+function projection(project) {
+ return projectionMutator(function() { return project; })();
+}
+
+function projectionMutator(projectAt) {
+ var project,
+ k = 150, // scale
+ x = 480, y = 250, // translate
+ dx, dy, lambda = 0, phi = 0, // center
+ deltaLambda = 0, deltaPhi = 0, deltaGamma = 0, rotate, projectRotate, // rotate
+ theta = null, preclip = clipAntimeridian, // clip angle
+ x0 = null, y0, x1, y1, postclip = identity, // clip extent
+ delta2 = 0.5, projectResample = resample(projectTransform, delta2), // precision
+ cache,
+ cacheStream;
+
+ function projection(point) {
+ point = projectRotate(point[0] * radians, point[1] * radians);
+ return [point[0] * k + dx, dy - point[1] * k];
+ }
+
+ function invert(point) {
+ point = projectRotate.invert((point[0] - dx) / k, (dy - point[1]) / k);
+ return point && [point[0] * degrees, point[1] * degrees];
+ }
+
+ function projectTransform(x, y) {
+ return x = project(x, y), [x[0] * k + dx, dy - x[1] * k];
+ }
+
+ 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) : 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.precision = function(_) {
+ return arguments.length ? (projectResample = resample(projectTransform, delta2 = _ * _), reset()) : sqrt(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() {
+ projectRotate = compose(rotate = rotateRadians(deltaLambda, deltaPhi, deltaGamma), project);
+ var center = project(lambda, phi);
+ dx = x - center[0] * k;
+ dy = y + center[1] * k;
+ 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 / 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(phi0);
+
+ function forward(lambda, phi) {
+ return [lambda * cosPhi0, sin(phi) / cosPhi0];
+ }
+
+ forward.invert = function(x, y) {
+ return [x / cosPhi0, asin(y * cosPhi0)];
+ };
+
+ return forward;
+}
+
+function conicEqualAreaRaw(y0, y1) {
+ var sy0 = sin(y0), n = (sy0 + sin(y1)) / 2;
+
+ // Are the parallels symmetrical around the Equator?
+ if (abs(n) < epsilon) return cylindricalEqualAreaRaw(y0);
+
+ var c = 1 + sy0 * (2 * n - sy0), r0 = sqrt(c) / n;
+
+ function project(x, y) {
+ var r = sqrt(c - 2 * n * sin(y)) / n;
+ return [r * sin(x *= n), r0 - r * cos(x)];
+ }
+
+ project.invert = function(x, y) {
+ var r0y = r0 - y;
+ return [atan2(x, abs(r0y)) / n * sign(r0y), asin((c - (x * x + r0y * r0y) * n * n) / (2 * n))];
+ };
+
+ return project;
+}
+
+var conicEqualArea = function() {
+ return conicProjection(conicEqualAreaRaw)
+ .scale(155.424)
+ .center([0, 33.6442]);
+};
+
+var albers = function() {
+ 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
+var albersUsa = function() {
+ 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, y + 0.120 * k + epsilon], [x - 0.214 * k - epsilon, y + 0.234 * k - epsilon]])
+ .stream(pointStream);
+
+ hawaiiPoint = hawaii
+ .translate([x - 0.205 * k, y + 0.212 * k])
+ .clipExtent([[x - 0.214 * k + epsilon, y + 0.166 * k + epsilon], [x - 0.115 * k - epsilon, y + 0.234 * k - epsilon]])
+ .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(x),
+ cy = cos(y),
+ k = scale(cx * cy);
+ return [
+ k * cy * sin(x),
+ k * sin(y)
+ ];
+ }
+}
+
+function azimuthalInvert(angle) {
+ return function(x, y) {
+ var z = sqrt(x * x + y * y),
+ c = angle(z),
+ sc = sin(c),
+ cc = cos(c);
+ return [
+ atan2(x * sc, z * cc),
+ asin(z && y * sc / z)
+ ];
+ }
+}
+
+var azimuthalEqualAreaRaw = azimuthalRaw(function(cxcy) {
+ return sqrt(2 / (1 + cxcy));
+});
+
+azimuthalEqualAreaRaw.invert = azimuthalInvert(function(z) {
+ return 2 * asin(z / 2);
+});
+
+var azimuthalEqualArea = function() {
+ return projection(azimuthalEqualAreaRaw)
+ .scale(124.75)
+ .clipAngle(180 - 1e-3);
+};
+
+var azimuthalEquidistantRaw = azimuthalRaw(function(c) {
+ return (c = acos(c)) && c / sin(c);
+});
+
+azimuthalEquidistantRaw.invert = azimuthalInvert(function(z) {
+ return z;
+});
+
+var azimuthalEquidistant = function() {
+ return projection(azimuthalEquidistantRaw)
+ .scale(79.4188)
+ .clipAngle(180 - 1e-3);
+};
+
+function mercatorRaw(lambda, phi) {
+ return [lambda, log(tan((halfPi + phi) / 2))];
+}
+
+mercatorRaw.invert = function(x, y) {
+ return [x, 2 * atan(exp(y)) - halfPi];
+};
+
+var mercator = function() {
+ return mercatorProjection(mercatorRaw)
+ .scale(961 / tau);
+};
+
+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 * 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 + y) / 2);
+}
+
+function conicConformalRaw(y0, y1) {
+ var cy0 = cos(y0),
+ n = y0 === y1 ? sin(y0) : log(cy0 / cos(y1)) / log(tany(y1) / tany(y0)),
+ f = cy0 * pow(tany(y0), n) / n;
+
+ if (!n) return mercatorRaw;
+
+ function project(x, y) {
+ if (f > 0) { if (y < -halfPi + epsilon) y = -halfPi + epsilon; }
+ else { if (y > halfPi - epsilon) y = halfPi - epsilon; }
+ var r = f / pow(tany(y), n);
+ return [r * sin(n * x), f - r * cos(n * x)];
+ }
+
+ project.invert = function(x, y) {
+ var fy = f - y, r = sign(n) * sqrt(x * x + fy * fy);
+ return [atan2(x, abs(fy)) / n * sign(fy), 2 * atan(pow(f / r, 1 / n)) - halfPi];
+ };
+
+ return project;
+}
+
+var conicConformal = function() {
+ return conicProjection(conicConformalRaw)
+ .scale(109.5)
+ .parallels([30, 30]);
+};
+
+function equirectangularRaw(lambda, phi) {
+ return [lambda, phi];
+}
+
+equirectangularRaw.invert = equirectangularRaw;
+
+var equirectangular = function() {
+ return projection(equirectangularRaw)
+ .scale(152.63);
+};
+
+function conicEquidistantRaw(y0, y1) {
+ var cy0 = cos(y0),
+ n = y0 === y1 ? sin(y0) : (cy0 - cos(y1)) / (y1 - y0),
+ g = cy0 / n + y0;
+
+ if (abs(n) < epsilon) return equirectangularRaw;
+
+ function project(x, y) {
+ var gy = g - y, nx = n * x;
+ return [gy * sin(nx), g - gy * cos(nx)];
+ }
+
+ project.invert = function(x, y) {
+ var gy = g - y;
+ return [atan2(x, abs(gy)) / n * sign(gy), g - sign(n) * sqrt(x * x + gy * gy)];
+ };
+
+ return project;
+}
+
+var conicEquidistant = function() {
+ return conicProjection(conicEquidistantRaw)
+ .scale(131.154)
+ .center([0, 13.9389]);
+};
+
+function gnomonicRaw(x, y) {
+ var cy = cos(y), k = cos(x) * cy;
+ return [cy * sin(x) / k, sin(y) / k];
+}
+
+gnomonicRaw.invert = azimuthalInvert(atan);
+
+var gnomonic = function() {
+ return projection(gnomonicRaw)
+ .scale(144.049)
+ .clipAngle(60);
+};
+
+function scaleTranslate(kx, ky, tx, ty) {
+ return kx === 1 && ky === 1 && tx === 0 && ty === 0 ? identity : transformer({
+ point: function(x, y) {
+ this.stream.point(x * kx + tx, y * ky + ty);
+ }
+ });
+}
+
+var identity$1 = function() {
+ var k = 1, tx = 0, ty = 0, sx = 1, sy = 1, transform$$1 = identity, // scale, translate and reflect
+ x0 = null, y0, x1, y1, // clip extent
+ postclip = identity,
+ cache,
+ cacheStream,
+ projection;
+
+ function reset() {
+ cache = cacheStream = null;
+ return projection;
+ }
+
+ return projection = {
+ stream: function(stream) {
+ return cache && cacheStream === stream ? cache : cache = transform$$1(postclip(cacheStream = stream));
+ },
+ postclip: function(_) {
+ return arguments.length ? (postclip = _, x0 = y0 = x1 = y1 = null, reset()) : postclip;
+ },
+ clipExtent: function(_) {
+ return arguments.length ? (postclip = _ == null ? (x0 = y0 = x1 = y1 = null, identity) : clipRectangle(x0 = +_[0][0], y0 = +_[0][1], x1 = +_[1][0], y1 = +_[1][1]), reset()) : x0 == null ? null : [[x0, y0], [x1, y1]];
+ },
+ scale: function(_) {
+ return arguments.length ? (transform$$1 = scaleTranslate((k = +_) * sx, k * sy, tx, ty), reset()) : k;
+ },
+ translate: function(_) {
+ return arguments.length ? (transform$$1 = scaleTranslate(k * sx, k * sy, tx = +_[0], ty = +_[1]), reset()) : [tx, ty];
+ },
+ reflectX: function(_) {
+ return arguments.length ? (transform$$1 = scaleTranslate(k * (sx = _ ? -1 : 1), k * sy, tx, ty), reset()) : sx < 0;
+ },
+ reflectY: function(_) {
+ return arguments.length ? (transform$$1 = scaleTranslate(k * sx, k * (sy = _ ? -1 : 1), tx, ty), reset()) : sy < 0;
+ },
+ fitExtent: function(extent, object) {
+ return fitExtent(projection, extent, object);
+ },
+ fitSize: function(size, object) {
+ return fitSize(projection, size, object);
+ },
+ fitWidth: function(width, object) {
+ return fitWidth(projection, width, object);
+ },
+ fitHeight: function(height, object) {
+ return fitHeight(projection, height, object);
+ }
+ };
+};
+
+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(delta) > epsilon && --i > 0);
+ return [
+ x / (0.8707 + (phi2 = phi * phi) * (-0.131979 + phi2 * (-0.013791 + phi2 * phi2 * phi2 * (0.003971 - 0.001529 * phi2)))),
+ phi
+ ];
+};
+
+var naturalEarth1 = function() {
+ return projection(naturalEarth1Raw)
+ .scale(175.295);
+};
+
+function orthographicRaw(x, y) {
+ return [cos(y) * sin(x), sin(y)];
+}
+
+orthographicRaw.invert = azimuthalInvert(asin);
+
+var orthographic = function() {
+ return projection(orthographicRaw)
+ .scale(249.5)
+ .clipAngle(90 + epsilon);
+};
+
+function stereographicRaw(x, y) {
+ var cy = cos(y), k = 1 + cos(x) * cy;
+ return [cy * sin(x) / k, sin(y) / k];
+}
+
+stereographicRaw.invert = azimuthalInvert(function(z) {
+ return 2 * atan(z);
+});
+
+var stereographic = function() {
+ return projection(stereographicRaw)
+ .scale(250)
+ .clipAngle(142);
+};
+
+function transverseMercatorRaw(lambda, phi) {
+ return [log(tan((halfPi + phi) / 2)), -lambda];
+}
+
+transverseMercatorRaw.invert = function(x, y) {
+ return [-y, 2 * atan(exp(x)) - halfPi];
+};
+
+var transverseMercator = function() {
+ 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);
+};
+
+exports.geoArea = area;
+exports.geoBounds = bounds;
+exports.geoCentroid = centroid;
+exports.geoCircle = circle;
+exports.geoClipAntimeridian = clipAntimeridian;
+exports.geoClipCircle = clipCircle;
+exports.geoClipExtent = extent;
+exports.geoClipRectangle = clipRectangle;
+exports.geoContains = contains;
+exports.geoDistance = distance;
+exports.geoGraticule = graticule;
+exports.geoGraticule10 = graticule10;
+exports.geoInterpolate = interpolate;
+exports.geoLength = length;
+exports.geoPath = index;
+exports.geoAlbers = albers;
+exports.geoAlbersUsa = albersUsa;
+exports.geoAzimuthalEqualArea = azimuthalEqualArea;
+exports.geoAzimuthalEqualAreaRaw = azimuthalEqualAreaRaw;
+exports.geoAzimuthalEquidistant = azimuthalEquidistant;
+exports.geoAzimuthalEquidistantRaw = azimuthalEquidistantRaw;
+exports.geoConicConformal = conicConformal;
+exports.geoConicConformalRaw = conicConformalRaw;
+exports.geoConicEqualArea = conicEqualArea;
+exports.geoConicEqualAreaRaw = conicEqualAreaRaw;
+exports.geoConicEquidistant = conicEquidistant;
+exports.geoConicEquidistantRaw = conicEquidistantRaw;
+exports.geoEquirectangular = equirectangular;
+exports.geoEquirectangularRaw = equirectangularRaw;
+exports.geoGnomonic = gnomonic;
+exports.geoGnomonicRaw = gnomonicRaw;
+exports.geoIdentity = identity$1;
+exports.geoProjection = projection;
+exports.geoProjectionMutator = projectionMutator;
+exports.geoMercator = mercator;
+exports.geoMercatorRaw = mercatorRaw;
+exports.geoNaturalEarth1 = naturalEarth1;
+exports.geoNaturalEarth1Raw = naturalEarth1Raw;
+exports.geoOrthographic = orthographic;
+exports.geoOrthographicRaw = orthographicRaw;
+exports.geoStereographic = stereographic;
+exports.geoStereographicRaw = stereographicRaw;
+exports.geoTransverseMercator = transverseMercator;
+exports.geoTransverseMercatorRaw = transverseMercatorRaw;
+exports.geoRotation = rotation;
+exports.geoStream = geoStream;
+exports.geoTransform = transform;
+
+Object.defineProperty(exports, '__esModule', { value: true });
+
+})));
+
+},{"d3-array":23}],36:[function(require,module,exports){
+// https://d3js.org/d3-hierarchy/ Version 1.1.5. Copyright 2017 Mike Bostock.
+(function (global, factory) {
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
+ typeof define === 'function' && define.amd ? define(['exports'], factory) :
+ (factory((global.d3 = global.d3 || {})));
+}(this, (function (exports) { 'use strict';
+
+function defaultSeparation(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;
+}
+
+var cluster = function() {
+ var separation = defaultSeparation,
+ 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;
+}
+
+var node_count = function() {
+ return this.eachAfter(count);
+};
+
+var node_each = function(callback) {
+ var node = this, current, next = [node], children, i, n;
+ do {
+ current = next.reverse(), next = [];
+ while (node = current.pop()) {
+ callback(node), children = node.children;
+ if (children) for (i = 0, n = children.length; i < n; ++i) {
+ next.push(children[i]);
+ }
+ }
+ } while (next.length);
+ return this;
+};
+
+var node_eachBefore = function(callback) {
+ var node = this, nodes = [node], children, i;
+ while (node = nodes.pop()) {
+ callback(node), children = node.children;
+ if (children) for (i = children.length - 1; i >= 0; --i) {
+ nodes.push(children[i]);
+ }
+ }
+ return this;
+};
+
+var node_eachAfter = function(callback) {
+ var node = this, nodes = [node], next = [], children, i, n;
+ while (node = nodes.pop()) {
+ next.push(node), children = node.children;
+ if (children) for (i = 0, n = children.length; i < n; ++i) {
+ nodes.push(children[i]);
+ }
+ }
+ while (node = next.pop()) {
+ callback(node);
+ }
+ return this;
+};
+
+var node_sum = function(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;
+ });
+};
+
+var node_sort = function(compare) {
+ return this.eachBefore(function(node) {
+ if (node.children) {
+ node.children.sort(compare);
+ }
+ });
+};
+
+var node_path = function(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;
+}
+
+var node_ancestors = function() {
+ var node = this, nodes = [node];
+ while (node = node.parent) {
+ nodes.push(node);
+ }
+ return nodes;
+};
+
+var node_descendants = function() {
+ var nodes = [];
+ this.each(function(node) {
+ nodes.push(node);
+ });
+ return nodes;
+};
+
+var node_leaves = function() {
+ var leaves = [];
+ this.eachBefore(function(node) {
+ if (!node.children) {
+ leaves.push(node);
+ }
+ });
+ return leaves;
+};
+
+var node_links = function() {
+ 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 hierarchy(data, children) {
+ var root = new Node(data),
+ valued = +data.value && (root.value = data.value),
+ node,
+ nodes = [root],
+ child,
+ childs,
+ i,
+ n;
+
+ if (children == null) children = defaultChildren;
+
+ while (node = nodes.pop()) {
+ if (valued) node.value = +node.data.value;
+ if ((childs = children(node.data)) && (n = childs.length)) {
+ node.children = new Array(n);
+ for (i = n - 1; i >= 0; --i) {
+ nodes.push(child = node.children[i] = new Node(childs[i]));
+ child.parent = node;
+ child.depth = node.depth + 1;
+ }
+ }
+ }
+
+ return root.eachBefore(computeHeight);
+}
+
+function node_copy() {
+ return hierarchy(this).eachBefore(copyData);
+}
+
+function defaultChildren(d) {
+ return d.children;
+}
+
+function copyData(node) {
+ node.data = node.data.data;
+}
+
+function computeHeight(node) {
+ var height = 0;
+ do node.height = height;
+ while ((node = node.parent) && (node.height < ++height));
+}
+
+function Node(data) {
+ this.data = data;
+ this.depth =
+ this.height = 0;
+ this.parent = null;
+}
+
+Node.prototype = hierarchy.prototype = {
+ constructor: Node,
+ count: node_count,
+ each: node_each,
+ eachAfter: node_eachAfter,
+ eachBefore: node_eachBefore,
+ sum: node_sum,
+ sort: node_sort,
+ path: node_path,
+ ancestors: node_ancestors,
+ descendants: node_descendants,
+ leaves: node_leaves,
+ links: node_links,
+ copy: node_copy
+};
+
+var slice = Array.prototype.slice;
+
+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;
+}
+
+var enclose = function(circles) {
+ var i = 0, n = (circles = shuffle(slice.call(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 + 1e-6, 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(a, b, c) {
+ var ax = a.x,
+ ay = a.y,
+ da = b.r + c.r,
+ db = a.r + c.r,
+ dx = b.x - ax,
+ dy = b.y - ay,
+ dc = dx * dx + dy * dy;
+ if (dc) {
+ var x = 0.5 + ((db *= db) - (da *= da)) / (2 * dc),
+ y = Math.sqrt(Math.max(0, 2 * da * (db + dc) - (db -= dc) * db - da * da)) / (2 * dc);
+ c.x = ax + x * dx + y * dy;
+ c.y = ay + x * dy - y * dx;
+ } else {
+ c.x = ax + db;
+ c.y = ay;
+ }
+}
+
+function intersects(a, b) {
+ var dx = b.x - a.x,
+ dy = b.y - a.y,
+ dr = a.r + b.r;
+ return dr * dr - 1e-6 > 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$1(circle) {
+ this._ = circle;
+ this.next = null;
+ this.previous = null;
+}
+
+function packEnclose(circles) {
+ if (!(n = 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$1(a), b = new Node$1(b), c = new Node$1(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$1(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;
+}
+
+var siblings = function(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;
+}
+
+var constant = function(x) {
+ return function() {
+ return x;
+ };
+};
+
+function defaultRadius(d) {
+ return Math.sqrt(d.value);
+}
+
+var index = function() {
+ 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(+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;
+ }
+ };
+}
+
+var roundNode = function(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);
+};
+
+var treemapDice = function(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;
+ }
+};
+
+var partition = function() {
+ 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 keyPrefix = "$";
+var preroot = {depth: -1};
+var ambiguous = {};
+
+function defaultId(d) {
+ return d.id;
+}
+
+function defaultParentId(d) {
+ return d.parentId;
+}
+
+var stratify = function() {
+ var id = defaultId,
+ parentId = defaultParentId;
+
+ function stratify(data) {
+ var d,
+ i,
+ n = data.length,
+ root,
+ parent,
+ node,
+ nodes = new Array(n),
+ nodeId,
+ nodeKey,
+ nodeByKey = {};
+
+ for (i = 0; i < n; ++i) {
+ d = data[i], node = nodes[i] = new Node(d);
+ if ((nodeId = id(d, i, data)) != null && (nodeId += "")) {
+ nodeKey = keyPrefix + (node.id = nodeId);
+ nodeByKey[nodeKey] = nodeKey in nodeByKey ? ambiguous : node;
+ }
+ }
+
+ for (i = 0; i < n; ++i) {
+ node = nodes[i], nodeId = parentId(data[i], i, data);
+ if (nodeId == null || !(nodeId += "")) {
+ if (root) throw new Error("multiple roots");
+ root = node;
+ } else {
+ parent = nodeByKey[keyPrefix + 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;
+ }
+ }
+
+ if (!root) throw new Error("no root");
+ 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 = required(x), stratify) : id;
+ };
+
+ stratify.parentId = function(x) {
+ return arguments.length ? (parentId = required(x), stratify) : parentId;
+ };
+
+ return stratify;
+};
+
+function defaultSeparation$1(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.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
+var tree = function() {
+ var separation = defaultSeparation$1,
+ 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;
+};
+
+var treemapSlice = function(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);
+
+var index$1 = function() {
+ 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(+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(+x), treemap) : paddingTop;
+ };
+
+ treemap.paddingRight = function(x) {
+ return arguments.length ? (paddingRight = typeof x === "function" ? x : constant(+x), treemap) : paddingRight;
+ };
+
+ treemap.paddingBottom = function(x) {
+ return arguments.length ? (paddingBottom = typeof x === "function" ? x : constant(+x), treemap) : paddingBottom;
+ };
+
+ treemap.paddingLeft = function(x) {
+ return arguments.length ? (paddingLeft = typeof x === "function" ? x : constant(+x), treemap) : paddingLeft;
+ };
+
+ return treemap;
+};
+
+var binary = function(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 = (x0 * valueRight + x1 * valueLeft) / value;
+ partition(i, k, valueLeft, x0, y0, xk, y1);
+ partition(k, j, valueRight, xk, y0, x1, y1);
+ } else {
+ var yk = (y0 * valueRight + y1 * valueLeft) / value;
+ partition(i, k, valueLeft, x0, y0, x1, yk);
+ partition(k, j, valueRight, x0, yk, x1, y1);
+ }
+ }
+};
+
+var sliceDice = function(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, y0 += (y1 - y0) * row.value / value);
+ else treemapSlice(row, x0, y0, x0 += (x1 - x0) * row.value / value, 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);
+
+exports.cluster = cluster;
+exports.hierarchy = hierarchy;
+exports.pack = index;
+exports.packSiblings = siblings;
+exports.packEnclose = enclose;
+exports.partition = partition;
+exports.stratify = stratify;
+exports.tree = tree;
+exports.treemap = index$1;
+exports.treemapBinary = binary;
+exports.treemapDice = treemapDice;
+exports.treemapSlice = treemapSlice;
+exports.treemapSliceDice = sliceDice;
+exports.treemapSquarify = squarify;
+exports.treemapResquarify = resquarify;
+
+Object.defineProperty(exports, '__esModule', { value: true });
+
+})));
+
+},{}],37:[function(require,module,exports){
+// https://d3js.org/d3-interpolate/ Version 1.1.6. Copyright 2017 Mike Bostock.
+(function (global, factory) {
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('d3-color')) :
+ typeof define === 'function' && define.amd ? define(['exports', 'd3-color'], factory) :
+ (factory((global.d3 = global.d3 || {}),global.d3));
+}(this, (function (exports,d3Color) { 'use strict';
+
+function basis(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;
+}
+
+var basis$1 = function(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((t - i / n) * n, v0, v1, v2, v3);
+ };
+};
+
+var basisClosed = function(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((t - i / n) * n, v0, v1, v2, v3);
+ };
+};
+
+var constant = function(x) {
+ return function() {
+ return x;
+ };
+};
+
+function linear(a, d) {
+ return function(t) {
+ return a + t * d;
+ };
+}
+
+function exponential(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(a, b) {
+ var d = b - a;
+ return d ? linear(a, d > 180 || d < -180 ? d - 360 * Math.round(d / 360) : d) : constant(isNaN(a) ? b : a);
+}
+
+function gamma(y) {
+ return (y = +y) === 1 ? nogamma : function(a, b) {
+ return b - a ? exponential(a, b, y) : constant(isNaN(a) ? b : a);
+ };
+}
+
+function nogamma(a, b) {
+ var d = b - a;
+ return d ? linear(a, d) : constant(isNaN(a) ? b : a);
+}
+
+var rgb$1 = ((function rgbGamma(y) {
+ var color$$1 = gamma(y);
+
+ function rgb$$1(start, end) {
+ var r = color$$1((start = d3Color.rgb(start)).r, (end = d3Color.rgb(end)).r),
+ g = color$$1(start.g, end.g),
+ b = color$$1(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$$1;
+ for (i = 0; i < n; ++i) {
+ color$$1 = d3Color.rgb(colors[i]);
+ r[i] = color$$1.r || 0;
+ g[i] = color$$1.g || 0;
+ b[i] = color$$1.b || 0;
+ }
+ r = spline(r);
+ g = spline(g);
+ b = spline(b);
+ color$$1.opacity = 1;
+ return function(t) {
+ color$$1.r = r(t);
+ color$$1.g = g(t);
+ color$$1.b = b(t);
+ return color$$1 + "";
+ };
+ };
+}
+
+var rgbBasis = rgbSpline(basis$1);
+var rgbBasisClosed = rgbSpline(basisClosed);
+
+var array = function(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] = value(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;
+ };
+};
+
+var date = function(a, b) {
+ var d = new Date;
+ return a = +a, b -= a, function(t) {
+ return d.setTime(a + b * t), d;
+ };
+};
+
+var number = function(a, b) {
+ return a = +a, b -= a, function(t) {
+ return a + b * t;
+ };
+};
+
+var object = function(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] = value(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;
+var reB = new RegExp(reA.source, "g");
+
+function zero(b) {
+ return function() {
+ return b;
+ };
+}
+
+function one(b) {
+ return function(t) {
+ return b(t) + "";
+ };
+}
+
+var string = function(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: number(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("");
+ });
+};
+
+var value = function(a, b) {
+ var t = typeof b, c;
+ return b == null || t === "boolean" ? constant(b)
+ : (t === "number" ? number
+ : t === "string" ? ((c = d3Color.color(b)) ? (b = c, rgb$1) : string)
+ : b instanceof d3Color.color ? rgb$1
+ : b instanceof Date ? date
+ : Array.isArray(b) ? array
+ : typeof b.valueOf !== "function" && typeof b.toString !== "function" || isNaN(b) ? object
+ : number)(a, b);
+};
+
+var round = function(a, b) {
+ return a = +a, b -= a, function(t) {
+ return Math.round(a + b * t);
+ };
+};
+
+var degrees = 180 / Math.PI;
+
+var identity = {
+ translateX: 0,
+ translateY: 0,
+ rotate: 0,
+ skewX: 0,
+ scaleX: 1,
+ scaleY: 1
+};
+
+var decompose = function(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,
+ skewX: Math.atan(skewX) * degrees,
+ scaleX: scaleX,
+ scaleY: scaleY
+ };
+};
+
+var cssNode;
+var cssRoot;
+var cssView;
+var svgNode;
+
+function parseCss(value) {
+ if (value === "none") return identity;
+ if (!cssNode) cssNode = document.createElement("DIV"), cssRoot = document.documentElement, cssView = document.defaultView;
+ cssNode.style.transform = value;
+ value = cssView.getComputedStyle(cssRoot.appendChild(cssNode), null).getPropertyValue("transform");
+ cssRoot.removeChild(cssNode);
+ value = value.slice(7, -1).split(",");
+ return decompose(+value[0], +value[1], +value[2], +value[3], +value[4], +value[5]);
+}
+
+function parseSvg(value) {
+ if (value == null) return identity;
+ if (!svgNode) svgNode = document.createElementNS("http://www.w3.org/2000/svg", "g");
+ svgNode.setAttribute("transform", value);
+ if (!(value = svgNode.transform.baseVal.consolidate())) return identity;
+ 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: number(xa, xb)}, {i: i - 2, x: number(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: number(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: number(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: number(xa, xb)}, {i: i - 2, x: number(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 rho = Math.SQRT2;
+var rho2 = 2;
+var rho4 = 4;
+var epsilon2 = 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);
+}
+
+// p0 = [ux0, uy0, w0]
+// p1 = [ux1, uy1, w1]
+var zoom = function(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) {
+ 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;
+
+ return i;
+};
+
+function hsl$1(hue$$1) {
+ return function(start, end) {
+ var h = hue$$1((start = d3Color.hsl(start)).h, (end = d3Color.hsl(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$2 = hsl$1(hue);
+var hslLong = hsl$1(nogamma);
+
+function lab$1(start, end) {
+ var l = nogamma((start = d3Color.lab(start)).l, (end = d3Color.lab(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$1(hue$$1) {
+ return function(start, end) {
+ var h = hue$$1((start = d3Color.hcl(start)).h, (end = d3Color.hcl(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$2 = hcl$1(hue);
+var hclLong = hcl$1(nogamma);
+
+function cubehelix$1(hue$$1) {
+ return (function cubehelixGamma(y) {
+ y = +y;
+
+ function cubehelix$$1(start, end) {
+ var h = hue$$1((start = d3Color.cubehelix(start)).h, (end = d3Color.cubehelix(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$$1.gamma = cubehelixGamma;
+
+ return cubehelix$$1;
+ })(1);
+}
+
+var cubehelix$2 = cubehelix$1(hue);
+var cubehelixLong = cubehelix$1(nogamma);
+
+var quantize = function(interpolator, n) {
+ var samples = new Array(n);
+ for (var i = 0; i < n; ++i) samples[i] = interpolator(i / (n - 1));
+ return samples;
+};
+
+exports.interpolate = value;
+exports.interpolateArray = array;
+exports.interpolateBasis = basis$1;
+exports.interpolateBasisClosed = basisClosed;
+exports.interpolateDate = date;
+exports.interpolateNumber = number;
+exports.interpolateObject = object;
+exports.interpolateRound = round;
+exports.interpolateString = string;
+exports.interpolateTransformCss = interpolateTransformCss;
+exports.interpolateTransformSvg = interpolateTransformSvg;
+exports.interpolateZoom = zoom;
+exports.interpolateRgb = rgb$1;
+exports.interpolateRgbBasis = rgbBasis;
+exports.interpolateRgbBasisClosed = rgbBasisClosed;
+exports.interpolateHsl = hsl$2;
+exports.interpolateHslLong = hslLong;
+exports.interpolateLab = lab$1;
+exports.interpolateHcl = hcl$2;
+exports.interpolateHclLong = hclLong;
+exports.interpolateCubehelix = cubehelix$2;
+exports.interpolateCubehelixLong = cubehelixLong;
+exports.quantize = quantize;
+
+Object.defineProperty(exports, '__esModule', { value: true });
+
+})));
+
+},{"d3-color":28}],38:[function(require,module,exports){
+// https://d3js.org/d3-path/ Version 1.0.5. Copyright 2017 Mike Bostock.
+(function (global, factory) {
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
+ typeof define === 'function' && define.amd ? define(['exports'], factory) :
+ (factory((global.d3 = global.d3 || {})));
+}(this, (function (exports) { 'use strict';
+
+var pi = Math.PI;
+var tau = 2 * pi;
+var epsilon = 1e-6;
+var tauEpsilon = tau - epsilon;
+
+function Path() {
+ this._x0 = this._y0 = // start of current subpath
+ this._x1 = this._y1 = null; // end of current subpath
+ this._ = "";
+}
+
+function path() {
+ return new Path;
+}
+
+Path.prototype = path.prototype = {
+ constructor: Path,
+ 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)) {}
+
+ // 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) || !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 - 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) {
+ 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;
+ 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 || Math.abs(this._y1 - y0) > epsilon) {
+ 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 + tau;
+
+ // 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) {
+ this._ += "A" + r + "," + r + ",0," + (+(da >= pi)) + "," + 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._;
+ }
+};
+
+exports.path = path;
+
+Object.defineProperty(exports, '__esModule', { value: true });
+
+})));
+
+},{}],39:[function(require,module,exports){
+// https://d3js.org/d3-polygon/ Version 1.0.3. Copyright 2017 Mike Bostock.
+(function (global, factory) {
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
+ typeof define === 'function' && define.amd ? define(['exports'], factory) :
+ (factory((global.d3 = global.d3 || {})));
+}(this, (function (exports) { 'use strict';
+
+var area = function(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;
+};
+
+var centroid = function(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.
+var cross = function(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) {
+ var n = points.length,
+ indexes = [0, 1],
+ size = 2;
+
+ for (var i = 2; i < n; ++i) {
+ while (size > 1 && cross(points[indexes[size - 2]], points[indexes[size - 1]], points[i]) <= 0) --size;
+ indexes[size++] = i;
+ }
+
+ return indexes.slice(0, size); // remove popped points
+}
+
+var hull = function(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;
+};
+
+var contains = function(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;
+};
+
+var length = function(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.sqrt(xa * xa + ya * ya);
+ }
+
+ return perimeter;
+};
+
+exports.polygonArea = area;
+exports.polygonCentroid = centroid;
+exports.polygonHull = hull;
+exports.polygonContains = contains;
+exports.polygonLength = length;
+
+Object.defineProperty(exports, '__esModule', { value: true });
+
+})));
+
+},{}],40:[function(require,module,exports){
+// https://d3js.org/d3-quadtree/ Version 1.0.3. Copyright 2017 Mike Bostock.
+(function (global, factory) {
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
+ typeof define === 'function' && define.amd ? define(['exports'], factory) :
+ (factory((global.d3 = global.d3 || {})));
+}(this, (function (exports) { 'use strict';
+
+var tree_add = function(d) {
+ var 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, inherit the existing extent.
+ if (x1 < x0) x0 = this._x0, x1 = this._x1;
+ if (y1 < y0) y0 = this._y0, y1 = this._y1;
+
+ // 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;
+}
+
+var tree_cover = function(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 if (x0 > x || x > x1 || y0 > y || y > y1) {
+ var z = x1 - x0,
+ node = this._root,
+ parent,
+ i;
+
+ switch (i = (y < (y0 + y1) / 2) << 1 | (x < (x0 + x1) / 2)) {
+ case 0: {
+ do parent = new Array(4), parent[i] = node, node = parent;
+ while (z *= 2, x1 = x0 + z, y1 = y0 + z, x > x1 || y > y1);
+ break;
+ }
+ case 1: {
+ do parent = new Array(4), parent[i] = node, node = parent;
+ while (z *= 2, x0 = x1 - z, y1 = y0 + z, x0 > x || y > y1);
+ break;
+ }
+ case 2: {
+ do parent = new Array(4), parent[i] = node, node = parent;
+ while (z *= 2, x1 = x0 + z, y0 = y1 - z, x > x1 || y0 > y);
+ break;
+ }
+ case 3: {
+ do parent = new Array(4), parent[i] = node, node = parent;
+ while (z *= 2, x0 = x1 - z, y0 = y1 - z, x0 > x || y0 > y);
+ break;
+ }
+ }
+
+ if (this._root && this._root.length) this._root = node;
+ }
+
+ // If the quadtree covers the point already, just return.
+ else return this;
+
+ this._x0 = x0;
+ this._y0 = y0;
+ this._x1 = x1;
+ this._y1 = y1;
+ return this;
+};
+
+var tree_data = function() {
+ var data = [];
+ this.visit(function(node) {
+ if (!node.length) do data.push(node.data); while (node = node.next)
+ });
+ return data;
+};
+
+var tree_extent = function(_) {
+ 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]];
+};
+
+var Quad = function(node, x0, y0, x1, y1) {
+ this.node = node;
+ this.x0 = x0;
+ this.y0 = y0;
+ this.x1 = x1;
+ this.y1 = y1;
+};
+
+var tree_find = function(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;
+};
+
+var tree_remove = function(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;
+}
+
+var tree_root = function() {
+ return this._root;
+};
+
+var tree_size = function() {
+ var size = 0;
+ this.visit(function(node) {
+ if (!node.length) do ++size; while (node = node.next)
+ });
+ return size;
+};
+
+var tree_visit = function(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;
+};
+
+var tree_visitAfter = function(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];
+}
+
+var tree_x = function(_) {
+ return arguments.length ? (this._x = _, this) : this._x;
+};
+
+function defaultY(d) {
+ return d[1];
+}
+
+var tree_y = function(_) {
+ 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;
+
+exports.quadtree = quadtree;
+
+Object.defineProperty(exports, '__esModule', { value: true });
+
+})));
+
+},{}],41:[function(require,module,exports){
+// https://d3js.org/d3-queue/ Version 3.0.7. Copyright 2017 Mike Bostock.
+(function (global, factory) {
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
+ typeof define === 'function' && define.amd ? define(['exports'], factory) :
+ (factory((global.d3 = global.d3 || {})));
+}(this, (function (exports) { 'use strict';
+
+var slice = [].slice;
+
+var noabort = {};
+
+function Queue(size) {
+ this._size = size;
+ this._call =
+ this._error = null;
+ this._tasks = [];
+ this._data = [];
+ this._waiting =
+ this._active =
+ this._ended =
+ this._start = 0; // inside a synchronous task callback?
+}
+
+Queue.prototype = queue.prototype = {
+ constructor: Queue,
+ defer: function(callback) {
+ if (typeof callback !== "function") throw new Error("invalid callback");
+ if (this._call) throw new Error("defer after await");
+ if (this._error != null) return this;
+ var t = slice.call(arguments, 1);
+ t.push(callback);
+ ++this._waiting, this._tasks.push(t);
+ poke(this);
+ return this;
+ },
+ abort: function() {
+ if (this._error == null) abort(this, new Error("abort"));
+ return this;
+ },
+ await: function(callback) {
+ if (typeof callback !== "function") throw new Error("invalid callback");
+ if (this._call) throw new Error("multiple await");
+ this._call = function(error, results) { callback.apply(null, [error].concat(results)); };
+ maybeNotify(this);
+ return this;
+ },
+ awaitAll: function(callback) {
+ if (typeof callback !== "function") throw new Error("invalid callback");
+ if (this._call) throw new Error("multiple await");
+ this._call = callback;
+ maybeNotify(this);
+ return this;
+ }
+};
+
+function poke(q) {
+ if (!q._start) {
+ try { start(q); } // let the current task complete
+ catch (e) {
+ if (q._tasks[q._ended + q._active - 1]) abort(q, e); // task errored synchronously
+ else if (!q._data) throw e; // await callback errored synchronously
+ }
+ }
+}
+
+function start(q) {
+ while (q._start = q._waiting && q._active < q._size) {
+ var i = q._ended + q._active,
+ t = q._tasks[i],
+ j = t.length - 1,
+ c = t[j];
+ t[j] = end(q, i);
+ --q._waiting, ++q._active;
+ t = c.apply(null, t);
+ if (!q._tasks[i]) continue; // task finished synchronously
+ q._tasks[i] = t || noabort;
+ }
+}
+
+function end(q, i) {
+ return function(e, r) {
+ if (!q._tasks[i]) return; // ignore multiple callbacks
+ --q._active, ++q._ended;
+ q._tasks[i] = null;
+ if (q._error != null) return; // ignore secondary errors
+ if (e != null) {
+ abort(q, e);
+ } else {
+ q._data[i] = r;
+ if (q._waiting) poke(q);
+ else maybeNotify(q);
+ }
+ };
+}
+
+function abort(q, e) {
+ var i = q._tasks.length, t;
+ q._error = e; // ignore active callbacks
+ q._data = undefined; // allow gc
+ q._waiting = NaN; // prevent starting
+
+ while (--i >= 0) {
+ if (t = q._tasks[i]) {
+ q._tasks[i] = null;
+ if (t.abort) {
+ try { t.abort(); }
+ catch (e) { /* ignore */ }
+ }
+ }
+ }
+
+ q._active = NaN; // allow notification
+ maybeNotify(q);
+}
+
+function maybeNotify(q) {
+ if (!q._active && q._call) {
+ var d = q._data;
+ q._data = undefined; // allow gc
+ q._call(q._error, d);
+ }
+}
+
+function queue(concurrency) {
+ if (concurrency == null) concurrency = Infinity;
+ else if (!((concurrency = +concurrency) >= 1)) throw new Error("invalid concurrency");
+ return new Queue(concurrency);
+}
+
+exports.queue = queue;
+
+Object.defineProperty(exports, '__esModule', { value: true });
+
+})));
+
+},{}],42:[function(require,module,exports){
+// https://d3js.org/d3-random/ Version 1.1.0. Copyright 2017 Mike Bostock.
+(function (global, factory) {
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
+ typeof define === 'function' && define.amd ? define(['exports'], factory) :
+ (factory((global.d3 = global.d3 || {})));
+}(this, (function (exports) { 'use strict';
+
+var defaultSource = function() {
+ return 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 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) {
+ function randomLogNormal() {
+ var randomNormal = normal.source(source).apply(this, arguments);
+ return function() {
+ return Math.exp(randomNormal());
+ };
+ }
+
+ randomLogNormal.source = sourceRandomLogNormal;
+
+ return randomLogNormal;
+}))(defaultSource);
+
+var irwinHall = ((function sourceRandomIrwinHall(source) {
+ function randomIrwinHall(n) {
+ return function() {
+ for (var sum = 0, i = 0; i < n; ++i) sum += source();
+ return sum;
+ };
+ }
+
+ randomIrwinHall.source = sourceRandomIrwinHall;
+
+ return randomIrwinHall;
+}))(defaultSource);
+
+var bates = ((function sourceRandomBates(source) {
+ function randomBates(n) {
+ var randomIrwinHall = irwinHall.source(source)(n);
+ return function() {
+ return randomIrwinHall() / n;
+ };
+ }
+
+ randomBates.source = sourceRandomBates;
+
+ return randomBates;
+}))(defaultSource);
+
+var exponential = ((function sourceRandomExponential(source) {
+ function randomExponential(lambda) {
+ return function() {
+ return -Math.log(1 - source()) / lambda;
+ };
+ }
+
+ randomExponential.source = sourceRandomExponential;
+
+ return randomExponential;
+}))(defaultSource);
+
+exports.randomUniform = uniform;
+exports.randomNormal = normal;
+exports.randomLogNormal = logNormal;
+exports.randomBates = bates;
+exports.randomIrwinHall = irwinHall;
+exports.randomExponential = exponential;
+
+Object.defineProperty(exports, '__esModule', { value: true });
+
+})));
+
+},{}],43:[function(require,module,exports){
+'use strict';
+
+var XMLHttpRequest = require('xmlhttprequest').XMLHttpRequest;
+
+Object.defineProperty(exports, '__esModule', { value: true });
+
+var d3Collection = require('d3-collection');
+var d3Dispatch = require('d3-dispatch');
+var d3Dsv = require('d3-dsv');
+
+var request = function(url, callback) {
+ var request,
+ event = d3Dispatch.dispatch("beforesend", "progress", "load", "error"),
+ mimeType,
+ headers = d3Collection.map(),
+ xhr = new XMLHttpRequest,
+ user = null,
+ password = null,
+ response,
+ responseType,
+ timeout = 0;
+
+ // If IE does not support CORS, use XDomainRequest.
+ if (typeof XDomainRequest !== "undefined"
+ && !("withCredentials" in xhr)
+ && /^(http(s)?:)?\/\//.test(url)) xhr = new XDomainRequest;
+
+ "onload" in xhr
+ ? xhr.onload = xhr.onerror = xhr.ontimeout = respond
+ : xhr.onreadystatechange = function(o) { xhr.readyState > 3 && respond(o); };
+
+ function respond(o) {
+ var status = xhr.status, result;
+ if (!status && hasResponse(xhr)
+ || status >= 200 && status < 300
+ || status === 304) {
+ if (response) {
+ try {
+ result = response.call(request, xhr);
+ } catch (e) {
+ event.call("error", request, e);
+ return;
+ }
+ } else {
+ result = xhr;
+ }
+ event.call("load", request, result);
+ } else {
+ event.call("error", request, o);
+ }
+ }
+
+ xhr.onprogress = function(e) {
+ event.call("progress", request, e);
+ };
+
+ request = {
+ header: function(name, value) {
+ name = (name + "").toLowerCase();
+ if (arguments.length < 2) return headers.get(name);
+ if (value == null) headers.remove(name);
+ else headers.set(name, value + "");
+ return request;
+ },
+
+ // If mimeType is non-null and no Accept header is set, a default is used.
+ mimeType: function(value) {
+ if (!arguments.length) return mimeType;
+ mimeType = value == null ? null : value + "";
+ return request;
+ },
+
+ // Specifies what type the response value should take;
+ // for instance, arraybuffer, blob, document, or text.
+ responseType: function(value) {
+ if (!arguments.length) return responseType;
+ responseType = value;
+ return request;
+ },
+
+ timeout: function(value) {
+ if (!arguments.length) return timeout;
+ timeout = +value;
+ return request;
+ },
+
+ user: function(value) {
+ return arguments.length < 1 ? user : (user = value == null ? null : value + "", request);
+ },
+
+ password: function(value) {
+ return arguments.length < 1 ? password : (password = value == null ? null : value + "", request);
+ },
+
+ // Specify how to convert the response content to a specific type;
+ // changes the callback value on "load" events.
+ response: function(value) {
+ response = value;
+ return request;
+ },
+
+ // Alias for send("GET", …).
+ get: function(data, callback) {
+ return request.send("GET", data, callback);
+ },
+
+ // Alias for send("POST", …).
+ post: function(data, callback) {
+ return request.send("POST", data, callback);
+ },
+
+ // If callback is non-null, it will be used for error and load events.
+ send: function(method, data, callback) {
+ xhr.open(method, url, true, user, password);
+ if (mimeType != null && !headers.has("accept")) headers.set("accept", mimeType + ",*/*");
+ if (xhr.setRequestHeader) headers.each(function(value, name) { xhr.setRequestHeader(name, value); });
+ if (mimeType != null && xhr.overrideMimeType) xhr.overrideMimeType(mimeType);
+ if (responseType != null) xhr.responseType = responseType;
+ if (timeout > 0) xhr.timeout = timeout;
+ if (callback == null && typeof data === "function") callback = data, data = null;
+ if (callback != null && callback.length === 1) callback = fixCallback(callback);
+ if (callback != null) request.on("error", callback).on("load", function(xhr) { callback(null, xhr); });
+ event.call("beforesend", request, xhr);
+ xhr.send(data == null ? null : data);
+ return request;
+ },
+
+ abort: function() {
+ xhr.abort();
+ return request;
+ },
+
+ on: function() {
+ var value = event.on.apply(event, arguments);
+ return value === event ? request : value;
+ }
+ };
+
+ if (callback != null) {
+ if (typeof callback !== "function") throw new Error("invalid callback: " + callback);
+ return request.get(callback);
+ }
+
+ return request;
+};
+
+function fixCallback(callback) {
+ return function(error, xhr) {
+ callback(error == null ? xhr : null);
+ };
+}
+
+function hasResponse(xhr) {
+ var type = xhr.responseType;
+ return type && type !== "text"
+ ? xhr.response // null on error
+ : xhr.responseText; // "" on error
+}
+
+var type = function(defaultMimeType, response) {
+ return function(url, callback) {
+ var r = request(url).mimeType(defaultMimeType).response(response);
+ if (callback != null) {
+ if (typeof callback !== "function") throw new Error("invalid callback: " + callback);
+ return r.get(callback);
+ }
+ return r;
+ };
+};
+
+var html = type("text/html", function(xhr) {
+ return document.createRange().createContextualFragment(xhr.responseText);
+});
+
+var json = type("application/json", function(xhr) {
+ return JSON.parse(xhr.responseText);
+});
+
+var text = type("text/plain", function(xhr) {
+ return xhr.responseText;
+});
+
+var xml = type("application/xml", function(xhr) {
+ var xml = xhr.responseXML;
+ if (!xml) throw new Error("parse error");
+ return xml;
+});
+
+var dsv = function(defaultMimeType, parse) {
+ return function(url, row, callback) {
+ if (arguments.length < 3) callback = row, row = null;
+ var r = request(url).mimeType(defaultMimeType);
+ r.row = function(_) { return arguments.length ? r.response(responseOf(parse, row = _)) : row; };
+ r.row(row);
+ return callback ? r.get(callback) : r;
+ };
+};
+
+function responseOf(parse, row) {
+ return function(request$$1) {
+ return parse(request$$1.responseText, row);
+ };
+}
+
+var csv = dsv("text/csv", d3Dsv.csvParse);
+
+var tsv = dsv("text/tab-separated-values", d3Dsv.tsvParse);
+
+exports.request = request;
+exports.html = html;
+exports.json = json;
+exports.text = text;
+exports.xml = xml;
+exports.csv = csv;
+exports.tsv = tsv;
+
+},{"d3-collection":27,"d3-dispatch":29,"d3-dsv":31,"xmlhttprequest":87}],44:[function(require,module,exports){
+// https://d3js.org/d3-scale/ Version 1.0.7. Copyright 2017 Mike Bostock.
+(function (global, factory) {
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('d3-array'), require('d3-collection'), require('d3-interpolate'), require('d3-format'), require('d3-time'), require('d3-time-format'), require('d3-color')) :
+ typeof define === 'function' && define.amd ? define(['exports', 'd3-array', 'd3-collection', 'd3-interpolate', 'd3-format', 'd3-time', 'd3-time-format', 'd3-color'], factory) :
+ (factory((global.d3 = global.d3 || {}),global.d3,global.d3,global.d3,global.d3,global.d3,global.d3,global.d3));
+}(this, (function (exports,d3Array,d3Collection,d3Interpolate,d3Format,d3Time,d3TimeFormat,d3Color) { 'use strict';
+
+var array = Array.prototype;
+
+var map$1 = array.map;
+var slice = array.slice;
+
+var implicit = {name: "implicit"};
+
+function ordinal(range$$1) {
+ var index = d3Collection.map(),
+ domain = [],
+ unknown = implicit;
+
+ range$$1 = range$$1 == null ? [] : slice.call(range$$1);
+
+ function scale(d) {
+ var key = d + "", i = index.get(key);
+ if (!i) {
+ if (unknown !== implicit) return unknown;
+ index.set(key, i = domain.push(d));
+ }
+ return range$$1[(i - 1) % range$$1.length];
+ }
+
+ scale.domain = function(_) {
+ if (!arguments.length) return domain.slice();
+ domain = [], index = d3Collection.map();
+ var i = -1, n = _.length, d, key;
+ while (++i < n) if (!index.has(key = (d = _[i]) + "")) index.set(key, domain.push(d));
+ return scale;
+ };
+
+ scale.range = function(_) {
+ return arguments.length ? (range$$1 = slice.call(_), scale) : range$$1.slice();
+ };
+
+ scale.unknown = function(_) {
+ return arguments.length ? (unknown = _, scale) : unknown;
+ };
+
+ scale.copy = function() {
+ return ordinal()
+ .domain(domain)
+ .range(range$$1)
+ .unknown(unknown);
+ };
+
+ return scale;
+}
+
+function band() {
+ var scale = ordinal().unknown(undefined),
+ domain = scale.domain,
+ ordinalRange = scale.range,
+ range$$1 = [0, 1],
+ step,
+ bandwidth,
+ round = false,
+ paddingInner = 0,
+ paddingOuter = 0,
+ align = 0.5;
+
+ delete scale.unknown;
+
+ function rescale() {
+ var n = domain().length,
+ reverse = range$$1[1] < range$$1[0],
+ start = range$$1[reverse - 0],
+ stop = range$$1[1 - reverse];
+ 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 = d3Array.range(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 ? (range$$1 = [+_[0], +_[1]], rescale()) : range$$1.slice();
+ };
+
+ scale.rangeRound = function(_) {
+ return range$$1 = [+_[0], +_[1]], 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 = paddingOuter = Math.max(0, Math.min(1, _)), rescale()) : paddingInner;
+ };
+
+ scale.paddingInner = function(_) {
+ return arguments.length ? (paddingInner = Math.max(0, Math.min(1, _)), rescale()) : paddingInner;
+ };
+
+ scale.paddingOuter = function(_) {
+ return arguments.length ? (paddingOuter = Math.max(0, Math.min(1, _)), rescale()) : paddingOuter;
+ };
+
+ scale.align = function(_) {
+ return arguments.length ? (align = Math.max(0, Math.min(1, _)), rescale()) : align;
+ };
+
+ scale.copy = function() {
+ return band()
+ .domain(domain())
+ .range(range$$1)
+ .round(round)
+ .paddingInner(paddingInner)
+ .paddingOuter(paddingOuter)
+ .align(align);
+ };
+
+ return rescale();
+}
+
+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() {
+ return pointish(band().paddingInner(1));
+}
+
+var constant = function(x) {
+ return function() {
+ return x;
+ };
+};
+
+var number = function(x) {
+ return +x;
+};
+
+var unit = [0, 1];
+
+function deinterpolateLinear(a, b) {
+ return (b -= (a = +a))
+ ? function(x) { return (x - a) / b; }
+ : constant(b);
+}
+
+function deinterpolateClamp(deinterpolate) {
+ return function(a, b) {
+ var d = deinterpolate(a = +a, b = +b);
+ return function(x) { return x <= a ? 0 : x >= b ? 1 : d(x); };
+ };
+}
+
+function reinterpolateClamp(reinterpolate) {
+ return function(a, b) {
+ var r = reinterpolate(a = +a, b = +b);
+ return function(t) { return t <= 0 ? a : t >= 1 ? b : r(t); };
+ };
+}
+
+function bimap(domain, range$$1, deinterpolate, reinterpolate) {
+ var d0 = domain[0], d1 = domain[1], r0 = range$$1[0], r1 = range$$1[1];
+ if (d1 < d0) d0 = deinterpolate(d1, d0), r0 = reinterpolate(r1, r0);
+ else d0 = deinterpolate(d0, d1), r0 = reinterpolate(r0, r1);
+ return function(x) { return r0(d0(x)); };
+}
+
+function polymap(domain, range$$1, deinterpolate, reinterpolate) {
+ var j = Math.min(domain.length, range$$1.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$$1 = range$$1.slice().reverse();
+ }
+
+ while (++i < j) {
+ d[i] = deinterpolate(domain[i], domain[i + 1]);
+ r[i] = reinterpolate(range$$1[i], range$$1[i + 1]);
+ }
+
+ return function(x) {
+ var i = d3Array.bisect(domain, x, 1, j) - 1;
+ return r[i](d[i](x));
+ };
+}
+
+function copy(source, target) {
+ return target
+ .domain(source.domain())
+ .range(source.range())
+ .interpolate(source.interpolate())
+ .clamp(source.clamp());
+}
+
+// deinterpolate(a, b)(x) takes a domain value x in [a,b] and returns the corresponding parameter t in [0,1].
+// reinterpolate(a, b)(t) takes a parameter t in [0,1] and returns the corresponding domain value x in [a,b].
+function continuous(deinterpolate, reinterpolate) {
+ var domain = unit,
+ range$$1 = unit,
+ interpolate$$1 = d3Interpolate.interpolate,
+ clamp = false,
+ piecewise,
+ output,
+ input;
+
+ function rescale() {
+ piecewise = Math.min(domain.length, range$$1.length) > 2 ? polymap : bimap;
+ output = input = null;
+ return scale;
+ }
+
+ function scale(x) {
+ return (output || (output = piecewise(domain, range$$1, clamp ? deinterpolateClamp(deinterpolate) : deinterpolate, interpolate$$1)))(+x);
+ }
+
+ scale.invert = function(y) {
+ return (input || (input = piecewise(range$$1, domain, deinterpolateLinear, clamp ? reinterpolateClamp(reinterpolate) : reinterpolate)))(+y);
+ };
+
+ scale.domain = function(_) {
+ return arguments.length ? (domain = map$1.call(_, number), rescale()) : domain.slice();
+ };
+
+ scale.range = function(_) {
+ return arguments.length ? (range$$1 = slice.call(_), rescale()) : range$$1.slice();
+ };
+
+ scale.rangeRound = function(_) {
+ return range$$1 = slice.call(_), interpolate$$1 = d3Interpolate.interpolateRound, rescale();
+ };
+
+ scale.clamp = function(_) {
+ return arguments.length ? (clamp = !!_, rescale()) : clamp;
+ };
+
+ scale.interpolate = function(_) {
+ return arguments.length ? (interpolate$$1 = _, rescale()) : interpolate$$1;
+ };
+
+ return rescale();
+}
+
+var tickFormat = function(domain, count, specifier) {
+ var start = domain[0],
+ stop = domain[domain.length - 1],
+ step = d3Array.tickStep(start, stop, count == null ? 10 : count),
+ precision;
+ specifier = d3Format.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 = d3Format.precisionPrefix(step, value))) specifier.precision = precision;
+ return d3Format.formatPrefix(specifier, value);
+ }
+ case "":
+ case "e":
+ case "g":
+ case "p":
+ case "r": {
+ if (specifier.precision == null && !isNaN(precision = d3Format.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 = d3Format.precisionFixed(step))) specifier.precision = precision - (specifier.type === "%") * 2;
+ break;
+ }
+ }
+ return d3Format.format(specifier);
+};
+
+function linearish(scale) {
+ var domain = scale.domain;
+
+ scale.ticks = function(count) {
+ var d = domain();
+ return d3Array.ticks(d[0], d[d.length - 1], count == null ? 10 : count);
+ };
+
+ scale.tickFormat = function(count, specifier) {
+ return tickFormat(domain(), count, specifier);
+ };
+
+ scale.nice = function(count) {
+ if (count == null) count = 10;
+
+ var d = domain(),
+ i0 = 0,
+ i1 = d.length - 1,
+ start = d[i0],
+ stop = d[i1],
+ step;
+
+ if (stop < start) {
+ step = start, start = stop, stop = step;
+ step = i0, i0 = i1, i1 = step;
+ }
+
+ step = d3Array.tickIncrement(start, stop, count);
+
+ if (step > 0) {
+ start = Math.floor(start / step) * step;
+ stop = Math.ceil(stop / step) * step;
+ step = d3Array.tickIncrement(start, stop, count);
+ } else if (step < 0) {
+ start = Math.ceil(start * step) / step;
+ stop = Math.floor(stop * step) / step;
+ step = d3Array.tickIncrement(start, stop, count);
+ }
+
+ if (step > 0) {
+ d[i0] = Math.floor(start / step) * step;
+ d[i1] = Math.ceil(stop / step) * step;
+ domain(d);
+ } else if (step < 0) {
+ d[i0] = Math.ceil(start * step) / step;
+ d[i1] = Math.floor(stop * step) / step;
+ domain(d);
+ }
+
+ return scale;
+ };
+
+ return scale;
+}
+
+function linear() {
+ var scale = continuous(deinterpolateLinear, d3Interpolate.interpolateNumber);
+
+ scale.copy = function() {
+ return copy(scale, linear());
+ };
+
+ return linearish(scale);
+}
+
+function identity() {
+ var domain = [0, 1];
+
+ function scale(x) {
+ return +x;
+ }
+
+ scale.invert = scale;
+
+ scale.domain = scale.range = function(_) {
+ return arguments.length ? (domain = map$1.call(_, number), scale) : domain.slice();
+ };
+
+ scale.copy = function() {
+ return identity().domain(domain);
+ };
+
+ return linearish(scale);
+}
+
+var nice = function(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 deinterpolate(a, b) {
+ return (b = Math.log(b / a))
+ ? function(x) { return Math.log(x / a) / b; }
+ : constant(b);
+}
+
+function reinterpolate(a, b) {
+ return a < 0
+ ? function(t) { return -Math.pow(-b, t) * Math.pow(-a, 1 - t); }
+ : function(t) { return Math.pow(b, t) * Math.pow(a, 1 - t); };
+}
+
+function pow10(x) {
+ return isFinite(x) ? +("1e" + x) : x < 0 ? 0 : x;
+}
+
+function powp(base) {
+ return base === 10 ? pow10
+ : base === Math.E ? Math.exp
+ : function(x) { return 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), function(x) { return Math.log(x) / base; });
+}
+
+function reflect(f) {
+ return function(x) {
+ return -f(-x);
+ };
+}
+
+function log() {
+ var scale = continuous(deinterpolate, reinterpolate).domain([1, 10]),
+ domain = scale.domain,
+ base = 10,
+ logs = logp(10),
+ pows = powp(10);
+
+ function rescale() {
+ logs = logp(base), pows = powp(base);
+ if (domain()[0] < 0) logs = reflect(logs), pows = reflect(pows);
+ return scale;
+ }
+
+ scale.base = function(_) {
+ return arguments.length ? (base = +_, rescale()) : base;
+ };
+
+ scale.domain = function(_) {
+ return arguments.length ? (domain(_), rescale()) : domain();
+ };
+
+ scale.ticks = function(count) {
+ var d = domain(),
+ u = d[0],
+ v = d[d.length - 1],
+ r;
+
+ if (r = v < u) i = u, u = v, v = i;
+
+ var i = logs(u),
+ j = logs(v),
+ p,
+ k,
+ t,
+ n = count == null ? 10 : +count,
+ z = [];
+
+ if (!(base % 1) && j - i < n) {
+ i = Math.round(i) - 1, j = Math.round(j) + 1;
+ if (u > 0) for (; i < j; ++i) {
+ for (k = 1, p = pows(i); k < base; ++k) {
+ t = p * k;
+ if (t < u) continue;
+ if (t > v) break;
+ z.push(t);
+ }
+ } else for (; i < j; ++i) {
+ for (k = base - 1, p = pows(i); k >= 1; --k) {
+ t = p * k;
+ if (t < u) continue;
+ if (t > v) break;
+ z.push(t);
+ }
+ }
+ } else {
+ z = d3Array.ticks(i, j, Math.min(j - i, n)).map(pows);
+ }
+
+ return r ? z.reverse() : z;
+ };
+
+ scale.tickFormat = function(count, specifier) {
+ if (specifier == null) specifier = base === 10 ? ".0e" : ",";
+ if (typeof specifier !== "function") specifier = d3Format.format(specifier);
+ if (count === Infinity) return specifier;
+ if (count == null) count = 10;
+ var k = Math.max(1, base * count / scale.ticks().length); // TODO fast estimate?
+ return function(d) {
+ var i = d / pows(Math.round(logs(d)));
+ if (i * base < base - 0.5) i *= base;
+ return i <= k ? specifier(d) : "";
+ };
+ };
+
+ scale.nice = function() {
+ return domain(nice(domain(), {
+ floor: function(x) { return pows(Math.floor(logs(x))); },
+ ceil: function(x) { return pows(Math.ceil(logs(x))); }
+ }));
+ };
+
+ scale.copy = function() {
+ return copy(scale, log().base(base));
+ };
+
+ return scale;
+}
+
+function raise(x, exponent) {
+ return x < 0 ? -Math.pow(-x, exponent) : Math.pow(x, exponent);
+}
+
+function pow() {
+ var exponent = 1,
+ scale = continuous(deinterpolate, reinterpolate),
+ domain = scale.domain;
+
+ function deinterpolate(a, b) {
+ return (b = raise(b, exponent) - (a = raise(a, exponent)))
+ ? function(x) { return (raise(x, exponent) - a) / b; }
+ : constant(b);
+ }
+
+ function reinterpolate(a, b) {
+ b = raise(b, exponent) - (a = raise(a, exponent));
+ return function(t) { return raise(a + b * t, 1 / exponent); };
+ }
+
+ scale.exponent = function(_) {
+ return arguments.length ? (exponent = +_, domain(domain())) : exponent;
+ };
+
+ scale.copy = function() {
+ return copy(scale, pow().exponent(exponent));
+ };
+
+ return linearish(scale);
+}
+
+function sqrt() {
+ return pow().exponent(0.5);
+}
+
+function quantile$1() {
+ var domain = [],
+ range$$1 = [],
+ thresholds = [];
+
+ function rescale() {
+ var i = 0, n = Math.max(1, range$$1.length);
+ thresholds = new Array(n - 1);
+ while (++i < n) thresholds[i - 1] = d3Array.quantile(domain, i / n);
+ return scale;
+ }
+
+ function scale(x) {
+ if (!isNaN(x = +x)) return range$$1[d3Array.bisect(thresholds, x)];
+ }
+
+ scale.invertExtent = function(y) {
+ var i = range$$1.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 (var i = 0, n = _.length, d; i < n; ++i) if (d = _[i], d != null && !isNaN(d = +d)) domain.push(d);
+ domain.sort(d3Array.ascending);
+ return rescale();
+ };
+
+ scale.range = function(_) {
+ return arguments.length ? (range$$1 = slice.call(_), rescale()) : range$$1.slice();
+ };
+
+ scale.quantiles = function() {
+ return thresholds.slice();
+ };
+
+ scale.copy = function() {
+ return quantile$1()
+ .domain(domain)
+ .range(range$$1);
+ };
+
+ return scale;
+}
+
+function quantize() {
+ var x0 = 0,
+ x1 = 1,
+ n = 1,
+ domain = [0.5],
+ range$$1 = [0, 1];
+
+ function scale(x) {
+ if (x <= x) return range$$1[d3Array.bisect(domain, x, 0, n)];
+ }
+
+ 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 = +_[0], x1 = +_[1], rescale()) : [x0, x1];
+ };
+
+ scale.range = function(_) {
+ return arguments.length ? (n = (range$$1 = slice.call(_)).length - 1, rescale()) : range$$1.slice();
+ };
+
+ scale.invertExtent = function(y) {
+ var i = range$$1.indexOf(y);
+ return i < 0 ? [NaN, NaN]
+ : i < 1 ? [x0, domain[0]]
+ : i >= n ? [domain[n - 1], x1]
+ : [domain[i - 1], domain[i]];
+ };
+
+ scale.copy = function() {
+ return quantize()
+ .domain([x0, x1])
+ .range(range$$1);
+ };
+
+ return linearish(scale);
+}
+
+function threshold() {
+ var domain = [0.5],
+ range$$1 = [0, 1],
+ n = 1;
+
+ function scale(x) {
+ if (x <= x) return range$$1[d3Array.bisect(domain, x, 0, n)];
+ }
+
+ scale.domain = function(_) {
+ return arguments.length ? (domain = slice.call(_), n = Math.min(domain.length, range$$1.length - 1), scale) : domain.slice();
+ };
+
+ scale.range = function(_) {
+ return arguments.length ? (range$$1 = slice.call(_), n = Math.min(domain.length, range$$1.length - 1), scale) : range$$1.slice();
+ };
+
+ scale.invertExtent = function(y) {
+ var i = range$$1.indexOf(y);
+ return [domain[i - 1], domain[i]];
+ };
+
+ scale.copy = function() {
+ return threshold()
+ .domain(domain)
+ .range(range$$1);
+ };
+
+ return scale;
+}
+
+var durationSecond = 1000;
+var durationMinute = durationSecond * 60;
+var durationHour = durationMinute * 60;
+var durationDay = durationHour * 24;
+var durationWeek = durationDay * 7;
+var durationMonth = durationDay * 30;
+var durationYear = durationDay * 365;
+
+function date(t) {
+ return new Date(t);
+}
+
+function number$1(t) {
+ return t instanceof Date ? +t : +new Date(+t);
+}
+
+function calendar(year, month, week, day, hour, minute, second, millisecond, format$$1) {
+ var scale = continuous(deinterpolateLinear, d3Interpolate.interpolateNumber),
+ invert = scale.invert,
+ domain = scale.domain;
+
+ var formatMillisecond = format$$1(".%L"),
+ formatSecond = format$$1(":%S"),
+ formatMinute = format$$1("%I:%M"),
+ formatHour = format$$1("%I %p"),
+ formatDay = format$$1("%a %d"),
+ formatWeek = format$$1("%b %d"),
+ formatMonth = format$$1("%B"),
+ formatYear = format$$1("%Y");
+
+ var tickIntervals = [
+ [second, 1, durationSecond],
+ [second, 5, 5 * durationSecond],
+ [second, 15, 15 * durationSecond],
+ [second, 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 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);
+ }
+
+ function tickInterval(interval, start, stop, step) {
+ if (interval == null) interval = 10;
+
+ // If a desired tick count is specified, pick a reasonable tick interval
+ // based on the extent of the domain and a rough estimate of tick size.
+ // Otherwise, assume interval is already a time interval and use it.
+ if (typeof interval === "number") {
+ var target = Math.abs(stop - start) / interval,
+ i = d3Array.bisector(function(i) { return i[2]; }).right(tickIntervals, target);
+ if (i === tickIntervals.length) {
+ step = d3Array.tickStep(start / durationYear, stop / durationYear, interval);
+ interval = year;
+ } else if (i) {
+ i = tickIntervals[target / tickIntervals[i - 1][2] < tickIntervals[i][2] / target ? i - 1 : i];
+ step = i[1];
+ interval = i[0];
+ } else {
+ step = Math.max(d3Array.tickStep(start, stop, interval), 1);
+ interval = millisecond;
+ }
+ }
+
+ return step == null ? interval : interval.every(step);
+ }
+
+ scale.invert = function(y) {
+ return new Date(invert(y));
+ };
+
+ scale.domain = function(_) {
+ return arguments.length ? domain(map$1.call(_, number$1)) : domain().map(date);
+ };
+
+ scale.ticks = function(interval, step) {
+ var d = domain(),
+ t0 = d[0],
+ t1 = d[d.length - 1],
+ r = t1 < t0,
+ t;
+ if (r) t = t0, t0 = t1, t1 = t;
+ t = tickInterval(interval, t0, t1, step);
+ t = t ? t.range(t0, t1 + 1) : []; // inclusive stop
+ return r ? t.reverse() : t;
+ };
+
+ scale.tickFormat = function(count, specifier) {
+ return specifier == null ? tickFormat : format$$1(specifier);
+ };
+
+ scale.nice = function(interval, step) {
+ var d = domain();
+ return (interval = tickInterval(interval, d[0], d[d.length - 1], step))
+ ? domain(nice(d, interval))
+ : scale;
+ };
+
+ scale.copy = function() {
+ return copy(scale, calendar(year, month, week, day, hour, minute, second, millisecond, format$$1));
+ };
+
+ return scale;
+}
+
+var time = function() {
+ return calendar(d3Time.timeYear, d3Time.timeMonth, d3Time.timeWeek, d3Time.timeDay, d3Time.timeHour, d3Time.timeMinute, d3Time.timeSecond, d3Time.timeMillisecond, d3TimeFormat.timeFormat).domain([new Date(2000, 0, 1), new Date(2000, 0, 2)]);
+};
+
+var utcTime = function() {
+ return calendar(d3Time.utcYear, d3Time.utcMonth, d3Time.utcWeek, d3Time.utcDay, d3Time.utcHour, d3Time.utcMinute, d3Time.utcSecond, d3Time.utcMillisecond, d3TimeFormat.utcFormat).domain([Date.UTC(2000, 0, 1), Date.UTC(2000, 0, 2)]);
+};
+
+var colors = function(s) {
+ return s.match(/.{6}/g).map(function(x) {
+ return "#" + x;
+ });
+};
+
+var category10 = colors("1f77b4ff7f0e2ca02cd627289467bd8c564be377c27f7f7fbcbd2217becf");
+
+var category20b = colors("393b795254a36b6ecf9c9ede6379398ca252b5cf6bcedb9c8c6d31bd9e39e7ba52e7cb94843c39ad494ad6616be7969c7b4173a55194ce6dbdde9ed6");
+
+var category20c = colors("3182bd6baed69ecae1c6dbefe6550dfd8d3cfdae6bfdd0a231a35474c476a1d99bc7e9c0756bb19e9ac8bcbddcdadaeb636363969696bdbdbdd9d9d9");
+
+var category20 = colors("1f77b4aec7e8ff7f0effbb782ca02c98df8ad62728ff98969467bdc5b0d58c564bc49c94e377c2f7b6d27f7f7fc7c7c7bcbd22dbdb8d17becf9edae5");
+
+var cubehelix$1 = d3Interpolate.interpolateCubehelixLong(d3Color.cubehelix(300, 0.5, 0.0), d3Color.cubehelix(-240, 0.5, 1.0));
+
+var warm = d3Interpolate.interpolateCubehelixLong(d3Color.cubehelix(-100, 0.75, 0.35), d3Color.cubehelix(80, 1.50, 0.8));
+
+var cool = d3Interpolate.interpolateCubehelixLong(d3Color.cubehelix(260, 0.75, 0.35), d3Color.cubehelix(80, 1.50, 0.8));
+
+var rainbow = d3Color.cubehelix();
+
+var rainbow$1 = function(t) {
+ if (t < 0 || t > 1) t -= Math.floor(t);
+ var ts = Math.abs(t - 0.5);
+ rainbow.h = 360 * t - 100;
+ rainbow.s = 1.5 - 1.5 * ts;
+ rainbow.l = 0.8 - 0.9 * ts;
+ return rainbow + "";
+};
+
+function ramp(range$$1) {
+ var n = range$$1.length;
+ return function(t) {
+ return range$$1[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 sequential(interpolator) {
+ var x0 = 0,
+ x1 = 1,
+ clamp = false;
+
+ function scale(x) {
+ var t = (x - x0) / (x1 - x0);
+ return interpolator(clamp ? Math.max(0, Math.min(1, t)) : t);
+ }
+
+ scale.domain = function(_) {
+ return arguments.length ? (x0 = +_[0], x1 = +_[1], scale) : [x0, x1];
+ };
+
+ scale.clamp = function(_) {
+ return arguments.length ? (clamp = !!_, scale) : clamp;
+ };
+
+ scale.interpolator = function(_) {
+ return arguments.length ? (interpolator = _, scale) : interpolator;
+ };
+
+ scale.copy = function() {
+ return sequential(interpolator).domain([x0, x1]).clamp(clamp);
+ };
+
+ return linearish(scale);
+}
+
+exports.scaleBand = band;
+exports.scalePoint = point;
+exports.scaleIdentity = identity;
+exports.scaleLinear = linear;
+exports.scaleLog = log;
+exports.scaleOrdinal = ordinal;
+exports.scaleImplicit = implicit;
+exports.scalePow = pow;
+exports.scaleSqrt = sqrt;
+exports.scaleQuantile = quantile$1;
+exports.scaleQuantize = quantize;
+exports.scaleThreshold = threshold;
+exports.scaleTime = time;
+exports.scaleUtc = utcTime;
+exports.schemeCategory10 = category10;
+exports.schemeCategory20b = category20b;
+exports.schemeCategory20c = category20c;
+exports.schemeCategory20 = category20;
+exports.interpolateCubehelixDefault = cubehelix$1;
+exports.interpolateRainbow = rainbow$1;
+exports.interpolateWarm = warm;
+exports.interpolateCool = cool;
+exports.interpolateViridis = viridis;
+exports.interpolateMagma = magma;
+exports.interpolateInferno = inferno;
+exports.interpolatePlasma = plasma;
+exports.scaleSequential = sequential;
+
+Object.defineProperty(exports, '__esModule', { value: true });
+
+})));
+
+},{"d3-array":23,"d3-collection":27,"d3-color":28,"d3-format":34,"d3-interpolate":37,"d3-time":48,"d3-time-format":47}],45:[function(require,module,exports){
+// https://d3js.org/d3-selection/ Version 1.3.0. Copyright 2018 Mike Bostock.
+(function (global, factory) {
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
+ typeof define === 'function' && define.amd ? define(['exports'], factory) :
+ (factory((global.d3 = global.d3 || {})));
+}(this, (function (exports) { 'use strict';
+
+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;
+}
+
+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() {}
+
+function selector(selector) {
+ return selector == null ? none : 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(subgroups, this._parents);
+}
+
+function empty() {
+ return [];
+}
+
+function selectorAll(selector) {
+ return selector == null ? empty : function() {
+ return this.querySelectorAll(selector);
+ };
+}
+
+function selection_selectAll(select) {
+ 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]) {
+ subgroups.push(select.call(node, node.__data__, i, group));
+ parents.push(node);
+ }
+ }
+ }
+
+ return new Selection(subgroups, parents);
+}
+
+var matcher = function(selector) {
+ return function() {
+ return this.matches(selector);
+ };
+};
+
+if (typeof document !== "undefined") {
+ var element = document.documentElement;
+ if (!element.matches) {
+ var vendorMatches = element.webkitMatchesSelector
+ || element.msMatchesSelector
+ || element.mozMatchesSelector
+ || element.oMatchesSelector;
+ matcher = function(selector) {
+ return function() {
+ return vendorMatches.call(this, selector);
+ };
+ };
+ }
+}
+
+var matcher$1 = matcher;
+
+function selection_filter(match) {
+ if (typeof match !== "function") match = matcher$1(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(subgroups, this._parents);
+}
+
+function sparse(update) {
+ return new Array(update.length);
+}
+
+function selection_enter() {
+ return new Selection(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(x) {
+ return function() {
+ return x;
+ };
+}
+
+var keyPrefix = "$"; // Protect against keys like “__proto__”.
+
+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 = {},
+ 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 = keyPrefix + key.call(node, node.__data__, i, group);
+ if (keyValue in nodeByKeyValue) {
+ exit[i] = node;
+ } else {
+ nodeByKeyValue[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 = keyPrefix + key.call(parent, data[i], i, data);
+ if (node = nodeByKeyValue[keyValue]) {
+ update[i] = node;
+ node.__data__ = data[i];
+ nodeByKeyValue[keyValue] = null;
+ } 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[keyValues[i]] === node)) {
+ exit[i] = node;
+ }
+ }
+}
+
+function selection_data(value, key) {
+ if (!value) {
+ data = new Array(this.size()), j = -1;
+ this.each(function(d) { data[++j] = d; });
+ return data;
+ }
+
+ var bind = key ? bindKey : bindIndex,
+ parents = this._parents,
+ groups = this._groups;
+
+ if (typeof value !== "function") value = constant(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 = 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(update, parents);
+ update._enter = enter;
+ update._exit = exit;
+ return update;
+}
+
+function selection_exit() {
+ return new Selection(this._exit || this._groups.map(sparse), this._parents);
+}
+
+function selection_merge(selection$$1) {
+
+ for (var groups0 = this._groups, groups1 = selection$$1._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(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 && next !== node.nextSibling) next.parentNode.insertBefore(node, next);
+ next = node;
+ }
+ }
+ }
+
+ return this;
+}
+
+function selection_sort(compare) {
+ if (!compare) compare = ascending;
+
+ 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(sortgroups, this._parents).order();
+}
+
+function ascending(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() {
+ var nodes = new Array(this.size()), i = -1;
+ this.each(function() { nodes[++i] = this; });
+ return nodes;
+}
+
+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() {
+ var size = 0;
+ this.each(function() { ++size; });
+ 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(name) {
+ return function() {
+ this.removeAttribute(name);
+ };
+}
+
+function attrRemoveNS(fullname) {
+ return function() {
+ this.removeAttributeNS(fullname.space, fullname.local);
+ };
+}
+
+function attrConstant(name, value) {
+ return function() {
+ this.setAttribute(name, value);
+ };
+}
+
+function attrConstantNS(fullname, value) {
+ return function() {
+ this.setAttributeNS(fullname.space, fullname.local, value);
+ };
+}
+
+function attrFunction(name, value) {
+ return function() {
+ var v = value.apply(this, arguments);
+ if (v == null) this.removeAttribute(name);
+ else this.setAttribute(name, v);
+ };
+}
+
+function attrFunctionNS(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 : attrRemove) : (typeof value === "function"
+ ? (fullname.local ? attrFunctionNS : attrFunction)
+ : (fullname.local ? attrConstantNS : attrConstant)))(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(name) {
+ return function() {
+ this.style.removeProperty(name);
+ };
+}
+
+function styleConstant(name, value, priority) {
+ return function() {
+ this.style.setProperty(name, value, priority);
+ };
+}
+
+function styleFunction(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 : typeof value === "function"
+ ? styleFunction
+ : styleConstant)(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(value) {
+ return function() {
+ this.textContent = value;
+ };
+}
+
+function textFunction(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
+ : textConstant)(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() {
+ return this.parentNode.insertBefore(this.cloneNode(false), this.nextSibling);
+}
+
+function selection_cloneDeep() {
+ return this.parentNode.insertBefore(this.cloneNode(true), this.nextSibling);
+}
+
+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__;
+}
+
+var filterEvents = {};
+
+exports.event = null;
+
+if (typeof document !== "undefined") {
+ var element$1 = document.documentElement;
+ if (!("onmouseenter" in element$1)) {
+ filterEvents = {mouseenter: "mouseover", mouseleave: "mouseout"};
+ }
+}
+
+function filterContextListener(listener, index, group) {
+ listener = contextListener(listener, index, group);
+ return function(event) {
+ var related = event.relatedTarget;
+ if (!related || (related !== this && !(related.compareDocumentPosition(this) & 8))) {
+ listener.call(this, event);
+ }
+ };
+}
+
+function contextListener(listener, index, group) {
+ return function(event1) {
+ var event0 = exports.event; // Events can be reentrant (e.g., focus).
+ exports.event = event1;
+ try {
+ listener.call(this, this.__data__, index, group);
+ } finally {
+ exports.event = event0;
+ }
+ };
+}
+
+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.capture);
+ } else {
+ on[++i] = o;
+ }
+ }
+ if (++i) on.length = i;
+ else delete this.__on;
+ };
+}
+
+function onAdd(typename, value, capture) {
+ var wrap = filterEvents.hasOwnProperty(typename.type) ? filterContextListener : contextListener;
+ return function(d, i, group) {
+ var on = this.__on, o, listener = wrap(value, i, group);
+ 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.capture);
+ this.addEventListener(o.type, o.listener = listener, o.capture = capture);
+ o.value = value;
+ return;
+ }
+ }
+ this.addEventListener(typename.type, listener, capture);
+ o = {type: typename.type, name: typename.name, value: value, listener: listener, capture: capture};
+ if (!on) this.__on = [o];
+ else on.push(o);
+ };
+}
+
+function selection_on(typename, value, capture) {
+ 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;
+ if (capture == null) capture = false;
+ for (i = 0; i < n; ++i) this.each(on(typenames[i], value, capture));
+ return this;
+}
+
+function customEvent(event1, listener, that, args) {
+ var event0 = exports.event;
+ event1.sourceEvent = exports.event;
+ exports.event = event1;
+ try {
+ return listener.apply(that, args);
+ } finally {
+ exports.event = event0;
+ }
+}
+
+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));
+}
+
+var root = [null];
+
+function Selection(groups, parents) {
+ this._groups = groups;
+ this._parents = parents;
+}
+
+function selection() {
+ return new Selection([[document.documentElement]], root);
+}
+
+Selection.prototype = selection.prototype = {
+ constructor: Selection,
+ select: selection_select,
+ selectAll: selection_selectAll,
+ filter: selection_filter,
+ data: selection_data,
+ enter: selection_enter,
+ exit: selection_exit,
+ merge: selection_merge,
+ 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
+};
+
+function select(selector) {
+ return typeof selector === "string"
+ ? new Selection([[document.querySelector(selector)]], [document.documentElement])
+ : new Selection([[selector]], root);
+}
+
+function create(name) {
+ return select(creator(name).call(document.documentElement));
+}
+
+var nextId = 0;
+
+function local() {
+ return new Local;
+}
+
+function Local() {
+ this._ = "@" + (++nextId).toString(36);
+}
+
+Local.prototype = local.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() {
+ var current = exports.event, source;
+ while (source = current.sourceEvent) current = source;
+ return current;
+}
+
+function point(node, event) {
+ 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];
+ }
+
+ var rect = node.getBoundingClientRect();
+ return [event.clientX - rect.left - node.clientLeft, event.clientY - rect.top - node.clientTop];
+}
+
+function mouse(node) {
+ var event = sourceEvent();
+ if (event.changedTouches) event = event.changedTouches[0];
+ return point(node, event);
+}
+
+function selectAll(selector) {
+ return typeof selector === "string"
+ ? new Selection([document.querySelectorAll(selector)], [document.documentElement])
+ : new Selection([selector == null ? [] : selector], root);
+}
+
+function touch(node, touches, identifier) {
+ if (arguments.length < 3) identifier = touches, touches = sourceEvent().changedTouches;
+
+ for (var i = 0, n = touches ? touches.length : 0, touch; i < n; ++i) {
+ if ((touch = touches[i]).identifier === identifier) {
+ return point(node, touch);
+ }
+ }
+
+ return null;
+}
+
+function touches(node, touches) {
+ if (touches == null) touches = sourceEvent().touches;
+
+ for (var i = 0, n = touches ? touches.length : 0, points = new Array(n); i < n; ++i) {
+ points[i] = point(node, touches[i]);
+ }
+
+ return points;
+}
+
+exports.create = create;
+exports.creator = creator;
+exports.local = local;
+exports.matcher = matcher$1;
+exports.mouse = mouse;
+exports.namespace = namespace;
+exports.namespaces = namespaces;
+exports.clientPoint = point;
+exports.select = select;
+exports.selectAll = selectAll;
+exports.selection = selection;
+exports.selector = selector;
+exports.selectorAll = selectorAll;
+exports.style = styleValue;
+exports.touch = touch;
+exports.touches = touches;
+exports.window = defaultView;
+exports.customEvent = customEvent;
+
+Object.defineProperty(exports, '__esModule', { value: true });
+
+})));
+
+},{}],46:[function(require,module,exports){
+// https://d3js.org/d3-shape/ Version 1.2.0. Copyright 2017 Mike Bostock.
+(function (global, factory) {
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('d3-path')) :
+ typeof define === 'function' && define.amd ? define(['exports', 'd3-path'], factory) :
+ (factory((global.d3 = global.d3 || {}),global.d3));
+}(this, (function (exports,d3Path) { 'use strict';
+
+var constant = function(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 = (x32 * (y0 - y2) - y32 * (x0 - x2)) / (y32 * x10 - x32 * y10);
+ 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)
+ };
+}
+
+var arc = function() {
+ var innerRadius = arcInnerRadius,
+ outerRadius = arcOuterRadius,
+ cornerRadius = constant(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 = d3Path.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);
+
+ // Restrict the corner radius according to the sector angle.
+ if (da < pi) {
+ var oc = da0 > epsilon ? intersect(x01, y01, x00, y00, x11, y11, x10, y10) : [x10, y10],
+ 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(+_), arc) : innerRadius;
+ };
+
+ arc.outerRadius = function(_) {
+ return arguments.length ? (outerRadius = typeof _ === "function" ? _ : constant(+_), arc) : outerRadius;
+ };
+
+ arc.cornerRadius = function(_) {
+ return arguments.length ? (cornerRadius = typeof _ === "function" ? _ : constant(+_), arc) : cornerRadius;
+ };
+
+ arc.padRadius = function(_) {
+ return arguments.length ? (padRadius = _ == null ? null : typeof _ === "function" ? _ : constant(+_), arc) : padRadius;
+ };
+
+ arc.startAngle = function(_) {
+ return arguments.length ? (startAngle = typeof _ === "function" ? _ : constant(+_), arc) : startAngle;
+ };
+
+ arc.endAngle = function(_) {
+ return arguments.length ? (endAngle = typeof _ === "function" ? _ : constant(+_), arc) : endAngle;
+ };
+
+ arc.padAngle = function(_) {
+ return arguments.length ? (padAngle = typeof _ === "function" ? _ : constant(+_), arc) : padAngle;
+ };
+
+ arc.context = function(_) {
+ return arguments.length ? ((context = _ == null ? null : _), arc) : context;
+ };
+
+ return arc;
+};
+
+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; // proceed
+ default: this._context.lineTo(x, y); break;
+ }
+ }
+};
+
+var curveLinear = function(context) {
+ return new Linear(context);
+};
+
+function x(p) {
+ return p[0];
+}
+
+function y(p) {
+ return p[1];
+}
+
+var line = function() {
+ var x$$1 = x,
+ y$$1 = y,
+ defined = constant(true),
+ context = null,
+ curve = curveLinear,
+ output = null;
+
+ function line(data) {
+ var i,
+ n = data.length,
+ d,
+ defined0 = false,
+ buffer;
+
+ if (context == null) output = curve(buffer = d3Path.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(+_), line) : x$$1;
+ };
+
+ line.y = function(_) {
+ return arguments.length ? (y$$1 = typeof _ === "function" ? _ : constant(+_), line) : y$$1;
+ };
+
+ line.defined = function(_) {
+ return arguments.length ? (defined = typeof _ === "function" ? _ : constant(!!_), 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;
+};
+
+var area = function() {
+ var x0 = x,
+ x1 = null,
+ y0 = constant(0),
+ y1 = y,
+ defined = constant(true),
+ context = null,
+ curve = curveLinear,
+ output = null;
+
+ function area(data) {
+ var i,
+ j,
+ k,
+ n = data.length,
+ d,
+ defined0 = false,
+ buffer,
+ x0z = new Array(n),
+ y0z = new Array(n);
+
+ if (context == null) output = curve(buffer = d3Path.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(+_), x1 = null, area) : x0;
+ };
+
+ area.x0 = function(_) {
+ return arguments.length ? (x0 = typeof _ === "function" ? _ : constant(+_), area) : x0;
+ };
+
+ area.x1 = function(_) {
+ return arguments.length ? (x1 = _ == null ? null : typeof _ === "function" ? _ : constant(+_), area) : x1;
+ };
+
+ area.y = function(_) {
+ return arguments.length ? (y0 = typeof _ === "function" ? _ : constant(+_), y1 = null, area) : y0;
+ };
+
+ area.y0 = function(_) {
+ return arguments.length ? (y0 = typeof _ === "function" ? _ : constant(+_), area) : y0;
+ };
+
+ area.y1 = function(_) {
+ return arguments.length ? (y1 = _ == null ? null : typeof _ === "function" ? _ : constant(+_), 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(!!_), 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;
+};
+
+var descending = function(a, b) {
+ return b < a ? -1 : b > a ? 1 : b >= a ? 0 : NaN;
+};
+
+var identity = function(d) {
+ return d;
+};
+
+var pie = function() {
+ var value = identity,
+ sortValues = descending,
+ sort = null,
+ startAngle = constant(0),
+ endAngle = constant(tau),
+ padAngle = constant(0);
+
+ function pie(data) {
+ var i,
+ n = 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(+_), 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(+_), pie) : startAngle;
+ };
+
+ pie.endAngle = function(_) {
+ return arguments.length ? (endAngle = typeof _ === "function" ? _ : constant(+_), pie) : endAngle;
+ };
+
+ pie.padAngle = function(_) {
+ return arguments.length ? (padAngle = typeof _ === "function" ? _ : constant(+_), pie) : padAngle;
+ };
+
+ return pie;
+};
+
+var curveRadialLinear = curveRadial(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(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(_)) : c()._curve;
+ };
+
+ return l;
+}
+
+var lineRadial$1 = function() {
+ return lineRadial(line().curve(curveRadialLinear));
+};
+
+var areaRadial = function() {
+ 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(_)) : c()._curve;
+ };
+
+ return a;
+};
+
+var pointRadial = function(x, y) {
+ return [(y = +y) * Math.cos(x -= Math.PI / 2), y * Math.sin(x)];
+};
+
+var slice = Array.prototype.slice;
+
+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 = d3Path.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(+_), link) : x$$1;
+ };
+
+ link.y = function(_) {
+ return arguments.length ? (y$$1 = typeof _ === "function" ? _ : constant(+_), 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$1(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$1);
+ 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);
+var 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;
+var kr = Math.sin(pi / 10) / Math.sin(7 * pi / 10);
+var kx = Math.sin(tau / 10) * kr;
+var 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;
+var s = Math.sqrt(3) / 2;
+var k = 1 / Math.sqrt(12);
+var 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
+];
+
+var symbol = function() {
+ var type = constant(circle),
+ size = constant(64),
+ context = null;
+
+ function symbol() {
+ var buffer;
+ if (!context) context = buffer = d3Path.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(_), symbol) : type;
+ };
+
+ symbol.size = function(_) {
+ return arguments.length ? (size = typeof _ === "function" ? _ : constant(+_), symbol) : size;
+ };
+
+ symbol.context = function(_) {
+ return arguments.length ? (context = _ == null ? null : _, symbol) : context;
+ };
+
+ return symbol;
+};
+
+var noop = function() {};
+
+function point(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(this, this._x1, this._y1); // proceed
+ 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); // proceed
+ default: point(this, x, y); break;
+ }
+ this._x0 = this._x1, this._x1 = x;
+ this._y0 = this._y1, this._y1 = y;
+ }
+};
+
+var basis = function(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(this, x, y); break;
+ }
+ this._x0 = this._x1, this._x1 = x;
+ this._y0 = this._y1, this._y1 = y;
+ }
+};
+
+var basisClosed = function(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; // proceed
+ default: point(this, x, y); break;
+ }
+ this._x0 = this._x1, this._x1 = x;
+ this._y0 = this._y1, this._y1 = y;
+ }
+};
+
+var basisOpen = function(context) {
+ return new BasisOpen(context);
+};
+
+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$1(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$1(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; // proceed
+ default: point$1(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$1(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; // proceed
+ default: point$1(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$2(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; // proceed
+ default: point$2(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$2(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; // proceed
+ default: point$2(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);
+ }
+};
+
+var linearClosed = function(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$3(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$3(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$3(this, slope2(this, t1 = slope3(this, x, y)), t1); break;
+ default: point$3(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];
+}
+
+var natural = function(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; // proceed
+ 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;
+ }
+};
+
+var step = function(context) {
+ return new Step(context, 0.5);
+};
+
+function stepBefore(context) {
+ return new Step(context, 0);
+}
+
+function stepAfter(context) {
+ return new Step(context, 1);
+}
+
+var none = function(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];
+ }
+ }
+};
+
+var none$1 = function(series) {
+ var n = series.length, o = new Array(n);
+ while (--n >= 0) o[n] = n;
+ return o;
+};
+
+function stackValue(d, key) {
+ return d[key];
+}
+
+var stack = function() {
+ var keys = constant([]),
+ order = none$1,
+ offset = none,
+ value = stackValue;
+
+ function stack(data) {
+ var kz = keys.apply(this, arguments),
+ i,
+ m = data.length,
+ n = kz.length,
+ sz = new Array(n),
+ oz;
+
+ for (i = 0; i < n; ++i) {
+ for (var ki = kz[i], si = sz[i] = new Array(m), j = 0, sij; j < m; ++j) {
+ si[j] = sij = [0, +value(data[j], ki, j, data)];
+ sij.data = data[j];
+ }
+ si.key = ki;
+ }
+
+ for (i = 0, oz = 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(slice.call(_)), stack) : keys;
+ };
+
+ stack.value = function(_) {
+ return arguments.length ? (value = typeof _ === "function" ? _ : constant(+_), stack) : value;
+ };
+
+ stack.order = function(_) {
+ return arguments.length ? (order = _ == null ? none$1 : typeof _ === "function" ? _ : constant(slice.call(_)), stack) : order;
+ };
+
+ stack.offset = function(_) {
+ return arguments.length ? (offset = _ == null ? none : _, stack) : offset;
+ };
+
+ return stack;
+};
+
+var expand = function(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(series, order);
+};
+
+var diverging = function(series, order) {
+ if (!((n = series.length) > 1)) 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] = yp;
+ }
+ }
+ }
+};
+
+var silhouette = function(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(series, order);
+};
+
+var wiggle = function(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(series, order);
+};
+
+var ascending = function(series) {
+ var sums = series.map(sum);
+ return none$1(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;
+}
+
+var descending$1 = function(series) {
+ return ascending(series).reverse();
+};
+
+var insideOut = function(series) {
+ var n = series.length,
+ i,
+ j,
+ sums = series.map(sum),
+ order = none$1(series).sort(function(a, b) { return sums[b] - sums[a]; }),
+ 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);
+};
+
+var reverse = function(series) {
+ return none$1(series).reverse();
+};
+
+exports.arc = arc;
+exports.area = area;
+exports.line = line;
+exports.pie = pie;
+exports.areaRadial = areaRadial;
+exports.radialArea = areaRadial;
+exports.lineRadial = lineRadial$1;
+exports.radialLine = lineRadial$1;
+exports.pointRadial = pointRadial;
+exports.linkHorizontal = linkHorizontal;
+exports.linkVertical = linkVertical;
+exports.linkRadial = linkRadial;
+exports.symbol = symbol;
+exports.symbols = symbols;
+exports.symbolCircle = circle;
+exports.symbolCross = cross;
+exports.symbolDiamond = diamond;
+exports.symbolSquare = square;
+exports.symbolStar = star;
+exports.symbolTriangle = triangle;
+exports.symbolWye = wye;
+exports.curveBasisClosed = basisClosed;
+exports.curveBasisOpen = basisOpen;
+exports.curveBasis = basis;
+exports.curveBundle = bundle;
+exports.curveCardinalClosed = cardinalClosed;
+exports.curveCardinalOpen = cardinalOpen;
+exports.curveCardinal = cardinal;
+exports.curveCatmullRomClosed = catmullRomClosed;
+exports.curveCatmullRomOpen = catmullRomOpen;
+exports.curveCatmullRom = catmullRom;
+exports.curveLinearClosed = linearClosed;
+exports.curveLinear = curveLinear;
+exports.curveMonotoneX = monotoneX;
+exports.curveMonotoneY = monotoneY;
+exports.curveNatural = natural;
+exports.curveStep = step;
+exports.curveStepAfter = stepAfter;
+exports.curveStepBefore = stepBefore;
+exports.stack = stack;
+exports.stackOffsetExpand = expand;
+exports.stackOffsetDiverging = diverging;
+exports.stackOffsetNone = none;
+exports.stackOffsetSilhouette = silhouette;
+exports.stackOffsetWiggle = wiggle;
+exports.stackOrderAscending = ascending;
+exports.stackOrderDescending = descending$1;
+exports.stackOrderInsideOut = insideOut;
+exports.stackOrderNone = none$1;
+exports.stackOrderReverse = reverse;
+
+Object.defineProperty(exports, '__esModule', { value: true });
+
+})));
+
+},{"d3-path":38}],47:[function(require,module,exports){
+// https://d3js.org/d3-time-format/ Version 2.1.1. Copyright 2017 Mike Bostock.
+(function (global, factory) {
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('d3-time')) :
+ typeof define === 'function' && define.amd ? define(['exports', 'd3-time'], factory) :
+ (factory((global.d3 = global.d3 || {}),global.d3));
+}(this, (function (exports,d3Time) { 'use strict';
+
+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 newYear(y) {
+ return {y: y, m: 0, d: 1, 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,
+ "H": formatHour24,
+ "I": formatHour12,
+ "j": formatDayOfYear,
+ "L": formatMilliseconds,
+ "m": formatMonthNumber,
+ "M": formatMinutes,
+ "p": formatPeriod,
+ "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,
+ "H": formatUTCHour24,
+ "I": formatUTCHour12,
+ "j": formatUTCDayOfYear,
+ "L": formatUTCMilliseconds,
+ "m": formatUTCMonthNumber,
+ "M": formatUTCMinutes,
+ "p": formatUTCPeriod,
+ "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,
+ "H": parseHour24,
+ "I": parseHour24,
+ "j": parseDayOfYear,
+ "L": parseMilliseconds,
+ "m": parseMonthNumber,
+ "M": parseMinutes,
+ "p": parsePeriod,
+ "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, newDate) {
+ return function(string) {
+ var d = newYear(1900),
+ 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);
+
+ // The am-pm flag is 0 for AM, and 1 for PM.
+ if ("p" in d) d.H = d.H % 12 + d.p * 12;
+
+ // 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(newYear(d.y)), day = week.getUTCDay();
+ week = day > 4 || day === 0 ? d3Time.utcMonday.ceil(week) : d3Time.utcMonday(week);
+ week = d3Time.utcDay.offset(week, (d.V - 1) * 7);
+ d.y = week.getUTCFullYear();
+ d.m = week.getUTCMonth();
+ d.d = week.getUTCDate() + (d.w + 6) % 7;
+ } else {
+ week = newDate(newYear(d.y)), day = week.getDay();
+ week = day > 4 || day === 0 ? d3Time.timeMonday.ceil(week) : d3Time.timeMonday(week);
+ week = d3Time.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(newYear(d.y)).getUTCDay() : newDate(newYear(d.y)).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 newDate(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[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[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[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[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[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 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)];
+ }
+
+ return {
+ format: function(specifier) {
+ var f = newFormat(specifier += "", formats);
+ f.toString = function() { return specifier; };
+ return f;
+ },
+ parse: function(specifier) {
+ var p = newParse(specifier += "", localDate);
+ 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, utcDate);
+ p.toString = function() { return specifier; };
+ return p;
+ }
+ };
+}
+
+var pads = {"-": "", "_": " ", "0": "0"};
+var numberRe = /^\s*\d+/;
+var percentRe = /^%/;
+var 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) {
+ var map = {}, i = -1, n = names.length;
+ while (++i < n) map[names[i].toLowerCase()] = i;
+ return map;
+}
+
+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 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.Q = (+n[0]) * 1000, 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 + d3Time.timeDay.count(d3Time.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(d3Time.timeSunday.count(d3Time.timeYear(d), d), p, 2);
+}
+
+function formatWeekNumberISO(d, p) {
+ var day = d.getDay();
+ d = (day >= 4 || day === 0) ? d3Time.timeThursday(d) : d3Time.timeThursday.ceil(d);
+ return pad(d3Time.timeThursday.count(d3Time.timeYear(d), d) + (d3Time.timeYear(d).getDay() === 4), p, 2);
+}
+
+function formatWeekdayNumberSunday(d) {
+ return d.getDay();
+}
+
+function formatWeekNumberMonday(d, p) {
+ return pad(d3Time.timeMonday.count(d3Time.timeYear(d), d), p, 2);
+}
+
+function formatYear(d, p) {
+ return pad(d.getFullYear() % 100, p, 2);
+}
+
+function formatFullYear(d, p) {
+ 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 + d3Time.utcDay.count(d3Time.utcYear(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(d3Time.utcSunday.count(d3Time.utcYear(d), d), p, 2);
+}
+
+function formatUTCWeekNumberISO(d, p) {
+ var day = d.getUTCDay();
+ d = (day >= 4 || day === 0) ? d3Time.utcThursday(d) : d3Time.utcThursday.ceil(d);
+ return pad(d3Time.utcThursday.count(d3Time.utcYear(d), d) + (d3Time.utcYear(d).getUTCDay() === 4), p, 2);
+}
+
+function formatUTCWeekdayNumberSunday(d) {
+ return d.getUTCDay();
+}
+
+function formatUTCWeekNumberMonday(d, p) {
+ return pad(d3Time.utcMonday.count(d3Time.utcYear(d), d), p, 2);
+}
+
+function formatUTCYear(d, p) {
+ return pad(d.getUTCFullYear() % 100, p, 2);
+}
+
+function formatUTCFullYear(d, p) {
+ 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;
+
+
+
+
+
+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);
+
+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);
+
+exports.timeFormatDefaultLocale = defaultLocale;
+exports.timeFormatLocale = formatLocale;
+exports.isoFormat = formatIso;
+exports.isoParse = parseIso;
+
+Object.defineProperty(exports, '__esModule', { value: true });
+
+})));
+
+},{"d3-time":48}],48:[function(require,module,exports){
+// https://d3js.org/d3-time/ Version 1.0.8. Copyright 2017 Mike Bostock.
+(function (global, factory) {
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
+ typeof define === 'function' && define.amd ? define(['exports'], factory) :
+ (factory((global.d3 = global.d3 || {})));
+}(this, (function (exports) { 'use strict';
+
+var t0 = new Date;
+var t1 = new Date;
+
+function newInterval(floori, offseti, count, field) {
+
+ function interval(date) {
+ return floori(date = new Date(+date)), date;
+ }
+
+ interval.floor = interval;
+
+ 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 milliseconds = millisecond.range;
+
+var durationSecond = 1e3;
+var durationMinute = 6e4;
+var durationHour = 36e5;
+var durationDay = 864e5;
+var durationWeek = 6048e5;
+
+var second = newInterval(function(date) {
+ date.setTime(Math.floor(date / durationSecond) * durationSecond);
+}, function(date, step) {
+ date.setTime(+date + step * durationSecond);
+}, function(start, end) {
+ return (end - start) / durationSecond;
+}, function(date) {
+ return date.getUTCSeconds();
+});
+
+var seconds = second.range;
+
+var minute = newInterval(function(date) {
+ date.setTime(Math.floor(date / durationMinute) * durationMinute);
+}, function(date, step) {
+ date.setTime(+date + step * durationMinute);
+}, function(start, end) {
+ return (end - start) / durationMinute;
+}, function(date) {
+ return date.getMinutes();
+});
+
+var minutes = minute.range;
+
+var hour = newInterval(function(date) {
+ var offset = date.getTimezoneOffset() * durationMinute % durationHour;
+ if (offset < 0) offset += durationHour;
+ date.setTime(Math.floor((+date - offset) / durationHour) * durationHour + offset);
+}, function(date, step) {
+ date.setTime(+date + step * durationHour);
+}, function(start, end) {
+ return (end - start) / durationHour;
+}, function(date) {
+ return date.getHours();
+});
+
+var hours = hour.range;
+
+var day = newInterval(function(date) {
+ date.setHours(0, 0, 0, 0);
+}, function(date, step) {
+ date.setDate(date.getDate() + step);
+}, function(start, end) {
+ return (end - start - (end.getTimezoneOffset() - start.getTimezoneOffset()) * durationMinute) / durationDay;
+}, function(date) {
+ return date.getDate() - 1;
+});
+
+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 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 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 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 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 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 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 utcYears = utcYear.range;
+
+exports.timeInterval = newInterval;
+exports.timeMillisecond = millisecond;
+exports.timeMilliseconds = milliseconds;
+exports.utcMillisecond = millisecond;
+exports.utcMilliseconds = milliseconds;
+exports.timeSecond = second;
+exports.timeSeconds = seconds;
+exports.utcSecond = second;
+exports.utcSeconds = seconds;
+exports.timeMinute = minute;
+exports.timeMinutes = minutes;
+exports.timeHour = hour;
+exports.timeHours = hours;
+exports.timeDay = day;
+exports.timeDays = days;
+exports.timeWeek = sunday;
+exports.timeWeeks = sundays;
+exports.timeSunday = sunday;
+exports.timeSundays = sundays;
+exports.timeMonday = monday;
+exports.timeMondays = mondays;
+exports.timeTuesday = tuesday;
+exports.timeTuesdays = tuesdays;
+exports.timeWednesday = wednesday;
+exports.timeWednesdays = wednesdays;
+exports.timeThursday = thursday;
+exports.timeThursdays = thursdays;
+exports.timeFriday = friday;
+exports.timeFridays = fridays;
+exports.timeSaturday = saturday;
+exports.timeSaturdays = saturdays;
+exports.timeMonth = month;
+exports.timeMonths = months;
+exports.timeYear = year;
+exports.timeYears = years;
+exports.utcMinute = utcMinute;
+exports.utcMinutes = utcMinutes;
+exports.utcHour = utcHour;
+exports.utcHours = utcHours;
+exports.utcDay = utcDay;
+exports.utcDays = utcDays;
+exports.utcWeek = utcSunday;
+exports.utcWeeks = utcSundays;
+exports.utcSunday = utcSunday;
+exports.utcSundays = utcSundays;
+exports.utcMonday = utcMonday;
+exports.utcMondays = utcMondays;
+exports.utcTuesday = utcTuesday;
+exports.utcTuesdays = utcTuesdays;
+exports.utcWednesday = utcWednesday;
+exports.utcWednesdays = utcWednesdays;
+exports.utcThursday = utcThursday;
+exports.utcThursdays = utcThursdays;
+exports.utcFriday = utcFriday;
+exports.utcFridays = utcFridays;
+exports.utcSaturday = utcSaturday;
+exports.utcSaturdays = utcSaturdays;
+exports.utcMonth = utcMonth;
+exports.utcMonths = utcMonths;
+exports.utcYear = utcYear;
+exports.utcYears = utcYears;
+
+Object.defineProperty(exports, '__esModule', { value: true });
+
+})));
+
+},{}],49:[function(require,module,exports){
+// https://d3js.org/d3-timer/ Version 1.0.7. Copyright 2017 Mike Bostock.
+(function (global, factory) {
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
+ typeof define === 'function' && define.amd ? define(['exports'], factory) :
+ (factory((global.d3 = global.d3 || {})));
+}(this, (function (exports) { 'use strict';
+
+var frame = 0;
+var timeout = 0;
+var interval = 0;
+var pokeDelay = 1000;
+var taskHead;
+var taskTail;
+var clockLast = 0;
+var clockNow = 0;
+var clockSkew = 0;
+var clock = typeof performance === "object" && performance.now ? performance : Date;
+var 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(null, e);
+ t = t._next;
+ }
+ --frame;
+}
+
+function wake() {
+ clockNow = (clockLast = clock.now()) + clockSkew;
+ frame = timeout = 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) timeout = clearTimeout(timeout);
+ var delay = time - clockNow; // Strictly less than if we recomputed clockNow.
+ if (delay > 24) {
+ if (time < Infinity) timeout = setTimeout(wake, time - clock.now() - clockSkew);
+ if (interval) interval = clearInterval(interval);
+ } else {
+ if (!interval) clockLast = clock.now(), interval = setInterval(poke, pokeDelay);
+ frame = 1, setFrame(wake);
+ }
+}
+
+var timeout$1 = function(callback, delay, time) {
+ var t = new Timer;
+ delay = delay == null ? 0 : +delay;
+ t.restart(function(elapsed) {
+ t.stop();
+ callback(elapsed + delay);
+ }, delay, time);
+ return t;
+};
+
+var interval$1 = function(callback, delay, time) {
+ var t = new Timer, total = delay;
+ if (delay == null) return t.restart(callback, delay, time), t;
+ delay = +delay, time = time == null ? now() : +time;
+ t.restart(function tick(elapsed) {
+ elapsed += total;
+ t.restart(tick, total += delay, time);
+ callback(elapsed);
+ }, delay, time);
+ return t;
+};
+
+exports.now = now;
+exports.timer = timer;
+exports.timerFlush = timerFlush;
+exports.timeout = timeout$1;
+exports.interval = interval$1;
+
+Object.defineProperty(exports, '__esModule', { value: true });
+
+})));
+
+},{}],50:[function(require,module,exports){
+// d3.tip
+// Copyright (c) 2013 Justin Palmer
+//
+// Tooltips for d3.js SVG visualizations
+
+(function (root, factory) {
+ if (typeof define === 'function' && define.amd) {
+ // AMD. Register as an anonymous module with d3 as a dependency.
+ define(['d3'], factory)
+ } else if (typeof module === 'object' && module.exports) {
+ // CommonJS
+ var d3 = require('d3')
+ module.exports = factory(d3)
+ } else {
+ // Browser global.
+ root.d3.tip = factory(root.d3)
+ }
+}(this, function (d3) {
+
+ // Public - contructs a new tooltip
+ //
+ // Returns a tip
+ return function() {
+ var direction = d3_tip_direction,
+ offset = d3_tip_offset,
+ html = d3_tip_html,
+ node = initNode(),
+ svg = null,
+ point = null,
+ target = null
+
+ function tip(vis) {
+ svg = getSVGNode(vis)
+ point = svg.createSVGPoint()
+ document.body.appendChild(node)
+ }
+
+ // Public - show the tooltip on the screen
+ //
+ // Returns a tip
+ tip.show = function() {
+ var args = Array.prototype.slice.call(arguments)
+ if(args[args.length - 1] instanceof SVGElement) target = args.pop()
+
+ var content = html.apply(this, args),
+ poffset = offset.apply(this, args),
+ dir = direction.apply(this, args),
+ nodel = getNodeEl(),
+ i = directions.length,
+ coords,
+ scrollTop = document.documentElement.scrollTop || document.body.scrollTop,
+ scrollLeft = document.documentElement.scrollLeft || document.body.scrollLeft
+
+ nodel.html(content)
+ .style('opacity', 1).style('pointer-events', 'all')
+
+ while(i--) nodel.classed(directions[i], false)
+ coords = direction_callbacks.get(dir).apply(this)
+ nodel.classed(dir, true)
+ .style('top', (coords.top + poffset[0]) + scrollTop + 'px')
+ .style('left', (coords.left + poffset[1]) + scrollLeft + 'px')
+
+ return tip;
+ };
+
+ // Public - hide the tooltip
+ //
+ // Returns a tip
+ tip.hide = function() {
+ var nodel = getNodeEl()
+ nodel.style('opacity', 0).style('pointer-events', 'none')
+ return tip
+ }
+
+ // Public: Proxy attr calls to the d3 tip container. Sets or gets attribute value.
+ //
+ // n - name of the attribute
+ // v - value of the attribute
+ //
+ // Returns tip or attribute value
+ tip.attr = function(n, v) {
+ if (arguments.length < 2 && typeof n === 'string') {
+ return getNodeEl().attr(n)
+ } else {
+ var args = Array.prototype.slice.call(arguments)
+ d3.selection.prototype.attr.apply(getNodeEl(), args)
+ }
+
+ return tip
+ }
+
+ // Public: Proxy style calls to the d3 tip container. Sets or gets a style value.
+ //
+ // n - name of the property
+ // v - value of the property
+ //
+ // Returns tip or style property value
+ tip.style = function(n, v) {
+ if (arguments.length < 2 && typeof n === 'string') {
+ return getNodeEl().style(n)
+ } else {
+ var args = Array.prototype.slice.call(arguments)
+ d3.selection.prototype.style.apply(getNodeEl(), args)
+ }
+
+ return tip
+ }
+
+ // Public: Set or get the direction of the tooltip
+ //
+ // v - One of n(north), s(south), e(east), or w(west), nw(northwest),
+ // sw(southwest), ne(northeast) or se(southeast)
+ //
+ // Returns tip or direction
+ tip.direction = function(v) {
+ if (!arguments.length) return direction
+ direction = v == null ? v : functor(v)
+
+ return tip
+ }
+
+ // Public: Sets or gets the offset of the tip
+ //
+ // v - Array of [x, y] offset
+ //
+ // Returns offset or
+ tip.offset = function(v) {
+ if (!arguments.length) return offset
+ offset = v == null ? v : functor(v)
+
+ return tip
+ }
+
+ // Public: sets or gets the html value of the tooltip
+ //
+ // v - String value of the tip
+ //
+ // Returns html value or tip
+ tip.html = function(v) {
+ if (!arguments.length) return html
+ html = v == null ? v : functor(v)
+
+ return tip
+ }
+
+ // Public: destroys the tooltip and removes it from the DOM
+ //
+ // Returns a tip
+ tip.destroy = function() {
+ if(node) {
+ getNodeEl().remove();
+ node = null;
+ }
+ return tip;
+ }
+
+ function d3_tip_direction() { return 'n' }
+ function d3_tip_offset() { return [0, 0] }
+ function d3_tip_html() { return ' ' }
+
+ var direction_callbacks = d3.map({
+ n: direction_n,
+ s: direction_s,
+ e: direction_e,
+ w: direction_w,
+ nw: direction_nw,
+ ne: direction_ne,
+ sw: direction_sw,
+ se: direction_se
+ }),
+
+ directions = direction_callbacks.keys()
+
+ function direction_n() {
+ var bbox = getScreenBBox()
+ return {
+ top: bbox.n.y - node.offsetHeight,
+ left: bbox.n.x - node.offsetWidth / 2
+ }
+ }
+
+ function direction_s() {
+ var bbox = getScreenBBox()
+ return {
+ top: bbox.s.y,
+ left: bbox.s.x - node.offsetWidth / 2
+ }
+ }
+
+ function direction_e() {
+ var bbox = getScreenBBox()
+ return {
+ top: bbox.e.y - node.offsetHeight / 2,
+ left: bbox.e.x
+ }
+ }
+
+ function direction_w() {
+ var bbox = getScreenBBox()
+ return {
+ top: bbox.w.y - node.offsetHeight / 2,
+ left: bbox.w.x - node.offsetWidth
+ }
+ }
+
+ function direction_nw() {
+ var bbox = getScreenBBox()
+ return {
+ top: bbox.nw.y - node.offsetHeight,
+ left: bbox.nw.x - node.offsetWidth
+ }
+ }
+
+ function direction_ne() {
+ var bbox = getScreenBBox()
+ return {
+ top: bbox.ne.y - node.offsetHeight,
+ left: bbox.ne.x
+ }
+ }
+
+ function direction_sw() {
+ var bbox = getScreenBBox()
+ return {
+ top: bbox.sw.y,
+ left: bbox.sw.x - node.offsetWidth
+ }
+ }
+
+ function direction_se() {
+ var bbox = getScreenBBox()
+ return {
+ top: bbox.se.y,
+ left: bbox.e.x
+ }
+ }
+
+ function initNode() {
+ var node = d3.select(document.createElement('div'));
+ node.style('position', 'absolute').style('top', 0).style('opacity', 0)
+ .style('pointer-events', 'none').style('box-sizing', 'border-box')
+
+ return node.node()
+ }
+
+ function getSVGNode(el) {
+ el = el.node()
+ if(el.tagName.toLowerCase() === 'svg')
+ return el
+
+ return el.ownerSVGElement
+ }
+
+ function getNodeEl() {
+ if(node === null) {
+ node = initNode();
+ // re-add node to DOM
+ document.body.appendChild(node);
+ };
+ return d3.select(node);
+ }
+
+ // Private - gets the screen coordinates of a shape
+ //
+ // Given a shape on the screen, will return an SVGPoint for the directions
+ // n(north), s(south), e(east), w(west), ne(northeast), se(southeast), nw(northwest),
+ // sw(southwest).
+ //
+ // +-+-+
+ // | |
+ // + +
+ // | |
+ // +-+-+
+ //
+ // Returns an Object {n, s, e, w, nw, sw, ne, se}
+ function getScreenBBox() {
+ var targetel = target || d3.event.target;
+
+ while ('undefined' === typeof targetel.getScreenCTM && 'undefined' === targetel.parentNode) {
+ targetel = targetel.parentNode;
+ }
+
+ var bbox = {},
+ matrix = targetel.getScreenCTM(),
+ tbbox = targetel.getBBox(),
+ width = tbbox.width,
+ height = tbbox.height,
+ x = tbbox.x,
+ y = tbbox.y
+
+ point.x = x
+ point.y = y
+ bbox.nw = point.matrixTransform(matrix)
+ point.x += width
+ bbox.ne = point.matrixTransform(matrix)
+ point.y += height
+ bbox.se = point.matrixTransform(matrix)
+ point.x -= width
+ bbox.sw = point.matrixTransform(matrix)
+ point.y -= height / 2
+ bbox.w = point.matrixTransform(matrix)
+ point.x += width
+ bbox.e = point.matrixTransform(matrix)
+ point.x -= width / 2
+ point.y -= height / 2
+ bbox.n = point.matrixTransform(matrix)
+ point.y += height
+ bbox.s = point.matrixTransform(matrix)
+
+ return bbox
+ }
+
+ // Private - replace D3JS 3.X d3.functor() function
+ function functor(v) {
+ return typeof v === "function" ? v : function() {
+ return v
+ }
+ }
+
+ return tip
+ };
+
+}));
+
+},{"d3":54}],51:[function(require,module,exports){
+// https://d3js.org/d3-transition/ Version 1.1.1. Copyright 2017 Mike Bostock.
+(function (global, factory) {
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('d3-selection'), require('d3-dispatch'), require('d3-timer'), require('d3-interpolate'), require('d3-color'), require('d3-ease')) :
+ typeof define === 'function' && define.amd ? define(['exports', 'd3-selection', 'd3-dispatch', 'd3-timer', 'd3-interpolate', 'd3-color', 'd3-ease'], factory) :
+ (factory((global.d3 = global.d3 || {}),global.d3,global.d3,global.d3,global.d3,global.d3,global.d3));
+}(this, (function (exports,d3Selection,d3Dispatch,d3Timer,d3Interpolate,d3Color,d3Ease) { 'use strict';
+
+var emptyOn = d3Dispatch.dispatch("start", "end", "interrupt");
+var emptyTween = [];
+
+var CREATED = 0;
+var SCHEDULED = 1;
+var STARTING = 2;
+var STARTED = 3;
+var RUNNING = 4;
+var ENDING = 5;
+var ENDED = 6;
+
+var schedule = function(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 > STARTING) throw new Error("too late; already started");
+ 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 = d3Timer.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 d3Timer.timeout(start);
+
+ // Interrupt the active transition, if any.
+ // Dispatch the interrupt event.
+ 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. No interrupt event is dispatched
+ // because the cancelled transitions never started. Note that this also
+ // removes this transition from the pending list!
+ else if (+i < id) {
+ o.state = ENDED;
+ o.timer.stop();
+ 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.
+ d3Timer.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(null, 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;
+ }
+}
+
+var interrupt = function(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();
+ if (active) schedule.on.call("interrupt", node, node.__data__, schedule.index, schedule.group);
+ delete schedules[i];
+ }
+
+ if (empty) delete node.__transition;
+};
+
+var selection_interrupt = function(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;
+ };
+}
+
+var transition_tween = function(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];
+ };
+}
+
+var interpolate = function(a, b) {
+ var c;
+ return (typeof b === "number" ? d3Interpolate.interpolateNumber
+ : b instanceof d3Color.color ? d3Interpolate.interpolateRgb
+ : (c = d3Color.color(b)) ? (b = c, d3Interpolate.interpolateRgb)
+ : d3Interpolate.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$$1, value1) {
+ var value00,
+ interpolate0;
+ return function() {
+ var value0 = this.getAttribute(name);
+ return value0 === value1 ? null
+ : value0 === value00 ? interpolate0
+ : interpolate0 = interpolate$$1(value00 = value0, value1);
+ };
+}
+
+function attrConstantNS(fullname, interpolate$$1, value1) {
+ var value00,
+ interpolate0;
+ return function() {
+ var value0 = this.getAttributeNS(fullname.space, fullname.local);
+ return value0 === value1 ? null
+ : value0 === value00 ? interpolate0
+ : interpolate0 = interpolate$$1(value00 = value0, value1);
+ };
+}
+
+function attrFunction(name, interpolate$$1, value) {
+ var value00,
+ value10,
+ interpolate0;
+ return function() {
+ var value0, value1 = value(this);
+ if (value1 == null) return void this.removeAttribute(name);
+ value0 = this.getAttribute(name);
+ return value0 === value1 ? null
+ : value0 === value00 && value1 === value10 ? interpolate0
+ : interpolate0 = interpolate$$1(value00 = value0, value10 = value1);
+ };
+}
+
+function attrFunctionNS(fullname, interpolate$$1, value) {
+ var value00,
+ value10,
+ interpolate0;
+ return function() {
+ var value0, value1 = value(this);
+ if (value1 == null) return void this.removeAttributeNS(fullname.space, fullname.local);
+ value0 = this.getAttributeNS(fullname.space, fullname.local);
+ return value0 === value1 ? null
+ : value0 === value00 && value1 === value10 ? interpolate0
+ : interpolate0 = interpolate$$1(value00 = value0, value10 = value1);
+ };
+}
+
+var transition_attr = function(name, value) {
+ var fullname = d3Selection.namespace(name), i = fullname === "transform" ? d3Interpolate.interpolateTransformSvg : interpolate;
+ 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 attrTweenNS(fullname, value) {
+ function tween() {
+ var node = this, i = value.apply(node, arguments);
+ return i && function(t) {
+ node.setAttributeNS(fullname.space, fullname.local, i(t));
+ };
+ }
+ tween._value = value;
+ return tween;
+}
+
+function attrTween(name, value) {
+ function tween() {
+ var node = this, i = value.apply(node, arguments);
+ return i && function(t) {
+ node.setAttribute(name, i(t));
+ };
+ }
+ tween._value = value;
+ return tween;
+}
+
+var transition_attrTween = function(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 = d3Selection.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;
+ };
+}
+
+var transition_delay = function(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;
+ };
+}
+
+var transition_duration = function(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;
+ };
+}
+
+var transition_ease = function(value) {
+ var id = this._id;
+
+ return arguments.length
+ ? this.each(easeConstant(id, value))
+ : get(this.node(), id).ease;
+};
+
+var transition_filter = function(match) {
+ if (typeof match !== "function") match = d3Selection.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);
+};
+
+var transition_merge = function(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;
+ };
+}
+
+var transition_on = function(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);
+ };
+}
+
+var transition_remove = function() {
+ return this.on("end.remove", removeFunction(this._id));
+};
+
+var transition_select = function(select) {
+ var name = this._name,
+ id = this._id;
+
+ if (typeof select !== "function") select = d3Selection.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);
+};
+
+var transition_selectAll = function(select) {
+ var name = this._name,
+ id = this._id;
+
+ if (typeof select !== "function") select = d3Selection.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 = d3Selection.selection.prototype.constructor;
+
+var transition_selection = function() {
+ return new Selection(this._groups, this._parents);
+};
+
+function styleRemove(name, interpolate$$1) {
+ var value00,
+ value10,
+ interpolate0;
+ return function() {
+ var value0 = d3Selection.style(this, name),
+ value1 = (this.style.removeProperty(name), d3Selection.style(this, name));
+ return value0 === value1 ? null
+ : value0 === value00 && value1 === value10 ? interpolate0
+ : interpolate0 = interpolate$$1(value00 = value0, value10 = value1);
+ };
+}
+
+function styleRemoveEnd(name) {
+ return function() {
+ this.style.removeProperty(name);
+ };
+}
+
+function styleConstant(name, interpolate$$1, value1) {
+ var value00,
+ interpolate0;
+ return function() {
+ var value0 = d3Selection.style(this, name);
+ return value0 === value1 ? null
+ : value0 === value00 ? interpolate0
+ : interpolate0 = interpolate$$1(value00 = value0, value1);
+ };
+}
+
+function styleFunction(name, interpolate$$1, value) {
+ var value00,
+ value10,
+ interpolate0;
+ return function() {
+ var value0 = d3Selection.style(this, name),
+ value1 = value(this);
+ if (value1 == null) value1 = (this.style.removeProperty(name), d3Selection.style(this, name));
+ return value0 === value1 ? null
+ : value0 === value00 && value1 === value10 ? interpolate0
+ : interpolate0 = interpolate$$1(value00 = value0, value10 = value1);
+ };
+}
+
+var transition_style = function(name, value, priority) {
+ var i = (name += "") === "transform" ? d3Interpolate.interpolateTransformCss : interpolate;
+ return value == null ? this
+ .styleTween(name, styleRemove(name, i))
+ .on("end.style." + name, styleRemoveEnd(name))
+ : this.styleTween(name, typeof value === "function"
+ ? styleFunction(name, i, tweenValue(this, "style." + name, value))
+ : styleConstant(name, i, value + ""), priority);
+};
+
+function styleTween(name, value, priority) {
+ function tween() {
+ var node = this, i = value.apply(node, arguments);
+ return i && function(t) {
+ node.style.setProperty(name, i(t), priority);
+ };
+ }
+ tween._value = value;
+ return tween;
+}
+
+var transition_styleTween = function(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;
+ };
+}
+
+var transition_text = function(value) {
+ return this.tween("text", typeof value === "function"
+ ? textFunction(tweenValue(this, "text", value))
+ : textConstant(value == null ? "" : value + ""));
+};
+
+var transition_transition = function() {
+ 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);
+};
+
+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 d3Selection.selection().transition(name);
+}
+
+function newId() {
+ return ++id;
+}
+
+var selection_prototype = d3Selection.selection.prototype;
+
+Transition.prototype = transition.prototype = {
+ constructor: Transition,
+ select: transition_select,
+ selectAll: transition_selectAll,
+ 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,
+ remove: transition_remove,
+ tween: transition_tween,
+ delay: transition_delay,
+ duration: transition_duration,
+ ease: transition_ease
+};
+
+var defaultTiming = {
+ time: null, // Set on use.
+ delay: 0,
+ duration: 250,
+ ease: d3Ease.easeCubicInOut
+};
+
+function inherit(node, id) {
+ var timing;
+ while (!(timing = node.__transition) || !(timing = timing[id])) {
+ if (!(node = node.parentNode)) {
+ return defaultTiming.time = d3Timer.now(), defaultTiming;
+ }
+ }
+ return timing;
+}
+
+var selection_transition = function(name) {
+ var id,
+ timing;
+
+ if (name instanceof Transition) {
+ id = name._id, name = name._name;
+ } else {
+ id = newId(), (timing = defaultTiming).time = d3Timer.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);
+};
+
+d3Selection.selection.prototype.interrupt = selection_interrupt;
+d3Selection.selection.prototype.transition = selection_transition;
+
+var root = [null];
+
+var active = function(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;
+};
+
+exports.transition = transition;
+exports.active = active;
+exports.interrupt = interrupt;
+
+Object.defineProperty(exports, '__esModule', { value: true });
+
+})));
+
+},{"d3-color":28,"d3-dispatch":29,"d3-ease":32,"d3-interpolate":37,"d3-selection":45,"d3-timer":49}],52:[function(require,module,exports){
+// https://d3js.org/d3-voronoi/ Version 1.1.2. Copyright 2017 Mike Bostock.
+(function (global, factory) {
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
+ typeof define === 'function' && define.amd ? define(['exports'], factory) :
+ (factory((global.d3 = global.d3 || {})));
+}(this, (function (exports) { 'use strict';
+
+var constant = function(x) {
+ return function() {
+ return x;
+ };
+};
+
+function x(d) {
+ return d[0];
+}
+
+function y(d) {
+ return d[1];
+}
+
+function RedBlackTree() {
+ this._ = null; // root node
+}
+
+function RedBlackNode(node) {
+ node.U = // parent node
+ node.C = // color - true for red, false for black
+ node.L = // left node
+ node.R = // right node
+ node.P = // previous node
+ node.N = null; // next node
+}
+
+RedBlackTree.prototype = {
+ constructor: RedBlackTree,
+
+ insert: function(after, node) {
+ var parent, grandpa, uncle;
+
+ if (after) {
+ node.P = after;
+ node.N = after.N;
+ if (after.N) after.N.P = node;
+ after.N = node;
+ if (after.R) {
+ after = after.R;
+ while (after.L) after = after.L;
+ after.L = node;
+ } else {
+ after.R = node;
+ }
+ parent = after;
+ } else if (this._) {
+ after = RedBlackFirst(this._);
+ node.P = null;
+ node.N = after;
+ after.P = after.L = node;
+ parent = after;
+ } else {
+ node.P = node.N = null;
+ this._ = node;
+ parent = null;
+ }
+ node.L = node.R = null;
+ node.U = parent;
+ node.C = true;
+
+ after = node;
+ while (parent && parent.C) {
+ grandpa = parent.U;
+ if (parent === grandpa.L) {
+ uncle = grandpa.R;
+ if (uncle && uncle.C) {
+ parent.C = uncle.C = false;
+ grandpa.C = true;
+ after = grandpa;
+ } else {
+ if (after === parent.R) {
+ RedBlackRotateLeft(this, parent);
+ after = parent;
+ parent = after.U;
+ }
+ parent.C = false;
+ grandpa.C = true;
+ RedBlackRotateRight(this, grandpa);
+ }
+ } else {
+ uncle = grandpa.L;
+ if (uncle && uncle.C) {
+ parent.C = uncle.C = false;
+ grandpa.C = true;
+ after = grandpa;
+ } else {
+ if (after === parent.L) {
+ RedBlackRotateRight(this, parent);
+ after = parent;
+ parent = after.U;
+ }
+ parent.C = false;
+ grandpa.C = true;
+ RedBlackRotateLeft(this, grandpa);
+ }
+ }
+ parent = after.U;
+ }
+ this._.C = false;
+ },
+
+ remove: function(node) {
+ if (node.N) node.N.P = node.P;
+ if (node.P) node.P.N = node.N;
+ node.N = node.P = null;
+
+ var parent = node.U,
+ sibling,
+ left = node.L,
+ right = node.R,
+ next,
+ red;
+
+ if (!left) next = right;
+ else if (!right) next = left;
+ else next = RedBlackFirst(right);
+
+ if (parent) {
+ if (parent.L === node) parent.L = next;
+ else parent.R = next;
+ } else {
+ this._ = next;
+ }
+
+ if (left && right) {
+ red = next.C;
+ next.C = node.C;
+ next.L = left;
+ left.U = next;
+ if (next !== right) {
+ parent = next.U;
+ next.U = node.U;
+ node = next.R;
+ parent.L = node;
+ next.R = right;
+ right.U = next;
+ } else {
+ next.U = parent;
+ parent = next;
+ node = next.R;
+ }
+ } else {
+ red = node.C;
+ node = next;
+ }
+
+ if (node) node.U = parent;
+ if (red) return;
+ if (node && node.C) { node.C = false; return; }
+
+ do {
+ if (node === this._) break;
+ if (node === parent.L) {
+ sibling = parent.R;
+ if (sibling.C) {
+ sibling.C = false;
+ parent.C = true;
+ RedBlackRotateLeft(this, parent);
+ sibling = parent.R;
+ }
+ if ((sibling.L && sibling.L.C)
+ || (sibling.R && sibling.R.C)) {
+ if (!sibling.R || !sibling.R.C) {
+ sibling.L.C = false;
+ sibling.C = true;
+ RedBlackRotateRight(this, sibling);
+ sibling = parent.R;
+ }
+ sibling.C = parent.C;
+ parent.C = sibling.R.C = false;
+ RedBlackRotateLeft(this, parent);
+ node = this._;
+ break;
+ }
+ } else {
+ sibling = parent.L;
+ if (sibling.C) {
+ sibling.C = false;
+ parent.C = true;
+ RedBlackRotateRight(this, parent);
+ sibling = parent.L;
+ }
+ if ((sibling.L && sibling.L.C)
+ || (sibling.R && sibling.R.C)) {
+ if (!sibling.L || !sibling.L.C) {
+ sibling.R.C = false;
+ sibling.C = true;
+ RedBlackRotateLeft(this, sibling);
+ sibling = parent.L;
+ }
+ sibling.C = parent.C;
+ parent.C = sibling.L.C = false;
+ RedBlackRotateRight(this, parent);
+ node = this._;
+ break;
+ }
+ }
+ sibling.C = true;
+ node = parent;
+ parent = parent.U;
+ } while (!node.C);
+
+ if (node) node.C = false;
+ }
+};
+
+function RedBlackRotateLeft(tree, node) {
+ var p = node,
+ q = node.R,
+ parent = p.U;
+
+ if (parent) {
+ if (parent.L === p) parent.L = q;
+ else parent.R = q;
+ } else {
+ tree._ = q;
+ }
+
+ q.U = parent;
+ p.U = q;
+ p.R = q.L;
+ if (p.R) p.R.U = p;
+ q.L = p;
+}
+
+function RedBlackRotateRight(tree, node) {
+ var p = node,
+ q = node.L,
+ parent = p.U;
+
+ if (parent) {
+ if (parent.L === p) parent.L = q;
+ else parent.R = q;
+ } else {
+ tree._ = q;
+ }
+
+ q.U = parent;
+ p.U = q;
+ p.L = q.R;
+ if (p.L) p.L.U = p;
+ q.R = p;
+}
+
+function RedBlackFirst(node) {
+ while (node.L) node = node.L;
+ return node;
+}
+
+function createEdge(left, right, v0, v1) {
+ var edge = [null, null],
+ index = edges.push(edge) - 1;
+ edge.left = left;
+ edge.right = right;
+ if (v0) setEdgeEnd(edge, left, right, v0);
+ if (v1) setEdgeEnd(edge, right, left, v1);
+ cells[left.index].halfedges.push(index);
+ cells[right.index].halfedges.push(index);
+ return edge;
+}
+
+function createBorderEdge(left, v0, v1) {
+ var edge = [v0, v1];
+ edge.left = left;
+ return edge;
+}
+
+function setEdgeEnd(edge, left, right, vertex) {
+ if (!edge[0] && !edge[1]) {
+ edge[0] = vertex;
+ edge.left = left;
+ edge.right = right;
+ } else if (edge.left === right) {
+ edge[1] = vertex;
+ } else {
+ edge[0] = vertex;
+ }
+}
+
+// Liang–Barsky line clipping.
+function clipEdge(edge, x0, y0, x1, y1) {
+ var a = edge[0],
+ b = edge[1],
+ 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) && !(t1 < 1)) return true; // TODO Better check?
+
+ if (t0 > 0) edge[0] = [ax + t0 * dx, ay + t0 * dy];
+ if (t1 < 1) edge[1] = [ax + t1 * dx, ay + t1 * dy];
+ return true;
+}
+
+function connectEdge(edge, x0, y0, x1, y1) {
+ var v1 = edge[1];
+ if (v1) return true;
+
+ var v0 = edge[0],
+ left = edge.left,
+ right = edge.right,
+ lx = left[0],
+ ly = left[1],
+ rx = right[0],
+ ry = right[1],
+ fx = (lx + rx) / 2,
+ fy = (ly + ry) / 2,
+ fm,
+ fb;
+
+ if (ry === ly) {
+ if (fx < x0 || fx >= x1) return;
+ if (lx > rx) {
+ if (!v0) v0 = [fx, y0];
+ else if (v0[1] >= y1) return;
+ v1 = [fx, y1];
+ } else {
+ if (!v0) v0 = [fx, y1];
+ else if (v0[1] < y0) return;
+ v1 = [fx, y0];
+ }
+ } else {
+ fm = (lx - rx) / (ry - ly);
+ fb = fy - fm * fx;
+ if (fm < -1 || fm > 1) {
+ if (lx > rx) {
+ if (!v0) v0 = [(y0 - fb) / fm, y0];
+ else if (v0[1] >= y1) return;
+ v1 = [(y1 - fb) / fm, y1];
+ } else {
+ if (!v0) v0 = [(y1 - fb) / fm, y1];
+ else if (v0[1] < y0) return;
+ v1 = [(y0 - fb) / fm, y0];
+ }
+ } else {
+ if (ly < ry) {
+ if (!v0) v0 = [x0, fm * x0 + fb];
+ else if (v0[0] >= x1) return;
+ v1 = [x1, fm * x1 + fb];
+ } else {
+ if (!v0) v0 = [x1, fm * x1 + fb];
+ else if (v0[0] < x0) return;
+ v1 = [x0, fm * x0 + fb];
+ }
+ }
+ }
+
+ edge[0] = v0;
+ edge[1] = v1;
+ return true;
+}
+
+function clipEdges(x0, y0, x1, y1) {
+ var i = edges.length,
+ edge;
+
+ while (i--) {
+ if (!connectEdge(edge = edges[i], x0, y0, x1, y1)
+ || !clipEdge(edge, x0, y0, x1, y1)
+ || !(Math.abs(edge[0][0] - edge[1][0]) > epsilon
+ || Math.abs(edge[0][1] - edge[1][1]) > epsilon)) {
+ delete edges[i];
+ }
+ }
+}
+
+function createCell(site) {
+ return cells[site.index] = {
+ site: site,
+ halfedges: []
+ };
+}
+
+function cellHalfedgeAngle(cell, edge) {
+ var site = cell.site,
+ va = edge.left,
+ vb = edge.right;
+ if (site === vb) vb = va, va = site;
+ if (vb) return Math.atan2(vb[1] - va[1], vb[0] - va[0]);
+ if (site === va) va = edge[1], vb = edge[0];
+ else va = edge[0], vb = edge[1];
+ return Math.atan2(va[0] - vb[0], vb[1] - va[1]);
+}
+
+function cellHalfedgeStart(cell, edge) {
+ return edge[+(edge.left !== cell.site)];
+}
+
+function cellHalfedgeEnd(cell, edge) {
+ return edge[+(edge.left === cell.site)];
+}
+
+function sortCellHalfedges() {
+ for (var i = 0, n = cells.length, cell, halfedges, j, m; i < n; ++i) {
+ if ((cell = cells[i]) && (m = (halfedges = cell.halfedges).length)) {
+ var index = new Array(m),
+ array = new Array(m);
+ for (j = 0; j < m; ++j) index[j] = j, array[j] = cellHalfedgeAngle(cell, edges[halfedges[j]]);
+ index.sort(function(i, j) { return array[j] - array[i]; });
+ for (j = 0; j < m; ++j) array[j] = halfedges[index[j]];
+ for (j = 0; j < m; ++j) halfedges[j] = array[j];
+ }
+ }
+}
+
+function clipCells(x0, y0, x1, y1) {
+ var nCells = cells.length,
+ iCell,
+ cell,
+ site,
+ iHalfedge,
+ halfedges,
+ nHalfedges,
+ start,
+ startX,
+ startY,
+ end,
+ endX,
+ endY,
+ cover = true;
+
+ for (iCell = 0; iCell < nCells; ++iCell) {
+ if (cell = cells[iCell]) {
+ site = cell.site;
+ halfedges = cell.halfedges;
+ iHalfedge = halfedges.length;
+
+ // Remove any dangling clipped edges.
+ while (iHalfedge--) {
+ if (!edges[halfedges[iHalfedge]]) {
+ halfedges.splice(iHalfedge, 1);
+ }
+ }
+
+ // Insert any border edges as necessary.
+ iHalfedge = 0, nHalfedges = halfedges.length;
+ while (iHalfedge < nHalfedges) {
+ end = cellHalfedgeEnd(cell, edges[halfedges[iHalfedge]]), endX = end[0], endY = end[1];
+ start = cellHalfedgeStart(cell, edges[halfedges[++iHalfedge % nHalfedges]]), startX = start[0], startY = start[1];
+ if (Math.abs(endX - startX) > epsilon || Math.abs(endY - startY) > epsilon) {
+ halfedges.splice(iHalfedge, 0, edges.push(createBorderEdge(site, end,
+ Math.abs(endX - x0) < epsilon && y1 - endY > epsilon ? [x0, Math.abs(startX - x0) < epsilon ? startY : y1]
+ : Math.abs(endY - y1) < epsilon && x1 - endX > epsilon ? [Math.abs(startY - y1) < epsilon ? startX : x1, y1]
+ : Math.abs(endX - x1) < epsilon && endY - y0 > epsilon ? [x1, Math.abs(startX - x1) < epsilon ? startY : y0]
+ : Math.abs(endY - y0) < epsilon && endX - x0 > epsilon ? [Math.abs(startY - y0) < epsilon ? startX : x0, y0]
+ : null)) - 1);
+ ++nHalfedges;
+ }
+ }
+
+ if (nHalfedges) cover = false;
+ }
+ }
+
+ // If there weren’t any edges, have the closest site cover the extent.
+ // It doesn’t matter which corner of the extent we measure!
+ if (cover) {
+ var dx, dy, d2, dc = Infinity;
+
+ for (iCell = 0, cover = null; iCell < nCells; ++iCell) {
+ if (cell = cells[iCell]) {
+ site = cell.site;
+ dx = site[0] - x0;
+ dy = site[1] - y0;
+ d2 = dx * dx + dy * dy;
+ if (d2 < dc) dc = d2, cover = cell;
+ }
+ }
+
+ if (cover) {
+ var v00 = [x0, y0], v01 = [x0, y1], v11 = [x1, y1], v10 = [x1, y0];
+ cover.halfedges.push(
+ edges.push(createBorderEdge(site = cover.site, v00, v01)) - 1,
+ edges.push(createBorderEdge(site, v01, v11)) - 1,
+ edges.push(createBorderEdge(site, v11, v10)) - 1,
+ edges.push(createBorderEdge(site, v10, v00)) - 1
+ );
+ }
+ }
+
+ // Lastly delete any cells with no edges; these were entirely clipped.
+ for (iCell = 0; iCell < nCells; ++iCell) {
+ if (cell = cells[iCell]) {
+ if (!cell.halfedges.length) {
+ delete cells[iCell];
+ }
+ }
+ }
+}
+
+var circlePool = [];
+
+var firstCircle;
+
+function Circle() {
+ RedBlackNode(this);
+ this.x =
+ this.y =
+ this.arc =
+ this.site =
+ this.cy = null;
+}
+
+function attachCircle(arc) {
+ var lArc = arc.P,
+ rArc = arc.N;
+
+ if (!lArc || !rArc) return;
+
+ var lSite = lArc.site,
+ cSite = arc.site,
+ rSite = rArc.site;
+
+ if (lSite === rSite) return;
+
+ var bx = cSite[0],
+ by = cSite[1],
+ ax = lSite[0] - bx,
+ ay = lSite[1] - by,
+ cx = rSite[0] - bx,
+ cy = rSite[1] - by;
+
+ var d = 2 * (ax * cy - ay * cx);
+ if (d >= -epsilon2) return;
+
+ var ha = ax * ax + ay * ay,
+ hc = cx * cx + cy * cy,
+ x = (cy * ha - ay * hc) / d,
+ y = (ax * hc - cx * ha) / d;
+
+ var circle = circlePool.pop() || new Circle;
+ circle.arc = arc;
+ circle.site = cSite;
+ circle.x = x + bx;
+ circle.y = (circle.cy = y + by) + Math.sqrt(x * x + y * y); // y bottom
+
+ arc.circle = circle;
+
+ var before = null,
+ node = circles._;
+
+ while (node) {
+ if (circle.y < node.y || (circle.y === node.y && circle.x <= node.x)) {
+ if (node.L) node = node.L;
+ else { before = node.P; break; }
+ } else {
+ if (node.R) node = node.R;
+ else { before = node; break; }
+ }
+ }
+
+ circles.insert(before, circle);
+ if (!before) firstCircle = circle;
+}
+
+function detachCircle(arc) {
+ var circle = arc.circle;
+ if (circle) {
+ if (!circle.P) firstCircle = circle.N;
+ circles.remove(circle);
+ circlePool.push(circle);
+ RedBlackNode(circle);
+ arc.circle = null;
+ }
+}
+
+var beachPool = [];
+
+function Beach() {
+ RedBlackNode(this);
+ this.edge =
+ this.site =
+ this.circle = null;
+}
+
+function createBeach(site) {
+ var beach = beachPool.pop() || new Beach;
+ beach.site = site;
+ return beach;
+}
+
+function detachBeach(beach) {
+ detachCircle(beach);
+ beaches.remove(beach);
+ beachPool.push(beach);
+ RedBlackNode(beach);
+}
+
+function removeBeach(beach) {
+ var circle = beach.circle,
+ x = circle.x,
+ y = circle.cy,
+ vertex = [x, y],
+ previous = beach.P,
+ next = beach.N,
+ disappearing = [beach];
+
+ detachBeach(beach);
+
+ var lArc = previous;
+ while (lArc.circle
+ && Math.abs(x - lArc.circle.x) < epsilon
+ && Math.abs(y - lArc.circle.cy) < epsilon) {
+ previous = lArc.P;
+ disappearing.unshift(lArc);
+ detachBeach(lArc);
+ lArc = previous;
+ }
+
+ disappearing.unshift(lArc);
+ detachCircle(lArc);
+
+ var rArc = next;
+ while (rArc.circle
+ && Math.abs(x - rArc.circle.x) < epsilon
+ && Math.abs(y - rArc.circle.cy) < epsilon) {
+ next = rArc.N;
+ disappearing.push(rArc);
+ detachBeach(rArc);
+ rArc = next;
+ }
+
+ disappearing.push(rArc);
+ detachCircle(rArc);
+
+ var nArcs = disappearing.length,
+ iArc;
+ for (iArc = 1; iArc < nArcs; ++iArc) {
+ rArc = disappearing[iArc];
+ lArc = disappearing[iArc - 1];
+ setEdgeEnd(rArc.edge, lArc.site, rArc.site, vertex);
+ }
+
+ lArc = disappearing[0];
+ rArc = disappearing[nArcs - 1];
+ rArc.edge = createEdge(lArc.site, rArc.site, null, vertex);
+
+ attachCircle(lArc);
+ attachCircle(rArc);
+}
+
+function addBeach(site) {
+ var x = site[0],
+ directrix = site[1],
+ lArc,
+ rArc,
+ dxl,
+ dxr,
+ node = beaches._;
+
+ while (node) {
+ dxl = leftBreakPoint(node, directrix) - x;
+ if (dxl > epsilon) node = node.L; else {
+ dxr = x - rightBreakPoint(node, directrix);
+ if (dxr > epsilon) {
+ if (!node.R) {
+ lArc = node;
+ break;
+ }
+ node = node.R;
+ } else {
+ if (dxl > -epsilon) {
+ lArc = node.P;
+ rArc = node;
+ } else if (dxr > -epsilon) {
+ lArc = node;
+ rArc = node.N;
+ } else {
+ lArc = rArc = node;
+ }
+ break;
+ }
+ }
+ }
+
+ createCell(site);
+ var newArc = createBeach(site);
+ beaches.insert(lArc, newArc);
+
+ if (!lArc && !rArc) return;
+
+ if (lArc === rArc) {
+ detachCircle(lArc);
+ rArc = createBeach(lArc.site);
+ beaches.insert(newArc, rArc);
+ newArc.edge = rArc.edge = createEdge(lArc.site, newArc.site);
+ attachCircle(lArc);
+ attachCircle(rArc);
+ return;
+ }
+
+ if (!rArc) { // && lArc
+ newArc.edge = createEdge(lArc.site, newArc.site);
+ return;
+ }
+
+ // else lArc !== rArc
+ detachCircle(lArc);
+ detachCircle(rArc);
+
+ var lSite = lArc.site,
+ ax = lSite[0],
+ ay = lSite[1],
+ bx = site[0] - ax,
+ by = site[1] - ay,
+ rSite = rArc.site,
+ cx = rSite[0] - ax,
+ cy = rSite[1] - ay,
+ d = 2 * (bx * cy - by * cx),
+ hb = bx * bx + by * by,
+ hc = cx * cx + cy * cy,
+ vertex = [(cy * hb - by * hc) / d + ax, (bx * hc - cx * hb) / d + ay];
+
+ setEdgeEnd(rArc.edge, lSite, rSite, vertex);
+ newArc.edge = createEdge(lSite, site, null, vertex);
+ rArc.edge = createEdge(site, rSite, null, vertex);
+ attachCircle(lArc);
+ attachCircle(rArc);
+}
+
+function leftBreakPoint(arc, directrix) {
+ var site = arc.site,
+ rfocx = site[0],
+ rfocy = site[1],
+ pby2 = rfocy - directrix;
+
+ if (!pby2) return rfocx;
+
+ var lArc = arc.P;
+ if (!lArc) return -Infinity;
+
+ site = lArc.site;
+ var lfocx = site[0],
+ lfocy = site[1],
+ plby2 = lfocy - directrix;
+
+ if (!plby2) return lfocx;
+
+ var hl = lfocx - rfocx,
+ aby2 = 1 / pby2 - 1 / plby2,
+ b = hl / plby2;
+
+ if (aby2) return (-b + Math.sqrt(b * b - 2 * aby2 * (hl * hl / (-2 * plby2) - lfocy + plby2 / 2 + rfocy - pby2 / 2))) / aby2 + rfocx;
+
+ return (rfocx + lfocx) / 2;
+}
+
+function rightBreakPoint(arc, directrix) {
+ var rArc = arc.N;
+ if (rArc) return leftBreakPoint(rArc, directrix);
+ var site = arc.site;
+ return site[1] === directrix ? site[0] : Infinity;
+}
+
+var epsilon = 1e-6;
+var epsilon2 = 1e-12;
+var beaches;
+var cells;
+var circles;
+var edges;
+
+function triangleArea(a, b, c) {
+ return (a[0] - c[0]) * (b[1] - a[1]) - (a[0] - b[0]) * (c[1] - a[1]);
+}
+
+function lexicographic(a, b) {
+ return b[1] - a[1]
+ || b[0] - a[0];
+}
+
+function Diagram(sites, extent) {
+ var site = sites.sort(lexicographic).pop(),
+ x,
+ y,
+ circle;
+
+ edges = [];
+ cells = new Array(sites.length);
+ beaches = new RedBlackTree;
+ circles = new RedBlackTree;
+
+ while (true) {
+ circle = firstCircle;
+ if (site && (!circle || site[1] < circle.y || (site[1] === circle.y && site[0] < circle.x))) {
+ if (site[0] !== x || site[1] !== y) {
+ addBeach(site);
+ x = site[0], y = site[1];
+ }
+ site = sites.pop();
+ } else if (circle) {
+ removeBeach(circle.arc);
+ } else {
+ break;
+ }
+ }
+
+ sortCellHalfedges();
+
+ if (extent) {
+ var x0 = +extent[0][0],
+ y0 = +extent[0][1],
+ x1 = +extent[1][0],
+ y1 = +extent[1][1];
+ clipEdges(x0, y0, x1, y1);
+ clipCells(x0, y0, x1, y1);
+ }
+
+ this.edges = edges;
+ this.cells = cells;
+
+ beaches =
+ circles =
+ edges =
+ cells = null;
+}
+
+Diagram.prototype = {
+ constructor: Diagram,
+
+ polygons: function() {
+ var edges = this.edges;
+
+ return this.cells.map(function(cell) {
+ var polygon = cell.halfedges.map(function(i) { return cellHalfedgeStart(cell, edges[i]); });
+ polygon.data = cell.site.data;
+ return polygon;
+ });
+ },
+
+ triangles: function() {
+ var triangles = [],
+ edges = this.edges;
+
+ this.cells.forEach(function(cell, i) {
+ if (!(m = (halfedges = cell.halfedges).length)) return;
+ var site = cell.site,
+ halfedges,
+ j = -1,
+ m,
+ s0,
+ e1 = edges[halfedges[m - 1]],
+ s1 = e1.left === site ? e1.right : e1.left;
+
+ while (++j < m) {
+ s0 = s1;
+ e1 = edges[halfedges[j]];
+ s1 = e1.left === site ? e1.right : e1.left;
+ if (s0 && s1 && i < s0.index && i < s1.index && triangleArea(site, s0, s1) < 0) {
+ triangles.push([site.data, s0.data, s1.data]);
+ }
+ }
+ });
+
+ return triangles;
+ },
+
+ links: function() {
+ return this.edges.filter(function(edge) {
+ return edge.right;
+ }).map(function(edge) {
+ return {
+ source: edge.left.data,
+ target: edge.right.data
+ };
+ });
+ },
+
+ find: function(x, y, radius) {
+ var that = this, i0, i1 = that._found || 0, n = that.cells.length, cell;
+
+ // Use the previously-found cell, or start with an arbitrary one.
+ while (!(cell = that.cells[i1])) if (++i1 >= n) return null;
+ var dx = x - cell.site[0], dy = y - cell.site[1], d2 = dx * dx + dy * dy;
+
+ // Traverse the half-edges to find a closer cell, if any.
+ do {
+ cell = that.cells[i0 = i1], i1 = null;
+ cell.halfedges.forEach(function(e) {
+ var edge = that.edges[e], v = edge.left;
+ if ((v === cell.site || !v) && !(v = edge.right)) return;
+ var vx = x - v[0], vy = y - v[1], v2 = vx * vx + vy * vy;
+ if (v2 < d2) d2 = v2, i1 = v.index;
+ });
+ } while (i1 !== null);
+
+ that._found = i0;
+
+ return radius == null || d2 <= radius * radius ? cell.site : null;
+ }
+};
+
+var voronoi = function() {
+ var x$$1 = x,
+ y$$1 = y,
+ extent = null;
+
+ function voronoi(data) {
+ return new Diagram(data.map(function(d, i) {
+ var s = [Math.round(x$$1(d, i, data) / epsilon) * epsilon, Math.round(y$$1(d, i, data) / epsilon) * epsilon];
+ s.index = i;
+ s.data = d;
+ return s;
+ }), extent);
+ }
+
+ voronoi.polygons = function(data) {
+ return voronoi(data).polygons();
+ };
+
+ voronoi.links = function(data) {
+ return voronoi(data).links();
+ };
+
+ voronoi.triangles = function(data) {
+ return voronoi(data).triangles();
+ };
+
+ voronoi.x = function(_) {
+ return arguments.length ? (x$$1 = typeof _ === "function" ? _ : constant(+_), voronoi) : x$$1;
+ };
+
+ voronoi.y = function(_) {
+ return arguments.length ? (y$$1 = typeof _ === "function" ? _ : constant(+_), voronoi) : y$$1;
+ };
+
+ voronoi.extent = function(_) {
+ return arguments.length ? (extent = _ == null ? null : [[+_[0][0], +_[0][1]], [+_[1][0], +_[1][1]]], voronoi) : extent && [[extent[0][0], extent[0][1]], [extent[1][0], extent[1][1]]];
+ };
+
+ voronoi.size = function(_) {
+ return arguments.length ? (extent = _ == null ? null : [[0, 0], [+_[0], +_[1]]], voronoi) : extent && [extent[1][0] - extent[0][0], extent[1][1] - extent[0][1]];
+ };
+
+ return voronoi;
+};
+
+exports.voronoi = voronoi;
+
+Object.defineProperty(exports, '__esModule', { value: true });
+
+})));
+
+},{}],53:[function(require,module,exports){
+// https://d3js.org/d3-zoom/ Version 1.7.1. Copyright 2017 Mike Bostock.
+(function (global, factory) {
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('d3-dispatch'), require('d3-drag'), require('d3-interpolate'), require('d3-selection'), require('d3-transition')) :
+ typeof define === 'function' && define.amd ? define(['exports', 'd3-dispatch', 'd3-drag', 'd3-interpolate', 'd3-selection', 'd3-transition'], factory) :
+ (factory((global.d3 = global.d3 || {}),global.d3,global.d3,global.d3,global.d3,global.d3));
+}(this, (function (exports,d3Dispatch,d3Drag,d3Interpolate,d3Selection,d3Transition) { 'use strict';
+
+var constant = function(x) {
+ return function() {
+ return x;
+ };
+};
+
+function ZoomEvent(target, type, transform) {
+ this.target = target;
+ this.type = type;
+ this.transform = transform;
+}
+
+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) {
+ return node.__zoom || identity;
+}
+
+function nopropagation() {
+ d3Selection.event.stopImmediatePropagation();
+}
+
+var noevent = function() {
+ d3Selection.event.preventDefault();
+ d3Selection.event.stopImmediatePropagation();
+};
+
+// Ignore right-click, since that should open the context menu.
+function defaultFilter() {
+ return !d3Selection.event.button;
+}
+
+function defaultExtent() {
+ var e = this, w, h;
+ if (e instanceof SVGElement) {
+ e = e.ownerSVGElement || e;
+ w = e.width.baseVal.value;
+ h = e.height.baseVal.value;
+ } else {
+ w = e.clientWidth;
+ h = e.clientHeight;
+ }
+ return [[0, 0], [w, h]];
+}
+
+function defaultTransform() {
+ return this.__zoom || identity;
+}
+
+function defaultWheelDelta() {
+ return -d3Selection.event.deltaY * (d3Selection.event.deltaMode ? 120 : 1) / 500;
+}
+
+function defaultTouchable() {
+ return "ontouchstart" in this;
+}
+
+function defaultConstrain(transform$$1, extent, translateExtent) {
+ var dx0 = transform$$1.invertX(extent[0][0]) - translateExtent[0][0],
+ dx1 = transform$$1.invertX(extent[1][0]) - translateExtent[1][0],
+ dy0 = transform$$1.invertY(extent[0][1]) - translateExtent[0][1],
+ dy1 = transform$$1.invertY(extent[1][1]) - translateExtent[1][1];
+ return transform$$1.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)
+ );
+}
+
+var zoom = function() {
+ var filter = defaultFilter,
+ extent = defaultExtent,
+ constrain = defaultConstrain,
+ wheelDelta = defaultWheelDelta,
+ touchable = defaultTouchable,
+ scaleExtent = [0, Infinity],
+ translateExtent = [[-Infinity, -Infinity], [Infinity, Infinity]],
+ duration = 250,
+ interpolate = d3Interpolate.interpolateZoom,
+ gestures = [],
+ listeners = d3Dispatch.dispatch("start", "zoom", "end"),
+ touchstarting,
+ touchending,
+ touchDelay = 500,
+ wheelDelay = 150,
+ clickDistance2 = 0;
+
+ function zoom(selection) {
+ selection
+ .property("__zoom", defaultTransform)
+ .on("wheel.zoom", wheeled)
+ .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("touch-action", "none")
+ .style("-webkit-tap-highlight-color", "rgba(0,0,0,0)");
+ }
+
+ zoom.transform = function(collection, transform$$1) {
+ var selection = collection.selection ? collection.selection() : collection;
+ selection.property("__zoom", defaultTransform);
+ if (collection !== selection) {
+ schedule(collection, transform$$1);
+ } else {
+ selection.interrupt().each(function() {
+ gesture(this, arguments)
+ .start()
+ .zoom(null, typeof transform$$1 === "function" ? transform$$1.apply(this, arguments) : transform$$1)
+ .end();
+ });
+ }
+ };
+
+ zoom.scaleBy = function(selection, k) {
+ zoom.scaleTo(selection, function() {
+ var k0 = this.__zoom.k,
+ k1 = typeof k === "function" ? k.apply(this, arguments) : k;
+ return k0 * k1;
+ });
+ };
+
+ zoom.scaleTo = function(selection, k) {
+ zoom.transform(selection, function() {
+ var e = extent.apply(this, arguments),
+ t0 = this.__zoom,
+ p0 = centroid(e),
+ p1 = t0.invert(p0),
+ k1 = typeof k === "function" ? k.apply(this, arguments) : k;
+ return constrain(translate(scale(t0, k1), p0, p1), e, translateExtent);
+ });
+ };
+
+ zoom.translateBy = function(selection, x, y) {
+ 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);
+ });
+ };
+
+ zoom.translateTo = function(selection, x, y) {
+ zoom.transform(selection, function() {
+ var e = extent.apply(this, arguments),
+ t = this.__zoom,
+ p = centroid(e);
+ return constrain(identity.translate(p[0], p[1]).scale(t.k).translate(
+ typeof x === "function" ? -x.apply(this, arguments) : -x,
+ typeof y === "function" ? -y.apply(this, arguments) : -y
+ ), e, translateExtent);
+ });
+ };
+
+ function scale(transform$$1, k) {
+ k = Math.max(scaleExtent[0], Math.min(scaleExtent[1], k));
+ return k === transform$$1.k ? transform$$1 : new Transform(k, transform$$1.x, transform$$1.y);
+ }
+
+ function translate(transform$$1, p0, p1) {
+ var x = p0[0] - p1[0] * transform$$1.k, y = p0[1] - p1[1] * transform$$1.k;
+ return x === transform$$1.x && y === transform$$1.y ? transform$$1 : new Transform(transform$$1.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$$1, center) {
+ transition
+ .on("start.zoom", function() { gesture(this, arguments).start(); })
+ .on("interrupt.zoom end.zoom", function() { gesture(this, arguments).end(); })
+ .tween("zoom", function() {
+ var that = this,
+ args = arguments,
+ g = gesture(that, args),
+ e = extent.apply(that, args),
+ p = center || centroid(e),
+ w = Math.max(e[1][0] - e[0][0], e[1][1] - e[0][1]),
+ a = that.__zoom,
+ b = typeof transform$$1 === "function" ? transform$$1.apply(that, args) : transform$$1,
+ 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) {
+ for (var i = 0, n = gestures.length, g; i < n; ++i) {
+ if ((g = gestures[i]).that === that) {
+ return g;
+ }
+ }
+ return new Gesture(that, args);
+ }
+
+ function Gesture(that, args) {
+ this.that = that;
+ this.args = args;
+ this.index = -1;
+ this.active = 0;
+ this.extent = extent.apply(that, args);
+ }
+
+ Gesture.prototype = {
+ start: function() {
+ if (++this.active === 1) {
+ this.index = gestures.push(this) - 1;
+ this.emit("start");
+ }
+ return this;
+ },
+ zoom: function(key, transform$$1) {
+ if (this.mouse && key !== "mouse") this.mouse[1] = transform$$1.invert(this.mouse[0]);
+ if (this.touch0 && key !== "touch") this.touch0[1] = transform$$1.invert(this.touch0[0]);
+ if (this.touch1 && key !== "touch") this.touch1[1] = transform$$1.invert(this.touch1[0]);
+ this.that.__zoom = transform$$1;
+ this.emit("zoom");
+ return this;
+ },
+ end: function() {
+ if (--this.active === 0) {
+ gestures.splice(this.index, 1);
+ this.index = -1;
+ this.emit("end");
+ }
+ return this;
+ },
+ emit: function(type) {
+ d3Selection.customEvent(new ZoomEvent(zoom, type, this.that.__zoom), listeners.apply, listeners, [type, this.that, this.args]);
+ }
+ };
+
+ function wheeled() {
+ if (!filter.apply(this, arguments)) return;
+ var g = gesture(this, arguments),
+ t = this.__zoom,
+ k = Math.max(scaleExtent[0], Math.min(scaleExtent[1], t.k * Math.pow(2, wheelDelta.apply(this, arguments)))),
+ p = d3Selection.mouse(this);
+
+ // 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)];
+ d3Transition.interrupt(this);
+ g.start();
+ }
+
+ noevent();
+ 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() {
+ if (touchending || !filter.apply(this, arguments)) return;
+ var g = gesture(this, arguments),
+ v = d3Selection.select(d3Selection.event.view).on("mousemove.zoom", mousemoved, true).on("mouseup.zoom", mouseupped, true),
+ p = d3Selection.mouse(this),
+ x0 = d3Selection.event.clientX,
+ y0 = d3Selection.event.clientY;
+
+ d3Drag.dragDisable(d3Selection.event.view);
+ nopropagation();
+ g.mouse = [p, this.__zoom.invert(p)];
+ d3Transition.interrupt(this);
+ g.start();
+
+ function mousemoved() {
+ noevent();
+ if (!g.moved) {
+ var dx = d3Selection.event.clientX - x0, dy = d3Selection.event.clientY - y0;
+ g.moved = dx * dx + dy * dy > clickDistance2;
+ }
+ g.zoom("mouse", constrain(translate(g.that.__zoom, g.mouse[0] = d3Selection.mouse(g.that), g.mouse[1]), g.extent, translateExtent));
+ }
+
+ function mouseupped() {
+ v.on("mousemove.zoom mouseup.zoom", null);
+ d3Drag.dragEnable(d3Selection.event.view, g.moved);
+ noevent();
+ g.end();
+ }
+ }
+
+ function dblclicked() {
+ if (!filter.apply(this, arguments)) return;
+ var t0 = this.__zoom,
+ p0 = d3Selection.mouse(this),
+ p1 = t0.invert(p0),
+ k1 = t0.k * (d3Selection.event.shiftKey ? 0.5 : 2),
+ t1 = constrain(translate(scale(t0, k1), p0, p1), extent.apply(this, arguments), translateExtent);
+
+ noevent();
+ if (duration > 0) d3Selection.select(this).transition().duration(duration).call(schedule, t1, p0);
+ else d3Selection.select(this).call(zoom.transform, t1);
+ }
+
+ function touchstarted() {
+ if (!filter.apply(this, arguments)) return;
+ var g = gesture(this, arguments),
+ touches = d3Selection.event.changedTouches,
+ started,
+ n = touches.length, i, t, p;
+
+ nopropagation();
+ for (i = 0; i < n; ++i) {
+ t = touches[i], p = d3Selection.touch(this, touches, t.identifier);
+ p = [p, this.__zoom.invert(p), t.identifier];
+ if (!g.touch0) g.touch0 = p, started = true;
+ else if (!g.touch1) g.touch1 = p;
+ }
+
+ // If this is a dbltap, reroute to the (optional) dblclick.zoom handler.
+ if (touchstarting) {
+ touchstarting = clearTimeout(touchstarting);
+ if (!g.touch1) {
+ g.end();
+ p = d3Selection.select(this).on("dblclick.zoom");
+ if (p) p.apply(this, arguments);
+ return;
+ }
+ }
+
+ if (started) {
+ touchstarting = setTimeout(function() { touchstarting = null; }, touchDelay);
+ d3Transition.interrupt(this);
+ g.start();
+ }
+ }
+
+ function touchmoved() {
+ var g = gesture(this, arguments),
+ touches = d3Selection.event.changedTouches,
+ n = touches.length, i, t, p, l;
+
+ noevent();
+ if (touchstarting) touchstarting = clearTimeout(touchstarting);
+ for (i = 0; i < n; ++i) {
+ t = touches[i], p = d3Selection.touch(this, touches, t.identifier);
+ 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() {
+ var g = gesture(this, arguments),
+ touches = d3Selection.event.changedTouches,
+ n = touches.length, i, t;
+
+ nopropagation();
+ 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();
+ }
+
+ 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);
+ };
+
+ return zoom;
+};
+
+exports.zoom = zoom;
+exports.zoomTransform = transform;
+exports.zoomIdentity = identity;
+
+Object.defineProperty(exports, '__esModule', { value: true });
+
+})));
+
+},{"d3-dispatch":29,"d3-drag":30,"d3-interpolate":37,"d3-selection":45,"d3-transition":51}],54:[function(require,module,exports){
+'use strict';
+
+Object.defineProperty(exports, '__esModule', { value: true });
+
+var d3Array = require('d3-array');
+var d3Axis = require('d3-axis');
+var d3Brush = require('d3-brush');
+var d3Chord = require('d3-chord');
+var d3Collection = require('d3-collection');
+var d3Color = require('d3-color');
+var d3Dispatch = require('d3-dispatch');
+var d3Drag = require('d3-drag');
+var d3Dsv = require('d3-dsv');
+var d3Ease = require('d3-ease');
+var d3Force = require('d3-force');
+var d3Format = require('d3-format');
+var d3Geo = require('d3-geo');
+var d3Hierarchy = require('d3-hierarchy');
+var d3Interpolate = require('d3-interpolate');
+var d3Path = require('d3-path');
+var d3Polygon = require('d3-polygon');
+var d3Quadtree = require('d3-quadtree');
+var d3Queue = require('d3-queue');
+var d3Random = require('d3-random');
+var d3Request = require('d3-request');
+var d3Scale = require('d3-scale');
+var d3Selection = require('d3-selection');
+var d3Shape = require('d3-shape');
+var d3Time = require('d3-time');
+var d3TimeFormat = require('d3-time-format');
+var d3Timer = require('d3-timer');
+var d3Transition = require('d3-transition');
+var d3Voronoi = require('d3-voronoi');
+var d3Zoom = require('d3-zoom');
+
+var version = "4.13.0";
+
+exports.version = version;
+Object.keys(d3Array).forEach(function (key) { exports[key] = d3Array[key]; });
+Object.keys(d3Axis).forEach(function (key) { exports[key] = d3Axis[key]; });
+Object.keys(d3Brush).forEach(function (key) { exports[key] = d3Brush[key]; });
+Object.keys(d3Chord).forEach(function (key) { exports[key] = d3Chord[key]; });
+Object.keys(d3Collection).forEach(function (key) { exports[key] = d3Collection[key]; });
+Object.keys(d3Color).forEach(function (key) { exports[key] = d3Color[key]; });
+Object.keys(d3Dispatch).forEach(function (key) { exports[key] = d3Dispatch[key]; });
+Object.keys(d3Drag).forEach(function (key) { exports[key] = d3Drag[key]; });
+Object.keys(d3Dsv).forEach(function (key) { exports[key] = d3Dsv[key]; });
+Object.keys(d3Ease).forEach(function (key) { exports[key] = d3Ease[key]; });
+Object.keys(d3Force).forEach(function (key) { exports[key] = d3Force[key]; });
+Object.keys(d3Format).forEach(function (key) { exports[key] = d3Format[key]; });
+Object.keys(d3Geo).forEach(function (key) { exports[key] = d3Geo[key]; });
+Object.keys(d3Hierarchy).forEach(function (key) { exports[key] = d3Hierarchy[key]; });
+Object.keys(d3Interpolate).forEach(function (key) { exports[key] = d3Interpolate[key]; });
+Object.keys(d3Path).forEach(function (key) { exports[key] = d3Path[key]; });
+Object.keys(d3Polygon).forEach(function (key) { exports[key] = d3Polygon[key]; });
+Object.keys(d3Quadtree).forEach(function (key) { exports[key] = d3Quadtree[key]; });
+Object.keys(d3Queue).forEach(function (key) { exports[key] = d3Queue[key]; });
+Object.keys(d3Random).forEach(function (key) { exports[key] = d3Random[key]; });
+Object.keys(d3Request).forEach(function (key) { exports[key] = d3Request[key]; });
+Object.keys(d3Scale).forEach(function (key) { exports[key] = d3Scale[key]; });
+Object.keys(d3Selection).forEach(function (key) { exports[key] = d3Selection[key]; });
+Object.keys(d3Shape).forEach(function (key) { exports[key] = d3Shape[key]; });
+Object.keys(d3Time).forEach(function (key) { exports[key] = d3Time[key]; });
+Object.keys(d3TimeFormat).forEach(function (key) { exports[key] = d3TimeFormat[key]; });
+Object.keys(d3Timer).forEach(function (key) { exports[key] = d3Timer[key]; });
+Object.keys(d3Transition).forEach(function (key) { exports[key] = d3Transition[key]; });
+Object.keys(d3Voronoi).forEach(function (key) { exports[key] = d3Voronoi[key]; });
+Object.keys(d3Zoom).forEach(function (key) { exports[key] = d3Zoom[key]; });
+Object.defineProperty(exports, "event", {get: function() { return d3Selection.event; }});
+
+},{"d3-array":23,"d3-axis":24,"d3-brush":25,"d3-chord":26,"d3-collection":27,"d3-color":28,"d3-dispatch":29,"d3-drag":30,"d3-dsv":31,"d3-ease":32,"d3-force":33,"d3-format":34,"d3-geo":35,"d3-hierarchy":36,"d3-interpolate":37,"d3-path":38,"d3-polygon":39,"d3-quadtree":40,"d3-queue":41,"d3-random":42,"d3-request":43,"d3-scale":44,"d3-selection":45,"d3-shape":46,"d3-time":48,"d3-time-format":47,"d3-timer":49,"d3-transition":51,"d3-voronoi":52,"d3-zoom":53}],55:[function(require,module,exports){
+// Copyright Joyent, Inc. and other Node contributors.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to permit
+// persons to whom the Software is furnished to do so, subject to the
+// following conditions:
+//
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
+// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+// USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+function EventEmitter() {
+ this._events = this._events || {};
+ this._maxListeners = this._maxListeners || undefined;
+}
+module.exports = EventEmitter;
+
+// Backwards-compat with node 0.10.x
+EventEmitter.EventEmitter = EventEmitter;
+
+EventEmitter.prototype._events = undefined;
+EventEmitter.prototype._maxListeners = undefined;
+
+// By default EventEmitters will print a warning if more than 10 listeners are
+// added to it. This is a useful default which helps finding memory leaks.
+EventEmitter.defaultMaxListeners = 10;
+
+// Obviously not all Emitters should be limited to 10. This function allows
+// that to be increased. Set to zero for unlimited.
+EventEmitter.prototype.setMaxListeners = function(n) {
+ if (!isNumber(n) || n < 0 || isNaN(n))
+ throw TypeError('n must be a positive number');
+ this._maxListeners = n;
+ return this;
+};
+
+EventEmitter.prototype.emit = function(type) {
+ var er, handler, len, args, i, listeners;
+
+ if (!this._events)
+ this._events = {};
+
+ // If there is no 'error' event listener then throw.
+ if (type === 'error') {
+ if (!this._events.error ||
+ (isObject(this._events.error) && !this._events.error.length)) {
+ er = arguments[1];
+ if (er instanceof Error) {
+ throw er; // Unhandled 'error' event
+ } else {
+ // At least give some kind of context to the user
+ var err = new Error('Uncaught, unspecified "error" event. (' + er + ')');
+ err.context = er;
+ throw err;
+ }
+ }
+ }
+
+ handler = this._events[type];
+
+ if (isUndefined(handler))
+ return false;
+
+ if (isFunction(handler)) {
+ switch (arguments.length) {
+ // fast cases
+ case 1:
+ handler.call(this);
+ break;
+ case 2:
+ handler.call(this, arguments[1]);
+ break;
+ case 3:
+ handler.call(this, arguments[1], arguments[2]);
+ break;
+ // slower
+ default:
+ args = Array.prototype.slice.call(arguments, 1);
+ handler.apply(this, args);
+ }
+ } else if (isObject(handler)) {
+ args = Array.prototype.slice.call(arguments, 1);
+ listeners = handler.slice();
+ len = listeners.length;
+ for (i = 0; i < len; i++)
+ listeners[i].apply(this, args);
+ }
+
+ return true;
+};
+
+EventEmitter.prototype.addListener = function(type, listener) {
+ var m;
+
+ if (!isFunction(listener))
+ throw TypeError('listener must be a function');
+
+ if (!this._events)
+ this._events = {};
+
+ // To avoid recursion in the case that type === "newListener"! Before
+ // adding it to the listeners, first emit "newListener".
+ if (this._events.newListener)
+ this.emit('newListener', type,
+ isFunction(listener.listener) ?
+ listener.listener : listener);
+
+ if (!this._events[type])
+ // Optimize the case of one listener. Don't need the extra array object.
+ this._events[type] = listener;
+ else if (isObject(this._events[type]))
+ // If we've already got an array, just append.
+ this._events[type].push(listener);
+ else
+ // Adding the second element, need to change to array.
+ this._events[type] = [this._events[type], listener];
+
+ // Check for listener leak
+ if (isObject(this._events[type]) && !this._events[type].warned) {
+ if (!isUndefined(this._maxListeners)) {
+ m = this._maxListeners;
+ } else {
+ m = EventEmitter.defaultMaxListeners;
+ }
+
+ if (m && m > 0 && this._events[type].length > m) {
+ this._events[type].warned = true;
+ console.error('(node) warning: possible EventEmitter memory ' +
+ 'leak detected. %d listeners added. ' +
+ 'Use emitter.setMaxListeners() to increase limit.',
+ this._events[type].length);
+ if (typeof console.trace === 'function') {
+ // not supported in IE 10
+ console.trace();
+ }
+ }
+ }
+
+ return this;
+};
+
+EventEmitter.prototype.on = EventEmitter.prototype.addListener;
+
+EventEmitter.prototype.once = function(type, listener) {
+ if (!isFunction(listener))
+ throw TypeError('listener must be a function');
+
+ var fired = false;
+
+ function g() {
+ this.removeListener(type, g);
+
+ if (!fired) {
+ fired = true;
+ listener.apply(this, arguments);
+ }
+ }
+
+ g.listener = listener;
+ this.on(type, g);
+
+ return this;
+};
+
+// emits a 'removeListener' event iff the listener was removed
+EventEmitter.prototype.removeListener = function(type, listener) {
+ var list, position, length, i;
+
+ if (!isFunction(listener))
+ throw TypeError('listener must be a function');
+
+ if (!this._events || !this._events[type])
+ return this;
+
+ list = this._events[type];
+ length = list.length;
+ position = -1;
+
+ if (list === listener ||
+ (isFunction(list.listener) && list.listener === listener)) {
+ delete this._events[type];
+ if (this._events.removeListener)
+ this.emit('removeListener', type, listener);
+
+ } else if (isObject(list)) {
+ for (i = length; i-- > 0;) {
+ if (list[i] === listener ||
+ (list[i].listener && list[i].listener === listener)) {
+ position = i;
+ break;
+ }
+ }
+
+ if (position < 0)
+ return this;
+
+ if (list.length === 1) {
+ list.length = 0;
+ delete this._events[type];
+ } else {
+ list.splice(position, 1);
+ }
+
+ if (this._events.removeListener)
+ this.emit('removeListener', type, listener);
+ }
+
+ return this;
+};
+
+EventEmitter.prototype.removeAllListeners = function(type) {
+ var key, listeners;
+
+ if (!this._events)
+ return this;
+
+ // not listening for removeListener, no need to emit
+ if (!this._events.removeListener) {
+ if (arguments.length === 0)
+ this._events = {};
+ else if (this._events[type])
+ delete this._events[type];
+ return this;
+ }
+
+ // emit removeListener for all listeners on all events
+ if (arguments.length === 0) {
+ for (key in this._events) {
+ if (key === 'removeListener') continue;
+ this.removeAllListeners(key);
+ }
+ this.removeAllListeners('removeListener');
+ this._events = {};
+ return this;
+ }
+
+ listeners = this._events[type];
+
+ if (isFunction(listeners)) {
+ this.removeListener(type, listeners);
+ } else if (listeners) {
+ // LIFO order
+ while (listeners.length)
+ this.removeListener(type, listeners[listeners.length - 1]);
+ }
+ delete this._events[type];
+
+ return this;
+};
+
+EventEmitter.prototype.listeners = function(type) {
+ var ret;
+ if (!this._events || !this._events[type])
+ ret = [];
+ else if (isFunction(this._events[type]))
+ ret = [this._events[type]];
+ else
+ ret = this._events[type].slice();
+ return ret;
+};
+
+EventEmitter.prototype.listenerCount = function(type) {
+ if (this._events) {
+ var evlistener = this._events[type];
+
+ if (isFunction(evlistener))
+ return 1;
+ else if (evlistener)
+ return evlistener.length;
+ }
+ return 0;
+};
+
+EventEmitter.listenerCount = function(emitter, type) {
+ return emitter.listenerCount(type);
+};
+
+function isFunction(arg) {
+ return typeof arg === 'function';
+}
+
+function isNumber(arg) {
+ return typeof arg === 'number';
+}
+
+function isObject(arg) {
+ return typeof arg === 'object' && arg !== null;
+}
+
+function isUndefined(arg) {
+ return arg === void 0;
+}
+
+},{}],56:[function(require,module,exports){
+var http = require('http');
+
+var https = module.exports;
+
+for (var key in http) {
+ if (http.hasOwnProperty(key)) https[key] = http[key];
+};
+
+https.request = function (params, cb) {
+ if (!params) params = {};
+ params.scheme = 'https';
+ params.protocol = 'https:';
+ return http.request.call(this, params, cb);
+}
+
+},{"http":78}],57:[function(require,module,exports){
+exports.read = function (buffer, offset, isLE, mLen, nBytes) {
+ var e, m
+ var eLen = (nBytes * 8) - mLen - 1
+ var eMax = (1 << eLen) - 1
+ var eBias = eMax >> 1
+ var nBits = -7
+ var i = isLE ? (nBytes - 1) : 0
+ var d = isLE ? -1 : 1
+ var s = buffer[offset + i]
+
+ i += d
+
+ e = s & ((1 << (-nBits)) - 1)
+ s >>= (-nBits)
+ nBits += eLen
+ for (; nBits > 0; e = (e * 256) + buffer[offset + i], i += d, nBits -= 8) {}
+
+ m = e & ((1 << (-nBits)) - 1)
+ e >>= (-nBits)
+ nBits += mLen
+ for (; nBits > 0; m = (m * 256) + buffer[offset + i], i += d, nBits -= 8) {}
+
+ if (e === 0) {
+ e = 1 - eBias
+ } else if (e === eMax) {
+ return m ? NaN : ((s ? -1 : 1) * Infinity)
+ } else {
+ m = m + Math.pow(2, mLen)
+ e = e - eBias
+ }
+ return (s ? -1 : 1) * m * Math.pow(2, e - mLen)
+}
+
+exports.write = function (buffer, value, offset, isLE, mLen, nBytes) {
+ var e, m, c
+ var eLen = (nBytes * 8) - mLen - 1
+ var eMax = (1 << eLen) - 1
+ var eBias = eMax >> 1
+ var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0)
+ var i = isLE ? 0 : (nBytes - 1)
+ var d = isLE ? 1 : -1
+ var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0
+
+ value = Math.abs(value)
+
+ if (isNaN(value) || value === Infinity) {
+ m = isNaN(value) ? 1 : 0
+ e = eMax
+ } else {
+ e = Math.floor(Math.log(value) / Math.LN2)
+ if (value * (c = Math.pow(2, -e)) < 1) {
+ e--
+ c *= 2
+ }
+ if (e + eBias >= 1) {
+ value += rt / c
+ } else {
+ value += rt * Math.pow(2, 1 - eBias)
+ }
+ if (value * c >= 2) {
+ e++
+ c /= 2
+ }
+
+ if (e + eBias >= eMax) {
+ m = 0
+ e = eMax
+ } else if (e + eBias >= 1) {
+ m = ((value * c) - 1) * Math.pow(2, mLen)
+ e = e + eBias
+ } else {
+ m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen)
+ e = 0
+ }
+ }
+
+ for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {}
+
+ e = (e << mLen) | m
+ eLen += mLen
+ for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {}
+
+ buffer[offset + i - d] |= s * 128
+}
+
+},{}],58:[function(require,module,exports){
+if (typeof Object.create === 'function') {
+ // implementation from standard node.js 'util' module
+ module.exports = function inherits(ctor, superCtor) {
+ ctor.super_ = superCtor
+ ctor.prototype = Object.create(superCtor.prototype, {
+ constructor: {
+ value: ctor,
+ enumerable: false,
+ writable: true,
+ configurable: true
+ }
+ });
+ };
+} else {
+ // old school shim for old browsers
+ module.exports = function inherits(ctor, superCtor) {
+ ctor.super_ = superCtor
+ var TempCtor = function () {}
+ TempCtor.prototype = superCtor.prototype
+ ctor.prototype = new TempCtor()
+ ctor.prototype.constructor = ctor
+ }
+}
+
+},{}],59:[function(require,module,exports){
+/*!
+ * Determine if an object is a Buffer
+ *
+ * @author Feross Aboukhadijeh
+ * @license MIT
+ */
+
+// The _isBuffer check is for Safari 5-7 support, because it's missing
+// Object.prototype.constructor. Remove this eventually
+module.exports = function (obj) {
+ return obj != null && (isBuffer(obj) || isSlowBuffer(obj) || !!obj._isBuffer)
+}
+
+function isBuffer (obj) {
+ return !!obj.constructor && typeof obj.constructor.isBuffer === 'function' && obj.constructor.isBuffer(obj)
+}
+
+// For Node v0.10 support. Remove this eventually.
+function isSlowBuffer (obj) {
+ return typeof obj.readFloatLE === 'function' && typeof obj.slice === 'function' && isBuffer(obj.slice(0, 0))
+}
+
+},{}],60:[function(require,module,exports){
+var toString = {}.toString;
+
+module.exports = Array.isArray || function (arr) {
+ return toString.call(arr) == '[object Array]';
+};
+
+},{}],61:[function(require,module,exports){
+!function(global, factory) {
+ 'object' == typeof exports && 'undefined' != typeof module ? factory(exports) : 'function' == typeof define && define.amd ? define([ 'exports' ], factory) : factory(global.preact = global.preact || {});
+}(this, function(exports) {
+ function VNode(nodeName, attributes, children) {
+ this.nodeName = nodeName;
+ this.attributes = attributes;
+ this.children = children;
+ this.key = attributes && attributes.key;
+ }
+ function h(nodeName, attributes) {
+ var lastSimple, child, simple, i, children = [];
+ for (i = arguments.length; i-- > 2; ) stack.push(arguments[i]);
+ if (attributes && attributes.children) {
+ if (!stack.length) stack.push(attributes.children);
+ delete attributes.children;
+ }
+ while (stack.length) if ((child = stack.pop()) instanceof Array) for (i = child.length; i--; ) stack.push(child[i]); else if (null != child && child !== !1) {
+ if ('number' == typeof child || child === !0) child = String(child);
+ simple = 'string' == typeof child;
+ if (simple && lastSimple) children[children.length - 1] += child; else {
+ children.push(child);
+ lastSimple = simple;
+ }
+ }
+ var p = new VNode(nodeName, attributes || void 0, children);
+ if (options.vnode) options.vnode(p);
+ return p;
+ }
+ function extend(obj, props) {
+ if (props) for (var i in props) obj[i] = props[i];
+ return obj;
+ }
+ function clone(obj) {
+ return extend({}, obj);
+ }
+ function delve(obj, key) {
+ for (var p = key.split('.'), i = 0; i < p.length && obj; i++) obj = obj[p[i]];
+ return obj;
+ }
+ function isFunction(obj) {
+ return 'function' == typeof obj;
+ }
+ function isString(obj) {
+ return 'string' == typeof obj;
+ }
+ function hashToClassName(c) {
+ var str = '';
+ for (var prop in c) if (c[prop]) {
+ if (str) str += ' ';
+ str += prop;
+ }
+ return str;
+ }
+ function cloneElement(vnode, props) {
+ return h(vnode.nodeName, extend(clone(vnode.attributes), props), arguments.length > 2 ? [].slice.call(arguments, 2) : vnode.children);
+ }
+ function createLinkedState(component, key, eventPath) {
+ var path = key.split('.');
+ return function(e) {
+ var t = e && e.target || this, state = {}, obj = state, v = isString(eventPath) ? delve(e, eventPath) : t.nodeName ? t.type.match(/^che|rad/) ? t.checked : t.value : e, i = 0;
+ for (;i < path.length - 1; i++) obj = obj[path[i]] || (obj[path[i]] = !i && component.state[path[i]] || {});
+ obj[path[i]] = v;
+ component.setState(state);
+ };
+ }
+ function enqueueRender(component) {
+ if (!component._dirty && (component._dirty = !0) && 1 == items.push(component)) (options.debounceRendering || defer)(rerender);
+ }
+ function rerender() {
+ var p, list = items;
+ items = [];
+ while (p = list.pop()) if (p._dirty) renderComponent(p);
+ }
+ function isFunctionalComponent(vnode) {
+ var nodeName = vnode && vnode.nodeName;
+ return nodeName && isFunction(nodeName) && !(nodeName.prototype && nodeName.prototype.render);
+ }
+ function buildFunctionalComponent(vnode, context) {
+ return vnode.nodeName(getNodeProps(vnode), context || EMPTY);
+ }
+ function isSameNodeType(node, vnode) {
+ if (isString(vnode)) return node instanceof Text;
+ if (isString(vnode.nodeName)) return isNamedNode(node, vnode.nodeName);
+ if (isFunction(vnode.nodeName)) return node._componentConstructor === vnode.nodeName || isFunctionalComponent(vnode); else ;
+ }
+ function isNamedNode(node, nodeName) {
+ return node.normalizedNodeName === nodeName || toLowerCase(node.nodeName) === toLowerCase(nodeName);
+ }
+ function getNodeProps(vnode) {
+ var props = clone(vnode.attributes);
+ props.children = vnode.children;
+ var defaultProps = vnode.nodeName.defaultProps;
+ if (defaultProps) for (var i in defaultProps) if (void 0 === props[i]) props[i] = defaultProps[i];
+ return props;
+ }
+ function removeNode(node) {
+ var p = node.parentNode;
+ if (p) p.removeChild(node);
+ }
+ function setAccessor(node, name, old, value, isSvg) {
+ if ('className' === name) name = 'class';
+ if ('class' === name && value && 'object' == typeof value) value = hashToClassName(value);
+ if ('key' === name) ; else if ('class' === name && !isSvg) node.className = value || ''; else if ('style' === name) {
+ if (!value || isString(value) || isString(old)) node.style.cssText = value || '';
+ if (value && 'object' == typeof value) {
+ if (!isString(old)) for (var i in old) if (!(i in value)) node.style[i] = '';
+ for (var i in value) node.style[i] = 'number' == typeof value[i] && !NON_DIMENSION_PROPS[i] ? value[i] + 'px' : value[i];
+ }
+ } else if ('dangerouslySetInnerHTML' === name) {
+ if (value) node.innerHTML = value.__html;
+ } else if ('o' == name[0] && 'n' == name[1]) {
+ var l = node._listeners || (node._listeners = {});
+ name = toLowerCase(name.substring(2));
+ if (value) {
+ if (!l[name]) node.addEventListener(name, eventProxy, !!NON_BUBBLING_EVENTS[name]);
+ } else if (l[name]) node.removeEventListener(name, eventProxy, !!NON_BUBBLING_EVENTS[name]);
+ l[name] = value;
+ } else if ('list' !== name && 'type' !== name && !isSvg && name in node) {
+ setProperty(node, name, null == value ? '' : value);
+ if (null == value || value === !1) node.removeAttribute(name);
+ } else {
+ var ns = isSvg && name.match(/^xlink\:?(.+)/);
+ if (null == value || value === !1) if (ns) node.removeAttributeNS('http://www.w3.org/1999/xlink', toLowerCase(ns[1])); else node.removeAttribute(name); else if ('object' != typeof value && !isFunction(value)) if (ns) node.setAttributeNS('http://www.w3.org/1999/xlink', toLowerCase(ns[1]), value); else node.setAttribute(name, value);
+ }
+ }
+ function setProperty(node, name, value) {
+ try {
+ node[name] = value;
+ } catch (e) {}
+ }
+ function eventProxy(e) {
+ return this._listeners[e.type](options.event && options.event(e) || e);
+ }
+ function collectNode(node) {
+ removeNode(node);
+ if (node instanceof Element) {
+ node._component = node._componentConstructor = null;
+ var _name = node.normalizedNodeName || toLowerCase(node.nodeName);
+ (nodes[_name] || (nodes[_name] = [])).push(node);
+ }
+ }
+ function createNode(nodeName, isSvg) {
+ var name = toLowerCase(nodeName), node = nodes[name] && nodes[name].pop() || (isSvg ? document.createElementNS('http://www.w3.org/2000/svg', nodeName) : document.createElement(nodeName));
+ node.normalizedNodeName = name;
+ return node;
+ }
+ function flushMounts() {
+ var c;
+ while (c = mounts.pop()) {
+ if (options.afterMount) options.afterMount(c);
+ if (c.componentDidMount) c.componentDidMount();
+ }
+ }
+ function diff(dom, vnode, context, mountAll, parent, componentRoot) {
+ if (!diffLevel++) isSvgMode = parent instanceof SVGElement;
+ var ret = idiff(dom, vnode, context, mountAll);
+ if (parent && ret.parentNode !== parent) parent.appendChild(ret);
+ if (!--diffLevel && !componentRoot) flushMounts();
+ return ret;
+ }
+ function idiff(dom, vnode, context, mountAll) {
+ var originalAttributes = vnode && vnode.attributes;
+ while (isFunctionalComponent(vnode)) vnode = buildFunctionalComponent(vnode, context);
+ if (null == vnode) vnode = '';
+ if (isString(vnode)) {
+ if (dom) {
+ if (dom instanceof Text && dom.parentNode) {
+ if (dom.nodeValue != vnode) dom.nodeValue = vnode;
+ return dom;
+ }
+ recollectNodeTree(dom);
+ }
+ return document.createTextNode(vnode);
+ }
+ if (isFunction(vnode.nodeName)) return buildComponentFromVNode(dom, vnode, context, mountAll);
+ var out = dom, nodeName = vnode.nodeName, prevSvgMode = isSvgMode, vchildren = vnode.children;
+ if (!isString(nodeName)) nodeName = String(nodeName);
+ isSvgMode = 'svg' === nodeName ? !0 : 'foreignObject' === nodeName ? !1 : isSvgMode;
+ if (!dom) out = createNode(nodeName, isSvgMode); else if (!isNamedNode(dom, nodeName)) {
+ out = createNode(nodeName, isSvgMode);
+ while (dom.firstChild) out.appendChild(dom.firstChild);
+ recollectNodeTree(dom);
+ }
+ if (vchildren && 1 === vchildren.length && 'string' == typeof vchildren[0] && 1 === out.childNodes.length && out.firstChild instanceof Text) {
+ if (out.firstChild.nodeValue != vchildren[0]) out.firstChild.nodeValue = vchildren[0];
+ } else if (vchildren && vchildren.length || out.firstChild) innerDiffNode(out, vchildren, context, mountAll);
+ var props = out[ATTR_KEY];
+ if (!props) {
+ out[ATTR_KEY] = props = {};
+ for (var a = out.attributes, i = a.length; i--; ) props[a[i].name] = a[i].value;
+ }
+ diffAttributes(out, vnode.attributes, props);
+ if (originalAttributes && 'function' == typeof originalAttributes.ref) (props.ref = originalAttributes.ref)(out);
+ isSvgMode = prevSvgMode;
+ return out;
+ }
+ function innerDiffNode(dom, vchildren, context, mountAll) {
+ var j, c, vchild, child, originalChildren = dom.childNodes, children = [], keyed = {}, keyedLen = 0, min = 0, len = originalChildren.length, childrenLen = 0, vlen = vchildren && vchildren.length;
+ if (len) for (var i = 0; i < len; i++) {
+ var _child = originalChildren[i], key = vlen ? (c = _child._component) ? c.__key : (c = _child[ATTR_KEY]) ? c.key : null : null;
+ if (key || 0 === key) {
+ keyedLen++;
+ keyed[key] = _child;
+ } else children[childrenLen++] = _child;
+ }
+ if (vlen) for (var i = 0; i < vlen; i++) {
+ vchild = vchildren[i];
+ child = null;
+ var key = vchild.key;
+ if (null != key) {
+ if (keyedLen && key in keyed) {
+ child = keyed[key];
+ keyed[key] = void 0;
+ keyedLen--;
+ }
+ } else if (!child && min < childrenLen) {
+ for (j = min; j < childrenLen; j++) {
+ c = children[j];
+ if (c && isSameNodeType(c, vchild)) {
+ child = c;
+ children[j] = void 0;
+ if (j === childrenLen - 1) childrenLen--;
+ if (j === min) min++;
+ break;
+ }
+ }
+ if (!child && min < childrenLen && isFunction(vchild.nodeName) && mountAll) {
+ child = children[min];
+ children[min++] = void 0;
+ }
+ }
+ child = idiff(child, vchild, context, mountAll);
+ if (child && child !== dom && child !== originalChildren[i]) dom.insertBefore(child, originalChildren[i] || null);
+ }
+ if (keyedLen) for (var i in keyed) if (keyed[i]) recollectNodeTree(keyed[i]);
+ if (min < childrenLen) removeOrphanedChildren(children);
+ }
+ function removeOrphanedChildren(children, unmountOnly) {
+ for (var i = children.length; i--; ) if (children[i]) recollectNodeTree(children[i], unmountOnly);
+ }
+ function recollectNodeTree(node, unmountOnly) {
+ var component = node._component;
+ if (component) unmountComponent(component, !unmountOnly); else {
+ if (node[ATTR_KEY] && node[ATTR_KEY].ref) node[ATTR_KEY].ref(null);
+ if (!unmountOnly) collectNode(node);
+ if (node.childNodes && node.childNodes.length) removeOrphanedChildren(node.childNodes, unmountOnly);
+ }
+ }
+ function diffAttributes(dom, attrs, old) {
+ for (var _name in old) if (!(attrs && _name in attrs) && null != old[_name]) setAccessor(dom, _name, old[_name], old[_name] = void 0, isSvgMode);
+ if (attrs) for (var _name2 in attrs) if (!('children' === _name2 || 'innerHTML' === _name2 || _name2 in old && attrs[_name2] === ('value' === _name2 || 'checked' === _name2 ? dom[_name2] : old[_name2]))) setAccessor(dom, _name2, old[_name2], old[_name2] = attrs[_name2], isSvgMode);
+ }
+ function collectComponent(component) {
+ var name = component.constructor.name, list = components[name];
+ if (list) list.push(component); else components[name] = [ component ];
+ }
+ function createComponent(Ctor, props, context) {
+ var inst = new Ctor(props, context), list = components[Ctor.name];
+ Component.call(inst, props, context);
+ if (list) for (var i = list.length; i--; ) if (list[i].constructor === Ctor) {
+ inst.nextBase = list[i].nextBase;
+ list.splice(i, 1);
+ break;
+ }
+ return inst;
+ }
+ function setComponentProps(component, props, opts, context, mountAll) {
+ if (!component._disable) {
+ component._disable = !0;
+ if (component.__ref = props.ref) delete props.ref;
+ if (component.__key = props.key) delete props.key;
+ if (!component.base || mountAll) {
+ if (component.componentWillMount) component.componentWillMount();
+ } else if (component.componentWillReceiveProps) component.componentWillReceiveProps(props, context);
+ if (context && context !== component.context) {
+ if (!component.prevContext) component.prevContext = component.context;
+ component.context = context;
+ }
+ if (!component.prevProps) component.prevProps = component.props;
+ component.props = props;
+ component._disable = !1;
+ if (0 !== opts) if (1 === opts || options.syncComponentUpdates !== !1 || !component.base) renderComponent(component, 1, mountAll); else enqueueRender(component);
+ if (component.__ref) component.__ref(component);
+ }
+ }
+ function renderComponent(component, opts, mountAll, isChild) {
+ if (!component._disable) {
+ var skip, rendered, inst, cbase, props = component.props, state = component.state, context = component.context, previousProps = component.prevProps || props, previousState = component.prevState || state, previousContext = component.prevContext || context, isUpdate = component.base, nextBase = component.nextBase, initialBase = isUpdate || nextBase, initialChildComponent = component._component;
+ if (isUpdate) {
+ component.props = previousProps;
+ component.state = previousState;
+ component.context = previousContext;
+ if (2 !== opts && component.shouldComponentUpdate && component.shouldComponentUpdate(props, state, context) === !1) skip = !0; else if (component.componentWillUpdate) component.componentWillUpdate(props, state, context);
+ component.props = props;
+ component.state = state;
+ component.context = context;
+ }
+ component.prevProps = component.prevState = component.prevContext = component.nextBase = null;
+ component._dirty = !1;
+ if (!skip) {
+ if (component.render) rendered = component.render(props, state, context);
+ if (component.getChildContext) context = extend(clone(context), component.getChildContext());
+ while (isFunctionalComponent(rendered)) rendered = buildFunctionalComponent(rendered, context);
+ var toUnmount, base, childComponent = rendered && rendered.nodeName;
+ if (isFunction(childComponent)) {
+ inst = initialChildComponent;
+ var childProps = getNodeProps(rendered);
+ if (inst && inst.constructor === childComponent) setComponentProps(inst, childProps, 1, context); else {
+ toUnmount = inst;
+ inst = createComponent(childComponent, childProps, context);
+ inst.nextBase = inst.nextBase || nextBase;
+ inst._parentComponent = component;
+ component._component = inst;
+ setComponentProps(inst, childProps, 0, context);
+ renderComponent(inst, 1, mountAll, !0);
+ }
+ base = inst.base;
+ } else {
+ cbase = initialBase;
+ toUnmount = initialChildComponent;
+ if (toUnmount) cbase = component._component = null;
+ if (initialBase || 1 === opts) {
+ if (cbase) cbase._component = null;
+ base = diff(cbase, rendered, context, mountAll || !isUpdate, initialBase && initialBase.parentNode, !0);
+ }
+ }
+ if (initialBase && base !== initialBase && inst !== initialChildComponent) {
+ var baseParent = initialBase.parentNode;
+ if (baseParent && base !== baseParent) {
+ baseParent.replaceChild(base, initialBase);
+ if (!toUnmount) {
+ initialBase._component = null;
+ recollectNodeTree(initialBase);
+ }
+ }
+ }
+ if (toUnmount) unmountComponent(toUnmount, base !== initialBase);
+ component.base = base;
+ if (base && !isChild) {
+ var componentRef = component, t = component;
+ while (t = t._parentComponent) (componentRef = t).base = base;
+ base._component = componentRef;
+ base._componentConstructor = componentRef.constructor;
+ }
+ }
+ if (!isUpdate || mountAll) mounts.unshift(component); else if (!skip) {
+ if (component.componentDidUpdate) component.componentDidUpdate(previousProps, previousState, previousContext);
+ if (options.afterUpdate) options.afterUpdate(component);
+ }
+ var fn, cb = component._renderCallbacks;
+ if (cb) while (fn = cb.pop()) fn.call(component);
+ if (!diffLevel && !isChild) flushMounts();
+ }
+ }
+ function buildComponentFromVNode(dom, vnode, context, mountAll) {
+ var c = dom && dom._component, oldDom = dom, isDirectOwner = c && dom._componentConstructor === vnode.nodeName, isOwner = isDirectOwner, props = getNodeProps(vnode);
+ while (c && !isOwner && (c = c._parentComponent)) isOwner = c.constructor === vnode.nodeName;
+ if (c && isOwner && (!mountAll || c._component)) {
+ setComponentProps(c, props, 3, context, mountAll);
+ dom = c.base;
+ } else {
+ if (c && !isDirectOwner) {
+ unmountComponent(c, !0);
+ dom = oldDom = null;
+ }
+ c = createComponent(vnode.nodeName, props, context);
+ if (dom && !c.nextBase) {
+ c.nextBase = dom;
+ oldDom = null;
+ }
+ setComponentProps(c, props, 1, context, mountAll);
+ dom = c.base;
+ if (oldDom && dom !== oldDom) {
+ oldDom._component = null;
+ recollectNodeTree(oldDom);
+ }
+ }
+ return dom;
+ }
+ function unmountComponent(component, remove) {
+ if (options.beforeUnmount) options.beforeUnmount(component);
+ var base = component.base;
+ component._disable = !0;
+ if (component.componentWillUnmount) component.componentWillUnmount();
+ component.base = null;
+ var inner = component._component;
+ if (inner) unmountComponent(inner, remove); else if (base) {
+ if (base[ATTR_KEY] && base[ATTR_KEY].ref) base[ATTR_KEY].ref(null);
+ component.nextBase = base;
+ if (remove) {
+ removeNode(base);
+ collectComponent(component);
+ }
+ removeOrphanedChildren(base.childNodes, !remove);
+ }
+ if (component.__ref) component.__ref(null);
+ if (component.componentDidUnmount) component.componentDidUnmount();
+ }
+ function Component(props, context) {
+ this._dirty = !0;
+ this.context = context;
+ this.props = props;
+ if (!this.state) this.state = {};
+ }
+ function render(vnode, parent, merge) {
+ return diff(merge, vnode, {}, !1, parent);
+ }
+ var options = {};
+ var stack = [];
+ var lcCache = {};
+ var toLowerCase = function(s) {
+ return lcCache[s] || (lcCache[s] = s.toLowerCase());
+ };
+ var resolved = 'undefined' != typeof Promise && Promise.resolve();
+ var defer = resolved ? function(f) {
+ resolved.then(f);
+ } : setTimeout;
+ var EMPTY = {};
+ var ATTR_KEY = 'undefined' != typeof Symbol ? Symbol.for('preactattr') : '__preactattr_';
+ var NON_DIMENSION_PROPS = {
+ boxFlex: 1,
+ boxFlexGroup: 1,
+ columnCount: 1,
+ fillOpacity: 1,
+ flex: 1,
+ flexGrow: 1,
+ flexPositive: 1,
+ flexShrink: 1,
+ flexNegative: 1,
+ fontWeight: 1,
+ lineClamp: 1,
+ lineHeight: 1,
+ opacity: 1,
+ order: 1,
+ orphans: 1,
+ strokeOpacity: 1,
+ widows: 1,
+ zIndex: 1,
+ zoom: 1
+ };
+ var NON_BUBBLING_EVENTS = {
+ blur: 1,
+ error: 1,
+ focus: 1,
+ load: 1,
+ resize: 1,
+ scroll: 1
+ };
+ var items = [];
+ var nodes = {};
+ var mounts = [];
+ var diffLevel = 0;
+ var isSvgMode = !1;
+ var components = {};
+ extend(Component.prototype, {
+ linkState: function(key, eventPath) {
+ var c = this._linkedStates || (this._linkedStates = {});
+ return c[key + eventPath] || (c[key + eventPath] = createLinkedState(this, key, eventPath));
+ },
+ setState: function(state, callback) {
+ var s = this.state;
+ if (!this.prevState) this.prevState = clone(s);
+ extend(s, isFunction(state) ? state(s, this.props) : state);
+ if (callback) (this._renderCallbacks = this._renderCallbacks || []).push(callback);
+ enqueueRender(this);
+ },
+ forceUpdate: function() {
+ renderComponent(this, 2);
+ },
+ render: function() {}
+ });
+ exports.h = h;
+ exports.cloneElement = cloneElement;
+ exports.Component = Component;
+ exports.render = render;
+ exports.rerender = rerender;
+ exports.options = options;
+});
+
+},{}],62:[function(require,module,exports){
+(function (process){
+'use strict';
+
+if (!process.version ||
+ process.version.indexOf('v0.') === 0 ||
+ process.version.indexOf('v1.') === 0 && process.version.indexOf('v1.8.') !== 0) {
+ module.exports = { nextTick: nextTick };
+} else {
+ module.exports = process
+}
+
+function nextTick(fn, arg1, arg2, arg3) {
+ if (typeof fn !== 'function') {
+ throw new TypeError('"callback" argument must be a function');
+ }
+ var len = arguments.length;
+ var args, i;
+ switch (len) {
+ case 0:
+ case 1:
+ return process.nextTick(fn);
+ case 2:
+ return process.nextTick(function afterTickOne() {
+ fn.call(null, arg1);
+ });
+ case 3:
+ return process.nextTick(function afterTickTwo() {
+ fn.call(null, arg1, arg2);
+ });
+ case 4:
+ return process.nextTick(function afterTickThree() {
+ fn.call(null, arg1, arg2, arg3);
+ });
+ default:
+ args = new Array(len - 1);
+ i = 0;
+ while (i < args.length) {
+ args[i++] = arguments[i];
+ }
+ return process.nextTick(function afterTick() {
+ fn.apply(null, args);
+ });
+ }
+}
+
+
+}).call(this,require('_process'))
+
+},{"_process":63}],63:[function(require,module,exports){
+// shim for using process in browser
+var process = module.exports = {};
+
+// cached from whatever global is present so that test runners that stub it
+// don't break things. But we need to wrap it in a try catch in case it is
+// wrapped in strict mode code which doesn't define any globals. It's inside a
+// function because try/catches deoptimize in certain engines.
+
+var cachedSetTimeout;
+var cachedClearTimeout;
+
+function defaultSetTimout() {
+ throw new Error('setTimeout has not been defined');
+}
+function defaultClearTimeout () {
+ throw new Error('clearTimeout has not been defined');
+}
+(function () {
+ try {
+ if (typeof setTimeout === 'function') {
+ cachedSetTimeout = setTimeout;
+ } else {
+ cachedSetTimeout = defaultSetTimout;
+ }
+ } catch (e) {
+ cachedSetTimeout = defaultSetTimout;
+ }
+ try {
+ if (typeof clearTimeout === 'function') {
+ cachedClearTimeout = clearTimeout;
+ } else {
+ cachedClearTimeout = defaultClearTimeout;
+ }
+ } catch (e) {
+ cachedClearTimeout = defaultClearTimeout;
+ }
+} ())
+function runTimeout(fun) {
+ if (cachedSetTimeout === setTimeout) {
+ //normal enviroments in sane situations
+ return setTimeout(fun, 0);
+ }
+ // if setTimeout wasn't available but was latter defined
+ if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
+ cachedSetTimeout = setTimeout;
+ return setTimeout(fun, 0);
+ }
+ try {
+ // when when somebody has screwed with setTimeout but no I.E. maddness
+ return cachedSetTimeout(fun, 0);
+ } catch(e){
+ try {
+ // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
+ return cachedSetTimeout.call(null, fun, 0);
+ } catch(e){
+ // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error
+ return cachedSetTimeout.call(this, fun, 0);
+ }
+ }
+
+
+}
+function runClearTimeout(marker) {
+ if (cachedClearTimeout === clearTimeout) {
+ //normal enviroments in sane situations
+ return clearTimeout(marker);
+ }
+ // if clearTimeout wasn't available but was latter defined
+ if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
+ cachedClearTimeout = clearTimeout;
+ return clearTimeout(marker);
+ }
+ try {
+ // when when somebody has screwed with setTimeout but no I.E. maddness
+ return cachedClearTimeout(marker);
+ } catch (e){
+ try {
+ // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
+ return cachedClearTimeout.call(null, marker);
+ } catch (e){
+ // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error.
+ // Some versions of I.E. have different rules for clearTimeout vs setTimeout
+ return cachedClearTimeout.call(this, marker);
+ }
+ }
+
+
+
+}
+var queue = [];
+var draining = false;
+var currentQueue;
+var queueIndex = -1;
+
+function cleanUpNextTick() {
+ if (!draining || !currentQueue) {
+ return;
+ }
+ draining = false;
+ if (currentQueue.length) {
+ queue = currentQueue.concat(queue);
+ } else {
+ queueIndex = -1;
+ }
+ if (queue.length) {
+ drainQueue();
+ }
+}
+
+function drainQueue() {
+ if (draining) {
+ return;
+ }
+ var timeout = runTimeout(cleanUpNextTick);
+ draining = true;
+
+ var len = queue.length;
+ while(len) {
+ currentQueue = queue;
+ queue = [];
+ while (++queueIndex < len) {
+ if (currentQueue) {
+ currentQueue[queueIndex].run();
+ }
+ }
+ queueIndex = -1;
+ len = queue.length;
+ }
+ currentQueue = null;
+ draining = false;
+ runClearTimeout(timeout);
+}
+
+process.nextTick = function (fun) {
+ var args = new Array(arguments.length - 1);
+ if (arguments.length > 1) {
+ for (var i = 1; i < arguments.length; i++) {
+ args[i - 1] = arguments[i];
+ }
+ }
+ queue.push(new Item(fun, args));
+ if (queue.length === 1 && !draining) {
+ runTimeout(drainQueue);
+ }
+};
+
+// v8 likes predictible objects
+function Item(fun, array) {
+ this.fun = fun;
+ this.array = array;
+}
+Item.prototype.run = function () {
+ this.fun.apply(null, this.array);
+};
+process.title = 'browser';
+process.browser = true;
+process.env = {};
+process.argv = [];
+process.version = ''; // empty string to avoid regexp issues
+process.versions = {};
+
+function noop() {}
+
+process.on = noop;
+process.addListener = noop;
+process.once = noop;
+process.off = noop;
+process.removeListener = noop;
+process.removeAllListeners = noop;
+process.emit = noop;
+process.prependListener = noop;
+process.prependOnceListener = noop;
+
+process.listeners = function (name) { return [] }
+
+process.binding = function (name) {
+ throw new Error('process.binding is not supported');
+};
+
+process.cwd = function () { return '/' };
+process.chdir = function (dir) {
+ throw new Error('process.chdir is not supported');
+};
+process.umask = function() { return 0; };
+
+},{}],64:[function(require,module,exports){
+(function (global){
+/*! https://mths.be/punycode v1.4.1 by @mathias */
+;(function(root) {
+
+ /** Detect free variables */
+ var freeExports = typeof exports == 'object' && exports &&
+ !exports.nodeType && exports;
+ var freeModule = typeof module == 'object' && module &&
+ !module.nodeType && module;
+ var freeGlobal = typeof global == 'object' && global;
+ if (
+ freeGlobal.global === freeGlobal ||
+ freeGlobal.window === freeGlobal ||
+ freeGlobal.self === freeGlobal
+ ) {
+ root = freeGlobal;
+ }
+
+ /**
+ * The `punycode` object.
+ * @name punycode
+ * @type Object
+ */
+ var punycode,
+
+ /** Highest positive signed 32-bit float value */
+ maxInt = 2147483647, // aka. 0x7FFFFFFF or 2^31-1
+
+ /** Bootstring parameters */
+ base = 36,
+ tMin = 1,
+ tMax = 26,
+ skew = 38,
+ damp = 700,
+ initialBias = 72,
+ initialN = 128, // 0x80
+ delimiter = '-', // '\x2D'
+
+ /** Regular expressions */
+ regexPunycode = /^xn--/,
+ regexNonASCII = /[^\x20-\x7E]/, // unprintable ASCII chars + non-ASCII chars
+ regexSeparators = /[\x2E\u3002\uFF0E\uFF61]/g, // RFC 3490 separators
+
+ /** Error messages */
+ errors = {
+ 'overflow': 'Overflow: input needs wider integers to process',
+ 'not-basic': 'Illegal input >= 0x80 (not a basic code point)',
+ 'invalid-input': 'Invalid input'
+ },
+
+ /** Convenience shortcuts */
+ baseMinusTMin = base - tMin,
+ floor = Math.floor,
+ stringFromCharCode = String.fromCharCode,
+
+ /** Temporary variable */
+ key;
+
+ /*--------------------------------------------------------------------------*/
+
+ /**
+ * A generic error utility function.
+ * @private
+ * @param {String} type The error type.
+ * @returns {Error} Throws a `RangeError` with the applicable error message.
+ */
+ function error(type) {
+ throw new RangeError(errors[type]);
+ }
+
+ /**
+ * A generic `Array#map` utility function.
+ * @private
+ * @param {Array} array The array to iterate over.
+ * @param {Function} callback The function that gets called for every array
+ * item.
+ * @returns {Array} A new array of values returned by the callback function.
+ */
+ function map(array, fn) {
+ var length = array.length;
+ var result = [];
+ while (length--) {
+ result[length] = fn(array[length]);
+ }
+ return result;
+ }
+
+ /**
+ * A simple `Array#map`-like wrapper to work with domain name strings or email
+ * addresses.
+ * @private
+ * @param {String} domain The domain name or email address.
+ * @param {Function} callback The function that gets called for every
+ * character.
+ * @returns {Array} A new string of characters returned by the callback
+ * function.
+ */
+ function mapDomain(string, fn) {
+ var parts = string.split('@');
+ var result = '';
+ if (parts.length > 1) {
+ // In email addresses, only the domain name should be punycoded. Leave
+ // the local part (i.e. everything up to `@`) intact.
+ result = parts[0] + '@';
+ string = parts[1];
+ }
+ // Avoid `split(regex)` for IE8 compatibility. See #17.
+ string = string.replace(regexSeparators, '\x2E');
+ var labels = string.split('.');
+ var encoded = map(labels, fn).join('.');
+ return result + encoded;
+ }
+
+ /**
+ * Creates an array containing the numeric code points of each Unicode
+ * character in the string. While JavaScript uses UCS-2 internally,
+ * this function will convert a pair of surrogate halves (each of which
+ * UCS-2 exposes as separate characters) into a single code point,
+ * matching UTF-16.
+ * @see `punycode.ucs2.encode`
+ * @see
+ * @memberOf punycode.ucs2
+ * @name decode
+ * @param {String} string The Unicode input string (UCS-2).
+ * @returns {Array} The new array of code points.
+ */
+ function ucs2decode(string) {
+ var output = [],
+ counter = 0,
+ length = string.length,
+ value,
+ extra;
+ while (counter < length) {
+ value = string.charCodeAt(counter++);
+ if (value >= 0xD800 && value <= 0xDBFF && counter < length) {
+ // high surrogate, and there is a next character
+ extra = string.charCodeAt(counter++);
+ if ((extra & 0xFC00) == 0xDC00) { // low surrogate
+ output.push(((value & 0x3FF) << 10) + (extra & 0x3FF) + 0x10000);
+ } else {
+ // unmatched surrogate; only append this code unit, in case the next
+ // code unit is the high surrogate of a surrogate pair
+ output.push(value);
+ counter--;
+ }
+ } else {
+ output.push(value);
+ }
+ }
+ return output;
+ }
+
+ /**
+ * Creates a string based on an array of numeric code points.
+ * @see `punycode.ucs2.decode`
+ * @memberOf punycode.ucs2
+ * @name encode
+ * @param {Array} codePoints The array of numeric code points.
+ * @returns {String} The new Unicode string (UCS-2).
+ */
+ function ucs2encode(array) {
+ return map(array, function(value) {
+ var output = '';
+ if (value > 0xFFFF) {
+ value -= 0x10000;
+ output += stringFromCharCode(value >>> 10 & 0x3FF | 0xD800);
+ value = 0xDC00 | value & 0x3FF;
+ }
+ output += stringFromCharCode(value);
+ return output;
+ }).join('');
+ }
+
+ /**
+ * Converts a basic code point into a digit/integer.
+ * @see `digitToBasic()`
+ * @private
+ * @param {Number} codePoint The basic numeric code point value.
+ * @returns {Number} The numeric value of a basic code point (for use in
+ * representing integers) in the range `0` to `base - 1`, or `base` if
+ * the code point does not represent a value.
+ */
+ function basicToDigit(codePoint) {
+ if (codePoint - 48 < 10) {
+ return codePoint - 22;
+ }
+ if (codePoint - 65 < 26) {
+ return codePoint - 65;
+ }
+ if (codePoint - 97 < 26) {
+ return codePoint - 97;
+ }
+ return base;
+ }
+
+ /**
+ * Converts a digit/integer into a basic code point.
+ * @see `basicToDigit()`
+ * @private
+ * @param {Number} digit The numeric value of a basic code point.
+ * @returns {Number} The basic code point whose value (when used for
+ * representing integers) is `digit`, which needs to be in the range
+ * `0` to `base - 1`. If `flag` is non-zero, the uppercase form is
+ * used; else, the lowercase form is used. The behavior is undefined
+ * if `flag` is non-zero and `digit` has no uppercase form.
+ */
+ function digitToBasic(digit, flag) {
+ // 0..25 map to ASCII a..z or A..Z
+ // 26..35 map to ASCII 0..9
+ return digit + 22 + 75 * (digit < 26) - ((flag != 0) << 5);
+ }
+
+ /**
+ * Bias adaptation function as per section 3.4 of RFC 3492.
+ * https://tools.ietf.org/html/rfc3492#section-3.4
+ * @private
+ */
+ function adapt(delta, numPoints, firstTime) {
+ var k = 0;
+ delta = firstTime ? floor(delta / damp) : delta >> 1;
+ delta += floor(delta / numPoints);
+ for (/* no initialization */; delta > baseMinusTMin * tMax >> 1; k += base) {
+ delta = floor(delta / baseMinusTMin);
+ }
+ return floor(k + (baseMinusTMin + 1) * delta / (delta + skew));
+ }
+
+ /**
+ * Converts a Punycode string of ASCII-only symbols to a string of Unicode
+ * symbols.
+ * @memberOf punycode
+ * @param {String} input The Punycode string of ASCII-only symbols.
+ * @returns {String} The resulting string of Unicode symbols.
+ */
+ function decode(input) {
+ // Don't use UCS-2
+ var output = [],
+ inputLength = input.length,
+ out,
+ i = 0,
+ n = initialN,
+ bias = initialBias,
+ basic,
+ j,
+ index,
+ oldi,
+ w,
+ k,
+ digit,
+ t,
+ /** Cached calculation results */
+ baseMinusT;
+
+ // Handle the basic code points: let `basic` be the number of input code
+ // points before the last delimiter, or `0` if there is none, then copy
+ // the first basic code points to the output.
+
+ basic = input.lastIndexOf(delimiter);
+ if (basic < 0) {
+ basic = 0;
+ }
+
+ for (j = 0; j < basic; ++j) {
+ // if it's not a basic code point
+ if (input.charCodeAt(j) >= 0x80) {
+ error('not-basic');
+ }
+ output.push(input.charCodeAt(j));
+ }
+
+ // Main decoding loop: start just after the last delimiter if any basic code
+ // points were copied; start at the beginning otherwise.
+
+ for (index = basic > 0 ? basic + 1 : 0; index < inputLength; /* no final expression */) {
+
+ // `index` is the index of the next character to be consumed.
+ // Decode a generalized variable-length integer into `delta`,
+ // which gets added to `i`. The overflow checking is easier
+ // if we increase `i` as we go, then subtract off its starting
+ // value at the end to obtain `delta`.
+ for (oldi = i, w = 1, k = base; /* no condition */; k += base) {
+
+ if (index >= inputLength) {
+ error('invalid-input');
+ }
+
+ digit = basicToDigit(input.charCodeAt(index++));
+
+ if (digit >= base || digit > floor((maxInt - i) / w)) {
+ error('overflow');
+ }
+
+ i += digit * w;
+ t = k <= bias ? tMin : (k >= bias + tMax ? tMax : k - bias);
+
+ if (digit < t) {
+ break;
+ }
+
+ baseMinusT = base - t;
+ if (w > floor(maxInt / baseMinusT)) {
+ error('overflow');
+ }
+
+ w *= baseMinusT;
+
+ }
+
+ out = output.length + 1;
+ bias = adapt(i - oldi, out, oldi == 0);
+
+ // `i` was supposed to wrap around from `out` to `0`,
+ // incrementing `n` each time, so we'll fix that now:
+ if (floor(i / out) > maxInt - n) {
+ error('overflow');
+ }
+
+ n += floor(i / out);
+ i %= out;
+
+ // Insert `n` at position `i` of the output
+ output.splice(i++, 0, n);
+
+ }
+
+ return ucs2encode(output);
+ }
+
+ /**
+ * Converts a string of Unicode symbols (e.g. a domain name label) to a
+ * Punycode string of ASCII-only symbols.
+ * @memberOf punycode
+ * @param {String} input The string of Unicode symbols.
+ * @returns {String} The resulting Punycode string of ASCII-only symbols.
+ */
+ function encode(input) {
+ var n,
+ delta,
+ handledCPCount,
+ basicLength,
+ bias,
+ j,
+ m,
+ q,
+ k,
+ t,
+ currentValue,
+ output = [],
+ /** `inputLength` will hold the number of code points in `input`. */
+ inputLength,
+ /** Cached calculation results */
+ handledCPCountPlusOne,
+ baseMinusT,
+ qMinusT;
+
+ // Convert the input in UCS-2 to Unicode
+ input = ucs2decode(input);
+
+ // Cache the length
+ inputLength = input.length;
+
+ // Initialize the state
+ n = initialN;
+ delta = 0;
+ bias = initialBias;
+
+ // Handle the basic code points
+ for (j = 0; j < inputLength; ++j) {
+ currentValue = input[j];
+ if (currentValue < 0x80) {
+ output.push(stringFromCharCode(currentValue));
+ }
+ }
+
+ handledCPCount = basicLength = output.length;
+
+ // `handledCPCount` is the number of code points that have been handled;
+ // `basicLength` is the number of basic code points.
+
+ // Finish the basic string - if it is not empty - with a delimiter
+ if (basicLength) {
+ output.push(delimiter);
+ }
+
+ // Main encoding loop:
+ while (handledCPCount < inputLength) {
+
+ // All non-basic code points < n have been handled already. Find the next
+ // larger one:
+ for (m = maxInt, j = 0; j < inputLength; ++j) {
+ currentValue = input[j];
+ if (currentValue >= n && currentValue < m) {
+ m = currentValue;
+ }
+ }
+
+ // Increase `delta` enough to advance the decoder's state to ,
+ // but guard against overflow
+ handledCPCountPlusOne = handledCPCount + 1;
+ if (m - n > floor((maxInt - delta) / handledCPCountPlusOne)) {
+ error('overflow');
+ }
+
+ delta += (m - n) * handledCPCountPlusOne;
+ n = m;
+
+ for (j = 0; j < inputLength; ++j) {
+ currentValue = input[j];
+
+ if (currentValue < n && ++delta > maxInt) {
+ error('overflow');
+ }
+
+ if (currentValue == n) {
+ // Represent delta as a generalized variable-length integer
+ for (q = delta, k = base; /* no condition */; k += base) {
+ t = k <= bias ? tMin : (k >= bias + tMax ? tMax : k - bias);
+ if (q < t) {
+ break;
+ }
+ qMinusT = q - t;
+ baseMinusT = base - t;
+ output.push(
+ stringFromCharCode(digitToBasic(t + qMinusT % baseMinusT, 0))
+ );
+ q = floor(qMinusT / baseMinusT);
+ }
+
+ output.push(stringFromCharCode(digitToBasic(q, 0)));
+ bias = adapt(delta, handledCPCountPlusOne, handledCPCount == basicLength);
+ delta = 0;
+ ++handledCPCount;
+ }
+ }
+
+ ++delta;
+ ++n;
+
+ }
+ return output.join('');
+ }
+
+ /**
+ * Converts a Punycode string representing a domain name or an email address
+ * to Unicode. Only the Punycoded parts of the input will be converted, i.e.
+ * it doesn't matter if you call it on a string that has already been
+ * converted to Unicode.
+ * @memberOf punycode
+ * @param {String} input The Punycoded domain name or email address to
+ * convert to Unicode.
+ * @returns {String} The Unicode representation of the given Punycode
+ * string.
+ */
+ function toUnicode(input) {
+ return mapDomain(input, function(string) {
+ return regexPunycode.test(string)
+ ? decode(string.slice(4).toLowerCase())
+ : string;
+ });
+ }
+
+ /**
+ * Converts a Unicode string representing a domain name or an email address to
+ * Punycode. Only the non-ASCII parts of the domain name will be converted,
+ * i.e. it doesn't matter if you call it with a domain that's already in
+ * ASCII.
+ * @memberOf punycode
+ * @param {String} input The domain name or email address to convert, as a
+ * Unicode string.
+ * @returns {String} The Punycode representation of the given domain name or
+ * email address.
+ */
+ function toASCII(input) {
+ return mapDomain(input, function(string) {
+ return regexNonASCII.test(string)
+ ? 'xn--' + encode(string)
+ : string;
+ });
+ }
+
+ /*--------------------------------------------------------------------------*/
+
+ /** Define the public API */
+ punycode = {
+ /**
+ * A string representing the current Punycode.js version number.
+ * @memberOf punycode
+ * @type String
+ */
+ 'version': '1.4.1',
+ /**
+ * An object of methods to convert from JavaScript's internal character
+ * representation (UCS-2) to Unicode code points, and back.
+ * @see
+ * @memberOf punycode
+ * @type Object
+ */
+ 'ucs2': {
+ 'decode': ucs2decode,
+ 'encode': ucs2encode
+ },
+ 'decode': decode,
+ 'encode': encode,
+ 'toASCII': toASCII,
+ 'toUnicode': toUnicode
+ };
+
+ /** Expose `punycode` */
+ // Some AMD build optimizers, like r.js, check for specific condition patterns
+ // like the following:
+ if (
+ typeof define == 'function' &&
+ typeof define.amd == 'object' &&
+ define.amd
+ ) {
+ define('punycode', function() {
+ return punycode;
+ });
+ } else if (freeExports && freeModule) {
+ if (module.exports == freeExports) {
+ // in Node.js, io.js, or RingoJS v0.8.0+
+ freeModule.exports = punycode;
+ } else {
+ // in Narwhal or RingoJS v0.7.0-
+ for (key in punycode) {
+ punycode.hasOwnProperty(key) && (freeExports[key] = punycode[key]);
+ }
+ }
+ } else {
+ // in Rhino or a web browser
+ root.punycode = punycode;
+ }
+
+}(this));
+
+}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
+
+},{}],65:[function(require,module,exports){
+// Copyright Joyent, Inc. and other Node contributors.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to permit
+// persons to whom the Software is furnished to do so, subject to the
+// following conditions:
+//
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
+// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+// USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+'use strict';
+
+// If obj.hasOwnProperty has been overridden, then calling
+// obj.hasOwnProperty(prop) will break.
+// See: https://github.com/joyent/node/issues/1707
+function hasOwnProperty(obj, prop) {
+ return Object.prototype.hasOwnProperty.call(obj, prop);
+}
+
+module.exports = function(qs, sep, eq, options) {
+ sep = sep || '&';
+ eq = eq || '=';
+ var obj = {};
+
+ if (typeof qs !== 'string' || qs.length === 0) {
+ return obj;
+ }
+
+ var regexp = /\+/g;
+ qs = qs.split(sep);
+
+ var maxKeys = 1000;
+ if (options && typeof options.maxKeys === 'number') {
+ maxKeys = options.maxKeys;
+ }
+
+ var len = qs.length;
+ // maxKeys <= 0 means that we should not limit keys count
+ if (maxKeys > 0 && len > maxKeys) {
+ len = maxKeys;
+ }
+
+ for (var i = 0; i < len; ++i) {
+ var x = qs[i].replace(regexp, '%20'),
+ idx = x.indexOf(eq),
+ kstr, vstr, k, v;
+
+ if (idx >= 0) {
+ kstr = x.substr(0, idx);
+ vstr = x.substr(idx + 1);
+ } else {
+ kstr = x;
+ vstr = '';
+ }
+
+ k = decodeURIComponent(kstr);
+ v = decodeURIComponent(vstr);
+
+ if (!hasOwnProperty(obj, k)) {
+ obj[k] = v;
+ } else if (isArray(obj[k])) {
+ obj[k].push(v);
+ } else {
+ obj[k] = [obj[k], v];
+ }
+ }
+
+ return obj;
+};
+
+var isArray = Array.isArray || function (xs) {
+ return Object.prototype.toString.call(xs) === '[object Array]';
+};
+
+},{}],66:[function(require,module,exports){
+// Copyright Joyent, Inc. and other Node contributors.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to permit
+// persons to whom the Software is furnished to do so, subject to the
+// following conditions:
+//
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
+// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+// USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+'use strict';
+
+var stringifyPrimitive = function(v) {
+ switch (typeof v) {
+ case 'string':
+ return v;
+
+ case 'boolean':
+ return v ? 'true' : 'false';
+
+ case 'number':
+ return isFinite(v) ? v : '';
+
+ default:
+ return '';
+ }
+};
+
+module.exports = function(obj, sep, eq, name) {
+ sep = sep || '&';
+ eq = eq || '=';
+ if (obj === null) {
+ obj = undefined;
+ }
+
+ if (typeof obj === 'object') {
+ return map(objectKeys(obj), function(k) {
+ var ks = encodeURIComponent(stringifyPrimitive(k)) + eq;
+ if (isArray(obj[k])) {
+ return map(obj[k], function(v) {
+ return ks + encodeURIComponent(stringifyPrimitive(v));
+ }).join(sep);
+ } else {
+ return ks + encodeURIComponent(stringifyPrimitive(obj[k]));
+ }
+ }).join(sep);
+
+ }
+
+ if (!name) return '';
+ return encodeURIComponent(stringifyPrimitive(name)) + eq +
+ encodeURIComponent(stringifyPrimitive(obj));
+};
+
+var isArray = Array.isArray || function (xs) {
+ return Object.prototype.toString.call(xs) === '[object Array]';
+};
+
+function map (xs, f) {
+ if (xs.map) return xs.map(f);
+ var res = [];
+ for (var i = 0; i < xs.length; i++) {
+ res.push(f(xs[i], i));
+ }
+ return res;
+}
+
+var objectKeys = Object.keys || function (obj) {
+ var res = [];
+ for (var key in obj) {
+ if (Object.prototype.hasOwnProperty.call(obj, key)) res.push(key);
+ }
+ return res;
+};
+
+},{}],67:[function(require,module,exports){
+'use strict';
+
+exports.decode = exports.parse = require('./decode');
+exports.encode = exports.stringify = require('./encode');
+
+},{"./decode":65,"./encode":66}],68:[function(require,module,exports){
+// Copyright Joyent, Inc. and other Node contributors.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to permit
+// persons to whom the Software is furnished to do so, subject to the
+// following conditions:
+//
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
+// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+// USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+// a duplex stream is just a stream that is both readable and writable.
+// Since JS doesn't have multiple prototypal inheritance, this class
+// prototypally inherits from Readable, and then parasitically from
+// Writable.
+
+'use strict';
+
+/**/
+
+var pna = require('process-nextick-args');
+/**/
+
+/**/
+var objectKeys = Object.keys || function (obj) {
+ var keys = [];
+ for (var key in obj) {
+ keys.push(key);
+ }return keys;
+};
+/**/
+
+module.exports = Duplex;
+
+/**/
+var util = require('core-util-is');
+util.inherits = require('inherits');
+/**/
+
+var Readable = require('./_stream_readable');
+var Writable = require('./_stream_writable');
+
+util.inherits(Duplex, Readable);
+
+{
+ // avoid scope creep, the keys array can then be collected
+ var keys = objectKeys(Writable.prototype);
+ for (var v = 0; v < keys.length; v++) {
+ var method = keys[v];
+ if (!Duplex.prototype[method]) Duplex.prototype[method] = Writable.prototype[method];
+ }
+}
+
+function Duplex(options) {
+ if (!(this instanceof Duplex)) return new Duplex(options);
+
+ Readable.call(this, options);
+ Writable.call(this, options);
+
+ if (options && options.readable === false) this.readable = false;
+
+ if (options && options.writable === false) this.writable = false;
+
+ this.allowHalfOpen = true;
+ if (options && options.allowHalfOpen === false) this.allowHalfOpen = false;
+
+ this.once('end', onend);
+}
+
+Object.defineProperty(Duplex.prototype, 'writableHighWaterMark', {
+ // making it explicit this property is not enumerable
+ // because otherwise some prototype manipulation in
+ // userland will fail
+ enumerable: false,
+ get: function () {
+ return this._writableState.highWaterMark;
+ }
+});
+
+// the no-half-open enforcer
+function onend() {
+ // if we allow half-open state, or if the writable side ended,
+ // then we're ok.
+ if (this.allowHalfOpen || this._writableState.ended) return;
+
+ // no more data can be written.
+ // But allow more writes to happen in this tick.
+ pna.nextTick(onEndNT, this);
+}
+
+function onEndNT(self) {
+ self.end();
+}
+
+Object.defineProperty(Duplex.prototype, 'destroyed', {
+ get: function () {
+ if (this._readableState === undefined || this._writableState === undefined) {
+ return false;
+ }
+ return this._readableState.destroyed && this._writableState.destroyed;
+ },
+ set: function (value) {
+ // we ignore the value if the stream
+ // has not been initialized yet
+ if (this._readableState === undefined || this._writableState === undefined) {
+ return;
+ }
+
+ // backward compatibility, the user is explicitly
+ // managing destroyed
+ this._readableState.destroyed = value;
+ this._writableState.destroyed = value;
+ }
+});
+
+Duplex.prototype._destroy = function (err, cb) {
+ this.push(null);
+ this.end();
+
+ pna.nextTick(cb, err);
+};
+},{"./_stream_readable":70,"./_stream_writable":72,"core-util-is":22,"inherits":58,"process-nextick-args":62}],69:[function(require,module,exports){
+// Copyright Joyent, Inc. and other Node contributors.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to permit
+// persons to whom the Software is furnished to do so, subject to the
+// following conditions:
+//
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
+// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+// USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+// a passthrough stream.
+// basically just the most minimal sort of Transform stream.
+// Every written chunk gets output as-is.
+
+'use strict';
+
+module.exports = PassThrough;
+
+var Transform = require('./_stream_transform');
+
+/**/
+var util = require('core-util-is');
+util.inherits = require('inherits');
+/**/
+
+util.inherits(PassThrough, Transform);
+
+function PassThrough(options) {
+ if (!(this instanceof PassThrough)) return new PassThrough(options);
+
+ Transform.call(this, options);
+}
+
+PassThrough.prototype._transform = function (chunk, encoding, cb) {
+ cb(null, chunk);
+};
+},{"./_stream_transform":71,"core-util-is":22,"inherits":58}],70:[function(require,module,exports){
+(function (process,global){
+// Copyright Joyent, Inc. and other Node contributors.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to permit
+// persons to whom the Software is furnished to do so, subject to the
+// following conditions:
+//
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
+// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+// USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+'use strict';
+
+/**/
+
+var pna = require('process-nextick-args');
+/**/
+
+module.exports = Readable;
+
+/**/
+var isArray = require('isarray');
+/**/
+
+/**/
+var Duplex;
+/**/
+
+Readable.ReadableState = ReadableState;
+
+/**/
+var EE = require('events').EventEmitter;
+
+var EElistenerCount = function (emitter, type) {
+ return emitter.listeners(type).length;
+};
+/**/
+
+/**/
+var Stream = require('./internal/streams/stream');
+/**/
+
+/**/
+
+var Buffer = require('safe-buffer').Buffer;
+var OurUint8Array = global.Uint8Array || function () {};
+function _uint8ArrayToBuffer(chunk) {
+ return Buffer.from(chunk);
+}
+function _isUint8Array(obj) {
+ return Buffer.isBuffer(obj) || obj instanceof OurUint8Array;
+}
+
+/**/
+
+/**/
+var util = require('core-util-is');
+util.inherits = require('inherits');
+/**/
+
+/**/
+var debugUtil = require('util');
+var debug = void 0;
+if (debugUtil && debugUtil.debuglog) {
+ debug = debugUtil.debuglog('stream');
+} else {
+ debug = function () {};
+}
+/**/
+
+var BufferList = require('./internal/streams/BufferList');
+var destroyImpl = require('./internal/streams/destroy');
+var StringDecoder;
+
+util.inherits(Readable, Stream);
+
+var kProxyEvents = ['error', 'close', 'destroy', 'pause', 'resume'];
+
+function prependListener(emitter, event, fn) {
+ // Sadly this is not cacheable as some libraries bundle their own
+ // event emitter implementation with them.
+ if (typeof emitter.prependListener === 'function') return emitter.prependListener(event, fn);
+
+ // This is a hack to make sure that our error handler is attached before any
+ // userland ones. NEVER DO THIS. This is here only because this code needs
+ // to continue to work with older versions of Node.js that do not include
+ // the prependListener() method. The goal is to eventually remove this hack.
+ if (!emitter._events || !emitter._events[event]) emitter.on(event, fn);else if (isArray(emitter._events[event])) emitter._events[event].unshift(fn);else emitter._events[event] = [fn, emitter._events[event]];
+}
+
+function ReadableState(options, stream) {
+ Duplex = Duplex || require('./_stream_duplex');
+
+ options = options || {};
+
+ // Duplex streams are both readable and writable, but share
+ // the same options object.
+ // However, some cases require setting options to different
+ // values for the readable and the writable sides of the duplex stream.
+ // These options can be provided separately as readableXXX and writableXXX.
+ var isDuplex = stream instanceof Duplex;
+
+ // object stream flag. Used to make read(n) ignore n and to
+ // make all the buffer merging and length checks go away
+ this.objectMode = !!options.objectMode;
+
+ if (isDuplex) this.objectMode = this.objectMode || !!options.readableObjectMode;
+
+ // the point at which it stops calling _read() to fill the buffer
+ // Note: 0 is a valid value, means "don't call _read preemptively ever"
+ var hwm = options.highWaterMark;
+ var readableHwm = options.readableHighWaterMark;
+ var defaultHwm = this.objectMode ? 16 : 16 * 1024;
+
+ if (hwm || hwm === 0) this.highWaterMark = hwm;else if (isDuplex && (readableHwm || readableHwm === 0)) this.highWaterMark = readableHwm;else this.highWaterMark = defaultHwm;
+
+ // cast to ints.
+ this.highWaterMark = Math.floor(this.highWaterMark);
+
+ // A linked list is used to store data chunks instead of an array because the
+ // linked list can remove elements from the beginning faster than
+ // array.shift()
+ this.buffer = new BufferList();
+ this.length = 0;
+ this.pipes = null;
+ this.pipesCount = 0;
+ this.flowing = null;
+ this.ended = false;
+ this.endEmitted = false;
+ this.reading = false;
+
+ // a flag to be able to tell if the event 'readable'/'data' is emitted
+ // immediately, or on a later tick. We set this to true at first, because
+ // any actions that shouldn't happen until "later" should generally also
+ // not happen before the first read call.
+ this.sync = true;
+
+ // whenever we return null, then we set a flag to say
+ // that we're awaiting a 'readable' event emission.
+ this.needReadable = false;
+ this.emittedReadable = false;
+ this.readableListening = false;
+ this.resumeScheduled = false;
+
+ // has it been destroyed
+ this.destroyed = false;
+
+ // Crypto is kind of old and crusty. Historically, its default string
+ // encoding is 'binary' so we have to make this configurable.
+ // Everything else in the universe uses 'utf8', though.
+ this.defaultEncoding = options.defaultEncoding || 'utf8';
+
+ // the number of writers that are awaiting a drain event in .pipe()s
+ this.awaitDrain = 0;
+
+ // if true, a maybeReadMore has been scheduled
+ this.readingMore = false;
+
+ this.decoder = null;
+ this.encoding = null;
+ if (options.encoding) {
+ if (!StringDecoder) StringDecoder = require('string_decoder/').StringDecoder;
+ this.decoder = new StringDecoder(options.encoding);
+ this.encoding = options.encoding;
+ }
+}
+
+function Readable(options) {
+ Duplex = Duplex || require('./_stream_duplex');
+
+ if (!(this instanceof Readable)) return new Readable(options);
+
+ this._readableState = new ReadableState(options, this);
+
+ // legacy
+ this.readable = true;
+
+ if (options) {
+ if (typeof options.read === 'function') this._read = options.read;
+
+ if (typeof options.destroy === 'function') this._destroy = options.destroy;
+ }
+
+ Stream.call(this);
+}
+
+Object.defineProperty(Readable.prototype, 'destroyed', {
+ get: function () {
+ if (this._readableState === undefined) {
+ return false;
+ }
+ return this._readableState.destroyed;
+ },
+ set: function (value) {
+ // we ignore the value if the stream
+ // has not been initialized yet
+ if (!this._readableState) {
+ return;
+ }
+
+ // backward compatibility, the user is explicitly
+ // managing destroyed
+ this._readableState.destroyed = value;
+ }
+});
+
+Readable.prototype.destroy = destroyImpl.destroy;
+Readable.prototype._undestroy = destroyImpl.undestroy;
+Readable.prototype._destroy = function (err, cb) {
+ this.push(null);
+ cb(err);
+};
+
+// Manually shove something into the read() buffer.
+// This returns true if the highWaterMark has not been hit yet,
+// similar to how Writable.write() returns true if you should
+// write() some more.
+Readable.prototype.push = function (chunk, encoding) {
+ var state = this._readableState;
+ var skipChunkCheck;
+
+ if (!state.objectMode) {
+ if (typeof chunk === 'string') {
+ encoding = encoding || state.defaultEncoding;
+ if (encoding !== state.encoding) {
+ chunk = Buffer.from(chunk, encoding);
+ encoding = '';
+ }
+ skipChunkCheck = true;
+ }
+ } else {
+ skipChunkCheck = true;
+ }
+
+ return readableAddChunk(this, chunk, encoding, false, skipChunkCheck);
+};
+
+// Unshift should *always* be something directly out of read()
+Readable.prototype.unshift = function (chunk) {
+ return readableAddChunk(this, chunk, null, true, false);
+};
+
+function readableAddChunk(stream, chunk, encoding, addToFront, skipChunkCheck) {
+ var state = stream._readableState;
+ if (chunk === null) {
+ state.reading = false;
+ onEofChunk(stream, state);
+ } else {
+ var er;
+ if (!skipChunkCheck) er = chunkInvalid(state, chunk);
+ if (er) {
+ stream.emit('error', er);
+ } else if (state.objectMode || chunk && chunk.length > 0) {
+ if (typeof chunk !== 'string' && !state.objectMode && Object.getPrototypeOf(chunk) !== Buffer.prototype) {
+ chunk = _uint8ArrayToBuffer(chunk);
+ }
+
+ if (addToFront) {
+ if (state.endEmitted) stream.emit('error', new Error('stream.unshift() after end event'));else addChunk(stream, state, chunk, true);
+ } else if (state.ended) {
+ stream.emit('error', new Error('stream.push() after EOF'));
+ } else {
+ state.reading = false;
+ if (state.decoder && !encoding) {
+ chunk = state.decoder.write(chunk);
+ if (state.objectMode || chunk.length !== 0) addChunk(stream, state, chunk, false);else maybeReadMore(stream, state);
+ } else {
+ addChunk(stream, state, chunk, false);
+ }
+ }
+ } else if (!addToFront) {
+ state.reading = false;
+ }
+ }
+
+ return needMoreData(state);
+}
+
+function addChunk(stream, state, chunk, addToFront) {
+ if (state.flowing && state.length === 0 && !state.sync) {
+ stream.emit('data', chunk);
+ stream.read(0);
+ } else {
+ // update the buffer info.
+ state.length += state.objectMode ? 1 : chunk.length;
+ if (addToFront) state.buffer.unshift(chunk);else state.buffer.push(chunk);
+
+ if (state.needReadable) emitReadable(stream);
+ }
+ maybeReadMore(stream, state);
+}
+
+function chunkInvalid(state, chunk) {
+ var er;
+ if (!_isUint8Array(chunk) && typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) {
+ er = new TypeError('Invalid non-string/buffer chunk');
+ }
+ return er;
+}
+
+// if it's past the high water mark, we can push in some more.
+// Also, if we have no data yet, we can stand some
+// more bytes. This is to work around cases where hwm=0,
+// such as the repl. Also, if the push() triggered a
+// readable event, and the user called read(largeNumber) such that
+// needReadable was set, then we ought to push more, so that another
+// 'readable' event will be triggered.
+function needMoreData(state) {
+ return !state.ended && (state.needReadable || state.length < state.highWaterMark || state.length === 0);
+}
+
+Readable.prototype.isPaused = function () {
+ return this._readableState.flowing === false;
+};
+
+// backwards compatibility.
+Readable.prototype.setEncoding = function (enc) {
+ if (!StringDecoder) StringDecoder = require('string_decoder/').StringDecoder;
+ this._readableState.decoder = new StringDecoder(enc);
+ this._readableState.encoding = enc;
+ return this;
+};
+
+// Don't raise the hwm > 8MB
+var MAX_HWM = 0x800000;
+function computeNewHighWaterMark(n) {
+ if (n >= MAX_HWM) {
+ n = MAX_HWM;
+ } else {
+ // Get the next highest power of 2 to prevent increasing hwm excessively in
+ // tiny amounts
+ n--;
+ n |= n >>> 1;
+ n |= n >>> 2;
+ n |= n >>> 4;
+ n |= n >>> 8;
+ n |= n >>> 16;
+ n++;
+ }
+ return n;
+}
+
+// This function is designed to be inlinable, so please take care when making
+// changes to the function body.
+function howMuchToRead(n, state) {
+ if (n <= 0 || state.length === 0 && state.ended) return 0;
+ if (state.objectMode) return 1;
+ if (n !== n) {
+ // Only flow one buffer at a time
+ if (state.flowing && state.length) return state.buffer.head.data.length;else return state.length;
+ }
+ // If we're asking for more than the current hwm, then raise the hwm.
+ if (n > state.highWaterMark) state.highWaterMark = computeNewHighWaterMark(n);
+ if (n <= state.length) return n;
+ // Don't have enough
+ if (!state.ended) {
+ state.needReadable = true;
+ return 0;
+ }
+ return state.length;
+}
+
+// you can override either this method, or the async _read(n) below.
+Readable.prototype.read = function (n) {
+ debug('read', n);
+ n = parseInt(n, 10);
+ var state = this._readableState;
+ var nOrig = n;
+
+ if (n !== 0) state.emittedReadable = false;
+
+ // if we're doing read(0) to trigger a readable event, but we
+ // already have a bunch of data in the buffer, then just trigger
+ // the 'readable' event and move on.
+ if (n === 0 && state.needReadable && (state.length >= state.highWaterMark || state.ended)) {
+ debug('read: emitReadable', state.length, state.ended);
+ if (state.length === 0 && state.ended) endReadable(this);else emitReadable(this);
+ return null;
+ }
+
+ n = howMuchToRead(n, state);
+
+ // if we've ended, and we're now clear, then finish it up.
+ if (n === 0 && state.ended) {
+ if (state.length === 0) endReadable(this);
+ return null;
+ }
+
+ // All the actual chunk generation logic needs to be
+ // *below* the call to _read. The reason is that in certain
+ // synthetic stream cases, such as passthrough streams, _read
+ // may be a completely synchronous operation which may change
+ // the state of the read buffer, providing enough data when
+ // before there was *not* enough.
+ //
+ // So, the steps are:
+ // 1. Figure out what the state of things will be after we do
+ // a read from the buffer.
+ //
+ // 2. If that resulting state will trigger a _read, then call _read.
+ // Note that this may be asynchronous, or synchronous. Yes, it is
+ // deeply ugly to write APIs this way, but that still doesn't mean
+ // that the Readable class should behave improperly, as streams are
+ // designed to be sync/async agnostic.
+ // Take note if the _read call is sync or async (ie, if the read call
+ // has returned yet), so that we know whether or not it's safe to emit
+ // 'readable' etc.
+ //
+ // 3. Actually pull the requested chunks out of the buffer and return.
+
+ // if we need a readable event, then we need to do some reading.
+ var doRead = state.needReadable;
+ debug('need readable', doRead);
+
+ // if we currently have less than the highWaterMark, then also read some
+ if (state.length === 0 || state.length - n < state.highWaterMark) {
+ doRead = true;
+ debug('length less than watermark', doRead);
+ }
+
+ // however, if we've ended, then there's no point, and if we're already
+ // reading, then it's unnecessary.
+ if (state.ended || state.reading) {
+ doRead = false;
+ debug('reading or ended', doRead);
+ } else if (doRead) {
+ debug('do read');
+ state.reading = true;
+ state.sync = true;
+ // if the length is currently zero, then we *need* a readable event.
+ if (state.length === 0) state.needReadable = true;
+ // call internal read method
+ this._read(state.highWaterMark);
+ state.sync = false;
+ // If _read pushed data synchronously, then `reading` will be false,
+ // and we need to re-evaluate how much data we can return to the user.
+ if (!state.reading) n = howMuchToRead(nOrig, state);
+ }
+
+ var ret;
+ if (n > 0) ret = fromList(n, state);else ret = null;
+
+ if (ret === null) {
+ state.needReadable = true;
+ n = 0;
+ } else {
+ state.length -= n;
+ }
+
+ if (state.length === 0) {
+ // If we have nothing in the buffer, then we want to know
+ // as soon as we *do* get something into the buffer.
+ if (!state.ended) state.needReadable = true;
+
+ // If we tried to read() past the EOF, then emit end on the next tick.
+ if (nOrig !== n && state.ended) endReadable(this);
+ }
+
+ if (ret !== null) this.emit('data', ret);
+
+ return ret;
+};
+
+function onEofChunk(stream, state) {
+ if (state.ended) return;
+ if (state.decoder) {
+ var chunk = state.decoder.end();
+ if (chunk && chunk.length) {
+ state.buffer.push(chunk);
+ state.length += state.objectMode ? 1 : chunk.length;
+ }
+ }
+ state.ended = true;
+
+ // emit 'readable' now to make sure it gets picked up.
+ emitReadable(stream);
+}
+
+// Don't emit readable right away in sync mode, because this can trigger
+// another read() call => stack overflow. This way, it might trigger
+// a nextTick recursion warning, but that's not so bad.
+function emitReadable(stream) {
+ var state = stream._readableState;
+ state.needReadable = false;
+ if (!state.emittedReadable) {
+ debug('emitReadable', state.flowing);
+ state.emittedReadable = true;
+ if (state.sync) pna.nextTick(emitReadable_, stream);else emitReadable_(stream);
+ }
+}
+
+function emitReadable_(stream) {
+ debug('emit readable');
+ stream.emit('readable');
+ flow(stream);
+}
+
+// at this point, the user has presumably seen the 'readable' event,
+// and called read() to consume some data. that may have triggered
+// in turn another _read(n) call, in which case reading = true if
+// it's in progress.
+// However, if we're not ended, or reading, and the length < hwm,
+// then go ahead and try to read some more preemptively.
+function maybeReadMore(stream, state) {
+ if (!state.readingMore) {
+ state.readingMore = true;
+ pna.nextTick(maybeReadMore_, stream, state);
+ }
+}
+
+function maybeReadMore_(stream, state) {
+ var len = state.length;
+ while (!state.reading && !state.flowing && !state.ended && state.length < state.highWaterMark) {
+ debug('maybeReadMore read 0');
+ stream.read(0);
+ if (len === state.length)
+ // didn't get any data, stop spinning.
+ break;else len = state.length;
+ }
+ state.readingMore = false;
+}
+
+// abstract method. to be overridden in specific implementation classes.
+// call cb(er, data) where data is <= n in length.
+// for virtual (non-string, non-buffer) streams, "length" is somewhat
+// arbitrary, and perhaps not very meaningful.
+Readable.prototype._read = function (n) {
+ this.emit('error', new Error('_read() is not implemented'));
+};
+
+Readable.prototype.pipe = function (dest, pipeOpts) {
+ var src = this;
+ var state = this._readableState;
+
+ switch (state.pipesCount) {
+ case 0:
+ state.pipes = dest;
+ break;
+ case 1:
+ state.pipes = [state.pipes, dest];
+ break;
+ default:
+ state.pipes.push(dest);
+ break;
+ }
+ state.pipesCount += 1;
+ debug('pipe count=%d opts=%j', state.pipesCount, pipeOpts);
+
+ var doEnd = (!pipeOpts || pipeOpts.end !== false) && dest !== process.stdout && dest !== process.stderr;
+
+ var endFn = doEnd ? onend : unpipe;
+ if (state.endEmitted) pna.nextTick(endFn);else src.once('end', endFn);
+
+ dest.on('unpipe', onunpipe);
+ function onunpipe(readable, unpipeInfo) {
+ debug('onunpipe');
+ if (readable === src) {
+ if (unpipeInfo && unpipeInfo.hasUnpiped === false) {
+ unpipeInfo.hasUnpiped = true;
+ cleanup();
+ }
+ }
+ }
+
+ function onend() {
+ debug('onend');
+ dest.end();
+ }
+
+ // when the dest drains, it reduces the awaitDrain counter
+ // on the source. This would be more elegant with a .once()
+ // handler in flow(), but adding and removing repeatedly is
+ // too slow.
+ var ondrain = pipeOnDrain(src);
+ dest.on('drain', ondrain);
+
+ var cleanedUp = false;
+ function cleanup() {
+ debug('cleanup');
+ // cleanup event handlers once the pipe is broken
+ dest.removeListener('close', onclose);
+ dest.removeListener('finish', onfinish);
+ dest.removeListener('drain', ondrain);
+ dest.removeListener('error', onerror);
+ dest.removeListener('unpipe', onunpipe);
+ src.removeListener('end', onend);
+ src.removeListener('end', unpipe);
+ src.removeListener('data', ondata);
+
+ cleanedUp = true;
+
+ // if the reader is waiting for a drain event from this
+ // specific writer, then it would cause it to never start
+ // flowing again.
+ // So, if this is awaiting a drain, then we just call it now.
+ // If we don't know, then assume that we are waiting for one.
+ if (state.awaitDrain && (!dest._writableState || dest._writableState.needDrain)) ondrain();
+ }
+
+ // If the user pushes more data while we're writing to dest then we'll end up
+ // in ondata again. However, we only want to increase awaitDrain once because
+ // dest will only emit one 'drain' event for the multiple writes.
+ // => Introduce a guard on increasing awaitDrain.
+ var increasedAwaitDrain = false;
+ src.on('data', ondata);
+ function ondata(chunk) {
+ debug('ondata');
+ increasedAwaitDrain = false;
+ var ret = dest.write(chunk);
+ if (false === ret && !increasedAwaitDrain) {
+ // If the user unpiped during `dest.write()`, it is possible
+ // to get stuck in a permanently paused state if that write
+ // also returned false.
+ // => Check whether `dest` is still a piping destination.
+ if ((state.pipesCount === 1 && state.pipes === dest || state.pipesCount > 1 && indexOf(state.pipes, dest) !== -1) && !cleanedUp) {
+ debug('false write response, pause', src._readableState.awaitDrain);
+ src._readableState.awaitDrain++;
+ increasedAwaitDrain = true;
+ }
+ src.pause();
+ }
+ }
+
+ // if the dest has an error, then stop piping into it.
+ // however, don't suppress the throwing behavior for this.
+ function onerror(er) {
+ debug('onerror', er);
+ unpipe();
+ dest.removeListener('error', onerror);
+ if (EElistenerCount(dest, 'error') === 0) dest.emit('error', er);
+ }
+
+ // Make sure our error handler is attached before userland ones.
+ prependListener(dest, 'error', onerror);
+
+ // Both close and finish should trigger unpipe, but only once.
+ function onclose() {
+ dest.removeListener('finish', onfinish);
+ unpipe();
+ }
+ dest.once('close', onclose);
+ function onfinish() {
+ debug('onfinish');
+ dest.removeListener('close', onclose);
+ unpipe();
+ }
+ dest.once('finish', onfinish);
+
+ function unpipe() {
+ debug('unpipe');
+ src.unpipe(dest);
+ }
+
+ // tell the dest that it's being piped to
+ dest.emit('pipe', src);
+
+ // start the flow if it hasn't been started already.
+ if (!state.flowing) {
+ debug('pipe resume');
+ src.resume();
+ }
+
+ return dest;
+};
+
+function pipeOnDrain(src) {
+ return function () {
+ var state = src._readableState;
+ debug('pipeOnDrain', state.awaitDrain);
+ if (state.awaitDrain) state.awaitDrain--;
+ if (state.awaitDrain === 0 && EElistenerCount(src, 'data')) {
+ state.flowing = true;
+ flow(src);
+ }
+ };
+}
+
+Readable.prototype.unpipe = function (dest) {
+ var state = this._readableState;
+ var unpipeInfo = { hasUnpiped: false };
+
+ // if we're not piping anywhere, then do nothing.
+ if (state.pipesCount === 0) return this;
+
+ // just one destination. most common case.
+ if (state.pipesCount === 1) {
+ // passed in one, but it's not the right one.
+ if (dest && dest !== state.pipes) return this;
+
+ if (!dest) dest = state.pipes;
+
+ // got a match.
+ state.pipes = null;
+ state.pipesCount = 0;
+ state.flowing = false;
+ if (dest) dest.emit('unpipe', this, unpipeInfo);
+ return this;
+ }
+
+ // slow case. multiple pipe destinations.
+
+ if (!dest) {
+ // remove all.
+ var dests = state.pipes;
+ var len = state.pipesCount;
+ state.pipes = null;
+ state.pipesCount = 0;
+ state.flowing = false;
+
+ for (var i = 0; i < len; i++) {
+ dests[i].emit('unpipe', this, unpipeInfo);
+ }return this;
+ }
+
+ // try to find the right one.
+ var index = indexOf(state.pipes, dest);
+ if (index === -1) return this;
+
+ state.pipes.splice(index, 1);
+ state.pipesCount -= 1;
+ if (state.pipesCount === 1) state.pipes = state.pipes[0];
+
+ dest.emit('unpipe', this, unpipeInfo);
+
+ return this;
+};
+
+// set up data events if they are asked for
+// Ensure readable listeners eventually get something
+Readable.prototype.on = function (ev, fn) {
+ var res = Stream.prototype.on.call(this, ev, fn);
+
+ if (ev === 'data') {
+ // Start flowing on next tick if stream isn't explicitly paused
+ if (this._readableState.flowing !== false) this.resume();
+ } else if (ev === 'readable') {
+ var state = this._readableState;
+ if (!state.endEmitted && !state.readableListening) {
+ state.readableListening = state.needReadable = true;
+ state.emittedReadable = false;
+ if (!state.reading) {
+ pna.nextTick(nReadingNextTick, this);
+ } else if (state.length) {
+ emitReadable(this);
+ }
+ }
+ }
+
+ return res;
+};
+Readable.prototype.addListener = Readable.prototype.on;
+
+function nReadingNextTick(self) {
+ debug('readable nexttick read 0');
+ self.read(0);
+}
+
+// pause() and resume() are remnants of the legacy readable stream API
+// If the user uses them, then switch into old mode.
+Readable.prototype.resume = function () {
+ var state = this._readableState;
+ if (!state.flowing) {
+ debug('resume');
+ state.flowing = true;
+ resume(this, state);
+ }
+ return this;
+};
+
+function resume(stream, state) {
+ if (!state.resumeScheduled) {
+ state.resumeScheduled = true;
+ pna.nextTick(resume_, stream, state);
+ }
+}
+
+function resume_(stream, state) {
+ if (!state.reading) {
+ debug('resume read 0');
+ stream.read(0);
+ }
+
+ state.resumeScheduled = false;
+ state.awaitDrain = 0;
+ stream.emit('resume');
+ flow(stream);
+ if (state.flowing && !state.reading) stream.read(0);
+}
+
+Readable.prototype.pause = function () {
+ debug('call pause flowing=%j', this._readableState.flowing);
+ if (false !== this._readableState.flowing) {
+ debug('pause');
+ this._readableState.flowing = false;
+ this.emit('pause');
+ }
+ return this;
+};
+
+function flow(stream) {
+ var state = stream._readableState;
+ debug('flow', state.flowing);
+ while (state.flowing && stream.read() !== null) {}
+}
+
+// wrap an old-style stream as the async data source.
+// This is *not* part of the readable stream interface.
+// It is an ugly unfortunate mess of history.
+Readable.prototype.wrap = function (stream) {
+ var _this = this;
+
+ var state = this._readableState;
+ var paused = false;
+
+ stream.on('end', function () {
+ debug('wrapped end');
+ if (state.decoder && !state.ended) {
+ var chunk = state.decoder.end();
+ if (chunk && chunk.length) _this.push(chunk);
+ }
+
+ _this.push(null);
+ });
+
+ stream.on('data', function (chunk) {
+ debug('wrapped data');
+ if (state.decoder) chunk = state.decoder.write(chunk);
+
+ // don't skip over falsy values in objectMode
+ if (state.objectMode && (chunk === null || chunk === undefined)) return;else if (!state.objectMode && (!chunk || !chunk.length)) return;
+
+ var ret = _this.push(chunk);
+ if (!ret) {
+ paused = true;
+ stream.pause();
+ }
+ });
+
+ // proxy all the other methods.
+ // important when wrapping filters and duplexes.
+ for (var i in stream) {
+ if (this[i] === undefined && typeof stream[i] === 'function') {
+ this[i] = function (method) {
+ return function () {
+ return stream[method].apply(stream, arguments);
+ };
+ }(i);
+ }
+ }
+
+ // proxy certain important events.
+ for (var n = 0; n < kProxyEvents.length; n++) {
+ stream.on(kProxyEvents[n], this.emit.bind(this, kProxyEvents[n]));
+ }
+
+ // when we try to consume some more bytes, simply unpause the
+ // underlying stream.
+ this._read = function (n) {
+ debug('wrapped _read', n);
+ if (paused) {
+ paused = false;
+ stream.resume();
+ }
+ };
+
+ return this;
+};
+
+Object.defineProperty(Readable.prototype, 'readableHighWaterMark', {
+ // making it explicit this property is not enumerable
+ // because otherwise some prototype manipulation in
+ // userland will fail
+ enumerable: false,
+ get: function () {
+ return this._readableState.highWaterMark;
+ }
+});
+
+// exposed for testing purposes only.
+Readable._fromList = fromList;
+
+// Pluck off n bytes from an array of buffers.
+// Length is the combined lengths of all the buffers in the list.
+// This function is designed to be inlinable, so please take care when making
+// changes to the function body.
+function fromList(n, state) {
+ // nothing buffered
+ if (state.length === 0) return null;
+
+ var ret;
+ if (state.objectMode) ret = state.buffer.shift();else if (!n || n >= state.length) {
+ // read it all, truncate the list
+ if (state.decoder) ret = state.buffer.join('');else if (state.buffer.length === 1) ret = state.buffer.head.data;else ret = state.buffer.concat(state.length);
+ state.buffer.clear();
+ } else {
+ // read part of list
+ ret = fromListPartial(n, state.buffer, state.decoder);
+ }
+
+ return ret;
+}
+
+// Extracts only enough buffered data to satisfy the amount requested.
+// This function is designed to be inlinable, so please take care when making
+// changes to the function body.
+function fromListPartial(n, list, hasStrings) {
+ var ret;
+ if (n < list.head.data.length) {
+ // slice is the same for buffers and strings
+ ret = list.head.data.slice(0, n);
+ list.head.data = list.head.data.slice(n);
+ } else if (n === list.head.data.length) {
+ // first chunk is a perfect match
+ ret = list.shift();
+ } else {
+ // result spans more than one buffer
+ ret = hasStrings ? copyFromBufferString(n, list) : copyFromBuffer(n, list);
+ }
+ return ret;
+}
+
+// Copies a specified amount of characters from the list of buffered data
+// chunks.
+// This function is designed to be inlinable, so please take care when making
+// changes to the function body.
+function copyFromBufferString(n, list) {
+ var p = list.head;
+ var c = 1;
+ var ret = p.data;
+ n -= ret.length;
+ while (p = p.next) {
+ var str = p.data;
+ var nb = n > str.length ? str.length : n;
+ if (nb === str.length) ret += str;else ret += str.slice(0, n);
+ n -= nb;
+ if (n === 0) {
+ if (nb === str.length) {
+ ++c;
+ if (p.next) list.head = p.next;else list.head = list.tail = null;
+ } else {
+ list.head = p;
+ p.data = str.slice(nb);
+ }
+ break;
+ }
+ ++c;
+ }
+ list.length -= c;
+ return ret;
+}
+
+// Copies a specified amount of bytes from the list of buffered data chunks.
+// This function is designed to be inlinable, so please take care when making
+// changes to the function body.
+function copyFromBuffer(n, list) {
+ var ret = Buffer.allocUnsafe(n);
+ var p = list.head;
+ var c = 1;
+ p.data.copy(ret);
+ n -= p.data.length;
+ while (p = p.next) {
+ var buf = p.data;
+ var nb = n > buf.length ? buf.length : n;
+ buf.copy(ret, ret.length - n, 0, nb);
+ n -= nb;
+ if (n === 0) {
+ if (nb === buf.length) {
+ ++c;
+ if (p.next) list.head = p.next;else list.head = list.tail = null;
+ } else {
+ list.head = p;
+ p.data = buf.slice(nb);
+ }
+ break;
+ }
+ ++c;
+ }
+ list.length -= c;
+ return ret;
+}
+
+function endReadable(stream) {
+ var state = stream._readableState;
+
+ // If we get here before consuming all the bytes, then that is a
+ // bug in node. Should never happen.
+ if (state.length > 0) throw new Error('"endReadable()" called on non-empty stream');
+
+ if (!state.endEmitted) {
+ state.ended = true;
+ pna.nextTick(endReadableNT, state, stream);
+ }
+}
+
+function endReadableNT(state, stream) {
+ // Check that we didn't get one last unshift.
+ if (!state.endEmitted && state.length === 0) {
+ state.endEmitted = true;
+ stream.readable = false;
+ stream.emit('end');
+ }
+}
+
+function indexOf(xs, x) {
+ for (var i = 0, l = xs.length; i < l; i++) {
+ if (xs[i] === x) return i;
+ }
+ return -1;
+}
+}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
+
+},{"./_stream_duplex":68,"./internal/streams/BufferList":73,"./internal/streams/destroy":74,"./internal/streams/stream":75,"_process":63,"core-util-is":22,"events":55,"inherits":58,"isarray":60,"process-nextick-args":62,"safe-buffer":77,"string_decoder/":82,"util":18}],71:[function(require,module,exports){
+// Copyright Joyent, Inc. and other Node contributors.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to permit
+// persons to whom the Software is furnished to do so, subject to the
+// following conditions:
+//
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
+// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+// USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+// a transform stream is a readable/writable stream where you do
+// something with the data. Sometimes it's called a "filter",
+// but that's not a great name for it, since that implies a thing where
+// some bits pass through, and others are simply ignored. (That would
+// be a valid example of a transform, of course.)
+//
+// While the output is causally related to the input, it's not a
+// necessarily symmetric or synchronous transformation. For example,
+// a zlib stream might take multiple plain-text writes(), and then
+// emit a single compressed chunk some time in the future.
+//
+// Here's how this works:
+//
+// The Transform stream has all the aspects of the readable and writable
+// stream classes. When you write(chunk), that calls _write(chunk,cb)
+// internally, and returns false if there's a lot of pending writes
+// buffered up. When you call read(), that calls _read(n) until
+// there's enough pending readable data buffered up.
+//
+// In a transform stream, the written data is placed in a buffer. When
+// _read(n) is called, it transforms the queued up data, calling the
+// buffered _write cb's as it consumes chunks. If consuming a single
+// written chunk would result in multiple output chunks, then the first
+// outputted bit calls the readcb, and subsequent chunks just go into
+// the read buffer, and will cause it to emit 'readable' if necessary.
+//
+// This way, back-pressure is actually determined by the reading side,
+// since _read has to be called to start processing a new chunk. However,
+// a pathological inflate type of transform can cause excessive buffering
+// here. For example, imagine a stream where every byte of input is
+// interpreted as an integer from 0-255, and then results in that many
+// bytes of output. Writing the 4 bytes {ff,ff,ff,ff} would result in
+// 1kb of data being output. In this case, you could write a very small
+// amount of input, and end up with a very large amount of output. In
+// such a pathological inflating mechanism, there'd be no way to tell
+// the system to stop doing the transform. A single 4MB write could
+// cause the system to run out of memory.
+//
+// However, even in such a pathological case, only a single written chunk
+// would be consumed, and then the rest would wait (un-transformed) until
+// the results of the previous transformed chunk were consumed.
+
+'use strict';
+
+module.exports = Transform;
+
+var Duplex = require('./_stream_duplex');
+
+/**/
+var util = require('core-util-is');
+util.inherits = require('inherits');
+/**/
+
+util.inherits(Transform, Duplex);
+
+function afterTransform(er, data) {
+ var ts = this._transformState;
+ ts.transforming = false;
+
+ var cb = ts.writecb;
+
+ if (!cb) {
+ return this.emit('error', new Error('write callback called multiple times'));
+ }
+
+ ts.writechunk = null;
+ ts.writecb = null;
+
+ if (data != null) // single equals check for both `null` and `undefined`
+ this.push(data);
+
+ cb(er);
+
+ var rs = this._readableState;
+ rs.reading = false;
+ if (rs.needReadable || rs.length < rs.highWaterMark) {
+ this._read(rs.highWaterMark);
+ }
+}
+
+function Transform(options) {
+ if (!(this instanceof Transform)) return new Transform(options);
+
+ Duplex.call(this, options);
+
+ this._transformState = {
+ afterTransform: afterTransform.bind(this),
+ needTransform: false,
+ transforming: false,
+ writecb: null,
+ writechunk: null,
+ writeencoding: null
+ };
+
+ // start out asking for a readable event once data is transformed.
+ this._readableState.needReadable = true;
+
+ // we have implemented the _read method, and done the other things
+ // that Readable wants before the first _read call, so unset the
+ // sync guard flag.
+ this._readableState.sync = false;
+
+ if (options) {
+ if (typeof options.transform === 'function') this._transform = options.transform;
+
+ if (typeof options.flush === 'function') this._flush = options.flush;
+ }
+
+ // When the writable side finishes, then flush out anything remaining.
+ this.on('prefinish', prefinish);
+}
+
+function prefinish() {
+ var _this = this;
+
+ if (typeof this._flush === 'function') {
+ this._flush(function (er, data) {
+ done(_this, er, data);
+ });
+ } else {
+ done(this, null, null);
+ }
+}
+
+Transform.prototype.push = function (chunk, encoding) {
+ this._transformState.needTransform = false;
+ return Duplex.prototype.push.call(this, chunk, encoding);
+};
+
+// This is the part where you do stuff!
+// override this function in implementation classes.
+// 'chunk' is an input chunk.
+//
+// Call `push(newChunk)` to pass along transformed output
+// to the readable side. You may call 'push' zero or more times.
+//
+// Call `cb(err)` when you are done with this chunk. If you pass
+// an error, then that'll put the hurt on the whole operation. If you
+// never call cb(), then you'll never get another chunk.
+Transform.prototype._transform = function (chunk, encoding, cb) {
+ throw new Error('_transform() is not implemented');
+};
+
+Transform.prototype._write = function (chunk, encoding, cb) {
+ var ts = this._transformState;
+ ts.writecb = cb;
+ ts.writechunk = chunk;
+ ts.writeencoding = encoding;
+ if (!ts.transforming) {
+ var rs = this._readableState;
+ if (ts.needTransform || rs.needReadable || rs.length < rs.highWaterMark) this._read(rs.highWaterMark);
+ }
+};
+
+// Doesn't matter what the args are here.
+// _transform does all the work.
+// That we got here means that the readable side wants more data.
+Transform.prototype._read = function (n) {
+ var ts = this._transformState;
+
+ if (ts.writechunk !== null && ts.writecb && !ts.transforming) {
+ ts.transforming = true;
+ this._transform(ts.writechunk, ts.writeencoding, ts.afterTransform);
+ } else {
+ // mark that we need a transform, so that any data that comes in
+ // will get processed, now that we've asked for it.
+ ts.needTransform = true;
+ }
+};
+
+Transform.prototype._destroy = function (err, cb) {
+ var _this2 = this;
+
+ Duplex.prototype._destroy.call(this, err, function (err2) {
+ cb(err2);
+ _this2.emit('close');
+ });
+};
+
+function done(stream, er, data) {
+ if (er) return stream.emit('error', er);
+
+ if (data != null) // single equals check for both `null` and `undefined`
+ stream.push(data);
+
+ // if there's nothing in the write buffer, then that means
+ // that nothing more will ever be provided
+ if (stream._writableState.length) throw new Error('Calling transform done when ws.length != 0');
+
+ if (stream._transformState.transforming) throw new Error('Calling transform done when still transforming');
+
+ return stream.push(null);
+}
+},{"./_stream_duplex":68,"core-util-is":22,"inherits":58}],72:[function(require,module,exports){
+(function (process,global){
+// Copyright Joyent, Inc. and other Node contributors.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to permit
+// persons to whom the Software is furnished to do so, subject to the
+// following conditions:
+//
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
+// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+// USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+// A bit simpler than readable streams.
+// Implement an async ._write(chunk, encoding, cb), and it'll handle all
+// the drain event emission and buffering.
+
+'use strict';
+
+/**/
+
+var pna = require('process-nextick-args');
+/**/
+
+module.exports = Writable;
+
+/* */
+function WriteReq(chunk, encoding, cb) {
+ this.chunk = chunk;
+ this.encoding = encoding;
+ this.callback = cb;
+ this.next = null;
+}
+
+// It seems a linked list but it is not
+// there will be only 2 of these for each stream
+function CorkedRequest(state) {
+ var _this = this;
+
+ this.next = null;
+ this.entry = null;
+ this.finish = function () {
+ onCorkedFinish(_this, state);
+ };
+}
+/* */
+
+/**/
+var asyncWrite = !process.browser && ['v0.10', 'v0.9.'].indexOf(process.version.slice(0, 5)) > -1 ? setImmediate : pna.nextTick;
+/**/
+
+/**/
+var Duplex;
+/**/
+
+Writable.WritableState = WritableState;
+
+/**/
+var util = require('core-util-is');
+util.inherits = require('inherits');
+/**/
+
+/**/
+var internalUtil = {
+ deprecate: require('util-deprecate')
+};
+/**/
+
+/**/
+var Stream = require('./internal/streams/stream');
+/**/
+
+/**/
+
+var Buffer = require('safe-buffer').Buffer;
+var OurUint8Array = global.Uint8Array || function () {};
+function _uint8ArrayToBuffer(chunk) {
+ return Buffer.from(chunk);
+}
+function _isUint8Array(obj) {
+ return Buffer.isBuffer(obj) || obj instanceof OurUint8Array;
+}
+
+/**/
+
+var destroyImpl = require('./internal/streams/destroy');
+
+util.inherits(Writable, Stream);
+
+function nop() {}
+
+function WritableState(options, stream) {
+ Duplex = Duplex || require('./_stream_duplex');
+
+ options = options || {};
+
+ // Duplex streams are both readable and writable, but share
+ // the same options object.
+ // However, some cases require setting options to different
+ // values for the readable and the writable sides of the duplex stream.
+ // These options can be provided separately as readableXXX and writableXXX.
+ var isDuplex = stream instanceof Duplex;
+
+ // object stream flag to indicate whether or not this stream
+ // contains buffers or objects.
+ this.objectMode = !!options.objectMode;
+
+ if (isDuplex) this.objectMode = this.objectMode || !!options.writableObjectMode;
+
+ // the point at which write() starts returning false
+ // Note: 0 is a valid value, means that we always return false if
+ // the entire buffer is not flushed immediately on write()
+ var hwm = options.highWaterMark;
+ var writableHwm = options.writableHighWaterMark;
+ var defaultHwm = this.objectMode ? 16 : 16 * 1024;
+
+ if (hwm || hwm === 0) this.highWaterMark = hwm;else if (isDuplex && (writableHwm || writableHwm === 0)) this.highWaterMark = writableHwm;else this.highWaterMark = defaultHwm;
+
+ // cast to ints.
+ this.highWaterMark = Math.floor(this.highWaterMark);
+
+ // if _final has been called
+ this.finalCalled = false;
+
+ // drain event flag.
+ this.needDrain = false;
+ // at the start of calling end()
+ this.ending = false;
+ // when end() has been called, and returned
+ this.ended = false;
+ // when 'finish' is emitted
+ this.finished = false;
+
+ // has it been destroyed
+ this.destroyed = false;
+
+ // should we decode strings into buffers before passing to _write?
+ // this is here so that some node-core streams can optimize string
+ // handling at a lower level.
+ var noDecode = options.decodeStrings === false;
+ this.decodeStrings = !noDecode;
+
+ // Crypto is kind of old and crusty. Historically, its default string
+ // encoding is 'binary' so we have to make this configurable.
+ // Everything else in the universe uses 'utf8', though.
+ this.defaultEncoding = options.defaultEncoding || 'utf8';
+
+ // not an actual buffer we keep track of, but a measurement
+ // of how much we're waiting to get pushed to some underlying
+ // socket or file.
+ this.length = 0;
+
+ // a flag to see when we're in the middle of a write.
+ this.writing = false;
+
+ // when true all writes will be buffered until .uncork() call
+ this.corked = 0;
+
+ // a flag to be able to tell if the onwrite cb is called immediately,
+ // or on a later tick. We set this to true at first, because any
+ // actions that shouldn't happen until "later" should generally also
+ // not happen before the first write call.
+ this.sync = true;
+
+ // a flag to know if we're processing previously buffered items, which
+ // may call the _write() callback in the same tick, so that we don't
+ // end up in an overlapped onwrite situation.
+ this.bufferProcessing = false;
+
+ // the callback that's passed to _write(chunk,cb)
+ this.onwrite = function (er) {
+ onwrite(stream, er);
+ };
+
+ // the callback that the user supplies to write(chunk,encoding,cb)
+ this.writecb = null;
+
+ // the amount that is being written when _write is called.
+ this.writelen = 0;
+
+ this.bufferedRequest = null;
+ this.lastBufferedRequest = null;
+
+ // number of pending user-supplied write callbacks
+ // this must be 0 before 'finish' can be emitted
+ this.pendingcb = 0;
+
+ // emit prefinish if the only thing we're waiting for is _write cbs
+ // This is relevant for synchronous Transform streams
+ this.prefinished = false;
+
+ // True if the error was already emitted and should not be thrown again
+ this.errorEmitted = false;
+
+ // count buffered requests
+ this.bufferedRequestCount = 0;
+
+ // allocate the first CorkedRequest, there is always
+ // one allocated and free to use, and we maintain at most two
+ this.corkedRequestsFree = new CorkedRequest(this);
+}
+
+WritableState.prototype.getBuffer = function getBuffer() {
+ var current = this.bufferedRequest;
+ var out = [];
+ while (current) {
+ out.push(current);
+ current = current.next;
+ }
+ return out;
+};
+
+(function () {
+ try {
+ Object.defineProperty(WritableState.prototype, 'buffer', {
+ get: internalUtil.deprecate(function () {
+ return this.getBuffer();
+ }, '_writableState.buffer is deprecated. Use _writableState.getBuffer ' + 'instead.', 'DEP0003')
+ });
+ } catch (_) {}
+})();
+
+// Test _writableState for inheritance to account for Duplex streams,
+// whose prototype chain only points to Readable.
+var realHasInstance;
+if (typeof Symbol === 'function' && Symbol.hasInstance && typeof Function.prototype[Symbol.hasInstance] === 'function') {
+ realHasInstance = Function.prototype[Symbol.hasInstance];
+ Object.defineProperty(Writable, Symbol.hasInstance, {
+ value: function (object) {
+ if (realHasInstance.call(this, object)) return true;
+ if (this !== Writable) return false;
+
+ return object && object._writableState instanceof WritableState;
+ }
+ });
+} else {
+ realHasInstance = function (object) {
+ return object instanceof this;
+ };
+}
+
+function Writable(options) {
+ Duplex = Duplex || require('./_stream_duplex');
+
+ // Writable ctor is applied to Duplexes, too.
+ // `realHasInstance` is necessary because using plain `instanceof`
+ // would return false, as no `_writableState` property is attached.
+
+ // Trying to use the custom `instanceof` for Writable here will also break the
+ // Node.js LazyTransform implementation, which has a non-trivial getter for
+ // `_writableState` that would lead to infinite recursion.
+ if (!realHasInstance.call(Writable, this) && !(this instanceof Duplex)) {
+ return new Writable(options);
+ }
+
+ this._writableState = new WritableState(options, this);
+
+ // legacy.
+ this.writable = true;
+
+ if (options) {
+ if (typeof options.write === 'function') this._write = options.write;
+
+ if (typeof options.writev === 'function') this._writev = options.writev;
+
+ if (typeof options.destroy === 'function') this._destroy = options.destroy;
+
+ if (typeof options.final === 'function') this._final = options.final;
+ }
+
+ Stream.call(this);
+}
+
+// Otherwise people can pipe Writable streams, which is just wrong.
+Writable.prototype.pipe = function () {
+ this.emit('error', new Error('Cannot pipe, not readable'));
+};
+
+function writeAfterEnd(stream, cb) {
+ var er = new Error('write after end');
+ // TODO: defer error events consistently everywhere, not just the cb
+ stream.emit('error', er);
+ pna.nextTick(cb, er);
+}
+
+// Checks that a user-supplied chunk is valid, especially for the particular
+// mode the stream is in. Currently this means that `null` is never accepted
+// and undefined/non-string values are only allowed in object mode.
+function validChunk(stream, state, chunk, cb) {
+ var valid = true;
+ var er = false;
+
+ if (chunk === null) {
+ er = new TypeError('May not write null values to stream');
+ } else if (typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) {
+ er = new TypeError('Invalid non-string/buffer chunk');
+ }
+ if (er) {
+ stream.emit('error', er);
+ pna.nextTick(cb, er);
+ valid = false;
+ }
+ return valid;
+}
+
+Writable.prototype.write = function (chunk, encoding, cb) {
+ var state = this._writableState;
+ var ret = false;
+ var isBuf = !state.objectMode && _isUint8Array(chunk);
+
+ if (isBuf && !Buffer.isBuffer(chunk)) {
+ chunk = _uint8ArrayToBuffer(chunk);
+ }
+
+ if (typeof encoding === 'function') {
+ cb = encoding;
+ encoding = null;
+ }
+
+ if (isBuf) encoding = 'buffer';else if (!encoding) encoding = state.defaultEncoding;
+
+ if (typeof cb !== 'function') cb = nop;
+
+ if (state.ended) writeAfterEnd(this, cb);else if (isBuf || validChunk(this, state, chunk, cb)) {
+ state.pendingcb++;
+ ret = writeOrBuffer(this, state, isBuf, chunk, encoding, cb);
+ }
+
+ return ret;
+};
+
+Writable.prototype.cork = function () {
+ var state = this._writableState;
+
+ state.corked++;
+};
+
+Writable.prototype.uncork = function () {
+ var state = this._writableState;
+
+ if (state.corked) {
+ state.corked--;
+
+ if (!state.writing && !state.corked && !state.finished && !state.bufferProcessing && state.bufferedRequest) clearBuffer(this, state);
+ }
+};
+
+Writable.prototype.setDefaultEncoding = function setDefaultEncoding(encoding) {
+ // node::ParseEncoding() requires lower case.
+ if (typeof encoding === 'string') encoding = encoding.toLowerCase();
+ if (!(['hex', 'utf8', 'utf-8', 'ascii', 'binary', 'base64', 'ucs2', 'ucs-2', 'utf16le', 'utf-16le', 'raw'].indexOf((encoding + '').toLowerCase()) > -1)) throw new TypeError('Unknown encoding: ' + encoding);
+ this._writableState.defaultEncoding = encoding;
+ return this;
+};
+
+function decodeChunk(state, chunk, encoding) {
+ if (!state.objectMode && state.decodeStrings !== false && typeof chunk === 'string') {
+ chunk = Buffer.from(chunk, encoding);
+ }
+ return chunk;
+}
+
+Object.defineProperty(Writable.prototype, 'writableHighWaterMark', {
+ // making it explicit this property is not enumerable
+ // because otherwise some prototype manipulation in
+ // userland will fail
+ enumerable: false,
+ get: function () {
+ return this._writableState.highWaterMark;
+ }
+});
+
+// if we're already writing something, then just put this
+// in the queue, and wait our turn. Otherwise, call _write
+// If we return false, then we need a drain event, so set that flag.
+function writeOrBuffer(stream, state, isBuf, chunk, encoding, cb) {
+ if (!isBuf) {
+ var newChunk = decodeChunk(state, chunk, encoding);
+ if (chunk !== newChunk) {
+ isBuf = true;
+ encoding = 'buffer';
+ chunk = newChunk;
+ }
+ }
+ var len = state.objectMode ? 1 : chunk.length;
+
+ state.length += len;
+
+ var ret = state.length < state.highWaterMark;
+ // we must ensure that previous needDrain will not be reset to false.
+ if (!ret) state.needDrain = true;
+
+ if (state.writing || state.corked) {
+ var last = state.lastBufferedRequest;
+ state.lastBufferedRequest = {
+ chunk: chunk,
+ encoding: encoding,
+ isBuf: isBuf,
+ callback: cb,
+ next: null
+ };
+ if (last) {
+ last.next = state.lastBufferedRequest;
+ } else {
+ state.bufferedRequest = state.lastBufferedRequest;
+ }
+ state.bufferedRequestCount += 1;
+ } else {
+ doWrite(stream, state, false, len, chunk, encoding, cb);
+ }
+
+ return ret;
+}
+
+function doWrite(stream, state, writev, len, chunk, encoding, cb) {
+ state.writelen = len;
+ state.writecb = cb;
+ state.writing = true;
+ state.sync = true;
+ if (writev) stream._writev(chunk, state.onwrite);else stream._write(chunk, encoding, state.onwrite);
+ state.sync = false;
+}
+
+function onwriteError(stream, state, sync, er, cb) {
+ --state.pendingcb;
+
+ if (sync) {
+ // defer the callback if we are being called synchronously
+ // to avoid piling up things on the stack
+ pna.nextTick(cb, er);
+ // this can emit finish, and it will always happen
+ // after error
+ pna.nextTick(finishMaybe, stream, state);
+ stream._writableState.errorEmitted = true;
+ stream.emit('error', er);
+ } else {
+ // the caller expect this to happen before if
+ // it is async
+ cb(er);
+ stream._writableState.errorEmitted = true;
+ stream.emit('error', er);
+ // this can emit finish, but finish must
+ // always follow error
+ finishMaybe(stream, state);
+ }
+}
+
+function onwriteStateUpdate(state) {
+ state.writing = false;
+ state.writecb = null;
+ state.length -= state.writelen;
+ state.writelen = 0;
+}
+
+function onwrite(stream, er) {
+ var state = stream._writableState;
+ var sync = state.sync;
+ var cb = state.writecb;
+
+ onwriteStateUpdate(state);
+
+ if (er) onwriteError(stream, state, sync, er, cb);else {
+ // Check if we're actually ready to finish, but don't emit yet
+ var finished = needFinish(state);
+
+ if (!finished && !state.corked && !state.bufferProcessing && state.bufferedRequest) {
+ clearBuffer(stream, state);
+ }
+
+ if (sync) {
+ /**/
+ asyncWrite(afterWrite, stream, state, finished, cb);
+ /**/
+ } else {
+ afterWrite(stream, state, finished, cb);
+ }
+ }
+}
+
+function afterWrite(stream, state, finished, cb) {
+ if (!finished) onwriteDrain(stream, state);
+ state.pendingcb--;
+ cb();
+ finishMaybe(stream, state);
+}
+
+// Must force callback to be called on nextTick, so that we don't
+// emit 'drain' before the write() consumer gets the 'false' return
+// value, and has a chance to attach a 'drain' listener.
+function onwriteDrain(stream, state) {
+ if (state.length === 0 && state.needDrain) {
+ state.needDrain = false;
+ stream.emit('drain');
+ }
+}
+
+// if there's something in the buffer waiting, then process it
+function clearBuffer(stream, state) {
+ state.bufferProcessing = true;
+ var entry = state.bufferedRequest;
+
+ if (stream._writev && entry && entry.next) {
+ // Fast case, write everything using _writev()
+ var l = state.bufferedRequestCount;
+ var buffer = new Array(l);
+ var holder = state.corkedRequestsFree;
+ holder.entry = entry;
+
+ var count = 0;
+ var allBuffers = true;
+ while (entry) {
+ buffer[count] = entry;
+ if (!entry.isBuf) allBuffers = false;
+ entry = entry.next;
+ count += 1;
+ }
+ buffer.allBuffers = allBuffers;
+
+ doWrite(stream, state, true, state.length, buffer, '', holder.finish);
+
+ // doWrite is almost always async, defer these to save a bit of time
+ // as the hot path ends with doWrite
+ state.pendingcb++;
+ state.lastBufferedRequest = null;
+ if (holder.next) {
+ state.corkedRequestsFree = holder.next;
+ holder.next = null;
+ } else {
+ state.corkedRequestsFree = new CorkedRequest(state);
+ }
+ state.bufferedRequestCount = 0;
+ } else {
+ // Slow case, write chunks one-by-one
+ while (entry) {
+ var chunk = entry.chunk;
+ var encoding = entry.encoding;
+ var cb = entry.callback;
+ var len = state.objectMode ? 1 : chunk.length;
+
+ doWrite(stream, state, false, len, chunk, encoding, cb);
+ entry = entry.next;
+ state.bufferedRequestCount--;
+ // if we didn't call the onwrite immediately, then
+ // it means that we need to wait until it does.
+ // also, that means that the chunk and cb are currently
+ // being processed, so move the buffer counter past them.
+ if (state.writing) {
+ break;
+ }
+ }
+
+ if (entry === null) state.lastBufferedRequest = null;
+ }
+
+ state.bufferedRequest = entry;
+ state.bufferProcessing = false;
+}
+
+Writable.prototype._write = function (chunk, encoding, cb) {
+ cb(new Error('_write() is not implemented'));
+};
+
+Writable.prototype._writev = null;
+
+Writable.prototype.end = function (chunk, encoding, cb) {
+ var state = this._writableState;
+
+ if (typeof chunk === 'function') {
+ cb = chunk;
+ chunk = null;
+ encoding = null;
+ } else if (typeof encoding === 'function') {
+ cb = encoding;
+ encoding = null;
+ }
+
+ if (chunk !== null && chunk !== undefined) this.write(chunk, encoding);
+
+ // .end() fully uncorks
+ if (state.corked) {
+ state.corked = 1;
+ this.uncork();
+ }
+
+ // ignore unnecessary end() calls.
+ if (!state.ending && !state.finished) endWritable(this, state, cb);
+};
+
+function needFinish(state) {
+ return state.ending && state.length === 0 && state.bufferedRequest === null && !state.finished && !state.writing;
+}
+function callFinal(stream, state) {
+ stream._final(function (err) {
+ state.pendingcb--;
+ if (err) {
+ stream.emit('error', err);
+ }
+ state.prefinished = true;
+ stream.emit('prefinish');
+ finishMaybe(stream, state);
+ });
+}
+function prefinish(stream, state) {
+ if (!state.prefinished && !state.finalCalled) {
+ if (typeof stream._final === 'function') {
+ state.pendingcb++;
+ state.finalCalled = true;
+ pna.nextTick(callFinal, stream, state);
+ } else {
+ state.prefinished = true;
+ stream.emit('prefinish');
+ }
+ }
+}
+
+function finishMaybe(stream, state) {
+ var need = needFinish(state);
+ if (need) {
+ prefinish(stream, state);
+ if (state.pendingcb === 0) {
+ state.finished = true;
+ stream.emit('finish');
+ }
+ }
+ return need;
+}
+
+function endWritable(stream, state, cb) {
+ state.ending = true;
+ finishMaybe(stream, state);
+ if (cb) {
+ if (state.finished) pna.nextTick(cb);else stream.once('finish', cb);
+ }
+ state.ended = true;
+ stream.writable = false;
+}
+
+function onCorkedFinish(corkReq, state, err) {
+ var entry = corkReq.entry;
+ corkReq.entry = null;
+ while (entry) {
+ var cb = entry.callback;
+ state.pendingcb--;
+ cb(err);
+ entry = entry.next;
+ }
+ if (state.corkedRequestsFree) {
+ state.corkedRequestsFree.next = corkReq;
+ } else {
+ state.corkedRequestsFree = corkReq;
+ }
+}
+
+Object.defineProperty(Writable.prototype, 'destroyed', {
+ get: function () {
+ if (this._writableState === undefined) {
+ return false;
+ }
+ return this._writableState.destroyed;
+ },
+ set: function (value) {
+ // we ignore the value if the stream
+ // has not been initialized yet
+ if (!this._writableState) {
+ return;
+ }
+
+ // backward compatibility, the user is explicitly
+ // managing destroyed
+ this._writableState.destroyed = value;
+ }
+});
+
+Writable.prototype.destroy = destroyImpl.destroy;
+Writable.prototype._undestroy = destroyImpl.undestroy;
+Writable.prototype._destroy = function (err, cb) {
+ this.end();
+ cb(err);
+};
+}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
+
+},{"./_stream_duplex":68,"./internal/streams/destroy":74,"./internal/streams/stream":75,"_process":63,"core-util-is":22,"inherits":58,"process-nextick-args":62,"safe-buffer":77,"util-deprecate":86}],73:[function(require,module,exports){
+'use strict';
+
+function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
+
+var Buffer = require('safe-buffer').Buffer;
+var util = require('util');
+
+function copyBuffer(src, target, offset) {
+ src.copy(target, offset);
+}
+
+module.exports = function () {
+ function BufferList() {
+ _classCallCheck(this, BufferList);
+
+ this.head = null;
+ this.tail = null;
+ this.length = 0;
+ }
+
+ BufferList.prototype.push = function push(v) {
+ var entry = { data: v, next: null };
+ if (this.length > 0) this.tail.next = entry;else this.head = entry;
+ this.tail = entry;
+ ++this.length;
+ };
+
+ BufferList.prototype.unshift = function unshift(v) {
+ var entry = { data: v, next: this.head };
+ if (this.length === 0) this.tail = entry;
+ this.head = entry;
+ ++this.length;
+ };
+
+ BufferList.prototype.shift = function shift() {
+ if (this.length === 0) return;
+ var ret = this.head.data;
+ if (this.length === 1) this.head = this.tail = null;else this.head = this.head.next;
+ --this.length;
+ return ret;
+ };
+
+ BufferList.prototype.clear = function clear() {
+ this.head = this.tail = null;
+ this.length = 0;
+ };
+
+ BufferList.prototype.join = function join(s) {
+ if (this.length === 0) return '';
+ var p = this.head;
+ var ret = '' + p.data;
+ while (p = p.next) {
+ ret += s + p.data;
+ }return ret;
+ };
+
+ BufferList.prototype.concat = function concat(n) {
+ if (this.length === 0) return Buffer.alloc(0);
+ if (this.length === 1) return this.head.data;
+ var ret = Buffer.allocUnsafe(n >>> 0);
+ var p = this.head;
+ var i = 0;
+ while (p) {
+ copyBuffer(p.data, ret, i);
+ i += p.data.length;
+ p = p.next;
+ }
+ return ret;
+ };
+
+ return BufferList;
+}();
+
+if (util && util.inspect && util.inspect.custom) {
+ module.exports.prototype[util.inspect.custom] = function () {
+ var obj = util.inspect({ length: this.length });
+ return this.constructor.name + ' ' + obj;
+ };
+}
+},{"safe-buffer":77,"util":18}],74:[function(require,module,exports){
+'use strict';
+
+/**/
+
+var pna = require('process-nextick-args');
+/**/
+
+// undocumented cb() API, needed for core, not for public API
+function destroy(err, cb) {
+ var _this = this;
+
+ var readableDestroyed = this._readableState && this._readableState.destroyed;
+ var writableDestroyed = this._writableState && this._writableState.destroyed;
+
+ if (readableDestroyed || writableDestroyed) {
+ if (cb) {
+ cb(err);
+ } else if (err && (!this._writableState || !this._writableState.errorEmitted)) {
+ pna.nextTick(emitErrorNT, this, err);
+ }
+ return this;
+ }
+
+ // we set destroyed to true before firing error callbacks in order
+ // to make it re-entrance safe in case destroy() is called within callbacks
+
+ if (this._readableState) {
+ this._readableState.destroyed = true;
+ }
+
+ // if this is a duplex stream mark the writable part as destroyed as well
+ if (this._writableState) {
+ this._writableState.destroyed = true;
+ }
+
+ this._destroy(err || null, function (err) {
+ if (!cb && err) {
+ pna.nextTick(emitErrorNT, _this, err);
+ if (_this._writableState) {
+ _this._writableState.errorEmitted = true;
+ }
+ } else if (cb) {
+ cb(err);
+ }
+ });
+
+ return this;
+}
+
+function undestroy() {
+ if (this._readableState) {
+ this._readableState.destroyed = false;
+ this._readableState.reading = false;
+ this._readableState.ended = false;
+ this._readableState.endEmitted = false;
+ }
+
+ if (this._writableState) {
+ this._writableState.destroyed = false;
+ this._writableState.ended = false;
+ this._writableState.ending = false;
+ this._writableState.finished = false;
+ this._writableState.errorEmitted = false;
+ }
+}
+
+function emitErrorNT(self, err) {
+ self.emit('error', err);
+}
+
+module.exports = {
+ destroy: destroy,
+ undestroy: undestroy
+};
+},{"process-nextick-args":62}],75:[function(require,module,exports){
+module.exports = require('events').EventEmitter;
+
+},{"events":55}],76:[function(require,module,exports){
+exports = module.exports = require('./lib/_stream_readable.js');
+exports.Stream = exports;
+exports.Readable = exports;
+exports.Writable = require('./lib/_stream_writable.js');
+exports.Duplex = require('./lib/_stream_duplex.js');
+exports.Transform = require('./lib/_stream_transform.js');
+exports.PassThrough = require('./lib/_stream_passthrough.js');
+
+},{"./lib/_stream_duplex.js":68,"./lib/_stream_passthrough.js":69,"./lib/_stream_readable.js":70,"./lib/_stream_transform.js":71,"./lib/_stream_writable.js":72}],77:[function(require,module,exports){
+/* eslint-disable node/no-deprecated-api */
+var buffer = require('buffer')
+var Buffer = buffer.Buffer
+
+// alternative to using Object.keys for old browsers
+function copyProps (src, dst) {
+ for (var key in src) {
+ dst[key] = src[key]
+ }
+}
+if (Buffer.from && Buffer.alloc && Buffer.allocUnsafe && Buffer.allocUnsafeSlow) {
+ module.exports = buffer
+} else {
+ // Copy properties from require('buffer')
+ copyProps(buffer, exports)
+ exports.Buffer = SafeBuffer
+}
+
+function SafeBuffer (arg, encodingOrOffset, length) {
+ return Buffer(arg, encodingOrOffset, length)
+}
+
+// Copy static methods from Buffer
+copyProps(Buffer, SafeBuffer)
+
+SafeBuffer.from = function (arg, encodingOrOffset, length) {
+ if (typeof arg === 'number') {
+ throw new TypeError('Argument must not be a number')
+ }
+ return Buffer(arg, encodingOrOffset, length)
+}
+
+SafeBuffer.alloc = function (size, fill, encoding) {
+ if (typeof size !== 'number') {
+ throw new TypeError('Argument must be a number')
+ }
+ var buf = Buffer(size)
+ if (fill !== undefined) {
+ if (typeof encoding === 'string') {
+ buf.fill(fill, encoding)
+ } else {
+ buf.fill(fill)
+ }
+ } else {
+ buf.fill(0)
+ }
+ return buf
+}
+
+SafeBuffer.allocUnsafe = function (size) {
+ if (typeof size !== 'number') {
+ throw new TypeError('Argument must be a number')
+ }
+ return Buffer(size)
+}
+
+SafeBuffer.allocUnsafeSlow = function (size) {
+ if (typeof size !== 'number') {
+ throw new TypeError('Argument must be a number')
+ }
+ return buffer.SlowBuffer(size)
+}
+
+},{"buffer":20}],78:[function(require,module,exports){
+(function (global){
+var ClientRequest = require('./lib/request')
+var response = require('./lib/response')
+var extend = require('xtend')
+var statusCodes = require('builtin-status-codes')
+var url = require('url')
+
+var http = exports
+
+http.request = function (opts, cb) {
+ if (typeof opts === 'string')
+ opts = url.parse(opts)
+ else
+ opts = extend(opts)
+
+ // Normally, the page is loaded from http or https, so not specifying a protocol
+ // will result in a (valid) protocol-relative url. However, this won't work if
+ // the protocol is something else, like 'file:'
+ var defaultProtocol = global.location.protocol.search(/^https?:$/) === -1 ? 'http:' : ''
+
+ var protocol = opts.protocol || defaultProtocol
+ var host = opts.hostname || opts.host
+ var port = opts.port
+ var path = opts.path || '/'
+
+ // Necessary for IPv6 addresses
+ if (host && host.indexOf(':') !== -1)
+ host = '[' + host + ']'
+
+ // This may be a relative url. The browser should always be able to interpret it correctly.
+ opts.url = (host ? (protocol + '//' + host) : '') + (port ? ':' + port : '') + path
+ opts.method = (opts.method || 'GET').toUpperCase()
+ opts.headers = opts.headers || {}
+
+ // Also valid opts.auth, opts.mode
+
+ var req = new ClientRequest(opts)
+ if (cb)
+ req.on('response', cb)
+ return req
+}
+
+http.get = function get (opts, cb) {
+ var req = http.request(opts, cb)
+ req.end()
+ return req
+}
+
+http.ClientRequest = ClientRequest
+http.IncomingMessage = response.IncomingMessage
+
+http.Agent = function () {}
+http.Agent.defaultMaxSockets = 4
+
+http.globalAgent = new http.Agent()
+
+http.STATUS_CODES = statusCodes
+
+http.METHODS = [
+ 'CHECKOUT',
+ 'CONNECT',
+ 'COPY',
+ 'DELETE',
+ 'GET',
+ 'HEAD',
+ 'LOCK',
+ 'M-SEARCH',
+ 'MERGE',
+ 'MKACTIVITY',
+ 'MKCOL',
+ 'MOVE',
+ 'NOTIFY',
+ 'OPTIONS',
+ 'PATCH',
+ 'POST',
+ 'PROPFIND',
+ 'PROPPATCH',
+ 'PURGE',
+ 'PUT',
+ 'REPORT',
+ 'SEARCH',
+ 'SUBSCRIBE',
+ 'TRACE',
+ 'UNLOCK',
+ 'UNSUBSCRIBE'
+]
+}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
+
+},{"./lib/request":80,"./lib/response":81,"builtin-status-codes":21,"url":84,"xtend":88}],79:[function(require,module,exports){
+(function (global){
+exports.fetch = isFunction(global.fetch) && isFunction(global.ReadableStream)
+
+exports.writableStream = isFunction(global.WritableStream)
+
+exports.abortController = isFunction(global.AbortController)
+
+exports.blobConstructor = false
+try {
+ new Blob([new ArrayBuffer(1)])
+ exports.blobConstructor = true
+} catch (e) {}
+
+// The xhr request to example.com may violate some restrictive CSP configurations,
+// so if we're running in a browser that supports `fetch`, avoid calling getXHR()
+// and assume support for certain features below.
+var xhr
+function getXHR () {
+ // Cache the xhr value
+ if (xhr !== undefined) return xhr
+
+ if (global.XMLHttpRequest) {
+ xhr = new global.XMLHttpRequest()
+ // If XDomainRequest is available (ie only, where xhr might not work
+ // cross domain), use the page location. Otherwise use example.com
+ // Note: this doesn't actually make an http request.
+ try {
+ xhr.open('GET', global.XDomainRequest ? '/' : 'https://example.com')
+ } catch(e) {
+ xhr = null
+ }
+ } else {
+ // Service workers don't have XHR
+ xhr = null
+ }
+ return xhr
+}
+
+function checkTypeSupport (type) {
+ var xhr = getXHR()
+ if (!xhr) return false
+ try {
+ xhr.responseType = type
+ return xhr.responseType === type
+ } catch (e) {}
+ return false
+}
+
+// For some strange reason, Safari 7.0 reports typeof global.ArrayBuffer === 'object'.
+// Safari 7.1 appears to have fixed this bug.
+var haveArrayBuffer = typeof global.ArrayBuffer !== 'undefined'
+var haveSlice = haveArrayBuffer && isFunction(global.ArrayBuffer.prototype.slice)
+
+// If fetch is supported, then arraybuffer will be supported too. Skip calling
+// checkTypeSupport(), since that calls getXHR().
+exports.arraybuffer = exports.fetch || (haveArrayBuffer && checkTypeSupport('arraybuffer'))
+
+// These next two tests unavoidably show warnings in Chrome. Since fetch will always
+// be used if it's available, just return false for these to avoid the warnings.
+exports.msstream = !exports.fetch && haveSlice && checkTypeSupport('ms-stream')
+exports.mozchunkedarraybuffer = !exports.fetch && haveArrayBuffer &&
+ checkTypeSupport('moz-chunked-arraybuffer')
+
+// If fetch is supported, then overrideMimeType will be supported too. Skip calling
+// getXHR().
+exports.overrideMimeType = exports.fetch || (getXHR() ? isFunction(getXHR().overrideMimeType) : false)
+
+exports.vbArray = isFunction(global.VBArray)
+
+function isFunction (value) {
+ return typeof value === 'function'
+}
+
+xhr = null // Help gc
+
+}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
+
+},{}],80:[function(require,module,exports){
+(function (process,global,Buffer){
+var capability = require('./capability')
+var inherits = require('inherits')
+var response = require('./response')
+var stream = require('readable-stream')
+var toArrayBuffer = require('to-arraybuffer')
+
+var IncomingMessage = response.IncomingMessage
+var rStates = response.readyStates
+
+function decideMode (preferBinary, useFetch) {
+ if (capability.fetch && useFetch) {
+ return 'fetch'
+ } else if (capability.mozchunkedarraybuffer) {
+ return 'moz-chunked-arraybuffer'
+ } else if (capability.msstream) {
+ return 'ms-stream'
+ } else if (capability.arraybuffer && preferBinary) {
+ return 'arraybuffer'
+ } else if (capability.vbArray && preferBinary) {
+ return 'text:vbarray'
+ } else {
+ return 'text'
+ }
+}
+
+var ClientRequest = module.exports = function (opts) {
+ var self = this
+ stream.Writable.call(self)
+
+ self._opts = opts
+ self._body = []
+ self._headers = {}
+ if (opts.auth)
+ self.setHeader('Authorization', 'Basic ' + new Buffer(opts.auth).toString('base64'))
+ Object.keys(opts.headers).forEach(function (name) {
+ self.setHeader(name, opts.headers[name])
+ })
+
+ var preferBinary
+ var useFetch = true
+ if (opts.mode === 'disable-fetch' || ('requestTimeout' in opts && !capability.abortController)) {
+ // If the use of XHR should be preferred. Not typically needed.
+ useFetch = false
+ preferBinary = true
+ } else if (opts.mode === 'prefer-streaming') {
+ // If streaming is a high priority but binary compatibility and
+ // the accuracy of the 'content-type' header aren't
+ preferBinary = false
+ } else if (opts.mode === 'allow-wrong-content-type') {
+ // If streaming is more important than preserving the 'content-type' header
+ preferBinary = !capability.overrideMimeType
+ } else if (!opts.mode || opts.mode === 'default' || opts.mode === 'prefer-fast') {
+ // Use binary if text streaming may corrupt data or the content-type header, or for speed
+ preferBinary = true
+ } else {
+ throw new Error('Invalid value for opts.mode')
+ }
+ self._mode = decideMode(preferBinary, useFetch)
+
+ self.on('finish', function () {
+ self._onFinish()
+ })
+}
+
+inherits(ClientRequest, stream.Writable)
+
+ClientRequest.prototype.setHeader = function (name, value) {
+ var self = this
+ var lowerName = name.toLowerCase()
+ // This check is not necessary, but it prevents warnings from browsers about setting unsafe
+ // headers. To be honest I'm not entirely sure hiding these warnings is a good thing, but
+ // http-browserify did it, so I will too.
+ if (unsafeHeaders.indexOf(lowerName) !== -1)
+ return
+
+ self._headers[lowerName] = {
+ name: name,
+ value: value
+ }
+}
+
+ClientRequest.prototype.getHeader = function (name) {
+ var header = this._headers[name.toLowerCase()]
+ if (header)
+ return header.value
+ return null
+}
+
+ClientRequest.prototype.removeHeader = function (name) {
+ var self = this
+ delete self._headers[name.toLowerCase()]
+}
+
+ClientRequest.prototype._onFinish = function () {
+ var self = this
+
+ if (self._destroyed)
+ return
+ var opts = self._opts
+
+ var headersObj = self._headers
+ var body = null
+ if (opts.method !== 'GET' && opts.method !== 'HEAD') {
+ if (capability.arraybuffer) {
+ body = toArrayBuffer(Buffer.concat(self._body))
+ } else if (capability.blobConstructor) {
+ body = new global.Blob(self._body.map(function (buffer) {
+ return toArrayBuffer(buffer)
+ }), {
+ type: (headersObj['content-type'] || {}).value || ''
+ })
+ } else {
+ // get utf8 string
+ body = Buffer.concat(self._body).toString()
+ }
+ }
+
+ // create flattened list of headers
+ var headersList = []
+ Object.keys(headersObj).forEach(function (keyName) {
+ var name = headersObj[keyName].name
+ var value = headersObj[keyName].value
+ if (Array.isArray(value)) {
+ value.forEach(function (v) {
+ headersList.push([name, v])
+ })
+ } else {
+ headersList.push([name, value])
+ }
+ })
+
+ if (self._mode === 'fetch') {
+ var signal = null
+ if (capability.abortController) {
+ var controller = new AbortController()
+ signal = controller.signal
+ self._fetchAbortController = controller
+
+ if ('requestTimeout' in opts && opts.requestTimeout !== 0) {
+ global.setTimeout(function () {
+ self.emit('requestTimeout')
+ if (self._fetchAbortController)
+ self._fetchAbortController.abort()
+ }, opts.requestTimeout)
+ }
+ }
+
+ global.fetch(self._opts.url, {
+ method: self._opts.method,
+ headers: headersList,
+ body: body || undefined,
+ mode: 'cors',
+ credentials: opts.withCredentials ? 'include' : 'same-origin',
+ signal: signal
+ }).then(function (response) {
+ self._fetchResponse = response
+ self._connect()
+ }, function (reason) {
+ self.emit('error', reason)
+ })
+ } else {
+ var xhr = self._xhr = new global.XMLHttpRequest()
+ try {
+ xhr.open(self._opts.method, self._opts.url, true)
+ } catch (err) {
+ process.nextTick(function () {
+ self.emit('error', err)
+ })
+ return
+ }
+
+ // Can't set responseType on really old browsers
+ if ('responseType' in xhr)
+ xhr.responseType = self._mode.split(':')[0]
+
+ if ('withCredentials' in xhr)
+ xhr.withCredentials = !!opts.withCredentials
+
+ if (self._mode === 'text' && 'overrideMimeType' in xhr)
+ xhr.overrideMimeType('text/plain; charset=x-user-defined')
+
+ if ('requestTimeout' in opts) {
+ xhr.timeout = opts.requestTimeout
+ xhr.ontimeout = function () {
+ self.emit('requestTimeout')
+ }
+ }
+
+ headersList.forEach(function (header) {
+ xhr.setRequestHeader(header[0], header[1])
+ })
+
+ self._response = null
+ xhr.onreadystatechange = function () {
+ switch (xhr.readyState) {
+ case rStates.LOADING:
+ case rStates.DONE:
+ self._onXHRProgress()
+ break
+ }
+ }
+ // Necessary for streaming in Firefox, since xhr.response is ONLY defined
+ // in onprogress, not in onreadystatechange with xhr.readyState = 3
+ if (self._mode === 'moz-chunked-arraybuffer') {
+ xhr.onprogress = function () {
+ self._onXHRProgress()
+ }
+ }
+
+ xhr.onerror = function () {
+ if (self._destroyed)
+ return
+ self.emit('error', new Error('XHR error'))
+ }
+
+ try {
+ xhr.send(body)
+ } catch (err) {
+ process.nextTick(function () {
+ self.emit('error', err)
+ })
+ return
+ }
+ }
+}
+
+/**
+ * Checks if xhr.status is readable and non-zero, indicating no error.
+ * Even though the spec says it should be available in readyState 3,
+ * accessing it throws an exception in IE8
+ */
+function statusValid (xhr) {
+ try {
+ var status = xhr.status
+ return (status !== null && status !== 0)
+ } catch (e) {
+ return false
+ }
+}
+
+ClientRequest.prototype._onXHRProgress = function () {
+ var self = this
+
+ if (!statusValid(self._xhr) || self._destroyed)
+ return
+
+ if (!self._response)
+ self._connect()
+
+ self._response._onXHRProgress()
+}
+
+ClientRequest.prototype._connect = function () {
+ var self = this
+
+ if (self._destroyed)
+ return
+
+ self._response = new IncomingMessage(self._xhr, self._fetchResponse, self._mode)
+ self._response.on('error', function(err) {
+ self.emit('error', err)
+ })
+
+ self.emit('response', self._response)
+}
+
+ClientRequest.prototype._write = function (chunk, encoding, cb) {
+ var self = this
+
+ self._body.push(chunk)
+ cb()
+}
+
+ClientRequest.prototype.abort = ClientRequest.prototype.destroy = function () {
+ var self = this
+ self._destroyed = true
+ if (self._response)
+ self._response._destroyed = true
+ if (self._xhr)
+ self._xhr.abort()
+ else if (self._fetchAbortController)
+ self._fetchAbortController.abort()
+}
+
+ClientRequest.prototype.end = function (data, encoding, cb) {
+ var self = this
+ if (typeof data === 'function') {
+ cb = data
+ data = undefined
+ }
+
+ stream.Writable.prototype.end.call(self, data, encoding, cb)
+}
+
+ClientRequest.prototype.flushHeaders = function () {}
+ClientRequest.prototype.setTimeout = function () {}
+ClientRequest.prototype.setNoDelay = function () {}
+ClientRequest.prototype.setSocketKeepAlive = function () {}
+
+// Taken from http://www.w3.org/TR/XMLHttpRequest/#the-setrequestheader%28%29-method
+var unsafeHeaders = [
+ 'accept-charset',
+ 'accept-encoding',
+ 'access-control-request-headers',
+ 'access-control-request-method',
+ 'connection',
+ 'content-length',
+ 'cookie',
+ 'cookie2',
+ 'date',
+ 'dnt',
+ 'expect',
+ 'host',
+ 'keep-alive',
+ 'origin',
+ 'referer',
+ 'te',
+ 'trailer',
+ 'transfer-encoding',
+ 'upgrade',
+ 'user-agent',
+ 'via'
+]
+
+}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},require("buffer").Buffer)
+
+},{"./capability":79,"./response":81,"_process":63,"buffer":20,"inherits":58,"readable-stream":76,"to-arraybuffer":83}],81:[function(require,module,exports){
+(function (process,global,Buffer){
+var capability = require('./capability')
+var inherits = require('inherits')
+var stream = require('readable-stream')
+
+var rStates = exports.readyStates = {
+ UNSENT: 0,
+ OPENED: 1,
+ HEADERS_RECEIVED: 2,
+ LOADING: 3,
+ DONE: 4
+}
+
+var IncomingMessage = exports.IncomingMessage = function (xhr, response, mode) {
+ var self = this
+ stream.Readable.call(self)
+
+ self._mode = mode
+ self.headers = {}
+ self.rawHeaders = []
+ self.trailers = {}
+ self.rawTrailers = []
+
+ // Fake the 'close' event, but only once 'end' fires
+ self.on('end', function () {
+ // The nextTick is necessary to prevent the 'request' module from causing an infinite loop
+ process.nextTick(function () {
+ self.emit('close')
+ })
+ })
+
+ if (mode === 'fetch') {
+ self._fetchResponse = response
+
+ self.url = response.url
+ self.statusCode = response.status
+ self.statusMessage = response.statusText
+
+ response.headers.forEach(function (header, key){
+ self.headers[key.toLowerCase()] = header
+ self.rawHeaders.push(key, header)
+ })
+
+ if (capability.writableStream) {
+ var writable = new WritableStream({
+ write: function (chunk) {
+ return new Promise(function (resolve, reject) {
+ if (self._destroyed) {
+ return
+ } else if(self.push(new Buffer(chunk))) {
+ resolve()
+ } else {
+ self._resumeFetch = resolve
+ }
+ })
+ },
+ close: function () {
+ if (!self._destroyed)
+ self.push(null)
+ },
+ abort: function (err) {
+ if (!self._destroyed)
+ self.emit('error', err)
+ }
+ })
+
+ try {
+ response.body.pipeTo(writable)
+ return
+ } catch (e) {} // pipeTo method isn't defined. Can't find a better way to feature test this
+ }
+ // fallback for when writableStream or pipeTo aren't available
+ var reader = response.body.getReader()
+ function read () {
+ reader.read().then(function (result) {
+ if (self._destroyed)
+ return
+ if (result.done) {
+ self.push(null)
+ return
+ }
+ self.push(new Buffer(result.value))
+ read()
+ }).catch(function(err) {
+ if (!self._destroyed)
+ self.emit('error', err)
+ })
+ }
+ read()
+ } else {
+ self._xhr = xhr
+ self._pos = 0
+
+ self.url = xhr.responseURL
+ self.statusCode = xhr.status
+ self.statusMessage = xhr.statusText
+ var headers = xhr.getAllResponseHeaders().split(/\r?\n/)
+ headers.forEach(function (header) {
+ var matches = header.match(/^([^:]+):\s*(.*)/)
+ if (matches) {
+ var key = matches[1].toLowerCase()
+ if (key === 'set-cookie') {
+ if (self.headers[key] === undefined) {
+ self.headers[key] = []
+ }
+ self.headers[key].push(matches[2])
+ } else if (self.headers[key] !== undefined) {
+ self.headers[key] += ', ' + matches[2]
+ } else {
+ self.headers[key] = matches[2]
+ }
+ self.rawHeaders.push(matches[1], matches[2])
+ }
+ })
+
+ self._charset = 'x-user-defined'
+ if (!capability.overrideMimeType) {
+ var mimeType = self.rawHeaders['mime-type']
+ if (mimeType) {
+ var charsetMatch = mimeType.match(/;\s*charset=([^;])(;|$)/)
+ if (charsetMatch) {
+ self._charset = charsetMatch[1].toLowerCase()
+ }
+ }
+ if (!self._charset)
+ self._charset = 'utf-8' // best guess
+ }
+ }
+}
+
+inherits(IncomingMessage, stream.Readable)
+
+IncomingMessage.prototype._read = function () {
+ var self = this
+
+ var resolve = self._resumeFetch
+ if (resolve) {
+ self._resumeFetch = null
+ resolve()
+ }
+}
+
+IncomingMessage.prototype._onXHRProgress = function () {
+ var self = this
+
+ var xhr = self._xhr
+
+ var response = null
+ switch (self._mode) {
+ case 'text:vbarray': // For IE9
+ if (xhr.readyState !== rStates.DONE)
+ break
+ try {
+ // This fails in IE8
+ response = new global.VBArray(xhr.responseBody).toArray()
+ } catch (e) {}
+ if (response !== null) {
+ self.push(new Buffer(response))
+ break
+ }
+ // Falls through in IE8
+ case 'text':
+ try { // This will fail when readyState = 3 in IE9. Switch mode and wait for readyState = 4
+ response = xhr.responseText
+ } catch (e) {
+ self._mode = 'text:vbarray'
+ break
+ }
+ if (response.length > self._pos) {
+ var newData = response.substr(self._pos)
+ if (self._charset === 'x-user-defined') {
+ var buffer = new Buffer(newData.length)
+ for (var i = 0; i < newData.length; i++)
+ buffer[i] = newData.charCodeAt(i) & 0xff
+
+ self.push(buffer)
+ } else {
+ self.push(newData, self._charset)
+ }
+ self._pos = response.length
+ }
+ break
+ case 'arraybuffer':
+ if (xhr.readyState !== rStates.DONE || !xhr.response)
+ break
+ response = xhr.response
+ self.push(new Buffer(new Uint8Array(response)))
+ break
+ case 'moz-chunked-arraybuffer': // take whole
+ response = xhr.response
+ if (xhr.readyState !== rStates.LOADING || !response)
+ break
+ self.push(new Buffer(new Uint8Array(response)))
+ break
+ case 'ms-stream':
+ response = xhr.response
+ if (xhr.readyState !== rStates.LOADING)
+ break
+ var reader = new global.MSStreamReader()
+ reader.onprogress = function () {
+ if (reader.result.byteLength > self._pos) {
+ self.push(new Buffer(new Uint8Array(reader.result.slice(self._pos))))
+ self._pos = reader.result.byteLength
+ }
+ }
+ reader.onload = function () {
+ self.push(null)
+ }
+ // reader.onerror = ??? // TODO: this
+ reader.readAsArrayBuffer(response)
+ break
+ }
+
+ // The ms-stream case handles end separately in reader.onload()
+ if (self._xhr.readyState === rStates.DONE && self._mode !== 'ms-stream') {
+ self.push(null)
+ }
+}
+
+}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},require("buffer").Buffer)
+
+},{"./capability":79,"_process":63,"buffer":20,"inherits":58,"readable-stream":76}],82:[function(require,module,exports){
+// Copyright Joyent, Inc. and other Node contributors.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to permit
+// persons to whom the Software is furnished to do so, subject to the
+// following conditions:
+//
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
+// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+// USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+'use strict';
+
+/**/
+
+var Buffer = require('safe-buffer').Buffer;
+/**/
+
+var isEncoding = Buffer.isEncoding || function (encoding) {
+ encoding = '' + encoding;
+ switch (encoding && encoding.toLowerCase()) {
+ case 'hex':case 'utf8':case 'utf-8':case 'ascii':case 'binary':case 'base64':case 'ucs2':case 'ucs-2':case 'utf16le':case 'utf-16le':case 'raw':
+ return true;
+ default:
+ return false;
+ }
+};
+
+function _normalizeEncoding(enc) {
+ if (!enc) return 'utf8';
+ var retried;
+ while (true) {
+ switch (enc) {
+ case 'utf8':
+ case 'utf-8':
+ return 'utf8';
+ case 'ucs2':
+ case 'ucs-2':
+ case 'utf16le':
+ case 'utf-16le':
+ return 'utf16le';
+ case 'latin1':
+ case 'binary':
+ return 'latin1';
+ case 'base64':
+ case 'ascii':
+ case 'hex':
+ return enc;
+ default:
+ if (retried) return; // undefined
+ enc = ('' + enc).toLowerCase();
+ retried = true;
+ }
+ }
+};
+
+// Do not cache `Buffer.isEncoding` when checking encoding names as some
+// modules monkey-patch it to support additional encodings
+function normalizeEncoding(enc) {
+ var nenc = _normalizeEncoding(enc);
+ if (typeof nenc !== 'string' && (Buffer.isEncoding === isEncoding || !isEncoding(enc))) throw new Error('Unknown encoding: ' + enc);
+ return nenc || enc;
+}
+
+// StringDecoder provides an interface for efficiently splitting a series of
+// buffers into a series of JS strings without breaking apart multi-byte
+// characters.
+exports.StringDecoder = StringDecoder;
+function StringDecoder(encoding) {
+ this.encoding = normalizeEncoding(encoding);
+ var nb;
+ switch (this.encoding) {
+ case 'utf16le':
+ this.text = utf16Text;
+ this.end = utf16End;
+ nb = 4;
+ break;
+ case 'utf8':
+ this.fillLast = utf8FillLast;
+ nb = 4;
+ break;
+ case 'base64':
+ this.text = base64Text;
+ this.end = base64End;
+ nb = 3;
+ break;
+ default:
+ this.write = simpleWrite;
+ this.end = simpleEnd;
+ return;
+ }
+ this.lastNeed = 0;
+ this.lastTotal = 0;
+ this.lastChar = Buffer.allocUnsafe(nb);
+}
+
+StringDecoder.prototype.write = function (buf) {
+ if (buf.length === 0) return '';
+ var r;
+ var i;
+ if (this.lastNeed) {
+ r = this.fillLast(buf);
+ if (r === undefined) return '';
+ i = this.lastNeed;
+ this.lastNeed = 0;
+ } else {
+ i = 0;
+ }
+ if (i < buf.length) return r ? r + this.text(buf, i) : this.text(buf, i);
+ return r || '';
+};
+
+StringDecoder.prototype.end = utf8End;
+
+// Returns only complete characters in a Buffer
+StringDecoder.prototype.text = utf8Text;
+
+// Attempts to complete a partial non-UTF-8 character using bytes from a Buffer
+StringDecoder.prototype.fillLast = function (buf) {
+ if (this.lastNeed <= buf.length) {
+ buf.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, this.lastNeed);
+ return this.lastChar.toString(this.encoding, 0, this.lastTotal);
+ }
+ buf.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, buf.length);
+ this.lastNeed -= buf.length;
+};
+
+// Checks the type of a UTF-8 byte, whether it's ASCII, a leading byte, or a
+// continuation byte. If an invalid byte is detected, -2 is returned.
+function utf8CheckByte(byte) {
+ if (byte <= 0x7F) return 0;else if (byte >> 5 === 0x06) return 2;else if (byte >> 4 === 0x0E) return 3;else if (byte >> 3 === 0x1E) return 4;
+ return byte >> 6 === 0x02 ? -1 : -2;
+}
+
+// Checks at most 3 bytes at the end of a Buffer in order to detect an
+// incomplete multi-byte UTF-8 character. The total number of bytes (2, 3, or 4)
+// needed to complete the UTF-8 character (if applicable) are returned.
+function utf8CheckIncomplete(self, buf, i) {
+ var j = buf.length - 1;
+ if (j < i) return 0;
+ var nb = utf8CheckByte(buf[j]);
+ if (nb >= 0) {
+ if (nb > 0) self.lastNeed = nb - 1;
+ return nb;
+ }
+ if (--j < i || nb === -2) return 0;
+ nb = utf8CheckByte(buf[j]);
+ if (nb >= 0) {
+ if (nb > 0) self.lastNeed = nb - 2;
+ return nb;
+ }
+ if (--j < i || nb === -2) return 0;
+ nb = utf8CheckByte(buf[j]);
+ if (nb >= 0) {
+ if (nb > 0) {
+ if (nb === 2) nb = 0;else self.lastNeed = nb - 3;
+ }
+ return nb;
+ }
+ return 0;
+}
+
+// Validates as many continuation bytes for a multi-byte UTF-8 character as
+// needed or are available. If we see a non-continuation byte where we expect
+// one, we "replace" the validated continuation bytes we've seen so far with
+// a single UTF-8 replacement character ('\ufffd'), to match v8's UTF-8 decoding
+// behavior. The continuation byte check is included three times in the case
+// where all of the continuation bytes for a character exist in the same buffer.
+// It is also done this way as a slight performance increase instead of using a
+// loop.
+function utf8CheckExtraBytes(self, buf, p) {
+ if ((buf[0] & 0xC0) !== 0x80) {
+ self.lastNeed = 0;
+ return '\ufffd';
+ }
+ if (self.lastNeed > 1 && buf.length > 1) {
+ if ((buf[1] & 0xC0) !== 0x80) {
+ self.lastNeed = 1;
+ return '\ufffd';
+ }
+ if (self.lastNeed > 2 && buf.length > 2) {
+ if ((buf[2] & 0xC0) !== 0x80) {
+ self.lastNeed = 2;
+ return '\ufffd';
+ }
+ }
+ }
+}
+
+// Attempts to complete a multi-byte UTF-8 character using bytes from a Buffer.
+function utf8FillLast(buf) {
+ var p = this.lastTotal - this.lastNeed;
+ var r = utf8CheckExtraBytes(this, buf, p);
+ if (r !== undefined) return r;
+ if (this.lastNeed <= buf.length) {
+ buf.copy(this.lastChar, p, 0, this.lastNeed);
+ return this.lastChar.toString(this.encoding, 0, this.lastTotal);
+ }
+ buf.copy(this.lastChar, p, 0, buf.length);
+ this.lastNeed -= buf.length;
+}
+
+// Returns all complete UTF-8 characters in a Buffer. If the Buffer ended on a
+// partial character, the character's bytes are buffered until the required
+// number of bytes are available.
+function utf8Text(buf, i) {
+ var total = utf8CheckIncomplete(this, buf, i);
+ if (!this.lastNeed) return buf.toString('utf8', i);
+ this.lastTotal = total;
+ var end = buf.length - (total - this.lastNeed);
+ buf.copy(this.lastChar, 0, end);
+ return buf.toString('utf8', i, end);
+}
+
+// For UTF-8, a replacement character is added when ending on a partial
+// character.
+function utf8End(buf) {
+ var r = buf && buf.length ? this.write(buf) : '';
+ if (this.lastNeed) return r + '\ufffd';
+ return r;
+}
+
+// UTF-16LE typically needs two bytes per character, but even if we have an even
+// number of bytes available, we need to check if we end on a leading/high
+// surrogate. In that case, we need to wait for the next two bytes in order to
+// decode the last character properly.
+function utf16Text(buf, i) {
+ if ((buf.length - i) % 2 === 0) {
+ var r = buf.toString('utf16le', i);
+ if (r) {
+ var c = r.charCodeAt(r.length - 1);
+ if (c >= 0xD800 && c <= 0xDBFF) {
+ this.lastNeed = 2;
+ this.lastTotal = 4;
+ this.lastChar[0] = buf[buf.length - 2];
+ this.lastChar[1] = buf[buf.length - 1];
+ return r.slice(0, -1);
+ }
+ }
+ return r;
+ }
+ this.lastNeed = 1;
+ this.lastTotal = 2;
+ this.lastChar[0] = buf[buf.length - 1];
+ return buf.toString('utf16le', i, buf.length - 1);
+}
+
+// For UTF-16LE we do not explicitly append special replacement characters if we
+// end on a partial character, we simply let v8 handle that.
+function utf16End(buf) {
+ var r = buf && buf.length ? this.write(buf) : '';
+ if (this.lastNeed) {
+ var end = this.lastTotal - this.lastNeed;
+ return r + this.lastChar.toString('utf16le', 0, end);
+ }
+ return r;
+}
+
+function base64Text(buf, i) {
+ var n = (buf.length - i) % 3;
+ if (n === 0) return buf.toString('base64', i);
+ this.lastNeed = 3 - n;
+ this.lastTotal = 3;
+ if (n === 1) {
+ this.lastChar[0] = buf[buf.length - 1];
+ } else {
+ this.lastChar[0] = buf[buf.length - 2];
+ this.lastChar[1] = buf[buf.length - 1];
+ }
+ return buf.toString('base64', i, buf.length - n);
+}
+
+function base64End(buf) {
+ var r = buf && buf.length ? this.write(buf) : '';
+ if (this.lastNeed) return r + this.lastChar.toString('base64', 0, 3 - this.lastNeed);
+ return r;
+}
+
+// Pass bytes on through for single-byte encodings (e.g. ascii, latin1, hex)
+function simpleWrite(buf) {
+ return buf.toString(this.encoding);
+}
+
+function simpleEnd(buf) {
+ return buf && buf.length ? this.write(buf) : '';
+}
+},{"safe-buffer":77}],83:[function(require,module,exports){
+var Buffer = require('buffer').Buffer
+
+module.exports = function (buf) {
+ // If the buffer is backed by a Uint8Array, a faster version will work
+ if (buf instanceof Uint8Array) {
+ // If the buffer isn't a subarray, return the underlying ArrayBuffer
+ if (buf.byteOffset === 0 && buf.byteLength === buf.buffer.byteLength) {
+ return buf.buffer
+ } else if (typeof buf.buffer.slice === 'function') {
+ // Otherwise we need to get a proper copy
+ return buf.buffer.slice(buf.byteOffset, buf.byteOffset + buf.byteLength)
+ }
+ }
+
+ if (Buffer.isBuffer(buf)) {
+ // This is the slow version that will work with any Buffer
+ // implementation (even in old browsers)
+ var arrayCopy = new Uint8Array(buf.length)
+ var len = buf.length
+ for (var i = 0; i < len; i++) {
+ arrayCopy[i] = buf[i]
+ }
+ return arrayCopy.buffer
+ } else {
+ throw new Error('Argument must be a Buffer')
+ }
+}
+
+},{"buffer":20}],84:[function(require,module,exports){
+// Copyright Joyent, Inc. and other Node contributors.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to permit
+// persons to whom the Software is furnished to do so, subject to the
+// following conditions:
+//
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
+// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+// USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+'use strict';
+
+var punycode = require('punycode');
+var util = require('./util');
+
+exports.parse = urlParse;
+exports.resolve = urlResolve;
+exports.resolveObject = urlResolveObject;
+exports.format = urlFormat;
+
+exports.Url = Url;
+
+function Url() {
+ this.protocol = null;
+ this.slashes = null;
+ this.auth = null;
+ this.host = null;
+ this.port = null;
+ this.hostname = null;
+ this.hash = null;
+ this.search = null;
+ this.query = null;
+ this.pathname = null;
+ this.path = null;
+ this.href = null;
+}
+
+// Reference: RFC 3986, RFC 1808, RFC 2396
+
+// define these here so at least they only have to be
+// compiled once on the first module load.
+var protocolPattern = /^([a-z0-9.+-]+:)/i,
+ portPattern = /:[0-9]*$/,
+
+ // Special case for a simple path URL
+ simplePathPattern = /^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/,
+
+ // RFC 2396: characters reserved for delimiting URLs.
+ // We actually just auto-escape these.
+ delims = ['<', '>', '"', '`', ' ', '\r', '\n', '\t'],
+
+ // RFC 2396: characters not allowed for various reasons.
+ unwise = ['{', '}', '|', '\\', '^', '`'].concat(delims),
+
+ // Allowed by RFCs, but cause of XSS attacks. Always escape these.
+ autoEscape = ['\''].concat(unwise),
+ // Characters that are never ever allowed in a hostname.
+ // Note that any invalid chars are also handled, but these
+ // are the ones that are *expected* to be seen, so we fast-path
+ // them.
+ nonHostChars = ['%', '/', '?', ';', '#'].concat(autoEscape),
+ hostEndingChars = ['/', '?', '#'],
+ hostnameMaxLen = 255,
+ hostnamePartPattern = /^[+a-z0-9A-Z_-]{0,63}$/,
+ hostnamePartStart = /^([+a-z0-9A-Z_-]{0,63})(.*)$/,
+ // protocols that can allow "unsafe" and "unwise" chars.
+ unsafeProtocol = {
+ 'javascript': true,
+ 'javascript:': true
+ },
+ // protocols that never have a hostname.
+ hostlessProtocol = {
+ 'javascript': true,
+ 'javascript:': true
+ },
+ // protocols that always contain a // bit.
+ slashedProtocol = {
+ 'http': true,
+ 'https': true,
+ 'ftp': true,
+ 'gopher': true,
+ 'file': true,
+ 'http:': true,
+ 'https:': true,
+ 'ftp:': true,
+ 'gopher:': true,
+ 'file:': true
+ },
+ querystring = require('querystring');
+
+function urlParse(url, parseQueryString, slashesDenoteHost) {
+ if (url && util.isObject(url) && url instanceof Url) return url;
+
+ var u = new Url;
+ u.parse(url, parseQueryString, slashesDenoteHost);
+ return u;
+}
+
+Url.prototype.parse = function(url, parseQueryString, slashesDenoteHost) {
+ if (!util.isString(url)) {
+ throw new TypeError("Parameter 'url' must be a string, not " + typeof url);
+ }
+
+ // Copy chrome, IE, opera backslash-handling behavior.
+ // Back slashes before the query string get converted to forward slashes
+ // See: https://code.google.com/p/chromium/issues/detail?id=25916
+ var queryIndex = url.indexOf('?'),
+ splitter =
+ (queryIndex !== -1 && queryIndex < url.indexOf('#')) ? '?' : '#',
+ uSplit = url.split(splitter),
+ slashRegex = /\\/g;
+ uSplit[0] = uSplit[0].replace(slashRegex, '/');
+ url = uSplit.join(splitter);
+
+ var rest = url;
+
+ // trim before proceeding.
+ // This is to support parse stuff like " http://foo.com \n"
+ rest = rest.trim();
+
+ if (!slashesDenoteHost && url.split('#').length === 1) {
+ // Try fast path regexp
+ var simplePath = simplePathPattern.exec(rest);
+ if (simplePath) {
+ this.path = rest;
+ this.href = rest;
+ this.pathname = simplePath[1];
+ if (simplePath[2]) {
+ this.search = simplePath[2];
+ if (parseQueryString) {
+ this.query = querystring.parse(this.search.substr(1));
+ } else {
+ this.query = this.search.substr(1);
+ }
+ } else if (parseQueryString) {
+ this.search = '';
+ this.query = {};
+ }
+ return this;
+ }
+ }
+
+ var proto = protocolPattern.exec(rest);
+ if (proto) {
+ proto = proto[0];
+ var lowerProto = proto.toLowerCase();
+ this.protocol = lowerProto;
+ rest = rest.substr(proto.length);
+ }
+
+ // figure out if it's got a host
+ // user@server is *always* interpreted as a hostname, and url
+ // resolution will treat //foo/bar as host=foo,path=bar because that's
+ // how the browser resolves relative URLs.
+ if (slashesDenoteHost || proto || rest.match(/^\/\/[^@\/]+@[^@\/]+/)) {
+ var slashes = rest.substr(0, 2) === '//';
+ if (slashes && !(proto && hostlessProtocol[proto])) {
+ rest = rest.substr(2);
+ this.slashes = true;
+ }
+ }
+
+ if (!hostlessProtocol[proto] &&
+ (slashes || (proto && !slashedProtocol[proto]))) {
+
+ // there's a hostname.
+ // the first instance of /, ?, ;, or # ends the host.
+ //
+ // If there is an @ in the hostname, then non-host chars *are* allowed
+ // to the left of the last @ sign, unless some host-ending character
+ // comes *before* the @-sign.
+ // URLs are obnoxious.
+ //
+ // ex:
+ // http://a@b@c/ => user:a@b host:c
+ // http://a@b?@c => user:a host:c path:/?@c
+
+ // v0.12 TODO(isaacs): This is not quite how Chrome does things.
+ // Review our test case against browsers more comprehensively.
+
+ // find the first instance of any hostEndingChars
+ var hostEnd = -1;
+ for (var i = 0; i < hostEndingChars.length; i++) {
+ var hec = rest.indexOf(hostEndingChars[i]);
+ if (hec !== -1 && (hostEnd === -1 || hec < hostEnd))
+ hostEnd = hec;
+ }
+
+ // at this point, either we have an explicit point where the
+ // auth portion cannot go past, or the last @ char is the decider.
+ var auth, atSign;
+ if (hostEnd === -1) {
+ // atSign can be anywhere.
+ atSign = rest.lastIndexOf('@');
+ } else {
+ // atSign must be in auth portion.
+ // http://a@b/c@d => host:b auth:a path:/c@d
+ atSign = rest.lastIndexOf('@', hostEnd);
+ }
+
+ // Now we have a portion which is definitely the auth.
+ // Pull that off.
+ if (atSign !== -1) {
+ auth = rest.slice(0, atSign);
+ rest = rest.slice(atSign + 1);
+ this.auth = decodeURIComponent(auth);
+ }
+
+ // the host is the remaining to the left of the first non-host char
+ hostEnd = -1;
+ for (var i = 0; i < nonHostChars.length; i++) {
+ var hec = rest.indexOf(nonHostChars[i]);
+ if (hec !== -1 && (hostEnd === -1 || hec < hostEnd))
+ hostEnd = hec;
+ }
+ // if we still have not hit it, then the entire thing is a host.
+ if (hostEnd === -1)
+ hostEnd = rest.length;
+
+ this.host = rest.slice(0, hostEnd);
+ rest = rest.slice(hostEnd);
+
+ // pull out port.
+ this.parseHost();
+
+ // we've indicated that there is a hostname,
+ // so even if it's empty, it has to be present.
+ this.hostname = this.hostname || '';
+
+ // if hostname begins with [ and ends with ]
+ // assume that it's an IPv6 address.
+ var ipv6Hostname = this.hostname[0] === '[' &&
+ this.hostname[this.hostname.length - 1] === ']';
+
+ // validate a little.
+ if (!ipv6Hostname) {
+ var hostparts = this.hostname.split(/\./);
+ for (var i = 0, l = hostparts.length; i < l; i++) {
+ var part = hostparts[i];
+ if (!part) continue;
+ if (!part.match(hostnamePartPattern)) {
+ var newpart = '';
+ for (var j = 0, k = part.length; j < k; j++) {
+ if (part.charCodeAt(j) > 127) {
+ // we replace non-ASCII char with a temporary placeholder
+ // we need this to make sure size of hostname is not
+ // broken by replacing non-ASCII by nothing
+ newpart += 'x';
+ } else {
+ newpart += part[j];
+ }
+ }
+ // we test again with ASCII char only
+ if (!newpart.match(hostnamePartPattern)) {
+ var validParts = hostparts.slice(0, i);
+ var notHost = hostparts.slice(i + 1);
+ var bit = part.match(hostnamePartStart);
+ if (bit) {
+ validParts.push(bit[1]);
+ notHost.unshift(bit[2]);
+ }
+ if (notHost.length) {
+ rest = '/' + notHost.join('.') + rest;
+ }
+ this.hostname = validParts.join('.');
+ break;
+ }
+ }
+ }
+ }
+
+ if (this.hostname.length > hostnameMaxLen) {
+ this.hostname = '';
+ } else {
+ // hostnames are always lower case.
+ this.hostname = this.hostname.toLowerCase();
+ }
+
+ if (!ipv6Hostname) {
+ // IDNA Support: Returns a punycoded representation of "domain".
+ // It only converts parts of the domain name that
+ // have non-ASCII characters, i.e. it doesn't matter if
+ // you call it with a domain that already is ASCII-only.
+ this.hostname = punycode.toASCII(this.hostname);
+ }
+
+ var p = this.port ? ':' + this.port : '';
+ var h = this.hostname || '';
+ this.host = h + p;
+ this.href += this.host;
+
+ // strip [ and ] from the hostname
+ // the host field still retains them, though
+ if (ipv6Hostname) {
+ this.hostname = this.hostname.substr(1, this.hostname.length - 2);
+ if (rest[0] !== '/') {
+ rest = '/' + rest;
+ }
+ }
+ }
+
+ // now rest is set to the post-host stuff.
+ // chop off any delim chars.
+ if (!unsafeProtocol[lowerProto]) {
+
+ // First, make 100% sure that any "autoEscape" chars get
+ // escaped, even if encodeURIComponent doesn't think they
+ // need to be.
+ for (var i = 0, l = autoEscape.length; i < l; i++) {
+ var ae = autoEscape[i];
+ if (rest.indexOf(ae) === -1)
+ continue;
+ var esc = encodeURIComponent(ae);
+ if (esc === ae) {
+ esc = escape(ae);
+ }
+ rest = rest.split(ae).join(esc);
+ }
+ }
+
+
+ // chop off from the tail first.
+ var hash = rest.indexOf('#');
+ if (hash !== -1) {
+ // got a fragment string.
+ this.hash = rest.substr(hash);
+ rest = rest.slice(0, hash);
+ }
+ var qm = rest.indexOf('?');
+ if (qm !== -1) {
+ this.search = rest.substr(qm);
+ this.query = rest.substr(qm + 1);
+ if (parseQueryString) {
+ this.query = querystring.parse(this.query);
+ }
+ rest = rest.slice(0, qm);
+ } else if (parseQueryString) {
+ // no query string, but parseQueryString still requested
+ this.search = '';
+ this.query = {};
+ }
+ if (rest) this.pathname = rest;
+ if (slashedProtocol[lowerProto] &&
+ this.hostname && !this.pathname) {
+ this.pathname = '/';
+ }
+
+ //to support http.request
+ if (this.pathname || this.search) {
+ var p = this.pathname || '';
+ var s = this.search || '';
+ this.path = p + s;
+ }
+
+ // finally, reconstruct the href based on what has been validated.
+ this.href = this.format();
+ return this;
+};
+
+// format a parsed object into a url string
+function urlFormat(obj) {
+ // ensure it's an object, and not a string url.
+ // If it's an obj, this is a no-op.
+ // this way, you can call url_format() on strings
+ // to clean up potentially wonky urls.
+ if (util.isString(obj)) obj = urlParse(obj);
+ if (!(obj instanceof Url)) return Url.prototype.format.call(obj);
+ return obj.format();
+}
+
+Url.prototype.format = function() {
+ var auth = this.auth || '';
+ if (auth) {
+ auth = encodeURIComponent(auth);
+ auth = auth.replace(/%3A/i, ':');
+ auth += '@';
+ }
+
+ var protocol = this.protocol || '',
+ pathname = this.pathname || '',
+ hash = this.hash || '',
+ host = false,
+ query = '';
+
+ if (this.host) {
+ host = auth + this.host;
+ } else if (this.hostname) {
+ host = auth + (this.hostname.indexOf(':') === -1 ?
+ this.hostname :
+ '[' + this.hostname + ']');
+ if (this.port) {
+ host += ':' + this.port;
+ }
+ }
+
+ if (this.query &&
+ util.isObject(this.query) &&
+ Object.keys(this.query).length) {
+ query = querystring.stringify(this.query);
+ }
+
+ var search = this.search || (query && ('?' + query)) || '';
+
+ if (protocol && protocol.substr(-1) !== ':') protocol += ':';
+
+ // only the slashedProtocols get the //. Not mailto:, xmpp:, etc.
+ // unless they had them to begin with.
+ if (this.slashes ||
+ (!protocol || slashedProtocol[protocol]) && host !== false) {
+ host = '//' + (host || '');
+ if (pathname && pathname.charAt(0) !== '/') pathname = '/' + pathname;
+ } else if (!host) {
+ host = '';
+ }
+
+ if (hash && hash.charAt(0) !== '#') hash = '#' + hash;
+ if (search && search.charAt(0) !== '?') search = '?' + search;
+
+ pathname = pathname.replace(/[?#]/g, function(match) {
+ return encodeURIComponent(match);
+ });
+ search = search.replace('#', '%23');
+
+ return protocol + host + pathname + search + hash;
+};
+
+function urlResolve(source, relative) {
+ return urlParse(source, false, true).resolve(relative);
+}
+
+Url.prototype.resolve = function(relative) {
+ return this.resolveObject(urlParse(relative, false, true)).format();
+};
+
+function urlResolveObject(source, relative) {
+ if (!source) return relative;
+ return urlParse(source, false, true).resolveObject(relative);
+}
+
+Url.prototype.resolveObject = function(relative) {
+ if (util.isString(relative)) {
+ var rel = new Url();
+ rel.parse(relative, false, true);
+ relative = rel;
+ }
+
+ var result = new Url();
+ var tkeys = Object.keys(this);
+ for (var tk = 0; tk < tkeys.length; tk++) {
+ var tkey = tkeys[tk];
+ result[tkey] = this[tkey];
+ }
+
+ // hash is always overridden, no matter what.
+ // even href="" will remove it.
+ result.hash = relative.hash;
+
+ // if the relative url is empty, then there's nothing left to do here.
+ if (relative.href === '') {
+ result.href = result.format();
+ return result;
+ }
+
+ // hrefs like //foo/bar always cut to the protocol.
+ if (relative.slashes && !relative.protocol) {
+ // take everything except the protocol from relative
+ var rkeys = Object.keys(relative);
+ for (var rk = 0; rk < rkeys.length; rk++) {
+ var rkey = rkeys[rk];
+ if (rkey !== 'protocol')
+ result[rkey] = relative[rkey];
+ }
+
+ //urlParse appends trailing / to urls like http://www.example.com
+ if (slashedProtocol[result.protocol] &&
+ result.hostname && !result.pathname) {
+ result.path = result.pathname = '/';
+ }
+
+ result.href = result.format();
+ return result;
+ }
+
+ if (relative.protocol && relative.protocol !== result.protocol) {
+ // if it's a known url protocol, then changing
+ // the protocol does weird things
+ // first, if it's not file:, then we MUST have a host,
+ // and if there was a path
+ // to begin with, then we MUST have a path.
+ // if it is file:, then the host is dropped,
+ // because that's known to be hostless.
+ // anything else is assumed to be absolute.
+ if (!slashedProtocol[relative.protocol]) {
+ var keys = Object.keys(relative);
+ for (var v = 0; v < keys.length; v++) {
+ var k = keys[v];
+ result[k] = relative[k];
+ }
+ result.href = result.format();
+ return result;
+ }
+
+ result.protocol = relative.protocol;
+ if (!relative.host && !hostlessProtocol[relative.protocol]) {
+ var relPath = (relative.pathname || '').split('/');
+ while (relPath.length && !(relative.host = relPath.shift()));
+ if (!relative.host) relative.host = '';
+ if (!relative.hostname) relative.hostname = '';
+ if (relPath[0] !== '') relPath.unshift('');
+ if (relPath.length < 2) relPath.unshift('');
+ result.pathname = relPath.join('/');
+ } else {
+ result.pathname = relative.pathname;
+ }
+ result.search = relative.search;
+ result.query = relative.query;
+ result.host = relative.host || '';
+ result.auth = relative.auth;
+ result.hostname = relative.hostname || relative.host;
+ result.port = relative.port;
+ // to support http.request
+ if (result.pathname || result.search) {
+ var p = result.pathname || '';
+ var s = result.search || '';
+ result.path = p + s;
+ }
+ result.slashes = result.slashes || relative.slashes;
+ result.href = result.format();
+ return result;
+ }
+
+ var isSourceAbs = (result.pathname && result.pathname.charAt(0) === '/'),
+ isRelAbs = (
+ relative.host ||
+ relative.pathname && relative.pathname.charAt(0) === '/'
+ ),
+ mustEndAbs = (isRelAbs || isSourceAbs ||
+ (result.host && relative.pathname)),
+ removeAllDots = mustEndAbs,
+ srcPath = result.pathname && result.pathname.split('/') || [],
+ relPath = relative.pathname && relative.pathname.split('/') || [],
+ psychotic = result.protocol && !slashedProtocol[result.protocol];
+
+ // if the url is a non-slashed url, then relative
+ // links like ../.. should be able
+ // to crawl up to the hostname, as well. This is strange.
+ // result.protocol has already been set by now.
+ // Later on, put the first path part into the host field.
+ if (psychotic) {
+ result.hostname = '';
+ result.port = null;
+ if (result.host) {
+ if (srcPath[0] === '') srcPath[0] = result.host;
+ else srcPath.unshift(result.host);
+ }
+ result.host = '';
+ if (relative.protocol) {
+ relative.hostname = null;
+ relative.port = null;
+ if (relative.host) {
+ if (relPath[0] === '') relPath[0] = relative.host;
+ else relPath.unshift(relative.host);
+ }
+ relative.host = null;
+ }
+ mustEndAbs = mustEndAbs && (relPath[0] === '' || srcPath[0] === '');
+ }
+
+ if (isRelAbs) {
+ // it's absolute.
+ result.host = (relative.host || relative.host === '') ?
+ relative.host : result.host;
+ result.hostname = (relative.hostname || relative.hostname === '') ?
+ relative.hostname : result.hostname;
+ result.search = relative.search;
+ result.query = relative.query;
+ srcPath = relPath;
+ // fall through to the dot-handling below.
+ } else if (relPath.length) {
+ // it's relative
+ // throw away the existing file, and take the new path instead.
+ if (!srcPath) srcPath = [];
+ srcPath.pop();
+ srcPath = srcPath.concat(relPath);
+ result.search = relative.search;
+ result.query = relative.query;
+ } else if (!util.isNullOrUndefined(relative.search)) {
+ // just pull out the search.
+ // like href='?foo'.
+ // Put this after the other two cases because it simplifies the booleans
+ if (psychotic) {
+ result.hostname = result.host = srcPath.shift();
+ //occationaly the auth can get stuck only in host
+ //this especially happens in cases like
+ //url.resolveObject('mailto:local1@domain1', 'local2@domain2')
+ var authInHost = result.host && result.host.indexOf('@') > 0 ?
+ result.host.split('@') : false;
+ if (authInHost) {
+ result.auth = authInHost.shift();
+ result.host = result.hostname = authInHost.shift();
+ }
+ }
+ result.search = relative.search;
+ result.query = relative.query;
+ //to support http.request
+ if (!util.isNull(result.pathname) || !util.isNull(result.search)) {
+ result.path = (result.pathname ? result.pathname : '') +
+ (result.search ? result.search : '');
+ }
+ result.href = result.format();
+ return result;
+ }
+
+ if (!srcPath.length) {
+ // no path at all. easy.
+ // we've already handled the other stuff above.
+ result.pathname = null;
+ //to support http.request
+ if (result.search) {
+ result.path = '/' + result.search;
+ } else {
+ result.path = null;
+ }
+ result.href = result.format();
+ return result;
+ }
+
+ // if a url ENDs in . or .., then it must get a trailing slash.
+ // however, if it ends in anything else non-slashy,
+ // then it must NOT get a trailing slash.
+ var last = srcPath.slice(-1)[0];
+ var hasTrailingSlash = (
+ (result.host || relative.host || srcPath.length > 1) &&
+ (last === '.' || last === '..') || last === '');
+
+ // strip single dots, resolve double dots to parent dir
+ // if the path tries to go above the root, `up` ends up > 0
+ var up = 0;
+ for (var i = srcPath.length; i >= 0; i--) {
+ last = srcPath[i];
+ if (last === '.') {
+ srcPath.splice(i, 1);
+ } else if (last === '..') {
+ srcPath.splice(i, 1);
+ up++;
+ } else if (up) {
+ srcPath.splice(i, 1);
+ up--;
+ }
+ }
+
+ // if the path is allowed to go above the root, restore leading ..s
+ if (!mustEndAbs && !removeAllDots) {
+ for (; up--; up) {
+ srcPath.unshift('..');
+ }
+ }
+
+ if (mustEndAbs && srcPath[0] !== '' &&
+ (!srcPath[0] || srcPath[0].charAt(0) !== '/')) {
+ srcPath.unshift('');
+ }
+
+ if (hasTrailingSlash && (srcPath.join('/').substr(-1) !== '/')) {
+ srcPath.push('');
+ }
+
+ var isAbsolute = srcPath[0] === '' ||
+ (srcPath[0] && srcPath[0].charAt(0) === '/');
+
+ // put the host back
+ if (psychotic) {
+ result.hostname = result.host = isAbsolute ? '' :
+ srcPath.length ? srcPath.shift() : '';
+ //occationaly the auth can get stuck only in host
+ //this especially happens in cases like
+ //url.resolveObject('mailto:local1@domain1', 'local2@domain2')
+ var authInHost = result.host && result.host.indexOf('@') > 0 ?
+ result.host.split('@') : false;
+ if (authInHost) {
+ result.auth = authInHost.shift();
+ result.host = result.hostname = authInHost.shift();
+ }
+ }
+
+ mustEndAbs = mustEndAbs || (result.host && srcPath.length);
+
+ if (mustEndAbs && !isAbsolute) {
+ srcPath.unshift('');
+ }
+
+ if (!srcPath.length) {
+ result.pathname = null;
+ result.path = null;
+ } else {
+ result.pathname = srcPath.join('/');
+ }
+
+ //to support request.http
+ if (!util.isNull(result.pathname) || !util.isNull(result.search)) {
+ result.path = (result.pathname ? result.pathname : '') +
+ (result.search ? result.search : '');
+ }
+ result.auth = relative.auth || result.auth;
+ result.slashes = result.slashes || relative.slashes;
+ result.href = result.format();
+ return result;
+};
+
+Url.prototype.parseHost = function() {
+ var host = this.host;
+ var port = portPattern.exec(host);
+ if (port) {
+ port = port[0];
+ if (port !== ':') {
+ this.port = port.substr(1);
+ }
+ host = host.substr(0, host.length - port.length);
+ }
+ if (host) this.hostname = host;
+};
+
+},{"./util":85,"punycode":64,"querystring":67}],85:[function(require,module,exports){
+'use strict';
+
+module.exports = {
+ isString: function(arg) {
+ return typeof(arg) === 'string';
+ },
+ isObject: function(arg) {
+ return typeof(arg) === 'object' && arg !== null;
+ },
+ isNull: function(arg) {
+ return arg === null;
+ },
+ isNullOrUndefined: function(arg) {
+ return arg == null;
+ }
+};
+
+},{}],86:[function(require,module,exports){
+(function (global){
+
+/**
+ * Module exports.
+ */
+
+module.exports = deprecate;
+
+/**
+ * Mark that a method should not be used.
+ * Returns a modified function which warns once by default.
+ *
+ * If `localStorage.noDeprecation = true` is set, then it is a no-op.
+ *
+ * If `localStorage.throwDeprecation = true` is set, then deprecated functions
+ * will throw an Error when invoked.
+ *
+ * If `localStorage.traceDeprecation = true` is set, then deprecated functions
+ * will invoke `console.trace()` instead of `console.error()`.
+ *
+ * @param {Function} fn - the function to deprecate
+ * @param {String} msg - the string to print to the console when `fn` is invoked
+ * @returns {Function} a new "deprecated" version of `fn`
+ * @api public
+ */
+
+function deprecate (fn, msg) {
+ if (config('noDeprecation')) {
+ return fn;
+ }
+
+ var warned = false;
+ function deprecated() {
+ if (!warned) {
+ if (config('throwDeprecation')) {
+ throw new Error(msg);
+ } else if (config('traceDeprecation')) {
+ console.trace(msg);
+ } else {
+ console.warn(msg);
+ }
+ warned = true;
+ }
+ return fn.apply(this, arguments);
+ }
+
+ return deprecated;
+}
+
+/**
+ * Checks `localStorage` for boolean values for the given `name`.
+ *
+ * @param {String} name
+ * @returns {Boolean}
+ * @api private
+ */
+
+function config (name) {
+ // accessing global.localStorage can trigger a DOMException in sandboxed iframes
+ try {
+ if (!global.localStorage) return false;
+ } catch (_) {
+ return false;
+ }
+ var val = global.localStorage[name];
+ if (null == val) return false;
+ return String(val).toLowerCase() === 'true';
+}
+
+}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
+
+},{}],87:[function(require,module,exports){
+(function (process,Buffer){
+/**
+ * Wrapper for built-in http.js to emulate the browser XMLHttpRequest object.
+ *
+ * This can be used with JS designed for browsers to improve reuse of code and
+ * allow the use of existing libraries.
+ *
+ * Usage: include("XMLHttpRequest.js") and use XMLHttpRequest per W3C specs.
+ *
+ * @author Dan DeFelippi
+ * @contributor David Ellis
+ * @license MIT
+ */
+
+var Url = require("url");
+var spawn = require("child_process").spawn;
+var fs = require("fs");
+
+exports.XMLHttpRequest = function() {
+ "use strict";
+
+ /**
+ * Private variables
+ */
+ var self = this;
+ var http = require("http");
+ var https = require("https");
+
+ // Holds http.js objects
+ var request;
+ var response;
+
+ // Request settings
+ var settings = {};
+
+ // Disable header blacklist.
+ // Not part of XHR specs.
+ var disableHeaderCheck = false;
+
+ // Set some default headers
+ var defaultHeaders = {
+ "User-Agent": "node-XMLHttpRequest",
+ "Accept": "*/*",
+ };
+
+ var headers = {};
+ var headersCase = {};
+
+ // These headers are not user setable.
+ // The following are allowed but banned in the spec:
+ // * user-agent
+ var forbiddenRequestHeaders = [
+ "accept-charset",
+ "accept-encoding",
+ "access-control-request-headers",
+ "access-control-request-method",
+ "connection",
+ "content-length",
+ "content-transfer-encoding",
+ "cookie",
+ "cookie2",
+ "date",
+ "expect",
+ "host",
+ "keep-alive",
+ "origin",
+ "referer",
+ "te",
+ "trailer",
+ "transfer-encoding",
+ "upgrade",
+ "via"
+ ];
+
+ // These request methods are not allowed
+ var forbiddenRequestMethods = [
+ "TRACE",
+ "TRACK",
+ "CONNECT"
+ ];
+
+ // Send flag
+ var sendFlag = false;
+ // Error flag, used when errors occur or abort is called
+ var errorFlag = false;
+
+ // Event listeners
+ var listeners = {};
+
+ /**
+ * Constants
+ */
+
+ this.UNSENT = 0;
+ this.OPENED = 1;
+ this.HEADERS_RECEIVED = 2;
+ this.LOADING = 3;
+ this.DONE = 4;
+
+ /**
+ * Public vars
+ */
+
+ // Current state
+ this.readyState = this.UNSENT;
+
+ // default ready state change handler in case one is not set or is set late
+ this.onreadystatechange = null;
+
+ // Result & response
+ this.responseText = "";
+ this.responseXML = "";
+ this.status = null;
+ this.statusText = null;
+
+ // Whether cross-site Access-Control requests should be made using
+ // credentials such as cookies or authorization headers
+ this.withCredentials = false;
+
+ /**
+ * Private methods
+ */
+
+ /**
+ * Check if the specified header is allowed.
+ *
+ * @param string header Header to validate
+ * @return boolean False if not allowed, otherwise true
+ */
+ var isAllowedHttpHeader = function(header) {
+ return disableHeaderCheck || (header && forbiddenRequestHeaders.indexOf(header.toLowerCase()) === -1);
+ };
+
+ /**
+ * Check if the specified method is allowed.
+ *
+ * @param string method Request method to validate
+ * @return boolean False if not allowed, otherwise true
+ */
+ var isAllowedHttpMethod = function(method) {
+ return (method && forbiddenRequestMethods.indexOf(method) === -1);
+ };
+
+ /**
+ * Public methods
+ */
+
+ /**
+ * Open the connection. Currently supports local server requests.
+ *
+ * @param string method Connection method (eg GET, POST)
+ * @param string url URL for the connection.
+ * @param boolean async Asynchronous connection. Default is true.
+ * @param string user Username for basic authentication (optional)
+ * @param string password Password for basic authentication (optional)
+ */
+ this.open = function(method, url, async, user, password) {
+ this.abort();
+ errorFlag = false;
+
+ // Check for valid request method
+ if (!isAllowedHttpMethod(method)) {
+ throw new Error("SecurityError: Request method not allowed");
+ }
+
+ settings = {
+ "method": method,
+ "url": url.toString(),
+ "async": (typeof async !== "boolean" ? true : async),
+ "user": user || null,
+ "password": password || null
+ };
+
+ setState(this.OPENED);
+ };
+
+ /**
+ * Disables or enables isAllowedHttpHeader() check the request. Enabled by default.
+ * This does not conform to the W3C spec.
+ *
+ * @param boolean state Enable or disable header checking.
+ */
+ this.setDisableHeaderCheck = function(state) {
+ disableHeaderCheck = state;
+ };
+
+ /**
+ * Sets a header for the request or appends the value if one is already set.
+ *
+ * @param string header Header name
+ * @param string value Header value
+ */
+ this.setRequestHeader = function(header, value) {
+ if (this.readyState !== this.OPENED) {
+ throw new Error("INVALID_STATE_ERR: setRequestHeader can only be called when state is OPEN");
+ }
+ if (!isAllowedHttpHeader(header)) {
+ console.warn("Refused to set unsafe header \"" + header + "\"");
+ return;
+ }
+ if (sendFlag) {
+ throw new Error("INVALID_STATE_ERR: send flag is true");
+ }
+ header = headersCase[header.toLowerCase()] || header;
+ headersCase[header.toLowerCase()] = header;
+ headers[header] = headers[header] ? headers[header] + ', ' + value : value;
+ };
+
+ /**
+ * Gets a header from the server response.
+ *
+ * @param string header Name of header to get.
+ * @return string Text of the header or null if it doesn't exist.
+ */
+ this.getResponseHeader = function(header) {
+ if (typeof header === "string"
+ && this.readyState > this.OPENED
+ && response
+ && response.headers
+ && response.headers[header.toLowerCase()]
+ && !errorFlag
+ ) {
+ return response.headers[header.toLowerCase()];
+ }
+
+ return null;
+ };
+
+ /**
+ * Gets all the response headers.
+ *
+ * @return string A string with all response headers separated by CR+LF
+ */
+ this.getAllResponseHeaders = function() {
+ if (this.readyState < this.HEADERS_RECEIVED || errorFlag) {
+ return "";
+ }
+ var result = "";
+
+ for (var i in response.headers) {
+ // Cookie headers are excluded
+ if (i !== "set-cookie" && i !== "set-cookie2") {
+ result += i + ": " + response.headers[i] + "\r\n";
+ }
+ }
+ return result.substr(0, result.length - 2);
+ };
+
+ /**
+ * Gets a request header
+ *
+ * @param string name Name of header to get
+ * @return string Returns the request header or empty string if not set
+ */
+ this.getRequestHeader = function(name) {
+ if (typeof name === "string" && headersCase[name.toLowerCase()]) {
+ return headers[headersCase[name.toLowerCase()]];
+ }
+
+ return "";
+ };
+
+ /**
+ * Sends the request to the server.
+ *
+ * @param string data Optional data to send as request body.
+ */
+ this.send = function(data) {
+ if (this.readyState !== this.OPENED) {
+ throw new Error("INVALID_STATE_ERR: connection must be opened before send() is called");
+ }
+
+ if (sendFlag) {
+ throw new Error("INVALID_STATE_ERR: send has already been called");
+ }
+
+ var ssl = false, local = false;
+ var url = Url.parse(settings.url);
+ var host;
+ // Determine the server
+ switch (url.protocol) {
+ case "https:":
+ ssl = true;
+ // SSL & non-SSL both need host, no break here.
+ case "http:":
+ host = url.hostname;
+ break;
+
+ case "file:":
+ local = true;
+ break;
+
+ case undefined:
+ case null:
+ case "":
+ host = "localhost";
+ break;
+
+ default:
+ throw new Error("Protocol not supported.");
+ }
+
+ // Load files off the local filesystem (file://)
+ if (local) {
+ if (settings.method !== "GET") {
+ throw new Error("XMLHttpRequest: Only GET method is supported");
+ }
+
+ if (settings.async) {
+ fs.readFile(url.pathname, "utf8", function(error, data) {
+ if (error) {
+ self.handleError(error);
+ } else {
+ self.status = 200;
+ self.responseText = data;
+ setState(self.DONE);
+ }
+ });
+ } else {
+ try {
+ this.responseText = fs.readFileSync(url.pathname, "utf8");
+ this.status = 200;
+ setState(self.DONE);
+ } catch(e) {
+ this.handleError(e);
+ }
+ }
+
+ return;
+ }
+
+ // Default to port 80. If accessing localhost on another port be sure
+ // to use http://localhost:port/path
+ var port = url.port || (ssl ? 443 : 80);
+ // Add query string if one is used
+ var uri = url.pathname + (url.search ? url.search : "");
+
+ // Set the defaults if they haven't been set
+ for (var name in defaultHeaders) {
+ if (!headersCase[name.toLowerCase()]) {
+ headers[name] = defaultHeaders[name];
+ }
+ }
+
+ // Set the Host header or the server may reject the request
+ headers.Host = host;
+ if (!((ssl && port === 443) || port === 80)) {
+ headers.Host += ":" + url.port;
+ }
+
+ // Set Basic Auth if necessary
+ if (settings.user) {
+ if (typeof settings.password === "undefined") {
+ settings.password = "";
+ }
+ var authBuf = new Buffer(settings.user + ":" + settings.password);
+ headers.Authorization = "Basic " + authBuf.toString("base64");
+ }
+
+ // Set content length header
+ if (settings.method === "GET" || settings.method === "HEAD") {
+ data = null;
+ } else if (data) {
+ headers["Content-Length"] = Buffer.isBuffer(data) ? data.length : Buffer.byteLength(data);
+
+ if (!headers["Content-Type"]) {
+ headers["Content-Type"] = "text/plain;charset=UTF-8";
+ }
+ } else if (settings.method === "POST") {
+ // For a post with no data set Content-Length: 0.
+ // This is required by buggy servers that don't meet the specs.
+ headers["Content-Length"] = 0;
+ }
+
+ var options = {
+ host: host,
+ port: port,
+ path: uri,
+ method: settings.method,
+ headers: headers,
+ agent: false,
+ withCredentials: self.withCredentials
+ };
+
+ // Reset error flag
+ errorFlag = false;
+
+ // Handle async requests
+ if (settings.async) {
+ // Use the proper protocol
+ var doRequest = ssl ? https.request : http.request;
+
+ // Request is being sent, set send flag
+ sendFlag = true;
+
+ // As per spec, this is called here for historical reasons.
+ self.dispatchEvent("readystatechange");
+
+ // Handler for the response
+ var responseHandler = function responseHandler(resp) {
+ // Set response var to the response we got back
+ // This is so it remains accessable outside this scope
+ response = resp;
+ // Check for redirect
+ // @TODO Prevent looped redirects
+ if (response.statusCode === 301 || response.statusCode === 302 || response.statusCode === 303 || response.statusCode === 307) {
+ // Change URL to the redirect location
+ settings.url = response.headers.location;
+ var url = Url.parse(settings.url);
+ // Set host var in case it's used later
+ host = url.hostname;
+ // Options for the new request
+ var newOptions = {
+ hostname: url.hostname,
+ port: url.port,
+ path: url.path,
+ method: response.statusCode === 303 ? "GET" : settings.method,
+ headers: headers,
+ withCredentials: self.withCredentials
+ };
+
+ // Issue the new request
+ request = doRequest(newOptions, responseHandler).on("error", errorHandler);
+ request.end();
+ // @TODO Check if an XHR event needs to be fired here
+ return;
+ }
+
+ response.setEncoding("utf8");
+
+ setState(self.HEADERS_RECEIVED);
+ self.status = response.statusCode;
+
+ response.on("data", function(chunk) {
+ // Make sure there's some data
+ if (chunk) {
+ self.responseText += chunk;
+ }
+ // Don't emit state changes if the connection has been aborted.
+ if (sendFlag) {
+ setState(self.LOADING);
+ }
+ });
+
+ response.on("end", function() {
+ if (sendFlag) {
+ // Discard the end event if the connection has been aborted
+ setState(self.DONE);
+ sendFlag = false;
+ }
+ });
+
+ response.on("error", function(error) {
+ self.handleError(error);
+ });
+ };
+
+ // Error handler for the request
+ var errorHandler = function errorHandler(error) {
+ self.handleError(error);
+ };
+
+ // Create the request
+ request = doRequest(options, responseHandler).on("error", errorHandler);
+
+ // Node 0.4 and later won't accept empty data. Make sure it's needed.
+ if (data) {
+ request.write(data);
+ }
+
+ request.end();
+
+ self.dispatchEvent("loadstart");
+ } else { // Synchronous
+ // Create a temporary file for communication with the other Node process
+ var contentFile = ".node-xmlhttprequest-content-" + process.pid;
+ var syncFile = ".node-xmlhttprequest-sync-" + process.pid;
+ fs.writeFileSync(syncFile, "", "utf8");
+ // The async request the other Node process executes
+ var execString = "var http = require('http'), https = require('https'), fs = require('fs');"
+ + "var doRequest = http" + (ssl ? "s" : "") + ".request;"
+ + "var options = " + JSON.stringify(options) + ";"
+ + "var responseText = '';"
+ + "var req = doRequest(options, function(response) {"
+ + "response.setEncoding('utf8');"
+ + "response.on('data', function(chunk) {"
+ + " responseText += chunk;"
+ + "});"
+ + "response.on('end', function() {"
+ + "fs.writeFileSync('" + contentFile + "', JSON.stringify({err: null, data: {statusCode: response.statusCode, headers: response.headers, text: responseText}}), 'utf8');"
+ + "fs.unlinkSync('" + syncFile + "');"
+ + "});"
+ + "response.on('error', function(error) {"
+ + "fs.writeFileSync('" + contentFile + "', JSON.stringify({err: error}), 'utf8');"
+ + "fs.unlinkSync('" + syncFile + "');"
+ + "});"
+ + "}).on('error', function(error) {"
+ + "fs.writeFileSync('" + contentFile + "', JSON.stringify({err: error}), 'utf8');"
+ + "fs.unlinkSync('" + syncFile + "');"
+ + "});"
+ + (data ? "req.write('" + JSON.stringify(data).slice(1,-1).replace(/'/g, "\\'") + "');":"")
+ + "req.end();";
+ // Start the other Node Process, executing this string
+ var syncProc = spawn(process.argv[0], ["-e", execString]);
+ while(fs.existsSync(syncFile)) {
+ // Wait while the sync file is empty
+ }
+ var resp = JSON.parse(fs.readFileSync(contentFile, 'utf8'));
+ // Kill the child process once the file has data
+ syncProc.stdin.end();
+ // Remove the temporary file
+ fs.unlinkSync(contentFile);
+
+ if (resp.err) {
+ self.handleError(resp.err);
+ } else {
+ response = resp.data;
+ self.status = resp.data.statusCode;
+ self.responseText = resp.data.text;
+ setState(self.DONE);
+ }
+ }
+ };
+
+ /**
+ * Called when an error is encountered to deal with it.
+ */
+ this.handleError = function(error) {
+ this.status = 0;
+ this.statusText = error;
+ this.responseText = error.stack;
+ errorFlag = true;
+ setState(this.DONE);
+ this.dispatchEvent('error');
+ };
+
+ /**
+ * Aborts a request.
+ */
+ this.abort = function() {
+ if (request) {
+ request.abort();
+ request = null;
+ }
+
+ headers = defaultHeaders;
+ this.status = 0;
+ this.responseText = "";
+ this.responseXML = "";
+
+ errorFlag = true;
+
+ if (this.readyState !== this.UNSENT
+ && (this.readyState !== this.OPENED || sendFlag)
+ && this.readyState !== this.DONE) {
+ sendFlag = false;
+ setState(this.DONE);
+ }
+ this.readyState = this.UNSENT;
+ this.dispatchEvent('abort');
+ };
+
+ /**
+ * Adds an event listener. Preferred method of binding to events.
+ */
+ this.addEventListener = function(event, callback) {
+ if (!(event in listeners)) {
+ listeners[event] = [];
+ }
+ // Currently allows duplicate callbacks. Should it?
+ listeners[event].push(callback);
+ };
+
+ /**
+ * Remove an event callback that has already been bound.
+ * Only works on the matching funciton, cannot be a copy.
+ */
+ this.removeEventListener = function(event, callback) {
+ if (event in listeners) {
+ // Filter will return a new array with the callback removed
+ listeners[event] = listeners[event].filter(function(ev) {
+ return ev !== callback;
+ });
+ }
+ };
+
+ /**
+ * Dispatch any events, including both "on" methods and events attached using addEventListener.
+ */
+ this.dispatchEvent = function(event) {
+ if (typeof self["on" + event] === "function") {
+ self["on" + event]();
+ }
+ if (event in listeners) {
+ for (var i = 0, len = listeners[event].length; i < len; i++) {
+ listeners[event][i].call(self);
+ }
+ }
+ };
+
+ /**
+ * Changes readyState and calls onreadystatechange.
+ *
+ * @param int state New state
+ */
+ var setState = function(state) {
+ if (state == self.LOADING || self.readyState !== state) {
+ self.readyState = state;
+
+ if (settings.async || self.readyState < self.OPENED || self.readyState === self.DONE) {
+ self.dispatchEvent("readystatechange");
+ }
+
+ if (self.readyState === self.DONE && !errorFlag) {
+ self.dispatchEvent("load");
+ // @TODO figure out InspectorInstrumentation::didLoadXHR(cookie)
+ self.dispatchEvent("loadend");
+ }
+ }
+ };
+};
+
+}).call(this,require('_process'),require("buffer").Buffer)
+
+},{"_process":63,"buffer":20,"child_process":19,"fs":19,"http":78,"https":56,"url":84}],88:[function(require,module,exports){
+module.exports = extend
+
+var hasOwnProperty = Object.prototype.hasOwnProperty;
+
+function extend() {
+ var target = {}
+
+ for (var i = 0; i < arguments.length; i++) {
+ var source = arguments[i]
+
+ for (var key in source) {
+ if (hasOwnProperty.call(source, key)) {
+ target[key] = source[key]
+ }
+ }
+ }
+
+ return target
+}
+
+},{}]},{},[16])
+//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIm5vZGVfbW9kdWxlcy9icm93c2VyLXBhY2svX3ByZWx1ZGUuanMiLCJhc3NldHMvc3JjL2pzL2NvbXBvbmVudHMvQ291bnRXaWRnZXQuanMiLCJhc3NldHMvc3JjL2pzL2NvbXBvbmVudHMvRGF0ZVBpY2tlci5qcyIsImFzc2V0cy9zcmMvanMvY29tcG9uZW50cy9HcmFwaC5qcyIsImFzc2V0cy9zcmMvanMvY29tcG9uZW50cy9HcmFwaFdpZGdldC5qcyIsImFzc2V0cy9zcmMvanMvY29tcG9uZW50cy9IZWFkZXJCYXIuanMiLCJhc3NldHMvc3JjL2pzL2NvbXBvbmVudHMvTG9naW5Gb3JtLmpzIiwiYXNzZXRzL3NyYy9qcy9jb21wb25lbnRzL0xvZ291dEJ1dHRvbi5qcyIsImFzc2V0cy9zcmMvanMvY29tcG9uZW50cy9Ob3RpZmljYXRpb24uanMiLCJhc3NldHMvc3JjL2pzL2NvbXBvbmVudHMvUGFnZXZpZXdzLmpzIiwiYXNzZXRzL3NyYy9qcy9jb21wb25lbnR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hdHRyKFwiY3Vyc29yXCIsIGN1cnNvcnMuc2VsZWN0aW9uKTtcbiAgICAgICAgICAgIG1vdmUoKTtcbiAgICAgICAgICB9XG4gICAgICAgICAgYnJlYWs7XG4gICAgICAgIH1cbiAgICAgICAgZGVmYXVsdDogcmV0dXJuO1xuICAgICAgfVxuICAgICAgbm9ldmVudCgpO1xuICAgIH1cblxuICAgIGZ1bmN0aW9uIGtleXVwcGVkKCkge1xuICAgICAgc3dpdGNoIChkM1NlbGVjdGlvbi5ldmVudC5rZXlDb2RlKSB7XG4gICAgICAgIGNhc2UgMTY6IHsgLy8gU0hJRlRcbiAgICAgICAgICBpZiAoc2hpZnRpbmcpIHtcbiAgICAgICAgICAgIGxvY2tYID0gbG9ja1kgPSBzaGlmdGluZyA9IGZhbHNlO1xuICAgICAgICAgICAgbW92ZSgpO1xuICAgICAgICAgIH1cbiAgICAgICAgICBicmVhaztcbiAgICAgICAgfVxuICAgICAgICBjYXNlIDE4OiB7IC8vIEFMVFxuICAgICAgICAgIGlmIChtb2RlID09PSBNT0RFX0NFTlRFUikge1xuICAgICAgICAgICAgaWYgKHNpZ25YIDwgMCkgZTAgPSBlMTsgZWxzZSBpZiAoc2lnblggPiAwKSB3MCA9IHcxO1xuICAgICAgICAgICAgaWYgKHNpZ25ZIDwgMCkgczAgPSBzMTsgZWxzZSBpZiAoc2lnblkgPiAwKSBuMCA9IG4xO1xuICAgICAgICAgICAgbW9kZSA9IE1PREVfSEFORExFO1xuICAgICAgICAgICAgbW92ZSgpO1xuICAgICAgICAgIH1cbiAgICAgICAgICBicmVhaztcbiAgICAgICAgfVxuICAgICAgICBjYXNlIDMyOiB7IC8vIFNQQUNFXG4gICAgICAgICAgaWYgKG1vZGUgPT09IE1PREVfU1BBQ0UpIHtcbiAgICAgICAgICAgIGlmIChkM1NlbGVjdGlvbi5ldmVudC5hbHRLZXkpIHtcbiAgICAgICAgICAgICAgaWYgKHNpZ25YKSBlMCA9IGUxIC0gZHggKiBzaWduWCwgdzAgPSB3MSArIGR4ICogc2lnblg7XG4gICAgICAgICAgICAgIGlmIChzaWduWSkgczAgPSBzMSAtIGR5ICogc2lnblksIG4wID0gbjEgKyBkeSAqIHNpZ25ZO1xuICAgICAgICAgICAgICBtb2RlID0gTU9ERV9DRU5URVI7XG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICBpZiAoc2lnblggPCAwKSBlMCA9IGUxOyBlbHNlIGlmIChzaWduWCA+IDApIHcwID0gdzE7XG4gICAgICAgICAgICAgIGlmIChzaWduWSA8IDApIHMwID0gczE7IGVsc2UgaWYgKHNpZ25ZID4gMCkgbjAgPSBuMTtcbiAgICAgICAgICAgICAgbW9kZSA9IE1PREVfSEFORExFO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgb3ZlcmxheS5hdHRyKFwiY3Vyc29yXCIsIGN1cnNvcnNbdHlwZV0pO1xuICAgICAgICAgICAgbW92ZSgpO1xuICAgICAgICAgIH1cbiAgICAgICAgICBicmVhaztcbiAgICAgICAgfVxuICAgICAgICBkZWZhdWx0OiByZXR1cm47XG4gICAgICB9XG4gICAgICBub2V2ZW50KCk7XG4gICAgfVxuICB9XG5cbiAgZnVuY3Rpb24gaW5pdGlhbGl6ZSgpIHtcbiAgICB2YXIgc3RhdGUgPSB0aGlzLl9fYnJ1c2ggfHwge3NlbGVjdGlvbjogbnVsbH07XG4gICAgc3RhdGUuZXh0ZW50ID0gZXh0ZW50LmFwcGx5KHRoaXMsIGFyZ3VtZW50cyk7XG4gICAgc3RhdGUuZGltID0gZGltO1xuICAgIHJldHVybiBzdGF0ZTtcbiAgfVxuXG4gIGJydXNoLmV4dGVudCA9IGZ1bmN0aW9uKF8pIHtcbiAgICByZXR1cm4gYXJndW1lbnRzLmxlbmd0aCA/IChleHRlbnQgPSB0eXBlb2YgXyA9PT0gXCJmdW5jdGlvblwiID8gXyA6IGNvbnN0YW50KFtbK19bMF1bMF0sICtfWzBdWzFdXSwgWytfWzFdWzBdLCArX1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AwO1xuXG4gICAgZm9yIChpID0gMDsgaSA8IG47ICsraSkge1xuICAgICAgbm9kZSA9IG5vZGVzW2ldLCBzeCArPSBub2RlLngsIHN5ICs9IG5vZGUueTtcbiAgICB9XG5cbiAgICBmb3IgKHN4ID0gc3ggLyBuIC0geCwgc3kgPSBzeSAvIG4gLSB5LCBpID0gMDsgaSA8IG47ICsraSkge1xuICAgICAgbm9kZSA9IG5vZGVzW2ldLCBub2RlLnggLT0gc3gsIG5vZGUueSAtPSBzeTtcbiAgICB9XG4gIH1cblxuICBmb3JjZS5pbml0aWFsaXplID0gZnVuY3Rpb24oXykge1xuICAgIG5vZGVzID0gXztcbiAgfTtcblxuICBmb3JjZS54ID0gZnVuY3Rpb24oXykge1xuICAgIHJldHVybiBhcmd1bWVudHMubGVuZ3RoID8gKHggPSArXywgZm9yY2UpIDogeDtcbiAgfTtcblxuICBmb3JjZS55ID0gZnVuY3Rpb24oXykge1xuICAgIHJldHVybiBhcmd1bWVudHMubGVuZ3RoID8gKHkgPSArXywgZm9yY2UpIDogeTtcbiAgfTtcblxuICByZXR1cm4gZm9yY2U7XG59O1xuXG52YXIgY29uc3RhbnQgPSBmdW5jdGlvbih4KSB7XG4gIHJldHVybiBmdW5jdGlvbigpIHtcbiAgICByZXR1cm4geDtcbiAgfTtcbn07XG5cbnZhciBqaWdnbGUgPSBmdW5jdGlvbigpIHtcbiAgcmV0dXJuIChNYXRoLnJhbmRvbSgpIC0gMC41KSAqIDFlLTY7XG59O1xuXG5mdW5jdGlvbiB4KGQpIHtcbiAgcmV0dXJuIGQueCArIGQudng7XG59XG5cbmZ1bmN0aW9uIHkoZCkge1xuICByZXR1cm4gZC55ICsgZC52eTtcbn1cblxudmFyIGNvbGxpZGUgPSBmdW5jdGlvbihyYWRpdXMpIHtcbiAgdmFyIG5vZGVzLFxuICAgICAgcmFkaWksXG4gICAgICBzdHJlbmd0aCA9IDEsXG4gICAgICBpdGVyYXRpb25zID0gMTtcblxuICBpZiAodHlwZW9mIHJhZGl1cyAhPT0gXCJmdW5jdGlvblwiKSByYWRpdXMgPSBjb25zdGFudChyYWRpdXMgPT0gbnVsbCA/IDEgOiArcmFkaXVzKTtcblxuICBmdW5jdGlvbiBmb3JjZSgpIHtcbiAgICB2YXIgaSwgbiA9IG5vZGVzLmxlbmd0aCxcbiAgICAgICAgdHJlZSxcbiAgICAgICAgbm9kZSxcbiAgICAgICAgeGksXG4gICAgICAgIHlpLFxuICAgICAgICByaSxcbiAgICAgICAgcmkyO1xuXG4gICAgZm9yICh2YXIgayA9IDA7IGsgPCBpdGVyYXRpb25zOyArK2spIHtcbiAgICAgIHRyZWUgPSBkM1F1YWR0cmVlLnF1YWR0cmVlKG5vZGVzLCB4LCB5KS52aXNpdEFmdGVyKHByZXBhcmUpO1xuICAgICAgZm9yIChpID0gMDsgaSA8IG47ICsraSkge1xuICAgICAgICBub2RlID0gbm9kZXNbaV07XG4gICAgICAgIHJpID0gcmFkaWlbbm9kZS5pbmRleF0sIHJpMiA9IHJpICogcmk7XG4gICAgICAgIHhpID0gbm9kZS54ICsgbm9kZS52eDtcbiAgICAgICAgeWkgPSBub2RlLnkgKyBub2RlLnZ5O1xuICAgICAgICB0cmVlLnZpc2l0KGFwcGx5KTtcbiAgICAgIH1cbiAgICB9XG5cbiAgICBmdW5jdGlvbiBhcHBseShxdWFkLCB4MCwgeTAsIHgxLCB5MSkge1xuICAgICAgdmFyIGRhdGEgPSBxdWFkLmRhdGEsIHJqID0gcXVhZC5yLCByID0gcmkgKyByajtcbiAgICAgIGlmIChkYXRhKSB7XG4gICAgICAgIGlmIChkYXRhLmluZGV4ID4gbm9kZS5pbmRleCkge1xuICAgICAgICAgIHZhciB4ID0geGkgLSBkYXRhLnggLSBkYXRhLnZ4LFxuICAgICAgICAgICAgICB5ID0geWkgLSBkYXRhLnkgLSBkYXRhLnZ5LFxuICAgICAgICAgICAgICBsID0geCAqIHggKyB5ICogeTtcbiAgICAgICAgICBpZiAobCA8IHIgKiByKSB7XG4gICAgICAgICAgICBpZiAoeCA9PT0gMCkgeCA9IGppZ2dsZSgpLCBsICs9IHggKiB4O1xuICAgICAgICAgICAgaWYgKHkgPT09IDApIHkgPSBqaWdnbGUoKSwgbCArPSB5ICogeTtcbiAgICAgICAgICAgIGwgPSAociAtIChsID0gTWF0aC5zcXJ0KGwpKSkgLyBsICogc3RyZW5ndGg7XG4gICAgICAgICAgICBub2RlLnZ4ICs9ICh4ICo9IGwpICogKHIgPSAocmogKj0gcmopIC8gKHJpMiArIHJqKSk7XG4gICAgICAgICAgICBub2RlLnZ5ICs9ICh5ICo9IGwpICogcjtcbiAgICAgICAgICAgIGRhdGEudnggLT0geCAqIChyID0gMSAtIHIpO1xuICAgICAgICAgICAgZGF0YS52eSAtPSB5ICogcjtcbiAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgICAgcmV0dXJuO1xuICAgICAgfVxuICAgICAgcmV0dXJuIHgwID4geGkgKyByIHx8IHgxIDwgeGkgLSByIHx8IHkwID4geWkgKyByIHx8IHkxIDwgeWkgLSByO1xuICAgIH1cbiAgfVxuXG4gIGZ1bmN0aW9uIHByZXBhcmUocXVhZCkge1xuICAgIGlmIChxdWFkLmRhdGEpIHJldHVybiBxdWFkLnIgPSByYWRpaVtxdWFkLmRhdGEuaW5kZXhdO1xuICAgIGZvciAodmFyIGkgPSBxdWFkLnIgPSAwOyBpIDwgNDsgKytpKSB7XG4gICAgICBpZiAocXVhZFtpXSAmJiBxdWFkW2ldLnIgPiBxdWFkLnIpIHtcbiAgICAgICAgcXVhZC5yID0gcXVhZFtpXS5yO1xuICAgICAgfVxuICAgIH1cbiAgfVxuXG4gIGZ1bmN0aW9uIGluaXRpYWxpemUoKSB7XG4gICAgaWYgKCFub2RlcykgcmV0dXJuO1xuICAgIHZhciBpLCBuID0gbm9kZXMubGVuZ3RoLCBub2RlO1xuICAgIHJhZGlpID0gbmV3IEFycmF5KG4pO1xuICAgIGZvciAoaSA9IDA7IGkgPCBuOyArK2kpIG5vZ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AgICAgIHRhcmdldC52eSAtPSB5ICogYjtcbiAgICAgICAgc291cmNlLnZ4ICs9IHggKiAoYiA9IDEgLSBiKTtcbiAgICAgICAgc291cmNlLnZ5ICs9IHkgKiBiO1xuICAgICAgfVxuICAgIH1cbiAgfVxuXG4gIGZ1bmN0aW9uIGluaXRpYWxpemUoKSB7XG4gICAgaWYgKCFub2RlcykgcmV0dXJuO1xuXG4gICAgdmFyIGksXG4gICAgICAgIG4gPSBub2Rlcy5sZW5ndGgsXG4gICAgICAgIG0gPSBsaW5rcy5sZW5ndGgsXG4gICAgICAgIG5vZGVCeUlkID0gZDNDb2xsZWN0aW9uLm1hcChub2RlcywgaWQpLFxuICAgICAgICBsaW5rO1xuXG4gICAgZm9yIChpID0gMCwgY291bnQgPSBuZXcgQXJyYXkobik7IGkgPCBtOyArK2kpIHtcbiAgICAgIGxpbmsgPSBsaW5rc1tpXSwgbGluay5pbmRleCA9IGk7XG4gICAgICBpZiAodHlwZW9mIGxpbmsuc291cmNlICE9PSBcIm9iamVjdFwiKSBsaW5rLnNvdXJjZSA9IGZpbmQobm9kZUJ5SWQsIGxpbmsuc291cmNlKTtcbiAgICAgIGlmICh0eXBlb2YgbGluay50YXJnZXQgIT09IFwib2JqZWN0XCIpIGxpbmsudGFyZ2V0ID0gZmluZChub2RlQnlJZCwgbGluay50YXJnZXQpO1xuICAgICAgY291bnRbbGluay5zb3VyY2UuaW5kZXhdID0gKGNvdW50W2xpbmsuc291cmNlLmluZGV4XSB8fCAwKSArIDE7XG4gICAgICBjb3VudFtsaW5rLnRhcmdldC5pbmRleF0gPSAoY291bnRbbGluay50YXJnZXQuaW5kZXhdIHx8IDApICsgMTtcbiAgICB9XG5cbiAgICBmb3IgKGkgPSAwLCBiaWFzID0gbmV3IEFycmF5KG0pOyBpIDwgbTsgKytpKSB7XG4gICAgICBsaW5rID0gbGlua3NbaV0sIGJpYXNbaV0gPSBjb3VudFtsaW5rLnNvdXJjZS5pbmRleF0gLyAoY291bnRbbG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Muc2V0KG5hbWUsIGluaXRpYWxpemVGb3JjZShfKSkpLCBzaW11bGF0aW9uKSA6IGZvcmNlcy5nZXQobmFtZSk7XG4gICAgfSxcblxuICAgIGZpbmQ6IGZ1bmN0aW9uKHgsIHksIHJhZGl1cykge1xuICAgICAgdmFyIGkgPSAwLFxuICAgICAgICAgIG4gPSBub2Rlcy5sZW5ndGgsXG4gICAgICAgICAgZHgsXG4gICAgICAgICAgZHksXG4gICAgICAgICAgZDIsXG4gICAgICAgICAgbm9kZSxcbiAgICAgICAgICBjbG9zZXN0O1xuXG4gICAgICBpZiAocmFkaXVzID09IG51bGwpIHJhZGl1cyA9IEluZmluaXR5O1xuICAgICAgZWxzZSByYWRpdXMgKj0gcmFkaXVzO1xuXG4gICAgICBmb3IgKGkgPSAwOyBpIDwgbjsgKytpKSB7XG4gICAgICAgIG5vZGUgPSBub2Rlc1tpXTtcbiAgICAgICAgZHggPSB4IC0gbm9kZS54O1xuICAgICAgICBkeSA9IHkgLSBub2RlLnk7XG4gICAgICAgIGQyID0gZHggKiBkeCArIGR5ICogZHk7XG4gICAgICAgIGlmIChkMiA8IHJhZGl1cykgY2xvc2VzdCA9IG5vZGUsIHJhZGl1cyA9IGQyO1xuICAgICAgfVxuXG4gICAgICByZXR1cm4gY2xvc2VzdDtcbiAgICB9LFxuXG4gICAgb246IGZ1bmN0aW9uKG5hbWUsIF8pIHtcbiAgICAgIHJldHVybiBhcmd1bWVudHMubGVuZ3RoID4gMSA/IChldmVudC5vbihuYW1lLCBfKSwgc2ltdWxhdGlvbikgOiBldmVudC5vbihuYW1lKTtcbiAgICB9XG4gIH07XG59O1xuXG52YXIgbWFueUJvZHkgPSBmdW5jdGlvbigpIHtcbiAgdmFyIG5vZGVzLFxuICAgICAgbm9kZSxcbiAgICAgIGFscGhhLFxuICAgICAgc3RyZW5ndGggPSBjb25zdGFudCgtMzApLFxuICAgICAgc3RyZW5ndGhzLFxuICAgICAgZGlzdGFuY2VNaW4yID0gMSxcbiAg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bmN0aW9uKCkge1xuICAgICAgICBzaW5rLnBvbHlnb25TdGFydCgpO1xuICAgICAgICBzaW5rLmxpbmVTdGFydCgpO1xuICAgICAgICBpbnRlcnBvbGF0ZShudWxsLCBudWxsLCAxLCBzaW5rKTtcbiAgICAgICAgc2luay5saW5lRW5kKCk7XG4gICAgICAgIHNpbmsucG9seWdvbkVuZCgpO1xuICAgICAgfVxuICAgIH07XG5cbiAgICBmdW5jdGlvbiBwb2ludChsYW1iZGEsIHBoaSkge1xuICAgICAgaWYgKHBvaW50VmlzaWJsZShsYW1iZGEsIHBoaSkpIHNpbmsucG9pbnQobGFtYmRhLCBwaGkpO1xuICAgIH1cblxuICAgIGZ1bmN0aW9uIHBvaW50TGluZShsYW1iZGEsIHBoaSkge1xuICAgICAgbGluZS5wb2ludChsYW1iZGEsIHBoaSk7XG4gICAgfVxuXG4gICAgZnVuY3Rpb24gbGluZVN0YXJ0KCkge1xuICAgICAgY2xpcC5wb2ludCA9IHBvaW50TGluZTtcbiAgICAgIGxpbmUubGluZVN0YXJ0KCk7XG4gICAgfVxuXG4gICAgZnVuY3Rpb24gbGluZUVuZCgpIHtcbiAgICAgIGNsaXAucG9pbnQgPSBwb2ludDtcbiAgICAgIGxpbmUubGluZUVuZCgpO1xuICAgIH1cblxuICAgIGZ1bmN0aW9uIHBvaW50UmluZyhsYW1iZGEsIHBoaSkge1xuICAgICAgcmluZy5wdXNoKFtsYW1iZGEsIHBoaV0pO1xuICAgICAgcmluZ1NpbmsucG9pbnQobGFtYmRhLCBwaGkpO1xuICAgIH1cblxuICAgIGZ1bmN0aW9uIHJpbmdTdGFydCgpIHtcbiAgICAgIHJpbmdTaW5rLmxpbmVTdGFydCgpO1xuICAgICAgcmluZyA9IFtdO1xuICAgIH1cblxuICAgIGZ1bmN0aW9uIHJpbmdFbmQoKSB7XG4gICAgICBwb2ludFJpbmcocmluZ1swXVswXSwgcmluZ1swXVsxXSk7XG4gICAgICByaW5nU2luay5saW5lRW5kKCk7XG5cbiAgICAgIHZhciBjbGVhbiA9IHJpbmdTaW5rLmNsZWFuKCksXG4gICAgICAgICAgcmluZ1NlZ21lbnRzID0gcmluZ0J1ZmZlci5yZXN1bHQoKSxcbiAgICAgICAgICBpLCBuID0gcmluZ1NlZ21lbnRzLmxlbmd0aCwgbSxcbiAgICAgICAgICBzZWdtZW50LFxuICAgICAgICAgIHBvaW50O1xuXG4gICAgICByaW5nLnBvcCgpO1xuICAgICAgcG9seWdvbi5wdXNoKHJpbmcpO1xuICAgICAgcmluZyA9IG51bGw7XG5cbiAgICAgIGlmICghbikgcmV0dXJuO1xuXG4gICAgICAvLyBObyBpbnRlcnNlY3Rpb25zLlxuICAgICAgaWYgKGNsZWFuICYgMSkge1xuICAgICAgICBzZWdtZW50ID0gcmluZ1NlZ21lbnRzWzBdO1xuICAgICAgICBpZiAoKG0gPSBzZWdtZW50Lmxlbmd0aCAtIDEpID4gMCkge1xuICAgICAgICAgIGlmICghcG9seWdvblN0YXJ0ZWQpIHNpbmsucG9seWdvblN0YXJ0KCksIHBvbHlnb25TdGFydGVkID0gdHJ1ZTtcbiAgICAgICAgICBzaW5rLmxpbmVTdGFydCgpO1xuICAgICAgICAgIGZvciAoaSA9IDA7IGkgPCBtOyArK2kpIHNpbmsucG9pbnQoKHBvaW50ID0gc2VnbWVudFtpXSlbMF0sIHBvaW50WzFdKTtcbiAgICAgICAgICBzaW5rLmxpbmVFbmQoKTtcbiAgICAgICAgfVxuICAgICAgICByZXR1cm47XG4gICAgICB9XG5cbiAgICAgIC8vIFJlam9pbiBjb25uZWN0ZWQgc2VnbWVudHMuXG4gICAgICAvLyBUT0RPIHJldXNlIHJpbmdCdWZmZXIucmVqb2luKCk/XG4gICAgICBpZiAobiA+IDEgJiYgY2xlYW4gJiAyKSByaW5nU2VnbWVudHMucHVzaChyaW5nU2VnbWVudHMucG9wKCkuY29uY2F0KHJpbmdTZWdtZW50cy5zaGlmdCgpKSk7XG5cbiAgICAgIHNlZ21lbnRzLnB1c2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vaW50MCwgcG9pbnQyKSB8fCBwb2ludEVxdWFsKHBvaW50MSwgcG9pbnQyKSkge1xuICAgICAgICAgICAgcG9pbnQxWzBdICs9IGVwc2lsb247XG4gICAgICAgICAgICBwb2ludDFbMV0gKz0gZXBzaWxvbjtcbiAgICAgICAgICAgIHYgPSB2aXNpYmxlKHBvaW50MVswXSwgcG9pbnQxWzFdKTtcbiAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgICAgaWYgKHYgIT09IHYwKSB7XG4gICAgICAgICAgY2xlYW4gPSAwO1xuICAgICAgICAgIGlmICh2KSB7XG4gICAgICAgICAgICAvLyBvdXRzaWRlIGdvaW5nIGluXG4gICAgICAgICAgICBzdHJlYW0ubGluZVN0YXJ0KCk7XG4gICAgICAgICAgICBwb2ludDIgPSBpbnRlcnNlY3QocG9pbnQxLCBwb2ludDApO1xuICAgICAgICAgICAgc3RyZWFtLnBvaW50KHBvaW50MlswXSwgcG9pbnQyWzFdKTtcbiAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgLy8gaW5zaWRlIGdvaW5nIG91dFxuICAgICAgICAgICAgcG9pbnQyID0gaW50ZXJzZWN0KHBvaW50MCwgcG9pbnQxKTtcbiAgICAgICAgICAgIHN0cmVhbS5wb2ludChwb2ludDJbMF0sIHBvaW50MlsxXSk7XG4gICAgICAgICAgICBzdHJlYW0ubGluZUVuZCgpO1xuICAgICAgICAgIH1cbiAgICAgICAgICBwb2ludDAgPSBwb2ludDI7XG4gICAgICAgIH0gZWxzZSBpZiAobm90SGVtaXNwaGVyZSAmJiBwb2ludDAgJiYgc21hbGxSYWRpdXMgXiB2KSB7XG4gICAgICAgICAgdmFyIHQ7XG4gICAgICAgICAgLy8gSWYgdGhlIGNvZGVzIGZvciB0d28gcG9pbnRzIGFyZSBkaWZmZXJlbnQsIG9yIGFyZSBib3RoIHplcm8sXG4gICAgICAgICAgLy8gYW5kIHRoZXJlIHRoaXMgc2VnbWVudCBpbnRlcnNlY3RzIHdpdGggdGhlIHNtYWxsIGNpcmNsZS5cbiAgICAgICAgICBpZiAoIShjICYgYzApICYmICh0ID0gaW50ZXJzZWN0KHBvaW50MSwgcG9pbnQwLCB0cnVlKSkpIHtcbiAgICAgICAgICAgIGNsZWFuID0gMDtcbiAgICAgICAgICAgIGlmIChzbWFsbFJhZGl1cykge1xuICAgICAgICAgICAgICBzdHJlYW0ubGluZVN0YXJ0KCk7XG4gICAgICAgICAgICAgIHN0cmVhbS5wb2ludCh0WzBdWzBdLCB0WzBdWzFdKTtcbiAgICAgICAgICAgICAgc3RyZWFtLnBvaW50KHRbMV1bMF0sIHRbMV1bMV0pO1xuICAgICAgICAgICAgICBzdHJlYW0ubGluZUVuZCgpO1xuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgc3RyZWFtLnBvaW50KHRbMV1bMF0sIHRbMV1bMV0pO1xuICAgICAgICAgICAgICBzdHJlYW0ubGluZUVuZCgpO1xuICAgICAgICAgICAgICBzdHJlYW0ubGluZVN0YXJ0KCk7XG4gICAgICAgICAgICAgIHN0cmVhbS5wb2ludCh0WzBdWzBdLCB0WzBdWzFdKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgICAgaWYgKHYgJiYgKCFwb2ludDAgfHwgIXBvaW50RXF1YWwocG9pbnQwLCBwb2ludDEpKSkge1xuICAgICAgICAgIHN0cmVhbS5wb2ludChwb2ludDFbMF0sIHBvaW50MVsxXSk7XG4gICAgICAgIH1cbiAgICAgICAgcG9pbnQwID0gcG9pbnQxLCB2MCA9IHYsIGMwID0gYztcbiAgICAgIH0sXG4gICAgICBsaW5lRW5kOiBmdW5jdGlvbigpIHtcbiAgICAgICAgaWYgKHYwKSBzdHJlYW0ubGluZUVuZCgpO1xuICAgICAgICBwb2ludDAgPSBudWxsO1xuICAgICAgfSxcbiAgICAgIC8vIFJlam9pbiBmaXJzdCBhbmQgbGFzdCBzZWdtZW50cyBpZiB0aGVyZSB3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gICAgIGlmIChzaGlmdCA+IDApIHtcbiAgICAgICAgICBtb3ZlU3VidHJlZShuZXh0QW5jZXN0b3IodmltLCB2LCBhbmNlc3RvciksIHYsIHNoaWZ0KTtcbiAgICAgICAgICBzaXAgKz0gc2hpZnQ7XG4gICAgICAgICAgc29wICs9IHNoaWZ0O1xuICAgICAgICB9XG4gICAgICAgIHNpbSArPSB2aW0ubTtcbiAgICAgICAgc2lwICs9IHZpcC5tO1xuICAgICAgICBzb20gKz0gdm9tLm07XG4gICAgICAgIHNvcCArPSB2b3AubTtcbiAgICAgIH1cbiAgICAgIGlmICh2aW0gJiYgIW5leHRSaWdodCh2b3ApKSB7XG4gICAgICAgIHZvcC50ID0gdmltO1xuICAgICAgICB2b3AubSArPSBzaW0gLSBzb3A7XG4gICAgICB9XG4gICAgICBpZiAodmlwICYmICFuZXh0TGVmdCh2b20pKSB7XG4gICAgICAgIHZvbS50ID0gdmlwO1xuICAgICAgICB2b20ubSArPSBzaXAgLSBzb207XG4gICAgICAgIGFuY2VzdG9yID0gdjtcbiAgICAgIH1cbiAgICB9XG4gICAgcmV0dXJuIGFuY2VzdG9yO1xuICB9XG5cbiAgZnVuY3Rpb24gc2l6ZU5vZGUobm9kZSkge1xuICAgIG5vZGUueCAqPSBkeDtcbiAgICBub2RlLnkgPSBub2RlLmRlcHRoICogZHk7XG4gIH1cblxuICB0cmVlLnNlcGFyYXRpb24gPSBmdW5jdGlvbih4KSB7XG4gICAgcmV0dXJuIGFyZ3VtZW50cy5sZW5ndGggPyAoc2VwYXJhdGlvbiA9IHgsIHRyZWUpIDogc2VwYXJhdGlvbjtcbiAgfTtcblxuICB0cmVlLnNpemUgPSBmdW5jdGlvbih4KSB7XG4gICAgcmV0dXJuIGFyZ3VtZW50cy5sZW5ndGggPyAobm9kZVNpemUgPSBmYWxzZSwgZHggPSAreFswXSwgZHkgPSAreFsxXSwgdHJlZSkgOiAobm9kZVNpemUgPyBudWxsIDogW2R4LCBkeV0pO1xuICB9O1xu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XkxLCB3MV1cbnZhciB6b29tID0gZnVuY3Rpb24ocDAsIHAxKSB7XG4gIHZhciB1eDAgPSBwMFswXSwgdXkwID0gcDBbMV0sIHcwID0gcDBbMl0sXG4gICAgICB1eDEgPSBwMVswXSwgdXkxID0gcDFbMV0sIHcxID0gcDFbMl0sXG4gICAgICBkeCA9IHV4MSAtIHV4MCxcbiAgICAgIGR5ID0gdXkxIC0gdXkwLFxuICAgICAgZDIgPSBkeCAqIGR4ICsgZHkgKiBkeSxcbiAgICAgIGksXG4gICAgICBTO1xuXG4gIC8vIFNwZWNpYWwgY2FzZSBmb3IgdTAg4omFIHUxLlxuICBpZiAoZDIgPCBlcHNpbG9uMikge1xuICAgIFMgPSBNYXRoLmxvZyh3MSAvIHcwKSAvIHJobztcbiAgICBpID0gZnVuY3Rpb24odCkge1xuICAgICAgcmV0dXJuIFtcbiAgICAgICAgdXgwICsgdCAqIGR4LFxuICAgICAgICB1eTAgKyB0ICogZHksXG4gICAgICAgIHcwICogTWF0aC5leHAocmhvICogdCAqIFMpXG4gICAgICBdO1xuICAgIH07XG4gIH1cblxuICAvLyBHZW5lcmFsIGNhc2UuXG4gIGVsc2Uge1xuICAgIHZhciBkMSA9IE1hdGguc3FydChkMiksXG4gICAgICAgIGIwID0gKHcxICogdzEgLSB3MCAqIHcwICsgcmhvNCAqIGQyKSAvICgyICogdzAgKiByaG8yICogZDEpLFxuICAgICAgICBiMSA9ICh3MSAqIHcxIC0gdzAgKiB3MCAtIHJobzQgKiBkMikgLyAoMiAqIHcxICogcmhvMiAqIGQxKSxcbiAgICAgICAgcjAgPSBNYXRoLmxvZyhNYXRoLnNxcnQoYjAgKiBiMCArIDEpIC0gYjApLFxuICAgICAgICByMSA9IE1hdGgubG9nKE1hdGguc3FydChiMSAqIGIxICsgMSkgLSBiMSk7XG4gICAgUyA9IChyMSAtIHIwKSAvIHJobztcbiAgICBpID0gZnVuY3Rpb24odCkge1xuICAgICAgdmFyIHMgPSB0ICogUyxcbiAgICA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VudCkge1xuICAgIHZhciBkID0gZG9tYWluKCksXG4gICAgICAgIHUgPSBkWzBdLFxuICAgICAgICB2ID0gZFtkLmxlbmd0aCAtIDFdLFxuICAgICAgICByO1xuXG4gICAgaWYgKHIgPSB2IDwgdSkgaSA9IHUsIHUgPSB2LCB2ID0gaTtcblxuICAgIHZhciBpID0gbG9ncyh1KSxcbiAgICAgICAgaiA9IGxvZ3ModiksXG4gICAgICAgIHAsXG4gICAgICAgIGssXG4gICAgICAgIHQsXG4gICAgICAgIG4gPSBjb3VudCA9PSBudWxsID8gMTAgOiArY291bnQsXG4gICAgICAgIHogPSBbXTtcblxuICAgIGlmICghKGJhc2UgJSAxKSAmJiBqIC0gaSA8IG4pIHtcbiAgICAgIGkgPSBNYXRoLnJvdW5kKGkpIC0gMSwgaiA9IE1hdGgucm91bmQoaikgKyAxO1xuICAgICAgaWYgKHUgPiAwKSBmb3IgKDsgaSA8IGo7ICsraSkge1xuICAgICAgICBmb3IgKGsgPSAxLCBwID0gcG93cyhpKTsgayA8IGJhc2U7ICsraykge1xuICAgICAgICAgIHQgPSBwICogaztcbiAgICAgICAgICBpZiAodCA8IHUpIGNvbnRpbnVlO1xuICAgICAgICAgIGlmICh0ID4gdikgYnJlYWs7XG4gICAgICAgICAgei5wdXNoKHQpO1xuICAgICAgICB9XG4gICAgICB9IGVsc2UgZm9yICg7IGkgPCBqOyArK2kpIHtcbiAgICAgICAgZm9yIChrID0gYmFzZSAtIDEsIHAgPSBwb3dzKGkpOyBrID49IDE7IC0taykge1xuICAgICAgICAgIHQgPSBwICogaztcbiAgICAgICAgICBpZiAodCA8IHUpIGNvbnRpbnVlO1xuICAgICAgICAgIGlmICh0ID4gdikgYnJlYWs7XG4gICAgICAgICAgei5wdXNoKHQpO1xuICAgICAgICB9XG4gICAgICB9XG4gICAgfSBlbHNlIHtcbiAgICAgIHogPSBkM0FycmF5LnRpY2tzKGksIGosIE1hdGgubWluKGogLSBpLCBuKSkubWFwKHBvd3MpO1xuICA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GhlIGlubmVyIHJhZGl1cy5cbiAgICBpZiAocjEgPCByMCkgciA9IHIxLCByMSA9IHIwLCByMCA9IHI7XG5cbiAgICAvLyBJcyBpdCBhIHBvaW50P1xuICAgIGlmICghKHIxID4gZXBzaWxvbikpIGNvbnRleHQubW92ZVRvKDAsIDApO1xuXG4gICAgLy8gT3IgaXMgaXQgYSBjaXJjbGUgb3IgYW5udWx1cz9cbiAgICBlbHNlIGlmIChkYSA+IHRhdSAtIGVwc2lsb24pIHtcbiAgICAgIGNvbnRleHQubW92ZVRvKHIxICogY29zKGEwKSwgcjEgKiBzaW4oYTApKTtcbiAgICAgIGNvbnRleHQuYXJjKDAsIDAsIHIxLCBhMCwgYTEsICFjdyk7XG4gICAgICBpZiAocjAgPiBlcHNpbG9uKSB7XG4gICAgICAgIGNvbnRleHQubW92ZVRvKHIwICogY29zKGExKSwgcjAgKiBzaW4oYTEpKTtcbiAgICAgICAgY29udGV4dC5hcmMoMCwgMCwgcjAsIGExLCBhMCwgY3cpO1xuICAgICAgfVxuICAgIH1cblxuICAgIC8vIE9yIGlzIGl0IGEgY2lyY3VsYXIgb3IgYW5udWxhciBzZWN0b3I/XG4gICAgZWxzZSB7XG4gICAgICB2YXIgYTAxID0gYTAsXG4gICAgICAgICAgYTExID0gYTEsXG4gICAgICAgICAgYTAwID0gYTAsXG4gICAgICAgICAgYTEwID0gYTEsXG4gICAgICAgICAgZGEwID0gZGEsXG4gICAgICAgICAgZGExID0gZGEsXG4gICAgICAgICAgYXAgPSBwYWRBbmdsZS5hcHBseSh0aGlzLCBhcmd1bWVudHMpIC8gMixcbiAgICAgICAgICBycCA9IChhcCA+IGVwc2lsb24pICYmIChwYWRSYWRpdXMgPyArcGFkUmFkaXVzLmFwcGx5KHRoaXMsIGFyZ3VtZW50cykgOiBzcXJ0KHIwICogcjAgKyByMSAqIHIxKSksXG4gICAgICAgICAgcmMgPSBtaW4oYWJzKHIxIC0gcjApIC8gMiwgK2Nvcm5lclJhZGl1cy5hcHBseSh0aGlzLCBhcmd1bWVudHMpKSxcbiAgICAgICAgICByYzAgPSByYyxcbiAgICAgICAgICByYzEgPSByYyxcbiAgICAgICAgICB0MCxcbiAgICAgICAgICB0MTtcblxuICAgICAgLy8gQXBwbHkgcGFkZGluZz8gTm90ZSB0aGF0IHNpbmNlIHIxIOKJpSByMCwgZGExIOKJpSBkYTAuXG4gICAgICBpZiAocnAgPiBlcHNpbG9uKSB7XG4gICAgICAgIHZhciBwMCA9IGFzaW4ocnAgLyByMCAqIHNpbihhcCkpLFxuICAgICAgICAgICAgcDEgPSBhc2luKHJwIC8gcjEgKiBzaW4oYXApKTtcbiAgICAgICAgaWYgKChkYTAgLT0gcDAgKiAyKSA+IGVwc2lsb24pIHAwICo9IChjdyA/IDEgOiAtMSksIGEwMCArPSBwMCwgYTEwIC09IHAwO1xuICAgICAgICBlbHNlIGRhMCA9IDAsIGEwMCA9IGExMCA9IChhMCArIGExKSAvIDI7XG4gICAgICAgIGlmICgoZGExIC09IHAxICogMikgPiBlcHNpbG9uKSBwMSAqPSAoY3cgPyAxIDogLTEpLCBhMDEgKz0gcDEsIGExMSAtPSBwMTtcbiAgICAgICAgZWxzZSBkYTEgPSAwLCBhMDEgPSBhMTEgPSAoYTAgKyBhMSkgLyAyO1xuICAgICAgfVxuXG4gICAgICB2YXIgeDAxID0gcjEgKiBjb3MoYTAxKSxcbiAgICAgICAgICB5MDEgPSByMSAqIHNpbihhMDEpLFxuICAgICAgICAgIHgxMCA9IHIwICogY29zKGExMCksXG4gICAgICAgICAgeTEwID0gcjAgKiBzaW4oYTEwKTtcblxuICAgICAgLy8gQXBwbHkgcm91bmRlZCBjb3JuZXJzP1xuICAgICAgaWYgKHJjID4gZXBzaWxvbikge1xuICAgICAgICB2YXIgeDExID0gcjEgKiBjb3MoYTExKSxcbiAgICAgICAgICAgIHkxMSA9IHIxICogc2luKGExMSksXG4gICAgICAgICAgICB4MDAgPSByMCAqIGNvcyhhMDApLFxuICAgICAgICAgICAgeT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mVUbyhyLCAtcik7XG4gICAgY29udGV4dC5saW5lVG8oMyAqIHIsIC1yKTtcbiAgICBjb250ZXh0LmxpbmVUbygzICogciwgcik7XG4gICAgY29udGV4dC5saW5lVG8ociwgcik7XG4gICAgY29udGV4dC5saW5lVG8ociwgMyAqIHIpO1xuICAgIGNvbnRleHQubGluZVRvKC1yLCAzICogcik7XG4gICAgY29udGV4dC5saW5lVG8oLXIsIHIpO1xuICAgIGNvbnRleHQubGluZVRvKC0zICogciwgcik7XG4gICAgY29udGV4dC5jbG9zZVBhdGgoKTtcbiAgfVxufTtcblxudmFyIHRhbjMwID0gTWF0aC5zcXJ0KDEgLyAzKTtcbnZhciB0YW4zMF8yID0gdGFuMzAgKiAyO1xuXG52YXIgZGlhbW9uZCA9IHtcbiAgZHJhdzogZnVuY3Rpb24oY29udGV4dCwgc2l6ZSkge1xuICAgIHZhciB5ID0gTWF0aC5zcXJ0KHNpemUgLyB0YW4zMF8yKSxcbiAgICAgICAgeCA9IHkgKiB0YW4zMDtcbiAgICBjb250ZXh0Lm1vdmVUbygwLCAteSk7XG4gICAgY29udGV4dC5saW5lVG8oeCwgMCk7XG4gICAgY29udGV4dC5saW5lVG8oMCwgeSk7XG4gICAgY29udGV4dC5saW5lVG8oLXgsIDApO1xuICAgIGNvbnRleHQuY2xvc2VQYXRoKCk7XG4gIH1cbn07XG5cbnZhciBrYSA9IDAuODkwODEzMDkxNTI5Mjg1MjI4MTA7XG52YXIga3IgPSBNYXRoLnNpbihwaSAvIDEwKSAvIE1hdGguc2luKDcgKiBwaSAvIDEwKTtcbnZhciBreCA9IE1hdGguc2luKHRhdSAvIDEwKSAqIGtyO1xudmFyIGt5ID0gLU1hdGguY29zKHRhdSAvIDEwKSAqIGtyO1xuXG52YXIgc3RhciA9IHtcbiAgZHJhdzogZnVuY3Rpb24oY29udGV4dCwgc2l6ZSkge1xuICAgIHZhciByID0gTWF0aC5zcXJ0KHNpemUgKiBrYSksXG4gICAgICAgIHggPSBreCAqIH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ge1xuICAgIHZhciBreiA9IGtleXMuYXBwbHkodGhpcywgYXJndW1lbnRzKSxcbiAgICAgICAgaSxcbiAgICAgICAgbSA9IGRhdGEubGVuZ3RoLFxuICAgICAgICBuID0ga3oubGVuZ3RoLFxuICAgICAgICBzeiA9IG5ldyBBcnJheShuKSxcbiAgICAgICAgb3o7XG5cbiAgICBmb3IgKGkgPSAwOyBpIDwgbjsgKytpKSB7XG4gICAgICBmb3IgKHZhciBraSA9IGt6W2ldLCBzaSA9IHN6W2ldID0gbmV3IEFycmF5KG0pLCBqID0gMCwgc2lqOyBqIDwgbTsgKytqKSB7XG4gICAgICAgIHNpW2pdID0gc2lqID0gWzAsICt2YWx1ZShkYXRhW2pdLCBraSwgaiwgZGF0YSldO1xuICAgICAgICBzaWouZGF0YSA9IGRhdGFbal07XG4gICAgICB9XG4gICAgICBzaS5rZXkgPSBraTtcbiAgICB9XG5cbiAgICBmb3IgKGkgPSAwLCBveiA9IG9yZGVyKHN6KTsgaSA8IG47ICsraSkge1xuICAgICAgc3pbb3pbaV1dLmluZGV4ID0gaTtcbiAgICB9XG5cbiAgICBvZmZzZXQoc3osIG96KTtcbiAgICByZXR1cm4gc3o7XG4gIH1cblxuICBzdGFjay5rZXlzID0gZnVuY3Rpb24oXykge1xuICAgIHJldHVybiBhcmd1bWVudHMubGVuZ3RoID8gKGtleXMgPSB0eXBlb2YgXyA9PT0gXCJmdW5jdGlvblwiID8gXyA6IGNvbnN0YW50KHNsaWNlLmNhbGwoXykpLCBzdGFjaykgOiBrZXlzO1xuICB9O1xuXG4gIHN0YWNrLnZhbHVlID0gZnVuY3Rpb24oXykge1xuICAgIHJldHVybiBhcmd1bWVudHMubGVuZ3RoID8gKHZhbHVlID0gdHlwZW9mIF8gPT09IFwiZnVuY3Rpb25cIiA/IF8gOiBjb25zdGFudCgrXyksIHN0YWNrKSA6IHZhbHVlO1xuICB9O1xuXG4gIHN0YWNrLm9yZGVyID0gZnVuY3Rpb24oXykge1xuICAgIHJldH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ldHVybiB7XG4gICAgICAgIHRvcDogIGJib3gubi55IC0gbm9kZS5vZmZzZXRIZWlnaHQsXG4gICAgICAgIGxlZnQ6IGJib3gubi54IC0gbm9kZS5vZmZzZXRXaWR0aCAvIDJcbiAgICAgIH1cbiAgICB9XG5cbiAgICBmdW5jdGlvbiBkaXJlY3Rpb25fcygpIHtcbiAgICAgIHZhciBiYm94ID0gZ2V0U2NyZWVuQkJveCgpXG4gICAgICByZXR1cm4ge1xuICAgICAgICB0b3A6ICBiYm94LnMueSxcbiAgICAgICAgbGVmdDogYmJveC5zLnggLSBub2RlLm9mZnNldFdpZHRoIC8gMlxuICAgICAgfVxuICAgIH1cblxuICAgIGZ1bmN0aW9uIGRpcmVjdGlvbl9lKCkge1xuICAgICAgdmFyIGJib3ggPSBnZXRTY3JlZW5CQm94KClcbiAgICAgIHJldHVybiB7XG4gICAgICAgIHRvcDogIGJib3guZS55IC0gbm9kZS5vZmZzZXRIZWlnaHQgLyAyLFxuICAgICAgICBsZWZ0OiBiYm94LmUueFxuICAgICAgfVxuICAgIH1cblxuICAgIGZ1bmN0aW9uIGRpcmVjdGlvbl93KCkge1xuICAgICAgdmFyIGJib3ggPSBnZXRTY3JlZW5CQm94KClcbiAgICAgIHJldHVybiB7XG4gICAgICAgIHRvcDogIGJib3gudy55IC0gbm9kZS5vZmZzZXRIZWlnaHQgLyAyLFxuICAgICAgICBsZWZ0OiBiYm94LncueCAtIG5vZGUub2Zmc2V0V2lkdGhcbiAgICAgIH1cbiAgICB9XG5cbiAgICBmdW5jdGlvbiBkaXJlY3Rpb25fbncoKSB7XG4gICAgICB2YXIgYmJveCA9IGdldFNjcmVlbkJCb3goKVxuICAgICAgcmV0dXJuIHtcbiAgICAgICAgdG9wOiAgYmJveC5udy55IC0gbm9kZS5vZmZzZXRIZWlnaHQsXG4gICAgICAgIGxlZnQ6IGJib3gubncueCAtIG5vZGUub2Zmc2V0V2lkdGhcbiAgICAgIH1cbiAgICB9XG5cbiAgICBmdW5jd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ZWwuZ2V0U2NyZWVuQ1RNICYmICd1bmRlZmluZWQnID09PSB0YXJnZXRlbC5wYXJlbnROb2RlKSB7XG4gICAgICAgICAgdGFyZ2V0ZWwgPSB0YXJnZXRlbC5wYXJlbnROb2RlO1xuICAgICAgfVxuXG4gICAgICB2YXIgYmJveCAgICAgICA9IHt9LFxuICAgICAgICAgIG1hdHJpeCAgICAgPSB0YXJnZXRlbC5nZXRTY3JlZW5DVE0oKSxcbiAgICAgICAgICB0YmJveCAgICAgID0gdGFyZ2V0ZWwuZ2V0QkJveCgpLFxuICAgICAgICAgIHdpZHRoICAgICAgPSB0YmJveC53aWR0aCxcbiAgICAgICAgICBoZWlnaHQgICAgID0gdGJib3guaGVpZ2h0LFxuICAgICAgICAgIHggICAgICAgICAgPSB0YmJveC54LFxuICAgICAgICAgIHkgICAgICAgICAgPSB0YmJveC55XG5cbiAgICAgIHBvaW50LnggPSB4XG4gICAgICBwb2ludC55ID0geVxuICAgICAgYmJveC5udyA9IHBvaW50Lm1hdHJpeFRyYW5zZm9ybShtYXRyaXgpXG4gICAgICBwb2ludC54ICs9IHdpZHRoXG4gICAgICBiYm94Lm5lID0gcG9pbnQubWF0cml4VHJhbnNmb3JtKG1hdHJpeClcbiAgICAgIHBvaW50LnkgKz0gaGVpZ2h0XG4gICAgICBiYm94LnNlID0gcG9pbnQubWF0cml4VHJhbnNmb3JtKG1hdHJpeClcbiAgICAgIHBvaW50LnggLT0gd2lkdGhcbiAgICAgIGJib3guc3cgPSBwb2ludC5tYXRyaXhUcmFuc2Zvcm0obWF0cml4KVxuICAgICAgcG9pbnQueSAtPSBoZWlnaHQgLyAyXG4gICAgICBiYm94LncgID0gcG9pbnQubWF0cml4VHJhbnNmb3JtKG1hdHJpeClcbiAgICAgIHBvaW50LnggKz0gd2lkdGhcbiAgICAgIGJib3guZSA9IHBvaW50Lm1hdHJpeFRyYW5zZm9ybShtYXRyaXgpXG4gICAgICBwb2ludC54IC09IHdpZHRoIC8gMlxuICAgIC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9IGxlZnQ7XG4gICAgICBsZWZ0LlUgPSBuZXh0O1xuICAgICAgaWYgKG5leHQgIT09IHJpZ2h0KSB7XG4gICAgICAgIHBhcmVudCA9IG5leHQuVTtcbiAgICAgICAgbmV4dC5VID0gbm9kZS5VO1xuICAgICAgICBub2RlID0gbmV4dC5SO1xuICAgICAgICBwYXJlbnQuTCA9IG5vZGU7XG4gICAgICAgIG5leHQuUiA9IHJpZ2h0O1xuICAgICAgICByaWdodC5VID0gbmV4dDtcbiAgICAgIH0gZWxzZSB7XG4gICAgICAgIG5leHQuVSA9IHBhcmVudDtcbiAgICAgICAgcGFyZW50ID0gbmV4dDtcbiAgICAgICAgbm9kZSA9IG5leHQuUjtcbiAgICAgIH1cbiAgICB9IGVsc2Uge1xuICAgICAgcmVkID0gbm9kZS5DO1xuICAgICAgbm9kZSA9IG5leHQ7XG4gICAgfVxuXG4gICAgaWYgKG5vZGUpIG5vZGUuVSA9IHBhcmVudDtcbiAgICBpZiAocmVkKSByZXR1cm47XG4gICAgaWYgKG5vZGUgJiYgbm9kZS5DKSB7IG5vZGUuQyA9IGZhbHNlOyByZXR1cm47IH1cblxuICAgIGRvIHtcbiAgICAgIGlmIChub2RlID09PSB0aGlzLl8pIGJyZWFrO1xuICAgICAgaWYgKG5vZGUgPT09IHBhcmVudC5MKSB7XG4gICAgICAgIHNpYmxpbmcgPSBwYXJlbnQuUjtcbiAgICAgICAgaWYgKHNpYmxpbmcuQykge1xuICAgICAgICAgIHNpYmxpbmcuQyA9IGZhbHNlO1xuICAgICAgICAgIHBhcmVudC5DID0gdHJ1ZTtcbiAgICAgICAgICBSZWRCbGFja1JvdGF0ZUxlZnQodGhpcywgcGFyZW50KTtcbiAgICAgICAgICBzaWJsaW5nID0gcGFyZW50LlI7XG4gICAgICAgIH1cbiAgICAgICAgaWYgKChzaWJsaW5nLkwgJiYgc2libGluZy5MLkMpXG4gICAgICAgICAgICB8fCAoc2libGluZy5SICYmIHNpYmxpbmcuUi5DKSkge1xuICAgICAgICAgIGlmICghc2libGluZy5SIHx8ICFzaWJsaW5nLlIuQykge1xuICAgICAgICAgICAgc2libGluZy5MLkMgPSBmYWxzZTtcbiAgICAgICAgICAgIHNpYmxpbmcuQyA9IHRydWU7XG4gICAgICAgICAgICBSZWRCbGFja1JvdGF0ZVJpZ2h0KHRoaXMsIHNpYmxpbmcpO1xuICAgICAgICAgICAgc2libGluZyA9IHBhcmVudC5SO1xuICAgICAgICAgIH1cbiAgICAgICAgICBzaWJsaW5nLkMgPSBwYXJlbnQuQztcbiAgICAgICAgICBwYXJlbnQuQyA9IHNpYmxpbmcuUi5DID0gZmFsc2U7XG4gICAgICAgICAgUmVkQmxhY2tSb3RhdGVMZWZ0KHRoaXMsIHBhcmVudCk7XG4gICAgICAgICAgbm9kZSA9IHRoaXMuXztcbiAgICAgICAgICBicmVhaztcbiAgICAgICAgfVxuICAgICAgfSBlbHNlIHtcbiAgICAgICAgc2libGluZyA9IHBhcmVudC5MO1xuICAgICAgICBpZiAoc2libGluZy5DKSB7XG4gICAgICAgICAgc2libGluZy5DID0gZmFsc2U7XG4gICAgICAgICAgcGFyZW50LkMgPSB0cnVlO1xuICAgICAgICAgIFJlZEJsYWNrUm90YXRlUmlnaHQodGhpcywgcGFyZW50KTtcbiAgICAgICAgICBzaWJsaW5nID0gcGFyZW50Lkw7XG4gICAgICAgIH1cbiAgICAgICAgaWYgKChzaWJsaW5nLkwgJiYgc2libGluZy5MLkMpXG4gICAgICAgICAgfHwgKHNpYmxpbmcuUiAmJiBzaWJsaW5nLlIuQykpIHtcbiAgICAgICAgICBpZiAoIXNpYmxpbmcuTCB8fCAhc2libGluZy5MLkMpIHtcbiAgICAgICAgICAgIHNpYmxpbmcuUi5DID0gZmFsc2U7XG4gICAgICAgICAgICBzaWJsaW5nLkMgPSB0cnVlO1xuICAgICAgICAgICAgUmVkQmxhY2tSb3RhdGVMZWZ0KHRoaXMsIHNpYmxpbmcpO1xuICAgICAgICAgICAgc2libGluZyA9IHBhc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Y29udGV4dCwgbW91bnRBbGwpO1xuICAgICAgICBpZiAocGFyZW50ICYmIHJldC5wYXJlbnROb2RlICE9PSBwYXJlbnQpIHBhcmVudC5hcHBlbmRDaGlsZChyZXQpO1xuICAgICAgICBpZiAoIS0tZGlmZkxldmVsICYmICFjb21wb25lbnRSb290KSBmbHVzaE1vdW50cygpO1xuICAgICAgICByZXR1cm4gcmV0O1xuICAgIH1cbiAgICBmdW5jdGlvbiBpZGlmZihkb20sIHZub2RlLCBjb250ZXh0LCBtb3VudEFsbCkge1xuICAgICAgICB2YXIgb3JpZ2luYWxBdHRyaWJ1dGVzID0gdm5vZGUgJiYgdm5vZGUuYXR0cmlidXRlcztcbiAgICAgICAgd2hpbGUgKGlzRnVuY3Rpb25hbENvbXBvbmVudCh2bm9kZSkpIHZub2RlID0gYnVpbGRGdW5jdGlvbmFsQ29tcG9uZW50KHZub2RlLCBjb250ZXh0KTtcbiAgICAgICAgaWYgKG51bGwgPT0gdm5vZGUpIHZub2RlID0gJyc7XG4gICAgICAgIGlmIChpc1N0cmluZyh2bm9kZSkpIHtcbiAgICAgICAgICAgIGlmIChkb20pIHtcbiAgICAgICAgICAgICAgICBpZiAoZG9tIGluc3RhbmNlb2YgVGV4dCAmJiBkb20ucGFyZW50Tm9kZSkge1xuICAgICAgICAgICAgICAgICAgICBpZiAoZG9tLm5vZGVWYWx1ZSAhPSB2bm9kZSkgZG9tLm5vZGVWYWx1ZSA9IHZub2RlO1xuICAgICAgICAgICAgICAgICAgICByZXR1cm4gZG9tO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICByZWNvbGxlY3ROb2RlVHJlZShkb20pO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgcmV0dXJuIGRvY3VtZW50LmNyZWF0ZVRleHROb2RlKHZub2RlKTtcbiAgICAgICAgfVxuICAgICAgICBpZiAoaXNGdW5jdGlvbih2bm9kZS5ub2RlTmFtZSkpIHJldHVybiBidWlsZENvbXBvbmVudEZyb21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mIHZjaGlsZHJlbi5sZW5ndGg7XG4gICAgICAgIGlmIChsZW4pIGZvciAodmFyIGkgPSAwOyBpIDwgbGVuOyBpKyspIHtcbiAgICAgICAgICAgIHZhciBfY2hpbGQgPSBvcmlnaW5hbENoaWxkcmVuW2ldLCBrZXkgPSB2bGVuID8gKGMgPSBfY2hpbGQuX2NvbXBvbmVudCkgPyBjLl9fa2V5IDogKGMgPSBfY2hpbGRbQVRUUl9LRVldKSA/IGMua2V5IDogbnVsbCA6IG51bGw7XG4gICAgICAgICAgICBpZiAoa2V5IHx8IDAgPT09IGtleSkge1xuICAgICAgICAgICAgICAgIGtleWVkTGVuKys7XG4gICAgICAgICAgICAgICAga2V5ZWRba2V5XSA9IF9jaGlsZDtcbiAgICAgICAgICAgIH0gZWxzZSBjaGlsZHJlbltjaGlsZHJlbkxlbisrXSA9IF9jaGlsZDtcbiAgICAgICAgfVxuICAgICAgICBpZiAodmxlbikgZm9yICh2YXIgaSA9IDA7IGkgPCB2bGVuOyBpKyspIHtcbiAgICAgICAgICAgIHZjaGlsZCA9IHZjaGlsZHJlbltpXTtcbiAgICAgICAgICAgIGNoaWxkID0gbnVsbDtcbiAgICAgICAgICAgIHZhciBrZXkgPSB2Y2hpbGQua2V5O1xuICAgICAgICAgICAgaWYgKG51bGwgIT0ga2V5KSB7XG4gICAgICAgICAgICAgICAgaWYgKGtleWVkTGVuICYmIGtleSBpbiBrZXllZCkge1xuICAgICAgICAgICAgICAgICAgICBjaGlsZCA9IGtleWVkW2tleV07XG4gICAgICAgICAgICAgICAgICAgIGtleWVkW2tleV0gPSB2b2lkIDA7XG4gICAgICAgICAgICAgICAgICAgIGtleWVkTGVuLS07XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSBlbHNlIGlmICghY2hpbGQgJiYgbWluIDwgY2hpbGRyZW5MZW4pIHtcbiAgICAgICAgICAgICAgICBmb3IgKGogPSBtaW47IGogPCBjaGlsZHJlbkxlbjsgaisrKSB7XG4gICAgICAgICAgICAgICAgICAgIGMgPSBjaGlsZHJlbltqXTtcbiAgICAgICAgICAgICAgICAgICAgaWYgKGMgJiYgaXNTYW1lTm9kZVR5cGUoYywgdmNoaWxkKSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgY2hpbGQgPSBjO1xuICAgICAgICAgICAgICAgICAgICAgICAgY2hpbGRyZW5bal0gPSB2b2lkIDA7XG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAoaiA9PT0gY2hpbGRyZW5MZW4gLSAxKSBjaGlsZHJlbkxlbi0tO1xuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGogPT09IG1pbikgbWluKys7XG4gICAgICAgICAgICAgICAgICAgICAgICBicmVhaztcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBpZiAoIWNoaWxkICYmIG1pbiA8IGNoaWxkcmVuTGVuICYmIGlzRnVuY3Rpb24odmNoaWxkLm5vZGVOYW1lKSAmJiBtb3VudEFsbCkge1xuICAgICAgICAgICAgICAgICAgICBjaGlsZCA9IGNoaWxkcmVuW21pbl07XG4gICAgICAgICAgICAgICAgICAgIGNoaWxkcmVuW21pbisrXSA9IHZvaWQgMDtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBjaGlsZCA9IGlkaWZmKGNoaWxkLCB2Y2hpbGQsIGNvbnRleHQsIG1vdW50QWxsKTtcbiAgICAgICAgICAgIGlmIChjaGlsZCAmJiBjaGlsZCAhPT0gZG9tICYmIGNoaWxkICE9PSBvcmlnaW5hbENoaWxkcmVuW2ldKSBkb20uaW5zZXJ0QmVmb3JlKGNoaWxkLCBvcmlnaW5hbENoaWxkcmVuW2ldIHx8IG51bGwpO1xuICAgICAgICB9XG4gICAgICAgIGlmIChrZXllZExlbikgZm9yICh2YXIgaSBpbiBrZXllZCkgaWYgKGtleWVkW2ldKSByZWNvbGxlY3ROb2RlVHJlZShrZXllZFtpXSk7XG4g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4gICAgICAgICAgICBpbnN0Lm5leHRCYXNlID0gbGlzdFtpXS5uZXh0QmFzZTtcbiAgICAgICAgICAgIGxpc3Quc3BsaWNlKGksIDEpO1xuICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgIH1cbiAgICAgICAgcmV0dXJuIGluc3Q7XG4gICAgfVxuICAgIGZ1bmN0aW9uIHNldENvbXBvbmVudFByb3BzKGNvbXBvbmVudCwgcHJvcHMsIG9wdHMsIGNvbnRleHQsIG1vdW50QWxsKSB7XG4gICAgICAgIGlmICghY29tcG9uZW50Ll9kaXNhYmxlKSB7XG4gICAgICAgICAgICBjb21wb25lbnQuX2Rpc2FibGUgPSAhMDtcbiAgICAgICAgICAgIGlmIChjb21wb25lbnQuX19yZWYgPSBwcm9wcy5yZWYpIGRlbGV0ZSBwcm9wcy5yZWY7XG4gICAgICAgICAgICBpZiAoY29tcG9uZW50Ll9fa2V5ID0gcHJvcHMua2V5KSBkZWxldGUgcHJvcHMua2V5O1xuICAgICAgICAgICAgaWYgKCFjb21wb25lbnQuYmFzZSB8fCBtb3VudEFsbCkge1xuICAgICAgICAgICAgICAgIGlmIChjb21wb25lbnQuY29tcG9uZW50V2lsbE1vdW50KSBjb21wb25lbnQuY29tcG9uZW50V2lsbE1vdW50KCk7XG4gICAgICAgICAgICB9IGVsc2UgaWYgKGNvbXBvbmVudC5jb21wb25lbnRXaWxsUmVjZWl2ZVByb3BzKSBjb21wb25lbnQuY29tcG9uZW50V2lsbFJlY2VpdmVQcm9wcyhwcm9wcywgY29udGV4dCk7XG4gICAgICAgICAgICBpZiAoY29udGV4dCAmJiBjb250ZXh0ICE9PSBjb21wb25lbnQuY29udGV4dCkge1xuICAgICAgICAgICAgICAgIGlmICghY29tcG9uZW50LnByZXZDb250ZXh0KSBjb21wb25lbnQucHJldkNvbnRleHQgPSBjb21wb25lbnQuY29udGV4dDtcbiAgICAgICAgICAgICAgICBjb21wb25lbnQuY29udGV4dCA9IGNvbnRleHQ7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBpZiAoIWNvbXBvbmVudC5wcmV2UHJvcHMpIGNvbXBvbmVudC5wcmV2UHJvcHMgPSBjb21wb25lbnQucHJvcHM7XG4gICAgICAgICAgICBjb21wb25lbnQucHJvcHMgPSBwcm9wcztcbiAgICAgICAgICAgIGNvbXBvbmVudC5fZGlzYWJsZSA9ICExO1xuICAgICAgICAgICAgaWYgKDAgIT09IG9wdHMpIGlmICgxID09PSBvcHRzIHx8IG9wdGlvbnMuc3luY0NvbXBvbmVudFVwZGF0ZXMgIT09ICExIHx8ICFjb21wb25lbnQuYmFzZSkgcmVuZGVyQ29tcG9uZW50KGNvbXBvbmVudCwgMSwgbW91bnRBbGwpOyBlbHNlIGVucXVldWVSZW5kZXIoY29tcG9uZW50KTtcbiAgICAgICAgICAgIGlmIChjb21wb25lbnQuX19yZWYpIGNvbXBvbmVudC5fX3JlZihjb21wb25lbnQpO1xuICAgICAgICB9XG4gICAgfVxuICAgIGZ1bmN0aW9uIHJlbmRlckNvbXBvbmVudChjb21wb25lbnQsIG9wdHMsIG1vdW50QWxsLCBpc0NoaWxkKSB7XG4gICAgICAgIGlmICghY29tcG9uZW50Ll9kaXNhYmxlKSB7XG4gICAgICAgICAgICB2YXIgc2tpcCwgcmVuZGVyZWQsIGluc3QsIGNiYXNlLCBwcm9wcyA9IGNvbXBvbmVudC5wcm9wcywgc3RhdGUgPSBjb21wb25lbnQuc3RhdGUsIGNvbnRleHQgPSBjb21wb25lbnQuY29udGV4dCwgcHJldmlvdXNQcm9wcyA9IGNvbXBvbmVudC5wcmV2UHJvcHMgfHwgcHJvcHMsIHByZXZpb3VzU3RhdGUgPSBjb21wb25lbnQucHJldlN0YXRlIHx8IHN0YXRlLCBwcmV2aW91c0NvbnRleHQgPSBjb21wb25lbnQucHJldkNvbnRleHQgfHwgY29udGV4dCwgaXNVcGRhdGUgPSBjb21wb25lbnQuYmFzZSwgbmV4dEJhc2UgPSBjb21wb25lbnQubmV4dEJhc2UsIGluaXRpYWxCYXNlID0gaXNVcGRhdGUgfHwgbmV4dEJhc2UsIGluaXRpYWxDaGlsZENvbXBvbmVudCA9IGNvbXBvbmVudC5fY29tcG9uZW50O1xuICAgICAgICAgICAgaWYgKGlzVXBkYXRlKSB7XG4gICAgICAgICAgICAgICAgY29tcG9uZW50LnByb3BzID0gcHJldmlvdXNQcm9wcztcbiAgICAgICAgICAgICAgICBjb21wb25lbnQuc3RhdGUgPSBwcmV2aW91c1N0YXRlO1xuICAgICAgICAgICAgICAgIGNvbXBvbmVudC5jb250ZXh0ID0gcHJldmlvdXNDb250ZXh0O1xuICAgICAgICAgICAgICAgIGlmICgyICE9PSBvcHRzICYmIGNvbXBvbmVudC5zaG91bGRDb21wb25lbnRVcGRhdGUgJiYgY29tcG9uZW50LnNob3VsZENvbXBvbmVudFVwZGF0ZShwcm9wcywgc3RhdGUsIGNvbnRleHQpID09PSAhMSkgc2tpcCA9ICEwOyBlbHNlIGlmIChjb21wb25lbnQuY29tcG9uZW50V2lsbFVwZGF0ZSkgY29tcG9uZW50LmNvbXBvbmVudFdpbGxVcGRhdGUocHJvcHMsIHN0YXRlLCBjb250ZXh0KTtcbiAgICAgICAgICAgICAgICBjb21wb25lbnQucHJvcHMgPSBwcm9wcztcbiAgICAgICAgICAgICAgICBjb21wb25lbnQuc3RhdGUgPSBzdGF0ZTtcbiAgICAgICAgICAgICAgICBjb21wb25lbnQuY29udGV4dCA9IGNvbnRleHQ7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBjb21wb25lbnQucHJldlByb3BzID0gY29tcG9uZW50LnByZXZTdGF0ZSA9IGNvbXBvbmVudC5wcmV2Q29udGV4dCA9IGNvbXBvbmVudC5uZXh0QmFzZSA9IG51bGw7XG4gICAgICAgICAgICBjb21wb25lbnQuX2RpcnR5ID0gITE7XG4gICAgICAgICAgICBpZiAoIXNraXApIHtcbiAgICAgICAgICAgICAgICBpZiAoY29tcG9uZW50LnJlbmRlcikgcmVuZGVyZWQgPSBjb21wb25lbnQucmVuZGVyKHByb3BzLCBzdGF0ZSwgY29udGV4dCk7XG4gICAgICAgICAgICAgICAgaWYgKGNvbXBvbmVudC5nZXRDaGlsZENvbnRleHQpIGNvbnRleHQgPSBleHRlbmQoY2xvbmUoY29udGV4dCksIGNvbXBvbmVudC5nZXRDaGlsZENvbnRleHQoKSk7XG4gICAgICAgICAgICAgICAgd2hpbGUgKGlzRnVuY3Rpb25hbENvbXBvbmVudChyZW5kZXJlZCkpIHJlbmRlcmVkID0gYnVpbGRGdW5jdGlvbmFsQ29tcG9uZW50KHJlbmRlcmVkLCBjb250ZXh0KTtcbiAgICAgICAgICAgICAgICB2YXIgdG9Vbm1vdW50LCBiYXNlLCBjaGlsZENvbXBvbmVudCA9IHJlbmRlcmVkICYmIHJlbmRlcmVkLm5vZGVOYW1lO1xuICAgICAgICAgICAgICAgIGlmIChpc0Z1bmN0aW9uKGNoaWxkQ29tcG9uZW50KSkge1xuICAgICAgICAgICAgICAgICAgICBpbnN0ID0gaW5pdGlhbENoaWxkQ29tcG9uZW50O1xuICAgICAgICAgICAgICAgICAgICB2YXIgY2hpbGRQcm9wcyA9IGdldE5vZGVQcm9wcyhyZW5kZXJlZCk7XG4gICAgICAgICAgICAgICAgICAgIGlmIChpbnN0ICYmIGluc3QuY29uc3RydWN0b3IgPT09IGNoaWxkQ29tcG9uZW50KSBzZXRDb21wb25lbnRQcm9wcyhpbnN0LCBjaGlsZFByb3BzLCAxLCBjb250ZXh0KTsgZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgICAgICB0b1VubW91bnQgPSBpbnN0O1xuICAgICAgICAgICAgICAgICAgICAgICAgaW5zdCA9IGNyZWF0ZUNvbXBvbmVudChjaGlsZENvbXBvbmVudCwgY2hpbGRQcm9wcywgY29udGV4dCk7XG4gICAgICAgICAgICAgICAgICAgICAgICBpbnN0Lm5leHRCYXNlID0gaW5zdC5uZXh0QmFzZSB8fCBuZXh0QmFzZTtcbiAgICAgICAgICAgICAgICAgICAgICAgIGluc3QuX3BhcmVudENvbXBvbmVudCA9IGNvbXBvbmVudDtcbiAgICAgICAgICAgICAgICAgICAgICAgIGNvbXBvbmVudC5fY29tcG9uZW50ID0gaW5zdDtcbiAgICAgICAgICAgICAgICAgICAgICAgIHNldENvbXBvbmVudFByb3BzKGluc3QsIGNoaWxkUHJvcHMsIDAsIGNvbnRleHQpO1xuICAgICAgICAgICAgICAgICAgICAgICAgcmVuZGVyQ29tcG9uZW50KGluc3QsIDEsIG1vdW50QWxsLCAhMCk7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgYmFzZSA9IGluc3QuYmFzZTtcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICBjYmFzZSA9IGluaXRpYWxCYXNlO1xuICAgICAgICAgICAgICAgICAgICB0b1VubW91bnQgPSBpbml0aWFsQ2hpbGRDb21wb25lbnQ7XG4gICAgICAgICAgICAgICAgICAgIGlmICh0b1VubW91bnQpIGNiYXNlID0gY29tcG9uZW50Ll9jb21wb25lbnQgPSBudWxsO1xuICAgICAgICAgICAgICAgICAgICBpZiAoaW5pdGlhbEJhc2UgfHwgMSA9PT0gb3B0cykge1xuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGNiYXNlKSBjYmFzZS5fY29tcG9uZW50ID0gbnVsbDtcbiAgICAgICAgICAgICAgICAgICAgICAgIGJhc2UgPSBkaWZmKGNiYXNlLCByZW5kZXJlZCwgY29udGV4dCwgbW91bnRBbGwgfHwgIWlzVXBkYXRlLCBpbml0aWFsQmFzZSAmJiBpbml0aWFsQmFzZS5wYXJlbnROb2RlLCAhMCk7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgaWYgKGluaXRpYWxCYXNlICYmIGJhc2UgIT09IGluaXRpYWxCYXNlICYmIGluc3QgIT09IGluaXRpYWxDaGlsZENvbXBvbmVudCkge1xuICAgICAgICAgICAgICAgICAgICB2YXIgYmFzZVBhcmVudCA9IGluaXRpYWxCYXNlLnBhcmVudE5vZGU7XG4gICAgICAgICAgICAgICAgICAgIGlmIChiYXNlUGFyZW50ICYmIGJhc2UgIT09IGJhc2VQYXJlbnQpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGJhc2VQYXJlbnQucmVwbGFjZUNoaWxkKGJhc2UsIGluaXRpYWxCYXNlKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghdG9Vbm1vdW50KSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgaW5pdGlhbEJhc2UuX2NvbXBvbmVudCA9IG51bGw7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVjb2xsZWN0Tm9kZVRyZWUoaW5pdGlhbEJhc2UpO1xuICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIGlmICh0b1VubW91bnQpIHVubW91bnRDb21wb25lbnQodG9Vbm1vdW50LCBiYXNlICE9PSBpbml0aWFsQmFzZSk7XG4gICAgICAgICAgICAgICAgY29tcG9uZW50LmJhc2UgPSBiYXNlO1xuICAgICAgICAgICAgICAgIGlmIChiYXNlICYmICFpc0NoaWxkKSB7XG4gICAgICAgICAgICAgICAgICAgIHZhciBjb21wb25lbnRSZWYgPSBjb21wb25lbnQsIHQgPSBjb21wb25lbnQ7XG4gICAgICAgICAgICAgICAgICAgIHdoaWxlICh0ID0gdC5fcGFyZW50Q29tcG9uZW50KSAoY29tcG9uZW50UmVmID0gdCkuYmFzZSA9IGJhc2U7XG4gICAgICAgICAgICAgICAgICAgIGJhc2UuX2NvbXBvbmVudCA9IGNvbXBvbmVudFJlZjtcbiAgICAgICAgICAgICAgICAgICAgYmFzZS5fY29tcG9uZW50Q29uc3RydWN0b3IgPSBjb21wb25lbnRSZWYuY29uc3RydWN0b3I7XG4gICAgICAgICAgICAgICAgfVxuICAgICAg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kZU5hbWU7XG4gICAgICAgIGlmIChjICYmIGlzT3duZXIgJiYgKCFtb3VudEFsbCB8fCBjLl9jb21wb25lbnQpKSB7XG4gICAgICAgICAgICBzZXRDb21wb25lbnRQcm9wcyhjLCBwcm9wcywgMywgY29udGV4dCwgbW91bnRBbGwpO1xuICAgICAgICAgICAgZG9tID0gYy5iYXNlO1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgaWYgKGMgJiYgIWlzRGlyZWN0T3duZXIpIHtcbiAgICAgICAgICAgICAgICB1bm1vdW50Q29tcG9uZW50KGMsICEwKTtcbiAgICAgICAgICAgICAgICBkb20gPSBvbGREb20gPSBudWxsO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgYyA9IGNyZWF0ZUNvbXBvbmVudCh2bm9kZS5ub2RlTmFtZSwgcHJvcHMsIGNvbnRleHQpO1xuICAgICAgICAgICAgaWYgKGRvbSAmJiAhYy5uZXh0QmFzZSkge1xuICAgICAgICAgICAgICAgIGMubmV4dEJhc2UgPSBkb207XG4gICAgICAgICAgICAgICAgb2xkRG9tID0gbnVsbDtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHNldENvbXBvbmVudFByb3BzKGMsIHByb3BzLCAxLCBjb250ZXh0LCBtb3VudEFsbCk7XG4gICAgICAgICAgICBkb20gPSBjLmJhc2U7XG4gICAgICAgICAgICBpZiAob2xkRG9tICYmIGRvbSAhPT0gb2xkRG9tKSB7XG4gICAgICAgICAgICAgICAgb2xkRG9tLl9jb21wb25lbnQgPSBudWxsO1xuICAgICAgICAgICAgICAgIHJlY29sbGVjdE5vZGVUcmVlKG9sZERvbSk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgICAgcmV0dXJuIGRvbTtcbiAgICB9XG4gICAgZnVuY3Rpb24gdW5tb3VudENvbXBvbmVudChjb21wb25lbnQsIHJlbW92ZSkge1xuICAgICAgICBpZiAob3B0aW9ucy5iZWZvcmVVbm1vdW50KSBvcHRpb25zLmJlZm9yZVVubW91bnQoY29tcG9uZW50KTtcbiAgICAgICAgdmFyIGJhc2UgPSBjb21wb25lbnQuYmFzZTtcbiAgICAgICAgY29tcG9uZW50Ll9kaXNhYmxlID0gITA7XG4gICAgICAgIGlmIChjb21wb25lbnQuY29tcG9uZW50V2lsbFVubW91bnQpIGNvbXBvbmVudC5jb21wb25lbnRXaWxsVW5tb3VudCgpO1xuICAgICAgICBjb21wb25lbnQuYmFzZSA9IG51bGw7XG4gICAgICAgIHZhciBpbm5lciA9IGNvbXBvbmVudC5fY29tcG9uZW50O1xuICAgICAgICBpZiAoaW5uZXIpIHVubW91bnRDb21wb25lbnQoaW5uZXIsIHJlbW92ZSk7IGVsc2UgaWYgKGJhc2UpIHtcbiAgICAgICAgICAgIGlmIChiYXNlW0FUVFJfS0VZXSAmJiBiYXNlW0FUVFJfS0VZXS5yZWYpIGJhc2VbQVRUUl9LRVldLnJlZihudWxsKTtcbiAgICAgICAgICAgIGNvbXBvbmVudC5uZXh0QmFzZSA9IGJhc2U7XG4gICAgICAgICAgICBpZiAocmVtb3ZlKSB7XG4gICAgICAgICAgICAgICAgcmVtb3ZlTm9kZShiYXNlKTtcbiAgICAgICAgICAgICAgICBjb2xsZWN0Q29tcG9uZW50KGNvbXBvbmVudCk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICByZW1vdmVPcnBoYW5lZENoaWxkcmVuKGJhc2UuY2hpbGROb2RlcywgIXJlbW92ZSk7XG4gICAgICAgIH1cbiAgICAgICAgaWYgKGNvbXBvbmVudC5fX3JlZikgY29tcG9uZW50Ll9fcmVmKG51bGwpO1xuICAgICAgICBpZiAoY29tcG9uZW50LmNvbXBvbmVudERpZFVubW91bnQpIGNvbXBvbmVudC5jb21wb25lbnREaWRVbm1vdW50KCk7XG4gICAgfVxuICAgIGZ1bmN0aW9uIENvbXBvbmVudChwcm9wcywgY29udGV4dCkge1xuICAgICAgICB0aGlzLl9kaXJ0eSA9ICEwO1xuICAgICAgICB0aGlzLm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vc2l0aXZlOiAxLFxuICAgICAgICBmbGV4U2hyaW5rOiAxLFxuICAgICAgICBmbGV4TmVnYXRpdmU6IDEsXG4gICAgICAgIGZvbnRXZWlnaHQ6IDEsXG4gICAgICAgIGxpbmVDbGFtcDogMSxcbiAgICAgICAgbGluZUhlaWdodDogMSxcbiAgICAgICAgb3BhY2l0eTogMSxcbiAgICAgICAgb3JkZXI6IDEsXG4gICAgICAgIG9ycGhhbnM6IDEsXG4gICAgICAgIHN0cm9rZU9wYWNpdHk6IDEsXG4gICAgICAgIHdpZG93czogMSxcbiAgICAgICAgekluZGV4OiAxLFxuICAgICAgICB6b29tOiAxXG4gICAgfTtcbiAgICB2YXIgTk9OX0JVQkJMSU5HX0VWRU5UUyA9IHtcbiAgICAgICAgYmx1cjogMSxcbiAgICAgICAgZXJyb3I6IDEsXG4gICAgICAgIGZvY3VzOiAxLFxuICAgICAgICBsb2FkOiAxLFxuICAgICAgICByZXNpemU6IDEsXG4gICAgICAgIHNjcm9sbDogMVxuICAgIH07XG4gICAgdmFyIGl0ZW1zID0gW107XG4gICAgdmFyIG5vZGVzID0ge307XG4gICAgdmFyIG1vdW50cyA9IFtdO1xuICAgIHZhciBkaWZmTGV2ZWwgPSAwO1xuICAgIHZhciBpc1N2Z01vZGUgPSAhMTtcbiAgICB2YXIgY29tcG9uZW50cyA9IHt9O1xuICAgIGV4dGVuZChDb21wb25lbnQucHJvdG90eXBlLCB7XG4gICAgICAgIGxpbmtTdGF0ZTogZnVuY3Rpb24oa2V5LCBldmVudFBhdGgpIHtcbiAgICAgICAgICAgIHZhciBjID0gdGhpcy5fbGlua2VkU3RhdGVzIHx8ICh0aGlzLl9saW5rZWRTdGF0ZXMgPSB7fSk7XG4gICAgICAgICAgICByZXR1cm4gY1trZXkgKyBldmVudFBhdGhdIHx8IChjW2tleSArIGV2ZW50UGF0aF0gPSBjcmVhdGVMaW5rZWRTdGF0ZSh0aGlzLCBrZXksIGV2ZW50UGF0aCkpO1xuICAgICAgICB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gICB2YXIgYml0ID0gcGFydC5tYXRjaChob3N0bmFtZVBhcnRTdGFydCk7XG4gICAgICAgICAgICBpZiAoYml0KSB7XG4gICAgICAgICAgICAgIHZhbGlkUGFydHMucHVzaChiaXRbMV0pO1xuICAgICAgICAgICAgICBub3RIb3N0LnVuc2hpZnQoYml0WzJdKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGlmIChub3RIb3N0Lmxlbmd0aCkge1xuICAgICAgICAgICAgICByZXN0ID0gJy8nICsgbm90SG9zdC5qb2luKCcuJykgKyByZXN0O1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgdGhpcy5ob3N0bmFtZSA9IHZhbGlkUGFydHMuam9pbignLicpO1xuICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICB9XG4gICAgfVxuXG4gICAgaWYgKHRoaXMuaG9zdG5hbWUubGVuZ3RoID4gaG9zdG5hbWVNYXhMZW4pIHtcbiAgICAgIHRoaXMuaG9zdG5hbWUgPSAnJztcbiAgICB9IGVsc2Uge1xuICAgICAgLy8gaG9zdG5hbWVzIGFyZSBhbHdheXMgbG93ZXIgY2FzZS5cbiAgICAgIHRoaXMuaG9zdG5hbWUgPSB0aGlzLmhvc3RuYW1lLnRvTG93ZXJDYXNlKCk7XG4gICAgfVxuXG4gICAgaWYgKCFpcHY2SG9zdG5hbWUpIHtcbiAgICAgIC8vIElETkEgU3VwcG9ydDogUmV0dXJucyBhIHB1bnljb2RlZCByZXByZXNlbnRhdGlvbiBvZiBcImRvbWFpblwiLlxuICAgICAgLy8gSXQgb25seSBjb252ZXJ0cyBwYXJ0cyBvZiB0aGUgZG9tYWluIG5hbWUgdGhhdFxuICAgICAgLy8gaGF2ZSBub24tQVNDSUkgY2hhcmFjdGVycywgaS5lLiBpdCBkb2Vzbid0IG1hdHRlciBpZlxuICAgICAgLy8geW91IGNhbGwgaXQgd2l0aCBhIGRvbWFpbiB0aGF0IGFscmVhZHkgaXMgQ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2VsZi5ET05FICYmICFlcnJvckZsYWcpIHtcbiAgICAgICAgc2VsZi5kaXNwYXRjaEV2ZW50KFwibG9hZFwiKTtcbiAgICAgICAgLy8gQFRPRE8gZmlndXJlIG91dCBJbnNwZWN0b3JJbnN0cnVtZW50YXRpb246OmRpZExvYWRYSFIoY29va2llKVxuICAgICAgICBzZWxmLmRpc3BhdGNoRXZlbnQoXCJsb2FkZW5kXCIpO1xuICAgICAgfVxuICAgIH1cbiAgfTtcbn07XG4iLCJtb2R1bGUuZXhwb3J0cyA9IGV4dGVuZFxuXG52YXIgaGFzT3duUHJvcGVydHkgPSBPYmplY3QucHJvdG90eXBlLmhhc093blByb3BlcnR5O1xuXG5mdW5jdGlvbiBleHRlbmQoKSB7XG4gICAgdmFyIHRhcmdldCA9IHt9XG5cbiAgICBmb3IgKHZhciBpID0gMDsgaSA8IGFyZ3VtZW50cy5sZW5ndGg7IGkrKykge1xuICAgICAgICB2YXIgc291cmNlID0gYXJndW1lbnRzW2ldXG5cbiAgICAgICAgZm9yICh2YXIga2V5IGluIHNvdXJjZSkge1xuICAgICAgICAgICAgaWYgKGhhc093blByb3BlcnR5LmNhbGwoc291cmNlLCBrZXkpKSB7XG4gICAgICAgICAgICAgICAgdGFyZ2V0W2tleV0gPSBzb3VyY2Vba2V5XVxuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgfVxuXG4gICAgcmV0dXJuIHRhcmdldFxufVxuIl19
diff --git a/assets/js/tracker.js b/assets/dist/js/tracker.js
similarity index 100%
rename from assets/js/tracker.js
rename to assets/dist/js/tracker.js
diff --git a/assets/src/img/country-flags/ad.png b/assets/src/img/country-flags/ad.png
new file mode 100644
index 0000000..ae7b64c
Binary files /dev/null and b/assets/src/img/country-flags/ad.png differ
diff --git a/assets/src/img/country-flags/ae.png b/assets/src/img/country-flags/ae.png
new file mode 100644
index 0000000..428fd79
Binary files /dev/null and b/assets/src/img/country-flags/ae.png differ
diff --git a/assets/src/img/country-flags/af.png b/assets/src/img/country-flags/af.png
new file mode 100644
index 0000000..04804e6
Binary files /dev/null and b/assets/src/img/country-flags/af.png differ
diff --git a/assets/src/img/country-flags/ag.png b/assets/src/img/country-flags/ag.png
new file mode 100644
index 0000000..df8c629
Binary files /dev/null and b/assets/src/img/country-flags/ag.png differ
diff --git a/assets/src/img/country-flags/ai.png b/assets/src/img/country-flags/ai.png
new file mode 100644
index 0000000..33ade6d
Binary files /dev/null and b/assets/src/img/country-flags/ai.png differ
diff --git a/assets/src/img/country-flags/al.png b/assets/src/img/country-flags/al.png
new file mode 100644
index 0000000..47d3354
Binary files /dev/null and b/assets/src/img/country-flags/al.png differ
diff --git a/assets/src/img/country-flags/am.png b/assets/src/img/country-flags/am.png
new file mode 100644
index 0000000..03f94ab
Binary files /dev/null and b/assets/src/img/country-flags/am.png differ
diff --git a/assets/src/img/country-flags/ao.png b/assets/src/img/country-flags/ao.png
new file mode 100644
index 0000000..385a334
Binary files /dev/null and b/assets/src/img/country-flags/ao.png differ
diff --git a/assets/src/img/country-flags/ar.png b/assets/src/img/country-flags/ar.png
new file mode 100644
index 0000000..a7e2412
Binary files /dev/null and b/assets/src/img/country-flags/ar.png differ
diff --git a/assets/src/img/country-flags/as.png b/assets/src/img/country-flags/as.png
new file mode 100644
index 0000000..b8f967a
Binary files /dev/null and b/assets/src/img/country-flags/as.png differ
diff --git a/assets/src/img/country-flags/at.png b/assets/src/img/country-flags/at.png
new file mode 100644
index 0000000..d3b2b2d
Binary files /dev/null and b/assets/src/img/country-flags/at.png differ
diff --git a/assets/src/img/country-flags/au.png b/assets/src/img/country-flags/au.png
new file mode 100644
index 0000000..22b082c
Binary files /dev/null and b/assets/src/img/country-flags/au.png differ
diff --git a/assets/src/img/country-flags/aw.png b/assets/src/img/country-flags/aw.png
new file mode 100644
index 0000000..980c144
Binary files /dev/null and b/assets/src/img/country-flags/aw.png differ
diff --git a/assets/src/img/country-flags/ax.png b/assets/src/img/country-flags/ax.png
new file mode 100644
index 0000000..21213a4
Binary files /dev/null and b/assets/src/img/country-flags/ax.png differ
diff --git a/assets/src/img/country-flags/az.png b/assets/src/img/country-flags/az.png
new file mode 100644
index 0000000..caeaf19
Binary files /dev/null and b/assets/src/img/country-flags/az.png differ
diff --git a/assets/src/img/country-flags/ba.png b/assets/src/img/country-flags/ba.png
new file mode 100644
index 0000000..d43d4b0
Binary files /dev/null and b/assets/src/img/country-flags/ba.png differ
diff --git a/assets/src/img/country-flags/bb.png b/assets/src/img/country-flags/bb.png
new file mode 100644
index 0000000..36140b9
Binary files /dev/null and b/assets/src/img/country-flags/bb.png differ
diff --git a/assets/src/img/country-flags/bd.png b/assets/src/img/country-flags/bd.png
new file mode 100644
index 0000000..63daa63
Binary files /dev/null and b/assets/src/img/country-flags/bd.png differ
diff --git a/assets/src/img/country-flags/be.png b/assets/src/img/country-flags/be.png
new file mode 100644
index 0000000..2db4fd7
Binary files /dev/null and b/assets/src/img/country-flags/be.png differ
diff --git a/assets/src/img/country-flags/bf.png b/assets/src/img/country-flags/bf.png
new file mode 100644
index 0000000..c3ac9da
Binary files /dev/null and b/assets/src/img/country-flags/bf.png differ
diff --git a/assets/src/img/country-flags/bg.png b/assets/src/img/country-flags/bg.png
new file mode 100644
index 0000000..5bde564
Binary files /dev/null and b/assets/src/img/country-flags/bg.png differ
diff --git a/assets/src/img/country-flags/bh.png b/assets/src/img/country-flags/bh.png
new file mode 100644
index 0000000..d08c757
Binary files /dev/null and b/assets/src/img/country-flags/bh.png differ
diff --git a/assets/src/img/country-flags/bi.png b/assets/src/img/country-flags/bi.png
new file mode 100644
index 0000000..6ba603c
Binary files /dev/null and b/assets/src/img/country-flags/bi.png differ
diff --git a/assets/src/img/country-flags/bj.png b/assets/src/img/country-flags/bj.png
new file mode 100644
index 0000000..aaee839
Binary files /dev/null and b/assets/src/img/country-flags/bj.png differ
diff --git a/assets/src/img/country-flags/bm.png b/assets/src/img/country-flags/bm.png
new file mode 100644
index 0000000..55a3912
Binary files /dev/null and b/assets/src/img/country-flags/bm.png differ
diff --git a/assets/src/img/country-flags/bn.png b/assets/src/img/country-flags/bn.png
new file mode 100644
index 0000000..a3a30c8
Binary files /dev/null and b/assets/src/img/country-flags/bn.png differ
diff --git a/assets/src/img/country-flags/bo.png b/assets/src/img/country-flags/bo.png
new file mode 100644
index 0000000..ef3d226
Binary files /dev/null and b/assets/src/img/country-flags/bo.png differ
diff --git a/assets/src/img/country-flags/br.png b/assets/src/img/country-flags/br.png
new file mode 100644
index 0000000..6861552
Binary files /dev/null and b/assets/src/img/country-flags/br.png differ
diff --git a/assets/src/img/country-flags/bs.png b/assets/src/img/country-flags/bs.png
new file mode 100644
index 0000000..e89e728
Binary files /dev/null and b/assets/src/img/country-flags/bs.png differ
diff --git a/assets/src/img/country-flags/bt.png b/assets/src/img/country-flags/bt.png
new file mode 100644
index 0000000..4bb90bf
Binary files /dev/null and b/assets/src/img/country-flags/bt.png differ
diff --git a/assets/src/img/country-flags/bw.png b/assets/src/img/country-flags/bw.png
new file mode 100644
index 0000000..0c5e0c9
Binary files /dev/null and b/assets/src/img/country-flags/bw.png differ
diff --git a/assets/src/img/country-flags/by.png b/assets/src/img/country-flags/by.png
new file mode 100644
index 0000000..1087934
Binary files /dev/null and b/assets/src/img/country-flags/by.png differ
diff --git a/assets/src/img/country-flags/bz.png b/assets/src/img/country-flags/bz.png
new file mode 100644
index 0000000..7226484
Binary files /dev/null and b/assets/src/img/country-flags/bz.png differ
diff --git a/assets/src/img/country-flags/ca.png b/assets/src/img/country-flags/ca.png
new file mode 100644
index 0000000..6d8d6f5
Binary files /dev/null and b/assets/src/img/country-flags/ca.png differ
diff --git a/assets/src/img/country-flags/cc.png b/assets/src/img/country-flags/cc.png
new file mode 100644
index 0000000..da5bd32
Binary files /dev/null and b/assets/src/img/country-flags/cc.png differ
diff --git a/assets/src/img/country-flags/cd.png b/assets/src/img/country-flags/cd.png
new file mode 100644
index 0000000..9ac55f1
Binary files /dev/null and b/assets/src/img/country-flags/cd.png differ
diff --git a/assets/src/img/country-flags/cf.png b/assets/src/img/country-flags/cf.png
new file mode 100644
index 0000000..f2feb8a
Binary files /dev/null and b/assets/src/img/country-flags/cf.png differ
diff --git a/assets/src/img/country-flags/cg.png b/assets/src/img/country-flags/cg.png
new file mode 100644
index 0000000..69cb8be
Binary files /dev/null and b/assets/src/img/country-flags/cg.png differ
diff --git a/assets/src/img/country-flags/ch.png b/assets/src/img/country-flags/ch.png
new file mode 100644
index 0000000..601e8f3
Binary files /dev/null and b/assets/src/img/country-flags/ch.png differ
diff --git a/assets/src/img/country-flags/ci.png b/assets/src/img/country-flags/ci.png
new file mode 100644
index 0000000..170ceac
Binary files /dev/null and b/assets/src/img/country-flags/ci.png differ
diff --git a/assets/src/img/country-flags/ck.png b/assets/src/img/country-flags/ck.png
new file mode 100644
index 0000000..12a4fe3
Binary files /dev/null and b/assets/src/img/country-flags/ck.png differ
diff --git a/assets/src/img/country-flags/cl.png b/assets/src/img/country-flags/cl.png
new file mode 100644
index 0000000..ecfb097
Binary files /dev/null and b/assets/src/img/country-flags/cl.png differ
diff --git a/assets/src/img/country-flags/cm.png b/assets/src/img/country-flags/cm.png
new file mode 100644
index 0000000..4008a23
Binary files /dev/null and b/assets/src/img/country-flags/cm.png differ
diff --git a/assets/src/img/country-flags/cn.png b/assets/src/img/country-flags/cn.png
new file mode 100644
index 0000000..8a8e879
Binary files /dev/null and b/assets/src/img/country-flags/cn.png differ
diff --git a/assets/src/img/country-flags/co.png b/assets/src/img/country-flags/co.png
new file mode 100644
index 0000000..3103d11
Binary files /dev/null and b/assets/src/img/country-flags/co.png differ
diff --git a/assets/src/img/country-flags/cr.png b/assets/src/img/country-flags/cr.png
new file mode 100644
index 0000000..b2c302e
Binary files /dev/null and b/assets/src/img/country-flags/cr.png differ
diff --git a/assets/src/img/country-flags/cu.png b/assets/src/img/country-flags/cu.png
new file mode 100644
index 0000000..8aea838
Binary files /dev/null and b/assets/src/img/country-flags/cu.png differ
diff --git a/assets/src/img/country-flags/cv.png b/assets/src/img/country-flags/cv.png
new file mode 100644
index 0000000..1ffceb9
Binary files /dev/null and b/assets/src/img/country-flags/cv.png differ
diff --git a/assets/src/img/country-flags/cw.png b/assets/src/img/country-flags/cw.png
new file mode 100644
index 0000000..27028c2
Binary files /dev/null and b/assets/src/img/country-flags/cw.png differ
diff --git a/assets/src/img/country-flags/cx.png b/assets/src/img/country-flags/cx.png
new file mode 100644
index 0000000..451a039
Binary files /dev/null and b/assets/src/img/country-flags/cx.png differ
diff --git a/assets/src/img/country-flags/cy.png b/assets/src/img/country-flags/cy.png
new file mode 100644
index 0000000..ce3e1a3
Binary files /dev/null and b/assets/src/img/country-flags/cy.png differ
diff --git a/assets/src/img/country-flags/cz.png b/assets/src/img/country-flags/cz.png
new file mode 100644
index 0000000..adfa272
Binary files /dev/null and b/assets/src/img/country-flags/cz.png differ
diff --git a/assets/src/img/country-flags/de.png b/assets/src/img/country-flags/de.png
new file mode 100644
index 0000000..8e22c8a
Binary files /dev/null and b/assets/src/img/country-flags/de.png differ
diff --git a/assets/src/img/country-flags/dj.png b/assets/src/img/country-flags/dj.png
new file mode 100644
index 0000000..288f42c
Binary files /dev/null and b/assets/src/img/country-flags/dj.png differ
diff --git a/assets/src/img/country-flags/dk.png b/assets/src/img/country-flags/dk.png
new file mode 100644
index 0000000..50e2919
Binary files /dev/null and b/assets/src/img/country-flags/dk.png differ
diff --git a/assets/src/img/country-flags/dm.png b/assets/src/img/country-flags/dm.png
new file mode 100644
index 0000000..89101a6
Binary files /dev/null and b/assets/src/img/country-flags/dm.png differ
diff --git a/assets/src/img/country-flags/do.png b/assets/src/img/country-flags/do.png
new file mode 100644
index 0000000..b7a6f4c
Binary files /dev/null and b/assets/src/img/country-flags/do.png differ
diff --git a/assets/src/img/country-flags/dz.png b/assets/src/img/country-flags/dz.png
new file mode 100644
index 0000000..1ab21fd
Binary files /dev/null and b/assets/src/img/country-flags/dz.png differ
diff --git a/assets/src/img/country-flags/ec.png b/assets/src/img/country-flags/ec.png
new file mode 100644
index 0000000..84ef4d4
Binary files /dev/null and b/assets/src/img/country-flags/ec.png differ
diff --git a/assets/src/img/country-flags/ee.png b/assets/src/img/country-flags/ee.png
new file mode 100644
index 0000000..7f506ce
Binary files /dev/null and b/assets/src/img/country-flags/ee.png differ
diff --git a/assets/src/img/country-flags/eg.png b/assets/src/img/country-flags/eg.png
new file mode 100644
index 0000000..e5ab4af
Binary files /dev/null and b/assets/src/img/country-flags/eg.png differ
diff --git a/assets/src/img/country-flags/er.png b/assets/src/img/country-flags/er.png
new file mode 100644
index 0000000..542ea41
Binary files /dev/null and b/assets/src/img/country-flags/er.png differ
diff --git a/assets/src/img/country-flags/es.png b/assets/src/img/country-flags/es.png
new file mode 100644
index 0000000..e018dd7
Binary files /dev/null and b/assets/src/img/country-flags/es.png differ
diff --git a/assets/src/img/country-flags/et.png b/assets/src/img/country-flags/et.png
new file mode 100644
index 0000000..5fba1f6
Binary files /dev/null and b/assets/src/img/country-flags/et.png differ
diff --git a/assets/src/img/country-flags/fi.png b/assets/src/img/country-flags/fi.png
new file mode 100644
index 0000000..cd6eb45
Binary files /dev/null and b/assets/src/img/country-flags/fi.png differ
diff --git a/assets/src/img/country-flags/fj.png b/assets/src/img/country-flags/fj.png
new file mode 100644
index 0000000..1bdd633
Binary files /dev/null and b/assets/src/img/country-flags/fj.png differ
diff --git a/assets/src/img/country-flags/fk.png b/assets/src/img/country-flags/fk.png
new file mode 100644
index 0000000..51858b7
Binary files /dev/null and b/assets/src/img/country-flags/fk.png differ
diff --git a/assets/src/img/country-flags/fm.png b/assets/src/img/country-flags/fm.png
new file mode 100644
index 0000000..01b76fa
Binary files /dev/null and b/assets/src/img/country-flags/fm.png differ
diff --git a/assets/src/img/country-flags/fo.png b/assets/src/img/country-flags/fo.png
new file mode 100644
index 0000000..0462b42
Binary files /dev/null and b/assets/src/img/country-flags/fo.png differ
diff --git a/assets/src/img/country-flags/fr.png b/assets/src/img/country-flags/fr.png
new file mode 100644
index 0000000..b8e120b
Binary files /dev/null and b/assets/src/img/country-flags/fr.png differ
diff --git a/assets/src/img/country-flags/ga.png b/assets/src/img/country-flags/ga.png
new file mode 100644
index 0000000..838b34b
Binary files /dev/null and b/assets/src/img/country-flags/ga.png differ
diff --git a/assets/src/img/country-flags/gb.png b/assets/src/img/country-flags/gb.png
new file mode 100644
index 0000000..53fdf1b
Binary files /dev/null and b/assets/src/img/country-flags/gb.png differ
diff --git a/assets/src/img/country-flags/gd.png b/assets/src/img/country-flags/gd.png
new file mode 100644
index 0000000..116e0f1
Binary files /dev/null and b/assets/src/img/country-flags/gd.png differ
diff --git a/assets/src/img/country-flags/ge.png b/assets/src/img/country-flags/ge.png
new file mode 100644
index 0000000..7948ed4
Binary files /dev/null and b/assets/src/img/country-flags/ge.png differ
diff --git a/assets/src/img/country-flags/gg.png b/assets/src/img/country-flags/gg.png
new file mode 100644
index 0000000..1700cce
Binary files /dev/null and b/assets/src/img/country-flags/gg.png differ
diff --git a/assets/src/img/country-flags/gh.png b/assets/src/img/country-flags/gh.png
new file mode 100644
index 0000000..f808603
Binary files /dev/null and b/assets/src/img/country-flags/gh.png differ
diff --git a/assets/src/img/country-flags/gi.png b/assets/src/img/country-flags/gi.png
new file mode 100644
index 0000000..cd9a54d
Binary files /dev/null and b/assets/src/img/country-flags/gi.png differ
diff --git a/assets/src/img/country-flags/gl.png b/assets/src/img/country-flags/gl.png
new file mode 100644
index 0000000..0fadabf
Binary files /dev/null and b/assets/src/img/country-flags/gl.png differ
diff --git a/assets/src/img/country-flags/gm.png b/assets/src/img/country-flags/gm.png
new file mode 100644
index 0000000..cf01f84
Binary files /dev/null and b/assets/src/img/country-flags/gm.png differ
diff --git a/assets/src/img/country-flags/gn.png b/assets/src/img/country-flags/gn.png
new file mode 100644
index 0000000..12812d5
Binary files /dev/null and b/assets/src/img/country-flags/gn.png differ
diff --git a/assets/src/img/country-flags/gq.png b/assets/src/img/country-flags/gq.png
new file mode 100644
index 0000000..cea6978
Binary files /dev/null and b/assets/src/img/country-flags/gq.png differ
diff --git a/assets/src/img/country-flags/gr.png b/assets/src/img/country-flags/gr.png
new file mode 100644
index 0000000..f1bcc67
Binary files /dev/null and b/assets/src/img/country-flags/gr.png differ
diff --git a/assets/src/img/country-flags/gs.png b/assets/src/img/country-flags/gs.png
new file mode 100644
index 0000000..8f01756
Binary files /dev/null and b/assets/src/img/country-flags/gs.png differ
diff --git a/assets/src/img/country-flags/gt.png b/assets/src/img/country-flags/gt.png
new file mode 100644
index 0000000..8429f0e
Binary files /dev/null and b/assets/src/img/country-flags/gt.png differ
diff --git a/assets/src/img/country-flags/gu.png b/assets/src/img/country-flags/gu.png
new file mode 100644
index 0000000..e06f96c
Binary files /dev/null and b/assets/src/img/country-flags/gu.png differ
diff --git a/assets/src/img/country-flags/gw.png b/assets/src/img/country-flags/gw.png
new file mode 100644
index 0000000..0883b13
Binary files /dev/null and b/assets/src/img/country-flags/gw.png differ
diff --git a/assets/src/img/country-flags/gy.png b/assets/src/img/country-flags/gy.png
new file mode 100644
index 0000000..982cc7f
Binary files /dev/null and b/assets/src/img/country-flags/gy.png differ
diff --git a/assets/src/img/country-flags/hk.png b/assets/src/img/country-flags/hk.png
new file mode 100644
index 0000000..3ac4c9b
Binary files /dev/null and b/assets/src/img/country-flags/hk.png differ
diff --git a/assets/src/img/country-flags/hn.png b/assets/src/img/country-flags/hn.png
new file mode 100644
index 0000000..3585e21
Binary files /dev/null and b/assets/src/img/country-flags/hn.png differ
diff --git a/assets/src/img/country-flags/hr.png b/assets/src/img/country-flags/hr.png
new file mode 100644
index 0000000..ead3478
Binary files /dev/null and b/assets/src/img/country-flags/hr.png differ
diff --git a/assets/src/img/country-flags/ht.png b/assets/src/img/country-flags/ht.png
new file mode 100644
index 0000000..7185e7b
Binary files /dev/null and b/assets/src/img/country-flags/ht.png differ
diff --git a/assets/src/img/country-flags/hu.png b/assets/src/img/country-flags/hu.png
new file mode 100644
index 0000000..278ad0e
Binary files /dev/null and b/assets/src/img/country-flags/hu.png differ
diff --git a/assets/src/img/country-flags/id.png b/assets/src/img/country-flags/id.png
new file mode 100644
index 0000000..98c4e80
Binary files /dev/null and b/assets/src/img/country-flags/id.png differ
diff --git a/assets/src/img/country-flags/ie.png b/assets/src/img/country-flags/ie.png
new file mode 100644
index 0000000..f1b39d6
Binary files /dev/null and b/assets/src/img/country-flags/ie.png differ
diff --git a/assets/src/img/country-flags/il.png b/assets/src/img/country-flags/il.png
new file mode 100644
index 0000000..528fa57
Binary files /dev/null and b/assets/src/img/country-flags/il.png differ
diff --git a/assets/src/img/country-flags/im.png b/assets/src/img/country-flags/im.png
new file mode 100644
index 0000000..66267ed
Binary files /dev/null and b/assets/src/img/country-flags/im.png differ
diff --git a/assets/src/img/country-flags/in.png b/assets/src/img/country-flags/in.png
new file mode 100644
index 0000000..c1ed48d
Binary files /dev/null and b/assets/src/img/country-flags/in.png differ
diff --git a/assets/src/img/country-flags/io.png b/assets/src/img/country-flags/io.png
new file mode 100644
index 0000000..dceaa05
Binary files /dev/null and b/assets/src/img/country-flags/io.png differ
diff --git a/assets/src/img/country-flags/iq.png b/assets/src/img/country-flags/iq.png
new file mode 100644
index 0000000..f02ffb1
Binary files /dev/null and b/assets/src/img/country-flags/iq.png differ
diff --git a/assets/src/img/country-flags/ir.png b/assets/src/img/country-flags/ir.png
new file mode 100644
index 0000000..33e1859
Binary files /dev/null and b/assets/src/img/country-flags/ir.png differ
diff --git a/assets/src/img/country-flags/is.png b/assets/src/img/country-flags/is.png
new file mode 100644
index 0000000..0087aa0
Binary files /dev/null and b/assets/src/img/country-flags/is.png differ
diff --git a/assets/src/img/country-flags/it.png b/assets/src/img/country-flags/it.png
new file mode 100644
index 0000000..034fe15
Binary files /dev/null and b/assets/src/img/country-flags/it.png differ
diff --git a/assets/src/img/country-flags/je.png b/assets/src/img/country-flags/je.png
new file mode 100644
index 0000000..8f72065
Binary files /dev/null and b/assets/src/img/country-flags/je.png differ
diff --git a/assets/src/img/country-flags/jm.png b/assets/src/img/country-flags/jm.png
new file mode 100644
index 0000000..2b34a3f
Binary files /dev/null and b/assets/src/img/country-flags/jm.png differ
diff --git a/assets/src/img/country-flags/jo.png b/assets/src/img/country-flags/jo.png
new file mode 100644
index 0000000..8f2bcf1
Binary files /dev/null and b/assets/src/img/country-flags/jo.png differ
diff --git a/assets/src/img/country-flags/jp.png b/assets/src/img/country-flags/jp.png
new file mode 100644
index 0000000..57247c5
Binary files /dev/null and b/assets/src/img/country-flags/jp.png differ
diff --git a/assets/src/img/country-flags/ke.png b/assets/src/img/country-flags/ke.png
new file mode 100644
index 0000000..3a39078
Binary files /dev/null and b/assets/src/img/country-flags/ke.png differ
diff --git a/assets/src/img/country-flags/kg.png b/assets/src/img/country-flags/kg.png
new file mode 100644
index 0000000..9240125
Binary files /dev/null and b/assets/src/img/country-flags/kg.png differ
diff --git a/assets/src/img/country-flags/kh.png b/assets/src/img/country-flags/kh.png
new file mode 100644
index 0000000..b18a879
Binary files /dev/null and b/assets/src/img/country-flags/kh.png differ
diff --git a/assets/src/img/country-flags/ki.png b/assets/src/img/country-flags/ki.png
new file mode 100644
index 0000000..87cb6cb
Binary files /dev/null and b/assets/src/img/country-flags/ki.png differ
diff --git a/assets/src/img/country-flags/km.png b/assets/src/img/country-flags/km.png
new file mode 100644
index 0000000..69d2c7d
Binary files /dev/null and b/assets/src/img/country-flags/km.png differ
diff --git a/assets/src/img/country-flags/kn.png b/assets/src/img/country-flags/kn.png
new file mode 100644
index 0000000..fd02a7c
Binary files /dev/null and b/assets/src/img/country-flags/kn.png differ
diff --git a/assets/src/img/country-flags/kp.png b/assets/src/img/country-flags/kp.png
new file mode 100644
index 0000000..b7f07d8
Binary files /dev/null and b/assets/src/img/country-flags/kp.png differ
diff --git a/assets/src/img/country-flags/kr.png b/assets/src/img/country-flags/kr.png
new file mode 100644
index 0000000..4763499
Binary files /dev/null and b/assets/src/img/country-flags/kr.png differ
diff --git a/assets/src/img/country-flags/kw.png b/assets/src/img/country-flags/kw.png
new file mode 100644
index 0000000..5c3aa81
Binary files /dev/null and b/assets/src/img/country-flags/kw.png differ
diff --git a/assets/src/img/country-flags/ky.png b/assets/src/img/country-flags/ky.png
new file mode 100644
index 0000000..1c5017c
Binary files /dev/null and b/assets/src/img/country-flags/ky.png differ
diff --git a/assets/src/img/country-flags/kz.png b/assets/src/img/country-flags/kz.png
new file mode 100644
index 0000000..3b3d356
Binary files /dev/null and b/assets/src/img/country-flags/kz.png differ
diff --git a/assets/src/img/country-flags/la.png b/assets/src/img/country-flags/la.png
new file mode 100644
index 0000000..64a94f5
Binary files /dev/null and b/assets/src/img/country-flags/la.png differ
diff --git a/assets/src/img/country-flags/lb.png b/assets/src/img/country-flags/lb.png
new file mode 100644
index 0000000..68a0376
Binary files /dev/null and b/assets/src/img/country-flags/lb.png differ
diff --git a/assets/src/img/country-flags/lc.png b/assets/src/img/country-flags/lc.png
new file mode 100644
index 0000000..fbeaad7
Binary files /dev/null and b/assets/src/img/country-flags/lc.png differ
diff --git a/assets/src/img/country-flags/li.png b/assets/src/img/country-flags/li.png
new file mode 100644
index 0000000..b46c952
Binary files /dev/null and b/assets/src/img/country-flags/li.png differ
diff --git a/assets/src/img/country-flags/lk.png b/assets/src/img/country-flags/lk.png
new file mode 100644
index 0000000..ae1f36a
Binary files /dev/null and b/assets/src/img/country-flags/lk.png differ
diff --git a/assets/src/img/country-flags/lr.png b/assets/src/img/country-flags/lr.png
new file mode 100644
index 0000000..5736136
Binary files /dev/null and b/assets/src/img/country-flags/lr.png differ
diff --git a/assets/src/img/country-flags/ls.png b/assets/src/img/country-flags/ls.png
new file mode 100644
index 0000000..4ffb9fc
Binary files /dev/null and b/assets/src/img/country-flags/ls.png differ
diff --git a/assets/src/img/country-flags/lt.png b/assets/src/img/country-flags/lt.png
new file mode 100644
index 0000000..2614dac
Binary files /dev/null and b/assets/src/img/country-flags/lt.png differ
diff --git a/assets/src/img/country-flags/lu.png b/assets/src/img/country-flags/lu.png
new file mode 100644
index 0000000..71bb70c
Binary files /dev/null and b/assets/src/img/country-flags/lu.png differ
diff --git a/assets/src/img/country-flags/lv.png b/assets/src/img/country-flags/lv.png
new file mode 100644
index 0000000..649c5ae
Binary files /dev/null and b/assets/src/img/country-flags/lv.png differ
diff --git a/assets/src/img/country-flags/ly.png b/assets/src/img/country-flags/ly.png
new file mode 100644
index 0000000..e70aef9
Binary files /dev/null and b/assets/src/img/country-flags/ly.png differ
diff --git a/assets/src/img/country-flags/ma.png b/assets/src/img/country-flags/ma.png
new file mode 100644
index 0000000..b330c27
Binary files /dev/null and b/assets/src/img/country-flags/ma.png differ
diff --git a/assets/src/img/country-flags/mc.png b/assets/src/img/country-flags/mc.png
new file mode 100644
index 0000000..594ed85
Binary files /dev/null and b/assets/src/img/country-flags/mc.png differ
diff --git a/assets/src/img/country-flags/md.png b/assets/src/img/country-flags/md.png
new file mode 100644
index 0000000..82d4608
Binary files /dev/null and b/assets/src/img/country-flags/md.png differ
diff --git a/assets/src/img/country-flags/me.png b/assets/src/img/country-flags/me.png
new file mode 100644
index 0000000..f9d7f02
Binary files /dev/null and b/assets/src/img/country-flags/me.png differ
diff --git a/assets/src/img/country-flags/mg.png b/assets/src/img/country-flags/mg.png
new file mode 100644
index 0000000..d2c0f80
Binary files /dev/null and b/assets/src/img/country-flags/mg.png differ
diff --git a/assets/src/img/country-flags/mh.png b/assets/src/img/country-flags/mh.png
new file mode 100644
index 0000000..3d72763
Binary files /dev/null and b/assets/src/img/country-flags/mh.png differ
diff --git a/assets/src/img/country-flags/mk.png b/assets/src/img/country-flags/mk.png
new file mode 100644
index 0000000..f27d78f
Binary files /dev/null and b/assets/src/img/country-flags/mk.png differ
diff --git a/assets/src/img/country-flags/ml.png b/assets/src/img/country-flags/ml.png
new file mode 100644
index 0000000..adc7d23
Binary files /dev/null and b/assets/src/img/country-flags/ml.png differ
diff --git a/assets/src/img/country-flags/mm.png b/assets/src/img/country-flags/mm.png
new file mode 100644
index 0000000..75c6369
Binary files /dev/null and b/assets/src/img/country-flags/mm.png differ
diff --git a/assets/src/img/country-flags/mn.png b/assets/src/img/country-flags/mn.png
new file mode 100644
index 0000000..7b2cc35
Binary files /dev/null and b/assets/src/img/country-flags/mn.png differ
diff --git a/assets/src/img/country-flags/mo.png b/assets/src/img/country-flags/mo.png
new file mode 100644
index 0000000..2565432
Binary files /dev/null and b/assets/src/img/country-flags/mo.png differ
diff --git a/assets/src/img/country-flags/mp.png b/assets/src/img/country-flags/mp.png
new file mode 100644
index 0000000..b1b27c0
Binary files /dev/null and b/assets/src/img/country-flags/mp.png differ
diff --git a/assets/src/img/country-flags/mq.png b/assets/src/img/country-flags/mq.png
new file mode 100644
index 0000000..b7525c1
Binary files /dev/null and b/assets/src/img/country-flags/mq.png differ
diff --git a/assets/src/img/country-flags/mr.png b/assets/src/img/country-flags/mr.png
new file mode 100644
index 0000000..0f4586d
Binary files /dev/null and b/assets/src/img/country-flags/mr.png differ
diff --git a/assets/src/img/country-flags/ms.png b/assets/src/img/country-flags/ms.png
new file mode 100644
index 0000000..2032c4b
Binary files /dev/null and b/assets/src/img/country-flags/ms.png differ
diff --git a/assets/src/img/country-flags/mt.png b/assets/src/img/country-flags/mt.png
new file mode 100644
index 0000000..153224d
Binary files /dev/null and b/assets/src/img/country-flags/mt.png differ
diff --git a/assets/src/img/country-flags/mu.png b/assets/src/img/country-flags/mu.png
new file mode 100644
index 0000000..8b76367
Binary files /dev/null and b/assets/src/img/country-flags/mu.png differ
diff --git a/assets/src/img/country-flags/mv.png b/assets/src/img/country-flags/mv.png
new file mode 100644
index 0000000..d8f2104
Binary files /dev/null and b/assets/src/img/country-flags/mv.png differ
diff --git a/assets/src/img/country-flags/mw.png b/assets/src/img/country-flags/mw.png
new file mode 100644
index 0000000..4f73882
Binary files /dev/null and b/assets/src/img/country-flags/mw.png differ
diff --git a/assets/src/img/country-flags/mx.png b/assets/src/img/country-flags/mx.png
new file mode 100644
index 0000000..bc897eb
Binary files /dev/null and b/assets/src/img/country-flags/mx.png differ
diff --git a/assets/src/img/country-flags/my.png b/assets/src/img/country-flags/my.png
new file mode 100644
index 0000000..9aa8c6d
Binary files /dev/null and b/assets/src/img/country-flags/my.png differ
diff --git a/assets/src/img/country-flags/mz.png b/assets/src/img/country-flags/mz.png
new file mode 100644
index 0000000..3f04bf2
Binary files /dev/null and b/assets/src/img/country-flags/mz.png differ
diff --git a/assets/src/img/country-flags/na.png b/assets/src/img/country-flags/na.png
new file mode 100644
index 0000000..54bab3a
Binary files /dev/null and b/assets/src/img/country-flags/na.png differ
diff --git a/assets/src/img/country-flags/nc.png b/assets/src/img/country-flags/nc.png
new file mode 100644
index 0000000..880d184
Binary files /dev/null and b/assets/src/img/country-flags/nc.png differ
diff --git a/assets/src/img/country-flags/ne.png b/assets/src/img/country-flags/ne.png
new file mode 100644
index 0000000..c587f32
Binary files /dev/null and b/assets/src/img/country-flags/ne.png differ
diff --git a/assets/src/img/country-flags/nf.png b/assets/src/img/country-flags/nf.png
new file mode 100644
index 0000000..572fd01
Binary files /dev/null and b/assets/src/img/country-flags/nf.png differ
diff --git a/assets/src/img/country-flags/ng.png b/assets/src/img/country-flags/ng.png
new file mode 100644
index 0000000..21e4cd2
Binary files /dev/null and b/assets/src/img/country-flags/ng.png differ
diff --git a/assets/src/img/country-flags/ni.png b/assets/src/img/country-flags/ni.png
new file mode 100644
index 0000000..59d2ae6
Binary files /dev/null and b/assets/src/img/country-flags/ni.png differ
diff --git a/assets/src/img/country-flags/nl.png b/assets/src/img/country-flags/nl.png
new file mode 100644
index 0000000..74d1a6c
Binary files /dev/null and b/assets/src/img/country-flags/nl.png differ
diff --git a/assets/src/img/country-flags/no.png b/assets/src/img/country-flags/no.png
new file mode 100644
index 0000000..1b91d5c
Binary files /dev/null and b/assets/src/img/country-flags/no.png differ
diff --git a/assets/src/img/country-flags/np.png b/assets/src/img/country-flags/np.png
new file mode 100644
index 0000000..2439fd7
Binary files /dev/null and b/assets/src/img/country-flags/np.png differ
diff --git a/assets/src/img/country-flags/nr.png b/assets/src/img/country-flags/nr.png
new file mode 100644
index 0000000..6653027
Binary files /dev/null and b/assets/src/img/country-flags/nr.png differ
diff --git a/assets/src/img/country-flags/nu.png b/assets/src/img/country-flags/nu.png
new file mode 100644
index 0000000..2acd015
Binary files /dev/null and b/assets/src/img/country-flags/nu.png differ
diff --git a/assets/src/img/country-flags/nz.png b/assets/src/img/country-flags/nz.png
new file mode 100644
index 0000000..da3a9ce
Binary files /dev/null and b/assets/src/img/country-flags/nz.png differ
diff --git a/assets/src/img/country-flags/om.png b/assets/src/img/country-flags/om.png
new file mode 100644
index 0000000..6d53eaf
Binary files /dev/null and b/assets/src/img/country-flags/om.png differ
diff --git a/assets/src/img/country-flags/pa.png b/assets/src/img/country-flags/pa.png
new file mode 100644
index 0000000..7b0938d
Binary files /dev/null and b/assets/src/img/country-flags/pa.png differ
diff --git a/assets/src/img/country-flags/pe.png b/assets/src/img/country-flags/pe.png
new file mode 100644
index 0000000..2579527
Binary files /dev/null and b/assets/src/img/country-flags/pe.png differ
diff --git a/assets/src/img/country-flags/pf.png b/assets/src/img/country-flags/pf.png
new file mode 100644
index 0000000..a83b224
Binary files /dev/null and b/assets/src/img/country-flags/pf.png differ
diff --git a/assets/src/img/country-flags/pg.png b/assets/src/img/country-flags/pg.png
new file mode 100644
index 0000000..722cee7
Binary files /dev/null and b/assets/src/img/country-flags/pg.png differ
diff --git a/assets/src/img/country-flags/ph.png b/assets/src/img/country-flags/ph.png
new file mode 100644
index 0000000..c2af43a
Binary files /dev/null and b/assets/src/img/country-flags/ph.png differ
diff --git a/assets/src/img/country-flags/pk.png b/assets/src/img/country-flags/pk.png
new file mode 100644
index 0000000..b3c8911
Binary files /dev/null and b/assets/src/img/country-flags/pk.png differ
diff --git a/assets/src/img/country-flags/pl.png b/assets/src/img/country-flags/pl.png
new file mode 100644
index 0000000..d4db002
Binary files /dev/null and b/assets/src/img/country-flags/pl.png differ
diff --git a/assets/src/img/country-flags/pn.png b/assets/src/img/country-flags/pn.png
new file mode 100644
index 0000000..acc1e64
Binary files /dev/null and b/assets/src/img/country-flags/pn.png differ
diff --git a/assets/src/img/country-flags/pr.png b/assets/src/img/country-flags/pr.png
new file mode 100644
index 0000000..253f92a
Binary files /dev/null and b/assets/src/img/country-flags/pr.png differ
diff --git a/assets/src/img/country-flags/ps.png b/assets/src/img/country-flags/ps.png
new file mode 100644
index 0000000..5efc6eb
Binary files /dev/null and b/assets/src/img/country-flags/ps.png differ
diff --git a/assets/src/img/country-flags/pt.png b/assets/src/img/country-flags/pt.png
new file mode 100644
index 0000000..fcc0e60
Binary files /dev/null and b/assets/src/img/country-flags/pt.png differ
diff --git a/assets/src/img/country-flags/pw.png b/assets/src/img/country-flags/pw.png
new file mode 100644
index 0000000..df14cd8
Binary files /dev/null and b/assets/src/img/country-flags/pw.png differ
diff --git a/assets/src/img/country-flags/py.png b/assets/src/img/country-flags/py.png
new file mode 100644
index 0000000..43bd2d2
Binary files /dev/null and b/assets/src/img/country-flags/py.png differ
diff --git a/assets/src/img/country-flags/qa.png b/assets/src/img/country-flags/qa.png
new file mode 100644
index 0000000..661e936
Binary files /dev/null and b/assets/src/img/country-flags/qa.png differ
diff --git a/assets/src/img/country-flags/re.png b/assets/src/img/country-flags/re.png
new file mode 100644
index 0000000..b8e120b
Binary files /dev/null and b/assets/src/img/country-flags/re.png differ
diff --git a/assets/src/img/country-flags/ro.png b/assets/src/img/country-flags/ro.png
new file mode 100644
index 0000000..f064c1e
Binary files /dev/null and b/assets/src/img/country-flags/ro.png differ
diff --git a/assets/src/img/country-flags/rs.png b/assets/src/img/country-flags/rs.png
new file mode 100644
index 0000000..4cc2587
Binary files /dev/null and b/assets/src/img/country-flags/rs.png differ
diff --git a/assets/src/img/country-flags/ru.png b/assets/src/img/country-flags/ru.png
new file mode 100644
index 0000000..9bc3ce6
Binary files /dev/null and b/assets/src/img/country-flags/ru.png differ
diff --git a/assets/src/img/country-flags/rw.png b/assets/src/img/country-flags/rw.png
new file mode 100644
index 0000000..d76d519
Binary files /dev/null and b/assets/src/img/country-flags/rw.png differ
diff --git a/assets/src/img/country-flags/sa.png b/assets/src/img/country-flags/sa.png
new file mode 100644
index 0000000..7151fe2
Binary files /dev/null and b/assets/src/img/country-flags/sa.png differ
diff --git a/assets/src/img/country-flags/sb.png b/assets/src/img/country-flags/sb.png
new file mode 100644
index 0000000..22ff0c2
Binary files /dev/null and b/assets/src/img/country-flags/sb.png differ
diff --git a/assets/src/img/country-flags/sc.png b/assets/src/img/country-flags/sc.png
new file mode 100644
index 0000000..d9aae43
Binary files /dev/null and b/assets/src/img/country-flags/sc.png differ
diff --git a/assets/src/img/country-flags/sd.png b/assets/src/img/country-flags/sd.png
new file mode 100644
index 0000000..a79e1cb
Binary files /dev/null and b/assets/src/img/country-flags/sd.png differ
diff --git a/assets/src/img/country-flags/se.png b/assets/src/img/country-flags/se.png
new file mode 100644
index 0000000..deb3df1
Binary files /dev/null and b/assets/src/img/country-flags/se.png differ
diff --git a/assets/src/img/country-flags/sg.png b/assets/src/img/country-flags/sg.png
new file mode 100644
index 0000000..9eaaff2
Binary files /dev/null and b/assets/src/img/country-flags/sg.png differ
diff --git a/assets/src/img/country-flags/sh.png b/assets/src/img/country-flags/sh.png
new file mode 100644
index 0000000..53fdf1b
Binary files /dev/null and b/assets/src/img/country-flags/sh.png differ
diff --git a/assets/src/img/country-flags/si.png b/assets/src/img/country-flags/si.png
new file mode 100644
index 0000000..07abf09
Binary files /dev/null and b/assets/src/img/country-flags/si.png differ
diff --git a/assets/src/img/country-flags/sk.png b/assets/src/img/country-flags/sk.png
new file mode 100644
index 0000000..4741be0
Binary files /dev/null and b/assets/src/img/country-flags/sk.png differ
diff --git a/assets/src/img/country-flags/sl.png b/assets/src/img/country-flags/sl.png
new file mode 100644
index 0000000..684daeb
Binary files /dev/null and b/assets/src/img/country-flags/sl.png differ
diff --git a/assets/src/img/country-flags/sm.png b/assets/src/img/country-flags/sm.png
new file mode 100644
index 0000000..a56c085
Binary files /dev/null and b/assets/src/img/country-flags/sm.png differ
diff --git a/assets/src/img/country-flags/sn.png b/assets/src/img/country-flags/sn.png
new file mode 100644
index 0000000..0234587
Binary files /dev/null and b/assets/src/img/country-flags/sn.png differ
diff --git a/assets/src/img/country-flags/so.png b/assets/src/img/country-flags/so.png
new file mode 100644
index 0000000..8330183
Binary files /dev/null and b/assets/src/img/country-flags/so.png differ
diff --git a/assets/src/img/country-flags/sr.png b/assets/src/img/country-flags/sr.png
new file mode 100644
index 0000000..e793251
Binary files /dev/null and b/assets/src/img/country-flags/sr.png differ
diff --git a/assets/src/img/country-flags/ss.png b/assets/src/img/country-flags/ss.png
new file mode 100644
index 0000000..78a6409
Binary files /dev/null and b/assets/src/img/country-flags/ss.png differ
diff --git a/assets/src/img/country-flags/st.png b/assets/src/img/country-flags/st.png
new file mode 100644
index 0000000..e4b292c
Binary files /dev/null and b/assets/src/img/country-flags/st.png differ
diff --git a/assets/src/img/country-flags/sv.png b/assets/src/img/country-flags/sv.png
new file mode 100644
index 0000000..604e6d4
Binary files /dev/null and b/assets/src/img/country-flags/sv.png differ
diff --git a/assets/src/img/country-flags/sx.png b/assets/src/img/country-flags/sx.png
new file mode 100644
index 0000000..8b561c7
Binary files /dev/null and b/assets/src/img/country-flags/sx.png differ
diff --git a/assets/src/img/country-flags/sy.png b/assets/src/img/country-flags/sy.png
new file mode 100644
index 0000000..2ecd5a8
Binary files /dev/null and b/assets/src/img/country-flags/sy.png differ
diff --git a/assets/src/img/country-flags/sz.png b/assets/src/img/country-flags/sz.png
new file mode 100644
index 0000000..b091ceb
Binary files /dev/null and b/assets/src/img/country-flags/sz.png differ
diff --git a/assets/src/img/country-flags/tc.png b/assets/src/img/country-flags/tc.png
new file mode 100644
index 0000000..2bd0f4c
Binary files /dev/null and b/assets/src/img/country-flags/tc.png differ
diff --git a/assets/src/img/country-flags/td.png b/assets/src/img/country-flags/td.png
new file mode 100644
index 0000000..78771bf
Binary files /dev/null and b/assets/src/img/country-flags/td.png differ
diff --git a/assets/src/img/country-flags/tf.png b/assets/src/img/country-flags/tf.png
new file mode 100644
index 0000000..1458929
Binary files /dev/null and b/assets/src/img/country-flags/tf.png differ
diff --git a/assets/src/img/country-flags/tg.png b/assets/src/img/country-flags/tg.png
new file mode 100644
index 0000000..b639225
Binary files /dev/null and b/assets/src/img/country-flags/tg.png differ
diff --git a/assets/src/img/country-flags/th.png b/assets/src/img/country-flags/th.png
new file mode 100644
index 0000000..b38e353
Binary files /dev/null and b/assets/src/img/country-flags/th.png differ
diff --git a/assets/src/img/country-flags/tj.png b/assets/src/img/country-flags/tj.png
new file mode 100644
index 0000000..0dca916
Binary files /dev/null and b/assets/src/img/country-flags/tj.png differ
diff --git a/assets/src/img/country-flags/tk.png b/assets/src/img/country-flags/tk.png
new file mode 100644
index 0000000..54fb320
Binary files /dev/null and b/assets/src/img/country-flags/tk.png differ
diff --git a/assets/src/img/country-flags/tl.png b/assets/src/img/country-flags/tl.png
new file mode 100644
index 0000000..87feb92
Binary files /dev/null and b/assets/src/img/country-flags/tl.png differ
diff --git a/assets/src/img/country-flags/tm.png b/assets/src/img/country-flags/tm.png
new file mode 100644
index 0000000..f6daee1
Binary files /dev/null and b/assets/src/img/country-flags/tm.png differ
diff --git a/assets/src/img/country-flags/tn.png b/assets/src/img/country-flags/tn.png
new file mode 100644
index 0000000..199cadc
Binary files /dev/null and b/assets/src/img/country-flags/tn.png differ
diff --git a/assets/src/img/country-flags/to.png b/assets/src/img/country-flags/to.png
new file mode 100644
index 0000000..533181d
Binary files /dev/null and b/assets/src/img/country-flags/to.png differ
diff --git a/assets/src/img/country-flags/tr.png b/assets/src/img/country-flags/tr.png
new file mode 100644
index 0000000..da7239b
Binary files /dev/null and b/assets/src/img/country-flags/tr.png differ
diff --git a/assets/src/img/country-flags/tt.png b/assets/src/img/country-flags/tt.png
new file mode 100644
index 0000000..6aa844c
Binary files /dev/null and b/assets/src/img/country-flags/tt.png differ
diff --git a/assets/src/img/country-flags/tv.png b/assets/src/img/country-flags/tv.png
new file mode 100644
index 0000000..c17b10e
Binary files /dev/null and b/assets/src/img/country-flags/tv.png differ
diff --git a/assets/src/img/country-flags/tw.png b/assets/src/img/country-flags/tw.png
new file mode 100644
index 0000000..df5d0d8
Binary files /dev/null and b/assets/src/img/country-flags/tw.png differ
diff --git a/assets/src/img/country-flags/tz.png b/assets/src/img/country-flags/tz.png
new file mode 100644
index 0000000..95daf34
Binary files /dev/null and b/assets/src/img/country-flags/tz.png differ
diff --git a/assets/src/img/country-flags/ua.png b/assets/src/img/country-flags/ua.png
new file mode 100644
index 0000000..09e4890
Binary files /dev/null and b/assets/src/img/country-flags/ua.png differ
diff --git a/assets/src/img/country-flags/ug.png b/assets/src/img/country-flags/ug.png
new file mode 100644
index 0000000..4970d3d
Binary files /dev/null and b/assets/src/img/country-flags/ug.png differ
diff --git a/assets/src/img/country-flags/us.png b/assets/src/img/country-flags/us.png
new file mode 100644
index 0000000..53c4ba1
Binary files /dev/null and b/assets/src/img/country-flags/us.png differ
diff --git a/assets/src/img/country-flags/uy.png b/assets/src/img/country-flags/uy.png
new file mode 100644
index 0000000..fdeee28
Binary files /dev/null and b/assets/src/img/country-flags/uy.png differ
diff --git a/assets/src/img/country-flags/uz.png b/assets/src/img/country-flags/uz.png
new file mode 100644
index 0000000..e9ab4eb
Binary files /dev/null and b/assets/src/img/country-flags/uz.png differ
diff --git a/assets/src/img/country-flags/va.png b/assets/src/img/country-flags/va.png
new file mode 100644
index 0000000..32356ad
Binary files /dev/null and b/assets/src/img/country-flags/va.png differ
diff --git a/assets/src/img/country-flags/vc.png b/assets/src/img/country-flags/vc.png
new file mode 100644
index 0000000..1b6b1f6
Binary files /dev/null and b/assets/src/img/country-flags/vc.png differ
diff --git a/assets/src/img/country-flags/ve.png b/assets/src/img/country-flags/ve.png
new file mode 100644
index 0000000..78a43da
Binary files /dev/null and b/assets/src/img/country-flags/ve.png differ
diff --git a/assets/src/img/country-flags/vg.png b/assets/src/img/country-flags/vg.png
new file mode 100644
index 0000000..4a599de
Binary files /dev/null and b/assets/src/img/country-flags/vg.png differ
diff --git a/assets/src/img/country-flags/vi.png b/assets/src/img/country-flags/vi.png
new file mode 100644
index 0000000..0d97f68
Binary files /dev/null and b/assets/src/img/country-flags/vi.png differ
diff --git a/assets/src/img/country-flags/vn.png b/assets/src/img/country-flags/vn.png
new file mode 100644
index 0000000..57a0848
Binary files /dev/null and b/assets/src/img/country-flags/vn.png differ
diff --git a/assets/src/img/country-flags/vu.png b/assets/src/img/country-flags/vu.png
new file mode 100644
index 0000000..8c40151
Binary files /dev/null and b/assets/src/img/country-flags/vu.png differ
diff --git a/assets/src/img/country-flags/ws.png b/assets/src/img/country-flags/ws.png
new file mode 100644
index 0000000..1c0cadd
Binary files /dev/null and b/assets/src/img/country-flags/ws.png differ
diff --git a/assets/src/img/country-flags/ye.png b/assets/src/img/country-flags/ye.png
new file mode 100644
index 0000000..a9d71cf
Binary files /dev/null and b/assets/src/img/country-flags/ye.png differ
diff --git a/assets/src/img/country-flags/za.png b/assets/src/img/country-flags/za.png
new file mode 100644
index 0000000..9d14f3e
Binary files /dev/null and b/assets/src/img/country-flags/za.png differ
diff --git a/assets/src/img/country-flags/zm.png b/assets/src/img/country-flags/zm.png
new file mode 100644
index 0000000..103232f
Binary files /dev/null and b/assets/src/img/country-flags/zm.png differ
diff --git a/assets/src/img/country-flags/zw.png b/assets/src/img/country-flags/zw.png
new file mode 100644
index 0000000..6a19b44
Binary files /dev/null and b/assets/src/img/country-flags/zw.png differ
diff --git a/assets/src/img/screenshot.png b/assets/src/img/screenshot.png
new file mode 100644
index 0000000..5b79b6c
Binary files /dev/null and b/assets/src/img/screenshot.png differ
diff --git a/assets/src/index.html b/assets/src/index.html
new file mode 100644
index 0000000..deb91b5
--- /dev/null
+++ b/assets/src/index.html
@@ -0,0 +1,14 @@
+
+
+
+ Ana - open web analytics
+
+
+
+
+
+
+
+
diff --git a/assets/js/components/CountWidget.js b/assets/src/js/components/CountWidget.js
similarity index 100%
rename from assets/js/components/CountWidget.js
rename to assets/src/js/components/CountWidget.js
diff --git a/assets/js/components/DatePicker.js b/assets/src/js/components/DatePicker.js
similarity index 100%
rename from assets/js/components/DatePicker.js
rename to assets/src/js/components/DatePicker.js
diff --git a/assets/js/components/Graph.js b/assets/src/js/components/Graph.js
similarity index 100%
rename from assets/js/components/Graph.js
rename to assets/src/js/components/Graph.js
diff --git a/assets/js/components/GraphWidget.js b/assets/src/js/components/GraphWidget.js
similarity index 100%
rename from assets/js/components/GraphWidget.js
rename to assets/src/js/components/GraphWidget.js
diff --git a/assets/js/components/HeaderBar.js b/assets/src/js/components/HeaderBar.js
similarity index 100%
rename from assets/js/components/HeaderBar.js
rename to assets/src/js/components/HeaderBar.js
diff --git a/assets/js/components/LoginForm.js b/assets/src/js/components/LoginForm.js
similarity index 100%
rename from assets/js/components/LoginForm.js
rename to assets/src/js/components/LoginForm.js
diff --git a/assets/js/components/LogoutButton.js b/assets/src/js/components/LogoutButton.js
similarity index 100%
rename from assets/js/components/LogoutButton.js
rename to assets/src/js/components/LogoutButton.js
diff --git a/assets/js/components/Notification.js b/assets/src/js/components/Notification.js
similarity index 100%
rename from assets/js/components/Notification.js
rename to assets/src/js/components/Notification.js
diff --git a/assets/js/components/Pageviews.js b/assets/src/js/components/Pageviews.js
similarity index 100%
rename from assets/js/components/Pageviews.js
rename to assets/src/js/components/Pageviews.js
diff --git a/assets/js/components/Realtime.js b/assets/src/js/components/Realtime.js
similarity index 100%
rename from assets/js/components/Realtime.js
rename to assets/src/js/components/Realtime.js
diff --git a/assets/js/components/Table.js b/assets/src/js/components/Table.js
similarity index 100%
rename from assets/js/components/Table.js
rename to assets/src/js/components/Table.js
diff --git a/assets/js/lib/client.js b/assets/src/js/lib/client.js
similarity index 100%
rename from assets/js/lib/client.js
rename to assets/src/js/lib/client.js
diff --git a/assets/js/lib/numbers.js b/assets/src/js/lib/numbers.js
similarity index 100%
rename from assets/js/lib/numbers.js
rename to assets/src/js/lib/numbers.js
diff --git a/assets/js/pages/dashboard.js b/assets/src/js/pages/dashboard.js
similarity index 100%
rename from assets/js/pages/dashboard.js
rename to assets/src/js/pages/dashboard.js
diff --git a/assets/js/pages/login.js b/assets/src/js/pages/login.js
similarity index 100%
rename from assets/js/pages/login.js
rename to assets/src/js/pages/login.js
diff --git a/assets/js/script.js b/assets/src/js/script.js
similarity index 100%
rename from assets/js/script.js
rename to assets/src/js/script.js
diff --git a/assets/src/js/tracker.js b/assets/src/js/tracker.js
new file mode 100644
index 0000000..2eb4da6
--- /dev/null
+++ b/assets/src/js/tracker.js
@@ -0,0 +1,69 @@
+'use strict';
+
+var queue = window.ana.q || [];
+var trackerUrl = '//ana.dev/collect';
+var commands = {
+ "trackPageview": trackPageview,
+ "setTrackerUrl": setTrackerUrl,
+};
+
+// convert object to query string
+function stringifyObject(json) {
+ var keys = Object.keys(json);
+
+ // omit empty
+ keys = keys.filter(function(k) {
+ return json[k].length > 0;
+ });
+
+ return '?' +
+ keys.map(function(k) {
+ return encodeURIComponent(k) + '=' +
+ encodeURIComponent(json[k]);
+ }).join('&');
+}
+
+function setTrackerUrl(v) {
+ trackerUrl = v;
+}
+
+function trackPageview() {
+ // Respect "Do Not Track" requests
+ if( navigator.DonotTrack == 1 ) {
+ return;
+ }
+
+ // get the path or canonical
+ var path = location.pathname + location.search;
+ var canonical = document.querySelector('link[rel="canonical"]');
+ if(canonical && canonical.href) {
+ path = canonical.href.substring(canonical.href.indexOf('/', 7)) || '/';
+ }
+
+ var d = {
+ h: location.hostname,
+ t: document.title,
+ l: navigator.language,
+ p: path,
+ sr: screen.width + "x" + screen.height,
+ t: document.title,
+ ru: document.referrer,
+ rk: ""
+ };
+
+ var i = document.createElement('img');
+ i.src = trackerUrl + stringifyObject(d);
+ document.body.appendChild(i);
+}
+
+// override global ana object
+window.ana = function() {
+ var args = [].slice.call(arguments);
+ var c = args.shift();
+ commands[c].apply(this, args);
+};
+
+// process existing queue
+queue.forEach(function(i) {
+ ana.apply(this, i);
+});
diff --git a/assets/sass/_forms.scss b/assets/src/sass/_forms.scss
similarity index 100%
rename from assets/sass/_forms.scss
rename to assets/src/sass/_forms.scss
diff --git a/assets/sass/_graphs.scss b/assets/src/sass/_graphs.scss
similarity index 100%
rename from assets/sass/_graphs.scss
rename to assets/src/sass/_graphs.scss
diff --git a/assets/sass/_grid.scss b/assets/src/sass/_grid.scss
similarity index 100%
rename from assets/sass/_grid.scss
rename to assets/src/sass/_grid.scss
diff --git a/assets/sass/_normalize.scss b/assets/src/sass/_normalize.scss
similarity index 100%
rename from assets/sass/_normalize.scss
rename to assets/src/sass/_normalize.scss
diff --git a/assets/sass/_tables.scss b/assets/src/sass/_tables.scss
similarity index 100%
rename from assets/sass/_tables.scss
rename to assets/src/sass/_tables.scss
diff --git a/assets/sass/_util.scss b/assets/src/sass/_util.scss
similarity index 100%
rename from assets/sass/_util.scss
rename to assets/src/sass/_util.scss
diff --git a/assets/sass/styles.scss b/assets/src/sass/styles.scss
similarity index 100%
rename from assets/sass/styles.scss
rename to assets/src/sass/styles.scss
diff --git a/gulpfile.js b/gulpfile.js
index 9979ed7..5f6abdd 100644
--- a/gulpfile.js
+++ b/gulpfile.js
@@ -12,7 +12,7 @@ const uglify = require('gulp-uglify')
const pump = require('pump')
const debug = process.env.NODE_ENV !== 'production';
-let defaultTasks = [ 'browserify', 'sass', 'tracker' ] ;
+let defaultTasks = [ 'browserify', 'sass', 'tracker', 'html', 'img' ] ;
if( ! debug ) {
defaultTasks.push( 'minify' );
}
@@ -21,7 +21,7 @@ gulp.task('default', defaultTasks);
gulp.task('browserify', function () {
return browserify({
- entries: './assets/js/script.js',
+ entries: './assets/src/js/script.js',
debug: debug
})
.transform("babelify", {presets: ["es2015"]})
@@ -32,40 +32,44 @@ gulp.task('browserify', function () {
})
.pipe(source('script.js'))
.pipe(buffer())
- .pipe(gulp.dest('./static/js/'))
+ .pipe(gulp.dest('./assets/dist/js/'))
});
gulp.task('minify', function(cb) {
process.env.NODE_ENV = 'production';
pump([
- gulp.src('./static/js/*.js'),
+ gulp.src('./assets/dist/js/*.js'),
uglify().on('error', gutil.log),
- gulp.dest('./static/js/')
+ gulp.dest('./assets/dist/js/')
], cb)
});
gulp.task('img', function() {
- return gulp.src('./assets/img/**/*')
- .pipe(gulp.dest('./static/img'))
+ return gulp.src('./assets/src/img/**/*')
+ .pipe(gulp.dest('./assets/dist/img'))
});
+gulp.task('html', function() {
+ return gulp.src('./assets/src/**/*.html')
+ .pipe(gulp.dest('./assets/dist'))
+});
gulp.task('tracker', function() {
- return gulp.src('./assets/js/tracker.js')
- .pipe(gulp.dest('./static/js'))
+ return gulp.src('./assets/src/js/tracker.js')
+ .pipe(gulp.dest('./assets/dist/js'))
});
gulp.task('sass', function () {
- var files = './assets/sass/[^_]*.scss';
+ var files = './assets/src/sass/[^_]*.scss';
return gulp.src(files)
.pipe(sass())
.on('error', gutil.log)
.pipe(rename({ extname: '.css' }))
- .pipe(gulp.dest('./static/css'))
+ .pipe(gulp.dest('./assets/dist/css'))
});
gulp.task('watch', ['default'], function() {
- gulp.watch(['./assets/js/**/*.js'], ['browserify', 'tracker'] );
- gulp.watch(['./assets/sass/**/**/*.scss'], ['sass'] );
+ gulp.watch(['./assets/src/js/**/*.js'], ['browserify', 'tracker'] );
+ gulp.watch(['./assets/src/sass/**/**/*.scss'], ['sass'] );
});
diff --git a/package-lock.json b/package-lock.json
new file mode 100644
index 0000000..5573cfc
--- /dev/null
+++ b/package-lock.json
@@ -0,0 +1,5924 @@
+{
+ "requires": true,
+ "lockfileVersion": 1,
+ "dependencies": {
+ "JSONStream": {
+ "version": "1.3.2",
+ "resolved": "https://registry.npmjs.org/JSONStream/-/JSONStream-1.3.2.tgz",
+ "integrity": "sha1-wQI3G27Dp887hHygDCC7D85Mbeo=",
+ "dev": true,
+ "requires": {
+ "jsonparse": "1.3.1",
+ "through": "2.3.8"
+ }
+ },
+ "abbrev": {
+ "version": "1.1.1",
+ "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz",
+ "integrity": "sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==",
+ "dev": true
+ },
+ "acorn": {
+ "version": "4.0.13",
+ "resolved": "https://registry.npmjs.org/acorn/-/acorn-4.0.13.tgz",
+ "integrity": "sha1-EFSVrlNh1pe9GVyCUZLhrX8lN4c=",
+ "dev": true
+ },
+ "acorn-node": {
+ "version": "1.3.0",
+ "resolved": "https://registry.npmjs.org/acorn-node/-/acorn-node-1.3.0.tgz",
+ "integrity": "sha512-efP54n3d1aLfjL2UMdaXa6DsswwzJeI5rqhbFvXMrKiJ6eJFpf+7R0zN7t8IC+XKn2YOAFAv6xbBNgHUkoHWLw==",
+ "dev": true,
+ "requires": {
+ "acorn": "5.5.3",
+ "xtend": "4.0.1"
+ },
+ "dependencies": {
+ "acorn": {
+ "version": "5.5.3",
+ "resolved": "https://registry.npmjs.org/acorn/-/acorn-5.5.3.tgz",
+ "integrity": "sha512-jd5MkIUlbbmb07nXH0DT3y7rDVtkzDi4XZOUVWAer8ajmF/DTSSbl5oNFyDOl/OXA33Bl79+ypHhl2pN20VeOQ==",
+ "dev": true
+ }
+ }
+ },
+ "ajv": {
+ "version": "5.5.2",
+ "resolved": "https://registry.npmjs.org/ajv/-/ajv-5.5.2.tgz",
+ "integrity": "sha1-c7Xuyj+rZT49P5Qis0GtQiBdyWU=",
+ "dev": true,
+ "requires": {
+ "co": "4.6.0",
+ "fast-deep-equal": "1.1.0",
+ "fast-json-stable-stringify": "2.0.0",
+ "json-schema-traverse": "0.3.1"
+ }
+ },
+ "align-text": {
+ "version": "0.1.4",
+ "resolved": "https://registry.npmjs.org/align-text/-/align-text-0.1.4.tgz",
+ "integrity": "sha1-DNkKVhCT810KmSVsIrcGlDP60Rc=",
+ "requires": {
+ "kind-of": "3.2.2",
+ "longest": "1.0.1",
+ "repeat-string": "1.6.1"
+ }
+ },
+ "amdefine": {
+ "version": "1.0.1",
+ "resolved": "https://registry.npmjs.org/amdefine/-/amdefine-1.0.1.tgz",
+ "integrity": "sha1-SlKCrBZHKek2Gbz9OtFR+BfOkfU=",
+ "dev": true
+ },
+ "ansi-gray": {
+ "version": "0.1.1",
+ "resolved": "https://registry.npmjs.org/ansi-gray/-/ansi-gray-0.1.1.tgz",
+ "integrity": "sha1-KWLPVOyXksSFEKPetSRDaGHvclE=",
+ "dev": true,
+ "requires": {
+ "ansi-wrap": "0.1.0"
+ }
+ },
+ "ansi-regex": {
+ "version": "2.1.1",
+ "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz",
+ "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=",
+ "dev": true
+ },
+ "ansi-styles": {
+ "version": "2.2.1",
+ "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz",
+ "integrity": "sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4=",
+ "dev": true
+ },
+ "ansi-wrap": {
+ "version": "0.1.0",
+ "resolved": "https://registry.npmjs.org/ansi-wrap/-/ansi-wrap-0.1.0.tgz",
+ "integrity": "sha1-qCJQ3bABXponyoLoLqYDu/pF768=",
+ "dev": true
+ },
+ "aproba": {
+ "version": "1.2.0",
+ "resolved": "https://registry.npmjs.org/aproba/-/aproba-1.2.0.tgz",
+ "integrity": "sha512-Y9J6ZjXtoYh8RnXVCMOU/ttDmk1aBjunq9vO0ta5x85WDQiQfUF9sIPBITdbiiIVcBo03Hi3jMxigBtsddlXRw==",
+ "dev": true
+ },
+ "archy": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/archy/-/archy-1.0.0.tgz",
+ "integrity": "sha1-+cjBN1fMHde8N5rHeyxipcKGjEA=",
+ "dev": true
+ },
+ "are-we-there-yet": {
+ "version": "1.1.4",
+ "resolved": "https://registry.npmjs.org/are-we-there-yet/-/are-we-there-yet-1.1.4.tgz",
+ "integrity": "sha1-u13KOCu5TwXhUZQ3PRb9O6HKEQ0=",
+ "dev": true,
+ "requires": {
+ "delegates": "1.0.0",
+ "readable-stream": "2.3.6"
+ }
+ },
+ "arr-diff": {
+ "version": "4.0.0",
+ "resolved": "https://registry.npmjs.org/arr-diff/-/arr-diff-4.0.0.tgz",
+ "integrity": "sha1-1kYQdP6/7HHn4VI1dhoyml3HxSA=",
+ "dev": true
+ },
+ "arr-flatten": {
+ "version": "1.1.0",
+ "resolved": "https://registry.npmjs.org/arr-flatten/-/arr-flatten-1.1.0.tgz",
+ "integrity": "sha512-L3hKV5R/p5o81R7O02IGnwpDmkp6E982XhtbuwSe3O4qOtMMMtodicASA1Cny2U+aCXcNpml+m4dPsvsJ3jatg==",
+ "dev": true
+ },
+ "arr-union": {
+ "version": "3.1.0",
+ "resolved": "https://registry.npmjs.org/arr-union/-/arr-union-3.1.0.tgz",
+ "integrity": "sha1-45sJrqne+Gao8gbiiK9jkZuuOcQ=",
+ "dev": true
+ },
+ "array-differ": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/array-differ/-/array-differ-1.0.0.tgz",
+ "integrity": "sha1-7/UuN1gknTO+QCuLuOVkuytdQDE=",
+ "dev": true
+ },
+ "array-each": {
+ "version": "1.0.1",
+ "resolved": "https://registry.npmjs.org/array-each/-/array-each-1.0.1.tgz",
+ "integrity": "sha1-p5SvDAWrF1KEbudTofIRoFugxE8=",
+ "dev": true
+ },
+ "array-filter": {
+ "version": "0.0.1",
+ "resolved": "https://registry.npmjs.org/array-filter/-/array-filter-0.0.1.tgz",
+ "integrity": "sha1-fajPLiZijtcygDWB/SH2fKzS7uw=",
+ "dev": true
+ },
+ "array-find-index": {
+ "version": "1.0.2",
+ "resolved": "https://registry.npmjs.org/array-find-index/-/array-find-index-1.0.2.tgz",
+ "integrity": "sha1-3wEKoSh+Fku9pvlyOwqWoexBh6E=",
+ "dev": true
+ },
+ "array-map": {
+ "version": "0.0.0",
+ "resolved": "https://registry.npmjs.org/array-map/-/array-map-0.0.0.tgz",
+ "integrity": "sha1-iKK6tz0c97zVwbEYoAP2b2ZfpmI=",
+ "dev": true
+ },
+ "array-reduce": {
+ "version": "0.0.0",
+ "resolved": "https://registry.npmjs.org/array-reduce/-/array-reduce-0.0.0.tgz",
+ "integrity": "sha1-FziZ0//Rx9k4PkR5Ul2+J4yrXys=",
+ "dev": true
+ },
+ "array-slice": {
+ "version": "1.1.0",
+ "resolved": "https://registry.npmjs.org/array-slice/-/array-slice-1.1.0.tgz",
+ "integrity": "sha512-B1qMD3RBP7O8o0H2KbrXDyB0IccejMF15+87Lvlor12ONPRHP6gTjXMNkt/d3ZuOGbAe66hFmaCfECI24Ufp6w==",
+ "dev": true
+ },
+ "array-uniq": {
+ "version": "1.0.3",
+ "resolved": "https://registry.npmjs.org/array-uniq/-/array-uniq-1.0.3.tgz",
+ "integrity": "sha1-r2rId6Jcx/dOBYiUdThY39sk/bY=",
+ "dev": true
+ },
+ "array-unique": {
+ "version": "0.3.2",
+ "resolved": "https://registry.npmjs.org/array-unique/-/array-unique-0.3.2.tgz",
+ "integrity": "sha1-qJS3XUvE9s1nnvMkSp/Y9Gri1Cg=",
+ "dev": true
+ },
+ "asn1": {
+ "version": "0.2.3",
+ "resolved": "https://registry.npmjs.org/asn1/-/asn1-0.2.3.tgz",
+ "integrity": "sha1-2sh4dxPJlmhJ/IGAd36+nB3fO4Y=",
+ "dev": true
+ },
+ "asn1.js": {
+ "version": "4.10.1",
+ "resolved": "https://registry.npmjs.org/asn1.js/-/asn1.js-4.10.1.tgz",
+ "integrity": "sha512-p32cOF5q0Zqs9uBiONKYLm6BClCoBCM5O9JfeUSlnQLBTxYdTK+pW+nXflm8UkKd2UYlEbYz5qEi0JuZR9ckSw==",
+ "dev": true,
+ "requires": {
+ "bn.js": "4.11.8",
+ "inherits": "2.0.3",
+ "minimalistic-assert": "1.0.1"
+ }
+ },
+ "assert": {
+ "version": "1.4.1",
+ "resolved": "https://registry.npmjs.org/assert/-/assert-1.4.1.tgz",
+ "integrity": "sha1-mZEtWRg2tab1s0XA8H7vwI/GXZE=",
+ "dev": true,
+ "requires": {
+ "util": "0.10.3"
+ }
+ },
+ "assert-plus": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz",
+ "integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU=",
+ "dev": true
+ },
+ "assign-symbols": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/assign-symbols/-/assign-symbols-1.0.0.tgz",
+ "integrity": "sha1-WWZ/QfrdTyDMvCu5a41Pf3jsA2c=",
+ "dev": true
+ },
+ "astw": {
+ "version": "2.2.0",
+ "resolved": "https://registry.npmjs.org/astw/-/astw-2.2.0.tgz",
+ "integrity": "sha1-e9QXhNMkk5h66yOba04cV6hzuRc=",
+ "dev": true,
+ "requires": {
+ "acorn": "4.0.13"
+ }
+ },
+ "async-foreach": {
+ "version": "0.1.3",
+ "resolved": "https://registry.npmjs.org/async-foreach/-/async-foreach-0.1.3.tgz",
+ "integrity": "sha1-NhIfhFwFeBct5Bmpfb6x0W7DRUI=",
+ "dev": true
+ },
+ "asynckit": {
+ "version": "0.4.0",
+ "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz",
+ "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=",
+ "dev": true
+ },
+ "atob": {
+ "version": "2.1.0",
+ "resolved": "https://registry.npmjs.org/atob/-/atob-2.1.0.tgz",
+ "integrity": "sha512-SuiKH8vbsOyCALjA/+EINmt/Kdl+TQPrtFgW7XZZcwtryFu9e5kQoX3bjCW6mIvGH1fbeAZZuvwGR5IlBRznGw==",
+ "dev": true
+ },
+ "aws-sign2": {
+ "version": "0.7.0",
+ "resolved": "https://registry.npmjs.org/aws-sign2/-/aws-sign2-0.7.0.tgz",
+ "integrity": "sha1-tG6JCTSpWR8tL2+G1+ap8bP+dqg=",
+ "dev": true
+ },
+ "aws4": {
+ "version": "1.7.0",
+ "resolved": "https://registry.npmjs.org/aws4/-/aws4-1.7.0.tgz",
+ "integrity": "sha512-32NDda82rhwD9/JBCCkB+MRYDp0oSvlo2IL6rQWA10PQi7tDUM3eqMSltXmY+Oyl/7N3P3qNtAlv7X0d9bI28w==",
+ "dev": true
+ },
+ "babel-code-frame": {
+ "version": "6.26.0",
+ "resolved": "https://registry.npmjs.org/babel-code-frame/-/babel-code-frame-6.26.0.tgz",
+ "integrity": "sha1-Y/1D99weO7fONZR9uP42mj9Yx0s=",
+ "dev": true,
+ "requires": {
+ "chalk": "1.1.3",
+ "esutils": "2.0.2",
+ "js-tokens": "3.0.2"
+ }
+ },
+ "babel-core": {
+ "version": "6.26.0",
+ "resolved": "https://registry.npmjs.org/babel-core/-/babel-core-6.26.0.tgz",
+ "integrity": "sha1-rzL3izGm/O8RnIew/Y2XU/A6C7g=",
+ "dev": true,
+ "requires": {
+ "babel-code-frame": "6.26.0",
+ "babel-generator": "6.26.1",
+ "babel-helpers": "6.24.1",
+ "babel-messages": "6.23.0",
+ "babel-register": "6.26.0",
+ "babel-runtime": "6.26.0",
+ "babel-template": "6.26.0",
+ "babel-traverse": "6.26.0",
+ "babel-types": "6.26.0",
+ "babylon": "6.18.0",
+ "convert-source-map": "1.5.1",
+ "debug": "2.6.9",
+ "json5": "0.5.1",
+ "lodash": "4.17.5",
+ "minimatch": "3.0.4",
+ "path-is-absolute": "1.0.1",
+ "private": "0.1.8",
+ "slash": "1.0.0",
+ "source-map": "0.5.7"
+ }
+ },
+ "babel-generator": {
+ "version": "6.26.1",
+ "resolved": "https://registry.npmjs.org/babel-generator/-/babel-generator-6.26.1.tgz",
+ "integrity": "sha512-HyfwY6ApZj7BYTcJURpM5tznulaBvyio7/0d4zFOeMPUmfxkCjHocCuoLa2SAGzBI8AREcH3eP3758F672DppA==",
+ "dev": true,
+ "requires": {
+ "babel-messages": "6.23.0",
+ "babel-runtime": "6.26.0",
+ "babel-types": "6.26.0",
+ "detect-indent": "4.0.0",
+ "jsesc": "1.3.0",
+ "lodash": "4.17.5",
+ "source-map": "0.5.7",
+ "trim-right": "1.0.1"
+ },
+ "dependencies": {
+ "jsesc": {
+ "version": "1.3.0",
+ "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-1.3.0.tgz",
+ "integrity": "sha1-RsP+yMGJKxKwgz25vHYiF226s0s=",
+ "dev": true
+ }
+ }
+ },
+ "babel-helper-builder-react-jsx": {
+ "version": "6.26.0",
+ "resolved": "https://registry.npmjs.org/babel-helper-builder-react-jsx/-/babel-helper-builder-react-jsx-6.26.0.tgz",
+ "integrity": "sha1-Of+DE7dci2Xc7/HzHTg+D/KkCKA=",
+ "dev": true,
+ "requires": {
+ "babel-runtime": "6.26.0",
+ "babel-types": "6.26.0",
+ "esutils": "2.0.2"
+ }
+ },
+ "babel-helper-call-delegate": {
+ "version": "6.24.1",
+ "resolved": "https://registry.npmjs.org/babel-helper-call-delegate/-/babel-helper-call-delegate-6.24.1.tgz",
+ "integrity": "sha1-7Oaqzdx25Bw0YfiL/Fdb0Nqi340=",
+ "dev": true,
+ "requires": {
+ "babel-helper-hoist-variables": "6.24.1",
+ "babel-runtime": "6.26.0",
+ "babel-traverse": "6.26.0",
+ "babel-types": "6.26.0"
+ }
+ },
+ "babel-helper-define-map": {
+ "version": "6.26.0",
+ "resolved": "https://registry.npmjs.org/babel-helper-define-map/-/babel-helper-define-map-6.26.0.tgz",
+ "integrity": "sha1-pfVtq0GiX5fstJjH66ypgZ+Vvl8=",
+ "dev": true,
+ "requires": {
+ "babel-helper-function-name": "6.24.1",
+ "babel-runtime": "6.26.0",
+ "babel-types": "6.26.0",
+ "lodash": "4.17.5"
+ }
+ },
+ "babel-helper-function-name": {
+ "version": "6.24.1",
+ "resolved": "https://registry.npmjs.org/babel-helper-function-name/-/babel-helper-function-name-6.24.1.tgz",
+ "integrity": "sha1-00dbjAPtmCQqJbSDUasYOZ01gKk=",
+ "dev": true,
+ "requires": {
+ "babel-helper-get-function-arity": "6.24.1",
+ "babel-runtime": "6.26.0",
+ "babel-template": "6.26.0",
+ "babel-traverse": "6.26.0",
+ "babel-types": "6.26.0"
+ }
+ },
+ "babel-helper-get-function-arity": {
+ "version": "6.24.1",
+ "resolved": "https://registry.npmjs.org/babel-helper-get-function-arity/-/babel-helper-get-function-arity-6.24.1.tgz",
+ "integrity": "sha1-j3eCqpNAfEHTqlCQj4mwMbG2hT0=",
+ "dev": true,
+ "requires": {
+ "babel-runtime": "6.26.0",
+ "babel-types": "6.26.0"
+ }
+ },
+ "babel-helper-hoist-variables": {
+ "version": "6.24.1",
+ "resolved": "https://registry.npmjs.org/babel-helper-hoist-variables/-/babel-helper-hoist-variables-6.24.1.tgz",
+ "integrity": "sha1-HssnaJydJVE+rbyZFKc/VAi+enY=",
+ "dev": true,
+ "requires": {
+ "babel-runtime": "6.26.0",
+ "babel-types": "6.26.0"
+ }
+ },
+ "babel-helper-optimise-call-expression": {
+ "version": "6.24.1",
+ "resolved": "https://registry.npmjs.org/babel-helper-optimise-call-expression/-/babel-helper-optimise-call-expression-6.24.1.tgz",
+ "integrity": "sha1-96E0J7qfc/j0+pk8VKl4gtEkQlc=",
+ "dev": true,
+ "requires": {
+ "babel-runtime": "6.26.0",
+ "babel-types": "6.26.0"
+ }
+ },
+ "babel-helper-regex": {
+ "version": "6.26.0",
+ "resolved": "https://registry.npmjs.org/babel-helper-regex/-/babel-helper-regex-6.26.0.tgz",
+ "integrity": "sha1-MlxZ+QL4LyS3T6zu0DY5VPZJXnI=",
+ "dev": true,
+ "requires": {
+ "babel-runtime": "6.26.0",
+ "babel-types": "6.26.0",
+ "lodash": "4.17.5"
+ }
+ },
+ "babel-helper-replace-supers": {
+ "version": "6.24.1",
+ "resolved": "https://registry.npmjs.org/babel-helper-replace-supers/-/babel-helper-replace-supers-6.24.1.tgz",
+ "integrity": "sha1-v22/5Dk40XNpohPKiov3S2qQqxo=",
+ "dev": true,
+ "requires": {
+ "babel-helper-optimise-call-expression": "6.24.1",
+ "babel-messages": "6.23.0",
+ "babel-runtime": "6.26.0",
+ "babel-template": "6.26.0",
+ "babel-traverse": "6.26.0",
+ "babel-types": "6.26.0"
+ }
+ },
+ "babel-helpers": {
+ "version": "6.24.1",
+ "resolved": "https://registry.npmjs.org/babel-helpers/-/babel-helpers-6.24.1.tgz",
+ "integrity": "sha1-NHHenK7DiOXIUOWX5Yom3fN2ArI=",
+ "dev": true,
+ "requires": {
+ "babel-runtime": "6.26.0",
+ "babel-template": "6.26.0"
+ }
+ },
+ "babel-messages": {
+ "version": "6.23.0",
+ "resolved": "https://registry.npmjs.org/babel-messages/-/babel-messages-6.23.0.tgz",
+ "integrity": "sha1-8830cDhYA1sqKVHG7F7fbGLyYw4=",
+ "dev": true,
+ "requires": {
+ "babel-runtime": "6.26.0"
+ }
+ },
+ "babel-plugin-check-es2015-constants": {
+ "version": "6.22.0",
+ "resolved": "https://registry.npmjs.org/babel-plugin-check-es2015-constants/-/babel-plugin-check-es2015-constants-6.22.0.tgz",
+ "integrity": "sha1-NRV7EBQm/S/9PaP3XH0ekYNbv4o=",
+ "dev": true,
+ "requires": {
+ "babel-runtime": "6.26.0"
+ }
+ },
+ "babel-plugin-syntax-jsx": {
+ "version": "6.18.0",
+ "resolved": "https://registry.npmjs.org/babel-plugin-syntax-jsx/-/babel-plugin-syntax-jsx-6.18.0.tgz",
+ "integrity": "sha1-CvMqmm4Tyno/1QaeYtew9Y0NiUY=",
+ "dev": true
+ },
+ "babel-plugin-transform-es2015-arrow-functions": {
+ "version": "6.22.0",
+ "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-arrow-functions/-/babel-plugin-transform-es2015-arrow-functions-6.22.0.tgz",
+ "integrity": "sha1-RSaSy3EdX3ncf4XkQM5BufJE0iE=",
+ "dev": true,
+ "requires": {
+ "babel-runtime": "6.26.0"
+ }
+ },
+ "babel-plugin-transform-es2015-block-scoped-functions": {
+ "version": "6.22.0",
+ "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-block-scoped-functions/-/babel-plugin-transform-es2015-block-scoped-functions-6.22.0.tgz",
+ "integrity": "sha1-u8UbSflk1wy42OC5ToICRs46YUE=",
+ "dev": true,
+ "requires": {
+ "babel-runtime": "6.26.0"
+ }
+ },
+ "babel-plugin-transform-es2015-block-scoping": {
+ "version": "6.26.0",
+ "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-block-scoping/-/babel-plugin-transform-es2015-block-scoping-6.26.0.tgz",
+ "integrity": "sha1-1w9SmcEwjQXBL0Y4E7CgnnOxiV8=",
+ "dev": true,
+ "requires": {
+ "babel-runtime": "6.26.0",
+ "babel-template": "6.26.0",
+ "babel-traverse": "6.26.0",
+ "babel-types": "6.26.0",
+ "lodash": "4.17.5"
+ }
+ },
+ "babel-plugin-transform-es2015-classes": {
+ "version": "6.24.1",
+ "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-classes/-/babel-plugin-transform-es2015-classes-6.24.1.tgz",
+ "integrity": "sha1-WkxYpQyclGHlZLSyo7+ryXolhNs=",
+ "dev": true,
+ "requires": {
+ "babel-helper-define-map": "6.26.0",
+ "babel-helper-function-name": "6.24.1",
+ "babel-helper-optimise-call-expression": "6.24.1",
+ "babel-helper-replace-supers": "6.24.1",
+ "babel-messages": "6.23.0",
+ "babel-runtime": "6.26.0",
+ "babel-template": "6.26.0",
+ "babel-traverse": "6.26.0",
+ "babel-types": "6.26.0"
+ }
+ },
+ "babel-plugin-transform-es2015-computed-properties": {
+ "version": "6.24.1",
+ "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-computed-properties/-/babel-plugin-transform-es2015-computed-properties-6.24.1.tgz",
+ "integrity": "sha1-b+Ko0WiV1WNPTNmZttNICjCBWbM=",
+ "dev": true,
+ "requires": {
+ "babel-runtime": "6.26.0",
+ "babel-template": "6.26.0"
+ }
+ },
+ "babel-plugin-transform-es2015-destructuring": {
+ "version": "6.23.0",
+ "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-destructuring/-/babel-plugin-transform-es2015-destructuring-6.23.0.tgz",
+ "integrity": "sha1-mXux8auWf2gtKwh2/jWNYOdlxW0=",
+ "dev": true,
+ "requires": {
+ "babel-runtime": "6.26.0"
+ }
+ },
+ "babel-plugin-transform-es2015-duplicate-keys": {
+ "version": "6.24.1",
+ "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-duplicate-keys/-/babel-plugin-transform-es2015-duplicate-keys-6.24.1.tgz",
+ "integrity": "sha1-c+s9MQypaePvnskcU3QabxV2Qj4=",
+ "dev": true,
+ "requires": {
+ "babel-runtime": "6.26.0",
+ "babel-types": "6.26.0"
+ }
+ },
+ "babel-plugin-transform-es2015-for-of": {
+ "version": "6.23.0",
+ "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-for-of/-/babel-plugin-transform-es2015-for-of-6.23.0.tgz",
+ "integrity": "sha1-9HyVsrYT3x0+zC/bdXNiPHUkhpE=",
+ "dev": true,
+ "requires": {
+ "babel-runtime": "6.26.0"
+ }
+ },
+ "babel-plugin-transform-es2015-function-name": {
+ "version": "6.24.1",
+ "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-function-name/-/babel-plugin-transform-es2015-function-name-6.24.1.tgz",
+ "integrity": "sha1-g0yJhTvDaxrw86TF26qU/Y6sqos=",
+ "dev": true,
+ "requires": {
+ "babel-helper-function-name": "6.24.1",
+ "babel-runtime": "6.26.0",
+ "babel-types": "6.26.0"
+ }
+ },
+ "babel-plugin-transform-es2015-literals": {
+ "version": "6.22.0",
+ "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-literals/-/babel-plugin-transform-es2015-literals-6.22.0.tgz",
+ "integrity": "sha1-T1SgLWzWbPkVKAAZox0xklN3yi4=",
+ "dev": true,
+ "requires": {
+ "babel-runtime": "6.26.0"
+ }
+ },
+ "babel-plugin-transform-es2015-modules-amd": {
+ "version": "6.24.1",
+ "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-modules-amd/-/babel-plugin-transform-es2015-modules-amd-6.24.1.tgz",
+ "integrity": "sha1-Oz5UAXI5hC1tGcMBHEvS8AoA0VQ=",
+ "dev": true,
+ "requires": {
+ "babel-plugin-transform-es2015-modules-commonjs": "6.26.0",
+ "babel-runtime": "6.26.0",
+ "babel-template": "6.26.0"
+ }
+ },
+ "babel-plugin-transform-es2015-modules-commonjs": {
+ "version": "6.26.0",
+ "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-modules-commonjs/-/babel-plugin-transform-es2015-modules-commonjs-6.26.0.tgz",
+ "integrity": "sha1-DYOUApt9xqvhqX7xgeAHWN0uXYo=",
+ "dev": true,
+ "requires": {
+ "babel-plugin-transform-strict-mode": "6.24.1",
+ "babel-runtime": "6.26.0",
+ "babel-template": "6.26.0",
+ "babel-types": "6.26.0"
+ }
+ },
+ "babel-plugin-transform-es2015-modules-systemjs": {
+ "version": "6.24.1",
+ "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-modules-systemjs/-/babel-plugin-transform-es2015-modules-systemjs-6.24.1.tgz",
+ "integrity": "sha1-/4mhQrkRmpBhlfXxBuzzBdlAfSM=",
+ "dev": true,
+ "requires": {
+ "babel-helper-hoist-variables": "6.24.1",
+ "babel-runtime": "6.26.0",
+ "babel-template": "6.26.0"
+ }
+ },
+ "babel-plugin-transform-es2015-modules-umd": {
+ "version": "6.24.1",
+ "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-modules-umd/-/babel-plugin-transform-es2015-modules-umd-6.24.1.tgz",
+ "integrity": "sha1-rJl+YoXNGO1hdq22B9YCNErThGg=",
+ "dev": true,
+ "requires": {
+ "babel-plugin-transform-es2015-modules-amd": "6.24.1",
+ "babel-runtime": "6.26.0",
+ "babel-template": "6.26.0"
+ }
+ },
+ "babel-plugin-transform-es2015-object-super": {
+ "version": "6.24.1",
+ "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-object-super/-/babel-plugin-transform-es2015-object-super-6.24.1.tgz",
+ "integrity": "sha1-JM72muIcuDp/hgPa0CH1cusnj40=",
+ "dev": true,
+ "requires": {
+ "babel-helper-replace-supers": "6.24.1",
+ "babel-runtime": "6.26.0"
+ }
+ },
+ "babel-plugin-transform-es2015-parameters": {
+ "version": "6.24.1",
+ "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-parameters/-/babel-plugin-transform-es2015-parameters-6.24.1.tgz",
+ "integrity": "sha1-V6w1GrScrxSpfNE7CfZv3wpiXys=",
+ "dev": true,
+ "requires": {
+ "babel-helper-call-delegate": "6.24.1",
+ "babel-helper-get-function-arity": "6.24.1",
+ "babel-runtime": "6.26.0",
+ "babel-template": "6.26.0",
+ "babel-traverse": "6.26.0",
+ "babel-types": "6.26.0"
+ }
+ },
+ "babel-plugin-transform-es2015-shorthand-properties": {
+ "version": "6.24.1",
+ "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-shorthand-properties/-/babel-plugin-transform-es2015-shorthand-properties-6.24.1.tgz",
+ "integrity": "sha1-JPh11nIch2YbvZmkYi5R8U3jiqA=",
+ "dev": true,
+ "requires": {
+ "babel-runtime": "6.26.0",
+ "babel-types": "6.26.0"
+ }
+ },
+ "babel-plugin-transform-es2015-spread": {
+ "version": "6.22.0",
+ "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-spread/-/babel-plugin-transform-es2015-spread-6.22.0.tgz",
+ "integrity": "sha1-1taKmfia7cRTbIGlQujdnxdG+NE=",
+ "dev": true,
+ "requires": {
+ "babel-runtime": "6.26.0"
+ }
+ },
+ "babel-plugin-transform-es2015-sticky-regex": {
+ "version": "6.24.1",
+ "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-sticky-regex/-/babel-plugin-transform-es2015-sticky-regex-6.24.1.tgz",
+ "integrity": "sha1-AMHNsaynERLN8M9hJsLta0V8zbw=",
+ "dev": true,
+ "requires": {
+ "babel-helper-regex": "6.26.0",
+ "babel-runtime": "6.26.0",
+ "babel-types": "6.26.0"
+ }
+ },
+ "babel-plugin-transform-es2015-template-literals": {
+ "version": "6.22.0",
+ "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-template-literals/-/babel-plugin-transform-es2015-template-literals-6.22.0.tgz",
+ "integrity": "sha1-qEs0UPfp+PH2g51taH2oS7EjbY0=",
+ "dev": true,
+ "requires": {
+ "babel-runtime": "6.26.0"
+ }
+ },
+ "babel-plugin-transform-es2015-typeof-symbol": {
+ "version": "6.23.0",
+ "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-typeof-symbol/-/babel-plugin-transform-es2015-typeof-symbol-6.23.0.tgz",
+ "integrity": "sha1-3sCfHN3/lLUqxz1QXITfWdzOs3I=",
+ "dev": true,
+ "requires": {
+ "babel-runtime": "6.26.0"
+ }
+ },
+ "babel-plugin-transform-es2015-unicode-regex": {
+ "version": "6.24.1",
+ "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-unicode-regex/-/babel-plugin-transform-es2015-unicode-regex-6.24.1.tgz",
+ "integrity": "sha1-04sS9C6nMj9yk4fxinxa4frrNek=",
+ "dev": true,
+ "requires": {
+ "babel-helper-regex": "6.26.0",
+ "babel-runtime": "6.26.0",
+ "regexpu-core": "2.0.0"
+ }
+ },
+ "babel-plugin-transform-react-jsx": {
+ "version": "6.24.1",
+ "resolved": "https://registry.npmjs.org/babel-plugin-transform-react-jsx/-/babel-plugin-transform-react-jsx-6.24.1.tgz",
+ "integrity": "sha1-hAoCjn30YN/DotKfDA2R9jduZqM=",
+ "dev": true,
+ "requires": {
+ "babel-helper-builder-react-jsx": "6.26.0",
+ "babel-plugin-syntax-jsx": "6.18.0",
+ "babel-runtime": "6.26.0"
+ }
+ },
+ "babel-plugin-transform-regenerator": {
+ "version": "6.26.0",
+ "resolved": "https://registry.npmjs.org/babel-plugin-transform-regenerator/-/babel-plugin-transform-regenerator-6.26.0.tgz",
+ "integrity": "sha1-4HA2lvveJ/Cj78rPi03KL3s6jy8=",
+ "dev": true,
+ "requires": {
+ "regenerator-transform": "0.10.1"
+ }
+ },
+ "babel-plugin-transform-strict-mode": {
+ "version": "6.24.1",
+ "resolved": "https://registry.npmjs.org/babel-plugin-transform-strict-mode/-/babel-plugin-transform-strict-mode-6.24.1.tgz",
+ "integrity": "sha1-1fr3qleKZbvlkc9e2uBKDGcCB1g=",
+ "dev": true,
+ "requires": {
+ "babel-runtime": "6.26.0",
+ "babel-types": "6.26.0"
+ }
+ },
+ "babel-preset-es2015": {
+ "version": "6.24.1",
+ "resolved": "https://registry.npmjs.org/babel-preset-es2015/-/babel-preset-es2015-6.24.1.tgz",
+ "integrity": "sha1-1EBQ1rwsn+6nAqrzjXJ6AhBTiTk=",
+ "dev": true,
+ "requires": {
+ "babel-plugin-check-es2015-constants": "6.22.0",
+ "babel-plugin-transform-es2015-arrow-functions": "6.22.0",
+ "babel-plugin-transform-es2015-block-scoped-functions": "6.22.0",
+ "babel-plugin-transform-es2015-block-scoping": "6.26.0",
+ "babel-plugin-transform-es2015-classes": "6.24.1",
+ "babel-plugin-transform-es2015-computed-properties": "6.24.1",
+ "babel-plugin-transform-es2015-destructuring": "6.23.0",
+ "babel-plugin-transform-es2015-duplicate-keys": "6.24.1",
+ "babel-plugin-transform-es2015-for-of": "6.23.0",
+ "babel-plugin-transform-es2015-function-name": "6.24.1",
+ "babel-plugin-transform-es2015-literals": "6.22.0",
+ "babel-plugin-transform-es2015-modules-amd": "6.24.1",
+ "babel-plugin-transform-es2015-modules-commonjs": "6.26.0",
+ "babel-plugin-transform-es2015-modules-systemjs": "6.24.1",
+ "babel-plugin-transform-es2015-modules-umd": "6.24.1",
+ "babel-plugin-transform-es2015-object-super": "6.24.1",
+ "babel-plugin-transform-es2015-parameters": "6.24.1",
+ "babel-plugin-transform-es2015-shorthand-properties": "6.24.1",
+ "babel-plugin-transform-es2015-spread": "6.22.0",
+ "babel-plugin-transform-es2015-sticky-regex": "6.24.1",
+ "babel-plugin-transform-es2015-template-literals": "6.22.0",
+ "babel-plugin-transform-es2015-typeof-symbol": "6.23.0",
+ "babel-plugin-transform-es2015-unicode-regex": "6.24.1",
+ "babel-plugin-transform-regenerator": "6.26.0"
+ }
+ },
+ "babel-register": {
+ "version": "6.26.0",
+ "resolved": "https://registry.npmjs.org/babel-register/-/babel-register-6.26.0.tgz",
+ "integrity": "sha1-btAhFz4vy0htestFxgCahW9kcHE=",
+ "dev": true,
+ "requires": {
+ "babel-core": "6.26.0",
+ "babel-runtime": "6.26.0",
+ "core-js": "2.5.5",
+ "home-or-tmp": "2.0.0",
+ "lodash": "4.17.5",
+ "mkdirp": "0.5.1",
+ "source-map-support": "0.4.18"
+ }
+ },
+ "babel-runtime": {
+ "version": "6.26.0",
+ "resolved": "https://registry.npmjs.org/babel-runtime/-/babel-runtime-6.26.0.tgz",
+ "integrity": "sha1-llxwWGaOgrVde/4E/yM3vItWR/4=",
+ "dev": true,
+ "requires": {
+ "core-js": "2.5.5",
+ "regenerator-runtime": "0.11.1"
+ }
+ },
+ "babel-template": {
+ "version": "6.26.0",
+ "resolved": "https://registry.npmjs.org/babel-template/-/babel-template-6.26.0.tgz",
+ "integrity": "sha1-3gPi0WOWsGn0bdn/+FIfsaDjXgI=",
+ "dev": true,
+ "requires": {
+ "babel-runtime": "6.26.0",
+ "babel-traverse": "6.26.0",
+ "babel-types": "6.26.0",
+ "babylon": "6.18.0",
+ "lodash": "4.17.5"
+ }
+ },
+ "babel-traverse": {
+ "version": "6.26.0",
+ "resolved": "https://registry.npmjs.org/babel-traverse/-/babel-traverse-6.26.0.tgz",
+ "integrity": "sha1-RqnL1+3MYsjlwGTi0tjQ9ANXZu4=",
+ "dev": true,
+ "requires": {
+ "babel-code-frame": "6.26.0",
+ "babel-messages": "6.23.0",
+ "babel-runtime": "6.26.0",
+ "babel-types": "6.26.0",
+ "babylon": "6.18.0",
+ "debug": "2.6.9",
+ "globals": "9.18.0",
+ "invariant": "2.2.4",
+ "lodash": "4.17.5"
+ }
+ },
+ "babel-types": {
+ "version": "6.26.0",
+ "resolved": "https://registry.npmjs.org/babel-types/-/babel-types-6.26.0.tgz",
+ "integrity": "sha1-o7Bz+Uq0nrb6Vc1lInozQ4BjJJc=",
+ "dev": true,
+ "requires": {
+ "babel-runtime": "6.26.0",
+ "esutils": "2.0.2",
+ "lodash": "4.17.5",
+ "to-fast-properties": "1.0.3"
+ }
+ },
+ "babelify": {
+ "version": "7.3.0",
+ "resolved": "https://registry.npmjs.org/babelify/-/babelify-7.3.0.tgz",
+ "integrity": "sha1-qlau3nBn/XvVSWZu4W3ChQh+iOU=",
+ "dev": true,
+ "requires": {
+ "babel-core": "6.26.0",
+ "object-assign": "4.1.1"
+ }
+ },
+ "babylon": {
+ "version": "6.18.0",
+ "resolved": "https://registry.npmjs.org/babylon/-/babylon-6.18.0.tgz",
+ "integrity": "sha512-q/UEjfGJ2Cm3oKV71DJz9d25TPnq5rhBVL2Q4fA5wcC3jcrdn7+SssEybFIxwAvvP+YCsCYNKughoF33GxgycQ==",
+ "dev": true
+ },
+ "balanced-match": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz",
+ "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=",
+ "dev": true
+ },
+ "base": {
+ "version": "0.11.2",
+ "resolved": "https://registry.npmjs.org/base/-/base-0.11.2.tgz",
+ "integrity": "sha512-5T6P4xPgpp0YDFvSWwEZ4NoE3aM4QBQXDzmVbraCkFj8zHM+mba8SyqB5DbZWyR7mYHo6Y7BdQo3MoA4m0TeQg==",
+ "dev": true,
+ "requires": {
+ "cache-base": "1.0.1",
+ "class-utils": "0.3.6",
+ "component-emitter": "1.2.1",
+ "define-property": "1.0.0",
+ "isobject": "3.0.1",
+ "mixin-deep": "1.3.1",
+ "pascalcase": "0.1.1"
+ },
+ "dependencies": {
+ "define-property": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/define-property/-/define-property-1.0.0.tgz",
+ "integrity": "sha1-dp66rz9KY6rTr56NMEybvnm/sOY=",
+ "dev": true,
+ "requires": {
+ "is-descriptor": "1.0.2"
+ }
+ },
+ "is-accessor-descriptor": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-1.0.0.tgz",
+ "integrity": "sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ==",
+ "dev": true,
+ "requires": {
+ "kind-of": "6.0.2"
+ }
+ },
+ "is-data-descriptor": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-1.0.0.tgz",
+ "integrity": "sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ==",
+ "dev": true,
+ "requires": {
+ "kind-of": "6.0.2"
+ }
+ },
+ "is-descriptor": {
+ "version": "1.0.2",
+ "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-1.0.2.tgz",
+ "integrity": "sha512-2eis5WqQGV7peooDyLmNEPUrps9+SXX5c9pL3xEB+4e9HnGuDa7mB7kHxHw4CbqS9k1T2hOH3miL8n8WtiYVtg==",
+ "dev": true,
+ "requires": {
+ "is-accessor-descriptor": "1.0.0",
+ "is-data-descriptor": "1.0.0",
+ "kind-of": "6.0.2"
+ }
+ },
+ "kind-of": {
+ "version": "6.0.2",
+ "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.2.tgz",
+ "integrity": "sha512-s5kLOcnH0XqDO+FvuaLX8DDjZ18CGFk7VygH40QoKPUQhW4e2rvM0rwUq0t8IQDOwYSeLK01U90OjzBTme2QqA==",
+ "dev": true
+ }
+ }
+ },
+ "base64-js": {
+ "version": "1.3.0",
+ "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.3.0.tgz",
+ "integrity": "sha512-ccav/yGvoa80BQDljCxsmmQ3Xvx60/UpBIij5QN21W3wBi/hhIC9OoO+KLpu9IJTS9j4DRVJ3aDDF9cMSoa2lw==",
+ "dev": true
+ },
+ "bcrypt-pbkdf": {
+ "version": "1.0.1",
+ "resolved": "https://registry.npmjs.org/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.1.tgz",
+ "integrity": "sha1-Y7xdy2EzG5K8Bf1SiVPDNGKgb40=",
+ "dev": true,
+ "optional": true,
+ "requires": {
+ "tweetnacl": "0.14.5"
+ }
+ },
+ "beeper": {
+ "version": "1.1.1",
+ "resolved": "https://registry.npmjs.org/beeper/-/beeper-1.1.1.tgz",
+ "integrity": "sha1-5tXqjF2tABMEpwsiY4RH9pyy+Ak=",
+ "dev": true
+ },
+ "bl": {
+ "version": "1.2.2",
+ "resolved": "https://registry.npmjs.org/bl/-/bl-1.2.2.tgz",
+ "integrity": "sha512-e8tQYnZodmebYDWGH7KMRvtzKXaJHx3BbilrgZCfvyLUYdKpK1t5PSPmpkny/SgiTSCnjfLW7v5rlONXVFkQEA==",
+ "dev": true,
+ "requires": {
+ "readable-stream": "2.3.6",
+ "safe-buffer": "5.1.1"
+ }
+ },
+ "block-stream": {
+ "version": "0.0.9",
+ "resolved": "https://registry.npmjs.org/block-stream/-/block-stream-0.0.9.tgz",
+ "integrity": "sha1-E+v+d4oDIFz+A3UUgeu0szAMEmo=",
+ "dev": true,
+ "requires": {
+ "inherits": "2.0.3"
+ }
+ },
+ "bn.js": {
+ "version": "4.11.8",
+ "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.11.8.tgz",
+ "integrity": "sha512-ItfYfPLkWHUjckQCk8xC+LwxgK8NYcXywGigJgSwOP8Y2iyWT4f2vsZnoOXTTbo+o5yXmIUJ4gn5538SO5S3gA==",
+ "dev": true
+ },
+ "boom": {
+ "version": "4.3.1",
+ "resolved": "https://registry.npmjs.org/boom/-/boom-4.3.1.tgz",
+ "integrity": "sha1-T4owBctKfjiJ90kDD9JbluAdLjE=",
+ "dev": true,
+ "requires": {
+ "hoek": "4.2.1"
+ }
+ },
+ "brace-expansion": {
+ "version": "1.1.11",
+ "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz",
+ "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==",
+ "dev": true,
+ "requires": {
+ "balanced-match": "1.0.0",
+ "concat-map": "0.0.1"
+ }
+ },
+ "braces": {
+ "version": "2.3.2",
+ "resolved": "https://registry.npmjs.org/braces/-/braces-2.3.2.tgz",
+ "integrity": "sha512-aNdbnj9P8PjdXU4ybaWLK2IF3jc/EoDYbC7AazW6to3TRsfXxscC9UXOB5iDiEQrkyIbWp2SLQda4+QAa7nc3w==",
+ "dev": true,
+ "requires": {
+ "arr-flatten": "1.1.0",
+ "array-unique": "0.3.2",
+ "extend-shallow": "2.0.1",
+ "fill-range": "4.0.0",
+ "isobject": "3.0.1",
+ "repeat-element": "1.1.2",
+ "snapdragon": "0.8.2",
+ "snapdragon-node": "2.1.1",
+ "split-string": "3.1.0",
+ "to-regex": "3.0.2"
+ },
+ "dependencies": {
+ "extend-shallow": {
+ "version": "2.0.1",
+ "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz",
+ "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=",
+ "dev": true,
+ "requires": {
+ "is-extendable": "0.1.1"
+ }
+ }
+ }
+ },
+ "brorand": {
+ "version": "1.1.0",
+ "resolved": "https://registry.npmjs.org/brorand/-/brorand-1.1.0.tgz",
+ "integrity": "sha1-EsJe/kCkXjwyPrhnWgoM5XsiNx8=",
+ "dev": true
+ },
+ "browser-pack": {
+ "version": "6.1.0",
+ "resolved": "https://registry.npmjs.org/browser-pack/-/browser-pack-6.1.0.tgz",
+ "integrity": "sha512-erYug8XoqzU3IfcU8fUgyHqyOXqIE4tUTTQ+7mqUjQlvnXkOO6OlT9c/ZoJVHYoAaqGxr09CN53G7XIsO4KtWA==",
+ "dev": true,
+ "requires": {
+ "JSONStream": "1.3.2",
+ "combine-source-map": "0.8.0",
+ "defined": "1.0.0",
+ "safe-buffer": "5.1.1",
+ "through2": "2.0.3",
+ "umd": "3.0.3"
+ }
+ },
+ "browser-resolve": {
+ "version": "1.11.2",
+ "resolved": "https://registry.npmjs.org/browser-resolve/-/browser-resolve-1.11.2.tgz",
+ "integrity": "sha1-j/CbCixCFxihBRwmCzLkj0QpOM4=",
+ "dev": true,
+ "requires": {
+ "resolve": "1.1.7"
+ },
+ "dependencies": {
+ "resolve": {
+ "version": "1.1.7",
+ "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.1.7.tgz",
+ "integrity": "sha1-IDEU2CrSxe2ejgQRs5ModeiJ6Xs=",
+ "dev": true
+ }
+ }
+ },
+ "browserify": {
+ "version": "13.3.0",
+ "resolved": "https://registry.npmjs.org/browserify/-/browserify-13.3.0.tgz",
+ "integrity": "sha1-tanJAgJD8McORnW+yCI7xifkFc4=",
+ "dev": true,
+ "requires": {
+ "JSONStream": "1.3.2",
+ "assert": "1.4.1",
+ "browser-pack": "6.1.0",
+ "browser-resolve": "1.11.2",
+ "browserify-zlib": "0.1.4",
+ "buffer": "4.9.1",
+ "cached-path-relative": "1.0.1",
+ "concat-stream": "1.5.2",
+ "console-browserify": "1.1.0",
+ "constants-browserify": "1.0.0",
+ "crypto-browserify": "3.12.0",
+ "defined": "1.0.0",
+ "deps-sort": "2.0.0",
+ "domain-browser": "1.1.7",
+ "duplexer2": "0.1.4",
+ "events": "1.1.1",
+ "glob": "7.1.2",
+ "has": "1.0.1",
+ "htmlescape": "1.1.1",
+ "https-browserify": "0.0.1",
+ "inherits": "2.0.3",
+ "insert-module-globals": "7.0.6",
+ "labeled-stream-splicer": "2.0.1",
+ "module-deps": "4.1.1",
+ "os-browserify": "0.1.2",
+ "parents": "1.0.1",
+ "path-browserify": "0.0.0",
+ "process": "0.11.10",
+ "punycode": "1.4.1",
+ "querystring-es3": "0.2.1",
+ "read-only-stream": "2.0.0",
+ "readable-stream": "2.3.6",
+ "resolve": "1.7.1",
+ "shasum": "1.0.2",
+ "shell-quote": "1.6.1",
+ "stream-browserify": "2.0.1",
+ "stream-http": "2.8.1",
+ "string_decoder": "0.10.31",
+ "subarg": "1.0.0",
+ "syntax-error": "1.4.0",
+ "through2": "2.0.3",
+ "timers-browserify": "1.4.2",
+ "tty-browserify": "0.0.1",
+ "url": "0.11.0",
+ "util": "0.10.3",
+ "vm-browserify": "0.0.4",
+ "xtend": "4.0.1"
+ },
+ "dependencies": {
+ "string_decoder": {
+ "version": "0.10.31",
+ "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz",
+ "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=",
+ "dev": true
+ }
+ }
+ },
+ "browserify-aes": {
+ "version": "1.2.0",
+ "resolved": "https://registry.npmjs.org/browserify-aes/-/browserify-aes-1.2.0.tgz",
+ "integrity": "sha512-+7CHXqGuspUn/Sl5aO7Ea0xWGAtETPXNSAjHo48JfLdPWcMng33Xe4znFvQweqc/uzk5zSOI3H52CYnjCfb5hA==",
+ "dev": true,
+ "requires": {
+ "buffer-xor": "1.0.3",
+ "cipher-base": "1.0.4",
+ "create-hash": "1.2.0",
+ "evp_bytestokey": "1.0.3",
+ "inherits": "2.0.3",
+ "safe-buffer": "5.1.1"
+ }
+ },
+ "browserify-cipher": {
+ "version": "1.0.1",
+ "resolved": "https://registry.npmjs.org/browserify-cipher/-/browserify-cipher-1.0.1.tgz",
+ "integrity": "sha512-sPhkz0ARKbf4rRQt2hTpAHqn47X3llLkUGn+xEJzLjwY8LRs2p0v7ljvI5EyoRO/mexrNunNECisZs+gw2zz1w==",
+ "dev": true,
+ "requires": {
+ "browserify-aes": "1.2.0",
+ "browserify-des": "1.0.1",
+ "evp_bytestokey": "1.0.3"
+ }
+ },
+ "browserify-des": {
+ "version": "1.0.1",
+ "resolved": "https://registry.npmjs.org/browserify-des/-/browserify-des-1.0.1.tgz",
+ "integrity": "sha512-zy0Cobe3hhgpiOM32Tj7KQ3Vl91m0njwsjzZQK1L+JDf11dzP9qIvjreVinsvXrgfjhStXwUWAEpB9D7Gwmayw==",
+ "dev": true,
+ "requires": {
+ "cipher-base": "1.0.4",
+ "des.js": "1.0.0",
+ "inherits": "2.0.3"
+ }
+ },
+ "browserify-rsa": {
+ "version": "4.0.1",
+ "resolved": "https://registry.npmjs.org/browserify-rsa/-/browserify-rsa-4.0.1.tgz",
+ "integrity": "sha1-IeCr+vbyApzy+vsTNWenAdQTVSQ=",
+ "dev": true,
+ "requires": {
+ "bn.js": "4.11.8",
+ "randombytes": "2.0.6"
+ }
+ },
+ "browserify-sign": {
+ "version": "4.0.4",
+ "resolved": "https://registry.npmjs.org/browserify-sign/-/browserify-sign-4.0.4.tgz",
+ "integrity": "sha1-qk62jl17ZYuqa/alfmMMvXqT0pg=",
+ "dev": true,
+ "requires": {
+ "bn.js": "4.11.8",
+ "browserify-rsa": "4.0.1",
+ "create-hash": "1.2.0",
+ "create-hmac": "1.1.7",
+ "elliptic": "6.4.0",
+ "inherits": "2.0.3",
+ "parse-asn1": "5.1.1"
+ }
+ },
+ "browserify-zlib": {
+ "version": "0.1.4",
+ "resolved": "https://registry.npmjs.org/browserify-zlib/-/browserify-zlib-0.1.4.tgz",
+ "integrity": "sha1-uzX4pRn2AOD6a4SFJByXnQFB+y0=",
+ "dev": true,
+ "requires": {
+ "pako": "0.2.9"
+ }
+ },
+ "buffer": {
+ "version": "4.9.1",
+ "resolved": "https://registry.npmjs.org/buffer/-/buffer-4.9.1.tgz",
+ "integrity": "sha1-bRu2AbB6TvztlwlBMgkwJ8lbwpg=",
+ "dev": true,
+ "requires": {
+ "base64-js": "1.3.0",
+ "ieee754": "1.1.11",
+ "isarray": "1.0.0"
+ }
+ },
+ "buffer-from": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.0.0.tgz",
+ "integrity": "sha512-83apNb8KK0Se60UE1+4Ukbe3HbfELJ6UlI4ldtOGs7So4KD26orJM8hIY9lxdzP+UpItH1Yh/Y8GUvNFWFFRxA==",
+ "dev": true
+ },
+ "buffer-xor": {
+ "version": "1.0.3",
+ "resolved": "https://registry.npmjs.org/buffer-xor/-/buffer-xor-1.0.3.tgz",
+ "integrity": "sha1-JuYe0UIvtw3ULm42cp7VHYVf6Nk=",
+ "dev": true
+ },
+ "builtin-modules": {
+ "version": "1.1.1",
+ "resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-1.1.1.tgz",
+ "integrity": "sha1-Jw8HbFpywC9bZaR9+Uxf46J4iS8=",
+ "dev": true
+ },
+ "builtin-status-codes": {
+ "version": "3.0.0",
+ "resolved": "https://registry.npmjs.org/builtin-status-codes/-/builtin-status-codes-3.0.0.tgz",
+ "integrity": "sha1-hZgoeOIbmOHGZCXgPQF0eI9Wnug=",
+ "dev": true
+ },
+ "cache-base": {
+ "version": "1.0.1",
+ "resolved": "https://registry.npmjs.org/cache-base/-/cache-base-1.0.1.tgz",
+ "integrity": "sha512-AKcdTnFSWATd5/GCPRxr2ChwIJ85CeyrEyjRHlKxQ56d4XJMGym0uAiKn0xbLOGOl3+yRpOTi484dVCEc5AUzQ==",
+ "dev": true,
+ "requires": {
+ "collection-visit": "1.0.0",
+ "component-emitter": "1.2.1",
+ "get-value": "2.0.6",
+ "has-value": "1.0.0",
+ "isobject": "3.0.1",
+ "set-value": "2.0.0",
+ "to-object-path": "0.3.0",
+ "union-value": "1.0.0",
+ "unset-value": "1.0.0"
+ }
+ },
+ "cached-path-relative": {
+ "version": "1.0.1",
+ "resolved": "https://registry.npmjs.org/cached-path-relative/-/cached-path-relative-1.0.1.tgz",
+ "integrity": "sha1-0JxLUoAKpMB44t2BqGmqyQ0uVOc=",
+ "dev": true
+ },
+ "camelcase": {
+ "version": "1.2.1",
+ "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-1.2.1.tgz",
+ "integrity": "sha1-m7UwTS4LVmmLLHWLCKPqqdqlijk="
+ },
+ "camelcase-keys": {
+ "version": "2.1.0",
+ "resolved": "https://registry.npmjs.org/camelcase-keys/-/camelcase-keys-2.1.0.tgz",
+ "integrity": "sha1-MIvur/3ygRkFHvodkyITyRuPkuc=",
+ "dev": true,
+ "requires": {
+ "camelcase": "2.1.1",
+ "map-obj": "1.0.1"
+ },
+ "dependencies": {
+ "camelcase": {
+ "version": "2.1.1",
+ "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-2.1.1.tgz",
+ "integrity": "sha1-fB0W1nmhu+WcoCys7PsBHiAfWh8=",
+ "dev": true
+ }
+ }
+ },
+ "caseless": {
+ "version": "0.12.0",
+ "resolved": "https://registry.npmjs.org/caseless/-/caseless-0.12.0.tgz",
+ "integrity": "sha1-G2gcIf+EAzyCZUMJBolCDRhxUdw=",
+ "dev": true
+ },
+ "center-align": {
+ "version": "0.1.3",
+ "resolved": "https://registry.npmjs.org/center-align/-/center-align-0.1.3.tgz",
+ "integrity": "sha1-qg0yYptu6XIgBBHL1EYckHvCt60=",
+ "requires": {
+ "align-text": "0.1.4",
+ "lazy-cache": "1.0.4"
+ }
+ },
+ "chalk": {
+ "version": "1.1.3",
+ "resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz",
+ "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=",
+ "dev": true,
+ "requires": {
+ "ansi-styles": "2.2.1",
+ "escape-string-regexp": "1.0.5",
+ "has-ansi": "2.0.0",
+ "strip-ansi": "3.0.1",
+ "supports-color": "2.0.0"
+ }
+ },
+ "cipher-base": {
+ "version": "1.0.4",
+ "resolved": "https://registry.npmjs.org/cipher-base/-/cipher-base-1.0.4.tgz",
+ "integrity": "sha512-Kkht5ye6ZGmwv40uUDZztayT2ThLQGfnj/T71N/XzeZeo3nf8foyW7zGTsPYkEya3m5f3cAypH+qe7YOrM1U2Q==",
+ "dev": true,
+ "requires": {
+ "inherits": "2.0.3",
+ "safe-buffer": "5.1.1"
+ }
+ },
+ "class-utils": {
+ "version": "0.3.6",
+ "resolved": "https://registry.npmjs.org/class-utils/-/class-utils-0.3.6.tgz",
+ "integrity": "sha512-qOhPa/Fj7s6TY8H8esGu5QNpMMQxz79h+urzrNYN6mn+9BnxlDGf5QZ+XeCDsxSjPqsSR56XOZOJmpeurnLMeg==",
+ "dev": true,
+ "requires": {
+ "arr-union": "3.1.0",
+ "define-property": "0.2.5",
+ "isobject": "3.0.1",
+ "static-extend": "0.1.2"
+ },
+ "dependencies": {
+ "define-property": {
+ "version": "0.2.5",
+ "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz",
+ "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=",
+ "dev": true,
+ "requires": {
+ "is-descriptor": "0.1.6"
+ }
+ }
+ }
+ },
+ "cliui": {
+ "version": "2.1.0",
+ "resolved": "https://registry.npmjs.org/cliui/-/cliui-2.1.0.tgz",
+ "integrity": "sha1-S0dXYP+AJkx2LDoXGQMukcf+oNE=",
+ "requires": {
+ "center-align": "0.1.3",
+ "right-align": "0.1.3",
+ "wordwrap": "0.0.2"
+ }
+ },
+ "clone": {
+ "version": "1.0.4",
+ "resolved": "https://registry.npmjs.org/clone/-/clone-1.0.4.tgz",
+ "integrity": "sha1-2jCcwmPfFZlMaIypAheco8fNfH4=",
+ "dev": true
+ },
+ "clone-stats": {
+ "version": "0.0.1",
+ "resolved": "https://registry.npmjs.org/clone-stats/-/clone-stats-0.0.1.tgz",
+ "integrity": "sha1-uI+UqCzzi4eR1YBG6kAprYjKmdE=",
+ "dev": true
+ },
+ "co": {
+ "version": "4.6.0",
+ "resolved": "https://registry.npmjs.org/co/-/co-4.6.0.tgz",
+ "integrity": "sha1-bqa989hTrlTMuOR7+gvz+QMfsYQ=",
+ "dev": true
+ },
+ "code-point-at": {
+ "version": "1.1.0",
+ "resolved": "https://registry.npmjs.org/code-point-at/-/code-point-at-1.1.0.tgz",
+ "integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=",
+ "dev": true
+ },
+ "collection-visit": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/collection-visit/-/collection-visit-1.0.0.tgz",
+ "integrity": "sha1-S8A3PBZLwykbTTaMgpzxqApZ3KA=",
+ "dev": true,
+ "requires": {
+ "map-visit": "1.0.0",
+ "object-visit": "1.0.1"
+ }
+ },
+ "color-support": {
+ "version": "1.1.3",
+ "resolved": "https://registry.npmjs.org/color-support/-/color-support-1.1.3.tgz",
+ "integrity": "sha512-qiBjkpbMLO/HL68y+lh4q0/O1MZFj2RX6X/KmMa3+gJD3z+WwI1ZzDHysvqHGS3mP6mznPckpXmw1nI9cJjyRg==",
+ "dev": true
+ },
+ "combine-source-map": {
+ "version": "0.8.0",
+ "resolved": "https://registry.npmjs.org/combine-source-map/-/combine-source-map-0.8.0.tgz",
+ "integrity": "sha1-pY0N8ELBhvz4IqjoAV9UUNLXmos=",
+ "dev": true,
+ "requires": {
+ "convert-source-map": "1.1.3",
+ "inline-source-map": "0.6.2",
+ "lodash.memoize": "3.0.4",
+ "source-map": "0.5.7"
+ },
+ "dependencies": {
+ "convert-source-map": {
+ "version": "1.1.3",
+ "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-1.1.3.tgz",
+ "integrity": "sha1-SCnId+n+SbMWHzvzZziI4gRpmGA=",
+ "dev": true
+ }
+ }
+ },
+ "combined-stream": {
+ "version": "1.0.6",
+ "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.6.tgz",
+ "integrity": "sha1-cj599ugBrFYTETp+RFqbactjKBg=",
+ "dev": true,
+ "requires": {
+ "delayed-stream": "1.0.0"
+ }
+ },
+ "commander": {
+ "version": "2.15.1",
+ "resolved": "https://registry.npmjs.org/commander/-/commander-2.15.1.tgz",
+ "integrity": "sha512-VlfT9F3V0v+jr4yxPc5gg9s62/fIVWsd2Bk2iD435um1NlGMYdVCq+MjcXnhYq2icNOizHr1kK+5TI6H0Hy0ag=="
+ },
+ "component-emitter": {
+ "version": "1.2.1",
+ "resolved": "https://registry.npmjs.org/component-emitter/-/component-emitter-1.2.1.tgz",
+ "integrity": "sha1-E3kY1teCg/ffemt8WmPhQOaUJeY=",
+ "dev": true
+ },
+ "concat-map": {
+ "version": "0.0.1",
+ "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
+ "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=",
+ "dev": true
+ },
+ "concat-stream": {
+ "version": "1.5.2",
+ "resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.5.2.tgz",
+ "integrity": "sha1-cIl4Yk2FavQaWnQd790mHadSwmY=",
+ "dev": true,
+ "requires": {
+ "inherits": "2.0.3",
+ "readable-stream": "2.0.6",
+ "typedarray": "0.0.6"
+ },
+ "dependencies": {
+ "process-nextick-args": {
+ "version": "1.0.7",
+ "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-1.0.7.tgz",
+ "integrity": "sha1-FQ4gt1ZZCtP5EJPyWk8q2L/zC6M=",
+ "dev": true
+ },
+ "readable-stream": {
+ "version": "2.0.6",
+ "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.0.6.tgz",
+ "integrity": "sha1-j5A0HmilPMySh4jaz80Rs265t44=",
+ "dev": true,
+ "requires": {
+ "core-util-is": "1.0.2",
+ "inherits": "2.0.3",
+ "isarray": "1.0.0",
+ "process-nextick-args": "1.0.7",
+ "string_decoder": "0.10.31",
+ "util-deprecate": "1.0.2"
+ }
+ },
+ "string_decoder": {
+ "version": "0.10.31",
+ "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz",
+ "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=",
+ "dev": true
+ }
+ }
+ },
+ "console-browserify": {
+ "version": "1.1.0",
+ "resolved": "https://registry.npmjs.org/console-browserify/-/console-browserify-1.1.0.tgz",
+ "integrity": "sha1-8CQcRXMKn8YyOyBtvzjtx0HQuxA=",
+ "dev": true,
+ "requires": {
+ "date-now": "0.1.4"
+ }
+ },
+ "console-control-strings": {
+ "version": "1.1.0",
+ "resolved": "https://registry.npmjs.org/console-control-strings/-/console-control-strings-1.1.0.tgz",
+ "integrity": "sha1-PXz0Rk22RG6mRL9LOVB/mFEAjo4=",
+ "dev": true
+ },
+ "constants-browserify": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/constants-browserify/-/constants-browserify-1.0.0.tgz",
+ "integrity": "sha1-wguW2MYXdIqvHBYCF2DNJ/y4y3U=",
+ "dev": true
+ },
+ "convert-source-map": {
+ "version": "1.5.1",
+ "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-1.5.1.tgz",
+ "integrity": "sha1-uCeAl7m8IpNl3lxiz1/K7YtVmeU=",
+ "dev": true
+ },
+ "copy-descriptor": {
+ "version": "0.1.1",
+ "resolved": "https://registry.npmjs.org/copy-descriptor/-/copy-descriptor-0.1.1.tgz",
+ "integrity": "sha1-Z29us8OZl8LuGsOpJP1hJHSPV40=",
+ "dev": true
+ },
+ "core-js": {
+ "version": "2.5.5",
+ "resolved": "https://registry.npmjs.org/core-js/-/core-js-2.5.5.tgz",
+ "integrity": "sha1-sU3ek2xkDAV5prUMq8wTLdYSfjs=",
+ "dev": true
+ },
+ "core-util-is": {
+ "version": "1.0.2",
+ "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz",
+ "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac="
+ },
+ "create-ecdh": {
+ "version": "4.0.1",
+ "resolved": "https://registry.npmjs.org/create-ecdh/-/create-ecdh-4.0.1.tgz",
+ "integrity": "sha512-iZvCCg8XqHQZ1ioNBTzXS/cQSkqkqcPs8xSX4upNB+DAk9Ht3uzQf2J32uAHNCne8LDmKr29AgZrEs4oIrwLuQ==",
+ "dev": true,
+ "requires": {
+ "bn.js": "4.11.8",
+ "elliptic": "6.4.0"
+ }
+ },
+ "create-hash": {
+ "version": "1.2.0",
+ "resolved": "https://registry.npmjs.org/create-hash/-/create-hash-1.2.0.tgz",
+ "integrity": "sha512-z00bCGNHDG8mHAkP7CtT1qVu+bFQUPjYq/4Iv3C3kWjTFV10zIjfSoeqXo9Asws8gwSHDGj/hl2u4OGIjapeCg==",
+ "dev": true,
+ "requires": {
+ "cipher-base": "1.0.4",
+ "inherits": "2.0.3",
+ "md5.js": "1.3.4",
+ "ripemd160": "2.0.2",
+ "sha.js": "2.4.11"
+ }
+ },
+ "create-hmac": {
+ "version": "1.1.7",
+ "resolved": "https://registry.npmjs.org/create-hmac/-/create-hmac-1.1.7.tgz",
+ "integrity": "sha512-MJG9liiZ+ogc4TzUwuvbER1JRdgvUFSB5+VR/g5h82fGaIRWMWddtKBHi7/sVhfjQZ6SehlyhvQYrcYkaUIpLg==",
+ "dev": true,
+ "requires": {
+ "cipher-base": "1.0.4",
+ "create-hash": "1.2.0",
+ "inherits": "2.0.3",
+ "ripemd160": "2.0.2",
+ "safe-buffer": "5.1.1",
+ "sha.js": "2.4.11"
+ }
+ },
+ "cross-spawn": {
+ "version": "3.0.1",
+ "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-3.0.1.tgz",
+ "integrity": "sha1-ElYDfsufDF9549bvE14wdwGEuYI=",
+ "dev": true,
+ "requires": {
+ "lru-cache": "4.1.2",
+ "which": "1.3.0"
+ },
+ "dependencies": {
+ "lru-cache": {
+ "version": "4.1.2",
+ "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-4.1.2.tgz",
+ "integrity": "sha512-wgeVXhrDwAWnIF/yZARsFnMBtdFXOg1b8RIrhilp+0iDYN4mdQcNZElDZ0e4B64BhaxeQ5zN7PMyvu7we1kPeQ==",
+ "dev": true,
+ "requires": {
+ "pseudomap": "1.0.2",
+ "yallist": "2.1.2"
+ }
+ }
+ }
+ },
+ "cryptiles": {
+ "version": "3.1.2",
+ "resolved": "https://registry.npmjs.org/cryptiles/-/cryptiles-3.1.2.tgz",
+ "integrity": "sha1-qJ+7Ig9c4l7FboxKqKT9e1sNKf4=",
+ "dev": true,
+ "requires": {
+ "boom": "5.2.0"
+ },
+ "dependencies": {
+ "boom": {
+ "version": "5.2.0",
+ "resolved": "https://registry.npmjs.org/boom/-/boom-5.2.0.tgz",
+ "integrity": "sha512-Z5BTk6ZRe4tXXQlkqftmsAUANpXmuwlsF5Oov8ThoMbQRzdGTA1ngYRW160GexgOgjsFOKJz0LYhoNi+2AMBUw==",
+ "dev": true,
+ "requires": {
+ "hoek": "4.2.1"
+ }
+ }
+ }
+ },
+ "crypto-browserify": {
+ "version": "3.12.0",
+ "resolved": "https://registry.npmjs.org/crypto-browserify/-/crypto-browserify-3.12.0.tgz",
+ "integrity": "sha512-fz4spIh+znjO2VjL+IdhEpRJ3YN6sMzITSBijk6FK2UvTqruSQW+/cCZTSNsMiZNvUeq0CqurF+dAbyiGOY6Wg==",
+ "dev": true,
+ "requires": {
+ "browserify-cipher": "1.0.1",
+ "browserify-sign": "4.0.4",
+ "create-ecdh": "4.0.1",
+ "create-hash": "1.2.0",
+ "create-hmac": "1.1.7",
+ "diffie-hellman": "5.0.3",
+ "inherits": "2.0.3",
+ "pbkdf2": "3.0.16",
+ "public-encrypt": "4.0.2",
+ "randombytes": "2.0.6",
+ "randomfill": "1.0.4"
+ }
+ },
+ "currently-unhandled": {
+ "version": "0.4.1",
+ "resolved": "https://registry.npmjs.org/currently-unhandled/-/currently-unhandled-0.4.1.tgz",
+ "integrity": "sha1-mI3zP+qxke95mmE2nddsF635V+o=",
+ "dev": true,
+ "requires": {
+ "array-find-index": "1.0.2"
+ }
+ },
+ "d3": {
+ "version": "4.13.0",
+ "resolved": "https://registry.npmjs.org/d3/-/d3-4.13.0.tgz",
+ "integrity": "sha512-l8c4+0SldjVKLaE2WG++EQlqD7mh/dmQjvi2L2lKPadAVC+TbJC4ci7Uk9bRi+To0+ansgsS0iWfPjD7DBy+FQ==",
+ "requires": {
+ "d3-array": "1.2.1",
+ "d3-axis": "1.0.8",
+ "d3-brush": "1.0.4",
+ "d3-chord": "1.0.4",
+ "d3-collection": "1.0.4",
+ "d3-color": "1.0.3",
+ "d3-dispatch": "1.0.3",
+ "d3-drag": "1.2.1",
+ "d3-dsv": "1.0.8",
+ "d3-ease": "1.0.3",
+ "d3-force": "1.1.0",
+ "d3-format": "1.2.2",
+ "d3-geo": "1.9.1",
+ "d3-hierarchy": "1.1.5",
+ "d3-interpolate": "1.1.6",
+ "d3-path": "1.0.5",
+ "d3-polygon": "1.0.3",
+ "d3-quadtree": "1.0.3",
+ "d3-queue": "3.0.7",
+ "d3-random": "1.1.0",
+ "d3-request": "1.0.6",
+ "d3-scale": "1.0.7",
+ "d3-selection": "1.3.0",
+ "d3-shape": "1.2.0",
+ "d3-time": "1.0.8",
+ "d3-time-format": "2.1.1",
+ "d3-timer": "1.0.7",
+ "d3-transition": "1.1.1",
+ "d3-voronoi": "1.1.2",
+ "d3-zoom": "1.7.1"
+ }
+ },
+ "d3-array": {
+ "version": "1.2.1",
+ "resolved": "https://registry.npmjs.org/d3-array/-/d3-array-1.2.1.tgz",
+ "integrity": "sha512-CyINJQ0SOUHojDdFDH4JEM0552vCR1utGyLHegJHyYH0JyCpSeTPxi4OBqHMA2jJZq4NH782LtaJWBImqI/HBw=="
+ },
+ "d3-axis": {
+ "version": "1.0.8",
+ "resolved": "https://registry.npmjs.org/d3-axis/-/d3-axis-1.0.8.tgz",
+ "integrity": "sha1-MacFoLU15ldZ3hQXOjGTMTfxjvo="
+ },
+ "d3-brush": {
+ "version": "1.0.4",
+ "resolved": "https://registry.npmjs.org/d3-brush/-/d3-brush-1.0.4.tgz",
+ "integrity": "sha1-AMLyOAGfJPbAoZSibUGhUw/+e8Q=",
+ "requires": {
+ "d3-dispatch": "1.0.3",
+ "d3-drag": "1.2.1",
+ "d3-interpolate": "1.1.6",
+ "d3-selection": "1.3.0",
+ "d3-transition": "1.1.1"
+ }
+ },
+ "d3-chord": {
+ "version": "1.0.4",
+ "resolved": "https://registry.npmjs.org/d3-chord/-/d3-chord-1.0.4.tgz",
+ "integrity": "sha1-fexPC6iG9xP+ERxF92NBT290yiw=",
+ "requires": {
+ "d3-array": "1.2.1",
+ "d3-path": "1.0.5"
+ }
+ },
+ "d3-collection": {
+ "version": "1.0.4",
+ "resolved": "https://registry.npmjs.org/d3-collection/-/d3-collection-1.0.4.tgz",
+ "integrity": "sha1-NC39EoN8kJdPM/HMCnha6lcNzcI="
+ },
+ "d3-color": {
+ "version": "1.0.3",
+ "resolved": "https://registry.npmjs.org/d3-color/-/d3-color-1.0.3.tgz",
+ "integrity": "sha1-vHZD/KjlOoNH4vva/6I2eWtYUJs="
+ },
+ "d3-dispatch": {
+ "version": "1.0.3",
+ "resolved": "https://registry.npmjs.org/d3-dispatch/-/d3-dispatch-1.0.3.tgz",
+ "integrity": "sha1-RuFJHqqbWMNY/OW+TovtYm54cfg="
+ },
+ "d3-drag": {
+ "version": "1.2.1",
+ "resolved": "https://registry.npmjs.org/d3-drag/-/d3-drag-1.2.1.tgz",
+ "integrity": "sha512-Cg8/K2rTtzxzrb0fmnYOUeZHvwa4PHzwXOLZZPwtEs2SKLLKLXeYwZKBB+DlOxUvFmarOnmt//cU4+3US2lyyQ==",
+ "requires": {
+ "d3-dispatch": "1.0.3",
+ "d3-selection": "1.3.0"
+ }
+ },
+ "d3-dsv": {
+ "version": "1.0.8",
+ "resolved": "https://registry.npmjs.org/d3-dsv/-/d3-dsv-1.0.8.tgz",
+ "integrity": "sha512-IVCJpQ+YGe3qu6odkPQI0KPqfxkhbP/oM1XhhE/DFiYmcXKfCRub4KXyiuehV1d4drjWVXHUWx4gHqhdZb6n/A==",
+ "requires": {
+ "commander": "2.15.1",
+ "iconv-lite": "0.4.21",
+ "rw": "1.3.3"
+ }
+ },
+ "d3-ease": {
+ "version": "1.0.3",
+ "resolved": "https://registry.npmjs.org/d3-ease/-/d3-ease-1.0.3.tgz",
+ "integrity": "sha1-aL+8NJM4o4DETYrMT7wzBKotjA4="
+ },
+ "d3-force": {
+ "version": "1.1.0",
+ "resolved": "https://registry.npmjs.org/d3-force/-/d3-force-1.1.0.tgz",
+ "integrity": "sha512-2HVQz3/VCQs0QeRNZTYb7GxoUCeb6bOzMp/cGcLa87awY9ZsPvXOGeZm0iaGBjXic6I1ysKwMn+g+5jSAdzwcg==",
+ "requires": {
+ "d3-collection": "1.0.4",
+ "d3-dispatch": "1.0.3",
+ "d3-quadtree": "1.0.3",
+ "d3-timer": "1.0.7"
+ }
+ },
+ "d3-format": {
+ "version": "1.2.2",
+ "resolved": "https://registry.npmjs.org/d3-format/-/d3-format-1.2.2.tgz",
+ "integrity": "sha512-zH9CfF/3C8zUI47nsiKfD0+AGDEuM8LwBIP7pBVpyR4l/sKkZqITmMtxRp04rwBrlshIZ17XeFAaovN3++wzkw=="
+ },
+ "d3-geo": {
+ "version": "1.9.1",
+ "resolved": "https://registry.npmjs.org/d3-geo/-/d3-geo-1.9.1.tgz",
+ "integrity": "sha512-l9wL/cEQkyZQYXw3xbmLsH3eQ5ij+icNfo4r0GrLa5rOCZR/e/3am45IQ0FvQ5uMsv+77zBRunLc9ufTWSQYFA==",
+ "requires": {
+ "d3-array": "1.2.1"
+ }
+ },
+ "d3-hierarchy": {
+ "version": "1.1.5",
+ "resolved": "https://registry.npmjs.org/d3-hierarchy/-/d3-hierarchy-1.1.5.tgz",
+ "integrity": "sha1-ochFxC+Eoga88cAcAQmOpN2qeiY="
+ },
+ "d3-interpolate": {
+ "version": "1.1.6",
+ "resolved": "https://registry.npmjs.org/d3-interpolate/-/d3-interpolate-1.1.6.tgz",
+ "integrity": "sha512-mOnv5a+pZzkNIHtw/V6I+w9Lqm9L5bG3OTXPM5A+QO0yyVMQ4W1uZhR+VOJmazaOZXri2ppbiZ5BUNWT0pFM9A==",
+ "requires": {
+ "d3-color": "1.0.3"
+ }
+ },
+ "d3-path": {
+ "version": "1.0.5",
+ "resolved": "https://registry.npmjs.org/d3-path/-/d3-path-1.0.5.tgz",
+ "integrity": "sha1-JB6xhJvZ6egCHA0KeZ+KDo5EF2Q="
+ },
+ "d3-polygon": {
+ "version": "1.0.3",
+ "resolved": "https://registry.npmjs.org/d3-polygon/-/d3-polygon-1.0.3.tgz",
+ "integrity": "sha1-FoiOkCZGCTPysXllKtN4Ik04LGI="
+ },
+ "d3-quadtree": {
+ "version": "1.0.3",
+ "resolved": "https://registry.npmjs.org/d3-quadtree/-/d3-quadtree-1.0.3.tgz",
+ "integrity": "sha1-rHmH4+I/6AWpkPKOG1DTj8uCJDg="
+ },
+ "d3-queue": {
+ "version": "3.0.7",
+ "resolved": "https://registry.npmjs.org/d3-queue/-/d3-queue-3.0.7.tgz",
+ "integrity": "sha1-yTouVLQXwJWRKdfXP2z31Ckudhg="
+ },
+ "d3-random": {
+ "version": "1.1.0",
+ "resolved": "https://registry.npmjs.org/d3-random/-/d3-random-1.1.0.tgz",
+ "integrity": "sha1-ZkLlBsb6OmSFldKyRpeIqNElKdM="
+ },
+ "d3-request": {
+ "version": "1.0.6",
+ "resolved": "https://registry.npmjs.org/d3-request/-/d3-request-1.0.6.tgz",
+ "integrity": "sha512-FJj8ySY6GYuAJHZMaCQ83xEYE4KbkPkmxZ3Hu6zA1xxG2GD+z6P+Lyp+zjdsHf0xEbp2xcluDI50rCS855EQ6w==",
+ "requires": {
+ "d3-collection": "1.0.4",
+ "d3-dispatch": "1.0.3",
+ "d3-dsv": "1.0.8",
+ "xmlhttprequest": "1.8.0"
+ }
+ },
+ "d3-scale": {
+ "version": "1.0.7",
+ "resolved": "https://registry.npmjs.org/d3-scale/-/d3-scale-1.0.7.tgz",
+ "integrity": "sha512-KvU92czp2/qse5tUfGms6Kjig0AhHOwkzXG0+PqIJB3ke0WUv088AHMZI0OssO9NCkXt4RP8yju9rpH8aGB7Lw==",
+ "requires": {
+ "d3-array": "1.2.1",
+ "d3-collection": "1.0.4",
+ "d3-color": "1.0.3",
+ "d3-format": "1.2.2",
+ "d3-interpolate": "1.1.6",
+ "d3-time": "1.0.8",
+ "d3-time-format": "2.1.1"
+ }
+ },
+ "d3-selection": {
+ "version": "1.3.0",
+ "resolved": "https://registry.npmjs.org/d3-selection/-/d3-selection-1.3.0.tgz",
+ "integrity": "sha512-qgpUOg9tl5CirdqESUAu0t9MU/t3O9klYfGfyKsXEmhyxyzLpzpeh08gaxBUTQw1uXIOkr/30Ut2YRjSSxlmHA=="
+ },
+ "d3-shape": {
+ "version": "1.2.0",
+ "resolved": "https://registry.npmjs.org/d3-shape/-/d3-shape-1.2.0.tgz",
+ "integrity": "sha1-RdAVOPBkuv0F6j1tLLdI/YxB93c=",
+ "requires": {
+ "d3-path": "1.0.5"
+ }
+ },
+ "d3-time": {
+ "version": "1.0.8",
+ "resolved": "https://registry.npmjs.org/d3-time/-/d3-time-1.0.8.tgz",
+ "integrity": "sha512-YRZkNhphZh3KcnBfitvF3c6E0JOFGikHZ4YqD+Lzv83ZHn1/u6yGenRU1m+KAk9J1GnZMnKcrtfvSktlA1DXNQ=="
+ },
+ "d3-time-format": {
+ "version": "2.1.1",
+ "resolved": "https://registry.npmjs.org/d3-time-format/-/d3-time-format-2.1.1.tgz",
+ "integrity": "sha512-8kAkymq2WMfzW7e+s/IUNAtN/y3gZXGRrdGfo6R8NKPAA85UBTxZg5E61bR6nLwjPjj4d3zywSQe1CkYLPFyrw==",
+ "requires": {
+ "d3-time": "1.0.8"
+ }
+ },
+ "d3-timer": {
+ "version": "1.0.7",
+ "resolved": "https://registry.npmjs.org/d3-timer/-/d3-timer-1.0.7.tgz",
+ "integrity": "sha512-vMZXR88XujmG/L5oB96NNKH5lCWwiLM/S2HyyAQLcjWJCloK5shxta4CwOFYLZoY3AWX73v8Lgv4cCAdWtRmOA=="
+ },
+ "d3-tip": {
+ "version": "0.7.1",
+ "resolved": "https://registry.npmjs.org/d3-tip/-/d3-tip-0.7.1.tgz",
+ "integrity": "sha1-eMv1VPZ7cgpw47DxkeFM/+aM3Xk=",
+ "requires": {
+ "d3": "4.13.0"
+ }
+ },
+ "d3-transition": {
+ "version": "1.1.1",
+ "resolved": "https://registry.npmjs.org/d3-transition/-/d3-transition-1.1.1.tgz",
+ "integrity": "sha512-xeg8oggyQ+y5eb4J13iDgKIjUcEfIOZs2BqV/eEmXm2twx80wTzJ4tB4vaZ5BKfz7XsI/DFmQL5me6O27/5ykQ==",
+ "requires": {
+ "d3-color": "1.0.3",
+ "d3-dispatch": "1.0.3",
+ "d3-ease": "1.0.3",
+ "d3-interpolate": "1.1.6",
+ "d3-selection": "1.3.0",
+ "d3-timer": "1.0.7"
+ }
+ },
+ "d3-voronoi": {
+ "version": "1.1.2",
+ "resolved": "https://registry.npmjs.org/d3-voronoi/-/d3-voronoi-1.1.2.tgz",
+ "integrity": "sha1-Fodmfo8TotFYyAwUgMWinLDYlzw="
+ },
+ "d3-zoom": {
+ "version": "1.7.1",
+ "resolved": "https://registry.npmjs.org/d3-zoom/-/d3-zoom-1.7.1.tgz",
+ "integrity": "sha512-sZHQ55DGq5BZBFGnRshUT8tm2sfhPHFnOlmPbbwTkAoPeVdRTkB4Xsf9GCY0TSHrTD8PeJPZGmP/TpGicwJDJQ==",
+ "requires": {
+ "d3-dispatch": "1.0.3",
+ "d3-drag": "1.2.1",
+ "d3-interpolate": "1.1.6",
+ "d3-selection": "1.3.0",
+ "d3-transition": "1.1.1"
+ }
+ },
+ "dashdash": {
+ "version": "1.14.1",
+ "resolved": "https://registry.npmjs.org/dashdash/-/dashdash-1.14.1.tgz",
+ "integrity": "sha1-hTz6D3y+L+1d4gMmuN1YEDX24vA=",
+ "dev": true,
+ "requires": {
+ "assert-plus": "1.0.0"
+ }
+ },
+ "date-now": {
+ "version": "0.1.4",
+ "resolved": "https://registry.npmjs.org/date-now/-/date-now-0.1.4.tgz",
+ "integrity": "sha1-6vQ5/U1ISK105cx9vvIAZyueNFs=",
+ "dev": true
+ },
+ "dateformat": {
+ "version": "2.2.0",
+ "resolved": "https://registry.npmjs.org/dateformat/-/dateformat-2.2.0.tgz",
+ "integrity": "sha1-QGXiATz5+5Ft39gu+1Bq1MZ2kGI=",
+ "dev": true
+ },
+ "debug": {
+ "version": "2.6.9",
+ "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz",
+ "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==",
+ "dev": true,
+ "requires": {
+ "ms": "2.0.0"
+ }
+ },
+ "decamelize": {
+ "version": "1.2.0",
+ "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-1.2.0.tgz",
+ "integrity": "sha1-9lNNFRSCabIDUue+4m9QH5oZEpA="
+ },
+ "decode-uri-component": {
+ "version": "0.2.0",
+ "resolved": "https://registry.npmjs.org/decode-uri-component/-/decode-uri-component-0.2.0.tgz",
+ "integrity": "sha1-6zkTMzRYd1y4TNGh+uBiEGu4dUU=",
+ "dev": true
+ },
+ "defaults": {
+ "version": "1.0.3",
+ "resolved": "https://registry.npmjs.org/defaults/-/defaults-1.0.3.tgz",
+ "integrity": "sha1-xlYFHpgX2f8I7YgUd/P+QBnz730=",
+ "dev": true,
+ "requires": {
+ "clone": "1.0.4"
+ }
+ },
+ "define-property": {
+ "version": "2.0.2",
+ "resolved": "https://registry.npmjs.org/define-property/-/define-property-2.0.2.tgz",
+ "integrity": "sha512-jwK2UV4cnPpbcG7+VRARKTZPUWowwXA8bzH5NP6ud0oeAxyYPuGZUAC7hMugpCdz4BeSZl2Dl9k66CHJ/46ZYQ==",
+ "dev": true,
+ "requires": {
+ "is-descriptor": "1.0.2",
+ "isobject": "3.0.1"
+ },
+ "dependencies": {
+ "is-accessor-descriptor": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-1.0.0.tgz",
+ "integrity": "sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ==",
+ "dev": true,
+ "requires": {
+ "kind-of": "6.0.2"
+ }
+ },
+ "is-data-descriptor": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-1.0.0.tgz",
+ "integrity": "sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ==",
+ "dev": true,
+ "requires": {
+ "kind-of": "6.0.2"
+ }
+ },
+ "is-descriptor": {
+ "version": "1.0.2",
+ "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-1.0.2.tgz",
+ "integrity": "sha512-2eis5WqQGV7peooDyLmNEPUrps9+SXX5c9pL3xEB+4e9HnGuDa7mB7kHxHw4CbqS9k1T2hOH3miL8n8WtiYVtg==",
+ "dev": true,
+ "requires": {
+ "is-accessor-descriptor": "1.0.0",
+ "is-data-descriptor": "1.0.0",
+ "kind-of": "6.0.2"
+ }
+ },
+ "kind-of": {
+ "version": "6.0.2",
+ "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.2.tgz",
+ "integrity": "sha512-s5kLOcnH0XqDO+FvuaLX8DDjZ18CGFk7VygH40QoKPUQhW4e2rvM0rwUq0t8IQDOwYSeLK01U90OjzBTme2QqA==",
+ "dev": true
+ }
+ }
+ },
+ "defined": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/defined/-/defined-1.0.0.tgz",
+ "integrity": "sha1-yY2bzvdWdBiOEQlpFRGZ45sfppM=",
+ "dev": true
+ },
+ "delayed-stream": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz",
+ "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=",
+ "dev": true
+ },
+ "delegates": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/delegates/-/delegates-1.0.0.tgz",
+ "integrity": "sha1-hMbhWbgZBP3KWaDvRM2HDTElD5o=",
+ "dev": true
+ },
+ "deprecated": {
+ "version": "0.0.1",
+ "resolved": "https://registry.npmjs.org/deprecated/-/deprecated-0.0.1.tgz",
+ "integrity": "sha1-+cmvVGSvoeepcUWKi97yqpTVuxk=",
+ "dev": true
+ },
+ "deps-sort": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/deps-sort/-/deps-sort-2.0.0.tgz",
+ "integrity": "sha1-CRckkC6EZYJg65EHSMzNGvbiH7U=",
+ "dev": true,
+ "requires": {
+ "JSONStream": "1.3.2",
+ "shasum": "1.0.2",
+ "subarg": "1.0.0",
+ "through2": "2.0.3"
+ }
+ },
+ "des.js": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/des.js/-/des.js-1.0.0.tgz",
+ "integrity": "sha1-wHTS4qpqipoH29YfmhXCzYPsjsw=",
+ "dev": true,
+ "requires": {
+ "inherits": "2.0.3",
+ "minimalistic-assert": "1.0.1"
+ }
+ },
+ "detect-file": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/detect-file/-/detect-file-1.0.0.tgz",
+ "integrity": "sha1-8NZtA2cqglyxtzvbP+YjEMjlUrc=",
+ "dev": true
+ },
+ "detect-indent": {
+ "version": "4.0.0",
+ "resolved": "https://registry.npmjs.org/detect-indent/-/detect-indent-4.0.0.tgz",
+ "integrity": "sha1-920GQ1LN9Docts5hnE7jqUdd4gg=",
+ "dev": true,
+ "requires": {
+ "repeating": "2.0.1"
+ }
+ },
+ "detective": {
+ "version": "4.7.1",
+ "resolved": "https://registry.npmjs.org/detective/-/detective-4.7.1.tgz",
+ "integrity": "sha512-H6PmeeUcZloWtdt4DAkFyzFL94arpHr3NOwwmVILFiy+9Qd4JTxxXrzfyGk/lmct2qVGBwTSwSXagqu2BxmWig==",
+ "dev": true,
+ "requires": {
+ "acorn": "5.5.3",
+ "defined": "1.0.0"
+ },
+ "dependencies": {
+ "acorn": {
+ "version": "5.5.3",
+ "resolved": "https://registry.npmjs.org/acorn/-/acorn-5.5.3.tgz",
+ "integrity": "sha512-jd5MkIUlbbmb07nXH0DT3y7rDVtkzDi4XZOUVWAer8ajmF/DTSSbl5oNFyDOl/OXA33Bl79+ypHhl2pN20VeOQ==",
+ "dev": true
+ }
+ }
+ },
+ "diffie-hellman": {
+ "version": "5.0.3",
+ "resolved": "https://registry.npmjs.org/diffie-hellman/-/diffie-hellman-5.0.3.tgz",
+ "integrity": "sha512-kqag/Nl+f3GwyK25fhUMYj81BUOrZ9IuJsjIcDE5icNM9FJHAVm3VcUDxdLPoQtTuUylWm6ZIknYJwwaPxsUzg==",
+ "dev": true,
+ "requires": {
+ "bn.js": "4.11.8",
+ "miller-rabin": "4.0.1",
+ "randombytes": "2.0.6"
+ }
+ },
+ "domain-browser": {
+ "version": "1.1.7",
+ "resolved": "https://registry.npmjs.org/domain-browser/-/domain-browser-1.1.7.tgz",
+ "integrity": "sha1-hnqksJP6oF8d4IwG9NeyH9+GmLw=",
+ "dev": true
+ },
+ "duplexer2": {
+ "version": "0.1.4",
+ "resolved": "https://registry.npmjs.org/duplexer2/-/duplexer2-0.1.4.tgz",
+ "integrity": "sha1-ixLauHjA1p4+eJEFFmKjL8a93ME=",
+ "dev": true,
+ "requires": {
+ "readable-stream": "2.3.6"
+ }
+ },
+ "ecc-jsbn": {
+ "version": "0.1.1",
+ "resolved": "https://registry.npmjs.org/ecc-jsbn/-/ecc-jsbn-0.1.1.tgz",
+ "integrity": "sha1-D8c6ntXw1Tw4GTOYUj735UN3dQU=",
+ "dev": true,
+ "optional": true,
+ "requires": {
+ "jsbn": "0.1.1"
+ }
+ },
+ "elliptic": {
+ "version": "6.4.0",
+ "resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.4.0.tgz",
+ "integrity": "sha1-ysmvh2LIWDYYcAPI3+GT5eLq5d8=",
+ "dev": true,
+ "requires": {
+ "bn.js": "4.11.8",
+ "brorand": "1.1.0",
+ "hash.js": "1.1.3",
+ "hmac-drbg": "1.0.1",
+ "inherits": "2.0.3",
+ "minimalistic-assert": "1.0.1",
+ "minimalistic-crypto-utils": "1.0.1"
+ }
+ },
+ "end-of-stream": {
+ "version": "1.4.1",
+ "resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.1.tgz",
+ "integrity": "sha512-1MkrZNvWTKCaigbn+W15elq2BB/L22nqrSY5DKlo3X6+vclJm8Bb5djXJBmEX6fS3+zCh/F4VBK5Z2KxJt4s2Q==",
+ "requires": {
+ "once": "1.4.0"
+ }
+ },
+ "error-ex": {
+ "version": "1.3.1",
+ "resolved": "https://registry.npmjs.org/error-ex/-/error-ex-1.3.1.tgz",
+ "integrity": "sha1-+FWobOYa3E6GIcPNoh56dhLDqNw=",
+ "dev": true,
+ "requires": {
+ "is-arrayish": "0.2.1"
+ }
+ },
+ "escape-string-regexp": {
+ "version": "1.0.5",
+ "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz",
+ "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=",
+ "dev": true
+ },
+ "esutils": {
+ "version": "2.0.2",
+ "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.2.tgz",
+ "integrity": "sha1-Cr9PHKpbyx96nYrMbepPqqBLrJs=",
+ "dev": true
+ },
+ "events": {
+ "version": "1.1.1",
+ "resolved": "https://registry.npmjs.org/events/-/events-1.1.1.tgz",
+ "integrity": "sha1-nr23Y1rQmccNzEwqH1AEKI6L2SQ=",
+ "dev": true
+ },
+ "evp_bytestokey": {
+ "version": "1.0.3",
+ "resolved": "https://registry.npmjs.org/evp_bytestokey/-/evp_bytestokey-1.0.3.tgz",
+ "integrity": "sha512-/f2Go4TognH/KvCISP7OUsHn85hT9nUkxxA9BEWxFn+Oj9o8ZNLm/40hdlgSLyuOimsrTKLUMEorQexp/aPQeA==",
+ "dev": true,
+ "requires": {
+ "md5.js": "1.3.4",
+ "safe-buffer": "5.1.1"
+ }
+ },
+ "expand-brackets": {
+ "version": "2.1.4",
+ "resolved": "https://registry.npmjs.org/expand-brackets/-/expand-brackets-2.1.4.tgz",
+ "integrity": "sha1-t3c14xXOMPa27/D4OwQVGiJEliI=",
+ "dev": true,
+ "requires": {
+ "debug": "2.6.9",
+ "define-property": "0.2.5",
+ "extend-shallow": "2.0.1",
+ "posix-character-classes": "0.1.1",
+ "regex-not": "1.0.2",
+ "snapdragon": "0.8.2",
+ "to-regex": "3.0.2"
+ },
+ "dependencies": {
+ "define-property": {
+ "version": "0.2.5",
+ "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz",
+ "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=",
+ "dev": true,
+ "requires": {
+ "is-descriptor": "0.1.6"
+ }
+ },
+ "extend-shallow": {
+ "version": "2.0.1",
+ "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz",
+ "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=",
+ "dev": true,
+ "requires": {
+ "is-extendable": "0.1.1"
+ }
+ }
+ }
+ },
+ "expand-tilde": {
+ "version": "2.0.2",
+ "resolved": "https://registry.npmjs.org/expand-tilde/-/expand-tilde-2.0.2.tgz",
+ "integrity": "sha1-l+gBqgUt8CRU3kawK/YhZCzchQI=",
+ "dev": true,
+ "requires": {
+ "homedir-polyfill": "1.0.1"
+ }
+ },
+ "extend": {
+ "version": "3.0.1",
+ "resolved": "https://registry.npmjs.org/extend/-/extend-3.0.1.tgz",
+ "integrity": "sha1-p1Xqe8Gt/MWjHOfnYtuq3F5jZEQ=",
+ "dev": true
+ },
+ "extend-shallow": {
+ "version": "3.0.2",
+ "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-3.0.2.tgz",
+ "integrity": "sha1-Jqcarwc7OfshJxcnRhMcJwQCjbg=",
+ "dev": true,
+ "requires": {
+ "assign-symbols": "1.0.0",
+ "is-extendable": "1.0.1"
+ },
+ "dependencies": {
+ "is-extendable": {
+ "version": "1.0.1",
+ "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-1.0.1.tgz",
+ "integrity": "sha512-arnXMxT1hhoKo9k1LZdmlNyJdDDfy2v0fXjFlmok4+i8ul/6WlbVge9bhM74OpNPQPMGUToDtz+KXa1PneJxOA==",
+ "dev": true,
+ "requires": {
+ "is-plain-object": "2.0.4"
+ }
+ }
+ }
+ },
+ "extglob": {
+ "version": "2.0.4",
+ "resolved": "https://registry.npmjs.org/extglob/-/extglob-2.0.4.tgz",
+ "integrity": "sha512-Nmb6QXkELsuBr24CJSkilo6UHHgbekK5UiZgfE6UHD3Eb27YC6oD+bhcT+tJ6cl8dmsgdQxnWlcry8ksBIBLpw==",
+ "dev": true,
+ "requires": {
+ "array-unique": "0.3.2",
+ "define-property": "1.0.0",
+ "expand-brackets": "2.1.4",
+ "extend-shallow": "2.0.1",
+ "fragment-cache": "0.2.1",
+ "regex-not": "1.0.2",
+ "snapdragon": "0.8.2",
+ "to-regex": "3.0.2"
+ },
+ "dependencies": {
+ "define-property": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/define-property/-/define-property-1.0.0.tgz",
+ "integrity": "sha1-dp66rz9KY6rTr56NMEybvnm/sOY=",
+ "dev": true,
+ "requires": {
+ "is-descriptor": "1.0.2"
+ }
+ },
+ "extend-shallow": {
+ "version": "2.0.1",
+ "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz",
+ "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=",
+ "dev": true,
+ "requires": {
+ "is-extendable": "0.1.1"
+ }
+ },
+ "is-accessor-descriptor": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-1.0.0.tgz",
+ "integrity": "sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ==",
+ "dev": true,
+ "requires": {
+ "kind-of": "6.0.2"
+ }
+ },
+ "is-data-descriptor": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-1.0.0.tgz",
+ "integrity": "sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ==",
+ "dev": true,
+ "requires": {
+ "kind-of": "6.0.2"
+ }
+ },
+ "is-descriptor": {
+ "version": "1.0.2",
+ "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-1.0.2.tgz",
+ "integrity": "sha512-2eis5WqQGV7peooDyLmNEPUrps9+SXX5c9pL3xEB+4e9HnGuDa7mB7kHxHw4CbqS9k1T2hOH3miL8n8WtiYVtg==",
+ "dev": true,
+ "requires": {
+ "is-accessor-descriptor": "1.0.0",
+ "is-data-descriptor": "1.0.0",
+ "kind-of": "6.0.2"
+ }
+ },
+ "kind-of": {
+ "version": "6.0.2",
+ "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.2.tgz",
+ "integrity": "sha512-s5kLOcnH0XqDO+FvuaLX8DDjZ18CGFk7VygH40QoKPUQhW4e2rvM0rwUq0t8IQDOwYSeLK01U90OjzBTme2QqA==",
+ "dev": true
+ }
+ }
+ },
+ "extsprintf": {
+ "version": "1.3.0",
+ "resolved": "https://registry.npmjs.org/extsprintf/-/extsprintf-1.3.0.tgz",
+ "integrity": "sha1-lpGEQOMEGnpBT4xS48V06zw+HgU=",
+ "dev": true
+ },
+ "fancy-log": {
+ "version": "1.3.2",
+ "resolved": "https://registry.npmjs.org/fancy-log/-/fancy-log-1.3.2.tgz",
+ "integrity": "sha1-9BEl49hPLn2JpD0G2VjI94vha+E=",
+ "dev": true,
+ "requires": {
+ "ansi-gray": "0.1.1",
+ "color-support": "1.1.3",
+ "time-stamp": "1.1.0"
+ }
+ },
+ "fast-deep-equal": {
+ "version": "1.1.0",
+ "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-1.1.0.tgz",
+ "integrity": "sha1-wFNHeBfIa1HaqFPIHgWbcz0CNhQ=",
+ "dev": true
+ },
+ "fast-json-stable-stringify": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.0.0.tgz",
+ "integrity": "sha1-1RQsDK7msRifh9OnYREGT4bIu/I=",
+ "dev": true
+ },
+ "fill-range": {
+ "version": "4.0.0",
+ "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-4.0.0.tgz",
+ "integrity": "sha1-1USBHUKPmOsGpj3EAtJAPDKMOPc=",
+ "dev": true,
+ "requires": {
+ "extend-shallow": "2.0.1",
+ "is-number": "3.0.0",
+ "repeat-string": "1.6.1",
+ "to-regex-range": "2.1.1"
+ },
+ "dependencies": {
+ "extend-shallow": {
+ "version": "2.0.1",
+ "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz",
+ "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=",
+ "dev": true,
+ "requires": {
+ "is-extendable": "0.1.1"
+ }
+ }
+ }
+ },
+ "find-index": {
+ "version": "0.1.1",
+ "resolved": "https://registry.npmjs.org/find-index/-/find-index-0.1.1.tgz",
+ "integrity": "sha1-Z101iyyjiS15Whq0cjL4tuLg3eQ=",
+ "dev": true
+ },
+ "find-up": {
+ "version": "1.1.2",
+ "resolved": "https://registry.npmjs.org/find-up/-/find-up-1.1.2.tgz",
+ "integrity": "sha1-ay6YIrGizgpgq2TWEOzK1TyyTQ8=",
+ "dev": true,
+ "requires": {
+ "path-exists": "2.1.0",
+ "pinkie-promise": "2.0.1"
+ }
+ },
+ "findup-sync": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/findup-sync/-/findup-sync-2.0.0.tgz",
+ "integrity": "sha1-kyaxSIwi0aYIhlCoaQGy2akKLLw=",
+ "dev": true,
+ "requires": {
+ "detect-file": "1.0.0",
+ "is-glob": "3.1.0",
+ "micromatch": "3.1.10",
+ "resolve-dir": "1.0.1"
+ }
+ },
+ "fined": {
+ "version": "1.1.0",
+ "resolved": "https://registry.npmjs.org/fined/-/fined-1.1.0.tgz",
+ "integrity": "sha1-s33IRLdqL15wgeiE98CuNE8VNHY=",
+ "dev": true,
+ "requires": {
+ "expand-tilde": "2.0.2",
+ "is-plain-object": "2.0.4",
+ "object.defaults": "1.1.0",
+ "object.pick": "1.3.0",
+ "parse-filepath": "1.0.2"
+ }
+ },
+ "first-chunk-stream": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/first-chunk-stream/-/first-chunk-stream-1.0.0.tgz",
+ "integrity": "sha1-Wb+1DNkF9g18OUzT2ayqtOatk04=",
+ "dev": true
+ },
+ "flagged-respawn": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/flagged-respawn/-/flagged-respawn-1.0.0.tgz",
+ "integrity": "sha1-Tnmumy6zi/hrO7Vr8+ClaqX8q9c=",
+ "dev": true
+ },
+ "for-in": {
+ "version": "1.0.2",
+ "resolved": "https://registry.npmjs.org/for-in/-/for-in-1.0.2.tgz",
+ "integrity": "sha1-gQaNKVqBQuwKxybG4iAMMPttXoA=",
+ "dev": true
+ },
+ "for-own": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/for-own/-/for-own-1.0.0.tgz",
+ "integrity": "sha1-xjMy9BXO3EsE2/5wz4NklMU8tEs=",
+ "dev": true,
+ "requires": {
+ "for-in": "1.0.2"
+ }
+ },
+ "forever-agent": {
+ "version": "0.6.1",
+ "resolved": "https://registry.npmjs.org/forever-agent/-/forever-agent-0.6.1.tgz",
+ "integrity": "sha1-+8cfDEGt6zf5bFd60e1C2P2sypE=",
+ "dev": true
+ },
+ "form-data": {
+ "version": "2.3.2",
+ "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.3.2.tgz",
+ "integrity": "sha1-SXBJi+YEwgwAXU9cI67NIda0kJk=",
+ "dev": true,
+ "requires": {
+ "asynckit": "0.4.0",
+ "combined-stream": "1.0.6",
+ "mime-types": "2.1.18"
+ }
+ },
+ "fragment-cache": {
+ "version": "0.2.1",
+ "resolved": "https://registry.npmjs.org/fragment-cache/-/fragment-cache-0.2.1.tgz",
+ "integrity": "sha1-QpD60n8T6Jvn8zeZxrxaCr//DRk=",
+ "dev": true,
+ "requires": {
+ "map-cache": "0.2.2"
+ }
+ },
+ "fs.realpath": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz",
+ "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=",
+ "dev": true
+ },
+ "fstream": {
+ "version": "1.0.11",
+ "resolved": "https://registry.npmjs.org/fstream/-/fstream-1.0.11.tgz",
+ "integrity": "sha1-XB+x8RdHcRTwYyoOtLcbPLD9MXE=",
+ "dev": true,
+ "requires": {
+ "graceful-fs": "4.1.11",
+ "inherits": "2.0.3",
+ "mkdirp": "0.5.1",
+ "rimraf": "2.6.2"
+ },
+ "dependencies": {
+ "graceful-fs": {
+ "version": "4.1.11",
+ "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.11.tgz",
+ "integrity": "sha1-Dovf5NHduIVNZOBOp8AOKgJuVlg=",
+ "dev": true
+ }
+ }
+ },
+ "function-bind": {
+ "version": "1.1.1",
+ "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz",
+ "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==",
+ "dev": true
+ },
+ "gauge": {
+ "version": "2.7.4",
+ "resolved": "https://registry.npmjs.org/gauge/-/gauge-2.7.4.tgz",
+ "integrity": "sha1-LANAXHU4w51+s3sxcCLjJfsBi/c=",
+ "dev": true,
+ "requires": {
+ "aproba": "1.2.0",
+ "console-control-strings": "1.1.0",
+ "has-unicode": "2.0.1",
+ "object-assign": "4.1.1",
+ "signal-exit": "3.0.2",
+ "string-width": "1.0.2",
+ "strip-ansi": "3.0.1",
+ "wide-align": "1.1.2"
+ }
+ },
+ "gaze": {
+ "version": "0.5.2",
+ "resolved": "https://registry.npmjs.org/gaze/-/gaze-0.5.2.tgz",
+ "integrity": "sha1-QLcJU30k0dRXZ9takIaJ3+aaxE8=",
+ "dev": true,
+ "requires": {
+ "globule": "0.1.0"
+ }
+ },
+ "get-caller-file": {
+ "version": "1.0.2",
+ "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-1.0.2.tgz",
+ "integrity": "sha1-9wLmMSfn4jHBYKgMFVSstw1QR+U=",
+ "dev": true
+ },
+ "get-stdin": {
+ "version": "4.0.1",
+ "resolved": "https://registry.npmjs.org/get-stdin/-/get-stdin-4.0.1.tgz",
+ "integrity": "sha1-uWjGsKBDhDJJAui/Gl3zJXmkUP4=",
+ "dev": true
+ },
+ "get-value": {
+ "version": "2.0.6",
+ "resolved": "https://registry.npmjs.org/get-value/-/get-value-2.0.6.tgz",
+ "integrity": "sha1-3BXKHGcjh8p2vTesCjlbogQqLCg=",
+ "dev": true
+ },
+ "getpass": {
+ "version": "0.1.7",
+ "resolved": "https://registry.npmjs.org/getpass/-/getpass-0.1.7.tgz",
+ "integrity": "sha1-Xv+OPmhNVprkyysSgmBOi6YhSfo=",
+ "dev": true,
+ "requires": {
+ "assert-plus": "1.0.0"
+ }
+ },
+ "glob": {
+ "version": "7.1.2",
+ "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz",
+ "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==",
+ "dev": true,
+ "requires": {
+ "fs.realpath": "1.0.0",
+ "inflight": "1.0.6",
+ "inherits": "2.0.3",
+ "minimatch": "3.0.4",
+ "once": "1.4.0",
+ "path-is-absolute": "1.0.1"
+ }
+ },
+ "glob-stream": {
+ "version": "3.1.18",
+ "resolved": "https://registry.npmjs.org/glob-stream/-/glob-stream-3.1.18.tgz",
+ "integrity": "sha1-kXCl8St5Awb9/lmPMT+PeVT9FDs=",
+ "dev": true,
+ "requires": {
+ "glob": "4.5.3",
+ "glob2base": "0.0.12",
+ "minimatch": "2.0.10",
+ "ordered-read-streams": "0.1.0",
+ "through2": "0.6.5",
+ "unique-stream": "1.0.0"
+ },
+ "dependencies": {
+ "glob": {
+ "version": "4.5.3",
+ "resolved": "https://registry.npmjs.org/glob/-/glob-4.5.3.tgz",
+ "integrity": "sha1-xstz0yJsHv7wTePFbQEvAzd+4V8=",
+ "dev": true,
+ "requires": {
+ "inflight": "1.0.6",
+ "inherits": "2.0.3",
+ "minimatch": "2.0.10",
+ "once": "1.4.0"
+ }
+ },
+ "isarray": {
+ "version": "0.0.1",
+ "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz",
+ "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=",
+ "dev": true
+ },
+ "minimatch": {
+ "version": "2.0.10",
+ "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-2.0.10.tgz",
+ "integrity": "sha1-jQh8OcazjAAbl/ynzm0OHoCvusc=",
+ "dev": true,
+ "requires": {
+ "brace-expansion": "1.1.11"
+ }
+ },
+ "readable-stream": {
+ "version": "1.0.34",
+ "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.0.34.tgz",
+ "integrity": "sha1-Elgg40vIQtLyqq+v5MKRbuMsFXw=",
+ "dev": true,
+ "requires": {
+ "core-util-is": "1.0.2",
+ "inherits": "2.0.3",
+ "isarray": "0.0.1",
+ "string_decoder": "0.10.31"
+ }
+ },
+ "string_decoder": {
+ "version": "0.10.31",
+ "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz",
+ "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=",
+ "dev": true
+ },
+ "through2": {
+ "version": "0.6.5",
+ "resolved": "https://registry.npmjs.org/through2/-/through2-0.6.5.tgz",
+ "integrity": "sha1-QaucZ7KdVyCQcUEOHXp6lozTrUg=",
+ "dev": true,
+ "requires": {
+ "readable-stream": "1.0.34",
+ "xtend": "4.0.1"
+ }
+ }
+ }
+ },
+ "glob-watcher": {
+ "version": "0.0.6",
+ "resolved": "https://registry.npmjs.org/glob-watcher/-/glob-watcher-0.0.6.tgz",
+ "integrity": "sha1-uVtKjfdLOcgymLDAXJeLTZo7cQs=",
+ "dev": true,
+ "requires": {
+ "gaze": "0.5.2"
+ }
+ },
+ "glob2base": {
+ "version": "0.0.12",
+ "resolved": "https://registry.npmjs.org/glob2base/-/glob2base-0.0.12.tgz",
+ "integrity": "sha1-nUGbPijxLoOjYhZKJ3BVkiycDVY=",
+ "dev": true,
+ "requires": {
+ "find-index": "0.1.1"
+ }
+ },
+ "global-modules": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/global-modules/-/global-modules-1.0.0.tgz",
+ "integrity": "sha512-sKzpEkf11GpOFuw0Zzjzmt4B4UZwjOcG757PPvrfhxcLFbq0wpsgpOqxpxtxFiCG4DtG93M6XRVbF2oGdev7bg==",
+ "dev": true,
+ "requires": {
+ "global-prefix": "1.0.2",
+ "is-windows": "1.0.2",
+ "resolve-dir": "1.0.1"
+ }
+ },
+ "global-prefix": {
+ "version": "1.0.2",
+ "resolved": "https://registry.npmjs.org/global-prefix/-/global-prefix-1.0.2.tgz",
+ "integrity": "sha1-2/dDxsFJklk8ZVVoy2btMsASLr4=",
+ "dev": true,
+ "requires": {
+ "expand-tilde": "2.0.2",
+ "homedir-polyfill": "1.0.1",
+ "ini": "1.3.5",
+ "is-windows": "1.0.2",
+ "which": "1.3.0"
+ }
+ },
+ "globals": {
+ "version": "9.18.0",
+ "resolved": "https://registry.npmjs.org/globals/-/globals-9.18.0.tgz",
+ "integrity": "sha512-S0nG3CLEQiY/ILxqtztTWH/3iRRdyBLw6KMDxnKMchrtbj2OFmehVh0WUCfW3DUrIgx/qFrJPICrq4Z4sTR9UQ==",
+ "dev": true
+ },
+ "globule": {
+ "version": "0.1.0",
+ "resolved": "https://registry.npmjs.org/globule/-/globule-0.1.0.tgz",
+ "integrity": "sha1-2cjt3h2nnRJaFRt5UzuXhnY0auU=",
+ "dev": true,
+ "requires": {
+ "glob": "3.1.21",
+ "lodash": "1.0.2",
+ "minimatch": "0.2.14"
+ },
+ "dependencies": {
+ "glob": {
+ "version": "3.1.21",
+ "resolved": "https://registry.npmjs.org/glob/-/glob-3.1.21.tgz",
+ "integrity": "sha1-0p4KBV3qUTj00H7UDomC6DwgZs0=",
+ "dev": true,
+ "requires": {
+ "graceful-fs": "1.2.3",
+ "inherits": "1.0.2",
+ "minimatch": "0.2.14"
+ }
+ },
+ "graceful-fs": {
+ "version": "1.2.3",
+ "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-1.2.3.tgz",
+ "integrity": "sha1-FaSAaldUfLLS2/J/QuiajDRRs2Q=",
+ "dev": true
+ },
+ "inherits": {
+ "version": "1.0.2",
+ "resolved": "https://registry.npmjs.org/inherits/-/inherits-1.0.2.tgz",
+ "integrity": "sha1-ykMJ2t7mtUzAuNJH6NfHoJdb3Js=",
+ "dev": true
+ },
+ "lodash": {
+ "version": "1.0.2",
+ "resolved": "https://registry.npmjs.org/lodash/-/lodash-1.0.2.tgz",
+ "integrity": "sha1-j1dWDIO1n8JwvT1WG2kAQ0MOJVE=",
+ "dev": true
+ },
+ "minimatch": {
+ "version": "0.2.14",
+ "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-0.2.14.tgz",
+ "integrity": "sha1-x054BXT2PG+aCQ6Q775u9TpqdWo=",
+ "dev": true,
+ "requires": {
+ "lru-cache": "2.7.3",
+ "sigmund": "1.0.1"
+ }
+ }
+ }
+ },
+ "glogg": {
+ "version": "1.0.1",
+ "resolved": "https://registry.npmjs.org/glogg/-/glogg-1.0.1.tgz",
+ "integrity": "sha512-ynYqXLoluBKf9XGR1gA59yEJisIL7YHEH4xr3ZziHB5/yl4qWfaK8Js9jGe6gBGCSCKVqiyO30WnRZADvemUNw==",
+ "requires": {
+ "sparkles": "1.0.0"
+ }
+ },
+ "graceful-fs": {
+ "version": "3.0.11",
+ "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-3.0.11.tgz",
+ "integrity": "sha1-dhPHeKGv6mLyXGMKCG1/Osu92Bg=",
+ "dev": true,
+ "requires": {
+ "natives": "1.1.3"
+ }
+ },
+ "gulp": {
+ "version": "3.9.1",
+ "resolved": "https://registry.npmjs.org/gulp/-/gulp-3.9.1.tgz",
+ "integrity": "sha1-VxzkWSjdQK9lFPxAEYZgFsE4RbQ=",
+ "dev": true,
+ "requires": {
+ "archy": "1.0.0",
+ "chalk": "1.1.3",
+ "deprecated": "0.0.1",
+ "gulp-util": "3.0.8",
+ "interpret": "1.1.0",
+ "liftoff": "2.5.0",
+ "minimist": "1.2.0",
+ "orchestrator": "0.3.8",
+ "pretty-hrtime": "1.0.3",
+ "semver": "4.3.6",
+ "tildify": "1.2.0",
+ "v8flags": "2.1.1",
+ "vinyl-fs": "0.3.14"
+ },
+ "dependencies": {
+ "minimist": {
+ "version": "1.2.0",
+ "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz",
+ "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=",
+ "dev": true
+ }
+ }
+ },
+ "gulp-rename": {
+ "version": "1.2.2",
+ "resolved": "https://registry.npmjs.org/gulp-rename/-/gulp-rename-1.2.2.tgz",
+ "integrity": "sha1-OtRCh2PwXidk3sHGfYaNsnVoeBc=",
+ "dev": true
+ },
+ "gulp-sass": {
+ "version": "2.3.2",
+ "resolved": "https://registry.npmjs.org/gulp-sass/-/gulp-sass-2.3.2.tgz",
+ "integrity": "sha1-grerkP6QLNw0wE8YDZLyw0kC3VI=",
+ "dev": true,
+ "requires": {
+ "gulp-util": "3.0.8",
+ "lodash.clonedeep": "4.5.0",
+ "node-sass": "3.13.1",
+ "through2": "2.0.3",
+ "vinyl-sourcemaps-apply": "0.2.1"
+ }
+ },
+ "gulp-uglify": {
+ "version": "2.1.2",
+ "resolved": "https://registry.npmjs.org/gulp-uglify/-/gulp-uglify-2.1.2.tgz",
+ "integrity": "sha1-bbhbHQ7mPRgFhZK2WGSdZcLsRUE=",
+ "requires": {
+ "gulplog": "1.0.0",
+ "has-gulplog": "0.1.0",
+ "lodash": "4.17.5",
+ "make-error-cause": "1.2.2",
+ "through2": "2.0.3",
+ "uglify-js": "2.8.29",
+ "uglify-save-license": "0.4.1",
+ "vinyl-sourcemaps-apply": "0.2.1"
+ }
+ },
+ "gulp-util": {
+ "version": "3.0.8",
+ "resolved": "https://registry.npmjs.org/gulp-util/-/gulp-util-3.0.8.tgz",
+ "integrity": "sha1-AFTh50RQLifATBh8PsxQXdVLu08=",
+ "dev": true,
+ "requires": {
+ "array-differ": "1.0.0",
+ "array-uniq": "1.0.3",
+ "beeper": "1.1.1",
+ "chalk": "1.1.3",
+ "dateformat": "2.2.0",
+ "fancy-log": "1.3.2",
+ "gulplog": "1.0.0",
+ "has-gulplog": "0.1.0",
+ "lodash._reescape": "3.0.0",
+ "lodash._reevaluate": "3.0.0",
+ "lodash._reinterpolate": "3.0.0",
+ "lodash.template": "3.6.2",
+ "minimist": "1.2.0",
+ "multipipe": "0.1.2",
+ "object-assign": "3.0.0",
+ "replace-ext": "0.0.1",
+ "through2": "2.0.3",
+ "vinyl": "0.5.3"
+ },
+ "dependencies": {
+ "minimist": {
+ "version": "1.2.0",
+ "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz",
+ "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=",
+ "dev": true
+ },
+ "object-assign": {
+ "version": "3.0.0",
+ "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-3.0.0.tgz",
+ "integrity": "sha1-m+3VygiXlJvKR+f/QIBi1Un1h/I=",
+ "dev": true
+ }
+ }
+ },
+ "gulplog": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/gulplog/-/gulplog-1.0.0.tgz",
+ "integrity": "sha1-4oxNRdBey77YGDY86PnFkmIp/+U=",
+ "requires": {
+ "glogg": "1.0.1"
+ }
+ },
+ "har-schema": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/har-schema/-/har-schema-2.0.0.tgz",
+ "integrity": "sha1-qUwiJOvKwEeCoNkDVSHyRzW37JI=",
+ "dev": true
+ },
+ "har-validator": {
+ "version": "5.0.3",
+ "resolved": "https://registry.npmjs.org/har-validator/-/har-validator-5.0.3.tgz",
+ "integrity": "sha1-ukAsJmGU8VlW7xXg/PJCmT9qff0=",
+ "dev": true,
+ "requires": {
+ "ajv": "5.5.2",
+ "har-schema": "2.0.0"
+ }
+ },
+ "has": {
+ "version": "1.0.1",
+ "resolved": "https://registry.npmjs.org/has/-/has-1.0.1.tgz",
+ "integrity": "sha1-hGFzP1OLCDfJNh45qauelwTcLyg=",
+ "dev": true,
+ "requires": {
+ "function-bind": "1.1.1"
+ }
+ },
+ "has-ansi": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/has-ansi/-/has-ansi-2.0.0.tgz",
+ "integrity": "sha1-NPUEnOHs3ysGSa8+8k5F7TVBbZE=",
+ "dev": true,
+ "requires": {
+ "ansi-regex": "2.1.1"
+ }
+ },
+ "has-gulplog": {
+ "version": "0.1.0",
+ "resolved": "https://registry.npmjs.org/has-gulplog/-/has-gulplog-0.1.0.tgz",
+ "integrity": "sha1-ZBTIKRNpfaUVkDl9r7EvIpZ4Ec4=",
+ "requires": {
+ "sparkles": "1.0.0"
+ }
+ },
+ "has-unicode": {
+ "version": "2.0.1",
+ "resolved": "https://registry.npmjs.org/has-unicode/-/has-unicode-2.0.1.tgz",
+ "integrity": "sha1-4Ob+aijPUROIVeCG0Wkedx3iqLk=",
+ "dev": true
+ },
+ "has-value": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/has-value/-/has-value-1.0.0.tgz",
+ "integrity": "sha1-GLKB2lhbHFxR3vJMkw7SmgvmsXc=",
+ "dev": true,
+ "requires": {
+ "get-value": "2.0.6",
+ "has-values": "1.0.0",
+ "isobject": "3.0.1"
+ }
+ },
+ "has-values": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/has-values/-/has-values-1.0.0.tgz",
+ "integrity": "sha1-lbC2P+whRmGab+V/51Yo1aOe/k8=",
+ "dev": true,
+ "requires": {
+ "is-number": "3.0.0",
+ "kind-of": "4.0.0"
+ },
+ "dependencies": {
+ "kind-of": {
+ "version": "4.0.0",
+ "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-4.0.0.tgz",
+ "integrity": "sha1-IIE989cSkosgc3hpGkUGb65y3Vc=",
+ "dev": true,
+ "requires": {
+ "is-buffer": "1.1.6"
+ }
+ }
+ }
+ },
+ "hash-base": {
+ "version": "3.0.4",
+ "resolved": "https://registry.npmjs.org/hash-base/-/hash-base-3.0.4.tgz",
+ "integrity": "sha1-X8hoaEfs1zSZQDMZprCj8/auSRg=",
+ "dev": true,
+ "requires": {
+ "inherits": "2.0.3",
+ "safe-buffer": "5.1.1"
+ }
+ },
+ "hash.js": {
+ "version": "1.1.3",
+ "resolved": "https://registry.npmjs.org/hash.js/-/hash.js-1.1.3.tgz",
+ "integrity": "sha512-/UETyP0W22QILqS+6HowevwhEFJ3MBJnwTf75Qob9Wz9t0DPuisL8kW8YZMK62dHAKE1c1p+gY1TtOLY+USEHA==",
+ "dev": true,
+ "requires": {
+ "inherits": "2.0.3",
+ "minimalistic-assert": "1.0.1"
+ }
+ },
+ "hawk": {
+ "version": "6.0.2",
+ "resolved": "https://registry.npmjs.org/hawk/-/hawk-6.0.2.tgz",
+ "integrity": "sha512-miowhl2+U7Qle4vdLqDdPt9m09K6yZhkLDTWGoUiUzrQCn+mHHSmfJgAyGaLRZbPmTqfFFjRV1QWCW0VWUJBbQ==",
+ "dev": true,
+ "requires": {
+ "boom": "4.3.1",
+ "cryptiles": "3.1.2",
+ "hoek": "4.2.1",
+ "sntp": "2.1.0"
+ }
+ },
+ "hmac-drbg": {
+ "version": "1.0.1",
+ "resolved": "https://registry.npmjs.org/hmac-drbg/-/hmac-drbg-1.0.1.tgz",
+ "integrity": "sha1-0nRXAQJabHdabFRXk+1QL8DGSaE=",
+ "dev": true,
+ "requires": {
+ "hash.js": "1.1.3",
+ "minimalistic-assert": "1.0.1",
+ "minimalistic-crypto-utils": "1.0.1"
+ }
+ },
+ "hoek": {
+ "version": "4.2.1",
+ "resolved": "https://registry.npmjs.org/hoek/-/hoek-4.2.1.tgz",
+ "integrity": "sha512-QLg82fGkfnJ/4iy1xZ81/9SIJiq1NGFUMGs6ParyjBZr6jW2Ufj/snDqTHixNlHdPNwN2RLVD0Pi3igeK9+JfA==",
+ "dev": true
+ },
+ "home-or-tmp": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/home-or-tmp/-/home-or-tmp-2.0.0.tgz",
+ "integrity": "sha1-42w/LSyufXRqhX440Y1fMqeILbg=",
+ "dev": true,
+ "requires": {
+ "os-homedir": "1.0.2",
+ "os-tmpdir": "1.0.2"
+ }
+ },
+ "homedir-polyfill": {
+ "version": "1.0.1",
+ "resolved": "https://registry.npmjs.org/homedir-polyfill/-/homedir-polyfill-1.0.1.tgz",
+ "integrity": "sha1-TCu8inWJmP7r9e1oWA921GdotLw=",
+ "dev": true,
+ "requires": {
+ "parse-passwd": "1.0.0"
+ }
+ },
+ "hosted-git-info": {
+ "version": "2.6.0",
+ "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.6.0.tgz",
+ "integrity": "sha512-lIbgIIQA3lz5XaB6vxakj6sDHADJiZadYEJB+FgA+C4nubM1NwcuvUr9EJPmnH1skZqpqUzWborWo8EIUi0Sdw==",
+ "dev": true
+ },
+ "htmlescape": {
+ "version": "1.1.1",
+ "resolved": "https://registry.npmjs.org/htmlescape/-/htmlescape-1.1.1.tgz",
+ "integrity": "sha1-OgPtwiFLyjtmQko+eVk0lQnLA1E=",
+ "dev": true
+ },
+ "http-signature": {
+ "version": "1.2.0",
+ "resolved": "https://registry.npmjs.org/http-signature/-/http-signature-1.2.0.tgz",
+ "integrity": "sha1-muzZJRFHcvPZW2WmCruPfBj7rOE=",
+ "dev": true,
+ "requires": {
+ "assert-plus": "1.0.0",
+ "jsprim": "1.4.1",
+ "sshpk": "1.14.1"
+ }
+ },
+ "https-browserify": {
+ "version": "0.0.1",
+ "resolved": "https://registry.npmjs.org/https-browserify/-/https-browserify-0.0.1.tgz",
+ "integrity": "sha1-P5E2XKvmC3ftDruiS0VOPgnZWoI=",
+ "dev": true
+ },
+ "iconv-lite": {
+ "version": "0.4.21",
+ "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.21.tgz",
+ "integrity": "sha512-En5V9za5mBt2oUA03WGD3TwDv0MKAruqsuxstbMUZaj9W9k/m1CV/9py3l0L5kw9Bln8fdHQmzHSYtvpvTLpKw==",
+ "requires": {
+ "safer-buffer": "2.1.2"
+ }
+ },
+ "ieee754": {
+ "version": "1.1.11",
+ "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.1.11.tgz",
+ "integrity": "sha512-VhDzCKN7K8ufStx/CLj5/PDTMgph+qwN5Pkd5i0sGnVwk56zJ0lkT8Qzi1xqWLS0Wp29DgDtNeS7v8/wMoZeHg==",
+ "dev": true
+ },
+ "in-publish": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/in-publish/-/in-publish-2.0.0.tgz",
+ "integrity": "sha1-4g/146KvwmkDILbcVSaCqcf631E=",
+ "dev": true
+ },
+ "indent-string": {
+ "version": "2.1.0",
+ "resolved": "https://registry.npmjs.org/indent-string/-/indent-string-2.1.0.tgz",
+ "integrity": "sha1-ji1INIdCEhtKghi3oTfppSBJ3IA=",
+ "dev": true,
+ "requires": {
+ "repeating": "2.0.1"
+ }
+ },
+ "indexof": {
+ "version": "0.0.1",
+ "resolved": "https://registry.npmjs.org/indexof/-/indexof-0.0.1.tgz",
+ "integrity": "sha1-gtwzbSMrkGIXnQWrMpOmYFn9Q10=",
+ "dev": true
+ },
+ "inflight": {
+ "version": "1.0.6",
+ "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz",
+ "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=",
+ "dev": true,
+ "requires": {
+ "once": "1.4.0",
+ "wrappy": "1.0.2"
+ }
+ },
+ "inherits": {
+ "version": "2.0.3",
+ "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz",
+ "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4="
+ },
+ "ini": {
+ "version": "1.3.5",
+ "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.5.tgz",
+ "integrity": "sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw==",
+ "dev": true
+ },
+ "inline-source-map": {
+ "version": "0.6.2",
+ "resolved": "https://registry.npmjs.org/inline-source-map/-/inline-source-map-0.6.2.tgz",
+ "integrity": "sha1-+Tk0ccGKedFyT4Y/o4tYY3Ct4qU=",
+ "dev": true,
+ "requires": {
+ "source-map": "0.5.7"
+ }
+ },
+ "insert-module-globals": {
+ "version": "7.0.6",
+ "resolved": "https://registry.npmjs.org/insert-module-globals/-/insert-module-globals-7.0.6.tgz",
+ "integrity": "sha512-R3sidKJr3SsggqQQ5cEwQb3pWG8RNx0UnpyeiOSR6jorRIeAOzH2gkTWnNdMnyRiVbjrG047K7UCtlMkQ1Mo9w==",
+ "dev": true,
+ "requires": {
+ "JSONStream": "1.3.2",
+ "combine-source-map": "0.8.0",
+ "concat-stream": "1.6.2",
+ "is-buffer": "1.1.6",
+ "lexical-scope": "1.2.0",
+ "path-is-absolute": "1.0.1",
+ "process": "0.11.10",
+ "through2": "2.0.3",
+ "xtend": "4.0.1"
+ },
+ "dependencies": {
+ "concat-stream": {
+ "version": "1.6.2",
+ "resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.6.2.tgz",
+ "integrity": "sha512-27HBghJxjiZtIk3Ycvn/4kbJk/1uZuJFfuPEns6LaEvpvG1f0hTea8lilrouyo9mVc2GWdcEZ8OLoGmSADlrCw==",
+ "dev": true,
+ "requires": {
+ "buffer-from": "1.0.0",
+ "inherits": "2.0.3",
+ "readable-stream": "2.3.6",
+ "typedarray": "0.0.6"
+ }
+ }
+ }
+ },
+ "interpret": {
+ "version": "1.1.0",
+ "resolved": "https://registry.npmjs.org/interpret/-/interpret-1.1.0.tgz",
+ "integrity": "sha1-ftGxQQxqDg94z5XTuEQMY/eLhhQ=",
+ "dev": true
+ },
+ "invariant": {
+ "version": "2.2.4",
+ "resolved": "https://registry.npmjs.org/invariant/-/invariant-2.2.4.tgz",
+ "integrity": "sha512-phJfQVBuaJM5raOpJjSfkiD6BpbCE4Ns//LaXl6wGYtUBY83nWS6Rf9tXm2e8VaK60JEjYldbPif/A2B1C2gNA==",
+ "dev": true,
+ "requires": {
+ "loose-envify": "1.3.1"
+ }
+ },
+ "invert-kv": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/invert-kv/-/invert-kv-1.0.0.tgz",
+ "integrity": "sha1-EEqOSqym09jNFXqO+L+rLXo//bY=",
+ "dev": true
+ },
+ "is-absolute": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/is-absolute/-/is-absolute-1.0.0.tgz",
+ "integrity": "sha512-dOWoqflvcydARa360Gvv18DZ/gRuHKi2NU/wU5X1ZFzdYfH29nkiNZsF3mp4OJ3H4yo9Mx8A/uAGNzpzPN3yBA==",
+ "dev": true,
+ "requires": {
+ "is-relative": "1.0.0",
+ "is-windows": "1.0.2"
+ }
+ },
+ "is-accessor-descriptor": {
+ "version": "0.1.6",
+ "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-0.1.6.tgz",
+ "integrity": "sha1-qeEss66Nh2cn7u84Q/igiXtcmNY=",
+ "dev": true,
+ "requires": {
+ "kind-of": "3.2.2"
+ }
+ },
+ "is-arrayish": {
+ "version": "0.2.1",
+ "resolved": "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.2.1.tgz",
+ "integrity": "sha1-d8mYQFJ6qOyxqLppe4BkWnqSap0=",
+ "dev": true
+ },
+ "is-buffer": {
+ "version": "1.1.6",
+ "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz",
+ "integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w=="
+ },
+ "is-builtin-module": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/is-builtin-module/-/is-builtin-module-1.0.0.tgz",
+ "integrity": "sha1-VAVy0096wxGfj3bDDLwbHgN6/74=",
+ "dev": true,
+ "requires": {
+ "builtin-modules": "1.1.1"
+ }
+ },
+ "is-data-descriptor": {
+ "version": "0.1.4",
+ "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-0.1.4.tgz",
+ "integrity": "sha1-C17mSDiOLIYCgueT8YVv7D8wG1Y=",
+ "dev": true,
+ "requires": {
+ "kind-of": "3.2.2"
+ }
+ },
+ "is-descriptor": {
+ "version": "0.1.6",
+ "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-0.1.6.tgz",
+ "integrity": "sha512-avDYr0SB3DwO9zsMov0gKCESFYqCnE4hq/4z3TdUlukEy5t9C0YRq7HLrsN52NAcqXKaepeCD0n+B0arnVG3Hg==",
+ "dev": true,
+ "requires": {
+ "is-accessor-descriptor": "0.1.6",
+ "is-data-descriptor": "0.1.4",
+ "kind-of": "5.1.0"
+ },
+ "dependencies": {
+ "kind-of": {
+ "version": "5.1.0",
+ "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-5.1.0.tgz",
+ "integrity": "sha512-NGEErnH6F2vUuXDh+OlbcKW7/wOcfdRHaZ7VWtqCztfHri/++YKmP51OdWeGPuqCOba6kk2OTe5d02VmTB80Pw==",
+ "dev": true
+ }
+ }
+ },
+ "is-extendable": {
+ "version": "0.1.1",
+ "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-0.1.1.tgz",
+ "integrity": "sha1-YrEQ4omkcUGOPsNqYX1HLjAd/Ik=",
+ "dev": true
+ },
+ "is-extglob": {
+ "version": "2.1.1",
+ "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz",
+ "integrity": "sha1-qIwCU1eR8C7TfHahueqXc8gz+MI=",
+ "dev": true
+ },
+ "is-finite": {
+ "version": "1.0.2",
+ "resolved": "https://registry.npmjs.org/is-finite/-/is-finite-1.0.2.tgz",
+ "integrity": "sha1-zGZ3aVYCvlUO8R6LSqYwU0K20Ko=",
+ "dev": true,
+ "requires": {
+ "number-is-nan": "1.0.1"
+ }
+ },
+ "is-fullwidth-code-point": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz",
+ "integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=",
+ "dev": true,
+ "requires": {
+ "number-is-nan": "1.0.1"
+ }
+ },
+ "is-glob": {
+ "version": "3.1.0",
+ "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-3.1.0.tgz",
+ "integrity": "sha1-e6WuJCF4BKxwcHuWkiVnSGzD6Eo=",
+ "dev": true,
+ "requires": {
+ "is-extglob": "2.1.1"
+ }
+ },
+ "is-number": {
+ "version": "3.0.0",
+ "resolved": "https://registry.npmjs.org/is-number/-/is-number-3.0.0.tgz",
+ "integrity": "sha1-JP1iAaR4LPUFYcgQJ2r8fRLXEZU=",
+ "dev": true,
+ "requires": {
+ "kind-of": "3.2.2"
+ }
+ },
+ "is-odd": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/is-odd/-/is-odd-2.0.0.tgz",
+ "integrity": "sha512-OTiixgpZAT1M4NHgS5IguFp/Vz2VI3U7Goh4/HA1adtwyLtSBrxYlcSYkhpAE07s4fKEcjrFxyvtQBND4vFQyQ==",
+ "dev": true,
+ "requires": {
+ "is-number": "4.0.0"
+ },
+ "dependencies": {
+ "is-number": {
+ "version": "4.0.0",
+ "resolved": "https://registry.npmjs.org/is-number/-/is-number-4.0.0.tgz",
+ "integrity": "sha512-rSklcAIlf1OmFdyAqbnWTLVelsQ58uvZ66S/ZyawjWqIviTWCjg2PzVGw8WUA+nNuPTqb4wgA+NszrJ+08LlgQ==",
+ "dev": true
+ }
+ }
+ },
+ "is-plain-object": {
+ "version": "2.0.4",
+ "resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-2.0.4.tgz",
+ "integrity": "sha512-h5PpgXkWitc38BBMYawTYMWJHFZJVnBquFE57xFpjB8pJFiF6gZ+bU+WyI/yqXiFR5mdLsgYNaPe8uao6Uv9Og==",
+ "dev": true,
+ "requires": {
+ "isobject": "3.0.1"
+ }
+ },
+ "is-relative": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/is-relative/-/is-relative-1.0.0.tgz",
+ "integrity": "sha512-Kw/ReK0iqwKeu0MITLFuj0jbPAmEiOsIwyIXvvbfa6QfmN9pkD1M+8pdk7Rl/dTKbH34/XBFMbgD4iMJhLQbGA==",
+ "dev": true,
+ "requires": {
+ "is-unc-path": "1.0.0"
+ }
+ },
+ "is-typedarray": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz",
+ "integrity": "sha1-5HnICFjfDBsR3dppQPlgEfzaSpo=",
+ "dev": true
+ },
+ "is-unc-path": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/is-unc-path/-/is-unc-path-1.0.0.tgz",
+ "integrity": "sha512-mrGpVd0fs7WWLfVsStvgF6iEJnbjDFZh9/emhRDcGWTduTfNHd9CHeUwH3gYIjdbwo4On6hunkztwOaAw0yllQ==",
+ "dev": true,
+ "requires": {
+ "unc-path-regex": "0.1.2"
+ }
+ },
+ "is-utf8": {
+ "version": "0.2.1",
+ "resolved": "https://registry.npmjs.org/is-utf8/-/is-utf8-0.2.1.tgz",
+ "integrity": "sha1-Sw2hRCEE0bM2NA6AeX6GXPOffXI=",
+ "dev": true
+ },
+ "is-windows": {
+ "version": "1.0.2",
+ "resolved": "https://registry.npmjs.org/is-windows/-/is-windows-1.0.2.tgz",
+ "integrity": "sha512-eXK1UInq2bPmjyX6e3VHIzMLobc4J94i4AWn+Hpq3OU5KkrRC96OAcR3PRJ/pGu6m8TRnBHP9dkXQVsT/COVIA==",
+ "dev": true
+ },
+ "isarray": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz",
+ "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE="
+ },
+ "isexe": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz",
+ "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=",
+ "dev": true
+ },
+ "isobject": {
+ "version": "3.0.1",
+ "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz",
+ "integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8=",
+ "dev": true
+ },
+ "isstream": {
+ "version": "0.1.2",
+ "resolved": "https://registry.npmjs.org/isstream/-/isstream-0.1.2.tgz",
+ "integrity": "sha1-R+Y/evVa+m+S4VAOaQ64uFKcCZo=",
+ "dev": true
+ },
+ "js-base64": {
+ "version": "2.4.3",
+ "resolved": "https://registry.npmjs.org/js-base64/-/js-base64-2.4.3.tgz",
+ "integrity": "sha512-H7ErYLM34CvDMto3GbD6xD0JLUGYXR3QTcH6B/tr4Hi/QpSThnCsIp+Sy5FRTw3B0d6py4HcNkW7nO/wdtGWEw==",
+ "dev": true
+ },
+ "js-tokens": {
+ "version": "3.0.2",
+ "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-3.0.2.tgz",
+ "integrity": "sha1-mGbfOVECEw449/mWvOtlRDIJwls=",
+ "dev": true
+ },
+ "jsbn": {
+ "version": "0.1.1",
+ "resolved": "https://registry.npmjs.org/jsbn/-/jsbn-0.1.1.tgz",
+ "integrity": "sha1-peZUwuWi3rXyAdls77yoDA7y9RM=",
+ "dev": true,
+ "optional": true
+ },
+ "jsesc": {
+ "version": "0.5.0",
+ "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-0.5.0.tgz",
+ "integrity": "sha1-597mbjXW/Bb3EP6R1c9p9w8IkR0=",
+ "dev": true
+ },
+ "json-schema": {
+ "version": "0.2.3",
+ "resolved": "https://registry.npmjs.org/json-schema/-/json-schema-0.2.3.tgz",
+ "integrity": "sha1-tIDIkuWaLwWVTOcnvT8qTogvnhM=",
+ "dev": true
+ },
+ "json-schema-traverse": {
+ "version": "0.3.1",
+ "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.3.1.tgz",
+ "integrity": "sha1-NJptRMU6Ud6JtAgFxdXlm0F9M0A=",
+ "dev": true
+ },
+ "json-stable-stringify": {
+ "version": "0.0.1",
+ "resolved": "https://registry.npmjs.org/json-stable-stringify/-/json-stable-stringify-0.0.1.tgz",
+ "integrity": "sha1-YRwj6BTbN1Un34URk9tZ3Sryf0U=",
+ "dev": true,
+ "requires": {
+ "jsonify": "0.0.0"
+ }
+ },
+ "json-stringify-safe": {
+ "version": "5.0.1",
+ "resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz",
+ "integrity": "sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus=",
+ "dev": true
+ },
+ "json5": {
+ "version": "0.5.1",
+ "resolved": "https://registry.npmjs.org/json5/-/json5-0.5.1.tgz",
+ "integrity": "sha1-Hq3nrMASA0rYTiOWdn6tn6VJWCE=",
+ "dev": true
+ },
+ "jsonify": {
+ "version": "0.0.0",
+ "resolved": "https://registry.npmjs.org/jsonify/-/jsonify-0.0.0.tgz",
+ "integrity": "sha1-LHS27kHZPKUbe1qu6PUDYx0lKnM=",
+ "dev": true
+ },
+ "jsonparse": {
+ "version": "1.3.1",
+ "resolved": "https://registry.npmjs.org/jsonparse/-/jsonparse-1.3.1.tgz",
+ "integrity": "sha1-P02uSpH6wxX3EGL4UhzCOfE2YoA=",
+ "dev": true
+ },
+ "jsprim": {
+ "version": "1.4.1",
+ "resolved": "https://registry.npmjs.org/jsprim/-/jsprim-1.4.1.tgz",
+ "integrity": "sha1-MT5mvB5cwG5Di8G3SZwuXFastqI=",
+ "dev": true,
+ "requires": {
+ "assert-plus": "1.0.0",
+ "extsprintf": "1.3.0",
+ "json-schema": "0.2.3",
+ "verror": "1.10.0"
+ }
+ },
+ "kind-of": {
+ "version": "3.2.2",
+ "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz",
+ "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=",
+ "requires": {
+ "is-buffer": "1.1.6"
+ }
+ },
+ "labeled-stream-splicer": {
+ "version": "2.0.1",
+ "resolved": "https://registry.npmjs.org/labeled-stream-splicer/-/labeled-stream-splicer-2.0.1.tgz",
+ "integrity": "sha512-MC94mHZRvJ3LfykJlTUipBqenZz1pacOZEMhhQ8dMGcDHs0SBE5GbsavUXV7YtP3icBW17W0Zy1I0lfASmo9Pg==",
+ "dev": true,
+ "requires": {
+ "inherits": "2.0.3",
+ "isarray": "2.0.4",
+ "stream-splicer": "2.0.0"
+ },
+ "dependencies": {
+ "isarray": {
+ "version": "2.0.4",
+ "resolved": "https://registry.npmjs.org/isarray/-/isarray-2.0.4.tgz",
+ "integrity": "sha512-GMxXOiUirWg1xTKRipM0Ek07rX+ubx4nNVElTJdNLYmNO/2YrDkgJGw9CljXn+r4EWiDQg/8lsRdHyg2PJuUaA==",
+ "dev": true
+ }
+ }
+ },
+ "lazy-cache": {
+ "version": "1.0.4",
+ "resolved": "https://registry.npmjs.org/lazy-cache/-/lazy-cache-1.0.4.tgz",
+ "integrity": "sha1-odePw6UEdMuAhF07O24dpJpEbo4="
+ },
+ "lcid": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/lcid/-/lcid-1.0.0.tgz",
+ "integrity": "sha1-MIrMr6C8SDo4Z7S28rlQYlHRuDU=",
+ "dev": true,
+ "requires": {
+ "invert-kv": "1.0.0"
+ }
+ },
+ "lexical-scope": {
+ "version": "1.2.0",
+ "resolved": "https://registry.npmjs.org/lexical-scope/-/lexical-scope-1.2.0.tgz",
+ "integrity": "sha1-/Ope3HBKSzqHls3KQZw6CvryLfQ=",
+ "dev": true,
+ "requires": {
+ "astw": "2.2.0"
+ }
+ },
+ "liftoff": {
+ "version": "2.5.0",
+ "resolved": "https://registry.npmjs.org/liftoff/-/liftoff-2.5.0.tgz",
+ "integrity": "sha1-IAkpG7Mc6oYbvxCnwVooyvdcMew=",
+ "dev": true,
+ "requires": {
+ "extend": "3.0.1",
+ "findup-sync": "2.0.0",
+ "fined": "1.1.0",
+ "flagged-respawn": "1.0.0",
+ "is-plain-object": "2.0.4",
+ "object.map": "1.0.1",
+ "rechoir": "0.6.2",
+ "resolve": "1.7.1"
+ }
+ },
+ "load-json-file": {
+ "version": "1.1.0",
+ "resolved": "https://registry.npmjs.org/load-json-file/-/load-json-file-1.1.0.tgz",
+ "integrity": "sha1-lWkFcI1YtLq0wiYbBPWfMcmTdMA=",
+ "dev": true,
+ "requires": {
+ "graceful-fs": "4.1.11",
+ "parse-json": "2.2.0",
+ "pify": "2.3.0",
+ "pinkie-promise": "2.0.1",
+ "strip-bom": "2.0.0"
+ },
+ "dependencies": {
+ "graceful-fs": {
+ "version": "4.1.11",
+ "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.11.tgz",
+ "integrity": "sha1-Dovf5NHduIVNZOBOp8AOKgJuVlg=",
+ "dev": true
+ },
+ "strip-bom": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-2.0.0.tgz",
+ "integrity": "sha1-YhmoVhZSBJHzV4i9vxRHqZx+aw4=",
+ "dev": true,
+ "requires": {
+ "is-utf8": "0.2.1"
+ }
+ }
+ }
+ },
+ "lodash": {
+ "version": "4.17.5",
+ "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.5.tgz",
+ "integrity": "sha512-svL3uiZf1RwhH+cWrfZn3A4+U58wbP0tGVTLQPbjplZxZ8ROD9VLuNgsRniTlLe7OlSqR79RUehXgpBW/s0IQw=="
+ },
+ "lodash._basecopy": {
+ "version": "3.0.1",
+ "resolved": "https://registry.npmjs.org/lodash._basecopy/-/lodash._basecopy-3.0.1.tgz",
+ "integrity": "sha1-jaDmqHbPNEwK2KVIghEd08XHyjY=",
+ "dev": true
+ },
+ "lodash._basetostring": {
+ "version": "3.0.1",
+ "resolved": "https://registry.npmjs.org/lodash._basetostring/-/lodash._basetostring-3.0.1.tgz",
+ "integrity": "sha1-0YYdh3+CSlL2aYMtyvPuFVZqB9U=",
+ "dev": true
+ },
+ "lodash._basevalues": {
+ "version": "3.0.0",
+ "resolved": "https://registry.npmjs.org/lodash._basevalues/-/lodash._basevalues-3.0.0.tgz",
+ "integrity": "sha1-W3dXYoAr3j0yl1A+JjAIIP32Ybc=",
+ "dev": true
+ },
+ "lodash._getnative": {
+ "version": "3.9.1",
+ "resolved": "https://registry.npmjs.org/lodash._getnative/-/lodash._getnative-3.9.1.tgz",
+ "integrity": "sha1-VwvH3t5G1hzc3mh9ZdPuy6o6r/U=",
+ "dev": true
+ },
+ "lodash._isiterateecall": {
+ "version": "3.0.9",
+ "resolved": "https://registry.npmjs.org/lodash._isiterateecall/-/lodash._isiterateecall-3.0.9.tgz",
+ "integrity": "sha1-UgOte6Ql+uhCRg5pbbnPPmqsBXw=",
+ "dev": true
+ },
+ "lodash._reescape": {
+ "version": "3.0.0",
+ "resolved": "https://registry.npmjs.org/lodash._reescape/-/lodash._reescape-3.0.0.tgz",
+ "integrity": "sha1-Kx1vXf4HyKNVdT5fJ/rH8c3hYWo=",
+ "dev": true
+ },
+ "lodash._reevaluate": {
+ "version": "3.0.0",
+ "resolved": "https://registry.npmjs.org/lodash._reevaluate/-/lodash._reevaluate-3.0.0.tgz",
+ "integrity": "sha1-WLx0xAZklTrgsSTYBpltrKQx4u0=",
+ "dev": true
+ },
+ "lodash._reinterpolate": {
+ "version": "3.0.0",
+ "resolved": "https://registry.npmjs.org/lodash._reinterpolate/-/lodash._reinterpolate-3.0.0.tgz",
+ "integrity": "sha1-DM8tiRZq8Ds2Y8eWU4t1rG4RTZ0=",
+ "dev": true
+ },
+ "lodash._root": {
+ "version": "3.0.1",
+ "resolved": "https://registry.npmjs.org/lodash._root/-/lodash._root-3.0.1.tgz",
+ "integrity": "sha1-+6HEUkwZ7ppfgTa0YJ8BfPTe1pI=",
+ "dev": true
+ },
+ "lodash.assign": {
+ "version": "4.2.0",
+ "resolved": "https://registry.npmjs.org/lodash.assign/-/lodash.assign-4.2.0.tgz",
+ "integrity": "sha1-DZnzzNem0mHRm9rrkkUAXShYCOc=",
+ "dev": true
+ },
+ "lodash.clonedeep": {
+ "version": "4.5.0",
+ "resolved": "https://registry.npmjs.org/lodash.clonedeep/-/lodash.clonedeep-4.5.0.tgz",
+ "integrity": "sha1-4j8/nE+Pvd6HJSnBBxhXoIblzO8=",
+ "dev": true
+ },
+ "lodash.escape": {
+ "version": "3.2.0",
+ "resolved": "https://registry.npmjs.org/lodash.escape/-/lodash.escape-3.2.0.tgz",
+ "integrity": "sha1-mV7g3BjBtIzJLv+ucaEKq1tIdpg=",
+ "dev": true,
+ "requires": {
+ "lodash._root": "3.0.1"
+ }
+ },
+ "lodash.isarguments": {
+ "version": "3.1.0",
+ "resolved": "https://registry.npmjs.org/lodash.isarguments/-/lodash.isarguments-3.1.0.tgz",
+ "integrity": "sha1-L1c9hcaiQon/AGY7SRwdM4/zRYo=",
+ "dev": true
+ },
+ "lodash.isarray": {
+ "version": "3.0.4",
+ "resolved": "https://registry.npmjs.org/lodash.isarray/-/lodash.isarray-3.0.4.tgz",
+ "integrity": "sha1-eeTriMNqgSKvhvhEqpvNhRtfu1U=",
+ "dev": true
+ },
+ "lodash.keys": {
+ "version": "3.1.2",
+ "resolved": "https://registry.npmjs.org/lodash.keys/-/lodash.keys-3.1.2.tgz",
+ "integrity": "sha1-TbwEcrFWvlCgsoaFXRvQsMZWCYo=",
+ "dev": true,
+ "requires": {
+ "lodash._getnative": "3.9.1",
+ "lodash.isarguments": "3.1.0",
+ "lodash.isarray": "3.0.4"
+ }
+ },
+ "lodash.memoize": {
+ "version": "3.0.4",
+ "resolved": "https://registry.npmjs.org/lodash.memoize/-/lodash.memoize-3.0.4.tgz",
+ "integrity": "sha1-LcvSwofLwKVcxCMovQxzYVDVPj8=",
+ "dev": true
+ },
+ "lodash.restparam": {
+ "version": "3.6.1",
+ "resolved": "https://registry.npmjs.org/lodash.restparam/-/lodash.restparam-3.6.1.tgz",
+ "integrity": "sha1-k2pOMJ7zMKdkXtQUWYbIWuWyCAU=",
+ "dev": true
+ },
+ "lodash.template": {
+ "version": "3.6.2",
+ "resolved": "https://registry.npmjs.org/lodash.template/-/lodash.template-3.6.2.tgz",
+ "integrity": "sha1-+M3sxhaaJVvpCYrosMU9N4kx0U8=",
+ "dev": true,
+ "requires": {
+ "lodash._basecopy": "3.0.1",
+ "lodash._basetostring": "3.0.1",
+ "lodash._basevalues": "3.0.0",
+ "lodash._isiterateecall": "3.0.9",
+ "lodash._reinterpolate": "3.0.0",
+ "lodash.escape": "3.2.0",
+ "lodash.keys": "3.1.2",
+ "lodash.restparam": "3.6.1",
+ "lodash.templatesettings": "3.1.1"
+ }
+ },
+ "lodash.templatesettings": {
+ "version": "3.1.1",
+ "resolved": "https://registry.npmjs.org/lodash.templatesettings/-/lodash.templatesettings-3.1.1.tgz",
+ "integrity": "sha1-+zB4RHU7Zrnxr6VOJix0UwfbqOU=",
+ "dev": true,
+ "requires": {
+ "lodash._reinterpolate": "3.0.0",
+ "lodash.escape": "3.2.0"
+ }
+ },
+ "longest": {
+ "version": "1.0.1",
+ "resolved": "https://registry.npmjs.org/longest/-/longest-1.0.1.tgz",
+ "integrity": "sha1-MKCy2jj3N3DoKUoNIuZiXtd9AJc="
+ },
+ "loose-envify": {
+ "version": "1.3.1",
+ "resolved": "https://registry.npmjs.org/loose-envify/-/loose-envify-1.3.1.tgz",
+ "integrity": "sha1-0aitM/qc4OcT1l/dCsi3SNR4yEg=",
+ "dev": true,
+ "requires": {
+ "js-tokens": "3.0.2"
+ }
+ },
+ "loud-rejection": {
+ "version": "1.6.0",
+ "resolved": "https://registry.npmjs.org/loud-rejection/-/loud-rejection-1.6.0.tgz",
+ "integrity": "sha1-W0b4AUft7leIcPCG0Eghz5mOVR8=",
+ "dev": true,
+ "requires": {
+ "currently-unhandled": "0.4.1",
+ "signal-exit": "3.0.2"
+ }
+ },
+ "lru-cache": {
+ "version": "2.7.3",
+ "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-2.7.3.tgz",
+ "integrity": "sha1-bUUk6LlV+V1PW1iFHOId1y+06VI=",
+ "dev": true
+ },
+ "make-error": {
+ "version": "1.3.4",
+ "resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.4.tgz",
+ "integrity": "sha512-0Dab5btKVPhibSalc9QGXb559ED7G7iLjFXBaj9Wq8O3vorueR5K5jaE3hkG6ZQINyhA/JgG6Qk4qdFQjsYV6g=="
+ },
+ "make-error-cause": {
+ "version": "1.2.2",
+ "resolved": "https://registry.npmjs.org/make-error-cause/-/make-error-cause-1.2.2.tgz",
+ "integrity": "sha1-3wOI/NCzeBbf8KX7gQiTl3fcvJ0=",
+ "requires": {
+ "make-error": "1.3.4"
+ }
+ },
+ "make-iterator": {
+ "version": "1.0.1",
+ "resolved": "https://registry.npmjs.org/make-iterator/-/make-iterator-1.0.1.tgz",
+ "integrity": "sha512-pxiuXh0iVEq7VM7KMIhs5gxsfxCux2URptUQaXo4iZZJxBAzTPOLE2BumO5dbfVYq/hBJFBR/a1mFDmOx5AGmw==",
+ "dev": true,
+ "requires": {
+ "kind-of": "6.0.2"
+ },
+ "dependencies": {
+ "kind-of": {
+ "version": "6.0.2",
+ "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.2.tgz",
+ "integrity": "sha512-s5kLOcnH0XqDO+FvuaLX8DDjZ18CGFk7VygH40QoKPUQhW4e2rvM0rwUq0t8IQDOwYSeLK01U90OjzBTme2QqA==",
+ "dev": true
+ }
+ }
+ },
+ "map-cache": {
+ "version": "0.2.2",
+ "resolved": "https://registry.npmjs.org/map-cache/-/map-cache-0.2.2.tgz",
+ "integrity": "sha1-wyq9C9ZSXZsFFkW7TyasXcmKDb8=",
+ "dev": true
+ },
+ "map-obj": {
+ "version": "1.0.1",
+ "resolved": "https://registry.npmjs.org/map-obj/-/map-obj-1.0.1.tgz",
+ "integrity": "sha1-2TPOuSBdgr3PSIb2dCvcK03qFG0=",
+ "dev": true
+ },
+ "map-visit": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/map-visit/-/map-visit-1.0.0.tgz",
+ "integrity": "sha1-7Nyo8TFE5mDxtb1B8S80edmN+48=",
+ "dev": true,
+ "requires": {
+ "object-visit": "1.0.1"
+ }
+ },
+ "md5.js": {
+ "version": "1.3.4",
+ "resolved": "https://registry.npmjs.org/md5.js/-/md5.js-1.3.4.tgz",
+ "integrity": "sha1-6b296UogpawYsENA/Fdk1bCdkB0=",
+ "dev": true,
+ "requires": {
+ "hash-base": "3.0.4",
+ "inherits": "2.0.3"
+ }
+ },
+ "meow": {
+ "version": "3.7.0",
+ "resolved": "https://registry.npmjs.org/meow/-/meow-3.7.0.tgz",
+ "integrity": "sha1-cstmi0JSKCkKu/qFaJJYcwioAfs=",
+ "dev": true,
+ "requires": {
+ "camelcase-keys": "2.1.0",
+ "decamelize": "1.2.0",
+ "loud-rejection": "1.6.0",
+ "map-obj": "1.0.1",
+ "minimist": "1.2.0",
+ "normalize-package-data": "2.4.0",
+ "object-assign": "4.1.1",
+ "read-pkg-up": "1.0.1",
+ "redent": "1.0.0",
+ "trim-newlines": "1.0.0"
+ },
+ "dependencies": {
+ "minimist": {
+ "version": "1.2.0",
+ "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz",
+ "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=",
+ "dev": true
+ }
+ }
+ },
+ "micromatch": {
+ "version": "3.1.10",
+ "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-3.1.10.tgz",
+ "integrity": "sha512-MWikgl9n9M3w+bpsY3He8L+w9eF9338xRl8IAO5viDizwSzziFEyUzo2xrrloB64ADbTf8uA8vRqqttDTOmccg==",
+ "dev": true,
+ "requires": {
+ "arr-diff": "4.0.0",
+ "array-unique": "0.3.2",
+ "braces": "2.3.2",
+ "define-property": "2.0.2",
+ "extend-shallow": "3.0.2",
+ "extglob": "2.0.4",
+ "fragment-cache": "0.2.1",
+ "kind-of": "6.0.2",
+ "nanomatch": "1.2.9",
+ "object.pick": "1.3.0",
+ "regex-not": "1.0.2",
+ "snapdragon": "0.8.2",
+ "to-regex": "3.0.2"
+ },
+ "dependencies": {
+ "kind-of": {
+ "version": "6.0.2",
+ "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.2.tgz",
+ "integrity": "sha512-s5kLOcnH0XqDO+FvuaLX8DDjZ18CGFk7VygH40QoKPUQhW4e2rvM0rwUq0t8IQDOwYSeLK01U90OjzBTme2QqA==",
+ "dev": true
+ }
+ }
+ },
+ "miller-rabin": {
+ "version": "4.0.1",
+ "resolved": "https://registry.npmjs.org/miller-rabin/-/miller-rabin-4.0.1.tgz",
+ "integrity": "sha512-115fLhvZVqWwHPbClyntxEVfVDfl9DLLTuJvq3g2O/Oxi8AiNouAHvDSzHS0viUJc+V5vm3eq91Xwqn9dp4jRA==",
+ "dev": true,
+ "requires": {
+ "bn.js": "4.11.8",
+ "brorand": "1.1.0"
+ }
+ },
+ "mime-db": {
+ "version": "1.33.0",
+ "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.33.0.tgz",
+ "integrity": "sha512-BHJ/EKruNIqJf/QahvxwQZXKygOQ256myeN/Ew+THcAa5q+PjyTTMMeNQC4DZw5AwfvelsUrA6B67NKMqXDbzQ==",
+ "dev": true
+ },
+ "mime-types": {
+ "version": "2.1.18",
+ "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.18.tgz",
+ "integrity": "sha512-lc/aahn+t4/SWV/qcmumYjymLsWfN3ELhpmVuUFjgsORruuZPVSwAQryq+HHGvO/SI2KVX26bx+En+zhM8g8hQ==",
+ "dev": true,
+ "requires": {
+ "mime-db": "1.33.0"
+ }
+ },
+ "minimalistic-assert": {
+ "version": "1.0.1",
+ "resolved": "https://registry.npmjs.org/minimalistic-assert/-/minimalistic-assert-1.0.1.tgz",
+ "integrity": "sha512-UtJcAD4yEaGtjPezWuO9wC4nwUnVH/8/Im3yEHQP4b67cXlD/Qr9hdITCU1xDbSEXg2XKNaP8jsReV7vQd00/A==",
+ "dev": true
+ },
+ "minimalistic-crypto-utils": {
+ "version": "1.0.1",
+ "resolved": "https://registry.npmjs.org/minimalistic-crypto-utils/-/minimalistic-crypto-utils-1.0.1.tgz",
+ "integrity": "sha1-9sAMHAsIIkblxNmd+4x8CDsrWCo=",
+ "dev": true
+ },
+ "minimatch": {
+ "version": "3.0.4",
+ "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz",
+ "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==",
+ "dev": true,
+ "requires": {
+ "brace-expansion": "1.1.11"
+ }
+ },
+ "minimist": {
+ "version": "0.0.8",
+ "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz",
+ "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=",
+ "dev": true
+ },
+ "mixin-deep": {
+ "version": "1.3.1",
+ "resolved": "https://registry.npmjs.org/mixin-deep/-/mixin-deep-1.3.1.tgz",
+ "integrity": "sha512-8ZItLHeEgaqEvd5lYBXfm4EZSFCX29Jb9K+lAHhDKzReKBQKj3R+7NOF6tjqYi9t4oI8VUfaWITJQm86wnXGNQ==",
+ "dev": true,
+ "requires": {
+ "for-in": "1.0.2",
+ "is-extendable": "1.0.1"
+ },
+ "dependencies": {
+ "is-extendable": {
+ "version": "1.0.1",
+ "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-1.0.1.tgz",
+ "integrity": "sha512-arnXMxT1hhoKo9k1LZdmlNyJdDDfy2v0fXjFlmok4+i8ul/6WlbVge9bhM74OpNPQPMGUToDtz+KXa1PneJxOA==",
+ "dev": true,
+ "requires": {
+ "is-plain-object": "2.0.4"
+ }
+ }
+ }
+ },
+ "mkdirp": {
+ "version": "0.5.1",
+ "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz",
+ "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=",
+ "dev": true,
+ "requires": {
+ "minimist": "0.0.8"
+ }
+ },
+ "module-deps": {
+ "version": "4.1.1",
+ "resolved": "https://registry.npmjs.org/module-deps/-/module-deps-4.1.1.tgz",
+ "integrity": "sha1-IyFYM/HaE/1gbMuAh7RIUty4If0=",
+ "dev": true,
+ "requires": {
+ "JSONStream": "1.3.2",
+ "browser-resolve": "1.11.2",
+ "cached-path-relative": "1.0.1",
+ "concat-stream": "1.5.2",
+ "defined": "1.0.0",
+ "detective": "4.7.1",
+ "duplexer2": "0.1.4",
+ "inherits": "2.0.3",
+ "parents": "1.0.1",
+ "readable-stream": "2.3.6",
+ "resolve": "1.7.1",
+ "stream-combiner2": "1.1.1",
+ "subarg": "1.0.0",
+ "through2": "2.0.3",
+ "xtend": "4.0.1"
+ }
+ },
+ "ms": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
+ "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=",
+ "dev": true
+ },
+ "multipipe": {
+ "version": "0.1.2",
+ "resolved": "https://registry.npmjs.org/multipipe/-/multipipe-0.1.2.tgz",
+ "integrity": "sha1-Ko8t33Du1WTf8tV/HhoTfZ8FB4s=",
+ "dev": true,
+ "requires": {
+ "duplexer2": "0.0.2"
+ },
+ "dependencies": {
+ "duplexer2": {
+ "version": "0.0.2",
+ "resolved": "https://registry.npmjs.org/duplexer2/-/duplexer2-0.0.2.tgz",
+ "integrity": "sha1-xhTc9n4vsUmVqRcR5aYX6KYKMds=",
+ "dev": true,
+ "requires": {
+ "readable-stream": "1.1.14"
+ }
+ },
+ "isarray": {
+ "version": "0.0.1",
+ "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz",
+ "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=",
+ "dev": true
+ },
+ "readable-stream": {
+ "version": "1.1.14",
+ "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz",
+ "integrity": "sha1-fPTFTvZI44EwhMY23SB54WbAgdk=",
+ "dev": true,
+ "requires": {
+ "core-util-is": "1.0.2",
+ "inherits": "2.0.3",
+ "isarray": "0.0.1",
+ "string_decoder": "0.10.31"
+ }
+ },
+ "string_decoder": {
+ "version": "0.10.31",
+ "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz",
+ "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=",
+ "dev": true
+ }
+ }
+ },
+ "nan": {
+ "version": "2.10.0",
+ "resolved": "https://registry.npmjs.org/nan/-/nan-2.10.0.tgz",
+ "integrity": "sha512-bAdJv7fBLhWC+/Bls0Oza+mvTaNQtP+1RyhhhvD95pgUJz6XM5IzgmxOkItJ9tkoCiplvAnXI1tNmmUD/eScyA==",
+ "dev": true
+ },
+ "nanomatch": {
+ "version": "1.2.9",
+ "resolved": "https://registry.npmjs.org/nanomatch/-/nanomatch-1.2.9.tgz",
+ "integrity": "sha512-n8R9bS8yQ6eSXaV6jHUpKzD8gLsin02w1HSFiegwrs9E098Ylhw5jdyKPaYqvHknHaSCKTPp7C8dGCQ0q9koXA==",
+ "dev": true,
+ "requires": {
+ "arr-diff": "4.0.0",
+ "array-unique": "0.3.2",
+ "define-property": "2.0.2",
+ "extend-shallow": "3.0.2",
+ "fragment-cache": "0.2.1",
+ "is-odd": "2.0.0",
+ "is-windows": "1.0.2",
+ "kind-of": "6.0.2",
+ "object.pick": "1.3.0",
+ "regex-not": "1.0.2",
+ "snapdragon": "0.8.2",
+ "to-regex": "3.0.2"
+ },
+ "dependencies": {
+ "kind-of": {
+ "version": "6.0.2",
+ "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.2.tgz",
+ "integrity": "sha512-s5kLOcnH0XqDO+FvuaLX8DDjZ18CGFk7VygH40QoKPUQhW4e2rvM0rwUq0t8IQDOwYSeLK01U90OjzBTme2QqA==",
+ "dev": true
+ }
+ }
+ },
+ "natives": {
+ "version": "1.1.3",
+ "resolved": "https://registry.npmjs.org/natives/-/natives-1.1.3.tgz",
+ "integrity": "sha512-BZGSYV4YOLxzoTK73l0/s/0sH9l8SHs2ocReMH1f8JYSh5FUWu4ZrKCpJdRkWXV6HFR/pZDz7bwWOVAY07q77g==",
+ "dev": true
+ },
+ "node-gyp": {
+ "version": "3.6.2",
+ "resolved": "https://registry.npmjs.org/node-gyp/-/node-gyp-3.6.2.tgz",
+ "integrity": "sha1-m/vlRWIoYoSDjnUOrAUpWFP6HGA=",
+ "dev": true,
+ "requires": {
+ "fstream": "1.0.11",
+ "glob": "7.1.2",
+ "graceful-fs": "4.1.11",
+ "minimatch": "3.0.4",
+ "mkdirp": "0.5.1",
+ "nopt": "3.0.6",
+ "npmlog": "4.1.2",
+ "osenv": "0.1.5",
+ "request": "2.85.0",
+ "rimraf": "2.6.2",
+ "semver": "5.3.0",
+ "tar": "2.2.1",
+ "which": "1.3.0"
+ },
+ "dependencies": {
+ "graceful-fs": {
+ "version": "4.1.11",
+ "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.11.tgz",
+ "integrity": "sha1-Dovf5NHduIVNZOBOp8AOKgJuVlg=",
+ "dev": true
+ },
+ "semver": {
+ "version": "5.3.0",
+ "resolved": "https://registry.npmjs.org/semver/-/semver-5.3.0.tgz",
+ "integrity": "sha1-myzl094C0XxgEq0yaqa00M9U+U8=",
+ "dev": true
+ }
+ }
+ },
+ "node-sass": {
+ "version": "3.13.1",
+ "resolved": "https://registry.npmjs.org/node-sass/-/node-sass-3.13.1.tgz",
+ "integrity": "sha1-ckD7v/I5YwS0IjUn7TAgWJwAT8I=",
+ "dev": true,
+ "requires": {
+ "async-foreach": "0.1.3",
+ "chalk": "1.1.3",
+ "cross-spawn": "3.0.1",
+ "gaze": "1.1.2",
+ "get-stdin": "4.0.1",
+ "glob": "7.1.2",
+ "in-publish": "2.0.0",
+ "lodash.assign": "4.2.0",
+ "lodash.clonedeep": "4.5.0",
+ "meow": "3.7.0",
+ "mkdirp": "0.5.1",
+ "nan": "2.10.0",
+ "node-gyp": "3.6.2",
+ "npmlog": "4.1.2",
+ "request": "2.85.0",
+ "sass-graph": "2.2.4"
+ },
+ "dependencies": {
+ "gaze": {
+ "version": "1.1.2",
+ "resolved": "https://registry.npmjs.org/gaze/-/gaze-1.1.2.tgz",
+ "integrity": "sha1-hHIkZ3rbiHDWeSV+0ziP22HkAQU=",
+ "dev": true,
+ "requires": {
+ "globule": "1.2.0"
+ }
+ },
+ "globule": {
+ "version": "1.2.0",
+ "resolved": "https://registry.npmjs.org/globule/-/globule-1.2.0.tgz",
+ "integrity": "sha1-HcScaCLdnoovoAuiopUAboZkvQk=",
+ "dev": true,
+ "requires": {
+ "glob": "7.1.2",
+ "lodash": "4.17.5",
+ "minimatch": "3.0.4"
+ }
+ }
+ }
+ },
+ "nopt": {
+ "version": "3.0.6",
+ "resolved": "https://registry.npmjs.org/nopt/-/nopt-3.0.6.tgz",
+ "integrity": "sha1-xkZdvwirzU2zWTF/eaxopkayj/k=",
+ "dev": true,
+ "requires": {
+ "abbrev": "1.1.1"
+ }
+ },
+ "normalize-package-data": {
+ "version": "2.4.0",
+ "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.4.0.tgz",
+ "integrity": "sha512-9jjUFbTPfEy3R/ad/2oNbKtW9Hgovl5O1FvFWKkKblNXoN/Oou6+9+KKohPK13Yc3/TyunyWhJp6gvRNR/PPAw==",
+ "dev": true,
+ "requires": {
+ "hosted-git-info": "2.6.0",
+ "is-builtin-module": "1.0.0",
+ "semver": "4.3.6",
+ "validate-npm-package-license": "3.0.3"
+ }
+ },
+ "npmlog": {
+ "version": "4.1.2",
+ "resolved": "https://registry.npmjs.org/npmlog/-/npmlog-4.1.2.tgz",
+ "integrity": "sha512-2uUqazuKlTaSI/dC8AzicUck7+IrEaOnN/e0jd3Xtt1KcGpwx30v50mL7oPyr/h9bL3E4aZccVwpwP+5W9Vjkg==",
+ "dev": true,
+ "requires": {
+ "are-we-there-yet": "1.1.4",
+ "console-control-strings": "1.1.0",
+ "gauge": "2.7.4",
+ "set-blocking": "2.0.0"
+ }
+ },
+ "number-is-nan": {
+ "version": "1.0.1",
+ "resolved": "https://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.1.tgz",
+ "integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=",
+ "dev": true
+ },
+ "oauth-sign": {
+ "version": "0.8.2",
+ "resolved": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.8.2.tgz",
+ "integrity": "sha1-Rqarfwrq2N6unsBWV4C31O/rnUM=",
+ "dev": true
+ },
+ "object-assign": {
+ "version": "4.1.1",
+ "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz",
+ "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=",
+ "dev": true
+ },
+ "object-copy": {
+ "version": "0.1.0",
+ "resolved": "https://registry.npmjs.org/object-copy/-/object-copy-0.1.0.tgz",
+ "integrity": "sha1-fn2Fi3gb18mRpBupde04EnVOmYw=",
+ "dev": true,
+ "requires": {
+ "copy-descriptor": "0.1.1",
+ "define-property": "0.2.5",
+ "kind-of": "3.2.2"
+ },
+ "dependencies": {
+ "define-property": {
+ "version": "0.2.5",
+ "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz",
+ "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=",
+ "dev": true,
+ "requires": {
+ "is-descriptor": "0.1.6"
+ }
+ }
+ }
+ },
+ "object-visit": {
+ "version": "1.0.1",
+ "resolved": "https://registry.npmjs.org/object-visit/-/object-visit-1.0.1.tgz",
+ "integrity": "sha1-95xEk68MU3e1n+OdOV5BBC3QRbs=",
+ "dev": true,
+ "requires": {
+ "isobject": "3.0.1"
+ }
+ },
+ "object.defaults": {
+ "version": "1.1.0",
+ "resolved": "https://registry.npmjs.org/object.defaults/-/object.defaults-1.1.0.tgz",
+ "integrity": "sha1-On+GgzS0B96gbaFtiNXNKeQ1/s8=",
+ "dev": true,
+ "requires": {
+ "array-each": "1.0.1",
+ "array-slice": "1.1.0",
+ "for-own": "1.0.0",
+ "isobject": "3.0.1"
+ }
+ },
+ "object.map": {
+ "version": "1.0.1",
+ "resolved": "https://registry.npmjs.org/object.map/-/object.map-1.0.1.tgz",
+ "integrity": "sha1-z4Plncj8wK1fQlDh94s7gb2AHTc=",
+ "dev": true,
+ "requires": {
+ "for-own": "1.0.0",
+ "make-iterator": "1.0.1"
+ }
+ },
+ "object.pick": {
+ "version": "1.3.0",
+ "resolved": "https://registry.npmjs.org/object.pick/-/object.pick-1.3.0.tgz",
+ "integrity": "sha1-h6EKxMFpS9Lhy/U1kaZhQftd10c=",
+ "dev": true,
+ "requires": {
+ "isobject": "3.0.1"
+ }
+ },
+ "once": {
+ "version": "1.4.0",
+ "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz",
+ "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=",
+ "requires": {
+ "wrappy": "1.0.2"
+ }
+ },
+ "orchestrator": {
+ "version": "0.3.8",
+ "resolved": "https://registry.npmjs.org/orchestrator/-/orchestrator-0.3.8.tgz",
+ "integrity": "sha1-FOfp4nZPcxX7rBhOUGx6pt+UrX4=",
+ "dev": true,
+ "requires": {
+ "end-of-stream": "0.1.5",
+ "sequencify": "0.0.7",
+ "stream-consume": "0.1.1"
+ },
+ "dependencies": {
+ "end-of-stream": {
+ "version": "0.1.5",
+ "resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-0.1.5.tgz",
+ "integrity": "sha1-jhdyBsPICDfYVjLouTWd/osvbq8=",
+ "dev": true,
+ "requires": {
+ "once": "1.3.3"
+ }
+ },
+ "once": {
+ "version": "1.3.3",
+ "resolved": "https://registry.npmjs.org/once/-/once-1.3.3.tgz",
+ "integrity": "sha1-suJhVXzkwxTsgwTz+oJmPkKXyiA=",
+ "dev": true,
+ "requires": {
+ "wrappy": "1.0.2"
+ }
+ }
+ }
+ },
+ "ordered-read-streams": {
+ "version": "0.1.0",
+ "resolved": "https://registry.npmjs.org/ordered-read-streams/-/ordered-read-streams-0.1.0.tgz",
+ "integrity": "sha1-/VZamvjrRHO6abbtijQ1LLVS8SY=",
+ "dev": true
+ },
+ "os-browserify": {
+ "version": "0.1.2",
+ "resolved": "https://registry.npmjs.org/os-browserify/-/os-browserify-0.1.2.tgz",
+ "integrity": "sha1-ScoCk+CxlZCl9d4Qx/JlphfY/lQ=",
+ "dev": true
+ },
+ "os-homedir": {
+ "version": "1.0.2",
+ "resolved": "https://registry.npmjs.org/os-homedir/-/os-homedir-1.0.2.tgz",
+ "integrity": "sha1-/7xJiDNuDoM94MFox+8VISGqf7M=",
+ "dev": true
+ },
+ "os-locale": {
+ "version": "1.4.0",
+ "resolved": "https://registry.npmjs.org/os-locale/-/os-locale-1.4.0.tgz",
+ "integrity": "sha1-IPnxeuKe00XoveWDsT0gCYA8FNk=",
+ "dev": true,
+ "requires": {
+ "lcid": "1.0.0"
+ }
+ },
+ "os-tmpdir": {
+ "version": "1.0.2",
+ "resolved": "https://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.2.tgz",
+ "integrity": "sha1-u+Z0BseaqFxc/sdm/lc0VV36EnQ=",
+ "dev": true
+ },
+ "osenv": {
+ "version": "0.1.5",
+ "resolved": "https://registry.npmjs.org/osenv/-/osenv-0.1.5.tgz",
+ "integrity": "sha512-0CWcCECdMVc2Rw3U5w9ZjqX6ga6ubk1xDVKxtBQPK7wis/0F2r9T6k4ydGYhecl7YUBxBVxhL5oisPsNxAPe2g==",
+ "dev": true,
+ "requires": {
+ "os-homedir": "1.0.2",
+ "os-tmpdir": "1.0.2"
+ }
+ },
+ "pako": {
+ "version": "0.2.9",
+ "resolved": "https://registry.npmjs.org/pako/-/pako-0.2.9.tgz",
+ "integrity": "sha1-8/dSL073gjSNqBYbrZ7P1Rv4OnU=",
+ "dev": true
+ },
+ "parents": {
+ "version": "1.0.1",
+ "resolved": "https://registry.npmjs.org/parents/-/parents-1.0.1.tgz",
+ "integrity": "sha1-/t1NK/GTp3dF/nHjcdc8MwfZx1E=",
+ "dev": true,
+ "requires": {
+ "path-platform": "0.11.15"
+ }
+ },
+ "parse-asn1": {
+ "version": "5.1.1",
+ "resolved": "https://registry.npmjs.org/parse-asn1/-/parse-asn1-5.1.1.tgz",
+ "integrity": "sha512-KPx7flKXg775zZpnp9SxJlz00gTd4BmJ2yJufSc44gMCRrRQ7NSzAcSJQfifuOLgW6bEi+ftrALtsgALeB2Adw==",
+ "dev": true,
+ "requires": {
+ "asn1.js": "4.10.1",
+ "browserify-aes": "1.2.0",
+ "create-hash": "1.2.0",
+ "evp_bytestokey": "1.0.3",
+ "pbkdf2": "3.0.16"
+ }
+ },
+ "parse-filepath": {
+ "version": "1.0.2",
+ "resolved": "https://registry.npmjs.org/parse-filepath/-/parse-filepath-1.0.2.tgz",
+ "integrity": "sha1-pjISf1Oq89FYdvWHLz/6x2PWyJE=",
+ "dev": true,
+ "requires": {
+ "is-absolute": "1.0.0",
+ "map-cache": "0.2.2",
+ "path-root": "0.1.1"
+ }
+ },
+ "parse-json": {
+ "version": "2.2.0",
+ "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-2.2.0.tgz",
+ "integrity": "sha1-9ID0BDTvgHQfhGkJn43qGPVaTck=",
+ "dev": true,
+ "requires": {
+ "error-ex": "1.3.1"
+ }
+ },
+ "parse-passwd": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/parse-passwd/-/parse-passwd-1.0.0.tgz",
+ "integrity": "sha1-bVuTSkVpk7I9N/QKOC1vFmao5cY=",
+ "dev": true
+ },
+ "pascalcase": {
+ "version": "0.1.1",
+ "resolved": "https://registry.npmjs.org/pascalcase/-/pascalcase-0.1.1.tgz",
+ "integrity": "sha1-s2PlXoAGym/iF4TS2yK9FdeRfxQ=",
+ "dev": true
+ },
+ "path-browserify": {
+ "version": "0.0.0",
+ "resolved": "https://registry.npmjs.org/path-browserify/-/path-browserify-0.0.0.tgz",
+ "integrity": "sha1-oLhwcpquIUAFt9UDLsLLuw+0RRo=",
+ "dev": true
+ },
+ "path-exists": {
+ "version": "2.1.0",
+ "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-2.1.0.tgz",
+ "integrity": "sha1-D+tsZPD8UY2adU3V77YscCJ2H0s=",
+ "dev": true,
+ "requires": {
+ "pinkie-promise": "2.0.1"
+ }
+ },
+ "path-is-absolute": {
+ "version": "1.0.1",
+ "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz",
+ "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=",
+ "dev": true
+ },
+ "path-parse": {
+ "version": "1.0.5",
+ "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.5.tgz",
+ "integrity": "sha1-PBrfhx6pzWyUMbbqK9dKD/BVxME=",
+ "dev": true
+ },
+ "path-platform": {
+ "version": "0.11.15",
+ "resolved": "https://registry.npmjs.org/path-platform/-/path-platform-0.11.15.tgz",
+ "integrity": "sha1-6GQhf3TDaFDwhSt43Hv31KVyG/I=",
+ "dev": true
+ },
+ "path-root": {
+ "version": "0.1.1",
+ "resolved": "https://registry.npmjs.org/path-root/-/path-root-0.1.1.tgz",
+ "integrity": "sha1-mkpoFMrBwM1zNgqV8yCDyOpHRbc=",
+ "dev": true,
+ "requires": {
+ "path-root-regex": "0.1.2"
+ }
+ },
+ "path-root-regex": {
+ "version": "0.1.2",
+ "resolved": "https://registry.npmjs.org/path-root-regex/-/path-root-regex-0.1.2.tgz",
+ "integrity": "sha1-v8zcjfWxLcUsi0PsONGNcsBLqW0=",
+ "dev": true
+ },
+ "path-type": {
+ "version": "1.1.0",
+ "resolved": "https://registry.npmjs.org/path-type/-/path-type-1.1.0.tgz",
+ "integrity": "sha1-WcRPfuSR2nBNpBXaWkBwuk+P5EE=",
+ "dev": true,
+ "requires": {
+ "graceful-fs": "4.1.11",
+ "pify": "2.3.0",
+ "pinkie-promise": "2.0.1"
+ },
+ "dependencies": {
+ "graceful-fs": {
+ "version": "4.1.11",
+ "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.11.tgz",
+ "integrity": "sha1-Dovf5NHduIVNZOBOp8AOKgJuVlg=",
+ "dev": true
+ }
+ }
+ },
+ "pbkdf2": {
+ "version": "3.0.16",
+ "resolved": "https://registry.npmjs.org/pbkdf2/-/pbkdf2-3.0.16.tgz",
+ "integrity": "sha512-y4CXP3thSxqf7c0qmOF+9UeOTrifiVTIM+u7NWlq+PRsHbr7r7dpCmvzrZxa96JJUNi0Y5w9VqG5ZNeCVMoDcA==",
+ "dev": true,
+ "requires": {
+ "create-hash": "1.2.0",
+ "create-hmac": "1.1.7",
+ "ripemd160": "2.0.2",
+ "safe-buffer": "5.1.1",
+ "sha.js": "2.4.11"
+ }
+ },
+ "performance-now": {
+ "version": "2.1.0",
+ "resolved": "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz",
+ "integrity": "sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns=",
+ "dev": true
+ },
+ "pify": {
+ "version": "2.3.0",
+ "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz",
+ "integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=",
+ "dev": true
+ },
+ "pinkie": {
+ "version": "2.0.4",
+ "resolved": "https://registry.npmjs.org/pinkie/-/pinkie-2.0.4.tgz",
+ "integrity": "sha1-clVrgM+g1IqXToDnckjoDtT3+HA=",
+ "dev": true
+ },
+ "pinkie-promise": {
+ "version": "2.0.1",
+ "resolved": "https://registry.npmjs.org/pinkie-promise/-/pinkie-promise-2.0.1.tgz",
+ "integrity": "sha1-ITXW36ejWMBprJsXh3YogihFD/o=",
+ "dev": true,
+ "requires": {
+ "pinkie": "2.0.4"
+ }
+ },
+ "posix-character-classes": {
+ "version": "0.1.1",
+ "resolved": "https://registry.npmjs.org/posix-character-classes/-/posix-character-classes-0.1.1.tgz",
+ "integrity": "sha1-AerA/jta9xoqbAL+q7jB/vfgDqs=",
+ "dev": true
+ },
+ "preact": {
+ "version": "6.4.0",
+ "resolved": "https://registry.npmjs.org/preact/-/preact-6.4.0.tgz",
+ "integrity": "sha1-G4yZdUsAJjmhwz5oF17vqYoBzBQ="
+ },
+ "pretty-hrtime": {
+ "version": "1.0.3",
+ "resolved": "https://registry.npmjs.org/pretty-hrtime/-/pretty-hrtime-1.0.3.tgz",
+ "integrity": "sha1-t+PqQkNaTJsnWdmeDyAesZWALuE=",
+ "dev": true
+ },
+ "private": {
+ "version": "0.1.8",
+ "resolved": "https://registry.npmjs.org/private/-/private-0.1.8.tgz",
+ "integrity": "sha512-VvivMrbvd2nKkiG38qjULzlc+4Vx4wm/whI9pQD35YrARNnhxeiRktSOhSukRLFNlzg6Br/cJPet5J/u19r/mg==",
+ "dev": true
+ },
+ "process": {
+ "version": "0.11.10",
+ "resolved": "https://registry.npmjs.org/process/-/process-0.11.10.tgz",
+ "integrity": "sha1-czIwDoQBYb2j5podHZGn1LwW8YI=",
+ "dev": true
+ },
+ "process-nextick-args": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.0.tgz",
+ "integrity": "sha512-MtEC1TqN0EU5nephaJ4rAtThHtC86dNN9qCuEhtshvpVBkAW5ZO7BASN9REnF9eoXGcRub+pFuKEpOHE+HbEMw=="
+ },
+ "pseudomap": {
+ "version": "1.0.2",
+ "resolved": "https://registry.npmjs.org/pseudomap/-/pseudomap-1.0.2.tgz",
+ "integrity": "sha1-8FKijacOYYkX7wqKw0wa5aaChrM=",
+ "dev": true
+ },
+ "public-encrypt": {
+ "version": "4.0.2",
+ "resolved": "https://registry.npmjs.org/public-encrypt/-/public-encrypt-4.0.2.tgz",
+ "integrity": "sha512-4kJ5Esocg8X3h8YgJsKAuoesBgB7mqH3eowiDzMUPKiRDDE7E/BqqZD1hnTByIaAFiwAw246YEltSq7tdrOH0Q==",
+ "dev": true,
+ "requires": {
+ "bn.js": "4.11.8",
+ "browserify-rsa": "4.0.1",
+ "create-hash": "1.2.0",
+ "parse-asn1": "5.1.1",
+ "randombytes": "2.0.6"
+ }
+ },
+ "pump": {
+ "version": "1.0.3",
+ "resolved": "https://registry.npmjs.org/pump/-/pump-1.0.3.tgz",
+ "integrity": "sha512-8k0JupWme55+9tCVE+FS5ULT3K6AbgqrGa58lTT49RpyfwwcGedHqaC5LlQNdEAumn/wFsu6aPwkuPMioy8kqw==",
+ "requires": {
+ "end-of-stream": "1.4.1",
+ "once": "1.4.0"
+ }
+ },
+ "punycode": {
+ "version": "1.4.1",
+ "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.4.1.tgz",
+ "integrity": "sha1-wNWmOycYgArY4esPpSachN1BhF4=",
+ "dev": true
+ },
+ "qs": {
+ "version": "6.5.1",
+ "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.1.tgz",
+ "integrity": "sha512-eRzhrN1WSINYCDCbrz796z37LOe3m5tmW7RQf6oBntukAG1nmovJvhnwHHRMAfeoItc1m2Hk02WER2aQ/iqs+A==",
+ "dev": true
+ },
+ "querystring": {
+ "version": "0.2.0",
+ "resolved": "https://registry.npmjs.org/querystring/-/querystring-0.2.0.tgz",
+ "integrity": "sha1-sgmEkgO7Jd+CDadW50cAWHhSFiA=",
+ "dev": true
+ },
+ "querystring-es3": {
+ "version": "0.2.1",
+ "resolved": "https://registry.npmjs.org/querystring-es3/-/querystring-es3-0.2.1.tgz",
+ "integrity": "sha1-nsYfeQSYdXB9aUFFlv2Qek1xHnM=",
+ "dev": true
+ },
+ "randombytes": {
+ "version": "2.0.6",
+ "resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.0.6.tgz",
+ "integrity": "sha512-CIQ5OFxf4Jou6uOKe9t1AOgqpeU5fd70A8NPdHSGeYXqXsPe6peOwI0cUl88RWZ6sP1vPMV3avd/R6cZ5/sP1A==",
+ "dev": true,
+ "requires": {
+ "safe-buffer": "5.1.1"
+ }
+ },
+ "randomfill": {
+ "version": "1.0.4",
+ "resolved": "https://registry.npmjs.org/randomfill/-/randomfill-1.0.4.tgz",
+ "integrity": "sha512-87lcbR8+MhcWcUiQ+9e+Rwx8MyR2P7qnt15ynUlbm3TU/fjbgz4GsvfSUDTemtCCtVCqb4ZcEFlyPNTh9bBTLw==",
+ "dev": true,
+ "requires": {
+ "randombytes": "2.0.6",
+ "safe-buffer": "5.1.1"
+ }
+ },
+ "read-only-stream": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/read-only-stream/-/read-only-stream-2.0.0.tgz",
+ "integrity": "sha1-JyT9aoET1zdkrCiNQ4YnDB2/F/A=",
+ "dev": true,
+ "requires": {
+ "readable-stream": "2.3.6"
+ }
+ },
+ "read-pkg": {
+ "version": "1.1.0",
+ "resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-1.1.0.tgz",
+ "integrity": "sha1-9f+qXs0pyzHAR0vKfXVra7KePyg=",
+ "dev": true,
+ "requires": {
+ "load-json-file": "1.1.0",
+ "normalize-package-data": "2.4.0",
+ "path-type": "1.1.0"
+ }
+ },
+ "read-pkg-up": {
+ "version": "1.0.1",
+ "resolved": "https://registry.npmjs.org/read-pkg-up/-/read-pkg-up-1.0.1.tgz",
+ "integrity": "sha1-nWPBMnbAZZGNV/ACpX9AobZD+wI=",
+ "dev": true,
+ "requires": {
+ "find-up": "1.1.2",
+ "read-pkg": "1.1.0"
+ }
+ },
+ "readable-stream": {
+ "version": "2.3.6",
+ "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz",
+ "integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==",
+ "requires": {
+ "core-util-is": "1.0.2",
+ "inherits": "2.0.3",
+ "isarray": "1.0.0",
+ "process-nextick-args": "2.0.0",
+ "safe-buffer": "5.1.1",
+ "string_decoder": "1.1.1",
+ "util-deprecate": "1.0.2"
+ }
+ },
+ "rechoir": {
+ "version": "0.6.2",
+ "resolved": "https://registry.npmjs.org/rechoir/-/rechoir-0.6.2.tgz",
+ "integrity": "sha1-hSBLVNuoLVdC4oyWdW70OvUOM4Q=",
+ "dev": true,
+ "requires": {
+ "resolve": "1.7.1"
+ }
+ },
+ "redent": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/redent/-/redent-1.0.0.tgz",
+ "integrity": "sha1-z5Fqsf1fHxbfsggi3W7H9zDCr94=",
+ "dev": true,
+ "requires": {
+ "indent-string": "2.1.0",
+ "strip-indent": "1.0.1"
+ }
+ },
+ "regenerate": {
+ "version": "1.3.3",
+ "resolved": "https://registry.npmjs.org/regenerate/-/regenerate-1.3.3.tgz",
+ "integrity": "sha512-jVpo1GadrDAK59t/0jRx5VxYWQEDkkEKi6+HjE3joFVLfDOh9Xrdh0dF1eSq+BI/SwvTQ44gSscJ8N5zYL61sg==",
+ "dev": true
+ },
+ "regenerator-runtime": {
+ "version": "0.11.1",
+ "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.11.1.tgz",
+ "integrity": "sha512-MguG95oij0fC3QV3URf4V2SDYGJhJnJGqvIIgdECeODCT98wSWDAJ94SSuVpYQUoTcGUIL6L4yNB7j1DFFHSBg==",
+ "dev": true
+ },
+ "regenerator-transform": {
+ "version": "0.10.1",
+ "resolved": "https://registry.npmjs.org/regenerator-transform/-/regenerator-transform-0.10.1.tgz",
+ "integrity": "sha512-PJepbvDbuK1xgIgnau7Y90cwaAmO/LCLMI2mPvaXq2heGMR3aWW5/BQvYrhJ8jgmQjXewXvBjzfqKcVOmhjZ6Q==",
+ "dev": true,
+ "requires": {
+ "babel-runtime": "6.26.0",
+ "babel-types": "6.26.0",
+ "private": "0.1.8"
+ }
+ },
+ "regex-not": {
+ "version": "1.0.2",
+ "resolved": "https://registry.npmjs.org/regex-not/-/regex-not-1.0.2.tgz",
+ "integrity": "sha512-J6SDjUgDxQj5NusnOtdFxDwN/+HWykR8GELwctJ7mdqhcyy1xEc4SRFHUXvxTp661YaVKAjfRLZ9cCqS6tn32A==",
+ "dev": true,
+ "requires": {
+ "extend-shallow": "3.0.2",
+ "safe-regex": "1.1.0"
+ }
+ },
+ "regexpu-core": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/regexpu-core/-/regexpu-core-2.0.0.tgz",
+ "integrity": "sha1-SdA4g3uNz4v6W5pCE5k45uoq4kA=",
+ "dev": true,
+ "requires": {
+ "regenerate": "1.3.3",
+ "regjsgen": "0.2.0",
+ "regjsparser": "0.1.5"
+ }
+ },
+ "regjsgen": {
+ "version": "0.2.0",
+ "resolved": "https://registry.npmjs.org/regjsgen/-/regjsgen-0.2.0.tgz",
+ "integrity": "sha1-bAFq3qxVT3WCP+N6wFuS1aTtsfc=",
+ "dev": true
+ },
+ "regjsparser": {
+ "version": "0.1.5",
+ "resolved": "https://registry.npmjs.org/regjsparser/-/regjsparser-0.1.5.tgz",
+ "integrity": "sha1-fuj4Tcb6eS0/0K4ijSS9lJ6tIFw=",
+ "dev": true,
+ "requires": {
+ "jsesc": "0.5.0"
+ }
+ },
+ "repeat-element": {
+ "version": "1.1.2",
+ "resolved": "https://registry.npmjs.org/repeat-element/-/repeat-element-1.1.2.tgz",
+ "integrity": "sha1-7wiaF40Ug7quTZPrmLT55OEdmQo=",
+ "dev": true
+ },
+ "repeat-string": {
+ "version": "1.6.1",
+ "resolved": "https://registry.npmjs.org/repeat-string/-/repeat-string-1.6.1.tgz",
+ "integrity": "sha1-jcrkcOHIirwtYA//Sndihtp15jc="
+ },
+ "repeating": {
+ "version": "2.0.1",
+ "resolved": "https://registry.npmjs.org/repeating/-/repeating-2.0.1.tgz",
+ "integrity": "sha1-UhTFOpJtNVJwdSf7q0FdvAjQbdo=",
+ "dev": true,
+ "requires": {
+ "is-finite": "1.0.2"
+ }
+ },
+ "replace-ext": {
+ "version": "0.0.1",
+ "resolved": "https://registry.npmjs.org/replace-ext/-/replace-ext-0.0.1.tgz",
+ "integrity": "sha1-KbvZIHinOfC8zitO5B6DeVNSKSQ=",
+ "dev": true
+ },
+ "request": {
+ "version": "2.85.0",
+ "resolved": "https://registry.npmjs.org/request/-/request-2.85.0.tgz",
+ "integrity": "sha512-8H7Ehijd4js+s6wuVPLjwORxD4zeuyjYugprdOXlPSqaApmL/QOy+EB/beICHVCHkGMKNh5rvihb5ov+IDw4mg==",
+ "dev": true,
+ "requires": {
+ "aws-sign2": "0.7.0",
+ "aws4": "1.7.0",
+ "caseless": "0.12.0",
+ "combined-stream": "1.0.6",
+ "extend": "3.0.1",
+ "forever-agent": "0.6.1",
+ "form-data": "2.3.2",
+ "har-validator": "5.0.3",
+ "hawk": "6.0.2",
+ "http-signature": "1.2.0",
+ "is-typedarray": "1.0.0",
+ "isstream": "0.1.2",
+ "json-stringify-safe": "5.0.1",
+ "mime-types": "2.1.18",
+ "oauth-sign": "0.8.2",
+ "performance-now": "2.1.0",
+ "qs": "6.5.1",
+ "safe-buffer": "5.1.1",
+ "stringstream": "0.0.5",
+ "tough-cookie": "2.3.4",
+ "tunnel-agent": "0.6.0",
+ "uuid": "3.2.1"
+ }
+ },
+ "require-directory": {
+ "version": "2.1.1",
+ "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz",
+ "integrity": "sha1-jGStX9MNqxyXbiNE/+f3kqam30I=",
+ "dev": true
+ },
+ "require-main-filename": {
+ "version": "1.0.1",
+ "resolved": "https://registry.npmjs.org/require-main-filename/-/require-main-filename-1.0.1.tgz",
+ "integrity": "sha1-l/cXtp1IeE9fUmpsWqj/3aBVpNE=",
+ "dev": true
+ },
+ "resolve": {
+ "version": "1.7.1",
+ "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.7.1.tgz",
+ "integrity": "sha512-c7rwLofp8g1U+h1KNyHL/jicrKg1Ek4q+Lr33AL65uZTinUZHe30D5HlyN5V9NW0JX1D5dXQ4jqW5l7Sy/kGfw==",
+ "dev": true,
+ "requires": {
+ "path-parse": "1.0.5"
+ }
+ },
+ "resolve-dir": {
+ "version": "1.0.1",
+ "resolved": "https://registry.npmjs.org/resolve-dir/-/resolve-dir-1.0.1.tgz",
+ "integrity": "sha1-eaQGRMNivoLybv/nOcm7U4IEb0M=",
+ "dev": true,
+ "requires": {
+ "expand-tilde": "2.0.2",
+ "global-modules": "1.0.0"
+ }
+ },
+ "resolve-url": {
+ "version": "0.2.1",
+ "resolved": "https://registry.npmjs.org/resolve-url/-/resolve-url-0.2.1.tgz",
+ "integrity": "sha1-LGN/53yJOv0qZj/iGqkIAGjiBSo=",
+ "dev": true
+ },
+ "ret": {
+ "version": "0.1.15",
+ "resolved": "https://registry.npmjs.org/ret/-/ret-0.1.15.tgz",
+ "integrity": "sha512-TTlYpa+OL+vMMNG24xSlQGEJ3B/RzEfUlLct7b5G/ytav+wPrplCpVMFuwzXbkecJrb6IYo1iFb0S9v37754mg==",
+ "dev": true
+ },
+ "right-align": {
+ "version": "0.1.3",
+ "resolved": "https://registry.npmjs.org/right-align/-/right-align-0.1.3.tgz",
+ "integrity": "sha1-YTObci/mo1FWiSENJOFMlhSGE+8=",
+ "requires": {
+ "align-text": "0.1.4"
+ }
+ },
+ "rimraf": {
+ "version": "2.6.2",
+ "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.2.tgz",
+ "integrity": "sha512-lreewLK/BlghmxtfH36YYVg1i8IAce4TI7oao75I1g245+6BctqTVQiBP3YUJ9C6DQOXJmkYR9X9fCLtCOJc5w==",
+ "dev": true,
+ "requires": {
+ "glob": "7.1.2"
+ }
+ },
+ "ripemd160": {
+ "version": "2.0.2",
+ "resolved": "https://registry.npmjs.org/ripemd160/-/ripemd160-2.0.2.tgz",
+ "integrity": "sha512-ii4iagi25WusVoiC4B4lq7pbXfAp3D9v5CwfkY33vffw2+pkDjY1D8GaN7spsxvCSx8dkPqOZCEZyfxcmJG2IA==",
+ "dev": true,
+ "requires": {
+ "hash-base": "3.0.4",
+ "inherits": "2.0.3"
+ }
+ },
+ "rw": {
+ "version": "1.3.3",
+ "resolved": "https://registry.npmjs.org/rw/-/rw-1.3.3.tgz",
+ "integrity": "sha1-P4Yt+pGrdmsUiF700BEkv9oHT7Q="
+ },
+ "safe-buffer": {
+ "version": "5.1.1",
+ "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz",
+ "integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg=="
+ },
+ "safe-regex": {
+ "version": "1.1.0",
+ "resolved": "https://registry.npmjs.org/safe-regex/-/safe-regex-1.1.0.tgz",
+ "integrity": "sha1-QKNmnzsHfR6UPURinhV91IAjvy4=",
+ "dev": true,
+ "requires": {
+ "ret": "0.1.15"
+ }
+ },
+ "safer-buffer": {
+ "version": "2.1.2",
+ "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz",
+ "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg=="
+ },
+ "sass-graph": {
+ "version": "2.2.4",
+ "resolved": "https://registry.npmjs.org/sass-graph/-/sass-graph-2.2.4.tgz",
+ "integrity": "sha1-E/vWPNHK8JCLn9k0dq1DpR0eC0k=",
+ "dev": true,
+ "requires": {
+ "glob": "7.1.2",
+ "lodash": "4.17.5",
+ "scss-tokenizer": "0.2.3",
+ "yargs": "7.1.0"
+ },
+ "dependencies": {
+ "camelcase": {
+ "version": "3.0.0",
+ "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-3.0.0.tgz",
+ "integrity": "sha1-MvxLn82vhF/N9+c7uXysImHwqwo=",
+ "dev": true
+ },
+ "cliui": {
+ "version": "3.2.0",
+ "resolved": "https://registry.npmjs.org/cliui/-/cliui-3.2.0.tgz",
+ "integrity": "sha1-EgYBU3qRbSmUD5NNo7SNWFo5IT0=",
+ "dev": true,
+ "requires": {
+ "string-width": "1.0.2",
+ "strip-ansi": "3.0.1",
+ "wrap-ansi": "2.1.0"
+ }
+ },
+ "yargs": {
+ "version": "7.1.0",
+ "resolved": "https://registry.npmjs.org/yargs/-/yargs-7.1.0.tgz",
+ "integrity": "sha1-a6MY6xaWFyf10oT46gA+jWFU0Mg=",
+ "dev": true,
+ "requires": {
+ "camelcase": "3.0.0",
+ "cliui": "3.2.0",
+ "decamelize": "1.2.0",
+ "get-caller-file": "1.0.2",
+ "os-locale": "1.4.0",
+ "read-pkg-up": "1.0.1",
+ "require-directory": "2.1.1",
+ "require-main-filename": "1.0.1",
+ "set-blocking": "2.0.0",
+ "string-width": "1.0.2",
+ "which-module": "1.0.0",
+ "y18n": "3.2.1",
+ "yargs-parser": "5.0.0"
+ }
+ }
+ }
+ },
+ "scss-tokenizer": {
+ "version": "0.2.3",
+ "resolved": "https://registry.npmjs.org/scss-tokenizer/-/scss-tokenizer-0.2.3.tgz",
+ "integrity": "sha1-jrBtualyMzOCTT9VMGQRSYR85dE=",
+ "dev": true,
+ "requires": {
+ "js-base64": "2.4.3",
+ "source-map": "0.4.4"
+ },
+ "dependencies": {
+ "source-map": {
+ "version": "0.4.4",
+ "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.4.4.tgz",
+ "integrity": "sha1-66T12pwNyZneaAMti092FzZSA2s=",
+ "dev": true,
+ "requires": {
+ "amdefine": "1.0.1"
+ }
+ }
+ }
+ },
+ "semver": {
+ "version": "4.3.6",
+ "resolved": "https://registry.npmjs.org/semver/-/semver-4.3.6.tgz",
+ "integrity": "sha1-MAvG4OhjdPe6YQaLWx7NV/xlMto=",
+ "dev": true
+ },
+ "sequencify": {
+ "version": "0.0.7",
+ "resolved": "https://registry.npmjs.org/sequencify/-/sequencify-0.0.7.tgz",
+ "integrity": "sha1-kM/xnQLgcCf9dn9erT57ldHnOAw=",
+ "dev": true
+ },
+ "set-blocking": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz",
+ "integrity": "sha1-BF+XgtARrppoA93TgrJDkrPYkPc=",
+ "dev": true
+ },
+ "set-value": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/set-value/-/set-value-2.0.0.tgz",
+ "integrity": "sha512-hw0yxk9GT/Hr5yJEYnHNKYXkIA8mVJgd9ditYZCe16ZczcaELYYcfvaXesNACk2O8O0nTiPQcQhGUQj8JLzeeg==",
+ "dev": true,
+ "requires": {
+ "extend-shallow": "2.0.1",
+ "is-extendable": "0.1.1",
+ "is-plain-object": "2.0.4",
+ "split-string": "3.1.0"
+ },
+ "dependencies": {
+ "extend-shallow": {
+ "version": "2.0.1",
+ "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz",
+ "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=",
+ "dev": true,
+ "requires": {
+ "is-extendable": "0.1.1"
+ }
+ }
+ }
+ },
+ "sha.js": {
+ "version": "2.4.11",
+ "resolved": "https://registry.npmjs.org/sha.js/-/sha.js-2.4.11.tgz",
+ "integrity": "sha512-QMEp5B7cftE7APOjk5Y6xgrbWu+WkLVQwk8JNjZ8nKRciZaByEW6MubieAiToS7+dwvrjGhH8jRXz3MVd0AYqQ==",
+ "dev": true,
+ "requires": {
+ "inherits": "2.0.3",
+ "safe-buffer": "5.1.1"
+ }
+ },
+ "shasum": {
+ "version": "1.0.2",
+ "resolved": "https://registry.npmjs.org/shasum/-/shasum-1.0.2.tgz",
+ "integrity": "sha1-5wEjENj0F/TetXEhUOVni4euVl8=",
+ "dev": true,
+ "requires": {
+ "json-stable-stringify": "0.0.1",
+ "sha.js": "2.4.11"
+ }
+ },
+ "shell-quote": {
+ "version": "1.6.1",
+ "resolved": "https://registry.npmjs.org/shell-quote/-/shell-quote-1.6.1.tgz",
+ "integrity": "sha1-9HgZSczkAmlxJ0MOo7PFR29IF2c=",
+ "dev": true,
+ "requires": {
+ "array-filter": "0.0.1",
+ "array-map": "0.0.0",
+ "array-reduce": "0.0.0",
+ "jsonify": "0.0.0"
+ }
+ },
+ "sigmund": {
+ "version": "1.0.1",
+ "resolved": "https://registry.npmjs.org/sigmund/-/sigmund-1.0.1.tgz",
+ "integrity": "sha1-P/IfGYytIXX587eBhT/ZTQ0ZtZA=",
+ "dev": true
+ },
+ "signal-exit": {
+ "version": "3.0.2",
+ "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.2.tgz",
+ "integrity": "sha1-tf3AjxKH6hF4Yo5BXiUTK3NkbG0=",
+ "dev": true
+ },
+ "slash": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/slash/-/slash-1.0.0.tgz",
+ "integrity": "sha1-xB8vbDn8FtHNF61LXYlhFK5HDVU=",
+ "dev": true
+ },
+ "snapdragon": {
+ "version": "0.8.2",
+ "resolved": "https://registry.npmjs.org/snapdragon/-/snapdragon-0.8.2.tgz",
+ "integrity": "sha512-FtyOnWN/wCHTVXOMwvSv26d+ko5vWlIDD6zoUJ7LW8vh+ZBC8QdljveRP+crNrtBwioEUWy/4dMtbBjA4ioNlg==",
+ "dev": true,
+ "requires": {
+ "base": "0.11.2",
+ "debug": "2.6.9",
+ "define-property": "0.2.5",
+ "extend-shallow": "2.0.1",
+ "map-cache": "0.2.2",
+ "source-map": "0.5.7",
+ "source-map-resolve": "0.5.1",
+ "use": "3.1.0"
+ },
+ "dependencies": {
+ "define-property": {
+ "version": "0.2.5",
+ "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz",
+ "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=",
+ "dev": true,
+ "requires": {
+ "is-descriptor": "0.1.6"
+ }
+ },
+ "extend-shallow": {
+ "version": "2.0.1",
+ "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz",
+ "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=",
+ "dev": true,
+ "requires": {
+ "is-extendable": "0.1.1"
+ }
+ }
+ }
+ },
+ "snapdragon-node": {
+ "version": "2.1.1",
+ "resolved": "https://registry.npmjs.org/snapdragon-node/-/snapdragon-node-2.1.1.tgz",
+ "integrity": "sha512-O27l4xaMYt/RSQ5TR3vpWCAB5Kb/czIcqUFOM/C4fYcLnbZUc1PkjTAMjof2pBWaSTwOUd6qUHcFGVGj7aIwnw==",
+ "dev": true,
+ "requires": {
+ "define-property": "1.0.0",
+ "isobject": "3.0.1",
+ "snapdragon-util": "3.0.1"
+ },
+ "dependencies": {
+ "define-property": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/define-property/-/define-property-1.0.0.tgz",
+ "integrity": "sha1-dp66rz9KY6rTr56NMEybvnm/sOY=",
+ "dev": true,
+ "requires": {
+ "is-descriptor": "1.0.2"
+ }
+ },
+ "is-accessor-descriptor": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-1.0.0.tgz",
+ "integrity": "sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ==",
+ "dev": true,
+ "requires": {
+ "kind-of": "6.0.2"
+ }
+ },
+ "is-data-descriptor": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-1.0.0.tgz",
+ "integrity": "sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ==",
+ "dev": true,
+ "requires": {
+ "kind-of": "6.0.2"
+ }
+ },
+ "is-descriptor": {
+ "version": "1.0.2",
+ "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-1.0.2.tgz",
+ "integrity": "sha512-2eis5WqQGV7peooDyLmNEPUrps9+SXX5c9pL3xEB+4e9HnGuDa7mB7kHxHw4CbqS9k1T2hOH3miL8n8WtiYVtg==",
+ "dev": true,
+ "requires": {
+ "is-accessor-descriptor": "1.0.0",
+ "is-data-descriptor": "1.0.0",
+ "kind-of": "6.0.2"
+ }
+ },
+ "kind-of": {
+ "version": "6.0.2",
+ "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.2.tgz",
+ "integrity": "sha512-s5kLOcnH0XqDO+FvuaLX8DDjZ18CGFk7VygH40QoKPUQhW4e2rvM0rwUq0t8IQDOwYSeLK01U90OjzBTme2QqA==",
+ "dev": true
+ }
+ }
+ },
+ "snapdragon-util": {
+ "version": "3.0.1",
+ "resolved": "https://registry.npmjs.org/snapdragon-util/-/snapdragon-util-3.0.1.tgz",
+ "integrity": "sha512-mbKkMdQKsjX4BAL4bRYTj21edOf8cN7XHdYUJEe+Zn99hVEYcMvKPct1IqNe7+AZPirn8BCDOQBHQZknqmKlZQ==",
+ "dev": true,
+ "requires": {
+ "kind-of": "3.2.2"
+ }
+ },
+ "sntp": {
+ "version": "2.1.0",
+ "resolved": "https://registry.npmjs.org/sntp/-/sntp-2.1.0.tgz",
+ "integrity": "sha512-FL1b58BDrqS3A11lJ0zEdnJ3UOKqVxawAkF3k7F0CVN7VQ34aZrV+G8BZ1WC9ZL7NyrwsW0oviwsWDgRuVYtJg==",
+ "dev": true,
+ "requires": {
+ "hoek": "4.2.1"
+ }
+ },
+ "source-map": {
+ "version": "0.5.7",
+ "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz",
+ "integrity": "sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w="
+ },
+ "source-map-resolve": {
+ "version": "0.5.1",
+ "resolved": "https://registry.npmjs.org/source-map-resolve/-/source-map-resolve-0.5.1.tgz",
+ "integrity": "sha512-0KW2wvzfxm8NCTb30z0LMNyPqWCdDGE2viwzUaucqJdkTRXtZiSY3I+2A6nVAjmdOy0I4gU8DwnVVGsk9jvP2A==",
+ "dev": true,
+ "requires": {
+ "atob": "2.1.0",
+ "decode-uri-component": "0.2.0",
+ "resolve-url": "0.2.1",
+ "source-map-url": "0.4.0",
+ "urix": "0.1.0"
+ }
+ },
+ "source-map-support": {
+ "version": "0.4.18",
+ "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.4.18.tgz",
+ "integrity": "sha512-try0/JqxPLF9nOjvSta7tVondkP5dwgyLDjVoyMDlmjugT2lRZ1OfsrYTkCd2hkDnJTKRbO/Rl3orm8vlsUzbA==",
+ "dev": true,
+ "requires": {
+ "source-map": "0.5.7"
+ }
+ },
+ "source-map-url": {
+ "version": "0.4.0",
+ "resolved": "https://registry.npmjs.org/source-map-url/-/source-map-url-0.4.0.tgz",
+ "integrity": "sha1-PpNdfd1zYxuXZZlW1VEo6HtQhKM=",
+ "dev": true
+ },
+ "sparkles": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/sparkles/-/sparkles-1.0.0.tgz",
+ "integrity": "sha1-Gsu/tZJDbRC76PeFt8xvgoFQEsM="
+ },
+ "spdx-correct": {
+ "version": "3.0.0",
+ "resolved": "https://registry.npmjs.org/spdx-correct/-/spdx-correct-3.0.0.tgz",
+ "integrity": "sha512-N19o9z5cEyc8yQQPukRCZ9EUmb4HUpnrmaL/fxS2pBo2jbfcFRVuFZ/oFC+vZz0MNNk0h80iMn5/S6qGZOL5+g==",
+ "dev": true,
+ "requires": {
+ "spdx-expression-parse": "3.0.0",
+ "spdx-license-ids": "3.0.0"
+ }
+ },
+ "spdx-exceptions": {
+ "version": "2.1.0",
+ "resolved": "https://registry.npmjs.org/spdx-exceptions/-/spdx-exceptions-2.1.0.tgz",
+ "integrity": "sha512-4K1NsmrlCU1JJgUrtgEeTVyfx8VaYea9J9LvARxhbHtVtohPs/gFGG5yy49beySjlIMhhXZ4QqujIZEfS4l6Cg==",
+ "dev": true
+ },
+ "spdx-expression-parse": {
+ "version": "3.0.0",
+ "resolved": "https://registry.npmjs.org/spdx-expression-parse/-/spdx-expression-parse-3.0.0.tgz",
+ "integrity": "sha512-Yg6D3XpRD4kkOmTpdgbUiEJFKghJH03fiC1OPll5h/0sO6neh2jqRDVHOQ4o/LMea0tgCkbMgea5ip/e+MkWyg==",
+ "dev": true,
+ "requires": {
+ "spdx-exceptions": "2.1.0",
+ "spdx-license-ids": "3.0.0"
+ }
+ },
+ "spdx-license-ids": {
+ "version": "3.0.0",
+ "resolved": "https://registry.npmjs.org/spdx-license-ids/-/spdx-license-ids-3.0.0.tgz",
+ "integrity": "sha512-2+EPwgbnmOIl8HjGBXXMd9NAu02vLjOO1nWw4kmeRDFyHn+M/ETfHxQUK0oXg8ctgVnl9t3rosNVsZ1jG61nDA==",
+ "dev": true
+ },
+ "split-string": {
+ "version": "3.1.0",
+ "resolved": "https://registry.npmjs.org/split-string/-/split-string-3.1.0.tgz",
+ "integrity": "sha512-NzNVhJDYpwceVVii8/Hu6DKfD2G+NrQHlS/V/qgv763EYudVwEcMQNxd2lh+0VrUByXN/oJkl5grOhYWvQUYiw==",
+ "dev": true,
+ "requires": {
+ "extend-shallow": "3.0.2"
+ }
+ },
+ "sshpk": {
+ "version": "1.14.1",
+ "resolved": "https://registry.npmjs.org/sshpk/-/sshpk-1.14.1.tgz",
+ "integrity": "sha1-Ew9Zde3a2WPx1W+SuaxsUfqfg+s=",
+ "dev": true,
+ "requires": {
+ "asn1": "0.2.3",
+ "assert-plus": "1.0.0",
+ "bcrypt-pbkdf": "1.0.1",
+ "dashdash": "1.14.1",
+ "ecc-jsbn": "0.1.1",
+ "getpass": "0.1.7",
+ "jsbn": "0.1.1",
+ "tweetnacl": "0.14.5"
+ }
+ },
+ "static-extend": {
+ "version": "0.1.2",
+ "resolved": "https://registry.npmjs.org/static-extend/-/static-extend-0.1.2.tgz",
+ "integrity": "sha1-YICcOcv/VTNyJv1eC1IPNB8ftcY=",
+ "dev": true,
+ "requires": {
+ "define-property": "0.2.5",
+ "object-copy": "0.1.0"
+ },
+ "dependencies": {
+ "define-property": {
+ "version": "0.2.5",
+ "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz",
+ "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=",
+ "dev": true,
+ "requires": {
+ "is-descriptor": "0.1.6"
+ }
+ }
+ }
+ },
+ "stream-browserify": {
+ "version": "2.0.1",
+ "resolved": "https://registry.npmjs.org/stream-browserify/-/stream-browserify-2.0.1.tgz",
+ "integrity": "sha1-ZiZu5fm9uZQKTkUUyvtDu3Hlyds=",
+ "dev": true,
+ "requires": {
+ "inherits": "2.0.3",
+ "readable-stream": "2.3.6"
+ }
+ },
+ "stream-combiner2": {
+ "version": "1.1.1",
+ "resolved": "https://registry.npmjs.org/stream-combiner2/-/stream-combiner2-1.1.1.tgz",
+ "integrity": "sha1-+02KFCDqNidk4hrUeAOXvry0HL4=",
+ "dev": true,
+ "requires": {
+ "duplexer2": "0.1.4",
+ "readable-stream": "2.3.6"
+ }
+ },
+ "stream-consume": {
+ "version": "0.1.1",
+ "resolved": "https://registry.npmjs.org/stream-consume/-/stream-consume-0.1.1.tgz",
+ "integrity": "sha512-tNa3hzgkjEP7XbCkbRXe1jpg+ievoa0O4SCFlMOYEscGSS4JJsckGL8swUyAa/ApGU3Ae4t6Honor4HhL+tRyg==",
+ "dev": true
+ },
+ "stream-http": {
+ "version": "2.8.1",
+ "resolved": "https://registry.npmjs.org/stream-http/-/stream-http-2.8.1.tgz",
+ "integrity": "sha512-cQ0jo17BLca2r0GfRdZKYAGLU6JRoIWxqSOakUMuKOT6MOK7AAlE856L33QuDmAy/eeOrhLee3dZKX0Uadu93A==",
+ "dev": true,
+ "requires": {
+ "builtin-status-codes": "3.0.0",
+ "inherits": "2.0.3",
+ "readable-stream": "2.3.6",
+ "to-arraybuffer": "1.0.1",
+ "xtend": "4.0.1"
+ }
+ },
+ "stream-splicer": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/stream-splicer/-/stream-splicer-2.0.0.tgz",
+ "integrity": "sha1-G2O+Q4oTPktnHMGTUZdgAXWRDYM=",
+ "dev": true,
+ "requires": {
+ "inherits": "2.0.3",
+ "readable-stream": "2.3.6"
+ }
+ },
+ "string-width": {
+ "version": "1.0.2",
+ "resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz",
+ "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=",
+ "dev": true,
+ "requires": {
+ "code-point-at": "1.1.0",
+ "is-fullwidth-code-point": "1.0.0",
+ "strip-ansi": "3.0.1"
+ }
+ },
+ "string_decoder": {
+ "version": "1.1.1",
+ "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz",
+ "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==",
+ "requires": {
+ "safe-buffer": "5.1.1"
+ }
+ },
+ "stringstream": {
+ "version": "0.0.5",
+ "resolved": "https://registry.npmjs.org/stringstream/-/stringstream-0.0.5.tgz",
+ "integrity": "sha1-TkhM1N5aC7vuGORjB3EKioFiGHg=",
+ "dev": true
+ },
+ "strip-ansi": {
+ "version": "3.0.1",
+ "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz",
+ "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=",
+ "dev": true,
+ "requires": {
+ "ansi-regex": "2.1.1"
+ }
+ },
+ "strip-bom": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-1.0.0.tgz",
+ "integrity": "sha1-hbiGLzhEtabV7IRnqTWYFzo295Q=",
+ "dev": true,
+ "requires": {
+ "first-chunk-stream": "1.0.0",
+ "is-utf8": "0.2.1"
+ }
+ },
+ "strip-indent": {
+ "version": "1.0.1",
+ "resolved": "https://registry.npmjs.org/strip-indent/-/strip-indent-1.0.1.tgz",
+ "integrity": "sha1-DHlipq3vp7vUrDZkYKY4VSrhoKI=",
+ "dev": true,
+ "requires": {
+ "get-stdin": "4.0.1"
+ }
+ },
+ "subarg": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/subarg/-/subarg-1.0.0.tgz",
+ "integrity": "sha1-9izxdYHplrSPyWVpn1TAauJouNI=",
+ "dev": true,
+ "requires": {
+ "minimist": "1.2.0"
+ },
+ "dependencies": {
+ "minimist": {
+ "version": "1.2.0",
+ "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz",
+ "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=",
+ "dev": true
+ }
+ }
+ },
+ "supports-color": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz",
+ "integrity": "sha1-U10EXOa2Nj+kARcIRimZXp3zJMc=",
+ "dev": true
+ },
+ "syntax-error": {
+ "version": "1.4.0",
+ "resolved": "https://registry.npmjs.org/syntax-error/-/syntax-error-1.4.0.tgz",
+ "integrity": "sha512-YPPlu67mdnHGTup2A8ff7BC2Pjq0e0Yp/IyTFN03zWO0RcK07uLcbi7C2KpGR2FvWbaB0+bfE27a+sBKebSo7w==",
+ "dev": true,
+ "requires": {
+ "acorn-node": "1.3.0"
+ }
+ },
+ "tar": {
+ "version": "2.2.1",
+ "resolved": "https://registry.npmjs.org/tar/-/tar-2.2.1.tgz",
+ "integrity": "sha1-jk0qJWwOIYXGsYrWlK7JaLg8sdE=",
+ "dev": true,
+ "requires": {
+ "block-stream": "0.0.9",
+ "fstream": "1.0.11",
+ "inherits": "2.0.3"
+ }
+ },
+ "through": {
+ "version": "2.3.8",
+ "resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz",
+ "integrity": "sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU=",
+ "dev": true
+ },
+ "through2": {
+ "version": "2.0.3",
+ "resolved": "https://registry.npmjs.org/through2/-/through2-2.0.3.tgz",
+ "integrity": "sha1-AARWmzfHx0ujnEPzzteNGtlBQL4=",
+ "requires": {
+ "readable-stream": "2.3.6",
+ "xtend": "4.0.1"
+ }
+ },
+ "tildify": {
+ "version": "1.2.0",
+ "resolved": "https://registry.npmjs.org/tildify/-/tildify-1.2.0.tgz",
+ "integrity": "sha1-3OwD9V3Km3qj5bBPIYF+tW5jWIo=",
+ "dev": true,
+ "requires": {
+ "os-homedir": "1.0.2"
+ }
+ },
+ "time-stamp": {
+ "version": "1.1.0",
+ "resolved": "https://registry.npmjs.org/time-stamp/-/time-stamp-1.1.0.tgz",
+ "integrity": "sha1-dkpaEa9QVhkhsTPztE5hhofg9cM=",
+ "dev": true
+ },
+ "timers-browserify": {
+ "version": "1.4.2",
+ "resolved": "https://registry.npmjs.org/timers-browserify/-/timers-browserify-1.4.2.tgz",
+ "integrity": "sha1-ycWLV1voQHN1y14kYtrO50NZ9B0=",
+ "dev": true,
+ "requires": {
+ "process": "0.11.10"
+ }
+ },
+ "to-arraybuffer": {
+ "version": "1.0.1",
+ "resolved": "https://registry.npmjs.org/to-arraybuffer/-/to-arraybuffer-1.0.1.tgz",
+ "integrity": "sha1-fSKbH8xjfkZsoIEYCDanqr/4P0M=",
+ "dev": true
+ },
+ "to-fast-properties": {
+ "version": "1.0.3",
+ "resolved": "https://registry.npmjs.org/to-fast-properties/-/to-fast-properties-1.0.3.tgz",
+ "integrity": "sha1-uDVx+k2MJbguIxsG46MFXeTKGkc=",
+ "dev": true
+ },
+ "to-object-path": {
+ "version": "0.3.0",
+ "resolved": "https://registry.npmjs.org/to-object-path/-/to-object-path-0.3.0.tgz",
+ "integrity": "sha1-KXWIt7Dn4KwI4E5nL4XB9JmeF68=",
+ "dev": true,
+ "requires": {
+ "kind-of": "3.2.2"
+ }
+ },
+ "to-regex": {
+ "version": "3.0.2",
+ "resolved": "https://registry.npmjs.org/to-regex/-/to-regex-3.0.2.tgz",
+ "integrity": "sha512-FWtleNAtZ/Ki2qtqej2CXTOayOH9bHDQF+Q48VpWyDXjbYxA4Yz8iDB31zXOBUlOHHKidDbqGVrTUvQMPmBGBw==",
+ "dev": true,
+ "requires": {
+ "define-property": "2.0.2",
+ "extend-shallow": "3.0.2",
+ "regex-not": "1.0.2",
+ "safe-regex": "1.1.0"
+ }
+ },
+ "to-regex-range": {
+ "version": "2.1.1",
+ "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-2.1.1.tgz",
+ "integrity": "sha1-fIDBe53+vlmeJzZ+DU3VWQFB2zg=",
+ "dev": true,
+ "requires": {
+ "is-number": "3.0.0",
+ "repeat-string": "1.6.1"
+ }
+ },
+ "tough-cookie": {
+ "version": "2.3.4",
+ "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.3.4.tgz",
+ "integrity": "sha512-TZ6TTfI5NtZnuyy/Kecv+CnoROnyXn2DN97LontgQpCwsX2XyLYCC0ENhYkehSOwAp8rTQKc/NUIF7BkQ5rKLA==",
+ "dev": true,
+ "requires": {
+ "punycode": "1.4.1"
+ }
+ },
+ "trim-newlines": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/trim-newlines/-/trim-newlines-1.0.0.tgz",
+ "integrity": "sha1-WIeWa7WCpFA6QetST301ARgVphM=",
+ "dev": true
+ },
+ "trim-right": {
+ "version": "1.0.1",
+ "resolved": "https://registry.npmjs.org/trim-right/-/trim-right-1.0.1.tgz",
+ "integrity": "sha1-yy4SAwZ+DI3h9hQJS5/kVwTqYAM=",
+ "dev": true
+ },
+ "tty-browserify": {
+ "version": "0.0.1",
+ "resolved": "https://registry.npmjs.org/tty-browserify/-/tty-browserify-0.0.1.tgz",
+ "integrity": "sha512-C3TaO7K81YvjCgQH9Q1S3R3P3BtN3RIM8n+OvX4il1K1zgE8ZhI0op7kClgkxtutIE8hQrcrHBXvIheqKUUCxw==",
+ "dev": true
+ },
+ "tunnel-agent": {
+ "version": "0.6.0",
+ "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz",
+ "integrity": "sha1-J6XeoGs2sEoKmWZ3SykIaPD8QP0=",
+ "dev": true,
+ "requires": {
+ "safe-buffer": "5.1.1"
+ }
+ },
+ "tweetnacl": {
+ "version": "0.14.5",
+ "resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-0.14.5.tgz",
+ "integrity": "sha1-WuaBd/GS1EViadEIr6k/+HQ/T2Q=",
+ "dev": true,
+ "optional": true
+ },
+ "typedarray": {
+ "version": "0.0.6",
+ "resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz",
+ "integrity": "sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=",
+ "dev": true
+ },
+ "uglify-js": {
+ "version": "2.8.29",
+ "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-2.8.29.tgz",
+ "integrity": "sha1-KcVzMUgFe7Th913zW3qcty5qWd0=",
+ "requires": {
+ "source-map": "0.5.7",
+ "uglify-to-browserify": "1.0.2",
+ "yargs": "3.10.0"
+ }
+ },
+ "uglify-save-license": {
+ "version": "0.4.1",
+ "resolved": "https://registry.npmjs.org/uglify-save-license/-/uglify-save-license-0.4.1.tgz",
+ "integrity": "sha1-lXJsF8xv0XHDYX479NjYKqjEzOE="
+ },
+ "uglify-to-browserify": {
+ "version": "1.0.2",
+ "resolved": "https://registry.npmjs.org/uglify-to-browserify/-/uglify-to-browserify-1.0.2.tgz",
+ "integrity": "sha1-bgkk1r2mta/jSeOabWMoUKD4grc=",
+ "optional": true
+ },
+ "umd": {
+ "version": "3.0.3",
+ "resolved": "https://registry.npmjs.org/umd/-/umd-3.0.3.tgz",
+ "integrity": "sha512-4IcGSufhFshvLNcMCV80UnQVlZ5pMOC8mvNPForqwA4+lzYQuetTESLDQkeLmihq8bRcnpbQa48Wb8Lh16/xow==",
+ "dev": true
+ },
+ "unc-path-regex": {
+ "version": "0.1.2",
+ "resolved": "https://registry.npmjs.org/unc-path-regex/-/unc-path-regex-0.1.2.tgz",
+ "integrity": "sha1-5z3T17DXxe2G+6xrCufYxqadUPo=",
+ "dev": true
+ },
+ "union-value": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/union-value/-/union-value-1.0.0.tgz",
+ "integrity": "sha1-XHHDTLW61dzr4+oM0IIHulqhrqQ=",
+ "dev": true,
+ "requires": {
+ "arr-union": "3.1.0",
+ "get-value": "2.0.6",
+ "is-extendable": "0.1.1",
+ "set-value": "0.4.3"
+ },
+ "dependencies": {
+ "extend-shallow": {
+ "version": "2.0.1",
+ "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz",
+ "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=",
+ "dev": true,
+ "requires": {
+ "is-extendable": "0.1.1"
+ }
+ },
+ "set-value": {
+ "version": "0.4.3",
+ "resolved": "https://registry.npmjs.org/set-value/-/set-value-0.4.3.tgz",
+ "integrity": "sha1-fbCPnT0i3H945Trzw79GZuzfzPE=",
+ "dev": true,
+ "requires": {
+ "extend-shallow": "2.0.1",
+ "is-extendable": "0.1.1",
+ "is-plain-object": "2.0.4",
+ "to-object-path": "0.3.0"
+ }
+ }
+ }
+ },
+ "unique-stream": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/unique-stream/-/unique-stream-1.0.0.tgz",
+ "integrity": "sha1-1ZpKdUJ0R9mqbJHnAmP40mpLEEs=",
+ "dev": true
+ },
+ "unset-value": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/unset-value/-/unset-value-1.0.0.tgz",
+ "integrity": "sha1-g3aHP30jNRef+x5vw6jtDfyKtVk=",
+ "dev": true,
+ "requires": {
+ "has-value": "0.3.1",
+ "isobject": "3.0.1"
+ },
+ "dependencies": {
+ "has-value": {
+ "version": "0.3.1",
+ "resolved": "https://registry.npmjs.org/has-value/-/has-value-0.3.1.tgz",
+ "integrity": "sha1-ex9YutpiyoJ+wKIHgCVlSEWZXh8=",
+ "dev": true,
+ "requires": {
+ "get-value": "2.0.6",
+ "has-values": "0.1.4",
+ "isobject": "2.1.0"
+ },
+ "dependencies": {
+ "isobject": {
+ "version": "2.1.0",
+ "resolved": "https://registry.npmjs.org/isobject/-/isobject-2.1.0.tgz",
+ "integrity": "sha1-8GVWEJaj8dou9GJy+BXIQNh+DIk=",
+ "dev": true,
+ "requires": {
+ "isarray": "1.0.0"
+ }
+ }
+ }
+ },
+ "has-values": {
+ "version": "0.1.4",
+ "resolved": "https://registry.npmjs.org/has-values/-/has-values-0.1.4.tgz",
+ "integrity": "sha1-bWHeldkd/Km5oCCJrThL/49it3E=",
+ "dev": true
+ }
+ }
+ },
+ "urix": {
+ "version": "0.1.0",
+ "resolved": "https://registry.npmjs.org/urix/-/urix-0.1.0.tgz",
+ "integrity": "sha1-2pN/emLiH+wf0Y1Js1wpNQZ6bHI=",
+ "dev": true
+ },
+ "url": {
+ "version": "0.11.0",
+ "resolved": "https://registry.npmjs.org/url/-/url-0.11.0.tgz",
+ "integrity": "sha1-ODjpfPxgUh63PFJajlW/3Z4uKPE=",
+ "dev": true,
+ "requires": {
+ "punycode": "1.3.2",
+ "querystring": "0.2.0"
+ },
+ "dependencies": {
+ "punycode": {
+ "version": "1.3.2",
+ "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.3.2.tgz",
+ "integrity": "sha1-llOgNvt8HuQjQvIyXM7v6jkmxI0=",
+ "dev": true
+ }
+ }
+ },
+ "use": {
+ "version": "3.1.0",
+ "resolved": "https://registry.npmjs.org/use/-/use-3.1.0.tgz",
+ "integrity": "sha512-6UJEQM/L+mzC3ZJNM56Q4DFGLX/evKGRg15UJHGB9X5j5Z3AFbgZvjUh2yq/UJUY4U5dh7Fal++XbNg1uzpRAw==",
+ "dev": true,
+ "requires": {
+ "kind-of": "6.0.2"
+ },
+ "dependencies": {
+ "kind-of": {
+ "version": "6.0.2",
+ "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.2.tgz",
+ "integrity": "sha512-s5kLOcnH0XqDO+FvuaLX8DDjZ18CGFk7VygH40QoKPUQhW4e2rvM0rwUq0t8IQDOwYSeLK01U90OjzBTme2QqA==",
+ "dev": true
+ }
+ }
+ },
+ "user-home": {
+ "version": "1.1.1",
+ "resolved": "https://registry.npmjs.org/user-home/-/user-home-1.1.1.tgz",
+ "integrity": "sha1-K1viOjK2Onyd640PKNSFcko98ZA=",
+ "dev": true
+ },
+ "util": {
+ "version": "0.10.3",
+ "resolved": "https://registry.npmjs.org/util/-/util-0.10.3.tgz",
+ "integrity": "sha1-evsa/lCAUkZInj23/g7TeTNqwPk=",
+ "dev": true,
+ "requires": {
+ "inherits": "2.0.1"
+ },
+ "dependencies": {
+ "inherits": {
+ "version": "2.0.1",
+ "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.1.tgz",
+ "integrity": "sha1-sX0I0ya0Qj5Wjv9xn5GwscvfafE=",
+ "dev": true
+ }
+ }
+ },
+ "util-deprecate": {
+ "version": "1.0.2",
+ "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz",
+ "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8="
+ },
+ "uuid": {
+ "version": "3.2.1",
+ "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.2.1.tgz",
+ "integrity": "sha512-jZnMwlb9Iku/O3smGWvZhauCf6cvvpKi4BKRiliS3cxnI+Gz9j5MEpTz2UFuXiKPJocb7gnsLHwiS05ige5BEA==",
+ "dev": true
+ },
+ "v8flags": {
+ "version": "2.1.1",
+ "resolved": "https://registry.npmjs.org/v8flags/-/v8flags-2.1.1.tgz",
+ "integrity": "sha1-qrGh+jDUX4jdMhFIh1rALAtV5bQ=",
+ "dev": true,
+ "requires": {
+ "user-home": "1.1.1"
+ }
+ },
+ "validate-npm-package-license": {
+ "version": "3.0.3",
+ "resolved": "https://registry.npmjs.org/validate-npm-package-license/-/validate-npm-package-license-3.0.3.tgz",
+ "integrity": "sha512-63ZOUnL4SIXj4L0NixR3L1lcjO38crAbgrTpl28t8jjrfuiOBL5Iygm+60qPs/KsZGzPNg6Smnc/oY16QTjF0g==",
+ "dev": true,
+ "requires": {
+ "spdx-correct": "3.0.0",
+ "spdx-expression-parse": "3.0.0"
+ }
+ },
+ "verror": {
+ "version": "1.10.0",
+ "resolved": "https://registry.npmjs.org/verror/-/verror-1.10.0.tgz",
+ "integrity": "sha1-OhBcoXBTr1XW4nDB+CiGguGNpAA=",
+ "dev": true,
+ "requires": {
+ "assert-plus": "1.0.0",
+ "core-util-is": "1.0.2",
+ "extsprintf": "1.3.0"
+ }
+ },
+ "vinyl": {
+ "version": "0.5.3",
+ "resolved": "https://registry.npmjs.org/vinyl/-/vinyl-0.5.3.tgz",
+ "integrity": "sha1-sEVbOPxeDPMNQyUTLkYZcMIJHN4=",
+ "dev": true,
+ "requires": {
+ "clone": "1.0.4",
+ "clone-stats": "0.0.1",
+ "replace-ext": "0.0.1"
+ }
+ },
+ "vinyl-buffer": {
+ "version": "1.0.1",
+ "resolved": "https://registry.npmjs.org/vinyl-buffer/-/vinyl-buffer-1.0.1.tgz",
+ "integrity": "sha1-lsGjR5uMU5JULGEgKQE7Wyf4i78=",
+ "dev": true,
+ "requires": {
+ "bl": "1.2.2",
+ "through2": "2.0.3"
+ }
+ },
+ "vinyl-fs": {
+ "version": "0.3.14",
+ "resolved": "https://registry.npmjs.org/vinyl-fs/-/vinyl-fs-0.3.14.tgz",
+ "integrity": "sha1-mmhRzhysHBzqX+hsCTHWIMLPqeY=",
+ "dev": true,
+ "requires": {
+ "defaults": "1.0.3",
+ "glob-stream": "3.1.18",
+ "glob-watcher": "0.0.6",
+ "graceful-fs": "3.0.11",
+ "mkdirp": "0.5.1",
+ "strip-bom": "1.0.0",
+ "through2": "0.6.5",
+ "vinyl": "0.4.6"
+ },
+ "dependencies": {
+ "clone": {
+ "version": "0.2.0",
+ "resolved": "https://registry.npmjs.org/clone/-/clone-0.2.0.tgz",
+ "integrity": "sha1-xhJqkK1Pctv1rNskPMN3JP6T/B8=",
+ "dev": true
+ },
+ "isarray": {
+ "version": "0.0.1",
+ "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz",
+ "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=",
+ "dev": true
+ },
+ "readable-stream": {
+ "version": "1.0.34",
+ "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.0.34.tgz",
+ "integrity": "sha1-Elgg40vIQtLyqq+v5MKRbuMsFXw=",
+ "dev": true,
+ "requires": {
+ "core-util-is": "1.0.2",
+ "inherits": "2.0.3",
+ "isarray": "0.0.1",
+ "string_decoder": "0.10.31"
+ }
+ },
+ "string_decoder": {
+ "version": "0.10.31",
+ "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz",
+ "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=",
+ "dev": true
+ },
+ "through2": {
+ "version": "0.6.5",
+ "resolved": "https://registry.npmjs.org/through2/-/through2-0.6.5.tgz",
+ "integrity": "sha1-QaucZ7KdVyCQcUEOHXp6lozTrUg=",
+ "dev": true,
+ "requires": {
+ "readable-stream": "1.0.34",
+ "xtend": "4.0.1"
+ }
+ },
+ "vinyl": {
+ "version": "0.4.6",
+ "resolved": "https://registry.npmjs.org/vinyl/-/vinyl-0.4.6.tgz",
+ "integrity": "sha1-LzVsh6VQolVGHza76ypbqL94SEc=",
+ "dev": true,
+ "requires": {
+ "clone": "0.2.0",
+ "clone-stats": "0.0.1"
+ }
+ }
+ }
+ },
+ "vinyl-source-stream": {
+ "version": "1.1.2",
+ "resolved": "https://registry.npmjs.org/vinyl-source-stream/-/vinyl-source-stream-1.1.2.tgz",
+ "integrity": "sha1-YrU6E1YQqJbpjKlr7jqH8Aio54A=",
+ "dev": true,
+ "requires": {
+ "through2": "2.0.3",
+ "vinyl": "0.4.6"
+ },
+ "dependencies": {
+ "clone": {
+ "version": "0.2.0",
+ "resolved": "https://registry.npmjs.org/clone/-/clone-0.2.0.tgz",
+ "integrity": "sha1-xhJqkK1Pctv1rNskPMN3JP6T/B8=",
+ "dev": true
+ },
+ "vinyl": {
+ "version": "0.4.6",
+ "resolved": "https://registry.npmjs.org/vinyl/-/vinyl-0.4.6.tgz",
+ "integrity": "sha1-LzVsh6VQolVGHza76ypbqL94SEc=",
+ "dev": true,
+ "requires": {
+ "clone": "0.2.0",
+ "clone-stats": "0.0.1"
+ }
+ }
+ }
+ },
+ "vinyl-sourcemaps-apply": {
+ "version": "0.2.1",
+ "resolved": "https://registry.npmjs.org/vinyl-sourcemaps-apply/-/vinyl-sourcemaps-apply-0.2.1.tgz",
+ "integrity": "sha1-q2VJ1h0XLCsbh75cUI0jnI74dwU=",
+ "requires": {
+ "source-map": "0.5.7"
+ }
+ },
+ "vm-browserify": {
+ "version": "0.0.4",
+ "resolved": "https://registry.npmjs.org/vm-browserify/-/vm-browserify-0.0.4.tgz",
+ "integrity": "sha1-XX6kW7755Kb/ZflUOOCofDV9WnM=",
+ "dev": true,
+ "requires": {
+ "indexof": "0.0.1"
+ }
+ },
+ "which": {
+ "version": "1.3.0",
+ "resolved": "https://registry.npmjs.org/which/-/which-1.3.0.tgz",
+ "integrity": "sha512-xcJpopdamTuY5duC/KnTTNBraPK54YwpenP4lzxU8H91GudWpFv38u0CKjclE1Wi2EH2EDz5LRcHcKbCIzqGyg==",
+ "dev": true,
+ "requires": {
+ "isexe": "2.0.0"
+ }
+ },
+ "which-module": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/which-module/-/which-module-1.0.0.tgz",
+ "integrity": "sha1-u6Y8qGGUiZT/MHc2CJ47lgJsKk8=",
+ "dev": true
+ },
+ "wide-align": {
+ "version": "1.1.2",
+ "resolved": "https://registry.npmjs.org/wide-align/-/wide-align-1.1.2.tgz",
+ "integrity": "sha512-ijDLlyQ7s6x1JgCLur53osjm/UXUYD9+0PbYKrBsYisYXzCxN+HC3mYDNy/dWdmf3AwqwU3CXwDCvsNgGK1S0w==",
+ "dev": true,
+ "requires": {
+ "string-width": "1.0.2"
+ }
+ },
+ "window-size": {
+ "version": "0.1.0",
+ "resolved": "https://registry.npmjs.org/window-size/-/window-size-0.1.0.tgz",
+ "integrity": "sha1-VDjNLqk7IC76Ohn+iIeu58lPnJ0="
+ },
+ "wordwrap": {
+ "version": "0.0.2",
+ "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-0.0.2.tgz",
+ "integrity": "sha1-t5Zpu0LstAn4PVg8rVLKF+qhZD8="
+ },
+ "wrap-ansi": {
+ "version": "2.1.0",
+ "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-2.1.0.tgz",
+ "integrity": "sha1-2Pw9KE3QV5T+hJc8rs3Rz4JP3YU=",
+ "dev": true,
+ "requires": {
+ "string-width": "1.0.2",
+ "strip-ansi": "3.0.1"
+ }
+ },
+ "wrappy": {
+ "version": "1.0.2",
+ "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz",
+ "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8="
+ },
+ "xmlhttprequest": {
+ "version": "1.8.0",
+ "resolved": "https://registry.npmjs.org/xmlhttprequest/-/xmlhttprequest-1.8.0.tgz",
+ "integrity": "sha1-Z/4HXFwk/vOfnWX197f+dRcZaPw="
+ },
+ "xtend": {
+ "version": "4.0.1",
+ "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.1.tgz",
+ "integrity": "sha1-pcbVMr5lbiPbgg77lDofBJmNY68="
+ },
+ "y18n": {
+ "version": "3.2.1",
+ "resolved": "https://registry.npmjs.org/y18n/-/y18n-3.2.1.tgz",
+ "integrity": "sha1-bRX7qITAhnnA136I53WegR4H+kE=",
+ "dev": true
+ },
+ "yallist": {
+ "version": "2.1.2",
+ "resolved": "https://registry.npmjs.org/yallist/-/yallist-2.1.2.tgz",
+ "integrity": "sha1-HBH5IY8HYImkfdUS+TxmmaaoHVI=",
+ "dev": true
+ },
+ "yargs": {
+ "version": "3.10.0",
+ "resolved": "https://registry.npmjs.org/yargs/-/yargs-3.10.0.tgz",
+ "integrity": "sha1-9+572FfdfB0tOMDnTvvWgdFDH9E=",
+ "requires": {
+ "camelcase": "1.2.1",
+ "cliui": "2.1.0",
+ "decamelize": "1.2.0",
+ "window-size": "0.1.0"
+ }
+ },
+ "yargs-parser": {
+ "version": "5.0.0",
+ "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-5.0.0.tgz",
+ "integrity": "sha1-J17PDX/+Bcd+ZOfIbkzZS/DhIoo=",
+ "dev": true,
+ "requires": {
+ "camelcase": "3.0.0"
+ },
+ "dependencies": {
+ "camelcase": {
+ "version": "3.0.0",
+ "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-3.0.0.tgz",
+ "integrity": "sha1-MvxLn82vhF/N9+c7uXysImHwqwo=",
+ "dev": true
+ }
+ }
+ }
+ }
+}
diff --git a/api/api.go b/pkg/api/api.go
similarity index 100%
rename from api/api.go
rename to pkg/api/api.go
diff --git a/api/api_test.go b/pkg/api/api_test.go
similarity index 100%
rename from api/api_test.go
rename to pkg/api/api_test.go
diff --git a/api/auth.go b/pkg/api/auth.go
similarity index 97%
rename from api/auth.go
rename to pkg/api/auth.go
index d3ae561..c564003 100644
--- a/api/auth.go
+++ b/pkg/api/auth.go
@@ -6,7 +6,7 @@ import (
"net/http"
"os"
- "github.com/dannyvankooten/ana/datastore"
+ "github.com/dannyvankooten/ana/pkg/datastore"
"github.com/gorilla/sessions"
"golang.org/x/crypto/bcrypt"
)
diff --git a/api/browsers.go b/pkg/api/browsers.go
similarity index 87%
rename from api/browsers.go
rename to pkg/api/browsers.go
index 8912217..0e6c861 100644
--- a/api/browsers.go
+++ b/pkg/api/browsers.go
@@ -1,7 +1,7 @@
package api
import (
- "github.com/dannyvankooten/ana/count"
+ "github.com/dannyvankooten/ana/pkg/count"
"net/http"
)
diff --git a/api/collect.go b/pkg/api/collect.go
similarity index 97%
rename from api/collect.go
rename to pkg/api/collect.go
index b412243..672631d 100644
--- a/api/collect.go
+++ b/pkg/api/collect.go
@@ -8,8 +8,8 @@ import (
"strings"
"time"
- "github.com/dannyvankooten/ana/datastore"
- "github.com/dannyvankooten/ana/models"
+ "github.com/dannyvankooten/ana/pkg/datastore"
+ "github.com/dannyvankooten/ana/pkg/models"
"github.com/mssola/user_agent"
)
diff --git a/api/languages.go b/pkg/api/languages.go
similarity index 87%
rename from api/languages.go
rename to pkg/api/languages.go
index 625fb76..399cd57 100644
--- a/api/languages.go
+++ b/pkg/api/languages.go
@@ -3,7 +3,7 @@ package api
import (
"net/http"
- "github.com/dannyvankooten/ana/count"
+ "github.com/dannyvankooten/ana/pkg/count"
)
// URL: /api/languages
diff --git a/api/pageviews.go b/pkg/api/pageviews.go
similarity index 94%
rename from api/pageviews.go
rename to pkg/api/pageviews.go
index 9756040..a7f2389 100644
--- a/api/pageviews.go
+++ b/pkg/api/pageviews.go
@@ -3,8 +3,8 @@ package api
import (
"net/http"
- "github.com/dannyvankooten/ana/count"
- "github.com/dannyvankooten/ana/datastore"
+ "github.com/dannyvankooten/ana/pkg/count"
+ "github.com/dannyvankooten/ana/pkg/datastore"
)
type pageviews struct {
diff --git a/api/referrers.go b/pkg/api/referrers.go
similarity index 87%
rename from api/referrers.go
rename to pkg/api/referrers.go
index a10015a..43d9d29 100644
--- a/api/referrers.go
+++ b/pkg/api/referrers.go
@@ -3,7 +3,7 @@ package api
import (
"net/http"
- "github.com/dannyvankooten/ana/count"
+ "github.com/dannyvankooten/ana/pkg/count"
)
// URL: /api/referrers
diff --git a/api/screens.go b/pkg/api/screens.go
similarity index 87%
rename from api/screens.go
rename to pkg/api/screens.go
index 764f3a1..1cff344 100644
--- a/api/screens.go
+++ b/pkg/api/screens.go
@@ -3,7 +3,7 @@ package api
import (
"net/http"
- "github.com/dannyvankooten/ana/count"
+ "github.com/dannyvankooten/ana/pkg/count"
)
// URL: /api/screen-resolutions
diff --git a/api/visitors.go b/pkg/api/visitors.go
similarity index 94%
rename from api/visitors.go
rename to pkg/api/visitors.go
index d986443..7325425 100644
--- a/api/visitors.go
+++ b/pkg/api/visitors.go
@@ -3,7 +3,7 @@ package api
import (
"net/http"
- "github.com/dannyvankooten/ana/count"
+ "github.com/dannyvankooten/ana/pkg/count"
)
// URL: /api/visitors/count
diff --git a/commands/data.go b/pkg/commands/data.go
similarity index 72%
rename from commands/data.go
rename to pkg/commands/data.go
index 1c08519..eee9d20 100644
--- a/commands/data.go
+++ b/pkg/commands/data.go
@@ -1,8 +1,8 @@
package commands
import (
- "github.com/dannyvankooten/ana/count"
- "github.com/dannyvankooten/ana/datastore"
+ "github.com/dannyvankooten/ana/pkg/count"
+ "github.com/dannyvankooten/ana/pkg/datastore"
)
// Seed creates n database records with dummy data
diff --git a/commands/server.go b/pkg/commands/server.go
similarity index 82%
rename from commands/server.go
rename to pkg/commands/server.go
index 1abf88d..c19f36e 100644
--- a/commands/server.go
+++ b/pkg/commands/server.go
@@ -2,7 +2,7 @@ package commands
import (
"fmt"
- "github.com/dannyvankooten/ana/api"
+ "github.com/dannyvankooten/ana/pkg/api"
"github.com/gorilla/handlers"
"github.com/gorilla/mux"
"log"
@@ -30,11 +30,11 @@ func Server(port int) {
//r.Handle("/api/countries", api.Authorize(api.GetCountriesHandler)).Methods("GET")
r.Handle("/api/browsers", api.Authorize(api.GetBrowsersHandler)).Methods("GET")
- r.PathPrefix("/static/").Handler(http.StripPrefix("/static/", http.FileServer(http.Dir("./static/"))))
- r.Path("/tracker.js").Handler(http.FileServer(http.Dir("./static/js/")))
- r.Handle("/", http.FileServer(http.Dir("./views/")))
+ r.Path("/tracker.js").Handler(http.FileServer(http.Dir("./assets/dist/js/")))
- log.Printf("HTTP server will now start listening on :%d\n", port)
+ r.PathPrefix("/").Handler(http.StripPrefix("/", http.FileServer(http.Dir("./assets/dist/"))))
+
+ log.Printf("HTTP server will now start listening on http://127.0.01:%d/\n", port)
err := http.ListenAndServe(fmt.Sprintf(":%d", port), handlers.LoggingHandler(os.Stdout, r))
log.Println(err)
}
diff --git a/commands/users.go b/pkg/commands/users.go
similarity index 81%
rename from commands/users.go
rename to pkg/commands/users.go
index a751c55..972115e 100644
--- a/commands/users.go
+++ b/pkg/commands/users.go
@@ -1,8 +1,8 @@
package commands
import (
- "github.com/dannyvankooten/ana/datastore"
- "github.com/dannyvankooten/ana/models"
+ "github.com/dannyvankooten/ana/pkg/datastore"
+ "github.com/dannyvankooten/ana/pkg/models"
"golang.org/x/crypto/bcrypt"
"log"
)
diff --git a/count/browsers.go b/pkg/count/browsers.go
similarity index 97%
rename from count/browsers.go
rename to pkg/count/browsers.go
index 42e556e..7d6636d 100644
--- a/count/browsers.go
+++ b/pkg/count/browsers.go
@@ -1,7 +1,7 @@
package count
import (
- "github.com/dannyvankooten/ana/datastore"
+ "github.com/dannyvankooten/ana/pkg/datastore"
)
// TotalUniqueBrowsers returns the total # of unique browsers between two given timestamps
diff --git a/count/count.go b/pkg/count/count.go
similarity index 98%
rename from count/count.go
rename to pkg/count/count.go
index a007c49..882b2f7 100644
--- a/count/count.go
+++ b/pkg/count/count.go
@@ -5,7 +5,7 @@ import (
"log"
"time"
- "github.com/dannyvankooten/ana/datastore"
+ "github.com/dannyvankooten/ana/pkg/datastore"
)
// Total represents a daily aggregated total for a metric
diff --git a/count/count_test.go b/pkg/count/count_test.go
similarity index 100%
rename from count/count_test.go
rename to pkg/count/count_test.go
diff --git a/count/languages.go b/pkg/count/languages.go
similarity index 97%
rename from count/languages.go
rename to pkg/count/languages.go
index dba685b..2cdc21c 100644
--- a/count/languages.go
+++ b/pkg/count/languages.go
@@ -1,7 +1,7 @@
package count
import (
- "github.com/dannyvankooten/ana/datastore"
+ "github.com/dannyvankooten/ana/pkg/datastore"
)
// TotalUniqueLanguages returns the total # of unique browser languages between two given timestamps
diff --git a/count/pageviews.go b/pkg/count/pageviews.go
similarity index 97%
rename from count/pageviews.go
rename to pkg/count/pageviews.go
index b16ddc5..255b057 100644
--- a/count/pageviews.go
+++ b/pkg/count/pageviews.go
@@ -1,6 +1,6 @@
package count
-import "github.com/dannyvankooten/ana/datastore"
+import "github.com/dannyvankooten/ana/pkg/datastore"
// Pageviews returns the total number of pageviews between the given timestamps
func Pageviews(before int64, after int64) int {
diff --git a/count/referrers.go b/pkg/count/referrers.go
similarity index 97%
rename from count/referrers.go
rename to pkg/count/referrers.go
index 08f7fbd..38ad940 100644
--- a/count/referrers.go
+++ b/pkg/count/referrers.go
@@ -1,7 +1,7 @@
package count
import (
- "github.com/dannyvankooten/ana/datastore"
+ "github.com/dannyvankooten/ana/pkg/datastore"
)
// TotalReferrers returns the total # of referrers between two given timestamps
diff --git a/count/screens.go b/pkg/count/screens.go
similarity index 97%
rename from count/screens.go
rename to pkg/count/screens.go
index e74c552..4be5550 100644
--- a/count/screens.go
+++ b/pkg/count/screens.go
@@ -1,7 +1,7 @@
package count
import (
- "github.com/dannyvankooten/ana/datastore"
+ "github.com/dannyvankooten/ana/pkg/datastore"
)
// TotalUniqueScreens returns the total # of screens between two given timestamps
diff --git a/count/visitors.go b/pkg/count/visitors.go
similarity index 98%
rename from count/visitors.go
rename to pkg/count/visitors.go
index 1e98e1a..2a3614e 100644
--- a/count/visitors.go
+++ b/pkg/count/visitors.go
@@ -1,7 +1,7 @@
package count
import (
- "github.com/dannyvankooten/ana/datastore"
+ "github.com/dannyvankooten/ana/pkg/datastore"
)
// RealtimeVisitors returns the total number of visitors in the last 3 minutes
diff --git a/datastore/migrations/1_initial.sql b/pkg/datastore/migrations/1_initial.sql
similarity index 100%
rename from datastore/migrations/1_initial.sql
rename to pkg/datastore/migrations/1_initial.sql
diff --git a/datastore/options.go b/pkg/datastore/options.go
similarity index 100%
rename from datastore/options.go
rename to pkg/datastore/options.go
diff --git a/datastore/options_test.go b/pkg/datastore/options_test.go
similarity index 100%
rename from datastore/options_test.go
rename to pkg/datastore/options_test.go
diff --git a/datastore/pages.go b/pkg/datastore/pages.go
similarity index 95%
rename from datastore/pages.go
rename to pkg/datastore/pages.go
index 2fc0032..9c56ca1 100644
--- a/datastore/pages.go
+++ b/pkg/datastore/pages.go
@@ -1,7 +1,7 @@
package datastore
import (
- "github.com/dannyvankooten/ana/models"
+ "github.com/dannyvankooten/ana/pkg/models"
)
var p models.Page
diff --git a/datastore/pageviews.go b/pkg/datastore/pageviews.go
similarity index 96%
rename from datastore/pageviews.go
rename to pkg/datastore/pageviews.go
index c71b715..80e302a 100644
--- a/datastore/pageviews.go
+++ b/pkg/datastore/pageviews.go
@@ -1,7 +1,7 @@
package datastore
import (
- "github.com/dannyvankooten/ana/models"
+ "github.com/dannyvankooten/ana/pkg/models"
)
//var pv models.Pageview
diff --git a/datastore/seed.go b/pkg/datastore/seed.go
similarity index 98%
rename from datastore/seed.go
rename to pkg/datastore/seed.go
index 5b6e748..2ce9d40 100644
--- a/datastore/seed.go
+++ b/pkg/datastore/seed.go
@@ -8,7 +8,7 @@ import (
"time"
randomdata "github.com/Pallinder/go-randomdata"
- "github.com/dannyvankooten/ana/models"
+ "github.com/dannyvankooten/ana/pkg/models"
)
var browserNames = []string{
diff --git a/datastore/store.go b/pkg/datastore/store.go
similarity index 97%
rename from datastore/store.go
rename to pkg/datastore/store.go
index 0bfd70b..dc2eb34 100644
--- a/datastore/store.go
+++ b/pkg/datastore/store.go
@@ -63,7 +63,7 @@ func getDSN(driver string) string {
func runMigrations(driver string) {
migrations := migrate.FileMigrationSource{
- Dir: "datastore/migrations",
+ Dir: "pkg/datastore/migrations",
}
migrate.SetTable("migrations")
diff --git a/datastore/users.go b/pkg/datastore/users.go
similarity index 93%
rename from datastore/users.go
rename to pkg/datastore/users.go
index 85d98e6..e4f994a 100644
--- a/datastore/users.go
+++ b/pkg/datastore/users.go
@@ -1,7 +1,7 @@
package datastore
import (
- "github.com/dannyvankooten/ana/models"
+ "github.com/dannyvankooten/ana/pkg/models"
)
var u models.User
diff --git a/datastore/visitors.go b/pkg/datastore/visitors.go
similarity index 95%
rename from datastore/visitors.go
rename to pkg/datastore/visitors.go
index 7a9a736..9cfe995 100644
--- a/datastore/visitors.go
+++ b/pkg/datastore/visitors.go
@@ -1,7 +1,7 @@
package datastore
import (
- "github.com/dannyvankooten/ana/models"
+ "github.com/dannyvankooten/ana/pkg/models"
)
var v models.Visitor
diff --git a/models/page.go b/pkg/models/page.go
similarity index 100%
rename from models/page.go
rename to pkg/models/page.go
diff --git a/models/pageview.go b/pkg/models/pageview.go
similarity index 100%
rename from models/pageview.go
rename to pkg/models/pageview.go
diff --git a/models/user.go b/pkg/models/user.go
similarity index 100%
rename from models/user.go
rename to pkg/models/user.go
diff --git a/models/visitor.go b/pkg/models/visitor.go
similarity index 100%
rename from models/visitor.go
rename to pkg/models/visitor.go
diff --git a/vendor/github.com/alecthomas/template/LICENSE b/vendor/github.com/alecthomas/template/LICENSE
new file mode 100644
index 0000000..7448756
--- /dev/null
+++ b/vendor/github.com/alecthomas/template/LICENSE
@@ -0,0 +1,27 @@
+Copyright (c) 2012 The Go Authors. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+
+ * Redistributions of source code must retain the above copyright
+notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above
+copyright notice, this list of conditions and the following disclaimer
+in the documentation and/or other materials provided with the
+distribution.
+ * Neither the name of Google Inc. nor the names of its
+contributors may be used to endorse or promote products derived from
+this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
diff --git a/vendor/github.com/alecthomas/template/README.md b/vendor/github.com/alecthomas/template/README.md
new file mode 100644
index 0000000..ef6a8ee
--- /dev/null
+++ b/vendor/github.com/alecthomas/template/README.md
@@ -0,0 +1,25 @@
+# Go's `text/template` package with newline elision
+
+This is a fork of Go 1.4's [text/template](http://golang.org/pkg/text/template/) package with one addition: a backslash immediately after a closing delimiter will delete all subsequent newlines until a non-newline.
+
+eg.
+
+```
+{{if true}}\
+hello
+{{end}}\
+```
+
+Will result in:
+
+```
+hello\n
+```
+
+Rather than:
+
+```
+\n
+hello\n
+\n
+```
diff --git a/vendor/github.com/alecthomas/template/doc.go b/vendor/github.com/alecthomas/template/doc.go
new file mode 100644
index 0000000..223c595
--- /dev/null
+++ b/vendor/github.com/alecthomas/template/doc.go
@@ -0,0 +1,406 @@
+// Copyright 2011 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+/*
+Package template implements data-driven templates for generating textual output.
+
+To generate HTML output, see package html/template, which has the same interface
+as this package but automatically secures HTML output against certain attacks.
+
+Templates are executed by applying them to a data structure. Annotations in the
+template refer to elements of the data structure (typically a field of a struct
+or a key in a map) to control execution and derive values to be displayed.
+Execution of the template walks the structure and sets the cursor, represented
+by a period '.' and called "dot", to the value at the current location in the
+structure as execution proceeds.
+
+The input text for a template is UTF-8-encoded text in any format.
+"Actions"--data evaluations or control structures--are delimited by
+"{{" and "}}"; all text outside actions is copied to the output unchanged.
+Actions may not span newlines, although comments can.
+
+Once parsed, a template may be executed safely in parallel.
+
+Here is a trivial example that prints "17 items are made of wool".
+
+ type Inventory struct {
+ Material string
+ Count uint
+ }
+ sweaters := Inventory{"wool", 17}
+ tmpl, err := template.New("test").Parse("{{.Count}} items are made of {{.Material}}")
+ if err != nil { panic(err) }
+ err = tmpl.Execute(os.Stdout, sweaters)
+ if err != nil { panic(err) }
+
+More intricate examples appear below.
+
+Actions
+
+Here is the list of actions. "Arguments" and "pipelines" are evaluations of
+data, defined in detail below.
+
+*/
+// {{/* a comment */}}
+// A comment; discarded. May contain newlines.
+// Comments do not nest and must start and end at the
+// delimiters, as shown here.
+/*
+
+ {{pipeline}}
+ The default textual representation of the value of the pipeline
+ is copied to the output.
+
+ {{if pipeline}} T1 {{end}}
+ If the value of the pipeline is empty, no output is generated;
+ otherwise, T1 is executed. The empty values are false, 0, any
+ nil pointer or interface value, and any array, slice, map, or
+ string of length zero.
+ Dot is unaffected.
+
+ {{if pipeline}} T1 {{else}} T0 {{end}}
+ If the value of the pipeline is empty, T0 is executed;
+ otherwise, T1 is executed. Dot is unaffected.
+
+ {{if pipeline}} T1 {{else if pipeline}} T0 {{end}}
+ To simplify the appearance of if-else chains, the else action
+ of an if may include another if directly; the effect is exactly
+ the same as writing
+ {{if pipeline}} T1 {{else}}{{if pipeline}} T0 {{end}}{{end}}
+
+ {{range pipeline}} T1 {{end}}
+ The value of the pipeline must be an array, slice, map, or channel.
+ If the value of the pipeline has length zero, nothing is output;
+ otherwise, dot is set to the successive elements of the array,
+ slice, or map and T1 is executed. If the value is a map and the
+ keys are of basic type with a defined order ("comparable"), the
+ elements will be visited in sorted key order.
+
+ {{range pipeline}} T1 {{else}} T0 {{end}}
+ The value of the pipeline must be an array, slice, map, or channel.
+ If the value of the pipeline has length zero, dot is unaffected and
+ T0 is executed; otherwise, dot is set to the successive elements
+ of the array, slice, or map and T1 is executed.
+
+ {{template "name"}}
+ The template with the specified name is executed with nil data.
+
+ {{template "name" pipeline}}
+ The template with the specified name is executed with dot set
+ to the value of the pipeline.
+
+ {{with pipeline}} T1 {{end}}
+ If the value of the pipeline is empty, no output is generated;
+ otherwise, dot is set to the value of the pipeline and T1 is
+ executed.
+
+ {{with pipeline}} T1 {{else}} T0 {{end}}
+ If the value of the pipeline is empty, dot is unaffected and T0
+ is executed; otherwise, dot is set to the value of the pipeline
+ and T1 is executed.
+
+Arguments
+
+An argument is a simple value, denoted by one of the following.
+
+ - A boolean, string, character, integer, floating-point, imaginary
+ or complex constant in Go syntax. These behave like Go's untyped
+ constants, although raw strings may not span newlines.
+ - The keyword nil, representing an untyped Go nil.
+ - The character '.' (period):
+ .
+ The result is the value of dot.
+ - A variable name, which is a (possibly empty) alphanumeric string
+ preceded by a dollar sign, such as
+ $piOver2
+ or
+ $
+ The result is the value of the variable.
+ Variables are described below.
+ - The name of a field of the data, which must be a struct, preceded
+ by a period, such as
+ .Field
+ The result is the value of the field. Field invocations may be
+ chained:
+ .Field1.Field2
+ Fields can also be evaluated on variables, including chaining:
+ $x.Field1.Field2
+ - The name of a key of the data, which must be a map, preceded
+ by a period, such as
+ .Key
+ The result is the map element value indexed by the key.
+ Key invocations may be chained and combined with fields to any
+ depth:
+ .Field1.Key1.Field2.Key2
+ Although the key must be an alphanumeric identifier, unlike with
+ field names they do not need to start with an upper case letter.
+ Keys can also be evaluated on variables, including chaining:
+ $x.key1.key2
+ - The name of a niladic method of the data, preceded by a period,
+ such as
+ .Method
+ The result is the value of invoking the method with dot as the
+ receiver, dot.Method(). Such a method must have one return value (of
+ any type) or two return values, the second of which is an error.
+ If it has two and the returned error is non-nil, execution terminates
+ and an error is returned to the caller as the value of Execute.
+ Method invocations may be chained and combined with fields and keys
+ to any depth:
+ .Field1.Key1.Method1.Field2.Key2.Method2
+ Methods can also be evaluated on variables, including chaining:
+ $x.Method1.Field
+ - The name of a niladic function, such as
+ fun
+ The result is the value of invoking the function, fun(). The return
+ types and values behave as in methods. Functions and function
+ names are described below.
+ - A parenthesized instance of one the above, for grouping. The result
+ may be accessed by a field or map key invocation.
+ print (.F1 arg1) (.F2 arg2)
+ (.StructValuedMethod "arg").Field
+
+Arguments may evaluate to any type; if they are pointers the implementation
+automatically indirects to the base type when required.
+If an evaluation yields a function value, such as a function-valued
+field of a struct, the function is not invoked automatically, but it
+can be used as a truth value for an if action and the like. To invoke
+it, use the call function, defined below.
+
+A pipeline is a possibly chained sequence of "commands". A command is a simple
+value (argument) or a function or method call, possibly with multiple arguments:
+
+ Argument
+ The result is the value of evaluating the argument.
+ .Method [Argument...]
+ The method can be alone or the last element of a chain but,
+ unlike methods in the middle of a chain, it can take arguments.
+ The result is the value of calling the method with the
+ arguments:
+ dot.Method(Argument1, etc.)
+ functionName [Argument...]
+ The result is the value of calling the function associated
+ with the name:
+ function(Argument1, etc.)
+ Functions and function names are described below.
+
+Pipelines
+
+A pipeline may be "chained" by separating a sequence of commands with pipeline
+characters '|'. In a chained pipeline, the result of the each command is
+passed as the last argument of the following command. The output of the final
+command in the pipeline is the value of the pipeline.
+
+The output of a command will be either one value or two values, the second of
+which has type error. If that second value is present and evaluates to
+non-nil, execution terminates and the error is returned to the caller of
+Execute.
+
+Variables
+
+A pipeline inside an action may initialize a variable to capture the result.
+The initialization has syntax
+
+ $variable := pipeline
+
+where $variable is the name of the variable. An action that declares a
+variable produces no output.
+
+If a "range" action initializes a variable, the variable is set to the
+successive elements of the iteration. Also, a "range" may declare two
+variables, separated by a comma:
+
+ range $index, $element := pipeline
+
+in which case $index and $element are set to the successive values of the
+array/slice index or map key and element, respectively. Note that if there is
+only one variable, it is assigned the element; this is opposite to the
+convention in Go range clauses.
+
+A variable's scope extends to the "end" action of the control structure ("if",
+"with", or "range") in which it is declared, or to the end of the template if
+there is no such control structure. A template invocation does not inherit
+variables from the point of its invocation.
+
+When execution begins, $ is set to the data argument passed to Execute, that is,
+to the starting value of dot.
+
+Examples
+
+Here are some example one-line templates demonstrating pipelines and variables.
+All produce the quoted word "output":
+
+ {{"\"output\""}}
+ A string constant.
+ {{`"output"`}}
+ A raw string constant.
+ {{printf "%q" "output"}}
+ A function call.
+ {{"output" | printf "%q"}}
+ A function call whose final argument comes from the previous
+ command.
+ {{printf "%q" (print "out" "put")}}
+ A parenthesized argument.
+ {{"put" | printf "%s%s" "out" | printf "%q"}}
+ A more elaborate call.
+ {{"output" | printf "%s" | printf "%q"}}
+ A longer chain.
+ {{with "output"}}{{printf "%q" .}}{{end}}
+ A with action using dot.
+ {{with $x := "output" | printf "%q"}}{{$x}}{{end}}
+ A with action that creates and uses a variable.
+ {{with $x := "output"}}{{printf "%q" $x}}{{end}}
+ A with action that uses the variable in another action.
+ {{with $x := "output"}}{{$x | printf "%q"}}{{end}}
+ The same, but pipelined.
+
+Functions
+
+During execution functions are found in two function maps: first in the
+template, then in the global function map. By default, no functions are defined
+in the template but the Funcs method can be used to add them.
+
+Predefined global functions are named as follows.
+
+ and
+ Returns the boolean AND of its arguments by returning the
+ first empty argument or the last argument, that is,
+ "and x y" behaves as "if x then y else x". All the
+ arguments are evaluated.
+ call
+ Returns the result of calling the first argument, which
+ must be a function, with the remaining arguments as parameters.
+ Thus "call .X.Y 1 2" is, in Go notation, dot.X.Y(1, 2) where
+ Y is a func-valued field, map entry, or the like.
+ The first argument must be the result of an evaluation
+ that yields a value of function type (as distinct from
+ a predefined function such as print). The function must
+ return either one or two result values, the second of which
+ is of type error. If the arguments don't match the function
+ or the returned error value is non-nil, execution stops.
+ html
+ Returns the escaped HTML equivalent of the textual
+ representation of its arguments.
+ index
+ Returns the result of indexing its first argument by the
+ following arguments. Thus "index x 1 2 3" is, in Go syntax,
+ x[1][2][3]. Each indexed item must be a map, slice, or array.
+ js
+ Returns the escaped JavaScript equivalent of the textual
+ representation of its arguments.
+ len
+ Returns the integer length of its argument.
+ not
+ Returns the boolean negation of its single argument.
+ or
+ Returns the boolean OR of its arguments by returning the
+ first non-empty argument or the last argument, that is,
+ "or x y" behaves as "if x then x else y". All the
+ arguments are evaluated.
+ print
+ An alias for fmt.Sprint
+ printf
+ An alias for fmt.Sprintf
+ println
+ An alias for fmt.Sprintln
+ urlquery
+ Returns the escaped value of the textual representation of
+ its arguments in a form suitable for embedding in a URL query.
+
+The boolean functions take any zero value to be false and a non-zero
+value to be true.
+
+There is also a set of binary comparison operators defined as
+functions:
+
+ eq
+ Returns the boolean truth of arg1 == arg2
+ ne
+ Returns the boolean truth of arg1 != arg2
+ lt
+ Returns the boolean truth of arg1 < arg2
+ le
+ Returns the boolean truth of arg1 <= arg2
+ gt
+ Returns the boolean truth of arg1 > arg2
+ ge
+ Returns the boolean truth of arg1 >= arg2
+
+For simpler multi-way equality tests, eq (only) accepts two or more
+arguments and compares the second and subsequent to the first,
+returning in effect
+
+ arg1==arg2 || arg1==arg3 || arg1==arg4 ...
+
+(Unlike with || in Go, however, eq is a function call and all the
+arguments will be evaluated.)
+
+The comparison functions work on basic types only (or named basic
+types, such as "type Celsius float32"). They implement the Go rules
+for comparison of values, except that size and exact type are
+ignored, so any integer value, signed or unsigned, may be compared
+with any other integer value. (The arithmetic value is compared,
+not the bit pattern, so all negative integers are less than all
+unsigned integers.) However, as usual, one may not compare an int
+with a float32 and so on.
+
+Associated templates
+
+Each template is named by a string specified when it is created. Also, each
+template is associated with zero or more other templates that it may invoke by
+name; such associations are transitive and form a name space of templates.
+
+A template may use a template invocation to instantiate another associated
+template; see the explanation of the "template" action above. The name must be
+that of a template associated with the template that contains the invocation.
+
+Nested template definitions
+
+When parsing a template, another template may be defined and associated with the
+template being parsed. Template definitions must appear at the top level of the
+template, much like global variables in a Go program.
+
+The syntax of such definitions is to surround each template declaration with a
+"define" and "end" action.
+
+The define action names the template being created by providing a string
+constant. Here is a simple example:
+
+ `{{define "T1"}}ONE{{end}}
+ {{define "T2"}}TWO{{end}}
+ {{define "T3"}}{{template "T1"}} {{template "T2"}}{{end}}
+ {{template "T3"}}`
+
+This defines two templates, T1 and T2, and a third T3 that invokes the other two
+when it is executed. Finally it invokes T3. If executed this template will
+produce the text
+
+ ONE TWO
+
+By construction, a template may reside in only one association. If it's
+necessary to have a template addressable from multiple associations, the
+template definition must be parsed multiple times to create distinct *Template
+values, or must be copied with the Clone or AddParseTree method.
+
+Parse may be called multiple times to assemble the various associated templates;
+see the ParseFiles and ParseGlob functions and methods for simple ways to parse
+related templates stored in files.
+
+A template may be executed directly or through ExecuteTemplate, which executes
+an associated template identified by name. To invoke our example above, we
+might write,
+
+ err := tmpl.Execute(os.Stdout, "no data needed")
+ if err != nil {
+ log.Fatalf("execution failed: %s", err)
+ }
+
+or to invoke a particular template explicitly by name,
+
+ err := tmpl.ExecuteTemplate(os.Stdout, "T2", "no data needed")
+ if err != nil {
+ log.Fatalf("execution failed: %s", err)
+ }
+
+*/
+package template
diff --git a/vendor/github.com/alecthomas/template/exec.go b/vendor/github.com/alecthomas/template/exec.go
new file mode 100644
index 0000000..c3078e5
--- /dev/null
+++ b/vendor/github.com/alecthomas/template/exec.go
@@ -0,0 +1,845 @@
+// Copyright 2011 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package template
+
+import (
+ "bytes"
+ "fmt"
+ "io"
+ "reflect"
+ "runtime"
+ "sort"
+ "strings"
+
+ "github.com/alecthomas/template/parse"
+)
+
+// state represents the state of an execution. It's not part of the
+// template so that multiple executions of the same template
+// can execute in parallel.
+type state struct {
+ tmpl *Template
+ wr io.Writer
+ node parse.Node // current node, for errors
+ vars []variable // push-down stack of variable values.
+}
+
+// variable holds the dynamic value of a variable such as $, $x etc.
+type variable struct {
+ name string
+ value reflect.Value
+}
+
+// push pushes a new variable on the stack.
+func (s *state) push(name string, value reflect.Value) {
+ s.vars = append(s.vars, variable{name, value})
+}
+
+// mark returns the length of the variable stack.
+func (s *state) mark() int {
+ return len(s.vars)
+}
+
+// pop pops the variable stack up to the mark.
+func (s *state) pop(mark int) {
+ s.vars = s.vars[0:mark]
+}
+
+// setVar overwrites the top-nth variable on the stack. Used by range iterations.
+func (s *state) setVar(n int, value reflect.Value) {
+ s.vars[len(s.vars)-n].value = value
+}
+
+// varValue returns the value of the named variable.
+func (s *state) varValue(name string) reflect.Value {
+ for i := s.mark() - 1; i >= 0; i-- {
+ if s.vars[i].name == name {
+ return s.vars[i].value
+ }
+ }
+ s.errorf("undefined variable: %s", name)
+ return zero
+}
+
+var zero reflect.Value
+
+// at marks the state to be on node n, for error reporting.
+func (s *state) at(node parse.Node) {
+ s.node = node
+}
+
+// doublePercent returns the string with %'s replaced by %%, if necessary,
+// so it can be used safely inside a Printf format string.
+func doublePercent(str string) string {
+ if strings.Contains(str, "%") {
+ str = strings.Replace(str, "%", "%%", -1)
+ }
+ return str
+}
+
+// errorf formats the error and terminates processing.
+func (s *state) errorf(format string, args ...interface{}) {
+ name := doublePercent(s.tmpl.Name())
+ if s.node == nil {
+ format = fmt.Sprintf("template: %s: %s", name, format)
+ } else {
+ location, context := s.tmpl.ErrorContext(s.node)
+ format = fmt.Sprintf("template: %s: executing %q at <%s>: %s", location, name, doublePercent(context), format)
+ }
+ panic(fmt.Errorf(format, args...))
+}
+
+// errRecover is the handler that turns panics into returns from the top
+// level of Parse.
+func errRecover(errp *error) {
+ e := recover()
+ if e != nil {
+ switch err := e.(type) {
+ case runtime.Error:
+ panic(e)
+ case error:
+ *errp = err
+ default:
+ panic(e)
+ }
+ }
+}
+
+// ExecuteTemplate applies the template associated with t that has the given name
+// to the specified data object and writes the output to wr.
+// If an error occurs executing the template or writing its output,
+// execution stops, but partial results may already have been written to
+// the output writer.
+// A template may be executed safely in parallel.
+func (t *Template) ExecuteTemplate(wr io.Writer, name string, data interface{}) error {
+ tmpl := t.tmpl[name]
+ if tmpl == nil {
+ return fmt.Errorf("template: no template %q associated with template %q", name, t.name)
+ }
+ return tmpl.Execute(wr, data)
+}
+
+// Execute applies a parsed template to the specified data object,
+// and writes the output to wr.
+// If an error occurs executing the template or writing its output,
+// execution stops, but partial results may already have been written to
+// the output writer.
+// A template may be executed safely in parallel.
+func (t *Template) Execute(wr io.Writer, data interface{}) (err error) {
+ defer errRecover(&err)
+ value := reflect.ValueOf(data)
+ state := &state{
+ tmpl: t,
+ wr: wr,
+ vars: []variable{{"$", value}},
+ }
+ t.init()
+ if t.Tree == nil || t.Root == nil {
+ var b bytes.Buffer
+ for name, tmpl := range t.tmpl {
+ if tmpl.Tree == nil || tmpl.Root == nil {
+ continue
+ }
+ if b.Len() > 0 {
+ b.WriteString(", ")
+ }
+ fmt.Fprintf(&b, "%q", name)
+ }
+ var s string
+ if b.Len() > 0 {
+ s = "; defined templates are: " + b.String()
+ }
+ state.errorf("%q is an incomplete or empty template%s", t.Name(), s)
+ }
+ state.walk(value, t.Root)
+ return
+}
+
+// Walk functions step through the major pieces of the template structure,
+// generating output as they go.
+func (s *state) walk(dot reflect.Value, node parse.Node) {
+ s.at(node)
+ switch node := node.(type) {
+ case *parse.ActionNode:
+ // Do not pop variables so they persist until next end.
+ // Also, if the action declares variables, don't print the result.
+ val := s.evalPipeline(dot, node.Pipe)
+ if len(node.Pipe.Decl) == 0 {
+ s.printValue(node, val)
+ }
+ case *parse.IfNode:
+ s.walkIfOrWith(parse.NodeIf, dot, node.Pipe, node.List, node.ElseList)
+ case *parse.ListNode:
+ for _, node := range node.Nodes {
+ s.walk(dot, node)
+ }
+ case *parse.RangeNode:
+ s.walkRange(dot, node)
+ case *parse.TemplateNode:
+ s.walkTemplate(dot, node)
+ case *parse.TextNode:
+ if _, err := s.wr.Write(node.Text); err != nil {
+ s.errorf("%s", err)
+ }
+ case *parse.WithNode:
+ s.walkIfOrWith(parse.NodeWith, dot, node.Pipe, node.List, node.ElseList)
+ default:
+ s.errorf("unknown node: %s", node)
+ }
+}
+
+// walkIfOrWith walks an 'if' or 'with' node. The two control structures
+// are identical in behavior except that 'with' sets dot.
+func (s *state) walkIfOrWith(typ parse.NodeType, dot reflect.Value, pipe *parse.PipeNode, list, elseList *parse.ListNode) {
+ defer s.pop(s.mark())
+ val := s.evalPipeline(dot, pipe)
+ truth, ok := isTrue(val)
+ if !ok {
+ s.errorf("if/with can't use %v", val)
+ }
+ if truth {
+ if typ == parse.NodeWith {
+ s.walk(val, list)
+ } else {
+ s.walk(dot, list)
+ }
+ } else if elseList != nil {
+ s.walk(dot, elseList)
+ }
+}
+
+// isTrue reports whether the value is 'true', in the sense of not the zero of its type,
+// and whether the value has a meaningful truth value.
+func isTrue(val reflect.Value) (truth, ok bool) {
+ if !val.IsValid() {
+ // Something like var x interface{}, never set. It's a form of nil.
+ return false, true
+ }
+ switch val.Kind() {
+ case reflect.Array, reflect.Map, reflect.Slice, reflect.String:
+ truth = val.Len() > 0
+ case reflect.Bool:
+ truth = val.Bool()
+ case reflect.Complex64, reflect.Complex128:
+ truth = val.Complex() != 0
+ case reflect.Chan, reflect.Func, reflect.Ptr, reflect.Interface:
+ truth = !val.IsNil()
+ case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
+ truth = val.Int() != 0
+ case reflect.Float32, reflect.Float64:
+ truth = val.Float() != 0
+ case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr:
+ truth = val.Uint() != 0
+ case reflect.Struct:
+ truth = true // Struct values are always true.
+ default:
+ return
+ }
+ return truth, true
+}
+
+func (s *state) walkRange(dot reflect.Value, r *parse.RangeNode) {
+ s.at(r)
+ defer s.pop(s.mark())
+ val, _ := indirect(s.evalPipeline(dot, r.Pipe))
+ // mark top of stack before any variables in the body are pushed.
+ mark := s.mark()
+ oneIteration := func(index, elem reflect.Value) {
+ // Set top var (lexically the second if there are two) to the element.
+ if len(r.Pipe.Decl) > 0 {
+ s.setVar(1, elem)
+ }
+ // Set next var (lexically the first if there are two) to the index.
+ if len(r.Pipe.Decl) > 1 {
+ s.setVar(2, index)
+ }
+ s.walk(elem, r.List)
+ s.pop(mark)
+ }
+ switch val.Kind() {
+ case reflect.Array, reflect.Slice:
+ if val.Len() == 0 {
+ break
+ }
+ for i := 0; i < val.Len(); i++ {
+ oneIteration(reflect.ValueOf(i), val.Index(i))
+ }
+ return
+ case reflect.Map:
+ if val.Len() == 0 {
+ break
+ }
+ for _, key := range sortKeys(val.MapKeys()) {
+ oneIteration(key, val.MapIndex(key))
+ }
+ return
+ case reflect.Chan:
+ if val.IsNil() {
+ break
+ }
+ i := 0
+ for ; ; i++ {
+ elem, ok := val.Recv()
+ if !ok {
+ break
+ }
+ oneIteration(reflect.ValueOf(i), elem)
+ }
+ if i == 0 {
+ break
+ }
+ return
+ case reflect.Invalid:
+ break // An invalid value is likely a nil map, etc. and acts like an empty map.
+ default:
+ s.errorf("range can't iterate over %v", val)
+ }
+ if r.ElseList != nil {
+ s.walk(dot, r.ElseList)
+ }
+}
+
+func (s *state) walkTemplate(dot reflect.Value, t *parse.TemplateNode) {
+ s.at(t)
+ tmpl := s.tmpl.tmpl[t.Name]
+ if tmpl == nil {
+ s.errorf("template %q not defined", t.Name)
+ }
+ // Variables declared by the pipeline persist.
+ dot = s.evalPipeline(dot, t.Pipe)
+ newState := *s
+ newState.tmpl = tmpl
+ // No dynamic scoping: template invocations inherit no variables.
+ newState.vars = []variable{{"$", dot}}
+ newState.walk(dot, tmpl.Root)
+}
+
+// Eval functions evaluate pipelines, commands, and their elements and extract
+// values from the data structure by examining fields, calling methods, and so on.
+// The printing of those values happens only through walk functions.
+
+// evalPipeline returns the value acquired by evaluating a pipeline. If the
+// pipeline has a variable declaration, the variable will be pushed on the
+// stack. Callers should therefore pop the stack after they are finished
+// executing commands depending on the pipeline value.
+func (s *state) evalPipeline(dot reflect.Value, pipe *parse.PipeNode) (value reflect.Value) {
+ if pipe == nil {
+ return
+ }
+ s.at(pipe)
+ for _, cmd := range pipe.Cmds {
+ value = s.evalCommand(dot, cmd, value) // previous value is this one's final arg.
+ // If the object has type interface{}, dig down one level to the thing inside.
+ if value.Kind() == reflect.Interface && value.Type().NumMethod() == 0 {
+ value = reflect.ValueOf(value.Interface()) // lovely!
+ }
+ }
+ for _, variable := range pipe.Decl {
+ s.push(variable.Ident[0], value)
+ }
+ return value
+}
+
+func (s *state) notAFunction(args []parse.Node, final reflect.Value) {
+ if len(args) > 1 || final.IsValid() {
+ s.errorf("can't give argument to non-function %s", args[0])
+ }
+}
+
+func (s *state) evalCommand(dot reflect.Value, cmd *parse.CommandNode, final reflect.Value) reflect.Value {
+ firstWord := cmd.Args[0]
+ switch n := firstWord.(type) {
+ case *parse.FieldNode:
+ return s.evalFieldNode(dot, n, cmd.Args, final)
+ case *parse.ChainNode:
+ return s.evalChainNode(dot, n, cmd.Args, final)
+ case *parse.IdentifierNode:
+ // Must be a function.
+ return s.evalFunction(dot, n, cmd, cmd.Args, final)
+ case *parse.PipeNode:
+ // Parenthesized pipeline. The arguments are all inside the pipeline; final is ignored.
+ return s.evalPipeline(dot, n)
+ case *parse.VariableNode:
+ return s.evalVariableNode(dot, n, cmd.Args, final)
+ }
+ s.at(firstWord)
+ s.notAFunction(cmd.Args, final)
+ switch word := firstWord.(type) {
+ case *parse.BoolNode:
+ return reflect.ValueOf(word.True)
+ case *parse.DotNode:
+ return dot
+ case *parse.NilNode:
+ s.errorf("nil is not a command")
+ case *parse.NumberNode:
+ return s.idealConstant(word)
+ case *parse.StringNode:
+ return reflect.ValueOf(word.Text)
+ }
+ s.errorf("can't evaluate command %q", firstWord)
+ panic("not reached")
+}
+
+// idealConstant is called to return the value of a number in a context where
+// we don't know the type. In that case, the syntax of the number tells us
+// its type, and we use Go rules to resolve. Note there is no such thing as
+// a uint ideal constant in this situation - the value must be of int type.
+func (s *state) idealConstant(constant *parse.NumberNode) reflect.Value {
+ // These are ideal constants but we don't know the type
+ // and we have no context. (If it was a method argument,
+ // we'd know what we need.) The syntax guides us to some extent.
+ s.at(constant)
+ switch {
+ case constant.IsComplex:
+ return reflect.ValueOf(constant.Complex128) // incontrovertible.
+ case constant.IsFloat && !isHexConstant(constant.Text) && strings.IndexAny(constant.Text, ".eE") >= 0:
+ return reflect.ValueOf(constant.Float64)
+ case constant.IsInt:
+ n := int(constant.Int64)
+ if int64(n) != constant.Int64 {
+ s.errorf("%s overflows int", constant.Text)
+ }
+ return reflect.ValueOf(n)
+ case constant.IsUint:
+ s.errorf("%s overflows int", constant.Text)
+ }
+ return zero
+}
+
+func isHexConstant(s string) bool {
+ return len(s) > 2 && s[0] == '0' && (s[1] == 'x' || s[1] == 'X')
+}
+
+func (s *state) evalFieldNode(dot reflect.Value, field *parse.FieldNode, args []parse.Node, final reflect.Value) reflect.Value {
+ s.at(field)
+ return s.evalFieldChain(dot, dot, field, field.Ident, args, final)
+}
+
+func (s *state) evalChainNode(dot reflect.Value, chain *parse.ChainNode, args []parse.Node, final reflect.Value) reflect.Value {
+ s.at(chain)
+ // (pipe).Field1.Field2 has pipe as .Node, fields as .Field. Eval the pipeline, then the fields.
+ pipe := s.evalArg(dot, nil, chain.Node)
+ if len(chain.Field) == 0 {
+ s.errorf("internal error: no fields in evalChainNode")
+ }
+ return s.evalFieldChain(dot, pipe, chain, chain.Field, args, final)
+}
+
+func (s *state) evalVariableNode(dot reflect.Value, variable *parse.VariableNode, args []parse.Node, final reflect.Value) reflect.Value {
+ // $x.Field has $x as the first ident, Field as the second. Eval the var, then the fields.
+ s.at(variable)
+ value := s.varValue(variable.Ident[0])
+ if len(variable.Ident) == 1 {
+ s.notAFunction(args, final)
+ return value
+ }
+ return s.evalFieldChain(dot, value, variable, variable.Ident[1:], args, final)
+}
+
+// evalFieldChain evaluates .X.Y.Z possibly followed by arguments.
+// dot is the environment in which to evaluate arguments, while
+// receiver is the value being walked along the chain.
+func (s *state) evalFieldChain(dot, receiver reflect.Value, node parse.Node, ident []string, args []parse.Node, final reflect.Value) reflect.Value {
+ n := len(ident)
+ for i := 0; i < n-1; i++ {
+ receiver = s.evalField(dot, ident[i], node, nil, zero, receiver)
+ }
+ // Now if it's a method, it gets the arguments.
+ return s.evalField(dot, ident[n-1], node, args, final, receiver)
+}
+
+func (s *state) evalFunction(dot reflect.Value, node *parse.IdentifierNode, cmd parse.Node, args []parse.Node, final reflect.Value) reflect.Value {
+ s.at(node)
+ name := node.Ident
+ function, ok := findFunction(name, s.tmpl)
+ if !ok {
+ s.errorf("%q is not a defined function", name)
+ }
+ return s.evalCall(dot, function, cmd, name, args, final)
+}
+
+// evalField evaluates an expression like (.Field) or (.Field arg1 arg2).
+// The 'final' argument represents the return value from the preceding
+// value of the pipeline, if any.
+func (s *state) evalField(dot reflect.Value, fieldName string, node parse.Node, args []parse.Node, final, receiver reflect.Value) reflect.Value {
+ if !receiver.IsValid() {
+ return zero
+ }
+ typ := receiver.Type()
+ receiver, _ = indirect(receiver)
+ // Unless it's an interface, need to get to a value of type *T to guarantee
+ // we see all methods of T and *T.
+ ptr := receiver
+ if ptr.Kind() != reflect.Interface && ptr.CanAddr() {
+ ptr = ptr.Addr()
+ }
+ if method := ptr.MethodByName(fieldName); method.IsValid() {
+ return s.evalCall(dot, method, node, fieldName, args, final)
+ }
+ hasArgs := len(args) > 1 || final.IsValid()
+ // It's not a method; must be a field of a struct or an element of a map. The receiver must not be nil.
+ receiver, isNil := indirect(receiver)
+ if isNil {
+ s.errorf("nil pointer evaluating %s.%s", typ, fieldName)
+ }
+ switch receiver.Kind() {
+ case reflect.Struct:
+ tField, ok := receiver.Type().FieldByName(fieldName)
+ if ok {
+ field := receiver.FieldByIndex(tField.Index)
+ if tField.PkgPath != "" { // field is unexported
+ s.errorf("%s is an unexported field of struct type %s", fieldName, typ)
+ }
+ // If it's a function, we must call it.
+ if hasArgs {
+ s.errorf("%s has arguments but cannot be invoked as function", fieldName)
+ }
+ return field
+ }
+ s.errorf("%s is not a field of struct type %s", fieldName, typ)
+ case reflect.Map:
+ // If it's a map, attempt to use the field name as a key.
+ nameVal := reflect.ValueOf(fieldName)
+ if nameVal.Type().AssignableTo(receiver.Type().Key()) {
+ if hasArgs {
+ s.errorf("%s is not a method but has arguments", fieldName)
+ }
+ return receiver.MapIndex(nameVal)
+ }
+ }
+ s.errorf("can't evaluate field %s in type %s", fieldName, typ)
+ panic("not reached")
+}
+
+var (
+ errorType = reflect.TypeOf((*error)(nil)).Elem()
+ fmtStringerType = reflect.TypeOf((*fmt.Stringer)(nil)).Elem()
+)
+
+// evalCall executes a function or method call. If it's a method, fun already has the receiver bound, so
+// it looks just like a function call. The arg list, if non-nil, includes (in the manner of the shell), arg[0]
+// as the function itself.
+func (s *state) evalCall(dot, fun reflect.Value, node parse.Node, name string, args []parse.Node, final reflect.Value) reflect.Value {
+ if args != nil {
+ args = args[1:] // Zeroth arg is function name/node; not passed to function.
+ }
+ typ := fun.Type()
+ numIn := len(args)
+ if final.IsValid() {
+ numIn++
+ }
+ numFixed := len(args)
+ if typ.IsVariadic() {
+ numFixed = typ.NumIn() - 1 // last arg is the variadic one.
+ if numIn < numFixed {
+ s.errorf("wrong number of args for %s: want at least %d got %d", name, typ.NumIn()-1, len(args))
+ }
+ } else if numIn < typ.NumIn()-1 || !typ.IsVariadic() && numIn != typ.NumIn() {
+ s.errorf("wrong number of args for %s: want %d got %d", name, typ.NumIn(), len(args))
+ }
+ if !goodFunc(typ) {
+ // TODO: This could still be a confusing error; maybe goodFunc should provide info.
+ s.errorf("can't call method/function %q with %d results", name, typ.NumOut())
+ }
+ // Build the arg list.
+ argv := make([]reflect.Value, numIn)
+ // Args must be evaluated. Fixed args first.
+ i := 0
+ for ; i < numFixed && i < len(args); i++ {
+ argv[i] = s.evalArg(dot, typ.In(i), args[i])
+ }
+ // Now the ... args.
+ if typ.IsVariadic() {
+ argType := typ.In(typ.NumIn() - 1).Elem() // Argument is a slice.
+ for ; i < len(args); i++ {
+ argv[i] = s.evalArg(dot, argType, args[i])
+ }
+ }
+ // Add final value if necessary.
+ if final.IsValid() {
+ t := typ.In(typ.NumIn() - 1)
+ if typ.IsVariadic() {
+ t = t.Elem()
+ }
+ argv[i] = s.validateType(final, t)
+ }
+ result := fun.Call(argv)
+ // If we have an error that is not nil, stop execution and return that error to the caller.
+ if len(result) == 2 && !result[1].IsNil() {
+ s.at(node)
+ s.errorf("error calling %s: %s", name, result[1].Interface().(error))
+ }
+ return result[0]
+}
+
+// canBeNil reports whether an untyped nil can be assigned to the type. See reflect.Zero.
+func canBeNil(typ reflect.Type) bool {
+ switch typ.Kind() {
+ case reflect.Chan, reflect.Func, reflect.Interface, reflect.Map, reflect.Ptr, reflect.Slice:
+ return true
+ }
+ return false
+}
+
+// validateType guarantees that the value is valid and assignable to the type.
+func (s *state) validateType(value reflect.Value, typ reflect.Type) reflect.Value {
+ if !value.IsValid() {
+ if typ == nil || canBeNil(typ) {
+ // An untyped nil interface{}. Accept as a proper nil value.
+ return reflect.Zero(typ)
+ }
+ s.errorf("invalid value; expected %s", typ)
+ }
+ if typ != nil && !value.Type().AssignableTo(typ) {
+ if value.Kind() == reflect.Interface && !value.IsNil() {
+ value = value.Elem()
+ if value.Type().AssignableTo(typ) {
+ return value
+ }
+ // fallthrough
+ }
+ // Does one dereference or indirection work? We could do more, as we
+ // do with method receivers, but that gets messy and method receivers
+ // are much more constrained, so it makes more sense there than here.
+ // Besides, one is almost always all you need.
+ switch {
+ case value.Kind() == reflect.Ptr && value.Type().Elem().AssignableTo(typ):
+ value = value.Elem()
+ if !value.IsValid() {
+ s.errorf("dereference of nil pointer of type %s", typ)
+ }
+ case reflect.PtrTo(value.Type()).AssignableTo(typ) && value.CanAddr():
+ value = value.Addr()
+ default:
+ s.errorf("wrong type for value; expected %s; got %s", typ, value.Type())
+ }
+ }
+ return value
+}
+
+func (s *state) evalArg(dot reflect.Value, typ reflect.Type, n parse.Node) reflect.Value {
+ s.at(n)
+ switch arg := n.(type) {
+ case *parse.DotNode:
+ return s.validateType(dot, typ)
+ case *parse.NilNode:
+ if canBeNil(typ) {
+ return reflect.Zero(typ)
+ }
+ s.errorf("cannot assign nil to %s", typ)
+ case *parse.FieldNode:
+ return s.validateType(s.evalFieldNode(dot, arg, []parse.Node{n}, zero), typ)
+ case *parse.VariableNode:
+ return s.validateType(s.evalVariableNode(dot, arg, nil, zero), typ)
+ case *parse.PipeNode:
+ return s.validateType(s.evalPipeline(dot, arg), typ)
+ case *parse.IdentifierNode:
+ return s.evalFunction(dot, arg, arg, nil, zero)
+ case *parse.ChainNode:
+ return s.validateType(s.evalChainNode(dot, arg, nil, zero), typ)
+ }
+ switch typ.Kind() {
+ case reflect.Bool:
+ return s.evalBool(typ, n)
+ case reflect.Complex64, reflect.Complex128:
+ return s.evalComplex(typ, n)
+ case reflect.Float32, reflect.Float64:
+ return s.evalFloat(typ, n)
+ case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
+ return s.evalInteger(typ, n)
+ case reflect.Interface:
+ if typ.NumMethod() == 0 {
+ return s.evalEmptyInterface(dot, n)
+ }
+ case reflect.String:
+ return s.evalString(typ, n)
+ case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr:
+ return s.evalUnsignedInteger(typ, n)
+ }
+ s.errorf("can't handle %s for arg of type %s", n, typ)
+ panic("not reached")
+}
+
+func (s *state) evalBool(typ reflect.Type, n parse.Node) reflect.Value {
+ s.at(n)
+ if n, ok := n.(*parse.BoolNode); ok {
+ value := reflect.New(typ).Elem()
+ value.SetBool(n.True)
+ return value
+ }
+ s.errorf("expected bool; found %s", n)
+ panic("not reached")
+}
+
+func (s *state) evalString(typ reflect.Type, n parse.Node) reflect.Value {
+ s.at(n)
+ if n, ok := n.(*parse.StringNode); ok {
+ value := reflect.New(typ).Elem()
+ value.SetString(n.Text)
+ return value
+ }
+ s.errorf("expected string; found %s", n)
+ panic("not reached")
+}
+
+func (s *state) evalInteger(typ reflect.Type, n parse.Node) reflect.Value {
+ s.at(n)
+ if n, ok := n.(*parse.NumberNode); ok && n.IsInt {
+ value := reflect.New(typ).Elem()
+ value.SetInt(n.Int64)
+ return value
+ }
+ s.errorf("expected integer; found %s", n)
+ panic("not reached")
+}
+
+func (s *state) evalUnsignedInteger(typ reflect.Type, n parse.Node) reflect.Value {
+ s.at(n)
+ if n, ok := n.(*parse.NumberNode); ok && n.IsUint {
+ value := reflect.New(typ).Elem()
+ value.SetUint(n.Uint64)
+ return value
+ }
+ s.errorf("expected unsigned integer; found %s", n)
+ panic("not reached")
+}
+
+func (s *state) evalFloat(typ reflect.Type, n parse.Node) reflect.Value {
+ s.at(n)
+ if n, ok := n.(*parse.NumberNode); ok && n.IsFloat {
+ value := reflect.New(typ).Elem()
+ value.SetFloat(n.Float64)
+ return value
+ }
+ s.errorf("expected float; found %s", n)
+ panic("not reached")
+}
+
+func (s *state) evalComplex(typ reflect.Type, n parse.Node) reflect.Value {
+ if n, ok := n.(*parse.NumberNode); ok && n.IsComplex {
+ value := reflect.New(typ).Elem()
+ value.SetComplex(n.Complex128)
+ return value
+ }
+ s.errorf("expected complex; found %s", n)
+ panic("not reached")
+}
+
+func (s *state) evalEmptyInterface(dot reflect.Value, n parse.Node) reflect.Value {
+ s.at(n)
+ switch n := n.(type) {
+ case *parse.BoolNode:
+ return reflect.ValueOf(n.True)
+ case *parse.DotNode:
+ return dot
+ case *parse.FieldNode:
+ return s.evalFieldNode(dot, n, nil, zero)
+ case *parse.IdentifierNode:
+ return s.evalFunction(dot, n, n, nil, zero)
+ case *parse.NilNode:
+ // NilNode is handled in evalArg, the only place that calls here.
+ s.errorf("evalEmptyInterface: nil (can't happen)")
+ case *parse.NumberNode:
+ return s.idealConstant(n)
+ case *parse.StringNode:
+ return reflect.ValueOf(n.Text)
+ case *parse.VariableNode:
+ return s.evalVariableNode(dot, n, nil, zero)
+ case *parse.PipeNode:
+ return s.evalPipeline(dot, n)
+ }
+ s.errorf("can't handle assignment of %s to empty interface argument", n)
+ panic("not reached")
+}
+
+// indirect returns the item at the end of indirection, and a bool to indicate if it's nil.
+// We indirect through pointers and empty interfaces (only) because
+// non-empty interfaces have methods we might need.
+func indirect(v reflect.Value) (rv reflect.Value, isNil bool) {
+ for ; v.Kind() == reflect.Ptr || v.Kind() == reflect.Interface; v = v.Elem() {
+ if v.IsNil() {
+ return v, true
+ }
+ if v.Kind() == reflect.Interface && v.NumMethod() > 0 {
+ break
+ }
+ }
+ return v, false
+}
+
+// printValue writes the textual representation of the value to the output of
+// the template.
+func (s *state) printValue(n parse.Node, v reflect.Value) {
+ s.at(n)
+ iface, ok := printableValue(v)
+ if !ok {
+ s.errorf("can't print %s of type %s", n, v.Type())
+ }
+ fmt.Fprint(s.wr, iface)
+}
+
+// printableValue returns the, possibly indirected, interface value inside v that
+// is best for a call to formatted printer.
+func printableValue(v reflect.Value) (interface{}, bool) {
+ if v.Kind() == reflect.Ptr {
+ v, _ = indirect(v) // fmt.Fprint handles nil.
+ }
+ if !v.IsValid() {
+ return "", true
+ }
+
+ if !v.Type().Implements(errorType) && !v.Type().Implements(fmtStringerType) {
+ if v.CanAddr() && (reflect.PtrTo(v.Type()).Implements(errorType) || reflect.PtrTo(v.Type()).Implements(fmtStringerType)) {
+ v = v.Addr()
+ } else {
+ switch v.Kind() {
+ case reflect.Chan, reflect.Func:
+ return nil, false
+ }
+ }
+ }
+ return v.Interface(), true
+}
+
+// Types to help sort the keys in a map for reproducible output.
+
+type rvs []reflect.Value
+
+func (x rvs) Len() int { return len(x) }
+func (x rvs) Swap(i, j int) { x[i], x[j] = x[j], x[i] }
+
+type rvInts struct{ rvs }
+
+func (x rvInts) Less(i, j int) bool { return x.rvs[i].Int() < x.rvs[j].Int() }
+
+type rvUints struct{ rvs }
+
+func (x rvUints) Less(i, j int) bool { return x.rvs[i].Uint() < x.rvs[j].Uint() }
+
+type rvFloats struct{ rvs }
+
+func (x rvFloats) Less(i, j int) bool { return x.rvs[i].Float() < x.rvs[j].Float() }
+
+type rvStrings struct{ rvs }
+
+func (x rvStrings) Less(i, j int) bool { return x.rvs[i].String() < x.rvs[j].String() }
+
+// sortKeys sorts (if it can) the slice of reflect.Values, which is a slice of map keys.
+func sortKeys(v []reflect.Value) []reflect.Value {
+ if len(v) <= 1 {
+ return v
+ }
+ switch v[0].Kind() {
+ case reflect.Float32, reflect.Float64:
+ sort.Sort(rvFloats{v})
+ case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
+ sort.Sort(rvInts{v})
+ case reflect.String:
+ sort.Sort(rvStrings{v})
+ case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr:
+ sort.Sort(rvUints{v})
+ }
+ return v
+}
diff --git a/vendor/github.com/alecthomas/template/funcs.go b/vendor/github.com/alecthomas/template/funcs.go
new file mode 100644
index 0000000..39ee5ed
--- /dev/null
+++ b/vendor/github.com/alecthomas/template/funcs.go
@@ -0,0 +1,598 @@
+// Copyright 2011 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package template
+
+import (
+ "bytes"
+ "errors"
+ "fmt"
+ "io"
+ "net/url"
+ "reflect"
+ "strings"
+ "unicode"
+ "unicode/utf8"
+)
+
+// FuncMap is the type of the map defining the mapping from names to functions.
+// Each function must have either a single return value, or two return values of
+// which the second has type error. In that case, if the second (error)
+// return value evaluates to non-nil during execution, execution terminates and
+// Execute returns that error.
+type FuncMap map[string]interface{}
+
+var builtins = FuncMap{
+ "and": and,
+ "call": call,
+ "html": HTMLEscaper,
+ "index": index,
+ "js": JSEscaper,
+ "len": length,
+ "not": not,
+ "or": or,
+ "print": fmt.Sprint,
+ "printf": fmt.Sprintf,
+ "println": fmt.Sprintln,
+ "urlquery": URLQueryEscaper,
+
+ // Comparisons
+ "eq": eq, // ==
+ "ge": ge, // >=
+ "gt": gt, // >
+ "le": le, // <=
+ "lt": lt, // <
+ "ne": ne, // !=
+}
+
+var builtinFuncs = createValueFuncs(builtins)
+
+// createValueFuncs turns a FuncMap into a map[string]reflect.Value
+func createValueFuncs(funcMap FuncMap) map[string]reflect.Value {
+ m := make(map[string]reflect.Value)
+ addValueFuncs(m, funcMap)
+ return m
+}
+
+// addValueFuncs adds to values the functions in funcs, converting them to reflect.Values.
+func addValueFuncs(out map[string]reflect.Value, in FuncMap) {
+ for name, fn := range in {
+ v := reflect.ValueOf(fn)
+ if v.Kind() != reflect.Func {
+ panic("value for " + name + " not a function")
+ }
+ if !goodFunc(v.Type()) {
+ panic(fmt.Errorf("can't install method/function %q with %d results", name, v.Type().NumOut()))
+ }
+ out[name] = v
+ }
+}
+
+// addFuncs adds to values the functions in funcs. It does no checking of the input -
+// call addValueFuncs first.
+func addFuncs(out, in FuncMap) {
+ for name, fn := range in {
+ out[name] = fn
+ }
+}
+
+// goodFunc checks that the function or method has the right result signature.
+func goodFunc(typ reflect.Type) bool {
+ // We allow functions with 1 result or 2 results where the second is an error.
+ switch {
+ case typ.NumOut() == 1:
+ return true
+ case typ.NumOut() == 2 && typ.Out(1) == errorType:
+ return true
+ }
+ return false
+}
+
+// findFunction looks for a function in the template, and global map.
+func findFunction(name string, tmpl *Template) (reflect.Value, bool) {
+ if tmpl != nil && tmpl.common != nil {
+ if fn := tmpl.execFuncs[name]; fn.IsValid() {
+ return fn, true
+ }
+ }
+ if fn := builtinFuncs[name]; fn.IsValid() {
+ return fn, true
+ }
+ return reflect.Value{}, false
+}
+
+// Indexing.
+
+// index returns the result of indexing its first argument by the following
+// arguments. Thus "index x 1 2 3" is, in Go syntax, x[1][2][3]. Each
+// indexed item must be a map, slice, or array.
+func index(item interface{}, indices ...interface{}) (interface{}, error) {
+ v := reflect.ValueOf(item)
+ for _, i := range indices {
+ index := reflect.ValueOf(i)
+ var isNil bool
+ if v, isNil = indirect(v); isNil {
+ return nil, fmt.Errorf("index of nil pointer")
+ }
+ switch v.Kind() {
+ case reflect.Array, reflect.Slice, reflect.String:
+ var x int64
+ switch index.Kind() {
+ case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
+ x = index.Int()
+ case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr:
+ x = int64(index.Uint())
+ default:
+ return nil, fmt.Errorf("cannot index slice/array with type %s", index.Type())
+ }
+ if x < 0 || x >= int64(v.Len()) {
+ return nil, fmt.Errorf("index out of range: %d", x)
+ }
+ v = v.Index(int(x))
+ case reflect.Map:
+ if !index.IsValid() {
+ index = reflect.Zero(v.Type().Key())
+ }
+ if !index.Type().AssignableTo(v.Type().Key()) {
+ return nil, fmt.Errorf("%s is not index type for %s", index.Type(), v.Type())
+ }
+ if x := v.MapIndex(index); x.IsValid() {
+ v = x
+ } else {
+ v = reflect.Zero(v.Type().Elem())
+ }
+ default:
+ return nil, fmt.Errorf("can't index item of type %s", v.Type())
+ }
+ }
+ return v.Interface(), nil
+}
+
+// Length
+
+// length returns the length of the item, with an error if it has no defined length.
+func length(item interface{}) (int, error) {
+ v, isNil := indirect(reflect.ValueOf(item))
+ if isNil {
+ return 0, fmt.Errorf("len of nil pointer")
+ }
+ switch v.Kind() {
+ case reflect.Array, reflect.Chan, reflect.Map, reflect.Slice, reflect.String:
+ return v.Len(), nil
+ }
+ return 0, fmt.Errorf("len of type %s", v.Type())
+}
+
+// Function invocation
+
+// call returns the result of evaluating the first argument as a function.
+// The function must return 1 result, or 2 results, the second of which is an error.
+func call(fn interface{}, args ...interface{}) (interface{}, error) {
+ v := reflect.ValueOf(fn)
+ typ := v.Type()
+ if typ.Kind() != reflect.Func {
+ return nil, fmt.Errorf("non-function of type %s", typ)
+ }
+ if !goodFunc(typ) {
+ return nil, fmt.Errorf("function called with %d args; should be 1 or 2", typ.NumOut())
+ }
+ numIn := typ.NumIn()
+ var dddType reflect.Type
+ if typ.IsVariadic() {
+ if len(args) < numIn-1 {
+ return nil, fmt.Errorf("wrong number of args: got %d want at least %d", len(args), numIn-1)
+ }
+ dddType = typ.In(numIn - 1).Elem()
+ } else {
+ if len(args) != numIn {
+ return nil, fmt.Errorf("wrong number of args: got %d want %d", len(args), numIn)
+ }
+ }
+ argv := make([]reflect.Value, len(args))
+ for i, arg := range args {
+ value := reflect.ValueOf(arg)
+ // Compute the expected type. Clumsy because of variadics.
+ var argType reflect.Type
+ if !typ.IsVariadic() || i < numIn-1 {
+ argType = typ.In(i)
+ } else {
+ argType = dddType
+ }
+ if !value.IsValid() && canBeNil(argType) {
+ value = reflect.Zero(argType)
+ }
+ if !value.Type().AssignableTo(argType) {
+ return nil, fmt.Errorf("arg %d has type %s; should be %s", i, value.Type(), argType)
+ }
+ argv[i] = value
+ }
+ result := v.Call(argv)
+ if len(result) == 2 && !result[1].IsNil() {
+ return result[0].Interface(), result[1].Interface().(error)
+ }
+ return result[0].Interface(), nil
+}
+
+// Boolean logic.
+
+func truth(a interface{}) bool {
+ t, _ := isTrue(reflect.ValueOf(a))
+ return t
+}
+
+// and computes the Boolean AND of its arguments, returning
+// the first false argument it encounters, or the last argument.
+func and(arg0 interface{}, args ...interface{}) interface{} {
+ if !truth(arg0) {
+ return arg0
+ }
+ for i := range args {
+ arg0 = args[i]
+ if !truth(arg0) {
+ break
+ }
+ }
+ return arg0
+}
+
+// or computes the Boolean OR of its arguments, returning
+// the first true argument it encounters, or the last argument.
+func or(arg0 interface{}, args ...interface{}) interface{} {
+ if truth(arg0) {
+ return arg0
+ }
+ for i := range args {
+ arg0 = args[i]
+ if truth(arg0) {
+ break
+ }
+ }
+ return arg0
+}
+
+// not returns the Boolean negation of its argument.
+func not(arg interface{}) (truth bool) {
+ truth, _ = isTrue(reflect.ValueOf(arg))
+ return !truth
+}
+
+// Comparison.
+
+// TODO: Perhaps allow comparison between signed and unsigned integers.
+
+var (
+ errBadComparisonType = errors.New("invalid type for comparison")
+ errBadComparison = errors.New("incompatible types for comparison")
+ errNoComparison = errors.New("missing argument for comparison")
+)
+
+type kind int
+
+const (
+ invalidKind kind = iota
+ boolKind
+ complexKind
+ intKind
+ floatKind
+ integerKind
+ stringKind
+ uintKind
+)
+
+func basicKind(v reflect.Value) (kind, error) {
+ switch v.Kind() {
+ case reflect.Bool:
+ return boolKind, nil
+ case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
+ return intKind, nil
+ case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr:
+ return uintKind, nil
+ case reflect.Float32, reflect.Float64:
+ return floatKind, nil
+ case reflect.Complex64, reflect.Complex128:
+ return complexKind, nil
+ case reflect.String:
+ return stringKind, nil
+ }
+ return invalidKind, errBadComparisonType
+}
+
+// eq evaluates the comparison a == b || a == c || ...
+func eq(arg1 interface{}, arg2 ...interface{}) (bool, error) {
+ v1 := reflect.ValueOf(arg1)
+ k1, err := basicKind(v1)
+ if err != nil {
+ return false, err
+ }
+ if len(arg2) == 0 {
+ return false, errNoComparison
+ }
+ for _, arg := range arg2 {
+ v2 := reflect.ValueOf(arg)
+ k2, err := basicKind(v2)
+ if err != nil {
+ return false, err
+ }
+ truth := false
+ if k1 != k2 {
+ // Special case: Can compare integer values regardless of type's sign.
+ switch {
+ case k1 == intKind && k2 == uintKind:
+ truth = v1.Int() >= 0 && uint64(v1.Int()) == v2.Uint()
+ case k1 == uintKind && k2 == intKind:
+ truth = v2.Int() >= 0 && v1.Uint() == uint64(v2.Int())
+ default:
+ return false, errBadComparison
+ }
+ } else {
+ switch k1 {
+ case boolKind:
+ truth = v1.Bool() == v2.Bool()
+ case complexKind:
+ truth = v1.Complex() == v2.Complex()
+ case floatKind:
+ truth = v1.Float() == v2.Float()
+ case intKind:
+ truth = v1.Int() == v2.Int()
+ case stringKind:
+ truth = v1.String() == v2.String()
+ case uintKind:
+ truth = v1.Uint() == v2.Uint()
+ default:
+ panic("invalid kind")
+ }
+ }
+ if truth {
+ return true, nil
+ }
+ }
+ return false, nil
+}
+
+// ne evaluates the comparison a != b.
+func ne(arg1, arg2 interface{}) (bool, error) {
+ // != is the inverse of ==.
+ equal, err := eq(arg1, arg2)
+ return !equal, err
+}
+
+// lt evaluates the comparison a < b.
+func lt(arg1, arg2 interface{}) (bool, error) {
+ v1 := reflect.ValueOf(arg1)
+ k1, err := basicKind(v1)
+ if err != nil {
+ return false, err
+ }
+ v2 := reflect.ValueOf(arg2)
+ k2, err := basicKind(v2)
+ if err != nil {
+ return false, err
+ }
+ truth := false
+ if k1 != k2 {
+ // Special case: Can compare integer values regardless of type's sign.
+ switch {
+ case k1 == intKind && k2 == uintKind:
+ truth = v1.Int() < 0 || uint64(v1.Int()) < v2.Uint()
+ case k1 == uintKind && k2 == intKind:
+ truth = v2.Int() >= 0 && v1.Uint() < uint64(v2.Int())
+ default:
+ return false, errBadComparison
+ }
+ } else {
+ switch k1 {
+ case boolKind, complexKind:
+ return false, errBadComparisonType
+ case floatKind:
+ truth = v1.Float() < v2.Float()
+ case intKind:
+ truth = v1.Int() < v2.Int()
+ case stringKind:
+ truth = v1.String() < v2.String()
+ case uintKind:
+ truth = v1.Uint() < v2.Uint()
+ default:
+ panic("invalid kind")
+ }
+ }
+ return truth, nil
+}
+
+// le evaluates the comparison <= b.
+func le(arg1, arg2 interface{}) (bool, error) {
+ // <= is < or ==.
+ lessThan, err := lt(arg1, arg2)
+ if lessThan || err != nil {
+ return lessThan, err
+ }
+ return eq(arg1, arg2)
+}
+
+// gt evaluates the comparison a > b.
+func gt(arg1, arg2 interface{}) (bool, error) {
+ // > is the inverse of <=.
+ lessOrEqual, err := le(arg1, arg2)
+ if err != nil {
+ return false, err
+ }
+ return !lessOrEqual, nil
+}
+
+// ge evaluates the comparison a >= b.
+func ge(arg1, arg2 interface{}) (bool, error) {
+ // >= is the inverse of <.
+ lessThan, err := lt(arg1, arg2)
+ if err != nil {
+ return false, err
+ }
+ return !lessThan, nil
+}
+
+// HTML escaping.
+
+var (
+ htmlQuot = []byte(""") // shorter than """
+ htmlApos = []byte("'") // shorter than "'" and apos was not in HTML until HTML5
+ htmlAmp = []byte("&")
+ htmlLt = []byte("<")
+ htmlGt = []byte(">")
+)
+
+// HTMLEscape writes to w the escaped HTML equivalent of the plain text data b.
+func HTMLEscape(w io.Writer, b []byte) {
+ last := 0
+ for i, c := range b {
+ var html []byte
+ switch c {
+ case '"':
+ html = htmlQuot
+ case '\'':
+ html = htmlApos
+ case '&':
+ html = htmlAmp
+ case '<':
+ html = htmlLt
+ case '>':
+ html = htmlGt
+ default:
+ continue
+ }
+ w.Write(b[last:i])
+ w.Write(html)
+ last = i + 1
+ }
+ w.Write(b[last:])
+}
+
+// HTMLEscapeString returns the escaped HTML equivalent of the plain text data s.
+func HTMLEscapeString(s string) string {
+ // Avoid allocation if we can.
+ if strings.IndexAny(s, `'"&<>`) < 0 {
+ return s
+ }
+ var b bytes.Buffer
+ HTMLEscape(&b, []byte(s))
+ return b.String()
+}
+
+// HTMLEscaper returns the escaped HTML equivalent of the textual
+// representation of its arguments.
+func HTMLEscaper(args ...interface{}) string {
+ return HTMLEscapeString(evalArgs(args))
+}
+
+// JavaScript escaping.
+
+var (
+ jsLowUni = []byte(`\u00`)
+ hex = []byte("0123456789ABCDEF")
+
+ jsBackslash = []byte(`\\`)
+ jsApos = []byte(`\'`)
+ jsQuot = []byte(`\"`)
+ jsLt = []byte(`\x3C`)
+ jsGt = []byte(`\x3E`)
+)
+
+// JSEscape writes to w the escaped JavaScript equivalent of the plain text data b.
+func JSEscape(w io.Writer, b []byte) {
+ last := 0
+ for i := 0; i < len(b); i++ {
+ c := b[i]
+
+ if !jsIsSpecial(rune(c)) {
+ // fast path: nothing to do
+ continue
+ }
+ w.Write(b[last:i])
+
+ if c < utf8.RuneSelf {
+ // Quotes, slashes and angle brackets get quoted.
+ // Control characters get written as \u00XX.
+ switch c {
+ case '\\':
+ w.Write(jsBackslash)
+ case '\'':
+ w.Write(jsApos)
+ case '"':
+ w.Write(jsQuot)
+ case '<':
+ w.Write(jsLt)
+ case '>':
+ w.Write(jsGt)
+ default:
+ w.Write(jsLowUni)
+ t, b := c>>4, c&0x0f
+ w.Write(hex[t : t+1])
+ w.Write(hex[b : b+1])
+ }
+ } else {
+ // Unicode rune.
+ r, size := utf8.DecodeRune(b[i:])
+ if unicode.IsPrint(r) {
+ w.Write(b[i : i+size])
+ } else {
+ fmt.Fprintf(w, "\\u%04X", r)
+ }
+ i += size - 1
+ }
+ last = i + 1
+ }
+ w.Write(b[last:])
+}
+
+// JSEscapeString returns the escaped JavaScript equivalent of the plain text data s.
+func JSEscapeString(s string) string {
+ // Avoid allocation if we can.
+ if strings.IndexFunc(s, jsIsSpecial) < 0 {
+ return s
+ }
+ var b bytes.Buffer
+ JSEscape(&b, []byte(s))
+ return b.String()
+}
+
+func jsIsSpecial(r rune) bool {
+ switch r {
+ case '\\', '\'', '"', '<', '>':
+ return true
+ }
+ return r < ' ' || utf8.RuneSelf <= r
+}
+
+// JSEscaper returns the escaped JavaScript equivalent of the textual
+// representation of its arguments.
+func JSEscaper(args ...interface{}) string {
+ return JSEscapeString(evalArgs(args))
+}
+
+// URLQueryEscaper returns the escaped value of the textual representation of
+// its arguments in a form suitable for embedding in a URL query.
+func URLQueryEscaper(args ...interface{}) string {
+ return url.QueryEscape(evalArgs(args))
+}
+
+// evalArgs formats the list of arguments into a string. It is therefore equivalent to
+// fmt.Sprint(args...)
+// except that each argument is indirected (if a pointer), as required,
+// using the same rules as the default string evaluation during template
+// execution.
+func evalArgs(args []interface{}) string {
+ ok := false
+ var s string
+ // Fast path for simple common case.
+ if len(args) == 1 {
+ s, ok = args[0].(string)
+ }
+ if !ok {
+ for i, arg := range args {
+ a, ok := printableValue(reflect.ValueOf(arg))
+ if ok {
+ args[i] = a
+ } // else left fmt do its thing
+ }
+ s = fmt.Sprint(args...)
+ }
+ return s
+}
diff --git a/vendor/github.com/alecthomas/template/helper.go b/vendor/github.com/alecthomas/template/helper.go
new file mode 100644
index 0000000..3636fb5
--- /dev/null
+++ b/vendor/github.com/alecthomas/template/helper.go
@@ -0,0 +1,108 @@
+// Copyright 2011 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// Helper functions to make constructing templates easier.
+
+package template
+
+import (
+ "fmt"
+ "io/ioutil"
+ "path/filepath"
+)
+
+// Functions and methods to parse templates.
+
+// Must is a helper that wraps a call to a function returning (*Template, error)
+// and panics if the error is non-nil. It is intended for use in variable
+// initializations such as
+// var t = template.Must(template.New("name").Parse("text"))
+func Must(t *Template, err error) *Template {
+ if err != nil {
+ panic(err)
+ }
+ return t
+}
+
+// ParseFiles creates a new Template and parses the template definitions from
+// the named files. The returned template's name will have the (base) name and
+// (parsed) contents of the first file. There must be at least one file.
+// If an error occurs, parsing stops and the returned *Template is nil.
+func ParseFiles(filenames ...string) (*Template, error) {
+ return parseFiles(nil, filenames...)
+}
+
+// ParseFiles parses the named files and associates the resulting templates with
+// t. If an error occurs, parsing stops and the returned template is nil;
+// otherwise it is t. There must be at least one file.
+func (t *Template) ParseFiles(filenames ...string) (*Template, error) {
+ return parseFiles(t, filenames...)
+}
+
+// parseFiles is the helper for the method and function. If the argument
+// template is nil, it is created from the first file.
+func parseFiles(t *Template, filenames ...string) (*Template, error) {
+ if len(filenames) == 0 {
+ // Not really a problem, but be consistent.
+ return nil, fmt.Errorf("template: no files named in call to ParseFiles")
+ }
+ for _, filename := range filenames {
+ b, err := ioutil.ReadFile(filename)
+ if err != nil {
+ return nil, err
+ }
+ s := string(b)
+ name := filepath.Base(filename)
+ // First template becomes return value if not already defined,
+ // and we use that one for subsequent New calls to associate
+ // all the templates together. Also, if this file has the same name
+ // as t, this file becomes the contents of t, so
+ // t, err := New(name).Funcs(xxx).ParseFiles(name)
+ // works. Otherwise we create a new template associated with t.
+ var tmpl *Template
+ if t == nil {
+ t = New(name)
+ }
+ if name == t.Name() {
+ tmpl = t
+ } else {
+ tmpl = t.New(name)
+ }
+ _, err = tmpl.Parse(s)
+ if err != nil {
+ return nil, err
+ }
+ }
+ return t, nil
+}
+
+// ParseGlob creates a new Template and parses the template definitions from the
+// files identified by the pattern, which must match at least one file. The
+// returned template will have the (base) name and (parsed) contents of the
+// first file matched by the pattern. ParseGlob is equivalent to calling
+// ParseFiles with the list of files matched by the pattern.
+func ParseGlob(pattern string) (*Template, error) {
+ return parseGlob(nil, pattern)
+}
+
+// ParseGlob parses the template definitions in the files identified by the
+// pattern and associates the resulting templates with t. The pattern is
+// processed by filepath.Glob and must match at least one file. ParseGlob is
+// equivalent to calling t.ParseFiles with the list of files matched by the
+// pattern.
+func (t *Template) ParseGlob(pattern string) (*Template, error) {
+ return parseGlob(t, pattern)
+}
+
+// parseGlob is the implementation of the function and method ParseGlob.
+func parseGlob(t *Template, pattern string) (*Template, error) {
+ filenames, err := filepath.Glob(pattern)
+ if err != nil {
+ return nil, err
+ }
+ if len(filenames) == 0 {
+ return nil, fmt.Errorf("template: pattern matches no files: %#q", pattern)
+ }
+ return parseFiles(t, filenames...)
+}
diff --git a/vendor/github.com/alecthomas/template/parse/lex.go b/vendor/github.com/alecthomas/template/parse/lex.go
new file mode 100644
index 0000000..55f1c05
--- /dev/null
+++ b/vendor/github.com/alecthomas/template/parse/lex.go
@@ -0,0 +1,556 @@
+// Copyright 2011 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package parse
+
+import (
+ "fmt"
+ "strings"
+ "unicode"
+ "unicode/utf8"
+)
+
+// item represents a token or text string returned from the scanner.
+type item struct {
+ typ itemType // The type of this item.
+ pos Pos // The starting position, in bytes, of this item in the input string.
+ val string // The value of this item.
+}
+
+func (i item) String() string {
+ switch {
+ case i.typ == itemEOF:
+ return "EOF"
+ case i.typ == itemError:
+ return i.val
+ case i.typ > itemKeyword:
+ return fmt.Sprintf("<%s>", i.val)
+ case len(i.val) > 10:
+ return fmt.Sprintf("%.10q...", i.val)
+ }
+ return fmt.Sprintf("%q", i.val)
+}
+
+// itemType identifies the type of lex items.
+type itemType int
+
+const (
+ itemError itemType = iota // error occurred; value is text of error
+ itemBool // boolean constant
+ itemChar // printable ASCII character; grab bag for comma etc.
+ itemCharConstant // character constant
+ itemComplex // complex constant (1+2i); imaginary is just a number
+ itemColonEquals // colon-equals (':=') introducing a declaration
+ itemEOF
+ itemField // alphanumeric identifier starting with '.'
+ itemIdentifier // alphanumeric identifier not starting with '.'
+ itemLeftDelim // left action delimiter
+ itemLeftParen // '(' inside action
+ itemNumber // simple number, including imaginary
+ itemPipe // pipe symbol
+ itemRawString // raw quoted string (includes quotes)
+ itemRightDelim // right action delimiter
+ itemElideNewline // elide newline after right delim
+ itemRightParen // ')' inside action
+ itemSpace // run of spaces separating arguments
+ itemString // quoted string (includes quotes)
+ itemText // plain text
+ itemVariable // variable starting with '$', such as '$' or '$1' or '$hello'
+ // Keywords appear after all the rest.
+ itemKeyword // used only to delimit the keywords
+ itemDot // the cursor, spelled '.'
+ itemDefine // define keyword
+ itemElse // else keyword
+ itemEnd // end keyword
+ itemIf // if keyword
+ itemNil // the untyped nil constant, easiest to treat as a keyword
+ itemRange // range keyword
+ itemTemplate // template keyword
+ itemWith // with keyword
+)
+
+var key = map[string]itemType{
+ ".": itemDot,
+ "define": itemDefine,
+ "else": itemElse,
+ "end": itemEnd,
+ "if": itemIf,
+ "range": itemRange,
+ "nil": itemNil,
+ "template": itemTemplate,
+ "with": itemWith,
+}
+
+const eof = -1
+
+// stateFn represents the state of the scanner as a function that returns the next state.
+type stateFn func(*lexer) stateFn
+
+// lexer holds the state of the scanner.
+type lexer struct {
+ name string // the name of the input; used only for error reports
+ input string // the string being scanned
+ leftDelim string // start of action
+ rightDelim string // end of action
+ state stateFn // the next lexing function to enter
+ pos Pos // current position in the input
+ start Pos // start position of this item
+ width Pos // width of last rune read from input
+ lastPos Pos // position of most recent item returned by nextItem
+ items chan item // channel of scanned items
+ parenDepth int // nesting depth of ( ) exprs
+}
+
+// next returns the next rune in the input.
+func (l *lexer) next() rune {
+ if int(l.pos) >= len(l.input) {
+ l.width = 0
+ return eof
+ }
+ r, w := utf8.DecodeRuneInString(l.input[l.pos:])
+ l.width = Pos(w)
+ l.pos += l.width
+ return r
+}
+
+// peek returns but does not consume the next rune in the input.
+func (l *lexer) peek() rune {
+ r := l.next()
+ l.backup()
+ return r
+}
+
+// backup steps back one rune. Can only be called once per call of next.
+func (l *lexer) backup() {
+ l.pos -= l.width
+}
+
+// emit passes an item back to the client.
+func (l *lexer) emit(t itemType) {
+ l.items <- item{t, l.start, l.input[l.start:l.pos]}
+ l.start = l.pos
+}
+
+// ignore skips over the pending input before this point.
+func (l *lexer) ignore() {
+ l.start = l.pos
+}
+
+// accept consumes the next rune if it's from the valid set.
+func (l *lexer) accept(valid string) bool {
+ if strings.IndexRune(valid, l.next()) >= 0 {
+ return true
+ }
+ l.backup()
+ return false
+}
+
+// acceptRun consumes a run of runes from the valid set.
+func (l *lexer) acceptRun(valid string) {
+ for strings.IndexRune(valid, l.next()) >= 0 {
+ }
+ l.backup()
+}
+
+// lineNumber reports which line we're on, based on the position of
+// the previous item returned by nextItem. Doing it this way
+// means we don't have to worry about peek double counting.
+func (l *lexer) lineNumber() int {
+ return 1 + strings.Count(l.input[:l.lastPos], "\n")
+}
+
+// errorf returns an error token and terminates the scan by passing
+// back a nil pointer that will be the next state, terminating l.nextItem.
+func (l *lexer) errorf(format string, args ...interface{}) stateFn {
+ l.items <- item{itemError, l.start, fmt.Sprintf(format, args...)}
+ return nil
+}
+
+// nextItem returns the next item from the input.
+func (l *lexer) nextItem() item {
+ item := <-l.items
+ l.lastPos = item.pos
+ return item
+}
+
+// lex creates a new scanner for the input string.
+func lex(name, input, left, right string) *lexer {
+ if left == "" {
+ left = leftDelim
+ }
+ if right == "" {
+ right = rightDelim
+ }
+ l := &lexer{
+ name: name,
+ input: input,
+ leftDelim: left,
+ rightDelim: right,
+ items: make(chan item),
+ }
+ go l.run()
+ return l
+}
+
+// run runs the state machine for the lexer.
+func (l *lexer) run() {
+ for l.state = lexText; l.state != nil; {
+ l.state = l.state(l)
+ }
+}
+
+// state functions
+
+const (
+ leftDelim = "{{"
+ rightDelim = "}}"
+ leftComment = "/*"
+ rightComment = "*/"
+)
+
+// lexText scans until an opening action delimiter, "{{".
+func lexText(l *lexer) stateFn {
+ for {
+ if strings.HasPrefix(l.input[l.pos:], l.leftDelim) {
+ if l.pos > l.start {
+ l.emit(itemText)
+ }
+ return lexLeftDelim
+ }
+ if l.next() == eof {
+ break
+ }
+ }
+ // Correctly reached EOF.
+ if l.pos > l.start {
+ l.emit(itemText)
+ }
+ l.emit(itemEOF)
+ return nil
+}
+
+// lexLeftDelim scans the left delimiter, which is known to be present.
+func lexLeftDelim(l *lexer) stateFn {
+ l.pos += Pos(len(l.leftDelim))
+ if strings.HasPrefix(l.input[l.pos:], leftComment) {
+ return lexComment
+ }
+ l.emit(itemLeftDelim)
+ l.parenDepth = 0
+ return lexInsideAction
+}
+
+// lexComment scans a comment. The left comment marker is known to be present.
+func lexComment(l *lexer) stateFn {
+ l.pos += Pos(len(leftComment))
+ i := strings.Index(l.input[l.pos:], rightComment)
+ if i < 0 {
+ return l.errorf("unclosed comment")
+ }
+ l.pos += Pos(i + len(rightComment))
+ if !strings.HasPrefix(l.input[l.pos:], l.rightDelim) {
+ return l.errorf("comment ends before closing delimiter")
+
+ }
+ l.pos += Pos(len(l.rightDelim))
+ l.ignore()
+ return lexText
+}
+
+// lexRightDelim scans the right delimiter, which is known to be present.
+func lexRightDelim(l *lexer) stateFn {
+ l.pos += Pos(len(l.rightDelim))
+ l.emit(itemRightDelim)
+ if l.peek() == '\\' {
+ l.pos++
+ l.emit(itemElideNewline)
+ }
+ return lexText
+}
+
+// lexInsideAction scans the elements inside action delimiters.
+func lexInsideAction(l *lexer) stateFn {
+ // Either number, quoted string, or identifier.
+ // Spaces separate arguments; runs of spaces turn into itemSpace.
+ // Pipe symbols separate and are emitted.
+ if strings.HasPrefix(l.input[l.pos:], l.rightDelim+"\\") || strings.HasPrefix(l.input[l.pos:], l.rightDelim) {
+ if l.parenDepth == 0 {
+ return lexRightDelim
+ }
+ return l.errorf("unclosed left paren")
+ }
+ switch r := l.next(); {
+ case r == eof || isEndOfLine(r):
+ return l.errorf("unclosed action")
+ case isSpace(r):
+ return lexSpace
+ case r == ':':
+ if l.next() != '=' {
+ return l.errorf("expected :=")
+ }
+ l.emit(itemColonEquals)
+ case r == '|':
+ l.emit(itemPipe)
+ case r == '"':
+ return lexQuote
+ case r == '`':
+ return lexRawQuote
+ case r == '$':
+ return lexVariable
+ case r == '\'':
+ return lexChar
+ case r == '.':
+ // special look-ahead for ".field" so we don't break l.backup().
+ if l.pos < Pos(len(l.input)) {
+ r := l.input[l.pos]
+ if r < '0' || '9' < r {
+ return lexField
+ }
+ }
+ fallthrough // '.' can start a number.
+ case r == '+' || r == '-' || ('0' <= r && r <= '9'):
+ l.backup()
+ return lexNumber
+ case isAlphaNumeric(r):
+ l.backup()
+ return lexIdentifier
+ case r == '(':
+ l.emit(itemLeftParen)
+ l.parenDepth++
+ return lexInsideAction
+ case r == ')':
+ l.emit(itemRightParen)
+ l.parenDepth--
+ if l.parenDepth < 0 {
+ return l.errorf("unexpected right paren %#U", r)
+ }
+ return lexInsideAction
+ case r <= unicode.MaxASCII && unicode.IsPrint(r):
+ l.emit(itemChar)
+ return lexInsideAction
+ default:
+ return l.errorf("unrecognized character in action: %#U", r)
+ }
+ return lexInsideAction
+}
+
+// lexSpace scans a run of space characters.
+// One space has already been seen.
+func lexSpace(l *lexer) stateFn {
+ for isSpace(l.peek()) {
+ l.next()
+ }
+ l.emit(itemSpace)
+ return lexInsideAction
+}
+
+// lexIdentifier scans an alphanumeric.
+func lexIdentifier(l *lexer) stateFn {
+Loop:
+ for {
+ switch r := l.next(); {
+ case isAlphaNumeric(r):
+ // absorb.
+ default:
+ l.backup()
+ word := l.input[l.start:l.pos]
+ if !l.atTerminator() {
+ return l.errorf("bad character %#U", r)
+ }
+ switch {
+ case key[word] > itemKeyword:
+ l.emit(key[word])
+ case word[0] == '.':
+ l.emit(itemField)
+ case word == "true", word == "false":
+ l.emit(itemBool)
+ default:
+ l.emit(itemIdentifier)
+ }
+ break Loop
+ }
+ }
+ return lexInsideAction
+}
+
+// lexField scans a field: .Alphanumeric.
+// The . has been scanned.
+func lexField(l *lexer) stateFn {
+ return lexFieldOrVariable(l, itemField)
+}
+
+// lexVariable scans a Variable: $Alphanumeric.
+// The $ has been scanned.
+func lexVariable(l *lexer) stateFn {
+ if l.atTerminator() { // Nothing interesting follows -> "$".
+ l.emit(itemVariable)
+ return lexInsideAction
+ }
+ return lexFieldOrVariable(l, itemVariable)
+}
+
+// lexVariable scans a field or variable: [.$]Alphanumeric.
+// The . or $ has been scanned.
+func lexFieldOrVariable(l *lexer, typ itemType) stateFn {
+ if l.atTerminator() { // Nothing interesting follows -> "." or "$".
+ if typ == itemVariable {
+ l.emit(itemVariable)
+ } else {
+ l.emit(itemDot)
+ }
+ return lexInsideAction
+ }
+ var r rune
+ for {
+ r = l.next()
+ if !isAlphaNumeric(r) {
+ l.backup()
+ break
+ }
+ }
+ if !l.atTerminator() {
+ return l.errorf("bad character %#U", r)
+ }
+ l.emit(typ)
+ return lexInsideAction
+}
+
+// atTerminator reports whether the input is at valid termination character to
+// appear after an identifier. Breaks .X.Y into two pieces. Also catches cases
+// like "$x+2" not being acceptable without a space, in case we decide one
+// day to implement arithmetic.
+func (l *lexer) atTerminator() bool {
+ r := l.peek()
+ if isSpace(r) || isEndOfLine(r) {
+ return true
+ }
+ switch r {
+ case eof, '.', ',', '|', ':', ')', '(':
+ return true
+ }
+ // Does r start the delimiter? This can be ambiguous (with delim=="//", $x/2 will
+ // succeed but should fail) but only in extremely rare cases caused by willfully
+ // bad choice of delimiter.
+ if rd, _ := utf8.DecodeRuneInString(l.rightDelim); rd == r {
+ return true
+ }
+ return false
+}
+
+// lexChar scans a character constant. The initial quote is already
+// scanned. Syntax checking is done by the parser.
+func lexChar(l *lexer) stateFn {
+Loop:
+ for {
+ switch l.next() {
+ case '\\':
+ if r := l.next(); r != eof && r != '\n' {
+ break
+ }
+ fallthrough
+ case eof, '\n':
+ return l.errorf("unterminated character constant")
+ case '\'':
+ break Loop
+ }
+ }
+ l.emit(itemCharConstant)
+ return lexInsideAction
+}
+
+// lexNumber scans a number: decimal, octal, hex, float, or imaginary. This
+// isn't a perfect number scanner - for instance it accepts "." and "0x0.2"
+// and "089" - but when it's wrong the input is invalid and the parser (via
+// strconv) will notice.
+func lexNumber(l *lexer) stateFn {
+ if !l.scanNumber() {
+ return l.errorf("bad number syntax: %q", l.input[l.start:l.pos])
+ }
+ if sign := l.peek(); sign == '+' || sign == '-' {
+ // Complex: 1+2i. No spaces, must end in 'i'.
+ if !l.scanNumber() || l.input[l.pos-1] != 'i' {
+ return l.errorf("bad number syntax: %q", l.input[l.start:l.pos])
+ }
+ l.emit(itemComplex)
+ } else {
+ l.emit(itemNumber)
+ }
+ return lexInsideAction
+}
+
+func (l *lexer) scanNumber() bool {
+ // Optional leading sign.
+ l.accept("+-")
+ // Is it hex?
+ digits := "0123456789"
+ if l.accept("0") && l.accept("xX") {
+ digits = "0123456789abcdefABCDEF"
+ }
+ l.acceptRun(digits)
+ if l.accept(".") {
+ l.acceptRun(digits)
+ }
+ if l.accept("eE") {
+ l.accept("+-")
+ l.acceptRun("0123456789")
+ }
+ // Is it imaginary?
+ l.accept("i")
+ // Next thing mustn't be alphanumeric.
+ if isAlphaNumeric(l.peek()) {
+ l.next()
+ return false
+ }
+ return true
+}
+
+// lexQuote scans a quoted string.
+func lexQuote(l *lexer) stateFn {
+Loop:
+ for {
+ switch l.next() {
+ case '\\':
+ if r := l.next(); r != eof && r != '\n' {
+ break
+ }
+ fallthrough
+ case eof, '\n':
+ return l.errorf("unterminated quoted string")
+ case '"':
+ break Loop
+ }
+ }
+ l.emit(itemString)
+ return lexInsideAction
+}
+
+// lexRawQuote scans a raw quoted string.
+func lexRawQuote(l *lexer) stateFn {
+Loop:
+ for {
+ switch l.next() {
+ case eof, '\n':
+ return l.errorf("unterminated raw quoted string")
+ case '`':
+ break Loop
+ }
+ }
+ l.emit(itemRawString)
+ return lexInsideAction
+}
+
+// isSpace reports whether r is a space character.
+func isSpace(r rune) bool {
+ return r == ' ' || r == '\t'
+}
+
+// isEndOfLine reports whether r is an end-of-line character.
+func isEndOfLine(r rune) bool {
+ return r == '\r' || r == '\n'
+}
+
+// isAlphaNumeric reports whether r is an alphabetic, digit, or underscore.
+func isAlphaNumeric(r rune) bool {
+ return r == '_' || unicode.IsLetter(r) || unicode.IsDigit(r)
+}
diff --git a/vendor/github.com/alecthomas/template/parse/node.go b/vendor/github.com/alecthomas/template/parse/node.go
new file mode 100644
index 0000000..55c37f6
--- /dev/null
+++ b/vendor/github.com/alecthomas/template/parse/node.go
@@ -0,0 +1,834 @@
+// Copyright 2011 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// Parse nodes.
+
+package parse
+
+import (
+ "bytes"
+ "fmt"
+ "strconv"
+ "strings"
+)
+
+var textFormat = "%s" // Changed to "%q" in tests for better error messages.
+
+// A Node is an element in the parse tree. The interface is trivial.
+// The interface contains an unexported method so that only
+// types local to this package can satisfy it.
+type Node interface {
+ Type() NodeType
+ String() string
+ // Copy does a deep copy of the Node and all its components.
+ // To avoid type assertions, some XxxNodes also have specialized
+ // CopyXxx methods that return *XxxNode.
+ Copy() Node
+ Position() Pos // byte position of start of node in full original input string
+ // tree returns the containing *Tree.
+ // It is unexported so all implementations of Node are in this package.
+ tree() *Tree
+}
+
+// NodeType identifies the type of a parse tree node.
+type NodeType int
+
+// Pos represents a byte position in the original input text from which
+// this template was parsed.
+type Pos int
+
+func (p Pos) Position() Pos {
+ return p
+}
+
+// Type returns itself and provides an easy default implementation
+// for embedding in a Node. Embedded in all non-trivial Nodes.
+func (t NodeType) Type() NodeType {
+ return t
+}
+
+const (
+ NodeText NodeType = iota // Plain text.
+ NodeAction // A non-control action such as a field evaluation.
+ NodeBool // A boolean constant.
+ NodeChain // A sequence of field accesses.
+ NodeCommand // An element of a pipeline.
+ NodeDot // The cursor, dot.
+ nodeElse // An else action. Not added to tree.
+ nodeEnd // An end action. Not added to tree.
+ NodeField // A field or method name.
+ NodeIdentifier // An identifier; always a function name.
+ NodeIf // An if action.
+ NodeList // A list of Nodes.
+ NodeNil // An untyped nil constant.
+ NodeNumber // A numerical constant.
+ NodePipe // A pipeline of commands.
+ NodeRange // A range action.
+ NodeString // A string constant.
+ NodeTemplate // A template invocation action.
+ NodeVariable // A $ variable.
+ NodeWith // A with action.
+)
+
+// Nodes.
+
+// ListNode holds a sequence of nodes.
+type ListNode struct {
+ NodeType
+ Pos
+ tr *Tree
+ Nodes []Node // The element nodes in lexical order.
+}
+
+func (t *Tree) newList(pos Pos) *ListNode {
+ return &ListNode{tr: t, NodeType: NodeList, Pos: pos}
+}
+
+func (l *ListNode) append(n Node) {
+ l.Nodes = append(l.Nodes, n)
+}
+
+func (l *ListNode) tree() *Tree {
+ return l.tr
+}
+
+func (l *ListNode) String() string {
+ b := new(bytes.Buffer)
+ for _, n := range l.Nodes {
+ fmt.Fprint(b, n)
+ }
+ return b.String()
+}
+
+func (l *ListNode) CopyList() *ListNode {
+ if l == nil {
+ return l
+ }
+ n := l.tr.newList(l.Pos)
+ for _, elem := range l.Nodes {
+ n.append(elem.Copy())
+ }
+ return n
+}
+
+func (l *ListNode) Copy() Node {
+ return l.CopyList()
+}
+
+// TextNode holds plain text.
+type TextNode struct {
+ NodeType
+ Pos
+ tr *Tree
+ Text []byte // The text; may span newlines.
+}
+
+func (t *Tree) newText(pos Pos, text string) *TextNode {
+ return &TextNode{tr: t, NodeType: NodeText, Pos: pos, Text: []byte(text)}
+}
+
+func (t *TextNode) String() string {
+ return fmt.Sprintf(textFormat, t.Text)
+}
+
+func (t *TextNode) tree() *Tree {
+ return t.tr
+}
+
+func (t *TextNode) Copy() Node {
+ return &TextNode{tr: t.tr, NodeType: NodeText, Pos: t.Pos, Text: append([]byte{}, t.Text...)}
+}
+
+// PipeNode holds a pipeline with optional declaration
+type PipeNode struct {
+ NodeType
+ Pos
+ tr *Tree
+ Line int // The line number in the input (deprecated; kept for compatibility)
+ Decl []*VariableNode // Variable declarations in lexical order.
+ Cmds []*CommandNode // The commands in lexical order.
+}
+
+func (t *Tree) newPipeline(pos Pos, line int, decl []*VariableNode) *PipeNode {
+ return &PipeNode{tr: t, NodeType: NodePipe, Pos: pos, Line: line, Decl: decl}
+}
+
+func (p *PipeNode) append(command *CommandNode) {
+ p.Cmds = append(p.Cmds, command)
+}
+
+func (p *PipeNode) String() string {
+ s := ""
+ if len(p.Decl) > 0 {
+ for i, v := range p.Decl {
+ if i > 0 {
+ s += ", "
+ }
+ s += v.String()
+ }
+ s += " := "
+ }
+ for i, c := range p.Cmds {
+ if i > 0 {
+ s += " | "
+ }
+ s += c.String()
+ }
+ return s
+}
+
+func (p *PipeNode) tree() *Tree {
+ return p.tr
+}
+
+func (p *PipeNode) CopyPipe() *PipeNode {
+ if p == nil {
+ return p
+ }
+ var decl []*VariableNode
+ for _, d := range p.Decl {
+ decl = append(decl, d.Copy().(*VariableNode))
+ }
+ n := p.tr.newPipeline(p.Pos, p.Line, decl)
+ for _, c := range p.Cmds {
+ n.append(c.Copy().(*CommandNode))
+ }
+ return n
+}
+
+func (p *PipeNode) Copy() Node {
+ return p.CopyPipe()
+}
+
+// ActionNode holds an action (something bounded by delimiters).
+// Control actions have their own nodes; ActionNode represents simple
+// ones such as field evaluations and parenthesized pipelines.
+type ActionNode struct {
+ NodeType
+ Pos
+ tr *Tree
+ Line int // The line number in the input (deprecated; kept for compatibility)
+ Pipe *PipeNode // The pipeline in the action.
+}
+
+func (t *Tree) newAction(pos Pos, line int, pipe *PipeNode) *ActionNode {
+ return &ActionNode{tr: t, NodeType: NodeAction, Pos: pos, Line: line, Pipe: pipe}
+}
+
+func (a *ActionNode) String() string {
+ return fmt.Sprintf("{{%s}}", a.Pipe)
+
+}
+
+func (a *ActionNode) tree() *Tree {
+ return a.tr
+}
+
+func (a *ActionNode) Copy() Node {
+ return a.tr.newAction(a.Pos, a.Line, a.Pipe.CopyPipe())
+
+}
+
+// CommandNode holds a command (a pipeline inside an evaluating action).
+type CommandNode struct {
+ NodeType
+ Pos
+ tr *Tree
+ Args []Node // Arguments in lexical order: Identifier, field, or constant.
+}
+
+func (t *Tree) newCommand(pos Pos) *CommandNode {
+ return &CommandNode{tr: t, NodeType: NodeCommand, Pos: pos}
+}
+
+func (c *CommandNode) append(arg Node) {
+ c.Args = append(c.Args, arg)
+}
+
+func (c *CommandNode) String() string {
+ s := ""
+ for i, arg := range c.Args {
+ if i > 0 {
+ s += " "
+ }
+ if arg, ok := arg.(*PipeNode); ok {
+ s += "(" + arg.String() + ")"
+ continue
+ }
+ s += arg.String()
+ }
+ return s
+}
+
+func (c *CommandNode) tree() *Tree {
+ return c.tr
+}
+
+func (c *CommandNode) Copy() Node {
+ if c == nil {
+ return c
+ }
+ n := c.tr.newCommand(c.Pos)
+ for _, c := range c.Args {
+ n.append(c.Copy())
+ }
+ return n
+}
+
+// IdentifierNode holds an identifier.
+type IdentifierNode struct {
+ NodeType
+ Pos
+ tr *Tree
+ Ident string // The identifier's name.
+}
+
+// NewIdentifier returns a new IdentifierNode with the given identifier name.
+func NewIdentifier(ident string) *IdentifierNode {
+ return &IdentifierNode{NodeType: NodeIdentifier, Ident: ident}
+}
+
+// SetPos sets the position. NewIdentifier is a public method so we can't modify its signature.
+// Chained for convenience.
+// TODO: fix one day?
+func (i *IdentifierNode) SetPos(pos Pos) *IdentifierNode {
+ i.Pos = pos
+ return i
+}
+
+// SetTree sets the parent tree for the node. NewIdentifier is a public method so we can't modify its signature.
+// Chained for convenience.
+// TODO: fix one day?
+func (i *IdentifierNode) SetTree(t *Tree) *IdentifierNode {
+ i.tr = t
+ return i
+}
+
+func (i *IdentifierNode) String() string {
+ return i.Ident
+}
+
+func (i *IdentifierNode) tree() *Tree {
+ return i.tr
+}
+
+func (i *IdentifierNode) Copy() Node {
+ return NewIdentifier(i.Ident).SetTree(i.tr).SetPos(i.Pos)
+}
+
+// VariableNode holds a list of variable names, possibly with chained field
+// accesses. The dollar sign is part of the (first) name.
+type VariableNode struct {
+ NodeType
+ Pos
+ tr *Tree
+ Ident []string // Variable name and fields in lexical order.
+}
+
+func (t *Tree) newVariable(pos Pos, ident string) *VariableNode {
+ return &VariableNode{tr: t, NodeType: NodeVariable, Pos: pos, Ident: strings.Split(ident, ".")}
+}
+
+func (v *VariableNode) String() string {
+ s := ""
+ for i, id := range v.Ident {
+ if i > 0 {
+ s += "."
+ }
+ s += id
+ }
+ return s
+}
+
+func (v *VariableNode) tree() *Tree {
+ return v.tr
+}
+
+func (v *VariableNode) Copy() Node {
+ return &VariableNode{tr: v.tr, NodeType: NodeVariable, Pos: v.Pos, Ident: append([]string{}, v.Ident...)}
+}
+
+// DotNode holds the special identifier '.'.
+type DotNode struct {
+ NodeType
+ Pos
+ tr *Tree
+}
+
+func (t *Tree) newDot(pos Pos) *DotNode {
+ return &DotNode{tr: t, NodeType: NodeDot, Pos: pos}
+}
+
+func (d *DotNode) Type() NodeType {
+ // Override method on embedded NodeType for API compatibility.
+ // TODO: Not really a problem; could change API without effect but
+ // api tool complains.
+ return NodeDot
+}
+
+func (d *DotNode) String() string {
+ return "."
+}
+
+func (d *DotNode) tree() *Tree {
+ return d.tr
+}
+
+func (d *DotNode) Copy() Node {
+ return d.tr.newDot(d.Pos)
+}
+
+// NilNode holds the special identifier 'nil' representing an untyped nil constant.
+type NilNode struct {
+ NodeType
+ Pos
+ tr *Tree
+}
+
+func (t *Tree) newNil(pos Pos) *NilNode {
+ return &NilNode{tr: t, NodeType: NodeNil, Pos: pos}
+}
+
+func (n *NilNode) Type() NodeType {
+ // Override method on embedded NodeType for API compatibility.
+ // TODO: Not really a problem; could change API without effect but
+ // api tool complains.
+ return NodeNil
+}
+
+func (n *NilNode) String() string {
+ return "nil"
+}
+
+func (n *NilNode) tree() *Tree {
+ return n.tr
+}
+
+func (n *NilNode) Copy() Node {
+ return n.tr.newNil(n.Pos)
+}
+
+// FieldNode holds a field (identifier starting with '.').
+// The names may be chained ('.x.y').
+// The period is dropped from each ident.
+type FieldNode struct {
+ NodeType
+ Pos
+ tr *Tree
+ Ident []string // The identifiers in lexical order.
+}
+
+func (t *Tree) newField(pos Pos, ident string) *FieldNode {
+ return &FieldNode{tr: t, NodeType: NodeField, Pos: pos, Ident: strings.Split(ident[1:], ".")} // [1:] to drop leading period
+}
+
+func (f *FieldNode) String() string {
+ s := ""
+ for _, id := range f.Ident {
+ s += "." + id
+ }
+ return s
+}
+
+func (f *FieldNode) tree() *Tree {
+ return f.tr
+}
+
+func (f *FieldNode) Copy() Node {
+ return &FieldNode{tr: f.tr, NodeType: NodeField, Pos: f.Pos, Ident: append([]string{}, f.Ident...)}
+}
+
+// ChainNode holds a term followed by a chain of field accesses (identifier starting with '.').
+// The names may be chained ('.x.y').
+// The periods are dropped from each ident.
+type ChainNode struct {
+ NodeType
+ Pos
+ tr *Tree
+ Node Node
+ Field []string // The identifiers in lexical order.
+}
+
+func (t *Tree) newChain(pos Pos, node Node) *ChainNode {
+ return &ChainNode{tr: t, NodeType: NodeChain, Pos: pos, Node: node}
+}
+
+// Add adds the named field (which should start with a period) to the end of the chain.
+func (c *ChainNode) Add(field string) {
+ if len(field) == 0 || field[0] != '.' {
+ panic("no dot in field")
+ }
+ field = field[1:] // Remove leading dot.
+ if field == "" {
+ panic("empty field")
+ }
+ c.Field = append(c.Field, field)
+}
+
+func (c *ChainNode) String() string {
+ s := c.Node.String()
+ if _, ok := c.Node.(*PipeNode); ok {
+ s = "(" + s + ")"
+ }
+ for _, field := range c.Field {
+ s += "." + field
+ }
+ return s
+}
+
+func (c *ChainNode) tree() *Tree {
+ return c.tr
+}
+
+func (c *ChainNode) Copy() Node {
+ return &ChainNode{tr: c.tr, NodeType: NodeChain, Pos: c.Pos, Node: c.Node, Field: append([]string{}, c.Field...)}
+}
+
+// BoolNode holds a boolean constant.
+type BoolNode struct {
+ NodeType
+ Pos
+ tr *Tree
+ True bool // The value of the boolean constant.
+}
+
+func (t *Tree) newBool(pos Pos, true bool) *BoolNode {
+ return &BoolNode{tr: t, NodeType: NodeBool, Pos: pos, True: true}
+}
+
+func (b *BoolNode) String() string {
+ if b.True {
+ return "true"
+ }
+ return "false"
+}
+
+func (b *BoolNode) tree() *Tree {
+ return b.tr
+}
+
+func (b *BoolNode) Copy() Node {
+ return b.tr.newBool(b.Pos, b.True)
+}
+
+// NumberNode holds a number: signed or unsigned integer, float, or complex.
+// The value is parsed and stored under all the types that can represent the value.
+// This simulates in a small amount of code the behavior of Go's ideal constants.
+type NumberNode struct {
+ NodeType
+ Pos
+ tr *Tree
+ IsInt bool // Number has an integral value.
+ IsUint bool // Number has an unsigned integral value.
+ IsFloat bool // Number has a floating-point value.
+ IsComplex bool // Number is complex.
+ Int64 int64 // The signed integer value.
+ Uint64 uint64 // The unsigned integer value.
+ Float64 float64 // The floating-point value.
+ Complex128 complex128 // The complex value.
+ Text string // The original textual representation from the input.
+}
+
+func (t *Tree) newNumber(pos Pos, text string, typ itemType) (*NumberNode, error) {
+ n := &NumberNode{tr: t, NodeType: NodeNumber, Pos: pos, Text: text}
+ switch typ {
+ case itemCharConstant:
+ rune, _, tail, err := strconv.UnquoteChar(text[1:], text[0])
+ if err != nil {
+ return nil, err
+ }
+ if tail != "'" {
+ return nil, fmt.Errorf("malformed character constant: %s", text)
+ }
+ n.Int64 = int64(rune)
+ n.IsInt = true
+ n.Uint64 = uint64(rune)
+ n.IsUint = true
+ n.Float64 = float64(rune) // odd but those are the rules.
+ n.IsFloat = true
+ return n, nil
+ case itemComplex:
+ // fmt.Sscan can parse the pair, so let it do the work.
+ if _, err := fmt.Sscan(text, &n.Complex128); err != nil {
+ return nil, err
+ }
+ n.IsComplex = true
+ n.simplifyComplex()
+ return n, nil
+ }
+ // Imaginary constants can only be complex unless they are zero.
+ if len(text) > 0 && text[len(text)-1] == 'i' {
+ f, err := strconv.ParseFloat(text[:len(text)-1], 64)
+ if err == nil {
+ n.IsComplex = true
+ n.Complex128 = complex(0, f)
+ n.simplifyComplex()
+ return n, nil
+ }
+ }
+ // Do integer test first so we get 0x123 etc.
+ u, err := strconv.ParseUint(text, 0, 64) // will fail for -0; fixed below.
+ if err == nil {
+ n.IsUint = true
+ n.Uint64 = u
+ }
+ i, err := strconv.ParseInt(text, 0, 64)
+ if err == nil {
+ n.IsInt = true
+ n.Int64 = i
+ if i == 0 {
+ n.IsUint = true // in case of -0.
+ n.Uint64 = u
+ }
+ }
+ // If an integer extraction succeeded, promote the float.
+ if n.IsInt {
+ n.IsFloat = true
+ n.Float64 = float64(n.Int64)
+ } else if n.IsUint {
+ n.IsFloat = true
+ n.Float64 = float64(n.Uint64)
+ } else {
+ f, err := strconv.ParseFloat(text, 64)
+ if err == nil {
+ n.IsFloat = true
+ n.Float64 = f
+ // If a floating-point extraction succeeded, extract the int if needed.
+ if !n.IsInt && float64(int64(f)) == f {
+ n.IsInt = true
+ n.Int64 = int64(f)
+ }
+ if !n.IsUint && float64(uint64(f)) == f {
+ n.IsUint = true
+ n.Uint64 = uint64(f)
+ }
+ }
+ }
+ if !n.IsInt && !n.IsUint && !n.IsFloat {
+ return nil, fmt.Errorf("illegal number syntax: %q", text)
+ }
+ return n, nil
+}
+
+// simplifyComplex pulls out any other types that are represented by the complex number.
+// These all require that the imaginary part be zero.
+func (n *NumberNode) simplifyComplex() {
+ n.IsFloat = imag(n.Complex128) == 0
+ if n.IsFloat {
+ n.Float64 = real(n.Complex128)
+ n.IsInt = float64(int64(n.Float64)) == n.Float64
+ if n.IsInt {
+ n.Int64 = int64(n.Float64)
+ }
+ n.IsUint = float64(uint64(n.Float64)) == n.Float64
+ if n.IsUint {
+ n.Uint64 = uint64(n.Float64)
+ }
+ }
+}
+
+func (n *NumberNode) String() string {
+ return n.Text
+}
+
+func (n *NumberNode) tree() *Tree {
+ return n.tr
+}
+
+func (n *NumberNode) Copy() Node {
+ nn := new(NumberNode)
+ *nn = *n // Easy, fast, correct.
+ return nn
+}
+
+// StringNode holds a string constant. The value has been "unquoted".
+type StringNode struct {
+ NodeType
+ Pos
+ tr *Tree
+ Quoted string // The original text of the string, with quotes.
+ Text string // The string, after quote processing.
+}
+
+func (t *Tree) newString(pos Pos, orig, text string) *StringNode {
+ return &StringNode{tr: t, NodeType: NodeString, Pos: pos, Quoted: orig, Text: text}
+}
+
+func (s *StringNode) String() string {
+ return s.Quoted
+}
+
+func (s *StringNode) tree() *Tree {
+ return s.tr
+}
+
+func (s *StringNode) Copy() Node {
+ return s.tr.newString(s.Pos, s.Quoted, s.Text)
+}
+
+// endNode represents an {{end}} action.
+// It does not appear in the final parse tree.
+type endNode struct {
+ NodeType
+ Pos
+ tr *Tree
+}
+
+func (t *Tree) newEnd(pos Pos) *endNode {
+ return &endNode{tr: t, NodeType: nodeEnd, Pos: pos}
+}
+
+func (e *endNode) String() string {
+ return "{{end}}"
+}
+
+func (e *endNode) tree() *Tree {
+ return e.tr
+}
+
+func (e *endNode) Copy() Node {
+ return e.tr.newEnd(e.Pos)
+}
+
+// elseNode represents an {{else}} action. Does not appear in the final tree.
+type elseNode struct {
+ NodeType
+ Pos
+ tr *Tree
+ Line int // The line number in the input (deprecated; kept for compatibility)
+}
+
+func (t *Tree) newElse(pos Pos, line int) *elseNode {
+ return &elseNode{tr: t, NodeType: nodeElse, Pos: pos, Line: line}
+}
+
+func (e *elseNode) Type() NodeType {
+ return nodeElse
+}
+
+func (e *elseNode) String() string {
+ return "{{else}}"
+}
+
+func (e *elseNode) tree() *Tree {
+ return e.tr
+}
+
+func (e *elseNode) Copy() Node {
+ return e.tr.newElse(e.Pos, e.Line)
+}
+
+// BranchNode is the common representation of if, range, and with.
+type BranchNode struct {
+ NodeType
+ Pos
+ tr *Tree
+ Line int // The line number in the input (deprecated; kept for compatibility)
+ Pipe *PipeNode // The pipeline to be evaluated.
+ List *ListNode // What to execute if the value is non-empty.
+ ElseList *ListNode // What to execute if the value is empty (nil if absent).
+}
+
+func (b *BranchNode) String() string {
+ name := ""
+ switch b.NodeType {
+ case NodeIf:
+ name = "if"
+ case NodeRange:
+ name = "range"
+ case NodeWith:
+ name = "with"
+ default:
+ panic("unknown branch type")
+ }
+ if b.ElseList != nil {
+ return fmt.Sprintf("{{%s %s}}%s{{else}}%s{{end}}", name, b.Pipe, b.List, b.ElseList)
+ }
+ return fmt.Sprintf("{{%s %s}}%s{{end}}", name, b.Pipe, b.List)
+}
+
+func (b *BranchNode) tree() *Tree {
+ return b.tr
+}
+
+func (b *BranchNode) Copy() Node {
+ switch b.NodeType {
+ case NodeIf:
+ return b.tr.newIf(b.Pos, b.Line, b.Pipe, b.List, b.ElseList)
+ case NodeRange:
+ return b.tr.newRange(b.Pos, b.Line, b.Pipe, b.List, b.ElseList)
+ case NodeWith:
+ return b.tr.newWith(b.Pos, b.Line, b.Pipe, b.List, b.ElseList)
+ default:
+ panic("unknown branch type")
+ }
+}
+
+// IfNode represents an {{if}} action and its commands.
+type IfNode struct {
+ BranchNode
+}
+
+func (t *Tree) newIf(pos Pos, line int, pipe *PipeNode, list, elseList *ListNode) *IfNode {
+ return &IfNode{BranchNode{tr: t, NodeType: NodeIf, Pos: pos, Line: line, Pipe: pipe, List: list, ElseList: elseList}}
+}
+
+func (i *IfNode) Copy() Node {
+ return i.tr.newIf(i.Pos, i.Line, i.Pipe.CopyPipe(), i.List.CopyList(), i.ElseList.CopyList())
+}
+
+// RangeNode represents a {{range}} action and its commands.
+type RangeNode struct {
+ BranchNode
+}
+
+func (t *Tree) newRange(pos Pos, line int, pipe *PipeNode, list, elseList *ListNode) *RangeNode {
+ return &RangeNode{BranchNode{tr: t, NodeType: NodeRange, Pos: pos, Line: line, Pipe: pipe, List: list, ElseList: elseList}}
+}
+
+func (r *RangeNode) Copy() Node {
+ return r.tr.newRange(r.Pos, r.Line, r.Pipe.CopyPipe(), r.List.CopyList(), r.ElseList.CopyList())
+}
+
+// WithNode represents a {{with}} action and its commands.
+type WithNode struct {
+ BranchNode
+}
+
+func (t *Tree) newWith(pos Pos, line int, pipe *PipeNode, list, elseList *ListNode) *WithNode {
+ return &WithNode{BranchNode{tr: t, NodeType: NodeWith, Pos: pos, Line: line, Pipe: pipe, List: list, ElseList: elseList}}
+}
+
+func (w *WithNode) Copy() Node {
+ return w.tr.newWith(w.Pos, w.Line, w.Pipe.CopyPipe(), w.List.CopyList(), w.ElseList.CopyList())
+}
+
+// TemplateNode represents a {{template}} action.
+type TemplateNode struct {
+ NodeType
+ Pos
+ tr *Tree
+ Line int // The line number in the input (deprecated; kept for compatibility)
+ Name string // The name of the template (unquoted).
+ Pipe *PipeNode // The command to evaluate as dot for the template.
+}
+
+func (t *Tree) newTemplate(pos Pos, line int, name string, pipe *PipeNode) *TemplateNode {
+ return &TemplateNode{tr: t, NodeType: NodeTemplate, Pos: pos, Line: line, Name: name, Pipe: pipe}
+}
+
+func (t *TemplateNode) String() string {
+ if t.Pipe == nil {
+ return fmt.Sprintf("{{template %q}}", t.Name)
+ }
+ return fmt.Sprintf("{{template %q %s}}", t.Name, t.Pipe)
+}
+
+func (t *TemplateNode) tree() *Tree {
+ return t.tr
+}
+
+func (t *TemplateNode) Copy() Node {
+ return t.tr.newTemplate(t.Pos, t.Line, t.Name, t.Pipe.CopyPipe())
+}
diff --git a/vendor/github.com/alecthomas/template/parse/parse.go b/vendor/github.com/alecthomas/template/parse/parse.go
new file mode 100644
index 0000000..0d77ade
--- /dev/null
+++ b/vendor/github.com/alecthomas/template/parse/parse.go
@@ -0,0 +1,700 @@
+// Copyright 2011 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// Package parse builds parse trees for templates as defined by text/template
+// and html/template. Clients should use those packages to construct templates
+// rather than this one, which provides shared internal data structures not
+// intended for general use.
+package parse
+
+import (
+ "bytes"
+ "fmt"
+ "runtime"
+ "strconv"
+ "strings"
+)
+
+// Tree is the representation of a single parsed template.
+type Tree struct {
+ Name string // name of the template represented by the tree.
+ ParseName string // name of the top-level template during parsing, for error messages.
+ Root *ListNode // top-level root of the tree.
+ text string // text parsed to create the template (or its parent)
+ // Parsing only; cleared after parse.
+ funcs []map[string]interface{}
+ lex *lexer
+ token [3]item // three-token lookahead for parser.
+ peekCount int
+ vars []string // variables defined at the moment.
+}
+
+// Copy returns a copy of the Tree. Any parsing state is discarded.
+func (t *Tree) Copy() *Tree {
+ if t == nil {
+ return nil
+ }
+ return &Tree{
+ Name: t.Name,
+ ParseName: t.ParseName,
+ Root: t.Root.CopyList(),
+ text: t.text,
+ }
+}
+
+// Parse returns a map from template name to parse.Tree, created by parsing the
+// templates described in the argument string. The top-level template will be
+// given the specified name. If an error is encountered, parsing stops and an
+// empty map is returned with the error.
+func Parse(name, text, leftDelim, rightDelim string, funcs ...map[string]interface{}) (treeSet map[string]*Tree, err error) {
+ treeSet = make(map[string]*Tree)
+ t := New(name)
+ t.text = text
+ _, err = t.Parse(text, leftDelim, rightDelim, treeSet, funcs...)
+ return
+}
+
+// next returns the next token.
+func (t *Tree) next() item {
+ if t.peekCount > 0 {
+ t.peekCount--
+ } else {
+ t.token[0] = t.lex.nextItem()
+ }
+ return t.token[t.peekCount]
+}
+
+// backup backs the input stream up one token.
+func (t *Tree) backup() {
+ t.peekCount++
+}
+
+// backup2 backs the input stream up two tokens.
+// The zeroth token is already there.
+func (t *Tree) backup2(t1 item) {
+ t.token[1] = t1
+ t.peekCount = 2
+}
+
+// backup3 backs the input stream up three tokens
+// The zeroth token is already there.
+func (t *Tree) backup3(t2, t1 item) { // Reverse order: we're pushing back.
+ t.token[1] = t1
+ t.token[2] = t2
+ t.peekCount = 3
+}
+
+// peek returns but does not consume the next token.
+func (t *Tree) peek() item {
+ if t.peekCount > 0 {
+ return t.token[t.peekCount-1]
+ }
+ t.peekCount = 1
+ t.token[0] = t.lex.nextItem()
+ return t.token[0]
+}
+
+// nextNonSpace returns the next non-space token.
+func (t *Tree) nextNonSpace() (token item) {
+ for {
+ token = t.next()
+ if token.typ != itemSpace {
+ break
+ }
+ }
+ return token
+}
+
+// peekNonSpace returns but does not consume the next non-space token.
+func (t *Tree) peekNonSpace() (token item) {
+ for {
+ token = t.next()
+ if token.typ != itemSpace {
+ break
+ }
+ }
+ t.backup()
+ return token
+}
+
+// Parsing.
+
+// New allocates a new parse tree with the given name.
+func New(name string, funcs ...map[string]interface{}) *Tree {
+ return &Tree{
+ Name: name,
+ funcs: funcs,
+ }
+}
+
+// ErrorContext returns a textual representation of the location of the node in the input text.
+// The receiver is only used when the node does not have a pointer to the tree inside,
+// which can occur in old code.
+func (t *Tree) ErrorContext(n Node) (location, context string) {
+ pos := int(n.Position())
+ tree := n.tree()
+ if tree == nil {
+ tree = t
+ }
+ text := tree.text[:pos]
+ byteNum := strings.LastIndex(text, "\n")
+ if byteNum == -1 {
+ byteNum = pos // On first line.
+ } else {
+ byteNum++ // After the newline.
+ byteNum = pos - byteNum
+ }
+ lineNum := 1 + strings.Count(text, "\n")
+ context = n.String()
+ if len(context) > 20 {
+ context = fmt.Sprintf("%.20s...", context)
+ }
+ return fmt.Sprintf("%s:%d:%d", tree.ParseName, lineNum, byteNum), context
+}
+
+// errorf formats the error and terminates processing.
+func (t *Tree) errorf(format string, args ...interface{}) {
+ t.Root = nil
+ format = fmt.Sprintf("template: %s:%d: %s", t.ParseName, t.lex.lineNumber(), format)
+ panic(fmt.Errorf(format, args...))
+}
+
+// error terminates processing.
+func (t *Tree) error(err error) {
+ t.errorf("%s", err)
+}
+
+// expect consumes the next token and guarantees it has the required type.
+func (t *Tree) expect(expected itemType, context string) item {
+ token := t.nextNonSpace()
+ if token.typ != expected {
+ t.unexpected(token, context)
+ }
+ return token
+}
+
+// expectOneOf consumes the next token and guarantees it has one of the required types.
+func (t *Tree) expectOneOf(expected1, expected2 itemType, context string) item {
+ token := t.nextNonSpace()
+ if token.typ != expected1 && token.typ != expected2 {
+ t.unexpected(token, context)
+ }
+ return token
+}
+
+// unexpected complains about the token and terminates processing.
+func (t *Tree) unexpected(token item, context string) {
+ t.errorf("unexpected %s in %s", token, context)
+}
+
+// recover is the handler that turns panics into returns from the top level of Parse.
+func (t *Tree) recover(errp *error) {
+ e := recover()
+ if e != nil {
+ if _, ok := e.(runtime.Error); ok {
+ panic(e)
+ }
+ if t != nil {
+ t.stopParse()
+ }
+ *errp = e.(error)
+ }
+ return
+}
+
+// startParse initializes the parser, using the lexer.
+func (t *Tree) startParse(funcs []map[string]interface{}, lex *lexer) {
+ t.Root = nil
+ t.lex = lex
+ t.vars = []string{"$"}
+ t.funcs = funcs
+}
+
+// stopParse terminates parsing.
+func (t *Tree) stopParse() {
+ t.lex = nil
+ t.vars = nil
+ t.funcs = nil
+}
+
+// Parse parses the template definition string to construct a representation of
+// the template for execution. If either action delimiter string is empty, the
+// default ("{{" or "}}") is used. Embedded template definitions are added to
+// the treeSet map.
+func (t *Tree) Parse(text, leftDelim, rightDelim string, treeSet map[string]*Tree, funcs ...map[string]interface{}) (tree *Tree, err error) {
+ defer t.recover(&err)
+ t.ParseName = t.Name
+ t.startParse(funcs, lex(t.Name, text, leftDelim, rightDelim))
+ t.text = text
+ t.parse(treeSet)
+ t.add(treeSet)
+ t.stopParse()
+ return t, nil
+}
+
+// add adds tree to the treeSet.
+func (t *Tree) add(treeSet map[string]*Tree) {
+ tree := treeSet[t.Name]
+ if tree == nil || IsEmptyTree(tree.Root) {
+ treeSet[t.Name] = t
+ return
+ }
+ if !IsEmptyTree(t.Root) {
+ t.errorf("template: multiple definition of template %q", t.Name)
+ }
+}
+
+// IsEmptyTree reports whether this tree (node) is empty of everything but space.
+func IsEmptyTree(n Node) bool {
+ switch n := n.(type) {
+ case nil:
+ return true
+ case *ActionNode:
+ case *IfNode:
+ case *ListNode:
+ for _, node := range n.Nodes {
+ if !IsEmptyTree(node) {
+ return false
+ }
+ }
+ return true
+ case *RangeNode:
+ case *TemplateNode:
+ case *TextNode:
+ return len(bytes.TrimSpace(n.Text)) == 0
+ case *WithNode:
+ default:
+ panic("unknown node: " + n.String())
+ }
+ return false
+}
+
+// parse is the top-level parser for a template, essentially the same
+// as itemList except it also parses {{define}} actions.
+// It runs to EOF.
+func (t *Tree) parse(treeSet map[string]*Tree) (next Node) {
+ t.Root = t.newList(t.peek().pos)
+ for t.peek().typ != itemEOF {
+ if t.peek().typ == itemLeftDelim {
+ delim := t.next()
+ if t.nextNonSpace().typ == itemDefine {
+ newT := New("definition") // name will be updated once we know it.
+ newT.text = t.text
+ newT.ParseName = t.ParseName
+ newT.startParse(t.funcs, t.lex)
+ newT.parseDefinition(treeSet)
+ continue
+ }
+ t.backup2(delim)
+ }
+ n := t.textOrAction()
+ if n.Type() == nodeEnd {
+ t.errorf("unexpected %s", n)
+ }
+ t.Root.append(n)
+ }
+ return nil
+}
+
+// parseDefinition parses a {{define}} ... {{end}} template definition and
+// installs the definition in the treeSet map. The "define" keyword has already
+// been scanned.
+func (t *Tree) parseDefinition(treeSet map[string]*Tree) {
+ const context = "define clause"
+ name := t.expectOneOf(itemString, itemRawString, context)
+ var err error
+ t.Name, err = strconv.Unquote(name.val)
+ if err != nil {
+ t.error(err)
+ }
+ t.expect(itemRightDelim, context)
+ var end Node
+ t.Root, end = t.itemList()
+ if end.Type() != nodeEnd {
+ t.errorf("unexpected %s in %s", end, context)
+ }
+ t.add(treeSet)
+ t.stopParse()
+}
+
+// itemList:
+// textOrAction*
+// Terminates at {{end}} or {{else}}, returned separately.
+func (t *Tree) itemList() (list *ListNode, next Node) {
+ list = t.newList(t.peekNonSpace().pos)
+ for t.peekNonSpace().typ != itemEOF {
+ n := t.textOrAction()
+ switch n.Type() {
+ case nodeEnd, nodeElse:
+ return list, n
+ }
+ list.append(n)
+ }
+ t.errorf("unexpected EOF")
+ return
+}
+
+// textOrAction:
+// text | action
+func (t *Tree) textOrAction() Node {
+ switch token := t.nextNonSpace(); token.typ {
+ case itemElideNewline:
+ return t.elideNewline()
+ case itemText:
+ return t.newText(token.pos, token.val)
+ case itemLeftDelim:
+ return t.action()
+ default:
+ t.unexpected(token, "input")
+ }
+ return nil
+}
+
+// elideNewline:
+// Remove newlines trailing rightDelim if \\ is present.
+func (t *Tree) elideNewline() Node {
+ token := t.peek()
+ if token.typ != itemText {
+ t.unexpected(token, "input")
+ return nil
+ }
+
+ t.next()
+ stripped := strings.TrimLeft(token.val, "\n\r")
+ diff := len(token.val) - len(stripped)
+ if diff > 0 {
+ // This is a bit nasty. We mutate the token in-place to remove
+ // preceding newlines.
+ token.pos += Pos(diff)
+ token.val = stripped
+ }
+ return t.newText(token.pos, token.val)
+}
+
+// Action:
+// control
+// command ("|" command)*
+// Left delim is past. Now get actions.
+// First word could be a keyword such as range.
+func (t *Tree) action() (n Node) {
+ switch token := t.nextNonSpace(); token.typ {
+ case itemElse:
+ return t.elseControl()
+ case itemEnd:
+ return t.endControl()
+ case itemIf:
+ return t.ifControl()
+ case itemRange:
+ return t.rangeControl()
+ case itemTemplate:
+ return t.templateControl()
+ case itemWith:
+ return t.withControl()
+ }
+ t.backup()
+ // Do not pop variables; they persist until "end".
+ return t.newAction(t.peek().pos, t.lex.lineNumber(), t.pipeline("command"))
+}
+
+// Pipeline:
+// declarations? command ('|' command)*
+func (t *Tree) pipeline(context string) (pipe *PipeNode) {
+ var decl []*VariableNode
+ pos := t.peekNonSpace().pos
+ // Are there declarations?
+ for {
+ if v := t.peekNonSpace(); v.typ == itemVariable {
+ t.next()
+ // Since space is a token, we need 3-token look-ahead here in the worst case:
+ // in "$x foo" we need to read "foo" (as opposed to ":=") to know that $x is an
+ // argument variable rather than a declaration. So remember the token
+ // adjacent to the variable so we can push it back if necessary.
+ tokenAfterVariable := t.peek()
+ if next := t.peekNonSpace(); next.typ == itemColonEquals || (next.typ == itemChar && next.val == ",") {
+ t.nextNonSpace()
+ variable := t.newVariable(v.pos, v.val)
+ decl = append(decl, variable)
+ t.vars = append(t.vars, v.val)
+ if next.typ == itemChar && next.val == "," {
+ if context == "range" && len(decl) < 2 {
+ continue
+ }
+ t.errorf("too many declarations in %s", context)
+ }
+ } else if tokenAfterVariable.typ == itemSpace {
+ t.backup3(v, tokenAfterVariable)
+ } else {
+ t.backup2(v)
+ }
+ }
+ break
+ }
+ pipe = t.newPipeline(pos, t.lex.lineNumber(), decl)
+ for {
+ switch token := t.nextNonSpace(); token.typ {
+ case itemRightDelim, itemRightParen:
+ if len(pipe.Cmds) == 0 {
+ t.errorf("missing value for %s", context)
+ }
+ if token.typ == itemRightParen {
+ t.backup()
+ }
+ return
+ case itemBool, itemCharConstant, itemComplex, itemDot, itemField, itemIdentifier,
+ itemNumber, itemNil, itemRawString, itemString, itemVariable, itemLeftParen:
+ t.backup()
+ pipe.append(t.command())
+ default:
+ t.unexpected(token, context)
+ }
+ }
+}
+
+func (t *Tree) parseControl(allowElseIf bool, context string) (pos Pos, line int, pipe *PipeNode, list, elseList *ListNode) {
+ defer t.popVars(len(t.vars))
+ line = t.lex.lineNumber()
+ pipe = t.pipeline(context)
+ var next Node
+ list, next = t.itemList()
+ switch next.Type() {
+ case nodeEnd: //done
+ case nodeElse:
+ if allowElseIf {
+ // Special case for "else if". If the "else" is followed immediately by an "if",
+ // the elseControl will have left the "if" token pending. Treat
+ // {{if a}}_{{else if b}}_{{end}}
+ // as
+ // {{if a}}_{{else}}{{if b}}_{{end}}{{end}}.
+ // To do this, parse the if as usual and stop at it {{end}}; the subsequent{{end}}
+ // is assumed. This technique works even for long if-else-if chains.
+ // TODO: Should we allow else-if in with and range?
+ if t.peek().typ == itemIf {
+ t.next() // Consume the "if" token.
+ elseList = t.newList(next.Position())
+ elseList.append(t.ifControl())
+ // Do not consume the next item - only one {{end}} required.
+ break
+ }
+ }
+ elseList, next = t.itemList()
+ if next.Type() != nodeEnd {
+ t.errorf("expected end; found %s", next)
+ }
+ }
+ return pipe.Position(), line, pipe, list, elseList
+}
+
+// If:
+// {{if pipeline}} itemList {{end}}
+// {{if pipeline}} itemList {{else}} itemList {{end}}
+// If keyword is past.
+func (t *Tree) ifControl() Node {
+ return t.newIf(t.parseControl(true, "if"))
+}
+
+// Range:
+// {{range pipeline}} itemList {{end}}
+// {{range pipeline}} itemList {{else}} itemList {{end}}
+// Range keyword is past.
+func (t *Tree) rangeControl() Node {
+ return t.newRange(t.parseControl(false, "range"))
+}
+
+// With:
+// {{with pipeline}} itemList {{end}}
+// {{with pipeline}} itemList {{else}} itemList {{end}}
+// If keyword is past.
+func (t *Tree) withControl() Node {
+ return t.newWith(t.parseControl(false, "with"))
+}
+
+// End:
+// {{end}}
+// End keyword is past.
+func (t *Tree) endControl() Node {
+ return t.newEnd(t.expect(itemRightDelim, "end").pos)
+}
+
+// Else:
+// {{else}}
+// Else keyword is past.
+func (t *Tree) elseControl() Node {
+ // Special case for "else if".
+ peek := t.peekNonSpace()
+ if peek.typ == itemIf {
+ // We see "{{else if ... " but in effect rewrite it to {{else}}{{if ... ".
+ return t.newElse(peek.pos, t.lex.lineNumber())
+ }
+ return t.newElse(t.expect(itemRightDelim, "else").pos, t.lex.lineNumber())
+}
+
+// Template:
+// {{template stringValue pipeline}}
+// Template keyword is past. The name must be something that can evaluate
+// to a string.
+func (t *Tree) templateControl() Node {
+ var name string
+ token := t.nextNonSpace()
+ switch token.typ {
+ case itemString, itemRawString:
+ s, err := strconv.Unquote(token.val)
+ if err != nil {
+ t.error(err)
+ }
+ name = s
+ default:
+ t.unexpected(token, "template invocation")
+ }
+ var pipe *PipeNode
+ if t.nextNonSpace().typ != itemRightDelim {
+ t.backup()
+ // Do not pop variables; they persist until "end".
+ pipe = t.pipeline("template")
+ }
+ return t.newTemplate(token.pos, t.lex.lineNumber(), name, pipe)
+}
+
+// command:
+// operand (space operand)*
+// space-separated arguments up to a pipeline character or right delimiter.
+// we consume the pipe character but leave the right delim to terminate the action.
+func (t *Tree) command() *CommandNode {
+ cmd := t.newCommand(t.peekNonSpace().pos)
+ for {
+ t.peekNonSpace() // skip leading spaces.
+ operand := t.operand()
+ if operand != nil {
+ cmd.append(operand)
+ }
+ switch token := t.next(); token.typ {
+ case itemSpace:
+ continue
+ case itemError:
+ t.errorf("%s", token.val)
+ case itemRightDelim, itemRightParen:
+ t.backup()
+ case itemPipe:
+ default:
+ t.errorf("unexpected %s in operand; missing space?", token)
+ }
+ break
+ }
+ if len(cmd.Args) == 0 {
+ t.errorf("empty command")
+ }
+ return cmd
+}
+
+// operand:
+// term .Field*
+// An operand is a space-separated component of a command,
+// a term possibly followed by field accesses.
+// A nil return means the next item is not an operand.
+func (t *Tree) operand() Node {
+ node := t.term()
+ if node == nil {
+ return nil
+ }
+ if t.peek().typ == itemField {
+ chain := t.newChain(t.peek().pos, node)
+ for t.peek().typ == itemField {
+ chain.Add(t.next().val)
+ }
+ // Compatibility with original API: If the term is of type NodeField
+ // or NodeVariable, just put more fields on the original.
+ // Otherwise, keep the Chain node.
+ // TODO: Switch to Chains always when we can.
+ switch node.Type() {
+ case NodeField:
+ node = t.newField(chain.Position(), chain.String())
+ case NodeVariable:
+ node = t.newVariable(chain.Position(), chain.String())
+ default:
+ node = chain
+ }
+ }
+ return node
+}
+
+// term:
+// literal (number, string, nil, boolean)
+// function (identifier)
+// .
+// .Field
+// $
+// '(' pipeline ')'
+// A term is a simple "expression".
+// A nil return means the next item is not a term.
+func (t *Tree) term() Node {
+ switch token := t.nextNonSpace(); token.typ {
+ case itemError:
+ t.errorf("%s", token.val)
+ case itemIdentifier:
+ if !t.hasFunction(token.val) {
+ t.errorf("function %q not defined", token.val)
+ }
+ return NewIdentifier(token.val).SetTree(t).SetPos(token.pos)
+ case itemDot:
+ return t.newDot(token.pos)
+ case itemNil:
+ return t.newNil(token.pos)
+ case itemVariable:
+ return t.useVar(token.pos, token.val)
+ case itemField:
+ return t.newField(token.pos, token.val)
+ case itemBool:
+ return t.newBool(token.pos, token.val == "true")
+ case itemCharConstant, itemComplex, itemNumber:
+ number, err := t.newNumber(token.pos, token.val, token.typ)
+ if err != nil {
+ t.error(err)
+ }
+ return number
+ case itemLeftParen:
+ pipe := t.pipeline("parenthesized pipeline")
+ if token := t.next(); token.typ != itemRightParen {
+ t.errorf("unclosed right paren: unexpected %s", token)
+ }
+ return pipe
+ case itemString, itemRawString:
+ s, err := strconv.Unquote(token.val)
+ if err != nil {
+ t.error(err)
+ }
+ return t.newString(token.pos, token.val, s)
+ }
+ t.backup()
+ return nil
+}
+
+// hasFunction reports if a function name exists in the Tree's maps.
+func (t *Tree) hasFunction(name string) bool {
+ for _, funcMap := range t.funcs {
+ if funcMap == nil {
+ continue
+ }
+ if funcMap[name] != nil {
+ return true
+ }
+ }
+ return false
+}
+
+// popVars trims the variable list to the specified length
+func (t *Tree) popVars(n int) {
+ t.vars = t.vars[:n]
+}
+
+// useVar returns a node for a variable reference. It errors if the
+// variable is not defined.
+func (t *Tree) useVar(pos Pos, name string) Node {
+ v := t.newVariable(pos, name)
+ for _, varName := range t.vars {
+ if varName == v.Ident[0] {
+ return v
+ }
+ }
+ t.errorf("undefined variable %q", v.Ident[0])
+ return nil
+}
diff --git a/vendor/github.com/alecthomas/template/template.go b/vendor/github.com/alecthomas/template/template.go
new file mode 100644
index 0000000..447ed2a
--- /dev/null
+++ b/vendor/github.com/alecthomas/template/template.go
@@ -0,0 +1,218 @@
+// Copyright 2011 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package template
+
+import (
+ "fmt"
+ "reflect"
+
+ "github.com/alecthomas/template/parse"
+)
+
+// common holds the information shared by related templates.
+type common struct {
+ tmpl map[string]*Template
+ // We use two maps, one for parsing and one for execution.
+ // This separation makes the API cleaner since it doesn't
+ // expose reflection to the client.
+ parseFuncs FuncMap
+ execFuncs map[string]reflect.Value
+}
+
+// Template is the representation of a parsed template. The *parse.Tree
+// field is exported only for use by html/template and should be treated
+// as unexported by all other clients.
+type Template struct {
+ name string
+ *parse.Tree
+ *common
+ leftDelim string
+ rightDelim string
+}
+
+// New allocates a new template with the given name.
+func New(name string) *Template {
+ return &Template{
+ name: name,
+ }
+}
+
+// Name returns the name of the template.
+func (t *Template) Name() string {
+ return t.name
+}
+
+// New allocates a new template associated with the given one and with the same
+// delimiters. The association, which is transitive, allows one template to
+// invoke another with a {{template}} action.
+func (t *Template) New(name string) *Template {
+ t.init()
+ return &Template{
+ name: name,
+ common: t.common,
+ leftDelim: t.leftDelim,
+ rightDelim: t.rightDelim,
+ }
+}
+
+func (t *Template) init() {
+ if t.common == nil {
+ t.common = new(common)
+ t.tmpl = make(map[string]*Template)
+ t.parseFuncs = make(FuncMap)
+ t.execFuncs = make(map[string]reflect.Value)
+ }
+}
+
+// Clone returns a duplicate of the template, including all associated
+// templates. The actual representation is not copied, but the name space of
+// associated templates is, so further calls to Parse in the copy will add
+// templates to the copy but not to the original. Clone can be used to prepare
+// common templates and use them with variant definitions for other templates
+// by adding the variants after the clone is made.
+func (t *Template) Clone() (*Template, error) {
+ nt := t.copy(nil)
+ nt.init()
+ nt.tmpl[t.name] = nt
+ for k, v := range t.tmpl {
+ if k == t.name { // Already installed.
+ continue
+ }
+ // The associated templates share nt's common structure.
+ tmpl := v.copy(nt.common)
+ nt.tmpl[k] = tmpl
+ }
+ for k, v := range t.parseFuncs {
+ nt.parseFuncs[k] = v
+ }
+ for k, v := range t.execFuncs {
+ nt.execFuncs[k] = v
+ }
+ return nt, nil
+}
+
+// copy returns a shallow copy of t, with common set to the argument.
+func (t *Template) copy(c *common) *Template {
+ nt := New(t.name)
+ nt.Tree = t.Tree
+ nt.common = c
+ nt.leftDelim = t.leftDelim
+ nt.rightDelim = t.rightDelim
+ return nt
+}
+
+// AddParseTree creates a new template with the name and parse tree
+// and associates it with t.
+func (t *Template) AddParseTree(name string, tree *parse.Tree) (*Template, error) {
+ if t.common != nil && t.tmpl[name] != nil {
+ return nil, fmt.Errorf("template: redefinition of template %q", name)
+ }
+ nt := t.New(name)
+ nt.Tree = tree
+ t.tmpl[name] = nt
+ return nt, nil
+}
+
+// Templates returns a slice of the templates associated with t, including t
+// itself.
+func (t *Template) Templates() []*Template {
+ if t.common == nil {
+ return nil
+ }
+ // Return a slice so we don't expose the map.
+ m := make([]*Template, 0, len(t.tmpl))
+ for _, v := range t.tmpl {
+ m = append(m, v)
+ }
+ return m
+}
+
+// Delims sets the action delimiters to the specified strings, to be used in
+// subsequent calls to Parse, ParseFiles, or ParseGlob. Nested template
+// definitions will inherit the settings. An empty delimiter stands for the
+// corresponding default: {{ or }}.
+// The return value is the template, so calls can be chained.
+func (t *Template) Delims(left, right string) *Template {
+ t.leftDelim = left
+ t.rightDelim = right
+ return t
+}
+
+// Funcs adds the elements of the argument map to the template's function map.
+// It panics if a value in the map is not a function with appropriate return
+// type. However, it is legal to overwrite elements of the map. The return
+// value is the template, so calls can be chained.
+func (t *Template) Funcs(funcMap FuncMap) *Template {
+ t.init()
+ addValueFuncs(t.execFuncs, funcMap)
+ addFuncs(t.parseFuncs, funcMap)
+ return t
+}
+
+// Lookup returns the template with the given name that is associated with t,
+// or nil if there is no such template.
+func (t *Template) Lookup(name string) *Template {
+ if t.common == nil {
+ return nil
+ }
+ return t.tmpl[name]
+}
+
+// Parse parses a string into a template. Nested template definitions will be
+// associated with the top-level template t. Parse may be called multiple times
+// to parse definitions of templates to associate with t. It is an error if a
+// resulting template is non-empty (contains content other than template
+// definitions) and would replace a non-empty template with the same name.
+// (In multiple calls to Parse with the same receiver template, only one call
+// can contain text other than space, comments, and template definitions.)
+func (t *Template) Parse(text string) (*Template, error) {
+ t.init()
+ trees, err := parse.Parse(t.name, text, t.leftDelim, t.rightDelim, t.parseFuncs, builtins)
+ if err != nil {
+ return nil, err
+ }
+ // Add the newly parsed trees, including the one for t, into our common structure.
+ for name, tree := range trees {
+ // If the name we parsed is the name of this template, overwrite this template.
+ // The associate method checks it's not a redefinition.
+ tmpl := t
+ if name != t.name {
+ tmpl = t.New(name)
+ }
+ // Even if t == tmpl, we need to install it in the common.tmpl map.
+ if replace, err := t.associate(tmpl, tree); err != nil {
+ return nil, err
+ } else if replace {
+ tmpl.Tree = tree
+ }
+ tmpl.leftDelim = t.leftDelim
+ tmpl.rightDelim = t.rightDelim
+ }
+ return t, nil
+}
+
+// associate installs the new template into the group of templates associated
+// with t. It is an error to reuse a name except to overwrite an empty
+// template. The two are already known to share the common structure.
+// The boolean return value reports wither to store this tree as t.Tree.
+func (t *Template) associate(new *Template, tree *parse.Tree) (bool, error) {
+ if new.common != t.common {
+ panic("internal error: associate not common")
+ }
+ name := new.name
+ if old := t.tmpl[name]; old != nil {
+ oldIsEmpty := parse.IsEmptyTree(old.Root)
+ newIsEmpty := parse.IsEmptyTree(tree.Root)
+ if newIsEmpty {
+ // Whether old is empty or not, new is empty; no reason to replace old.
+ return false, nil
+ }
+ if !oldIsEmpty {
+ return false, fmt.Errorf("template: redefinition of template %q", name)
+ }
+ }
+ t.tmpl[name] = new
+ return true, nil
+}
diff --git a/vendor/github.com/alecthomas/units/COPYING b/vendor/github.com/alecthomas/units/COPYING
new file mode 100644
index 0000000..2993ec0
--- /dev/null
+++ b/vendor/github.com/alecthomas/units/COPYING
@@ -0,0 +1,19 @@
+Copyright (C) 2014 Alec Thomas
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of
+this software and associated documentation files (the "Software"), to deal in
+the Software without restriction, including without limitation the rights to
+use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
+of the Software, and to permit persons to whom the Software is furnished to do
+so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git a/vendor/github.com/alecthomas/units/README.md b/vendor/github.com/alecthomas/units/README.md
new file mode 100644
index 0000000..bee884e
--- /dev/null
+++ b/vendor/github.com/alecthomas/units/README.md
@@ -0,0 +1,11 @@
+# Units - Helpful unit multipliers and functions for Go
+
+The goal of this package is to have functionality similar to the [time](http://golang.org/pkg/time/) package.
+
+It allows for code like this:
+
+```go
+n, err := ParseBase2Bytes("1KB")
+// n == 1024
+n = units.Mebibyte * 512
+```
diff --git a/vendor/github.com/alecthomas/units/bytes.go b/vendor/github.com/alecthomas/units/bytes.go
new file mode 100644
index 0000000..eaadeb8
--- /dev/null
+++ b/vendor/github.com/alecthomas/units/bytes.go
@@ -0,0 +1,83 @@
+package units
+
+// Base2Bytes is the old non-SI power-of-2 byte scale (1024 bytes in a kilobyte,
+// etc.).
+type Base2Bytes int64
+
+// Base-2 byte units.
+const (
+ Kibibyte Base2Bytes = 1024
+ KiB = Kibibyte
+ Mebibyte = Kibibyte * 1024
+ MiB = Mebibyte
+ Gibibyte = Mebibyte * 1024
+ GiB = Gibibyte
+ Tebibyte = Gibibyte * 1024
+ TiB = Tebibyte
+ Pebibyte = Tebibyte * 1024
+ PiB = Pebibyte
+ Exbibyte = Pebibyte * 1024
+ EiB = Exbibyte
+)
+
+var (
+ bytesUnitMap = MakeUnitMap("iB", "B", 1024)
+ oldBytesUnitMap = MakeUnitMap("B", "B", 1024)
+)
+
+// ParseBase2Bytes supports both iB and B in base-2 multipliers. That is, KB
+// and KiB are both 1024.
+func ParseBase2Bytes(s string) (Base2Bytes, error) {
+ n, err := ParseUnit(s, bytesUnitMap)
+ if err != nil {
+ n, err = ParseUnit(s, oldBytesUnitMap)
+ }
+ return Base2Bytes(n), err
+}
+
+func (b Base2Bytes) String() string {
+ return ToString(int64(b), 1024, "iB", "B")
+}
+
+var (
+ metricBytesUnitMap = MakeUnitMap("B", "B", 1000)
+)
+
+// MetricBytes are SI byte units (1000 bytes in a kilobyte).
+type MetricBytes SI
+
+// SI base-10 byte units.
+const (
+ Kilobyte MetricBytes = 1000
+ KB = Kilobyte
+ Megabyte = Kilobyte * 1000
+ MB = Megabyte
+ Gigabyte = Megabyte * 1000
+ GB = Gigabyte
+ Terabyte = Gigabyte * 1000
+ TB = Terabyte
+ Petabyte = Terabyte * 1000
+ PB = Petabyte
+ Exabyte = Petabyte * 1000
+ EB = Exabyte
+)
+
+// ParseMetricBytes parses base-10 metric byte units. That is, KB is 1000 bytes.
+func ParseMetricBytes(s string) (MetricBytes, error) {
+ n, err := ParseUnit(s, metricBytesUnitMap)
+ return MetricBytes(n), err
+}
+
+func (m MetricBytes) String() string {
+ return ToString(int64(m), 1000, "B", "B")
+}
+
+// ParseStrictBytes supports both iB and B suffixes for base 2 and metric,
+// respectively. That is, KiB represents 1024 and KB represents 1000.
+func ParseStrictBytes(s string) (int64, error) {
+ n, err := ParseUnit(s, bytesUnitMap)
+ if err != nil {
+ n, err = ParseUnit(s, metricBytesUnitMap)
+ }
+ return int64(n), err
+}
diff --git a/vendor/github.com/alecthomas/units/doc.go b/vendor/github.com/alecthomas/units/doc.go
new file mode 100644
index 0000000..156ae38
--- /dev/null
+++ b/vendor/github.com/alecthomas/units/doc.go
@@ -0,0 +1,13 @@
+// Package units provides helpful unit multipliers and functions for Go.
+//
+// The goal of this package is to have functionality similar to the time [1] package.
+//
+//
+// [1] http://golang.org/pkg/time/
+//
+// It allows for code like this:
+//
+// n, err := ParseBase2Bytes("1KB")
+// // n == 1024
+// n = units.Mebibyte * 512
+package units
diff --git a/vendor/github.com/alecthomas/units/si.go b/vendor/github.com/alecthomas/units/si.go
new file mode 100644
index 0000000..8234a9d
--- /dev/null
+++ b/vendor/github.com/alecthomas/units/si.go
@@ -0,0 +1,26 @@
+package units
+
+// SI units.
+type SI int64
+
+// SI unit multiples.
+const (
+ Kilo SI = 1000
+ Mega = Kilo * 1000
+ Giga = Mega * 1000
+ Tera = Giga * 1000
+ Peta = Tera * 1000
+ Exa = Peta * 1000
+)
+
+func MakeUnitMap(suffix, shortSuffix string, scale int64) map[string]float64 {
+ return map[string]float64{
+ shortSuffix: 1,
+ "K" + suffix: float64(scale),
+ "M" + suffix: float64(scale * scale),
+ "G" + suffix: float64(scale * scale * scale),
+ "T" + suffix: float64(scale * scale * scale * scale),
+ "P" + suffix: float64(scale * scale * scale * scale * scale),
+ "E" + suffix: float64(scale * scale * scale * scale * scale * scale),
+ }
+}
diff --git a/vendor/github.com/alecthomas/units/util.go b/vendor/github.com/alecthomas/units/util.go
new file mode 100644
index 0000000..6527e92
--- /dev/null
+++ b/vendor/github.com/alecthomas/units/util.go
@@ -0,0 +1,138 @@
+package units
+
+import (
+ "errors"
+ "fmt"
+ "strings"
+)
+
+var (
+ siUnits = []string{"", "K", "M", "G", "T", "P", "E"}
+)
+
+func ToString(n int64, scale int64, suffix, baseSuffix string) string {
+ mn := len(siUnits)
+ out := make([]string, mn)
+ for i, m := range siUnits {
+ if n%scale != 0 || i == 0 && n == 0 {
+ s := suffix
+ if i == 0 {
+ s = baseSuffix
+ }
+ out[mn-1-i] = fmt.Sprintf("%d%s%s", n%scale, m, s)
+ }
+ n /= scale
+ if n == 0 {
+ break
+ }
+ }
+ return strings.Join(out, "")
+}
+
+// Below code ripped straight from http://golang.org/src/pkg/time/format.go?s=33392:33438#L1123
+var errLeadingInt = errors.New("units: bad [0-9]*") // never printed
+
+// leadingInt consumes the leading [0-9]* from s.
+func leadingInt(s string) (x int64, rem string, err error) {
+ i := 0
+ for ; i < len(s); i++ {
+ c := s[i]
+ if c < '0' || c > '9' {
+ break
+ }
+ if x >= (1<<63-10)/10 {
+ // overflow
+ return 0, "", errLeadingInt
+ }
+ x = x*10 + int64(c) - '0'
+ }
+ return x, s[i:], nil
+}
+
+func ParseUnit(s string, unitMap map[string]float64) (int64, error) {
+ // [-+]?([0-9]*(\.[0-9]*)?[a-z]+)+
+ orig := s
+ f := float64(0)
+ neg := false
+
+ // Consume [-+]?
+ if s != "" {
+ c := s[0]
+ if c == '-' || c == '+' {
+ neg = c == '-'
+ s = s[1:]
+ }
+ }
+ // Special case: if all that is left is "0", this is zero.
+ if s == "0" {
+ return 0, nil
+ }
+ if s == "" {
+ return 0, errors.New("units: invalid " + orig)
+ }
+ for s != "" {
+ g := float64(0) // this element of the sequence
+
+ var x int64
+ var err error
+
+ // The next character must be [0-9.]
+ if !(s[0] == '.' || ('0' <= s[0] && s[0] <= '9')) {
+ return 0, errors.New("units: invalid " + orig)
+ }
+ // Consume [0-9]*
+ pl := len(s)
+ x, s, err = leadingInt(s)
+ if err != nil {
+ return 0, errors.New("units: invalid " + orig)
+ }
+ g = float64(x)
+ pre := pl != len(s) // whether we consumed anything before a period
+
+ // Consume (\.[0-9]*)?
+ post := false
+ if s != "" && s[0] == '.' {
+ s = s[1:]
+ pl := len(s)
+ x, s, err = leadingInt(s)
+ if err != nil {
+ return 0, errors.New("units: invalid " + orig)
+ }
+ scale := 1.0
+ for n := pl - len(s); n > 0; n-- {
+ scale *= 10
+ }
+ g += float64(x) / scale
+ post = pl != len(s)
+ }
+ if !pre && !post {
+ // no digits (e.g. ".s" or "-.s")
+ return 0, errors.New("units: invalid " + orig)
+ }
+
+ // Consume unit.
+ i := 0
+ for ; i < len(s); i++ {
+ c := s[i]
+ if c == '.' || ('0' <= c && c <= '9') {
+ break
+ }
+ }
+ u := s[:i]
+ s = s[i:]
+ unit, ok := unitMap[u]
+ if !ok {
+ return 0, errors.New("units: unknown unit " + u + " in " + orig)
+ }
+
+ f += g * unit
+ }
+
+ if neg {
+ f = -f
+ }
+ if f < float64(-1<<63) || f > float64(1<<63-1) {
+ return 0, errors.New("units: overflow parsing unit")
+ }
+ return int64(f), nil
+}
diff --git a/vendor/vendor.json b/vendor/vendor.json
index 3308712..dc6278d 100644
--- a/vendor/vendor.json
+++ b/vendor/vendor.json
@@ -8,6 +8,24 @@
"revision": "6fc9e945968728bdf662e5a9f2d4b97f5a24dd03",
"revisionTime": "2016-10-21T13:40:32Z"
},
+ {
+ "checksumSHA1": "KmjnydoAbofMieIWm+it5OWERaM=",
+ "path": "github.com/alecthomas/template",
+ "revision": "a0175ee3bccc567396460bf5acd36800cb10c49c",
+ "revisionTime": "2016-04-05T07:15:01Z"
+ },
+ {
+ "checksumSHA1": "3wt0pTXXeS+S93unwhGoLIyGX/Q=",
+ "path": "github.com/alecthomas/template/parse",
+ "revision": "a0175ee3bccc567396460bf5acd36800cb10c49c",
+ "revisionTime": "2016-04-05T07:15:01Z"
+ },
+ {
+ "checksumSHA1": "fCc3grA7vIxfBru7R3SqjcW+oLI=",
+ "path": "github.com/alecthomas/units",
+ "revision": "2efee857e7cfd4f3d0138cc3cbb1b4966962b93a",
+ "revisionTime": "2015-10-22T06:55:26Z"
+ },
{
"checksumSHA1": "QD6LqgLz2JMxXqns8TaxtK9AuHs=",
"path": "github.com/go-sql-driver/mysql",