@fastintegration/controller
Version:
BIPBOP integration services, backend client.
27 lines (25 loc) • 31.2 kB
JavaScript
/**
* Bundle of @fastintegration/controller
* Generated: 2018-05-08
* Version: 1.2.3
* Dependencies:
*
* es6-error -- 4.1.1
*
* superoverload -- 1.2.3
*
* human-interval -- 0.1.6
*
* lodash -- 4.17.5
*
* p-timeout -- 2.0.1
*
* p-finally -- 1.0.0
*
* local-storage -- 1.4.2
*
* escape-firebase -- 1.0.1
*
* unfetch -- 3.0.0
*/
;function _interopDefault(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var firebase=_interopDefault(require("firebase"));function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _possibleConstructorReturn(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function _inherits(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}function _extendableBuiltin(e){function t(){e.apply(this,arguments)}return t.prototype=Object.create(e.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e,t}var ExtendableError=function(e){function r(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:"";_classCallCheck(this,r);var t=_possibleConstructorReturn(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,e));return Object.defineProperty(t,"message",{configurable:!0,enumerable:!1,value:e,writable:!0}),Object.defineProperty(t,"name",{configurable:!0,enumerable:!1,value:t.constructor.name,writable:!0}),Error.hasOwnProperty("captureStackTrace")?(Error.captureStackTrace(t,t.constructor),_possibleConstructorReturn(t)):(Object.defineProperty(t,"stack",{configurable:!0,enumerable:!1,value:new Error(e).stack,writable:!0}),t)}return _inherits(r,_extendableBuiltin(Error)),r}(),commonjsGlobal="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function createCommonjsModule(e,t){return e(t={exports:{}},t.exports),t.exports}var build=createCommonjsModule(function(e,t){e.exports=function(){var r=/\s([a-zA-Z]+)/;function b(e){if(null===e)return"null";if(void 0===e)return"undefined";var t=Object.prototype.toString.call(e).match(r);if(!Array.isArray(t))throw new Error("Unexpected type of arg "+String(e));return t[1].toLowerCase()}function v(e){return e.map(function(e,t){return"_"+t}).join(",")}var d=["number","string","array","object","function","regexp","date"].reduce(function(e,t){return e[t]=!0,e},{});return function(){for(var e=arguments,t=arguments.length,r=Array(t),n=0;n<t;n++)r[n]=e[n];for(var a=0<r.length%2?r.shift():null,o=function(e){for(var t=[],r=0,n=e.length;r<n;r++){var a=e[r],o=Math.floor(r/2);t[o]=t[o]||[],t[o].push(a)}return t}(r),i=new Array(o.length),s=new Array(o.length),c=[],u=0;u<o.length;u++){var l=o[u],f=l[0],p=l[1],_=f.filter(function(e){return!d[e]});if(0<_.length)throw new Error('Signature "'+f.join(", ")+'" contains unsupported types: "'+_.join(", ")+'"');var y=f.join(", ");s[u]=p,f.length>c.length&&(c=f),i[u]="\nif (hashKey === '"+y+"') {\n return fns["+String(u)+"].call(this, "+v(f)+");\n}"}var h=i.join(" else "),g="\nreturn function overloadedFn("+v(c)+") {\n var hashKey = '';\n var len = arguments.length;\n var args = new Array(len);\n\n for (var i = 0; i < len; i++) {\n args[i] = arguments[i];\n }\n\n for (var i = 0; i < len; i++) {\n hashKey += getType(args[i]);\n if (i !== len - 1) {\n hashKey += ', ';\n }\n }\n "+h+"\n "+(0<o.length?"else {":"")+"\n if (!defaultFn) {\n throw new Error('No matching function for call with signature \"' + hashKey + '\"');\n }\n "+(0<o.length?"}":"")+"\n return defaultFn.apply(this, arguments);\n}";return new Function("getType, fns, defaultFn",g)(b,s,a)}}()}),FastIntegrationError=function(e){function t(){e.apply(this,arguments)}return e&&(t.__proto__=e),(t.prototype=Object.create(e&&e.prototype)).constructor=t}(ExtendableError),FastIntegrationWebServiceError=function(e){function t(){e.apply(this,arguments)}return e&&(t.__proto__=e),(t.prototype=Object.create(e&&e.prototype)).constructor=t}(FastIntegrationError),errorFactory=build(function(){return new FastIntegrationError},["string"],function(e){return new FastIntegrationError(e)},["object"],function(e){var t=e.message,r=e.source,n=e.code,a=e.log;return Object.assign(new FastIntegrationError(t),{source:r,code:n,log:a})},["string","number"],function(e,t){return Object.assign(new FastIntegrationError(e),{code:t})},["string","string"],function(e,t){return Object.assign(new FastIntegrationError(e),{code:parseInt(t,10)})}),errorFactory$1=Object.freeze({FastIntegrationError:FastIntegrationError,FastIntegrationWebServiceError:FastIntegrationWebServiceError,default:errorFactory}),humanInterval_1=createCommonjsModule(function(e){var a=e.exports=function(e){return e?"number"==typeof e?e:(e=(e=function(r){var n=a.languageMap,e=new RegExp("("+Object.keys(n).join("|")+")","g"),t=r.match(e);if(!t)return r;return t.forEach(function(e){var t=1<n[e]?n[e]:n[e].toString().slice(1);r=r.replace(e,t)}),r}(e)).replace(/(second|minute|hour|day|week|month|year)s?(?! ?(s )?and |s?$)/,"$1,")).split(/and|,/).reduce(function(e,t){return e+(""!==t?function(e){var t,r=parseFloat(e,10);t=null!==e.match(/(second|minute|hour|day|week|month|year)s?/)?e.match(/(second|minute|hour|day|week|month|year)s?/)[1]:void 0;r||(r=1);switch(t){case"second":t=1e3;break;case"minute":t=6e4;break;case"hour":t=36e5;break;case"day":t=864e5;break;case"week":t=6048e5;break;case"month":t=2592e6;break;case"year":t=31536e6}return t*r}(t):0)},0):e};a.languageMap={one:1,two:2,three:3,four:4,five:5,six:6,seven:7,eight:8,nine:9,ten:10}});function apply(e,t,r){switch(r.length){case 0:return e.call(t);case 1:return e.call(t,r[0]);case 2:return e.call(t,r[0],r[1]);case 3:return e.call(t,r[0],r[1],r[2])}return e.apply(t,r)}var _apply=apply;function identity(e){return e}var identity_1=identity,nativeMax=Math.max;function overRest(o,i,s){return i=nativeMax(void 0===i?o.length-1:i,0),function(){for(var e=arguments,t=-1,r=nativeMax(e.length-i,0),n=Array(r);++t<r;)n[t]=e[i+t];t=-1;for(var a=Array(i+1);++t<i;)a[t]=e[t];return a[i]=s(n),_apply(o,this,a)}}var _overRest=overRest;function constant(e){return function(){return e}}var constant_1=constant,freeGlobal="object"==typeof commonjsGlobal&&commonjsGlobal&&commonjsGlobal.Object===Object&&commonjsGlobal,_freeGlobal=freeGlobal,freeSelf="object"==typeof self&&self&&self.Object===Object&&self,root=_freeGlobal||freeSelf||Function("return this")(),_root=root,Symbol=_root.Symbol,_Symbol=Symbol,objectProto=Object.prototype,hasOwnProperty=objectProto.hasOwnProperty,nativeObjectToString=objectProto.toString,symToStringTag=_Symbol?_Symbol.toStringTag:void 0;function getRawTag(e){var t=hasOwnProperty.call(e,symToStringTag),r=e[symToStringTag];try{var n=!(e[symToStringTag]=void 0)}catch(e){}var a=nativeObjectToString.call(e);return n&&(t?e[symToStringTag]=r:delete e[symToStringTag]),a}var _getRawTag=getRawTag,objectProto$1=Object.prototype,nativeObjectToString$1=objectProto$1.toString;function objectToString(e){return nativeObjectToString$1.call(e)}var _objectToString=objectToString,nullTag="[object Null]",undefinedTag="[object Undefined]",symToStringTag$1=_Symbol?_Symbol.toStringTag:void 0;function baseGetTag(e){return null==e?void 0===e?undefinedTag:nullTag:symToStringTag$1&&symToStringTag$1 in Object(e)?_getRawTag(e):_objectToString(e)}var _baseGetTag=baseGetTag;function isObject(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}var isObject_1=isObject,asyncTag="[object AsyncFunction]",funcTag="[object Function]",genTag="[object GeneratorFunction]",proxyTag="[object Proxy]";function isFunction(e){if(!isObject_1(e))return!1;var t=_baseGetTag(e);return t==funcTag||t==genTag||t==asyncTag||t==proxyTag}var isFunction_1=isFunction,coreJsData=_root["__core-js_shared__"],_coreJsData=coreJsData,maskSrcKey=function(){var e=/[^.]+$/.exec(_coreJsData&&_coreJsData.keys&&_coreJsData.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}();function isMasked(e){return!!maskSrcKey&&maskSrcKey in e}var _isMasked=isMasked,funcProto=Function.prototype,funcToString=funcProto.toString;function toSource(e){if(null!=e){try{return funcToString.call(e)}catch(e){}try{return e+""}catch(e){}}return""}var _toSource=toSource,reRegExpChar=/[\\^$.*+?()[\]{}|]/g,reIsHostCtor=/^\[object .+?Constructor\]$/,funcProto$1=Function.prototype,objectProto$2=Object.prototype,funcToString$1=funcProto$1.toString,hasOwnProperty$1=objectProto$2.hasOwnProperty,reIsNative=RegExp("^"+funcToString$1.call(hasOwnProperty$1).replace(reRegExpChar,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function baseIsNative(e){return!(!isObject_1(e)||_isMasked(e))&&(isFunction_1(e)?reIsNative:reIsHostCtor).test(_toSource(e))}var _baseIsNative=baseIsNative;function getValue(e,t){return null==e?void 0:e[t]}var _getValue=getValue;function getNative(e,t){var r=_getValue(e,t);return _baseIsNative(r)?r:void 0}var _getNative=getNative,defineProperty=function(){try{var e=_getNative(Object,"defineProperty");return e({},"",{}),e}catch(e){}}(),_defineProperty=defineProperty,baseSetToString=_defineProperty?function(e,t){return _defineProperty(e,"toString",{configurable:!0,enumerable:!1,value:constant_1(t),writable:!0})}:identity_1,_baseSetToString=baseSetToString,HOT_COUNT=800,HOT_SPAN=16,nativeNow=Date.now;function shortOut(r){var n=0,a=0;return function(){var e=nativeNow(),t=HOT_SPAN-(e-a);if(a=e,0<t){if(++n>=HOT_COUNT)return arguments[0]}else n=0;return r.apply(void 0,arguments)}}var _shortOut=shortOut,setToString=_shortOut(_baseSetToString),_setToString=setToString;function baseRest(e,t){return _setToString(_overRest(e,t,identity_1),e+"")}var _baseRest=baseRest;function listCacheClear(){this.__data__=[],this.size=0}var _listCacheClear=listCacheClear;function eq(e,t){return e===t||e!=e&&t!=t}var eq_1=eq;function assocIndexOf(e,t){for(var r=e.length;r--;)if(eq_1(e[r][0],t))return r;return-1}var _assocIndexOf=assocIndexOf,arrayProto=Array.prototype,splice=arrayProto.splice;function listCacheDelete(e){var t=this.__data__,r=_assocIndexOf(t,e);return!(r<0)&&(r==t.length-1?t.pop():splice.call(t,r,1),--this.size,!0)}var _listCacheDelete=listCacheDelete;function listCacheGet(e){var t=this.__data__,r=_assocIndexOf(t,e);return r<0?void 0:t[r][1]}var _listCacheGet=listCacheGet;function listCacheHas(e){return-1<_assocIndexOf(this.__data__,e)}var _listCacheHas=listCacheHas;function listCacheSet(e,t){var r=this.__data__,n=_assocIndexOf(r,e);return n<0?(++this.size,r.push([e,t])):r[n][1]=t,this}var _listCacheSet=listCacheSet;function ListCache(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}ListCache.prototype.clear=_listCacheClear,ListCache.prototype.delete=_listCacheDelete,ListCache.prototype.get=_listCacheGet,ListCache.prototype.has=_listCacheHas,ListCache.prototype.set=_listCacheSet;var _ListCache=ListCache;function stackClear(){this.__data__=new _ListCache,this.size=0}var _stackClear=stackClear;function stackDelete(e){var t=this.__data__,r=t.delete(e);return this.size=t.size,r}var _stackDelete=stackDelete;function stackGet(e){return this.__data__.get(e)}var _stackGet=stackGet;function stackHas(e){return this.__data__.has(e)}var _stackHas=stackHas,Map=_getNative(_root,"Map"),_Map=Map,nativeCreate=_getNative(Object,"create"),_nativeCreate=nativeCreate;function hashClear(){this.__data__=_nativeCreate?_nativeCreate(null):{},this.size=0}var _hashClear=hashClear;function hashDelete(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}var _hashDelete=hashDelete,HASH_UNDEFINED="__lodash_hash_undefined__",objectProto$3=Object.prototype,hasOwnProperty$2=objectProto$3.hasOwnProperty;function hashGet(e){var t=this.__data__;if(_nativeCreate){var r=t[e];return r===HASH_UNDEFINED?void 0:r}return hasOwnProperty$2.call(t,e)?t[e]:void 0}var _hashGet=hashGet,objectProto$4=Object.prototype,hasOwnProperty$3=objectProto$4.hasOwnProperty;function hashHas(e){var t=this.__data__;return _nativeCreate?void 0!==t[e]:hasOwnProperty$3.call(t,e)}var _hashHas=hashHas,HASH_UNDEFINED$1="__lodash_hash_undefined__";function hashSet(e,t){var r=this.__data__;return this.size+=this.has(e)?0:1,r[e]=_nativeCreate&&void 0===t?HASH_UNDEFINED$1:t,this}var _hashSet=hashSet;function Hash(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}Hash.prototype.clear=_hashClear,Hash.prototype.delete=_hashDelete,Hash.prototype.get=_hashGet,Hash.prototype.has=_hashHas,Hash.prototype.set=_hashSet;var _Hash=Hash;function mapCacheClear(){this.size=0,this.__data__={hash:new _Hash,map:new(_Map||_ListCache),string:new _Hash}}var _mapCacheClear=mapCacheClear;function isKeyable(e){var t=typeof e;return"string"==t||"number"==t||"symbol"==t||"boolean"==t?"__proto__"!==e:null===e}var _isKeyable=isKeyable;function getMapData(e,t){var r=e.__data__;return _isKeyable(t)?r["string"==typeof t?"string":"hash"]:r.map}var _getMapData=getMapData;function mapCacheDelete(e){var t=_getMapData(this,e).delete(e);return this.size-=t?1:0,t}var _mapCacheDelete=mapCacheDelete;function mapCacheGet(e){return _getMapData(this,e).get(e)}var _mapCacheGet=mapCacheGet;function mapCacheHas(e){return _getMapData(this,e).has(e)}var _mapCacheHas=mapCacheHas;function mapCacheSet(e,t){var r=_getMapData(this,e),n=r.size;return r.set(e,t),this.size+=r.size==n?0:1,this}var _mapCacheSet=mapCacheSet;function MapCache(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}MapCache.prototype.clear=_mapCacheClear,MapCache.prototype.delete=_mapCacheDelete,MapCache.prototype.get=_mapCacheGet,MapCache.prototype.has=_mapCacheHas,MapCache.prototype.set=_mapCacheSet;var _MapCache=MapCache,LARGE_ARRAY_SIZE=200;function stackSet(e,t){var r=this.__data__;if(r instanceof _ListCache){var n=r.__data__;if(!_Map||n.length<LARGE_ARRAY_SIZE-1)return n.push([e,t]),this.size=++r.size,this;r=this.__data__=new _MapCache(n)}return r.set(e,t),this.size=r.size,this}var _stackSet=stackSet;function Stack(e){var t=this.__data__=new _ListCache(e);this.size=t.size}Stack.prototype.clear=_stackClear,Stack.prototype.delete=_stackDelete,Stack.prototype.get=_stackGet,Stack.prototype.has=_stackHas,Stack.prototype.set=_stackSet;var _Stack=Stack;function baseAssignValue(e,t,r){"__proto__"==t&&_defineProperty?_defineProperty(e,t,{configurable:!0,enumerable:!0,value:r,writable:!0}):e[t]=r}var _baseAssignValue=baseAssignValue;function assignMergeValue(e,t,r){(void 0===r||eq_1(e[t],r))&&(void 0!==r||t in e)||_baseAssignValue(e,t,r)}var _assignMergeValue=assignMergeValue;function createBaseFor(c){return function(e,t,r){for(var n=-1,a=Object(e),o=r(e),i=o.length;i--;){var s=o[c?i:++n];if(!1===t(a[s],s,a))break}return e}}var _createBaseFor=createBaseFor,baseFor=_createBaseFor(),_baseFor=baseFor,_cloneBuffer=createCommonjsModule(function(e,t){var r=t&&!t.nodeType&&t,n=r&&e&&!e.nodeType&&e,a=n&&n.exports===r?_root.Buffer:void 0,o=a?a.allocUnsafe:void 0;e.exports=function(e,t){if(t)return e.slice();var r=e.length,n=o?o(r):new e.constructor(r);return e.copy(n),n}}),Uint8Array=_root.Uint8Array,_Uint8Array=Uint8Array;function cloneArrayBuffer(e){var t=new e.constructor(e.byteLength);return new _Uint8Array(t).set(new _Uint8Array(e)),t}var _cloneArrayBuffer=cloneArrayBuffer;function cloneTypedArray(e,t){var r=t?_cloneArrayBuffer(e.buffer):e.buffer;return new e.constructor(r,e.byteOffset,e.length)}var _cloneTypedArray=cloneTypedArray;function copyArray(e,t){var r=-1,n=e.length;for(t||(t=Array(n));++r<n;)t[r]=e[r];return t}var _copyArray=copyArray,objectCreate=Object.create,baseCreate=function(){function r(){}return function(e){if(!isObject_1(e))return{};if(objectCreate)return objectCreate(e);r.prototype=e;var t=new r;return r.prototype=void 0,t}}(),_baseCreate=baseCreate;function overArg(t,r){return function(e){return t(r(e))}}var _overArg=overArg,getPrototype=_overArg(Object.getPrototypeOf,Object),_getPrototype=getPrototype,objectProto$5=Object.prototype;function isPrototype(e){var t=e&&e.constructor;return e===("function"==typeof t&&t.prototype||objectProto$5)}var _isPrototype=isPrototype;function initCloneObject(e){return"function"!=typeof e.constructor||_isPrototype(e)?{}:_baseCreate(_getPrototype(e))}var _initCloneObject=initCloneObject;function isObjectLike(e){return null!=e&&"object"==typeof e}var isObjectLike_1=isObjectLike,argsTag="[object Arguments]";function baseIsArguments(e){return isObjectLike_1(e)&&_baseGetTag(e)==argsTag}var _baseIsArguments=baseIsArguments,objectProto$6=Object.prototype,hasOwnProperty$4=objectProto$6.hasOwnProperty,propertyIsEnumerable=objectProto$6.propertyIsEnumerable,isArguments=_baseIsArguments(function(){return arguments}())?_baseIsArguments:function(e){return isObjectLike_1(e)&&hasOwnProperty$4.call(e,"callee")&&!propertyIsEnumerable.call(e,"callee")},isArguments_1=isArguments,isArray=Array.isArray,isArray_1=isArray,MAX_SAFE_INTEGER=9007199254740991;function isLength(e){return"number"==typeof e&&-1<e&&e%1==0&&e<=MAX_SAFE_INTEGER}var isLength_1=isLength;function isArrayLike(e){return null!=e&&isLength_1(e.length)&&!isFunction_1(e)}var isArrayLike_1=isArrayLike;function isArrayLikeObject(e){return isObjectLike_1(e)&&isArrayLike_1(e)}var isArrayLikeObject_1=isArrayLikeObject;function stubFalse(){return!1}var stubFalse_1=stubFalse,isBuffer_1=createCommonjsModule(function(e,t){var r=t&&!t.nodeType&&t,n=r&&e&&!e.nodeType&&e,a=n&&n.exports===r?_root.Buffer:void 0,o=(a?a.isBuffer:void 0)||stubFalse_1;e.exports=o}),objectTag="[object Object]",funcProto$2=Function.prototype,objectProto$7=Object.prototype,funcToString$2=funcProto$2.toString,hasOwnProperty$5=objectProto$7.hasOwnProperty,objectCtorString=funcToString$2.call(Object);function isPlainObject(e){if(!isObjectLike_1(e)||_baseGetTag(e)!=objectTag)return!1;var t=_getPrototype(e);if(null===t)return!0;var r=hasOwnProperty$5.call(t,"constructor")&&t.constructor;return"function"==typeof r&&r instanceof r&&funcToString$2.call(r)==objectCtorString}var isPlainObject_1=isPlainObject,argsTag$1="[object Arguments]",arrayTag="[object Array]",boolTag="[object Boolean]",dateTag="[object Date]",errorTag="[object Error]",funcTag$1="[object Function]",mapTag="[object Map]",numberTag="[object Number]",objectTag$1="[object Object]",regexpTag="[object RegExp]",setTag="[object Set]",stringTag="[object String]",weakMapTag="[object WeakMap]",arrayBufferTag="[object ArrayBuffer]",dataViewTag="[object DataView]",float32Tag="[object Float32Array]",float64Tag="[object Float64Array]",int8Tag="[object Int8Array]",int16Tag="[object Int16Array]",int32Tag="[object Int32Array]",uint8Tag="[object Uint8Array]",uint8ClampedTag="[object Uint8ClampedArray]",uint16Tag="[object Uint16Array]",uint32Tag="[object Uint32Array]",typedArrayTags={};function baseIsTypedArray(e){return isObjectLike_1(e)&&isLength_1(e.length)&&!!typedArrayTags[_baseGetTag(e)]}typedArrayTags[float32Tag]=typedArrayTags[float64Tag]=typedArrayTags[int8Tag]=typedArrayTags[int16Tag]=typedArrayTags[int32Tag]=typedArrayTags[uint8Tag]=typedArrayTags[uint8ClampedTag]=typedArrayTags[uint16Tag]=typedArrayTags[uint32Tag]=!0,typedArrayTags[argsTag$1]=typedArrayTags[arrayTag]=typedArrayTags[arrayBufferTag]=typedArrayTags[boolTag]=typedArrayTags[dataViewTag]=typedArrayTags[dateTag]=typedArrayTags[errorTag]=typedArrayTags[funcTag$1]=typedArrayTags[mapTag]=typedArrayTags[numberTag]=typedArrayTags[objectTag$1]=typedArrayTags[regexpTag]=typedArrayTags[setTag]=typedArrayTags[stringTag]=typedArrayTags[weakMapTag]=!1;var _baseIsTypedArray=baseIsTypedArray;function baseUnary(t){return function(e){return t(e)}}var _baseUnary=baseUnary,_nodeUtil=createCommonjsModule(function(e,t){var r=t&&!t.nodeType&&t,n=r&&e&&!e.nodeType&&e,a=n&&n.exports===r&&_freeGlobal.process,o=function(){try{return a&&a.binding&&a.binding("util")}catch(e){}}();e.exports=o}),nodeIsTypedArray=_nodeUtil&&_nodeUtil.isTypedArray,isTypedArray=nodeIsTypedArray?_baseUnary(nodeIsTypedArray):_baseIsTypedArray,isTypedArray_1=isTypedArray;function safeGet(e,t){return"__proto__"==t?void 0:e[t]}var _safeGet=safeGet,objectProto$8=Object.prototype,hasOwnProperty$6=objectProto$8.hasOwnProperty;function assignValue(e,t,r){var n=e[t];hasOwnProperty$6.call(e,t)&&eq_1(n,r)&&(void 0!==r||t in e)||_baseAssignValue(e,t,r)}var _assignValue=assignValue;function copyObject(e,t,r,n){var a=!r;r||(r={});for(var o=-1,i=t.length;++o<i;){var s=t[o],c=n?n(r[s],e[s],s,r,e):void 0;void 0===c&&(c=e[s]),a?_baseAssignValue(r,s,c):_assignValue(r,s,c)}return r}var _copyObject=copyObject;function baseTimes(e,t){for(var r=-1,n=Array(e);++r<e;)n[r]=t(r);return n}var _baseTimes=baseTimes,MAX_SAFE_INTEGER$1=9007199254740991,reIsUint=/^(?:0|[1-9]\d*)$/;function isIndex(e,t){var r=typeof e;return!!(t=null==t?MAX_SAFE_INTEGER$1:t)&&("number"==r||"symbol"!=r&&reIsUint.test(e))&&-1<e&&e%1==0&&e<t}var _isIndex=isIndex,objectProto$9=Object.prototype,hasOwnProperty$7=objectProto$9.hasOwnProperty;function arrayLikeKeys(e,t){var r=isArray_1(e),n=!r&&isArguments_1(e),a=!r&&!n&&isBuffer_1(e),o=!r&&!n&&!a&&isTypedArray_1(e),i=r||n||a||o,s=i?_baseTimes(e.length,String):[],c=s.length;for(var u in e)!t&&!hasOwnProperty$7.call(e,u)||i&&("length"==u||a&&("offset"==u||"parent"==u)||o&&("buffer"==u||"byteLength"==u||"byteOffset"==u)||_isIndex(u,c))||s.push(u);return s}var _arrayLikeKeys=arrayLikeKeys;function nativeKeysIn(e){var t=[];if(null!=e)for(var r in Object(e))t.push(r);return t}var _nativeKeysIn=nativeKeysIn,objectProto$10=Object.prototype,hasOwnProperty$8=objectProto$10.hasOwnProperty;function baseKeysIn(e){if(!isObject_1(e))return _nativeKeysIn(e);var t=_isPrototype(e),r=[];for(var n in e)("constructor"!=n||!t&&hasOwnProperty$8.call(e,n))&&r.push(n);return r}var _baseKeysIn=baseKeysIn;function keysIn(e){return isArrayLike_1(e)?_arrayLikeKeys(e,!0):_baseKeysIn(e)}var keysIn_1=keysIn;function toPlainObject(e){return _copyObject(e,keysIn_1(e))}var toPlainObject_1=toPlainObject;function baseMergeDeep(e,t,r,n,a,o,i){var s=_safeGet(e,r),c=_safeGet(t,r),u=i.get(c);if(u)_assignMergeValue(e,r,u);else{var l=o?o(s,c,r+"",e,t,i):void 0,f=void 0===l;if(f){var p=isArray_1(c),_=!p&&isBuffer_1(c),y=!p&&!_&&isTypedArray_1(c);l=c,p||_||y?l=isArray_1(s)?s:isArrayLikeObject_1(s)?_copyArray(s):_?_cloneBuffer(c,!(f=!1)):y?_cloneTypedArray(c,!(f=!1)):[]:isPlainObject_1(c)||isArguments_1(c)?isArguments_1(l=s)?l=toPlainObject_1(s):(!isObject_1(s)||n&&isFunction_1(s))&&(l=_initCloneObject(c)):f=!1}f&&(i.set(c,l),a(l,c,n,o,i),i.delete(c)),_assignMergeValue(e,r,l)}}var _baseMergeDeep=baseMergeDeep;function baseMerge(n,a,o,i,s){n!==a&&_baseFor(a,function(e,t){if(isObject_1(e))s||(s=new _Stack),_baseMergeDeep(n,a,t,o,baseMerge,i,s);else{var r=i?i(_safeGet(n,t),e,t+"",n,a,s):void 0;void 0===r&&(r=e),_assignMergeValue(n,t,r)}},keysIn_1)}var _baseMerge=baseMerge;function customDefaultsMerge(e,t,r,n,a,o){return isObject_1(e)&&isObject_1(t)&&(o.set(t,e),_baseMerge(e,t,void 0,customDefaultsMerge,o),o.delete(t)),e}var _customDefaultsMerge=customDefaultsMerge;function isIterateeCall(e,t,r){if(!isObject_1(r))return!1;var n=typeof t;return!!("number"==n?isArrayLike_1(r)&&_isIndex(t,r.length):"string"==n&&t in r)&&eq_1(r[t],e)}var _isIterateeCall=isIterateeCall;function createAssigner(s){return _baseRest(function(e,t){var r=-1,n=t.length,a=1<n?t[n-1]:void 0,o=2<n?t[2]:void 0;for(a=3<s.length&&"function"==typeof a?(n--,a):void 0,o&&_isIterateeCall(t[0],t[1],o)&&(a=n<3?void 0:a,n=1),e=Object(e);++r<n;){var i=t[r];i&&s(e,i,r,a)}return e})}var _createAssigner=createAssigner,mergeWith=_createAssigner(function(e,t,r,n){_baseMerge(e,t,r,n)}),mergeWith_1=mergeWith,defaultsDeep=_baseRest(function(e){return e.push(void 0,_customDefaultsMerge),_apply(mergeWith_1,void 0,e)}),defaultsDeep_1=defaultsDeep,pFinally=function(e,t){return t=t||function(){},e.then(function(e){return new Promise(function(e){e(t())}).then(function(){return e})},function(e){return new Promise(function(e){e(t())}).then(function(){throw e})})},TimeoutError=function(t){function e(e){t.call(this,e),this.name="TimeoutError"}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e}(Error),pTimeout=function(n,a,o){return new Promise(function(t,r){if("number"!=typeof a||a<0)throw new TypeError("Expected `ms` to be a positive number");var e=setTimeout(function(){if("function"!=typeof o){var e=o instanceof Error?o:new TimeoutError("string"==typeof o?o:"Promise timed out after "+a+" milliseconds");"function"==typeof n.cancel&&n.cancel(),r(e)}else try{t(o())}catch(e){r(e)}},a);pFinally(n.then(t,r),function(){clearTimeout(e)})})},TimeoutError_1=TimeoutError;pTimeout.TimeoutError=TimeoutError_1;var ms={};function getItem(e){return e in ms?ms[e]:null}function setItem(e,t){return ms[e]=t,!0}function removeItem(e){return!!(e in ms)&&delete ms[e]}function clear(){return ms={},!0}var stub={getItem:getItem,setItem:setItem,removeItem:removeItem,clear:clear},ls="localStorage"in commonjsGlobal&&commonjsGlobal.localStorage?commonjsGlobal.localStorage:stub,escapeFirebase=function(e){return e.toString().replace(/[.#$[\]]/g,"-")},index="function"==typeof fetch?fetch.bind():function(a,o){return o=o||{},new Promise(function(e,t){var r=new XMLHttpRequest;for(var n in r.open(o.method||"get",a),o.headers)r.setRequestHeader(n,o.headers[n]);function s(){var n,a=[],o=[],i={};return r.getAllResponseHeaders().replace(/^(.*?):\s*([\s\S]*?)$/gm,function(e,t,r){a.push(t=t.toLowerCase()),o.push([t,r]),n=i[t],i[t]=n?n+","+r:r}),{ok:1==(r.status/200|0),status:r.status,statusText:r.statusText,url:r.responseURL,clone:s,text:function(){return Promise.resolve(r.responseText)},json:function(){return Promise.resolve(r.responseText).then(JSON.parse)},blob:function(){return Promise.resolve(new Blob([r.response]))},headers:{keys:function(){return a},entries:function(){return o},get:function(e){return i[e.toLowerCase()]},has:function(e){return e.toLowerCase()in i}}}}r.withCredentials="include"==o.credentials,r.onload=function(){e(s())},r.onerror=t,r.send(o.body)})},cnj="https://us-central1-fastjur-71771.cloudfunctions.net/cnj",oab="https://us-central1-fastjur-71771.cloudfunctions.net/oab",expectation="https://us-central1-fastjur-71771.cloudfunctions.net/expectation",promad="https://us-central1-fastjur-71771.cloudfunctions.net/promad",key="https://us-central1-fastjur-71771.cloudfunctions.net/key",endpoints={cnj:cnj,oab:oab,expectation:expectation,promad:promad,key:key},apiKey="AIzaSyA_RIZP7bos4M9dRxwa1QVQnXh0Xl0m4pc",authDomain="fastjur-71771.firebaseapp.com",databaseURL="https://fastjur-71771.firebaseio.com",projectId="fastjur-71771",storageBucket="fastjur-71771.appspot.com",messagingSenderId="626350414834",firebaseConfiguration={apiKey:apiKey,authDomain:authDomain,databaseURL:databaseURL,projectId:projectId,storageBucket:storageBucket,messagingSenderId:messagingSenderId};firebase.initializeApp(firebaseConfiguration);var WebService=function(e){void 0===e&&(e={}),this.configuration=e};WebService.endpoints=function(){return endpoints},WebService.checkResponse=function(e){return e.ok&&e.headers.has("content-type")&&-1!==e.headers.get("content-type").indexOf("application/json")},WebService.errorResponse=function(e){return Promise.resolve().then(function(){return errorFactory(e.json())}).catch(function(){return errorFactory(e.statusText)}).then(function(e){throw e})},WebService.sendJson=function(e,t){return index(e,{method:"POST",body:JSON.stringify(t),cache:"no-store",redirect:"error",headers:{"Content-Type":"application/json"}}).catch(function(e){throw errorFactory(e.toString())}).then(function(e){return WebService.checkResponse(e)?e.json():WebService.errorResponse(e)})},WebService.prototype.idToken=function(){return this.currentUser().then(function(e){return e.getIdToken()})},WebService.prototype.authentication=function(){return new Promise(function(n,e){"undefined"==typeof document&&e(new Error),document.body.dispatchEvent(new Event("fastintegration.authentication.required"));var a=function(e){var t=e.detail;document.body.removeEventListener("fastintegration.authentication",a);var r=t.user;n(r)};document.body.addEventListener("fastintegration.authentication",a)})},WebService.prototype.currentUser=function(){var e=this,t=firebase.auth();return Promise.resolve().then(function(){return t.currentUser?t.currentUser:e.authentication()})},WebService.prototype.waitForLabel=function(l){return this.currentUser().then(function(e){var u=e.uid;return new Promise(function(t,r){var n,a=firebase.database(),o="/"+escapeFirebase(u)+"/content/"+l,i="/"+escapeFirebase(u)+"/error/"+l,s=!1,c=function(e){e.val()?(s=!0,n&&a.ref(i).off("value",n),t(e.val())):s||a.ref(o).once("value").then(c)};n=function(e){e.val()?(s=!0,a.ref(i).off("value",c),r(errorFactory(e.val()))):s||a.ref(i).once("value").then(n)},a.ref(o).once("value").then(c),a.ref(i).once("value").then(n)})})},WebService.prototype.onChange=function(a,t){var o=function(e){return e.val()&&t(e.val())},i=function(e){return e.val()&&t(null,e.val())};return this.currentUser().then(function(e){var t=e.uid;return{error:"/"+escapeFirebase(t)+"/error",content:"/"+escapeFirebase(t)+"/content",database:firebase.database()}}).then(function(e){var t=e.error,r=e.content,n=e.database;return Promise.resolve().then(function(){n.ref(r).on(a,i),n.ref(t).on(a,o)}).then(function(){return function(){n.ref(r).off(a,i),n.ref(t).off(a,o)}})})},WebService.prototype.key=function(){return this.idToken().then(function(e){return WebService.sendJson(WebService.endpoints().key,{idToken:e})})};var JuristekIntegration=function(r){function n(e){void 0===e&&(e={}),r.call(this,defaultsDeep_1(e,{timeout:{oab:"300 seconds",cnj:"300 seconds",cnjPromise:"300 seconds",expectation:"300 seconds"}}))}return r&&(n.__proto__=r),((n.prototype=Object.create(r&&r.prototype)).constructor=n).prototype.oab=function(t){return pTimeout(this.idToken().then(function(e){return r.sendJson(n.endpoints().oab,{oab:t,idToken:e})}),humanInterval_1(this.configuration.timeout.oab))},n.prototype.cnj=function(t){return pTimeout(this.idToken().then(function(e){return r.sendJson(n.endpoints().cnj,{cnj:t,idToken:e})}),humanInterval_1(this.configuration.timeout.cnj))},n.prototype.cnjPromise=function(e){var r=this;return pTimeout(this.cnj(e).then(function(e){var t=e.label;return r.waitForLabel(t)}),humanInterval_1(this.configuration.timeout.cnjPromise))},n.prototype.oabAsync=function(e,r){var n=this;return pTimeout(this.oab(e).then(function(t){return Promise.resolve(t.pushes.map(function(e){return n.onChange(e["label-oab"],r)})).then(function(e){return function(){return{content:t,unregisters:e.map(function(e){return e()})}}})}),humanInterval_1(this.configuration.timeout.oab))},n}(WebService);exports.exceptions=errorFactory$1,exports.JuristekIntegration=JuristekIntegration,exports.WebService=WebService;