Socket
Socket
Sign inDemoInstall

bullet-train-client

Package Overview
Dependencies
0
Maintainers
1
Versions
50
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.1.0 to 0.1.1

2

index.js

@@ -1,1 +0,1 @@

!function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var n=e();for(var r in n)("object"==typeof exports?exports:t)[r]=n[r]}}(this,(function(){return function(t){var e={};function n(r){if(e[r])return e[r].exports;var i=e[r]={i:r,l:!1,exports:{}};return t[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)n.d(r,i,function(e){return t[e]}.bind(null,i));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=1)}([function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r,i=function(t,e){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return function(t,e){var n=[],r=!0,i=!1,o=void 0;try{for(var a,u=t[Symbol.iterator]();!(r=(a=u.next()).done)&&(n.push(a.value),!e||n.length!==e);r=!0);}catch(t){i=!0,o=t}finally{try{!r&&u.return&&u.return()}finally{if(i)throw o}}return n}(t,e);throw new TypeError("Invalid attempt to destructure non-iterable instance")},o=n(3),a=(r=o)&&r.__esModule?r:{default:r};var u={getItem:function(t,e){return u.multiGet([t]).then((function(t){return t[0][1]})).then((function(t){return e&&e(null,t),t})).catch((function(t){return e&&e(t,null),t}))},setItem:function(t,e,n){return u.multiSet([[t,e]]).then((function(t){return n&&n(null,t),t})).catch((function(t){return n&&n(t,null),t}))},getAllKeys:function(t){return Promise.resolve(Object.keys(localStorage)).then((function(e){return t&&t(null,e),e})).catch((function(e){return t&&t(e,null),e}))},removeItem:function(t,e){return u.multiRemove([t]).then((function(){e&&e(null)})).catch((function(t){e&&e(t,null)}))},clear:function(){return new Promise((function(t){window.localStorage.clear(),t()}))},mergeItem:function(t,e){return u.multiMerge([[t,e]])},multiGet:function(t){return new Promise((function(e){e(t.reduce((function(t,e){return t.concat([[e,localStorage.getItem(e)]])}),[]))}))},multiSet:function(t){return new Promise((function(e,n){var r=[];return t.forEach((function(t){var e=i(t,2),n=e[0],o=e[1];try{localStorage.setItem(n,o)}catch(t){r.push(t)}})),r.length>0?n(r):e()}))},multiMerge:function(t){return new Promise((function(e,n){var r=[];return t.forEach((function(t){var e=i(t,2),n=e[0],o=e[1],u=localStorage.getItem(n);if(u)try{localStorage.setItem(n,JSON.stringify((0,a.default)(JSON.parse(u),JSON.parse(o))))}catch(t){r.push(t)}})),r.length>0?n(r):e()}))},multiRemove:function(t){return new Promise((function(e){t.forEach((function(t){return window.localStorage.removeItem(t)})),e()}))},flushGetRequests:function(){console.warn("AsyncStorage.flushGetRequests: Not supported on `web`")}};e.default=u},function(t,e,n){"use strict";n.r(e);var r=n(0),i=n.n(r),o=n(2).default,a=n(5)({AsyncStorage:i.a,fetch:o});"undefined"!=typeof window&&(window.bulletTrain=a),e.default=a},function(t,e,n){"use strict";n.r(e),e.default=function(t,e){return e=e||{},new Promise((function(n,r){var i=new XMLHttpRequest,o=[],a=[],u={},c=function(){return{ok:2==(i.status/100|0),statusText:i.statusText,status:i.status,url:i.responseURL,text:function(){return Promise.resolve(i.responseText)},json:function(){return Promise.resolve(JSON.parse(i.responseText))},blob:function(){return Promise.resolve(new Blob([i.response]))},clone:c,headers:{keys:function(){return o},entries:function(){return a},get:function(t){return u[t.toLowerCase()]},has:function(t){return t.toLowerCase()in u}}}};for(var s in i.open(e.method||"get",t,!0),i.onload=function(){i.getAllResponseHeaders().replace(/^(.*?):[^\S\n]*([\s\S]*?)$/gm,(function(t,e,n){o.push(e=e.toLowerCase()),a.push([e,n]),u[e]=u[e]?u[e]+","+n:n})),n(c())},i.onerror=r,i.withCredentials="include"==e.credentials,e.headers)i.setRequestHeader(s,e.headers[s]);i.send(e.body||null)}))}},function(t,e,n){(function(t){var n=200,r="__lodash_hash_undefined__",i=800,o=16,a=9007199254740991,u="[object Arguments]",c="[object AsyncFunction]",s="[object Function]",l="[object GeneratorFunction]",f="[object Null]",h="[object Object]",p="[object Proxy]",v="[object Undefined]",g=/^\[object .+?Constructor\]$/,y=/^(?:0|[1-9]\d*)$/,d={};d["[object Float32Array]"]=d["[object Float64Array]"]=d["[object Int8Array]"]=d["[object Int16Array]"]=d["[object Int32Array]"]=d["[object Uint8Array]"]=d["[object Uint8ClampedArray]"]=d["[object Uint16Array]"]=d["[object Uint32Array]"]=!0,d[u]=d["[object Array]"]=d["[object ArrayBuffer]"]=d["[object Boolean]"]=d["[object DataView]"]=d["[object Date]"]=d["[object Error]"]=d[s]=d["[object Map]"]=d["[object Number]"]=d[h]=d["[object RegExp]"]=d["[object Set]"]=d["[object String]"]=d["[object WeakMap]"]=!1;var b="object"==typeof global&&global&&global.Object===Object&&global,_="object"==typeof self&&self&&self.Object===Object&&self,m=b||_||Function("return this")(),j=e&&!e.nodeType&&e,S=j&&"object"==typeof t&&t&&!t.nodeType&&t,w=S&&S.exports===j,O=w&&b.process,P=function(){try{var t=S&&S.require&&S.require("util").types;return t||O&&O.binding&&O.binding("util")}catch(t){}}(),A=P&&P.isTypedArray;function T(t,e,n){switch(n.length){case 0:return t.call(e);case 1:return t.call(e,n[0]);case 2:return t.call(e,n[0],n[1]);case 3:return t.call(e,n[0],n[1],n[2])}return t.apply(e,n)}var I,k,x,F=Array.prototype,E=Function.prototype,N=Object.prototype,L=m["__core-js_shared__"],z=E.toString,C=N.hasOwnProperty,J=(I=/[^.]+$/.exec(L&&L.keys&&L.keys.IE_PROTO||""))?"Symbol(src)_1."+I:"",R=N.toString,D=z.call(Object),M=RegExp("^"+z.call(C).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),U=w?m.Buffer:void 0,B=m.Symbol,$=m.Uint8Array,G=U?U.allocUnsafe:void 0,q=(k=Object.getPrototypeOf,x=Object,function(t){return k(x(t))}),H=Object.create,V=N.propertyIsEnumerable,K=F.splice,W=B?B.toStringTag:void 0,X=function(){try{var t=jt(Object,"defineProperty");return t({},"",{}),t}catch(t){}}(),Q=U?U.isBuffer:void 0,Y=Math.max,Z=Date.now,tt=jt(m,"Map"),et=jt(Object,"create"),nt=function(){function t(){}return function(e){if(!Nt(e))return{};if(H)return H(e);t.prototype=e;var n=new t;return t.prototype=void 0,n}}();function rt(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}function it(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}function ot(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}function at(t){var e=this.__data__=new it(t);this.size=e.size}function ut(t,e){var n=It(t),r=!n&&Tt(t),i=!n&&!r&&xt(t),o=!n&&!r&&!i&&zt(t),a=n||r||i||o,u=a?function(t,e){for(var n=-1,r=Array(t);++n<t;)r[n]=e(n);return r}(t.length,String):[],c=u.length;for(var s in t)!e&&!C.call(t,s)||a&&("length"==s||i&&("offset"==s||"parent"==s)||o&&("buffer"==s||"byteLength"==s||"byteOffset"==s)||St(s,c))||u.push(s);return u}function ct(t,e,n){(void 0===n||At(t[e],n))&&(void 0!==n||e in t)||ft(t,e,n)}function st(t,e,n){var r=t[e];C.call(t,e)&&At(r,n)&&(void 0!==n||e in t)||ft(t,e,n)}function lt(t,e){for(var n=t.length;n--;)if(At(t[n][0],e))return n;return-1}function ft(t,e,n){"__proto__"==e&&X?X(t,e,{configurable:!0,enumerable:!0,value:n,writable:!0}):t[e]=n}rt.prototype.clear=function(){this.__data__=et?et(null):{},this.size=0},rt.prototype.delete=function(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e},rt.prototype.get=function(t){var e=this.__data__;if(et){var n=e[t];return n===r?void 0:n}return C.call(e,t)?e[t]:void 0},rt.prototype.has=function(t){var e=this.__data__;return et?void 0!==e[t]:C.call(e,t)},rt.prototype.set=function(t,e){var n=this.__data__;return this.size+=this.has(t)?0:1,n[t]=et&&void 0===e?r:e,this},it.prototype.clear=function(){this.__data__=[],this.size=0},it.prototype.delete=function(t){var e=this.__data__,n=lt(e,t);return!(n<0)&&(n==e.length-1?e.pop():K.call(e,n,1),--this.size,!0)},it.prototype.get=function(t){var e=this.__data__,n=lt(e,t);return n<0?void 0:e[n][1]},it.prototype.has=function(t){return lt(this.__data__,t)>-1},it.prototype.set=function(t,e){var n=this.__data__,r=lt(n,t);return r<0?(++this.size,n.push([t,e])):n[r][1]=e,this},ot.prototype.clear=function(){this.size=0,this.__data__={hash:new rt,map:new(tt||it),string:new rt}},ot.prototype.delete=function(t){var e=mt(this,t).delete(t);return this.size-=e?1:0,e},ot.prototype.get=function(t){return mt(this,t).get(t)},ot.prototype.has=function(t){return mt(this,t).has(t)},ot.prototype.set=function(t,e){var n=mt(this,t),r=n.size;return n.set(t,e),this.size+=n.size==r?0:1,this},at.prototype.clear=function(){this.__data__=new it,this.size=0},at.prototype.delete=function(t){var e=this.__data__,n=e.delete(t);return this.size=e.size,n},at.prototype.get=function(t){return this.__data__.get(t)},at.prototype.has=function(t){return this.__data__.has(t)},at.prototype.set=function(t,e){var r=this.__data__;if(r instanceof it){var i=r.__data__;if(!tt||i.length<n-1)return i.push([t,e]),this.size=++r.size,this;r=this.__data__=new ot(i)}return r.set(t,e),this.size=r.size,this};var ht,pt=function(t,e,n){for(var r=-1,i=Object(t),o=n(t),a=o.length;a--;){var u=o[ht?a:++r];if(!1===e(i[u],u,i))break}return t};function vt(t){return null==t?void 0===t?v:f:W&&W in Object(t)?function(t){var e=C.call(t,W),n=t[W];try{t[W]=void 0;var r=!0}catch(t){}var i=R.call(t);r&&(e?t[W]=n:delete t[W]);return i}(t):function(t){return R.call(t)}(t)}function gt(t){return Lt(t)&&vt(t)==u}function yt(t){return!(!Nt(t)||function(t){return!!J&&J in t}(t))&&(Ft(t)?M:g).test(function(t){if(null!=t){try{return z.call(t)}catch(t){}try{return t+""}catch(t){}}return""}(t))}function dt(t){if(!Nt(t))return function(t){var e=[];if(null!=t)for(var n in Object(t))e.push(n);return e}(t);var e=wt(t),n=[];for(var r in t)("constructor"!=r||!e&&C.call(t,r))&&n.push(r);return n}function bt(t,e,n,r,i){t!==e&&pt(e,(function(o,a){if(i||(i=new at),Nt(o))!function(t,e,n,r,i,o,a){var u=Ot(t,n),c=Ot(e,n),s=a.get(c);if(s)return void ct(t,n,s);var l=o?o(u,c,n+"",t,e,a):void 0,f=void 0===l;if(f){var p=It(c),v=!p&&xt(c),g=!p&&!v&&zt(c);l=c,p||v||g?It(u)?l=u:Lt(m=u)&&kt(m)?l=function(t,e){var n=-1,r=t.length;e||(e=Array(r));for(;++n<r;)e[n]=t[n];return e}(u):v?(f=!1,l=function(t,e){if(e)return t.slice();var n=t.length,r=G?G(n):new t.constructor(n);return t.copy(r),r}(c,!0)):g?(f=!1,y=c,d=!0?(b=y.buffer,_=new b.constructor(b.byteLength),new $(_).set(new $(b)),_):y.buffer,l=new y.constructor(d,y.byteOffset,y.length)):l=[]:function(t){if(!Lt(t)||vt(t)!=h)return!1;var e=q(t);if(null===e)return!0;var n=C.call(e,"constructor")&&e.constructor;return"function"==typeof n&&n instanceof n&&z.call(n)==D}(c)||Tt(c)?(l=u,Tt(u)?l=function(t){return function(t,e,n,r){var i=!n;n||(n={});var o=-1,a=e.length;for(;++o<a;){var u=e[o],c=r?r(n[u],t[u],u,n,t):void 0;void 0===c&&(c=t[u]),i?ft(n,u,c):st(n,u,c)}return n}(t,Ct(t))}(u):Nt(u)&&!Ft(u)||(l=function(t){return"function"!=typeof t.constructor||wt(t)?{}:nt(q(t))}(c))):f=!1}var y,d,b,_;var m;f&&(a.set(c,l),i(l,c,r,o,a),a.delete(c));ct(t,n,l)}(t,e,a,n,bt,r,i);else{var u=r?r(Ot(t,a),o,a+"",t,e,i):void 0;void 0===u&&(u=o),ct(t,a,u)}}),Ct)}function _t(t,e){return Pt(function(t,e,n){return e=Y(void 0===e?t.length-1:e,0),function(){for(var r=arguments,i=-1,o=Y(r.length-e,0),a=Array(o);++i<o;)a[i]=r[e+i];i=-1;for(var u=Array(e+1);++i<e;)u[i]=r[i];return u[e]=n(a),T(t,this,u)}}(t,e,Dt),t+"")}function mt(t,e){var n,r,i=t.__data__;return("string"==(r=typeof(n=e))||"number"==r||"symbol"==r||"boolean"==r?"__proto__"!==n:null===n)?i["string"==typeof e?"string":"hash"]:i.map}function jt(t,e){var n=function(t,e){return null==t?void 0:t[e]}(t,e);return yt(n)?n:void 0}function St(t,e){var n=typeof t;return!!(e=null==e?a:e)&&("number"==n||"symbol"!=n&&y.test(t))&&t>-1&&t%1==0&&t<e}function wt(t){var e=t&&t.constructor;return t===("function"==typeof e&&e.prototype||N)}function Ot(t,e){if(("constructor"!==e||"function"!=typeof t[e])&&"__proto__"!=e)return t[e]}var Pt=function(t){var e=0,n=0;return function(){var r=Z(),a=o-(r-n);if(n=r,a>0){if(++e>=i)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}(X?function(t,e){return X(t,"toString",{configurable:!0,enumerable:!1,value:(n=e,function(){return n}),writable:!0});var n}:Dt);function At(t,e){return t===e||t!=t&&e!=e}var Tt=gt(function(){return arguments}())?gt:function(t){return Lt(t)&&C.call(t,"callee")&&!V.call(t,"callee")},It=Array.isArray;function kt(t){return null!=t&&Et(t.length)&&!Ft(t)}var xt=Q||function(){return!1};function Ft(t){if(!Nt(t))return!1;var e=vt(t);return e==s||e==l||e==c||e==p}function Et(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=a}function Nt(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}function Lt(t){return null!=t&&"object"==typeof t}var zt=A?function(t){return function(e){return t(e)}}(A):function(t){return Lt(t)&&Et(t.length)&&!!d[vt(t)]};function Ct(t){return kt(t)?ut(t,!0):dt(t)}var Jt,Rt=(Jt=function(t,e,n){bt(t,e,n)},_t((function(t,e){var n=-1,r=e.length,i=r>1?e[r-1]:void 0,o=r>2?e[2]:void 0;for(i=Jt.length>3&&"function"==typeof i?(r--,i):void 0,o&&function(t,e,n){if(!Nt(n))return!1;var r=typeof e;return!!("number"==r?kt(n)&&St(e,n.length):"string"==r&&e in n)&&At(n[e],t)}(e[0],e[1],o)&&(i=r<3?void 0:i,r=1),t=Object(t);++n<r;){var a=e[n];a&&Jt(t,a,n,i)}return t})));function Dt(t){return t}t.exports=Rt}).call(this,n(4)(t))},function(t,e){t.exports=function(t){return t.webpackPolyfill||(t.deprecate=function(){},t.paths=[],t.children||(t.children=[]),Object.defineProperty(t,"loaded",{enumerable:!0,get:function(){return t.l}}),Object.defineProperty(t,"id",{enumerable:!0,get:function(){return t.i}}),t.webpackPolyfill=1),t}},function(t,e){function n(t){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function r(t,e){for(var n,r=0;r<e.length;r++)(n=e[r]).enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}function i(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}var o,a,u="https://api.bullet-train.io/api/v1/",c=function(){function t(e){var r=this;(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")})(this,t),i(this,"getJSON",(function(t,e,n){var i={method:e||"GET",body:n,headers:{"x-environment-key":r.environmentID}};return"GET"!==e&&(i.headers["Content-Type"]="application/json; charset=utf-8"),o(t,i).then((function(t){return 200<=t.status&&300>t.status?t:t.text().then((function(t){var e=t;try{e=JSON.parse(t)}catch(t){}return Promise.reject(e)}))})).then((function(t){return t.json()}))})),i(this,"getFlags",(function(t,e){var n=r.onChange,i=r.onError,o=r.identity,a=r.api,u=(r.disableCache,!1),c=function(t,e){var i=t.flags,o=t.traits,a={},u={};if(o=o||[],(i=i||[]).forEach((function(t){a[t.feature.name.toLowerCase().replace(/ /g,"_")]={enabled:t.enabled,value:t.feature_state_value}})),o.forEach((function(t){u[t.trait_key.toLowerCase().replace(/ /g,"_")]=t.trait_value})),r.oldFlags=a,r.flags=a,r.traits=u,e){var c={};e.map((function(t){c[t.name]=t})),r.segments=c}r.updateStorage(),n&&n(r.oldFlags,{isFromServer:!0})};return o?Promise.all([r.getJSON(a+"identities/?identifier="+encodeURIComponent(o))]).then((function(t){c(t[0],t[1])})).catch((function(t){var e=t.message;i&&i({message:e})})):Promise.all([r.getJSON(a+"flags/")]).then((function(e){c({flags:e[0]},null),t&&!u&&(u=!0,t())})).catch((function(t){e&&!u&&(u=!0,e(t)),i&&i(t)}))})),i(this,"getValue",(function(t){var e=r.flags&&r.flags[t],n=null;return e&&(n=e.value),n})),i(this,"getTrait",(function(t){return r.traits&&r.traits[t]})),i(this,"setTrait",(function(t,e){var n=r.getJSON,i=r.identity,o=r.api;return n("".concat(o,"traits/"),"POST",JSON.stringify({identity:{identifier:i},trait_key:t,trait_value:e})).then(r.getFlags)})),i(this,"setTraits",(function(t){var e=r.getJSON,i=r.identity,o=r.api;t&&"object"===n(t)||console.error("Expected object for bulletTrain.setTraits");var a=Object.keys(t).map((function(e){return{identity:{identifier:i},trait_key:e,trait_value:t[e]}}));return e("".concat(o,"traits/bulk/"),"PUT",JSON.stringify(a)).then(r.getFlags)})),i(this,"incrementTrait",(function(t,e){var n=r.getJSON,i=r.identity,o=r.api;return n("".concat(o,"traits/increment-value/"),"POST",JSON.stringify({trait_key:t,increment_by:e,identifier:i})).then(r.getFlags)})),i(this,"hasFeature",(function(t){var e=r.flags&&r.flags[t],n=!1;return e&&e.enabled&&(n=!0),n})),o=e.fetch?e.fetch:global.fetch,a=e.AsyncStorage}return function(t,e,n){e&&r(t.prototype,e),n&&r(t,n)}(t,[{key:"init",value:function(t){var e=this,n=t.environmentID,r=t.api,i=void 0===r?u:r,o=t.onChange,c=t.cacheFlags,s=t.onError,l=t.defaultFlags,f=t.preventFetch,h=t.enableLogs,p=t.AsyncStorage,v=t.state;return new Promise((function(t,r){if(e.environmentID=n,e.api=i,e.interval=null,e.onChange=o,e.onError=s,e.enableLogs=h,e.flags=Object.assign({},l)||{},e.initialised=!0,e.timer=e.enableLogs?(new Date).valueOf():null,p&&(a=p),e.cacheFlags=void 0!==a&&c,e.setState(v),!n)throw r("Please specify a environment id"),"Please specify a environment id";c?a.getItem("BULLET_TRAIN_DB",(function(n,i){if(i)try{var o=JSON.parse(i);o&&o.api===e.api&&(e.setState(o),e.log("Retrieved flags from cache",o)),e.flags?(e.onChange&&e.onChange(null,{isFromServer:!1}),t(),e.getFlags(Promise.resolve,Promise.reject)):e.getFlags(t,r)}catch(t){e.log("Exception fetching cached logs",t)}})):!f&&e.getFlags(t,r)}))}},{key:"getAllFlags",value:function(){return this.flags}},{key:"identify",value:function(t){this.identity=t,this.initialised&&!this.interval&&this.getFlags()}},{key:"getState",value:function(){return{api:this.api,environmentID:this.environmentID,flags:this.flags,identity:this.identity,segments:this.segments,traits:this.traits}}},{key:"setState",value:function(t){t&&(this.initialised=!0,this.api=t.api||this.api||u,this.environmentID=t.environmentID||this.environmentID,this.flags=t.flags||this.flags,this.identity=t.identity||this.identity,this.segments=t.segments||this.segments,this.traits=t.traits||this.traits)}},{key:"log",value:function(){if(this.enableLogs){for(var t=arguments.length,e=Array(t),n=0;n<t;n++)e[n]=arguments[n];console.log.apply(this,["BULLET TRAIN:",(new Date).valueOf()-this.timer,"ms"].concat(e))}}},{key:"updateStorage",value:function(){if(this.cacheFlags){var t=JSON.stringify(this.getState());this.log("Setting storage",t),a.setItem("BULLET_TRAIN_DB",t)}}},{key:"logout",value:function(){this.identity=null,this.segments=null,this.traits=null,this.initialised&&!this.interval&&this.getFlags()}},{key:"startListening",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:1e3;this.interval||(this.interval=setInterval(this.getFlags,t))}},{key:"getSegments",value:function(){}},{key:"stopListening",value:function(){clearInterval(this.interval)}}]),t}();t.exports=function(t){var e=t.fetch,n=t.AsyncStorage;return new c({fetch:e,AsyncStorage:n})}}])}));
!function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var n=e();for(var r in n)("object"==typeof exports?exports:t)[r]=n[r]}}(this,(function(){return function(t){var e={};function n(r){if(e[r])return e[r].exports;var i=e[r]={i:r,l:!1,exports:{}};return t[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)n.d(r,i,function(e){return t[e]}.bind(null,i));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=1)}([function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r,i=function(t,e){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return function(t,e){var n=[],r=!0,i=!1,o=void 0;try{for(var a,u=t[Symbol.iterator]();!(r=(a=u.next()).done)&&(n.push(a.value),!e||n.length!==e);r=!0);}catch(t){i=!0,o=t}finally{try{!r&&u.return&&u.return()}finally{if(i)throw o}}return n}(t,e);throw new TypeError("Invalid attempt to destructure non-iterable instance")},o=n(3),a=(r=o)&&r.__esModule?r:{default:r};var u={getItem:function(t,e){return u.multiGet([t]).then((function(t){return t[0][1]})).then((function(t){return e&&e(null,t),t})).catch((function(t){return e&&e(t,null),t}))},setItem:function(t,e,n){return u.multiSet([[t,e]]).then((function(t){return n&&n(null,t),t})).catch((function(t){return n&&n(t,null),t}))},getAllKeys:function(t){return Promise.resolve(Object.keys(localStorage)).then((function(e){return t&&t(null,e),e})).catch((function(e){return t&&t(e,null),e}))},removeItem:function(t,e){return u.multiRemove([t]).then((function(){e&&e(null)})).catch((function(t){e&&e(t,null)}))},clear:function(){return new Promise((function(t){window.localStorage.clear(),t()}))},mergeItem:function(t,e){return u.multiMerge([[t,e]])},multiGet:function(t){return new Promise((function(e){e(t.reduce((function(t,e){return t.concat([[e,localStorage.getItem(e)]])}),[]))}))},multiSet:function(t){return new Promise((function(e,n){var r=[];return t.forEach((function(t){var e=i(t,2),n=e[0],o=e[1];try{localStorage.setItem(n,o)}catch(t){r.push(t)}})),r.length>0?n(r):e()}))},multiMerge:function(t){return new Promise((function(e,n){var r=[];return t.forEach((function(t){var e=i(t,2),n=e[0],o=e[1],u=localStorage.getItem(n);if(u)try{localStorage.setItem(n,JSON.stringify((0,a.default)(JSON.parse(u),JSON.parse(o))))}catch(t){r.push(t)}})),r.length>0?n(r):e()}))},multiRemove:function(t){return new Promise((function(e){t.forEach((function(t){return window.localStorage.removeItem(t)})),e()}))},flushGetRequests:function(){console.warn("AsyncStorage.flushGetRequests: Not supported on `web`")}};e.default=u},function(t,e,n){"use strict";n.r(e);var r=n(0),i=n.n(r),o=n(2).default,a=n(5)({AsyncStorage:i.a,fetch:o});"undefined"!=typeof window&&(window.bulletTrain=a),e.default=a},function(t,e,n){"use strict";n.r(e),e.default=function(t,e){return e=e||{},new Promise((function(n,r){var i=new XMLHttpRequest,o=[],a=[],u={},c=function(){return{ok:2==(i.status/100|0),statusText:i.statusText,status:i.status,url:i.responseURL,text:function(){return Promise.resolve(i.responseText)},json:function(){return Promise.resolve(JSON.parse(i.responseText))},blob:function(){return Promise.resolve(new Blob([i.response]))},clone:c,headers:{keys:function(){return o},entries:function(){return a},get:function(t){return u[t.toLowerCase()]},has:function(t){return t.toLowerCase()in u}}}};for(var s in i.open(e.method||"get",t,!0),i.onload=function(){i.getAllResponseHeaders().replace(/^(.*?):[^\S\n]*([\s\S]*?)$/gm,(function(t,e,n){o.push(e=e.toLowerCase()),a.push([e,n]),u[e]=u[e]?u[e]+","+n:n})),n(c())},i.onerror=r,i.withCredentials="include"==e.credentials,e.headers)i.setRequestHeader(s,e.headers[s]);i.send(e.body||null)}))}},function(t,e,n){(function(t){var n=200,r="__lodash_hash_undefined__",i=800,o=16,a=9007199254740991,u="[object Arguments]",c="[object AsyncFunction]",s="[object Function]",l="[object GeneratorFunction]",f="[object Null]",h="[object Object]",p="[object Proxy]",v="[object Undefined]",g=/^\[object .+?Constructor\]$/,y=/^(?:0|[1-9]\d*)$/,d={};d["[object Float32Array]"]=d["[object Float64Array]"]=d["[object Int8Array]"]=d["[object Int16Array]"]=d["[object Int32Array]"]=d["[object Uint8Array]"]=d["[object Uint8ClampedArray]"]=d["[object Uint16Array]"]=d["[object Uint32Array]"]=!0,d[u]=d["[object Array]"]=d["[object ArrayBuffer]"]=d["[object Boolean]"]=d["[object DataView]"]=d["[object Date]"]=d["[object Error]"]=d[s]=d["[object Map]"]=d["[object Number]"]=d[h]=d["[object RegExp]"]=d["[object Set]"]=d["[object String]"]=d["[object WeakMap]"]=!1;var b="object"==typeof global&&global&&global.Object===Object&&global,_="object"==typeof self&&self&&self.Object===Object&&self,m=b||_||Function("return this")(),j=e&&!e.nodeType&&e,S=j&&"object"==typeof t&&t&&!t.nodeType&&t,w=S&&S.exports===j,O=w&&b.process,P=function(){try{var t=S&&S.require&&S.require("util").types;return t||O&&O.binding&&O.binding("util")}catch(t){}}(),A=P&&P.isTypedArray;function T(t,e,n){switch(n.length){case 0:return t.call(e);case 1:return t.call(e,n[0]);case 2:return t.call(e,n[0],n[1]);case 3:return t.call(e,n[0],n[1],n[2])}return t.apply(e,n)}var I,k,x,F=Array.prototype,E=Function.prototype,N=Object.prototype,L=m["__core-js_shared__"],z=E.toString,C=N.hasOwnProperty,J=(I=/[^.]+$/.exec(L&&L.keys&&L.keys.IE_PROTO||""))?"Symbol(src)_1."+I:"",R=N.toString,D=z.call(Object),M=RegExp("^"+z.call(C).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),U=w?m.Buffer:void 0,B=m.Symbol,$=m.Uint8Array,G=U?U.allocUnsafe:void 0,q=(k=Object.getPrototypeOf,x=Object,function(t){return k(x(t))}),H=Object.create,V=N.propertyIsEnumerable,K=F.splice,W=B?B.toStringTag:void 0,X=function(){try{var t=jt(Object,"defineProperty");return t({},"",{}),t}catch(t){}}(),Q=U?U.isBuffer:void 0,Y=Math.max,Z=Date.now,tt=jt(m,"Map"),et=jt(Object,"create"),nt=function(){function t(){}return function(e){if(!Nt(e))return{};if(H)return H(e);t.prototype=e;var n=new t;return t.prototype=void 0,n}}();function rt(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}function it(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}function ot(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}function at(t){var e=this.__data__=new it(t);this.size=e.size}function ut(t,e){var n=It(t),r=!n&&Tt(t),i=!n&&!r&&xt(t),o=!n&&!r&&!i&&zt(t),a=n||r||i||o,u=a?function(t,e){for(var n=-1,r=Array(t);++n<t;)r[n]=e(n);return r}(t.length,String):[],c=u.length;for(var s in t)!e&&!C.call(t,s)||a&&("length"==s||i&&("offset"==s||"parent"==s)||o&&("buffer"==s||"byteLength"==s||"byteOffset"==s)||St(s,c))||u.push(s);return u}function ct(t,e,n){(void 0===n||At(t[e],n))&&(void 0!==n||e in t)||ft(t,e,n)}function st(t,e,n){var r=t[e];C.call(t,e)&&At(r,n)&&(void 0!==n||e in t)||ft(t,e,n)}function lt(t,e){for(var n=t.length;n--;)if(At(t[n][0],e))return n;return-1}function ft(t,e,n){"__proto__"==e&&X?X(t,e,{configurable:!0,enumerable:!0,value:n,writable:!0}):t[e]=n}rt.prototype.clear=function(){this.__data__=et?et(null):{},this.size=0},rt.prototype.delete=function(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e},rt.prototype.get=function(t){var e=this.__data__;if(et){var n=e[t];return n===r?void 0:n}return C.call(e,t)?e[t]:void 0},rt.prototype.has=function(t){var e=this.__data__;return et?void 0!==e[t]:C.call(e,t)},rt.prototype.set=function(t,e){var n=this.__data__;return this.size+=this.has(t)?0:1,n[t]=et&&void 0===e?r:e,this},it.prototype.clear=function(){this.__data__=[],this.size=0},it.prototype.delete=function(t){var e=this.__data__,n=lt(e,t);return!(n<0)&&(n==e.length-1?e.pop():K.call(e,n,1),--this.size,!0)},it.prototype.get=function(t){var e=this.__data__,n=lt(e,t);return n<0?void 0:e[n][1]},it.prototype.has=function(t){return lt(this.__data__,t)>-1},it.prototype.set=function(t,e){var n=this.__data__,r=lt(n,t);return r<0?(++this.size,n.push([t,e])):n[r][1]=e,this},ot.prototype.clear=function(){this.size=0,this.__data__={hash:new rt,map:new(tt||it),string:new rt}},ot.prototype.delete=function(t){var e=mt(this,t).delete(t);return this.size-=e?1:0,e},ot.prototype.get=function(t){return mt(this,t).get(t)},ot.prototype.has=function(t){return mt(this,t).has(t)},ot.prototype.set=function(t,e){var n=mt(this,t),r=n.size;return n.set(t,e),this.size+=n.size==r?0:1,this},at.prototype.clear=function(){this.__data__=new it,this.size=0},at.prototype.delete=function(t){var e=this.__data__,n=e.delete(t);return this.size=e.size,n},at.prototype.get=function(t){return this.__data__.get(t)},at.prototype.has=function(t){return this.__data__.has(t)},at.prototype.set=function(t,e){var r=this.__data__;if(r instanceof it){var i=r.__data__;if(!tt||i.length<n-1)return i.push([t,e]),this.size=++r.size,this;r=this.__data__=new ot(i)}return r.set(t,e),this.size=r.size,this};var ht,pt=function(t,e,n){for(var r=-1,i=Object(t),o=n(t),a=o.length;a--;){var u=o[ht?a:++r];if(!1===e(i[u],u,i))break}return t};function vt(t){return null==t?void 0===t?v:f:W&&W in Object(t)?function(t){var e=C.call(t,W),n=t[W];try{t[W]=void 0;var r=!0}catch(t){}var i=R.call(t);r&&(e?t[W]=n:delete t[W]);return i}(t):function(t){return R.call(t)}(t)}function gt(t){return Lt(t)&&vt(t)==u}function yt(t){return!(!Nt(t)||function(t){return!!J&&J in t}(t))&&(Ft(t)?M:g).test(function(t){if(null!=t){try{return z.call(t)}catch(t){}try{return t+""}catch(t){}}return""}(t))}function dt(t){if(!Nt(t))return function(t){var e=[];if(null!=t)for(var n in Object(t))e.push(n);return e}(t);var e=wt(t),n=[];for(var r in t)("constructor"!=r||!e&&C.call(t,r))&&n.push(r);return n}function bt(t,e,n,r,i){t!==e&&pt(e,(function(o,a){if(i||(i=new at),Nt(o))!function(t,e,n,r,i,o,a){var u=Ot(t,n),c=Ot(e,n),s=a.get(c);if(s)return void ct(t,n,s);var l=o?o(u,c,n+"",t,e,a):void 0,f=void 0===l;if(f){var p=It(c),v=!p&&xt(c),g=!p&&!v&&zt(c);l=c,p||v||g?It(u)?l=u:Lt(m=u)&&kt(m)?l=function(t,e){var n=-1,r=t.length;e||(e=Array(r));for(;++n<r;)e[n]=t[n];return e}(u):v?(f=!1,l=function(t,e){if(e)return t.slice();var n=t.length,r=G?G(n):new t.constructor(n);return t.copy(r),r}(c,!0)):g?(f=!1,y=c,d=!0?(b=y.buffer,_=new b.constructor(b.byteLength),new $(_).set(new $(b)),_):y.buffer,l=new y.constructor(d,y.byteOffset,y.length)):l=[]:function(t){if(!Lt(t)||vt(t)!=h)return!1;var e=q(t);if(null===e)return!0;var n=C.call(e,"constructor")&&e.constructor;return"function"==typeof n&&n instanceof n&&z.call(n)==D}(c)||Tt(c)?(l=u,Tt(u)?l=function(t){return function(t,e,n,r){var i=!n;n||(n={});var o=-1,a=e.length;for(;++o<a;){var u=e[o],c=r?r(n[u],t[u],u,n,t):void 0;void 0===c&&(c=t[u]),i?ft(n,u,c):st(n,u,c)}return n}(t,Ct(t))}(u):Nt(u)&&!Ft(u)||(l=function(t){return"function"!=typeof t.constructor||wt(t)?{}:nt(q(t))}(c))):f=!1}var y,d,b,_;var m;f&&(a.set(c,l),i(l,c,r,o,a),a.delete(c));ct(t,n,l)}(t,e,a,n,bt,r,i);else{var u=r?r(Ot(t,a),o,a+"",t,e,i):void 0;void 0===u&&(u=o),ct(t,a,u)}}),Ct)}function _t(t,e){return Pt(function(t,e,n){return e=Y(void 0===e?t.length-1:e,0),function(){for(var r=arguments,i=-1,o=Y(r.length-e,0),a=Array(o);++i<o;)a[i]=r[e+i];i=-1;for(var u=Array(e+1);++i<e;)u[i]=r[i];return u[e]=n(a),T(t,this,u)}}(t,e,Dt),t+"")}function mt(t,e){var n,r,i=t.__data__;return("string"==(r=typeof(n=e))||"number"==r||"symbol"==r||"boolean"==r?"__proto__"!==n:null===n)?i["string"==typeof e?"string":"hash"]:i.map}function jt(t,e){var n=function(t,e){return null==t?void 0:t[e]}(t,e);return yt(n)?n:void 0}function St(t,e){var n=typeof t;return!!(e=null==e?a:e)&&("number"==n||"symbol"!=n&&y.test(t))&&t>-1&&t%1==0&&t<e}function wt(t){var e=t&&t.constructor;return t===("function"==typeof e&&e.prototype||N)}function Ot(t,e){if(("constructor"!==e||"function"!=typeof t[e])&&"__proto__"!=e)return t[e]}var Pt=function(t){var e=0,n=0;return function(){var r=Z(),a=o-(r-n);if(n=r,a>0){if(++e>=i)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}(X?function(t,e){return X(t,"toString",{configurable:!0,enumerable:!1,value:(n=e,function(){return n}),writable:!0});var n}:Dt);function At(t,e){return t===e||t!=t&&e!=e}var Tt=gt(function(){return arguments}())?gt:function(t){return Lt(t)&&C.call(t,"callee")&&!V.call(t,"callee")},It=Array.isArray;function kt(t){return null!=t&&Et(t.length)&&!Ft(t)}var xt=Q||function(){return!1};function Ft(t){if(!Nt(t))return!1;var e=vt(t);return e==s||e==l||e==c||e==p}function Et(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=a}function Nt(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}function Lt(t){return null!=t&&"object"==typeof t}var zt=A?function(t){return function(e){return t(e)}}(A):function(t){return Lt(t)&&Et(t.length)&&!!d[vt(t)]};function Ct(t){return kt(t)?ut(t,!0):dt(t)}var Jt,Rt=(Jt=function(t,e,n){bt(t,e,n)},_t((function(t,e){var n=-1,r=e.length,i=r>1?e[r-1]:void 0,o=r>2?e[2]:void 0;for(i=Jt.length>3&&"function"==typeof i?(r--,i):void 0,o&&function(t,e,n){if(!Nt(n))return!1;var r=typeof e;return!!("number"==r?kt(n)&&St(e,n.length):"string"==r&&e in n)&&At(n[e],t)}(e[0],e[1],o)&&(i=r<3?void 0:i,r=1),t=Object(t);++n<r;){var a=e[n];a&&Jt(t,a,n,i)}return t})));function Dt(t){return t}t.exports=Rt}).call(this,n(4)(t))},function(t,e){t.exports=function(t){return t.webpackPolyfill||(t.deprecate=function(){},t.paths=[],t.children||(t.children=[]),Object.defineProperty(t,"loaded",{enumerable:!0,get:function(){return t.l}}),Object.defineProperty(t,"id",{enumerable:!0,get:function(){return t.i}}),t.webpackPolyfill=1),t}},function(t,e){function n(t){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function r(t,e){for(var n,r=0;r<e.length;r++)(n=e[r]).enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}function i(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}var o,a,u="https://api.bullet-train.io/api/v1/",c=function(){function t(e){var r=this;(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")})(this,t),i(this,"getJSON",(function(t,e,n){var i={method:e||"GET",body:n,headers:{"x-environment-key":r.environmentID}};return"GET"!==e&&(i.headers["Content-Type"]="application/json; charset=utf-8"),o(t,i).then((function(t){return 200<=t.status&&300>t.status?t:t.text().then((function(t){var e=t;try{e=JSON.parse(t)}catch(t){}return Promise.reject(e)}))})).then((function(t){return t.json()}))})),i(this,"getFlags",(function(t,e){var n=r.onChange,i=r.onError,o=r.identity,a=r.api,u=(r.disableCache,!1),c=function(t,e){var i=t.flags,o=t.traits,a={},u={};if(o=o||[],(i=i||[]).forEach((function(t){a[t.feature.name.toLowerCase().replace(/ /g,"_")]={enabled:t.enabled,value:t.feature_state_value}})),o.forEach((function(t){u[t.trait_key.toLowerCase().replace(/ /g,"_")]=t.trait_value})),r.oldFlags=a,r.flags=a,r.traits=u,e){var c={};e.map((function(t){c[t.name]=t})),r.segments=c}r.updateStorage(),n&&n(r.oldFlags,{isFromServer:!0})};return o?Promise.all([r.getJSON(a+"identities/?identifier="+encodeURIComponent(o))]).then((function(t){c(t[0],t[1])})).catch((function(t){var e=t.message;i&&i({message:e})})):Promise.all([r.getJSON(a+"flags/")]).then((function(e){c({flags:e[0]},null),t&&!u&&(u=!0,t())})).catch((function(t){e&&!u&&(u=!0,e(t)),i&&i(t)}))})),i(this,"getValue",(function(t){var e=r.flags&&r.flags[t],n=null;return e&&(n=e.value),n})),i(this,"getTrait",(function(t){return r.traits&&r.traits[t]})),i(this,"setTrait",(function(t,e){var n=r.getJSON,i=r.identity,o=r.api;return n("".concat(o,"traits/"),"POST",JSON.stringify({identity:{identifier:i},trait_key:t,trait_value:e})).then((function(){r.initialised&&r.getFlags()}))})),i(this,"setTraits",(function(t){var e=r.getJSON,i=r.identity,o=r.api;t&&"object"===n(t)||console.error("Expected object for bulletTrain.setTraits");var a=Object.keys(t).map((function(e){return{identity:{identifier:i},trait_key:e,trait_value:t[e]}}));return e("".concat(o,"traits/bulk/"),"PUT",JSON.stringify(a)).then((function(){r.initialised&&r.getFlags()}))})),i(this,"incrementTrait",(function(t,e){var n=r.getJSON,i=r.identity,o=r.api;return n("".concat(o,"traits/increment-value/"),"POST",JSON.stringify({trait_key:t,increment_by:e,identifier:i})).then(r.getFlags)})),i(this,"hasFeature",(function(t){var e=r.flags&&r.flags[t],n=!1;return e&&e.enabled&&(n=!0),n})),o=e.fetch?e.fetch:global.fetch,a=e.AsyncStorage}return function(t,e,n){e&&r(t.prototype,e),n&&r(t,n)}(t,[{key:"init",value:function(t){var e=this,n=t.environmentID,r=t.api,i=void 0===r?u:r,o=t.onChange,c=t.cacheFlags,s=t.onError,l=t.defaultFlags,f=t.preventFetch,h=t.enableLogs,p=t.AsyncStorage,v=t.state;return new Promise((function(t,r){if(e.environmentID=n,e.api=i,e.interval=null,e.onChange=o,e.onError=s,e.enableLogs=h,e.flags=Object.assign({},l)||{},e.initialised=!0,e.timer=e.enableLogs?(new Date).valueOf():null,p&&(a=p),e.cacheFlags=void 0!==a&&c,e.setState(v),!n)throw r("Please specify a environment id"),"Please specify a environment id";c?a.getItem("BULLET_TRAIN_DB",(function(n,i){if(i)try{var o=JSON.parse(i);o&&o.api===e.api&&(e.setState(o),e.log("Retrieved flags from cache",o)),e.flags?(e.onChange&&e.onChange(null,{isFromServer:!1}),t(),e.getFlags(Promise.resolve,Promise.reject)):e.getFlags(t,r)}catch(t){e.log("Exception fetching cached logs",t)}})):!f&&e.getFlags(t,r)}))}},{key:"getAllFlags",value:function(){return this.flags}},{key:"identify",value:function(t){this.identity=t,this.initialised&&!this.interval&&this.getFlags()}},{key:"getState",value:function(){return{api:this.api,environmentID:this.environmentID,flags:this.flags,identity:this.identity,segments:this.segments,traits:this.traits}}},{key:"setState",value:function(t){t&&(this.initialised=!0,this.api=t.api||this.api||u,this.environmentID=t.environmentID||this.environmentID,this.flags=t.flags||this.flags,this.identity=t.identity||this.identity,this.segments=t.segments||this.segments,this.traits=t.traits||this.traits)}},{key:"log",value:function(){if(this.enableLogs){for(var t=arguments.length,e=Array(t),n=0;n<t;n++)e[n]=arguments[n];console.log.apply(this,["BULLET TRAIN:",(new Date).valueOf()-this.timer,"ms"].concat(e))}}},{key:"updateStorage",value:function(){if(this.cacheFlags){var t=JSON.stringify(this.getState());this.log("Setting storage",t),a.setItem("BULLET_TRAIN_DB",t)}}},{key:"logout",value:function(){this.identity=null,this.segments=null,this.traits=null,this.initialised&&!this.interval&&this.getFlags()}},{key:"startListening",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:1e3;this.interval||(this.interval=setInterval(this.getFlags,t))}},{key:"getSegments",value:function(){}},{key:"stopListening",value:function(){clearInterval(this.interval)}}]),t}();t.exports=function(t){var e=t.fetch,n=t.AsyncStorage;return new c({fetch:e,AsyncStorage:n})}}])}));

@@ -1,1 +0,1 @@

!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var r=t();for(var n in r)("object"==typeof exports?exports:e)[n]=r[n]}}(this,(function(){return function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=6)}([function(e,t){e.exports=require("stream")},function(e,t){e.exports=require("zlib")},function(e,t){e.exports=require("url")},function(e,t){e.exports=require("http")},function(e,t){e.exports=require("https")},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n,o=function(e,t){if(Array.isArray(e))return e;if(Symbol.iterator in Object(e))return function(e,t){var r=[],n=!0,o=!1,i=void 0;try{for(var s,a=e[Symbol.iterator]();!(n=(s=a.next()).done)&&(r.push(s.value),!t||r.length!==t);n=!0);}catch(e){o=!0,i=e}finally{try{!n&&a.return&&a.return()}finally{if(o)throw i}}return r}(e,t);throw new TypeError("Invalid attempt to destructure non-iterable instance")},i=r(9),s=(n=i)&&n.__esModule?n:{default:n};var a={getItem:function(e,t){return a.multiGet([e]).then((function(e){return e[0][1]})).then((function(e){return t&&t(null,e),e})).catch((function(e){return t&&t(e,null),e}))},setItem:function(e,t,r){return a.multiSet([[e,t]]).then((function(e){return r&&r(null,e),e})).catch((function(e){return r&&r(e,null),e}))},getAllKeys:function(e){return Promise.resolve(Object.keys(localStorage)).then((function(t){return e&&e(null,t),t})).catch((function(t){return e&&e(t,null),t}))},removeItem:function(e,t){return a.multiRemove([e]).then((function(){t&&t(null)})).catch((function(e){t&&t(e,null)}))},clear:function(){return new Promise((function(e){window.localStorage.clear(),e()}))},mergeItem:function(e,t){return a.multiMerge([[e,t]])},multiGet:function(e){return new Promise((function(t){t(e.reduce((function(e,t){return e.concat([[t,localStorage.getItem(t)]])}),[]))}))},multiSet:function(e){return new Promise((function(t,r){var n=[];return e.forEach((function(e){var t=o(e,2),r=t[0],i=t[1];try{localStorage.setItem(r,i)}catch(e){n.push(e)}})),n.length>0?r(n):t()}))},multiMerge:function(e){return new Promise((function(t,r){var n=[];return e.forEach((function(e){var t=o(e,2),r=t[0],i=t[1],a=localStorage.getItem(r);if(a)try{localStorage.setItem(r,JSON.stringify((0,s.default)(JSON.parse(a),JSON.parse(i))))}catch(e){n.push(e)}})),n.length>0?r(n):t()}))},multiRemove:function(e){return new Promise((function(t){e.forEach((function(e){return window.localStorage.removeItem(e)})),t()}))},flushGetRequests:function(){console.warn("AsyncStorage.flushGetRequests: Not supported on `web`")}};t.default=a},function(e,t,r){"use strict";r.r(t);var n=r(5),o=r.n(n),i=r(7).default;"undefined"==typeof window&&(i=r(8).default);var s=r(11)({AsyncStorage:o.a,fetch:i});"undefined"!=typeof window&&(window.bulletTrain=s),t.default=s},function(e,t,r){"use strict";r.r(t),t.default=function(e,t){return t=t||{},new Promise((function(r,n){var o=new XMLHttpRequest,i=[],s=[],a={},u=function(){return{ok:2==(o.status/100|0),statusText:o.statusText,status:o.status,url:o.responseURL,text:function(){return Promise.resolve(o.responseText)},json:function(){return Promise.resolve(JSON.parse(o.responseText))},blob:function(){return Promise.resolve(new Blob([o.response]))},clone:u,headers:{keys:function(){return i},entries:function(){return s},get:function(e){return a[e.toLowerCase()]},has:function(e){return e.toLowerCase()in a}}}};for(var c in o.open(t.method||"get",e,!0),o.onload=function(){o.getAllResponseHeaders().replace(/^(.*?):[^\S\n]*([\s\S]*?)$/gm,(function(e,t,r){i.push(t=t.toLowerCase()),s.push([t,r]),a[t]=a[t]?a[t]+","+r:r})),r(u())},o.onerror=n,o.withCredentials="include"==t.credentials,t.headers)o.setRequestHeader(c,t.headers[c]);o.send(t.body||null)}))}},function(e,t,r){"use strict";r.r(t),r.d(t,"Headers",(function(){return A})),r.d(t,"Request",(function(){return M})),r.d(t,"Response",(function(){return F})),r.d(t,"FetchError",(function(){return h}));var n=r(0),o=r(3),i=r(2),s=r(4),a=r(1);const u=n.Readable,c=Symbol("buffer"),l=Symbol("type");class f{constructor(){this[l]="";const e=arguments[0],t=arguments[1],r=[];let n=0;if(e){const t=e,o=Number(t.length);for(let e=0;e<o;e++){const o=t[e];let i;n+=(i=o instanceof Buffer?o:ArrayBuffer.isView(o)?Buffer.from(o.buffer,o.byteOffset,o.byteLength):o instanceof ArrayBuffer?Buffer.from(o):o instanceof f?o[c]:Buffer.from("string"==typeof o?o:String(o))).length,r.push(i)}}this[c]=Buffer.concat(r);let o=t&&void 0!==t.type&&String(t.type).toLowerCase();o&&!/[^\u0020-\u007E]/.test(o)&&(this[l]=o)}get size(){return this[c].length}get type(){return this[l]}text(){return Promise.resolve(this[c].toString())}arrayBuffer(){const e=this[c],t=e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength);return Promise.resolve(t)}stream(){const e=new u;return e._read=function(){},e.push(this[c]),e.push(null),e}toString(){return"[object Blob]"}slice(){const e=this.size,t=arguments[0],r=arguments[1];let n,o;n=void 0===t?0:t<0?Math.max(e+t,0):Math.min(t,e),o=void 0===r?e:r<0?Math.max(e+r,0):Math.min(r,e);const i=Math.max(o-n,0),s=this[c].slice(n,n+i),a=new f([],{type:arguments[2]});return a[c]=s,a}}function h(e,t,r){Error.call(this,e),this.message=e,this.type=t,r&&(this.code=this.errno=r.code),Error.captureStackTrace(this,this.constructor)}let p;Object.defineProperties(f.prototype,{size:{enumerable:!0},type:{enumerable:!0},slice:{enumerable:!0}}),Object.defineProperty(f.prototype,Symbol.toStringTag,{value:"Blob",writable:!1,enumerable:!1,configurable:!0}),h.prototype=Object.create(Error.prototype),h.prototype.constructor=h,h.prototype.name="FetchError";try{p=require("encoding").convert}catch(e){}const d=Symbol("Body internals"),y=n.PassThrough;function b(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=r.size;let i=void 0===o?0:o;var s=r.timeout;let a=void 0===s?0:s;null==e?e=null:m(e)?e=Buffer.from(e.toString()):v(e)||Buffer.isBuffer(e)||("[object ArrayBuffer]"===Object.prototype.toString.call(e)?e=Buffer.from(e):ArrayBuffer.isView(e)?e=Buffer.from(e.buffer,e.byteOffset,e.byteLength):e instanceof n||(e=Buffer.from(String(e)))),this[d]={body:e,disturbed:!1,error:null},this.size=i,this.timeout=a,e instanceof n&&e.on("error",(function(e){const r="AbortError"===e.name?e:new h(`Invalid response body while trying to fetch ${t.url}: ${e.message}`,"system",e);t[d].error=r}))}function g(){var e=this;if(this[d].disturbed)return b.Promise.reject(new TypeError(`body used already for: ${this.url}`));if(this[d].disturbed=!0,this[d].error)return b.Promise.reject(this[d].error);let t=this.body;if(null===t)return b.Promise.resolve(Buffer.alloc(0));if(v(t)&&(t=t.stream()),Buffer.isBuffer(t))return b.Promise.resolve(t);if(!(t instanceof n))return b.Promise.resolve(Buffer.alloc(0));let r=[],o=0,i=!1;return new b.Promise((function(n,s){let a;e.timeout&&(a=setTimeout((function(){i=!0,s(new h(`Response timeout while trying to fetch ${e.url} (over ${e.timeout}ms)`,"body-timeout"))}),e.timeout)),t.on("error",(function(t){"AbortError"===t.name?(i=!0,s(t)):s(new h(`Invalid response body while trying to fetch ${e.url}: ${t.message}`,"system",t))})),t.on("data",(function(t){if(!i&&null!==t){if(e.size&&o+t.length>e.size)return i=!0,void s(new h(`content size at ${e.url} over limit: ${e.size}`,"max-size"));o+=t.length,r.push(t)}})),t.on("end",(function(){if(!i){clearTimeout(a);try{n(Buffer.concat(r,o))}catch(t){s(new h(`Could not create Buffer from response body for ${e.url}: ${t.message}`,"system",t))}}}))}))}function m(e){return"object"==typeof e&&"function"==typeof e.append&&"function"==typeof e.delete&&"function"==typeof e.get&&"function"==typeof e.getAll&&"function"==typeof e.has&&"function"==typeof e.set&&("URLSearchParams"===e.constructor.name||"[object URLSearchParams]"===Object.prototype.toString.call(e)||"function"==typeof e.sort)}function v(e){return"object"==typeof e&&"function"==typeof e.arrayBuffer&&"string"==typeof e.type&&"function"==typeof e.stream&&"function"==typeof e.constructor&&"string"==typeof e.constructor.name&&/^(Blob|File)$/.test(e.constructor.name)&&/^(Blob|File)$/.test(e[Symbol.toStringTag])}function w(e){let t,r,o=e.body;if(e.bodyUsed)throw new Error("cannot clone body after it is used");return o instanceof n&&"function"!=typeof o.getBoundary&&(t=new y,r=new y,o.pipe(t),o.pipe(r),e[d].body=t,o=r),o}function _(e){return null===e?null:"string"==typeof e?"text/plain;charset=UTF-8":m(e)?"application/x-www-form-urlencoded;charset=UTF-8":v(e)?e.type||null:Buffer.isBuffer(e)?null:"[object ArrayBuffer]"===Object.prototype.toString.call(e)?null:ArrayBuffer.isView(e)?null:"function"==typeof e.getBoundary?`multipart/form-data;boundary=${e.getBoundary()}`:e instanceof n?null:"text/plain;charset=UTF-8"}function j(e){const t=e.body;return null===t?0:v(t)?t.size:Buffer.isBuffer(t)?t.length:t&&"function"==typeof t.getLengthSync&&(t._lengthRetrievers&&0==t._lengthRetrievers.length||t.hasKnownLength&&t.hasKnownLength())?t.getLengthSync():null}b.prototype={get body(){return this[d].body},get bodyUsed(){return this[d].disturbed},arrayBuffer(){return g.call(this).then((function(e){return e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength)}))},blob(){let e=this.headers&&this.headers.get("content-type")||"";return g.call(this).then((function(t){return Object.assign(new f([],{type:e.toLowerCase()}),{[c]:t})}))},json(){var e=this;return g.call(this).then((function(t){try{return JSON.parse(t.toString())}catch(t){return b.Promise.reject(new h(`invalid json response body at ${e.url} reason: ${t.message}`,"invalid-json"))}}))},text(){return g.call(this).then((function(e){return e.toString()}))},buffer(){return g.call(this)},textConverted(){var e=this;return g.call(this).then((function(t){return function(e,t){if("function"!=typeof p)throw new Error("The package `encoding` must be installed to use the textConverted() function");const r=t.get("content-type");let n,o,i="utf-8";r&&(n=/charset=([^;]*)/i.exec(r));o=e.slice(0,1024).toString(),!n&&o&&(n=/<meta.+?charset=(['"])(.+?)\1/i.exec(o));!n&&o&&(n=/<meta[\s]+?http-equiv=(['"])content-type\1[\s]+?content=(['"])(.+?)\2/i.exec(o))&&(n=/charset=(.*)/i.exec(n.pop()));!n&&o&&(n=/<\?xml.+?encoding=(['"])(.+?)\1/i.exec(o));n&&("gb2312"!==(i=n.pop())&&"gbk"!==i||(i="gb18030"));return p(e,"UTF-8",i).toString()}(t,e.headers)}))}},Object.defineProperties(b.prototype,{body:{enumerable:!0},bodyUsed:{enumerable:!0},arrayBuffer:{enumerable:!0},blob:{enumerable:!0},json:{enumerable:!0},text:{enumerable:!0}}),b.mixIn=function(e){for(const t of Object.getOwnPropertyNames(b.prototype))if(!(t in e)){const r=Object.getOwnPropertyDescriptor(b.prototype,t);Object.defineProperty(e,t,r)}},b.Promise=global.Promise;const S=/[^\^_`a-zA-Z\-0-9!#$%&'*+.|~]/,O=/[^\t\x20-\x7e\x80-\xff]/;function T(e){if(e=`${e}`,S.test(e)||""===e)throw new TypeError(`${e} is not a legal HTTP header name`)}function P(e){if(e=`${e}`,O.test(e))throw new TypeError(`${e} is not a legal HTTP header value`)}function x(e,t){t=t.toLowerCase();for(const r in e)if(r.toLowerCase()===t)return r}const E=Symbol("map");class A{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:void 0;if(this[E]=Object.create(null),e instanceof A){const t=e.raw(),r=Object.keys(t);for(const e of r)for(const r of t[e])this.append(e,r)}else if(null==e);else{if("object"!=typeof e)throw new TypeError("Provided initializer must be an object");{const t=e[Symbol.iterator];if(null!=t){if("function"!=typeof t)throw new TypeError("Header pairs must be iterable");const r=[];for(const t of e){if("object"!=typeof t||"function"!=typeof t[Symbol.iterator])throw new TypeError("Each header pair must be iterable");r.push(Array.from(t))}for(const e of r){if(2!==e.length)throw new TypeError("Each header pair must be a name/value tuple");this.append(e[0],e[1])}}else for(const t of Object.keys(e)){const r=e[t];this.append(t,r)}}}}get(e){T(e=`${e}`);const t=x(this[E],e);return void 0===t?null:this[E][t].join(", ")}forEach(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:void 0,r=B(this),n=0;for(;n<r.length;){var o=r[n];const i=o[0],s=o[1];e.call(t,s,i,this),r=B(this),n++}}set(e,t){t=`${t}`,T(e=`${e}`),P(t);const r=x(this[E],e);this[E][void 0!==r?r:e]=[t]}append(e,t){t=`${t}`,T(e=`${e}`),P(t);const r=x(this[E],e);void 0!==r?this[E][r].push(t):this[E][e]=[t]}has(e){return T(e=`${e}`),void 0!==x(this[E],e)}delete(e){T(e=`${e}`);const t=x(this[E],e);void 0!==t&&delete this[E][t]}raw(){return this[E]}keys(){return L(this,"key")}values(){return L(this,"value")}[Symbol.iterator](){return L(this,"key+value")}}function B(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"key+value";return Object.keys(e[E]).sort().map("key"===t?function(e){return e.toLowerCase()}:"value"===t?function(t){return e[E][t].join(", ")}:function(t){return[t.toLowerCase(),e[E][t].join(", ")]})}A.prototype.entries=A.prototype[Symbol.iterator],Object.defineProperty(A.prototype,Symbol.toStringTag,{value:"Headers",writable:!1,enumerable:!1,configurable:!0}),Object.defineProperties(A.prototype,{get:{enumerable:!0},forEach:{enumerable:!0},set:{enumerable:!0},append:{enumerable:!0},has:{enumerable:!0},delete:{enumerable:!0},keys:{enumerable:!0},values:{enumerable:!0},entries:{enumerable:!0}});const k=Symbol("internal");function L(e,t){const r=Object.create(C);return r[k]={target:e,kind:t,index:0},r}const C=Object.setPrototypeOf({next(){if(!this||Object.getPrototypeOf(this)!==C)throw new TypeError("Value of `this` is not a HeadersIterator");var e=this[k];const t=e.target,r=e.kind,n=e.index,o=B(t,r);return n>=o.length?{value:void 0,done:!0}:(this[k].index=n+1,{value:o[n],done:!1})}},Object.getPrototypeOf(Object.getPrototypeOf([][Symbol.iterator]())));function $(e){const t=Object.assign({__proto__:null},e[E]),r=x(e[E],"Host");return void 0!==r&&(t[r]=t[r][0]),t}Object.defineProperty(C,Symbol.toStringTag,{value:"HeadersIterator",writable:!1,enumerable:!1,configurable:!0});const z=Symbol("Response internals"),I=o.STATUS_CODES;class F{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};b.call(this,e,t);const r=t.status||200,n=new A(t.headers);if(null!=e&&!n.has("Content-Type")){const t=_(e);t&&n.append("Content-Type",t)}this[z]={url:t.url,status:r,statusText:t.statusText||I[r],headers:n,counter:t.counter}}get url(){return this[z].url||""}get status(){return this[z].status}get ok(){return this[z].status>=200&&this[z].status<300}get redirected(){return this[z].counter>0}get statusText(){return this[z].statusText}get headers(){return this[z].headers}clone(){return new F(w(this),{url:this.url,status:this.status,statusText:this.statusText,headers:this.headers,ok:this.ok,redirected:this.redirected})}}b.mixIn(F.prototype),Object.defineProperties(F.prototype,{url:{enumerable:!0},status:{enumerable:!0},ok:{enumerable:!0},redirected:{enumerable:!0},statusText:{enumerable:!0},headers:{enumerable:!0},clone:{enumerable:!0}}),Object.defineProperty(F.prototype,Symbol.toStringTag,{value:"Response",writable:!1,enumerable:!1,configurable:!0});const R=Symbol("Request internals"),U=i.parse,N=i.format,q="destroy"in n.Readable.prototype;function D(e){return"object"==typeof e&&"object"==typeof e[R]}class M{constructor(e){let t,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};D(e)?t=U(e.url):(t=e&&e.href?U(e.href):U(`${e}`),e={});let n=r.method||e.method||"GET";if(n=n.toUpperCase(),(null!=r.body||D(e)&&null!==e.body)&&("GET"===n||"HEAD"===n))throw new TypeError("Request with GET/HEAD method cannot have body");let o=null!=r.body?r.body:D(e)&&null!==e.body?w(e):null;b.call(this,o,{timeout:r.timeout||e.timeout||0,size:r.size||e.size||0});const i=new A(r.headers||e.headers||{});if(null!=o&&!i.has("Content-Type")){const e=_(o);e&&i.append("Content-Type",e)}let s=D(e)?e.signal:null;if("signal"in r&&(s=r.signal),null!=s&&!function(e){const t=e&&"object"==typeof e&&Object.getPrototypeOf(e);return!(!t||"AbortSignal"!==t.constructor.name)}(s))throw new TypeError("Expected signal to be an instanceof AbortSignal");this[R]={method:n,redirect:r.redirect||e.redirect||"follow",headers:i,parsedURL:t,signal:s},this.follow=void 0!==r.follow?r.follow:void 0!==e.follow?e.follow:20,this.compress=void 0!==r.compress?r.compress:void 0===e.compress||e.compress,this.counter=r.counter||e.counter||0,this.agent=r.agent||e.agent}get method(){return this[R].method}get url(){return N(this[R].parsedURL)}get headers(){return this[R].headers}get redirect(){return this[R].redirect}get signal(){return this[R].signal}clone(){return new M(this)}}function H(e){Error.call(this,e),this.type="aborted",this.message=e,Error.captureStackTrace(this,this.constructor)}b.mixIn(M.prototype),Object.defineProperty(M.prototype,Symbol.toStringTag,{value:"Request",writable:!1,enumerable:!1,configurable:!0}),Object.defineProperties(M.prototype,{method:{enumerable:!0},url:{enumerable:!0},headers:{enumerable:!0},redirect:{enumerable:!0},clone:{enumerable:!0},signal:{enumerable:!0}}),H.prototype=Object.create(Error.prototype),H.prototype.constructor=H,H.prototype.name="AbortError";const J=n.PassThrough,G=i.resolve;function V(e,t){if(!V.Promise)throw new Error("native promise missing, set fetch.Promise to your favorite alternative");return b.Promise=V.Promise,new V.Promise((function(r,i){const u=new M(e,t),c=function(e){const t=e[R].parsedURL,r=new A(e[R].headers);if(r.has("Accept")||r.set("Accept","*/*"),!t.protocol||!t.hostname)throw new TypeError("Only absolute URLs are supported");if(!/^https?:$/.test(t.protocol))throw new TypeError("Only HTTP(S) protocols are supported");if(e.signal&&e.body instanceof n.Readable&&!q)throw new Error("Cancellation of streamed requests with AbortSignal is not supported in node < 8");let o=null;if(null==e.body&&/^(POST|PUT)$/i.test(e.method)&&(o="0"),null!=e.body){const t=j(e);"number"==typeof t&&(o=String(t))}o&&r.set("Content-Length",o),r.has("User-Agent")||r.set("User-Agent","node-fetch/1.0 (+https://github.com/bitinn/node-fetch)"),e.compress&&!r.has("Accept-Encoding")&&r.set("Accept-Encoding","gzip,deflate");let i=e.agent;return"function"==typeof i&&(i=i(t)),r.has("Connection")||i||r.set("Connection","close"),Object.assign({},t,{method:e.method,headers:$(r),agent:i})}(u),l=("https:"===c.protocol?s:o).request,f=u.signal;let p=null;const d=function(){let e=new H("The user aborted a request.");i(e),u.body&&u.body instanceof n.Readable&&u.body.destroy(e),p&&p.body&&p.body.emit("error",e)};if(f&&f.aborted)return void d();const y=function(){d(),m()},b=l(c);let g;function m(){b.abort(),f&&f.removeEventListener("abort",y),clearTimeout(g)}f&&f.addEventListener("abort",y),u.timeout&&b.once("socket",(function(e){g=setTimeout((function(){i(new h(`network timeout at: ${u.url}`,"request-timeout")),m()}),u.timeout)})),b.on("error",(function(e){i(new h(`request to ${u.url} failed, reason: ${e.message}`,"system",e)),m()})),b.on("response",(function(e){clearTimeout(g);const t=function(e){const t=new A;for(const r of Object.keys(e))if(!S.test(r))if(Array.isArray(e[r]))for(const n of e[r])O.test(n)||(void 0===t[E][r]?t[E][r]=[n]:t[E][r].push(n));else O.test(e[r])||(t[E][r]=[e[r]]);return t}(e.headers);if(V.isRedirect(e.statusCode)){const n=t.get("Location"),o=null===n?null:G(u.url,n);switch(u.redirect){case"error":return i(new h(`redirect mode is set to error: ${u.url}`,"no-redirect")),void m();case"manual":if(null!==o)try{t.set("Location",o)}catch(e){i(e)}break;case"follow":if(null===o)break;if(u.counter>=u.follow)return i(new h(`maximum redirect reached at: ${u.url}`,"max-redirect")),void m();const n={headers:new A(u.headers),follow:u.follow,counter:u.counter+1,agent:u.agent,compress:u.compress,method:u.method,body:u.body,signal:u.signal,timeout:u.timeout};return 303!==e.statusCode&&u.body&&null===j(u)?(i(new h("Cannot follow redirect with body being a readable stream","unsupported-redirect")),void m()):(303!==e.statusCode&&(301!==e.statusCode&&302!==e.statusCode||"POST"!==u.method)||(n.method="GET",n.body=void 0,n.headers.delete("content-length")),r(V(new M(o,n))),void m())}}e.once("end",(function(){f&&f.removeEventListener("abort",y)}));let n=e.pipe(new J);const o={url:u.url,status:e.statusCode,statusText:e.statusMessage,headers:t,size:u.size,timeout:u.timeout,counter:u.counter},s=t.get("Content-Encoding");if(!u.compress||"HEAD"===u.method||null===s||204===e.statusCode||304===e.statusCode)return p=new F(n,o),void r(p);const c={flush:a.Z_SYNC_FLUSH,finishFlush:a.Z_SYNC_FLUSH};if("gzip"==s||"x-gzip"==s)return n=n.pipe(a.createGunzip(c)),p=new F(n,o),void r(p);if("deflate"!=s&&"x-deflate"!=s){if("br"==s&&"function"==typeof a.createBrotliDecompress)return n=n.pipe(a.createBrotliDecompress()),p=new F(n,o),void r(p);p=new F(n,o),r(p)}else{e.pipe(new J).once("data",(function(e){n=8==(15&e[0])?n.pipe(a.createInflate()):n.pipe(a.createInflateRaw()),p=new F(n,o),r(p)}))}})),function(e,t){const r=t.body;null===r?e.end():v(r)?r.stream().pipe(e):Buffer.isBuffer(r)?(e.write(r),e.end()):r.pipe(e)}(b,u)}))}V.isRedirect=function(e){return 301===e||302===e||303===e||307===e||308===e},V.Promise=global.Promise,t.default=V},function(e,t,r){(function(e){var r=200,n="__lodash_hash_undefined__",o=800,i=16,s=9007199254740991,a="[object Arguments]",u="[object AsyncFunction]",c="[object Function]",l="[object GeneratorFunction]",f="[object Null]",h="[object Object]",p="[object Proxy]",d="[object Undefined]",y=/^\[object .+?Constructor\]$/,b=/^(?:0|[1-9]\d*)$/,g={};g["[object Float32Array]"]=g["[object Float64Array]"]=g["[object Int8Array]"]=g["[object Int16Array]"]=g["[object Int32Array]"]=g["[object Uint8Array]"]=g["[object Uint8ClampedArray]"]=g["[object Uint16Array]"]=g["[object Uint32Array]"]=!0,g[a]=g["[object Array]"]=g["[object ArrayBuffer]"]=g["[object Boolean]"]=g["[object DataView]"]=g["[object Date]"]=g["[object Error]"]=g[c]=g["[object Map]"]=g["[object Number]"]=g[h]=g["[object RegExp]"]=g["[object Set]"]=g["[object String]"]=g["[object WeakMap]"]=!1;var m="object"==typeof global&&global&&global.Object===Object&&global,v="object"==typeof self&&self&&self.Object===Object&&self,w=m||v||Function("return this")(),_=t&&!t.nodeType&&t,j=_&&"object"==typeof e&&e&&!e.nodeType&&e,S=j&&j.exports===_,O=S&&m.process,T=function(){try{var e=j&&j.require&&j.require("util").types;return e||O&&O.binding&&O.binding("util")}catch(e){}}(),P=T&&T.isTypedArray;function x(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 E,A,B,k=Array.prototype,L=Function.prototype,C=Object.prototype,$=w["__core-js_shared__"],z=L.toString,I=C.hasOwnProperty,F=(E=/[^.]+$/.exec($&&$.keys&&$.keys.IE_PROTO||""))?"Symbol(src)_1."+E:"",R=C.toString,U=z.call(Object),N=RegExp("^"+z.call(I).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),q=S?w.Buffer:void 0,D=w.Symbol,M=w.Uint8Array,H=q?q.allocUnsafe:void 0,J=(A=Object.getPrototypeOf,B=Object,function(e){return A(B(e))}),G=Object.create,V=C.propertyIsEnumerable,K=k.splice,Z=D?D.toStringTag:void 0,Y=function(){try{var e=_e(Object,"defineProperty");return e({},"",{}),e}catch(e){}}(),W=q?q.isBuffer:void 0,X=Math.max,Q=Date.now,ee=_e(w,"Map"),te=_e(Object,"create"),re=function(){function e(){}return function(t){if(!Ce(t))return{};if(G)return G(t);e.prototype=t;var r=new e;return e.prototype=void 0,r}}();function ne(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])}}function oe(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])}}function ie(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])}}function se(e){var t=this.__data__=new oe(e);this.size=t.size}function ae(e,t){var r=Ee(e),n=!r&&xe(e),o=!r&&!n&&Be(e),i=!r&&!n&&!o&&ze(e),s=r||n||o||i,a=s?function(e,t){for(var r=-1,n=Array(e);++r<e;)n[r]=t(r);return n}(e.length,String):[],u=a.length;for(var c in e)!t&&!I.call(e,c)||s&&("length"==c||o&&("offset"==c||"parent"==c)||i&&("buffer"==c||"byteLength"==c||"byteOffset"==c)||je(c,u))||a.push(c);return a}function ue(e,t,r){(void 0===r||Pe(e[t],r))&&(void 0!==r||t in e)||fe(e,t,r)}function ce(e,t,r){var n=e[t];I.call(e,t)&&Pe(n,r)&&(void 0!==r||t in e)||fe(e,t,r)}function le(e,t){for(var r=e.length;r--;)if(Pe(e[r][0],t))return r;return-1}function fe(e,t,r){"__proto__"==t&&Y?Y(e,t,{configurable:!0,enumerable:!0,value:r,writable:!0}):e[t]=r}ne.prototype.clear=function(){this.__data__=te?te(null):{},this.size=0},ne.prototype.delete=function(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t},ne.prototype.get=function(e){var t=this.__data__;if(te){var r=t[e];return r===n?void 0:r}return I.call(t,e)?t[e]:void 0},ne.prototype.has=function(e){var t=this.__data__;return te?void 0!==t[e]:I.call(t,e)},ne.prototype.set=function(e,t){var r=this.__data__;return this.size+=this.has(e)?0:1,r[e]=te&&void 0===t?n:t,this},oe.prototype.clear=function(){this.__data__=[],this.size=0},oe.prototype.delete=function(e){var t=this.__data__,r=le(t,e);return!(r<0)&&(r==t.length-1?t.pop():K.call(t,r,1),--this.size,!0)},oe.prototype.get=function(e){var t=this.__data__,r=le(t,e);return r<0?void 0:t[r][1]},oe.prototype.has=function(e){return le(this.__data__,e)>-1},oe.prototype.set=function(e,t){var r=this.__data__,n=le(r,e);return n<0?(++this.size,r.push([e,t])):r[n][1]=t,this},ie.prototype.clear=function(){this.size=0,this.__data__={hash:new ne,map:new(ee||oe),string:new ne}},ie.prototype.delete=function(e){var t=we(this,e).delete(e);return this.size-=t?1:0,t},ie.prototype.get=function(e){return we(this,e).get(e)},ie.prototype.has=function(e){return we(this,e).has(e)},ie.prototype.set=function(e,t){var r=we(this,e),n=r.size;return r.set(e,t),this.size+=r.size==n?0:1,this},se.prototype.clear=function(){this.__data__=new oe,this.size=0},se.prototype.delete=function(e){var t=this.__data__,r=t.delete(e);return this.size=t.size,r},se.prototype.get=function(e){return this.__data__.get(e)},se.prototype.has=function(e){return this.__data__.has(e)},se.prototype.set=function(e,t){var n=this.__data__;if(n instanceof oe){var o=n.__data__;if(!ee||o.length<r-1)return o.push([e,t]),this.size=++n.size,this;n=this.__data__=new ie(o)}return n.set(e,t),this.size=n.size,this};var he,pe=function(e,t,r){for(var n=-1,o=Object(e),i=r(e),s=i.length;s--;){var a=i[he?s:++n];if(!1===t(o[a],a,o))break}return e};function de(e){return null==e?void 0===e?d:f:Z&&Z in Object(e)?function(e){var t=I.call(e,Z),r=e[Z];try{e[Z]=void 0;var n=!0}catch(e){}var o=R.call(e);n&&(t?e[Z]=r:delete e[Z]);return o}(e):function(e){return R.call(e)}(e)}function ye(e){return $e(e)&&de(e)==a}function be(e){return!(!Ce(e)||function(e){return!!F&&F in e}(e))&&(ke(e)?N:y).test(function(e){if(null!=e){try{return z.call(e)}catch(e){}try{return e+""}catch(e){}}return""}(e))}function ge(e){if(!Ce(e))return function(e){var t=[];if(null!=e)for(var r in Object(e))t.push(r);return t}(e);var t=Se(e),r=[];for(var n in e)("constructor"!=n||!t&&I.call(e,n))&&r.push(n);return r}function me(e,t,r,n,o){e!==t&&pe(t,(function(i,s){if(o||(o=new se),Ce(i))!function(e,t,r,n,o,i,s){var a=Oe(e,r),u=Oe(t,r),c=s.get(u);if(c)return void ue(e,r,c);var l=i?i(a,u,r+"",e,t,s):void 0,f=void 0===l;if(f){var p=Ee(u),d=!p&&Be(u),y=!p&&!d&&ze(u);l=u,p||d||y?Ee(a)?l=a:$e(w=a)&&Ae(w)?l=function(e,t){var r=-1,n=e.length;t||(t=Array(n));for(;++r<n;)t[r]=e[r];return t}(a):d?(f=!1,l=function(e,t){if(t)return e.slice();var r=e.length,n=H?H(r):new e.constructor(r);return e.copy(n),n}(u,!0)):y?(f=!1,b=u,g=!0?(m=b.buffer,v=new m.constructor(m.byteLength),new M(v).set(new M(m)),v):b.buffer,l=new b.constructor(g,b.byteOffset,b.length)):l=[]:function(e){if(!$e(e)||de(e)!=h)return!1;var t=J(e);if(null===t)return!0;var r=I.call(t,"constructor")&&t.constructor;return"function"==typeof r&&r instanceof r&&z.call(r)==U}(u)||xe(u)?(l=a,xe(a)?l=function(e){return function(e,t,r,n){var o=!r;r||(r={});var i=-1,s=t.length;for(;++i<s;){var a=t[i],u=n?n(r[a],e[a],a,r,e):void 0;void 0===u&&(u=e[a]),o?fe(r,a,u):ce(r,a,u)}return r}(e,Ie(e))}(a):Ce(a)&&!ke(a)||(l=function(e){return"function"!=typeof e.constructor||Se(e)?{}:re(J(e))}(u))):f=!1}var b,g,m,v;var w;f&&(s.set(u,l),o(l,u,n,i,s),s.delete(u));ue(e,r,l)}(e,t,s,r,me,n,o);else{var a=n?n(Oe(e,s),i,s+"",e,t,o):void 0;void 0===a&&(a=i),ue(e,s,a)}}),Ie)}function ve(e,t){return Te(function(e,t,r){return t=X(void 0===t?e.length-1:t,0),function(){for(var n=arguments,o=-1,i=X(n.length-t,0),s=Array(i);++o<i;)s[o]=n[t+o];o=-1;for(var a=Array(t+1);++o<t;)a[o]=n[o];return a[t]=r(s),x(e,this,a)}}(e,t,Ue),e+"")}function we(e,t){var r,n,o=e.__data__;return("string"==(n=typeof(r=t))||"number"==n||"symbol"==n||"boolean"==n?"__proto__"!==r:null===r)?o["string"==typeof t?"string":"hash"]:o.map}function _e(e,t){var r=function(e,t){return null==e?void 0:e[t]}(e,t);return be(r)?r:void 0}function je(e,t){var r=typeof e;return!!(t=null==t?s:t)&&("number"==r||"symbol"!=r&&b.test(e))&&e>-1&&e%1==0&&e<t}function Se(e){var t=e&&e.constructor;return e===("function"==typeof t&&t.prototype||C)}function Oe(e,t){if(("constructor"!==t||"function"!=typeof e[t])&&"__proto__"!=t)return e[t]}var Te=function(e){var t=0,r=0;return function(){var n=Q(),s=i-(n-r);if(r=n,s>0){if(++t>=o)return arguments[0]}else t=0;return e.apply(void 0,arguments)}}(Y?function(e,t){return Y(e,"toString",{configurable:!0,enumerable:!1,value:(r=t,function(){return r}),writable:!0});var r}:Ue);function Pe(e,t){return e===t||e!=e&&t!=t}var xe=ye(function(){return arguments}())?ye:function(e){return $e(e)&&I.call(e,"callee")&&!V.call(e,"callee")},Ee=Array.isArray;function Ae(e){return null!=e&&Le(e.length)&&!ke(e)}var Be=W||function(){return!1};function ke(e){if(!Ce(e))return!1;var t=de(e);return t==c||t==l||t==u||t==p}function Le(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=s}function Ce(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}function $e(e){return null!=e&&"object"==typeof e}var ze=P?function(e){return function(t){return e(t)}}(P):function(e){return $e(e)&&Le(e.length)&&!!g[de(e)]};function Ie(e){return Ae(e)?ae(e,!0):ge(e)}var Fe,Re=(Fe=function(e,t,r){me(e,t,r)},ve((function(e,t){var r=-1,n=t.length,o=n>1?t[n-1]:void 0,i=n>2?t[2]:void 0;for(o=Fe.length>3&&"function"==typeof o?(n--,o):void 0,i&&function(e,t,r){if(!Ce(r))return!1;var n=typeof t;return!!("number"==n?Ae(r)&&je(t,r.length):"string"==n&&t in r)&&Pe(r[t],e)}(t[0],t[1],i)&&(o=n<3?void 0:o,n=1),e=Object(e);++r<n;){var s=t[r];s&&Fe(e,s,r,o)}return e})));function Ue(e){return e}e.exports=Re}).call(this,r(10)(e))},function(e,t){e.exports=function(e){return e.webpackPolyfill||(e.deprecate=function(){},e.paths=[],e.children||(e.children=[]),Object.defineProperty(e,"loaded",{enumerable:!0,get:function(){return e.l}}),Object.defineProperty(e,"id",{enumerable:!0,get:function(){return e.i}}),e.webpackPolyfill=1),e}},function(e,t){function r(e){return(r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function n(e,t){for(var r,n=0;n<t.length;n++)(r=t[n]).enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}function o(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var i,s,a="https://api.bullet-train.io/api/v1/",u=function(){function e(t){var n=this;(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")})(this,e),o(this,"getJSON",(function(e,t,r){var o={method:t||"GET",body:r,headers:{"x-environment-key":n.environmentID}};return"GET"!==t&&(o.headers["Content-Type"]="application/json; charset=utf-8"),i(e,o).then((function(e){return 200<=e.status&&300>e.status?e:e.text().then((function(e){var t=e;try{t=JSON.parse(e)}catch(e){}return Promise.reject(t)}))})).then((function(e){return e.json()}))})),o(this,"getFlags",(function(e,t){var r=n.onChange,o=n.onError,i=n.identity,s=n.api,a=(n.disableCache,!1),u=function(e,t){var o=e.flags,i=e.traits,s={},a={};if(i=i||[],(o=o||[]).forEach((function(e){s[e.feature.name.toLowerCase().replace(/ /g,"_")]={enabled:e.enabled,value:e.feature_state_value}})),i.forEach((function(e){a[e.trait_key.toLowerCase().replace(/ /g,"_")]=e.trait_value})),n.oldFlags=s,n.flags=s,n.traits=a,t){var u={};t.map((function(e){u[e.name]=e})),n.segments=u}n.updateStorage(),r&&r(n.oldFlags,{isFromServer:!0})};return i?Promise.all([n.getJSON(s+"identities/?identifier="+encodeURIComponent(i))]).then((function(e){u(e[0],e[1])})).catch((function(e){var t=e.message;o&&o({message:t})})):Promise.all([n.getJSON(s+"flags/")]).then((function(t){u({flags:t[0]},null),e&&!a&&(a=!0,e())})).catch((function(e){t&&!a&&(a=!0,t(e)),o&&o(e)}))})),o(this,"getValue",(function(e){var t=n.flags&&n.flags[e],r=null;return t&&(r=t.value),r})),o(this,"getTrait",(function(e){return n.traits&&n.traits[e]})),o(this,"setTrait",(function(e,t){var r=n.getJSON,o=n.identity,i=n.api;return r("".concat(i,"traits/"),"POST",JSON.stringify({identity:{identifier:o},trait_key:e,trait_value:t})).then(n.getFlags)})),o(this,"setTraits",(function(e){var t=n.getJSON,o=n.identity,i=n.api;e&&"object"===r(e)||console.error("Expected object for bulletTrain.setTraits");var s=Object.keys(e).map((function(t){return{identity:{identifier:o},trait_key:t,trait_value:e[t]}}));return t("".concat(i,"traits/bulk/"),"PUT",JSON.stringify(s)).then(n.getFlags)})),o(this,"incrementTrait",(function(e,t){var r=n.getJSON,o=n.identity,i=n.api;return r("".concat(i,"traits/increment-value/"),"POST",JSON.stringify({trait_key:e,increment_by:t,identifier:o})).then(n.getFlags)})),o(this,"hasFeature",(function(e){var t=n.flags&&n.flags[e],r=!1;return t&&t.enabled&&(r=!0),r})),i=t.fetch?t.fetch:global.fetch,s=t.AsyncStorage}return function(e,t,r){t&&n(e.prototype,t),r&&n(e,r)}(e,[{key:"init",value:function(e){var t=this,r=e.environmentID,n=e.api,o=void 0===n?a:n,i=e.onChange,u=e.cacheFlags,c=e.onError,l=e.defaultFlags,f=e.preventFetch,h=e.enableLogs,p=e.AsyncStorage,d=e.state;return new Promise((function(e,n){if(t.environmentID=r,t.api=o,t.interval=null,t.onChange=i,t.onError=c,t.enableLogs=h,t.flags=Object.assign({},l)||{},t.initialised=!0,t.timer=t.enableLogs?(new Date).valueOf():null,p&&(s=p),t.cacheFlags=void 0!==s&&u,t.setState(d),!r)throw n("Please specify a environment id"),"Please specify a environment id";u?s.getItem("BULLET_TRAIN_DB",(function(r,o){if(o)try{var i=JSON.parse(o);i&&i.api===t.api&&(t.setState(i),t.log("Retrieved flags from cache",i)),t.flags?(t.onChange&&t.onChange(null,{isFromServer:!1}),e(),t.getFlags(Promise.resolve,Promise.reject)):t.getFlags(e,n)}catch(e){t.log("Exception fetching cached logs",e)}})):!f&&t.getFlags(e,n)}))}},{key:"getAllFlags",value:function(){return this.flags}},{key:"identify",value:function(e){this.identity=e,this.initialised&&!this.interval&&this.getFlags()}},{key:"getState",value:function(){return{api:this.api,environmentID:this.environmentID,flags:this.flags,identity:this.identity,segments:this.segments,traits:this.traits}}},{key:"setState",value:function(e){e&&(this.initialised=!0,this.api=e.api||this.api||a,this.environmentID=e.environmentID||this.environmentID,this.flags=e.flags||this.flags,this.identity=e.identity||this.identity,this.segments=e.segments||this.segments,this.traits=e.traits||this.traits)}},{key:"log",value:function(){if(this.enableLogs){for(var e=arguments.length,t=Array(e),r=0;r<e;r++)t[r]=arguments[r];console.log.apply(this,["BULLET TRAIN:",(new Date).valueOf()-this.timer,"ms"].concat(t))}}},{key:"updateStorage",value:function(){if(this.cacheFlags){var e=JSON.stringify(this.getState());this.log("Setting storage",e),s.setItem("BULLET_TRAIN_DB",e)}}},{key:"logout",value:function(){this.identity=null,this.segments=null,this.traits=null,this.initialised&&!this.interval&&this.getFlags()}},{key:"startListening",value:function(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:1e3;this.interval||(this.interval=setInterval(this.getFlags,e))}},{key:"getSegments",value:function(){}},{key:"stopListening",value:function(){clearInterval(this.interval)}}]),e}();e.exports=function(e){var t=e.fetch,r=e.AsyncStorage;return new u({fetch:t,AsyncStorage:r})}}])}));
!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var r=t();for(var n in r)("object"==typeof exports?exports:e)[n]=r[n]}}(this,(function(){return function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=6)}([function(e,t){e.exports=require("stream")},function(e,t){e.exports=require("zlib")},function(e,t){e.exports=require("url")},function(e,t){e.exports=require("http")},function(e,t){e.exports=require("https")},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n,o=function(e,t){if(Array.isArray(e))return e;if(Symbol.iterator in Object(e))return function(e,t){var r=[],n=!0,o=!1,i=void 0;try{for(var s,a=e[Symbol.iterator]();!(n=(s=a.next()).done)&&(r.push(s.value),!t||r.length!==t);n=!0);}catch(e){o=!0,i=e}finally{try{!n&&a.return&&a.return()}finally{if(o)throw i}}return r}(e,t);throw new TypeError("Invalid attempt to destructure non-iterable instance")},i=r(9),s=(n=i)&&n.__esModule?n:{default:n};var a={getItem:function(e,t){return a.multiGet([e]).then((function(e){return e[0][1]})).then((function(e){return t&&t(null,e),e})).catch((function(e){return t&&t(e,null),e}))},setItem:function(e,t,r){return a.multiSet([[e,t]]).then((function(e){return r&&r(null,e),e})).catch((function(e){return r&&r(e,null),e}))},getAllKeys:function(e){return Promise.resolve(Object.keys(localStorage)).then((function(t){return e&&e(null,t),t})).catch((function(t){return e&&e(t,null),t}))},removeItem:function(e,t){return a.multiRemove([e]).then((function(){t&&t(null)})).catch((function(e){t&&t(e,null)}))},clear:function(){return new Promise((function(e){window.localStorage.clear(),e()}))},mergeItem:function(e,t){return a.multiMerge([[e,t]])},multiGet:function(e){return new Promise((function(t){t(e.reduce((function(e,t){return e.concat([[t,localStorage.getItem(t)]])}),[]))}))},multiSet:function(e){return new Promise((function(t,r){var n=[];return e.forEach((function(e){var t=o(e,2),r=t[0],i=t[1];try{localStorage.setItem(r,i)}catch(e){n.push(e)}})),n.length>0?r(n):t()}))},multiMerge:function(e){return new Promise((function(t,r){var n=[];return e.forEach((function(e){var t=o(e,2),r=t[0],i=t[1],a=localStorage.getItem(r);if(a)try{localStorage.setItem(r,JSON.stringify((0,s.default)(JSON.parse(a),JSON.parse(i))))}catch(e){n.push(e)}})),n.length>0?r(n):t()}))},multiRemove:function(e){return new Promise((function(t){e.forEach((function(e){return window.localStorage.removeItem(e)})),t()}))},flushGetRequests:function(){console.warn("AsyncStorage.flushGetRequests: Not supported on `web`")}};t.default=a},function(e,t,r){"use strict";r.r(t);var n=r(5),o=r.n(n),i=r(7).default;"undefined"==typeof window&&(i=r(8).default);var s=r(11)({AsyncStorage:o.a,fetch:i});"undefined"!=typeof window&&(window.bulletTrain=s),t.default=s},function(e,t,r){"use strict";r.r(t),t.default=function(e,t){return t=t||{},new Promise((function(r,n){var o=new XMLHttpRequest,i=[],s=[],a={},u=function(){return{ok:2==(o.status/100|0),statusText:o.statusText,status:o.status,url:o.responseURL,text:function(){return Promise.resolve(o.responseText)},json:function(){return Promise.resolve(JSON.parse(o.responseText))},blob:function(){return Promise.resolve(new Blob([o.response]))},clone:u,headers:{keys:function(){return i},entries:function(){return s},get:function(e){return a[e.toLowerCase()]},has:function(e){return e.toLowerCase()in a}}}};for(var c in o.open(t.method||"get",e,!0),o.onload=function(){o.getAllResponseHeaders().replace(/^(.*?):[^\S\n]*([\s\S]*?)$/gm,(function(e,t,r){i.push(t=t.toLowerCase()),s.push([t,r]),a[t]=a[t]?a[t]+","+r:r})),r(u())},o.onerror=n,o.withCredentials="include"==t.credentials,t.headers)o.setRequestHeader(c,t.headers[c]);o.send(t.body||null)}))}},function(e,t,r){"use strict";r.r(t),r.d(t,"Headers",(function(){return A})),r.d(t,"Request",(function(){return M})),r.d(t,"Response",(function(){return F})),r.d(t,"FetchError",(function(){return h}));var n=r(0),o=r(3),i=r(2),s=r(4),a=r(1);const u=n.Readable,c=Symbol("buffer"),l=Symbol("type");class f{constructor(){this[l]="";const e=arguments[0],t=arguments[1],r=[];let n=0;if(e){const t=e,o=Number(t.length);for(let e=0;e<o;e++){const o=t[e];let i;n+=(i=o instanceof Buffer?o:ArrayBuffer.isView(o)?Buffer.from(o.buffer,o.byteOffset,o.byteLength):o instanceof ArrayBuffer?Buffer.from(o):o instanceof f?o[c]:Buffer.from("string"==typeof o?o:String(o))).length,r.push(i)}}this[c]=Buffer.concat(r);let o=t&&void 0!==t.type&&String(t.type).toLowerCase();o&&!/[^\u0020-\u007E]/.test(o)&&(this[l]=o)}get size(){return this[c].length}get type(){return this[l]}text(){return Promise.resolve(this[c].toString())}arrayBuffer(){const e=this[c],t=e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength);return Promise.resolve(t)}stream(){const e=new u;return e._read=function(){},e.push(this[c]),e.push(null),e}toString(){return"[object Blob]"}slice(){const e=this.size,t=arguments[0],r=arguments[1];let n,o;n=void 0===t?0:t<0?Math.max(e+t,0):Math.min(t,e),o=void 0===r?e:r<0?Math.max(e+r,0):Math.min(r,e);const i=Math.max(o-n,0),s=this[c].slice(n,n+i),a=new f([],{type:arguments[2]});return a[c]=s,a}}function h(e,t,r){Error.call(this,e),this.message=e,this.type=t,r&&(this.code=this.errno=r.code),Error.captureStackTrace(this,this.constructor)}let p;Object.defineProperties(f.prototype,{size:{enumerable:!0},type:{enumerable:!0},slice:{enumerable:!0}}),Object.defineProperty(f.prototype,Symbol.toStringTag,{value:"Blob",writable:!1,enumerable:!1,configurable:!0}),h.prototype=Object.create(Error.prototype),h.prototype.constructor=h,h.prototype.name="FetchError";try{p=require("encoding").convert}catch(e){}const d=Symbol("Body internals"),y=n.PassThrough;function b(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=r.size;let i=void 0===o?0:o;var s=r.timeout;let a=void 0===s?0:s;null==e?e=null:m(e)?e=Buffer.from(e.toString()):v(e)||Buffer.isBuffer(e)||("[object ArrayBuffer]"===Object.prototype.toString.call(e)?e=Buffer.from(e):ArrayBuffer.isView(e)?e=Buffer.from(e.buffer,e.byteOffset,e.byteLength):e instanceof n||(e=Buffer.from(String(e)))),this[d]={body:e,disturbed:!1,error:null},this.size=i,this.timeout=a,e instanceof n&&e.on("error",(function(e){const r="AbortError"===e.name?e:new h(`Invalid response body while trying to fetch ${t.url}: ${e.message}`,"system",e);t[d].error=r}))}function g(){var e=this;if(this[d].disturbed)return b.Promise.reject(new TypeError(`body used already for: ${this.url}`));if(this[d].disturbed=!0,this[d].error)return b.Promise.reject(this[d].error);let t=this.body;if(null===t)return b.Promise.resolve(Buffer.alloc(0));if(v(t)&&(t=t.stream()),Buffer.isBuffer(t))return b.Promise.resolve(t);if(!(t instanceof n))return b.Promise.resolve(Buffer.alloc(0));let r=[],o=0,i=!1;return new b.Promise((function(n,s){let a;e.timeout&&(a=setTimeout((function(){i=!0,s(new h(`Response timeout while trying to fetch ${e.url} (over ${e.timeout}ms)`,"body-timeout"))}),e.timeout)),t.on("error",(function(t){"AbortError"===t.name?(i=!0,s(t)):s(new h(`Invalid response body while trying to fetch ${e.url}: ${t.message}`,"system",t))})),t.on("data",(function(t){if(!i&&null!==t){if(e.size&&o+t.length>e.size)return i=!0,void s(new h(`content size at ${e.url} over limit: ${e.size}`,"max-size"));o+=t.length,r.push(t)}})),t.on("end",(function(){if(!i){clearTimeout(a);try{n(Buffer.concat(r,o))}catch(t){s(new h(`Could not create Buffer from response body for ${e.url}: ${t.message}`,"system",t))}}}))}))}function m(e){return"object"==typeof e&&"function"==typeof e.append&&"function"==typeof e.delete&&"function"==typeof e.get&&"function"==typeof e.getAll&&"function"==typeof e.has&&"function"==typeof e.set&&("URLSearchParams"===e.constructor.name||"[object URLSearchParams]"===Object.prototype.toString.call(e)||"function"==typeof e.sort)}function v(e){return"object"==typeof e&&"function"==typeof e.arrayBuffer&&"string"==typeof e.type&&"function"==typeof e.stream&&"function"==typeof e.constructor&&"string"==typeof e.constructor.name&&/^(Blob|File)$/.test(e.constructor.name)&&/^(Blob|File)$/.test(e[Symbol.toStringTag])}function w(e){let t,r,o=e.body;if(e.bodyUsed)throw new Error("cannot clone body after it is used");return o instanceof n&&"function"!=typeof o.getBoundary&&(t=new y,r=new y,o.pipe(t),o.pipe(r),e[d].body=t,o=r),o}function _(e){return null===e?null:"string"==typeof e?"text/plain;charset=UTF-8":m(e)?"application/x-www-form-urlencoded;charset=UTF-8":v(e)?e.type||null:Buffer.isBuffer(e)?null:"[object ArrayBuffer]"===Object.prototype.toString.call(e)?null:ArrayBuffer.isView(e)?null:"function"==typeof e.getBoundary?`multipart/form-data;boundary=${e.getBoundary()}`:e instanceof n?null:"text/plain;charset=UTF-8"}function j(e){const t=e.body;return null===t?0:v(t)?t.size:Buffer.isBuffer(t)?t.length:t&&"function"==typeof t.getLengthSync&&(t._lengthRetrievers&&0==t._lengthRetrievers.length||t.hasKnownLength&&t.hasKnownLength())?t.getLengthSync():null}b.prototype={get body(){return this[d].body},get bodyUsed(){return this[d].disturbed},arrayBuffer(){return g.call(this).then((function(e){return e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength)}))},blob(){let e=this.headers&&this.headers.get("content-type")||"";return g.call(this).then((function(t){return Object.assign(new f([],{type:e.toLowerCase()}),{[c]:t})}))},json(){var e=this;return g.call(this).then((function(t){try{return JSON.parse(t.toString())}catch(t){return b.Promise.reject(new h(`invalid json response body at ${e.url} reason: ${t.message}`,"invalid-json"))}}))},text(){return g.call(this).then((function(e){return e.toString()}))},buffer(){return g.call(this)},textConverted(){var e=this;return g.call(this).then((function(t){return function(e,t){if("function"!=typeof p)throw new Error("The package `encoding` must be installed to use the textConverted() function");const r=t.get("content-type");let n,o,i="utf-8";r&&(n=/charset=([^;]*)/i.exec(r));o=e.slice(0,1024).toString(),!n&&o&&(n=/<meta.+?charset=(['"])(.+?)\1/i.exec(o));!n&&o&&(n=/<meta[\s]+?http-equiv=(['"])content-type\1[\s]+?content=(['"])(.+?)\2/i.exec(o))&&(n=/charset=(.*)/i.exec(n.pop()));!n&&o&&(n=/<\?xml.+?encoding=(['"])(.+?)\1/i.exec(o));n&&("gb2312"!==(i=n.pop())&&"gbk"!==i||(i="gb18030"));return p(e,"UTF-8",i).toString()}(t,e.headers)}))}},Object.defineProperties(b.prototype,{body:{enumerable:!0},bodyUsed:{enumerable:!0},arrayBuffer:{enumerable:!0},blob:{enumerable:!0},json:{enumerable:!0},text:{enumerable:!0}}),b.mixIn=function(e){for(const t of Object.getOwnPropertyNames(b.prototype))if(!(t in e)){const r=Object.getOwnPropertyDescriptor(b.prototype,t);Object.defineProperty(e,t,r)}},b.Promise=global.Promise;const S=/[^\^_`a-zA-Z\-0-9!#$%&'*+.|~]/,O=/[^\t\x20-\x7e\x80-\xff]/;function T(e){if(e=`${e}`,S.test(e)||""===e)throw new TypeError(`${e} is not a legal HTTP header name`)}function P(e){if(e=`${e}`,O.test(e))throw new TypeError(`${e} is not a legal HTTP header value`)}function x(e,t){t=t.toLowerCase();for(const r in e)if(r.toLowerCase()===t)return r}const E=Symbol("map");class A{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:void 0;if(this[E]=Object.create(null),e instanceof A){const t=e.raw(),r=Object.keys(t);for(const e of r)for(const r of t[e])this.append(e,r)}else if(null==e);else{if("object"!=typeof e)throw new TypeError("Provided initializer must be an object");{const t=e[Symbol.iterator];if(null!=t){if("function"!=typeof t)throw new TypeError("Header pairs must be iterable");const r=[];for(const t of e){if("object"!=typeof t||"function"!=typeof t[Symbol.iterator])throw new TypeError("Each header pair must be iterable");r.push(Array.from(t))}for(const e of r){if(2!==e.length)throw new TypeError("Each header pair must be a name/value tuple");this.append(e[0],e[1])}}else for(const t of Object.keys(e)){const r=e[t];this.append(t,r)}}}}get(e){T(e=`${e}`);const t=x(this[E],e);return void 0===t?null:this[E][t].join(", ")}forEach(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:void 0,r=B(this),n=0;for(;n<r.length;){var o=r[n];const i=o[0],s=o[1];e.call(t,s,i,this),r=B(this),n++}}set(e,t){t=`${t}`,T(e=`${e}`),P(t);const r=x(this[E],e);this[E][void 0!==r?r:e]=[t]}append(e,t){t=`${t}`,T(e=`${e}`),P(t);const r=x(this[E],e);void 0!==r?this[E][r].push(t):this[E][e]=[t]}has(e){return T(e=`${e}`),void 0!==x(this[E],e)}delete(e){T(e=`${e}`);const t=x(this[E],e);void 0!==t&&delete this[E][t]}raw(){return this[E]}keys(){return L(this,"key")}values(){return L(this,"value")}[Symbol.iterator](){return L(this,"key+value")}}function B(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"key+value";return Object.keys(e[E]).sort().map("key"===t?function(e){return e.toLowerCase()}:"value"===t?function(t){return e[E][t].join(", ")}:function(t){return[t.toLowerCase(),e[E][t].join(", ")]})}A.prototype.entries=A.prototype[Symbol.iterator],Object.defineProperty(A.prototype,Symbol.toStringTag,{value:"Headers",writable:!1,enumerable:!1,configurable:!0}),Object.defineProperties(A.prototype,{get:{enumerable:!0},forEach:{enumerable:!0},set:{enumerable:!0},append:{enumerable:!0},has:{enumerable:!0},delete:{enumerable:!0},keys:{enumerable:!0},values:{enumerable:!0},entries:{enumerable:!0}});const k=Symbol("internal");function L(e,t){const r=Object.create(C);return r[k]={target:e,kind:t,index:0},r}const C=Object.setPrototypeOf({next(){if(!this||Object.getPrototypeOf(this)!==C)throw new TypeError("Value of `this` is not a HeadersIterator");var e=this[k];const t=e.target,r=e.kind,n=e.index,o=B(t,r);return n>=o.length?{value:void 0,done:!0}:(this[k].index=n+1,{value:o[n],done:!1})}},Object.getPrototypeOf(Object.getPrototypeOf([][Symbol.iterator]())));function $(e){const t=Object.assign({__proto__:null},e[E]),r=x(e[E],"Host");return void 0!==r&&(t[r]=t[r][0]),t}Object.defineProperty(C,Symbol.toStringTag,{value:"HeadersIterator",writable:!1,enumerable:!1,configurable:!0});const z=Symbol("Response internals"),I=o.STATUS_CODES;class F{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};b.call(this,e,t);const r=t.status||200,n=new A(t.headers);if(null!=e&&!n.has("Content-Type")){const t=_(e);t&&n.append("Content-Type",t)}this[z]={url:t.url,status:r,statusText:t.statusText||I[r],headers:n,counter:t.counter}}get url(){return this[z].url||""}get status(){return this[z].status}get ok(){return this[z].status>=200&&this[z].status<300}get redirected(){return this[z].counter>0}get statusText(){return this[z].statusText}get headers(){return this[z].headers}clone(){return new F(w(this),{url:this.url,status:this.status,statusText:this.statusText,headers:this.headers,ok:this.ok,redirected:this.redirected})}}b.mixIn(F.prototype),Object.defineProperties(F.prototype,{url:{enumerable:!0},status:{enumerable:!0},ok:{enumerable:!0},redirected:{enumerable:!0},statusText:{enumerable:!0},headers:{enumerable:!0},clone:{enumerable:!0}}),Object.defineProperty(F.prototype,Symbol.toStringTag,{value:"Response",writable:!1,enumerable:!1,configurable:!0});const R=Symbol("Request internals"),U=i.parse,N=i.format,q="destroy"in n.Readable.prototype;function D(e){return"object"==typeof e&&"object"==typeof e[R]}class M{constructor(e){let t,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};D(e)?t=U(e.url):(t=e&&e.href?U(e.href):U(`${e}`),e={});let n=r.method||e.method||"GET";if(n=n.toUpperCase(),(null!=r.body||D(e)&&null!==e.body)&&("GET"===n||"HEAD"===n))throw new TypeError("Request with GET/HEAD method cannot have body");let o=null!=r.body?r.body:D(e)&&null!==e.body?w(e):null;b.call(this,o,{timeout:r.timeout||e.timeout||0,size:r.size||e.size||0});const i=new A(r.headers||e.headers||{});if(null!=o&&!i.has("Content-Type")){const e=_(o);e&&i.append("Content-Type",e)}let s=D(e)?e.signal:null;if("signal"in r&&(s=r.signal),null!=s&&!function(e){const t=e&&"object"==typeof e&&Object.getPrototypeOf(e);return!(!t||"AbortSignal"!==t.constructor.name)}(s))throw new TypeError("Expected signal to be an instanceof AbortSignal");this[R]={method:n,redirect:r.redirect||e.redirect||"follow",headers:i,parsedURL:t,signal:s},this.follow=void 0!==r.follow?r.follow:void 0!==e.follow?e.follow:20,this.compress=void 0!==r.compress?r.compress:void 0===e.compress||e.compress,this.counter=r.counter||e.counter||0,this.agent=r.agent||e.agent}get method(){return this[R].method}get url(){return N(this[R].parsedURL)}get headers(){return this[R].headers}get redirect(){return this[R].redirect}get signal(){return this[R].signal}clone(){return new M(this)}}function H(e){Error.call(this,e),this.type="aborted",this.message=e,Error.captureStackTrace(this,this.constructor)}b.mixIn(M.prototype),Object.defineProperty(M.prototype,Symbol.toStringTag,{value:"Request",writable:!1,enumerable:!1,configurable:!0}),Object.defineProperties(M.prototype,{method:{enumerable:!0},url:{enumerable:!0},headers:{enumerable:!0},redirect:{enumerable:!0},clone:{enumerable:!0},signal:{enumerable:!0}}),H.prototype=Object.create(Error.prototype),H.prototype.constructor=H,H.prototype.name="AbortError";const J=n.PassThrough,G=i.resolve;function V(e,t){if(!V.Promise)throw new Error("native promise missing, set fetch.Promise to your favorite alternative");return b.Promise=V.Promise,new V.Promise((function(r,i){const u=new M(e,t),c=function(e){const t=e[R].parsedURL,r=new A(e[R].headers);if(r.has("Accept")||r.set("Accept","*/*"),!t.protocol||!t.hostname)throw new TypeError("Only absolute URLs are supported");if(!/^https?:$/.test(t.protocol))throw new TypeError("Only HTTP(S) protocols are supported");if(e.signal&&e.body instanceof n.Readable&&!q)throw new Error("Cancellation of streamed requests with AbortSignal is not supported in node < 8");let o=null;if(null==e.body&&/^(POST|PUT)$/i.test(e.method)&&(o="0"),null!=e.body){const t=j(e);"number"==typeof t&&(o=String(t))}o&&r.set("Content-Length",o),r.has("User-Agent")||r.set("User-Agent","node-fetch/1.0 (+https://github.com/bitinn/node-fetch)"),e.compress&&!r.has("Accept-Encoding")&&r.set("Accept-Encoding","gzip,deflate");let i=e.agent;return"function"==typeof i&&(i=i(t)),r.has("Connection")||i||r.set("Connection","close"),Object.assign({},t,{method:e.method,headers:$(r),agent:i})}(u),l=("https:"===c.protocol?s:o).request,f=u.signal;let p=null;const d=function(){let e=new H("The user aborted a request.");i(e),u.body&&u.body instanceof n.Readable&&u.body.destroy(e),p&&p.body&&p.body.emit("error",e)};if(f&&f.aborted)return void d();const y=function(){d(),m()},b=l(c);let g;function m(){b.abort(),f&&f.removeEventListener("abort",y),clearTimeout(g)}f&&f.addEventListener("abort",y),u.timeout&&b.once("socket",(function(e){g=setTimeout((function(){i(new h(`network timeout at: ${u.url}`,"request-timeout")),m()}),u.timeout)})),b.on("error",(function(e){i(new h(`request to ${u.url} failed, reason: ${e.message}`,"system",e)),m()})),b.on("response",(function(e){clearTimeout(g);const t=function(e){const t=new A;for(const r of Object.keys(e))if(!S.test(r))if(Array.isArray(e[r]))for(const n of e[r])O.test(n)||(void 0===t[E][r]?t[E][r]=[n]:t[E][r].push(n));else O.test(e[r])||(t[E][r]=[e[r]]);return t}(e.headers);if(V.isRedirect(e.statusCode)){const n=t.get("Location"),o=null===n?null:G(u.url,n);switch(u.redirect){case"error":return i(new h(`redirect mode is set to error: ${u.url}`,"no-redirect")),void m();case"manual":if(null!==o)try{t.set("Location",o)}catch(e){i(e)}break;case"follow":if(null===o)break;if(u.counter>=u.follow)return i(new h(`maximum redirect reached at: ${u.url}`,"max-redirect")),void m();const n={headers:new A(u.headers),follow:u.follow,counter:u.counter+1,agent:u.agent,compress:u.compress,method:u.method,body:u.body,signal:u.signal,timeout:u.timeout};return 303!==e.statusCode&&u.body&&null===j(u)?(i(new h("Cannot follow redirect with body being a readable stream","unsupported-redirect")),void m()):(303!==e.statusCode&&(301!==e.statusCode&&302!==e.statusCode||"POST"!==u.method)||(n.method="GET",n.body=void 0,n.headers.delete("content-length")),r(V(new M(o,n))),void m())}}e.once("end",(function(){f&&f.removeEventListener("abort",y)}));let n=e.pipe(new J);const o={url:u.url,status:e.statusCode,statusText:e.statusMessage,headers:t,size:u.size,timeout:u.timeout,counter:u.counter},s=t.get("Content-Encoding");if(!u.compress||"HEAD"===u.method||null===s||204===e.statusCode||304===e.statusCode)return p=new F(n,o),void r(p);const c={flush:a.Z_SYNC_FLUSH,finishFlush:a.Z_SYNC_FLUSH};if("gzip"==s||"x-gzip"==s)return n=n.pipe(a.createGunzip(c)),p=new F(n,o),void r(p);if("deflate"!=s&&"x-deflate"!=s){if("br"==s&&"function"==typeof a.createBrotliDecompress)return n=n.pipe(a.createBrotliDecompress()),p=new F(n,o),void r(p);p=new F(n,o),r(p)}else{e.pipe(new J).once("data",(function(e){n=8==(15&e[0])?n.pipe(a.createInflate()):n.pipe(a.createInflateRaw()),p=new F(n,o),r(p)}))}})),function(e,t){const r=t.body;null===r?e.end():v(r)?r.stream().pipe(e):Buffer.isBuffer(r)?(e.write(r),e.end()):r.pipe(e)}(b,u)}))}V.isRedirect=function(e){return 301===e||302===e||303===e||307===e||308===e},V.Promise=global.Promise,t.default=V},function(e,t,r){(function(e){var r=200,n="__lodash_hash_undefined__",o=800,i=16,s=9007199254740991,a="[object Arguments]",u="[object AsyncFunction]",c="[object Function]",l="[object GeneratorFunction]",f="[object Null]",h="[object Object]",p="[object Proxy]",d="[object Undefined]",y=/^\[object .+?Constructor\]$/,b=/^(?:0|[1-9]\d*)$/,g={};g["[object Float32Array]"]=g["[object Float64Array]"]=g["[object Int8Array]"]=g["[object Int16Array]"]=g["[object Int32Array]"]=g["[object Uint8Array]"]=g["[object Uint8ClampedArray]"]=g["[object Uint16Array]"]=g["[object Uint32Array]"]=!0,g[a]=g["[object Array]"]=g["[object ArrayBuffer]"]=g["[object Boolean]"]=g["[object DataView]"]=g["[object Date]"]=g["[object Error]"]=g[c]=g["[object Map]"]=g["[object Number]"]=g[h]=g["[object RegExp]"]=g["[object Set]"]=g["[object String]"]=g["[object WeakMap]"]=!1;var m="object"==typeof global&&global&&global.Object===Object&&global,v="object"==typeof self&&self&&self.Object===Object&&self,w=m||v||Function("return this")(),_=t&&!t.nodeType&&t,j=_&&"object"==typeof e&&e&&!e.nodeType&&e,S=j&&j.exports===_,O=S&&m.process,T=function(){try{var e=j&&j.require&&j.require("util").types;return e||O&&O.binding&&O.binding("util")}catch(e){}}(),P=T&&T.isTypedArray;function x(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 E,A,B,k=Array.prototype,L=Function.prototype,C=Object.prototype,$=w["__core-js_shared__"],z=L.toString,I=C.hasOwnProperty,F=(E=/[^.]+$/.exec($&&$.keys&&$.keys.IE_PROTO||""))?"Symbol(src)_1."+E:"",R=C.toString,U=z.call(Object),N=RegExp("^"+z.call(I).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),q=S?w.Buffer:void 0,D=w.Symbol,M=w.Uint8Array,H=q?q.allocUnsafe:void 0,J=(A=Object.getPrototypeOf,B=Object,function(e){return A(B(e))}),G=Object.create,V=C.propertyIsEnumerable,K=k.splice,Z=D?D.toStringTag:void 0,Y=function(){try{var e=_e(Object,"defineProperty");return e({},"",{}),e}catch(e){}}(),W=q?q.isBuffer:void 0,X=Math.max,Q=Date.now,ee=_e(w,"Map"),te=_e(Object,"create"),re=function(){function e(){}return function(t){if(!Ce(t))return{};if(G)return G(t);e.prototype=t;var r=new e;return e.prototype=void 0,r}}();function ne(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])}}function oe(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])}}function ie(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])}}function se(e){var t=this.__data__=new oe(e);this.size=t.size}function ae(e,t){var r=Ee(e),n=!r&&xe(e),o=!r&&!n&&Be(e),i=!r&&!n&&!o&&ze(e),s=r||n||o||i,a=s?function(e,t){for(var r=-1,n=Array(e);++r<e;)n[r]=t(r);return n}(e.length,String):[],u=a.length;for(var c in e)!t&&!I.call(e,c)||s&&("length"==c||o&&("offset"==c||"parent"==c)||i&&("buffer"==c||"byteLength"==c||"byteOffset"==c)||je(c,u))||a.push(c);return a}function ue(e,t,r){(void 0===r||Pe(e[t],r))&&(void 0!==r||t in e)||fe(e,t,r)}function ce(e,t,r){var n=e[t];I.call(e,t)&&Pe(n,r)&&(void 0!==r||t in e)||fe(e,t,r)}function le(e,t){for(var r=e.length;r--;)if(Pe(e[r][0],t))return r;return-1}function fe(e,t,r){"__proto__"==t&&Y?Y(e,t,{configurable:!0,enumerable:!0,value:r,writable:!0}):e[t]=r}ne.prototype.clear=function(){this.__data__=te?te(null):{},this.size=0},ne.prototype.delete=function(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t},ne.prototype.get=function(e){var t=this.__data__;if(te){var r=t[e];return r===n?void 0:r}return I.call(t,e)?t[e]:void 0},ne.prototype.has=function(e){var t=this.__data__;return te?void 0!==t[e]:I.call(t,e)},ne.prototype.set=function(e,t){var r=this.__data__;return this.size+=this.has(e)?0:1,r[e]=te&&void 0===t?n:t,this},oe.prototype.clear=function(){this.__data__=[],this.size=0},oe.prototype.delete=function(e){var t=this.__data__,r=le(t,e);return!(r<0)&&(r==t.length-1?t.pop():K.call(t,r,1),--this.size,!0)},oe.prototype.get=function(e){var t=this.__data__,r=le(t,e);return r<0?void 0:t[r][1]},oe.prototype.has=function(e){return le(this.__data__,e)>-1},oe.prototype.set=function(e,t){var r=this.__data__,n=le(r,e);return n<0?(++this.size,r.push([e,t])):r[n][1]=t,this},ie.prototype.clear=function(){this.size=0,this.__data__={hash:new ne,map:new(ee||oe),string:new ne}},ie.prototype.delete=function(e){var t=we(this,e).delete(e);return this.size-=t?1:0,t},ie.prototype.get=function(e){return we(this,e).get(e)},ie.prototype.has=function(e){return we(this,e).has(e)},ie.prototype.set=function(e,t){var r=we(this,e),n=r.size;return r.set(e,t),this.size+=r.size==n?0:1,this},se.prototype.clear=function(){this.__data__=new oe,this.size=0},se.prototype.delete=function(e){var t=this.__data__,r=t.delete(e);return this.size=t.size,r},se.prototype.get=function(e){return this.__data__.get(e)},se.prototype.has=function(e){return this.__data__.has(e)},se.prototype.set=function(e,t){var n=this.__data__;if(n instanceof oe){var o=n.__data__;if(!ee||o.length<r-1)return o.push([e,t]),this.size=++n.size,this;n=this.__data__=new ie(o)}return n.set(e,t),this.size=n.size,this};var he,pe=function(e,t,r){for(var n=-1,o=Object(e),i=r(e),s=i.length;s--;){var a=i[he?s:++n];if(!1===t(o[a],a,o))break}return e};function de(e){return null==e?void 0===e?d:f:Z&&Z in Object(e)?function(e){var t=I.call(e,Z),r=e[Z];try{e[Z]=void 0;var n=!0}catch(e){}var o=R.call(e);n&&(t?e[Z]=r:delete e[Z]);return o}(e):function(e){return R.call(e)}(e)}function ye(e){return $e(e)&&de(e)==a}function be(e){return!(!Ce(e)||function(e){return!!F&&F in e}(e))&&(ke(e)?N:y).test(function(e){if(null!=e){try{return z.call(e)}catch(e){}try{return e+""}catch(e){}}return""}(e))}function ge(e){if(!Ce(e))return function(e){var t=[];if(null!=e)for(var r in Object(e))t.push(r);return t}(e);var t=Se(e),r=[];for(var n in e)("constructor"!=n||!t&&I.call(e,n))&&r.push(n);return r}function me(e,t,r,n,o){e!==t&&pe(t,(function(i,s){if(o||(o=new se),Ce(i))!function(e,t,r,n,o,i,s){var a=Oe(e,r),u=Oe(t,r),c=s.get(u);if(c)return void ue(e,r,c);var l=i?i(a,u,r+"",e,t,s):void 0,f=void 0===l;if(f){var p=Ee(u),d=!p&&Be(u),y=!p&&!d&&ze(u);l=u,p||d||y?Ee(a)?l=a:$e(w=a)&&Ae(w)?l=function(e,t){var r=-1,n=e.length;t||(t=Array(n));for(;++r<n;)t[r]=e[r];return t}(a):d?(f=!1,l=function(e,t){if(t)return e.slice();var r=e.length,n=H?H(r):new e.constructor(r);return e.copy(n),n}(u,!0)):y?(f=!1,b=u,g=!0?(m=b.buffer,v=new m.constructor(m.byteLength),new M(v).set(new M(m)),v):b.buffer,l=new b.constructor(g,b.byteOffset,b.length)):l=[]:function(e){if(!$e(e)||de(e)!=h)return!1;var t=J(e);if(null===t)return!0;var r=I.call(t,"constructor")&&t.constructor;return"function"==typeof r&&r instanceof r&&z.call(r)==U}(u)||xe(u)?(l=a,xe(a)?l=function(e){return function(e,t,r,n){var o=!r;r||(r={});var i=-1,s=t.length;for(;++i<s;){var a=t[i],u=n?n(r[a],e[a],a,r,e):void 0;void 0===u&&(u=e[a]),o?fe(r,a,u):ce(r,a,u)}return r}(e,Ie(e))}(a):Ce(a)&&!ke(a)||(l=function(e){return"function"!=typeof e.constructor||Se(e)?{}:re(J(e))}(u))):f=!1}var b,g,m,v;var w;f&&(s.set(u,l),o(l,u,n,i,s),s.delete(u));ue(e,r,l)}(e,t,s,r,me,n,o);else{var a=n?n(Oe(e,s),i,s+"",e,t,o):void 0;void 0===a&&(a=i),ue(e,s,a)}}),Ie)}function ve(e,t){return Te(function(e,t,r){return t=X(void 0===t?e.length-1:t,0),function(){for(var n=arguments,o=-1,i=X(n.length-t,0),s=Array(i);++o<i;)s[o]=n[t+o];o=-1;for(var a=Array(t+1);++o<t;)a[o]=n[o];return a[t]=r(s),x(e,this,a)}}(e,t,Ue),e+"")}function we(e,t){var r,n,o=e.__data__;return("string"==(n=typeof(r=t))||"number"==n||"symbol"==n||"boolean"==n?"__proto__"!==r:null===r)?o["string"==typeof t?"string":"hash"]:o.map}function _e(e,t){var r=function(e,t){return null==e?void 0:e[t]}(e,t);return be(r)?r:void 0}function je(e,t){var r=typeof e;return!!(t=null==t?s:t)&&("number"==r||"symbol"!=r&&b.test(e))&&e>-1&&e%1==0&&e<t}function Se(e){var t=e&&e.constructor;return e===("function"==typeof t&&t.prototype||C)}function Oe(e,t){if(("constructor"!==t||"function"!=typeof e[t])&&"__proto__"!=t)return e[t]}var Te=function(e){var t=0,r=0;return function(){var n=Q(),s=i-(n-r);if(r=n,s>0){if(++t>=o)return arguments[0]}else t=0;return e.apply(void 0,arguments)}}(Y?function(e,t){return Y(e,"toString",{configurable:!0,enumerable:!1,value:(r=t,function(){return r}),writable:!0});var r}:Ue);function Pe(e,t){return e===t||e!=e&&t!=t}var xe=ye(function(){return arguments}())?ye:function(e){return $e(e)&&I.call(e,"callee")&&!V.call(e,"callee")},Ee=Array.isArray;function Ae(e){return null!=e&&Le(e.length)&&!ke(e)}var Be=W||function(){return!1};function ke(e){if(!Ce(e))return!1;var t=de(e);return t==c||t==l||t==u||t==p}function Le(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=s}function Ce(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}function $e(e){return null!=e&&"object"==typeof e}var ze=P?function(e){return function(t){return e(t)}}(P):function(e){return $e(e)&&Le(e.length)&&!!g[de(e)]};function Ie(e){return Ae(e)?ae(e,!0):ge(e)}var Fe,Re=(Fe=function(e,t,r){me(e,t,r)},ve((function(e,t){var r=-1,n=t.length,o=n>1?t[n-1]:void 0,i=n>2?t[2]:void 0;for(o=Fe.length>3&&"function"==typeof o?(n--,o):void 0,i&&function(e,t,r){if(!Ce(r))return!1;var n=typeof t;return!!("number"==n?Ae(r)&&je(t,r.length):"string"==n&&t in r)&&Pe(r[t],e)}(t[0],t[1],i)&&(o=n<3?void 0:o,n=1),e=Object(e);++r<n;){var s=t[r];s&&Fe(e,s,r,o)}return e})));function Ue(e){return e}e.exports=Re}).call(this,r(10)(e))},function(e,t){e.exports=function(e){return e.webpackPolyfill||(e.deprecate=function(){},e.paths=[],e.children||(e.children=[]),Object.defineProperty(e,"loaded",{enumerable:!0,get:function(){return e.l}}),Object.defineProperty(e,"id",{enumerable:!0,get:function(){return e.i}}),e.webpackPolyfill=1),e}},function(e,t){function r(e){return(r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function n(e,t){for(var r,n=0;n<t.length;n++)(r=t[n]).enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}function o(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var i,s,a="https://api.bullet-train.io/api/v1/",u=function(){function e(t){var n=this;(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")})(this,e),o(this,"getJSON",(function(e,t,r){var o={method:t||"GET",body:r,headers:{"x-environment-key":n.environmentID}};return"GET"!==t&&(o.headers["Content-Type"]="application/json; charset=utf-8"),i(e,o).then((function(e){return 200<=e.status&&300>e.status?e:e.text().then((function(e){var t=e;try{t=JSON.parse(e)}catch(e){}return Promise.reject(t)}))})).then((function(e){return e.json()}))})),o(this,"getFlags",(function(e,t){var r=n.onChange,o=n.onError,i=n.identity,s=n.api,a=(n.disableCache,!1),u=function(e,t){var o=e.flags,i=e.traits,s={},a={};if(i=i||[],(o=o||[]).forEach((function(e){s[e.feature.name.toLowerCase().replace(/ /g,"_")]={enabled:e.enabled,value:e.feature_state_value}})),i.forEach((function(e){a[e.trait_key.toLowerCase().replace(/ /g,"_")]=e.trait_value})),n.oldFlags=s,n.flags=s,n.traits=a,t){var u={};t.map((function(e){u[e.name]=e})),n.segments=u}n.updateStorage(),r&&r(n.oldFlags,{isFromServer:!0})};return i?Promise.all([n.getJSON(s+"identities/?identifier="+encodeURIComponent(i))]).then((function(e){u(e[0],e[1])})).catch((function(e){var t=e.message;o&&o({message:t})})):Promise.all([n.getJSON(s+"flags/")]).then((function(t){u({flags:t[0]},null),e&&!a&&(a=!0,e())})).catch((function(e){t&&!a&&(a=!0,t(e)),o&&o(e)}))})),o(this,"getValue",(function(e){var t=n.flags&&n.flags[e],r=null;return t&&(r=t.value),r})),o(this,"getTrait",(function(e){return n.traits&&n.traits[e]})),o(this,"setTrait",(function(e,t){var r=n.getJSON,o=n.identity,i=n.api;return r("".concat(i,"traits/"),"POST",JSON.stringify({identity:{identifier:o},trait_key:e,trait_value:t})).then((function(){n.initialised&&n.getFlags()}))})),o(this,"setTraits",(function(e){var t=n.getJSON,o=n.identity,i=n.api;e&&"object"===r(e)||console.error("Expected object for bulletTrain.setTraits");var s=Object.keys(e).map((function(t){return{identity:{identifier:o},trait_key:t,trait_value:e[t]}}));return t("".concat(i,"traits/bulk/"),"PUT",JSON.stringify(s)).then((function(){n.initialised&&n.getFlags()}))})),o(this,"incrementTrait",(function(e,t){var r=n.getJSON,o=n.identity,i=n.api;return r("".concat(i,"traits/increment-value/"),"POST",JSON.stringify({trait_key:e,increment_by:t,identifier:o})).then(n.getFlags)})),o(this,"hasFeature",(function(e){var t=n.flags&&n.flags[e],r=!1;return t&&t.enabled&&(r=!0),r})),i=t.fetch?t.fetch:global.fetch,s=t.AsyncStorage}return function(e,t,r){t&&n(e.prototype,t),r&&n(e,r)}(e,[{key:"init",value:function(e){var t=this,r=e.environmentID,n=e.api,o=void 0===n?a:n,i=e.onChange,u=e.cacheFlags,c=e.onError,l=e.defaultFlags,f=e.preventFetch,h=e.enableLogs,p=e.AsyncStorage,d=e.state;return new Promise((function(e,n){if(t.environmentID=r,t.api=o,t.interval=null,t.onChange=i,t.onError=c,t.enableLogs=h,t.flags=Object.assign({},l)||{},t.initialised=!0,t.timer=t.enableLogs?(new Date).valueOf():null,p&&(s=p),t.cacheFlags=void 0!==s&&u,t.setState(d),!r)throw n("Please specify a environment id"),"Please specify a environment id";u?s.getItem("BULLET_TRAIN_DB",(function(r,o){if(o)try{var i=JSON.parse(o);i&&i.api===t.api&&(t.setState(i),t.log("Retrieved flags from cache",i)),t.flags?(t.onChange&&t.onChange(null,{isFromServer:!1}),e(),t.getFlags(Promise.resolve,Promise.reject)):t.getFlags(e,n)}catch(e){t.log("Exception fetching cached logs",e)}})):!f&&t.getFlags(e,n)}))}},{key:"getAllFlags",value:function(){return this.flags}},{key:"identify",value:function(e){this.identity=e,this.initialised&&!this.interval&&this.getFlags()}},{key:"getState",value:function(){return{api:this.api,environmentID:this.environmentID,flags:this.flags,identity:this.identity,segments:this.segments,traits:this.traits}}},{key:"setState",value:function(e){e&&(this.initialised=!0,this.api=e.api||this.api||a,this.environmentID=e.environmentID||this.environmentID,this.flags=e.flags||this.flags,this.identity=e.identity||this.identity,this.segments=e.segments||this.segments,this.traits=e.traits||this.traits)}},{key:"log",value:function(){if(this.enableLogs){for(var e=arguments.length,t=Array(e),r=0;r<e;r++)t[r]=arguments[r];console.log.apply(this,["BULLET TRAIN:",(new Date).valueOf()-this.timer,"ms"].concat(t))}}},{key:"updateStorage",value:function(){if(this.cacheFlags){var e=JSON.stringify(this.getState());this.log("Setting storage",e),s.setItem("BULLET_TRAIN_DB",e)}}},{key:"logout",value:function(){this.identity=null,this.segments=null,this.traits=null,this.initialised&&!this.interval&&this.getFlags()}},{key:"startListening",value:function(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:1e3;this.interval||(this.interval=setInterval(this.getFlags,e))}},{key:"getSegments",value:function(){}},{key:"stopListening",value:function(){clearInterval(this.interval)}}]),e}();e.exports=function(e){var t=e.fetch,r=e.AsyncStorage;return new u({fetch:t,AsyncStorage:r})}}])}));

@@ -1725,3 +1725,5 @@ !function (e, t) {

trait_value: t
})).then(n.getFlags);
})).then(function () {
n.initialised && n.getFlags();
});
}), o(this, "setTraits", function (e) {

@@ -1741,3 +1743,5 @@ var t = n.getJSON,

});
return t("".concat(i, "traits/bulk/"), "PUT", JSON.stringify(s)).then(n.getFlags);
return t("".concat(i, "traits/bulk/"), "PUT", JSON.stringify(s)).then(function () {
n.initialised && n.getFlags();
});
}), o(this, "incrementTrait", function (e, t) {

@@ -1744,0 +1748,0 @@ var r = n.getJSON,

{
"name": "bullet-train-client",
"version": "0.1.0",
"version": "0.1.1",
"description": "Feature flagging to support continuous development",

@@ -5,0 +5,0 @@ "main": "./index.js",

@@ -79,2 +79,9 @@ <img width="100%" src="https://raw.githubusercontent.com/SolidStateGroup/bullet-train-frontend/master/hero.png"/>

## Notes on initialisation
``identify``, ``setTrait`` and ``setTraits`` all trigger calls to ``getFlags``, which in turn hits the get flags endpoint. This is due to identities and traits affecting flags that are returned.
However, you can avoid these extra calls to get flags if you call these finctions before ``bulletTrain.init``.
## Contributing

@@ -81,0 +88,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc