Jelajahi Sumber

Initial commit

Michael Zitzmann 5 tahun lalu
melakukan
d6d916ec10
39 mengubah file dengan 7422 tambahan dan 0 penghapusan
  1. 4 0
      .babelrc
  2. 32 0
      .eslintrc.json
  3. 4 0
      .gitignore
  4. 3 0
      .stylelintrc.json
  5. 110 0
      README.md
  6. 36 0
      assets/css/index.css
  7. TEMPAT SAMPAH
      assets/fonts/Asap-Bold.ttf
  8. TEMPAT SAMPAH
      assets/fonts/Asap-Italic.ttf
  9. TEMPAT SAMPAH
      assets/fonts/Asap-Regular.ttf
  10. TEMPAT SAMPAH
      assets/fonts/AsapCondensed-Regular.ttf
  11. TEMPAT SAMPAH
      assets/fonts/lora/Lora-Regular.ttf
  12. 44 0
      assets/fonts/lora/SIL Open Font License.txt
  13. TEMPAT SAMPAH
      assets/fonts/montserrat/Montserrat-SemiBold.otf
  14. 43 0
      assets/fonts/montserrat/SIL Open Font License.txt
  15. TEMPAT SAMPAH
      assets/img/BMJV_Web_Master_de_WBZ.png
  16. TEMPAT SAMPAH
      assets/img/HardingCenter_Logo_de_RGB.png
  17. TEMPAT SAMPAH
      assets/img/Risikoradar.jpg
  18. TEMPAT SAMPAH
      assets/img/hc.png
  19. TEMPAT SAMPAH
      assets/img/mpib.png
  20. 4684 0
      assets/js/blob-stream.js
  21. 0 0
      assets/js/blob-stream.min.js
  22. 673 0
      assets/js/pdfkit.js
  23. 0 0
      assets/js/pdfkit.min.js
  24. 134 0
      bin/prepareData.js
  25. 119 0
      bin/preprocess.js
  26. 39 0
      build.json
  27. 73 0
      data/context.md
  28. 72 0
      data/crime.tsv
  29. TEMPAT SAMPAH
      data/original/Kriminalität_2016-12-23.xlsx
  30. TEMPAT SAMPAH
      data/original/Kriminalität_2017-01-15.xlsx
  31. 56 0
      package.json
  32. 101 0
      rollup.config.js
  33. 201 0
      src/css/main.css
  34. 73 0
      src/html/markdown/index.md
  35. 14 0
      src/html/skeletons/main.html
  36. 56 0
      src/html/skeletons/visualisation.html
  37. 64 0
      src/js/config.json
  38. 8 0
      src/js/d3-custom.js
  39. 779 0
      src/js/main.js

+ 4 - 0
.babelrc

@@ -0,0 +1,4 @@
+{
+    presets: ["@babel/preset-env"],
+    exclude: "node_modules/**"
+}

+ 32 - 0
.eslintrc.json

@@ -0,0 +1,32 @@
+{
+    "env": {
+        "browser": true,
+        "es6": true
+    },
+    "globals": {
+        "ENV": true,
+        "process": true
+    },
+    "extends": ["plugin:json/recommended", "eslint:recommended"],
+    "parserOptions": {
+        "sourceType": "module"
+    },
+    "rules": {
+        "indent": [
+            "error", 4,
+            { "SwitchCase": 1 }
+        ],
+        "linebreak-style": [
+            "error",
+            "unix"
+        ],
+        "quotes": [
+            "error",
+            "single"
+        ],
+        "semi": [
+            "error",
+            "always"
+        ]
+    }
+}

+ 4 - 0
.gitignore

@@ -0,0 +1,4 @@
+package-lock.json
+node_modules
+dist
+build

+ 3 - 0
.stylelintrc.json

@@ -0,0 +1,3 @@
+{
+  "extends": "stylelint-config-recommended"
+}

+ 110 - 0
README.md

@@ -0,0 +1,110 @@
+# Crime Visualisierung
+
+## Entwicklungsumgebung
+
+Um dieses Projekt zu ändern oder weiterzuentwickeln, werden [`nodejs`][nodejs] und `npm` benötigt. Die Abhängigkeiten werden wie üblich per `npm install` installiert.
+
+Für die Entwicklung wurden Teile von ES6 verwendet und mit [`rollup`][rollup], [`babel`][babel] und [`postcss`][postcss] transpiliert. Als *Build Management Tool* werden einfache `npm` Scripts verwendet.
+
+`npm run watch` beispielsweis startet den Entwicklungsserver, transformiert Javascript und CSS Dateien bei Änderungen für das *Development* Target und lädt die Visualisierung im Browser.
+
+Die folgenden Scripts sind in `package.json` definiert und können entsprechend mit `npm run …` ausgeführt werden:
+```
+- prepare         Wird ausgeführt, nachdem `npm install` aufgerufen wurde. In diesem Schritt werden die statischen Abhängigkeiten erstellt.
+- build           Generiert Javascript und CSS Dateien (einmalig) und kopiert alle generierten Dateien inklusive html-Dateien in das Verzeichnis `dist`.
+- build:data      Transformiert die Rohdaten in eine JSON-Datei für die Visualisierung.
+- build:html      Generiert HTML Dateien für Visualisierung und umgebenden Text.
+- build:static    Generiert die von der Anwendung benötigten JSON- und HTML-Dateien.
+- build:dev       Generiert Javascript und CSS Dateien für einen *Development Build*.
+- build:prod      Generiert Javascript und CSS Dateien für einen *Production Build*.
+- watch           Startet den Entwicklungsserver führt bei Änderungen einen Development Build durch.
+```
+
+In der Datei `rollup.config.js` werden die Konfigurationen für `rollup` und `postcss` dynamisch generiert. Für den *Development Build* werden SourceMaps erstellt, dagegen werden Javascript und CSS Dateien für den *Production Build* mit [`terser`][terser] bzw. [`cssnano`][cssnano] optimiert.
+
+Die HTML-Dateien werden von einem nodejs Script für das entsprechende *Target* generiert (momentan kann man die Sinnhaftigkeit bezweifeln, nachdem nur die geladenen Resourcen verschieden benannt werden). Leider ist HTML5 mit dem Versuch [gescheitert, HTML imports zu standardisieren][html5-imports]. Als pragmatische Alternative, und um möglichst flexibel zu bleiben, wurde daher entschieden, die eigentliche Visualisierung per `iframe` in der umgebenden Webseite einzubetten.
+
+Für einen vereinfachten Workflow wird hier der Rahmentext für diese Seite aus einem Markdown Dokument in HTML konvertiert. Der darin enthaltene `iframe` *Tag* wird dynamisch konfiguriert und das Ergebnis in einer HTML-Datei gespeichert.
+
+Die Datei `config.json` enthält die Konfigurationen sowohl zum Generieren der HTML-Dateien als auch für die Erstellung der Javascript- und CSS-Dateien.
+
+Nach dem Ausführen eines *Builds* sind alle Dateien, die für die Funktionalität der Website / Web App erforderlich sind im Verzeichnis `dist` zu finden:
+
+```
+├── index.html                            Diese HTML-Seite ist der Einstiegspunkt und wird vom Web-Server ausgeliefert
+├── crime.html                            Die Visualisierung wird in einem iframe in der index.html eingebunden
+├── css
+│   ├── index.css                         Stylesheet für die umgebende Webseite
+│   └── main[.min].css                    Stylesheet für die Visualisierung
+├── data
+│   ├── data_de.json                      Daten der Visualisierung (deutsch)
+│   └── data_en.json                      Daten der Visualisierung (englisch)
+├── fonts
+│   ├── ASAP                              Fonts für die Visualisierung
+│   ├── montserrat                        Font für Überschriften der umgebenden Seite (wird entfallen)
+│   └── lora                              Font für den Fließtext der umgebenden Seite (wird entfallen)
+├── img
+│   ├── BMJV_Web_Master_de_WBZ.png        BMJV Logo
+│   ├── HardingCenter_Logo_de_RGB.png     Harding Zentrum Logo
+│   └── mpib.png                          Max-Planck Institut fuur Bildungsforschung Logo
+└── js
+    ├── main.min.js                       Javascript der Visualisierung
+    ├── blob-stream.min.js                Wird von pdfkit benötigt
+    └── pdfkit.min.js                     Fettleibige Bibliothek zum generieren von PDF Dateien im Browser  
+```
+
+Dieses Verzeichnis kann von einem Webserver ausgeliefert werden, um die Visualiserung online zur Verfügung zu stellen.
+
+## Verzeichnisstruktur
+
+```
+├── bin
+│   ├── crime.js                        // Generiert data.json aus crime.tsv
+│   ├── preprocess.js                   // Generiert HTML Dateien für Visualisierung und umgebendes HTML
+├── data
+│   ├── context.md                      // Inhalt der umgebenden HTML Seite
+│   └── crime.tsv                       // Rohdaten
+├── html
+│   ├── markdown
+│   │   └── index.md                    // Markdown für HTML Seite mit Kontextinformationen
+│   └── skeletons
+│       ├── main.html                   // Template für umgebende HTML Seite
+│       └── visualisation.htmL          // Template für HTML Seite der Visualisierung
+├── package.json
+├── rollup.config.js                    // Build Prozess
+├── src
+│   ├── config.json                     // Konfiguration der Visualisierung
+│   ├── d3-custom.js                    // Definition der verwendeten d3 Module
+│   └── main.js                         // Implementierung der Visualisierung
+└── styles
+    └── main.css                        // Stildefinitionen
+```
+
+## Wie ändere ich Inhalte und Daten?
+
+### Texte und Labels
+
+Der Text der umgebenden HTML Datei ist in `data/context.md` zu finden. Diese Markdown Datei wird im Schritt `build:html` zu HTML konvertiert. Gleichzeitig wird auch die Größe iframes festgelegt und die einzubindende HTML Datei der Visualisierung mit den entsprechenden Referenzen zu den Javascript und CSS Dateien erstellt.
+
+Die statischen Labels der Visualisierung sind in `src/config.json` definiert. Alle anderen Informationen werden aus den Daten bezogen.
+
+### Daten
+
+Für diese Treemap Visualisierung sind die hierarchischen Rohdaten in der Datei `data/crime.tsv` definiert. Bevor sie in der Visualisierung verwendet werden können, müssen sie in eine JSON Datei transformiert werden. Dies geschieht im Schrit `build:data` des Build Prozesses. Bei Beibehaltung der Struktur der Daten können diese so beliebig ausgetauscht werden.
+
+### Drop-Down Menüs
+
+Die Werte in den Drop-Down Menüs sind derzeit noch im HTML-Template der Visualisierung definiert.
+
+## Historisches
+
+Ursprünglich wurde diese Visualisierung von *Data Science & Stories* entwickelt (inzwischen in einem Ressort des [Tagesspiegel][tagesspiegel] aufgegangen).
+
+[nodejs]: https://nodejs.org/
+[rollup]: http://rollupjs.org/
+[babel]: https://babeljs.io/
+[postcss]: https://postcss.org
+[terser]: https://terser.org
+[cssnano]: https://cssnano.co
+[html5-imports]: https://caniuse.com/#search=html%20imports
+[tagesspiegel]: https://digitalpresent.tagesspiegel.de

+ 36 - 0
assets/css/index.css

@@ -0,0 +1,36 @@
+@font-face {
+    font-family: "Montserrat";
+    src: url("../fonts/montserrat/Montserrat-SemiBold.otf");
+}
+@font-face {
+    font-family: "Lora";
+    src: url("../fonts/lora/Lora-Regular.ttf");
+}
+body {
+    font-family: "Lora", "Helvetica Neue", Helvetica, Arial, sans-serif;
+    line-height: 1.5;
+}
+
+main {
+    margin: 0 auto;
+    max-width: 64em;
+}
+
+h1, h2 {
+    color: #262525;
+    font-family: "Montserrat", "Helvetica Neue", Helvetica, Arial, sans-serif;
+    font-weight: 700;
+    margin: 35px 0 35px;
+}
+
+iframe {
+    display: block;
+    margin: 0 auto;
+}
+
+.logos {
+    align-items: center;
+    display: flex;
+    justify-content: space-between;
+    margin: 2rem 0;
+}

TEMPAT SAMPAH
assets/fonts/Asap-Bold.ttf


TEMPAT SAMPAH
assets/fonts/Asap-Italic.ttf


TEMPAT SAMPAH
assets/fonts/Asap-Regular.ttf


TEMPAT SAMPAH
assets/fonts/AsapCondensed-Regular.ttf


TEMPAT SAMPAH
assets/fonts/lora/Lora-Regular.ttf


+ 44 - 0
assets/fonts/lora/SIL Open Font License.txt

@@ -0,0 +1,44 @@
+Copyright (c) 2011-2013, Cyreal (www.cyreal.org a@cyreal.org), with
+Reserved Font Name 'Lora'
+
+This Font Software is licensed under the SIL Open Font License, Version 1.1.
+This license is copied below, and is also available with a FAQ at: http://scripts.sil.org/OFL
+
+-----------------------------------------------------------
+SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
+-----------------------------------------------------------
+
+PREAMBLE
+The goals of the Open Font License (OFL) are to stimulate worldwide development of collaborative font projects, to support the font creation efforts of academic and linguistic communities, and to provide a free and open framework in which fonts may be shared and improved in partnership with others.
+
+The OFL allows the licensed fonts to be used, studied, modified and redistributed freely as long as they are not sold by themselves. The fonts, including any derivative works, can be bundled, embedded, redistributed and/or sold with any software provided that any reserved names are not used by derivative works. The fonts and derivatives, however, cannot be released under any other type of license. The requirement for fonts to remain under this license does not apply to any document created using the fonts or their derivatives.
+
+DEFINITIONS
+"Font Software" refers to the set of files released by the Copyright Holder(s) under this license and clearly marked as such. This may include source files, build scripts and documentation.
+
+"Reserved Font Name" refers to any names specified as such after the copyright statement(s).
+
+"Original Version" refers to the collection of Font Software components as distributed by the Copyright Holder(s).
+
+"Modified Version" refers to any derivative made by adding to, deleting, or substituting -- in part or in whole -- any of the components of the Original Version, by changing formats or by porting the Font Software to a new environment.
+
+"Author" refers to any designer, engineer, programmer, technical writer or other person who contributed to the Font Software.
+
+PERMISSION & CONDITIONS
+Permission is hereby granted, free of charge, to any person obtaining a copy of the Font Software, to use, study, copy, merge, embed, modify, redistribute, and sell modified and unmodified copies of the Font Software, subject to the following conditions:
+
+1) Neither the Font Software nor any of its individual components, in Original or Modified Versions, may be sold by itself.
+
+2) Original or Modified Versions of the Font Software may be bundled, redistributed and/or sold with any software, provided that each copy contains the above copyright notice and this license. These can be included either as stand-alone text files, human-readable headers or in the appropriate machine-readable metadata fields within text or binary files as long as those fields can be easily viewed by the user.
+
+3) No Modified Version of the Font Software may use the Reserved Font Name(s) unless explicit written permission is granted by the corresponding Copyright Holder. This restriction only applies to the primary font name as presented to the users.
+
+4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font Software shall not be used to promote, endorse or advertise any Modified Version, except to acknowledge the contribution(s) of the Copyright Holder(s) and the Author(s) or with their explicit written permission.
+
+5) The Font Software, modified or unmodified, in part or in whole, must be distributed entirely under this license, and must not be distributed under any other license. The requirement for fonts to remain under this license does not apply to any document created using the Font Software.
+
+TERMINATION
+This license becomes null and void if any of the above conditions are not met.
+
+DISCLAIMER
+THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM OTHER DEALINGS IN THE FONT SOFTWARE.

TEMPAT SAMPAH
assets/fonts/montserrat/Montserrat-SemiBold.otf


+ 43 - 0
assets/fonts/montserrat/SIL Open Font License.txt

@@ -0,0 +1,43 @@
+Copyright 2011 The Montserrat Project Authors (https://github.com/JulietaUla/Montserrat)
+
+This Font Software is licensed under the SIL Open Font License, Version 1.1.
+This license is copied below, and is also available with a FAQ at: http://scripts.sil.org/OFL
+
+-----------------------------------------------------------
+SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
+-----------------------------------------------------------
+
+PREAMBLE
+The goals of the Open Font License (OFL) are to stimulate worldwide development of collaborative font projects, to support the font creation efforts of academic and linguistic communities, and to provide a free and open framework in which fonts may be shared and improved in partnership with others.
+
+The OFL allows the licensed fonts to be used, studied, modified and redistributed freely as long as they are not sold by themselves. The fonts, including any derivative works, can be bundled, embedded, redistributed and/or sold with any software provided that any reserved names are not used by derivative works. The fonts and derivatives, however, cannot be released under any other type of license. The requirement for fonts to remain under this license does not apply to any document created using the fonts or their derivatives.
+
+DEFINITIONS
+"Font Software" refers to the set of files released by the Copyright Holder(s) under this license and clearly marked as such. This may include source files, build scripts and documentation.
+
+"Reserved Font Name" refers to any names specified as such after the copyright statement(s).
+
+"Original Version" refers to the collection of Font Software components as distributed by the Copyright Holder(s).
+
+"Modified Version" refers to any derivative made by adding to, deleting, or substituting -- in part or in whole -- any of the components of the Original Version, by changing formats or by porting the Font Software to a new environment.
+
+"Author" refers to any designer, engineer, programmer, technical writer or other person who contributed to the Font Software.
+
+PERMISSION & CONDITIONS
+Permission is hereby granted, free of charge, to any person obtaining a copy of the Font Software, to use, study, copy, merge, embed, modify, redistribute, and sell modified and unmodified copies of the Font Software, subject to the following conditions:
+
+1) Neither the Font Software nor any of its individual components, in Original or Modified Versions, may be sold by itself.
+
+2) Original or Modified Versions of the Font Software may be bundled, redistributed and/or sold with any software, provided that each copy contains the above copyright notice and this license. These can be included either as stand-alone text files, human-readable headers or in the appropriate machine-readable metadata fields within text or binary files as long as those fields can be easily viewed by the user.
+
+3) No Modified Version of the Font Software may use the Reserved Font Name(s) unless explicit written permission is granted by the corresponding Copyright Holder. This restriction only applies to the primary font name as presented to the users.
+
+4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font Software shall not be used to promote, endorse or advertise any Modified Version, except to acknowledge the contribution(s) of the Copyright Holder(s) and the Author(s) or with their explicit written permission.
+
+5) The Font Software, modified or unmodified, in part or in whole, must be distributed entirely under this license, and must not be distributed under any other license. The requirement for fonts to remain under this license does not apply to any document created using the Font Software.
+
+TERMINATION
+This license becomes null and void if any of the above conditions are not met.
+
+DISCLAIMER
+THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM OTHER DEALINGS IN THE FONT SOFTWARE.

TEMPAT SAMPAH
assets/img/BMJV_Web_Master_de_WBZ.png


TEMPAT SAMPAH
assets/img/HardingCenter_Logo_de_RGB.png


TEMPAT SAMPAH
assets/img/Risikoradar.jpg


TEMPAT SAMPAH
assets/img/hc.png


TEMPAT SAMPAH
assets/img/mpib.png


+ 4684 - 0
assets/js/blob-stream.js

