mubot-server
Version:
A server for mubot
54 lines • 452 kB
JavaScript
var SolidClient=function(e){function t(n){if(r[n])return r[n].exports;var i=r[n]={exports:{},id:n,loaded:!1};return e[n].call(i.exports,i,i.exports,t),i.loaded=!0,i.exports}var r={};return t.m=e,t.c=r,t.p="",t(0)}(function(e){for(var t in e)if(Object.prototype.hasOwnProperty.call(e,t))switch(typeof e[t]){case"function":break;case"object":e[t]=function(t){var r=t.slice(1),n=e[t[0]];return function(e,t,i){n.apply(this,[e,t,i].concat(r))}}(e[t]);break;default:e[t]=e[e[t]]}return e}([function(e,t,r){e.exports=r(1)},function(e,t,r){"use strict";var n=r(2),i=r(85),o=r(90)(n),a=r(102),s=new a(o),u=r(104),l=r(88)(n),c={acl:i.acl,AppRegistration:r(107),appRegistry:r(106),auth:s,config:r(115),currentUser:s.currentUser.bind(s),identity:r(104),login:s.login.bind(s),meta:r(116),rdflib:n,signup:s.signup.bind(s),status:r(118),typeRegistry:r(113),vocab:l,web:o};c.clearPermissions=function(e){return i.clearPermissions(e,o)},c.discoverWebID=function(e){return u.discoverWebID(e,o,l)},c.getPermissions=function(e){return i.getPermissions(e,o,n)},c.getProfile=function(e,t){return u.getProfile(e,t,o,n)},e.exports=c},function(e,t,r){"use strict";var n;n="undefined"!=typeof $rdf?$rdf:"undefined"!=typeof tabulator?tabulator.rdf:r(3),e.exports=n},function(e,t,r){"use strict";var n={BlankNode:r(4),Collection:r(7),convert:r(11),DataFactory:r(56),Empty:r(79),Fetcher:r(58),Formula:r(73),IndexedFormula:r(72),jsonParser:r(80),Literal:r(8),log:r(59),N3Parser:r(60),NamedNode:r(9),Namespace:r(67),Node:r(6),parse:r(68),Query:r(78).Query,queryToSPARQL:r(81),RDFaProcessor:r(69),RDFParser:r(70),serialize:r(74),Serializer:r(75),SPARQLToQuery:r(82),sparqlUpdateParser:r(71),Statement:r(76),term:r(6).fromValue,UpdateManager:r(83),UpdatesSocket:r(84).UpdatesSocket,UpdatesVia:r(84).UpdatesVia,uri:r(61),Util:r(62),Variable:r(77)};n.NextId=n.BlankNode.nextId,n.fromNT=n.Formula.prototype.fromNT,n.fetcher=n.DataFactory.fetcher,n.graph=n.DataFactory.graph,n.lit=n.DataFactory.lit,n.st=n.DataFactory.st,n.sym=n.DataFactory.namedNode,n.variable=n.DataFactory.variable,n.blankNode=n.DataFactory.blankNode,n.defaultGraph=n.DataFactory.defaultGraph,n.literal=n.DataFactory.literal,n.namedNode=n.DataFactory.namedNode,n.quad=n.DataFactory.quad,n.triple=n.DataFactory.triple,e.exports=n},function(e,t,r){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!==("undefined"==typeof t?"undefined":a(t))&&"function"!=typeof t?e:t}function o(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+("undefined"==typeof t?"undefined":a(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)}var a="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},s=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}(),u=r(5),l=r(6),c=function(e){function t(e){n(this,t);var r=i(this,Object.getPrototypeOf(t).call(this));return r.termType=t.termType,r.id=t.nextId++,r.value=e||r.id.toString(),r}return o(t,e),s(t,[{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 r=new t;return e.copyTo(this,r),r}},{key:"toCanonical",value:function(){return"_:"+this.value}},{key:"toString",value:function(){return t.NTAnonymousNodePrefix+this.id}}]),t}(l);c.nextId=0,c.termType="BlankNode",c.NTAnonymousNodePrefix="_:n",c.prototype.classOrder=u.BlankNode,c.prototype.isBlank=1,c.prototype.isVar=1,e.exports=c},function(e,t){"use strict";var r={Literal:1,Collection:3,Formula:4,NamedNode:5,BlankNode:6,Variable:7};e.exports=r},function(e,t,r){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var i=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}(),o=function(){function e(){n(this,e)}return i(e,[{key:"substitute",value:function(e){return 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")}}]),e}();e.exports=o,o.fromValue=function(e){var t=r(7),n=r(8);r(9);if("undefined"==typeof e||null===e)return e;var i=e&&e.termType;return i?e:Array.isArray(e)?new t(e):n.fromValue(e)}},function(e,t,r){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!==("undefined"==typeof t?"undefined":a(t))&&"function"!=typeof t?e:t}function o(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+("undefined"==typeof t?"undefined":a(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)}var a="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},s=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}(),u=r(4),l=r(5),c=r(6),f=function(e){function t(e){n(this,t);var r=i(this,Object.getPrototypeOf(t).call(this));return r.termType=t.termType,r.id=u.nextId++,r.elements=[],r.closed=!1,e&&e.length>0&&e.forEach(function(e){r.elements.push(c.fromValue(e))}),r}return o(t,e),s(t,[{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){var r=this.elements.map(function(t){t.substitute(e)});return new t(r)}},{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)}}]),t}(c);f.termType="collection",f.prototype.classOrder=l.Collection,f.prototype.compareTerm=u.prototype.compareTerm,f.prototype.isVar=0,e.exports=f},function(e,t,r){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!==("undefined"==typeof t?"undefined":a(t))&&"function"!=typeof t?e:t}function o(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+("undefined"==typeof t?"undefined":a(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)}var a="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},s="function"==typeof Symbol&&"symbol"===a(Symbol.iterator)?function(e){return"undefined"==typeof e?"undefined":a(e)}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol?"symbol":"undefined"==typeof e?"undefined":a(e)},u=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}(),l=r(5),c=r(9),f=r(6),h=r(10),d=function(e){function t(e,r,o){n(this,t);var a=i(this,Object.getPrototypeOf(t).call(this));return a.termType=t.termType,a.value=e,r&&(a.lang=r,o=h.langString),o&&(a.datatype=c.fromValue(o)),a}return o(t,e),u(t,[{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.replace(/\\/g,"\\\\"),e=e.replace(/\"/g,'\\"'),e=e.replace(/\n/g,"\\n"),e='"'+e+'"',this.language?e+="@"+this.language:this.datatype.equals(h.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||""}}],[{key:"fromBoolean",value:function(e){var r=e?"1":"0";return new t(r,null,h["boolean"])}},{key:"fromDate",value:function(e){if(!(e instanceof Date))throw new TypeError("Invalid argument to Literal.fromDate()");var r=function(e){return(""+(100+e)).slice(1,3)},n=""+e.getUTCFullYear()+"-"+r(e.getUTCMonth()+1)+"-"+r(e.getUTCDate())+"T"+r(e.getUTCHours())+":"+r(e.getUTCMinutes())+":"+r(e.getUTCSeconds())+"Z";return new t(n,null,h.dateTime)}},{key:"fromNumber",value:function(e){if("number"!=typeof e)throw new TypeError("Invalid argument to Literal.fromNumber()");var r=void 0;return r=(""+e).indexOf("e")>=0?h["float"]:(""+e).indexOf(".")>=0?h.decimal:h.integer,new t(""+e,null,r)}},{key:"fromValue",value:function(e){if("undefined"==typeof e||null===e)return e;if(e&&e.termType)return e;switch("undefined"==typeof e?"undefined":s(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 "+("undefined"==typeof e?"undefined":s(e)))}}]),t}(f);d.termType="Literal",d.prototype.classOrder=l.Literal,d.prototype.datatype=h.string,d.prototype.lang="",d.prototype.isVar=0,e.exports=d},function(e,t,r){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!==("undefined"==typeof t?"undefined":a(t))&&"function"!=typeof t?e:t}function o(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+("undefined"==typeof t?"undefined":a(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)}var a="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},s=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}(),u=r(5),l=r(6),c=function(e){function t(e){n(this,t);var r=i(this,Object.getPrototypeOf(t).call(this));return r.termType=t.termType,r.value=e,r}return o(t,e),s(t,[{key:"dir",value:function(){var e=this.uri.split("#")[0],r=e.slice(0,-1).lastIndexOf("/"),n=e.indexOf("//");return n>=0&&r<n+2||r<0?null: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}}],[{key:"fromValue",value:function(e){if("undefined"==typeof e||null===e)return e;var r=e&&e.termType;return r?e:new t(e)}}]),t}(l);c.termType="NamedNode",c.prototype.classOrder=u.NamedNode,c.prototype.isVar=0,e.exports=c},function(e,t,r){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var i=r(9),o=function a(){n(this,a)};o["boolean"]=new i("http://www.w3.org/2001/XMLSchema#boolean"),o.dateTime=new i("http://www.w3.org/2001/XMLSchema#dateTime"),o.decimal=new i("http://www.w3.org/2001/XMLSchema#decimal"),o["float"]=new i("http://www.w3.org/2001/XMLSchema#float"),o.integer=new i("http://www.w3.org/2001/XMLSchema#integer"),o.langString=new i("http://www.w3.org/1999/02/22-rdf-syntax-ns#langString"),o.string=new i("http://www.w3.org/2001/XMLSchema#string"),e.exports=o},function(e,t,r){"use strict";function n(e,t){var r,n=s.Parser(),i=s.Writer({format:"N-Quads"});o.waterfall([function(t){n.parse(e,t)},function(e,t,r){null!==e&&i.addTriple(e),"function"==typeof r&&i.end(r)},function(e,t){try{a.fromRDF(e,{format:"application/nquads"},t)}catch(r){t(r)}},function(e,n){r=JSON.stringify(e),t(null,r)}],function(e,n){t(e,r)})}function i(e,t){var r,n=s.Parser(),i=s.Writer({format:"N-Quads"});o.waterfall([function(t){n.parse(e,t)},function(e,t,r){null!==e&&i.addTriple(e),"function"==typeof r&&i.end(r)},function(e,n){r=e,t(null,r)}],function(e,n){t(e,r)})}e.exports.convertToJson=n,e.exports.convertToNQuads=i;var o=r(12),a=r(15),s=r(22)},function(e,t,r){var n,i;(function(r,o){"use strict";/*!
* async
* https://github.com/caolan/async
*
* Copyright 2010-2014 Caolan McMahon
* Released under the MIT license
*/
!function(){function a(e){var t=!1;return function(){if(t)throw new Error("Callback was already called.");t=!0,e.apply(s,arguments)}}var s,u,l={};s=this,null!=s&&(u=s.async),l.noConflict=function(){return s.async=u,l};var c=Object.prototype.toString,f=Array.isArray||function(e){return"[object Array]"===c.call(e)},h=function(e,t){for(var r=0;r<e.length;r+=1)t(e[r],r,e)},d=function(e,t){if(e.map)return e.map(t);var r=[];return h(e,function(e,n,i){r.push(t(e,n,i))}),r},p=function(e,t,r){return e.reduce?e.reduce(t,r):(h(e,function(e,n,i){r=t(r,e,n,i)}),r)},g=function(e){if(Object.keys)return Object.keys(e);var t=[];for(var r in e)e.hasOwnProperty(r)&&t.push(r);return t};"undefined"!=typeof r&&r.nextTick?(l.nextTick=r.nextTick,"undefined"!=typeof o?l.setImmediate=function(e){o(e)}:l.setImmediate=l.nextTick):"function"==typeof o?(l.nextTick=function(e){o(e)},l.setImmediate=l.nextTick):(l.nextTick=function(e){setTimeout(e,0)},l.setImmediate=l.nextTick),l.each=function(e,t,r){function n(t){t?(r(t),r=function(){}):(i+=1,i>=e.length&&r())}if(r=r||function(){},!e.length)return r();var i=0;h(e,function(e){t(e,a(n))})},l.forEach=l.each,l.eachSeries=function(e,t,r){if(r=r||function(){},!e.length)return r();var n=0,i=function o(){t(e[n],function(t){t?(r(t),r=function(){}):(n+=1,n>=e.length?r():o())})};i()},l.forEachSeries=l.eachSeries,l.eachLimit=function(e,t,r,n){var i=v(t);i.apply(null,[e,r,n])},l.forEachLimit=l.eachLimit;var v=function(e){return function(t,r,n){if(n=n||function(){},!t.length||e<=0)return n();var i=0,o=0,a=0;!function s(){if(i>=t.length)return n();for(;a<e&&o<t.length;)o+=1,a+=1,r(t[o-1],function(e){e?(n(e),n=function(){}):(i+=1,a-=1,i>=t.length?n():s())})}()}},y=function(e){return function(){var t=Array.prototype.slice.call(arguments);return e.apply(null,[l.each].concat(t))}},m=function(e,t){return function(){var r=Array.prototype.slice.call(arguments);return t.apply(null,[v(e)].concat(r))}},b=function(e){return function(){var t=Array.prototype.slice.call(arguments);return e.apply(null,[l.eachSeries].concat(t))}},w=function(e,t,r,n){if(t=d(t,function(e,t){return{index:t,value:e}}),n){var i=[];e(t,function(e,t){r(e.value,function(r,n){i[e.index]=n,t(r)})},function(e){n(e,i)})}else e(t,function(e,t){r(e.value,function(e){t(e)})})};l.map=y(w),l.mapSeries=b(w),l.mapLimit=function(e,t,r,n){return x(t)(e,r,n)};var x=function(e){return m(e,w)};l.reduce=function(e,t,r,n){l.eachSeries(e,function(e,n){r(t,e,function(e,r){t=r,n(e)})},function(e){n(e,t)})},l.inject=l.reduce,l.foldl=l.reduce,l.reduceRight=function(e,t,r,n){var i=d(e,function(e){return e}).reverse();l.reduce(i,t,r,n)},l.foldr=l.reduceRight;var _=function(e,t,r,n){var i=[];t=d(t,function(e,t){return{index:t,value:e}}),e(t,function(e,t){r(e.value,function(r){r&&i.push(e),t()})},function(e){n(d(i.sort(function(e,t){return e.index-t.index}),function(e){return e.value}))})};l.filter=y(_),l.filterSeries=b(_),l.select=l.filter,l.selectSeries=l.filterSeries;var T=function(e,t,r,n){var i=[];t=d(t,function(e,t){return{index:t,value:e}}),e(t,function(e,t){r(e.value,function(r){r||i.push(e),t()})},function(e){n(d(i.sort(function(e,t){return e.index-t.index}),function(e){return e.value}))})};l.reject=y(T),l.rejectSeries=b(T);var E=function(e,t,r,n){e(t,function(e,t){r(e,function(r){r?(n(e),n=function(){}):t()})},function(e){n()})};l.detect=y(E),l.detectSeries=b(E),l.some=function(e,t,r){l.each(e,function(e,n){t(e,function(e){e&&(r(!0),r=function(){}),n()})},function(e){r(!1)})},l.any=l.some,l.every=function(e,t,r){l.each(e,function(e,n){t(e,function(e){e||(r(!1),r=function(){}),n()})},function(e){r(!0)})},l.all=l.every,l.sortBy=function(e,t,r){l.map(e,function(e,r){t(e,function(t,n){t?r(t):r(null,{value:e,criteria:n})})},function(e,t){if(e)return r(e);var n=function(e,t){var r=e.criteria,n=t.criteria;return r<n?-1:r>n?1:0};r(null,d(t.sort(n),function(e){return e.value}))})},l.auto=function(e,t){t=t||function(){};var r=g(e),n=r.length;if(!n)return t();var i={},o=[],a=function(e){o.unshift(e)},s=function(e){for(var t=0;t<o.length;t+=1)if(o[t]===e)return void o.splice(t,1)},u=function(){n--,h(o.slice(0),function(e){e()})};a(function(){if(!n){var e=t;t=function(){},e(null,i)}}),h(r,function(r){var n=f(e[r])?e[r]:[e[r]],o=function(e){var n=Array.prototype.slice.call(arguments,1);if(n.length<=1&&(n=n[0]),e){var o={};h(g(i),function(e){o[e]=i[e]}),o[r]=n,t(e,o),t=function(){}}else i[r]=n,l.setImmediate(u)},c=n.slice(0,Math.abs(n.length-1))||[],d=function(){return p(c,function(e,t){return e&&i.hasOwnProperty(t)},!0)&&!i.hasOwnProperty(r)};if(d())n[n.length-1](o,i);else{var v=function y(){d()&&(s(y),n[n.length-1](o,i))};a(v)}})},l.retry=function(e,t,r){var n=5,i=[];"function"==typeof e&&(r=t,t=e,e=n),e=parseInt(e,10)||n;var o=function(n,o){for(var a=function(e,t){return function(r){e(function(e,n){r(!e||t,{err:e,result:n})},o)}};e;)i.push(a(t,!(e-=1)));l.series(i,function(e,t){t=t[t.length-1],(n||r)(t.err,t.result)})};return r?o():o},l.waterfall=function(e,t){if(t=t||function(){},!f(e)){var r=new Error("First argument to waterfall must be an array of functions");return t(r)}if(!e.length)return t();var n=function i(e){return function(r){if(r)t.apply(null,arguments),t=function(){};else{var n=Array.prototype.slice.call(arguments,1),o=e.next();o?n.push(i(o)):n.push(t),l.setImmediate(function(){e.apply(null,n)})}}};n(l.iterator(e))()};var k=function(e,t,r){if(r=r||function(){},f(t))e.map(t,function(e,t){e&&e(function(e){var r=Array.prototype.slice.call(arguments,1);r.length<=1&&(r=r[0]),t.call(null,e,r)})},r);else{var n={};e.each(g(t),function(e,r){t[e](function(t){var i=Array.prototype.slice.call(arguments,1);i.length<=1&&(i=i[0]),n[e]=i,r(t)})},function(e){r(e,n)})}};l.parallel=function(e,t){k({map:l.map,each:l.each},e,t)},l.parallelLimit=function(e,t,r){k({map:x(t),each:v(t)},e,r)},l.series=function(e,t){if(t=t||function(){},f(e))l.mapSeries(e,function(e,t){e&&e(function(e){var r=Array.prototype.slice.call(arguments,1);r.length<=1&&(r=r[0]),t.call(null,e,r)})},t);else{var r={};l.eachSeries(g(e),function(t,n){e[t](function(e){var i=Array.prototype.slice.call(arguments,1);i.length<=1&&(i=i[0]),r[t]=i,n(e)})},function(e){t(e,r)})}},l.iterator=function(e){var t=function r(t){var n=function i(){return e.length&&e[t].apply(null,arguments),i.next()};return n.next=function(){return t<e.length-1?r(t+1):null},n};return t(0)},l.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 S=function(e,t,r,n){var i=[];e(t,function(e,t){r(e,function(e,r){i=i.concat(r||[]),t(e)})},function(e){n(e,i)})};l.concat=y(S),l.concatSeries=b(S),l.whilst=function(e,t,r){e()?t(function(n){return n?r(n):void l.whilst(e,t,r)}):r()},l.doWhilst=function(e,t,r){e(function(n){if(n)return r(n);var i=Array.prototype.slice.call(arguments,1);t.apply(null,i)?l.doWhilst(e,t,r):r()})},l.until=function(e,t,r){e()?r():t(function(n){return n?r(n):void l.until(e,t,r)})},l.doUntil=function(e,t,r){e(function(n){if(n)return r(n);var i=Array.prototype.slice.call(arguments,1);t.apply(null,i)?r():l.doUntil(e,t,r)})},l.queue=function(e,t){function r(e,t,r,n){return e.started||(e.started=!0),f(t)||(t=[t]),0==t.length?l.setImmediate(function(){e.drain&&e.drain()}):void h(t,function(t){var i={data:t,callback:"function"==typeof n?n:null};r?e.tasks.unshift(i):e.tasks.push(i),e.saturated&&e.tasks.length===e.concurrency&&e.saturated(),l.setImmediate(e.process)})}void 0===t&&(t=1);var n=0,i={tasks:[],concurrency:t,saturated:null,empty:null,drain:null,started:!1,paused:!1,push:function(e,t){r(i,e,!1,t)},kill:function(){i.drain=null,i.tasks=[]},unshift:function(e,t){r(i,e,!0,t)},process:function(){if(!i.paused&&n<i.concurrency&&i.tasks.length){var t=i.tasks.shift();i.empty&&0===i.tasks.length&&i.empty(),n+=1;var r=function(){n-=1,t.callback&&t.callback.apply(t,arguments),i.drain&&i.tasks.length+n===0&&i.drain(),i.process()},o=a(r);e(t.data,o)}},length:function(){return i.tasks.length},running:function(){return n},idle:function(){return i.tasks.length+n===0},pause:function(){i.paused!==!0&&(i.paused=!0)},resume:function(){if(i.paused!==!1){i.paused=!1;for(var e=1;e<=i.concurrency;e++)l.setImmediate(i.process)}}};return i},l.priorityQueue=function(e,t){function r(e,t){return e.priority-t.priority}function n(e,t,r){for(var n=-1,i=e.length-1;n<i;){var o=n+(i-n+1>>>1);r(t,e[o])>=0?n=o:i=o-1}return n}function i(e,t,i,o){return e.started||(e.started=!0),f(t)||(t=[t]),0==t.length?l.setImmediate(function(){e.drain&&e.drain()}):void h(t,function(t){var a={data:t,priority:i,callback:"function"==typeof o?o:null};e.tasks.splice(n(e.tasks,a,r)+1,0,a),e.saturated&&e.tasks.length===e.concurrency&&e.saturated(),l.setImmediate(e.process)})}var o=l.queue(e,t);return o.push=function(e,t,r){i(o,e,t,r)},delete o.unshift,o},l.cargo=function(e,t){var r=!1,n=[],i={tasks:n,payload:t,saturated:null,empty:null,drain:null,drained:!0,push:function(e,r){f(e)||(e=[e]),h(e,function(e){n.push({data:e,callback:"function"==typeof r?r:null}),i.drained=!1,i.saturated&&n.length===t&&i.saturated()}),l.setImmediate(i.process)},process:function o(){if(!r){if(0===n.length)return i.drain&&!i.drained&&i.drain(),void(i.drained=!0);var a="number"==typeof t?n.splice(0,t):n.splice(0,n.length),s=d(a,function(e){return e.data});i.empty&&i.empty(),r=!0,e(s,function(){r=!1;var e=arguments;h(a,function(t){t.callback&&t.callback.apply(null,e)}),o()})}},length:function(){return n.length},running:function(){return r}};return i};var N=function(e){return function(t){var r=Array.prototype.slice.call(arguments,1);t.apply(null,r.concat([function(t){var r=Array.prototype.slice.call(arguments,1);"undefined"!=typeof console&&(t?console.error&&console.error(t):console[e]&&h(r,function(t){console[e](t)}))}]))}};l.log=N("log"),l.dir=N("dir"),l.memoize=function(e,t){var r={},n={};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 r?l.nextTick(function(){o.apply(null,r[a])}):a in n?n[a].push(o):(n[a]=[o],e.apply(null,i.concat([function(){r[a]=arguments;var e=n[a];delete n[a];for(var t=0,i=e.length;t<i;t++)e[t].apply(null,arguments)}])))};return i.memo=r,i.unmemoized=e,i},l.unmemoize=function(e){return function(){return(e.unmemoized||e).apply(null,arguments)}},l.times=function(e,t,r){for(var n=[],i=0;i<e;i++)n.push(i);return l.map(n,t,r)},l.timesSeries=function(e,t,r){for(var n=[],i=0;i<e;i++)n.push(i);return l.mapSeries(n,t,r)},l.seq=function(){var e=arguments;return function(){var t=this,r=Array.prototype.slice.call(arguments),n=r.pop();l.reduce(e,r,function(e,r,n){r.apply(t,e.concat([function(){var e=arguments[0],t=Array.prototype.slice.call(arguments,1);n(e,t)}]))},function(e,r){n.apply(t,[e].concat(r))})}},l.compose=function(){return l.seq.apply(null,Array.prototype.reverse.call(arguments))};var I=function(e,t){var r=function(){var r=this,n=Array.prototype.slice.call(arguments),i=n.pop();return e(t,function(e,t){e.apply(r,n.concat([t]))},i)};if(arguments.length>2){var n=Array.prototype.slice.call(arguments,2);return r.apply(this,n)}return r};l.applyEach=y(I),l.applyEachSeries=b(I),l.forever=function(e,t){function r(n){if(n){if(t)return t(n);throw n}e(r)}r()},"undefined"!=typeof e&&e.exports?e.exports=l:(n=[],i=function(){return l}.apply(t,n),!(void 0!==i&&(e.exports=i)))}()}).call(t,r(13),r(14).setImmediate)},function(e,t){"use strict";function r(e){return u===setTimeout?setTimeout(e,0):u.call(null,e,0)}function n(e){l===clearTimeout?clearTimeout(e):l.call(null,e)}function i(){d&&f&&(d=!1,f.length?h=f.concat(h):p=-1,h.length&&o())}function o(){if(!d){var e=r(i);d=!0;for(var t=h.length;t;){for(f=h,h=[];++p<t;)f&&f[p].run();p=-1,t=h.length}f=null,d=!1,n(e)}}function a(e,t){this.fun=e,this.array=t}function s(){}var u,l,c=e.exports={};!function(){try{u=setTimeout}catch(e){u=function(){throw new Error("setTimeout is not defined")}}try{l=clearTimeout}catch(e){l=function(){throw new Error("clearTimeout is not defined")}}}();var f,h=[],d=!1,p=-1;c.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];h.push(new a(e,t)),1!==h.length||d||r(o)},a.prototype.run=function(){this.fun.apply(null,this.array)},c.title="browser",c.browser=!0,c.env={},c.argv=[],c.version="",c.versions={},c.on=s,c.addListener=s,c.once=s,c.off=s,c.removeListener=s,c.removeAllListeners=s,c.emit=s,c.binding=function(e){throw new Error("process.binding is not supported")},c.cwd=function(){return"/"},c.chdir=function(e){throw new Error("process.chdir is not supported")},c.umask=function(){return 0}},function(e,t,r){(function(e,n){"use strict";function i(e,t){this._id=e,this._clearFn=t}var o=r(13).nextTick,a=Function.prototype.apply,s=Array.prototype.slice,u={},l=0;t.setTimeout=function(){return new i(a.call(setTimeout,window,arguments),clearTimeout)},t.setInterval=function(){return new i(a.call(setInterval,window,arguments),clearInterval)},t.clearTimeout=t.clearInterval=function(e){e.close()},i.prototype.unref=i.prototype.ref=function(){},i.prototype.close=function(){this._clearFn.call(window,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))},t.setImmediate="function"==typeof e?e:function(e){var r=l++,n=!(arguments.length<2)&&s.call(arguments,1);return u[r]=!0,o(function(){u[r]&&(n?e.apply(null,n):e.call(null),t.clearImmediate(r))}),r},t.clearImmediate="function"==typeof n?n:function(e){delete u[e]}}).call(t,r(14).setImmediate,r(14).clearImmediate)},function(e,t,r){var n,i;(function(o,a,s,u){"use strict";var l="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};/**
* 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 c="undefined"!=typeof o&&o.versions&&o.versions.node,f=!c&&("undefined"!=typeof window||"undefined"!=typeof self);f&&"undefined"==typeof a&&("undefined"!=typeof window?a=window:"undefined"!=typeof self?a=self:"undefined"!=typeof $&&(a=$));var h=function(e){function t(){}function n(e){for(var t=[],r=Object.keys(e).sort(),n=0;n<r.length;++n){var i=r[n],o=e[i];H(o)||(o=[o]);for(var a=0;a<o.length;++a){var s=o[a];if(null!==s){if(!X(s))throw new Le("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 i(e,t){if(H(t))for(var r=0;r<t.length;++r)t[r]=i(e,t[r]);else if(K(t))t["@list"]=i(e,t["@list"]);else if(B(t)){ee(t)&&(t["@id"]=e.getId(t["@id"]));for(var n=Object.keys(t).sort(),o=0;o<n.length;++o){var a=n[o];"@id"!==a&&(t[a]=i(e,t[a]))}}return t}function h(t,r,n){if(null===n||void 0===n)return null;var i=U(t,r,{vocab:!0});if("@id"===i)return U(t,n,{base:!0});if("@type"===i)return U(t,n,{vocab:!0,base:!0});var o=e.getContextValue(t,r,"@type");if("@id"===o||"@graph"===i&&X(n))return{"@id":U(t,n,{base:!0})};if("@vocab"===o)return{"@id":U(t,n,{vocab:!0,base:!0})};if(F(i))return n;var a={};if(null!==o)a["@type"]=o;else if(X(n)){var s=e.getContextValue(t,r,"@language");null!==s&&(a["@language"]=s)}return["boolean","number","string"].indexOf("undefined"==typeof n?"undefined":l(n))===-1&&(n=n.toString()),a["@value"]=n,a}function d(e,t,r){for(var n=[],i=Object.keys(e).sort(),o=0;o<i.length;++o)for(var a=i[o],s=e[a],u=Object.keys(s).sort(),l=0;l<u.length;++l){var c=u[l],f=s[c];if("@type"===c)c=Ne;else if(F(c))continue;for(var h=0;h<f.length;++h){var d=f[h],v={};if(v.type=0===a.indexOf("_:")?"blank node":"IRI",v.value=a,te(a)){var y={};if(y.type=0===c.indexOf("_:")?"blank node":"IRI",y.value=c,te(c)&&("blank node"!==y.type||r.produceGeneralizedRdf))if(K(d))p(d["@list"],t,v,y,n);else{var m=g(d);m&&n.push({subject:v,predicate:y,object:m})}}}}return n}function p(e,t,r,n,i){for(var o={type:"IRI",value:Ee},a={type:"IRI",value:ke},s={type:"IRI",value:Se},u=0;u<e.length;++u){var l=e[u],c={type:"blank node",value:t.getId()};i.push({subject:r,predicate:n,object:c}),r=c,n=o;var f=g(l);f&&i.push({subject:r,predicate:n,object:f}),n=a}i.push({subject:r,predicate:n,object:s})}function g(e){var t={};if(Z(e)){t.type="literal";var r=e["@value"],n=e["@type"]||null;G(r)?(t.value=r.toString(),t.datatype=n||me):W(r)||n===be?(W(r)||(r=parseFloat(r)),t.value=r.toExponential(15).replace(/(\d)0*e\+?/,"$1E"),t.datatype=n||be):V(r)?(t.value=r.toFixed(0),t.datatype=n||we):"@language"in e?(t.value=r,t.datatype=n||Ae,t.language=e["@language"]):(t.value=r,t.datatype=n||xe)}else{var i=B(e)?e["@id"]:e;t.type=0===i.indexOf("_:")?"blank node":"IRI",t.value=i}return"IRI"!==t.type||te(t.value)?t:null}function v(e,t){if("IRI"===e.type||"blank node"===e.type)return{"@id":e.value};var r={"@value":e.value};if(e.language)r["@language"]=e.language;else{var n=e.datatype;if(n||(n=xe),t){if(n===me)"true"===r["@value"]?r["@value"]=!0:"false"===r["@value"]&&(r["@value"]=!1);else if(Y(r["@value"]))if(n===we){var i=parseInt(r["@value"],10);i.toFixed(0)===r["@value"]&&(r["@value"]=i)}else n===be&&(r["@value"]=parseFloat(r["@value"]));[me,we,be,xe].indexOf(n)===-1&&(r["@type"]=n)}else n!==xe&&(r["@type"]=n)}return r}function y(e,t){for(var r=["subject","predicate","object"],n=0;n<r.length;++n){var i=r[n];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}function m(t,r,n,i,o,a){if(H(t))for(var s=0;s<t.length;++s)m(t[s],r,n,i,void 0,a);else{if(!B(t))return void(a&&a.push(t));if(Z(t)){if("@type"in t){var u=t["@type"];0===u.indexOf("_:")&&(t["@type"]=u=i.getId(u))}return void(a&&a.push(t))}if("@type"in t)for(var l=t["@type"],s=0;s<l.length;++s){var u=l[s];0===u.indexOf("_:")&&i.getId(u)}J(o)&&(o=ee(t)?i.getId(t["@id"]):t["@id"]),a&&a.push({"@id":o});var c=r[n],f=c[o]=c[o]||{};f["@id"]=o;for(var h=Object.keys(t).sort(),d=0;d<h.length;++d){var p=h[d];if("@id"!==p)if("@reverse"!==p)if("@graph"!==p)if("@type"!==p&&F(p)){if("@index"===p&&p in f&&(t[p]!==f[p]||t[p]["@id"]!==f[p]["@id"]))throw new Le("Invalid JSON-LD syntax; conflicting @index property detected.","jsonld.SyntaxError",{code:"conflicting indexes",subject:f});f[p]=t[p]}else{var g=t[p];if(0===p.indexOf("_:")&&(p=i.getId(p)),0!==g.length)for(var v=0;v<g.length;++v){var y=g[v];if("@type"===p&&(y=0===y.indexOf("_:")?i.getId(y):y),$(y)||Q(y)){var b=ee(y)?i.getId(y["@id"]):y["@id"];e.addValue(f,p,{"@id":b},{propertyIsArray:!0,allowDuplicate:!1}),m(y,r,n,i,b)}else if(K(y)){var w=[];m(y["@list"],r,n,i,o,w),y={"@list":w},e.addValue(f,p,y,{propertyIsArray:!0,allowDuplicate:!1})}else m(y,r,n,i,o),e.addValue(f,p,y,{propertyIsArray:!0,allowDuplicate:!1})}else e.addValue(f,p,[],{propertyIsArray:!0})}else{o in r||(r[o]={});var x="@merged"===n?n:o;m(t[p],r,x,i)}else{var _={"@id":o},T=t["@reverse"];for(var E in T)for(var k=T[E],S=0;S<k.length;++S){var N=k[S],I=N["@id"];ee(N)&&(I=i.getId(I)),m(N,r,n,i,I),e.addValue(c[I],E,_,{propertyIsArray:!0,allowDuplicate:!1})}}}}}function b(e){for(var t=e["@default"],r=Object.keys(e).sort(),n=0;n<r.length;++n){var i=r[n];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(),l=0;l<u.length;++l){var c=o[u[l]];Q(c)||s.push(c)}}}return t}function w(e,t,r,n,i){E(r),r=r[0];for(var o=e.options,a={embed:T(r,o,"embed"),explicit:T(r,o,"explicit"),requireAll:T(r,o,"requireAll")},s=k(e,t,r,a),u=Object.keys(s).sort(),l=0;l<u.length;++l){var c=u[l],f=s[c];if("@link"===a.embed&&c in e.link)I(n,i,e.link[c]);else{null===i&&(e.uniqueEmbeds={});var h={};if(h["@id"]=c,e.link[c]=h,"@never"===a.embed||_(f,e.subjectStack))I(n,i,h);else{"@last"===a.embed&&(c in e.uniqueEmbeds&&N(e,c),e.uniqueEmbeds[c]={parent:n,property:i}),e.subjectStack.push(f);for(var d=Object.keys(f).sort(),p=0;p<d.length;p++){var g=d[p];if(F(g))h[g]=re(f[g]);else if(!a.explicit||g in r)for(var v=f[g],y=0;y<v.length;++y){var m=v[y];if(K(m)){var b={"@list":[]};I(h,g,b);var S=m["@list"];for(var R in S)if(m=S[R],Q(m)){var j=g in r?r[g][0]["@list"]:x(a);w(e,[m["@id"]],j,b,"@list")}else I(b,"@list",re(m))}else if(Q(m)){var j=g in r?r[g]:x(a);w(e,[m["@id"]],j,h,g)}else I(h,g,re(m))}}for(var d=Object.keys(r).sort(),p=0;p<d.length;++p){var g=d[p];if(!F(g)){var A=r[g][0],O=T(A,o,"omitDefault");if(!(O||g in h)){var C="@null";"@default"in A&&(C=re(A["@default"])),H(C)||(C=[C]),h[g]=[{"@preserve":C}]}}}I(n,i,h),e.subjectStack.pop()}}}}function x(e){var t={};for(var r in e)void 0!==e[r]&&(t["@"+r]=[e[r]]);return[t]}function _(e,t){for(var r=t.length-1;r>=0;--r)if(t[r]["@id"]===e["@id"])return!0;return!1}function T(e,t,r){var n="@"+r,i=n in e?e[n][0]:t[r];return"embed"===r&&(i===!0?i="@last":i===!1?i="@never":"@always"!==i&&"@never"!==i&&"@link"!==i&&(i="@last")),i}function E(e){if(!H(e)||1!==e.length||!B(e[0]))throw new Le("Invalid JSON-LD syntax; a JSON-LD frame must be a single object.","jsonld.SyntaxError",{frame:e})}function k(e,t,r,n){for(var i={},o=0;o<t.length;++o){var a=t[o],s=e.subjects[a];S(s,r,n)&&(i[a]=s)}return i}function S(t,r,n){if("@type"in r&&(1!==r["@type"].length||!B(r["@type"][0]))){for(var i=r["@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 r){if(F(u)){if("@id"!==u&&"@type"!==u)continue;if(a=!1,"@id"===u&&X(r[u])){if(t[u]!==r[u])return!1;s=!0;continue}}if(a=!1,u in t){if(H(r[u])&&0===r[u].length&&void 0!==t[u])return!1;s=!0}else{var l=H(r[u])&&B(r[u][0])&&"@default"in r[u][0];if(n.requireAll&&!l)return!1}}return a||s}function N(t,r){var n=t.uniqueEmbeds,i=n[r],o=i.parent,a=i.property,s={"@id":r};if(H(o)){for(var u=0;u<o.length;++u)if(e.compareValues(o[u],s)){o[u]=s;break}}else{var l=H(o[a]);e.removeValue(o,a,s,{propertyIsArray:l}),e.addValue(o,a,s,{propertyIsArray:l})}var c=function f(e){for(var t=Object.keys(n),r=0;r<t.length;++r){var i=t[r];i in n&&B(n[i].parent)&&n[i].parent["@id"]===e&&(delete n[i],f(i))}};c(r)}function I(t,r,n){B(t)?e.addValue(t,r,n,{propertyIsArray:!0}):t.push(n)}/**
* 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 R(t,r,n){if(H(r)){for(var i=[],o=0;o<r.length;++o){var a=R(t,r[o],n);null!==a&&i.push(a)}r=i}else if(B(r)){// remove @preserve
if("@preserve"in r)return"@null"===r["@preserve"]?null:r["@preserve"];if(Z(r))return r;if(K(r))return r["@list"]=R(t,r["@list"],n),r;var s=O(t,"@id");if(s in r){var u=r[s];if(u in n.link){var l=n.link[u].indexOf(r);if(l!==-1)return n.link[u][l];n.link[u].push(r)}else n.link[u]=[r]}for(var c in r){var a=R(t,r[c],n),f=e.getContextValue(t,c,"@container");n.compactArrays&&H(a)&&1===a.length&&null===f&&(a=a[0]),r[c]=a}}return r}function j(e,t){return e.length<t.length?-1:t.length<e.length?1:e===t?0:e<t?-1:1}function A(e,t,r,n,i,o){null===o&&(o="@null");var a=[];if("@id"!==o&&"@reverse"!==o||!Q(r))a.push(o);else{"@reverse"===o&&a.push("@reverse");var s=O(e,r["@id"],null,{vocab:!0});s in e.mappings&&e.mappings[s]&&e.mappings[s]["@id"]===r["@id"]?a.push.apply(a,["@vocab","@id"]):a.push.apply(a,["@id","@vocab"])}a.push("@none");for(var u=e.inverse[t],l=0;l<n.length;++l){var c=n[l];if(c in u)for(var f=u[c][i],h=0;h<a.length;++h){var d=a[h];if(d in f)return f[d]}}return null}function O(e,t,r,n,i){if(null===t)return t;J(r)&&(r=null),J(i)&&(i=!1),n=n||{};var o=e.getInverse();if(F(t))return t in o?o[t]["@none"]["@type"]["@none"]:t;if(n.vocab&&t in o){var a=e["@language"]||"@none",s=[];B(r)&&"@index"in r&&s.push("@index");var u="@language",l="@null";if(i)u="@type",l="@reverse",s.push("@set");else if(K(r)){"@index"in r||s.push("@list");for(var c=r["@list"],f=0===c.length?a:null,h=null,d=0;d<c.length;++d){var p=c[d],g="@none",v="@none";if(Z(p)?"@language"in p?g=p["@language"]:"@type"in p?v=p["@type"]:g="@null":v="@id",null===f?f=g:g!==f&&Z(p)&&(f="@none"),null===h?h=v:v!==h&&(h="@none"),"@none"===f&&"@none"===h)break}f=f||"@none",h=h||"@none","@none"!==h?(u="@type",l=h):l=f}else Z(r)?"@language"in r&&!("@index"in r)?(s.push("@language"),l=r["@language"]):"@type"in r&&(u="@type",l=r["@type"]):(u="@type",l="@id"),s.push("@set");s.push("@none");var y=A(e,t,r,s,u,l);if(null!==y)return y}if(n.vocab&&"@vocab"in e){var m=e["@vocab"];if(0===t.indexOf(m)&&t!==m){var b=t.substr(m.length);if(!(b in e.mappings))return b}}for(var w=null,x=0,_=[],T=e.fastCurieMap,E=t.length-1;x<E&&t[x]in T;++x)T=T[t[x]],""in T&&_.push(T[""][0]);for(var d=_.length-1;d>=0;--d)for(var k=_[d],S=k.terms,N=0;N<S.length;++N){var I=S[N]+":"+t.substr(k.iri.length),R=!(I in e.mappings)||null===r&&e.mappings[I]["@id"]===t;R&&(null===w||j(I,w)<0)&&(w=I)}return null!==w?w:n.vocab?t:P(e["@base"],t)}function C(t,r,n){if(Z(n)){var i=e.getContextValue(t,r,"@type"),o=e.getContextValue(t,r,"@language"),a=e.getContextValue(t,r,"@container"),s="@index"in n&&"@index"!==a;if(!s&&(n["@type"]===i||n["@language"]===o))return n["@value"];var u=Object.keys(n).length,l=1===u||2===u&&"@index"in n&&!s,c="@language"in t,f=X(n["@value"]),h=t.mappings[r]&&null===t.mappings[r]["@language"];if(l&&(!c||!f||h))return n["@value"];var d={};return s&&(d[O(t,"@index")]=n["@index"]),"@type"in n?d[O(t,"@type")]=O(t,n["@type"],null,{vocab:!0}):"@language"in n&&(d[O(t,"@language")]=n["@language"]),d[O(t,"@value")]=n["@value"],d}var p=U(t,r,{vocab:!0}),i=e.getContextValue(t,r,"@type"),g=O(t,n["@id"],null,{vocab:"@vocab"===i});if("@id"===i||"@vocab"===i||"@graph"===p)return g;var d={};return d[O(t,"@id")]=g,d}function L(e,t,r,n){if(r in n){if(n[r])return;throw new Le("Cyclical context definition detected.","jsonld.CyclicalContext",{code:"cyclic IRI mapping",context:t,term:r})}if(n[r]=!1,F(r))throw new Le("Invalid JSON-LD syntax; keywords cannot be overridden.","jsonld.SyntaxError",{code:"keyword redefinition",context:t,term:r});if(""===r)throw new Le("Invalid JSON-LD syntax; a term cannot be an empty string.","jsonld.SyntaxError",{code:"invalid term definition",context:t});e.mappings[r]&&delete e.mappings[r];var i=t[r];if(null===i||B(i)&&null===i["@id"])return e.mappings[r]=null,void(n[r]=!0);if(X(i)&&(i={"@id":i}),!B(i))throw new Le("Invalid JSON-LD syntax; @context property values must be strings or objects.","jsonld.SyntaxError",{code:"invalid term definition",context:t});var o=e.mappings[r]={};if(o.reverse=!1,"@reverse"in i){if("@id"in i)throw new Le("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(!X(a))throw new Le("Invalid JSON-LD syntax; a @context @reverse value must be a string.","jsonld.SyntaxError",{code:"invalid IRI mapping",context:t});var s=U(e,a,{vocab:!0,base:!1},t,n);if(!te(s))throw new Le("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){var s=i["@id"];if(!X(s))throw new Le("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!==r){if(s=U(e,s,{vocab:!0,base:!1},t,n),!te(s)&&!F(s))throw new Le("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 u=r.indexOf(":");if(o._termHasColon=u!==-1,!("@id"in o))if(o._termHasColon){var l=r.substr(0,u);if(l in t&&L(e,t,l,n),e.mappings[l]){var c=r.substr(u+1);o["@id"]=e.mappings[l]["@id"]+c}else o["@id"]=r}else{if(!("@vocab"in e))throw new Le("Invalid JSON-LD syntax; @context terms must define an @id.","jsonld.SyntaxError",{code:"invalid IRI mapping",context:t,term:r});o["@id"]=e["@vocab"]+r}if(n[r]=!0,"@type"in i){var f=i["@type"];if(!X(f))throw new Le("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(f=U(e,f,{vocab:!0,base:!1},t,n),!te(f))throw new Le("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 Le("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 Le("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 Le("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 d=i["@language"];if(null!==d&&!X(d))throw new Le("Invalid JSON-LD syntax; @context @language value must be a string or null.","jsonld.SyntaxError",{code:"invalid language mapping",context:t});null!==d&&(d=d.toLowerCase()),o["@language"]=d}// disallow aliasing @context and @preserve
var s=o["@id"];if("@context"===s||"@preserve"===s)throw new Le("Invalid JSON-LD syntax; @context and @preserve cannot be aliased.","jsonld.SyntaxError",{code:"invalid keyword alias",context:t})}function U(t,r,n,i,o){if(null===r||F(r))return r;if(r=String(r),i&&r in i&&o[r]!==!0&&L(t,i,r,o),n=n||{},n.vocab){var a=t.mappings[r];if(null===a)return null;if(a)return a["@id"]}var s=r.indexOf(":");if(s!==-1){var u=r.substr(0,s),l=r.substr(s+1);if("_"===u||0===l.indexOf("//"))return r;i&&u in i&&L(t,i,u,o);var a=t.mappings[u];return a?a["@id"]+l:r}if(n.vocab&&"@vocab"in t)return t["@vocab"]+r;var c=r;return n.base&&(c=e.prependBase(t["@base"],c)),c}function D(t,r){if(null===t)return r;if(r.indexOf(":")!==-1)return r;X(t)&&(t=e.url.parse(t||""));var n=e.url.parse(r),i={protocol:t.protocol||""};if(null!==n.authority)i.authority=n.authority,i.path=n.path,i.query=n.query;else if(i.authority=t.authority,""===n.path)i.path=t.path,null!==n.query?i.query=n.query:i.query=t.query;else{if(0===n.path.indexOf("/"))i.path=n.path;else{var o=t.path;""!==n.path&&(o=o.substr(0,o.lastIndexOf("/")+1),o.length>0&&"/"!==o.substr(-1)&&(o+="/"),o+=n.path),i.path=o}i.query=n.query}i.path=ce(i.path,!!i.authority);var a=i.protocol;return null!==i.authority&&(a+="//"+i.authority),a+=i.path,null!==i.query&&(a+="?"+i.query),null!==n.fragment&&(a+="#"+n.fragment),""===a&&(a="./"),a}function P(t,r){if(null===t)return r;X(t)&&(t=e.url.parse(t||""));var n="";if(""!==t.href?n+=(t.protocol||"")+"//"+(t.authority||""):r.indexOf("//")&&(n+="//"),0!==r.indexOf(n))return r;for(var i=e.url.parse(r.substr(n.length)),o=t.normalizedPath.split("/"),a=i.normalizedPath.split("/"),s=i.fragment||i.query?0:1;o.length>0&&a.length>s&&o[0]===a[0];)o.shift(),a.shift();var u="";if(o.length>0){o.pop();for(var l=0;l<o.length;++l)u+="../"}return u+=a.join("/"),null!==i.query&&(u+="?"+i.query),null!==i.fragment&&(u+="#"+i.fragment),""===u&&(u="./"),u}function M(t){function r(){var e=this;if(e.inverse)return e.inverse;for(var t=e.inverse={},r=e.fastCurieMap={},o={},a=e["@language"]||"@none",s=e.mappings,u=Object.keys(s).sort(j),l=0;l<u.length;++l){var c=u[l],f=s[c];if(null!==f){var h=f["@container"]||"@none",d=f["@id"];H(d)||(d=[d]);for(var p=0;p<d.length;++p){var g=d[p],v=t[g],y=F(g);if(v)y||f._termHasColon||o[g].push(c);else if(t[g]=v={},!y&&!f._termHasColon){o[g]=[c];var m={iri:g,terms:o[g]};g[0]in r?r[g[0]].push(m):r[g[0]]=[m]}if(v[h]||(v[h]={"@language":{},"@type":{}}),v=v[h],f.reverse)i(f,c,v["@type"],"@reverse");else if("@type"in f)i(f,c,v["@type"],f["@type"]);else if("@language"in f){var b=f["@language"]||"@null";i(f,c,v["@language"],b)}else i(f,c,v["@language"],a),i(f,c,v["@type"],"@none"),i(f,c,v["@language"],"@none")}}}for(var w in r)n(r,w,1);return t}function n(e,t,r){for(var i,o,a=e[t],s=e[t]={},u=0;u<a.length;++u)i=a[u].iri,o=r>=i.length?"":i[r],o in s?s[o].push(a[u]):s[o]=[a[u]];for(var t in s)""!==t&&n(s,t,r+1)}function i(e,t,r,n){n in r||(r[n]=t)}function o(){var e={};return e["@base"]=this["@base"],e.mappings=re(this.mappings),e.clone=this.clone,e.inverse=null,e.getInverse=this.getInverse,"@language"in this&&(e["@language"]=this["@language"]),"@vocab"in this&&(e["@vocab"]=this["@vocab"]),e}var a=e.url.parse(t.base||"");return{"@base":a,mappings:{},inverse:null,getInverse:r,clone:o}}function F(e){if(!X(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 B(e){return"[object Object]"===Object.prototype.toString.call(e)}function q(e){return B(e)&&0===Object.keys(e).length}function H(e){return Array.isArray(e)}function z(e){if(!X(e)&&!q(e)){var t=!1;if(H(e)){t=!0;for(var r=0;r<e.length;++r)if(!X(e[r])){t=!1;break}}if(!t)throw new Le('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 X(e){return"string"==typeof e||"[object String]"===Object.prototype.toString.call(e)}fun