Skip to content

Instantly share code, notes, and snippets.

@Bertware
Last active December 6, 2018 13:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Bertware/cdac7b597f3d5f51a3c817068c958468 to your computer and use it in GitHub Desktop.
Save Bertware/cdac7b597f3d5f51a3c817068c958468 to your computer and use it in GitHub Desktop.
Linked Connections to isochrone or heatmap map
<!Doctype html>
<html prefix="dct: http://purl.org/dc/terms/
rdf: http://www.w3.org/1999/02/22-rdf-syntax-ns#
foaf: http://xmlns.com/foaf/0.1/
og: http://ogp.me/ns#">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>LC2Heat</title>
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.3.4/dist/leaflet.css"/>
<script src="https://unpkg.com/leaflet@1.3.4/dist/leaflet.js"></script>
<script src="leaflet-heat.js"></script>
<!--<script src='http://linkedconnections.org/js/lc-client.js'></script>-->
<script src='https://linkedconnections.org/js/lc-client.js'></script>
<script src="https://code.jquery.com/jquery-3.2.1.min.js"
crossorigin="anonymous"></script>
<style>
html, body {
height: 100%;
width: 100%;
margin: 0;
padding: 0;
}
#map {
min-height: 500px;
min-width: 500px;
height: 100%;
width: 100%;
}
</style>
</head>
<body>
<div id="map">
</div>
<script>
const TIME_INTERVAL = 3600 * 3;
$(function () {
var map = L.map('map', {
scrollWheelZoom: true
}).setView([57.9978819, 13.3822411], 8);
L.tileLayer('https://{s}.tile.openstreetmap.se/hydda/full/{z}/{x}/{y}.png', {
maxZoom: 18,
subdomains: 'abc',
}).addTo(map);
var heat = L.heatLayer([], {
minOpacity: 0.9,
radius: 10,
blur: 15,
gradient:
{
1.0: 'green',
0.75: 'lime',
0.50: 'yellow',
0.25: 'orange',
0.0: 'red'
},
}).addTo(map);
//Create our stations list on the basis of the iRail API
var stations = {};
var markers = {};
var blueIcon = L.icon({
iconUrl: 'https://linkedconnections.org/images/marker-icon.png',
// iconRetinaUrl : 'https://linkedconnections.org/images/marker-icon-2x.png',
iconAnchor: [12, 41]
});
$.get("https://se.lc.bertmarcelis.be/stations-sj.json", {headers: {'accept': 'application/ld+json'}}, function (sjStations) {
sjStations["@graph"].forEach(function (station) {
var key = station["@id"];
station.point = new L.LatLng(station.latitude, station.longitude);
stations[key] = station;
markers[key] = L.marker([station.latitude, station.longitude]).setIcon(blueIcon).addTo(map);
markers[key].on("click", function () {
handleClick(key, markers[key]);
});
});
$.get("https://se.lc.bertmarcelis.be/stations-vasttrafik.json", {headers: {'accept': 'application/ld+json'}}, function (stationslist) {
stationslist["@graph"].forEach(function (station) {
var key = station["@id"];
station.point = new L.LatLng(station.latitude, station.longitude);
stations[key] = station;
if (Math.random() < 0.1 && !(key in markers)) {
markers[key] = L.marker([station.latitude, station.longitude]).setIcon(blueIcon).addTo(map);
markers[key].on("click", function () {
handleClick(key, markers[key]);
});
}
});
});
var startIcon = L.icon({
iconUrl: 'https://linkedconnections.org/images/marker-icon-start.png',
iconRetinaUrl: 'https://linkedconnections.org/images/marker-icon-2x-start.png'
});
L.Icon.Default.iconUrl = 'https://linkedconnections.org/images/marker-icon.png';
L.Icon.Default.iconRetinaUrl = 'https://linkedconnections.org/images/marker-icon-2x.png';
var planner = new window.lc.Client({"entrypoints": ['https://se.lc.bertmarcelis.be/sj/connections', 'https://se.lc.bertmarcelis.be/vasttrafik/connections']});
var departureStop = "";
var arrivalStop = "";
var handleClick = function (station, marker) {
if (departureStop === "") {
for (key in markers) {
map.removeLayer(markers[key]);
}
marker.addTo(map);
marker.setIcon(startIcon);
departureStop = station;
heat.addLatLng([stations[departureStop].point.lat, stations[departureStop].point.lng, 1]);
var startTime = new Date();
planner.query({
"departureStop": departureStop,
"departureTime": startTime
}, function (stream) {
var trips = {};
var countTrips = 0;
var seen = [];
stream.on('data', function (connection) {
console.log(connection);
if (stations[connection.arrivalStop] && stations[connection.departureStop]) {
var arrStr = connection.arrivalStop;
connection.arrivalStop = stations[connection.arrivalStop];
connection.departureStop = stations[connection.departureStop];
//circle for the isochrone to be drawn
//Keep an occurence of different trips and give a new colour per trip
//Hour and a Half duration!
var secondsFromStart = (connection.arrivalTime - startTime) / 1000;
console.log(secondsFromStart + " seconds elapsed!");
if (secondsFromStart < TIME_INTERVAL) {
seen.push(arrStr);
heat.addLatLng([connection.arrivalStop.point.lat, connection.arrivalStop.point.lng, (TIME_INTERVAL - secondsFromStart) / TIME_INTERVAL]);
}
}
if (secondsFromStart > TIME_INTERVAL * 4) {
stream.end();
}
});
stream.on('error', function (error) {
console.error(error);
});
stream.on('end', function () {
console.log('end of stream');
});
});
}
};
});
});
</script>
</body>
</html>
<!Doctype html>
<html prefix="dct: http://purl.org/dc/terms/
rdf: http://www.w3.org/1999/02/22-rdf-syntax-ns#
foaf: http://xmlns.com/foaf/0.1/
og: http://ogp.me/ns#">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>LC2Heat</title>
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.3.4/dist/leaflet.css"/>
<script src="https://unpkg.com/leaflet@1.3.4/dist/leaflet.js"></script>
<script src="leaflet-heat.js"></script>
<!--<script src='http://linkedconnections.org/js/lc-client.js'></script>-->
<script src='https://linkedconnections.org/js/lc-client.js'></script>
<script src="https://code.jquery.com/jquery-3.2.1.min.js"
crossorigin="anonymous"></script>
<style>
html, body {
height: 100%;
width: 100%;
margin:0;
padding:0;
}
#map {
min-height: 500px;
min-width: 500px;
height: 100%;
width: 100%;
}
</style>
</head>
<body>
<div id="map">
</div>
<script>
const TIME_INTERVAL = 7200;
// Centre is BE.NMBS.008813003
$(function () {
var map = L.map('map', {
scrollWheelZoom: true
}).setView([57.9978819,13.3822411], 8);
L.tileLayer('https://{s}.tile.openstreetmap.se/hydda/full/{z}/{x}/{y}.png', {
maxZoom: 18,
subdomains: 'abc',
}).addTo(map);
var heat = L.heatLayer([], {
minOpacity: 0.9,
radius: 10,
blur:15,
gradient:
{1.0: 'green',
0.75: 'lime',
0.50: 'yellow',
0.25: 'orange',
0.0: 'red'},
}).addTo(map);
//Create our stations list on the basis of the iRail API
var stations = {};
var markers = {};
var blueIcon = L.icon({
iconUrl: 'https://linkedconnections.org/images/marker-icon.png',
// iconRetinaUrl : 'https://linkedconnections.org/images/marker-icon-2x.png',
iconAnchor: [12, 41]
});
$.get("https://se.lc.bertmarcelis.be/stations-vasttrafik.json", {headers: {'accept': 'application/ld+json'}}, function (stationslist) {
stationslist["@graph"].forEach(function (station) {
var key = station["@id"];
station.point = new L.LatLng(station.latitude, station.longitude);
stations[key] = station;
if(Math.random() < 0.1) {
markers[key] = L.marker([station.latitude, station.longitude]).setIcon(blueIcon).addTo(map);
markers[key].on("click", function () {
handleClick(key, markers[key]);
});
}
});
var startIcon = L.icon({
iconUrl: 'https://linkedconnections.org/images/marker-icon-start.png',
iconRetinaUrl: 'https://linkedconnections.org/images/marker-icon-2x-start.png'
});
L.Icon.Default.iconUrl = 'https://linkedconnections.org/images/marker-icon.png';
L.Icon.Default.iconRetinaUrl = 'https://linkedconnections.org/images/marker-icon-2x.png';
var planner = new window.lc.Client({"entrypoints": ['https://se.lc.bertmarcelis.be/vasttrafik/connections']});
var departureStop = "";
var arrivalStop = "";
var handleClick = function (station, marker) {
if (departureStop === "") {
for (key in markers) {
map.removeLayer(markers[key]);
}
marker.addTo(map);
marker.setIcon(startIcon);
departureStop = station;
heat.addLatLng([stations[departureStop].latitude, stations[departureStop].longitude, 1]);
var startTime = new Date();
planner.query({
"departureStop": departureStop,
"departureTime": startTime
}, function (stream) {
var trips = {};
var countTrips = 0;
var seen = [];
stream.on('data', function (connection) {
console.log(connection);
if (stations[connection.arrivalStop] && stations[connection.departureStop]) {
var arrStr = connection.arrivalStop;
connection.arrivalStop = stations[connection.arrivalStop];
connection.departureStop = stations[connection.departureStop];
var secondsFromStart = (connection.arrivalTime - startTime) / 1000;
console.log(secondsFromStart + " seconds elapsed!");
if (secondsFromStart < TIME_INTERVAL) {
seen.push(arrStr);
heat.addLatLng([connection.arrivalStop.point.lat, connection.arrivalStop.point.lng, (TIME_INTERVAL - secondsFromStart) / TIME_INTERVAL]);
}
}
if (secondsFromStart > TIME_INTERVAL * 4) {
stream.end();
}
});
stream.on('error', function (error) {
console.error(error);
});
stream.on('end', function () {
console.log('end of stream');
});
});
}
};
});
});
</script>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Demo overview</title>
</head>
<body>
<h1>GTFS analytics - realtime client side calculations</h1>
<h2>Using Linked Connections as transport format</h2>
<p><a href="heatmap-vt-sj.html">Heatmap Västtrafik & SJ</a></p>
<p><a href="heatmap-vt.html">Heatmap Västtrafik</a></p>
<p><a href="isochrone-vt.html">Isochrone map Västtrafik</a></p>
<p><a href="isochrone-vt-sj.html">Isochrone map Västtrafik & SJ</a></p>
<p><a href="isochrone-se.html">Isochrone map Sweden</a></p>
<p><a href="isochrone-se-dk.html">Isochrone map Sweden Denmark</a></p>
<p><a href="isochrone-skane.html">Isochrone map Skåne</a></p>
<p><a href="isochrone-sl.html">Isochrone map Stockholm</a></p>
</body>
</html>
<!Doctype html>
<html prefix="dct: http://purl.org/dc/terms/
rdf: http://www.w3.org/1999/02/22-rdf-syntax-ns#
foaf: http://xmlns.com/foaf/0.1/
og: http://ogp.me/ns#">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>LC2Isochrone</title>
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.3.4/dist/leaflet.css"/>
<script src="https://unpkg.com/leaflet@1.3.4/dist/leaflet.js"></script>
<script src="leaflet-heat.js"></script>
<script src="leaflet-isochrone.js"></script>
<!--<script src='http://linkedconnections.org/js/lc-client.js'></script>-->
<script src='lc-client-fix.js'></script>
<script src="https://code.jquery.com/jquery-3.2.1.min.js"
crossorigin="anonymous"></script>
<style>
html, body {
height: 100%;
width: 100%;
margin: 0;
padding: 0;
}
#map {
min-height: 500px;
min-width: 500px;
height: 100%;
width: 100%;
}
</style>
</head>
<body>
<div id="map">
</div>
<script>
const TIME_INTERVAL = 3600 * 8;
$(function () {
var map = L.map('map', {
scrollWheelZoom: true
}).setView([57.9978819, 13.3822411], 8);
L.tileLayer('https://{s}.tile.openstreetmap.se/hydda/full/{z}/{x}/{y}.png', {
maxZoom: 18,
subdomains: 'abc',
}).addTo(map);
var heat = L.isochroneLayer([], {
minOpacity: 0.9,
radius: 10,
blur: 15,
gradient:
{
1.0: 'green',
0.75: 'lime',
0.50: 'yellow',
0.25: 'orange',
0.0: 'red'
},
}).addTo(map);
//Create our stations list on the basis of the iRail API
var stations = {};
var markers = {};
var blueIcon = L.icon({
iconUrl: 'https://linkedconnections.org/images/marker-icon.png',
// iconRetinaUrl : 'https://linkedconnections.org/images/marker-icon-2x.png',
iconAnchor: [12, 41]
});
$.get("https://se.lc.bertmarcelis.be/stations-sj.json", {headers: {'accept': 'application/ld+json'}}, function (sjStations) {
sjStations["@graph"].forEach(function (station) {
var key = station["@id"];
station.point = new L.LatLng(parseFloat(station.latitude), parseFloat(station.longitude));
stations[key] = station;
markers[key] = L.marker([parseFloat(station.latitude), parseFloat(station.longitude)]).setIcon(blueIcon).addTo(map);
markers[key].on("click", function () {
handleClick(key, markers[key]);
});
}); console.log("SJ OK");
$.get("https://se.lc.bertmarcelis.be/stations.json", {headers: {'accept': 'application/ld+json'}}, function (skaneStations) {
skaneStations["@graph"].forEach(function (station) {
var key = station["@id"];
station.point = new L.LatLng(station.latitude, station.longitude);
stations[key] = station;
});
console.log("Skåne OK");
$.get("https://dk.lc.bertmarcelis.be/stations.json", {headers: {'accept': 'application/ld+json'}}, function (dkStations) {
dkStations["@graph"].forEach(function (station) {
var key = station["@id"];
station.point = new L.LatLng(station.latitude, station.longitude);
stations[key] = station;
});
console.log("DK OK");
});
});
var startIcon = L.icon({
iconUrl: 'https://linkedconnections.org/images/marker-icon-start.png',
iconRetinaUrl: 'https://linkedconnections.org/images/marker-icon-2x-start.png'
});
L.Icon.Default.iconUrl = 'https://linkedconnections.org/images/marker-icon.png';
L.Icon.Default.iconRetinaUrl = 'https://linkedconnections.org/images/marker-icon-2x.png';
var planner = new window.lc.Client({"entrypoints": ['https://se.lc.bertmarcelis.be/sj/connections', 'https://se.lc.bertmarcelis.be/vasttrafik/connections',
'https://se.lc.bertmarcelis.be/sl/connections','https://se.lc.bertmarcelis.be/ul/connections','https://se.lc.bertmarcelis.be/varmlandstrafik/connections',
"https://se.lc.bertmarcelis.be/dalatrafik/connections",
"https://se.lc.bertmarcelis.be/klt/connections",
"https://se.lc.bertmarcelis.be/kronoberg/connections",
"https://se.lc.bertmarcelis.be/mtr/connections",
"https://se.lc.bertmarcelis.be/norbotten/connections",
"https://se.lc.bertmarcelis.be/orebro/connections",
"https://se.lc.bertmarcelis.be/oresundstag/connections",
"https://se.lc.bertmarcelis.be/ostgotatrafiken/connections",
"https://se.lc.bertmarcelis.be/scandlines/connections",
"https://se.lc.bertmarcelis.be/vasterbotten/connections",
"https://se.lc.bertmarcelis.be/vl/connections",
"https://se.lc.bertmarcelis.be/waxholmsbolaget/connections", 'https://se.lc.bertmarcelis.be/skanetrafiken/connections',
'https://dk.lc.bertmarcelis.be/arriva/connections', 'https://dk.lc.bertmarcelis.be/dsb/connections',
'https://dk.lc.bertmarcelis.be/metroselskabet/connections',
'https://dk.lc.bertmarcelis.be/midtrafik/connections', 'https://dk.lc.bertmarcelis.be/sydtrafik/connections',
'https://dk.lc.bertmarcelis.be/dsbs/connections', 'https://dk.lc.bertmarcelis.be/movia/connections']});
var departureStop = "";
var arrivalStop = "";
var handleClick = function (station, marker) {
if (departureStop === "") {
for (key in markers) {
map.removeLayer(markers[key]);
}
marker.addTo(map);
marker.setIcon(startIcon);
departureStop = station;
heat.addLatLng([stations[departureStop].point.lat, stations[departureStop].point.lng, 1]);
var startTime = new Date();
planner.query({
"departureStop": departureStop,
"departureTime": startTime
}, function (stream) {
var trips = {};
var countTrips = 0;
var seen = [];
stream.on('data', function (connection) {
console.log(connection);
if (stations[decodeURIComponent(connection.arrivalStop)] && stations[decodeURIComponent(connection.departureStop)]) {
var arrStr = connection.arrivalStop;
connection.arrivalStop = stations[decodeURIComponent(connection.arrivalStop)];
connection.departureStop = stations[decodeURIComponent(connection.departureStop)];
//circle for the isochrone to be drawn
//Keep an occurence of different trips and give a new colour per trip
//Hour and a Half duration!
var secondsFromStart = (connection.arrivalTime - startTime) / 1000;
console.log(secondsFromStart + " seconds elapsed!");
if (secondsFromStart < TIME_INTERVAL && !seen.includes(arrStr)) {
seen.push(arrStr);
heat.addLatLng([connection.arrivalStop.point.lat, connection.arrivalStop.point.lng, (TIME_INTERVAL - secondsFromStart) / TIME_INTERVAL]);
}
}
if (secondsFromStart > TIME_INTERVAL * 4) {
stream.end();
}
});
stream.on('error', function (error) {
console.error(error);
});
stream.on('end', function () {
console.log('end of stream');
});
});
}
}
});
});
</script>
</body>
</html>
<!Doctype html>
<html prefix="dct: http://purl.org/dc/terms/
rdf: http://www.w3.org/1999/02/22-rdf-syntax-ns#
foaf: http://xmlns.com/foaf/0.1/
og: http://ogp.me/ns#">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>LC2Isochrone</title>
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.3.4/dist/leaflet.css"/>
<script src="https://unpkg.com/leaflet@1.3.4/dist/leaflet.js"></script>
<script src="leaflet-heat.js"></script>
<script src="leaflet-isochrone.js"></script>
<!--<script src='http://linkedconnections.org/js/lc-client.js'></script>-->
<script src='https://linkedconnections.org/js/lc-client.js'></script>
<script src="https://code.jquery.com/jquery-3.2.1.min.js"
crossorigin="anonymous"></script>
<style>
html, body {
height: 100%;
width: 100%;
margin: 0;
padding: 0;
}
#map {
min-height: 500px;
min-width: 500px;
height: 100%;
width: 100%;
}
</style>
</head>
<body>
<div id="map">
</div>
<script>
const TIME_INTERVAL = 3600 * 10;
$(function () {
var map = L.map('map', {
scrollWheelZoom: true
}).setView([57.9978819, 13.3822411], 8);
L.tileLayer('https://{s}.tile.openstreetmap.se/hydda/full/{z}/{x}/{y}.png', {
maxZoom: 18,
subdomains: 'abc',
}).addTo(map);
var heat = L.isochroneLayer([], {
minOpacity: 0.9,
radius: 10,
blur: 15,
gradient:
{
1.0: 'green',
0.75: 'lime',
0.50: 'yellow',
0.25: 'orange',
0.0: 'red'
},
}).addTo(map);
//Create our stations list on the basis of the iRail API
var stations = {};
var markers = {};
var blueIcon = L.icon({
iconUrl: 'https://linkedconnections.org/images/marker-icon.png',
// iconRetinaUrl : 'https://linkedconnections.org/images/marker-icon-2x.png',
iconAnchor: [12, 41]
});
$.get("https://se.lc.bertmarcelis.be/stations-sj.json", {headers: {'accept': 'application/ld+json'}}, function (sjStations) {
sjStations["@graph"].forEach(function (station) {
var key = station["@id"];
station.point = new L.LatLng(station.latitude, station.longitude);
stations[key] = station;
markers[key] = L.marker([station.latitude, station.longitude]).setIcon(blueIcon).addTo(map);
markers[key].on("click", function () {
handleClick(key, markers[key]);
});
});
$.get("https://se.lc.bertmarcelis.be/stations.json", {headers: {'accept': 'application/ld+json'}}, function (stationslistNMBS) {
stationslistNMBS["@graph"].forEach(function (station) {
var key = station["@id"];
station.point = new L.LatLng(station.latitude, station.longitude);
stations[key] = station;
if (Math.random() < 0.01 && !(key in markers)) {
markers[key] = L.marker([station.latitude, station.longitude]).setIcon(blueIcon).addTo(map);
markers[key].on("click", function () {
handleClick(key, markers[key]);
});
}
});
});
var startIcon = L.icon({
iconUrl: 'https://linkedconnections.org/images/marker-icon-start.png',
iconRetinaUrl: 'https://linkedconnections.org/images/marker-icon-2x-start.png'
});
L.Icon.Default.iconUrl = 'https://linkedconnections.org/images/marker-icon.png';
L.Icon.Default.iconRetinaUrl = 'https://linkedconnections.org/images/marker-icon-2x.png';
var planner = new window.lc.Client({"entrypoints": ['https://se.lc.bertmarcelis.be/sj/connections', 'https://se.lc.bertmarcelis.be/vasttrafik/connections',
'https://se.lc.bertmarcelis.be/sl/connections','https://se.lc.bertmarcelis.be/ul/connections','https://se.lc.bertmarcelis.be/varmlandstrafik/connections',//"https://se.lc.bertmarcelis.be/arlandaexpres/connections",
"https://se.lc.bertmarcelis.be/dalatrafik/connections",
"https://se.lc.bertmarcelis.be/klt/connections",
"https://se.lc.bertmarcelis.be/kronoberg/connections",
"https://se.lc.bertmarcelis.be/mtr/connections",
"https://se.lc.bertmarcelis.be/norbotten/connections",
"https://se.lc.bertmarcelis.be/orebro/connections",
"https://se.lc.bertmarcelis.be/oresundstag/connections",
"https://se.lc.bertmarcelis.be/ostgotatrafiken/connections",
"https://se.lc.bertmarcelis.be/scandlines/connections",
"https://se.lc.bertmarcelis.be/skanetrafiken/connections",
"https://se.lc.bertmarcelis.be/vasterbotten/connections",
"https://se.lc.bertmarcelis.be/vl/connections",
"https://se.lc.bertmarcelis.be/waxholmsbolaget/connections"]});
var departureStop = "";
var arrivalStop = "";
var handleClick = function (station, marker) {
if (departureStop === "") {
for (key in markers) {
map.removeLayer(markers[key]);
}
marker.addTo(map);
marker.setIcon(startIcon);
departureStop = station;
heat.addLatLng([stations[departureStop].point.lat, stations[departureStop].point.lng, 1]);
var startTime = new Date();
planner.query({
"departureStop": departureStop,
"departureTime": startTime
}, function (stream) {
var trips = {};
var countTrips = 0;
var seen = [];
stream.on('data', function (connection) {
console.log(connection);
if (stations[connection.arrivalStop] && stations[connection.departureStop]) {
var arrStr = connection.arrivalStop;
connection.arrivalStop = stations[connection.arrivalStop];
connection.departureStop = stations[connection.departureStop];
//circle for the isochrone to be drawn
//Keep an occurence of different trips and give a new colour per trip
//Hour and a Half duration!
var secondsFromStart = (connection.arrivalTime - startTime) / 1000;
console.log(secondsFromStart + " seconds elapsed!");
if (secondsFromStart < TIME_INTERVAL && !seen.includes(arrStr)) {
seen.push(arrStr);
heat.addLatLng([connection.arrivalStop.point.lat, connection.arrivalStop.point.lng, (TIME_INTERVAL - secondsFromStart) / TIME_INTERVAL]);
}
}
if (secondsFromStart > TIME_INTERVAL * 4) {
stream.end();
}
});
stream.on('error', function (error) {
console.error(error);
});
stream.on('end', function () {
console.log('end of stream');
});
});
}
}
});
});
</script>
</body>
</html>
<!Doctype html>
<html prefix="dct: http://purl.org/dc/terms/
rdf: http://www.w3.org/1999/02/22-rdf-syntax-ns#
foaf: http://xmlns.com/foaf/0.1/
og: http://ogp.me/ns#">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>LC2Isochrone</title>
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.3.4/dist/leaflet.css"/>
<script src="https://unpkg.com/leaflet@1.3.4/dist/leaflet.js"></script>
<script src="leaflet-heat.js"></script>
<script src="leaflet-isochrone.js"></script>
<!--<script src='http://linkedconnections.org/js/lc-client.js'></script>-->
<script src='lc-client-fix.js'></script>
<script src="https://code.jquery.com/jquery-3.2.1.min.js"
crossorigin="anonymous"></script>
<style>
html, body {
height: 100%;
width: 100%;
margin: 0;
padding: 0;
}
#map {
min-height: 500px;
min-width: 500px;
height: 100%;
width: 100%;
}
</style>
</head>
<body>
<div id="map">
</div>
<script>
const TIME_INTERVAL = 3600 * 3;
$(function () {
var map = L.map('map', {
scrollWheelZoom: true
}).setView([57.9978819, 13.3822411], 8);
L.tileLayer('https://{s}.tile.openstreetmap.se/hydda/full/{z}/{x}/{y}.png', {
maxZoom: 18,
subdomains: 'abc',
}).addTo(map);
var heat = L.isochroneLayer([], {
minOpacity: 0.9,
radius: 10,
blur: 15,
gradient:
{
1.0: 'green',
0.75: 'lime',
0.50: 'yellow',
0.25: 'orange',
0.0: 'red'
},
}).addTo(map);
//Create our stations list on the basis of the iRail API
var stations = {};
var markers = {};
var blueIcon = L.icon({
iconUrl: 'https://linkedconnections.org/images/marker-icon.png',
// iconRetinaUrl : 'https://linkedconnections.org/images/marker-icon-2x.png',
iconAnchor: [12, 41]
});
$.get("https://se.lc.bertmarcelis.be/stations-sj.json", {headers: {'accept': 'application/ld+json'}}, function (sjStations) {
sjStations["@graph"].forEach(function (station) {
var key = station["@id"];
station.point = new L.LatLng(parseFloat(station.latitude), parseFloat(station.longitude));
stations[key] = station;
markers[key] = L.marker([parseFloat(station.latitude), parseFloat(station.longitude)]).setIcon(blueIcon).addTo(map);
markers[key].on("click", function () {
handleClick(key, markers[key]);
});
}); console.log("SJ OK");
$.get("https://se.lc.bertmarcelis.be/stations-skanetrafiken.json", {headers: {'accept': 'application/ld+json'}}, function (skaneStations) {
skaneStations["@graph"].forEach(function (station) {
var key = station["@id"];
station.point = new L.LatLng(station.latitude, station.longitude);
stations[key] = station;
if (Math.random() < 0.1 && !(key in markers)) {
markers[key] = L.marker([parseFloat(station.latitude), parseFloat(station.longitude)]).setIcon(blueIcon).addTo(map);
markers[key].on("click", function () {
handleClick(key, markers[key]);
});
}
});
console.log("Skåne OK");
$.get("https://dk.lc.bertmarcelis.be/stations.json", {headers: {'accept': 'application/ld+json'}}, function (dkStations) {
dkStations["@graph"].forEach(function (station) {
var key = station["@id"];
station.point = new L.LatLng(station.latitude, station.longitude);
stations[key] = station;
if (Math.random() < 0.01 && !(key in markers)) {
markers[key] = L.marker([station.latitude, station.longitude]).setIcon(blueIcon).addTo(map);
markers[key].on("click", function () {
handleClick(key, markers[key]);
});
}
});
console.log("DK OK");
});
});
var startIcon = L.icon({
iconUrl: 'https://linkedconnections.org/images/marker-icon-start.png',
iconRetinaUrl: 'https://linkedconnections.org/images/marker-icon-2x-start.png'
});
L.Icon.Default.iconUrl = 'https://linkedconnections.org/images/marker-icon.png';
L.Icon.Default.iconRetinaUrl = 'https://linkedconnections.org/images/marker-icon-2x.png';
var planner = new window.lc.Client({"entrypoints": ['https://se.lc.bertmarcelis.be/sj/connections', 'https://se.lc.bertmarcelis.be/skanetrafiken/connections',
'https://dk.lc.bertmarcelis.be/arriva/connections', 'https://dk.lc.bertmarcelis.be/dsb/connections',
'https://dk.lc.bertmarcelis.be/metroselskabet/connections',
'https://dk.lc.bertmarcelis.be/midtrafik/connections', 'https://dk.lc.bertmarcelis.be/sydtrafik/connections',
'https://dk.lc.bertmarcelis.be/dsbs/connections', 'https://dk.lc.bertmarcelis.be/movia/connections']});
var departureStop = "";
var arrivalStop = "";
var handleClick = function (station, marker) {
if (departureStop === "") {
for (key in markers) {
map.removeLayer(markers[key]);
}
marker.addTo(map);
marker.setIcon(startIcon);
departureStop = station;
heat.addLatLng([stations[departureStop].point.lat, stations[departureStop].point.lng, 1]);
var startTime = new Date();
planner.query({
"departureStop": departureStop,
"departureTime": startTime
}, function (stream) {
var trips = {};
var countTrips = 0;
var seen = [];
stream.on('data', function (connection) {
console.log(connection);
if (stations[decodeURIComponent(connection.arrivalStop)] && stations[decodeURIComponent(connection.departureStop)]) {
var arrStr = connection.arrivalStop;
connection.arrivalStop = stations[decodeURIComponent(connection.arrivalStop)];
connection.departureStop = stations[decodeURIComponent(connection.departureStop)];
//circle for the isochrone to be drawn
//Keep an occurence of different trips and give a new colour per trip
//Hour and a Half duration!
var secondsFromStart = (connection.arrivalTime - startTime) / 1000;
console.log(secondsFromStart + " seconds elapsed!");
if (secondsFromStart < TIME_INTERVAL && !seen.includes(arrStr)) {
seen.push(arrStr);
heat.addLatLng([connection.arrivalStop.point.lat, connection.arrivalStop.point.lng, (TIME_INTERVAL - secondsFromStart) / TIME_INTERVAL]);
}
}
if (secondsFromStart > TIME_INTERVAL * 4) {
stream.end();
}
});
stream.on('error', function (error) {
console.error(error);
});
stream.on('end', function () {
console.log('end of stream');
});
});
}
}
});
});
</script>
</body>
</html>
<!Doctype html>
<html prefix="dct: http://purl.org/dc/terms/
rdf: http://www.w3.org/1999/02/22-rdf-syntax-ns#
foaf: http://xmlns.com/foaf/0.1/
og: http://ogp.me/ns#">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>LC2Isochrone Stockholm</title>
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.3.4/dist/leaflet.css"/>
<script src="https://unpkg.com/leaflet@1.3.4/dist/leaflet.js"></script>
<script src="leaflet-heat.js"></script>
<script src="leaflet-isochrone.js"></script>
<!--<script src='http://linkedconnections.org/js/lc-client.js'></script>-->
<script src='https://linkedconnections.org/js/lc-client.js'></script>
<script src="https://code.jquery.com/jquery-3.2.1.min.js"
crossorigin="anonymous"></script>
<style>
html, body {
height: 100%;
width: 100%;
margin: 0;
padding: 0;
}
#map {
min-height: 500px;
min-width: 500px;
height: 100%;
width: 100%;
}
</style>
</head>
<body>
<div id="map">
</div>
<script>
const TIME_INTERVAL = 3600 * 3;
$(function () {
var map = L.map('map', {
scrollWheelZoom: true
}).setView([57.9978819, 13.3822411], 8);
L.tileLayer('https://{s}.tile.openstreetmap.se/hydda/full/{z}/{x}/{y}.png', {
maxZoom: 18,
subdomains: 'abc',
}).addTo(map);
var heat = L.isochroneLayer([], {
minOpacity: 0.9,
radius: 10,
blur: 15,
gradient:
{
1.0: 'green',
0.75: 'lime',
0.50: 'yellow',
0.25: 'orange',
0.0: 'red'
},
}).addTo(map);
//Create our stations list on the basis of the iRail API
var stations = {};
var markers = {};
var blueIcon = L.icon({
iconUrl: 'https://linkedconnections.org/images/marker-icon.png',
// iconRetinaUrl : 'https://linkedconnections.org/images/marker-icon-2x.png',
iconAnchor: [12, 41]
});
$.get("https://se.lc.bertmarcelis.be/stations-sj.json", {headers: {'accept': 'application/ld+json'}}, function (sjStations) {
sjStations["@graph"].forEach(function (station) {
var key = station["@id"];
station.point = new L.LatLng(station.latitude, station.longitude);
stations[key] = station;
markers[key] = L.marker([station.latitude, station.longitude]).setIcon(blueIcon).addTo(map);
markers[key].on("click", function () {
handleClick(key, markers[key]);
});
});
$.get("https://se.lc.bertmarcelis.be/stations-sl.json", {headers: {'accept': 'application/ld+json'}}, function (stationslistNMBS) {
stationslistNMBS["@graph"].forEach(function (station) {
var key = station["@id"];
station.point = new L.LatLng(station.latitude, station.longitude);
stations[key] = station;
if (Math.random() < 0.01 && !(key in markers)) {
markers[key] = L.marker([station.latitude, station.longitude]).setIcon(blueIcon).addTo(map);
markers[key].on("click", function () {
handleClick(key, markers[key]);
});
}
});
});
$.get("https://se.lc.bertmarcelis.be/stations.json", {headers: {'accept': 'application/ld+json'}}, function (stationslistNMBS) {
stationslistNMBS["@graph"].forEach(function (station) {
var key = station["@id"];
station.point = new L.LatLng(station.latitude, station.longitude);
stations[key] = station;
if (Math.random() < 0.01 && !(key in markers)) {
markers[key] = L.marker([station.latitude, station.longitude]).setIcon(blueIcon).addTo(map);
markers[key].on("click", function () {
handleClick(key, markers[key]);
});
}
});
});
var startIcon = L.icon({
iconUrl: 'https://linkedconnections.org/images/marker-icon-start.png',
iconRetinaUrl: 'https://linkedconnections.org/images/marker-icon-2x-start.png'
});
L.Icon.Default.iconUrl = 'https://linkedconnections.org/images/marker-icon.png';
L.Icon.Default.iconRetinaUrl = 'https://linkedconnections.org/images/marker-icon-2x.png';
var planner = new window.lc.Client({"entrypoints": ['https://se.lc.bertmarcelis.be/sj/connections', 'https://se.lc.bertmarcelis.be/sl/connections', 'https://se.lc.bertmarcelis.be/ul/connections', 'https://se.lc.bertmarcelis.be/mtr/connections']});
var departureStop = "";
var arrivalStop = "";
var handleClick = function (station, marker) {
if (departureStop === "") {
for (key in markers) {
map.removeLayer(markers[key]);
}
marker.addTo(map);
marker.setIcon(startIcon);
departureStop = station;
heat.addLatLng([stations[departureStop].point.lat, stations[departureStop].point.lng, 1]);
var startTime = new Date();
planner.query({
"departureStop": departureStop,
"departureTime": startTime
}, function (stream) {
var trips = {};
var countTrips = 0;
var seen = [];
stream.on('data', function (connection) {
console.log(connection);
if (stations[connection.arrivalStop] && stations[connection.departureStop]) {
var arrStr = connection.arrivalStop;
connection.arrivalStop = stations[connection.arrivalStop];
connection.departureStop = stations[connection.departureStop];
//circle for the isochrone to be drawn
//Keep an occurence of different trips and give a new colour per trip
//Hour and a Half duration!
var secondsFromStart = (connection.arrivalTime - startTime) / 1000;
console.log(secondsFromStart + " seconds elapsed!");
if (secondsFromStart < TIME_INTERVAL && !seen.includes(arrStr)) {
seen.push(arrStr);
heat.addLatLng([connection.arrivalStop.point.lat, connection.arrivalStop.point.lng, (TIME_INTERVAL - secondsFromStart) / TIME_INTERVAL]);
}
}
if (secondsFromStart > TIME_INTERVAL * 4) {
stream.end();
}
});
stream.on('error', function (error) {
console.error(error);
});
stream.on('end', function () {
console.log('end of stream');
});
});
}
}
});
});
</script>
</body>
</html>
<!Doctype html>
<html prefix="dct: http://purl.org/dc/terms/
rdf: http://www.w3.org/1999/02/22-rdf-syntax-ns#
foaf: http://xmlns.com/foaf/0.1/
og: http://ogp.me/ns#">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>LC2Isochrone</title>
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.3.4/dist/leaflet.css"/>
<script src="https://unpkg.com/leaflet@1.3.4/dist/leaflet.js"></script>
<script src="leaflet-heat.js"></script>
<script src="leaflet-isochrone.js"></script>
<!--<script src='http://linkedconnections.org/js/lc-client.js'></script>-->
<script src='https://linkedconnections.org/js/lc-client.js'></script>
<script src="https://code.jquery.com/jquery-3.2.1.min.js"
crossorigin="anonymous"></script>
<style>
html, body {
height: 100%;
width: 100%;
margin: 0;
padding: 0;
}
#map {
min-height: 500px;
min-width: 500px;
height: 100%;
width: 100%;
}
</style>
</head>
<body>
<div id="map">
</div>
<script>
const TIME_INTERVAL = 3600 * 3;
$(function () {
var map = L.map('map', {
scrollWheelZoom: true
}).setView([57.9978819, 13.3822411], 8);
L.tileLayer('https://{s}.tile.openstreetmap.se/hydda/full/{z}/{x}/{y}.png', {
maxZoom: 18,
subdomains: 'abc',
}).addTo(map);
var heat = L.isochroneLayer([], {
minOpacity: 0.9,
radius: 10,
blur: 15,
gradient:
{
1.0: 'green',
0.75: 'lime',
0.50: 'yellow',
0.25: 'orange',
0.0: 'red'
},
}).addTo(map);
//Create our stations list on the basis of the iRail API
var stations = {};
var markers = {};
var blueIcon = L.icon({
iconUrl: 'https://linkedconnections.org/images/marker-icon.png',
// iconRetinaUrl : 'https://linkedconnections.org/images/marker-icon-2x.png',
iconAnchor: [12, 41]
});
$.get("https://se.lc.bertmarcelis.be/stations-sj.json", {headers: {'accept': 'application/ld+json'}}, function (sjStations) {
sjStations["@graph"].forEach(function (station) {
var key = station["@id"];
station.point = new L.LatLng(station.latitude, station.longitude);
stations[key] = station;
markers[key] = L.marker([station.latitude, station.longitude]).setIcon(blueIcon).addTo(map);
markers[key].on("click", function () {
handleClick(key, markers[key]);
});
});
$.get("https://se.lc.bertmarcelis.be/stations-vasttrafik.json", {headers: {'accept': 'application/ld+json'}}, function (stationslistNMBS) {
stationslistNMBS["@graph"].forEach(function (station) {
var key = station["@id"];
station.point = new L.LatLng(station.latitude, station.longitude);
stations[key] = station;
if (Math.random() < 0.1 && !(key in markers)) {
markers[key] = L.marker([station.latitude, station.longitude]).setIcon(blueIcon).addTo(map);
markers[key].on("click", function () {
handleClick(key, markers[key]);
});
}
});
});
var startIcon = L.icon({
iconUrl: 'https://linkedconnections.org/images/marker-icon-start.png',
iconRetinaUrl: 'https://linkedconnections.org/images/marker-icon-2x-start.png'
});
L.Icon.Default.iconUrl = 'https://linkedconnections.org/images/marker-icon.png';
L.Icon.Default.iconRetinaUrl = 'https://linkedconnections.org/images/marker-icon-2x.png';
var planner = new window.lc.Client({"entrypoints": ['https://se.lc.bertmarcelis.be/sj/connections', 'https://se.lc.bertmarcelis.be/vasttrafik/connections']});
var departureStop = "";
var arrivalStop = "";
var handleClick = function (station, marker) {
if (departureStop === "") {
for (key in markers) {
map.removeLayer(markers[key]);
}
marker.addTo(map);
marker.setIcon(startIcon);
departureStop = station;
heat.addLatLng([stations[departureStop].point.lat, stations[departureStop].point.lng, 1]);
var startTime = new Date();
planner.query({
"departureStop": departureStop,
"departureTime": startTime
}, function (stream) {
var trips = {};
var countTrips = 0;
var seen = [];
stream.on('data', function (connection) {
console.log(connection);
if (stations[connection.arrivalStop] && stations[connection.departureStop]) {
var arrStr = connection.arrivalStop;
connection.arrivalStop = stations[connection.arrivalStop];
connection.departureStop = stations[connection.departureStop];
//circle for the isochrone to be drawn
//Keep an occurence of different trips and give a new colour per trip
//Hour and a Half duration!
var secondsFromStart = (connection.arrivalTime - startTime) / 1000;
console.log(secondsFromStart + " seconds elapsed!");
if (secondsFromStart < TIME_INTERVAL && !seen.includes(arrStr)) {
seen.push(arrStr);
heat.addLatLng([connection.arrivalStop.point.lat, connection.arrivalStop.point.lng, (TIME_INTERVAL - secondsFromStart) / TIME_INTERVAL]);
}
}
if (secondsFromStart > TIME_INTERVAL * 4) {
stream.end();
}
});
stream.on('error', function (error) {
console.error(error);
});
stream.on('end', function () {
console.log('end of stream');
});
});
}
}
});
});
</script>
</body>
</html>
<!Doctype html>
<html prefix="dct: http://purl.org/dc/terms/
rdf: http://www.w3.org/1999/02/22-rdf-syntax-ns#
foaf: http://xmlns.com/foaf/0.1/
og: http://ogp.me/ns#">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>LC2Isochrone</title>
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.3.4/dist/leaflet.css"/>
<script src="https://unpkg.com/leaflet@1.3.4/dist/leaflet.js"></script>
<script src="leaflet-heat.js"></script>
<script src="leaflet-isochrone.js"></script>
<!--<script src='http://linkedconnections.org/js/lc-client.js'></script>-->
<script src='https://linkedconnections.org/js/lc-client.js'></script>
<script src="https://code.jquery.com/jquery-3.2.1.min.js"
crossorigin="anonymous"></script>
<style>
html, body {
height: 100%;
width: 100%;
margin: 0;
padding: 0;
}
#map {
min-height: 500px;
min-width: 500px;
height: 100%;
width: 100%;
}
</style>
</head>
<body>
<div id="map">
</div>
<script>
const TIME_INTERVAL = 3600 * 3;
$(function () {
var map = L.map('map', {
scrollWheelZoom: true
}).setView([57.9978819, 13.3822411], 8);
L.tileLayer('https://{s}.tile.openstreetmap.se/hydda/full/{z}/{x}/{y}.png', {
maxZoom: 18,
subdomains: 'abc',
}).addTo(map);
var heat = L.isochroneLayer([], {
minOpacity: 0.9,
radius: 10,
blur: 15,
gradient:
{
1.0: 'green',
0.75: 'lime',
0.50: 'yellow',
0.25: 'orange',
0.0: 'red'
},
}).addTo(map);
//Create our stations list on the basis of the iRail API
var stations = {};
var markers = {};
var blueIcon = L.icon({
iconUrl: 'https://linkedconnections.org/images/marker-icon.png',
// iconRetinaUrl : 'https://linkedconnections.org/images/marker-icon-2x.png',
iconAnchor: [12, 41]
});
$.get("https://se.lc.bertmarcelis.be/stations-vasttrafik.json", {headers: {'accept': 'application/ld+json'}}, function (stationslistNMBS) {
stationslistNMBS["@graph"].forEach(function (station) {
var key = station["@id"];
station.point = new L.LatLng(station.latitude, station.longitude);
stations[key] = station;
if (Math.random() < 0.1) {
markers[key] = L.marker([station.latitude, station.longitude]).setIcon(blueIcon).addTo(map);
markers[key].on("click", function () {
handleClick(key, markers[key]);
});
}
});
var startIcon = L.icon({
iconUrl: 'https://linkedconnections.org/images/marker-icon-start.png',
iconRetinaUrl: 'https://linkedconnections.org/images/marker-icon-2x-start.png'
});
L.Icon.Default.iconUrl = 'https://linkedconnections.org/images/marker-icon.png';
L.Icon.Default.iconRetinaUrl = 'https://linkedconnections.org/images/marker-icon-2x.png';
var planner = new window.lc.Client({"entrypoints": ['https://se.lc.bertmarcelis.be/vasttrafik/connections']});
var departureStop = "";
var arrivalStop = "";
var handleClick = function (station, marker) {
if (departureStop === "") {
for (key in markers) {
map.removeLayer(markers[key]);
}
marker.addTo(map);
marker.setIcon(startIcon);
departureStop = station;
heat.addLatLng([stations[departureStop].point.lat, stations[departureStop].point.lng, 1]);
var startTime = new Date();
planner.query({
"departureStop": departureStop,
"departureTime": startTime
}, function (stream) {
var trips = {};
var countTrips = 0;
var seen = [];
stream.on('data', function (connection) {
console.log(connection);
if (stations[connection.arrivalStop] && stations[connection.departureStop]) {
var arrStr = connection.arrivalStop;
connection.arrivalStop = stations[connection.arrivalStop];
connection.departureStop = stations[connection.departureStop];
//circle for the isochrone to be drawn
//Keep an occurence of different trips and give a new colour per trip
//Hour and a Half duration!
var secondsFromStart = (connection.arrivalTime - startTime) / 1000;
console.log(secondsFromStart + " seconds elapsed!");
if (secondsFromStart < TIME_INTERVAL && !seen.includes(arrStr)) {
seen.push(arrStr);
heat.addLatLng([connection.arrivalStop.point.lat, connection.arrivalStop.point.lng, (TIME_INTERVAL - secondsFromStart) / TIME_INTERVAL]);
}
}
if (secondsFromStart > TIME_INTERVAL * 4) {
stream.end();
}
});
stream.on('error', function (error) {
console.error(error);
});
stream.on('end', function () {
console.log('end of stream');
});
});
}
};
});
});
</script>
</body>
</html>
(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){
const Readable = require('stream').Readable;
const UriTemplate = require('uritemplate');
const N3Util = require('n3').Util;
const ConnectionsStore = require('./ConnectionsStore');
class ConnectionsFetcher extends Readable {
constructor (starturl, ldfetch, departureTime) {
super({objectMode: true});
this._discoveryPhase = true;
this.ldfetch = ldfetch;
this.departureTime = departureTime;
this.starturl = starturl;
this.store;
}
close () {
this.push(null);
}
_read () {
if (this._discoveryPhase) {
//Building block 1: a way to find a first page
this.ldfetch.get(this.starturl).then(response => {
//the current page needs to be discoverable
//Option 1: the lc:departureTimeQuery
// → through a hydra:search → hydra:template
// Need to check whether this is our building block: hydra:search → hydra:mapping → hydra:property === lc:departureTimeQuery
//filter once all triples with these predicates
var metaTriples = response.triples.filter(triple => {
return triple.predicate === 'http://www.w3.org/ns/hydra/core#search' || triple.predicate === 'http://www.w3.org/ns/hydra/core#mapping' || triple.predicate === 'http://www.w3.org/ns/hydra/core#template' || triple.predicate === 'http://www.w3.org/ns/hydra/core#property' || triple.predicate === 'http://www.w3.org/ns/hydra/core#variable';
});
var searchUriTriples = metaTriples.filter(triple => {
return triple.predicate === 'http://www.w3.org/ns/hydra/core#search' && triple.subject === response.url;
});
//look for all search template for the mapping
for (var i = 0; i < searchUriTriples.length; i ++) {
var searchUri = searchUriTriples[i].object;
//search for the lc:departureTimeQuery URI
var mappings = metaTriples.filter(triple => {
return triple.subject === searchUri && triple.predicate === 'http://www.w3.org/ns/hydra/core#mapping';
});
var mappingsUri = mappings[0].object;
/*for (var j = 0; j < mappings.length; j++) {
var mapping = metaTriples.filter(triple => {
return triple.subject === mappings[j].object;
});
}*/
//TODO: filter on the right subject
var template = N3Util.getLiteralValue(metaTriples.filter(triple => {
return triple.subject === searchUri && triple.predicate === 'http://www.w3.org/ns/hydra/core#template';
})[0].object);
var tpl = UriTemplate.parse(template);
var params = {};
params["departureTime"] = this.departureTime.toISOString();
var url = tpl.expand(params);
this.ldfetch.get(url).then(response => {
this.store = new ConnectionsStore(response.url, response.triples);
this.push(this.store.connections.shift());
}, error => {
console.error(error);
});
}
//Option 2: TODO: rangeGate and rangeFragments (multidimensional interfaces -- http://w3id.org/multidimensional-interface/spec)
//Not yet implemented
});
this._discoveryPhase = false;
} else {
//readConnection if still more available
if (this.store.connections.length > 0) {
this.push(this.store.connections.shift());
} else {
//fetch new page
this.ldfetch.get(this.store.nextPageIri).then(response => {
this.store = new ConnectionsStore(response.url, response.triples);
var connection = this.store.connections.shift();
this.push(connection);
}, error => {
this.push(null, error);
});
}
}
}
}
module.exports = ConnectionsFetcher;
},{"./ConnectionsStore":2,"n3":34,"stream":82,"uritemplate":51}],2:[function(require,module,exports){
var N3Util = require('n3').Util;
class ConnectionsStore {
constructor (documentIri, triples) {
this.documentIri = documentIri;
this.connections = [];
this.addTriples(triples);
}
addTriples (triples) {
//Find next page
//building block 1: every page should be a hydra:PagedCollection with a next and previous page link
var nextPage = triples.filter(triple => {
return triple.predicate === 'http://www.w3.org/ns/hydra/core#next' && triple.subject === this.documentIri;
});
this.nextPageIri = null;
if (nextPage[0] && nextPage[0].object.substr(0,4) === 'http') {
this.nextPageIri = nextPage[0].object;
}
//group all entities together and
var entities = [];
for (var i = 0; i < triples.length ; i++) {
var triple = triples[i];
if (!entities[triple.subject]) {
entities[triple.subject] = {};
}
//process different object types
/*if (N3Util.getLiteralType(triple.object) === 'http://www.w3.org/2001/XMLSchema#dateTime') {
triple.object = new Date(triple.object);
}*/
//process different object types
//if (N3Util.isLiteral(triple.object) && N3Util.getLiteralType(triple.object) === 'http://www.w3.org/2001/XMLSchema#integer') {
// triple.object = N3Util.getLiteralValue(triple.object);
//}
if (triple.predicate === "http://semweb.mmlab.be/ns/linkedconnections#departureTime") {
triple.predicate = "departureTime";
triple.object = new Date(N3Util.getLiteralValue(triple.object));
}
if (triple.predicate === "http://semweb.mmlab.be/ns/linkedconnections#departureDelay") {
triple.predicate = "departureDelay";
triple.object = N3Util.getLiteralValue(triple.object);
}
if (triple.predicate === "http://semweb.mmlab.be/ns/linkedconnections#arrivalDelay") {
triple.predicate = "arrivalDelay";
triple.object = N3Util.getLiteralValue(triple.object);
}
if (triple.predicate === "http://semweb.mmlab.be/ns/linkedconnections#arrivalTime") {
triple.predicate = "arrivalTime";
triple.object = new Date(N3Util.getLiteralValue(triple.object));
}
if (triple.predicate === "http://semweb.mmlab.be/ns/linkedconnections#departureStop") {
triple.predicate = "departureStop";
}
if (triple.predicate === "http://semweb.mmlab.be/ns/linkedconnections#arrivalStop") {
triple.predicate = "arrivalStop";
}
if (triple.predicate === "http://vocab.gtfs.org/terms#trip") {
triple.predicate = "gtfs:trip";
}
entities[triple.subject][triple.predicate] = triple.object;
}
//Find all Connections
//building block 2: every lc:Connection entity is taken from the page and processed
var keys = Object.keys(entities);
var connections = [];
for (var i = 0; i < keys.length; i++) {
if (entities[keys[i]]["http://www.w3.org/1999/02/22-rdf-syntax-ns#type"] && entities[keys[i]]["http://www.w3.org/1999/02/22-rdf-syntax-ns#type"] === 'http://semweb.mmlab.be/ns/linkedconnections#Connection') {
entities[keys[i]]["@id"] = keys[i];
connections.push(entities[keys[i]]);
}
}
this.connections = connections.sort( (connectionA, connectionB) => {
return connectionA.departureTime.valueOf() - connectionB.departureTime.valueOf();
});
}
getNextPageIri () {
return this.nextPageIri;
}
getConnections () {
return this.connections;
}
}
module.exports = ConnectionsStore;
},{"n3":34}],3:[function(require,module,exports){
var ConnectionsStream=require("./ConnectionsFetcher"),MergeSortStream=require("merge-sort-stream"),util=require("util"),async=require("async"),EventEmitter=require("events"),Fetcher=function(e,t){EventEmitter.call(this),this._config=e,this._http=t,this._entrypoints=e.entrypoints||[],this._connectionsStreams=[],this._mergeStream=null};util.inherits(Fetcher,EventEmitter),Fetcher.prototype.close=function(){for(var e in this._connectionsStreams)this._connectionsStreams[e].close()},Fetcher.prototype.buildConnectionsStream=function(e,t){var n=this,r=null;async.forEachOf(this._entrypoints,function(t,i,o){var s=new ConnectionsStream(t,n._http,e.departureTime);0===i?(r=s,n._connectionsStreams=[s]):(n._connectionsStreams.push(s),r=new MergeSortStream(r,s,function(e,t){return t.departureTime-e.departureTime})),o()},function(e){t(r)})},module.exports=Fetcher;
},{"./ConnectionsFetcher":1,"async":5,"events":59,"merge-sort-stream":33,"util":94}],4:[function(require,module,exports){
var Planner = require('csa').BasicCSA,
LDFetch = require('ldfetch'),
Fetcher = require('./Fetcher');
var Client = function (config) {
// Validate config
this._config = config;
this._numberOfQueries = 0; //Number of queries being ran
//Create an HTTP interface, which is the data interface
this._http = new LDFetch();
}
Client.prototype.query = function (q, cb) {
// Create fetcher: will create streams for a specific query
var fetcher = new Fetcher(this._config, this._http);
//1. Validate query
if (q.departureTime) {
q.departureTime = new Date(q.departureTime);
} else {
throw "Date of departure not set";
}
if (!q.departureStop) {
throw "Location of departure not set";
}
q.departureStop = decodeURIComponent(q.departureStop);
this._numberOfQueries ++;
var query = q, self = this;
query.index = this._numberOfQueries-1;
//2. Use query to configure the data fetchers
fetcher.buildConnectionsStream(q, connectionsStream => {
//3. fire results using CSA.js and return the stream
var planner = new Planner(q);
//When a result is found, stop the stream
planner.on("result", function () {
fetcher.close();
});
cb(connectionsStream.pipe(planner), this._http, connectionsStream);
});
};
if (typeof window !== "undefined") {
window.lc = {
Client : Client,
Fetcher: Fetcher
};
}
module.exports = Client;
module.exports.Fetcher = Fetcher;
},{"./Fetcher":3,"csa":10,"ldfetch":32}],5:[function(require,module,exports){
(function (process,global){
!function(){function n(){}function t(n){return n}function e(n){return!!n}function r(n){return!n}function u(n){return function(){if(null===n)throw new Error("Callback was already called.");n.apply(this,arguments),n=null}}function i(n){return function(){null!==n&&(n.apply(this,arguments),n=null)}}function o(n){return M(n)||"number"==typeof n.length&&n.length>=0&&n.length%1==0}function c(n,t){for(var e=-1,r=n.length;++e<r;)t(n[e],e,n)}function f(n,t){for(var e=-1,r=n.length,u=Array(r);++e<r;)u[e]=t(n[e],e,n);return u}function a(n){return f(Array(n),function(n,t){return t})}function l(n,t,e){return c(n,function(n,r,u){e=t(e,n,r,u)}),e}function s(n,t){c(W(n),function(e){t(n[e],e)})}function p(n,t){for(var e=0;e<n.length;e++)if(n[e]===t)return e;return-1}function h(n){var t,e,r=-1;return o(n)?(t=n.length,function(){return r++,r<t?r:null}):(e=W(n),t=e.length,function(){return r++,r<t?e[r]:null})}function y(n,t){return t=null==t?n.length-1:+t,function(){for(var e=Math.max(arguments.length-t,0),r=Array(e),u=0;u<e;u++)r[u]=arguments[u+t];switch(t){case 0:return n.call(this,r);case 1:return n.call(this,arguments[0],r)}}}function m(n){return function(t,e,r){return n(t,r)}}function d(t){return function(e,r,o){o=i(o||n),e=e||[];var c=h(e);if(t<=0)return o(null);var f=!1,a=0,l=!1;!function n(){if(f&&a<=0)return o(null);for(;a<t&&!l;){var i=c();if(null===i)return f=!0,void(a<=0&&o(null));a+=1,r(e[i],i,u(function(t){a-=1,t?(o(t),l=!0):n()}))}}()}}function v(n){return function(t,e,r){return n(P.eachOf,t,e,r)}}function g(n){return function(t,e,r,u){return n(d(e),t,r,u)}}function k(n){return function(t,e,r){return n(P.eachOfSeries,t,e,r)}}function b(t,e,r,u){u=i(u||n),e=e||[];var c=o(e)?[]:{};t(e,function(n,t,e){r(n,function(n,r){c[t]=r,e(n)})},function(n){u(n,c)})}function w(n,t,e,r){var u=[];n(t,function(n,t,r){e(n,function(e){e&&u.push({index:t,value:n}),r()})},function(){r(f(u.sort(function(n,t){return n.index-t.index}),function(n){return n.value}))})}function O(n,t,e,r){w(n,t,function(n,t){e(n,function(n){t(!n)})},r)}function S(n,t,e){return function(r,u,i,o){function c(){o&&o(e(!1,void 0))}function f(n,r,u){if(!o)return u();i(n,function(r){o&&t(r)&&(o(e(!0,n)),o=i=!1),u()})}arguments.length>3?n(r,u,f,c):(o=i,i=u,n(r,f,c))}}function E(n,t){return t}function L(t,e,r){r=r||n;var u=o(e)?[]:{};t(e,function(n,t,e){n(y(function(n,r){r.length<=1&&(r=r[0]),u[t]=r,e(n)}))},function(n){r(n,u)})}function j(n,t,e,r){var u=[];n(t,function(n,t,r){e(n,function(n,t){u=u.concat(t||[]),r(n)})},function(n){r(n,u)})}function I(t,e,r){function i(t,e,r,u){if(null!=u&&"function"!=typeof u)throw new Error("task callback must be a function");if(t.started=!0,M(e)||(e=[e]),0===e.length&&t.idle())return P.setImmediate(function(){t.drain()});c(e,function(e){var i={data:e,callback:u||n};r?t.tasks.unshift(i):t.tasks.push(i),t.tasks.length===t.concurrency&&t.saturated()}),P.setImmediate(t.process)}function o(n,t){return function(){a-=1;var e=!1,r=arguments;c(t,function(n){c(l,function(t,r){t!==n||e||(l.splice(r,1),e=!0)}),n.callback.apply(n,r)}),n.tasks.length+a===0&&n.drain(),n.process()}}if(null==e)e=1;else if(0===e)throw new Error("Concurrency must not be zero");var a=0,l=[],s={tasks:[],concurrency:e,payload:r,saturated:n,empty:n,drain:n,started:!1,paused:!1,push:function(n,t){i(s,n,!1,t)},kill:function(){s.drain=n,s.tasks=[]},unshift:function(n,t){i(s,n,!0,t)},process:function(){for(;!s.paused&&a<s.concurrency&&s.tasks.length;){var n=s.payload?s.tasks.splice(0,s.payload):s.tasks.splice(0,s.tasks.length),e=f(n,function(n){return n.data});0===s.tasks.length&&s.empty(),a+=1,l.push(n[0]);var r=u(o(s,n));t(e,r)}},length:function(){return s.tasks.length},running:function(){return a},workersList:function(){return l},idle:function(){return s.tasks.length+a===0},pause:function(){s.paused=!0},resume:function(){if(!1!==s.paused){s.paused=!1;for(var n=Math.min(s.concurrency,s.tasks.length),t=1;t<=n;t++)P.setImmediate(s.process)}}};return s}function x(n){return y(function(t,e){t.apply(null,e.concat([y(function(t,e){"object"==typeof console&&(t?console.error&&console.error(t):console[n]&&c(e,function(t){console[n](t)}))})]))})}function A(n){return function(t,e,r){n(a(t),e,r)}}function T(n){return y(function(t,e){var r=y(function(e){var r=this,u=e.pop();return n(t,function(n,t,u){n.apply(r,e.concat([u]))},u)});return e.length?r.apply(this,e):r})}function z(n){return y(function(t){var e=t.pop();t.push(function(){var n=arguments;r?P.setImmediate(function(){e.apply(null,n)}):e.apply(null,n)});var r=!0;n.apply(this,t),r=!1})}var q,P={},C="object"==typeof self&&self.self===self&&self||"object"==typeof global&&global.global===global&&global||this;null!=C&&(q=C.async),P.noConflict=function(){return C.async=q,P};var H=Object.prototype.toString,M=Array.isArray||function(n){return"[object Array]"===H.call(n)},U=function(n){var t=typeof n;return"function"===t||"object"===t&&!!n},W=Object.keys||function(n){var t=[];for(var e in n)n.hasOwnProperty(e)&&t.push(e);return t},B="function"==typeof setImmediate&&setImmediate,D=B?function(n){B(n)}:function(n){setTimeout(n,0)};"object"==typeof process&&"function"==typeof process.nextTick?P.nextTick=process.nextTick:P.nextTick=D,P.setImmediate=B?D:P.nextTick,P.forEach=P.each=function(n,t,e){return P.eachOf(n,m(t),e)},P.forEachSeries=P.eachSeries=function(n,t,e){return P.eachOfSeries(n,m(t),e)},P.forEachLimit=P.eachLimit=function(n,t,e,r){return d(t)(n,m(e),r)},P.forEachOf=P.eachOf=function(t,e,r){function o(n){a--,n?r(n):null===c&&a<=0&&r(null)}r=i(r||n),t=t||[];for(var c,f=h(t),a=0;null!=(c=f());)a+=1,e(t[c],c,u(o));0===a&&r(null)},P.forEachOfSeries=P.eachOfSeries=function(t,e,r){function o(){var n=!0;if(null===f)return r(null);e(t[f],f,u(function(t){if(t)r(t);else{if(null===(f=c()))return r(null);n?P.setImmediate(o):o()}})),n=!1}r=i(r||n),t=t||[];var c=h(t),f=c();o()},P.forEachOfLimit=P.eachOfLimit=function(n,t,e,r){d(t)(n,e,r)},P.map=v(b),P.mapSeries=k(b),P.mapLimit=g(b),P.inject=P.foldl=P.reduce=function(n,t,e,r){P.eachOfSeries(n,function(n,r,u){e(t,n,function(n,e){t=e,u(n)})},function(n){r(n,t)})},P.foldr=P.reduceRight=function(n,e,r,u){var i=f(n,t).reverse();P.reduce(i,e,r,u)},P.transform=function(n,t,e,r){3===arguments.length&&(r=e,e=t,t=M(n)?[]:{}),P.eachOf(n,function(n,r,u){e(t,n,r,u)},function(n){r(n,t)})},P.select=P.filter=v(w),P.selectLimit=P.filterLimit=g(w),P.selectSeries=P.filterSeries=k(w),P.reject=v(O),P.rejectLimit=g(O),P.rejectSeries=k(O),P.any=P.some=S(P.eachOf,e,t),P.someLimit=S(P.eachOfLimit,e,t),P.all=P.every=S(P.eachOf,r,r),P.everyLimit=S(P.eachOfLimit,r,r),P.detect=S(P.eachOf,t,E),P.detectSeries=S(P.eachOfSeries,t,E),P.detectLimit=S(P.eachOfLimit,t,E),P.sortBy=function(n,t,e){function r(n,t){var e=n.criteria,r=t.criteria;return e<r?-1:e>r?1:0}P.map(n,function(n,e){t(n,function(t,r){t?e(t):e(null,{value:n,criteria:r})})},function(n,t){if(n)return e(n);e(null,f(t.sort(r),function(n){return n.value}))})},P.auto=function(t,e,r){function u(n){g.unshift(n)}function o(n){var t=p(g,n);t>=0&&g.splice(t,1)}function f(){h--,c(g.slice(0),function(n){n()})}"function"==typeof arguments[1]&&(r=e,e=null),r=i(r||n);var a=W(t),h=a.length;if(!h)return r(null);e||(e=h);var m={},d=0,v=!1,g=[];u(function(){h||r(null,m)}),c(a,function(n){function i(){return d<e&&l(k,function(n,t){return n&&m.hasOwnProperty(t)},!0)&&!m.hasOwnProperty(n)}function c(){i()&&(d++,o(c),h[h.length-1](g,m))}if(!v){for(var a,h=M(t[n])?t[n]:[t[n]],g=y(function(t,e){if(d--,e.length<=1&&(e=e[0]),t){var u={};s(m,function(n,t){u[t]=n}),u[n]=e,v=!0,r(t,u)}else m[n]=e,P.setImmediate(f)}),k=h.slice(0,h.length-1),b=k.length;b--;){if(!(a=t[k[b]]))throw new Error("Has nonexistent dependency in "+k.join(", "));if(M(a)&&p(a,n)>=0)throw new Error("Has cyclic dependencies")}i()?(d++,h[h.length-1](g,m)):u(c)}})},P.retry=function(n,t,e){function r(n,t){for(;c.times;){var e=!(c.times-=1);o.push(function(n,e){return function(r){n(function(n,t){r(!n||e,{err:n,result:t})},t)}}(c.task,e)),!e&&c.interval>0&&o.push(function(n){return function(t){setTimeout(function(){t(null)},n)}}(c.interval))}P.series(o,function(t,e){e=e[e.length-1],(n||c.callback)(e.err,e.result)})}var u=5,i=0,o=[],c={times:u,interval:i},f=arguments.length;if(f<1||f>3)throw new Error("Invalid arguments - must be either (task), (task, callback), (times, task) or (times, task, callback)");return f<=2&&"function"==typeof n&&(e=t,t=n),"function"!=typeof n&&function(n,t){if("number"==typeof t)n.times=parseInt(t,10)||u;else{if("object"!=typeof t)throw new Error("Unsupported argument type for 'times': "+typeof t);n.times=parseInt(t.times,10)||u,n.interval=parseInt(t.interval,10)||i}}(c,n),c.callback=e,c.task=t,c.callback?r():r},P.waterfall=function(t,e){function r(n){return y(function(t,u){if(t)e.apply(null,[t].concat(u));else{var i=n.next();i?u.push(r(i)):u.push(e),z(n).apply(null,u)}})}if(e=i(e||n),!M(t)){var u=new Error("First argument to waterfall must be an array of functions");return e(u)}if(!t.length)return e();r(P.iterator(t))()},P.parallel=function(n,t){L(P.eachOf,n,t)},P.parallelLimit=function(n,t,e){L(d(t),n,e)},P.series=function(n,t){L(P.eachOfSeries,n,t)},P.iterator=function(n){function t(e){function r(){return n.length&&n[e].apply(null,arguments),r.next()}return r.next=function(){return e<n.length-1?t(e+1):null},r}return t(0)},P.apply=y(function(n,t){return y(function(e){return n.apply(null,t.concat(e))})}),P.concat=v(j),P.concatSeries=k(j),P.whilst=function(t,e,r){if(r=r||n,t()){var u=y(function(n,i){n?r(n):t.apply(this,i)?e(u):r.apply(null,[null].concat(i))});e(u)}else r(null)},P.doWhilst=function(n,t,e){var r=0;return P.whilst(function(){return++r<=1||t.apply(this,arguments)},n,e)},P.until=function(n,t,e){return P.whilst(function(){return!n.apply(this,arguments)},t,e)},P.doUntil=function(n,t,e){return P.doWhilst(n,function(){return!t.apply(this,arguments)},e)},P.during=function(t,e,r){r=r||n;var u=y(function(n,e){n?r(n):(e.push(i),t.apply(this,e))}),i=function(n,t){n?r(n):t?e(u):r(null)};t(i)},P.doDuring=function(n,t,e){var r=0;P.during(function(n){r++<1?n(null,!0):t.apply(this,arguments)},n,e)},P.queue=function(n,t){return I(function(t,e){n(t[0],e)},t,1)},P.priorityQueue=function(t,e){function r(n,t){return n.priority-t.priority}function u(n,t,e){for(var r=-1,u=n.length-1;r<u;){var i=r+(u-r+1>>>1);e(t,n[i])>=0?r=i:u=i-1}return r}function i(t,e,i,o){if(null!=o&&"function"!=typeof o)throw new Error("task callback must be a function");if(t.started=!0,M(e)||(e=[e]),0===e.length)return P.setImmediate(function(){t.drain()});c(e,function(e){var c={data:e,priority:i,callback:"function"==typeof o?o:n};t.tasks.splice(u(t.tasks,c,r)+1,0,c),t.tasks.length===t.concurrency&&t.saturated(),P.setImmediate(t.process)})}var o=P.queue(t,e);return o.push=function(n,t,e){i(o,n,t,e)},delete o.unshift,o},P.cargo=function(n,t){return I(n,1,t)},P.log=x("log"),P.dir=x("dir"),P.memoize=function(n,e){var r={},u={},i=Object.prototype.hasOwnProperty;e=e||t;var o=y(function(t){var o=t.pop(),c=e.apply(null,t);i.call(r,c)?P.setImmediate(function(){o.apply(null,r[c])}):i.call(u,c)?u[c].push(o):(u[c]=[o],n.apply(null,t.concat([y(function(n){r[c]=n;var t=u[c];delete u[c];for(var e=0,i=t.length;e<i;e++)t[e].apply(null,n)})])))});return o.memo=r,o.unmemoized=n,o},P.unmemoize=function(n){return function(){return(n.unmemoized||n).apply(null,arguments)}},P.times=A(P.map),P.timesSeries=A(P.mapSeries),P.timesLimit=function(n,t,e,r){return P.mapLimit(a(n),t,e,r)},P.seq=function(){var t=arguments;return y(function(e){var r=this,u=e[e.length-1];"function"==typeof u?e.pop():u=n,P.reduce(t,e,function(n,t,e){t.apply(r,n.concat([y(function(n,t){e(n,t)})]))},function(n,t){u.apply(r,[n].concat(t))})})},P.compose=function(){return P.seq.apply(null,Array.prototype.reverse.call(arguments))},P.applyEach=T(P.eachOf),P.applyEachSeries=T(P.eachOfSeries),P.forever=function(t,e){function r(n){if(n)return i(n);o(r)}var i=u(e||n),o=z(t);r()},P.ensureAsync=z,P.constant=y(function(n){var t=[null].concat(n);return function(n){return n.apply(this,t)}}),P.wrapSync=P.asyncify=function(n){return y(function(t){var e,r=t.pop();try{e=n.apply(this,t)}catch(n){return r(n)}U(e)&&"function"==typeof e.then?e.then(function(n){r(null,n)}).catch(function(n){r(n.message?n:new Error(n))}):r(null,e)})},"object"==typeof module&&module.exports?module.exports=P:"function"==typeof define&&define.amd?define([],function(){return P}):C.async=P}();
}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
},{"_process":66}],6:[function(require,module,exports){
(function (Buffer){
function isArray(r){return Array.isArray?Array.isArray(r):"[object Array]"===objectToString(r)}function isBoolean(r){return"boolean"==typeof r}function isNull(r){return null===r}function isNullOrUndefined(r){return null==r}function isNumber(r){return"number"==typeof r}function isString(r){return"string"==typeof r}function isSymbol(r){return"symbol"==typeof r}function isUndefined(r){return void 0===r}function isRegExp(r){return"[object RegExp]"===objectToString(r)}function isObject(r){return"object"==typeof r&&null!==r}function isDate(r){return"[object Date]"===objectToString(r)}function isError(r){return"[object Error]"===objectToString(r)||r instanceof Error}function isFunction(r){return"function"==typeof r}function isPrimitive(r){return null===r||"boolean"==typeof r||"number"==typeof r||"string"==typeof r||"symbol"==typeof r||void 0===r}function objectToString(r){return Object.prototype.toString.call(r)}exports.isArray=isArray,exports.isBoolean=isBoolean,exports.isNull=isNull,exports.isNullOrUndefined=isNullOrUndefined,exports.isNumber=isNumber,exports.isString=isString,exports.isSymbol=isSymbol,exports.isUndefined=isUndefined,exports.isRegExp=isRegExp,exports.isObject=isObject,exports.isDate=isDate,exports.isError=isError,exports.isFunction=isFunction,exports.isPrimitive=isPrimitive,exports.isBuffer=Buffer.isBuffer;
}).call(this,{"isBuffer":require("../../../../../../../../usr/local/lib/node_modules/browserify/node_modules/is-buffer/index.js")})
},{"../../../../../../../../usr/local/lib/node_modules/browserify/node_modules/is-buffer/index.js":63}],7:[function(require,module,exports){
function AddStreamNameTransformer(r){Transform.call(this,{objectMode:!0}),this._name=r}var Transform=require("stream").Transform,util=require("util");util.inherits(AddStreamNameTransformer,Transform),AddStreamNameTransformer.prototype._transform=function(r,e,a){r.streamName=this._name,this.push(r),a()},module.exports=AddStreamNameTransformer;
},{"stream":82,"util":94}],8:[function(require,module,exports){
var util=require("util"),Transform=require("stream").Transform,PriorityQueue=require("js-priority-queue"),ResultStream=function(i){if(Transform.call(this,{objectMode:!0}),this._earliestArrivalTimes={},this._pending=new PriorityQueue({comparator:function(i,r){return i.arrivalTime-r.arrivalTime}}),!i)throw"no query found";if(this._latestArrivalTime=i.latestArrivalTime,this._departureStop=i.departureStop,this._arrivalStop=i.arrivalStop||"",this._departureStop===this._arrivalStop)throw"You are already at this location";this._departureTime=i.departureTime,this._earliestArrivalTimes[this._departureStop]={"@id":null,arrivalTime:i.departureTime},this._minimumSpanningTree={},this._count=0,this._hasEmitted=!1};util.inherits(ResultStream,Transform),ResultStream.prototype._transform=function(i,r,e){this._count++;for(var t=i.departureStop,a=i.arrivalStop;this._pending.length>0&&this._pending.peek().arrivalTime<=i.departureTime;){var s=this._pending.dequeue();this._earliestArrivalTimes[s.arrivalStop]["@id"]==s["@id"]&&this.push(s)}!this._hasEmitted&&this._earliestArrivalTimes[this._arrivalStop]&&i.departureTime>this._earliestArrivalTimes[this._arrivalStop].arrivalTime&&(this.emit("result",this._reconstructRoute()),this._hasEmitted=!0),this._earliestArrivalTimes[t]&&this._earliestArrivalTimes[t].arrivalTime<=i.departureTime&&(!this._earliestArrivalTimes[a]||this._earliestArrivalTimes[a].arrivalTime>i.arrivalTime)&&(this._minimumSpanningTree[i["@id"]]=i,this._earliestArrivalTimes[a]={arrivalTime:i.arrivalTime,"@id":i["@id"]},i.previous=this._earliestArrivalTimes[t]["@id"],this._minimumSpanningTree[i["@id"]]=i,this._pending.queue(i)),e()},ResultStream.prototype._reconstructRoute=function(){for(var i=[],r=this._minimumSpanningTree[this._earliestArrivalTimes[this._arrivalStop]["@id"]],e=!1,t=this._earliestArrivalTimes[this._arrivalStop].arrivalTime;r&&!e;)i.unshift(r),r=this._minimumSpanningTree[r.previous],r&&t>=r.arrivalTime?t=r.arrivalTime:r&&(i.unshift(r),console.error("Illegal minimum spanning tree found with an infinite loop (may occur due to bad data) with @id: ",r["@id"]),e=!0);return i},ResultStream.prototype._flush=function(i){!this._hasEmitted&&this._earliestArrivalTimes[this._arrivalStop]&&(this.emit("result",this._reconstructRoute()),this._hasEmitted=!0),i()},module.exports=ResultStream;
},{"js-priority-queue":22,"stream":82,"util":94}],9:[function(require,module,exports){
var Readable=require("stream").Readable,Transform=require("stream").Transform,util=require("util"),AddStreamNameTransformer=require("./AddStreamNameTransformer"),MergeStream=function(e,t){Readable.call(this,{objectMode:!0});this._connectionsStreams=[],this._amountStreams=0,this._connectionsStreamIndex={},this._queues=[],this._departureTime=t,this._maxInQueues=t,this._amountConnectionsInQueues={};for(var n=0;n<e.length;n++){var s=e[n][0],r=e[n][1];this.addConnectionsStream(s,r)}};util.inherits(MergeStream,Readable),MergeStream.prototype.addConnectionsStream=function(e,t){var n=this,s=this._connectionsStreams.length;this._connectionsStreamIndex[e]=s,this._amountConnectionsInQueues[e]=0,this._amountStreams++,this._connectionsStreams[s]=t.pipe(new AddStreamNameTransformer(e)),this._connectionsStreams[s].on("data",function(e){e.departureTime>=n._departureTime&&(n._amountConnectionsInQueues[e.streamName]++,n._connectionListener(e))}),this._connectionsStreams[s].on("end",function(){n._amountStreams--;var e=n._connectionsStreams.indexOf(this);n._connectionsStreams[e]=null,0==n._amountStreams?n.close():n._read()})},MergeStream.prototype._read=function(){if(this._streamsPaused())if(this._allActiveStreamsAvailable()){var e=this._next();if(null!=e)this.push(e);else for(var t=0;t<this._connectionsStreams.length;t++)null!=this._connectionsStreams[t]&&this._connectionsStreams[t].resume()}else for(var t=0;t<this._connectionsStreams.length;t++)null!=this._connectionsStreams[t]&&this._connectionsStreams[t].resume()},MergeStream.prototype._next=function(){for(var e=null,t=0;t<=this._queues.length;){if(this._queues[t]&&this._queues[t].length>0){if(this._queues[t][0].departureTime==this._departureTime){var n=this._queues[t].shift();return this._amountConnectionsInQueues[n.streamName]-=1,n}this._queues[t]&&(null==e||this._queues[t][0].departureTime<e)&&(e=this._queues[t][0].departureTime)}t++}return null!=e||e>this._departureTime?(this._departureTime=e,this._next()):null},MergeStream.prototype.close=function(){for(var e=this._next();null!=e;)this.push(e),e=this._next();this._queues=[],this.push(null)},MergeStream.prototype._connectionListener=function(e){if(e.departureTime>this._maxInQueues){var t=e.streamName,n=this._connectionsStreamIndex[t];null!=this._connectionsStreams[n]&&this._connectionsStreams[n].pause(),this._read()}this._addConnection(e)},MergeStream.prototype._addConnection=function(e){for(var t=!1,n=0;!t&&n<this._queues.length;){var s=this._queues[n].length;(0===s||this._queues[n][s-1].departureTime<=e.departureTime)&&(this._queues[n].push(e),t=!0),n++}if(!t){var r=[e];this._queues.push(r)}e.departureTime>this._maxInQueues&&(this._maxInQueues=e.departureTime)},MergeStream.prototype._streamsPaused=function(){for(var e=0;e<this._connectionsStreams.length;e++)if(null!=this._connectionsStreams[e]&&this._amountStreams==this._amountConnectionsInQueues.length&&!this._connectionsStreams[e].isPaused())return!1;return!0},MergeStream.prototype._allActiveStreamsAvailable=function(){for(var e in this._amountConnectionsInQueues){if(0==this._amountConnectionsInQueues[e]){if(Object.keys(this._amountConnectionsInQueues).length==this._amountStreams)return!1;var t=this._connectionsStreamIndex[e];this._connectionsStreams[t]=null,delete this._amountConnectionsInQueues[e]}}return!0},module.exports=MergeStream;
},{"./AddStreamNameTransformer":7,"stream":82,"util":94}],10:[function(require,module,exports){
module.exports={BasicCSA:require("./BasicCSA"),MergeStream:require("./MergeStream")};
},{"./BasicCSA":8,"./MergeStream":9}],11:[function(require,module,exports){
var once=require("once"),noop=function(){},isRequest=function(e){return e.setHeader&&"function"==typeof e.abort},isChildProcess=function(e){return e.stdio&&Array.isArray(e.stdio)&&3===e.stdio.length},eos=function(e,r,n){if("function"==typeof r)return eos(e,null,r);r||(r={}),n=once(n||noop);var o=e._writableState,t=e._readableState,i=r.readable||!1!==r.readable&&e.readable,s=r.writable||!1!==r.writable&&e.writable,l=function(){e.writable||c()},c=function(){s=!1,i||n.call(e)},a=function(){i=!1,s||n.call(e)},u=function(r){n.call(e,r?new Error("exited with error code: "+r):null)},d=function(){return(!i||t&&t.ended)&&(!s||o&&o.ended)?void 0:n.call(e,new Error("premature close"))},f=function(){e.req.on("finish",c)};return isRequest(e)?(e.on("complete",c),e.on("abort",d),e.req?f():e.on("request",f)):s&&!o&&(e.on("end",l),e.on("close",l)),isChildProcess(e)&&e.on("exit",u),e.on("end",a),e.on("finish",c),!1!==r.error&&e.on("error",n),e.on("close",d),function(){e.removeListener("complete",c),e.removeListener("abort",d),e.removeListener("request",f),e.req&&e.req.removeListener("finish",c),e.removeListener("end",l),e.removeListener("close",l),e.removeListener("finish",c),e.removeListener("exit",u),e.removeListener("end",a),e.removeListener("error",n),e.removeListener("close",d)}};module.exports=eos;
},{"once":42}],12:[function(require,module,exports){
(function (process,global){
(function(){"use strict";function t(t){return"function"==typeof t||"object"==typeof t&&null!==t}function e(t){return"function"==typeof t}function n(t){return"object"==typeof t&&null!==t}function r(t){D=t}function o(t){U=t}function i(){return function(){F(s)}}function u(){return function(){setTimeout(s,1)}}function s(){for(var t=0;t<N;t+=2){(0,H[t])(H[t+1]),H[t]=void 0,H[t+1]=void 0}N=0}function c(){}function a(){return new TypeError("You cannot resolve a promise with itself")}function f(){return new TypeError("A promises callback cannot return that same promise.")}function l(t){try{return t.then}catch(t){return V.error=t,V}}function p(t,e,n,r){try{t.call(e,n,r)}catch(t){return t}}function _(t,e,n){U(function(t){var r=!1,o=p(n,e,function(n){r||(r=!0,e!==n?v(t,n):m(t,n))},function(e){r||(r=!0,b(t,e))},"Settle: "+(t._label||" unknown promise"));!r&&o&&(r=!0,b(t,o))},t)}function h(t,e){e._state===Q?m(t,e._result):e._state===R?b(t,e._result):w(e,void 0,function(e){v(t,e)},function(e){b(t,e)})}function d(t,n){if(n.constructor===t.constructor)h(t,n);else{var r=l(n);r===V?b(t,V.error):void 0===r?m(t,n):e(r)?_(t,n,r):m(t,n)}}function v(e,n){e===n?b(e,a()):t(n)?d(e,n):m(e,n)}function y(t){t._onerror&&t._onerror(t._result),g(t)}function m(t,e){t._state===J&&(t._result=e,t._state=Q,0!==t._subscribers.length&&U(g,t))}function b(t,e){t._state===J&&(t._state=R,t._result=e,U(y,t))}function w(t,e,n,r){var o=t._subscribers,i=o.length;t._onerror=null,o[i]=e,o[i+Q]=n,o[i+R]=r,0===i&&t._state&&U(g,t)}function g(t){var e=t._subscribers,n=t._state;if(0!==e.length){for(var r,o,i=t._result,u=0;u<e.length;u+=3)r=e[u],o=e[u+n],r?j(n,r,o,i):o(i);t._subscribers.length=0}}function A(){this.error=null}function E(t,e){try{return t(e)}catch(t){return X.error=t,X}}function j(t,n,r,o){var i,u,s,c,a=e(r);if(a){if(i=E(r,o),i===X?(c=!0,u=i.error,i=null):s=!0,n===i)return void b(n,f())}else i=o,s=!0;n._state!==J||(a&&s?v(n,i):c?b(n,u):t===Q?m(n,i):t===R&&b(n,i))}function S(t,e){try{e(function(e){v(t,e)},function(e){b(t,e)})}catch(e){b(t,e)}}function T(t,e){var n=this;n._instanceConstructor=t,n.promise=new t(c),n._validateInput(e)?(n._input=e,n.length=e.length,n._remaining=e.length,n._init(),0===n.length?m(n.promise,n._result):(n.length=n.length||0,n._enumerate(),0===n._remaining&&m(n.promise,n._result))):b(n.promise,n._validationError())}function P(t){return new Z(this,t).promise}function x(t){function e(t){v(o,t)}function n(t){b(o,t)}var r=this,o=new r(c);if(!L(t))return b(o,new TypeError("You must pass an array to race.")),o;for(var i=t.length,u=0;o._state===J&&u<i;u++)w(r.resolve(t[u]),void 0,e,n);return o}function C(t){var e=this;if(t&&"object"==typeof t&&t.constructor===e)return t;var n=new e(c);return v(n,t),n}function M(t){var e=this,n=new e(c);return b(n,t),n}function O(){throw new TypeError("You must pass a resolver function as the first argument to the promise constructor")}function k(){throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function.")}function I(t){this._id=ot++,this._state=void 0,this._result=void 0,this._subscribers=[],c!==t&&(e(t)||O(),this instanceof I||k(),S(this,t))}function Y(){var t;if("undefined"!=typeof global)t=global;else if("undefined"!=typeof self)t=self;else try{t=Function("return this")()}catch(t){throw new Error("polyfill failed because global object is unavailable in this environment")}var e=t.Promise;e&&"[object Promise]"===Object.prototype.toString.call(e.resolve())&&!e.cast||(t.Promise=it)}var q;q=Array.isArray?Array.isArray:function(t){return"[object Array]"===Object.prototype.toString.call(t)};var F,D,K,L=q,N=0,U=function(t,e){H[N]=t,H[N+1]=e,2===(N+=2)&&(D?D(s):K())},W="undefined"!=typeof window?window:void 0,$=W||{},z=$.MutationObserver||$.WebKitMutationObserver,B="undefined"!=typeof process&&"[object process]"==={}.toString.call(process),G="undefined"!=typeof Uint8ClampedArray&&"undefined"!=typeof importScripts&&"undefined"!=typeof MessageChannel,H=new Array(1e3);K=B?function(){var t=process.nextTick,e=process.versions.node.match(/^(?:(\d+)\.)?(?:(\d+)\.)?(\*|\d+)$/);return Array.isArray(e)&&"0"===e[1]&&"10"===e[2]&&(t=setImmediate),function(){t(s)}}():z?function(){var t=0,e=new z(s),n=document.createTextNode("");return e.observe(n,{characterData:!0}),function(){n.data=t=++t%2}}():G?function(){var t=new MessageChannel;return t.port1.onmessage=s,function(){t.port2.postMessage(0)}}():void 0===W&&"function"==typeof require?function(){try{var t=require,e=t("vertx");return F=e.runOnLoop||e.runOnContext,i()}catch(t){return u()}}():u();var J=void 0,Q=1,R=2,V=new A,X=new A;T.prototype._validateInput=function(t){return L(t)},T.prototype._validationError=function(){return new Error("Array Methods must be provided an Array")},T.prototype._init=function(){this._result=new Array(this.length)};var Z=T;T.prototype._enumerate=function(){for(var t=this,e=t.length,n=t.promise,r=t._input,o=0;n._state===J&&o<e;o++)t._eachEntry(r[o],o)},T.prototype._eachEntry=function(t,e){var r=this,o=r._instanceConstructor;n(t)?t.constructor===o&&t._state!==J?(t._onerror=null,r._settledAt(t._state,e,t._result)):r._willSettleAt(o.resolve(t),e):(r._remaining--,r._result[e]=t)},T.prototype._settledAt=function(t,e,n){var r=this,o=r.promise;o._state===J&&(r._remaining--,t===R?b(o,n):r._result[e]=n),0===r._remaining&&m(o,r._result)},T.prototype._willSettleAt=function(t,e){var n=this;w(t,void 0,function(t){n._settledAt(Q,e,t)},function(t){n._settledAt(R,e,t)})};var tt=P,et=x,nt=C,rt=M,ot=0,it=I;I.all=tt,I.race=et,I.resolve=nt,I.reject=rt,I._setScheduler=r,I._setAsap=o,I._asap=U,I.prototype={constructor:I,then:function(t,e){var n=this,r=n._state;if(r===Q&&!t||r===R&&!e)return this;var o=new this.constructor(c),i=n._result;if(r){var u=arguments[r-1];U(function(){j(r,o,u,i)})}else w(n,o,t,e);return o},catch:function(t){return this.then(null,t)}};var ut=Y,st={Promise:it,polyfill:ut};"function"==typeof define&&define.amd?define(function(){return st}):"undefined"!=typeof module&&module.exports?module.exports=st:void 0!==this&&(this.ES6Promise=st),ut()}).call(this);
}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
},{"_process":66}],13:[function(require,module,exports){
"use strict";function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function _classCallCheck(e,r){if(!(e instanceof r))throw new TypeError("Cannot call a class as a function")}function _possibleConstructorReturn(e,r){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!r||"object"!=typeof r&&"function"!=typeof r?e:r}function _inherits(e,r){if("function"!=typeof r&&null!==r)throw new TypeError("Super expression must either be null or a function, not "+typeof r);e.prototype=Object.create(r&&r.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),r&&(Object.setPrototypeOf?Object.setPrototypeOf(e,r):e.__proto__=r)}Object.defineProperty(exports,"__esModule",{value:!0});var _createClass=function(){function e(e,r){for(var t=0;t<r.length;t++){var a=r[t];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}return function(r,t,a){return t&&e(r.prototype,t),a&&e(r,a),r}}(),_rdfaProcessor=require("./rdfa-processor"),_rdfaProcessor2=_interopRequireDefault(_rdfaProcessor),_rdfaGraph=require("./rdfa-graph"),GraphRDFaProcessor=function(e){function r(e){return _classCallCheck(this,r),_possibleConstructorReturn(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,e))}return _inherits(r,e),_createClass(r,[{key:"getObjectSize",value:function(e){var r=0;for(var t in e)e.hasOwnProperty(t)&&r++;return r}},{key:"init",value:function(){var e=this;this.finishedHandlers.push(function(r){for(var t in e.target.graph.subjects){var a=e.target.graph.subjects[t];0==e.getObjectSize(a.predicates)&&delete e.target.graph.subjects[t]}})}},{key:"newBlankNode",value:function(){return this.target.graph.newBlankNode()}},{key:"newSubjectOrigin",value:function(e,r){for(var t=this.newSubject(null,r),a=0;a<t.origins.length;a++)if(t.origins[a]===e)return;t.origins.push(e),e.data||Object.defineProperty(e,"data",{value:t,writable:!1,configurable:!0,enumerable:!0})}},{key:"newSubject",value:function(e,r){var t=this.target.graph.subjects[r];return t||(t=new _rdfaGraph.RDFaSubject(this.target.graph,r),this.target.graph.subjects[r]=t),t}},{key:"addTriple",value:function(e,r,t,a){var o=this.newSubject(e,r),s=o.predicates[t];s||(s=new _rdfaGraph.RDFaPredicate(t),o.predicates[t]=s);for(var n=0;n<s.objects.length;n++)if(s.objects[n].type==a.type&&s.objects[n].value==a.value){if(s.objects[n].origin!==e){if(!Array.isArray(s.objects[n].origin)){var i=[];i.push(s.objects[n].origin),s.objects[n].origin=i}s.objects[n].origin.push(e)}return}s.objects.push(a),a.origin=e,t==_rdfaProcessor2.default.typeURI&&o.types.push(a.value)}},{key:"copyProperties",value:function(){var e=[],t={};for(var a in this.target.graph.subjects){var o=this.target.graph.subjects[a],s=o.predicates[r.rdfaCopyPredicate];if(s){e.push(a);for(var n=0;n<s.objects.length;n++)if(s.objects[n].type==_rdfaProcessor2.default.objectURI){var i=s.objects[n].value,c=this.target.graph.subjects[i];if(c){var u=c.predicates[_rdfaProcessor2.default.typeURI];if(u){for(var p=!1,f=0;f<u.objects.length&&!p;f++)u.objects[f].value==r.rdfaPatternType&&u.objects[f].type==_rdfaProcessor2.default.objectURI&&(p=!0);if(p){t[i]=!0;for(var l in c.predicates){var b=c.predicates[l];if(l==_rdfaProcessor2.default.typeURI){if(1==b.objects.length)continue;for(var f=0;f<b.objects.length;f++)if(b.objects[f].value!=r.rdfaPatternType){var h=o.predicates[l];h||(h=new _rdfaGraph.RDFaPredicate(l),o.predicates[l]=h),h.objects.push({type:b.objects[f].type,value:b.objects[f].value,language:b.objects[f].language,origin:b.objects[f].origin}),o.types.push(b.objects[f].value)}}else{var h=o.predicates[l];h||(h=new _rdfaGraph.RDFaPredicate(l),o.predicates[l]=h);for(var f=0;f<b.objects.length;f++)h.objects.push({type:b.objects[f].type,value:b.objects[f].value,language:b.objects[f].language,origin:b.objects[f].origin})}}}}}}}}for(var n=0;n<e.length;n++){var o=this.target.graph.subjects[e[n]];delete o.predicates[r.rdfaCopyPredicate]}for(var a in t)delete this.target.graph.subjects[a]}}]),r}(_rdfaProcessor2.default);exports.default=GraphRDFaProcessor,GraphRDFaProcessor.rdfaCopyPredicate="http://www.w3.org/ns/rdfa#copy",GraphRDFaProcessor.rdfaPatternType="http://www.w3.org/ns/rdfa#Pattern",module.exports=exports.default;
},{"./rdfa-graph":16,"./rdfa-processor":17}],14:[function(require,module,exports){
"use strict";function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},a=e.documentElement||e,o=r.baseURI?r.baseURI:a.baseURI,s=new _rdfaGraph.RDFaGraph,u={graph:s,baseURI:(new _uriResolver2.default).parseURI(o)};return new _graphRdfaProcessor2.default(u).process(a,r),u.graph};var _uriResolver=require("./uri-resolver"),_uriResolver2=_interopRequireDefault(_uriResolver),_graphRdfaProcessor=require("./graph-rdfa-processor"),_graphRdfaProcessor2=_interopRequireDefault(_graphRdfaProcessor),_rdfaGraph=require("./rdfa-graph");module.exports=exports.default;
},{"./graph-rdfa-processor":13,"./rdfa-graph":16,"./uri-resolver":18}],15:[function(require,module,exports){
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var Node={ELEMENT_NODE:1,ATTRIBUTE_NODE:2,TEXT_NODE:3,CDATA_SECTION_NODE:4,ENTITY_REFERENCE_NODE:5,ENTITY_NODE:6,PROCESSING_INSTRUCTION_NODE:7,COMMENT_NODE:8,DOCUMENT_NODE:9,DOCUMENT_TYPE_NODE:10,DOCUMENT_FRAGMENT_NODE:11,NOTATION_NODE:12};exports.default=Node,module.exports=exports.default;
},{}],16:[function(require,module,exports){
"use strict";function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(exports,"__esModule",{value:!0}),exports.RDFaPredicate=exports.RDFaSubject=exports.RDFaGraph=void 0;var _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},_createClass=function(){function e(e,t){for(var r=0;r<t.length;r++){var s=t[r];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(e,s.key,s)}}return function(t,r,s){return r&&e(t.prototype,r),s&&e(t,s),t}}(),_node=require("./node"),_node2=_interopRequireDefault(_node),RDFaGraph=exports.RDFaGraph=function(){function e(){_classCallCheck(this,e);var t=this;this.curieParser={trim:function(e){return e.replace(/^\s\s*/,"").replace(/\s\s*$/,"")},parse:function(e,r){e=this.trim(e),"["==e.charAt(0)&&"]"==e.charAt(e.length-1)&&(e=e.substring(1,e.length-1));var s=e.indexOf(":");if(s>=0){var i=e.substring(0,s);if(""==i){var a=t.prefixes[""];return a?a+e.substring(s+1):null}if("_"==i)return"_:"+e.substring(s+1);if(DocumentData.NCNAME.test(i)){var a=t.prefixes[i];if(a)return a+e.substring(s+1)}}return r?t.baseURI.resolve(e):e}},this.base=null,this.toString=function(e){var t=e&&e.shorten?{graph:this,shorten:!0,prefixesUsed:{}}:null;if(e&&e.blankNodePrefix&&(t.filterBlankNode=function(t){return"_:"+e.blankNodePrefix+t.substring(2)}),e&&e.numericalBlankNodePrefix){var r=/^[0-9]+$/;t.filterBlankNode=function(t){var s=t.substring(2);return r.test(s)?"_:"+e.numericalBlankNodePrefix+s:t}}var s="";for(var i in this.subjects){s+=this.subjects[i].toString(t),s+="\n"}var a=e&&e.baseURI?"@base <"+baseURI+"> .\n":"";if(t&&t.shorten)for(var n in t.prefixesUsed)a+="@prefix "+n+": <"+this.prefixes[n]+"> .\n";return 0==a.length?s:a+"\n"+s},this.blankNodeCounter=0,this.clear=function(){this.subjects={},this.prefixes={},this.terms={},this.blankNodeCounter=0},this.clear(),this.prefixes[""]="http://www.w3.org/1999/xhtml/vocab#",this.prefixes.grddl="http://www.w3.org/2003/g/data-view#",this.prefixes.ma="http://www.w3.org/ns/ma-ont#",this.prefixes.owl="http://www.w3.org/2002/07/owl#",this.prefixes.rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#",this.prefixes.rdfa="http://www.w3.org/ns/rdfa#",this.prefixes.rdfs="http://www.w3.org/2000/01/rdf-schema#",this.prefixes.rif="http://www.w3.org/2007/rif#",this.prefixes.skos="http://www.w3.org/2004/02/skos/core#",this.prefixes.skosxl="http://www.w3.org/2008/05/skos-xl#",this.prefixes.wdr="http://www.w3.org/2007/05/powder#",this.prefixes.void="http://rdfs.org/ns/void#",this.prefixes.wdrs="http://www.w3.org/2007/05/powder-s#",this.prefixes.xhv="http://www.w3.org/1999/xhtml/vocab#",this.prefixes.xml="http://www.w3.org/XML/1998/namespace",this.prefixes.xsd="http://www.w3.org/2001/XMLSchema#",this.prefixes.sd="http://www.w3.org/ns/sparql-service-description#",this.prefixes.org="http://www.w3.org/ns/org#",this.prefixes.gldp="http://www.w3.org/ns/people#",this.prefixes.cnt="http://www.w3.org/2008/content#",this.prefixes.dcat="http://www.w3.org/ns/dcat#",this.prefixes.earl="http://www.w3.org/ns/earl#",this.prefixes.ht="http://www.w3.org/2006/http#",this.prefixes.ptr="http://www.w3.org/2009/pointers#",this.prefixes.cc="http://creativecommons.org/ns#",this.prefixes.ctag="http://commontag.org/ns#",this.prefixes.dc="http://purl.org/dc/terms/",this.prefixes.dcterms="http://purl.org/dc/terms/",this.prefixes.foaf="http://xmlns.com/foaf/0.1/",this.prefixes.gr="http://purl.org/goodrelations/v1#",this.prefixes.ical="http://www.w3.org/2002/12/cal/icaltzd#",this.prefixes.og="http://ogp.me/ns#",this.prefixes.rev="http://purl.org/stuff/rev#",this.prefixes.sioc="http://rdfs.org/sioc/ns#",this.prefixes.v="http://rdf.data-vocabulary.org/#",this.prefixes.vcard="http://www.w3.org/2006/vcard/ns#",this.prefixes.schema="http://schema.org/",this.terms.describedby="http://www.w3.org/2007/05/powder-s#describedby",this.terms.license="http://www.w3.org/1999/xhtml/vocab#license",this.terms.role="http://www.w3.org/1999/xhtml/vocab#role",Object.defineProperty(this,"tripleCount",{enumerable:!0,configurable:!1,get:function(){var e=0;for(var t in this.subjects){var r=this.subjects[t];for(var s in r.predicates)e+=r.predicates[s].objects.length}return e}})}return _createClass(e,[{key:"newBlankNode",value:function(){return"_:"+ ++this.blankNodeCounter}},{key:"expand",value:function(e){return this.curieParser.parse(e,!0)}},{key:"shorten",value:function(e,t){for(prefix in this.prefixes){var r=this.prefixes[prefix];if(0==e.indexOf(r))return t&&(t[prefix]=r),prefix+":"+e.substring(r.length)}return null}},{key:"add",value:function(e,t,r,s){if(e&&t&&r){e=this.expand(e),t=this.expand(t);var i=this.subjects[e];i||(i=new RDFaSubject(this,e),this.subjects[e]=i),s&&s.origin&&i.origins.push(s.origin),"http://www.w3.org/1999/02/22-rdf-syntax-ns#type"==t&&i.types.push(r);var a=i.predicates[t];a||(a=new RDFaPredicate(t),i.predicates[t]=a),"string"==typeof r?a.objects.push({type:RDFaProcessor.PlainLiteralURI,value:r}):a.objects.push({type:r.type?this.expand(r.type):RDFaProcessor.PlainLiteralURI,value:r.value?r.value:"",origin:r.origin,language:r.language})}}},{key:"addCollection",value:function(e,t,r,s){if(e&&t&&r){for(var i=e,a=t,n=0;n<r.length;n++){var o={type:s&&s.type?s.type:"rdf:PlainLiteral"};s&&s.language&&(o.language=s.language),s&&s.datatype&&(o.datatype=s.datatype),"object"==_typeof(r[n])?(o.value=r[n].value?r[n].value:"",r[n].type&&(o.type=r[n].type),r[n].language&&(o.language=r[n].language),r[n].datatype&&(o.datatype=r[n].datatype)):o.value=r[n];var h=this.newBlankNode();this.add(i,a,{type:"rdf:object",value:h}),this.add(h,"rdf:first",o),i=h,a="http://www.w3.org/1999/02/22-rdf-syntax-ns#rest"}this.add(i,a,{type:"rdf:object",value:"http://www.w3.org/1999/02/22-rdf-syntax-ns#nil"})}}},{key:"remove",value:function(e,t){if(!e)return void(this.subjects={});e=this.expand(e);var r=this.subjects[r];if(r){if(!t)return void delete this.subjects[e];t=this.expand(t),delete r.predicates[t]}}}]),e}(),RDFaSubject=exports.RDFaSubject=function(){function e(t,r){_classCallCheck(this,e),this.graph=t,this.subject=r,this.id=r,this.predicates={},this.origins=[],this.types=[]}return _createClass(e,[{key:"toString",value:function(e){var t=null;"_:"==this.subject.substring(0,2)?t=e&&e.filterBlankNode?e.filterBlankNode(this.subject):this.subject:e&&e.shorten?(t=this.graph.shorten(this.subject,e.prefixesUsed))||(t="<"+this.subject+">"):t="<"+this.subject+">";var r=!0;for(var s in this.predicates)r?r=!1:t+=";\n",t+=" "+this.predicates[s].toString(e);return t+=" ."}},{key:"toObject",value:function(){var e={subject:this.subject,predicates:{}};for(var t in this.predicates){var r=this.predicates[t],s={predicate:t,objects:[]};e.predicates[t]=s;for(var i=0;i<r.objects.length;i++){var a=r.objects[i];if(a.type==RDFaProcessor.XMLLiteralURI){for(var n=new XMLSerializer,o="",h=0;h<a.value.length;h++)a.value[h].nodeType==_node2.default.ELEMENT_NODE?o+=n.serializeToString(a.value[h]):a.value[h].nodeType==_node2.default.TEXT_NODE&&(o+=a.value[h].nodeValue);s.objects.push({type:a.type,value:o,language:a.language})}else if(a.type==RDFaProcessor.HTMLLiteralURI){var o=0==a.value.length?"":a.value[0].parentNode.innerHTML;s.objects.push({type:a.type,value:o,language:a.language})}else s.objects.push({type:a.type,value:a.value,language:a.language})}}return e}},{key:"getValues",value:function(){for(var e=[],t=0;t<arguments.length;t++){var r=this.graph.curieParser.parse(arguments[t],!0),s=this.predicates[r];if(s)for(var i=0;i<s.objects.length;i++)e.push(s.objects[i].value)}return e}}]),e}(),RDFaPredicate=exports.RDFaPredicate=function(){function e(t){_classCallCheck(this,e),this.id=t,this.predicate=t,this.objects=[]}return _createClass(e,[{key:"toString",value:function(t){var r=null;t&&t.shorten&&t.graph?(r=t.graph.shorten(this.predicate,t.prefixesUsed))||(r="<"+this.predicate+">"):r="<"+this.predicate+">",r+=" ";for(var s=0;s<this.objects.length;s++)if(s>0&&(r+=", "),"http://www.w3.org/1999/02/22-rdf-syntax-ns#object"==this.objects[s].type)"_:"==this.objects[s].value.substring(0,2)?t&&t.filterBlankNode?r+=t.filterBlankNode(this.objects[s].value):r+=this.objects[s].value:t&&t.shorten&&t.graph?(u=t.graph.shorten(this.objects[s].value,t.prefixesUsed),u?r+=u:r+="<"+this.objects[s].value+">"):r+="<"+this.objects[s].value+">";else if("http://www.w3.org/2001/XMLSchema#integer"==this.objects[s].type||"http://www.w3.org/2001/XMLSchema#decimal"==this.objects[s].type||"http://www.w3.org/2001/XMLSchema#double"==this.objects[s].type||"http://www.w3.org/2001/XMLSchema#boolean"==this.objects[s].type)r+=this.objects[s].value;else if("http://www.w3.org/1999/02/22-rdf-syntax-ns#XMLLiteral"==this.objects[s].type){for(var i=new XMLSerializer,a="",n=0;n<this.objects[s].value.length;n++)if(this.objects[s].value[n].nodeType==_node2.default.ELEMENT_NODE){var o=e.getPrefixMap(this.objects[s].value[n]),h=[];for(var p in o)h.push(p);h.sort();for(var l=this.objects[s].value[n].cloneNode(!0),c=0;c<h.length;c++)l.setAttributeNS("http://www.w3.org/2000/xmlns/",0==h[c].length?"xmlns":"xmlns:"+h[c],o[h[c]]);a+=i.serializeToString(l)}else this.objects[s].value[n].nodeType==_node2.default.TEXT_NODE&&(a+=this.objects[s].value[n].nodeValue);r+='"""'+a.replace(/"""/g,'\\"\\"\\"')+'"""^^<http://www.w3.org/1999/02/22-rdf-syntax-ns#XMLLiteral>'}else if("http://www.w3.org/1999/02/22-rdf-syntax-ns#HTML"==this.objects[s].type)0==this.objects[s].value.length?r+='""""""^^<http://www.w3.org/1999/02/22-rdf-syntax-ns#HTML>':r+='"""'+this.objects[s].value[0].parentNode.innerHTML.replace(/"""/g,'\\"\\"\\"')+'"""^^<http://www.w3.org/1999/02/22-rdf-syntax-ns#HTML>';else{var f=this.objects[s].value.toString();f.indexOf("\n")>=0||f.indexOf("\r")>=0?r+='"""'+f.replace(/"""/g,'\\"\\"\\"')+'"""':r+='"'+f.replace(/"/g,'\\"')+'"',"http://www.w3.org/1999/02/22-rdf-syntax-ns#PlainLiteral"!=this.objects[s].type?r+="^^<"+this.objects[s].type+">":this.objects[s].language&&(r+="@"+this.objects[s].language)}return r}}]),e}();RDFaPredicate.getPrefixMap=function(e){for(var t={};e.attributes;){for(var r=0;r<e.attributes.length;r++)if("http://www.w3.org/2000/xmlns/"==e.attributes[r].namespaceURI){var s=e.attributes[r].localName;"xmlns"==e.attributes[r].localName&&(s=""),s in t||(t[s]=e.attributes[r].nodeValue)}e=e.parentNode}return t};
},{"./node":15}],17:[function(require,module,exports){
"use strict";function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _possibleConstructorReturn(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function _inherits(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(exports,"__esModule",{value:!0});var _createClass=function(){function e(e,t){for(var r=0;r<t.length;r++){var a=t[r];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}return function(t,r,a){return r&&e(t.prototype,r),a&&e(t,a),t}}(),_uriResolver=require("./uri-resolver"),_uriResolver2=_interopRequireDefault(_uriResolver),_node=require("./node"),_node2=_interopRequireDefault(_node),RDFaProcessor=function(e){function t(e){_classCallCheck(this,t);var r=_possibleConstructorReturn(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return r.target=e||{graph:{subjects:{},prefixes:{},terms:{}}},r.theOne="_:"+(new Date).getTime(),r.language=null,r.vocabulary=null,r.blankCounter=0,r.langAttributes=[{namespaceURI:"http://www.w3.org/XML/1998/namespace",localName:"lang"}],r.inXHTMLMode=!1,r.absURIRE=/[\w\_\-]+:\S+/,r.finishedHandlers=[],r.init(),r}return _inherits(t,e),_createClass(t,[{key:"newBlankNode",value:function(){return"_:"+ ++this.blankCounter}},{key:"tokenize",value:function(e){return t.trim(e).split(/\s+/)}},{key:"parseSafeCURIEOrCURIEOrURI",value:function(e,r,a){return e=t.trim(e),"["==e.charAt(0)&&"]"==e.charAt(e.length-1)?(e=e.substring(1,e.length-1),e=e.trim(e),0==e.length?null:"_:"==e?this.theOne:this.parseCURIE(e,r,a)):this.parseCURIEOrURI(e,r,a)}},{key:"parseCURIE",value:function(e,r,a){var s=e.indexOf(":");if(s>=0){var n=e.substring(0,s);if(""==n){var i=r[""];return i?i+e.substring(s+1):null}if("_"==n)return"_:"+e.substring(s+1);if(t.NCNAME.test(n)){var i=r[n];if(i)return i+e.substring(s+1)}}return null}},{key:"parseCURIEOrURI",value:function(e,t,r){var a=this.parseCURIE(e,t,r);return a||this.resolveAndNormalize(r,e)}},{key:"parsePredicate",value:function(e,t,r,a,s,n){if(""==e)return null;var i=this.parseTermOrCURIEOrAbsURI(e,t,n?null:r,a,s);return i&&0==i.indexOf("_:")?null:i}},{key:"parseTermOrCURIEOrURI",value:function(e,r,a,s,n){e=t.trim(e);var i=this.parseCURIE(e,s,n);if(i)return i;var o=a[e];return o||((o=a[e.toLowerCase()])?o:r&&!this.absURIRE.exec(e)?r+e:this.resolveAndNormalize(n,e))}},{key:"parseTermOrCURIEOrAbsURI",value:function(e,r,a,s,n){e=t.trim(e);var i=this.parseCURIE(e,s,n);if(i)return i;if(a){if(r&&!this.absURIRE.exec(e))return r+e;var o=a[e];if(o)return o;if(o=a[e.toLowerCase()])return o}return this.absURIRE.exec(e)?this.resolveAndNormalize(n,e):null}},{key:"resolveAndNormalize",value:function(e,t){var r=e.resolve(t),a=this.parseURI(r);return a.normalize(),a.spec}},{key:"parsePrefixMappings",value:function(e,t){for(var r=this.tokenize(e),a=null,s=0;s<r.length;s++)":"==r[s][r[s].length-1]?a=r[s].substring(0,r[s].length-1):a&&(t[a]=this.target.baseURI?this.target.baseURI.resolve(r[s]):r[s],a=null)}},{key:"copyMappings",value:function(e){var t={};for(var r in e)t[r]=e[r];return t}},{key:"ancestorPath",value:function(e){for(var t="";e&&e.nodeType!=_node2.default.DOCUMENT_NODE;)t="/"+e.localName+t,e=e.parentNode;return t}},{key:"setContext",value:function(e){"html"==e.localName&&"XHTML+RDFa 1.1"==e.getAttribute("version")?this.setXHTMLContext():"html"==e.localName||"http://www.w3.org/1999/xhtml"==e.namespaceURI?e.ownerDocument.doctype?"-//W3C//DTD XHTML+RDFa 1.0//EN"==e.ownerDocument.doctype.publicId&&"http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd"==e.ownerDocument.doctype.systemId?(console.log("WARNING: RDF 1.0 is not supported. Defaulting to HTML5 mode."),this.setHTMLContext()):"-//W3C//DTD XHTML+RDFa 1.1//EN"==e.ownerDocument.doctype.publicId&&"http://www.w3.org/MarkUp/DTD/xhtml-rdfa-2.dtd"==e.ownerDocument.doctype.systemId?this.setXHTMLContext():this.setHTMLContext():this.setHTMLContext():this.setXMLContext()}},{key:"setInitialContext",value:function(){this.vocabulary=null,this.langAttributes=[{namespaceURI:"http://www.w3.org/XML/1998/namespace",localName:"lang"}]}},{key:"setXMLContext",value:function(){this.setInitialContext(),this.inXHTMLMode=!1,this.inHTMLMode=!1}},{key:"setHTMLContext",value:function(){this.setInitialContext(),this.langAttributes=[{namespaceURI:"http://www.w3.org/XML/1998/namespace",localName:"lang"},{namespaceURI:null,localName:"lang"}],this.inXHTMLMode=!1,this.inHTMLMode=!0}},{key:"setXHTMLContext",value:function(){this.setInitialContext(),this.inXHTMLMode=!0,this.inHTMLMode=!1,this.langAttributes=[{namespaceURI:"http://www.w3.org/XML/1998/namespace",localName:"lang"},{namespaceURI:null,localName:"lang"}],this.target.graph.terms.alternate="http://www.w3.org/1999/xhtml/vocab#alternate",this.target.graph.terms.appendix="http://www.w3.org/1999/xhtml/vocab#appendix",this.target.graph.terms.bookmark="http://www.w3.org/1999/xhtml/vocab#bookmark",this.target.graph.terms.cite="http://www.w3.org/1999/xhtml/vocab#cite",this.target.graph.terms.chapter="http://www.w3.org/1999/xhtml/vocab#chapter",this.target.graph.terms.contents="http://www.w3.org/1999/xhtml/vocab#contents",this.target.graph.terms.copyright="http://www.w3.org/1999/xhtml/vocab#copyright",this.target.graph.terms.first="http://www.w3.org/1999/xhtml/vocab#first",this.target.graph.terms.glossary="http://www.w3.org/1999/xhtml/vocab#glossary",this.target.graph.terms.help="http://www.w3.org/1999/xhtml/vocab#help",this.target.graph.terms.icon="http://www.w3.org/1999/xhtml/vocab#icon",this.target.graph.terms.index="http://www.w3.org/1999/xhtml/vocab#index",this.target.graph.terms.last="http://www.w3.org/1999/xhtml/vocab#last",this.target.graph.terms.license="http://www.w3.org/1999/xhtml/vocab#license",this.target.graph.terms.meta="http://www.w3.org/1999/xhtml/vocab#meta",this.target.graph.terms.next="http://www.w3.org/1999/xhtml/vocab#next",this.target.graph.terms.prev="http://www.w3.org/1999/xhtml/vocab#prev",this.target.graph.terms.previous="http://www.w3.org/1999/xhtml/vocab#previous",this.target.graph.terms.section="http://www.w3.org/1999/xhtml/vocab#section",this.target.graph.terms.stylesheet="http://www.w3.org/1999/xhtml/vocab#stylesheet",this.target.graph.terms.subsection="http://www.w3.org/1999/xhtml/vocab#subsection",this.target.graph.terms.start="http://www.w3.org/1999/xhtml/vocab#start",this.target.graph.terms.top="http://www.w3.org/1999/xhtml/vocab#top",this.target.graph.terms.up="http://www.w3.org/1999/xhtml/vocab#up",this.target.graph.terms.p3pv1="http://www.w3.org/1999/xhtml/vocab#p3pv1",this.target.graph.terms.related="http://www.w3.org/1999/xhtml/vocab#related",this.target.graph.terms.role="http://www.w3.org/1999/xhtml/vocab#role",this.target.graph.terms.transformation="http://www.w3.org/1999/xhtml/vocab#transformation"}},{key:"init",value:function(){}},{key:"newSubjectOrigin",value:function(e,t){}},{key:"addTriple",value:function(e,t,r,a){}},{key:"process",value:function(e,r){e.nodeType==_node2.default.DOCUMENT_NODE?(e=e.documentElement,this.setContext(e)):e.parentNode.nodeType==_node2.default.DOCUMENT_NODE&&this.setContext(e);var a=[],s=function(e){var t=e.indexOf("#");return t>=0&&(e=e.substring(0,t)),r&&r.baseURIMap&&(e=r.baseURIMap(e)),e};for(a.push({current:e,context:this.push(null,s(e.baseURI))});a.length>0;){var n=a.shift();if(n.parent){if(n.context.parent&&n.context.parent.listMapping==n.listMapping)continue;for(var i in n.listMapping){var o=n.listMapping[i];if(0!=o.length){for(var l=[],p=0;p<o.length;p++)l.push(this.newBlankNode());for(var p=0;p<l.length;p++)this.addTriple(n.parent,l[p],"http://www.w3.org/1999/02/22-rdf-syntax-ns#first",o[p]),this.addTriple(n.parent,l[p],"http://www.w3.org/1999/02/22-rdf-syntax-ns#rest",{type:t.objectURI,value:p+1<l.length?l[p+1]:"http://www.w3.org/1999/02/22-rdf-syntax-ns#nil"});this.addTriple(n.parent,n.subject,i,{type:t.objectURI,value:l[0]})}else this.addTriple(n.parent,n.subject,i,{type:t.objectURI,value:"http://www.w3.org/1999/02/22-rdf-syntax-ns#nil"})}}else{var h,u=n.current,c=n.context,w=!1,g=null,d=null,v=null,b=c.prefixes,m=!1,f=[],R=c.listMapping,I=!c.parent,U=c.language,y=c.vocabulary;if(u.baseURI)if("about:blank"===u.baseURI){if(!this.target.baseURI)throw new Error("node.baseURI is about:blank a valid URL must be provided with the baseURI option. If you use JSDOM call it with an `url` parameter or, set the baseURI option of this library");h=this.target.baseURI}else h=this.parseURI(s(u.baseURI));else{if(!this.target.baseURI)throw new Error("node.baseURI was null as baseURI must be specified as an option");h=this.target.baseURI}u.item=null;var M=u.getAttributeNode("vocab");if(M){var x=t.trim(M.value);if(x.length>0){y=x;var T=h.spec;this.addTriple(u,T,"http://www.w3.org/ns/rdfa#usesVocabulary",{type:t.objectURI,value:y})}else y=this.vocabulary}for(var p=0;p<u.attributes.length;p++){var N=u.attributes[p];if("x"==N.name.charAt(0)&&0==N.name.indexOf("xmlns:")){m||(b=this.copyMappings(b),m=!0);var O=N.name.substring(6),C=t.trim(N.value);b[O]=this.target.baseURI?this.target.baseURI.resolve(C):C}}var L=u.getAttributeNode("prefix");L&&(m||(b=this.copyMappings(b),m=!0),this.parsePrefixMappings(L.value,b));for(var E=null,p=0;!E&&p<this.langAttributes.length;p++)E=u.getAttributeNodeNS(this.langAttributes[p].namespaceURI,this.langAttributes[p].localName);if(E){var x=t.trim(E.value);U=x.length>0?x:null}var D=u.getAttributeNode("rel"),_=u.getAttributeNode("rev"),j=u.getAttributeNode("typeof"),k=u.getAttributeNode("property"),A=u.getAttributeNode("datatype"),P=this.inHTMLMode?u.getAttributeNode("datetime"):null,H=u.getAttributeNode("content"),X=u.getAttributeNode("about"),S=u.getAttributeNode("src"),F=u.getAttributeNode("resource"),z=u.getAttributeNode("href"),B=u.getAttributeNode("inlist"),q=[];if(D)for(var Z=this.tokenize(D.value),p=0;p<Z.length;p++){var i=this.parsePredicate(Z[p],y,c.terms,b,h,this.inHTMLMode&&null!=k);i&&q.push(i)}var W=[];if(_)for(var Z=this.tokenize(_.value),p=0;p<Z.length;p++){var i=this.parsePredicate(Z[p],y,c.terms,b,h,this.inHTMLMode&&null!=k);i&&W.push(i)}!this.inHTMLMode||null==D&&null==_||null==k||(0==q.length&&(D=null),0==W.length&&(_=null)),D||_?(X&&(g=this.parseSafeCURIEOrCURIEOrURI(X.value,b,h)),j&&(v=g),g||(u.parentNode.nodeType==_node2.default.DOCUMENT_NODE?g=s(u.baseURI):c.parentObject&&(g=s(u.parentNode.baseURI)==c.parentObject?s(u.baseURI):c.parentObject)),F&&(d=this.parseSafeCURIEOrCURIEOrURI(F.value,b,h)),d||(z?d=this.resolveAndNormalize(h,encodeURI(z.value)):S?d=this.resolveAndNormalize(h,encodeURI(S.value)):!j||X||this.inXHTMLMode&&("head"==u.localName||"body"==u.localName)||(d=this.newBlankNode())),!j||X||!this.inXHTMLMode||"head"!=u.localName&&"body"!=u.localName?j&&!X&&(v=d):v=g):!k||H||A?(X&&(g=this.parseSafeCURIEOrCURIEOrURI(X.value,b,h)),!g&&F&&(g=this.parseSafeCURIEOrCURIEOrURI(F.value,b,h)),!g&&z&&(g=this.resolveAndNormalize(h,encodeURI(z.value))),!g&&S&&(g=this.resolveAndNormalize(h,encodeURI(S.value))),g||(u.parentNode.nodeType==_node2.default.DOCUMENT_NODE?g=s(u.baseURI):!this.inXHTMLMode&&!this.inHTMLMode||"head"!=u.localName&&"body"!=u.localName?j?g=this.newBlankNode():c.parentObject&&(g=s(u.parentNode.baseURI)==c.parentObject?s(u.baseURI):c.parentObject,k||(w=!0)):g=s(u.parentNode.baseURI)==c.parentObject?s(u.baseURI):c.parentObject),j&&(v=g)):(X&&(g=this.parseSafeCURIEOrCURIEOrURI(X.value,b,h),j&&(v=g)),g||u.parentNode.nodeType!=_node2.default.DOCUMENT_NODE?!g&&c.parentObject&&(g=s(u.parentNode.baseURI)==c.parentObject?s(u.baseURI):c.parentObject):(g=s(u.baseURI),j&&(v=g)),j&&!v&&(F&&(v=this.parseSafeCURIEOrCURIEOrURI(F.value,b,h)),!v&&z&&(v=this.resolveAndNormalize(h,encodeURI(z.value))),!v&&S&&(v=this.resolveAndNormalize(h,encodeURI(S.value))),v||!this.inXHTMLMode&&!this.inHTMLMode||"head"!=u.localName&&"body"!=u.localName||(v=g),v||(v=this.newBlankNode()),d=v));if(g&&(X||F||v)){var Y=g;j&&!X&&!F&&d&&(Y=d),this.newSubjectOrigin(u,Y)}if(v)for(var Z=this.tokenize(j.value),p=0;p<Z.length;p++){var $=this.parseTermOrCURIEOrAbsURI(Z[p],y,c.terms,b,h);$&&this.addTriple(u,v,t.typeURI,{type:t.objectURI,value:$})}if(g&&g!=c.parentObject&&(R={},I=!0),d){if(D&&B)for(var p=0;p<q.length;p++){var o=R[q[p]];o||(o=[],R[q[p]]=o),o.push({type:t.objectURI,value:d})}else if(D)for(var p=0;p<q.length;p++)this.addTriple(u,g,q[p],{type:t.objectURI,value:d});if(_)for(var p=0;p<W.length;p++)this.addTriple(u,d,W[p],{type:t.objectURI,value:g})}else{if(g&&!d&&(D||_)&&(d=this.newBlankNode()),D&&B)for(var p=0;p<q.length;p++){var o=R[q[p]];o||(o=[],R[i]=o),f.push({predicate:q[p],list:o})}else if(D)for(var p=0;p<q.length;p++)f.push({predicate:q[p],forward:!0});if(_)for(var p=0;p<W.length;p++)f.push({predicate:W[p],forward:!1})}if(k){var G=null,J=null;A?(G=""==A.value?t.PlainLiteralURI:this.parseTermOrCURIEOrAbsURI(A.value,y,c.terms,b,h),J=P&&!H?P.value:G==t.XMLLiteralURI||G==t.HTMLLiteralURI?null:H?H.value:u.textContent):H?(G=t.PlainLiteralURI,J=H.value):P?(J=P.value,(G=t.deriveDateTimeType(J))||(G=t.PlainLiteralURI)):D||_||(F&&(J=this.parseSafeCURIEOrCURIEOrURI(F.value,b,h)),!J&&z?J=this.resolveAndNormalize(h,encodeURI(z.value)):!J&&S&&(J=this.resolveAndNormalize(h,encodeURI(S.value))),J&&(G=t.objectURI)),G||(j&&!X?(G=t.objectURI,J=v):(J=u.textContent,this.inHTMLMode&&"time"==u.localName&&(G=t.deriveDateTimeType(J)),G||(G=t.PlainLiteralURI)));for(var Z=this.tokenize(k.value),p=0;p<Z.length;p++){var i=this.parsePredicate(Z[p],y,c.terms,b,h);if(i)if(B){var o=R[i];o||(o=[],R[i]=o),o.push(G==t.XMLLiteralURI||G==t.HTMLLiteralURI?{type:G,value:u.childNodes}:{type:G||t.PlainLiteralURI,value:J,language:U})}else G==t.XMLLiteralURI||G==t.HTMLLiteralURI?this.addTriple(u,g,i,{type:G,value:u.childNodes}):this.addTriple(u,g,i,{type:G||t.PlainLiteralURI,value:J,language:U})}}if(g&&!w)for(var p=0;p<c.incomplete.length;p++)c.incomplete[p].list?c.incomplete[p].list.push({type:t.objectURI,value:g}):c.incomplete[p].forward?this.addTriple(u,c.subject,c.incomplete[p].predicate,{type:t.objectURI,value:g}):this.addTriple(u,g,c.incomplete[p].predicate,{type:t.objectURI,value:c.subject});var V=null,K=g;w?(V=this.push(c,c.subject),V.parentObject=s(u.parentNode.baseURI)==c.parentObject?s(u.baseURI):c.parentObject,V.incomplete=c.incomplete,V.language=U,V.prefixes=b,V.vocabulary=y):(V=this.push(c,g),V.parentObject=d||(g||c.subject),V.prefixes=b,V.incomplete=f,d&&(K=d,R={},I=!0),V.listMapping=R,V.language=U,V.vocabulary=y),I&&a.unshift({parent:u,context:c,subject:K,listMapping:R});for(var Q=u.lastChild;Q;Q=Q.previousSibling)Q.nodeType==_node2.default.ELEMENT_NODE&&a.unshift({current:Q,context:V})}}this.inHTMLMode&&this.copyProperties();for(var p=0;p<this.finishedHandlers.length;p++)this.finishedHandlers[p](e)}},{key:"copyProperties",value:function(){}},{key:"push",value:function(e,t){return{parent:e,subject:t||(e?e.subject:null),parentObject:null,incomplete:[],listMapping:e?e.listMapping:{},language:e?e.language:this.language,prefixes:e?e.prefixes:this.target.graph.prefixes,terms:e?e.terms:this.target.graph.terms,vocabulary:e?e.vocabulary:this.vocabulary}}}]),t}(_uriResolver2.default);exports.default=RDFaProcessor,RDFaProcessor.XMLLiteralURI="http://www.w3.org/1999/02/22-rdf-syntax-ns#XMLLiteral",RDFaProcessor.HTMLLiteralURI="http://www.w3.org/1999/02/22-rdf-syntax-ns#HTML",RDFaProcessor.PlainLiteralURI="http://www.w3.org/1999/02/22-rdf-syntax-ns#PlainLiteral",RDFaProcessor.objectURI="http://www.w3.org/1999/02/22-rdf-syntax-ns#object",RDFaProcessor.typeURI="http://www.w3.org/1999/02/22-rdf-syntax-ns#type",RDFaProcessor.nameChar="[-A-Z_a-zÀ-ÖØ-öø-˿Ͱ-ͽͿ-῿‌-‍⁰-↏Ⰰ-⿯、-퟿豈-﷏ﷰ-�က0-F.0-9·̀-ͯ‿-⁀]",RDFaProcessor.nameStartChar="[A-Za-zÀ-ÖØ-öø-ÿĀ-ıĴ-ľŁ-ňŊ-žƀ-ǃǍ-ǰǴ-ǵǺ-ȗɐ-ʨʻ-ˁΆΈ-ΊΌΎ-ΡΣ-ώϐ-ϖϚϜϞϠϢ-ϳЁ-ЌЎ-яё-ќў-ҁҐ-ӄӇ-ӈӋ-ӌӐ-ӫӮ-ӵӸ-ӹԱ-Ֆՙա-ֆא-תװ-ײء-غف-يٱ-ڷں-ھۀ-ێې-ۓەۥ-ۦअ-हऽक़-ॡঅ-ঌএ-ঐও-নপ-রলশ-হড়-ঢ়য়-ৡৰ-ৱਅ-ਊਏ-ਐਓ-ਨਪ-ਰਲ-ਲ਼ਵ-ਸ਼ਸ-ਹਖ਼-ੜਫ਼ੲ-ੴઅ-ઋઍએ-ઑઓ-નપ-રલ-ળવ-હઽૠଅ-ଌଏ-ଐଓ-ନପ-ରଲ-ଳଶ-ହଽଡ଼-ଢ଼ୟ-ୡஅ-ஊஎ-ஐஒ-கங-சஜஞ-டண-தந-பம-வஷ-ஹఅ-ఌఎ-ఐఒ-నప-ళవ-హౠ-ౡಅ-ಌಎ-ಐಒ-ನಪ-ಳವ-ಹೞೠ-ೡഅ-ഌഎ-ഐഒ-നപ-ഹൠ-ൡก-ฮะา-ำเ-ๅກ-ຂຄງ-ຈຊຍດ-ທນ-ຟມ-ຣລວສ-ຫອ-ຮະາ-ຳຽເ-ໄཀ-ཇཉ-ཀྵႠ-Ⴥა-ჶᄀᄂ-ᄃᄅ-ᄇᄉᄋ-ᄌᄎ-ᄒᄼᄾᅀᅌᅎᅐᅔ-ᅕᅙᅟ-ᅡᅣᅥᅧᅩᅭ-ᅮᅲ-ᅳᅵᆞᆨᆫᆮ-ᆯᆷ-ᆸᆺᆼ-ᇂᇫᇰᇹḀ-ẛẠ-ỹἀ-ἕἘ-Ἕἠ-ὅὈ-Ὅὐ-ὗὙὛὝὟ-ώᾀ-ᾴᾶ-ᾼιῂ-ῄῆ-ῌῐ-ΐῖ-Ίῠ-Ῥῲ-ῴῶ-ῼΩK-Å℮ↀ-ↂぁ-ゔァ-ヺㄅ-ㄬ가-힣一-龥〇〡-〩_]",RDFaProcessor.NCNAME=new RegExp("^"+RDFaProcessor.nameStartChar+RDFaProcessor.nameChar+"*$"),RDFaProcessor.trim=function(e){return e.replace(/^\s\s*/,"").replace(/\s\s*$/,"")},RDFaProcessor.dateTimeTypes=[{pattern:/-?P(?:[0-9]+Y)?(?:[0-9]+M)?(?:[0-9]+D)?(?:T(?:[0-9]+H)?(?:[0-9]+M)?(?:[0-9]+(?:\.[0-9]+)?S)?)?/,type:"http://www.w3.org/2001/XMLSchema#duration"},{pattern:/-?(?:[1-9][0-9][0-9][0-9]|0[1-9][0-9][0-9]|00[1-9][0-9]|000[1-9])-[0-9][0-9]-[0-9][0-9]T(?:[0-1][0-9]|2[0-4]):[0-5][0-9]:[0-5][0-9](?:\.[0-9]+)?(?:Z|[+\-][0-9][0-9]:[0-9][0-9])?/,type:"http://www.w3.org/2001/XMLSchema#dateTime"},{pattern:/-?(?:[1-9][0-9][0-9][0-9]|0[1-9][0-9][0-9]|00[1-9][0-9]|000[1-9])-[0-9][0-9]-[0-9][0-9](?:Z|[+\-][0-9][0-9]:[0-9][0-9])?/,type:"http://www.w3.org/2001/XMLSchema#date"},{pattern:/(?:[0-1][0-9]|2[0-4]):[0-5][0-9]:[0-5][0-9](?:\.[0-9]+)?(?:Z|[+\-][0-9][0-9]:[0-9][0-9])?/,type:"http://www.w3.org/2001/XMLSchema#time"},{pattern:/-?(?:[1-9][0-9][0-9][0-9]|0[1-9][0-9][0-9]|00[1-9][0-9]|000[1-9])-[0-9][0-9]/,type:"http://www.w3.org/2001/XMLSchema#gYearMonth"},{pattern:/-?[1-9][0-9][0-9][0-9]|0[1-9][0-9][0-9]|00[1-9][0-9]|000[1-9]/,type:"http://www.w3.org/2001/XMLSchema#gYear"}],RDFaProcessor.deriveDateTimeType=function(e){for(var t=0;t<RDFaProcessor.dateTimeTypes.length;t++){var r=RDFaProcessor.dateTimeTypes[t].pattern.exec(e);if(r&&r[0].length==e.length)return RDFaProcessor.dateTimeTypes[t].type}return null},module.exports=exports.default;
},{"./node":15,"./uri-resolver":18}],18:[function(require,module,exports){
"use strict";function _classCallCheck(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(exports,"__esModule",{value:!0});var _createClass=function(){function t(t,e){for(var s=0;s<e.length;s++){var h=e[s];h.enumerable=h.enumerable||!1,h.configurable=!0,"value"in h&&(h.writable=!0),Object.defineProperty(t,h.key,h)}}return function(e,s,h){return s&&t(e.prototype,s),h&&t(e,h),e}}(),URIResolver=function(){function t(){_classCallCheck(this,t)}return _createClass(t,[{key:"parseURI",value:function(e){var s=t.SCHEME.exec(e);if(!s)throw new Error("Bad URI value, no scheme: "+e);var h={spec:e};return h.scheme=s[0].substring(0,s[0].length-1),h.schemeSpecificPart=h.spec.substring(s[0].length),"/"==h.schemeSpecificPart.charAt(0)&&"/"==h.schemeSpecificPart.charAt(1)?this.parseGeneric(h):h.isGeneric=!1,h.normalize=function(){if(this.isGeneric&&0!=this.segments.length){if(this.path.length>1&&"/."==this.path.substring(this.path.length-2))return this.path=this.path.substring(0,this.path.length-1),this.segments.splice(this.segments.length-1,1),this.schemeSpecificPart="//"+this.authority+this.path,void 0!==this.query&&(this.schemeSpecificPart+="?"+this.query),void 0!==this.fragment&&(this.schemeSpecificPart+="#"+this.fragment),void(this.spec=this.scheme+":"+this.schemeSpecificPart);var t=this.path.charAt(this.path.length-1);"/"!=t&&(t="");for(var e=0;e<this.segments.length;e++)e>0&&".."==this.segments[e]&&(this.segments.splice(e-1,2),e-=2),"."==this.segments[e]&&(this.segments.splice(e,1),e--);this.path=0==this.segments.length?"/":"/"+this.segments.join("/")+t,this.schemeSpecificPart="//"+this.authority+this.path,void 0!==this.query&&(this.schemeSpecificPart+="?"+this.query),void 0!==this.fragment&&(this.schemeSpecificPart+="#"+this.fragment),this.spec=this.scheme+":"+this.schemeSpecificPart}},h.resolve=function(e){if(!e)return this.spec;if("#"==e.charAt(0)){var s=this.spec.lastIndexOf("#");return s<0?this.spec+e:this.spec.substring(0,s)+e}if(!this.isGeneric)throw new Error("Cannot resolve uri against non-generic URI: "+this.spec);e.indexOf(":");if("/"==e.charAt(0))return this.scheme+"://"+this.authority+e;if("."==e.charAt(0)&&"/"==e.charAt(1)){if("/"==this.path.charAt(this.path.length-1))return this.scheme+"://"+this.authority+this.path+e.substring(2);var h=this.path.lastIndexOf("/");return this.scheme+"://"+this.authority+this.path.substring(0,h)+e.substring(1)}if(t.SCHEME.test(e))return e;if("?"==e.charAt(0))return this.scheme+"://"+this.authority+this.path+e;if("/"==this.path.charAt(this.path.length-1))return this.scheme+"://"+this.authority+this.path+e;var h=this.path.lastIndexOf("/");return this.scheme+"://"+this.authority+this.path.substring(0,h+1)+e},h.relativeTo=function(t){if(t.scheme!=this.scheme)return this.spec;if(!this.isGeneric)throw new Error("A non generic URI cannot be made relative: "+this.spec);if(!t.isGeneric)throw new Error("Cannot make a relative URI against a non-generic URI: "+t.spec);if(t.authority!=this.authority)return this.spec;for(var e=0;e<this.segments.length&&e<t.segments.length;e++)if(this.segments[e]!=t.segments[e]){for(var s="/"==t.path.charAt(t.path.length-1)?0:-1,h="",i=e;i<t.segments.length+s;i++)h+="../";for(var i=e;i<this.segments.length;i++)h+=this.segments[i],i+1<this.segments.length&&(h+="/");return"/"==this.path.charAt(this.path.length-1)&&(h+="/"),h}if(this.segments.length==t.segments.length)return this.hash?this.hash:this.query?this.query:"";if(e<this.segments.length){for(var h="",i=e;i<this.segments.length;i++)h+=this.segments[i],i+1<this.segments.length&&(h+="/");return"/"==this.path.charAt(this.path.length-1)&&(h+="/"),h}throw new Error("Cannot calculate a relative URI for "+this.spec+" against "+t.spec)},h}},{key:"parseGeneric",value:function(t){if("/"!=t.schemeSpecificPart.charAt(0)||"/"!=t.schemeSpecificPart.charAt(1))throw new Error("Generic URI values should start with '//':"+t.spec);var e=t.schemeSpecificPart.substring(2),s=e.indexOf("/");t.authority=s<0?e:e.substring(0,s),t.path=s<0?"":e.substring(s);var h=t.path.indexOf("#");h>=0&&(t.fragment=t.path.substring(h+1),t.path=t.path.substring(0,h));var i=t.path.indexOf("?");if(i>=0&&(t.query=t.path.substring(i+1),t.path=t.path.substring(0,i)),"/"==t.path||""==t.path)t.segments=[];else{t.segments=t.path.split(/\//),t.segments.length>0&&""==t.segments[0]&&t.path.length>1&&"/"!=t.path.charAt(1)&&t.segments.shift(),t.segments.length>0&&t.path.length>0&&"/"==t.path.charAt(t.path.length-1)&&""==t.segments[t.segments.length-1]&&t.path.length>1&&"/"!=t.path.charAt(t.path.length-2)&&t.segments.pop();for(var r=0;r<t.segments.length;r++)for(var n=t.segments[r].split(/%[A-Za-z0-9][A-Za-z0-9]|[\ud800-\udfff][\ud800-\udfff]|[A-Za-z0-9\-\._~!$&'()*+,;=@:\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+/),a=0;a<n.length;a++)if(n[a].length>0)throw new Error("Unecaped character "+n[a].charAt(0)+" ("+n[a].charCodeAt(0)+") in URI "+t.spec)}t.isGeneric=!0}}]),t}();exports.default=URIResolver,URIResolver.SCHEME=/^[A-Za-z][A-Za-z0-9\+\-\.]*\:/,module.exports=exports.default;
},{}],19:[function(require,module,exports){
"function"==typeof Object.create?module.exports=function(t,e){t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}})}:module.exports=function(t,e){t.super_=e;var o=function(){};o.prototype=e.prototype,t.prototype=new o,t.prototype.constructor=t};
},{}],20:[function(require,module,exports){
function isUrl(r){return matcher.test(r)}module.exports=isUrl;var matcher=/^(?:\w+:)?\/\/([^\s\.]+\.\S{2}|localhost[\:?\d]*)\S*$/;
},{}],21:[function(require,module,exports){
module.exports=Array.isArray||function(r){return"[object Array]"==Object.prototype.toString.call(r)};
},{}],22:[function(require,module,exports){
(function (global){
!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var e;e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,e.PriorityQueue=t()}}(function(){return function t(e,i,r){function o(n,s){if(!i[n]){if(!e[n]){var h="function"==typeof require&&require;if(!s&&h)return h(n,!0);if(a)return a(n,!0);var u=new Error("Cannot find module '"+n+"'");throw u.code="MODULE_NOT_FOUND",u}var p=i[n]={exports:{}};e[n][0].call(p.exports,function(t){var i=e[n][1][t];return o(i||t)},p,p.exports,t,e,i,r)}return i[n].exports}for(var a="function"==typeof require&&require,n=0;n<r.length;n++)o(r[n]);return o}({1:[function(t,e,i){var r,o,a,n,s,h=function(t,e){function i(){this.constructor=t}for(var r in e)u.call(e,r)&&(t[r]=e[r]);return i.prototype=e.prototype,t.prototype=new i,t.__super__=e.prototype,t},u={}.hasOwnProperty;r=t("./PriorityQueue/AbstractPriorityQueue"),o=t("./PriorityQueue/ArrayStrategy"),n=t("./PriorityQueue/BinaryHeapStrategy"),a=t("./PriorityQueue/BHeapStrategy"),s=function(t){function e(t){t||(t={}),t.strategy||(t.strategy=n),t.comparator||(t.comparator=function(t,e){return(t||0)-(e||0)}),e.__super__.constructor.call(this,t)}return h(e,t),e}(r),s.ArrayStrategy=o,s.BinaryHeapStrategy=n,s.BHeapStrategy=a,e.exports=s},{"./PriorityQueue/AbstractPriorityQueue":2,"./PriorityQueue/ArrayStrategy":3,"./PriorityQueue/BHeapStrategy":4,"./PriorityQueue/BinaryHeapStrategy":5}],2:[function(t,e,i){e.exports=function(){function t(t){var e;if(null==(null!=t?t.strategy:void 0))throw"Must pass options.strategy, a strategy";if(null==(null!=t?t.comparator:void 0))throw"Must pass options.comparator, a comparator";this.priv=new t.strategy(t),this.length=(null!=t&&null!=(e=t.initialValues)?e.length:void 0)||0}return t.prototype.queue=function(t){this.length++,this.priv.queue(t)},t.prototype.dequeue=function(t){if(!this.length)throw"Empty queue";return this.length--,this.priv.dequeue()},t.prototype.peek=function(t){if(!this.length)throw"Empty queue";return this.priv.peek()},t.prototype.clear=function(){return this.length=0,this.priv.clear()},t}()},{}],3:[function(t,e,i){var r;r=function(t,e,i){var r,o,a;for(o=0,r=t.length;o<r;)a=o+r>>>1,i(t[a],e)>=0?o=a+1:r=a;return o},e.exports=function(){function t(t){var e;this.options=t,this.comparator=this.options.comparator,this.data=(null!=(e=this.options.initialValues)?e.slice(0):void 0)||[],this.data.sort(this.comparator).reverse()}return t.prototype.queue=function(t){var e;e=r(this.data,t,this.comparator),this.data.splice(e,0,t)},t.prototype.dequeue=function(){return this.data.pop()},t.prototype.peek=function(){return this.data[this.data.length-1]},t.prototype.clear=function(){this.data.length=0},t}()},{}],4:[function(t,e,i){e.exports=function(){function t(t){var e,i,r,o,a,n,s,h;for(this.comparator=(null!=t?t.comparator:void 0)||function(t,e){return t-e},this.pageSize=(null!=t?t.pageSize:void 0)||512,this.length=0,s=0;1<<s<this.pageSize;)s+=1;if(1<<s!==this.pageSize)throw"pageSize must be a power of two";for(this._shift=s,this._emptyMemoryPageTemplate=e=[],i=0,a=this.pageSize;0<=a?i<a:i>a;0<=a?++i:--i)e.push(null);if(this._memory=[],this._mask=this.pageSize-1,t.initialValues)for(n=t.initialValues,r=0,o=n.length;r<o;r++)h=n[r],this.queue(h)}return t.prototype.queue=function(t){this.length+=1,this._write(this.length,t),this._bubbleUp(this.length,t)},t.prototype.dequeue=function(){var t,e;return t=this._read(1),e=this._read(this.length),this.length-=1,this.length>0&&(this._write(1,e),this._bubbleDown(1,e)),t},t.prototype.peek=function(){return this._read(1)},t.prototype.clear=function(){this.length=0,this._memory.length=0},t.prototype._write=function(t,e){var i;for(i=t>>this._shift;i>=this._memory.length;)this._memory.push(this._emptyMemoryPageTemplate.slice(0));return this._memory[i][t&this._mask]=e},t.prototype._read=function(t){return this._memory[t>>this._shift][t&this._mask]},t.prototype._bubbleUp=function(t,e){var i,r,o,a;for(i=this.comparator;t>1&&(r=t&this._mask,t<this.pageSize||r>3?o=t&~this._mask|r>>1:r<2?(o=t-this.pageSize>>this._shift,o+=o&~(this._mask>>1),o|=this.pageSize>>1):o=t-2,a=this._read(o),!(i(a,e)<0));)this._write(o,e),this._write(t,a),t=o},t.prototype._bubbleDown=function(t,e){var i,r,o,a,n;for(n=this.comparator;t<this.length;)if(t>this._mask&&!(t&this._mask-1)?i=r=t+2:t&this.pageSize>>1?(i=(t&~this._mask)>>1,i|=t&this._mask>>1,i=i+1<<this._shift,r=i+1):(i=t+(t&this._mask),r=i+1),i!==r&&r<=this.length)if(o=this._read(i),a=this._read(r),n(o,e)<0&&n(o,a)<=0)this._write(i,e),this._write(t,o),t=i;else{if(!(n(a,e)<0))break;this._write(r,e),this._write(t,a),t=r}else{if(!(i<=this.length))break;if(o=this._read(i),!(n(o,e)<0))break;this._write(i,e),this._write(t,o),t=i}},t}()},{}],5:[function(t,e,i){e.exports=function(){function t(t){var e;this.comparator=(null!=t?t.comparator:void 0)||function(t,e){return t-e},this.length=0,this.data=(null!=(e=t.initialValues)?e.slice(0):void 0)||[],this._heapify()}return t.prototype._heapify=function(){var t,e,i;if(this.data.length>0)for(t=e=1,i=this.data.length;1<=i?e<i:e>i;t=1<=i?++e:--e)this._bubbleUp(t)},t.prototype.queue=function(t){this.data.push(t),this._bubbleUp(this.data.length-1)},t.prototype.dequeue=function(){var t,e;return e=this.data[0],t=this.data.pop(),this.data.length>0&&(this.data[0]=t,this._bubbleDown(0)),e},t.prototype.peek=function(){return this.data[0]},t.prototype.clear=function(){this.length=0,this.data.length=0},t.prototype._bubbleUp=function(t){for(var e,i;t>0&&(e=t-1>>>1,this.comparator(this.data[t],this.data[e])<0);)i=this.data[e],this.data[e]=this.data[t],this.data[t]=i,t=e},t.prototype._bubbleDown=function(t){var e,i,r,o,a;for(e=this.data.length-1;;){if(i=1+(t<<1),o=i+1,r=t,i<=e&&this.comparator(this.data[i],this.data[r])<0&&(r=i),o<=e&&this.comparator(this.data[o],this.data[r])<0&&(r=o),r===t)break;a=this.data[r],this.data[r]=this.data[t],this.data[t]=a,t=r}},t}()},{}]},{},[1])(1)});
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
},{}],23:[function(require,module,exports){
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var jsdom={env:function(e){e.done&&e.done(new Error("Only DOM elements are supported in a browser environment"))}};exports.default=jsdom,module.exports=exports.default;
},{}],24:[function(require,module,exports){
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var XMLSerializer=exports.XMLSerializer=window.XMLSerializer;
},{}],25:[function(require,module,exports){
"use strict";function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function jsonldRdfaParser(e,t){function r(e){var r=void 0;e.baseURI&&"about:blank"!==e.baseURI||(r={baseURI:"http://localhost/"});var o=void 0,a=void 0;try{o=processGraph((0,_graphRdfaProcessor2.default)(e,r))}catch(e){a=e}t(a,o)}if("object"===(void 0===e?"undefined":_typeof(e))&&"nodeType"in e)r(e);else{if("string"!=typeof e)return t(new Error("data must be a file path, HTML string, URL or a DOM element"));var o={done:function(e,o){if(e)return t(e);r(o.document)}};(0,_isUrl2.default)(e)?o.url=e:/<[a-z][\s\S]*>/i.test(e)?o.html=e:o.file=e,_jsdom2.default.env(o)}}function processGraph(e){var t={"@default":[]},r=e.subjects,o=function(e){var t=e.ownerDocument.createElement("div");return t.appendChild(e.cloneNode(!0)),t.innerHTML};return Object.keys(r).forEach(function(e){var a=r[e].predicates;Object.keys(a).forEach(function(r){for(var n=a[r].objects,i=0;i<n.length;++i){var u=n[i],l={};l.subject={type:0===e.indexOf("_:")?"blank node":"IRI",value:e},l.predicate={type:0===r.indexOf("_:")?"blank node":"IRI",value:r},l.object={};var s=u.value;u.type===RDF_XML_LITERAL?function(){var e=new _xmldom.XMLSerializer;s=Array.from(u.value).map(function(t){return e.serializeToString(t)}).join(""),l.object.datatype=RDF_XML_LITERAL}():u.type===RDF_HTML_LITERAL?(s=Array.from(u.value).map(o).join(""),l.object.datatype=RDF_HTML_LITERAL):u.type===RDF_OBJECT?0===u.value.indexOf("_:")?l.object.type="blank node":l.object.type="IRI":(l.object.type="literal",u.type===RDF_PLAIN_LITERAL?u.language?(l.object.datatype=RDF_LANGSTRING,l.object.language=u.language):l.object.datatype=XSD_STRING:l.object.datatype=u.type),l.object.value=s,t["@default"].push(l)}})}),t}Object.defineProperty(exports,"__esModule",{value:!0});var _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};exports.default=jsonldRdfaParser;var _graphRdfaProcessor=require("graph-rdfa-processor"),_graphRdfaProcessor2=_interopRequireDefault(_graphRdfaProcessor),_jsdom=require("jsdom"),_jsdom2=_interopRequireDefault(_jsdom),_xmldom=require("xmldom"),_isUrl=require("is-url"),_isUrl2=_interopRequireDefault(_isUrl),RDF="http://www.w3.org/1999/02/22-rdf-syntax-ns#",RDF_XML_LITERAL=RDF+"XMLLiteral",RDF_HTML_LITERAL=RDF+"HTML",RDF_OBJECT=RDF+"object",RDF_PLAIN_LITERAL=RDF+"PlainLiteral",RDF_LANGSTRING=RDF+"langString",XSD_STRING="http://www.w3.org/2001/XMLSchema#string";module.exports=exports.default;
},{"graph-rdfa-processor":14,"is-url":20,"jsdom":23,"xmldom":24}],26:[function(require,module,exports){
},{}],27:[function(require,module,exports){
(function (process,global,__dirname){
!function(){var e="undefined"!=typeof process&&process.versions&&process.versions.node,t=!e&&("undefined"!=typeof window||"undefined"!=typeof self);t&&"undefined"==typeof global&&("undefined"!=typeof window?global=window:"undefined"!=typeof self?global=self:"undefined"!=typeof $&&(global=$));var n=function(n){function r(){}function a(e){for(var t=[],n=Object.keys(e).sort(),r=0;r<n.length;++r){var a=n[r],o=e[a];A(o)||(o=[o]);for(var i=0;i<o.length;++i){var l=o[i];if(null!==l){if(!J(l))throw new Oe("Invalid JSON-LD syntax; language map values must be strings.","jsonld.SyntaxError",{code:"invalid language map value",languageMap:e});t.push({"@value":l,"@language":a.toLowerCase()})}}}return t}function o(e,t){if(A(t))for(var n=0;n<t.length;++n)t[n]=o(e,t[n]);else if(X(t))t["@list"]=o(e,t["@list"]);else if(T(t)){G(t)&&(t["@id"]=e.getId(t["@id"]));for(var r=Object.keys(t).sort(),a=0;a<r.length;++a){var i=r[a];"@id"!==i&&(t[i]=o(e,t[i]))}}return t}function i(e,t,r){if(null===r||void 0===r)return null;var a=D(e,t,{vocab:!0});if("@id"===a)return D(e,r,{base:!0});if("@type"===a)return D(e,r,{vocab:!0,base:!0});var o=n.getContextValue(e,t,"@type");if("@id"===o||"@graph"===a&&J(r))return{"@id":D(e,r,{base:!0})};if("@vocab"===o)return{"@id":D(e,r,{vocab:!0,base:!0})};if(_(a))return r;var i={};if(null!==o)i["@type"]=o;else if(J(r)){var l=n.getContextValue(e,t,"@language");null!==l&&(i["@language"]=l)}return-1===["boolean","number","string"].indexOf(typeof r)&&(r=r.toString()),i["@value"]=r,i}function l(e,t,n){for(var r=[],a=Object.keys(e).sort(),o=0;o<a.length;++o)for(var i=a[o],l=e[i],c=Object.keys(l).sort(),d=0;d<c.length;++d){var f=c[d],p=l[f];if("@type"===f)f=xe;else if(_(f))continue;for(var h=0;h<p.length;++h){var v=p[h],g={};if(g.type=0===i.indexOf("_:")?"blank node":"IRI",g.value=i,$(i)){var y={};if(y.type=0===f.indexOf("_:")?"blank node":"IRI",y.value=f,$(f)&&("blank node"!==y.type||n.produceGeneralizedRdf))if(X(v))u(v["@list"],t,g,y,r);else{var m=s(v);m&&r.push({subject:g,predicate:y,object:m})}}}}return r}function u(e,t,n,r,a){for(var o={type:"IRI",value:ge},i={type:"IRI",value:ye},l={type:"IRI",value:me},u=0;u<e.length;++u){var c=e[u],d={type:"blank node",value:t.getId()};a.push({subject:n,predicate:r,object:d}),n=d,r=o;var f=s(c);f&&a.push({subject:n,predicate:r,object:f}),r=i}a.push({subject:n,predicate:r,object:l})}function s(e){var t={};if(Q(e)){t.type="literal";var n=e["@value"],r=e["@type"]||null;V(n)?(t.value=n.toString(),t.datatype=r||de):F(n)||r===fe?(F(n)||(n=parseFloat(n)),t.value=n.toExponential(15).replace(/(\d)0*e\+?/,"$1E"),t.datatype=r||fe):P(n)?(t.value=n.toFixed(0),t.datatype=r||pe):"@language"in e?(t.value=n,t.datatype=r||ke,t.language=e["@language"]):(t.value=n,t.datatype=r||he)}else{var a=T(e)?e["@id"]:e;t.type=0===a.indexOf("_:")?"blank node":"IRI",t.value=a}return"IRI"!==t.type||$(t.value)?t:null}function c(e,t){if("IRI"===e.type||"blank node"===e.type)return{"@id":e.value};var n={"@value":e.value};if(e.language)n["@language"]=e.language;else{var r=e.datatype;if(r||(r=he),t){if(r===de)"true"===n["@value"]?n["@value"]=!0:"false"===n["@value"]&&(n["@value"]=!1);else if(B(n["@value"]))if(r===pe){var a=parseInt(n["@value"],10);a.toFixed(0)===n["@value"]&&(n["@value"]=a)}else r===fe&&(n["@value"]=parseFloat(n["@value"]));-1===[de,pe,fe,he].indexOf(r)&&(n["@type"]=r)}else r!==he&&(n["@type"]=r)}return n}function d(e,t){for(var n=["subject","predicate","object"],r=0;r<n.length;++r){var a=n[r];if(e[a].type!==t[a].type||e[a].value!==t[a].value)return!1}return e.object.language===t.object.language&&e.object.datatype===t.object.datatype}function f(e,t,r,a,o,i){if(A(e))for(var l=0;l<e.length;++l)f(e[l],t,r,a,void 0,i);else{if(!T(e))return void(i&&i.push(e));if(Q(e)){if("@type"in e){var u=e["@type"];0===u.indexOf("_:")&&(e["@type"]=u=a.getId(u))}return void(i&&i.push(e))}if("@type"in e)for(var s=e["@type"],l=0;l<s.length;++l){var u=s[l];0===u.indexOf("_:")&&a.getId(u)}M(o)&&(o=G(e)?a.getId(e["@id"]):e["@id"]),i&&i.push({"@id":o});var c=t[r],d=c[o]=c[o]||{};d["@id"]=o;for(var p=Object.keys(e).sort(),h=0;h<p.length;++h){var v=p[h];if("@id"!==v)if("@reverse"!==v)if("@graph"!==v)if("@type"!==v&&_(v)){if("@index"===v&&v in d&&(e[v]!==d[v]||e[v]["@id"]!==d[v]["@id"]))throw new Oe("Invalid JSON-LD syntax; conflicting @index property detected.","jsonld.SyntaxError",{code:"conflicting indexes",subject:d});d[v]=e[v]}else{var g=e[v];if(0===v.indexOf("_:")&&(v=a.getId(v)),0!==g.length)for(var y=0;y<g.length;++y){var m=g[y];if("@type"===v&&(m=0===m.indexOf("_:")?a.getId(m):m),z(m)||H(m)){var x=G(m)?a.getId(m["@id"]):m["@id"];n.addValue(d,v,{"@id":x},{propertyIsArray:!0,allowDuplicate:!1}),f(m,t,r,a,x)}else if(X(m)){var b=[];f(m["@list"],t,r,a,o,b),m={"@list":b},n.addValue(d,v,m,{propertyIsArray:!0,allowDuplicate:!1})}else f(m,t,r,a,o),n.addValue(d,v,m,{propertyIsArray:!0,allowDuplicate:!1})}else n.addValue(d,v,[],{propertyIsArray:!0})}else{o in t||(t[o]={});var w="@merged"===r?r:o;f(e[v],t,w,a)}else{var j={"@id":o},k=e["@reverse"];for(var I in k)for(var L=k[I],O=0;O<L.length;++O){var E=L[O],S=E["@id"];G(E)&&(S=a.getId(S)),f(E,t,r,a,S),n.addValue(c[S],I,j,{propertyIsArray:!0,allowDuplicate:!1})}}}}}function p(e){for(var t=e["@default"],n=Object.keys(e).sort(),r=0;r<n.length;++r){var a=n[r];if("@default"!==a){var o=e[a],i=t[a];i?"@graph"in i||(i["@graph"]=[]):t[a]=i={"@id":a,"@graph":[]};for(var l=i["@graph"],u=Object.keys(o).sort(),s=0;s<u.length;++s){var c=o[u[s]];H(c)||l.push(c)}}}return t}function h(e,t,n,r,a){m(n),n=n[0];for(var o=e.options,i={embed:y(n,o,"embed"),explicit:y(n,o,"explicit"),requireAll:y(n,o,"requireAll")},l=x(e,t,n,i),u=Object.keys(l).sort(),s=0;s<u.length;++s){var c=u[s],d=l[c];if("@link"===i.embed&&c in e.link)j(r,a,e.link[c]);else{null===a&&(e.uniqueEmbeds={});var f={};if(f["@id"]=c,e.link[c]=f,"@never"===i.embed||g(d,e.subjectStack))j(r,a,f);else{"@last"===i.embed&&(c in e.uniqueEmbeds&&w(e,c),e.uniqueEmbeds[c]={parent:r,property:a}),e.subjectStack.push(d);for(var p=Object.keys(d).sort(),b=0;b<p.length;b++){var k=p[b];if(_(k))f[k]=W(d[k]);else if(!i.explicit||k in n)for(var I=d[k],L=0;L<I.length;++L){var O=I[L];if(X(O)){var E={"@list":[]};j(f,k,E);var S=O["@list"];for(var D in S)if(O=S[D],H(O)){var N=k in n?n[k][0]["@list"]:v(i);h(e,[O["@id"]],N,E,"@list")}else j(E,"@list",W(O))}else if(H(O)){var N=k in n?n[k]:v(i);h(e,[O["@id"]],N,f,k)}else j(f,k,W(O))}}for(var p=Object.keys(n).sort(),b=0;b<p.length;++b){var k=p[b];if(!_(k)){var C=n[k][0];if(!(y(C,o,"omitDefault")||k in f)){var R="@null";"@default"in C&&(R=W(C["@default"])),A(R)||(R=[R]),f[k]=[{"@preserve":R}]}}}j(r,a,f),e.subjectStack.pop()}}}}function v(e){var t={};for(var n in e)void 0!==e[n]&&(t["@"+n]=[e[n]]);return[t]}function g(e,t){for(var n=t.length-1;n>=0;--n)if(t[n]["@id"]===e["@id"])return!0;return!1}function y(e,t,n){var r="@"+n,a=r in e?e[r][0]:t[n];return"embed"===n&&(!0===a?a="@last":!1===a?a="@never":"@always"!==a&&"@never"!==a&&"@link"!==a&&(a="@last")),a}function m(e){if(!A(e)||1!==e.length||!T(e[0]))throw new Oe("Invalid JSON-LD syntax; a JSON-LD frame must be a single object.","jsonld.SyntaxError",{frame:e})}function x(e,t,n,r){for(var a={},o=0;o<t.length;++o){var i=t[o],l=e.subjects[i];b(l,n,r)&&(a[i]=l)}return a}function b(e,t,r){if("@type"in t&&(1!==t["@type"].length||!T(t["@type"][0]))){for(var a=t["@type"],o=0;o<a.length;++o)if(n.hasValue(e,"@type",a[o]))return!0;return!1}var i=!0,l=!1;for(var u in t){if(_(u)){if("@id"!==u&&"@type"!==u)continue;if(i=!1,"@id"===u&&J(t[u])){if(e[u]!==t[u])return!1;l=!0;continue}}if(i=!1,u in e){if(A(t[u])&&0===t[u].length&&void 0!==e[u])return!1;l=!0}else{var s=A(t[u])&&T(t[u][0])&&"@default"in t[u][0];if(r.requireAll&&!s)return!1}}return i||l}function w(e,t){var r=e.uniqueEmbeds,a=r[t],o=a.parent,i=a.property,l={"@id":t};if(A(o)){for(var u=0;u<o.length;++u)if(n.compareValues(o[u],l)){o[u]=l;break}}else{var s=A(o[i]);n.removeValue(o,i,l,{propertyIsArray:s}),n.addValue(o,i,l,{propertyIsArray:s})}var c=function(e){for(var t=Object.keys(r),n=0;n<t.length;++n){var a=t[n];a in r&&T(r[a].parent)&&r[a].parent["@id"]===e&&(delete r[a],c(a))}};c(t)}function j(e,t,r){T(e)?n.addValue(e,t,r,{propertyIsArray:!0}):e.push(r)}function k(e,t,r){if(A(t)){for(var a=[],o=0;o<t.length;++o){var i=k(e,t[o],r);null!==i&&a.push(i)}t=a}else if(T(t)){if("@preserve"in t)return"@null"===t["@preserve"]?null:t["@preserve"];if(Q(t))return t;if(X(t))return t["@list"]=k(e,t["@list"],r),t;var l=O(e,"@id");if(l in t){var u=t[l];if(u in r.link){var s=r.link[u].indexOf(t);if(-1!==s)return r.link[u][s];r.link[u].push(t)}else r.link[u]=[t]}for(var c in t){var i=k(e,t[c],r),d=n.getContextValue(e,c,"@container");r.compactArrays&&A(i)&&1===i.length&&null===d&&(i=i[0]),t[c]=i}}return t}function I(e,t){return e.length<t.length?-1:t.length<e.length?1:e===t?0:e<t?-1:1}function L(e,t,n,r,a,o){null===o&&(o="@null");var i=[];if("@id"!==o&&"@reverse"!==o||!H(n))i.push(o);else{"@reverse"===o&&i.push("@reverse");var l=O(e,n["@id"],null,{vocab:!0});l in e.mappings&&e.mappings[l]&&e.mappings[l]["@id"]===n["@id"]?i.push.apply(i,["@vocab","@id"]):i.push.apply(i,["@id","@vocab"])}i.push("@none");for(var u=e.inverse[t],s=0;s<r.length;++s){var c=r[s];if(c in u)for(var d=u[c][a],f=0;f<i.length;++f){var p=i[f];if(p in d)return d[p]}}return null}function O(e,t,n,r,a){if(null===t)return t;M(n)&&(n=null),M(a)&&(a=!1),r=r||{};var o=e.getInverse();if(_(t))return t in o?o[t]["@none"]["@type"]["@none"]:t;if(r.vocab&&t in o){var i=e["@language"]||"@none",l=[];T(n)&&"@index"in n&&l.push("@index");var u="@language",s="@null";if(a)u="@type",s="@reverse",l.push("@set");else if(X(n)){"@index"in n||l.push("@list");for(var c=n["@list"],d=0===c.length?i:null,f=null,p=0;p<c.length;++p){var h=c[p],v="@none",g="@none";if(Q(h)?"@language"in h?v=h["@language"]:"@type"in h?g=h["@type"]:v="@null":g="@id",null===d?d=v:v!==d&&Q(h)&&(d="@none"),null===f?f=g:g!==f&&(f="@none"),"@none"===d&&"@none"===f)break}d=d||"@none",f=f||"@none","@none"!==f?(u="@type",s=f):s=d}else Q(n)?"@language"in n&&!("@index"in n)?(l.push("@language"),s=n["@language"]):"@type"in n&&(u="@type",s=n["@type"]):(u="@type",s="@id"),l.push("@set");l.push("@none");var y=L(e,t,n,l,u,s);if(null!==y)return y}if(r.vocab&&"@vocab"in e){var m=e["@vocab"];if(0===t.indexOf(m)&&t!==m){var x=t.substr(m.length);if(!(x in e.mappings))return x}}for(var b=null,w=0,j=[],k=e.fastCurieMap,O=t.length-1;w<O&&t[w]in k;++w)""in(k=k[t[w]])&&j.push(k[""][0]);for(var p=j.length-1;p>=0;--p)for(var E=j[p],S=E.terms,D=0;D<S.length;++D){var N=S[D]+":"+t.substr(E.iri.length),R=!(N in e.mappings)||null===n&&e.mappings[N]["@id"]===t;R&&(null===b||I(N,b)<0)&&(b=N)}return null!==b?b:r.vocab?t:C(e["@base"],t)}function E(e,t,r){if(Q(r)){var a=n.getContextValue(e,t,"@type"),o=n.getContextValue(e,t,"@language"),i=n.getContextValue(e,t,"@container"),l="@index"in r&&"@index"!==i;if(!l&&(r["@type"]===a||r["@language"]===o))return r["@value"];var u=Object.keys(r).length,s=1===u||2===u&&"@index"in r&&!l,c="@language"in e,d=J(r["@value"]),f=e.mappings[t]&&null===e.mappings[t]["@language"];if(s&&(!c||!d||f))return r["@value"];var p={};return l&&(p[O(e,"@index")]=r["@index"]),"@type"in r?p[O(e,"@type")]=O(e,r["@type"],null,{vocab:!0}):"@language"in r&&(p[O(e,"@language")]=r["@language"]),p[O(e,"@value")]=r["@value"],p}var h=D(e,t,{vocab:!0}),a=n.getContextValue(e,t,"@type"),v=O(e,r["@id"],null,{vocab:"@vocab"===a});if("@id"===a||"@vocab"===a||"@graph"===h)return v;var p={};return p[O(e,"@id")]=v,p}function S(e,t,n,r){if(n in r){if(r[n])return;throw new Oe("Cyclical context definition detected.","jsonld.CyclicalContext",{code:"cyclic IRI mapping",context:t,term:n})}if(r[n]=!1,_(n))throw new Oe("Invalid JSON-LD syntax; keywords cannot be overridden.","jsonld.SyntaxError",{code:"keyword redefinition",context:t,term:n});if(""===n)throw new Oe("Invalid JSON-LD syntax; a term cannot be an empty string.","jsonld.SyntaxError",{code:"invalid term definition",context:t});e.mappings[n]&&delete e.mappings[n];var a=t[n];if(null===a||T(a)&&null===a["@id"])return e.mappings[n]=null,void(r[n]=!0);if(J(a)&&(a={"@id":a}),!T(a))throw new Oe("Invalid JSON-LD syntax; @context property values must be strings or objects.","jsonld.SyntaxError",{code:"invalid term definition",context:t});var o=e.mappings[n]={};if(o.reverse=!1,"@reverse"in a){if("@id"in a)throw new Oe("Invalid JSON-LD syntax; a @reverse term definition must not contain @id.","jsonld.SyntaxError",{code:"invalid reverse property",context:t});var i=a["@reverse"];if(!J(i))throw new Oe("Invalid JSON-LD syntax; a @context @reverse value must be a string.","jsonld.SyntaxError",{code:"invalid IRI mapping",context:t});var l=D(e,i,{vocab:!0,base:!1},t,r);if(!$(l))throw new Oe("Invalid JSON-LD syntax; a @context @reverse value must be an absolute IRI or a blank node identifier.","jsonld.SyntaxError",{code:"invalid IRI mapping",context:t});o["@id"]=l,o.reverse=!0}else if("@id"in a){var l=a["@id"];if(!J(l))throw new Oe("Invalid JSON-LD syntax; a @context @id value must be an array of strings or a string.","jsonld.SyntaxError",{code:"invalid IRI mapping",context:t});if(l!==n){if(l=D(e,l,{vocab:!0,base:!1},t,r),!$(l)&&!_(l))throw new Oe("Invalid JSON-LD syntax; a @context @id value must be an absolute IRI, a blank node identifier, or a keyword.","jsonld.SyntaxError",{code:"invalid IRI mapping",context:t});o["@id"]=l}}var u=n.indexOf(":");if(o._termHasColon=-1!==u,!("@id"in o))if(o._termHasColon){var s=n.substr(0,u);if(s in t&&S(e,t,s,r),e.mappings[s]){var c=n.substr(u+1);o["@id"]=e.mappings[s]["@id"]+c}else o["@id"]=n}else{if(!("@vocab"in e))throw new Oe("Invalid JSON-LD syntax; @context terms must define an @id.","jsonld.SyntaxError",{code:"invalid IRI mapping",context:t,term:n});o["@id"]=e["@vocab"]+n}if(r[n]=!0,"@type"in a){var d=a["@type"];if(!J(d))throw new Oe("Invalid JSON-LD syntax; an @context @type values must be a string.","jsonld.SyntaxError",{code:"invalid type mapping",context:t});if("@id"!==d&&"@vocab"!==d){if(d=D(e,d,{vocab:!0,base:!1},t,r),!$(d))throw new Oe("Invalid JSON-LD syntax; an @context @type value must be an absolute IRI.","jsonld.SyntaxError",{code:"invalid type mapping",context:t});if(0===d.indexOf("_:"))throw new Oe("Invalid JSON-LD syntax; an @context @type values must be an IRI, not a blank node identifier.","jsonld.SyntaxError",{code:"invalid type mapping",context:t})}o["@type"]=d}if("@container"in a){var f=a["@container"];if("@list"!==f&&"@set"!==f&&"@index"!==f&&"@language"!==f)throw new Oe("Invalid JSON-LD syntax; @context @container value must be one of the following: @list, @set, @index, or @language.","jsonld.SyntaxError",{code:"invalid container mapping",context:t});if(o.reverse&&"@index"!==f&&"@set"!==f&&null!==f)throw new Oe("Invalid JSON-LD syntax; @context @container value for a @reverse type definition must be @index or @set.","jsonld.SyntaxError",{code:"invalid reverse property",context:t});o["@container"]=f}if("@language"in a&&!("@type"in a)){var p=a["@language"];if(null!==p&&!J(p))throw new Oe("Invalid JSON-LD syntax; @context @language value must be a string or null.","jsonld.SyntaxError",{code:"invalid language mapping",context:t});null!==p&&(p=p.toLowerCase()),o["@language"]=p}var l=o["@id"];if("@context"===l||"@preserve"===l)throw new Oe("Invalid JSON-LD syntax; @context and @preserve cannot be aliased.","jsonld.SyntaxError",{code:"invalid keyword alias",context:t})}function D(e,t,r,a,o){if(null===t||_(t))return t;if(t=String(t),a&&t in a&&!0!==o[t]&&S(e,a,t,o),r=r||{},r.vocab){var i=e.mappings[t];if(null===i)return null;if(i)return i["@id"]}var l=t.indexOf(":");if(-1!==l){var u=t.substr(0,l),s=t.substr(l+1);if("_"===u||0===s.indexOf("//"))return t;a&&u in a&&S(e,a,u,o);var i=e.mappings[u];return i?i["@id"]+s:t}if(r.vocab&&"@vocab"in e)return e["@vocab"]+t;var c=t;return r.base&&(c=n.prependBase(e["@base"],c)),c}function N(e,t){if(null===e)return t;if(-1!==t.indexOf(":"))return t;J(e)&&(e=n.url.parse(e||""));var r=n.url.parse(t),a={protocol:e.protocol||""};if(null!==r.authority)a.authority=r.authority,a.path=r.path,a.query=r.query;else if(a.authority=e.authority,""===r.path)a.path=e.path,null!==r.query?a.query=r.query:a.query=e.query;else{if(0===r.path.indexOf("/"))a.path=r.path;else{var o=e.path;""!==r.path&&(o=o.substr(0,o.lastIndexOf("/")+1),o.length>0&&"/"!==o.substr(-1)&&(o+="/"),o+=r.path),a.path=o}a.query=r.query}a.path=ae(a.path,!!a.authority);var i=a.protocol;return null!==a.authority&&(i+="//"+a.authority),i+=a.path,null!==a.query&&(i+="?"+a.query),null!==r.fragment&&(i+="#"+r.fragment),""===i&&(i="./"),i}function C(e,t){if(null===e)return t;J(e)&&(e=n.url.parse(e||""));var r="";if(""!==e.href?r+=(e.protocol||"")+"//"+(e.authority||""):t.indexOf("//")&&(r+="//"),0!==t.indexOf(r))return t;for(var a=n.url.parse(t.substr(r.length)),o=e.normalizedPath.split("/"),i=a.normalizedPath.split("/"),l=a.fragment||a.query?0:1;o.length>0&&i.length>l&&o[0]===i[0];)o.shift(),i.shift();var u="";if(o.length>0){o.pop();for(var s=0;s<o.length;++s)u+="../"}return u+=i.join("/"),null!==a.query&&(u+="?"+a.query),null!==a.fragment&&(u+="#"+a.fragment),""===u&&(u="./"),u}function R(e){function t(){var e=this;if(e.inverse)return e.inverse;for(var t=e.inverse={},n=e.fastCurieMap={},o={},i=e["@language"]||"@none",l=e.mappings,u=Object.keys(l).sort(I),s=0;s<u.length;++s){var c=u[s],d=l[c];if(null!==d){var f=d["@container"]||"@none",p=d["@id"];A(p)||(p=[p]);for(var h=0;h<p.length;++h){var v=p[h],g=t[v],y=_(v);if(g)y||d._termHasColon||o[v].push(c);else if(t[v]=g={},!y&&!d._termHasColon){o[v]=[c];var m={iri:v,terms:o[v]};v[0]in n?n[v[0]].push(m):n[v[0]]=[m]}if(g[f]||(g[f]={"@language":{},"@type":{}}),g=g[f],d.reverse)a(d,c,g["@type"],"@reverse");else if("@type"in d)a(d,c,g["@type"],d["@type"]);else if("@language"in d){var x=d["@language"]||"@null";a(d,c,g["@language"],x)}else a(d,c,g["@language"],i),a(d,c,g["@type"],"@none"),a(d,c,g["@language"],"@none")}}}for(var b in n)r(n,b,1);return t}function r(e,t,n){for(var a,o,i=e[t],l=e[t]={},u=0;u<i.length;++u)a=i[u].iri,o=n>=a.length?"":a[n],o in l?l[o].push(i[u]):l[o]=[i[u]];for(var t in l)""!==t&&r(l,t,n+1)}function a(e,t,n,r){r in n||(n[r]=t)}function o(){var e={};return e["@base"]=this["@base"],e.mappings=W(this.mappings),e.clone=this.clone,e.inverse=null,e.getInverse=this.getInverse,"@language"in this&&(e["@language"]=this["@language"]),"@vocab"in this&&(e["@vocab"]=this["@vocab"]),e}return{"@base":n.url.parse(e.base||""),mappings:{},inverse:null,getInverse:t,clone:o}}function _(e){if(!J(e))return!1;switch(e){case"@base":case"@context":case"@container":case"@default":case"@embed":case"@explicit":case"@graph":case"@id":case"@index":case"@language":case"@list":case"@omitDefault":case"@preserve":case"@requireAll":case"@reverse":case"@set":case"@type":case"@value":case"@vocab":return!0}return!1}function T(e){return"[object Object]"===Object.prototype.toString.call(e)}function U(e){return T(e)&&0===Object.keys(e).length}function A(e){return Array.isArray(e)}function q(e){if(!J(e)&&!U(e)){var t=!1;if(A(e)){t=!0;for(var n=0;n<e.length;++n)if(!J(e[n])){t=!1;break}}if(!t)throw new Oe('Invalid JSON-LD syntax; "@type" value must a string, an array of strings, or an empty object.',"jsonld.SyntaxError",{code:"invalid type value",value:e})}}function J(e){return"string"==typeof e||"[object String]"===Object.prototype.toString.call(e)}function P(e){return"number"==typeof e||"[object Number]"===Object.prototype.toString.call(e)}function F(e){return P(e)&&-1!==String(e).indexOf(".")}function B(e){return!isNaN(parseFloat(e))&&isFinite(e)}function V(e){return"boolean"==typeof e||"[object Boolean]"===Object.prototype.toString.call(e)}function M(e){return void 0===e}function z(e){var t=!1;if(T(e)&&!("@value"in e||"@set"in e||"@list"in e)){t=Object.keys(e).length>1||!("@id"in e)}return t}function H(e){return T(e)&&1===Object.keys(e).length&&"@id"in e}function Q(e){return T(e)&&"@value"in e}function X(e){return T(e)&&"@list"in e}function G(e){var t=!1;return T(e)&&(t="@id"in e?0===e["@id"].indexOf("_:"):0===Object.keys(e).length||!("@value"in e||"@set"in e||"@list"in e)),t}function $(e){return J(e)&&-1!==e.indexOf(":")}function W(e){if(e&&"object"==typeof e){var t;if(A(e)){t=[];for(var n=0;n<e.length;++n)t[n]=W(e[n])}else if(T(e)){t={};for(var r in e)t[r]=W(e[r])}else t=e.toString();return t}return e}function Y(e,t,r,a){var o=Object.keys(t).length;if(A(e)){for(var i=0;i<e.length;++i)Y(e[i],t,r,a);return o<Object.keys(t).length}if(T(e)){for(var l in e)if("@context"===l){var u=e[l];if(A(u))for(var s=u.length,i=0;i<s;++i){var c=u[i];J(c)&&(c=n.prependBase(a,c),r?(c=t[c],A(c)?(Array.prototype.splice.apply(u,[i,1].concat(c)),i+=c.length-1,s=u.length):u[i]=c):c in t||(t[c]=!1))}else J(u)&&(u=n.prependBase(a,u),r?e[l]=t[u]:u in t||(t[u]=!1))}else Y(e[l],t,r,a);return o<Object.keys(t).length}return!1}function Z(e,t,n){var r=null,a=t.documentLoader,o=function(e,t,n,a,i){if(Object.keys(t).length>Le)return r=new Oe("Maximum number of @context URLs exceeded.","jsonld.ContextUrlError",{code:"loading remote context failed",max:Le}),i(r);var l={},u=function(){Y(e,l,!0,a),i(null,e)};if(!Y(e,l,!1,a))return u();var s=[];for(var c in l)!1===l[c]&&s.push(c);for(var d=s.length,f=0;f<s.length;++f)!function(e){if(e in t)return r=new Oe("Cyclical @context URLs detected.","jsonld.ContextUrlError",{code:"recursive context inclusion",url:e}),i(r);var a=W(t);a[e]=!0;var s=function(t,s){if(!r){var c=s?s.document:null;if(!t&&J(c))try{c=JSON.parse(c)}catch(e){t=e}if(t?t=new Oe("Dereferencing a URL did not result in a valid JSON-LD object. Possible causes are an inaccessible URL perhaps due to a same-origin policy (ensure the server uses CORS if you are using client-side JavaScript), too many redirects, a non-JSON response, or more than one HTTP Link Header was provided for a remote context.","jsonld.InvalidUrl",{code:"loading remote context failed",url:e,cause:t}):T(c)||(t=new Oe("Dereferencing a URL did not result in a JSON object. The response was valid JSON, but it was not a JSON object.","jsonld.InvalidUrl",{code:"invalid remote context",url:e,cause:t})),t)return r=t,i(r);c="@context"in c?{"@context":c["@context"]}:{"@context":{}},s.contextUrl&&(A(c["@context"])||(c["@context"]=[c["@context"]]),c["@context"].push(s.contextUrl)),o(c,a,n,e,function(t,n){if(t)return i(t);l[e]=n["@context"],0===(d-=1)&&u()})}},c=n(e,s);c&&"then"in c&&c.then(s.bind(null,null),s)}(s[f])};o(e,{},a,t.base,n)}function K(e){for(var t=/(?:\r\n)|(?:\n)|(?:\r)/g,n=new RegExp("^[ \\t]*(?:#.*)?$"),r=new RegExp('^[ \\t]*(?:(?:<([^:]+:[^>]*)>)|(_:(?:[A-Za-z0-9]+)))[ \\t]+(?:<([^:]+:[^>]*)>)[ \\t]+(?:(?:<([^:]+:[^>]*)>)|(_:(?:[A-Za-z0-9]+))|(?:"([^"\\\\]*(?:\\\\.[^"\\\\]*)*)"(?:(?:\\^\\^(?:<([^:]+:[^>]*)>))|(?:@([a-z]+(?:-[a-z0-9]+)*)))?))[ \\t]*(?:\\.|(?:(?:(?:<([^:]+:[^>]*)>)|(_:(?:[A-Za-z0-9]+)))[ \\t]*\\.))[ \\t]*(?:#.*)?$'),a={},o=e.split(t),i=0,l=0;l<o.length;++l){var u=o[l];if(i++,!n.test(u)){var s=u.match(r);if(null===s)throw new Oe("Error while parsing N-Quads; invalid quad.","jsonld.ParseError",{line:i});var c={};if(M(s[1])?c.subject={type:"blank node",value:s[2]}:c.subject={type:"IRI",value:s[1]},c.predicate={type:"IRI",value:s[3]},M(s[4]))if(M(s[5])){c.object={type:"literal"},M(s[7])?M(s[8])?c.object.datatype=he:(c.object.datatype=ke,c.object.language=s[8]):c.object.datatype=s[7];var f=s[6].replace(/\\"/g,'"').replace(/\\t/g,"\t").replace(/\\n/g,"\n").replace(/\\r/g,"\r").replace(/\\\\/g,"\\");c.object.value=f}else c.object={type:"blank node",value:s[5]};else c.object={type:"IRI",value:s[4]};var p="@default";if(M(s[9])?M(s[10])||(p=s[10]):p=s[9],p in a){for(var h=!0,v=a[p],g=0;h&&g<v.length;++g)d(v[g],c)&&(h=!1);h&&v.push(c)}else a[p]=[c]}}return a}function ee(e){var t=[];for(var n in e)for(var r=e[n],a=0;a<r.length;++a){var o=r[a];"@default"===n&&(n=null),t.push(te(o,n))}return t.sort().join("")}function te(e,t){var n=e.subject,r=e.predicate,a=e.object,o=t||null;"name"in e&&e.name&&(o=e.name.value);var i="";if("IRI"===n.type?i+="<"+n.value+">":i+=n.value,i+=" ","IRI"===r.type?i+="<"+r.value+">":i+=r.value,i+=" ","IRI"===a.type)i+="<"+a.value+">";else if("blank node"===a.type)i+=a.value;else{var l=a.value.replace(/\\/g,"\\\\").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\"/g,'\\"');i+='"'+l+'"',a.datatype===ke?a.language&&(i+="@"+a.language):a.datatype!==he&&(i+="^^<"+a.datatype+">")}return null!==o&&void 0!==o&&(0!==o.indexOf("_:")?i+=" <"+o+">":i+=" "+o),i+=" .\n"}function ne(e){var t={};t["@default"]=[];for(var n=e.getSubjects(),r=0;r<n.length;++r){var a=n[r];if(null!==a){var o=e.getSubjectTriples(a);if(null!==o){var i=o.predicates;for(var l in i)for(var u=i[l].objects,s=0;s<u.length;++s){var c=u[s],d={};0===a.indexOf("_:")?d.subject={type:"blank node",value:a}:d.subject={type:"IRI",value:a},0===l.indexOf("_:")?d.predicate={type:"blank node",value:l}:d.predicate={type:"IRI",value:l};var f=c.value;if(c.type===we){se||Re();var p=new se;f="";for(var h=0;h<c.value.length;h++)c.value[h].nodeType===ce.ELEMENT_NODE?f+=p.serializeToString(c.value[h]):c.value[h].nodeType===ce.TEXT_NODE&&(f+=c.value[h].nodeValue)}d.object={},c.type===je?0===c.value.indexOf("_:")?d.object.type="blank node":d.object.type="IRI":(d.object.type="literal",c.type===be?c.language?(d.object.datatype=ke,d.object.language=c.language):d.object.datatype=he:d.object.datatype=c.type),d.object.value=f,t["@default"].push(d)}}}}return t}function re(e){this.prefix=e,this.counter=0,this.existing={}}function ae(e,t){var n="";0===e.indexOf("/")&&(n="/");for(var r=e.split("/"),a=[];r.length>0;)"."===r[0]||""===r[0]&&r.length>1?r.shift():".."!==r[0]?a.push(r.shift()):(r.shift(),t||a.length>0&&".."!==a[a.length-1]?a.pop():a.push(".."));return n+a.join("/")}n.compact=function(e,t,r,a){function o(e,n,r,o){if(e)return a(e);o.compactArrays&&!o.graph&&A(n)?1===n.length?n=n[0]:0===n.length&&(n={}):o.graph&&T(n)&&(n=[n]),T(t)&&"@context"in t&&(t=t["@context"]),t=W(t),A(t)||(t=[t]);var i=t;t=[];for(var l=0;l<i.length;++l)(!T(i[l])||Object.keys(i[l]).length>0)&&t.push(i[l]);var u=t.length>0;if(1===t.length&&(t=t[0]),A(n)){var s=O(r,"@graph"),c=n;n={},u&&(n["@context"]=t),n[s]=c}else if(T(n)&&u){var c=n;n={"@context":t};for(var d in c)n[d]=c[d]}a(null,n,r)}if(arguments.length<2)return n.nextTick(function(){a(new TypeError("Could not compact, too few arguments."))});if("function"==typeof r&&(a=r,r={}),r=r||{},null===t)return n.nextTick(function(){a(new Oe("The compaction context must not be null.","jsonld.CompactError",{code:"invalid local context"}))});if(null===e)return n.nextTick(function(){a(null,null)});"base"in r||(r.base="string"==typeof e?e:""),"compactArrays"in r||(r.compactArrays=!0),"graph"in r||(r.graph=!1),"skipExpansion"in r||(r.skipExpansion=!1),"documentLoader"in r||(r.documentLoader=n.loadDocument),"link"in r||(r.link=!1),r.link&&(r.skipExpansion=!0);!function(e,t,r){if(t.skipExpansion)return n.nextTick(function(){r(null,e)});n.expand(e,t,r)}(e,r,function(e,i){if(e)return a(new Oe("Could not expand input before compaction.","jsonld.CompactError",{cause:e}));var l=R(r);n.processContext(l,t,r,function(e,t){if(e)return a(new Oe("Could not process context before compaction.","jsonld.CompactError",{cause:e}));var n;try{n=(new Ee).compact(t,null,i,r)}catch(e){return a(e)}o(null,n,t,r)})})},n.expand=function(e,t,r){function a(e){"base"in t||(t.base=e.documentUrl||"");var n={document:W(e.document),remoteContext:{"@context":e.contextUrl}};if("expandContext"in t){var a=W(t.expandContext);n.expandContext="object"==typeof a&&"@context"in a?a:{"@context":a}}Z(n,t,function(e,n){if(e)return r(e);var a;try{var o=new Ee,i=R(t),l=n.document,u=n.remoteContext["@context"];n.expandContext&&(i=o.processContext(i,n.expandContext["@context"],t)),u&&(i=o.processContext(i,u,t)),a=o.expand(i,null,l,t,!1),T(a)&&"@graph"in a&&1===Object.keys(a).length?a=a["@graph"]:null===a&&(a=[]),A(a)||(a=[a])}catch(e){return r(e)}r(null,a)})}if(arguments.length<1)return n.nextTick(function(){r(new TypeError("Could not expand, too few arguments."))});"function"==typeof t&&(r=t,t={}),t=t||{},"documentLoader"in t||(t.documentLoader=n.loadDocument),"keepFreeFloatingNodes"in t||(t.keepFreeFloatingNodes=!1),n.nextTick(function(){if("string"==typeof e){var n=function(e,t){if(e)return r(e);try{if(!t.document)throw new Oe("No remote document found at the given URL.","jsonld.NullRemoteDocument");"string"==typeof t.document&&(t.document=JSON.parse(t.document))}catch(e){return r(new Oe("Could not retrieve a JSON-LD document from the URL. URL dereferencing not implemented.","jsonld.LoadDocumentError",{code:"loading document failed",cause:e,remoteDoc:t}))}a(t)},o=t.documentLoader(e,n);return void(o&&"then"in o&&o.then(n.bind(null,null),n))}a({contextUrl:null,documentUrl:null,document:e})})},n.flatten=function(e,t,r,a){if(arguments.length<1)return n.nextTick(function(){a(new TypeError("Could not flatten, too few arguments."))});"function"==typeof r?(a=r,r={}):"function"==typeof t&&(a=t,t=null,r={}),r=r||{},"base"in r||(r.base="string"==typeof e?e:""),"documentLoader"in r||(r.documentLoader=n.loadDocument),n.expand(e,r,function(e,o){if(e)return a(new Oe("Could not expand input before flattening.","jsonld.FlattenError",{cause:e}));var i;try{i=(new Ee).flatten(o)}catch(e){return a(e)}if(null===t)return a(null,i);r.graph=!0,r.skipExpansion=!0,n.compact(i,t,r,function(e,t){if(e)return a(new Oe("Could not compact flattened output.","jsonld.FlattenError",{cause:e}));a(null,t)})})},n.frame=function(e,t,r,a){function o(t){var o,i=t.document;i?(o=i["@context"],t.contextUrl?(o?A(o)?o.push(t.contextUrl):o=[o,t.contextUrl]:o=t.contextUrl,i["@context"]=o):o=o||{}):o={},n.expand(e,r,function(e,t){if(e)return a(new Oe("Could not expand input before framing.","jsonld.FrameError",{cause:e}));var l=W(r);l.isFrame=!0,l.keepFreeFloatingNodes=!0,n.expand(i,l,function(e,r){if(e)return a(new Oe("Could not expand frame before framing.","jsonld.FrameError",{cause:e}));var i;try{i=(new Ee).frame(t,r,l)}catch(e){return a(e)}l.graph=!0,l.skipExpansion=!0,l.link={},n.compact(i,o,l,function(e,t,n){if(e)return a(new Oe("Could not compact framed output.","jsonld.FrameError",{cause:e}));var r=O(n,"@graph");l.link={},t[r]=k(n,t[r],l),a(null,t)})})})}if(arguments.length<2)return n.nextTick(function(){a(new TypeError("Could not frame, too few arguments."))});"function"==typeof r&&(a=r,r={}),r=r||{},"base"in r||(r.base="string"==typeof e?e:""),"documentLoader"in r||(r.documentLoader=n.loadDocument),"embed"in r||(r.embed="@last"),r.explicit=r.explicit||!1,"requireAll"in r||(r.requireAll=!0),r.omitDefault=r.omitDefault||!1,n.nextTick(function(){if("string"==typeof t){var e=function(e,t){if(e)return a(e);try{if(!t.document)throw new Oe("No remote document found at the given URL.","jsonld.NullRemoteDocument");"string"==typeof t.document&&(t.document=JSON.parse(t.document))}catch(e){return a(new Oe("Could not retrieve a JSON-LD document from the URL. URL dereferencing not implemented.","jsonld.LoadDocumentError",{code:"loading document failed",cause:e,remoteDoc:t}))}o(t)},n=r.documentLoader(t,e);return void(n&&"then"in n&&n.then(e.bind(null,null),e))}o({contextUrl:null,documentUrl:null,document:t})})},n.link=function(e,t,r,a){var o={};t&&(o["@context"]=t),o["@embed"]="@link",n.frame(e,o,r,a)},n.objectify=function(e,t,r,a){"function"==typeof r&&(a=r,r={}),r=r||{},"base"in r||(r.base="string"==typeof e?e:""),"documentLoader"in r||(r.documentLoader=n.loadDocument),n.expand(e,r,function(e,o){if(e)return a(new Oe("Could not expand input before linking.","jsonld.LinkError",{cause:e}));var i;try{i=(new Ee).flatten(o)}catch(e){return a(e)}r.graph=!0,r.skipExpansion=!0,n.compact(i,t,r,function(e,t,r){if(e)return a(new Oe("Could not compact flattened output before linking.","jsonld.LinkError",{cause:e}));var o=O(r,"@graph"),i=t[o][0],l=function(e){if(T(e)||A(e)){if(T(e)){if(l.visited[e["@id"]])return;l.visited[e["@id"]]=!0}for(var t in e){var a=e[t],o="@id"===n.getContextValue(r,t,"@type")
;if(A(a)||T(a)||o)if(J(a)&&o)e[t]=a=i[a],l(a);else if(A(a))for(var u=0;u<a.length;++u)J(a[u])&&o?a[u]=i[a[u]]:T(a[u])&&"@id"in a[u]&&(a[u]=i[a[u]["@id"]]),l(a[u]);else if(T(a)){var s=a["@id"];e[t]=a=i[s],l(a)}}}};l.visited={},l(i),t.of_type={};for(var u in i)if("@type"in i[u]){var s=i[u]["@type"];A(s)||(s=[s]);for(var c=0;c<s.length;++c)s[c]in t.of_type||(t.of_type[s[c]]=[]),t.of_type[s[c]].push(i[u])}a(null,t)})})},n.normalize=function(e,t,r){if(arguments.length<1)return n.nextTick(function(){r(new TypeError("Could not normalize, too few arguments."))});if("function"==typeof t&&(r=t,t={}),t=t||{},"algorithm"in t||(t.algorithm="URGNA2012"),"base"in t||(t.base="string"==typeof e?e:""),"documentLoader"in t||(t.documentLoader=n.loadDocument),"inputFormat"in t){if("application/nquads"!==t.inputFormat)return r(new Oe("Unknown normalization input format.","jsonld.NormalizeError"));var a=K(e);(new Ee).normalize(a,t,r)}else{var o=W(t);delete o.format,o.produceGeneralizedRdf=!1,n.toRDF(e,o,function(e,n){if(e)return r(new Oe("Could not convert input to RDF dataset before normalization.","jsonld.NormalizeError",{cause:e}));(new Ee).normalize(n,t,r)})}},n.fromRDF=function(e,t,r){if(arguments.length<1)return n.nextTick(function(){r(new TypeError("Could not convert from RDF, too few arguments."))});"function"==typeof t&&(r=t,t={}),t=t||{},"useRdfType"in t||(t.useRdfType=!1),"useNativeTypes"in t||(t.useNativeTypes=!1),"format"in t||!J(e)||"format"in t||(t.format="application/nquads"),n.nextTick(function(){function n(e,t,n){(new Ee).fromRDF(e,t,n)}var a;if(t.format){if(!(a=t.rdfParser||ue[t.format]))return r(new Oe("Unknown input format.","jsonld.UnknownFormat",{format:t.format}))}else a=function(){return e};var o=!1;try{e=a(e,function(e,a){if(o=!0,e)return r(e);n(a,t,r)})}catch(e){if(!o)return r(e);throw e}if(e){if("then"in e)return e.then(function(e){n(e,t,r)},r);n(e,t,r)}})},n.toRDF=function(e,t,r){if(arguments.length<1)return n.nextTick(function(){r(new TypeError("Could not convert to RDF, too few arguments."))});"function"==typeof t&&(r=t,t={}),t=t||{},"base"in t||(t.base="string"==typeof e?e:""),"documentLoader"in t||(t.documentLoader=n.loadDocument),n.expand(e,t,function(e,n){if(e)return r(new Oe("Could not expand input before serialization to RDF.","jsonld.RdfError",{cause:e}));var a;try{if(a=Ee.prototype.toRDF(n,t),t.format){if("application/nquads"===t.format)return r(null,ee(a));throw new Oe("Unknown output format.","jsonld.UnknownFormat",{format:t.format})}}catch(e){return r(e)}r(null,a)})},n.createNodeMap=function(e,t,r){if(arguments.length<1)return n.nextTick(function(){r(new TypeError("Could not create node map, too few arguments."))});"function"==typeof t&&(r=t,t={}),t=t||{},"base"in t||(t.base="string"==typeof e?e:""),"documentLoader"in t||(t.documentLoader=n.loadDocument),n.expand(e,t,function(e,n){if(e)return r(new Oe("Could not expand input before creating node map.","jsonld.CreateNodeMapError",{cause:e}));var a;try{a=(new Ee).createNodeMap(n,t)}catch(e){return r(e)}r(null,a)})},n.merge=function(e,t,r,a){function o(e,t){if(!u){if(e)return u=e,a(new Oe("Could not expand input before flattening.","jsonld.FlattenError",{cause:e}));l.push(t),0==--s&&i(l)}}function i(e){var o=!0;"mergeNodes"in r&&(o=r.mergeNodes);var i,l=r.namer||r.issuer||new re("_:b"),u={"@default":{}};try{for(var s=0;s<e.length;++s){var c=e[s];c=n.relabelBlankNodes(c,{issuer:new re("_:b"+s+"-")});var d=o||0===s?u:{"@default":{}};if(f(c,d,"@default",l),d!==u)for(var h in d){var v=d[h];if(h in u){var g=u[h];for(var y in v)y in g||(g[y]=v[y])}else u[h]=v}}i=p(u)}catch(e){return a(e)}for(var m=[],x=Object.keys(i).sort(),b=0;b<x.length;++b){var w=i[x[b]];H(w)||m.push(w)}if(null===t)return a(null,m);r.graph=!0,r.skipExpansion=!0,n.compact(m,t,r,function(e,t){if(e)return a(new Oe("Could not compact merged output.","jsonld.MergeError",{cause:e}));a(null,t)})}if(arguments.length<1)return n.nextTick(function(){a(new TypeError("Could not merge, too few arguments."))});if(!A(e))return n.nextTick(function(){a(new TypeError('Could not merge, "docs" must be an array.'))});"function"==typeof r?(a=r,r={}):"function"==typeof t&&(a=t,t=null,r={}),r=r||{};for(var l=[],u=null,s=e.length,c=0;c<e.length;++c){var d={};for(var h in r)d[h]=r[h];n.expand(e[c],d,o)}},n.relabelBlankNodes=function(e,t){return t=t||{},o(t.namer||t.issuer||new re("_:b"),e)},n.prependBase=function(e,t){return N(e,t)},n.documentLoader=function(t,r){var a=new Oe("Could not retrieve a JSON-LD document from the URL. URL dereferencing not implemented.","jsonld.LoadDocumentError",{code:"loading document failed"});return e?r(a,{contextUrl:null,documentUrl:t,document:null}):n.promisify(function(e){e(a)})},n.loadDocument=function(e,t){var r=n.documentLoader(e,t);r&&"then"in r&&r.then(t.bind(null,null),t)},n.promises=function(e){e=e||{};var t=Array.prototype.slice,r=n.promisify,a=e.api||{},o=e.version||"jsonld.js";"string"==typeof e.api&&(e.version||(o=e.api),a={}),a.expand=function(e){if(arguments.length<1)throw new TypeError("Could not expand, too few arguments.");return r.apply(null,[n.expand].concat(t.call(arguments)))},a.compact=function(e,a){if(arguments.length<2)throw new TypeError("Could not compact, too few arguments.");var o=function(e,t,r,a){"function"==typeof r&&(a=r,r={}),r=r||{},n.compact(e,t,r,function(e,t){a(e,t)})};return r.apply(null,[o].concat(t.call(arguments)))},a.flatten=function(e){if(arguments.length<1)throw new TypeError("Could not flatten, too few arguments.");return r.apply(null,[n.flatten].concat(t.call(arguments)))},a.frame=function(e,a){if(arguments.length<2)throw new TypeError("Could not frame, too few arguments.");return r.apply(null,[n.frame].concat(t.call(arguments)))},a.fromRDF=function(e){if(arguments.length<1)throw new TypeError("Could not convert from RDF, too few arguments.");return r.apply(null,[n.fromRDF].concat(t.call(arguments)))},a.toRDF=function(e){if(arguments.length<1)throw new TypeError("Could not convert to RDF, too few arguments.");return r.apply(null,[n.toRDF].concat(t.call(arguments)))},a.normalize=function(e){if(arguments.length<1)throw new TypeError("Could not normalize, too few arguments.");return r.apply(null,[n.normalize].concat(t.call(arguments)))},"jsonld.js"===o&&(a.link=function(e,a){if(arguments.length<2)throw new TypeError("Could not link, too few arguments.");return r.apply(null,[n.link].concat(t.call(arguments)))},a.objectify=function(e){return r.apply(null,[n.objectify].concat(t.call(arguments)))},a.createNodeMap=function(e){return r.apply(null,[n.createNodeMap].concat(t.call(arguments)))},a.merge=function(e){return r.apply(null,[n.merge].concat(t.call(arguments)))});try{n.Promise=global.Promise||require("es6-promise").Promise}catch(e){var i=function(){throw new Error("Unable to find a Promise implementation.")};for(var l in a)a[l]=i}return a},n.promisify=function(e){if(!n.Promise)try{n.Promise=global.Promise||require("es6-promise").Promise}catch(e){throw new Error("Unable to find a Promise implementation.")}var t=Array.prototype.slice.call(arguments,1);return new n.Promise(function(n,r){e.apply(null,t.concat(function(e,t){e?r(e):n(t)}))})},n.promises({api:n.promises}),r.prototype=n.promises({version:"json-ld-1.0"}),r.prototype.toString=function(){return this instanceof r?"[object JsonLdProcessor]":"[object JsonLdProcessorPrototype]"},n.JsonLdProcessor=r;var oe=!!Object.defineProperty;if(oe)try{Object.defineProperty({},"x",{})}catch(e){oe=!1}oe&&(Object.defineProperty(r,"prototype",{writable:!1,enumerable:!1}),Object.defineProperty(r.prototype,"constructor",{writable:!0,enumerable:!1,configurable:!0,value:r})),t&&void 0===global.JsonLdProcessor&&(oe?Object.defineProperty(global,"JsonLdProcessor",{writable:!0,enumerable:!1,configurable:!0,value:r}):global.JsonLdProcessor=r);var ie="function"==typeof setImmediate&&setImmediate,le=ie?function(e){ie(e)}:function(e){setTimeout(e,0)};"object"==typeof process&&"function"==typeof process.nextTick?n.nextTick=process.nextTick:n.nextTick=le,n.setImmediate=ie?le:n.nextTick,n.parseLinkHeader=function(e){for(var t={},n=e.match(/(?:<[^>]*?>|"[^"]*?"|[^,])+/g),r=/\s*<([^>]*?)>\s*(?:;\s*(.*))?/,a=0;a<n.length;++a){var o=n[a].match(r);if(o){for(var i={target:o[1]},l=o[2],u=/(.*?)=(?:(?:"([^"]*?)")|([^"]*?))\s*(?:(?:;\s*)|$)/g;o=u.exec(l);)i[o[1]]=void 0===o[2]?o[3]:o[2];var s=i.rel||"";A(t[s])?t[s].push(i):t[s]=s in t?[t[s],i]:i}}return t},n.RequestQueue=function(){this._requests={}},n.RequestQueue.prototype.wrapLoader=function(e){return this._loader=e,this._usePromise=1===e.length,this.add.bind(this)},n.RequestQueue.prototype.add=function(e,t){var r=this;if(!t&&!r._usePromise)throw new Error("callback must be specified.");if(r._usePromise)return new n.Promise(function(t,n){var a=r._requests[e];a||(a=r._requests[e]=r._loader(e).then(function(t){return delete r._requests[e],t}).catch(function(t){throw delete r._requests[e],t})),a.then(function(e){t(e)}).catch(function(e){n(e)})});e in r._requests?r._requests[e].push(t):(r._requests[e]=[t],r._loader(e,function(t,n){var a=r._requests[e];delete r._requests[e];for(var o=0;o<a.length;++o)a[o](t,n)}))},n.DocumentCache=function(e){this.order=[],this.cache={},this.size=e||50,this.expires=3e4},n.DocumentCache.prototype.get=function(e){if(e in this.cache){var t=this.cache[e];if(t.expires>=+new Date)return t.ctx;delete this.cache[e],this.order.splice(this.order.indexOf(e),1)}return null},n.DocumentCache.prototype.set=function(e,t){this.order.length===this.size&&delete this.cache[this.order.shift()],this.order.push(e),this.cache[e]={ctx:t,expires:+new Date+this.expires}},n.ActiveContextCache=function(e){this.order=[],this.cache={},this.size=e||100},n.ActiveContextCache.prototype.get=function(e,t){var n=JSON.stringify(e),r=JSON.stringify(t),a=this.cache[n];return a&&r in a?a[r]:null},n.ActiveContextCache.prototype.set=function(e,t,n){if(this.order.length===this.size){var r=this.order.shift();delete this.cache[r.activeCtx][r.localCtx]}var a=JSON.stringify(e),o=JSON.stringify(t);this.order.push({activeCtx:a,localCtx:o}),a in this.cache||(this.cache[a]={}),this.cache[a][o]=W(n)},n.cache={activeCtx:new n.ActiveContextCache},n.documentLoaders={},n.documentLoaders.jquery=function(e,t){function r(r,a){return 0!==r.indexOf("http:")&&0!==r.indexOf("https:")?a(new Oe('URL could not be dereferenced; only "http" and "https" URLs are supported.',"jsonld.InvalidUrl",{code:"loading document failed",url:r}),{contextUrl:null,documentUrl:r,document:null}):t.secure&&0!==r.indexOf("https")?a(new Oe('URL could not be dereferenced; secure mode is enabled and the URL\'s scheme is not "https".',"jsonld.InvalidUrl",{code:"loading document failed",url:r}),{contextUrl:null,documentUrl:r,document:null}):void e.ajax({url:r,accepts:{json:"application/ld+json, application/json"},headers:{Accept:"application/ld+json, application/json"},dataType:"json",crossDomain:!0,success:function(e,t,o){var i={contextUrl:null,documentUrl:r,document:e},l=o.getResponseHeader("Content-Type"),u=o.getResponseHeader("Link");if(u&&"application/ld+json"!==l){if(u=n.parseLinkHeader(u)[Ie],A(u))return a(new Oe("URL could not be dereferenced, it has more than one associated HTTP Link Header.","jsonld.InvalidUrl",{code:"multiple context link headers",url:r}),i);u&&(i.contextUrl=u.target)}a(null,i)},error:function(e,t,n){a(new Oe("URL could not be dereferenced, an error occurred.","jsonld.LoadDocumentError",{code:"loading document failed",url:r,cause:n}),{contextUrl:null,documentUrl:r,document:null})}})}t=t||{};var a=new n.RequestQueue;return("usePromise"in t?t.usePromise:"undefined"!=typeof Promise)?a.wrapLoader(function(e){return n.promisify(r,e)}):a.wrapLoader(r)},n.documentLoaders.node=function(e){function t(u,s,c){function d(e,r,o){if(f={contextUrl:null,documentUrl:u,document:o||null},e)return c(new Oe("URL could not be dereferenced, an error occurred.","jsonld.LoadDocumentError",{code:"loading document failed",url:u,cause:e}),f);var i=l.STATUS_CODES[r.statusCode];if(r.statusCode>=400)return c(new Oe("URL could not be dereferenced: "+i,"jsonld.InvalidUrl",{code:"loading document failed",url:u,httpStatusCode:r.statusCode}),f);if(r.headers.link&&"application/ld+json"!==r.headers["content-type"]){var d=n.parseLinkHeader(r.headers.link)[Ie];if(A(d))return c(new Oe("URL could not be dereferenced, it has more than one associated HTTP Link Header.","jsonld.InvalidUrl",{code:"multiple context link headers",url:u}),f);d&&(f.contextUrl=d.target)}if(r.statusCode>=300&&r.statusCode<400&&r.headers.location)return s.length===a?c(new Oe("URL could not be dereferenced; there were too many redirects.","jsonld.TooManyRedirects",{code:"loading document failed",url:u,httpStatusCode:r.statusCode,redirects:s}),f):-1!==s.indexOf(u)?c(new Oe("URL could not be dereferenced; infinite redirection was detected.","jsonld.InfiniteRedirectDetected",{code:"recursive context inclusion",url:u,httpStatusCode:r.statusCode,redirects:s}),f):(s.push(u),t(r.headers.location,s,c));s.push(u),c(e,f)}if(0!==u.indexOf("http:")&&0!==u.indexOf("https:"))return c(new Oe('URL could not be dereferenced; only "http" and "https" URLs are supported.',"jsonld.InvalidUrl",{code:"loading document failed",url:u}),{contextUrl:null,documentUrl:u,document:null});if(e.secure&&0!==u.indexOf("https"))return c(new Oe('URL could not be dereferenced; secure mode is enabled and the URL\'s scheme is not "https".',"jsonld.InvalidUrl",{code:"loading document failed",url:u}),{contextUrl:null,documentUrl:u,document:null});var f=null;if(null!==f)return c(null,f);var p={Accept:i};for(var h in e.headers)p[h]=e.headers[h];o({url:u,headers:p,strictSSL:r,followRedirect:!1},d)}e=e||{};var r=!("strictSSL"in e)||e.strictSSL,a="maxRedirects"in e?e.maxRedirects:-1,o="request"in e?e.request:require("request"),i="application/ld+json, application/json",l=require("http"),u=new n.RequestQueue;if(e.usePromise)return u.wrapLoader(function(e){return n.promisify(t,e,[])});var s=e.headers||{};if("Accept"in s||"accept"in s)throw new RangeError('Accept header may not be specified as an option; only "'+i+'" is supported.');return u.wrapLoader(function(e,n){t(e,[],n)})},n.documentLoaders.xhr=function(e){function t(t,a){if(0!==t.indexOf("http:")&&0!==t.indexOf("https:"))return a(new Oe('URL could not be dereferenced; only "http" and "https" URLs are supported.',"jsonld.InvalidUrl",{code:"loading document failed",url:t}),{contextUrl:null,documentUrl:t,document:null});if(e.secure&&0!==t.indexOf("https"))return a(new Oe('URL could not be dereferenced; secure mode is enabled and the URL\'s scheme is not "https".',"jsonld.InvalidUrl",{code:"loading document failed",url:t}),{contextUrl:null,documentUrl:t,document:null});var o=e.xhr||XMLHttpRequest,i=new o;i.onload=function(){if(i.status>=400)return a(new Oe("URL could not be dereferenced: "+i.statusText,"jsonld.LoadDocumentError",{code:"loading document failed",url:t,httpStatusCode:i.status}),{contextUrl:null,documentUrl:t,document:null});var e,o={contextUrl:null,documentUrl:t,document:i.response},l=i.getResponseHeader("Content-Type");if(r.test(i.getAllResponseHeaders())&&(e=i.getResponseHeader("Link")),e&&"application/ld+json"!==l){if(e=n.parseLinkHeader(e)[Ie],A(e))return a(new Oe("URL could not be dereferenced, it has more than one associated HTTP Link Header.","jsonld.InvalidUrl",{code:"multiple context link headers",url:t}),o);e&&(o.contextUrl=e.target)}a(null,o)},i.onerror=function(){a(new Oe("URL could not be dereferenced, an error occurred.","jsonld.LoadDocumentError",{code:"loading document failed",url:t}),{contextUrl:null,documentUrl:t,document:null})},i.open("GET",t,!0),i.setRequestHeader("Accept","application/ld+json, application/json"),i.send()}e=e||{};var r=/(^|(\r\n))link:/i,a=new n.RequestQueue;return("usePromise"in e?e.usePromise:"undefined"!=typeof Promise)?a.wrapLoader(function(e){return n.promisify(t,e)}):a.wrapLoader(t)},n.useDocumentLoader=function(e){if(!(e in n.documentLoaders))throw new Oe('Unknown document loader type: "'+e+'"',"jsonld.UnknownDocumentLoader",{type:e});n.documentLoader=n.documentLoaders[e].apply(n,Array.prototype.slice.call(arguments,1))},n.processContext=function(e,t){var r={},a=2;arguments.length>3&&(r=arguments[2]||{},a+=1);var o=arguments[a];if("base"in r||(r.base=""),"documentLoader"in r||(r.documentLoader=n.loadDocument),null===t)return o(null,R(r));t=W(t),T(t)&&"@context"in t||(t={"@context":t}),Z(t,r,function(t,n){if(t)return o(t);try{n=(new Ee).processContext(e,n,r)}catch(e){return o(e)}o(null,n)})},n.hasProperty=function(e,t){var n=!1;if(t in e){var r=e[t];n=!A(r)||r.length>0}return n},n.hasValue=function(e,t,r){var a=!1;if(n.hasProperty(e,t)){var o=e[t],i=X(o);if(A(o)||i){i&&(o=o["@list"]);for(var l=0;l<o.length;++l)if(n.compareValues(r,o[l])){a=!0;break}}else A(r)||(a=n.compareValues(r,o))}return a},n.addValue=function(e,t,r,a){if(a=a||{},"propertyIsArray"in a||(a.propertyIsArray=!1),"allowDuplicate"in a||(a.allowDuplicate=!0),A(r)){0!==r.length||!a.propertyIsArray||t in e||(e[t]=[]);for(var o=0;o<r.length;++o)n.addValue(e,t,r[o],a)}else if(t in e){var i=!a.allowDuplicate&&n.hasValue(e,t,r);A(e[t])||i&&!a.propertyIsArray||(e[t]=[e[t]]),i||e[t].push(r)}else e[t]=a.propertyIsArray?[r]:r},n.getValues=function(e,t){var n=e[t]||[];return A(n)||(n=[n]),n},n.removeProperty=function(e,t){delete e[t]},n.removeValue=function(e,t,r,a){"propertyIsArray"in(a=a||{})||(a.propertyIsArray=!1);var o=n.getValues(e,t).filter(function(e){return!n.compareValues(e,r)});0===o.length?n.removeProperty(e,t):1!==o.length||a.propertyIsArray?e[t]=o:e[t]=o[0]},n.compareValues=function(e,t){return e===t||(!(!Q(e)||!Q(t)||e["@value"]!==t["@value"]||e["@type"]!==t["@type"]||e["@language"]!==t["@language"]||e["@index"]!==t["@index"])||!!(T(e)&&"@id"in e&&T(t)&&"@id"in t)&&e["@id"]===t["@id"])},n.getContextValue=function(e,t,n){var r=null;if(null===t)return r;if("@language"===n&&n in e&&(r=e[n]),e.mappings[t]){var a=e.mappings[t];M(n)?r=a:n in a&&(r=a[n])}return r};var ue={};if(n.registerRDFParser=function(e,t){ue[e]=t},n.unregisterRDFParser=function(e){delete ue[e]},e){if(void 0===se)var se=null;if(void 0===ce)var ce={ELEMENT_NODE:1,ATTRIBUTE_NODE:2,TEXT_NODE:3,CDATA_SECTION_NODE:4,ENTITY_REFERENCE_NODE:5,ENTITY_NODE:6,PROCESSING_INSTRUCTION_NODE:7,COMMENT_NODE:8,DOCUMENT_NODE:9,DOCUMENT_TYPE_NODE:10,DOCUMENT_FRAGMENT_NODE:11,NOTATION_NODE:12}}var de="http://www.w3.org/2001/XMLSchema#boolean",fe="http://www.w3.org/2001/XMLSchema#double",pe="http://www.w3.org/2001/XMLSchema#integer",he="http://www.w3.org/2001/XMLSchema#string",ve="http://www.w3.org/1999/02/22-rdf-syntax-ns#",ge=ve+"first",ye=ve+"rest",me=ve+"nil",xe=ve+"type",be=ve+"PlainLiteral",we=ve+"XMLLiteral",je=ve+"object",ke=ve+"langString",Ie="http://www.w3.org/ns/json-ld#context",Le=10,Oe=function(t,n,r){e?(Error.call(this),Error.captureStackTrace(this,this.constructor)):"undefined"!=typeof Error&&(this.stack=(new Error).stack),this.name=n||"jsonld.Error",this.message=t||"An unspecified JSON-LD error occurred.",this.details=r||{}};e?require("util").inherits(Oe,Error):"undefined"!=typeof Error&&(Oe.prototype=new Error);var Ee=function(){};Ee.prototype.compact=function(e,t,r,a){if(A(r)){for(var o=[],i=0;i<r.length;++i){var l=this.compact(e,t,r[i],a);null!==l&&o.push(l)}if(a.compactArrays&&1===o.length){var u=n.getContextValue(e,t,"@container");null===u&&(o=o[0])}return o}if(T(r)){if(a.link&&"@id"in r&&r["@id"]in a.link)for(var s=a.link[r["@id"]],i=0;i<s.length;++i)if(s[i].expanded===r)return s[i].compacted;if(Q(r)||H(r)){var o=E(e,t,r);return a.link&&H(r)&&(r["@id"]in a.link||(a.link[r["@id"]]=[]),a.link[r["@id"]].push({expanded:r,compacted:o})),o}var c="@reverse"===t,o={};a.link&&"@id"in r&&(r["@id"]in a.link||(a.link[r["@id"]]=[]),a.link[r["@id"]].push({expanded:r,compacted:o}));for(var d=Object.keys(r).sort(),f=0;f<d.length;++f){var p=d[f],h=r[p];if("@id"!==p&&"@type"!==p)if("@reverse"!==p)if("@index"!==p)if("@graph"!==p&&"@list"!==p&&_(p)){var v=O(e,p);n.addValue(o,v,h)}else{if(0===h.length){var g=O(e,p,h,{vocab:!0},c);n.addValue(o,g,h,{propertyIsArray:!0})}for(var y=0;y<h.length;++y){var m=h[y],g=O(e,p,m,{vocab:!0},c),u=n.getContextValue(e,g,"@container"),x=X(m),b=null;x&&(b=m["@list"]);var w=this.compact(e,g,x?b:m,a);if(x)if(A(w)||(w=[w]),"@list"!==u){var j={};j[O(e,"@list")]=w,w=j,"@index"in m&&(w[O(e,"@index")]=m["@index"])}else if(g in o)throw new Oe('JSON-LD compact error; property has a "@list" @container rule but there is more than a single @list that matches the compacted term in the document. Compaction might mix unwanted items into the list.',"jsonld.SyntaxError",{code:"compaction to list of lists"});if("@language"===u||"@index"===u){var k;g in o?k=o[g]:o[g]=k={},"@language"===u&&Q(w)&&(w=w["@value"]),n.addValue(k,m[u],w)}else{var I=!a.compactArrays||"@set"===u||"@list"===u||A(w)&&0===w.length||"@list"===p||"@graph"===p;n.addValue(o,g,w,{propertyIsArray:I})}}}else{var u=n.getContextValue(e,t,"@container");if("@index"===u)continue;var v=O(e,p);n.addValue(o,v,h)}else{var L=this.compact(e,"@reverse",h,a);for(var S in L)if(e.mappings[S]&&e.mappings[S].reverse){var D=L[S],u=n.getContextValue(e,S,"@container"),N="@set"===u||!a.compactArrays;n.addValue(o,S,D,{propertyIsArray:N}),delete L[S]}if(Object.keys(L).length>0){var v=O(e,p);n.addValue(o,v,L)}}else{var L;if(J(h))L=O(e,h,null,{vocab:"@type"===p});else{L=[];for(var y=0;y<h.length;++y)L.push(O(e,h[y],null,{vocab:!0}))}var v=O(e,p),I=A(L)&&0===h.length;n.addValue(o,v,L,{propertyIsArray:I})}}return o}return r},Ee.prototype.expand=function(e,t,r,o,l){var u=this;if(null===r||void 0===r)return null;if(!A(r)&&!T(r))return l||null!==t&&"@graph"!==D(e,t,{vocab:!0})?i(e,t,r):null;if(A(r)){var s=[],c=n.getContextValue(e,t,"@container");l=l||"@list"===c;for(var d=0;d<r.length;++d){var f=u.expand(e,t,r[d],o);if(l&&(A(f)||X(f)))throw new Oe("Invalid JSON-LD syntax; lists of lists are not permitted.","jsonld.SyntaxError",{code:"list of lists"});null!==f&&(A(f)?s=s.concat(f):s.push(f))}return s}"@context"in r&&(e=u.processContext(e,r["@context"],o));for(var p=D(e,t,{vocab:!0}),s={},h=Object.keys(r).sort(),v=0;v<h.length;++v){var g,y=h[v],m=r[y];if("@context"!==y){var x=D(e,y,{vocab:!0});if(null!==x&&($(x)||_(x))){if(_(x)){if("@reverse"===p)throw new Oe("Invalid JSON-LD syntax; a keyword cannot be used as a @reverse property.","jsonld.SyntaxError",{code:"invalid reverse property map",value:m});if(x in s)throw new Oe("Invalid JSON-LD syntax; colliding keywords detected.","jsonld.SyntaxError",{code:"colliding keywords",keyword:x})}if("@id"===x&&!J(m)){if(!o.isFrame)throw new Oe('Invalid JSON-LD syntax; "@id" value must a string.',"jsonld.SyntaxError",{code:"invalid @id value",value:m});if(!T(m))throw new Oe('Invalid JSON-LD syntax; "@id" value must be a string or an object.',"jsonld.SyntaxError",{code:"invalid @id value",value:m})}if("@type"===x&&q(m),"@graph"===x&&!T(m)&&!A(m))throw new Oe('Invalid JSON-LD syntax; "@graph" value must not be an object or an array.',"jsonld.SyntaxError",{code:"invalid @graph value",value:m});if("@value"===x&&(T(m)||A(m)))throw new Oe('Invalid JSON-LD syntax; "@value" value must not be an object or an array.',"jsonld.SyntaxError",{code:"invalid value object value",value:m});if("@language"===x){if(null===m)continue;if(!J(m))throw new Oe('Invalid JSON-LD syntax; "@language" value must be a string.',"jsonld.SyntaxError",{code:"invalid language-tagged string",value:m});m=m.toLowerCase()}if("@index"===x&&!J(m))throw new Oe('Invalid JSON-LD syntax; "@index" value must be a string.',"jsonld.SyntaxError",{code:"invalid @index value",value:m});if("@reverse"!==x){var c=n.getContextValue(e,y,"@container");if("@language"===c&&T(m))g=a(m);else if("@index"===c&&T(m))g=function(t){for(var n=[],r=Object.keys(m).sort(),a=0;a<r.length;++a){var i=r[a],l=m[i];A(l)||(l=[l]),l=u.expand(e,t,l,o,!1);for(var s=0;s<l.length;++s){var c=l[s];"@index"in c||(c["@index"]=i),n.push(c)}}return n}(y);else{var b="@list"===x;if(b||"@set"===x){var w=t;if(b&&"@graph"===p&&(w=null),g=u.expand(e,w,m,o,b),b&&X(g))throw new Oe("Invalid JSON-LD syntax; lists of lists are not permitted.","jsonld.SyntaxError",{code:"list of lists"})}else g=u.expand(e,y,m,o,!1)}if(null!==g||"@value"===x)if("@list"===x||X(g)||"@list"!==c||(g=A(g)?g:[g],g={"@list":g}),e.mappings[y]&&e.mappings[y].reverse){var j=s["@reverse"]=s["@reverse"]||{};A(g)||(g=[g]);for(var k=0;k<g.length;++k){var I=g[k];if(Q(I)||X(I))throw new Oe('Invalid JSON-LD syntax; "@reverse" value must not be a @value or an @list.',"jsonld.SyntaxError",{code:"invalid reverse property value",value:g});n.addValue(j,x,I,{propertyIsArray:!0})}}else{var L=-1===["@index","@id","@type","@value","@language"].indexOf(x);n.addValue(s,x,g,{propertyIsArray:L})}}else{if(!T(m))throw new Oe('Invalid JSON-LD syntax; "@reverse" value must be an object.',"jsonld.SyntaxError",{code:"invalid @reverse value",value:m});if("@reverse"in(g=u.expand(e,"@reverse",m,o)))for(var O in g["@reverse"])n.addValue(s,O,g["@reverse"][O],{propertyIsArray:!0});var j=s["@reverse"]||null;for(var O in g)if("@reverse"!==O){null===j&&(j=s["@reverse"]={}),n.addValue(j,O,[],{propertyIsArray:!0});for(var E=g[O],k=0;k<E.length;++k){var I=E[k];if(Q(I)||X(I))throw new Oe('Invalid JSON-LD syntax; "@reverse" value must not be a @value or an @list.',"jsonld.SyntaxError",{code:"invalid reverse property value",value:g});n.addValue(j,O,I,{propertyIsArray:!0})}}}}}}h=Object.keys(s);var S=h.length;if("@value"in s){if("@type"in s&&"@language"in s)throw new Oe('Invalid JSON-LD syntax; an element containing "@value" may not contain both "@type" and "@language".',"jsonld.SyntaxError",{code:"invalid value object",element:s});var N=S-1;if("@type"in s&&(N-=1),"@index"in s&&(N-=1),"@language"in s&&(N-=1),0!==N)throw new Oe('Invalid JSON-LD syntax; an element containing "@value" may only have an "@index" property and at most one other property which can be "@type" or "@language".',"jsonld.SyntaxError",{code:"invalid value object",element:s});if(null===s["@value"])s=null;else{if("@language"in s&&!J(s["@value"]))throw new Oe("Invalid JSON-LD syntax; only strings may be language-tagged.","jsonld.SyntaxError",{code:"invalid language-tagged value",element:s});if("@type"in s&&(!$(s["@type"])||0===s["@type"].indexOf("_:")))throw new Oe('Invalid JSON-LD syntax; an element containing "@value" and "@type" must have an absolute IRI for the value of "@type".',"jsonld.SyntaxError",{code:"invalid typed value",element:s})}}else if("@type"in s&&!A(s["@type"]))s["@type"]=[s["@type"]];else if("@set"in s||"@list"in s){if(S>1&&!(2===S&&"@index"in s))throw new Oe('Invalid JSON-LD syntax; if an element has the property "@set" or "@list", then it can have at most one other property that is "@index".',"jsonld.SyntaxError",{code:"invalid set or list object",element:s});"@set"in s&&(s=s["@set"],h=Object.keys(s),S=h.length)}else 1===S&&"@language"in s&&(s=null);return!T(s)||o.keepFreeFloatingNodes||l||null!==t&&"@graph"!==p||(0===S||"@value"in s||"@list"in s||1===S&&"@id"in s)&&(s=null),s},Ee.prototype.createNodeMap=function(e,t){t=t||{};var n=t.namer||t.issuer||new re("_:b"),r={"@default":{}};return f(e,r,"@default",n),p(r)},Ee.prototype.flatten=function(e){for(var t=this.createNodeMap(e),n=[],r=Object.keys(t).sort(),a=0;a<r.length;++a){var o=t[r[a]];H(o)||n.push(o)}return n},Ee.prototype.frame=function(e,t,n){var r={options:n,graphs:{"@default":{},"@merged":{}},subjectStack:[],link:{}},a=new re("_:b");f(e,r.graphs,"@merged",a),r.subjects=r.graphs["@merged"];var o=[];return h(r,Object.keys(r.subjects).sort(),t,o,null),o},Ee.prototype.normalize=function(e,t,n){return"URDNA2015"===t.algorithm?new Se(t).main(e,n):"URGNA2012"===t.algorithm?new De(t).main(e,n):void n(new Error("Invalid RDF Dataset Normalization algorithm: "+t.algorithm))},Ee.prototype.fromRDF=function(e,t,r){var a={},o={"@default":a},i={};for(var l in e){var u=e[l];l in o||(o[l]={}),"@default"===l||l in a||(a[l]={"@id":l});for(var s=o[l],d=0;d<u.length;++d){var f=u[d],p=f.subject.value,h=f.predicate.value,v=f.object;p in s||(s[p]={"@id":p});var g=s[p],y="IRI"===v.type||"blank node"===v.type;if(!y||v.value in s||(s[v.value]={"@id":v.value}),h!==xe||t.useRdfType||!y){var m=c(v,t.useNativeTypes);if(n.addValue(g,h,m,{propertyIsArray:!0}),y)if(v.value===me){var x=s[v.value];"usages"in x||(x.usages=[]),x.usages.push({node:g,property:h,value:m})}else v.value in i?i[v.value]=!1:i[v.value]={node:g,property:h,value:m}}else n.addValue(g,"@type",v.value,{propertyIsArray:!0})}}for(var l in o){var b=o[l];if(me in b){for(var w=b[me],j=0;j<w.usages.length;++j){for(var k=w.usages[j],g=k.node,I=k.property,L=k.value,O=[],E=[],S=Object.keys(g).length;I===ye&&T(i[g["@id"]])&&A(g[ge])&&1===g[ge].length&&A(g[ye])&&1===g[ye].length&&(3===S||4===S&&A(g["@type"])&&1===g["@type"].length&&"http://www.w3.org/1999/02/22-rdf-syntax-ns#List"===g["@type"][0])&&(O.push(g[ge][0]),E.push(g["@id"]),k=i[g["@id"]],g=k.node,I=k.property,L=k.value,S=Object.keys(g).length,0===g["@id"].indexOf("_:")););if(I===ge){if(g["@id"]===me)continue;L=b[L["@id"]][ye][0],O.pop(),E.pop()}delete L["@id"],L["@list"]=O.reverse();for(var D=0;D<E.length;++D)delete b[E[D]]}delete w.usages}}for(var N=[],C=Object.keys(a).sort(),j=0;j<C.length;++j){var R=C[j],g=a[R];if(R in o)for(var u=g["@graph"]=[],b=o[R],_=Object.keys(b).sort(),U=0;U<_.length;++U){var q=b[_[U]];H(q)||u.push(q)}H(g)||N.push(g)}r(null,N)},Ee.prototype.toRDF=function(e,t){var n=new re("_:b"),r={"@default":{}};f(e,r,"@default",n);for(var a={},o=Object.keys(r).sort(),i=0;i<o.length;++i){var u=o[i];("@default"===u||$(u))&&(a[u]=l(r[u],n,t))}return a},Ee.prototype.processContext=function(e,t,r){T(t)&&"@context"in t&&A(t["@context"])&&(t=t["@context"]);var a=A(t)?t:[t];if(0===a.length)return e.clone();for(var o=e,i=0;i<a.length;++i){var l=a[i];if(null!==l){if(T(l)&&"@context"in l&&(l=l["@context"]),!T(l))throw new Oe("Invalid JSON-LD syntax; @context must be an object.","jsonld.SyntaxError",{code:"invalid local context",context:l});if(n.cache.activeCtx){var u=n.cache.activeCtx.get(e,l);if(u){o=e=u;continue}}e=o,o=o.clone();var s={};if("@base"in l){var c=l["@base"];if(null===c)c=null;else{if(!J(c))throw new Oe('Invalid JSON-LD syntax; the value of "@base" in a @context must be a string or null.',"jsonld.SyntaxError",{code:"invalid base IRI",context:l});if(""!==c&&!$(c))throw new Oe('Invalid JSON-LD syntax; the value of "@base" in a @context must be an absolute IRI or the empty string.',"jsonld.SyntaxError",{code:"invalid base IRI",context:l})}null!==c&&(c=n.url.parse(c||"")),o["@base"]=c,s["@base"]=!0}if("@vocab"in l){var d=l["@vocab"];if(null===d)delete o["@vocab"];else{if(!J(d))throw new Oe('Invalid JSON-LD syntax; the value of "@vocab" in a @context must be a string or null.',"jsonld.SyntaxError",{code:"invalid vocab mapping",context:l});if(!$(d))throw new Oe('Invalid JSON-LD syntax; the value of "@vocab" in a @context must be an absolute IRI.',"jsonld.SyntaxError",{code:"invalid vocab mapping",context:l});o["@vocab"]=d}s["@vocab"]=!0}if("@language"in l){var d=l["@language"];if(null===d)delete o["@language"];else{if(!J(d))throw new Oe('Invalid JSON-LD syntax; the value of "@language" in a @context must be a string or null.',"jsonld.SyntaxError",{code:"invalid default language",context:l});o["@language"]=d.toLowerCase()}s["@language"]=!0}for(var f in l)S(o,l,f,s);n.cache.activeCtx&&n.cache.activeCtx.set(e,l,o)}else o=e=R(r)}return o};var Se=function(){var e={subject:"s",object:"o",name:"g"},t=function(e){e=e||{},this.name="URDNA2015",this.options=e,this.blankNodeInfo={},this.hashToBlankNodes={},this.canonicalIssuer=new re("_:c14n"),this.quads=[],this.schedule={},this.schedule.MAX_DEPTH="maxCallStackDepth"in e?e.maxCallStackDepth:500,this.schedule.MAX_TOTAL_DEPTH="maxTotalCallStackDepth"in e?e.maxCallStackDepth:4294967295,this.schedule.depth=0,this.schedule.totalDepth=0,this.schedule.timeSlice="timeSlice"in e?e.timeSlice:10};return t.prototype.doWork=function(e,t){var r=this.schedule
;if(r.totalDepth>=r.MAX_TOTAL_DEPTH)return t(new Error("Maximum total call stack depth exceeded; normalization aborting."));!function a(){if(r.depth===r.MAX_DEPTH)return r.depth=0,r.running=!1,n.nextTick(a);var o=(new Date).getTime();if(r.running||(r.start=(new Date).getTime(),r.deadline=r.start+r.timeSlice),o<r.deadline)return r.running=!0,r.depth++,r.totalDepth++,e(function(e,n){r.depth--,r.totalDepth--,t(e,n)});r.depth=0,r.running=!1,n.setImmediate(a)}()},t.prototype.forEach=function(e,t,n){var r,a,o=this,i=0;if(A(e))a=e.length,r=function(){return i!==a&&(r.value=e[i++],r.key=i,!0)};else{var l=Object.keys(e);a=l.length,r=function(){return i!==a&&(r.key=l[i++],r.value=e[r.key],!0)}}!function e(a,i){return a?n(a):r()?o.doWork(function(){t(r.value,r.key,e)}):void n()}()},t.prototype.waterfall=function(e,t){var n=this;n.forEach(e,function(e,t,r){n.doWork(e,r)},t)},t.prototype.whilst=function(e,t,n){var r=this;!function a(o){return o?n(o):e()?void r.doWork(t,a):n()}()},t.prototype.main=function(e,t){var n=this;n.schedule.start=(new Date).getTime();var r;if(n.options.format&&"application/nquads"!==n.options.format)return t(new Oe("Unknown output format.","jsonld.UnknownFormat",{format:n.options.format}));var a={};n.waterfall([function(t){n.forEach(e,function(e,t,r){"@default"===t&&(t=null),n.forEach(e,function(e,r,o){null!==t&&(0===t.indexOf("_:")?e.name={type:"blank node",value:t}:e.name={type:"IRI",value:t}),n.quads.push(e),n.forEachComponent(e,function(t){if("blank node"===t.type){var r=t.value;r in n.blankNodeInfo?n.blankNodeInfo[r].quads.push(e):(a[r]=!0,n.blankNodeInfo[r]={quads:[e]})}}),o()},r)},t)},function(e){var t=!0;n.whilst(function(){return t},function(e){t=!1,n.hashToBlankNodes={},n.waterfall([function(e){n.forEach(a,function(e,t,r){n.hashFirstDegreeQuads(t,function(e,a){if(e)return r(e);a in n.hashToBlankNodes?n.hashToBlankNodes[a].push(t):n.hashToBlankNodes[a]=[t],r()})},e)},function(e){var r=Object.keys(n.hashToBlankNodes).sort();n.forEach(r,function(e,r,o){var i=n.hashToBlankNodes[e];if(i.length>1)return o();var l=i[0];n.canonicalIssuer.getId(l),delete a[l],delete n.hashToBlankNodes[e],t=!0,o()},e)}],e)},e)},function(e){var t=Object.keys(n.hashToBlankNodes).sort();n.forEach(t,function(e,t,r){var a=[],o=n.hashToBlankNodes[e];n.waterfall([function(e){n.forEach(o,function(e,t,r){if(n.canonicalIssuer.hasId(e))return r();var o=new re("_:b");o.getId(e),n.hashNDegreeQuads(e,o,function(e,t){if(e)return r(e);a.push(t),r()})},e)},function(e){a.sort(function(e,t){return e.hash<t.hash?-1:e.hash>t.hash?1:0}),n.forEach(a,function(e,t,r){for(var a in e.issuer.existing)n.canonicalIssuer.getId(a);r()},e)}],r)},e)},function(e){var t=[];n.waterfall([function(e){n.forEach(n.quads,function(e,r,a){n.forEachComponent(e,function(e){"blank node"===e.type&&0!==e.value.indexOf(n.canonicalIssuer.prefix)&&(e.value=n.canonicalIssuer.getId(e.value))}),t.push(te(e)),a()},e)},function(e){if(t.sort(),"application/nquads"===n.options.format)return r=t.join(""),e();r=K(t.join("")),e()}],e)}],function(e){t(e,r)})},t.prototype.hashFirstDegreeQuads=function(e,t){var n=this,r=n.blankNodeInfo[e];if("hash"in r)return t(null,r.hash);var a=[],o=r.quads;n.forEach(o,function(t,r,o){var i={predicate:t.predicate};n.forEachComponent(t,function(t,r){i[r]=n.modifyFirstDegreeComponent(e,t,r)}),a.push(te(i)),o()},function(e){if(e)return t(e);a.sort(),r.hash=Ce.hashNQuads(n.name,a),t(null,r.hash)})},t.prototype.modifyFirstDegreeComponent=function(e,t){return"blank node"!==t.type?t:(t=W(t),t.value=t.value===e?"_:a":"_:z",t)},t.prototype.hashRelatedBlankNode=function(e,t,n,r,a){var o,i=this;i.waterfall([function(t){return i.canonicalIssuer.hasId(e)?(o=i.canonicalIssuer.getId(e),t()):n.hasId(e)?(o=n.getId(e),t()):void i.hashFirstDegreeQuads(e,function(e,n){if(e)return t(e);o=n,t()})}],function(e){if(e)return a(e);var n=new Ce(i.name);return n.update(r),"g"!==r&&n.update(i.getRelatedPredicate(t)),n.update(o),a(null,n.digest())})},t.prototype.getRelatedPredicate=function(e){return"<"+e.predicate.value+">"},t.prototype.hashNDegreeQuads=function(e,t,n){var r,a=this,o=new Ce(a.name);a.waterfall([function(n){a.createHashToRelated(e,t,function(e,t){if(e)return n(e);r=t,n()})},function(e){var n=Object.keys(r).sort();a.forEach(n,function(e,n,i){o.update(e);var l,u="",s=new Ne(r[e]);a.whilst(function(){return s.hasNext()},function(e){var n=s.next(),r=t.clone(),o="",i=[];a.waterfall([function(t){a.forEach(n,function(t,n,l){if(a.canonicalIssuer.hasId(t)?o+=a.canonicalIssuer.getId(t):(r.hasId(t)||i.push(t),o+=r.getId(t)),0!==u.length&&o.length>=u.length&&o>u)return e();l()},t)},function(t){a.forEach(i,function(t,n,i){a.hashNDegreeQuads(t,r,function(n,a){return n?i(n):(o+=r.getId(t),o+="<"+a.hash+">",r=a.issuer,0!==u.length&&o.length>=u.length&&o>u?e():void i())})},t)},function(e){(0===u.length||o<u)&&(u=o,l=r),e()}],e)},function(e){if(e)return i(e);o.update(u),t=l,i()})},e)}],function(e){n(e,{hash:o.digest(),issuer:t})})},t.prototype.createHashToRelated=function(t,n,r){var a=this,o={},i=a.blankNodeInfo[t].quads;a.forEach(i,function(r,i,l){a.forEach(r,function(i,l,u){if("predicate"===l||"blank node"!==i.type||i.value===t)return u();var s=i.value,c=e[l];a.hashRelatedBlankNode(s,r,n,c,function(e,t){if(e)return u(e);t in o?o[t].push(s):o[t]=[s],u()})},l)},function(e){r(e,o)})},t.prototype.forEachComponent=function(e,t){for(var n in e)"predicate"!==n&&t(e[n],n,e)},t}(),De=function(){var e=function(e){Se.call(this,e),this.name="URGNA2012"};return e.prototype=new Se,e.prototype.modifyFirstDegreeComponent=function(e,t,n){return"blank node"!==t.type?t:(t=W(t),t.value="name"===n?"_:g":t.value===e?"_:a":"_:z",t)},e.prototype.getRelatedPredicate=function(e){return e.predicate.value},e.prototype.createHashToRelated=function(e,t,n){var r=this,a={},o=r.blankNodeInfo[e].quads;r.forEach(o,function(n,o,i){var l,u;if("blank node"===n.subject.type&&n.subject.value!==e)u=n.subject.value,l="p";else{if("blank node"!==n.object.type||n.object.value===e)return i();u=n.object.value,l="r"}r.hashRelatedBlankNode(u,n,t,l,function(e,t){t in a?a[t].push(u):a[t]=[u],i()})},function(e){n(e,a)})},e}();Object.keys||(Object.keys=function(e){if(e!==Object(e))throw new TypeError("Object.keys called on non-object");var t=[];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.push(n);return t}),n.registerRDFParser("application/nquads",K),n.registerRDFParser("rdfa-api",ne),n.IdentifierIssuer=re,n.UniqueNamer=re,re.prototype.clone=function(){var e=new re(this.prefix);return e.counter=this.counter,e.existing=W(this.existing),e},re.prototype.getId=function(e){if(e&&e in this.existing)return this.existing[e];var t=this.prefix+this.counter;return this.counter+=1,e&&(this.existing[e]=t),t},re.prototype.getName=re.prototype.getName,re.prototype.hasId=function(e){return e in this.existing},re.prototype.isNamed=re.prototype.hasId;var Ne=function(e){this.list=e.sort(),this.done=!1,this.left={};for(var t=0;t<e.length;++t)this.left[e[t]]=!0};Ne.prototype.hasNext=function(){return!this.done},Ne.prototype.next=function(){for(var e=this.list.slice(),t=null,n=0,r=this.list.length,a=0;a<r;++a){var o=this.list[a],i=this.left[o];(null===t||o>t)&&(i&&a>0&&o>this.list[a-1]||!i&&a<r-1&&o>this.list[a+1])&&(t=o,n=a)}if(null===t)this.done=!0;else{var l=this.left[t]?n-1:n+1;this.list[n]=this.list[l],this.list[l]=t;for(var a=0;a<r;++a)this.list[a]>t&&(this.left[this.list[a]]=!this.left[this.list[a]])}return e};var Ce=function(e){if(!(this instanceof Ce))return new Ce(e);if(-1===["URDNA2015","URGNA2012"].indexOf(e))throw new Error("Invalid RDF Dataset Normalization algorithm: "+e);Ce._init.call(this,e)};if(Ce.hashNQuads=function(e,t){for(var n=new Ce(e),r=0;r<t.length;++r)n.update(t[r]);return n.digest()},function(e){if(e){var t=require("crypto");return Ce._init=function(e){e="URDNA2015"===e?"sha256":"sha1",this.md=t.createHash(e)},Ce.prototype.update=function(e){return this.md.update(e,"utf8")},void(Ce.prototype.digest=function(){return this.md.digest("hex")})}Ce._init=function(e){e="URDNA2015"===e?new a.Algorithm:new r.Algorithm,this.md=new n(e)},Ce.prototype.update=function(e){return this.md.update(e)},Ce.prototype.digest=function(){return this.md.digest().toHex()};var n=function(e){if(!(this instanceof n))return new n(e);if(this._algorithm=e,!n._padding||n._padding.length<this._algorithm.blockSize){n._padding=String.fromCharCode(128);for(var t=String.fromCharCode(0),r=64;r>0;)1&r&&(n._padding+=t),(r>>>=1)>0&&(t+=t)}this.start()};n.prototype.start=function(){this.messageLength=0,this.fullMessageLength=[];for(var e=this._algorithm.messageLengthSize/4,t=0;t<e;++t)this.fullMessageLength.push(0);return this._input=new n.ByteBuffer,this.state=this._algorithm.start(),this},n.prototype.update=function(e){e=new n.ByteBuffer(unescape(encodeURIComponent(e))),this.messageLength+=e.length();var t=e.length();t=[t/4294967296>>>0,t>>>0];for(var r=this.fullMessageLength.length-1;r>=0;--r)this.fullMessageLength[r]+=t[1],t[1]=t[0]+(this.fullMessageLength[r]/4294967296>>>0),this.fullMessageLength[r]=this.fullMessageLength[r]>>>0,t[0]=t[1]/4294967296>>>0;for(this._input.putBytes(e.bytes());this._input.length()>=this._algorithm.blockSize;)this.state=this._algorithm.digest(this.state,this._input);return(this._input.read>2048||0===this._input.length())&&this._input.compact(),this},n.prototype.digest=function(){var e=new n.ByteBuffer;e.putBytes(this._input.bytes());var t=this.fullMessageLength[this.fullMessageLength.length-1]+this._algorithm.messageLengthSize,r=t&this._algorithm.blockSize-1;e.putBytes(n._padding.substr(0,this._algorithm.blockSize-r));for(var a=new n.ByteBuffer,o=0;o<this.fullMessageLength.length;++o)a.putInt32(this.fullMessageLength[o]<<3|this.fullMessageLength[o+1]>>>28);this._algorithm.writeMessageLength(e,a);var i=this._algorithm.digest(this.state.copy(),e),l=new n.ByteBuffer;return i.write(l),l},n.ByteBuffer=function(e){this.data="string"==typeof e?e:"",this.read=0},n.ByteBuffer.prototype.putInt32=function(e){this.data+=String.fromCharCode(e>>24&255)+String.fromCharCode(e>>16&255)+String.fromCharCode(e>>8&255)+String.fromCharCode(255&e)},n.ByteBuffer.prototype.getInt32=function(){var e=this.data.charCodeAt(this.read)<<24^this.data.charCodeAt(this.read+1)<<16^this.data.charCodeAt(this.read+2)<<8^this.data.charCodeAt(this.read+3);return this.read+=4,e},n.ByteBuffer.prototype.putBytes=function(e){this.data+=e},n.ByteBuffer.prototype.bytes=function(){return this.data.slice(this.read)},n.ByteBuffer.prototype.length=function(){return this.data.length-this.read},n.ByteBuffer.prototype.compact=function(){this.data=this.data.slice(this.read),this.read=0},n.ByteBuffer.prototype.toHex=function(){for(var e="",t=this.read;t<this.data.length;++t){var n=this.data.charCodeAt(t);n<16&&(e+="0"),e+=n.toString(16)}return e};var r={_w:null};r.Algorithm=function(){this.name="sha1",this.blockSize=64,this.digestLength=20,this.messageLengthSize=8},r.Algorithm.prototype.start=function(){return r._w||(r._w=new Array(80)),r._createState()},r.Algorithm.prototype.writeMessageLength=function(e,t){e.putBytes(t.bytes())},r.Algorithm.prototype.digest=function(e,t){for(var n,a,o,i,l,u,s,c,d=t.length(),f=r._w;d>=64;){for(a=e.h0,o=e.h1,i=e.h2,l=e.h3,u=e.h4,c=0;c<16;++c)n=t.getInt32(),f[c]=n,s=l^o&(i^l),n=(a<<5|a>>>27)+s+u+1518500249+n,u=l,l=i,i=o<<30|o>>>2,o=a,a=n;for(;c<20;++c)n=f[c-3]^f[c-8]^f[c-14]^f[c-16],n=n<<1|n>>>31,f[c]=n,s=l^o&(i^l),n=(a<<5|a>>>27)+s+u+1518500249+n,u=l,l=i,i=o<<30|o>>>2,o=a,a=n;for(;c<32;++c)n=f[c-3]^f[c-8]^f[c-14]^f[c-16],n=n<<1|n>>>31,f[c]=n,s=o^i^l,n=(a<<5|a>>>27)+s+u+1859775393+n,u=l,l=i,i=o<<30|o>>>2,o=a,a=n;for(;c<40;++c)n=f[c-6]^f[c-16]^f[c-28]^f[c-32],n=n<<2|n>>>30,f[c]=n,s=o^i^l,n=(a<<5|a>>>27)+s+u+1859775393+n,u=l,l=i,i=o<<30|o>>>2,o=a,a=n;for(;c<60;++c)n=f[c-6]^f[c-16]^f[c-28]^f[c-32],n=n<<2|n>>>30,f[c]=n,s=o&i|l&(o^i),n=(a<<5|a>>>27)+s+u+2400959708+n,u=l,l=i,i=o<<30|o>>>2,o=a,a=n;for(;c<80;++c)n=f[c-6]^f[c-16]^f[c-28]^f[c-32],n=n<<2|n>>>30,f[c]=n,s=o^i^l,n=(a<<5|a>>>27)+s+u+3395469782+n,u=l,l=i,i=o<<30|o>>>2,o=a,a=n;e.h0=e.h0+a|0,e.h1=e.h1+o|0,e.h2=e.h2+i|0,e.h3=e.h3+l|0,e.h4=e.h4+u|0,d-=64}return e},r._createState=function(){var e={h0:1732584193,h1:4023233417,h2:2562383102,h3:271733878,h4:3285377520};return e.copy=function(){var t=r._createState();return t.h0=e.h0,t.h1=e.h1,t.h2=e.h2,t.h3=e.h3,t.h4=e.h4,t},e.write=function(t){t.putInt32(e.h0),t.putInt32(e.h1),t.putInt32(e.h2),t.putInt32(e.h3),t.putInt32(e.h4)},e};var a={_k:null,_w:null};a.Algorithm=function(){this.name="sha256",this.blockSize=64,this.digestLength=32,this.messageLengthSize=8},a.Algorithm.prototype.start=function(){return a._k||a._init(),a._createState()},a.Algorithm.prototype.writeMessageLength=function(e,t){e.putBytes(t.bytes())},a.Algorithm.prototype.digest=function(e,t){for(var n,r,o,i,l,u,s,c,d,f,p,h,v,g,y,m=t.length(),x=a._k,b=a._w;m>=64;){for(s=0;s<16;++s)b[s]=t.getInt32();for(;s<64;++s)n=b[s-2],n=(n>>>17|n<<15)^(n>>>19|n<<13)^n>>>10,r=b[s-15],r=(r>>>7|r<<25)^(r>>>18|r<<14)^r>>>3,b[s]=n+b[s-7]+r+b[s-16]|0;for(c=e.h0,d=e.h1,f=e.h2,p=e.h3,h=e.h4,v=e.h5,g=e.h6,y=e.h7,s=0;s<64;++s)i=(h>>>6|h<<26)^(h>>>11|h<<21)^(h>>>25|h<<7),l=g^h&(v^g),o=(c>>>2|c<<30)^(c>>>13|c<<19)^(c>>>22|c<<10),u=c&d|f&(c^d),n=y+i+l+x[s]+b[s],r=o+u,y=g,g=v,v=h,h=p+n|0,p=f,f=d,d=c,c=n+r|0;e.h0=e.h0+c|0,e.h1=e.h1+d|0,e.h2=e.h2+f|0,e.h3=e.h3+p|0,e.h4=e.h4+h|0,e.h5=e.h5+v|0,e.h6=e.h6+g|0,e.h7=e.h7+y|0,m-=64}return e},a._createState=function(){var e={h0:1779033703,h1:3144134277,h2:1013904242,h3:2773480762,h4:1359893119,h5:2600822924,h6:528734635,h7:1541459225};return e.copy=function(){var t=a._createState();return t.h0=e.h0,t.h1=e.h1,t.h2=e.h2,t.h3=e.h3,t.h4=e.h4,t.h5=e.h5,t.h6=e.h6,t.h7=e.h7,t},e.write=function(t){t.putInt32(e.h0),t.putInt32(e.h1),t.putInt32(e.h2),t.putInt32(e.h3),t.putInt32(e.h4),t.putInt32(e.h5),t.putInt32(e.h6),t.putInt32(e.h7)},e},a._init=function(){a._k=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],a._w=new Array(64)}}(e),!se)var Re=function(){se=require("xmldom").XMLSerializer};if(n.url={},n.url.parsers={simple:{keys:["href","scheme","authority","path","query","fragment"],regex:/^(?:([^:\/?#]+):)?(?:\/\/([^\/?#]*))?([^?#]*)(?:\?([^#]*))?(?:#(.*))?/},full:{keys:["href","protocol","scheme","authority","auth","user","password","hostname","port","path","directory","file","query","fragment"],regex:/^(([^:\/?#]+):)?(?:\/\/((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?))?(?:(((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/}},n.url.parse=function(e,t){for(var r={},a=n.url.parsers[t||"full"],o=a.regex.exec(e),i=a.keys.length;i--;)r[a.keys[i]]=void 0===o[i]?null:o[i];return r.normalizedPath=ae(r.path,!!r.authority),r},e?n.useDocumentLoader("node"):"undefined"!=typeof XMLHttpRequest&&n.useDocumentLoader("xhr"),e){n.use=function(e){switch(e){case"request":n.request=require("jsonld-request");break;default:throw new Oe("Unknown extension.","jsonld.UnknownExtension",{extension:e})}};var _e={exports:{},filename:__dirname};require("pkginfo")(_e,"version"),n.version=_e.exports.version}return n},r=function(){return n(function(){return r()})};!e&&"function"==typeof define&&define.amd?define([],function(){return n(r),r}):(n(r),"function"==typeof require&&"undefined"!=typeof module&&module.exports&&(module.exports=r),t&&("undefined"==typeof jsonld?jsonld=jsonldjs=r:jsonldjs=r))}();
}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},"/node_modules/jsonld/js")
},{"_process":66,"crypto":26,"es6-promise":12,"http":26,"jsonld-request":26,"pkginfo":26,"request":26,"util":26,"xmldom":26}],28:[function(require,module,exports){
function HttpFetcher(t,e){EventEmitter.call(this),this._accept=t||"application/ld+json;q=1.0"}var q=require("q"),http=require("http"),https=require("https"),util=require("util"),URLParser=require("url"),EventEmitter=require("events");util.inherits(HttpFetcher,EventEmitter),HttpFetcher.prototype.get=function(t){return this.request(t,"GET")},HttpFetcher.prototype.request=function(t,e){function r(e,r,o){var p;if(p=c._xhr?c._xhr.responseURL:c._fetchResponse.url,n.emit("response",p),e)return s.reject(new Error(e));if(r.statusCode>=500)return s.reject(new Error("Request failed: "+t));var i=/^[^;]+/.exec(r.headers["content-type"]||"text/html")[0];s.resolve({url:p,type:i,body:o,status:r.statusCode})}this.emit("request",t);var o=e||"GET",n=this,s=q.defer(),p=URLParser.parse(t),i={Accept:this._accept},u={hostname:p.hostname,port:p.port,path:p.path,headers:i,withCredentials:!1,method:o},h=function(e){var o=e,s=[],p=0;o.on("data",function(t){p+=t.length,s.push(t)}),e.on("error",function(t){r(t)}),o.on("end",function(){n.emit("downloaded",{url:t,totalBytes:p}),r(null,e,s.join(""))})},c={};return"https:"===p.protocol?c=https.request(u,h):"http:"===p.protocol?c=http.request(u,h):console.error("Only http or https supported. Not "+p.protocol),c.on("error",function(t){s.reject(t)}),c.end(null),s.promise},HttpFetcher.prototype.cancelAll=function(){},module.exports=HttpFetcher;
},{"events":59,"http":83,"https":60,"q":43,"url":89,"util":94}],29:[function(require,module,exports){
module.exports = class {
constructor (options) {
this.triples = {};
this.prefixes = {};
}
addTriple (triple) {
if (triple.graph) {
if (!this.triples[triple.graph])
this.triples[triple.graph] = {};
if (!this.triples[triple.graph][triple.subject]) {
this.triples[triple.graph][triple.subject] = {};
}
this.triples[triple.graph][triple.subject][triple.predicate] = triple.object;
} else {
if (!this.triples[triple.subject]) {
this.triples[triple.subject] = {};
}
this.triples[triple.subject][triple.predicate] = triple.object;
}
}
addPrefix (prefix, uri) {
this.prefixes[prefix] = uri;
}
addPrefixes (prefixes) {
prefixes.forEach( (prefix, uri) => {
this.addPrefix(prefix, uri);
});
}
addTriples (triples) {
triples.forEach(triple => {
this.addTriple(triple);
});
}
getTriples () {
return triples;
}
}
},{}],30:[function(require,module,exports){
var N3 = require('n3');
var jsonld = require('jsonld');
module.exports = class {
constructor (options) {
this.documentIRI = options.documentIRI;
}
parse (document, callback) {
var convertEntity = function (entity) {
// Return IRIs and blank nodes as-is
if (entity.type !== 'literal')
return entity.value;
else {
// Add a language tag to the literal if present
if ('language' in entity)
return '"' + entity.value + '"@' + entity.language;
// Add a datatype to the literal if present
if (entity.datatype !== 'http://www.w3.org/2001/XMLSchema#string')
return '"' + entity.value + '"^^' + entity.datatype;
// Otherwise, return the regular literal
return '"' + entity.value + '"';
}
}
var prefixes = [];
//read context
jsonld.toRDF(JSON.parse(document), {base: this.documentIRI},function(error, triples) {
for (var graphName in triples) {
triples[graphName].forEach(function (triple, index) {
callback(null, { subject : triple.subject.value,
predicate : triple.predicate.value,
object : convertEntity(triple.object)});
if (index === triples[graphName].length-1 ) {
//This is the end
callback(null, null);
}
});
}
if (error) {
callback(error);
}
});
}
}
},{"jsonld":27,"n3":34}],31:[function(require,module,exports){
var N3 = require('n3');
var jsonld = require('jsonld');
var jsonldRdfaParser = require('jsonld-rdfa-parser');
module.exports = class {
constructor (options) {
jsonld.registerRDFParser('text/html', jsonldRdfaParser);
this.documentIRI = options.documentIRI;
}
parse (document, callback) {
var convertEntity = function (entity) {
// Return IRIs and blank nodes as-is
if (entity.type !== 'literal')
return entity.value;
else {
// Add a language tag to the literal if present
if ('language' in entity)
return '"' + entity.value + '"@' + entity.language;
// Add a datatype to the literal if present
if (entity.datatype !== 'http://www.w3.org/2001/XMLSchema#string')
return '"' + entity.value + '"^^' + entity.datatype;
// Otherwise, return the regular literal
return '"' + entity.value + '"';
}
}
jsonld.fromRDF(document, {format: 'text/html', base: this.documentIRI}, function(err, data) {
var prefixes = [];
//read context
jsonld.toRDF(data, function(error, triples) {
for (var graphName in triples) {
triples[graphName].forEach(function (triple, index) {
callback(null, { subject : triple.subject.value,
predicate : triple.predicate.value,
object : convertEntity(triple.object)});
if (index === triples[graphName].length-1 ) {
//This is the end
callback(null, null);
}
});
}
if (error) {
callback(error);
}
});
});
}
}
},{"jsonld":27,"jsonld-rdfa-parser":25,"n3":34}],32:[function(require,module,exports){
var util = require("util");
var q = require('q');
var Fetcher = require("./NodeHttpFetcher.js");
var N3 = require('n3');
var JsonldToRDF = require('./JsonldToRDF');
var RDFaToRDF = require('./RDFaToRDF');
var EntityStore = require('./EntityStore');
const EventEmitter = require('events');
/** This is the common part for both browser and NodeJS */
module.exports = class extends EventEmitter {
constructor (options) {
super();
this.prefixes = {};
if (options) {
//console.log(options);
}
var accept = 'application/trig;q=1.0,application/n-quads;q=0.7,text/turtle;q=0.6,application/n-triples;q=0.3,application/ld+json;q=0.3,text/n3;q=0.2';
this.fetcher = new Fetcher(accept);
//forward events on this class
this.fetcher.on("cache-miss", obj => {
this.emit("cache-miss",obj);
});
this.fetcher.on("cache-hit", obj => {
this.emit("cache-hit",obj);
});
this.fetcher.on("downloaded", obj => {
this.emit("downloaded",obj);
});
}
addPrefix (prefix, uri) {
this.prefixes[prefix] = uri;
}
getCacheStats () {
return this.fetcher.getCacheStats();
}
get (url) {
this.emit('request', url);
return this.fetcher.get(url).then((response) => {
if (url !== response.url) {
this.emit('redirect',{'from': url, 'to': response.url});
}
this.emit('response', response.url);
var triples = [], prefixes = {}, promise = q.defer();
if (response.type === 'application/ld+json' || response.type === 'application/json' || response.type === 'text/html') {
var parser;
if (response.type === 'application/ld+json' || response.type === 'application/json') {
parser = new JsonldToRDF({documentIRI: response.url});
} else {
//response.type === 'text/html'
parser = new RDFaToRDF({documentIRI: response.url});
}
parser.parse(response.body, (error, triple, newPrefixes) => {
this.emit('parsed', response.url);
if (error) {
promise.reject(error);
} else if (triple) {
triples.push(triple);
} else {
prefixes = Object.assign(this.prefixes, prefixes);
promise.resolve({ triples,
prefixes,
statusCode: response.statusCode,
url : response.url});
}
if (newPrefixes) {
prefixes = Object.assign(prefixes, newPrefixes);
}
});
} else if (["application/trig","application/n-quads","text/turtle","application/n-triples","text/n3"].indexOf(response.type.toLowerCase()) > -1) {
//Just try anything else using N3 parser
//Parse N3, text/turtle, N-Quads, n-triples or trig and store in N3 Store
var parser = new N3.Parser({documentIRI: response.url});
parser.parse(response.body, (error, triple, newPrefixes) => {
this.emit("parsed", response.url)
if (error) {
promise.reject(error);
} else if (triple) {
triples.push(triple);
} else {
prefixes = Object.assign(prefixes, this.prefixes);
promise.resolve({ triples: triples,
prefixes: prefixes,
statusCode: response.statusCode,
url : response.url});
}
if (newPrefixes) {
prefixes = Object.assign(prefixes, newPrefixes);
}
});
} else {
//No parser found
promise.resolve({
statusCode: response.statusCode,
triples: triples,
prefixes: prefixes,
url : response.url,
error: 'Cannot parse ' + response.type
});
}
return promise.promise;
});
}
};
},{"./EntityStore":29,"./JsonldToRDF":30,"./NodeHttpFetcher.js":28,"./RDFaToRDF":31,"events":59,"n3":34,"q":43,"util":94}],33:[function(require,module,exports){
function MergeSortStream(e,t,r){if(!(this instanceof MergeSortStream))return new MergeSortStream(e,t,r);this._compare=r,this._sourceA=stream2(e),this._sourceB=stream2(t),this._endA=!1,this._endB=!1,this._chunkA=null,this._chunkB=null,this._destroyed=!1,Readable.call(this,{objectMode:!0,highWaterMark:0});var s=this;eos(e,function(e){if(e)return s.destroy(e);s._endA=!0,s._read()}),eos(t,function(e){if(e)return s.destroy(e);s._endB=!0,s._read()}),e.on("readable",function(){s._readableA=!0,s._read()}),t.on("readable",function(){s._readableB=!0,s._read()})}function exist(e){return null!==e}var Readable=require("readable-stream").Readable,eos=require("end-of-stream"),util=require("util"),stream2=function(e){return e._readableState?e:new Readable({objectMode:!0,highWaterMark:16}).wrap(e)},destroy=function(e){e.readable&&e.destroy&&e.destroy()};util.inherits(MergeSortStream,Readable),MergeSortStream.prototype.destroy=function(e){this._destroyed||(this._destroyed=!0,destroy(this._sourceA),destroy(this._sourceB),e&&this.emit("error",e),this.emit("close"))},MergeSortStream.prototype._read=function(){var e=null;this._readableA&&!exist(this._chunkA)?(this._chunkA=this._sourceA.read(),this._readableA=exist(this._chunkA)):this._readableB&&!exist(this._chunkB)&&(this._chunkB=this._sourceB.read(),this._readableB=exist(this._chunkB)),exist(this._chunkA)&&exist(this._chunkB)?this._compare(this._chunkA,this._chunkB)>0?(e=this._chunkA,this._chunkA=null):(e=this._chunkB,this._chunkB=null):this._endB&&exist(this._chunkA)?(e=this._chunkA,this._chunkA=null):this._endA&&exist(this._chunkB)&&(e=this._chunkB,this._chunkB=null),exist(e)&&this.push(e),!exist(e)&&this._endA&&this._endB&&this.push(null)},module.exports=MergeSortStream;
},{"end-of-stream":11,"readable-stream":49,"util":94}],34:[function(require,module,exports){
var globalRequire=require;require=function(){};var exports=module.exports={Lexer:require("./lib/N3Lexer"),Parser:require("./lib/N3Parser"),Writer:require("./lib/N3Writer"),Store:require("./lib/N3Store"),StreamParser:require("./lib/N3StreamParser"),StreamWriter:require("./lib/N3StreamWriter"),Util:require("./lib/N3Util")};Object.keys(exports).forEach(function(e){Object.defineProperty(exports,e,{configurable:!0,enumerable:!0,get:function(){return delete exports[e],exports[e]=globalRequire("./lib/N3"+e)}})});
},{"./lib/N3Lexer":35,"./lib/N3Parser":36,"./lib/N3Store":37,"./lib/N3StreamParser":38,"./lib/N3StreamWriter":39,"./lib/N3Util":40,"./lib/N3Writer":41}],35:[function(require,module,exports){
function N3Lexer(e){if(!(this instanceof N3Lexer))return new N3Lexer(e);if(e=e||{},e.lineMode){this._tripleQuotedString=this._number=this._boolean=/$0^/;var f=this;this._tokenize=this.tokenize,this.tokenize=function(e,u){this._tokenize(e,function(e,t){!e&&/^(?:IRI|prefixed|literal|langcode|type|\.|eof)$/.test(t.type)?u&&u(e,t):u&&u(e||f._syntaxError(t.type,u=null))})}}this._n3Mode=!1!==e.n3,this._comments=!!e.comments}var fromCharCode=String.fromCharCode,immediately="function"==typeof setImmediate?setImmediate:function(e){setTimeout(e,0)},escapeSequence=/\\u([a-fA-F0-9]{4})|\\U([a-fA-F0-9]{8})|\\[uU]|\\(.)/g,escapeReplacements={"\\":"\\","'":"'",'"':'"',n:"\n",r:"\r",t:"\t",f:"\f",b:"\b",_:"_","~":"~",".":".","-":"-","!":"!",$:"$","&":"&","(":"(",")":")","*":"*","+":"+",",":",",";":";","=":"=","/":"/","?":"?","#":"#","@":"@","%":"%"},illegalIriChars=/[\x00-\x20<>\\"\{\}\|\^\`]/;N3Lexer.prototype={_iri:/^<((?:[^ <>{}\\]|\\[uU])+)>[ \t]*/,_unescapedIri:/^<([^\x00-\x20<>\\"\{\}\|\^\`]*)>[ \t]*/,_unescapedString:/^"[^"\\]+"(?=[^"\\])/,_singleQuotedString:/^"[^"\\]*(?:\\.[^"\\]*)*"(?=[^"\\])|^'[^'\\]*(?:\\.[^'\\]*)*'(?=[^'\\])/,_tripleQuotedString:/^""("[^"\\]*(?:(?:\\.|"(?!""))[^"\\]*)*")""|^''('[^'\\]*(?:(?:\\.|'(?!''))[^'\\]*)*')''/,_langcode:/^@([a-z]+(?:-[a-z0-9]+)*)(?=[^a-z0-9\-])/i,_prefix:/^((?:[A-Za-z\xc0-\xd6\xd8-\xf6\xf8-\u02ff\u0370-\u037d\u037f-\u1fff\u200c\u200d\u2070-\u218f\u2c00-\u2fef\u3001-\ud7ff\uf900-\ufdcf\ufdf0-\ufffd]|[\ud800-\udb7f][\udc00-\udfff])(?:\.?[\-0-9A-Z_a-z\xb7\xc0-\xd6\xd8-\xf6\xf8-\u037d\u037f-\u1fff\u200c\u200d\u203f\u2040\u2070-\u218f\u2c00-\u2fef\u3001-\ud7ff\uf900-\ufdcf\ufdf0-\ufffd]|[\ud800-\udb7f][\udc00-\udfff])*)?:(?=[#\s<])/,_prefixed:/^((?:[A-Za-z\xc0-\xd6\xd8-\xf6\xf8-\u02ff\u0370-\u037d\u037f-\u1fff\u200c\u200d\u2070-\u218f\u2c00-\u2fef\u3001-\ud7ff\uf900-\ufdcf\ufdf0-\ufffd]|[\ud800-\udb7f][\udc00-\udfff])(?:\.?[\-0-9A-Z_a-z\xb7\xc0-\xd6\xd8-\xf6\xf8-\u037d\u037f-\u1fff\u200c\u200d\u203f\u2040\u2070-\u218f\u2c00-\u2fef\u3001-\ud7ff\uf900-\ufdcf\ufdf0-\ufffd]|[\ud800-\udb7f][\udc00-\udfff])*)?:((?:(?:[0-:A-Z_a-z\xc0-\xd6\xd8-\xf6\xf8-\u02ff\u0370-\u037d\u037f-\u1fff\u200c\u200d\u2070-\u218f\u2c00-\u2fef\u3001-\ud7ff\uf900-\ufdcf\ufdf0-\ufffd]|[\ud800-\udb7f][\udc00-\udfff]|%[0-9a-fA-F]{2}|\\[!#-\/;=?\-@_~])(?:(?:[\.\-0-:A-Z_a-z\xb7\xc0-\xd6\xd8-\xf6\xf8-\u037d\u037f-\u1fff\u200c\u200d\u203f\u2040\u2070-\u218f\u2c00-\u2fef\u3001-\ud7ff\uf900-\ufdcf\ufdf0-\ufffd]|[\ud800-\udb7f][\udc00-\udfff]|%[0-9a-fA-F]{2}|\\[!#-\/;=?\-@_~])*(?:[\-0-:A-Z_a-z\xb7\xc0-\xd6\xd8-\xf6\xf8-\u037d\u037f-\u1fff\u200c\u200d\u203f\u2040\u2070-\u218f\u2c00-\u2fef\u3001-\ud7ff\uf900-\ufdcf\ufdf0-\ufffd]|[\ud800-\udb7f][\udc00-\udfff]|%[0-9a-fA-F]{2}|\\[!#-\/;=?\-@_~]))?)?)(?:[ \t]+|(?=\.?[,;!\^\s#()\[\]\{\}"'<]))/,_variable:/^\?(?:(?:[A-Z_a-z\xc0-\xd6\xd8-\xf6\xf8-\u02ff\u0370-\u037d\u037f-\u1fff\u200c\u200d\u2070-\u218f\u2c00-\u2fef\u3001-\ud7ff\uf900-\ufdcf\ufdf0-\ufffd]|[\ud800-\udb7f][\udc00-\udfff])(?:[\-0-:A-Z_a-z\xb7\xc0-\xd6\xd8-\xf6\xf8-\u037d\u037f-\u1fff\u200c\u200d\u203f\u2040\u2070-\u218f\u2c00-\u2fef\u3001-\ud7ff\uf900-\ufdcf\ufdf0-\ufffd]|[\ud800-\udb7f][\udc00-\udfff])*)(?=[.,;!\^\s#()\[\]\{\}"'<])/,_blank:/^_:((?:[0-9A-Z_a-z\xc0-\xd6\xd8-\xf6\xf8-\u02ff\u0370-\u037d\u037f-\u1fff\u200c\u200d\u2070-\u218f\u2c00-\u2fef\u3001-\ud7ff\uf900-\ufdcf\ufdf0-\ufffd]|[\ud800-\udb7f][\udc00-\udfff])(?:\.?[\-0-9A-Z_a-z\xb7\xc0-\xd6\xd8-\xf6\xf8-\u037d\u037f-\u1fff\u200c\u200d\u203f\u2040\u2070-\u218f\u2c00-\u2fef\u3001-\ud7ff\uf900-\ufdcf\ufdf0-\ufffd]|[\ud800-\udb7f][\udc00-\udfff])*)(?:[ \t]+|(?=\.?[,;:\s#()\[\]\{\}"'<]))/,_number:/^[\-+]?(?:\d+\.?\d*([eE](?:[\-\+])?\d+)|\d*\.?\d+)(?=[.,;:\s#()\[\]\{\}"'<])/,_boolean:/^(?:true|false)(?=[.,;\s#()\[\]\{\}"'<])/,_keyword:/^@[a-z]+(?=[\s#<])/i,_sparqlKeyword:/^(?:PREFIX|BASE|GRAPH)(?=[\s#<])/i,_shortPredicates:/^a(?=\s+|<)/,_newline:/^[ \t]*(?:#[^\n\r]*)?(?:\r\n|\n|\r)[ \t]*/,_comment:/#([^\n\r]*)/,_whitespace:/^[ \t]+/,_endOfFile:/^(?:#[^\n\r]*)?$/,_tokenizeToEnd:function(e,f){function u(f){e(f._syntaxError(/^\S*/.exec(t)[0]))}for(var t=this._input,i=this._comments;;){for(var n,s;n=this._newline.exec(t);)i&&(s=this._comment.exec(n[0]))&&e(null,{line:this._line,type:"comment",value:s[1],prefix:""}),t=t.substr(n[0].length,t.length),this._line++;if((n=this._whitespace.exec(t))&&(t=t.substr(n[0].length,t.length)),this._endOfFile.test(t))return f&&(i&&(s=this._comment.exec(t))&&e(null,{line:this._line,type:"comment",value:s[1],prefix:""}),e(t=null,{line:this._line,type:"eof",value:"",prefix:""})),this._input=t;var d,r=this._line,c="",a="",o="",l=t[0],x=null,h=0,_=!1;switch(l){case"^":if(t.length<3)break;if("^"!==t[1]){this._n3Mode&&(h=1,c="^");break}if(this._prevTokenType="^^",t=t.substr(2),"<"!==t[0]){_=!0;break}case"<":if(x=this._unescapedIri.exec(t))c="IRI",a=x[1];else if(x=this._iri.exec(t)){if(null===(d=this._unescape(x[1]))||illegalIriChars.test(d))return u(this);c="IRI",a=d}else this._n3Mode&&t.length>1&&"="===t[1]&&(c="inverse",h=2,a="http://www.w3.org/2000/10/swap/log#implies");break;case"_":((x=this._blank.exec(t))||f&&(x=this._blank.exec(t+" ")))&&(c="blank",o="_",a=x[1]);break;case'"':case"'":if(x=this._unescapedString.exec(t))c="literal",a=x[0];else if(x=this._singleQuotedString.exec(t)){if(null===(d=this._unescape(x[0])))return u(this);c="literal",a=d.replace(/^'|'$/g,'"')}else if(x=this._tripleQuotedString.exec(t)){if(d=x[1]||x[2],this._line+=d.split(/\r\n|\r|\n/).length-1,null===(d=this._unescape(d)))return u(this);c="literal",a=d.replace(/^'|'$/g,'"')}break;case"?":this._n3Mode&&(x=this._variable.exec(t))&&(c="var",a=x[0]);break;case"@":"literal"===this._prevTokenType&&(x=this._langcode.exec(t))?(c="langcode",a=x[1]):(x=this._keyword.exec(t))&&(c=x[0]);break;case".":if(1===t.length?f:t[1]<"0"||t[1]>"9"){c=".",h=1;break}case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":case"+":case"-":(x=this._number.exec(t))&&(c="literal",a='"'+x[0]+'"^^http://www.w3.org/2001/XMLSchema#'+(x[1]?"double":/^[+\-]?\d+$/.test(x[0])?"integer":"decimal"));break;case"B":case"b":case"p":case"P":case"G":case"g":(x=this._sparqlKeyword.exec(t))?c=x[0].toUpperCase():_=!0;break;case"f":case"t":(x=this._boolean.exec(t))?(c="literal",a='"'+x[0]+'"^^http://www.w3.org/2001/XMLSchema#boolean'):_=!0;break;case"a":(x=this._shortPredicates.exec(t))?(c="abbreviation",a="http://www.w3.org/1999/02/22-rdf-syntax-ns#type"):_=!0;break;case"=":this._n3Mode&&t.length>1&&(c="abbreviation",">"!==t[1]?(h=1,a="http://www.w3.org/2002/07/owl#sameAs"):(h=2,a="http://www.w3.org/2000/10/swap/log#implies"));break;case"!":if(!this._n3Mode)break;case",":case";":case"[":case"]":case"(":case")":case"{":case"}":h=1,c=l;break;default:_=!0}if(_&&("@prefix"!==this._prevTokenType&&"PREFIX"!==this._prevTokenType||!(x=this._prefix.exec(t))?((x=this._prefixed.exec(t))||f&&(x=this._prefixed.exec(t+" ")))&&(c="prefixed",o=x[1]||"",a=this._unescape(x[2])):(c="prefix",a=x[1]||"")),"^^"===this._prevTokenType)switch(c){case"prefixed":c="type";break;case"IRI":c="typeIRI";break;default:c=""}if(!c)return f||!/^'''|^"""/.test(t)&&/\n|\r/.test(t)?u(this):this._input=t;e(null,{line:r,type:c,value:a,prefix:o}),this._prevTokenType=c,t=t.substr(h||x[0].length,t.length)}},_unescape:function(e){try{return e.replace(escapeSequence,function(e,f,u,t){var i;if(f){if(i=parseInt(f,16),isNaN(i))throw new Error;return fromCharCode(i)}if(u){if(i=parseInt(u,16),isNaN(i))throw new Error;return i<=65535?fromCharCode(i):fromCharCode(55296+(i-=65536)/1024,56320+(1023&i))}var n=escapeReplacements[t];if(!n)throw new Error;return n})}catch(e){return null}},_syntaxError:function(e){return this._input=null,new Error('Unexpected "'+e+'" on line '+this._line+".")},tokenize:function(e,f){var u=this;if(this._line=1,"string"==typeof e){if(this._input=e,"function"!=typeof f){var t,i=[];if(this._tokenizeToEnd(function(e,f){e?t=e:i.push(f)},!0),t)throw t;return i}immediately(function(){u._tokenizeToEnd(f,!0)})}else this._input="","function"==typeof e.setEncoding&&e.setEncoding("utf8"),e.on("data",function(e){null!==u._input&&(u._input+=e,u._tokenizeToEnd(f,!1))}),e.on("end",function(){null!==u._input&&u._tokenizeToEnd(f,!0)})}},module.exports=N3Lexer;
},{}],36:[function(require,module,exports){
function N3Parser(t){if(!(this instanceof N3Parser))return new N3Parser(t);this._contextStack=[],this._graph=null,t=t||{},this._setBase(t.documentIRI);var e="string"==typeof t.format?t.format.match(/\w*$/)[0].toLowerCase():"",i="turtle"===e,r="trig"===e,a=/triple/.test(e),s=/quad/.test(e),n=this._n3Mode=/n3/.test(e),h=a||s;(this._supportsNamedGraphs=!(i||n))||(this._readPredicateOrNamedGraph=this._readPredicate),this._supportsQuads=!(i||r||a||n),h&&(this._base="",this._resolveIRI=function(t){return this._error("Disallowed relative IRI",t),this._callback=noop,this._subject=null}),this._blankNodePrefix="string"!=typeof t.blankNodePrefix?"":"_:"+t.blankNodePrefix.replace(/^_:/,""),this._lexer=t.lexer||new N3Lexer({lineMode:h,n3:n}),this._explicitQuantifiers=!!t.explicitQuantifiers}function noop(){}var N3Lexer=require("./N3Lexer"),RDF_PREFIX="http://www.w3.org/1999/02/22-rdf-syntax-ns#",RDF_NIL=RDF_PREFIX+"nil",RDF_FIRST=RDF_PREFIX+"first",RDF_REST=RDF_PREFIX+"rest",QUANTIFIERS_GRAPH="urn:n3:quantifiers",absoluteIRI=/^[a-z][a-z0-9+.-]*:/i,schemeAuthority=/^(?:([a-z][a-z0-9+.-]*:))?(?:\/\/[^\/]*)?/i,dotSegments=/(?:^|\/)\.\.?(?:$|[\/#?])/,blankNodePrefix=0,blankNodeCount=0;N3Parser._resetBlankNodeIds=function(){blankNodePrefix=blankNodeCount=0},N3Parser.prototype={_setBase:function(t){if(t){var e=t.indexOf("#");e>=0&&(t=t.substr(0,e)),this._base=t,this._basePath=t.indexOf("/")<0?t:t.replace(/[^\/?]*(?:\?.*)?$/,""),t=t.match(schemeAuthority),this._baseRoot=t[0],this._baseScheme=t[1]}else this._base=null},_saveContext:function(t,e,i,r,a){var s=this._n3Mode;this._contextStack.push({subject:i,predicate:r,object:a,graph:e,type:t,inverse:!!s&&this._inversePredicate,blankPrefix:s?this._prefixes._:"",quantified:s?this._quantified:null}),s&&(this._inversePredicate=!1,this._prefixes._=this._graph+".",this._quantified=Object.create(this._quantified))},_restoreContext:function(){var t=this._contextStack.pop(),e=this._n3Mode;this._subject=t.subject,this._predicate=t.predicate,this._object=t.object,this._graph=t.graph,e&&(this._inversePredicate=t.inverse,this._prefixes._=t.blankPrefix,this._quantified=t.quantified)},_readInTopContext:function(t){switch(t.type){case"eof":return null!==this._graph?this._error("Unclosed graph",t):(delete this._prefixes._,this._callback(null,null,this._prefixes));case"PREFIX":this._sparqlStyle=!0;case"@prefix":return this._readPrefix;case"BASE":this._sparqlStyle=!0;case"@base":return this._readBaseIRI;case"{":if(this._supportsNamedGraphs)return this._graph="",this._subject=null,this._readSubject;case"GRAPH":if(this._supportsNamedGraphs)return this._readNamedGraphLabel;default:return this._readSubject(t)}},_readEntity:function(t,e){var i;switch(t.type){case"IRI":case"typeIRI":i=null===this._base||absoluteIRI.test(t.value)?t.value:this._resolveIRI(t);break;case"type":case"blank":case"prefixed":var r=this._prefixes[t.prefix];if(void 0===r)return this._error('Undefined prefix "'+t.prefix+':"',t);i=r+t.value;break;case"var":return t.value;default:return this._error("Expected entity but got "+t.type,t)}return!e&&this._n3Mode&&i in this._quantified&&(i=this._quantified[i]),i},_readSubject:function(t){switch(this._predicate=null,t.type){case"[":return this._saveContext("blank",this._graph,this._subject="_:b"+blankNodeCount++,null,null),this._readBlankNodeHead;case"(":return this._saveContext("list",this._graph,RDF_NIL,null,null),this._subject=null,this._readListItem;case"{":return this._n3Mode?(this._saveContext("formula",this._graph,this._graph="_:b"+blankNodeCount++,null,null),this._readSubject):this._error("Unexpected graph",t);case"}":return this._readPunctuation(t);case"@forSome":return this._subject=null,this._predicate="http://www.w3.org/2000/10/swap/reify#forSome",this._quantifiedPrefix="_:b",this._readQuantifierList;case"@forAll":return this._subject=null,this._predicate="http://www.w3.org/2000/10/swap/reify#forAll",this._quantifiedPrefix="?b-",this._readQuantifierList;default:if(void 0===(this._subject=this._readEntity(t)))return;if(this._n3Mode)return this._getPathReader(this._readPredicateOrNamedGraph)}return this._readPredicateOrNamedGraph},_readPredicate:function(t){var e=t.type;switch(e){case"inverse":this._inversePredicate=!0;case"abbreviation":this._predicate=t.value;break;case".":case"]":case"}":return null===this._predicate?this._error("Unexpected "+e,t):(this._subject=null,"]"===e?this._readBlankNodeTail(t):this._readPunctuation(t));case";":return this._readPredicate;case"blank":if(!this._n3Mode)return this._error("Disallowed blank node as predicate",t);default:if(void 0===(this._predicate=this._readEntity(t)))return}return this._readObject},_readObject:function(t){switch(t.type){case"literal":return this._object=t.value,this._readDataTypeOrLang;case"[":return this._saveContext("blank",this._graph,this._subject,this._predicate,this._subject="_:b"+blankNodeCount++),this._readBlankNodeHead;case"(":return this._saveContext("list",this._graph,this._subject,this._predicate,RDF_NIL),this._subject=null,this._readListItem;case"{":return this._n3Mode?(this._saveContext("formula",this._graph,this._subject,this._predicate,this._graph="_:b"+blankNodeCount++),this._readSubject):this._error("Unexpected graph",t);default:if(void 0===(this._object=this._readEntity(t)))return;if(this._n3Mode)return this._getPathReader(this._getContextEndReader())}return this._getContextEndReader()},_readPredicateOrNamedGraph:function(t){return"{"===t.type?this._readGraph(t):this._readPredicate(t)},_readGraph:function(t){return"{"!==t.type?this._error("Expected graph but got "+t.type,t):(this._graph=this._subject,this._subject=null,this._readSubject)},_readBlankNodeHead:function(t){return"]"===t.type?(this._subject=null,this._readBlankNodeTail(t)):(this._predicate=null,this._readPredicate(t))},_readBlankNodeTail:function(t){if("]"!==t.type)return this._readBlankNodePunctuation(t);null!==this._subject&&this._triple(this._subject,this._predicate,this._object,this._graph);var e=null===this._predicate;return this._restoreContext(),null===this._object?e?this._readPredicateOrNamedGraph:this._readPredicateAfterBlank:this._getContextEndReader()},_readPredicateAfterBlank:function(t){return"."!==t.type||this._contextStack.length?this._readPredicate(t):(this._subject=null,this._readPunctuation(t))},_readListItem:function(t){var e=null,i=null,r=this._subject,a=this._contextStack,s=a[a.length-1],n=this._readListItem,h=!0;switch(t.type){case"[":this._saveContext("blank",this._graph,i="_:b"+blankNodeCount++,RDF_FIRST,this._subject=e="_:b"+blankNodeCount++),n=this._readBlankNodeHead;break;case"(":this._saveContext("list",this._graph,i="_:b"+blankNodeCount++,RDF_FIRST,RDF_NIL),this._subject=null;break;case")":if(this._restoreContext(),0!==a.length&&"list"===a[a.length-1].type&&this._triple(this._subject,this._predicate,this._object,this._graph),null===this._predicate){if(n=this._readPredicate,this._subject===RDF_NIL)return n}else if(n=this._getContextEndReader(),this._object===RDF_NIL)return n;i=RDF_NIL;break;case"literal":e=t.value,h=!1,n=this._readListItemDataTypeOrLang;break;default:if(void 0===(e=this._readEntity(t)))return}if(null===i&&(this._subject=i="_:b"+blankNodeCount++),null===r?null===s.predicate?s.subject=i:s.object=i:this._triple(r,RDF_REST,i,this._graph),null!==e){if(this._n3Mode&&("IRI"===t.type||"prefixed"===t.type))return this._saveContext("item",this._graph,i,RDF_FIRST,e),this._subject=e,this._predicate=null,this._getPathReader(this._readListItem);h?this._triple(i,RDF_FIRST,e,this._graph):this._object=e}return n},_readDataTypeOrLang:function(t){return this._completeLiteral(t,!1)},_readListItemDataTypeOrLang:function(t){return this._completeLiteral(t,!0)},_completeLiteral:function(t,e){var i=!1;switch(t.type){case"type":case"typeIRI":i=!0,this._object+="^^"+this._readEntity(t);break;case"langcode":i=!0,this._object+="@"+t.value.toLowerCase()}return e&&this._triple(this._subject,RDF_FIRST,this._object,this._graph),i?this._getContextEndReader():(this._readCallback=this._getContextEndReader(),this._readCallback(t))},_readFormulaTail:function(t){return"}"!==t.type?this._readPunctuation(t):(null!==this._subject&&this._triple(this._subject,this._predicate,this._object,this._graph),this._restoreContext(),null===this._object?this._readPredicate:this._getContextEndReader())},_readPunctuation:function(t){var e,i=this._subject,r=this._graph,a=this._inversePredicate;switch(t.type){case"}":if(null===this._graph)return this._error("Unexpected graph closing",t);if(this._n3Mode)return this._readFormulaTail(t);this._graph=null;case".":this._subject=null,e=this._contextStack.length?this._readSubject:this._readInTopContext,a&&(this._inversePredicate=!1);break;case";":e=this._readPredicate;break;case",":e=this._readObject;break;default:if(this._supportsQuads&&null===this._graph&&void 0!==(r=this._readEntity(t))){e=this._readQuadPunctuation;break}return this._error('Expected punctuation to follow "'+this._object+'"',t)}if(null!==i){var s=this._predicate,n=this._object;a?this._triple(n,s,i,r):this._triple(i,s,n,r)}return e},_readBlankNodePunctuation:function(t){var e;switch(t.type){case";":e=this._readPredicate;break;case",":e=this._readObject;break;default:return this._error('Expected punctuation to follow "'+this._object+'"',t)}return this._triple(this._subject,this._predicate,this._object,this._graph),e},_readQuadPunctuation:function(t){return"."!==t.type?this._error("Expected dot to follow quad",t):this._readInTopContext},_readPrefix:function(t){return"prefix"!==t.type?this._error("Expected prefix to follow @prefix",t):(this._prefix=t.value,this._readPrefixIRI)},_readPrefixIRI:function(t){if("IRI"!==t.type)return this._error('Expected IRI to follow prefix "'+this._prefix+':"',t);var e=this._readEntity(t);return this._prefixes[this._prefix]=e,this._prefixCallback(this._prefix,e),this._readDeclarationPunctuation},_readBaseIRI:function(t){return"IRI"!==t.type?this._error("Expected IRI to follow base declaration",t):(this._setBase(null===this._base||absoluteIRI.test(t.value)?t.value:this._resolveIRI(t)),this._readDeclarationPunctuation)},_readNamedGraphLabel:function(t){switch(t.type){case"IRI":case"blank":case"prefixed":return this._readSubject(t),this._readGraph;case"[":return this._readNamedGraphBlankLabel;default:return this._error("Invalid graph label",t)}},_readNamedGraphBlankLabel:function(t){return"]"!==t.type?this._error("Invalid graph label",t):(this._subject="_:b"+blankNodeCount++,this._readGraph)},_readDeclarationPunctuation:function(t){return this._sparqlStyle?(this._sparqlStyle=!1,this._readInTopContext(t)):"."!==t.type?this._error("Expected declaration to end with a dot",t):this._readInTopContext},_readQuantifierList:function(t){var e;switch(t.type){case"IRI":case"prefixed":if(void 0!==(e=this._readEntity(t,!0)))break;default:return this._error("Unexpected "+t.type,t)}return this._explicitQuantifiers?(null===this._subject?this._triple(this._graph||"",this._predicate,this._subject="_:b"+blankNodeCount++,QUANTIFIERS_GRAPH):this._triple(this._subject,RDF_REST,this._subject="_:b"+blankNodeCount++,QUANTIFIERS_GRAPH),this._triple(this._subject,RDF_FIRST,e,QUANTIFIERS_GRAPH)):this._quantified[e]=this._quantifiedPrefix+blankNodeCount++,this._readQuantifierPunctuation},_readQuantifierPunctuation:function(t){return","===t.type?this._readQuantifierList:(this._explicitQuantifiers&&(this._triple(this._subject,RDF_REST,RDF_NIL,QUANTIFIERS_GRAPH),this._subject=null),this._readCallback=this._getContextEndReader(),this._readCallback(t))},_getPathReader:function(t){return this._afterPath=t,this._readPath},_readPath:function(t){switch(t.type){case"!":return this._readForwardPath;case"^":return this._readBackwardPath;default:var e=this._contextStack,i=e.length&&e[e.length-1];if(i&&"item"===i.type){var r=this._subject;this._restoreContext(),this._triple(this._subject,RDF_FIRST,r,this._graph)}return this._afterPath(t)}},_readForwardPath:function(t){var e,i,r="_:b"+blankNodeCount++;if(void 0!==(i=this._readEntity(t)))return null===this._predicate?(e=this._subject,this._subject=r):(e=this._object,this._object=r),this._triple(e,i,r,this._graph),this._readPath},_readBackwardPath:function(t){var e,i,r="_:b"+blankNodeCount++;if(void 0!==(e=this._readEntity(t)))return null===this._predicate?(i=this._subject,this._subject=r):(i=this._object,this._object=r),this._triple(r,e,i,this._graph),this._readPath},_getContextEndReader:function(){var t=this._contextStack;if(!t.length)return this._readPunctuation;switch(t[t.length-1].type){case"blank":return this._readBlankNodeTail;case"list":return this._readListItem;case"formula":return this._readFormulaTail}},_triple:function(t,e,i,r){this._callback(null,{subject:t,predicate:e,object:i,graph:r||""})},_error:function(t,e){this._callback(new Error(t+" on line "+e.line+"."))},_resolveIRI:function(t){var e=t.value;switch(e[0]){case void 0:return this._base;case"#":return this._base+e;case"?":return this._base.replace(/(?:\?.*)?$/,e);case"/":return("/"===e[1]?this._baseScheme:this._baseRoot)+this._removeDotSegments(e);default:return this._removeDotSegments(this._basePath+e)}},_removeDotSegments:function(t){if(!dotSegments.test(t))return t;for(var e="",i=t.length,r=-1,a=-1,s=0,n="/";r<i;){switch(n){case":":if(a<0&&"/"===t[++r]&&"/"===t[++r])for(;(a=r+1)<i&&"/"!==t[a];)r=a;break;case"?":case"#":r=i;break;case"/":if("."===t[r+1])switch(n=t[++r+1]){case"/":e+=t.substring(s,r-1),s=r+1;break;case void 0:case"?":case"#":return e+t.substring(s,r)+t.substr(r+1);case".":if(void 0===(n=t[++r+1])||"/"===n||"?"===n||"#"===n){if(e+=t.substring(s,r-2),(s=e.lastIndexOf("/"))>=a&&(e=e.substr(0,s)),"/"!==n)return e+"/"+t.substr(r+1);s=r+1}}}n=t[++r]}return e+t.substring(s)},parse:function(t,e,i){var r=this;if(this._readCallback=this._readInTopContext,this._sparqlStyle=!1,this._prefixes=Object.create(null),this._prefixes._=this._blankNodePrefix||"_:b"+blankNodePrefix+++"_",this._prefixCallback=i||noop,this._inversePredicate=!1,this._quantified=Object.create(null),!e){var a,s=[];if(this._callback=function(t,e){t?a=t:e&&s.push(e)},this._lexer.tokenize(t).every(function(t){return r._readCallback=r._readCallback(t)}),a)throw a;return s}this._callback=e,this._lexer.tokenize(t,function(t,e){null!==t?(r._callback(t),r._callback=noop):r._readCallback&&(r._readCallback=r._readCallback(e))})}},module.exports=N3Parser;
},{"./N3Lexer":35}],37:[function(require,module,exports){
function N3Store(e,i){if(!(this instanceof N3Store))return new N3Store(e,i);this._size=0,this._graphs=Object.create(null),this._id=0,this._ids=Object.create(null),this._ids["><"]=0,this._entities=Object.create(null),this._blankNodeIndex=0,i||!e||e[0]||(i=e,e=null),i=i||{},this._prefixes=Object.create(null),i.prefixes&&this.addPrefixes(i.prefixes),e&&this.addTriples(e)}function isString(e){return"string"==typeof e||e instanceof String}var expandPrefixedName=require("./N3Util").expandPrefixedName;N3Store.prototype={get size(){var e=this._size;if(null!==e)return e;e=0;var i,t,r=this._graphs;for(var n in r)for(var s in i=r[n].subjects)for(var a in t=i[s])e+=Object.keys(t[a]).length;return this._size=e},_addToIndex:function(e,i,t,r){var n=e[i]||(e[i]={}),s=n[t]||(n[t]={}),a=r in s;return a||(s[r]=null),!a},_removeFromIndex:function(e,i,t,r){var n,s=e[i],a=s[t];delete a[r];for(n in a)return;delete s[t];for(n in s)return;delete e[i]},_findInIndex:function(e,i,t,r,n,s,a,d,f,o){var u,c,h,p=!i+!t+!r,x=p>1?Object.keys(this._ids):this._entities;i&&((u=e,e={})[i]=u[i]);for(var l in e){var _=x[l];if(c=e[l]){t&&((u=c,c={})[t]=u[t]);for(var I in c){var b=x[I];if(h=c[I])for(var j=(r?r in h?[r]:[]:Object.keys(h)),v=j.length-1;v>=0;v--){var y={subject:"",predicate:"",object:"",graph:d};if(y[n]=_,y[s]=b,y[a]=x[j[v]],o)o.push(y);else if(f(y))return!0}}}}return o},_loop:function(e,i){for(var t in e)i(t)},_loopByKey0:function(e,i,t){var r,n;if(r=e[i])for(n in r)t(n)},_loopByKey1:function(e,i,t){var r,n;for(r in e)n=e[r],n[i]&&t(r)},_loopBy2Keys:function(e,i,t,r){var n,s,a;if((n=e[i])&&(s=n[t]))for(a in s)r(a)},_countInIndex:function(e,i,t,r){var n,s,a,d=0;i&&((n=e,e={})[i]=n[i]);for(var f in e)if(s=e[f]){t&&((n=s,s={})[t]=n[t]);for(var o in s)(a=s[o])&&(r?r in a&&d++:d+=Object.keys(a).length)}return d},_getGraphs:function(e){if(!isString(e))return this._graphs;var i={};return i[e]=this._graphs[e],i},_uniqueEntities:function(e){var i=Object.create(null),t=this._entities;return function(r){r in i||(i[r]=!0,e(t[r]))}},addTriple:function(e,i,t,r){i||(r=e.graph,t=e.object,i=e.predicate,e=e.subject),r=r||"";var n=this._graphs[r];n||(n=this._graphs[r]={subjects:{},predicates:{},objects:{}},Object.freeze(n));var s=this._ids,a=this._entities;e=s[e]||(s[a[++this._id]=e]=this._id),i=s[i]||(s[a[++this._id]=i]=this._id),t=s[t]||(s[a[++this._id]=t]=this._id);var d=this._addToIndex(n.subjects,e,i,t);return this._addToIndex(n.predicates,i,t,e),this._addToIndex(n.objects,t,e,i),this._size=null,d},addTriples:function(e){for(var i=e.length-1;i>=0;i--)this.addTriple(e[i])},addPrefix:function(e,i){this._prefixes[e]=i},addPrefixes:function(e){for(var i in e)this.addPrefix(i,e[i])},removeTriple:function(e,i,t,r){i||(r=e.graph,t=e.object,i=e.predicate,e=e.subject),r=r||"";var n,s,a,d=this._ids,f=this._graphs;if(!((e=d[e])&&(i=d[i])&&(t=d[t])&&(n=f[r])&&(s=n.subjects[e])&&(a=s[i])&&t in a))return!1;this._removeFromIndex(n.subjects,e,i,t),this._removeFromIndex(n.predicates,i,t,e),this._removeFromIndex(n.objects,t,e,i),null!==this._size&&this._size--;for(e in n.subjects)return!0;return delete f[r],!0},removeTriples:function(e){for(var i=e.length-1;i>=0;i--)this.removeTriple(e[i])},getTriples:function(e,i,t,r){var n=this._prefixes;return this.getTriplesByIRI(expandPrefixedName(e,n),expandPrefixedName(i,n),expandPrefixedName(t,n),expandPrefixedName(r,n))},getTriplesByIRI:function(e,i,t,r){var n,s,a,d,f=[],o=this._getGraphs(r),u=this._ids;if(isString(e)&&!(s=u[e])||isString(i)&&!(a=u[i])||isString(t)&&!(d=u[t]))return f;for(var c in o)(n=o[c])&&(s?d?this._findInIndex(n.objects,d,s,a,"object","subject","predicate",c,null,f):this._findInIndex(n.subjects,s,a,null,"subject","predicate","object",c,null,f):a?this._findInIndex(n.predicates,a,d,null,"predicate","object","subject",c,null,f):d?this._findInIndex(n.objects,d,null,null,"object","subject","predicate",c,null,f):this._findInIndex(n.subjects,null,null,null,"subject","predicate","object",c,null,f));return f},countTriples:function(e,i,t,r){var n=this._prefixes;return this.countTriplesByIRI(expandPrefixedName(e,n),expandPrefixedName(i,n),expandPrefixedName(t,n),expandPrefixedName(r,n))},countTriplesByIRI:function(e,i,t,r){var n,s,a,d,f=0,o=this._getGraphs(r),u=this._ids;if(isString(e)&&!(s=u[e])||isString(i)&&!(a=u[i])||isString(t)&&!(d=u[t]))return 0;for(var c in o)(n=o[c])&&(f+=e?t?this._countInIndex(n.objects,d,s,a):this._countInIndex(n.subjects,s,a,d):i?this._countInIndex(n.predicates,a,d,s):this._countInIndex(n.objects,d,s,a));return f},forEach:function(e,i,t,r,n){var s=this._prefixes;this.forEachByIRI(e,expandPrefixedName(i,s),expandPrefixedName(t,s),expandPrefixedName(r,s),expandPrefixedName(n,s))},forEachByIRI:function(e,i,t,r,n){this.someByIRI(function(i){return e(i),!1},i,t,r,n)},every:function(e,i,t,r,n){var s=this._prefixes;return this.everyByIRI(e,expandPrefixedName(i,s),expandPrefixedName(t,s),expandPrefixedName(r,s),expandPrefixedName(n,s))},everyByIRI:function(e,i,t,r,n){var s=!1,a=!this.someByIRI(function(i){return s=!0,!e(i)},i,t,r,n);return s&&a},some:function(e,i,t,r,n){var s=this._prefixes;return this.someByIRI(e,expandPrefixedName(i,s),expandPrefixedName(t,s),expandPrefixedName(r,s),expandPrefixedName(n,s))},someByIRI:function(e,i,t,r,n){var s,a,d,f,o=this._getGraphs(n),u=this._ids;if(isString(i)&&!(a=u[i])||isString(t)&&!(d=u[t])||isString(r)&&!(f=u[r]))return!1;for(var c in o)if(s=o[c])if(a){if(f){if(this._findInIndex(s.objects,f,a,d,"object","subject","predicate",c,e,null))return!0}else if(this._findInIndex(s.subjects,a,d,null,"subject","predicate","object",c,e,null))return!0}else if(d){if(this._findInIndex(s.predicates,d,f,null,"predicate","object","subject",c,e,null))return!0}else if(f){if(this._findInIndex(s.objects,f,null,null,"object","subject","predicate",c,e,null))return!0}else if(this._findInIndex(s.subjects,null,null,null,"subject","predicate","object",c,e,null))return!0;return!1},getSubjects:function(e,i,t){var r=this._prefixes;return this.getSubjectsByIRI(expandPrefixedName(e,r),expandPrefixedName(i,r),expandPrefixedName(t,r))},getSubjectsByIRI:function(e,i,t){var r=[];return this.forSubjectsByIRI(function(e){r.push(e)},e,i,t),r},forSubjects:function(e,i,t,r){var n=this._prefixes;this.forSubjectsByIRI(e,expandPrefixedName(i,n),expandPrefixedName(t,n),expandPrefixedName(r,n))},forSubjectsByIRI:function(e,i,t,r){var n,s,a,d=this._ids,f=this._getGraphs(r);if(e=this._uniqueEntities(e),!(isString(i)&&!(s=d[i])||isString(t)&&!(a=d[t])))for(r in f)(n=f[r])&&(s?a?this._loopBy2Keys(n.predicates,s,a,e):this._loopByKey1(n.subjects,s,e):a?this._loopByKey0(n.objects,a,e):this._loop(n.subjects,e))},getPredicates:function(e,i,t){var r=this._prefixes;return this.getPredicatesByIRI(expandPrefixedName(e,r),expandPrefixedName(i,r),expandPrefixedName(t,r))},getPredicatesByIRI:function(e,i,t){var r=[];return this.forPredicatesByIRI(function(e){r.push(e)},e,i,t),r},forPredicates:function(e,i,t,r){var n=this._prefixes;this.forPredicatesByIRI(e,expandPrefixedName(i,n),expandPrefixedName(t,n),expandPrefixedName(r,n))},forPredicatesByIRI:function(e,i,t,r){var n,s,a,d=this._ids,f=this._getGraphs(r);if(e=this._uniqueEntities(e),!(isString(i)&&!(s=d[i])||isString(t)&&!(a=d[t])))for(r in f)(n=f[r])&&(s?a?this._loopBy2Keys(n.objects,a,s,e):this._loopByKey0(n.subjects,s,e):a?this._loopByKey1(n.predicates,a,e):this._loop(n.predicates,e))},getObjects:function(e,i,t){var r=this._prefixes;return this.getObjectsByIRI(expandPrefixedName(e,r),expandPrefixedName(i,r),expandPrefixedName(t,r))},getObjectsByIRI:function(e,i,t){var r=[];return this.forObjectsByIRI(function(e){r.push(e)},e,i,t),r},forObjects:function(e,i,t,r){var n=this._prefixes;this.forObjectsByIRI(e,expandPrefixedName(i,n),expandPrefixedName(t,n),expandPrefixedName(r,n))},forObjectsByIRI:function(e,i,t,r){var n,s,a,d=this._ids,f=this._getGraphs(r);if(e=this._uniqueEntities(e),!(isString(i)&&!(s=d[i])||isString(t)&&!(a=d[t])))for(r in f)(n=f[r])&&(s?a?this._loopBy2Keys(n.subjects,s,a,e):this._loopByKey1(n.objects,s,e):a?this._loopByKey0(n.predicates,a,e):this._loop(n.objects,e))},getGraphs:function(e,i,t){var r=this._prefixes;return this.getGraphsByIRI(expandPrefixedName(e,r),expandPrefixedName(i,r),expandPrefixedName(t,r))},getGraphsByIRI:function(e,i,t){var r=[];return this.forGraphsByIRI(function(e){r.push(e)},e,i,t),r},forGraphs:function(e,i,t,r){var n=this._prefixes;this.forGraphsByIRI(e,expandPrefixedName(i,n),expandPrefixedName(t,n),expandPrefixedName(r,n))},forGraphsByIRI:function(e,i,t,r){for(var n in this._graphs)this.someByIRI(function(i){return e(i.graph),!0},i,t,r,n)},createBlankNode:function(e){var i,t;if(e)for(i=e="_:"+e,t=1;this._ids[i];)i=e+t++;else do{i="_:b"+this._blankNodeIndex++}while(this._ids[i]);return this._ids[i]=++this._id,this._entities[this._id]=i,i}},module.exports=N3Store;
},{"./N3Util":40}],38:[function(require,module,exports){
function N3StreamParser(r){if(!(this instanceof N3StreamParser))return new N3StreamParser(r);Transform.call(this,{decodeStrings:!0}),this._readableState.objectMode=!0;var e,t,a=this,s=new N3Parser(r);s.parse({on:function(r,a){"data"===r?e=a:t=a}},function(r,e){r&&a.emit("error",r)||e&&a.push(e)},function(r,e){a.emit("prefix",r,e)}),this._transform=function(r,t,a){e(r),a()},this._flush=function(r){t(),r()}}var Transform=require("stream").Transform,util=require("util"),N3Parser=require("./N3Parser.js");util.inherits(N3StreamParser,Transform),module.exports=N3StreamParser;
},{"./N3Parser.js":36,"stream":82,"util":94}],39:[function(require,module,exports){
function N3StreamWriter(r){if(!(this instanceof N3StreamWriter))return new N3StreamWriter(r);Transform.call(this,{encoding:"utf8"}),this._writableState.objectMode=!0;var t=this,e=new N3Writer({write:function(r,e,i){t.push(r),i&&i()},end:function(r){t.push(null),r&&r()}},r);this._transform=function(r,t,i){e.addTriple(r,i)},this._flush=function(r){e.end(r)}}var Transform=require("stream").Transform,util=require("util"),N3Writer=require("./N3Writer.js");util.inherits(N3StreamWriter,Transform),module.exports=N3StreamWriter;
},{"./N3Writer.js":41,"stream":82,"util":94}],40:[function(require,module,exports){
var Xsd="http://www.w3.org/2001/XMLSchema#",XsdString=Xsd+"string",XsdInteger=Xsd+"integer",XsdDouble=Xsd+"double",XsdBoolean=Xsd+"boolean",RdfLangString="http://www.w3.org/1999/02/22-rdf-syntax-ns#langString",N3Util={isIRI:function(e){if("string"!=typeof e)return!1;if(0===e.length)return!0;var r=e[0];return'"'!==r&&"_"!==r},isLiteral:function(e){return"string"==typeof e&&'"'===e[0]},isBlank:function(e){return"string"==typeof e&&"_:"===e.substr(0,2)},isDefaultGraph:function(e){return!e},inDefaultGraph:function(e){return!e.graph},getLiteralValue:function(e){var r=/^"([^]*)"/.exec(e);if(!r)throw new Error(e+" is not a literal");return r[1]},getLiteralType:function(e){var r=/^"[^]*"(?:\^\^([^"]+)|(@)[^@"]+)?$/.exec(e);if(!r)throw new Error(e+" is not a literal");return r[1]||(r[2]?RdfLangString:XsdString)},getLiteralLanguage:function(e){var r=/^"[^]*"(?:@([^@"]+)|\^\^[^"]+)?$/.exec(e);if(!r)throw new Error(e+" is not a literal");return r[1]?r[1].toLowerCase():""},isPrefixedName:function(e){return"string"==typeof e&&/^[^:\/"']*:[^:\/"']+$/.test(e)},expandPrefixedName:function(e,r){var t,n,i,a=/(?:^|"\^\^)([^:\/#"'\^_]*):[^\/]*$/.exec(e);return a&&(t=a[1],n=r[t],i=a.index),void 0===n?e:0===i?n+e.substr(t.length+1):e.substr(0,i+3)+n+e.substr(i+t.length+4)},createIRI:function(e){return e&&'"'===e[0]?N3Util.getLiteralValue(e):e},createLiteral:function(e,r){if(!r)switch(typeof e){case"boolean":r=XsdBoolean;break;case"number":isFinite(e)?r=e%1==0?XsdInteger:XsdDouble:(r=XsdDouble,isNaN(e)||(e=e>0?"INF":"-INF"));break;default:return'"'+e+'"'}return'"'+e+(/^[a-z]+(-[a-z0-9]+)*$/i.test(r)?'"@'+r.toLowerCase():'"^^'+r)},prefix:function(e){return N3Util.prefixes({"":e})("")},prefixes:function(e){function r(e,r){if(r||!(e in t)){var n=Object.create(null);r=r||"",t[e]=function(e){return n[e]||(n[e]=r+e)}}return t[e]}var t=Object.create(null);for(var n in e)r(n,e[n]);return r}};module.exports=N3Util;
},{}],41:[function(require,module,exports){
function N3Writer(e,t){if(!(this instanceof N3Writer))return new N3Writer(e,t);if(e&&"function"!=typeof e.write&&(t=e,e=null),t=t||{},e)this._outputStream=e,this._endStream=void 0===t.end||!!t.end;else{var r="";this._outputStream={write:function(e,t,i){r+=e,i&&i()},end:function(e){e&&e(null,r)}},this._endStream=!0}this._subject=null,/triple|quad/i.test(t.format)?this._writeTriple=this._writeTripleLine:(this._graph="",this._prefixIRIs=Object.create(null),t.prefixes&&this.addPrefixes(t.prefixes))}function characterReplacer(e){var t=escapeReplacements[e];return void 0===t&&(1===e.length?(t=e.charCodeAt(0).toString(16),t="\\u0000".substr(0,6-t.length)+t):(t=(1024*(e.charCodeAt(0)-55296)+e.charCodeAt(1)+9216).toString(16),t="\\U00000000".substr(0,10-t.length)+t)),t}var N3LiteralMatcher=/^"([^]*)"(?:\^\^(.+)|@([\-a-z]+))?$/i,RDF_PREFIX="http://www.w3.org/1999/02/22-rdf-syntax-ns#",RDF_TYPE=RDF_PREFIX+"type",escape=/["\\\t\n\r\b\f\u0000-\u0019\ud800-\udbff]/,escapeAll=/["\\\t\n\r\b\f\u0000-\u0019]|[\ud800-\udbff][\udc00-\udfff]/g,escapeReplacements={"\\":"\\\\",'"':'\\"',"\t":"\\t","\n":"\\n","\r":"\\r","\b":"\\b","\f":"\\f"};N3Writer.prototype={_write:function(e,t){this._outputStream.write(e,"utf8",t)},_writeTriple:function(e,t,r,i,n){try{this._graph!==i&&(this._write((null===this._subject?"":this._graph?"\n}\n":".\n")+(i?this._encodeIriOrBlankNode(i)+" {\n":"")),this._subject=null,this._graph="["!==i[0]?i:"]"),this._subject===e?this._predicate===t?this._write(", "+this._encodeObject(r),n):this._write(";\n "+this._encodePredicate(this._predicate=t)+" "+this._encodeObject(r),n):this._write((null===this._subject?"":".\n")+this._encodeSubject(this._subject=e)+" "+this._encodePredicate(this._predicate=t)+" "+this._encodeObject(r),n)}catch(e){n&&n(e)}},_writeTripleLine:function(e,t,r,i,n){delete this._prefixMatch;try{this._write(this._encodeIriOrBlankNode(e)+" "+this._encodeIriOrBlankNode(t)+" "+this._encodeObject(r)+(i?" "+this._encodeIriOrBlankNode(i)+".\n":".\n"),n)}catch(e){n&&n(e)}},_encodeIriOrBlankNode:function(e){var t=e[0];if("["===t||"("===t||"_"===t&&":"===e[1])return e;escape.test(e)&&(e=e.replace(escapeAll,characterReplacer));var r=this._prefixRegex.exec(e);return r?r[1]?this._prefixIRIs[r[1]]+r[2]:e:"<"+e+">"},_encodeLiteral:function(e,t,r){return escape.test(e)&&(e=e.replace(escapeAll,characterReplacer)),r?'"'+e+'"@'+r:t?'"'+e+'"^^'+this._encodeIriOrBlankNode(t):'"'+e+'"'},_encodeSubject:function(e){if('"'===e[0])throw new Error("A literal as subject is not allowed: "+e);return"["===e[0]&&(this._subject="]"),this._encodeIriOrBlankNode(e)},_encodePredicate:function(e){if('"'===e[0])throw new Error("A literal as predicate is not allowed: "+e);return e===RDF_TYPE?"a":this._encodeIriOrBlankNode(e)},_encodeObject:function(e){if('"'!==e[0])return this._encodeIriOrBlankNode(e);var t=N3LiteralMatcher.exec(e);if(!t)throw new Error("Invalid literal: "+e);return this._encodeLiteral(t[1],t[2],t[3])},_blockedWrite:function(){throw new Error("Cannot write because the writer has been closed.")},addTriple:function(e,t,r,i,n){void 0===r?this._writeTriple(e.subject,e.predicate,e.object,e.graph||"",t):"string"!=typeof i?this._writeTriple(e,t,r,"",i):this._writeTriple(e,t,r,i,n)},addTriples:function(e){for(var t=0;t<e.length;t++)this.addTriple(e[t])},addPrefix:function(e,t,r){var i={};i[e]=t,this.addPrefixes(i,r)},addPrefixes:function(e,t){var r=this._prefixIRIs,i=!1;for(var n in e){var c=e[n];/[#\/]$/.test(c)&&r[c]!==(n+=":")&&(i=!0,r[c]=n,null!==this._subject&&(this._write(this._graph?"\n}\n":".\n"),this._subject=null,this._graph=""),this._write("@prefix "+n+" <"+c+">.\n"))}if(i){var s="",a="";for(var h in r)s+=s?"|"+h:h,a+=(a?"|":"")+r[h];s=s.replace(/[\]\/\(\)\*\+\?\.\\\$]/g,"\\$&"),this._prefixRegex=new RegExp("^(?:"+a+")[^/]*$|^("+s+")([a-zA-Z][\\-_a-zA-Z0-9]*)$")}this._write(i?"\n":"",t)},blank:function(e,t){var r,i,n=e;switch(void 0===e?n=[]:"string"==typeof e?n=[{predicate:e,object:t}]:"length"in e||(n=[e]),i=n.length){case 0:return"[]";case 1:if(r=n[0],"["!==r.object[0])return"[ "+this._encodePredicate(r.predicate)+" "+this._encodeObject(r.object)+" ]";default:for(var c="[",s=0;s<i;s++)r=n[s],r.predicate===e?c+=", "+this._encodeObject(r.object):(c+=(s?";\n ":"\n ")+this._encodePredicate(r.predicate)+" "+this._encodeObject(r.object),e=r.predicate);return c+"\n]"}},list:function(e){for(var t=e&&e.length||0,r=new Array(t),i=0;i<t;i++)r[i]=this._encodeObject(e[i]);return"("+r.join(" ")+")"},_prefixRegex:/$0^/,end:function(e){null!==this._subject&&(this._write(this._graph?"\n}\n":".\n"),this._subject=null),this._write=this._blockedWrite;var t=e&&function(r,i){t=null,e(r,i)};if(this._endStream)try{return this._outputStream.end(t)}catch(e){}t&&t()}},module.exports=N3Writer;
},{}],42:[function(require,module,exports){
function once(e){var r=function(){return r.called?r.value:(r.called=!0,r.value=e.apply(this,arguments))};return r.called=!1,r}function onceStrict(e){var r=function(){if(r.called)throw new Error(r.onceError);return r.called=!0,r.value=e.apply(this,arguments)},n=e.name||"Function wrapped with `once`";return r.onceError=n+" shouldn't be called more than once",r.called=!1,r}var wrappy=require("wrappy");module.exports=wrappy(once),module.exports.strict=wrappy(onceStrict),once.proto=once(function(){Object.defineProperty(Function.prototype,"once",{value:function(){return once(this)},configurable:!0}),Object.defineProperty(Function.prototype,"onceStrict",{value:function(){return onceStrict(this)},configurable:!0})});
},{"wrappy":52}],43:[function(require,module,exports){
(function (process){
!function(t){"use strict";if("function"==typeof bootstrap)bootstrap("promise",t);else if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define(t);else if("undefined"!=typeof ses){if(!ses.ok())return;ses.makeQ=t}else{if("undefined"==typeof window&&"undefined"==typeof self)throw new Error("This environment was not anticipated by Q. Please file a bug.");var n="undefined"!=typeof window?window:self,e=n.Q;n.Q=t(),n.Q.noConflict=function(){return n.Q=e,this}}}(function(){"use strict";function t(t){return function(){return q.apply(t,arguments)}}function n(t){return t===Object(t)}function e(t){return"[object StopIteration]"===nt(t)||t instanceof V}function r(t,n){if(B&&n.stack&&"object"==typeof t&&null!==t&&t.stack){for(var e=[],r=n;r;r=r.source)r.stack&&(!t.__minimumStackCounter__||t.__minimumStackCounter__>r.stackCounter)&&(Y(t,"__minimumStackCounter__",{value:r.stackCounter,configurable:!0}),e.unshift(r.stack));e.unshift(t.stack);var i=e.join("\n"+et+"\n"),u=o(i);Y(t,"stack",{value:u,configurable:!0})}}function o(t){for(var n=t.split("\n"),e=[],r=0;r<n.length;++r){var o=n[r];c(o)||i(o)||!o||e.push(o)}return e.join("\n")}function i(t){return-1!==t.indexOf("(module.js:")||-1!==t.indexOf("(node.js:")}function u(t){var n=/at .+ \((.+):(\d+):(?:\d+)\)$/.exec(t);if(n)return[n[1],Number(n[2])];var e=/at ([^ ]+):(\d+):(?:\d+)$/.exec(t);if(e)return[e[1],Number(e[2])];var r=/.*@(.+):(\d+)$/.exec(t);return r?[r[1],Number(r[2])]:void 0}function c(t){var n=u(t);if(!n)return!1;var e=n[0],r=n[1];return e===$&&r>=G&&r<=ft}function f(){if(B)try{throw new Error}catch(r){var t=r.stack.split("\n"),n=t[0].indexOf("@")>0?t[1]:t[2],e=u(n);if(!e)return;return $=e[0],e[1]}}function s(t){return t instanceof d?t:m(t)?S(t):R(t)}function p(){function t(t){n=t,s.longStackSupport&&B&&(i.source=t),J(e,function(n,e){s.nextTick(function(){t.promiseDispatch.apply(t,e)})},void 0),e=void 0,r=void 0}var n,e=[],r=[],o=X(p.prototype),i=X(d.prototype);if(i.promiseDispatch=function(t,o,i){var u=z(arguments);e?(e.push(u),"when"===o&&i[1]&&r.push(i[1])):s.nextTick(function(){n.promiseDispatch.apply(n,u)})},i.valueOf=function(){if(e)return i;var t=y(n);return v(t)&&(n=t),t},i.inspect=function(){return n?n.inspect():{state:"pending"}},s.longStackSupport&&B)try{throw new Error}catch(t){i.stack=t.stack.substring(t.stack.indexOf("\n")+1),i.stackCounter=rt++}return o.promise=i,o.resolve=function(e){n||t(s(e))},o.fulfill=function(e){n||t(R(e))},o.reject=function(e){n||t(T(e))},o.notify=function(t){n||J(r,function(n,e){s.nextTick(function(){e(t)})},void 0)},o}function a(t){if("function"!=typeof t)throw new TypeError("resolver must be a function.");var n=p();try{t(n.resolve,n.reject,n.notify)}catch(t){n.reject(t)}return n.promise}function l(t){return a(function(n,e){for(var r=0,o=t.length;r<o;r++)s(t[r]).then(n,e)})}function d(t,n,e){void 0===n&&(n=function(t){return T(new Error("Promise does not support operation: "+t))}),void 0===e&&(e=function(){return{state:"unknown"}});var r=X(d.prototype);if(r.promiseDispatch=function(e,o,i){var u;try{u=t[o]?t[o].apply(r,i):n.call(r,o,i)}catch(t){u=T(t)}e&&e(u)},r.inspect=e,e){var o=e();"rejected"===o.state&&(r.exception=o.reason),r.valueOf=function(){var t=e();return"pending"===t.state||"rejected"===t.state?r:t.value}}return r}function h(t,n,e,r){return s(t).then(n,e,r)}function y(t){if(v(t)){var n=t.inspect();if("fulfilled"===n.state)return n.value}return t}function v(t){return t instanceof d}function m(t){return n(t)&&"function"==typeof t.then}function k(t){return v(t)&&"pending"===t.inspect().state}function w(t){return!v(t)||"fulfilled"===t.inspect().state}function j(t){return v(t)&&"rejected"===t.inspect().state}function g(){ot.length=0,it.length=0,ct||(ct=!0)}function b(t,n){ct&&("object"==typeof process&&"function"==typeof process.emit&&s.nextTick.runAfter(function(){-1!==K(it,t)&&(process.emit("unhandledRejection",n,t),ut.push(t))}),it.push(t),n&&void 0!==n.stack?ot.push(n.stack):ot.push("(no stack) "+n))}function x(t){if(ct){var n=K(it,t);-1!==n&&("object"==typeof process&&"function"==typeof process.emit&&s.nextTick.runAfter(function(){var e=K(ut,t);-1!==e&&(process.emit("rejectionHandled",ot[n],t),ut.splice(e,1))}),it.splice(n,1),ot.splice(n,1))}}function T(t){var n=d({when:function(n){return n&&x(this),n?n(t):this}},function(){return this},function(){return{state:"rejected",reason:t}});return b(n,t),n}function R(t){return d({when:function(){return t},get:function(n){return t[n]},set:function(n,e){t[n]=e},delete:function(n){delete t[n]},post:function(n,e){return null===n||void 0===n?t.apply(void 0,e):t[n].apply(t,e)},apply:function(n,e){return t.apply(n,e)},keys:function(){return tt(t)}},void 0,function(){return{state:"fulfilled",value:t}})}function S(t){var n=p();return s.nextTick(function(){try{t.then(n.resolve,n.reject,n.notify)}catch(t){n.reject(t)}}),n.promise}function E(t){return d({isDef:function(){}},function(n,e){return P(t,n,e)},function(){return s(t).inspect()})}function O(t,n,e){return s(t).spread(n,e)}function C(t){return function(){function n(t,n){var u;if("undefined"==typeof StopIteration){try{u=r[t](n)}catch(t){return T(t)}return u.done?s(u.value):h(u.value,o,i)}try{u=r[t](n)}catch(t){return e(t)?s(t.value):T(t)}return h(u,o,i)}var r=t.apply(this,arguments),o=n.bind(n,"next"),i=n.bind(n,"throw");return o()}}function Q(t){s.done(s.async(t)())}function _(t){throw new V(t)}function N(t){return function(){return O([this,D(arguments)],function(n,e){return t.apply(n,e)})}}function P(t,n,e){return s(t).dispatch(n,e)}function D(t){return h(t,function(t){var n=0,e=p();return J(t,function(r,o,i){var u;v(o)&&"fulfilled"===(u=o.inspect()).state?t[i]=u.value:(++n,h(o,function(r){t[i]=r,0==--n&&e.resolve(t)},e.reject,function(t){e.notify({index:i,value:t})}))},void 0),0===n&&e.resolve(t),e.promise})}function A(t){if(0===t.length)return s.resolve();var n=s.defer(),e=0;return J(t,function(r,o,i){function u(t){n.resolve(t)}function c(t){0===--e&&(t.message="Q can't get fulfillment value from any promise, all promises were rejected. Last error message: "+t.message,n.reject(t))}function f(t){n.notify({index:i,value:t})}var s=t[i];e++,h(s,u,c,f)},void 0),n.promise}function I(t){return h(t,function(t){return t=W(t,s),h(D(W(t,function(t){return h(t,H,H)})),function(){return t})})}function U(t){return s(t).allSettled()}function F(t,n){return s(t).then(void 0,void 0,n)}function M(t,n){return s(t).nodeify(n)}var B=!1;try{throw new Error}catch(t){B=!!t.stack}var $,V,G=f(),H=function(){},L=function(){function t(){for(var t,r;e.next;)e=e.next,t=e.task,e.task=void 0,r=e.domain,r&&(e.domain=void 0,r.enter()),n(t,r);for(;c.length;)t=c.pop(),n(t);o=!1}function n(n,e){try{n()}catch(n){if(u)throw e&&e.exit(),setTimeout(t,0),e&&e.enter(),n;setTimeout(function(){throw n},0)}e&&e.exit()}var e={task:void 0,next:null},r=e,o=!1,i=void 0,u=!1,c=[];if(L=function(t){r=r.next={task:t,domain:u&&process.domain,next:null},o||(o=!0,i())},"object"==typeof process&&"[object process]"===process.toString()&&process.nextTick)u=!0,i=function(){process.nextTick(t)};else if("function"==typeof setImmediate)i="undefined"!=typeof window?setImmediate.bind(window,t):function(){setImmediate(t)};else if("undefined"!=typeof MessageChannel){var f=new MessageChannel;f.port1.onmessage=function(){i=s,f.port1.onmessage=t,t()};var s=function(){f.port2.postMessage(0)};i=function(){setTimeout(t,0),s()}}else i=function(){setTimeout(t,0)};return L.runAfter=function(t){c.push(t),o||(o=!0,i())},L}(),q=Function.call,z=t(Array.prototype.slice),J=t(Array.prototype.reduce||function(t,n){var e=0,r=this.length;if(1===arguments.length)for(;;){if(e in this){n=this[e++];break}if(++e>=r)throw new TypeError}for(;e<r;e++)e in this&&(n=t(n,this[e],e));return n}),K=t(Array.prototype.indexOf||function(t){for(var n=0;n<this.length;n++)if(this[n]===t)return n;return-1}),W=t(Array.prototype.map||function(t,n){var e=this,r=[];return J(e,function(o,i,u){r.push(t.call(n,i,u,e))},void 0),r}),X=Object.create||function(t){function n(){}return n.prototype=t,new n},Y=Object.defineProperty||function(t,n,e){return t[n]=e.value,t},Z=t(Object.prototype.hasOwnProperty),tt=Object.keys||function(t){var n=[];for(var e in t)Z(t,e)&&n.push(e);return n},nt=t(Object.prototype.toString);V="undefined"!=typeof ReturnValue?ReturnValue:function(t){this.value=t};var et="From previous event:";s.resolve=s,s.nextTick=L,s.longStackSupport=!1;var rt=1;"object"==typeof process&&process&&process.env&&process.env.Q_DEBUG&&(s.longStackSupport=!0),s.defer=p,p.prototype.makeNodeResolver=function(){var t=this;return function(n,e){n?t.reject(n):arguments.length>2?t.resolve(z(arguments,1)):t.resolve(e)}},s.Promise=a,s.promise=a,a.race=l,a.all=D,a.reject=T,a.resolve=s,s.passByCopy=function(t){return t},d.prototype.passByCopy=function(){return this},s.join=function(t,n){return s(t).join(n)},d.prototype.join=function(t){return s([this,t]).spread(function(t,n){if(t===n)return t;throw new Error("Q can't join: not the same: "+t+" "+n)})},s.race=l,d.prototype.race=function(){return this.then(s.race)},s.makePromise=d,d.prototype.toString=function(){return"[object Promise]"},d.prototype.then=function(t,n,e){function o(n){try{return"function"==typeof t?t(n):n}catch(t){return T(t)}}function i(t){if("function"==typeof n){r(t,c);try{return n(t)}catch(t){return T(t)}}return T(t)}function u(t){return"function"==typeof e?e(t):t}var c=this,f=p(),a=!1;return s.nextTick(function(){c.promiseDispatch(function(t){a||(a=!0,f.resolve(o(t)))},"when",[function(t){a||(a=!0,f.resolve(i(t)))}])}),c.promiseDispatch(void 0,"when",[void 0,function(t){var n,e=!1;try{n=u(t)}catch(t){if(e=!0,!s.onerror)throw t;s.onerror(t)}e||f.notify(n)}]),f.promise},s.tap=function(t,n){return s(t).tap(n)},d.prototype.tap=function(t){return t=s(t),this.then(function(n){return t.fcall(n).thenResolve(n)})},s.when=h,d.prototype.thenResolve=function(t){return this.then(function(){return t})},s.thenResolve=function(t,n){return s(t).thenResolve(n)},d.prototype.thenReject=function(t){return this.then(function(){throw t})},s.thenReject=function(t,n){return s(t).thenReject(n)},s.nearer=y,s.isPromise=v,s.isPromiseAlike=m,s.isPending=k,d.prototype.isPending=function(){return"pending"===this.inspect().state},s.isFulfilled=w,d.prototype.isFulfilled=function(){return"fulfilled"===this.inspect().state},s.isRejected=j,d.prototype.isRejected=function(){return"rejected"===this.inspect().state};var ot=[],it=[],ut=[],ct=!0;s.resetUnhandledRejections=g,s.getUnhandledReasons=function(){return ot.slice()},s.stopUnhandledRejectionTracking=function(){g(),ct=!1},g(),s.reject=T,s.fulfill=R,s.master=E,s.spread=O,d.prototype.spread=function(t,n){return this.all().then(function(n){return t.apply(void 0,n)},n)},s.async=C,s.spawn=Q,s.return=_,s.promised=N,s.dispatch=P,d.prototype.dispatch=function(t,n){var e=this,r=p();return s.nextTick(function(){e.promiseDispatch(r.resolve,t,n)}),r.promise},s.get=function(t,n){return s(t).dispatch("get",[n])},d.prototype.get=function(t){return this.dispatch("get",[t])},s.set=function(t,n,e){return s(t).dispatch("set",[n,e])},d.prototype.set=function(t,n){return this.dispatch("set",[t,n])},s.del=s.delete=function(t,n){return s(t).dispatch("delete",[n])},d.prototype.del=d.prototype.delete=function(t){return this.dispatch("delete",[t])},s.mapply=s.post=function(t,n,e){return s(t).dispatch("post",[n,e])},d.prototype.mapply=d.prototype.post=function(t,n){return this.dispatch("post",[t,n])},s.send=s.mcall=s.invoke=function(t,n){return s(t).dispatch("post",[n,z(arguments,2)])},d.prototype.send=d.prototype.mcall=d.prototype.invoke=function(t){return this.dispatch("post",[t,z(arguments,1)])},s.fapply=function(t,n){return s(t).dispatch("apply",[void 0,n])},d.prototype.fapply=function(t){return this.dispatch("apply",[void 0,t])},s.try=s.fcall=function(t){return s(t).dispatch("apply",[void 0,z(arguments,1)])},d.prototype.fcall=function(){return this.dispatch("apply",[void 0,z(arguments)])},s.fbind=function(t){var n=s(t),e=z(arguments,1);return function(){return n.dispatch("apply",[this,e.concat(z(arguments))])}},d.prototype.fbind=function(){var t=this,n=z(arguments);return function(){return t.dispatch("apply",[this,n.concat(z(arguments))])}},s.keys=function(t){return s(t).dispatch("keys",[])},d.prototype.keys=function(){return this.dispatch("keys",[])},s.all=D,d.prototype.all=function(){return D(this)},s.any=A,d.prototype.any=function(){return A(this)},s.allResolved=function(t,n,e){return function(){return"undefined"!=typeof console&&"function"==typeof console.warn&&console.warn(n+" is deprecated, use "+e+" instead.",new Error("").stack),t.apply(t,arguments)}}(I,"allResolved","allSettled"),d.prototype.allResolved=function(){return I(this)},s.allSettled=U,d.prototype.allSettled=function(){return this.then(function(t){return D(W(t,function(t){function n(){return t.inspect()}return t=s(t),t.then(n,n)}))})},s.fail=s.catch=function(t,n){return s(t).then(void 0,n)},d.prototype.fail=d.prototype.catch=function(t){return this.then(void 0,t)},s.progress=F,d.prototype.progress=function(t){return this.then(void 0,void 0,t)},s.fin=s.finally=function(t,n){return s(t).finally(n)},d.prototype.fin=d.prototype.finally=function(t){if(!t||"function"!=typeof t.apply)throw new Error("Q can't apply finally callback");return t=s(t),this.then(function(n){return t.fcall().then(function(){return n})},function(n){return t.fcall().then(function(){throw n})})},s.done=function(t,n,e,r){return s(t).done(n,e,r)},d.prototype.done=function(t,n,e){var o=function(t){s.nextTick(function(){if(r(t,i),!s.onerror)throw t;s.onerror(t)})},i=t||n||e?this.then(t,n,e):this;"object"==typeof process&&process&&process.domain&&(o=process.domain.bind(o)),i.then(void 0,o)},s.timeout=function(t,n,e){return s(t).timeout(n,e)},d.prototype.timeout=function(t,n){var e=p(),r=setTimeout(function(){n&&"string"!=typeof n||(n=new Error(n||"Timed out after "+t+" ms"),n.code="ETIMEDOUT"),e.reject(n)},t);return this.then(function(t){clearTimeout(r),e.resolve(t)},function(t){clearTimeout(r),e.reject(t)},e.notify),e.promise},s.delay=function(t,n){return void 0===n&&(n=t,t=void 0),s(t).delay(n)},d.prototype.delay=function(t){return this.then(function(n){var e=p();return setTimeout(function(){e.resolve(n)},t),e.promise})},s.nfapply=function(t,n){return s(t).nfapply(n)},d.prototype.nfapply=function(t){var n=p(),e=z(t);return e.push(n.makeNodeResolver()),this.fapply(e).fail(n.reject),n.promise},s.nfcall=function(t){var n=z(arguments,1);return s(t).nfapply(n)},d.prototype.nfcall=function(){var t=z(arguments),n=p();return t.push(n.makeNodeResolver()),this.fapply(t).fail(n.reject),n.promise},s.nfbind=s.denodeify=function(t){if(void 0===t)throw new Error("Q can't wrap an undefined function");var n=z(arguments,1);return function(){var e=n.concat(z(arguments)),r=p();return e.push(r.makeNodeResolver()),s(t).fapply(e).fail(r.reject),r.promise}},d.prototype.nfbind=d.prototype.denodeify=function(){var t=z(arguments);return t.unshift(this),s.denodeify.apply(void 0,t)},s.nbind=function(t,n){var e=z(arguments,2);return function(){function r(){return t.apply(n,arguments)}var o=e.concat(z(arguments)),i=p();return o.push(i.makeNodeResolver()),s(r).fapply(o).fail(i.reject),i.promise}},d.prototype.nbind=function(){var t=z(arguments,0);return t.unshift(this),s.nbind.apply(void 0,t)},s.nmapply=s.npost=function(t,n,e){return s(t).npost(n,e)},d.prototype.nmapply=d.prototype.npost=function(t,n){var e=z(n||[]),r=p();return e.push(r.makeNodeResolver()),this.dispatch("post",[t,e]).fail(r.reject),r.promise},s.nsend=s.nmcall=s.ninvoke=function(t,n){var e=z(arguments,2),r=p();return e.push(r.makeNodeResolver()),s(t).dispatch("post",[n,e]).fail(r.reject),r.promise},d.prototype.nsend=d.prototype.nmcall=d.prototype.ninvoke=function(t){var n=z(arguments,1),e=p();return n.push(e.makeNodeResolver()),this.dispatch("post",[t,n]).fail(e.reject),e.promise},s.nodeify=M,d.prototype.nodeify=function(t){if(!t)return this;this.then(function(n){s.nextTick(function(){t(null,n)})},function(n){s.nextTick(function(){t(n)})})},s.noConflict=function(){throw new Error("Q.noConflict only works when Q is used as a global")};var ft=f();return s});
}).call(this,require('_process'))
},{"_process":66}],44:[function(require,module,exports){
(function (process){
function Duplex(e){if(!(this instanceof Duplex))return new Duplex(e);Readable.call(this,e),Writable.call(this,e),e&&!1===e.readable&&(this.readable=!1),e&&!1===e.writable&&(this.writable=!1),this.allowHalfOpen=!0,e&&!1===e.allowHalfOpen&&(this.allowHalfOpen=!1),this.once("end",onend)}function onend(){this.allowHalfOpen||this._writableState.ended||process.nextTick(this.end.bind(this))}function forEach(e,t){for(var i=0,r=e.length;i<r;i++)t(e[i],i)}module.exports=Duplex;var objectKeys=Object.keys||function(e){var t=[];for(var i in e)t.push(i);return t},util=require("core-util-is");util.inherits=require("inherits");var Readable=require("./_stream_readable"),Writable=require("./_stream_writable");util.inherits(Duplex,Readable),forEach(objectKeys(Writable.prototype),function(e){Duplex.prototype[e]||(Duplex.prototype[e]=Writable.prototype[e])});
}).call(this,require('_process'))
},{"./_stream_readable":46,"./_stream_writable":48,"_process":66,"core-util-is":6,"inherits":19}],45:[function(require,module,exports){
function PassThrough(r){if(!(this instanceof PassThrough))return new PassThrough(r);Transform.call(this,r)}module.exports=PassThrough;var Transform=require("./_stream_transform"),util=require("core-util-is");util.inherits=require("inherits"),util.inherits(PassThrough,Transform),PassThrough.prototype._transform=function(r,s,i){i(null,r)};
},{"./_stream_transform":47,"core-util-is":6,"inherits":19}],46:[function(require,module,exports){
(function (process){
function ReadableState(e,t){var n=require("./_stream_duplex");e=e||{};var r=e.highWaterMark,i=e.objectMode?16:16384;this.highWaterMark=r||0===r?r:i,this.highWaterMark=~~this.highWaterMark,this.buffer=[],this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.objectMode=!!e.objectMode,t instanceof n&&(this.objectMode=this.objectMode||!!e.readableObjectMode),this.defaultEncoding=e.defaultEncoding||"utf8",this.ranOut=!1,this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,e.encoding&&(StringDecoder||(StringDecoder=require("string_decoder/").StringDecoder),this.decoder=new StringDecoder(e.encoding),this.encoding=e.encoding)}function Readable(e){require("./_stream_duplex");if(!(this instanceof Readable))return new Readable(e);this._readableState=new ReadableState(e,this),this.readable=!0,Stream.call(this)}function readableAddChunk(e,t,n,r,i){var a=chunkInvalid(t,n);if(a)e.emit("error",a);else if(util.isNullOrUndefined(n))t.reading=!1,t.ended||onEofChunk(e,t);else if(t.objectMode||n&&n.length>0)if(t.ended&&!i){var d=new Error("stream.push() after EOF");e.emit("error",d)}else if(t.endEmitted&&i){var d=new Error("stream.unshift() after end event");e.emit("error",d)}else!t.decoder||i||r||(n=t.decoder.write(n)),i||(t.reading=!1),t.flowing&&0===t.length&&!t.sync?(e.emit("data",n),e.read(0)):(t.length+=t.objectMode?1:n.length,i?t.buffer.unshift(n):t.buffer.push(n),t.needReadable&&emitReadable(e)),maybeReadMore(e,t);else i||(t.reading=!1);return needMoreData(t)}function needMoreData(e){return!e.ended&&(e.needReadable||e.length<e.highWaterMark||0===e.length)}function roundUpToNextPowerOf2(e){if(e>=MAX_HWM)e=MAX_HWM;else{e--;for(var t=1;t<32;t<<=1)e|=e>>t;e++}return e}function howMuchToRead(e,t){return 0===t.length&&t.ended?0:t.objectMode?0===e?0:1:isNaN(e)||util.isNull(e)?t.flowing&&t.buffer.length?t.buffer[0].length:t.length:e<=0?0:(e>t.highWaterMark&&(t.highWaterMark=roundUpToNextPowerOf2(e)),e>t.length?t.ended?t.length:(t.needReadable=!0,0):e)}function chunkInvalid(e,t){var n=null;return util.isBuffer(t)||util.isString(t)||util.isNullOrUndefined(t)||e.objectMode||(n=new TypeError("Invalid non-string/buffer chunk")),n}function onEofChunk(e,t){if(t.decoder&&!t.ended){var n=t.decoder.end();n&&n.length&&(t.buffer.push(n),t.length+=t.objectMode?1:n.length)}t.ended=!0,emitReadable(e)}function emitReadable(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(debug("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?process.nextTick(function(){emitReadable_(e)}):emitReadable_(e))}function emitReadable_(e){debug("emit readable"),e.emit("readable"),flow(e)}function maybeReadMore(e,t){t.readingMore||(t.readingMore=!0,process.nextTick(function(){maybeReadMore_(e,t)}))}function maybeReadMore_(e,t){for(var n=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length<t.highWaterMark&&(debug("maybeReadMore read 0"),e.read(0),n!==t.length);)n=t.length;t.readingMore=!1}function pipeOnDrain(e){return function(){var t=e._readableState;debug("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&EE.listenerCount(e,"data")&&(t.flowing=!0,flow(e))}}function resume(e,t){t.resumeScheduled||(t.resumeScheduled=!0,process.nextTick(function(){resume_(e,t)}))}function resume_(e,t){t.resumeScheduled=!1,e.emit("resume"),flow(e),t.flowing&&!t.reading&&e.read(0)}function flow(e){var t=e._readableState;if(debug("flow",t.flowing),t.flowing)do{var n=e.read()}while(null!==n&&t.flowing)}function fromList(e,t){var n,r=t.buffer,i=t.length,a=!!t.decoder,d=!!t.objectMode;if(0===r.length)return null;if(0===i)n=null;else if(d)n=r.shift();else if(!e||e>=i)n=a?r.join(""):Buffer.concat(r,i),r.length=0;else if(e<r[0].length){var o=r[0];n=o.slice(0,e),r[0]=o.slice(e)}else if(e===r[0].length)n=r.shift();else{n=a?"":new Buffer(e);for(var l=0,u=0,s=r.length;u<s&&l<e;u++){var o=r[0],h=Math.min(e-l,o.length);a?n+=o.slice(0,h):o.copy(n,l,0,h),h<o.length?r[0]=o.slice(h):r.shift(),l+=h}}return n}function endReadable(e){var t=e._readableState;if(t.length>0)throw new Error("endReadable called on non-empty stream");t.endEmitted||(t.ended=!0,process.nextTick(function(){t.endEmitted||0!==t.length||(t.endEmitted=!0,e.readable=!1,e.emit("end"))}))}function forEach(e,t){for(var n=0,r=e.length;n<r;n++)t(e[n],n)}function indexOf(e,t){for(var n=0,r=e.length;n<r;n++)if(e[n]===t)return n;return-1}module.exports=Readable;var isArray=require("isarray"),Buffer=require("buffer").Buffer;Readable.ReadableState=ReadableState;var EE=require("events").EventEmitter;EE.listenerCount||(EE.listenerCount=function(e,t){return e.listeners(t).length});var Stream=require("stream"),util=require("core-util-is");util.inherits=require("inherits");var StringDecoder,debug=require("util");debug=debug&&debug.debuglog?debug.debuglog("stream"):function(){},util.inherits(Readable,Stream),Readable.prototype.push=function(e,t){var n=this._readableState;return util.isString(e)&&!n.objectMode&&(t=t||n.defaultEncoding)!==n.encoding&&(e=new Buffer(e,t),t=""),readableAddChunk(this,n,e,t,!1)},Readable.prototype.unshift=function(e){return readableAddChunk(this,this._readableState,e,"",!0)},Readable.prototype.setEncoding=function(e){return StringDecoder||(StringDecoder=require("string_decoder/").StringDecoder),this._readableState.decoder=new StringDecoder(e),this._readableState.encoding=e,this};var MAX_HWM=8388608;Readable.prototype.read=function(e){debug("read",e);var t=this._readableState,n=e;if((!util.isNumber(e)||e>0)&&(t.emittedReadable=!1),0===e&&t.needReadable&&(t.length>=t.highWaterMark||t.ended))return debug("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?endReadable(this):emitReadable(this),null;if(0===(e=howMuchToRead(e,t))&&t.ended)return 0===t.length&&endReadable(this),null;var r=t.needReadable;debug("need readable",r),(0===t.length||t.length-e<t.highWaterMark)&&(r=!0,debug("length less than watermark",r)),(t.ended||t.reading)&&(r=!1,debug("reading or ended",r)),r&&(debug("do read"),t.reading=!0,t.sync=!0,0===t.length&&(t.needReadable=!0),this._read(t.highWaterMark),t.sync=!1),r&&!t.reading&&(e=howMuchToRead(n,t));var i;return i=e>0?fromList(e,t):null,util.isNull(i)&&(t.needReadable=!0,e=0),t.length-=e,0!==t.length||t.ended||(t.needReadable=!0),n!==e&&t.ended&&0===t.length&&endReadable(this),util.isNull(i)||this.emit("data",i),i},Readable.prototype._read=function(e){this.emit("error",new Error("not implemented"))},Readable.prototype.pipe=function(e,t){function n(e){debug("onunpipe"),e===s&&i()}function r(){debug("onend"),e.end()}function i(){debug("cleanup"),e.removeListener("close",o),e.removeListener("finish",l),e.removeListener("drain",c),e.removeListener("error",d),e.removeListener("unpipe",n),s.removeListener("end",r),s.removeListener("end",i),s.removeListener("data",a),!h.awaitDrain||e._writableState&&!e._writableState.needDrain||c()}function a(t){debug("ondata"),!1===e.write(t)&&(debug("false write response, pause",s._readableState.awaitDrain),s._readableState.awaitDrain++,s.pause())}function d(t){debug("onerror",t),u(),e.removeListener("error",d),0===EE.listenerCount(e,"error")&&e.emit("error",t)}function o(){e.removeListener("finish",l),u()}function l(){debug("onfinish"),e.removeListener("close",o),u()}function u(){debug("unpipe"),s.unpipe(e)}var s=this,h=this._readableState;switch(h.pipesCount){case 0:h.pipes=e;break;case 1:h.pipes=[h.pipes,e];break;default:h.pipes.push(e)}h.pipesCount+=1,debug("pipe count=%d opts=%j",h.pipesCount,t);var f=(!t||!1!==t.end)&&e!==process.stdout&&e!==process.stderr,b=f?r:i;h.endEmitted?process.nextTick(b):s.once("end",b),e.on("unpipe",n);var c=pipeOnDrain(s);return e.on("drain",c),s.on("data",a),e._events&&e._events.error?isArray(e._events.error)?e._events.error.unshift(d):e._events.error=[d,e._events.error]:e.on("error",d),e.once("close",o),e.once("finish",l),e.emit("pipe",s),h.flowing||(debug("pipe resume"),s.resume()),e},Readable.prototype.unpipe=function(e){var t=this._readableState;if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes?this:(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this),this);if(!e){var n=t.pipes,r=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var i=0;i<r;i++)n[i].emit("unpipe",this);return this}var i=indexOf(t.pipes,e);return-1===i?this:(t.pipes.splice(i,1),t.pipesCount-=1,1===t.pipesCount&&(t.pipes=t.pipes[0]),e.emit("unpipe",this),this)},Readable.prototype.on=function(e,t){var n=Stream.prototype.on.call(this,e,t);if("data"===e&&!1!==this._readableState.flowing&&this.resume(),"readable"===e&&this.readable){var r=this._readableState;if(!r.readableListening)if(r.readableListening=!0,r.emittedReadable=!1,r.needReadable=!0,r.reading)r.length&&emitReadable(this,r);else{var i=this;process.nextTick(function(){debug("readable nexttick read 0"),i.read(0)})}}return n},Readable.prototype.addListener=Readable.prototype.on,Readable.prototype.resume=function(){var e=this._readableState;return e.flowing||(debug("resume"),e.flowing=!0,e.reading||(debug("resume read 0"),this.read(0)),resume(this,e)),this},Readable.prototype.pause=function(){return debug("call pause flowing=%j",this._readableState.flowing),!1!==this._readableState.flowing&&(debug("pause"),this._readableState.flowing=!1,this.emit("pause")),this},Readable.prototype.wrap=function(e){var t=this._readableState,n=!1,r=this;e.on("end",function(){if(debug("wrapped end"),t.decoder&&!t.ended){var e=t.decoder.end();e&&e.length&&r.push(e)}r.push(null)}),e.on("data",function(i){if(debug("wrapped data"),t.decoder&&(i=t.decoder.write(i)),i&&(t.objectMode||i.length)){r.push(i)||(n=!0,e.pause())}});for(var i in e)util.isFunction(e[i])&&util.isUndefined(this[i])&&(this[i]=function(t){return function(){return e[t].apply(e,arguments)}}(i));return forEach(["error","close","destroy","pause","resume"],function(t){e.on(t,r.emit.bind(r,t))}),r._read=function(t){debug("wrapped _read",t),n&&(n=!1,e.resume())},r},Readable._fromList=fromList;
}).call(this,require('_process'))
},{"./_stream_duplex":44,"_process":66,"buffer":56,"core-util-is":6,"events":59,"inherits":19,"isarray":21,"stream":82,"string_decoder/":50,"util":54}],47:[function(require,module,exports){
function TransformState(r,t){this.afterTransform=function(r,n){return afterTransform(t,r,n)},this.needTransform=!1,this.transforming=!1,this.writecb=null,this.writechunk=null}function afterTransform(r,t,n){var e=r._transformState;e.transforming=!1;var i=e.writecb;if(!i)return r.emit("error",new Error("no writecb in Transform class"));e.writechunk=null,e.writecb=null,util.isNullOrUndefined(n)||r.push(n),i&&i(t);var a=r._readableState;a.reading=!1,(a.needReadable||a.length<a.highWaterMark)&&r._read(a.highWaterMark)}function Transform(r){if(!(this instanceof Transform))return new Transform(r);Duplex.call(this,r),this._transformState=new TransformState(r,this);var t=this;this._readableState.needReadable=!0,this._readableState.sync=!1,this.once("prefinish",function(){util.isFunction(this._flush)?this._flush(function(r){done(t,r)}):done(t)})}function done(r,t){if(t)return r.emit("error",t);var n=r._writableState,e=r._transformState;if(n.length)throw new Error("calling transform done when ws.length != 0");if(e.transforming)throw new Error("calling transform done when still transforming");return r.push(null)}module.exports=Transform;var Duplex=require("./_stream_duplex"),util=require("core-util-is");util.inherits=require("inherits"),util.inherits(Transform,Duplex),Transform.prototype.push=function(r,t){return this._transformState.needTransform=!1,Duplex.prototype.push.call(this,r,t)},Transform.prototype._transform=function(r,t,n){throw new Error("not implemented")},Transform.prototype._write=function(r,t,n){var e=this._transformState;if(e.writecb=n,e.writechunk=r,e.writeencoding=t,!e.transforming){var i=this._readableState;(e.needTransform||i.needReadable||i.length<i.highWaterMark)&&this._read(i.highWaterMark)}},Transform.prototype._read=function(r){var t=this._transformState;util.isNull(t.writechunk)||!t.writecb||t.transforming?t.needTransform=!0:(t.transforming=!0,this._transform(t.writechunk,t.writeencoding,t.afterTransform))};
},{"./_stream_duplex":44,"core-util-is":6,"inherits":19}],48:[function(require,module,exports){
(function (process){
function WriteReq(e,i,t){this.chunk=e,this.encoding=i,this.callback=t}function WritableState(e,i){var t=require("./_stream_duplex");e=e||{};var r=e.highWaterMark,n=e.objectMode?16:16384;this.highWaterMark=r||0===r?r:n,this.objectMode=!!e.objectMode,i instanceof t&&(this.objectMode=this.objectMode||!!e.writableObjectMode),this.highWaterMark=~~this.highWaterMark,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1;var f=!1===e.decodeStrings;this.decodeStrings=!f,this.defaultEncoding=e.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(e){onwrite(i,e)},this.writecb=null,this.writelen=0,this.buffer=[],this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1}function Writable(e){var i=require("./_stream_duplex");if(!(this instanceof Writable||this instanceof i))return new Writable(e);this._writableState=new WritableState(e,this),this.writable=!0,Stream.call(this)}function writeAfterEnd(e,i,t){var r=new Error("write after end");e.emit("error",r),process.nextTick(function(){t(r)})}function validChunk(e,i,t,r){var n=!0;if(!(util.isBuffer(t)||util.isString(t)||util.isNullOrUndefined(t)||i.objectMode)){var f=new TypeError("Invalid non-string/buffer chunk");e.emit("error",f),process.nextTick(function(){r(f)}),n=!1}return n}function decodeChunk(e,i,t){return!e.objectMode&&!1!==e.decodeStrings&&util.isString(i)&&(i=new Buffer(i,t)),i}function writeOrBuffer(e,i,t,r,n){t=decodeChunk(i,t,r),util.isBuffer(t)&&(r="buffer");var f=i.objectMode?1:t.length;i.length+=f;var o=i.length<i.highWaterMark;return o||(i.needDrain=!0),i.writing||i.corked?i.buffer.push(new WriteReq(t,r,n)):doWrite(e,i,!1,f,t,r,n),o}function doWrite(e,i,t,r,n,f,o){i.writelen=r,i.writecb=o,i.writing=!0,i.sync=!0,t?e._writev(n,i.onwrite):e._write(n,f,i.onwrite),i.sync=!1}function onwriteError(e,i,t,r,n){t?process.nextTick(function(){i.pendingcb--,n(r)}):(i.pendingcb--,n(r)),e._writableState.errorEmitted=!0,e.emit("error",r)}function onwriteStateUpdate(e){e.writing=!1,e.writecb=null,e.length-=e.writelen,e.writelen=0}function onwrite(e,i){var t=e._writableState,r=t.sync,n=t.writecb;if(onwriteStateUpdate(t),i)onwriteError(e,t,r,i,n);else{var f=needFinish(e,t);f||t.corked||t.bufferProcessing||!t.buffer.length||clearBuffer(e,t),r?process.nextTick(function(){afterWrite(e,t,f,n)}):afterWrite(e,t,f,n)}}function afterWrite(e,i,t,r){t||onwriteDrain(e,i),i.pendingcb--,r(),finishMaybe(e,i)}function onwriteDrain(e,i){0===i.length&&i.needDrain&&(i.needDrain=!1,e.emit("drain"))}function clearBuffer(e,i){if(i.bufferProcessing=!0,e._writev&&i.buffer.length>1){for(var t=[],r=0;r<i.buffer.length;r++)t.push(i.buffer[r].callback);i.pendingcb++,doWrite(e,i,!0,i.length,i.buffer,"",function(e){for(var r=0;r<t.length;r++)i.pendingcb--,t[r](e)}),i.buffer=[]}else{for(var r=0;r<i.buffer.length;r++){var n=i.buffer[r],f=n.chunk,o=n.encoding,u=n.callback,s=i.objectMode?1:f.length;if(doWrite(e,i,!1,s,f,o,u),i.writing){r++;break}}r<i.buffer.length?i.buffer=i.buffer.slice(r):i.buffer.length=0}i.bufferProcessing=!1}function needFinish(e,i){return i.ending&&0===i.length&&!i.finished&&!i.writing}function prefinish(e,i){i.prefinished||(i.prefinished=!0,e.emit("prefinish"))}function finishMaybe(e,i){var t=needFinish(e,i);return t&&(0===i.pendingcb?(prefinish(e,i),i.finished=!0,e.emit("finish")):prefinish(e,i)),t}function endWritable(e,i,t){i.ending=!0,finishMaybe(e,i),t&&(i.finished?process.nextTick(t):e.once("finish",t)),i.ended=!0}module.exports=Writable;var Buffer=require("buffer").Buffer;Writable.WritableState=WritableState;var util=require("core-util-is");util.inherits=require("inherits");var Stream=require("stream");util.inherits(Writable,Stream),Writable.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe. Not readable."))},Writable.prototype.write=function(e,i,t){var r=this._writableState,n=!1;return util.isFunction(i)&&(t=i,i=null),util.isBuffer(e)?i="buffer":i||(i=r.defaultEncoding),util.isFunction(t)||(t=function(){}),r.ended?writeAfterEnd(this,r,t):validChunk(this,r,e,t)&&(r.pendingcb++,n=writeOrBuffer(this,r,e,i,t)),n},Writable.prototype.cork=function(){this._writableState.corked++},Writable.prototype.uncork=function(){var e=this._writableState;e.corked&&(e.corked--,e.writing||e.corked||e.finished||e.bufferProcessing||!e.buffer.length||clearBuffer(this,e))},Writable.prototype._write=function(e,i,t){t(new Error("not implemented"))},Writable.prototype._writev=null,Writable.prototype.end=function(e,i,t){var r=this._writableState;util.isFunction(e)?(t=e,e=null,i=null):util.isFunction(i)&&(t=i,i=null),util.isNullOrUndefined(e)||this.write(e,i),r.corked&&(r.corked=1,this.uncork()),r.ending||r.finished||endWritable(this,r,t)};
}).call(this,require('_process'))
},{"./_stream_duplex":44,"_process":66,"buffer":56,"core-util-is":6,"inherits":19,"stream":82}],49:[function(require,module,exports){
(function (process){
exports=module.exports=require("./lib/_stream_readable.js"),exports.Stream=require("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"),process.browser||"disable"!==process.env.READABLE_STREAM||(module.exports=require("stream"));
}).call(this,require('_process'))
},{"./lib/_stream_duplex.js":44,"./lib/_stream_passthrough.js":45,"./lib/_stream_readable.js":46,"./lib/_stream_transform.js":47,"./lib/_stream_writable.js":48,"_process":66,"stream":82}],50:[function(require,module,exports){
function assertEncoding(e){if(e&&!isBufferEncoding(e))throw new Error("Unknown encoding: "+e)}function passThroughWrite(e){return e.toString(this.encoding)}function utf16DetectIncompleteChar(e){this.charReceived=e.length%2,this.charLength=this.charReceived?2:0}function base64DetectIncompleteChar(e){this.charReceived=e.length%3,this.charLength=this.charReceived?3:0}var Buffer=require("buffer").Buffer,isBufferEncoding=Buffer.isEncoding||function(e){switch(e&&e.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!0;default:return!1}},StringDecoder=exports.StringDecoder=function(e){switch(this.encoding=(e||"utf8").toLowerCase().replace(/[-_]/,""),assertEncoding(e),this.encoding){case"utf8":this.surrogateSize=3;break;case"ucs2":case"utf16le":this.surrogateSize=2,this.detectIncompleteChar=utf16DetectIncompleteChar;break;case"base64":this.surrogateSize=3,this.detectIncompleteChar=base64DetectIncompleteChar;break;default:return void(this.write=passThroughWrite)}this.charBuffer=new Buffer(6),this.charReceived=0,this.charLength=0};StringDecoder.prototype.write=function(e){for(var t="";this.charLength;){var r=e.length>=this.charLength-this.charReceived?this.charLength-this.charReceived:e.length;if(e.copy(this.charBuffer,this.charReceived,0,r),this.charReceived+=r,this.charReceived<this.charLength)return"";e=e.slice(r,e.length),t=this.charBuffer.slice(0,this.charLength).toString(this.encoding);var h=t.charCodeAt(t.length-1);if(!(h>=55296&&h<=56319)){if(this.charReceived=this.charLength=0,0===e.length)return t;break}this.charLength+=this.surrogateSize,t=""}this.detectIncompleteChar(e);var i=e.length;this.charLength&&(e.copy(this.charBuffer,0,e.length-this.charReceived,i),i-=this.charReceived),t+=e.toString(this.encoding,0,i);var i=t.length-1,h=t.charCodeAt(i);if(h>=55296&&h<=56319){var c=this.surrogateSize;return this.charLength+=c,this.charReceived+=c,this.charBuffer.copy(this.charBuffer,c,0,c),e.copy(this.charBuffer,0,0,c),t.substring(0,i)}return t},StringDecoder.prototype.detectIncompleteChar=function(e){for(var t=e.length>=3?3:e.length;t>0;t--){var r=e[e.length-t];if(1==t&&r>>5==6){this.charLength=2;break}if(t<=2&&r>>4==14){this.charLength=3;break}if(t<=3&&r>>3==30){this.charLength=4;break}}this.charReceived=t},StringDecoder.prototype.end=function(e){var t="";if(e&&e.length&&(t=this.write(e)),this.charReceived){var r=this.charReceived,h=this.charBuffer,i=this.encoding;t+=h.slice(0,r).toString(i)}return t};
},{"buffer":56}],51:[function(require,module,exports){
(function (global){
!function(e){"use strict";function t(e){var n;if(null===e||void 0===e)return!1;if(r.isArray(e))return e.length>0;if("string"==typeof e||"number"==typeof e||"boolean"==typeof e)return!0;for(n in e)if(e.hasOwnProperty(n)&&t(e[n]))return!0;return!1}var n=function(){function e(e){this.options=e}return e.prototype.toString=function(){return JSON&&JSON.stringify?JSON.stringify(this.options):this.options},e}(),r=function(){function e(e){return"[object Array]"===Object.prototype.toString.apply(e)}function t(e){return"[object String]"===Object.prototype.toString.apply(e)}function n(e){return"[object Number]"===Object.prototype.toString.apply(e)}function r(e){return"[object Boolean]"===Object.prototype.toString.apply(e)}function i(e,t){var n,r="",i=!0;for(n=0;n<e.length;n+=1)i?i=!1:r+=t,r+=e[n];return r}function o(e,t){for(var n=[],r=0;r<e.length;r+=1)n.push(t(e[r]));return n}function s(e,t){for(var n=[],r=0;r<e.length;r+=1)t(e[r])&&n.push(e[r]);return n}function a(e){if("object"!=typeof e||null===e)return e;Object.freeze(e);var t,n;for(n in e)e.hasOwnProperty(n)&&"object"==typeof(t=e[n])&&u(t);return e}function u(e){return"function"==typeof Object.freeze?a(e):e}return{isArray:e,isString:t,isNumber:n,isBoolean:r,join:i,map:o,filter:s,deepFreeze:u}}(),i=function(){function e(e){return e>="a"&&e<="z"||e>="A"&&e<="Z"}function t(e){return e>="0"&&e<="9"}function n(e){return t(e)||e>="a"&&e<="f"||e>="A"&&e<="F"}return{isAlpha:e,isDigit:t,isHexDigit:n}}(),o=function(){function e(e){var t,n,r="",i=s.encode(e);for(n=0;n<i.length;n+=1)t=i.charCodeAt(n),r+="%"+(t<16?"0":"")+t.toString(16).toUpperCase();return r}function t(e,t){return"%"===e.charAt(t)&&i.isHexDigit(e.charAt(t+1))&&i.isHexDigit(e.charAt(t+2))}function n(e,t){return parseInt(e.substr(t,2),16)}function r(e){if(!t(e,0))return!1;var r=n(e,1),i=s.numBytes(r);if(0===i)return!1;for(var o=1;o<i;o+=1)if(!t(e,3*o)||!s.isValidFollowingCharCode(n(e,3*o+1)))return!1;return!0}function o(e,r){var i=e.charAt(r);if(!t(e,r))return i;var o=n(e,r+1),a=s.numBytes(o);if(0===a)return i;for(var u=1;u<a;u+=1)if(!t(e,r+3*u)||!s.isValidFollowingCharCode(n(e,r+3*u+1)))return i;return e.substr(r,3*a)}var s={encode:function(e){return unescape(encodeURIComponent(e))},numBytes:function(e){return e<=127?1:194<=e&&e<=223?2:224<=e&&e<=239?3:240<=e&&e<=244?4:0},isValidFollowingCharCode:function(e){return 128<=e&&e<=191}};return{encodeCharacter:e,isPctEncoded:r,pctCharAt:o}}(),s=function(){function e(e){return i.isAlpha(e)||i.isDigit(e)||"_"===e||o.isPctEncoded(e)}function t(e){return i.isAlpha(e)||i.isDigit(e)||"-"===e||"."===e||"_"===e||"~"===e}function n(e){return":"===e||"/"===e||"?"===e||"#"===e||"["===e||"]"===e||"@"===e||"!"===e||"$"===e||"&"===e||"("===e||")"===e||"*"===e||"+"===e||","===e||";"===e||"="===e||"'"===e}return{isVarchar:e,isUnreserved:t,isReserved:n}}(),a=function(){function e(e,t){var n,r="",i="";for("number"!=typeof e&&"boolean"!=typeof e||(e=e.toString()),n=0;n<e.length;n+=i.length)i=e.charAt(n),r+=s.isUnreserved(i)||t&&s.isReserved(i)?i:o.encodeCharacter(i);return r}function t(t){return e(t,!0)}function n(e,t){var n=o.pctCharAt(e,t);return n.length>1?n:s.isReserved(n)||s.isUnreserved(n)?n:o.encodeCharacter(n)}function r(e){var t,n="",r="";for(t=0;t<e.length;t+=r.length)r=o.pctCharAt(e,t),r.length>1?n+=r:n+=s.isReserved(r)||s.isUnreserved(r)?r:o.encodeCharacter(r);return n}return{encode:e,encodePassReserved:t,encodeLiteral:r,encodeLiteralCharacter:n}}(),u=function(){function e(e){t[e]={symbol:e,separator:"?"===e?"&":""===e||"+"===e||"#"===e?",":e,named:";"===e||"&"===e||"?"===e,ifEmpty:"&"===e||"?"===e?"=":"",first:"+"===e?"":e,encode:"+"===e||"#"===e?a.encodePassReserved:a.encode,toString:function(){return this.symbol}}}var t={};return e(""),e("+"),e("#"),e("."),e("/"),e(";"),e("?"),e("&"),{valueOf:function(e){return t[e]?t[e]:"=,!@|".indexOf(e)>=0?null:t[""]}}}(),f=function(){function e(e){this.literal=a.encodeLiteral(e)}return e.prototype.expand=function(){return this.literal},e.prototype.toString=e.prototype.expand,e}(),p=function(){function e(e){function t(){var t=e.substring(h,f);if(0===t.length)throw new n({expressionText:e,message:"a varname must be specified",position:f});c={varname:t,exploded:!1,maxLength:null},h=null}function r(){if(d===f)throw new n({expressionText:e,message:"after a ':' you have to specify the length",position:f});c.maxLength=parseInt(e.substring(d,f),10),d=null}var a,f,p=[],c=null,h=null,d=null,g="";for(a=function(t){var r=u.valueOf(t);if(null===r)throw new n({expressionText:e,message:"illegal use of reserved operator",position:f,operator:t});return r}(e.charAt(0)),f=a.symbol.length,h=f;f<e.length;f+=g.length){if(g=o.pctCharAt(e,f),null!==h){if("."===g){if(h===f)throw new n({expressionText:e,message:"a varname MUST NOT start with a dot",position:f});continue}if(s.isVarchar(g))continue;t()}if(null!==d){if(f===d&&"0"===g)throw new n({expressionText:e,message:"A :prefix must not start with digit 0",position:f});if(i.isDigit(g)){if(f-d>=4)throw new n({expressionText:e,message:"A :prefix must have max 4 digits",position:f});continue}r()}if(":"!==g)if("*"!==g){if(","!==g)throw new n({expressionText:e,message:"illegal character",character:g,position:f});p.push(c),c=null,h=f+1}else{if(null===c)throw new n({expressionText:e,message:"exploded without varspec",position:f});if(c.exploded)throw new n({expressionText:e,message:"exploded twice",position:f});if(c.maxLength)throw new n({expressionText:e,message:"an explode (*) MUST NOT follow to a prefix",position:f});c.exploded=!0}else{if(null!==c.maxLength)throw new n({expressionText:e,message:"only one :maxLength is allowed per varspec",position:f});if(c.exploded)throw new n({expressionText:e,message:"an exploeded varspec MUST NOT be varspeced",position:f});d=f+1}}return null!==h&&t(),null!==d&&r(),p.push(c),new l(e,a,p)}function t(t){var r,i,o=[],s=null,a=0;for(r=0;r<t.length;r+=1)if(i=t.charAt(r),null===a){if(null===s)throw new Error("reached unreachable code");if("{"===i)throw new n({templateText:t,message:"brace already opened",position:r});if("}"===i){if(s+1===r)throw new n({templateText:t,message:"empty braces",position:s});try{o.push(e(t.substring(s+1,r)))}catch(e){if(e.prototype===n.prototype)throw new n({templateText:t,message:e.options.message,position:s+e.options.position,details:e.options});throw e}s=null,a=r+1}}else{if("}"===i)throw new n({templateText:t,message:"unopened brace closed",position:r});"{"===i&&(a<r&&o.push(new f(t.substring(a,r))),a=null,s=r)}if(null!==s)throw new n({templateText:t,message:"unclosed brace",position:s});return a<t.length&&o.push(new f(t.substr(a))),new c(t,o)}return t}(),l=function(){function e(e){return JSON&&JSON.stringify?JSON.stringify(e):e}function n(e){if(!t(e))return!0;if(r.isString(e))return""===e;if(r.isNumber(e)||r.isBoolean(e))return!1;if(r.isArray(e))return 0===e.length;for(var n in e)if(e.hasOwnProperty(n))return!1;return!0}function i(e){var t,n=[];for(t in e)e.hasOwnProperty(t)&&n.push({name:t,value:e[t]});return n}function o(e,t,n){this.templateText=e,this.operator=t,this.varspecs=n}function s(e,t,n){var r="";if(n=n.toString(),t.named){if(r+=a.encodeLiteral(e.varname),""===n)return r+=t.ifEmpty;r+="="}return null!==e.maxLength&&(n=n.substr(0,e.maxLength)),r+=t.encode(n)}function u(e){return t(e.value)}function f(e,o,s){var f=[],p="";if(o.named){if(p+=a.encodeLiteral(e.varname),n(s))return p+=o.ifEmpty;p+="="}return r.isArray(s)?(f=s,f=r.filter(f,t),f=r.map(f,o.encode),p+=r.join(f,",")):(f=i(s),f=r.filter(f,u),f=r.map(f,function(e){return o.encode(e.name)+","+o.encode(e.value)}),p+=r.join(f,",")),p}function p(e,o,s){var f=r.isArray(s),p=[];return f?(p=s,p=r.filter(p,t),p=r.map(p,function(t){var r=a.encodeLiteral(e.varname);return n(t)?r+=o.ifEmpty:r+="="+o.encode(t),r})):(p=i(s),p=r.filter(p,u),p=r.map(p,function(e){var t=a.encodeLiteral(e.name);return n(e.value)?t+=o.ifEmpty:t+="="+o.encode(e.value),t})),r.join(p,o.separator)}function l(e,n){var o=[],s="";return r.isArray(n)?(o=n,o=r.filter(o,t),o=r.map(o,e.encode),s+=r.join(o,e.separator)):(o=i(n),o=r.filter(o,function(e){return t(e.value)}),o=r.map(o,function(t){return e.encode(t.name)+"="+e.encode(t.value)}),s+=r.join(o,e.separator)),s}return o.prototype.toString=function(){return this.templateText},o.prototype.expand=function(i){var o,a,u,c=[],h=this.operator;for(o=0;o<this.varspecs.length;o+=1)if(a=this.varspecs[o],null!==(u=i[a.varname])&&void 0!==u)if(a.exploded&&!0,r.isArray(u),"string"==typeof u||"number"==typeof u||"boolean"==typeof u)c.push(s(a,h,u));else{if(a.maxLength&&t(u))throw new Error("Prefix modifiers are not applicable to variables that have composite values. You tried to expand "+this+" with "+e(u));a.exploded?t(u)&&(h.named?c.push(p(a,h,u)):c.push(l(h,u))):!h.named&&n(u)||c.push(f(a,h,u))}return 0===c.length?"":h.first+r.join(c,h.separator)},o}(),c=function(){function e(e,t){this.templateText=e,this.expressions=t,r.deepFreeze(this)}return e.prototype.toString=function(){return this.templateText},e.prototype.expand=function(e){var t,n="";for(t=0;t<this.expressions.length;t+=1)n+=this.expressions[t].expand(e);return n},e.parse=p,e.UriTemplateError=n,e}();!function(e){"undefined"!=typeof module?module.exports=e:"function"==typeof define?define([],function(){return e}):"undefined"!=typeof window?window.UriTemplate=e:global.UriTemplate=e}(c)}();
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
},{}],52:[function(require,module,exports){
function wrappy(n,r){function e(){for(var r=new Array(arguments.length),e=0;e<r.length;e++)r[e]=arguments[e];var t=n.apply(this,r),o=r[r.length-1];return"function"==typeof t&&t!==o&&Object.keys(o).forEach(function(n){t[n]=o[n]}),t}if(n&&r)return wrappy(n)(r);if("function"!=typeof n)throw new TypeError("need wrapper function");return Object.keys(n).forEach(function(r){e[r]=n[r]}),e}module.exports=wrappy;
},{}],53:[function(require,module,exports){
"use strict";function placeHoldersCount(o){var r=o.length;if(r%4>0)throw new Error("Invalid string. Length must be a multiple of 4");return"="===o[r-2]?2:"="===o[r-1]?1:0}function byteLength(o){return 3*o.length/4-placeHoldersCount(o)}function toByteArray(o){var r,e,t,u,n,p,a=o.length;n=placeHoldersCount(o),p=new Arr(3*a/4-n),t=n>0?a-4:a;var l=0;for(r=0,e=0;r<t;r+=4,e+=3)u=revLookup[o.charCodeAt(r)]<<18|revLookup[o.charCodeAt(r+1)]<<12|revLookup[o.charCodeAt(r+2)]<<6|revLookup[o.charCodeAt(r+3)],p[l++]=u>>16&255,p[l++]=u>>8&255,p[l++]=255&u;return 2===n?(u=revLookup[o.charCodeAt(r)]<<2|revLookup[o.charCodeAt(r+1)]>>4,p[l++]=255&u):1===n&&(u=revLookup[o.charCodeAt(r)]<<10|revLookup[o.charCodeAt(r+1)]<<4|revLookup[o.charCodeAt(r+2)]>>2,p[l++]=u>>8&255,p[l++]=255&u),p}function tripletToBase64(o){return lookup[o>>18&63]+lookup[o>>12&63]+lookup[o>>6&63]+lookup[63&o]}function encodeChunk(o,r,e){for(var t,u=[],n=r;n<e;n+=3)t=(o[n]<<16)+(o[n+1]<<8)+o[n+2],u.push(tripletToBase64(t));return u.join("")}function fromByteArray(o){for(var r,e=o.length,t=e%3,u="",n=[],p=0,a=e-t;p<a;p+=16383)n.push(encodeChunk(o,p,p+16383>a?a:p+16383));return 1===t?(r=o[e-1],u+=lookup[r>>2],u+=lookup[r<<4&63],u+="=="):2===t&&(r=(o[e-2]<<8)+o[e-1],u+=lookup[r>>10],u+=lookup[r>>4&63],u+=lookup[r<<2&63],u+="="),n.push(u),n.join("")}exports.byteLength=byteLength,exports.toByteArray=toByteArray,exports.fromByteArray=fromByteArray;for(var lookup=[],revLookup=[],Arr="undefined"!=typeof Uint8Array?Uint8Array:Array,code="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",i=0,len=code.length;i<len;++i)lookup[i]=code[i],revLookup[code.charCodeAt(i)]=i;revLookup["-".charCodeAt(0)]=62,revLookup["_".charCodeAt(0)]=63;
},{}],54:[function(require,module,exports){
arguments[4][26][0].apply(exports,arguments)
},{"dup":26}],55:[function(require,module,exports){
(function (global){
"use strict";var buffer=require("buffer"),Buffer=buffer.Buffer,SlowBuffer=buffer.SlowBuffer,MAX_LEN=buffer.kMaxLength||2147483647;exports.alloc=function(r,e,f){if("function"==typeof Buffer.alloc)return Buffer.alloc(r,e,f);if("number"==typeof f)throw new TypeError("encoding must not be number");if("number"!=typeof r)throw new TypeError("size must be a number");if(r>MAX_LEN)throw new RangeError("size is too large");var n=f,o=e;void 0===o&&(n=void 0,o=0);var t=new Buffer(r);if("string"==typeof o)for(var u=new Buffer(o,n),i=u.length,a=-1;++a<r;)t[a]=u[a%i];else t.fill(o);return t},exports.allocUnsafe=function(r){if("function"==typeof Buffer.allocUnsafe)return Buffer.allocUnsafe(r);if("number"!=typeof r)throw new TypeError("size must be a number");if(r>MAX_LEN)throw new RangeError("size is too large");return new Buffer(r)},exports.from=function(r,e,f){if("function"==typeof Buffer.from&&(!global.Uint8Array||Uint8Array.from!==Buffer.from))return Buffer.from(r,e,f);if("number"==typeof r)throw new TypeError('"value" argument must not be a number');if("string"==typeof r)return new Buffer(r,e);if("undefined"!=typeof ArrayBuffer&&r instanceof ArrayBuffer){var n=e;if(1===arguments.length)return new Buffer(r);void 0===n&&(n=0);var o=f;if(void 0===o&&(o=r.byteLength-n),n>=r.byteLength)throw new RangeError("'offset' is out of bounds");if(o>r.byteLength-n)throw new RangeError("'length' is out of bounds");return new Buffer(r.slice(n,n+o))}if(Buffer.isBuffer(r)){var t=new Buffer(r.length);return r.copy(t,0,0,r.length),t}if(r){if(Array.isArray(r)||"undefined"!=typeof ArrayBuffer&&r.buffer instanceof ArrayBuffer||"length"in r)return new Buffer(r);if("Buffer"===r.type&&Array.isArray(r.data))return new Buffer(r.data)}throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")},exports.allocUnsafeSlow=function(r){if("function"==typeof Buffer.allocUnsafeSlow)return Buffer.allocUnsafeSlow(r);if("number"!=typeof r)throw new TypeError("size must be a number");if(r>=MAX_LEN)throw new RangeError("size is too large");return new SlowBuffer(r)};
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
},{"buffer":56}],56:[function(require,module,exports){
"use strict";function typedArraySupport(){try{var e=new Uint8Array(1);return e.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===e.foo()}catch(e){return!1}}function createBuffer(e){if(e>K_MAX_LENGTH)throw new RangeError("Invalid typed array length");var t=new Uint8Array(e);return t.__proto__=Buffer.prototype,t}function Buffer(e,t,r){if("number"==typeof e){if("string"==typeof t)throw new Error("If encoding is specified then the first argument must be a string");return allocUnsafe(e)}return from(e,t,r)}function from(e,t,r){if("number"==typeof e)throw new TypeError('"value" argument must not be a number');return e instanceof ArrayBuffer?fromArrayBuffer(e,t,r):"string"==typeof e?fromString(e,t):fromObject(e)}function assertSize(e){if("number"!=typeof e)throw new TypeError('"size" argument must be a number');if(e<0)throw new RangeError('"size" argument must not be negative')}function alloc(e,t,r){return assertSize(e),e<=0?createBuffer(e):void 0!==t?"string"==typeof r?createBuffer(e).fill(t,r):createBuffer(e).fill(t):createBuffer(e)}function allocUnsafe(e){return assertSize(e),createBuffer(e<0?0:0|checked(e))}function fromString(e,t){if("string"==typeof t&&""!==t||(t="utf8"),!Buffer.isEncoding(t))throw new TypeError('"encoding" must be a valid string encoding');var r=0|byteLength(e,t),n=createBuffer(r),f=n.write(e,t);return f!==r&&(n=n.slice(0,f)),n}function fromArrayLike(e){for(var t=e.length<0?0:0|checked(e.length),r=createBuffer(t),n=0;n<t;n+=1)r[n]=255&e[n];return r}function fromArrayBuffer(e,t,r){if(t<0||e.byteLength<t)throw new RangeError("'offset' is out of bounds");if(e.byteLength<t+(r||0))throw new RangeError("'length' is out of bounds");var n;return n=void 0===t&&void 0===r?new Uint8Array(e):void 0===r?new Uint8Array(e,t):new Uint8Array(e,t,r),n.__proto__=Buffer.prototype,n}function fromObject(e){if(Buffer.isBuffer(e)){var t=0|checked(e.length),r=createBuffer(t);return 0===r.length?r:(e.copy(r,0,0,t),r)}if(e){if(ArrayBuffer.isView(e)||"length"in e)return"number"!=typeof e.length||isnan(e.length)?createBuffer(0):fromArrayLike(e);if("Buffer"===e.type&&Array.isArray(e.data))return fromArrayLike(e.data)}throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}function checked(e){if(e>=K_MAX_LENGTH)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+K_MAX_LENGTH.toString(16)+" bytes");return 0|e}function SlowBuffer(e){return+e!=e&&(e=0),Buffer.alloc(+e)}function byteLength(e,t){if(Buffer.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||e instanceof ArrayBuffer)return e.byteLength;"string"!=typeof e&&(e=""+e);var r=e.length;if(0===r)return 0;for(var n=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return utf8ToBytes(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return base64ToBytes(e).length;default:if(n)return utf8ToBytes(e).length;t=(""+t).toLowerCase(),n=!0}}function slowToString(e,t,r){var n=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if(r>>>=0,t>>>=0,r<=t)return"";for(e||(e="utf8");;)switch(e){case"hex":return hexSlice(this,t,r);case"utf8":case"utf-8":return utf8Slice(this,t,r);case"ascii":return asciiSlice(this,t,r);case"latin1":case"binary":return latin1Slice(this,t,r);case"base64":return base64Slice(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return utf16leSlice(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function swap(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function bidirectionalIndexOf(e,t,r,n,f){if(0===e.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=f?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(f)return-1;r=e.length-1}else if(r<0){if(!f)return-1;r=0}if("string"==typeof t&&(t=Buffer.from(t,n)),Buffer.isBuffer(t))return 0===t.length?-1:arrayIndexOf(e,t,r,n,f);if("number"==typeof t)return t&=255,"function"==typeof Uint8Array.prototype.indexOf?f?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):arrayIndexOf(e,[t],r,n,f);throw new TypeError("val must be string, number or Buffer")}function arrayIndexOf(e,t,r,n,f){function i(e,t){return 1===o?e[t]:e.readUInt16BE(t*o)}var o=1,u=e.length,s=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return-1;o=2,u/=2,s/=2,r/=2}var a;if(f){var h=-1;for(a=r;a<u;a++)if(i(e,a)===i(t,-1===h?0:a-h)){if(-1===h&&(h=a),a-h+1===s)return h*o}else-1!==h&&(a-=a-h),h=-1}else for(r+s>u&&(r=u-s),a=r;a>=0;a--){for(var c=!0,l=0;l<s;l++)if(i(e,a+l)!==i(t,l)){c=!1;break}if(c)return a}return-1}function hexWrite(e,t,r,n){r=Number(r)||0;var f=e.length-r;n?(n=Number(n))>f&&(n=f):n=f;var i=t.length;if(i%2!=0)throw new TypeError("Invalid hex string");n>i/2&&(n=i/2);for(var o=0;o<n;++o){var u=parseInt(t.substr(2*o,2),16);if(isNaN(u))return o;e[r+o]=u}return o}function utf8Write(e,t,r,n){return blitBuffer(utf8ToBytes(t,e.length-r),e,r,n)}function asciiWrite(e,t,r,n){return blitBuffer(asciiToBytes(t),e,r,n)}function latin1Write(e,t,r,n){return asciiWrite(e,t,r,n)}function base64Write(e,t,r,n){return blitBuffer(base64ToBytes(t),e,r,n)}function ucs2Write(e,t,r,n){return blitBuffer(utf16leToBytes(t,e.length-r),e,r,n)}function base64Slice(e,t,r){return 0===t&&r===e.length?base64.fromByteArray(e):base64.fromByteArray(e.slice(t,r))}function utf8Slice(e,t,r){r=Math.min(e.length,r);for(var n=[],f=t;f<r;){var i=e[f],o=null,u=i>239?4:i>223?3:i>191?2:1;if(f+u<=r){var s,a,h,c;switch(u){case 1:i<128&&(o=i);break;case 2:s=e[f+1],128==(192&s)&&(c=(31&i)<<6|63&s)>127&&(o=c);break;case 3:s=e[f+1],a=e[f+2],128==(192&s)&&128==(192&a)&&(c=(15&i)<<12|(63&s)<<6|63&a)>2047&&(c<55296||c>57343)&&(o=c);break;case 4:s=e[f+1],a=e[f+2],h=e[f+3],128==(192&s)&&128==(192&a)&&128==(192&h)&&(c=(15&i)<<18|(63&s)<<12|(63&a)<<6|63&h)>65535&&c<1114112&&(o=c)}}null===o?(o=65533,u=1):o>65535&&(o-=65536,n.push(o>>>10&1023|55296),o=56320|1023&o),n.push(o),f+=u}return decodeCodePointsArray(n)}function decodeCodePointsArray(e){var t=e.length;if(t<=MAX_ARGUMENTS_LENGTH)return String.fromCharCode.apply(String,e);for(var r="",n=0;n<t;)r+=String.fromCharCode.apply(String,e.slice(n,n+=MAX_ARGUMENTS_LENGTH));return r}function asciiSlice(e,t,r){var n="";r=Math.min(e.length,r);for(var f=t;f<r;++f)n+=String.fromCharCode(127&e[f]);return n}function latin1Slice(e,t,r){var n="";r=Math.min(e.length,r);for(var f=t;f<r;++f)n+=String.fromCharCode(e[f]);return n}function hexSlice(e,t,r){var n=e.length;(!t||t<0)&&(t=0),(!r||r<0||r>n)&&(r=n);for(var f="",i=t;i<r;++i)f+=toHex(e[i]);return f}function utf16leSlice(e,t,r){for(var n=e.slice(t,r),f="",i=0;i<n.length;i+=2)f+=String.fromCharCode(n[i]+256*n[i+1]);return f}function checkOffset(e,t,r){if(e%1!=0||e<0)throw new RangeError("offset is not uint");if(e+t>r)throw new RangeError("Trying to access beyond buffer length")}function checkInt(e,t,r,n,f,i){if(!Buffer.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>f||t<i)throw new RangeError('"value" argument is out of bounds');if(r+n>e.length)throw new RangeError("Index out of range")}function checkIEEE754(e,t,r,n,f,i){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function writeFloat(e,t,r,n,f){return t=+t,r>>>=0,f||checkIEEE754(e,t,r,4,3.4028234663852886e38,-3.4028234663852886e38),ieee754.write(e,t,r,n,23,4),r+4}function writeDouble(e,t,r,n,f){return t=+t,r>>>=0,f||checkIEEE754(e,t,r,8,1.7976931348623157e308,-1.7976931348623157e308),ieee754.write(e,t,r,n,52,8),r+8}function base64clean(e){if(e=stringtrim(e).replace(INVALID_BASE64_RE,""),e.length<2)return"";for(;e.length%4!=0;)e+="=";return e}function stringtrim(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}function toHex(e){return e<16?"0"+e.toString(16):e.toString(16)}function utf8ToBytes(e,t){t=t||1/0;for(var r,n=e.length,f=null,i=[],o=0;o<n;++o){if((r=e.charCodeAt(o))>55295&&r<57344){if(!f){if(r>56319){(t-=3)>-1&&i.push(239,191,189);continue}if(o+1===n){(t-=3)>-1&&i.push(239,191,189);continue}f=r;continue}if(r<56320){(t-=3)>-1&&i.push(239,191,189),f=r;continue}r=65536+(f-55296<<10|r-56320)}else f&&(t-=3)>-1&&i.push(239,191,189);if(f=null,r<128){if((t-=1)<0)break;i.push(r)}else if(r<2048){if((t-=2)<0)break;i.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;i.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;i.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return i}function asciiToBytes(e){for(var t=[],r=0;r<e.length;++r)t.push(255&e.charCodeAt(r));return t}function utf16leToBytes(e,t){for(var r,n,f,i=[],o=0;o<e.length&&!((t-=2)<0);++o)r=e.charCodeAt(o),n=r>>8,f=r%256,i.push(f),i.push(n);return i}function base64ToBytes(e){return base64.toByteArray(base64clean(e))}function blitBuffer(e,t,r,n){for(var f=0;f<n&&!(f+r>=t.length||f>=e.length);++f)t[f+r]=e[f];return f}function isnan(e){return e!==e}var base64=require("base64-js"),ieee754=require("ieee754");exports.Buffer=Buffer,exports.SlowBuffer=SlowBuffer,exports.INSPECT_MAX_BYTES=50;var K_MAX_LENGTH=2147483647;exports.kMaxLength=K_MAX_LENGTH,Buffer.TYPED_ARRAY_SUPPORT=typedArraySupport(),Buffer.TYPED_ARRAY_SUPPORT||"undefined"==typeof console||"function"!=typeof console.error||console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."),"undefined"!=typeof Symbol&&Symbol.species&&Buffer[Symbol.species]===Buffer&&Object.defineProperty(Buffer,Symbol.species,{value:null,configurable:!0,enumerable:!1,writable:!1}),Buffer.poolSize=8192,Buffer.from=function(e,t,r){return from(e,t,r)},Buffer.prototype.__proto__=Uint8Array.prototype,Buffer.__proto__=Uint8Array,Buffer.alloc=function(e,t,r){return alloc(e,t,r)},Buffer.allocUnsafe=function(e){return allocUnsafe(e)},Buffer.allocUnsafeSlow=function(e){return allocUnsafe(e)},Buffer.isBuffer=function(e){return null!=e&&!0===e._isBuffer},Buffer.compare=function(e,t){if(!Buffer.isBuffer(e)||!Buffer.isBuffer(t))throw new TypeError("Arguments must be Buffers");if(e===t)return 0;for(var r=e.length,n=t.length,f=0,i=Math.min(r,n);f<i;++f)if(e[f]!==t[f]){r=e[f],n=t[f];break}return r<n?-1:n<r?1:0},Buffer.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},Buffer.concat=function(e,t){if(!Array.isArray(e))throw new TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return Buffer.alloc(0);var r;if(void 0===t)for(t=0,r=0;r<e.length;++r)t+=e[r].length;var n=Buffer.allocUnsafe(t),f=0;for(r=0;r<e.length;++r){var i=e[r];if(!Buffer.isBuffer(i))throw new TypeError('"list" argument must be an Array of Buffers');i.copy(n,f),f+=i.length}return n},Buffer.byteLength=byteLength,Buffer.prototype._isBuffer=!0,Buffer.prototype.swap16=function(){var e=this.length;if(e%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var t=0;t<e;t+=2)swap(this,t,t+1);return this},Buffer.prototype.swap32=function(){var e=this.length;if(e%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var t=0;t<e;t+=4)swap(this,t,t+3),swap(this,t+1,t+2);return this},Buffer.prototype.swap64=function(){var e=this.length;if(e%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var t=0;t<e;t+=8)swap(this,t,t+7),swap(this,t+1,t+6),swap(this,t+2,t+5),swap(this,t+3,t+4);return this},Buffer.prototype.toString=function(){var e=this.length;return 0===e?"":0===arguments.length?utf8Slice(this,0,e):slowToString.apply(this,arguments)},Buffer.prototype.equals=function(e){if(!Buffer.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e||0===Buffer.compare(this,e)},Buffer.prototype.inspect=function(){var e="",t=exports.INSPECT_MAX_BYTES;return this.length>0&&(e=this.toString("hex",0,t).match(/.{2}/g).join(" "),this.length>t&&(e+=" ... ")),"<Buffer "+e+">"},Buffer.prototype.compare=function(e,t,r,n,f){if(!Buffer.isBuffer(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===n&&(n=0),void 0===f&&(f=this.length),t<0||r>e.length||n<0||f>this.length)throw new RangeError("out of range index");if(n>=f&&t>=r)return 0;if(n>=f)return-1;if(t>=r)return 1;if(t>>>=0,r>>>=0,n>>>=0,f>>>=0,this===e)return 0;for(var i=f-n,o=r-t,u=Math.min(i,o),s=this.slice(n,f),a=e.slice(t,r),h=0;h<u;++h)if(s[h]!==a[h]){i=s[h],o=a[h];break}return i<o?-1:o<i?1:0},Buffer.prototype.includes=function(e,t,r){return-1!==this.indexOf(e,t,r)},Buffer.prototype.indexOf=function(e,t,r){return bidirectionalIndexOf(this,e,t,r,!0)},Buffer.prototype.lastIndexOf=function(e,t,r){return bidirectionalIndexOf(this,e,t,r,!1)},Buffer.prototype.write=function(e,t,r,n){if(void 0===t)n="utf8",r=this.length,t=0;else if(void 0===r&&"string"==typeof t)n=t,r=this.length,t=0;else{if(!isFinite(t))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");t>>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var f=this.length-t;if((void 0===r||r>f)&&(r=f),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var i=!1;;)switch(n){case"hex":return hexWrite(this,e,t,r);case"utf8":case"utf-8":return utf8Write(this,e,t,r);case"ascii":return asciiWrite(this,e,t,r);case"latin1":case"binary":return latin1Write(this,e,t,r);case"base64":return base64Write(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ucs2Write(this,e,t,r);default:if(i)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),i=!0}},Buffer.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var MAX_ARGUMENTS_LENGTH=4096;Buffer.prototype.slice=function(e,t){var r=this.length;e=~~e,t=void 0===t?r:~~t,e<0?(e+=r)<0&&(e=0):e>r&&(e=r),t<0?(t+=r)<0&&(t=0):t>r&&(t=r),t<e&&(t=e);var n=this.subarray(e,t);return n.__proto__=Buffer.prototype,n},Buffer.prototype.readUIntLE=function(e,t,r){e>>>=0,t>>>=0,r||checkOffset(e,t,this.length);for(var n=this[e],f=1,i=0;++i<t&&(f*=256);)n+=this[e+i]*f;return n},Buffer.prototype.readUIntBE=function(e,t,r){e>>>=0,t>>>=0,r||checkOffset(e,t,this.length);for(var n=this[e+--t],f=1;t>0&&(f*=256);)n+=this[e+--t]*f;return n},Buffer.prototype.readUInt8=function(e,t){return e>>>=0,t||checkOffset(e,1,this.length),this[e]},Buffer.prototype.readUInt16LE=function(e,t){return e>>>=0,t||checkOffset(e,2,this.length),this[e]|this[e+1]<<8},Buffer.prototype.readUInt16BE=function(e,t){return e>>>=0,t||checkOffset(e,2,this.length),this[e]<<8|this[e+1]},Buffer.prototype.readUInt32LE=function(e,t){return e>>>=0,t||checkOffset(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},Buffer.prototype.readUInt32BE=function(e,t){return e>>>=0,t||checkOffset(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},Buffer.prototype.readIntLE=function(e,t,r){e>>>=0,t>>>=0,r||checkOffset(e,t,this.length);for(var n=this[e],f=1,i=0;++i<t&&(f*=256);)n+=this[e+i]*f;return f*=128,n>=f&&(n-=Math.pow(2,8*t)),n},Buffer.prototype.readIntBE=function(e,t,r){e>>>=0,t>>>=0,r||checkOffset(e,t,this.length);for(var n=t,f=1,i=this[e+--n];n>0&&(f*=256);)i+=this[e+--n]*f;return f*=128,i>=f&&(i-=Math.pow(2,8*t)),i},Buffer.prototype.readInt8=function(e,t){return e>>>=0,t||checkOffset(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},Buffer.prototype.readInt16LE=function(e,t){e>>>=0,t||checkOffset(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},Buffer.prototype.readInt16BE=function(e,t){e>>>=0,t||checkOffset(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},Buffer.prototype.readInt32LE=function(e,t){return e>>>=0,t||checkOffset(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},Buffer.prototype.readInt32BE=function(e,t){return e>>>=0,t||checkOffset(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},Buffer.prototype.readFloatLE=function(e,t){return e>>>=0,t||checkOffset(e,4,this.length),ieee754.read(this,e,!0,23,4)},Buffer.prototype.readFloatBE=function(e,t){return e>>>=0,t||checkOffset(e,4,this.length),ieee754.read(this,e,!1,23,4)},Buffer.prototype.readDoubleLE=function(e,t){return e>>>=0,t||checkOffset(e,8,this.length),ieee754.read(this,e,!0,52,8)},Buffer.prototype.readDoubleBE=function(e,t){return e>>>=0,t||checkOffset(e,8,this.length),ieee754.read(this,e,!1,52,8)},Buffer.prototype.writeUIntLE=function(e,t,r,n){if(e=+e,t>>>=0,r>>>=0,!n){checkInt(this,e,t,r,Math.pow(2,8*r)-1,0)}var f=1,i=0;for(this[t]=255&e;++i<r&&(f*=256);)this[t+i]=e/f&255;return t+r},Buffer.prototype.writeUIntBE=function(e,t,r,n){if(e=+e,t>>>=0,r>>>=0,!n){checkInt(this,e,t,r,Math.pow(2,8*r)-1,0)}var f=r-1,i=1;for(this[t+f]=255&e;--f>=0&&(i*=256);)this[t+f]=e/i&255;return t+r},Buffer.prototype.writeUInt8=function(e,t,r){return e=+e,t>>>=0,r||checkInt(this,e,t,1,255,0),this[t]=255&e,t+1},Buffer.prototype.writeUInt16LE=function(e,t,r){return e=+e,t>>>=0,r||checkInt(this,e,t,2,65535,0),this[t]=255&e,this[t+1]=e>>>8,t+2},Buffer.prototype.writeUInt16BE=function(e,t,r){return e=+e,t>>>=0,r||checkInt(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=255&e,t+2},Buffer.prototype.writeUInt32LE=function(e,t,r){return e=+e,t>>>=0,r||checkInt(this,e,t,4,4294967295,0),this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e,t+4},Buffer.prototype.writeUInt32BE=function(e,t,r){return e=+e,t>>>=0,r||checkInt(this,e,t,4,4294967295,0),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},Buffer.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t>>>=0,!n){var f=Math.pow(2,8*r-1);checkInt(this,e,t,r,f-1,-f)}var i=0,o=1,u=0;for(this[t]=255&e;++i<r&&(o*=256);)e<0&&0===u&&0!==this[t+i-1]&&(u=1),this[t+i]=(e/o>>0)-u&255;return t+r},Buffer.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t>>>=0,!n){var f=Math.pow(2,8*r-1);checkInt(this,e,t,r,f-1,-f)}var i=r-1,o=1,u=0;for(this[t+i]=255&e;--i>=0&&(o*=256);)e<0&&0===u&&0!==this[t+i+1]&&(u=1),this[t+i]=(e/o>>0)-u&255;return t+r},Buffer.prototype.writeInt8=function(e,t,r){return e=+e,t>>>=0,r||checkInt(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=255&e,t+1},Buffer.prototype.writeInt16LE=function(e,t,r){return e=+e,t>>>=0,r||checkInt(this,e,t,2,32767,-32768),this[t]=255&e,this[t+1]=e>>>8,t+2},Buffer.prototype.writeInt16BE=function(e,t,r){return e=+e,t>>>=0,r||checkInt(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=255&e,t+2},Buffer.prototype.writeInt32LE=function(e,t,r){return e=+e,t>>>=0,r||checkInt(this,e,t,4,2147483647,-2147483648),this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24,t+4},Buffer.prototype.writeInt32BE=function(e,t,r){return e=+e,t>>>=0,r||checkInt(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},Buffer.prototype.writeFloatLE=function(e,t,r){return writeFloat(this,e,t,!0,r)},Buffer.prototype.writeFloatBE=function(e,t,r){return writeFloat(this,e,t,!1,r)},Buffer.prototype.writeDoubleLE=function(e,t,r){return writeDouble(this,e,t,!0,r)},Buffer.prototype.writeDoubleBE=function(e,t,r){return writeDouble(this,e,t,!1,r)},Buffer.prototype.copy=function(e,t,r,n){if(r||(r=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n<r&&(n=r),n===r)return 0;if(0===e.length||0===this.length)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t<n-r&&(n=e.length-t+r);var f,i=n-r;if(this===e&&r<t&&t<n)for(f=i-1;f>=0;--f)e[f+t]=this[f+r];else if(i<1e3)for(f=0;f<i;++f)e[f+t]=this[f+r];else Uint8Array.prototype.set.call(e,this.subarray(r,r+i),t);return i},Buffer.prototype.fill=function(e,t,r,n){if("string"==typeof e){if("string"==typeof t?(n=t,t=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),1===e.length){var f=e.charCodeAt(0);f<256&&(e=f)}if(void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!Buffer.isEncoding(n))throw new TypeError("Unknown encoding: "+n)}else"number"==typeof e&&(e&=255);if(t<0||this.length<t||this.length<r)throw new RangeError("Out of range index");if(r<=t)return this;t>>>=0,r=void 0===r?this.length:r>>>0,e||(e=0);var i;if("number"==typeof e)for(i=t;i<r;++i)this[i]=e;else{var o=Buffer.isBuffer(e)?e:new Buffer(e,n),u=o.length;for(i=0;i<r-t;++i)this[i+t]=o[i%u]}return this};var INVALID_BASE64_RE=/[^+\/0-9A-Za-z-_]/g;
},{"base64-js":53,"ieee754":61}],57:[function(require,module,exports){
module.exports={100:"Continue",101:"Switching Protocols",102:"Processing",200:"OK",201:"Created",202:"Accepted",203:"Non-Authoritative Information",204:"No Content",205:"Reset Content",206:"Partial Content",207:"Multi-Status",208:"Already Reported",226:"IM Used",300:"Multiple Choices",301:"Moved Permanently",302:"Found",303:"See Other",304:"Not Modified",305:"Use Proxy",307:"Temporary Redirect",308:"Permanent Redirect",400:"Bad Request",401:"Unauthorized",402:"Payment Required",403:"Forbidden",404:"Not Found",405:"Method Not Allowed",406:"Not Acceptable",407:"Proxy Authentication Required",408:"Request Timeout",409:"Conflict",410:"Gone",411:"Length Required",412:"Precondition Failed",413:"Payload Too Large",414:"URI Too Long",415:"Unsupported Media Type",416:"Range Not Satisfiable",417:"Expectation Failed",418:"I'm a teapot",421:"Misdirected Request",422:"Unprocessable Entity",423:"Locked",424:"Failed Dependency",425:"Unordered Collection",426:"Upgrade Required",428:"Precondition Required",429:"Too Many Requests",431:"Request Header Fields Too Large",451:"Unavailable For Legal Reasons",500:"Internal Server Error",501:"Not Implemented",502:"Bad Gateway",503:"Service Unavailable",504:"Gateway Timeout",505:"HTTP Version Not Supported",506:"Variant Also Negotiates",507:"Insufficient Storage",508:"Loop Detected",509:"Bandwidth Limit Exceeded",510:"Not Extended",511:"Network Authentication Required"};
},{}],58:[function(require,module,exports){
(function (Buffer){
function isArray(r){return Array.isArray?Array.isArray(r):"[object Array]"===objectToString(r)}function isBoolean(r){return"boolean"==typeof r}function isNull(r){return null===r}function isNullOrUndefined(r){return null==r}function isNumber(r){return"number"==typeof r}function isString(r){return"string"==typeof r}function isSymbol(r){return"symbol"==typeof r}function isUndefined(r){return void 0===r}function isRegExp(r){return"[object RegExp]"===objectToString(r)}function isObject(r){return"object"==typeof r&&null!==r}function isDate(r){return"[object Date]"===objectToString(r)}function isError(r){return"[object Error]"===objectToString(r)||r instanceof Error}function isFunction(r){return"function"==typeof r}function isPrimitive(r){return null===r||"boolean"==typeof r||"number"==typeof r||"string"==typeof r||"symbol"==typeof r||void 0===r}function objectToString(r){return Object.prototype.toString.call(r)}exports.isArray=isArray,exports.isBoolean=isBoolean,exports.isNull=isNull,exports.isNullOrUndefined=isNullOrUndefined,exports.isNumber=isNumber,exports.isString=isString,exports.isSymbol=isSymbol,exports.isUndefined=isUndefined,exports.isRegExp=isRegExp,exports.isObject=isObject,exports.isDate=isDate,exports.isError=isError,exports.isFunction=isFunction,exports.isPrimitive=isPrimitive,exports.isBuffer=Buffer.isBuffer;
}).call(this,{"isBuffer":require("../../is-buffer/index.js")})
},{"../../is-buffer/index.js":63}],59:[function(require,module,exports){
function EventEmitter(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}function isFunction(e){return"function"==typeof e}function isNumber(e){return"number"==typeof e}function isObject(e){return"object"==typeof e&&null!==e}function isUndefined(e){return void 0===e}module.exports=EventEmitter,EventEmitter.EventEmitter=EventEmitter,EventEmitter.prototype._events=void 0,EventEmitter.prototype._maxListeners=void 0,EventEmitter.defaultMaxListeners=10,EventEmitter.prototype.setMaxListeners=function(e){if(!isNumber(e)||e<0||isNaN(e))throw TypeError("n must be a positive number");return this._maxListeners=e,this},EventEmitter.prototype.emit=function(e){var t,i,n,s,r,o;if(this._events||(this._events={}),"error"===e&&(!this._events.error||isObject(this._events.error)&&!this._events.error.length)){if((t=arguments[1])instanceof Error)throw t;var h=new Error('Uncaught, unspecified "error" event. ('+t+")");throw h.context=t,h}if(i=this._events[e],isUndefined(i))return!1;if(isFunction(i))switch(arguments.length){case 1:i.call(this);break;case 2:i.call(this,arguments[1]);break;case 3:i.call(this,arguments[1],arguments[2]);break;default:s=Array.prototype.slice.call(arguments,1),i.apply(this,s)}else if(isObject(i))for(s=Array.prototype.slice.call(arguments,1),o=i.slice(),n=o.length,r=0;r<n;r++)o[r].apply(this,s);return!0},EventEmitter.prototype.addListener=function(e,t){var i;if(!isFunction(t))throw TypeError("listener must be a function");return this._events||(this._events={}),this._events.newListener&&this.emit("newListener",e,isFunction(t.listener)?t.listener:t),this._events[e]?isObject(this._events[e])?this._events[e].push(t):this._events[e]=[this._events[e],t]:this._events[e]=t,isObject(this._events[e])&&!this._events[e].warned&&(i=isUndefined(this._maxListeners)?EventEmitter.defaultMaxListeners:this._maxListeners)&&i>0&&this._events[e].length>i&&(this._events[e].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[e].length),"function"==typeof console.trace&&console.trace()),this},EventEmitter.prototype.on=EventEmitter.prototype.addListener,EventEmitter.prototype.once=function(e,t){function i(){this.removeListener(e,i),n||(n=!0,t.apply(this,arguments))}if(!isFunction(t))throw TypeError("listener must be a function");var n=!1;return i.listener=t,this.on(e,i),this},EventEmitter.prototype.removeListener=function(e,t){var i,n,s,r;if(!isFunction(t))throw TypeError("listener must be a function");if(!this._events||!this._events[e])return this;if(i=this._events[e],s=i.length,n=-1,i===t||isFunction(i.listener)&&i.listener===t)delete this._events[e],this._events.removeListener&&this.emit("removeListener",e,t);else if(isObject(i)){for(r=s;r-- >0;)if(i[r]===t||i[r].listener&&i[r].listener===t){n=r;break}if(n<0)return this;1===i.length?(i.length=0,delete this._events[e]):i.splice(n,1),this._events.removeListener&&this.emit("removeListener",e,t)}return this},EventEmitter.prototype.removeAllListeners=function(e){var t,i;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[e]&&delete this._events[e],this;if(0===arguments.length){for(t in this._events)"removeListener"!==t&&this.removeAllListeners(t);return this.removeAllListeners("removeListener"),this._events={},this}if(i=this._events[e],isFunction(i))this.removeListener(e,i);else if(i)for(;i.length;)this.removeListener(e,i[i.length-1]);return delete this._events[e],this},EventEmitter.prototype.listeners=function(e){return this._events&&this._events[e]?isFunction(this._events[e])?[this._events[e]]:this._events[e].slice():[]},EventEmitter.prototype.listenerCount=function(e){if(this._events){var t=this._events[e];if(isFunction(t))return 1;if(t)return t.length}return 0},EventEmitter.listenerCount=function(e,t){return e.listenerCount(t)};
},{}],60:[function(require,module,exports){
var http=require("http"),https=module.exports;for(var key in http)http.hasOwnProperty(key)&&(https[key]=http[key]);https.request=function(t,e){return t||(t={}),t.scheme="https",t.protocol="https:",http.request.call(this,t,e)};
},{"http":83}],61:[function(require,module,exports){
exports.read=function(a,o,t,r,h){var M,p,w=8*h-r-1,f=(1<<w)-1,e=f>>1,i=-7,N=t?h-1:0,n=t?-1:1,s=a[o+N];for(N+=n,M=s&(1<<-i)-1,s>>=-i,i+=w;i>0;M=256*M+a[o+N],N+=n,i-=8);for(p=M&(1<<-i)-1,M>>=-i,i+=r;i>0;p=256*p+a[o+N],N+=n,i-=8);if(0===M)M=1-e;else{if(M===f)return p?NaN:1/0*(s?-1:1);p+=Math.pow(2,r),M-=e}return(s?-1:1)*p*Math.pow(2,M-r)},exports.write=function(a,o,t,r,h,M){var p,w,f,e=8*M-h-1,i=(1<<e)-1,N=i>>1,n=23===h?Math.pow(2,-24)-Math.pow(2,-77):0,s=r?0:M-1,u=r?1:-1,l=o<0||0===o&&1/o<0?1:0;for(o=Math.abs(o),isNaN(o)||o===1/0?(w=isNaN(o)?1:0,p=i):(p=Math.floor(Math.log(o)/Math.LN2),o*(f=Math.pow(2,-p))<1&&(p--,f*=2),o+=p+N>=1?n/f:n*Math.pow(2,1-N),o*f>=2&&(p++,f/=2),p+N>=i?(w=0,p=i):p+N>=1?(w=(o*f-1)*Math.pow(2,h),p+=N):(w=o*Math.pow(2,N-1)*Math.pow(2,h),p=0));h>=8;a[t+s]=255&w,s+=u,w/=256,h-=8);for(p=p<<h|w,e+=h;e>0;a[t+s]=255&p,s+=u,p/=256,e-=8);a[t+s-u]|=128*l};
},{}],62:[function(require,module,exports){
arguments[4][19][0].apply(exports,arguments)
},{"dup":19}],63:[function(require,module,exports){
function isBuffer(f){return!!f.constructor&&"function"==typeof f.constructor.isBuffer&&f.constructor.isBuffer(f)}function isSlowBuffer(f){return"function"==typeof f.readFloatLE&&"function"==typeof f.slice&&isBuffer(f.slice(0,0))}module.exports=function(f){return null!=f&&(isBuffer(f)||isSlowBuffer(f)||!!f._isBuffer)};
},{}],64:[function(require,module,exports){
var toString={}.toString;module.exports=Array.isArray||function(r){return"[object Array]"==toString.call(r)};
},{}],65:[function(require,module,exports){
(function (process){
"use strict";function nextTick(e,n,c,r){if("function"!=typeof e)throw new TypeError('"callback" argument must be a function');var s,t,o=arguments.length;switch(o){case 0:case 1:return process.nextTick(e);case 2:return process.nextTick(function(){e.call(null,n)});case 3:return process.nextTick(function(){e.call(null,n,c)});case 4:return process.nextTick(function(){e.call(null,n,c,r)});default:for(s=new Array(o-1),t=0;t<s.length;)s[t++]=arguments[t];return process.nextTick(function(){e.apply(null,s)})}}!process.version||0===process.version.indexOf("v0.")||0===process.version.indexOf("v1.")&&0!==process.version.indexOf("v1.8.")?module.exports=nextTick:module.exports=process.nextTick;
}).call(this,require('_process'))
},{"_process":66}],66:[function(require,module,exports){
function defaultSetTimout(){throw new Error("setTimeout has not been defined")}function defaultClearTimeout(){throw new Error("clearTimeout has not been defined")}function runTimeout(e){if(cachedSetTimeout===setTimeout)return setTimeout(e,0);if((cachedSetTimeout===defaultSetTimout||!cachedSetTimeout)&&setTimeout)return cachedSetTimeout=setTimeout,setTimeout(e,0);try{return cachedSetTimeout(e,0)}catch(t){try{return cachedSetTimeout.call(null,e,0)}catch(t){return cachedSetTimeout.call(this,e,0)}}}function runClearTimeout(e){if(cachedClearTimeout===clearTimeout)return clearTimeout(e);if((cachedClearTimeout===defaultClearTimeout||!cachedClearTimeout)&&clearTimeout)return cachedClearTimeout=clearTimeout,clearTimeout(e);try{return cachedClearTimeout(e)}catch(t){try{return cachedClearTimeout.call(null,e)}catch(t){return cachedClearTimeout.call(this,e)}}}function cleanUpNextTick(){draining&&currentQueue&&(draining=!1,currentQueue.length?queue=currentQueue.concat(queue):queueIndex=-1,queue.length&&drainQueue())}function drainQueue(){if(!draining){var e=runTimeout(cleanUpNextTick);draining=!0;for(var t=queue.length;t;){for(currentQueue=queue,queue=[];++queueIndex<t;)currentQueue&&currentQueue[queueIndex].run();queueIndex=-1,t=queue.length}currentQueue=null,draining=!1,runClearTimeout(e)}}function Item(e,t){this.fun=e,this.array=t}function noop(){}var process=module.exports={},cachedSetTimeout,cachedClearTimeout;!function(){try{cachedSetTimeout="function"==typeof setTimeout?setTimeout:defaultSetTimout}catch(e){cachedSetTimeout=defaultSetTimout}try{cachedClearTimeout="function"==typeof clearTimeout?clearTimeout:defaultClearTimeout}catch(e){cachedClearTimeout=defaultClearTimeout}}();var queue=[],draining=!1,currentQueue,queueIndex=-1;process.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var u=1;u<arguments.length;u++)t[u-1]=arguments[u];queue.push(new Item(e,t)),1!==queue.length||draining||runTimeout(drainQueue)},Item.prototype.run=function(){this.fun.apply(null,this.array)},process.title="browser",process.browser=!0,process.env={},process.argv=[],process.version="",process.versions={},process.on=noop,process.addListener=noop,process.once=noop,process.off=noop,process.removeListener=noop,process.removeAllListeners=noop,process.emit=noop,process.binding=function(e){throw new Error("process.binding is not supported")},process.cwd=function(){return"/"},process.chdir=function(e){throw new Error("process.chdir is not supported")},process.umask=function(){return 0};
},{}],67:[function(require,module,exports){
(function (global){
!function(e){function o(e){throw new RangeError(T[e])}function n(e,o){for(var n=e.length,t=[];n--;)t[n]=o(e[n]);return t}function t(e,o){var t=e.split("@"),r="";return t.length>1&&(r=t[0]+"@",e=t[1]),e=e.replace(S,"."),r+n(e.split("."),o).join(".")}function r(e){for(var o,n,t=[],r=0,u=e.length;r<u;)o=e.charCodeAt(r++),o>=55296&&o<=56319&&r<u?(n=e.charCodeAt(r++),56320==(64512&n)?t.push(((1023&o)<<10)+(1023&n)+65536):(t.push(o),r--)):t.push(o);return t}function u(e){return n(e,function(e){var o="";return e>65535&&(e-=65536,o+=P(e>>>10&1023|55296),e=56320|1023&e),o+=P(e)}).join("")}function i(e){return e-48<10?e-22:e-65<26?e-65:e-97<26?e-97:b}function f(e,o){return e+22+75*(e<26)-((0!=o)<<5)}function c(e,o,n){var t=0;for(e=n?M(e/j):e>>1,e+=M(e/o);e>L*C>>1;t+=b)e=M(e/L);return M(t+(L+1)*e/(e+m))}function l(e){var n,t,r,f,l,s,d,p,a,h,v=[],g=e.length,w=0,m=I,j=A;for(t=e.lastIndexOf(E),t<0&&(t=0),r=0;r<t;++r)e.charCodeAt(r)>=128&&o("not-basic"),v.push(e.charCodeAt(r));for(f=t>0?t+1:0;f<g;){for(l=w,s=1,d=b;f>=g&&o("invalid-input"),p=i(e.charCodeAt(f++)),(p>=b||p>M((x-w)/s))&&o("overflow"),w+=p*s,a=d<=j?y:d>=j+C?C:d-j,!(p<a);d+=b)h=b-a,s>M(x/h)&&o("overflow"),s*=h;n=v.length+1,j=c(w-l,n,0==l),M(w/n)>x-m&&o("overflow"),m+=M(w/n),w%=n,v.splice(w++,0,m)}return u(v)}function s(e){var n,t,u,i,l,s,d,p,a,h,v,g,w,m,j,F=[];for(e=r(e),g=e.length,n=I,t=0,l=A,s=0;s<g;++s)(v=e[s])<128&&F.push(P(v));for(u=i=F.length,i&&F.push(E);u<g;){for(d=x,s=0;s<g;++s)(v=e[s])>=n&&v<d&&(d=v);for(w=u+1,d-n>M((x-t)/w)&&o("overflow"),t+=(d-n)*w,n=d,s=0;s<g;++s)if(v=e[s],v<n&&++t>x&&o("overflow"),v==n){for(p=t,a=b;h=a<=l?y:a>=l+C?C:a-l,!(p<h);a+=b)j=p-h,m=b-h,F.push(P(f(h+j%m,0))),p=M(j/m);F.push(P(f(p,0))),l=c(t,w,u==i),t=0,++u}++t,++n}return F.join("")}function d(e){return t(e,function(e){return F.test(e)?l(e.slice(4).toLowerCase()):e})}function p(e){return t(e,function(e){return O.test(e)?"xn--"+s(e):e})}var a="object"==typeof exports&&exports&&!exports.nodeType&&exports,h="object"==typeof module&&module&&!module.nodeType&&module,v="object"==typeof global&&global;v.global!==v&&v.window!==v&&v.self!==v||(e=v);var g,w,x=2147483647,b=36,y=1,C=26,m=38,j=700,A=72,I=128,E="-",F=/^xn--/,O=/[^\x20-\x7E]/,S=/[\x2E\u3002\uFF0E\uFF61]/g,T={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},L=b-y,M=Math.floor,P=String.fromCharCode;if(g={version:"1.4.1",ucs2:{decode:r,encode:u},decode:l,encode:s,toASCII:p,toUnicode:d},"function"==typeof define&&"object"==typeof define.amd&&define.amd)define("punycode",function(){return g});else if(a&&h)if(module.exports==a)h.exports=g;else for(w in g)g.hasOwnProperty(w)&&(a[w]=g[w]);else e.punycode=g}(this);
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
},{}],68:[function(require,module,exports){
"use strict";function hasOwnProperty(r,e){return Object.prototype.hasOwnProperty.call(r,e)}module.exports=function(r,e,t,n){e=e||"&",t=t||"=";var o={};if("string"!=typeof r||0===r.length)return o;var a=/\+/g;r=r.split(e);var s=1e3;n&&"number"==typeof n.maxKeys&&(s=n.maxKeys);var p=r.length;s>0&&p>s&&(p=s);for(var y=0;y<p;++y){var u,c,i,l,f=r[y].replace(a,"%20"),v=f.indexOf(t);v>=0?(u=f.substr(0,v),c=f.substr(v+1)):(u=f,c=""),i=decodeURIComponent(u),l=decodeURIComponent(c),hasOwnProperty(o,i)?isArray(o[i])?o[i].push(l):o[i]=[o[i],l]:o[i]=l}return o};var isArray=Array.isArray||function(r){return"[object Array]"===Object.prototype.toString.call(r)};
},{}],69:[function(require,module,exports){
"use strict";function map(r,e){if(r.map)return r.map(e);for(var t=[],n=0;n<r.length;n++)t.push(e(r[n],n));return t}var stringifyPrimitive=function(r){switch(typeof r){case"string":return r;case"boolean":return r?"true":"false";case"number":return isFinite(r)?r:"";default:return""}};module.exports=function(r,e,t,n){return e=e||"&",t=t||"=",null===r&&(r=void 0),"object"==typeof r?map(objectKeys(r),function(n){var i=encodeURIComponent(stringifyPrimitive(n))+t;return isArray(r[n])?map(r[n],function(r){return i+encodeURIComponent(stringifyPrimitive(r))}).join(e):i+encodeURIComponent(stringifyPrimitive(r[n]))}).join(e):n?encodeURIComponent(stringifyPrimitive(n))+t+encodeURIComponent(stringifyPrimitive(r)):""};var isArray=Array.isArray||function(r){return"[object Array]"===Object.prototype.toString.call(r)},objectKeys=Object.keys||function(r){var e=[];for(var t in r)Object.prototype.hasOwnProperty.call(r,t)&&e.push(t);return e};
},{}],70:[function(require,module,exports){
"use strict";exports.decode=exports.parse=require("./decode"),exports.encode=exports.stringify=require("./encode");
},{"./decode":68,"./encode":69}],71:[function(require,module,exports){
module.exports=require("./lib/_stream_duplex.js");
},{"./lib/_stream_duplex.js":72}],72:[function(require,module,exports){
"use strict";function Duplex(e){if(!(this instanceof Duplex))return new Duplex(e);Readable.call(this,e),Writable.call(this,e),e&&!1===e.readable&&(this.readable=!1),e&&!1===e.writable&&(this.writable=!1),this.allowHalfOpen=!0,e&&!1===e.allowHalfOpen&&(this.allowHalfOpen=!1),this.once("end",onend)}function onend(){this.allowHalfOpen||this._writableState.ended||processNextTick(onEndNT,this)}function onEndNT(e){e.end()}function forEach(e,t){for(var r=0,i=e.length;r<i;r++)t(e[r],r)}var objectKeys=Object.keys||function(e){var t=[];for(var r in e)t.push(r);return t};module.exports=Duplex;var processNextTick=require("process-nextick-args"),util=require("core-util-is");util.inherits=require("inherits");var Readable=require("./_stream_readable"),Writable=require("./_stream_writable");util.inherits(Duplex,Readable);for(var keys=objectKeys(Writable.prototype),v=0;v<keys.length;v++){var method=keys[v];Duplex.prototype[method]||(Duplex.prototype[method]=Writable.prototype[method])}
},{"./_stream_readable":74,"./_stream_writable":76,"core-util-is":58,"inherits":62,"process-nextick-args":65}],73:[function(require,module,exports){
"use strict";function PassThrough(r){if(!(this instanceof PassThrough))return new PassThrough(r);Transform.call(this,r)}module.exports=PassThrough;var Transform=require("./_stream_transform"),util=require("core-util-is");util.inherits=require("inherits"),util.inherits(PassThrough,Transform),PassThrough.prototype._transform=function(r,s,i){i(null,r)};
},{"./_stream_transform":75,"core-util-is":58,"inherits":62}],74:[function(require,module,exports){
(function (process){
"use strict";function prependListener(e,t,n){if("function"==typeof e.prependListener)return e.prependListener(t,n);e._events&&e._events[t]?isArray(e._events[t])?e._events[t].unshift(n):e._events[t]=[n,e._events[t]]:e.on(t,n)}function ReadableState(e,t){Duplex=Duplex||require("./_stream_duplex"),e=e||{},this.objectMode=!!e.objectMode,t instanceof Duplex&&(this.objectMode=this.objectMode||!!e.readableObjectMode);var n=e.highWaterMark,r=this.objectMode?16:16384;this.highWaterMark=n||0===n?n:r,this.highWaterMark=~~this.highWaterMark,this.buffer=new BufferList,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.defaultEncoding=e.defaultEncoding||"utf8",this.ranOut=!1,this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,e.encoding&&(StringDecoder||(StringDecoder=require("string_decoder/").StringDecoder),this.decoder=new StringDecoder(e.encoding),this.encoding=e.encoding)}function Readable(e){if(Duplex=Duplex||require("./_stream_duplex"),!(this instanceof Readable))return new Readable(e);this._readableState=new ReadableState(e,this),this.readable=!0,e&&"function"==typeof e.read&&(this._read=e.read),Stream.call(this)}function readableAddChunk(e,t,n,r,a){var i=chunkInvalid(t,n);if(i)e.emit("error",i);else if(null===n)t.reading=!1,onEofChunk(e,t);else if(t.objectMode||n&&n.length>0)if(t.ended&&!a){var d=new Error("stream.push() after EOF");e.emit("error",d)}else if(t.endEmitted&&a){var o=new Error("stream.unshift() after end event");e.emit("error",o)}else{var u;!t.decoder||a||r||(n=t.decoder.write(n),u=!t.objectMode&&0===n.length),a||(t.reading=!1),u||(t.flowing&&0===t.length&&!t.sync?(e.emit("data",n),e.read(0)):(t.length+=t.objectMode?1:n.length,a?t.buffer.unshift(n):t.buffer.push(n),t.needReadable&&emitReadable(e))),maybeReadMore(e,t)}else a||(t.reading=!1);return needMoreData(t)}function needMoreData(e){return!e.ended&&(e.needReadable||e.length<e.highWaterMark||0===e.length)}function computeNewHighWaterMark(e){return e>=MAX_HWM?e=MAX_HWM:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}function howMuchToRead(e,t){return e<=0||0===t.length&&t.ended?0:t.objectMode?1:e!==e?t.flowing&&t.length?t.buffer.head.data.length:t.length:(e>t.highWaterMark&&(t.highWaterMark=computeNewHighWaterMark(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}function chunkInvalid(e,t){var n=null;return Buffer.isBuffer(t)||"string"==typeof t||null===t||void 0===t||e.objectMode||(n=new TypeError("Invalid non-string/buffer chunk")),n}function onEofChunk(e,t){if(!t.ended){if(t.decoder){var n=t.decoder.end();n&&n.length&&(t.buffer.push(n),t.length+=t.objectMode?1:n.length)}t.ended=!0,emitReadable(e)}}function emitReadable(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(debug("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?processNextTick(emitReadable_,e):emitReadable_(e))}function emitReadable_(e){debug("emit readable"),e.emit("readable"),flow(e)}function maybeReadMore(e,t){t.readingMore||(t.readingMore=!0,processNextTick(maybeReadMore_,e,t))}function maybeReadMore_(e,t){for(var n=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length<t.highWaterMark&&(debug("maybeReadMore read 0"),e.read(0),n!==t.length);)n=t.length;t.readingMore=!1}function pipeOnDrain(e){return function(){var t=e._readableState;debug("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&EElistenerCount(e,"data")&&(t.flowing=!0,flow(e))}}function nReadingNextTick(e){debug("readable nexttick read 0"),e.read(0)}function resume(e,t){t.resumeScheduled||(t.resumeScheduled=!0,processNextTick(resume_,e,t))}function resume_(e,t){t.reading||(debug("resume read 0"),e.read(0)),t.resumeScheduled=!1,t.awaitDrain=0,e.emit("resume"),flow(e),t.flowing&&!t.reading&&e.read(0)}function flow(e){var t=e._readableState;for(debug("flow",t.flowing);t.flowing&&null!==e.read(););}function fromList(e,t){if(0===t.length)return null;var n;return t.objectMode?n=t.buffer.shift():!e||e>=t.length?(n=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.head.data:t.buffer.concat(t.length),t.buffer.clear()):n=fromListPartial(e,t.buffer,t.decoder),n}function fromListPartial(e,t,n){var r;return e<t.head.data.length?(r=t.head.data.slice(0,e),t.head.data=t.head.data.slice(e)):r=e===t.head.data.length?t.shift():n?copyFromBufferString(e,t):copyFromBuffer(e,t),r}function copyFromBufferString(e,t){var n=t.head,r=1,a=n.data;for(e-=a.length;n=n.next;){var i=n.data,d=e>i.length?i.length:e;if(d===i.length?a+=i:a+=i.slice(0,e),0===(e-=d)){d===i.length?(++r,n.next?t.head=n.next:t.head=t.tail=null):(t.head=n,n.data=i.slice(d));break}++r}return t.length-=r,a}function copyFromBuffer(e,t){var n=bufferShim.allocUnsafe(e),r=t.head,a=1;for(r.data.copy(n),e-=r.data.length;r=r.next;){var i=r.data,d=e>i.length?i.length:e;if(i.copy(n,n.length-e,0,d),0===(e-=d)){d===i.length?(++a,r.next?t.head=r.next:t.head=t.tail=null):(t.head=r,r.data=i.slice(d));break}++a}return t.length-=a,n}function endReadable(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,processNextTick(endReadableNT,t,e))}function endReadableNT(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function forEach(e,t){for(var n=0,r=e.length;n<r;n++)t(e[n],n)}function indexOf(e,t){for(var n=0,r=e.length;n<r;n++)if(e[n]===t)return n;return-1}module.exports=Readable;var processNextTick=require("process-nextick-args"),isArray=require("isarray"),Duplex;Readable.ReadableState=ReadableState;var EE=require("events").EventEmitter,EElistenerCount=function(e,t){return e.listeners(t).length},Stream;!function(){try{Stream=require("stream")}catch(e){}finally{Stream||(Stream=require("events").EventEmitter)}}();var Buffer=require("buffer").Buffer,bufferShim=require("buffer-shims"),util=require("core-util-is");util.inherits=require("inherits");var debugUtil=require("util"),debug=void 0;debug=debugUtil&&debugUtil.debuglog?debugUtil.debuglog("stream"):function(){};var BufferList=require("./internal/streams/BufferList"),StringDecoder;util.inherits(Readable,Stream),Readable.prototype.push=function(e,t){var n=this._readableState;return n.objectMode||"string"!=typeof e||(t=t||n.defaultEncoding)!==n.encoding&&(e=bufferShim.from(e,t),t=""),readableAddChunk(this,n,e,t,!1)},Readable.prototype.unshift=function(e){return readableAddChunk(this,this._readableState,e,"",!0)},Readable.prototype.isPaused=function(){return!1===this._readableState.flowing},Readable.prototype.setEncoding=function(e){return StringDecoder||(StringDecoder=require("string_decoder/").StringDecoder),this._readableState.decoder=new StringDecoder(e),this._readableState.encoding=e,this};var MAX_HWM=8388608;Readable.prototype.read=function(e){debug("read",e),e=parseInt(e,10);var t=this._readableState,n=e;if(0!==e&&(t.emittedReadable=!1),0===e&&t.needReadable&&(t.length>=t.highWaterMark||t.ended))return debug("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?endReadable(this):emitReadable(this),null;if(0===(e=howMuchToRead(e,t))&&t.ended)return 0===t.length&&endReadable(this),null;var r=t.needReadable;debug("need readable",r),(0===t.length||t.length-e<t.highWaterMark)&&(r=!0,debug("length less than watermark",r)),t.ended||t.reading?(r=!1,debug("reading or ended",r)):r&&(debug("do read"),t.reading=!0,t.sync=!0,0===t.length&&(t.needReadable=!0),this._read(t.highWaterMark),t.sync=!1,t.reading||(e=howMuchToRead(n,t)));var a;return a=e>0?fromList(e,t):null,null===a?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),n!==e&&t.ended&&endReadable(this)),null!==a&&this.emit("data",a),a},Readable.prototype._read=function(e){this.emit("error",new Error("_read() is not implemented"))},Readable.prototype.pipe=function(e,t){function n(e){debug("onunpipe"),e===s&&a()}function r(){debug("onend"),e.end()}function a(){debug("cleanup"),e.removeListener("close",o),e.removeListener("finish",u),e.removeListener("drain",c),e.removeListener("error",d),e.removeListener("unpipe",n),s.removeListener("end",r),s.removeListener("end",a),s.removeListener("data",i),g=!0,!h.awaitDrain||e._writableState&&!e._writableState.needDrain||c()}function i(t){debug("ondata"),b=!1,!1!==e.write(t)||b||((1===h.pipesCount&&h.pipes===e||h.pipesCount>1&&-1!==indexOf(h.pipes,e))&&!g&&(debug("false write response, pause",s._readableState.awaitDrain),s._readableState.awaitDrain++,b=!0),s.pause())}function d(t){debug("onerror",t),l(),e.removeListener("error",d),0===EElistenerCount(e,"error")&&e.emit("error",t)}function o(){e.removeListener("finish",u),l()}function u(){debug("onfinish"),e.removeListener("close",o),l()}function l(){debug("unpipe"),s.unpipe(e)}var s=this,h=this._readableState;switch(h.pipesCount){case 0:h.pipes=e;break;case 1:h.pipes=[h.pipes,e];break;default:h.pipes.push(e)}h.pipesCount+=1,debug("pipe count=%d opts=%j",h.pipesCount,t);var f=(!t||!1!==t.end)&&e!==process.stdout&&e!==process.stderr,p=f?r:a;h.endEmitted?processNextTick(p):s.once("end",p),e.on("unpipe",n);var c=pipeOnDrain(s);e.on("drain",c);var g=!1,b=!1;return s.on("data",i),prependListener(e,"error",d),e.once("close",o),e.once("finish",u),e.emit("pipe",s),h.flowing||(debug("pipe resume"),s.resume()),e},Readable.prototype.unpipe=function(e){var t=this._readableState;if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes?this:(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this),this);if(!e){var n=t.pipes,r=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var a=0;a<r;a++)n[a].emit("unpipe",this);return this}var i=indexOf(t.pipes,e);return-1===i?this:(t.pipes.splice(i,1),t.pipesCount-=1,1===t.pipesCount&&(t.pipes=t.pipes[0]),e.emit("unpipe",this),this)},Readable.prototype.on=function(e,t){var n=Stream.prototype.on.call(this,e,t);if("data"===e)!1!==this._readableState.flowing&&this.resume();else if("readable"===e){var r=this._readableState;r.endEmitted||r.readableListening||(r.readableListening=r.needReadable=!0,r.emittedReadable=!1,r.reading?r.length&&emitReadable(this,r):processNextTick(nReadingNextTick,this))}return n},Readable.prototype.addListener=Readable.prototype.on,Readable.prototype.resume=function(){var e=this._readableState;return e.flowing||(debug("resume"),e.flowing=!0,resume(this,e)),this},Readable.prototype.pause=function(){return debug("call pause flowing=%j",this._readableState.flowing),!1!==this._readableState.flowing&&(debug("pause"),this._readableState.flowing=!1,this.emit("pause")),this},Readable.prototype.wrap=function(e){var t=this._readableState,n=!1,r=this;e.on("end",function(){if(debug("wrapped end"),t.decoder&&!t.ended){var e=t.decoder.end();e&&e.length&&r.push(e)}r.push(null)}),e.on("data",function(a){if(debug("wrapped data"),t.decoder&&(a=t.decoder.write(a)),(!t.objectMode||null!==a&&void 0!==a)&&(t.objectMode||a&&a.length)){r.push(a)||(n=!0,e.pause())}});for(var a in e)void 0===this[a]&&"function"==typeof e[a]&&(this[a]=function(t){return function(){return e[t].apply(e,arguments)}}(a));return forEach(["error","close","destroy","pause","resume"],function(t){e.on(t,r.emit.bind(r,t))}),r._read=function(t){debug("wrapped _read",t),n&&(n=!1,e.resume())},r},Readable._fromList=fromList;
}).call(this,require('_process'))
},{"./_stream_duplex":72,"./internal/streams/BufferList":77,"_process":66,"buffer":56,"buffer-shims":55,"core-util-is":58,"events":59,"inherits":62,"isarray":64,"process-nextick-args":65,"stream":82,"string_decoder/":87,"util":54}],75:[function(require,module,exports){
"use strict";function TransformState(r){this.afterTransform=function(t,n){return afterTransform(r,t,n)},this.needTransform=!1,this.transforming=!1,this.writecb=null,this.writechunk=null,this.writeencoding=null}function afterTransform(r,t,n){var e=r._transformState;e.transforming=!1;var i=e.writecb;if(!i)return r.emit("error",new Error("no writecb in Transform class"));e.writechunk=null,e.writecb=null,null!==n&&void 0!==n&&r.push(n),i(t);var a=r._readableState;a.reading=!1,(a.needReadable||a.length<a.highWaterMark)&&r._read(a.highWaterMark)}function Transform(r){if(!(this instanceof Transform))return new Transform(r);Duplex.call(this,r),this._transformState=new TransformState(this);var t=this;this._readableState.needReadable=!0,this._readableState.sync=!1,r&&("function"==typeof r.transform&&(this._transform=r.transform),"function"==typeof r.flush&&(this._flush=r.flush)),this.once("prefinish",function(){"function"==typeof this._flush?this._flush(function(r,n){done(t,r,n)}):done(t)})}function done(r,t,n){if(t)return r.emit("error",t);null!==n&&void 0!==n&&r.push(n);var e=r._writableState,i=r._transformState;if(e.length)throw new Error("Calling transform done when ws.length != 0");if(i.transforming)throw new Error("Calling transform done when still transforming");return r.push(null)}module.exports=Transform;var Duplex=require("./_stream_duplex"),util=require("core-util-is");util.inherits=require("inherits"),util.inherits(Transform,Duplex),Transform.prototype.push=function(r,t){return this._transformState.needTransform=!1,Duplex.prototype.push.call(this,r,t)},Transform.prototype._transform=function(r,t,n){throw new Error("_transform() is not implemented")},Transform.prototype._write=function(r,t,n){var e=this._transformState;if(e.writecb=n,e.writechunk=r,e.writeencoding=t,!e.transforming){var i=this._readableState;(e.needTransform||i.needReadable||i.length<i.highWaterMark)&&this._read(i.highWaterMark)}},Transform.prototype._read=function(r){var t=this._transformState;null!==t.writechunk&&t.writecb&&!t.transforming?(t.transforming=!0,this._transform(t.writechunk,t.writeencoding,t.afterTransform)):t.needTransform=!0};
},{"./_stream_duplex":72,"core-util-is":58,"inherits":62}],76:[function(require,module,exports){
(function (process){
"use strict";function nop(){}function WriteReq(e,t,r){this.chunk=e,this.encoding=t,this.callback=r,this.next=null}function WritableState(e,t){Duplex=Duplex||require("./_stream_duplex"),e=e||{},this.objectMode=!!e.objectMode,t instanceof Duplex&&(this.objectMode=this.objectMode||!!e.writableObjectMode);var r=e.highWaterMark,i=this.objectMode?16:16384;this.highWaterMark=r||0===r?r:i,this.highWaterMark=~~this.highWaterMark,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1;var n=!1===e.decodeStrings;this.decodeStrings=!n,this.defaultEncoding=e.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(e){onwrite(t,e)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.bufferedRequestCount=0,this.corkedRequestsFree=new CorkedRequest(this)}function Writable(e){if(Duplex=Duplex||require("./_stream_duplex"),!(realHasInstance.call(Writable,this)||this instanceof Duplex))return new Writable(e);this._writableState=new WritableState(e,this),this.writable=!0,e&&("function"==typeof e.write&&(this._write=e.write),"function"==typeof e.writev&&(this._writev=e.writev)),Stream.call(this)}function writeAfterEnd(e,t){var r=new Error("write after end");e.emit("error",r),processNextTick(t,r)}function validChunk(e,t,r,i){var n=!0,s=!1;return null===r?s=new TypeError("May not write null values to stream"):Buffer.isBuffer(r)||"string"==typeof r||void 0===r||t.objectMode||(s=new TypeError("Invalid non-string/buffer chunk")),s&&(e.emit("error",s),processNextTick(i,s),n=!1),n}function decodeChunk(e,t,r){return e.objectMode||!1===e.decodeStrings||"string"!=typeof t||(t=bufferShim.from(t,r)),t}function writeOrBuffer(e,t,r,i,n){r=decodeChunk(t,r,i),Buffer.isBuffer(r)&&(i="buffer");var s=t.objectMode?1:r.length;t.length+=s;var o=t.length<t.highWaterMark;if(o||(t.needDrain=!0),t.writing||t.corked){var u=t.lastBufferedRequest;t.lastBufferedRequest=new WriteReq(r,i,n),u?u.next=t.lastBufferedRequest:t.bufferedRequest=t.lastBufferedRequest,t.bufferedRequestCount+=1}else doWrite(e,t,!1,s,r,i,n);return o}function doWrite(e,t,r,i,n,s,o){t.writelen=i,t.writecb=o,t.writing=!0,t.sync=!0,r?e._writev(n,t.onwrite):e._write(n,s,t.onwrite),t.sync=!1}function onwriteError(e,t,r,i,n){--t.pendingcb,r?processNextTick(n,i):n(i),e._writableState.errorEmitted=!0,e.emit("error",i)}function onwriteStateUpdate(e){e.writing=!1,e.writecb=null,e.length-=e.writelen,e.writelen=0}function onwrite(e,t){var r=e._writableState,i=r.sync,n=r.writecb;if(onwriteStateUpdate(r),t)onwriteError(e,r,i,t,n);else{var s=needFinish(r);s||r.corked||r.bufferProcessing||!r.bufferedRequest||clearBuffer(e,r),i?asyncWrite(afterWrite,e,r,s,n):afterWrite(e,r,s,n)}}function afterWrite(e,t,r,i){r||onwriteDrain(e,t),t.pendingcb--,i(),finishMaybe(e,t)}function onwriteDrain(e,t){0===t.length&&t.needDrain&&(t.needDrain=!1,e.emit("drain"))}function clearBuffer(e,t){t.bufferProcessing=!0;var r=t.bufferedRequest;if(e._writev&&r&&r.next){var i=t.bufferedRequestCount,n=new Array(i),s=t.corkedRequestsFree;s.entry=r;for(var o=0;r;)n[o]=r,r=r.next,o+=1;doWrite(e,t,!0,t.length,n,"",s.finish),t.pendingcb++,t.lastBufferedRequest=null,s.next?(t.corkedRequestsFree=s.next,s.next=null):t.corkedRequestsFree=new CorkedRequest(t)}else{for(;r;){var u=r.chunk,f=r.encoding,a=r.callback;if(doWrite(e,t,!1,t.objectMode?1:u.length,u,f,a),r=r.next,t.writing)break}null===r&&(t.lastBufferedRequest=null)}t.bufferedRequestCount=0,t.bufferedRequest=r,t.bufferProcessing=!1}function needFinish(e){return e.ending&&0===e.length&&null===e.bufferedRequest&&!e.finished&&!e.writing}function prefinish(e,t){t.prefinished||(t.prefinished=!0,e.emit("prefinish"))}function finishMaybe(e,t){var r=needFinish(t);return r&&(0===t.pendingcb?(prefinish(e,t),t.finished=!0,e.emit("finish")):prefinish(e,t)),r}function endWritable(e,t,r){t.ending=!0,finishMaybe(e,t),r&&(t.finished?processNextTick(r):e.once("finish",r)),t.ended=!0,e.writable=!1}function CorkedRequest(e){var t=this;this.next=null,this.entry=null,this.finish=function(r){var i=t.entry;for(t.entry=null;i;){var n=i.callback;e.pendingcb--,n(r),i=i.next}e.corkedRequestsFree?e.corkedRequestsFree.next=t:e.corkedRequestsFree=t}}module.exports=Writable;var processNextTick=require("process-nextick-args"),asyncWrite=!process.browser&&["v0.10","v0.9."].indexOf(process.version.slice(0,5))>-1?setImmediate:processNextTick,Duplex;Writable.WritableState=WritableState;var util=require("core-util-is");util.inherits=require("inherits");var internalUtil={deprecate:require("util-deprecate")},Stream;!function(){try{Stream=require("stream")}catch(e){}finally{Stream||(Stream=require("events").EventEmitter)}}();var Buffer=require("buffer").Buffer,bufferShim=require("buffer-shims");util.inherits(Writable,Stream),WritableState.prototype.getBuffer=function(){for(var e=this.bufferedRequest,t=[];e;)t.push(e),e=e.next;return t},function(){try{Object.defineProperty(WritableState.prototype,"buffer",{get:internalUtil.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.")})}catch(e){}}();var realHasInstance;"function"==typeof Symbol&&Symbol.hasInstance&&"function"==typeof Function.prototype[Symbol.hasInstance]?(realHasInstance=Function.prototype[Symbol.hasInstance],Object.defineProperty(Writable,Symbol.hasInstance,{value:function(e){return!!realHasInstance.call(this,e)||e&&e._writableState instanceof WritableState}})):realHasInstance=function(e){return e instanceof this},Writable.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe, not readable"))},Writable.prototype.write=function(e,t,r){var i=this._writableState,n=!1;return"function"==typeof t&&(r=t,t=null),Buffer.isBuffer(e)?t="buffer":t||(t=i.defaultEncoding),"function"!=typeof r&&(r=nop),i.ended?writeAfterEnd(this,r):validChunk(this,i,e,r)&&(i.pendingcb++,n=writeOrBuffer(this,i,e,t,r)),n},Writable.prototype.cork=function(){this._writableState.corked++},Writable.prototype.uncork=function(){var e=this._writableState;e.corked&&(e.corked--,e.writing||e.corked||e.finished||e.bufferProcessing||!e.bufferedRequest||clearBuffer(this,e))},Writable.prototype.setDefaultEncoding=function(e){if("string"==typeof e&&(e=e.toLowerCase()),!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((e+"").toLowerCase())>-1))throw new TypeError("Unknown encoding: "+e);return this._writableState.defaultEncoding=e,this},Writable.prototype._write=function(e,t,r){r(new Error("_write() is not implemented"))},Writable.prototype._writev=null,Writable.prototype.end=function(e,t,r){var i=this._writableState;"function"==typeof e?(r=e,e=null,t=null):"function"==typeof t&&(r=t,t=null),null!==e&&void 0!==e&&this.write(e,t),i.corked&&(i.corked=1,this.uncork()),i.ending||i.finished||endWritable(this,i,r)};
}).call(this,require('_process'))
},{"./_stream_duplex":72,"_process":66,"buffer":56,"buffer-shims":55,"core-util-is":58,"events":59,"inherits":62,"process-nextick-args":65,"stream":82,"util-deprecate":91}],77:[function(require,module,exports){
"use strict";function BufferList(){this.head=null,this.tail=null,this.length=0}var Buffer=require("buffer").Buffer,bufferShim=require("buffer-shims");module.exports=BufferList,BufferList.prototype.push=function(t){var e={data:t,next:null};this.length>0?this.tail.next=e:this.head=e,this.tail=e,++this.length},BufferList.prototype.unshift=function(t){var e={data:t,next:this.head};0===this.length&&(this.tail=e),this.head=e,++this.length},BufferList.prototype.shift=function(){if(0!==this.length){var t=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,t}},BufferList.prototype.clear=function(){this.head=this.tail=null,this.length=0},BufferList.prototype.join=function(t){if(0===this.length)return"";for(var e=this.head,i=""+e.data;e=e.next;)i+=t+e.data;return i},BufferList.prototype.concat=function(t){if(0===this.length)return bufferShim.alloc(0);if(1===this.length)return this.head.data;for(var e=bufferShim.allocUnsafe(t>>>0),i=this.head,h=0;i;)i.data.copy(e,h),h+=i.data.length,i=i.next;return e};
},{"buffer":56,"buffer-shims":55}],78:[function(require,module,exports){
module.exports=require("./lib/_stream_passthrough.js");
},{"./lib/_stream_passthrough.js":73}],79:[function(require,module,exports){
(function (process){
var Stream=function(){try{return require("stream")}catch(r){}}();exports=module.exports=require("./lib/_stream_readable.js"),exports.Stream=Stream||exports,exports.Readable=exports,exports.Writable=require("./lib/_stream_writable.js"),exports.Duplex=require("./lib/_stream_duplex.js"),exports.Transform=require("./lib/_stream_transform.js"),exports.PassThrough=require("./lib/_stream_passthrough.js"),!process.browser&&"disable"===process.env.READABLE_STREAM&&Stream&&(module.exports=Stream);
}).call(this,require('_process'))
},{"./lib/_stream_duplex.js":72,"./lib/_stream_passthrough.js":73,"./lib/_stream_readable.js":74,"./lib/_stream_transform.js":75,"./lib/_stream_writable.js":76,"_process":66,"stream":82}],80:[function(require,module,exports){
module.exports=require("./lib/_stream_transform.js");
},{"./lib/_stream_transform.js":75}],81:[function(require,module,exports){
module.exports=require("./lib/_stream_writable.js");
},{"./lib/_stream_writable.js":76}],82:[function(require,module,exports){
function Stream(){EE.call(this)}module.exports=Stream;var EE=require("events").EventEmitter,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"),Stream.Stream=Stream,Stream.prototype.pipe=function(e,r){function t(r){e.writable&&!1===e.write(r)&&m.pause&&m.pause()}function n(){m.readable&&m.resume&&m.resume()}function a(){u||(u=!0,e.end())}function o(){u||(u=!0,"function"==typeof e.destroy&&e.destroy())}function i(e){if(s(),0===EE.listenerCount(this,"error"))throw e}function s(){m.removeListener("data",t),e.removeListener("drain",n),m.removeListener("end",a),m.removeListener("close",o),m.removeListener("error",i),e.removeListener("error",i),m.removeListener("end",s),m.removeListener("close",s),e.removeListener("close",s)}var m=this;m.on("data",t),e.on("drain",n),e._isStdio||r&&!1===r.end||(m.on("end",a),m.on("close",o));var u=!1;return m.on("error",i),e.on("error",i),m.on("end",s),m.on("close",s),e.on("close",s),e.emit("pipe",m),e};
},{"events":59,"inherits":62,"readable-stream/duplex.js":71,"readable-stream/passthrough.js":78,"readable-stream/readable.js":79,"readable-stream/transform.js":80,"readable-stream/writable.js":81}],83:[function(require,module,exports){
(function (global){
var ClientRequest=require("./lib/request"),extend=require("xtend"),statusCodes=require("builtin-status-codes"),url=require("url"),http=exports;http.request=function(t,e){t="string"==typeof t?url.parse(t):extend(t);var r=-1===global.location.protocol.search(/^https?:$/)?"http:":"",s=t.protocol||r,o=t.hostname||t.host,n=t.port,u=t.path||"/";o&&-1!==o.indexOf(":")&&(o="["+o+"]"),t.url=(o?s+"//"+o:"")+(n?":"+n:"")+u,t.method=(t.method||"GET").toUpperCase(),t.headers=t.headers||{};var C=new ClientRequest(t);return e&&C.on("response",e),C},http.get=function(t,e){var r=http.request(t,e);return r.end(),r},http.Agent=function(){},http.Agent.defaultMaxSockets=4,http.STATUS_CODES=statusCodes,http.METHODS=["CHECKOUT","CONNECT","COPY","DELETE","GET","HEAD","LOCK","M-SEARCH","MERGE","MKACTIVITY","MKCOL","MOVE","NOTIFY","OPTIONS","PATCH","POST","PROPFIND","PROPPATCH","PURGE","PUT","REPORT","SEARCH","SUBSCRIBE","TRACE","UNLOCK","UNSUBSCRIBE"];
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
},{"./lib/request":85,"builtin-status-codes":57,"url":89,"xtend":95}],84:[function(require,module,exports){
(function (global){
function getXHR(){if(void 0!==xhr)return xhr;if(global.XMLHttpRequest){xhr=new global.XMLHttpRequest;try{xhr.open("GET",global.XDomainRequest?"/":"https://example.com")}catch(e){xhr=null}}else xhr=null;return xhr}function checkTypeSupport(e){var r=getXHR();if(!r)return!1;try{return r.responseType=e,r.responseType===e}catch(e){}return!1}function isFunction(e){return"function"==typeof e}exports.fetch=isFunction(global.fetch)&&isFunction(global.ReadableStream),exports.blobConstructor=!1;try{new Blob([new ArrayBuffer(1)]),exports.blobConstructor=!0}catch(e){}var xhr,haveArrayBuffer=void 0!==global.ArrayBuffer,haveSlice=haveArrayBuffer&&isFunction(global.ArrayBuffer.prototype.slice);exports.arraybuffer=exports.fetch||haveArrayBuffer&&checkTypeSupport("arraybuffer"),exports.msstream=!exports.fetch&&haveSlice&&checkTypeSupport("ms-stream"),exports.mozchunkedarraybuffer=!exports.fetch&&haveArrayBuffer&&checkTypeSupport("moz-chunked-arraybuffer"),exports.overrideMimeType=exports.fetch||!!getXHR()&&isFunction(getXHR().overrideMimeType),exports.vbArray=isFunction(global.VBArray),xhr=null;
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
},{}],85:[function(require,module,exports){
(function (process,global,Buffer){
function decideMode(e,t){return capability.fetch&&t?"fetch":capability.mozchunkedarraybuffer?"moz-chunked-arraybuffer":capability.msstream?"ms-stream":capability.arraybuffer&&e?"arraybuffer":capability.vbArray&&e?"text:vbarray":"text"}function statusValid(e){try{var t=e.status;return null!==t&&0!==t}catch(e){return!1}}var capability=require("./capability"),inherits=require("inherits"),response=require("./response"),stream=require("readable-stream"),toArrayBuffer=require("to-arraybuffer"),IncomingMessage=response.IncomingMessage,rStates=response.readyStates,ClientRequest=module.exports=function(e){var t=this;stream.Writable.call(t),t._opts=e,t._body=[],t._headers={},e.auth&&t.setHeader("Authorization","Basic "+new Buffer(e.auth).toString("base64")),Object.keys(e.headers).forEach(function(r){t.setHeader(r,e.headers[r])});var r,o=!0;if("disable-fetch"===e.mode||"timeout"in e)o=!1,r=!0;else if("prefer-streaming"===e.mode)r=!1;else if("allow-wrong-content-type"===e.mode)r=!capability.overrideMimeType;else{if(e.mode&&"default"!==e.mode&&"prefer-fast"!==e.mode)throw new Error("Invalid value for opts.mode");r=!0}t._mode=decideMode(r,o),t.on("finish",function(){t._onFinish()})};inherits(ClientRequest,stream.Writable),ClientRequest.prototype.setHeader=function(e,t){var r=this,o=e.toLowerCase();-1===unsafeHeaders.indexOf(o)&&(r._headers[o]={name:e,value:t})},ClientRequest.prototype.getHeader=function(e){return this._headers[e.toLowerCase()].value},ClientRequest.prototype.removeHeader=function(e){delete this._headers[e.toLowerCase()]},ClientRequest.prototype._onFinish=function(){var e=this;if(!e._destroyed){var t=e._opts,r=e._headers,o=null;if("POST"!==t.method&&"PUT"!==t.method&&"PATCH"!==t.method&&"MERGE"!==t.method||(o=capability.blobConstructor?new global.Blob(e._body.map(function(e){return toArrayBuffer(e)}),{type:(r["content-type"]||{}).value||""}):Buffer.concat(e._body).toString()),"fetch"===e._mode){var n=Object.keys(r).map(function(e){return[r[e].name,r[e].value]});global.fetch(e._opts.url,{method:e._opts.method,headers:n,body:o||void 0,mode:"cors",credentials:t.withCredentials?"include":"same-origin"}).then(function(t){e._fetchResponse=t,e._connect()},function(t){e.emit("error",t)})}else{var s=e._xhr=new global.XMLHttpRequest;try{s.open(e._opts.method,e._opts.url,!0)}catch(t){return void process.nextTick(function(){e.emit("error",t)})}"responseType"in s&&(s.responseType=e._mode.split(":")[0]),"withCredentials"in s&&(s.withCredentials=!!t.withCredentials),"text"===e._mode&&"overrideMimeType"in s&&s.overrideMimeType("text/plain; charset=x-user-defined"),"timeout"in t&&(s.timeout=t.timeout,s.ontimeout=function(){e.emit("timeout")}),Object.keys(r).forEach(function(e){s.setRequestHeader(r[e].name,r[e].value)}),e._response=null,s.onreadystatechange=function(){switch(s.readyState){case rStates.LOADING:case rStates.DONE:e._onXHRProgress()}},"moz-chunked-arraybuffer"===e._mode&&(s.onprogress=function(){e._onXHRProgress()}),s.onerror=function(){e._destroyed||e.emit("error",new Error("XHR error"))};try{s.send(o)}catch(t){return void process.nextTick(function(){e.emit("error",t)})}}}},ClientRequest.prototype._onXHRProgress=function(){var e=this;statusValid(e._xhr)&&!e._destroyed&&(e._response||e._connect(),e._response._onXHRProgress())},ClientRequest.prototype._connect=function(){var e=this;e._destroyed||(e._response=new IncomingMessage(e._xhr,e._fetchResponse,e._mode),e._response.on("error",function(t){e.emit("error",t)}),e.emit("response",e._response))},ClientRequest.prototype._write=function(e,t,r){this._body.push(e),r()},ClientRequest.prototype.abort=ClientRequest.prototype.destroy=function(){var e=this;e._destroyed=!0,e._response&&(e._response._destroyed=!0),e._xhr&&e._xhr.abort()},ClientRequest.prototype.end=function(e,t,r){var o=this;"function"==typeof e&&(r=e,e=void 0),stream.Writable.prototype.end.call(o,e,t,r)},ClientRequest.prototype.flushHeaders=function(){},ClientRequest.prototype.setTimeout=function(){},ClientRequest.prototype.setNoDelay=function(){},ClientRequest.prototype.setSocketKeepAlive=function(){};var unsafeHeaders=["accept-charset","accept-encoding","access-control-request-headers","access-control-request-method","connection","content-length","cookie","cookie2","date","dnt","expect","host","keep-alive","origin","referer","te","trailer","transfer-encoding","upgrade","user-agent","via"];
}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},require("buffer").Buffer)
},{"./capability":84,"./response":86,"_process":66,"buffer":56,"inherits":62,"readable-stream":79,"to-arraybuffer":88}],86:[function(require,module,exports){
(function (process,global,Buffer){
var capability=require("./capability"),inherits=require("inherits"),stream=require("readable-stream"),rStates=exports.readyStates={UNSENT:0,OPENED:1,HEADERS_RECEIVED:2,LOADING:3,DONE:4},IncomingMessage=exports.IncomingMessage=function(e,r,s){function a(){n.read().then(function(e){if(!t._destroyed){if(e.done)return void t.push(null);t.push(new Buffer(e.value)),a()}}).catch(function(e){t.emit("error",e)})}var t=this;if(stream.Readable.call(t),t._mode=s,t.headers={},t.rawHeaders=[],t.trailers={},t.rawTrailers=[],t.on("end",function(){process.nextTick(function(){t.emit("close")})}),"fetch"===s){t._fetchResponse=r,t.url=r.url,t.statusCode=r.status,t.statusMessage=r.statusText,r.headers.forEach(function(e,r){t.headers[r.toLowerCase()]=e,t.rawHeaders.push(r,e)});var n=r.body.getReader();a()}else{t._xhr=e,t._pos=0,t.url=e.responseURL,t.statusCode=e.status,t.statusMessage=e.statusText;if(e.getAllResponseHeaders().split(/\r?\n/).forEach(function(e){var r=e.match(/^([^:]+):\s*(.*)/);if(r){var s=r[1].toLowerCase();"set-cookie"===s?(void 0===t.headers[s]&&(t.headers[s]=[]),t.headers[s].push(r[2])):void 0!==t.headers[s]?t.headers[s]+=", "+r[2]:t.headers[s]=r[2],t.rawHeaders.push(r[1],r[2])}}),t._charset="x-user-defined",!capability.overrideMimeType){var o=t.rawHeaders["mime-type"];if(o){var i=o.match(/;\s*charset=([^;])(;|$)/);i&&(t._charset=i[1].toLowerCase())}t._charset||(t._charset="utf-8")}}};inherits(IncomingMessage,stream.Readable),IncomingMessage.prototype._read=function(){},IncomingMessage.prototype._onXHRProgress=function(){var e=this,r=e._xhr,s=null;switch(e._mode){case"text:vbarray":if(r.readyState!==rStates.DONE)break;try{s=new global.VBArray(r.responseBody).toArray()}catch(e){}if(null!==s){e.push(new Buffer(s));break}case"text":try{s=r.responseText}catch(r){e._mode="text:vbarray";break}if(s.length>e._pos){var a=s.substr(e._pos);if("x-user-defined"===e._charset){for(var t=new Buffer(a.length),n=0;n<a.length;n++)t[n]=255&a.charCodeAt(n);e.push(t)}else e.push(a,e._charset);e._pos=s.length}break;case"arraybuffer":if(r.readyState!==rStates.DONE||!r.response)break;s=r.response,e.push(new Buffer(new Uint8Array(s)));break;case"moz-chunked-arraybuffer":if(s=r.response,r.readyState!==rStates.LOADING||!s)break;e.push(new Buffer(new Uint8Array(s)));break;case"ms-stream":if(s=r.response,r.readyState!==rStates.LOADING)break;var o=new global.MSStreamReader;o.onprogress=function(){o.result.byteLength>e._pos&&(e.push(new Buffer(new Uint8Array(o.result.slice(e._pos)))),e._pos=o.result.byteLength)},o.onload=function(){e.push(null)},o.readAsArrayBuffer(s)}e._xhr.readyState===rStates.DONE&&"ms-stream"!==e._mode&&e.push(null)};
}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},require("buffer").Buffer)
},{"./capability":84,"_process":66,"buffer":56,"inherits":62,"readable-stream":79}],87:[function(require,module,exports){
arguments[4][50][0].apply(exports,arguments)
},{"buffer":56,"dup":50}],88:[function(require,module,exports){
var Buffer=require("buffer").Buffer;module.exports=function(e){if(e instanceof Uint8Array){if(0===e.byteOffset&&e.byteLength===e.buffer.byteLength)return e.buffer;if("function"==typeof e.buffer.slice)return e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength)}if(Buffer.isBuffer(e)){for(var f=new Uint8Array(e.length),r=e.length,t=0;t<r;t++)f[t]=e[t];return f.buffer}throw new Error("Argument must be a Buffer")};
},{"buffer":56}],89:[function(require,module,exports){
"use strict";function Url(){this.protocol=null,this.slashes=null,this.auth=null,this.host=null,this.port=null,this.hostname=null,this.hash=null,this.search=null,this.query=null,this.pathname=null,this.path=null,this.href=null}function urlParse(t,s,e){if(t&&util.isObject(t)&&t instanceof Url)return t;var h=new Url;return h.parse(t,s,e),h}function urlFormat(t){return util.isString(t)&&(t=urlParse(t)),t instanceof Url?t.format():Url.prototype.format.call(t)}function urlResolve(t,s){return urlParse(t,!1,!0).resolve(s)}function urlResolveObject(t,s){return t?urlParse(t,!1,!0).resolveObject(s):s}var punycode=require("punycode"),util=require("./util");exports.parse=urlParse,exports.resolve=urlResolve,exports.resolveObject=urlResolveObject,exports.format=urlFormat,exports.Url=Url;var protocolPattern=/^([a-z0-9.+-]+:)/i,portPattern=/:[0-9]*$/,simplePathPattern=/^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/,delims=["<",">",'"',"`"," ","\r","\n","\t"],unwise=["{","}","|","\\","^","`"].concat(delims),autoEscape=["'"].concat(unwise),nonHostChars=["%","/","?",";","#"].concat(autoEscape),hostEndingChars=["/","?","#"],hostnameMaxLen=255,hostnamePartPattern=/^[+a-z0-9A-Z_-]{0,63}$/,hostnamePartStart=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,unsafeProtocol={javascript:!0,"javascript:":!0},hostlessProtocol={javascript:!0,"javascript:":!0},slashedProtocol={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},querystring=require("querystring");Url.prototype.parse=function(t,s,e){if(!util.isString(t))throw new TypeError("Parameter 'url' must be a string, not "+typeof t);var h=t.indexOf("?"),r=-1!==h&&h<t.indexOf("#")?"?":"#",a=t.split(r),o=/\\/g;a[0]=a[0].replace(o,"/"),t=a.join(r);var n=t;if(n=n.trim(),!e&&1===t.split("#").length){var i=simplePathPattern.exec(n);if(i)return this.path=n,this.href=n,this.pathname=i[1],i[2]?(this.search=i[2],this.query=s?querystring.parse(this.search.substr(1)):this.search.substr(1)):s&&(this.search="",this.query={}),this}var l=protocolPattern.exec(n);if(l){l=l[0];var u=l.toLowerCase();this.protocol=u,n=n.substr(l.length)}if(e||l||n.match(/^\/\/[^@\/]+@[^@\/]+/)){var p="//"===n.substr(0,2);!p||l&&hostlessProtocol[l]||(n=n.substr(2),this.slashes=!0)}if(!hostlessProtocol[l]&&(p||l&&!slashedProtocol[l])){for(var c=-1,f=0;f<hostEndingChars.length;f++){var m=n.indexOf(hostEndingChars[f]);-1!==m&&(-1===c||m<c)&&(c=m)}var v,g;g=-1===c?n.lastIndexOf("@"):n.lastIndexOf("@",c),-1!==g&&(v=n.slice(0,g),n=n.slice(g+1),this.auth=decodeURIComponent(v)),c=-1;for(var f=0;f<nonHostChars.length;f++){var m=n.indexOf(nonHostChars[f]);-1!==m&&(-1===c||m<c)&&(c=m)}-1===c&&(c=n.length),this.host=n.slice(0,c),n=n.slice(c),this.parseHost(),this.hostname=this.hostname||"";var y="["===this.hostname[0]&&"]"===this.hostname[this.hostname.length-1];if(!y)for(var P=this.hostname.split(/\./),f=0,d=P.length;f<d;f++){var b=P[f];if(b&&!b.match(hostnamePartPattern)){for(var q="",O=0,j=b.length;O<j;O++)b.charCodeAt(O)>127?q+="x":q+=b[O];if(!q.match(hostnamePartPattern)){var x=P.slice(0,f),U=P.slice(f+1),C=b.match(hostnamePartStart);C&&(x.push(C[1]),U.unshift(C[2])),U.length&&(n="/"+U.join(".")+n),this.hostname=x.join(".");break}}}this.hostname.length>hostnameMaxLen?this.hostname="":this.hostname=this.hostname.toLowerCase(),y||(this.hostname=punycode.toASCII(this.hostname));var A=this.port?":"+this.port:"",w=this.hostname||"";this.host=w+A,this.href+=this.host,y&&(this.hostname=this.hostname.substr(1,this.hostname.length-2),"/"!==n[0]&&(n="/"+n))}if(!unsafeProtocol[u])for(var f=0,d=autoEscape.length;f<d;f++){var E=autoEscape[f];if(-1!==n.indexOf(E)){var I=encodeURIComponent(E);I===E&&(I=escape(E)),n=n.split(E).join(I)}}var R=n.indexOf("#");-1!==R&&(this.hash=n.substr(R),n=n.slice(0,R));var S=n.indexOf("?");if(-1!==S?(this.search=n.substr(S),this.query=n.substr(S+1),s&&(this.query=querystring.parse(this.query)),n=n.slice(0,S)):s&&(this.search="",this.query={}),n&&(this.pathname=n),slashedProtocol[u]&&this.hostname&&!this.pathname&&(this.pathname="/"),this.pathname||this.search){var A=this.pathname||"",k=this.search||"";this.path=A+k}return this.href=this.format(),this},Url.prototype.format=function(){var t=this.auth||"";t&&(t=encodeURIComponent(t),t=t.replace(/%3A/i,":"),t+="@");var s=this.protocol||"",e=this.pathname||"",h=this.hash||"",r=!1,a="";this.host?r=t+this.host:this.hostname&&(r=t+(-1===this.hostname.indexOf(":")?this.hostname:"["+this.hostname+"]"),this.port&&(r+=":"+this.port)),this.query&&util.isObject(this.query)&&Object.keys(this.query).length&&(a=querystring.stringify(this.query));var o=this.search||a&&"?"+a||"";return s&&":"!==s.substr(-1)&&(s+=":"),this.slashes||(!s||slashedProtocol[s])&&!1!==r?(r="//"+(r||""),e&&"/"!==e.charAt(0)&&(e="/"+e)):r||(r=""),h&&"#"!==h.charAt(0)&&(h="#"+h),o&&"?"!==o.charAt(0)&&(o="?"+o),e=e.replace(/[?#]/g,function(t){return encodeURIComponent(t)}),o=o.replace("#","%23"),s+r+e+o+h},Url.prototype.resolve=function(t){return this.resolveObject(urlParse(t,!1,!0)).format()},Url.prototype.resolveObject=function(t){if(util.isString(t)){var s=new Url;s.parse(t,!1,!0),t=s}for(var e=new Url,h=Object.keys(this),r=0;r<h.length;r++){var a=h[r];e[a]=this[a]}if(e.hash=t.hash,""===t.href)return e.href=e.format(),e;if(t.slashes&&!t.protocol){for(var o=Object.keys(t),n=0;n<o.length;n++){var i=o[n];"protocol"!==i&&(e[i]=t[i])}return slashedProtocol[e.protocol]&&e.hostname&&!e.pathname&&(e.path=e.pathname="/"),e.href=e.format(),e}if(t.protocol&&t.protocol!==e.protocol){if(!slashedProtocol[t.protocol]){for(var l=Object.keys(t),u=0;u<l.length;u++){var p=l[u];e[p]=t[p]}return e.href=e.format(),e}if(e.protocol=t.protocol,t.host||hostlessProtocol[t.protocol])e.pathname=t.pathname;else{for(var c=(t.pathname||"").split("/");c.length&&!(t.host=c.shift()););t.host||(t.host=""),t.hostname||(t.hostname=""),""!==c[0]&&c.unshift(""),c.length<2&&c.unshift(""),e.pathname=c.join("/")}if(e.search=t.search,e.query=t.query,e.host=t.host||"",e.auth=t.auth,e.hostname=t.hostname||t.host,e.port=t.port,e.pathname||e.search){var f=e.pathname||"",m=e.search||"";e.path=f+m}return e.slashes=e.slashes||t.slashes,e.href=e.format(),e}var v=e.pathname&&"/"===e.pathname.charAt(0),g=t.host||t.pathname&&"/"===t.pathname.charAt(0),y=g||v||e.host&&t.pathname,P=y,d=e.pathname&&e.pathname.split("/")||[],c=t.pathname&&t.pathname.split("/")||[],b=e.protocol&&!slashedProtocol[e.protocol];if(b&&(e.hostname="",e.port=null,e.host&&(""===d[0]?d[0]=e.host:d.unshift(e.host)),e.host="",t.protocol&&(t.hostname=null,t.port=null,t.host&&(""===c[0]?c[0]=t.host:c.unshift(t.host)),t.host=null),y=y&&(""===c[0]||""===d[0])),g)e.host=t.host||""===t.host?t.host:e.host,e.hostname=t.hostname||""===t.hostname?t.hostname:e.hostname,e.search=t.search,e.query=t.query,d=c;else if(c.length)d||(d=[]),d.pop(),d=d.concat(c),e.search=t.search,e.query=t.query;else if(!util.isNullOrUndefined(t.search)){if(b){e.hostname=e.host=d.shift();var q=!!(e.host&&e.host.indexOf("@")>0)&&e.host.split("@");q&&(e.auth=q.shift(),e.host=e.hostname=q.shift())}return e.search=t.search,e.query=t.query,util.isNull(e.pathname)&&util.isNull(e.search)||(e.path=(e.pathname?e.pathname:"")+(e.search?e.search:"")),e.href=e.format(),e}if(!d.length)return e.pathname=null,e.search?e.path="/"+e.search:e.path=null,e.href=e.format(),e;for(var O=d.slice(-1)[0],j=(e.host||t.host||d.length>1)&&("."===O||".."===O)||""===O,x=0,U=d.length;U>=0;U--)O=d[U],"."===O?d.splice(U,1):".."===O?(d.splice(U,1),x++):x&&(d.splice(U,1),x--);if(!y&&!P)for(;x--;x)d.unshift("..");!y||""===d[0]||d[0]&&"/"===d[0].charAt(0)||d.unshift(""),j&&"/"!==d.join("/").substr(-1)&&d.push("");var C=""===d[0]||d[0]&&"/"===d[0].charAt(0);if(b){e.hostname=e.host=C?"":d.length?d.shift():"";var q=!!(e.host&&e.host.indexOf("@")>0)&&e.host.split("@");q&&(e.auth=q.shift(),e.host=e.hostname=q.shift())}return y=y||e.host&&d.length,y&&!C&&d.unshift(""),d.length?e.pathname=d.join("/"):(e.pathname=null,e.path=null),util.isNull(e.pathname)&&util.isNull(e.search)||(e.path=(e.pathname?e.pathname:"")+(e.search?e.search:"")),e.auth=t.auth||e.auth,e.slashes=e.slashes||t.slashes,e.href=e.format(),e},Url.prototype.parseHost=function(){var t=this.host,s=portPattern.exec(t);s&&(s=s[0],":"!==s&&(this.port=s.substr(1)),t=t.substr(0,t.length-s.length)),t&&(this.hostname=t)};
},{"./util":90,"punycode":67,"querystring":70}],90:[function(require,module,exports){
"use strict";module.exports={isString:function(n){return"string"==typeof n},isObject:function(n){return"object"==typeof n&&null!==n},isNull:function(n){return null===n},isNullOrUndefined:function(n){return null==n}};
},{}],91:[function(require,module,exports){
(function (global){
function deprecate(r,e){function o(){if(!t){if(config("throwDeprecation"))throw new Error(e);config("traceDeprecation")?console.trace(e):console.warn(e),t=!0}return r.apply(this,arguments)}if(config("noDeprecation"))return r;var t=!1;return o}function config(r){try{if(!global.localStorage)return!1}catch(r){return!1}var e=global.localStorage[r];return null!=e&&"true"===String(e).toLowerCase()}module.exports=deprecate;
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
},{}],92:[function(require,module,exports){
arguments[4][19][0].apply(exports,arguments)
},{"dup":19}],93:[function(require,module,exports){
module.exports=function(o){return o&&"object"==typeof o&&"function"==typeof o.copy&&"function"==typeof o.fill&&"function"==typeof o.readUInt8};
},{}],94:[function(require,module,exports){
(function (process,global){
function inspect(e,r){var t={seen:[],stylize:stylizeNoColor};return arguments.length>=3&&(t.depth=arguments[2]),arguments.length>=4&&(t.colors=arguments[3]),isBoolean(r)?t.showHidden=r:r&&exports._extend(t,r),isUndefined(t.showHidden)&&(t.showHidden=!1),isUndefined(t.depth)&&(t.depth=2),isUndefined(t.colors)&&(t.colors=!1),isUndefined(t.customInspect)&&(t.customInspect=!0),t.colors&&(t.stylize=stylizeWithColor),formatValue(t,e,t.depth)}function stylizeWithColor(e,r){var t=inspect.styles[r];return t?"["+inspect.colors[t][0]+"m"+e+"["+inspect.colors[t][1]+"m":e}function stylizeNoColor(e,r){return e}function arrayToHash(e){var r={};return e.forEach(function(e,t){r[e]=!0}),r}function formatValue(e,r,t){if(e.customInspect&&r&&isFunction(r.inspect)&&r.inspect!==exports.inspect&&(!r.constructor||r.constructor.prototype!==r)){var n=r.inspect(t,e);return isString(n)||(n=formatValue(e,n,t)),n}var i=formatPrimitive(e,r);if(i)return i;var o=Object.keys(r),s=arrayToHash(o);if(e.showHidden&&(o=Object.getOwnPropertyNames(r)),isError(r)&&(o.indexOf("message")>=0||o.indexOf("description")>=0))return formatError(r);if(0===o.length){if(isFunction(r)){var u=r.name?": "+r.name:"";return e.stylize("[Function"+u+"]","special")}if(isRegExp(r))return e.stylize(RegExp.prototype.toString.call(r),"regexp");if(isDate(r))return e.stylize(Date.prototype.toString.call(r),"date");if(isError(r))return formatError(r)}var c="",a=!1,l=["{","}"];if(isArray(r)&&(a=!0,l=["[","]"]),isFunction(r)){c=" [Function"+(r.name?": "+r.name:"")+"]"}if(isRegExp(r)&&(c=" "+RegExp.prototype.toString.call(r)),isDate(r)&&(c=" "+Date.prototype.toUTCString.call(r)),isError(r)&&(c=" "+formatError(r)),0===o.length&&(!a||0==r.length))return l[0]+c+l[1];if(t<0)return isRegExp(r)?e.stylize(RegExp.prototype.toString.call(r),"regexp"):e.stylize("[Object]","special");e.seen.push(r);var p;return p=a?formatArray(e,r,t,s,o):o.map(function(n){return formatProperty(e,r,t,s,n,a)}),e.seen.pop(),reduceToSingleString(p,c,l)}function formatPrimitive(e,r){if(isUndefined(r))return e.stylize("undefined","undefined");if(isString(r)){var t="'"+JSON.stringify(r).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(t,"string")}return isNumber(r)?e.stylize(""+r,"number"):isBoolean(r)?e.stylize(""+r,"boolean"):isNull(r)?e.stylize("null","null"):void 0}function formatError(e){return"["+Error.prototype.toString.call(e)+"]"}function formatArray(e,r,t,n,i){for(var o=[],s=0,u=r.length;s<u;++s)hasOwnProperty(r,String(s))?o.push(formatProperty(e,r,t,n,String(s),!0)):o.push("");return i.forEach(function(i){i.match(/^\d+$/)||o.push(formatProperty(e,r,t,n,i,!0))}),o}function formatProperty(e,r,t,n,i,o){var s,u,c;if(c=Object.getOwnPropertyDescriptor(r,i)||{value:r[i]},c.get?u=c.set?e.stylize("[Getter/Setter]","special"):e.stylize("[Getter]","special"):c.set&&(u=e.stylize("[Setter]","special")),hasOwnProperty(n,i)||(s="["+i+"]"),u||(e.seen.indexOf(c.value)<0?(u=isNull(t)?formatValue(e,c.value,null):formatValue(e,c.value,t-1),u.indexOf("\n")>-1&&(u=o?u.split("\n").map(function(e){return" "+e}).join("\n").substr(2):"\n"+u.split("\n").map(function(e){return" "+e}).join("\n"))):u=e.stylize("[Circular]","special")),isUndefined(s)){if(o&&i.match(/^\d+$/))return u;s=JSON.stringify(""+i),s.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(s=s.substr(1,s.length-2),s=e.stylize(s,"name")):(s=s.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),s=e.stylize(s,"string"))}return s+": "+u}function reduceToSingleString(e,r,t){var n=0;return e.reduce(function(e,r){return n++,r.indexOf("\n")>=0&&n++,e+r.replace(/\u001b\[\d\d?m/g,"").length+1},0)>60?t[0]+(""===r?"":r+"\n ")+" "+e.join(",\n ")+" "+t[1]:t[0]+r+" "+e.join(", ")+" "+t[1]}function isArray(e){return Array.isArray(e)}function isBoolean(e){return"boolean"==typeof e}function isNull(e){return null===e}function isNullOrUndefined(e){return null==e}function isNumber(e){return"number"==typeof e}function isString(e){return"string"==typeof e}function isSymbol(e){return"symbol"==typeof e}function isUndefined(e){return void 0===e}function isRegExp(e){return isObject(e)&&"[object RegExp]"===objectToString(e)}function isObject(e){return"object"==typeof e&&null!==e}function isDate(e){return isObject(e)&&"[object Date]"===objectToString(e)}function isError(e){return isObject(e)&&("[object Error]"===objectToString(e)||e instanceof Error)}function isFunction(e){return"function"==typeof e}function isPrimitive(e){return null===e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||"symbol"==typeof e||void 0===e}function objectToString(e){return Object.prototype.toString.call(e)}function pad(e){return e<10?"0"+e.toString(10):e.toString(10)}function timestamp(){var e=new Date,r=[pad(e.getHours()),pad(e.getMinutes()),pad(e.getSeconds())].join(":");return[e.getDate(),months[e.getMonth()],r].join(" ")}function hasOwnProperty(e,r){return Object.prototype.hasOwnProperty.call(e,r)}var formatRegExp=/%[sdj%]/g;exports.format=function(e){if(!isString(e)){for(var r=[],t=0;t<arguments.length;t++)r.push(inspect(arguments[t]));return r.join(" ")}for(var t=1,n=arguments,i=n.length,o=String(e).replace(formatRegExp,function(e){if("%%"===e)return"%";if(t>=i)return e;switch(e){case"%s":return String(n[t++]);case"%d":return Number(n[t++]);case"%j":try{return JSON.stringify(n[t++])}catch(e){return"[Circular]"}default:return e}}),s=n[t];t<i;s=n[++t])isNull(s)||!isObject(s)?o+=" "+s:o+=" "+inspect(s);return o},exports.deprecate=function(e,r){function t(){if(!n){if(process.throwDeprecation)throw new Error(r);process.traceDeprecation?console.trace(r):console.error(r),n=!0}return e.apply(this,arguments)}if(isUndefined(global.process))return function(){return exports.deprecate(e,r).apply(this,arguments)};if(!0===process.noDeprecation)return e;var n=!1;return t};var debugs={},debugEnviron;exports.debuglog=function(e){if(isUndefined(debugEnviron)&&(debugEnviron=process.env.NODE_DEBUG||""),e=e.toUpperCase(),!debugs[e])if(new RegExp("\\b"+e+"\\b","i").test(debugEnviron)){var r=process.pid;debugs[e]=function(){var t=exports.format.apply(exports,arguments);console.error("%s %d: %s",e,r,t)}}else debugs[e]=function(){};return debugs[e]},exports.inspect=inspect,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]},inspect.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},exports.isArray=isArray,exports.isBoolean=isBoolean,exports.isNull=isNull,exports.isNullOrUndefined=isNullOrUndefined,exports.isNumber=isNumber,exports.isString=isString,exports.isSymbol=isSymbol,exports.isUndefined=isUndefined,exports.isRegExp=isRegExp,exports.isObject=isObject,exports.isDate=isDate,exports.isError=isError,exports.isFunction=isFunction,exports.isPrimitive=isPrimitive,exports.isBuffer=require("./support/isBuffer");var months=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];exports.log=function(){console.log("%s - %s",timestamp(),exports.format.apply(exports,arguments))},exports.inherits=require("inherits"),exports._extend=function(e,r){if(!r||!isObject(r))return e;for(var t=Object.keys(r),n=t.length;n--;)e[t[n]]=r[t[n]];return e};
}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
},{"./support/isBuffer":93,"_process":66,"inherits":92}],95:[function(require,module,exports){
function extend(){for(var r={},e=0;e<arguments.length;e++){var t=arguments[e];for(var n in t)hasOwnProperty.call(t,n)&&(r[n]=t[n])}return r}module.exports=extend;var hasOwnProperty=Object.prototype.hasOwnProperty;
},{}]},{},[4])
/*
(c) 2014, Vladimir Agafonkin
simpleheat, a tiny JavaScript library for drawing heatmaps with Canvas
https://github.com/mourner/simpleheat
*/
!function(){"use strict";function t(i){return this instanceof t?(this._canvas=i="string"==typeof i?document.getElementById(i):i,this._ctx=i.getContext("2d"),this._width=i.width,this._height=i.height,this._max=1,void this.clear()):new t(i)}t.prototype={defaultRadius:25,defaultGradient:{.4:"blue",.6:"cyan",.7:"lime",.8:"yellow",1:"red"},data:function(t,i){return this._data=t,this},max:function(t){return this._max=t,this},add:function(t){return this._data.push(t),this},clear:function(){return this._data=[],this},radius:function(t,i){i=i||15;var a=this._circle=document.createElement("canvas"),s=a.getContext("2d"),e=this._r=t+i;return a.width=a.height=2*e,s.shadowOffsetX=s.shadowOffsetY=200,s.shadowBlur=i,s.shadowColor="black",s.beginPath(),s.arc(e-200,e-200,t,0,2*Math.PI,!0),s.closePath(),s.fill(),this},gradient:function(t){var i=document.createElement("canvas"),a=i.getContext("2d"),s=a.createLinearGradient(0,0,0,256);i.width=1,i.height=256;for(var e in t)s.addColorStop(e,t[e]);return a.fillStyle=s,a.fillRect(0,0,1,256),this._grad=a.getImageData(0,0,1,256).data,this},draw:function(t){this._circle||this.radius(this.defaultRadius),this._grad||this.gradient(this.defaultGradient);var i=this._ctx;i.clearRect(0,0,this._width,this._height);for(var a,s=0,e=this._data.length;e>s;s++)a=this._data[s],i.globalAlpha=Math.max(a[2]/this._max,t||.05),i.drawImage(this._circle,a[0]-this._r,a[1]-this._r);var n=i.getImageData(0,0,this._width,this._height);return this._colorize(n.data,this._grad),i.putImageData(n,0,0),this},_colorize:function(t,i){for(var a,s=3,e=t.length;e>s;s+=4)a=4*t[s],a&&(t[s-3]=i[a],t[s-2]=i[a+1],t[s-1]=i[a+2])}},window.simpleheat=t}(),/*
(c) 2014, Vladimir Agafonkin
Leaflet.heat, a tiny and fast heatmap plugin for Leaflet.
https://github.com/Leaflet/Leaflet.heat
*/
L.HeatLayer=(L.Layer?L.Layer:L.Class).extend({initialize:function(t,i){this._latlngs=t,L.setOptions(this,i)},setLatLngs:function(t){return this._latlngs=t,this.redraw()},addLatLng:function(t){return this._latlngs.push(t),this.redraw()},setOptions:function(t){return L.setOptions(this,t),this._heat&&this._updateOptions(),this.redraw()},redraw:function(){return!this._heat||this._frame||this._map._animating||(this._frame=L.Util.requestAnimFrame(this._redraw,this)),this},onAdd:function(t){this._map=t,this._canvas||this._initCanvas(),t._panes.overlayPane.appendChild(this._canvas),t.on("moveend",this._reset,this),t.options.zoomAnimation&&L.Browser.any3d&&t.on("zoomanim",this._animateZoom,this),this._reset()},onRemove:function(t){t.getPanes().overlayPane.removeChild(this._canvas),t.off("moveend",this._reset,this),t.options.zoomAnimation&&t.off("zoomanim",this._animateZoom,this)},addTo:function(t){return t.addLayer(this),this},_initCanvas:function(){var t=this._canvas=L.DomUtil.create("canvas","leaflet-heatmap-layer leaflet-layer"),i=L.DomUtil.testProp(["transformOrigin","WebkitTransformOrigin","msTransformOrigin"]);t.style[i]="50% 50%";var a=this._map.getSize();t.width=a.x,t.height=a.y;var s=this._map.options.zoomAnimation&&L.Browser.any3d;L.DomUtil.addClass(t,"leaflet-zoom-"+(s?"animated":"hide")),this._heat=simpleheat(t),this._updateOptions()},_updateOptions:function(){this._heat.radius(this.options.radius||this._heat.defaultRadius,this.options.blur),this.options.gradient&&this._heat.gradient(this.options.gradient),this.options.max&&this._heat.max(this.options.max)},_reset:function(){var t=this._map.containerPointToLayerPoint([0,0]);L.DomUtil.setPosition(this._canvas,t);var i=this._map.getSize();this._heat._width!==i.x&&(this._canvas.width=this._heat._width=i.x),this._heat._height!==i.y&&(this._canvas.height=this._heat._height=i.y),this._redraw()},_redraw:function(){var t,i,a,s,e,n,h,o,r,d=[],_=this._heat._r,l=this._map.getSize(),m=new L.Bounds(L.point([-_,-_]),l.add([_,_])),c=void 0===this.options.max?1:this.options.max,u=void 0===this.options.maxZoom?this._map.getMaxZoom():this.options.maxZoom,f=1/Math.pow(2,Math.max(0,Math.min(u-this._map.getZoom(),12))),g=_/2,p=[],v=this._map._getMapPanePos(),w=v.x%g,y=v.y%g;for(t=0,i=this._latlngs.length;i>t;t++)if(a=this._map.latLngToContainerPoint(this._latlngs[t]),m.contains(a)){e=Math.floor((a.x-w)/g)+2,n=Math.floor((a.y-y)/g)+2;var x=void 0!==this._latlngs[t].alt?this._latlngs[t].alt:void 0!==this._latlngs[t][2]?+this._latlngs[t][2]:1;r=x*f,p[n]=p[n]||[],s=p[n][e],s?(s[0]=(s[0]*s[2]+a.x*r)/(s[2]+r),s[1]=(s[1]*s[2]+a.y*r)/(s[2]+r),s[2]+=r):p[n][e]=[a.x,a.y,r]}for(t=0,i=p.length;i>t;t++)if(p[t])for(h=0,o=p[t].length;o>h;h++)s=p[t][h],s&&d.push([Math.round(s[0]),Math.round(s[1]),Math.min(s[2],c)]);this._heat.data(d).draw(this.options.minOpacity),this._frame=null},_animateZoom:function(t){var i=this._map.getZoomScale(t.zoom),a=this._map._getCenterOffset(t.center)._multiplyBy(-i).subtract(this._map._getMapPanePos());L.DomUtil.setTransform?L.DomUtil.setTransform(this._canvas,a,i):this._canvas.style[L.DomUtil.TRANSFORM]=L.DomUtil.getTranslateString(a)+" scale("+i+")"}}),L.heatLayer=function(t,i){return new L.HeatLayer(t,i)};
'use strict';
/*
(c) 2014, Vladimir Agafonkin
simpleheat, a tiny JavaScript library for drawing heatmaps with Canvas
https://github.com/mourner/simpleheat
*/
if (typeof module !== 'undefined') module.exports = simpleisochrone;
function simpleisochrone(canvas) {
if (!(this instanceof simpleisochrone)) return new simpleisochrone(canvas);
this._canvas = canvas = typeof canvas === 'string' ? document.getElementById(canvas) : canvas;
this._ctx = canvas.getContext('2d');
this._width = canvas.width;
this._height = canvas.height;
this._max = 1;
this._data = [];
}
simpleisochrone.prototype = {
defaultRadius: 25,
defaultGradient: {
0.4: 'blue',
0.6: 'cyan',
0.7: 'lime',
0.8: 'yellow',
1.0: 'red'
},
data: function (data) {
this._data = data;
return this;
},
max: function (max) {
this._max = max;
return this;
},
add: function (point) {
this._data.push(point);
return this;
},
clear: function () {
this._data = [];
return this;
},
resize: function () {
this._width = this._canvas.width;
this._height = this._canvas.height;
},
gradient: function (grad) {
// create a 256x1 gradient that we'll use to turn a grayscale heatmap into a colored one
var canvas = this._createCanvas(),
ctx = canvas.getContext('2d'),
gradient = ctx.createLinearGradient(0, 0, 0, 256);
canvas.width = 1;
canvas.height = 256;
for (var i in grad) {
gradient.addColorStop(+i, grad[i]);
}
ctx.fillStyle = gradient;
ctx.fillRect(0, 0, 1, 256);
this._grad = ctx.getImageData(0, 0, 1, 256).data;
return this;
},
intensityCircle: function (r, intensity, blur) {
blur = blur === undefined ? 15 : blur;
// create a grayscale blurred circle image that we'll use for drawing points
var circle = this._createCanvas(),
ctx = circle.getContext('2d'),
r2 = this._r = r + blur;
circle.width = circle.height = r2 * 2;
ctx.shadowOffsetX = ctx.shadowOffsetY = r2 * 2;
ctx.shadowBlur = blur;
var colorInt = (intensity / this._max * 255);
ctx.shadowColor = 'rgb(' + colorInt + ', ' + colorInt + ',' + colorInt + ')';
ctx.fillStyle = 'rgb(' + colorInt + ', ' + colorInt + ',' + colorInt + ')';
ctx.beginPath();
ctx.arc(-r2, -r2, r, 0, Math.PI * 2, true);
ctx.closePath();
ctx.fill();
return circle;
},
draw: function (minOpacity) {
if (!this._grad) this.gradient(this.defaultGradient);
var ctx = this._ctx;
ctx.clearRect(0, 0, this._width, this._height);
// draw a grayscale heatmap by putting a blurred circle at each data point
for (var i = 0, len = this._data.length, p; i < len; i++) {
p = this._data[i];
ctx.globalAlpha = p[2] / this._max;
ctx.drawImage(this.intensityCircle(this.defaultRadius, p[2]), p[0] - this._r, p[1] - this._r);
}
// colorize the heatmap, using opacity value of each pixel to get the right color from our gradient
var colored = ctx.getImageData(0, 0, this._width, this._height);
this._colorize(colored.data, this._grad);
ctx.putImageData(colored, 0, 0);
return this;
},
_colorize: function (pixels, gradient) {
for (var i = 0, len = pixels.length, j; i < len; i += 4) {
j = pixels[i] * 4; // get gradient color from opacity value
if (j) {
pixels[i] = gradient[j];
pixels[i + 1] = gradient[j + 1];
pixels[i + 2] = gradient[j + 2];
}
}
},
_createCanvas: function () {
if (typeof document !== 'undefined') {
return document.createElement('canvas');
} else {
// create a new canvas instance in node.js
// the canvas class needs to have a default constructor without any parameter
return new this._canvas.constructor();
}
}
};
/*
(c) 2014, Vladimir Agafonkin
Leaflet.heat, a tiny and fast heatmap plugin for Leaflet.
https://github.com/Leaflet/Leaflet.heat
*/
/*
(c) 2014, Vladimir Agafonkin
Leaflet.heat, a tiny and fast heatmap plugin for Leaflet.
https://github.com/Leaflet/Leaflet.heat
*/
L.IsochroneLayer = (L.Layer ? L.Layer : L.Class).extend({
// options: {
// minOpacity: 0.05,
// maxZoom: 18,
// radius: 25,
// blur: 15,
// max: 1.0
// },
initialize: function (latlngs, options) {
this._latlngs = latlngs;
L.setOptions(this, options);
},
setLatLngs: function (latlngs) {
this._latlngs = latlngs;
return this.redraw();
},
addLatLng: function (latlng) {
this._latlngs.push(latlng);
return this.redraw();
},
setOptions: function (options) {
L.setOptions(this, options);
if (this._heat) {
this._updateOptions();
}
return this.redraw();
},
redraw: function () {
if (this._heat && !this._frame && this._map && !this._map._animating) {
this._frame = L.Util.requestAnimFrame(this._redraw, this);
}
return this;
},
onAdd: function (map) {
this._map = map;
if (!this._canvas) {
this._initCanvas();
}
if (this.options.pane) {
this.getPane().appendChild(this._canvas);
}else{
map._panes.overlayPane.appendChild(this._canvas);
}
map.on('moveend', this._reset, this);
if (map.options.zoomAnimation && L.Browser.any3d) {
map.on('zoomanim', this._animateZoom, this);
}
this._reset();
},
onRemove: function (map) {
if (this.options.pane) {
this.getPane().removeChild(this._canvas);
}else{
map.getPanes().overlayPane.removeChild(this._canvas);
}
map.off('moveend', this._reset, this);
if (map.options.zoomAnimation) {
map.off('zoomanim', this._animateZoom, this);
}
},
addTo: function (map) {
map.addLayer(this);
return this;
},
_initCanvas: function () {
var canvas = this._canvas = L.DomUtil.create('canvas', 'leaflet-heatmap-layer leaflet-layer');
var originProp = L.DomUtil.testProp(['transformOrigin', 'WebkitTransformOrigin', 'msTransformOrigin']);
canvas.style[originProp] = '50% 50%';
var size = this._map.getSize();
canvas.width = size.x;
canvas.height = size.y;
var animated = this._map.options.zoomAnimation && L.Browser.any3d;
L.DomUtil.addClass(canvas, 'leaflet-zoom-' + (animated ? 'animated' : 'hide'));
this._heat = simpleisochrone(canvas);
this._updateOptions();
},
_updateOptions: function () {
this._heat.intensityCircle(this.options.radius || this._heat.defaultRadius, 1,this.options.blur);
if (this.options.gradient) {
this._heat.gradient(this.options.gradient);
}
if (this.options.max) {
this._heat.max(this.options.max);
}
},
_reset: function () {
var topLeft = this._map.containerPointToLayerPoint([0, 0]);
L.DomUtil.setPosition(this._canvas, topLeft);
var size = this._map.getSize();
if (this._heat._width !== size.x) {
this._canvas.width = this._heat._width = size.x;
}
if (this._heat._height !== size.y) {
this._canvas.height = this._heat._height = size.y;
}
this._redraw();
},
_redraw: function () {
if (!this._map) {
return;
}
var data = [],
r = this._heat._r,
size = this._map.getSize(),
bounds = new L.Bounds(
L.point([-r, -r]),
size.add([r, r])),
max = this.options.max === undefined ? 1 : this.options.max,
maxZoom = this.options.maxZoom === undefined ? this._map.getMaxZoom() : this.options.maxZoom,
v = 1 / Math.pow(2, Math.max(0, Math.min(maxZoom - this._map.getZoom(), 12))),
cellSize = r / 2,
grid = [],
panePos = this._map._getMapPanePos(),
offsetX = panePos.x % cellSize,
offsetY = panePos.y % cellSize,
i, len, p, cell, x, y, j, len2, k;
// console.time('process');
this._latlngs.sort(compareIntensity);
for (i = 0, len = this._latlngs.length; i < len; i++) {
p = this._map.latLngToContainerPoint(this._latlngs[i]);
if (bounds.contains(p)) {
x = Math.floor((p.x - offsetX) / cellSize) + 2;
y = Math.floor((p.y - offsetY) / cellSize) + 2;
var alt = this._latlngs[i][2];
k = alt;// * v;
grid[y] = grid[y] || [];
cell = grid[y][x];
if (!cell) {
grid[y][x] = [p.x, p.y, k];
} else {
cell[0] = (cell[0] * cell[2] + p.x * k) / (cell[2] + k); // x
cell[1] = (cell[1] * cell[2] + p.y * k) / (cell[2] + k); // y
cell[2] = k; // cumulated intensity value
}
}
}
for (i = 0, len = grid.length; i < len; i++) {
if (grid[i]) {
for (j = 0, len2 = grid[i].length; j < len2; j++) {
cell = grid[i][j];
if (cell) {
data.push([
Math.round(cell[0]),
Math.round(cell[1]),
Math.min(cell[2], max)
]);
}
}
}
}
// console.timeEnd('process');
// console.time('draw ' + data.length);
this._heat.data(data).draw(this.options.minOpacity);
// console.timeEnd('draw ' + data.length);
this._frame = null;
},
_animateZoom: function (e) {
var scale = this._map.getZoomScale(e.zoom),
offset = this._map._getCenterOffset(e.center)._multiplyBy(-scale).subtract(this._map._getMapPanePos());
if (L.DomUtil.setTransform) {
L.DomUtil.setTransform(this._canvas, offset, scale);
} else {
this._canvas.style[L.DomUtil.TRANSFORM] = L.DomUtil.getTranslateString(offset) + ' scale(' + scale + ')';
}
}
});
L.isochroneLayer = function (latlngs, options) {
return new L.IsochroneLayer(latlngs, options);
};
function compareIntensity(a, b) {
if (a[2] < b[2]) {
return -1;
}
if (a[2] > b[2]) {
return 1;
}
// a must be equal to b
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment