text: !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("solid-auth-cli")):"function"==typeof define&&define.amd?define(["solid-auth-cli"],t):"object"==typeof exports?exports.SolidFileClient=t(require("solid-auth-cli")):e.SolidFileClient=t(e["solid-auth-cli"])}(window,function(e){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var i=t[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)n.d(r,i,function(t){return e[t]}.bind(null,i));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=92)}([function(e,t,n){e.exports=n(63)},function(e,t){function n(e,t,n,r,i,o,a){try{var s=e[o](a),u=s.value}catch(e){return void n(e)}s.done?t(u):Promise.resolve(u).then(r,i)}e.exports=function(e){return function(){var t=this,r=arguments;return new Promise(function(i,o){var a=e.apply(t,r);function s(e){n(a,i,o,s,u,"next",e)}function u(e){n(a,i,o,s,u,"throw",e)}s(void 0)})}}},function(e,t,n){"use strict";function r(e){return(r="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})(e)}function i(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function o(e,t){return!t||"object"!==r(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function a(e){return(a=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function s(e,t){return(s=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}var u=n(14),c=n(3),l=function(e){function t(e){var n;if(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),(n=o(this,a(t).call(this))).termType=t.termType,e&&e.termType===t.termType&&(e=e.value),!e)throw new Error("Missing IRI for NamedNode");if(!e.includes(":"))throw new Error('NamedNode IRI "'+e+'" must be absolute.');if(e.includes(" "))throw new Error('Error: NamedNode IRI "'+e+'" must not contain unencoded spaces.');return n.value=e,n}var n,r,u;return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&s(e,t)}(t,c),n=t,u=[{key:"fromValue",value:function(e){return null==e?e:e&&e.termType?e:new t(e)}}],(r=[{key:"dir",value:function(){var e=this.uri.split("#")[0],n=e.slice(0,-1).lastIndexOf("/"),r=e.indexOf("//");return r>=0&&n<r+2||n<0?null:new t(e.slice(0,n+1))}},{key:"site",value:function(){var e=this.uri.split("#")[0],n=e.indexOf("//");if(n<0)throw new Error("This URI does not have a web site part (origin)");var r=e.indexOf("/",n+2);if(r<0)throw new Error("This URI does not have a web site part. (origin)");return new t(e.slice(0,r+1))}},{key:"doc",value:function(){return this.uri.indexOf("#")<0?this:new t(this.uri.split("#")[0])}},{key:"toString",value:function(){return"<"+this.uri+">"}},{key:"uri",get:function(){return this.value},set:function(e){this.value=e}}])&&i(n.prototype,r),u&&i(n,u),t}();l.termType="NamedNode",l.prototype.classOrder=u.NamedNode,l.prototype.isVar=0,e.exports=l},function(e,t,n){"use strict";function r(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}var i=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e)}var t,n,i;return t=e,(n=[{key:"substitute",value:function(e){return console.log("@@@ node substitute"+this),this}},{key:"compareTerm",value:function(e){return this.classOrder<e.classOrder?-1:this.classOrder>e.classOrder?1:this.value<e.value?-1:this.value>e.value?1:0}},{key:"equals",value:function(e){return!!e&&(this.termType===e.termType&&this.value===e.value)}},{key:"hashString",value:function(){return this.toCanonical()}},{key:"sameTerm",value:function(e){return this.equals(e)}},{key:"toCanonical",value:function(){return this.toNT()}},{key:"toNT",value:function(){return this.toString()}},{key:"toString",value:function(){throw new Error("Node.toString() is abstract - see the subclasses instead")}}])&&r(t.prototype,n),i&&r(t,i),e}();e.exports=i,i.fromValue=function(e){var t=n(21),r=n(15);n(2);return null==e?e:e&&e.termType?e:Array.isArray(e)?new t(e):r.fromValue(e)};var o={xsd:n(16)("http://www.w3.org/2001/XMLSchema#")};i.toJS=function(e){if(e.elements)return e.elements.map(i.toJS);if(!e.datatype)return e;if(e.datatype.sameTerm(o.xsd("boolean")))return"1"===e.value;if(e.datatype.sameTerm(o.xsd("dateTime"))||e.datatype.sameTerm(o.xsd("date")))return new Date(e.value);if(e.datatype.sameTerm(o.xsd("integer"))||e.datatype.sameTerm(o.xsd("float"))||e.datatype.sameTerm(o.xsd("decimal"))){Number(e.value);return Number(e.value)}return e.value}},function(e,t,n){"use strict";var r=r||console.log;e.exports.docpart=o,e.exports.document=function(e){return new i(o(e.uri))},e.exports.hostpart=function(e){var t=/[^\/]*\/\/([^\/]*)\//.exec(e);return t?t[1]:""},e.exports.join=function(e,t){var n,i,o,a,s,u=t.indexOf("#");u>0&&(t=t.slice(0,u));if(0===e.length)return t;if(0===e.indexOf("#"))return t+e;if(e.indexOf(":")>=0)return e;if(n=t.indexOf(":"),0===t.length)return e;if(n<0)return r("Invalid base: "+t+" in join with given: "+e),e;if(i=t.slice(0,+n+1||9e9),0===e.indexOf("//"))return i+e;if(t.indexOf("//",n)===n+1){if((o=t.indexOf("/",n+3))<0)return t.length-n-3>0?t+"/"+e:i+e}else if((o=t.indexOf("/",n+1))<0)return t.length-n-1>0?t+"/"+e:i+e;if(0===e.indexOf("/"))return t.slice(0,o)+e;if(s=t.slice(o),(a=s.lastIndexOf("/"))<0)return i+e;a>=0&&a<s.length-1&&(s=s.slice(0,+a+1||9e9));s+=e;for(;s.match(/[^\/]*\/\.\.\//);)s=s.replace(/[^\/]*\/\.\.\//,"");return s=(s=s.replace(/\.\//g,"")).replace(/\/\.$/,"/"),t.slice(0,o)+s},e.exports.protocol=function(e){var t;return(t=e.indexOf(":"))<0?null:e.slice(0,t)},e.exports.refTo=function(e,t){var n,r,i,o,a,s,u,c,l,f,h,p,d=new RegExp("^[-_a-zA-Z0-9.]+:(//[^/]*)?/[^/]*$");if(!e)return t;if(e===t)return"";for(n=u=0,o=t.length;u<o&&t[n]===e[n];n=++u);if(e.slice(0,n).match(d)&&((r=t.indexOf("//"))<0&&(r=-2),i=t.indexOf("/",r+2),"/"!==t[i+1]&&"/"!==e[i+1]&&t.slice(0,i)===e.slice(0,i)))return t.slice(i);if("#"===t[n]&&e.length===n)return t.slice(n);for(;n>0&&"/"!==t[n-1];)n--;if(n<3)return t;if(e.indexOf("//",n-2)>0||t.indexOf("//",n-2)>0)return t;if(e.indexOf(":",n)>0)return t;for(s=0,f=e.slice(n),c=0,a=f.length;c<a;c++)"/"===f[c]&&s++;if(0===s&&n<t.length&&"#"===t[n])return"./"+t.slice(n);if(0===s&&n===t.length)return"./";if(p="",s>0)for(l=1,h=s;h>=1?l<=h:l>=h;h>=1?++l:--l)p+="../";return p+t.slice(n)};var i=n(2);function o(e){var t;return(t=e.indexOf("#"))<0?e:e.slice(0,t)}},function(e,t,n){"use strict";var r={BlankNode:n(9),Collection:n(21),convert:n(42),DataFactory:n(24),Empty:n(87),Fetcher:n(36),Formula:n(59),Store:n(19),jsonParser:n(88),Literal:n(15),log:n(13),N3Parser:n(27),NamedNode:n(2),Namespace:n(16),Node:n(3),parse:n(60),Query:n(20).Query,queryToSPARQL:n(89),RDFaProcessor:n(39),RDFParser:n(40),serialize:n(37),Serializer:n(38),SPARQLToQuery:n(90),sparqlUpdateParser:n(61),Statement:n(25),term:n(3).fromValue,UpdateManager:n(91),UpdatesSocket:n(62).UpdatesSocket,UpdatesVia:n(62).UpdatesVia,uri:n(4),Util:n(6),Variable:n(26)};r.IndexedFormula=r.Store,r.NextId=r.BlankNode.nextId,r.fromNT=r.Formula.prototype.fromNT,r.fetcher=r.DataFactory.fetcher,r.graph=r.DataFactory.graph,r.lit=r.DataFactory.lit,r.st=r.DataFactory.st,r.sym=r.DataFactory.namedNode,r.variable=r.DataFactory.variable,r.blankNode=r.DataFactory.blankNode,r.defaultGraph=r.DataFactory.defaultGraph,r.literal=r.DataFactory.literal,r.namedNode=r.DataFactory.namedNode,r.quad=r.DataFactory.quad,r.triple=r.DataFactory.triple,e.exports=r},function(e,t,n){"use strict";(function(e){var t=n(4).docpart,r=n(13),i=n(2);function o(e,t,n,r){var i,a="",s=[!1];if(void 0===e.nodeType)return a;if(1===e.nodeType){if(e.hasAttribute("class")&&"classWithChildText"in t&&e.matches(t.classWithChildText.class))a+=e.querySelector(t.classWithChildText.element).textContent;else if(!("skipNodeWithClass"in t&&e.matches("."+t.skipNodeWithClass))){var u=e.nodeName.toLowerCase();a+="<"+u;var c=[];for(i=e.attributes.length-1;i>=0;i--){var l=e.attributes[i];if(!(r.length>0&&r[l.name])&&!/^\d+$/.test(l.name)){if("class"===l.name&&"replaceClassItemWith"in t&&l.value.split(" ").indexOf(t.replaceClassItemWith.source)>-1){var f=new RegExp(t.replaceClassItemWith.source,"g");l.value=l.value.replace(f,t.replaceClassItemWith.target).trim()}"class"===l.name&&"skipClassWithValue"in t&&t.skipClassWithValue===l.value||c.push(l.name+"='"+l.value.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/'/g,"&quot;")+"'")}}if(c.length>0&&("sortAttributes"in t&&t.sortAttributes&&c.sort(function(e,t){return e.toLowerCase().localeCompare(t.toLowerCase())}),a+=" "+c.join(" ")),n[u])a+=" />";else{for(a+=">",a+="html"===u?"\n  ":"",s.push("style"===u||"script"===u),i=0;i<e.childNodes.length;i++)a+=o(e.childNodes[i]);s.pop(),a+="body"===u?"</"+u+">\n":"</"+u+">"}}}else if(8===e.nodeType)a+="\x3c!--"+e.nodeValue+"--\x3e";else if(3===e.nodeType||4===e.nodeType){var h=e.nodeValue.replace(/\n+$/,"");a+=s[s.length-1]?h:h.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}else console.log("Warning; Cannot handle serialising nodes of type: "+e.nodeType),console.log(e);return a}function a(e,t,n,r){var i=function(e){return"BlankNode"===e.termType?null:e},o=function(e){var t=n.statementsMatching(e).map(function(e){return i(e.subject)+" "+i(e.predicate)+" "+i(e.object)}).concat(n.statementsMatching(void 0,void 0,e).map(function(e){return i(e.subject)+" "+i(e.predicate)+" "+i(e.object)}));return t.sort(),t.join("\n")};return"BlankNode"===e.termType&&"BlankNode"===t.termType?0===e.compareTerm(t)?0:o(e)>o(t)?1:o(e)<o(t)?-1:e.compareTerm(t):r&&e.uri&&t.uri?(r[e.uri]||e.uri).localeCompare(r[t.uri]||t.uri):e.compareTerm(t)}function s(e,t){return e.slice(0,t.length)===t}e.exports.AJAR_handleNewTerm=function(e,n,i){var o=null;if(void 0===e.fetcher)return;o=e.fetcher;if("NamedNode"!==n.termType)return;var a,u=t(n.uri);if(n.uri.indexOf("#")<0){if(s(n.uri,"http://dbpedia.org/resource/Category:"))return;s(n.uri,"http://purl.org/dc/elements/1.1/")||s(n.uri,"http://purl.org/dc/terms/")?a="http://dublincore.org/2005/06/13/dcq":s(n.uri,"http://xmlns.com/wot/0.1/")?a="http://xmlns.com/wot/0.1/index.rdf":s(n.uri,"http://web.resource.org/cc/")&&(a="http://web.resource.org/cc/schema.rdf")}a&&(u=a);if(o&&"unrequested"!==o.getState(u))return;a&&r.warn("Assuming server still broken, faking redirect of <"+n.uri+"> to <"+u+">");return o.fetch(u,{referringTerm:i})},e.exports.ArrayIndexOf=function(e,t,n){n||(n=0);var r=e.length;n<0&&(n=r+n);for(;n<r;n++)if(e[n]===t)return n;return-1},e.exports.callbackify=function(e,t){e.callbacks={};for(var n=t.length-1;n>=0;n--)e.callbacks[t[n]]=[];e.addHook=function(t){e.callbacks[t]||(e.callbacks[t]=[])},e.addCallback=function(t,n){e.callbacks[t].push(n)},e.removeCallback=function(t,n){for(var r=0;r<e.callbacks[t].length;r++)if(e.callbacks[t][r].name===n)return e.callbacks[t].splice(r,1),!0;return!1},e.insertCallback=function(t,n){e.callbacks[t].unshift(n)},e.fireCallbacks=function(t,n){var r,i,o=[],a=[],s=e.callbacks[t].length;for(r=s-1;r>=0;r--)(i=e.callbacks[t][r])&&i.apply(e,n)&&o.push(i);for(r=o.length-1;r>=0;r--)a.push(o[r]);for(r=s;r<e.callbacks[t].length;r++)a.push(e.callbacks[t][r]);e.callbacks[t]=a}},e.exports.dtstamp=function(){var e=new Date,t=e.getYear()+1900,n=e.getMonth()+1,r=e.getDate(),i=e.getUTCHours(),o=e.getUTCMinutes(),a=e.getSeconds();n<10&&(n="0"+n);r<10&&(r="0"+r);i<10&&(i="0"+i);o<10&&(o="0"+o);a<10&&(a="0"+a);return t+"-"+n+"-"+r+"T"+i+":"+o+":"+a+"Z"},e.exports.DOMParserFactory=function(){return window.DOMParser?new DOMParser:!!window.ActiveXObject&&new ActiveXObject("Microsoft.XMLDOM")},e.exports.domToString=function(e,t){var n=[];"selfClosing"in(t=t||{})&&t.selfClosing.split(" ").forEach(function(e){n[e]=!0});var r=[];"skipAttributes"in t&&t.skipAttributes.split(" ").forEach(function(e){r[e]=!0});return o(e,t,n,r)},e.exports.dumpNode=o,e.exports.heavyCompare=a,e.exports.heavyCompareSPO=function(e,t,n,r){return a(e.subject,t.subject,n,r)||a(e.predicate,t.predicate,n,r)||a(e.object,t.object,n,r)},e.exports.output=function(e){var t=document.createElement("div");t.textContent=e,document.body.appendChild(t)},e.exports.parseXML=function(t,r){var i;if(r=r||{},e&&e.exports){var o=n(84).DOMParser,a=(new o).parseFromString(t,r.contentType||"application/xhtml+xml");return a}i="undefined"!=typeof window&&window.DOMParser?new window.DOMParser:new o;return i.parseFromString(t,"application/xml")},e.exports.RDFArrayRemove=function(e,t){for(var n=0;n<e.length;n++)if(e[n].subject.sameTerm(t.subject)&&e[n].predicate.sameTerm(t.predicate)&&e[n].object.sameTerm(t.object)&&e[n].why.sameTerm(t.why))return void e.splice(n,1);throw new Error("RDFArrayRemove: Array did not contain "+t+" "+t.why)},e.exports.stackString=function(e){var t=e+"\n";if(!e.stack)return t+"No stack available.\n";for(var n=e.stack.toString().split("\n"),r=[],i=0;i<n.length;i++){var o=n[i];if(o.indexOf("ecmaunit.js")>-1)break;"("==o.charAt(0)&&(o="function"+o);var a=o.split("@");r.push(a)}for(var i=0;i<r.length;i++)t+="  "+r[i][1]+"\n    "+r[i][0];return t},e.exports.string_startswith=s,e.exports.string={},e.exports.string.template=function(e,t){for(var n=e.split("%s"),r="",i=0;i<t.length;i++)t[i]+="",r+=n[i]+t[i];return r+n.slice(t.length).join()},e.exports.uri=n(4),e.exports.log=r,e.exports.mediaTypeClass=function(e){return e=e.split(";")[0].trim(),new i("http://www.w3.org/ns/iana/media-types/"+e+"#Resource")},e.exports.linkRelationProperty=function(e){return new i("http://www.w3.org/ns/iana/link-relations/relation#"+e.trim())}}).call(this,n(83)(e))},function(e,t){var n,r,i=e.exports={};function o(){throw new Error("setTimeout has not been defined")}function a(){throw new Error("clearTimeout has not been defined")}function s(e){if(n===setTimeout)return setTimeout(e,0);if((n===o||!n)&&setTimeout)return n=setTimeout,setTimeout(e,0);try{return n(e,0)}catch(t){try{return n.call(null,e,0)}catch(t){return n.call(this,e,0)}}}!function(){try{n="function"==typeof setTimeout?setTimeout:o}catch(e){n=o}try{r="function"==typeof clearTimeout?clearTimeout:a}catch(e){r=a}}();var u,c=[],l=!1,f=-1;function h(){l&&u&&(l=!1,u.length?c=u.concat(c):f=-1,c.length&&p())}function p(){if(!l){var e=s(h);l=!0;for(var t=c.length;t;){for(u=c,c=[];++f<t;)u&&u[f].run();f=-1,t=c.length}u=null,l=!1,function(e){if(r===clearTimeout)return clearTimeout(e);if((r===a||!r)&&clearTimeout)return r=clearTimeout,clearTimeout(e);try{r(e)}catch(t){try{return r.call(null,e)}catch(t){return r.call(this,e)}}}(e)}}function d(e,t){this.fun=e,this.array=t}function y(){}i.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];c.push(new d(e,t)),1!==c.length||l||s(p)},d.prototype.run=function(){this.fun.apply(null,this.array)},i.title="browser",i.browser=!0,i.env={},i.argv=[],i.version="",i.versions={},i.on=y,i.addListener=y,i.once=y,i.off=y,i.removeListener=y,i.removeAllListeners=y,i.emit=y,i.prependListener=y,i.prependOnceListener=y,i.listeners=function(e){return[]},i.binding=function(e){throw new Error("process.binding is not supported")},i.cwd=function(){return"/"},i.chdir=function(e){throw new Error("process.chdir is not supported")},i.umask=function(){return 0}},function(e,t){var n;n=function(){return this}();try{n=n||new Function("return this")()}catch(e){"object"==typeof window&&(n=window)}e.exports=n},function(e,t,n){"use strict";function r(e){return(r="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})(e)}function i(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function o(e,t){return!t||"object"!==r(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function a(e){return(a=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function s(e,t){return(s=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}var u=n(14),c=n(3),l=function(e){function t(e){var n;if(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),(n=o(this,a(t).call(this))).termType=t.termType,e){if("string"!=typeof e)throw console.log("Bad blank id:",e),new Error("Bad id argument to new blank node: "+e);if(e.includes("#")){var r=e.split("#");e=r[r.length-1]}n.id=e}else n.id="n"+t.nextId++;return n.value=n.id,n}var n,r,u;return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&s(e,t)}(t,c),n=t,(r=[{key:"compareTerm",value:function(e){return this.classOrder<e.classOrder?-1:this.classOrder>e.classOrder?1:this.id<e.id?-1:this.id>e.id?1:0}},{key:"copy",value:function(e){var n=new t;return e.copyTo(this,n),n}},{key:"toCanonical",value:function(){return"_:"+this.value}},{key:"toString",value:function(){return t.NTAnonymousNodePrefix+this.id}}])&&i(n.prototype,r),u&&i(n,u),t}();l.nextId=0,l.termType="BlankNode",l.NTAnonymousNodePrefix="_:",l.prototype.classOrder=u.BlankNode,l.prototype.isBlank=1,l.prototype.isVar=1,e.exports=l},function(e,t){},function(e,t){"function"==typeof Object.create?e.exports=function(e,t){e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}})}:e.exports=function(e,t){e.super_=t;var n=function(){};n.prototype=t.prototype,e.prototype=new n,e.prototype.constructor=e}},function(e,t,n){"use strict";var r=n(22),i=Object.keys||function(e){var t=[];for(var n in e)t.push(n);return t};e.exports=f;var o=n(18);o.inherits=n(11);var a=n(49),s=n(34);o.inherits(f,a);for(var u=i(s.prototype),c=0;c<u.length;c++){var l=u[c];f.prototype[l]||(f.prototype[l]=s.prototype[l])}function f(e){if(!(this instanceof f))return new f(e);a.call(this,e),s.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",h)}function h(){this.allowHalfOpen||this._writableState.ended||r.nextTick(p,this)}function p(e){e.end()}Object.defineProperty(f.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),Object.defineProperty(f.prototype,"destroyed",{get:function(){return void 0!==this._readableState&&void 0!==this._writableState&&(this._readableState.destroyed&&this._writableState.destroyed)},set:function(e){void 0!==this._readableState&&void 0!==this._writableState&&(this._readableState.destroyed=e,this._writableState.destroyed=e)}}),f.prototype._destroy=function(e,t){this.push(null),this.end(),r.nextTick(t,e)}},function(e,t,n){"use strict";e.exports={debug:function(e){},warn:function(e){},info:function(e){},error:function(e){},success:function(e){},msg:function(e){}}},function(e,t,n){"use strict";e.exports={Literal:1,Collection:3,Graph:4,NamedNode:5,BlankNode:6,Variable:7}},function(e,t,n){"use strict";function r(e){return(r="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})(e)}function i(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function o(e,t){return!t||"object"!==r(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function a(e){return(a=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function s(e,t){return(s=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}var u=n(14),c=n(2),l=n(3),f=n(41),h=function(e){function t(e,n,r){var i;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),(i=o(this,a(t).call(this))).termType=t.termType,i.value=e,n&&(i.lang=n,r=f.langString),r&&(i.datatype=c.fromValue(r)),i}var n,u,h;return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&s(e,t)}(t,l),n=t,h=[{key:"fromBoolean",value:function(e){return new t(e?"1":"0",null,f.boolean)}},{key:"fromDate",value:function(e){if(!(e instanceof Date))throw new TypeError("Invalid argument to Literal.fromDate()");var n=function(e){return(""+(100+e)).slice(1,3)};return new t(e.getUTCFullYear()+"-"+n(e.getUTCMonth()+1)+"-"+n(e.getUTCDate())+"T"+n(e.getUTCHours())+":"+n(e.getUTCMinutes())+":"+n(e.getUTCSeconds())+"Z",null,f.dateTime)}},{key:"fromNumber",value:function(e){if("number"!=typeof e)throw new TypeError("Invalid argument to Literal.fromNumber()");var n,r=e.toString();return n=r.indexOf("e")<0&&Math.abs(e)<=Number.MAX_SAFE_INTEGER?Number.isInteger(e)?f.integer:f.decimal:f.double,new t(r,null,n)}},{key:"fromValue",value:function(e){if(null==e)return e;if("object"===r(e)&&e.termType)return e;switch(r(e)){case"object":if(e instanceof Date)return t.fromDate(e);case"boolean":return t.fromBoolean(e);case"number":return t.fromNumber(e);case"string":return new t(e)}throw new Error("Can't make literal from "+e+" of type "+r(e))}}],(u=[{key:"copy",value:function(){return new t(this.value,this.lang,this.datatype)}},{key:"equals",value:function(e){return!!e&&(this.termType===e.termType&&this.value===e.value&&this.language===e.language&&(!this.datatype&&!e.datatype||this.datatype&&this.datatype.equals(e.datatype)))}},{key:"toNT",value:function(){if("number"==typeof this.value)return this.toString();if("string"!=typeof this.value)throw new Error("Value of RDF literal is not string or number: "+this.value);var e=this.value;return e='"'+(e=(e=(e=e.replace(/\\/g,"\\\\")).replace(/\"/g,'\\"')).replace(/\n/g,"\\n"))+'"',this.language?e+="@"+this.language:this.datatype.equals(f.string)||(e+="^^"+this.datatype.toCanonical()),e}},{key:"toString",value:function(){return""+this.value}},{key:"language",get:function(){return this.lang},set:function(e){this.lang=e||""}}])&&i(n.prototype,u),h&&i(n,h),t}();h.termType="Literal",h.prototype.classOrder=u.Literal,h.prototype.datatype=f.string,h.prototype.lang="",h.prototype.isVar=0,e.exports=h},function(e,t,n){"use strict";var r=n(2);e.exports=function(e){return function(t){return new r(e+(t||""))}}},function(e,t,n){(function(e){var r=void 0!==e&&e||"undefined"!=typeof self&&self||window,i=Function.prototype.apply;function o(e,t){this._id=e,this._clearFn=t}t.setTimeout=function(){return new o(i.call(setTimeout,r,arguments),clearTimeout)},t.setInterval=function(){return new o(i.call(setInterval,r,arguments),clearInterval)},t.clearTimeout=t.clearInterval=function(e){e&&e.close()},o.prototype.unref=o.prototype.ref=function(){},o.prototype.close=function(){this._clearFn.call(r,this._id)},t.enroll=function(e,t){clearTimeout(e._idleTimeoutId),e._idleTimeout=t},t.unenroll=function(e){clearTimeout(e._idleTimeoutId),e._idleTimeout=-1},t._unrefActive=t.active=function(e){clearTimeout(e._idleTimeoutId);var t=e._idleTimeout;t>=0&&(e._idleTimeoutId=setTimeout(function(){e._onTimeout&&e._onTimeout()},t))},n(66),t.setImmediate="undefined"!=typeof self&&self.setImmediate||void 0!==e&&e.setImmediate||this&&this.setImmediate,t.clearImmediate="undefined"!=typeof self&&self.clearImmediate||void 0!==e&&e.clearImmediate||this&&this.clearImmediate}).call(this,n(8))},function(e,t,n){(function(e){function n(e){return Object.prototype.toString.call(e)}t.isArray=function(e){return Array.isArray?Array.isArray(e):"[object Array]"===n(e)},t.isBoolean=function(e){return"boolean"==typeof e},t.isNull=function(e){return null===e},t.isNullOrUndefined=function(e){return null==e},t.isNumber=function(e){return"number"==typeof e},t.isString=function(e){return"string"==typeof e},t.isSymbol=function(e){return"symbol"==typeof e},t.isUndefined=function(e){return void 0===e},t.isRegExp=function(e){return"[object RegExp]"===n(e)},t.isObject=function(e){return"object"==typeof e&&null!==e},t.isDate=function(e){return"[object Date]"===n(e)},t.isError=function(e){return"[object Error]"===n(e)||e instanceof Error},t.isFunction=function(e){return"function"==typeof e},t.isPrimitive=function(e){return null===e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||"symbol"==typeof e||void 0===e},t.isBuffer=e.isBuffer}).call(this,n(52).Buffer)},function(e,t,n){"use strict";function r(e){return(r="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})(e)}function i(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function o(e,t){return!t||"object"!==r(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function a(e){return(a=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function s(e,t){return(s=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}var u=n(6).ArrayIndexOf,c=n(59),l=n(6).RDFArrayRemove,f=n(25),h=n(3),p=n(26);function d(e,t,n,r){var i=e.any(t,n,void 0);return!!i&&(e.equate(i,r),!0)}function y(e,t,n,r){var i=e.any(void 0,n,r);return!!i&&(e.equate(i,t),!0)}function v(e,t,n,r,i){e.typeCallback&&e.typeCallback(e,r,i);var o=e.classActions[r.hashString()],a=!1;if(o)for(var s=0;s<o.length;s++)a=a||o[s](e,t,n,r,i);return a}var g=function(e){function t(e){var n;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),(n=o(this,a(t).call(this))).propertyActions=[],n.classActions=[],n.redirections=[],n.aliases=[],n.HTTPRedirects=[],n.subjectIndex=[],n.predicateIndex=[],n.objectIndex=[],n.whyIndex=[],n.index=[n.subjectIndex,n.predicateIndex,n.objectIndex,n.whyIndex],n.namespaces={},n.features=e||["sameAs","InverseFunctionalProperty","FunctionalProperty"],n.initPropertyActions(n.features),n}var r,g,m;return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&s(e,t)}(t,c),r=t,m=[{key:"defaultGraphURI",get:function(){return"chrome:theSession"}}],(g=[{key:"substitute",value:function(e){var n=this.statements.map(function(t){return t.substitute(e)}),r=new t;return r.add(n),r}},{key:"applyPatch",value:function(e,t,r){var i,o=n(20).Query,a=this,s=null;function u(n){if(e.delete){i=e.delete,s&&(i=i.substitute(s)),i=i.statements;var o=[],u=i.map(function(e){var n=a.statementsMatching(e.subject,e.predicate,e.object,t);return 0===n.length?(o.push(e),null):n[0]});if(o.length)return r("Could not find to delete: "+o.join("\n or "));u.map(function(e){a.remove(e)})}e.insert&&(i=e.insert,s&&(i=i.substitute(s)),(i=i.statements).map(function(e){e.why=t,a.add(e.subject,e.predicate,e.object,e.why)})),n()}if(e.where){var c=new o("patch");c.pat=e.where,c.pat.statements.map(function(e){e.why=t}),c.sync=!0;var l=[];a.query(c,function(e){l.push(e)},a.fetcher,function(){return 0===l.length?r("No match found to be patched:"+e.where):l.length>1?r("Patch ambiguous. No patch done."):(s=l[0],void u(r))})}else u(r)}},{key:"declareExistential",value:function(e){return this._existentialVariables||(this._existentialVariables=[]),this._existentialVariables.push(e),e}},{key:"initPropertyActions",value:function(e){this.propertyActions["<http://www.w3.org/1999/02/22-rdf-syntax-ns#type>"]=[v],u(e,"sameAs")>=0&&(this.propertyActions["<http://www.w3.org/2002/07/owl#sameAs>"]=[function(e,t,n,r,i){return e.equate(t,r),!0}]),u(e,"InverseFunctionalProperty")>=0&&(this.classActions["<http://www.w3.org/2002/07/owl#InverseFunctionalProperty>"]=[function(e,t,n,r,i){return e.newPropertyAction(t,y)}]),u(e,"FunctionalProperty")>=0&&(this.classActions["<http://www.w3.org/2002/07/owl#FunctionalProperty>"]=[function(e,t,n,r,i){return e.newPropertyAction(t,d)}])}},{key:"add",value:function(e,n,r,i){var o,a,s;if(1===arguments.length){if(e instanceof Array)for(o=0;o<e.length;o++)this.add(e[o]);else e instanceof f?this.add(e.subject,e.predicate,e.object,e.why):e instanceof t&&this.add(e.statements);return this}i||(i=this.fetcher?this.fetcher.appNode:this.sym("chrome:theSession")),e=h.fromValue(e),n=h.fromValue(n),r=h.fromValue(r),i=h.fromValue(i),this.predicateCallback&&this.predicateCallback(this,n,i);var u=this.canon(n).hashString(),c=!1;if(a=this.propertyActions[u])for(o=0;o<a.length;o++)c=c||a[o](this,e,n,r,i);if(this.holds(e,n,r,i))return null;var l=[this.canon(e).hashString(),u,this.canon(r).hashString(),this.canon(i).hashString()];for(s=new f(e,n,r,i),o=0;o<4;o++){var p=this.index[o],d=l[o];p[d]||(p[d]=[]),p[d].push(s)}return this.statements.push(s),s}},{key:"canon",value:function(e){if(!e)return e;var t=this.redirections[e.hashString()];return t||e}},{key:"check",value:function(){this.checkStatementList(this.statements);for(var e=0;e<4;e++){var t=this.index[e];for(var n in t)t.hasOwnProperty(n)&&this.checkStatementList(t[n],e)}}},{key:"checkStatementList",value:function(e,t){for(var n,r=" found in "+["subject","predicate","object","why"][t]+" index.",i=0;i<e.length;i++){for(var o=[(n=e[i]).subject,n.predicate,n.object,n.why],a=function(e,t){for(var n=0;n<e.length;n++)if(e[n].subject.sameTerm(t.subject)&&e[n].predicate.sameTerm(t.predicate)&&e[n].object.sameTerm(t.object)&&e[n].why.sameTerm(t.why))return!0},s=0;s<4;s++){var u=this.canon(o[s]).hashString();this.index[s][u]&&a(this.index[s][u],n)}if(!a(this.statements,n))throw new Error("Statement list does not statement "+n+"@"+n.why+r)}}},{key:"close",value:function(){return this}},{key:"copyTo",value:function(e,t,n){n||(n=[]);var r=this.statementsMatching(e);-1!==u(n,"two-direction")&&r.concat(this.statementsMatching(void 0,void 0,e));for(var i=0;i<r.length;i++){var o=r[i];switch(o.object.termType){case"NamedNode":this.add(t,o.predicate,o.object);break;case"Literal":case"BlankNode":case"Collection":this.add(t,o.predicate,o.object.copy(this))}-1!==u(n,"delete")&&this.remove(o)}}},{key:"equate",value:function(e,t){e=this.canon(e),t=this.canon(t);var n=e.compareTerm(t);return!n||(n<0?this.replaceWith(t,e):this.replaceWith(e,t))}},{key:"formula",value:function(e){return new t(e)}},{key:"match",value:function(e,t,n,r){return this.statementsMatching(h.fromValue(e),h.fromValue(t),h.fromValue(n),h.fromValue(r))}},{key:"mentionsURI",value:function(e){var t="<"+e+">";return!!this.subjectIndex[t]||!!this.objectIndex[t]||!!this.predicateIndex[t]}},{key:"newExistential",value:function(e){if(!e)return this.bnode();var t=this.sym(e);return this.declareExistential(t)}},{key:"newPropertyAction",value:function(e,t){var n=e.hashString();this.propertyActions[n]||(this.propertyActions[n]=[]),this.propertyActions[n].push(t);for(var r=this.statementsMatching(void 0,e,void 0),i=!1,o=0;o<r.length;o++)i=i||t(this,r[o].subject,e,r[o].object);return i}},{key:"newUniversal",value:function(e){var t=this.sym(e);return this._universalVariables||(this._universalVariables=[]),this._universalVariables.push(t),t}},{key:"variable",value:function(e){return new p(e)}},{key:"nextSymbol",value:function(e){for(var t=0;;t++){var n=e.uri+"#n"+t;if(!this.mentionsURI(n))return this.sym(n)}}},{key:"query",value:function(e,t,r,i){return n(20).indexedFormulaQuery.call(this,e,t,r,i)}},{key:"querySync",value:function(e){var t=[],r=!1;if(e.sync=!0,n(20).indexedFormulaQuery.call(this,e,function(e){t.push(e)},null,function(){r=!0}),!r)throw new Error("Sync query should have called done function");return t}},{key:"remove",value:function(e){if(e instanceof Array){for(var n=0;n<e.length;n++)this.remove(e[n]);return this}if(e instanceof t)return this.remove(e.statements);var r=this.statementsMatching(e.subject,e.predicate,e.object,e.why);if(!r.length)throw new Error("Statement to be removed is not on store: "+e);return this.removeStatement(r[0]),this}},{key:"removeDocument",value:function(e){for(var t=this.statementsMatching(void 0,void 0,void 0,e).slice(),n=0;n<t.length;n++)this.removeStatement(t[n]);return this}},{key:"removeMany",value:function(e,t,n,r,i){for(var o=this.statementsMatching(e,t,n,r,!1),a=[],s=0;s<o.length;s++)a.push(o[s]);for(i&&(a=a.slice(0,i)),s=0;s<a.length;s++)this.remove(a[s])}},{key:"removeMatches",value:function(e,t,n,r){return this.removeStatements(this.statementsMatching(e,t,n,r)),this}},{key:"removeStatement",value:function(e){for(var t=[e.subject,e.predicate,e.object,e.why],n=0;n<4;n++){var r=this.canon(t[n]).hashString();this.index[n][r]&&l(this.index[n][r],e)}return l(this.statements,e),this}},{key:"removeStatements",value:function(e){for(var t=0;t<e.length;t++)this.remove(e[t]);return this}},{key:"replaceWith",value:function(e,t){for(var n=e.hashString(),r=t.hashString(),i=function(e){var t=e[n];if(t){var i=e[r];e[r]=i?t.concat(i):t,delete e[n]}},o=0;o<4;o++)i(this.index[o]);if(this.redirections[n]=t,e.uri){if(this.aliases[r]||(this.aliases[r]=[]),this.aliases[r].push(e),this.aliases[n])for(o=0;o<this.aliases[n].length;o++)this.redirections[this.aliases[n][o].hashString()]=t,this.aliases[r].push(this.aliases[n][o]);this.add(t,this.sym("http://www.w3.org/2007/ont/link#uri"),e.uri),this.fetcher&&this.fetcher.nowKnownAs(e,t)}return i(this.classActions),i(this.propertyActions),!0}},{key:"allAliases",value:function(e){var t=this.aliases[this.canon(e).hashString()]||[];return t.push(this.canon(e)),t}},{key:"sameThings",value:function(e,t){if(e.sameTerm(t))return!0;var n=this.canon(e);if(!n)return!1;var r=this.canon(t);return!!r&&n.uri===r.uri}},{key:"setPrefixForURI",value:function(e,t){"tab"===e&&this.namespaces.tab||"ns"!==e.slice(0,2)&&"default"!==e.slice(0,7)&&(this.namespaces[e]=t)}},{key:"statementsMatching",value:function(e,t,n,r,i){var o,a,s=[e,t,n,r],u=[],c=[],l=[],f=[];for(o=0;o<4;o++)u[o]=this.canon(h.fromValue(s[o])),u[o]?(f.push(o),c[o]=u[o].hashString()):l.push(o);if(0===f.length)return this.statements;if(1===f.length)return o=f[0],(a=this.index[o][c[o]])&&i&&a.length>1&&(a=a.slice(0,1)),a=a||[];var p,d,y=1e10;for(d=0;d<f.length;d++){if(o=f[d],!(a=this.index[o][c[o]]))return[];a.length<y&&(y=a.length,p=d)}for(var v=f[p],g=this.index[v][c[v]],m=f.slice(0,p).concat(f.slice(p+1)),w=[],b=["subject","predicate","object","why"],x=0;x<g.length;x++){var _=g[x];for(d=0;d<m.length;d++)if(o=m[d],!this.canon(_[b[o]]).sameTerm(u[o])){_=null;break}if(null!=_&&(w.push(_),i))break}return w}},{key:"uris",value:function(e){var t=this.canon(e),n=this.aliases[t.hashString()];if(!t.uri)return[];var r=[t.uri];if(n)for(var i=0;i<n.length;i++)r.push(n[i].uri);return r}},{key:"length",get:function(){return this.statements.length}}])&&i(r.prototype,g),m&&i(r,m),t}();e.exports=g,g.handleRDFType=v},function(e,t,n){"use strict";var r=n(19),i=n(13),o=n(4).docpart,a=r.defaultGraphURI;e.exports.Query=function e(t,n){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.pat=new r,this.vars=[],this.name=t,this.id=n},e.exports.indexedFormulaQuery=function(e,t,n,r){function s(e){var t,n="";for(t in e)e.hasOwnProperty(t)&&(n+="    "+t+" -> "+e[t]);return n}function u(e){var t,n="Bindings: ",r=e.length;for(t=0;t<r;t++)n+=s(e[t][0])+";\n\t";return n}function c(e,t,n,r){var i;if(e.length!==t.length)return[];if(!e.length)return[[[],null]];var o=function(e,t,n,r){var i=n[e];if(void 0===i){if(e.isVar){var o=[];return o[e]=t,[[o,null]]}i=e}if(!i.complexType)return r.redirections[i]&&(i=r.redirections[i]),r.redirections[t]&&(t=r.redirections[t]),i.sameTerm(t)||i.uri&&i.uri===a?[[[],null]]:[];if(e instanceof Array)return t instanceof Array?c(e,t,n):[];throw new Error("query.js: oops - code not written yet")}(e[0],t[0],n,r);if(0===o.length)return o;var s,u,l,f,h,p,d,y=[],v=o.length;for(s=0;s<v;s++){for(h in d=[],u=o[s][0])u.hasOwnProperty(h)&&(d[h]=u[h]);for(h in n)n.hasOwnProperty(h)&&(d[h]=n[h]);for(f=(i=c(e.slice(1),t.slice(1),d,r)).length,l=0;l<f;l++){for(h in p=i[l][0],u)u.hasOwnProperty(h)&&(p[h]=u[h]);y.push([p,null])}}return y}function l(e,t){var n,r={};for(n in e)e.hasOwnProperty(n)&&(r[n]=e[n]);for(n in t)t.hasOwnProperty(n)&&(r[n]=t[n]);return r}function f(e,t){return this.trunkBindings=t,this.originalCallback=e,this.branches=[],this}function h(e,t){return this.count=0,this.success=!1,this.done=!1,this.callback=e,this.onDone=t,this}f.prototype.checkAllDone=function(){var e;for(e=0;e<this.branches.length;e++)if(!this.branches[e].done)return;i.debug("OPTIONAL BIDNINGS ALL DONE:"),this.doCallBacks(this.branches.length-1,this.trunkBindings)},f.prototype.doCallBacks=function(e,t){var n;if(e<0)return this.originalCallback(t);for(n=0;n<this.branches[e].results.length;n++)this.doCallBacks(e-1,l(t,this.branches[e].results[n]))},h.prototype.reportMatch=function(e){this.callback(e),this.success=!0},h.prototype.reportDone=function(){this.done=!0,i.info("Mandatory query branch finished.***"),void 0!==this.onDone&&this.onDone()};var p=function(e){return this.count=0,this.done=!1,this.results=[],this.junction=e,e.branches.push(this),this};function d(e,t,n){var r,i,o,s,u,c;for(t.nvars=0,t.index=null,r=[t.subject,t.predicate,t.object,t.why],s=[e.subjectIndex,e.predicateIndex,e.objectIndex,e.whyIndex],o=0;o<4;o++){var l=r[o];if(l.uri&&l.uri===a);else if(l.isVar&&void 0===n[l])t.nvars++;else{if(c=void 0,l=void 0===(c=n[u=r[o]])?u:c,e.redirections[l.hashString()]&&(l=e.redirections[l.hashString()]),!(i=s[o][l.hashString()]))return t.index=[],!1;(null===t.index||t.index.length>i.length)&&(t.index=i)}}return null===t.index&&(t.index=e.statements),!0}function y(e,t){return e.nvars!==t.nvars?e.nvars-t.nvars:e.index.length-t.index.length}p.prototype.reportMatch=function(e){this.results.push(e)},p.prototype.reportDone=function(){i.debug("Optional branch finished - results.length = "+this.results.length),0===this.results.length&&(this.results.push({}),i.debug("Optional branch FAILED - that's OK.")),this.done=!0,this.junction.checkAllDone()};var v=function e(n,r,a,u,c,l,h){i.debug("Match begins, Branch count now: "+h.count+" for "+h.pattern_debug);var d,y,v=n.fetcher?n.fetcher:null,g=r.statements;if(0===g.length){if(i.debug("FOUND MATCH WITH BINDINGS:"+s(a)),0===r.optional.length)h.reportMatch(a);else{i.debug("OPTIONAL: "+r.optional);var w,b=new f(t,a),x=[];for(w=0;w<r.optional.length;w++)x[w]=new p(b),x[w].pattern_debug=r.optional[w];for(w=0;w<r.optional.length;w++)x[w].count=x[w].count+1,e(n,r.optional[w],a,"",c,t,x[w])}return h.count--,void i.debug("Match ends -- success , Branch count now: "+h.count+" for "+h.pattern_debug)}var _=g.length;if(v){var k=function(t,i){var o=t.uri.split("#")[0];v.nowOrWhenFetched(o,void 0,function(i,o,s){i||console.log("Error following link to <"+t.uri+"> in query: "+o),e(n,r,a,u,c,l,h)})};for(y=0;y<_;y++){if(d=g[y],void 0!==a[d.subject]&&a[d.subject].uri&&v&&"unrequested"===v.getState(o(a[d.subject].uri)))return void k(a[d.subject]);if(void 0!==a[d.object]&&a[d.object].uri&&v&&"unrequested"===v.getState(o(a[d.object].uri)))return void k(a[d.object])}}m(n,r,a,u,c,l,h)},g=function(e,t){var n,r,i=!0;for(n in e)e.hasOwnProperty(n)&&t[n]&&(r=t[n].test)&&!r(e[n])&&(i=!1);return i},m=function(e,t,n,r,o,a,l){var f,h,p,m,w,b,x,_=t.statements,k=_.length;for(f=0;f<k;f++)d(e,x=_[f],n);_.sort(y),x=_[0];var S,T=e.formula();T.optional=t.optional,T.constraints=t.constraints,T.statements=_.slice(1),i.debug(r+"match2 searching "+x.index.length+" for "+x+"; bindings so far="+s(n));var E,O,j=x.index.length,N=0;for(S=0;S<j;S++)for(O=x.index[S],E=c([x.subject,x.predicate,x.object,x.why],[O.subject,O.predicate,O.object,O.why],n,e),i.info(r+" From first: "+E.length+": "+u(E)),p=E.length,h=0;h<p;h++)if(w=[],b=E[h][0],g(b,t.constraints)){for(m in b)b.hasOwnProperty(m)&&(w[m]=b[m]);for(m in n)n.hasOwnProperty(m)&&(w[m]=n[m]);l.count++,N++,v(e,T,w,r+"  ",o,a,l)}else i.debug("Branch count CS: "+l.count);l.count--,0===N&&i.debug("Match2 fails completely on "+x),i.debug("Match2 ends, Branch count: "+l.count+" for "+l.pattern_debug),0===l.count&&(i.debug("Branch finished."),l.reportDone())},w=this;i.debug("Query on "+this.statements.length);var b=new h(t,r);b.count++,e.sync?v(w,e.pat,e.pat.initBindings,"",n,t,b):setTimeout(function(){v(w,e.pat,e.pat.initBindings,"",n,t,b)},0)}},function(e,t,n){"use strict";function r(e){return(r="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})(e)}function i(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function o(e,t){return!t||"object"!==r(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function a(e){return(a=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function s(e,t){return(s=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}var u=n(9),c=n(14),l=n(3),f=function(e){function t(e){var n;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),(n=o(this,a(t).call(this))).termType=t.termType,n.id=u.nextId++,n.elements=[],n.closed=!1,e&&e.length>0&&e.forEach(function(e){n.elements.push(l.fromValue(e))}),n}var n,r,c;return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&s(e,t)}(t,l),n=t,(r=[{key:"append",value:function(e){return this.elements.push(e)}},{key:"close",value:function(){return this.closed=!0,this.closed}},{key:"shift",value:function(){return this.elements.shift()}},{key:"substitute",value:function(e){return new t(this.elements.map(function(t){t.substitute(e)}))}},{key:"toNT",value:function(){return u.NTAnonymousNodePrefix+this.id}},{key:"toString",value:function(){return"("+this.elements.join(" ")+")"}},{key:"unshift",value:function(e){return this.elements.unshift(e)}}])&&i(n.prototype,r),c&&i(n,c),t}();f.termType="Collection",f.prototype.classOrder=c.Collection,f.prototype.compareTerm=u.prototype.compareTerm,f.prototype.isVar=0,e.exports=f},function(e,t,n){"use strict";(function(t){!t.version||0===t.version.indexOf("v0.")||0===t.version.indexOf("v1.")&&0!==t.version.indexOf("v1.8.")?e.exports={nextTick:function(e,n,r,i){if("function"!=typeof e)throw new TypeError('"callback" argument must be a function');var o,a,s=arguments.length;switch(s){case 0:case 1:return t.nextTick(e);case 2:return t.nextTick(function(){e.call(null,n)});case 3:return t.nextTick(function(){e.call(null,n,r)});case 4:return t.nextTick(function(){e.call(null,n,r,i)});default:for(o=new Array(s-1),a=0;a<o.length;)o[a++]=arguments[a];return t.nextTick(function(){e.apply(null,o)})}}}:e.exports=t}).call(this,n(7))},function(e,t,n){var r=n(52),i=r.Buffer;function o(e,t){for(var n in e)t[n]=e[n]}function a(e,t,n){return i(e,t,n)}i.from&&i.alloc&&i.allocUnsafe&&i.allocUnsafeSlow?e.exports=r:(o(r,t),t.Buffer=a),o(i,a),a.from=function(e,t,n){if("number"==typeof e)throw new TypeError("Argument must not be a number");return i(e,t,n)},a.alloc=function(e,t,n){if("number"!=typeof e)throw new TypeError("Argument must be a number");var r=i(e);return void 0!==t?"string"==typeof n?r.fill(t,n):r.fill(t):r.fill(0),r},a.allocUnsafe=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return i(e)},a.allocUnsafeSlow=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return r.SlowBuffer(e)}},function(e,t,n){"use strict";var r=n(9),i=n(21),o=n(82),a=n(36),s=n(19),u=n(15),c=n(2),l=n(25),f=n(26);function h(e){return new c(e)}function p(e,t,n,r){return r=r||new o,new l(e,t,n,r)}e.exports.blankNode=function(e){return new r(e)},e.exports.defaultGraph=function(){return new o},e.exports.graph=function(){return new s},e.exports.literal=function(e,t){return"string"==typeof t?-1===t.indexOf(":")?new u(e,t):new u(e,null,h(t)):new u(e,null,t)},e.exports.namedNode=h,e.exports.quad=p,e.exports.triple=function(e,t,n){return p(e,t,n)},e.exports.variable=function(e){return new f(e)},e.exports.collection=function(e){return new i(e)},e.exports.fetcher=function(e,t){return new a(e,t)},e.exports.lit=function(e,t,n){return new u(""+e,t,n)},e.exports.st=function(e,t,n,r){return new l(e,t,n,r)}},function(e,t,n){"use strict";function r(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}var i=n(3),o=function(){function e(t,n,r,o){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.subject=i.fromValue(t),this.predicate=i.fromValue(n),this.object=i.fromValue(r),this.why=o}var t,n,o;return t=e,(n=[{key:"equals",value:function(e){return e.subject.equals(this.subject)&&e.predicate.equals(this.predicate)&&e.object.equals(this.object)&&e.graph.equals(this.graph)}},{key:"substitute",value:function(t){var n=new e(this.subject.substitute(t),this.predicate.substitute(t),this.object.substitute(t),this.why.substitute(t));return console.log("@@@ statement substitute:"+n),n}},{key:"toCanonical",value:function(){var e=[this.subject.toCanonical(),this.predicate.toCanonical(),this.object.toCanonical()];return this.graph&&"DefaultGraph"!==this.graph.termType&&e.push(this.graph.toCanonical()),e.join(" ")+" ."}},{key:"toNT",value:function(){return[this.subject.toNT(),this.predicate.toNT(),this.object.toNT()].join(" ")+" ."}},{key:"toString",value:function(){return this.toNT()}},{key:"graph",get:function(){return this.why},set:function(e){this.why=e}}])&&r(t.prototype,n),o&&r(t,o),e}();e.exports=o},function(e,t,n){"use strict";function r(e){return(r="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})(e)}function i(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function o(e,t){return!t||"object"!==r(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function a(e){return(a=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function s(e,t){return(s=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}var u=n(14),c=n(3),l=n(4),f=function(e){function t(){var e,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),(e=o(this,a(t).call(this))).termType=t.termType,e.value=n,e.base="varid:",e.uri=l.join(n,e.base),e}var n,r,u;return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&s(e,t)}(t,c),n=t,(r=[{key:"equals",value:function(e){return!!e&&(this.termType===e.termType&&this.value===e.value)}},{key:"hashString",value:function(){return this.toString()}},{key:"substitute",value:function(e){var t;return null!=(t=e[this.toNT()])?t:this}},{key:"toString",value:function(){return this.uri.slice(0,this.base.length)===this.base?"?"+this.uri.slice(this.base.length):"?"+this.uri}}])&&i(n.prototype,r),u&&i(n,u),t}();f.termType="Variable",f.prototype.classOrder=u.Variable,f.prototype.isVar=1,e.exports=f},function(e,t,n){"use strict";function r(e){return(r="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})(e)}var i=n(4),o=n(6).ArrayIndexOf,a=function(){var e=function(e){e=e.replace(/\r\n/g,"\n");for(var t="",n=0;n<e.length;n++){var r=e.charCodeAt(n);r<128?t+=String.fromCharCode(r):r>127&&r<2048?(t+=String.fromCharCode(r>>6|192),t+=String.fromCharCode(63&r|128)):(t+=String.fromCharCode(r>>12|224),t+=String.fromCharCode(r>>6&63|128),t+=String.fromCharCode(63&r|128))}return t},t="http://www.w3.org/2000/10/swap/log#",n=function(e){return e},a=function(e){return e},s=function(e){if(e.length>0)throw"missing.js: oops nnonempty dict not imp";return[]},u=function(e){return e.length},c=function(e,t,n){if(void 0===e.slice)throw"@@ mising.js: No .slice function for "+e+" of type "+r(e);return void 0===n||null==n?e.slice(t):e.slice(t,n)},l=Error("dummy error stop iteration"),f=function(e){return this.last=0,this.li=e,this.next=function(){if(this.last==this.li.length)throw l;return this.li[this.last++]},this},h=function(e,t){return e.indexOf(t)},p=function(e,t){if(!e){if(t)throw"python Assertion failed: "+t;throw"(python) Assertion failed."}};String.prototype.encode=function(t){if("utf-8"!=t)throw"UTF8_converter: can only do utf-8";return e(this)},String.prototype.decode=function(e){if("utf-8"!=e)throw"UTF8_converter: can only do utf-8";return this};var d=function(e,t){return i.join(t,e)},y=0;var v="\t\r\n !\"#$%&'()*.,+/;<=>?@[\\]^`{|}~:",g=(new RegExp("^[ \\t]*(#[^\\n]*)?\\r?\\n","g"),new RegExp("^[ \\t]*(#[^\\n]*)?$","g"),new RegExp("^[ \\t]*","g"),new RegExp("^[-+]?[0-9]+","g"),new RegExp("^([-+]?[0-9]+)(\\.[0-9]+)?(e[-+]?[0-9]+)?","g")),m=new RegExp("^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9](T[0-9][0-9]:[0-9][0-9](:[0-9][0-9](\\.[0-9]*)?)?)?Z?"),w=(new RegExp("^[0-9]+","g"),new RegExp('[\\\\\\r\\n\\"]',"g")),b=new RegExp("^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*","g");function x(e,t,n,r,i,o,u,c){void 0===t&&(t=null),void 0===n&&(n=""),void 0===r&&(r=null),void 0===i&&(i=""),void 0===o&&(o=null),void 0===u&&(u=""),void 0===c&&(c=null),this._bindings=new s([]),this._flags=u,""!=n&&(p(n.indexOf(":")>=0,"Document URI not absolute: "+n),this._bindings[""]=n+"#"),this._store=e,i&&e.setGenPrefix(i),this._thisDoc=n,this.source=e.sym(n),this.lines=0,this.statementCount=0,this.startOfLine=0,this.previousLine=0,this._genPrefix=i,this.keywords=new a(["a","this","bind","has","is","of","true","false"]),this.keywordsSet=0,this._anonymousNodes=new s([]),this._variables=new s([]),this._parentVariables=new s([]),this._reason=c,this._reason2=null,y&&(this._reason2=why_BecauseOfData(e.sym(n),this._reason)),this._baseURI=r||(n||null),p(!this._baseURI||this._baseURI.indexOf(":")>=0),this._genPrefix||(this._thisDoc?this._genPrefix=this._thisDoc+"#_g":this._genPrefix=RDFSink_uniqueURI()),null==t?this._thisDoc?this._formula=e.formula(n+"#_formula"):this._formula=e.formula():this._formula=t,this._context=this._formula,this._parentContext=null}function _(e,t,n,r,i){this._str=n.encode("utf-8"),this._str=n,this._i=r,this._why=i,this.lines=t,this._uri=e}function k(e,t,n,r,i){var o=t+1,a="Line "+o+" of <"+e+">: Bad syntax: "+i+'\nat: "'+n.slice(r,r+30)+'"',s=new SyntaxError(a,e,o);return s.lineNo=o,s.characterInFile=r,s.syntaxProblem=i,s}return x.prototype.here=function(e){return this._genPrefix+"_L"+this.lines+"C"+(e-this.startOfLine+1)},x.prototype.formula=function(){return this._formula},x.prototype.loadStream=function(e){return this.loadBuf(e.read())},x.prototype.loadBuf=function(e){return this.startDoc(),this.feed(e),this.endDoc()},x.prototype.feed=function(e){for(var t=e.decode("utf-8"),n=0;n>=0;){var r=this.skipSpace(t,n);if(r<0)return;if((n=this.directiveOrStatement(t,r))<0)throw k(this._thisDoc,this.lines,t,r,"expected directive or statement")}},x.prototype.directiveOrStatement=function(e,t){var n,r=this.skipSpace(e,t);return r<0?r:(n=this.directive(e,r))>=0?this.checkDot(e,n):(n=this.statement(e,r))>=0?this.checkDot(e,n):n},x.prototype.tok=function(e,t,n){if("@"==t.slice(n,n+1))n=n+1;else if(o(this.keywords,e)<0)return-1;var r=n+u(e);return t.slice(n,r)==e&&"\t\r\n !\"#$%&'()*.,+/;<=>?@[\\]^`{|}~".indexOf(t.charAt(r))>=0?r:-1},x.prototype.directive=function(e,t){if((s=this.skipSpace(e,t))<0)return s;var n=new a([]);if((s=this.tok("bind",e,t))>0)throw k(this._thisDoc,this.lines,e,t,"keyword bind is obsolete: use @prefix");if((s=this.tok("keywords",e,t))>0){if((t=this.commaSeparatedList(e,s,n,!1))<0)throw k(this._thisDoc,this.lines,e,t,"'@keywords' needs comma separated list of words");return this.setKeywords(c(n,null,null)),t}if((s=this.tok("forAll",e,t))>0){if((t=this.commaSeparatedList(e,s,n,!0))<0)throw k(this._thisDoc,this.lines,e,t,"Bad variable list after @forAll");var r=new f(n);try{for(;;){var i=r.next();(o(this._variables,i)<0||o(this._parentVariables,i)>=0)&&(this._variables[i]=this._context.newUniversal(i))}}catch(e){if(e!=l)throw e}return t}if((s=this.tok("forSome",e,t))>0){if((t=this.commaSeparatedList(e,s,n,this.uri_ref2))<0)throw k(this._thisDoc,this.lines,e,t,"Bad variable list after @forSome");r=new f(n);try{for(;;){i=r.next();this._context.declareExistential(i)}}catch(e){if(e!=l)throw e}return t}if((s=this.tok("prefix",e,t))>=0){var s,u=new a([]);if((t=this.qname(e,s,u))<0)throw k(this._thisDoc,this.lines,e,s,"expected qname after @prefix");if((s=this.uri_ref2(e,t,u))<0)throw k(this._thisDoc,this.lines,e,t,"expected <uriref> after @prefix _qname_");var h=u[1].uri;if(this._baseURI)h=d(this._baseURI,h);else p(h.indexOf(":")>=0,"With no base URI, cannot handle relative URI for NS");return p(h.indexOf(":")>=0),this._bindings[u[0][0]]=h,this.bind(u[0][0],function(e){return encodeURI(e)}(h)),s}if((s=this.tok("base",e,t))>=0){u=new a([]);if((t=this.uri_ref2(e,s,u))<0)throw k(this._thisDoc,this.lines,e,s,"expected <uri> after @base ");h=u[0].uri;if(!this._baseURI)throw k(this._thisDoc,this.lines,e,s,"With no previous base URI, cannot use relative URI in @base  <"+h+">");h=d(this._baseURI,h);return p(h.indexOf(":")>=0),this._baseURI=h,t}return-1},x.prototype.bind=function(e,t){""==e||this._store.setPrefixForURI(e,t)},x.prototype.setKeywords=function(e){null==e?this.keywordsSet=0:(this.keywords=e,this.keywordsSet=1)},x.prototype.startDoc=function(){},x.prototype.endDoc=function(){return this._formula},x.prototype.makeStatement=function(e){e[0].add(e[2],e[1],e[3],this.source),this.statementCount+=1},x.prototype.statement=function(e,t){var n=new a([]);if((t=this.object(e,t,n))<0)return t;var r=this.property_list(e,t,n[0]);if(r<0)throw k(this._thisDoc,this.lines,e,t,"expected propertylist");return r},x.prototype.subject=function(e,t,n){return this.item(e,t,n)},x.prototype.verb=function(e,r,i){if((s=this.skipSpace(e,r))<0)return s;var o=new a([]);if((s=this.tok("has",e,r))>=0){if((r=this.prop(e,s,o))<0)throw k(this._thisDoc,this.lines,e,s,"expected property after 'has'");return i.push(new n(["->",o[0]])),r}if((s=this.tok("is",e,r))>=0){if((r=this.prop(e,s,o))<0)throw k(this._thisDoc,this.lines,e,s,"expected <property> after 'is'");if((s=this.skipSpace(e,r))<0)throw k(this._thisDoc,this.lines,e,r,"End of file found, expected property after 'is'");var s;r=s;if((s=this.tok("of",e,r))<0)throw k(this._thisDoc,this.lines,e,r,"expected 'of' after 'is' <prop>");return i.push(new n(["<-",o[0]])),s}if((s=this.tok("a",e,r))>=0)return i.push(new n(["->",this._store.sym("http://www.w3.org/1999/02/22-rdf-syntax-ns#type")])),s;if("<="==e.slice(r,r+2))return i.push(new n(["<-",this._store.sym(t+"implies")])),r+2;if("="==e.slice(r,r+1))return">"==e.slice(r+1,r+2)?(i.push(new n(["->",this._store.sym(t+"implies")])),r+2):(i.push(new n(["->",this._store.sym("http://www.w3.org/2002/07/owl#sameAs")])),r+1);if(":="==e.slice(r,r+2))return i.push(new n(["->",t+"becomes"])),r+2;if((s=this.prop(e,r,o))>=0)return i.push(new n(["->",o[0]])),s;if(">-"==e.slice(r,r+2)||"<-"==e.slice(r,r+2))throw k(this._thisDoc,this.lines,e,s,">- ... -> syntax is obsolete.");return-1},x.prototype.prop=function(e,t,n){return this.item(e,t,n)},x.prototype.item=function(e,t,n){return this.path(e,t,n)},x.prototype.blankNode=function(e){return this._context.bnode(e,this._reason2)},x.prototype.path=function(e,t,r){if((a=this.nodeOrLiteral(e,t,r))<0)return a;for(;"!^.".indexOf(e.slice(a,a+1))>=0;){var i=e.slice(a,a+1);if("."==i){var o=e.slice(a+1,a+2);if(!o||v.indexOf(o)>=0&&":?<[{(".indexOf(o)<0)break}var a,s=r.pop(),u=this.blankNode(this.here(a));if((a=this.node(e,a+1,r))<0)throw k(this._thisDoc,this.lines,e,a,"EOF found in middle of path syntax");var c=r.pop();"^"==i?this.makeStatement(new n([this._context,c,u,s])):this.makeStatement(new n([this._context,c,s,u])),r.push(u)}return a},x.prototype.anonymousNode=function(e){if(t=this._anonymousNodes[e])return t;var t=this._store.bnode(e);return this._anonymousNodes[e]=t,t},x.prototype.node=function(e,t,r,i){void 0===i&&(i=null);var o=i;if((v=this.skipSpace(e,t))<0)return v;t=v;var c=e.slice(t,t+1);if("["==c){var h=this.here(t);if((v=this.skipSpace(e,t+1))<0)throw k(this._thisDoc,this.lines,e,t,"EOF after '['");if("="==e.slice(v,v+1)){var t=v+1,p=new a([]);if(!((v=this.objectList(e,t,p))>=0))throw k(this._thisDoc,this.lines,e,t,"objectList expected after [= ");o=p[0];if(u(p)>1){var d=new f(p);try{for(;;){var y=d.next();this.makeStatement(new n([this._context,this._store.sym("http://www.w3.org/2002/07/owl#sameAs"),o,y]))}}catch(e){if(e!=l)throw e}}if((v=this.skipSpace(e,v))<0)throw k(this._thisDoc,this.lines,e,t,"EOF when objectList expected after [ = ");if(";"==e.slice(v,v+1))var v=v+1}if(null==o)o=this.blankNode(h);if((t=this.property_list(e,v,o))<0)throw k(this._thisDoc,this.lines,e,v,"property_list expected");if((v=this.skipSpace(e,t))<0)throw k(this._thisDoc,this.lines,e,t,"EOF when ']' expected after [ <propertyList>");if("]"!=e.slice(v,v+1))throw k(this._thisDoc,this.lines,e,v,"']' expected");return r.push(o),v+1}if("{"==c){if("$"==e.slice(t+1,t+2)){for(var v=(t+=1)+1,g=new a([]),m=!0;;){if((t=this.skipSpace(e,v))<0)throw k(this._thisDoc,this.lines,e,t,"needed '$}', found end.");if("$}"==e.slice(t,t+2)){var v=t+2;break}if(m)m=!1;else{if(","!=e.slice(t,t+1))throw k(this._thisDoc,this.lines,e,t,"expected: ','");t+=1}var w=new a([]);if((v=this.item(e,t,w))<0)throw k(this._thisDoc,this.lines,e,t,"expected item in set or '$}'");g.push(w[0])}return r.push(this._store.newSet(g,this._context)),v}var v=t+1,b=this._parentContext;this._parentContext=this._context;var x=this._anonymousNodes,_=this._parentVariables;this._parentVariables=this._variables,this._anonymousNodes=new s([]),this._variables=this._variables.slice();var S=this._reason2;if(this._reason2=null,null==o)o=this._store.formula();for(this._context=o;;){if((t=this.skipSpace(e,v))<0)throw k(this._thisDoc,this.lines,e,t,"needed '}', found end.");if("}"==e.slice(t,t+1)){var v=t+1;break}if((v=this.directiveOrStatement(e,t))<0)throw k(this._thisDoc,this.lines,e,t,"expected statement or '}'")}return this._anonymousNodes=x,this._variables=this._parentVariables,this._parentVariables=_,this._context=this._parentContext,this._reason2=S,this._parentContext=b,r.push(o.close()),v}if("("==c){var T=this._store.list;if("$"==e.slice(t+1,t+2)){T=this._store.newSet;t+=1}for(v=t+1,g=new a([]);;){if((t=this.skipSpace(e,v))<0)throw k(this._thisDoc,this.lines,e,t,"needed ')', found end.");if(")"==e.slice(t,t+1)){v=t+1;break}w=new a([]);if((v=this.item(e,t,w))<0)throw k(this._thisDoc,this.lines,e,t,"expected item in list or ')'");g.push(w[0])}return r.push(T(g,this._context)),v}if((v=this.tok("this",e,t))>=0)throw k(this._thisDoc,this.lines,e,t,"Keyword 'this' was ancient N3. Now use @forSome and @forAll keywords.");if((v=this.tok("true",e,t))>=0)return r.push(!0),v;if((v=this.tok("false",e,t))>=0)return r.push(!1),v;if(null==o&&(v=this.uri_ref2(e,t,r))>=0)return v;return-1},x.prototype.property_list=function(e,t,r){for(;;){if((d=this.skipSpace(e,t))<0)throw k(this._thisDoc,this.lines,e,t,"EOF found when expected verb in property list");if(":-"!=e.slice(d,d+2)){t=d;var i=new a([]);if((d=this.verb(e,t,i))<=0)return t;var o=new a([]);if((t=this.objectList(e,d,o))<0)throw k(this._thisDoc,this.lines,e,d,"objectList expected");var s=new f(o);try{for(;;){var u=s.next(),c=i[0],h=c[0],p=c[1];"->"==h?this.makeStatement(new n([this._context,p,r,u])):this.makeStatement(new n([this._context,p,u,r]))}}catch(e){if(e!=l)throw e}if((d=this.skipSpace(e,t))<0)throw k(this._thisDoc,this.lines,e,d,"EOF found in list of objects");if(";"!=e.slice(t,t+1))return t;t=t+1}else{var d,t=d+2,y=new a([]);if((d=this.node(e,t,y,r))<0)throw k(this._thisDoc,this.lines,e,t,"bad {} or () or [] node after :- ");var t=d}}},x.prototype.commaSeparatedList=function(e,t,n,r){if((i=this.skipSpace(e,t))<0)throw k(this._thisDoc,this.lines,e,i,"EOF found expecting comma sep list");if("."==e.charAt(i))return t;if(r)var i=this.uri_ref2(e,i,n);else i=this.bareWord(e,i,n);if(i<0)return-1;for(;;){if((t=this.skipSpace(e,i))<0)return t;var o=e.slice(t,t+1);if(","!=o)return"."!=o?-1:t;if(r)i=this.uri_ref2(e,t+1,n);else i=this.bareWord(e,t+1,n);if(i<0)throw k(this._thisDoc,this.lines,e,i,"bad list content")}},x.prototype.objectList=function(e,t,n){if((t=this.object(e,t,n))<0)return-1;for(;;){var r=this.skipSpace(e,t);if(r<0)throw k(this._thisDoc,this.lines,e,r,"EOF found after object");if(","!=e.slice(r,r+1))return r;if((t=this.object(e,r+1,n))<0)return t}},x.prototype.checkDot=function(e,t){var n=this.skipSpace(e,t);if(n<0)return n;if("."==e.slice(n,n+1))return n+1;if("}"==e.slice(n,n+1))return n;if("]"==e.slice(n,n+1))return n;throw k(this._thisDoc,this.lines,e,n,"expected '.' or '}' or ']' at end of statement")},x.prototype.uri_ref2=function(e,t,n){var r=new a([]);if((m=this.qname(e,t,r))>=0){var i=r[0],s=i[0],l=i[1];if(null==s){p(0,"not used?");var f=this._baseURI+"#"}else{if(!(f=this._bindings[s])){if("_"==s)return n.push(this.anonymousNode(l)),m;throw k(this._thisDoc,this.lines,e,t,"Prefix "+s+" not bound.")}}var h=this._store.sym(f+l);return o(this._variables,h)>=0?n.push(this._variables[h]):n.push(h),m}if((t=this.skipSpace(e,t))<0)return-1;if("?"==e.charAt(t)){var y=new a([]);return(m=this.variable(e,t,y))>0?(n.push(y[0]),m):-1}if("<"==e.charAt(t)){for(var v=t=t+1;t<u(e);){if(">"==e.charAt(t)){var g=e.slice(v,t);if(this._baseURI)g=d(this._baseURI,g);else p(g.indexOf(":")>=0,"With no base URI, cannot deal with relative URIs");if("#"==e.slice(t-1,t)&&"#"!=c(g,-1,null))g=g+"#";h=this._store.sym(g);return o(this._variables,h)>=0?n.push(this._variables[h]):n.push(h),t+1}t=t+1}throw k(this._thisDoc,this.lines,e,m,"unterminated URI reference")}if(this.keywordsSet){var m;y=new a([]);if((m=this.bareWord(e,t,y))<0)return-1;if(o(this.keywords,y[0])>=0)throw k(this._thisDoc,this.lines,e,t,'Keyword "'+y[0]+'" not allowed here.');return n.push(this._store.sym(this._bindings[""]+y[0])),m}return-1},x.prototype.skipSpace=function(e,t){for(var n=t||0;n<e.length;n++){var r=e.charAt(n);if(" \n\r\t\f\v            ​\u2028\u2029　".indexOf(r)<0){if("#"!==e.charAt(n))return n;for(;;n++){if(n===e.length)return-1;if("\n"===e.charAt(n)){this.lines=this.lines+1;break}}}else"\n"===e.charAt(n)&&(this.lines=this.lines+1)}return-1},x.prototype.variable=function(e,t,n){if((r=this.skipSpace(e,t))<0)return-1;if("?"!=e.slice(r,r+1))return-1;var r;t=r+=1;if("0123456789-".indexOf(e.charAt(r))>=0)throw k(this._thisDoc,this.lines,e,r,"Varible name can't start with '"+e.charAt(r)+"s'");for(;t<u(e)&&v.indexOf(e.charAt(t))<0;)t=t+1;if(null==this._parentContext)throw k(this._thisDoc,this.lines,e,r,"Can't use ?xxx syntax for variable in outermost level: "+e.slice(r-1,t));return n.push(this._store.variable(e.slice(r,t))),t},x.prototype.bareWord=function(e,t,n){var r=this.skipSpace(e,t);if(r<0)return-1;var i=e.charAt(r);if("0123456789-".indexOf(i)>=0)return-1;if(v.indexOf(i)>=0)return-1;for(t=r;t<u(e)&&v.indexOf(e.charAt(t))<0;)t=t+1;return n.push(e.slice(r,t)),t},x.prototype.qname=function(e,t,r){if((t=this.skipSpace(e,t))<0)return-1;var i=e.charAt(t);if("0123456789-+".indexOf(i)>=0)return-1;if(v.indexOf(i)<0){var a=i;for(t=t+1;t<u(e);){i=e.charAt(t);if(!(v.indexOf(i)<0))break;a=a+i,t=t+1}}else a="";if(t<u(e)&&":"==e.charAt(t)){var s=a;for(t=t+1,a="";t<u(e);){i=e.charAt(t);if(!(v.indexOf(i)<0))break;a=a+i,t=t+1}return r.push(new n([s,a])),t}return a&&this.keywordsSet&&o(this.keywords,a)<0?(r.push(new n(["",a])),t):-1},x.prototype.object=function(e,t,n){if((a=this.subject(e,t,n))>=0)return a;if((a=this.skipSpace(e,t))<0)return-1;t=a;var r=null,i=e.charAt(t);if('"'==i||"'"==i){r=e.slice(t,t+3==i+i)?i+i+i:i;t=t+u(r);var o=this.strconst(e,t,r),a=o[0],s=o[1];return n.push(this._store.literal(s)),a}return-1},x.prototype.nodeOrLiteral=function(e,t,n){if((l=this.node(e,t,n))>=0)return l;if((l=this.skipSpace(e,t))<0)return-1;t=l;var r=e.charAt(t);if("-+0987654321".indexOf(r)>=0){if(m.lastIndex=0,null!=(p=m.exec(e.slice(t)))){l=t+(i=p[0]).length,i.indexOf("T")>=0?n.push(this._store.literal(i,void 0,this._store.sym("http://www.w3.org/2001/XMLSchema#dateTime"))):n.push(this._store.literal(i,void 0,this._store.sym("http://www.w3.org/2001/XMLSchema#date")))}else{var i;if(g.lastIndex=0,null==(p=g.exec(e.slice(t))))throw k(this._thisDoc,this.lines,e,t,"Bad number or date syntax");l=t+g.lastIndex,(i=e.slice(t,l)).indexOf("e")>=0?n.push(this._store.literal(parseFloat(i),void 0,this._store.sym("http://www.w3.org/2001/XMLSchema#double"))):e.slice(t,l).indexOf(".")>=0?n.push(this._store.literal(parseFloat(i),void 0,this._store.sym("http://www.w3.org/2001/XMLSchema#decimal"))):n.push(this._store.literal(parseInt(i),void 0,this._store.sym("http://www.w3.org/2001/XMLSchema#integer")))}return l}if('"'==e.charAt(t)){if('"""'==e.slice(t,t+3))var o='"""';else o='"';t=t+u(o);var s=null,c=this.strconst(e,t,o),l=c[0],f=c[1],h=null;if("@"==e.slice(l,l+1)){var p;if(b.lastIndex=0,null==(p=b.exec(e.slice(l+1))))throw k(this._thisDoc,startline,e,t,"Bad language code syntax on string literal, after @");t=b.lastIndex+l+1,h=e.slice(l+1,t),l=t}if("^^"==e.slice(l,l+2)){var d=new a([]);l=this.uri_ref2(e,l+2,d),s=d[0]}return n.push(this._store.literal(f,h,s)),l}return-1},x.prototype.strconst=function(e,t,r){for(var i=t,o="",a=this.lines;i<u(e);){t=i+u(r);if(e.slice(i,t)==r)return new n([t,o]);if('"'!=e.charAt(i)){if(w.lastIndex=0,!w.exec(e.slice(i)))throw k(this._thisDoc,a,e,i,"Closing quote missing in string at ^ in "+e.slice(i-20,i)+"^"+e.slice(i,i+20));t=i+w.lastIndex-1,o=o+e.slice(i,t);if('"'!=(l=e.charAt(t)))if("\r"!=l){if("\n"==l){if('"'==r)throw k(this._thisDoc,a,e,t,"newline found in string literal");this.lines=this.lines+1;o=o+l,i=t+1;this.previousLine=this.startOfLine,this.startOfLine=i}else if("\\"==l){i=t+1;if(!(l=e.slice(i,i+1)))throw k(this._thisDoc,a,e,t,"unterminated string literal (2)");var s=h('abfrtvn\\"',l);if(s>=0)o=o+'a\b\f\r\t\v\n\\"'.charAt(s),i=i+1;else if("u"==l)i=(c=this.uEscape(e,i+1,a))[0],o=o+(l=c[1]);else{if("U"!=l)throw k(this._thisDoc,this.lines,e,t,"bad escape");var c,l;i=(c=this.UEscape(e,i+1,a))[0],o=o+(l=c[1])}}}else var i=t+1;else var i=t}else var o=o+'"',i=i+1}throw k(this._thisDoc,this.lines,e,t,"unterminated string literal")},x.prototype.uEscape=function(e,t,r){for(var i=t,o=0,a=0;o<4;){var s=e.slice(i,i+1).toLowerCase();i=i+1;if(""==s)throw k(this._thisDoc,r,e,t,"unterminated string literal(3)");var u=h("0123456789abcdef",s);if(u<0)throw k(this._thisDoc,r,e,t,"bad string literal hex escape");a=16*a+u,o=o+1}var c=String.fromCharCode(a);return new n([i,c])},x.prototype.UEscape=function(e,t,r){for(var i=t,o=0,a="\\U";o<8;){var s=e.slice(i,i+1).toLowerCase();i=i+1;if(""==s)throw k(this._thisDoc,r,e,t,"unterminated string literal(3)");if(h("0123456789abcdef",s)<0)throw k(this._thisDoc,r,e,t,"bad string literal hex escape");a=a+s,o=o+1}var u,l=(u="0x"+c(a,2,10)-0,String.fromCharCode(u));return new n([i,l])},_.prototype.toString=function(){var e=this._str,t=this._i,r=0;if(t>60){var i="...";r=t-60}else i="";if(u(e)-t>60)var o="...";else o="";return'Line %i of <%s>: Bad syntax (%s) at ^ in:\n"%s%s^%s%s"'%new n([this.lines+1,this._uri,this._why,i,e.slice(r,t),e.slice(t,t+60),o])},function(e,t,n,r,i,o,a,s){return new x(e,t,n,r,i,o,a,s)}}();e.exports=a},function(e,t){e.exports=function(e){var t={};function n(r){if(t[r])return t[r].exports;var i=t[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)n.d(r,i,function(t){return e[t]}.bind(null,i));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=0)}([function(e,t,n){"use strict";n.r(t);var r=n(1);const i=new r.default;if(t.default=i,Object.getOwnPropertyNames(r.default.prototype).forEach(e=>{const t=i[e];"function"==typeof t&&(i[e]=t.bind(i))}),"undefined"!=typeof window)if("SolidAuthClient"in window)console.warn("Caution: multiple versions of solid-auth-client active.");else{let e=!1;Object.defineProperty(window,"SolidAuthClient",{enumerable:!0,get:()=>(e||(e=!0,console.warn("window.SolidAuthClient has been deprecated."),console.warn("Please use window.solid.auth instead.")),i)})}},function(e,t,n){"use strict";n.r(t),n.d(t,"default",function(){return v});var r=n(2),i=n.n(r),o=n(3),a=n.n(o),s=n(4),u=n.n(s),c=n(5),l=n(81),f=n(9),h=n(10),p=n(7),d=n(12);const y=fetch;class v extends u.a{constructor(...e){super(...e),a()(this,"_pendingSession",void 0)}fetch(e,t){return this.emit("request",Object(p.toUrlString)(e)),Object(c.authnFetch)(Object(h.defaultStorage)(),y,e,t)}login(e,t){return t=i()({},g(Object(p.currentUrlNoParams)()),t),d.login(e,t)}async popupLogin(e){e=i()({},g(),e),/https?:/.test(e.popupUri)||(e.popupUri=new URL(e.popupUri||"/.well-known/solid/login",window.location).toString()),e.callbackUri||(e.callbackUri=e.popupUri);const t=Object(l.openIdpPopup)(e.popupUri),n=await Object(l.obtainSession)(e.storage,t,e);return this.emit("login",n),this.emit("session",n),n}async currentSession(e=Object(h.defaultStorage)()){let t=this._pendingSession||await Object(f.getSession)(e);if(!t){try{this._pendingSession=d.currentSession(e),t=await this._pendingSession}catch(e){console.error(e)}t&&(await Object(f.saveSession)(e)(t),this.emit("login",t),this.emit("session",t)),delete this._pendingSession}return t}async trackSession(e){e(await this.currentSession()),this.on("session",e)}async logout(e=Object(h.defaultStorage)()){if(await Object(f.getSession)(e)){try{await d.logout(e,y),this.emit("logout"),this.emit("session",null)}catch(e){console.warn("Error logging out:"),console.error(e)}await Object(f.clearSession)(e)}}}function g(e){return{callbackUri:e?e.split("#")[0]:"",popupUri:"",storage:Object(h.defaultStorage)()}}},function(e,t,n){var r=n(3);e.exports=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},i=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(i=i.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),i.forEach(function(t){r(e,t,n[t])})}return e}},function(e,t){e.exports=function(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}},function(e,t){function n(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}function r(e){return"function"==typeof e}function i(e){return"object"==typeof e&&null!==e}function o(e){return void 0===e}e.exports=n,n.EventEmitter=n,n.prototype._events=void 0,n.prototype._maxListeners=void 0,n.defaultMaxListeners=10,n.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||isNaN(e))throw TypeError("n must be a positive number");return this._maxListeners=e,this},n.prototype.emit=function(e){var t,n,a,s,u,c;if(this._events||(this._events={}),"error"===e&&(!this._events.error||i(this._events.error)&&!this._events.error.length)){if((t=arguments[1])instanceof Error)throw t;var l=new Error('Uncaught, unspecified "error" event. ('+t+")");throw l.context=t,l}if(o(n=this._events[e]))return!1;if(r(n))switch(arguments.length){case 1:n.call(this);break;case 2:n.call(this,arguments[1]);break;case 3:n.call(this,arguments[1],arguments[2]);break;default:s=Array.prototype.slice.call(arguments,1),n.apply(this,s)}else if(i(n))for(s=Array.prototype.slice.call(arguments,1),a=(c=n.slice()).length,u=0;u<a;u++)c[u].apply(this,s);return!0},n.prototype.addListener=function(e,t){var a;if(!r(t))throw TypeError("listener must be a function");return this._events||(this._events={}),this._events.newListener&&this.emit("newListener",e,r(t.listener)?t.listener:t),this._events[e]?i(this._events[e])?this._events[e].push(t):this._events[e]=[this._events[e],t]:this._events[e]=t,i(this._events[e])&&!this._events[e].warned&&(a=o(this._maxListeners)?n.defaultMaxListeners:this._maxListeners)&&a>0&&this._events[e].length>a&&(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},n.prototype.on=n.prototype.addListener,n.prototype.once=function(e,t){if(!r(t))throw TypeError("listener must be a function");var n=!1;function i(){this.removeListener(e,i),n||(n=!0,t.apply(this,arguments))}return i.listener=t,this.on(e,i),this},n.prototype.removeListener=function(e,t){var n,o,a,s;if(!r(t))throw TypeError("listener must be a function");if(!this._events||!this._events[e])return this;if(a=(n=this._events[e]).length,o=-1,n===t||r(n.listener)&&n.listener===t)delete this._events[e],this._events.removeListener&&this.emit("removeListener",e,t);else if(i(n)){for(s=a;s-- >0;)if(n[s]===t||n[s].listener&&n[s].listener===t){o=s;break}if(o<0)return this;1===n.length?(n.length=0,delete this._events[e]):n.splice(o,1),this._events.removeListener&&this.emit("removeListener",e,t)}return this},n.prototype.removeAllListeners=function(e){var t,n;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(r(n=this._events[e]))this.removeListener(e,n);else if(n)for(;n.length;)this.removeListener(e,n[n.length-1]);return delete this._events[e],this},n.prototype.listeners=function(e){return this._events&&this._events[e]?r(this._events[e])?[this._events[e]]:this._events[e].slice():[]},n.prototype.listenerCount=function(e){if(this._events){var t=this._events[e];if(r(t))return 1;if(t)return t.length}return 0},n.listenerCount=function(e,t){return e.listenerCount(t)}},function(e,t,n){"use strict";n.r(t),n.d(t,"authnFetch",function(){return s});n(6);var r=n(7),i=n(8),o=n(9),a=n(12);async function s(e,t,n,r){const s=await Object(o.getSession)(e);if(!s)return t(n,r);if(await u(e,n))return Object(a.fetchWithCredentials)(s,t,n,r);let c=await t(n,r);return 401===c.status&&(await Object(i.updateHostFromResponse)(e)(c),await u(e,n)&&(c=Object(a.fetchWithCredentials)(s,t,n,r))),c}async function u(e,t){const n=await Object(i.getHost)(e)(Object(r.toUrlString)(t));return null!=n&&n.requiresAuth}},function(e,t){e.exports=window.fetch},function(e,t,n){"use strict";n.r(t),n.d(t,"currentUrl",function(){return r}),n.d(t,"currentUrlNoParams",function(){return i}),n.d(t,"navigateTo",function(){return o}),n.d(t,"originOf",function(){return a}),n.d(t,"toUrlString",function(){return s});const r=()=>window.location.href,i=()=>window.location.origin+window.location.pathname,o=e=>{window.location.href=e},a=e=>new URL(e).origin,s=e=>("string"!=typeof e&&(e="url"in e?e.url:e.toString()),new URL(e,r()).toString())},function(e,t,n){"use strict";n.r(t),n.d(t,"getHost",function(){return u}),n.d(t,"saveHost",function(){return c}),n.d(t,"updateHostFromResponse",function(){return l});var r=n(2),i=n.n(r),o=n(9),a=n(10),s=n(12);function u(e){return async t=>{const n=new URL(t).host,r=await Object(o.getSession)(e);if(r&&n===new URL(r.idp).host)return{url:n,requiresAuth:!0};const i=(await Object(a.getData)(e)).hosts;return i&&i[n]}}function c(e){return async({url:t,requiresAuth:n})=>{await Object(a.updateStorage)(e,e=>i()({},e,{hosts:i()({},e.hosts,{[t]:{requiresAuth:n}})}))}}function l(e){return async t=>{if(s.requiresAuth(t)){const n=new URL(t.url).host;await c(e)({url:n,requiresAuth:!0})}}}},function(e,t,n){"use strict";n.r(t),n.d(t,"getSession",function(){return a}),n.d(t,"saveSession",function(){return s}),n.d(t,"clearSession",function(){return u});var r=n(2),i=n.n(r),o=n(10);async function a(e){return(await Object(o.getData)(e)).session||null}function s(e){return async t=>{return(await Object(o.updateStorage)(e,e=>i()({},e,{session:t}))).session}}async function u(e){await Object(o.updateStorage)(e,e=>i()({},e,{session:null}))}},function(e,t,n){"use strict";n.r(t),n.d(t,"NAMESPACE",function(){return r}),n.d(t,"defaultStorage",function(){return i}),n.d(t,"getData",function(){return o}),n.d(t,"updateStorage",function(){return a}),n.d(t,"asyncStorage",function(){return s}),n.d(t,"memStorage",function(){return u}),n.d(t,"ipcStorage",function(){return c});n(11);const r="solid-auth-client",i=()=>{try{if(window&&window.localStorage)return s(window.localStorage)}catch(e){if(!(e instanceof ReferenceError))throw e}return console.warn("'window.localStorage' unavailable.  Creating a (not very useful) in-memory storage object as the default storage interface."),s(u())};async function o(e){let t,n;try{t=await e.getItem(r),n=JSON.parse(t||"{}")}catch(e){console.warn("Could not deserialize data:",t),console.error(e),n={}}return n}async function a(e,t){const n=t(await o(e));return await e.setItem(r,JSON.stringify(n)),n}function s(e){return{getItem:t=>Promise.resolve(e.getItem(t)),setItem:(t,n)=>Promise.resolve(e.setItem(t,n)),removeItem:t=>Promise.resolve(e.removeItem(t))}}const u=()=>{const e={};return{getItem:t=>void 0===e[t]?null:e[t],setItem:(t,n)=>{e[t]=n},removeItem:t=>{delete e[t]}}};function c(e){return{getItem:t=>e.request("storage/getItem",t),setItem:(t,n)=>e.request("storage/setItem",t,n),removeItem:t=>e.request("storage/removeItem",t)}}},function(e,t,n){"use strict";n.r(t),n.d(t,"Server",function(){return a}),n.d(t,"Client",function(){return s});var r=n(3),i=n.n(r);const o="solid-auth-client";class a{constructor(e,t,n){i()(this,"_clientWindow",void 0),i()(this,"_clientOrigin",void 0),i()(this,"_handler",void 0),i()(this,"_messageListener",void 0),this._clientWindow=e,this._clientOrigin=t,this._handler=n,this._messageListener=(e=>this._handleMessage(e))}async _handleMessage({data:e,origin:t}){if(t!==this._clientOrigin)return void console.warn(`solid-auth-client is listening to ${this._clientOrigin} `+`so ignored a message received from ${t}.`);const n=e&&e[o];if(n&&n.method){const e=n,t=e.id,r=e.method,i=e.args,a=await this._handler(r,...i);this._clientWindow.postMessage({[o]:{id:t,ret:a}},this._clientOrigin)}}start(){window.addEventListener("message",this._messageListener)}stop(){window.removeEventListener("message",this._messageListener)}}class s{constructor(e,t){i()(this,"_serverWindow",void 0),i()(this,"_serverOrigin",void 0),this._serverWindow=e,this._serverOrigin=t}request(e,...t){const n=Math.random();return this._serverWindow.postMessage({[o]:{id:n,method:e,args:t}},this._serverOrigin),new Promise((e,t)=>{window.addEventListener("message",i);const r=setTimeout(()=>{t(new Error("Could not connect to main window.")),window.removeEventListener("message",i)},2e3);function i({data:t}){const a=t&&t[o];a&&a.id===n&&a.hasOwnProperty("ret")&&(e(a.ret),clearTimeout(r),window.removeEventListener("message",i))}})}}},function(e,t,n){"use strict";n.r(t),n.d(t,"login",function(){return d}),n.d(t,"currentSession",function(){return y}),n.d(t,"logout",function(){return v}),n.d(t,"getRegisteredRp",function(){return g}),n.d(t,"requiresAuth",function(){return w}),n.d(t,"fetchWithCredentials",function(){return b});var r=n(13),i=n.n(r),o=n(2),a=n.n(o),s=n(15),u=n(19),c=n.n(u),l=n(80),f=n.n(l),h=n(7),p=n(10);async function d(e,t){try{const n=await g(e,t);return await async function(e){await Object(p.updateStorage)(e,e=>a()({},e,{appHashFragment:window.location.hash}))}(t.storage),async function(e,{callbackUri:t,storage:n}){const r=await Object(p.getData)(n),i=await e.createRequest({redirect_uri:t},r);return await Object(p.updateStorage)(n,()=>r),Object(h.navigateTo)(i)}(n,t)}catch(e){return console.warn("Error logging in with WebID-OIDC"),console.error(e),null}}async function y(e=Object(p.defaultStorage)()){try{const t=await m(e);if(!t)return null;const n=Object(h.currentUrl)();if(!/#(.*&)?access_token=/.test(n))return null;window.location.hash="",await async function(e){await Object(p.updateStorage)(e,e=>{let t=e.appHashFragment,n=void 0===t?"":t,r=i()(e,["appHashFragment"]);return window.location.hash=n,r})}(e);const r=await Object(p.getData)(e),o=await t.validateResponse(n,r);return o?a()({},o,{webId:o.idClaims.sub,idp:o.issuer}):null}catch(e){return console.warn("Error finding a WebID-OIDC session"),console.error(e),null}}async function v(e,t){const n=await m(e);if(n)try{await n.logout();try{await t("/.well-known/solid/logout",{credentials:"include"})}catch(e){}}catch(e){console.warn("Error logging out of the WebID-OIDC session"),console.error(e)}}async function g(e,t){let n=await m(t.storage);return n&&n.provider.url===e&&n.registration.redirect_uris.includes(t.callbackUri)||(n=await function(e,{storage:t,callbackUri:n}){const r={issuer:e,grant_types:["implicit"],redirect_uris:[n],response_types:["id_token token"],scope:"openid profile"},i={defaults:{authenticate:{redirect_uri:n,response_type:"id_token token"}},store:t};return c.a.register(e,r,i)}(e,t),await async function(e,t,n){return await Object(p.updateStorage)(e,e=>a()({},e,{rpConfig:n})),n}(t.storage,0,n)),n}async function m(e){const t=(await Object(p.getData)(e)).rpConfig;return t?(t.store=e,c.a.from(t)):null}function w(e){if(401!==e.status)return!1;const t=e.headers.get("www-authenticate");if(!t)return!1;const n=s.parse(t);return"Bearer"===n.scheme&&n.params&&"openid webid"===n.params.scope}async function b(e,t,n,r){const i=await f.a.issueFor(Object(h.toUrlString)(n),e);return t(n,a()({},r,{credentials:"include",headers:a()({},r&&r.headers?r.headers:{},{authorization:`Bearer ${i}`})}))}},function(e,t,n){var r=n(14);e.exports=function(e,t){if(null==e)return{};var n,i,o=r(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(i=0;i<a.length;i++)n=a[i],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}},function(e,t){e.exports=function(e,t){if(null==e)return{};var n,r,i={},o=Object.keys(e);for(r=0;r<o.length;r++)n=o[r],t.indexOf(n)>=0||(i[n]=e[n]);return i}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"format",{enumerable:!0,get:function(){return r.default}}),Object.defineProperty(t,"parse",{enumerable:!0,get:function(){return i.default}});var r=o(n(16)),i=o(n(18));function o(e){return e&&e.__esModule?e:{default:e}}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var r=n(17);function i(e){return function(e){if(Array.isArray(e)){for(var t=0,n=new Array(e.length);t<e.length;t++)n[t]=e[t];return n}}(e)||function(e){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e))return Array.from(e)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}()}function o(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=[],r=!0,i=!1,o=void 0;try{for(var a,s=e[Symbol.iterator]();!(r=(a=s.next()).done)&&(n.push(a.value),!t||n.length!==t);r=!0);}catch(e){i=!0,o=e}finally{try{r||null==s.return||s.return()}finally{if(i)throw o}}return n}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}var a=function(e){return e.reduce(function(e,t){var n=o(t,2),a=n[0],s=n[1],u=function(e){return function(t){return`${e}=${t&&!(0,r.isToken)(t)?(0,r.quote)(t):t}`}}(a);if(!(0,r.isToken)(a))throw new TypeError;return Array.isArray(s)?i(e).concat(i(s.map(u))):i(e).concat([u(s)])},[])};t.default=function(e,t,n){var o="string"==typeof e?{scheme:e,token:t,params:n}:e;if("object"!=typeof o)throw new TypeError;if(!(0,r.isScheme)(o.scheme))throw new TypeError("Invalid scheme.");return[o.scheme].concat(i(void 0!==o.token?[o.token]:[]),i(void 0!==o.params?function e(t,n){if(Array.isArray(t))return a(t);if("object"==typeof t){var r=t;return e(Object.keys(t).map(function(e){return[e,r[e]]}),n)}throw new TypeError}(o.params):[])).join(" ")}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.unquote=t.quote=t.isScheme=t.isToken=void 0;var r=/^[^\u0000-\u001F\u007F()<>@,;:\\"\/?={}\[\]\u0020\u0009]+$/,i=function(e){return"string"==typeof e&&r.test(e)};t.isToken=i;var o=i;t.isScheme=o;t.quote=function(e){return`"${e.replace(/"/g,'\\"')}"`};t.unquote=function(e){return e.substr(1,e.length-2).replace(/\\"/g,'"')}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var r=n(17),i=/((?:[a-zA-Z0-9._~+\/-]+=*(?:\s+|$))|[^\u0000-\u001F\u007F()<>@,;:\\"\/?={}\[\]\u0020\u0009]+)(?:=([^\\"=\s,]+|"(?:[^"\\]|\\.)*"))?/g,o=function(e,t){var n='"'===t.charAt(0)?(0,r.unquote)(t):t.trim();return Array.isArray(e)?e.concat(n):"string"==typeof e?[e,n]:n};t.default=function(e){if("string"!=typeof e)throw new TypeError("Header value must be a string.");var t=e.indexOf(" "),n=e.substr(0,t);if(!(0,r.isScheme)(n))throw new TypeError(`Invalid scheme ${n}`);return function(e,t){for(var n=null,r={};;){var a=i.exec(t);if(null===a)break;a[2]?r[a[1]]=o(r[a[1]],a[2]):n=o(n,a[1])}return{scheme:e,params:r,token:n}}(n,e.substr(t))}},function(e,t,n){"use strict";e.exports=n(20)},function(e,t,n){(function(t){const r=n(22),i=n(6),{URL:o}=n(27),a=i.Headers?i.Headers:t.Headers,{JSONDocument:s}=n(28),{JWKSet:u}=n(37),c=n(68),l=n(70),f=n(79),h=n(74),p=n(69);class d extends s{static get schema(){return f}static from(e){let t=new d(e),n=t.validate();if(!n.valid)return Promise.reject(new Error(JSON.stringify(n)));let r=t.provider.jwks;return r?u.importKeys(r).then(e=>(t.provider.jwks=e,t)):t.jwks().then(()=>t)}static register(e,t,n){let r=new d({provider:{url:e},defaults:Object.assign({},n.defaults),store:n.store});return Promise.resolve().then(()=>r.discover()).then(()=>r.jwks()).then(()=>r.register(t)).then(()=>r)}discover(){try{let e=this.provider.url;r(e,'RelyingParty provider must define "url"');let t=new o(e);return t.pathname=".well-known/openid-configuration",i(t.toString()).then(h("Error fetching openid configuration")).then(e=>e.json().then(e=>this.provider.configuration=e))}catch(e){return Promise.reject(e)}}register(e){try{let t=this.provider.configuration;r(t,"OpenID Configuration is not initialized."),r(t.registration_endpoint,"OpenID Configuration is missing registration_endpoint.");let n=t.registration_endpoint,o="post",s=new a({"Content-Type":"application/json"}),u=this.defaults.register,c=JSON.stringify(Object.assign({},u,e));return i(n,{method:o,headers:s,body:c}).then(h("Error registering client")).then(e=>e.json().then(e=>this.registration=e))}catch(e){return Promise.reject(e)}}serialize(){return JSON.stringify(this)}jwks(){try{let e=this.provider.configuration;r(e,"OpenID Configuration is not initialized."),r(e.jwks_uri,"OpenID Configuration is missing jwks_uri.");let t=e.jwks_uri;return i(t).then(h("Error resolving provider keys")).then(e=>e.json().then(e=>u.importKeys(e)).then(e=>this.provider.jwks=e))}catch(e){return Promise.reject(e)}}createRequest(e,t){return c.create(this,e,t||this.store)}validateResponse(e,t=this.store){let n;n=e.match(/^http(s?):\/\//)?{rp:this,redirect:e,session:t}:{rp:this,body:e,session:t};const r=new l(n);return l.validateResponse(r)}userinfo(){try{let e=this.provider.configuration;r(e,"OpenID Configuration is not initialized."),r(e.userinfo_endpoint,"OpenID Configuration is missing userinfo_endpoint.");let t=e.userinfo_endpoint,n=this.store.access_token;r(n,"Missing access token.");let o=new a({"Content-Type":"application/json",Authorization:`Bearer ${n}`});return i(t,{headers:o}).then(h("Error fetching userinfo")).then(e=>e.json())}catch(e){return Promise.reject(e)}}logoutRequest(e={}){const{id_token_hint:t,post_logout_redirect_uri:n,state:i}=e;let a;if(r(this.provider,"OpenID Configuration is not initialized"),a=this.provider.configuration,r(a,"OpenID Configuration is not initialized"),!a.end_session_endpoint)return console.log("OpenId Configuration for "+`${a.issuer} is missing end_session_endpoint`),null;if(n&&!t)throw new Error("id_token_hint is required when using post_logout_redirect_uri");const s={};t&&(s.id_token_hint=t),n&&(s.post_logout_redirect_uri=n),i&&(s.state=i);const u=new o(a.end_session_endpoint);return u.search=p.encode(s),u.href}logout(){let e;try{r(this.provider,"OpenID Configuration is not initialized."),e=this.provider.configuration,r(e,"OpenID Configuration is not initialized."),r(e.end_session_endpoint,"OpenID Configuration is missing end_session_endpoint.")}catch(e){return Promise.reject(e)}if(!e.end_session_endpoint)return this.clearSession(),Promise.resolve(void 0);let t=e.end_session_endpoint;return i(t,{method:"get",credentials:"include"}).then(h("Error logging out")).then(()=>this.clearSession())}clearSession(){let e=this.store;e&&delete e[y]}popTokenFor(e,t){return PoPToken.issueFor(e,t)}}const y="oidc.session.privateKey";d.SESSION_PRIVATE_KEY=y,e.exports=d}).call(this,n(21))},function(e,t){var n;n=function(){return this}();try{n=n||Function("return this")()||(0,eval)("this")}catch(e){"object"==typeof window&&(n=window)}e.exports=n},function(e,t,n){"use strict";(function(t){
  /*!
   * The buffer module from node.js, for the browser.
   *
   * @author   Feross Aboukhadijeh <feross@feross.org> <http://feross.org>
   * @license  MIT
   */
  function r(e,t){if(e===t)return 0;for(var n=e.length,r=t.length,i=0,o=Math.min(n,r);i<o;++i)if(e[i]!==t[i]){n=e[i],r=t[i];break}return n<r?-1:r<n?1:0}function i(e){return t.Buffer&&"function"==typeof t.Buffer.isBuffer?t.Buffer.isBuffer(e):!(null==e||!e._isBuffer)}var o=n(23),a=Object.prototype.hasOwnProperty,s=Array.prototype.slice,u="foo"===function(){}.name;function c(e){return Object.prototype.toString.call(e)}function l(e){return!i(e)&&("function"==typeof t.ArrayBuffer&&("function"==typeof ArrayBuffer.isView?ArrayBuffer.isView(e):!!e&&(e instanceof DataView||!!(e.buffer&&e.buffer instanceof ArrayBuffer))))}var f=e.exports=g,h=/\s*function\s+([^\(\s]*)\s*/;function p(e){if(o.isFunction(e)){if(u)return e.name;var t=e.toString().match(h);return t&&t[1]}}function d(e,t){return"string"==typeof e?e.length<t?e:e.slice(0,t):e}function y(e){if(u||!o.isFunction(e))return o.inspect(e);var t=p(e);return"[Function"+(t?": "+t:"")+"]"}function v(e,t,n,r,i){throw new f.AssertionError({message:n,actual:e,expected:t,operator:r,stackStartFunction:i})}function g(e,t){e||v(e,!0,t,"==",f.ok)}function m(e,t,n,a){if(e===t)return!0;if(i(e)&&i(t))return 0===r(e,t);if(o.isDate(e)&&o.isDate(t))return e.getTime()===t.getTime();if(o.isRegExp(e)&&o.isRegExp(t))return e.source===t.source&&e.global===t.global&&e.multiline===t.multiline&&e.lastIndex===t.lastIndex&&e.ignoreCase===t.ignoreCase;if(null!==e&&"object"==typeof e||null!==t&&"object"==typeof t){if(l(e)&&l(t)&&c(e)===c(t)&&!(e instanceof Float32Array||e instanceof Float64Array))return 0===r(new Uint8Array(e.buffer),new Uint8Array(t.buffer));if(i(e)!==i(t))return!1;var u=(a=a||{actual:[],expected:[]}).actual.indexOf(e);return-1!==u&&u===a.expected.indexOf(t)||(a.actual.push(e),a.expected.push(t),function(e,t,n,r){if(null==e||null==t)return!1;if(o.isPrimitive(e)||o.isPrimitive(t))return e===t;if(n&&Object.getPrototypeOf(e)!==Object.getPrototypeOf(t))return!1;var i=w(e),a=w(t);if(i&&!a||!i&&a)return!1;if(i)return e=s.call(e),t=s.call(t),m(e,t,n);var u,c,l=_(e),f=_(t);if(l.length!==f.length)return!1;for(l.sort(),f.sort(),c=l.length-1;c>=0;c--)if(l[c]!==f[c])return!1;for(c=l.length-1;c>=0;c--)if(u=l[c],!m(e[u],t[u],n,r))return!1;return!0}(e,t,n,a))}return n?e===t:e==t}function w(e){return"[object Arguments]"==Object.prototype.toString.call(e)}function b(e,t){if(!e||!t)return!1;if("[object RegExp]"==Object.prototype.toString.call(t))return t.test(e);try{if(e instanceof t)return!0}catch(e){}return!Error.isPrototypeOf(t)&&!0===t.call({},e)}function x(e,t,n,r){var i;if("function"!=typeof t)throw new TypeError('"block" argument must be a function');"string"==typeof n&&(r=n,n=null),i=function(e){var t;try{e()}catch(e){t=e}return t}(t),r=(n&&n.name?" ("+n.name+").":".")+(r?" "+r:"."),e&&!i&&v(i,n,"Missing expected exception"+r);var a="string"==typeof r,s=!e&&i&&!n;if((!e&&o.isError(i)&&a&&b(i,n)||s)&&v(i,n,"Got unwanted exception"+r),e&&i&&n&&!b(i,n)||!e&&i)throw i}f.AssertionError=function(e){var t;this.name="AssertionError",this.actual=e.actual,this.expected=e.expected,this.operator=e.operator,e.message?(this.message=e.message,this.generatedMessage=!1):(this.message=d(y((t=this).actual),128)+" "+t.operator+" "+d(y(t.expected),128),this.generatedMessage=!0);var n=e.stackStartFunction||v;if(Error.captureStackTrace)Error.captureStackTrace(this,n);else{var r=new Error;if(r.stack){var i=r.stack,o=p(n),a=i.indexOf("\n"+o);if(a>=0){var s=i.indexOf("\n",a+1);i=i.substring(s+1)}this.stack=i}}},o.inherits(f.AssertionError,Error),f.fail=v,f.ok=g,f.equal=function(e,t,n){e!=t&&v(e,t,n,"==",f.equal)},f.notEqual=function(e,t,n){e==t&&v(e,t,n,"!=",f.notEqual)},f.deepEqual=function(e,t,n){m(e,t,!1)||v(e,t,n,"deepEqual",f.deepEqual)},f.deepStrictEqual=function(e,t,n){m(e,t,!0)||v(e,t,n,"deepStrictEqual",f.deepStrictEqual)},f.notDeepEqual=function(e,t,n){m(e,t,!1)&&v(e,t,n,"notDeepEqual",f.notDeepEqual)},f.notDeepStrictEqual=function e(t,n,r){m(t,n,!0)&&v(t,n,r,"notDeepStrictEqual",e)},f.strictEqual=function(e,t,n){e!==t&&v(e,t,n,"===",f.strictEqual)},f.notStrictEqual=function(e,t,n){e===t&&v(e,t,n,"!==",f.notStrictEqual)},f.throws=function(e,t,n){x(!0,e,t,n)},f.doesNotThrow=function(e,t,n){x(!1,e,t,n)},f.ifError=function(e){if(e)throw e};var _=Object.keys||function(e){var t=[];for(var n in e)a.call(e,n)&&t.push(n);return t}}).call(this,n(21))},function(e,t,n){(function(e,r){var i=/%[sdj%]/g;t.format=function(e){if(!g(e)){for(var t=[],n=0;n<arguments.length;n++)t.push(s(arguments[n]));return t.join(" ")}n=1;for(var r=arguments,o=r.length,a=String(e).replace(i,function(e){if("%%"===e)return"%";if(n>=o)return e;switch(e){case"%s":return String(r[n++]);case"%d":return Number(r[n++]);case"%j":try{return JSON.stringify(r[n++])}catch(e){return"[Circular]"}default:return e}}),u=r[n];n<o;u=r[++n])y(u)||!b(u)?a+=" "+u:a+=" "+s(u);return a},t.deprecate=function(n,i){if(m(e.process))return function(){return t.deprecate(n,i).apply(this,arguments)};if(!0===r.noDeprecation)return n;var o=!1;return function(){if(!o){if(r.throwDeprecation)throw new Error(i);r.traceDeprecation?console.trace(i):console.error(i),o=!0}return n.apply(this,arguments)}};var o,a={};function s(e,n){var r={seen:[],stylize:c};return arguments.length>=3&&(r.depth=arguments[2]),arguments.length>=4&&(r.colors=arguments[3]),d(n)?r.showHidden=n:n&&t._extend(r,n),m(r.showHidden)&&(r.showHidden=!1),m(r.depth)&&(r.depth=2),m(r.colors)&&(r.colors=!1),m(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=u),l(r,e,r.depth)}function u(e,t){var n=s.styles[t];return n?"["+s.colors[n][0]+"m"+e+"["+s.colors[n][1]+"m":e}function c(e,t){return e}function l(e,n,r){if(e.customInspect&&n&&k(n.inspect)&&n.inspect!==t.inspect&&(!n.constructor||n.constructor.prototype!==n)){var i=n.inspect(r,e);return g(i)||(i=l(e,i,r)),i}var o=function(e,t){if(m(t))return e.stylize("undefined","undefined");if(g(t)){var n="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(n,"string")}if(v(t))return e.stylize(""+t,"number");if(d(t))return e.stylize(""+t,"boolean");if(y(t))return e.stylize("null","null")}(e,n);if(o)return o;var a=Object.keys(n),s=function(e){var t={};return e.forEach(function(e,n){t[e]=!0}),t}(a);if(e.showHidden&&(a=Object.getOwnPropertyNames(n)),_(n)&&(a.indexOf("message")>=0||a.indexOf("description")>=0))return f(n);if(0===a.length){if(k(n)){var u=n.name?": "+n.name:"";return e.stylize("[Function"+u+"]","special")}if(w(n))return e.stylize(RegExp.prototype.toString.call(n),"regexp");if(x(n))return e.stylize(Date.prototype.toString.call(n),"date");if(_(n))return f(n)}var c,b="",S=!1,T=["{","}"];(p(n)&&(S=!0,T=["[","]"]),k(n))&&(b=" [Function"+(n.name?": "+n.name:"")+"]");return w(n)&&(b=" "+RegExp.prototype.toString.call(n)),x(n)&&(b=" "+Date.prototype.toUTCString.call(n)),_(n)&&(b=" "+f(n)),0!==a.length||S&&0!=n.length?r<0?w(n)?e.stylize(RegExp.prototype.toString.call(n),"regexp"):e.stylize("[Object]","special"):(e.seen.push(n),c=S?function(e,t,n,r,i){for(var o=[],a=0,s=t.length;a<s;++a)O(t,String(a))?o.push(h(e,t,n,r,String(a),!0)):o.push("");return i.forEach(function(i){i.match(/^\d+$/)||o.push(h(e,t,n,r,i,!0))}),o}(e,n,r,s,a):a.map(function(t){return h(e,n,r,s,t,S)}),e.seen.pop(),function(e,t,n){if(e.reduce(function(e,t){return 0,t.indexOf("\n")>=0&&0,e+t.replace(/\u001b\[\d\d?m/g,"").length+1},0)>60)return n[0]+(""===t?"":t+"\n ")+" "+e.join(",\n  ")+" "+n[1];return n[0]+t+" "+e.join(", ")+" "+n[1]}(c,b,T)):T[0]+b+T[1]}function f(e){return"["+Error.prototype.toString.call(e)+"]"}function h(e,t,n,r,i,o){var a,s,u;if((u=Object.getOwnPropertyDescriptor(t,i)||{value:t[i]}).get?s=u.set?e.stylize("[Getter/Setter]","special"):e.stylize("[Getter]","special"):u.set&&(s=e.stylize("[Setter]","special")),O(r,i)||(a="["+i+"]"),s||(e.seen.indexOf(u.value)<0?(s=y(n)?l(e,u.value,null):l(e,u.value,n-1)).indexOf("\n")>-1&&(s=o?s.split("\n").map(function(e){return"  "+e}).join("\n").substr(2):"\n"+s.split("\n").map(function(e){return"   "+e}).join("\n")):s=e.stylize("[Circular]","special")),m(a)){if(o&&i.match(/^\d+$/))return s;(a=JSON.stringify(""+i)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(a=a.substr(1,a.length-2),a=e.stylize(a,"name")):(a=a.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),a=e.stylize(a,"string"))}return a+": "+s}function p(e){return Array.isArray(e)}function d(e){return"boolean"==typeof e}function y(e){return null===e}function v(e){return"number"==typeof e}function g(e){return"string"==typeof e}function m(e){return void 0===e}function w(e){return b(e)&&"[object RegExp]"===S(e)}function b(e){return"object"==typeof e&&null!==e}function x(e){return b(e)&&"[object Date]"===S(e)}function _(e){return b(e)&&("[object Error]"===S(e)||e instanceof Error)}function k(e){return"function"==typeof e}function S(e){return Object.prototype.toString.call(e)}function T(e){return e<10?"0"+e.toString(10):e.toString(10)}t.debuglog=function(e){if(m(o)&&(o=r.env.NODE_DEBUG||""),e=e.toUpperCase(),!a[e])if(new RegExp("\\b"+e+"\\b","i").test(o)){var n=r.pid;a[e]=function(){var r=t.format.apply(t,arguments);console.error("%s %d: %s",e,n,r)}}else a[e]=function(){};return a[e]},t.inspect=s,s.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]},s.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},t.isArray=p,t.isBoolean=d,t.isNull=y,t.isNullOrUndefined=function(e){return null==e},t.isNumber=v,t.isString=g,t.isSymbol=function(e){return"symbol"==typeof e},t.isUndefined=m,t.isRegExp=w,t.isObject=b,t.isDate=x,t.isError=_,t.isFunction=k,t.isPrimitive=function(e){return null===e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||"symbol"==typeof e||void 0===e},t.isBuffer=n(25);var E=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function O(e,t){return Object.prototype.hasOwnProperty.call(e,t)}t.log=function(){var e,n;console.log("%s - %s",(e=new Date,n=[T(e.getHours()),T(e.getMinutes()),T(e.getSeconds())].join(":"),[e.getDate(),E[e.getMonth()],n].join(" ")),t.format.apply(t,arguments))},t.inherits=n(26),t._extend=function(e,t){if(!t||!b(t))return e;for(var n=Object.keys(t),r=n.length;r--;)e[n[r]]=t[n[r]];return e}}).call(this,n(21),n(24))},function(e,t){var n,r,i=e.exports={};function o(){throw new Error("setTimeout has not been defined")}function a(){throw new Error("clearTimeout has not been defined")}function s(e){if(n===setTimeout)return setTimeout(e,0);if((n===o||!n)&&setTimeout)return n=setTimeout,setTimeout(e,0);try{return n(e,0)}catch(t){try{return n.call(null,e,0)}catch(t){return n.call(this,e,0)}}}!function(){try{n="function"==typeof setTimeout?setTimeout:o}catch(e){n=o}try{r="function"==typeof clearTimeout?clearTimeout:a}catch(e){r=a}}();var u,c=[],l=!1,f=-1;function h(){l&&u&&(l=!1,u.length?c=u.concat(c):f=-1,c.length&&p())}function p(){if(!l){var e=s(h);l=!0;for(var t=c.length;t;){for(u=c,c=[];++f<t;)u&&u[f].run();f=-1,t=c.length}u=null,l=!1,function(e){if(r===clearTimeout)return clearTimeout(e);if((r===a||!r)&&clearTimeout)return r=clearTimeout,clearTimeout(e);try{r(e)}catch(t){try{return r.call(null,e)}catch(t){return r.call(this,e)}}}(e)}}function d(e,t){this.fun=e,this.array=t}function y(){}i.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];c.push(new d(e,t)),1!==c.length||l||s(p)},d.prototype.run=function(){this.fun.apply(null,this.array)},i.title="browser",i.browser=!0,i.env={},i.argv=[],i.version="",i.versions={},i.on=y,i.addListener=y,i.once=y,i.off=y,i.removeListener=y,i.removeAllListeners=y,i.emit=y,i.prependListener=y,i.prependOnceListener=y,i.listeners=function(e){return[]},i.binding=function(e){throw new Error("process.binding is not supported")},i.cwd=function(){return"/"},i.chdir=function(e){throw new Error("process.chdir is not supported")},i.umask=function(){return 0}},function(e,t){e.exports=function(e){return e&&"object"==typeof e&&"function"==typeof e.copy&&"function"==typeof e.fill&&"function"==typeof e.readUInt8}},function(e,t){"function"==typeof Object.create?e.exports=function(e,t){e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}})}:e.exports=function(e,t){e.super_=t;var n=function(){};n.prototype=t.prototype,e.prototype=new n,e.prototype.constructor=e}},function(e,t){e.exports=window.window},function(e,t,n){"use strict";e.exports={Formats:n(29),Initializer:n(30),JSONDocument:n(31),JSONMapping:n(34),JSONPatch:n(32),JSONPointer:n(33),JSONSchema:n(35),Validator:n(36)}},function(e,t,n){"use strict";var r=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}();var i=/^\d\d\d\d-[0-1]\d-[0-3]\d[t\s][0-2]\d:[0-5]\d:[0-5]\d(?:\.\d+)?(?:z|[+-]\d\d:\d\d)$/i,o=/^(?:[a-z][a-z0-9+-.]*)?(?:\:|\/)\/?[^\s]*$/i,a=/^[a-z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)*$/i,s=/^(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)$/,u=/^\s*(?:(?:(?:[0-9a-f]{1,4}:){7}(?:[0-9a-f]{1,4}|:))|(?:(?:[0-9a-f]{1,4}:){6}(?::[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(?:(?:[0-9a-f]{1,4}:){5}(?:(?:(?::[0-9a-f]{1,4}){1,2})|:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(?:(?:[0-9a-f]{1,4}:){4}(?:(?:(?::[0-9a-f]{1,4}){1,3})|(?:(?::[0-9a-f]{1,4})?:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?:(?:[0-9a-f]{1,4}:){3}(?:(?:(?::[0-9a-f]{1,4}){1,4})|(?:(?::[0-9a-f]{1,4}){0,2}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?:(?:[0-9a-f]{1,4}:){2}(?:(?:(?::[0-9a-f]{1,4}){1,5})|(?:(?::[0-9a-f]{1,4}){0,3}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?:(?:[0-9a-f]{1,4}:){1}(?:(?:(?::[0-9a-f]{1,4}){1,6})|(?:(?::[0-9a-f]{1,4}){0,4}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?::(?:(?:(?::[0-9a-f]{1,4}){1,7})|(?:(?::[0-9a-f]{1,4}){0,5}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(?:%.+)?\s*$/i,c=/^[a-z](?:(?:[-0-9a-z]{0,61})?[0-9a-z])?(\.[a-z](?:(?:[-0-9a-z]{0,61})?[0-9a-z])?)*$/i,l=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e)}return r(e,[{key:"register",value:function(e,t){if("string"!=typeof e)throw new Error("Format name must be a string");return"string"==typeof t&&(t=new RegExp(t)),this[e]=t}},{key:"resolve",value:function(e){var t=this[e];if(!t)throw new Error("Unknown JSON Schema format.");return t}},{key:"test",value:function(e,t){return this.resolve(e).test(t)}}],[{key:"initialize",value:function(){var t=new e;return t.register("date-time",i),t.register("uri",o),t.register("email",a),t.register("ipv4",s),t.register("ipv6",u),t.register("hostname",c),t}}]),e}();e.exports=l.initialize()},function(e,t,n){"use strict";var r="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},i=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}();var o=function(){function e(t,n){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),Object.assign(this,n||{}),this.root=this.root||this,this.root.depth=this.root.depth||1,this.level>this.root.depth&&(this.root.depth=this.level),this.level=this.level||0,this.schema=t}return i(e,[{key:"compile",value:function(){var e=this.root,t=(this.depth,this.level,""),n="";if(n+=this.default(),n+=this.properties(),n+=this.items(),n+=this.member(),n+=this.item(),e===this){for(var r=1;r<=this.root.depth;r++)t+=this.declaration(r);return"\n        options = options || {}\n\n        if (options.filter === false) {\n          Object.assign(target, JSON.parse(JSON.stringify(source)))\n        }\n\n        "+t+"\n        "+n+"\n      "}return n}},{key:"declaration",value:function(e){return"\n      var target"+e+"\n      var source"+e+"\n      var count"+e+"\n    "}},{key:"default",value:function(){var e=this.schema,t=this.level,n=this.key,r=this.index,i=e.default,o="";return e.hasOwnProperty("default")&&(n&&(o+="\n          target"+t+"['"+n+"'] = "+JSON.stringify(i)+"\n        "),r&&(o+="\n          target"+t+"["+r+"] = "+JSON.stringify(i)+"\n        "),t>1&&(o+="\n          count"+t+"++\n        "),o="\n        if (options.defaults !== false) {\n          "+o+"\n        }\n      "),o}},{key:"member",value:function(){var e=this.schema,t=(this.root,this.level),n=this.key,r=e.properties,i=e.additionalProperties,o=e.items,a=e.additionalItems,s="";return!n||r||i||o||a||(s+="\n        target"+t+"['"+n+"'] = source"+t+"['"+n+"']\n      ",t>1&&(s+="\n          count"+t+"++\n        "),s="\n        if (source"+t+".hasOwnProperty('"+n+"')) {\n          "+s+"\n        }\n      "),s}},{key:"item",value:function(){var e=this.schema,t=(this.root,this.level),n=this.index,r=e.properties,i=e.additionalProperties,o=e.items,a=e.additionalItems,s="";return!n||r||i||o||a||(s+="\n        target"+t+"["+n+"] = source"+t+"["+n+"]\n      ",t>1&&(s+="\n          count"+t+"++\n        "),s="\n        if ("+n+" < len) {\n          "+s+"\n        }\n      "),s}},{key:"properties",value:function(){var t=this.schema,n=this.root,r=this.level,i=this.key,o=this.index,a=t.properties,s="";return a&&(Object.keys(a).forEach(function(t){var i=new e(a[t],{key:t,root:n,level:r+1});s+=i.compile()}),n===this?s="\n          if (typeof source === 'object' && source !== null && !Array.isArray(source)) {\n            if (typeof target !== 'object') {\n              throw new Error('?')\n            }\n\n            source1 = source\n            target1 = target\n            count1 = 0\n\n            "+s+"\n          }\n        ":(o&&(s="\n            if ("+o+" < source"+r+".length || typeof source"+r+"["+o+"] === 'object') {\n\n              source"+(r+1)+" = source"+r+"["+o+"] || {}\n              count"+(r+1)+" = 0\n\n              if ("+o+" < target"+r+".length || typeof target"+r+"["+o+"] !== 'object') {\n                target"+(r+1)+" = {}\n                if ("+o+" < source"+r+".length) {\n                  count"+(r+1)+"++\n                }\n              } else {\n                target"+(r+1)+" = target"+r+"["+o+"]\n              }\n\n              "+s+"\n\n              if (count"+(r+1)+" > 0) {\n                target"+r+"["+o+"] = target"+(r+1)+"\n                count"+r+"++\n              }\n\n            } else {\n              target"+r+"["+o+"] = source"+r+"["+o+"]\n              count"+r+"++\n            }\n          "),i&&(s="\n            if ((typeof source"+r+"['"+i+"'] === 'object'\n                  && source"+r+"['"+i+"'] !== null\n                  && !Array.isArray(source"+r+"['"+i+"']))\n                || !source"+r+".hasOwnProperty('"+i+"')) {\n\n              source"+(r+1)+" = source"+r+"['"+i+"'] || {}\n              count"+(r+1)+" = 0\n\n              if (!target"+r+".hasOwnProperty('"+i+"')\n                  || typeof target"+r+"['"+i+"'] !== 'object'\n                  || target"+r+"['"+i+"'] === null\n                  || Array.isArray(target"+r+"['"+i+"'])) {\n                target"+(r+1)+" = {}\n                if (source"+r+".hasOwnProperty('"+i+"')) {\n                  count"+(r+1)+"++\n                }\n              } else {\n                target"+(r+1)+" = target"+r+"['"+i+"']\n                count"+(r+1)+"++\n              }\n\n              "+s+"\n\n              if (count"+(r+1)+" > 0) {\n                target"+r+"['"+i+"'] = target"+(r+1)+"\n                count"+r+"++\n              }\n\n            } else {\n              target"+r+"['"+i+"'] = source"+r+"['"+i+"']\n              count"+r+"++\n            }\n          "))),s}},{key:"additionalProperties",value:function(){}},{key:"items",value:function(){var t=this.schema,n=this.root,i=this.level,o=this.key,a=(this.index,t.items),s="";if(a){if(Array.isArray(a));else if("object"===(void 0===a?"undefined":r(a))&&null!==a){var u="i"+(i+1);s+="\n          var sLen = source"+(i+1)+".length || 0\n          var tLen = target"+(i+1)+".length || 0\n          var len = 0\n\n          if (sLen > len) { len = sLen }\n          // THIS IS WRONG, CAUSED SIMPLE ARRAY INIT TO FAIL (OVERWRITE\n          // EXISTING TARGET VALUES WITH UNDEFINED WHEN SOURCE IS SHORTER THAN\n          // TARGET). LEAVING HERE UNTIL WE FINISH TESTING AND SEE WHY IT MIGHT\n          // HAVE BEEN HERE IN THE FIRST PLACE.\n          //\n          // if (tLen > len) { len = tLen }\n\n          for (var "+u+" = 0; "+u+" < len; "+u+"++) {\n            "+new e(a,{index:u,root:n,level:i+1}).compile()+"\n          }\n        "}s=n===this?"\n          if (Array.isArray(source)) {\n            if (!Array.isArray(target)) {\n              throw new Error('?')\n            }\n\n            source1 = source\n            target1 = target\n\n            "+s+"\n          }\n        ":"\n          if (Array.isArray(source"+i+"['"+o+"']) || !source"+i+".hasOwnProperty('"+o+"')) {\n\n            source"+(i+1)+" = source"+i+"['"+o+"'] || []\n            count"+(i+1)+" = 0\n\n            if (!target"+i+".hasOwnProperty('"+o+"') || !Array.isArray(target"+i+"['"+o+"'])) {\n              target"+(i+1)+" = []\n                if (source"+i+".hasOwnProperty('"+o+"')) {\n                  count"+(i+1)+"++\n                }\n\n            } else {\n              target"+(i+1)+" = target"+i+"['"+o+"']\n              count"+(i+1)+"++\n            }\n\n            "+s+"\n\n            if (count"+(i+1)+" > 0) {\n              target"+i+"['"+o+"'] = target"+(i+1)+"\n              count"+i+"++\n            }\n\n          } else {\n            target"+i+"['"+o+"'] = source"+i+"['"+o+"']\n            count"+i+"++\n          }\n        "}return s}},{key:"additionalItems",value:function(){}}],[{key:"compile",value:function(t){var n=new e(t).compile();try{return new Function("target","source","options",n)}catch(e){console.log(e,e.stack)}}}]),e}();e.exports=o},function(e,t,n){"use strict";var r=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}();var i=n(32),o=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.initialize(t,n)}return r(e,null,[{key:"schema",get:function(){throw new Error("Schema must be defined by classes extending JSONDocument")}}]),r(e,[{key:"initialize",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.constructor.schema.initialize(this,e,t)}},{key:"validate",value:function(e){var t=this.constructor.schema;return(e||t).validate(this)}},{key:"patch",value:function(e){var t=new i(e);t.apply(this)}},{key:"select",value:function(){}},{key:"project",value:function(e){return e.project(this)}}],[{key:"serialize",value:function(e){return JSON.stringify(e)}},{key:"deserialize",value:function(e){try{return JSON.parse(e)}catch(e){throw new Error("Failed to parse JSON")}}}]),e}();e.exports=o},function(e,t,n){"use strict";var r="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},i=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}();var o=n(33),a=["add","remove","replace","move","copy","test"],s=function(){function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.ops=t||[]}return i(e,[{key:"apply",value:function(e){var t=this;this.ops.forEach(function(n){var r=n.op;if(!r)throw new Error('Missing "op" in JSON Patch operation');if(-1===a.indexOf(r))throw new Error('Invalid "op" in JSON Patch operation');if(!n.path)throw new Error('Missing "path" in JSON Patch operation');t[r](n,e)})}},{key:"add",value:function(e,t){if(void 0===e.value)throw new Error('Missing "value" in JSON Patch add operation');new o(e.path,2).add(t,e.value)}},{key:"remove",value:function(e,t){new o(e.path).remove(t)}},{key:"replace",value:function(e,t){if(void 0===e.value)throw new Error('Missing "value" in JSON Patch replace operation');new o(e.path).replace(t,e.value)}},{key:"move",value:function(e,t){if(void 0===e.from)throw new Error('Missing "from" in JSON Patch move operation');if(e.path.match(new RegExp("^"+e.from)))throw new Error('Invalid "from" in JSON Patch move operation');var n=new o(e.path),r=new o(e.from),i=r.get(t);r.remove(t),n.add(t,i)}},{key:"copy",value:function(e,t){if(void 0===e.from)throw new Error('Missing "from" in JSON Patch copy operation');var n=new o(e.path),r=new o(e.from).get(t);n.add(t,r)}},{key:"test",value:function(e,t){if(void 0===e.value)throw new Error('Missing "value" in JSON Patch test operation');var n=new o(e.path).get(t);if(r(e.value),n!==e.value)throw new Error("Mismatching JSON Patch test value")}}]),e}();e.exports=s},function(e,t,n){"use strict";var r=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}();var i=0,o=function(){function e(t,n){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.expr=t,this.mode=n||i,this.tokens=t&&"#"===t.charAt(0)?this.parseURIFragmentIdentifier(t):this.parseJSONString(t)}return r(e,[{key:"escape",value:function(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}},{key:"unescape",value:function(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}},{key:"parseJSONString",value:function(e){if("string"!=typeof e)throw new Error("JSON Pointer must be a string");if(""===e)return[];if("/"!==e.charAt(0))throw new Error("Invalid JSON Pointer");return"/"===e?[""]:e.substr(1).split("/").map(this.unescape)}},{key:"toJSONString",value:function(){return"/"+this.tokens.map(this.escape).join("/")}},{key:"parseURIFragmentIdentifier",value:function(e){if("string"!=typeof e)throw new Error("JSON Pointer must be a string");if("#"!==e.charAt(0))throw new Error("Invalid JSON Pointer URI Fragment Identifier");return this.parseJSONString(decodeURIComponent(e.substr(1)))}},{key:"toURIFragmentIdentifier",value:function(){var e=this;return"#/"+this.tokens.map(function(t){return encodeURIComponent(e.escape(t))}).join("/")}},{key:"get",value:function(e){for(var t=e,n=this.tokens,r=0;r<n.length;r++){if(!t||void 0===t[n[r]]){if(this.mode!==i)return;throw new Error("Invalid JSON Pointer reference")}t=t[n[r]]}return t}},{key:"add",value:function(e,t){for(var n=this.tokens,r=e,o=0;o<n.length;o++){var a=n[o];if(o===n.length-1)"-"===a?r.push(t):Array.isArray(r)?r.splice(a,0,t):void 0!==t&&(r[a]=t);else if(r[a])r=r[a];else switch(this.mode){case i:throw new Error("Invalid JSON Pointer reference");case 1:r=r[a]=parseInt(a)?[]:{};break;case 2:return;default:throw new Error("Invalid pointer mode")}}}},{key:"replace",value:function(e,t){for(var n=this.tokens,r=e,i=0;i<n.length;i++){var o=n[i];i===n.length-1?r[o]=t:r=r[o]?r[o]:r[o]=parseInt(o)?[]:{}}}},{key:"remove",value:function(e){for(var t=this.tokens,n=e,r=0;r<t.length;r++){var i=t[r];if(void 0===n||void 0===n[i])return;if(Array.isArray(n))return void n.splice(i,1);r===t.length-1&&delete n[i],n=n[i]}}}],[{key:"parse",value:function(t){return new e(t)}}]),e}();e.exports=o},function(e,t,n){"use strict";var r=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}();var i=n(33),o=1,a=function(){function e(t){var n=this;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),Object.defineProperty(this,"mapping",{enumerable:!1,value:new Map}),Object.keys(t).forEach(function(e){var r=t[e];n.mapping.set(new i(e,o),new i(r,o))})}return r(e,[{key:"map",value:function(e,t){this.mapping.forEach(function(n,r){r.add(e,n.get(t))})}},{key:"project",value:function(e,t){this.mapping.forEach(function(n,r){n.add(t,r.get(e))})}}]),e}();e.exports=a},function(e,t,n){"use strict";var r="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},i=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}();function o(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var a=n(30),s=n(36),u=function(){function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),Object.assign(this,t),Object.defineProperties(this,{initialize:{enumerable:!1,writeable:!1,value:a.compile(t)},validate:{enumerable:!1,writeable:!1,value:s.compile(t)}})}return i(e,[{key:"extend",value:function(t){function n(e){return e&&"object"===(void 0===e?"undefined":r(e))&&null!==e&&!Array.isArray(e)}return new e(function e(t,r){var i=Object.assign({},t);return n(t)&&n(r)&&Object.keys(r).forEach(function(a){n(r[a])&&a in t?i[a]=e(t[a],r[a]):Object.assign(i,o({},a,r[a]))}),i}(this,t))}}]),e}();e.exports=u},function(e,t,n){"use strict";var r="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},i=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}();var o=n(29),a=0,s=function(){function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.schema=t,Object.assign(this,n),this.address||(this.address=""),!0!==this.require&&(this.require=!1)}return i(e,null,[{key:"compile",value:function(t){var n='\n      // "cursor"\n      let value = data\n      let container\n      let stack = []\n      let top = -1\n\n      // error state\n      let valid = true\n      let errors = []\n\n      // complex schema state\n      let initialValidity\n      let anyValid\n      let notValid\n      let countOfValid\n      let initialErrorCount\n      let accumulatedErrorCount\n\n      // validation code\n      '+new e(t).compile()+"\n\n      // validation result\n      return {\n        valid,\n        errors\n      }\n    ";return new Function("data",n)}},{key:"counter",get:function(){return a++}}]),i(e,[{key:"compile",value:function(){var e="";return this.require&&(e+=this.required()),e+=this.type(),e+=this.array(),e+=this.number(),e+=this.object(),e+=this.string(),e+=this.enum(),e+=this.anyOf(),e+=this.allOf(),e+=this.not(),e+=this.oneOf()}},{key:"push",value:function(){return"\n      stack.push(value)\n      container = value\n      top++\n    "}},{key:"pop",value:function(){return"\n      if (stack.length > 1) {\n        top--\n        stack.pop()\n      }\n\n      value = container = stack[top]\n    "}},{key:"type",value:function(){var e=this.schema.type,t=this.address,n="";e&&(n+="\n      // "+t+" type checking\n      if (value !== undefined && "+(Array.isArray(e)?e:[e]).map(function(e){return"array"===e?"!Array.isArray(value)":"boolean"===e?"typeof value !== 'boolean'":"integer"===e?"!Number.isInteger(value)":"null"===e?"value !== null":"number"===e?"typeof value !== 'number'":"object"===e?"(typeof value !== 'object' || Array.isArray(value) || value === null)":"string"===e?"typeof value !== 'string'":void 0}).join(" && ")+") {\n        valid = false\n        errors.push({\n          keyword: 'type',\n          message: 'invalid type'\n        })\n      }\n      ");return n}},{key:"array",value:function(){var e=this.validations(["additionalItems","items","minItems","maxItems","uniqueItems"]),t="";return e.length>0&&(t+="\n      /**\n       * Array validations\n       */\n      if (Array.isArray(value)) {\n      "+e+"\n      }\n      "),t}},{key:"number",value:function(){var e=this.validations(["minimum","maximum","multipleOf"]),t="";return e.length>0&&(t+="\n      /**\n       * Number validations\n       */\n      if (typeof value === 'number') {\n      "+e+"\n      }\n      "),t}},{key:"object",value:function(){var e=this.validations(["maxProperties","minProperties","additionalProperties","properties","patternProperties","dependencies","schemaDependencies","propertyDependencies"]),t="";return e.length>0&&(t+="\n      /**\n       * Object validations\n       */\n      if (typeof value === 'object' && value !== null && !Array.isArray(value)) {\n      "+e+"\n      }\n      "),t}},{key:"string",value:function(){var e=this.validations(["maxLength","minLength","pattern","format"]),t="";return e.length>0&&(t+="\n      /**\n       * String validations\n       */\n      if (typeof value === 'string') {\n      "+e+"\n      }\n      "),t}},{key:"validations",value:function(e){var t=this,n=this.schema,r="";return Object.keys(n).filter(function(t){return-1!==e.indexOf(t)}).forEach(function(e){r+=t[e]()}),r}},{key:"enum",value:function(){var e=this.schema.enum,t=this.address,n=["value !== undefined"],i="";return e&&(e.forEach(function(e){switch(void 0===e?"undefined":r(e)){case"boolean":case"number":n.push("value !== "+e);break;case"string":n.push('value !== "'+e+'"');break;case"object":null===e?n.push("value !== null"):n.push("'"+JSON.stringify(e)+"' !== JSON.stringify(value)");break;default:throw new Error("Things are not well in the land of enum")}}),i+='\n      /**\n       * Validate "'+t+'" enum\n       */\n      if ('+n.join(" && ")+") {\n        valid = false\n        errors.push({\n          keyword: 'enum',\n          message: JSON.stringify(value) + ' is not an enumerated value'\n        })\n      }\n      "),i}},{key:"anyOf",value:function(){var t=this.schema.anyOf,n=this.address,r="";return Array.isArray(t)&&(r+="\n        initialValidity = valid\n        initialErrorCount = errors.length\n        anyValid = false\n      ",t.forEach(function(t){var i=new e(t,{address:n});r+="\n        accumulatedErrorCount = errors.length\n        "+i.compile()+"\n        if (accumulatedErrorCount === errors.length) {\n          anyValid = true\n        }\n        "}),r+="\n          if (anyValid === true) {\n            valid = initialValidity\n            errors = errors.slice(0, initialErrorCount)\n          }\n      "),r}},{key:"allOf",value:function(){var t=this.schema.allOf,n=this.address,r="";return Array.isArray(t)&&t.forEach(function(t){var i=new e(t,{address:n});r+="\n        "+i.compile()+"\n        "}),r}},{key:"oneOf",value:function(){var t=this.schema.oneOf,n=this.address,r="";return Array.isArray(t)&&(r+="\n        /**\n         * Validate "+n+" oneOf\n         */\n        initialValidity = valid\n        initialErrorCount = errors.length\n        countOfValid = 0\n      ",t.forEach(function(t){var i=new e(t,{address:n});r+="\n        accumulatedErrorCount = errors.length\n        "+i.compile()+"\n        if (accumulatedErrorCount === errors.length) {\n          countOfValid += 1\n        }\n        "}),r+="\n          if (countOfValid === 1) {\n            valid = initialValidity\n            errors = errors.slice(0, initialErrorCount)\n          } else {\n            valid = false\n            errors.push({\n              keyword: 'oneOf',\n              message: 'what is a reasonable error message for this case?'\n            })\n          }\n      "),r}},{key:"not",value:function(){var t=this.schema.not,n=this.address,i="";"object"!==(void 0===t?"undefined":r(t))||null===t||Array.isArray(t)||(i+="\n        /**\n         * NOT\n         */\n        if (value !== undefined) {\n          initialValidity = valid\n          initialErrorCount = errors.length\n          notValid = true\n\n          accumulatedErrorCount = errors.length\n\n          "+new e(t,{address:n}).compile()+"\n\n          if (accumulatedErrorCount === errors.length) {\n            notValid = false\n          }\n\n          if (notValid === true) {\n            valid = initialValidity\n            errors = errors.slice(0, initialErrorCount)\n          } else {\n            valid = false\n            errors = errors.slice(0, initialErrorCount)\n            errors.push({\n              keyword: 'not',\n              message: 'hmm...'\n            })\n          }\n        }\n      ");return i}},{key:"properties",value:function(){var t=this.schema,n=this.address,i=t.properties,o=t.required,a=this.push();return o=Array.isArray(o)?o:[],"object"===(void 0===i?"undefined":r(i))&&Object.keys(i).forEach(function(t){var r=i[t],s=-1!==o.indexOf(t),u=new e(r,{address:[n,t].filter(function(e){return!!e}).join("."),require:s});a+="\n        value = container['"+t+"']\n        ",a+=u.compile()}),a+=this.pop()}},{key:"otherProperties",value:function(){return"\n      /**\n       * Validate Other Properties\n       */\n      "+this.push()+"\n\n      for (let key in container) {\n        value = container[key]\n        matched = false\n\n        "+this.patternValidations()+"\n        "+this.additionalValidations()+"\n      }\n\n      "+this.pop()+"\n    "}},{key:"patternValidations",value:function(){var t=this.schema.patternProperties,n="";return"object"===(void 0===t?"undefined":r(t))&&Object.keys(t).forEach(function(r){var i=new e(t[r]);n+="\n          if (key.match('"+r+"')) {\n            matched = true\n            "+i.compile()+"\n          }\n        "}),n}},{key:"additionalValidations",value:function(){var t=this.schema,n=t.properties,i=t.additionalProperties,o=this.address,a="",s=["matched !== true"];if(Object.keys(n||{}).forEach(function(e){s.push("key !== '"+e+"'")}),"object"===(void 0===i?"undefined":r(i))){var u=new e(i,{address:o+"[APKey]"});a+="\n        // validate additional properties\n        if ("+s.join(" && ")+") {\n          "+u.compile()+"\n        }\n      "}return!1===i&&(a+="\n        // validate non-presence of additional properties\n        if ("+s.join(" && ")+") {\n          valid = false\n          errors.push({\n            keyword: 'additionalProperties',\n            message: key + ' is not a defined property'\n          })\n        }\n      "),a}},{key:"patternProperties",value:function(){var e="";return this.otherPropertiesCalled||(this.otherPropertiesCalled=!0,e+=this.otherProperties()),e}},{key:"additionalProperties",value:function(){var e="";return this.otherPropertiesCalled||(this.otherPropertiesCalled=!0,e+=this.otherProperties()),e}},{key:"minProperties",value:function(){var e=this.schema.minProperties;return"\n        // "+this.address+" min properties\n        if (Object.keys(value).length < "+e+") {\n          valid = false\n          errors.push({\n            keyword: 'minProperties',\n            message: 'too few properties'\n          })\n        }\n    "}},{key:"maxProperties",value:function(){var e=this.schema.maxProperties;return"\n        // "+this.address+" max properties\n        if (Object.keys(value).length > "+e+") {\n          valid = false\n          errors.push({\n            keyword: 'maxProperties',\n            message: 'too many properties'\n          })\n        }\n    "}},{key:"dependencies",value:function(){var t=this.schema.dependencies,n=this.address,i=this.push();return"object"===(void 0===t?"undefined":r(t))&&Object.keys(t).forEach(function(o){var a=t[o],s=[];if(Array.isArray(a))a.forEach(function(e){s.push("container['"+e+"'] === undefined")}),i+="\n            if (container['"+o+"'] !== undefined && ("+s.join(" || ")+")) {\n              valid = false\n              errors.push({\n                keyword: 'dependencies',\n                message: 'unmet dependencies'\n              })\n            }\n          ";else if("object"===(void 0===a?"undefined":r(a))){var u=new e(a,{address:n});i+="\n            if (container['"+o+"'] !== undefined) {\n              "+u.compile()+"\n            }\n          "}}),i+=this.pop()}},{key:"required",value:function(){this.schema.properties;var e="";return e+="\n      // validate "+this.address+" presence\n      if (value === undefined) {\n        valid = false\n        errors.push({\n          keyword: 'required',\n          message: 'is required'\n        })\n      }\n    "}},{key:"additionalItems",value:function(){var t=this.schema,n=t.items,i=t.additionalItems,o=(this.address,"");if(!1===i&&Array.isArray(n)&&(o+="\n        // don't allow additional items\n        if (value.length > "+n.length+") {\n          valid = false\n          errors.push({\n            keyword: 'additionalItems',\n            message: 'additional items not allowed'\n          })\n        }\n      "),"object"===(void 0===i?"undefined":r(i))&&null!==i&&Array.isArray(n)){var a=new e(i),s=e.counter;o+="\n        // additional items\n        "+this.push()+"\n\n        for (var i"+s+" = "+n.length+"; i"+s+" <= container.length; i"+s+"++) {\n          value = container[i"+s+"]\n          "+a.compile()+"\n        }\n\n        "+this.pop()+"\n      "}return o}},{key:"items",value:function(){var t=this.schema.items,n=this.address,i="";if(Array.isArray(t))i+=this.push(),t.forEach(function(t,r){var o=new e(t,{address:n+"["+r+"]"});i+="\n          // item #"+r+"\n          value = container["+r+"]\n          "+o.compile()+"\n        "}),i+=this.pop();else if("object"===(void 0===t?"undefined":r(t))&&null!==t){var o=new e(t),a=e.counter;i+="\n        // items\n        "+this.push()+"\n\n        for (var i"+a+" = 0; i"+a+" < container.length; i"+a+"++) {\n          // read array element\n          value = container[i"+a+"]\n          "+o.compile()+"\n        }\n\n        "+this.pop()+"\n      "}return i}},{key:"minItems",value:function(){var e=this.schema.minItems;return"\n        // "+this.address+" min items\n        if (value.length < "+e+") {\n          valid = false\n          errors.push({\n            keyword: 'minItems',\n            message: 'too few properties'\n          })\n        }\n    "}},{key:"maxItems",value:function(){var e=this.schema.maxItems;return"\n        // "+this.address+" max items\n        if (value.length > "+e+") {\n          valid = false\n          errors.push({\n            keyword: 'maxItems',\n            message: 'too many properties'\n          })\n        }\n    "}},{key:"uniqueItems",value:function(){var e=this.schema.uniqueItems,t=this.address,n="";return!0===e&&(n+="\n        // validate "+t+" unique items\n        let values = value.map(v => JSON.stringify(v)) // TODO: optimize\n        let set = new Set(values)\n        if (values.length !== set.size) {\n          valid = false\n          errors.push({\n            keyword: 'uniqueItems',\n            message: 'items must be unique'\n          })\n        }\n      "),n}},{key:"minLength",value:function(){var e=this.schema.minLength;return"\n        // "+this.address+" validate minLength\n        if (Array.from(value).length < "+e+") {\n          valid = false\n          errors.push({\n            keyword: 'minLength',\n            message: 'too short'\n          })\n        }\n    "}},{key:"maxLength",value:function(){var e=this.schema.maxLength;return"\n        // "+this.address+" validate maxLength\n        if (Array.from(value).length > "+e+") {\n          valid = false\n          errors.push({\n            keyword: 'maxLength',\n            message: 'too long'\n          })\n        }\n    "}},{key:"pattern",value:function(){var e=this.schema.pattern,t=this.address;if(e)return"\n          // "+t+" validate pattern\n          if (!value.match(new RegExp('"+e+"'))) {\n            valid = false\n            errors.push({\n              keyword: 'pattern',\n              message: 'does not match the required pattern'\n            })\n          }\n      "}},{key:"format",value:function(){var e=this.schema.format,t=this.address,n=o.resolve(e);if(n)return"\n      // "+t+" validate format\n      if (!value.match("+n+")) {\n        valid = false\n        errors.push({\n          keyword: 'format',\n          message: 'is not \""+e+"\" format'\n        })\n      }\n      "}},{key:"minimum",value:function(){var e=this.schema,t=e.minimum,n=e.exclusiveMinimum;return"\n        // "+this.address+" validate minimum\n        if (value "+(!0===n?"<=":"<")+" "+t+") {\n          valid = false\n          errors.push({\n            keyword: 'minimum',\n            message: 'too small'\n          })\n        }\n    "}},{key:"maximum",value:function(){var e=this.schema,t=e.maximum,n=e.exclusiveMaximum;return"\n        // "+this.address+" validate maximum\n        if (value "+(!0===n?">=":">")+" "+t+") {\n          valid = false\n          errors.push({\n            keyword: 'maximum',\n            message: 'too large'\n          })\n        }\n    "}},{key:"multipleOf",value:function(){var e=this.schema.multipleOf,t="";if("number"==typeof e){var n=e.toString().length-e.toFixed(0).length-1,r=n>0?Math.pow(10,n):1;t+="\n        if ("+(n>0?"(value * "+r+") % "+e*r+" !== 0":"value % "+e+" !== 0")+") {\n          valid = false\n          errors.push({\n            keyword: 'multipleOf',\n            message: 'must be a multiple of "+e+"'\n          })\n        }\n      "}return t}}]),e}();e.exports=s},function(e,t,n){"use strict";var r=n(38),i=n(57),o=n(60),a=n(62),s=n(67),u=n(64),c=n(66),l=n(58),f=n(61),h=n(65),p=n(63);e.exports={JWA:r,JWK:i,JWKSet:o,JWT:a,JWS:s,Base64URLSchema:u,JOSEHeaderSchema:c,JWKSchema:l,JWKSetSchema:f,JWTClaimsSetSchema:h,JWTSchema:p}},function(e,t,n){"use strict";var r=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}();n(39);var i=n(46),o=n(55).NotSupportedError,a=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e)}return r(e,null,[{key:"sign",value:function(e,t,n){var r=i.normalize("sign",e);return r instanceof Error?Promise.reject(new o(e)):r.sign(t,n)}},{key:"verify",value:function(e,t,n,r){var a=i.normalize("verify",e);return a instanceof Error?Promise.reject(new o(e)):a.verify(t,n,r)}},{key:"importKey",value:function(e){return i.normalize("importKey",e.alg).importKey(e)}}]),e}();e.exports=a},function(e,t,n){e.exports=n(40).default,e.exports.default=e.exports},function(e,t,n){"use strict";(function(e){Object.defineProperty(t,"__esModule",{value:!0});const r=n(45);function i(t,n="utf8"){return e.isBuffer(t)?a(t.toString("base64")):a(e.from(t,n).toString("base64"))}function o(e){return e=e.toString(),r.default(e).replace(/\-/g,"+").replace(/_/g,"/")}function a(e){return e.replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}let s=i;s.encode=i,s.decode=function(t,n="utf8"){return e.from(o(t),"base64").toString(n)},s.toBase64=o,s.fromBase64=a,s.toBuffer=function(t){return e.from(o(t),"base64")},t.default=s}).call(this,n(41).Buffer)},function(e,t,n){"use strict";(function(e){
  /*!
   * The buffer module from node.js, for the browser.
   *
   * @author   Feross Aboukhadijeh <feross@feross.org> <http://feross.org>
   * @license  MIT
   */
  var r=n(42),i=n(43),o=n(44);function a(){return u.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function s(e,t){if(a()<t)throw new RangeError("Invalid typed array length");return u.TYPED_ARRAY_SUPPORT?(e=new Uint8Array(t)).__proto__=u.prototype:(null===e&&(e=new u(t)),e.length=t),e}function u(e,t,n){if(!(u.TYPED_ARRAY_SUPPORT||this instanceof u))return new u(e,t,n);if("number"==typeof e){if("string"==typeof t)throw new Error("If encoding is specified then the first argument must be a string");return f(this,e)}return c(this,e,t,n)}function c(e,t,n,r){if("number"==typeof t)throw new TypeError('"value" argument must not be a number');return"undefined"!=typeof ArrayBuffer&&t instanceof ArrayBuffer?function(e,t,n,r){if(t.byteLength,n<0||t.byteLength<n)throw new RangeError("'offset' is out of bounds");if(t.byteLength<n+(r||0))throw new RangeError("'length' is out of bounds");t=void 0===n&&void 0===r?new Uint8Array(t):void 0===r?new Uint8Array(t,n):new Uint8Array(t,n,r);u.TYPED_ARRAY_SUPPORT?(e=t).__proto__=u.prototype:e=h(e,t);return e}(e,t,n,r):"string"==typeof t?function(e,t,n){"string"==typeof n&&""!==n||(n="utf8");if(!u.isEncoding(n))throw new TypeError('"encoding" must be a valid string encoding');var r=0|d(t,n),i=(e=s(e,r)).write(t,n);i!==r&&(e=e.slice(0,i));return e}(e,t,n):function(e,t){if(u.isBuffer(t)){var n=0|p(t.length);return 0===(e=s(e,n)).length?e:(t.copy(e,0,0,n),e)}if(t){if("undefined"!=typeof ArrayBuffer&&t.buffer instanceof ArrayBuffer||"length"in t)return"number"!=typeof t.length||(r=t.length)!=r?s(e,0):h(e,t);if("Buffer"===t.type&&o(t.data))return h(e,t.data)}var r;throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}(e,t)}function l(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 f(e,t){if(l(t),e=s(e,t<0?0:0|p(t)),!u.TYPED_ARRAY_SUPPORT)for(var n=0;n<t;++n)e[n]=0;return e}function h(e,t){var n=t.length<0?0:0|p(t.length);e=s(e,n);for(var r=0;r<n;r+=1)e[r]=255&t[r];return e}function p(e){if(e>=a())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+a().toString(16)+" bytes");return 0|e}function d(e,t){if(u.isBuffer(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var n=e.length;if(0===n)return 0;for(var r=!1;;)switch(t){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":case void 0:return B(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return q(e).length;default:if(r)return B(e).length;t=(""+t).toLowerCase(),r=!0}}function y(e,t,n){var r=e[t];e[t]=e[n],e[n]=r}function v(e,t,n,r,i){if(0===e.length)return-1;if("string"==typeof n?(r=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),n=+n,isNaN(n)&&(n=i?0:e.length-1),n<0&&(n=e.length+n),n>=e.length){if(i)return-1;n=e.length-1}else if(n<0){if(!i)return-1;n=0}if("string"==typeof t&&(t=u.from(t,r)),u.isBuffer(t))return 0===t.length?-1:g(e,t,n,r,i);if("number"==typeof t)return t&=255,u.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,n):Uint8Array.prototype.lastIndexOf.call(e,t,n):g(e,[t],n,r,i);throw new TypeError("val must be string, number or Buffer")}function g(e,t,n,r,i){var o,a=1,s=e.length,u=t.length;if(void 0!==r&&("ucs2"===(r=String(r).toLowerCase())||"ucs-2"===r||"utf16le"===r||"utf-16le"===r)){if(e.length<2||t.length<2)return-1;a=2,s/=2,u/=2,n/=2}function c(e,t){return 1===a?e[t]:e.readUInt16BE(t*a)}if(i){var l=-1;for(o=n;o<s;o++)if(c(e,o)===c(t,-1===l?0:o-l)){if(-1===l&&(l=o),o-l+1===u)return l*a}else-1!==l&&(o-=o-l),l=-1}else for(n+u>s&&(n=s-u),o=n;o>=0;o--){for(var f=!0,h=0;h<u;h++)if(c(e,o+h)!==c(t,h)){f=!1;break}if(f)return o}return-1}function m(e,t,n,r){n=Number(n)||0;var i=e.length-n;r?(r=Number(r))>i&&(r=i):r=i;var o=t.length;if(o%2!=0)throw new TypeError("Invalid hex string");r>o/2&&(r=o/2);for(var a=0;a<r;++a){var s=parseInt(t.substr(2*a,2),16);if(isNaN(s))return a;e[n+a]=s}return a}function w(e,t,n,r){return z(B(t,e.length-n),e,n,r)}function b(e,t,n,r){return z(function(e){for(var t=[],n=0;n<e.length;++n)t.push(255&e.charCodeAt(n));return t}(t),e,n,r)}function x(e,t,n,r){return b(e,t,n,r)}function _(e,t,n,r){return z(q(t),e,n,r)}function k(e,t,n,r){return z(function(e,t){for(var n,r,i,o=[],a=0;a<e.length&&!((t-=2)<0);++a)n=e.charCodeAt(a),r=n>>8,i=n%256,o.push(i),o.push(r);return o}(t,e.length-n),e,n,r)}function S(e,t,n){return 0===t&&n===e.length?r.fromByteArray(e):r.fromByteArray(e.slice(t,n))}function T(e,t,n){n=Math.min(e.length,n);for(var r=[],i=t;i<n;){var o,a,s,u,c=e[i],l=null,f=c>239?4:c>223?3:c>191?2:1;if(i+f<=n)switch(f){case 1:c<128&&(l=c);break;case 2:128==(192&(o=e[i+1]))&&(u=(31&c)<<6|63&o)>127&&(l=u);break;case 3:o=e[i+1],a=e[i+2],128==(192&o)&&128==(192&a)&&(u=(15&c)<<12|(63&o)<<6|63&a)>2047&&(u<55296||u>57343)&&(l=u);break;case 4:o=e[i+1],a=e[i+2],s=e[i+3],128==(192&o)&&128==(192&a)&&128==(192&s)&&(u=(15&c)<<18|(63&o)<<12|(63&a)<<6|63&s)>65535&&u<1114112&&(l=u)}null===l?(l=65533,f=1):l>65535&&(l-=65536,r.push(l>>>10&1023|55296),l=56320|1023&l),r.push(l),i+=f}return function(e){var t=e.length;if(t<=E)return String.fromCharCode.apply(String,e);var n="",r=0;for(;r<t;)n+=String.fromCharCode.apply(String,e.slice(r,r+=E));return n}(r)}t.Buffer=u,t.SlowBuffer=function(e){+e!=e&&(e=0);return u.alloc(+e)},t.INSPECT_MAX_BYTES=50,u.TYPED_ARRAY_SUPPORT=void 0!==e.TYPED_ARRAY_SUPPORT?e.TYPED_ARRAY_SUPPORT:function(){try{var e=new Uint8Array(1);return e.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===e.foo()&&"function"==typeof e.subarray&&0===e.subarray(1,1).byteLength}catch(e){return!1}}(),t.kMaxLength=a(),u.poolSize=8192,u._augment=function(e){return e.__proto__=u.prototype,e},u.from=function(e,t,n){return c(null,e,t,n)},u.TYPED_ARRAY_SUPPORT&&(u.prototype.__proto__=Uint8Array.prototype,u.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&u[Symbol.species]===u&&Object.defineProperty(u,Symbol.species,{value:null,configurable:!0})),u.alloc=function(e,t,n){return function(e,t,n,r){return l(t),t<=0?s(e,t):void 0!==n?"string"==typeof r?s(e,t).fill(n,r):s(e,t).fill(n):s(e,t)}(null,e,t,n)},u.allocUnsafe=function(e){return f(null,e)},u.allocUnsafeSlow=function(e){return f(null,e)},u.isBuffer=function(e){return!(null==e||!e._isBuffer)},u.compare=function(e,t){if(!u.isBuffer(e)||!u.isBuffer(t))throw new TypeError("Arguments must be Buffers");if(e===t)return 0;for(var n=e.length,r=t.length,i=0,o=Math.min(n,r);i<o;++i)if(e[i]!==t[i]){n=e[i],r=t[i];break}return n<r?-1:r<n?1:0},u.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}},u.concat=function(e,t){if(!o(e))throw new TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return u.alloc(0);var n;if(void 0===t)for(t=0,n=0;n<e.length;++n)t+=e[n].length;var r=u.allocUnsafe(t),i=0;for(n=0;n<e.length;++n){var a=e[n];if(!u.isBuffer(a))throw new TypeError('"list" argument must be an Array of Buffers');a.copy(r,i),i+=a.length}return r},u.byteLength=d,u.prototype._isBuffer=!0,u.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)y(this,t,t+1);return this},u.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)y(this,t,t+3),y(this,t+1,t+2);return this},u.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)y(this,t,t+7),y(this,t+1,t+6),y(this,t+2,t+5),y(this,t+3,t+4);return this},u.prototype.toString=function(){var e=0|this.length;return 0===e?"":0===arguments.length?T(this,0,e):function(e,t,n){var r=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===n||n>this.length)&&(n=this.length),n<=0)return"";if((n>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return N(this,t,n);case"utf8":case"utf-8":return T(this,t,n);case"ascii":return O(this,t,n);case"latin1":case"binary":return j(this,t,n);case"base64":return S(this,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return I(this,t,n);default:if(r)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),r=!0}}.apply(this,arguments)},u.prototype.equals=function(e){if(!u.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e||0===u.compare(this,e)},u.prototype.inspect=function(){var e="",n=t.INSPECT_MAX_BYTES;return this.length>0&&(e=this.toString("hex",0,n).match(/.{2}/g).join(" "),this.length>n&&(e+=" ... ")),"<Buffer "+e+">"},u.prototype.compare=function(e,t,n,r,i){if(!u.isBuffer(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===n&&(n=e?e.length:0),void 0===r&&(r=0),void 0===i&&(i=this.length),t<0||n>e.length||r<0||i>this.length)throw new RangeError("out of range index");if(r>=i&&t>=n)return 0;if(r>=i)return-1;if(t>=n)return 1;if(this===e)return 0;for(var o=(i>>>=0)-(r>>>=0),a=(n>>>=0)-(t>>>=0),s=Math.min(o,a),c=this.slice(r,i),l=e.slice(t,n),f=0;f<s;++f)if(c[f]!==l[f]){o=c[f],a=l[f];break}return o<a?-1:a<o?1:0},u.prototype.includes=function(e,t,n){return-1!==this.indexOf(e,t,n)},u.prototype.indexOf=function(e,t,n){return v(this,e,t,n,!0)},u.prototype.lastIndexOf=function(e,t,n){return v(this,e,t,n,!1)},u.prototype.write=function(e,t,n,r){if(void 0===t)r="utf8",n=this.length,t=0;else if(void 0===n&&"string"==typeof t)r=t,n=this.length,t=0;else{if(!isFinite(t))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");t|=0,isFinite(n)?(n|=0,void 0===r&&(r="utf8")):(r=n,n=void 0)}var i=this.length-t;if((void 0===n||n>i)&&(n=i),e.length>0&&(n<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");r||(r="utf8");for(var o=!1;;)switch(r){case"hex":return m(this,e,t,n);case"utf8":case"utf-8":return w(this,e,t,n);case"ascii":return b(this,e,t,n);case"latin1":case"binary":return x(this,e,t,n);case"base64":return _(this,e,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return k(this,e,t,n);default:if(o)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),o=!0}},u.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var E=4096;function O(e,t,n){var r="";n=Math.min(e.length,n);for(var i=t;i<n;++i)r+=String.fromCharCode(127&e[i]);return r}function j(e,t,n){var r="";n=Math.min(e.length,n);for(var i=t;i<n;++i)r+=String.fromCharCode(e[i]);return r}function N(e,t,n){var r=e.length;(!t||t<0)&&(t=0),(!n||n<0||n>r)&&(n=r);for(var i="",o=t;o<n;++o)i+=F(e[o]);return i}function I(e,t,n){for(var r=e.slice(t,n),i="",o=0;o<r.length;o+=2)i+=String.fromCharCode(r[o]+256*r[o+1]);return i}function R(e,t,n){if(e%1!=0||e<0)throw new RangeError("offset is not uint");if(e+t>n)throw new RangeError("Trying to access beyond buffer length")}function A(e,t,n,r,i,o){if(!u.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||t<o)throw new RangeError('"value" argument is out of bounds');if(n+r>e.length)throw new RangeError("Index out of range")}function C(e,t,n,r){t<0&&(t=65535+t+1);for(var i=0,o=Math.min(e.length-n,2);i<o;++i)e[n+i]=(t&255<<8*(r?i:1-i))>>>8*(r?i:1-i)}function P(e,t,n,r){t<0&&(t=4294967295+t+1);for(var i=0,o=Math.min(e.length-n,4);i<o;++i)e[n+i]=t>>>8*(r?i:3-i)&255}function L(e,t,n,r,i,o){if(n+r>e.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function D(e,t,n,r,o){return o||L(e,0,n,4),i.write(e,t,n,r,23,4),n+4}function U(e,t,n,r,o){return o||L(e,0,n,8),i.write(e,t,n,r,52,8),n+8}u.prototype.slice=function(e,t){var n,r=this.length;if((e=~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),(t=void 0===t?r:~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),t<e&&(t=e),u.TYPED_ARRAY_SUPPORT)(n=this.subarray(e,t)).__proto__=u.prototype;else{var i=t-e;n=new u(i,void 0);for(var o=0;o<i;++o)n[o]=this[o+e]}return n},u.prototype.readUIntLE=function(e,t,n){e|=0,t|=0,n||R(e,t,this.length);for(var r=this[e],i=1,o=0;++o<t&&(i*=256);)r+=this[e+o]*i;return r},u.prototype.readUIntBE=function(e,t,n){e|=0,t|=0,n||R(e,t,this.length);for(var r=this[e+--t],i=1;t>0&&(i*=256);)r+=this[e+--t]*i;return r},u.prototype.readUInt8=function(e,t){return t||R(e,1,this.length),this[e]},u.prototype.readUInt16LE=function(e,t){return t||R(e,2,this.length),this[e]|this[e+1]<<8},u.prototype.readUInt16BE=function(e,t){return t||R(e,2,this.length),this[e]<<8|this[e+1]},u.prototype.readUInt32LE=function(e,t){return t||R(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},u.prototype.readUInt32BE=function(e,t){return t||R(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},u.prototype.readIntLE=function(e,t,n){e|=0,t|=0,n||R(e,t,this.length);for(var r=this[e],i=1,o=0;++o<t&&(i*=256);)r+=this[e+o]*i;return r>=(i*=128)&&(r-=Math.pow(2,8*t)),r},u.prototype.readIntBE=function(e,t,n){e|=0,t|=0,n||R(e,t,this.length);for(var r=t,i=1,o=this[e+--r];r>0&&(i*=256);)o+=this[e+--r]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*t)),o},u.prototype.readInt8=function(e,t){return t||R(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},u.prototype.readInt16LE=function(e,t){t||R(e,2,this.length);var n=this[e]|this[e+1]<<8;return 32768&n?4294901760|n:n},u.prototype.readInt16BE=function(e,t){t||R(e,2,this.length);var n=this[e+1]|this[e]<<8;return 32768&n?4294901760|n:n},u.prototype.readInt32LE=function(e,t){return t||R(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},u.prototype.readInt32BE=function(e,t){return t||R(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},u.prototype.readFloatLE=function(e,t){return t||R(e,4,this.length),i.read(this,e,!0,23,4)},u.prototype.readFloatBE=function(e,t){return t||R(e,4,this.length),i.read(this,e,!1,23,4)},u.prototype.readDoubleLE=function(e,t){return t||R(e,8,this.length),i.read(this,e,!0,52,8)},u.prototype.readDoubleBE=function(e,t){return t||R(e,8,this.length),i.read(this,e,!1,52,8)},u.prototype.writeUIntLE=function(e,t,n,r){(e=+e,t|=0,n|=0,r)||A(this,e,t,n,Math.pow(2,8*n)-1,0);var i=1,o=0;for(this[t]=255&e;++o<n&&(i*=256);)this[t+o]=e/i&255;return t+n},u.prototype.writeUIntBE=function(e,t,n,r){(e=+e,t|=0,n|=0,r)||A(this,e,t,n,Math.pow(2,8*n)-1,0);var i=n-1,o=1;for(this[t+i]=255&e;--i>=0&&(o*=256);)this[t+i]=e/o&255;return t+n},u.prototype.writeUInt8=function(e,t,n){return e=+e,t|=0,n||A(this,e,t,1,255,0),u.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},u.prototype.writeUInt16LE=function(e,t,n){return e=+e,t|=0,n||A(this,e,t,2,65535,0),u.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):C(this,e,t,!0),t+2},u.prototype.writeUInt16BE=function(e,t,n){return e=+e,t|=0,n||A(this,e,t,2,65535,0),u.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):C(this,e,t,!1),t+2},u.prototype.writeUInt32LE=function(e,t,n){return e=+e,t|=0,n||A(this,e,t,4,4294967295,0),u.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):P(this,e,t,!0),t+4},u.prototype.writeUInt32BE=function(e,t,n){return e=+e,t|=0,n||A(this,e,t,4,4294967295,0),u.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):P(this,e,t,!1),t+4},u.prototype.writeIntLE=function(e,t,n,r){if(e=+e,t|=0,!r){var i=Math.pow(2,8*n-1);A(this,e,t,n,i-1,-i)}var o=0,a=1,s=0;for(this[t]=255&e;++o<n&&(a*=256);)e<0&&0===s&&0!==this[t+o-1]&&(s=1),this[t+o]=(e/a>>0)-s&255;return t+n},u.prototype.writeIntBE=function(e,t,n,r){if(e=+e,t|=0,!r){var i=Math.pow(2,8*n-1);A(this,e,t,n,i-1,-i)}var o=n-1,a=1,s=0;for(this[t+o]=255&e;--o>=0&&(a*=256);)e<0&&0===s&&0!==this[t+o+1]&&(s=1),this[t+o]=(e/a>>0)-s&255;return t+n},u.prototype.writeInt8=function(e,t,n){return e=+e,t|=0,n||A(this,e,t,1,127,-128),u.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},u.prototype.writeInt16LE=function(e,t,n){return e=+e,t|=0,n||A(this,e,t,2,32767,-32768),u.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):C(this,e,t,!0),t+2},u.prototype.writeInt16BE=function(e,t,n){return e=+e,t|=0,n||A(this,e,t,2,32767,-32768),u.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):C(this,e,t,!1),t+2},u.prototype.writeInt32LE=function(e,t,n){return e=+e,t|=0,n||A(this,e,t,4,2147483647,-2147483648),u.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):P(this,e,t,!0),t+4},u.prototype.writeInt32BE=function(e,t,n){return e=+e,t|=0,n||A(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),u.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):P(this,e,t,!1),t+4},u.prototype.writeFloatLE=function(e,t,n){return D(this,e,t,!0,n)},u.prototype.writeFloatBE=function(e,t,n){return D(this,e,t,!1,n)},u.prototype.writeDoubleLE=function(e,t,n){return U(this,e,t,!0,n)},u.prototype.writeDoubleBE=function(e,t,n){return U(this,e,t,!1,n)},u.prototype.copy=function(e,t,n,r){if(n||(n=0),r||0===r||(r=this.length),t>=e.length&&(t=e.length),t||(t=0),r>0&&r<n&&(r=n),r===n)return 0;if(0===e.length||0===this.length)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("sourceStart out of bounds");if(r<0)throw new RangeError("sourceEnd out of bounds");r>this.length&&(r=this.length),e.length-t<r-n&&(r=e.length-t+n);var i,o=r-n;if(this===e&&n<t&&t<r)for(i=o-1;i>=0;--i)e[i+t]=this[i+n];else if(o<1e3||!u.TYPED_ARRAY_SUPPORT)for(i=0;i<o;++i)e[i+t]=this[i+n];else Uint8Array.prototype.set.call(e,this.subarray(n,n+o),t);return o},u.prototype.fill=function(e,t,n,r){if("string"==typeof e){if("string"==typeof t?(r=t,t=0,n=this.length):"string"==typeof n&&(r=n,n=this.length),1===e.length){var i=e.charCodeAt(0);i<256&&(e=i)}if(void 0!==r&&"string"!=typeof r)throw new TypeError("encoding must be a string");if("string"==typeof r&&!u.isEncoding(r))throw new TypeError("Unknown encoding: "+r)}else"number"==typeof e&&(e&=255);if(t<0||this.length<t||this.length<n)throw new RangeError("Out of range index");if(n<=t)return this;var o;if(t>>>=0,n=void 0===n?this.length:n>>>0,e||(e=0),"number"==typeof e)for(o=t;o<n;++o)this[o]=e;else{var a=u.isBuffer(e)?e:B(new u(e,r).toString()),s=a.length;for(o=0;o<n-t;++o)this[o+t]=a[o%s]}return this};var M=/[^+\/0-9A-Za-z-_]/g;function F(e){return e<16?"0"+e.toString(16):e.toString(16)}function B(e,t){var n;t=t||1/0;for(var r=e.length,i=null,o=[],a=0;a<r;++a){if((n=e.charCodeAt(a))>55295&&n<57344){if(!i){if(n>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(a+1===r){(t-=3)>-1&&o.push(239,191,189);continue}i=n;continue}if(n<56320){(t-=3)>-1&&o.push(239,191,189),i=n;continue}n=65536+(i-55296<<10|n-56320)}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,n<128){if((t-=1)<0)break;o.push(n)}else if(n<2048){if((t-=2)<0)break;o.push(n>>6|192,63&n|128)}else if(n<65536){if((t-=3)<0)break;o.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(n<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return o}function q(e){return r.toByteArray(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(M,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function z(e,t,n,r){for(var i=0;i<r&&!(i+n>=t.length||i>=e.length);++i)t[i+n]=e[i];return i}}).call(this,n(21))},function(e,t,n){"use strict";t.byteLength=function(e){var t=c(e),n=t[0],r=t[1];return 3*(n+r)/4-r},t.toByteArray=function(e){for(var t,n=c(e),r=n[0],a=n[1],s=new o(function(e,t,n){return 3*(t+n)/4-n}(0,r,a)),u=0,l=a>0?r-4:r,f=0;f<l;f+=4)t=i[e.charCodeAt(f)]<<18|i[e.charCodeAt(f+1)]<<12|i[e.charCodeAt(f+2)]<<6|i[e.charCodeAt(f+3)],s[u++]=t>>16&255,s[u++]=t>>8&255,s[u++]=255&t;2===a&&(t=i[e.charCodeAt(f)]<<2|i[e.charCodeAt(f+1)]>>4,s[u++]=255&t);1===a&&(t=i[e.charCodeAt(f)]<<10|i[e.charCodeAt(f+1)]<<4|i[e.charCodeAt(f+2)]>>2,s[u++]=t>>8&255,s[u++]=255&t);return s},t.fromByteArray=function(e){for(var t,n=e.length,i=n%3,o=[],a=0,s=n-i;a<s;a+=16383)o.push(l(e,a,a+16383>s?s:a+16383));1===i?(t=e[n-1],o.push(r[t>>2]+r[t<<4&63]+"==")):2===i&&(t=(e[n-2]<<8)+e[n-1],o.push(r[t>>10]+r[t>>4&63]+r[t<<2&63]+"="));return o.join("")};for(var r=[],i=[],o="undefined"!=typeof Uint8Array?Uint8Array:Array,a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0,u=a.length;s<u;++s)r[s]=a[s],i[a.charCodeAt(s)]=s;function c(e){var t=e.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var n=e.indexOf("=");return-1===n&&(n=t),[n,n===t?0:4-n%4]}function l(e,t,n){for(var i,o,a=[],s=t;s<n;s+=3)i=(e[s]<<16&16711680)+(e[s+1]<<8&65280)+(255&e[s+2]),a.push(r[(o=i)>>18&63]+r[o>>12&63]+r[o>>6&63]+r[63&o]);return a.join("")}i["-".charCodeAt(0)]=62,i["_".charCodeAt(0)]=63},function(e,t){t.read=function(e,t,n,r,i){var o,a,s=8*i-r-1,u=(1<<s)-1,c=u>>1,l=-7,f=n?i-1:0,h=n?-1:1,p=e[t+f];for(f+=h,o=p&(1<<-l)-1,p>>=-l,l+=s;l>0;o=256*o+e[t+f],f+=h,l-=8);for(a=o&(1<<-l)-1,o>>=-l,l+=r;l>0;a=256*a+e[t+f],f+=h,l-=8);if(0===o)o=1-c;else{if(o===u)return a?NaN:1/0*(p?-1:1);a+=Math.pow(2,r),o-=c}return(p?-1:1)*a*Math.pow(2,o-r)},t.write=function(e,t,n,r,i,o){var a,s,u,c=8*o-i-1,l=(1<<c)-1,f=l>>1,h=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,p=r?0:o-1,d=r?1:-1,y=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(s=isNaN(t)?1:0,a=l):(a=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-a))<1&&(a--,u*=2),(t+=a+f>=1?h/u:h*Math.pow(2,1-f))*u>=2&&(a++,u/=2),a+f>=l?(s=0,a=l):a+f>=1?(s=(t*u-1)*Math.pow(2,i),a+=f):(s=t*Math.pow(2,f-1)*Math.pow(2,i),a=0));i>=8;e[n+p]=255&s,p+=d,s/=256,i-=8);for(a=a<<i|s,c+=i;c>0;e[n+p]=255&a,p+=d,a/=256,c-=8);e[n+p-d]|=128*y}},function(e,t){var n={}.toString;e.exports=Array.isArray||function(e){return"[object Array]"==n.call(e)}},function(e,t,n){"use strict";(function(e){Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(t){let n=t.length,r=n%4;if(!r)return t;let i=n,o=4-r,a=n+o,s=e.alloc(a);for(s.write(t);o--;)s.write("=",i++);return s.toString()}}).call(this,n(41).Buffer)},function(e,t,n){"use strict";var r=n(47),i=n(48),o=n(52),a=new(n(53));a.define("HS256","sign",new i({name:"HMAC",hash:{name:"SHA-256"}})),a.define("HS384","sign",new i({name:"HMAC",hash:{name:"SHA-384"}})),a.define("HS512","sign",new i({name:"HMAC",hash:{name:"SHA-512"}})),a.define("RS256","sign",new o({name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}})),a.define("RS384","sign",new o({name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-384"}})),a.define("RS512","sign",new o({name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-512"}})),a.define("none","sign",new r({})),a.define("HS256","verify",new i({name:"HMAC",hash:{name:"SHA-256"}})),a.define("HS384","verify",new i({name:"HMAC",hash:{name:"SHA-384"}})),a.define("HS512","verify",new i({name:"HMAC",hash:{name:"SHA-512"}})),a.define("RS256","verify",new o({name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}})),a.define("RS384","verify",new o({name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-384"}})),a.define("RS512","verify",new o({name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-512"}})),a.define("none","verify",new r({})),a.define("RS256","importKey",new o({name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}})),a.define("RS384","importKey",new o({name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-384"}})),a.define("RS512","importKey",new o({name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-512"}})),e.exports=a},function(e,t,n){"use strict";var r=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}();var i=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e)}return r(e,[{key:"sign",value:function(){return Promise.resolve("")}},{key:"verify",value:function(){}}]),e}();e.exports=i},function(e,t,n){"use strict";(function(t){var r=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}();var i=n(39),o=n(49),a=n(50),s=function(){function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.params=t}return r(e,[{key:"sign",value:function(e,n){var r=this.params;return n=(new a).encode(n),o.subtle.sign(r,e,n).then(function(e){return i(t.from(e))})}},{key:"verify",value:function(e,t,n){var r=this.params;return"string"==typeof t&&(t=Uint8Array.from(i.toBuffer(t))),"string"==typeof n&&(n=(new a).encode(n)),o.subtle.verify(r,e,t,n)}},{key:"assertSufficientKeyLength",value:function(e){if(e.length<this.bitlength)throw new Error("The key is too short.")}}]),e}();e.exports=s}).call(this,n(41).Buffer)},function(e,t){e.exports=window.crypto},function(e,t,n){"use strict";(function(t){var r=t.TextEncoder?t.TextEncoder:n(51).TextEncoder;e.exports=r}).call(this,n(21))},function(e,t){e.exports=window.TextEncoder},function(e,t,n){"use strict";(function(t){var r=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}();var i=n(39),o=n(49),a=n(50),s=function(){function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.params=t}return r(e,[{key:"sign",value:function(e,n){var r=this.params;return n=(new a).encode(n),o.subtle.sign(r,e,n).then(function(e){return i(t.from(e))})}},{key:"verify",value:function(e,t,n){var r=this.params;return"string"==typeof t&&(t=Uint8Array.from(i.toBuffer(t))),"string"==typeof n&&(n=(new a).encode(n)),o.subtle.verify(r,e,t,n)}},{key:"importKey",value:function(e){var t=Object.assign({},e),n=this.params,r=e.key_ops||[];return"sig"===e.use&&r.push("verify"),"enc"===e.use?Promise.resolve(e):(e.key_ops&&(r=e.key_ops),o.subtle.importKey("jwk",t,n,!0,r).then(function(e){return Object.defineProperty(t,"cryptoKey",{enumerable:!1,value:e}),t}))}}]),e}();e.exports=s}).call(this,n(41).Buffer)},function(e,t,n){"use strict";var r=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}();var i=n(54),o=["sign","verify","encrypt","decrypt","importKey"],a=function(){function e(){var t=this;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),o.forEach(function(e){t[e]={}})}return r(e,[{key:"define",value:function(e,t,n){this[t][e]=n}},{key:"normalize",value:function(e,t){var n=this[e];if(!n)return new SyntaxError;var r=n[t];return r||new i(t)}}],[{key:"operations",get:function(){return o}}]),e}();e.exports=a},function(e,t,n){"use strict";var r=function(e){function t(e){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);var n=function(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}(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return n.message=e+" is not a supported algorithm",n}return function(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)}(t,Error),t}();e.exports=r},function(e,t,n){"use strict";e.exports={DataError:n(56),NotSupportedError:n(54)}},function(e,t,n){"use strict";var r=function(e){function t(e){return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),function(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}(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e))}return function(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)}(t,Error),t}();e.exports=r},function(e,t,n){"use strict";var r=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}();var i=n(28).JSONDocument,o=n(58),a=n(38),s=function(e){function t(){return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),function(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}(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return function(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)}(t,i),r(t,null,[{key:"importKey",value:function(e){return a.importKey(e)}},{key:"schema",get:function(){return o}}]),t}();e.exports=s},function(e,t,n){"use strict";var r=n(28).JSONSchema,i=(n(59).BASE64_REGEXP,new r({type:"object",properties:{kty:{type:"string",enum:["RSA","EC","oct"]},use:{type:"string",enum:["sig","enc"]},key_ops:{type:"array",items:{enum:["sign","verify","encrypt","decrypt","wrapKey","unwrapKey","deriveKey","deriveBits"]}},alg:{type:"string",enum:["HS256","HS384","HS512","RS256","RS384","RS512","ES256","ES384","ES512","PS256","PS384","PS512","none"]},kid:{type:"string"},x5u:{type:"string"},x5c:{type:"array"},x5t:{type:"string"}}}));e.exports=i},function(e,t,n){"use strict";var r=n(28).Formats;r.register("StringOrURI",new RegExp),r.register("NumericDate",new RegExp),r.register("URI",new RegExp),r.register("url",new RegExp),r.register("base64",new RegExp),r.register("base64url",new RegExp),r.register("MediaType",new RegExp)},function(e,t,n){"use strict";var r=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}();var i=n(28).JSONDocument,o=n(61),a=n(57),s=function(e){function t(){return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),function(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}(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return function(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)}(t,i),r(t,null,[{key:"importKeys",value:function(e){var n=this.schema.validate(e);if(!n.valid)return Promise.reject(new Error("Invalid JWKSet: "+JSON.stringify(n,null,2)));if(!e.keys)return Promise.reject(new Error("Cannot import JWKSet: keys property is empty"));var r=void 0,i=void 0;try{r=new t(e),i=e.keys.map(function(e){return a.importKey(e)})}catch(e){return Promise.reject(e)}return Promise.all(i).then(function(e){return r.keys=e,r})}},{key:"schema",get:function(){return o}}]),t}();e.exports=s},function(e,t,n){"use strict";var r=new(0,n(28).JSONSchema)({type:"object",properties:{keys:{type:"array",items:n(58)}}});e.exports=r},function(e,t,n){"use strict";var r="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},i=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}();var o=n(39),a=n(28).JSONDocument,s=n(63),u=n(67),c=n(56),l=function(e){function t(){return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),function(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}(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return function(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)}(t,a),i(t,[{key:"isJWE",value:function(){return!!this.header.enc}},{key:"resolveKeys",value:function(e){var t=this.header.kid,n=void 0,i=void 0;if(Array.isArray(e)&&(n=e),e.keys&&(n=e.keys),e.keys||"object"!==(void 0===e?"undefined":r(e))||(n=[e]),!n)throw new c("Invalid JWK argument");return!!(i=t?n.find(function(e){return e.kid===t}):n.find(function(e){return"sig"===e.use}))&&(this.key=i.cryptoKey,!0)}},{key:"encode",value:function(){var e=this.validate();if(!e.valid)return Promise.reject(e);return this.isJWE()?JWE.encrypt(this):u.sign(this)}},{key:"verify",value:function(){var e=this.validate();return e.valid?u.verify(this):Promise.reject(e)}}],[{key:"decode",value:function(e){var t=void 0;if("string"!=typeof e)throw new c("JWT must be a string");if(e.startsWith("{")){try{e=JSON.parse(e,function(){})}catch(e){throw new c("Invalid JWT serialization")}e.signatures||e.recipients?e.serialization="json":e.serialization="flattened",t=new this(e,{filter:!1})}else try{var n=e.split("."),r=n.length;if(3!==r&&5!==r)throw new Error("Malformed JWT");var i=JSON.parse(o.decode(n[0]));if(3===r){t=new this({type:"JWS",segments:n,header:i,payload:JSON.parse(o.decode(n[1])),signature:n[2],serialization:"compact"},{filter:!1})}}catch(e){throw new c("Invalid JWT compact serialization")}return t}},{key:"encode",value:function(e,n,r){return new t(e,n).encode(r)}},{key:"verify",value:function(e,n){var r=t.decode(n);return r.key=e,r.verify().then(function(e){return r})}},{key:"schema",get:function(){return s}}]),t}();e.exports=l},function(e,t,n){"use strict";var r=n(64),i=n(65),o=n(66),a=new(0,n(28).JSONSchema)({type:"object",properties:{type:{type:"string",enum:["JWS","JWE"]},segments:{type:"array"},header:o,protected:o,unprotected:o,iv:r,aad:r,ciphertext:r,tag:r,recipients:{type:"array",items:{type:"object",properties:{header:o,encrypted_key:r}}},payload:i,signatures:{type:"array",items:{type:"object",properties:{protected:o,header:o,signature:r,key:{type:"object"}}}},signature:r,verified:{type:"boolean",default:!1},key:{type:"object"},serialization:{type:"string",enum:["compact","json","flattened"],default:"compact"}}});e.exports=a},function(e,t,n){"use strict";var r=new(0,n(28).JSONSchema)({type:"string",format:"base64url"});e.exports=r},function(e,t,n){"use strict";var r=new(0,n(28).JSONSchema)({properties:{iss:{type:"string",format:"StringOrURI"},sub:{type:"string",format:"StringOrURI"},aud:{type:["array","string"],format:"StringOrURI",items:{format:"StringOrURI"}},exp:{type:"number",format:"NumericDate"},nbf:{type:"number",format:"NumericDate"},iat:{type:"number",format:"NumericDate"},jti:{type:"string"}}});e.exports=r},function(e,t,n){"use strict";n(58);var r=new(0,n(28).JSONSchema)({type:"object",properties:{typ:{type:"string"},cty:{type:"string",enum:["JWT"]},alg:{type:"string",format:"StringOrURI"},jku:{type:"string",format:"URI"},kid:{type:"string"},x5u:{type:"string",format:"URI"},x5c:{type:"array",items:{type:"string",format:"base64"}},x5t:{type:"string",format:"base64url"},crit:{type:"array",items:{type:"string"},minItems:1},enc:{type:"string",format:"StringOrURI"},zip:{type:"string"}}});e.exports=r},function(e,t,n){"use strict";var r=function(){return function(e,t){if(Array.isArray(e))return e;if(Symbol.iterator in Object(e))return function(e,t){var n=[],r=!0,i=!1,o=void 0;try{for(var a,s=e[Symbol.iterator]();!(r=(a=s.next()).done)&&(n.push(a.value),!t||n.length!==t);r=!0);}catch(e){i=!0,o=e}finally{try{!r&&s.return&&s.return()}finally{if(i)throw o}}return n}(e,t);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),i=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}();var o=n(39),a=n(38),s=n(55).DataError,u=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e)}return i(e,null,[{key:"sign",value:function(e){var t=o(JSON.stringify(e.payload));if("compact"===e.serialization){var n=e.key,r=e.header.alg,i=o(JSON.stringify(e.header))+"."+t;return a.sign(r,n,i).then(function(e){return i+"."+e})}return e.serialization,e.serialization,Promise.reject(new s("Unsupported serialization"))}},{key:"verify",value:function(e){e.signatures;var t=e.key,n=e.signature,i=e.header.alg;if(e.signature){var o=r(e.segments,2),u=o[0]+"."+o[1];return"none"===i?Promise.reject(new s("Signature provided to verify with alg: none")):a.verify(i,t,n,u).then(function(t){return e.verified=t,t})}if("none"===i){if(!t&&!n)return e.verified=!0,Promise.resolve(!0);if(t)return Promise.reject(new s("Key provided to verify signature with alg: none"))}return Promise.reject(new s("Missing signature(s)"))}}]),e}();e.exports=u},function(e,t,n){(function(t){const r=n(22),i=n(39),o=n(49),{JWT:a}=n(37),s=n(69),{URL:u}=n(27);class c{static create(e,n,a){const{provider:l,defaults:f,registration:h}=e;let p,d,y,v;return Promise.resolve().then(()=>(r(l.configuration,"RelyingParty provider OpenID Configuration is missing"),r(f.authenticate,"RelyingParty default authentication parameters are missing"),r(h,"RelyingParty client registration is missing"),p=l.configuration.issuer,d=l.configuration.authorization_endpoint,y={client_id:h.client_id},v=Object.assign(f.authenticate,y,n),r(p,"Missing issuer in provider OpenID Configuration"),r(d,"Missing authorization_endpoint in provider OpenID Configuration"),r(v.scope,"Missing scope parameter in authentication request"),r(v.response_type,"Missing response_type parameter in authentication request"),r(v.client_id,"Missing client_id parameter in authentication request"),r(v.redirect_uri,"Missing redirect_uri parameter in authentication request"),v.state=Array.from(o.getRandomValues(new Uint8Array(16))),v.nonce=Array.from(o.getRandomValues(new Uint8Array(16))),Promise.all([o.subtle.digest({name:"SHA-256"},new Uint8Array(v.state)),o.subtle.digest({name:"SHA-256"},new Uint8Array(v.nonce))]))).then(e=>{let n=i(t.from(e[0])),r=i(t.from(e[1]));a[`${p}/requestHistory/${n}`]=JSON.stringify(v),v.state=n,v.nonce=r}).then(()=>c.generateSessionKeys()).then(e=>{c.storeSessionKeys(e,v,a)}).then(()=>{if(l.configuration.request_parameter_supported)return c.encodeRequestParams(v).then(e=>{v=e})}).then(()=>{let e=new u(d);return e.search=s.encode(v),e.href})}static generateSessionKeys(){return o.subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:2048,publicExponent:new Uint8Array([1,0,1]),hash:{name:"SHA-256"}},!0,["sign","verify"]).then(e=>Promise.all([o.subtle.exportKey("jwk",e.publicKey),o.subtle.exportKey("jwk",e.privateKey)])).then(e=>{let[t,n]=e;return{public:t,private:n}})}static storeSessionKeys(e,t,n){n["oidc.session.privateKey"]=JSON.stringify(e.private),t.key=e.public}static encodeRequestParams(e){const t=["scope","client_id","response_type","state"],n=Object.keys(e).filter(e=>!t.includes(e));let r={};return n.forEach(t=>{r[t]=e[t]}),new a({header:{alg:"none"},payload:r},{filter:!1}).encode().then(t=>{return{scope:e.scope,client_id:e.client_id,response_type:e.response_type,request:t,state:e.state}})}}e.exports=c}).call(this,n(41).Buffer)},function(e,t){e.exports=class{static encode(e){let t=[];return Object.keys(e).forEach(function(n){t.push(encodeURIComponent(n)+"="+encodeURIComponent(e[n]))}),t.join("&")}static decode(e){let t={};return e.split("&").forEach(function(e){let n=e.split("="),r=decodeURIComponent(n[0]),i=decodeURIComponent(n[1]);t[r]=i}),t}}},function(e,t,n){(function(t,r){const{URL:i}=n(27),o=n(22),a=n(49),s=n(39),u=n(6),c=u.Headers?u.Headers:t.Headers,l=n(69),f=n(71),h=n(73),p=n(74),d=n(76);class y{constructor({rp:e,redirect:t,body:n,session:r,mode:i,params:o={}}){this.rp=e,this.redirect=t,this.body=n,this.session=r,this.mode=i,this.params=o}static validateResponse(e){return Promise.resolve(e).then(this.parseResponse).then(this.errorResponse).then(this.matchRequest).then(this.validateStateParam).then(this.validateResponseMode).then(this.validateResponseParams).then(this.exchangeAuthorizationCode).then(this.validateIDToken).then(h.fromAuthResponse)}static parseResponse(e){let{redirect:t,body:n}=e;if(t&&n||!t&&!n)throw new d(400,"Invalid response mode");if(t){let n=new i(t),{search:r,hash:o}=n;if(r&&o||!r&&!o)throw new d(400,"Invalid response mode");r&&(e.params=l.decode(r.substring(1)),e.mode="query"),o&&(e.params=l.decode(o.substring(1)),e.mode="fragment")}return n&&(e.params=l.decode(n),e.mode="form_post"),e}static errorResponse(e){const t=e.params.error;if(t){const n={};n.error=t,n.error_description=e.params.error_description,n.error_uri=e.params.error_uri,n.state=e.params.state;const r=new Error(`AuthenticationResponse error: ${t}`);throw r.info=n,r}return e}static matchRequest(e){let{rp:t,params:n,session:r}=e,i=n.state,o=t.provider.configuration.issuer;if(!i)throw new Error("Missing state parameter in authentication response");let a=r[`${o}/requestHistory/${i}`];if(!a)throw new Error("Mismatching state parameter in authentication response");return e.request=JSON.parse(a),e}static validateStateParam(e){let t=new Uint8Array(e.request.state),n=e.params.state;return a.subtle.digest({name:"SHA-256"},t).then(t=>{if(n!==s(r.from(t)))throw new Error("Mismatching state parameter in authentication response");return e})}static validateResponseMode(e){if("code"!==e.request.response_type&&"query"===e.mode)throw new Error("Invalid response mode");return e}static validateResponseParams(e){let{request:t,params:n}=e,r=t.response_type.split(" ");return r.includes("code")&&o(n.code,"Missing authorization code in authentication response"),r.includes("id_token")&&o(n.id_token,"Missing id_token in authentication response"),r.includes("token")&&(o(n.access_token,"Missing access_token in authentication response"),o(n.token_type,"Missing token_type in authentication response")),e}static exchangeAuthorizationCode(e){let{rp:t,params:n,request:i}=e,a=n.code;if(!a||"code"!==i.response_type)return Promise.resolve(e);let{provider:s,registration:f}=t,h=f.client_id,d=f.client_secret;if(!d)return Promise.reject(new Error("Client cannot exchange authorization code because it is not a confidential client"));let y=s.configuration.token_endpoint,v=new c({"Content-Type":"application/x-www-form-urlencoded"}),g={grant_type:"authorization_code",code:a,redirect_uri:i.redirect_uri},m=f.token_endpoint_auth_method||"client_secret_basic";if("client_secret_basic"===m){let e=new r(`${h}:${d}`).toString("base64");v.set("Authorization",`Basic ${e}`)}"client_secret_post"===m&&(g.client_id=h,g.client_secret=d);let w=l.encode(g);return u(y,{method:"POST",headers:v,body:w}).then(p("Error exchanging authorization code")).then(e=>e.json()).then(t=>(o(t.access_token,"Missing access_token in token response"),o(t.token_type,"Missing token_type in token response"),o(t.id_token,"Missing id_token in token response"),e.params=Object.assign(e.params,t),e))}static validateIDToken(e){return e.params.id_token?Promise.resolve(e).then(y.decryptIDToken).then(y.decodeIDToken).then(y.validateIssuer).then(y.validateAudience).then(y.resolveKeys).then(y.verifySignature).then(y.validateExpires).then(y.verifyNonce).then(y.validateAcr).then(y.validateAuthTime).then(y.validateAccessTokenHash).then(y.validateAuthorizationCodeHash):Promise.resolve(e)}static decryptIDToken(e){return Promise.resolve(e)}static decodeIDToken(e){let t=e.params.id_token;try{e.decoded=f.decode(t)}catch(e){const n=new d(400,"Error decoding ID Token");throw n.cause=e,n.info={id_token:t},n}return e}static validateIssuer(e){let t=e.rp.provider.configuration;if(e.decoded.payload.iss!==t.issuer)throw new Error("Mismatching issuer in ID Token");return e}static validateAudience(e){let t=e.rp.registration,{aud:n,azp:r}=e.decoded.payload;if("string"==typeof n&&n!==t.client_id)throw new Error("Mismatching audience in id_token");if(Array.isArray(n)&&!n.includes(t.client_id))throw new Error("Mismatching audience in id_token");if(Array.isArray(n)&&!r)throw new Error("Missing azp claim in id_token");if(r&&r!==t.client_id)throw new Error("Mismatching azp claim in id_token");return e}static resolveKeys(e){let t=e.rp,n=t.provider,r=e.decoded;return Promise.resolve(n.jwks).then(e=>e||t.jwks()).then(t=>{if(r.resolveKeys(t))return Promise.resolve(e);throw new Error("Cannot resolve signing key for ID Token")})}static verifySignature(e){let t=e.decoded.header.alg,n=e.rp.registration.id_token_signed_response_alg||"RS256";if(t!==n)throw new Error(`Expected ID Token to be signed with ${n}`);return e.decoded.verify().then(t=>{if(!t)throw new Error("Invalid ID Token signature");return e})}static validateExpires(e){if(e.decoded.payload.exp<=Math.floor(Date.now()/1e3))throw new Error("Expired ID Token");return e}static verifyNonce(e){let t=new Uint8Array(e.request.nonce),n=e.decoded.payload.nonce;if(!n)throw new Error("Missing nonce in ID Token");return a.subtle.digest({name:"SHA-256"},t).then(t=>{if(n!==s(r.from(t)))throw new Error("Mismatching nonce in ID Token");return e})}static validateAcr(e){return e}static validateAuthTime(e){return e}static validateAccessTokenHash(e){return e}static validateAuthorizationCodeHash(e){return e}}e.exports=y}).call(this,n(21),n(41).Buffer)},function(e,t,n){const{JWT:r}=n(37),i=n(72);e.exports=class extends r{static get schema(){return i}}},function(e,t,n){const{JWTSchema:r}=n(37),i=r.extend({properties:{header:{},payload:{properties:{iss:{type:"string",format:"url"},sub:{type:"string",maxLength:255},auth_time:{type:"integer",format:"NumericDate"},nonce:{type:"string"},acr:{type:"string"},amr:{type:"array",items:{type:"string"}},azp:{type:"string",format:"StringOrURI"}},required:["iss","sub","aud","exp","iat"]}}});e.exports=i},function(e,t,n){"use strict";const r=n(6),i=n(74),o=n(75);class a{constructor(e){this.credentialType=e.credentialType||"access_token",this.issuer=e.issuer,this.authorization=e.authorization||{},this.sessionKey=e.sessionKey,this.idClaims=e.idClaims,this.accessClaims=e.accessClaims}static from(e){return new a(e)}static fromAuthResponse(e){const t=n(20);let r=e.decoded&&e.decoded.payload||{},{rp:i}=e,o=i.registration,s={credentialType:(i.defaults.authenticate||{}).credential_type||i.defaults.popToken?"pop_token":"access_token",sessionKey:e.session[t.SESSION_PRIVATE_KEY],issuer:r.iss,idClaims:r,authorization:{client_id:o.client_id,access_token:e.params.access_token,id_token:e.params.id_token,refresh_token:e.params.refresh_token}};return a.from(s)}get fetch(){return(e,t)=>Promise.resolve().then(()=>this.hasCredentials()?this.fetchWithCredentials(e,t):r(e,t)).then(i("Error while fetching resource"))}bearerTokenFor(e){switch(this.credentialType){case"pop_token":return o.issueFor(e,this);default:return Promise.resolve(this.authorization[this.credentialType])}}hasCredentials(){switch(this.credentialType){case"pop_token":return!!this.authorization.id_token;default:return!!this.authorization[this.credentialType]}}fetchWithCredentials(e,t={}){return t.headers=t.headers||{},this.bearerTokenFor(e).then(n=>(t.headers.authorization=`Bearer ${n}`,r(e,t)))}}e.exports=a},function(e,t,n){"use strict";e.exports=function(e="fetch error"){return t=>{if(t.status>=200&&t.status<300)return t;let n=`${e}: ${t.status} ${t.statusText}`,r=new Error(n);throw r.response=t,r.statusCode=t.status,r}}},function(e,t,n){"use strict";const{URL:r}=n(27),{JWT:i,JWK:o}=n(37),a=3600;class s extends i{static issueFor(e,t){if(!e)throw new Error("Cannot issue PoPToken - missing resource server URI");if(!t.sessionKey)throw new Error("Cannot issue PoPToken - missing session key");if(!t.authorization.id_token)throw new Error("Cannot issue PoPToken - missing id token");let n=JSON.parse(t.sessionKey);return o.importKey(n).then(n=>{let i={aud:new r(e).origin,key:n,iss:t.authorization.client_id,id_token:t.authorization.id_token};return s.issue(i)}).then(e=>e.encode())}static issue(e){let{aud:t,iss:n,key:r}=e,i=r.alg,o=e.iat||Math.floor(Date.now()/1e3),u={alg:i},c={iss:n,aud:t,exp:o+(e.max||a),iat:o,id_token:e.id_token,token_type:"pop"};return new s({header:u,payload:c,key:r.cryptoKey},{filter:!1})}}e.exports=s},function(e,t,n){t=e.exports=a;var r=n(77),i=n(78),o=t;function a(e,t,n){if("string"==typeof e&&(e=o[e]),"number"!=typeof e)throw new TypeError("Non-numeric HTTP code");"object"==typeof t&&null!=t&&(n=t,t=null),r.call(this,t||i[e],n),this.code=e}for(var s in a.prototype=Object.create(r.prototype,{constructor:{value:a,configurable:!0,writable:!0}}),a.prototype.name="HttpError",Object.defineProperties(a.prototype,{statusCode:u("code"),statusMessage:u("message"),status:{configurable:!0,get:function(){return this.code},set:function(e){Object.defineProperty(this,"status",{value:e,configurable:!0,enumerable:!0,writable:!0})}}}),a.prototype.toString=function(){return this.name+": "+this.code+" "+this.message},i){t[i[s].replace("'","").replace(/[- ]/g,"_").toUpperCase()]=+s}function u(e){return{configurable:!0,get:function(){return this[e]},set:function(t){return this[e]=t}}}},function(e,t){var n=Object.hasOwnProperty,r=Object.getPrototypeOf,i=Error.captureStackTrace;function o(e,t){if(e&&"object"==typeof e?(t=e,e=void 0):this.message=e,t)for(var o in t)this[o]=t[o];n.call(this,"name")||(this.name=n.call(r(this),"name")?this.name:this.constructor.name),!i||"stack"in this||i(this,this.constructor)}e.exports=o,o.prototype=Object.create(Error.prototype,{constructor:{value:o,configurable:!0,writable:!0}}),o.prototype.name="StandardError"},function(e){e.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",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"}},function(e,t,n){const{JSONSchema:r}=n(28),i=new r({type:"object",properties:{provider:{type:"object",properties:{name:{type:"string"},url:{type:"string",format:"uri"},configuration:{},jwks:{}},required:["url"]},defaults:{type:"object",properties:{popToken:{type:"boolean",default:!1},authenticate:{type:"object",properties:{redirect_uri:{type:"string",format:"uri"},response_type:{type:"string",default:"id_token token",enum:["code","token","id_token token","id_token token code"]},display:{type:"string",default:"page",enum:["page","popup"]},scope:{type:["string","array"],default:["openid"]}}},register:{}}},registration:{},store:{type:"object",default:{}}}});e.exports=i},function(e,t,n){"use strict";var r=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}();var i=n(27).URL,o=n(37),a=o.JWT,s=o.JWK,u=function(e){function t(){return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),function(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}(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return function(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)}(t,a),r(t,null,[{key:"issueFor",value:function(e,n){if(!e)throw new Error("Cannot issue PoPToken - missing resource server URI");if(!n.sessionKey)throw new Error("Cannot issue PoPToken - missing session key");if(!n.authorization.id_token)throw new Error("Cannot issue PoPToken - missing id token");var r=JSON.parse(n.sessionKey);return s.importKey(r).then(function(r){var o={aud:new i(e).origin,key:r,iss:n.authorization.client_id,id_token:n.authorization.id_token};return t.issue(o)}).then(function(e){return e.encode()})}},{key:"issue",value:function(e){var n=e.aud,r=e.iss,i=e.key,o=i.alg,a=e.iat||Math.floor(Date.now()/1e3);return new t({header:{alg:o},payload:{iss:r,aud:n,exp:a+(e.max||3600),iat:a,id_token:e.id_token,token_type:"pop"},key:i.cryptoKey},{filter:!1})}}]),t}();e.exports=u},function(e,t,n){"use strict";n.r(t),n.d(t,"openIdpPopup",function(){return o}),n.d(t,"obtainSession",function(){return a}),n.d(t,"popupHandler",function(){return s});var r=n(11),i=n(7);function o(e){const t=`width=650,height=400,left=${window.screenX+(window.innerWidth-650)/2},top=${window.screenY+(window.innerHeight-400)/2}`;return window.open(e,"solid-auth-client",t)}function a(e,t,n){return new Promise((o,a)=>{const u=new r.Server(t,Object(i.originOf)(n.popupUri||""),s(e,n,e=>{u.stop(),o(e)}));u.start()})}function s(e,{popupUri:t,callbackUri:n},r){return async(i,...o)=>{switch(i){case"getAppOrigin":return window.location.origin;case"storage/getItem":return e.getItem(...o);case"storage/setItem":return e.setItem(...o);case"storage/removeItem":return e.removeItem(...o);case"getLoginOptions":return{popupUri:t,callbackUri:n};case"foundSession":r(...o)}}}}]).default},function(e,t,n){(function(t){var n=String.fromCharCode,r="function"==typeof t?t:function(e){setTimeout(e,0)},i=/\\u([a-fA-F0-9]{4})|\\U([a-fA-F0-9]{8})|\\[uU]|\\(.)/g,o={"\\":"\\","'":"'",'"':'"',n:"\n",r:"\r",t:"\t",f:"\f",b:"\b",_:"_","~":"~",".":".","-":"-","!":"!",$:"$","&":"&","(":"(",")":")","*":"*","+":"+",",":",",";":";","=":"=","/":"/","?":"?","#":"#","@":"@","%":"%"},a=/[\x00-\x20<>\\"\{\}\|\^\`]/;function s(e){if(!(this instanceof s))return new s(e);if(e&&e.lineMode){this._tripleQuotedString=this._number=this._boolean=/$0^/;var t=this;this._tokenize=this.tokenize,this.tokenize=function(e,n){this._tokenize(e,function(e,r){!e&&/^(?:IRI|prefixed|literal|langcode|type|\.|eof)$/.test(r.type)?n&&n(e,r):n&&n(e||t._syntaxError(r.type,n=null))})}}}s.prototype={_iri:/^<((?:[^>\\]|\\[uU])+)>/,_unescapedIri:/^<([^\x00-\x20<>\\"\{\}\|\^\`]*)>/,_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}|\\[!#-\/;=?\-@_~]))?)?)(?=\.?[,;\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])*)(?=\.?[,;:\s#()\[\]\{\}"'<])/,_number:/^[\-+]?(?:\d+\.?\d*([eE](?:[\-\+])?\d+)|\d*\.?\d+)(?=[.,;:\s#()\[\]\{\}"'<])/,_boolean:/^(?:true|false)(?=[.,;:\s#()\[\]\{\}"'<])/,_keyword:/^@[a-z]+(?=[\s#<:])/,_sparqlKeyword:/^(?:PREFIX|BASE|GRAPH)(?=[\s#<:])/i,_shortPredicates:/^a(?=\s+|<)/,_newline:/^[ \t]*(?:#[^\n\r]*)?(?:\r\n|\n|\r)[ \t]*/,_whitespace:/^[ \t]+/,_endOfFile:/^(?:#[^\n\r]*)?$/,_tokenizeToEnd:function(e,t){for(var n=this._input;;){for(var r;r=this._newline.exec(n);)n=n.substr(r[0].length,n.length),this._line++;if((r=this._whitespace.exec(n))&&(n=n.substr(r[0].length,n.length)),this._endOfFile.test(n))return t&&e(n=null,{line:this._line,type:"eof",value:"",prefix:""}),this._input=n;var i,o=this._line,s="",u="",c="",l=n[0],f=null,h=0,p=!1;switch(l){case"^":if(1===n.length)break;if("^"!==n[1])return d(this);if(this._prevTokenType="^","<"!==(n=n.substr(2))[0]){p=!0;break}case"<":if(f=this._unescapedIri.exec(n))s="IRI",u=f[1];else if(f=this._iri.exec(n)){if(null===(i=this._unescape(f[1]))||a.test(i))return d(this);s="IRI",u=i}break;case"_":((f=this._blank.exec(n))||t&&(f=this._blank.exec(n+" ")))&&(s="prefixed",c="_",u=f[1]);break;case'"':case"'":if(f=this._unescapedString.exec(n))s="literal",u=f[0];else if(f=this._singleQuotedString.exec(n)){if(null===(i=this._unescape(f[0])))return d(this);s="literal",u=i.replace(/^'|'$/g,'"')}else if(f=this._tripleQuotedString.exec(n)){if(i=f[1]||f[2],this._line+=i.split(/\r\n|\r|\n/).length-1,null===(i=this._unescape(i)))return d(this);s="literal",u=i.replace(/^'|'$/g,'"')}break;case"@":"literal"===this._prevTokenType&&(f=this._langcode.exec(n))?(s="langcode",u=f[1]):(f=this._keyword.exec(n))&&(s=f[0]);break;case".":if(1===n.length?t:n[1]<"0"||n[1]>"9"){s=".",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"-":(f=this._number.exec(n))&&(s="literal",u='"'+f[0]+'"^^http://www.w3.org/2001/XMLSchema#'+(f[1]?"double":/^[+\-]?\d+$/.test(f[0])?"integer":"decimal"));break;case"B":case"b":case"p":case"P":case"G":case"g":(f=this._sparqlKeyword.exec(n))?s=f[0].toUpperCase():p=!0;break;case"f":case"t":(f=this._boolean.exec(n))?(s="literal",u='"'+f[0]+'"^^http://www.w3.org/2001/XMLSchema#boolean'):p=!0;break;case"a":(f=this._shortPredicates.exec(n))?(s="abbreviation",u="http://www.w3.org/1999/02/22-rdf-syntax-ns#type"):p=!0;break;case",":case";":case"[":case"]":case"(":case")":case"{":case"}":h=1,s=l;break;default:p=!0}if(p&&("@prefix"!==this._prevTokenType&&"PREFIX"!==this._prevTokenType||!(f=this._prefix.exec(n))?((f=this._prefixed.exec(n))||t&&(f=this._prefixed.exec(n+" ")))&&(s="prefixed",c=f[1]||"",u=this._unescape(f[2])):(s="prefix",u=f[1]||"")),"^"===this._prevTokenType&&(s="IRI"===s||"prefixed"===s?"type":""),!s)return t||!/^'''|^"""/.test(n)&&/\n|\r/.test(n)?d(this):this._input=n;e(null,{line:o,type:s,value:u,prefix:c}),this._prevTokenType=s,n=n.substr(h||f[0].length,n.length)}function d(t){e(t._syntaxError(/^\S*/.exec(n)[0]))}},_unescape:function(e){try{return e.replace(i,function(e,t,r,i){var a;if(t){if(a=parseInt(t,16),isNaN(a))throw new Error;return n(a)}if(r){if(a=parseInt(r,16),isNaN(a))throw new Error;return a<=65535?n(a):n(55296+(a-=65536)/1024,56320+(1023&a))}var s=o[i];if(!s)throw new Error;return s})}catch(e){return null}},_syntaxError:function(e){return this._input=null,new Error('Syntax error: unexpected "'+e+'" on line '+this._line+".")},tokenize:function(e,t){var n=this;function i(e){null!==n._input&&(n._input+=e,n._tokenizeToEnd(t,!1))}function o(){null!==n._input&&n._tokenizeToEnd(t,!0)}this._line=1,"string"==typeof e?(this._input=e,r(function(){n._tokenizeToEnd(t,!0)})):(this._input="",e&&"function"!=typeof e?("function"==typeof e.setEncoding&&e.setEncoding("utf8"),e.on("data",i),e.on("end",o)):(this.addChunk=i,this.end=o,t||(t=e)))}},e.exports=s}).call(this,n(17).setImmediate)},function(e,t,n){var r=n(29),i="http://www.w3.org/1999/02/22-rdf-syntax-ns#",o=i+"nil",a=i+"first",s=/^[a-z][a-z0-9+.-]*:/i,u=/^(?:([a-z][a-z0-9+.-]*:))?(?:\/\/[^\/]*)?/i,c=/(?:^|\/)\.\.?(?:$|[\/#?])/,l=0,f=0;function h(e){if(!(this instanceof h))return new h(e);this._tripleStack=[],this._graph=null,e=e||{},this._setBase(e.documentIRI);var t="string"==typeof e.format&&e.format.match(/\w*$/)[0].toLowerCase(),n="turtle"===t,i="trig"===t,o=/triple/.test(t),a=/quad/.test(t),s=o||a;(this._supportsNamedGraphs=!n)||(this._readPredicateOrNamedGraph=this._readPredicate),this._supportsQuads=!(n||i||o),s&&(this._base="",this._resolveIRI=function(e){return this._error("Disallowed relative IRI",e),this._callback=p,this._subject=null}),this._blankNodePrefix="string"!=typeof e.blankNodePrefix?"":"_:"+e.blankNodePrefix.replace(/^_:/,""),this._lexer=e.lexer||new r({lineMode:s})}function p(){}h._resetBlankNodeIds=function(){l=f=0},h.prototype={_setBase:function(e){if(e){if(e.indexOf("#")>=0)throw new Error("Invalid base IRI "+e)}else e=null;(this._base=e)&&(this._basePath=e.replace(/[^\/?]*(?:\?.*)?$/,""),e=e.match(u),this._baseRoot=e[0],this._baseScheme=e[1])},_readInTopContext:function(e){switch(e.type){case"eof":return null!==this._graph?this._error("Unclosed graph",e):(delete this._prefixes._,this._callback(null,null,this._prefixes));case"@prefix":return this._sparqlStyle=!1,this._readPrefix;case"PREFIX":return this._sparqlStyle=!0,this._readPrefix;case"@base":return this._sparqlStyle=!1,this._readBaseIRI;case"BASE":return this._sparqlStyle=!0,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(e)}},_readSubject:function(e){switch(this._predicate=null,e.type){case"IRI":null===this._base||s.test(e.value)?this._subject=e.value:this._subject=this._resolveIRI(e);break;case"prefixed":var t=this._prefixes[e.prefix];if(void 0===t)return this._error('Undefined prefix "'+e.prefix+':"',e);this._subject=t+e.value;break;case"[":return this._subject="_:b"+f++,this._tripleStack.push({subject:this._subject,predicate:null,object:null,type:"blank"}),this._readBlankNodeHead;case"(":return this._tripleStack.push({subject:o,predicate:null,object:null,type:"list"}),this._subject=null,this._readListItem;case"}":return this._readPunctuation(e);default:return this._error("Expected subject but got "+e.type,e)}return this._readPredicateOrNamedGraph},_readPredicate:function(e){var t=e.type;switch(t){case"IRI":case"abbreviation":null===this._base||s.test(e.value)?this._predicate=e.value:this._predicate=this._resolveIRI(e);break;case"prefixed":if("_"===e.prefix)return this._error("Disallowed blank node as predicate",e);var n=this._prefixes[e.prefix];if(void 0===n)return this._error('Undefined prefix "'+e.prefix+':"',e);this._predicate=n+e.value;break;case".":case"]":case"}":return null===this._predicate?this._error("Unexpected "+t,e):(this._subject=null,"]"===t?this._readBlankNodeTail(e):this._readPunctuation(e));case";":return this._readPredicate;default:return this._error('Expected predicate to follow "'+this._subject+'"',e)}return this._readObject},_readObject:function(e){switch(e.type){case"IRI":null===this._base||s.test(e.value)?this._object=e.value:this._object=this._resolveIRI(e);break;case"prefixed":var t=this._prefixes[e.prefix];if(void 0===t)return this._error('Undefined prefix "'+e.prefix+':"',e);this._object=t+e.value;break;case"literal":return this._object=e.value,this._readDataTypeOrLang;case"[":var n="_:b"+f++;return this._tripleStack.push({subject:this._subject,predicate:this._predicate,object:n,type:"blank"}),this._subject=n,this._readBlankNodeHead;case"(":return this._tripleStack.push({subject:this._subject,predicate:this._predicate,object:o,type:"list"}),this._subject=null,this._readListItem;default:return this._error('Expected object to follow "'+this._predicate+'"',e)}return this._getTripleEndReader()},_readPredicateOrNamedGraph:function(e){return"{"===e.type?this._readGraph(e):this._readPredicate(e)},_readGraph:function(e){return"{"!==e.type?this._error("Expected graph but got "+e.type,e):(this._graph=this._subject,this._subject=null,this._readSubject)},_readBlankNodeHead:function(e){return"]"===e.type?(this._subject=null,this._readBlankNodeTail(e)):(this._predicate=null,this._readPredicate(e))},_readBlankNodeTail:function(e){if("]"!==e.type)return this._readBlankNodePunctuation(e);null!==this._subject&&this._callback(null,{subject:this._subject,predicate:this._predicate,object:this._object,graph:this._graph||""});var t=this._tripleStack.pop();return this._subject=t.subject,null!==t.object?(this._predicate=t.predicate,this._object=t.object,this._getTripleEndReader()):null!==this._predicate?this._readPredicate:this._readPredicateOrNamedGraph},_readDataTypeOrLang:function(e){switch(e.type){case"type":var t;if(""===e.prefix)t=null===this._base||s.test(e.value)?e.value:this._resolveIRI(e);else{var n=this._prefixes[e.prefix];if(void 0===n)return this._error('Undefined prefix "'+e.prefix+':"',e);t=n+e.value}return this._object+="^^"+t,this._getTripleEndReader();case"langcode":return this._object+="@"+e.value.toLowerCase(),this._getTripleEndReader();default:return this._getTripleEndReader().call(this,e)}},_readListItem:function(e){var t=null,n=null,r=this._subject,i=this._tripleStack,u=i[i.length-1],c=this._readListItem;switch(e.type){case"IRI":t=null===this._base||s.test(e.value)?e.value:this._resolveIRI(e);break;case"prefixed":var l=this._prefixes[e.prefix];if(void 0===l)return this._error('Undefined prefix "'+e.prefix+':"',e);t=l+e.value;break;case"literal":t=e.value,c=this._readDataTypeOrLang;break;case"[":n="_:b"+f++,t="_:b"+f++,i.push({subject:n,predicate:a,object:t,type:"blank"}),this._subject=t,c=this._readBlankNodeHead;break;case"(":n="_:b"+f++,i.push({subject:n,predicate:a,object:o,type:"list"}),this._subject=null,c=this._readListItem;break;case")":if(i.pop(),0!==i.length&&"list"===i[i.length-1].type&&this._callback(null,{subject:u.subject,predicate:u.predicate,object:u.object,graph:this._graph||""}),this._subject=u.subject,null===u.predicate){if(c=this._readPredicate,u.subject===o)return c}else if(this._predicate=u.predicate,this._object=u.object,c=this._getTripleEndReader(),u.object===o)return c;n=o;break;default:return this._error('Expected list item instead of "'+e.type+'"',e)}return null===n&&(this._subject=n="_:b"+f++),null===r?u.object===o?u.object=n:u.subject=n:this._callback(null,{subject:r,predicate:"http://www.w3.org/1999/02/22-rdf-syntax-ns#rest",object:n,graph:this._graph||""}),null!==t&&this._callback(null,{subject:n,predicate:a,object:t,graph:this._graph||""}),c},_readPunctuation:function(e){var t,n=this._subject,r=this._graph;switch(e.type){case"}":if(null===this._graph)return this._error("Unexpected graph closing",e);this._graph=null;case".":this._subject=null,t=this._readInTopContext;break;case";":t=this._readPredicate;break;case",":t=this._readObject;break;case"IRI":if(this._supportsQuads&&null===this._graph){r=null===this._base||s.test(e.value)?e.value:this._resolveIRI(e),n=this._subject,t=this._readQuadPunctuation;break}case"prefixed":if(this._supportsQuads&&null===this._graph){var i=this._prefixes[e.prefix];if(void 0===i)return this._error('Undefined prefix "'+e.prefix+':"',e);r=i+e.value,t=this._readQuadPunctuation;break}default:return this._error('Expected punctuation to follow "'+this._object+'"',e)}return null!==n&&this._callback(null,{subject:n,predicate:this._predicate,object:this._object,graph:r||""}),t},_readBlankNodePunctuation:function(e){var t;switch(e.type){case";":t=this._readPredicate;break;case",":t=this._readObject;break;default:return this._error('Expected punctuation to follow "'+this._object+'"',e)}return this._callback(null,{subject:this._subject,predicate:this._predicate,object:this._object,graph:this._graph||""}),t},_readQuadPunctuation:function(e){return"."!==e.type?this._error("Expected dot to follow quad",e):this._readInTopContext},_readPrefix:function(e){return"prefix"!==e.type?this._error("Expected prefix to follow @prefix",e):(this._prefix=e.value,this._readPrefixIRI)},_readPrefixIRI:function(e){return"IRI"!==e.type?this._error('Expected IRI to follow prefix "'+this._prefix+':"',e):(t=null===this._base||s.test(e.value)?e.value:this._resolveIRI(e),this._prefixes[this._prefix]=t,this._prefixCallback(this._prefix,t),this._readDeclarationPunctuation);var t},_readBaseIRI:function(e){if("IRI"!==e.type)return this._error("Expected IRI to follow base declaration",e);try{this._setBase(null===this._base||s.test(e.value)?e.value:this._resolveIRI(e))}catch(t){this._error(t.message,e)}return this._readDeclarationPunctuation},_readNamedGraphLabel:function(e){switch(e.type){case"IRI":case"prefixed":return this._readSubject(e),this._readGraph;case"[":return this._readNamedGraphBlankLabel;default:return this._error("Invalid graph label",e)}},_readNamedGraphBlankLabel:function(e){return"]"!==e.type?this._error("Invalid graph label",e):(this._subject="_:b"+f++,this._readGraph)},_readDeclarationPunctuation:function(e){return this._sparqlStyle?this._readInTopContext(e):"."!==e.type?this._error("Expected declaration to end with a dot",e):this._readInTopContext},_getTripleEndReader:function(){var e=this._tripleStack;if(0===e.length)return this._readPunctuation;switch(e[e.length-1].type){case"blank":return this._readBlankNodeTail;case"list":return this._readListItem}},_error:function(e,t){this._callback(new Error(e+" at line "+t.line+"."))},_resolveIRI:function(e){var t=e.value;switch(t[0]){case void 0:return this._base;case"#":return this._base+t;case"?":return this._base.replace(/(?:\?.*)?$/,t);case"/":return("/"===t[1]?this._baseScheme:this._baseRoot)+this._removeDotSegments(t);default:return this._removeDotSegments(this._basePath+t)}},_removeDotSegments:function(e){if(!c.test(e))return e;for(var t="",n=e.length,r=-1,i=-1,o=0,a="/";r<n;){switch(a){case":":if(i<0&&"/"===e[++r]&&"/"===e[++r])for(;(i=r+1)<n&&"/"!==e[i];)r=i;break;case"?":case"#":r=n;break;case"/":if("."===e[r+1])switch(a=e[++r+1]){case"/":t+=e.substring(o,r-1),o=r+1;break;case void 0:case"?":case"#":return t+e.substring(o,r)+e.substr(r+1);case".":if(void 0===(a=e[++r+1])||"/"===a||"?"===a||"#"===a){if((o=(t+=e.substring(o,r-2)).lastIndexOf("/"))>=i&&(t=t.substr(0,o)),"/"!==a)return t+"/"+e.substr(r+1);o=r+1}}}a=e[++r]}return t+e.substring(o)},parse:function(e,t,n){this._readCallback=this._readInTopContext,this._prefixes=Object.create(null),this._prefixes._=this._blankNodePrefix||"_:b"+l+++"_","function"==typeof e&&(n=t,t=e,e=null),this._callback=t||p,this._prefixCallback=n||p;var r=this;this._lexer.tokenize(e,function(e,t){null!==e?(r._callback(e),r._callback=p):void 0!==r._readCallback&&(r._readCallback=r._readCallback(t))}),e||(this.addChunk=this._lexer.addChunk,this.end=this._lexer.end)}},e.exports=h},function(e,t){var n={isIRI:function(e){if(!e)return e;var t=e[0];return'"'!==t&&"_"!==t},isLiteral:function(e){return e&&'"'===e[0]},isBlank:function(e){return e&&"_:"===e.substr(0,2)},getLiteralValue:function(e){var t=/^"([^]*)"/.exec(e);if(!t)throw new Error(e+" is not a literal");return t[1]},getLiteralType:function(e){var t=/^"[^]*"(?:\^\^([^"]+)|(@)[^@"]+)?$/.exec(e);if(!t)throw new Error(e+" is not a literal");return t[1]||(t[2]?"http://www.w3.org/1999/02/22-rdf-syntax-ns#langString":"http://www.w3.org/2001/XMLSchema#string")},getLiteralLanguage:function(e){var t=/^"[^]*"(?:@([^@"]+)|\^\^[^"]+)?$/.exec(e);if(!t)throw new Error(e+" is not a literal");return t[1]?t[1].toLowerCase():""},isPrefixedName:function(e){return e&&/^[^:\/"']*:[^:\/"']+$/.test(e)},expandPrefixedName:function(e,t){var n,r,i,o=/(?:^|"\^\^)([^:\/#"'\^_]*):[^\/]*$/.exec(e);return o&&(r=t[n=o[1]],i=o.index),void 0===r?e:0===i?r+e.substr(n.length+1):e.substr(0,i+3)+r+e.substr(i+n.length+4)},createIRI:function(e){return e&&'"'===e[0]?n.getLiteralValue(e):e},createLiteral:function(e,t){if(!t)switch(typeof e){case"boolean":t="http://www.w3.org/2001/XMLSchema#boolean";break;case"number":if(isFinite(e)){t=e%1==0?"http://www.w3.org/2001/XMLSchema#integer":"http://www.w3.org/2001/XMLSchema#decimal";break}default:return'"'+e+'"'}return'"'+e+(/^[a-z]+(-[a-z0-9]+)*$/i.test(t)?'"@'+t.toLowerCase():'"^^'+t)}};function r(e,t){for(var r in n)t?e.prototype[r]=i(n[r]):e[r]=n[r];return e}function i(e){return function(t){return e(this,t)}}e.exports=r(r)},function(e,t,n){"use strict";var r,i="object"==typeof Reflect?Reflect:null,o=i&&"function"==typeof i.apply?i.apply:function(e,t,n){return Function.prototype.apply.call(e,t,n)};r=i&&"function"==typeof i.ownKeys?i.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};var a=Number.isNaN||function(e){return e!=e};function s(){s.init.call(this)}e.exports=s,s.EventEmitter=s,s.prototype._events=void 0,s.prototype._eventsCount=0,s.prototype._maxListeners=void 0;var u=10;function c(e){return void 0===e._maxListeners?s.defaultMaxListeners:e._maxListeners}function l(e,t,n,r){var i,o,a,s;if("function"!=typeof n)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof n);if(void 0===(o=e._events)?(o=e._events=Object.create(null),e._eventsCount=0):(void 0!==o.newListener&&(e.emit("newListener",t,n.listener?n.listener:n),o=e._events),a=o[t]),void 0===a)a=o[t]=n,++e._eventsCount;else if("function"==typeof a?a=o[t]=r?[n,a]:[a,n]:r?a.unshift(n):a.push(n),(i=c(e))>0&&a.length>i&&!a.warned){a.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+a.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=e,u.type=t,u.count=a.length,s=u,console&&console.warn&&console.warn(s)}return e}function f(e,t,n){var r={fired:!1,wrapFn:void 0,target:e,type:t,listener:n},i=function(){for(var e=[],t=0;t<arguments.length;t++)e.push(arguments[t]);this.fired||(this.target.removeListener(this.type,this.wrapFn),this.fired=!0,o(this.listener,this.target,e))}.bind(r);return i.listener=n,r.wrapFn=i,i}function h(e,t,n){var r=e._events;if(void 0===r)return[];var i=r[t];return void 0===i?[]:"function"==typeof i?n?[i.listener||i]:[i]:n?function(e){for(var t=new Array(e.length),n=0;n<t.length;++n)t[n]=e[n].listener||e[n];return t}(i):d(i,i.length)}function p(e){var t=this._events;if(void 0!==t){var n=t[e];if("function"==typeof n)return 1;if(void 0!==n)return n.length}return 0}function d(e,t){for(var n=new Array(t),r=0;r<t;++r)n[r]=e[r];return n}Object.defineProperty(s,"defaultMaxListeners",{enumerable:!0,get:function(){return u},set:function(e){if("number"!=typeof e||e<0||a(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");u=e}}),s.init=function(){void 0!==this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},s.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||a(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this},s.prototype.getMaxListeners=function(){return c(this)},s.prototype.emit=function(e){for(var t=[],n=1;n<arguments.length;n++)t.push(arguments[n]);var r="error"===e,i=this._events;if(void 0!==i)r=r&&void 0===i.error;else if(!r)return!1;if(r){var a;if(t.length>0&&(a=t[0]),a instanceof Error)throw a;var s=new Error("Unhandled error."+(a?" ("+a.message+")":""));throw s.context=a,s}var u=i[e];if(void 0===u)return!1;if("function"==typeof u)o(u,this,t);else{var c=u.length,l=d(u,c);for(n=0;n<c;++n)o(l[n],this,t)}return!0},s.prototype.addListener=function(e,t){return l(this,e,t,!1)},s.prototype.on=s.prototype.addListener,s.prototype.prependListener=function(e,t){return l(this,e,t,!0)},s.prototype.once=function(e,t){if("function"!=typeof t)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t);return this.on(e,f(this,e,t)),this},s.prototype.prependOnceListener=function(e,t){if("function"!=typeof t)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t);return this.prependListener(e,f(this,e,t)),this},s.prototype.removeListener=function(e,t){var n,r,i,o,a;if("function"!=typeof t)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t);if(void 0===(r=this._events))return this;if(void 0===(n=r[e]))return this;if(n===t||n.listener===t)0==--this._eventsCount?this._events=Object.create(null):(delete r[e],r.removeListener&&this.emit("removeListener",e,n.listener||t));else if("function"!=typeof n){for(i=-1,o=n.length-1;o>=0;o--)if(n[o]===t||n[o].listener===t){a=n[o].listener,i=o;break}if(i<0)return this;0===i?n.shift():function(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}(n,i),1===n.length&&(r[e]=n[0]),void 0!==r.removeListener&&this.emit("removeListener",e,a||t)}return this},s.prototype.off=s.prototype.removeListener,s.prototype.removeAllListeners=function(e){var t,n,r;if(void 0===(n=this._events))return this;if(void 0===n.removeListener)return 0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==n[e]&&(0==--this._eventsCount?this._events=Object.create(null):delete n[e]),this;if(0===arguments.length){var i,o=Object.keys(n);for(r=0;r<o.length;++r)"removeListener"!==(i=o[r])&&this.removeAllListeners(i);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if("function"==typeof(t=n[e]))this.removeListener(e,t);else if(void 0!==t)for(r=t.length-1;r>=0;r--)this.removeListener(e,t[r]);return this},s.prototype.listeners=function(e){return h(this,e,!0)},s.prototype.rawListeners=function(e){return h(this,e,!1)},s.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):p.call(e,t)},s.prototype.listenerCount=p,s.prototype.eventNames=function(){return this._eventsCount>0?r(this._events):[]}},function(e,t,n){(t=e.exports=n(49)).Stream=t,t.Readable=t,t.Writable=n(34),t.Duplex=n(12),t.Transform=n(55),t.PassThrough=n(76)},function(e,t,n){"use strict";(function(t,r,i){var o=n(22);function a(e){var t=this;this.next=null,this.entry=null,this.finish=function(){!function(e,t,n){var r=e.entry;e.entry=null;for(;r;){var i=r.callback;t.pendingcb--,i(n),r=r.next}t.corkedRequestsFree?t.corkedRequestsFree.next=e:t.corkedRequestsFree=e}(t,e)}}e.exports=m;var s,u=!t.browser&&["v0.10","v0.9."].indexOf(t.version.slice(0,5))>-1?r:o.nextTick;m.WritableState=g;var c=n(18);c.inherits=n(11);var l={deprecate:n(75)},f=n(51),h=n(23).Buffer,p=i.Uint8Array||function(){};var d,y=n(53);function v(){}function g(e,t){s=s||n(12),e=e||{};var r=t instanceof s;this.objectMode=!!e.objectMode,r&&(this.objectMode=this.objectMode||!!e.writableObjectMode);var i=e.highWaterMark,c=e.writableHighWaterMark,l=this.objectMode?16:16384;this.highWaterMark=i||0===i?i:r&&(c||0===c)?c:l,this.highWaterMark=Math.floor(this.highWaterMark),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!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){!function(e,t){var n=e._writableState,r=n.sync,i=n.writecb;if(function(e){e.writing=!1,e.writecb=null,e.length-=e.writelen,e.writelen=0}(n),t)!function(e,t,n,r,i){--t.pendingcb,n?(o.nextTick(i,r),o.nextTick(S,e,t),e._writableState.errorEmitted=!0,e.emit("error",r)):(i(r),e._writableState.errorEmitted=!0,e.emit("error",r),S(e,t))}(e,n,r,t,i);else{var a=_(n);a||n.corked||n.bufferProcessing||!n.bufferedRequest||x(e,n),r?u(b,e,n,a,i):b(e,n,a,i)}}(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 a(this)}function m(e){if(s=s||n(12),!(d.call(m,this)||this instanceof s))return new m(e);this._writableState=new g(e,this),this.writable=!0,e&&("function"==typeof e.write&&(this._write=e.write),"function"==typeof e.writev&&(this._writev=e.writev),"function"==typeof e.destroy&&(this._destroy=e.destroy),"function"==typeof e.final&&(this._final=e.final)),f.call(this)}function w(e,t,n,r,i,o,a){t.writelen=r,t.writecb=a,t.writing=!0,t.sync=!0,n?e._writev(i,t.onwrite):e._write(i,o,t.onwrite),t.sync=!1}function b(e,t,n,r){n||function(e,t){0===t.length&&t.needDrain&&(t.needDrain=!1,e.emit("drain"))}(e,t),t.pendingcb--,r(),S(e,t)}function x(e,t){t.bufferProcessing=!0;var n=t.bufferedRequest;if(e._writev&&n&&n.next){var r=t.bufferedRequestCount,i=new Array(r),o=t.corkedRequestsFree;o.entry=n;for(var s=0,u=!0;n;)i[s]=n,n.isBuf||(u=!1),n=n.next,s+=1;i.allBuffers=u,w(e,t,!0,t.length,i,"",o.finish),t.pendingcb++,t.lastBufferedRequest=null,o.next?(t.corkedRequestsFree=o.next,o.next=null):t.corkedRequestsFree=new a(t),t.bufferedRequestCount=0}else{for(;n;){var c=n.chunk,l=n.encoding,f=n.callback;if(w(e,t,!1,t.objectMode?1:c.length,c,l,f),n=n.next,t.bufferedRequestCount--,t.writing)break}null===n&&(t.lastBufferedRequest=null)}t.bufferedRequest=n,t.bufferProcessing=!1}function _(e){return e.ending&&0===e.length&&null===e.bufferedRequest&&!e.finished&&!e.writing}function k(e,t){e._final(function(n){t.pendingcb--,n&&e.emit("error",n),t.prefinished=!0,e.emit("prefinish"),S(e,t)})}function S(e,t){var n=_(t);return n&&(!function(e,t){t.prefinished||t.finalCalled||("function"==typeof e._final?(t.pendingcb++,t.finalCalled=!0,o.nextTick(k,e,t)):(t.prefinished=!0,e.emit("prefinish")))}(e,t),0===t.pendingcb&&(t.finished=!0,e.emit("finish"))),n}c.inherits(m,f),g.prototype.getBuffer=function(){for(var e=this.bufferedRequest,t=[];e;)t.push(e),e=e.next;return t},function(){try{Object.defineProperty(g.prototype,"buffer",{get:l.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch(e){}}(),"function"==typeof Symbol&&Symbol.hasInstance&&"function"==typeof Function.prototype[Symbol.hasInstance]?(d=Function.prototype[Symbol.hasInstance],Object.defineProperty(m,Symbol.hasInstance,{value:function(e){return!!d.call(this,e)||this===m&&(e&&e._writableState instanceof g)}})):d=function(e){return e instanceof this},m.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe, not readable"))},m.prototype.write=function(e,t,n){var r,i=this._writableState,a=!1,s=!i.objectMode&&(r=e,h.isBuffer(r)||r instanceof p);return s&&!h.isBuffer(e)&&(e=function(e){return h.from(e)}(e)),"function"==typeof t&&(n=t,t=null),s?t="buffer":t||(t=i.defaultEncoding),"function"!=typeof n&&(n=v),i.ended?function(e,t){var n=new Error("write after end");e.emit("error",n),o.nextTick(t,n)}(this,n):(s||function(e,t,n,r){var i=!0,a=!1;return null===n?a=new TypeError("May not write null values to stream"):"string"==typeof n||void 0===n||t.objectMode||(a=new TypeError("Invalid non-string/buffer chunk")),a&&(e.emit("error",a),o.nextTick(r,a),i=!1),i}(this,i,e,n))&&(i.pendingcb++,a=function(e,t,n,r,i,o){if(!n){var a=function(e,t,n){e.objectMode||!1===e.decodeStrings||"string"!=typeof t||(t=h.from(t,n));return t}(t,r,i);r!==a&&(n=!0,i="buffer",r=a)}var s=t.objectMode?1:r.length;t.length+=s;var u=t.length<t.highWaterMark;u||(t.needDrain=!0);if(t.writing||t.corked){var c=t.lastBufferedRequest;t.lastBufferedRequest={chunk:r,encoding:i,isBuf:n,callback:o,next:null},c?c.next=t.lastBufferedRequest:t.bufferedRequest=t.lastBufferedRequest,t.bufferedRequestCount+=1}else w(e,t,!1,s,r,i,o);return u}(this,i,s,e,t,n)),a},m.prototype.cork=function(){this._writableState.corked++},m.prototype.uncork=function(){var e=this._writableState;e.corked&&(e.corked--,e.writing||e.corked||e.finished||e.bufferProcessing||!e.bufferedRequest||x(this,e))},m.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},Object.defineProperty(m.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),m.prototype._write=function(e,t,n){n(new Error("_write() is not implemented"))},m.prototype._writev=null,m.prototype.end=function(e,t,n){var r=this._writableState;"function"==typeof e?(n=e,e=null,t=null):"function"==typeof t&&(n=t,t=null),null!=e&&this.write(e,t),r.corked&&(r.corked=1,this.uncork()),r.ending||r.finished||function(e,t,n){t.ending=!0,S(e,t),n&&(t.finished?o.nextTick(n):e.once("finish",n));t.ended=!0,e.writable=!1}(this,r,n)},Object.defineProperty(m.prototype,"destroyed",{get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(e){this._writableState&&(this._writableState.destroyed=e)}}),m.prototype.destroy=y.destroy,m.prototype._undestroy=y.undestroy,m.prototype._destroy=function(e,t){this.end(),t(e)}}).call(this,n(7),n(17).setImmediate,n(8))},function(e,t){var n=/^"([^]*)"(?:\^\^(.+)|@([\-a-z]+))?$/i,r=/["\\\t\n\r\b\f\u0000-\u0019\ud800-\udbff]/,i=/["\\\t\n\r\b\f\u0000-\u0019]|[\ud800-\udbff][\udc00-\udfff]/g,o={"\\":"\\\\",'"':'\\"',"\t":"\\t","\n":"\\n","\r":"\\r","\b":"\\b","\f":"\\f"};function a(e,t){if(!(this instanceof a))return new a(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 n="";this._outputStream={write:function(e,t,r){n+=e,r&&r()},end:function(e){e&&e(null,n)}},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 s(e){var t=o[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}a.prototype={_write:function(e,t){this._outputStream.write(e,"utf8",t)},_writeTriple:function(e,t,n,r,i){try{this._graph!==r&&(this._write((null===this._subject?"":this._graph?"\n}\n":".\n")+(r?this._encodeIriOrBlankNode(r)+" {\n":"")),this._subject=null,this._graph="["!==r[0]?r:"]"),this._subject===e?this._predicate===t?this._write(", "+this._encodeObject(n),i):this._write(";\n    "+this._encodePredicate(this._predicate=t)+" "+this._encodeObject(n),i):this._write((null===this._subject?"":".\n")+this._encodeSubject(this._subject=e)+" "+this._encodePredicate(this._predicate=t)+" "+this._encodeObject(n),i)}catch(e){i&&i(e)}},_writeTripleLine:function(e,t,n,r,i){delete this._prefixMatch;try{this._write(this._encodeIriOrBlankNode(e)+" "+this._encodeIriOrBlankNode(t)+" "+this._encodeObject(n)+(r?" "+this._encodeIriOrBlankNode(r)+".\n":".\n"),i)}catch(e){i&&i(e)}},_encodeIriOrBlankNode:function(e){var t=e[0];if("["===t||"("===t||"_"===t&&":"===e[1])return e;r.test(e)&&(e=e.replace(i,s));var n=this._prefixRegex.exec(e);return n?n[1]?this._prefixIRIs[n[1]]+n[2]:e:"<"+e+">"},_encodeLiteral:function(e,t,n){return r.test(e)&&(e=e.replace(i,s)),n?'"'+e+'"@'+n: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"http://www.w3.org/1999/02/22-rdf-syntax-ns#type"===e?"a":this._encodeIriOrBlankNode(e)},_encodeObject:function(e){if('"'!==e[0])return this._encodeIriOrBlankNode(e);var t=n.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,n,r,i){void 0===n?this._writeTriple(e.subject,e.predicate,e.object,e.graph||"",t):"string"!=typeof r?this._writeTriple(e,t,n,"",r):this._writeTriple(e,t,n,r,i)},addTriples:function(e){for(var t=0;t<e.length;t++)this.addTriple(e[t])},addPrefix:function(e,t,n){var r={};r[e]=t,this.addPrefixes(r,n)},addPrefixes:function(e,t){var n=this._prefixIRIs,r=!1;for(var i in e){var o=e[i];/[#\/]$/.test(o)&&n[o]!==(i+=":")&&(r=!0,n[o]=i,null!==this._subject&&(this._write(this._graph?"\n}\n":".\n"),this._subject=null,this._graph=""),this._write("@prefix "+i+" <"+o+">.\n"))}if(r){var a="",s="";for(var u in n)a+=a?"|"+u:u,s+=(s?"|":"")+n[u];a=a.replace(/[\]\/\(\)\*\+\?\.\\\$]/g,"\\$&"),this._prefixRegex=new RegExp("^(?:"+s+")[^/]*$|^("+a+")([a-zA-Z][\\-_a-zA-Z0-9]*)$")}this._write(r?"\n":"",t)},blank:function(e,t){var n,r,i=e;switch(void 0===e?i=[]:"string"==typeof e?i=[{predicate:e,object:t}]:"length"in e||(i=[e]),r=i.length){case 0:return"[]";case 1:if("["!==(n=i[0]).object[0])return"[ "+this._encodePredicate(n.predicate)+" "+this._encodeObject(n.object)+" ]";default:for(var o="[",a=0;a<r;a++)(n=i[a]).predicate===e?o+=", "+this._encodeObject(n.object):(o+=(a?";\n  ":"\n  ")+this._encodePredicate(n.predicate)+" "+this._encodeObject(n.object),e=n.predicate);return o+"\n]"}},list:function(e){for(var t=e&&e.length||0,n=new Array(t),r=0;r<t;r++)n[r]=this._encodeObject(e[r]);return"("+n.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(n,r){t=null,e(n,r)};if(this._endStream)try{return this._outputStream.end(t)}catch(e){}t&&t()}},e.exports=a},function(e,t,n){"use strict";function r(e){return(r="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})(e)}function i(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function o(e,t,n){return t&&i(e.prototype,t),n&&i(e,n),e}function a(e,t){return!t||"object"!==r(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function s(e){return(s=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function u(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&c(e,t)}function c(e,t){return(c=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function l(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var f=n(19),h=n(13),p=n(27),d=n(2),y=n(16),v=n(60),g=n(39).parseRDFaDOM,m=n(40),w=n(4),b=n(6),x=n(37),_=("undefined"==typeof window?n(86):n(28)).fetch,k={"text/n3":!0,"text/turtle":!0,"application/rdf+xml":!0,"application/xhtml+xml":!0,"text/html":!0,"application/ld+json":!0},S={rdf:"application/rdf+xml",owl:"application/rdf+xml",n3:"text/n3",ttl:"text/turtle",nt:"text/n3",acl:"text/n3",html:"text/html",xml:"text/xml"},T={link:y("http://www.w3.org/2007/ont/link#"),http:y("http://www.w3.org/2007/ont/http#"),httph:y("http://www.w3.org/2007/ont/httph#"),rdf:y("http://www.w3.org/1999/02/22-rdf-syntax-ns#"),rdfs:y("http://www.w3.org/2000/01/rdf-schema#"),dc:y("http://purl.org/dc/elements/1.1/"),ldp:y("http://www.w3.org/ns/ldp#")},E=function e(t,n){l(this,e),this.response=t,this.dom=n},O=function(e){function t(){return l(this,t),a(this,s(t).apply(this,arguments))}return u(t,E),o(t,[{key:"parse",value:function(e,t,n,r){var i=e.store;if(this.dom||(this.dom=b.parseXML(t)),"parsererror"===this.dom.documentElement.nodeName)return e.failFetch(n,"Badly formed XML in "+n.resource.uri,"parse_error");var o=new m(i);try{o.parse(this.dom,n.original.uri,n.original,r)}catch(t){return e.failFetch(n,"Syntax error parsing RDF/XML! "+t,"parse_error")}return n.noMeta||i.add(n.original,T.rdf("type"),T.link("RDFDocument"),e.appNode),e.doneFetch(n,this.response)}}],[{key:"toString",value:function(){return"RDFXMLHandler"}},{key:"register",value:function(e){e.mediatypes["application/rdf+xml"]={q:.9}}}]),t}();O.pattern=new RegExp("application/rdf\\+xml");var j=function(e){function t(){return l(this,t),a(this,s(t).apply(this,arguments))}return u(t,E),o(t,[{key:"parse",value:function(e,t,n,r){var i,o;this.dom||(this.dom=b.parseXML(t));var a=e.store,s=this.dom.getElementsByTagName("title");s.length>0&&a.add(n.resource,T.dc("title"),a.literal(s[0].textContent),n.resource);for(var u=this.dom.getElementsByTagName("link"),c=u.length-1;c>=0;c--)o=!1,(i=u[c].getAttribute("rel"))||(i=u[c].getAttribute("rev"),o=!0),i&&e.linkData(n.original,i,u[c].getAttribute("href"),n.resource,o);for(var l=this.dom.getElementsByTagName("script"),f=0;f<l.length;f++){var h=l[f].getAttribute("type");k[h]&&(v(l[f].textContent,a,n.original.uri,h),v(l[f].textContent,a,n.original.uri,h))}if(n.noMeta||a.add(n.resource,T.rdf("type"),T.link("WebPage"),e.appNode),!n.noRDFa&&g)try{g(this.dom,a,n.original.uri)}catch(t){var p="Error trying to parse "+n.resource+" as RDFa:\n"+t+":\n"+t.stack;return e.failFetch(n,p,"parse_error")}return e.doneFetch(n,this.response)}}],[{key:"toString",value:function(){return"XHTMLHandler"}},{key:"register",value:function(e){e.mediatypes["application/xhtml+xml"]={}}}]),t}();j.pattern=new RegExp("application/xhtml");var N=function(e){function t(){return l(this,t),a(this,s(t).apply(this,arguments))}return u(t,E),o(t,[{key:"parse",value:function(e,t,n,r){for(var i=b.parseXML(t),o=0;o<i.childNodes.length;o++)if(1===i.childNodes[o].nodeType){var a=i.childNodes[o].namespaceURI;if(a&&a===a.rdf)return e.addStatus(n.req,"Has XML root element in the RDF namespace, so assume RDF/XML."),new O(this.response,i).parse(e,t,n,r);break}if(i.doctype&&("html"===i.doctype.name&&i.doctype.publicId.match(/^-\/\/W3C\/\/DTD XHTML/)&&i.doctype.systemId.match(/http:\/\/www.w3.org\/TR\/xhtml/)))return e.addStatus(n.req,"Has XHTML DOCTYPE. Switching to XHTML Handler.\n"),new j(this.response,i).parse(e,t,n,r);var s=i.getElementsByTagName("html")[0];if(s){var u=s.getAttribute("xmlns");if(u&&u.match(/^http:\/\/www.w3.org\/1999\/xhtml/))return e.addStatus(n.req,"Has a default namespace for XHTML. Switching to XHTMLHandler.\n"),new j(this.response,i).parse(e,t,n,r)}return e.failFetch(n,"Unsupported dialect of XML: not RDF or XHTML namespace, etc.\n"+t.slice(0,80),901)}}],[{key:"toString",value:function(){return"XMLHandler"}},{key:"register",value:function(e){e.mediatypes["text/xml"]={q:.5},e.mediatypes["application/xml"]={q:.5}}}]),t}();N.pattern=new RegExp("(text|application)/(.*)xml");var I=function(e){function t(){return l(this,t),a(this,s(t).apply(this,arguments))}return u(t,E),o(t,[{key:"parse",value:function(e,t,n,r){var i=e.store;if(t.match(/\s*<\?xml\s+version\s*=[^<>]+\?>/))return e.addStatus(n.req,"Has an XML declaration. We'll assume it's XHTML as the content-type was text/html.\n"),new j(this.response).parse(e,t,n,r);if(t.match(/.*<!DOCTYPE\s+html[^<]+-\/\/W3C\/\/DTD XHTML[^<]+http:\/\/www.w3.org\/TR\/xhtml[^<]+>/))return e.addStatus(n.req,"Has XHTML DOCTYPE. Switching to XHTMLHandler.\n"),new j(this.response).parse(e,t,n,r);if(t.match(/[^(<html)]*<html\s+[^<]*xmlns=['"]http:\/\/www.w3.org\/1999\/xhtml["'][^<]*>/))return e.addStatus(n.req,"Has default namespace for XHTML, so switching to XHTMLHandler.\n"),new j(this.response).parse(e,t,n,r);var o=new RegExp("<title>([\\s\\S]+?)</title>","im").exec(t);return o&&i.add(n.resource,T.dc("title"),i.literal(o[1]),n.resource),i.add(n.resource,T.rdf("type"),T.link("WebPage"),e.appNode),e.addStatus(n.req,"non-XML HTML document, not parsed for data."),e.doneFetch(n,this.response)}}],[{key:"toString",value:function(){return"HTMLHandler"}},{key:"register",value:function(e){e.mediatypes["text/html"]={q:.9}}}]),t}();I.pattern=new RegExp("text/html");var R=function(e){function t(){return l(this,t),a(this,s(t).apply(this,arguments))}return u(t,E),o(t,[{key:"parse",value:function(e,t,n,r){return t.match(/\s*<\?xml\s+version\s*=[^<>]+\?>/)?(e.addStatus(n.req,"Warning: "+n.resource+" has an XML declaration. We'll assume it's XML but its content-type wasn't XML.\n"),new N(this.response).parse(e,t,n,r)):t.slice(0,500).match(/xmlns:/)?(e.addStatus(n.req,"May have an XML namespace. We'll assume it's XML but its content-type wasn't XML.\n"),new N(this.response).parse(e,t,n,r)):(e.addStatus(n.req,"Plain text document, no known RDF semantics."),e.doneFetch(n,this.response))}}],[{key:"toString",value:function(){return"TextHandler"}},{key:"register",value:function(e){e.mediatypes["text/plain"]={q:.5}}}]),t}();R.pattern=new RegExp("text/plain");var A=function(e){function t(){return l(this,t),a(this,s(t).apply(this,arguments))}return u(t,E),o(t,[{key:"parse",value:function(e,t,n,r){var i=e.store,o=p(i,i,n.original.uri,n.original.uri,null,null,"",null);try{o.loadBuf(t)}catch(t){var a="Error trying to parse "+n.resource+" as Notation3:\n"+t;return e.failFetch(n,a,"parse_error",r)}return e.addStatus(n.req,"N3 parsed: "+o.statementCount+" triples in "+o.lines+" lines."),e.store.add(n.original,T.rdf("type"),T.link("RDFDocument"),e.appNode),e.doneFetch(n,this.response)}}],[{key:"toString",value:function(){return"N3Handler"}},{key:"register",value:function(e){e.mediatypes["text/n3"]={q:"1.0"},e.mediatypes["text/turtle"]={q:1}}}]),t}();A.pattern=new RegExp("(application|text)/(x-)?(rdf\\+)?(n3|turtle)");var C={RDFXMLHandler:O,XHTMLHandler:j,XMLHandler:N,HTMLHandler:I,TextHandler:R,N3Handler:A},P=function(){function e(t){var n=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(l(this,e),this.store=t||new f,this.timeout=r.timeout||3e4,this._fetch=r.fetch||_,!this._fetch)throw new Error("No _fetch function availble for Fetcher");this.appNode=this.store.bnode(),this.store.fetcher=this,this.requested={},this.timeouts={},this.redirectedTo={},this.fetchQueue={},this.fetchCallbacks={},this.nonexistent={},this.lookedUp={},this.handlers=[],this.mediatypes={"image/*":{q:.9},"*/*":{q:.1}},b.callbackify(this,["request","fail","refresh","retract","done"]),Object.keys(C).map(function(e){return n.addHandler(C[e])})}return o(e,[{key:"load",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(n=Object.assign({},n),e instanceof Array)return Promise.all(e.map(function(e){return t.load(e,Object.assign({},n))}));var r=e.uri||e;return r=r.split("#")[0],n=this.initFetchOptions(r,n),this.pendingFetchPromise(r,n.baseURI,n)}},{key:"pendingFetchPromise",value:function(e,t,n){var r,i=this;return!n.force&&this.fetchQueue[t]?r=this.fetchQueue[t]:(r=Promise.race([this.setRequestTimeout(e,n),this.fetchUri(e,n)]),this.fetchQueue[t]=r,this.cleanupFetchRequest(t,n,this.timeout)),r.then(function(t){return e in i.timeouts&&(i.timeouts[e].forEach(clearTimeout),delete i.timeouts[e]),t})}},{key:"cleanupFetchRequest",value:function(e,t,n){var r=this;this.timeouts[e]=(this.timeouts[e]||[]).concat(setTimeout(function(){r.isPending(e)||delete r.fetchQueue[e]},n))}},{key:"initFetchOptions",value:function(t,n){var r=this.store;!n.method||"GET"===n.method.toUpperCase()||(n.force=!0),n.resource=r.sym(t),n.baseURI=n.baseURI||t,n.original=r.sym(n.baseURI),n.req=r.bnode(),n.headers=n.headers||{},n.contentType&&(n.headers["content-type"]=n.contentType),n.force&&(n.cache="no-cache");var i=this.acceptString();n.headers.accept=i;var o=e.offlineOverride(t);n.requestedURI=o,e.withCredentials(o,n)&&(n.credentials="include");var a=e.proxyIfNecessary(o);return o!==a&&(n.proxyUsed=!0),n.actualProxyURI=a,n}},{key:"fetchUri",value:function(t,n){var r=this;if(!t)return Promise.reject(new Error("Cannot fetch an empty uri"));if(e.unsupportedProtocol(t))return this.failFetch(n,"fetcher: Unsupported protocol","unsupported_protocol");var i=this.getState(t);if(n.force)delete this.nonexistent[t];else{if("fetched"===i)return Promise.resolve(this.doneFetch(n,{status:200,ok:!0,statusText:"Already loaded into quadstore."}));if("failed"===i&&404===this.requested[t]){var o="Previously failed: "+this.requested[t],a={url:t,status:this.requested[t],statusText:o,responseText:o,headers:{},ok:!1,body:null,bodyUsed:!1,size:0,timeout:0};return this.failFetch(n,o,this.requested[t],a)}}this.fireCallbacks("request",[t]),this.requested[t]=!0,n.noMeta||this.saveRequestMetadata(t,n);var s=n.actualProxyURI;return this._fetch(s,n).then(function(e){return r.handleResponse(e,t,n)},function(e){var t={url:s,status:999,statusText:(e.name||"network failure")+": "+(e.errno||e.code||e.type),responseText:e.message,headers:{},ok:!1,body:null,bodyUsed:!1,size:0,timeout:0};return console.log("Fetcher: <"+s+"> Non-HTTP fetch error: "+e),r.failFetch(n,"fetch failed: "+e,999,t)})}},{key:"nowOrWhenFetched",value:function(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};e=e.uri||e,"function"==typeof t?n=t:void 0===t||(t instanceof d?r.referringTerm=t:r=t),this.load(e,r).then(function(t){if(n)if(t)if(t.ok)n(!0,"OK",t);else{var r="HTTP error: Status "+t.status+" ("+t.statusText+")";t.responseText&&(r+=" "+t.responseText),console.log(r+" fetching "+e),n(!1,r,t)}else{var i="@@ nowOrWhenFetched:  no response object!";console.log(i),n(!1,i)}},function(t){var r=t.message||t.statusText;r="Failed to load  <"+e+"> "+r,console.log(r),t.response&&t.response.status&&(r+=" status: "+t.response.status),n(!1,r,t.response)})}},{key:"addStatus",value:function(e,t){var n=new Date;t="["+n.getHours()+":"+n.getMinutes()+":"+n.getSeconds()+"."+n.getMilliseconds()+"] "+t;var r=this.store,i=r.the(e,T.link("status"));i&&i.append?i.append(r.literal(t)):h.warn("web.js: No list to add to: "+i+","+t)}},{key:"failFetch",value:function(e,t,n,r){this.addStatus(e.req,t),e.noMeta||this.store.add(e.original,T.link("error"),t);var i=(e.method||"GET").toUpperCase();("GET"===i||"HEAD"===i)&&(e.resource.sameTerm(e.original),this.requested[w.docpart(e.original.uri)]=n,this.fireCallbacks("fail",[e.original.uri,t]));var o=new Error("Fetcher: "+t);return o.status=n,o.statusText=t,o.response=r,Promise.reject(o)}},{key:"linkData",value:function(e,t,n,r,i){if(n){var o,a=this.store,s=a.sym(w.join(n,e.uri));if("alternate"===t||"seeAlso"===t||"meta"===t||"describedby"===t){if(s.uri===e.uri)return;o=T.rdfs("seeAlso")}else o="type"===t?a.sym("http://www.w3.org/1999/02/22-rdf-syntax-ns#type"):a.sym(w.join(encodeURIComponent(t),"http://www.iana.org/assignments/link-relations/"));i?a.add(s,o,e,r):a.add(e,o,s,r)}}},{key:"parseLinkHeader",value:function(e,t,n){if(e)for(var r=/[^\(\)<>@,;:"\/\[\]\?={} \t]+=(([^\(\)<>@,;:"\/\[\]\?={} \t]+)|("[^"]*"))/g,i=e.match(/<[^>]*>\s*(\s*;\s*[^()<>@,;:"\/[\]?={} \t]+=(([^\(\)<>@,;:"\/\[\]\?={} \t]+)|("[^"]*")))*(,|$)/g),o=0;o<i.length;o++)for(var a=i[o].split(">"),s=a[0].substring(1),u=a[1].match(r),c=0;c<u.length;c++){var l=u[c].split("=")[1].replace(/["']/g,"");this.linkData(t,l,s,n)}}},{key:"doneFetch",value:function(e,t){return this.addStatus(e.req,"Done."),this.requested[e.original.uri]="done",this.fireCallbacks("done",[e.original.uri]),t.req=e.req,t}},{key:"nowKnownAs",value:function(e,t){this.lookedUp[e.uri]?this.lookedUp[t.uri]||this.lookUpThing(t,e):this.lookedUp[t.uri]&&(this.lookedUp[e.uri]||this.lookUpThing(e,t))}},{key:"putBack",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};e=e.uri||e;var n=new d(e).doc();return t.contentType=t.contentType||"text/turtle",t.data=x(n,this.store,n.uri,t.contentType),this.webOperation("PUT",e,t)}},{key:"webCopy",value:function(e,t,n){var r=this;return this.webOperation("GET",e).then(function(e){return r.webOperation("PUT",t,{data:e.responseText,contentType:n})})}},{key:"delete",value:function(e,t){var n=this;return this.webOperation("DELETE",e,t).then(function(t){return n.requested[e]=404,n.nonexistent[e]=!0,n.unload(n.store.sym(e)),t})}},{key:"createIfNotExists",value:function(e){return new Promise(function(t,n){kb.fetcher.load(e).then(function(n){console.log("createIfNotExists doc exists, all good "+e),t(n)},function(r){404===r.response.status?(console.log("createIfNotExists doc does NOT exist, will create... "+e),kb.fetcher.webOperation("PUT",e.uri,{data:"",contentType:"text/turtle"}).then(function(n){delete kb.fetcher.requested[e.uri],console.log("createIfNotExists doc created ok "+e),t(n)},function(t){console.log("createIfNotExists doc FAILED: "+e+": "+t),n(t)})):(console.log("createIfNotExists doc load error NOT 404:  "+e+": "+r),n(r))})})}},{key:"createContainer",value:function(e,t,n){var r={"content-type":"text/turtle",link:T.ldp("BasicContainer")+'; rel="type"'};t&&(r.slug=t);var i={headers:r};return n&&(i.body=n),this.webOperation("POST",e,i)}},{key:"webOperation",value:function(t,n){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};n=n.uri||n,r.method=t,r.body=r.data||r.body,r.force=!0;var i=this;if(r.body&&!r.contentType)throw new Error("Web operation sending data must have a defined contentType.");return r.contentType&&(r.headers=r.headers||{},r.headers["content-type"]=r.contentType),e.withCredentials(n,r)&&(r.credentials="include"),new Promise(function(e,o){i._fetch(n,r).then(function(r){if(r.ok)"PUT"!==t&&"PATCH"!==t&&"POST"!==t&&"DELETE"!==t||delete i.requested[n],r.body?r.text().then(function(t){r.responseText=t,e(r)}):e(r);else{var a="Web error: "+r.status;r.statusText&&(a+=" ("+r.statusText+")"),a+=" on "+t+" of <"+n+">",r.responseText&&(a+=": "+r.responseText);var s=new Error(a);s.response=r,o(s)}},function(e){o(new Error("Fetch error for "+t+" of <"+n+">:"+e))})})}},{key:"lookUpThing",value:function(e,t){var n=this,r=this.store.uris(e);return(r=r.map(function(e){return w.docpart(e)})).forEach(function(e){n.lookedUp[e]=!0}),this.load(r,{referringTerm:t})}},{key:"getHeader",value:function(e,t){for(var n=this.store,r=n.each(void 0,T.link("requestedURI"),e.uri),i=0;i<r.length;i++){var o=r[i];if(void 0!==o){var a=n.any(o,T.link("response"));if(void 0!==a){var s=n.each(a,T.httph(t.toLowerCase()));return s.length?s.map(function(e){return e.value}):[]}}}}},{key:"saveRequestMetadata",value:function(e,t){var n=t.req,r=this.store,i=t.referringTerm;this.addStatus(t.req,"Accept: "+t.headers.accept),i&&i.uri&&r.add(e,T.link("requestedBy"),i.uri,this.appNode),t.original&&t.original.uri!==e&&r.add(n,T.link("orginalURI"),r.literal(t.original.uri),this.appNode);var o=new Date,a="["+o.getHours()+":"+o.getMinutes()+":"+o.getSeconds()+"] ";r.add(n,T.rdfs("label"),r.literal(a+" Request for "+e),this.appNode),r.add(n,T.link("requestedURI"),r.literal(e),this.appNode),r.add(n,T.link("status"),r.collection(),this.appNode)}},{key:"saveResponseMetadata",value:function(e,t){var n=this.store,r=n.bnode();return n.add(t.req,T.link("response"),r,r),n.add(r,T.http("status"),n.literal(e.status),r),n.add(r,T.http("statusText"),n.literal(e.statusText),r),t.resource.uri.startsWith("http")?(e.headers.forEach(function(e,i){n.add(r,T.httph(i),e,r),"content-type"===i&&n.add(t.resource,T.rdf("type"),b.mediaTypeClass(e),r)}),r):r}},{key:"objectRefresh",value:function(e){var t=this.store.uris(e);if(void 0!==t)for(var n=0;n<t.length;n++)this.refresh(this.store.sym(w.docpart(t[n])))}},{key:"refresh",value:function(e,t){this.fireCallbacks("refresh",arguments),this.nowOrWhenFetched(e,{force:!0,clearPreviousData:!0},t)}},{key:"refreshIfExpired",value:function(e,t){var n=this.getHeader(e,"Expires");!n||new Date(n).getTime()<=(new Date).getTime()?this.refresh(e,t):t(!0,"Not expired",{})}},{key:"retract",value:function(e){this.store.removeMany(void 0,void 0,void 0,e),e.uri&&delete this.requested[w.docpart(e.uri)],this.fireCallbacks("retract",arguments)}},{key:"getState",value:function(e){return void 0===this.requested[e]?"unrequested":!0===this.requested[e]?"requested":"done"===this.requested[e]?"fetched":"redirected"===this.requested[e]?this.getState(this.redirectedTo[e]):"failed"}},{key:"isPending",value:function(e){return!0===this.requested[e]}},{key:"unload",value:function(e){this.store.removeDocument(e),delete this.requested[e.uri]}},{key:"addHandler",value:function(e){this.handlers.push(e),e.register(this)}},{key:"retryNoCredentials",value:function(e,t){console.log("web: Retrying with no credentials for "+t.resource),t.retriedWithNoCredentials=!0,delete this.requested[e];var n=Object.assign({},t,{withCredentials:!1});return this.addStatus(t.req,"Abort: Will retry with credentials SUPPRESSED to see if that helps"),this.load(e,n)}},{key:"isCrossSite",value:function(e){if("undefined"==typeof document||!document.location)return!1;var t=w.hostpart,n=""+document.location;return t(n)&&t(e)&&t(n)!==t(e)}},{key:"handleError",value:function(t,n,r){if(this.isCrossSite(n)){if(r.withCredentials&&!r.retriedWithNoCredentials)return this.retryNoCredentials(n,r);var i=e.crossSiteProxy(n);if(i&&!r.proxyUsed)return console.log("web: Direct failed so trying proxy "+i),this.redirectToProxy(i,r)}var o;return t.message?o="Fetch error: "+t.message:(o=t.statusText,t.responseText&&(o+=" ".concat(t.responseText))),this.failFetch(r,o,t.status||998,t)}},{key:"addType",value:function(e,t,n,r){var i=t;if(r){var o=n.any(i,T.link("requestedURI"));o&&o!==r&&n.add(n.sym(r),T.rdf("type"),e,this.appNode)}for(;;){var a=n.any(i,T.link("requestedURI"));if(a&&a.value&&n.add(n.sym(a.value),T.rdf("type"),e,this.appNode),!(i=n.any(void 0,n.sym("http://www.w3.org/2007/ont/link#redirectedRequest"),i)))break;var s=n.any(i,n.sym("http://www.w3.org/2007/ont/link#response"));if(!s)break;var u=n.any(s,n.sym("http://www.w3.org/2007/ont/http#status"));if(!u)break;if("301"!==u&&"302"!==u)break}}},{key:"handleResponse",value:function(e,t,n){var r=this,i=this.store,o=e.headers,a=n.req,s=this.saveResponseMetadata(e,n),u=this.normalizedContentType(n,o)||"",c=o.get("content-location");if(0===e.status)return console.log("Masked error - status 0 for "+t),this.handleError(e,t,n);if(e.status>=400)return 404===e.status&&(this.nonexistent[n.original.uri]=!0,this.nonexistent[t]=!0),this.saveErrorResponse(e,s).then(function(){var t=n.resource+" "+e.statusText;return r.failFetch(n,t,e.status,e)});var l=null,f=null;if(c&&(f=w.join(c,t))!==t&&(l=f),200===e.status){this.addType(T.link("Document"),a,i,t),l&&this.addType(T.link("Document"),a,i,l),n.clearPreviousData&&i.removeDocument(n.resource);var h=u.includes("image/")||u.includes("application/pdf");u&&h&&(this.addType(i.sym("http://purl.org/dc/terms/Image"),a,i,t),l&&this.addType(i.sym("http://purl.org/dc/terms/Image"),a,i,l))}if(c){if(!n.force&&l&&"done"===this.requested[f])return this.doneFetch(n,e);this.requested[f]=!0}this.parseLinkHeader(o.get("link"),n.original,a);var p=this.handlerForContentType(u,e);return p?e.text().then(function(t){return e.responseText=t,p.parse(r,t,n,e)}):(this.addStatus(a,"Fetch over. No data handled."),this.doneFetch(n,e))}},{key:"saveErrorResponse",value:function(e,t){var n=this.store;return e.text().then(function(e){e.length>10&&n.add(t,T.http("content"),n.literal(e),t)})}},{key:"handlerForContentType",value:function(e,t){if(!e)return null;var n=this.handlers.find(function(t){return e.match(t.pattern)});return n?new n(t):null}},{key:"guessContentType",value:function(e){return S[e.split(".").pop()]}},{key:"normalizedContentType",value:function(e,t){if(e.forceContentType)return e.forceContentType;var n=t.get("content-type");if(!n||n.includes("application/octet-stream")){var r=this.guessContentType(e.resource.uri);if(r)return r}var i=w.protocol(e.resource.uri);return!n&&["file","chrome"].includes(i)?"text/xml":n}},{key:"redirectToProxy",value:function(e,t){var n=this;this.addStatus(t.req,"BLOCKED -> Cross-site Proxy to <"+e+">"),t.proxyUsed=!0;var r=this.store,i=t.req;t.noMeta||(r.add(i,T.link("redirectedTo"),r.sym(e),i),this.addStatus(i,"redirected to new request")),this.requested[t.resource.uri]="redirected",this.redirectedTo[t.resource.uri]=e;var o=Object.assign({},t);return o.baseURI=t.resource.uri,this.fetchUri(e,o).then(function(e){return o.noMeta||r.add(i,T.link("redirectedRequest"),o.req,n.appNode),e})}},{key:"setRequestTimeout",value:function(e,t){var n=this;return new Promise(function(r){n.timeouts[e]=(n.timeouts[e]||[]).concat(setTimeout(function(){!n.isPending(e)||t.retriedWithNoCredentials||t.proxyUsed||r(n.failFetch(t,"Request to ".concat(e," timed out"),"timeout"))},n.timeout))})}},{key:"addFetchCallback",value:function(e,t){this.fetchCallbacks[e]?this.fetchCallbacks[e].push(t):this.fetchCallbacks[e]=[t]}},{key:"acceptString",value:function(){var e="";for(var t in this.mediatypes)for(var n in""!==e&&(e+=", "),e+=t,this.mediatypes[t])e+=";"+n+"="+this.mediatypes[t][n];return e}}],[{key:"crossSiteProxy",value:function(t){return e.crossSiteProxyTemplate?e.crossSiteProxyTemplate.replace("{uri}",encodeURIComponent(t)):void 0}},{key:"offlineOverride",value:function(e){var t,n=e;return"undefined"!=typeof window&&window.panes&&(t=window.panes.UI)&&t.preferences&&t.preferences.get("offlineModeUsingLocalhost")&&"http://"===n.slice(0,7)&&"localhost/"!==n.slice(7,17)&&(n="http://localhost/"+n.slice(7),h.warn("Localhost kludge for offline use: actually getting <"+n+">")),n}},{key:"proxyIfNecessary",value:function(t){var n;if("undefined"!=typeof window&&window.panes&&(n=window.panes.UI)&&n.isExtension)return t;if("undefined"!=typeof $SolidTestEnvironment&&$SolidTestEnvironment.localSiteMap){var r=function e(t,n){var r=n[t.shift()];return r?"string"==typeof r?r+t.join("/"):t?e(t,r):null:null}(t.split("/").slice(2),$SolidTestEnvironment.localSiteMap);if(r)return r}return e.crossSiteProxyTemplate&&"undefined"!=typeof document&&document.location&&"https:"===(""+document.location).slice(0,6)&&"http:"===t.slice(0,5)?e.crossSiteProxyTemplate.replace("{uri}",encodeURIComponent(t)):t}},{key:"unsupportedProtocol",value:function(e){var t=w.protocol(e);return"tel"===t||"mailto"===t||"urn"===t}},{key:"withCredentials",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=e.startsWith("https:");return void 0!==t.withCredentials&&(n=t.withCredentials),n}}]),e}();e.exports=P,e.exports.HANDLERS=C,e.exports.CONTENT_TYPE_BY_EXT=S},function(e,t,n){"use strict";e.exports=function(e,t,n,o,a,s){n=n||e.uri,s=s||{},o=o||"text/turtle";try{var u=i(t);s.flags&&u.setFlags(s.flags);var c,l=t.statementsMatching(void 0,void 0,void 0,e);switch(u.suggestNamespaces(t.namespaces),u.setBase(n),o){case"application/rdf+xml":return f(null,u.statementsToXML(l));case"text/n3":case"application/n3":return f(null,u.statementsToN3(l));case"text/turtle":case"application/x-turtle":return u.setFlags("si"),f(null,u.statementsToN3(l));case"application/n-triples":return u.setFlags("deinprstux"),f(null,u.statementsToNTriples(l));case"application/ld+json":u.setFlags("deinprstux"),c=u.statementsToNTriples(l),r.convertToJson(c,a);break;case"application/n-quads":case"application/nquads":return u.setFlags("deinprstux q"),f(null,u.statementsToNTriples(l));default:throw new Error("Serialize: Content-type "+o+" not supported for data write.")}}catch(e){if(a)return a(e);throw e}function f(e,t){return a?void a(e,t):t}};var r=n(42),i=n(38)},function(e,t,n){"use strict";var r=n(2),i=n(9),o=n(4),a=n(6),s=n(41),u=function(){var e=function(e){this.flags="",this.base=null,this.prefixes=[],this.namespaces=[],this.suggestPrefix("rdf","http://www.w3.org/1999/02/22-rdf-syntax-ns#"),this.suggestPrefix("xml","reserved:reservedForFutureUse"),this.namespacesUsed=[],this.keywords=["a"],this.prefixchars="abcdefghijklmnopqustuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",this.incoming=null,this.formulas=[],this.store=e};e.prototype.setBase=function(e){return this.base=e,this},e.prototype.setFlags=function(e){return this.flags=e||"",this},e.prototype.toStr=function(e){var t=e.toNT();return"Graph"===e.termType&&(this.formulas[t]=e),t},e.prototype.fromStr=function(e){if("{"===e[0]){var t=this.formulas[e];return t||console.log("No formula object for "+e),t}return this.store.fromNT(e)},e.prototype.suggestPrefix=function(e,t){"default"!==e.slice(0,7)&&"ns"!==e.slice(0,2)&&e&&t&&(e in this.namespaces||t in this.prefixes||(this.prefixes[t]=e,this.namespaces[e]=t))},e.prototype.suggestNamespaces=function(e){for(var t in e)return this.suggestPrefix(t,e[t]),this},e.prototype.checkIntegrity=function(){var e,t;for(e in this.namespaces)if(this.prefixes[this.namespaces[e]]!==e)throw new Error("Serializer integity error 1: "+e+", "+this.namespaces[e]+", "+this.prefixes[this.namespaces[e]]+"!");for(t in this.prefixes)if(this.namespaces[this.prefixes[t]]!==t)throw new Error("Serializer integity error 2: "+t+", "+this.prefixs[t]+", "+this.namespaces[this.prefixes[t]]+"!")},e.prototype.makeUpPrefix=function(t){var n=t;var r=function(n){return!!e.prototype.validPrefix.test(n)&&"ns"!==n&&!(n in this.namespaces)&&(this.prefixes[t]=n,this.namespaces[n]=t,n)}.bind(this);"#/".indexOf(n[n.length-1])>=0&&(n=n.slice(0,-1));var i=n.lastIndexOf("/");i>=0&&(n=n.slice(i+1));for(var o=0;o<n.length&&this.prefixchars.indexOf(n[o]);)o++;if((n=n.slice(0,o)).length<6&&r(n))return n;if(r(n.slice(0,3)))return n.slice(0,3);if(r(n.slice(0,2)))return n.slice(0,2);if(r(n.slice(0,4)))return n.slice(0,4);if(r(n.slice(0,1)))return n.slice(0,1);if(r(n.slice(0,5)))return n.slice(0,5);e.prototype.validPrefix.test(n)||(n="n");for(var a=0;;a++)if(r(n.slice(0,3)+a))return n.slice(0,3)+a},e.prototype.rootSubjects=function(e){for(var t={},n={},r={},i=0;i<e.length;i++){var o=e[i],a=function(e){t.hasOwnProperty(e)||(t[e]=[]),t[e].push(o.subject)};[o.subject,o.predicate,o.object].map(function(e){"BlankNode"===e.termType?r[e.toNT()]=!0:"Collection"===e.termType&&e.elements.forEach(function(e){a(e)})}),a(e[i].object);var s=n[this.toStr(o.subject)];s||(s=[]),s.push(o),n[this.toStr(o.subject)]=s}var u=[];for(var c in n)if(n.hasOwnProperty(c)){var l=this.fromStr(c);"BlankNode"===l.termType&&t[l]&&1===t[l].length||u.push(l)}this.incoming=t;for(var f={},h=0;h<u.length;h++)f[u[h].toNT()]=!0;return{roots:u,subjects:n,rootsHash:f,incoming:t}},e.prototype.toN3=function(e){return this.statementsToN3(e.statements)},e.prototype._notQNameChars="\t\r\n !\"#$%&'()*.,+/;<=>?@[\\]^`{|}~",e.prototype._notNameChars=e.prototype._notQNameChars+":",e.prototype.explicitURI=function(e){return"<"+(e=this.flags.indexOf("r")<0&&this.base?o.refTo(this.base,e):this.flags.indexOf("u")>=0?function(e){for(var t,n="",r=0;r<e.length;r++)t=e.charCodeAt(r),n+=t>65535?"\\U"+("00000000"+t.toString(16)).slice(-8):t>126?"\\u"+("0000"+t.toString(16)).slice(-4):e[r];return n}(e):encodeURI(e))+">"},e.prototype.statementsToNTriples=function(e){var t=e.slice();t.sort();for(var n="",r="http://www.w3.org/1999/02/22-rdf-syntax-ns#",o=this,a=this.store,s=function e(t){if("Collection"!==t.termType)return o.atomicTermToN3(t);for(var s=t.elements,u=a.sym(r+"nill"),c=s.length-1;c>=0;c--){var l=new i;n+=e(l)+" "+e(a.sym(r+"first"))+" "+e(s[c])+".\n",n+=e(l)+" "+e(a.sym(r+"rest"))+" "+e(u)+".\n",u=l}return o.atomicTermToN3(u)},u=0;u<t.length;u++){var c=t[u],l="";l+=s(c.subject)+" ",l+=s(c.predicate)+" ",l+=s(c.object)+" ",this.flags.indexOf("q")>=0&&(l+=s(c.why)+" "),n+=l+=".\n"}return n},e.prototype.statementsToN3=function(t){var n=this.store,r={"http://www.w3.org/1999/02/22-rdf-syntax-ns#type":"aaa:00"};t.sort(function(e,t){return a.heavyCompareSPO(e,t,n,r)}),this.base&&!this.defaultNamespace&&(this.defaultNamespace=this.base+"#");var i={};this.flags.indexOf("s")<0&&(i["http://www.w3.org/2002/07/owl#sameAs"]="="),this.flags.indexOf("t")<0&&(i["http://www.w3.org/1999/02/22-rdf-syntax-ns#type"]="a"),this.flags.indexOf("i")<0&&(i["http://www.w3.org/2000/10/swap/log#implies"]="=>");var o=function(e){for(var t="",n=0;n<e;n++)t+=" ";return t},s=function e(t){for(var n="",r=0;r<t.length;r++){var i=t[r],o="string"==typeof i?i:e(i);if(0!==r){var a=n.slice(-1)||" ";","===o||";"===o||("."!==o||"0123456789.".includes(a))&&(n+=" ")}n+=o}return n};var u=function(e){for(var t=this.rootSubjects(e),n=t.roots,r=[],i=0;i<n.length;i++){var o=n[i];r.push(c(o,t))}return r}.bind(this);function c(e,t){return"BlankNode"!==e.termType||t.incoming[e]?[h(e,t)].concat([l(e,t)]).concat(["."]):f(e,t,!0).concat(["."])}var l=function(e,t){var n=[],r=null,o=t.subjects[this.toStr(e)]||[];if(void 0===o)throw new Error("Cant find statements for "+e);for(var a=[],s=0;s<o.length;s++){var u=o[s];u.predicate.uri===r?a.push(","):(r&&(n=n.concat([a]).concat([";"]),a=[]),n.push(i[u.predicate.uri]?i[u.predicate.uri]:h(u.predicate,t))),r=u.predicate.uri,a.push(f(u.object,t))}return n=n.concat([a])}.bind(this);var f=function(e,t,n){return"BlankNode"!==e.termType||!n&&void 0!==t.rootsHash[e.toNT()]?h(e,t):t.subjects[this.toStr(e)]?["[",l(e,t),"]"]:"[]"}.bind(this);e.prototype.termToN3=h;var h=function(e,t){var n,r;switch(e.termType){case"Graph":return(r=(r=["{"]).concat(u(e.statements))).concat(["}"]);case"Collection":for(r=["("],n=0;n<e.elements.length;n++)r.push([f(e.elements[n],t)]);return r.push(")"),r;default:return this.atomicTermToN3(e)}}.bind(this);var p=function(){var e="";for(var t in this.defaultNamespace&&(e+="@prefix : "+this.explicitURI(this.defaultNamespace)+".\n"),this.prefixes)this.prefixes.hasOwnProperty(t)&&this.namespacesUsed[t]&&(e+="@prefix "+this.prefixes[t]+": "+this.explicitURI(t)+".\n");return e+"\n"}.bind(this),d=u(t);return p()+function e(t,n){var r="",i=1e5;void 0===n&&(n=-1);for(var a=0;a<t.length;a++){var u=t[a];if("string"!=typeof u){var c=e(u,n+1);if(c.length<10*(80-4*n)&&c.indexOf('"""')<0){var l=s(u);l.length<80-4*n&&(u=l,c="")}c&&(i=1e4),r+=c}if("string"==typeof u){if(1===u.length&&"\n"===r.slice(-1)&&",.;".indexOf(u)>=0){r=r.slice(0,-1)+u+"\n",i+=1;continue}if(i<4*n+4||i+u.length+1<80&&";.".indexOf(r[r.length-2])<0)r=r.slice(0,-1)+" "+u+"\n",i+=u.length+1;else{var f=o(4*n)+u;r+=f+"\n",i=f.length,n<0&&(r+="\n",i=1e5)}}}return r}(d)},e.prototype.atomicTermToN3=function(e,t){switch(e.termType){case"BlankNode":case"Variable":return e.toNT();case"Literal":var n=e.value;if("string"!=typeof n)throw new TypeError("Value of RDF literal node must be a string");if(e.datatype&&this.flags.indexOf("x")<0)switch(e.datatype.uri){case"http://www.w3.org/2001/XMLSchema#integer":return n;case"http://www.w3.org/2001/XMLSchema#decimal":return n.indexOf(".")<0&&(n+=".0"),n;case"http://www.w3.org/2001/XMLSchema#double":return n.indexOf(".")<0&&(n+=".0"),n.indexOf("e")<0&&(n+="e0"),n;case"http://www.w3.org/2001/XMLSchema#boolean":return"1"===e.value?"true":"false"}var r=this.stringToN3(e.value);return e.language?r+="@"+e.language:e.datatype.equals(s.string)||(r+="^^"+this.atomicTermToN3(e.datatype,t)),r;case"NamedNode":return this.symbolToN3(e);default:throw new Error("Internal: atomicTermToN3 cannot handle "+e+" of termType: "+e.termType)}},e.prototype.validPrefix=new RegExp(/^[a-zA-Z][a-zA-Z0-9]*$/),e.prototype.forbidden1=new RegExp(/[\\"\b\f\r\v\t\n\u0080-\uffff]/gm),e.prototype.forbidden3=new RegExp(/[\\"\b\f\r\v\u0080-\uffff]/gm),e.prototype.stringToN3=function(t,n){n||(n="e");var r,i,o,a,s,u="";for(t.length>20&&'"'!==t.slice(-1)&&n.indexOf("n")<0&&(t.indexOf("\n")>0||t.indexOf('"')>0)?(a='"""',s=e.prototype.forbidden3):(a='"',s=e.prototype.forbidden1),r=0;r<t.length;){if(s.lastIndex=0,null==s.exec(t.slice(r)))break;i=r+s.lastIndex-1,u+=t.slice(r,i);var c=t[i];'"'===c&&'"""'===a&&'"""'!==t.slice(i,i+3)?u+=c:(o='\b\f\r\t\v\n\\"'.indexOf(c))>=0?u+="\\"+'bfrtvn\\"'[o]:n.indexOf("e")>=0?u+="\\u"+("000"+c.charCodeAt(0).toString(16).toLowerCase()).slice(-4):u+=c,r=i+1}return a+u+t.slice(r)+a},e.prototype.symbolToN3=function(t){var n=t.uri,r=n.indexOf("#");if(r<0&&this.flags.indexOf("/")<0&&(r=n.lastIndexOf("/")),r>=0&&this.flags.indexOf("p")<0&&(0===n.indexOf("http")||0===n.indexOf("ws")||0===n.indexOf("file"))){for(var i=!0,o=r+1;o<n.length;o++)if(e.prototype._notNameChars.indexOf(n[o])>=0){i=!1;break}if(i){var a=n.slice(r+1),s=n.slice(0,r+1);if(this.defaultNamespace&&this.defaultNamespace===s&&this.flags.indexOf("d")<0)return this.flags.indexOf("k")>=0&&this.keyords.indexOf(a)<0?a:":"+a;var u=this.prefixes[s];if(u||(u=this.makeUpPrefix(s)),u)return this.namespacesUsed[s]=!0,u+":"+a}}return this.explicitURI(n)},e.prototype.writeStore=function(e){var t=this.store,n=t.fetcher,r=n&&n.appNode,i=this.store.index[3];for(var o in i){var a=t.fromNT(o);r&&a.sameTerm(r)||e("\n"+this.atomicTermToN3(a)+" "+this.atomicTermToN3(t.sym("http://www.w3.org/2000/10/swap/log#semantics"))+" { "+this.statementsToN3(t.statementsMatching(void 0,void 0,void 0,a))+" }.\n")}t.statementsMatching(void 0,t.sym("http://www.w3.org/2007/ont/link#requestedURI")).map(function(n){e("\n<"+n.object.value+"> log:metadata {\n");var r=t.statementsMatching(void 0,void 0,void 0,n.subject);e(this.statementsToN3(this.statementsToN3(r))),e("}.\n")});var s=[];r&&s.push(r);var u=[];s.map(function(e){u=u.concat(t.statementsMatching(void 0,void 0,void 0,e))}),e(this.statementsToN3(u))},e.prototype.statementsToXML=function(t){var n=[];n["http://www.w3.org/1999/02/22-rdf-syntax-ns#"]=!0;var i="http://www.w3.org/1999/02/22-rdf-syntax-ns#_",o=function(e){for(var t="",n=0;n<e;n++)t+=" ";return t},u=function e(t){for(var n="",r=0;r<t.length;r++){var i=t[r];n+="string"==typeof i?i:e(i)}return n};var c=function(e){this.suggestPrefix("rdf","http://www.w3.org/1999/02/22-rdf-syntax-ns#");for(var t=this.rootSubjects(e),n=t.roots,r=[],i=0;i<n.length;i++){var o=n[i];r.push(h(o,t))}return r}.bind(this);function l(e){return void 0===e?"@@@undefined@@@@":e.replace(/[&<"]/g,function(e){switch(e[0]){case"&":return"&amp;";case"<":return"&lt;";case'"':return"&quot;"}})}var f=function(e){return l(this.base?a.uri.refTo(this.base,e.uri):e.uri)}.bind(this);var h=function(e,t){var n,o,a,u,c=[],v=t.subjects[this.toStr(e)];if(void 0===v)return d(e,t);v.sort(function(e,t){var n=e.predicate.uri,r=t.predicate.uri;if(n.substring(0,i.length)===i||r.substring(0,i.length)===i)return n.localeCompare(r);var o=n.substring(i.length),a=r.substring(i.length),s=parseInt(o,10),u=parseInt(a,10);return isNaN(s)||isNaN(u)||s!==o||u!==a?n.localeCompare(r):s-u});for(var g=0;g<v.length;g++)if("http://www.w3.org/1999/02/22-rdf-syntax-ns#type"!==(a=v[g]).predicate.uri||n||"symbol"!==a.object.termType){if((u=a.predicate).uri.substr(0,i.length)===i){var m=u.uri.substr(i.length);m===parseInt(m,10).toString()&&(u=new r("http://www.w3.org/1999/02/22-rdf-syntax-ns#li"))}switch(o=y(u),a.object.termType){case"BlankNode":c=1===t.incoming[a.object].length?c.concat(["<"+o+' rdf:parseType="Resource">',h(a.object,t),"</"+o+">"]):c.concat(["<"+o+' rdf:nodeID="'+a.object.toNT().slice(2)+'"/>']);break;case"NamedNode":c=c.concat(["<"+o+' rdf:resource="'+f(a.object)+'"/>']);break;case"Literal":c=c.concat(["<"+o+(a.object.datatype.equals(s.string)?"":' rdf:datatype="'+l(a.object.datatype.uri)+'"')+(a.object.language?' xml:lang="'+a.object.language+'"':"")+">"+l(a.object.value)+"</"+o+">"]);break;case"Collection":c=c.concat(["<"+o+' rdf:parseType="Collection">',p(a.object,t),"</"+o+">"]);break;default:throw new Error("Can't serialize object of type "+a.object.termType+" into XML")}}else n=a.object;var w=n?y(n):"rdf:Description",b="";return"BlankNode"===e.termType?t.incoming[e]&&1===t.incoming[e].length||(b=' rdf:nodeID="'+e.toNT().slice(2)+'"'):b=' rdf:about="'+f(e)+'"',["<"+w+b+">"].concat([c]).concat(["</"+w+">"])}.bind(this);function p(e,t){for(var n=[],r=0;r<e.elements.length;r++)n.push(h(e.elements[r],t));return n}var d=function(e,t){var n=[],r=t.subjects[this.toStr(e)];if(!r)return n;r.sort();for(var i=0;i<r.length;i++){var o=r[i];switch(o.object.termType){case"BlankNode":n=t.rootsHash[o.object.toNT()]?n.concat(["<"+y(o.predicate)+' rdf:nodeID="'+o.object.toNT().slice(2)+'">',"</"+y(o.predicate)+">"]):n.concat(["<"+y(o.predicate)+' rdf:parseType="Resource">',d(o.object,t),"</"+y(o.predicate)+">"]);break;case"NamedNode":n=n.concat(["<"+y(o.predicate)+' rdf:resource="'+f(o.object)+'"/>']);break;case"Literal":n=n.concat(["<"+y(o.predicate)+(o.object.datatype.equals(s.string)?"":' rdf:datatype="'+l(o.object.datatype.value)+'"')+(o.object.language?' xml:lang="'+o.object.language+'"':"")+">"+l(o.object.value)+"</"+y(o.predicate)+">"]);break;case"Collection":n=n.concat(["<"+y(o.predicate)+' rdf:parseType="Collection">',p(o.object,t),"</"+y(o.predicate)+">"]);break;default:throw new Error("Can't serialize object of type "+o.object.termType+" into XML")}}return n}.bind(this);var y=function(t){var r=t.uri,i=r.indexOf("#");if(i<0&&this.flags.indexOf("/")<0&&(i=r.lastIndexOf("/")),i<0)throw new Error("Cannot make qname out of <"+r+">");for(var o=i+1;o<r.length;o++)if(e.prototype._notNameChars.indexOf(r[o])>=0)throw new Error('Invalid character "'+r[o]+'" cannot be in XML qname for URI: '+r);var a=r.slice(i+1),s=r.slice(0,i+1);if(this.defaultNamespace&&this.defaultNamespace===s&&this.flags.indexOf("d")<0)return a;var u=this.prefixes[s];return u||(u=this.makeUpPrefix(s)),n[s]=!0,u+":"+a}.bind(this),v=c(t),g="<rdf:RDF";for(var m in this.defaultNamespace&&(g+=' xmlns="'+l(this.defaultNamespace)+'"'),n)if(n.hasOwnProperty(m)){var w=this.base&&this.flags.includes("z")?a.uri.refTo(this.base,m):m;g+="\n xmlns:"+this.prefixes[m]+'="'+l(w)+'"'}return function e(t,n){var r,i="",a=1e5;n||(n=0);for(var s=0;s<t.length;s++){var c=t[s];if("string"!=typeof c){var l=e(c,n+1);l.length<10*(80-4*n)&&l.indexOf('"""')<0&&(r=u(c)).length<80-4*n&&(c="   "+r,l=""),l&&(a=1e4),i+=l}"string"==typeof c&&(a<4*n+4?(i=i.slice(0,-1)+" "+c+"\n",a+=c.length+1):(i+=(r=o(4*n)+c)+"\n",a=r.length))}return i}([g+=">",v,"</rdf:RDF>"],-1)};return function(t){return new e(t)}}();e.exports=u},function(e,t,n){"use strict";function r(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}var i=n(9),o=n(15),a=n(24),s=n(2),u=n(4),c=n(6);if(void 0===l)var l={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 f=function(){function e(t,n){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.options=n||{},this.kb=t,this.target=n.target||{graph:{subjects:{},prefixes:{},terms:{}}},this.blankNodes=[],this.htmlOptions={selfClosing:"br img input area base basefont col colgroup source wbr isindex link meta param hr"},this.theOne="_:"+(new Date).getTime(),this.language=null,this.vocabulary=null,this.blankCounter=0,this.langAttributes=[{namespaceURI:"http://www.w3.org/XML/1998/namespace",localName:"lang"}],this.inXHTMLMode=!1,this.absURIRE=/[\w\_\-]+:\S+/,this.finishedHandlers=[],this.init()}var t,n,f;return t=e,f=[{key:"parseRDFaDOM",value:function(t,n,r){var i=new e(n,{base:r});t.baseURI||(t.baseURI=r),i.process(t)}},{key:"tokenize",value:function(e){return this.trim(e).split(/\s+/)}},{key:"trim",value:function(e){return e.replace(/^\s\s*/,"").replace(/\s\s*$/,"")}}],(n=[{key:"addTriple",value:function(e,t,n,r){var i,o,s,u;i=void 0===t?a.namedNode(this.options.base):this.toRDFNodeObject(t),s=this.toRDFNodeObject(n),o=this.toRDFNodeObject(r),u=a.namedNode(this.options.base),this.kb.add(i,s,o,u)}},{key:"ancestorPath",value:function(e){for(var t="";e&&e.nodeType!==l.DOCUMENT_NODE;)t="/"+e.localName+t,e=e.parentNode;return t}},{key:"copyMappings",value:function(e){var t={};for(var n in e)t[n]=e[n];return t}},{key:"copyProperties",value:function(){}},{key:"deriveDateTimeType",value:function(t){for(var n=0;n<e.dateTimeTypes.length;n++){var r=e.dateTimeTypes[n].pattern.exec(t);if(r&&r[0].length===t.length)return e.dateTimeTypes[n].type}return null}},{key:"init",value:function(){}},{key:"newBlankNode",value:function(){return this.blankCounter++,"_:"+this.blankCounter}},{key:"newSubjectOrigin",value:function(e,t){}},{key:"parseCURIE",value:function(t,n,r){var i,o=t.indexOf(":");if(o>=0){var a=t.substring(0,o);if(""===a)return(i=n[""])?i+t.substring(o+1):null;if("_"===a)return"_:"+t.substring(o+1);if(e.NCNAME.test(a)&&(i=n[a]))return i+t.substring(o+1)}return null}},{key:"parseCURIEOrURI",value:function(e,t,n){var r=this.parseCURIE(e,t,n);return r||this.resolveAndNormalize(n,e)}},{key:"parsePredicate",value:function(e,t,n,r,i,o){if(""===e)return null;var a=this.parseTermOrCURIEOrAbsURI(e,t,o?null:n,r,i);return a&&0===a.indexOf("_:")?null:a}},{key:"parsePrefixMappings",value:function(e,t){for(var n=this.tokenize(e),r=null,i=0;i<n.length;i++)":"===n[i][n[i].length-1]?r=n[i].substring(0,n[i].length-1):r&&(t[r]=this.options.base?u.join(n[i],this.options.base):n[i],r=null)}},{key:"parseSafeCURIEOrCURIEOrURI",value:function(e,t,n){return"["===(e=this.trim(e)).charAt(0)&&"]"===e.charAt(e.length-1)?0===(e=(e=e.substring(1,e.length-1)).trim(e)).length?null:"_:"===e?this.theOne:this.parseCURIE(e,t,n):this.parseCURIEOrURI(e,t,n)}},{key:"parseTermOrCURIEOrAbsURI",value:function(e,t,n,r,i){e=this.trim(e);var o=this.parseCURIE(e,r,i);if(o)return o;if(n){if(t&&!this.absURIRE.exec(e))return t+e;var a=n[e];if(a)return a;if(a=n[e.toLowerCase()])return a}return this.absURIRE.exec(e)?this.resolveAndNormalize(i,e):null}},{key:"parseTermOrCURIEOrURI",value:function(e,t,n,r,i){e=this.trim(e);var o=this.parseCURIE(e,r,i);if(o)return o;var a=n[e];return a||((a=n[e.toLowerCase()])?a:t&&!this.absURIRE.exec(e)?t+e:this.resolveAndNormalize(i,e))}},{key:"parseURI",value:function(e){return e}},{key:"process",value:function(t,n){var r;t.nodeType===l.DOCUMENT_NODE?(r=t.baseURI,(t=t.documentElement).baseURI||(t.baseURI=r),this.setContext(t)):t.parentNode.nodeType===l.DOCUMENT_NODE&&this.setContext(t);var i=[],o=function(e){if(!e&&n&&n.baseURI)return n.baseURI;var t=e.indexOf("#");return t>=0&&(e=e.substring(0,t)),n&&n.baseURIMap&&(e=n.baseURIMap(e)),e};for(i.push({current:t,context:this.push(null,o(t.baseURI))});i.length>0;){var a=i.shift();if(a.parent){if(a.context.parent&&a.context.parent.listMapping===a.listMapping)continue;for(var s in a.listMapping){var c=a.listMapping[s];if(0!==c.length){for(var f=[],h=0;h<c.length;h++)f.push(this.newBlankNode());for(var p=0;p<f.length;p++)this.addTriple(a.parent,f[p],"http://www.w3.org/1999/02/22-rdf-syntax-ns#first",c[p]),this.addTriple(a.parent,f[p],"http://www.w3.org/1999/02/22-rdf-syntax-ns#rest",{type:e.objectURI,value:p+1<f.length?f[p+1]:"http://www.w3.org/1999/02/22-rdf-syntax-ns#nil"});this.addTriple(a.parent,a.subject,s,{type:e.objectURI,value:f[0]})}else this.addTriple(a.parent,a.subject,s,{type:e.objectURI,value:"http://www.w3.org/1999/02/22-rdf-syntax-ns#nil"})}}else{var d=a.current,y=a.context,v=!1,g=null,m=null,w=null,b=y.prefixes,x=!1,_=[],k=y.listMapping,S=!y.parent,T=y.language,E=y.vocabulary;r=this.parseURI(o(d.baseURI)),d.item=null;var O=d.getAttributeNode("vocab");if(O){var j=this.trim(O.value);if(j.length>0){E=j;var N=r.spec;this.addTriple(d,N,"http://www.w3.org/ns/rdfa#usesVocabulary",{type:e.objectURI,value:E})}else E=this.vocabulary}for(var I=0;I<d.attributes.length;I++){var R=d.attributes[I];if("x"===R.nodeName.charAt(0)&&0===R.nodeName.indexOf("xmlns:")){x||(b=this.copyMappings(b),x=!0);var A=R.nodeName.substring(6),C=e.trim(R.value);b[A]=this.options.base?u.join(C,this.options.base):C}}var P=d.getAttributeNode("prefix");P&&(x||(b=this.copyMappings(b),x=!0),this.parsePrefixMappings(P.value,b));for(var L=null,D=0;!L&&D<this.langAttributes.length;D++)L=d.getAttributeNodeNS(this.langAttributes[D].namespaceURI,this.langAttributes[D].localName);if(L){var U=e.trim(L.value);T=U.length>0?U:null}var M,F,B=d.getAttributeNode("rel"),q=d.getAttributeNode("rev"),z=d.getAttributeNode("typeof"),H=d.getAttributeNode("property"),V=d.getAttributeNode("datatype"),J=this.inHTMLMode?d.getAttributeNode("datetime"):null,W=d.getAttributeNode("content"),X=d.getAttributeNode("about"),Y=d.getAttributeNode("src"),$=d.getAttributeNode("resource"),K=d.getAttributeNode("href"),G=d.getAttributeNode("inlist"),Q=[];if(B){F=this.tokenize(B.value);for(var Z=0;Z<F.length;Z++)(M=this.parsePredicate(F[Z],E,y.terms,b,r,this.inHTMLMode&&null!==H))&&Q.push(M)}var ee=[];if(q){F=this.tokenize(q.value);for(var te=0;te<F.length;te++)(M=this.parsePredicate(F[te],E,y.terms,b,r,this.inHTMLMode&&H))&&ee.push(M)}if(this.inHTMLMode&&(B||q)&&H&&(0===Q.length&&(B=null),0===ee.length&&(q=null)),B||q?(X&&(g=this.parseSafeCURIEOrCURIEOrURI(X.value,b,r)),z&&(w=g),g||(d.parentNode.nodeType===l.DOCUMENT_NODE?g=o(d.baseURI):y.parentObject&&(g=o(d.parentNode.baseURI)===y.parentObject?o(d.baseURI):y.parentObject)),$&&(m=this.parseSafeCURIEOrCURIEOrURI($.value,b,r)),m||(K?m=this.resolveAndNormalize(r,encodeURI(K.value)):Y?m=this.resolveAndNormalize(r,encodeURI(Y.value)):!z||X||this.inXHTMLMode&&("head"===d.localName||"body"===d.localName)||(m=this.newBlankNode())),!z||X||!this.inXHTMLMode||"head"!==d.localName&&"body"!==d.localName?z&&!X&&(w=m):w=g):!H||W||V?(X&&(g=this.parseSafeCURIEOrCURIEOrURI(X.value,b,r)),!g&&$&&(g=this.parseSafeCURIEOrCURIEOrURI($.value,b,r)),!g&&K&&(g=this.resolveAndNormalize(r,encodeURI(K.value))),!g&&Y&&(g=this.resolveAndNormalize(r,encodeURI(Y.value))),g||(d.parentNode.nodeType===l.DOCUMENT_NODE?g=o(d.baseURI):!this.inXHTMLMode&&!this.inHTMLMode||"head"!==d.localName&&"body"!==d.localName?z?g=this.newBlankNode():y.parentObject&&(g=o(d.parentNode.baseURI)===y.parentObject?o(d.baseURI):y.parentObject,H||(v=!0)):g=o(d.parentNode.baseURI)===y.parentObject?o(d.baseURI):y.parentObject),z&&(w=g)):(X&&(g=this.parseSafeCURIEOrCURIEOrURI(X.value,b,r),z&&(w=g)),g||d.parentNode.nodeType!==l.DOCUMENT_NODE?!g&&y.parentObject&&(g=o(d.parentNode.baseURI)===y.parentObject?o(d.baseURI):y.parentObject):(g=o(d.baseURI),z&&(w=g)),z&&!w&&($&&(w=this.parseSafeCURIEOrCURIEOrURI($.value,b,r)),!w&&K&&(w=this.resolveAndNormalize(r,encodeURI(K.value))),!w&&Y&&(w=this.resolveAndNormalize(r,encodeURI(Y.value))),w||!this.inXHTMLMode&&!this.inHTMLMode||"head"!==d.localName&&"body"!==d.localName||(w=g),w||(w=this.newBlankNode()),m=w)),g&&(X||$||w)){var ne=g;z&&!X&&!$&&m&&(ne=m),this.newSubjectOrigin(d,ne)}if(w){F=this.tokenize(z.value);for(var re=0;re<F.length;re++){var ie=this.parseTermOrCURIEOrAbsURI(F[re],E,y.terms,b,r);ie&&this.addTriple(d,w,e.typeURI,{type:e.objectURI,value:ie})}}if(g&&g!==y.parentObject&&(k={},S=!0),m){if(B&&G)for(var oe=0;oe<Q.length;oe++){var ae=k[Q[oe]];ae||(ae=[],k[Q[oe]]=ae),ae.push({type:e.objectURI,value:m})}else if(B)for(var se=0;se<Q.length;se++)this.addTriple(d,g,Q[se],{type:e.objectURI,value:m});if(q)for(var ue=0;ue<ee.length;ue++)this.addTriple(d,m,ee[ue],{type:e.objectURI,value:g})}else{if(g&&!m&&(B||q)&&(m=this.newBlankNode()),B&&G)for(var ce=0;ce<Q.length;ce++){var le=k[Q[ce]];le||(le=[],k[M]=le),_.push({predicate:Q[ce],list:le})}else if(B)for(var fe=0;fe<Q.length;fe++)_.push({predicate:Q[fe],forward:!0});if(q)for(var he=0;he<ee.length;he++)_.push({predicate:ee[he],forward:!1})}if(H){var pe=null,de=null;V?(pe=""===V.value?e.PlainLiteralURI:this.parseTermOrCURIEOrAbsURI(V.value,E,y.terms,b,r),de=J&&!W?J.value:pe===e.XMLLiteralURI||pe===e.HTMLLiteralURI?null:W?W.value:d.textContent):W?(pe=e.PlainLiteralURI,de=W.value):J?(de=J.value,(pe=e.deriveDateTimeType(de))||(pe=e.PlainLiteralURI)):B||q||($&&(de=this.parseSafeCURIEOrCURIEOrURI($.value,b,r)),!de&&K?de=this.resolveAndNormalize(r,encodeURI(K.value)):!de&&Y&&(de=this.resolveAndNormalize(r,encodeURI(Y.value))),de&&(pe=e.objectURI)),pe||(z&&!X?(pe=e.objectURI,de=w):(de=d.textContent,this.inHTMLMode&&"time"===d.localName&&(pe=e.deriveDateTimeType(de)),pe||(pe=e.PlainLiteralURI))),F=this.tokenize(H.value);for(var ye=0;ye<F.length;ye++){var ve=this.parsePredicate(F[ye],E,y.terms,b,r);if(ve)if(G){var ge=k[ve];ge||(ge=[],k[ve]=ge),ge.push(pe===e.XMLLiteralURI||pe===e.HTMLLiteralURI?{type:pe,value:d.childNodes}:{type:pe||e.PlainLiteralURI,value:de,language:T})}else pe===e.XMLLiteralURI||pe===e.HTMLLiteralURI?this.addTriple(d,g,ve,{type:pe,value:d.childNodes}):this.addTriple(d,g,ve,{type:pe||e.PlainLiteralURI,value:de,language:T})}}if(g&&!v)for(var me=0;me<y.incomplete.length;me++)y.incomplete[me].list?y.incomplete[me].list.push({type:e.objectURI,value:g}):y.incomplete[me].forward?this.addTriple(d,y.subject,y.incomplete[me].predicate,{type:e.objectURI,value:g}):this.addTriple(d,g,y.incomplete[me].predicate,{type:e.objectURI,value:y.subject});var we=null,be=g;v?((we=this.push(y,y.subject)).parentObject=o(d.parentNode.baseURI)===y.parentObject?o(d.baseURI):y.parentObject,we.incomplete=y.incomplete,we.language=T,we.prefixes=b,we.vocabulary=E):((we=this.push(y,g)).parentObject=m||g||y.subject,we.prefixes=b,we.incomplete=_,m&&(be=m,k={},S=!0),we.listMapping=k,we.language=T,we.vocabulary=E),S&&i.unshift({parent:d,context:y,subject:be,listMapping:k});for(var xe=d.lastChild;xe;xe=xe.previousSibling)xe.nodeType===l.ELEMENT_NODE&&i.unshift({current:xe,context:we})}}this.inHTMLMode&&this.copyProperties();for(var _e=0;_e<this.finishedHandlers.length;_e++)this.finishedHandlers[_e](t)}},{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}}},{key:"resolveAndNormalize",value:function(e,t){return u.join(t,e)}},{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?"undefined"!=typeof document&&document.doctype?"-//W3C//DTD XHTML+RDFa 1.0//EN"===document.doctype.publicId&&"http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd"===document.doctype.systemId?(console.log("WARNING: RDF 1.0 is not supported.  Defaulting to HTML5 mode."),this.setHTMLContext()):"-//W3C//DTD XHTML+RDFa 1.1//EN"===document.doctype.publicId&&"http://www.w3.org/MarkUp/DTD/xhtml-rdfa-2.dtd"===document.doctype.systemId?this.setXHTMLContext():this.setHTMLContext():this.setHTMLContext():this.setXMLContext()}},{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:"setInitialContext",value:function(){this.vocabulary=null,this.langAttributes=[{namespaceURI:"http://www.w3.org/XML/1998/namespace",localName:"lang"}]}},{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:"setXMLContext",value:function(){this.setInitialContext(),this.inXHTMLMode=!1,this.inHTMLMode=!1}},{key:"tokenize",value:function(e){return this.trim(e).split(/\s+/)}},{key:"toRDFNodeObject",value:function(t){if(void 0!==t){if("string"==typeof t)return"_:"===t.substring(0,2)?(void 0===this.blankNodes[t.substring(2)]&&(this.blankNodes[t.substring(2)]=new i(t.substring(2))),this.blankNodes[t.substring(2)]):a.namedNode(t);switch(t.type){case e.objectURI:return"_:"===t.value.substring(0,2)?(void 0===this.blankNodes[t.value.substring(2)]&&(this.blankNodes[t.value.substring(2)]=new i(t.value.substring(2))),this.blankNodes[t.value.substring(2)]):a.namedNode(t.value);case e.PlainLiteralURI:return new o(t.value,t.language||"");case e.XMLLiteralURI:case e.HTMLLiteralURI:var n="";return Object.keys(t.value).forEach(function(e){n+=c.domToString(t.value[e],this.htmlOptions)}),new o(n,"",new s(t.type));default:return new o(t.value,"",new s(t.type))}}}},{key:"trim",value:function(e){return e.replace(/^\s\s*/,"").replace(/\s\s*$/,"")}}])&&r(t.prototype,n),f&&r(t,f),e}();f.XMLLiteralURI="http://www.w3.org/1999/02/22-rdf-syntax-ns#XMLLiteral",f.HTMLLiteralURI="http://www.w3.org/1999/02/22-rdf-syntax-ns#HTML",f.PlainLiteralURI="http://www.w3.org/1999/02/22-rdf-syntax-ns#PlainLiteral",f.objectURI="http://www.w3.org/1999/02/22-rdf-syntax-ns#object",f.typeURI="http://www.w3.org/1999/02/22-rdf-syntax-ns#type",f.nameChar="[-A-Z_a-zÀ-ÖØ-öø-˿Ͱ-ͽͿ-῿‌-‍⁰-↏Ⰰ-⿯、-퟿豈-﷏ﷰ-�က0-F.0-9·̀-ͯ‿-⁀]",f.nameStartChar="[A-Za-zÀ-ÖØ-öø-ÿĀ-ıĴ-ľŁ-ňŊ-žƀ-ǃǍ-ǰǴ-ǵǺ-ȗɐ-ʨʻ-ˁΆΈ-ΊΌΎ-ΡΣ-ώϐ-ϖϚϜϞϠϢ-ϳЁ-ЌЎ-яё-ќў-ҁҐ-ӄӇ-ӈӋ-ӌӐ-ӫӮ-ӵӸ-ӹԱ-Ֆՙա-ֆא-תװ-ײء-غف-يٱ-ڷں-ھۀ-ێې-ۓەۥ-ۦअ-हऽक़-ॡঅ-ঌএ-ঐও-নপ-রলশ-হড়-ঢ়য়-ৡৰ-ৱਅ-ਊਏ-ਐਓ-ਨਪ-ਰਲ-ਲ਼ਵ-ਸ਼ਸ-ਹਖ਼-ੜਫ਼ੲ-ੴઅ-ઋઍએ-ઑઓ-નપ-રલ-ળવ-હઽૠଅ-ଌଏ-ଐଓ-ନପ-ରଲ-ଳଶ-ହଽଡ଼-ଢ଼ୟ-ୡஅ-ஊஎ-ஐஒ-கங-சஜஞ-டண-தந-பம-வஷ-ஹఅ-ఌఎ-ఐఒ-నప-ళవ-హౠ-ౡಅ-ಌಎ-ಐಒ-ನಪ-ಳವ-ಹೞೠ-ೡഅ-ഌഎ-ഐഒ-നപ-ഹൠ-ൡก-ฮะา-ำเ-ๅກ-ຂຄງ-ຈຊຍດ-ທນ-ຟມ-ຣລວສ-ຫອ-ຮະາ-ຳຽເ-ໄཀ-ཇཉ-ཀྵႠ-Ⴥა-ჶᄀᄂ-ᄃᄅ-ᄇᄉᄋ-ᄌᄎ-ᄒᄼᄾᅀᅌᅎᅐᅔ-ᅕᅙᅟ-ᅡᅣᅥᅧᅩᅭ-ᅮᅲ-ᅳᅵᆞᆨᆫᆮ-ᆯᆷ-ᆸᆺᆼ-ᇂᇫᇰᇹḀ-ẛẠ-ỹἀ-ἕἘ-Ἕἠ-ὅὈ-Ὅὐ-ὗὙὛὝὟ-ώᾀ-ᾴᾶ-ᾼιῂ-ῄῆ-ῌῐ-ΐῖ-Ίῠ-Ῥῲ-ῴῶ-ῼΩK-Å℮ↀ-ↂぁ-ゔァ-ヺㄅ-ㄬ가-힣一-龥〇〡-〩_]",f.NCNAME=new RegExp("^"+f.nameStartChar+f.nameChar+"*$"),f.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"}],e.exports=f},function(e,t,n){"use strict";var r=n(4);e.exports=function(e){var t={ns:{RDF:"http://www.w3.org/1999/02/22-rdf-syntax-ns#",RDFS:"http://www.w3.org/2000/01/rdf-schema#"},nodeType:{ELEMENT:1,ATTRIBUTE:2,TEXT:3,CDATA_SECTION:4,ENTITY_REFERENCE:5,ENTITY:6,PROCESSING_INSTRUCTION:7,COMMENT:8,DOCUMENT:9,DOCUMENT_TYPE:10,DOCUMENT_FRAGMENT:11,NOTATION:12}};this.frameFactory=function(e,n,i){return{NODE:1,ARC:2,parent:n,parser:e,store:e.store,element:i,lastChild:0,base:null,lang:null,node:null,nodeType:null,listIndex:1,rdfid:null,datatype:null,collection:!1,terminateFrame:function(){this.collection&&this.node.close()},addSymbol:function(e,t){t=r.join(t,this.base),this.node=this.store.sym(t),this.nodeType=e},loadTriple:function(){if(this.parent.parent.collection?this.parent.parent.node.append(this.node):this.store.add(this.parent.parent.node,this.parent.node,this.node,this.parser.why),null!=this.parent.rdfid){var e=this.store.sym(r.join("#"+this.parent.rdfid,this.base));this.store.add(e,this.store.sym(t.ns.RDF+"type"),this.store.sym(t.ns.RDF+"Statement"),this.parser.why),this.store.add(e,this.store.sym(t.ns.RDF+"subject"),this.parent.parent.node,this.parser.why),this.store.add(e,this.store.sym(t.ns.RDF+"predicate"),this.parent.node,this.parser.why),this.store.add(e,this.store.sym(t.ns.RDF+"object"),this.node,this.parser.why)}},isTripleToLoad:function(){return null!=this.parent&&null!=this.parent.parent&&this.nodeType===this.NODE&&this.parent.nodeType===this.ARC&&this.parent.parent.nodeType===this.NODE},addNode:function(e){this.addSymbol(this.NODE,e),this.isTripleToLoad()&&this.loadTriple()},addCollection:function(){this.nodeType=this.NODE,this.node=this.store.collection(),this.collection=!0,this.isTripleToLoad()&&this.loadTriple()},addCollectionArc:function(){this.nodeType=this.ARC},addBNode:function(e){null!=e?null!=this.parser.bnodes[e]?this.node=this.parser.bnodes[e]:this.node=this.parser.bnodes[e]=this.store.bnode():this.node=this.store.bnode(),this.nodeType=this.NODE,this.isTripleToLoad()&&this.loadTriple()},addArc:function(e){e===t.ns.RDF+"li"&&(e=t.ns.RDF+"_"+this.parent.listIndex,this.parent.listIndex++),this.addSymbol(this.ARC,e)},addLiteral:function(e){this.parent.datatype?this.node=this.store.literal(e,"",this.store.sym(this.parent.datatype)):this.node=this.store.literal(e,this.lang),this.nodeType=this.NODE,this.isTripleToLoad()&&this.loadTriple()}}},this.getAttributeNodeNS=function(e,t,n){var r=null;if(e.getAttributeNodeNS)r=e.getAttributeNodeNS(t,n);else for(var i,o=e.attributes,a=0;a<o.length;++a)if((i=o[a]).namespaceURI===t&&(i.prefix?i.prefix+":"+n:n)===i.nodeName){r=i;break}return r},this.store=e,this.bnodes={},this.why=null,this.reify=!1,this.parse=function(e,n,r){var i,o=e.childNodes;if(this.cleanParser(),e.nodeType===t.nodeType.DOCUMENT){for(var a=0;a<o.length;a++)if(o[a].nodeType===t.nodeType.ELEMENT){i=o[a];break}}else{if(e.nodeType!==t.nodeType.ELEMENT)throw new Error("RDFParser: can't find root in "+n+". Halting. ");i=e}this.why=r;var s=this.frameFactory(this);return this.base=n,s.base=n,s.lang=null,this.parseDOM(this.buildFrame(s,i)),!0},this.parseDOM=function(e){for(var n,i=function(e){var t="";if(null==e.namespaceURI)throw new Error("RDF/XML syntax error: No namespace for "+e.localName+" in "+this.base);return e.namespaceURI&&(t+=e.namespaceURI),e.localName?t+=e.localName:e.nodeName&&(e.nodeName.indexOf(":")>=0?t+=e.nodeName.split(":")[1]:t+=e.nodeName),t}.bind(this),o=!0;e.parent;){var a=e.element,s=a.attributes;if(a.nodeType===t.nodeType.TEXT||a.nodeType===t.nodeType.CDATA_SECTION)e.parent.nodeType===e.NODE&&(e.addArc(t.ns.RDF+"value"),e=this.buildFrame(e)),e.addLiteral(a.nodeValue);else if(i(a)!==t.ns.RDF+"RDF")if(e.parent&&e.parent.collection&&(e.addCollectionArc(),(e=this.buildFrame(e,e.element)).parent.element=null),e.parent&&e.parent.nodeType&&e.parent.nodeType!==e.ARC){e.addArc(i(a)),this.reify&&(n=this.getAttributeNodeNS(a,t.ns.RDF,"ID"))&&(e.rdfid=n.nodeValue,a.removeAttributeNode(n));var u=this.getAttributeNodeNS(a,t.ns.RDF,"parseType"),c=this.getAttributeNodeNS(a,t.ns.RDF,"datatype");if(c&&(e.datatype=c.nodeValue,a.removeAttributeNode(c)),u){var l=u.nodeValue;"Literal"===l?(e.datatype=t.ns.RDF+"XMLLiteral",(e=this.buildFrame(e)).addLiteral(a.childNodes),o=!1):"Resource"===l?((e=this.buildFrame(e,e.element)).parent.element=null,e.addBNode()):"Collection"===l&&((e=this.buildFrame(e,e.element)).parent.element=null,e.addCollection()),a.removeAttributeNode(u)}if(0!==s.length){var f=this.getAttributeNodeNS(a,t.ns.RDF,"resource"),h=this.getAttributeNodeNS(a,t.ns.RDF,"nodeID");e=this.buildFrame(e),f?(e.addNode(f.nodeValue),a.removeAttributeNode(f)):h?(e.addBNode(h.nodeValue),a.removeAttributeNode(h)):e.addBNode();for(var p=s.length-1;p>=0;p--){var d=this.buildFrame(e);d.addArc(i(s[p])),i(s[p])===t.ns.RDF+"type"?this.buildFrame(d).addNode(s[p].nodeValue):this.buildFrame(d).addLiteral(s[p].nodeValue)}}else 0===a.childNodes.length&&this.buildFrame(e).addLiteral("")}else{var y=this.getAttributeNodeNS(a,t.ns.RDF,"about");if(n=this.getAttributeNodeNS(a,t.ns.RDF,"ID"),y&&n)throw new Error("RDFParser: "+a.nodeName+" has both rdf:id and rdf:about. Halting. Only one of these properties may be specified on a node.");if(!y&&n)e.addNode("#"+n.nodeValue),a.removeAttributeNode(n);else if(null==y&&null==n){var v=this.getAttributeNodeNS(a,t.ns.RDF,"nodeID");v?(e.addBNode(v.nodeValue),a.removeAttributeNode(v)):e.addBNode()}else e.addNode(y.nodeValue),a.removeAttributeNode(y);var g=this.getAttributeNodeNS(a,t.ns.RDF,"type");t.ns.RDF+"Description"!==i(a)&&(g={nodeValue:i(a)}),null!=g&&(this.store.add(e.node,this.store.sym(t.ns.RDF+"type"),this.store.sym(r.join(g.nodeValue,e.base)),this.why),g.nodeName&&a.removeAttributeNode(g));for(var m=s.length-1;m>=0;m--)this.store.add(e.node,this.store.sym(i(s[m])),this.store.literal(s[m].nodeValue,e.lang),this.why)}for(a=e.element;e.parent;){for(var w=e;null==a;)a=(e=e.parent).element;var b=a.childNodes&&a.childNodes[e.lastChild];if(b&&o){if((b.nodeType===t.nodeType.ELEMENT||b.nodeType===t.nodeType.TEXT||b.nodeType===t.nodeType.CDATA_SECTION)&&(b.nodeType!==t.nodeType.TEXT&&b.nodeType!==t.nodeType.CDATA_SECTION||1===a.childNodes.length)){e.lastChild++,e=this.buildFrame(w,a.childNodes[e.lastChild-1]);break}e.lastChild++}else{if(e.terminateFrame(),!(e=e.parent))break;a=e.element,o=!0}}}},this.cleanParser=function(){this.bnodes={},this.why=null},this.buildFrame=function(e,n){var i=this.frameFactory(this,e,n);if(e&&(i.base=e.base,i.lang=e.lang),!n||n.nodeType===t.nodeType.TEXT||n.nodeType===t.nodeType.CDATA_SECTION)return i;var o=n.attributes,a=n.getAttributeNode("xml:base");null!=a&&(i.base=a.nodeValue,n.removeAttribute("xml:base"));var s=n.getAttributeNode("xml:lang");null!=s&&(i.lang=s.nodeValue,n.removeAttribute("xml:lang"));for(var u=o.length-1;u>=0;u--)if("xml"===o[u].nodeName.substr(0,3)){if("xmlns:"===o[u].name.slice(0,6)){var c=o[u].nodeValue;this.base&&(c=r.join(c,this.base)),this.store.setPrefixForURI(o[u].name.slice(6),c)}n.removeAttributeNode(o[u])}return i}}},function(e,t,n){"use strict";var r=n(2),i=function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e)};i.boolean=new r("http://www.w3.org/2001/XMLSchema#boolean"),i.dateTime=new r("http://www.w3.org/2001/XMLSchema#dateTime"),i.decimal=new r("http://www.w3.org/2001/XMLSchema#decimal"),i.double=new r("http://www.w3.org/2001/XMLSchema#double"),i.integer=new r("http://www.w3.org/2001/XMLSchema#integer"),i.langString=new r("http://www.w3.org/1999/02/22-rdf-syntax-ns#langString"),i.string=new r("http://www.w3.org/2001/XMLSchema#string"),e.exports=i},function(e,t,n){"use strict";e.exports.convertToJson=function(e,t){var n,a=o.Parser(),s=o.Writer({format:"N-Quads"});r.waterfall([function(t){a.parse(e,t)},function(e,t,n){null!==e&&s.addTriple(e),"function"==typeof n&&s.end(n)},function(e,t){try{i.fromRDF(e,{format:"application/nquads"},t)}catch(e){t(e)}},function(e,r){n=JSON.stringify(e),t(null,n)}],function(e,r){t(e,n)})},e.exports.convertToNQuads=function(e,t){var n,i=o.Parser(),a=o.Writer({format:"N-Quads"});r.waterfall([function(t){i.parse(e,t)},function(e,t,n){null!==e&&a.addTriple(e),"function"==typeof n&&a.end(n)},function(e,r){t(null,n=e)}],function(e,r){t(e,n)})};var r=n(65),i=n(43),o=n(45)},function(e,t,n){(function(r,i,o,a){var s;
  /**
   * A JavaScript implementation of the JSON-LD API.
   *
   * @author Dave Longley
   *
   * @license BSD 3-Clause License
   * Copyright (c) 2011-2015 Digital Bazaar, Inc.
   * All rights reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions are met:
   *
   * Redistributions of source code must retain the above copyright notice,
   * this list of conditions and the following disclaimer.
   *
   * Redistributions in binary form must reproduce the above copyright
   * notice, this list of conditions and the following disclaimer in the
   * documentation and/or other materials provided with the distribution.
   *
   * Neither the name of the Digital Bazaar, Inc. nor the names of its
   * contributors may be used to endorse or promote products derived from
   * this software without specific prior written permission.
   *
   * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
   * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
   * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
   * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
   * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
   * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
   * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
   * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
   * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
   * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
   */
  /**
   * A JavaScript implementation of the JSON-LD API.
   *
   * @author Dave Longley
   *
   * @license BSD 3-Clause License
   * Copyright (c) 2011-2015 Digital Bazaar, Inc.
   * All rights reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions are met:
   *
   * Redistributions of source code must retain the above copyright notice,
   * this list of conditions and the following disclaimer.
   *
   * Redistributions in binary form must reproduce the above copyright
   * notice, this list of conditions and the following disclaimer in the
   * documentation and/or other materials provided with the distribution.
   *
   * Neither the name of the Digital Bazaar, Inc. nor the names of its
   * contributors may be used to endorse or promote products derived from
   * this software without specific prior written permission.
   *
   * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
   * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
   * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
   * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
   * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
   * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
   * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
   * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
   * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
   * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
   */
  !function(){var u=void 0!==r&&r.versions&&r.versions.node,c=!u&&("undefined"!=typeof window||"undefined"!=typeof self);c&&void 0===i&&("undefined"!=typeof window?i=window:"undefined"!=typeof self?i=self:"undefined"!=typeof $&&(i=$));var l=function(e){function t(){}e.compact=function(t,n,r,i){if(arguments.length<2)return e.nextTick(function(){i(new TypeError("Could not compact, too few arguments."))});if("function"==typeof r&&(i=r,r={}),r=r||{},null===n)return e.nextTick(function(){i(new I("The compaction context must not be null.","jsonld.CompactError",{code:"invalid local context"}))});if(null===t)return e.nextTick(function(){i(null,null)});"base"in r||(r.base="string"==typeof t?t:""),"compactArrays"in r||(r.compactArrays=!0),"graph"in r||(r.graph=!1),"skipExpansion"in r||(r.skipExpansion=!1),"documentLoader"in r||(r.documentLoader=e.loadDocument),"link"in r||(r.link=!1),r.link&&(r.skipExpansion=!0);!function(t,n,r){if(n.skipExpansion)return e.nextTick(function(){r(null,t)});e.expand(t,n,r)}(t,r,function(t,o){if(t)return i(new I("Could not expand input before compaction.","jsonld.CompactError",{cause:t}));var a=ee(r);e.processContext(a,n,r,function(e,t){if(e)return i(new I("Could not process context before compaction.","jsonld.CompactError",{cause:e}));var a;try{a=(new R).compact(t,null,o,r)}catch(e){return i(e)}!function(e,t,r,o){if(e)return i(e);o.compactArrays&&!o.graph&&re(t)?1===t.length?t=t[0]:0===t.length&&(t={}):o.graph&&ne(t)&&(t=[t]);ne(n)&&"@context"in n&&(n=n["@context"]);re(n=ye(n))||(n=[n]);var a=n;n=[];for(var s=0;s<a.length;++s)(!ne(a[s])||Object.keys(a[s]).length>0)&&n.push(a[s]);var u=n.length>0;1===n.length&&(n=n[0]);if(re(t)){var c=G(r,"@graph"),l=t;t={},u&&(t["@context"]=n),t[c]=l}else if(ne(t)&&u){var l=t;for(var f in t={"@context":n},l)t[f]=l[f]}i(null,t,r)}(null,a,t,r)})})},e.expand=function(t,n,r){if(arguments.length<1)return e.nextTick(function(){r(new TypeError("Could not expand, too few arguments."))});function i(e){"base"in n||(n.base=e.documentUrl||"");var t={document:ye(e.document),remoteContext:{"@context":e.contextUrl}};if("expandContext"in n){var i=ye(n.expandContext);t.expandContext="object"==typeof i&&"@context"in i?i:{"@context":i}}ge(t,n,function(e,t){if(e)return r(e);var i;try{var o=new R,a=ee(n),s=t.document,u=t.remoteContext["@context"];t.expandContext&&(a=o.processContext(a,t.expandContext["@context"],n)),u&&(a=o.processContext(a,u,n)),ne(i=o.expand(a,null,s,n,!1))&&"@graph"in i&&1===Object.keys(i).length?i=i["@graph"]:null===i&&(i=[]),re(i)||(i=[i])}catch(e){return r(e)}r(null,i)})}"function"==typeof n&&(r=n,n={}),"documentLoader"in(n=n||{})||(n.documentLoader=e.loadDocument),"keepFreeFloatingNodes"in n||(n.keepFreeFloatingNodes=!1),e.nextTick(function(){if("string"!=typeof t)i({contextUrl:null,documentUrl:null,document:t});else{var e=function(e,t){if(e)return r(e);try{if(!t.document)throw new I("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 I("Could not retrieve a JSON-LD document from the URL. URL dereferencing not implemented.","jsonld.LoadDocumentError",{code:"loading document failed",cause:e,remoteDoc:t}))}i(t)},o=n.documentLoader(t,e);o&&"then"in o&&o.then(e.bind(null,null),e)}})},e.flatten=function(t,n,r,i){if(arguments.length<1)return e.nextTick(function(){i(new TypeError("Could not flatten, too few arguments."))});"function"==typeof r?(i=r,r={}):"function"==typeof n&&(i=n,n=null,r={}),"base"in(r=r||{})||(r.base="string"==typeof t?t:""),"documentLoader"in r||(r.documentLoader=e.loadDocument),e.expand(t,r,function(t,o){if(t)return i(new I("Could not expand input before flattening.","jsonld.FlattenError",{cause:t}));var a;try{a=(new R).flatten(o)}catch(e){return i(e)}if(null===n)return i(null,a);r.graph=!0,r.skipExpansion=!0,e.compact(a,n,r,function(e,t){if(e)return i(new I("Could not compact flattened output.","jsonld.FlattenError",{cause:e}));i(null,t)})})},e.frame=function(t,n,r,i){if(arguments.length<2)return e.nextTick(function(){i(new TypeError("Could not frame, too few arguments."))});function o(n){var o,a=n.document;a?(o=a["@context"],n.contextUrl?(o?re(o)?o.push(n.contextUrl):o=[o,n.contextUrl]:o=n.contextUrl,a["@context"]=o):o=o||{}):o={},e.expand(t,r,function(t,n){if(t)return i(new I("Could not expand input before framing.","jsonld.FrameError",{cause:t}));var s=ye(r);s.isFrame=!0,s.keepFreeFloatingNodes=!0,e.expand(a,s,function(t,r){if(t)return i(new I("Could not expand frame before framing.","jsonld.FrameError",{cause:t}));var a;try{a=(new R).frame(n,r,s)}catch(e){return i(e)}s.graph=!0,s.skipExpansion=!0,s.link={},e.compact(a,o,s,function(t,n,r){if(t)return i(new I("Could not compact framed output.","jsonld.FrameError",{cause:t}));var o=G(r,"@graph");
  // remove @preserve from results
  s.link={},n[o]=
  /**
   * Removes the @preserve keywords as the last step of the framing algorithm.
   *
   * @param ctx the active context used to compact the input.
   * @param input the framed, compacted output.
   * @param options the compaction options used.
   *
   * @return the resulting output.
   */
  function t(n,r,i){if(re(r)){for(var o=[],a=0;a<r.length;++a){var s=t(n,r[a],i);null!==s&&o.push(s)}r=o}else if(ne(r)){
  // remove @preserve
  if("@preserve"in r)return"@null"===r["@preserve"]?null:r["@preserve"];if(fe(r))return r;if(he(r))return r["@list"]=t(n,r["@list"],i),r;var u=G(n,"@id");if(u in r){var c=r[u];if(c in i.link){var l=i.link[c].indexOf(r);if(-1!==l)return i.link[c][l];i.link[c].push(r)}else i.link[c]=[r]}for(var f in r){var s=t(n,r[f],i),h=e.getContextValue(n,f,"@container");i.compactArrays&&re(s)&&1===s.length&&null===h&&(s=s[0]),r[f]=s}}return r}(r,n[o],s),i(null,n)})})})}"function"==typeof r&&(i=r,r={}),"base"in(r=r||{})||(r.base="string"==typeof t?t:""),"documentLoader"in r||(r.documentLoader=e.loadDocument),"embed"in r||(r.embed="@last"),r.explicit=r.explicit||!1,"requireAll"in r||(r.requireAll=!0),r.omitDefault=r.omitDefault||!1,e.nextTick(function(){if("string"!=typeof n)o({contextUrl:null,documentUrl:null,document:n});else{var e=function(e,t){if(e)return i(e);try{if(!t.document)throw new I("No remote document found at the given URL.","jsonld.NullRemoteDocument");"string"==typeof t.document&&(t.document=JSON.parse(t.document))}catch(e){return i(new I("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)},t=r.documentLoader(n,e);t&&"then"in t&&t.then(e.bind(null,null),e)}})},e.link=function(t,n,r,i){var o={};n&&(o["@context"]=n),o["@embed"]="@link",e.frame(t,o,r,i)},e.objectify=function(t,n,r,i){"function"==typeof r&&(i=r,r={}),"base"in(r=r||{})||(r.base="string"==typeof t?t:""),"documentLoader"in r||(r.documentLoader=e.loadDocument),e.expand(t,r,function(t,o){if(t)return i(new I("Could not expand input before linking.","jsonld.LinkError",{cause:t}));var a;try{a=(new R).flatten(o)}catch(e){return i(e)}r.graph=!0,r.skipExpansion=!0,e.compact(a,n,r,function(t,n,r){if(t)return i(new I("Could not compact flattened output before linking.","jsonld.LinkError",{cause:t}));var o=n[G(r,"@graph")][0],a=function(t){if(ne(t)||re(t)){if(ne(t)){if(a.visited[t["@id"]])return;a.visited[t["@id"]]=!0}for(var n in t){var i=t[n],s="@id"===e.getContextValue(r,n,"@type");if(re(i)||ne(i)||s)if(oe(i)&&s)t[n]=i=o[i],a(i);else if(re(i))for(var u=0;u<i.length;++u)oe(i[u])&&s?i[u]=o[i[u]]:ne(i[u])&&"@id"in i[u]&&(i[u]=o[i[u]["@id"]]),a(i[u]);else if(ne(i)){var c=i["@id"];t[n]=i=o[c],a(i)}}}};for(var s in a.visited={},a(o),n.of_type={},o)if("@type"in o[s]){var u=o[s]["@type"];re(u)||(u=[u]);for(var c=0;c<u.length;++c)u[c]in n.of_type||(n.of_type[u[c]]=[]),n.of_type[u[c]].push(o[s])}i(null,n)})})},e.normalize=function(t,n,r){if(arguments.length<1)return e.nextTick(function(){r(new TypeError("Could not normalize, too few arguments."))});if("function"==typeof n&&(r=n,n={}),"algorithm"in(n=n||{})||(n.algorithm="URGNA2012"),"base"in n||(n.base="string"==typeof t?t:""),"documentLoader"in n||(n.documentLoader=e.loadDocument),"inputFormat"in n){if("application/nquads"!==n.inputFormat)return r(new I("Unknown normalization input format.","jsonld.NormalizeError"));var i=me(t);(new R).normalize(i,n,r)}else{var o=ye(n);delete o.format,o.produceGeneralizedRdf=!1,e.toRDF(t,o,function(e,t){if(e)return r(new I("Could not convert input to RDF dataset before normalization.","jsonld.NormalizeError",{cause:e}));(new R).normalize(t,n,r)})}},e.fromRDF=function(t,n,r){if(arguments.length<1)return e.nextTick(function(){r(new TypeError("Could not convert from RDF, too few arguments."))});"function"==typeof n&&(r=n,n={}),"useRdfType"in(n=n||{})||(n.useRdfType=!1),"useNativeTypes"in n||(n.useNativeTypes=!1),"format"in n||!oe(t)||"format"in n||(n.format="application/nquads"),e.nextTick(function(){var e;if(n.format){if(!(e=n.rdfParser||h[n.format]))return r(new I("Unknown input format.","jsonld.UnknownFormat",{format:n.format}))}else e=function(){return t};var i=!1;try{t=e(t,function(e,t){if(i=!0,e)return r(e);o(t,n,r)})}catch(e){if(!i)return r(e);throw e}if(t){if("then"in t)return t.then(function(e){o(e,n,r)},r);o(t,n,r)}function o(e,t,n){(new R).fromRDF(e,t,n)}})},e.toRDF=function(t,n,r){if(arguments.length<1)return e.nextTick(function(){r(new TypeError("Could not convert to RDF, too few arguments."))});"function"==typeof n&&(r=n,n={}),"base"in(n=n||{})||(n.base="string"==typeof t?t:""),"documentLoader"in n||(n.documentLoader=e.loadDocument),e.expand(t,n,function(e,t){if(e)return r(new I("Could not expand input before serialization to RDF.","jsonld.RdfError",{cause:e}));var i;try{if(i=R.prototype.toRDF(t,n),n.format){if("application/nquads"===n.format)return r(null,function(e){var t=[];for(var n in e)for(var r=e[n],i=0;i<r.length;++i){var o=r[i];"@default"===n&&(n=null),t.push(we(o,n))}return t.sort().join("")}(i));throw new I("Unknown output format.","jsonld.UnknownFormat",{format:n.format})}}catch(e){return r(e)}r(null,i)})},e.createNodeMap=function(t,n,r){if(arguments.length<1)return e.nextTick(function(){r(new TypeError("Could not create node map, too few arguments."))});"function"==typeof n&&(r=n,n={}),"base"in(n=n||{})||(n.base="string"==typeof t?t:""),"documentLoader"in n||(n.documentLoader=e.loadDocument),e.expand(t,n,function(e,t){if(e)return r(new I("Could not expand input before creating node map.","jsonld.CreateNodeMapError",{cause:e}));var i;try{i=(new R).createNodeMap(t,n)}catch(e){return r(e)}r(null,i)})},e.merge=function(t,n,r,i){if(arguments.length<1)return e.nextTick(function(){i(new TypeError("Could not merge, too few arguments."))});if(!re(t))return e.nextTick(function(){i(new TypeError('Could not merge, "docs" must be an array.'))});"function"==typeof r?(i=r,r={}):"function"==typeof n&&(i=n,n=null,r={}),r=r||{};for(var o=[],a=null,s=t.length,u=0;u<t.length;++u){var c={};for(var l in r)c[l]=r[l];e.expand(t[u],c,f)}function f(t,u){if(!a){if(t)return a=t,i(new I("Could not expand input before flattening.","jsonld.FlattenError",{cause:t}));o.push(u),0==--s&&function(t){var o=!0;"mergeNodes"in r&&(o=r.mergeNodes);var a,s=r.namer||r.issuer||new be("_:b"),u={"@default":{}};try{for(var c=0;c<t.length;++c){var l=t[c];l=e.relabelBlankNodes(l,{issuer:new be("_:b"+c+"-")});var f=o||0===c?u:{"@default":{}};if(z(l,f,"@default",s),f!==u)for(var h in f){var p=f[h];if(h in u){var d=u[h];for(var y in p)y in d||(d[y]=p[y])}else u[h]=p}}a=H(u)}catch(e){return i(e)}for(var v=[],g=Object.keys(a).sort(),m=0;m<g.length;++m){var w=a[g[m]];le(w)||v.push(w)}if(null===n)return i(null,v);r.graph=!0,r.skipExpansion=!0,e.compact(v,n,r,function(e,t){if(e)return i(new I("Could not compact merged output.","jsonld.MergeError",{cause:e}));i(null,t)})}(o)}}},e.relabelBlankNodes=function(e,t){return function e(t,n){if(re(n))for(var r=0;r<n.length;++r)n[r]=e(t,n[r]);else if(he(n))n["@list"]=e(t,n["@list"]);else if(ne(n)){pe(n)&&(n["@id"]=t.getId(n["@id"]));for(var i=Object.keys(n).sort(),o=0;o<i.length;++o){var a=i[o];"@id"!==a&&(n[a]=e(t,n[a]))}}return n}((t=t||{}).namer||t.issuer||new be("_:b"),e)},e.prependBase=function(t,n){return function(t,n){if(null===t)return n;if(-1!==n.indexOf(":"))return n;oe(t)&&(t=e.url.parse(t||""));var r=e.url.parse(n),i={protocol:t.protocol||""};if(null!==r.authority)i.authority=r.authority,i.path=r.path,i.query=r.query;else if(i.authority=t.authority,""===r.path)i.path=t.path,null!==r.query?i.query=r.query:i.query=t.query;else{if(0===r.path.indexOf("/"))i.path=r.path;else{var o=t.path;""!==r.path&&((o=o.substr(0,o.lastIndexOf("/")+1)).length>0&&"/"!==o.substr(-1)&&(o+="/"),o+=r.path),i.path=o}i.query=r.query}i.path=Se(i.path,!!i.authority);var a=i.protocol;null!==i.authority&&(a+="//"+i.authority);a+=i.path,null!==i.query&&(a+="?"+i.query);null!==r.fragment&&(a+="#"+r.fragment);""===a&&(a="./");return a}(t,n)},e.documentLoader=function(t,n){var r=new I("Could not retrieve a JSON-LD document from the URL. URL dereferencing not implemented.","jsonld.LoadDocumentError",{code:"loading document failed"});return u?n(r,{contextUrl:null,documentUrl:t,document:null}):e.promisify(function(e){e(r)})},e.loadDocument=function(t,n){var r=e.documentLoader(t,n);r&&"then"in r&&r.then(n.bind(null,null),n)},e.promises=function(t){t=t||{};var r=Array.prototype.slice,o=e.promisify,a=t.api||{},s=t.version||"jsonld.js";"string"==typeof t.api&&(t.version||(s=t.api),a={}),a.expand=function(t){if(arguments.length<1)throw new TypeError("Could not expand, too few arguments.");return o.apply(null,[e.expand].concat(r.call(arguments)))},a.compact=function(t,n){if(arguments.length<2)throw new TypeError("Could not compact, too few arguments.");return o.apply(null,[function(t,n,r,i){"function"==typeof r&&(i=r,r={}),r=r||{},e.compact(t,n,r,function(e,t){i(e,t)})}].concat(r.call(arguments)))},a.flatten=function(t){if(arguments.length<1)throw new TypeError("Could not flatten, too few arguments.");return o.apply(null,[e.flatten].concat(r.call(arguments)))},a.frame=function(t,n){if(arguments.length<2)throw new TypeError("Could not frame, too few arguments.");return o.apply(null,[e.frame].concat(r.call(arguments)))},a.fromRDF=function(t){if(arguments.length<1)throw new TypeError("Could not convert from RDF, too few arguments.");return o.apply(null,[e.fromRDF].concat(r.call(arguments)))},a.toRDF=function(t){if(arguments.length<1)throw new TypeError("Could not convert to RDF, too few arguments.");return o.apply(null,[e.toRDF].concat(r.call(arguments)))},a.normalize=function(t){if(arguments.length<1)throw new TypeError("Could not normalize, too few arguments.");return o.apply(null,[e.normalize].concat(r.call(arguments)))},"jsonld.js"===s&&(a.link=function(t,n){if(arguments.length<2)throw new TypeError("Could not link, too few arguments.");return o.apply(null,[e.link].concat(r.call(arguments)))},a.objectify=function(t){return o.apply(null,[e.objectify].concat(r.call(arguments)))},a.createNodeMap=function(t){return o.apply(null,[e.createNodeMap].concat(r.call(arguments)))},a.merge=function(t){return o.apply(null,[e.merge].concat(r.call(arguments)))});try{e.Promise=i.Promise||n(44).Promise}catch(e){var u=function(){throw new Error("Unable to find a Promise implementation.")};for(var c in a)a[c]=u}return a},e.promisify=function(t){if(!e.Promise)try{e.Promise=i.Promise||n(44).Promise}catch(e){throw new Error("Unable to find a Promise implementation.")}var r=Array.prototype.slice.call(arguments,1);return new e.Promise(function(e,n){t.apply(null,r.concat(function(t,r){t?n(t):e(r)}))})},e.promises({api:e.promises}),t.prototype=e.promises({version:"json-ld-1.0"}),t.prototype.toString=function(){return this instanceof t?"[object JsonLdProcessor]":"[object JsonLdProcessorPrototype]"},e.JsonLdProcessor=t;var s=!!Object.defineProperty;if(s)try{Object.defineProperty({},"x",{})}catch(e){s=!1}s&&(Object.defineProperty(t,"prototype",{writable:!1,enumerable:!1}),Object.defineProperty(t.prototype,"constructor",{writable:!0,enumerable:!1,configurable:!0,value:t})),c&&void 0===i.JsonLdProcessor&&(s?Object.defineProperty(i,"JsonLdProcessor",{writable:!0,enumerable:!1,configurable:!0,value:t}):i.JsonLdProcessor=t);var l="function"==typeof o&&o,f=l?function(e){l(e)}:function(e){setTimeout(e,0)};"object"==typeof r&&"function"==typeof r.nextTick?e.nextTick=r.nextTick:e.nextTick=f,e.setImmediate=l?f:e.nextTick,e.parseLinkHeader=function(e){for(var t={},n=e.match(/(?:<[^>]*?>|"[^"]*?"|[^,])+/g),r=/\s*<([^>]*?)>\s*(?:;\s*(.*))?/,i=0;i<n.length;++i){var o=n[i].match(r);if(o){for(var a={target:o[1]},s=o[2],u=/(.*?)=(?:(?:"([^"]*?)")|([^"]*?))\s*(?:(?:;\s*)|$)/g;o=u.exec(s);)a[o[1]]=void 0===o[2]?o[3]:o[2];var c=a.rel||"";re(t[c])?t[c].push(a):t[c]=c in t?[t[c],a]:a}}return t},e.RequestQueue=function(){this._requests={}},e.RequestQueue.prototype.wrapLoader=function(e){return this._loader=e,this._usePromise=1===e.length,this.add.bind(this)},e.RequestQueue.prototype.add=function(t,n){var r=this;if(!n&&!r._usePromise)throw new Error("callback must be specified.");if(r._usePromise)return new e.Promise(function(e,n){var i=r._requests[t];i||(i=r._requests[t]=r._loader(t).then(function(e){return delete r._requests[t],e}).catch(function(e){throw delete r._requests[t],e})),i.then(function(t){e(t)}).catch(function(e){n(e)})});t in r._requests?r._requests[t].push(n):(r._requests[t]=[n],r._loader(t,function(e,n){var i=r._requests[t];delete r._requests[t];for(var o=0;o<i.length;++o)i[o](e,n)}))},e.DocumentCache=function(e){this.order=[],this.cache={},this.size=e||50,this.expires=3e4},e.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},e.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}},e.ActiveContextCache=function(e){this.order=[],this.cache={},this.size=e||100},e.ActiveContextCache.prototype.get=function(e,t){var n=JSON.stringify(e),r=JSON.stringify(t),i=this.cache[n];return i&&r in i?i[r]:null},e.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 i=JSON.stringify(e),o=JSON.stringify(t);this.order.push({activeCtx:i,localCtx:o}),i in this.cache||(this.cache[i]={}),this.cache[i][o]=ye(n)},e.cache={activeCtx:new e.ActiveContextCache},e.documentLoaders={},e.documentLoaders.jquery=function(t,n){n=n||{};var r=new e.RequestQueue;return("usePromise"in n?n.usePromise:"undefined"!=typeof Promise)?r.wrapLoader(function(t){return e.promisify(i,t)}):r.wrapLoader(i);function i(r,i){return 0!==r.indexOf("http:")&&0!==r.indexOf("https:")?i(new I('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}):n.secure&&0!==r.indexOf("https")?i(new I('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 t.ajax({url:r,accepts:{json:"application/ld+json, application/json"},headers:{Accept:"application/ld+json, application/json"},dataType:"json",crossDomain:!0,success:function(t,n,o){var a={contextUrl:null,documentUrl:r,document:t},s=o.getResponseHeader("Content-Type"),u=o.getResponseHeader("Link");if(u&&"application/ld+json"!==s){if(re(u=e.parseLinkHeader(u)[j]))return i(new I("URL could not be dereferenced, it has more than one associated HTTP Link Header.","jsonld.InvalidUrl",{code:"multiple context link headers",url:r}),a);u&&(a.contextUrl=u.target)}i(null,a)},error:function(e,t,n){i(new I("URL could not be dereferenced, an error occurred.","jsonld.LoadDocumentError",{code:"loading document failed",url:r,cause:n}),{contextUrl:null,documentUrl:r,document:null})}})}},e.documentLoaders.node=function(t){var r=!("strictSSL"in(t=t||{}))||t.strictSSL,i="maxRedirects"in t?t.maxRedirects:-1,o="request"in t?t.request:n(10),a="application/ld+json, application/json",s=n(10),u=new e.RequestQueue;if(t.usePromise)return u.wrapLoader(function(t){return e.promisify(l,t,[])});var c=t.headers||{};if("Accept"in c||"accept"in c)throw new RangeError('Accept header may not be specified as an option; only "'+a+'" is supported.');return u.wrapLoader(function(e,t){l(e,[],t)});function l(n,u,c){if(0!==n.indexOf("http:")&&0!==n.indexOf("https:"))return c(new I('URL could not be dereferenced; only "http" and "https" URLs are supported.',"jsonld.InvalidUrl",{code:"loading document failed",url:n}),{contextUrl:null,documentUrl:n,document:null});if(t.secure&&0!==n.indexOf("https"))return c(new I('URL could not be dereferenced; secure mode is enabled and the URL\'s scheme is not "https".',"jsonld.InvalidUrl",{code:"loading document failed",url:n}),{contextUrl:null,documentUrl:n,document:null});var f=null;if(null!==f)return c(null,f);var h={Accept:a};for(var p in t.headers)h[p]=t.headers[p];o({url:n,headers:h,strictSSL:r,followRedirect:!1},function(t,r,o){if(f={contextUrl:null,documentUrl:n,document:o||null},t)return c(new I("URL could not be dereferenced, an error occurred.","jsonld.LoadDocumentError",{code:"loading document failed",url:n,cause:t}),f);var a=s.STATUS_CODES[r.statusCode];if(r.statusCode>=400)return c(new I("URL could not be dereferenced: "+a,"jsonld.InvalidUrl",{code:"loading document failed",url:n,httpStatusCode:r.statusCode}),f);if(r.headers.link&&"application/ld+json"!==r.headers["content-type"]){var h=e.parseLinkHeader(r.headers.link)[j];if(re(h))return c(new I("URL could not be dereferenced, it has more than one associated HTTP Link Header.","jsonld.InvalidUrl",{code:"multiple context link headers",url:n}),f);h&&(f.contextUrl=h.target)}if(r.statusCode>=300&&r.statusCode<400&&r.headers.location)return u.length===i?c(new I("URL could not be dereferenced; there were too many redirects.","jsonld.TooManyRedirects",{code:"loading document failed",url:n,httpStatusCode:r.statusCode,redirects:u}),f):-1!==u.indexOf(n)?c(new I("URL could not be dereferenced; infinite redirection was detected.","jsonld.InfiniteRedirectDetected",{code:"recursive context inclusion",url:n,httpStatusCode:r.statusCode,redirects:u}),f):(u.push(n),l(r.headers.location,u,c));u.push(n),c(t,f)})}},e.documentLoaders.xhr=function(t){t=t||{};var n=/(^|(\r\n))link:/i,r=new e.RequestQueue;return("usePromise"in t?t.usePromise:"undefined"!=typeof Promise)?r.wrapLoader(function(t){return e.promisify(i,t)}):r.wrapLoader(i);function i(r,i){if(0!==r.indexOf("http:")&&0!==r.indexOf("https:"))return i(new I('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});if(t.secure&&0!==r.indexOf("https"))return i(new I('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});var o=new(t.xhr||XMLHttpRequest);o.onload=function(){if(o.status>=400)return i(new I("URL could not be dereferenced: "+o.statusText,"jsonld.LoadDocumentError",{code:"loading document failed",url:r,httpStatusCode:o.status}),{contextUrl:null,documentUrl:r,document:null});var t,a={contextUrl:null,documentUrl:r,document:o.response},s=o.getResponseHeader("Content-Type");if(n.test(o.getAllResponseHeaders())&&(t=o.getResponseHeader("Link")),t&&"application/ld+json"!==s){if(re(t=e.parseLinkHeader(t)[j]))return i(new I("URL could not be dereferenced, it has more than one associated HTTP Link Header.","jsonld.InvalidUrl",{code:"multiple context link headers",url:r}),a);t&&(a.contextUrl=t.target)}i(null,a)},o.onerror=function(){i(new I("URL could not be dereferenced, an error occurred.","jsonld.LoadDocumentError",{code:"loading document failed",url:r}),{contextUrl:null,documentUrl:r,document:null})},o.open("GET",r,!0),o.setRequestHeader("Accept","application/ld+json, application/json"),o.send()}},e.useDocumentLoader=function(t){if(!(t in e.documentLoaders))throw new I('Unknown document loader type: "'+t+'"',"jsonld.UnknownDocumentLoader",{type:t});e.documentLoader=e.documentLoaders[t].apply(e,Array.prototype.slice.call(arguments,1))},e.processContext=function(t,n){var r={},i=2;arguments.length>3&&(r=arguments[2]||{},i+=1);var o=arguments[i];if("base"in r||(r.base=""),"documentLoader"in r||(r.documentLoader=e.loadDocument),null===n)return o(null,ee(r));ne(n=ye(n))&&"@context"in n||(n={"@context":n}),ge(n,r,function(e,n){if(e)return o(e);try{n=(new R).processContext(t,n,r)}catch(e){return o(e)}o(null,n)})},e.hasProperty=function(e,t){var n=!1;if(t in e){var r=e[t];n=!re(r)||r.length>0}return n},e.hasValue=function(t,n,r){var i=!1;if(e.hasProperty(t,n)){var o=t[n],a=he(o);if(re(o)||a){a&&(o=o["@list"]);for(var s=0;s<o.length;++s)if(e.compareValues(r,o[s])){i=!0;break}}else re(r)||(i=e.compareValues(r,o))}return i},e.addValue=function(t,n,r,i){if("propertyIsArray"in(i=i||{})||(i.propertyIsArray=!1),"allowDuplicate"in i||(i.allowDuplicate=!0),re(r)){0!==r.length||!i.propertyIsArray||n in t||(t[n]=[]);for(var o=0;o<r.length;++o)e.addValue(t,n,r[o],i)}else if(n in t){var a=!i.allowDuplicate&&e.hasValue(t,n,r);re(t[n])||a&&!i.propertyIsArray||(t[n]=[t[n]]),a||t[n].push(r)}else t[n]=i.propertyIsArray?[r]:r},e.getValues=function(e,t){var n=e[t]||[];return re(n)||(n=[n]),n},e.removeProperty=function(e,t){delete e[t]},e.removeValue=function(t,n,r,i){"propertyIsArray"in(i=i||{})||(i.propertyIsArray=!1);var o=e.getValues(t,n).filter(function(t){return!e.compareValues(t,r)});0===o.length?e.removeProperty(t,n):1!==o.length||i.propertyIsArray?t[n]=o:t[n]=o[0]},e.compareValues=function(e,t){return e===t||(!(!fe(e)||!fe(t)||e["@value"]!==t["@value"]||e["@type"]!==t["@type"]||e["@language"]!==t["@language"]||e["@index"]!==t["@index"])||!!(ne(e)&&"@id"in e&&ne(t)&&"@id"in t)&&e["@id"]===t["@id"])},e.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 i=e.mappings[t];ue(n)?r=i:n in i&&(r=i[n])}return r};var h={};if(e.registerRDFParser=function(e,t){h[e]=t},e.unregisterRDFParser=function(e){delete h[e]},u){if(void 0===p)var p=null;if(void 0===d)var d={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 y="http://www.w3.org/2001/XMLSchema#boolean",v="http://www.w3.org/2001/XMLSchema#double",g="http://www.w3.org/2001/XMLSchema#integer",m="http://www.w3.org/2001/XMLSchema#string",w="http://www.w3.org/1999/02/22-rdf-syntax-ns#",b=w+"first",x=w+"rest",_=w+"nil",k=w+"type",S=w+"PlainLiteral",T=w+"XMLLiteral",E=w+"object",O=w+"langString",j="http://www.w3.org/ns/json-ld#context",N=10,I=function(e,t,n){u?(Error.call(this),Error.captureStackTrace(this,this.constructor)):"undefined"!=typeof Error&&(this.stack=(new Error).stack),this.name=t||"jsonld.Error",this.message=e||"An unspecified JSON-LD error occurred.",this.details=n||{}};u?n(10).inherits(I,Error):"undefined"!=typeof Error&&(I.prototype=new Error);var R=function(){};function A(e){for(var t=[],n=Object.keys(e).sort(),r=0;r<n.length;++r){var i=n[r],o=e[i];re(o)||(o=[o]);for(var a=0;a<o.length;++a){var s=o[a];if(null!==s){if(!oe(s))throw new I("Invalid JSON-LD syntax; language map values must be strings.","jsonld.SyntaxError",{code:"invalid language map value",languageMap:e});t.push({"@value":s,"@language":i.toLowerCase()})}}}return t}function C(e,t,n){for(var r=[],i=Object.keys(e).sort(),o=0;o<i.length;++o)for(var a=i[o],s=e[a],u=Object.keys(s).sort(),c=0;c<u.length;++c){var l=u[c],f=s[l];if("@type"===l)l=k;else if(te(l))continue;for(var h=0;h<f.length;++h){var p=f[h],d={};if(d.type=0===a.indexOf("_:")?"blank node":"IRI",d.value=a,de(a)){var y={};if(y.type=0===l.indexOf("_:")?"blank node":"IRI",y.value=l,de(l)&&("blank node"!==y.type||n.produceGeneralizedRdf))if(he(p))P(p["@list"],t,d,y,r);else{var v=L(p);v&&r.push({subject:d,predicate:y,object:v})}}}}return r}function P(e,t,n,r,i){for(var o={type:"IRI",value:b},a={type:"IRI",value:x},s={type:"IRI",value:_},u=0;u<e.length;++u){var c=e[u],l={type:"blank node",value:t.getId()};i.push({subject:n,predicate:r,object:l}),n=l,r=o;var f=L(c);f&&i.push({subject:n,predicate:r,object:f}),r=a}i.push({subject:n,predicate:r,object:s})}function L(e){var t,n={};if(fe(e)){n.type="literal";var r=e["@value"],i=e["@type"]||null;"boolean"==typeof(t=r)||"[object Boolean]"===Object.prototype.toString.call(t)?(n.value=r.toString(),n.datatype=i||y):se(r)||i===v?(se(r)||(r=parseFloat(r)),n.value=r.toExponential(15).replace(/(\d)0*e\+?/,"$1E"),n.datatype=i||v):ae(r)?(n.value=r.toFixed(0),n.datatype=i||g):"@language"in e?(n.value=r,n.datatype=i||O,n.language=e["@language"]):(n.value=r,n.datatype=i||m)}else{var o=ne(e)?e["@id"]:e;n.type=0===o.indexOf("_:")?"blank node":"IRI",n.value=o}return"IRI"!==n.type||de(n.value)?n:null}function D(e,t){if("IRI"===e.type||"blank node"===e.type)return{"@id":e.value};var n,r={"@value":e.value};if(e.language)r["@language"]=e.language;else{var i=e.datatype;if(i||(i=m),t){if(i===y)"true"===r["@value"]?r["@value"]=!0:"false"===r["@value"]&&(r["@value"]=!1);else if(n=r["@value"],!isNaN(parseFloat(n))&&isFinite(n))if(i===g){var o=parseInt(r["@value"],10);o.toFixed(0)===r["@value"]&&(r["@value"]=o)}else i===v&&(r["@value"]=parseFloat(r["@value"]));-1===[y,g,v,m].indexOf(i)&&(r["@type"]=i)}else i!==m&&(r["@type"]=i)}return r}function U(e,t){for(var n=["subject","predicate","object"],r=0;r<n.length;++r){var i=n[r];if(e[i].type!==t[i].type||e[i].value!==t[i].value)return!1}return e.object.language===t.object.language&&e.object.datatype===t.object.datatype}R.prototype.compact=function(t,n,r,i){if(re(r)){for(var o=[],a=0;a<r.length;++a){var s=this.compact(t,n,r[a],i);null!==s&&o.push(s)}if(i.compactArrays&&1===o.length)null===(_=e.getContextValue(t,n,"@container"))&&(o=o[0]);return o}if(ne(r)){if(i.link&&"@id"in r&&r["@id"]in i.link){var u=i.link[r["@id"]];for(a=0;a<u.length;++a)if(u[a].expanded===r)return u[a].compacted}if(fe(r)||le(r)){o=function(t,n,r){if(fe(r)){var i=e.getContextValue(t,n,"@type"),o=e.getContextValue(t,n,"@language"),a=e.getContextValue(t,n,"@container"),s="@index"in r&&"@index"!==a;if(!s&&(r["@type"]===i||r["@language"]===o))return r["@value"];var u=Object.keys(r).length,c=1===u||2===u&&"@index"in r&&!s,l="@language"in t,f=oe(r["@value"]),h=t.mappings[n]&&null===t.mappings[n]["@language"];if(c&&(!l||!f||h))return r["@value"];var p={};return s&&(p[G(t,"@index")]=r["@index"]),"@type"in r?p[G(t,"@type")]=G(t,r["@type"],null,{vocab:!0}):"@language"in r&&(p[G(t,"@language")]=r["@language"]),p[G(t,"@value")]=r["@value"],p}var d=Z(t,n,{vocab:!0}),i=e.getContextValue(t,n,"@type"),y=G(t,r["@id"],null,{vocab:"@vocab"===i});if("@id"===i||"@vocab"===i||"@graph"===d)return y;return(p={})[G(t,"@id")]=y,p}(t,n,r);return i.link&&le(r)&&(r["@id"]in i.link||(i.link[r["@id"]]=[]),i.link[r["@id"]].push({expanded:r,compacted:o})),o}var c="@reverse"===n;o={};i.link&&"@id"in r&&(r["@id"]in i.link||(i.link[r["@id"]]=[]),i.link[r["@id"]].push({expanded:r,compacted:o}));for(var l=Object.keys(r).sort(),f=0;f<l.length;++f){var h=l[f],p=r[h];if("@id"!==h&&"@type"!==h)if("@reverse"!==h)if("@index"!==h)if("@graph"!==h&&"@list"!==h&&te(h)){T=G(t,h);e.addValue(o,T,p)}else{if(0===p.length){var d=G(t,h,p,{vocab:!0},c);e.addValue(o,d,p,{propertyIsArray:!0})}for(O=0;O<p.length;++O){var y=p[O],v=(d=G(t,h,y,{vocab:!0},c),_=e.getContextValue(t,d,"@container"),he(y)),g=null;v&&(g=y["@list"]);var m=this.compact(t,d,v?g:y,i);if(v)if(re(m)||(m=[m]),"@list"!==_){var w={};w[G(t,"@list")]=m,m=w,"@index"in y&&(m[G(t,"@index")]=y["@index"])}else if(d in o)throw new I('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"===_||"@index"===_){var b;d in o?b=o[d]:o[d]=b={},"@language"===_&&fe(m)&&(m=m["@value"]),e.addValue(b,y[_],m)}else{j=!i.compactArrays||"@set"===_||"@list"===_||re(m)&&0===m.length||"@list"===h||"@graph"===h;e.addValue(o,d,m,{propertyIsArray:j})}}}else{if("@index"===(_=e.getContextValue(t,n,"@container")))continue;T=G(t,h);e.addValue(o,T,p)}else{E=this.compact(t,"@reverse",p,i);for(var x in E)if(t.mappings[x]&&t.mappings[x].reverse){var _,k=E[x],S="@set"===(_=e.getContextValue(t,x,"@container"))||!i.compactArrays;e.addValue(o,x,k,{propertyIsArray:S}),delete E[x]}if(Object.keys(E).length>0){var T=G(t,h);e.addValue(o,T,E)}}else{var E;if(oe(p))E=G(t,p,null,{vocab:"@type"===h});else{E=[];for(var O=0;O<p.length;++O)E.push(G(t,p[O],null,{vocab:!0}))}var T=G(t,h),j=re(E)&&0===p.length;e.addValue(o,T,E,{propertyIsArray:j})}}return o}return r},R.prototype.expand=function(t,n,r,i,o){var a=this;if(null==r)return null;if(!re(r)&&!ne(r))return o||null!==n&&"@graph"!==Z(t,n,{vocab:!0})?function(t,n,r){if(null==r)return null;var i=Z(t,n,{vocab:!0});if("@id"===i)return Z(t,r,{base:!0});if("@type"===i)return Z(t,r,{vocab:!0,base:!0});var o=e.getContextValue(t,n,"@type");if("@id"===o||"@graph"===i&&oe(r))return{"@id":Z(t,r,{base:!0})};if("@vocab"===o)return{"@id":Z(t,r,{vocab:!0,base:!0})};if(te(i))return r;var a={};if(null!==o)a["@type"]=o;else if(oe(r)){var s=e.getContextValue(t,n,"@language");null!==s&&(a["@language"]=s)}-1===["boolean","number","string"].indexOf(typeof r)&&(r=r.toString());return a["@value"]=r,a}(t,n,r):null;if(re(r)){var s=[],u=e.getContextValue(t,n,"@container");o=o||"@list"===u;for(var c=0;c<r.length;++c){var l=a.expand(t,n,r[c],i);if(o&&(re(l)||he(l)))throw new I("Invalid JSON-LD syntax; lists of lists are not permitted.","jsonld.SyntaxError",{code:"list of lists"});null!==l&&(re(l)?s=s.concat(l):s.push(l))}return s}"@context"in r&&(t=a.processContext(t,r["@context"],i));for(var f=Z(t,n,{vocab:!0}),h=(s={},Object.keys(r).sort()),p=0;p<h.length;++p){var d,y=h[p],v=r[y];if("@context"!==y){var g=Z(t,y,{vocab:!0});if(null!==g&&(de(g)||te(g))){if(te(g)){if("@reverse"===f)throw new I("Invalid JSON-LD syntax; a keyword cannot be used as a @reverse property.","jsonld.SyntaxError",{code:"invalid reverse property map",value:v});if(g in s)throw new I("Invalid JSON-LD syntax; colliding keywords detected.","jsonld.SyntaxError",{code:"colliding keywords",keyword:g})}if("@id"===g&&!oe(v)){if(!i.isFrame)throw new I('Invalid JSON-LD syntax; "@id" value must a string.',"jsonld.SyntaxError",{code:"invalid @id value",value:v});if(!ne(v))throw new I('Invalid JSON-LD syntax; "@id" value must be a string or an object.',"jsonld.SyntaxError",{code:"invalid @id value",value:v})}if("@type"===g&&ie(v),"@graph"===g&&!ne(v)&&!re(v))throw new I('Invalid JSON-LD syntax; "@graph" value must not be an object or an array.',"jsonld.SyntaxError",{code:"invalid @graph value",value:v});if("@value"===g&&(ne(v)||re(v)))throw new I('Invalid JSON-LD syntax; "@value" value must not be an object or an array.',"jsonld.SyntaxError",{code:"invalid value object value",value:v});if("@language"===g){if(null===v)continue;if(!oe(v))throw new I('Invalid JSON-LD syntax; "@language" value must be a string.',"jsonld.SyntaxError",{code:"invalid language-tagged string",value:v});v=v.toLowerCase()}if("@index"===g&&!oe(v))throw new I('Invalid JSON-LD syntax; "@index" value must be a string.',"jsonld.SyntaxError",{code:"invalid @index value",value:v});if("@reverse"!==g){if("@language"===(u=e.getContextValue(t,y,"@container"))&&ne(v))d=A(v);else if("@index"===u&&ne(v))d=function(e){for(var n=[],r=Object.keys(v).sort(),o=0;o<r.length;++o){var s=r[o],u=v[s];re(u)||(u=[u]),u=a.expand(t,e,u,i,!1);for(var c=0;c<u.length;++c){var l=u[c];"@index"in l||(l["@index"]=s),n.push(l)}}return n}(y);else{var m="@list"===g;if(m||"@set"===g){var w=n;if(m&&"@graph"===f&&(w=null),d=a.expand(t,w,v,i,m),m&&he(d))throw new I("Invalid JSON-LD syntax; lists of lists are not permitted.","jsonld.SyntaxError",{code:"list of lists"})}else d=a.expand(t,y,v,i,!1)}if(null!==d||"@value"===g)if("@list"===g||he(d)||"@list"!==u||(d={"@list":d=re(d)?d:[d]}),t.mappings[y]&&t.mappings[y].reverse){_=s["@reverse"]=s["@reverse"]||{};re(d)||(d=[d]);for(S=0;S<d.length;++S){if(fe(T=d[S])||he(T))throw new I('Invalid JSON-LD syntax; "@reverse" value must not be a @value or an @list.',"jsonld.SyntaxError",{code:"invalid reverse property value",value:d});e.addValue(_,g,T,{propertyIsArray:!0})}}else{var b=-1===["@index","@id","@type","@value","@language"].indexOf(g);e.addValue(s,g,d,{propertyIsArray:b})}}else{if(!ne(v))throw new I('Invalid JSON-LD syntax; "@reverse" value must be an object.',"jsonld.SyntaxError",{code:"invalid @reverse value",value:v});if("@reverse"in(d=a.expand(t,"@reverse",v,i)))for(var x in d["@reverse"])e.addValue(s,x,d["@reverse"][x],{propertyIsArray:!0});var _=s["@reverse"]||null;for(var x in d)if("@reverse"!==x){null===_&&(_=s["@reverse"]={}),e.addValue(_,x,[],{propertyIsArray:!0});for(var k=d[x],S=0;S<k.length;++S){var T;if(fe(T=k[S])||he(T))throw new I('Invalid JSON-LD syntax; "@reverse" value must not be a @value or an @list.',"jsonld.SyntaxError",{code:"invalid reverse property value",value:d});e.addValue(_,x,T,{propertyIsArray:!0})}}}}}}var E=(h=Object.keys(s)).length;if("@value"in s){if("@type"in s&&"@language"in s)throw new I('Invalid JSON-LD syntax; an element containing "@value" may not contain both "@type" and "@language".',"jsonld.SyntaxError",{code:"invalid value object",element:s});var O=E-1;if("@type"in s&&(O-=1),"@index"in s&&(O-=1),"@language"in s&&(O-=1),0!==O)throw new I('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&&!oe(s["@value"]))throw new I("Invalid JSON-LD syntax; only strings may be language-tagged.","jsonld.SyntaxError",{code:"invalid language-tagged value",element:s});if("@type"in s&&(!de(s["@type"])||0===s["@type"].indexOf("_:")))throw new I('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&&!re(s["@type"]))s["@type"]=[s["@type"]];else if("@set"in s||"@list"in s){if(E>1&&!(2===E&&"@index"in s))throw new I('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"],E=(h=Object.keys(s)).length)}else 1===E&&"@language"in s&&(s=null);return!ne(s)||i.keepFreeFloatingNodes||o||null!==n&&"@graph"!==f||(0===E||"@value"in s||"@list"in s||1===E&&"@id"in s)&&(s=null),s},R.prototype.createNodeMap=function(e,t){var n={"@default":{}};return z(e,n,"@default",(t=t||{}).namer||t.issuer||new be("_:b")),H(n)},R.prototype.flatten=function(e){for(var t=this.createNodeMap(e),n=[],r=Object.keys(t).sort(),i=0;i<r.length;++i){var o=t[r[i]];le(o)||n.push(o)}return n},R.prototype.frame=function(e,t,n){var r={options:n,graphs:{"@default":{},"@merged":{}},subjectStack:[],link:{}},i=new be("_:b");z(e,r.graphs,"@merged",i),r.subjects=r.graphs["@merged"];var o=[];return function e(t,n,r,i,o){!function(e){if(!re(e)||1!==e.length||!ne(e[0]))throw new I("Invalid JSON-LD syntax; a JSON-LD frame must be a single object.","jsonld.SyntaxError",{frame:e})}(r);r=r[0];var a=t.options;var s={embed:W(r,a,"embed"),explicit:W(r,a,"explicit"),requireAll:W(r,a,"requireAll")};var u=function(e,t,n,r){for(var i={},o=0;o<t.length;++o){var a=t[o],s=e.subjects[a];X(s,n,r)&&(i[a]=s)}return i}(t,n,r,s);var c=Object.keys(u).sort();for(var l=0;l<c.length;++l){var f=c[l],h=u[f];if("@link"===s.embed&&f in t.link)$(i,o,t.link[f]);else{null===o&&(t.uniqueEmbeds={});var p={};if(p["@id"]=f,t.link[f]=p,"@never"===s.embed||J(h,t.subjectStack))$(i,o,p);else{"@last"===s.embed&&(f in t.uniqueEmbeds&&Y(t,f),t.uniqueEmbeds[f]={parent:i,property:o}),t.subjectStack.push(h);for(var d=Object.keys(h).sort(),y=0;y<d.length;y++){var v=d[y];if(te(v))p[v]=ye(h[v]);else if(!s.explicit||v in r)for(var g=h[v],m=0;m<g.length;++m){var w=g[m];if(he(w)){var b={"@list":[]};$(p,v,b);var x=w["@list"];for(var _ in x)if(le(w=x[_])){var k=v in r?r[v][0]["@list"]:V(s);e(t,[w["@id"]],k,b,"@list")}else $(b,"@list",ye(w))}else if(le(w)){var k=v in r?r[v]:V(s);e(t,[w["@id"]],k,p,v)}else $(p,v,ye(w))}}for(var d=Object.keys(r).sort(),y=0;y<d.length;++y){var v=d[y];if(!te(v)){var S=r[v][0],T=W(S,a,"omitDefault");if(!(T||v in p)){var E="@null";"@default"in S&&(E=ye(S["@default"])),re(E)||(E=[E]),p[v]=[{"@preserve":E}]}}}$(i,o,p),t.subjectStack.pop()}}}}(r,Object.keys(r.subjects).sort(),t,o,null),o},R.prototype.normalize=function(e,t,n){return"URDNA2015"===t.algorithm?new B(t).main(e,n):"URGNA2012"===t.algorithm?new q(t).main(e,n):void n(new Error("Invalid RDF Dataset Normalization algorithm: "+t.algorithm))},R.prototype.fromRDF=function(t,n,r){var i={},o={"@default":i},a={};for(var s in t){var u=t[s];s in o||(o[s]={}),"@default"===s||s in i||(i[s]={"@id":s});for(var c=o[s],l=0;l<u.length;++l){var f=u[l],h=f.subject.value,p=f.predicate.value,d=f.object;h in c||(c[h]={"@id":h});var y=c[h],v="IRI"===d.type||"blank node"===d.type;if(!v||d.value in c||(c[d.value]={"@id":d.value}),p!==k||n.useRdfType||!v){var g=D(d,n.useNativeTypes);if(e.addValue(y,p,g,{propertyIsArray:!0}),v)if(d.value===_){var m=c[d.value];"usages"in m||(m.usages=[]),m.usages.push({node:y,property:p,value:g})}else d.value in a?a[d.value]=!1:a[d.value]={node:y,property:p,value:g}}else e.addValue(y,"@type",d.value,{propertyIsArray:!0})}}for(var s in o){var w=o[s];if(_ in w){for(var S=w[_],T=0;T<S.usages.length;++T){for(var E=S.usages[T],O=(y=E.node,E.property),j=E.value,N=[],I=[],R=Object.keys(y).length;O===x&&ne(a[y["@id"]])&&re(y[b])&&1===y[b].length&&re(y[x])&&1===y[x].length&&(3===R||4===R&&re(y["@type"])&&1===y["@type"].length&&"http://www.w3.org/1999/02/22-rdf-syntax-ns#List"===y["@type"][0])&&(N.push(y[b][0]),I.push(y["@id"]),y=(E=a[y["@id"]]).node,O=E.property,j=E.value,R=Object.keys(y).length,0===y["@id"].indexOf("_:")););if(O===b){if(y["@id"]===_)continue;j=w[j["@id"]][x][0],N.pop(),I.pop()}delete j["@id"],j["@list"]=N.reverse();for(var A=0;A<I.length;++A)delete w[I[A]]}delete S.usages}}var C=[],P=Object.keys(i).sort();for(T=0;T<P.length;++T){var L=P[T];y=i[L];if(L in o){u=y["@graph"]=[],w=o[L];for(var U=Object.keys(w).sort(),M=0;M<U.length;++M){var F=w[U[M]];le(F)||u.push(F)}}le(y)||C.push(y)}r(null,C)},R.prototype.toRDF=function(e,t){var n=new be("_:b"),r={"@default":{}};z(e,r,"@default",n);for(var i={},o=Object.keys(r).sort(),a=0;a<o.length;++a){var s=o[a];("@default"===s||de(s))&&(i[s]=C(r[s],n,t))}return i},R.prototype.processContext=function(t,n,r){ne(n)&&"@context"in n&&re(n["@context"])&&(n=n["@context"]);var i=re(n)?n:[n];if(0===i.length)return t.clone();for(var o=t,a=0;a<i.length;++a){var s=i[a];if(null!==s){if(ne(s)&&"@context"in s&&(s=s["@context"]),!ne(s))throw new I("Invalid JSON-LD syntax; @context must be an object.","jsonld.SyntaxError",{code:"invalid local context",context:s});if(e.cache.activeCtx){var u=e.cache.activeCtx.get(t,s);if(u){o=t=u;continue}}t=o,o=o.clone();var c={};if("@base"in s){var l=s["@base"];if(null===l)l=null;else{if(!oe(l))throw new I('Invalid JSON-LD syntax; the value of "@base" in a @context must be a string or null.',"jsonld.SyntaxError",{code:"invalid base IRI",context:s});if(""!==l&&!de(l))throw new I('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:s})}null!==l&&(l=e.url.parse(l||"")),o["@base"]=l,c["@base"]=!0}if("@vocab"in s){if(null===(f=s["@vocab"]))delete o["@vocab"];else{if(!oe(f))throw new I('Invalid JSON-LD syntax; the value of "@vocab" in a @context must be a string or null.',"jsonld.SyntaxError",{code:"invalid vocab mapping",context:s});if(!de(f))throw new I('Invalid JSON-LD syntax; the value of "@vocab" in a @context must be an absolute IRI.',"jsonld.SyntaxError",{code:"invalid vocab mapping",context:s});o["@vocab"]=f}c["@vocab"]=!0}if("@language"in s){var f;if(null===(f=s["@language"]))delete o["@language"];else{if(!oe(f))throw new I('Invalid JSON-LD syntax; the value of "@language" in a @context must be a string or null.',"jsonld.SyntaxError",{code:"invalid default language",context:s});o["@language"]=f.toLowerCase()}c["@language"]=!0}for(var h in s)Q(o,s,h,c);e.cache.activeCtx&&e.cache.activeCtx.set(t,s,o)}else o=t=ee(r)}return o};var M,F,B=(M={subject:"s",object:"o",name:"g"},(F=function(e){e=e||{},this.name="URDNA2015",this.options=e,this.blankNodeInfo={},this.hashToBlankNodes={},this.canonicalIssuer=new be("_: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}).prototype.doWork=function(t,n){var r=this.schedule;if(r.totalDepth>=r.MAX_TOTAL_DEPTH)return n(new Error("Maximum total call stack depth exceeded; normalization aborting."));!function i(){if(r.depth===r.MAX_DEPTH)return r.depth=0,r.running=!1,e.nextTick(i);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++,t(function(e,t){r.depth--,r.totalDepth--,n(e,t)});r.depth=0,r.running=!1,e.setImmediate(i)}()},F.prototype.forEach=function(e,t,n){var r,i,o=this,a=0;if(re(e))i=e.length,r=function(){return a!==i&&(r.value=e[a++],r.key=a,!0)};else{var s=Object.keys(e);i=s.length,r=function(){return a!==i&&(r.key=s[a++],r.value=e[r.key],!0)}}!function e(i,a){return i?n(i):r()?o.doWork(function(){t(r.value,r.key,e)}):void n()}()},F.prototype.waterfall=function(e,t){var n=this;n.forEach(e,function(e,t,r){n.doWork(e,r)},t)},F.prototype.whilst=function(e,t,n){var r=this;!function i(o){return o?n(o):e()?void r.doWork(t,i):n()}()},F.prototype.main=function(e,t){var n,r=this;if(r.schedule.start=(new Date).getTime(),r.options.format&&"application/nquads"!==r.options.format)return t(new I("Unknown output format.","jsonld.UnknownFormat",{format:r.options.format}));var i={};r.waterfall([function(t){r.forEach(e,function(e,t,n){"@default"===t&&(t=null),r.forEach(e,function(e,n,o){null!==t&&(0===t.indexOf("_:")?e.name={type:"blank node",value:t}:e.name={type:"IRI",value:t}),r.quads.push(e),r.forEachComponent(e,function(t){if("blank node"===t.type){var n=t.value;n in r.blankNodeInfo?r.blankNodeInfo[n].quads.push(e):(i[n]=!0,r.blankNodeInfo[n]={quads:[e]})}}),o()},n)},t)},function(e){var t=!0;r.whilst(function(){return t},function(e){t=!1,r.hashToBlankNodes={},r.waterfall([function(e){r.forEach(i,function(e,t,n){r.hashFirstDegreeQuads(t,function(e,i){if(e)return n(e);i in r.hashToBlankNodes?r.hashToBlankNodes[i].push(t):r.hashToBlankNodes[i]=[t],n()})},e)},function(e){var n=Object.keys(r.hashToBlankNodes).sort();r.forEach(n,function(e,n,o){var a=r.hashToBlankNodes[e];if(a.length>1)return o();var s=a[0];r.canonicalIssuer.getId(s),delete i[s],delete r.hashToBlankNodes[e],t=!0,o()},e)}],e)},e)},function(e){var t=Object.keys(r.hashToBlankNodes).sort();r.forEach(t,function(e,t,n){var i=[],o=r.hashToBlankNodes[e];r.waterfall([function(e){r.forEach(o,function(e,t,n){if(r.canonicalIssuer.hasId(e))return n();var o=new be("_:b");o.getId(e),r.hashNDegreeQuads(e,o,function(e,t){if(e)return n(e);i.push(t),n()})},e)},function(e){i.sort(function(e,t){return e.hash<t.hash?-1:e.hash>t.hash?1:0}),r.forEach(i,function(e,t,n){for(var i in e.issuer.existing)r.canonicalIssuer.getId(i);n()},e)}],n)},e)},function(e){var t=[];r.waterfall([function(e){r.forEach(r.quads,function(e,n,i){r.forEachComponent(e,function(e){"blank node"===e.type&&0!==e.value.indexOf(r.canonicalIssuer.prefix)&&(e.value=r.canonicalIssuer.getId(e.value))}),t.push(we(e)),i()},e)},function(e){if(t.sort(),"application/nquads"===r.options.format)return n=t.join(""),e();n=me(t.join("")),e()}],e)}],function(e){t(e,n)})},F.prototype.hashFirstDegreeQuads=function(e,t){var n=this,r=n.blankNodeInfo[e];if("hash"in r)return t(null,r.hash);var i=[],o=r.quads;n.forEach(o,function(t,r,o){var a={predicate:t.predicate};n.forEachComponent(t,function(t,r){a[r]=n.modifyFirstDegreeComponent(e,t,r)}),i.push(we(a)),o()},function(e){if(e)return t(e);i.sort(),r.hash=_e.hashNQuads(n.name,i),t(null,r.hash)})},F.prototype.modifyFirstDegreeComponent=function(e,t){return"blank node"!==t.type?t:((t=ye(t)).value=t.value===e?"_:a":"_:z",t)},F.prototype.hashRelatedBlankNode=function(e,t,n,r,i){var o,a=this;a.waterfall([function(t){return a.canonicalIssuer.hasId(e)?(o=a.canonicalIssuer.getId(e),t()):n.hasId(e)?(o=n.getId(e),t()):void a.hashFirstDegreeQuads(e,function(e,n){if(e)return t(e);o=n,t()})}],function(e){if(e)return i(e);var n=new _e(a.name);return n.update(r),"g"!==r&&n.update(a.getRelatedPredicate(t)),n.update(o),i(null,n.digest())})},F.prototype.getRelatedPredicate=function(e){return"<"+e.predicate.value+">"},F.prototype.hashNDegreeQuads=function(e,t,n){var r,i=this,o=new _e(i.name);i.waterfall([function(n){i.createHashToRelated(e,t,function(e,t){if(e)return n(e);r=t,n()})},function(e){var n=Object.keys(r).sort();i.forEach(n,function(e,n,a){o.update(e);var s,u="",c=new xe(r[e]);i.whilst(function(){return c.hasNext()},function(e){var n=c.next(),r=t.clone(),o="",a=[];i.waterfall([function(t){i.forEach(n,function(t,n,s){if(i.canonicalIssuer.hasId(t)?o+=i.canonicalIssuer.getId(t):(r.hasId(t)||a.push(t),o+=r.getId(t)),0!==u.length&&o.length>=u.length&&o>u)return e();s()},t)},function(t){i.forEach(a,function(t,n,a){i.hashNDegreeQuads(t,r,function(n,i){return n?a(n):(o+=r.getId(t),o+="<"+i.hash+">",r=i.issuer,0!==u.length&&o.length>=u.length&&o>u?e():void a())})},t)},function(e){(0===u.length||o<u)&&(u=o,s=r),e()}],e)},function(e){if(e)return a(e);o.update(u),t=s,a()})},e)}],function(e){n(e,{hash:o.digest(),issuer:t})})},F.prototype.createHashToRelated=function(e,t,n){var r=this,i={},o=r.blankNodeInfo[e].quads;r.forEach(o,function(n,o,a){r.forEach(n,function(o,a,s){if("predicate"===a||"blank node"!==o.type||o.value===e)return s();var u=o.value,c=M[a];r.hashRelatedBlankNode(u,n,t,c,function(e,t){if(e)return s(e);t in i?i[t].push(u):i[t]=[u],s()})},a)},function(e){n(e,i)})},F.prototype.forEachComponent=function(e,t){for(var n in e)"predicate"!==n&&t(e[n],n,e)},F),q=function(){var e=function(e){B.call(this,e),this.name="URGNA2012"};return(e.prototype=new B).modifyFirstDegreeComponent=function(e,t,n){return"blank node"!==t.type?t:((t=ye(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,i={},o=r.blankNodeInfo[e].quads;r.forEach(o,function(n,o,a){var s,u;if("blank node"===n.subject.type&&n.subject.value!==e)u=n.subject.value,s="p";else{if("blank node"!==n.object.type||n.object.value===e)return a();u=n.object.value,s="r"}r.hashRelatedBlankNode(u,n,t,s,function(e,t){t in i?i[t].push(u):i[t]=[u],a()})},function(e){n(e,i)})},e}();function z(t,n,r,i,o,a){if(re(t))for(var s=0;s<t.length;++s)z(t[s],n,r,i,void 0,a);else if(ne(t))if(fe(t)){"@type"in t&&0===(c=t["@type"]).indexOf("_:")&&(t["@type"]=c=i.getId(c)),a&&a.push(t)}else{if("@type"in t){var u=t["@type"];for(s=0;s<u.length;++s){var c;0===(c=u[s]).indexOf("_:")&&i.getId(c)}}ue(o)&&(o=pe(t)?i.getId(t["@id"]):t["@id"]),a&&a.push({"@id":o});var l=n[r],f=l[o]=l[o]||{};f["@id"]=o;for(var h=Object.keys(t).sort(),p=0;p<h.length;++p){var d=h[p];if("@id"!==d)if("@reverse"!==d)if("@graph"!==d)if("@type"!==d&&te(d)){if("@index"===d&&d in f&&(t[d]!==f[d]||t[d]["@id"]!==f[d]["@id"]))throw new I("Invalid JSON-LD syntax; conflicting @index property detected.","jsonld.SyntaxError",{code:"conflicting indexes",subject:f});f[d]=t[d]}else{var y=t[d];if(0===d.indexOf("_:")&&(d=i.getId(d)),0!==y.length)for(var v=0;v<y.length;++v){var g=y[v];if("@type"===d&&(g=0===g.indexOf("_:")?i.getId(g):g),ce(g)||le(g)){var m=pe(g)?i.getId(g["@id"]):g["@id"];e.addValue(f,d,{"@id":m},{propertyIsArray:!0,allowDuplicate:!1}),z(g,n,r,i,m)}else if(he(g)){var w=[];z(g["@list"],n,r,i,o,w),g={"@list":w},e.addValue(f,d,g,{propertyIsArray:!0,allowDuplicate:!1})}else z(g,n,r,i,o),e.addValue(f,d,g,{propertyIsArray:!0,allowDuplicate:!1})}else e.addValue(f,d,[],{propertyIsArray:!0})}else{o in n||(n[o]={});var b="@merged"===r?r:o;z(t[d],n,b,i)}else{var x={"@id":o},_=t["@reverse"];for(var k in _)for(var S=_[k],T=0;T<S.length;++T){var E=S[T],O=E["@id"];pe(E)&&(O=i.getId(O)),z(E,n,r,i,O),e.addValue(l[O],k,x,{propertyIsArray:!0,allowDuplicate:!1})}}}}else a&&a.push(t)}function H(e){for(var t=e["@default"],n=Object.keys(e).sort(),r=0;r<n.length;++r){var i=n[r];if("@default"!==i){var o=e[i],a=t[i];a?"@graph"in a||(a["@graph"]=[]):t[i]=a={"@id":i,"@graph":[]};for(var s=a["@graph"],u=Object.keys(o).sort(),c=0;c<u.length;++c){var l=o[u[c]];le(l)||s.push(l)}}}return t}function V(e){var t={};for(var n in e)void 0!==e[n]&&(t["@"+n]=[e[n]]);return[t]}function J(e,t){for(var n=t.length-1;n>=0;--n)if(t[n]["@id"]===e["@id"])return!0;return!1}function W(e,t,n){var r="@"+n,i=r in e?e[r][0]:t[n];return"embed"===n&&(!0===i?i="@last":!1===i?i="@never":"@always"!==i&&"@never"!==i&&"@link"!==i&&(i="@last")),i}function X(t,n,r){if("@type"in n&&(1!==n["@type"].length||!ne(n["@type"][0]))){for(var i=n["@type"],o=0;o<i.length;++o)if(e.hasValue(t,"@type",i[o]))return!0;return!1}var a=!0,s=!1;for(var u in n){if(te(u)){if("@id"!==u&&"@type"!==u)continue;if(a=!1,"@id"===u&&oe(n[u])){if(t[u]!==n[u])return!1;s=!0;continue}}if(a=!1,u in t){if(re(n[u])&&0===n[u].length&&void 0!==t[u])return!1;s=!0}else{var c=re(n[u])&&ne(n[u][0])&&"@default"in n[u][0];if(r.requireAll&&!c)return!1}}return a||s}function Y(t,n){var r=t.uniqueEmbeds,i=r[n],o=i.parent,a=i.property,s={"@id":n};if(re(o)){for(var u=0;u<o.length;++u)if(e.compareValues(o[u],s)){o[u]=s;break}}else{var c=re(o[a]);e.removeValue(o,a,s,{propertyIsArray:c}),e.addValue(o,a,s,{propertyIsArray:c})}var l=function(e){for(var t=Object.keys(r),n=0;n<t.length;++n){var i=t[n];i in r&&ne(r[i].parent)&&r[i].parent["@id"]===e&&(delete r[i],l(i))}};l(n)}function $(t,n,r){ne(t)?e.addValue(t,n,r,{propertyIsArray:!0}):t.push(r)}function K(e,t){return e.length<t.length?-1:t.length<e.length?1:e===t?0:e<t?-1:1}function G(t,n,r,i,o){if(null===n)return n;ue(r)&&(r=null),ue(o)&&(o=!1),i=i||{};var a=t.getInverse();if(te(n))return n in a?a[n]["@none"]["@type"]["@none"]:n;if(i.vocab&&n in a){var s=t["@language"]||"@none",u=[];ne(r)&&"@index"in r&&u.push("@index");var c="@language",l="@null";if(o)c="@type",l="@reverse",u.push("@set");else if(he(r)){"@index"in r||u.push("@list");for(var f=r["@list"],h=0===f.length?s:null,p=null,d=0;d<f.length;++d){var y=f[d],v="@none",g="@none";if(fe(y)?"@language"in y?v=y["@language"]:"@type"in y?g=y["@type"]:v="@null":g="@id",null===h?h=v:v!==h&&fe(y)&&(h="@none"),null===p?p=g:g!==p&&(p="@none"),"@none"===h&&"@none"===p)break}h=h||"@none","@none"!==(p=p||"@none")?(c="@type",l=p):l=h}else fe(r)?"@language"in r&&!("@index"in r)?(u.push("@language"),l=r["@language"]):"@type"in r&&(c="@type",l=r["@type"]):(c="@type",l="@id"),u.push("@set");u.push("@none");var m=function(e,t,n,r,i,o){null===o&&(o="@null");var a=[];if("@id"!==o&&"@reverse"!==o||!le(n))a.push(o);else{"@reverse"===o&&a.push("@reverse");var s=G(e,n["@id"],null,{vocab:!0});s in e.mappings&&e.mappings[s]&&e.mappings[s]["@id"]===n["@id"]?a.push.apply(a,["@vocab","@id"]):a.push.apply(a,["@id","@vocab"])}a.push("@none");for(var u=e.inverse[t],c=0;c<r.length;++c){var l=r[c];if(l in u)for(var f=u[l][i],h=0;h<a.length;++h){var p=a[h];if(p in f)return f[p]}}return null}(t,n,r,u,c,l);if(null!==m)return m}if(i.vocab&&"@vocab"in t){var w=t["@vocab"];if(0===n.indexOf(w)&&n!==w){var b=n.substr(w.length);if(!(b in t.mappings))return b}}for(var x=null,_=0,k=[],S=t.fastCurieMap,T=n.length-1;_<T&&n[_]in S;++_)""in(S=S[n[_]])&&k.push(S[""][0]);for(d=k.length-1;d>=0;--d)for(var E=k[d],O=E.terms,j=0;j<O.length;++j){var N=O[j]+":"+n.substr(E.iri.length);(!(N in t.mappings)||null===r&&t.mappings[N]["@id"]===n)&&(null===x||K(N,x)<0)&&(x=N)}return null!==x?x:i.vocab?n:function(t,n){if(null===t)return n;oe(t)&&(t=e.url.parse(t||""));var r="";""!==t.href?r+=(t.protocol||"")+"//"+(t.authority||""):n.indexOf("//")&&(r+="//");if(0!==n.indexOf(r))return n;var i=e.url.parse(n.substr(r.length)),o=t.normalizedPath.split("/"),a=i.normalizedPath.split("/"),s=i.fragment||i.query?0:1;for(;o.length>0&&a.length>s&&o[0]===a[0];)o.shift(),a.shift();var u="";if(o.length>0){o.pop();for(var c=0;c<o.length;++c)u+="../"}u+=a.join("/"),null!==i.query&&(u+="?"+i.query);null!==i.fragment&&(u+="#"+i.fragment);""===u&&(u="./");return u}(t["@base"],n)}function Q(e,t,n,r){if(n in r){if(r[n])return;throw new I("Cyclical context definition detected.","jsonld.CyclicalContext",{code:"cyclic IRI mapping",context:t,term:n})}if(r[n]=!1,te(n))throw new I("Invalid JSON-LD syntax; keywords cannot be overridden.","jsonld.SyntaxError",{code:"keyword redefinition",context:t,term:n});if(""===n)throw new I("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 i=t[n];if(null===i||ne(i)&&null===i["@id"])return e.mappings[n]=null,void(r[n]=!0);if(oe(i)&&(i={"@id":i}),!ne(i))throw new I("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 i){if("@id"in i)throw new I("Invalid JSON-LD syntax; a @reverse term definition must not contain @id.","jsonld.SyntaxError",{code:"invalid reverse property",context:t});var a=i["@reverse"];if(!oe(a))throw new I("Invalid JSON-LD syntax; a @context @reverse value must be a string.","jsonld.SyntaxError",{code:"invalid IRI mapping",context:t});if(!de(s=Z(e,a,{vocab:!0,base:!1},t,r)))throw new I("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"]=s,o.reverse=!0}else if("@id"in i){if(!oe(s=i["@id"]))throw new I("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(s!==n){if(!de(s=Z(e,s,{vocab:!0,base:!1},t,r))&&!te(s))throw new I("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"]=s}}var s,u=n.indexOf(":");if(o._termHasColon=-1!==u,!("@id"in o))if(o._termHasColon){var c=n.substr(0,u);if(c in t&&Q(e,t,c,r),e.mappings[c]){var l=n.substr(u+1);o["@id"]=e.mappings[c]["@id"]+l}else o["@id"]=n}else{if(!("@vocab"in e))throw new I("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 i){var f=i["@type"];if(!oe(f))throw new I("Invalid JSON-LD syntax; an @context @type values must be a string.","jsonld.SyntaxError",{code:"invalid type mapping",context:t});if("@id"!==f&&"@vocab"!==f){if(!de(f=Z(e,f,{vocab:!0,base:!1},t,r)))throw new I("Invalid JSON-LD syntax; an @context @type value must be an absolute IRI.","jsonld.SyntaxError",{code:"invalid type mapping",context:t});if(0===f.indexOf("_:"))throw new I("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"]=f}if("@container"in i){var h=i["@container"];if("@list"!==h&&"@set"!==h&&"@index"!==h&&"@language"!==h)throw new I("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"!==h&&"@set"!==h&&null!==h)throw new I("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"]=h}if("@language"in i&&!("@type"in i)){var p=i["@language"];if(null!==p&&!oe(p))throw new I("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}
  // disallow aliasing @context and @preserve
  if("@context"===(s=o["@id"])||"@preserve"===s)throw new I("Invalid JSON-LD syntax; @context and @preserve cannot be aliased.","jsonld.SyntaxError",{code:"invalid keyword alias",context:t})}function Z(t,n,r,i,o){if(null===n||te(n))return n;if(n=String(n),i&&n in i&&!0!==o[n]&&Q(t,i,n,o),(r=r||{}).vocab){if(null===(s=t.mappings[n]))return null;if(s)return s["@id"]}var a=n.indexOf(":");if(-1!==a){var s,u=n.substr(0,a),c=n.substr(a+1);return"_"===u||0===c.indexOf("//")?n:(i&&u in i&&Q(t,i,u,o),(s=t.mappings[u])?s["@id"]+c:n)}if(r.vocab&&"@vocab"in t)return t["@vocab"]+n;var l=n;return r.base&&(l=e.prependBase(t["@base"],l)),l}function ee(t){return{"@base":e.url.parse(t.base||""),mappings:{},inverse:null,getInverse:function(){if(this.inverse)return this.inverse;for(var e=this.inverse={},t=this.fastCurieMap={},i={},o=this["@language"]||"@none",a=this.mappings,s=Object.keys(a).sort(K),u=0;u<s.length;++u){var c=s[u],l=a[c];if(null!==l){var f=l["@container"]||"@none",h=l["@id"];re(h)||(h=[h]);for(var p=0;p<h.length;++p){var d=h[p],y=e[d],v=te(d);if(y)v||l._termHasColon||i[d].push(c);else if(e[d]=y={},!v&&!l._termHasColon){i[d]=[c];var g={iri:d,terms:i[d]};d[0]in t?t[d[0]].push(g):t[d[0]]=[g]}if(y[f]||(y[f]={"@language":{},"@type":{}}),y=y[f],l.reverse)r(l,c,y["@type"],"@reverse");else if("@type"in l)r(l,c,y["@type"],l["@type"]);else if("@language"in l){var m=l["@language"]||"@null";r(l,c,y["@language"],m)}else r(l,c,y["@language"],o),r(l,c,y["@type"],"@none"),r(l,c,y["@language"],"@none")}}}for(var w in t)n(t,w,1);return e},clone:function(){var e={};e["@base"]=this["@base"],e.mappings=ye(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"]);return e}};function n(e,t,r){for(var i,o,a=e[t],s=e[t]={},u=0;u<a.length;++u)(o=r>=(i=a[u].iri).length?"":i[r])in s?s[o].push(a[u]):s[o]=[a[u]];for(var t in s)""!==t&&n(s,t,r+1)}function r(e,t,n,r){r in n||(n[r]=t)}}function te(e){if(!oe(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 ne(e){return"[object Object]"===Object.prototype.toString.call(e)}function re(e){return Array.isArray(e)}function ie(e){if(!oe(e)&&!function(e){return ne(e)&&0===Object.keys(e).length}(e)){var t=!1;if(re(e)){t=!0;for(var n=0;n<e.length;++n)if(!oe(e[n])){t=!1;break}}if(!t)throw new I('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 oe(e){return"string"==typeof e||"[object String]"===Object.prototype.toString.call(e)}function ae(e){return"number"==typeof e||"[object Number]"===Object.prototype.toString.call(e)}function se(e){return ae(e)&&-1!==String(e).indexOf(".")}function ue(e){return void 0===e}function ce(e){var t=!1;ne(e)&&!("@value"in e||"@set"in e||"@list"in e)&&(t=Object.keys(e).length>1||!("@id"in e));return t}function le(e){return ne(e)&&1===Object.keys(e).length&&"@id"in e}function fe(e){return ne(e)&&"@value"in e}function he(e){return ne(e)&&"@list"in e}function pe(e){var t=!1;return ne(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 de(e){return oe(e)&&-1!==e.indexOf(":")}function ye(e){if(e&&"object"==typeof e){var t;if(re(e)){t=[];for(var n=0;n<e.length;++n)t[n]=ye(e[n])}else if(ne(e))for(var r in t={},e)t[r]=ye(e[r]);else t=e.toString();return t}return e}function ve(t,n,r,i){var o=Object.keys(n).length;if(re(t)){for(var a=0;a<t.length;++a)ve(t[a],n,r,i);return o<Object.keys(n).length}if(ne(t)){for(var s in t)if("@context"===s){var u=t[s];if(re(u)){var c=u.length;for(a=0;a<c;++a){var l=u[a];oe(l)&&(l=e.prependBase(i,l),r?re(l=n[l])?(Array.prototype.splice.apply(u,[a,1].concat(l)),a+=l.length-1,c=u.length):u[a]=l:l in n||(n[l]=!1))}}else oe(u)&&(u=e.prependBase(i,u),r?t[s]=n[u]:u in n||(n[u]=!1))}else ve(t[s],n,r,i);return o<Object.keys(n).length}return!1}function ge(e,t,n){var r=null,i=t.documentLoader,o=function(e,t,n,i,a){if(Object.keys(t).length>N)return r=new I("Maximum number of @context URLs exceeded.","jsonld.ContextUrlError",{code:"loading remote context failed",max:N}),a(r);var s={},u=function(){ve(e,s,!0,i),a(null,e)};if(!ve(e,s,!1,i))return u();var c=[];for(var l in s)!1===s[l]&&c.push(l);for(var f=c.length,h=0;h<c.length;++h)!function(e){if(e in t)return r=new I("Cyclical @context URLs detected.","jsonld.ContextUrlError",{code:"recursive context inclusion",url:e}),a(r);var i=ye(t);i[e]=!0;var c=function(t,c){if(!r){var l=c?c.document:null;if(!t&&oe(l))try{l=JSON.parse(l)}catch(e){t=e}if(t?t=new I("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}):ne(l)||(t=new I("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 a(r=t);l="@context"in l?{"@context":l["@context"]}:{"@context":{}},c.contextUrl&&(re(l["@context"])||(l["@context"]=[l["@context"]]),l["@context"].push(c.contextUrl)),o(l,i,n,e,function(t,n){if(t)return a(t);s[e]=n["@context"],0===(f-=1)&&u()})}},l=n(e,c);l&&"then"in l&&l.then(c.bind(null,null),c)}(c[h])};o(e,{},i,t.base,n)}function me(e){for(var t=new RegExp("^[ \\t]*(?:#.*)?$"),n=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]*(?:#.*)?$'),r={},i=e.split(/(?:\r\n)|(?:\n)|(?:\r)/g),o=0,a=0;a<i.length;++a){var s=i[a];if(o++,!t.test(s)){var u=s.match(n);if(null===u)throw new I("Error while parsing N-Quads; invalid quad.","jsonld.ParseError",{line:o});var c={};if(ue(u[1])?c.subject={type:"blank node",value:u[2]}:c.subject={type:"IRI",value:u[1]},c.predicate={type:"IRI",value:u[3]},ue(u[4]))if(ue(u[5])){c.object={type:"literal"},ue(u[7])?ue(u[8])?c.object.datatype=m:(c.object.datatype=O,c.object.language=u[8]):c.object.datatype=u[7];var l=u[6].replace(/\\"/g,'"').replace(/\\t/g,"\t").replace(/\\n/g,"\n").replace(/\\r/g,"\r").replace(/\\\\/g,"\\");c.object.value=l}else c.object={type:"blank node",value:u[5]};else c.object={type:"IRI",value:u[4]};var f="@default";if(ue(u[9])?ue(u[10])||(f=u[10]):f=u[9],f in r){for(var h=!0,p=r[f],d=0;h&&d<p.length;++d)U(p[d],c)&&(h=!1);h&&p.push(c)}else r[f]=[c]}}return r}function we(e,t){var n=e.subject,r=e.predicate,i=e.object,o=t||null;"name"in e&&e.name&&(o=e.name.value);var a="";if("IRI"===n.type?a+="<"+n.value+">":a+=n.value,a+=" ","IRI"===r.type?a+="<"+r.value+">":a+=r.value,a+=" ","IRI"===i.type)a+="<"+i.value+">";else if("blank node"===i.type)a+=i.value;else{a+='"'+i.value.replace(/\\/g,"\\\\").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\"/g,'\\"')+'"',i.datatype===O?i.language&&(a+="@"+i.language):i.datatype!==m&&(a+="^^<"+i.datatype+">")}return null!=o&&(0!==o.indexOf("_:")?a+=" <"+o+">":a+=" "+o),a+=" .\n"}function be(e){this.prefix=e,this.counter=0,this.existing={}}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}),e.registerRDFParser("application/nquads",me),e.registerRDFParser("rdfa-api",function(e){for(var t={"@default":[]},n=e.getSubjects(),r=0;r<n.length;++r){var i=n[r];if(null!==i){var o=e.getSubjectTriples(i);if(null!==o){var a=o.predicates;for(var s in a)for(var u=a[s].objects,c=0;c<u.length;++c){var l=u[c],f={};0===i.indexOf("_:")?f.subject={type:"blank node",value:i}:f.subject={type:"IRI",value:i},0===s.indexOf("_:")?f.predicate={type:"blank node",value:s}:f.predicate={type:"IRI",value:s};var h=l.value;if(l.type===T){p||ke();var y=new p;h="";for(var v=0;v<l.value.length;v++)l.value[v].nodeType===d.ELEMENT_NODE?h+=y.serializeToString(l.value[v]):l.value[v].nodeType===d.TEXT_NODE&&(h+=l.value[v].nodeValue)}f.object={},l.type===E?0===l.value.indexOf("_:")?f.object.type="blank node":f.object.type="IRI":(f.object.type="literal",l.type===S?l.language?(f.object.datatype=O,f.object.language=l.language):f.object.datatype=m:f.object.datatype=l.type),f.object.value=h,t["@default"].push(f)}}}}return t}),e.IdentifierIssuer=be,e.UniqueNamer=be,be.prototype.clone=function(){var e=new be(this.prefix);return e.counter=this.counter,e.existing=ye(this.existing),e},be.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},be.prototype.getName=be.prototype.getName,be.prototype.hasId=function(e){return e in this.existing},be.prototype.isNamed=be.prototype.hasId;var xe=function(e){this.list=e.sort(),this.done=!1,this.left={};for(var t=0;t<e.length;++t)this.left[e[t]]=!0};xe.prototype.hasNext=function(){return!this.done},xe.prototype.next=function(){for(var e=this.list.slice(),t=null,n=0,r=this.list.length,i=0;i<r;++i){var o=this.list[i],a=this.left[o];(null===t||o>t)&&(a&&i>0&&o>this.list[i-1]||!a&&i<r-1&&o>this.list[i+1])&&(t=o,n=i)}if(null===t)this.done=!0;else{var s=this.left[t]?n-1:n+1;this.list[n]=this.list[s],this.list[s]=t;for(i=0;i<r;++i)this.list[i]>t&&(this.left[this.list[i]]=!this.left[this.list[i]])}return e};var _e=function(e){if(!(this instanceof _e))return new _e(e);if(-1===["URDNA2015","URGNA2012"].indexOf(e))throw new Error("Invalid RDF Dataset Normalization algorithm: "+e);_e._init.call(this,e)};if(_e.hashNQuads=function(e,t){for(var n=new _e(e),r=0;r<t.length;++r)n.update(t[r]);return n.digest()},function(e){if(e){var t=n(10);return _e._init=function(e){e="URDNA2015"===e?"sha256":"sha1",this.md=t.createHash(e)},_e.prototype.update=function(e){return this.md.update(e,"utf8")},void(_e.prototype.digest=function(){return this.md.digest("hex")})}_e._init=function(e){e="URDNA2015"===e?new o.Algorithm:new i.Algorithm,this.md=new r(e)},_e.prototype.update=function(e){return this.md.update(e)},_e.prototype.digest=function(){return this.md.digest().toHex()};var r=function(e){if(!(this instanceof r))return new r(e);if(this._algorithm=e,!r._padding||r._padding.length<this._algorithm.blockSize){r._padding=String.fromCharCode(128);for(var t=String.fromCharCode(0),n=64;n>0;)1&n&&(r._padding+=t),(n>>>=1)>0&&(t+=t)}this.start()};r.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 r.ByteBuffer,this.state=this._algorithm.start(),this},r.prototype.update=function(e){e=new r.ByteBuffer(unescape(encodeURIComponent(e))),this.messageLength+=e.length();var t=e.length();t=[t/4294967296>>>0,t>>>0];for(var n=this.fullMessageLength.length-1;n>=0;--n)this.fullMessageLength[n]+=t[1],t[1]=t[0]+(this.fullMessageLength[n]/4294967296>>>0),this.fullMessageLength[n]=this.fullMessageLength[n]>>>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},r.prototype.digest=function(){var e=new r.ByteBuffer;e.putBytes(this._input.bytes());var t=this.fullMessageLength[this.fullMessageLength.length-1]+this._algorithm.messageLengthSize&this._algorithm.blockSize-1;e.putBytes(r._padding.substr(0,this._algorithm.blockSize-t));for(var n=new r.ByteBuffer,i=0;i<this.fullMessageLength.length;++i)n.putInt32(this.fullMessageLength[i]<<3|this.fullMessageLength[i+1]>>>28);this._algorithm.writeMessageLength(e,n);var o=this._algorithm.digest(this.state.copy(),e),a=new r.ByteBuffer;return o.write(a),a},r.ByteBuffer=function(e){this.data="string"==typeof e?e:"",this.read=0},r.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)},r.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},r.ByteBuffer.prototype.putBytes=function(e){this.data+=e},r.ByteBuffer.prototype.bytes=function(){return this.data.slice(this.read)},r.ByteBuffer.prototype.length=function(){return this.data.length-this.read},r.ByteBuffer.prototype.compact=function(){this.data=this.data.slice(this.read),this.read=0},r.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 i={_w:null,Algorithm:function(){this.name="sha1",this.blockSize=64,this.digestLength=20,this.messageLengthSize=8}};i.Algorithm.prototype.start=function(){return i._w||(i._w=new Array(80)),i._createState()},i.Algorithm.prototype.writeMessageLength=function(e,t){e.putBytes(t.bytes())},i.Algorithm.prototype.digest=function(e,t){for(var n,r,o,a,s,u,c,l=t.length(),f=i._w;l>=64;){for(r=e.h0,o=e.h1,a=e.h2,s=e.h3,u=e.h4,c=0;c<16;++c)n=t.getInt32(),f[c]=n,n=(r<<5|r>>>27)+(s^o&(a^s))+u+1518500249+n,u=s,s=a,a=o<<30|o>>>2,o=r,r=n;for(;c<20;++c)n=(n=f[c-3]^f[c-8]^f[c-14]^f[c-16])<<1|n>>>31,f[c]=n,n=(r<<5|r>>>27)+(s^o&(a^s))+u+1518500249+n,u=s,s=a,a=o<<30|o>>>2,o=r,r=n;for(;c<32;++c)n=(n=f[c-3]^f[c-8]^f[c-14]^f[c-16])<<1|n>>>31,f[c]=n,n=(r<<5|r>>>27)+(o^a^s)+u+1859775393+n,u=s,s=a,a=o<<30|o>>>2,o=r,r=n;for(;c<40;++c)n=(n=f[c-6]^f[c-16]^f[c-28]^f[c-32])<<2|n>>>30,f[c]=n,n=(r<<5|r>>>27)+(o^a^s)+u+1859775393+n,u=s,s=a,a=o<<30|o>>>2,o=r,r=n;for(;c<60;++c)n=(n=f[c-6]^f[c-16]^f[c-28]^f[c-32])<<2|n>>>30,f[c]=n,n=(r<<5|r>>>27)+(o&a|s&(o^a))+u+2400959708+n,u=s,s=a,a=o<<30|o>>>2,o=r,r=n;for(;c<80;++c)n=(n=f[c-6]^f[c-16]^f[c-28]^f[c-32])<<2|n>>>30,f[c]=n,n=(r<<5|r>>>27)+(o^a^s)+u+3395469782+n,u=s,s=a,a=o<<30|o>>>2,o=r,r=n;e.h0=e.h0+r|0,e.h1=e.h1+o|0,e.h2=e.h2+a|0,e.h3=e.h3+s|0,e.h4=e.h4+u|0,l-=64}return e},i._createState=function(){var e={h0:1732584193,h1:4023233417,h2:2562383102,h3:271733878,h4:3285377520,copy:function(){var t=i._createState();return t.h0=e.h0,t.h1=e.h1,t.h2=e.h2,t.h3=e.h3,t.h4=e.h4,t},write:function(t){t.putInt32(e.h0),t.putInt32(e.h1),t.putInt32(e.h2),t.putInt32(e.h3),t.putInt32(e.h4)}};return e};var o={_k:null,_w:null,Algorithm:function(){this.name="sha256",this.blockSize=64,this.digestLength=32,this.messageLengthSize=8}};o.Algorithm.prototype.start=function(){return o._k||o._init(),o._createState()},o.Algorithm.prototype.writeMessageLength=function(e,t){e.putBytes(t.bytes())},o.Algorithm.prototype.digest=function(e,t){for(var n,r,i,a,s,u,c,l,f,h,p,d,y,v=t.length(),g=o._k,m=o._w;v>=64;){for(s=0;s<16;++s)m[s]=t.getInt32();for(;s<64;++s)n=((n=m[s-2])>>>17|n<<15)^(n>>>19|n<<13)^n>>>10,r=((r=m[s-15])>>>7|r<<25)^(r>>>18|r<<14)^r>>>3,m[s]=n+m[s-7]+r+m[s-16]|0;for(u=e.h0,c=e.h1,l=e.h2,f=e.h3,h=e.h4,p=e.h5,d=e.h6,y=e.h7,s=0;s<64;++s)i=(u>>>2|u<<30)^(u>>>13|u<<19)^(u>>>22|u<<10),a=u&c|l&(u^c),n=y+((h>>>6|h<<26)^(h>>>11|h<<21)^(h>>>25|h<<7))+(d^h&(p^d))+g[s]+m[s],y=d,d=p,p=h,h=f+n|0,f=l,l=c,c=u,u=n+(r=i+a)|0;e.h0=e.h0+u|0,e.h1=e.h1+c|0,e.h2=e.h2+l|0,e.h3=e.h3+f|0,e.h4=e.h4+h|0,e.h5=e.h5+p|0,e.h6=e.h6+d|0,e.h7=e.h7+y|0,v-=64}return e},o._createState=function(){var e={h0:1779033703,h1:3144134277,h2:1013904242,h3:2773480762,h4:1359893119,h5:2600822924,h6:528734635,h7:1541459225,copy:function(){var t=o._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},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)}};return e},o._init=function(){o._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],o._w=new Array(64)}}(u),!p)var ke=function(){p=n(10).XMLSerializer};function Se(e,t){var n="";0===e.indexOf("/")&&(n="/");for(var r=e.split("/"),i=[];r.length>0;)"."===r[0]||""===r[0]&&r.length>1?r.shift():".."!==r[0]?i.push(r.shift()):(r.shift(),t||i.length>0&&".."!==i[i.length-1]?i.pop():i.push(".."));return n+i.join("/")}if(e.url={},e.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*))?))?(?:(((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/}},e.url.parse=function(t,n){for(var r={},i=e.url.parsers[n||"full"],o=i.regex.exec(t),a=i.keys.length;a--;)r[i.keys[a]]=void 0===o[a]?null:o[a];return r.normalizedPath=Se(r.path,!!r.authority),r},u?e.useDocumentLoader("node"):"undefined"!=typeof XMLHttpRequest&&e.useDocumentLoader("xhr"),u){e.use=function(t){switch(t){case"request":e.request=n(10);break;default:throw new I("Unknown extension.","jsonld.UnknownExtension",{extension:t})}};var Te={exports:{},filename:a};n(10)(Te,"version"),e.version=Te.exports.version}return e},f=function(){return l(function(){return f()})};!u&&n(68)?void 0===(s=function(){return l(f),f}.apply(t,[]))||(e.exports=s):(l(f),e.exports&&(e.exports=f),c&&("undefined"==typeof jsonld?jsonld=jsonldjs=f:jsonldjs=f))}()}).call(this,n(7),n(8),n(17).setImmediate,"/")},function(e,t,n){(function(r,i,o){var a;
  /*!
   * @overview es6-promise - a tiny implementation of Promises/A+.
   * @copyright Copyright (c) 2014 Yehuda Katz, Tom Dale, Stefan Penner and contributors (Conversion to ES6 API by Jake Archibald)
   * @license   Licensed under MIT license
   *            See https://raw.githubusercontent.com/jakearchibald/es6-promise/master/LICENSE
   * @version   2.3.0
   */
  (function(){"use strict";function s(e){return"function"==typeof e}var u,c,l=Array.isArray?Array.isArray:function(e){return"[object Array]"===Object.prototype.toString.call(e)},f=0,h=function(e,t){E[f]=e,E[f+1]=t,2===(f+=2)&&(c?c(O):w())};var p="undefined"!=typeof window?window:void 0,d=p||{},y=d.MutationObserver||d.WebKitMutationObserver,v=void 0!==r&&"[object process]"==={}.toString.call(r),g="undefined"!=typeof Uint8ClampedArray&&"undefined"!=typeof importScripts&&"undefined"!=typeof MessageChannel;function m(){return function(){setTimeout(O,1)}}var w,b,x,_,k,S,T,E=new Array(1e3);function O(){for(var e=0;e<f;e+=2){(0,E[e])(E[e+1]),E[e]=void 0,E[e+1]=void 0}f=0}function j(){}v?(S=r.nextTick,T=r.versions.node.match(/^(?:(\d+)\.)?(?:(\d+)\.)?(\*|\d+)$/),Array.isArray(T)&&"0"===T[1]&&"10"===T[2]&&(S=i),w=function(){S(O)}):y?(x=0,_=new y(O),k=document.createTextNode(""),_.observe(k,{characterData:!0}),w=function(){k.data=x=++x%2}):g?((b=new MessageChannel).port1.onmessage=O,w=function(){b.port2.postMessage(0)}):w=void 0===p?function(){try{var e=n(67);return u=e.runOnLoop||e.runOnContext,function(){u(O)}}catch(e){return m()}}():m();var N=void 0,I=1,R=2,A=new B;function C(e,t){if(t.constructor===e.constructor)!function(e,t){t._state===I?D(e,t._result):t._state===R?U(e,t._result):M(t,void 0,function(t){P(e,t)},function(t){U(e,t)})}(e,t);else{var n=function(e){try{return e.then}catch(e){return A.error=e,A}}(t);n===A?U(e,A.error):void 0===n?D(e,t):s(n)?function(e,t,n){h(function(e){var r=!1,i=function(e,t,n,r){try{e.call(t,n,r)}catch(e){return e}}(n,t,function(n){r||(r=!0,t!==n?P(e,n):D(e,n))},function(t){r||(r=!0,U(e,t))},e._label);!r&&i&&(r=!0,U(e,i))},e)}(e,t,n):D(e,t)}}function P(e,t){var n;e===t?U(e,new TypeError("You cannot resolve a promise with itself")):"function"==typeof(n=t)||"object"==typeof n&&null!==n?C(e,t):D(e,t)}function L(e){e._onerror&&e._onerror(e._result),F(e)}function D(e,t){e._state===N&&(e._result=t,e._state=I,0!==e._subscribers.length&&h(F,e))}function U(e,t){e._state===N&&(e._state=R,e._result=t,h(L,e))}function M(e,t,n,r){var i=e._subscribers,o=i.length;e._onerror=null,i[o]=t,i[o+I]=n,i[o+R]=r,0===o&&e._state&&h(F,e)}function F(e){var t=e._subscribers,n=e._state;if(0!==t.length){for(var r,i,o=e._result,a=0;a<t.length;a+=3)r=t[a],i=t[a+n],r?z(n,r,i,o):i(o);e._subscribers.length=0}}function B(){this.error=null}var q=new B;function z(e,t,n,r){var i,o,a,u,c=s(n);if(c){if((i=function(e,t){try{return e(t)}catch(e){return q.error=e,q}}(n,r))===q?(u=!0,o=i.error,i=null):a=!0,t===i)return void U(t,new TypeError("A promises callback cannot return that same promise."))}else i=r,a=!0;t._state!==N||(c&&a?P(t,i):u?U(t,o):e===I?D(t,i):e===R&&U(t,i))}function H(e,t){this._instanceConstructor=e,this.promise=new e(j),this._validateInput(t)?(this._input=t,this.length=t.length,this._remaining=t.length,this._init(),0===this.length?D(this.promise,this._result):(this.length=this.length||0,this._enumerate(),0===this._remaining&&D(this.promise,this._result))):U(this.promise,this._validationError())}H.prototype._validateInput=function(e){return l(e)},H.prototype._validationError=function(){return new Error("Array Methods must be provided an Array")},H.prototype._init=function(){this._result=new Array(this.length)};var V=H;H.prototype._enumerate=function(){for(var e=this.length,t=this.promise,n=this._input,r=0;t._state===N&&r<e;r++)this._eachEntry(n[r],r)},H.prototype._eachEntry=function(e,t){var n,r=this._instanceConstructor;"object"==typeof(n=e)&&null!==n?e.constructor===r&&e._state!==N?(e._onerror=null,this._settledAt(e._state,t,e._result)):this._willSettleAt(r.resolve(e),t):(this._remaining--,this._result[t]=e)},H.prototype._settledAt=function(e,t,n){var r=this.promise;r._state===N&&(this._remaining--,e===R?U(r,n):this._result[t]=n),0===this._remaining&&D(r,this._result)},H.prototype._willSettleAt=function(e,t){var n=this;M(e,void 0,function(e){n._settledAt(I,t,e)},function(e){n._settledAt(R,t,e)})};var J=function(e){return new V(this,e).promise};var W=function(e){var t=new this(j);if(!l(e))return U(t,new TypeError("You must pass an array to race.")),t;var n=e.length;function r(e){P(t,e)}function i(e){U(t,e)}for(var o=0;t._state===N&&o<n;o++)M(this.resolve(e[o]),void 0,r,i);return t};var X=function(e){if(e&&"object"==typeof e&&e.constructor===this)return e;var t=new this(j);return P(t,e),t};var Y=function(e){var t=new this(j);return U(t,e),t},$=0;var K=G;function G(e){this._id=$++,this._state=void 0,this._result=void 0,this._subscribers=[],j!==e&&(s(e)||function(){throw new TypeError("You must pass a resolver function as the first argument to the promise constructor")}(),this instanceof G||function(){throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function.")}(),function(e,t){try{t(function(t){P(e,t)},function(t){U(e,t)})}catch(t){U(e,t)}}(this,e))}G.all=J,G.race=W,G.resolve=X,G.reject=Y,G._setScheduler=function(e){c=e},G._setAsap=function(e){h=e},G._asap=h,G.prototype={constructor:G,then:function(e,t){var n=this._state;if(n===I&&!e||n===R&&!t)return this;var r=new this.constructor(j),i=this._result;if(n){var o=arguments[n-1];h(function(){z(n,r,o,i)})}else M(this,r,e,t);return r},catch:function(e){return this.then(null,e)}};var Q=function(){var e;if(void 0!==o)e=o;else if("undefined"!=typeof self)e=self;else try{e=Function("return this")()}catch(e){throw new Error("polyfill failed because global object is unavailable in this environment")}var t=e.Promise;t&&"[object Promise]"===Object.prototype.toString.call(t.resolve())&&!t.cast||(e.Promise=K)},Z={Promise:K,polyfill:Q};void 0===(a=function(){return Z}.call(t,n,t,e))||(e.exports=a),Q()}).call(this)}).call(this,n(7),n(17).setImmediate,n(8))},function(e,t,n){var r;r=function(){};t=e.exports={Lexer:r("./lib/N3Lexer"),Parser:r("./lib/N3Parser"),Writer:r("./lib/N3Writer"),Store:r("./lib/N3Store"),StreamParser:r("./lib/N3StreamParser"),StreamWriter:r("./lib/N3StreamWriter"),Util:r("./lib/N3Util")};Object.keys(t).forEach(function(e){Object.defineProperty(t,e,{configurable:!0,enumerable:!0,get:function(){return delete t[e],t[e]=n(69)("./N3"+e)}})})},function(e,t,n){var r=n(31).expandPrefixedName;function i(e,t){if(!(this instanceof i))return new i(e,t);this._size=0,this._graphs=Object.create(null),this._entities=Object.create(null),this._entities["><"]=0,this._entityCount=0,this._blankNodeIndex=0,t||!e||e[0]||(t=e,e=null),this._prefixes=Object.create(null),t&&t.prefixes&&this.addPrefixes(t.prefixes),e&&this.addTriples(e)}i.prototype={get size(){var e=this._size;if(null!==e)return e;var t,n,r=this._graphs;for(var i in r)for(var o in t=r[i].subjects)for(var a in n=t[o])e+=Object.keys(n[a]).length;return this._size=e},_addToIndex:function(e,t,n,r){var i=e[t]||(e[t]={});(i[n]||(i[n]={}))[r]=null},_removeFromIndex:function(e,t,n,r){var i,o=e[t],a=o[n];for(i in delete a[r],a)return;for(i in delete o[n],o)return;delete e[t]},_findInIndex:function(e,t,n,r,i,o,a,s){var u,c,l,f=[],h=Object.keys(this._entities);for(var p in t&&((u=e,e={})[t]=u[t]),e){var d=h[p];if(c=e[p])for(var y in n&&((u=c,c={})[n]=u[n]),c){var v=h[y];if(l=c[y])for(var g=(r?r in l?[r]:[]:Object.keys(l)),m=g.length-1;m>=0;m--){var w={subject:"",predicate:"",object:"",graph:s};w[i]=d,w[o]=v,w[a]=h[g[m]],f.push(w)}}}return f},_countInIndex:function(e,t,n,r){var i,o,a,s=0;for(var u in t&&((i=e,e={})[t]=i[t]),e)if(o=e[u])for(var c in n&&((i=o,o={})[n]=i[n]),o)(a=o[c])&&(r?r in a&&s++:s+=Object.keys(a).length);return s},addTriple:function(e,t,n,r){t||(r=e.graph,n=e.object,t=e.predicate,e=e.subject),r=r||"";var i=this._graphs[r];i||(i=this._graphs[r]={subjects:{},predicates:{},objects:{}},Object.freeze(i));var o=this._entities;e=o[e]||(o[e]=++this._entityCount),t=o[t]||(o[t]=++this._entityCount),n=o[n]||(o[n]=++this._entityCount),this._addToIndex(i.subjects,e,t,n),this._addToIndex(i.predicates,t,n,e),this._addToIndex(i.objects,n,e,t),this._size=null},addTriples:function(e){for(var t=e.length-1;t>=0;t--)this.addTriple(e[t])},addPrefix:function(e,t){this._prefixes[e]=t},addPrefixes:function(e){for(var t in e)this.addPrefix(t,e[t])},removeTriple:function(e,t,n,r){t||(r=e.graph,n=e.object,t=e.predicate,e=e.subject),r=r||"";var i,o,a,s=this._entities,u=this._graphs;if((e=s[e])&&((t=s[t])&&(n=s[n])&&(i=u[r])&&(o=i.subjects[e])&&(a=o[t])&&n in a)){for(e in this._removeFromIndex(i.subjects,e,t,n),this._removeFromIndex(i.predicates,t,n,e),this._removeFromIndex(i.objects,n,e,t),null!==this._size&&this._size--,i.subjects)return;delete u[r]}},removeTriples:function(e){for(var t=e.length-1;t>=0;t--)this.removeTriple(e[t])},find:function(e,t,n,i){var o=this._prefixes;return this.findByIRI(r(e,o),r(t,o),r(n,o),r(i,o))},findByIRI:function(e,t,n,r){r=r||"";var i=this._graphs[r],o=this._entities;return i?e&&!(e=o[e])?[]:t&&!(t=o[t])?[]:n&&!(n=o[n])?[]:e?n?this._findInIndex(i.objects,n,e,t,"object","subject","predicate",r):this._findInIndex(i.subjects,e,t,null,"subject","predicate","object",r):t?this._findInIndex(i.predicates,t,n,null,"predicate","object","subject",r):n?this._findInIndex(i.objects,n,null,null,"object","subject","predicate",r):this._findInIndex(i.subjects,null,null,null,"subject","predicate","object",r):[]},count:function(e,t,n,i){var o=this._prefixes;return this.countByIRI(r(e,o),r(t,o),r(n,o),r(i,o))},countByIRI:function(e,t,n,r){r=r||"";var i=this._graphs[r],o=this._entities;return i?e&&!(e=o[e])?0:t&&!(t=o[t])?0:n&&!(n=o[n])?0:e?n?this._countInIndex(i.objects,n,e,t):this._countInIndex(i.subjects,e,t,n):t?this._countInIndex(i.predicates,t,n,e):this._countInIndex(i.objects,n,e,t):0},createBlankNode:function(e){var t,n;if(e)for(t=e="_:"+e,n=1;this._entities[t];)t=e+n++;else do{t="_:b"+this._blankNodeIndex++}while(this._entities[t]);return this._entities[t]=++this._entityCount,t}},e.exports=i},function(e,t,n){var r=n(48).Transform,i=n(56),o=n(30);function a(e){if(!(this instanceof a))return new a(e);r.call(this,{decodeStrings:!0}),this._readableState.objectMode=!0;var t=this,n=new o(e);n.parse(function(e,n){n&&t.push(n)||e&&t.emit("error",e)},this.emit.bind(this,"prefix")),this._transform=function(e,t,r){n.addChunk(e),r()},this._flush=function(e){n.end(),e()}}i.inherits(a,r),e.exports=a},function(e,t,n){e.exports=i;var r=n(32).EventEmitter;function i(){r.call(this)}n(11)(i,r),i.Readable=n(33),i.Writable=n(77),i.Duplex=n(78),i.Transform=n(79),i.PassThrough=n(80),i.Stream=i,i.prototype.pipe=function(e,t){var n=this;function i(t){e.writable&&!1===e.write(t)&&n.pause&&n.pause()}function o(){n.readable&&n.resume&&n.resume()}n.on("data",i),e.on("drain",o),e._isStdio||t&&!1===t.end||(n.on("end",s),n.on("close",u));var a=!1;function s(){a||(a=!0,e.end())}function u(){a||(a=!0,"function"==typeof e.destroy&&e.destroy())}function c(e){if(l(),0===r.listenerCount(this,"error"))throw e}function l(){n.removeListener("data",i),e.removeListener("drain",o),n.removeListener("end",s),n.removeListener("close",u),n.removeListener("error",c),e.removeListener("error",c),n.removeListener("end",l),n.removeListener("close",l),e.removeListener("close",l)}return n.on("error",c),e.on("error",c),n.on("end",l),n.on("close",l),e.on("close",l),e.emit("pipe",n),e}},function(e,t,n){"use strict";(function(t,r){var i=n(22);e.exports=w;var o,a=n(50);w.ReadableState=m;n(32).EventEmitter;var s=function(e,t){return e.listeners(t).length},u=n(51),c=n(23).Buffer,l=t.Uint8Array||function(){};var f=n(18);f.inherits=n(11);var h=n(72),p=void 0;p=h&&h.debuglog?h.debuglog("stream"):function(){};var d,y=n(73),v=n(53);f.inherits(w,u);var g=["error","close","destroy","pause","resume"];function m(e,t){e=e||{};var r=t instanceof(o=o||n(12));this.objectMode=!!e.objectMode,r&&(this.objectMode=this.objectMode||!!e.readableObjectMode);var i=e.highWaterMark,a=e.readableHighWaterMark,s=this.objectMode?16:16384;this.highWaterMark=i||0===i?i:r&&(a||0===a)?a:s,this.highWaterMark=Math.floor(this.highWaterMark),this.buffer=new y,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.destroyed=!1,this.defaultEncoding=e.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,e.encoding&&(d||(d=n(54).StringDecoder),this.decoder=new d(e.encoding),this.encoding=e.encoding)}function w(e){if(o=o||n(12),!(this instanceof w))return new w(e);this._readableState=new m(e,this),this.readable=!0,e&&("function"==typeof e.read&&(this._read=e.read),"function"==typeof e.destroy&&(this._destroy=e.destroy)),u.call(this)}function b(e,t,n,r,i){var o,a=e._readableState;null===t?(a.reading=!1,function(e,t){if(t.ended)return;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,S(e)}(e,a)):(i||(o=function(e,t){var n;r=t,c.isBuffer(r)||r instanceof l||"string"==typeof t||void 0===t||e.objectMode||(n=new TypeError("Invalid non-string/buffer chunk"));var r;return n}(a,t)),o?e.emit("error",o):a.objectMode||t&&t.length>0?("string"==typeof t||a.objectMode||Object.getPrototypeOf(t)===c.prototype||(t=function(e){return c.from(e)}(t)),r?a.endEmitted?e.emit("error",new Error("stream.unshift() after end event")):x(e,a,t,!0):a.ended?e.emit("error",new Error("stream.push() after EOF")):(a.reading=!1,a.decoder&&!n?(t=a.decoder.write(t),a.objectMode||0!==t.length?x(e,a,t,!1):E(e,a)):x(e,a,t,!1))):r||(a.reading=!1));return function(e){return!e.ended&&(e.needReadable||e.length<e.highWaterMark||0===e.length)}(a)}function x(e,t,n,r){t.flowing&&0===t.length&&!t.sync?(e.emit("data",n),e.read(0)):(t.length+=t.objectMode?1:n.length,r?t.buffer.unshift(n):t.buffer.push(n),t.needReadable&&S(e)),E(e,t)}Object.defineProperty(w.prototype,"destroyed",{get:function(){return void 0!==this._readableState&&this._readableState.destroyed},set:function(e){this._readableState&&(this._readableState.destroyed=e)}}),w.prototype.destroy=v.destroy,w.prototype._undestroy=v.undestroy,w.prototype._destroy=function(e,t){this.push(null),t(e)},w.prototype.push=function(e,t){var n,r=this._readableState;return r.objectMode?n=!0:"string"==typeof e&&((t=t||r.defaultEncoding)!==r.encoding&&(e=c.from(e,t),t=""),n=!0),b(this,e,t,!1,n)},w.prototype.unshift=function(e){return b(this,e,null,!0,!1)},w.prototype.isPaused=function(){return!1===this._readableState.flowing},w.prototype.setEncoding=function(e){return d||(d=n(54).StringDecoder),this._readableState.decoder=new d(e),this._readableState.encoding=e,this};var _=8388608;function k(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=function(e){return e>=_?e=_:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}function S(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(p("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?i.nextTick(T,e):T(e))}function T(e){p("emit readable"),e.emit("readable"),I(e)}function E(e,t){t.readingMore||(t.readingMore=!0,i.nextTick(O,e,t))}function O(e,t){for(var n=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length<t.highWaterMark&&(p("maybeReadMore read 0"),e.read(0),n!==t.length);)n=t.length;t.readingMore=!1}function j(e){p("readable nexttick read 0"),e.read(0)}function N(e,t){t.reading||(p("resume read 0"),e.read(0)),t.resumeScheduled=!1,t.awaitDrain=0,e.emit("resume"),I(e),t.flowing&&!t.reading&&e.read(0)}function I(e){var t=e._readableState;for(p("flow",t.flowing);t.flowing&&null!==e.read(););}function R(e,t){return 0===t.length?null:(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=function(e,t,n){var r;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?function(e,t){var n=t.head,r=1,i=n.data;e-=i.length;for(;n=n.next;){var o=n.data,a=e>o.length?o.length:e;if(a===o.length?i+=o:i+=o.slice(0,e),0===(e-=a)){a===o.length?(++r,n.next?t.head=n.next:t.head=t.tail=null):(t.head=n,n.data=o.slice(a));break}++r}return t.length-=r,i}(e,t):function(e,t){var n=c.allocUnsafe(e),r=t.head,i=1;r.data.copy(n),e-=r.data.length;for(;r=r.next;){var o=r.data,a=e>o.length?o.length:e;if(o.copy(n,n.length-e,0,a),0===(e-=a)){a===o.length?(++i,r.next?t.head=r.next:t.head=t.tail=null):(t.head=r,r.data=o.slice(a));break}++i}return t.length-=i,n}(e,t);return r}(e,t.buffer,t.decoder),n);var n}function A(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,i.nextTick(C,t,e))}function C(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function P(e,t){for(var n=0,r=e.length;n<r;n++)if(e[n]===t)return n;return-1}w.prototype.read=function(e){p("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 p("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?A(this):S(this),null;if(0===(e=k(e,t))&&t.ended)return 0===t.length&&A(this),null;var r,i=t.needReadable;return p("need readable",i),(0===t.length||t.length-e<t.highWaterMark)&&p("length less than watermark",i=!0),t.ended||t.reading?p("reading or ended",i=!1):i&&(p("do read"),t.reading=!0,t.sync=!0,0===t.length&&(t.needReadable=!0),this._read(t.highWaterMark),t.sync=!1,t.reading||(e=k(n,t))),null===(r=e>0?R(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),n!==e&&t.ended&&A(this)),null!==r&&this.emit("data",r),r},w.prototype._read=function(e){this.emit("error",new Error("_read() is not implemented"))},w.prototype.pipe=function(e,t){var n=this,o=this._readableState;switch(o.pipesCount){case 0:o.pipes=e;break;case 1:o.pipes=[o.pipes,e];break;default:o.pipes.push(e)}o.pipesCount+=1,p("pipe count=%d opts=%j",o.pipesCount,t);var u=(!t||!1!==t.end)&&e!==r.stdout&&e!==r.stderr?l:w;function c(t,r){p("onunpipe"),t===n&&r&&!1===r.hasUnpiped&&(r.hasUnpiped=!0,p("cleanup"),e.removeListener("close",g),e.removeListener("finish",m),e.removeListener("drain",f),e.removeListener("error",v),e.removeListener("unpipe",c),n.removeListener("end",l),n.removeListener("end",w),n.removeListener("data",y),h=!0,!o.awaitDrain||e._writableState&&!e._writableState.needDrain||f())}function l(){p("onend"),e.end()}o.endEmitted?i.nextTick(u):n.once("end",u),e.on("unpipe",c);var f=function(e){return function(){var t=e._readableState;p("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&s(e,"data")&&(t.flowing=!0,I(e))}}(n);e.on("drain",f);var h=!1;var d=!1;function y(t){p("ondata"),d=!1,!1!==e.write(t)||d||((1===o.pipesCount&&o.pipes===e||o.pipesCount>1&&-1!==P(o.pipes,e))&&!h&&(p("false write response, pause",n._readableState.awaitDrain),n._readableState.awaitDrain++,d=!0),n.pause())}function v(t){p("onerror",t),w(),e.removeListener("error",v),0===s(e,"error")&&e.emit("error",t)}function g(){e.removeListener("finish",m),w()}function m(){p("onfinish"),e.removeListener("close",g),w()}function w(){p("unpipe"),n.unpipe(e)}return n.on("data",y),function(e,t,n){if("function"==typeof e.prependListener)return e.prependListener(t,n);e._events&&e._events[t]?a(e._events[t])?e._events[t].unshift(n):e._events[t]=[n,e._events[t]]:e.on(t,n)}(e,"error",v),e.once("close",g),e.once("finish",m),e.emit("pipe",n),o.flowing||(p("pipe resume"),n.resume()),e},w.prototype.unpipe=function(e){var t=this._readableState,n={hasUnpiped:!1};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,n),this);if(!e){var r=t.pipes,i=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var o=0;o<i;o++)r[o].emit("unpipe",this,n);return this}var a=P(t.pipes,e);return-1===a?this:(t.pipes.splice(a,1),t.pipesCount-=1,1===t.pipesCount&&(t.pipes=t.pipes[0]),e.emit("unpipe",this,n),this)},w.prototype.on=function(e,t){var n=u.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&&S(this):i.nextTick(j,this))}return n},w.prototype.addListener=w.prototype.on,w.prototype.resume=function(){var e=this._readableState;return e.flowing||(p("resume"),e.flowing=!0,function(e,t){t.resumeScheduled||(t.resumeScheduled=!0,i.nextTick(N,e,t))}(this,e)),this},w.prototype.pause=function(){return p("call pause flowing=%j",this._readableState.flowing),!1!==this._readableState.flowing&&(p("pause"),this._readableState.flowing=!1,this.emit("pause")),this},w.prototype.wrap=function(e){var t=this,n=this._readableState,r=!1;for(var i in e.on("end",function(){if(p("wrapped end"),n.decoder&&!n.ended){var e=n.decoder.end();e&&e.length&&t.push(e)}t.push(null)}),e.on("data",function(i){(p("wrapped data"),n.decoder&&(i=n.decoder.write(i)),n.objectMode&&null==i)||(n.objectMode||i&&i.length)&&(t.push(i)||(r=!0,e.pause()))}),e)void 0===this[i]&&"function"==typeof e[i]&&(this[i]=function(t){return function(){return e[t].apply(e,arguments)}}(i));for(var o=0;o<g.length;o++)e.on(g[o],this.emit.bind(this,g[o]));return this._read=function(t){p("wrapped _read",t),r&&(r=!1,e.resume())},this},Object.defineProperty(w.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}}),w._fromList=R}).call(this,n(8),n(7))},function(e,t){var n={}.toString;e.exports=Array.isArray||function(e){return"[object Array]"==n.call(e)}},function(e,t,n){e.exports=n(32).EventEmitter},function(e,t,n){"use strict";(function(e){
  /*!
   * The buffer module from node.js, for the browser.
   *
   * @author   Feross Aboukhadijeh <feross@feross.org> <http://feross.org>
   * @license  MIT
   */
  var r=n(70),i=n(71),o=n(50);function a(){return u.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function s(e,t){if(a()<t)throw new RangeError("Invalid typed array length");return u.TYPED_ARRAY_SUPPORT?(e=new Uint8Array(t)).__proto__=u.prototype:(null===e&&(e=new u(t)),e.length=t),e}function u(e,t,n){if(!(u.TYPED_ARRAY_SUPPORT||this instanceof u))return new u(e,t,n);if("number"==typeof e){if("string"==typeof t)throw new Error("If encoding is specified then the first argument must be a string");return f(this,e)}return c(this,e,t,n)}function c(e,t,n,r){if("number"==typeof t)throw new TypeError('"value" argument must not be a number');return"undefined"!=typeof ArrayBuffer&&t instanceof ArrayBuffer?function(e,t,n,r){if(t.byteLength,n<0||t.byteLength<n)throw new RangeError("'offset' is out of bounds");if(t.byteLength<n+(r||0))throw new RangeError("'length' is out of bounds");t=void 0===n&&void 0===r?new Uint8Array(t):void 0===r?new Uint8Array(t,n):new Uint8Array(t,n,r);u.TYPED_ARRAY_SUPPORT?(e=t).__proto__=u.prototype:e=h(e,t);return e}(e,t,n,r):"string"==typeof t?function(e,t,n){"string"==typeof n&&""!==n||(n="utf8");if(!u.isEncoding(n))throw new TypeError('"encoding" must be a valid string encoding');var r=0|d(t,n),i=(e=s(e,r)).write(t,n);i!==r&&(e=e.slice(0,i));return e}(e,t,n):function(e,t){if(u.isBuffer(t)){var n=0|p(t.length);return 0===(e=s(e,n)).length?e:(t.copy(e,0,0,n),e)}if(t){if("undefined"!=typeof ArrayBuffer&&t.buffer instanceof ArrayBuffer||"length"in t)return"number"!=typeof t.length||(r=t.length)!=r?s(e,0):h(e,t);if("Buffer"===t.type&&o(t.data))return h(e,t.data)}var r;throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}(e,t)}function l(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 f(e,t){if(l(t),e=s(e,t<0?0:0|p(t)),!u.TYPED_ARRAY_SUPPORT)for(var n=0;n<t;++n)e[n]=0;return e}function h(e,t){var n=t.length<0?0:0|p(t.length);e=s(e,n);for(var r=0;r<n;r+=1)e[r]=255&t[r];return e}function p(e){if(e>=a())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+a().toString(16)+" bytes");return 0|e}function d(e,t){if(u.isBuffer(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var n=e.length;if(0===n)return 0;for(var r=!1;;)switch(t){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":case void 0:return B(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return q(e).length;default:if(r)return B(e).length;t=(""+t).toLowerCase(),r=!0}}function y(e,t,n){var r=e[t];e[t]=e[n],e[n]=r}function v(e,t,n,r,i){if(0===e.length)return-1;if("string"==typeof n?(r=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),n=+n,isNaN(n)&&(n=i?0:e.length-1),n<0&&(n=e.length+n),n>=e.length){if(i)return-1;n=e.length-1}else if(n<0){if(!i)return-1;n=0}if("string"==typeof t&&(t=u.from(t,r)),u.isBuffer(t))return 0===t.length?-1:g(e,t,n,r,i);if("number"==typeof t)return t&=255,u.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,n):Uint8Array.prototype.lastIndexOf.call(e,t,n):g(e,[t],n,r,i);throw new TypeError("val must be string, number or Buffer")}function g(e,t,n,r,i){var o,a=1,s=e.length,u=t.length;if(void 0!==r&&("ucs2"===(r=String(r).toLowerCase())||"ucs-2"===r||"utf16le"===r||"utf-16le"===r)){if(e.length<2||t.length<2)return-1;a=2,s/=2,u/=2,n/=2}function c(e,t){return 1===a?e[t]:e.readUInt16BE(t*a)}if(i){var l=-1;for(o=n;o<s;o++)if(c(e,o)===c(t,-1===l?0:o-l)){if(-1===l&&(l=o),o-l+1===u)return l*a}else-1!==l&&(o-=o-l),l=-1}else for(n+u>s&&(n=s-u),o=n;o>=0;o--){for(var f=!0,h=0;h<u;h++)if(c(e,o+h)!==c(t,h)){f=!1;break}if(f)return o}return-1}function m(e,t,n,r){n=Number(n)||0;var i=e.length-n;r?(r=Number(r))>i&&(r=i):r=i;var o=t.length;if(o%2!=0)throw new TypeError("Invalid hex string");r>o/2&&(r=o/2);for(var a=0;a<r;++a){var s=parseInt(t.substr(2*a,2),16);if(isNaN(s))return a;e[n+a]=s}return a}function w(e,t,n,r){return z(B(t,e.length-n),e,n,r)}function b(e,t,n,r){return z(function(e){for(var t=[],n=0;n<e.length;++n)t.push(255&e.charCodeAt(n));return t}(t),e,n,r)}function x(e,t,n,r){return b(e,t,n,r)}function _(e,t,n,r){return z(q(t),e,n,r)}function k(e,t,n,r){return z(function(e,t){for(var n,r,i,o=[],a=0;a<e.length&&!((t-=2)<0);++a)n=e.charCodeAt(a),r=n>>8,i=n%256,o.push(i),o.push(r);return o}(t,e.length-n),e,n,r)}function S(e,t,n){return 0===t&&n===e.length?r.fromByteArray(e):r.fromByteArray(e.slice(t,n))}function T(e,t,n){n=Math.min(e.length,n);for(var r=[],i=t;i<n;){var o,a,s,u,c=e[i],l=null,f=c>239?4:c>223?3:c>191?2:1;if(i+f<=n)switch(f){case 1:c<128&&(l=c);break;case 2:128==(192&(o=e[i+1]))&&(u=(31&c)<<6|63&o)>127&&(l=u);break;case 3:o=e[i+1],a=e[i+2],128==(192&o)&&128==(192&a)&&(u=(15&c)<<12|(63&o)<<6|63&a)>2047&&(u<55296||u>57343)&&(l=u);break;case 4:o=e[i+1],a=e[i+2],s=e[i+3],128==(192&o)&&128==(192&a)&&128==(192&s)&&(u=(15&c)<<18|(63&o)<<12|(63&a)<<6|63&s)>65535&&u<1114112&&(l=u)}null===l?(l=65533,f=1):l>65535&&(l-=65536,r.push(l>>>10&1023|55296),l=56320|1023&l),r.push(l),i+=f}return function(e){var t=e.length;if(t<=E)return String.fromCharCode.apply(String,e);var n="",r=0;for(;r<t;)n+=String.fromCharCode.apply(String,e.slice(r,r+=E));return n}(r)}t.Buffer=u,t.SlowBuffer=function(e){+e!=e&&(e=0);return u.alloc(+e)},t.INSPECT_MAX_BYTES=50,u.TYPED_ARRAY_SUPPORT=void 0!==e.TYPED_ARRAY_SUPPORT?e.TYPED_ARRAY_SUPPORT:function(){try{var e=new Uint8Array(1);return e.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===e.foo()&&"function"==typeof e.subarray&&0===e.subarray(1,1).byteLength}catch(e){return!1}}(),t.kMaxLength=a(),u.poolSize=8192,u._augment=function(e){return e.__proto__=u.prototype,e},u.from=function(e,t,n){return c(null,e,t,n)},u.TYPED_ARRAY_SUPPORT&&(u.prototype.__proto__=Uint8Array.prototype,u.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&u[Symbol.species]===u&&Object.defineProperty(u,Symbol.species,{value:null,configurable:!0})),u.alloc=function(e,t,n){return function(e,t,n,r){return l(t),t<=0?s(e,t):void 0!==n?"string"==typeof r?s(e,t).fill(n,r):s(e,t).fill(n):s(e,t)}(null,e,t,n)},u.allocUnsafe=function(e){return f(null,e)},u.allocUnsafeSlow=function(e){return f(null,e)},u.isBuffer=function(e){return!(null==e||!e._isBuffer)},u.compare=function(e,t){if(!u.isBuffer(e)||!u.isBuffer(t))throw new TypeError("Arguments must be Buffers");if(e===t)return 0;for(var n=e.length,r=t.length,i=0,o=Math.min(n,r);i<o;++i)if(e[i]!==t[i]){n=e[i],r=t[i];break}return n<r?-1:r<n?1:0},u.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}},u.concat=function(e,t){if(!o(e))throw new TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return u.alloc(0);var n;if(void 0===t)for(t=0,n=0;n<e.length;++n)t+=e[n].length;var r=u.allocUnsafe(t),i=0;for(n=0;n<e.length;++n){var a=e[n];if(!u.isBuffer(a))throw new TypeError('"list" argument must be an Array of Buffers');a.copy(r,i),i+=a.length}return r},u.byteLength=d,u.prototype._isBuffer=!0,u.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)y(this,t,t+1);return this},u.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)y(this,t,t+3),y(this,t+1,t+2);return this},u.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)y(this,t,t+7),y(this,t+1,t+6),y(this,t+2,t+5),y(this,t+3,t+4);return this},u.prototype.toString=function(){var e=0|this.length;return 0===e?"":0===arguments.length?T(this,0,e):function(e,t,n){var r=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===n||n>this.length)&&(n=this.length),n<=0)return"";if((n>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return N(this,t,n);case"utf8":case"utf-8":return T(this,t,n);case"ascii":return O(this,t,n);case"latin1":case"binary":return j(this,t,n);case"base64":return S(this,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return I(this,t,n);default:if(r)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),r=!0}}.apply(this,arguments)},u.prototype.equals=function(e){if(!u.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e||0===u.compare(this,e)},u.prototype.inspect=function(){var e="",n=t.INSPECT_MAX_BYTES;return this.length>0&&(e=this.toString("hex",0,n).match(/.{2}/g).join(" "),this.length>n&&(e+=" ... ")),"<Buffer "+e+">"},u.prototype.compare=function(e,t,n,r,i){if(!u.isBuffer(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===n&&(n=e?e.length:0),void 0===r&&(r=0),void 0===i&&(i=this.length),t<0||n>e.length||r<0||i>this.length)throw new RangeError("out of range index");if(r>=i&&t>=n)return 0;if(r>=i)return-1;if(t>=n)return 1;if(this===e)return 0;for(var o=(i>>>=0)-(r>>>=0),a=(n>>>=0)-(t>>>=0),s=Math.min(o,a),c=this.slice(r,i),l=e.slice(t,n),f=0;f<s;++f)if(c[f]!==l[f]){o=c[f],a=l[f];break}return o<a?-1:a<o?1:0},u.prototype.includes=function(e,t,n){return-1!==this.indexOf(e,t,n)},u.prototype.indexOf=function(e,t,n){return v(this,e,t,n,!0)},u.prototype.lastIndexOf=function(e,t,n){return v(this,e,t,n,!1)},u.prototype.write=function(e,t,n,r){if(void 0===t)r="utf8",n=this.length,t=0;else if(void 0===n&&"string"==typeof t)r=t,n=this.length,t=0;else{if(!isFinite(t))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");t|=0,isFinite(n)?(n|=0,void 0===r&&(r="utf8")):(r=n,n=void 0)}var i=this.length-t;if((void 0===n||n>i)&&(n=i),e.length>0&&(n<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");r||(r="utf8");for(var o=!1;;)switch(r){case"hex":return m(this,e,t,n);case"utf8":case"utf-8":return w(this,e,t,n);case"ascii":return b(this,e,t,n);case"latin1":case"binary":return x(this,e,t,n);case"base64":return _(this,e,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return k(this,e,t,n);default:if(o)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),o=!0}},u.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var E=4096;function O(e,t,n){var r="";n=Math.min(e.length,n);for(var i=t;i<n;++i)r+=String.fromCharCode(127&e[i]);return r}function j(e,t,n){var r="";n=Math.min(e.length,n);for(var i=t;i<n;++i)r+=String.fromCharCode(e[i]);return r}function N(e,t,n){var r=e.length;(!t||t<0)&&(t=0),(!n||n<0||n>r)&&(n=r);for(var i="",o=t;o<n;++o)i+=F(e[o]);return i}function I(e,t,n){for(var r=e.slice(t,n),i="",o=0;o<r.length;o+=2)i+=String.fromCharCode(r[o]+256*r[o+1]);return i}function R(e,t,n){if(e%1!=0||e<0)throw new RangeError("offset is not uint");if(e+t>n)throw new RangeError("Trying to access beyond buffer length")}function A(e,t,n,r,i,o){if(!u.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||t<o)throw new RangeError('"value" argument is out of bounds');if(n+r>e.length)throw new RangeError("Index out of range")}function C(e,t,n,r){t<0&&(t=65535+t+1);for(var i=0,o=Math.min(e.length-n,2);i<o;++i)e[n+i]=(t&255<<8*(r?i:1-i))>>>8*(r?i:1-i)}function P(e,t,n,r){t<0&&(t=4294967295+t+1);for(var i=0,o=Math.min(e.length-n,4);i<o;++i)e[n+i]=t>>>8*(r?i:3-i)&255}function L(e,t,n,r,i,o){if(n+r>e.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function D(e,t,n,r,o){return o||L(e,0,n,4),i.write(e,t,n,r,23,4),n+4}function U(e,t,n,r,o){return o||L(e,0,n,8),i.write(e,t,n,r,52,8),n+8}u.prototype.slice=function(e,t){var n,r=this.length;if((e=~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),(t=void 0===t?r:~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),t<e&&(t=e),u.TYPED_ARRAY_SUPPORT)(n=this.subarray(e,t)).__proto__=u.prototype;else{var i=t-e;n=new u(i,void 0);for(var o=0;o<i;++o)n[o]=this[o+e]}return n},u.prototype.readUIntLE=function(e,t,n){e|=0,t|=0,n||R(e,t,this.length);for(var r=this[e],i=1,o=0;++o<t&&(i*=256);)r+=this[e+o]*i;return r},u.prototype.readUIntBE=function(e,t,n){e|=0,t|=0,n||R(e,t,this.length);for(var r=this[e+--t],i=1;t>0&&(i*=256);)r+=this[e+--t]*i;return r},u.prototype.readUInt8=function(e,t){return t||R(e,1,this.length),this[e]},u.prototype.readUInt16LE=function(e,t){return t||R(e,2,this.length),this[e]|this[e+1]<<8},u.prototype.readUInt16BE=function(e,t){return t||R(e,2,this.length),this[e]<<8|this[e+1]},u.prototype.readUInt32LE=function(e,t){return t||R(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},u.prototype.readUInt32BE=function(e,t){return t||R(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},u.prototype.readIntLE=function(e,t,n){e|=0,t|=0,n||R(e,t,this.length);for(var r=this[e],i=1,o=0;++o<t&&(i*=256);)r+=this[e+o]*i;return r>=(i*=128)&&(r-=Math.pow(2,8*t)),r},u.prototype.readIntBE=function(e,t,n){e|=0,t|=0,n||R(e,t,this.length);for(var r=t,i=1,o=this[e+--r];r>0&&(i*=256);)o+=this[e+--r]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*t)),o},u.prototype.readInt8=function(e,t){return t||R(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},u.prototype.readInt16LE=function(e,t){t||R(e,2,this.length);var n=this[e]|this[e+1]<<8;return 32768&n?4294901760|n:n},u.prototype.readInt16BE=function(e,t){t||R(e,2,this.length);var n=this[e+1]|this[e]<<8;return 32768&n?4294901760|n:n},u.prototype.readInt32LE=function(e,t){return t||R(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},u.prototype.readInt32BE=function(e,t){return t||R(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},u.prototype.readFloatLE=function(e,t){return t||R(e,4,this.length),i.read(this,e,!0,23,4)},u.prototype.readFloatBE=function(e,t){return t||R(e,4,this.length),i.read(this,e,!1,23,4)},u.prototype.readDoubleLE=function(e,t){return t||R(e,8,this.length),i.read(this,e,!0,52,8)},u.prototype.readDoubleBE=function(e,t){return t||R(e,8,this.length),i.read(this,e,!1,52,8)},u.prototype.writeUIntLE=function(e,t,n,r){(e=+e,t|=0,n|=0,r)||A(this,e,t,n,Math.pow(2,8*n)-1,0);var i=1,o=0;for(this[t]=255&e;++o<n&&(i*=256);)this[t+o]=e/i&255;return t+n},u.prototype.writeUIntBE=function(e,t,n,r){(e=+e,t|=0,n|=0,r)||A(this,e,t,n,Math.pow(2,8*n)-1,0);var i=n-1,o=1;for(this[t+i]=255&e;--i>=0&&(o*=256);)this[t+i]=e/o&255;return t+n},u.prototype.writeUInt8=function(e,t,n){return e=+e,t|=0,n||A(this,e,t,1,255,0),u.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},u.prototype.writeUInt16LE=function(e,t,n){return e=+e,t|=0,n||A(this,e,t,2,65535,0),u.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):C(this,e,t,!0),t+2},u.prototype.writeUInt16BE=function(e,t,n){return e=+e,t|=0,n||A(this,e,t,2,65535,0),u.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):C(this,e,t,!1),t+2},u.prototype.writeUInt32LE=function(e,t,n){return e=+e,t|=0,n||A(this,e,t,4,4294967295,0),u.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):P(this,e,t,!0),t+4},u.prototype.writeUInt32BE=function(e,t,n){return e=+e,t|=0,n||A(this,e,t,4,4294967295,0),u.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):P(this,e,t,!1),t+4},u.prototype.writeIntLE=function(e,t,n,r){if(e=+e,t|=0,!r){var i=Math.pow(2,8*n-1);A(this,e,t,n,i-1,-i)}var o=0,a=1,s=0;for(this[t]=255&e;++o<n&&(a*=256);)e<0&&0===s&&0!==this[t+o-1]&&(s=1),this[t+o]=(e/a>>0)-s&255;return t+n},u.prototype.writeIntBE=function(e,t,n,r){if(e=+e,t|=0,!r){var i=Math.pow(2,8*n-1);A(this,e,t,n,i-1,-i)}var o=n-1,a=1,s=0;for(this[t+o]=255&e;--o>=0&&(a*=256);)e<0&&0===s&&0!==this[t+o+1]&&(s=1),this[t+o]=(e/a>>0)-s&255;return t+n},u.prototype.writeInt8=function(e,t,n){return e=+e,t|=0,n||A(this,e,t,1,127,-128),u.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},u.prototype.writeInt16LE=function(e,t,n){return e=+e,t|=0,n||A(this,e,t,2,32767,-32768),u.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):C(this,e,t,!0),t+2},u.prototype.writeInt16BE=function(e,t,n){return e=+e,t|=0,n||A(this,e,t,2,32767,-32768),u.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):C(this,e,t,!1),t+2},u.prototype.writeInt32LE=function(e,t,n){return e=+e,t|=0,n||A(this,e,t,4,2147483647,-2147483648),u.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):P(this,e,t,!0),t+4},u.prototype.writeInt32BE=function(e,t,n){return e=+e,t|=0,n||A(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),u.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):P(this,e,t,!1),t+4},u.prototype.writeFloatLE=function(e,t,n){return D(this,e,t,!0,n)},u.prototype.writeFloatBE=function(e,t,n){return D(this,e,t,!1,n)},u.prototype.writeDoubleLE=function(e,t,n){return U(this,e,t,!0,n)},u.prototype.writeDoubleBE=function(e,t,n){return U(this,e,t,!1,n)},u.prototype.copy=function(e,t,n,r){if(n||(n=0),r||0===r||(r=this.length),t>=e.length&&(t=e.length),t||(t=0),r>0&&r<n&&(r=n),r===n)return 0;if(0===e.length||0===this.length)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("sourceStart out of bounds");if(r<0)throw new RangeError("sourceEnd out of bounds");r>this.length&&(r=this.length),e.length-t<r-n&&(r=e.length-t+n);var i,o=r-n;if(this===e&&n<t&&t<r)for(i=o-1;i>=0;--i)e[i+t]=this[i+n];else if(o<1e3||!u.TYPED_ARRAY_SUPPORT)for(i=0;i<o;++i)e[i+t]=this[i+n];else Uint8Array.prototype.set.call(e,this.subarray(n,n+o),t);return o},u.prototype.fill=function(e,t,n,r){if("string"==typeof e){if("string"==typeof t?(r=t,t=0,n=this.length):"string"==typeof n&&(r=n,n=this.length),1===e.length){var i=e.charCodeAt(0);i<256&&(e=i)}if(void 0!==r&&"string"!=typeof r)throw new TypeError("encoding must be a string");if("string"==typeof r&&!u.isEncoding(r))throw new TypeError("Unknown encoding: "+r)}else"number"==typeof e&&(e&=255);if(t<0||this.length<t||this.length<n)throw new RangeError("Out of range index");if(n<=t)return this;var o;if(t>>>=0,n=void 0===n?this.length:n>>>0,e||(e=0),"number"==typeof e)for(o=t;o<n;++o)this[o]=e;else{var a=u.isBuffer(e)?e:B(new u(e,r).toString()),s=a.length;for(o=0;o<n-t;++o)this[o+t]=a[o%s]}return this};var M=/[^+\/0-9A-Za-z-_]/g;function F(e){return e<16?"0"+e.toString(16):e.toString(16)}function B(e,t){var n;t=t||1/0;for(var r=e.length,i=null,o=[],a=0;a<r;++a){if((n=e.charCodeAt(a))>55295&&n<57344){if(!i){if(n>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(a+1===r){(t-=3)>-1&&o.push(239,191,189);continue}i=n;continue}if(n<56320){(t-=3)>-1&&o.push(239,191,189),i=n;continue}n=65536+(i-55296<<10|n-56320)}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,n<128){if((t-=1)<0)break;o.push(n)}else if(n<2048){if((t-=2)<0)break;o.push(n>>6|192,63&n|128)}else if(n<65536){if((t-=3)<0)break;o.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(n<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return o}function q(e){return r.toByteArray(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(M,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function z(e,t,n,r){for(var i=0;i<r&&!(i+n>=t.length||i>=e.length);++i)t[i+n]=e[i];return i}}).call(this,n(8))},function(e,t,n){"use strict";var r=n(22);function i(e,t){e.emit("error",t)}e.exports={destroy:function(e,t){var n=this,o=this._readableState&&this._readableState.destroyed,a=this._writableState&&this._writableState.destroyed;return o||a?(t?t(e):!e||this._writableState&&this._writableState.errorEmitted||r.nextTick(i,this,e),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(e||null,function(e){!t&&e?(r.nextTick(i,n,e),n._writableState&&(n._writableState.errorEmitted=!0)):t&&t(e)}),this)},undestroy:function(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)}}},function(e,t,n){"use strict";var r=n(23).Buffer,i=r.isEncoding||function(e){switch((e=""+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}};function o(e){var t;switch(this.encoding=function(e){var t=function(e){if(!e)return"utf8";for(var t;;)switch(e){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return e;default:if(t)return;e=(""+e).toLowerCase(),t=!0}}(e);if("string"!=typeof t&&(r.isEncoding===i||!i(e)))throw new Error("Unknown encoding: "+e);return t||e}(e),this.encoding){case"utf16le":this.text=u,this.end=c,t=4;break;case"utf8":this.fillLast=s,t=4;break;case"base64":this.text=l,this.end=f,t=3;break;default:return this.write=h,void(this.end=p)}this.lastNeed=0,this.lastTotal=0,this.lastChar=r.allocUnsafe(t)}function a(e){return e<=127?0:e>>5==6?2:e>>4==14?3:e>>3==30?4:e>>6==2?-1:-2}function s(e){var t=this.lastTotal-this.lastNeed,n=function(e,t,n){if(128!=(192&t[0]))return e.lastNeed=0,"�";if(e.lastNeed>1&&t.length>1){if(128!=(192&t[1]))return e.lastNeed=1,"�";if(e.lastNeed>2&&t.length>2&&128!=(192&t[2]))return e.lastNeed=2,"�"}}(this,e);return void 0!==n?n:this.lastNeed<=e.length?(e.copy(this.lastChar,t,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(e.copy(this.lastChar,t,0,e.length),void(this.lastNeed-=e.length))}function u(e,t){if((e.length-t)%2==0){var n=e.toString("utf16le",t);if(n){var r=n.charCodeAt(n.length-1);if(r>=55296&&r<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1],n.slice(0,-1)}return n}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=e[e.length-1],e.toString("utf16le",t,e.length-1)}function c(e){var t=e&&e.length?this.write(e):"";if(this.lastNeed){var n=this.lastTotal-this.lastNeed;return t+this.lastChar.toString("utf16le",0,n)}return t}function l(e,t){var n=(e.length-t)%3;return 0===n?e.toString("base64",t):(this.lastNeed=3-n,this.lastTotal=3,1===n?this.lastChar[0]=e[e.length-1]:(this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1]),e.toString("base64",t,e.length-n))}function f(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+this.lastChar.toString("base64",0,3-this.lastNeed):t}function h(e){return e.toString(this.encoding)}function p(e){return e&&e.length?this.write(e):""}t.StringDecoder=o,o.prototype.write=function(e){if(0===e.length)return"";var t,n;if(this.lastNeed){if(void 0===(t=this.fillLast(e)))return"";n=this.lastNeed,this.lastNeed=0}else n=0;return n<e.length?t?t+this.text(e,n):this.text(e,n):t||""},o.prototype.end=function(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+"�":t},o.prototype.text=function(e,t){var n=function(e,t,n){var r=t.length-1;if(r<n)return 0;var i=a(t[r]);if(i>=0)return i>0&&(e.lastNeed=i-1),i;if(--r<n||-2===i)return 0;if((i=a(t[r]))>=0)return i>0&&(e.lastNeed=i-2),i;if(--r<n||-2===i)return 0;if((i=a(t[r]))>=0)return i>0&&(2===i?i=0:e.lastNeed=i-3),i;return 0}(this,e,t);if(!this.lastNeed)return e.toString("utf8",t);this.lastTotal=n;var r=e.length-(n-this.lastNeed);return e.copy(this.lastChar,0,r),e.toString("utf8",t,r)},o.prototype.fillLast=function(e){if(this.lastNeed<=e.length)return e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,e.length),this.lastNeed-=e.length}},function(e,t,n){"use strict";e.exports=a;var r=n(12),i=n(18);function o(e,t){var n=this._transformState;n.transforming=!1;var r=n.writecb;if(!r)return this.emit("error",new Error("write callback called multiple times"));n.writechunk=null,n.writecb=null,null!=t&&this.push(t),r(e);var i=this._readableState;i.reading=!1,(i.needReadable||i.length<i.highWaterMark)&&this._read(i.highWaterMark)}function a(e){if(!(this instanceof a))return new a(e);r.call(this,e),this._transformState={afterTransform:o.bind(this),needTransform:!1,transforming:!1,writecb:null,writechunk:null,writeencoding:null},this._readableState.needReadable=!0,this._readableState.sync=!1,e&&("function"==typeof e.transform&&(this._transform=e.transform),"function"==typeof e.flush&&(this._flush=e.flush)),this.on("prefinish",s)}function s(){var e=this;"function"==typeof this._flush?this._flush(function(t,n){u(e,t,n)}):u(this,null,null)}function u(e,t,n){if(t)return e.emit("error",t);if(null!=n&&e.push(n),e._writableState.length)throw new Error("Calling transform done when ws.length != 0");if(e._transformState.transforming)throw new Error("Calling transform done when still transforming");return e.push(null)}i.inherits=n(11),i.inherits(a,r),a.prototype.push=function(e,t){return this._transformState.needTransform=!1,r.prototype.push.call(this,e,t)},a.prototype._transform=function(e,t,n){throw new Error("_transform() is not implemented")},a.prototype._write=function(e,t,n){var r=this._transformState;if(r.writecb=n,r.writechunk=e,r.writeencoding=t,!r.transforming){var i=this._readableState;(r.needTransform||i.needReadable||i.length<i.highWaterMark)&&this._read(i.highWaterMark)}},a.prototype._read=function(e){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},a.prototype._destroy=function(e,t){var n=this;r.prototype._destroy.call(this,e,function(e){t(e),n.emit("close")})}},function(e,t,n){(function(e){var r=Object.getOwnPropertyDescriptors||function(e){for(var t=Object.keys(e),n={},r=0;r<t.length;r++)n[t[r]]=Object.getOwnPropertyDescriptor(e,t[r]);return n},i=/%[sdj%]/g;t.format=function(e){if(!g(e)){for(var t=[],n=0;n<arguments.length;n++)t.push(s(arguments[n]));return t.join(" ")}n=1;for(var r=arguments,o=r.length,a=String(e).replace(i,function(e){if("%%"===e)return"%";if(n>=o)return e;switch(e){case"%s":return String(r[n++]);case"%d":return Number(r[n++]);case"%j":try{return JSON.stringify(r[n++])}catch(e){return"[Circular]"}default:return e}}),u=r[n];n<o;u=r[++n])y(u)||!b(u)?a+=" "+u:a+=" "+s(u);return a},t.deprecate=function(n,r){if(void 0!==e&&!0===e.noDeprecation)return n;if(void 0===e)return function(){return t.deprecate(n,r).apply(this,arguments)};var i=!1;return function(){if(!i){if(e.throwDeprecation)throw new Error(r);e.traceDeprecation?console.trace(r):console.error(r),i=!0}return n.apply(this,arguments)}};var o,a={};function s(e,n){var r={seen:[],stylize:c};return arguments.length>=3&&(r.depth=arguments[2]),arguments.length>=4&&(r.colors=arguments[3]),d(n)?r.showHidden=n:n&&t._extend(r,n),m(r.showHidden)&&(r.showHidden=!1),m(r.depth)&&(r.depth=2),m(r.colors)&&(r.colors=!1),m(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=u),l(r,e,r.depth)}function u(e,t){var n=s.styles[t];return n?"["+s.colors[n][0]+"m"+e+"["+s.colors[n][1]+"m":e}function c(e,t){return e}function l(e,n,r){if(e.customInspect&&n&&k(n.inspect)&&n.inspect!==t.inspect&&(!n.constructor||n.constructor.prototype!==n)){var i=n.inspect(r,e);return g(i)||(i=l(e,i,r)),i}var o=function(e,t){if(m(t))return e.stylize("undefined","undefined");if(g(t)){var n="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(n,"string")}if(v(t))return e.stylize(""+t,"number");if(d(t))return e.stylize(""+t,"boolean");if(y(t))return e.stylize("null","null")}(e,n);if(o)return o;var a=Object.keys(n),s=function(e){var t={};return e.forEach(function(e,n){t[e]=!0}),t}(a);if(e.showHidden&&(a=Object.getOwnPropertyNames(n)),_(n)&&(a.indexOf("message")>=0||a.indexOf("description")>=0))return f(n);if(0===a.length){if(k(n)){var u=n.name?": "+n.name:"";return e.stylize("[Function"+u+"]","special")}if(w(n))return e.stylize(RegExp.prototype.toString.call(n),"regexp");if(x(n))return e.stylize(Date.prototype.toString.call(n),"date");if(_(n))return f(n)}var c,b="",S=!1,T=["{","}"];(p(n)&&(S=!0,T=["[","]"]),k(n))&&(b=" [Function"+(n.name?": "+n.name:"")+"]");return w(n)&&(b=" "+RegExp.prototype.toString.call(n)),x(n)&&(b=" "+Date.prototype.toUTCString.call(n)),_(n)&&(b=" "+f(n)),0!==a.length||S&&0!=n.length?r<0?w(n)?e.stylize(RegExp.prototype.toString.call(n),"regexp"):e.stylize("[Object]","special"):(e.seen.push(n),c=S?function(e,t,n,r,i){for(var o=[],a=0,s=t.length;a<s;++a)O(t,String(a))?o.push(h(e,t,n,r,String(a),!0)):o.push("");return i.forEach(function(i){i.match(/^\d+$/)||o.push(h(e,t,n,r,i,!0))}),o}(e,n,r,s,a):a.map(function(t){return h(e,n,r,s,t,S)}),e.seen.pop(),function(e,t,n){if(e.reduce(function(e,t){return 0,t.indexOf("\n")>=0&&0,e+t.replace(/\u001b\[\d\d?m/g,"").length+1},0)>60)return n[0]+(""===t?"":t+"\n ")+" "+e.join(",\n  ")+" "+n[1];return n[0]+t+" "+e.join(", ")+" "+n[1]}(c,b,T)):T[0]+b+T[1]}function f(e){return"["+Error.prototype.toString.call(e)+"]"}function h(e,t,n,r,i,o){var a,s,u;if((u=Object.getOwnPropertyDescriptor(t,i)||{value:t[i]}).get?s=u.set?e.stylize("[Getter/Setter]","special"):e.stylize("[Getter]","special"):u.set&&(s=e.stylize("[Setter]","special")),O(r,i)||(a="["+i+"]"),s||(e.seen.indexOf(u.value)<0?(s=y(n)?l(e,u.value,null):l(e,u.value,n-1)).indexOf("\n")>-1&&(s=o?s.split("\n").map(function(e){return"  "+e}).join("\n").substr(2):"\n"+s.split("\n").map(function(e){return"   "+e}).join("\n")):s=e.stylize("[Circular]","special")),m(a)){if(o&&i.match(/^\d+$/))return s;(a=JSON.stringify(""+i)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(a=a.substr(1,a.length-2),a=e.stylize(a,"name")):(a=a.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),a=e.stylize(a,"string"))}return a+": "+s}function p(e){return Array.isArray(e)}function d(e){return"boolean"==typeof e}function y(e){return null===e}function v(e){return"number"==typeof e}function g(e){return"string"==typeof e}function m(e){return void 0===e}function w(e){return b(e)&&"[object RegExp]"===S(e)}function b(e){return"object"==typeof e&&null!==e}function x(e){return b(e)&&"[object Date]"===S(e)}function _(e){return b(e)&&("[object Error]"===S(e)||e instanceof Error)}function k(e){return"function"==typeof e}function S(e){return Object.prototype.toString.call(e)}function T(e){return e<10?"0"+e.toString(10):e.toString(10)}t.debuglog=function(n){if(m(o)&&(o=e.env.NODE_DEBUG||""),n=n.toUpperCase(),!a[n])if(new RegExp("\\b"+n+"\\b","i").test(o)){var r=e.pid;a[n]=function(){var e=t.format.apply(t,arguments);console.error("%s %d: %s",n,r,e)}}else a[n]=function(){};return a[n]},t.inspect=s,s.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]},s.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},t.isArray=p,t.isBoolean=d,t.isNull=y,t.isNullOrUndefined=function(e){return null==e},t.isNumber=v,t.isString=g,t.isSymbol=function(e){return"symbol"==typeof e},t.isUndefined=m,t.isRegExp=w,t.isObject=b,t.isDate=x,t.isError=_,t.isFunction=k,t.isPrimitive=function(e){return null===e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||"symbol"==typeof e||void 0===e},t.isBuffer=n(81);var E=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function O(e,t){return Object.prototype.hasOwnProperty.call(e,t)}t.log=function(){var e,n;console.log("%s - %s",(e=new Date,n=[T(e.getHours()),T(e.getMinutes()),T(e.getSeconds())].join(":"),[e.getDate(),E[e.getMonth()],n].join(" ")),t.format.apply(t,arguments))},t.inherits=n(11),t._extend=function(e,t){if(!t||!b(t))return e;for(var n=Object.keys(t),r=n.length;r--;)e[n[r]]=t[n[r]];return e};var j="undefined"!=typeof Symbol?Symbol("util.promisify.custom"):void 0;function N(e,t){if(!e){var n=new Error("Promise was rejected with a falsy value");n.reason=e,e=n}return t(e)}t.promisify=function(e){if("function"!=typeof e)throw new TypeError('The "original" argument must be of type Function');if(j&&e[j]){var t;if("function"!=typeof(t=e[j]))throw new TypeError('The "util.promisify.custom" argument must be of type Function');return Object.defineProperty(t,j,{value:t,enumerable:!1,writable:!1,configurable:!0}),t}function t(){for(var t,n,r=new Promise(function(e,r){t=e,n=r}),i=[],o=0;o<arguments.length;o++)i.push(arguments[o]);i.push(function(e,r){e?n(e):t(r)});try{e.apply(this,i)}catch(e){n(e)}return r}return Object.setPrototypeOf(t,Object.getPrototypeOf(e)),j&&Object.defineProperty(t,j,{value:t,enumerable:!1,writable:!1,configurable:!0}),Object.defineProperties(t,r(e))},t.promisify.custom=j,t.callbackify=function(t){if("function"!=typeof t)throw new TypeError('The "original" argument must be of type Function');function n(){for(var n=[],r=0;r<arguments.length;r++)n.push(arguments[r]);var i=n.pop();if("function"!=typeof i)throw new TypeError("The last argument must be of type Function");var o=this,a=function(){return i.apply(o,arguments)};t.apply(this,n).then(function(t){e.nextTick(a,null,t)},function(t){e.nextTick(N,t,a)})}return Object.setPrototypeOf(n,Object.getPrototypeOf(t)),Object.defineProperties(n,r(t)),n}}).call(this,n(7))},function(e,t,n){var r=n(48).Transform,i=n(56),o=n(35);function a(e){if(!(this instanceof a))return new a(e);r.call(this,{encoding:"utf8"}),this._writableState.objectMode=!0;var t=this,n=new o({write:function(e,n,r){t.push(e),r&&r()},end:function(e){t.push(null),e&&e()}},e);this._transform=function(e,t,r){n.addTriple(e,r)},this._flush=function(e){n.end(e)}}i.inherits(a,r),e.exports=a},function(e,t){function n(e,t){for(var n in e)t[n]=e[n]}function r(e,t){var r=e.prototype;if(Object.create){var i=Object.create(t.prototype);r.__proto__=i}if(!(r instanceof t)){function o(){}o.prototype=t.prototype,n(r,o=new o),e.prototype=r=o}r.constructor!=e&&("function"!=typeof e&&console.error("unknow Class:"+e),r.constructor=e)}var i="http://www.w3.org/1999/xhtml",o={},a=o.ELEMENT_NODE=1,s=o.ATTRIBUTE_NODE=2,u=o.TEXT_NODE=3,c=o.CDATA_SECTION_NODE=4,l=o.ENTITY_REFERENCE_NODE=5,f=o.ENTITY_NODE=6,h=o.PROCESSING_INSTRUCTION_NODE=7,p=o.COMMENT_NODE=8,d=o.DOCUMENT_NODE=9,y=o.DOCUMENT_TYPE_NODE=10,v=o.DOCUMENT_FRAGMENT_NODE=11,g=o.NOTATION_NODE=12,m={},w={},b=(m.INDEX_SIZE_ERR=(w[1]="Index size error",1),m.DOMSTRING_SIZE_ERR=(w[2]="DOMString size error",2),m.HIERARCHY_REQUEST_ERR=(w[3]="Hierarchy request error",3)),x=(m.WRONG_DOCUMENT_ERR=(w[4]="Wrong document",4),m.INVALID_CHARACTER_ERR=(w[5]="Invalid character",5),m.NO_DATA_ALLOWED_ERR=(w[6]="No data allowed",6),m.NO_MODIFICATION_ALLOWED_ERR=(w[7]="No modification allowed",7),m.NOT_FOUND_ERR=(w[8]="Not found",8)),_=(m.NOT_SUPPORTED_ERR=(w[9]="Not supported",9),m.INUSE_ATTRIBUTE_ERR=(w[10]="Attribute in use",10));m.INVALID_STATE_ERR=(w[11]="Invalid state",11),m.SYNTAX_ERR=(w[12]="Syntax error",12),m.INVALID_MODIFICATION_ERR=(w[13]="Invalid modification",13),m.NAMESPACE_ERR=(w[14]="Invalid namespace",14),m.INVALID_ACCESS_ERR=(w[15]="Invalid access",15);function k(e,t){if(t instanceof Error)var n=t;else n=this,Error.call(this,w[e]),this.message=w[e],Error.captureStackTrace&&Error.captureStackTrace(this,k);return n.code=e,t&&(this.message=this.message+": "+t),n}function S(){}function T(e,t){this._node=e,this._refresh=t,E(this)}function E(e){var t=e._node._inc||e._node.ownerDocument._inc;if(e._inc!=t){var r=e._refresh(e._node);ne(e,"length",r.length),n(r,e),e._inc=t}}function O(){}function j(e,t){for(var n=e.length;n--;)if(e[n]===t)return n}function N(e,t,n,r){if(r?t[j(t,r)]=n:t[t.length++]=n,e){n.ownerElement=e;var i=e.ownerDocument;i&&(r&&D(i,e,r),function(e,t,n){e&&e._inc++,"http://www.w3.org/2000/xmlns/"==n.namespaceURI&&(t._nsMap[n.prefix?n.localName:""]=n.value)}(i,e,n))}}function I(e,t,n){var r=j(t,n);if(!(r>=0))throw k(x,new Error(e.tagName+"@"+n));for(var i=t.length-1;r<i;)t[r]=t[++r];if(t.length=i,e){var o=e.ownerDocument;o&&(D(o,e,n),n.ownerElement=null)}}function R(e){if(this._features={},e)for(var t in e)this._features=e[t]}function A(){}function C(e){return("<"==e?"&lt;":">"==e&&"&gt;")||"&"==e&&"&amp;"||'"'==e&&"&quot;"||"&#"+e.charCodeAt()+";"}function P(e,t){if(t(e))return!0;if(e=e.firstChild)do{if(P(e,t))return!0}while(e=e.nextSibling)}function L(){}function D(e,t,n,r){e&&e._inc++,"http://www.w3.org/2000/xmlns/"==n.namespaceURI&&delete t._nsMap[n.prefix?n.localName:""]}function U(e,t,n){if(e&&e._inc){e._inc++;var r=t.childNodes;if(n)r[r.length++]=n;else{for(var i=t.firstChild,o=0;i;)r[o++]=i,i=i.nextSibling;r.length=o}}}function M(e,t){var n=t.previousSibling,r=t.nextSibling;return n?n.nextSibling=r:e.firstChild=r,r?r.previousSibling=n:e.lastChild=n,U(e.ownerDocument,e),t}function F(e,t,n){var r=t.parentNode;if(r&&r.removeChild(t),t.nodeType===v){var i=t.firstChild;if(null==i)return t;var o=t.lastChild}else i=o=t;var a=n?n.previousSibling:e.lastChild;i.previousSibling=a,o.nextSibling=n,a?a.nextSibling=i:e.firstChild=i,null==n?e.lastChild=o:n.previousSibling=o;do{i.parentNode=e}while(i!==o&&(i=i.nextSibling));return U(e.ownerDocument||e,e),t.nodeType==v&&(t.firstChild=t.lastChild=null),t}function B(){this._nsMap={}}function q(){}function z(){}function H(){}function V(){}function J(){}function W(){}function X(){}function Y(){}function $(){}function K(){}function G(){}function Q(){}function Z(e,t){var n=[],r=9==this.nodeType?this.documentElement:this,i=r.prefix,o=r.namespaceURI;if(o&&null==i&&null==(i=r.lookupPrefix(o)))var a=[{namespace:o,prefix:null}];return te(this,n,e,t,a),n.join("")}function ee(e,t,n){var r=e.prefix||"",i=e.namespaceURI;if(!r&&!i)return!1;if("xml"===r&&"http://www.w3.org/XML/1998/namespace"===i||"http://www.w3.org/2000/xmlns/"==i)return!1;for(var o=n.length;o--;){var a=n[o];if(a.prefix==r)return a.namespace!=i}return!0}function te(e,t,n,r,o){if(r){if(!(e=r(e)))return;if("string"==typeof e)return void t.push(e)}switch(e.nodeType){case a:o||(o=[]);o.length;var f=e.attributes,g=f.length,m=e.firstChild,w=e.tagName;n=i===e.namespaceURI||n,t.push("<",w);for(var b=0;b<g;b++){"xmlns"==(x=f.item(b)).prefix?o.push({prefix:x.localName,namespace:x.value}):"xmlns"==x.nodeName&&o.push({prefix:"",namespace:x.value})}for(b=0;b<g;b++){var x;if(ee(x=f.item(b),0,o)){var _=x.prefix||"",k=x.namespaceURI,S=_?" xmlns:"+_:" xmlns";t.push(S,'="',k,'"'),o.push({prefix:_,namespace:k})}te(x,t,n,r,o)}if(ee(e,0,o)){_=e.prefix||"",k=e.namespaceURI,S=_?" xmlns:"+_:" xmlns";t.push(S,'="',k,'"'),o.push({prefix:_,namespace:k})}if(m||n&&!/^(?:meta|link|img|br|hr|input)$/i.test(w)){if(t.push(">"),n&&/^script$/i.test(w))for(;m;)m.data?t.push(m.data):te(m,t,n,r,o),m=m.nextSibling;else for(;m;)te(m,t,n,r,o),m=m.nextSibling;t.push("</",w,">")}else t.push("/>");return;case d:case v:for(m=e.firstChild;m;)te(m,t,n,r,o),m=m.nextSibling;return;case s:return t.push(" ",e.name,'="',e.value.replace(/[<&"]/g,C),'"');case u:return t.push(e.data.replace(/[<&]/g,C));case c:return t.push("<![CDATA[",e.data,"]]>");case p:return t.push("\x3c!--",e.data,"--\x3e");case y:var T=e.publicId,E=e.systemId;if(t.push("<!DOCTYPE ",e.name),T)t.push(' PUBLIC "',T),E&&"."!=E&&t.push('" "',E),t.push('">');else if(E&&"."!=E)t.push(' SYSTEM "',E,'">');else{var O=e.internalSubset;O&&t.push(" [",O,"]"),t.push(">")}return;case h:return t.push("<?",e.target," ",e.data,"?>");case l:return t.push("&",e.nodeName,";");default:t.push("??",e.nodeName)}}function ne(e,t,n){e[t]=n}k.prototype=Error.prototype,n(m,k),S.prototype={length:0,item:function(e){return this[e]||null},toString:function(e,t){for(var n=[],r=0;r<this.length;r++)te(this[r],n,e,t);return n.join("")}},T.prototype.item=function(e){return E(this),this[e]},r(T,S),O.prototype={length:0,item:S.prototype.item,getNamedItem:function(e){for(var t=this.length;t--;){var n=this[t];if(n.nodeName==e)return n}},setNamedItem:function(e){var t=e.ownerElement;if(t&&t!=this._ownerElement)throw new k(_);var n=this.getNamedItem(e.nodeName);return N(this._ownerElement,this,e,n),n},setNamedItemNS:function(e){var t,n=e.ownerElement;if(n&&n!=this._ownerElement)throw new k(_);return t=this.getNamedItemNS(e.namespaceURI,e.localName),N(this._ownerElement,this,e,t),t},removeNamedItem:function(e){var t=this.getNamedItem(e);return I(this._ownerElement,this,t),t},removeNamedItemNS:function(e,t){var n=this.getNamedItemNS(e,t);return I(this._ownerElement,this,n),n},getNamedItemNS:function(e,t){for(var n=this.length;n--;){var r=this[n];if(r.localName==t&&r.namespaceURI==e)return r}return null}},R.prototype={hasFeature:function(e,t){var n=this._features[e.toLowerCase()];return!(!n||t&&!(t in n))},createDocument:function(e,t,n){var r=new L;if(r.implementation=this,r.childNodes=new S,r.doctype=n,n&&r.appendChild(n),t){var i=r.createElementNS(e,t);r.appendChild(i)}return r},createDocumentType:function(e,t,n){var r=new W;return r.name=e,r.nodeName=e,r.publicId=t,r.systemId=n,r}},A.prototype={firstChild:null,lastChild:null,previousSibling:null,nextSibling:null,attributes:null,parentNode:null,childNodes:null,ownerDocument:null,nodeValue:null,namespaceURI:null,prefix:null,localName:null,insertBefore:function(e,t){return F(this,e,t)},replaceChild:function(e,t){this.insertBefore(e,t),t&&this.removeChild(t)},removeChild:function(e){return M(this,e)},appendChild:function(e){return this.insertBefore(e,null)},hasChildNodes:function(){return null!=this.firstChild},cloneNode:function(e){return function e(t,n,r){var i=new n.constructor;for(var o in n){var u=n[o];"object"!=typeof u&&u!=i[o]&&(i[o]=u)}n.childNodes&&(i.childNodes=new S);i.ownerDocument=t;switch(i.nodeType){case a:var c=n.attributes,l=i.attributes=new O,f=c.length;l._ownerElement=i;for(var h=0;h<f;h++)i.setAttributeNode(e(t,c.item(h),!0));break;case s:r=!0}if(r)for(var p=n.firstChild;p;)i.appendChild(e(t,p,r)),p=p.nextSibling;return i}(this.ownerDocument||this,this,e)},normalize:function(){for(var e=this.firstChild;e;){var t=e.nextSibling;t&&t.nodeType==u&&e.nodeType==u?(this.removeChild(t),e.appendData(t.data)):(e.normalize(),e=t)}},isSupported:function(e,t){return this.ownerDocument.implementation.hasFeature(e,t)},hasAttributes:function(){return this.attributes.length>0},lookupPrefix:function(e){for(var t=this;t;){var n=t._nsMap;if(n)for(var r in n)if(n[r]==e)return r;t=t.nodeType==s?t.ownerDocument:t.parentNode}return null},lookupNamespaceURI:function(e){for(var t=this;t;){var n=t._nsMap;if(n&&e in n)return n[e];t=t.nodeType==s?t.ownerDocument:t.parentNode}return null},isDefaultNamespace:function(e){return null==this.lookupPrefix(e)}},n(o,A),n(o,A.prototype),L.prototype={nodeName:"#document",nodeType:d,doctype:null,documentElement:null,_inc:1,insertBefore:function(e,t){if(e.nodeType==v){for(var n=e.firstChild;n;){var r=n.nextSibling;this.insertBefore(n,t),n=r}return e}return null==this.documentElement&&e.nodeType==a&&(this.documentElement=e),F(this,e,t),e.ownerDocument=this,e},removeChild:function(e){return this.documentElement==e&&(this.documentElement=null),M(this,e)},importNode:function(e,t){return function e(t,n,r){var i;switch(n.nodeType){case a:(i=n.cloneNode(!1)).ownerDocument=t;case v:break;case s:r=!0}i||(i=n.cloneNode(!1));i.ownerDocument=t;i.parentNode=null;if(r)for(var o=n.firstChild;o;)i.appendChild(e(t,o,r)),o=o.nextSibling;return i}(this,e,t)},getElementById:function(e){var t=null;return P(this.documentElement,function(n){if(n.nodeType==a&&n.getAttribute("id")==e)return t=n,!0}),t},createElement:function(e){var t=new B;return t.ownerDocument=this,t.nodeName=e,t.tagName=e,t.childNodes=new S,(t.attributes=new O)._ownerElement=t,t},createDocumentFragment:function(){var e=new K;return e.ownerDocument=this,e.childNodes=new S,e},createTextNode:function(e){var t=new H;return t.ownerDocument=this,t.appendData(e),t},createComment:function(e){var t=new V;return t.ownerDocument=this,t.appendData(e),t},createCDATASection:function(e){var t=new J;return t.ownerDocument=this,t.appendData(e),t},createProcessingInstruction:function(e,t){var n=new G;return n.ownerDocument=this,n.tagName=n.target=e,n.nodeValue=n.data=t,n},createAttribute:function(e){var t=new q;return t.ownerDocument=this,t.name=e,t.nodeName=e,t.localName=e,t.specified=!0,t},createEntityReference:function(e){var t=new $;return t.ownerDocument=this,t.nodeName=e,t},createElementNS:function(e,t){var n=new B,r=t.split(":"),i=n.attributes=new O;return n.childNodes=new S,n.ownerDocument=this,n.nodeName=t,n.tagName=t,n.namespaceURI=e,2==r.length?(n.prefix=r[0],n.localName=r[1]):n.localName=t,i._ownerElement=n,n},createAttributeNS:function(e,t){var n=new q,r=t.split(":");return n.ownerDocument=this,n.nodeName=t,n.name=t,n.namespaceURI=e,n.specified=!0,2==r.length?(n.prefix=r[0],n.localName=r[1]):n.localName=t,n}},r(L,A),B.prototype={nodeType:a,hasAttribute:function(e){return null!=this.getAttributeNode(e)},getAttribute:function(e){var t=this.getAttributeNode(e);return t&&t.value||""},getAttributeNode:function(e){return this.attributes.getNamedItem(e)},setAttribute:function(e,t){var n=this.ownerDocument.createAttribute(e);n.value=n.nodeValue=""+t,this.setAttributeNode(n)},removeAttribute:function(e){var t=this.getAttributeNode(e);t&&this.removeAttributeNode(t)},appendChild:function(e){return e.nodeType===v?this.insertBefore(e,null):function(e,t){var n=t.parentNode;if(n){var r=e.lastChild;n.removeChild(t),r=e.lastChild}return r=e.lastChild,t.parentNode=e,t.previousSibling=r,t.nextSibling=null,r?r.nextSibling=t:e.firstChild=t,e.lastChild=t,U(e.ownerDocument,e,t),t}(this,e)},setAttributeNode:function(e){return this.attributes.setNamedItem(e)},setAttributeNodeNS:function(e){return this.attributes.setNamedItemNS(e)},removeAttributeNode:function(e){return this.attributes.removeNamedItem(e.nodeName)},removeAttributeNS:function(e,t){var n=this.getAttributeNodeNS(e,t);n&&this.removeAttributeNode(n)},hasAttributeNS:function(e,t){return null!=this.getAttributeNodeNS(e,t)},getAttributeNS:function(e,t){var n=this.getAttributeNodeNS(e,t);return n&&n.value||""},setAttributeNS:function(e,t,n){var r=this.ownerDocument.createAttributeNS(e,t);r.value=r.nodeValue=""+n,this.setAttributeNode(r)},getAttributeNodeNS:function(e,t){return this.attributes.getNamedItemNS(e,t)},getElementsByTagName:function(e){return new T(this,function(t){var n=[];return P(t,function(r){r===t||r.nodeType!=a||"*"!==e&&r.tagName!=e||n.push(r)}),n})},getElementsByTagNameNS:function(e,t){return new T(this,function(n){var r=[];return P(n,function(i){i===n||i.nodeType!==a||"*"!==e&&i.namespaceURI!==e||"*"!==t&&i.localName!=t||r.push(i)}),r})}},L.prototype.getElementsByTagName=B.prototype.getElementsByTagName,L.prototype.getElementsByTagNameNS=B.prototype.getElementsByTagNameNS,r(B,A),q.prototype.nodeType=s,r(q,A),z.prototype={data:"",substringData:function(e,t){return this.data.substring(e,e+t)},appendData:function(e){e=this.data+e,this.nodeValue=this.data=e,this.length=e.length},insertData:function(e,t){this.replaceData(e,0,t)},appendChild:function(e){throw new Error(w[b])},deleteData:function(e,t){this.replaceData(e,t,"")},replaceData:function(e,t,n){n=this.data.substring(0,e)+n+this.data.substring(e+t),this.nodeValue=this.data=n,this.length=n.length}},r(z,A),H.prototype={nodeName:"#text",nodeType:u,splitText:function(e){var t=this.data,n=t.substring(e);t=t.substring(0,e),this.data=this.nodeValue=t,this.length=t.length;var r=this.ownerDocument.createTextNode(n);return this.parentNode&&this.parentNode.insertBefore(r,this.nextSibling),r}},r(H,z),V.prototype={nodeName:"#comment",nodeType:p},r(V,z),J.prototype={nodeName:"#cdata-section",nodeType:c},r(J,z),W.prototype.nodeType=y,r(W,A),X.prototype.nodeType=g,r(X,A),Y.prototype.nodeType=f,r(Y,A),$.prototype.nodeType=l,r($,A),K.prototype.nodeName="#document-fragment",K.prototype.nodeType=v,r(K,A),G.prototype.nodeType=h,r(G,A),Q.prototype.serializeToString=function(e,t,n){return Z.call(e,t,n)},A.prototype.toString=Z;try{if(Object.defineProperty){Object.defineProperty(T.prototype,"length",{get:function(){return E(this),this.$$length}}),Object.defineProperty(A.prototype,"textContent",{get:function(){return function e(t){switch(t.nodeType){case a:case v:var n=[];for(t=t.firstChild;t;)7!==t.nodeType&&8!==t.nodeType&&n.push(e(t)),t=t.nextSibling;return n.join("");default:return t.nodeValue}}(this)},set:function(e){switch(this.nodeType){case a:case v:for(;this.firstChild;)this.removeChild(this.firstChild);(e||String(e))&&this.appendChild(this.ownerDocument.createTextNode(e));break;default:this.data=e,this.value=e,this.nodeValue=e}}}),ne=function(e,t,n){e["$$"+t]=n}}}catch(e){}t.DOMImplementation=R,t.XMLSerializer=Q},function(e,t,n){"use strict";function r(e){return(r="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})(e)}function i(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function o(e,t){return!t||"object"!==r(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function a(e){return(a=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function s(e,t){return(s=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}var u=n(9),c=n(14),l=n(21),f=n(15),h=n(13),p=n(2),d=n(3),y=n(37),v=n(25),g=n(26),m=function(e){function t(e,n,r,i){var s;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),(s=o(this,a(t).call(this))).termType=t.termType,s.statements=e||[],s.constraints=n||[],s.initBindings=r||[],s.optional=i||[],s}var n,r,c;return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&s(e,t)}(t,d),n=t,(r=[{key:"add",value:function(e,t,n,r){return this.statements.push(new v(e,t,n,r))}},{key:"addStatement",value:function(e){return this.statements.push(e)}},{key:"bnode",value:function(e){return new u(e)}},{key:"addAll",value:function(e){var t=this;e.forEach(function(e){t.add(e.subject,e.predicate,e.object,e.graph)})}},{key:"any",value:function(e,t,n,r){var i=this.anyStatementMatching(e,t,n,r);if(null!=i)return null==e?i.subject:null==t?i.predicate:null==n?i.object:void 0}},{key:"anyValue",value:function(e,t,n,r){var i=this.any(e,t,n,r);return i?i.value:void 0}},{key:"anyJS",value:function(e,t,n,r){var i=this.any(e,t,n,r);return i?d.toJS(i):void 0}},{key:"anyStatementMatching",value:function(e,t,n,r){var i=this.statementsMatching(e,t,n,r,!0);if(i&&0!==i.length)return i[0]}},{key:"statementsMatching",value:function(e,t,n,r,i){return this.statements.filter(function(i){return(!e||e.sameTerm(i.subject))&&(!t||t.sameTerm(i.predicate))&&(!n||e.sameTerm(i.object))&&(!r||r.sameTerm(i.subject))})}},{key:"bottomTypeURIs",value:function(e){var t,n,r,i,o,a,s;for(i in t=[],e)if(e.hasOwnProperty(i)){for(s=e[i],n=!0,r=0,o=(a=this.each(void 0,this.sym("http://www.w3.org/2000/01/rdf-schema#subClassOf"),this.sym(i))).length;r<o;r++)if(a[r].uri in e){n=!1;break}n&&(t[i]=s)}return t}},{key:"collection",value:function(){return new l}},{key:"each",value:function(e,t,n,r){var i,o,a,s,u,c,l,f,h,p=[],d=this.statementsMatching(e,t,n,r,!1);if(null==e)for(o=0,c=d.length;o<c;o++)i=d[o],p.push(i.subject);else if(null==t)for(a=0,l=d.length;a<l;a++)i=d[a],p.push(i.predicate);else if(null==n)for(s=0,f=d.length;s<f;s++)i=d[s],p.push(i.object);else if(null==r)for(u=0,h=d.length;u<h;u++)i=d[u],p.push(i.why);return p}},{key:"equals",value:function(e){return!!e&&this.hashString()===e.hashString()}},{key:"findMembersNT",value:function(e){var t,n,r,i,o,a,s,u,c,l,f,h,p,d,y,v,g,m,w,b,x;for(b in(m={})[e.toNT()]=!0,c={},h=this.transitiveClosure(m,this.sym("http://www.w3.org/2000/01/rdf-schema#subClassOf"),!0))if(h.hasOwnProperty(b)){for(t=0,r=(p=this.statementsMatching(void 0,this.sym("http://www.w3.org/1999/02/22-rdf-syntax-ns#type"),this.fromNT(b))).length;t<r;t++)c[(w=p[t]).subject.toNT()]=w;for(n=0,i=(d=this.each(void 0,this.sym("http://www.w3.org/2000/01/rdf-schema#domain"),this.fromNT(b))).length;n<i;n++)for(l=d[n],u=0,o=(y=this.statementsMatching(void 0,l)).length;u<o;u++)c[(w=y[u]).subject.toNT()]=w;for(f=0,a=(v=this.each(void 0,this.sym("http://www.w3.org/2000/01/rdf-schema#range"),this.fromNT(b))).length;f<a;f++)for(l=v[f],x=0,s=(g=this.statementsMatching(void 0,l)).length;x<s;x++)c[(w=g[x]).object.toNT()]=w}return c}},{key:"findMemberURIs",value:function(e){return this.NTtoURI(this.findMembersNT(e))}},{key:"findSubClassesNT",value:function(e){var t={};return t[e.toNT()]=!0,this.transitiveClosure(t,this.sym("http://www.w3.org/2000/01/rdf-schema#subClassOf"),!0)}},{key:"findSuperClassesNT",value:function(e){var t={};return t[e.toNT()]=!0,this.transitiveClosure(t,this.sym("http://www.w3.org/2000/01/rdf-schema#subClassOf"),!1)}},{key:"findTypesNT",value:function(e){var t,n,r,i,o,a,s,u,c,l,f,h,p,d;for("http://www.w3.org/1999/02/22-rdf-syntax-ns#type",d=[],t=0,r=(c=this.statementsMatching(e,void 0,void 0)).length;t<r;t++)if("http://www.w3.org/1999/02/22-rdf-syntax-ns#type"===(p=c[t]).predicate.uri)d[p.object.toNT()]=p;else for(n=0,i=(l=this.each(p.predicate,this.sym("http://www.w3.org/2000/01/rdf-schema#domain"))).length;n<i;n++)d[l[n].toNT()]=p;for(s=0,o=(f=this.statementsMatching(void 0,void 0,e)).length;s<o;s++)for(p=f[s],u=0,a=(h=this.each(p.predicate,this.sym("http://www.w3.org/2000/01/rdf-schema#range"))).length;u<a;u++)d[h[u].toNT()]=p;return this.transitiveClosure(d,this.sym("http://www.w3.org/2000/01/rdf-schema#subClassOf"),!1)}},{key:"findTypeURIs",value:function(e){return this.NTtoURI(this.findTypesNT(e))}},{key:"connectedStatements",value:function(e,t,n){n=n||[];for(var r=[e],i=[],o=[],a=[],s=this,u=function(e){var u=function(e){"BlankNode"!==e.termType||i[e.value]||(i[e.value]=!0,r.push(e))},c=s.statementsMatching(null,null,e,t).concat(s.statementsMatching(e,null,null,t));(c=c.filter(function(e){if(n[e.predicate.uri])return!1;var t=e.toNT();return!o[t]&&(o[t]=!0,!0)})).forEach(function(e,t){u(e.subject),u(e.object)}),a=a.concat(c)};r.length;)u(r.shift());return a}},{key:"formula",value:function(){return new t}},{key:"fromNT",value:function(e){var t,n,r;switch(e[0]){case"<":return this.sym(e.slice(1,-1));case'"':if(r=void 0,t=void 0,(n=e.lastIndexOf('"'))<e.length-1)if("@"===e[n+1])r=e.slice(n+2);else{if("^^"!==e.slice(n+1,n+3))throw new Error("Can't convert string from NT: "+e);t=this.fromNT(e.slice(n+3))}return e=(e=(e=(e=e.slice(1,n)).replace(/\\"/g,'"')).replace(/\\n/g,"\n")).replace(/\\\\/g,"\\"),this.literal(e,r,t);case"_":return new u(e.slice(2));case"?":return new g(e.slice(1))}throw new Error("Can't convert from NT: "+e)}},{key:"holds",value:function(e,t,n,r){var i;if(1===arguments.length){if(!e)return!0;if(e instanceof Array){for(i=0;i<e.length;i++)if(!this.holds(e[i]))return!1;return!0}if(e instanceof v)return this.holds(e.subject,e.predicate,e.object,e.why);if(e.statements)return this.holds(e.statements)}return null!=this.anyStatementMatching(e,t,n,r)}},{key:"holdsStatement",value:function(e){return this.holds(e.subject,e.predicate,e.object,e.why)}},{key:"list",value:function(e){var t=new l;return e.forEach(function(e){t.append(e)}),t}},{key:"literal",value:function(e,t,n){return new f(""+e,t,n)}},{key:"NTtoURI",value:function(e){var t,n,r={};for(t in e)e.hasOwnProperty(t)&&(n=e[t],"<"===t[0]&&(r[t.slice(1,-1)]=n));return r}},{key:"serialize",value:function(e,t,n){var r,i,o;switch((o=y(this)).suggestNamespaces(this.namespaces),o.setBase(e),i=n?this.statementsMatching(void 0,void 0,void 0,n):this.statements,null!=t?t:"text/n3"){case"application/rdf+xml":r=o.statementsToXML(i);break;case"text/n3":case"text/turtle":r=o.statementsToN3(i);break;default:throw new Error("serialize: Content-type "+t+" not supported.")}return r}},{key:"substitute",value:function(e){var n=this.statements.map(function(t){return t.substitute(e)});console.log("Formula subs statmnts:"+n);var r=new t;return r.add(n),console.log("indexed-form subs formula:"+r),r}},{key:"sym",value:function(e,t){if(t)throw new Error("This feature (kb.sym with 2 args) is removed. Do not assume prefix mappings.");return new p(e)}},{key:"the",value:function(e,t,n,r){var i=this.any(e,t,n,r);return null==i&&h.error("No value found for the() {"+e+" "+t+" "+n+"}."),i}},{key:"transitiveClosure",value:function(e,t,n){var r,i,o,a,s,u={};Object.assign(u,e);for(var c={};;){if(null==(s=function(){for(var e in u)if(u.hasOwnProperty(e))return e}()))return c;for(r=0,i=(a=n?this.each(void 0,t,this.fromNT(s)):this.each(this.fromNT(s),t)).length;r<i;r++)(o=a[r].toNT())in c||o in u||(u[o]=u[s]);c[s]=u[s],delete u[s]}}},{key:"topTypeURIs",value:function(e){var t,n,r,i,o,a,s;for(n in a=[],e)if(e.hasOwnProperty(n)){for(s=e[n],i=0,t=0,r=(o=this.each(this.sym(n),this.sym("http://www.w3.org/2000/01/rdf-schema#subClassOf"))).length;t<r;t++)if("http://www.w3.org/2000/01/rdf-schema#Resource"!==o[t].uri){i++;break}i||(a[n]=s)}return a["http://www.w3.org/2000/01/rdf-schema#Resource"]&&delete a["http://www.w3.org/2000/01/rdf-schema#Resource"],a["http://www.w3.org/2002/07/owl#Thing"]&&delete a["http://www.w3.org/2002/07/owl#Thing"],a}},{key:"toString",value:function(){return"{"+this.statements.join("\n")+"}"}},{key:"whether",value:function(e,t,n,r){return this.statementsMatching(e,t,n,r,!1).length}}])&&i(n.prototype,r),c&&i(n,c),t}();m.termType="Graph",m.prototype.classOrder=c.Graph,m.prototype.isVar=0,m.prototype.ns=n(16),m.prototype.variable=function(e){return new g(e)},e.exports=m},function(e,t,n){"use strict";e.exports=function e(t,n,p,d,y){d=d||"text/turtle";d=d.split(";")[0];try{if("text/n3"===d||"text/turtle"===d){var v=s(n,n,p,p,null,null,"",null);v.loadBuf(t),x()}else if("application/rdf+xml"===d){var g=new l(n);g.parse(h.parseXML(t),p,n.sym(p)),x()}else if("application/xhtml+xml"===d)c(h.parseXML(t,{contentType:"application/xhtml+xml"}),n,p),x();else if("text/html"===d)c(h.parseXML(t,{contentType:"text/html"}),n,p),x();else if("application/sparql-update"===d)f(t,n,p),x();else{if("application/ld+json"!==d&&"application/nquads"!==d&&"application/n-quads"!==d)throw new Error("Don't know how to parse "+d+" yet");var m=a.Parser(),w=[];if("application/ld+json"===d){var b;try{b=JSON.parse(t)}catch(e){return y(e,null)}i.toRDF(b,{format:"application/nquads",base:p},_)}else _(null,t)}}catch(e){!function(e){if("application/ld+json"!==d||"application/nquads"!==d||"application/n-quads"!==d){if(!y){var t=new Error(e+" while trying to parse <"+p+"> as "+d);throw t.cause=e,t}y(e,n)}}(e)}e.handled={"text/n3":!0,"text/turtle":!0,"application/rdf+xml":!0,"application/xhtml+xml":!0,"text/html":!0,"application/sparql-update":!0,"application/ld+json":!0,"application/nquads":!0,"application/n-quads":!0};function x(){y&&y(null,n)}function _(e,t){e&&y(e,n);try{m.parse(t,k)}catch(e){y(e,n)}}function k(e,t,r){if(e&&y(e,n),t)w.push(t);else{for(var i=0;i<w.length;i++)S(n,w[i]);y(null,n)}}function S(e,t){var n=T(t.subject),r=T(t.predicate),i=T(t.object),o=null;t.graph&&(o=T(t.graph)),e.add(n,r,i,o)}function T(e){var t;if(a.Util.isLiteral(e)){t=a.Util.getLiteralValue(e);var n=a.Util.getLiteralLanguage(e),i=new u(a.Util.getLiteralType(e));return new o(t,n,i)}return a.Util.isIRI(e)?new u(e):a.Util.isBlank(e)?(t=e.substring(2,e.length),new r(t)):null}};var r=n(9),i=n(43),o=n(15),a=n(45),s=n(27),u=n(2),c=n(39).parseRDFaDOM,l=n(40),f=n(61),h=n(6)},function(e,t,n){"use strict";e.exports=function(e,t,n){var o,a,s,u=["INSERT","DELETE","WHERE"],c=i("http://www.w3.org/ns/pim/patch#"),l=r(t,t,n,n,null,null,"",null),f={},h=function(e,t,n,r,i){return"Line "+(t+1)+" of <"+e+">: Bad syntax:\n   "+i+'\n   at: "'+n.slice(r,r+30)+'"'};o=0;var p=t.sym(n+"#query");f.query=p;for(;;){if((a=l.skipSpace(e,o))<0)return f;if(";"===e[a]){if((o=l.skipSpace(e,a+1))<0)return f;a=o}var d=!1;for(s=0;s<u.length;s++){var y=u[s];if(e.slice(a,a+y.length)===y){if((o=l.skipSpace(e,a+y.length))<0)throw h(l._thisDoc,l.lines,e,a+y.length,"found EOF, needed {...} after "+y);if(("INSERT"===y||"DELETE"===y)&&"DATA"===e.slice(o,o+4)){if((a=l.skipSpace(e,o+4))<0)throw h(l._thisDoc,l.lines,e,o+4,"needed {...} after INSERT DATA "+y);o=a}var v=[];if((a=l.node(e,o,v))<0)throw h(l._thisDoc,l.lines,e,o,"bad syntax or EOF in {...} after "+y);f[y.toLowerCase()]=v[0],t.add(p,c(y.toLowerCase()),v[0]),d=!0,o=a}}if(!d&&"@prefix"===e.slice(a,a+7)){if((o=l.directive(e,a))<0)throw h(l._thisDoc,l.lines,e,o,"bad syntax or EOF after @prefix ");o=l.checkDot(e,o),d=!0}if(!d)throw h(l._thisDoc,l.lines,e,a,"Unknown syntax at start of statememt: '"+e.slice(a).slice(0,20)+"'")}};var r=n(27),i=n(16)},function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function o(e,t,n){return t&&i(e.prototype,t),n&&i(e,n),e}var a=n(24).namedNode,s=function(){function e(t,n){r(this,e),this.parent=t,this.via=n,this.connected=!1,this.pending={},this.subscribed={},this.socket={};try{this.socket=new WebSocket(n),this.socket.onopen=this.onOpen,this.socket.onclose=this.onClose,this.socket.onmessage=this.onMessage,this.socket.onerror=this.onError}catch(e){this.onError(e)}}return o(e,[{key:"_decode",value:function(e){var t,n,r,i,o,a,s;for(n in i={},o=function(){var n,r,i,o;for(o=[],n=0,r=(i=e.split("&")).length;n<r;n++)t=i[n],o.push(t.split("="));return o}())t=o[n],s=(a=[decodeURIComponent(t[0]),decodeURIComponent(t[1])])[1],null==i[r=a[0]]&&(i[r]=[]),i[r].push(s);return i}},{key:"_send",value:function(e,t,n){var r,i;return i=[e,t,n].join(" "),"function"==typeof(r=this.socket).send?r.send(i):void 0}},{key:"_subscribe",value:function(e){return this._send("sub",e,""),this.subscribed[e]=!0,this.subscribed[e]}},{key:"onClose",value:function(e){var t;for(t in this.connected=!1,this.subscribed)this.pending[t]=!0;return this.subscribed={},this.subscribed}},{key:"onError",value:function(e){throw new Error("onError"+e)}},{key:"onMessage",value:function(e){var t,n;return"ping"===(n=e.data.split(" "))[0]?"function"==typeof(t=this.socket).send?t.send("pong "+n.slice(1).join(" ")):void 0:"pub"===n[0]?this.parent.onUpdate(n[1],this._decode(n[2])):void 0}},{key:"onOpen",value:function(e){var t,n;for(n in this.connected=!0,t=[],this.pending)delete this.pending[n],t.push(this._subscribe(n));return t}},{key:"subscribe",value:function(e){return this.connected?this._subscribe(e):(this.pending[e]=!0,this.pending[e])}}]),e}(),u=function(){function e(t){r(this,e),this.fetcher=t,this.graph={},this.via={},this.fetcher.addCallback("headers",this.onHeaders)}return o(e,[{key:"onHeaders",value:function(e){var t,n,r;return null==e.headers||("undefined"==typeof WebSocket||null===WebSocket||(t=e.headers.etag,r=e.headers["updates-via"],n=e.uri,t&&r&&(this.graph[n]={etag:t,via:r},this.register(r,n)),!0))}},{key:"onUpdate",value:function(e,t){return this.fetcher.refresh(a(e))}},{key:"register",value:function(e,t){return null==this.via[e]&&(this.via[e]=new s(this,e)),this.via[e].subscribe(t)}}]),e}();e.exports.UpdatesSocket=s,e.exports.UpdatesVia=u},function(e,t,n){var r=function(){return this||"object"==typeof self&&self}()||Function("return this")(),i=r.regeneratorRuntime&&Object.getOwnPropertyNames(r).indexOf("regeneratorRuntime")>=0,o=i&&r.regeneratorRuntime;if(r.regeneratorRuntime=void 0,e.exports=n(64),i)r.regeneratorRuntime=o;else try{delete r.regeneratorRuntime}catch(e){r.regeneratorRuntime=void 0}},function(e,t){!function(t){"use strict";var n,r=Object.prototype,i=r.hasOwnProperty,o="function"==typeof Symbol?Symbol:{},a=o.iterator||"@@iterator",s=o.asyncIterator||"@@asyncIterator",u=o.toStringTag||"@@toStringTag",c="object"==typeof e,l=t.regeneratorRuntime;if(l)c&&(e.exports=l);else{(l=t.regeneratorRuntime=c?e.exports:{}).wrap=b;var f="suspendedStart",h="suspendedYield",p="executing",d="completed",y={},v={};v[a]=function(){return this};var g=Object.getPrototypeOf,m=g&&g(g(R([])));m&&m!==r&&i.call(m,a)&&(v=m);var w=S.prototype=_.prototype=Object.create(v);k.prototype=w.constructor=S,S.constructor=k,S[u]=k.displayName="GeneratorFunction",l.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===k||"GeneratorFunction"===(t.displayName||t.name))},l.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,S):(e.__proto__=S,u in e||(e[u]="GeneratorFunction")),e.prototype=Object.create(w),e},l.awrap=function(e){return{__await:e}},T(E.prototype),E.prototype[s]=function(){return this},l.AsyncIterator=E,l.async=function(e,t,n,r){var i=new E(b(e,t,n,r));return l.isGeneratorFunction(t)?i:i.next().then(function(e){return e.done?e.value:i.next()})},T(w),w[u]="Generator",w[a]=function(){return this},w.toString=function(){return"[object Generator]"},l.keys=function(e){var t=[];for(var n in e)t.push(n);return t.reverse(),function n(){for(;t.length;){var r=t.pop();if(r in e)return n.value=r,n.done=!1,n}return n.done=!0,n}},l.values=R,I.prototype={constructor:I,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=n,this.done=!1,this.delegate=null,this.method="next",this.arg=n,this.tryEntries.forEach(N),!e)for(var t in this)"t"===t.charAt(0)&&i.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=n)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function r(r,i){return s.type="throw",s.arg=e,t.next=r,i&&(t.method="next",t.arg=n),!!i}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],s=a.completion;if("root"===a.tryLoc)return r("end");if(a.tryLoc<=this.prev){var u=i.call(a,"catchLoc"),c=i.call(a,"finallyLoc");if(u&&c){if(this.prev<a.catchLoc)return r(a.catchLoc,!0);if(this.prev<a.finallyLoc)return r(a.finallyLoc)}else if(u){if(this.prev<a.catchLoc)return r(a.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return r(a.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var r=this.tryEntries[n];if(r.tryLoc<=this.prev&&i.call(r,"finallyLoc")&&this.prev<r.finallyLoc){var o=r;break}}o&&("break"===e||"continue"===e)&&o.tryLoc<=t&&t<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=e,a.arg=t,o?(this.method="next",this.next=o.finallyLoc,y):this.complete(a)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),y},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),N(n),y}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var i=r.arg;N(n)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:R(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=n),y}}}function b(e,t,n,r){var i=t&&t.prototype instanceof _?t:_,o=Object.create(i.prototype),a=new I(r||[]);return o._invoke=function(e,t,n){var r=f;return function(i,o){if(r===p)throw new Error("Generator is already running");if(r===d){if("throw"===i)throw o;return A()}for(n.method=i,n.arg=o;;){var a=n.delegate;if(a){var s=O(a,n);if(s){if(s===y)continue;return s}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(r===f)throw r=d,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);r=p;var u=x(e,t,n);if("normal"===u.type){if(r=n.done?d:h,u.arg===y)continue;return{value:u.arg,done:n.done}}"throw"===u.type&&(r=d,n.method="throw",n.arg=u.arg)}}}(e,n,a),o}function x(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}function _(){}function k(){}function S(){}function T(e){["next","throw","return"].forEach(function(t){e[t]=function(e){return this._invoke(t,e)}})}function E(e){var t;this._invoke=function(n,r){function o(){return new Promise(function(t,o){!function t(n,r,o,a){var s=x(e[n],e,r);if("throw"!==s.type){var u=s.arg,c=u.value;return c&&"object"==typeof c&&i.call(c,"__await")?Promise.resolve(c.__await).then(function(e){t("next",e,o,a)},function(e){t("throw",e,o,a)}):Promise.resolve(c).then(function(e){u.value=e,o(u)},function(e){return t("throw",e,o,a)})}a(s.arg)}(n,r,t,o)})}return t=t?t.then(o,o):o()}}function O(e,t){var r=e.iterator[t.method];if(r===n){if(t.delegate=null,"throw"===t.method){if(e.iterator.return&&(t.method="return",t.arg=n,O(e,t),"throw"===t.method))return y;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method")}return y}var i=x(r,e.iterator,t.arg);if("throw"===i.type)return t.method="throw",t.arg=i.arg,t.delegate=null,y;var o=i.arg;return o?o.done?(t[e.resultName]=o.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=n),t.delegate=null,y):o:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,y)}function j(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function N(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function I(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(j,this),this.reset(!0)}function R(e){if(e){var t=e[a];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var r=-1,o=function t(){for(;++r<e.length;)if(i.call(e,r))return t.value=e[r],t.done=!1,t;return t.value=n,t.done=!0,t};return o.next=o}}return{next:A}}function A(){return{value:n,done:!0}}}(function(){return this||"object"==typeof self&&self}()||Function("return this")())},function(e,t,n){(function(n,r){var i;
  /*!
   * async
   * https://github.com/caolan/async
   *
   * Copyright 2010-2014 Caolan McMahon
   * Released under the MIT license
   */
  /*!
   * async
   * https://github.com/caolan/async
   *
   * Copyright 2010-2014 Caolan McMahon
   * Released under the MIT license
   */
  !function(){var o,a,s={};function u(e){var t=!1;return function(){if(t)throw new Error("Callback was already called.");t=!0,e.apply(o,arguments)}}null!=(o=this)&&(a=o.async),s.noConflict=function(){return o.async=a,s};var c=Object.prototype.toString,l=Array.isArray||function(e){return"[object Array]"===c.call(e)},f=function(e,t){for(var n=0;n<e.length;n+=1)t(e[n],n,e)},h=function(e,t){if(e.map)return e.map(t);var n=[];return f(e,function(e,r,i){n.push(t(e,r,i))}),n},p=function(e){if(Object.keys)return Object.keys(e);var t=[];for(var n in e)e.hasOwnProperty(n)&&t.push(n);return t};void 0!==n&&n.nextTick?(s.nextTick=n.nextTick,s.setImmediate=void 0!==r?function(e){r(e)}:s.nextTick):"function"==typeof r?(s.nextTick=function(e){r(e)},s.setImmediate=s.nextTick):(s.nextTick=function(e){setTimeout(e,0)},s.setImmediate=s.nextTick),s.each=function(e,t,n){if(n=n||function(){},!e.length)return n();var r=0;function i(t){t?(n(t),n=function(){}):(r+=1)>=e.length&&n()}f(e,function(e){t(e,u(i))})},s.forEach=s.each,s.eachSeries=function(e,t,n){if(n=n||function(){},!e.length)return n();var r=0,i=function(){t(e[r],function(t){t?(n(t),n=function(){}):(r+=1)>=e.length?n():i()})};i()},s.forEachSeries=s.eachSeries,s.eachLimit=function(e,t,n,r){d(t).apply(null,[e,n,r])},s.forEachLimit=s.eachLimit;var d=function(e){return function(t,n,r){if(r=r||function(){},!t.length||e<=0)return r();var i=0,o=0,a=0;!function s(){if(i>=t.length)return r();for(;a<e&&o<t.length;)a+=1,n(t[(o+=1)-1],function(e){e?(r(e),r=function(){}):(a-=1,(i+=1)>=t.length?r():s())})}()}},y=function(e){return function(){var t=Array.prototype.slice.call(arguments);return e.apply(null,[s.each].concat(t))}},v=function(e){return function(){var t=Array.prototype.slice.call(arguments);return e.apply(null,[s.eachSeries].concat(t))}},g=function(e,t,n,r){if(t=h(t,function(e,t){return{index:t,value:e}}),r){var i=[];e(t,function(e,t){n(e.value,function(n,r){i[e.index]=r,t(n)})},function(e){r(e,i)})}else e(t,function(e,t){n(e.value,function(e){t(e)})})};s.map=y(g),s.mapSeries=v(g),s.mapLimit=function(e,t,n,r){return m(t)(e,n,r)};var m=function(e){return function(e,t){return function(){var n=Array.prototype.slice.call(arguments);return t.apply(null,[d(e)].concat(n))}}(e,g)};s.reduce=function(e,t,n,r){s.eachSeries(e,function(e,r){n(t,e,function(e,n){t=n,r(e)})},function(e){r(e,t)})},s.inject=s.reduce,s.foldl=s.reduce,s.reduceRight=function(e,t,n,r){var i=h(e,function(e){return e}).reverse();s.reduce(i,t,n,r)},s.foldr=s.reduceRight;var w=function(e,t,n,r){var i=[];e(t=h(t,function(e,t){return{index:t,value:e}}),function(e,t){n(e.value,function(n){n&&i.push(e),t()})},function(e){r(h(i.sort(function(e,t){return e.index-t.index}),function(e){return e.value}))})};s.filter=y(w),s.filterSeries=v(w),s.select=s.filter,s.selectSeries=s.filterSeries;var b=function(e,t,n,r){var i=[];e(t=h(t,function(e,t){return{index:t,value:e}}),function(e,t){n(e.value,function(n){n||i.push(e),t()})},function(e){r(h(i.sort(function(e,t){return e.index-t.index}),function(e){return e.value}))})};s.reject=y(b),s.rejectSeries=v(b);var x=function(e,t,n,r){e(t,function(e,t){n(e,function(n){n?(r(e),r=function(){}):t()})},function(e){r()})};s.detect=y(x),s.detectSeries=v(x),s.some=function(e,t,n){s.each(e,function(e,r){t(e,function(e){e&&(n(!0),n=function(){}),r()})},function(e){n(!1)})},s.any=s.some,s.every=function(e,t,n){s.each(e,function(e,r){t(e,function(e){e||(n(!1),n=function(){}),r()})},function(e){n(!0)})},s.all=s.every,s.sortBy=function(e,t,n){s.map(e,function(e,n){t(e,function(t,r){t?n(t):n(null,{value:e,criteria:r})})},function(e,t){if(e)return n(e);n(null,h(t.sort(function(e,t){var n=e.criteria,r=t.criteria;return n<r?-1:n>r?1:0}),function(e){return e.value}))})},s.auto=function(e,t){t=t||function(){};var n=p(e),r=n.length;if(!r)return t();var i={},o=[],a=function(e){o.unshift(e)},u=function(){r--,f(o.slice(0),function(e){e()})};a(function(){if(!r){var e=t;t=function(){},e(null,i)}}),f(n,function(n){var r=l(e[n])?e[n]:[e[n]],c=function(e){var r=Array.prototype.slice.call(arguments,1);if(r.length<=1&&(r=r[0]),e){var o={};f(p(i),function(e){o[e]=i[e]}),o[n]=r,t(e,o),t=function(){}}else i[n]=r,s.setImmediate(u)},h=r.slice(0,Math.abs(r.length-1))||[],d=function(){return t=function(e,t){return e&&i.hasOwnProperty(t)},r=!0,((e=h).reduce?e.reduce(t,r):(f(e,function(e,n,i){r=t(r,e,n,i)}),r))&&!i.hasOwnProperty(n);var e,t,r};if(d())r[r.length-1](c,i);else{var y=function(){d()&&(!function(e){for(var t=0;t<o.length;t+=1)if(o[t]===e)return void o.splice(t,1)}(y),r[r.length-1](c,i))};a(y)}})},s.retry=function(e,t,n){var r=[];"function"==typeof e&&(n=t,t=e,e=5),e=parseInt(e,10)||5;var i=function(i,o){for(var a=function(e,t){return function(n){e(function(e,r){n(!e||t,{err:e,result:r})},o)}};e;)r.push(a(t,!(e-=1)));s.series(r,function(e,t){t=t[t.length-1],(i||n)(t.err,t.result)})};return n?i():i},s.waterfall=function(e,t){if(t=t||function(){},!l(e)){var n=new Error("First argument to waterfall must be an array of functions");return t(n)}if(!e.length)return t();var r=function(e){return function(n){if(n)t.apply(null,arguments),t=function(){};else{var i=Array.prototype.slice.call(arguments,1),o=e.next();o?i.push(r(o)):i.push(t),s.setImmediate(function(){e.apply(null,i)})}}};r(s.iterator(e))()};var _=function(e,t,n){if(n=n||function(){},l(t))e.map(t,function(e,t){e&&e(function(e){var n=Array.prototype.slice.call(arguments,1);n.length<=1&&(n=n[0]),t.call(null,e,n)})},n);else{var r={};e.each(p(t),function(e,n){t[e](function(t){var i=Array.prototype.slice.call(arguments,1);i.length<=1&&(i=i[0]),r[e]=i,n(t)})},function(e){n(e,r)})}};s.parallel=function(e,t){_({map:s.map,each:s.each},e,t)},s.parallelLimit=function(e,t,n){_({map:m(t),each:d(t)},e,n)},s.series=function(e,t){if(t=t||function(){},l(e))s.mapSeries(e,function(e,t){e&&e(function(e){var n=Array.prototype.slice.call(arguments,1);n.length<=1&&(n=n[0]),t.call(null,e,n)})},t);else{var n={};s.eachSeries(p(e),function(t,r){e[t](function(e){var i=Array.prototype.slice.call(arguments,1);i.length<=1&&(i=i[0]),n[t]=i,r(e)})},function(e){t(e,n)})}},s.iterator=function(e){var t=function(n){var r=function(){return e.length&&e[n].apply(null,arguments),r.next()};return r.next=function(){return n<e.length-1?t(n+1):null},r};return t(0)},s.apply=function(e){var t=Array.prototype.slice.call(arguments,1);return function(){return e.apply(null,t.concat(Array.prototype.slice.call(arguments)))}};var k=function(e,t,n,r){var i=[];e(t,function(e,t){n(e,function(e,n){i=i.concat(n||[]),t(e)})},function(e){r(e,i)})};s.concat=y(k),s.concatSeries=v(k),s.whilst=function(e,t,n){e()?t(function(r){if(r)return n(r);s.whilst(e,t,n)}):n()},s.doWhilst=function(e,t,n){e(function(r){if(r)return n(r);var i=Array.prototype.slice.call(arguments,1);t.apply(null,i)?s.doWhilst(e,t,n):n()})},s.until=function(e,t,n){e()?n():t(function(r){if(r)return n(r);s.until(e,t,n)})},s.doUntil=function(e,t,n){e(function(r){if(r)return n(r);var i=Array.prototype.slice.call(arguments,1);t.apply(null,i)?n():s.doUntil(e,t,n)})},s.queue=function(e,t){function n(e,t,n,r){if(e.started||(e.started=!0),l(t)||(t=[t]),0==t.length)return s.setImmediate(function(){e.drain&&e.drain()});f(t,function(t){var i={data:t,callback:"function"==typeof r?r:null};n?e.tasks.unshift(i):e.tasks.push(i),e.saturated&&e.tasks.length===e.concurrency&&e.saturated(),s.setImmediate(e.process)})}void 0===t&&(t=1);var r=0,i={tasks:[],concurrency:t,saturated:null,empty:null,drain:null,started:!1,paused:!1,push:function(e,t){n(i,e,!1,t)},kill:function(){i.drain=null,i.tasks=[]},unshift:function(e,t){n(i,e,!0,t)},process:function(){if(!i.paused&&r<i.concurrency&&i.tasks.length){var t=i.tasks.shift();i.empty&&0===i.tasks.length&&i.empty(),r+=1;var n=u(function(){r-=1,t.callback&&t.callback.apply(t,arguments),i.drain&&i.tasks.length+r===0&&i.drain(),i.process()});e(t.data,n)}},length:function(){return i.tasks.length},running:function(){return r},idle:function(){return i.tasks.length+r===0},pause:function(){!0!==i.paused&&(i.paused=!0)},resume:function(){if(!1!==i.paused){i.paused=!1;for(var e=1;e<=i.concurrency;e++)s.setImmediate(i.process)}}};return i},s.priorityQueue=function(e,t){function n(e,t){return e.priority-t.priority}var r=s.queue(e,t);return r.push=function(e,t,i){!function(e,t,r,i){if(e.started||(e.started=!0),l(t)||(t=[t]),0==t.length)return s.setImmediate(function(){e.drain&&e.drain()});f(t,function(t){var o={data:t,priority:r,callback:"function"==typeof i?i:null};e.tasks.splice(function(e,t,n){for(var r=-1,i=e.length-1;r<i;){var o=r+(i-r+1>>>1);n(t,e[o])>=0?r=o:i=o-1}return r}(e.tasks,o,n)+1,0,o),e.saturated&&e.tasks.length===e.concurrency&&e.saturated(),s.setImmediate(e.process)})}(r,e,t,i)},delete r.unshift,r},s.cargo=function(e,t){var n=!1,r=[],i={tasks:r,payload:t,saturated:null,empty:null,drain:null,drained:!0,push:function(e,n){l(e)||(e=[e]),f(e,function(e){r.push({data:e,callback:"function"==typeof n?n:null}),i.drained=!1,i.saturated&&r.length===t&&i.saturated()}),s.setImmediate(i.process)},process:function o(){if(!n){if(0===r.length)return i.drain&&!i.drained&&i.drain(),void(i.drained=!0);var a="number"==typeof t?r.splice(0,t):r.splice(0,r.length),s=h(a,function(e){return e.data});i.empty&&i.empty(),n=!0,e(s,function(){n=!1;var e=arguments;f(a,function(t){t.callback&&t.callback.apply(null,e)}),o()})}},length:function(){return r.length},running:function(){return n}};return i};var S=function(e){return function(t){var n=Array.prototype.slice.call(arguments,1);t.apply(null,n.concat([function(t){var n=Array.prototype.slice.call(arguments,1);"undefined"!=typeof console&&(t?console.error&&console.error(t):console[e]&&f(n,function(t){console[e](t)}))}]))}};s.log=S("log"),s.dir=S("dir"),s.memoize=function(e,t){var n={},r={};t=t||function(e){return e};var i=function(){var i=Array.prototype.slice.call(arguments),o=i.pop(),a=t.apply(null,i);a in n?s.nextTick(function(){o.apply(null,n[a])}):a in r?r[a].push(o):(r[a]=[o],e.apply(null,i.concat([function(){n[a]=arguments;var e=r[a];delete r[a];for(var t=0,i=e.length;t<i;t++)e[t].apply(null,arguments)}])))};return i.memo=n,i.unmemoized=e,i},s.unmemoize=function(e){return function(){return(e.unmemoized||e).apply(null,arguments)}},s.times=function(e,t,n){for(var r=[],i=0;i<e;i++)r.push(i);return s.map(r,t,n)},s.timesSeries=function(e,t,n){for(var r=[],i=0;i<e;i++)r.push(i);return s.mapSeries(r,t,n)},s.seq=function(){var e=arguments;return function(){var t=this,n=Array.prototype.slice.call(arguments),r=n.pop();s.reduce(e,n,function(e,n,r){n.apply(t,e.concat([function(){var e=arguments[0],t=Array.prototype.slice.call(arguments,1);r(e,t)}]))},function(e,n){r.apply(t,[e].concat(n))})}},s.compose=function(){return s.seq.apply(null,Array.prototype.reverse.call(arguments))};var T=function(e,t){var n=function(){var n=this,r=Array.prototype.slice.call(arguments),i=r.pop();return e(t,function(e,t){e.apply(n,r.concat([t]))},i)};if(arguments.length>2){var r=Array.prototype.slice.call(arguments,2);return n.apply(this,r)}return n};s.applyEach=y(T),s.applyEachSeries=v(T),s.forever=function(e,t){!function n(r){if(r){if(t)return t(r);throw r}e(n)}()},e.exports?e.exports=s:void 0===(i=function(){return s}.apply(t,[]))||(e.exports=i)}()}).call(this,n(7),n(17).setImmediate)},function(e,t,n){(function(e,t){!function(e,n){"use strict";if(!e.setImmediate){var r,i,o,a,s,u=1,c={},l=!1,f=e.document,h=Object.getPrototypeOf&&Object.getPrototypeOf(e);h=h&&h.setTimeout?h:e,"[object process]"==={}.toString.call(e.process)?r=function(e){t.nextTick(function(){d(e)})}:!function(){if(e.postMessage&&!e.importScripts){var t=!0,n=e.onmessage;return e.onmessage=function(){t=!1},e.postMessage("","*"),e.onmessage=n,t}}()?e.MessageChannel?((o=new MessageChannel).port1.onmessage=function(e){d(e.data)},r=function(e){o.port2.postMessage(e)}):f&&"onreadystatechange"in f.createElement("script")?(i=f.documentElement,r=function(e){var t=f.createElement("script");t.onreadystatechange=function(){d(e),t.onreadystatechange=null,i.removeChild(t),t=null},i.appendChild(t)}):r=function(e){setTimeout(d,0,e)}:(a="setImmediate$"+Math.random()+"$",s=function(t){t.source===e&&"string"==typeof t.data&&0===t.data.indexOf(a)&&d(+t.data.slice(a.length))},e.addEventListener?e.addEventListener("message",s,!1):e.attachEvent("onmessage",s),r=function(t){e.postMessage(a+t,"*")}),h.setImmediate=function(e){"function"!=typeof e&&(e=new Function(""+e));for(var t=new Array(arguments.length-1),n=0;n<t.length;n++)t[n]=arguments[n+1];var i={callback:e,args:t};return c[u]=i,r(u),u++},h.clearImmediate=p}function p(e){delete c[e]}function d(e){if(l)setTimeout(d,0,e);else{var t=c[e];if(t){l=!0;try{!function(e){var t=e.callback,r=e.args;switch(r.length){case 0:t();break;case 1:t(r[0]);break;case 2:t(r[0],r[1]);break;case 3:t(r[0],r[1],r[2]);break;default:t.apply(n,r)}}(t)}finally{p(e),l=!1}}}}}("undefined"==typeof self?void 0===e?this:e:self)}).call(this,n(8),n(7))},function(e,t){},function(e,t){(function(t){e.exports=t}).call(this,{})},function(e,t,n){var r={"./N3Lexer":29,"./N3Lexer.js":29,"./N3Parser":30,"./N3Parser.js":30,"./N3Store":46,"./N3Store.js":46,"./N3StreamParser":47,"./N3StreamParser.js":47,"./N3StreamWriter":57,"./N3StreamWriter.js":57,"./N3Util":31,"./N3Util.js":31,"./N3Writer":35,"./N3Writer.js":35};function i(e){var t=o(e);return n(t)}function o(e){var t=r[e];if(!(t+1)){var n=new Error("Cannot find module '"+e+"'");throw n.code="MODULE_NOT_FOUND",n}return t}i.keys=function(){return Object.keys(r)},i.resolve=o,e.exports=i,i.id=69},function(e,t,n){"use strict";t.byteLength=function(e){var t=c(e),n=t[0],r=t[1];return 3*(n+r)/4-r},t.toByteArray=function(e){for(var t,n=c(e),r=n[0],a=n[1],s=new o(function(e,t,n){return 3*(t+n)/4-n}(0,r,a)),u=0,l=a>0?r-4:r,f=0;f<l;f+=4)t=i[e.charCodeAt(f)]<<18|i[e.charCodeAt(f+1)]<<12|i[e.charCodeAt(f+2)]<<6|i[e.charCodeAt(f+3)],s[u++]=t>>16&255,s[u++]=t>>8&255,s[u++]=255&t;2===a&&(t=i[e.charCodeAt(f)]<<2|i[e.charCodeAt(f+1)]>>4,s[u++]=255&t);1===a&&(t=i[e.charCodeAt(f)]<<10|i[e.charCodeAt(f+1)]<<4|i[e.charCodeAt(f+2)]>>2,s[u++]=t>>8&255,s[u++]=255&t);return s},t.fromByteArray=function(e){for(var t,n=e.length,i=n%3,o=[],a=0,s=n-i;a<s;a+=16383)o.push(l(e,a,a+16383>s?s:a+16383));1===i?(t=e[n-1],o.push(r[t>>2]+r[t<<4&63]+"==")):2===i&&(t=(e[n-2]<<8)+e[n-1],o.push(r[t>>10]+r[t>>4&63]+r[t<<2&63]+"="));return o.join("")};for(var r=[],i=[],o="undefined"!=typeof Uint8Array?Uint8Array:Array,a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0,u=a.length;s<u;++s)r[s]=a[s],i[a.charCodeAt(s)]=s;function c(e){var t=e.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var n=e.indexOf("=");return-1===n&&(n=t),[n,n===t?0:4-n%4]}function l(e,t,n){for(var i,o,a=[],s=t;s<n;s+=3)i=(e[s]<<16&16711680)+(e[s+1]<<8&65280)+(255&e[s+2]),a.push(r[(o=i)>>18&63]+r[o>>12&63]+r[o>>6&63]+r[63&o]);return a.join("")}i["-".charCodeAt(0)]=62,i["_".charCodeAt(0)]=63},function(e,t){t.read=function(e,t,n,r,i){var o,a,s=8*i-r-1,u=(1<<s)-1,c=u>>1,l=-7,f=n?i-1:0,h=n?-1:1,p=e[t+f];for(f+=h,o=p&(1<<-l)-1,p>>=-l,l+=s;l>0;o=256*o+e[t+f],f+=h,l-=8);for(a=o&(1<<-l)-1,o>>=-l,l+=r;l>0;a=256*a+e[t+f],f+=h,l-=8);if(0===o)o=1-c;else{if(o===u)return a?NaN:1/0*(p?-1:1);a+=Math.pow(2,r),o-=c}return(p?-1:1)*a*Math.pow(2,o-r)},t.write=function(e,t,n,r,i,o){var a,s,u,c=8*o-i-1,l=(1<<c)-1,f=l>>1,h=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,p=r?0:o-1,d=r?1:-1,y=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(s=isNaN(t)?1:0,a=l):(a=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-a))<1&&(a--,u*=2),(t+=a+f>=1?h/u:h*Math.pow(2,1-f))*u>=2&&(a++,u/=2),a+f>=l?(s=0,a=l):a+f>=1?(s=(t*u-1)*Math.pow(2,i),a+=f):(s=t*Math.pow(2,f-1)*Math.pow(2,i),a=0));i>=8;e[n+p]=255&s,p+=d,s/=256,i-=8);for(a=a<<i|s,c+=i;c>0;e[n+p]=255&a,p+=d,a/=256,c-=8);e[n+p-d]|=128*y}},function(e,t){},function(e,t,n){"use strict";var r=n(23).Buffer,i=n(74);e.exports=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.head=null,this.tail=null,this.length=0}return e.prototype.push=function(e){var t={data:e,next:null};this.length>0?this.tail.next=t:this.head=t,this.tail=t,++this.length},e.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},e.prototype.shift=function(){if(0!==this.length){var e=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,e}},e.prototype.clear=function(){this.head=this.tail=null,this.length=0},e.prototype.join=function(e){if(0===this.length)return"";for(var t=this.head,n=""+t.data;t=t.next;)n+=e+t.data;return n},e.prototype.concat=function(e){if(0===this.length)return r.alloc(0);if(1===this.length)return this.head.data;for(var t,n,i,o=r.allocUnsafe(e>>>0),a=this.head,s=0;a;)t=a.data,n=o,i=s,t.copy(n,i),s+=a.data.length,a=a.next;return o},e}(),i&&i.inspect&&i.inspect.custom&&(e.exports.prototype[i.inspect.custom]=function(){var e=i.inspect({length:this.length});return this.constructor.name+" "+e})},function(e,t){},function(e,t,n){(function(t){function n(e){try{if(!t.localStorage)return!1}catch(e){return!1}var n=t.localStorage[e];return null!=n&&"true"===String(n).toLowerCase()}e.exports=function(e,t){if(n("noDeprecation"))return e;var r=!1;return function(){if(!r){if(n("throwDeprecation"))throw new Error(t);n("traceDeprecation")?console.trace(t):console.warn(t),r=!0}return e.apply(this,arguments)}}}).call(this,n(8))},function(e,t,n){"use strict";e.exports=o;var r=n(55),i=n(18);function o(e){if(!(this instanceof o))return new o(e);r.call(this,e)}i.inherits=n(11),i.inherits(o,r),o.prototype._transform=function(e,t,n){n(null,e)}},function(e,t,n){e.exports=n(34)},function(e,t,n){e.exports=n(12)},function(e,t,n){e.exports=n(33).Transform},function(e,t,n){e.exports=n(33).PassThrough},function(e,t){e.exports=function(e){return e&&"object"==typeof e&&"function"==typeof e.copy&&"function"==typeof e.fill&&"function"==typeof e.readUInt8}},function(e,t,n){"use strict";function r(e){return(r="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})(e)}function i(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function o(e,t){return!t||"object"!==r(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function a(e){return(a=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function s(e,t){return(s=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}var u=n(3),c=function(e){function t(){var e;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),(e=o(this,a(t).call(this))).termType="DefaultGraph",e.value="",e}var n,r,c;return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&s(e,t)}(t,u),n=t,(r=[{key:"toCanonical",value:function(){return this.value}}])&&i(n.prototype,r),c&&i(n,c),t}();e.exports=c},function(e,t){e.exports=function(e){return e.webpackPolyfill||(e.deprecate=function(){},e.paths=[],e.children||(e.children=[]),Object.defineProperty(e,"loaded",{enumerable:!0,get:function(){return e.l}}),Object.defineProperty(e,"id",{enumerable:!0,get:function(){return e.i}}),e.webpackPolyfill=1),e}},function(e,t,n){function r(e){this.options=e||{locator:{}}}function i(){this.cdata=!1}function o(e,t){t.lineNumber=e.lineNumber,t.columnNumber=e.columnNumber}function a(e){if(e)return"\n@"+(e.systemId||"")+"#[line:"+e.lineNumber+",col:"+e.columnNumber+"]"}function s(e,t,n){return"string"==typeof e?e.substr(t,n):e.length>=t+n||t?new java.lang.String(e,t,n)+"":e}function u(e,t){e.currentElement?e.currentElement.appendChild(t):e.doc.appendChild(t)}r.prototype.parseFromString=function(e,t){var n=this.options,r=new c,o=n.domBuilder||new i,s=n.errorHandler,u=n.locator,l=n.xmlns||{},f={lt:"<",gt:">",amp:"&",quot:'"',apos:"'"};return u&&o.setDocumentLocator(u),r.errorHandler=function(e,t,n){if(!e){if(t instanceof i)return t;e=t}var r={},o=e instanceof Function;function s(t){var i=e[t];!i&&o&&(i=2==e.length?function(n){e(t,n)}:e),r[t]=i&&function(e){i("[xmldom "+t+"]\t"+e+a(n))}||function(){}}return n=n||{},s("warning"),s("error"),s("fatalError"),r}(s,o,u),r.domBuilder=n.domBuilder||o,/\/x?html?$/.test(t)&&(f.nbsp=" ",f.copy="©",l[""]="http://www.w3.org/1999/xhtml"),l.xml=l.xml||"http://www.w3.org/XML/1998/namespace",e?r.parse(e,l,f):r.errorHandler.error("invalid doc source"),o.doc},i.prototype={startDocument:function(){this.doc=(new l).createDocument(null,null,null),this.locator&&(this.doc.documentURI=this.locator.systemId)},startElement:function(e,t,n,r){var i=this.doc,a=i.createElementNS(e,n||t),s=r.length;u(this,a),this.currentElement=a,this.locator&&o(this.locator,a);for(var c=0;c<s;c++){e=r.getURI(c);var l=r.getValue(c),f=(n=r.getQName(c),i.createAttributeNS(e,n));this.locator&&o(r.getLocator(c),f),f.value=f.nodeValue=l,a.setAttributeNode(f)}},endElement:function(e,t,n){var r=this.currentElement;r.tagName;this.currentElement=r.parentNode},startPrefixMapping:function(e,t){},endPrefixMapping:function(e){},processingInstruction:function(e,t){var n=this.doc.createProcessingInstruction(e,t);this.locator&&o(this.locator,n),u(this,n)},ignorableWhitespace:function(e,t,n){},characters:function(e,t,n){if(e=s.apply(this,arguments)){if(this.cdata)var r=this.doc.createCDATASection(e);else r=this.doc.createTextNode(e);this.currentElement?this.currentElement.appendChild(r):/^\s*$/.test(e)&&this.doc.appendChild(r),this.locator&&o(this.locator,r)}},skippedEntity:function(e){},endDocument:function(){this.doc.normalize()},setDocumentLocator:function(e){(this.locator=e)&&(e.lineNumber=0)},comment:function(e,t,n){e=s.apply(this,arguments);var r=this.doc.createComment(e);this.locator&&o(this.locator,r),u(this,r)},startCDATA:function(){this.cdata=!0},endCDATA:function(){this.cdata=!1},startDTD:function(e,t,n){var r=this.doc.implementation;if(r&&r.createDocumentType){var i=r.createDocumentType(e,t,n);this.locator&&o(this.locator,i),u(this,i)}},warning:function(e){console.warn("[xmldom warning]\t"+e,a(this.locator))},error:function(e){console.error("[xmldom error]\t"+e,a(this.locator))},fatalError:function(e){throw console.error("[xmldom fatalError]\t"+e,a(this.locator)),e}},"endDTD,startEntity,endEntity,attributeDecl,elementDecl,externalEntityDecl,internalEntityDecl,resolveEntity,getExternalSubset,notationDecl,unparsedEntityDecl".replace(/\w+/g,function(e){i.prototype[e]=function(){return null}});var c=n(85).XMLReader,l=t.DOMImplementation=n(58).DOMImplementation;t.XMLSerializer=n(58).XMLSerializer,t.DOMParser=r},function(e,t){var n=/[A-Z_a-z\xC0-\xD6\xD8-\xF6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/,r=new RegExp("[\\-\\.0-9"+n.source.slice(1,-1)+"\\u00B7\\u0300-\\u036F\\u203F-\\u2040]"),i=new RegExp("^"+n.source+r.source+"*(?::"+n.source+r.source+"*)?$"),o=0,a=1,s=2,u=3,c=4,l=5,f=6,h=7;function p(){}function d(e,t){return t.lineNumber=e.lineNumber,t.columnNumber=e.columnNumber,t}function y(e,t,n,r,i,p){for(var d,y=++t,v=o;;){var g=e.charAt(y);switch(g){case"=":if(v===a)d=e.slice(t,y),v=u;else{if(v!==s)throw new Error("attribute equal must after attrName");v=u}break;case"'":case'"':if(v===u||v===a){if(v===a&&(p.warning('attribute value must after "="'),d=e.slice(t,y)),t=y+1,!((y=e.indexOf(g,t))>0))throw new Error("attribute value no end '"+g+"' match");m=e.slice(t,y).replace(/&#?\w+;/g,i),n.add(d,m,t-1),v=l}else{if(v!=c)throw new Error('attribute value must after "="');m=e.slice(t,y).replace(/&#?\w+;/g,i),n.add(d,m,t),p.warning('attribute "'+d+'" missed start quot('+g+")!!"),t=y+1,v=l}break;case"/":switch(v){case o:n.setTagName(e.slice(t,y));case l:case f:case h:v=h,n.closed=!0;case c:case a:case s:break;default:throw new Error("attribute invalid close char('/')")}break;case"":return p.error("unexpected end of input"),v==o&&n.setTagName(e.slice(t,y)),y;case">":switch(v){case o:n.setTagName(e.slice(t,y));case l:case f:case h:break;case c:case a:"/"===(m=e.slice(t,y)).slice(-1)&&(n.closed=!0,m=m.slice(0,-1));case s:v===s&&(m=d),v==c?(p.warning('attribute "'+m+'" missed quot(")!!'),n.add(d,m.replace(/&#?\w+;/g,i),t)):("http://www.w3.org/1999/xhtml"===r[""]&&m.match(/^(?:disabled|checked|selected)$/i)||p.warning('attribute "'+m+'" missed value!! "'+m+'" instead!!'),n.add(m,m,t));break;case u:throw new Error("attribute value missed!!")}return y;case"":g=" ";default:if(g<=" ")switch(v){case o:n.setTagName(e.slice(t,y)),v=f;break;case a:d=e.slice(t,y),v=s;break;case c:var m=e.slice(t,y).replace(/&#?\w+;/g,i);p.warning('attribute "'+m+'" missed quot(")!!'),n.add(d,m,t);case l:v=f}else switch(v){case s:n.tagName;"http://www.w3.org/1999/xhtml"===r[""]&&d.match(/^(?:disabled|checked|selected)$/i)||p.warning('attribute "'+d+'" missed value!! "'+d+'" instead2!!'),n.add(d,d,t),t=y,v=a;break;case l:p.warning('attribute space is required"'+d+'"!!');case f:v=a,t=y;break;case u:v=c,t=y;break;case h:throw new Error("elements closed character '/' and '>' must be connected to")}}y++}}function v(e,t,n){for(var r=e.tagName,i=null,o=e.length;o--;){var a=e[o],s=a.qName,u=a.value;if((h=s.indexOf(":"))>0)var c=a.prefix=s.slice(0,h),l=s.slice(h+1),f="xmlns"===c&&l;else l=s,c=null,f="xmlns"===s&&"";a.localName=l,!1!==f&&(null==i&&(i={},w(n,n={})),n[f]=i[f]=u,a.uri="http://www.w3.org/2000/xmlns/",t.startPrefixMapping(f,u))}for(o=e.length;o--;){(c=(a=e[o]).prefix)&&("xml"===c&&(a.uri="http://www.w3.org/XML/1998/namespace"),"xmlns"!==c&&(a.uri=n[c||""]))}var h;(h=r.indexOf(":"))>0?(c=e.prefix=r.slice(0,h),l=e.localName=r.slice(h+1)):(c=null,l=e.localName=r);var p=e.uri=n[c||""];if(t.startElement(p,l,r,e),!e.closed)return e.currentNSMap=n,e.localNSMap=i,!0;if(t.endElement(p,l,r),i)for(c in i)t.endPrefixMapping(c)}function g(e,t,n,r,i){if(/^(?:script|textarea)$/i.test(n)){var o=e.indexOf("</"+n+">",t),a=e.substring(t+1,o);if(/[&<]/.test(a))return/^script$/i.test(n)?(i.characters(a,0,a.length),o):(a=a.replace(/&#?\w+;/g,r),i.characters(a,0,a.length),o)}return t+1}function m(e,t,n,r){var i=r[n];return null==i&&((i=e.lastIndexOf("</"+n+">"))<t&&(i=e.lastIndexOf("</"+n)),r[n]=i),i<t}function w(e,t){for(var n in e)t[n]=e[n]}function b(e,t,n,r){switch(e.charAt(t+2)){case"-":return"-"===e.charAt(t+3)?(i=e.indexOf("--\x3e",t+4))>t?(n.comment(e,t+4,i-t-4),i+3):(r.error("Unclosed comment"),-1):-1;default:if("CDATA["==e.substr(t+3,6)){var i=e.indexOf("]]>",t+9);return n.startCDATA(),n.characters(e,t+9,i-t-9),n.endCDATA(),i+3}var o=function(e,t){var n,r=[],i=/'[^']+'|"[^"]+"|[^\s<>\/=]+=?|(\/?\s*>|<)/g;i.lastIndex=t,i.exec(e);for(;n=i.exec(e);)if(r.push(n),n[1])return r}(e,t),a=o.length;if(a>1&&/!doctype/i.test(o[0][0])){var s=o[1][0],u=a>3&&/^public$/i.test(o[2][0])&&o[3][0],c=a>4&&o[4][0],l=o[a-1];return n.startDTD(s,u&&u.replace(/^(['"])(.*?)\1$/,"$2"),c&&c.replace(/^(['"])(.*?)\1$/,"$2")),n.endDTD(),l.index+l[0].length}}return-1}function x(e,t,n){var r=e.indexOf("?>",t);if(r){var i=e.substring(t,r).match(/^<\?(\S*)\s*([\s\S]*?)\s*$/);if(i){i[0].length;return n.processingInstruction(i[1],i[2]),r+2}return-1}return-1}function _(e){}function k(e,t){return e.__proto__=t,e}p.prototype={parse:function(e,t,n){var r=this.domBuilder;r.startDocument(),w(t,t={}),function(e,t,n,r,i){function o(e){var t=e.slice(1,-1);return t in n?n[t]:"#"===t.charAt(0)?function(e){if(e>65535){var t=55296+((e-=65536)>>10),n=56320+(1023&e);return String.fromCharCode(t,n)}return String.fromCharCode(e)}(parseInt(t.substr(1).replace("x","0x"))):(i.error("entity not found:"+e),e)}function a(t){if(t>w){var n=e.substring(w,t).replace(/&#?\w+;/g,o);f&&s(w),r.characters(n,0,t-w),w=t}}function s(t,n){for(;t>=c&&(n=l.exec(e));)u=n.index,c=u+n[0].length,f.lineNumber++;f.columnNumber=t-u+1}var u=0,c=0,l=/.*(?:\r\n?|\n)|.*$/g,f=r.locator,h=[{currentNSMap:t}],p={},w=0;for(;;){try{var k=e.indexOf("<",w);if(k<0){if(!e.substr(w).match(/^\s*$/)){var S=r.doc,T=S.createTextNode(e.substr(w));S.appendChild(T),r.currentElement=T}return}switch(k>w&&a(k),e.charAt(k+1)){case"/":var E=e.indexOf(">",k+3),O=e.substring(k+2,E),j=h.pop();E<0?(O=e.substring(k+2).replace(/[\s<].*/,""),i.error("end tag name: "+O+" is not complete:"+j.tagName),E=k+1+O.length):O.match(/\s</)&&(O=O.replace(/[\s<].*/,""),i.error("end tag name: "+O+" maybe not complete"),E=k+1+O.length);var N=j.localNSMap,I=j.tagName==O,R=I||j.tagName&&j.tagName.toLowerCase()==O.toLowerCase();if(R){if(r.endElement(j.uri,j.localName,O),N)for(var A in N)r.endPrefixMapping(A);I||i.fatalError("end tag name: "+O+" is not match the current start tagName:"+j.tagName)}else h.push(j);E++;break;case"?":f&&s(k),E=x(e,k,r);break;case"!":f&&s(k),E=b(e,k,r,i);break;default:f&&s(k);var C=new _,P=h[h.length-1].currentNSMap,E=y(e,k,C,P,o,i),L=C.length;if(!C.closed&&m(e,E,C.tagName,p)&&(C.closed=!0,n.nbsp||i.warning("unclosed xml attribute")),f&&L){for(var D=d(f,{}),U=0;U<L;U++){var M=C[U];s(M.offset),M.locator=d(f,{})}r.locator=D,v(C,r,P)&&h.push(C),r.locator=f}else v(C,r,P)&&h.push(C);"http://www.w3.org/1999/xhtml"!==C.uri||C.closed?E++:E=g(e,E,C.tagName,o,r)}}catch(e){i.error("element parse error: "+e),E=-1}E>w?w=E:a(Math.max(k,w)+1)}}(e,t,n,r,this.errorHandler),r.endDocument()}},_.prototype={setTagName:function(e){if(!i.test(e))throw new Error("invalid tagName:"+e);this.tagName=e},add:function(e,t,n){if(!i.test(e))throw new Error("invalid attribute:"+e);this[this.length++]={qName:e,value:t,offset:n}},length:0,getLocalName:function(e){return this[e].localName},getLocator:function(e){return this[e].locator},getQName:function(e){return this[e].qName},getURI:function(e){return this[e].uri},getValue:function(e){return this[e].value}},k({},k.prototype)instanceof k||(k=function(e,t){function n(){}for(t in n.prototype=t,n=new n,e)n[t]=e[t];return n}),t.XMLReader=p},function(t,n){t.exports=e},function(e,t,n){"use strict";function r(e){return(r="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})(e)}function i(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function o(e,t){return!t||"object"!==r(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function a(e){return(a=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function s(e,t){return(s=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}var u=n(3),c=function(e){function t(){var e;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),(e=o(this,a(t).call(this))).termType=t.termType,e}var n,r,c;return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&s(e,t)}(t,u),n=t,(r=[{key:"toString",value:function(){return"()"}}])&&i(n.prototype,r),c&&i(n,c),t}();c.termType="empty",e.exports=c},function(e,t,n){"use strict";var r={parseJSON:function(e,t,n){var r,i,o,a={},s=n.sym(t);for(var u in e){0===u.indexOf("_:")?a[u]?r=a[u]:(r=n.bnode(u),a[u]=r):r=n.sym(u);var c=e[u];for(var l in c){var f=c[l];for(var h in i=n.sym(l),f){var p=f[h];if("uri"===p.type)o=n.sym(p.value),n.add(r,i,o,s);else if("BlankNode"===p.type)a[p.value]?o=a[p.value]:(o=n.bnode(p.value),a[p.value]=o),n.add(r,i,o,s);else{if("Literal"!==p.type)throw new Error("error: unexpected termtype: "+h.type);o=p.datatype?n.literal(p.value,void 0,n.sym(p.datatype)):p.lang?n.literal(p.value,p.lang):n.literal(p.value),n.add(r,i,o,s)}}}}}};e.exports=r},function(e,t,n){"use strict";var r=n(13);e.exports=function(e){var t=0;function n(e){var t="",n=e.statements;for(var i in n)r.debug("Found statement: "+n),t+=a()+n[i]+"\n";return t}function i(e){var t="";for(var n in e.constraints){var r=e.constraints[n];t+=a()+"FILTER ( "+r.describe(n)+" ) \n"}return t}function o(e){var o=a()+"WHERE \n{ \n";return t++,o+=n(e),o+=i(e),o+=function e(o){for(var s="",u=0;u<o.optional.length;u++)r.debug("Found optional query"),s+=a()+"OPTIONAL { \n",t++,s+=n(o.optional[u]),s+=i(o.optional[u]),s+=e(o.optional[u]),t--,s+=a()+"}\n";return s}(e),t--,o+="}"}function a(){for(var e="",n=0;n<t;n++)e+="    ";return e}return function(e){return function(e){for(var t=a()+"SELECT ",n=0;n<e.vars.length;n++)t+=e.vars[n]+" ";return t+="\n"}(e)+o(e.pat)}(e)}},function(e,t,n){"use strict";var r=n(13),i=n(20).Query;e.exports=function(e,t,n){var o=[];function a(e){if(o[e])return o[e];var t=n.variable(e);return o[e]=t,t}function s(e){return"string"==typeof e&&e.match(/^[\?\$]/)}function u(e){return"string"==typeof e&&e.match(/^<[^>]*>$/)}function c(e){return"string"==typeof e&&(e.match(/^_:/)||e.match(/^$/))}function l(e){return"string"==typeof e&&e.match(/^:|^[^_][^:]*:/)}function f(e){return e.split(":")[0]}function h(e){return e.split(":")[1]}function p(e){return u(e)?e.slice(1,e.length-1):e}function d(e){e=e.replace(/\(/g," ( ").replace(/\)/g," ) ").replace(/</g," <").replace(/>/g,"> ").replace(/{/g," { ").replace(/}/g," } ").replace(/[\t\n\r]/g," ").replace(/; /g," ; ").replace(/\. /g," . ").replace(/, /g," , "),r.info("New str into spaceDelimit: \n"+e);var t,n=[],i=e.split(" ");for(var o in i)"string"==typeof(t=i[o])&&t.match(/[^ \n\t]/)&&(n=n.concat(i[o]));return n}function y(e,t){for(var n=0;n<t.length;n++)if("string"==typeof t[n]&&t[n].toLowerCase()===e.toLowerCase())return n;return null}function v(e,t){for(var n=[],r=0;r<t.length;r++)"string"==typeof t[r]&&t[r].toLowerCase()===e.toLowerCase()&&n.push(r);return n}function g(e,t,n){r.info("Looking for a close bracket of type "+n+" in "+e);for(var i=0,o=0;o<e.length;o++)if(e[o]===t&&i++,e[o]===n&&i--,i<0)return o;return r.error("Statement had no close parenthesis in SPARQL query"),0}function m(e){return this.describe=function(t){return t+" = "+e.toNT()},this.test=function(t){return e.sameTerm(t)},this}function w(e){this.describe=function(t){return"REGEXP( '"+e+"' , "+t+" )"},this.test=function(t){var n=new RegExp(e);return!!t.value&&n.test(t.value)}}function b(e,t){3!==e.length||"Variable"!==e[0].termType||"NamedNode"!==e[2].termType&&"Literal"!==e[2].termType?6===e.length&&"string"==typeof e[0]&&"regexp"===e[0].toLowerCase()&&"("===e[1]&&")"===e[5]&&","===e[3]&&"Variable"===e[4].termType&&"Literal"===e[2].termType&&(r.debug("Constraint added: "+e),t.constraints[e[4]]=new w(e[2].value)):"="===e[1]?(r.debug("Constraint added: "+e),t.constraints[e[0]]=new m(e[2])):">"===e[1]?(r.debug("Constraint added: "+e),t.constraints[e[0]]=new m(e[2])):"<"===e[1]?(r.debug("Constraint added: "+e),t.constraints[e[0]]=new m(e[2])):r.warn("I don't know how to handle the constraint: "+e)}function x(e,t){r.debug("Optional query: "+e+" not yet implemented.");var i=n.formula();_(e,i),t.optional.push(i)}function _(e,t){var i,o,d=function(e){for(var t,i=[],o=0;o<e.length;o++)"string"==typeof e[o]?(e[o]="string"==typeof(t=e[o])?t.replace(/^&lt;/,"<").replace(/&gt;$/,">"):t,s(e[o])?i[o]=a(e[o].slice(1)):c(e[o])?(r.info(e[o]+" was identified as a bnode."),i[o]=n.bnode()):u(e[o])?(r.info(e[o]+" was identified as a symbol."),i[o]=n.sym(p(e[o]))):l(e[o])?(r.info(e[o]+" was identified as a prefixed symbol"),T[f(e[o])]?i[o]=n.sym(e[o]=T[f(e[o])]+h(e[o])):(r.error("SPARQL error: "+e[o]+" with prefix "+f(e[o])+" does not have a correct prefix entry."),i[o]=e[o])):i[o]=e[o]):i[o]=e[o];return i}(e);for(r.debug("WHERE: "+d);y("OPTIONAL",d);)o=y("OPTIONAL",d),r.debug("OPT: "+o+" "+d[o]+" in "+d),"{"!==d[o+1]&&r.warn("Bad optional opening bracket in word "+o),-1===(i=g(d.slice(o+2),"{","}"))?r.error("No matching bracket in word "+o):(x(d.slice(o+2,o+2+i),t),o=y("OPTIONAL",d),i=g(d.slice(o+2),"{","}"),d.splice(o,i+3));for(r.debug("WHERE after optionals: "+d);y("FILTER",d);){var m=y("FILTER",d);"("!==d[m+1]&&r.warn("Bad filter opening bracket in word "+m),-1===(i=g(d.slice(m+2),"(",")"))?r.error("No matching bracket in word "+m):(b(d.slice(m+2,m+2+i),t),m=y("FILTER",d),i=g(d.slice(m+2),"(",")"),d.splice(m,i+3))}r.debug("WHERE after filters and optionals: "+d),function(e,t){var n=new Array(1);n[0]=-1;for(var i=n.concat(v(".",e)),o=[],a=0;a<i.length-1;a++)o[a]=e.slice(i[a]+1,i[a+1]);for(a in o){r.info("s+p+o "+a+" = "+o[a]);var s=o[a][0];o[a].splice(0,1);var u=n.concat(v(";",o[a]));u.push(o[a].length);for(var c=[],l=0;l<u.length-1;l++)c[l]=o[a].slice(u[l]+1,u[l+1]);for(a in c){r.info("p+o "+a+" = "+o[a]);var f=c[a][0];c[a].splice(0,1);var h=n.concat(v(",",c[a]));h.push(c[a].length);var p=[];for(l=0;l<h.length-1;l++)p[l]=c[a].slice(h[l]+1,h[l+1]);for(a in p){var d=p[a][0];r.info("Subj="+s+" Pred="+f+" Obj="+d),t.add(s,f,d)}}}}(d,t)}r.info("SPARQL input: \n"+e);var k=new i,S=function(e){var t=function e(t){var i=-1===t.indexOf("'")?null:t.indexOf("'"),o=-1===t.indexOf('"')?null:t.indexOf('"');if(!i&&!o){var a=new Array(1);return a[0]=t,a}var s,u,c=new Array(2);if(!i||o&&o<i)s='"',u=o;else{if(o&&!(i&&i<o))return r.error("SQARQL QUERY OOPS!"),c;s="'",u=i}c[0]=t.slice(0,u);var l,f=t.slice(u+1).indexOf(s);return-1===f?(r.error("SPARQL parsing error: no matching parentheses in literal "+t),t):(t.slice(f+u+2).match(/^\^\^/)?(l=t.slice(f+u+2).indexOf(" "),c[1]=n.literal(t.slice(u+1,u+1+f),"",n.sym(p(t.slice(u+4+f,u+2+f+l)))),c=c.concat(e(t.slice(f+u+3+l)))):t.slice(f+u+2).match(/^@/)?(l=t.slice(f+u+2).indexOf(" "),c[1]=n.literal(t.slice(u+1,u+1+f),t.slice(u+3+f,u+2+f+l),null),c=c.concat(e(t.slice(f+u+2+l)))):(c[1]=n.literal(t.slice(u+1,u+1+f),"",null),r.info("Literal found: "+c[1]),c=c.concat(e(t.slice(f+u+2)))),c)}(e),i=[];for(var o in t)i="string"==typeof t[o]?i.concat(d(t[o])):i.concat(t[o]);return i=function(e){for(var t=e,n=0;n<t.length;n++)if("a"===t[n]&&(t[n]="<http://www.w3.org/1999/02/22-rdf-syntax-ns#type>"),"is"===t[n]&&"of"===t[n+2]){t.splice(n,1),t.splice(n+1,1);var r=t[n-1];t[n-1]=t[n+1],t[n+1]=r}return t}(i),r.info("SPARQL Tokens: "+i),i}(e),T=function(e){var t,n=v("PREFIX",e),i=[];for(var o in n){var a=e[n[o]+1],s=e[n[o]+2];if("string"==typeof(t=a)&&t.match(/:$/))if(u(s)){r.info("Prefix found: "+a+" -> "+s);var c=f(a),l=p(s);i[c]=l}else r.error("Invalid SPARQL symbol: "+s);else r.error("Invalid SPARQL prefix: "+a)}return i}(S);T.rdf||(T.rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"),T.rdfs||(T.rdfs="http://www.w3.org/2000/01/rdf-schema#");var E=y("SELECT",S),O=y("WHERE",S);if(E<0||O<0||E>O)return r.error("Invalid or nonexistent SELECT and WHERE tags in SPARQL query"),!1;if(function(e,t){for(var n in r.info("SPARQL vars: "+e),e)if(s(e[n])){r.info("Added "+e[n]+" to query variables from SPARQL");var i=a(e[n].slice(1));t.vars.push(i),i.label=e[n].slice(1)}else r.warn("Incorrect SPARQL variable in SELECT: "+e[n])}(S.slice(E+1,O),k),_(S.slice(O+2,S.length-1),k.pat),t)return k;for(var j in k.pat.statements){var N=k.pat.statements[j];"NamedNode"===N.subject.termType&&n.fetcher&&n.fetcher.lookUpThing(N.subject,"sparql:"+N.subject),"NamedNode"===N.object.termType&&n.fetcher&&n.fetcher.lookUpThing(N.object,"sparql:"+N.object)}return k}},function(e,t,n){"use strict";function r(e){return(r="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})(e)}function i(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}var o=n(19),a=n(4).docpart,s=n(36),u=n(24).namedNode,c=n(16),l=n(38),f=n(4).join,h=n(6),p=function(){function e(t){if(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),t=t||new o,this.store=t,t.updater)throw new Error("You can't have two UpdateManagers for the same store");t.fetcher||(t.fetcher=new s(t)),t.updater=this,this.ifps={},this.fps={},this.ns={},this.ns.link=c("http://www.w3.org/2007/ont/link#"),this.ns.http=c("http://www.w3.org/2007/ont/http#"),this.ns.httph=c("http://www.w3.org/2007/ont/httph#"),this.ns.ldp=c("http://www.w3.org/ns/ldp#"),this.ns.rdf=c("http://www.w3.org/1999/02/22-rdf-syntax-ns#"),this.ns.rdfs=c("http://www.w3.org/2000/01/rdf-schema#"),this.ns.rdf=c("http://www.w3.org/1999/02/22-rdf-syntax-ns#"),this.ns.owl=c("http://www.w3.org/2002/07/owl#"),this.patchControl=[]}var t,n,p;return t=e,(n=[{key:"patchControlFor",value:function(e){return this.patchControl[e.uri]||(this.patchControl[e.uri]=[]),this.patchControl[e.uri]}},{key:"editable",value:function(e,t){if(!e)return!1;if(t||(t=this.store),"file:///"===e.slice(0,8)){if(t.holds(t.sym(e),u("http://www.w3.org/1999/02/22-rdf-syntax-ns#type"),u("http://www.w3.org/2007/ont/link#MachineEditableDocument")))return"LOCALFILE";var n=t.statementsMatching(t.sym(e));return console.log("UpdateManager.editable: Not MachineEditableDocument file "+e+"\n"),console.log(n.map(function(e){return e.toNT()}).join("\n")),!1}var r,i,o=!1,s=t.each(void 0,this.ns.link("requestedURI"),a(e));if(t.holds(u(e),this.ns.rdf("type"),this.ns.ldp("Resource")))return"SPARQL";for(var c=0;c<s.length;c++)if(void 0!==(r=s[c])){var l=t.any(r,this.ns.link("response"));if(void 0!==r){var f=t.each(l,this.ns.httph("accept-patch"));if(f.length)for(var h=0;h<f.length;h++)if((i=f[h].value.trim()).indexOf("application/sparql-update")>=0)return"SPARQL";var p=t.each(l,this.ns.httph("ms-author-via"));if(p.length)for(var d=0;d<p.length;d++){if((i=p[d].value.trim()).indexOf("SPARQL")>=0)return"SPARQL";if(i.indexOf("DAV")>=0)return"DAV"}var y=t.each(l,this.ns.http("status"));if(y.length)for(var v=0;v<y.length;v++)200!==y[v]&&404!==y[v]||(o=!0)}else console.log("UpdateManager.editable: No response for "+e+"\n")}if(0===s.length)console.log("UpdateManager.editable: No request for "+e+"\n");else if(o)return!1;console.log("UpdateManager.editable: inconclusive for "+e+"\n")}},{key:"anonymize",value:function(e){return"_:"===e.toNT().substr(0,2)&&this.mentioned(e)?"?"+e.toNT().substr(2):e.toNT()}},{key:"anonymizeNT",value:function(e){return this.anonymize(e.subject)+" "+this.anonymize(e.predicate)+" "+this.anonymize(e.object)+" ."}},{key:"statementBnodes",value:function(e){return[e.subject,e.predicate,e.object].filter(function(e){return e.isBlank})}},{key:"statementArrayBnodes",value:function(e){for(var t=[],n=0;n<e.length;n++)t=t.concat(this.statementBnodes(e[n]));t.sort();for(var r=[],i=0;i<t.length;i++)0!==i&&t[i].sameTerm(t[i-1])||r.push(t[i]);return r}},{key:"cacheIfps",value:function(){this.ifps={};for(var e=this.store.each(void 0,this.ns.rdf("type"),this.ns.owl("InverseFunctionalProperty")),t=0;t<e.length;t++)this.ifps[e[t].uri]=!0;this.fps={},e=this.store.each(void 0,this.ns.rdf("type"),this.ns.owl("FunctionalProperty"));for(var n=0;n<e.length;n++)this.fps[e[n].uri]=!0}},{key:"bnodeContext2",value:function(e,t,n){for(var r,i,o=this.store.statementsMatching(void 0,void 0,e,t),a=0;a<o.length;a++)if(this.fps[o[a].predicate.uri]){if(!(r=o[a].subject).isBlank)return[o[a]];if(n&&(i=this.bnodeContext2(r,t,n-1)))return i.concat([o[a]])}o=this.store.statementsMatching(e,void 0,void 0,t);for(var s=0;s<o.length;s++)if(this.ifps[o[s].predicate.uri]){if(!(r=o[s].object).isBlank)return[o[s]];if(n&&(i=this.bnodeContext2(r,t,n-1)))return i.concat([o[s]])}return null}},{key:"bnodeContext1",value:function(e,t){for(var n=0;n<3;n++){var r=this.bnodeContext2(e,t,n);if(null!==r)return r}return this.store.connectedStatements(e,t)}},{key:"mentioned",value:function(e){return 0!==this.store.statementsMatching(e).length||0!==this.store.statementsMatching(void 0,e).length||0!==this.store.statementsMatching(void 0,void 0,e).length}},{key:"bnodeContext",value:function(e,t){var n=[];if(e.length){this.cacheIfps();for(var r=0;r<e.length;r++){var i=e[r];this.mentioned(i)&&(n=n.concat(this.bnodeContext1(i,t)))}}return n}},{key:"statementContext",value:function(e){var t=this.statementBnodes(e);return this.bnodeContext(t,e.why)}},{key:"contextWhere",value:function(e){var t=this;return e&&0!==e.length?"WHERE { "+e.map(function(e){return t.anonymizeNT(e)}).join("\n")+" }\n":""}},{key:"fire",value:function(e,t,n){var r=this;return Promise.resolve().then(function(){if(!e)throw new Error("No URI given for remote editing operation: "+t);console.log("UpdateManager: sending update to <"+e+">");var n={noMeta:!0,contentType:"application/sparql-update",body:t};return r.store.fetcher.webOperation("PATCH",e,n)}).then(function(r){if(!r.ok){var i="UpdateManager: update failed for <"+e+"> status="+r.status+", "+r.statusText+"\n   for query: "+t;throw console.log(i),new Error(i)}console.log("UpdateManager: update Ok for <"+e+">"),n(e,r.ok,r.responseText,r)}).catch(function(t){n(e,!1,t.message,t)})}},{key:"update_statement",value:function(e){if(!e||e.why){var t=this,n=this.statementContext(e);return{statement:e?[e.subject,e.predicate,e.object,e.why]:void 0,statementNT:e?this.anonymizeNT(e):void 0,where:t.contextWhere(n),set_object:function(e,n){var r=this.where;r+="DELETE DATA { "+this.statementNT+" } ;\n",r+="INSERT DATA { "+this.anonymize(this.statement[0])+" "+this.anonymize(this.statement[1])+" "+this.anonymize(e)+"  . }\n",t.fire(this.statement[3].uri,r,n)}}}}},{key:"insert_statement",value:function(e,t){var n=e instanceof Array?e[0]:e,r=this.contextWhere(this.statementContext(n));if(e instanceof Array){for(var i="",o=0;o<e.length;o++)i+=e[o]+"\n";r+="INSERT DATA { "+i+" }\n"}else r+="INSERT DATA { "+this.anonymize(e.subject)+" "+this.anonymize(e.predicate)+" "+this.anonymize(e.object)+"  . }\n";this.fire(n.why.uri,r,t)}},{key:"delete_statement",value:function(e,t){var n=e instanceof Array?e[0]:e,r=this.contextWhere(this.statementContext(n));if(e instanceof Array){for(var i="",o=0;o<e.length;o++)i+=e[o]+"\n";r+="DELETE DATA { "+i+" }\n"}else r+="DELETE DATA { "+this.anonymize(e.subject)+" "+this.anonymize(e.predicate)+" "+this.anonymize(e.object)+"  . }\n";this.fire(n.why.uri,r,t)}},{key:"requestDownstreamAction",value:function(e,t){var n=this.patchControlFor(e);if(n.pendingUpstream)if(n.downstreamAction){if(""+n.downstreamAction!=""+t)throw new Error("Can't wait for > 1 different downstream actions")}else n.downstreamAction=t;else t(e)}},{key:"clearUpstreamCount",value:function(e){this.patchControlFor(e).upstreamCount=0}},{key:"getUpdatesVia",value:function(e){var t=this.store.fetcher.getHeader(e,"updates-via");return t&&t.length?t[0].trim():null}},{key:"addDownstreamChangeListener",value:function(e,t){var n=this,r=this.patchControlFor(e);r.downstreamChangeListeners||(r.downstreamChangeListeners=[]),r.downstreamChangeListeners.push(t),this.setRefreshHandler(e,function(e){n.reloadAndSync(e)})}},{key:"reloadAndSync",value:function(e){var t=this.patchControlFor(e),n=this;if(t.reloading)return console.log("   Already reloading - note this load may be out of date"),void(t.outOfDate=!0);t.reloading=!0;var r=1e3;!function i(){console.log("try reload - timeout = "+r),n.reload(n.store,e,function(n,o,a){if(n){if(t.downstreamChangeListeners)for(var s=0;s<t.downstreamChangeListeners.length;s++)console.log("        Calling downstream listener "+s),t.downstreamChangeListeners[s]();t.reloading=!1,t.outOfDate&&(console.log("   Extra reload because of extra update."),t.outOfDate=!1,i())}else t.reloading=!1,0===a.status?(console.log("Network error refreshing the data. Retrying in "+r/1e3),t.reloading=!0,r*=2,setTimeout(i,r)):console.log("Error "+a.status+"refreshing the data:"+o+". Stopped"+e)})}()}},{key:"setRefreshHandler",value:function(e,t){var n=this.getUpdatesVia(e),r=t,i=this,o=this,a=1500,s=0;if(!n)return console.log("Server doies not support live updates thoughUpdates-Via :-("),!1;n=(n=f(n,e.uri)).replace(/^http:/,"ws:").replace(/^https:/,"wss:"),console.log("Web socket URI "+n);return function t(){var u;if("undefined"!=typeof WebSocket)u=new WebSocket(n);else if("undefined"!=typeof Services)u=Services.wm.getMostRecentWindow("navigator:browser").WebSocket(n);else{if("undefined"==typeof window||!window.WebSocket)return void console.log("Live update disabled, as WebSocket not supported by platform :-(");u=window.WebSocket(n)}u.onopen=function(){console.log("    websocket open"),a=1500,this.send("sub "+e.uri),s&&(console.log("Web socket has been down, better check for any news."),o.requestDownstreamAction(e,r))};var c=i.patchControlFor(e);c.upstreamCount=0,u.onerror=function(e){console.log("Error on Websocket:",e)},u.onclose=function(e){console.log("*** Websocket closed with code "+e.code+", reason '"+e.reason+"' clean = "+e.clean),a*=2,s+=1,console.log("Retrying in "+a+"ms"),setTimeout(function(){console.log("Trying websocket again"),t()},a)},u.onmessage=function(t){if(t.data&&"pub"===t.data.slice(0,3)){if("upstreamCount"in c&&(c.upstreamCount-=1,c.upstreamCount>=0))return void console.log("just an echo: "+c.upstreamCount);console.log("Assume a real downstream change: "+c.upstreamCount+" -> 0"),c.upstreamCount=0,i.requestDownstreamAction(e,r)}}}(),!0}},{key:"update",value:function(e,t,n,i){var a=this;if(!n){var s=this;return new Promise(function(n,r){s.update(e,t,function(e,t,i){t?n():r(new Error(i))})})}try{var u=this.store,c=e?e instanceof o?e.statements:e instanceof Array?e:[e]:[],l=t?t instanceof o?t.statements:t instanceof Array?t:[t]:[];if(!(c instanceof Array))throw new Error("Type Error "+r(c)+": "+c);if(!(l instanceof Array))throw new Error("Type Error "+r(l)+": "+l);if(0===c.length&&0===l.length)return n(null,!0);var f=c.length?c[0].why:l[0].why;if(!f){var p="Error patching: statement does not specify which document to patch:"+c[0]+", "+l[0];throw console.log(p),new Error(p)}var d=this.patchControlFor(f),y=Date.now(),v=["subject","predicate","object","why"],g={delete:c,insert:l};["insert","delete"].map(function(e){g[e].map(function(e){if(!f.sameTerm(e.why))throw new Error("update: destination "+f+" inconsistent with delete quad "+e.why);v.map(function(t){if(void 0===e[t])throw new Error("update: undefined "+t+" of statement.")})})});var m=this.editable(f.uri,u);if(!1===m)throw new Error("Update: Can't make changes in uneditable "+f);if(void 0===m){if(i)throw new Error("Update: Loaded "+f+"but stil can't figure out what editing protcol it supports.");return console.log("Update: have not loaded ".concat(f," before: loading now...")),void this.store.fetcher.load(f).then(function(r){a.update(e,t,n,!0)},function(e){throw new Error("Update: Can't read ".concat(f," before patching: ").concat(e))})}if(m.indexOf("SPARQL")>=0){var w=[];c.length&&(w=this.statementArrayBnodes(c)),l.length&&(w=w.concat(this.statementArrayBnodes(l)));var b=this.bnodeContext(w,f),x=this.contextWhere(b),_="";if(x.length){if(c.length){_+="DELETE { ";for(var k=0;k<c.length;k++)_+=this.anonymizeNT(c[k])+"\n";_+=" }\n"}if(l.length){_+="INSERT { ";for(var S=0;S<l.length;S++)_+=this.anonymizeNT(l[S])+"\n";_+=" }\n"}_+=x}else{if(c.length){_+="DELETE DATA { ";for(var T=0;T<c.length;T++)_+=this.anonymizeNT(c[T])+"\n";_+=" } \n"}if(l.length){c.length&&(_+=" ; "),_+="INSERT DATA { ";for(var E=0;E<l.length;E++)_+=this.anonymizeNT(l[E])+"\n";_+=" }\n"}}d.pendingUpstream=d.pendingUpstream?d.pendingUpstream+1:1,"upstreamCount"in d&&(d.upstreamCount+=1,console.log("upstream count up to : "+d.upstreamCount)),this.fire(f.uri,_,function(e,t,r,i){if(i.elapsedTimeMs=Date.now()-y,console.log("    UpdateManager: Return "+(t?"success ":"FAILURE ")+i.status+" elapsed "+i.elapsedTimeMs+"ms"),t){try{u.remove(c)}catch(e){t=!1,r="Remote Ok BUT error deleting "+c.length+" from store!!! "+e}for(var o=0;o<l.length;o++)u.add(l[o].subject,l[o].predicate,l[o].object,f)}if(n(e,t,r,i),d.pendingUpstream-=1,0===d.pendingUpstream&&d.downstreamAction){var a=d.downstreamAction;delete d.downstreamAction,console.log("delayed downstream action:"),a(f)}})}else if(m.indexOf("DAV")>=0)this.updateDav(f,c,l,n);else{if(!(m.indexOf("LOCALFILE")>=0))throw new Error("Unhandled edit method: '"+m+"' for "+f);try{this.updateLocalFile(f,c,l,n)}catch(e){n(f.uri,!1,"Exception trying to write back file <"+f.uri+">\n")}}}catch(e){n(void 0,!1,"Exception in update: "+e+"\n"+h.stackString(e))}}},{key:"updateDav",value:function(e,t,n,r){var i=this.store,o=i.any(e,this.ns.link("request"));if(!o)throw new Error("No record of our HTTP GET request for document: "+e);var a=i.any(o,this.ns.link("response"));if(!a)return null;for(var s=i.the(a,this.ns.httph("content-type")).value,u=i.statementsMatching(void 0,void 0,void 0,e).slice(),c=0;c<t.length;c++)h.RDFArrayRemove(u,t[c]);for(var l=0;l<n.length;l++)u.push(n[l]);var p,d=this.serialize(e.uri,u,s),y=i.the(a,this.ns.httph("content-location"));y&&(p=f(y.value,p));var v={contentType:s,noMeta:!0,body:d};return i.fetcher.webOperation("PUT",p,v).then(function(o){if(!o.ok)throw new Error(o.error);for(var a=0;a<t.length;a++)i.remove(t[a]);for(var s=0;s<n.length;s++)i.add(n[s].subject,n[s].predicate,n[s].object,e);r(e.uri,o.ok,o.responseText,o)}).catch(function(t){r(e.uri,!1,t.message,t)})}},{key:"updateLocalFile",value:function(e,t,n,r){var i=this.store;console.log("Writing back to local file\n");for(var o=i.statementsMatching(void 0,void 0,void 0,e).slice(),a=0;a<t.length;a++)h.RDFArrayRemove(o,t[a]);for(var u=0;u<n.length;u++)o.push(n[u]);var c=e.uri.lastIndexOf(".");if(c<1)throw new Error("Rewriting file: No filename extension: "+e.uri);var l=e.uri.slice(c+1),f=s.CONTENT_TYPE_BY_EXT[l];if(!f)throw new Error("File extension ."+l+" not supported for data write");var p=this.serialize(e.uri,o,f);console.log("Writing back: <<<"+p+">>>");var d=e.uri.slice(7),y=Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsILocalFile);if(y.initWithPath(d),!y.exists())throw new Error("Rewriting file <"+e.uri+"> but it does not exist!");var v=Components.classes["@mozilla.org/network/file-output-stream;1"].createInstance(Components.interfaces.nsIFileOutputStream);v.init(y,42,parseInt("0666",8),0),v.write(p,p.length),v.close();for(var g=0;g<t.length;g++)i.remove(t[g]);for(var m=0;m<n.length;m++)i.add(n[m].subject,n[m].predicate,n[m].object,e);r(e.uri,!0,"")}},{key:"serialize",value:function(e,t,n){var r,i=this.store;if("string"==typeof t)return t;var o=l(i);switch(o.suggestNamespaces(i.namespaces),o.setBase(e),n){case"text/xml":case"application/rdf+xml":r=o.statementsToXML(t);break;case"text/n3":case"text/turtle":case"application/x-turtle":case"application/n3":r=o.statementsToN3(t);break;default:throw new Error("Content-type "+n+" not supported for data serialization")}return r}},{key:"put",value:function(e,t,n,r){var i,o=this,a=this.store;return Promise.resolve().then(function(){return i=o.serialize(e.uri,t,n),a.fetcher.webOperation("PUT",e.uri,{contentType:n,body:i})}).then(function(n){if(!n.ok)return r(e.uri,n.ok,n.error,n);delete a.fetcher.nonexistent[e.uri],delete a.fetcher.requested[e.uri],"string"!=typeof t&&t.map(function(e){a.addStatement(e)}),r(e.uri,n.ok,"",n)}).catch(function(t){r(e.uri,!1,t.message)})}},{key:"reload",value:function(e,t,n){var r=Date.now();e.fetcher.nowOrWhenFetched(t.uri,{force:!0,noMeta:!0,clearPreviousData:!0},function(e,i,o){if(e)if(o.onErrorWasCalled||200!==o.status)console.log("    Non-HTTP error reloading data! onErrorWasCalled="+o.onErrorWasCalled+" status: "+o.status),n(!1,"Non-HTTP error reloading data: "+i,o);else{var a=Date.now()-r;t.reloadTimeTotal||(t.reloadTimeTotal=0),t.reloadTimeCount||(t.reloadTimeCount=0),t.reloadTimeTotal+=a,t.reloadTimeCount+=1,console.log("    Fetch took "+a+"ms, av. of "+t.reloadTimeCount+" = "+t.reloadTimeTotal/t.reloadTimeCount+"ms."),n(!0)}else console.log("    ERROR reloading data: "+i),n(!1,"Error reloading data: "+i,o)})}}])&&i(t.prototype,n),p&&i(t,p),e}();e.exports=p},function(e,t,n){"use strict";n.r(t);var r,i=n(0),o=n.n(i),a=n(1),s=n.n(a),u=n(28),c=n.n(u),l=n(5),f="folder";function h(e,t){var n=l.sym(t),r=l.sym("http://purl.org/dc/terms/modified"),i=l.sym("http://www.w3.org/ns/posix/stat#size"),o=l.sym("http://www.w3.org/ns/posix/stat#mtime"),a=e.any(n,r,void 0);return void 0!==a&&{modified:a=a.value,size:e.any(n,i,void 0).value,mtime:e.any(n,o,void 0).value}}function p(e,t){var n=l.sym(t),r=l.sym("http://www.w3.org/1999/02/22-rdf-syntax-ns#type"),i=e.each(n,r,void 0);for(var o in i){var a=i[o].value;if(a.match("ldp#BasicContainer"))return f;if(a.match("http://www.w3.org/ns/iana/media-types/"))return a.replace("http://www.w3.org/ns/iana/media-types/","").replace("#Resource","")}return"unknown"}function d(e,t,n){var r=function(e,t){for(var n={folders:[],files:[]},r=e.each(l.sym(t),l.sym("http://www.w3.org/ns/ldp#contains"),void 0),i=0;i<r.length;i++){var o=r[i],a={};a.type=p(e,o.value);var s=h(e,o.value);if(a.modified=s.modified,a.size=s.size,a.mtime=s.mtime,a.label=decodeURIComponent(o.value).replace(/.*\//,""),a.type===f){o.value=o.value.replace(/[\/]+/g,"/"),o.value=o.value.replace(/https:/,"https:/");var u=o.value.replace(/\/$/,"");a.name=u.replace(/.*\//,""),a.url=o.value,n.folders.push(a)}else a.url=o.value,a.name=o.value.replace(/.*\//,""),n.files.push(a)}return n}(e,t),i=h(e,t),o=t.replace(/\/$/,""),a=o.replace(/.*\//,""),s=o.substr(0,o.lastIndexOf("/"))+"/";return{type:f,name:a,url:t,modified:i.modified,size:i.size,mtime:i.mtime,parent:s,content:n,folders:r.folders,files:r.files}}function y(e){var t=e.replace(/.*\./,"");return t.match(/\/$/)?f:t.match(/(md|markdown)/)?"text/markdown":t.match(/html/)?"text/html":t.match(/xml/)?"text/xml":t.match(/ttl/)?"text/turtle":t.match(/n3/)?"text/n3":t.match(/rq/)?"application/sparql":t.match(/css/)?"text/css":t.match(/txt/)?"text/plain":t.match(/json/)?"application/json":t.match(/js/)?"application/javascript":t.match(/(png|gif|jpeg|tif)/)?"image":t.match(/(mp3|aif|ogg)/)?"audio":t.match(/(avi|mp4|mpeg)/)?"video":"text/turtle"}function v(e,t,n){return g.apply(this,arguments)}function g(){return(g=s()(o.a.mark(function e(t,n,r){return o.a.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new Promise(function(e,i){r=r||y(n);var o=l.graph();try{l.parse(t,o,n,r),e(o)}catch(e){i(e)}}));case 1:case"end":return e.stop()}},e,this)}))).apply(this,arguments)}function m(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"";return n=n||{},console.log("deepCopying "+e+"\n"+r+"-> "+t),e.match(/\/$/)||(e+="/"),t.match(/\/$/)||(t+="/"),new Promise(function(i,o){G(e).then(function(a){for(var s=[],u=a.folders.concat(a.files),c=function(){var i=u[l],o=function(e,t,n){if(!n.startsWith(e))throw new Error("source {".concat(n,"} is not in tree {").concat(e,"}"));return t+n.slice(e.length)}(e,t,i.url);"folder"===i.type?L(o).then(function(){s.push(m(i.url,o,n,r+"  "))}):(console.log("copying "+o),s.push(k(i.url,o)))},l=0;l<u.length;l++)c();Promise.all(s).then(i(!0)).catch(function(e){console.log("Overall promise rejected: "+e),o(e)})},function(e){o("Could not read folder : "+e)})})}function w(e){return y(e)}function b(e,t,n){return d(e,t,n)}function x(e,t,n){return _.apply(this,arguments)}function _(){return(_=s()(o.a.mark(function e(t,n,r){return o.a.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",v(t,n,r));case 1:case"end":return e.stop()}},e,this)}))).apply(this,arguments)}function k(e,t){return S.apply(this,arguments)}function S(){return(S=s()(o.a.mark(function e(t,n){return o.a.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:$(t).then(function(e){U(n,e).then(function(e){return e},function(e){throw new Error("copy upload error  "+e)})},function(e){throw new Error("copy download error  "+e)});case 1:case"end":return e.stop()}},e,this)}))).apply(this,arguments)}function T(e,t){return E.apply(this,arguments)}function E(){return(E=s()(o.a.mark(function e(t,n){return o.a.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new Promise(function(e,r){n=n||y(t),Z(t).then(function(i){"application/json"===n?i.json().then(function(t){e(t)},function(e){return r("JSON parse : "+e)}):v(i,t,n).then(function(t){e(t)},function(e){return r("RDF parse : "+e)})},function(e){return r(e)})}));case 1:case"end":return e.stop()}},e,this)}))).apply(this,arguments)}function O(){return j.apply(this,arguments)}function j(){return(j=s()(o.a.mark(function e(){var t;return o.a.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,r.auth.currentSession();case 2:if(t=e.sent){e.next=8;break}return"https://solid.community/common/popup.html",e.next=7,r.auth.popupLogin({popupUri:"https://solid.community/common/popup.html"});case 7:t=e.sent;case 8:return e.abrupt("return",t.webId);case 9:case"end":return e.stop()}},e,this)}))).apply(this,arguments)}function N(){return I.apply(this,arguments)}function I(){return(I=s()(o.a.mark(function e(){var t;return o.a.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,r.auth.currentSession();case 2:if(!(t=e.sent)){e.next=7;break}return e.abrupt("return",t);case 7:throw new Error("No current session!");case 8:case"end":return e.stop()}},e,this)}))).apply(this,arguments)}function R(e){return A.apply(this,arguments)}function A(){return(A=s()(o.a.mark(function e(t){var n;return o.a.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,r.auth.currentSession();case 3:if(!(n=e.sent)){e.next=6;break}return e.abrupt("return",n);case 6:e.next=14;break;case 8:return e.prev=8,e.t0=e.catch(0),e.next=12,r.auth.login(t);case 12:return n=e.sent,e.abrupt("return",n);case 14:return e.next=16,r.auth.login(t);case 16:return n=e.sent,e.abrupt("return",n);case 18:case"end":return e.stop()}},e,this,[[0,8]])}))).apply(this,arguments)}function C(e,t,n,r){return P.apply(this,arguments)}function P(){return(P=s()(o.a.mark(function e(t,n,i,a){return o.a.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new Promise(function(e,o){var s='<http://www.w3.org/ns/ldp#Resource>; rel="type"';"folder"===a&&(s='<http://www.w3.org/ns/ldp#BasicContainer>; rel="type"',a="text/turtle");var u={method:"POST",headers:{slug:n,link:s},body:i};void 0===a&&"undefined"==typeof window||(u.headers["Content-Type"]=a),r.auth.fetch(t,u).then(function(n){var r=n.headers.get("location"),i=r.substr(r.lastIndexOf("/")+1);e(t+i)},function(e){o(e)})}));case 1:case"end":return e.stop()}},e,this)}))).apply(this,arguments)}function L(e){return D.apply(this,arguments)}function D(){return(D=s()(o.a.mark(function e(t){return o.a.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new Promise(function(e,n){$(t).then(function(t){e()},function(r){U(t,void 0,"folder").then(function(t){e(t)},function(e){n(e)})})}));case 1:case"end":return e.stop()}},e,this)}))).apply(this,arguments)}function U(e,t,n){return M.apply(this,arguments)}function M(){return(M=s()(o.a.mark(function e(t,n,r){return o.a.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new Promise(function(e,i){var o=t.replace(/\/$/,"").replace(/.*\//,"");C(t.substring(0,t.lastIndexOf(o)),o,n,r).then(function(t){e(t)},function(e){i(e)})}));case 1:case"end":return e.stop()}},e,this)}))).apply(this,arguments)}function F(){return B.apply(this,arguments)}function B(){return(B=s()(o.a.mark(function e(){return o.a.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",r.auth.logout());case 1:case"end":return e.stop()}},e,this)}))).apply(this,arguments)}function q(e){return z.apply(this,arguments)}function z(){return(z=s()(o.a.mark(function e(t){return o.a.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",J(t));case 1:case"end":return e.stop()}},e,this)}))).apply(this,arguments)}function H(e){return V.apply(this,arguments)}function V(){return(V=s()(o.a.mark(function e(t){return o.a.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",J(t));case 1:case"end":return e.stop()}},e,this)}))).apply(this,arguments)}function J(e){return W.apply(this,arguments)}function W(){return(W=s()(o.a.mark(function e(t){return o.a.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new Promise(function(e,n){Z(t,{method:"DELETE"}).then(function(t){e(t)},function(t){e(t)})}));case 1:case"end":return e.stop()}},e,this)}))).apply(this,arguments)}function X(e,t,n){return Y.apply(this,arguments)}function Y(){return(Y=s()(o.a.mark(function e(t,n,r){var i;return o.a.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,J(t);case 2:if(!(i=e.sent).match||!i.match(/409/)){e.next=5;break}throw new Error("Coulnd't delete, conflict!");case 5:return e.next=7,U(t,n,r);case 7:return i=e.sent,e.abrupt("return",i);case 9:case"end":return e.stop()}},e,this)}))).apply(this,arguments)}function $(e){return K.apply(this,arguments)}function K(){return(K=s()(o.a.mark(function e(t){return o.a.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new Promise(function(e,n){Z(t).then(function(t){e(t)},function(e){return n("fetch error "+e)})}));case 1:case"end":return e.stop()}},e,this)}))).apply(this,arguments)}function G(e){return Q.apply(this,arguments)}function Q(){return(Q=s()(o.a.mark(function e(t){return o.a.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return"/"!=t.substr(-1)&&(t+="/"),e.abrupt("return",new Promise(function(e,n){Z(t,{headers:{Accept:"text/turtle"}}).then(function(r){v(r,t,"text/turtle").then(function(n){e(d(n,t,r))},function(e){return n(e)})},function(e){return n(e)})}));case 2:case"end":return e.stop()}},e,this)}))).apply(this,arguments)}function Z(e,t){return ee.apply(this,arguments)}function ee(){return(ee=s()(o.a.mark(function e(t,n){return o.a.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new Promise(function(e,i){r.auth.fetch(t,n).then(function(n){n.ok||i(n.status+" ("+n.statusText+") "+t);var r=n.headers._headers?n.headers._headers["content-type"]:"";(r=r.toString()).match(/(image|audio|video)/)?n.buffer().then(function(t){e(t)},function(e){return i("buffer error "+e)}):n.text?n.text().then(function(t){e(t)},function(e){return i("buffer error "+e)}):e(n)},function(e){i("fetch errror "+e+t)})}));case 1:case"end":return e.stop()}},e,this)}))).apply(this,arguments)}function te(e){return ne.apply(this,arguments)}function ne(){return(ne=s()(o.a.mark(function e(t){return o.a.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",r.auth.getCredentials(t));case 1:case"end":return e.stop()}},e,this)}))).apply(this,arguments)}function re(e){return ie.apply(this,arguments)}function ie(){return(ie=s()(o.a.mark(function e(t){return o.a.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",!0);case 1:case"end":return e.stop()}},e,this)}))).apply(this,arguments)}function oe(e,t){return ae.apply(this,arguments)}function ae(){return(ae=s()(o.a.mark(function e(t,n){return o.a.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if("undefined"==typeof window){e.next=2;break}return e.abrupt("return",re(t));case 2:return e.abrupt("return",new Promise(function(e,r){Z(t,{encoding:null}).then(function(i){n.match(/\/$/)||(n+="/");var o=n+t.replace(/.*\//,"");try{fs.writeFileSync(o,i),e(o)}catch(e){r("write error "+o+" "+e)}},function(e){r("fetch error "+e)})}));case 3:case"end":return e.stop()}},e,this)}))).apply(this,arguments)}function se(e,t){return ue.apply(this,arguments)}function ue(){return(ue=s()(o.a.mark(function e(t,n){return o.a.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if("undefined"==typeof window){e.next=2;break}return e.abrupt("return",re(n));case 2:return e.abrupt("return",new Promise(function(e,r){var i=fs.readFileSync(t,"utf-8");n.match(/\/$/)||(n+="/"),q(n+=t.replace(/.*\//,"")).then(function(){U(n,i).then(function(){e(t)},function(e){r("create "+e)})},function(e){r("delete error "+e)})}));case 3:case"end":return e.stop()}},e,this)}))).apply(this,arguments)}n.d(t,"copyFolder",function(){return m}),n.d(t,"guessFileType",function(){return w}),n.d(t,"processFolder",function(){return b}),n.d(t,"text2graph",function(){return x}),n.d(t,"copyFile",function(){return k}),n.d(t,"fetchAndParse",function(){return T}),n.d(t,"popupLogin",function(){return O}),n.d(t,"checkSession",function(){return N}),n.d(t,"login",function(){return R}),n.d(t,"add",function(){return C}),n.d(t,"createFolder",function(){return L}),n.d(t,"createFile",function(){return U}),n.d(t,"logout",function(){return F}),n.d(t,"deleteFile",function(){return q}),n.d(t,"deleteFolder",function(){return H}),n.d(t,"remove",function(){return J}),n.d(t,"updateFile",function(){return X}),n.d(t,"readFile",function(){return $}),n.d(t,"readFolder",function(){return G}),n.d(t,"fetch",function(){return Z}),n.d(t,"getCredentials",function(){return te}),n.d(t,"doWin",function(){return re}),n.d(t,"downloadFile",function(){return oe}),n.d(t,"uploadFile",function(){return se}),void 0!==c.a&&(r={auth:c.a})}])});
  //# sourceMappingURL=solid-file-client.bundle.js.map