@pubby/sdk
Version:
Pubby Development Kit
1 lines • 113 kB
JavaScript
var PubbySDK=function(t){"use strict";var n=function(t,e){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])})(t,e)};function c(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}var a=function(){return(a=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)};function h(t,s,a,u){return new(a=a||Promise)(function(r,e){function n(t){try{i(u.next(t))}catch(t){e(t)}}function o(t){try{i(u.throw(t))}catch(t){e(t)}}function i(t){var e;t.done?r(t.value):((e=t.value)instanceof a?e:new a(function(t){t(e)})).then(n,o)}i((u=u.apply(t,s||[])).next())})}function p(r,n){var o,i,s,a={label:0,sent:function(){if(1&s[0])throw s[1];return s[1]},trys:[],ops:[]},t={next:e(0),throw:e(1),return:e(2)};return"function"==typeof Symbol&&(t[Symbol.iterator]=function(){return this}),t;function e(e){return function(t){return function(e){if(o)throw new TypeError("Generator is already executing.");for(;a;)try{if(o=1,i&&(s=2&e[0]?i.return:e[0]?i.throw||((s=i.return)&&s.call(i),0):i.next)&&!(s=s.call(i,e[1])).done)return s;switch(i=0,(e=s?[2&e[0],s.value]:e)[0]){case 0:case 1:s=e;break;case 4:return a.label++,{value:e[1],done:!1};case 5:a.label++,i=e[1],e=[0];continue;case 7:e=a.ops.pop(),a.trys.pop();continue;default:if(!(s=0<(s=a.trys).length&&s[s.length-1])&&(6===e[0]||2===e[0])){a=0;continue}if(3===e[0]&&(!s||e[1]>s[0]&&e[1]<s[3])){a.label=e[1];break}if(6===e[0]&&a.label<s[1]){a.label=s[1],s=e;break}if(s&&a.label<s[2]){a.label=s[2],a.ops.push(e);break}s[2]&&a.ops.pop(),a.trys.pop();continue}e=n.call(r,a)}catch(t){e=[6,t],i=0}finally{o=s=0}if(5&e[0])throw e[1];return{value:e[0]?e[1]:void 0,done:!0}}([e,t])}}}Object.create;function l(t){var e="function"==typeof Symbol&&Symbol.iterator,r=e&&t[e],n=0;if(r)return r.call(t);if(t&&"number"==typeof t.length)return{next:function(){return{value:(t=t&&n>=t.length?void 0:t)&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function f(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,o,i=r.call(t),s=[];try{for(;(void 0===e||0<e--)&&!(n=i.next()).done;)s.push(n.value)}catch(t){o={error:t}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return s}function d(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(f(arguments[e]));return t}function y(t){return this instanceof y?(this.v=t,this):new y(t)}function e(t,e,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var o=r.apply(t,e||[]),i=[],s={};return n("next"),n("throw"),n("return"),s[Symbol.asyncIterator]=function(){return this},s;function n(n){o[n]&&(s[n]=function(r){return new Promise(function(t,e){1<i.push([n,r,t,e])||a(n,r)})})}function a(t,e){try{(r=o[t](e)).value instanceof y?Promise.resolve(r.value.v).then(u,c):h(i[0][2],r)}catch(t){h(i[0][3],t)}var r}function u(t){a("next",t)}function c(t){a("throw",t)}function h(t,e){t(e),i.shift(),i.length&&a(i[0][0],i[0][1])}}Object.create;var o=(r.prototype.add=function(t){var e,r,n,o;if(this.closed)return this;if(null===(this.value=t)){this.done=!0,this.closed=!0;try{for(var i=l(this._subscriptions),s=i.next();!s.done;s=i.next())(a=s.value).onComplete&&a.onComplete(),a.onFinish&&a.onFinish()}catch(t){e={error:t}}finally{try{s&&!s.done&&(r=i.return)&&r.call(i)}finally{if(e)throw e.error}}this.destroy()}else try{for(var a,u=l(this._subscriptions),c=u.next();!c.done;c=u.next())(a=c.value).onData&&a.onData(t)}catch(t){n={error:t}}finally{try{c&&!c.done&&(o=u.return)&&o.call(u)}finally{if(n)throw n.error}}return this},r.prototype.error=function(e){return this.closed||this._subscriptions.forEach(function(t){t.onError&&t.onError(e)}),this},r.prototype.pipe=function(e,t){if(void 0===t&&(t=!0),e.destroyed)throw new Error("Could not pipe, target stream is destroyed!");t=this.subscribe({onData:function(t){return e.add(t)},onError:function(t){return e.error(t)},onFinish:t?function(){return e.add(null)}:void 0}).subscription;return this._pipes.set(e,t),e},r.prototype.unpipe=function(t){var e=this._pipes.get(t);e&&(this._subscriptions.delete(e),this._pipes.delete(t))},r.prototype.subscribe=function(t,e){var r=this;return"function"==typeof t&&(t={onData:t,onError:e}),this._subscriptions.add(t),this._generator&&(this._generator(this),this._generator=void 0),{subscription:t,dispose:function(){return r.unsubscribe(t)}}},r.prototype.unsubscribe=function(t){return this._subscriptions.delete(t),this},r.prototype.destroy=function(){this.closed=!0,this.destroyed=!0,this._pipes.clear(),this._subscriptions.clear()},r.prototype.toPromise=function(){var n=this;return new Promise(function(e,t){var r=n.subscribe({onError:t,onData:function(t){r.dispose(),e(t)}})})},r.prototype.toIterator=function(){return e(this,arguments,function(){return p(this,function(t){switch(t.label){case 0:return this.done?[3,4]:[4,y(this.toPromise())];case 1:return[4,y(t.sent())];case 2:return[4,t.sent()];case 3:return t.sent(),[3,0];case 4:return[2]}})})},r.prototype[Symbol.asyncIterator]=function(){return this.toIterator()},r.prototype.watch=function(e){var r=this.value;return this.subscribe(function(t){t=e.watch(t);e.comparator(r,t)||e.listener({previous:r,current:t}),r=t})},r.prototype.createWatcher=function(e){var r=this;return function(t){return r.watch({watch:e.watch,comparator:e.comparator,listener:t})}},r.prototype.createEvent=function(e,r,n){return void 0===n&&(n=function(t){return t}),this.subscribe(function(t){return r.emit(e,n(t))})},r);function r(t){this._generator=t,this._subscriptions=new Set,this._pipes=new Map,this.closed=!1,this.destroyed=!1,this.done=!1,this.value=null}var i,s=(c(u,i=o),u.prototype.add=function(t){var r=this;return this.closed?this:null!==t?(this.transformFn(t,function(t,e){return t?r.error(t):i.prototype.add.call(r,e)}),this):i.prototype.add.call(this,t)},u);function u(t){var e=i.call(this)||this;return e.transformFn=t,e}function v(t,e){function r(t){return n.add(t)}var n=new o;return t.on?t.on(e,r):t.addEventListener&&t.addEventListener(e,r),n.subscribe({onFinish:function(){t.off?t.off(e,r):t.removeEventListener&&t.removeEventListener(e,r)}}),n}var m=Symbol("listeners"),b=(g.prototype.on=function(t){for(var e,r=[],n=1;n<arguments.length;n++)r[n-1]=arguments[n];var o=null!==(e=this[m].get(t))&&void 0!==e?e:new Map;return r.forEach(function(t){return o.set(t,{once:!1})}),this[m].set(t,o),this},g.prototype.once=function(t){for(var e,r=[],n=1;n<arguments.length;n++)r[n-1]=arguments[n];var o=null!==(e=this[m].get(t))&&void 0!==e?e:new Map;return r.forEach(function(t){return o.set(t,{once:!0})}),this[m].set(t,o),this},g.prototype.off=function(t){for(var e,r,n,o=[],i=1;i<arguments.length;i++)o[i-1]=arguments[i];if(!t)return this[m].clear(),this;if(!this[m].has(t))return this;if(!o.length)return this[m].delete(t),this;var s=null!==(n=this[m].get(t))&&void 0!==n?n:new Map;try{for(var a=l(o),u=a.next();!u.done;u=a.next()){var c=u.value;s.delete(c)}}catch(t){e={error:t}}finally{try{u&&!u.done&&(r=a.return)&&r.call(a)}finally{if(e)throw e.error}}return s.size<=0&&this[m].delete(t),this},g.prototype.emit=function(t){for(var e,r,n=[],o=1;o<arguments.length;o++)n[o-1]=arguments[o];if(!this[m].has(t))return this;var i=this[m].get(t);try{for(var s=l(i),a=s.next();!a.done;a=s.next()){var u=f(a.value,2),c=u[0];u[1].once&&i.delete(c),c.apply(void 0,d(n))}}catch(t){e={error:t}}finally{try{a&&!a.done&&(r=s.return)&&r.call(s)}finally{if(e)throw e.error}}return this},g.prototype.stream=function(t){return v(this,t)},g);function g(){this[_]=new Map}var w,_=m,k=(c(E,w=b),E);function E(t,e){var r=w.call(this)||this;return r.pubby=t,r.options=e,r}var O,j=Symbol("modulesMap"),x=(c(T,O=k),Object.defineProperty(T.prototype,"user",{get:function(){return this.strategy.user},enumerable:!1,configurable:!0}),Object.defineProperty(T.prototype,"strategy",{get:function(){return this.options.strategy},enumerable:!1,configurable:!0}),T.prototype.init=function(){var t,e;return null===(e=(t=this.strategy).init)||void 0===e?void 0:e.call(t,this.pubby)},T.prototype.isAuthenticated=function(){return this.strategy.isAuthenticated()},T);function T(t,e){e=O.call(this,t,e)||this;return t.auth=e}var A=new Function("try { return window.performance; } catch(e) { return undefined; }")(),S=new Function("try { return window.localStorage; } catch(e) { return undefined; }")(),R=new Map,C=null!=A?A:{now:function(){return 1e3*process.uptime()}},P=null!=S?S:{getItem:function(t){return R.get(t)},setItem:function(t,e){return R.set(t,e)},deleteItem:function(t){return R.delete(t)}},Nt="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function N(t,e){for(var r=e&&e.plainObjects?Object.create(null):{},n=0;n<t.length;++n)void 0!==t[n]&&(r[n]=t[n]);return r}function q(t,e,r,n,o,i,s,a,u,c,h,p,l){var f=t;if("function"==typeof s?f=s(e,f):f instanceof Date?f=c(f):"comma"===r&&K(f)&&(f=$.maybeMap(f,function(t){return t instanceof Date?c(t):t}).join(",")),null===f){if(n)return i&&!p?i(e,X.encoder,l,"key"):e;f=""}if(Z(f)||$.isBuffer(f))return i?[h(p?e:i(e,X.encoder,l,"key"))+"="+h(i(f,X.encoder,l,"value"))]:[h(e)+"="+h(String(f))];var d,y=[];if(void 0===f)return y;d=K(s)?s:(t=Object.keys(f),a?t.sort(a):t);for(var v=0;v<d.length;++v){var m=d[v],b=f[m];o&&null===b||(m=K(f)?"function"==typeof r?r(e,m):e:e+(u?"."+m:"["+m+"]"),W(y,q(b,m,r,n,o,i,s,a,u,c,h,p,l)))}return y}var L=Object.prototype.hasOwnProperty,U=Array.isArray,B=function(){for(var t=[],e=0;e<256;++e)t.push("%"+((e<16?"0":"")+e.toString(16)).toUpperCase());return t}(),I={arrayToObject:N,assign:function(t,r){return Object.keys(r).reduce(function(t,e){return t[e]=r[e],t},t)},combine:function(t,e){return[].concat(t,e)},compact:function(t){for(var e=[{obj:{o:t},prop:"o"}],r=[],n=0;n<e.length;++n)for(var o=e[n],i=o.obj[o.prop],s=Object.keys(i),a=0;a<s.length;++a){var u=s[a],c=i[u];"object"==typeof c&&null!==c&&-1===r.indexOf(c)&&(e.push({obj:i,prop:u}),r.push(c))}return function(t){for(;1<t.length;){var e=t.pop(),r=e.obj[e.prop];if(U(r)){for(var n=[],o=0;o<r.length;++o)void 0!==r[o]&&n.push(r[o]);e.obj[e.prop]=n}}}(e),t},decode:function(e,t,r){e=e.replace(/\+/g," ");if("iso-8859-1"===r)return e.replace(/%[0-9a-f]{2}/gi,unescape);try{return decodeURIComponent(e)}catch(t){return e}},encode:function(t,e,r){if(0===t.length)return t;var n=t;if("symbol"==typeof t?n=Symbol.prototype.toString.call(t):"string"!=typeof t&&(n=String(t)),"iso-8859-1"===r)return escape(n).replace(/%u[0-9a-f]{4}/gi,function(t){return"%26%23"+parseInt(t.slice(2),16)+"%3B"});for(var o="",i=0;i<n.length;++i){var s=n.charCodeAt(i);45===s||46===s||95===s||126===s||48<=s&&s<=57||65<=s&&s<=90||97<=s&&s<=122?o+=n.charAt(i):s<128?o+=B[s]:s<2048?o+=B[192|s>>6]+B[128|63&s]:s<55296||57344<=s?o+=B[224|s>>12]+B[128|s>>6&63]+B[128|63&s]:(i+=1,s=65536+((1023&s)<<10|1023&n.charCodeAt(i)),o+=B[240|s>>18]+B[128|s>>12&63]+B[128|s>>6&63]+B[128|63&s])}return o},isBuffer:function(t){return!(!t||"object"!=typeof t)&&!!(t.constructor&&t.constructor.isBuffer&&t.constructor.isBuffer(t))},isRegExp:function(t){return"[object RegExp]"===Object.prototype.toString.call(t)},maybeMap:function(t,e){if(U(t)){for(var r=[],n=0;n<t.length;n+=1)r.push(e(t[n]));return r}return e(t)},merge:function n(o,i,s){if(!i)return o;if("object"!=typeof i){if(U(o))o.push(i);else{if(!o||"object"!=typeof o)return[o,i];(s&&(s.plainObjects||s.allowPrototypes)||!L.call(Object.prototype,i))&&(o[i]=!0)}return o}if(!o||"object"!=typeof o)return[o].concat(i);var t=o;return U(o)&&!U(i)&&(t=N(o,s)),U(o)&&U(i)?(i.forEach(function(t,e){var r;L.call(o,e)?(r=o[e])&&"object"==typeof r&&t&&"object"==typeof t?o[e]=n(r,t,s):o.push(t):o[e]=t}),o):Object.keys(i).reduce(function(t,e){var r=i[e];return L.call(t,e)?t[e]=n(t[e],r,s):t[e]=r,t},t)}},M=String.prototype.replace,D=/%20/g,F={RFC1738:"RFC1738",RFC3986:"RFC3986"},z=I.assign({default:F.RFC3986,formatters:{RFC1738:function(t){return M.call(t,D,"+")},RFC3986:function(t){return String(t)}}},F),$=I,H=z,V=Object.prototype.hasOwnProperty,J={brackets:function(t){return t+"[]"},comma:"comma",indices:function(t,e){return t+"["+e+"]"},repeat:function(t){return t}},K=Array.isArray,G=Array.prototype.push,W=function(t,e){G.apply(t,K(e)?e:[e])},Y=Date.prototype.toISOString,Q=H.default,X={addQueryPrefix:!1,allowDots:!1,charset:"utf-8",charsetSentinel:!1,delimiter:"&",encode:!0,encoder:$.encode,encodeValuesOnly:!1,format:Q,formatter:H.formatters[Q],indices:!1,serializeDate:function(t){return Y.call(t)},skipNulls:!1,strictNullHandling:!1},Z=function(t){return"string"==typeof t||"number"==typeof t||"boolean"==typeof t||"symbol"==typeof t||"bigint"==typeof t},tt=I,et=Object.prototype.hasOwnProperty,rt=Array.isArray,nt={allowDots:!1,allowPrototypes:!1,arrayLimit:20,charset:"utf-8",charsetSentinel:!1,comma:!1,decoder:tt.decode,delimiter:"&",depth:5,ignoreQueryPrefix:!1,interpretNumericEntities:!1,parameterLimit:1e3,parseArrays:!0,plainObjects:!1,strictNullHandling:!1},ot=function(t){return t.replace(/&#(\d+);/g,function(t,e){return String.fromCharCode(parseInt(e,10))})},it=function(t,e){return t&&"string"==typeof t&&e.comma&&-1<t.indexOf(",")?t.split(","):t},st="utf8=%26%2310003%3B",at="utf8=%E2%9C%93",ut=function(t,e,r,n){for(var o=n?e:it(e,r),i=t.length-1;0<=i;--i){var s,a,u,c=t[i];"[]"===c&&r.parseArrays?s=[].concat(o):(s=r.plainObjects?Object.create(null):{},a="["===c.charAt(0)&&"]"===c.charAt(c.length-1)?c.slice(1,-1):c,u=parseInt(a,10),r.parseArrays||""!==a?!isNaN(u)&&c!==a&&String(u)===a&&0<=u&&r.parseArrays&&u<=r.arrayLimit?(s=[])[u]=o:s[a]=o:s={0:o}),o=s}return o},ct={formats:z,parse:function(t,e){var r=function(t){if(!t)return nt;if(null!==t.decoder&&void 0!==t.decoder&&"function"!=typeof t.decoder)throw new TypeError("Decoder has to be a function.");if(void 0!==t.charset&&"utf-8"!==t.charset&&"iso-8859-1"!==t.charset)throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var e=(void 0===t.charset?nt:t).charset;return{allowDots:void 0===t.allowDots?nt.allowDots:!!t.allowDots,allowPrototypes:("boolean"==typeof t.allowPrototypes?t:nt).allowPrototypes,arrayLimit:("number"==typeof t.arrayLimit?t:nt).arrayLimit,charset:e,charsetSentinel:("boolean"==typeof t.charsetSentinel?t:nt).charsetSentinel,comma:("boolean"==typeof t.comma?t:nt).comma,decoder:("function"==typeof t.decoder?t:nt).decoder,delimiter:("string"==typeof t.delimiter||tt.isRegExp(t.delimiter)?t:nt).delimiter,depth:"number"==typeof t.depth||!1===t.depth?+t.depth:nt.depth,ignoreQueryPrefix:!0===t.ignoreQueryPrefix,interpretNumericEntities:("boolean"==typeof t.interpretNumericEntities?t:nt).interpretNumericEntities,parameterLimit:("number"==typeof t.parameterLimit?t:nt).parameterLimit,parseArrays:!1!==t.parseArrays,plainObjects:("boolean"==typeof t.plainObjects?t:nt).plainObjects,strictNullHandling:("boolean"==typeof t.strictNullHandling?t:nt).strictNullHandling}}(e);if(""===t||null==t)return r.plainObjects?Object.create(null):{};for(var n="string"==typeof t?function(t,e){var r,n,o,i,s={},a=e.ignoreQueryPrefix?t.replace(/^\?/,""):t,t=e.parameterLimit===1/0?void 0:e.parameterLimit,u=a.split(e.delimiter,t),c=-1,h=e.charset;if(e.charsetSentinel)for(r=0;r<u.length;++r)0===u[r].indexOf("utf8=")&&(u[r]===at?h="utf-8":u[r]===st&&(h="iso-8859-1"),c=r,r=u.length);for(r=0;r<u.length;++r)r!==c&&((i=-1===(i=-1===(i=(n=u[r]).indexOf("]="))?n.indexOf("="):i+1)?(o=e.decoder(n,nt.decoder,h,"key"),e.strictNullHandling?null:""):(o=e.decoder(n.slice(0,i),nt.decoder,h,"key"),tt.maybeMap(it(n.slice(i+1),e),function(t){return e.decoder(t,nt.decoder,h,"value")})))&&e.interpretNumericEntities&&"iso-8859-1"===h&&(i=ot(i)),-1<n.indexOf("[]=")&&(i=rt(i)?[i]:i),et.call(s,o)?s[o]=tt.combine(s[o],i):s[o]=i);return s}(t,r):t,o=r.plainObjects?Object.create(null):{},i=Object.keys(n),s=0;s<i.length;++s)var a=i[s],a=function(t,e,r,n){if(t){var o=r.allowDots?t.replace(/\.([^.[]+)/g,"[$1]"):t,i=/(\[[^[\]]*])/g,s=0<r.depth&&/(\[[^[\]]*])/.exec(o),t=s?o.slice(0,s.index):o,a=[];if(t){if(!r.plainObjects&&et.call(Object.prototype,t)&&!r.allowPrototypes)return;a.push(t)}for(var u=0;0<r.depth&&null!==(s=i.exec(o))&&u<r.depth;){if(u+=1,!r.plainObjects&&et.call(Object.prototype,s[1].slice(1,-1))&&!r.allowPrototypes)return;a.push(s[1])}return s&&a.push("["+o.slice(s.index)+"]"),ut(a,e,r,n)}}(a,n[a],r,"string"==typeof t),o=tt.merge(o,a,r);return tt.compact(o)},stringify:function(t,e){var r=t,n=function(t){if(!t)return X;if(null!==t.encoder&&void 0!==t.encoder&&"function"!=typeof t.encoder)throw new TypeError("Encoder has to be a function.");var e=t.charset||X.charset;if(void 0!==t.charset&&"utf-8"!==t.charset&&"iso-8859-1"!==t.charset)throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var r=H.default;if(void 0!==t.format){if(!V.call(H.formatters,t.format))throw new TypeError("Unknown format option provided.");r=t.format}var n=H.formatters[r],r=X.filter;return"function"!=typeof t.filter&&!K(t.filter)||(r=t.filter),{addQueryPrefix:("boolean"==typeof t.addQueryPrefix?t:X).addQueryPrefix,allowDots:void 0===t.allowDots?X.allowDots:!!t.allowDots,charset:e,charsetSentinel:("boolean"==typeof t.charsetSentinel?t:X).charsetSentinel,delimiter:(void 0===t.delimiter?X:t).delimiter,encode:("boolean"==typeof t.encode?t:X).encode,encoder:("function"==typeof t.encoder?t:X).encoder,encodeValuesOnly:("boolean"==typeof t.encodeValuesOnly?t:X).encodeValuesOnly,filter:r,formatter:n,serializeDate:("function"==typeof t.serializeDate?t:X).serializeDate,skipNulls:("boolean"==typeof t.skipNulls?t:X).skipNulls,sort:"function"==typeof t.sort?t.sort:null,strictNullHandling:("boolean"==typeof t.strictNullHandling?t:X).strictNullHandling}}(e);"function"==typeof n.filter?r=(0,n.filter)("",r):K(n.filter)&&(s=n.filter);var o=[];if("object"!=typeof r||null===r)return"";var t=e&&e.arrayFormat in J?e.arrayFormat:!(e&&"indices"in e)||e.indices?"indices":"repeat",i=J[t],s=s||Object.keys(r);n.sort&&s.sort(n.sort);for(var a=0;a<s.length;++a){var u=s[a];n.skipNulls&&null===r[u]||W(o,q(r[u],u,i,n.strictNullHandling,n.skipNulls,n.encode?n.encoder:null,n.filter,n.sort,n.allowDots,n.serializeDate,n.formatter,n.encodeValuesOnly,n.charset))}e=o.join(n.delimiter),t=!0===n.addQueryPrefix?"?":"";return n.charsetSentinel&&("iso-8859-1"===n.charset?t+="utf8=%26%2310003%3B&":t+="utf8=%E2%9C%93&"),0<e.length?t+e:""}},ht={exports:{}},pt=function(r,n){return function(){for(var t=new Array(arguments.length),e=0;e<t.length;e++)t[e]=arguments[e];return r.apply(n,t)}},lt=pt,ft=Object.prototype.toString;function dt(t){return"[object Array]"===ft.call(t)}function yt(t){return void 0===t}function vt(t){return null!==t&&"object"==typeof t}function mt(t){if("[object Object]"!==ft.call(t))return!1;t=Object.getPrototypeOf(t);return null===t||t===Object.prototype}function bt(t){return"[object Function]"===ft.call(t)}function gt(t,e){if(null!=t)if(dt(t="object"!=typeof t?[t]:t))for(var r=0,n=t.length;r<n;r++)e.call(null,t[r],r,t);else for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&e.call(null,t[o],o,t)}var wt={isArray:dt,isArrayBuffer:function(t){return"[object ArrayBuffer]"===ft.call(t)},isBuffer:function(t){return null!==t&&!yt(t)&&null!==t.constructor&&!yt(t.constructor)&&"function"==typeof t.constructor.isBuffer&&t.constructor.isBuffer(t)},isFormData:function(t){return"undefined"!=typeof FormData&&t instanceof FormData},isArrayBufferView:function(t){return t="undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(t):t&&t.buffer&&t.buffer instanceof ArrayBuffer},isString:function(t){return"string"==typeof t},isNumber:function(t){return"number"==typeof t},isObject:vt,isPlainObject:mt,isUndefined:yt,isDate:function(t){return"[object Date]"===ft.call(t)},isFile:function(t){return"[object File]"===ft.call(t)},isBlob:function(t){return"[object Blob]"===ft.call(t)},isFunction:bt,isStream:function(t){return vt(t)&&bt(t.pipe)},isURLSearchParams:function(t){return"undefined"!=typeof URLSearchParams&&t instanceof URLSearchParams},isStandardBrowserEnv:function(){return("undefined"==typeof navigator||"ReactNative"!==navigator.product&&"NativeScript"!==navigator.product&&"NS"!==navigator.product)&&("undefined"!=typeof window&&"undefined"!=typeof document)},forEach:gt,merge:function r(){var n={};function t(t,e){mt(n[e])&&mt(t)?n[e]=r(n[e],t):mt(t)?n[e]=r({},t):dt(t)?n[e]=t.slice():n[e]=t}for(var e=0,o=arguments.length;e<o;e++)gt(arguments[e],t);return n},extend:function(r,t,n){return gt(t,function(t,e){r[e]=n&&"function"==typeof t?lt(t,n):t}),r},trim:function(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")},stripBOM:function(t){return t=65279===t.charCodeAt(0)?t.slice(1):t}},_t=wt;function kt(t){return encodeURIComponent(t).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function Et(t,e,r){return e&&(r=r?r(e):_t.isURLSearchParams(e)?e.toString():(n=[],_t.forEach(e,function(t,e){null!=t&&(_t.isArray(t)?e+="[]":t=[t],_t.forEach(t,function(t){_t.isDate(t)?t=t.toISOString():_t.isObject(t)&&(t=JSON.stringify(t)),n.push(kt(e)+"="+kt(t))}))}),n.join("&")))&&(-1!==(e=t.indexOf("#"))&&(t=t.slice(0,e)),t+=(-1===t.indexOf("?")?"?":"&")+r),t;var n}var Ot=wt;function jt(){this.handlers=[]}jt.prototype.use=function(t,e,r){return this.handlers.push({fulfilled:t,rejected:e,synchronous:!!r&&r.synchronous,runWhen:r?r.runWhen:null}),this.handlers.length-1},jt.prototype.eject=function(t){this.handlers[t]&&(this.handlers[t]=null)},jt.prototype.forEach=function(e){Ot.forEach(this.handlers,function(t){null!==t&&e(t)})};var xt,Tt,At,b=jt,St=wt,A=function(t,e,r,n,o){return t.config=e,r&&(t.code=r),t.request=n,t.response=o,t.isAxiosError=!0,t.toJSON=function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:this.config,code:this.code,status:this.response&&this.response.status?this.response.status:null}},t},Rt=A,S=function(t,e,r,n,o){t=new Error(t);return Rt(t,e,r,n,o)},Ct=S,Pt=wt,F=Pt.isStandardBrowserEnv()?{write:function(t,e,r,n,o,i){var s=[];s.push(t+"="+encodeURIComponent(e)),Pt.isNumber(r)&&s.push("expires="+new Date(r).toGMTString()),Pt.isString(n)&&s.push("path="+n),Pt.isString(o)&&s.push("domain="+o),!0===i&&s.push("secure"),document.cookie=s.join("; ")},read:function(t){t=document.cookie.match(new RegExp("(^|;\\s*)("+t+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove:function(t){this.write(t,"",Date.now()-864e5)}}:{write:function(){},read:function(){return null},remove:function(){}},qt=function(t){return/^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(t)},Lt=function(t,e){return e?t.replace(/\/+$/,"")+"/"+e.replace(/^\/+/,""):t},Ut=wt,Bt=["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"],It=wt,Q=It.isStandardBrowserEnv()?(Tt=/(msie|trident)/i.test(navigator.userAgent),At=document.createElement("a"),xt=Mt(window.location.href),function(t){t=It.isString(t)?Mt(t):t;return t.protocol===xt.protocol&&t.host===xt.host}):function(){return!0};function Mt(t){return Tt&&(At.setAttribute("href",t),t=At.href),At.setAttribute("href",t),{href:At.href,protocol:At.protocol?At.protocol.replace(/:$/,""):"",host:At.host,search:At.search?At.search.replace(/^\?/,""):"",hash:At.hash?At.hash.replace(/^#/,""):"",hostname:At.hostname,port:At.port,pathname:"/"===At.pathname.charAt(0)?At.pathname:"/"+At.pathname}}function Dt(t){this.message=t}Dt.prototype.toString=function(){return"Cancel"+(this.message?": "+this.message:"")},Dt.prototype.__CANCEL__=!0;function Ft(p){return new Promise(function(e,r){var t,n=p.data,o=p.headers,i=p.responseType;function s(){p.cancelToken&&p.cancelToken.unsubscribe(t),p.signal&&p.signal.removeEventListener("abort",t)}zt.isFormData(n)&&delete o["Content-Type"];var a,u=new XMLHttpRequest;p.auth&&(a=p.auth.username||"",c=p.auth.password?unescape(encodeURIComponent(p.auth.password)):"",o.Authorization="Basic "+btoa(a+":"+c));var c=Jt(p.baseURL,p.url);function h(){var t;u&&(t="getAllResponseHeaders"in u?Kt(u.getAllResponseHeaders()):null,t={data:i&&"text"!==i&&"json"!==i?u.response:u.responseText,status:u.status,statusText:u.statusText,headers:t,config:p,request:u},$t(function(t){e(t),s()},function(t){r(t),s()},t),u=null)}u.open(p.method.toUpperCase(),Vt(c,p.params,p.paramsSerializer),!0),u.timeout=p.timeout,"onloadend"in u?u.onloadend=h:u.onreadystatechange=function(){u&&4===u.readyState&&(0!==u.status||u.responseURL&&0===u.responseURL.indexOf("file:"))&&setTimeout(h)},u.onabort=function(){u&&(r(Wt("Request aborted",p,"ECONNABORTED",u)),u=null)},u.onerror=function(){r(Wt("Network Error",p,null,u)),u=null},u.ontimeout=function(){var t=p.timeout?"timeout of "+p.timeout+"ms exceeded":"timeout exceeded",e=p.transitional||Yt.transitional;p.timeoutErrorMessage&&(t=p.timeoutErrorMessage),r(Wt(t,p,e.clarifyTimeoutError?"ETIMEDOUT":"ECONNABORTED",u)),u=null},!zt.isStandardBrowserEnv()||(c=(p.withCredentials||Gt(c))&&p.xsrfCookieName?Ht.read(p.xsrfCookieName):void 0)&&(o[p.xsrfHeaderName]=c),"setRequestHeader"in u&&zt.forEach(o,function(t,e){void 0===n&&"content-type"===e.toLowerCase()?delete o[e]:u.setRequestHeader(e,t)}),zt.isUndefined(p.withCredentials)||(u.withCredentials=!!p.withCredentials),i&&"json"!==i&&(u.responseType=p.responseType),"function"==typeof p.onDownloadProgress&&u.addEventListener("progress",p.onDownloadProgress),"function"==typeof p.onUploadProgress&&u.upload&&u.upload.addEventListener("progress",p.onUploadProgress),(p.cancelToken||p.signal)&&(t=function(t){u&&(r(!t||t.type?new Qt("canceled"):t),u.abort(),u=null)},p.cancelToken&&p.cancelToken.subscribe(t),p.signal&&(p.signal.aborted?t():p.signal.addEventListener("abort",t))),n=n||null,u.send(n)})}var I=Dt,zt=wt,$t=function(t,e,r){var n=r.config.validateStatus;r.status&&n&&!n(r.status)?e(Ct("Request failed with status code "+r.status,r.config,null,r.request,r)):t(r)},Ht=F,Vt=Et,Jt=function(t,e){return t&&!qt(e)?Lt(t,e):e},Kt=function(t){var e,r,n={};return t&&Ut.forEach(t.split("\n"),function(t){r=t.indexOf(":"),e=Ut.trim(t.substr(0,r)).toLowerCase(),r=Ut.trim(t.substr(r+1)),e&&(n[e]&&0<=Bt.indexOf(e)||(n[e]="set-cookie"===e?(n[e]||[]).concat([r]):n[e]?n[e]+", "+r:r))}),n},Gt=Q,Wt=S,Yt=void 0,Qt=I,Xt=wt,Zt=function(r,n){St.forEach(r,function(t,e){e!==n&&e.toUpperCase()===n.toUpperCase()&&(r[n]=t,delete r[e])})},te=A,ee={"Content-Type":"application/x-www-form-urlencoded"};function re(t,e){!Xt.isUndefined(t)&&Xt.isUndefined(t["Content-Type"])&&(t["Content-Type"]=e)}var ne,oe={transitional:{silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},adapter:ne="undefined"!=typeof XMLHttpRequest||"undefined"!=typeof process&&"[object process]"===Object.prototype.toString.call(process)?Ft:ne,transformRequest:[function(t,e){return Zt(e,"Accept"),Zt(e,"Content-Type"),Xt.isFormData(t)||Xt.isArrayBuffer(t)||Xt.isBuffer(t)||Xt.isStream(t)||Xt.isFile(t)||Xt.isBlob(t)?t:Xt.isArrayBufferView(t)?t.buffer:Xt.isURLSearchParams(t)?(re(e,"application/x-www-form-urlencoded;charset=utf-8"),t.toString()):Xt.isObject(t)||e&&"application/json"===e["Content-Type"]?(re(e,"application/json"),function(t,e,r){if(Xt.isString(t))try{return(e||JSON.parse)(t),Xt.trim(t)}catch(t){if("SyntaxError"!==t.name)throw t}return(r||JSON.stringify)(t)}(t)):t}],transformResponse:[function(t){var e=this.transitional||oe.transitional,r=e&&e.silentJSONParsing,e=e&&e.forcedJSONParsing,r=!r&&"json"===this.responseType;if(r||e&&Xt.isString(t)&&t.length)try{return JSON.parse(t)}catch(t){if(r){if("SyntaxError"===t.name)throw te(t,this,"E_JSON_PARSE");throw t}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,validateStatus:function(t){return 200<=t&&t<300},headers:{common:{Accept:"application/json, text/plain, */*"}}};Xt.forEach(["delete","get","head"],function(t){oe.headers[t]={}}),Xt.forEach(["post","put","patch"],function(t){oe.headers[t]=Xt.merge(ee)});var z=oe,ie=wt,se=z,F=function(t){return!(!t||!t.__CANCEL__)},ae=wt,ue=function(e,r,t){var n=this||se;return ie.forEach(t,function(t){e=t.call(n,e,r)}),e},ce=F,he=z,pe=I;function le(t){if(t.cancelToken&&t.cancelToken.throwIfRequested(),t.signal&&t.signal.aborted)throw new pe("canceled")}var fe=wt,Q=function(e,r){r=r||{};var n={};function o(t,e){return fe.isPlainObject(t)&&fe.isPlainObject(e)?fe.merge(t,e):fe.isPlainObject(e)?fe.merge({},e):fe.isArray(e)?e.slice():e}function i(t){return fe.isUndefined(r[t])?fe.isUndefined(e[t])?void 0:o(void 0,e[t]):o(e[t],r[t])}function t(t){if(!fe.isUndefined(r[t]))return o(void 0,r[t])}function s(t){return fe.isUndefined(r[t])?fe.isUndefined(e[t])?void 0:o(void 0,e[t]):o(void 0,r[t])}function a(t){return t in r?o(e[t],r[t]):t in e?o(void 0,e[t]):void 0}var u={url:t,method:t,data:t,baseURL:s,transformRequest:s,transformResponse:s,paramsSerializer:s,timeout:s,timeoutMessage:s,withCredentials:s,adapter:s,responseType:s,xsrfCookieName:s,xsrfHeaderName:s,onUploadProgress:s,onDownloadProgress:s,decompress:s,maxContentLength:s,maxBodyLength:s,transport:s,httpAgent:s,httpsAgent:s,cancelToken:s,socketPath:s,responseEncoding:s,validateStatus:a};return fe.forEach(Object.keys(e).concat(Object.keys(r)),function(t){var e=u[t]||i,r=e(t);fe.isUndefined(r)&&e!==a||(n[t]=r)}),n},S="0.24.0",de=S,ye={};["object","boolean","number","function","string","symbol"].forEach(function(e,r){ye[e]=function(t){return typeof t===e||"a"+(r<1?"n ":" ")+e}});var ve={};ye.transitional=function(n,o,r){function i(t,e){return"[Axios v"+de+"] Transitional option '"+t+"'"+e+(r?". "+r:"")}return function(t,e,r){if(!1===n)throw new Error(i(e," has been removed"+(o?" in "+o:"")));return o&&!ve[e]&&(ve[e]=!0,console.warn(i(e," has been deprecated since v"+o+" and will be removed in the near future"))),!n||n(t,e,r)}};var A=wt,me=Et,be=b,ge=function(e){return le(e),e.headers=e.headers||{},e.data=ue.call(e,e.data,e.headers,e.transformRequest),e.headers=ae.merge(e.headers.common||{},e.headers[e.method]||{},e.headers),ae.forEach(["delete","get","head","post","put","patch","common"],function(t){delete e.headers[t]}),(e.adapter||he.adapter)(e).then(function(t){return le(e),t.data=ue.call(e,t.data,t.headers,e.transformResponse),t},function(t){return ce(t)||(le(e),t&&t.response&&(t.response.data=ue.call(e,t.response.data,t.response.headers,e.transformResponse))),Promise.reject(t)})},we=Q,_e={assertOptions:function(t,e,r){if("object"!=typeof t)throw new TypeError("options must be an object");for(var n=Object.keys(t),o=n.length;0<o--;){var i=n[o],s=e[i];if(s){var a=t[i],a=void 0===a||s(a,i,t);if(!0!==a)throw new TypeError("option "+i+" must be "+a)}else if(!0!==r)throw Error("Unknown option "+i)}},validators:ye},ke=_e.validators;function Ee(t){this.defaults=t,this.interceptors={request:new be,response:new be}}Ee.prototype.request=function(e){"string"==typeof e?(e=arguments[1]||{}).url=arguments[0]:e=e||{},(e=we(this.defaults,e)).method?e.method=e.method.toLowerCase():this.defaults.method?e.method=this.defaults.method.toLowerCase():e.method="get";var t=e.transitional;void 0!==t&&_e.assertOptions(t,{silentJSONParsing:ke.transitional(ke.boolean),forcedJSONParsing:ke.transitional(ke.boolean),clarifyTimeoutError:ke.transitional(ke.boolean)},!1);var r=[],n=!0;this.interceptors.request.forEach(function(t){"function"==typeof t.runWhen&&!1===t.runWhen(e)||(n=n&&t.synchronous,r.unshift(t.fulfilled,t.rejected))});var o,i=[];if(this.interceptors.response.forEach(function(t){i.push(t.fulfilled,t.rejected)}),!n){var s=[ge,void 0];for(Array.prototype.unshift.apply(s,r),s=s.concat(i),o=Promise.resolve(e);s.length;)o=o.then(s.shift(),s.shift());return o}for(var a=e;r.length;){var u=r.shift(),c=r.shift();try{a=u(a)}catch(t){c(t);break}}try{o=ge(a)}catch(t){return Promise.reject(t)}for(;i.length;)o=o.then(i.shift(),i.shift());return o},Ee.prototype.getUri=function(t){return t=we(this.defaults,t),me(t.url,t.params,t.paramsSerializer).replace(/^\?/,"")},A.forEach(["delete","get","head","options"],function(r){Ee.prototype[r]=function(t,e){return this.request(we(e||{},{method:r,url:t,data:(e||{}).data}))}}),A.forEach(["post","put","patch"],function(n){Ee.prototype[n]=function(t,e,r){return this.request(we(r||{},{method:n,url:t,data:e}))}});var b=Ee,Oe=I;function je(t){if("function"!=typeof t)throw new TypeError("executor must be a function.");var e;this.promise=new Promise(function(t){e=t});var n=this;this.promise.then(function(t){if(n._listeners){for(var e=n._listeners.length,r=0;r<e;r++)n._listeners[r](t);n._listeners=null}}),this.promise.then=function(t){var e,t=new Promise(function(t){n.subscribe(t),e=t}).then(t);return t.cancel=function(){n.unsubscribe(e)},t},t(function(t){n.reason||(n.reason=new Oe(t),e(n.reason))})}je.prototype.throwIfRequested=function(){if(this.reason)throw this.reason},je.prototype.subscribe=function(t){this.reason?t(this.reason):this._listeners?this._listeners.push(t):this._listeners=[t]},je.prototype.unsubscribe=function(t){!this._listeners||-1!==(t=this._listeners.indexOf(t))&&this._listeners.splice(t,1)},je.source=function(){var e;return{token:new je(function(t){e=t}),cancel:e}};var A=je,xe=wt,Te=pt,Ae=b,Se=Q;pt=function e(r){var t=new Ae(r),n=Te(Ae.prototype.request,t);return xe.extend(n,Ae.prototype,t),xe.extend(n,t),n.create=function(t){return e(Se(r,t))},n}(z);pt.Axios=Ae,pt.Cancel=I,pt.CancelToken=A,pt.isCancel=F,pt.VERSION=S,pt.all=function(t){return Promise.all(t)},pt.spread=function(e){return function(t){return e.apply(null,t)}},pt.isAxiosError=function(t){return"object"==typeof t&&!0===t.isAxiosError},ht.exports=pt;ht.exports.default=pt,ht.exports;var Re=ht.exports;function Ce(t){this.message=t}(Ce.prototype=new Error).name="InvalidCharacterError";var Pe="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(t){var e=String(t).replace(/=+$/,"");if(e.length%4==1)throw new Ce("'atob' failed: The string to be decoded is not correctly encoded.");for(var r,n,o=0,i=0,s="";n=e.charAt(i++);~n&&(r=o%4?64*r+n:n,o++%4)&&(s+=String.fromCharCode(255&r>>(-2*o&6))))n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(n);return s};function Ne(t){this.message=t}function qe(t,e){if("string"!=typeof t)throw new Ne("Invalid token specified");e=!0===(e=e||{}).header?0:1;try{return JSON.parse(function(t){var e=t.replace(/-/g,"+").replace(/_/g,"/");switch(e.length%4){case 0:break;case 2:e+="==";break;case 3:e+="=";break;default:throw"Illegal base64url string!"}try{return decodeURIComponent(Pe(e).replace(/(.)/g,function(t,e){e=e.charCodeAt(0).toString(16).toUpperCase();return"%"+(e=e.length<2?"0"+e:e)}))}catch(t){return Pe(e)}}(t.split(".")[e]))}catch(t){throw new Ne("Invalid token specified: "+t.message)}}(Ne.prototype=new Error).name="InvalidTokenError";function Le(e){return function(t){return a(a({},t),{data:ct.stringify({grant_type:"refresh_token",refresh_token:e})})}}var Ue=(Be.prototype.getToken=function(){return h(this,void 0,void 0,function(){return p(this,function(t){return[2,this.options.storage.get()]})})},Be.prototype.getTokenPayload=function(){return h(this,void 0,void 0,function(){var e;return p(this,function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),e=qe,[4,this.getToken()];case 1:return[2,e.apply(void 0,[t.sent().accessToken])];case 2:return t.sent(),[2,null];case 3:return[2]}})})},Be.prototype.isTokenExpired=function(){var o;return h(this,void 0,void 0,function(){var e,r,n;return p(this,function(t){switch(t.label){case 0:return[4,this.getToken()];case 1:return(e=t.sent().expires,null===(o=this.offset)||void 0===o)?[3,2]:(n=o,[3,4]);case 2:return[4,this.updateOffset()];case 3:n=t.sent(),t.label=4;case 4:return r=n,[2,Date.now()-r+this.delay>=e]}})})},Be.prototype.isAuthenticated=function(){return h(this,void 0,void 0,function(){return p(this,function(t){switch(t.label){case 0:return[4,this.getTokenPayload()];case 1:return null===t.sent()?[3,3]:[4,this.fetchOrRefreshAccessToken()];case 2:return t.sent(),[2,!0];case 3:return[2,!1]}})})},Be.prototype.updateOffset=function(){return h(this,void 0,void 0,function(){var e;return p(this,function(t){switch(t.label){case 0:return[4,Re.get(process.env.baseURL+"/oauth/time").then(function(t){return t.data.time}).catch(function(){return 0})];case 1:return e=t.sent(),this.offset=Date.now()-e,[2,this.offset]}})})},Be.prototype.fetchOrRefreshAccessToken=function(){return h(this,void 0,void 0,function(){var o,e=this;return p(this,function(t){switch(t.label){case 0:return[4,this.getToken()];case 1:return null!=(o=t.sent())&&o.refreshToken?(this.tokenRequest||(this.tokenRequest=new Promise(function(r,n){return h(e,void 0,void 0,function(){var e;return p(this,function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,this.isTokenExpired()];case 1:return t.sent()?r(this.refreshAccessToken().then(function(t){return t.accessToken})):r(null==o?void 0:o.accessToken),[3,3];case 2:return e=t.sent(),n(e),[3,3];case 3:return[2]}})})}).finally(function(){e.tokenRequest=null})),[2,this.tokenRequest]):[2,Promise.resolve(null)]}})})},Be.prototype.requestToken=function(t){t=t({method:"POST",baseURL:this.options.tokenUrl,headers:{"content-type":"application/x-www-form-urlencoded"},auth:{username:this.options.clientId,password:this.options.clientSecret}},a({},this.options));return Re(t).then(function(t){return{accessToken:t.data.access_token,refreshToken:t.data.refresh_token,expires:Date.now()+1e3*t.data.expires}})},Be.prototype.requestTokenAndSave=function(r){return h(this,void 0,void 0,function(){var e=this;return p(this,function(t){return[2,this.requestToken(r).then(function(t){return e.options.storage.save(t)})]})})},Be.prototype.login=function(t,e,r){var n,o,i,s=this;return this.requestToken((n=t,o=e,void 0===(i=r=void 0===r?[]:r)&&(i=[]),function(t){return a(a({},t),{data:ct.stringify({grant_type:"password",username:n,password:o,scope:i.join(" ")})})})).then(function(t){return s.options.storage.save(t)})},Be.prototype.revoke=function(){return h(this,void 0,void 0,function(){var e;return p(this,function(t){switch(t.label){case 0:return[4,this.getToken()];case 1:return e=t.sent(),[4,Re({method:"DELETE",baseURL:this.options.tokenUrl,headers:{"content-type":"application/x-www-form-urlencoded",authorization:"Bearer "+(null==e?void 0:e.accessToken),"x-refresh-token":null==e?void 0:e.refreshToken}})];case 2:return t.sent(),[2]}})})},Be.prototype.refreshAccessToken=function(){return h(this,void 0,void 0,function(){var e,r,n=this;return p(this,function(t){switch(t.label){case 0:return e=this.requestTokenAndSave,r=Le,[4,this.getToken()];case 1:return[2,e.apply(this,[r.apply(void 0,[t.sent().refreshToken])]).catch(function(r){return h(n,void 0,void 0,function(){var e;return p(this,function(t){switch(t.label){case 0:return null!==(e=r.response)&&void 0!==e&&e.data.error?[4,this.options.storage.clear()]:[3,2];case 1:t.sent(),t.label=2;case 2:return[2,Promise.reject(r)]}})})})]}})})},Be);function Be(t){this.tokenRequest=null,this.offset=0,this.delay=3e3;var r="pubby";this.options=a({storage:{get:function(){var e;return h(this,void 0,void 0,function(){return p(this,function(t){return[2,JSON.parse(null!==(e=P.getItem(r))&&void 0!==e?e:"{}")]})})},save:function(e){return h(this,void 0,void 0,function(){return p(this,function(t){return P.setItem(r,JSON.stringify(e)),[2,e]})})},clear:function(){return h(this,void 0,void 0,function(){return p(this,function(t){return P.removeItem(r),[2]})})}}},t)}var Ie=(Me.prototype.init=function(n){return h(this,void 0,void 0,function(){var r;return p(this,function(t){switch(t.label){case 0:return this.oauth=new Ue({tokenUrl:n.config.current.baseURL+"/oauth/token",clientId:this.options.clientId,clientSecret:this.options.secret}),[4,this.oauth.requestTokenAndSave((void 0===(e=["user"])&&(e=[]),function(t){return a(a({},t),{data:ct.stringify({grant_type:"client_credentials",scope:e.join(" ")})})}))];case 1:return t.sent(),r=this,[4,n.api.user.getProfile()];case 2:return r.user=t.sent(),n.has("ws")?[4,n.ws.connect()]:[3,4];case 3:t.sent(),t.label=4;case 4:return[2]}var e})})},Me.prototype.getToken=function(){return this.oauth.getToken().then(function(t){return t.accessToken})},Me.prototype.getTicket=function(){return h(this,void 0,void 0,function(){return p(this,function(t){return[2,this.getToken()]})})},Me.prototype.isAuthenticated=function(){return this.oauth.isAuthenticated()},Me);function Me(t){this.options=t}var De,b=(c(Fe,De=k),Fe);function Fe(t,e){var r=De.call(this,t,e)||this;return t.use(x,{strategy:new Ie(e)}),r}Object.defineProperty(ze.prototype,"baseURL",{get:function(){return this.api.pubby.config.current.baseURL},enumerable:!1,configurable:!0}),ze.prototype.request=function(t){return this.axios.request(t=void 0===t?{}:t).then(function(t){return t.data})},ze.prototype.find=function(t,e){return this.request(a({method:"get",url:"/",params:t=void 0===t?{}:t},e=void 0===e?{}:e))},ze.prototype.findOne=function(t,e,r){return void 0===e&&(e={}),void 0===r&&(r={}),this.request(a({method:"get",url:String(t),params:e},r))},ze.prototype.create=function(t,e,r){return this.request(a({method:"post",url:"/",data:t,params:e=void 0===e?{}:e},r=void 0===r?{}:r))},ze.prototype.update=function(t,e,r){return void 0===e&&(e={}),void 0===r&&(r={}),this.request(a({method:"patch",url:String(t.id),data:t,params:e},r))},ze.prototype.delete=function(e,r,n){return void 0===r&&(r={}),void 0===n&&(n={}),h(this,void 0,void 0,function(){return p(this,function(t){switch(t.label){case 0:return[4,this.request(a({method:"delete",url:String(e),params:r},n))];case 1:return t.sent(),[2]}})})},ze.prototype.save=function(t,e,r){return void 0===e&&(e={}),void 0===r&&(r={}),t.id?this.update(t,e,r):this.create(t,e,r)},ze.axios=Re,Q=ze;function ze(t,e,r){var o=this;void 0===r&&(r={}),this.api=t,this.axios=ze.axios.create(a({baseURL:this.baseURL+"/"+e},r)),this.axios.interceptors.request.use(function(n){return h(o,void 0,void 0,function(){var e,r;return p(this,function(t){switch(t.label){case 0:return n.public?[3,2]:[4,this.api.pubby.auth.strategy.getToken()];case 1:(e=t.sent())&&(n.headers.authorization=null!==(r=n.headers.authorization)&&void 0!==r?r:"Bearer "+e),t.label=2;case 2:return[2,n]}})})})}var $e,He=(c(Ve,$e=Q),Ve.prototype.getMedias=function(t,e){return this.request({method:"GET",url:t+"/items",params:e=void 0===e?{}:e})},Ve.prototype.addMedias=function(t,e,r){return this.request({method:"POST",url:t+"/items",data:e,params:r=void 0===r?{}:r})},Ve.prototype.deleteMedia=function(t,e,r){return this.request({method:"DELETE",url:t+"/items/"+e,params:r=void 0===r?{}:r})},Ve.prototype.updateMedia=function(t,e,r){return this.request({method:"PATCH",url:t+"/items/"+e.id,data:e,params:r=void 0===r?{}:r})},Ve.prototype.moveMedia=function(t,e,r,n,o){return this.request({method:"PATCH",url:t+"/items/"+e+"/move",params:o=void 0===o?{}:o,data:{target:r,direction:n}})},Ve.prototype.getImportToken=function(){return this.request({method:"GET",baseURL:this.baseURL+"/import",url:"token"}).then(function(t){return t.token})},Ve.prototype.exportAll=function(){return this.request({method:"GET",url:"/export"})},Ve.prototype.shuffle=function(t){return this.request({method:"PATCH",url:t+"/shuffle"})},Ve);function Ve(t){return $e.call(this,t,"me/playlists")||this}var Je,Ke=(c(Ge,Je=Q),Ge.prototype.myRooms=function(t){return this.request({method:"GET",baseURL:this.baseURL+"/me/rooms",url:"/",params:t=void 0===t?{}:t})},Ge.prototype.getCurrent=function(){return this.request({method:"GET",baseURL:this.baseURL+"/me/rooms",url:"current"})},Ge.prototype.save=function(t){var e;return this.request({method:t.id?"PATCH":"POST",baseURL:this.baseURL+"/me/rooms",url:null!==(e=t.id)&&void 0!==e?e:"/",data:t})},Ge.prototype.getRoles=function(t){return this.request({method:"GET",url:t+"/roles"}).then(function(t){return t.map(function(t){return[t.id,t]})}).then(function(t){return new Map(t)})},Ge.prototype.addRole=function(t,e,r){return this.request({method:"POST",url:t+"/roles",data:e,params:r=void 0===r?{}:r})},Ge.prototype.browser=function(t){return this.request({method:"GET",url:"browser",params:t=void 0===t?{}:t})},Ge.prototype.getBans=function(t,e){return this.request({method:"GET",url:t+"/bans",params:e=void 0===e?{}:e})},Ge.prototype.banUser=function(t,e,r,n){return this.request({method:"POST",url:t+"/bans",data:{userId:e,reason:r,expires:n}})},Ge.prototype.unbanUser=function(t,e){return this.request({method:"DELETE",url:t+"/bans/"+e})},Ge);function Ge(t){return Je.call(this,t,"rooms")||this}var We,Ye=(c(Qe,We=Q),Qe.prototype.signup=function(t){return this.axios({method:"POST",url:"signup",data:t,public:!0})},Qe.prototype.getProfile=function(){return this.request({method:"GET",baseURL:this.baseURL,url:"/me"})},Qe.prototype.updateProfile=function(t){return this.request({method:"PATCH",baseURL:this.baseURL,url:"/me",data:t})},Qe.prototype.getNextMedia=function(){return this.request({method:"GET",baseURL:this.baseURL,url:"/me/next-media"})},Qe);function Qe(t){return We.call(this,t,"users")||this}var Xe,Ze=(c(tr,Xe=Q),tr);function tr(t){return Xe.call(this,t,"enum")||this}var er,rr=(c(nr,er=Q),nr.prototype.getByUser=function(t){return this.request({method:"GET",url:"user/"+t})},nr.prototype.pending=function(t){return this.request({method:"GET",url:"pending",params:t=void 0===t?{}:t})},nr.prototype.add=function(t){return this.request({method:"POST",url:t})},nr.prototype.accept=function(t){return this.request({method:"PATCH",url:t})},nr.prototype.reject=function(t){return this.request({method:"DELETE",url:t})},nr);function nr(t){return er.call(this,t,"friendships")||this}var or,ir=(c(sr,or=Q),sr);function sr(t){return or.call(this,t,"media")||this}var ar,ur=(c(cr,ar=Q),cr);function cr(t){return ar.call(this,t,"recovery")||this}var hr,pr=(c(lr,hr=Q),lr.prototype.getUsers=function(t,e){return this.request({method:"GET",url:t+"/users",params:e=void 0===e?{}:e})},lr.prototype.addUsers=function(t,e,r){return this.request({method:"POST",url:t+"/users",data:e,params:r=void 0===r?{}:r})},lr.prototype.removeUsers=function(t,e,r){return this.request({method:"DELETE",url:t+"/users",params:a(a({},r=void 0===r?{}:r),{users:e})})},lr);function lr(t){return hr.call(this,t,"roles")||this}var fr,dr=(c(yr,fr=k),yr.prototype.init=function(){},yr);function yr(t){var e=fr.call(this,t)||this;return e.playlist=new He(e),e.room=new Ke(e),e.user=new Ye(e),e.enum=new Ze(e),e.friendships=new rr(e),e.media=new ir(e),e.recovery=new ur(e),e.roles=new pr(e),t.api=e,t.require(x),e}function vr(r){return new s(function(t,e){r(t)&&e(null,t)})}Symbol("send");var mr,z=function(){},I=(c(br,mr=z),br.id="e",br);function br(t){var e=mr.call(this)||this;return e.message=t,e}var gr,A=(c(wr,gr=z),wr.id="server-ping",wr);function wr(t){var e=gr.call(this)||this;return e.time=t,e}var _r,F=(c(kr,_r=z),kr.id="ppa",kr);function kr(){return null!==_r&&_r.apply(this,arguments)||this}var Er,S=(c(Or,Er=z),Or.id="pp",Or);function Or(t){var e=Er.call(this)||this;return e.time=t,e}var jr,xr=(c(Tr,jr=z),Tr.id="pu",Tr);function Tr(t){var e=jr.call(this)||this;return e.state=t,e}var Ar,Sr=(c(Rr,Ar=z),Rr.id="qar",Rr);function Rr(t,e){var r=Ar.call(this)||this;return r.userId=t,r.addedUserId=e,r}var Cr,Pr=(c(Nr,Cr=z),Nr.id="qu",Nr);function Nr(t){var e=Cr.call(this)||this;return e.queue=t,e}var qr,Lr=(c(Ur,qr=z),Ur.id="us",Ur);function Ur(t){var e=qr.call(this)||this;return e.user=t,e}var Br,Ir=(c(Mr,Br=z),Mr.id="ul",Mr);function Mr(t){var e=Br.call(this)||this;return e.userId=t,e}var Dr,Fr=(c(zr,Dr=z),zr.id="chms",zr);function zr(t){var e=Dr.call(this)||this;return e.message=t,e}var $r,pt=(c(Hr,$r=z),Hr.id="chmsrm",Hr);function Hr(t){var e=$r.call(this)||this;return e.messageId=t,e}var Vr,Jr=(c(Kr,Vr=z),Kr.id="mau",Kr);function Kr(t,e){var r=Vr.call(this)||this;return r.type=t,r.state=e,r}var Gr,ht=(c(Wr,Gr=z),Wr.id="rru",Wr);function Wr(t,e){var r=Gr.call(this)||this;return r.usersRoles=e,r.roles=new Map(t),r}var Yr,Qr=(c(Xr,Yr=z),Xr.id="ru",Xr);function Xr(t){var e=Yr.call(this)||this;return e.room=t,e}var Zr,Q=(c(tn,Zr=z),tn.id="ust",tn);function tn(t,e){var r=Zr.call(this)||this;return r.userId=t,r.status=e,r}var en,z=(c(rn,en=z),rn.id="ufr",rn);function rn(t,e){var r=en.call(this)||this;return r.user=t,r.status=e,r}pt=Object.freeze({__proto__:null,ErrorResponse:I,PingMessage:A,PlaybackPauseResponse:F,PlaybackPlayResponse:S,PlaybackUpdateResponse:xr,QueueAddResponse:Sr,QueueUpdateResponse:Pr,UserSetResponse:Lr,UserLeaveResponse:Ir,ChatMessageResponse:Fr,ChatMessageRemoveResponse:pt,MediaActionsUpdateResponse:Jr,RoomRolesUpdateResponse:ht,RoomUpdateResponse:Qr,UserStatusResponse:Q,UserFriendshipResponse:z}),nn.prototype.toMessage=function(){return this.data},ht=nn;function nn(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];this.data=t}var on;c(sn,on=ht),sn.id="pf";function sn(){return null!==on&&on.apply(this,arguments)||this}var an;c(un,an=ht),un.id="ppa";function un(){return null!==an&&an.apply(this,arguments)||this}var cn;c(hn,cn=ht),hn.id="pp";function hn(t){return cn.call(this,t)||this}var pn,ln=(c(fn,pn=ht),fn.id="psk",fn);function fn(){return null!==pn&&pn.apply(this,arguments)||this}var dn;c(yn,dn=ht),yn.id="ps";function yn(){return dn.call(this,Date.now()+Number(P.getItem("timeOffset")))||this}var vn;c(mn,vn=ht),mn.id="qc";function mn(){return null!==vn&&vn.apply(this,arguments)||this}var bn,gn=(c(wn,bn=ht),wn.id="qj",wn);function w