@@ -0,0 +1,4684 @@
+!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var f;"undefined"!=typeof window?f=window:"undefined"!=typeof global?f=global:"undefined"!=typeof self&&(f=self),f.blobStream=e()}}(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
+(function (global){
+/**
+ * Create a blob builder even when vendor prefixes exist
+ */
+
+var BlobBuilder = global.BlobBuilder
+  || global.WebKitBlobBuilder
+  || global.MSBlobBuilder
+  || global.MozBlobBuilder;
+
+/**
+ * Check if Blob constructor is supported
+ */
+
+var blobSupported = (function() {
+  try {
+    var a = new Blob(['hi']);
+    return a.size === 2;
+  } catch(e) {
+    return false;
+  }
+})();
+
+/**
+ * Check if Blob constructor supports ArrayBufferViews
+ * Fails in Safari 6, so we need to map to ArrayBuffers there.
+ */
+
+var blobSupportsArrayBufferView = blobSupported && (function() {
+  try {
+    var b = new Blob([new Uint8Array([1,2])]);
+    return b.size === 2;
+  } catch(e) {
+    return false;
+  }
+})();
+
+/**
+ * Check if BlobBuilder is supported
+ */
+
+var blobBuilderSupported = BlobBuilder
+  && BlobBuilder.prototype.append
+  && BlobBuilder.prototype.getBlob;
+
+/**
+ * Helper function that maps ArrayBufferViews to ArrayBuffers
+ * Used by BlobBuilder constructor and old browsers that didn't
+ * support it in the Blob constructor.
+ */
+
+function mapArrayBufferViews(ary) {
+  for (var i = 0; i < ary.length; i++) {
+    var chunk = ary[i];
+    if (chunk.buffer instanceof ArrayBuffer) {
+      var buf = chunk.buffer;
+
+      // if this is a subarray, make a copy so we only
+      // include the subarray region from the underlying buffer
+      if (chunk.byteLength !== buf.byteLength) {
+        var copy = new Uint8Array(chunk.byteLength);
+        copy.set(new Uint8Array(buf, chunk.byteOffset, chunk.byteLength));
+        buf = copy.buffer;
+      }
+
+      ary[i] = buf;
+    }
+  }
+}
+
+function BlobBuilderConstructor(ary, options) {
+  options = options || {};
+
+  var bb = new BlobBuilder();
+  mapArrayBufferViews(ary);
+
+  for (var i = 0; i < ary.length; i++) {
+    bb.append(ary[i]);
+  }
+
+  return (options.type) ? bb.getBlob(options.type) : bb.getBlob();
+};
+
+function BlobConstructor(ary, options) {
+  mapArrayBufferViews(ary);
+  return new Blob(ary, options || {});
+};
+
+module.exports = (function() {
+  if (blobSupported) {
+    return blobSupportsArrayBufferView ? global.Blob : BlobConstructor;
+  } else if (blobBuilderSupported) {
+    return BlobBuilderConstructor;
+  } else {
+    return undefined;
+  }
+})();
+
+}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
+},{}],2:[function(require,module,exports){
+(function (global){
+var WritableStream = require('stream').Writable;
+var util = require('util');
+var Blob = require('blob');
+var URL = global.URL || global.webkitURL || global.mozURL;
+
+function BlobStream() {
+  if (!(this instanceof BlobStream))
+    return new BlobStream;
+    
+  WritableStream.call(this);
+  this._chunks = [];
+  this._blob = null;
+  this.length = 0;
+}
+
+util.inherits(BlobStream, WritableStream);
+
+BlobStream.prototype._write = function(chunk, encoding, callback) {
+  // convert chunks to Uint8Arrays (e.g. Buffer when array fallback is being used)
+  if (!(chunk instanceof Uint8Array))
+    chunk = new Uint8Array(chunk);
+    
+  this.length += chunk.length;
+  this._chunks.push(chunk);
+  callback();
+};
+
+BlobStream.prototype.toBlob = function(type) {
+  type = type || 'application/octet-stream';
+  
+  // cache the blob if needed
+  if (!this._blob) {
+    this._blob = new Blob(this._chunks, {
+      type: type
+    });
+    
+    this._chunks = []; // free memory
+  }
+  
+  // if the cached blob's type doesn't match the requested type, make a new blob
+  if (this._blob.type !== type)
+    this._blob = new Blob([this._blob], { type: type });
+  
+  return this._blob;
+};
+
+BlobStream.prototype.toBlobURL = function(type) {
+  return URL.createObjectURL(this.toBlob(type));
+};
+
+module.exports = BlobStream;
+
+}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
+},{"blob":1,"stream":22,"util":25}],3:[function(require,module,exports){
+/*!
+ * The buffer module from node.js, for the browser.
+ *
+ * @author   Feross Aboukhadijeh <feross@feross.org> <http://feross.org>
+ * @license  MIT
+ */
+
+var base64 = require('base64-js')
+var ieee754 = require('ieee754')
+var isArray = require('is-array')
+
+exports.Buffer = Buffer
+exports.SlowBuffer = Buffer
+exports.INSPECT_MAX_BYTES = 50
+Buffer.poolSize = 8192 // not used by this implementation
+
+var kMaxLength = 0x3fffffff
+
+/**
+ * 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+.
+ *
+ * Note:
+ *
+ * - Implementation must support adding new properties to `Uint8Array` instances.
+ *   Firefox 4-29 lacked support, fixed in Firefox 30+.
+ *   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 will
+ * get the Object implementation, which is slower but will work correctly.
+ */
+Buffer.TYPED_ARRAY_SUPPORT = (function () {
+  try {
+    var buf = new ArrayBuffer(0)
+    var arr = new Uint8Array(buf)
+    arr.foo = function () { return 42 }
+    return 42 === arr.foo() && // typed array instances can be augmented
+        typeof arr.subarray === 'function' && // chrome 9-10 lack `subarray`
+        new Uint8Array(1).subarray(1, 1).byteLength === 0 // ie10 has broken `subarray`
+  } catch (e) {
+    return false
+  }
+})()
+
+/**
+ * Class: Buffer
+ * =============
+ *
+ * The Buffer constructor returns instances of `Uint8Array` that are augmented
+ * with function properties for all the node `Buffer` API functions. We use
+ * `Uint8Array` so that square bracket notation works as expected -- it returns
+ * a single octet.
+ *
+ * By augmenting the instances, we can avoid modifying the `Uint8Array`
+ * prototype.
+ */
+function Buffer (subject, encoding, noZero) {
+  if (!(this instanceof Buffer))
+    return new Buffer(subject, encoding, noZero)
+
+  var type = typeof subject
+
+  // Find the length
+  var length
+  if (type === 'number')
+    length = subject > 0 ? subject >>> 0 : 0
+  else if (type === 'string') {
+    if (encoding === 'base64')
+      subject = base64clean(subject)
+    length = Buffer.byteLength(subject, encoding)
+  } else if (type === 'object' && subject !== null) { // assume object is array-like
+    if (subject.type === 'Buffer' && isArray(subject.data))
+      subject = subject.data
+    length = +subject.length > 0 ? Math.floor(+subject.length) : 0
+  } else
+    throw new TypeError('must start with number, buffer, array or string')
+
+  if (this.length > kMaxLength)
+    throw new RangeError('Attempt to allocate Buffer larger than maximum ' +
+      'size: 0x' + kMaxLength.toString(16) + ' bytes')
+
+  var buf
+  if (Buffer.TYPED_ARRAY_SUPPORT) {
+    // Preferred: Return an augmented `Uint8Array` instance for best performance
+    buf = Buffer._augment(new Uint8Array(length))
+  } else {
+    // Fallback: Return THIS instance of Buffer (created by `new`)
+    buf = this
+    buf.length = length
+    buf._isBuffer = true
+  }
+
+  var i
+  if (Buffer.TYPED_ARRAY_SUPPORT && typeof subject.byteLength === 'number') {
+    // Speed optimization -- use set if we're copying from a typed array
+    buf._set(subject)
+  } else if (isArrayish(subject)) {
+    // Treat array-ish objects as a byte array
+    if (Buffer.isBuffer(subject)) {
+      for (i = 0; i < length; i++)
+        buf[i] = subject.readUInt8(i)
+    } else {
+      for (i = 0; i < length; i++)
+        buf[i] = ((subject[i] % 256) + 256) % 256
+    }
+  } else if (type === 'string') {
+    buf.write(subject, 0, encoding)
+  } else if (type === 'number' && !Buffer.TYPED_ARRAY_SUPPORT && !noZero) {
+    for (i = 0; i < length; i++) {
+      buf[i] = 0
+    }
+  }
+
+  return buf
+}
+
+Buffer.isBuffer = function (b) {
+  return !!(b != null && b._isBuffer)
+}
+
+Buffer.compare = function (a, b) {
+  if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b))
+    throw new TypeError('Arguments must be Buffers')
+
+  var x = a.length
+  var y = b.length
+  for (var i = 0, len = Math.min(x, y); i < len && a[i] === b[i]; i++) {}
+  if (i !== len) {
+    x = a[i]
+    y = b[i]
+  }
+  if (x < y) return -1
+  if (y < x) return 1
+  return 0
+}
+
+Buffer.isEncoding = function (encoding) {
+  switch (String(encoding).toLowerCase()) {
+    case 'hex':
+    case 'utf8':
+    case 'utf-8':
+    case 'ascii':
+    case 'binary':
+    case 'base64':
+    case 'raw':
+    case 'ucs2':
+    case 'ucs-2':
+    case 'utf16le':
+    case 'utf-16le':
+      return true
+    default:
+      return false
+  }
+}
+
+Buffer.concat = function (list, totalLength) {
+  if (!isArray(list)) throw new TypeError('Usage: Buffer.concat(list[, length])')
+
+  if (list.length === 0) {
+    return new Buffer(0)
+  } else if (list.length === 1) {
+    return list[0]
+  }
+
+  var i
+  if (totalLength === undefined) {
+    totalLength = 0
+    for (i = 0; i < list.length; i++) {
+      totalLength += list[i].length
+    }
+  }
+
+  var buf = new Buffer(totalLength)
+  var pos = 0
+  for (i = 0; i < list.length; i++) {
+    var item = list[i]
+    item.copy(buf, pos)
+    pos += item.length
+  }
+  return buf
+}
+
+Buffer.byteLength = function (str, encoding) {
+  var ret
+  str = str + ''
+  switch (encoding || 'utf8') {
+    case 'ascii':
+    case 'binary':
+    case 'raw':
+      ret = str.length
+      break
+    case 'ucs2':
+    case 'ucs-2':
+    case 'utf16le':
+    case 'utf-16le':
+      ret = str.length * 2
+      break
+    case 'hex':
+      ret = str.length >>> 1
+      break
+    case 'utf8':
+    case 'utf-8':
+      ret = utf8ToBytes(str).length
+      break
+    case 'base64':
+      ret = base64ToBytes(str).length
+      break
+    default:
+      ret = str.length
+  }
+  return ret
+}
+
+// pre-set for values that may exist in the future
+Buffer.prototype.length = undefined
+Buffer.prototype.parent = undefined
+
+// toString(encoding, start=0, end=buffer.length)
+Buffer.prototype.toString = function (encoding, start, end) {
+  var loweredCase = false
+
+  start = start >>> 0
+  end = end === undefined || end === Infinity ? this.length : end >>> 0
+
+  if (!encoding) encoding = 'utf8'
+  if (start < 0) start = 0
+  if (end > this.length) end = this.length
+  if (end <= start) return ''
+
+  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 'binary':
+        return binarySlice(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
+    }
+  }
+}
+
+Buffer.prototype.equals = function (b) {
+  if(!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')
+  return Buffer.compare(this, b) === 0
+}
+
+Buffer.prototype.inspect = function () {
+  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 ' + str + '>'
+}
+
+Buffer.prototype.compare = function (b) {
+  if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')
+  return Buffer.compare(this, b)
+}
+
+// `get` will be removed in Node 0.13+
+Buffer.prototype.get = function (offset) {
+  console.log('.get() is deprecated. Access using array indexes instead.')
+  return this.readUInt8(offset)
+}
+
+// `set` will be removed in Node 0.13+
+Buffer.prototype.set = function (v, offset) {
+  console.log('.set() is deprecated. Access using array indexes instead.')
+  return this.writeUInt8(v, offset)
+}
+
+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 Error('Invalid hex string')
+
+  if (length > strLen / 2) {
+    length = strLen / 2
+  }
+  for (var i = 0; i < length; i++) {
+    var byte = parseInt(string.substr(i * 2, 2), 16)
+    if (isNaN(byte)) throw new Error('Invalid hex string')
+    buf[offset + i] = byte
+  }
+  return i
+}
+
+function utf8Write (buf, string, offset, length) {
+  var charsWritten = blitBuffer(utf8ToBytes(string), buf, offset, length)
+  return charsWritten
+}
+
+function asciiWrite (buf, string, offset, length) {
+  var charsWritten = blitBuffer(asciiToBytes(string), buf, offset, length)
+  return charsWritten
+}
+
+function binaryWrite (buf, string, offset, length) {
+  return asciiWrite(buf, string, offset, length)
+}
+
+function base64Write (buf, string, offset, length) {
+  var charsWritten = blitBuffer(base64ToBytes(string), buf, offset, length)
+  return charsWritten
+}
+
+function utf16leWrite (buf, string, offset, length) {
+  var charsWritten = blitBuffer(utf16leToBytes(string), buf, offset, length)
+  return charsWritten
+}
+
+Buffer.prototype.write = function (string, offset, length, encoding) {
+  // Support both (string, offset, length, encoding)
+  // and the legacy (string, encoding, offset, length)
+  if (isFinite(offset)) {
+    if (!isFinite(length)) {
+      encoding = length
+      length = undefined
+    }
+  } else {  // legacy
+    var swap = encoding
+    encoding = offset
+    offset = length
+    length = swap
+  }
+
+  offset = Number(offset) || 0
+  var remaining = this.length - offset
+  if (!length) {
+    length = remaining
+  } else {
+    length = Number(length)
+    if (length > remaining) {
+      length = remaining
+    }
+  }
+  encoding = String(encoding || 'utf8').toLowerCase()
+
+  var ret
+  switch (encoding) {
+    case 'hex':
+      ret = hexWrite(this, string, offset, length)
+      break
+    case 'utf8':
+    case 'utf-8':
+      ret = utf8Write(this, string, offset, length)
+      break
+    case 'ascii':
+      ret = asciiWrite(this, string, offset, length)
+      break
+    case 'binary':
+      ret = binaryWrite(this, string, offset, length)
+      break
+    case 'base64':
+      ret = base64Write(this, string, offset, length)
+      break
+    case 'ucs2':
+    case 'ucs-2':
+    case 'utf16le':
+    case 'utf-16le':
+      ret = utf16leWrite(this, string, offset, length)
+      break
+    default:
+      throw new TypeError('Unknown encoding: ' + encoding)
+  }
+  return ret
+}
+
+Buffer.prototype.toJSON = function () {
+  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) {
+  var res = ''
+  var tmp = ''
+  end = Math.min(buf.length, end)
+
+  for (var i = start; i < end; i++) {
+    if (buf[i] <= 0x7F) {
+      res += decodeUtf8Char(tmp) + String.fromCharCode(buf[i])
+      tmp = ''
+    } else {
+      tmp += '%' + buf[i].toString(16)
+    }
+  }
+
+  return res + decodeUtf8Char(tmp)
+}
+
+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])
+  }
+  return ret
+}
+
+function binarySlice (buf, start, end) {
+  return asciiSlice(buf, start, end)
+}
+
+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 (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
+
+  if (Buffer.TYPED_ARRAY_SUPPORT) {
+    return Buffer._augment(this.subarray(start, end))
+  } else {
+    var sliceLen = end - start
+    var newBuf = new Buffer(sliceLen, undefined, true)
+    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.readUInt8 = function (offset, noAssert) {
+  if (!noAssert)
+    checkOffset(offset, 1, this.length)
+  return this[offset]
+}
+
+Buffer.prototype.readUInt16LE = function (offset, noAssert) {
+  if (!noAssert)
+    checkOffset(offset, 2, this.length)
+  return this[offset] | (this[offset + 1] << 8)
+}
+
+Buffer.prototype.readUInt16BE = function (offset, noAssert) {
+  if (!noAssert)
+    checkOffset(offset, 2, this.length)
+  return (this[offset] << 8) | this[offset + 1]
+}
+
+Buffer.prototype.readUInt32LE = function (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 (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.readInt8 = function (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 (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 (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 (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 (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 (offset, noAssert) {
+  if (!noAssert)
+    checkOffset(offset, 4, this.length)
+  return ieee754.read(this, offset, true, 23, 4)
+}
+
+Buffer.prototype.readFloatBE = function (offset, noAssert) {
+  if (!noAssert)
+    checkOffset(offset, 4, this.length)
+  return ieee754.read(this, offset, false, 23, 4)
+}
+
+Buffer.prototype.readDoubleLE = function (offset, noAssert) {
+  if (!noAssert)
+    checkOffset(offset, 8, this.length)
+  return ieee754.read(this, offset, true, 52, 8)
+}
+
+Buffer.prototype.readDoubleBE = function (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 must be a Buffer instance')
+  if (value > max || value < min) throw new TypeError('value is out of bounds')
+  if (offset + ext > buf.length) throw new TypeError('index out of range')
+}
+
+Buffer.prototype.writeUInt8 = function (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
+  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 (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
+    this[offset + 1] = (value >>> 8)
+  } else objectWriteUInt16(this, value, offset, true)
+  return offset + 2
+}
+
+Buffer.prototype.writeUInt16BE = function (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
+  } 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 (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
+  } else objectWriteUInt32(this, value, offset, true)
+  return offset + 4
+}
+
+Buffer.prototype.writeUInt32BE = function (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
+  } else objectWriteUInt32(this, value, offset, false)
+  return offset + 4
+}
+
+Buffer.prototype.writeInt8 = function (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
+  return offset + 1
+}
+
+Buffer.prototype.writeInt16LE = function (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
+    this[offset + 1] = (value >>> 8)
+  } else objectWriteUInt16(this, value, offset, true)
+  return offset + 2
+}
+
+Buffer.prototype.writeInt16BE = function (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
+  } else objectWriteUInt16(this, value, offset, false)
+  return offset + 2
+}
+
+Buffer.prototype.writeInt32LE = function (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
+    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 (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
+  } else objectWriteUInt32(this, value, offset, false)
+  return offset + 4
+}
+
+function checkIEEE754 (buf, value, offset, ext, max, min) {
+  if (value > max || value < min) throw new TypeError('value is out of bounds')
+  if (offset + ext > buf.length) throw new TypeError('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 (value, offset, noAssert) {
+  return writeFloat(this, value, offset, true, noAssert)
+}
+
+Buffer.prototype.writeFloatBE = function (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 (value, offset, noAssert) {
+  return writeDouble(this, value, offset, true, noAssert)
+}
+
+Buffer.prototype.writeDoubleBE = function (value, offset, noAssert) {
+  return writeDouble(this, value, offset, false, noAssert)
+}
+
+// copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)
+Buffer.prototype.copy = function (target, target_start, start, end) {
+  var source = this
+
+  if (!start) start = 0
+  if (!end && end !== 0) end = this.length
+  if (!target_start) target_start = 0
+
+  // Copy 0 bytes; we're done
+  if (end === start) return
+  if (target.length === 0 || source.length === 0) return
+
+  // Fatal error conditions
+  if (end < start) throw new TypeError('sourceEnd < sourceStart')
+  if (target_start < 0 || target_start >= target.length)
+    throw new TypeError('targetStart out of bounds')
+  if (start < 0 || start >= source.length) throw new TypeError('sourceStart out of bounds')
+  if (end < 0 || end > source.length) throw new TypeError('sourceEnd out of bounds')
+
+  // Are we oob?
+  if (end > this.length)
+    end = this.length
+  if (target.length - target_start < end - start)
+    end = target.length - target_start + start
+
+  var len = end - start
+
+  if (len < 1000 || !Buffer.TYPED_ARRAY_SUPPORT) {
+    for (var i = 0; i < len; i++) {
+      target[i + target_start] = this[i + start]
+    }
+  } else {
+    target._set(this.subarray(start, start + len), target_start)
+  }
+}
+
+// fill(value, start=0, end=buffer.length)
+Buffer.prototype.fill = function (value, start, end) {
+  if (!value) value = 0
+  if (!start) start = 0
+  if (!end) end = this.length
+
+  if (end < start) throw new TypeError('end < start')
+
+  // Fill 0 bytes; we're done
+  if (end === start) return
+  if (this.length === 0) return
+
+  if (start < 0 || start >= this.length) throw new TypeError('start out of bounds')
+  if (end < 0 || end > this.length) throw new TypeError('end out of bounds')
+
+  var i
+  if (typeof value === 'number') {
+    for (i = start; i < end; i++) {
+      this[i] = value
+    }
+  } else {
+    var bytes = utf8ToBytes(value.toString())
+    var len = bytes.length
+    for (i = start; i < end; i++) {
+      this[i] = bytes[i % len]
+    }
+  }
+
+  return this
+}
+
+/**
+ * Creates a new `ArrayBuffer` with the *copied* memory of the buffer instance.
+ * Added in Node 0.12. Only available in browsers that support ArrayBuffer.
+ */
+Buffer.prototype.toArrayBuffer = function () {
+  if (typeof Uint8Array !== 'undefined') {
+    if (Buffer.TYPED_ARRAY_SUPPORT) {
+      return (new Buffer(this)).buffer
+    } else {
+      var buf = new Uint8Array(this.length)
+      for (var i = 0, len = buf.length; i < len; i += 1) {
+        buf[i] = this[i]
+      }
+      return buf.buffer
+    }
+  } else {
+    throw new TypeError('Buffer.toArrayBuffer not supported in this browser')
+  }
+}
+
+// HELPER FUNCTIONS
+// ================
+
+var BP = Buffer.prototype
+
+/**
+ * Augment a Uint8Array *instance* (not the Uint8Array class!) with Buffer methods
+ */
+Buffer._augment = function (arr) {
+  arr.constructor = Buffer
+  arr._isBuffer = true
+
+  // save reference to original Uint8Array get/set methods before overwriting
+  arr._get = arr.get
+  arr._set = arr.set
+
+  // deprecated, will be removed in node 0.13+
+  arr.get = BP.get
+  arr.set = BP.set
+
+  arr.write = BP.write
+  arr.toString = BP.toString
+  arr.toLocaleString = BP.toString
+  arr.toJSON = BP.toJSON
+  arr.equals = BP.equals
+  arr.compare = BP.compare
+  arr.copy = BP.copy
+  arr.slice = BP.slice
+  arr.readUInt8 = BP.readUInt8
+  arr.readUInt16LE = BP.readUInt16LE
+  arr.readUInt16BE = BP.readUInt16BE
+  arr.readUInt32LE = BP.readUInt32LE
+  arr.readUInt32BE = BP.readUInt32BE
+  arr.readInt8 = BP.readInt8
+  arr.readInt16LE = BP.readInt16LE
+  arr.readInt16BE = BP.readInt16BE
+  arr.readInt32LE = BP.readInt32LE
+  arr.readInt32BE = BP.readInt32BE
+  arr.readFloatLE = BP.readFloatLE
+  arr.readFloatBE = BP.readFloatBE
+  arr.readDoubleLE = BP.readDoubleLE
+  arr.readDoubleBE = BP.readDoubleBE
+  arr.writeUInt8 = BP.writeUInt8
+  arr.writeUInt16LE = BP.writeUInt16LE
+  arr.writeUInt16BE = BP.writeUInt16BE
+  arr.writeUInt32LE = BP.writeUInt32LE
+  arr.writeUInt32BE = BP.writeUInt32BE
+  arr.writeInt8 = BP.writeInt8
+  arr.writeInt16LE = BP.writeInt16LE
+  arr.writeInt16BE = BP.writeInt16BE
+  arr.writeInt32LE = BP.writeInt32LE
+  arr.writeInt32BE = BP.writeInt32BE
+  arr.writeFloatLE = BP.writeFloatLE
+  arr.writeFloatBE = BP.writeFloatBE
+  arr.writeDoubleLE = BP.writeDoubleLE
+  arr.writeDoubleBE = BP.writeDoubleBE
+  arr.fill = BP.fill
+  arr.inspect = BP.inspect
+  arr.toArrayBuffer = BP.toArrayBuffer
+
+  return arr
+}
+
+var INVALID_BASE64_RE = /[^+\/0-9A-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 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 isArrayish (subject) {
+  return isArray(subject) || Buffer.isBuffer(subject) ||
+      subject && typeof subject === 'object' &&
+      typeof subject.length === 'number'
+}
+
+function toHex (n) {
+  if (n < 16) return '0' + n.toString(16)
+  return n.toString(16)
+}
+
+function utf8ToBytes (str) {
+  var byteArray = []
+  for (var i = 0; i < str.length; i++) {
+    var b = str.charCodeAt(i)
+    if (b <= 0x7F) {
+      byteArray.push(b)
+    } else {
+      var start = i
+      if (b >= 0xD800 && b <= 0xDFFF) i++
+      var h = encodeURIComponent(str.slice(start, i+1)).substr(1).split('%')
+      for (var j = 0; j < h.length; j++) {
+        byteArray.push(parseInt(h[j], 16))
+      }
+    }
+  }
+  return byteArray
+}
+
+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) {
+  var c, hi, lo
+  var byteArray = []
+  for (var i = 0; i < str.length; i++) {
+    c = str.charCodeAt(i)
+    hi = c >> 8
+    lo = c % 256
+    byteArray.push(lo)
+    byteArray.push(hi)
+  }
+
+  return byteArray
+}
+
+function base64ToBytes (str) {
+  return base64.toByteArray(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 decodeUtf8Char (str) {
+  try {
+    return decodeURIComponent(str)
+  } catch (err) {
+    return String.fromCharCode(0xFFFD) // UTF 8 invalid char
+  }
+}
+
+},{"base64-js":4,"ieee754":5,"is-array":6}],4:[function(require,module,exports){
+var lookup = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
+
+;(function (exports) {
+	'use strict';
+
+  var Arr = (typeof Uint8Array !== 'undefined')
+    ? Uint8Array
+    : Array
+
+	var PLUS   = '+'.charCodeAt(0)
+	var SLASH  = '/'.charCodeAt(0)
+	var NUMBER = '0'.charCodeAt(0)
+	var LOWER  = 'a'.charCodeAt(0)
+	var UPPER  = 'A'.charCodeAt(0)
+
+	function decode (elt) {
+		var code = elt.charCodeAt(0)
+		if (code === PLUS)
+			return 62 // '+'
+		if (code === SLASH)
+			return 63 // '/'
+		if (code < NUMBER)
+			return -1 //no match
+		if (code < NUMBER + 10)
+			return code - NUMBER + 26 + 26
+		if (code < UPPER + 26)
+			return code - UPPER
+		if (code < LOWER + 26)
+			return code - LOWER + 26
+	}
+
+	function b64ToByteArray (b64) {
+		var i, j, l, tmp, placeHolders, arr
+
+		if (b64.length % 4 > 0) {
+			throw new Error('Invalid string. Length must be a multiple of 4')
+		}
+
+		// the number of equal signs (place holders)
+		// if there are two placeholders, than the two characters before it
+		// represent one byte
+		// if there is only one, then the three characters before it represent 2 bytes
+		// this is just a cheap hack to not do indexOf twice
+		var len = b64.length
+		placeHolders = '=' === b64.charAt(len - 2) ? 2 : '=' === b64.charAt(len - 1) ? 1 : 0
+
+		// base64 is 4/3 + up to two characters of the original data
+		arr = new Arr(b64.length * 3 / 4 - placeHolders)
+
+		// if there are placeholders, only get up to the last complete 4 chars
+		l = placeHolders > 0 ? b64.length - 4 : b64.length
+
+		var L = 0
+
+		function push (v) {
+			arr[L++] = v
+		}
+
+		for (i = 0, j = 0; i < l; i += 4, j += 3) {
+			tmp = (decode(b64.charAt(i)) << 18) | (decode(b64.charAt(i + 1)) << 12) | (decode(b64.charAt(i + 2)) << 6) | decode(b64.charAt(i + 3))
+			push((tmp & 0xFF0000) >> 16)
+			push((tmp & 0xFF00) >> 8)
+			push(tmp & 0xFF)
+		}
+
+		if (placeHolders === 2) {
+			tmp = (decode(b64.charAt(i)) << 2) | (decode(b64.charAt(i + 1)) >> 4)
+			push(tmp & 0xFF)
+		} else if (placeHolders === 1) {
+			tmp = (decode(b64.charAt(i)) << 10) | (decode(b64.charAt(i + 1)) << 4) | (decode(b64.charAt(i + 2)) >> 2)
+			push((tmp >> 8) & 0xFF)
+			push(tmp & 0xFF)
+		}
+
+		return arr
+	}
+
+	function uint8ToBase64 (uint8) {
+		var i,
+			extraBytes = uint8.length % 3, // if we have 1 byte left, pad 2 bytes
+			output = "",
+			temp, length
+
+		function encode (num) {
+			return lookup.charAt(num)
+		}
+
+		function tripletToBase64 (num) {
+			return encode(num >> 18 & 0x3F) + encode(num >> 12 & 0x3F) + encode(num >> 6 & 0x3F) + encode(num & 0x3F)
+		}
+
+		// go through the array every three bytes, we'll deal with trailing stuff later
+		for (i = 0, length = uint8.length - extraBytes; i < length; i += 3) {
+			temp = (uint8[i] << 16) + (uint8[i + 1] << 8) + (uint8[i + 2])
+			output += tripletToBase64(temp)
+		}
+
+		// pad the end with zeros, but make sure to not forget the extra bytes
+		switch (extraBytes) {
+			case 1:
+				temp = uint8[uint8.length - 1]
+				output += encode(temp >> 2)
+				output += encode((temp << 4) & 0x3F)
+				output += '=='
+				break
+			case 2:
+				temp = (uint8[uint8.length - 2] << 8) + (uint8[uint8.length - 1])
+				output += encode(temp >> 10)
+				output += encode((temp >> 4) & 0x3F)
+				output += encode((temp << 2) & 0x3F)
+				output += '='
+				break
+		}
+
+		return output
+	}
+
+	exports.toByteArray = b64ToByteArray
+	exports.fromByteArray = uint8ToBase64
+}(typeof exports === 'undefined' ? (this.base64js = {}) : exports))
+
+},{}],5:[function(require,module,exports){
+exports.read = function(buffer, offset, isLE, mLen, nBytes) {
+  var e, m,
+      eLen = nBytes * 8 - mLen - 1,
+      eMax = (1 << eLen) - 1,
+      eBias = eMax >> 1,
+      nBits = -7,
+      i = isLE ? (nBytes - 1) : 0,
+      d = isLE ? -1 : 1,
+      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,
+      eLen = nBytes * 8 - mLen - 1,
+      eMax = (1 << eLen) - 1,
+      eBias = eMax >> 1,
+      rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0),
+      i = isLE ? 0 : (nBytes - 1),
+      d = isLE ? 1 : -1,
+      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;
+};
+
+},{}],6:[function(require,module,exports){
+
+/**
+ * isArray
+ */
+
+var isArray = Array.isArray;
+
+/**
+ * toString
+ */
+
+var str = Object.prototype.toString;
+
+/**
+ * Whether or not the given `val`
+ * is an array.
+ *
+ * example:
+ *
+ *        isArray([]);
+ *        // > true
+ *        isArray(arguments);
+ *        // > false
+ *        isArray('');
+ *        // > false
+ *
+ * @param {mixed} val
+ * @return {bool}
+ */
+
+module.exports = isArray || function (val) {
+  return !! val && '[object Array]' == str.call(val);
+};
+
+},{}],7:[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
+      }
+      throw TypeError('Uncaught, unspecified "error" event.');
+    }
+  }
+
+  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:
+        len = arguments.length;
+        args = new Array(len - 1);
+        for (i = 1; i < len; i++)
+          args[i - 1] = arguments[i];
+        handler.apply(this, args);
+    }
+  } else if (isObject(handler)) {
+    len = arguments.length;
+    args = new Array(len - 1);
+    for (i = 1; i < len; i++)
+      args[i - 1] = arguments[i];
+
+    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) {
+    var m;
+    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 {
+    // 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.listenerCount = function(emitter, type) {
+  var ret;
+  if (!emitter._events || !emitter._events[type])
+    ret = 0;
+  else if (isFunction(emitter._events[type]))
+    ret = 1;
+  else
+    ret = emitter._events[type].length;
+  return ret;
+};
+
+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;
+}
+
+},{}],8:[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
+  }
+}
+
+},{}],9:[function(require,module,exports){
+module.exports = Array.isArray || function (arr) {
+  return Object.prototype.toString.call(arr) == '[object Array]';
+};
+
+},{}],10:[function(require,module,exports){
+// shim for using process in browser
+
+var process = module.exports = {};
+
+process.nextTick = (function () {
+    var canSetImmediate = typeof window !== 'undefined'
+    && window.setImmediate;
+    var canMutationObserver = typeof window !== 'undefined'
+    && window.MutationObserver;
+    var canPost = typeof window !== 'undefined'
+    && window.postMessage && window.addEventListener
+    ;
+
+    if (canSetImmediate) {
+        return function (f) { return window.setImmediate(f) };
+    }
+
+    var queue = [];
+
+    if (canMutationObserver) {
+        var hiddenDiv = document.createElement("div");
+        var observer = new MutationObserver(function () {
+            var queueList = queue.slice();
+            queue.length = 0;
+            queueList.forEach(function (fn) {
+                fn();
+            });
+        });
+
+        observer.observe(hiddenDiv, { attributes: true });
+
+        return function nextTick(fn) {
+            if (!queue.length) {
+                hiddenDiv.setAttribute('yes', 'no');
+            }
+            queue.push(fn);
+        };
+    }
+
+    if (canPost) {
+        window.addEventListener('message', function (ev) {
+            var source = ev.source;
+            if ((source === window || source === null) && ev.data === 'process-tick') {
+                ev.stopPropagation();
+                if (queue.length > 0) {
+                    var fn = queue.shift();
+                    fn();
+                }
+            }
+        }, true);
+
+        return function nextTick(fn) {
+            queue.push(fn);
+            window.postMessage('process-tick', '*');
+        };
+    }
+
+    return function nextTick(fn) {
+        setTimeout(fn, 0);
+    };
+})();
+
+process.title = 'browser';
+process.browser = true;
+process.env = {};
+process.argv = [];
+
+function noop() {}
+
+process.on = noop;
+process.addListener = noop;
+process.once = noop;
+process.off = noop;
+process.removeListener = noop;
+process.removeAllListeners = noop;
+process.emit = noop;
+
+process.binding = function (name) {
+    throw new Error('process.binding is not supported');
+};
+
+// TODO(shtylman)
+process.cwd = function () { return '/' };
+process.chdir = function (dir) {
+    throw new Error('process.chdir is not supported');
+};
+
+},{}],11:[function(require,module,exports){
+module.exports = require("./lib/_stream_duplex.js")
+
+},{"./lib/_stream_duplex.js":12}],12:[function(require,module,exports){
+(function (process){
+// 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.
+
+module.exports = Duplex;
+
+/*<replacement>*/
+var objectKeys = Object.keys || function (obj) {
+  var keys = [];
+  for (var key in obj) keys.push(key);
+  return keys;
+}
+/*</replacement>*/
+
+
+/*<replacement>*/
+var util = require('core-util-is');
+util.inherits = require('inherits');
+/*</replacement>*/
+
+var Readable = require('./_stream_readable');
+var Writable = require('./_stream_writable');
+
+util.inherits(Duplex, Readable);
+
+forEach(objectKeys(Writable.prototype), function(method) {
+  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);
+}
+
+// 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.
+  process.nextTick(this.end.bind(this));
+}
+
+function forEach (xs, f) {
+  for (var i = 0, l = xs.length; i < l; i++) {
+    f(xs[i], i);
+  }
+}
+
+}).call(this,require('_process'))
+},{"./_stream_readable":14,"./_stream_writable":16,"_process":10,"core-util-is":17,"inherits":8}],13:[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.
+
+module.exports = PassThrough;
+
+var Transform = require('./_stream_transform');
+
+/*<replacement>*/
+var util = require('core-util-is');
+util.inherits = require('inherits');
+/*</replacement>*/
+
+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":15,"core-util-is":17,"inherits":8}],14:[function(require,module,exports){
+(function (process){
+// 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.
+
+module.exports = Readable;
+
+/*<replacement>*/
+var isArray = require('isarray');
+/*</replacement>*/
+
+
+/*<replacement>*/
+var Buffer = require('buffer').Buffer;
+/*</replacement>*/
+
+Readable.ReadableState = ReadableState;
+
+var EE = require('events').EventEmitter;
+
+/*<replacement>*/
+if (!EE.listenerCount) EE.listenerCount = function(emitter, type) {
+  return emitter.listeners(type).length;
+};
+/*</replacement>*/
+
+var Stream = require('stream');
+
+/*<replacement>*/
+var util = require('core-util-is');
+util.inherits = require('inherits');
+/*</replacement>*/
+
+var StringDecoder;
+
+util.inherits(Readable, Stream);
+
+function ReadableState(options, stream) {
+  options = options || {};
+
+  // 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;
+  this.highWaterMark = (hwm || hwm === 0) ? hwm : 16 * 1024;
+
+  // cast to ints.
+  this.highWaterMark = ~~this.highWaterMark;
+
+  this.buffer = [];
+  this.length = 0;
+  this.pipes = null;
+  this.pipesCount = 0;
+  this.flowing = false;
+  this.ended = false;
+  this.endEmitted = false;
+  this.reading = false;
+
+  // In streams that never have any data, and do push(null) right away,
+  // the consumer can miss the 'end' event if they do some I/O before
+  // consuming the stream.  So, we don't emit('end') until some reading
+  // happens.
+  this.calledRead = false;
+
+  // 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, becuase any
+  // actions that shouldn't happen until "later" should generally also
+  // not happen before the first write 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;
+
+
+  // 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;
+
+  // 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';
+
+  // when piping, we only care about 'readable' events that happen
+  // after read()ing all the bytes and not getting any pushback.
+  this.ranOut = false;
+
+  // 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) {
+  if (!(this instanceof Readable))
+    return new Readable(options);
+
+  this._readableState = new ReadableState(options, this);
+
+  // legacy
+  this.readable = true;
+
+  Stream.call(this);
+}
+
+// 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;
+
+  if (typeof chunk === 'string' && !state.objectMode) {
+    encoding = encoding || state.defaultEncoding;
+    if (encoding !== state.encoding) {
+      chunk = new Buffer(chunk, encoding);
+      encoding = '';
+    }
+  }
+
+  return readableAddChunk(this, state, chunk, encoding, false);
+};
+
+// Unshift should *always* be something directly out of read()
+Readable.prototype.unshift = function(chunk) {
+  var state = this._readableState;
+  return readableAddChunk(this, state, chunk, '', true);
+};
+
+function readableAddChunk(stream, state, chunk, encoding, addToFront) {
+  var er = chunkInvalid(state, chunk);
+  if (er) {
+    stream.emit('error', er);
+  } else if (chunk === null || chunk === undefined) {
+    state.reading = false;
+    if (!state.ended)
+      onEofChunk(stream, state);
+  } else if (state.objectMode || chunk && chunk.length > 0) {
+    if (state.ended && !addToFront) {
+      var e = new Error('stream.push() after EOF');
+      stream.emit('error', e);
+    } else if (state.endEmitted && addToFront) {
+      var e = new Error('stream.unshift() after end event');
+      stream.emit('error', e);
+    } else {
+      if (state.decoder && !addToFront && !encoding)
+        chunk = state.decoder.write(chunk);
+
+      // update the buffer info.
+      state.length += state.objectMode ? 1 : chunk.length;
+      if (addToFront) {
+        state.buffer.unshift(chunk);
+      } else {
+        state.reading = false;
+        state.buffer.push(chunk);
+      }
+
+      if (state.needReadable)
+        emitReadable(stream);
+
+      maybeReadMore(stream, state);
+    }
+  } else if (!addToFront) {
+    state.reading = false;
+  }
+
+  return needMoreData(state);
+}
+
+
+
+// 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);
+}
+
+// backwards compatibility.
+Readable.prototype.setEncoding = function(enc) {
+  if (!StringDecoder)
+    StringDecoder = require('string_decoder/').StringDecoder;
+  this._readableState.decoder = new StringDecoder(enc);
+  this._readableState.encoding = enc;
+};
+
+// Don't raise the hwm > 128MB
+var MAX_HWM = 0x800000;
+function roundUpToNextPowerOf2(n) {
+  if (n >= MAX_HWM) {
+    n = MAX_HWM;
+  } else {
+    // Get the next highest power of 2
+    n--;
+    for (var p = 1; p < 32; p <<= 1) n |= n >> p;
+    n++;
+  }
+  return n;
+}
+
+function howMuchToRead(n, state) {
+  if (state.length === 0 && state.ended)
+    return 0;
+
+  if (state.objectMode)
+    return n === 0 ? 0 : 1;
+
+  if (n === null || isNaN(n)) {
+    // only flow one buffer at a time
+    if (state.flowing && state.buffer.length)
+      return state.buffer[0].length;
+    else
+      return state.length;
+  }
+
+  if (n <= 0)
+    return 0;
+
+  // If we're asking for more than the target buffer level,
+  // then raise the water mark.  Bump up to the next highest
+  // power of 2, to prevent increasing it excessively in tiny
+  // amounts.
+  if (n > state.highWaterMark)
+    state.highWaterMark = roundUpToNextPowerOf2(n);
+
+  // don't have that much.  return null, unless we've ended.
+  if (n > state.length) {
+    if (!state.ended) {
+      state.needReadable = true;
+      return 0;
+    } else
+      return state.length;
+  }
+
+  return n;
+}
+
+// you can override either this method, or the async _read(n) below.
+Readable.prototype.read = function(n) {
+  var state = this._readableState;
+  state.calledRead = true;
+  var nOrig = n;
+  var ret;
+
+  if (typeof n !== 'number' || 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)) {
+    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) {
+    ret = null;
+
+    // In cases where the decoder did not receive enough data
+    // to produce a full chunk, then immediately received an
+    // EOF, state.buffer will contain [<Buffer >, <Buffer 00 ...>].
+    // howMuchToRead will see this and coerce the amount to
+    // read to zero (because it's looking at the length of the
+    // first <Buffer > in state.buffer), and we'll end up here.
+    //
+    // This can only happen via state.decoder -- no other venue
+    // exists for pushing a zero-length chunk into state.buffer
+    // and triggering this behavior. In this case, we return our
+    // remaining data and end the stream, if appropriate.
+    if (state.length > 0 && state.decoder) {
+      ret = fromList(n, state);
+      state.length -= ret.length;
+    }
+
+    if (state.length === 0)
+      endReadable(this);
+
+    return ret;
+  }
+
+  // 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;
+
+  // if we currently have less than the highWaterMark, then also read some
+  if (state.length - n <= state.highWaterMark)
+    doRead = true;
+
+  // 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;
+
+  if (doRead) {
+    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 called its callback synchronously, then `reading`
+  // will be false, and we need to re-evaluate how much data we
+  // can return to the user.
+  if (doRead && !state.reading)
+    n = howMuchToRead(nOrig, state);
+
+  if (n > 0)
+    ret = fromList(n, state);
+  else
+    ret = null;
+
+  if (ret === null) {
+    state.needReadable = true;
+    n = 0;
+  }
+
+  state.length -= n;
+
+  // If we have nothing in the buffer, then we want to know
+  // as soon as we *do* get something into the buffer.
+  if (state.length === 0 && !state.ended)
+    state.needReadable = true;
+
+  // If we happened to read() exactly the remaining amount in the
+  // buffer, and the EOF has been seen at this point, then make sure
+  // that we emit 'end' on the very next tick.
+  if (state.ended && !state.endEmitted && state.length === 0)
+    endReadable(this);
+
+  return ret;
+};
+
+function chunkInvalid(state, chunk) {
+  var er = null;
+  if (!Buffer.isBuffer(chunk) &&
+      'string' !== typeof chunk &&
+      chunk !== null &&
+      chunk !== undefined &&
+      !state.objectMode) {
+    er = new TypeError('Invalid non-string/buffer chunk');
+  }
+  return er;
+}
+
+
+function onEofChunk(stream, state) {
+  if (state.decoder && !state.ended) {
+    var chunk = state.decoder.end();
+    if (chunk && chunk.length) {
+      state.buffer.push(chunk);
+      state.length += state.objectMode ? 1 : chunk.length;
+    }
+  }
+  state.ended = true;
+
+  // if we've ended and we have some data left, then emit
+  // 'readable' now to make sure it gets picked up.
+  if (state.length > 0)
+    emitReadable(stream);
+  else
+    endReadable(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)
+    return;
+
+  state.emittedReadable = true;
+  if (state.sync)
+    process.nextTick(function() {
+      emitReadable_(stream);
+    });
+  else
+    emitReadable_(stream);
+}
+
+function emitReadable_(stream) {
+  stream.emit('readable');
+}
+
+
+// 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;
+    process.nextTick(function() {
+      maybeReadMore_(stream, state);
+    });
+  }
+}
+
+function maybeReadMore_(stream, state) {
+  var len = state.length;
+  while (!state.reading && !state.flowing && !state.ended &&
+         state.length < state.highWaterMark) {
+    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('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;
+
+  var doEnd = (!pipeOpts || pipeOpts.end !== false) &&
+              dest !== process.stdout &&
+              dest !== process.stderr;
+
+  var endFn = doEnd ? onend : cleanup;
+  if (state.endEmitted)
+    process.nextTick(endFn);
+  else
+    src.once('end', endFn);
+
+  dest.on('unpipe', onunpipe);
+  function onunpipe(readable) {
+    if (readable !== src) return;
+    cleanup();
+  }
+
+  function 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);
+
+  function 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', cleanup);
+
+    // 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 (!dest._writableState || dest._writableState.needDrain)
+      ondrain();
+  }
+
+  // if the dest has an error, then stop piping into it.
+  // however, don't suppress the throwing behavior for this.
+  function onerror(er) {
+    unpipe();
+    dest.removeListener('error', onerror);
+    if (EE.listenerCount(dest, 'error') === 0)
+      dest.emit('error', er);
+  }
+  // This is a brutally ugly hack to make sure that our error handler
+  // is attached before any userland ones.  NEVER DO THIS.
+  if (!dest._events || !dest._events.error)
+    dest.on('error', onerror);
+  else if (isArray(dest._events.error))
+    dest._events.error.unshift(onerror);
+  else
+    dest._events.error = [onerror, dest._events.error];
+
+
+
+  // Both close and finish should trigger unpipe, but only once.
+  function onclose() {
+    dest.removeListener('finish', onfinish);
+    unpipe();
+  }
+  dest.once('close', onclose);
+  function onfinish() {
+    dest.removeListener('close', onclose);
+    unpipe();
+  }
+  dest.once('finish', onfinish);
+
+  function 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) {
+    // the handler that waits for readable events after all
+    // the data gets sucked out in flow.
+    // This would be easier to follow with a .once() handler
+    // in flow(), but that is too slow.
+    this.on('readable', pipeOnReadable);
+
+    state.flowing = true;
+    process.nextTick(function() {
+      flow(src);
+    });
+  }
+
+  return dest;
+};
+
+function pipeOnDrain(src) {
+  return function() {
+    var dest = this;
+    var state = src._readableState;
+    state.awaitDrain--;
+    if (state.awaitDrain === 0)
+      flow(src);
+  };
+}
+
+function flow(src) {
+  var state = src._readableState;
+  var chunk;
+  state.awaitDrain = 0;
+
+  function write(dest, i, list) {
+    var written = dest.write(chunk);
+    if (false === written) {
+      state.awaitDrain++;
+    }
+  }
+
+  while (state.pipesCount && null !== (chunk = src.read())) {
+
+    if (state.pipesCount === 1)
+      write(state.pipes, 0, null);
+    else
+      forEach(state.pipes, write);
+
+    src.emit('data', chunk);
+
+    // if anyone needs a drain, then we have to wait for that.
+    if (state.awaitDrain > 0)
+      return;
+  }
+
+  // if every destination was unpiped, either before entering this
+  // function, or in the while loop, then stop flowing.
+  //
+  // NB: This is a pretty rare edge case.
+  if (state.pipesCount === 0) {
+    state.flowing = false;
+
+    // if there were data event listeners added, then switch to old mode.
+    if (EE.listenerCount(src, 'data') > 0)
+      emitDataEvents(src);
+    return;
+  }
+
+  // at this point, no one needed a drain, so we just ran out of data
+  // on the next readable event, start it over again.
+  state.ranOut = true;
+}
+
+function pipeOnReadable() {
+  if (this._readableState.ranOut) {
+    this._readableState.ranOut = false;
+    flow(this);
+  }
+}
+
+
+Readable.prototype.unpipe = function(dest) {
+  var state = this._readableState;
+
+  // 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;
+    this.removeListener('readable', pipeOnReadable);
+    state.flowing = false;
+    if (dest)
+      dest.emit('unpipe', this);
+    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;
+    this.removeListener('readable', pipeOnReadable);
+    state.flowing = false;
+
+    for (var i = 0; i < len; i++)
+      dests[i].emit('unpipe', this);
+    return this;
+  }
+
+  // try to find the right one.
+  var i = indexOf(state.pipes, dest);
+  if (i === -1)
+    return this;
+
+  state.pipes.splice(i, 1);
+  state.pipesCount -= 1;
+  if (state.pipesCount === 1)
+    state.pipes = state.pipes[0];
+
+  dest.emit('unpipe', this);
+
+  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' && !this._readableState.flowing)
+    emitDataEvents(this);
+
+  if (ev === 'readable' && this.readable) {
+    var state = this._readableState;
+    if (!state.readableListening) {
+      state.readableListening = true;
+      state.emittedReadable = false;
+      state.needReadable = true;
+      if (!state.reading) {
+        this.read(0);
+      } else if (state.length) {
+        emitReadable(this, state);
+      }
+    }
+  }
+
+  return res;
+};
+Readable.prototype.addListener = Readable.prototype.on;
+
+// 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() {
+  emitDataEvents(this);
+  this.read(0);
+  this.emit('resume');
+};
+
+Readable.prototype.pause = function() {
+  emitDataEvents(this, true);
+  this.emit('pause');
+};
+
+function emitDataEvents(stream, startPaused) {
+  var state = stream._readableState;
+
+  if (state.flowing) {
+    // https://github.com/isaacs/readable-stream/issues/16
+    throw new Error('Cannot switch to old mode now.');
+  }
+
+  var paused = startPaused || false;
+  var readable = false;
+
+  // convert to an old-style stream.
+  stream.readable = true;
+  stream.pipe = Stream.prototype.pipe;
+  stream.on = stream.addListener = Stream.prototype.on;
+
+  stream.on('readable', function() {
+    readable = true;
+
+    var c;
+    while (!paused && (null !== (c = stream.read())))
+      stream.emit('data', c);
+
+    if (c === null) {
+      readable = false;
+      stream._readableState.needReadable = true;
+    }
+  });
+
+  stream.pause = function() {
+    paused = true;
+    this.emit('pause');
+  };
+
+  stream.resume = function() {
+    paused = false;
+    if (readable)
+      process.nextTick(function() {
+        stream.emit('readable');
+      });
+    else
+      this.read(0);
+    this.emit('resume');
+  };
+
+  // now make it start, just in case it hadn't already.
+  stream.emit('readable');
+}
+
+// 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 state = this._readableState;
+  var paused = false;
+
+  var self = this;
+  stream.on('end', function() {
+    if (state.decoder && !state.ended) {
+      var chunk = state.decoder.end();
+      if (chunk && chunk.length)
+        self.push(chunk);
+    }
+
+    self.push(null);
+  });
+
+  stream.on('data', function(chunk) {
+    if (state.decoder)
+      chunk = state.decoder.write(chunk);
+
+    // don't skip over falsy values in objectMode
+    //if (state.objectMode && util.isNullOrUndefined(chunk))
+    if (state.objectMode && (chunk === null || chunk === undefined))
+      return;
+    else if (!state.objectMode && (!chunk || !chunk.length))
+      return;
+
+    var ret = self.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 (typeof stream[i] === 'function' &&
+        typeof this[i] === 'undefined') {
+      this[i] = function(method) { return function() {
+        return stream[method].apply(stream, arguments);
+      }}(i);
+    }
+  }
+
+  // proxy certain important events.
+  var events = ['error', 'close', 'destroy', 'pause', 'resume'];
+  forEach(events, function(ev) {
+    stream.on(ev, self.emit.bind(self, ev));
+  });
+
+  // when we try to consume some more bytes, simply unpause the
+  // underlying stream.
+  self._read = function(n) {
+    if (paused) {
+      paused = false;
+      stream.resume();
+    }
+  };
+
+  return self;
+};
+
+
+
+// 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.
+function fromList(n, state) {
+  var list = state.buffer;
+  var length = state.length;
+  var stringMode = !!state.decoder;
+  var objectMode = !!state.objectMode;
+  var ret;
+
+  // nothing in the list, definitely empty.
+  if (list.length === 0)
+    return null;
+
+  if (length === 0)
+    ret = null;
+  else if (objectMode)
+    ret = list.shift();
+  else if (!n || n >= length) {
+    // read it all, truncate the array.
+    if (stringMode)
+      ret = list.join('');
+    else
+      ret = Buffer.concat(list, length);
+    list.length = 0;
+  } else {
+    // read just some of it.
+    if (n < list[0].length) {
+      // just take a part of the first list item.
+      // slice is the same for buffers and strings.
+      var buf = list[0];
+      ret = buf.slice(0, n);
+      list[0] = buf.slice(n);
+    } else if (n === list[0].length) {
+      // first list is a perfect match
+      ret = list.shift();
+    } else {
+      // complex case.
+      // we have enough to cover it, but it spans past the first buffer.
+      if (stringMode)
+        ret = '';
+      else
+        ret = new Buffer(n);
+
+      var c = 0;
+      for (var i = 0, l = list.length; i < l && c < n; i++) {
+        var buf = list[0];
+        var cpy = Math.min(n - c, buf.length);
+
+        if (stringMode)
+          ret += buf.slice(0, cpy);
+        else
+          buf.copy(ret, c, 0, cpy);
+
+        if (cpy < buf.length)
+          list[0] = buf.slice(cpy);
+        else
+          list.shift();
+
+        c += cpy;
+      }
+    }
+  }
+
+  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.calledRead) {
+    state.ended = true;
+    process.nextTick(function() {
+      // 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 forEach (xs, f) {
+  for (var i = 0, l = xs.length; i < l; i++) {
+    f(xs[i], i);
+  }
+}
+
+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'))
+},{"_process":10,"buffer":3,"core-util-is":17,"events":7,"inherits":8,"isarray":9,"stream":22,"string_decoder/":23}],15:[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.
+
+module.exports = Transform;
+
+var Duplex = require('./_stream_duplex');
+
+/*<replacement>*/
+var util = require('core-util-is');
+util.inherits = require('inherits');
+/*</replacement>*/
+
+util.inherits(Transform, Duplex);
+
+
+function TransformState(options, stream) {
+  this.afterTransform = function(er, data) {
+    return afterTransform(stream, er, data);
+  };
+
+  this.needTransform = false;
+  this.transforming = false;
+  this.writecb = null;
+  this.writechunk = null;
+}
+
+function afterTransform(stream, er, data) {
+  var ts = stream._transformState;
+  ts.transforming = false;
+
+  var cb = ts.writecb;
+
+  if (!cb)
+    return stream.emit('error', new Error('no writecb in Transform class'));
+
+  ts.writechunk = null;
+  ts.writecb = null;
+
+  if (data !== null && data !== undefined)
+    stream.push(data);
+
+  if (cb)
+    cb(er);
+
+  var rs = stream._readableState;
+  rs.reading = false;
+  if (rs.needReadable || rs.length < rs.highWaterMark) {
+    stream._read(rs.highWaterMark);
+  }
+}
+
+
+function Transform(options) {
+  if (!(this instanceof Transform))
+    return new Transform(options);
+
+  Duplex.call(this, options);
+
+  var ts = this._transformState = new TransformState(options, this);
+
+  // when the writable side finishes, then flush out anything remaining.
+  var stream = this;
+
+  // 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;
+
+  this.once('finish', function() {
+    if ('function' === typeof this._flush)
+      this._flush(function(er) {
+        done(stream, er);
+      });
+    else
+      done(stream);
+  });
+}
+
+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('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;
+  }
+};
+
+
+function done(stream, er) {
+  if (er)
+    return stream.emit('error', er);
+
+  // if there's nothing in the write buffer, then that means
+  // that nothing more will ever be provided
+  var ws = stream._writableState;
+  var rs = stream._readableState;
+  var ts = stream._transformState;
+
+  if (ws.length)
+    throw new Error('calling transform done when ws.length != 0');
+
+  if (ts.transforming)
+    throw new Error('calling transform done when still transforming');
+
+  return stream.push(null);
+}
+
+},{"./_stream_duplex":12,"core-util-is":17,"inherits":8}],16:[function(require,module,exports){
+(function (process){
+// 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, cb), and it'll handle all
+// the drain event emission and buffering.
+
+module.exports = Writable;
+
+/*<replacement>*/
+var Buffer = require('buffer').Buffer;
+/*</replacement>*/
+
+Writable.WritableState = WritableState;
+
+
+/*<replacement>*/
+var util = require('core-util-is');
+util.inherits = require('inherits');
+/*</replacement>*/
+
+var Stream = require('stream');
+
+util.inherits(Writable, Stream);
+
+function WriteReq(chunk, encoding, cb) {
+  this.chunk = chunk;
+  this.encoding = encoding;
+  this.callback = cb;
+}
+
+function WritableState(options, stream) {
+  options = options || {};
+
+  // 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;
+  this.highWaterMark = (hwm || hwm === 0) ? hwm : 16 * 1024;
+
+  // object stream flag to indicate whether or not this stream
+  // contains buffers or objects.
+  this.objectMode = !!options.objectMode;
+
+  // cast to ints.
+  this.highWaterMark = ~~this.highWaterMark;
+
+  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;
+
+  // 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;
+
+  // 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, becuase 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.buffer = [];
+
+  // True if the error was already emitted and should not be thrown again
+  this.errorEmitted = false;
+}
+
+function Writable(options) {
+  var Duplex = require('./_stream_duplex');
+
+  // Writable ctor is applied to Duplexes, though they're not
+  // instanceof Writable, they're instanceof Readable.
+  if (!(this instanceof Writable) && !(this instanceof Duplex))
+    return new Writable(options);
+
+  this._writableState = new WritableState(options, this);
+
+  // legacy.
+  this.writable = true;
+
+  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, state, cb) {
+  var er = new Error('write after end');
+  // TODO: defer error events consistently everywhere, not just the cb
+  stream.emit('error', er);
+  process.nextTick(function() {
+    cb(er);
+  });
+}
+
+// If we get something that is not a buffer, string, null, or undefined,
+// and we're not in objectMode, then that's an error.
+// Otherwise stream chunks are all considered to be of length=1, and the
+// watermarks determine how many objects to keep in the buffer, rather than
+// how many bytes or characters.
+function validChunk(stream, state, chunk, cb) {
+  var valid = true;
+  if (!Buffer.isBuffer(chunk) &&
+      'string' !== typeof chunk &&
+      chunk !== null &&
+      chunk !== undefined &&
+      !state.objectMode) {
+    var er = new TypeError('Invalid non-string/buffer chunk');
+    stream.emit('error', er);
+    process.nextTick(function() {
+      cb(er);
+    });
+    valid = false;
+  }
+  return valid;
+}
+
+Writable.prototype.write = function(chunk, encoding, cb) {
+  var state = this._writableState;
+  var ret = false;
+
+  if (typeof encoding === 'function') {
+    cb = encoding;
+    encoding = null;
+  }
+
+  if (Buffer.isBuffer(chunk))
+    encoding = 'buffer';
+  else if (!encoding)
+    encoding = state.defaultEncoding;
+
+  if (typeof cb !== 'function')
+    cb = function() {};
+
+  if (state.ended)
+    writeAfterEnd(this, state, cb);
+  else if (validChunk(this, state, chunk, cb))
+    ret = writeOrBuffer(this, state, chunk, encoding, cb);
+
+  return ret;
+};
+
+function decodeChunk(state, chunk, encoding) {
+  if (!state.objectMode &&
+      state.decodeStrings !== false &&
+      typeof chunk === 'string') {
+    chunk = new Buffer(chunk, encoding);
+  }
+  return chunk;
+}
+
+// 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, chunk, encoding, cb) {
+  chunk = decodeChunk(state, chunk, encoding);
+  if (Buffer.isBuffer(chunk))
+    encoding = 'buffer';
+  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.buffer.push(new WriteReq(chunk, encoding, cb));
+  else
+    doWrite(stream, state, len, chunk, encoding, cb);
+
+  return ret;
+}
+
+function doWrite(stream, state, len, chunk, encoding, cb) {
+  state.writelen = len;
+  state.writecb = cb;
+  state.writing = true;
+  state.sync = true;
+  stream._write(chunk, encoding, state.onwrite);
+  state.sync = false;
+}
+
+function onwriteError(stream, state, sync, er, cb) {
+  if (sync)
+    process.nextTick(function() {
+      cb(er);
+    });
+  else
+    cb(er);
+
+  stream._writableState.errorEmitted = true;
+  stream.emit('error', er);
+}
+
+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(stream, state);
+
+    if (!finished && !state.bufferProcessing && state.buffer.length)
+      clearBuffer(stream, state);
+
+    if (sync) {
+      process.nextTick(function() {
+        afterWrite(stream, state, finished, cb);
+      });
+    } else {
+      afterWrite(stream, state, finished, cb);
+    }
+  }
+}
+
+function afterWrite(stream, state, finished, cb) {
+  if (!finished)
+    onwriteDrain(stream, state);
+  cb();
+  if (finished)
+    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;
+
+  for (var c = 0; c < state.buffer.length; c++) {
+    var entry = state.buffer[c];
+    var chunk = entry.chunk;
+    var encoding = entry.encoding;
+    var cb = entry.callback;
+    var len = state.objectMode ? 1 : chunk.length;
+
+    doWrite(stream, state, len, chunk, encoding, cb);
+
+    // 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) {
+      c++;
+      break;
+    }
+  }
+
+  state.bufferProcessing = false;
+  if (c < state.buffer.length)
+    state.buffer = state.buffer.slice(c);
+  else
+    state.buffer.length = 0;
+}
+
+Writable.prototype._write = function(chunk, encoding, cb) {
+  cb(new Error('not implemented'));
+};
+
+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 (typeof chunk !== 'undefined' && chunk !== null)
+    this.write(chunk, encoding);
+
+  // ignore unnecessary end() calls.
+  if (!state.ending && !state.finished)
+    endWritable(this, state, cb);
+};
+
+
+function needFinish(stream, state) {
+  return (state.ending &&
+          state.length === 0 &&
+          !state.finished &&
+          !state.writing);
+}
+
+function finishMaybe(stream, state) {
+  var need = needFinish(stream, state);
+  if (need) {
+    state.finished = true;
+    stream.emit('finish');
+  }
+  return need;
+}
+
+function endWritable(stream, state, cb) {
+  state.ending = true;
+  finishMaybe(stream, state);
+  if (cb) {
+    if (state.finished)
+      process.nextTick(cb);
+    else
+      stream.once('finish', cb);
+  }
+  state.ended = true;
+}
+
+}).call(this,require('_process'))
+},{"./_stream_duplex":12,"_process":10,"buffer":3,"core-util-is":17,"inherits":8,"stream":22}],17:[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(ar) {
+  return Array.isArray(ar);
+}
+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 isObject(re) && objectToString(re) === '[object RegExp]';
+}
+exports.isRegExp = isRegExp;
+
+function isObject(arg) {
+  return typeof arg === 'object' && arg !== null;
+}
+exports.isObject = isObject;
+
+function isDate(d) {
+  return isObject(d) && objectToString(d) === '[object Date]';
+}
+exports.isDate = isDate;
+
+function isError(e) {
+  return isObject(e) &&
+      (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;
+
+function isBuffer(arg) {
+  return Buffer.isBuffer(arg);
+}
+exports.isBuffer = isBuffer;
+
+function objectToString(o) {
+  return Object.prototype.toString.call(o);
+}
+}).call(this,require("buffer").Buffer)
+},{"buffer":3}],18:[function(require,module,exports){
+module.exports = require("./lib/_stream_passthrough.js")
+
+},{"./lib/_stream_passthrough.js":13}],19:[function(require,module,exports){
+var Stream = require('stream'); // hack to fix a circular dependency issue when used with browserify
+exports = module.exports = require('./lib/_stream_readable.js');
+exports.Stream = Stream;
+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":12,"./lib/_stream_passthrough.js":13,"./lib/_stream_readable.js":14,"./lib/_stream_transform.js":15,"./lib/_stream_writable.js":16,"stream":22}],20:[function(require,module,exports){
+module.exports = require("./lib/_stream_transform.js")
+
+},{"./lib/_stream_transform.js":15}],21:[function(require,module,exports){
+module.exports = require("./lib/_stream_writable.js")
+
+},{"./lib/_stream_writable.js":16}],22:[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.
+
+module.exports = Stream;
+
+var EE = require('events').EventEmitter;
+var inherits = require('inherits');
+
+inherits(Stream, EE);
+Stream.Readable = require('readable-stream/readable.js');
+Stream.Writable = require('readable-stream/writable.js');
+Stream.Duplex = require('readable-stream/duplex.js');
+Stream.Transform = require('readable-stream/transform.js');
+Stream.PassThrough = require('readable-stream/passthrough.js');
+
+// Backwards-compat with node 0.4.x
+Stream.Stream = Stream;
+
+
+
+// old-style streams.  Note that the pipe method (the only relevant
+// part of this class) is overridden in the Readable class.
+
+function Stream() {
+  EE.call(this);
+}
+
+Stream.prototype.pipe = function(dest, options) {
+  var source = this;
+
+  function ondata(chunk) {
+    if (dest.writable) {
+      if (false === dest.write(chunk) && source.pause) {
+        source.pause();
+      }
+    }
+  }
+
+  source.on('data', ondata);
+
+  function ondrain() {
+    if (source.readable && source.resume) {
+      source.resume();
+    }
+  }
+
+  dest.on('drain', ondrain);
+
+  // If the 'end' option is not supplied, dest.end() will be called when
+  // source gets the 'end' or 'close' events.  Only dest.end() once.
+  if (!dest._isStdio && (!options || options.end !== false)) {
+    source.on('end', onend);
+    source.on('close', onclose);
+  }
+
+  var didOnEnd = false;
+  function onend() {
+    if (didOnEnd) return;
+    didOnEnd = true;
+
+    dest.end();
+  }
+
+
+  function onclose() {
+    if (didOnEnd) return;
+    didOnEnd = true;
+
+    if (typeof dest.destroy === 'function') dest.destroy();
+  }
+
+  // don't leave dangling pipes when there are errors.
+  function onerror(er) {
+    cleanup();
+    if (EE.listenerCount(this, 'error') === 0) {
+      throw er; // Unhandled stream error in pipe.
+    }
+  }
+
+  source.on('error', onerror);
+  dest.on('error', onerror);
+
+  // remove all the event listeners that were added.
+  function cleanup() {
+    source.removeListener('data', ondata);
+    dest.removeListener('drain', ondrain);
+
+    source.removeListener('end', onend);
+    source.removeListener('close', onclose);
+
+    source.removeListener('error', onerror);
+    dest.removeListener('error', onerror);
+
+    source.removeListener('end', cleanup);
+    source.removeListener('close', cleanup);
+
+    dest.removeListener('close', cleanup);
+  }
+
+  source.on('end', cleanup);
+  source.on('close', cleanup);
+
+  dest.on('close', cleanup);
+
+  dest.emit('pipe', source);
+
+  // Allow for unix-like usage: A.pipe(B).pipe(C)
+  return dest;
+};
+
+},{"events":7,"inherits":8,"readable-stream/duplex.js":11,"readable-stream/passthrough.js":18,"readable-stream/readable.js":19,"readable-stream/transform.js":20,"readable-stream/writable.js":21}],23:[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.
+
+var Buffer = require('buffer').Buffer;
+
+var isBufferEncoding = Buffer.isEncoding
+  || function(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 assertEncoding(encoding) {
+  if (encoding && !isBufferEncoding(encoding)) {
+    throw new Error('Unknown encoding: ' + encoding);
+  }
+}
+
+// StringDecoder provides an interface for efficiently splitting a series of
+// buffers into a series of JS strings without breaking apart multi-byte
+// characters. CESU-8 is handled as part of the UTF-8 encoding.
+//
+// @TODO Handling all encodings inside a single object makes it very difficult
+// to reason about this code, so it should be split up in the future.
+// @TODO There should be a utf8-strict encoding that rejects invalid UTF-8 code
+// points as used by CESU-8.
+var StringDecoder = exports.StringDecoder = function(encoding) {
+  this.encoding = (encoding || 'utf8').toLowerCase().replace(/[-_]/, '');
+  assertEncoding(encoding);
+  switch (this.encoding) {
+    case 'utf8':
+      // CESU-8 represents each of Surrogate Pair by 3-bytes
+      this.surrogateSize = 3;
+      break;
+    case 'ucs2':
+    case 'utf16le':
+      // UTF-16 represents each of Surrogate Pair by 2-bytes
+      this.surrogateSize = 2;
+      this.detectIncompleteChar = utf16DetectIncompleteChar;
+      break;
+    case 'base64':
+      // Base-64 stores 3 bytes in 4 chars, and pads the remainder.
+      this.surrogateSize = 3;
+      this.detectIncompleteChar = base64DetectIncompleteChar;
+      break;
+    default:
+      this.write = passThroughWrite;
+      return;
+  }
+
+  // Enough space to store all bytes of a single character. UTF-8 needs 4
+  // bytes, but CESU-8 may require up to 6 (3 bytes per surrogate).
+  this.charBuffer = new Buffer(6);
+  // Number of bytes received for the current incomplete multi-byte character.
+  this.charReceived = 0;
+  // Number of bytes expected for the current incomplete multi-byte character.
+  this.charLength = 0;
+};
+
+
+// write decodes the given buffer and returns it as JS string that is
+// guaranteed to not contain any partial multi-byte characters. Any partial
+// character found at the end of the buffer is buffered up, and will be
+// returned when calling write again with the remaining bytes.
+//
+// Note: Converting a Buffer containing an orphan surrogate to a String
+// currently works, but converting a String to a Buffer (via `new Buffer`, or
+// Buffer#write) will replace incomplete surrogates with the unicode
+// replacement character. See https://codereview.chromium.org/121173009/ .
+StringDecoder.prototype.write = function(buffer) {
+  var charStr = '';
+  // if our last write ended with an incomplete multibyte character
+  while (this.charLength) {
+    // determine how many remaining bytes this buffer has to offer for this char
+    var available = (buffer.length >= this.charLength - this.charReceived) ?
+        this.charLength - this.charReceived :
+        buffer.length;
+
+    // add the new bytes to the char buffer
+    buffer.copy(this.charBuffer, this.charReceived, 0, available);
+    this.charReceived += available;
+
+    if (this.charReceived < this.charLength) {
+      // still not enough chars in this buffer? wait for more ...
+      return '';
+    }
+
+    // remove bytes belonging to the current character from the buffer
+    buffer = buffer.slice(available, buffer.length);
+
+    // get the character that was split
+    charStr = this.charBuffer.slice(0, this.charLength).toString(this.encoding);
+
+    // CESU-8: lead surrogate (D800-DBFF) is also the incomplete character
+    var charCode = charStr.charCodeAt(charStr.length - 1);
+    if (charCode >= 0xD800 && charCode <= 0xDBFF) {
+      this.charLength += this.surrogateSize;
+      charStr = '';
+      continue;
+    }
+    this.charReceived = this.charLength = 0;
+
+    // if there are no more bytes in this buffer, just emit our char
+    if (buffer.length === 0) {
+      return charStr;
+    }
+    break;
+  }
+
+  // determine and set charLength / charReceived
+  this.detectIncompleteChar(buffer);
+
+  var end = buffer.length;
+  if (this.charLength) {
+    // buffer the incomplete character bytes we got
+    buffer.copy(this.charBuffer, 0, buffer.length - this.charReceived, end);
+    end -= this.charReceived;
+  }
+
+  charStr += buffer.toString(this.encoding, 0, end);
+
+  var end = charStr.length - 1;
+  var charCode = charStr.charCodeAt(end);
+  // CESU-8: lead surrogate (D800-DBFF) is also the incomplete character
+  if (charCode >= 0xD800 && charCode <= 0xDBFF) {
+    var size = this.surrogateSize;
+    this.charLength += size;
+    this.charReceived += size;
+    this.charBuffer.copy(this.charBuffer, size, 0, size);
+    buffer.copy(this.charBuffer, 0, 0, size);
+    return charStr.substring(0, end);
+  }
+
+  // or just emit the charStr
+  return charStr;
+};
+
+// detectIncompleteChar determines if there is an incomplete UTF-8 character at
+// the end of the given buffer. If so, it sets this.charLength to the byte
+// length that character, and sets this.charReceived to the number of bytes
+// that are available for this character.
+StringDecoder.prototype.detectIncompleteChar = function(buffer) {
+  // determine how many bytes we have to check at the end of this buffer
+  var i = (buffer.length >= 3) ? 3 : buffer.length;
+
+  // Figure out if one of the last i bytes of our buffer announces an
+  // incomplete char.
+  for (; i > 0; i--) {
+    var c = buffer[buffer.length - i];
+
+    // See http://en.wikipedia.org/wiki/UTF-8#Description
+
+    // 110XXXXX
+    if (i == 1 && c >> 5 == 0x06) {
+      this.charLength = 2;
+      break;
+    }
+
+    // 1110XXXX
+    if (i <= 2 && c >> 4 == 0x0E) {
+      this.charLength = 3;
+      break;
+    }
+
+    // 11110XXX
+    if (i <= 3 && c >> 3 == 0x1E) {
+      this.charLength = 4;
+      break;
+    }
+  }
+  this.charReceived = i;
+};
+
+StringDecoder.prototype.end = function(buffer) {
+  var res = '';
+  if (buffer && buffer.length)
+    res = this.write(buffer);
+
+  if (this.charReceived) {
+    var cr = this.charReceived;
+    var buf = this.charBuffer;
+    var enc = this.encoding;
+    res += buf.slice(0, cr).toString(enc);
+  }
+
+  return res;
+};
+
+function passThroughWrite(buffer) {
+  return buffer.toString(this.encoding);
+}
+
+function utf16DetectIncompleteChar(buffer) {
+  this.charReceived = buffer.length % 2;
+  this.charLength = this.charReceived ? 2 : 0;
+}
+
+function base64DetectIncompleteChar(buffer) {
+  this.charReceived = buffer.length % 3;
+  this.charLength = this.charReceived ? 3 : 0;
+}
+
+},{"buffer":3}],24:[function(require,module,exports){
+module.exports = function isBuffer(arg) {
+  return arg && typeof arg === 'object'
+    && typeof arg.copy === 'function'
+    && typeof arg.fill === 'function'
+    && typeof arg.readUInt8 === 'function';
+}
+},{}],25:[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.
+
+var formatRegExp = /%[sdj%]/g;
+exports.format = function(f) {
+  if (!isString(f)) {
+    var objects = [];
+    for (var i = 0; i < arguments.length; i++) {
+      objects.push(inspect(arguments[i]));
+    }
+    return objects.join(' ');
+  }
+
+  var i = 1;
+  var args = arguments;
+  var len = args.length;
+  var str = String(f).replace(formatRegExp, function(x) {
+    if (x === '%%') return '%';
+    if (i >= len) return x;
+    switch (x) {
+      case '%s': return String(args[i++]);
+      case '%d': return Number(args[i++]);
+      case '%j':
+        try {
+          return JSON.stringify(args[i++]);
+        } catch (_) {
+          return '[Circular]';
+        }
+      default:
+        return x;
+    }
+  });
+  for (var x = args[i]; i < len; x = args[++i]) {
+    if (isNull(x) || !isObject(x)) {
+      str += ' ' + x;
+    } else {
+      str += ' ' + inspect(x);
+    }
+  }
+  return str;
+};
+
+
+// Mark that a method should not be used.
+// Returns a modified function which warns once by default.
+// If --no-deprecation is set, then it is a no-op.
+exports.deprecate = function(fn, msg) {
+  // Allow for deprecating things in the process of starting up.
+  if (isUndefined(global.process)) {
+    return function() {
+      return exports.deprecate(fn, msg).apply(this, arguments);
+    };
+  }
+
+  if (process.noDeprecation === true) {
+    return fn;
+  }
+
+  var warned = false;
+  function deprecated() {
+    if (!warned) {
+      if (process.throwDeprecation) {
+        throw new Error(msg);
+      } else if (process.traceDeprecation) {
+        console.trace(msg);
+      } else {
+        console.error(msg);
+      }
+      warned = true;
+    }
+    return fn.apply(this, arguments);
+  }
+
+  return deprecated;
+};
+
+
+var debugs = {};
+var debugEnviron;
+exports.debuglog = function(set) {
+  if (isUndefined(debugEnviron))
+    debugEnviron = process.env.NODE_DEBUG || '';
+  set = set.toUpperCase();
+  if (!debugs[set]) {
+    if (new RegExp('\\b' + set + '\\b', 'i').test(debugEnviron)) {
+      var pid = process.pid;
+      debugs[set] = function() {
+        var msg = exports.format.apply(exports, arguments);
+        console.error('%s %d: %s', set, pid, msg);
+      };
+    } else {
+      debugs[set] = function() {};
+    }
+  }
+  return debugs[set];
+};
+
+
+/**
+ * Echos the value of a value. Trys to print the value out
+ * in the best way possible given the different types.
+ *
+ * @param {Object} obj The object to print out.
+ * @param {Object} opts Optional options object that alters the output.
+ */
+/* legacy: obj, showHidden, depth, colors*/
+function inspect(obj, opts) {
+  // default options
+  var ctx = {
+    seen: [],
+    stylize: stylizeNoColor
+  };
+  // legacy...
+  if (arguments.length >= 3) ctx.depth = arguments[2];
+  if (arguments.length >= 4) ctx.colors = arguments[3];
+  if (isBoolean(opts)) {
+    // legacy...
+    ctx.showHidden = opts;
+  } else if (opts) {
+    // got an "options" object
+    exports._extend(ctx, opts);
+  }
+  // set default options
+  if (isUndefined(ctx.showHidden)) ctx.showHidden = false;
+  if (isUndefined(ctx.depth)) ctx.depth = 2;
+  if (isUndefined(ctx.colors)) ctx.colors = false;
+  if (isUndefined(ctx.customInspect)) ctx.customInspect = true;
+  if (ctx.colors) ctx.stylize = stylizeWithColor;
+  return formatValue(ctx, obj, ctx.depth);
+}
+exports.inspect = inspect;
+
+
+// http://en.wikipedia.org/wiki/ANSI_escape_code#graphics
+inspect.colors = {
+  'bold' : [1, 22],
+  'italic' : [3, 23],
+  'underline' : [4, 24],
+  'inverse' : [7, 27],
+  'white' : [37, 39],
+  'grey' : [90, 39],
+  'black' : [30, 39],
+  'blue' : [34, 39],
+  'cyan' : [36, 39],
+  'green' : [32, 39],
+  'magenta' : [35, 39],
+  'red' : [31, 39],
+  'yellow' : [33, 39]
+};
+
+// Don't use 'blue' not visible on cmd.exe
+inspect.styles = {
+  'special': 'cyan',
+  'number': 'yellow',
+  'boolean': 'yellow',
+  'undefined': 'grey',
+  'null': 'bold',
+  'string': 'green',
+  'date': 'magenta',
+  // "name": intentionally not styling
+  'regexp': 'red'
+};
+
+
+function stylizeWithColor(str, styleType) {
+  var style = inspect.styles[styleType];
+
+  if (style) {
+    return '\u001b[' + inspect.colors[style][0] + 'm' + str +
+           '\u001b[' + inspect.colors[style][1] + 'm';
+  } else {
+    return str;
+  }
+}
+
+
+function stylizeNoColor(str, styleType) {
+  return str;
+}
+
+
+function arrayToHash(array) {
+  var hash = {};
+
+  array.forEach(function(val, idx) {
+    hash[val] = true;
+  });
+
+  return hash;
+}
+
+
+function formatValue(ctx, value, recurseTimes) {
+  // Provide a hook for user-specified inspect functions.
+  // Check that value is an object with an inspect function on it
+  if (ctx.customInspect &&
+      value &&
+      isFunction(value.inspect) &&
+      // Filter out the util module, it's inspect function is special
+      value.inspect !== exports.inspect &&
+      // Also filter out any prototype objects using the circular check.
+      !(value.constructor && value.constructor.prototype === value)) {
+    var ret = value.inspect(recurseTimes, ctx);
+    if (!isString(ret)) {
+      ret = formatValue(ctx, ret, recurseTimes);
+    }
+    return ret;
+  }
+
+  // Primitive types cannot have properties
+  var primitive = formatPrimitive(ctx, value);
+  if (primitive) {
+    return primitive;
+  }
+
+  // Look up the keys of the object.
+  var keys = Object.keys(value);
+  var visibleKeys = arrayToHash(keys);
+
+  if (ctx.showHidden) {
+    keys = Object.getOwnPropertyNames(value);
+  }
+
+  // IE doesn't make error fields non-enumerable
+  // http://msdn.microsoft.com/en-us/library/ie/dww52sbt(v=vs.94).aspx
+  if (isError(value)
+      && (keys.indexOf('message') >= 0 || keys.indexOf('description') >= 0)) {
+    return formatError(value);
+  }
+
+  // Some type of object without properties can be shortcutted.
+  if (keys.length === 0) {
+    if (isFunction(value)) {
+      var name = value.name ? ': ' + value.name : '';
+      return ctx.stylize('[Function' + name + ']', 'special');
+    }
+    if (isRegExp(value)) {
+      return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
+    }
+    if (isDate(value)) {
+      return ctx.stylize(Date.prototype.toString.call(value), 'date');
+    }
+    if (isError(value)) {
+      return formatError(value);
+    }
+  }
+
+  var base = '', array = false, braces = ['{', '}'];
+
+  // Make Array say that they are Array
+  if (isArray(value)) {
+    array = true;
+    braces = ['[', ']'];
+  }
+
+  // Make functions say that they are functions
+  if (isFunction(value)) {
+    var n = value.name ? ': ' + value.name : '';
+    base = ' [Function' + n + ']';
+  }
+
+  // Make RegExps say that they are RegExps
+  if (isRegExp(value)) {
+    base = ' ' + RegExp.prototype.toString.call(value);
+  }
+
+  // Make dates with properties first say the date
+  if (isDate(value)) {
+    base = ' ' + Date.prototype.toUTCString.call(value);
+  }
+
+  // Make error with message first say the error
+  if (isError(value)) {
+    base = ' ' + formatError(value);
+  }
+
+  if (keys.length === 0 && (!array || value.length == 0)) {
+    return braces[0] + base + braces[1];
+  }
+
+  if (recurseTimes < 0) {
+    if (isRegExp(value)) {
+      return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
+    } else {
+      return ctx.stylize('[Object]', 'special');
+    }
+  }
+
+  ctx.seen.push(value);
+
+  var output;
+  if (array) {
+    output = formatArray(ctx, value, recurseTimes, visibleKeys, keys);
+  } else {
+    output = keys.map(function(key) {
+      return formatProperty(ctx, value, recurseTimes, visibleKeys, key, array);
+    });
+  }
+
+  ctx.seen.pop();
+
+  return reduceToSingleString(output, base, braces);
+}
+
+
+function formatPrimitive(ctx, value) {
+  if (isUndefined(value))
+    return ctx.stylize('undefined', 'undefined');
+  if (isString(value)) {
+    var simple = '\'' + JSON.stringify(value).replace(/^"|"$/g, '')
+                                             .replace(/'/g, "\\'")
+                                             .replace(/\\"/g, '"') + '\'';
+    return ctx.stylize(simple, 'string');
+  }
+  if (isNumber(value))
+    return ctx.stylize('' + value, 'number');
+  if (isBoolean(value))
+    return ctx.stylize('' + value, 'boolean');
+  // For some reason typeof null is "object", so special case here.
+  if (isNull(value))
+    return ctx.stylize('null', 'null');
+}
+
+
+function formatError(value) {
+  return '[' + Error.prototype.toString.call(value) + ']';
+}
+
+
+function formatArray(ctx, value, recurseTimes, visibleKeys, keys) {
+  var output = [];
+  for (var i = 0, l = value.length; i < l; ++i) {
+    if (hasOwnProperty(value, String(i))) {
+      output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
+          String(i), true));
+    } else {
+      output.push('');
+    }
+  }
+  keys.forEach(function(key) {
+    if (!key.match(/^\d+$/)) {
+      output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
+          key, true));
+    }
+  });
+  return output;
+}
+
+
+function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) {
+  var name, str, desc;
+  desc = Object.getOwnPropertyDescriptor(value, key) || { value: value[key] };
+  if (desc.get) {
+    if (desc.set) {
+      str = ctx.stylize('[Getter/Setter]', 'special');
+    } else {
+      str = ctx.stylize('[Getter]', 'special');
+    }
+  } else {
+    if (desc.set) {
+      str = ctx.stylize('[Setter]', 'special');
+    }
+  }
+  if (!hasOwnProperty(visibleKeys, key)) {
+    name = '[' + key + ']';
+  }
+  if (!str) {
+    if (ctx.seen.indexOf(desc.value) < 0) {
+      if (isNull(recurseTimes)) {
+        str = formatValue(ctx, desc.value, null);
+      } else {
+        str = formatValue(ctx, desc.value, recurseTimes - 1);
+      }
+      if (str.indexOf('\n') > -1) {
+        if (array) {
+          str = str.split('\n').map(function(line) {
+            return '  ' + line;
+          }).join('\n').substr(2);
+        } else {
+          str = '\n' + str.split('\n').map(function(line) {
+            return '   ' + line;
+          }).join('\n');
+        }
+      }
+    } else {
+      str = ctx.stylize('[Circular]', 'special');
+    }
+  }
+  if (isUndefined(name)) {
+    if (array && key.match(/^\d+$/)) {
+      return str;
+    }
+    name = JSON.stringify('' + key);
+    if (name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)) {
+      name = name.substr(1, name.length - 2);
+      name = ctx.stylize(name, 'name');
+    } else {
+      name = name.replace(/'/g, "\\'")
+                 .replace(/\\"/g, '"')
+                 .replace(/(^"|"$)/g, "'");
+      name = ctx.stylize(name, 'string');
+    }
+  }
+
+  return name + ': ' + str;
+}
+
+
+function reduceToSingleString(output, base, braces) {
+  var numLinesEst = 0;
+  var length = output.reduce(function(prev, cur) {
+    numLinesEst++;
+    if (cur.indexOf('\n') >= 0) numLinesEst++;
+    return prev + cur.replace(/\u001b\[\d\d?m/g, '').length + 1;
+  }, 0);
+
+  if (length > 60) {
+    return braces[0] +
+           (base === '' ? '' : base + '\n ') +
+           ' ' +
+           output.join(',\n  ') +
+           ' ' +
+           braces[1];
+  }
+
+  return braces[0] + base + ' ' + output.join(', ') + ' ' + braces[1];
+}
+
+
+// NOTE: These type checking functions intentionally don't use `instanceof`
+// because it is fragile and can be easily faked with `Object.create()`.
+function isArray(ar) {
+  return Array.isArray(ar);
+}
+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 isObject(re) && objectToString(re) === '[object RegExp]';
+}
+exports.isRegExp = isRegExp;
+
+function isObject(arg) {
+  return typeof arg === 'object' && arg !== null;
+}
+exports.isObject = isObject;
+
+function isDate(d) {
+  return isObject(d) && objectToString(d) === '[object Date]';
+}
+exports.isDate = isDate;
+
+function isError(e) {
+  return isObject(e) &&
+      (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 = require('./support/isBuffer');
+
+function objectToString(o) {
+  return Object.prototype.toString.call(o);
+}
+
+
+function pad(n) {
+  return n < 10 ? '0' + n.toString(10) : n.toString(10);
+}
+
+
+var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep',
+              'Oct', 'Nov', 'Dec'];
+
+// 26 Feb 16:19:34
+function timestamp() {
+  var d = new Date();
+  var time = [pad(d.getHours()),
+              pad(d.getMinutes()),
+              pad(d.getSeconds())].join(':');
+  return [d.getDate(), months[d.getMonth()], time].join(' ');
+}
+
+
+// log is just a thin wrapper to console.log that prepends a timestamp
+exports.log = function() {
+  console.log('%s - %s', timestamp(), exports.format.apply(exports, arguments));
+};
+
+
+/**
+ * Inherit the prototype methods from one constructor into another.
+ *
+ * The Function.prototype.inherits from lang.js rewritten as a standalone
+ * function (not on Function.prototype). NOTE: If this file is to be loaded
+ * during bootstrapping this function needs to be rewritten using some native
+ * functions as prototype setup using normal JavaScript does not work as
+ * expected during bootstrapping (see mirror.js in r114903).
+ *
+ * @param {function} ctor Constructor function which needs to inherit the
+ *     prototype.
+ * @param {function} superCtor Constructor function to inherit prototype from.
+ */
+exports.inherits = require('inherits');
+
+exports._extend = function(origin, add) {
+  // Don't do anything if add isn't an object
+  if (!add || !isObject(add)) return origin;
+
+  var keys = Object.keys(add);
+  var i = keys.length;
+  while (i--) {
+    origin[keys[i]] = add[keys[i]];
+  }
+  return origin;
+};
+
+function hasOwnProperty(obj, prop) {
+  return Object.prototype.hasOwnProperty.call(obj, prop);
+}
+
+}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
+},{"./support/isBuffer":24,"_process":10,"inherits":8}]},{},[2])(2)
+});

File diff ditekan karena terlalu besar
+ 0 - 0
assets/js/blob-stream.min.js


File diff ditekan karena terlalu besar
+ 673 - 0
assets/js/pdfkit.js


File diff ditekan karena terlalu besar
+ 0 - 0
assets/js/pdfkit.min.js


+ 134 - 0
bin/prepareData.js

@@ -0,0 +1,134 @@
+"use strict";
+
+const fs = require('fs');
+const path = require('path');
+const config = require('../build.json');
+
+// Change current directory to script location so that
+// the relative paths of the resources can be resolved
+process.chdir(path.dirname(process.argv[1]));
+
+function createDirectory(dir) {
+    fs.mkdirSync(
+        dir,
+        { recursive: true },
+        (error) => {
+            if (error !== null) {
+                console.error('Error while creating directory', error);
+            }
+        }
+    );
+}
+
+function transformData() {
+    // TSV laden und parsen
+    var matrix = fs.readFileSync(path.join('../', config.path.data, 'crime.tsv'), 'utf8');
+    matrix = matrix.split('\n').map(l => l.split('\t'));
+
+    var rowCount = matrix.length - 1; // trailing new line
+    var colCount = matrix[0].length - 1;  // treat dark figures separately
+
+    var result = {entries:[]};
+    var nodes = new Map();
+
+    // Die einzelnen Zeilen (je Straftat) in einen Tree einsortieren
+    for (var r = 2; r < rowCount; r++) {
+        var parentid = matrix[r][1].trim();
+
+        var node = {};
+        if (parentid === '') {
+            result.tree = node;
+        } else {
+            var parent = nodes.get(parentid);
+            if (!parent) throw Error('"'+parentid+'" not found');
+            if (!parent.children) parent.children = [];
+            parent.children.push(node);
+        }
+
+        nodes.set(matrix[r][0].trim(), node);
+
+        node.id = matrix[r][0].trim();
+        node.title = matrix[r][2].trim();
+        // node.dark = matrix[r][colcount].trim();
+        // node.dark = Math.random() * 0.8 + 0.1;  fake dark figure
+    }
+
+    // Jeden Wert den Straftaten, Geschlecht und Alter zuordnen
+    for (var c = 3; c < colCount; c++) {
+
+        // Zuordnung zum Alter
+        var alter = matrix[0][c];
+        switch (alter) {
+            case 'alle': alter = ''; break;
+            case 'bis unter 6': alter = '0-5'; break;
+            case '6 bis unter 14': alter = '6-13'; break;
+            case '14 bis unter 18': alter = '14-17'; break;
+            case '18 bis unter 21': alter = '18-20'; break;
+            case '21 bis unter 60': alter = '21-59'; break;
+            case '60 und älter': alter = '60+'; break;
+            default: throw Error(alter);
+        }
+
+        // Zuordnung zum Geschlecht
+        var geschlecht = matrix[1][c];
+        switch (geschlecht) {
+            case 'insges.': geschlecht = ''; break;
+            case 'männlich': geschlecht = 'm'; break;
+            case 'weiblich': geschlecht = 'w'; break;
+            default: throw Error(geschlecht);
+        }
+
+        var entry = {alter:alter, geschlecht:geschlecht, values:{}};
+        result.entries.push(entry);
+
+        // Zuordnung zur Straftat
+        for (var r = 2; r < rowCount; r++) {
+            var crimeId = matrix[r][0].trim();
+            var value = parseFloat(matrix[r][c].replace(/,/g, '.')) || 0;
+            entry.values[crimeId] = round(value);
+        }
+    }
+
+    // Validierung, ob die Summen aufgehen
+    result.entries.forEach((entry) => {
+        var values = entry.values;
+        validate(result.tree);
+        function validate(node) {
+            if (!node.children) return;
+
+            var sum = 0;
+            node.children.forEach(child => {
+                validate(child);
+                sum += values[child.id];
+            });
+            // if (Math.abs(sum - values[node.id]) > 1e-3) {
+            //     var msg = [
+            //         'Für Alter "'+entry.alter+'" und Geschlecht "'+entry.geschlecht+'"',
+            //         'ist die Differenz von "'+node.id+'" minus der Summe der Kinder gleich',
+            //         (sum - values[node.id]).toFixed(3)
+            //     ].join(' ');
+            //     console.log(msg);
+            // }
+            values[node.id] = round(sum);
+        }
+    });
+
+    // Resultat als JSON speichern
+    fs.writeFileSync(
+        path.join(
+            '../',
+            config.path.output,
+            config.path.data,
+            'data.json'),
+        JSON.stringify(result, null, '\t'),
+        'utf8'
+    );
+
+    // Runde alle Zahlen auf 4 Nachkommastellen
+    function round(v) {
+        return Math.round(v*1e4)/1e4;
+    }
+}
+
+createDirectory(path.join('../', config.path.output, config.path.data));
+transformData();

+ 119 - 0
bin/preprocess.js

@@ -0,0 +1,119 @@
+/**
+ * Generate html files, target-dependent
+ * Context for embedding page is loaded from markdown file
+ */
+const process = require('process');
+const path = require('path');
+const fs = require('fs');
+const posthtml = require('posthtml');
+const expressions = require('posthtml-expressions');
+const marked = require('marked');
+const config = require('../build.json');
+// const config = require('../src/config.json');
+
+const target = process.env.NODE_ENV || 'development';
+
+// Change current directory to script location so that
+// the relative paths of the resources can be resolved
+process.chdir(path.dirname(process.argv[1]));
+
+function createDirectory(dir) {
+    fs.mkdirSync(
+        dir,
+        { recursive: true },
+        (error) => {
+            if (error !== null) {
+                console.error('Error while creating directory', error);
+            }
+        }
+    );
+}
+
+function createVisualisationHtml() {
+    const visualisation = fs.readFileSync(
+        path.join(
+            '../',
+            config.path.input,
+            config.path.html,
+            config.path.skeletons,
+            config.html.visualisation.skeleton
+        ), 'utf8'
+    );
+
+    // Generate html file for the visualisation
+    posthtml(
+        expressions({
+            locals: {
+                javascript: path.join(config.path.js, `${config.main}${config[target].infix}.js`),
+                stylesheet: path.join(config.path.css, `${config.main}${config[target].infix}.css`)
+            }
+        })
+    ).process(visualisation)
+        .then((result) => {
+            fs.writeFileSync(
+                path.join(
+                    '../',
+                    config.path.output,
+                    config.html.visualisation.name
+                ), result.html
+            );
+        });
+}
+
+function createContextHtml() {
+    // Load context from markdown file
+    const md = fs.readFileSync(
+        path.join(
+            '../',
+            config.path.input,
+            config.path.html,
+            config.path.markdown,
+            config.context
+        ), 'utf8');
+
+    // Convert markdown to html
+    var converted = marked(md);
+
+    // Load html skeleton
+    const skeleton = fs.readFileSync(
+        path.join(
+            '../',
+            config.path.input,
+            config.path.html,
+            config.path.skeletons,
+            config.html.index.skeleton
+        ), 'utf8');
+
+    // Compile html
+    // 1: Assign variables to iframe in context
+    // 2: Place generated html from (1) into skeleton
+    // write file
+    posthtml(
+        expressions({
+            locals: {
+                d3: config.html.visualisation.name,
+                width: `${config.width}px`,
+                height: `${config.height}px`
+            }
+        })
+    ).process(converted)
+        .then((result) => posthtml(expressions({locals: { content: result.html }}))
+            .process(skeleton)
+            .then((result) => {
+                fs.writeFileSync(
+                    path.join(
+                        '../',
+                        config.path.output,
+                        config.html.index.name
+                    ), result.html
+                );
+            }));
+}
+
+function createHtml() {
+    createVisualisationHtml();
+    createContextHtml();
+}
+
+createDirectory(path.join('../', config.path.output));
+createHtml();

+ 39 - 0
build.json

@@ -0,0 +1,39 @@
+{
+    "context": "index.md",
+    "main": "main",
+    "path": {
+        "assets": "assets",
+        "bin": "bin",
+        "build": "build",
+        "css": "css",
+        "data": "data",
+        "fonts": "fonts",
+        "html": "html",
+        "img": "img",
+        "input": "src",
+        "js": "js",
+        "markdown": "markdown",
+        "output": "dist",
+        "skeletons": "skeletons"
+    },
+    "html": {
+        "index": {
+            "name": "index.html",
+            "skeleton": "main.html"
+        },
+        "visualisation": {
+            "name": "treemap.html",
+            "skeleton": "visualisation.html"
+        }
+    },
+    "development": {
+        "infix": "",
+        "sourcemap": true
+    },
+    "production": {
+        "infix": ".min",
+        "sourcemap": false
+    },
+    "height": 600,
+    "width": 960
+}

+ 73 - 0
data/context.md

@@ -0,0 +1,73 @@
+## Fragestellungen zur Risikokommunikation für Verbraucher
+
+Liegt ein Problem des Risikos vor, d.h. sind belastbare numerische Schätzer vom Eintreffen spezifischer Ereignisse oder Entscheidungenkonsequenzen verfügbar, ist eine Hauptfragestellung, wie Risikokommunikation hier transparent, ausgewogen und verständlich für die Verbraucher sein kann?
+Vier Herausforderungen sind hierbei
+
+1. Wie können Einzelfallwahrscheinlichkeiten trotz aleatorischer Unsicherheit über den konkreten Ausgang im Einzelfall vermittelt werden?
+2. Wie lässt sich der massenhaften Stratifizierung von Wahrscheinlichkeiten durch vorliegende Einflussfaktoren oder Kategorien Rechnung tragen?
+3. Wie können hierarchisch strukturierte Ereignisse zwischen zu vergleichenden Wahrscheinlichkeiten abgebildet werden?
+4. Wie lassen sich die ersten drei Herausforderungen nicht nur nach dem letzten Stand der Forschung sondern zudem auch ansprechend adressieren, da das Hervorrufen von Aufmerksamkeit und Bindung des Verbrauchers an das Informationsangebot für dessen Exploration notwendig ist.
+
+## Lösungsansatz
+Dynamische Treemaps mit visueller Legende
+
+1.	Einzelfallwahrscheinlichkeiten lassen sich entweder mit einfachen Häufigkeiten (sofern nur Wahrscheinlichkeitswerte > 1% auch als Prozentformat) in tabellarischer Form (Schwartz et al., 2009) oder, zur Unterstützung von Verbrauchern mit niedriger Numeracy (Cokely et al., 2012), durch den Einsatz von empirisch validierten Grafikformaten (Garcia-Retamero & Galesic, 2010), Barcharts oder IconArrays kommunizieren.
+2.	Multiple Vergleiche, welche stratifizierte Daten implizieren, wenn zum Beispiel dasselbe Risiko für viele Gruppen verglichen soll, erfordern den Einsatz von mehreren Explorationsebenen bzw. hierarchisierter Navigation. Barcharts sind geeignet multiple Instanzen vergleichbar nebeneinander zu stellen. Dieses Prinzip lässt sich mit einer Hierarchisierung verknüpfen.
+3.	Treemaps, die mehrere Tiefenebenen aufweisen, zwischen denen man dynamisch navigieren kann, erlauben die Abbildung von Hierarchien (Stasko et al., 2000) und zugleich den verständlichen Vergleich von Wahrscheinlichkeiten, da sie die Teile vom Ganzen (part-to-whole relationships) einander gegenüberstellen.
+4.	Dynamische Informationsvisualisierungen können ansprechend sein, wenn Sie auf verschiedenen Explorationstiefen, mit einem leichten Einstieg, begleitet mit Erklärtext und einem durchziehenden Narrativ versehen sind. 
+
+Erste Ergebnisse der RisikoAtlas-Kommunikationsstudien mit dem vorliegenden Format zeigen, dass es besser angenommen wird und exploriert wird als Tabellen mit denselben Informationen. Es wird nicht gezeigt, dass Informationen besser extrahiert oder gemerkt werden können als aus klassischen Tabellen.
+
+## Thematisches Muster
+Digitale Kriminalität
+
+## Einleitung
+Kriminalität ist in der digitalen Welt genauso allgegenwärtig wie in der analogen Welt. Verbraucher haben im Rahmen der dynamischen Entwicklung der digitalen Welt weniger Erfahrungen bezüglich der Verbindung zwischen ihrem Verhalten und dem Risiko, Opfer eines digitalen Verbrechens zu werden.
+
+## Welche Kriminalitätsrisiken werden hier dargestellt?
+Es werden die Häufigkeiten von Straftaten aus Sicht der Betroffenen dargestellt. Um ein Verständnis vom zahlenmäßigen Verhältnis der verschiedenen Straftaten zu vermitteln, wird ein Überblick über die jährlich Betroffenen gegebenen. Hierzu werden die analogen Straftaten aus polizeilichen Opferstatistiken den registrierten Fällen von Computerkriminalität gegenübergestellt. Es werden nicht die möglichen digitalen Risiken durch institutionelle Überwachung, zum Beispiel Kunden-Profiling, thematisiert.
+
+## Für welche Verbraucher ist die folgende Grafik geeignet?
+Für alle Verbraucher stellt sich die Frage, welche digitalen Kriminalitätsrisiken bestehen und inwieweit diese den einzelnen betreffen können.
+
+<iframe src="{{ d3 }}" width="{{ width }}" height="{{ height }}" frameborder="0"></iframe>
+
+<div class="logos">
+    <img src="img/HardingCenter_Logo_de_RGB.png" width="200" height="34" alt="Harding Center Logo"/>
+    <img src="img/mpib.png" width="500" height="40" alt="Max-Planck-Institut für Bildungsforschung Logo"/>
+    <img src="img/BMJV_Web_Master_de_WBZ.png" width="200" height="165" alt="Bundesministerium für Justiz und Verbraucherschutz Logo"/>
+</div>
+
+## Was zeigt die Grafik?
+Dargestellt sind hier die Risiken, Opfer von digitaler Kriminalität zu werden. Durch Klick auf die Vierecke lässt sich in die jeweiligen Kategorien von Straftaten eintauchen. Mit dem Klick auf den erscheinenden Pfeil links oben kann man immer wieder zurückkehren. Alle Zahlen beziehen sich auf die gesamte Bevölkerung Deutschlands und basieren auf dem Jahr 2016. Auf der rechten Seite werden in separaten Balken zusätzliche Informationen dazu gegeben, wie oft verschiedene Altersgruppen bzw. Männer oder Frauen Opfer wurden. 
+
+## Woher stammen die Zahlen? 
+Alle Zahlen stellen registrierte Tatopfer der Vergangenheit dar. Sie wurden der Polizeilichen Kriminalstatistik 2016 entnommen.
+
+## Wie hoch ist die Qualität der Daten? 
+Aus einem Jahr der Vergangenheit lässt sich nur bedingt auf zukünftige Jahre schließen. Die Verhältnismäßigkeit der verschiedenen Risiken, Opfer von bestimmten Straftaten zu werden, ist jedoch grob so auch in der Zukunft zu erwarten. 
+Wie viele Verbraucher tatsächlich betroffen sind, wird für analoge und digitale Straftaten nicht gleichermaßen gut erfasst. Nicht nur, dass die Dunkelziffern viel höher ausfallen als bei klassischen Straftaten, auch die Vielfalt und ständig neuartige Tatbestände sowie länderübergreifende Netzwerke machen die Erfassung schwer.
+Eine verbesserte Erfassung digitaler Kriminalität lässt eine Zunahme dieser Zahlen in der Zukunft erwarten.
+
+## Was kann man tun? 
+Um das Risiko zu senken, Opfer von digitaler Kriminalität zu werden, sind bestimmte Daumenregeln empfehlenswert. 
+Hierzu zählt v.a. der äußerst vorsichtige Umgang mit digitalen Nachrichten, deren Absender man nicht kennt: 
+Keine persönlichen Daten auf Webseiten angeben, deren Adressen mit http statt https beginnen;
+Des Weiteren sind jegliche Passwörter persönlich, komplex und nur ein einziges Mal zu wählen.
+
+## Quellen.
+Cokely, E. T., Galesic, M., Schulz, E., Ghazal, S., & Garcia-Retamero, R. (2012). Measuring Risk Literacy: The Berlin Numeracy Test. Judgment and Decision Making, 7(1), 25-47.  
+Frey, C. B., & Osborne, M. A. (2017). The future of employment: how susceptible are jobs to computerisation?. Technological Forecasting and Social Change, 114, 254-280.  
+Garcia-Retamero, R., & Galesic, M. (2010). Who proficts from visual aids: Overcoming challenges in people's understanding of risks. Social Science & Medicine, 70(7), 1019-1025.  
+McDowell, M., Gigerenzer, G., Wegwarth, O., & Rebitschek, F. G. (2019). Effect of Tabular and Icon Fact Box Formats on Comprehension of Benefits and Harms of Prostate Cancer Screening: A Randomized Trial. Medical Decision Making, 39(1), 41-56.  
+McDowell, M., Rebitschek, F. G., Gigerenzer, G., & Wegwarth, O. (2016). A simple tool for communicating the benefits and harms of health interventions: a guide for creating a fact box. MDM Policy & Practice, 1(1), 2381468316665365.  
+O*Net (2018). O*NET Resource Center. https://www.onetcenter.org [Letzter Abruf, 31.12.2018]  
+Schwartz, L. M., Woloshin, S., & Welch, H. G. (2009). Using a drug facts box to communicate drug benefits and harms: two randomized trials. Annals of Internal Medicine, 150(8), 516-527.  
+Stasko, J., Catrambone, R., Guzdial, M., & McDonald, K. (2000). An Evaluation Of Space-Filling Information Visualizations For Depicting Hierarchical Structures. Int. J. Human-Computer Studies, 53, 663-694.
+
+
+## Letztes Update
+7. Februar 2019
+
+## Erstellung
+Felix G. Rebitschek, Michael Zitzmann in Zusammenarbeit mit Data Science and Stories

+ 72 - 0
data/crime.tsv

@@ -0,0 +1,72 @@
+Schlüssel	Elternschlüssel	Straftat	alle	alle	alle	bis unter 6	bis unter 6	bis unter 6	6 bis unter 14	6 bis unter 14	6 bis unter 14	14 bis unter 18	14 bis unter 18	14 bis unter 18	18 bis unter 21	18 bis unter 21	18 bis unter 21	21 bis unter 60	21 bis unter 60	21 bis unter 60	60 und älter	60 und älter	60 und älter
+			insges.	männlich	weiblich	insges.	männlich	weiblich	insges.	männlich	weiblich	insges.	männlich	weiblich	insges.	männlich	weiblich	insges.	männlich	weiblich	insges.	männlich	weiblich
+alles		Alles	100000.00000000	100000.0000	100000.0000	100000.0000	100000.0000	100000.0000	100000.0000	100000.0000	100000.0000	100000.0000	100000.0000	100000.0000	100000.0000	100000.0000	100000.0000	100000.0000	100000.0000	100000.0000	100000.0000	100000.0000	100000.0000
+leben	alles	Kein Opfer registrierter Straftat und kein Fall von Computerkriminalität	98768.28959719	98536.8999	98993.5829	99782.5663	99776.7368	99788.7157	99027.5016	98972.7265	99085.4703	97460.6045	97241.9432	97695.3630	96788.7936	96232.6000	97408.6584	98467.1164	98194.3162	98749.2225	99740.4349	99667.3438	99799.8826
+------	alles	"Registrierte Opfer von Straftaten gegen das Leben, gegen die sexuelle Selbstbestimmung und von Rohheits- und sonstigen Delikten im Vergleich mit Computerkriminalität"	1231.71040281	1463.1001	1006.4171	217.4337	223.2632	211.2843	972.4984	1027.2735	914.5297	2539.3955	2758.0568	2304.6370	3211.2064	3767.4000	2591.3416	1532.8836	1805.6838	1250.7775	259.5651	332.6562	200.1174
+000000	------	Straftaten gegen das Leben	1.69460099	1.89503536	1.49944745	2.22762579	2.59509425	1.83998667	0.46188072	0.59887691	0.31689706	0.73869120	0.80641309	0.66598381	1.48156928	1.65774248	1.28522831	1.50446411	1.82076037	1.17737825	2.41284685	2.47241853	2.36439488
+010000	000000	Mord	0.46622664	0.43825753	0.49345886	0.39311043	0.29779770	0.49365496	0.18817363	0.19962564	0.17605392	0.25693607	0.12406355	0.39959029	0.45586747	0.28830304	0.64261415	0.56044159	0.52408983	0.59803340	0.40286312	0.42494693	0.38490149
+010079	010000	Mord (nicht in Zusammenhang mit Raub- oder Sexualdelikten)	0.43723846	0.40642877	0.46723641	0.37127097	0.29779770	0.44877724	0.18817363	0.19962564	0.17605392	0.22481906	0.12406355	0.33299191	0.45586747	0.28830304	0.64261415	0.53287889	0.48794571	0.57934485	0.35954450	0.37665751	0.34562583
+011000	010000	Mord im Zusammenhang mit Raubdelikten	0.02294898	0.02938039	0.01668701	0.00000000	0.00000000	0.00000000	0.00000000	0.00000000	0.00000000	0.00000000	0.00000000	0.00000000	0.00000000	0.00000000	0.00000000	0.02296892	0.03162611	0.01401641	0.03898675	0.04828942	0.03142053
+012000	010000	Mord im Zusammenhang mit Sexualdelikten	0.00603921	0.00244837	0.00953544	0.02183947	0.00000000	0.04487772	0.00000000	0.00000000	0.00000000	0.03211701	0.00000000	0.06659838	0.00000000	0.00000000	0.00000000	0.00459378	0.00451802	0.00467214	0.00433186	0.00000000	0.00785513
+020000	000000	Totschlag und Tötung auf Verlangen	0.37805425	0.44070590	0.31705328	0.65518406	0.80830805	0.49365496	0.06842677	0.13308376	0.00000000	0.19270205	0.24812711	0.13319676	0.53184538	0.72075760	0.32130708	0.37898714	0.51053579	0.24295107	0.40719498	0.28973655	0.50272848
+020010	020000	Totschlag	0.36356016	0.42846407	0.30036626	0.65518406	0.80830805	0.49365496	0.06842677	0.13308376	0.00000000	0.19270205	0.24812711	0.13319676	0.53184538	0.72075760	0.32130708	0.37439336	0.50149976	0.24295107	0.36387636	0.26076289	0.44774255
+020020	020000	Totschlag (ohne eigene Schuld vom Getöteten provoziert)	0.00000000	0.00000000	0.00000000	0.00000000	0.00000000	0.00000000	0.00000000	0.00000000	0.00000000	0.00000000	0.00000000	0.00000000	0.00000000	0.00000000	0.00000000	0.00000000	0.00000000	0.00000000	0.00000000	0.00000000	0.00000000
+020030	020000	Tötung auf Verlangen (durch Getöteten zur Tötung bestimmt)	0.01449409	0.01224183	0.01668701	0.00000000	0.00000000	0.00000000	0.00000000	0.00000000	0.00000000	0.00000000	0.00000000	0.00000000	0.00000000	0.00000000	0.00000000	0.00459378	0.00903603	0.00000000	0.04331861	0.02897365	0.05498593
+030000	000000	Fahrlässige Tötung (keine Verkehrsunfälle)	0.85032010	1.01607193	0.68893531	1.17933130	1.48898850	0.85267675	0.20528032	0.26616751	0.14084314	0.28905308	0.43422243	0.13319676	0.49385643	0.64868184	0.32130708	0.56503538	0.78613475	0.33639378	1.60278875	1.75773505	1.47676491
+100000	------	Straftaten gegen die sexuelle Selbstbestimmung	64.80429575	17.45929867	110.90189833	39.76967223	24.33432642	56.05227716	230.27320245	99.18066985	369.00901713	301.12907344	54.40186790	566.01964119	210.95267184	30.19974355	412.39763357	50.13425677	9.44717107	92.20927412	6.99595629	1.84465601	11.18570869
+110000	100000	Straftaten gegen die sexuelle Selbstbestimmung unter Gewaltanwendung oder Ausnutzen eines Abhängigkeitsverhältnisses 	34.78582218	4.78165900	63.99946830	1.15749183	0.63813793	1.70535351	26.13902781	6.08858188	47.35850458	234.26146136	29.96134800	453.60157385	171.86203627	20.54159168	340.50517505	33.75282463	4.25145288	64.26055717	3.05829421	0.44426270	5.18438745
+111000	110000	Vergewaltigung und sexuelle Nötigung (auch mit Todesfolge)	10.02628854	1.03565886	18.78004288	0.28391309	0.12762759	0.44877724	2.83971114	0.96485724	4.82387742	63.43109215	4.15612902	127.06971119	50.52531128	5.26153050	100.97074901	10.78160999	1.12498594	20.76764408	0.53281896	0.01931577	0.95047103
+112000	110000	Sonstige sexuelle Nötigung (gegen den erkennbaren Willen und/oder unter Gewaltanwendung)	13.03985195	2.26229028	23.53345816	0.48046831	0.34034023	0.62828813	6.46633018	2.59513326	10.56323522	90.63419851	12.53041883	174.48775855	62.98568880	11.09966708	120.81146102	12.85800016	2.06925124	24.01477853	1.37753195	0.23178924	2.30940896
+113000	110000	Sexueller Missbrauch von Schutzbefohlenen	0.75369281	0.24728498	1.24675837	0.00000000	0.00000000	0.00000000	0.00000000	0.00000000	0.00000000	11.88329321	4.40425612	19.91291596	1.40559137	0.57660608	2.32947631	0.40654984	0.08132428	0.74286961	0.17327446	0.03863154	0.28278477
+130000	100000	Sexueller Missbrauch	29.68873296	12.61153379	46.31600066	38.56850146	23.69618849	54.25716821	203.86046754	92.92573327	321.26319392	64.65153849	23.88223391	108.42216447	37.57107734	9.36984884	69.00069483	16.04608594	5.15505604	27.30863434	3.93766209	1.40039331	6.00132123
+131000	130000	Sexueller Missbrauch von Kindern	16.52688906	8.20202644	24.63241725	38.56850146	23.69618849	54.25716821	203.86046754	92.92573327	321.26319392	0.00000000	0.00000000	0.00000000	0.00000000	0.00000000	0.00000000	0.00000000	0.00000000	0.00000000	0.00000000	0.00000000	0.00000000
+132000	130000	Exhibitionistische Handlungen und Erregung öffentlichen Ärgernisses	12.19919459	3.91248903	20.26757103	0.00000000	0.00000000	0.00000000	0.00000000	0.00000000	0.00000000	39.05428256	11.28978330	68.86272608	37.57107734	9.36984884	69.00069483	16.04608594	5.15505604	27.30863434	3.93766209	1.40039331	6.00132123
+133000	130000	Sexueller Missbrauch von Jugendlichen	0.96264932	0.49701832	1.41601237	0.00000000	0.00000000	0.00000000	0.00000000	0.00000000	0.00000000	25.59725592	12.59245061	39.55943839	0.00000000	0.00000000	0.00000000	0.00000000	0.00000000	0.00000000	0.00000000	0.00000000	0.00000000
+134000	130000	Sexueller Missbrauch Widerstandsunfähiger [Jahr 2016]	1.69251323	0.40700680	2.92644689	0.12260717	0.04779477	0.20143157	0.29583981	0.20335530	0.39344000	9.07095412	1.75530556	16.78439141	9.33879289	2.07992180	17.02417433	1.74693338	0.42005770	3.09932239	0.31046065	0.07208792	0.50030461
+141000	100000	Förderung sexueller Handlungen Minderjähriger oder Ausbeuten von Prostituierten	0.13648604	0.03917386	0.23123434	0.04367894	0.00000000	0.08975545	0.27370710	0.16635470	0.38731862	2.05548856	0.55828599	3.66291096	0.37988956	0.14415152	0.64261415	0.04823473	0.00000000	0.09811485	0.00000000	0.00000000	0.00000000
+141100	141000	Förderung sexueller Handlungen Minderjähriger	0.09541944	0.03427713	0.15495085	0.04367894	0.00000000	0.08975545	0.27370710	0.16635470	0.38731862	1.95913753	0.55828599	3.46311582	0.00000000	0.00000000	0.00000000	0.00000000	0.00000000	0.00000000	0.00000000	0.00000000	0.00000000
+141200	141000	Ausbeuten von Prostituierten	0.04106660	0.00489673	0.07628349	0.00000000	0.00000000	0.00000000	0.00000000	0.00000000	0.00000000	0.09635103	0.00000000	0.19979514	0.37988956	0.14415152	0.64261415	0.04823473	0.00000000	0.09811485	0.00000000	0.00000000	0.00000000
+142000	100000	Zuhälterei	0.19325457	0.02693203	0.35519502	0.00000000	0.00000000	0.00000000	0.00000000	0.00000000	0.00000000	0.16058504	0.00000000	0.33299191	1.13966868	0.14415152	2.24914954	0.28711147	0.04066214	0.54196776	0.00000000	0.00000000	0.00000000
+200000	------	Rohheitsdelikte	1001.81718478	1223.06169895	786.40178049	174.40999584	194.88732399	152.80864991	739.24865691	924.20014999	543.51366302	2231.84305060	2694.47427139	1735.15422187	2942.96642080	3659.86295515	2144.00179932	1318.79945969	1534.01094535	1096.24660692	247.35362250	322.92103887	185.89171071
+210000	200000	Raub, räuberische Erpressung und räuberischer Angriff auf Kraftfahrer	39.83701345	57.19138376	22.93987721	0.48046831	0.55305287	0.40389952	17.91070819	29.04552995	6.12667643	109.16571252	183.36593103	29.50308284	129.23842780	200.94721964	49.32063635	50.48797810	69.02624561	31.31732694	13.56305830	14.01359096	13.19662261
+210010	210000	Sonstiger Raub	2.80823044	3.98838838	1.65916601	0.00000000	0.00000000	0.00000000	1.76198944	2.86130077	0.59858333	8.38253927	12.90260949	3.52971420	10.40897390	13.98269749	6.42614154	3.36724334	4.60385811	2.08844475	0.95734139	1.17826196	0.77765812
+210020	210000	Sonstiger schwerer Raub	0.93728465	1.49840005	0.39095291	0.02183947	0.00000000	0.04487772	0.20528032	0.39925127	0.00000000	1.86278650	3.16362060	0.46618867	3.79889559	6.48681842	0.80326769	1.25869669	1.89756664	0.59803340	0.24691610	0.37665751	0.14139239
+210040	210000	Räuberischer Diebstahl	10.36086051	14.37435738	6.45310689	0.10919734	0.17017011	0.04487772	1.36853549	2.22915293	0.45774019	10.11685774	15.81810298	3.99590287	17.13301909	24.57783425	8.83594462	16.52383943	22.06147122	10.79730607	2.30888217	3.10018105	1.66528809
+210050	210000	Sonstige räuberische Erpressung	1.91925943	3.07025109	0.79859284	0.02183947	0.04254253	0.00000000	2.70285759	4.05905459	1.26758823	9.12123047	15.88013476	1.86475467	7.02795683	11.38797012	2.16882277	2.01207719	2.99544448	0.99516495	0.36820823	0.52152578	0.24350911
+211000	210000	Raub, räuberische Erpressung auf/gegen Geldinstitute, Postfilialen und -agenturen	0.10145865	0.06855425	0.13349612	0.00000000	0.00000000	0.00000000	0.00000000	0.00000000	0.00000000	0.03211701	0.00000000	0.06659838	0.00000000	0.00000000	0.00000000	0.16537621	0.10391436	0.22893466	0.04765048	0.04828942	0.04713080
+212000	210000	Raub, räuberische Erpressung auf/gegen sonstige Zahlstellen und Geschäfte 	0.03623523	0.02693203	0.04529333	0.00000000	0.00000000	0.00000000	0.00000000	0.00000000	0.00000000	0.00000000	0.00000000	0.00000000	0.00000000	0.00000000	0.00000000	0.05742229	0.03614413	0.07942631	0.02165931	0.02897365	0.01571027
+213000	210000	Raub, räuberische Erpressung auf/gegen Geld- und Werttransporte	0.06763910	0.10772811	0.02860631	0.00000000	0.00000000	0.00000000	0.00000000	0.00000000	0.00000000	0.00000000	0.00000000	0.00000000	0.15195582	0.28830304	0.00000000	0.11025081	0.16264857	0.05606563	0.01732745	0.03863154	0.00000000
+214000	210000	Räuberischer Angriff auf Kraftfahrer	0.16909775	0.26687191	0.07389964	0.00000000	0.00000000	0.00000000	0.00000000	0.00000000	0.00000000	0.00000000	0.00000000	0.00000000	0.37988956	0.64868184	0.08032677	0.25265810	0.37951333	0.12147553	0.08663723	0.15452616	0.03142053
+216000	210000	Handtaschenraub	1.49047585	0.35990982	2.59125497	0.02183947	0.00000000	0.04487772	0.15396024	0.13308376	0.17605392	1.02774428	0.68234954	1.39856600	2.08939257	0.86490912	3.45405108	1.28625939	0.37047730	2.23328096	2.49948408	0.36699963	4.23391642
+217000	210000	Sonstige Raubüberfälle auf Straßen, Wegen oder Plätzen	16.17299163	27.16217353	5.47334075	0.06551841	0.12762759	0.00000000	11.08513745	18.59845503	3.13375978	74.25452408	128.83999958	15.65061956	71.57119282	121.08727726	16.38666094	17.47245573	28.22404479	6.35410482	4.05462235	5.09936322	3.20489406
+218000	210000	Raub zur Erlangung von Betäubungsmitteln	0.12199195	0.22524968	0.02145473	0.02183947	0.04254253	0.00000000	0.01710669	0.03327094	0.00000000	0.61022317	1.17860375	0.00000000	0.75977912	1.36943945	0.08032677	0.13092283	0.22590079	0.03270495	0.01299558	0.01931577	0.00785513
+219000	210000	Raubüberfälle in Wohnungen	2.65483462	3.45219620	1.87848106	0.19655522	0.12762759	0.26926634	0.58162758	0.73196066	0.42252941	2.89053078	4.21816080	1.46516438	7.74974699	11.31589436	3.77535816	3.19957024	4.14753852	2.21926455	2.02731117	2.33720814	1.77525995
+220000	200000	Körperverletzung 	699.14792008	881.34813893	521.74811447	140.51514065	159.27922746	120.72107732	579.64320569	741.74231924	408.09298746	1707.24383072	2106.41303114	1278.68891763	2277.17198056	2956.83598945	1519.70214834	898.13751248	1080.33890540	709.72080390	149.01603499	191.58346238	114.39429466
+221000	220000	Körperverletzung mit Todesfolge	0.10749785	0.15179870	0.06436420	0.13103681	0.17017011	0.08975545	0.01710669	0.00000000	0.03521078	0.00000000	0.00000000	0.00000000	0.00000000	0.00000000	0.00000000	0.08268810	0.14457651	0.01868854	0.19926563	0.25110501	0.15710265
+222000	220000	Gefährliche und schwere Körperverletzung, Verstümmelung weiblicher Genitalien	173.35055505	261.19904078	87.81660571	14.39220977	17.57006435	11.03992008	115.53860852	150.15174875	78.90736712	471.89520862	654.00101856	276.38328168	703.93535191	1056.91894865	310.54329010	223.36124064	328.48685777	114.64954285	24.43169876	37.12490948	14.10781798
+223000	220000	Misshandlung von Schutzbefohlenen	6.43175358	6.99987868	5.87859682	37.19261494	43.64863445	30.38221909	41.50083866	45.81408332	36.93611250	20.97240667	15.56997588	26.77254921	1.36760241	1.15321216	1.60653539	0.33075242	0.32529714	0.33639378	1.57246572	1.12997253	1.93236260
+224000	220000	Vorsätzliche einfache Körperverletzung	488.46662175	580.89199608	398.47637069	62.98502730	71.38636316	54.12253503	379.49489066	499.92913290	252.03879243	1167.90290386	1394.72246053	924.38553004	1527.80183745	1858.83385744	1158.87430066	640.63986627	716.45791175	562.23548995	103.30623263	132.32268075	79.70602952
+225000	220000	Fahrlässige Körperverletzung	30.79149184	32.10542469	29.51217706	25.81425183	26.50399538	25.08664767	43.09176116	45.84735426	40.17550463	46.47331157	42.11957617	51.14755671	44.06718879	39.92997119	48.67802219	33.72296504	34.92426224	32.48068878	19.50637225	20.75479461	18.49098192
+230000	200000	Straftaten gegen die körperliche Freiheit	262.83225125	284.52217626	241.71378881	33.41438688	35.05504365	31.68367308	141.69474303	153.41230080	129.29399913	415.43350735	404.69530922	426.96222140	536.55601244	502.07974606	574.97901463	370.17396911	384.64579434	355.20847608	84.77452921	117.32398553	58.30079345
+231000	230000	Menschenraub, Entziehung Minderjähriger, Kinderhandel	2.32750970	2.48019486	2.17884732	10.98525268	11.23122758	10.72577601	8.31385309	7.98502542	8.66185288	3.08323283	2.41923928	3.79610772	0.75977912	0.28830304	1.28522831	1.86048234	2.06473323	1.64926397	0.05198234	0.08692096	0.02356540
+232000	230000	Zwangsheirat, Nachstellung (Stalking), Freiheitsberaubung, Nötigung, Bedrohung	259.57832747	281.51068596	238.22381892	22.31993686	23.69618849	20.86814162	133.27824978	145.36073350	120.49130311	409.07433963	400.97340264	417.77164481	528.19844215	498.04350349	561.80542447	367.28447926	381.97112898	352.09683357	84.69655570	117.19843303	58.26151778
+233000	230000	Erpresserischer Menschenraub	0.08092535	0.12731504	0.03575789	0.00000000	0.00000000	0.00000000	0.00000000	0.00000000	0.00000000	0.19270205	0.37219066	0.00000000	0.34190060	0.50453032	0.16065354	0.11714148	0.17168460	0.06073777	0.00433186	0.00965788	0.00000000
+234000	230000	Geiselnahme	0.04952148	0.04651896	0.05244490	0.06551841	0.04254253	0.08975545	0.01710669	0.03327094	0.00000000	0.06423402	0.12406355	0.00000000	0.11396687	0.14415152	0.08032677	0.06660986	0.04969817	0.08409845	0.01299558	0.01931577	0.00785513
+236000	230000	Menschenhandel zum Zweck der sexuellen Ausbeutung	0.33940333	0.03672549	0.63410655	0.04367894	0.08508506	0.00000000	0.00000000	0.00000000	0.00000000	1.25256334	0.06203178	2.53073848	3.03911647	0.14415152	6.26548801	0.36750268	0.04518016	0.70082039	0.00000000	0.00000000	0.00000000
+237000	230000	Menschenhandel zum Zweck der Ausbeutung der Arbeitskraft	0.05797637	0.09793464	0.01907087	0.00000000	0.00000000	0.00000000	0.01710669	0.03327094	0.00000000	0.03211701	0.00000000	0.06659838	0.18994478	0.36037880	0.00000000	0.09187567	0.14909452	0.03270495	0.00433186	0.00965788	0.00000000
+238000	230000	Förderung des Menschenhandel [Jahr 2016]	0.03590000	0.00760000	0.06310000	0.00000000	0.00000000	0.00000000	0.00000000	0.00000000	0.00000000	0.09320000	0.00000000	0.19150000	0.08230000	0.00000000	0.16940000	0.05300000	0.00910000	0.09770000	0.00460000	0.01030000	0.00000000
+600000	------	sonstige Delikte des Strafgesetzbuches	89.50420000	147.62360000	32.92790000	0.63330000	0.89340000	0.35900000	2.24100000	3.02770000	1.40840000	5.32930000	8.06110000	2.39750000	55.90700000	75.71920000	33.83070000	164.54070000	263.94010000	61.77220000	2.81130000	5.46630000	0.65300000
+621021	600000	Widerstand/tätl. Angriff auf Vollstreckungsbeamte/Gleichg.	86.35097221	142.34555676	31.83167208	0.50230778	0.72322299	0.26926634	0.06842677	0.06654188	0.07042157	1.47738240	1.73688974	1.19877086	51.55101309	68.61612378	32.53234157	159.71666646	256.01788411	60.13038903	2.27855914	4.57783743	0.40846689
+621029	600000	"Widerstand gegen Vollstreckungsbeamte (ohne Polizei; Jahr 2016)"	0.80850000	1.35750000	0.28150000	0.00000000	0.00000000	0.00000000	0.00000000	0.00000000	0.00000000	0.03110000	0.06050000	0.00000000	0.20570000	0.16000000	0.25410000	1.47040000	2.40620000	0.51660000	0.04110000	0.07210000	0.01640000
+621030	600000	Widerstand gegen Vollstreckungsbeamten Gleichgestellte [Jahr 2016]	0.40610000	0.72050000	0.10430000	0.00000000	0.00000000	0.00000000	0.00000000	0.00000000	0.00000000	0.03110000	0.06050000	0.00000000	0.12340000	0.24000000	0.00000000	0.72600000	1.24650000	0.19550000	0.04110000	0.08240000	0.00820000
+641000	600000	(Vorsätzliche) Brandstiftung und Herbeiführen einer Brandgefahr	0.03019603	0.03917386	0.02145473	0.00000000	0.00000000	0.00000000	0.05132008	0.06654188	0.03521078	0.03211701	0.06203178	0.00000000	0.00000000	0.00000000	0.00000000	0.02985959	0.03614413	0.02336068	0.03465489	0.04828942	0.02356540
+655100	600000	Körperverletzung durch Amtsträger	1.90838886	3.16084064	0.68893531	0.13103681	0.17017011	0.08975545	2.12123001	2.89457171	1.30279901	3.75769002	6.14114586	1.19877086	4.02682932	6.70304571	1.04424800	2.59778460	4.23338082	0.90639436	0.41585870	0.68570983	0.19637831
+700000	------	Straftaten gegen strafrechtliche Nebengesetze (z.B. auf dem Wirtschaftssektor, gegen Gesetz zum Schutz der Jugend in der Öffentlichkeit, auf dem Umweltsektor, Rauschgiftdelikte)	0.02415682	0.02938039	0.01907087	0.00000000	0.00000000	0.00000000	0.00000000	0.00000000	0.00000000	0.09635103	0.12406355	0.06659838	0.07597791	0.07207576	0.08032677	0.03445338	0.04066214	0.02803282	0.00000000	0.00000000	0.00000000
+734600	700000	Leichtfertige Verursachung des Todes eines Anderen durch Abgabe von Betäubungsmitteln	0.02415682	0.02938039	0.01907087	0.00000000	0.00000000	0.00000000	0.00000000	0.00000000	0.00000000	0.09635103	0.12406355	0.06659838	0.07597791	0.07207576	0.08032677	0.03445338	0.04066214	0.02803282	0.00000000	0.00000000	0.00000000
+5***00	------	Fälle von Computerkriminalität ohne Softwarepiraterie	74.96707033	74.96707033	74.96707033	74.96707033	74.96707033	74.96707033	74.96707033	74.96707033	74.96707033	74.96707033	74.96707033	74.96707033	74.96707033	74.96707033	74.96707033	74.96707033	74.96707033	74.96707033	74.96707033	74.96707033	74.96707033
+517500	5***00	Computerbetrug zur Verschaffung eines rechtswidrigen Vermögensvorteils oder Beschädigung des Vermögens eines anderen	12.96375797	12.96375797	12.96375797	12.96375797	12.96375797	12.96375797	12.96375797	12.96375797	12.96375797	12.96375797	12.96375797	12.96375797	12.96375797	12.96375797	12.96375797	12.96375797	12.96375797	12.96375797	12.96375797	12.96375797	12.96375797
+543000	5***00	Fälschung beweiserheblicher Daten, Täuschung im Rechtsverkehr bei Datenverarbeitung	10.31617039	10.31617039	10.31617039	10.31617039	10.31617039	10.31617039	10.31617039	10.31617039	10.31617039	10.31617039	10.31617039	10.31617039	10.31617039	10.31617039	10.31617039	10.31617039	10.31617039	10.31617039	10.31617039	10.31617039	10.31617039
+674200	5***00	Sachbeschädigung durch Datenveränderung, Computersabotage	3.47254301	3.47254301	3.47254301	3.47254301	3.47254301	3.47254301	3.47254301	3.47254301	3.47254301	3.47254301	3.47254301	3.47254301	3.47254301	3.47254301	3.47254301	3.47254301	3.47254301	3.47254301	3.47254301	3.47254301	3.47254301
+678000	5***00	Ausspähen, Abfangen von Daten einschl. Vorbereitungshandlungen	10.58310326	10.58310326	10.58310326	10.58310326	10.58310326	10.58310326	10.58310326	10.58310326	10.58310326	10.58310326	10.58310326	10.58310326	10.58310326	10.58310326	10.58310326	10.58310326	10.58310326	10.58310326	10.58310326	10.58310326	10.58310326
+516900	5***00	Computerbetrug mittels rechtswidrig erlangter sonstiger unbarer Zahlungsmittel	4.07042433	4.07042433	4.07042433	4.07042433	4.07042433	4.07042433	4.07042433	4.07042433	4.07042433	4.07042433	4.07042433	4.07042433	4.07042433	4.07042433	4.07042433	4.07042433	4.07042433	4.07042433	4.07042433	4.07042433	4.07042433
+517900	5***00	Missbräuchliche Nutzung von Kommunikationsdiensten	0.77784963	0.77784963	0.77784963	0.77784963	0.77784963	0.77784963	0.77784963	0.77784963	0.77784963	0.77784963	0.77784963	0.77784963	0.77784963	0.77784963	0.77784963	0.77784963	0.77784963	0.77784963	0.77784963	0.77784963	0.77784963

TEMPAT SAMPAH
data/original/Kriminalität_2016-12-23.xlsx


TEMPAT SAMPAH
data/original/Kriminalität_2017-01-15.xlsx


+ 56 - 0
package.json

@@ -0,0 +1,56 @@
+{
+  "name": "Treemap",
+  "version": "1.0.0",
+  "description": "Durch den Einsatz des mehrstufigen Kacheldiagramms (multi-layer treemap) soll den Verbrauchern ein Verständnis für die Eintrittswahrscheinlichkeit von Risiken vermittelt und ein Vergleich ermöglicht werden",
+  "scripts": {
+    "prepare": "npm run build:static",
+    "build": "rollup -c",
+    "build:data": "node bin/prepareData.js",
+    "build:html": "node bin/preprocess.js",
+    "build:dev": "NODE_ENV=development npm run build",
+    "build:prod": "NODE_ENV=production npm run build",
+    "build:static": "npm run build:data && npm run build:html",
+    "watch": "NODE_ENV=development npm run build:static && NODE_OPT=serve rollup -c --watch"
+  },
+  "devDependencies": {
+    "@babel/core": "^7.11.4",
+    "@babel/preset-env": "^7.11.0",
+    "@rollup/plugin-babel": "^5.2.0",
+    "@rollup/plugin-commonjs": "^15.0.0",
+    "@rollup/plugin-json": "^4.1.0",
+    "@rollup/plugin-node-resolve": "^9.0.0",
+    "autoprefixer": "^9.8.6",
+    "babel-preset-env": "^1.7.0",
+    "cssnano": "^4.1.10",
+    "eslint": "^7.8.1",
+    "eslint-plugin-json": "^2.1.2",
+    "marked": "^1.1.1",
+    "postcss": "^7.0.32",
+    "posthtml": "^0.13.3",
+    "posthtml-expressions": "^1.4.6",
+    "rollup": "2.26",
+    "rollup-plugin-browsersync": "^1.1.0",
+    "rollup-plugin-copy": "^3.3.0",
+    "rollup-plugin-delete": "^2.0.0",
+    "rollup-plugin-eslint": "^7.0.0",
+    "rollup-plugin-postcss": "^3.1.6",
+    "rollup-plugin-sourcemaps": "^0.6.2",
+    "rollup-plugin-terser": "^7.0.0",
+    "rollup-watch": "^4.3.1",
+    "stylelint": "^13.6.1",
+    "stylelint-config-recommended": "^3.0.0"
+  },
+  "dependencies": {
+    "d3-array": "^2.6.0",
+    "d3-axis": "^2.0.0",
+    "d3-color": "^2.0.0",
+    "d3-format": "^2.0.0",
+    "d3-hierarchy": "^1.1.9",
+    "d3-interpolate": "^2.0.1",
+    "d3-request": "^1.0.6",
+    "d3-scale": "^3.2.2",
+    "d3-scale-chromatic": "^2.0.0",
+    "d3-selection": "^2.0.0",
+    "d3-zoom": "^2.0.0"
+  }
+}

+ 101 - 0
rollup.config.js

@@ -0,0 +1,101 @@
+import autoprefixer from 'autoprefixer';
+import babel from '@rollup/plugin-babel';
+import browsersync from 'rollup-plugin-browsersync';
+import commonjs from '@rollup/plugin-commonjs';
+import copy from 'rollup-plugin-copy';
+import cssnano from 'cssnano';
+import del from 'rollup-plugin-delete';
+import { eslint } from 'rollup-plugin-eslint';
+import json from '@rollup/plugin-json';
+import path from 'path';
+import postcss from 'rollup-plugin-postcss';
+import resolve from '@rollup/plugin-node-resolve';
+import sourcemaps from 'rollup-plugin-sourcemaps';
+import stylelint from 'stylelint';
+import { terser } from 'rollup-plugin-terser';
+
+import config from './build.json';
+
+const printWarning = (message) => {
+    if (message.code === 'CIRCULAR_DEPENDENCY') {
+        return;
+    }
+    console.error(message);  // eslint-disable-line
+};
+
+
+const generateConfiguration = (target, option) => {
+
+    target = target === undefined ? 'development' : target;
+
+    // Common postcs configruation for development and production build.
+    let postcssconf = {
+        extract: true,
+        plugins: [
+            autoprefixer(),
+            stylelint(),
+            (target === 'production' && cssnano())
+        ],
+    };
+
+    // Browsersync configruation
+    let browsersyncconf = {
+        server: {
+            baseDir: config.path.output,
+            index: config.html.index.name,  // first html file in array is served as index
+        },
+        watch: true,
+    };
+
+    // Default rollup plugins
+    const plugins = {
+        development: [sourcemaps()],
+        production: [terser()],
+        prepare: [
+            (option !== 'serve' && del({ targets: [path.join(config.path.output, '/*'), path.join(config.path.build, '/*')] })),
+            resolve({browser: true}),
+            commonjs(),
+            json(),
+            eslint({
+                extends: ['plugin:json/recommended', 'eslint:recommended'],
+                exclude: ['src/css/**', 'src/html/**']
+            }),
+            babel( { babelHelpers: 'bundled' }),
+        ],
+        postProcess: [
+            postcss(postcssconf),
+            copy({
+                targets: [
+                    { src: path.join(config.path.build, '/*.css'), dest: path.join(config.path.output, config.path.css) },
+                    { src: path.join(config.path.build, '/*.js*'), dest: path.join(config.path.output, config.path.js) },
+                    { src: path.join(config.path.assets, config.path.js), dest: config.path.output },
+                    { src: path.join(config.path.assets, config.path.css), dest: config.path.output },
+                    { src: path.join(config.path.assets, config.path.img), dest: config.path.output },
+                    { src: path.join(config.path.assets, config.path.fonts), dest: config.path.output },
+                ],
+                hook: 'writeBundle',
+                verbose: true
+            }),
+            (option === 'serve' && browsersync(browsersyncconf))
+        ]
+    };
+
+    let rconf = {
+        onwarn: printWarning,
+        input: path.join(config.path.input, config.path.js, `${config.main}.js`),
+        plugins: plugins.prepare.concat(plugins[target], plugins.postProcess),  // Concatenate plugin arrays
+        output: {
+            file: path.join(
+                config.path.build,
+                `${config.main}${config[target].infix}.js`
+            ),
+            format: 'iife',
+            sourcemap: config[target].sourcemap
+        }
+    };
+    return rconf;
+};
+
+const rollup_config = generateConfiguration(process.env.NODE_ENV, process.env.NODE_OPT);
+
+export default rollup_config;

+ 201 - 0
src/css/main.css

@@ -0,0 +1,201 @@
+@font-face {
+    font-family: "ASAP Regular";
+    src: url("../fonts/Asap-Regular.ttf");
+}
+
+@font-face {
+    font-family: "ASAP Condensed";
+    src: url("../fonts/AsapCondensed-Regular.ttf");
+}
+
+* {
+    margin: 0;
+    box-sizing: border-box;
+}
+
+html, body {
+    height: 100%;
+}
+
+body {
+    font-size: 16px;
+}
+
+#wrapper {
+    height: 100%;
+    position: relative;
+}
+
+#form {
+    text-align: left;
+    height: 36px;
+    position: absolute;
+    top: 0px;
+    left: 0px;
+    right: 0px;
+    margin: 0;
+    background: #7c7872;
+    color: #ffffff;
+    border-bottom: 1px solid #fff;
+}
+
+@media (min-width: 400px) {
+    .form-inline .form-control {
+        display: inline-block;
+        width: auto;
+        vertical-align: middle;
+    }
+}
+
+#form #btnback {
+    background: #C6C4C1;
+    width: 72px;
+    height: 35px;
+    display: inline-block;
+    float: left;
+    border-right: 1px solid #fff;
+    cursor: pointer;
+}
+
+#chart {
+    position: relative;
+    overflow: hidden;
+    padding-top: 35px;
+    height: 100%;
+}
+
+svg text {
+    text-rendering: geometricPrecision;
+    pointer-events: none;
+    font-family: 'Asap Regular', Helvetica, sans-serif;
+}
+svg .treemap text {
+    fill: #fff;
+}
+svg rect.cell {
+    stroke: #f2f2f2;
+    stroke-width: 1;
+    cursor: pointer;
+}
+svg .depth0 {
+    opacity: 0!important;
+}
+
+.controls {
+    background: #7c7872;
+    border-bottom: 1px solid #fff;
+    color: #ffffff;
+    display: inline-block;
+    height: 36px;
+    left: 0;
+    margin: 0;
+    padding: 0 0.4em;
+    position: fixed;
+    right: 0;
+    text-align: left;
+    top: 0;
+}
+
+.controls .form-inline {
+    float: left;
+    margin: 0 0.4em;
+    padding-top: 3px;
+}
+
+
+#form .form-inline {
+    padding-top: 3px;
+    float: left;
+}
+
+form p {
+    float: left;
+    margin: 0;
+    padding: 0 0.25em;
+}
+
+.form-inline .form-control {
+    display: inline-block;
+    height: 2.2em;
+    vertical-align: middle;
+    width: auto;
+}
+
+.form-item {
+    border-radius: 2px;
+    line-height: 1.4;
+    float: left;
+    font-size: 13px;
+    font-weight: normal;
+    margin: 0;
+    padding: 0.4em 0.8em;
+}
+
+select ~ label {
+    display: none;
+}
+
+
+.outside {
+    stop-color: black;
+    stop-opacity: 0;
+}
+
+.inside {
+    stop-opacity: 100;
+}
+.overlay {
+    background: #efeeed;
+    box-sizing: border-box;
+    font-family: 'Asap Regular', Helvetica, sans-serif;
+    opacity: 0;
+    overflow: hidden;
+    pointer-events: none;
+    position: absolute;
+    right: 10px;
+    top: 45px;
+    transition: opacity 1s;
+    width: 20em;
+    z-index: 100;
+}
+.overlay.show {
+    opacity: 1;
+}
+
+.overlay header {
+    background: #c6c4c1;
+    min-height: 8.7em;
+    display: flex;
+    align-items: center;
+    justify-content: center;
+}
+
+.overlay h2 {
+    font-size: 1em;
+    line-height: 1.4em;
+    color: #9f1c1b;
+    padding: 0.8em;
+}
+.overlay p {
+    font-size: 0.8em;
+    background: #efeeed;
+    color: #5b564e;
+    padding: 0.8em;
+}
+.class-size {
+    color: #9f1c1b;
+    font-size: 18px;
+    font-weight: bold;
+}
+.overlay #chart2 {
+    width: 13em;
+    height: 11em;
+    margin: 1em auto;
+}
+.overlay #source {
+    font-size: 0.8em;
+    background: #efeeed;
+    color: #5b564e;
+    opacity: 0.6;
+    padding: 1em;
+}

+ 73 - 0
src/html/markdown/index.md

@@ -0,0 +1,73 @@
+## Fragestellungen zur Risikokommunikation für Verbraucher
+
+Liegt ein Problem des Risikos vor, d.h. sind belastbare numerische Schätzer vom Eintreffen spezifischer Ereignisse oder Entscheidungenkonsequenzen verfügbar, ist eine Hauptfragestellung, wie Risikokommunikation hier transparent, ausgewogen und verständlich für die Verbraucher sein kann?
+Vier Herausforderungen sind hierbei
+
+1. Wie können Einzelfallwahrscheinlichkeiten trotz aleatorischer Unsicherheit über den konkreten Ausgang im Einzelfall vermittelt werden?
+2. Wie lässt sich der massenhaften Stratifizierung von Wahrscheinlichkeiten durch vorliegende Einflussfaktoren oder Kategorien Rechnung tragen?
+3. Wie können hierarchisch strukturierte Ereignisse zwischen zu vergleichenden Wahrscheinlichkeiten abgebildet werden?
+4. Wie lassen sich die ersten drei Herausforderungen nicht nur nach dem letzten Stand der Forschung sondern zudem auch ansprechend adressieren, da das Hervorrufen von Aufmerksamkeit und Bindung des Verbrauchers an das Informationsangebot für dessen Exploration notwendig ist.
+
+## Lösungsansatz
+Dynamische Treemaps mit visueller Legende
+
+1.	Einzelfallwahrscheinlichkeiten lassen sich entweder mit einfachen Häufigkeiten (sofern nur Wahrscheinlichkeitswerte > 1% auch als Prozentformat) in tabellarischer Form (Schwartz et al., 2009) oder, zur Unterstützung von Verbrauchern mit niedriger Numeracy (Cokely et al., 2012), durch den Einsatz von empirisch validierten Grafikformaten (Garcia-Retamero & Galesic, 2010), Barcharts oder IconArrays kommunizieren.
+2.	Multiple Vergleiche, welche stratifizierte Daten implizieren, wenn zum Beispiel dasselbe Risiko für viele Gruppen verglichen soll, erfordern den Einsatz von mehreren Explorationsebenen bzw. hierarchisierter Navigation. Barcharts sind geeignet multiple Instanzen vergleichbar nebeneinander zu stellen. Dieses Prinzip lässt sich mit einer Hierarchisierung verknüpfen.
+3.	Treemaps, die mehrere Tiefenebenen aufweisen, zwischen denen man dynamisch navigieren kann, erlauben die Abbildung von Hierarchien (Stasko et al., 2000) und zugleich den verständlichen Vergleich von Wahrscheinlichkeiten, da sie die Teile vom Ganzen (part-to-whole relationships) einander gegenüberstellen.
+4.	Dynamische Informationsvisualisierungen können ansprechend sein, wenn Sie auf verschiedenen Explorationstiefen, mit einem leichten Einstieg, begleitet mit Erklärtext und einem durchziehenden Narrativ versehen sind. 
+
+Erste Ergebnisse der RisikoAtlas-Kommunikationsstudien mit dem vorliegenden Format zeigen, dass es besser angenommen wird und exploriert wird als Tabellen mit denselben Informationen. Es wird nicht gezeigt, dass Informationen besser extrahiert oder gemerkt werden können als aus klassischen Tabellen.
+
+## Thematisches Muster
+Digitale Kriminalität
+
+## Einleitung
+Kriminalität ist in der digitalen Welt genauso allgegenwärtig wie in der analogen Welt. Verbraucher haben im Rahmen der dynamischen Entwicklung der digitalen Welt weniger Erfahrungen bezüglich der Verbindung zwischen ihrem Verhalten und dem Risiko, Opfer eines digitalen Verbrechens zu werden.
+
+## Welche Kriminalitätsrisiken werden hier dargestellt?
+Es werden die Häufigkeiten von Straftaten aus Sicht der Betroffenen dargestellt. Um ein Verständnis vom zahlenmäßigen Verhältnis der verschiedenen Straftaten zu vermitteln, wird ein Überblick über die jährlich Betroffenen gegebenen. Hierzu werden die analogen Straftaten aus polizeilichen Opferstatistiken den registrierten Fällen von Computerkriminalität gegenübergestellt. Es werden nicht die möglichen digitalen Risiken durch institutionelle Überwachung, zum Beispiel Kunden-Profiling, thematisiert.
+
+## Für welche Verbraucher ist die folgende Grafik geeignet?
+Für alle Verbraucher stellt sich die Frage, welche digitalen Kriminalitätsrisiken bestehen und inwieweit diese den einzelnen betreffen können.
+
+<iframe src="{{ d3 }}" width="{{ width }}" height="{{ height }}" frameborder="0"></iframe>
+
+<div class="logos">
+    <img src="img/HardingCenter_Logo_de_RGB.png" width="200" height="34" alt="Harding Center Logo"/>
+    <img src="img/mpib.png" width="500" height="40" alt="Max-Planck-Institut für Bildungsforschung Logo"/>
+    <img src="img/BMJV_Web_Master_de_WBZ.png" width="200" height="165" alt="Bundesministerium für Justiz und Verbraucherschutz Logo"/>
+</div>
+
+## Was zeigt die Grafik?
+Dargestellt sind hier die Risiken, Opfer von digitaler Kriminalität zu werden. Durch Klick auf die Vierecke lässt sich in die jeweiligen Kategorien von Straftaten eintauchen. Mit dem Klick auf den erscheinenden Pfeil links oben kann man immer wieder zurückkehren. Alle Zahlen beziehen sich auf die gesamte Bevölkerung Deutschlands und basieren auf dem Jahr 2016. Auf der rechten Seite werden in separaten Balken zusätzliche Informationen dazu gegeben, wie oft verschiedene Altersgruppen bzw. Männer oder Frauen Opfer wurden. 
+
+## Woher stammen die Zahlen? 
+Alle Zahlen stellen registrierte Tatopfer der Vergangenheit dar. Sie wurden der Polizeilichen Kriminalstatistik 2016 entnommen.
+
+## Wie hoch ist die Qualität der Daten? 
+Aus einem Jahr der Vergangenheit lässt sich nur bedingt auf zukünftige Jahre schließen. Die Verhältnismäßigkeit der verschiedenen Risiken, Opfer von bestimmten Straftaten zu werden, ist jedoch grob so auch in der Zukunft zu erwarten. 
+Wie viele Verbraucher tatsächlich betroffen sind, wird für analoge und digitale Straftaten nicht gleichermaßen gut erfasst. Nicht nur, dass die Dunkelziffern viel höher ausfallen als bei klassischen Straftaten, auch die Vielfalt und ständig neuartige Tatbestände sowie länderübergreifende Netzwerke machen die Erfassung schwer.
+Eine verbesserte Erfassung digitaler Kriminalität lässt eine Zunahme dieser Zahlen in der Zukunft erwarten.
+
+## Was kann man tun? 
+Um das Risiko zu senken, Opfer von digitaler Kriminalität zu werden, sind bestimmte Daumenregeln empfehlenswert. 
+Hierzu zählt v.a. der äußerst vorsichtige Umgang mit digitalen Nachrichten, deren Absender man nicht kennt: 
+Keine persönlichen Daten auf Webseiten angeben, deren Adressen mit http statt https beginnen;
+Des Weiteren sind jegliche Passwörter persönlich, komplex und nur ein einziges Mal zu wählen.
+
+## Quellen.
+Cokely, E. T., Galesic, M., Schulz, E., Ghazal, S., & Garcia-Retamero, R. (2012). Measuring Risk Literacy: The Berlin Numeracy Test. Judgment and Decision Making, 7(1), 25-47.  
+Frey, C. B., & Osborne, M. A. (2017). The future of employment: how susceptible are jobs to computerisation?. Technological Forecasting and Social Change, 114, 254-280.  
+Garcia-Retamero, R., & Galesic, M. (2010). Who proficts from visual aids: Overcoming challenges in people's understanding of risks. Social Science & Medicine, 70(7), 1019-1025.  
+McDowell, M., Gigerenzer, G., Wegwarth, O., & Rebitschek, F. G. (2019). Effect of Tabular and Icon Fact Box Formats on Comprehension of Benefits and Harms of Prostate Cancer Screening: A Randomized Trial. Medical Decision Making, 39(1), 41-56.  
+McDowell, M., Rebitschek, F. G., Gigerenzer, G., & Wegwarth, O. (2016). A simple tool for communicating the benefits and harms of health interventions: a guide for creating a fact box. MDM Policy & Practice, 1(1), 2381468316665365.  
+O*Net (2018). O*NET Resource Center. https://www.onetcenter.org [Letzter Abruf, 31.12.2018]  
+Schwartz, L. M., Woloshin, S., & Welch, H. G. (2009). Using a drug facts box to communicate drug benefits and harms: two randomized trials. Annals of Internal Medicine, 150(8), 516-527.  
+Stasko, J., Catrambone, R., Guzdial, M., & McDonald, K. (2000). An Evaluation Of Space-Filling Information Visualizations For Depicting Hierarchical Structures. Int. J. Human-Computer Studies, 53, 663-694.
+
+
+## Letztes Update
+7. Februar 2019
+
+## Erstellung
+Felix G. Rebitschek, Michael Zitzmann in Zusammenarbeit mit Data Science and Stories

+ 14 - 0
src/html/skeletons/main.html

@@ -0,0 +1,14 @@
+<!DOCTYPE html>
+<html>
+    <head>
+        <meta charset="utf-8">
+        <title>Digitale Kriminalität</title>
+        <meta name="viewport" content="width=device-width, initial-scale=1">
+        <link href="css/index.css" rel="stylesheet">
+    </head>
+    <body>
+        <main>
+            {{{ content }}}
+        </main>
+    </body>
+</html>

+ 56 - 0
src/html/skeletons/visualisation.html

@@ -0,0 +1,56 @@
+<!DOCTYPE html>
+<html>
+    <head>
+        <meta charset="utf-8">
+        <title>Crime</title>
+        <meta name="viewport" content="width=device-width, initial-scale=1">
+        <link rel="stylesheet" type="text/css" href="{{ stylesheet }}">    
+    </head>
+    <body>
+        <div id="wrapper">
+            <div id="chart"></div>
+            <div id="form" class="row controls">
+                <div id="btnback">
+                    <svg version="1.1" baseProfile="tiny" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 72 35" width="72" height="35" xml:space="preserve">
+                        <path fill="#FFFFFF" d="M53.2,22.3H36v5.1l-17.2-9.9L36,7.6v5.1h17.3V22.3z"/>
+                    </svg>
+                </div>
+                <div class="form-inline">
+                    <select class="form-control form-item" id="geschlecht">
+                        <option id="gender-option" value="">alle</option>
+                        <option disabled>────</option>
+                        <option value="w">weiblich</option>
+                        <option value="m">männlich</option>
+                    </select>
+                </div>
+                <div class="form-inline">
+                    <select class="form-control form-item" id="alter">
+                        <option id="age-option" value="">alle</option>
+                        <option disabled>────</option>
+                        <option value="0-5">0-5</option>
+                        <option value="6-13">6-13</option>
+                        <option value="14-17">14-17</option>
+                        <option value="18-20">18-20</option>
+                        <option value="21-59">21-59</option>
+                        <option value="60+">60+</option>
+                    </select>
+                </div>
+            </div>
+        </div>
+        <div class="overlay">
+            <header>
+                <h2 id="data-title"></h2>
+            </header>
+            <p>
+                <span id="reference-group-title"></span>
+                <br />
+                <span id="data-desc" class="class-size"></span> <span id="reference-group-size"></span>
+            </p>
+            <p id="chart-title"></p>
+            <div id="chart2" class="chart"></div>
+            <p id="chart-note"></p>
+            <div id="source"></div>
+        </div>
+    <script type="text/javascript" src="{{ javascript }}"></script>
+    </body>
+</html>

+ 64 - 0
src/js/config.json

@@ -0,0 +1,64 @@
+{
+    "lang": "de",
+    "title": {
+        "de": "Digitale Kriminalität",
+        "en": "Digital Crime Risks"
+    },
+    "labels": {
+        "gender": {
+            "all": {
+                "de": "Geschlecht",
+                "en": "Gender"
+            },
+            "female": {
+                "de": "weiblich",
+                "en": "female"
+            },
+            "male": {
+                "de": "männlich",
+                "en": "male"
+            }
+        },
+        "age": {
+            "de": "Alter",
+            "en": "Age"
+        },
+        "overlay": {
+            "reference": {
+                "title": {
+                    "de": "Wahrscheinlichkeit, in einem Jahr Opfer zu werden:",
+                    "en": ""
+                },
+                "size": 100000
+            },
+            "source": {
+                "prefix": {
+                    "de": "Quelle:",
+                    "en": "Source:"
+                },
+                "title": {
+                    "de": "Polizeiliche Kriminalstatistik 2018",
+                    "en": ""
+                }
+            },
+            "chart": {
+                "title": {
+                    "de": "Alter/Geschlecht im Vergleich:",
+                    "en": ""
+                },
+                "note": {
+                    "de": "Bitte beachten Sie, dass für einzelne Gruppen das Risiko niedriger oder höher als das Durchschnittsrisiko ausfällt.",
+                    "en": ""
+                }
+            }
+        },
+        "of": {
+            "de": "von",
+            "en": "von"
+        },
+        "per": {
+            "de": "je",
+            "en": "per"
+        }
+    }
+}

+ 8 - 0
src/js/d3-custom.js

@@ -0,0 +1,8 @@
+export { color } from 'd3-color';
+export { format } from 'd3-format';
+export { hierarchy, treemap, treemapResquarify } from 'd3-hierarchy';
+export { json } from 'd3-request';
+export { scaleOrdinal } from 'd3-scale';
+export { schemeCategory10 } from 'd3-scale-chromatic';
+export { selection, select, selectAll } from 'd3-selection';
+export { zoomIdentity } from 'd3-zoom';

+ 779 - 0
src/js/main.js

