UNPKG

smartdown

Version:

A library for translating, rendering and interacting with Smartdown documents. Smartdown is an extension of Markdown that provides richer media support and reactive programming capability.

2 lines 240 kB
/*! For license information please see ldf-client-browser.js.LICENSE.txt */ !function(t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).ldf=t()}((function(){return function t(e,r,n){function i(o,a){if(!r[o]){if(!e[o]){var u="function"==typeof require&&require;if(!a&&u)return u(o,!0);if(s)return s(o,!0);var c=new Error("Cannot find module '"+o+"'");throw c.code="MODULE_NOT_FOUND",c}var l=r[o]={exports:{}};e[o][0].call(l.exports,(function(t){return i(e[o][1][t]||t)}),l,l.exports,t,e,r,n)}return r[o].exports}for(var s="function"==typeof require&&require,o=0;o<n.length;o++)i(n[o]);return i}({1:[function(t,e,r){(function(r){"use strict";var n=t("object-assign");function i(t,e){if(t===e)return 0;for(var r=t.length,n=e.length,i=0,s=Math.min(r,n);i<s;++i)if(t[i]!==e[i]){r=t[i],n=e[i];break}return r<n?-1:n<r?1:0}function s(t){return r.Buffer&&"function"==typeof r.Buffer.isBuffer?r.Buffer.isBuffer(t):!(null==t||!t._isBuffer)}var o=t("util/"),a=Object.prototype.hasOwnProperty,u=Array.prototype.slice,c="foo"===function(){}.name;function l(t){return Object.prototype.toString.call(t)}function f(t){return!s(t)&&"function"==typeof r.ArrayBuffer&&("function"==typeof ArrayBuffer.isView?ArrayBuffer.isView(t):!!t&&(t instanceof DataView||!!(t.buffer&&t.buffer instanceof ArrayBuffer)))}var h=e.exports=b,p=/\s*function\s+([^\(\s]*)\s*/;function d(t){if(o.isFunction(t)){if(c)return t.name;var e=t.toString().match(p);return e&&e[1]}}function _(t,e){return"string"==typeof t?t.length<e?t:t.slice(0,e):t}function y(t){if(c||!o.isFunction(t))return o.inspect(t);var e=d(t);return"[Function"+(e?": "+e:"")+"]"}function g(t,e,r,n,i){throw new h.AssertionError({message:r,actual:t,expected:e,operator:n,stackStartFunction:i})}function b(t,e){t||g(t,!0,e,"==",h.ok)}function v(t,e,r,n){if(t===e)return!0;if(s(t)&&s(e))return 0===i(t,e);if(o.isDate(t)&&o.isDate(e))return t.getTime()===e.getTime();if(o.isRegExp(t)&&o.isRegExp(e))return t.source===e.source&&t.global===e.global&&t.multiline===e.multiline&&t.lastIndex===e.lastIndex&&t.ignoreCase===e.ignoreCase;if(null!==t&&"object"==typeof t||null!==e&&"object"==typeof e){if(f(t)&&f(e)&&l(t)===l(e)&&!(t instanceof Float32Array||t instanceof Float64Array))return 0===i(new Uint8Array(t.buffer),new Uint8Array(e.buffer));if(s(t)!==s(e))return!1;var a=(n=n||{actual:[],expected:[]}).actual.indexOf(t);return-1!==a&&a===n.expected.indexOf(e)||(n.actual.push(t),n.expected.push(e),function(t,e,r,n){if(null==t||null==e)return!1;if(o.isPrimitive(t)||o.isPrimitive(e))return t===e;if(r&&Object.getPrototypeOf(t)!==Object.getPrototypeOf(e))return!1;var i=m(t),s=m(e);if(i&&!s||!i&&s)return!1;if(i)return v(t=u.call(t),e=u.call(e),r);var a,c,l=E(t),f=E(e);if(l.length!==f.length)return!1;for(l.sort(),f.sort(),c=l.length-1;c>=0;c--)if(l[c]!==f[c])return!1;for(c=l.length-1;c>=0;c--)if(!v(t[a=l[c]],e[a],r,n))return!1;return!0}(t,e,r,n))}return r?t===e:t==e}function m(t){return"[object Arguments]"==Object.prototype.toString.call(t)}function x(t,e){if(!t||!e)return!1;if("[object RegExp]"==Object.prototype.toString.call(e))return e.test(t);try{if(t instanceof e)return!0}catch(t){}return!Error.isPrototypeOf(e)&&!0===e.call({},t)}function w(t,e,r,n){var i;if("function"!=typeof e)throw new TypeError('"block" argument must be a function');"string"==typeof r&&(n=r,r=null),i=function(t){var e;try{t()}catch(t){e=t}return e}(e),n=(r&&r.name?" ("+r.name+").":".")+(n?" "+n:"."),t&&!i&&g(i,r,"Missing expected exception"+n);var s="string"==typeof n,a=!t&&i&&!r;if((!t&&o.isError(i)&&s&&x(i,r)||a)&&g(i,r,"Got unwanted exception"+n),t&&i&&r&&!x(i,r)||!t&&i)throw i}h.AssertionError=function(t){this.name="AssertionError",this.actual=t.actual,this.expected=t.expected,this.operator=t.operator,t.message?(this.message=t.message,this.generatedMessage=!1):(this.message=function(t){return _(y(t.actual),128)+" "+t.operator+" "+_(y(t.expected),128)}(this),this.generatedMessage=!0);var e=t.stackStartFunction||g;if(Error.captureStackTrace)Error.captureStackTrace(this,e);else{var r=new Error;if(r.stack){var n=r.stack,i=d(e),s=n.indexOf("\n"+i);if(s>=0){var o=n.indexOf("\n",s+1);n=n.substring(o+1)}this.stack=n}}},o.inherits(h.AssertionError,Error),h.fail=g,h.ok=b,h.equal=function(t,e,r){t!=e&&g(t,e,r,"==",h.equal)},h.notEqual=function(t,e,r){t==e&&g(t,e,r,"!=",h.notEqual)},h.deepEqual=function(t,e,r){v(t,e,!1)||g(t,e,r,"deepEqual",h.deepEqual)},h.deepStrictEqual=function(t,e,r){v(t,e,!0)||g(t,e,r,"deepStrictEqual",h.deepStrictEqual)},h.notDeepEqual=function(t,e,r){v(t,e,!1)&&g(t,e,r,"notDeepEqual",h.notDeepEqual)},h.notDeepStrictEqual=function t(e,r,n){v(e,r,!0)&&g(e,r,n,"notDeepStrictEqual",t)},h.strictEqual=function(t,e,r){t!==e&&g(t,e,r,"===",h.strictEqual)},h.notStrictEqual=function(t,e,r){t===e&&g(t,e,r,"!==",h.notStrictEqual)},h.throws=function(t,e,r){w(!0,t,e,r)},h.doesNotThrow=function(t,e,r){w(!1,t,e,r)},h.ifError=function(t){if(t)throw t},h.strict=n((function t(e,r){e||g(e,!0,r,"==",t)}),h,{equal:h.strictEqual,deepEqual:h.deepStrictEqual,notEqual:h.notStrictEqual,notDeepEqual:h.notDeepStrictEqual}),h.strict.strict=h.strict;var E=Object.keys||function(t){var e=[];for(var r in t)a.call(t,r)&&e.push(r);return e}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"object-assign":7,"util/":4}],2:[function(t,e,r){"function"==typeof Object.create?e.exports=function(t,e){t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}})}:e.exports=function(t,e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}},{}],3:[function(t,e,r){e.exports=function(t){return t&&"object"==typeof t&&"function"==typeof t.copy&&"function"==typeof t.fill&&"function"==typeof t.readUInt8}},{}],4:[function(t,e,r){(function(e,n){var i=/%[sdj%]/g;r.format=function(t){if(!g(t)){for(var e=[],r=0;r<arguments.length;r++)e.push(a(arguments[r]));return e.join(" ")}r=1;for(var n=arguments,s=n.length,o=String(t).replace(i,(function(t){if("%%"===t)return"%";if(r>=s)return t;switch(t){case"%s":return String(n[r++]);case"%d":return Number(n[r++]);case"%j":try{return JSON.stringify(n[r++])}catch(t){return"[Circular]"}default:return t}})),u=n[r];r<s;u=n[++r])_(u)||!m(u)?o+=" "+u:o+=" "+a(u);return o},r.deprecate=function(t,i){if(b(n.process))return function(){return r.deprecate(t,i).apply(this,arguments)};if(!0===e.noDeprecation)return t;var s=!1;return function(){if(!s){if(e.throwDeprecation)throw new Error(i);e.traceDeprecation?console.trace(i):console.error(i),s=!0}return t.apply(this,arguments)}};var s,o={};function a(t,e){var n={seen:[],stylize:c};return arguments.length>=3&&(n.depth=arguments[2]),arguments.length>=4&&(n.colors=arguments[3]),d(e)?n.showHidden=e:e&&r._extend(n,e),b(n.showHidden)&&(n.showHidden=!1),b(n.depth)&&(n.depth=2),b(n.colors)&&(n.colors=!1),b(n.customInspect)&&(n.customInspect=!0),n.colors&&(n.stylize=u),l(n,t,n.depth)}function u(t,e){var r=a.styles[e];return r?"["+a.colors[r][0]+"m"+t+"["+a.colors[r][1]+"m":t}function c(t,e){return t}function l(t,e,n){if(t.customInspect&&e&&E(e.inspect)&&e.inspect!==r.inspect&&(!e.constructor||e.constructor.prototype!==e)){var i=e.inspect(n,t);return g(i)||(i=l(t,i,n)),i}var s=function(t,e){if(b(e))return t.stylize("undefined","undefined");if(g(e)){var r="'"+JSON.stringify(e).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return t.stylize(r,"string")}return y(e)?t.stylize(""+e,"number"):d(e)?t.stylize(""+e,"boolean"):_(e)?t.stylize("null","null"):void 0}(t,e);if(s)return s;var o=Object.keys(e),a=function(t){var e={};return t.forEach((function(t,r){e[t]=!0})),e}(o);if(t.showHidden&&(o=Object.getOwnPropertyNames(e)),w(e)&&(o.indexOf("message")>=0||o.indexOf("description")>=0))return f(e);if(0===o.length){if(E(e)){var u=e.name?": "+e.name:"";return t.stylize("[Function"+u+"]","special")}if(v(e))return t.stylize(RegExp.prototype.toString.call(e),"regexp");if(x(e))return t.stylize(Date.prototype.toString.call(e),"date");if(w(e))return f(e)}var c,m="",F=!1,T=["{","}"];return p(e)&&(F=!0,T=["[","]"]),E(e)&&(m=" [Function"+(e.name?": "+e.name:"")+"]"),v(e)&&(m=" "+RegExp.prototype.toString.call(e)),x(e)&&(m=" "+Date.prototype.toUTCString.call(e)),w(e)&&(m=" "+f(e)),0!==o.length||F&&0!=e.length?n<0?v(e)?t.stylize(RegExp.prototype.toString.call(e),"regexp"):t.stylize("[Object]","special"):(t.seen.push(e),c=F?function(t,e,r,n,i){for(var s=[],o=0,a=e.length;o<a;++o)k(e,String(o))?s.push(h(t,e,r,n,String(o),!0)):s.push("");return i.forEach((function(i){i.match(/^\d+$/)||s.push(h(t,e,r,n,i,!0))})),s}(t,e,n,a,o):o.map((function(r){return h(t,e,n,a,r,F)})),t.seen.pop(),function(t,e,r){return t.reduce((function(t,e){return e.indexOf("\n"),t+e.replace(/\u001b\[\d\d?m/g,"").length+1}),0)>60?r[0]+(""===e?"":e+"\n ")+" "+t.join(",\n ")+" "+r[1]:r[0]+e+" "+t.join(", ")+" "+r[1]}(c,m,T)):T[0]+m+T[1]}function f(t){return"["+Error.prototype.toString.call(t)+"]"}function h(t,e,r,n,i,s){var o,a,u;if((u=Object.getOwnPropertyDescriptor(e,i)||{value:e[i]}).get?a=u.set?t.stylize("[Getter/Setter]","special"):t.stylize("[Getter]","special"):u.set&&(a=t.stylize("[Setter]","special")),k(n,i)||(o="["+i+"]"),a||(t.seen.indexOf(u.value)<0?(a=_(r)?l(t,u.value,null):l(t,u.value,r-1)).indexOf("\n")>-1&&(a=s?a.split("\n").map((function(t){return" "+t})).join("\n").substr(2):"\n"+a.split("\n").map((function(t){return" "+t})).join("\n")):a=t.stylize("[Circular]","special")),b(o)){if(s&&i.match(/^\d+$/))return a;(o=JSON.stringify(""+i)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(o=o.substr(1,o.length-2),o=t.stylize(o,"name")):(o=o.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),o=t.stylize(o,"string"))}return o+": "+a}function p(t){return Array.isArray(t)}function d(t){return"boolean"==typeof t}function _(t){return null===t}function y(t){return"number"==typeof t}function g(t){return"string"==typeof t}function b(t){return void 0===t}function v(t){return m(t)&&"[object RegExp]"===F(t)}function m(t){return"object"==typeof t&&null!==t}function x(t){return m(t)&&"[object Date]"===F(t)}function w(t){return m(t)&&("[object Error]"===F(t)||t instanceof Error)}function E(t){return"function"==typeof t}function F(t){return Object.prototype.toString.call(t)}function T(t){return t<10?"0"+t.toString(10):t.toString(10)}r.debuglog=function(t){if(b(s)&&(s=e.env.NODE_DEBUG||""),t=t.toUpperCase(),!o[t])if(new RegExp("\\b"+t+"\\b","i").test(s)){var n=e.pid;o[t]=function(){var e=r.format.apply(r,arguments);console.error("%s %d: %s",t,n,e)}}else o[t]=function(){};return o[t]},r.inspect=a,a.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},a.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},r.isArray=p,r.isBoolean=d,r.isNull=_,r.isNullOrUndefined=function(t){return null==t},r.isNumber=y,r.isString=g,r.isSymbol=function(t){return"symbol"==typeof t},r.isUndefined=b,r.isRegExp=v,r.isObject=m,r.isDate=x,r.isError=w,r.isFunction=E,r.isPrimitive=function(t){return null===t||"boolean"==typeof t||"number"==typeof t||"string"==typeof t||"symbol"==typeof t||void 0===t},r.isBuffer=t("./support/isBuffer");var I=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function k(t,e){return Object.prototype.hasOwnProperty.call(t,e)}r.log=function(){var t,e;console.log("%s - %s",(e=[T((t=new Date).getHours()),T(t.getMinutes()),T(t.getSeconds())].join(":"),[t.getDate(),I[t.getMonth()],e].join(" ")),r.format.apply(r,arguments))},r.inherits=t("inherits"),r._extend=function(t,e){if(!e||!m(e))return t;for(var r=Object.keys(e),n=r.length;n--;)t[r[n]]=e[r[n]];return t}}).call(this,t("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./support/isBuffer":3,_process:8,inherits:2}],5:[function(t,e,r){},{}],6:[function(t,e,r){var n=Object.create||function(t){var e=function(){};return e.prototype=t,new e},i=Object.keys||function(t){var e=[];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.push(r);return r},s=Function.prototype.bind||function(t){var e=this;return function(){return e.apply(t,arguments)}};function o(){this._events&&Object.prototype.hasOwnProperty.call(this,"_events")||(this._events=n(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0}e.exports=o,o.EventEmitter=o,o.prototype._events=void 0,o.prototype._maxListeners=void 0;var a,u=10;try{var c={};Object.defineProperty&&Object.defineProperty(c,"x",{value:0}),a=0===c.x}catch(t){a=!1}function l(t){return void 0===t._maxListeners?o.defaultMaxListeners:t._maxListeners}function f(t,e,r,i){var s,o,a;if("function"!=typeof r)throw new TypeError('"listener" argument must be a function');if((o=t._events)?(o.newListener&&(t.emit("newListener",e,r.listener?r.listener:r),o=t._events),a=o[e]):(o=t._events=n(null),t._eventsCount=0),a){if("function"==typeof a?a=o[e]=i?[r,a]:[a,r]:i?a.unshift(r):a.push(r),!a.warned&&(s=l(t))&&s>0&&a.length>s){a.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+a.length+' "'+String(e)+'" listeners added. Use emitter.setMaxListeners() to increase limit.');u.name="MaxListenersExceededWarning",u.emitter=t,u.type=e,u.count=a.length,"object"==typeof console&&console.warn&&console.warn("%s: %s",u.name,u.message)}}else a=o[e]=r,++t._eventsCount;return t}function h(){if(!this.fired)switch(this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length){case 0:return this.listener.call(this.target);case 1:return this.listener.call(this.target,arguments[0]);case 2:return this.listener.call(this.target,arguments[0],arguments[1]);case 3:return this.listener.call(this.target,arguments[0],arguments[1],arguments[2]);default:for(var t=new Array(arguments.length),e=0;e<t.length;++e)t[e]=arguments[e];this.listener.apply(this.target,t)}}function p(t,e,r){var n={fired:!1,wrapFn:void 0,target:t,type:e,listener:r},i=s.call(h,n);return i.listener=r,n.wrapFn=i,i}function d(t,e,r){var n=t._events;if(!n)return[];var i=n[e];return i?"function"==typeof i?r?[i.listener||i]:[i]:r?function(t){for(var e=new Array(t.length),r=0;r<e.length;++r)e[r]=t[r].listener||t[r];return e}(i):y(i,i.length):[]}function _(t){var e=this._events;if(e){var r=e[t];if("function"==typeof r)return 1;if(r)return r.length}return 0}function y(t,e){for(var r=new Array(e),n=0;n<e;++n)r[n]=t[n];return r}a?Object.defineProperty(o,"defaultMaxListeners",{enumerable:!0,get:function(){return u},set:function(t){if("number"!=typeof t||t<0||t!=t)throw new TypeError('"defaultMaxListeners" must be a positive number');u=t}}):o.defaultMaxListeners=u,o.prototype.setMaxListeners=function(t){if("number"!=typeof t||t<0||isNaN(t))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=t,this},o.prototype.getMaxListeners=function(){return l(this)},o.prototype.emit=function(t){var e,r,n,i,s,o,a="error"===t;if(o=this._events)a=a&&null==o.error;else if(!a)return!1;if(a){if(arguments.length>1&&(e=arguments[1]),e instanceof Error)throw e;var u=new Error('Unhandled "error" event. ('+e+")");throw u.context=e,u}if(!(r=o[t]))return!1;var c="function"==typeof r;switch(n=arguments.length){case 1:!function(t,e,r){if(e)t.call(r);else for(var n=t.length,i=y(t,n),s=0;s<n;++s)i[s].call(r)}(r,c,this);break;case 2:!function(t,e,r,n){if(e)t.call(r,n);else for(var i=t.length,s=y(t,i),o=0;o<i;++o)s[o].call(r,n)}(r,c,this,arguments[1]);break;case 3:!function(t,e,r,n,i){if(e)t.call(r,n,i);else for(var s=t.length,o=y(t,s),a=0;a<s;++a)o[a].call(r,n,i)}(r,c,this,arguments[1],arguments[2]);break;case 4:!function(t,e,r,n,i,s){if(e)t.call(r,n,i,s);else for(var o=t.length,a=y(t,o),u=0;u<o;++u)a[u].call(r,n,i,s)}(r,c,this,arguments[1],arguments[2],arguments[3]);break;default:for(i=new Array(n-1),s=1;s<n;s++)i[s-1]=arguments[s];!function(t,e,r,n){if(e)t.apply(r,n);else for(var i=t.length,s=y(t,i),o=0;o<i;++o)s[o].apply(r,n)}(r,c,this,i)}return!0},o.prototype.addListener=function(t,e){return f(this,t,e,!1)},o.prototype.on=o.prototype.addListener,o.prototype.prependListener=function(t,e){return f(this,t,e,!0)},o.prototype.once=function(t,e){if("function"!=typeof e)throw new TypeError('"listener" argument must be a function');return this.on(t,p(this,t,e)),this},o.prototype.prependOnceListener=function(t,e){if("function"!=typeof e)throw new TypeError('"listener" argument must be a function');return this.prependListener(t,p(this,t,e)),this},o.prototype.removeListener=function(t,e){var r,i,s,o,a;if("function"!=typeof e)throw new TypeError('"listener" argument must be a function');if(!(i=this._events))return this;if(!(r=i[t]))return this;if(r===e||r.listener===e)0==--this._eventsCount?this._events=n(null):(delete i[t],i.removeListener&&this.emit("removeListener",t,r.listener||e));else if("function"!=typeof r){for(s=-1,o=r.length-1;o>=0;o--)if(r[o]===e||r[o].listener===e){a=r[o].listener,s=o;break}if(s<0)return this;0===s?r.shift():function(t,e){for(var r=e,n=r+1,i=t.length;n<i;r+=1,n+=1)t[r]=t[n];t.pop()}(r,s),1===r.length&&(i[t]=r[0]),i.removeListener&&this.emit("removeListener",t,a||e)}return this},o.prototype.removeAllListeners=function(t){var e,r,s;if(!(r=this._events))return this;if(!r.removeListener)return 0===arguments.length?(this._events=n(null),this._eventsCount=0):r[t]&&(0==--this._eventsCount?this._events=n(null):delete r[t]),this;if(0===arguments.length){var o,a=i(r);for(s=0;s<a.length;++s)"removeListener"!==(o=a[s])&&this.removeAllListeners(o);return this.removeAllListeners("removeListener"),this._events=n(null),this._eventsCount=0,this}if("function"==typeof(e=r[t]))this.removeListener(t,e);else if(e)for(s=e.length-1;s>=0;s--)this.removeListener(t,e[s]);return this},o.prototype.listeners=function(t){return d(this,t,!0)},o.prototype.rawListeners=function(t){return d(this,t,!1)},o.listenerCount=function(t,e){return"function"==typeof t.listenerCount?t.listenerCount(e):_.call(t,e)},o.prototype.listenerCount=_,o.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]}},{}],7:[function(t,e,r){"use strict";var n=Object.getOwnPropertySymbols,i=Object.prototype.hasOwnProperty,s=Object.prototype.propertyIsEnumerable;e.exports=function(){try{if(!Object.assign)return!1;var t=new String("abc");if(t[5]="de","5"===Object.getOwnPropertyNames(t)[0])return!1;for(var e={},r=0;r<10;r++)e["_"+String.fromCharCode(r)]=r;if("0123456789"!==Object.getOwnPropertyNames(e).map((function(t){return e[t]})).join(""))return!1;var n={};return"abcdefghijklmnopqrst".split("").forEach((function(t){n[t]=t})),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},n)).join("")}catch(t){return!1}}()?Object.assign:function(t,e){for(var r,o,a=function(t){if(null==t)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(t)}(t),u=1;u<arguments.length;u++){for(var c in r=Object(arguments[u]))i.call(r,c)&&(a[c]=r[c]);if(n){o=n(r);for(var l=0;l<o.length;l++)s.call(r,o[l])&&(a[o[l]]=r[o[l]])}}return a}},{}],8:[function(t,e,r){var n,i,s=e.exports={};function o(){throw new Error("setTimeout has not been defined")}function a(){throw new Error("clearTimeout has not been defined")}function u(t){if(n===setTimeout)return setTimeout(t,0);if((n===o||!n)&&setTimeout)return n=setTimeout,setTimeout(t,0);try{return n(t,0)}catch(e){try{return n.call(null,t,0)}catch(e){return n.call(this,t,0)}}}!function(){try{n="function"==typeof setTimeout?setTimeout:o}catch(t){n=o}try{i="function"==typeof clearTimeout?clearTimeout:a}catch(t){i=a}}();var c,l=[],f=!1,h=-1;function p(){f&&c&&(f=!1,c.length?l=c.concat(l):h=-1,l.length&&d())}function d(){if(!f){var t=u(p);f=!0;for(var e=l.length;e;){for(c=l,l=[];++h<e;)c&&c[h].run();h=-1,e=l.length}c=null,f=!1,function(t){if(i===clearTimeout)return clearTimeout(t);if((i===a||!i)&&clearTimeout)return i=clearTimeout,clearTimeout(t);try{return i(t)}catch(e){try{return i.call(null,t)}catch(e){return i.call(this,t)}}}(t)}}function _(t,e){this.fun=t,this.array=e}function y(){}s.nextTick=function(t){var e=new Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)e[r-1]=arguments[r];l.push(new _(t,e)),1!==l.length||f||u(d)},_.prototype.run=function(){this.fun.apply(null,this.array)},s.title="browser",s.browser=!0,s.env={},s.argv=[],s.version="",s.versions={},s.on=y,s.addListener=y,s.once=y,s.off=y,s.removeListener=y,s.removeAllListeners=y,s.emit=y,s.prependListener=y,s.prependOnceListener=y,s.listeners=function(t){return[]},s.binding=function(t){throw new Error("process.binding is not supported")},s.cwd=function(){return"/"},s.chdir=function(t){throw new Error("process.chdir is not supported")},s.umask=function(){return 0}},{}],9:[function(t,e,r){(function(t){!function(n){var i="object"==typeof r&&r&&!r.nodeType&&r,s="object"==typeof e&&e&&!e.nodeType&&e,o="object"==typeof t&&t;o.global!==o&&o.window!==o&&o.self!==o||(n=o);var a,u,c=2147483647,l=36,f=26,h=38,p=700,d=/^xn--/,_=/[^\x20-\x7E]/,y=/[\x2E\u3002\uFF0E\uFF61]/g,g={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},b=l-1,v=Math.floor,m=String.fromCharCode;function x(t){throw new RangeError(g[t])}function w(t,e){for(var r=t.length,n=[];r--;)n[r]=e(t[r]);return n}function E(t,e){var r=t.split("@"),n="";return r.length>1&&(n=r[0]+"@",t=r[1]),n+w((t=t.replace(y,".")).split("."),e).join(".")}function F(t){for(var e,r,n=[],i=0,s=t.length;i<s;)(e=t.charCodeAt(i++))>=55296&&e<=56319&&i<s?56320==(64512&(r=t.charCodeAt(i++)))?n.push(((1023&e)<<10)+(1023&r)+65536):(n.push(e),i--):n.push(e);return n}function T(t){return w(t,(function(t){var e="";return t>65535&&(e+=m((t-=65536)>>>10&1023|55296),t=56320|1023&t),e+m(t)})).join("")}function I(t,e){return t+22+75*(t<26)-((0!=e)<<5)}function k(t,e,r){var n=0;for(t=r?v(t/p):t>>1,t+=v(t/e);t>b*f>>1;n+=l)t=v(t/b);return v(n+(b+1)*t/(t+h))}function A(t){var e,r,n,i,s,o,a,u,h,p,d,_=[],y=t.length,g=0,b=128,m=72;for((r=t.lastIndexOf("-"))<0&&(r=0),n=0;n<r;++n)t.charCodeAt(n)>=128&&x("not-basic"),_.push(t.charCodeAt(n));for(i=r>0?r+1:0;i<y;){for(s=g,o=1,a=l;i>=y&&x("invalid-input"),((u=(d=t.charCodeAt(i++))-48<10?d-22:d-65<26?d-65:d-97<26?d-97:l)>=l||u>v((c-g)/o))&&x("overflow"),g+=u*o,!(u<(h=a<=m?1:a>=m+f?f:a-m));a+=l)o>v(c/(p=l-h))&&x("overflow"),o*=p;m=k(g-s,e=_.length+1,0==s),v(g/e)>c-b&&x("overflow"),b+=v(g/e),g%=e,_.splice(g++,0,b)}return T(_)}function C(t){var e,r,n,i,s,o,a,u,h,p,d,_,y,g,b,w=[];for(_=(t=F(t)).length,e=128,r=0,s=72,o=0;o<_;++o)(d=t[o])<128&&w.push(m(d));for(n=i=w.length,i&&w.push("-");n<_;){for(a=c,o=0;o<_;++o)(d=t[o])>=e&&d<a&&(a=d);for(a-e>v((c-r)/(y=n+1))&&x("overflow"),r+=(a-e)*y,e=a,o=0;o<_;++o)if((d=t[o])<e&&++r>c&&x("overflow"),d==e){for(u=r,h=l;!(u<(p=h<=s?1:h>=s+f?f:h-s));h+=l)b=u-p,g=l-p,w.push(m(I(p+b%g,0))),u=v(b/g);w.push(m(I(u,0))),s=k(r,y,n==i),r=0,++n}++r,++e}return w.join("")}if(a={version:"1.4.1",ucs2:{decode:F,encode:T},decode:A,encode:C,toASCII:function(t){return E(t,(function(t){return _.test(t)?"xn--"+C(t):t}))},toUnicode:function(t){return E(t,(function(t){return d.test(t)?A(t.slice(4).toLowerCase()):t}))}},i&&s)if(e.exports==i)s.exports=a;else for(u in a)a.hasOwnProperty(u)&&(i[u]=a[u]);else n.punycode=a}(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],10:[function(t,e,r){"use strict";function n(t,e){return Object.prototype.hasOwnProperty.call(t,e)}e.exports=function(t,e,r,s){e=e||"&",r=r||"=";var o={};if("string"!=typeof t||0===t.length)return o;var a=/\+/g;t=t.split(e);var u=1e3;s&&"number"==typeof s.maxKeys&&(u=s.maxKeys);var c=t.length;u>0&&c>u&&(c=u);for(var l=0;l<c;++l){var f,h,p,d,_=t[l].replace(a,"%20"),y=_.indexOf(r);y>=0?(f=_.substr(0,y),h=_.substr(y+1)):(f=_,h=""),p=decodeURIComponent(f),d=decodeURIComponent(h),n(o,p)?i(o[p])?o[p].push(d):o[p]=[o[p],d]:o[p]=d}return o};var i=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)}},{}],11:[function(t,e,r){"use strict";var n=function(t){switch(typeof t){case"string":return t;case"boolean":return t?"true":"false";case"number":return isFinite(t)?t:"";default:return""}};e.exports=function(t,e,r,a){return e=e||"&",r=r||"=",null===t&&(t=void 0),"object"==typeof t?s(o(t),(function(o){var a=encodeURIComponent(n(o))+r;return i(t[o])?s(t[o],(function(t){return a+encodeURIComponent(n(t))})).join(e):a+encodeURIComponent(n(t[o]))})).join(e):a?encodeURIComponent(n(a))+r+encodeURIComponent(n(t)):""};var i=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)};function s(t,e){if(t.map)return t.map(e);for(var r=[],n=0;n<t.length;n++)r.push(e(t[n],n));return r}var o=Object.keys||function(t){var e=[];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.push(r);return e}},{}],12:[function(t,e,r){"use strict";r.decode=r.parse=t("./decode"),r.encode=r.stringify=t("./encode")},{"./decode":10,"./encode":11}],13:[function(t,e,r){(function(e,n){var i=t("process/browser.js").nextTick,s=Function.prototype.apply,o=Array.prototype.slice,a={},u=0;function c(t,e){this._id=t,this._clearFn=e}r.setTimeout=function(){return new c(s.call(setTimeout,window,arguments),clearTimeout)},r.setInterval=function(){return new c(s.call(setInterval,window,arguments),clearInterval)},r.clearTimeout=r.clearInterval=function(t){t.close()},c.prototype.unref=c.prototype.ref=function(){},c.prototype.close=function(){this._clearFn.call(window,this._id)},r.enroll=function(t,e){clearTimeout(t._idleTimeoutId),t._idleTimeout=e},r.unenroll=function(t){clearTimeout(t._idleTimeoutId),t._idleTimeout=-1},r._unrefActive=r.active=function(t){clearTimeout(t._idleTimeoutId);var e=t._idleTimeout;e>=0&&(t._idleTimeoutId=setTimeout((function(){t._onTimeout&&t._onTimeout()}),e))},r.setImmediate="function"==typeof e?e:function(t){var e=u++,n=!(arguments.length<2)&&o.call(arguments,1);return a[e]=!0,i((function(){a[e]&&(n?t.apply(null,n):t.call(null),r.clearImmediate(e))})),e},r.clearImmediate="function"==typeof n?n:function(t){delete a[t]}}).call(this,t("timers").setImmediate,t("timers").clearImmediate)},{"process/browser.js":8,timers:13}],14:[function(t,e,r){"use strict";var n=t("punycode"),i=t("./util");function s(){this.protocol=null,this.slashes=null,this.auth=null,this.host=null,this.port=null,this.hostname=null,this.hash=null,this.search=null,this.query=null,this.pathname=null,this.path=null,this.href=null}r.parse=v,r.resolve=function(t,e){return v(t,!1,!0).resolve(e)},r.resolveObject=function(t,e){return t?v(t,!1,!0).resolveObject(e):e},r.format=function(t){return i.isString(t)&&(t=v(t)),t instanceof s?t.format():s.prototype.format.call(t)},r.Url=s;var o=/^([a-z0-9.+-]+:)/i,a=/:[0-9]*$/,u=/^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/,c=["{","}","|","\\","^","`"].concat(["<",">",'"',"`"," ","\r","\n","\t"]),l=["'"].concat(c),f=["%","/","?",";","#"].concat(l),h=["/","?","#"],p=/^[+a-z0-9A-Z_-]{0,63}$/,d=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,_={javascript:!0,"javascript:":!0},y={javascript:!0,"javascript:":!0},g={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},b=t("querystring");function v(t,e,r){if(t&&i.isObject(t)&&t instanceof s)return t;var n=new s;return n.parse(t,e,r),n}s.prototype.parse=function(t,e,r){if(!i.isString(t))throw new TypeError("Parameter 'url' must be a string, not "+typeof t);var s=t.indexOf("?"),a=-1!==s&&s<t.indexOf("#")?"?":"#",c=t.split(a);c[0]=c[0].replace(/\\/g,"/");var v=t=c.join(a);if(v=v.trim(),!r&&1===t.split("#").length){var m=u.exec(v);if(m)return this.path=v,this.href=v,this.pathname=m[1],m[2]?(this.search=m[2],this.query=e?b.parse(this.search.substr(1)):this.search.substr(1)):e&&(this.search="",this.query={}),this}var x=o.exec(v);if(x){var w=(x=x[0]).toLowerCase();this.protocol=w,v=v.substr(x.length)}if(r||x||v.match(/^\/\/[^@\/]+@[^@\/]+/)){var E="//"===v.substr(0,2);!E||x&&y[x]||(v=v.substr(2),this.slashes=!0)}if(!y[x]&&(E||x&&!g[x])){for(var F,T,I=-1,k=0;k<h.length;k++)-1!==(A=v.indexOf(h[k]))&&(-1===I||A<I)&&(I=A);for(-1!==(T=-1===I?v.lastIndexOf("@"):v.lastIndexOf("@",I))&&(F=v.slice(0,T),v=v.slice(T+1),this.auth=decodeURIComponent(F)),I=-1,k=0;k<f.length;k++){var A;-1!==(A=v.indexOf(f[k]))&&(-1===I||A<I)&&(I=A)}-1===I&&(I=v.length),this.host=v.slice(0,I),v=v.slice(I),this.parseHost(),this.hostname=this.hostname||"";var C="["===this.hostname[0]&&"]"===this.hostname[this.hostname.length-1];if(!C)for(var S=this.hostname.split(/\./),j=(k=0,S.length);k<j;k++){var O=S[k];if(O&&!O.match(p)){for(var D="",P=0,N=O.length;P<N;P++)O.charCodeAt(P)>127?D+="x":D+=O[P];if(!D.match(p)){var R=S.slice(0,k),L=S.slice(k+1),U=O.match(d);U&&(R.push(U[1]),L.unshift(U[2])),L.length&&(v="/"+L.join(".")+v),this.hostname=R.join(".");break}}}this.hostname.length>255?this.hostname="":this.hostname=this.hostname.toLowerCase(),C||(this.hostname=n.toASCII(this.hostname));var B=this.port?":"+this.port:"",$=this.hostname||"";this.host=$+B,this.href+=this.host,C&&(this.hostname=this.hostname.substr(1,this.hostname.length-2),"/"!==v[0]&&(v="/"+v))}if(!_[w])for(k=0,j=l.length;k<j;k++){var q=l[k];if(-1!==v.indexOf(q)){var M=encodeURIComponent(q);M===q&&(M=escape(q)),v=v.split(q).join(M)}}var G=v.indexOf("#");-1!==G&&(this.hash=v.substr(G),v=v.slice(0,G));var z=v.indexOf("?");if(-1!==z?(this.search=v.substr(z),this.query=v.substr(z+1),e&&(this.query=b.parse(this.query)),v=v.slice(0,z)):e&&(this.search="",this.query={}),v&&(this.pathname=v),g[w]&&this.hostname&&!this.pathname&&(this.pathname="/"),this.pathname||this.search){B=this.pathname||"";var V=this.search||"";this.path=B+V}return this.href=this.format(),this},s.prototype.format=function(){var t=this.auth||"";t&&(t=(t=encodeURIComponent(t)).replace(/%3A/i,":"),t+="@");var e=this.protocol||"",r=this.pathname||"",n=this.hash||"",s=!1,o="";this.host?s=t+this.host:this.hostname&&(s=t+(-1===this.hostname.indexOf(":")?this.hostname:"["+this.hostname+"]"),this.port&&(s+=":"+this.port)),this.query&&i.isObject(this.query)&&Object.keys(this.query).length&&(o=b.stringify(this.query));var a=this.search||o&&"?"+o||"";return e&&":"!==e.substr(-1)&&(e+=":"),this.slashes||(!e||g[e])&&!1!==s?(s="//"+(s||""),r&&"/"!==r.charAt(0)&&(r="/"+r)):s||(s=""),n&&"#"!==n.charAt(0)&&(n="#"+n),a&&"?"!==a.charAt(0)&&(a="?"+a),e+s+(r=r.replace(/[?#]/g,(function(t){return encodeURIComponent(t)})))+(a=a.replace("#","%23"))+n},s.prototype.resolve=function(t){return this.resolveObject(v(t,!1,!0)).format()},s.prototype.resolveObject=function(t){if(i.isString(t)){var e=new s;e.parse(t,!1,!0),t=e}for(var r=new s,n=Object.keys(this),o=0;o<n.length;o++){var a=n[o];r[a]=this[a]}if(r.hash=t.hash,""===t.href)return r.href=r.format(),r;if(t.slashes&&!t.protocol){for(var u=Object.keys(t),c=0;c<u.length;c++){var l=u[c];"protocol"!==l&&(r[l]=t[l])}return g[r.protocol]&&r.hostname&&!r.pathname&&(r.path=r.pathname="/"),r.href=r.format(),r}if(t.protocol&&t.protocol!==r.protocol){if(!g[t.protocol]){for(var f=Object.keys(t),h=0;h<f.length;h++){var p=f[h];r[p]=t[p]}return r.href=r.format(),r}if(r.protocol=t.protocol,t.host||y[t.protocol])r.pathname=t.pathname;else{for(var d=(t.pathname||"").split("/");d.length&&!(t.host=d.shift()););t.host||(t.host=""),t.hostname||(t.hostname=""),""!==d[0]&&d.unshift(""),d.length<2&&d.unshift(""),r.pathname=d.join("/")}if(r.search=t.search,r.query=t.query,r.host=t.host||"",r.auth=t.auth,r.hostname=t.hostname||t.host,r.port=t.port,r.pathname||r.search){var _=r.pathname||"",b=r.search||"";r.path=_+b}return r.slashes=r.slashes||t.slashes,r.href=r.format(),r}var v=r.pathname&&"/"===r.pathname.charAt(0),m=t.host||t.pathname&&"/"===t.pathname.charAt(0),x=m||v||r.host&&t.pathname,w=x,E=r.pathname&&r.pathname.split("/")||[],F=(d=t.pathname&&t.pathname.split("/")||[],r.protocol&&!g[r.protocol]);if(F&&(r.hostname="",r.port=null,r.host&&(""===E[0]?E[0]=r.host:E.unshift(r.host)),r.host="",t.protocol&&(t.hostname=null,t.port=null,t.host&&(""===d[0]?d[0]=t.host:d.unshift(t.host)),t.host=null),x=x&&(""===d[0]||""===E[0])),m)r.host=t.host||""===t.host?t.host:r.host,r.hostname=t.hostname||""===t.hostname?t.hostname:r.hostname,r.search=t.search,r.query=t.query,E=d;else if(d.length)E||(E=[]),E.pop(),E=E.concat(d),r.search=t.search,r.query=t.query;else if(!i.isNullOrUndefined(t.search))return F&&(r.hostname=r.host=E.shift(),(C=!!(r.host&&r.host.indexOf("@")>0)&&r.host.split("@"))&&(r.auth=C.shift(),r.host=r.hostname=C.shift())),r.search=t.search,r.query=t.query,i.isNull(r.pathname)&&i.isNull(r.search)||(r.path=(r.pathname?r.pathname:"")+(r.search?r.search:"")),r.href=r.format(),r;if(!E.length)return r.pathname=null,r.search?r.path="/"+r.search:r.path=null,r.href=r.format(),r;for(var T=E.slice(-1)[0],I=(r.host||t.host||E.length>1)&&("."===T||".."===T)||""===T,k=0,A=E.length;A>=0;A--)"."===(T=E[A])?E.splice(A,1):".."===T?(E.splice(A,1),k++):k&&(E.splice(A,1),k--);if(!x&&!w)for(;k--;k)E.unshift("..");!x||""===E[0]||E[0]&&"/"===E[0].charAt(0)||E.unshift(""),I&&"/"!==E.join("/").substr(-1)&&E.push("");var C,S=""===E[0]||E[0]&&"/"===E[0].charAt(0);return F&&(r.hostname=r.host=S?"":E.length?E.shift():"",(C=!!(r.host&&r.host.indexOf("@")>0)&&r.host.split("@"))&&(r.auth=C.shift(),r.host=r.hostname=C.shift())),(x=x||r.host&&E.length)&&!S&&E.unshift(""),E.length?r.pathname=E.join("/"):(r.pathname=null,r.path=null),i.isNull(r.pathname)&&i.isNull(r.search)||(r.path=(r.pathname?r.pathname:"")+(r.search?r.search:"")),r.auth=t.auth||r.auth,r.slashes=r.slashes||t.slashes,r.href=r.format(),r},s.prototype.parseHost=function(){var t=this.host,e=a.exec(t);e&&(":"!==(e=e[0])&&(this.port=e.substr(1)),t=t.substr(0,t.length-e.length)),t&&(this.hostname=t)}},{"./util":15,punycode:9,querystring:12}],15:[function(t,e,r){"use strict";e.exports={isString:function(t){return"string"==typeof t},isObject:function(t){return"object"==typeof t&&null!==t},isNull:function(t){return null===t},isNullOrUndefined:function(t){return null==t}}},{}],16:[function(t,e,r){arguments[4][2][0].apply(r,arguments)},{dup:2}],17:[function(t,e,r){arguments[4][3][0].apply(r,arguments)},{dup:3}],18:[function(t,e,r){arguments[4][4][0].apply(r,arguments)},{"./support/isBuffer":17,_process:8,dup:4,inherits:16}],19:[function(t,e,r){var n=t("events").EventEmitter,i=t("asynciterator"),s=t("parse-link-header"),o=t("lodash");t("setimmediate");var a=o.object(["accept-encoding","user-agent","referer"]),u=Object.create(null);function c(t){return t?t.replace(/\?.*$/,""):""}e.exports=function(t){u[c(t.url)]&&delete t.headers["accept-datetime"];var e=new XMLHttpRequest,r=t.headers;for(var o in e.open(t.method,t.url,!0),e.timeout=t.timeout,r)!(o in a)&&r[o]&&e.setRequestHeader(o,r[o]);var l=new n;return l.abort=function(){e.abort()},e.onload=function(){var n=i.single(e.responseText||"");n.statusCode=e.status;for(var o,a=n.headers={},f=e.getAllResponseHeaders()||"",h=/^([^:\n\r]+):[ \t]*([^\r\n]*)$/gm;o=h.exec(f);)a[o[1].toLowerCase()]=o[2];if(l.emit("response",n),r["accept-datetime"]&&a["memento-datetime"]){var p=c(a["content-location"]||t.url);if(!u[p]){var d=a.link&&s(a.link);p!==c(d&&d.timegate&&d.timegate.url)&&(u[p]=!0)}}},e.onerror=function(){l.emit("error",new Error("Error requesting "+t.url))},e.ontimeout=function(){l.emit("error",new Error("Timeout requesting "+t.url))},e.send(),l}},{asynciterator:42,events:6,lodash:49,"parse-link-header":59,setimmediate:62}],20:[function(t,e,r){r.createHash=function(){var t;return{update:function(e){t?t+=e:t=e},digest:function(){return function(t){var e,r,u,c=(t+="€").length,l=~~((c/4+2+15)/16),f=new Array(l);for(e=0,u=0;e<l;e++)for(f[e]=new Array(16),r=0;r<16;r++,u++)f[e][r]=(u<c?t.charCodeAt(u)<<24:0)|(++u<c?t.charCodeAt(u)<<16:0)|(++u<c?t.charCodeAt(u)<<8:0)|(++u<c?t.charCodeAt(u):0);f[l-1][14]=~~((t.length-1)/i),f[l-1][15]=8*(t.length-1)&4294967295;var h,p,d,_,y,g,b=1732584193,v=4023233417,m=2562383102,x=271733878,w=3285377520,E=new Array(80);for(e=0;e<l;e++){for(g=0;g<16;g++)E[g]=f[e][g];for(g=16;g<80;g++)E[g]=o(E[g-3]^E[g-8]^E[g-14]^E[g-16],1);for(h=b,p=v,d=m,_=x,y=w,g=0;g<80;g++){var F=~~(g/20),T=o(h,5)+s(F,p,d,_)+y+n[F]+E[g]&4294967295;y=_,_=d,d=o(p,30),p=h,h=T}b=b+h&4294967295,v=v+p&4294967295,m=m+d&4294967295,x=x+_&4294967295,w=w+y&4294967295}return a(b)+a(v)+a(m)+a(x)+a(w)}(t)}}};var n=[1518500249,1859775393,2400959708,3395469782],i=Math.pow(2,35);function s(t,e,r,n){switch(t){case 0:return e&r^~e&n;case 1:case 3:return e^r^n;case 2:return e&r^e&n^r&n}}function o(t,e){return t<<e|t>>>32-e}function a(t){for(var e="",r=7;r>=0;r--)e+=(t>>>4*r&15).toString(16);return e}},{}],21:[function(t,e,r){var n=t("./MetadataExtractor"),i=t("lodash");function s(t){if(!(this instanceof s))return new s(t);n.call(this),this._extractors=i.isArray(t)?{"":t}:t,i.any(this._extractors,"length")||(this._extractors=null)}n.inherits(s),s.prototype._extract=function(t,e,r){i.each(this._extractors||r(null,{})&&null,(function(n,s){var o,a=n.length;function u(t,e){t||(o=o?i.defaults(o,e):e),0==--a&&(s&&(e=o,(o={})[s]=e),r(null,o||{}))}i.each(n,(function(r){r.extract(t,e,u)}))}))},e.exports=s},{"./MetadataExtractor":24,lodash:49}],22:[function(t,e,r){var n=t("./MetadataExtractor"),i=t("uritemplate"),s=t("../util/RdfUtil"),o=t("assert"),a=["first","next","previous","last"],u={getFragmentUrl:function(t){throw new Error("The fragment "+this.fragment+" does not contain Triple Pattern Fragment hypermedia controls.")}};function c(){if(!(this instanceof c))return new c;n.call(this)}a.forEach((function(t){Object.defineProperty(u,t,{get:function(){throw new Error("The fragment "+this.fragment+" does not contain controls for "+t+".")}})})),n.inherits(c),c.prototype._extract=function(t,e,r){var n=Object.create(null);e.on("data",(function(t){if(0===t.predicate.indexOf(s.HYDRA)){var e=t.predicate.substr(s.HYDRA.length),r=n[e]||(n[e]={});(r[t.subject]||(r[t.subject]=[])).push(t.object)}})),e.on("end",(function(){var e=Object.create(u);e.fragment=t.fragmentUrl,a.forEach((function(t){var r=n[t]||n[t+"Page"],i=r&&r[e.fragment];i&&i.length>0&&Object.defineProperty(e,t,{value:i[0],enumerable:!0})}));var c=n.search;if(c){var l=c[Object.keys(c)[0]][0],f=(n.template||{})[l]||[];o(1===f.length,"Expected 1 hydra:template for "+l);var h=s.getLiteralValue(f[0]),p=i.parse(h),d=(n.mapping||{})[l]||[];o(d.length>=3,"Expected at least 3 hydra:mappings for "+l),d=d.reduce((function(t,e){var r=((n.variable||{})[e]||[])[0],i=((n.property||{})[e]||[])[0];return o(r,"Expected a hydra:variable for "+e),o(i,"Expected a hydra:property for "+e),t[i]=s.getLiteralValue(r),t}),{}),e.getFragmentUrl=function(t){var e={};return e[d[s.RDF_SUBJECT]]=t.subject,e[d[s.RDF_PREDICATE]]=t.predicate,e[d[s.RDF_OBJECT]]=t.object,p.expand(e)}}r(null,e)}))},e.exports=c},{"../util/RdfUtil":39,"./MetadataExtractor":24,assert:1,uritemplate:66}],23:[function(t,e,r){var n=t("./MetadataExtractor"),i=t("../util/RdfUtil"),s=a([i.VOID_TRIPLES,i.HYDRA_TOTALITEMS]);function o(t){if(!(this instanceof o))return new o(t);n.call(this),this._countPredicates=a(t&&t.countPredicates)||s}function a(t){return t&&t.reduce((function(t,e){return t[e]=!0,t}),Object.create(null))}n.inherits(o),o.prototype._extract=function(t,e,r){var n=this._countPredicates;function s(e){if(e.predicate in n&&i.decodedURIEquals(e.subject,t.fragmentUrl)){var r=e.object.match(/\d+/);r&&o({totalTriples:parseInt(r[0],10)})}}function o(t){e.removeListener("end",o),e.removeListener("data",s),r(null,t||{})}e.on("end",o),e.on("data",s)},e.exports=o},{"../util/RdfUtil":39,"./MetadataExtractor":24}],24:[function(t,e,r){var n=t("util");function i(){if(!(this instanceof i))return new i}i.inherits=function(t){n.inherits(t,this),t.inherits=this.inherits},i.prototype.extract=function(t,e,r){if(r)return e?void this._extract(t||{},e,r):r(null,{})},i.prototype._extract=function(t,e,r){throw new Error("Not implemented")},e.exports=i},{util:18}],25:[function(t,e,r){var n=t("asynciterator").SimpleTransformIterator,i=t("crypto");function s(t,e){if(!(this instanceof s))return new s(t,e);n.call(this,t,e),this._uniques=Object.create(null)}n.subclass(s),s.prototype._filter=function(t){var e=this._uniques,r=this._hash(t);r in e||(e[r]=!0,this._push(t))},s.prototype._hash=function(t){var e=i.createHash("sha1");return e.update(JSON.stringify(t)),e.digest("base64")},e.exports=s},{asynciterator:42,crypto:20}],26:[function(t,e,r){var n=t("asynciterator").TransformIterator;function i(t,e,r){if(!(this instanceof i))return new i(t,e,r);"function"!=typeof e&&(r=e,e=null),n.call(this,t,r);var o=r&&r.window;this._windowLength=isFinite(o)&&o>0?~~o:1/0,this._sort=e||s,this._sorted=[]}function s(t,e){return t<e?-1:t>e?1:0}n.subclass(i),i.prototype._read=function(t,e){var r,n=this._sorted,i=this._source,s=n.length;if(i){for(;s!==this._windowLength&&null!==(r=i.read());){for(var o,a,u=0,c=s-1;u<=c;)(a=this._sort(r,n[o=u+c>>1]))<0?u=o+1:a>0?c=o-1:(u=o,c=-1);n.splice(u,0,r),s++}s===this._windowLength&&this._push(n.pop())}e()},i.prototype._flush=function(t){for(var e=this._sorted,r=e.length;r--;)this._push(e.pop());t()},e.exports=i},{asynciterator:42}],27:[function(t,e,r){var n=t("sparqljs").Parser,i=t("asynciterator"),s=i.TransformIterator,o=t("../triple-pattern-fragments/ReorderingGraphPatternIterator"),a=t("./UnionIterator"),u=t("./SortIterator"),c=t("./DistinctIterator"),l=t("../util/SparqlExpressionEvaluator"),f=t("lodash"),h=t("../util/RdfUtil"),p=t("../util/CustomError"),d={SELECT:y,CONSTRUCT:g,DESCRIBE:b,ASK:v};function _(t,e,r){"function"!=typeof t.read&&(r=e,e=t,t=null),r=r||{},t=t||i.single({});try{"string"==typeof e&&(e=new n(r.prefixes).parse(e));var s,o=d[e.queryType];if(!o)throw new Error("No iterator available for query type: "+e.queryType);for(var a=new m(t,(s=new o(null,e,r)).patterns||e.where,r),f=e.order&&e.order.length-1;f>=0;f--){var h=new l(e.order[f].expression),p=!e.order[f].descending;a=new u(a,(function(t,e){var r="",n="";try{r=h(t)}catch(t){}try{n=h(e)}catch(t){}return r<n?p?-1:1:r>n?p?1:-1:0}),r)}return s.source=a,e.distinct&&(s=new c(s,r)),("offset"in e||"limit"in e)&&(s=s.transform({offset:e.offset,limit:e.limit})),s.queryType=e.queryType,s}catch(t){throw t=/Parse error/.test(t.message)?new w(e,t):new E(e,t)}}function y(t,e,r){s.call(this,t,r),this.setProperty("variables",e.variables)}function g(t,e,r){s.call(this,t,r),this._template=e.template.filter((function(t){return h.hasVariables(t)||this._push(t)}),this),this._blankNodeId=0}function b(t,e,r){for(var n=e.variables,i=e.template=[],s=0,o=n.length;s<o;s++)i.push(h.triple(n[s],"?__predicate"+s,"?__object"+s));e.where=(e.where||[]).concat({type:"bgp",triples:i}),g.call(this,t,e,r)}function v(t,e,r){s.call(this,t,r),this._result=!1}function m(t,e,r){return e.reduce((function(t,e){return new x(t,e,r)}),t)}function x(t,e,r){var n=r.optional?f.create(r,{optional:!1}):r;switch(e.type){case"bgp":return new o(t,e.triples,r);case"group":return new m(t,e.patterns,n);case"optional":return n=f.create(r,{optional:!0}),new m(t,e.patterns,n);case"union":return new a(e.patterns.map((function(e){return new x(t.clone(),e,n)})),r);case"filter":var i=new l(e.expression);return t.filter((function(t){try{return!/^"false"|^"0"/.test(i(t))}catch(t){return!1}}));default:throw new Error("Unsupported group type: "+e.type)}}s.subclass(_),_.subclass(y),y.prototype._transform=function(t,e){function r(e){var r=t[e];return"string"==typeof r?h.deskolemize(r):null}this._push(this.getProperty("variables").reduce((function(e,n){if("*"!==n)e[n]=r(n);else for(n in t)h.isVariable(n)&&(e[n]=r(n));return e}),Object.create(null))),e()},_.subclass(g),g.prototype._transform=function(t,e){var r=Object.create(null);this._template.forEach((function(e){var n=e.subject,i=e.predicate,s=e.object,o=n[0],a=i[0],u=s[0];if("?"===o){if(void 0===(n=h.deskolemize(t[n])))return}else"_"===o&&(n=r[n]||(r[n]="_:b"+this._blankNodeId++));if("?"===a){if(void 0===(i=h.deskolemize(t[i])))return}else"_"===a&&(i=r[i]||(r[i]="_:b"+this._blankNodeId++));if("?"===u){if(void 0===(s=h.deskolemize(t[s])))return}else"_"===u&&(s=r[s]||(r[s]="_:b"+this._blankNodeId++));this._push({subject:n,predicate:i,object:s})}),this),e()},g.subclass(b),_.subclass(v),v.prototype._transform=function(t,e){this._result=!0,this.close(),e()},v.prototype._flush=function(t){this._push(this._result),t()},i.subclass(m),i.subclass(x);var w=p("InvalidQueryError",(function(t,e){this.message="Syntax error in query\n"+e.message})),E=p("UnsupportedQueryError",(function(t,e){this.message="The query is not yet supported\n"+e.message}));e.exports=_,_.InvalidQueryError=w,_.UnsupportedQueryError=E},{"../triple-pattern-fragments/ReorderingGraphPatternIterator":30,"../util/CustomError":35,"../util/RdfUtil":39,"../util/SparqlExpressionEvaluator":40,"./DistinctIterator":25,"./SortIterator":26,"./UnionIterator":28,asynciterator:42,lodash:49,sparqljs:65}],28:[function(t,e,r){var n=t("asynciterator").BufferedIterator;function i(t,e){if(!(this instanceof i))return new i(t,e);if(n.call(this,e),this._sources=[],this._sourceIndex=0,t&&t.length){var r=this;function s(){r._fillBuffer()}function o(t){r.emit("error",t)}for(var a=0,u=t.length;a<u;a++){var c=t[a];c&&!c.ended&&(this._sources.push(c),c.on("readable",s),c.on("end",s),c.on("error",o))}}}n.subclass(i),i.prototype._read=function(t,e){for(var r=this._sources,n=null,i=r.length;null===n&&i--;){var s=r[this._sourceIndex];n=s.read(),s.ended?r.splice(this._sourceIndex,1):this._sourceIndex++,this._sourceIndex>=r.length&&(this._sourceIndex=0)}null!==n&&this._push(n),r.length||this.close(),e()},e.exports=i},{asynciterator:42}],29:[function(t,e,r){(function(r){var n=t("../util/HttpClient"),i=t("asynciterator").BufferedIterator,s=t("../util/RdfUtil"),o=t("lru-cache"),a=t("../extractors/CompositeExtractor"),u=t("../extractors/CountExtractor"),c=t("../extractors/ControlsExtractor"),l=t("lodash"),f=[t("./TrigFragmentIterator"),t("./TurtleFragmentIterator")];function h(t,e){if(!(this instanceof h))return new h(t,e);e=l.defaults(e||{},{contentType:"application/trig;q=1.0,application/n-quads;q=0.7,text/turtle;q=0.6,application/n-triples;q=0.3,text/n3;q=0.2"});var r=this._cache=new o({max:100});if(this._httpClient=e.httpClient||new n(e),this._metadataExtractor=e.metadataExtractor||new a({metadata:[new u],controls:[new c]}),t){if("string"==typeof t){var i=this._startFragmentUrl=t;(t=new p(this)).loadFromUrl(i)}this._startFragment=t,t.setMaxListeners(100),t.once("error",(function(e){r.reset(),t.error=e})),t.getProperty("controls",(function(){t.error=null,t.removeAllListeners("error")}))}}function p(t,e){if(!(this instanceof p))return new p(t);i.call(this),this._fragmentsClient=t,this._pattern=e}h.prototype.getFragmentByPattern=function(t){var e=this._cache,n=JSON.stringify(t);if(e.has(n))return e.get(n).clone();var i=new p(this,t),o=this._startFragment;if(null!==o.error){if(o.error)return r(a),i;o.once("error",a)}function a(){i.emit("error",o.error),i.close()}return o.getProperty("controls",(function(e){var r=s.isVariableOrBlank(t.subject)?null:t.subject,n=s.isVariableOrBlank(t.predicate)?null:t.predicate,o=s.isVariableOrBlank(t.object)?null:t.object;if(s.isLiteral(r)||s.isLiteral(n))return i.empty();t={subject:r,predicate:n,object:o},i.loadFromUrl(e.getFragmentUrl(t))})),e.set(n,i),i.clone()},h.prototype.abortAll=function(){this._httpClient.abortAll()},h.prototype.getRequestCount=function(){return this._httpClient?this._httpClient._requestId:0},i.subclass(p),p.prototype._read=function(t,e){for(var r;t-- >0&&this._page&&(r=this._page.read());)this._push(r);e()},p.prototype.loadFromUrl=function(t){var e,n=this,i=this._fragmentsClient,s={"user-agent":"Triple Pattern Fragments Client"};i._startFragmentUrl&&(s.referer=i._startFragmentUrl),(e=i._httpClient.get(t,s)).on("error",(function(t){n.emit("error",t)})),e.getProperty("statusCode",(function(s){if(200!==s)return e.emit("error",new Error("Could not retrieve "+t+" ("+s+")")),n.close();e.getProperty("contentType",(function(s){var o=l.find(f,(function(t){return t.supportsContentType(s)}));if(!o)return n.emit("error",new Error("No parser for "+s+" at "+t));var a=n._page=new o(e,t);a.on("readable",(function(){n.readable=!0}));var u={};function c(){var t;try{t=u&&u.next}catch(t){}t?n.loadFromUrl(t):n.close()}i._metadataExtractor.extract({fragmentUrl:t},a.metadataStream,(function(t,e){for(var r in e)n.getProperty(r)||n.setProperty(r,e[r]);u=e.controls||u})),a.on("end",(function(){r(c)})),a.on("error",(function(t){n.emit("error",t)})),n.readable=!0}))}))},p.prototype.empty=function(){return this.getProperty("metadata")||this.setProperty("metadata",{totalTriples:0}),this.close(),this},p.prototype.toString=function(){return"["+this.constructor.name+" {"+s.toQuickString(this._pattern)+")}"},e.exports=h}).call(this,t("timers").setImmediate)},{"../extractors/CompositeExtractor":21,"../extractors/ControlsExtractor":22,"../extractors/CountExtractor":23,"../util/HttpClient":37,"../util/RdfUtil":39,"./TrigFragmentIterator":31,"./TurtleFragmentIterator":33,asynciterator:42,lodash:49,"lru-cache":50,timers:13}],30:[function(t,e,r){var n=t("asynciterator"),i=n.TransformIterator,s=n.MultiTransformIterator,o=t("../util/RdfUtil"),a=t("lodash"),u=t("../util/ExecutionLogger")("ReorderingGraphPatternIterator"),c=t("./TriplePatternIterator");function l(t,e,r){return e&&e.length?1===e.length?new c(t,e[0],r):this instanceof l?(s.call(this,t,r),this._pattern=e,this._options=r||(r={}),void(this._client=r.fragmentsClient)):new l(t,e,r):new i(t,r)}s.subclass(l),l.prototype._createTransformer=function(t){var e,r=o.applyBindings(t,this._pattern),s=this._options,f=a.sortBy(o.findConnectedPatterns(r),(function(t){var e=a.union.apply(a,t.map(o.getVariables)).length;return-(r.length*e+t.length)})),h=f.pop