!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e() else if("function"==typeof define&&define.amd)define([],e) else{var t t="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,t.$rdf=e()}}(function(){var e return function e(t,r,n){function i(a,s){if(!r[a]){if(!t[a]){var u="function"==typeof require&&require if(!s&&u)return u(a,!0) if(o)return o(a,!0) var l=new Error("Cannot find module '"+a+"'") throw l.code="MODULE_NOT_FOUND",l}var c=r[a]={exports:{}} t[a][0].call(c.exports,function(e){var r=t[a][1][e] return i(r||e)},c,c.exports,e,t,r,n)}return r[a].exports}for(var o="function"==typeof require&&require,a=0;a=e.length&&r()}if(r=r||function(){},!e.length)return r() var o=0 l(e,function(e){t(e,n(i))})},a.forEach=a.each,a.eachSeries=function(e,t,r){if(r=r||function(){},!e.length)return r() var n=0,i=function(){t(e[n],function(t){t?(r(t),r=function(){}):(n+=1,n>=e.length?r():i())})} i()},a.forEachSeries=a.eachSeries,a.eachLimit=function(e,t,r,n){d(t).apply(null,[e,r,n])},a.forEachLimit=a.eachLimit var d=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=t.length?n():s())})}()}},p=function(e){return function(){var t=Array.prototype.slice.call(arguments) return e.apply(null,[a.each].concat(t))}},v=function(e,t){return function(){var r=Array.prototype.slice.call(arguments) return t.apply(null,[d(e)].concat(r))}},g=function(e){return function(){var t=Array.prototype.slice.call(arguments) return e.apply(null,[a.eachSeries].concat(t))}},m=function(e,t,r,n){if(t=c(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)})})} a.map=p(m),a.mapSeries=g(m),a.mapLimit=function(e,t,r,n){return y(t)(e,r,n)} var y=function(e){return v(e,m)} a.reduce=function(e,t,r,n){a.eachSeries(e,function(e,n){r(t,e,function(e,r){t=r,n(e)})},function(e){n(e,t)})},a.inject=a.reduce,a.foldl=a.reduce,a.reduceRight=function(e,t,r,n){var i=c(e,function(e){return e}).reverse() a.reduce(i,t,r,n)},a.foldr=a.reduceRight var b=function(e,t,r,n){var i=[] t=c(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(c(i.sort(function(e,t){return e.index-t.index}),function(e){return e.value}))})} a.filter=p(b),a.filterSeries=g(b),a.select=a.filter,a.selectSeries=a.filterSeries var w=function(e,t,r,n){var i=[] t=c(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(c(i.sort(function(e,t){return e.index-t.index}),function(e){return e.value}))})} a.reject=p(w),a.rejectSeries=g(w) var x=function(e,t,r,n){e(t,function(e,t){r(e,function(r){r?(n(e),n=function(){}):t()})},function(e){n()})} a.detect=p(x),a.detectSeries=g(x),a.some=function(e,t,r){a.each(e,function(e,n){t(e,function(e){e&&(r(!0),r=function(){}),n()})},function(e){r(!1)})},a.any=a.some,a.every=function(e,t,r){a.each(e,function(e,n){t(e,function(e){e||(r(!1),r=function(){}),n()})},function(e){r(!0)})},a.all=a.every,a.sortBy=function(e,t,r){a.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 rn?1:0} r(null,c(t.sort(n),function(e){return e.value}))})},a.auto=function(e,t){t=t||function(){} var r=h(e),n=r.length if(!n)return t() var i={},o=[],s=function(e){o.unshift(e)},c=function(e){for(var t=0;t>>1) r(t,e[o])>=0?n=o:i=o-1}return n}function i(e,t,i,o){if(e.started||(e.started=!0),u(t)||(t=[t]),0==t.length)return a.setImmediate(function(){e.drain&&e.drain()}) l(t,function(t){var s={data:t,priority:i,callback:"function"==typeof o?o:null} e.tasks.splice(n(e.tasks,s,r)+1,0,s),e.saturated&&e.tasks.length===e.concurrency&&e.saturated(),a.setImmediate(e.process)})}var o=a.queue(e,t) return o.push=function(e,t,r){i(o,e,t,r)},delete o.unshift,o},a.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){u(e)||(e=[e]),l(e,function(e){n.push({data:e,callback:"function"==typeof r?r:null}),i.drained=!1,i.saturated&&n.length===t&&i.saturated()}),a.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=c(a,function(e){return e.data}) i.empty&&i.empty(),r=!0,e(s,function(){r=!1 var e=arguments l(a,function(t){t.callback&&t.callback.apply(null,e)}),o()})}},length:function(){return n.length},running:function(){return r}} return i} var k=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]&&l(r,function(t){console[e](t)}))}]))}} a.log=k("log"),a.dir=k("dir"),a.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(),s=t.apply(null,i) s in r?a.nextTick(function(){o.apply(null,r[s])}):s in n?n[s].push(o):(n[s]=[o],e.apply(null,i.concat([function(){r[s]=arguments var e=n[s] delete n[s] for(var t=0,i=e.length;t2){return r.apply(this,Array.prototype.slice.call(arguments,2))}return r} a.applyEach=p(N),a.applyEachSeries=g(N),a.forever=function(e,t){function r(n){if(n){if(t)return t(n) throw n}e(r)}r()},void 0!==r&&r.exports?r.exports=a:void 0!==e&&e.amd?e([],function(){return a}):i.async=a}()}).call(this,t("_process"))},{_process:10}],2:[function(e,t,r){},{}],3:[function(e,t,r){(function(t){"use strict" function n(){return o.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function i(e,t){if(n()=n())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+n().toString(16)+" bytes") return 0|e}function v(e){return+e!=e&&(e=0),o.alloc(+e)}function g(e,t){if(o.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 r=e.length if(0===r)return 0 for(var n=!1;;)switch(t){case"ascii":case"binary":case"raw":case"raws":return r case"utf8":case"utf-8":case void 0:return z(e).length case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r case"hex":return r>>>1 case"base64":return W(e).length default:if(n)return z(e).length t=(""+t).toLowerCase(),n=!0}}function m(e,t,r){var n=!1 if((void 0===t||t<0)&&(t=0),t>this.length)return"" if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"" if(r>>>=0,t>>>=0,r<=t)return"" for(e||(e="utf8");;)switch(e){case"hex":return O(this,t,r) case"utf8":case"utf-8":return j(this,t,r) case"ascii":return I(this,t,r) case"binary":return R(this,t,r) case"base64":return E(this,t,r) case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return C(this,t,r) default:if(n)throw new TypeError("Unknown encoding: "+e) e=(e+"").toLowerCase(),n=!0}}function y(e,t,r){var n=e[t] e[t]=e[r],e[r]=n}function b(e,t,r,n){function i(e,t){return 1===o?e[t]:e.readUInt16BE(t*o)}var o=1,a=e.length,s=t.length if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return-1 o=2,a/=2,s/=2,r/=2}for(var u=-1,l=0;r+li&&(n=i):n=i var o=t.length if(o%2!=0)throw new Error("Invalid hex string") n>o/2&&(n=o/2) for(var a=0;a239?4:o>223?3:o>191?2:1 if(i+s<=r){var u,l,c,f switch(s){case 1:o<128&&(a=o) break case 2:u=e[i+1],128==(192&u)&&(f=(31&o)<<6|63&u)>127&&(a=f) break case 3:u=e[i+1],l=e[i+2],128==(192&u)&&128==(192&l)&&(f=(15&o)<<12|(63&u)<<6|63&l)>2047&&(f<55296||f>57343)&&(a=f) break case 4:u=e[i+1],l=e[i+2],c=e[i+3],128==(192&u)&&128==(192&l)&&128==(192&c)&&(f=(15&o)<<18|(63&u)<<12|(63&l)<<6|63&c)>65535&&f<1114112&&(a=f)}}null===a?(a=65533,s=1):a>65535&&(a-=65536,n.push(a>>>10&1023|55296),a=56320|1023&a),n.push(a),i+=s}return S(n)}function S(e){var t=e.length if(t<=Z)return String.fromCharCode.apply(String,e) for(var r="",n=0;nn)&&(r=n) for(var i="",o=t;or)throw new RangeError("Trying to access beyond buffer length")}function D(e,t,r,n,i,a){if(!o.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance') if(t>i||te.length)throw new RangeError("Index out of range")}function A(e,t,r,n){t<0&&(t=65535+t+1) for(var i=0,o=Math.min(e.length-r,2);i>>8*(n?i:1-i)}function M(e,t,r,n){t<0&&(t=4294967295+t+1) for(var i=0,o=Math.min(e.length-r,4);i>>8*(n?i:3-i)&255}function U(e,t,r,n,i,o){if(r+n>e.length)throw new RangeError("Index out of range") if(r<0)throw new RangeError("Index out of range")}function P(e,t,r,n,i){return i||U(e,t,r,4,3.4028234663852886e38,-3.4028234663852886e38),Q.write(e,t,r,n,23,4),r+4}function q(e,t,r,n,i){return i||U(e,t,r,8,1.7976931348623157e308,-1.7976931348623157e308),Q.write(e,t,r,n,52,8),r+8}function F(e){if(e=B(e).replace(K,""),e.length<2)return"" for(;e.length%4!=0;)e+="=" return e}function B(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}function H(e){return e<16?"0"+e.toString(16):e.toString(16)}function z(e,t){t=t||1/0 for(var r,n=e.length,i=null,o=[],a=0;a55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&o.push(239,191,189) continue}if(a+1===n){(t-=3)>-1&&o.push(239,191,189) continue}i=r continue}if(r<56320){(t-=3)>-1&&o.push(239,191,189),i=r continue}r=65536+(i-55296<<10|r-56320)}else i&&(t-=3)>-1&&o.push(239,191,189) if(i=null,r<128){if((t-=1)<0)break o.push(r)}else if(r<2048){if((t-=2)<0)break o.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point") if((t-=4)<0)break o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function X(e){for(var t=[],r=0;r>8,i=r%256,o.push(i),o.push(n) return o}function W(e){return Y.toByteArray(F(e))}function J(e,t,r,n){for(var i=0;i=t.length||i>=e.length);i++)t[i+r]=e[i] return i}function $(e){return e!==e}var Y=e("base64-js"),Q=e("ieee754"),G=e("isarray") r.Buffer=o,r.SlowBuffer=v,r.INSPECT_MAX_BYTES=50,o.TYPED_ARRAY_SUPPORT=void 0!==t.TYPED_ARRAY_SUPPORT?t.TYPED_ARRAY_SUPPORT:function(){try{var e=new Uint8Array(1) return e.foo=function(){return 42},42===e.foo()&&"function"==typeof e.subarray&&0===e.subarray(1,1).byteLength}catch(e){return!1}}(),r.kMaxLength=n(),o.poolSize=8192,o._augment=function(e){return e.__proto__=o.prototype,e},o.from=function(e,t,r){return a(null,e,t,r)},o.TYPED_ARRAY_SUPPORT&&(o.prototype.__proto__=Uint8Array.prototype,o.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&o[Symbol.species]===o&&Object.defineProperty(o,Symbol.species,{value:null,configurable:!0})),o.alloc=function(e,t,r){return u(null,e,t,r)},o.allocUnsafe=function(e){return l(null,e)},o.allocUnsafeSlow=function(e){return l(null,e)},o.isBuffer=function(e){return!(null==e||!e._isBuffer)},o.compare=function(e,t){if(!o.isBuffer(e)||!o.isBuffer(t))throw new TypeError("Arguments must be Buffers") if(e===t)return 0 for(var r=e.length,n=t.length,i=0,a=Math.min(r,n);i0&&(e=this.toString("hex",0,t).match(/.{2}/g).join(" "),this.length>t&&(e+=" ... ")),""},o.prototype.compare=function(e,t,r,n,i){if(!o.isBuffer(e))throw new TypeError("Argument must be a Buffer") if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),t<0||r>e.length||n<0||i>this.length)throw new RangeError("out of range index") if(n>=i&&t>=r)return 0 if(n>=i)return-1 if(t>=r)return 1 if(t>>>=0,r>>>=0,n>>>=0,i>>>=0,this===e)return 0 for(var a=i-n,s=r-t,u=Math.min(a,s),l=this.slice(n,i),c=e.slice(t,r),f=0;f2147483647?t=2147483647:t<-2147483648&&(t=-2147483648),t>>=0,0===this.length)return-1 if(t>=this.length)return-1 if(t<0&&(t=Math.max(this.length+t,0)),"string"==typeof e&&(e=o.from(e,r)),o.isBuffer(e))return 0===e.length?-1:b(this,e,t,r) if("number"==typeof e)return o.TYPED_ARRAY_SUPPORT&&"function"===Uint8Array.prototype.indexOf?Uint8Array.prototype.indexOf.call(this,e,t):b(this,[e],t,r) throw new TypeError("val must be string, number or Buffer")},o.prototype.includes=function(e,t,r){return-1!==this.indexOf(e,t,r)},o.prototype.write=function(e,t,r,n){if(void 0===t)n="utf8",r=this.length,t=0 else if(void 0===r&&"string"==typeof t)n=t,r=this.length,t=0 else{if(!isFinite(t))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported") t|=0,isFinite(r)?(r|=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var i=this.length-t if((void 0===r||r>i)&&(r=i),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds") n||(n="utf8") for(var o=!1;;)switch(n){case"hex":return w(this,e,t,r) case"utf8":case"utf-8":return x(this,e,t,r) case"ascii":return _(this,e,t,r) case"binary":return T(this,e,t,r) case"base64":return k(this,e,t,r) case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return N(this,e,t,r) default:if(o)throw new TypeError("Unknown encoding: "+n) n=(""+n).toLowerCase(),o=!0}},o.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}} var Z=4096 o.prototype.slice=function(e,t){var r=this.length e=~~e,t=void 0===t?r:~~t,e<0?(e+=r)<0&&(e=0):e>r&&(e=r),t<0?(t+=r)<0&&(t=0):t>r&&(t=r),t0&&(i*=256);)n+=this[e+--t]*i return n},o.prototype.readUInt8=function(e,t){return t||L(e,1,this.length),this[e]},o.prototype.readUInt16LE=function(e,t){return t||L(e,2,this.length),this[e]|this[e+1]<<8},o.prototype.readUInt16BE=function(e,t){return t||L(e,2,this.length),this[e]<<8|this[e+1]},o.prototype.readUInt32LE=function(e,t){return t||L(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},o.prototype.readUInt32BE=function(e,t){return t||L(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},o.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||L(e,t,this.length) for(var n=this[e],i=1,o=0;++o=i&&(n-=Math.pow(2,8*t)),n},o.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||L(e,t,this.length) for(var n=t,i=1,o=this[e+--n];n>0&&(i*=256);)o+=this[e+--n]*i return i*=128,o>=i&&(o-=Math.pow(2,8*t)),o},o.prototype.readInt8=function(e,t){return t||L(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},o.prototype.readInt16LE=function(e,t){t||L(e,2,this.length) var r=this[e]|this[e+1]<<8 return 32768&r?4294901760|r:r},o.prototype.readInt16BE=function(e,t){t||L(e,2,this.length) var r=this[e+1]|this[e]<<8 return 32768&r?4294901760|r:r},o.prototype.readInt32LE=function(e,t){return t||L(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},o.prototype.readInt32BE=function(e,t){return t||L(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},o.prototype.readFloatLE=function(e,t){return t||L(e,4,this.length),Q.read(this,e,!0,23,4)},o.prototype.readFloatBE=function(e,t){return t||L(e,4,this.length),Q.read(this,e,!1,23,4)},o.prototype.readDoubleLE=function(e,t){return t||L(e,8,this.length),Q.read(this,e,!0,52,8)},o.prototype.readDoubleBE=function(e,t){return t||L(e,8,this.length),Q.read(this,e,!1,52,8)},o.prototype.writeUIntLE=function(e,t,r,n){if(e=+e,t|=0,r|=0,!n){D(this,e,t,r,Math.pow(2,8*r)-1,0)}var i=1,o=0 for(this[t]=255&e;++o=0&&(o*=256);)this[t+i]=e/o&255 return t+r},o.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||D(this,e,t,1,255,0),o.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},o.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||D(this,e,t,2,65535,0),o.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):A(this,e,t,!0),t+2},o.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||D(this,e,t,2,65535,0),o.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):A(this,e,t,!1),t+2},o.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||D(this,e,t,4,4294967295,0),o.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):M(this,e,t,!0),t+4},o.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||D(this,e,t,4,4294967295,0),o.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):M(this,e,t,!1),t+4},o.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1) D(this,e,t,r,i-1,-i)}var o=0,a=1,s=0 for(this[t]=255&e;++o>0)-s&255 return t+r},o.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1) D(this,e,t,r,i-1,-i)}var o=r-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+r},o.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||D(this,e,t,1,127,-128),o.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},o.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||D(this,e,t,2,32767,-32768),o.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):A(this,e,t,!0),t+2},o.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||D(this,e,t,2,32767,-32768),o.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):A(this,e,t,!1),t+2},o.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||D(this,e,t,4,2147483647,-2147483648),o.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):M(this,e,t,!0),t+4},o.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||D(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),o.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):M(this,e,t,!1),t+4},o.prototype.writeFloatLE=function(e,t,r){return P(this,e,t,!0,r)},o.prototype.writeFloatBE=function(e,t,r){return P(this,e,t,!1,r)},o.prototype.writeDoubleLE=function(e,t,r){return q(this,e,t,!0,r)},o.prototype.writeDoubleBE=function(e,t,r){return q(this,e,t,!1,r)},o.prototype.copy=function(e,t,r,n){if(r||(r=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n=this.length)throw new RangeError("sourceStart out of bounds") if(n<0)throw new RangeError("sourceEnd out of bounds") n>this.length&&(n=this.length),e.length-t=0;i--)e[i+t]=this[i+r] else if(a<1e3||!o.TYPED_ARRAY_SUPPORT)for(i=0;i>>=0,r=void 0===r?this.length:r>>>0,e||(e=0) var a if("number"==typeof e)for(a=t;a0)throw new Error("Invalid string. Length must be a multiple of 4") o="="===e[s-2]?2:"="===e[s-1]?1:0,a=new l(3*s/4-o),n=o>0?s-4:s var c=0 for(t=0,r=0;t>16&255,a[c++]=i>>8&255,a[c++]=255&i return 2===o?(i=u[e.charCodeAt(t)]<<2|u[e.charCodeAt(t+1)]>>4,a[c++]=255&i):1===o&&(i=u[e.charCodeAt(t)]<<10|u[e.charCodeAt(t+1)]<<4|u[e.charCodeAt(t+2)]>>2,a[c++]=i>>8&255,a[c++]=255&i),a}function i(e){return s[e>>18&63]+s[e>>12&63]+s[e>>6&63]+s[63&e]}function o(e,t,r){for(var n,o=[],a=t;al?l:u+16383)) return 1===n?(t=e[r-1],i+=s[t>>2],i+=s[t<<4&63],i+="=="):2===n&&(t=(e[r-2]<<8)+e[r-1],i+=s[t>>10],i+=s[t>>4&63],i+=s[t<<2&63],i+="="),a.push(i),a.join("")}r.toByteArray=n,r.fromByteArray=a var s=[],u=[],l="undefined"!=typeof Uint8Array?Uint8Array:Array !function(){for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0,r=e.length;t>1,c=-7,f=r?i-1:0,h=r?-1:1,d=e[t+f] for(f+=h,o=d&(1<<-c)-1,d>>=-c,c+=s;c>0;o=256*o+e[t+f],f+=h,c-=8);for(a=o&(1<<-c)-1,o>>=-c,c+=n;c>0;a=256*a+e[t+f],f+=h,c-=8);if(0===o)o=1-l else{if(o===u)return a?NaN:1/0*(d?-1:1) a+=Math.pow(2,n),o-=l}return(d?-1:1)*a*Math.pow(2,o-n)},r.write=function(e,t,r,n,i,o){var a,s,u,l=8*o-i-1,c=(1<>1,h=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:o-1,p=n?1:-1,v=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=c):(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),t*u>=2&&(a++,u/=2),a+f>=c?(s=0,a=c):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[r+d]=255&s,d+=p,s/=256,i-=8);for(a=a<0;e[r+d]=255&a,d+=p,a/=256,l-=8);e[r+d-p]|=128*v}},{}],6:[function(e,t,r){var n={}.toString t.exports=Array.isArray||function(e){return"[object Array]"==n.call(e)}},{}],7:[function(e,t,r){function n(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}function i(e){return"function"==typeof e}function o(e){return"number"==typeof e}function a(e){return"object"==typeof e&&null!==e}function s(e){return void 0===e}t.exports=n,n.EventEmitter=n,n.prototype._events=void 0,n.prototype._maxListeners=void 0,n.defaultMaxListeners=10,n.prototype.setMaxListeners=function(e){if(!o(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,r,n,o,u,l if(this._events||(this._events={}),"error"===e&&(!this._events.error||a(this._events.error)&&!this._events.error.length)){if((t=arguments[1])instanceof Error)throw t throw TypeError('Uncaught, unspecified "error" event.')}if(r=this._events[e],s(r))return!1 if(i(r))switch(arguments.length){case 1:r.call(this) break case 2:r.call(this,arguments[1]) break case 3:r.call(this,arguments[1],arguments[2]) break default:o=Array.prototype.slice.call(arguments,1),r.apply(this,o)}else if(a(r))for(o=Array.prototype.slice.call(arguments,1),l=r.slice(),n=l.length,u=0;u0&&this._events[e].length>r&&(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){function r(){this.removeListener(e,r),n||(n=!0,t.apply(this,arguments))}if(!i(t))throw TypeError("listener must be a function") var n=!1 return r.listener=t,this.on(e,r),this},n.prototype.removeListener=function(e,t){var r,n,o,s if(!i(t))throw TypeError("listener must be a function") if(!this._events||!this._events[e])return this if(r=this._events[e],o=r.length,n=-1,r===t||i(r.listener)&&r.listener===t)delete this._events[e],this._events.removeListener&&this.emit("removeListener",e,t) else if(a(r)){for(s=o;s-- >0;)if(r[s]===t||r[s].listener&&r[s].listener===t){n=s break}if(n<0)return this 1===r.length?(r.length=0,delete this._events[e]):r.splice(n,1),this._events.removeListener&&this.emit("removeListener",e,t)}return this},n.prototype.removeAllListeners=function(e){var t,r 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=this._events[e],i(r))this.removeListener(e,r) else if(r)for(;r.length;)this.removeListener(e,r[r.length-1]) return delete this._events[e],this},n.prototype.listeners=function(e){return this._events&&this._events[e]?i(this._events[e])?[this._events[e]]:this._events[e].slice():[]},n.prototype.listenerCount=function(e){if(this._events){var t=this._events[e] if(i(t))return 1 if(t)return t.length}return 0},n.listenerCount=function(e,t){return e.listenerCount(t)}},{}],8:[function(e,t,r){"function"==typeof Object.create?t.exports=function(e,t){e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}})}:t.exports=function(e,t){e.super_=t var r=function(){} r.prototype=t.prototype,e.prototype=new r,e.prototype.constructor=e}},{}],9:[function(e,t,r){t.exports=function(e){return!(null==e||!(e._isBuffer||e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)))}},{}],10:[function(e,t,r){function n(){c&&s&&(c=!1,s.length?l=s.concat(l):f=-1,l.length&&i())}function i(){if(!c){var e=setTimeout(n) c=!0 for(var t=l.length;t;){for(s=l,l=[];++f1)for(var r=1;r0)if(t.ended&&!i){var s=new Error("stream.push() after EOF") e.emit("error",s)}else if(t.endEmitted&&i){var s=new Error("stream.unshift() after end event") e.emit("error",s)}else{var u !t.decoder||i||n||(r=t.decoder.write(r),u=!t.objectMode&&0===r.length),i||(t.reading=!1),u||(t.flowing&&0===t.length&&!t.sync?(e.emit("data",r),e.read(0)):(t.length+=t.objectMode?1:r.length,i?t.buffer.unshift(r):t.buffer.push(r),t.needReadable&&f(e))),d(e,t)}else i||(t.reading=!1) return a(t)}function a(e){return!e.ended&&(e.needReadable||e.length=A?e=A:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}function u(e,t){return 0===t.length&&t.ended?0:t.objectMode?0===e?0:1:null===e||isNaN(e)?t.flowing&&t.buffer.length?t.buffer[0].length:t.length:e<=0?0:(e>t.highWaterMark&&(t.highWaterMark=s(e)),e>t.length?t.ended?t.length:(t.needReadable=!0,0):e)}function l(e,t){var r=null return j.isBuffer(t)||"string"==typeof t||null===t||void 0===t||e.objectMode||(r=new TypeError("Invalid non-string/buffer chunk")),r}function c(e,t){if(!t.ended){if(t.decoder){var r=t.decoder.end() r&&r.length&&(t.buffer.push(r),t.length+=t.objectMode?1:r.length)}t.ended=!0,f(e)}}function f(e){var t=e._readableState t.needReadable=!1,t.emittedReadable||(C("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?N(h,e):h(e))}function h(e){C("emit readable"),e.emit("readable"),b(e)}function d(e,t){t.readingMore||(t.readingMore=!0,N(p,e,t))}function p(e,t){for(var r=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length=i)r=o?n.join(""):1===n.length?n[0]:j.concat(n,i),n.length=0 else if(e0)throw new Error("endReadable called on non-empty stream") t.endEmitted||(t.ended=!0,N(_,t,e))}function _(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function T(e,t){for(var r=0,n=e.length;r0)&&(t.emittedReadable=!1),0===e&&t.needReadable&&(t.length>=t.highWaterMark||t.ended))return C("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?x(this):f(this),null if(0===(e=u(e,t))&&t.ended)return 0===t.length&&x(this),null var n=t.needReadable C("need readable",n),(0===t.length||t.length-e0?w(e,t):null,null===i&&(t.needReadable=!0,e=0),t.length-=e,0!==t.length||t.ended||(t.needReadable=!0),r!==e&&t.ended&&0===t.length&&x(this),null!==i&&this.emit("data",i),i},i.prototype._read=function(e){this.emit("error",new Error("not implemented"))},i.prototype.pipe=function(e,t){function n(e){C("onunpipe"),e===f&&o()}function i(){C("onend"),e.end()}function o(){C("cleanup"),e.removeListener("close",u),e.removeListener("finish",l),e.removeListener("drain",g),e.removeListener("error",s),e.removeListener("unpipe",n),f.removeListener("end",i),f.removeListener("end",o),f.removeListener("data",a),m=!0,!h.awaitDrain||e._writableState&&!e._writableState.needDrain||g()}function a(t){C("ondata"),!1===e.write(t)&&(1!==h.pipesCount||h.pipes[0]!==e||1!==f.listenerCount("data")||m||(C("false write response, pause",f._readableState.awaitDrain),f._readableState.awaitDrain++),f.pause())}function s(t){C("onerror",t),c(),e.removeListener("error",s),0===I(e,"error")&&e.emit("error",t)}function u(){e.removeListener("finish",l),c()}function l(){C("onfinish"),e.removeListener("close",u),c()}function c(){C("unpipe"),f.unpipe(e)}var f=this,h=this._readableState switch(h.pipesCount){case 0:h.pipes=e break case 1:h.pipes=[h.pipes,e] break default:h.pipes.push(e)}h.pipesCount+=1,C("pipe count=%d opts=%j",h.pipesCount,t) var d=(!t||!1!==t.end)&&e!==r.stdout&&e!==r.stderr,p=d?i:o h.endEmitted?N(p):f.once("end",p),e.on("unpipe",n) var g=v(f) e.on("drain",g) var m=!1 return f.on("data",a),e._events&&e._events.error?E(e._events.error)?e._events.error.unshift(s):e._events.error=[s,e._events.error]:e.on("error",s),e.once("close",u),e.once("finish",l),e.emit("pipe",f),h.flowing||(C("pipe resume"),f.resume()),e},i.prototype.unpipe=function(e){var t=this._readableState if(0===t.pipesCount)return this if(1===t.pipesCount)return e&&e!==t.pipes?this:(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this),this) if(!e){var r=t.pipes,n=t.pipesCount t.pipes=null,t.pipesCount=0,t.flowing=!1 for(var i=0;i-1?setImmediate:T,N=e("buffer").Buffer a.WritableState=o var E=e("core-util-is") E.inherits=e("inherits") var j,S={deprecate:e("util-deprecate")} !function(){try{j=e("stream")}catch(e){}finally{j||(j=e("events").EventEmitter)}}() var N=e("buffer").Buffer E.inherits(a,j) var I o.prototype.getBuffer=function(){for(var e=this.bufferedRequest,t=[];e;)t.push(e),e=e.next return t},function(){try{Object.defineProperty(o.prototype,"buffer",{get:S.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.")})}catch(e){}}() var I a.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe. Not readable."))},a.prototype.write=function(e,t,r){var i=this._writableState,o=!1 return"function"==typeof t&&(r=t,t=null),N.isBuffer(e)?t="buffer":t||(t=i.defaultEncoding),"function"!=typeof r&&(r=n),i.ended?s(this,r):u(this,i,e,r)&&(i.pendingcb++,o=c(this,i,e,t,r)),o},a.prototype.cork=function(){this._writableState.corked++},a.prototype.uncork=function(){var e=this._writableState e.corked&&(e.corked--,e.writing||e.corked||e.finished||e.bufferProcessing||!e.bufferedRequest||m(this,e))},a.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) this._writableState.defaultEncoding=e},a.prototype._write=function(e,t,r){r(new Error("not implemented"))},a.prototype._writev=null,a.prototype.end=function(e,t,r){var n=this._writableState "function"==typeof e?(r=e,e=null,t=null):"function"==typeof t&&(r=t,t=null),null!==e&&void 0!==e&&this.write(e,t),n.corked&&(n.corked=1,this.uncork()),n.ending||n.finished||x(this,n,r)}}).call(this,e("_process"))},{"./_stream_duplex":12,_process:10,buffer:3,"core-util-is":17,events:7,inherits:8,"process-nextick-args":19,"util-deprecate":20}],17:[function(e,t,r){(function(e){function t(e){return Array.isArray?Array.isArray(e):"[object Array]"===g(e)}function n(e){return"boolean"==typeof e}function i(e){return null===e}function o(e){return null==e}function a(e){return"number"==typeof e}function s(e){return"string"==typeof e}function u(e){return"symbol"==typeof e}function l(e){return void 0===e}function c(e){return"[object RegExp]"===g(e)}function f(e){return"object"==typeof e&&null!==e}function h(e){return"[object Date]"===g(e)}function d(e){return"[object Error]"===g(e)||e instanceof Error}function p(e){return"function"==typeof e}function v(e){return null===e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||"symbol"==typeof e||void 0===e}function g(e){return Object.prototype.toString.call(e)}r.isArray=t,r.isBoolean=n,r.isNull=i,r.isNullOrUndefined=o,r.isNumber=a,r.isString=s,r.isSymbol=u,r.isUndefined=l,r.isRegExp=c,r.isObject=f,r.isDate=h,r.isError=d,r.isFunction=p,r.isPrimitive=v,r.isBuffer=e.isBuffer}).call(this,{isBuffer:e("../../../../insert-module-globals/node_modules/is-buffer/index.js")})},{"../../../../insert-module-globals/node_modules/is-buffer/index.js":9}],18:[function(e,t,r){arguments[4][6][0].apply(r,arguments)},{dup:6}],19:[function(e,t,r){(function(e){"use strict" function r(t,r,n,i){if("function"!=typeof t)throw new TypeError('"callback" argument must be a function') var o,a,s=arguments.length switch(s){case 0:case 1:return e.nextTick(t) case 2:return e.nextTick(function(){t.call(null,r)}) case 3:return e.nextTick(function(){t.call(null,r,n)}) case 4:return e.nextTick(function(){t.call(null,r,n,i)}) default:for(o=new Array(s-1),a=0;a=this.charLength-this.charReceived?this.charLength-this.charReceived:e.length if(e.copy(this.charBuffer,this.charReceived,0,r),this.charReceived+=r,this.charReceived=55296&&n<=56319)){if(this.charReceived=this.charLength=0,0===e.length)return t break}this.charLength+=this.surrogateSize,t=""}this.detectIncompleteChar(e) var i=e.length this.charLength&&(e.copy(this.charBuffer,0,e.length-this.charReceived,i),i-=this.charReceived),t+=e.toString(this.encoding,0,i) var i=t.length-1,n=t.charCodeAt(i) if(n>=55296&&n<=56319){var o=this.surrogateSize return this.charLength+=o,this.charReceived+=o,this.charBuffer.copy(this.charBuffer,o,0,o),e.copy(this.charBuffer,0,0,o),t.substring(0,i)}return t},l.prototype.detectIncompleteChar=function(e){for(var t=e.length>=3?3:e.length;t>0;t--){var r=e[e.length-t] if(1==t&&r>>5==6){this.charLength=2 break}if(t<=2&&r>>4==14){this.charLength=3 break}if(t<=3&&r>>3==30){this.charLength=4 break}}this.charReceived=t},l.prototype.end=function(e){var t="" if(e&&e.length&&(t=this.write(e)),this.charReceived){var r=this.charReceived,n=this.charBuffer,i=this.encoding t+=n.slice(0,r).toString(i)}return t}},{buffer:3}],27:[function(e,t,r){t.exports=function(e){return e&&"object"==typeof e&&"function"==typeof e.copy&&"function"==typeof e.fill&&"function"==typeof e.readUInt8}},{}],28:[function(e,t,r){(function(t,n){function i(e,t){var n={seen:[],stylize:a} return arguments.length>=3&&(n.depth=arguments[2]),arguments.length>=4&&(n.colors=arguments[3]),v(t)?n.showHidden=t:t&&r._extend(n,t),x(n.showHidden)&&(n.showHidden=!1),x(n.depth)&&(n.depth=2),x(n.colors)&&(n.colors=!1),x(n.customInspect)&&(n.customInspect=!0),n.colors&&(n.stylize=o),u(n,e,n.depth)}function o(e,t){var r=i.styles[t] return r?"["+i.colors[r][0]+"m"+e+"["+i.colors[r][1]+"m":e}function a(e,t){return e}function s(e){var t={} return e.forEach(function(e,r){t[e]=!0}),t}function u(e,t,n){if(e.customInspect&&t&&E(t.inspect)&&t.inspect!==r.inspect&&(!t.constructor||t.constructor.prototype!==t)){var i=t.inspect(n,e) return b(i)||(i=u(e,i,n)),i}var o=l(e,t) if(o)return o var a=Object.keys(t),v=s(a) if(e.showHidden&&(a=Object.getOwnPropertyNames(t)),N(t)&&(a.indexOf("message")>=0||a.indexOf("description")>=0))return c(t) if(0===a.length){if(E(t)){var g=t.name?": "+t.name:"" return e.stylize("[Function"+g+"]","special")}if(_(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp") if(k(t))return e.stylize(Date.prototype.toString.call(t),"date") if(N(t))return c(t)}var m="",y=!1,w=["{","}"] if(p(t)&&(y=!0,w=["[","]"]),E(t)){m=" [Function"+(t.name?": "+t.name:"")+"]"}if(_(t)&&(m=" "+RegExp.prototype.toString.call(t)),k(t)&&(m=" "+Date.prototype.toUTCString.call(t)),N(t)&&(m=" "+c(t)),0===a.length&&(!y||0==t.length))return w[0]+m+w[1] if(n<0)return _(t)?e.stylize(RegExp.prototype.toString.call(t),"regexp"):e.stylize("[Object]","special") e.seen.push(t) var x return x=y?f(e,t,n,v,a):a.map(function(r){return h(e,t,n,v,r,y)}),e.seen.pop(),d(x,m,w)}function l(e,t){if(x(t))return e.stylize("undefined","undefined") if(b(t)){var r="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'" return e.stylize(r,"string")}return y(t)?e.stylize(""+t,"number"):v(t)?e.stylize(""+t,"boolean"):g(t)?e.stylize("null","null"):void 0}function c(e){return"["+Error.prototype.toString.call(e)+"]"}function f(e,t,r,n,i){for(var o=[],a=0,s=t.length;a-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")),x(a)){if(o&&i.match(/^\d+$/))return s a=JSON.stringify(""+i),a.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 d(e,t,r){var n=0 return e.reduce(function(e,t){return n++,t.indexOf("\n")>=0&&n++,e+t.replace(/\u001b\[\d\d?m/g,"").length+1},0)>60?r[0]+(""===t?"":t+"\n ")+" "+e.join(",\n ")+" "+r[1]:r[0]+t+" "+e.join(", ")+" "+r[1]}function p(e){return Array.isArray(e)}function v(e){return"boolean"==typeof e}function g(e){return null===e}function m(e){return null==e}function y(e){return"number"==typeof e}function b(e){return"string"==typeof e}function w(e){return"symbol"==typeof e}function x(e){return void 0===e}function _(e){return T(e)&&"[object RegExp]"===S(e)}function T(e){return"object"==typeof e&&null!==e}function k(e){return T(e)&&"[object Date]"===S(e)}function N(e){return T(e)&&("[object Error]"===S(e)||e instanceof Error)}function E(e){return"function"==typeof e}function j(e){return null===e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||"symbol"==typeof e||void 0===e}function S(e){return Object.prototype.toString.call(e)}function I(e){return e<10?"0"+e.toString(10):e.toString(10)}function R(){var e=new Date,t=[I(e.getHours()),I(e.getMinutes()),I(e.getSeconds())].join(":") return[e.getDate(),A[e.getMonth()],t].join(" ")}function O(e,t){return Object.prototype.hasOwnProperty.call(e,t)}var C=/%[sdj%]/g r.format=function(e){if(!b(e)){for(var t=[],r=0;r=o)return e switch(e){case"%s":return String(n[r++]) case"%d":return Number(n[r++]) case"%j":try{return JSON.stringify(n[r++])}catch(e){return"[Circular]"}default:return e}}),s=n[r];r=0;--r)if(t[r]["@id"]===e["@id"])return!0 return!1}function x(e,t,r){var n="@"+r,i=n in e?e[n][0]:t[r] return"embed"===r&&(!0===i?i="@last":!1===i?i="@never":"@always"!==i&&"@never"!==i&&"@link"!==i&&(i="@last")),i}function _(e){if(!F(e)||1!==e.length||!P(e[0]))throw new Re("Invalid JSON-LD syntax; a JSON-LD frame must be a single object.","jsonld.SyntaxError",{frame:e})}function T(e,t,r,n){for(var i={},o=0;o=0;--d)for(var N=_[d],E=N.terms,j=0;j0&&"/"!==o.substr(-1)&&(o+="/"),o+=n.path),i.path=o}i.query=n.query}i.path=ue(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 A(t,r){if(null===t)return r H(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=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=ee(this.mappings),e.clone=this.clone,e.inverse=null,e.getInverse=this.getInverse,"@language"in this&&(e["@language"]=this["@language"]),"@vocab"in this&&(e["@vocab"]=this["@vocab"]),e}return{"@base":e.url.parse(t.base||""),mappings:{},inverse:null,getInverse:r,clone:o}}function U(e){if(!H(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 P(e){return"[object Object]"===Object.prototype.toString.call(e)}function q(e){return P(e)&&0===Object.keys(e).length}function F(e){return Array.isArray(e)}function B(e){if(!H(e)&&!q(e)){var t=!1 if(F(e)){t=!0 for(var r=0;r1||!("@id"in e)}return t}function Y(e){return P(e)&&1===Object.keys(e).length&&"@id"in e}function Q(e){return P(e)&&"@value"in e}function G(e){return P(e)&&"@list"in e}function Z(e){var t=!1 return P(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 K(e){return H(e)&&-1!==e.indexOf(":")}function ee(e){if(e&&"object"==typeof e){var t if(F(e)){t=[] for(var r=0;rIe)return n=new Re("Maximum number of @context URLs exceeded.","jsonld.ContextUrlError",{code:"loading remote context failed",max:Ie}),a(n) var s={},u=function(){te(e,s,!0,i),a(null,e)} te(e,s,!1,i)||u() var l=[] for(var c in s)!1===s[c]&&l.push(c) for(var f=l.length,h=0;h]*)>)|(_:(?:[A-Za-z0-9]+)))[ \\t]+(?:<([^:]+:[^>]*)>)[ \\t]+(?:(?:<([^:]+:[^>]*)>)|(_:(?:[A-Za-z0-9]+))|(?:"([^"\\\\]*(?:\\\\.[^"\\\\]*)*)"(?:(?:\\^\\^(?:<([^:]+:[^>]*)>))|(?:@([a-z]+(?:-[a-z0-9]+)*)))?))[ \\t]*(?:\\.|(?:(?:(?:<([^:]+:[^>]*)>)|(_:(?:[A-Za-z0-9]+)))[ \\t]*\\.))[ \\t]*(?:#.*)?$'),i={},o=e.split(t),a=0,s=0;s":a+=r.value,a+=" ","IRI"===n.type?a+="<"+n.value+">":a+=n.value,a+=" ","IRI"===i.type)a+="<"+i.value+">" else if("blank node"===i.type)a+=i.value else{var s=i.value.replace(/\\/g,"\\\\").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\"/g,'\\"') a+='"'+s+'"',i.datatype===je?i.language&&(a+="@"+i.language):i.datatype!==ye&&(a+="^^<"+i.datatype+">")}return null!==o&&void 0!==o&&(0!==o.indexOf("_:")?a+=" <"+o+">":a+=" "+o),a+=" .\n"}function ae(e){var t={} t["@default"]=[] for(var r=e.getSubjects(),n=0;n0;)"."===n[0]||""===n[0]&&n.length>1?n.shift():".."!==n[0]?i.push(n.shift()):(n.shift(),t||i.length>0&&".."!==i[i.length-1]?i.pop():i.push("..")) return r+i.join("/")}e.compact=function(t,r,n,i){function o(e,t,n,o){if(e)return i(e) o.compactArrays&&!o.graph&&F(t)?1===t.length?t=t[0]:0===t.length&&(t={}):o.graph&&P(t)&&(t=[t]),P(r)&&"@context"in r&&(r=r["@context"]),r=ee(r),F(r)||(r=[r]) var a=r r=[] for(var s=0;s0)&&r.push(a[s]) var u=r.length>0 if(1===r.length&&(r=r[0]),F(t)){var l=R(n,"@graph"),c=t t={},u&&(t["@context"]=r),t[l]=c}else if(P(t)&&u){var c=t t={"@context":r} for(var f in c)t[f]=c[f]}i(null,t,n)}if(arguments.length<2)return e.nextTick(function(){i(new TypeError("Could not compact, too few arguments."))}) if("function"==typeof n&&(i=n,n={}),n=n||{},null===r)return e.nextTick(function(){i(new Re("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 n||(n.base="string"==typeof t?t:""),"compactArrays"in n||(n.compactArrays=!0),"graph"in n||(n.graph=!1),"skipExpansion"in n||(n.skipExpansion=!1),"documentLoader"in n||(n.documentLoader=e.loadDocument),"link"in n||(n.link=!1),n.link&&(n.skipExpansion=!0) !function(t,r,n){if(r.skipExpansion)return e.nextTick(function(){n(null,t)}) e.expand(t,r,n)}(t,n,function(t,a){if(t)return i(new Re("Could not expand input before compaction.","jsonld.CompactError",{cause:t})) var s=M(n) e.processContext(s,r,n,function(e,t){if(e)return i(new Re("Could not process context before compaction.","jsonld.CompactError",{cause:e})) var r try{r=(new Oe).compact(t,null,a,n)}catch(e){return i(e)}o(null,r,t,n)})})},e.expand=function(t,r,n){function i(e){"base"in r||(r.base=e.documentUrl||"") var t={document:ee(e.document),remoteContext:{"@context":e.contextUrl}} if("expandContext"in r){var i=ee(r.expandContext) t.expandContext="object"==typeof i&&"@context"in i?i:{"@context":i}}re(t,r,function(e,t){if(e)return n(e) var i try{var o=new Oe,a=M(r),s=t.document,u=t.remoteContext["@context"] t.expandContext&&(a=o.processContext(a,t.expandContext["@context"],r)),u&&(a=o.processContext(a,u,r)),i=o.expand(a,null,s,r,!1),P(i)&&"@graph"in i&&1===Object.keys(i).length?i=i["@graph"]:null===i&&(i=[]),F(i)||(i=[i])}catch(e){return n(e)}n(null,i)})}if(arguments.length<1)return e.nextTick(function(){n(new TypeError("Could not expand, too few arguments."))}) "function"==typeof r&&(n=r,r={}),r=r||{},"documentLoader"in r||(r.documentLoader=e.loadDocument),"keepFreeFloatingNodes"in r||(r.keepFreeFloatingNodes=!1),e.nextTick(function(){if("string"==typeof t){var e=function(e,t){if(e)return n(e) try{if(!t.document)throw new Re("No remote document found at the given URL.","jsonld.NullRemoteDocument") "string"==typeof t.document&&(t.document=JSON.parse(t.document))}catch(e){return n(new Re("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=r.documentLoader(t,e) return void(o&&"then"in o&&o.then(e.bind(null,null),e))}i({contextUrl:null,documentUrl:null,document:t})})},e.flatten=function(t,r,n,i){if(arguments.length<1)return e.nextTick(function(){i(new TypeError("Could not flatten, too few arguments."))}) "function"==typeof n?(i=n,n={}):"function"==typeof r&&(i=r,r=null,n={}),n=n||{},"base"in n||(n.base="string"==typeof t?t:""),"documentLoader"in n||(n.documentLoader=e.loadDocument),e.expand(t,n,function(t,o){if(t)return i(new Re("Could not expand input before flattening.","jsonld.FlattenError",{cause:t})) var a try{a=(new Oe).flatten(o)}catch(e){return i(e)}if(null===r)return i(null,a) n.graph=!0,n.skipExpansion=!0,e.compact(a,r,n,function(e,t){if(e)return i(new Re("Could not compact flattened output.","jsonld.FlattenError",{cause:e})) i(null,t)})})},e.frame=function(t,r,n,i){function o(r){var o,a=r.document a?(o=a["@context"],r.contextUrl?(o?F(o)?o.push(r.contextUrl):o=[o,r.contextUrl]:o=r.contextUrl,a["@context"]=o):o=o||{}):o={},e.expand(t,n,function(t,r){if(t)return i(new Re("Could not expand input before framing.","jsonld.FrameError",{cause:t})) var s=ee(n) s.isFrame=!0,s.keepFreeFloatingNodes=!0,e.expand(a,s,function(t,n){if(t)return i(new Re("Could not expand frame before framing.","jsonld.FrameError",{cause:t})) var a try{a=(new Oe).frame(r,n,s)}catch(e){return i(e)}s.graph=!0,s.skipExpansion=!0,s.link={},e.compact(a,o,s,function(e,t,r){if(e)return i(new Re("Could not compact framed output.","jsonld.FrameError",{cause:e})) var n=R(r,"@graph") s.link={},t[n]=j(r,t[n],s),i(null,t)})})})}if(arguments.length<2)return e.nextTick(function(){i(new TypeError("Could not frame, too few arguments."))}) "function"==typeof n&&(i=n,n={}),n=n||{},"base"in n||(n.base="string"==typeof t?t:""),"documentLoader"in n||(n.documentLoader=e.loadDocument),"embed"in n||(n.embed="@last"),n.explicit=n.explicit||!1,"requireAll"in n||(n.requireAll=!0),n.omitDefault=n.omitDefault||!1,e.nextTick(function(){if("string"==typeof r){var e=function(e,t){if(e)return i(e) try{if(!t.document)throw new Re("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 Re("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=n.documentLoader(r,e) return void(t&&"then"in t&&t.then(e.bind(null,null),e))}o({contextUrl:null,documentUrl:null,document:r})})},e.link=function(t,r,n,i){var o={} r&&(o["@context"]=r),o["@embed"]="@link",e.frame(t,o,n,i)},e.objectify=function(t,r,n,i){"function"==typeof n&&(i=n,n={}),n=n||{},"base"in n||(n.base="string"==typeof t?t:""),"documentLoader"in n||(n.documentLoader=e.loadDocument),e.expand(t,n,function(t,o){if(t)return i(new Re("Could not expand input before linking.","jsonld.LinkError",{cause:t})) var a try{a=(new Oe).flatten(o)}catch(e){return i(e)}n.graph=!0,n.skipExpansion=!0,e.compact(a,r,n,function(t,r,n){if(t)return i(new Re("Could not compact flattened output before linking.","jsonld.LinkError",{cause:t})) var o=R(n,"@graph"),a=r[o][0],s=function(t){if(P(t)||F(t)){if(P(t)){if(s.visited[t["@id"]])return s.visited[t["@id"]]=!0}for(var r in t){var i=t[r],o="@id"===e.getContextValue(n,r,"@type") if(F(i)||P(i)||o)if(H(i)&&o)t[r]=i=a[i],s(i) else if(F(i))for(var u=0;u]*?>|"[^"]*?"|[^,])+/g),n=/\s*<([^>]*?)>\s*(?:;\s*(.*))?/,i=0;i=+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 r=JSON.stringify(e),n=JSON.stringify(t),i=this.cache[r] return i&&n in i?i[n]:null},e.ActiveContextCache.prototype.set=function(e,t,r){if(this.order.length===this.size){var n=this.order.shift() delete this.cache[n.activeCtx][n.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]=ee(r)},e.cache={activeCtx:new e.ActiveContextCache},e.documentLoaders={},e.documentLoaders.jquery=function(t,r){function n(n,i){return 0!==n.indexOf("http:")&&0!==n.indexOf("https:")?i(new Re('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}):r.secure&&0!==n.indexOf("https")?i(new Re('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}):void t.ajax({url:n,accepts:{json:"application/ld+json, application/json"},headers:{Accept:"application/ld+json, application/json"},dataType:"json",crossDomain:!0,success:function(t,r,o){var a={contextUrl:null,documentUrl:n,document:t},s=o.getResponseHeader("Content-Type"),u=o.getResponseHeader("Link") if(u&&"application/ld+json"!==s){if(u=e.parseLinkHeader(u)[Se],F(u))return i(new Re("URL could not be dereferenced, it has more than one associated HTTP Link Header.","jsonld.InvalidUrl",{code:"multiple context link headers",url:n}),a) u&&(a.contextUrl=u.target)}i(null,a)},error:function(e,t,r){i(new Re("URL could not be dereferenced, an error occurred.","jsonld.LoadDocumentError",{code:"loading document failed",url:n,cause:r}),{contextUrl:null,documentUrl:n,document:null})}})}r=r||{} var i=new e.RequestQueue return("usePromise"in r?r.usePromise:"undefined"!=typeof Promise)?i.wrapLoader(function(t){return e.promisify(n,t)}):i.wrapLoader(n)},e.documentLoaders.node=function(r){function n(t,l,c){function f(r,i,a){if(h={contextUrl:null,documentUrl:t,document:a||null},r)return c(new Re("URL could not be dereferenced, an error occurred.","jsonld.LoadDocumentError",{code:"loading document failed",url:t,cause:r}),h) var s=u.STATUS_CODES[i.statusCode] if(i.statusCode>=400)return c(new Re("URL could not be dereferenced: "+s,"jsonld.InvalidUrl",{code:"loading document failed",url:t,httpStatusCode:i.statusCode}),h) if(i.headers.link&&"application/ld+json"!==i.headers["content-type"]){var f=e.parseLinkHeader(i.headers.link)[Se] if(F(f))return c(new Re("URL could not be dereferenced, it has more than one associated HTTP Link Header.","jsonld.InvalidUrl",{code:"multiple context link headers",url:t}),h) f&&(h.contextUrl=f.target)}if(i.statusCode>=300&&i.statusCode<400&&i.headers.location)return l.length===o?c(new Re("URL could not be dereferenced; there were too many redirects.","jsonld.TooManyRedirects",{code:"loading document failed",url:t,httpStatusCode:i.statusCode,redirects:l}),h):-1!==l.indexOf(t)?c(new Re("URL could not be dereferenced; infinite redirection was detected.","jsonld.InfiniteRedirectDetected",{code:"recursive context inclusion",url:t,httpStatusCode:i.statusCode,redirects:l}),h):(l.push(t),n(i.headers.location,l,c)) l.push(t),c(r,h)}if(0!==t.indexOf("http:")&&0!==t.indexOf("https:"))return c(new Re('URL could not be dereferenced; only "http" and "https" URLs are supported.',"jsonld.InvalidUrl",{code:"loading document failed",url:t}),{contextUrl:null,documentUrl:t,document:null}) if(r.secure&&0!==t.indexOf("https"))return c(new Re('URL could not be dereferenced; secure mode is enabled and the URL\'s scheme is not "https".',"jsonld.InvalidUrl",{code:"loading document failed",url:t}),{contextUrl:null,documentUrl:t,document:null}) var h=null if(null!==h)return c(null,h) var d={Accept:s} for(var p in r.headers)d[p]=r.headers[p] a({url:t,headers:d,strictSSL:i,followRedirect:!1},f)}r=r||{} var i=!("strictSSL"in r)||r.strictSSL,o="maxRedirects"in r?r.maxRedirects:-1,a="request"in r?r.request:t("request"),s="application/ld+json, application/json",u=t("http"),l=new e.RequestQueue if(r.usePromise)return l.wrapLoader(function(t){return e.promisify(n,t,[])}) var c=r.headers||{} if("Accept"in c||"accept"in c)throw new RangeError('Accept header may not be specified as an option; only "'+s+'" is supported.') return l.wrapLoader(function(e,t){n(e,[],t)})},e.documentLoaders.xhr=function(t){function r(r,i){if(0!==r.indexOf("http:")&&0!==r.indexOf("https:"))return i(new Re('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 Re('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=t.xhr||XMLHttpRequest,a=new o a.onload=function(){if(a.status>=400)return i(new Re("URL could not be dereferenced: "+a.statusText,"jsonld.LoadDocumentError",{code:"loading document failed",url:r,httpStatusCode:a.status}),{contextUrl:null,documentUrl:r,document:null}) var t,o={contextUrl:null,documentUrl:r,document:a.response},s=a.getResponseHeader("Content-Type") if(n.test(a.getAllResponseHeaders())&&(t=a.getResponseHeader("Link")),t&&"application/ld+json"!==s){if(t=e.parseLinkHeader(t)[Se],F(t))return i(new Re("URL could not be dereferenced, it has more than one associated HTTP Link Header.","jsonld.InvalidUrl",{code:"multiple context link headers",url:r}),o) t&&(o.contextUrl=t.target)}i(null,o)},a.onerror=function(){i(new Re("URL could not be dereferenced, an error occurred.","jsonld.LoadDocumentError",{code:"loading document failed",url:r}),{contextUrl:null,documentUrl:r,document:null})},a.open("GET",r,!0),a.setRequestHeader("Accept","application/ld+json, application/json"),a.send()}t=t||{} var n=/(^|(\r\n))link:/i,i=new e.RequestQueue return("usePromise"in t?t.usePromise:"undefined"!=typeof Promise)?i.wrapLoader(function(t){return e.promisify(r,t)}):i.wrapLoader(r)},e.useDocumentLoader=function(t){if(!(t in e.documentLoaders))throw new Re('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,r){var n={},i=2 arguments.length>3&&(n=arguments[2]||{},i+=1) var o=arguments[i] if("base"in n||(n.base=""),"documentLoader"in n||(n.documentLoader=e.loadDocument),null===r)return o(null,M(n)) r=ee(r),P(r)&&"@context"in r||(r={"@context":r}),re(r,n,function(e,r){if(e)return o(e) try{r=(new Oe).processContext(t,r,n)}catch(e){return o(e)}o(null,r)})},e.hasProperty=function(e,t){var r=!1 if(t in e){var n=e[t] r=!F(n)||n.length>0}return r},e.hasValue=function(t,r,n){var i=!1 if(e.hasProperty(t,r)){var o=t[r],a=G(o) if(F(o)||a){a&&(o=o["@list"]) for(var s=0;s0){var v=R(t,d) e.addValue(o,v,N)}}else{var N if(H(p))N=R(t,p,null,{vocab:"@type"===d}) else{N=[] for(var m=0;m1&&!(2===S&&"@index"in s))throw new Re('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"],p=Object.keys(s),S=p.length)}else 1===S&&"@language"in s&&(s=null) return!P(s)||i.keepFreeFloatingNodes||o||null!==r&&"@graph"!==d||(0===S||"@value"in s||"@list"in s||1===S&&"@id"in s)&&(s=null),s},Oe.prototype.createNodeMap=function(e,t){t=t||{} var r=t.namer||t.issuer||new se("_:b"),n={"@default":{}} return g(e,n,"@default",r),m(n)},Oe.prototype.flatten=function(e){for(var t=this.createNodeMap(e),r=[],n=Object.keys(t).sort(),i=0;i=n.MAX_TOTAL_DEPTH)return r(new Error("Maximum total call stack depth exceeded; normalization aborting.")) !function i(){if(n.depth===n.MAX_DEPTH)return n.depth=0,n.running=!1,e.nextTick(i) var o=(new Date).getTime() if(n.running||(n.start=(new Date).getTime(),n.deadline=n.start+n.timeSlice),o1)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 se("_: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.hasht.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(oe(e)),i()},e)},function(e){if(t.sort(),"application/nquads"===r.options.format)return n=t.join(""),e() n=ne(t.join("")),e()}],e)}],function(e){t(e,n)})},r.prototype.hashFirstDegreeQuads=function(e,t){var r=this,n=r.blankNodeInfo[e] if("hash"in n)return t(null,n.hash) var i=[],o=n.quads r.forEach(o,function(t,n,o){var a={predicate:t.predicate} r.forEachComponent(t,function(t,n){a[n]=r.modifyFirstDegreeComponent(e,t,n)}),i.push(oe(a)),o()},function(e){if(e)return t(e) i.sort(),n.hash=Ae.hashNQuads(r.name,i),t(null,n.hash)})},r.prototype.modifyFirstDegreeComponent=function(e,t){return"blank node"!==t.type?t:(t=ee(t),t.value=t.value===e?"_:a":"_:z",t)},r.prototype.hashRelatedBlankNode=function(e,t,r,n,i){var o,a=this a.waterfall([function(t){return a.canonicalIssuer.hasId(e)?(o=a.canonicalIssuer.getId(e),t()):r.hasId(e)?(o=r.getId(e),t()):void a.hashFirstDegreeQuads(e,function(e,r){if(e)return t(e) o=r,t()})}],function(e){if(e)return i(e) var r=new Ae(a.name) return r.update(n),"g"!==n&&r.update(a.getRelatedPredicate(t)),r.update(o),i(null,r.digest())})},r.prototype.getRelatedPredicate=function(e){return"<"+e.predicate.value+">"},r.prototype.hashNDegreeQuads=function(e,t,r){var n,i=this,o=new Ae(i.name) i.waterfall([function(r){i.createHashToRelated(e,t,function(e,t){if(e)return r(e) n=t,r()})},function(e){var r=Object.keys(n).sort() i.forEach(r,function(e,r,a){o.update(e) var s,u="",l=new De(n[e]) i.whilst(function(){return l.hasNext()},function(e){var r=l.next(),n=t.clone(),o="",a=[] i.waterfall([function(t){i.forEach(r,function(t,r,s){if(i.canonicalIssuer.hasId(t)?o+=i.canonicalIssuer.getId(t):(n.hasId(t)||a.push(t),o+=n.getId(t)),0!==u.length&&o.length>=u.length&&o>u)return e() s()},t)},function(t){i.forEach(a,function(t,r,a){i.hashNDegreeQuads(t,n,function(r,i){return r?a(r):(o+=n.getId(t),o+="<"+i.hash+">",n=i.issuer,0!==u.length&&o.length>=u.length&&o>u?e():void a())})},t)},function(e){(0===u.length||ot)&&(a&&i>0&&o>this.list[i-1]||!a&&ithis.list[i+1])&&(t=o,r=i)}if(null===t)this.done=!0 else{var s=this.left[t]?r-1:r+1 this.list[r]=this.list[s],this.list[s]=t for(var i=0;it&&(this.left[this.list[i]]=!this.left[this.list[i]])}return e} var Ae=function(e){if(!(this instanceof Ae))return new Ae(e) if(-1===["URDNA2015","URGNA2012"].indexOf(e))throw new Error("Invalid RDF Dataset Normalization algorithm: "+e) Ae._init.call(this,e)} if(Ae.hashNQuads=function(e,t){for(var r=new Ae(e),n=0;n0;)1&r&&(n._padding+=t),(r>>>=1)>0&&(t+=t)}this.start()} n.prototype.start=function(){this.messageLength=0,this.fullMessageLength=[] for(var e=this._algorithm.messageLengthSize/4,t=0;t>>0,t>>>0] for(var r=this.fullMessageLength.length-1;r>=0;--r)this.fullMessageLength[r]+=t[1],t[1]=t[0]+(this.fullMessageLength[r]/4294967296>>>0),this.fullMessageLength[r]=this.fullMessageLength[r]>>>0,t[0]=t[1]/4294967296>>>0 for(this._input.putBytes(e.bytes());this._input.length()>=this._algorithm.blockSize;)this.state=this._algorithm.digest(this.state,this._input) return(this._input.read>2048||0===this._input.length())&&this._input.compact(),this},n.prototype.digest=function(){var e=new n.ByteBuffer e.putBytes(this._input.bytes()) var t=this.fullMessageLength[this.fullMessageLength.length-1]+this._algorithm.messageLengthSize,r=t&this._algorithm.blockSize-1 e.putBytes(n._padding.substr(0,this._algorithm.blockSize-r)) for(var i=new n.ByteBuffer,o=0;o>>28) this._algorithm.writeMessageLength(e,i) var a=this._algorithm.digest(this.state.copy(),e),s=new n.ByteBuffer return a.write(s),s},n.ByteBuffer=function(e){this.data="string"==typeof e?e:"",this.read=0},n.ByteBuffer.prototype.putInt32=function(e){this.data+=String.fromCharCode(e>>24&255)+String.fromCharCode(e>>16&255)+String.fromCharCode(e>>8&255)+String.fromCharCode(255&e)},n.ByteBuffer.prototype.getInt32=function(){var e=this.data.charCodeAt(this.read)<<24^this.data.charCodeAt(this.read+1)<<16^this.data.charCodeAt(this.read+2)<<8^this.data.charCodeAt(this.read+3) return this.read+=4,e},n.ByteBuffer.prototype.putBytes=function(e){this.data+=e},n.ByteBuffer.prototype.bytes=function(){return this.data.slice(this.read)},n.ByteBuffer.prototype.length=function(){return this.data.length-this.read},n.ByteBuffer.prototype.compact=function(){this.data=this.data.slice(this.read),this.read=0},n.ByteBuffer.prototype.toHex=function(){for(var e="",t=this.read;t=64;){for(n=e.h0,o=e.h1,a=e.h2,s=e.h3,u=e.h4,c=0;c<16;++c)r=t.getInt32(),h[c]=r,l=s^o&(a^s),r=(n<<5|n>>>27)+l+u+1518500249+r,u=s,s=a,a=o<<30|o>>>2,o=n,n=r for(;c<20;++c)r=h[c-3]^h[c-8]^h[c-14]^h[c-16],r=r<<1|r>>>31,h[c]=r,l=s^o&(a^s),r=(n<<5|n>>>27)+l+u+1518500249+r,u=s,s=a,a=o<<30|o>>>2,o=n,n=r for(;c<32;++c)r=h[c-3]^h[c-8]^h[c-14]^h[c-16],r=r<<1|r>>>31,h[c]=r,l=o^a^s,r=(n<<5|n>>>27)+l+u+1859775393+r,u=s,s=a,a=o<<30|o>>>2,o=n,n=r for(;c<40;++c)r=h[c-6]^h[c-16]^h[c-28]^h[c-32],r=r<<2|r>>>30,h[c]=r,l=o^a^s,r=(n<<5|n>>>27)+l+u+1859775393+r,u=s,s=a,a=o<<30|o>>>2,o=n,n=r for(;c<60;++c)r=h[c-6]^h[c-16]^h[c-28]^h[c-32],r=r<<2|r>>>30,h[c]=r,l=o&a|s&(o^a),r=(n<<5|n>>>27)+l+u+2400959708+r,u=s,s=a,a=o<<30|o>>>2,o=n,n=r for(;c<80;++c)r=h[c-6]^h[c-16]^h[c-28]^h[c-32],r=r<<2|r>>>30,h[c]=r,l=o^a^s,r=(n<<5|n>>>27)+l+u+3395469782+r,u=s,s=a,a=o<<30|o>>>2,o=n,n=r e.h0=e.h0+n|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,f-=64}return e},i._createState=function(){var e={h0:1732584193,h1:4023233417,h2:2562383102,h3:271733878,h4:3285377520} return e.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},e.write=function(t){t.putInt32(e.h0),t.putInt32(e.h1),t.putInt32(e.h2),t.putInt32(e.h3),t.putInt32(e.h4)},e} var o={_k:null,_w:null} o.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 r,n,i,a,s,u,l,c,f,h,d,p,v,g,m,y=t.length(),b=o._k,w=o._w;y>=64;){for(l=0;l<16;++l)w[l]=t.getInt32() for(;l<64;++l)r=w[l-2],r=(r>>>17|r<<15)^(r>>>19|r<<13)^r>>>10,n=w[l-15],n=(n>>>7|n<<25)^(n>>>18|n<<14)^n>>>3,w[l]=r+w[l-7]+n+w[l-16]|0 for(c=e.h0,f=e.h1,h=e.h2,d=e.h3,p=e.h4,v=e.h5,g=e.h6,m=e.h7,l=0;l<64;++l)a=(p>>>6|p<<26)^(p>>>11|p<<21)^(p>>>25|p<<7),s=g^p&(v^g),i=(c>>>2|c<<30)^(c>>>13|c<<19)^(c>>>22|c<<10),u=c&f|h&(c^f),r=m+a+s+b[l]+w[l],n=i+u,m=g,g=v,v=p,p=d+r|0,d=h,h=f,f=c,c=r+n|0 e.h0=e.h0+c|0,e.h1=e.h1+f|0,e.h2=e.h2+h|0,e.h3=e.h3+d|0,e.h4=e.h4+p|0,e.h5=e.h5+v|0,e.h6=e.h6+g|0,e.h7=e.h7+m|0,y-=64}return e},o._createState=function(){var e={h0:1779033703,h1:3144134277,h2:1013904242,h3:2773480762,h4:1359893119,h5:2600822924,h6:528734635,h7:1541459225} return e.copy=function(){var t=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},e.write=function(t){t.putInt32(e.h0),t.putInt32(e.h1),t.putInt32(e.h2),t.putInt32(e.h3),t.putInt32(e.h4),t.putInt32(e.h5),t.putInt32(e.h6),t.putInt32(e.h7)},e},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)}}(a),!de)var Me=function(){de=t("xmldom").XMLSerializer} 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,r){for(var n={},i=e.url.parsers[r||"full"],o=i.regex.exec(t),a=i.keys.length;a--;)n[i.keys[a]]=void 0===o[a]?null:o[a] return n.normalizedPath=ue(n.path,!!n.authority),n},a?e.useDocumentLoader("node"):"undefined"!=typeof XMLHttpRequest&&e.useDocumentLoader("xhr"),a){e.use=function(r){switch(r){case"request":e.request=t("jsonld-request") break default:throw new Re("Unknown extension.","jsonld.UnknownExtension",{extension:r})}} var Ue={exports:{},filename:o} t("pkginfo")(Ue,"version"),e.version=Ue.exports.version}return e},l=function(){return u(function(){return l()})} !a&&"function"==typeof e&&e.amd?e([],function(){return u(l),l}):(u(l),"function"==typeof t&&void 0!==r&&r.exports&&(r.exports=l),s&&("undefined"==typeof jsonld?jsonld=jsonldjs=l:jsonldjs=l))}()}).call(this,t("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},"/node_modules/jsonld/js")},{_process:10,crypto:29,"es6-promise":31,http:29,"jsonld-request":29,pkginfo:29,request:29,util:29,xmldom:29}],31:[function(t,r,n){(function(n,i){(function(){"use strict" function o(e){return"function"==typeof e||"object"==typeof e&&null!==e}function a(e){return"function"==typeof e}function s(e){return"object"==typeof e&&null!==e}function u(e){H=e}function l(e){W=e}function c(){return function(){B(h)}}function f(){return function(){setTimeout(h,1)}}function h(){for(var e=0;e\\"\{\}\|\^\`]/ n.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){function r(t){e(t._syntaxError(/^\S*/.exec(n)[0]))}for(var n=this._input;;){for(var i;i=this._newline.exec(n);)n=n.substr(i[0].length,n.length),this._line++ if((i=this._whitespace.exec(n))&&(n=n.substr(i[0].length,n.length)),this._endOfFile.test(n))return t&&e(n=null,{line:this._line,type:"eof",value:"",prefix:""}),this._input=n var o,a=this._line,s="",l="",c="",f=n[0],h=null,d=0,p=!1 switch(f){case"^":if(1===n.length)break if("^"!==n[1])return r(this) if(this._prevTokenType="^",n=n.substr(2),"<"!==n[0]){p=!0 break}case"<":if(h=this._unescapedIri.exec(n))s="IRI",l=h[1] else if(h=this._iri.exec(n)){if(null===(o=this._unescape(h[1]))||u.test(o))return r(this) s="IRI",l=o}break case"_":((h=this._blank.exec(n))||t&&(h=this._blank.exec(n+" ")))&&(s="prefixed",c="_",l=h[1]) break case'"':case"'":if(h=this._unescapedString.exec(n))s="literal",l=h[0] else if(h=this._singleQuotedString.exec(n)){if(null===(o=this._unescape(h[0])))return r(this) s="literal",l=o.replace(/^'|'$/g,'"')}else if(h=this._tripleQuotedString.exec(n)){if(o=h[1]||h[2],this._line+=o.split(/\r\n|\r|\n/).length-1,null===(o=this._unescape(o)))return r(this) s="literal",l=o.replace(/^'|'$/g,'"')}break case"@":"literal"===this._prevTokenType&&(h=this._langcode.exec(n))?(s="langcode",l=h[1]):(h=this._keyword.exec(n))&&(s=h[0]) break case".":if(1===n.length?t:n[1]<"0"||n[1]>"9"){s=".",d=1 break}case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":case"+":case"-":(h=this._number.exec(n))&&(s="literal",l='"'+h[0]+'"^^http://www.w3.org/2001/XMLSchema#'+(h[1]?"double":/^[+\-]?\d+$/.test(h[0])?"integer":"decimal")) break case"B":case"b":case"p":case"P":case"G":case"g":(h=this._sparqlKeyword.exec(n))?s=h[0].toUpperCase():p=!0 break case"f":case"t":(h=this._boolean.exec(n))?(s="literal",l='"'+h[0]+'"^^http://www.w3.org/2001/XMLSchema#boolean'):p=!0 break case"a":(h=this._shortPredicates.exec(n))?(s="abbreviation",l="http://www.w3.org/1999/02/22-rdf-syntax-ns#type"):p=!0 break case",":case";":case"[":case"]":case"(":case")":case"{":case"}":d=1,s=f break default:p=!0}if(p&&("@prefix"!==this._prevTokenType&&"PREFIX"!==this._prevTokenType||!(h=this._prefix.exec(n))?((h=this._prefixed.exec(n))||t&&(h=this._prefixed.exec(n+" ")))&&(s="prefixed",c=h[1]||"",l=this._unescape(h[2])):(s="prefix",l=h[1]||"")),"^"===this._prevTokenType&&(s="IRI"===s||"prefixed"===s?"type":""),!s)return t||!/^'''|^"""/.test(n)&&/\n|\r/.test(n)?r(this):this._input=n e(null,{line:a,type:s,value:l,prefix:c}),this._prevTokenType=s,n=n.substr(d||h[0].length,n.length)}},_unescape:function(e){try{return e.replace(a,function(e,t,r,n){var o if(t){if(o=parseInt(t,16),isNaN(o))throw new Error return i(o)}if(r){if(o=parseInt(r,16),isNaN(o))throw new Error return o<=65535?i(o):i(55296+(o-=65536)/1024,56320+(1023&o))}var a=s[n] if(!a)throw new Error return a})}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){function r(e){null!==i._input&&(i._input+=e,i._tokenizeToEnd(t,!1))}function n(){null!==i._input&&i._tokenizeToEnd(t,!0)}var i=this this._line=1,"string"==typeof e?(this._input=e,o(function(){i._tokenizeToEnd(t,!0)})):(this._input="",e&&"function"!=typeof e?("function"==typeof e.setEncoding&&e.setEncoding("utf8"),e.on("data",r),e.on("end",n)):(this.addChunk=r,this.end=n,t||(t=e)))}},t.exports=n},{}],34:[function(e,t,r){function n(e){if(!(this instanceof n))return new n(e) this._tripleStack=[],this._graph=null,e=e||{},this._setBase(e.documentIRI) var t="string"==typeof e.format&&e.format.match(/\w*$/)[0].toLowerCase(),r="turtle"===t,a="trig"===t,s=/triple/.test(t),u=/quad/.test(t),l=s||u;(this._supportsNamedGraphs=!r)||(this._readPredicateOrNamedGraph=this._readPredicate),this._supportsQuads=!(r||a||s),l&&(this._base="",this._resolveIRI=function(e){return this._error("Disallowed relative IRI",e),this._callback=i,this._subject=null}),this._blankNodePrefix="string"!=typeof e.blankNodePrefix?"":"_:"+e.blankNodePrefix.replace(/^_:/,""),this._lexer=e.lexer||new o({lineMode:l})}function i(){}var o=e("./N3Lexer"),a="http://www.w3.org/1999/02/22-rdf-syntax-ns#",s=a+"nil",u=a+"first",l=/^[a-z][a-z0-9+.-]*:/i,c=/^(?:([a-z][a-z0-9+.-]*:))?(?:\/\/[^\/]*)?/i,f=/(?:^|\/)\.\.?(?:$|[\/#?])/,h=0,d=0 n._resetBlankNodeIds=function(){h=d=0},n.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(c),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||l.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"+d++,this._tripleStack.push({subject:this._subject,predicate:null,object:null,type:"blank"}),this._readBlankNodeHead case"(":return this._tripleStack.push({subject:s,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||l.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 r=this._prefixes[e.prefix] if(void 0===r)return this._error('Undefined prefix "'+e.prefix+':"',e) this._predicate=r+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||l.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 r="_:b"+d++ return this._tripleStack.push({subject:this._subject,predicate:this._predicate,object:r,type:"blank"}),this._subject=r,this._readBlankNodeHead case"(":return this._tripleStack.push({subject:this._subject,predicate:this._predicate,object:s,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||l.test(e.value)?e.value:this._resolveIRI(e) else{var r=this._prefixes[e.prefix] if(void 0===r)return this._error('Undefined prefix "'+e.prefix+':"',e) t=r+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,r=null,n=this._subject,i=this._tripleStack,o=i[i.length-1],a=this._readListItem switch(e.type){case"IRI":t=null===this._base||l.test(e.value)?e.value:this._resolveIRI(e) break case"prefixed":var c=this._prefixes[e.prefix] if(void 0===c)return this._error('Undefined prefix "'+e.prefix+':"',e) t=c+e.value break case"literal":t=e.value,a=this._readDataTypeOrLang break case"[":r="_:b"+d++,t="_:b"+d++,i.push({subject:r,predicate:u,object:t,type:"blank"}),this._subject=t,a=this._readBlankNodeHead break case"(":r="_:b"+d++,i.push({subject:r,predicate:u,object:s,type:"list"}),this._subject=null,a=this._readListItem break case")":if(i.pop(),0!==i.length&&"list"===i[i.length-1].type&&this._callback(null,{subject:o.subject,predicate:o.predicate,object:o.object,graph:this._graph||""}),this._subject=o.subject,null===o.predicate){if(a=this._readPredicate,o.subject===s)return a}else if(this._predicate=o.predicate,this._object=o.object,a=this._getTripleEndReader(),o.object===s)return a r=s break default:return this._error('Expected list item instead of "'+e.type+'"',e)}return null===r&&(this._subject=r="_:b"+d++),null===n?o.object===s?o.object=r:o.subject=r:this._callback(null,{subject:n,predicate:"http://www.w3.org/1999/02/22-rdf-syntax-ns#rest",object:r,graph:this._graph||""}),null!==t&&this._callback(null,{subject:r,predicate:u,object:t,graph:this._graph||""}),a},_readPunctuation:function(e){var t,r=this._subject,n=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){n=null===this._base||l.test(e.value)?e.value:this._resolveIRI(e),r=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) n=i+e.value,t=this._readQuadPunctuation break}default:return this._error('Expected punctuation to follow "'+this._object+'"',e)}return null!==r&&this._callback(null,{subject:r,predicate:this._predicate,object:this._object,graph:n||""}),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){if("IRI"!==e.type)return this._error('Expected IRI to follow prefix "'+this._prefix+':"',e) var t return t=null===this._base||l.test(e.value)?e.value:this._resolveIRI(e),this._prefixes[this._prefix]=t,this._prefixCallback(this._prefix,t),this._readDeclarationPunctuation},_readBaseIRI:function(e){if("IRI"!==e.type)return this._error("Expected IRI to follow base declaration",e) try{this._setBase(null===this._base||l.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"+d++,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(!f.test(e))return e for(var t="",r=e.length,n=-1,i=-1,o=0,a="/";n=i&&(t=t.substr(0,o)),"/"!==a)return t+"/"+e.substr(n+1) o=n+1}}}a=e[++n]}return t+e.substring(o)},parse:function(e,t,r){this._readCallback=this._readInTopContext,this._prefixes=Object.create(null),this._prefixes._=this._blankNodePrefix||"_:b"+h+++"_","function"==typeof e&&(r=t,t=e,e=null),this._callback=t||i,this._prefixCallback=r||i var n=this this._lexer.tokenize(e,function(e,t){null!==e?(n._callback(e),n._callback=i):void 0!==n._readCallback&&(n._readCallback=n._readCallback(t))}),e||(this.addChunk=this._lexer.addChunk,this.end=this._lexer.end)}},t.exports=n},{"./N3Lexer":33}],35:[function(e,t,r){function n(e,t){if(!(this instanceof n))return new n(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)}var i=e("./N3Util").expandPrefixedName n.prototype={get size(){var e=this._size if(null!==e)return e var t,r,n=this._graphs for(var i in n)for(var o in t=n[i].subjects)for(var a in r=t[o])e+=Object.keys(r[a]).length return this._size=e},_addToIndex:function(e,t,r,n){var i=e[t]||(e[t]={});(i[r]||(i[r]={}))[n]=null},_removeFromIndex:function(e,t,r,n){var i,o=e[t],a=o[r] delete a[n] for(i in a)return delete o[r] for(i in o)return delete e[t]},_findInIndex:function(e,t,r,n,i,o,a,s){var u,l,c,f=[],h=Object.keys(this._entities) t&&((u=e,e={})[t]=u[t]) for(var d in e){var p=h[d] if(l=e[d]){r&&((u=l,l={})[r]=u[r]) for(var v in l){var g=h[v] if(c=l[v])for(var m=(n?n in c?[n]:[]:Object.keys(c)),y=m.length-1;y>=0;y--){var b={subject:"",predicate:"",object:"",graph:s} b[i]=p,b[o]=g,b[a]=h[m[y]],f.push(b)}}}}return f},_countInIndex:function(e,t,r,n){var i,o,a,s=0 t&&((i=e,e={})[t]=i[t]) for(var u in e)if(o=e[u]){r&&((i=o,o={})[r]=i[r]) for(var l in o)(a=o[l])&&(n?n in a&&s++:s+=Object.keys(a).length)}return s},addTriple:function(e,t,r,n){t||(n=e.graph,r=e.object,t=e.predicate,e=e.subject),n=n||"" var i=this._graphs[n] i||(i=this._graphs[n]={subjects:{},predicates:{},objects:{}},Object.freeze(i)) var o=this._entities e=o[e]||(o[e]=++this._entityCount),t=o[t]||(o[t]=++this._entityCount),r=o[r]||(o[r]=++this._entityCount),this._addToIndex(i.subjects,e,t,r),this._addToIndex(i.predicates,t,r,e),this._addToIndex(i.objects,r,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,r,n){t||(n=e.graph,r=e.object,t=e.predicate,e=e.subject),n=n||"" var i,o=this._entities,a=this._graphs if((e=o[e])&&(t=o[t])&&(r=o[r])&&(i=a[n])){var s,u if((s=i.subjects[e])&&(u=s[t])&&r in u){this._removeFromIndex(i.subjects,e,t,r),this._removeFromIndex(i.predicates,t,r,e),this._removeFromIndex(i.objects,r,e,t),null!==this._size&&this._size-- for(e in i.subjects)return delete a[n]}}},removeTriples:function(e){for(var t=e.length-1;t>=0;t--)this.removeTriple(e[t])},find:function(e,t,r,n){var o=this._prefixes return this.findByIRI(i(e,o),i(t,o),i(r,o),i(n,o))},findByIRI:function(e,t,r,n){n=n||"" var i=this._graphs[n],o=this._entities return i?e&&!(e=o[e])?[]:t&&!(t=o[t])?[]:r&&!(r=o[r])?[]:e?r?this._findInIndex(i.objects,r,e,t,"object","subject","predicate",n):this._findInIndex(i.subjects,e,t,null,"subject","predicate","object",n):t?this._findInIndex(i.predicates,t,r,null,"predicate","object","subject",n):r?this._findInIndex(i.objects,r,null,null,"object","subject","predicate",n):this._findInIndex(i.subjects,null,null,null,"subject","predicate","object",n):[]},count:function(e,t,r,n){var o=this._prefixes return this.countByIRI(i(e,o),i(t,o),i(r,o),i(n,o))},countByIRI:function(e,t,r,n){n=n||"" var i=this._graphs[n],o=this._entities return i?e&&!(e=o[e])?0:t&&!(t=o[t])?0:r&&!(r=o[r])?0:e?r?this._countInIndex(i.objects,r,e,t):this._countInIndex(i.subjects,e,t,r):t?this._countInIndex(i.predicates,t,r,e):this._countInIndex(i.objects,r,e,t):0},createBlankNode:function(e){var t,r if(e)for(t=e="_:"+e,r=1;this._entities[t];)t=e+r++ else do{t="_:b"+this._blankNodeIndex++}while(this._entities[t]) return this._entities[t]=++this._entityCount,t}},t.exports=n},{"./N3Util":38}],36:[function(e,t,r){function n(e){if(!(this instanceof n))return new n(e) i.call(this,{decodeStrings:!0}),this._readableState.objectMode=!0 var t=this,r=new a(e) r.parse(function(e,r){r&&t.push(r)||e&&t.emit("error",e)},this.emit.bind(this,"prefix")),this._transform=function(e,t,n){r.addChunk(e),n()},this._flush=function(e){r.end(),e()}}var i=e("stream").Transform,o=e("util"),a=e("./N3Parser.js") o.inherits(n,i),t.exports=n},{"./N3Parser.js":34,stream:25,util:28}],37:[function(e,t,r){function n(e){if(!(this instanceof n))return new n(e) i.call(this,{encoding:"utf8"}),this._writableState.objectMode=!0 var t=this,r=new a({write:function(e,r,n){t.push(e),n&&n()},end:function(e){t.push(null),e&&e()}},e) this._transform=function(e,t,n){r.addTriple(e,n)},this._flush=function(e){r.end(e)}}var i=e("stream").Transform,o=e("util"),a=e("./N3Writer.js") o.inherits(n,i),t.exports=n},{"./N3Writer.js":39,stream:25,util:28}],38:[function(e,t,r){function n(e,t){for(var r in o)t?e.prototype[r]=i(o[r]):e[r]=o[r] return e}function i(e){return function(t){return e(this,t)}}var o={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 r,n,i,o=/(?:^|"\^\^)([^:\/#"'\^_]*):[^\/]*$/.exec(e) return o&&(r=o[1],n=t[r],i=o.index),void 0===n?e:0===i?n+e.substr(r.length+1):e.substr(0,i+3)+n+e.substr(i+r.length+4)},createIRI:function(e){return e&&'"'===e[0]?o.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)}} t.exports=n(n)},{}],39:[function(e,t,r){function n(e,t){if(!(this instanceof n))return new n(e,t) if(e&&"function"!=typeof e.write&&(t=e,e=null),t=t||{},e)this._outputStream=e,this._endStream=void 0===t.end||!!t.end else{var r="" this._outputStream={write:function(e,t,n){r+=e,n&&n()},end:function(e){e&&e(null,r)}},this._endStream=!0}this._subject=null,/triple|quad/i.test(t.format)?this._writeTriple=this._writeTripleLine:(this._graph="",this._prefixIRIs=Object.create(null),t.prefixes&&this.addPrefixes(t.prefixes))}function i(e){var t=u[e] return void 0===t&&(1===e.length?(t=e.charCodeAt(0).toString(16),t="\\u0000".substr(0,6-t.length)+t):(t=(1024*(e.charCodeAt(0)-55296)+e.charCodeAt(1)+9216).toString(16),t="\\U00000000".substr(0,10-t.length)+t)),t}var o=/^"([^]*)"(?:\^\^(.+)|@([\-a-z]+))?$/i,a=/["\\\t\n\r\b\f\u0000-\u0019\ud800-\udbff]/,s=/["\\\t\n\r\b\f\u0000-\u0019]|[\ud800-\udbff][\udc00-\udfff]/g,u={"\\":"\\\\",'"':'\\"',"\t":"\\t","\n":"\\n","\r":"\\r","\b":"\\b","\f":"\\f"} n.prototype={_write:function(e,t){this._outputStream.write(e,"utf8",t)},_writeTriple:function(e,t,r,n,i){try{this._graph!==n&&(this._write((null===this._subject?"":this._graph?"\n}\n":".\n")+(n?this._encodeIriOrBlankNode(n)+" {\n":"")),this._subject=null,this._graph="["!==n[0]?n:"]"),this._subject===e?this._predicate===t?this._write(", "+this._encodeObject(r),i):this._write(";\n "+this._encodePredicate(this._predicate=t)+" "+this._encodeObject(r),i):this._write((null===this._subject?"":".\n")+this._encodeSubject(this._subject=e)+" "+this._encodePredicate(this._predicate=t)+" "+this._encodeObject(r),i)}catch(e){i&&i(e)}},_writeTripleLine:function(e,t,r,n,i){delete this._prefixMatch try{this._write(this._encodeIriOrBlankNode(e)+" "+this._encodeIriOrBlankNode(t)+" "+this._encodeObject(r)+(n?" "+this._encodeIriOrBlankNode(n)+".\n":".\n"),i)}catch(e){i&&i(e)}},_encodeIriOrBlankNode:function(e){var t=e[0] if("["===t||"("===t||"_"===t&&":"===e[1])return e a.test(e)&&(e=e.replace(s,i)) var r=this._prefixRegex.exec(e) return r?r[1]?this._prefixIRIs[r[1]]+r[2]:e:"<"+e+">"},_encodeLiteral:function(e,t,r){return a.test(e)&&(e=e.replace(s,i)),r?'"'+e+'"@'+r:t?'"'+e+'"^^'+this._encodeIriOrBlankNode(t):'"'+e+'"'},_encodeSubject:function(e){if('"'===e[0])throw new Error("A literal as subject is not allowed: "+e) return"["===e[0]&&(this._subject="]"),this._encodeIriOrBlankNode(e)},_encodePredicate:function(e){if('"'===e[0])throw new Error("A literal as predicate is not allowed: "+e) return"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=o.exec(e) if(!t)throw new Error("Invalid literal: "+e) return this._encodeLiteral(t[1],t[2],t[3])},_blockedWrite:function(){throw new Error("Cannot write because the writer has been closed.")},addTriple:function(e,t,r,n,i){void 0===r?this._writeTriple(e.subject,e.predicate,e.object,e.graph||"",t):"string"!=typeof n?this._writeTriple(e,t,r,"",n):this._writeTriple(e,t,r,n,i)},addTriples:function(e){for(var t=0;t.\n"))}if(n){var a="",s="" for(var u in r)a+=a?"|"+u:u,s+=(s?"|":"")+r[u] a=a.replace(/[\]\/\(\)\*\+\?\.\\\$]/g,"\\$&"),this._prefixRegex=new RegExp("^(?:"+s+")[^/]*$|^("+a+")([a-zA-Z][\\-_a-zA-Z0-9]*)$")}this._write(n?"\n":"",t)},blank:function(e,t){var r,n,i=e switch(void 0===e?i=[]:"string"==typeof e?i=[{predicate:e,object:t}]:"length"in e||(i=[e]),n=i.length){case 0:return"[]" case 1:if(r=i[0],"["!==r.object[0])return"[ "+this._encodePredicate(r.predicate)+" "+this._encodeObject(r.object)+" ]" default:for(var o="[",a=0;a=t+r||t?new java.lang.String(e,t,r)+"":e}function l(e,t){e.currentElement?e.currentElement.appendChild(t):e.document.appendChild(t)}if(n.prototype.parseFromString=function(e,t){var r=this.options,n=new c,a=r.domBuilder||new o,s=r.errorHandler,u=r.locator,l=r.xmlns||{},f={lt:"<",gt:">",amp:"&",quot:'"',apos:"'"} return u&&a.setDocumentLocator(u),n.errorHandler=i(s,a,u),n.domBuilder=r.domBuilder||a,/\/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?n.parse(e,l,f):n.errorHandler.error("invalid document source"),a.document},o.prototype={startDocument:function(){this.document=(new f).createDocument(null,null,null),this.locator&&(this.document.documentURI=this.locator.systemId)},startElement:function(e,t,r,n){var i=this.document,o=i.createElementNS(e,r||t),s=n.length l(this,o),this.currentElement=o,this.locator&&a(this.locator,o) for(var u=0;u=0))throw o(ie,new Error) for(var i=t.length-1;n"==e&&">"||"&"==e&&"&"||'"'==e&&"""||"&#"+e.charCodeAt()+";"}function g(e,t){if(t(e))return!0 if(e=e.firstChild)do{if(g(e,t))return!0}while(e=e.nextSibling)}function m(){}function y(e,t,r){e&&e._inc++,"http://www.w3.org/2000/xmlns/"==r.namespaceURI&&(t._nsMap[r.prefix?r.localName:""]=r.value)}function b(e,t,r,n){e&&e._inc++,"http://www.w3.org/2000/xmlns/"==r.namespaceURI&&delete t._nsMap[r.prefix?r.localName:""]}function w(e,t,r){if(e&&e._inc){e._inc++ var n=t.childNodes if(r)n[n.length++]=r else{for(var i=t.firstChild,o=0;i;)n[o++]=i,i=i.nextSibling n.length=o}}}function x(e,t){var r=t.previousSibling,n=t.nextSibling return r?r.nextSibling=n:e.firstChild=n,n?n.previousSibling=r:e.lastChild=r,w(e.ownerDocument,e),t}function _(e,t,r){var n=t.parentNode if(n&&n.removeChild(t),t.nodeType===ee){var i=t.firstChild if(null==i)return t var o=t.lastChild}else i=o=t var a=r?r.previousSibling:e.lastChild i.previousSibling=a,o.nextSibling=r,a?a.nextSibling=i:e.firstChild=i,null==r?e.lastChild=o:r.previousSibling=o do{i.parentNode=e}while(i!==o&&(i=i.nextSibling)) return w(e.ownerDocument||e,e),t.nodeType==ee&&(t.firstChild=t.lastChild=null),t}function T(e,t){var r=t.parentNode if(r){var n=e.lastChild r.removeChild(t) var n=e.lastChild}var n=e.lastChild return t.parentNode=e,t.previousSibling=n,t.nextSibling=null,n?n.nextSibling=t:e.firstChild=t,e.lastChild=t,w(e.ownerDocument,e,t),t}function k(){this._nsMap={}}function N(){}function E(){}function j(){}function S(){}function I(){}function R(){}function O(){}function C(){}function L(){}function D(){}function A(){}function M(){}function U(e,t,r,n){switch(e.nodeType){case X:var i=e.attributes,o=i.length,a=e.firstChild,s=e.tagName n=H===e.namespaceURI||n,t.push("<",s),r&&t.sort.apply(i,r) for(var u=0;u"),n&&/^script$/i.test(s))a&&t.push(a.data) else for(;a;)U(a,t,r,n),a=a.nextSibling t.push("")}else t.push("/>") return case Z:case ee:for(var a=e.firstChild;a;)U(a,t,r,n),a=a.nextSibling return case V:return t.push(" ",e.name,'="',e.value.replace(/[<&"]/g,v),'"') case W:return t.push(e.data.replace(/[<&]/g,v)) case J:return t.push("") case G:return t.push("\x3c!--",e.data,"--\x3e") case K:var l=e.publicId,c=e.systemId if(t.push("') else if(c&&"."!=c)t.push(' SYSTEM "',c,'">') else{var f=e.internalSubset f&&t.push(" [",f,"]"),t.push(">")}return case Q:return t.push("") case $:return t.push("&",e.nodeName,";") default:t.push("??",e.nodeName)}}function P(e,t,r){var n switch(t.nodeType){case X:n=t.cloneNode(!1),n.ownerDocument=e case ee:break case V:r=!0}if(n||(n=t.cloneNode(!1)),n.ownerDocument=e,n.parentNode=null,r)for(var i=t.firstChild;i;)n.appendChild(P(e,i,r)),i=i.nextSibling return n}function q(e,t,r){var n=new t.constructor for(var i in t){var o=t[i] "object"!=typeof o&&o!=n[i]&&(n[i]=o)}switch(t.childNodes&&(n.childNodes=new a),n.ownerDocument=e,n.nodeType){case X:var s=t.attributes,u=n.attributes=new l,c=s.length u._ownerElement=n for(var f=0;f0},lookupPrefix:function(e){for(var t=this;t;){var r=t._nsMap if(r)for(var n in r)if(r[n]==e)return n t=2==t.nodeType?t.ownerDocument:t.parentNode}return null},lookupNamespaceURI:function(e){for(var t=this;t;){var r=t._nsMap if(r&&e in r)return r[e] t=2==t.nodeType?t.ownerDocument:t.parentNode}return null},isDefaultNamespace:function(e){return null==this.lookupPrefix(e)}},n(z,p),n(z,p.prototype),m.prototype={nodeName:"#document",nodeType:Z,doctype:null,documentElement:null,_inc:1,insertBefore:function(e,t){if(e.nodeType==ee){for(var r=e.firstChild;r;){var n=r.nextSibling this.insertBefore(r,t),r=n}return e}return null==this.documentElement&&1==e.nodeType&&(this.documentElement=e),_(this,e,t),e.ownerDocument=this,e},removeChild:function(e){return this.documentElement==e&&(this.documentElement=null),x(this,e)},importNode:function(e,t){return P(this,e,t)},getElementById:function(e){var t=null return g(this.documentElement,function(r){if(1==r.nodeType&&r.getAttribute("id")==e)return t=r,!0}),t},createElement:function(e){var t=new k return t.ownerDocument=this,t.nodeName=e,t.tagName=e,t.childNodes=new a,(t.attributes=new l)._ownerElement=t,t},createDocumentFragment:function(){var e=new D return e.ownerDocument=this,e.childNodes=new a,e},createTextNode:function(e){var t=new j return t.ownerDocument=this,t.appendData(e),t},createComment:function(e){var t=new S return t.ownerDocument=this,t.appendData(e),t},createCDATASection:function(e){var t=new I return t.ownerDocument=this,t.appendData(e),t},createProcessingInstruction:function(e,t){var r=new A return r.ownerDocument=this,r.tagName=r.target=e,r.nodeValue=r.data=t,r},createAttribute:function(e){var t=new N return t.ownerDocument=this,t.name=e,t.nodeName=e,t.localName=e,t.specified=!0,t},createEntityReference:function(e){var t=new L return t.ownerDocument=this,t.nodeName=e,t},createElementNS:function(e,t){var r=new k,n=t.split(":"),i=r.attributes=new l return r.childNodes=new a,r.ownerDocument=this,r.nodeName=t,r.tagName=t,r.namespaceURI=e,2==n.length?(r.prefix=n[0],r.localName=n[1]):r.localName=t,i._ownerElement=r,r},createAttributeNS:function(e,t){var r=new N,n=t.split(":") return r.ownerDocument=this,r.nodeName=t,r.name=t,r.namespaceURI=e,r.specified=!0,2==n.length?(r.prefix=n[0],r.localName=n[1]):r.localName=t,r}},i(m,p),k.prototype={nodeType:X,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 r=this.ownerDocument.createAttribute(e) r.value=r.nodeValue=""+t,this.setAttributeNode(r)},removeAttribute:function(e){var t=this.getAttributeNode(e) t&&this.removeAttributeNode(t)},appendChild:function(e){return e.nodeType===ee?this.insertBefore(e,null):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 r=this.getAttributeNodeNS(e,t) r&&this.removeAttributeNode(r)},hasAttributeNS:function(e,t){return null!=this.getAttributeNodeNS(e,t)},getAttributeNS:function(e,t){var r=this.getAttributeNodeNS(e,t) return r&&r.value||""},setAttributeNS:function(e,t,r){var n=this.ownerDocument.createAttributeNS(e,t) n.value=n.nodeValue=""+r,this.setAttributeNode(n)},getAttributeNodeNS:function(e,t){return this.attributes.getNamedItemNS(e,t)},getElementsByTagName:function(e){return new s(this,function(t){var r=[] return g(t,function(n){n===t||n.nodeType!=X||"*"!==e&&n.tagName!=e||r.push(n)}),r})},getElementsByTagNameNS:function(e,t){return new s(this,function(r){var n=[] return g(r,function(i){i===r||i.nodeType!==X||"*"!==e&&i.namespaceURI!==e||"*"!==t&&i.localName!=t||n.push(i)}),n})}},m.prototype.getElementsByTagName=k.prototype.getElementsByTagName,m.prototype.getElementsByTagNameNS=k.prototype.getElementsByTagNameNS,i(k,p),N.prototype.nodeType=V,i(N,p),E.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(ne[3])},deleteData:function(e,t){this.replaceData(e,t,"")},replaceData:function(e,t,r){r=this.data.substring(0,e)+r+this.data.substring(e+t),this.nodeValue=this.data=r,this.length=r.length}},i(E,p),j.prototype={nodeName:"#text",nodeType:W,splitText:function(e){var t=this.data,r=t.substring(e) t=t.substring(0,e),this.data=this.nodeValue=t,this.length=t.length var n=this.ownerDocument.createTextNode(r) return this.parentNode&&this.parentNode.insertBefore(n,this.nextSibling),n}},i(j,E),S.prototype={nodeName:"#comment",nodeType:G},i(S,E),I.prototype={nodeName:"#cdata-section",nodeType:J},i(I,E),R.prototype.nodeType=K,i(R,p),O.prototype.nodeType=te,i(O,p),C.prototype.nodeType=Y,i(C,p),L.prototype.nodeType=$,i(L,p),D.prototype.nodeName="#document-fragment",D.prototype.nodeType=ee,i(D,p),A.prototype.nodeType=Q,i(A,p),M.prototype.serializeToString=function(e,t){return e.toString(t)},p.prototype.toString=function(e){var t=[] return U(this,t,e),t.join("")} try{Object.defineProperty&&(Object.defineProperty(s.prototype,"length",{get:function(){return u(this),this.$$length}}),Object.defineProperty(p.prototype,"textContent",{get:function(){return B(this)},set:function(e){switch(this.nodeType){case 1:case 11:for(;this.firstChild;)this.removeChild(this.firstChild);(e||String(e))&&this.appendChild(this.ownerDocument.createTextNode(e)) break default:this.data=e,this.value=value,this.nodeValue=e}}}),F=function(e,t,r){e["$$"+t]=r})}catch(e){}"function"==typeof e&&(r.DOMImplementation=d,r.XMLSerializer=M)},{}],42:[function(e,t,r){function n(){}function i(e,t,r,n,i){function c(e){if(e>65535){e-=65536 var t=55296+(e>>10),r=56320+(1023&e) return String.fromCharCode(t,r)}return String.fromCharCode(e)}function p(e){var t=e.slice(1,-1) return t in r?r[t]:"#"===t.charAt(0)?c(parseInt(t.substr(1).replace("x","0x"))):(i.error("entity not found:"+e),e)}function v(t){if(t>T){var r=e.substring(T,t).replace(/&#?\w+;/g,p) w&&g(T),n.characters(r,0,t-T),T=t}}function g(t,r){for(;t>=y&&(r=b.exec(e));)m=r.index,y=m+r[0].length,w.lineNumber++ w.columnNumber=t-m+1}for(var m=0,y=0,b=/.+(?:\r\n?|\n)|.*$/g,w=n.locator,x=[{currentNSMap:t}],_={},T=0;;){try{var k=e.indexOf("<",T) if(k<0){if(!e.substr(T).match(/^\s*$/)){var N=n.document,E=N.createTextNode(e.substr(T)) N.appendChild(E),n.currentElement=E}return}switch(k>T&&v(k),e.charAt(k+1)){case"/":var j=e.indexOf(">",k+3),S=e.substring(k+2,j),I=x.pop(),R=I.localNSMap if(I.tagName!=S&&i.fatalError("end tag name: "+S+" is not match the current start tagName:"+I.tagName),n.endElement(I.uri,I.localName,S),R)for(var O in R)n.endPrefixMapping(O) j++ break case"?":w&&g(k),j=h(e,k,n) break case"!":w&&g(k),j=f(e,k,n,i) break default:w&&g(k) var C=new d,j=a(e,k,C,p,i),L=C.length if(w){if(L)for(var D=0;DT?T=j:v(Math.max(k,T)+1)}}function o(e,t){return t.lineNumber=e.lineNumber,t.columnNumber=e.columnNumber,t}function a(e,t,r,n,i){for(var o,a,s=++t,u=b;;){var l=e.charAt(s) switch(l){case"=":if(u===w)o=e.slice(t,s),u=_ else{if(u!==x)throw new Error("attribute equal must after attrName") u=_}break case"'":case'"':if(u===_){if(t=s+1,!((s=e.indexOf(l,t))>0))throw new Error("attribute value no end '"+l+"' match") a=e.slice(t,s).replace(/&#?\w+;/g,n),r.add(o,a,t-1),u=k}else{if(u!=T)throw new Error('attribute value must after "="') a=e.slice(t,s).replace(/&#?\w+;/g,n),r.add(o,a,t),i.warning('attribute "'+o+'" missed start quot('+l+")!!"),t=s+1,u=k}break case"/":switch(u){case b:r.setTagName(e.slice(t,s)) case k:case N:case E:u=E,r.closed=!0 case T:case w:case x:break default:throw new Error("attribute invalid close char('/')")}break case"":i.error("unexpected end of input") case">":switch(u){case b:r.setTagName(e.slice(t,s)) case k:case N:case E:break case T:case w:a=e.slice(t,s),"/"===a.slice(-1)&&(r.closed=!0,a=a.slice(0,-1)) case x:u===x&&(a=o),u==T?(i.warning('attribute "'+a+'" missed quot(")!!'),r.add(o,a.replace(/&#?\w+;/g,n),t)):(i.warning('attribute "'+a+'" missed value!! "'+a+'" instead!!'),r.add(a,a,t)) break case _:throw new Error("attribute value missed!!")}return s case"€":l=" " default:if(l<=" ")switch(u){case b:r.setTagName(e.slice(t,s)),u=N break case w:o=e.slice(t,s),u=x break case T:var a=e.slice(t,s).replace(/&#?\w+;/g,n) i.warning('attribute "'+a+'" missed quot(")!!'),r.add(o,a,t) case k:u=N}else switch(u){case x:i.warning('attribute "'+o+'" missed value!! "'+o+'" instead!!'),r.add(o,o,t),t=s,u=w break case k:i.warning('attribute space is required"'+o+'"!!') case N:u=w,t=s break case _:u=T,t=s break case E:throw new Error("elements closed character '/' and '>' must be connected to")}}s++}}function s(e,t,r){for(var n=e.tagName,i=null,o=r[r.length-1].currentNSMap,a=e.length;a--;){var s=e[a],u=s.qName,l=s.value,f=u.indexOf(":") if(f>0)var h=s.prefix=u.slice(0,f),d=u.slice(f+1),p="xmlns"===h&&d else d=u,h=null,p="xmlns"===u&&"" s.localName=d,!1!==p&&(null==i&&(i={},c(o,o={})),o[p]=i[p]=l,s.uri="http://www.w3.org/2000/xmlns/",t.startPrefixMapping(p,l))}for(var a=e.length;a--;){s=e[a] var h=s.prefix h&&("xml"===h&&(s.uri="http://www.w3.org/XML/1998/namespace"),"xmlns"!==h&&(s.uri=o[h]))}var f=n.indexOf(":") f>0?(h=e.prefix=n.slice(0,f),d=e.localName=n.slice(f+1)):(h=null,d=e.localName=n) var v=e.uri=o[h||""] if(t.startElement(v,d,n,e),e.closed){if(t.endElement(v,d,n),i)for(h in i)t.endPrefixMapping(h)}else e.currentNSMap=o,e.localNSMap=i,r.push(e)}function u(e,t,r,n,i){if(/^(?:script|textarea)$/i.test(r)){var o=e.indexOf("",t),a=e.substring(t+1,o) if(/[&<]/.test(a))return/^script$/i.test(r)?(i.characters(a,0,a.length),o):(a=a.replace(/&#?\w+;/g,n),i.characters(a,0,a.length),o)}return t+1}function l(e,t,r,n){var i=n[r] return null==i&&(i=n[r]=e.lastIndexOf("")),it?(r.comment(e,t+4,i-t-4),i+3):(n.error("Unclosed comment"),-1)}return-1 default:if("CDATA["==e.substr(t+3,6)){var i=e.indexOf("]]>",t+9) return r.startCDATA(),r.characters(e,t+9,i-t-9),r.endCDATA(),i+3}var o=v(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],l=a>4&&o[4][0],c=o[a-1] return r.startDTD(s,u&&u.replace(/^(['"])(.*?)\1$/,"$2"),l&&l.replace(/^(['"])(.*?)\1$/,"$2")),r.endDTD(),c.index+c[0].length}}return-1}function h(e,t,r){var n=e.indexOf("?>",t) if(n){var i=e.substring(t,n).match(/^<\?(\S*)\s*([\s\S]*?)\s*$/) if(i){i[0].length return r.processingInstruction(i[1],i[2]),n+2}return-1}return-1}function d(e){}function p(e,t){return e.__proto__=t,e}function v(e,t){var r,n=[],i=/'[^']+'|"[^"]+"|[^\s<>\/=]+=?|(\/?\s*>|<)/g for(i.lastIndex=t,i.exec(e);r=i.exec(e);)if(n.push(r),r[1])return n}var g=/[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]/,m=new RegExp("[\\-\\.0-9"+g.source.slice(1,-1)+"·̀-ͯ\\u203F-⁀]"),y=new RegExp("^"+g.source+m.source+"*(?::"+g.source+m.source+"*)?$"),b=0,w=1,x=2,_=3,T=4,k=5,N=6,E=7 n.prototype={parse:function(e,t,r){var n=this.domBuilder n.startDocument(),c(t,t={}),i(e,t,r,n,this.errorHandler),n.endDocument()}},d.prototype={setTagName:function(e){if(!y.test(e))throw new Error("invalid tagName:"+e) this.tagName=e},add:function(e,t,r){if(!y.test(e))throw new Error("invalid attribute:"+e) this[this.length++]={qName:e,value:t,offset:r}},length:0,getLocalName:function(e){return this[e].localName},getOffset:function(e){return this[e].offset},getQName:function(e){return this[e].qName},getURI:function(e){return this[e].uri},getValue:function(e){return this[e].value}},p({},p.prototype)instanceof p||(p=function(e,t){function r(){}r.prototype=t,r=new r for(t in e)r[t]=e[t] return r}),"function"==typeof e&&(r.XMLReader=n)},{}],43:[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"!=typeof 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 "+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)}var a=function(){function e(e,t){for(var r=0;re.classOrder?1:this.ide.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}(u) l.nextId=0,l.termType="BlankNode",l.NTAnonymousNodePrefix="_:n",l.prototype.classOrder=s.BlankNode,l.prototype.isBlank=1,l.prototype.isVar=1,t.exports=l},{"./class-order":44,"./node":59}],44:[function(e,t,r){"use strict" var n={Literal:1,Collection:3,Formula:4,NamedNode:5,BlankNode:6,Variable:7} t.exports=n},{}],45:[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"!=typeof 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 "+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)}var a=function(){function e(e,t){for(var r=0;r0&&e.forEach(function(e){r.elements.push(l.fromValue(e))}),r}return o(t,e),a(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){return new t(this.elements.map(function(t){t.substitute(e)}))}},{key:"toNT",value:function(){return s.NTAnonymousNodePrefix+this.id}},{key:"toString",value:function(){return"("+this.elements.join(" ")+")"}},{key:"unshift",value:function(e){return this.elements.unshift(e)}}]),t}(l) c.termType="collection",c.prototype.classOrder=u.Collection,c.prototype.compareTerm=s.prototype.compareTerm,c.prototype.isVar=0,t.exports=c},{"./blank-node":43,"./class-order":44,"./node":59}],46:[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(e){t(e)}},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)})}t.exports.convertToJson=n,t.exports.convertToNQuads=i var o=e("async"),a=e("jsonld"),s=e("n3")},{async:1,jsonld:30,n3:32}],47:[function(e,t,r){"use strict" function n(e){return new v(e)}function i(e){return new g(e)}function o(){return new m}function a(e,t,r){return new y(e,t,r)}function s(){return new b}function u(e,t,r){return new w(""+e,t,r)}function l(e,t){return"string"==typeof t?-1===t.indexOf(":")?new w(e,t):new w(e,null,c(t)):new w(e,null,t)}function c(e){return new x(e)}function f(e,t,r,n){return n=n||new m,new _(e,t,r,n)}function h(e,t,r,n){return new _(e,t,r,n)}function d(e,t,r){return f(e,t,r)}function p(e){return new T(e)}var v=e("./blank-node"),g=e("./collection"),m=e("./default-graph"),y=e("./fetcher"),b=e("./indexed-formula"),w=e("./literal"),x=e("./named-node"),_=e("./statement"),T=e("./variable") t.exports.blankNode=n,t.exports.defaultGraph=o,t.exports.graph=s,t.exports.literal=l,t.exports.namedNode=c,t.exports.quad=f,t.exports.triple=d,t.exports.variable=p,t.exports.collection=i,t.exports.fetcher=a,t.exports.lit=u,t.exports.st=h},{"./blank-node":43,"./collection":45,"./default-graph":48,"./fetcher":50,"./indexed-formula":52,"./literal":54,"./named-node":57,"./statement":69,"./variable":74}],48:[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"!=typeof 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 "+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)}var a=function(){function e(e,t){for(var r=0;r0&&i.add(e.resource,m.dc("title"),i.literal(o[0].textContent),e.resource) for(var a=this.dom.getElementsByTagName("link"),s=a.length-1;s>=0;s--)r=a[s].getAttribute("rel"),n=!1,r||(r=a[s].getAttribute("rev"),n=!0),r&&v.linkData(e,r,a[s].getAttribute("href"),e.resource,n) for(var c=this.dom.getElementsByTagName("script"),f=0;f]+\?>/))return v.addStatus(e.req,"Has an XML declaration. We'll assume it's XHTML as the content-type was text/html.\n"),void v.switchHandler("XHTMLHandler",e,t) if(r.match(/.*/))return v.addStatus(e.req,"Has XHTML DOCTYPE. Switching to XHTMLHandler.\n"),void v.switchHandler("XHTMLHandler",e,t) if(r.match(/[^(/))return v.addStatus(e.req,"Has default namespace for XHTML, so switching to XHTMLHandler.\n"),void v.switchHandler("XHTMLHandler",e,t) var n=new RegExp("([\\s\\S]+?)","im").exec(r) if(n){var i=v.store return i.add(e.resource,m.dc("title"),i.literal(n[1]),e.resource),i.add(e.resource,m.rdf("type"),m.link("WebPage"),v.appNode),void t()}v.addStatus(e.req,"non-XML HTML document, not parsed for data."),v.doneFetch(e)}}},e.HTMLHandler.toString=function(){return"HTMLHandler"},e.HTMLHandler.register=function(e){e.mediatypes["text/html"]={q:.9}},e.HTMLHandler.pattern=new RegExp("text/html"),e.TextHandler=function(){this.handlerFactory=function(e){e.handle=function(t){var r=e.responseText return r.match(/\s*<\?xml\s+version\s*=[^<>]+\?>/)?(v.addStatus(e.req,"Warning: "+e.resource+" has an XML declaration. We'll assume it's XML but its content-type wasn't XML.\n"),void v.switchHandler("XMLHandler",e,t)):r.slice(0,500).match(/xmlns:/)?(v.addStatus(e.req,"May have an XML namespace. We'll assume it's XML but its content-type wasn't XML.\n"),void v.switchHandler("XMLHandler",e,t)):(v.addStatus(e.req,"Plain text document, no known RDF semantics."),void v.doneFetch(e))}}},e.TextHandler.toString=function(){return"TextHandler"},e.TextHandler.register=function(e){e.mediatypes["text/plain"]={q:.5}},e.TextHandler.pattern=new RegExp("text/plain"),e.N3Handler=function(){this.handlerFactory=function(e){e.handle=function(t){var r=o(g,g,e.original.uri,e.original.uri,null,null,"",null) try{r.loadBuf(e.responseText)}catch(t){var n="Error trying to parse "+e.resource+" as Notation3:\n"+t+":\n"+t.stack return void v.failFetch(e,n)}v.addStatus(e.req,"N3 parsed: "+r.statementCount+" triples in "+r.lines+" lines."),v.store.add(e.original,m.rdf("type"),m.link("RDFDocument"),v.appNode),v.doneFetch(e)}}},e.N3Handler.toString=function(){return"N3Handler"},e.N3Handler.register=function(e){e.mediatypes["text/n3"]={q:"1.0"},e.mediatypes["text/turtle"]={q:1}},e.N3Handler.pattern=new RegExp("(application|text)/(x-)?(rdf\\+)?(n3|turtle)"),h.callbackify(this,["request","recv","headers","load","fail","refresh","retract","done"]),this.addHandler=function(e){v.handlers.push(e),e.register(v)},this.switchHandler=function(t,r,i,o){for(var a=null,s=0;s failed: "+t,e) return delete this.fetchCallbacks[e.original.uri],this.fireCallbacks("fail",[e.original.uri,t]),e.abort(),e},this.linkData=function(e,t,r,n,i){if(r){var o,a=g.sym(f.join(r,e.original.uri)) if("alternate"===t||"seeAlso"===t||"meta"===t||"describedby"===t){if(a.uri===e.original.uri)return o=m.rdfs("seeAlso")}else o="type"===t?g.sym("http://www.w3.org/1999/02/22-rdf-syntax-ns#type"):g.sym(f.join(t,"http://www.iana.org/assignments/link-relations/")) i?g.add(a,o,e.original,n):g.add(e.original,o,a,n)}},this.parseLinkHeader=function(e,t){var r try{r=e.getResponseHeader("link")}catch(e){}if(r)for(var n=/<[^>]*>\s*(\s*;\s*[^\(\)<>@,;:"\/\[\]\?={} \t]+=(([^\(\)<>@,;:"\/\[\]\?={} \t]+)|("[^"]*")))*(,|$)/g,i=/[^\(\)<>@,;:"\/\[\]\?={} \t]+=(([^\(\)<>@,;:"\/\[\]\?={} \t]+)|("[^"]*"))/g,o=r.match(n),a=0;a"),u=s[0].substring(1),l=s[1],c=l.match(i),f=0;f=200&&a.status<300 r.noMeta||"undefined"==typeof tabulator||n.saveResponseMetadata(a,n.store),e?i(a):o(a.status+" "+a.statusText)}},a.open(e,t,!0),r.contentType&&a.setRequestHeader("Content-type",r.contentType),a.send(r.data?r.data:void 0)})},this.webCopy=function(e,t,r){var n=this return e=e.uri||e,new Promise(function(i,o){n.webOperation("GET",e).then(function(e){n.webOperation("PUT",t,{data:e.responseText,contentType:r}).then(function(e){i(e)}).catch(function(e){o(e)})}).catch(function(e){o(e)})})},this.lookUpThing=function(e,t,r,n,i){var o,a=g.uris(e),s=!0,u="",l={} if(!1===r||!0===r?(o=r,r={force:o}):(void 0===r&&(r={}),o=!!r.force),void 0!==a)for(var c=0;c0||i&&i(s,u)})}(h)}return a.length},this.load=function(e,t){var r=this if(e instanceof Array){var n=e.map(function(e){return r.load(e)}) return Promise.all(n)}return e=e.uri||e,new Promise(function(n,i){r.nowOrWhenFetched(e,t,function(e,t,r){e?n(r):i(t)})})},this.nowOrWhenFetched=function(e,t,r,n){e=e.uri||e,"function"==typeof t?(n={},r=t):void 0===t||(n=t instanceof a?{referingTerm:t}:t),this.requestURI(e,t,n||{},r)},this.get=this.nowOrWhenFetched,this.getHeader=function(e,t){for(var r=this.store,n=r.each(void 0,m.link("requestedURI"),e.uri),i=0;i Cross-site Proxy to <"+r+">"),e.aborted)return var l=y.store,c=e.req l.add(c,m.http("redirectedTo"),l.sym(r),c) var h=e.req=l.bnode() l.add(c,m.http("redirectedRequest"),h,e.req) var d=new Date,p="["+d.getHours()+":"+d.getMinutes()+":"+d.getSeconds()+"] " l.add(h,m.rdfs("label"),l.literal(p+" Request for "+r),this.appNode),l.add(h,m.link("status"),l.collection(),this.appNode),l.add(h,m.link("requestedURI"),l.literal(r),this.appNode) var v=l.bnode() l.add(c,m.link("response"),v),e.abort(),e.aborted=!0,e.redirected=!0,y.addStatus(c,"redirected XHR"),y.fetchCallbacks[e.resource.uri]&&(y.fetchCallbacks[r]||(y.fetchCallbacks[r]=[]),y.fetchCallbacks[r],y.fetchCallbacks[r].concat(y.fetchCallbacks[e.resource.uri]),delete y.fetchCallbacks[e.resource.uri]),y.fireCallbacks("redirected",u),y.requested[e.resource.uri]="redirected" var g=y.requestURI(r,e.resource,e.options||{},e.userCallback) if(g&&g.req)return void l.add(e.req,l.sym("http://www.w3.org/2007/ont/link#redirectedRequest"),g.req,y.appNode)}}y.failFetch(e,"HTTP Blocked. (ReadyState 0) Cross-site violation for <"+t+">") break case 3:break case 4:if(function(){if(!e.handleResponseDone){e.handleResponseDone=!0 var r=null,i=e.req y.fireCallbacks("recv",u) var o=y.store if(y.saveResponseMetadata(e,o),y.fireCallbacks("headers",[{uri:t,headers:e.headers}]),0===e.status){if(console.log("Masked error - status 0 for "+e.resource.uri),x())return return void(e.CORS_status=900)}if(e.status>=400){if(404===e.status&&(o.fetcher.nonexistant[e.resource.uri]=!0),e.responseText.length>10){var s=o.bnode() o.add(s,m.http("content"),o.literal(e.responseText),s),e.statusText&&o.add(s,m.http("statusText"),o.literal(e.statusText),s)}return void y.failFetch(e,"HTTP error for "+e.resource+": "+e.status+" "+e.statusText)}var l,c=e.headers["content-location"],h=function(e){var t=i for(c&&o.any(t,m.link("requestedURI"))!==c&&o.add(o.sym(c),m.rdf("type"),e,y.appNode);;){var r=o.any(t,m.link("requestedURI")) if(r&&r.value&&o.add(o.sym(r.value),m.rdf("type"),e,y.appNode),!(t=o.any(void 0,o.sym("http://www.w3.org/2007/ont/link#redirectedRequest"),t)))break var n=o.any(t,o.sym("http://www.w3.org/2007/ont/link#response")) if(!n)break var a=o.any(n,o.sym("http://www.w3.org/2007/ont/http#status")) if(!a)break if("301"!==a&&"302"!==a)break}},d={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"} if(200===e.status){h(m.link("Document")) var p=e.headers["content-type"] n.forceContentType&&(e.headers["content-type"]=n.forceContentType),(!p||p.indexOf("application/octet-stream")>=0)&&(l=d[e.resource.uri.split(".").pop()])&&(e.headers["content-type"]=l),p&&(0!==p.indexOf("image/")&&0!==p.indexOf("application/pdf")||h(o.sym("http://purl.org/dc/terms/Image"))),n.clearPreviousData&&o.removeDocument(e.resource)}if("file"!==f.protocol(e.resource.uri)&&"chrome"!==f.protocol(e.resource.uri)||(n.forceContentType?e.headers["content-type"]=n.forceContentType:(l=d[e.resource.uri.split(".").pop()],e.headers["content-type"]=l||"text/xml")),c){var v=f.join(e.resource.uri,c) if(!a&&v!==e.resource.uri&&y.requested[v]&&"done"===y.requested[v])return y.doneFetch(e),void e.abort() y.requested[v]=!0}for(var g=0;g")) var k="https:"===T.slice(0,6) void 0!==n.withCredentials&&(k=n.withCredentials) var N=this.proxyIfNecessary(T) v.onerror=function(t){return function(r){if(t.onErrorWasCalled=!0,"undefined"!=typeof document&&e.crossSiteProxyTemplate&&document.location&&!t.proxyUsed){var n=f.hostpart,i=""+document.location,o=t.resource.uri if(n(i)&&n(o)&&n(i)!==n(o))if(401===t.status||403===t.status||404===t.status)_(t)() else{if(x())return var a=e.crossSiteProxy(o) if(console.log("web: Direct failed so trying proxy "+a),y.addStatus(t.req,"BLOCKED -> Cross-site Proxy to <"+a+">"),t.aborted)return var s=y.store,u=t.req t.options.noMeta||s.add(u,m.http("redirectedTo"),s.sym(a),u),t.abort(),t.aborted=!0,y.addStatus(u,"redirected to new request"),y.requested[t.resource.uri]="redirected",y.redirectedTo[t.resource.uri]=a,y.fetchCallbacks[t.resource.uri]&&(y.fetchCallbacks[a]||(y.fetchCallbacks[a]=[]),y.fetchCallbacks[a],y.fetchCallbacks[a].concat(y.fetchCallbacks[t.resource.uri]),delete y.fetchCallbacks[t.resource.uri]) var l=y.requestURI(a,t.resource,t.options,t.userCallback) if(l&&(l.proxyUsed=!0,l.original=t.original,console.log("Proxying but original still "+l.original)),l&&l.req)return void(t.options.noMeta||s.add(t.req,s.sym("http://www.w3.org/2007/ont/link#redirectedRequest"),l.req,y.appNode))}t.CORS_status=999}}}(v),v.onreadystatechange=_(v),v.timeout=y.timeout,v.withCredentials=k,v.actualProxyURI=N,v.req=g,v.options=n,v.options=n,v.resource=d,v.requestedURI=T,v.ontimeout=function(){y.failFetch(v,"requestTimeout")} try{v.open("GET",N,this.async)}catch(e){return this.failFetch(v,"XHR open for GET failed for <"+T+">:\n\t"+e)}if(a&&v.setRequestHeader("Cache-control","no-cache"),"undefined"!=typeof tabulator&&tabulator.isExtension&&v.channel&&("http"===f.protocol(v.resource.uri)||"https"===f.protocol(v.resource.uri)))try{v.channel.notificationCallbacks={getInterface:function(e){return e.equals(Components.interfaces.nsIChannelEventSink)?{onChannelRedirect:function(e,t,i){if(!v.aborted){var o=y.store,a=t.URI.spec,s=v.req if(!v.options.noMeta){y.addStatus(v.req,"Redirected: "+v.status+" to <"+a+">"),o.add(s,m.http("redirectedTo"),o.sym(a),v.req) var l=v.req=o.bnode() o.add(s,m.http("redirectedRequest"),l,this.appNode) var c=new Date,h="["+c.getHours()+":"+c.getMinutes()+":"+c.getSeconds()+"] " o.add(l,m.rdfs("label"),o.literal(h+" Request for "+a),this.appNode),o.add(l,m.link("status"),o.collection(),this.appNode),o.add(l,m.link("requestedURI"),o.literal(a),this.appNode) var d=o.bnode() o.add(s,m.link("response"),d),o.add(d,m.http("status"),o.literal(v.status),d),v.statusText&&o.add(d,m.http("statusText"),o.literal(v.statusText),d)}if(v.status-0!=303&&(o.HTTPRedirects[v.resource.uri]=a),v.status-0==301&&r){var p=f.docpart(r.uri),g="Warning: "+v.resource+" has moved to <"+a+">." r&&(g+=" Link in <"+p+" >should be changed",o.add(p,o.sym("http://www.w3.org/2007/ont/link#warning"),g,y.appNode))}v.abort(),v.aborted=!0,y.fetchCallbacks[v.resource.uri]&&(y.fetchCallbacks[a]||(y.fetchCallbacks[a]=[]),y.fetchCallbacks[a],y.fetchCallbacks[a].concat(y.fetchCallbacks[v.resource.uri]),delete y.fetchCallbacks[v.resource.uri]),y.addStatus(s,"redirected"),y.fireCallbacks("redirected",u),y.requested[v.resource.uri]="redirected",y.redirectedTo[v.resource.uri]=a var b=a.indexOf("#") b>=0&&(v.options.noMeta||o.add(v.resource,o.sym("http://www.w3.org/2007/ont/link#warning"),"Warning: "+v.resource+" HTTP redirects to"+a+' which should not contain a "#" sign'),a=a.slice(0,b)) var w=y.requestURI(a,v.resource,v.options,v.userCallback) w&&w.req&&!n.noMeta&&o.add(v.req,o.sym("http://www.w3.org/2007/ont/link#redirectedRequest"),w.req,y.appNode)}},asyncOnChannelRedirect:function(e,t,n,i){if(!v.aborted){var o=y.store,a=t.URI.spec,s=v.req y.addStatus(v.req,"Redirected: "+v.status+" to <"+a+">"),o.add(s,m.http("redirectedTo"),o.sym(a),v.req) var u=v.req=o.bnode() o.add(s,m.http("redirectedRequest"),u,v.req) var l=new Date,c="["+l.getHours()+":"+l.getMinutes()+":"+l.getSeconds()+"] " o.add(u,m.rdfs("label"),o.literal(c+" Request for "+a),this.appNode),o.add(u,m.link("status"),o.collection(),this.appNode),o.add(u,m.link("requestedURI"),o.literal(a),this.appNode) var h=o.bnode() if(o.add(s,m.link("response"),h),o.add(h,m.http("status"),o.literal(v.status),h),v.statusText&&o.add(h,m.http("statusText"),o.literal(v.statusText),h),v.status-0!=303&&(o.HTTPRedirects[v.resource.uri]=a),v.status-0==301&&r){var d=f.docpart(r.uri),p="Warning: "+v.resource+" has moved to <"+a+">." r&&(p+=" Link in <"+d+" >should be changed",o.add(d,o.sym("http://www.w3.org/2007/ont/link#warning"),p,y.appNode))}v.abort(),v.aborted=!0 var g=a.indexOf("#") if(g>=0){var b="Warning: "+v.resource+" HTTP redirects to"+a+' which do not normally contain a "#" sign' o.add(v.resource,o.sym("http://www.w3.org/2007/ont/link#warning"),b),a=a.slice(0,g)}y.requested[v.resource.uri]="redirected",y.redirectedTo[v.resource.uri]=a var w=y.requestURI(a,v.resource,v.options,v.userCallback) w&&(w.original=v.original,w.req&&o.add(v.req,o.sym("http://www.w3.org/2007/ont/link#redirectedRequest"),w.req,y.appNode))}}}:Components.results.NS_NOINTERFACE}}}catch(e){return y.failFetch(v,"@@ Couldn't set callback for redirects: "+e)}try{var E="" for(var j in this.mediatypes){""!==E&&(E+=", "),E+=j for(var S in this.mediatypes[j])E+=";"+S+"="+this.mediatypes[j][S]}v.setRequestHeader("Accept",E),this.addStatus(v.req,"Accept: "+E)}catch(e){throw new Error("Can't set Accept header: "+e)}try{v.send(null)}catch(e){return this.failFetch(v,"XHR send failed:"+e)}return setTimeout(function(){4!==v.readyState&&y.isPending(v.resource.uri)&&y.failFetch(v,"requestTimeout")},this.timeout),this.addStatus(v.req,"HTTP Request sent."),v}},this.objectRefresh=function(e){var t=g.uris(e) if(void 0!==t)for(var r=0;r1?n("Patch ambiguous. No patch done."):(u=c[0],void s(n))})}else s(n)}},{key:"declareExistential",value:function(e){return this._existentialVariables||(this._existentialVariables=[]),this._existentialVariables.push(e),e}},{key:"initPropertyActions",value:function(e){this.propertyActions[""]=[u],c(e,"sameAs")>=0&&(this.propertyActions[""]=[function(e,t,r,n,i){return e.equate(t,n),!0}]),c(e,"InverseFunctionalProperty")>=0&&(this.classActions["<"+g+"InverseFunctionalProperty>"]=[function(e,t,r,n,i){return e.newPropertyAction(t,s)}]),c(e,"FunctionalProperty")>=0&&(this.classActions["<"+g+"FunctionalProperty>"]=[function(e,t,r,n,i){return e.newPropertyAction(t,a)}])}},{key:"add",value:function(e,t,n,i){var o if(1===arguments.length){if(e instanceof Array)for(o=0;o" 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 r=e.hashString() this.propertyActions[r]||(this.propertyActions[r]=[]),this.propertyActions[r].push(t) for(var n=this.statementsMatching(void 0,e,void 0),i=!1,o=0;o1&&(a=a.slice(0,1)),a=a||[] var h,d,v=1e10 for(d=0;d=0?f.float:(""+e).indexOf(".")>=0?f.decimal:f.integer,new t(""+e,null,r)}},{key:"fromValue",value:function(e){if(void 0===e||null===e)return e if(e&&e.termType)return e switch(void 0===e?"undefined":a(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 "+(void 0===e?"undefined":a(e)))}}]),t}(c) h.termType="Literal",h.prototype.classOrder=u.Literal,h.prototype.datatype=f.string,h.prototype.lang="",h.prototype.isVar=0,t.exports=h},{"./class-order":44,"./named-node":57,"./node":59,"./xsd":75}],55:[function(e,t,r){"use strict" t.exports={debug:function(e){},warn:function(e){},info:function(e){},error:function(e){},success:function(e){},msg:function(e){}}},{}],56:[function(e,t,r){"use strict" var n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol?"symbol":typeof e},i=e("./uri"),o=e("./util").ArrayIndexOf,a=function(){function e(e){return encodeURI(e)}function t(e,t,n,i,o,a,s,u){return new r(e,t,n,i,o,a,s,u)}function r(e,t,r,n,i,o,a,s){void 0===t&&(t=null),void 0===r&&(r=""),void 0===n&&(n=null),void 0===i&&(i=""),void 0===o&&(o=null),void 0===a&&(a=""),void 0===s&&(s=null),this._bindings=new h([]),this._flags=a,""!=r&&(y(r.indexOf(":")>=0,"Document URI not absolute: "+r),this._bindings[""]=r+"#"),this._store=e,i&&e.setGenPrefix(i),this._thisDoc=r,this.source=e.sym(r),this.lines=0,this.statementCount=0,this.startOfLine=0,this.previousLine=0,this._genPrefix=i,this.keywords=new f(["a","this","bind","has","is","of","true","false"]),this.keywordsSet=0,this._anonymousNodes=new h([]),this._variables=new h([]),this._parentVariables=new h([]),this._reason=s,this._reason2=null,x&&(this._reason2=why_BecauseOfData(e.sym(r),this._reason)),this._baseURI=n||(r||null),y(!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(r+"#_formula"):this._formula=e.formula():this._formula=t,this._context=this._formula,this._parentContext=null}function a(e,t,r,n,i){this._str=r.encode("utf-8"),this._str=r,this._i=n,this._why=i,this.lines=t,this._uri=e}function s(e,t,r,n,i){return"Line "+(t+1)+" of <"+e+">: Bad syntax: "+i+'\nat: "'+p(r,n,n+30)+'"'}var u={encode:function(e){e=e.replace(/\r\n/g,"\n") for(var t="",r=0;r127&&n<2048?(t+=String.fromCharCode(n>>6|192),t+=String.fromCharCode(63&n|128)):(t+=String.fromCharCode(n>>12|224),t+=String.fromCharCode(n>>6&63|128),t+=String.fromCharCode(63&n|128))}return t},decode:function(e){for(var t="",r=0;r191&&n<224?(t+=String.fromCharCode((31&n)<<6|63&e.charCodeAt(r+1)),r+=2):(t+=String.fromCharCode((15&n)<<12|(63&e.charCodeAt(r+1))<<6|63&e.charCodeAt(r+2)),r+=3)}return t}},l="http://www.w3.org/2000/10/swap/log#",c=function(e){return e},f=function(e){return e},h=function(e){if(e.length>0)throw"missing.js: oops nnonempty dict not imp" return[]},d=function(e){return e.length},p=function(e,t,r){if(void 0===e.slice)throw"@@ mising.js: No .slice function for "+e+" of type "+(void 0===e?"undefined":n(e)) return void 0===r||null==r?e.slice(t):e.slice(t,r)},v=Error("dummy error stop iteration"),g=function(e){return this.last=0,this.li=e,this.next=function(){if(this.last==this.li.length)throw v return this.li[this.last++]},this},m=function(e,t){return e.indexOf(t)},y=function(e,t){if(!e){if(t)throw"python Assertion failed: "+t throw"(python) Assertion failed."}},b=function(e){return String.fromCharCode(e)} String.prototype.encode=function(e){if("utf-8"!=e)throw"UTF8_converter: can only do utf-8" return u.encode(this)},String.prototype.decode=function(e){if("utf-8"!=e)throw"UTF8_converter: can only do utf-8" return this} var w=function(e,t){return i.join(t,e)},x=0,_="\t\r\n !\"#$%&'()*.,+/;<=>?@[\\]^`{|}~",T=_+":",k=(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")),N=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?"),E=(new RegExp("^[0-9]+","g"),new RegExp('[\\\\\\r\\n\\"]',"g")),j=new RegExp("^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)?","g") return r.prototype.here=function(e){return this._genPrefix+"_L"+this.lines+"C"+(e-this.startOfLine+1)},r.prototype.formula=function(){return this._formula},r.prototype.loadStream=function(e){return this.loadBuf(e.read())},r.prototype.loadBuf=function(e){return this.startDoc(),this.feed(e),this.endDoc()},r.prototype.feed=function(e){for(var t=e.decode("utf-8"),r=0;r>=0;){var n=this.skipSpace(t,r) if(n<0)return var r=this.directiveOrStatement(t,n) if(r<0)throw s(this._thisDoc,this.lines,t,n,"expected directive or statement")}},r.prototype.directiveOrStatement=function(e,t){var r=this.skipSpace(e,t) if(r<0)return r var n=this.directive(e,r) if(n>=0)return this.checkDot(e,n) var n=this.statement(e,r) return n>=0?this.checkDot(e,n):n},r.prototype.tok=function(e,t,r){if("@"==p(t,r,r+1))var r=r+1 else if(o(this.keywords,e)<0)return-1 var n=r+d(e) return p(t,r,n)==e&&_.indexOf(t.charAt(n))>=0?n:-1},r.prototype.directive=function(t,r){var n=this.skipSpace(t,r) if(n<0)return n var i=new f([]),n=this.tok("bind",t,r) if(n>0)throw s(this._thisDoc,this.lines,t,r,"keyword bind is obsolete: use @prefix") var n=this.tok("keywords",t,r) if(n>0){var r=this.commaSeparatedList(t,n,i,!1) if(r<0)throw s(this._thisDoc,this.lines,t,r,"'@keywords' needs comma separated list of words") return this.setKeywords(p(i,null,null)),r}var n=this.tok("forAll",t,r) if(n>0){var r=this.commaSeparatedList(t,n,i,!0) if(r<0)throw s(this._thisDoc,this.lines,t,r,"Bad variable list after @forAll") var a=new g(i) try{for(;;){var u=a.next();(o(this._variables,u)<0||o(this._parentVariables,u)>=0)&&(this._variables[u]=this._context.newUniversal(u))}}catch(e){if(e!=v)throw e}return r}var n=this.tok("forSome",t,r) if(n>0){var r=this.commaSeparatedList(t,n,i,this.uri_ref2) if(r<0)throw s(this._thisDoc,this.lines,t,r,"Bad variable list after @forSome") var a=new g(i) try{for(;;){var u=a.next() this._context.declareExistential(u)}}catch(e){if(e!=v)throw e}return r}var n=this.tok("prefix",t,r) if(n>=0){var l=new f([]),r=this.qname(t,n,l) if(r<0)throw s(this._thisDoc,this.lines,t,n,"expected qname after @prefix") var n=this.uri_ref2(t,r,l) if(n<0)throw s(this._thisDoc,this.lines,t,r,"expected after @prefix _qname_") var c=l[1].uri if(this._baseURI)var c=w(this._baseURI,c) else y(c.indexOf(":")>=0,"With no base URI, cannot handle relative URI for NS") return y(c.indexOf(":")>=0),this._bindings[l[0][0]]=c,this.bind(l[0][0],e(c)),n}var n=this.tok("base",t,r) if(n>=0){var l=new f([]),r=this.uri_ref2(t,n,l) if(r<0)throw s(this._thisDoc,this.lines,t,n,"expected after @base ") var c=l[0].uri if(!this._baseURI)throw s(this._thisDoc,this.lines,t,n,"With no previous base URI, cannot use relative URI in @base <"+c+">") var c=w(this._baseURI,c) return y(c.indexOf(":")>=0),this._baseURI=c,r}return-1},r.prototype.bind=function(e,t){""==e||this._store.setPrefixForURI(e,t)},r.prototype.setKeywords=function(e){null==e?this.keywordsSet=0:(this.keywords=e,this.keywordsSet=1)},r.prototype.startDoc=function(){},r.prototype.endDoc=function(){return this._formula},r.prototype.makeStatement=function(e){e[0].add(e[2],e[1],e[3],this.source),this.statementCount+=1},r.prototype.statement=function(e,t){var r=new f([]),t=this.object(e,t,r) if(t<0)return t var n=this.property_list(e,t,r[0]) if(n<0)throw s(this._thisDoc,this.lines,e,t,"expected propertylist") return n},r.prototype.subject=function(e,t,r){return this.item(e,t,r)},r.prototype.verb=function(e,t,r){var n=this.skipSpace(e,t) if(n<0)return n var i=new f([]),n=this.tok("has",e,t) if(n>=0){var t=this.prop(e,n,i) if(t<0)throw s(this._thisDoc,this.lines,e,n,"expected property after 'has'") return r.push(new c(["->",i[0]])),t}var n=this.tok("is",e,t) if(n>=0){var t=this.prop(e,n,i) if(t<0)throw s(this._thisDoc,this.lines,e,n,"expected after 'is'") var n=this.skipSpace(e,t) if(n<0)throw s(this._thisDoc,this.lines,e,t,"End of file found, expected property after 'is'") var t=n,n=this.tok("of",e,t) if(n<0)throw s(this._thisDoc,this.lines,e,t,"expected 'of' after 'is' ") return r.push(new c(["<-",i[0]])),n}var n=this.tok("a",e,t) if(n>=0)return r.push(new c(["->",this._store.sym("http://www.w3.org/1999/02/22-rdf-syntax-ns#type")])),n if("<="==p(e,t,t+2))return r.push(new c(["<-",this._store.sym(l+"implies")])),t+2 if("="==p(e,t,t+1))return">"==p(e,t+1,t+2)?(r.push(new c(["->",this._store.sym(l+"implies")])),t+2):(r.push(new c(["->",this._store.sym("http://www.w3.org/2002/07/owl#sameAs")])),t+1) if(":="==p(e,t,t+2))return r.push(new c(["->",l+"becomes"])),t+2 var n=this.prop(e,t,i) if(n>=0)return r.push(new c(["->",i[0]])),n if(">-"==p(e,t,t+2)||"<-"==p(e,t,t+2))throw s(this._thisDoc,this.lines,e,n,">- ... -> syntax is obsolete.") return-1},r.prototype.prop=function(e,t,r){return this.item(e,t,r)},r.prototype.item=function(e,t,r){return this.path(e,t,r)},r.prototype.blankNode=function(e){return this._context.bnode(e,this._reason2)},r.prototype.path=function(e,t,r){var n=this.nodeOrLiteral(e,t,r) if(n<0)return n for(;"!^.".indexOf(p(e,n,n+1))>=0;){var i=p(e,n,n+1) if("."==i){var o=p(e,n+1,n+2) if(!o||T.indexOf(o)>=0&&":?<[{(".indexOf(o)<0)break}var a=r.pop(),u=this.blankNode(this.here(n)),n=this.node(e,n+1,r) if(n<0)throw s(this._thisDoc,this.lines,e,n,"EOF found in middle of path syntax") var l=r.pop() "^"==i?this.makeStatement(new c([this._context,l,u,a])):this.makeStatement(new c([this._context,l,a,u])),r.push(u)}return n},r.prototype.anonymousNode=function(e){var t=this._anonymousNodes[e] if(t)return t var t=this._store.bnode(this._context,this._reason2) return this._anonymousNodes[e]=t,t},r.prototype.node=function(e,t,r,n){void 0===n&&(n=null) var i=n,o=this.skipSpace(e,t) if(o<0)return o var t=o,a=p(e,t,t+1) if("["==a){var u=this.here(t),o=this.skipSpace(e,t+1) if(o<0)throw s(this._thisDoc,this.lines,e,t,"EOF after '['") if("="==p(e,o,o+1)){var t=o+1,l=new f([]),o=this.objectList(e,t,l) if(!(o>=0))throw s(this._thisDoc,this.lines,e,t,"objectList expected after [= ") var i=l[0] if(d(l)>1){var m=new g(l) try{for(;;){var y=m.next() this.makeStatement(new c([this._context,this._store.sym("http://www.w3.org/2002/07/owl#sameAs"),i,y]))}}catch(e){if(e!=v)throw e}}var o=this.skipSpace(e,o) if(o<0)throw s(this._thisDoc,this.lines,e,t,"EOF when objectList expected after [ = ") if(";"==p(e,o,o+1))var o=o+1}if(null==i)var i=this.blankNode(u) var t=this.property_list(e,o,i) if(t<0)throw s(this._thisDoc,this.lines,e,o,"property_list expected") var o=this.skipSpace(e,t) if(o<0)throw s(this._thisDoc,this.lines,e,t,"EOF when ']' expected after [ ") if("]"!=p(e,o,o+1))throw s(this._thisDoc,this.lines,e,o,"']' expected") return r.push(i),o+1}if("{"==a){var b=p(e,t+1,t+2) if("$"==b){t+=1 for(var o=t+1,w=new f([]),x=!0;;){var t=this.skipSpace(e,o) if(t<0)throw s(this._thisDoc,this.lines,e,t,"needed '$}', found end.") if("$}"==p(e,t,t+2)){var o=t+2 break}if(x)var x=!1 else{if(","!=p(e,t,t+1))throw s(this._thisDoc,this.lines,e,t,"expected: ','") t+=1}var _=new f([]),o=this.item(e,t,_) if(o<0)throw s(this._thisDoc,this.lines,e,t,"expected item in set or '$}'") w.push(_[0])}return r.push(this._store.newSet(w,this._context)),o}var o=t+1,T=this._parentContext this._parentContext=this._context var k=this._anonymousNodes,N=this._parentVariables this._parentVariables=this._variables,this._anonymousNodes=new h([]),this._variables=this._variables.slice() var E=this._reason2 if(this._reason2=null,null==i)var i=this._store.formula() for(this._context=i;;){var t=this.skipSpace(e,o) if(t<0)throw s(this._thisDoc,this.lines,e,t,"needed '}', found end.") if("}"==p(e,t,t+1)){var o=t+1 break}var o=this.directiveOrStatement(e,t) if(o<0)throw s(this._thisDoc,this.lines,e,t,"expected statement or '}'")}return this._anonymousNodes=k,this._variables=this._parentVariables,this._parentVariables=N,this._context=this._parentContext,this._reason2=E,this._parentContext=T,r.push(i.close()),o}if("("==a){var j=this._store.list,b=p(e,t+1,t+2) if("$"==b){var j=this._store.newSet t+=1}for(var o=t+1,w=new f([]);;){var t=this.skipSpace(e,o) if(t<0)throw s(this._thisDoc,this.lines,e,t,"needed ')', found end.") if(")"==p(e,t,t+1)){var o=t+1 break}var _=new f([]),o=this.item(e,t,_) if(o<0)throw s(this._thisDoc,this.lines,e,t,"expected item in list or ')'") w.push(_[0])}return r.push(j(w,this._context)),o}var o=this.tok("this",e,t) if(o>=0)throw s(this._thisDoc,this.lines,e,t,"Keyword 'this' was ancient N3. Now use @forSome and @forAll keywords.") var o=this.tok("true",e,t) if(o>=0)return r.push(!0),o var o=this.tok("false",e,t) if(o>=0)return r.push(!1),o if(null==i){var o=this.uri_ref2(e,t,r) if(o>=0)return o}return-1},r.prototype.property_list=function(e,t,r){for(;;){var n=this.skipSpace(e,t) if(n<0)throw s(this._thisDoc,this.lines,e,t,"EOF found when expected verb in property list") if(":-"!=p(e,n,n+2)){var t=n,i=new f([]),n=this.verb(e,t,i) if(n<=0)return t var o=new f([]),t=this.objectList(e,n,o) if(t<0)throw s(this._thisDoc,this.lines,e,n,"objectList expected") var a=new g(o) try{for(;;){var u=a.next(),l=i[0],h=l[0],d=l[1] "->"==h?this.makeStatement(new c([this._context,d,r,u])):this.makeStatement(new c([this._context,d,u,r]))}}catch(e){if(e!=v)throw e}var n=this.skipSpace(e,t) if(n<0)throw s(this._thisDoc,this.lines,e,n,"EOF found in list of objects") if(";"!=p(e,t,t+1))return t var t=t+1}else{var t=n+2,m=new f([]),n=this.node(e,t,m,r) if(n<0)throw s(this._thisDoc,this.lines,e,t,"bad {} or () or [] node after :- ") var t=n}}},r.prototype.commaSeparatedList=function(e,t,r,n){var i=this.skipSpace(e,t) if(i<0)throw s(this._thisDoc,this.lines,e,i,"EOF found expecting comma sep list") if("."==e.charAt(i))return t if(n)var i=this.uri_ref2(e,i,r) else var i=this.bareWord(e,i,r) if(i<0)return-1 for(;;){var t=this.skipSpace(e,i) if(t<0)return t var o=p(e,t,t+1) if(","!=o)return"."!=o?-1:t if(n)var i=this.uri_ref2(e,t+1,r) else var i=this.bareWord(e,t+1,r) if(i<0)throw s(this._thisDoc,this.lines,e,i,"bad list content")}},r.prototype.objectList=function(e,t,r){var t=this.object(e,t,r) if(t<0)return-1 for(;;){var n=this.skipSpace(e,t) if(n<0)throw s(this._thisDoc,this.lines,e,n,"EOF found after object") if(","!=p(e,n,n+1))return n var t=this.object(e,n+1,r) if(t<0)return t}},r.prototype.checkDot=function(e,t){var r=this.skipSpace(e,t) if(r<0)return r if("."==p(e,r,r+1))return r+1 if("}"==p(e,r,r+1))return r if("]"==p(e,r,r+1))return r throw s(this._thisDoc,this.lines,e,r,"expected '.' or '}' or ']' at end of statement")},r.prototype.uri_ref2=function(e,t,r){var n=new f([]),i=this.qname(e,t,n) if(i>=0){var a=n[0],u=a[0],l=a[1] if(null==u){y(0,"not used?") var c=this._baseURI+"#"}else{var c=this._bindings[u] if(!c){if("_"==u)return r.push(this.anonymousNode(l)),i throw s(this._thisDoc,this.lines,e,t,"Prefix "+u+" not bound.")}}var h=this._store.sym(c+l) return o(this._variables,h)>=0?r.push(this._variables[h]):r.push(h),i}var t=this.skipSpace(e,t) if(t<0)return-1 if("?"==e.charAt(t)){var v=new f([]),i=this.variable(e,t,v) return i>0?(r.push(v[0]),i):-1}if("<"==e.charAt(t)){for(var t=t+1,g=t;t"==e.charAt(t)){var m=p(e,g,t) if(this._baseURI)var m=w(this._baseURI,m) else y(m.indexOf(":")>=0,"With no base URI, cannot deal with relative URIs") if("#"==p(e,t-1,t)&&"#"!=p(m,-1,null))var m=m+"#" var h=this._store.sym(m) return o(this._variables,h)>=0?r.push(this._variables[h]):r.push(h),t+1}var t=t+1}throw s(this._thisDoc,this.lines,e,i,"unterminated URI reference")}if(this.keywordsSet){var v=new f([]),i=this.bareWord(e,t,v) if(i<0)return-1 if(o(this.keywords,v[0])>=0)throw s(this._thisDoc,this.lines,e,t,'Keyword "'+v[0]+'" not allowed here.') return r.push(this._store.sym(this._bindings[""]+v[0])),i}return-1},r.prototype.skipSpace=function(e,t){for(var r=" \n\r\t\f\v            ​\u2028\u2029 ",n=t||0;n=0)throw s(this._thisDoc,this.lines,e,n,"Varible name can't start with '"+e.charAt(n)+"s'") for(;t=0)return-1 if(T.indexOf(i)>=0)return-1 for(var t=n;t=0)return-1 if(T.indexOf(n)<0)for(var i=n,t=t+1;t=0)return n var n=this.skipSpace(e,t) if(n<0)return-1 var t=n if('"'==e.charAt(t)){if('"""'==p(e,t,t+3))var i='"""' else var i='"' var t=t+d(i),o=this.strconst(e,t,i),n=o[0],a=o[1] return r.push(this._store.literal(a)),n}return-1},r.prototype.nodeOrLiteral=function(e,t,r){var n=this.node(e,t,r) if(n>=0)return n var n=this.skipSpace(e,t) if(n<0)return-1 var t=n if("-+0987654321".indexOf(e.charAt(t))>=0){N.lastIndex=0 var i=N.exec(e.slice(t)) if(null!=i){var o=i[0] n=t+o.length,o.indexOf("T")>=0?r.push(this._store.literal(o,void 0,this._store.sym("http://www.w3.org/2001/XMLSchema#dateTime"))):r.push(this._store.literal(o,void 0,this._store.sym("http://www.w3.org/2001/XMLSchema#date")))}else{k.lastIndex=0 var i=k.exec(e.slice(t)) if(null==i)throw s(this._thisDoc,this.lines,e,t,"Bad number or date syntax") n=t+k.lastIndex var o=p(e,t,n) o.indexOf("e")>=0?r.push(this._store.literal(parseFloat(o),void 0,this._store.sym("http://www.w3.org/2001/XMLSchema#double"))):p(e,t,n).indexOf(".")>=0?r.push(this._store.literal(parseFloat(o),void 0,this._store.sym("http://www.w3.org/2001/XMLSchema#decimal"))):r.push(this._store.literal(parseInt(o),void 0,this._store.sym("http://www.w3.org/2001/XMLSchema#integer")))}return n}if('"'==e.charAt(t)){if('"""'==p(e,t,t+3))var a='"""' else var a='"' var t=t+d(a),u=null,l=this.strconst(e,t,a),n=l[0],c=l[1],h=null if("@"==p(e,n,n+1)){j.lastIndex=0 var i=j.exec(e.slice(n+1)) if(null==i)throw s(this._thisDoc,startline,e,t,"Bad language code syntax on string literal, after @") var t=j.lastIndex+n+1,h=p(e,n+1,t),n=t}if("^^"==p(e,n,n+2))var v=new f([]),n=this.uri_ref2(e,n+2,v),u=v[0] return r.push(this._store.literal(c,h,u)),n}return-1},r.prototype.strconst=function(e,t,r){for(var n=t,i="",o=this.lines;n=0)var l='a\b\f\r\t\v\n\\"'.charAt(u),i=i+l,n=n+1 else if("u"==a)var f=this.uEscape(e,n+1,o),n=f[0],a=f[1],i=i+a else{if("U"!=a)throw s(this._thisDoc,this.lines,e,t,"bad escape") var f=this.UEscape(e,n+1,o),n=f[0],a=f[1],i=i+a}}}else var n=t+1 else var n=t}else var i=i+'"',n=n+1}throw s(this._thisDoc,this.lines,e,t,"unterminated string literal")},r.prototype.uEscape=function(e,t,r){for(var n=t,i=0,o=0;i<4;){var a=p(e,n,n+1),u=a.toLowerCase(),n=n+1 if(""==u)throw s(this._thisDoc,r,e,t,"unterminated string literal(3)") var l=m("0123456789abcdef",u) if(l<0)throw s(this._thisDoc,r,e,t,"bad string literal hex escape") var o=16*o+l,i=i+1}var f=String.fromCharCode(o) return new c([n,f])},r.prototype.UEscape=function(e,t,r){for(var n=t,i=0,o="\\U";i<8;){var a=p(e,n,n+1),u=a.toLowerCase(),n=n+1 if(""==u)throw s(this._thisDoc,r,e,t,"unterminated string literal(3)") if(m("0123456789abcdef",u)<0)throw s(this._thisDoc,r,e,t,"bad string literal hex escape") var o=o+u,i=i+1}var l=b("0x"+p(o,2,10)-0) return new c([n,l])},a.prototype.toString=function(){var e=this._str,t=this._i,r=0 if(t>60)var n="...",r=t-60 else var n="" if(d(e)-t>60)var i="..." else var i="" return'Line %i of <%s>: Bad syntax (%s) at ^ in:\n"%s%s^%s%s"'%new c([this.lines+1,this._uri,this._why,n,p(e,r,t),p(e,t,t+60),i])},t}() t.exports=a},{"./uri":72,"./util":73}],57:[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"!=typeof 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 "+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)}var a=function(){function e(e,t){for(var r=0;r=0&&r"}},{key:"uri",get:function(){return this.value},set:function(e){this.value=e}}],[{key:"fromValue",value:function(e){return void 0===e||null===e?e:e&&e.termType?e:new t(e)}}]),t}(u) l.termType="NamedNode",l.prototype.classOrder=s.NamedNode,l.prototype.isVar=0,t.exports=l},{"./class-order":44,"./node":59}],58:[function(e,t,r){"use strict" function n(e){return function(t){return new i(e+(t||""))}}var i=e("./named-node") t.exports=n},{"./named-node":57}],59:[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;re.classOrder?1:this.valuee.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}() t.exports=o,o.fromValue=function(t){var r=e("./collection"),n=e("./literal") e("./named-node") return void 0===t||null===t?t:t&&t.termType?t:Array.isArray(t)?new r(t):n.fromValue(t)}},{"./collection":45,"./literal":54,"./named-node":57}],60:[function(e,t,r){"use strict" function n(e,t,r,n,p){function v(){p&&p(null,t)}function g(e,r){e&&p(e,t) try{x.parse(r,m)}catch(e){p(e,t)}}function m(e,r,n){if(e&&p(e,t),r)_.push(r) else{for(var i=0;i<_.length;i++)y(t,_[i]) p(null,t)}}function y(e,t){var r=b(t.subject),n=b(t.predicate),i=b(t.object),o=null t.graph&&(o=b(t.graph)),e.add(r,n,i,o)}function b(e){var t if(s.Util.isLiteral(e)){t=s.Util.getLiteralValue(e) var r=s.Util.getLiteralLanguage(e),n=new l(s.Util.getLiteralType(e)) return new a(t,r,n)}return s.Util.isIRI(e)?new l(e):s.Util.isBlank(e)?(t=e.substring(2,e.length),new i(t)):null}try{if("text/n3"===n||"text/turtle"===n){u(t,t,r,r,null,null,"",null).loadBuf(e),v()}else if("application/rdf+xml"===n){var w=new f(t) w.parse(d.parseXML(e),r,t.sym(r)),v()}else if("application/xhtml+xml"===n)c(d.parseXML(e,{contentType:"application/xhtml+xml"}),t,r),v() else if("text/html"===n)c(d.parseXML(e,{contentType:"text/html"}),t,r),v() else if("application/sparql-update"===n)h(e,t,r),v() else{if("application/ld+json"!==n&&"application/nquads"!==n&&"application/n-quads"!==n)throw new Error("Don't know how to parse "+n+" yet") var x=s.Parser(),_=[] if("application/ld+json"===n){var T try{T=JSON.parse(e)}catch(e){p(e,null)}o.toRDF(T,{format:"application/nquads"},g)}else g(null,e)}}catch(e){!function(e){if("application/ld+json"!==n||"application/nquads"!==n||"application/n-quads"!==n){if(!p)throw new Error("Error trying to parse <"+r+"> as "+n+":\n"+e+":\n"+e.stack) p(e,t)}}(e)}}t.exports=n var i=e("./blank-node"),o=e("jsonld"),a=e("./literal"),s=e("n3"),u=e("./n3parser"),l=e("./named-node"),c=e("./rdfaparser").parseRDFaDOM,f=e("./rdfxmlparser"),h=e("./patch-parser"),d=e("./util")},{"./blank-node":43,"./literal":54,"./n3parser":56,"./named-node":57,"./patch-parser":61,"./rdfaparser":64,"./rdfxmlparser":65,"./util":73,jsonld:30,n3:32}],61:[function(e,t,r){"use strict" function n(e,t,r){var n,a,s,u=["INSERT","DELETE","WHERE"],l=o("http://www.w3.org/ns/pim/patch#"),c=i(t,t,r,r,null,null,"",null),f={},h=function(e,t,r,n,i){return"Line "+(t+1)+" of <"+e+">: Bad syntax:\n "+i+'\n at: "'+r.slice(n,n+30)+'"'} n=0 var d=t.sym(r+"#query") for(f.query=d;;){if((a=c.skipSpace(e,n))<0)return f if(";"===e[a]){if((n=c.skipSpace(e,a+1))<0)return f a=n}var p=!1 for(s=0;s "+e[t]) return r},u=function(e){var t,r="Bindings: ",n=e.length for(t=0;to.length)&&(t.index=o)}return null===t.index&&(t.index=e.statements),!0},m=0,y=function e(r,n,i,u,l,c,f){a.debug("Match begins, Branch count now: "+f.count+" for "+f.pattern_debug) var h=r.fetcher?r.fetcher:null,p=n.statements if(0===p.length){if(a.debug("FOUND MATCH WITH BINDINGS:"+o(i)),0===n.optional.length)f.reportMatch(i) else{a.debug("OPTIONAL: "+n.optional) var g,y=new d(t,i),b=[] for(g=0;g in query: "+a),e(r,n,i,u,l,c,f)})}) for(_=0;_=0){var a=t.substring(0,o) if(""===a)return i=r[""],i?i+t.substring(o+1):null if("_"===a)return"_:"+t.substring(o+1) if(e.NCNAME.test(a)&&(i=r[a]))return i+t.substring(o+1)}return null}},{key:"parseCURIEOrURI",value:function(e,t,r){var n=this.parseCURIE(e,t,r) return n||this.resolveAndNormalize(r,e)}},{key:"parsePredicate",value:function(e,t,r,n,i,o){if(""===e)return null var a=this.parseTermOrCURIEOrAbsURI(e,t,o?null:r,n,i) return a&&0===a.indexOf("_:")?null:a}},{key:"parsePrefixMappings",value:function(e,t){for(var r=this.tokenize(e),n=null,i=0;i=0&&(e=e.substring(0,t)),r&&r.baseURIMap&&(e=r.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 u=a.listMapping[s] if(0!==u.length){for(var c=[],h=0;h0){E=S var I=n.spec this.addTriple(p,I,"http://www.w3.org/ns/rdfa#usesVocabulary",{type:e.objectURI,value:E})}else E=this.vocabulary}for(var R=0;R0?U:null}var P,q,F=p.getAttributeNode("rel"),B=p.getAttributeNode("rev"),H=p.getAttributeNode("typeof"),z=p.getAttributeNode("property"),X=p.getAttributeNode("datatype"),V=this.inHTMLMode?p.getAttributeNode("datetime"):null,W=p.getAttributeNode("content"),J=p.getAttributeNode("about"),$=p.getAttributeNode("src"),Y=p.getAttributeNode("resource"),Q=p.getAttributeNode("href"),G=p.getAttributeNode("inlist"),Z=[] if(F){q=this.tokenize(F.value) for(var K=0;K=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),e.parent.element=null),e.parent&&e.parent.nodeType&&e.parent.nodeType!==e.ARC){e.addArc(i(a)),this.reify&&(r=this.getAttributeNodeNS(a,t.ns.RDF,"ID"))&&(e.rdfid=r.nodeValue,a.removeAttributeNode(r)) var u=this.getAttributeNodeNS(a,t.ns.RDF,"parseType"),l=this.getAttributeNodeNS(a,t.ns.RDF,"datatype") if(l&&(e.datatype=l.nodeValue,a.removeAttributeNode(l)),u){var c=u.nodeValue "Literal"===c?(e.datatype=t.ns.RDF+"XMLLiteral",e=this.buildFrame(e),e.addLiteral(a),o=!1):"Resource"===c?(e=this.buildFrame(e,e.element),e.parent.element=null,e.addBNode()):"Collection"===c&&(e=this.buildFrame(e,e.element),e.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 d=s.length-1;d>=0;d--){var p=this.buildFrame(e) p.addArc(i(s[d])),i(s[d])===t.ns.RDF+"type"?this.buildFrame(p).addNode(s[d].nodeValue):this.buildFrame(p).addLiteral(s[d].nodeValue)}}else 0===a.childNodes.length&&this.buildFrame(e).addLiteral("")}else{var v=this.getAttributeNodeNS(a,t.ns.RDF,"about") if(r=this.getAttributeNodeNS(a,t.ns.RDF,"ID"),v&&r)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(!v&&r)e.addNode("#"+r.nodeValue),a.removeAttributeNode(r) else if(null==v&&null==r){var g=this.getAttributeNodeNS(a,t.ns.RDF,"nodeID") g?(e.addBNode(g.nodeValue),a.removeAttributeNode(g)):e.addBNode()}else e.addNode(v.nodeValue),a.removeAttributeNode(v) var m=this.getAttributeNodeNS(a,t.ns.RDF,"type") t.ns.RDF+"Description"!==i(a)&&(m={nodeValue:i(a)}),null!=m&&(this.store.add(e.node,this.store.sym(t.ns.RDF+"type"),this.store.sym(n.join(m.nodeValue,e.base)),this.why),m.nodeName&&a.removeAttributeNode(m)) for(var y=s.length-1;y>=0;y--)this.store.add(e.node,this.store.sym(i(s[y])),this.store.literal(s[y].nodeValue,e.lang),this.why)}for(a=e.element;e.parent;){for(var b=e;null==a;)e=e.parent,a=e.element var w=a.childNodes&&a.childNodes[e.lastChild] if(w&&o){if((w.nodeType===t.nodeType.ELEMENT||w.nodeType===t.nodeType.TEXT||w.nodeType===t.nodeType.CDATA_SECTION)&&(w.nodeType!==t.nodeType.TEXT&&w.nodeType!==t.nodeType.CDATA_SECTION||1===a.childNodes.length)){e.lastChild++,e=this.buildFrame(b,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,r){var i=this.frameFactory(this,e,r) if(e&&(i.base=e.base,i.lang=e.lang),!r||r.nodeType===t.nodeType.TEXT||r.nodeType===t.nodeType.CDATA_SECTION)return i var o=r.attributes,a=r.getAttributeNode("xml:base") null!=a&&(i.base=a.nodeValue,r.removeAttribute("xml:base")) var s=r.getAttributeNode("xml:lang") null!=s&&(i.lang=s.nodeValue,r.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 l=o[u].nodeValue this.base&&(l=n.join(l,this.base)),this.store.setPrefixForURI(o[u].name.slice(6),l)}r.removeAttributeNode(o[u])}return i}} t.exports=i},{"./uri":72}],66:[function(e,t,r){"use strict" function n(e,t,r,n,a){function s(e,t){return a?void a(e,t):t}var u=null try{var l,c=o(t),f=t.statementsMatching(void 0,void 0,void 0,e) switch(c.suggestNamespaces(t.namespaces),c.setBase(r),n){case"application/rdf+xml":return u=c.statementsToXML(f),s(null,u) case"text/n3":case"application/n3":return u=c.statementsToN3(f),s(null,u) case"text/turtle":case"application/x-turtle":return c.setFlags("si"),u=c.statementsToN3(f),s(null,u) case"application/ld+json":l=c.statementsToN3(f),i.convertToJson(l,a) break case"application/n-quads":case"application/nquads":l=c.statementsToN3(f),u=i.convertToNQuads(l,a) break default:throw new Error("Serialize: Content-type "+n+" not supported for data write.")}}catch(e){if(a)return a(e) throw e}}t.exports=n var i=e("./convert"),o=e("./serializer")},{"./convert":46,"./serializer":67}],67:[function(e,t,r){"use strict" var n=e("./named-node"),i=e("./uri"),o=e("./util"),a=e("./xsd"),s=function(){function e(e){return encodeURI(e)}function t(e){for(var t,r="",n=0;n65535?"\\U"+("00000000"+t.toString(16)).slice(-8):t>126?"\\u"+("0000"+t.toString(16)).slice(-4):e[n] return r}var r=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} return r.prototype.setBase=function(e){this.base=e},r.prototype.setFlags=function(e){this.flags=e||""},r.prototype.toStr=function(e){var t=e.toNT() return"formula"==e.termType&&(this.formulas[t]=e),t},r.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)},r.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))},r.prototype.suggestNamespaces=function(e){for(var t in e)this.suggestPrefix(t,e[t])},r.prototype.checkIntegrity=function(){var e,t for(e in this.namespaces)if(this.prefixes[this.namespaces[e]]!==e)throw"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"Serializer integity error 2: "+t+", "+this.prefixs[t]+", "+this.namespaces[this.prefixes[t]]+"!"},r.prototype.makeUpPrefix=function(e){function t(t){return!!r.prototype.validPrefix.test(t)&&("ns"!==t&&(!(t in this.namespaces)&&(this.prefixes[e]=t,this.namespaces[t]=e,n=t,!0)))}var n,i=e t=t.bind(this),"#/".indexOf(i[i.length-1])>=0&&(i=i.slice(0,-1)) var o=i.lastIndexOf("/") o>=0&&(i=i.slice(o+1)) for(var a=0;a?@[\\]^`{|}~",r.prototype._notNameChars=r.prototype._notQNameChars+":",r.prototype.statementsToN3=function(n){function o(e){for(var t=this.rootSubjects(e),r=t.roots,n=[],i=0;i=0?t(r):e(r))+">"}function f(){var e="" this.defaultNamespace&&(e+="@prefix : <"+this.defaultNamespace+">.\n") for(var t in this.prefixes)this.prefixes.hasOwnProperty(t)&&this.namespacesUsed[t]&&(e+="@prefix "+this.prefixes[t]+": "+c(t)+".\n") return e+"\n"}var h={} this.flags.indexOf("s")<0&&(h["http://www.w3.org/2002/07/owl#sameAs"]="="),this.flags.indexOf("t")<0&&(h["http://www.w3.org/1999/02/22-rdf-syntax-ns#type"]="a"),this.flags.indexOf("i")<0&&(h["http://www.w3.org/2000/10/swap/log#implies"]="=>") var d=function(e){for(var t="",r=0;r=0){n=n.slice(0,-1)+a+"\n",i+=1 continue}if("])}".indexOf(a)>=0){n=n.slice(0,-1)+" "+a+"\n",i+=2 continue}}if(i<4*r+4)n=n.slice(0,-1)+" "+a+"\n",i+=a.length+1 else{var u=d(4*r)+a n+=u+"\n",i=u.length}}}return n}(g,-1)},r.prototype.atomicTermToN3=function(e,t){switch(e.termType){case"BlankNode":case"Variable":return e.toNT() case"Literal":if(e.datatype)switch(e.datatype.uri){case"http://www.w3.org/2001/XMLSchema#integer":return e.value.toString() case"http://www.w3.org/2001/XMLSchema#boolean":return e.value?"true":"false"}var r=this.stringToN3(e.value) return e.language?r+="@"+e.language:e.datatype.equals(a.string)||(r+="^^"+this.termToN3(e.datatype,t)),r case"NamedNode":return this.symbolToN3(e) default:throw"Internal: atomicTermToN3 cannot handle "+e+" of termType+"+e.termType}},r.prototype.validPrefix=new RegExp(/^[a-zA-Z][a-zA-Z0-9]*$/),r.prototype.forbidden1=new RegExp(/[\\"\b\f\r\v\t\n\u0080-\uffff]/gm),r.prototype.forbidden3=new RegExp(/[\\"\b\f\r\v\u0080-\uffff]/gm),r.prototype.stringToN3=function(e,t){t||(t="e") var n,i,o="",a=0,s=0 e.length>20&&'"'!=e.slice(-1)&&t.indexOf("n")<0&&(e.indexOf("\n")>0||e.indexOf('"')>0)?(n='"""',i=r.prototype.forbidden3):(n='"',i=r.prototype.forbidden1) for(var a=0;a=0?o+="\\"+'bfrtvn\\"'[l]:t.indexOf("e")>=0?o+="\\u"+("000"+u.charCodeAt(0).toString(16).toLowerCase()).slice(-4):o+=u}a=s+1}return n+o+e.slice(a)+n},r.prototype.symbolToN3=function(e){var t=e.uri,n=t.indexOf("#") if(n<0&&this.flags.indexOf("/")<0&&(n=t.lastIndexOf("/")),n>=0&&this.flags.indexOf("p")<0&&(0===t.indexOf("http")||0===t.indexOf("ws")||0===t.indexOf("file"))){for(var i=!0,o=n+1;o=0){i=!1 break}if(t.slice(0,n+1)==this.base+"#")return"<#"+t.slice(n+1)+">" if(i){var a=t.slice(n+1),s=t.slice(0,n+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 this.checkIntegrity() var u=this.prefixes[s] if(u||(u=this.makeUpPrefix(s)),u)return this.namespacesUsed[s]=!0,u+":"+a}}return explicitURI(t)},r.prototype.writeStore=function(e){var t=this.store,r=t.fetcher,n=r&&r.appNode,i=this.store.index[3] for(var o in i){var a=t.fromNT(o) n&&a.sameTerm(n)||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(r){e("\n<"+r.object.value+"> log:metadata {\n") var n=t.statementsMatching(void 0,void 0,void 0,r.subject) e(this.statementsToN3(this.statementsToN3(n))),e("}.\n")}) var s=[] n&&s.push(n) var u=[] s.map(function(e){u=u.concat(t.statementsMatching(void 0,void 0,void 0,e))}),e(this.statementsToN3(u))},r.prototype.statementsToXML=function(e){function t(e){this.suggestPrefix("rdf","http://www.w3.org/1999/02/22-rdf-syntax-ns#") for(var t=this.rootSubjects(e),r=t.roots,n=[],i=0;i",u(c.object,t),""]):p.concat(["<"+o+' rdf:nodeID="'+c.object.toNT().slice(2)+'"/>']) break case"NamedNode":p=p.concat(["<"+o+' rdf:resource="'+s(c.object)+'"/>']) break case"Literal":p=p.concat(["<"+o+(c.object.datatype.equals(a.string)?"":' rdf:datatype="'+i(c.object.datatype.uri)+'"')+(c.object.language?' xml:lang="'+c.object.language+'"':"")+">"+i(c.object.value)+""]) break case"collection":p=p.concat(["<"+o+' rdf:parseType="Collection">',l(c.object,t),""]) break default:throw"Can't serialize object of type "+c.object.termType+" into XML"}}else r=c.object var b=r?f(r):"rdf:Description",w="" return"BlankNode"==e.termType?t.incoming[e]&&1==t.incoming[e].length||(w=' rdf:nodeID="'+e.toNT().slice(2)+'"'):w=' rdf:about="'+s(e)+'"',["<"+b+w+">"].concat([p]).concat([""])}function l(e,t){for(var r=[],n=0;n',""]):r.concat(["<"+f(u.predicate)+' rdf:parseType="Resource">',c(u.object,t),""]) break case"NamedNode":r=r.concat(["<"+f(u.predicate)+' rdf:resource="'+s(u.object)+'"/>']) break case"Literal":r=r.concat(["<"+f(u.predicate)+(u.object.datatype.equals(a.string)?"":' rdf:datatype="'+i(u.object.datatype.value)+'"')+(u.object.language?' xml:lang="'+u.object.language+'"':"")+">"+i(u.object.value)+""]) break case"collection":r=r.concat(["<"+f(u.predicate)+' rdf:parseType="Collection">',l(u.object,t),""]) break default:throw"Can't serialize object of type "+u.object.termType+" into XML"}}return r}function f(e){var t=e.uri,n=t.indexOf("#") if(n<0&&this.flags.indexOf("/")<0&&(n=t.lastIndexOf("/")),n<0)throw"Cannot make qname out of <"+t+">" for(var i=n+1;i=0)throw'Invalid character "'+t[i]+'" cannot be in XML qname for URI: '+t var o=t.slice(n+1),a=t.slice(0,n+1) if(this.defaultNamespace&&this.defaultNamespace==a&&this.flags.indexOf("d")<0)return o var s=this.prefixes[a] return s||(s=this.makeUpPrefix(a)),h[a]=!0,s+":"+o}var h=[] h["http://www.w3.org/1999/02/22-rdf-syntax-ns#"]=!0 var d="http://www.w3.org/1999/02/22-rdf-syntax-ns#_",p=function(e){for(var t="",r=0;r"] return function e(t,r){var n="",i=1e5 r||(r=0) for(var o=0;o"):e}function l(e){return"string"==typeof e&&e.match(/^<[^>]*>$/)}function c(e){return"string"==typeof e&&(e.match(/^_:/)||e.match(/^$/))}function f(e){return"string"==typeof e&&e.match(/:$/)}function h(e){return"string"==typeof e&&e.match(/^:|^[^_][^:]*:/)}function d(e){return e.split(":")[0]}function p(e){return e.split(":")[1]}function v(e){return l(e)?e.slice(1,e.length-1):e}function g(e){var t=-1===e.indexOf("'")?null:e.indexOf("'"),n=-1===e.indexOf('"')?null:e.indexOf('"') if(!t&&!n){var o=new Array(1) return o[0]=e,o}var a,s,u=new Array(2) if(!t||n&&n/g,"> ").replace(/{/g," { ").replace(/}/g," } ").replace(/[\t\n\r]/g," ").replace(/; /g," ; ").replace(/\. /g," . ").replace(/, /g," , "),i.info("New str into spaceDelimit: \n"+e) var t=[],r=e.split(" ") for(var n in r)a(r[n])&&(t=t.concat(r[n])) return t}function y(e){for(var t=e,r=0;r"),"is"===t[r]&&"of"===t[r+2]){t.splice(r,1),t.splice(r+1,1) var n=t[r-1] t[r-1]=t[r+1],t[r+1]=n}return t}function b(e){for(var t=[],o=0;o"===e[1]?(i.debug("Constraint added: "+e),t.constraints[e[0]]=new T(e[2])):"<"===e[1]?(i.debug("Constraint added: "+e),t.constraints[e[0]]=new T(e[2])):i.warn("I don't know how to handle the constraint: "+e)}function E(e,t){i.debug("Optional query: "+e+" not yet implemented.") var n=r.formula() j(e,n),t.optional.push(n)}function j(e,t){var r,n=b(e) i.debug("WHERE: "+n) for(var o;w("OPTIONAL",n);)o=w("OPTIONAL",n),i.debug("OPT: "+o+" "+n[o]+" in "+n),"{"!==n[o+1]&&i.warn("Bad optional opening bracket in word "+o),r=_(n.slice(o+2),"{","}"),-1===r?i.error("No matching bracket in word "+o):(E(n.slice(o+2,o+2+r),t),o=w("OPTIONAL",n),r=_(n.slice(o+2),"{","}"),n.splice(o,r+3)) for(i.debug("WHERE after optionals: "+n);w("FILTER",n);){var a=w("FILTER",n) "("!==n[a+1]&&i.warn("Bad filter opening bracket in word "+a),r=_(n.slice(a+2),"(",")"),-1===r?i.error("No matching bracket in word "+a):(N(n.slice(a+2,a+2+r),t),a=w("FILTER",n),r=_(n.slice(a+2),"(",")"),n.splice(a,r+3))}i.debug("WHERE after filters and optionals: "+n),S(n,t)}function S(e,t){var r=new Array(1) r[0]=-1 for(var n=r.concat(x(".",e)),o=[],a=0;a "+a) var s=d(o),u=v(a) r[s]=u}else i.error("Invalid SPARQL symbol: "+a) else i.error("Invalid SPARQL prefix: "+o)}return r}(O) C.rdf||(C.rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"),C.rdfs||(C.rdfs="http://www.w3.org/2000/01/rdf-schema#") var L=w("SELECT",O),D=w("WHERE",O) if(L<0||D<0||L>D)return i.error("Invalid or nonexistent SELECT and WHERE tags in SPARQL query"),!1 if(function(e,t){i.info("SPARQL vars: "+e) for(var r in e)if(s(e[r])){i.info("Added "+e[r]+" to query variables from SPARQL") var o=n(e[r].slice(1)) t.vars.push(o),o.label=e[r].slice(1)}else i.warn("Incorrect SPARQL variable in SELECT: "+e[r])}(O.slice(L+1,D),R),j(O.slice(D+2,O.length-1),R.pat),t)return R for(var A in R.pat.statements){var M=R.pat.statements[A] "NamedNode"===M.subject.termType&&r.fetcher&&r.fetcher.lookUpThing(M.subject,"sparql:"+M.subject),"NamedNode"===M.object.termType&&r.fetcher&&r.fetcher.lookUpThing(M.object,"sparql:"+M.object)}return R}var i=e("./log"),o=e("./query").Query t.exports=n},{"./log":55,"./query":63}],69:[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=0)return"SPARQL" var d=t.each(f,this.ns.httph("ms-author-via")) if(d.length)for(s=0;s=0)return"SPARQL" if(l.indexOf("DAV")>=0)return"DAV"}var p=t.each(f,this.ns.http("status")) if(p.length)for(s=0;s") var n=h.XMLHTTPFactory() n.options={},n.onreadystatechange=function(){if(4===n.readyState){var i=!n.status||n.status>=200&&n.status<300 i?console.log("sparql: update Ok for <"+e+">"):console.log("sparql: update failed for <"+e+"> status="+n.status+", "+n.statusText+", body length="+n.responseText.length+"\n for query: "+t),r(e,i,n.responseText,n)}},n.open("PATCH",e,!0),n.setRequestHeader("Content-type","application/sparql-update"),n.send(t)},e.prototype.update_statement=function(e){if(!e||e.why){var t=this,r=this._statement_context(e) return{statement:e?[e.subject,e.predicate,e.object,e.why]:void 0,statementNT:e?this.anonymizeNT(e):void 0,where:t._context_where(r),set_object:function(e,r){var n=this.where n+="DELETE DATA { "+this.statementNT+" } ;\n",n+="INSERT DATA { "+this.anonymize(this.statement[0])+" "+this.anonymize(this.statement[1])+" "+this.anonymize(e)+" . }\n",t._fire(this.statement[3].uri,n,r)}}}},e.prototype.insert_statement=function(e,t){var r=e instanceof Array?e[0]:e,n=this._context_where(this._statement_context(r)) if(e instanceof Array){for(var i="",o=0;o 1 differnt downstream actions")}r.downstreamAction=t}else t(e)},e.prototype.clearUpstreamCount=function(e){this.patchControlFor(e).upstreamCount=0},e.prototype.getUpdatesVia=function(e){var t=this.store.fetcher.getHeader(e,"updates-via") return t&&t.length?t[0].trim():null},e.prototype.addDownstreamChangeListener=function(e,t){var r=this.patchControlFor(e) r.downstreamChangeListeners||(r.downstreamChangeListeners=[]),r.downstreamChangeListeners.push(t) var n=this this.setRefreshHandler(e,function(e){n.reloadAndSync(e)})},e.prototype.reloadAndSync=function(e){var t=this.patchControlFor(e),r=this if(t.reloading)return void console.log(" Already reloading - stop") t.reloading=!0 var n=1e3 !function i(){console.log("try reload - timeout = "+n),r.reload(r.store,e,function(r,o,a){if(t.reloading=!1,r){if(t.downstreamChangeListeners)for(var s=0;s=0))return void console.log("just an echo: "+l.upstreamCount) console.log("Assume a real downstream change: "+l.upstreamCount+" -> 0"),l.upstreamCount=0,i.requestDownstreamAction(e,n)}}}(),!0},e.prototype.update=function(e,t,r){try{var i=this.store,o=e?e instanceof s?e.statements:e instanceof Array?e:[e]:[],a=t?t instanceof s?t.statements:t instanceof Array?t:[t]:[] if(!(o instanceof Array))throw new Error("Type Error "+(void 0===o?"undefined":n(o))+": "+o) if(!(a instanceof Array))throw new Error("Type Error "+(void 0===a?"undefined":n(a))+": "+a) if(0===o.length&&0===a.length)return r(null,!0) var u=o.length?o[0].why:a[0].why,l=this.patchControlFor(u),d=Date.now(),p=["subject","predicate","object","why"],v={delete:o,insert:a};["insert","delete"].map(function(e){v[e].map(function(e){if(!u.sameTerm(e.why))throw new Error("update: destination "+u+" inconsistent with delete quad "+e.why) p.map(function(t){if(void 0===e[t])throw new Error("update: undefined "+t+" of statement.")})})}) var g=this.editable(u.uri,i) if(!g)throw new Error("Can't make changes in uneditable "+u) var m,y,b,w if(g.indexOf("SPARQL")>=0){var x=[] o.length&&(x=this._statement_array_bnodes(o)),a.length&&(x=x.concat(this._statement_array_bnodes(a))) var _=this._bnode_context(x,u),T=this._context_where(_),k="" if(T.length){if(o.length){for(k+="DELETE { ",m=0;m=0){var N=i.any(u,this.ns.link("request")) if(!N)throw new Error("No record of our HTTP GET request for document: "+u) var E=i.any(N,this.ns.link("response")) if(!E)return null var j=i.the(E,this.ns.httph("content-type")).value for(y=i.statementsMatching(void 0,void 0,void 0,u).slice(),m=0;m=200&&R.status<300 if(e){for(var t=0;t=0))throw new Error("Unhandled edit method: '"+g+"' for "+u) try{for(console.log("Writing back to local file\n"),y=i.statementsMatching(void 0,void 0,void 0,u).slice(),m=0;m>>") var L=u.uri.slice(7),D=Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsILocalFile) if(D.initWithPath(L),!D.exists())throw new Error("Rewriting file <"+u.uri+"> but it does not exist!") var A=Components.classes["@mozilla.org/network/file-output-stream;1"].createInstance(Components.interfaces.nsIFileOutputStream) for(A.init(D,42,parseInt("0666",8),0),A.write(b,b.length),A.close(),m=0;m\n")}}}catch(e){r(void 0,!1,"Exception in update: "+e)}},e.prototype.put=function(e,t,r,i){var o,a=this.store if((void 0===t?"undefined":n(t))===n(""))o=t else{var s=c(a) switch(s.suggestNamespaces(a.namespaces),s.setBase(e.uri),r){case"application/rdf+xml":o=s.statementsToXML(t) break case"text/n3":case"text/turtle":case"application/x-turtle":case"application/n3":o=s.statementsToN3(t) break default:throw new Error("Content-type "+r+" not supported for data PUT")}}var u=h.XMLHTTPFactory() u.options={},u.onreadystatechange=function(){if(4===u.readyState){var r=!u.status||u.status>=200&&u.status<300 r&&"string"!=typeof t&&t.map(function(e){a.addStatement(e)}),r&&(delete a.fetcher.nonexistant[e.uri],delete a.fetcher.requested[e.uri]),i(e.uri,r,u.responseText,u)}},u.open("PUT",e.uri,!0),u.setRequestHeader("Content-type",r),u.send(o)},e.prototype.reload=function(e,t,r){var n=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),r(!1,"Non-HTTP error reloading data: "+i,o) else{var a=Date.now()-n t.reloadTime_total||(t.reloadTime_total=0),t.reloadTime_count||(t.reloadTime_count=0),t.reloadTime_total+=a,t.reloadTime_count+=1,console.log(" Fetch took "+a+"ms, av. of "+t.reloadTime_count+" = "+t.reloadTime_total/t.reloadTime_count+"ms."),r(!0)}else console.log(" ERROR reloading data: "+i),r(!1,"Error reloading data: "+i,o)})},e.prototype.oldReload=function(e,t,r){var n=a(),i=fetcher(n),o=Date.now() i.nowOrWhenFetched(t.uri,{force:!0,noMeta:!0,clearPreviousData:!0},function(i,a,s){if(i)if(s.onErrorWasCalled||200!==s.status)console.log(" Non-HTTP error reloading data! onErrorWasCalled="+s.onErrorWasCalled+" status: "+s.status),r(!1,"Non-HTTP error reloading data: "+a,s) else{var u=e.statementsMatching(void 0,void 0,void 0,t).slice(),l=n.statementsMatching(void 0,void 0,void 0,t).slice() console.log(" replacing "+u.length+" with "+l.length+" out of total statements "+e.statements.length),e.remove(u),e.add(l) var c=Date.now()-o 0===l.length&&console.log("????????????????? 0000000"),t.reloadTime_total||(t.reloadTime_total=0),t.reloadTime_count||(t.reloadTime_count=0),t.reloadTime_total+=c,t.reloadTime_count+=1,console.log(" fetch took "+c+"ms, av. of "+t.reloadTime_count+" = "+t.reloadTime_total/t.reloadTime_count+"ms."),r(!0)}else console.log(" ERROR reloading data: "+a),r(!1,"Error reloading data: "+a,s)})},e}() t.exports=d},{"./data-factory":47,"./fetcher":50,"./indexed-formula":52,"./namespace":58,"./serializer":67,"./uri":72,"./util":73}],71:[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;r0&&(t=t.slice(0,s)),0===e.length)return t if(0===e.indexOf("#"))return t+e if(e.indexOf(":")>=0)return e if(r=t.indexOf(":"),0===t.length)return e if(r<0)return l("Invalid base: "+t+" in join with given: "+e),e if(n=t.slice(0,+r+1||9e9),0===e.indexOf("//"))return n+e if(t.indexOf("//",r)===r+1){if((i=t.indexOf("/",r+3))<0)return t.length-r-3>0?t+"/"+e:n+e}else if((i=t.indexOf("/",r+1))<0)return t.length-r-1>0?t+"/"+e:n+e if(0===e.indexOf("/"))return t.slice(0,i)+e if(a=t.slice(i),(o=a.lastIndexOf("/"))<0)return n+e for(o>=0&&o0&&"/"!==t[r-1];)r-- if(r<3)return t if(e.indexOf("//",r-2)>0||t.indexOf("//",r-2)>0)return t if(e.indexOf(":",r)>0)return t for(s=0,f=e.slice(r),l=0,a=f.length;l0)for(c=1,h=s;h>=1?c<=h:c>=h;h>=1?++c:--c)d+="../" return d+t.slice(r)}var l=l||console.log t.exports.docpart=n,t.exports.document=i,t.exports.hostpart=o,t.exports.join=a,t.exports.protocol=s,t.exports.refTo=u var c=e("./data-factory").namedNode},{"./data-factory":47}],73:[function(e,t,r){"use strict" function n(e,t,r){var n=null if(void 0!==e.fetcher&&(n=e.fetcher,"NamedNode"===t.termType)){var i,o=b(t.uri) if(t.uri.indexOf("#")<0){if(g(t.uri,"http://dbpedia.org/resource/Category:"))return g(t.uri,"http://purl.org/dc/elements/1.1/")||g(t.uri,"http://purl.org/dc/terms/")?i="http://dublincore.org/2005/06/13/dcq":g(t.uri,"http://xmlns.com/wot/0.1/")?i="http://xmlns.com/wot/0.1/index.rdf":g(t.uri,"http://web.resource.org/cc/")&&(i="http://web.resource.org/cc/schema.rdf")}i&&(o=i),n&&"unrequested"!==n.getState(o)||(i&&w.warn("Assuming server still broken, faking redirect of <"+t.uri+"> to <"+o+">"),n.requestURI(o,r))}}function i(e,t,r){r||(r=0) var n=e.length for(r<0&&(r=n+r);r=0;r--)e.callbacks[t[r]]=[] e.addHook=function(t){e.callbacks[t]||(e.callbacks[t]=[])},e.addCallback=function(t,r){e.callbacks[t].push(r)},e.removeCallback=function(t,r){for(var n=0;n=0;n--)e.callbacks[t][n].apply(e,r)&&i.push(e.callbacks[t][n]) for(n=i.length-1;n>=0;n--)o.push(i[n]) for(n=a;n=0;i--){var c=e.attributes[i] if(!(n.length>0&&n[c.name])&&!/^\d+$/.test(c.name)){if("class"===c.name&&"replaceClassItemWith"in t&&c.value.split(" ").indexOf(t.replaceClassItemWith.source)>-1){var f=new RegExp(t.replaceClassItemWith.source,"g") c.value=c.value.replace(f,t.replaceClassItemWith.target).trim()}"class"===c.name&&"skipClassWithValue"in t&&t.skipClassWithValue===c.value||l.push(c.name+"='"+c.value.replace(/&/g,"&").replace(//g,">").replace(/'/g,""")+"'")}}if(l.length>0&&("sortAttributes"in t&&t.sortAttributes&&l.sort(function(e,t){return e.toLowerCase().localeCompare(t.toLowerCase())}),o+=" "+l.join(" ")),r[s])o+=" />" else{for(o+=">",o+="html"===s?"\n ":"",a.push("style"===s||"script"===s),i=0;i\n":""}}}else if(8===e.nodeType)o+="\x3c!--"+e.nodeValue+"--\x3e" else if(3===e.nodeType||4===e.nodeType){var h=e.nodeValue.replace(/\n+$/,"") o+=a[a.length-1]?h:h.replace(/&/g,"&").replace(//g,">")}else console.log("Warning; Cannot handle serialising nodes of type: "+e.nodeType),console.log(e) return o}function l(){var e=new Date,t=e.getYear()+1900,r=e.getMonth()+1,n=e.getDate(),i=e.getUTCHours(),o=e.getUTCMinutes(),a=e.getSeconds() return r<10&&(r="0"+r),n<10&&(n="0"+n),i<10&&(i="0"+i),o<10&&(o="0"+o),a<10&&(a="0"+a),t+"-"+r+"-"+n+"T"+i+":"+o+":"+a+"Z"}function c(e){for(var t,r=e.getAllResponseHeaders().split("\n"),n={},i=0;i0){var o=r[i].split(": ") void 0===o[1]?n[t]+="\n"+o[0]:(t=o[0].toLowerCase(),n[t]=o[1])}return n}function f(e,t,r){var n=function(e){return"BlankNode"===e.termType?null:e},i=function(t){var i=r.statementsMatching(e).map(function(e){return n(e.subject)+" "+n(e.predicate)+" "+n(e.object)}).concat(r.statementsMatching(void 0,void 0,e).map(function(e){return n(e.subject)+" "+n(e.predicate)+" "+n(e.object)})) return i.sort(),i.join("\n")} return"BlankNode"===e.termType||"BlankNode"===t.termType?0===e.compareTerm(t)?0:i()>i()?1:i()