@@ -0,0 +1,779 @@
+import * as d3 from './d3-custom';
+import config from './config.json';
+
+// See rollup.config.js for postcss configuration
+import '../css/main.css';
+
+function crime() {
+    var data = false, root, treemap, cells, width, height, svgLabels = [], selectedNode, svgHighlight, alreadyDrawn;
+    // var darkFigure, tlclip, trclip, blclip, brclip;
+
+    var svg = d3.select('#chart').append('svg');
+    var svgBackground = svg.append('rect')
+        .attr('fill', '#dedddc');
+
+    // introducing margins
+    var margin = {
+        top: 20,
+        right: 20,
+        bottom: 20,
+        left: 20
+    };
+
+    var lang = config.lang;
+    var option = window.location.search.substr(1,4);
+    if(option === 'lang') {
+        lang = window.location.search.substr(6, window.location.search.length - 1);
+    }
+
+    document.title = config.title[config.lang];
+
+    var labels = config.labels;
+    d3.select('#gender-label').text(labels.gender.all[lang]);
+    d3.select('#gender-option').text(labels.gender.all[lang]);
+    d3.select('#gender-female').text(labels.gender.female[lang]);
+    d3.select('#gender-male').text(labels.gender.male[lang]);
+    d3.select('#age-label').text(labels.age[lang]);
+    d3.select('#age-option').text(labels.age[lang]);
+
+    var svgWrapper = svg.append('g')
+        .attr('transform', 'translate(-' + (margin.left / 2) + ',-' + (margin.top / 2) + ')');
+
+    var svgContainer = svgWrapper.append('g');
+
+    var frame = svg.append('rect')
+        .attr('stroke', '#7c7872')
+        .attr('stroke-width', margin.top)
+        .attr('fill', 'none');
+
+    let arrow = d3.select('#btnback');
+    arrow.select('svg').classed('hidden', true);
+
+    d3.json('data/data.json', function (_data) {
+
+        data = _data;
+
+        data.nodes = {};
+        var id = 0;
+        scanTree(data.tree, function (node) {
+            data.nodes[node.id] = node;
+            node.nodeid = 'cell'+(id++);
+        });
+
+        scanTree(data.tree,            function (node) { node.basecolor = d3.color('#000000'); });
+        scanTree(data.nodes['000000'], function (node) { node.basecolor = d3.color('#e36315'); });
+        scanTree(data.nodes['100000'], function (node) { node.basecolor = d3.color('#f4881c'); });
+        scanTree(data.nodes['200000'], function (node) { node.basecolor = d3.color('#f2d31d'); });
+        scanTree(data.nodes['5***00'], function (node) { node.basecolor = d3.color('#f2bf1a'); });
+        scanTree(data.nodes['600000'], function (node) { node.basecolor = d3.color('#f7a11d'); });
+        scanTree(data.nodes['700000'], function (node) { node.basecolor = d3.color('#d4470f'); });
+
+        redraw();
+
+        function scanTree(node, cb) {
+            cb(node);
+            if (node.children) node.children.forEach(function (child) { scanTree(child, cb); });
+        }
+    });
+
+    d3.select(window).on('resize', redraw);
+    d3.selectAll('select').on('change', function() { redraw(true); });
+
+
+    function redraw(doAnimate) {
+        // Falls noch keine Daten vorhanden sind, dann gleich die Funktion abbrechen.
+        if (!data) return;
+
+        if (!alreadyDrawn) {
+            initialDraw();
+            arrow.on('click', function () {
+                select((selectedNode && selectedNode.parent) ? selectedNode.parent : false);
+            });
+            alreadyDrawn = true;
+        }
+
+        // Welches Alter/Geschlecht ist ausgewählt?
+        let alter = d3.select('#alter').node().value;
+        let geschlecht = d3.select('#geschlecht').node().value;
+
+        // Suche den Eintrag mit dem ausgewählten Alter/Geschlecht.
+        var entry = data.entries.filter(function (entry) {
+            if (entry.alter !== alter) return false;
+            if (entry.geschlecht !== geschlecht) return false;
+            return true;
+        });
+        if (entry.length !== 1) return console.error(entry);
+        entry = entry[0];
+
+        // kopiere alle Werte in den Tree
+        Object.keys(entry.values).forEach(function (key) {
+            data.nodes[key].value = entry.values[key] || 1e-8;
+        });
+
+        width = d3.select('#chart').node().offsetWidth;
+        height = d3.select('#chart').node().offsetHeight - 35;
+
+        svg
+            .attr('width', width)
+            .attr('height', height);
+        svgWrapper
+            .attr('width', width - margin.left - margin.right)
+            .attr('height', height - margin.top - margin.bottom);
+        svgBackground
+            .attr('width', width)
+            .attr('height', height);
+        frame
+            .attr('width', width)
+            .attr('height', height);
+
+        // Aktualisiert alle Texte der Straftaten
+        updateCellValues(root);
+        function updateCellValues(node) {
+            node.value = node.data.value;
+            node.data.desc = node.data.value < 1 ? '<1' : round(node.data.value);
+            if (node.children) {
+                var sum = 0;
+                node.children.forEach(function (child) {
+                    updateCellValues(child);
+                    sum += child.value;
+                });
+                node.value = sum;
+            }
+        }
+
+        // Größe der quadratischen Treemap rechts unten
+        var size = Math.sqrt(width*height*data.tree.children[1].value/data.tree.value);
+
+        treemap.size([size, size]);
+        treemap(root);
+
+
+        // Label "98,8%"
+        svgLabels[0]
+            .attr('x', width*0.3)
+            .attr('y', height*0.5)
+            .text(round(data.tree.children[0].value) + ' von ' + round(100000));
+
+        // Label für "keine Straftat"
+        svgLabels[1]
+            .attr('x', width*0.3)
+            .attr('y', height*0.5+18)
+            .text(data.tree.children[0].title);
+
+        // Label "1.2%"
+        animate(svgLabels[2])
+            .attr('x', width)
+            .attr('y', height - size*1.2 - 12)
+            .text(round(data.tree.children[1].value) + ' von ' + round(100000));
+
+        // Label für "Opfer einer Straftat"
+        animate(svgLabels[3])
+            .attr('x', width)
+            .attr('y', height - size*1.2)
+            .text(data.tree.children[1].title);
+
+        cells.forEach(function (cell) {
+            updateCellSize(cell);
+
+            animate(cell.svgGroup).attr('transform', 'translate(' + cell.x + ',' + cell.y + ') scale(' + cell.s + ')');
+
+            animate(cell.svgRect)
+                .attr('width', cell.rw)
+                .attr('height', cell.rh);
+
+            cell.svgText0.text(cell.data.desc);
+
+
+            cell.svgText1.html(null);
+            cell.svgText1.selectAll('tspan')
+                .data(textToLines(cell.data.title, 2*cell.rw/10))
+                .enter().append('tspan')
+                .attr('x', 4)
+                .attr('y', function (d, i) { return (i+1.3)*8+15; })
+                .text(function (d) { return d; });
+        });
+
+        select(selectedNode);
+
+        function select(node) {
+            var duration = (node === undefined) ? 0 : 2000;
+            selectedNode = node;
+
+            var cell = node;
+            if (!cell) cell = {children:root.children};
+
+            // Je nach ausgewählter Zelle wird berechnet,
+            // welche Zellen sichtbar sind und welche nicht.
+            cells.forEach(function (cell) {
+                cell.wasVisible = cell.isVisible;
+                cell.isVisible = false;
+            });
+
+            // mache alle Geschwister der Vorfahren sichtbar
+            var tCell = cell;
+            while (tCell.parent) {
+                let p = tCell.parent;
+                p.children.forEach(function (child) {
+                    child.isVisible = true;
+                });
+                tCell = p;
+            }
+
+            // mache die Unterknoten sichtbar
+            if (cell.children && cell.children.length > 0) {
+                cell.children.forEach(function (child) { child.isVisible = true; });
+            } else {
+                cell.isVisible = true;
+            }
+
+            // animiere die Zellen je nachdem, ob sie unsichtbar oder sichtbar werden sollen.
+            cells.forEach(function (cell) {
+                if (cell.wasVisible === cell.isVisible) return;
+                if (cell.isVisible) {
+                    cell.svgGroup
+                        .attr('display', 'inline')
+                        .transition().duration(duration*0.3)
+                        .style('opacity', 1);
+                } else {
+                    cell.svgGroup
+                        .transition().duration(duration*0.3)
+                        .style('opacity', 0)
+                        .on('end', function () {
+                            cell.svgGroup.attr('display','none');
+                        });
+                }
+            });
+
+            if (node) {
+                arrow.select('svg').transition().duration(duration).style('opacity', 1);
+            } else {
+                arrow.select('svg').transition().duration(duration).style('opacity', 0);
+            }
+
+            if (node) {
+                // Populate HTML overlay
+                // dynamic data
+                d3.select('#data-title').text(node.data.title);
+                d3.select('#data-desc').text(node.data.desc);
+                // "static" data
+                var olabels = config.labels.overlay;
+                d3.select('#reference-group-title').text(olabels.reference.title[lang]);
+                d3.select('#reference-group-size').text(config.labels.of[lang] + ' ' + round(olabels.reference.size));
+                d3.select('#chart-title').text(olabels.chart.title[lang]);
+                d3.select('#chart-note').text(olabels.chart.note[lang]);
+                d3.select('#source').text(olabels.source.prefix[lang] + ' ' + olabels.source.title[lang]);
+                d3.select('.overlay').classed('show', true);
+
+                // rote Markierung der ausgewählten Zelle aktualisieren
+                svgHighlight
+                    .attr('display','inline');
+
+                animate(svgHighlight)
+                    .attr('width', node.rw)
+                    .attr('height', node.rh)
+                    .attr('transform', 'translate('+node.x+','+node.y+')scale('+node.s+')');
+
+
+                // Diagramm der Infobox zeichnen
+                var id = node.data.id;
+                var chartData = [];
+                var maxValue = 0;
+                data.entries.forEach(function (entry) {
+                    var row, col;
+                    switch (entry.geschlecht) {
+                        case 'w': col = 0; break;
+                        case 'm': col = 1; break;
+                        default: return;
+                    }
+                    switch (entry.alter) {
+                        case '60+': row = 0; break;
+                        case '21-59': row = 1; break;
+                        case '18-20': row = 2; break;
+                        case '14-17': row = 3; break;
+                        case '6-13': row = 4; break;
+                        case '0-5': row = 5; break;
+                        default: return;
+                    }
+                    if (!chartData[row]) chartData[row] = [];  //
+                    var value = entry.values[id];
+                    chartData[row][col] = value;
+                    if (value > maxValue) maxValue = value;
+                });
+
+                var svg2 = d3.select('#chart2 svg');
+
+                var rowHeight = 25;
+                var offset = 25;
+                //
+                // update x axis labels
+                svg2.select('#left-axis-label')
+                    .text(round(maxValue));
+
+                svg2.select('#right-axis-label')
+                    .text(round(maxValue));
+
+                for (let lr = 0; lr < 2; ++lr) {
+                    let data = chartData.map(d => d[lr]);
+                    svg2.selectAll('.rect-' + lr)
+                        .data(data)
+                        .join(
+                            enter => enter.append('rect')
+                                .attr('class', 'rect-' + lr)
+                                .attr('x', d => lr ? 90 + offset : 90 + offset - d / maxValue * 90 || 0)  // 
+                                .attr('y', (d, i) => i * rowHeight + 15)
+                                .attr('width', d => d / maxValue * 90 || 0)
+                                .attr('height', rowHeight-0.3)
+                                .attr('fill', lr ? '#7c7872' : '#94918c'),
+                            update => update
+                                .attr('x', d => lr ? 90 + offset : 90 + offset - d / maxValue * 90 || 0)  // 
+                                .attr('width', d => d / maxValue * 90 || 0)
+                        );
+                }
+            } else {
+                d3.select('.overlay').classed('show', false);
+                svgHighlight.attr('display','none');
+            }
+
+            var vWidth = node ? width-200 : width;
+            var box = node || {x:offset, y:0, w:width, h:height};
+            var s = Math.min(vWidth/box.w, height/box.h)*(node ? 0.8 : 1);
+            var x = -box.x + (vWidth/s - box.w)/2;
+            var y = -box.y + (height/s- box.h)/2;
+            var t = d3.zoomIdentity.scale(s).translate(x, y);
+
+            svgContainer.transition()
+                .duration(duration)
+                .attr('transform', t);
+        }
+
+        function animate(node) {
+            if (!doAnimate) return node;
+            return node.transition().duration(2000);
+        }
+
+        function initialDraw() {
+            // Falls noch keine Daten vorhanden sind, dann gleich die Funktion abbrechen.
+            if (!data) return;
+
+            svgBackground
+                .on('click', function () {
+                    select(false);
+                });
+
+            var entry = data.entries.filter(function (entry) {
+                return (entry.alter === '') && (entry.geschlecht === '');
+            });
+            if (entry.length !== 1) return console.error(entry);
+            entry = entry[0];
+
+            Object.keys(entry.values).forEach(function (key) {
+                data.nodes[key].value = entry.values[key];
+            });
+
+            // Bereite SVG vor
+            width = d3.select('#chart').node().offsetWidth;
+            height = d3.select('#chart').node().offsetHeight - 35;
+
+            svgContainer.html(null);
+            svg
+                .attr('width', width)
+                .attr('height', height);
+            svgWrapper
+                .attr('width', width - margin.left - margin.right)
+                .attr('height', height - margin.top - margin.bottom);
+            svgBackground
+                .attr('width', width)
+                .attr('height', height);
+            frame
+                .attr('width', width)
+                .attr('height', height);
+
+
+            var svg2 = d3.select('#chart2').append('svg');
+            svg2
+                .attr('width', 220)
+                .attr('height', 180);
+
+            var rowHeight = 25;
+            var offset = 25;
+            var axes = {
+                x0: offset,
+                x1: 90 + offset,
+                x2: 180 + offset,
+                y0: 15,
+                y1: 165,
+                y2: 175
+            };
+
+            // Zeichne weiße Achsenlinien
+            svg2.append('path')
+                .attr('d', `M${axes.x0},${axes.y0}H${axes.x2}M${axes.x1},${axes.y0}V${axes.y1}`)
+                .attr('stroke', '#fff')
+                .attr('fill', 'none');
+
+            // Zeichne graue Achsenlinien unten
+            svg2.append('path')
+                .attr('d', `M${axes.x0},${axes.y2}V${axes.y1}H${axes.x2}V${axes.y2}`)
+                .attr('stroke', '#5b564e')
+                .attr('fill', 'none');
+
+            // x-Achsen-Beschriftung links
+            svg2.append('text')
+                .attr('id', 'left-axis-label')
+                .attr('x', 3 + offset)
+                .attr('y', axes.y2)
+                .attr('fill', '#5b564e')
+                .attr('text-anchor', 'start')
+                .attr('font-size', '10px');
+
+            // x-Achsen-Beschriftung mitte
+            svg2.append('text')
+                .attr('x', (axes.x2 + offset) / 2)
+                .attr('y', axes.y2)
+                .attr('fill', '#5b564e')
+                .attr('text-anchor', 'middle')
+                .attr('font-size', '10px')
+                .text(labels.per[lang] + ' ' + round(labels.overlay.reference.size));
+
+            // x-Achsen-Beschriftung rechts
+            svg2.append('text')
+                .attr('id', 'right-axis-label')
+                .attr('x', 177 + offset)
+                .attr('y', axes.y2)
+                .attr('fill', '#5b564e')
+                .attr('text-anchor', 'end')
+                .attr('font-size', '10px');
+
+            // Beschriftung "weiblich"
+            svg2.append('text')
+                .attr('x', 45 + offset)
+                .attr('y', 10)
+                .attr('fill', '#5b564e')
+                .attr('text-anchor', 'middle')
+                .attr('font-size', '10px')
+                .attr('font-weight', 'bold')
+                .text(labels.gender.female[lang]);
+
+            // Beschriftung "männlich"
+            svg2.append('text')
+                .attr('x', 135 + offset)
+                .attr('y', 10)
+                .attr('fill', '#5b564e')
+                .attr('text-anchor', 'middle')
+                .attr('font-size', '10px')
+                .attr('font-weight', 'bold')
+                .text(labels.gender.male[lang]);
+
+            // // Beschriftung "Altersklassen"
+            ['60+','21-59','18-20','14-17','6-13','0-5'].forEach(function (t,i) {
+                svg2.append('text')
+                    .attr('x',offset)
+                    .attr('y',(i+0.5)*rowHeight+3+15)
+                    .attr('fill','#5b564e')
+                    .attr('font-size', '10px')
+                    .attr('text-anchor', 'end')
+                    .text(t);
+            });
+
+            // // Gradient definitions
+            // var defs = svg.append('defs');
+            // // left gradient
+            // var gradient = defs.append('linearGradient')
+            //     .attr('id', 'leftgradient')
+            //     .attr('x1', 0)
+            //     .attr('x2', 1)
+            //     .attr('y1', 1)
+            //     .attr('y2', 1);
+            // gradient.append('stop')
+            //     .attr('class', 'outside')
+            //     .attr('offset', '0%');
+            // gradient.append('stop')
+            //     .attr('class', 'inside')
+            //     .attr('offset', '100%');
+            // // top gradient
+            // gradient = defs.append('linearGradient')
+            //     .attr('id', 'topgradient')
+            //     .attr('x1', 0)
+            //     .attr('x2', 0)
+            //     .attr('y1', 0)
+            //     .attr('y2', 1);
+            // gradient.append('stop')
+            //     .attr('class', 'outside')
+            //     .attr('offset', '0%');
+            // gradient.append('stop')
+            //     .attr('class', 'inside')
+            //     .attr('offset', '100%');
+            // // right gradient
+            // gradient = defs.append('linearGradient')
+            //     .attr('id', 'rightgradient')
+            //     .attr('x1', 0)
+            //     .attr('x2', 1)
+            //     .attr('y1', 1)
+            //     .attr('y2', 1);
+            // gradient.append('stop')
+            //     .attr('class', 'inside')
+            //     .attr('offset', '0%');
+            // gradient.append('stop')
+            //     .attr('class', 'outside')
+            //     .attr('offset', '100%');
+            // // bottom gradient
+            // gradient = defs.append('linearGradient')
+            //     .attr('id', 'bottomgradient')
+            //     .attr('x1', 0)
+            //     .attr('x2', 0)
+            //     .attr('y1', 0)
+            //     .attr('y2', 1);
+            // gradient.append('stop')
+            //     .attr('class', 'inside')
+            //     .attr('offset', '0%');
+            // gradient.append('stop')
+            //     .attr('class', 'outside')
+            //     .attr('offset', '100%');
+            // // Radial gradient
+            // gradient = defs.append('radialGradient')
+            //     .attr('id', 'radialgradient');
+            // gradient.append('stop')
+            //     .attr('class', 'inside')
+            //     .attr('offset', '0%');
+            // gradient.append('stop')
+            //     .attr('class', 'outside')
+            //     .attr('offset', '100%');
+
+            // // clippaths for radial gradients
+            // tlclip = defs.append('clipPath')
+            //     .attr('id', 'tlclip');
+            // tlclip.append('rect');
+            // trclip = defs.append('clipPath')
+            //     .attr('id', 'trclip');
+            // trclip.append('rect');
+            // blclip = defs.append('clipPath')
+            //     .attr('id', 'blclip');
+            // blclip.append('rect');
+            // brclip = defs.append('clipPath')
+            //     .attr('id', 'brclip');
+            // brclip.append('rect');
+
+            root = d3.hierarchy(data.tree.children[1])
+                .sort(function(a, b) { return b.value - a.value; });
+
+            updateCellValues(root);
+
+            var size = Math.sqrt(width * height * data.tree.children[1].value / data.tree.value);
+
+            treemap = d3.treemap()
+                .tile(d3.treemapResquarify)
+                // .tile(d3.treemapSquarify)
+                // .tile(d3.treemapBinary)
+                .size([size, size])
+                .paddingInner(0);
+
+            treemap(root);
+
+            cells = [];
+            scanCells(root);
+
+            function scanCells(cell) {
+                cells.push(cell);
+
+                if (cell.children) cell.children.forEach(scanCells);
+                updateCellSize(cell);
+                cell.color = cell.data.basecolor.rgb();
+            }
+
+            svgLabels = [
+                svgContainer.append('text')
+                    .attr('text-anchor', 'start')
+                    .attr('fill', '#5b564e')
+                    .style('font-family', 'Trebuchet MS, Verdana')
+                    .style('font-weight', 'bold')
+                    .style('font-size', '48px'),
+                svgContainer.append('text')
+                    .attr('text-anchor', 'start')
+                    .attr('fill', '#5b564e')
+                    .style('font-family', 'Trebuchet MS, Verdana')
+                    .style('font-size', '12px'),
+                svgContainer.append('text')
+                    .attr('text-anchor', 'end')
+                    .attr('fill', '#9f1c1b')
+                    .style('font-family', 'Trebuchet MS, Verdana')
+                    .style('font-weight', 'bold')
+                    .style('font-size', '24px'),
+                svgContainer.append('text')
+                    .attr('text-anchor', 'end')
+                    .attr('fill', '#9f1c1b')
+                    .style('font-family', 'Trebuchet MS, Verdana')
+                    .style('font-size', '7px')
+            ];
+
+            cells.forEach(function (cell) {
+                cell.svgGroup = svgContainer.append('g')
+                    .on('click', function () {
+                        select(selectedNode ? cell : root);
+                    })
+                    .attr('class', 'treemap depth'+cell.depth);
+
+                cell.svgRect = cell.svgGroup.append('rect')
+                    .attr('id', cell.data.nodeid)
+                    .attr('fill', cell.color)
+                    .attr('class', 'cell')
+                    .attr('vector-effect', 'non-scaling-stroke');
+
+                cell.svgGroup.append('clipPath')
+                    .attr('id', 'clip-' + cell.data.nodeid)
+                    .append('use')
+                    .attr('xlink:href', '#' + cell.data.nodeid);
+
+                cell.svgText0 = cell.svgGroup.append('text')
+                    .attr('x', 3)
+                    .attr('y', 16)
+                    .attr('clip-path', 'url(#clip-' + cell.data.nodeid + ')')
+                    .style('font-weight', 'bold')
+                    .style('font-size', '16px');
+
+                cell.svgText1 = cell.svgGroup.append('text')
+                    .attr('clip-path', 'url(#clip-' + cell.data.nodeid + ')')
+                    .style('font-size', '8px');
+            });
+
+            svgHighlight = svgContainer.append('rect')
+                .attr('display','none')
+                .attr('fill','none')
+                .attr('stroke','#9f1c1b')
+                .attr('stroke-width', 3)
+                .attr('vector-effect', 'non-scaling-stroke');
+
+            // // dark figure
+            // darkFigure = svgContainer.append('g')
+            //     .style('visibility', 'visible');
+
+            // // left horizontal gradient
+            // // darkFigure.horizontal = darkFigure.append('rect')
+            // darkFigure.left = darkFigure.append('rect')
+            //     .attr('class', 'hgradient')
+            //     .style('fill', 'url(#leftgradient)')
+            //     .attr('class', 'dark-figure');
+
+            // // top vertical gradient
+            // darkFigure.top = darkFigure.append('rect')
+            //     .attr('class', 'vgradient')
+            //     .style('fill', 'url(#topgradient)')
+            //     .attr('class', 'dark-figure');
+
+            // // gradients need to be inversed on these rects
+            // // // right horizontal gradient
+            // darkFigure.right = darkFigure.append('rect')
+            //     .attr('class', 'hgradient')
+            //     .style('fill', 'url(#rightgradient)')
+            //     .attr('class', 'dark-figure');
+
+            // // bottom vertical gradient
+            // darkFigure.bottom = darkFigure.append('rect')
+            //     .attr('class', 'vgradient')
+            //     .style('fill', 'url(#bottomgradient)')
+            //     .attr('class', 'dark-figure');
+
+            // // top left radial gradient
+            // darkFigure.topleft = darkFigure.append('rect')
+            //     .attr('class', 'rgradient')
+            //     .style('fill', 'url(#radialgradient)')
+            //     .attr('class', 'dark-figure')
+            //     .attr('clip-path', 'url(#tlclip)');
+
+            // // bottom right radial gradient
+            // darkFigure.bottomright = darkFigure.append('rect')
+            //     .attr('class', 'rgradient')
+            //     .style('fill', 'url(#radialgradient)')
+            //     .attr('class', 'dark-figure')
+            //     .attr('clip-path', 'url(#brclip)');
+
+            // // bottom left radial gradient
+            // darkFigure.bottomleft = darkFigure.append('rect')
+            //     .attr('class', 'rgradient')
+            //     .style('fill', 'url(#radialgradient)')
+            //     .attr('class', 'dark-figure')
+            //     .attr('clip-path', 'url(#blclip)');
+
+            // // top right  radial gradient
+            // darkFigure.topright = darkFigure.append('rect')
+            //     .attr('class', 'rgradient')
+            //     .style('fill', 'url(#radialgradient)')
+            //     .attr('class', 'dark-figure')
+            //     .attr('clip-path', 'url(#trclip)');
+        }
+    }
+
+    function round(v) {
+        // rundet den Wert v auf ganze zahlen, mit zwei signifikanten Ziffern und Tausender-Trennzeichen
+        // Also: aus 3852940.5737 wird "3 800 000"
+
+        // var i = 0;
+
+        // Wiviele Ziffern hat der Wert?
+        //var digits = Math.floor(Math.log10(v));
+        var digits = Math.floor(Math.log(Math.E) / Math.log(v));  // fix for IE < Edge
+
+        // 10^(digits-1) ist der Genauigkeitsfaktor, auf den gerundet werden muss.
+        var factor = Math.pow(10,digits-1);
+        v = Math.round(v/factor)*factor;
+        // Jetzt ist v auf 2 signifikante Stellen gerundet.
+
+        v = v.toFixed(0);
+
+        // v von hinten in 3-Zeichen-Blöcken durchgehen und mit einem &thinsp; trennen.
+        var s = '';
+        while (v.length > 3) {
+            s = String.fromCharCode(8201) + v.substr(-3) + s;
+            v = v.substr(0, v.length-3);
+        }
+        return v+s;
+    }
+
+    function updateCellSize(cell) {
+        // Breite und Höhe der Zelle berechnen
+        // Achtung: Die Zellen werden diagonal gespiegelt.
+        cell.w = (cell.y1 - cell.y0) || 0;
+        cell.h = (cell.x1 - cell.x0) || 0;
+
+        // Die Zellen werden nicht klein gezeichnet,
+        // sondern in normaler Größe und dann klein skaliert (svg transform)
+
+        // Der Skalierungsfaktor fpr die SVG-Transform
+        cell.s = Math.min(cell.w, Math.sqrt(cell.w*cell.h))/100;
+        if (cell.s < 1e-9) cell.s = 1;
+
+        // x- und y-Position der Zellen definieren,
+        // so dass die Treemap rechts unten und diagonal gespiegelt ist.
+        cell.x = (width  - cell.y1);
+        cell.y = (height - cell.x1);
+
+        // Mit dieser Größe muss die Zelle gezeichnet werden,
+        // so dass sie nach dem Skalieren die Größe von cell.w/cell.h hat.
+        cell.rw = cell.w/cell.s;
+        cell.rh = cell.h/cell.s;
+    }
+
+    function textToLines(text, maxWidth) {
+        // Versucht einen Text so in mehrere Zeilen umzubrechen,
+        // so dass jede Zeile nicht länger ist als maxWidth
+
+        var lines = text.split('#');
+        return lines.map(function (line) {
+            line = line.split(' ');
+            var i = 0;
+            while (i < line.length-1) {
+                if (line[i].length+line[i+1].length < maxWidth) {
+                    line = [].concat(
+                        line.slice(0,i),
+                        [line[i]+' '+line[i+1]],
+                        line.slice(i+2)
+                    );
+                    i--;
+                }
+                i++;
+            }
+            return line.join('#');
+        }).join('#').split('#');
+    }
+}
+
+crime();

Beberapa file tidak ditampilkan karena terlalu banyak file yang berubah dalam diff ini