skapi-js 0.2.5 → 1.0.0-alpha.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/skapi.js +1 -1
- package/dist/skapi.js.map +1 -1
- package/dist/skapi.module.js +1 -1
- package/dist/skapi.module.js.map +1 -1
- package/js/Types.d.ts +22 -4
- package/js/main/skapi.d.ts +199 -61
- package/js/main/skapi.js +115 -61
- package/js/methods/database.d.ts +13 -18
- package/js/methods/database.js +26 -30
- package/js/methods/request.d.ts +3 -7
- package/js/methods/request.js +37 -50
- package/js/methods/subscription.d.ts +2 -2
- package/js/methods/subscription.js +2 -2
- package/js/methods/user.d.ts +15 -14
- package/js/methods/user.js +46 -11
- package/package.json +5 -7
package/dist/skapi.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/*! For license information please see skapi.js.LICENSE.txt */
|
|
2
|
-
!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var n=t();for(var r in n)("object"==typeof exports?exports:e)[r]=n[r]}}(self,(()=>(()=>{var e={742:(e,t)=>{"use strict";t.byteLength=function(e){var t=a(e),n=t[0],r=t[1];return 3*(n+r)/4-r},t.toByteArray=function(e){var t,n,s=a(e),o=s[0],u=s[1],c=new i(function(e,t,n){return 3*(t+n)/4-n}(0,o,u)),l=0,h=u>0?o-4:o;for(n=0;n<h;n+=4)t=r[e.charCodeAt(n)]<<18|r[e.charCodeAt(n+1)]<<12|r[e.charCodeAt(n+2)]<<6|r[e.charCodeAt(n+3)],c[l++]=t>>16&255,c[l++]=t>>8&255,c[l++]=255&t;return 2===u&&(t=r[e.charCodeAt(n)]<<2|r[e.charCodeAt(n+1)]>>4,c[l++]=255&t),1===u&&(t=r[e.charCodeAt(n)]<<10|r[e.charCodeAt(n+1)]<<4|r[e.charCodeAt(n+2)]>>2,c[l++]=t>>8&255,c[l++]=255&t),c},t.fromByteArray=function(e){for(var t,r=e.length,i=r%3,s=[],o=16383,a=0,c=r-i;a<c;a+=o)s.push(u(e,a,a+o>c?c:a+o));return 1===i?(t=e[r-1],s.push(n[t>>2]+n[t<<4&63]+"==")):2===i&&(t=(e[r-2]<<8)+e[r-1],s.push(n[t>>10]+n[t>>4&63]+n[t<<2&63]+"=")),s.join("")};for(var n=[],r=[],i="undefined"!=typeof Uint8Array?Uint8Array:Array,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",o=0;o<64;++o)n[o]=s[o],r[s.charCodeAt(o)]=o;function a(e){var t=e.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var n=e.indexOf("=");return-1===n&&(n=t),[n,n===t?0:4-n%4]}function u(e,t,r){for(var i,s,o=[],a=t;a<r;a+=3)i=(e[a]<<16&16711680)+(e[a+1]<<8&65280)+(255&e[a+2]),o.push(n[(s=i)>>18&63]+n[s>>12&63]+n[s>>6&63]+n[63&s]);return o.join("")}r["-".charCodeAt(0)]=62,r["_".charCodeAt(0)]=63},764:(e,t,n)=>{"use strict";var r=n(742),i=n(645),s=n(826);function o(){return u.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function a(e,t){if(o()<t)throw new RangeError("Invalid typed array length");return u.TYPED_ARRAY_SUPPORT?(e=new Uint8Array(t)).__proto__=u.prototype:(null===e&&(e=new u(t)),e.length=t),e}function u(e,t,n){if(!(u.TYPED_ARRAY_SUPPORT||this instanceof u))return new u(e,t,n);if("number"==typeof e){if("string"==typeof t)throw new Error("If encoding is specified then the first argument must be a string");return h(this,e)}return c(this,e,t,n)}function c(e,t,n,r){if("number"==typeof t)throw new TypeError('"value" argument must not be a number');return"undefined"!=typeof ArrayBuffer&&t instanceof ArrayBuffer?function(e,t,n,r){if(t.byteLength,n<0||t.byteLength<n)throw new RangeError("'offset' is out of bounds");if(t.byteLength<n+(r||0))throw new RangeError("'length' is out of bounds");return t=void 0===n&&void 0===r?new Uint8Array(t):void 0===r?new Uint8Array(t,n):new Uint8Array(t,n,r),u.TYPED_ARRAY_SUPPORT?(e=t).__proto__=u.prototype:e=f(e,t),e}(e,t,n,r):"string"==typeof t?function(e,t,n){if("string"==typeof n&&""!==n||(n="utf8"),!u.isEncoding(n))throw new TypeError('"encoding" must be a valid string encoding');var r=0|p(t,n),i=(e=a(e,r)).write(t,n);return i!==r&&(e=e.slice(0,i)),e}(e,t,n):function(e,t){if(u.isBuffer(t)){var n=0|d(t.length);return 0===(e=a(e,n)).length||t.copy(e,0,0,n),e}if(t){if("undefined"!=typeof ArrayBuffer&&t.buffer instanceof ArrayBuffer||"length"in t)return"number"!=typeof t.length||(r=t.length)!=r?a(e,0):f(e,t);if("Buffer"===t.type&&s(t.data))return f(e,t.data)}var r;throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}(e,t)}function l(e){if("number"!=typeof e)throw new TypeError('"size" argument must be a number');if(e<0)throw new RangeError('"size" argument must not be negative')}function h(e,t){if(l(t),e=a(e,t<0?0:0|d(t)),!u.TYPED_ARRAY_SUPPORT)for(var n=0;n<t;++n)e[n]=0;return e}function f(e,t){var n=t.length<0?0:0|d(t.length);e=a(e,n);for(var r=0;r<n;r+=1)e[r]=255&t[r];return e}function d(e){if(e>=o())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+o().toString(16)+" bytes");return 0|e}function p(e,t){if(u.isBuffer(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var n=e.length;if(0===n)return 0;for(var r=!1;;)switch(t){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":case void 0:return B(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return $(e).length;default:if(r)return B(e).length;t=(""+t).toLowerCase(),r=!0}}function g(e,t,n){var r=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===n||n>this.length)&&(n=this.length),n<=0)return"";if((n>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return C(this,t,n);case"utf8":case"utf-8":return T(this,t,n);case"ascii":return D(this,t,n);case"latin1":case"binary":return U(this,t,n);case"base64":return I(this,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return P(this,t,n);default:if(r)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),r=!0}}function y(e,t,n){var r=e[t];e[t]=e[n],e[n]=r}function w(e,t,n,r,i){if(0===e.length)return-1;if("string"==typeof n?(r=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),n=+n,isNaN(n)&&(n=i?0:e.length-1),n<0&&(n=e.length+n),n>=e.length){if(i)return-1;n=e.length-1}else if(n<0){if(!i)return-1;n=0}if("string"==typeof t&&(t=u.from(t,r)),u.isBuffer(t))return 0===t.length?-1:m(e,t,n,r,i);if("number"==typeof t)return t&=255,u.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,n):Uint8Array.prototype.lastIndexOf.call(e,t,n):m(e,[t],n,r,i);throw new TypeError("val must be string, number or Buffer")}function m(e,t,n,r,i){var s,o=1,a=e.length,u=t.length;if(void 0!==r&&("ucs2"===(r=String(r).toLowerCase())||"ucs-2"===r||"utf16le"===r||"utf-16le"===r)){if(e.length<2||t.length<2)return-1;o=2,a/=2,u/=2,n/=2}function c(e,t){return 1===o?e[t]:e.readUInt16BE(t*o)}if(i){var l=-1;for(s=n;s<a;s++)if(c(e,s)===c(t,-1===l?0:s-l)){if(-1===l&&(l=s),s-l+1===u)return l*o}else-1!==l&&(s-=s-l),l=-1}else for(n+u>a&&(n=a-u),s=n;s>=0;s--){for(var h=!0,f=0;f<u;f++)if(c(e,s+f)!==c(t,f)){h=!1;break}if(h)return s}return-1}function b(e,t,n,r){n=Number(n)||0;var i=e.length-n;r?(r=Number(r))>i&&(r=i):r=i;var s=t.length;if(s%2!=0)throw new TypeError("Invalid hex string");r>s/2&&(r=s/2);for(var o=0;o<r;++o){var a=parseInt(t.substr(2*o,2),16);if(isNaN(a))return o;e[n+o]=a}return o}function _(e,t,n,r){return q(B(t,e.length-n),e,n,r)}function A(e,t,n,r){return q(function(e){for(var t=[],n=0;n<e.length;++n)t.push(255&e.charCodeAt(n));return t}(t),e,n,r)}function v(e,t,n,r){return A(e,t,n,r)}function E(e,t,n,r){return q($(t),e,n,r)}function S(e,t,n,r){return q(function(e,t){for(var n,r,i,s=[],o=0;o<e.length&&!((t-=2)<0);++o)r=(n=e.charCodeAt(o))>>8,i=n%256,s.push(i),s.push(r);return s}(t,e.length-n),e,n,r)}function I(e,t,n){return 0===t&&n===e.length?r.fromByteArray(e):r.fromByteArray(e.slice(t,n))}function T(e,t,n){n=Math.min(e.length,n);for(var r=[],i=t;i<n;){var s,o,a,u,c=e[i],l=null,h=c>239?4:c>223?3:c>191?2:1;if(i+h<=n)switch(h){case 1:c<128&&(l=c);break;case 2:128==(192&(s=e[i+1]))&&(u=(31&c)<<6|63&s)>127&&(l=u);break;case 3:s=e[i+1],o=e[i+2],128==(192&s)&&128==(192&o)&&(u=(15&c)<<12|(63&s)<<6|63&o)>2047&&(u<55296||u>57343)&&(l=u);break;case 4:s=e[i+1],o=e[i+2],a=e[i+3],128==(192&s)&&128==(192&o)&&128==(192&a)&&(u=(15&c)<<18|(63&s)<<12|(63&o)<<6|63&a)>65535&&u<1114112&&(l=u)}null===l?(l=65533,h=1):l>65535&&(l-=65536,r.push(l>>>10&1023|55296),l=56320|1023&l),r.push(l),i+=h}return function(e){var t=e.length;if(t<=R)return String.fromCharCode.apply(String,e);for(var n="",r=0;r<t;)n+=String.fromCharCode.apply(String,e.slice(r,r+=R));return n}(r)}t.lW=u,t.h2=50,u.TYPED_ARRAY_SUPPORT=void 0!==n.g.TYPED_ARRAY_SUPPORT?n.g.TYPED_ARRAY_SUPPORT:function(){try{var e=new Uint8Array(1);return e.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===e.foo()&&"function"==typeof e.subarray&&0===e.subarray(1,1).byteLength}catch(e){return!1}}(),o(),u.poolSize=8192,u._augment=function(e){return e.__proto__=u.prototype,e},u.from=function(e,t,n){return c(null,e,t,n)},u.TYPED_ARRAY_SUPPORT&&(u.prototype.__proto__=Uint8Array.prototype,u.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&u[Symbol.species]===u&&Object.defineProperty(u,Symbol.species,{value:null,configurable:!0})),u.alloc=function(e,t,n){return function(e,t,n,r){return l(t),t<=0?a(e,t):void 0!==n?"string"==typeof r?a(e,t).fill(n,r):a(e,t).fill(n):a(e,t)}(null,e,t,n)},u.allocUnsafe=function(e){return h(null,e)},u.allocUnsafeSlow=function(e){return h(null,e)},u.isBuffer=function(e){return!(null==e||!e._isBuffer)},u.compare=function(e,t){if(!u.isBuffer(e)||!u.isBuffer(t))throw new TypeError("Arguments must be Buffers");if(e===t)return 0;for(var n=e.length,r=t.length,i=0,s=Math.min(n,r);i<s;++i)if(e[i]!==t[i]){n=e[i],r=t[i];break}return n<r?-1:r<n?1:0},u.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},u.concat=function(e,t){if(!s(e))throw new TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return u.alloc(0);var n;if(void 0===t)for(t=0,n=0;n<e.length;++n)t+=e[n].length;var r=u.allocUnsafe(t),i=0;for(n=0;n<e.length;++n){var o=e[n];if(!u.isBuffer(o))throw new TypeError('"list" argument must be an Array of Buffers');o.copy(r,i),i+=o.length}return r},u.byteLength=p,u.prototype._isBuffer=!0,u.prototype.swap16=function(){var e=this.length;if(e%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var t=0;t<e;t+=2)y(this,t,t+1);return this},u.prototype.swap32=function(){var e=this.length;if(e%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var t=0;t<e;t+=4)y(this,t,t+3),y(this,t+1,t+2);return this},u.prototype.swap64=function(){var e=this.length;if(e%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var t=0;t<e;t+=8)y(this,t,t+7),y(this,t+1,t+6),y(this,t+2,t+5),y(this,t+3,t+4);return this},u.prototype.toString=function(){var e=0|this.length;return 0===e?"":0===arguments.length?T(this,0,e):g.apply(this,arguments)},u.prototype.equals=function(e){if(!u.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e||0===u.compare(this,e)},u.prototype.inspect=function(){var e="",n=t.h2;return this.length>0&&(e=this.toString("hex",0,n).match(/.{2}/g).join(" "),this.length>n&&(e+=" ... ")),"<Buffer "+e+">"},u.prototype.compare=function(e,t,n,r,i){if(!u.isBuffer(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===n&&(n=e?e.length:0),void 0===r&&(r=0),void 0===i&&(i=this.length),t<0||n>e.length||r<0||i>this.length)throw new RangeError("out of range index");if(r>=i&&t>=n)return 0;if(r>=i)return-1;if(t>=n)return 1;if(this===e)return 0;for(var s=(i>>>=0)-(r>>>=0),o=(n>>>=0)-(t>>>=0),a=Math.min(s,o),c=this.slice(r,i),l=e.slice(t,n),h=0;h<a;++h)if(c[h]!==l[h]){s=c[h],o=l[h];break}return s<o?-1:o<s?1:0},u.prototype.includes=function(e,t,n){return-1!==this.indexOf(e,t,n)},u.prototype.indexOf=function(e,t,n){return w(this,e,t,n,!0)},u.prototype.lastIndexOf=function(e,t,n){return w(this,e,t,n,!1)},u.prototype.write=function(e,t,n,r){if(void 0===t)r="utf8",n=this.length,t=0;else if(void 0===n&&"string"==typeof t)r=t,n=this.length,t=0;else{if(!isFinite(t))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");t|=0,isFinite(n)?(n|=0,void 0===r&&(r="utf8")):(r=n,n=void 0)}var i=this.length-t;if((void 0===n||n>i)&&(n=i),e.length>0&&(n<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");r||(r="utf8");for(var s=!1;;)switch(r){case"hex":return b(this,e,t,n);case"utf8":case"utf-8":return _(this,e,t,n);case"ascii":return A(this,e,t,n);case"latin1":case"binary":return v(this,e,t,n);case"base64":return E(this,e,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return S(this,e,t,n);default:if(s)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),s=!0}},u.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var R=4096;function D(e,t,n){var r="";n=Math.min(e.length,n);for(var i=t;i<n;++i)r+=String.fromCharCode(127&e[i]);return r}function U(e,t,n){var r="";n=Math.min(e.length,n);for(var i=t;i<n;++i)r+=String.fromCharCode(e[i]);return r}function C(e,t,n){var r,i=e.length;(!t||t<0)&&(t=0),(!n||n<0||n>i)&&(n=i);for(var s="",o=t;o<n;++o)s+=(r=e[o])<16?"0"+r.toString(16):r.toString(16);return s}function P(e,t,n){for(var r=e.slice(t,n),i="",s=0;s<r.length;s+=2)i+=String.fromCharCode(r[s]+256*r[s+1]);return i}function N(e,t,n){if(e%1!=0||e<0)throw new RangeError("offset is not uint");if(e+t>n)throw new RangeError("Trying to access beyond buffer length")}function k(e,t,n,r,i,s){if(!u.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||t<s)throw new RangeError('"value" argument is out of bounds');if(n+r>e.length)throw new RangeError("Index out of range")}function O(e,t,n,r){t<0&&(t=65535+t+1);for(var i=0,s=Math.min(e.length-n,2);i<s;++i)e[n+i]=(t&255<<8*(r?i:1-i))>>>8*(r?i:1-i)}function M(e,t,n,r){t<0&&(t=4294967295+t+1);for(var i=0,s=Math.min(e.length-n,4);i<s;++i)e[n+i]=t>>>8*(r?i:3-i)&255}function F(e,t,n,r,i,s){if(n+r>e.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function V(e,t,n,r,s){return s||F(e,0,n,4),i.write(e,t,n,r,23,4),n+4}function x(e,t,n,r,s){return s||F(e,0,n,8),i.write(e,t,n,r,52,8),n+8}u.prototype.slice=function(e,t){var n,r=this.length;if((e=~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),(t=void 0===t?r:~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),t<e&&(t=e),u.TYPED_ARRAY_SUPPORT)(n=this.subarray(e,t)).__proto__=u.prototype;else{var i=t-e;n=new u(i,void 0);for(var s=0;s<i;++s)n[s]=this[s+e]}return n},u.prototype.readUIntLE=function(e,t,n){e|=0,t|=0,n||N(e,t,this.length);for(var r=this[e],i=1,s=0;++s<t&&(i*=256);)r+=this[e+s]*i;return r},u.prototype.readUIntBE=function(e,t,n){e|=0,t|=0,n||N(e,t,this.length);for(var r=this[e+--t],i=1;t>0&&(i*=256);)r+=this[e+--t]*i;return r},u.prototype.readUInt8=function(e,t){return t||N(e,1,this.length),this[e]},u.prototype.readUInt16LE=function(e,t){return t||N(e,2,this.length),this[e]|this[e+1]<<8},u.prototype.readUInt16BE=function(e,t){return t||N(e,2,this.length),this[e]<<8|this[e+1]},u.prototype.readUInt32LE=function(e,t){return t||N(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},u.prototype.readUInt32BE=function(e,t){return t||N(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},u.prototype.readIntLE=function(e,t,n){e|=0,t|=0,n||N(e,t,this.length);for(var r=this[e],i=1,s=0;++s<t&&(i*=256);)r+=this[e+s]*i;return r>=(i*=128)&&(r-=Math.pow(2,8*t)),r},u.prototype.readIntBE=function(e,t,n){e|=0,t|=0,n||N(e,t,this.length);for(var r=t,i=1,s=this[e+--r];r>0&&(i*=256);)s+=this[e+--r]*i;return s>=(i*=128)&&(s-=Math.pow(2,8*t)),s},u.prototype.readInt8=function(e,t){return t||N(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},u.prototype.readInt16LE=function(e,t){t||N(e,2,this.length);var n=this[e]|this[e+1]<<8;return 32768&n?4294901760|n:n},u.prototype.readInt16BE=function(e,t){t||N(e,2,this.length);var n=this[e+1]|this[e]<<8;return 32768&n?4294901760|n:n},u.prototype.readInt32LE=function(e,t){return t||N(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},u.prototype.readInt32BE=function(e,t){return t||N(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},u.prototype.readFloatLE=function(e,t){return t||N(e,4,this.length),i.read(this,e,!0,23,4)},u.prototype.readFloatBE=function(e,t){return t||N(e,4,this.length),i.read(this,e,!1,23,4)},u.prototype.readDoubleLE=function(e,t){return t||N(e,8,this.length),i.read(this,e,!0,52,8)},u.prototype.readDoubleBE=function(e,t){return t||N(e,8,this.length),i.read(this,e,!1,52,8)},u.prototype.writeUIntLE=function(e,t,n,r){e=+e,t|=0,n|=0,r||k(this,e,t,n,Math.pow(2,8*n)-1,0);var i=1,s=0;for(this[t]=255&e;++s<n&&(i*=256);)this[t+s]=e/i&255;return t+n},u.prototype.writeUIntBE=function(e,t,n,r){e=+e,t|=0,n|=0,r||k(this,e,t,n,Math.pow(2,8*n)-1,0);var i=n-1,s=1;for(this[t+i]=255&e;--i>=0&&(s*=256);)this[t+i]=e/s&255;return t+n},u.prototype.writeUInt8=function(e,t,n){return e=+e,t|=0,n||k(this,e,t,1,255,0),u.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},u.prototype.writeUInt16LE=function(e,t,n){return e=+e,t|=0,n||k(this,e,t,2,65535,0),u.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):O(this,e,t,!0),t+2},u.prototype.writeUInt16BE=function(e,t,n){return e=+e,t|=0,n||k(this,e,t,2,65535,0),u.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):O(this,e,t,!1),t+2},u.prototype.writeUInt32LE=function(e,t,n){return e=+e,t|=0,n||k(this,e,t,4,4294967295,0),u.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):M(this,e,t,!0),t+4},u.prototype.writeUInt32BE=function(e,t,n){return e=+e,t|=0,n||k(this,e,t,4,4294967295,0),u.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):M(this,e,t,!1),t+4},u.prototype.writeIntLE=function(e,t,n,r){if(e=+e,t|=0,!r){var i=Math.pow(2,8*n-1);k(this,e,t,n,i-1,-i)}var s=0,o=1,a=0;for(this[t]=255&e;++s<n&&(o*=256);)e<0&&0===a&&0!==this[t+s-1]&&(a=1),this[t+s]=(e/o>>0)-a&255;return t+n},u.prototype.writeIntBE=function(e,t,n,r){if(e=+e,t|=0,!r){var i=Math.pow(2,8*n-1);k(this,e,t,n,i-1,-i)}var s=n-1,o=1,a=0;for(this[t+s]=255&e;--s>=0&&(o*=256);)e<0&&0===a&&0!==this[t+s+1]&&(a=1),this[t+s]=(e/o>>0)-a&255;return t+n},u.prototype.writeInt8=function(e,t,n){return e=+e,t|=0,n||k(this,e,t,1,127,-128),u.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},u.prototype.writeInt16LE=function(e,t,n){return e=+e,t|=0,n||k(this,e,t,2,32767,-32768),u.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):O(this,e,t,!0),t+2},u.prototype.writeInt16BE=function(e,t,n){return e=+e,t|=0,n||k(this,e,t,2,32767,-32768),u.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):O(this,e,t,!1),t+2},u.prototype.writeInt32LE=function(e,t,n){return e=+e,t|=0,n||k(this,e,t,4,2147483647,-2147483648),u.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):M(this,e,t,!0),t+4},u.prototype.writeInt32BE=function(e,t,n){return e=+e,t|=0,n||k(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),u.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):M(this,e,t,!1),t+4},u.prototype.writeFloatLE=function(e,t,n){return V(this,e,t,!0,n)},u.prototype.writeFloatBE=function(e,t,n){return V(this,e,t,!1,n)},u.prototype.writeDoubleLE=function(e,t,n){return x(this,e,t,!0,n)},u.prototype.writeDoubleBE=function(e,t,n){return x(this,e,t,!1,n)},u.prototype.copy=function(e,t,n,r){if(n||(n=0),r||0===r||(r=this.length),t>=e.length&&(t=e.length),t||(t=0),r>0&&r<n&&(r=n),r===n)return 0;if(0===e.length||0===this.length)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("sourceStart out of bounds");if(r<0)throw new RangeError("sourceEnd out of bounds");r>this.length&&(r=this.length),e.length-t<r-n&&(r=e.length-t+n);var i,s=r-n;if(this===e&&n<t&&t<r)for(i=s-1;i>=0;--i)e[i+t]=this[i+n];else if(s<1e3||!u.TYPED_ARRAY_SUPPORT)for(i=0;i<s;++i)e[i+t]=this[i+n];else Uint8Array.prototype.set.call(e,this.subarray(n,n+s),t);return s},u.prototype.fill=function(e,t,n,r){if("string"==typeof e){if("string"==typeof t?(r=t,t=0,n=this.length):"string"==typeof n&&(r=n,n=this.length),1===e.length){var i=e.charCodeAt(0);i<256&&(e=i)}if(void 0!==r&&"string"!=typeof r)throw new TypeError("encoding must be a string");if("string"==typeof r&&!u.isEncoding(r))throw new TypeError("Unknown encoding: "+r)}else"number"==typeof e&&(e&=255);if(t<0||this.length<t||this.length<n)throw new RangeError("Out of range index");if(n<=t)return this;var s;if(t>>>=0,n=void 0===n?this.length:n>>>0,e||(e=0),"number"==typeof e)for(s=t;s<n;++s)this[s]=e;else{var o=u.isBuffer(e)?e:B(new u(e,r).toString()),a=o.length;for(s=0;s<n-t;++s)this[s+t]=o[s%a]}return this};var L=/[^+\/0-9A-Za-z-_]/g;function B(e,t){var n;t=t||1/0;for(var r=e.length,i=null,s=[],o=0;o<r;++o){if((n=e.charCodeAt(o))>55295&&n<57344){if(!i){if(n>56319){(t-=3)>-1&&s.push(239,191,189);continue}if(o+1===r){(t-=3)>-1&&s.push(239,191,189);continue}i=n;continue}if(n<56320){(t-=3)>-1&&s.push(239,191,189),i=n;continue}n=65536+(i-55296<<10|n-56320)}else i&&(t-=3)>-1&&s.push(239,191,189);if(i=null,n<128){if((t-=1)<0)break;s.push(n)}else if(n<2048){if((t-=2)<0)break;s.push(n>>6|192,63&n|128)}else if(n<65536){if((t-=3)<0)break;s.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(n<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;s.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return s}function $(e){return r.toByteArray(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(L,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function q(e,t,n,r){for(var i=0;i<r&&!(i+n>=t.length||i>=e.length);++i)t[i+n]=e[i];return i}},249:function(e,t,n){var r;e.exports=(r=r||function(e,t){var r;if("undefined"!=typeof window&&window.crypto&&(r=window.crypto),"undefined"!=typeof self&&self.crypto&&(r=self.crypto),"undefined"!=typeof globalThis&&globalThis.crypto&&(r=globalThis.crypto),!r&&"undefined"!=typeof window&&window.msCrypto&&(r=window.msCrypto),!r&&void 0!==n.g&&n.g.crypto&&(r=n.g.crypto),!r)try{r=n(480)}catch(e){}var i=function(){if(r){if("function"==typeof r.getRandomValues)try{return r.getRandomValues(new Uint32Array(1))[0]}catch(e){}if("function"==typeof r.randomBytes)try{return r.randomBytes(4).readInt32LE()}catch(e){}}throw new Error("Native crypto module could not be used to get secure random number.")},s=Object.create||function(){function e(){}return function(t){var n;return e.prototype=t,n=new e,e.prototype=null,n}}(),o={},a=o.lib={},u=a.Base={extend:function(e){var t=s(this);return e&&t.mixIn(e),t.hasOwnProperty("init")&&this.init!==t.init||(t.init=function(){t.$super.init.apply(this,arguments)}),t.init.prototype=t,t.$super=this,t},create:function(){var e=this.extend();return e.init.apply(e,arguments),e},init:function(){},mixIn:function(e){for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t]);e.hasOwnProperty("toString")&&(this.toString=e.toString)},clone:function(){return this.init.prototype.extend(this)}},c=a.WordArray=u.extend({init:function(e,t){e=this.words=e||[],this.sigBytes=null!=t?t:4*e.length},toString:function(e){return(e||h).stringify(this)},concat:function(e){var t=this.words,n=e.words,r=this.sigBytes,i=e.sigBytes;if(this.clamp(),r%4)for(var s=0;s<i;s++){var o=n[s>>>2]>>>24-s%4*8&255;t[r+s>>>2]|=o<<24-(r+s)%4*8}else for(var a=0;a<i;a+=4)t[r+a>>>2]=n[a>>>2];return this.sigBytes+=i,this},clamp:function(){var t=this.words,n=this.sigBytes;t[n>>>2]&=4294967295<<32-n%4*8,t.length=e.ceil(n/4)},clone:function(){var e=u.clone.call(this);return e.words=this.words.slice(0),e},random:function(e){for(var t=[],n=0;n<e;n+=4)t.push(i());return new c.init(t,e)}}),l=o.enc={},h=l.Hex={stringify:function(e){for(var t=e.words,n=e.sigBytes,r=[],i=0;i<n;i++){var s=t[i>>>2]>>>24-i%4*8&255;r.push((s>>>4).toString(16)),r.push((15&s).toString(16))}return r.join("")},parse:function(e){for(var t=e.length,n=[],r=0;r<t;r+=2)n[r>>>3]|=parseInt(e.substr(r,2),16)<<24-r%8*4;return new c.init(n,t/2)}},f=l.Latin1={stringify:function(e){for(var t=e.words,n=e.sigBytes,r=[],i=0;i<n;i++){var s=t[i>>>2]>>>24-i%4*8&255;r.push(String.fromCharCode(s))}return r.join("")},parse:function(e){for(var t=e.length,n=[],r=0;r<t;r++)n[r>>>2]|=(255&e.charCodeAt(r))<<24-r%4*8;return new c.init(n,t)}},d=l.Utf8={stringify:function(e){try{return decodeURIComponent(escape(f.stringify(e)))}catch(e){throw new Error("Malformed UTF-8 data")}},parse:function(e){return f.parse(unescape(encodeURIComponent(e)))}},p=a.BufferedBlockAlgorithm=u.extend({reset:function(){this._data=new c.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=d.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(t){var n,r=this._data,i=r.words,s=r.sigBytes,o=this.blockSize,a=s/(4*o),u=(a=t?e.ceil(a):e.max((0|a)-this._minBufferSize,0))*o,l=e.min(4*u,s);if(u){for(var h=0;h<u;h+=o)this._doProcessBlock(i,h);n=i.splice(0,u),r.sigBytes-=l}return new c.init(n,l)},clone:function(){var e=u.clone.call(this);return e._data=this._data.clone(),e},_minBufferSize:0}),g=(a.Hasher=p.extend({cfg:u.extend(),init:function(e){this.cfg=this.cfg.extend(e),this.reset()},reset:function(){p.reset.call(this),this._doReset()},update:function(e){return this._append(e),this._process(),this},finalize:function(e){return e&&this._append(e),this._doFinalize()},blockSize:16,_createHelper:function(e){return function(t,n){return new e.init(n).finalize(t)}},_createHmacHelper:function(e){return function(t,n){return new g.HMAC.init(e,n).finalize(t)}}}),o.algo={});return o}(Math),r)},269:function(e,t,n){var r,i,s;e.exports=(r=n(249),s=(i=r).lib.WordArray,i.enc.Base64={stringify:function(e){var t=e.words,n=e.sigBytes,r=this._map;e.clamp();for(var i=[],s=0;s<n;s+=3)for(var o=(t[s>>>2]>>>24-s%4*8&255)<<16|(t[s+1>>>2]>>>24-(s+1)%4*8&255)<<8|t[s+2>>>2]>>>24-(s+2)%4*8&255,a=0;a<4&&s+.75*a<n;a++)i.push(r.charAt(o>>>6*(3-a)&63));var u=r.charAt(64);if(u)for(;i.length%4;)i.push(u);return i.join("")},parse:function(e){var t=e.length,n=this._map,r=this._reverseMap;if(!r){r=this._reverseMap=[];for(var i=0;i<n.length;i++)r[n.charCodeAt(i)]=i}var o=n.charAt(64);if(o){var a=e.indexOf(o);-1!==a&&(t=a)}return function(e,t,n){for(var r=[],i=0,o=0;o<t;o++)if(o%4){var a=n[e.charCodeAt(o-1)]<<o%4*2|n[e.charCodeAt(o)]>>>6-o%4*2;r[i>>>2]|=a<<24-i%4*8,i++}return s.create(r,i)}(e,t,r)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="},r.enc.Base64)},10:function(e,t,n){var r;e.exports=(r=n(249),n(153),n(824),r.HmacSHA256)},824:function(e,t,n){var r,i,s;e.exports=(i=(r=n(249)).lib.Base,s=r.enc.Utf8,void(r.algo.HMAC=i.extend({init:function(e,t){e=this._hasher=new e.init,"string"==typeof t&&(t=s.parse(t));var n=e.blockSize,r=4*n;t.sigBytes>r&&(t=e.finalize(t)),t.clamp();for(var i=this._oKey=t.clone(),o=this._iKey=t.clone(),a=i.words,u=o.words,c=0;c<n;c++)a[c]^=1549556828,u[c]^=909522486;i.sigBytes=o.sigBytes=r,this.reset()},reset:function(){var e=this._hasher;e.reset(),e.update(this._iKey)},update:function(e){return this._hasher.update(e),this},finalize:function(e){var t=this._hasher,n=t.finalize(e);return t.reset(),t.finalize(this._oKey.clone().concat(n))}})))},433:function(e,t,n){var r;e.exports=(r=n(249),function(){if("function"==typeof ArrayBuffer){var e=r.lib.WordArray,t=e.init,n=e.init=function(e){if(e instanceof ArrayBuffer&&(e=new Uint8Array(e)),(e instanceof Int8Array||"undefined"!=typeof Uint8ClampedArray&&e instanceof Uint8ClampedArray||e instanceof Int16Array||e instanceof Uint16Array||e instanceof Int32Array||e instanceof Uint32Array||e instanceof Float32Array||e instanceof Float64Array)&&(e=new Uint8Array(e.buffer,e.byteOffset,e.byteLength)),e instanceof Uint8Array){for(var n=e.byteLength,r=[],i=0;i<n;i++)r[i>>>2]|=e[i]<<24-i%4*8;t.call(this,r,n)}else t.apply(this,arguments)};n.prototype=e}}(),r.lib.WordArray)},153:function(e,t,n){var r;e.exports=(r=n(249),function(e){var t=r,n=t.lib,i=n.WordArray,s=n.Hasher,o=t.algo,a=[],u=[];!function(){function t(t){for(var n=e.sqrt(t),r=2;r<=n;r++)if(!(t%r))return!1;return!0}function n(e){return 4294967296*(e-(0|e))|0}for(var r=2,i=0;i<64;)t(r)&&(i<8&&(a[i]=n(e.pow(r,.5))),u[i]=n(e.pow(r,1/3)),i++),r++}();var c=[],l=o.SHA256=s.extend({_doReset:function(){this._hash=new i.init(a.slice(0))},_doProcessBlock:function(e,t){for(var n=this._hash.words,r=n[0],i=n[1],s=n[2],o=n[3],a=n[4],l=n[5],h=n[6],f=n[7],d=0;d<64;d++){if(d<16)c[d]=0|e[t+d];else{var p=c[d-15],g=(p<<25|p>>>7)^(p<<14|p>>>18)^p>>>3,y=c[d-2],w=(y<<15|y>>>17)^(y<<13|y>>>19)^y>>>10;c[d]=g+c[d-7]+w+c[d-16]}var m=r&i^r&s^i&s,b=(r<<30|r>>>2)^(r<<19|r>>>13)^(r<<10|r>>>22),_=f+((a<<26|a>>>6)^(a<<21|a>>>11)^(a<<7|a>>>25))+(a&l^~a&h)+u[d]+c[d];f=h,h=l,l=a,a=o+_|0,o=s,s=i,i=r,r=_+(b+m)|0}n[0]=n[0]+r|0,n[1]=n[1]+i|0,n[2]=n[2]+s|0,n[3]=n[3]+o|0,n[4]=n[4]+a|0,n[5]=n[5]+l|0,n[6]=n[6]+h|0,n[7]=n[7]+f|0},_doFinalize:function(){var t=this._data,n=t.words,r=8*this._nDataBytes,i=8*t.sigBytes;return n[i>>>5]|=128<<24-i%32,n[14+(i+64>>>9<<4)]=e.floor(r/4294967296),n[15+(i+64>>>9<<4)]=r,t.sigBytes=4*n.length,this._process(),this._hash},clone:function(){var e=s.clone.call(this);return e._hash=this._hash.clone(),e}});t.SHA256=s._createHelper(l),t.HmacSHA256=s._createHmacHelper(l)}(Math),r.SHA256)},645:(e,t)=>{t.read=function(e,t,n,r,i){var s,o,a=8*i-r-1,u=(1<<a)-1,c=u>>1,l=-7,h=n?i-1:0,f=n?-1:1,d=e[t+h];for(h+=f,s=d&(1<<-l)-1,d>>=-l,l+=a;l>0;s=256*s+e[t+h],h+=f,l-=8);for(o=s&(1<<-l)-1,s>>=-l,l+=r;l>0;o=256*o+e[t+h],h+=f,l-=8);if(0===s)s=1-c;else{if(s===u)return o?NaN:1/0*(d?-1:1);o+=Math.pow(2,r),s-=c}return(d?-1:1)*o*Math.pow(2,s-r)},t.write=function(e,t,n,r,i,s){var o,a,u,c=8*s-i-1,l=(1<<c)-1,h=l>>1,f=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=r?0:s-1,p=r?1:-1,g=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,o=l):(o=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-o))<1&&(o--,u*=2),(t+=o+h>=1?f/u:f*Math.pow(2,1-h))*u>=2&&(o++,u/=2),o+h>=l?(a=0,o=l):o+h>=1?(a=(t*u-1)*Math.pow(2,i),o+=h):(a=t*Math.pow(2,h-1)*Math.pow(2,i),o=0));i>=8;e[n+d]=255&a,d+=p,a/=256,i-=8);for(o=o<<i|a,c+=i;c>0;e[n+d]=255&o,d+=p,o/=256,c-=8);e[n+d-p]|=128*g}},826:e=>{var t={}.toString;e.exports=Array.isArray||function(e){return"[object Array]"==t.call(e)}},204:(e,t,n)=>{e.exports=self.fetch||(self.fetch=n(869).default||n(869))},808:(e,t,n)=>{var r,i,s;void 0===(i="function"==typeof(r=s=function(){function e(){for(var e=0,t={};e<arguments.length;e++){var n=arguments[e];for(var r in n)t[r]=n[r]}return t}function t(e){return e.replace(/(%[0-9A-Z]{2})+/g,decodeURIComponent)}return function n(r){function i(){}function s(t,n,s){if("undefined"!=typeof document){"number"==typeof(s=e({path:"/"},i.defaults,s)).expires&&(s.expires=new Date(1*new Date+864e5*s.expires)),s.expires=s.expires?s.expires.toUTCString():"";try{var o=JSON.stringify(n);/^[\{\[]/.test(o)&&(n=o)}catch(e){}n=r.write?r.write(n,t):encodeURIComponent(String(n)).replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g,decodeURIComponent),t=encodeURIComponent(String(t)).replace(/%(23|24|26|2B|5E|60|7C)/g,decodeURIComponent).replace(/[\(\)]/g,escape);var a="";for(var u in s)s[u]&&(a+="; "+u,!0!==s[u]&&(a+="="+s[u].split(";")[0]));return document.cookie=t+"="+n+a}}function o(e,n){if("undefined"!=typeof document){for(var i={},s=document.cookie?document.cookie.split("; "):[],o=0;o<s.length;o++){var a=s[o].split("="),u=a.slice(1).join("=");n||'"'!==u.charAt(0)||(u=u.slice(1,-1));try{var c=t(a[0]);if(u=(r.read||r)(u,c)||t(u),n)try{u=JSON.parse(u)}catch(e){}if(i[c]=u,e===c)break}catch(e){}}return e?i[e]:i}}return i.set=s,i.get=function(e){return o(e,!1)},i.getJSON=function(e){return o(e,!0)},i.remove=function(t,n){s(t,"",e(n,{expires:-1}))},i.defaults={},i.withConverter=n,i}((function(){}))})?r.call(t,n,t,e):r)||(e.exports=i),e.exports=s()},869:(e,t,n)=>{"use strict";function r(e,t){return t=t||{},new Promise((function(n,r){var i=new XMLHttpRequest,s=[],o=[],a={},u=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(i.responseText).then(JSON.parse)},blob:function(){return Promise.resolve(new Blob([i.response]))},clone:u,headers:{keys:function(){return s},entries:function(){return o},get:function(e){return a[e.toLowerCase()]},has:function(e){return e.toLowerCase()in a}}}};for(var c in i.open(t.method||"get",e,!0),i.onload=function(){i.getAllResponseHeaders().replace(/^(.*?):[^\S\n]*([\s\S]*?)$/gm,(function(e,t,n){s.push(t=t.toLowerCase()),o.push([t,n]),a[t]=a[t]?a[t]+","+n:n})),n(u())},i.onerror=r,i.withCredentials="include"==t.credentials,t.headers)i.setRequestHeader(c,t.headers[c]);i.send(t.body||null)}))}n.r(t),n.d(t,{default:()=>r})},296:()=>{},480:()=>{}},t={};function n(r){var i=t[r];if(void 0!==i)return i.exports;var s=t[r]={exports:{}};return e[r].call(s.exports,s,s.exports,n),s.exports}n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var r={};return(()=>{"use strict";n.r(r),n.d(r,{Skapi:()=>vt,SkapiError:()=>e});class e extends Error{constructor(e,t){Array.isArray(e)&&e.length<=2?(super(e[1]||"Something went wrong."),this.name="SKAPI",this.code=e[0]||"ERROR",t&&(t.code&&(this.code=t.code),t.cause&&(this.cause=t.cause))):"string"==typeof e?(super(e||"Something went wrong."),this.name="SKAPI",this.code="ERROR",t&&(t.code&&(this.code=t.code),t.cause&&(this.cause=t.cause))):e instanceof Error&&(super(e.message||"Something went wrong."),this.cause=e,this.name=e.name,e.hasOwnProperty("code")&&(this.code=e.code))}}class t{static hash(e){"string"!=typeof e&&(console.warn("coercing non-string value to empty string"),e="");const n=t.sb(e);let r,i,s,o,a=1732584193,u=-271733879,c=-1732584194,l=271733878;for(let e=0;e<n.length;e+=16)r=a,i=u,s=c,o=l,a=t.ff(a,u,c,l,n[e],7,-680876936),l=t.ff(l,a,u,c,n[e+1],12,-389564586),c=t.ff(c,l,a,u,n[e+2],17,606105819),u=t.ff(u,c,l,a,n[e+3],22,-1044525330),a=t.ff(a,u,c,l,n[e+4],7,-176418897),l=t.ff(l,a,u,c,n[e+5],12,1200080426),c=t.ff(c,l,a,u,n[e+6],17,-1473231341),u=t.ff(u,c,l,a,n[e+7],22,-45705983),a=t.ff(a,u,c,l,n[e+8],7,1770035416),l=t.ff(l,a,u,c,n[e+9],12,-1958414417),c=t.ff(c,l,a,u,n[e+10],17,-42063),u=t.ff(u,c,l,a,n[e+11],22,-1990404162),a=t.ff(a,u,c,l,n[e+12],7,1804603682),l=t.ff(l,a,u,c,n[e+13],12,-40341101),c=t.ff(c,l,a,u,n[e+14],17,-1502002290),u=t.ff(u,c,l,a,n[e+15],22,1236535329),a=t.gg(a,u,c,l,n[e+1],5,-165796510),l=t.gg(l,a,u,c,n[e+6],9,-1069501632),c=t.gg(c,l,a,u,n[e+11],14,643717713),u=t.gg(u,c,l,a,n[e],20,-373897302),a=t.gg(a,u,c,l,n[e+5],5,-701558691),l=t.gg(l,a,u,c,n[e+10],9,38016083),c=t.gg(c,l,a,u,n[e+15],14,-660478335),u=t.gg(u,c,l,a,n[e+4],20,-405537848),a=t.gg(a,u,c,l,n[e+9],5,568446438),l=t.gg(l,a,u,c,n[e+14],9,-1019803690),c=t.gg(c,l,a,u,n[e+3],14,-187363961),u=t.gg(u,c,l,a,n[e+8],20,1163531501),a=t.gg(a,u,c,l,n[e+13],5,-1444681467),l=t.gg(l,a,u,c,n[e+2],9,-51403784),c=t.gg(c,l,a,u,n[e+7],14,1735328473),u=t.gg(u,c,l,a,n[e+12],20,-1926607734),a=t.hh(a,u,c,l,n[e+5],4,-378558),l=t.hh(l,a,u,c,n[e+8],11,-2022574463),c=t.hh(c,l,a,u,n[e+11],16,1839030562),u=t.hh(u,c,l,a,n[e+14],23,-35309556),a=t.hh(a,u,c,l,n[e+1],4,-1530992060),l=t.hh(l,a,u,c,n[e+4],11,1272893353),c=t.hh(c,l,a,u,n[e+7],16,-155497632),u=t.hh(u,c,l,a,n[e+10],23,-1094730640),a=t.hh(a,u,c,l,n[e+13],4,681279174),l=t.hh(l,a,u,c,n[e],11,-358537222),c=t.hh(c,l,a,u,n[e+3],16,-722521979),u=t.hh(u,c,l,a,n[e+6],23,76029189),a=t.hh(a,u,c,l,n[e+9],4,-640364487),l=t.hh(l,a,u,c,n[e+12],11,-421815835),c=t.hh(c,l,a,u,n[e+15],16,530742520),u=t.hh(u,c,l,a,n[e+2],23,-995338651),a=t.ii(a,u,c,l,n[e],6,-198630844),l=t.ii(l,a,u,c,n[e+7],10,1126891415),c=t.ii(c,l,a,u,n[e+14],15,-1416354905),u=t.ii(u,c,l,a,n[e+5],21,-57434055),a=t.ii(a,u,c,l,n[e+12],6,1700485571),l=t.ii(l,a,u,c,n[e+3],10,-1894986606),c=t.ii(c,l,a,u,n[e+10],15,-1051523),u=t.ii(u,c,l,a,n[e+1],21,-2054922799),a=t.ii(a,u,c,l,n[e+8],6,1873313359),l=t.ii(l,a,u,c,n[e+15],10,-30611744),c=t.ii(c,l,a,u,n[e+6],15,-1560198380),u=t.ii(u,c,l,a,n[e+13],21,1309151649),a=t.ii(a,u,c,l,n[e+4],6,-145523070),l=t.ii(l,a,u,c,n[e+11],10,-1120210379),c=t.ii(c,l,a,u,n[e+2],15,718787259),u=t.ii(u,c,l,a,n[e+9],21,-343485551),a=t.ad(a,r),u=t.ad(u,i),c=t.ad(c,s),l=t.ad(l,o);return t.rh(a)+t.rh(u)+t.rh(c)+t.rh(l)}static rh(e){let n="";for(let r=0;r<=3;r++)n+=t.alphabet.charAt(e>>8*r+4&15)+t.alphabet.charAt(e>>8*r&15);return n}static ad(e,t){const n=(65535&e)+(65535&t);return(e>>16)+(t>>16)+(n>>16)<<16|65535&n}static rl(e,t){return e<<t|e>>>32-t}static cm(e,n,r,i,s,o){return t.ad(t.rl(t.ad(t.ad(n,e),t.ad(i,o)),s),r)}static ff(e,n,r,i,s,o,a){return t.cm(n&r|~n&i,e,n,s,o,a)}static gg(e,n,r,i,s,o,a){return t.cm(n&i|r&~i,e,n,s,o,a)}static hh(e,n,r,i,s,o,a){return t.cm(n^r^i,e,n,s,o,a)}static ii(e,n,r,i,s,o,a){return t.cm(r^(n|~i),e,n,s,o,a)}static sb(e){let t;const n=1+(e.length+8>>6),r=new Array(16*n);for(t=0;t<16*n;t++)r[t]=0;for(t=0;t<e.length;t++)r[t>>2]|=e.charCodeAt(t)<<t%4*8;return r[t>>2]|=128<<t%4*8,r[16*n-2]=8*e.length,r}}function i(t){function n(e,t,n){let r=t.slice(0,1),i=t.slice(-1);if("."===r&&(t=t.slice(1)),"."===i&&(t=t.slice(0,-1)),t.includes(".")){let n=t.split(".");t=n.pop();for(let t of n)t&&(e.hasOwnProperty(t)||(e[t]={}),e=e[t])}e.hasOwnProperty(t)?Array.isArray(e[t])?e[t].push(n):e[t]=[e[t],n]:e[t]=n}if(t instanceof FormData){let r={},i=0,s=[];for(let e of t.entries()){let t=e[0],o=e[1];if(o instanceof File)s.includes(t)||s.push(t),i+=o.size;else if(o instanceof FileList){if(s.includes(t)||s.push(t),o&&o.length>0)for(let e=0;e<=o.length-1;e++)i+=o.item(e).size}else n(r,t,o)}if(i>44e5)throw new e("Total File size cannot exceed 4MB. Use skapi.uploadFiles() instead.",{code:"INVALID_REQUEST"});return{meta:r,files:s}}if(t instanceof SubmitEvent&&(t=t.target),t instanceof HTMLFormElement){let r={},i=[],s=0,o=t.querySelectorAll("input"),a=t.querySelectorAll("textarea");for(let e=0;e<a.length;e++){let t=a[e];t.name&&n(r,t.name,t.value)}for(let e=0;e<o.length;e++){let t=o[e];if(t.name)if("number"===t.type)t.value&&n(r,t.name,Number(t.value));else if("checkbox"===t.type||"radio"===t.type)t.checked?""===t.value&&"checkbox"===t.type||"on"===t.value||"true"===t.value?n(r,t.name,!0):"false"===t.value?n(r,t.name,!1):t.value&&n(r,t.name,t.value):"checkbox"===t.type&&(""===t.value||"on"===t.value||"true"===t.value?n(r,t.name,!1):"false"===t.value?n(r,t.name,!0):n(r,t.name,void 0));else if("file"===t.type){if(i.includes(t.name)||i.push(t.name),t.files&&t.files.length>0)for(let e=0;e<=t.files.length-1;e++)s+=t.files.item(e).size}else n(r,t.name,t.value)}if(s>44e5)throw new e("Total File size cannot exceed 4MB. Use skapi.uploadFiles() instead.",{code:"INVALID_REQUEST"});return{meta:r,files:i}}return null}t.alphabet="0123456789abcdef";const s={UserId:function(t,n="User ID"){if(!t)throw new e(`${n} is empty.`,{code:"INVALID_PARAMETER"});if("string"!=typeof t)throw new e(`${n} should be type: string.`,{code:"INVALID_PARAMETER"});if(!t.match(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-5][0-9a-f]{3}-[089ab][0-9a-f]{3}-[0-9a-f]{12}$/i))throw new e(`${n} is invalid.`,{code:"INVALID_PARAMETER"});return t},PhoneNumber:function(t){if(t&&("string"!=typeof t||"+"!==t.charAt(0)||isNaN(Number(t.substring(1)))))throw new e('"phone_number" is invalid. The format should be "+00123456789". Type: string.',{code:"INVALID_PARAMETER"});return t||""},Birthdate:function(t){if(t){if("string"!=typeof t)throw new e('"birthdate" is invalid. The format should be "yyyy-mm-dd". Type: string.',{code:"INVALID_PARAMETER"});{let n=new RegExp(/([12]\d{3}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01]))/);if(10!==t.length||3!==t.split("-").length||!n.test(t))throw new e('"birthdate" is invalid. The format should be "yyyy-mm-dd". Type: string.',{code:"INVALID_PARAMETER"})}}return t||""},Password:function(t){if(!t)throw new e('"password" is required.',{code:"INVALID_PARAMETER"});if("string"!=typeof t)throw new e('"password" should be type: string.',{code:"INVALID_PARAMETER"});if(t.length<6)throw new e('"password" should be at least 6 characters.',{code:"INVALID_PARAMETER"});if(t.length>60)throw new e('"password" can be up to 60 characters max.',{code:"INVALID_PARAMETER"});return t},Email:function(t,n="email"){if(!t)throw new e(`"${n}" is required.`,{code:"INVALID_PARAMETER"});if("string"!=typeof t)throw new e(`"${n}"should be type: string.`,{code:"INVALID_PARAMETER"});if(t.length<5)throw new e(`"${n}" should be at least 5 characters.`,{code:"INVALID_PARAMETER"});if(/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/.test(t)&&(t=t.trim()).split("@")[1].split(".").length>=2)return t.toLowerCase();throw new e(`"${t}" is an invalid email.`,{code:"INVALID_PARAMETER"})},Url:function(t){const n=(()=>{let e=window.location.origin||null;return e&&"/"===e.slice(-1)&&(e=e.slice(0,-1)),e})();let r=t=>{if("string"==typeof t){if("*"===t)return"*";{let r=t.trim();if(!r.includes(" ")&&!r.includes(",")){let i;"/"===r.slice(0,1)&&n?r=n+r:"."===r.slice(0,1)&&n&&(r=window.location.href.split("/").slice(0,-1).join("/")+r);try{i=new URL(r)}catch(n){throw new e(`"${t}" is an invalid url.`,{code:"INVALID_PARAMETER"})}if(i.protocol){let e=i.href;return"/"===e.charAt(e.length-1)&&(e=e.substring(0,e.length-1)),e}}}}throw new e(`"${t}" is an invalid url.`,{code:"INVALID_PARAMETER"})};return Array.isArray(t)?t.map((e=>r(e))):r(t)},specialChars:function(t,n="parameter",r=!1,i=!1){let s=s=>{if("string"!=typeof s)throw new e(`${n} should be type: <string | string[]>.`,{code:"INVALID_PARAMETER"});if(!i&&t.includes(" "))throw new e(`${n} should not have whitespace.`,{code:"INVALID_PARAMETER"});if(!r&&t.includes("."))throw new e(`${n} should not have periods.`,{code:"INVALID_PARAMETER"});if(/[`!@#$%^&*()_+\-=\[\]{};':"\\|,<>\/?~]/.test(s))throw new e(`${n} should not have special characters.`,{code:"INVALID_PARAMETER"})};if(Array.isArray(t))for(let e of t)s(e);else s(t);return t},Params:function t(n,r,s=null,o=[],a=null){function u(t){if(t instanceof Promise)throw new e("Parameter should not be a promise",{code:"INVALID_PARAMETER"});return t&&"object"==typeof t&&!Array.isArray(t)&&Object.keys(t).length}Array.isArray(o)&&(o=o.concat(["service","owner"]));let c,l=n,h=null,f=a?` in "${a}" is invalid.`:". Parameter should be type <object>.";if(null===a){if(u(l)){l=l instanceof HTMLFormElement||l instanceof FormData||l instanceof SubmitEvent?i(n)?.meta:JSON.parse(JSON.stringify(n));for(let t in l)if(!r.hasOwnProperty(t)&&Array.isArray(o)&&!o.includes(t))throw new e(`Key name "${t}" is invalid in parameter.`,{code:"INVALID_PARAMETER"});if(Array.isArray(s)&&s.length)for(let t of s)if(!Object.keys(l).includes(t))throw new e(`Key "${t}" is required in parameter.`,{code:"INVALID_PARAMETER"})}else if((d=l)&&"object"==typeof d&&!Array.isArray(d)&&!Object.keys(d).length||void 0===l){let e={};for(let t in r){let n=r[t];Array.isArray(n)&&"function"==typeof n[n.length-1]&&(e[t]=n[n.length-1]())}return Object.keys(e).length?e:l}if(null===l)return null}var d;if(u(r)&&u(l)){for(let e in r){let n=r[e];if(l.hasOwnProperty(e)&&null===l[e])l[e]=null;else if(l.hasOwnProperty(e)&&void 0!==l[e])l[e]=t(l[e],n,null,null,e);else{let t=Array.isArray(n)&&"function"==typeof n[n.length-1]?n[n.length-1]:null;if(t){let n=t();void 0!==n&&(l[e]=n)}}}c=l}else if(Array.isArray(r))for(let n of r)try{void 0!==typeof l&&"function"!=typeof n&&(c=t(l,n,null,null,a));break}catch(t){if("string"==typeof t&&"BREAK:"===t.substring(0,6)){let n=(t=t.substring(6)).split(":");h=new e(n[1],{code:n[0]});break}h=t}else{if("function"==typeof r)return r(l);if("string"==typeof r)if(Array.isArray(l)){if("array"!==r)throw new e(`Invalid type "${typeof l}"${f}`,{code:"INVALID_PARAMETER"});for(let t of l)if(!["number","string","boolean"].includes(typeof t)&&null!==t)throw new e(`Invalid type "${typeof t}" in "${a}" array value.`,{code:"INVALID_PARAMETER"});c=l}else if(["number","string","boolean","array","function"].includes(r)){if(typeof l!==r)throw new e(`Value: ${l}${f}`,{code:"INVALID_PARAMETER"});if("number"===r&&Math.abs(l)>4503599627370496)throw`BREAK:INVALID_PARAMETER:"${a}" integer value should be within -4503599627370496 ~ +4503599627370546.`;c=l}else{if(l!==r)throw new e(`Value: ${l}${f}`,{code:"INVALID_PARAMETER"});c=l}else null===r&&(c=l)}if(void 0===c&&h)throw h;return c}},o={};function a(){return this.__connection}async function u(e,t){return await this.checkAdmin()?(e?.dir||(e.dir="/"),c.bind(this)("list-host-directory",e,{fetchOptions:t,auth:!0,method:"post"})):[]}async function c(t,n=null,r){r=r||{};let{auth:i=!1,method:a="post",meta:u=null,bypassAwaitConnection:c=!1}=r;a=a.toLowerCase();let f=c?null:await this.__connection;if(!f&&!c)throw new e("Invalid connection. The service could have been disabled, or has a restricted CORS.",{code:"INVALID_REQUEST"});let g=i?this.session?.idToken?.jwtToken:null;if(i){if(!g)throw this.logout(),new e("User login is required.",{code:"INVALID_REQUEST"});{let t=Date.now()/1e3;if(this.session.idToken.payload.exp<t)try{await this.authentication().getSession({refreshToken:!0}),g=this.session?.idToken?.jwtToken}catch(t){throw this.logout(),new e("User login is required.",{code:"INVALID_REQUEST"})}}}let y="";try{y=s.Url(t)}catch(e){}let w=y||await(async(e,t)=>{const n=await Promise.all([this.admin_endpoint,this.record_endpoint]),r=n[0],i=n[1];return((()=>{switch(e){case"get-newsletters":case"get-public-newsletters":case"delete-newsletter":case"block-account":case"register-service":case"get-users":case"post-userdata":case"remove-account":case"post-secure":case"subscribe-newsletter":case"subscribe-public-newsletter":case"signup":case"confirm-signup":case"recover-account":case"mock":case"get-services":case"service":case"grant-access":case"last-verified-email":case"get-newsletter-subscription":case"request-username-change":case"register-subdomain":case"list-host-directory":case"refresh-cdn":case"request-newsletter-sender":case"set-404":return{public:r.admin_public,private:r.admin_private};case"post-record":case"get-records":case"subscription":case"get-subscription":case"del-records":case"get-table":case"get-tag":case"get-index":case"storage-info":case"get-signed-url":case"grant-private-access":case"request-private-access-key":case"del-files":return{private:i.record_private,public:i.record_public};default:return null}})()?.[t?"private":"public"]||"")+e})(t,!!i),m=this.session?.attributes?.["custom:service"]||f?.service||this.service,b=this.session?.attributes?.["custom:owner"]||f?.owner||this.owner;if(u){if("object"!=typeof u||Array.isArray(u))throw new e("Invalid meta data.",{code:"INVALID_REQUEST"});u=JSON.parse(JSON.stringify(u))}if(Array.isArray(n)||n&&"object"!=typeof n)throw new e("Request data should be a JSON Object | FormData | HTMLFormElement.",{code:"INVALID_REQUEST"});let _="blob"!==r?.responseType?{service:m,owner:b}:{},A={},{fetchMore:v=!1,progress:E}=r?.fetchOptions||{};if(r?.fetchOptions&&Object.keys(r.fetchOptions).length){let t=s.Params({limit:r.fetchOptions?.limit||50,startKey:r.fetchOptions?.startKey||null,ascending:"boolean"!=typeof r.fetchOptions?.ascending||r.fetchOptions.ascending},{limit:["number",()=>50],startKey:null,ascending:["boolean",()=>!0]});if(t.hasOwnProperty("limit")&&"number"==typeof t.limit){if(t.limit>1e3)throw new e("Fetch limit should be below 1000.",{code:"INVALID_REQUEST"});Object.assign(A,{limit:t.limit})}t.hasOwnProperty("startKey")&&"object"==typeof t.startKey&&t.startKey&&Object.keys(t.startKey)&&Object.assign(A,{startKey:t.startKey}),t.hasOwnProperty("ascending")&&"boolean"==typeof t.ascending&&Object.assign(A,{ascending:t.ascending})}Object.assign(_,A);let S=!1;if(n instanceof SubmitEvent&&(n=n?.target),n instanceof HTMLFormElement&&(n=new FormData(n)),n instanceof FormData&&(S=!0),u)u=Object.assign(_,u);else if(n)if(S)for(let e in _)void 0!==_[e]&&n.set(e,new Blob([JSON.stringify(_[e])],{type:"application/json"}));else n=Object.assign(_,n);else n=_;if(S&&"function"==typeof r?.fetchOptions?.formData){let t=r.fetchOptions.formData(n);if(t instanceof Promise&&(t=await t),t instanceof FormData&&(n=t),!(n instanceof FormData))throw new e("Callback for extractFormData() should return FormData",{code:"INVALID_PARAMETER"});{let t=0;for(let e of n.entries()){let n=e[1];if(n instanceof File)t+=n.size;else if(n instanceof FileList&&n&&n.length>0)for(let e=0;e<=n.length-1;e++)t+=n.item(e).size}if(t>42e5)throw new e("Files cannot exceed 4MB. Use skapi.uploadFiles(...) instead.",{code:"INVALID_REQUEST"})}}let I=l.bind(this)({params:n,url:y||t,fetchMore:!S&&v});if(I&&"object"==typeof I)return I;if("string"==typeof I){if(!(o[I]instanceof Promise)){let e={Accept:"*/*"};g&&(e.Authorization=g),u&&(e["Content-Meta"]=window.btoa(encodeURIComponent("string"==typeof u?u:JSON.stringify(u)))),r.hasOwnProperty("contentType")?r?.contentType&&(e["Content-Type"]=r.contentType):n instanceof FormData||(e["Content-Type"]="application/json");let t={headers:e};r?.responseType&&(t.responseType=r.responseType),"post"===a?o[I]=d.bind(this)(w,n,t,E):"get"===a&&(o[I]=p.bind(this)(w,n,t,E))}try{let e=await o[I];return S?e:await h.bind(this)({hashedParam:I,url:t,response:e})}catch(e){throw e}finally{I&&o.hasOwnProperty(I)&&delete o[I]}}}function l(n){let{params:r={},url:i,fetchMore:s=!1}=n||{};if(r.hasOwnProperty("startKey")&&r.startKey){if("object"!=typeof r.startKey&&!Object.keys(r.startKey).length&&"start"!==r.startKey&&"end"!==r.startKey)throw new e(`"${r.startKey}" is invalid startKey key.`,{code:"INVALID_PARAMETER"});"start"===r.startKey&&(s=!1,delete r.startKey)}let o=(()=>{if(r&&"object"==typeof r&&Object.keys(r).length){function e(e){function t(e){return"object"==typeof e&&e?Object.keys(e).sort().reduce(((t,n)=>(t[n]=e[n],t)),{}):e}let n=t(e);n.hasOwnProperty("limit")&&delete n.limit;for(let r in n)n[r]&&"object"==typeof n[r]&&(n[r]=t(e[r]));return n}return t.hash(i+"/"+JSON.stringify(e(r)))}return t.hash(i+"/"+this.service)})();if(!s&&this.__startKeyHistory?.[i]?.[o]){if(this.__cached_requests?.[i]&&this.__cached_requests?.[i]?.[o]&&delete this.__cached_requests[i][o],Array.isArray(this.__startKeyHistory[i][o])&&this.__startKeyHistory[i][o].length)for(let e of this.__startKeyHistory[i][o]){let n=o+"/"+t.hash(JSON.stringify(e));this.__cached_requests?.[i]&&this.__cached_requests?.[i]?.[n]&&delete this.__cached_requests[i][n]}return delete this.__startKeyHistory[i][o],o}if(!Array.isArray(this.__startKeyHistory?.[i]?.[o]))return o;let a=this.__startKeyHistory[i][o],u=a[a.length-1],c=o;if(u){if("end"===u)return{list:[],startKey:"end",endOfList:!0,startKeyHistory:this.__startKeyHistory[i][o]};c+=t.hash(u),r.startKey=JSON.parse(u)}return this.__cached_requests?.[i]?.[c]?this.__cached_requests[i][c]:o}async function h(e){let{hashedParam:t,url:n,response:r}=e,i=null;if(i=r instanceof Promise?await r:r,!(i&&"object"==typeof i&&i.hasOwnProperty("startKey")&&t&&n))return i;this.__startKeyHistory.hasOwnProperty(n)||(this.__startKeyHistory[n]={}),this.__cached_requests?.[n]||(this.__cached_requests[n]={}),this.__cached_requests[n][t]=i,this.__startKeyHistory[n].hasOwnProperty(t)||(this.__startKeyHistory[n][t]=[]);let s="end"===i.startKey?"end":JSON.stringify(i.startKey);return this.__startKeyHistory[n][t].includes(s)||this.__startKeyHistory[n][t].push(s),this.__cached_requests[n][t]=i,Object.assign({startKeyHistory:this.__startKeyHistory[n][t]},i)}async function f(t,n,r){let i=await((t,r,i)=>new Promise(((s,o)=>{let a=new XMLHttpRequest;for(var u in a.open((n.method||"GET").toUpperCase(),t),r.headers||{})a.setRequestHeader(u,r.headers[u]);n.responseType&&(a.responseType=n.responseType),a.onload=()=>{if(a.status>=200&&a.status<300)if("json"==r.responseType||"blob"==r.responseType)s(a.response);else{let e=a.responseText;try{e=JSON.parse(e)}catch(e){}s(e)}else{let t=a.status,n=["INVALID_CORS","INVALID_REQUEST","SERVICE_DISABLED","INVALID_PARAMETER","ERROR","EXISTS","NOT_EXISTS"],r=a.responseText;try{r=JSON.parse(r)}catch(e){}if("string"==typeof r){let t=a.response.split(":"),r=t.splice(0,1)[0].trim();o(new e(t.join("").trim(),{code:n.includes(r)?r:"ERROR"}))}else if("object"==typeof r&&r?.message){let n=r?.code||(t?t.toString():null)||"ERROR";o(new e(r?.message,{code:n}))}}},a.onerror=()=>o("Network error"),a.onabort=()=>o("Aborted"),a.ontimeout=()=>o("Timeout"),"function"==typeof i&&(a.onprogress=e=>{i({status:"download",progress:e.loaded/e.total*100,loaded:e.loaded,total:e.total,abort:()=>a.abort()})},a.upload&&(a.upload.onprogress=e=>{i({status:"upload",progress:e.loaded/e.total*100,loaded:e.loaded,total:e.total,abort:()=>a.abort()})})),a.send(r.body)})))(t,{headers:n?.headers,body:n.body,responseType:n?.responseType},r);if("object"==typeof i&&"GET"===n.method&&i.hasOwnProperty("body"))try{i=JSON.parse(i.body)}catch(e){}return i}async function d(e,t,n,r){let i=Object.assign({method:"POST"},n,{body:t instanceof FormData?t:JSON.stringify(t)});return f.bind(this)(e,i,r)}async function p(e,t,n,r){t&&"object"==typeof t&&Object.keys(t).length&&("?"!==e.substring(e.length-1)&&(e+="?"),e+=Object.keys(t).map((e=>{let n=t[e];return"string"!=typeof n&&(n=JSON.stringify(n)),encodeURIComponent(e)+"="+encodeURIComponent(n)})).join("&"));let i=Object.assign({method:"GET"},n);return f.bind(this)(e,i,r)}async function g(e){let t={url:e=>s.Url(e),data:null,sync:["boolean",()=>!0]};if(Array.isArray(e))for(let n of e)n=s.Params(n,t);else e=s.Params(e,t);return await c.bind(this)("post-secure",e,{auth:!0})}async function y(e,t,n){if(n=n||{},t&&t?.formData&&"function"==typeof t.formData){let e={formData:t.formData};Object.assign(n,e)}return c.bind(this)("mock",e,n)}async function w(){await this.__connection;let n=`${this.service}:${t.hash(window.location.href.split("?")[0])}`,r=window.sessionStorage.getItem(n);if(null!==r){try{r=JSON.parse(r)}catch(e){}return r}throw new e("Form response doesn't exist.",{code:"NOT_EXISTS"})}const m={};function b(n){let{preventMultipleCalls:r=!1}=n||{};return function(n,i,s){const o=s.value;s.value=function(...n){let s=n[0],a=n?.[1]||{},u=!0,c=null,l="";if(s instanceof SubmitEvent){s.preventDefault();let e=window.location.href;c=s.target;let t=new URL(c.action);l=t.href,c.action&&t.href!==e||(u=!1)}const h=n=>{if(a?.response){if("function"==typeof a.response)return a.response(n);throw new e('Callback "response" should be type: function.',{code:"INVALID_PARAMETER"})}return c&&u&&(window.sessionStorage.setItem(`${this.service}:${t.hash(l)}`,JSON.stringify(n)),window.location.href=l),n};let f,d=t=>{s instanceof SubmitEvent&&s.preventDefault();let n=t instanceof Error?t:new e(t);if(a?.onerror){if("function"==typeof a.onerror)return a.onerror(n);throw new e('Callback "onerror" should be type: function.',{code:"INVALID_PARAMETER"})}throw n};const p=()=>{try{f=o.bind(this)(...n)}catch(e){let t=d(e);if(t instanceof Error)throw t;return t}if(f instanceof Promise)return(async()=>{try{let e=await f;return h(e)}catch(e){return d(e)}})()};return r?(async()=>{if(m?.[i]instanceof Promise){let e=await m[i];return m[i]=null,e}return m[i]=p().finally((()=>{m[i]=null})),m[i]})():p()}}}var _,A=function(){function e(e){var t=e||{},n=t.ValidationData,r=t.Username,i=t.Password,s=t.AuthParameters,o=t.ClientMetadata;this.validationData=n||{},this.authParameters=s||{},this.clientMetadata=o||{},this.username=r,this.password=i}var t=e.prototype;return t.getUsername=function(){return this.username},t.getPassword=function(){return this.password},t.getValidationData=function(){return this.validationData},t.getAuthParameters=function(){return this.authParameters},t.getClientMetadata=function(){return this.clientMetadata},e}(),v=n(764),E=n(249),S=n.n(E),I=(n(433),n(153)),T=n.n(I),R=n(10),D=n.n(R);if("undefined"!=typeof window&&window.crypto&&(_=window.crypto),!_&&"undefined"!=typeof window&&window.msCrypto&&(_=window.msCrypto),!_&&void 0!==n.g&&n.g.crypto&&(_=n.g.crypto),!_)try{_=n(296)}catch(e){}function U(){if(_){if("function"==typeof _.getRandomValues)try{return _.getRandomValues(new Uint32Array(1))[0]}catch(e){}if("function"==typeof _.randomBytes)try{return _.randomBytes(4).readInt32LE()}catch(e){}}throw new Error("Native crypto module could not be used to get secure random number.")}var C=function(){function e(e,t){e=this.words=e||[],this.sigBytes=null!=t?t:4*e.length}var t=e.prototype;return t.random=function(t){for(var n=[],r=0;r<t;r+=4)n.push(U());return new e(n,t)},t.toString=function(){return function(e){for(var t=e.words,n=e.sigBytes,r=[],i=0;i<n;i++){var s=t[i>>>2]>>>24-i%4*8&255;r.push((s>>>4).toString(16)),r.push((15&s).toString(16))}return r.join("")}(this)},e}();const P=N;function N(e,t){null!=e&&this.fromString(e,t)}function k(){return new N(null)}var O,M="undefined"!=typeof navigator;M&&"Microsoft Internet Explorer"==navigator.appName?(N.prototype.am=function(e,t,n,r,i,s){for(var o=32767&t,a=t>>15;--s>=0;){var u=32767&this[e],c=this[e++]>>15,l=a*u+c*o;i=((u=o*u+((32767&l)<<15)+n[r]+(1073741823&i))>>>30)+(l>>>15)+a*c+(i>>>30),n[r++]=1073741823&u}return i},O=30):M&&"Netscape"!=navigator.appName?(N.prototype.am=function(e,t,n,r,i,s){for(;--s>=0;){var o=t*this[e++]+n[r]+i;i=Math.floor(o/67108864),n[r++]=67108863&o}return i},O=26):(N.prototype.am=function(e,t,n,r,i,s){for(var o=16383&t,a=t>>14;--s>=0;){var u=16383&this[e],c=this[e++]>>14,l=a*u+c*o;i=((u=o*u+((16383&l)<<14)+n[r]+i)>>28)+(l>>14)+a*c,n[r++]=268435455&u}return i},O=28),N.prototype.DB=O,N.prototype.DM=(1<<O)-1,N.prototype.DV=1<<O,N.prototype.FV=Math.pow(2,52),N.prototype.F1=52-O,N.prototype.F2=2*O-52;var F,V,x=new Array;for(F="0".charCodeAt(0),V=0;V<=9;++V)x[F++]=V;for(F="a".charCodeAt(0),V=10;V<36;++V)x[F++]=V;for(F="A".charCodeAt(0),V=10;V<36;++V)x[F++]=V;function L(e){return"0123456789abcdefghijklmnopqrstuvwxyz".charAt(e)}function B(e,t){var n=x[e.charCodeAt(t)];return null==n?-1:n}function $(e){var t=k();return t.fromInt(e),t}function q(e){var t,n=1;return 0!=(t=e>>>16)&&(e=t,n+=16),0!=(t=e>>8)&&(e=t,n+=8),0!=(t=e>>4)&&(e=t,n+=4),0!=(t=e>>2)&&(e=t,n+=2),0!=(t=e>>1)&&(e=t,n+=1),n}function K(e){this.m=e,this.mp=e.invDigit(),this.mpl=32767&this.mp,this.mph=this.mp>>15,this.um=(1<<e.DB-15)-1,this.mt2=2*e.t}function j(e){return v.lW.from((new C).random(e).toString(),"hex")}K.prototype.convert=function(e){var t=k();return e.abs().dlShiftTo(this.m.t,t),t.divRemTo(this.m,null,t),e.s<0&&t.compareTo(N.ZERO)>0&&this.m.subTo(t,t),t},K.prototype.revert=function(e){var t=k();return e.copyTo(t),this.reduce(t),t},K.prototype.reduce=function(e){for(;e.t<=this.mt2;)e[e.t++]=0;for(var t=0;t<this.m.t;++t){var n=32767&e[t],r=n*this.mpl+((n*this.mph+(e[t]>>15)*this.mpl&this.um)<<15)&e.DM;for(e[n=t+this.m.t]+=this.m.am(0,r,e,t,0,this.m.t);e[n]>=e.DV;)e[n]-=e.DV,e[++n]++}e.clamp(),e.drShiftTo(this.m.t,e),e.compareTo(this.m)>=0&&e.subTo(this.m,e)},K.prototype.mulTo=function(e,t,n){e.multiplyTo(t,n),this.reduce(n)},K.prototype.sqrTo=function(e,t){e.squareTo(t),this.reduce(t)},N.prototype.copyTo=function(e){for(var t=this.t-1;t>=0;--t)e[t]=this[t];e.t=this.t,e.s=this.s},N.prototype.fromInt=function(e){this.t=1,this.s=e<0?-1:0,e>0?this[0]=e:e<-1?this[0]=e+this.DV:this.t=0},N.prototype.fromString=function(e,t){var n;if(16==t)n=4;else if(8==t)n=3;else if(2==t)n=1;else if(32==t)n=5;else{if(4!=t)throw new Error("Only radix 2, 4, 8, 16, 32 are supported");n=2}this.t=0,this.s=0;for(var r=e.length,i=!1,s=0;--r>=0;){var o=B(e,r);o<0?"-"==e.charAt(r)&&(i=!0):(i=!1,0==s?this[this.t++]=o:s+n>this.DB?(this[this.t-1]|=(o&(1<<this.DB-s)-1)<<s,this[this.t++]=o>>this.DB-s):this[this.t-1]|=o<<s,(s+=n)>=this.DB&&(s-=this.DB))}this.clamp(),i&&N.ZERO.subTo(this,this)},N.prototype.clamp=function(){for(var e=this.s&this.DM;this.t>0&&this[this.t-1]==e;)--this.t},N.prototype.dlShiftTo=function(e,t){var n;for(n=this.t-1;n>=0;--n)t[n+e]=this[n];for(n=e-1;n>=0;--n)t[n]=0;t.t=this.t+e,t.s=this.s},N.prototype.drShiftTo=function(e,t){for(var n=e;n<this.t;++n)t[n-e]=this[n];t.t=Math.max(this.t-e,0),t.s=this.s},N.prototype.lShiftTo=function(e,t){var n,r=e%this.DB,i=this.DB-r,s=(1<<i)-1,o=Math.floor(e/this.DB),a=this.s<<r&this.DM;for(n=this.t-1;n>=0;--n)t[n+o+1]=this[n]>>i|a,a=(this[n]&s)<<r;for(n=o-1;n>=0;--n)t[n]=0;t[o]=a,t.t=this.t+o+1,t.s=this.s,t.clamp()},N.prototype.rShiftTo=function(e,t){t.s=this.s;var n=Math.floor(e/this.DB);if(n>=this.t)t.t=0;else{var r=e%this.DB,i=this.DB-r,s=(1<<r)-1;t[0]=this[n]>>r;for(var o=n+1;o<this.t;++o)t[o-n-1]|=(this[o]&s)<<i,t[o-n]=this[o]>>r;r>0&&(t[this.t-n-1]|=(this.s&s)<<i),t.t=this.t-n,t.clamp()}},N.prototype.subTo=function(e,t){for(var n=0,r=0,i=Math.min(e.t,this.t);n<i;)r+=this[n]-e[n],t[n++]=r&this.DM,r>>=this.DB;if(e.t<this.t){for(r-=e.s;n<this.t;)r+=this[n],t[n++]=r&this.DM,r>>=this.DB;r+=this.s}else{for(r+=this.s;n<e.t;)r-=e[n],t[n++]=r&this.DM,r>>=this.DB;r-=e.s}t.s=r<0?-1:0,r<-1?t[n++]=this.DV+r:r>0&&(t[n++]=r),t.t=n,t.clamp()},N.prototype.multiplyTo=function(e,t){var n=this.abs(),r=e.abs(),i=n.t;for(t.t=i+r.t;--i>=0;)t[i]=0;for(i=0;i<r.t;++i)t[i+n.t]=n.am(0,r[i],t,i,0,n.t);t.s=0,t.clamp(),this.s!=e.s&&N.ZERO.subTo(t,t)},N.prototype.squareTo=function(e){for(var t=this.abs(),n=e.t=2*t.t;--n>=0;)e[n]=0;for(n=0;n<t.t-1;++n){var r=t.am(n,t[n],e,2*n,0,1);(e[n+t.t]+=t.am(n+1,2*t[n],e,2*n+1,r,t.t-n-1))>=t.DV&&(e[n+t.t]-=t.DV,e[n+t.t+1]=1)}e.t>0&&(e[e.t-1]+=t.am(n,t[n],e,2*n,0,1)),e.s=0,e.clamp()},N.prototype.divRemTo=function(e,t,n){var r=e.abs();if(!(r.t<=0)){var i=this.abs();if(i.t<r.t)return null!=t&&t.fromInt(0),void(null!=n&&this.copyTo(n));null==n&&(n=k());var s=k(),o=this.s,a=e.s,u=this.DB-q(r[r.t-1]);u>0?(r.lShiftTo(u,s),i.lShiftTo(u,n)):(r.copyTo(s),i.copyTo(n));var c=s.t,l=s[c-1];if(0!=l){var h=l*(1<<this.F1)+(c>1?s[c-2]>>this.F2:0),f=this.FV/h,d=(1<<this.F1)/h,p=1<<this.F2,g=n.t,y=g-c,w=null==t?k():t;for(s.dlShiftTo(y,w),n.compareTo(w)>=0&&(n[n.t++]=1,n.subTo(w,n)),N.ONE.dlShiftTo(c,w),w.subTo(s,s);s.t<c;)s[s.t++]=0;for(;--y>=0;){var m=n[--g]==l?this.DM:Math.floor(n[g]*f+(n[g-1]+p)*d);if((n[g]+=s.am(0,m,n,y,0,c))<m)for(s.dlShiftTo(y,w),n.subTo(w,n);n[g]<--m;)n.subTo(w,n)}null!=t&&(n.drShiftTo(c,t),o!=a&&N.ZERO.subTo(t,t)),n.t=c,n.clamp(),u>0&&n.rShiftTo(u,n),o<0&&N.ZERO.subTo(n,n)}}},N.prototype.invDigit=function(){if(this.t<1)return 0;var e=this[0];if(0==(1&e))return 0;var t=3&e;return(t=(t=(t=(t=t*(2-(15&e)*t)&15)*(2-(255&e)*t)&255)*(2-((65535&e)*t&65535))&65535)*(2-e*t%this.DV)%this.DV)>0?this.DV-t:-t},N.prototype.addTo=function(e,t){for(var n=0,r=0,i=Math.min(e.t,this.t);n<i;)r+=this[n]+e[n],t[n++]=r&this.DM,r>>=this.DB;if(e.t<this.t){for(r+=e.s;n<this.t;)r+=this[n],t[n++]=r&this.DM,r>>=this.DB;r+=this.s}else{for(r+=this.s;n<e.t;)r+=e[n],t[n++]=r&this.DM,r>>=this.DB;r+=e.s}t.s=r<0?-1:0,r>0?t[n++]=r:r<-1&&(t[n++]=this.DV+r),t.t=n,t.clamp()},N.prototype.toString=function(e){if(this.s<0)return"-"+this.negate().toString(e);var t;if(16==e)t=4;else if(8==e)t=3;else if(2==e)t=1;else if(32==e)t=5;else{if(4!=e)throw new Error("Only radix 2, 4, 8, 16, 32 are supported");t=2}var n,r=(1<<t)-1,i=!1,s="",o=this.t,a=this.DB-o*this.DB%t;if(o-- >0)for(a<this.DB&&(n=this[o]>>a)>0&&(i=!0,s=L(n));o>=0;)a<t?(n=(this[o]&(1<<a)-1)<<t-a,n|=this[--o]>>(a+=this.DB-t)):(n=this[o]>>(a-=t)&r,a<=0&&(a+=this.DB,--o)),n>0&&(i=!0),i&&(s+=L(n));return i?s:"0"},N.prototype.negate=function(){var e=k();return N.ZERO.subTo(this,e),e},N.prototype.abs=function(){return this.s<0?this.negate():this},N.prototype.compareTo=function(e){var t=this.s-e.s;if(0!=t)return t;var n=this.t;if(0!=(t=n-e.t))return this.s<0?-t:t;for(;--n>=0;)if(0!=(t=this[n]-e[n]))return t;return 0},N.prototype.bitLength=function(){return this.t<=0?0:this.DB*(this.t-1)+q(this[this.t-1]^this.s&this.DM)},N.prototype.mod=function(e){var t=k();return this.abs().divRemTo(e,null,t),this.s<0&&t.compareTo(N.ZERO)>0&&e.subTo(t,t),t},N.prototype.equals=function(e){return 0==this.compareTo(e)},N.prototype.add=function(e){var t=k();return this.addTo(e,t),t},N.prototype.subtract=function(e){var t=k();return this.subTo(e,t),t},N.prototype.multiply=function(e){var t=k();return this.multiplyTo(e,t),t},N.prototype.divide=function(e){var t=k();return this.divRemTo(e,t,null),t},N.prototype.modPow=function(e,t,n){var r,i=e.bitLength(),s=$(1),o=new K(t);if(i<=0)return s;r=i<18?1:i<48?3:i<144?4:i<768?5:6;var a=new Array,u=3,c=r-1,l=(1<<r)-1;if(a[1]=o.convert(this),r>1){var h=k();for(o.sqrTo(a[1],h);u<=l;)a[u]=k(),o.mulTo(h,a[u-2],a[u]),u+=2}var f,d,p=e.t-1,g=!0,y=k();for(i=q(e[p])-1;p>=0;){for(i>=c?f=e[p]>>i-c&l:(f=(e[p]&(1<<i+1)-1)<<c-i,p>0&&(f|=e[p-1]>>this.DB+i-c)),u=r;0==(1&f);)f>>=1,--u;if((i-=u)<0&&(i+=this.DB,--p),g)a[f].copyTo(s),g=!1;else{for(;u>1;)o.sqrTo(s,y),o.sqrTo(y,s),u-=2;u>0?o.sqrTo(s,y):(d=s,s=y,y=d),o.mulTo(y,a[f],s)}for(;p>=0&&0==(e[p]&1<<i);)o.sqrTo(s,y),d=s,s=y,y=d,--i<0&&(i=this.DB-1,--p)}var w=o.revert(s);return n(null,w),w},N.ZERO=$(0),N.ONE=$(1);var H=/^[89a-f]/i,W=function(){function e(e){this.N=new P("FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD129024E088A67CC74020BBEA63B139B22514A08798E3404DDEF9519B3CD3A431B302B0A6DF25F14374FE1356D6D51C245E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7EDEE386BFB5A899FA5AE9F24117C4B1FE649286651ECE45B3DC2007CB8A163BF0598DA48361C55D39A69163FA8FD24CF5F83655D23DCA3AD961C62F356208552BB9ED529077096966D670C354E4ABC9804F1746C08CA18217C32905E462E36CE3BE39E772C180E86039B2783A2EC07A28FB5C55DF06F4C52C9DE2BCBF6955817183995497CEA956AE515D2261898FA051015728E5A8AAAC42DAD33170D04507A33A85521ABDF1CBA64ECFB850458DBEF0A8AEA71575D060C7DB3970F85A6E1E4C7ABF5AE8CDB0933D71E8C94E04A25619DCEE3D2261AD2EE6BF12FFA06D98A0864D87602733EC86A64521F2B18177B200CBBE117577A615D6C770988C0BAD946E208E24FA074E5AB3143DB5BFCE0FD108E4B82D120A93AD2CAFFFFFFFFFFFFFFFF",16),this.g=new P("2",16),this.k=new P(this.hexHash(""+this.padHex(this.N)+this.padHex(this.g)),16),this.smallAValue=this.generateRandomSmallA(),this.getLargeAValue((function(){})),this.infoBits=v.lW.from("Caldera Derived Key","utf8"),this.poolName=e}var t=e.prototype;return t.getSmallAValue=function(){return this.smallAValue},t.getLargeAValue=function(e){var t=this;this.largeAValue?e(null,this.largeAValue):this.calculateA(this.smallAValue,(function(n,r){n&&e(n,null),t.largeAValue=r,e(null,t.largeAValue)}))},t.generateRandomSmallA=function(){var e=j(128).toString("hex");return new P(e,16)},t.generateRandomString=function(){return j(40).toString("base64")},t.getRandomPassword=function(){return this.randomPassword},t.getSaltDevices=function(){return this.SaltToHashDevices},t.getVerifierDevices=function(){return this.verifierDevices},t.generateHashDevice=function(e,t,n){var r=this;this.randomPassword=this.generateRandomString();var i=""+e+t+":"+this.randomPassword,s=this.hash(i),o=j(16).toString("hex");this.SaltToHashDevices=this.padHex(new P(o,16)),this.g.modPow(new P(this.hexHash(this.SaltToHashDevices+s),16),this.N,(function(e,t){e&&n(e,null),r.verifierDevices=r.padHex(t),n(null,null)}))},t.calculateA=function(e,t){var n=this;this.g.modPow(e,this.N,(function(e,r){e&&t(e,null),r.mod(n.N).equals(P.ZERO)&&t(new Error("Illegal paramater. A mod N cannot be 0."),null),t(null,r)}))},t.calculateU=function(e,t){return this.UHexHash=this.hexHash(this.padHex(e)+this.padHex(t)),new P(this.UHexHash,16)},t.hash=function(e){var t=e instanceof v.lW?S().lib.WordArray.create(e):e,n=T()(t).toString();return new Array(64-n.length).join("0")+n},t.hexHash=function(e){return this.hash(v.lW.from(e,"hex"))},t.computehkdf=function(e,t){var n=S().lib.WordArray.create(v.lW.concat([this.infoBits,v.lW.from(String.fromCharCode(1),"utf8")])),r=e instanceof v.lW?S().lib.WordArray.create(e):e,i=t instanceof v.lW?S().lib.WordArray.create(t):t,s=D()(r,i),o=D()(n,s);return v.lW.from(o.toString(),"hex").slice(0,16)},t.getPasswordAuthenticationKey=function(e,t,n,r,i){var s=this;if(n.mod(this.N).equals(P.ZERO))throw new Error("B cannot be zero.");if(this.UValue=this.calculateU(this.largeAValue,n),this.UValue.equals(P.ZERO))throw new Error("U cannot be zero.");var o=""+this.poolName+e+":"+t,a=this.hash(o),u=new P(this.hexHash(this.padHex(r)+a),16);this.calculateS(u,n,(function(e,t){e&&i(e,null);var n=s.computehkdf(v.lW.from(s.padHex(t),"hex"),v.lW.from(s.padHex(s.UValue),"hex"));i(null,n)}))},t.calculateS=function(e,t,n){var r=this;this.g.modPow(e,this.N,(function(i,s){i&&n(i,null),t.subtract(r.k.multiply(s)).modPow(r.smallAValue.add(r.UValue.multiply(e)),r.N,(function(e,t){e&&n(e,null),n(null,t.mod(r.N))}))}))},t.getNewPasswordRequiredChallengeUserAttributePrefix=function(){return"userAttributes."},t.padHex=function(e){if(!(e instanceof P))throw new Error("Not a BigInteger");var t=e.compareTo(P.ZERO)<0,n=e.abs().toString(16);if(n=n.length%2!=0?"0"+n:n,n=H.test(n)?"00"+n:n,t){var r=n.split("").map((function(e){var t=15&~parseInt(e,16);return"0123456789ABCDEF".charAt(t)})).join("");(n=new P(r,16).add(P.ONE).toString(16)).toUpperCase().startsWith("FF8")&&(n=n.substring(2))}return n},e}(),J=function(){function e(e){this.jwtToken=e||"",this.payload=this.decodePayload()}var t=e.prototype;return t.getJwtToken=function(){return this.jwtToken},t.getExpiration=function(){return this.payload.exp},t.getIssuedAt=function(){return this.payload.iat},t.decodePayload=function(){var e=this.jwtToken.split(".")[1];try{return JSON.parse(v.lW.from(e,"base64").toString("utf8"))}catch(e){return{}}},e}();function z(e,t){return z=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},z(e,t)}var Y=function(e){var t,n;function r(t){var n=(void 0===t?{}:t).AccessToken;return e.call(this,n||"")||this}return n=e,(t=r).prototype=Object.create(n.prototype),t.prototype.constructor=t,z(t,n),r}(J);function Q(e,t){return Q=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},Q(e,t)}var G=function(e){var t,n;function r(t){var n=(void 0===t?{}:t).IdToken;return e.call(this,n||"")||this}return n=e,(t=r).prototype=Object.create(n.prototype),t.prototype.constructor=t,Q(t,n),r}(J),Z=n(269),X=n.n(Z),ee=function(){function e(e){var t=(void 0===e?{}:e).RefreshToken;this.token=t||""}return e.prototype.getToken=function(){return this.token},e}(),te=function(){function e(e){var t=void 0===e?{}:e,n=t.IdToken,r=t.RefreshToken,i=t.AccessToken,s=t.ClockDrift;if(null==i||null==n)throw new Error("Id token and Access Token must be present.");this.idToken=n,this.refreshToken=r,this.accessToken=i,this.clockDrift=void 0===s?this.calculateClockDrift():s}var t=e.prototype;return t.getIdToken=function(){return this.idToken},t.getRefreshToken=function(){return this.refreshToken},t.getAccessToken=function(){return this.accessToken},t.getClockDrift=function(){return this.clockDrift},t.calculateClockDrift=function(){return Math.floor(new Date/1e3)-Math.min(this.accessToken.getIssuedAt(),this.idToken.getIssuedAt())},t.isValid=function(){var e=Math.floor(new Date/1e3)-this.clockDrift;return e<this.accessToken.getExpiration()&&e<this.idToken.getExpiration()},e}(),ne=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],re=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],ie=function(){function e(){}return e.prototype.getNowString=function(){var e=new Date,t=re[e.getUTCDay()],n=ne[e.getUTCMonth()],r=e.getUTCDate(),i=e.getUTCHours();i<10&&(i="0"+i);var s=e.getUTCMinutes();s<10&&(s="0"+s);var o=e.getUTCSeconds();return o<10&&(o="0"+o),t+" "+n+" "+r+" "+i+":"+s+":"+o+" UTC "+e.getUTCFullYear()},e}(),se=function(){function e(e){var t=void 0===e?{}:e,n=t.Name,r=t.Value;this.Name=n||"",this.Value=r||""}var t=e.prototype;return t.getValue=function(){return this.Value},t.setValue=function(e){return this.Value=e,this},t.getName=function(){return this.Name},t.setName=function(e){return this.Name=e,this},t.toString=function(){return JSON.stringify(this)},t.toJSON=function(){return{Name:this.Name,Value:this.Value}},e}(),oe={},ae=function(){function e(){}return e.setItem=function(e,t){return oe[e]=t,oe[e]},e.getItem=function(e){return Object.prototype.hasOwnProperty.call(oe,e)?oe[e]:void 0},e.removeItem=function(e){return delete oe[e]},e.clear=function(){return oe={}},e}(),ue=function(){function e(){try{this.storageWindow=window.localStorage,this.storageWindow.setItem("aws.cognito.test-ls",1),this.storageWindow.removeItem("aws.cognito.test-ls")}catch(e){this.storageWindow=ae}}return e.prototype.getStorage=function(){return this.storageWindow},e}(),ce="undefined"!=typeof navigator?navigator.userAgent:"nodejs",le=function(){function e(e){if(null==e||null==e.Username||null==e.Pool)throw new Error("Username and Pool information are required.");this.username=e.Username||"",this.pool=e.Pool,this.Session=null,this.client=e.Pool.client,this.signInUserSession=null,this.authenticationFlowType="USER_SRP_AUTH",this.storage=e.Storage||(new ue).getStorage(),this.keyPrefix="CognitoIdentityServiceProvider."+this.pool.getClientId(),this.userDataKey=this.keyPrefix+"."+this.username+".userData"}var t=e.prototype;return t.setSignInUserSession=function(e){this.clearCachedUserData(),this.signInUserSession=e,this.cacheTokens()},t.getSignInUserSession=function(){return this.signInUserSession},t.getUsername=function(){return this.username},t.getAuthenticationFlowType=function(){return this.authenticationFlowType},t.setAuthenticationFlowType=function(e){this.authenticationFlowType=e},t.initiateAuth=function(e,t){var n=this,r=e.getAuthParameters();r.USERNAME=this.username;var i=0!==Object.keys(e.getValidationData()).length?e.getValidationData():e.getClientMetadata(),s={AuthFlow:"CUSTOM_AUTH",ClientId:this.pool.getClientId(),AuthParameters:r,ClientMetadata:i};this.getUserContextData()&&(s.UserContextData=this.getUserContextData()),this.client.request("InitiateAuth",s,(function(e,r){if(e)return t.onFailure(e);var i=r.ChallengeName,s=r.ChallengeParameters;return"CUSTOM_CHALLENGE"===i?(n.Session=r.Session,t.customChallenge(s)):(n.signInUserSession=n.getCognitoUserSession(r.AuthenticationResult),n.cacheTokens(),t.onSuccess(n.signInUserSession))}))},t.authenticateUser=function(e,t){return"USER_PASSWORD_AUTH"===this.authenticationFlowType?this.authenticateUserPlainUsernamePassword(e,t):"USER_SRP_AUTH"===this.authenticationFlowType||"CUSTOM_AUTH"===this.authenticationFlowType?this.authenticateUserDefaultAuth(e,t):t.onFailure(new Error("Authentication flow type is invalid."))},t.authenticateUserDefaultAuth=function(e,t){var n,r,i=this,s=new W(this.pool.getUserPoolName()),o=new ie,a={};null!=this.deviceKey&&(a.DEVICE_KEY=this.deviceKey),a.USERNAME=this.username,s.getLargeAValue((function(u,c){u&&t.onFailure(u),a.SRP_A=c.toString(16),"CUSTOM_AUTH"===i.authenticationFlowType&&(a.CHALLENGE_NAME="SRP_A");var l=0!==Object.keys(e.getValidationData()).length?e.getValidationData():e.getClientMetadata(),h={AuthFlow:i.authenticationFlowType,ClientId:i.pool.getClientId(),AuthParameters:a,ClientMetadata:l};i.getUserContextData(i.username)&&(h.UserContextData=i.getUserContextData(i.username)),i.client.request("InitiateAuth",h,(function(a,u){if(a)return t.onFailure(a);var c=u.ChallengeParameters;i.username=c.USER_ID_FOR_SRP,i.userDataKey=i.keyPrefix+"."+i.username+".userData",n=new P(c.SRP_B,16),r=new P(c.SALT,16),i.getCachedDeviceKeyAndPassword(),s.getPasswordAuthenticationKey(i.username,e.getPassword(),n,r,(function(e,n){e&&t.onFailure(e);var r=o.getNowString(),a=S().lib.WordArray.create(v.lW.concat([v.lW.from(i.pool.getUserPoolName(),"utf8"),v.lW.from(i.username,"utf8"),v.lW.from(c.SECRET_BLOCK,"base64"),v.lW.from(r,"utf8")])),h=S().lib.WordArray.create(n),f=X().stringify(D()(a,h)),d={};d.USERNAME=i.username,d.PASSWORD_CLAIM_SECRET_BLOCK=c.SECRET_BLOCK,d.TIMESTAMP=r,d.PASSWORD_CLAIM_SIGNATURE=f,null!=i.deviceKey&&(d.DEVICE_KEY=i.deviceKey);var p={ChallengeName:"PASSWORD_VERIFIER",ClientId:i.pool.getClientId(),ChallengeResponses:d,Session:u.Session,ClientMetadata:l};i.getUserContextData()&&(p.UserContextData=i.getUserContextData()),function e(t,n){return i.client.request("RespondToAuthChallenge",t,(function(r,s){return r&&"ResourceNotFoundException"===r.code&&-1!==r.message.toLowerCase().indexOf("device")?(d.DEVICE_KEY=null,i.deviceKey=null,i.randomPassword=null,i.deviceGroupKey=null,i.clearCachedDeviceKeyAndPassword(),e(t,n)):n(r,s)}))}(p,(function(e,n){return e?t.onFailure(e):i.authenticateUserInternal(n,s,t)}))}))}))}))},t.authenticateUserPlainUsernamePassword=function(e,t){var n=this,r={};if(r.USERNAME=this.username,r.PASSWORD=e.getPassword(),r.PASSWORD){var i=new W(this.pool.getUserPoolName());this.getCachedDeviceKeyAndPassword(),null!=this.deviceKey&&(r.DEVICE_KEY=this.deviceKey);var s=0!==Object.keys(e.getValidationData()).length?e.getValidationData():e.getClientMetadata(),o={AuthFlow:"USER_PASSWORD_AUTH",ClientId:this.pool.getClientId(),AuthParameters:r,ClientMetadata:s};this.getUserContextData(this.username)&&(o.UserContextData=this.getUserContextData(this.username)),this.client.request("InitiateAuth",o,(function(e,r){return e?t.onFailure(e):n.authenticateUserInternal(r,i,t)}))}else t.onFailure(new Error("PASSWORD parameter is required"))},t.authenticateUserInternal=function(e,t,n){var r=this,i=e.ChallengeName,s=e.ChallengeParameters;if("SMS_MFA"===i)return this.Session=e.Session,n.mfaRequired(i,s);if("SELECT_MFA_TYPE"===i)return this.Session=e.Session,n.selectMFAType(i,s);if("MFA_SETUP"===i)return this.Session=e.Session,n.mfaSetup(i,s);if("SOFTWARE_TOKEN_MFA"===i)return this.Session=e.Session,n.totpRequired(i,s);if("CUSTOM_CHALLENGE"===i)return this.Session=e.Session,n.customChallenge(s);if("NEW_PASSWORD_REQUIRED"===i){this.Session=e.Session;var o=null,a=null,u=[],c=t.getNewPasswordRequiredChallengeUserAttributePrefix();if(s&&(o=JSON.parse(e.ChallengeParameters.userAttributes),a=JSON.parse(e.ChallengeParameters.requiredAttributes)),a)for(var l=0;l<a.length;l++)u[l]=a[l].substr(c.length);return n.newPasswordRequired(o,u)}if("DEVICE_SRP_AUTH"===i)return this.Session=e.Session,void this.getDeviceResponse(n);this.signInUserSession=this.getCognitoUserSession(e.AuthenticationResult),this.challengeName=i,this.cacheTokens();var h=e.AuthenticationResult.NewDeviceMetadata;if(null==h)return n.onSuccess(this.signInUserSession);t.generateHashDevice(e.AuthenticationResult.NewDeviceMetadata.DeviceGroupKey,e.AuthenticationResult.NewDeviceMetadata.DeviceKey,(function(i){if(i)return n.onFailure(i);var s={Salt:v.lW.from(t.getSaltDevices(),"hex").toString("base64"),PasswordVerifier:v.lW.from(t.getVerifierDevices(),"hex").toString("base64")};r.verifierDevices=s.PasswordVerifier,r.deviceGroupKey=h.DeviceGroupKey,r.randomPassword=t.getRandomPassword(),r.client.request("ConfirmDevice",{DeviceKey:h.DeviceKey,AccessToken:r.signInUserSession.getAccessToken().getJwtToken(),DeviceSecretVerifierConfig:s,DeviceName:ce},(function(t,i){return t?n.onFailure(t):(r.deviceKey=e.AuthenticationResult.NewDeviceMetadata.DeviceKey,r.cacheDeviceKeyAndPassword(),!0===i.UserConfirmationNecessary?n.onSuccess(r.signInUserSession,i.UserConfirmationNecessary):n.onSuccess(r.signInUserSession))}))}))},t.completeNewPasswordChallenge=function(e,t,n,r){var i=this;if(!e)return n.onFailure(new Error("New password is required."));var s=new W(this.pool.getUserPoolName()),o=s.getNewPasswordRequiredChallengeUserAttributePrefix(),a={};t&&Object.keys(t).forEach((function(e){a[o+e]=t[e]})),a.NEW_PASSWORD=e,a.USERNAME=this.username;var u={ChallengeName:"NEW_PASSWORD_REQUIRED",ClientId:this.pool.getClientId(),ChallengeResponses:a,Session:this.Session,ClientMetadata:r};this.getUserContextData()&&(u.UserContextData=this.getUserContextData()),this.client.request("RespondToAuthChallenge",u,(function(e,t){return e?n.onFailure(e):i.authenticateUserInternal(t,s,n)}))},t.getDeviceResponse=function(e,t){var n=this,r=new W(this.deviceGroupKey),i=new ie,s={};s.USERNAME=this.username,s.DEVICE_KEY=this.deviceKey,r.getLargeAValue((function(o,a){o&&e.onFailure(o),s.SRP_A=a.toString(16);var u={ChallengeName:"DEVICE_SRP_AUTH",ClientId:n.pool.getClientId(),ChallengeResponses:s,ClientMetadata:t,Session:n.Session};n.getUserContextData()&&(u.UserContextData=n.getUserContextData()),n.client.request("RespondToAuthChallenge",u,(function(t,s){if(t)return e.onFailure(t);var o=s.ChallengeParameters,a=new P(o.SRP_B,16),u=new P(o.SALT,16);r.getPasswordAuthenticationKey(n.deviceKey,n.randomPassword,a,u,(function(t,r){if(t)return e.onFailure(t);var a=i.getNowString(),u=S().lib.WordArray.create(v.lW.concat([v.lW.from(n.deviceGroupKey,"utf8"),v.lW.from(n.deviceKey,"utf8"),v.lW.from(o.SECRET_BLOCK,"base64"),v.lW.from(a,"utf8")])),c=S().lib.WordArray.create(r),l=X().stringify(D()(u,c)),h={};h.USERNAME=n.username,h.PASSWORD_CLAIM_SECRET_BLOCK=o.SECRET_BLOCK,h.TIMESTAMP=a,h.PASSWORD_CLAIM_SIGNATURE=l,h.DEVICE_KEY=n.deviceKey;var f={ChallengeName:"DEVICE_PASSWORD_VERIFIER",ClientId:n.pool.getClientId(),ChallengeResponses:h,Session:s.Session};n.getUserContextData()&&(f.UserContextData=n.getUserContextData()),n.client.request("RespondToAuthChallenge",f,(function(t,r){return t?e.onFailure(t):(n.signInUserSession=n.getCognitoUserSession(r.AuthenticationResult),n.cacheTokens(),e.onSuccess(n.signInUserSession))}))}))}))}))},t.confirmRegistration=function(e,t,n,r){var i={ClientId:this.pool.getClientId(),ConfirmationCode:e,Username:this.username,ForceAliasCreation:t,ClientMetadata:r};this.getUserContextData()&&(i.UserContextData=this.getUserContextData()),this.client.request("ConfirmSignUp",i,(function(e){return e?n(e,null):n(null,"SUCCESS")}))},t.sendCustomChallengeAnswer=function(e,t,n){var r=this,i={};i.USERNAME=this.username,i.ANSWER=e;var s=new W(this.pool.getUserPoolName());this.getCachedDeviceKeyAndPassword(),null!=this.deviceKey&&(i.DEVICE_KEY=this.deviceKey);var o={ChallengeName:"CUSTOM_CHALLENGE",ChallengeResponses:i,ClientId:this.pool.getClientId(),Session:this.Session,ClientMetadata:n};this.getUserContextData()&&(o.UserContextData=this.getUserContextData()),this.client.request("RespondToAuthChallenge",o,(function(e,n){return e?t.onFailure(e):r.authenticateUserInternal(n,s,t)}))},t.sendMFACode=function(e,t,n,r){var i=this,s={};s.USERNAME=this.username,s.SMS_MFA_CODE=e;var o=n||"SMS_MFA";"SOFTWARE_TOKEN_MFA"===o&&(s.SOFTWARE_TOKEN_MFA_CODE=e),null!=this.deviceKey&&(s.DEVICE_KEY=this.deviceKey);var a={ChallengeName:o,ChallengeResponses:s,ClientId:this.pool.getClientId(),Session:this.Session,ClientMetadata:r};this.getUserContextData()&&(a.UserContextData=this.getUserContextData()),this.client.request("RespondToAuthChallenge",a,(function(e,n){if(e)return t.onFailure(e);if("DEVICE_SRP_AUTH"!==n.ChallengeName){if(i.signInUserSession=i.getCognitoUserSession(n.AuthenticationResult),i.cacheTokens(),null==n.AuthenticationResult.NewDeviceMetadata)return t.onSuccess(i.signInUserSession);var r=new W(i.pool.getUserPoolName());r.generateHashDevice(n.AuthenticationResult.NewDeviceMetadata.DeviceGroupKey,n.AuthenticationResult.NewDeviceMetadata.DeviceKey,(function(e){if(e)return t.onFailure(e);var s={Salt:v.lW.from(r.getSaltDevices(),"hex").toString("base64"),PasswordVerifier:v.lW.from(r.getVerifierDevices(),"hex").toString("base64")};i.verifierDevices=s.PasswordVerifier,i.deviceGroupKey=n.AuthenticationResult.NewDeviceMetadata.DeviceGroupKey,i.randomPassword=r.getRandomPassword(),i.client.request("ConfirmDevice",{DeviceKey:n.AuthenticationResult.NewDeviceMetadata.DeviceKey,AccessToken:i.signInUserSession.getAccessToken().getJwtToken(),DeviceSecretVerifierConfig:s,DeviceName:ce},(function(e,r){return e?t.onFailure(e):(i.deviceKey=n.AuthenticationResult.NewDeviceMetadata.DeviceKey,i.cacheDeviceKeyAndPassword(),!0===r.UserConfirmationNecessary?t.onSuccess(i.signInUserSession,r.UserConfirmationNecessary):t.onSuccess(i.signInUserSession))}))}))}else i.getDeviceResponse(t)}))},t.changePassword=function(e,t,n,r){if(null==this.signInUserSession||!this.signInUserSession.isValid())return n(new Error("User is not authenticated"),null);this.client.request("ChangePassword",{PreviousPassword:e,ProposedPassword:t,AccessToken:this.signInUserSession.getAccessToken().getJwtToken(),ClientMetadata:r},(function(e){return e?n(e,null):n(null,"SUCCESS")}))},t.enableMFA=function(e){if(null==this.signInUserSession||!this.signInUserSession.isValid())return e(new Error("User is not authenticated"),null);var t=[];t.push({DeliveryMedium:"SMS",AttributeName:"phone_number"}),this.client.request("SetUserSettings",{MFAOptions:t,AccessToken:this.signInUserSession.getAccessToken().getJwtToken()},(function(t){return t?e(t,null):e(null,"SUCCESS")}))},t.setUserMfaPreference=function(e,t,n){if(null==this.signInUserSession||!this.signInUserSession.isValid())return n(new Error("User is not authenticated"),null);this.client.request("SetUserMFAPreference",{SMSMfaSettings:e,SoftwareTokenMfaSettings:t,AccessToken:this.signInUserSession.getAccessToken().getJwtToken()},(function(e){return e?n(e,null):n(null,"SUCCESS")}))},t.disableMFA=function(e){if(null==this.signInUserSession||!this.signInUserSession.isValid())return e(new Error("User is not authenticated"),null);this.client.request("SetUserSettings",{MFAOptions:[],AccessToken:this.signInUserSession.getAccessToken().getJwtToken()},(function(t){return t?e(t,null):e(null,"SUCCESS")}))},t.deleteUser=function(e,t){var n=this;if(null==this.signInUserSession||!this.signInUserSession.isValid())return e(new Error("User is not authenticated"),null);this.client.request("DeleteUser",{AccessToken:this.signInUserSession.getAccessToken().getJwtToken(),ClientMetadata:t},(function(t){return t?e(t,null):(n.clearCachedUser(),e(null,"SUCCESS"))}))},t.updateAttributes=function(e,t,n){var r=this;if(null==this.signInUserSession||!this.signInUserSession.isValid())return t(new Error("User is not authenticated"),null);this.client.request("UpdateUserAttributes",{AccessToken:this.signInUserSession.getAccessToken().getJwtToken(),UserAttributes:e,ClientMetadata:n},(function(e){return e?t(e,null):r.getUserData((function(){return t(null,"SUCCESS")}),{bypassCache:!0})}))},t.getUserAttributes=function(e){if(null==this.signInUserSession||!this.signInUserSession.isValid())return e(new Error("User is not authenticated"),null);this.client.request("GetUser",{AccessToken:this.signInUserSession.getAccessToken().getJwtToken()},(function(t,n){if(t)return e(t,null);for(var r=[],i=0;i<n.UserAttributes.length;i++){var s={Name:n.UserAttributes[i].Name,Value:n.UserAttributes[i].Value},o=new se(s);r.push(o)}return e(null,r)}))},t.getMFAOptions=function(e){if(null==this.signInUserSession||!this.signInUserSession.isValid())return e(new Error("User is not authenticated"),null);this.client.request("GetUser",{AccessToken:this.signInUserSession.getAccessToken().getJwtToken()},(function(t,n){return t?e(t,null):e(null,n.MFAOptions)}))},t.createGetUserRequest=function(){return this.client.promisifyRequest("GetUser",{AccessToken:this.signInUserSession.getAccessToken().getJwtToken()})},t.refreshSessionIfPossible=function(e){var t=this;return void 0===e&&(e={}),new Promise((function(n){var r=t.signInUserSession.getRefreshToken();r&&r.getToken()?t.refreshSession(r,n,e.clientMetadata):n()}))},t.getUserData=function(e,t){var n=this;if(null==this.signInUserSession||!this.signInUserSession.isValid())return this.clearCachedUserData(),e(new Error("User is not authenticated"),null);var r=this.getUserDataFromCache();if(r)if(this.isFetchUserDataAndTokenRequired(t))this.fetchUserData().then((function(e){return n.refreshSessionIfPossible(t).then((function(){return e}))})).then((function(t){return e(null,t)})).catch(e);else try{return void e(null,JSON.parse(r))}catch(t){return this.clearCachedUserData(),void e(t,null)}else this.fetchUserData().then((function(t){e(null,t)})).catch(e)},t.getUserDataFromCache=function(){return this.storage.getItem(this.userDataKey)},t.isFetchUserDataAndTokenRequired=function(e){var t=(e||{}).bypassCache;return void 0!==t&&t},t.fetchUserData=function(){var e=this;return this.createGetUserRequest().then((function(t){return e.cacheUserData(t),t}))},t.deleteAttributes=function(e,t){var n=this;if(null==this.signInUserSession||!this.signInUserSession.isValid())return t(new Error("User is not authenticated"),null);this.client.request("DeleteUserAttributes",{UserAttributeNames:e,AccessToken:this.signInUserSession.getAccessToken().getJwtToken()},(function(e){return e?t(e,null):n.getUserData((function(){return t(null,"SUCCESS")}),{bypassCache:!0})}))},t.resendConfirmationCode=function(e,t){var n={ClientId:this.pool.getClientId(),Username:this.username,ClientMetadata:t};this.client.request("ResendConfirmationCode",n,(function(t,n){return t?e(t,null):e(null,n)}))},t.getSession=function(e,t){if(void 0===t&&(t={}),null==this.username)return e(new Error("Username is null. Cannot retrieve a new session"),null);if(null!=this.signInUserSession&&this.signInUserSession.isValid())return e(null,this.signInUserSession);var n="CognitoIdentityServiceProvider."+this.pool.getClientId()+"."+this.username,r=n+".idToken",i=n+".accessToken",s=n+".refreshToken",o=n+".clockDrift";if(this.storage.getItem(r)){var a=new G({IdToken:this.storage.getItem(r)}),u=new Y({AccessToken:this.storage.getItem(i)}),c=new ee({RefreshToken:this.storage.getItem(s)}),l=parseInt(this.storage.getItem(o),0)||0,h=new te({IdToken:a,AccessToken:u,RefreshToken:c,ClockDrift:l});if(h.isValid())return this.signInUserSession=h,e(null,this.signInUserSession);if(!c.getToken())return e(new Error("Cannot retrieve a new session. Please authenticate."),null);this.refreshSession(c,e,t.clientMetadata)}else e(new Error("Local storage is missing an ID Token, Please authenticate"),null)},t.refreshSession=function(e,t,n){var r=this,i=this.pool.wrapRefreshSessionCallback?this.pool.wrapRefreshSessionCallback(t):t,s={};s.REFRESH_TOKEN=e.getToken();var o="CognitoIdentityServiceProvider."+this.pool.getClientId(),a=o+".LastAuthUser";if(this.storage.getItem(a)){this.username=this.storage.getItem(a);var u=o+"."+this.username+".deviceKey";this.deviceKey=this.storage.getItem(u),s.DEVICE_KEY=this.deviceKey}var c={ClientId:this.pool.getClientId(),AuthFlow:"REFRESH_TOKEN_AUTH",AuthParameters:s,ClientMetadata:n};this.getUserContextData()&&(c.UserContextData=this.getUserContextData()),this.client.request("InitiateAuth",c,(function(t,n){if(t)return"NotAuthorizedException"===t.code&&r.clearCachedUser(),i(t,null);if(n){var s=n.AuthenticationResult;return Object.prototype.hasOwnProperty.call(s,"RefreshToken")||(s.RefreshToken=e.getToken()),r.signInUserSession=r.getCognitoUserSession(s),r.cacheTokens(),i(null,r.signInUserSession)}}))},t.cacheTokens=function(){var e="CognitoIdentityServiceProvider."+this.pool.getClientId(),t=e+"."+this.username+".idToken",n=e+"."+this.username+".accessToken",r=e+"."+this.username+".refreshToken",i=e+"."+this.username+".clockDrift",s=e+".LastAuthUser";this.storage.setItem(t,this.signInUserSession.getIdToken().getJwtToken()),this.storage.setItem(n,this.signInUserSession.getAccessToken().getJwtToken()),this.storage.setItem(r,this.signInUserSession.getRefreshToken().getToken()),this.storage.setItem(i,""+this.signInUserSession.getClockDrift()),this.storage.setItem(s,this.username)},t.cacheUserData=function(e){this.storage.setItem(this.userDataKey,JSON.stringify(e))},t.clearCachedUserData=function(){this.storage.removeItem(this.userDataKey)},t.clearCachedUser=function(){this.clearCachedTokens(),this.clearCachedUserData()},t.cacheDeviceKeyAndPassword=function(){var e="CognitoIdentityServiceProvider."+this.pool.getClientId()+"."+this.username,t=e+".deviceKey",n=e+".randomPasswordKey",r=e+".deviceGroupKey";this.storage.setItem(t,this.deviceKey),this.storage.setItem(n,this.randomPassword),this.storage.setItem(r,this.deviceGroupKey)},t.getCachedDeviceKeyAndPassword=function(){var e="CognitoIdentityServiceProvider."+this.pool.getClientId()+"."+this.username,t=e+".deviceKey",n=e+".randomPasswordKey",r=e+".deviceGroupKey";this.storage.getItem(t)&&(this.deviceKey=this.storage.getItem(t),this.randomPassword=this.storage.getItem(n),this.deviceGroupKey=this.storage.getItem(r))},t.clearCachedDeviceKeyAndPassword=function(){var e="CognitoIdentityServiceProvider."+this.pool.getClientId()+"."+this.username,t=e+".deviceKey",n=e+".randomPasswordKey",r=e+".deviceGroupKey";this.storage.removeItem(t),this.storage.removeItem(n),this.storage.removeItem(r)},t.clearCachedTokens=function(){var e="CognitoIdentityServiceProvider."+this.pool.getClientId(),t=e+"."+this.username+".idToken",n=e+"."+this.username+".accessToken",r=e+"."+this.username+".refreshToken",i=e+".LastAuthUser",s=e+"."+this.username+".clockDrift";this.storage.removeItem(t),this.storage.removeItem(n),this.storage.removeItem(r),this.storage.removeItem(i),this.storage.removeItem(s)},t.getCognitoUserSession=function(e){var t=new G(e),n=new Y(e),r=new ee(e);return new te({IdToken:t,AccessToken:n,RefreshToken:r})},t.forgotPassword=function(e,t){var n={ClientId:this.pool.getClientId(),Username:this.username,ClientMetadata:t};this.getUserContextData()&&(n.UserContextData=this.getUserContextData()),this.client.request("ForgotPassword",n,(function(t,n){return t?e.onFailure(t):"function"==typeof e.inputVerificationCode?e.inputVerificationCode(n):e.onSuccess(n)}))},t.confirmPassword=function(e,t,n,r){var i={ClientId:this.pool.getClientId(),Username:this.username,ConfirmationCode:e,Password:t,ClientMetadata:r};this.getUserContextData()&&(i.UserContextData=this.getUserContextData()),this.client.request("ConfirmForgotPassword",i,(function(e){return e?n.onFailure(e):n.onSuccess("SUCCESS")}))},t.getAttributeVerificationCode=function(e,t,n){if(null==this.signInUserSession||!this.signInUserSession.isValid())return t.onFailure(new Error("User is not authenticated"));this.client.request("GetUserAttributeVerificationCode",{AttributeName:e,AccessToken:this.signInUserSession.getAccessToken().getJwtToken(),ClientMetadata:n},(function(e,n){return e?t.onFailure(e):"function"==typeof t.inputVerificationCode?t.inputVerificationCode(n):t.onSuccess("SUCCESS")}))},t.verifyAttribute=function(e,t,n){if(null==this.signInUserSession||!this.signInUserSession.isValid())return n.onFailure(new Error("User is not authenticated"));this.client.request("VerifyUserAttribute",{AttributeName:e,Code:t,AccessToken:this.signInUserSession.getAccessToken().getJwtToken()},(function(e){return e?n.onFailure(e):n.onSuccess("SUCCESS")}))},t.getDevice=function(e){if(null==this.signInUserSession||!this.signInUserSession.isValid())return e.onFailure(new Error("User is not authenticated"));this.client.request("GetDevice",{AccessToken:this.signInUserSession.getAccessToken().getJwtToken(),DeviceKey:this.deviceKey},(function(t,n){return t?e.onFailure(t):e.onSuccess(n)}))},t.forgetSpecificDevice=function(e,t){if(null==this.signInUserSession||!this.signInUserSession.isValid())return t.onFailure(new Error("User is not authenticated"));this.client.request("ForgetDevice",{AccessToken:this.signInUserSession.getAccessToken().getJwtToken(),DeviceKey:e},(function(e){return e?t.onFailure(e):t.onSuccess("SUCCESS")}))},t.forgetDevice=function(e){var t=this;this.forgetSpecificDevice(this.deviceKey,{onFailure:e.onFailure,onSuccess:function(n){return t.deviceKey=null,t.deviceGroupKey=null,t.randomPassword=null,t.clearCachedDeviceKeyAndPassword(),e.onSuccess(n)}})},t.setDeviceStatusRemembered=function(e){if(null==this.signInUserSession||!this.signInUserSession.isValid())return e.onFailure(new Error("User is not authenticated"));this.client.request("UpdateDeviceStatus",{AccessToken:this.signInUserSession.getAccessToken().getJwtToken(),DeviceKey:this.deviceKey,DeviceRememberedStatus:"remembered"},(function(t){return t?e.onFailure(t):e.onSuccess("SUCCESS")}))},t.setDeviceStatusNotRemembered=function(e){if(null==this.signInUserSession||!this.signInUserSession.isValid())return e.onFailure(new Error("User is not authenticated"));this.client.request("UpdateDeviceStatus",{AccessToken:this.signInUserSession.getAccessToken().getJwtToken(),DeviceKey:this.deviceKey,DeviceRememberedStatus:"not_remembered"},(function(t){return t?e.onFailure(t):e.onSuccess("SUCCESS")}))},t.listDevices=function(e,t,n){if(null==this.signInUserSession||!this.signInUserSession.isValid())return n.onFailure(new Error("User is not authenticated"));var r={AccessToken:this.signInUserSession.getAccessToken().getJwtToken(),Limit:e};t&&(r.PaginationToken=t),this.client.request("ListDevices",r,(function(e,t){return e?n.onFailure(e):n.onSuccess(t)}))},t.globalSignOut=function(e){var t=this;if(null==this.signInUserSession||!this.signInUserSession.isValid())return e.onFailure(new Error("User is not authenticated"));this.client.request("GlobalSignOut",{AccessToken:this.signInUserSession.getAccessToken().getJwtToken()},(function(n){return n?e.onFailure(n):(t.clearCachedUser(),e.onSuccess("SUCCESS"))}))},t.signOut=function(e){var t=this;e&&"function"==typeof e?this.getSession((function(n,r){if(n)return e(n);t.revokeTokens((function(n){t.cleanClientData(),e(n)}))})):this.cleanClientData()},t.revokeTokens=function(e){if(void 0===e&&(e=function(){}),"function"!=typeof e)throw new Error("Invalid revokeTokenCallback. It should be a function.");if(!this.signInUserSession)return e(new Error("User is not authenticated"));if(!this.signInUserSession.getAccessToken())return e(new Error("No Access token available"));var t=this.signInUserSession.getRefreshToken().getToken(),n=this.signInUserSession.getAccessToken();if(this.isSessionRevocable(n)&&t)return this.revokeToken({token:t,callback:e});e()},t.isSessionRevocable=function(e){if(e&&"function"==typeof e.decodePayload)try{return!!e.decodePayload().origin_jti}catch(e){}return!1},t.cleanClientData=function(){this.signInUserSession=null,this.clearCachedUser()},t.revokeToken=function(e){var t=e.token,n=e.callback;this.client.requestWithRetry("RevokeToken",{Token:t,ClientId:this.pool.getClientId()},(function(e){if(e)return n(e);n()}))},t.sendMFASelectionAnswer=function(e,t){var n=this,r={};r.USERNAME=this.username,r.ANSWER=e;var i={ChallengeName:"SELECT_MFA_TYPE",ChallengeResponses:r,ClientId:this.pool.getClientId(),Session:this.Session};this.getUserContextData()&&(i.UserContextData=this.getUserContextData()),this.client.request("RespondToAuthChallenge",i,(function(r,i){return r?t.onFailure(r):(n.Session=i.Session,"SMS_MFA"===e?t.mfaRequired(i.ChallengeName,i.ChallengeParameters):"SOFTWARE_TOKEN_MFA"===e?t.totpRequired(i.ChallengeName,i.ChallengeParameters):void 0)}))},t.getUserContextData=function(){return this.pool.getUserContextData(this.username)},t.associateSoftwareToken=function(e){var t=this;null!=this.signInUserSession&&this.signInUserSession.isValid()?this.client.request("AssociateSoftwareToken",{AccessToken:this.signInUserSession.getAccessToken().getJwtToken()},(function(t,n){return t?e.onFailure(t):e.associateSecretCode(n.SecretCode)})):this.client.request("AssociateSoftwareToken",{Session:this.Session},(function(n,r){return n?e.onFailure(n):(t.Session=r.Session,e.associateSecretCode(r.SecretCode))}))},t.verifySoftwareToken=function(e,t,n){var r=this;null!=this.signInUserSession&&this.signInUserSession.isValid()?this.client.request("VerifySoftwareToken",{AccessToken:this.signInUserSession.getAccessToken().getJwtToken(),UserCode:e,FriendlyDeviceName:t},(function(e,t){return e?n.onFailure(e):n.onSuccess(t)})):this.client.request("VerifySoftwareToken",{Session:this.Session,UserCode:e,FriendlyDeviceName:t},(function(e,t){if(e)return n.onFailure(e);r.Session=t.Session;var i={};i.USERNAME=r.username;var s={ChallengeName:"MFA_SETUP",ClientId:r.pool.getClientId(),ChallengeResponses:i,Session:r.Session};r.getUserContextData()&&(s.UserContextData=r.getUserContextData()),r.client.request("RespondToAuthChallenge",s,(function(e,t){return e?n.onFailure(e):(r.signInUserSession=r.getCognitoUserSession(t.AuthenticationResult),r.cacheTokens(),n.onSuccess(r.signInUserSession))}))}))},e}(),he=(n(204),"aws-amplify/5.0.4"),fe={userAgent:he+" js",product:"",navigator:null,isReactNative:!1};function de(){}"undefined"!=typeof navigator&&navigator.product&&(fe.product=navigator.product||"",fe.navigator=navigator||null,"ReactNative"===navigator.product?(fe.userAgent=he+" react-native",fe.isReactNative=!0):(fe.userAgent=he+" js",fe.isReactNative=!1)),de.prototype.userAgent=fe.userAgent;const pe=de;function ge(e){var t="function"==typeof Map?new Map:void 0;return ge=function(e){if(null===e||(n=e,-1===Function.toString.call(n).indexOf("[native code]")))return e;var n;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,r)}function r(){return ye(e,arguments,me(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),we(r,e)},ge(e)}function ye(e,t,n){return ye=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}()?Reflect.construct.bind():function(e,t,n){var r=[null];r.push.apply(r,t);var i=new(Function.bind.apply(e,r));return n&&we(i,n.prototype),i},ye.apply(null,arguments)}function we(e,t){return we=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},we(e,t)}function me(e){return me=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},me(e)}var be=function(e){function t(t,n,r,i){var s;return(s=e.call(this,t)||this).code=n,s.name=r,s.statusCode=i,s}return r=e,(n=t).prototype=Object.create(r.prototype),n.prototype.constructor=n,we(n,r),t;var n,r}(ge(Error)),_e=function(){function e(e,t,n){this.endpoint=t||"https://cognito-idp."+e+".amazonaws.com/";var r=(n||{}).credentials;this.fetchOptions=r?{credentials:r}:{}}var t=e.prototype;return t.promisifyRequest=function(e,t){var n=this;return new Promise((function(r,i){n.request(e,t,(function(e,t){e?i(new be(e.message,e.code,e.name,e.statusCode)):r(t)}))}))},t.requestWithRetry=function(e,t,n){var r,i,s=this;(r=[t],i=5e3,void 0===i&&(i=Se),Ee((function(t){return new Promise((function(n,r){s.request(e,t,(function(e,t){e?r(e):n(t)}))}))}),r,function(e){return function(t){var n=100*Math.pow(2,t)+100*Math.random();return!(n>e)&&n}}(i))).then((function(e){return n(null,e)})).catch((function(e){return n(e)}))},t.request=function(e,t,n){var r,i={"Content-Type":"application/x-amz-json-1.1","X-Amz-Target":"AWSCognitoIdentityProviderService."+e,"X-Amz-User-Agent":pe.prototype.userAgent,"Cache-Control":"no-store"},s=Object.assign({},this.fetchOptions,{headers:i,method:"POST",mode:"cors",body:JSON.stringify(t)});fetch(this.endpoint,s).then((function(e){return r=e,e}),(function(e){if(e instanceof TypeError)throw new Error("Network error");throw e})).then((function(e){return e.json().catch((function(){return{}}))})).then((function(e){if(r.ok)return n(null,e);var t=(e.__type||e.code).split("#").pop(),i=new Error(e.message||e.Message||null);return i.name=t,i.code=t,n(i)})).catch((function(e){if(r&&r.headers&&r.headers.get("x-amzn-errortype"))try{var t=r.headers.get("x-amzn-errortype").split(":")[0],i=new Error(r.status?r.status.toString():null);return i.code=t,i.name=t,i.statusCode=r.status,n(i)}catch(t){return n(e)}else e instanceof Error&&"Network error"===e.message&&(e.code="NetworkError");return n(e)}))},e}(),Ae={debug:function(){}},ve=function(e){return e&&e.nonRetryable};function Ee(e,t,n,r){if(void 0===r&&(r=1),"function"!=typeof e)throw Error("functionToRetry must be a function");return Ae.debug(e.name+" attempt #"+r+" with args: "+JSON.stringify(t)),e.apply(void 0,t).catch((function(i){if(Ae.debug("error on "+e.name,i),ve(i))throw Ae.debug(e.name+" non retryable error",i),i;var s=n(r,t,i);if(Ae.debug(e.name+" retrying in "+s+" ms"),!1!==s)return new Promise((function(e){return setTimeout(e,s)})).then((function(){return Ee(e,t,n,r+1)}));throw i}))}var Se=3e5,Ie=function(){function e(e,t){var n=e||{},r=n.UserPoolId,i=n.ClientId,s=n.endpoint,o=n.fetchOptions,a=n.AdvancedSecurityDataCollectionFlag;if(!r||!i)throw new Error("Both UserPoolId and ClientId are required.");if(r.length>55||!/^[\w-]+_[0-9a-zA-Z]+$/.test(r))throw new Error("Invalid UserPoolId format.");var u=r.split("_")[0];this.userPoolId=r,this.clientId=i,this.client=new _e(u,s,o),this.advancedSecurityDataCollectionFlag=!1!==a,this.storage=e.Storage||(new ue).getStorage(),t&&(this.wrapRefreshSessionCallback=t)}var t=e.prototype;return t.getUserPoolId=function(){return this.userPoolId},t.getUserPoolName=function(){return this.getUserPoolId().split("_")[1]},t.getClientId=function(){return this.clientId},t.signUp=function(e,t,n,r,i,s){var o=this,a={ClientId:this.clientId,Username:e,Password:t,UserAttributes:n,ValidationData:r,ClientMetadata:s};this.getUserContextData(e)&&(a.UserContextData=this.getUserContextData(e)),this.client.request("SignUp",a,(function(t,n){if(t)return i(t,null);var r={Username:e,Pool:o,Storage:o.storage},s={user:new le(r),userConfirmed:n.UserConfirmed,userSub:n.UserSub,codeDeliveryDetails:n.CodeDeliveryDetails};return i(null,s)}))},t.getCurrentUser=function(){var e="CognitoIdentityServiceProvider."+this.clientId+".LastAuthUser",t=this.storage.getItem(e);if(t){var n={Username:t,Pool:this,Storage:this.storage};return new le(n)}return null},t.getUserContextData=function(e){if("undefined"!=typeof AmazonCognitoAdvancedSecurityData){var t=AmazonCognitoAdvancedSecurityData;if(this.advancedSecurityDataCollectionFlag){var n=t.getData(e,this.userPoolId,this.clientId);if(n)return{EncodedData:n}}return{}}},e}();n(808);let Te=null,Re=null;function De(){if(!Re)throw new e("User pool is missing",{code:"INVALID_REQUEST"});const n=t=>{let n={};if(Array.isArray(t)){let n={};for(let r of t)if(n[r.Name]=r.Value,"custom:service"===r.Name&&n[r.Name]!==this.service)throw new e("The user is not registered to the service.",{code:"INVALID_REQUEST"});t=n}for(let r in t)if(r.includes("custom:")){if("custom:service"===r&&t[r]!==this.service)throw new e("The user is not registered to the service.",{code:"INVALID_REQUEST"});n[r.replace("custom:","")]=t[r]}else{if("address"===r){let e=t[r];if(e&&"object"==typeof e&&Object.keys(e).length&&e?.formatted)try{t[r]=JSON.parse(e.formatted)}catch(n){t[r]=e.formatted}}n[r]=t[r]}for(let e of["address_public","birthdate_public","email_public","gender_public","phone_number_public","access_group"])e.includes("_public")?n.hasOwnProperty(e.split("_")[0])?n[e]=!!n.hasOwnProperty(e)&&!!Number(n[e]):delete n[e]:n[e]=n.hasOwnProperty(e)?Number(n[e]):0;for(let e of["email","phone_number"])n.hasOwnProperty(e)?!0===n[e+"_verified"]||"true"===n[e+"_verified"]?n[e+"_verified"]=!0:n[e+"_verified"]=!1:delete n[e+"_verified"];for(let e of["aud",{from:"auth_time",to:"log"},"cognito:username","event_id","exp","iat","iss","jti","origin_jti","secret_key",{from:"sub",to:"user_id"},"token_use"])"string"==typeof e?delete n[e]:(n[e.to]=n[e.from],delete n[e.from]);this.__user=n},r=t=>{let{refreshToken:r=!1}=t||{};return new Promise(((t,i)=>{Te=Re?.getCurrentUser()||null,null!==Te?Te.getSession(((s,o)=>{if(s)i(s);else if(o)if(r||!o.isValid()){let r=!1;try{o.getIdToken().payload["custom:service"]!==this.service&&(Te.signOut(),this.session=null,r=!0,t(null))}catch(s){}r||Te.refreshSession(o.getRefreshToken(),((r,s)=>{if(r)i(r);else{if(!s.isValid())return void i(new e("Invalid session.",{code:"INVALID_REQUEST"}));this.session=s,n(s.getIdToken().payload),t(s)}}))}else{let e=o.getIdToken().payload;e["custom:service"]!==this.service?(Te.signOut(),this.session=null,t(null)):(this.session=o,n(e),t(o))}else i(new e("Current session does not exist.",{code:"INVALID_REQUEST"}))})):i(null)}))},i=async n=>{if(!n)throw new e("E-Mail is required.",{code:"INVALID_PARAMETER"});let r=this.service+"-"+t.hash(n);return{cognitoUser:new le({Username:r,Pool:Re}),cognitoUsername:r}};return{getSession:r,authenticateUser:(t,n)=>new Promise(((s,o)=>{this.__request_signup_confirmation=null,this.__disabledAccount=null,i(t).then((t=>{Te=t.cognitoUser;let i=t.cognitoUsername,a=new A({Username:i,Password:n});Te.authenticateUser(a,{newPasswordRequired:(t,n)=>{this.__request_signup_confirmation=i,o(new e("User's signup confirmation is required.",{code:"SIGNUP_CONFIRMATION_NEEDED"}))},onSuccess:e=>r().then((e=>s(this.user))),onFailure:t=>{let n=[t.message||"Failed to authenticate user.",t?.code||"INVALID_REQUEST"];"NotAuthorizedException"===t.code&&("User is disabled."===t.message?(this.__disabledAccount=i,n=["This account is disabled.","USER_IS_DISABLED"]):n=["Incorrect username or password.","INCORRECT_USERNAME_OR_PASSWORD"]);let r=n[1],s=n[0],a=n[0].split("#");a.length>1&&(a=a[a.length-1].split(":"),r=a[0],s=a[1]),o(new e(s,{code:r,cause:t}))}})}))})),createCognitoUser:i,getUser:()=>new Promise(((t,r)=>{this.session||t(null),null===Te?r(new e("Invalid session",{code:"INVALID_REQUEST"})):Te.getUserAttributes(((e,i)=>{e?r(e):(n(i),t(this.user))}))}))}}async function Ue(e){await this.__connection;try{return await De.bind(this)().getSession(e),this.user}catch(e){return null}}async function Ce(){return await this.__connection,this.__user?.service===this.service?this.__user?.owner===this.host:(await Pe.bind(this)(),!1)}async function Pe(e){await this.__connection,Te&&Te.signOut();let t={session:null,__startKeyHistory:{},__cached_requests:{},__user:null};for(let e in t)this[e]=t[e];return"SUCCESS: The user has been logged out."}async function Ne(t){if(!this.__request_signup_confirmation)throw new e("Least one login attempt is required.",{code:"INVALID_REQUEST"});return t=t?s.Url(t):void 0,await c.bind(this)("confirm-signup",{username:this.__request_signup_confirmation,redirect:t})}async function ke(t=!1){if("string"==typeof t)s.Url(t);else if("boolean"!=typeof t)throw new e("Argument should be type: <boolean | string>.",{code:"INVALID_REQUEST"});if(!this.__disabledAccount)throw new e("Least one signin attempt of disabled account is required.",{code:"INVALID_REQUEST"});return await c.bind(this)("recover-account",{username:this.__disabledAccount,redirect:t}),this.__disabledAccount=null,"SUCCESS: Recovery e-mail has been sent."}async function Oe(e,t){await Pe.bind(this)();let n=s.Params(e,{email:e=>s.Email(e),password:e=>s.Password(e)},["email","password"]);return De.bind(this)().authenticateUser(n.email,n.password)}async function Me(t,n){await this.logout();let r=s.Params(t||{},{email:e=>s.Email(e),password:e=>s.Password(e),name:"string",address:"string",gender:"string",birthdate:e=>s.Birthdate(e),phone_number:e=>s.PhoneNumber(e),email_public:["boolean",()=>!1],address_public:["boolean",()=>!1],gender_public:["boolean",()=>!1],birthdate_public:["boolean",()=>!1],phone_number_public:["boolean",()=>!1],misc:"string"},["email","password"]);n=s.Params(n||{},{email_subscription:t=>{if("boolean"!=typeof t)throw new e('"option.email_subscription" should be type: <boolean>.',{code:"INVALID_PARAMETER"});if(!n?.signup_confirmation)throw new e('"option.signup_confirmation" is required for email subscription.',{code:"INVALID_PARAMETER"});return t},signup_confirmation:t=>{if("string"==typeof t)return s.Url(t);if("boolean"==typeof t)return t;throw new e('"option.signup_confirmation" should be type: <string | boolean>.',{code:"INVALID_PARAMETER"})},login:t=>{if("boolean"==typeof t){if(n.signup_confirmation&&t)throw new e('"login" is not allowed when "option.signup_confirmation" is true.',{code:"INVALID_PARAMETER"});return t}throw new e('"option.login" should be type: boolean.',{code:"INVALID_PARAMETER"})}});let i=n?.login||!1,o=n?.signup_confirmation||!1;if(r.email_public&&!o)throw new e('"option.signup_confirmation" should be true if "email_public" is set to true.',{code:"INVALID_PARAMETER"});if(r.signup_confirmation=o,r.email_subscription=n?.email_subscription||!1,await c.bind(this)("signup",r),o){let e=await De.bind(this)().createCognitoUser(r.email);return Te=e.cognitoUser,this.__request_signup_confirmation=e.cognitoUsername,"SUCCESS: The account has been created. User's signup confirmation is required."}return i?Oe.bind(this)({email:r.email,password:r.password}):"SUCCESS: The account has been created."}async function Fe(){await this.__connection;let e=await c.bind(this)("remove-account",{disable:this.__user.user_id},{auth:!0});return await Pe.bind(this)(),e}async function Ve(t,n){await this.__connection;let r=s.Params(t,{email:e=>s.Email(e),code:["number","string"],new_password:e=>s.Password(e)},["email","code","new_password"]),i=r.code,o=r.new_password;return"number"==typeof i&&(i=i.toString()),new Promise((async(t,n)=>{(await De.bind(this)().createCognitoUser(r.email)).cognitoUser.confirmPassword(i,o,{onSuccess:e=>{t("SUCCESS: New password has been set.")},onFailure:t=>{n(new e(t?.message||"Failed to reset password.",{code:t?.code}))}})}))}async function xe(t,n){let r;if(await this.__connection,!Te)throw new e("The user has to be logged in.",{code:"INVALID_REQUEST"});if("email"===t||"phone_number"===t){if(!this.__user.hasOwnProperty(t))throw new e(`No ${"email"===t?"e-mail":"phone number"} to verify`,{code:"INVALID_REQUEST"});return this.__user?.[`${t}_verified`]?`SUCCESS: "${t}" is verified.`:(r=(n?s.Params(n,{code:["string"]}):{}).code||"",new Promise(((n,i)=>{let s={onSuccess:e=>{r?De.bind(this)().getSession({refreshToken:!0}).then((()=>{this.__user&&(this.__user[t+"_verified"]=!0),n(`SUCCESS: "${t}" is verified.`)})).catch((e=>{i(e)})):n("SUCCESS: Verification code has been sent.")},onFailure:t=>{i(new e(t.message||"Failed to request verification code.",{code:t?.code}))}};r?Te?.verifyAttribute(t,r,s):(s.inputVerificationCode=null,Te?.getAttributeVerificationCode(t,s))})))}}function Le(e){return xe.bind(this)("phone_number",e)}function Be(e){return xe.bind(this)("email",e)}async function $e(t,n){await this.__connection;let r=s.Params(t,{email:e=>s.Email(e)},["email"]);return new Promise((async(t,n)=>{(await De.bind(this)().createCognitoUser(r.email)).cognitoUser.forgotPassword({onSuccess:e=>{t("SUCCESS: Verification code has been sent.")},onFailure:t=>{n(new e(t?.message||"Failed to send verification code.",{code:t?.code||"ERROR"}))}})}))}async function qe(t){if(await this.__connection,!this.session)throw new e("User login is required.",{code:"INVALID_REQUEST"});let n=s.Params(t,{current_password:"string",new_password:"string"});if(!n?.current_password)throw new e('"current_password" is required to change password.',{code:"INVALID_PARAMETER"});if(!n?.new_password)throw new e('"new_password" is required to change password.',{code:"INVALID_PARAMETER"});return s.Password(n.current_password),s.Password(n.new_password),new Promise(((t,r)=>{Te.changePassword(n.current_password,n.new_password,((n,i)=>{n&&r("InvalidParameterException"===n?.code?new e("Invalid password parameter.",{code:"INVALID_PARAMETER"}):"NotAuthorizedException"===n?.code?new e("Incorrect password.",{code:"INVALID_REQUEST"}):new e(n?.message||"Failed to change user password.",{code:n?.code||n?.name})),t("SUCCESS: Password has been changed.")}))}))}async function Ke(n,r){if(await this.__connection,!this.session)throw new e("User login is required.",{code:"INVALID_REQUEST"});let i=s.Params(n||{},{email:e=>s.Email(e),address:e=>e?"string"==typeof e?e:"object"==typeof e?JSON.stringify(e):"":"",name:"string",gender:"string",birthdate:e=>s.Birthdate(e),phone_number:e=>s.PhoneNumber(e),email_public:"boolean",phone_number_public:"boolean",address_public:"boolean",gender_public:"boolean",birthdate_public:"boolean",misc:"string"});if(i&&"object"==typeof i&&!Object.keys(i).length)return this.user;i.email&&(i.preferred_username=this.service+"-"+t.hash(i.email));let o=[["email_public","email_verified","User's E-Mail should be verified to set"],["phone_number_public","phone_number_verified","User's phone number should be verified to set"]];if(this.__user)for(let t of o)if(i[t[0]]&&!this.__user[t[1]])throw new e(`${t[2]} "${t[0]}" to true.`,{code:"INVALID_REQUEST"});let a=[];for(let e in i)if(i[e]!==this.user[e]){if(["email_public","phone_number_public","address_public","gender_public","birthdate_public","misc"].includes(e)){let t=i[e];"boolean"==typeof t&&(t=t?"1":"0"),i["custom:"+e]=t,a.push(e)}}else a.push(e);for(let e of a)delete i[e];if(i&&"object"==typeof i&&Object.keys(i).length){let e=[];for(let t in i)e.push(new se({Name:t,Value:i[t]}));return await new Promise(((t,n)=>{Te?.updateAttributes(e,((e,r)=>{e&&n([e?.code||e?.name,e?.message||"Failed to update user settings."]),t(r)}))})),await De.bind(this)().getSession({refreshToken:!0}),this.user}return this.user}async function je(t,n){if(t||(t={searchFor:"timestamp",condition:">",value:0},n||(n={}),n.ascending=!1),await Ce.bind(this)()&&!t.hasOwnProperty("service"))throw new e("Service ID is required.",{code:"INVALID_PARAMETER"});const r={user_id:e=>s.UserId(e),name:"string",email:e=>s.Email(e),phone_number:e=>s.PhoneNumber(e),address:"string",gender:"string",birthdate:e=>s.Birthdate(e),locale:t=>{if("string"!=typeof t||"string"==typeof t&&t.length>5)throw new e('Value of "locale" should be a country code.',{code:"INVALID_PARAMETER"});return t},timestamp:"number",access_group:"number",approved:e=>e?"by_admin:approved":"by_admin:suspended"};if(t=s.Params(t,{searchFor:["user_id","name","email","phone_number","address","gender","birthdate","locale","subscribers","timestamp","access_group","approved"],condition:[">",">=","=","<","<=","gt","gte","eq","lt","lte",()=>"="],value:n=>{let i=r[t.searchFor];if("function"==typeof i)return i(n);if(typeof n!==i)throw new e(`Value does not match the type of "${t.searchFor}" index.`,{code:"INVALID_PARAMETER"});return n},range:n=>{let i=r[t.searchFor];if("function"==typeof i)return i(n);if(typeof n!==i)throw new e(`Range does not match the type of "${t.searchFor}" index.`,{code:"INVALID_PARAMETER"});return n}},["searchFor","value"]),t?.condition&&"="!==t?.condition&&t.hasOwnProperty("range"))throw new e("Conditions does not apply on range search.",{code:"INVALID_PARAMETER"});if("user_id"===t.searchFor&&"="!==t.condition)throw new e('Conditions are not allowed on "user_id"',{code:"INVALID_PARAMETER"});if("access_group"===t.searchFor&&(t.searchFor="group"),"string"==typeof t?.value&&!t?.value)throw new e("Value should not be an empty string.",{code:"INVALID_PARAMETER"});if("string"==typeof t?.searchFor&&!t?.searchFor)throw new e('"searchFor" should not be an empty string.',{code:"INVALID_PARAMETER"});return c.bind(this)("get-users",t,{auth:!0,fetchOptions:n})}async function He(e){await this.__connection;let t=await c.bind(this)("last-verified-email",e,{auth:!0});return t.includes("SUCCESS")?(await De.bind(this)().getSession({refreshToken:!0}),this.user):t}async function We(e){return await this.__connection,e=s.Params(e,{username:s.Email,redirect:s.Url},["username"]),await c.bind(this)("request-username-change",e,{auth:!0})}const Je=4503599627370496;function ze(t){const n={user_id:"",record_id:"",updated:0,uploaded:0,table:{name:"",access_group:0},reference:{reference_limit:null,allow_multiple_reference:!0,referenced_count:0},ip:"",bin:[]},r={ip:e=>{n.ip=e},rec:e=>{if(!e)return;n.record_id=e;let t=e.substring(0,e.length-9).split("").reverse().reduce(((e,t,n)=>e+"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".indexOf(t)*62**n),0);n.uploaded=t},usr:e=>{n.user_id=e},tbl:e=>{if(!e)return;let t=e.split("/");n.table.name=t[0],n.table.access_group="**"==t[2]?"private":parseInt(t[2]),t?.[3]&&(n.table.subscription={user_id:t[3],group:parseInt(t[4])})},usr_tbl:e=>{let t=e.split("/");n.user_id=t[0],n.table.name=t[1],n.table.access_group="**"==t[3]?"private":parseInt(t[3]),t?.[4]&&(n.table.subscription={user_id:t[4],group:parseInt(t[5])})},idx:t=>{if(!t)return;let r=t.split("!"),i=r.splice(0,1)[0],s=function(t){let n=t.substring(3);switch(t.substring(0,3)){case"!S%":return n;case"!N%":let r=n.split("."),i=Number(r[0])-4503599627370496;return 1===r.length?i:parseFloat(i.toString()+"."+r[1]);case"!B%":return"1"===n;case"!L%":case"!D%":try{return JSON.parse(n)}catch(t){throw new e("Value parse error.",{code:"PARSE_ERROR"})}default:return t}}("!"+r.join("!"));n.index={name:i,value:s}},ref:e=>{e&&(n.reference.record_id=e.split("/")[0])},tags:e=>{n.tags=e},upd:e=>{n.updated=e},acpt_mrf:e=>{n.reference.allow_multiple_reference=e},ref_limt:e=>{n.reference.reference_limit=e},rfd:e=>{n.reference.referenced_count=e},bin:e=>{n.bin=e},data:e=>{let t=e;"!D%{}"===e?t={}:"!L%[]"===e&&(t=[]),n.data=t}};if(t.record_id)return t;for(let e in r)t.hasOwnProperty(e)&&r[e](t[e]);return n}async function Ye(t){let n=await Ce.bind(this)(),{service:r=this.service,endpoints:i,storage:s="records"}=t;if("host"===s&&!n)throw new e("No access",{code:"INVALID_REQUEST"});if("string"==typeof i&&(i=[i]),!Array.isArray(i))throw new e('"endpoints" should be type: array | string.',{code:"INVALID_PARAMETER"});if("host"!==s&&"records"!==s)throw new e('"storage" should be type: "records" | "host".',{code:"INVALID_PARAMETER"});return c.bind(this)("del-files",{service:r,endpoints:i,storage:s},{auth:!0,method:"post"})}async function Qe(t,n){let r=await Ce.bind(this)();if(t instanceof SubmitEvent&&(t=t.target),t instanceof HTMLFormElement&&(t=new FormData(t)),t instanceof FormData){let e=[];for(let n of t.entries()){let t=n[1];t instanceof File&&e.push(t)}t=e}if(!(t[0]instanceof File))throw new e('"fileList" should be a FileList or array of File object.',{code:"INVALID_PARAMETER"});let i,s={reserved_key:function(e=6){let t="";let n=0;for(;n<e;)t+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".charAt(Math.floor(62*Math.random())),n+=1;return t}(),service:n?.service||this.service,request:n?.request||"post"};if("host"===s.request){if(!r)throw new e("The user has no access.",{code:"INVALID_REQUEST"});s.request}if(n?.record_id)s.id=n.record_id;else if(!r)throw new e("Record ID is required.",{code:"INVALID_PARAMETER"});let o=(e,t,r)=>new Promise(((s,o)=>{i=new XMLHttpRequest,i.open("POST",e),i.onload=e=>{let t=i.responseText;try{t=JSON.parse(t)}catch(e){}if(i.status>=200&&i.status<300){let e=i.responseText;try{e=JSON.parse(e)}catch(e){}s(e)}else o(t)},i.onerror=()=>o("Network error"),i.onabort=()=>o("Aborted"),i.ontimeout=()=>o("Timeout"),i.upload&&"function"==typeof n.progress&&(i.upload.onprogress=r),i.send(t)})),a=[],u=[];function l(e){const t="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";if(0===e)return t[0];let n="";for(;e>0;)n=t[e%62]+n,e=Math.floor(e/62);return n}for(let e of t){let t=Object.assign({key:e.name,sizeKey:l(e.size),contentType:e.type||null},s),{fields:r=null,url:h}=await c.bind(this)("get-signed-url",t,{auth:!0}),f=new FormData;for(let e in r)f.append(e,r[e]);f.append("file",e);try{await o(h,f,(t=>{n.progress({status:"upload",progress:t.loaded/t.total*100,currentFile:e,completed:a,failed:u,loaded:t.loaded,total:t.total,abort:()=>i.abort()})})),a.push(e)}catch(t){u.push(e)}}return{completed:a,failed:u}}async function Ge(t,n){if("string"!=typeof t)throw new e('"url" should be type: string.',{code:"INVALID_PARAMETER"});n?.noCdn||s.Url(t);let r=!1,i=t.split("/"),o=i[2].split("."),a=null;3===o.length&&"skapi"===o[1]&&(a=o[0],r=!0);let u=i.slice(3);if(!r){if("auth"!==u[0]&&"publ"!==u[0])throw new e("Invalid file url.",{code:"INVALID_PARAMETER"});try{s.UserId(u[2]),s.UserId(u[3])}catch{throw new e("Invalid file url.",{code:"INVALID_PARAMETER"})}}let l=a?null:u[1];s.Params(n,{expiration:["number",()=>60],noCdn:["boolean",()=>!1],dataType:["base64","blob","endpoint","download",()=>"download"]},[],["progress"]);let h="auth"==u[0],f=t.split("/").slice(-1)[0];if(n?.noCdn||h&&("download"===n?.dataType||"endpoint"===n?.dataType)){let p={request:a?"get-host":"get",id:a||u[5],key:t};l&&(p.service=l),t=(await c.bind(this)("get-signed-url",p,{auth:!0})).url}if("download"===n?.dataType){let g=document.createElement("a");return g.href=t,document.body.appendChild(g),g.setAttribute("download",f),g.target="_blank",g.click(),document.body.removeChild(g),null}if("endpoint"===n?.dataType)return t;let d=await c.bind(this)(t,{service:l||this.service},{method:"get",auth:h,contentType:null,responseType:"blob",fetchOptions:{progress:n?.progress}});if("base64"===n?.dataType){function y(e){return new Promise(((t,n)=>{const r=new FileReader;r.onloadend=()=>t(r.result),r.readAsDataURL(e)}))}return y(d)}return d}async function Ze(t,n){await this.__connection;const r={$updated:"number",$uploaded:"number",$referenced_count:"number"};"string"==typeof t?.table&&(t.table={name:t.table,access_group:0});const i={table:{name:"string",access_group:["number","private","public","authorized"],subscription:{user_id:e=>s.UserId(e,'User ID in "subscription.user_id"'),group:t=>{if("number"!=typeof t)throw new e('"subscription.group" should be type: number.',{code:"INVALID_PARAMETER"});if(t>99||t<0)throw new e('"subscription.group" should be within range: 0 ~ 99.',{code:"INVALID_PARAMETER"});return t}}},reference:"string",index:{name:t=>{if("string"!=typeof t)throw new e('"index.name" should be type: string.',{code:"INVALID_PARAMETER"});return r.hasOwnProperty(t)||["$uploaded","$updated","$referenced_count","$user_id"].includes(t)?t:s.specialChars(t,"index.name",!0,!1)},value:n=>{if(t.index?.name&&r.hasOwnProperty(t.index.name)){let i=r[t.index.name];if(typeof n===i)return n;throw new e(`"index.value" should be type: ${i}.`,{code:"INVALID_PARAMETER"})}if("number"==typeof n){if(n>Je||n<-4503599627370496)throw new e("Number value should be within range -4503599627370496 ~ +4503599627370496",{code:"INVALID_PARAMETER"});return n}return"boolean"==typeof n?n:"$user_id"==t.index?.name?s.UserId(n):s.specialChars(n,"index.value",!1,!0)},condition:["gt","gte","lt","lte",">",">=","<","<=","=","eq","!=","ne"],range:n=>{if(!t.index||!("value"in t.index))throw new e('"index.value" is required.',{code:"INVALID_PARAMETER"});if("$record_id"===t.index.name)throw new e(`Cannot do "index.range" on ${t.index.name}`,{code:"INVALID_PARAMETER"});if(typeof t.index.value!=typeof n)throw new e('"index.range" type should match the type of "index.value".',{code:"INVALID_PARAMETER"});return"string"==typeof n?s.specialChars(n,"index.value"):n}},tag:"string",private_access_key:"string"};if(t?.table&&("public"===t.table.access_group?t.table.access_group=0:"authorized"===t.table.access_group&&(t.table.access_group=1),"number"==typeof t.table.access_group))if(this.__user){if(this.user.access_group<t.table.access_group)throw new e("User has no access",{code:"INVALID_REQUEST"})}else if(0<t.table.access_group)throw new e("User has no access",{code:"INVALID_REQUEST"});if(t?.index&&!t.index?.name)throw new e('"index.name" is required when using "index" parameter.',{code:"INVALID_REQUEST"});if(t?.record_id){s.specialChars(t.record_id,"record_id",!1,!1);let e={record_id:t.record_id};t?.service&&(e.service=t.service),t=e}else{let n;if(!this.session&&"private"===t.table?.access_group)throw new e("Unsigned users have no access to private records.",{code:"INVALID_REQUEST"});if(t.reference)try{n=s.UserId(t?.reference)}catch(e){}if(t=s.Params(t||{},i,n?[]:["table"]),t.table?.subscription&&!this.session)throw new e("Unsigned users have no access to subscription records.",{code:"INVALID_REQUEST"})}let o=!(!t.hasOwnProperty("access_group")||!t.table.access_group)||!!this.__user,a=await c.bind(this)("get-records",t,{fetchOptions:n,auth:o,method:o?"post":"get"});for(let e in a.list)a.list[e]=ze(a.list[e]);return a}async function Xe(t,n){let r=await this.checkAdmin();if(!n)throw new e('"config" argument is required.',{code:"INVALID_PARAMETER"});if(!this.user)throw new e("Login is required.",{code:"INVALID_REQUEST"});let o={};"function"==typeof n?.formData&&(o.formData=n.formData,delete n.formData),"string"==typeof n.table&&(n.table={name:n.table},n.record_id||(n.table.access_group=0));let a=n.progress||null;if(n=s.Params(n||{},{record_id:"string",table:{name:"string",subscription_group:["number",null],access_group:["number","private","public","authorized"]},reference:{record_id:["string",null],reference_limit:t=>{if(null===t)return null;if("number"==typeof t){if(0>t)throw new e('"reference_limit" should be >= 0',{code:"INVALID_PARAMETER"});if(t>4503599627370546)throw new e('"reference_limit" should be <= 4503599627370546',{code:"INVALID_PARAMETER"});return t}throw new e('"reference_limit" should be type: <number | null>',{code:"INVALID_PARAMETER"})},allow_multiple_reference:"boolean"},index:{name:"string",value:["string","number","boolean"]},tags:t=>{if(null===t)return t;if("string"==typeof t)return[t];if(Array.isArray(t)){for(let n of t){if("string"!=typeof n)throw new e('"tags" should be type: <string | string[]>',{code:"INVALID_PARAMETER"});s.specialChars(t,"tag",!1,!0)}return t}throw new e('"tags" should be type: <string | string[]>',{code:"INVALID_PARAMETER"})}},[],["response","onerror","progress"],null),!n?.table&&!n?.record_id)throw new e('Either "record_id" or "table" should have a value.',{code:"INVALID_PARAMETER"});if(n.table){if("public"===n.table.access_group?n.table.access_group=0:"authorized"===n.table.access_group&&(n.table.access_group=1),"number"==typeof n.table.access_group&&!r&&this.user.access_group<n.table.access_group)throw new e("User has no access",{code:"INVALID_REQUEST"});if(!n.table.name)throw new e('"table.name" cannot be empty string.',{code:"INVALID_PARAMETER"});if(r){if("private"===n.table.access_group)throw new e("Service owner cannot write private records.",{code:"INVALID_REQUEST"});if(n.table.hasOwnProperty("subscription_group"))throw new e("Service owner cannot write to subscription table.",{code:"INVALID_REQUEST"})}if("number"==typeof n.table?.subscription_group&&n.table.subscription_group<0||n.table.subscription_group>99)throw new e("Subscription group should be within range: 0 ~ 99",{code:"INVALID_PARAMETER"})}if(delete n.response,delete n.onerror,delete n.progress,n.index){if(!n.index.name||"string"!=typeof n.index.name)throw new e('"index.name" is required. type: string.',{code:"INVALID_PARAMETER"});if(["$uploaded","$updated","$referenced_count","$user_id"].includes(n.index.name)||s.specialChars(n.index.name,"index name",!0),!n.index.hasOwnProperty("value"))throw new e('"index.value" is required.',{code:"INVALID_PARAMETER"});if("string"==typeof n.index.value)s.specialChars(n.index.value,"index value",!1,!0);else if("number"==typeof n.index.value&&(n.index.value>Je||n.index.value<-4503599627370496))throw new e("Number value should be within range -4503599627370496 ~ +4503599627370496",{code:"INVALID_PARAMETER"})}let u={auth:!0},l=null;if(t instanceof HTMLFormElement||t instanceof FormData||t instanceof SubmitEvent){let e=t instanceof SubmitEvent?t.target:t,r=t instanceof FormData?t:new FormData(e),s=i(t);u.meta=n,Object.keys(s.meta).length&&(u.meta.data=s.meta);let o={};for(let[e,t]of r.entries())if(s.meta.hasOwnProperty(e)&&!(t instanceof Blob)){let n=r.getAll(e).indexOf(t);o.hasOwnProperty(e)?o[e].push(n):o[e]=[n]}if(Object.keys(o).length)for(let e in o){let t=r.getAll(e),n=t.length;for(;n--;)o[e].includes(n)&&t.splice(n,1);r.delete(e);for(let n of t)r.append(e,n,n instanceof File?n.name:null)}l=r}else l=Object.assign({data:t},n);return"function"==typeof a&&(o.progress=a),Object.keys(o).length&&Object.assign(u,{fetchOptions:o}),ze(await c.bind(this)("post-record",l,u))}async function et(e,t){let n=await c.bind(this)("get-table",s.Params(e||{},{table:"string",condition:["gt","gte","lt","lte",">",">=","<","<=","=","eq","!=","ne"]}),Object.assign({auth:!0},{fetchOptions:t})),r={cnt_rec:"number_of_records",tbl:"table",srvc:"service"};if(Array.isArray(n.list))for(let e of n.list)for(let t in r)e.hasOwnProperty(t)&&(e[r[t]]=e[t],delete e[t]);return n}async function tt(t,n){let r=s.Params(t||{},{table:"string",index:e=>s.specialChars(e,"index name",!0,!1),order:{by:["average_number","total_number","number_count","average_bool","total_bool","bool_count","string_count","index_name","number_of_records"],value:["string","number","boolean"],condition:["gt","gte","lt","lte",">",">=","<","<=","=","eq","!=","ne"]}},["table"]);if(r.hasOwnProperty("order")){if(!r.order?.by)throw new e('"order.by" is required.',{code:"INVALID_PARAMETER"});if(r.order.hasOwnProperty("condition")&&!r.order.hasOwnProperty("value"))throw new e('"value" is required for "condition".',{code:"INVALID_PARAMETER"});if(r.hasOwnProperty("index")&&"."!==r.index.substring(r.index.length-1))throw new e('"index" should be a parent index name of the compound index when using "order.by"',{code:"INVALID_PARAMETER"})}let i=await c.bind(this)("get-index",r,Object.assign({auth:!0},{fetchOptions:n})),o={cnt_bool:"boolean_count",cnt_numb:"number_count",totl_numb:"total_number",totl_bool:"total_bool",avrg_numb:"average_number",avrg_bool:"average_bool",cnt_str:"string_count"};return Array.isArray(i.list)&&(i.list=i.list.map((e=>{let t=e.idx.split("/"),n={table:t[1],index:t[2],number_of_records:e.cnt_rec};for(let t in o)e?.[t]&&(n[o[t]]=e[t]);return n}))),i}async function nt(e,t){let n=await c.bind(this)("get-tag",s.Params(e||{},{table:"string",tag:"string",condition:["gt","gte","lt","lte",">",">=","<","<=","=","eq","!=","ne"]}),Object.assign({auth:!0},{fetchOptions:t}));if(Array.isArray(n.list))for(let e in n.list){let t=n.list[e],r=t.tag.split("/");n.list[e]={table:r[1],tag:r[0],number_of_records:t.cnt_rec}}return n}async function rt(t){let n=await this.checkAdmin();if(n&&!t?.service)throw new e("Service ID is required.",{code:"INVALID_PARAMETER"});if(t?.record_id)return await c.bind(this)("del-records",{service:t.service||this.service,record_id:(t=>{let n=s.specialChars(t,"record_id",!1,!1);if("string"==typeof n)return[n];if(n.length>100)throw new e('"record_id" should not exceed 100 items.',{code:"INVALID_PARAMETER"});return n})(t.record_id)},{auth:!0});{if(!t?.table){if(n)return null;throw new e('Either "table" or "record_id" is required.',{code:"INVALID_PARAMETER"})}let r={access_group:t=>{if("string"==typeof t&&["private","public","authorized"].includes(t))switch(t){case"private":return t;case"public":return 0;case"authorized":return 1}else if("number"==typeof t&&t>=0&&t<100)return t;throw new e('Invalid "table.access_group". Access group should be type <number (0~99) | "private" | "public" | "authorized">.',{code:"INVALID_PARAMETER"})},name:"string",subscription:t=>{if(n)return s.UserId(t,'User ID in "table.subscription"');throw new e('"table.subscription" is an invalid parameter key.',{code:"INVALID_PARAMETER"})},subscription_group:r=>{if(n&&"string"!=typeof t?.table?.subscription)throw new e('"table.subscription" is required.',{code:"INVALID_PARAMETER"});if("number"==typeof r&&r>=0&&r<99)return r;throw new e("Subscription group should be between 0 ~ 99.",{code:"INVALID_PARAMETER"})}};t.table=s.Params(t.table||{},r,n?[]:["name"])}return await c.bind(this)("del-records",t,{auth:!0})}async function it(t){if(!t.record_id)throw new e("Record ID is required.",{code:"INVALID_PARAMETER"});if(!t.user_id||Array.isArray(t.user_id)&&!t.user_id.length)throw new e("User ID is required.",{code:"INVALID_PARAMETER"});return ut({record_id:t.record_id,user_id:t.user_id||null,execute:"add"})}async function st(t){if(!t.record_id)throw new e("Record ID is required.",{code:"INVALID_PARAMETER"});if(!t.user_id||Array.isArray(t.user_id)&&!t.user_id.length)throw new e("User ID is required.",{code:"INVALID_PARAMETER"});return ut({record_id:t.record_id,user_id:t.user_id||null,execute:"remove"})}async function ot(e){return ut({record_id:e.record_id,user_id:e.user_id||null,execute:"list"})}async function at(e){await c.bind(this)("request-private-access-key",{record_id:e},{auth:!0})}async function ut(t){let n=t.execute,r=s.Params(t,{record_id:"string",user_id:t=>{if(!t){if("list"==n)return null;throw new e("User ID is required.",{code:"INVALID_PARAMETER"})}let r=s.specialChars(t,"user id",!1,!1);if("string"==typeof r)return[r];if(r.length>100)throw new e("Cannot process more than 100 users at once.",{code:"INVALID_REQUEST"});return r},execute:["add","remove","list"]},["execute","record_id","user_id"]);r.user_id||(r.user_id=null),await c.bind(this)("grant-private-access",r,{auth:!0})}function ct(t){if(t=s.Params(t,{user_id:e=>s.UserId(e,'"user_id"'),group:t=>{if("*"===t)return t;if("number"!=typeof t)throw new e('"group" should be type: number.',{code:"INVALID_PARAMETER"});if(t<1&&t>99)throw new e('"group" should be within range 1 ~ 99.',{code:"INVALID_PARAMETER"});return t}},["user_id","group"]),this.__user&&t.user_id===this.__user.user_id)throw new e('"user_id" cannot be the user\'s own ID.',{code:"INVALID_PARAMETER"});return t}async function lt(t,n,r){if(!(t=s.Params(t,{subscriber:e=>s.UserId(e,'User ID in "subscriber"'),group:"number",subscription:e=>s.UserId(e,'User ID in "subscription"'),blocked:"boolean"})).subscriber&&!t.subscription)throw new e('At least either "subscriber" or "subscription" should have a value.',{code:"INVALID_PARAMETER"});let i=await c.bind(this)("get-subscription",t,Object.assign({auth:!0},{fetchOptions:n}));return i.list=i.list.map(r||(e=>{let t={},n=e.sub.split("#");return t.subscriber=n[2],t.subscription=n[0],t.group=parseInt(n[1]),t.timestamp=e.stmp,t.blocked="N"===e.grp.substring(0,1),t})),i}async function ht(t){await this.__connection;let{user_id:n,group:r}=ct.bind(this)(t);if("number"!=typeof r)throw new e('"group" should be type: number.',{code:"INVALID_PARAMETER"});return await c.bind(this)("subscription",{subscribe:n,group:r},{auth:!0})}async function ft(e){await this.__connection;let{user_id:t,group:n}=ct.bind(this)(e);return await c.bind(this)("subscription",{unsubscribe:t,group:n},{auth:!0})}async function dt(e){await this.__connection;let{user_id:t,group:n}=ct.bind(this)(e);return await c.bind(this)("subscription",{block:t,group:n},{auth:!0})}async function pt(e){await this.__connection;let{user_id:t,group:n}=ct.bind(this)(e);return await c.bind(this)("subscription",{unblock:t,group:n},{auth:!0})}async function gt(e,t){return await this.__connection,e=s.Params(e,{user_id:e=>s.UserId(e,'"user_id"'),group:"number",blocked:"boolean"})||{},lt.bind(this)({subscriber:e.user_id||this.__user?.user_id,group:e.group,blocked:e.blocked},t)}async function yt(e,t){await this.__connection;let n={subscription:(e=s.Params(e,{user_id:e=>s.UserId(e,'"user_id"'),group:"number",blocked:"boolean"})||{}).user_id||this.__user?.user_id,group:e.group,blocked:e.blocked};return lt.bind(this)(n,t)}async function wt(t){await this.__connection;let n=await this.checkAdmin();t=s.Params(t,{user_id:t=>{if(t!==this.__user.user_id&&!n)throw new e("No access.",{code:"INVALID_REQUEST"});return t},group:"number"});let r=await c.bind(this)("get-newsletter-subscription",t,{auth:!0}),i=[];for(let e of r){let t=e.subt.split("#"),n=!0;"@"===t[0].charAt(0)&&(n=!1,t[0]=t[0].substring(1));let r=parseInt(t[0]);i.push({timestamp:e.stmp,group:r,subscribed_email:t[1],active:n})}return i}async function mt(e,t){await this.__connection;let n=s.Params(e||{},{email:e=>s.Email(e),group:["number","public","authorized"],redirect:e=>s.Url(e)},this.__user?["group"]:["email","group"]);return c.bind(this)(`subscribe-${this.__user?"":"public-"}newsletter`,n,{fetchOptions:t,auth:!!this.__user})}async function bt(e){await this.__connection,e=s.Params(e,{group:["number","public","authorized"]},["group"]);let t=Object.assign({action:"unsubscribe"},e);return c.bind(this)("subscribe-newsletter",t,{auth:!0})}async function _t(t,n){let r=await this.checkAdmin(),i={message_id:"string",timestamp:"number",read:"number",complaint:"number",subject:"string"};t||(n||(n={}),n.ascending=!1);let o=t||{searchFor:"timestamp",value:0,condition:">"};t=s.Params(o,{searchFor:["message_id","timestamp","read","complaint","group","subject"],value:t=>{if(typeof t!==i[o.searchFor])throw new e(`"value" type does not match the type of "${o.searchFor}" index.`,{code:"INVALID_PARAMETER"});if("string"==typeof t&&!t)throw new e('"value" should not be empty string.',{code:"INVALID_PARAMETER"});return t},range:t=>{if(!o.hasOwnProperty("value")||typeof t!=typeof o.value)throw new e('"range" should match type of "value".',{code:"INVALID_PARAMETER"});return t},condition:[">",">=","=","<","<=","gt","gte","eq","lt","lte",()=>"="],group:t=>{if(!this.session)throw new e("User should be logged in.",{code:"INVALID_REQUEST"});if("public"===t)return 0;if("authorized"===t)return 1;if("number"==typeof t&&!r&&t>parseInt(this.session.idToken.payload.access_group))throw new e("User has no access.",{code:"INVALID_REQUEST"});return t}},["searchFor","value","group"]);let a=await c.bind(this)(0===t.group?"get-public-newsletters":"get-newsletters",t,Object.assign({method:"get",auth:0!==t.group},{fetchOptions:n})),u={message_id:"mid",timestamp:"stmp",complaint:"cmpl",read:"read",subject:"subj",bounced:"bnce",url:"url"},l={message_id:"",timestamp:0,complaint:0,read:0,subject:"",bounced:0,url:""};return a.list=a.list.map((e=>{let t={};for(let n in u)t[n]=e[u[n]]||l[u[n]];return t})),a}var At=function(e,t,n,r){var i,s=arguments.length,o=s<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,n,r);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(o=(s<3?i(o):s>3?i(t,n,o):i(t,n))||o);return s>3&&o&&Object.defineProperty(t,n,o),o};class vt{get user(){return this.__user&&Object.keys(this.__user).length?JSON.parse(JSON.stringify(this.__user)):null}set user(e){}constructor(t,n,r){if(this.version="0.2.5",this.__disabledAccount=null,this.__cached_requests={},this.__startKeyHistory={},this.__request_signup_confirmation=null,this.__class_properties_has_been_cached=!1,this.session=null,this.__user=null,this.connection=null,this.host="skapi",this.hostDomain="skapi.com",this.validate={userId(e){try{return s.UserId(e),!0}catch(e){return!1}},url(e){try{return s.Url(e),!0}catch(e){return!1}},phoneNumber(e){try{return s.PhoneNumber(e),!0}catch(e){return!1}},birthdate(e){try{return s.Birthdate(e),!0}catch(e){return!1}},email(e){try{return s.Email(e),!0}catch(e){return!1}}},this.getConnection=a.bind(this),this.getProfile=Ue.bind(this),this.checkAdmin=Ce.bind(this),this.getFile=Ge.bind(this),this.request=c.bind(this),this.secureRequest=g.bind(this),this.getFormResponse=w.bind(this),this.getRecords=Ze.bind(this),this.getTables=et.bind(this),this.getIndexes=tt.bind(this),this.getTags=nt.bind(this),this.deleteRecords=rt.bind(this),this.resendSignupConfirmation=Ne.bind(this),this.recoverAccount=ke.bind(this),this.getUsers=je.bind(this),this.disableAccount=Fe.bind(this),this.lastVerifiedEmail=He.bind(this),this.getSubscribedTo=gt.bind(this),this.getSubscribers=yt.bind(this),this.getSubscriptions=lt.bind(this),this.unsubscribeNewsletter=bt.bind(this),this.getNewsletters=_t.bind(this),this.getNewsletterSubscription=wt.bind(this),this.requestUsernameChange=We.bind(this),this.grantPrivateRecordAccess=it.bind(this),this.removePrivateRecordAccess=st.bind(this),this.listPrivateRecordAccess=ot.bind(this),this.requestPrivateRecordAccessKey=at.bind(this),this.listHostDirectory=u.bind(this),this.deleteFiles=Ye.bind(this),"string"!=typeof t||"string"!=typeof n)throw new e('"service_id" and "owner" should be type <string>.',{code:"INVALID_PARAMETER"});if(!t||!n)throw new e('"service_id" and "owner" is required',{code:"INVALID_PARAMETER"});n!==this.host&&s.UserId(n,'"owner"'),this.service=t,this.owner=n;let i="boolean"!=typeof r?.autoLogin||r.autoLogin;const o="https://d1h765tqb4s5ov.cloudfront.net";let l=t.substring(0,4);this.admin_endpoint=fetch(`${o}/${l}/admin.json`).then((e=>e.blob())).then((e=>new Promise(((t,n)=>{const r=new FileReader;r.onloadend=()=>t(r.result),r.onerror=n,r.readAsDataURL(e)})))).then((e=>"string"==typeof e?JSON.parse(window.atob(e.split(",")[1])):null)),this.record_endpoint=fetch(`${o}/${l}/record.json`).then((e=>e.blob())).then((e=>new Promise(((t,n)=>{const r=new FileReader;r.onloadend=()=>t(r.result),r.onerror=n,r.readAsDataURL(e)})))).then((e=>"string"==typeof e?JSON.parse(window.atob(e.split(",")[1])):null)),this.__connection=(async()=>{if(!window.sessionStorage)throw new Error("This browser does not support skapi.");const e=JSON.parse(window.sessionStorage.getItem(`${t}#${n}`)||"null");if(e?.connection)for(let t in e)this[t]=e[t];const r=await this.admin_endpoint;var s;s={UserPoolId:r.userpool_id,ClientId:r.userpool_client},Re=new Ie(s);const o=[];if(e?.connection||o.push(this.updateConnection()),!e?.connection&&!i){let e=Re.getCurrentUser();e&&e.signOut()}let a;(e?.connection||i)&&(o.push(De.bind(this)().getSession({refreshToken:!e?.connection}).catch((e=>{this.__user=null}))),this.updateConnection()),o.length&&(a=await Promise.all(o));const u=()=>{if(this.__class_properties_has_been_cached)return;let e=()=>{let e={};const r=["__startKeyHistory","__cached_requests","__request_signup_confirmation","connection"];if(this.connection){for(let t of r)e[t]=this[t];window.sessionStorage.setItem(`${t}#${n}`,JSON.stringify(e)),this.__class_properties_has_been_cached=!0}};return a instanceof Promise?a.then((()=>e())):e()};return window.addEventListener("beforeunload",u),window.addEventListener("visibilitychange",u),this.connection})()}async updateConnection(){return this.connection=await c.bind(this)("service",{service:this.service,owner:this.owner},{bypassAwaitConnection:!0,method:"get"}),console.log(`Built with:\n%c\r\n $$\\ $$\\ \r\n $$ | \\__|\r\n $$$$$$$\\ $$ | $$\\ $$$$$$\\ $$$$$$\\ $$\\ \r\n$$ _____|$$ | $$ |\\____$$\\ $$ __$$\\ $$ |\r\n\\$$$$$$\\ $$$$$$ / $$$$$$$ |$$ / $$ |$$ |\r\n \\____$$\\ $$ _$$< $$ __$$ |$$ | $$ |$$ |\r\n$$$$$$$ |$$ | \\$$\\\\$$$$$$$ |$$$$$$$ |$$ |\r\n\\_______/ \\__| \\__|\\_______|$$ ____/ \\__|\r\n $$ | \r\n $$ | \r\n \\__| \r\nVersion: ${this.version}\n\nDocumentation: https://docs.skapi.com`,"font-family: monospace; color:blue;"),this.connection}uploadFiles(...e){return Qe.bind(this)(...e)}mock(...e){return y.bind(this)(...e)}login(...e){return Oe.bind(this)(...e)}logout(...e){return Pe.bind(this)(...e)}signup(...e){return Me.bind(this)(...e)}resetPassword(...e){return Ve.bind(this)(...e)}verifyEmail(...e){return Be.bind(this)(...e)}verifyPhoneNumber(...e){return Le.bind(this)(...e)}forgotPassword(...e){return $e.bind(this)(...e)}changePassword(...e){return qe.bind(this)(...e)}updateProfile(...e){return Ke.bind(this)(...e)}postRecord(...e){return Xe.bind(this)(...e)}subscribe(...e){return ht.bind(this)(...e)}unsubscribe(...e){return ft.bind(this)(...e)}blockSubscriber(...e){return dt.bind(this)(...e)}unblockSubscriber(...e){return pt.bind(this)(...e)}subscribeNewsletter(...e){return mt.bind(this)(...e)}}At([b()],vt.prototype,"uploadFiles",null),At([b()],vt.prototype,"mock",null),At([b({preventMultipleCalls:!0})],vt.prototype,"login",null),At([b()],vt.prototype,"logout",null),At([b({preventMultipleCalls:!0})],vt.prototype,"signup",null),At([b({preventMultipleCalls:!0})],vt.prototype,"resetPassword",null),At([b({preventMultipleCalls:!0})],vt.prototype,"verifyEmail",null),At([b({preventMultipleCalls:!0})],vt.prototype,"verifyPhoneNumber",null),At([b({preventMultipleCalls:!0})],vt.prototype,"forgotPassword",null),At([b({preventMultipleCalls:!0})],vt.prototype,"changePassword",null),At([b({preventMultipleCalls:!0})],vt.prototype,"updateProfile",null),At([b()],vt.prototype,"postRecord",null),At([b()],vt.prototype,"subscribe",null),At([b()],vt.prototype,"unsubscribe",null),At([b()],vt.prototype,"blockSubscriber",null),At([b()],vt.prototype,"unblockSubscriber",null),At([b()],vt.prototype,"subscribeNewsletter",null)})(),r})()));
|
|
2
|
+
!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]}}(self,(()=>(()=>{var e={742:(e,t)=>{"use strict";t.byteLength=function(e){var t=a(e),r=t[0],n=t[1];return 3*(r+n)/4-n},t.toByteArray=function(e){var t,r,s=a(e),o=s[0],u=s[1],c=new i(function(e,t,r){return 3*(t+r)/4-r}(0,o,u)),l=0,h=u>0?o-4:o;for(r=0;r<h;r+=4)t=n[e.charCodeAt(r)]<<18|n[e.charCodeAt(r+1)]<<12|n[e.charCodeAt(r+2)]<<6|n[e.charCodeAt(r+3)],c[l++]=t>>16&255,c[l++]=t>>8&255,c[l++]=255&t;return 2===u&&(t=n[e.charCodeAt(r)]<<2|n[e.charCodeAt(r+1)]>>4,c[l++]=255&t),1===u&&(t=n[e.charCodeAt(r)]<<10|n[e.charCodeAt(r+1)]<<4|n[e.charCodeAt(r+2)]>>2,c[l++]=t>>8&255,c[l++]=255&t),c},t.fromByteArray=function(e){for(var t,n=e.length,i=n%3,s=[],o=16383,a=0,c=n-i;a<c;a+=o)s.push(u(e,a,a+o>c?c:a+o));return 1===i?(t=e[n-1],s.push(r[t>>2]+r[t<<4&63]+"==")):2===i&&(t=(e[n-2]<<8)+e[n-1],s.push(r[t>>10]+r[t>>4&63]+r[t<<2&63]+"=")),s.join("")};for(var r=[],n=[],i="undefined"!=typeof Uint8Array?Uint8Array:Array,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",o=0;o<64;++o)r[o]=s[o],n[s.charCodeAt(o)]=o;function a(e){var t=e.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=e.indexOf("=");return-1===r&&(r=t),[r,r===t?0:4-r%4]}function u(e,t,n){for(var i,s,o=[],a=t;a<n;a+=3)i=(e[a]<<16&16711680)+(e[a+1]<<8&65280)+(255&e[a+2]),o.push(r[(s=i)>>18&63]+r[s>>12&63]+r[s>>6&63]+r[63&s]);return o.join("")}n["-".charCodeAt(0)]=62,n["_".charCodeAt(0)]=63},764:(e,t,r)=>{"use strict";var n=r(742),i=r(645),s=r(826);function o(){return u.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function a(e,t){if(o()<t)throw new RangeError("Invalid typed array length");return u.TYPED_ARRAY_SUPPORT?(e=new Uint8Array(t)).__proto__=u.prototype:(null===e&&(e=new u(t)),e.length=t),e}function u(e,t,r){if(!(u.TYPED_ARRAY_SUPPORT||this instanceof u))return new u(e,t,r);if("number"==typeof e){if("string"==typeof t)throw new Error("If encoding is specified then the first argument must be a string");return h(this,e)}return c(this,e,t,r)}function c(e,t,r,n){if("number"==typeof t)throw new TypeError('"value" argument must not be a number');return"undefined"!=typeof ArrayBuffer&&t instanceof ArrayBuffer?function(e,t,r,n){if(t.byteLength,r<0||t.byteLength<r)throw new RangeError("'offset' is out of bounds");if(t.byteLength<r+(n||0))throw new RangeError("'length' is out of bounds");return t=void 0===r&&void 0===n?new Uint8Array(t):void 0===n?new Uint8Array(t,r):new Uint8Array(t,r,n),u.TYPED_ARRAY_SUPPORT?(e=t).__proto__=u.prototype:e=f(e,t),e}(e,t,r,n):"string"==typeof t?function(e,t,r){if("string"==typeof r&&""!==r||(r="utf8"),!u.isEncoding(r))throw new TypeError('"encoding" must be a valid string encoding');var n=0|p(t,r),i=(e=a(e,n)).write(t,r);return i!==n&&(e=e.slice(0,i)),e}(e,t,r):function(e,t){if(u.isBuffer(t)){var r=0|d(t.length);return 0===(e=a(e,r)).length||t.copy(e,0,0,r),e}if(t){if("undefined"!=typeof ArrayBuffer&&t.buffer instanceof ArrayBuffer||"length"in t)return"number"!=typeof t.length||(n=t.length)!=n?a(e,0):f(e,t);if("Buffer"===t.type&&s(t.data))return f(e,t.data)}var n;throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}(e,t)}function l(e){if("number"!=typeof e)throw new TypeError('"size" argument must be a number');if(e<0)throw new RangeError('"size" argument must not be negative')}function h(e,t){if(l(t),e=a(e,t<0?0:0|d(t)),!u.TYPED_ARRAY_SUPPORT)for(var r=0;r<t;++r)e[r]=0;return e}function f(e,t){var r=t.length<0?0:0|d(t.length);e=a(e,r);for(var n=0;n<r;n+=1)e[n]=255&t[n];return e}function d(e){if(e>=o())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+o().toString(16)+" bytes");return 0|e}function p(e,t){if(u.isBuffer(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var r=e.length;if(0===r)return 0;for(var n=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return B(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return $(e).length;default:if(n)return B(e).length;t=(""+t).toLowerCase(),n=!0}}function g(e,t,r){var n=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return C(this,t,r);case"utf8":case"utf-8":return T(this,t,r);case"ascii":return U(this,t,r);case"latin1":case"binary":return D(this,t,r);case"base64":return I(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return P(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function y(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function w(e,t,r,n,i){if(0===e.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=i?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(i)return-1;r=e.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof t&&(t=u.from(t,n)),u.isBuffer(t))return 0===t.length?-1:m(e,t,r,n,i);if("number"==typeof t)return t&=255,u.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):m(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function m(e,t,r,n,i){var s,o=1,a=e.length,u=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return-1;o=2,a/=2,u/=2,r/=2}function c(e,t){return 1===o?e[t]:e.readUInt16BE(t*o)}if(i){var l=-1;for(s=r;s<a;s++)if(c(e,s)===c(t,-1===l?0:s-l)){if(-1===l&&(l=s),s-l+1===u)return l*o}else-1!==l&&(s-=s-l),l=-1}else for(r+u>a&&(r=a-u),s=r;s>=0;s--){for(var h=!0,f=0;f<u;f++)if(c(e,s+f)!==c(t,f)){h=!1;break}if(h)return s}return-1}function b(e,t,r,n){r=Number(r)||0;var i=e.length-r;n?(n=Number(n))>i&&(n=i):n=i;var s=t.length;if(s%2!=0)throw new TypeError("Invalid hex string");n>s/2&&(n=s/2);for(var o=0;o<n;++o){var a=parseInt(t.substr(2*o,2),16);if(isNaN(a))return o;e[r+o]=a}return o}function _(e,t,r,n){return q(B(t,e.length-r),e,r,n)}function A(e,t,r,n){return q(function(e){for(var t=[],r=0;r<e.length;++r)t.push(255&e.charCodeAt(r));return t}(t),e,r,n)}function v(e,t,r,n){return A(e,t,r,n)}function E(e,t,r,n){return q($(t),e,r,n)}function S(e,t,r,n){return q(function(e,t){for(var r,n,i,s=[],o=0;o<e.length&&!((t-=2)<0);++o)n=(r=e.charCodeAt(o))>>8,i=r%256,s.push(i),s.push(n);return s}(t,e.length-r),e,r,n)}function I(e,t,r){return 0===t&&r===e.length?n.fromByteArray(e):n.fromByteArray(e.slice(t,r))}function T(e,t,r){r=Math.min(e.length,r);for(var n=[],i=t;i<r;){var s,o,a,u,c=e[i],l=null,h=c>239?4:c>223?3:c>191?2:1;if(i+h<=r)switch(h){case 1:c<128&&(l=c);break;case 2:128==(192&(s=e[i+1]))&&(u=(31&c)<<6|63&s)>127&&(l=u);break;case 3:s=e[i+1],o=e[i+2],128==(192&s)&&128==(192&o)&&(u=(15&c)<<12|(63&s)<<6|63&o)>2047&&(u<55296||u>57343)&&(l=u);break;case 4:s=e[i+1],o=e[i+2],a=e[i+3],128==(192&s)&&128==(192&o)&&128==(192&a)&&(u=(15&c)<<18|(63&s)<<12|(63&o)<<6|63&a)>65535&&u<1114112&&(l=u)}null===l?(l=65533,h=1):l>65535&&(l-=65536,n.push(l>>>10&1023|55296),l=56320|1023&l),n.push(l),i+=h}return function(e){var t=e.length;if(t<=R)return String.fromCharCode.apply(String,e);for(var r="",n=0;n<t;)r+=String.fromCharCode.apply(String,e.slice(n,n+=R));return r}(n)}t.lW=u,t.h2=50,u.TYPED_ARRAY_SUPPORT=void 0!==r.g.TYPED_ARRAY_SUPPORT?r.g.TYPED_ARRAY_SUPPORT:function(){try{var e=new Uint8Array(1);return e.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===e.foo()&&"function"==typeof e.subarray&&0===e.subarray(1,1).byteLength}catch(e){return!1}}(),o(),u.poolSize=8192,u._augment=function(e){return e.__proto__=u.prototype,e},u.from=function(e,t,r){return c(null,e,t,r)},u.TYPED_ARRAY_SUPPORT&&(u.prototype.__proto__=Uint8Array.prototype,u.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&u[Symbol.species]===u&&Object.defineProperty(u,Symbol.species,{value:null,configurable:!0})),u.alloc=function(e,t,r){return function(e,t,r,n){return l(t),t<=0?a(e,t):void 0!==r?"string"==typeof n?a(e,t).fill(r,n):a(e,t).fill(r):a(e,t)}(null,e,t,r)},u.allocUnsafe=function(e){return h(null,e)},u.allocUnsafeSlow=function(e){return h(null,e)},u.isBuffer=function(e){return!(null==e||!e._isBuffer)},u.compare=function(e,t){if(!u.isBuffer(e)||!u.isBuffer(t))throw new TypeError("Arguments must be Buffers");if(e===t)return 0;for(var r=e.length,n=t.length,i=0,s=Math.min(r,n);i<s;++i)if(e[i]!==t[i]){r=e[i],n=t[i];break}return r<n?-1:n<r?1:0},u.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},u.concat=function(e,t){if(!s(e))throw new TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return u.alloc(0);var r;if(void 0===t)for(t=0,r=0;r<e.length;++r)t+=e[r].length;var n=u.allocUnsafe(t),i=0;for(r=0;r<e.length;++r){var o=e[r];if(!u.isBuffer(o))throw new TypeError('"list" argument must be an Array of Buffers');o.copy(n,i),i+=o.length}return n},u.byteLength=p,u.prototype._isBuffer=!0,u.prototype.swap16=function(){var e=this.length;if(e%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var t=0;t<e;t+=2)y(this,t,t+1);return this},u.prototype.swap32=function(){var e=this.length;if(e%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var t=0;t<e;t+=4)y(this,t,t+3),y(this,t+1,t+2);return this},u.prototype.swap64=function(){var e=this.length;if(e%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var t=0;t<e;t+=8)y(this,t,t+7),y(this,t+1,t+6),y(this,t+2,t+5),y(this,t+3,t+4);return this},u.prototype.toString=function(){var e=0|this.length;return 0===e?"":0===arguments.length?T(this,0,e):g.apply(this,arguments)},u.prototype.equals=function(e){if(!u.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e||0===u.compare(this,e)},u.prototype.inspect=function(){var e="",r=t.h2;return this.length>0&&(e=this.toString("hex",0,r).match(/.{2}/g).join(" "),this.length>r&&(e+=" ... ")),"<Buffer "+e+">"},u.prototype.compare=function(e,t,r,n,i){if(!u.isBuffer(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),t<0||r>e.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&t>=r)return 0;if(n>=i)return-1;if(t>=r)return 1;if(this===e)return 0;for(var s=(i>>>=0)-(n>>>=0),o=(r>>>=0)-(t>>>=0),a=Math.min(s,o),c=this.slice(n,i),l=e.slice(t,r),h=0;h<a;++h)if(c[h]!==l[h]){s=c[h],o=l[h];break}return s<o?-1:o<s?1:0},u.prototype.includes=function(e,t,r){return-1!==this.indexOf(e,t,r)},u.prototype.indexOf=function(e,t,r){return w(this,e,t,r,!0)},u.prototype.lastIndexOf=function(e,t,r){return w(this,e,t,r,!1)},u.prototype.write=function(e,t,r,n){if(void 0===t)n="utf8",r=this.length,t=0;else if(void 0===r&&"string"==typeof t)n=t,r=this.length,t=0;else{if(!isFinite(t))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");t|=0,isFinite(r)?(r|=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var i=this.length-t;if((void 0===r||r>i)&&(r=i),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var s=!1;;)switch(n){case"hex":return b(this,e,t,r);case"utf8":case"utf-8":return _(this,e,t,r);case"ascii":return A(this,e,t,r);case"latin1":case"binary":return v(this,e,t,r);case"base64":return E(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return S(this,e,t,r);default:if(s)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),s=!0}},u.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var R=4096;function U(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;i<r;++i)n+=String.fromCharCode(127&e[i]);return n}function D(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;i<r;++i)n+=String.fromCharCode(e[i]);return n}function C(e,t,r){var n,i=e.length;(!t||t<0)&&(t=0),(!r||r<0||r>i)&&(r=i);for(var s="",o=t;o<r;++o)s+=(n=e[o])<16?"0"+n.toString(16):n.toString(16);return s}function P(e,t,r){for(var n=e.slice(t,r),i="",s=0;s<n.length;s+=2)i+=String.fromCharCode(n[s]+256*n[s+1]);return i}function N(e,t,r){if(e%1!=0||e<0)throw new RangeError("offset is not uint");if(e+t>r)throw new RangeError("Trying to access beyond buffer length")}function k(e,t,r,n,i,s){if(!u.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||t<s)throw new RangeError('"value" argument is out of bounds');if(r+n>e.length)throw new RangeError("Index out of range")}function O(e,t,r,n){t<0&&(t=65535+t+1);for(var i=0,s=Math.min(e.length-r,2);i<s;++i)e[r+i]=(t&255<<8*(n?i:1-i))>>>8*(n?i:1-i)}function M(e,t,r,n){t<0&&(t=4294967295+t+1);for(var i=0,s=Math.min(e.length-r,4);i<s;++i)e[r+i]=t>>>8*(n?i:3-i)&255}function F(e,t,r,n,i,s){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function V(e,t,r,n,s){return s||F(e,0,r,4),i.write(e,t,r,n,23,4),r+4}function x(e,t,r,n,s){return s||F(e,0,r,8),i.write(e,t,r,n,52,8),r+8}u.prototype.slice=function(e,t){var r,n=this.length;if((e=~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),(t=void 0===t?n:~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),t<e&&(t=e),u.TYPED_ARRAY_SUPPORT)(r=this.subarray(e,t)).__proto__=u.prototype;else{var i=t-e;r=new u(i,void 0);for(var s=0;s<i;++s)r[s]=this[s+e]}return r},u.prototype.readUIntLE=function(e,t,r){e|=0,t|=0,r||N(e,t,this.length);for(var n=this[e],i=1,s=0;++s<t&&(i*=256);)n+=this[e+s]*i;return n},u.prototype.readUIntBE=function(e,t,r){e|=0,t|=0,r||N(e,t,this.length);for(var n=this[e+--t],i=1;t>0&&(i*=256);)n+=this[e+--t]*i;return n},u.prototype.readUInt8=function(e,t){return t||N(e,1,this.length),this[e]},u.prototype.readUInt16LE=function(e,t){return t||N(e,2,this.length),this[e]|this[e+1]<<8},u.prototype.readUInt16BE=function(e,t){return t||N(e,2,this.length),this[e]<<8|this[e+1]},u.prototype.readUInt32LE=function(e,t){return t||N(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},u.prototype.readUInt32BE=function(e,t){return t||N(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},u.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||N(e,t,this.length);for(var n=this[e],i=1,s=0;++s<t&&(i*=256);)n+=this[e+s]*i;return n>=(i*=128)&&(n-=Math.pow(2,8*t)),n},u.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||N(e,t,this.length);for(var n=t,i=1,s=this[e+--n];n>0&&(i*=256);)s+=this[e+--n]*i;return s>=(i*=128)&&(s-=Math.pow(2,8*t)),s},u.prototype.readInt8=function(e,t){return t||N(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},u.prototype.readInt16LE=function(e,t){t||N(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},u.prototype.readInt16BE=function(e,t){t||N(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},u.prototype.readInt32LE=function(e,t){return t||N(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},u.prototype.readInt32BE=function(e,t){return t||N(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},u.prototype.readFloatLE=function(e,t){return t||N(e,4,this.length),i.read(this,e,!0,23,4)},u.prototype.readFloatBE=function(e,t){return t||N(e,4,this.length),i.read(this,e,!1,23,4)},u.prototype.readDoubleLE=function(e,t){return t||N(e,8,this.length),i.read(this,e,!0,52,8)},u.prototype.readDoubleBE=function(e,t){return t||N(e,8,this.length),i.read(this,e,!1,52,8)},u.prototype.writeUIntLE=function(e,t,r,n){e=+e,t|=0,r|=0,n||k(this,e,t,r,Math.pow(2,8*r)-1,0);var i=1,s=0;for(this[t]=255&e;++s<r&&(i*=256);)this[t+s]=e/i&255;return t+r},u.prototype.writeUIntBE=function(e,t,r,n){e=+e,t|=0,r|=0,n||k(this,e,t,r,Math.pow(2,8*r)-1,0);var i=r-1,s=1;for(this[t+i]=255&e;--i>=0&&(s*=256);)this[t+i]=e/s&255;return t+r},u.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||k(this,e,t,1,255,0),u.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},u.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||k(this,e,t,2,65535,0),u.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):O(this,e,t,!0),t+2},u.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||k(this,e,t,2,65535,0),u.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):O(this,e,t,!1),t+2},u.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||k(this,e,t,4,4294967295,0),u.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):M(this,e,t,!0),t+4},u.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||k(this,e,t,4,4294967295,0),u.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):M(this,e,t,!1),t+4},u.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);k(this,e,t,r,i-1,-i)}var s=0,o=1,a=0;for(this[t]=255&e;++s<r&&(o*=256);)e<0&&0===a&&0!==this[t+s-1]&&(a=1),this[t+s]=(e/o>>0)-a&255;return t+r},u.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);k(this,e,t,r,i-1,-i)}var s=r-1,o=1,a=0;for(this[t+s]=255&e;--s>=0&&(o*=256);)e<0&&0===a&&0!==this[t+s+1]&&(a=1),this[t+s]=(e/o>>0)-a&255;return t+r},u.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||k(this,e,t,1,127,-128),u.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},u.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||k(this,e,t,2,32767,-32768),u.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):O(this,e,t,!0),t+2},u.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||k(this,e,t,2,32767,-32768),u.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):O(this,e,t,!1),t+2},u.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||k(this,e,t,4,2147483647,-2147483648),u.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):M(this,e,t,!0),t+4},u.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||k(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),u.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):M(this,e,t,!1),t+4},u.prototype.writeFloatLE=function(e,t,r){return V(this,e,t,!0,r)},u.prototype.writeFloatBE=function(e,t,r){return V(this,e,t,!1,r)},u.prototype.writeDoubleLE=function(e,t,r){return x(this,e,t,!0,r)},u.prototype.writeDoubleBE=function(e,t,r){return x(this,e,t,!1,r)},u.prototype.copy=function(e,t,r,n){if(r||(r=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n<r&&(n=r),n===r)return 0;if(0===e.length||0===this.length)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t<n-r&&(n=e.length-t+r);var i,s=n-r;if(this===e&&r<t&&t<n)for(i=s-1;i>=0;--i)e[i+t]=this[i+r];else if(s<1e3||!u.TYPED_ARRAY_SUPPORT)for(i=0;i<s;++i)e[i+t]=this[i+r];else Uint8Array.prototype.set.call(e,this.subarray(r,r+s),t);return s},u.prototype.fill=function(e,t,r,n){if("string"==typeof e){if("string"==typeof t?(n=t,t=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),1===e.length){var i=e.charCodeAt(0);i<256&&(e=i)}if(void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!u.isEncoding(n))throw new TypeError("Unknown encoding: "+n)}else"number"==typeof e&&(e&=255);if(t<0||this.length<t||this.length<r)throw new RangeError("Out of range index");if(r<=t)return this;var s;if(t>>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(s=t;s<r;++s)this[s]=e;else{var o=u.isBuffer(e)?e:B(new u(e,n).toString()),a=o.length;for(s=0;s<r-t;++s)this[s+t]=o[s%a]}return this};var L=/[^+\/0-9A-Za-z-_]/g;function B(e,t){var r;t=t||1/0;for(var n=e.length,i=null,s=[],o=0;o<n;++o){if((r=e.charCodeAt(o))>55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&s.push(239,191,189);continue}if(o+1===n){(t-=3)>-1&&s.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&s.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(t-=3)>-1&&s.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;s.push(r)}else if(r<2048){if((t-=2)<0)break;s.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;s.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;s.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return s}function $(e){return n.toByteArray(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(L,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function q(e,t,r,n){for(var i=0;i<n&&!(i+r>=t.length||i>=e.length);++i)t[i+r]=e[i];return i}},249:function(e,t,r){var n;e.exports=(n=n||function(e,t){var n;if("undefined"!=typeof window&&window.crypto&&(n=window.crypto),"undefined"!=typeof self&&self.crypto&&(n=self.crypto),"undefined"!=typeof globalThis&&globalThis.crypto&&(n=globalThis.crypto),!n&&"undefined"!=typeof window&&window.msCrypto&&(n=window.msCrypto),!n&&void 0!==r.g&&r.g.crypto&&(n=r.g.crypto),!n)try{n=r(480)}catch(e){}var i=function(){if(n){if("function"==typeof n.getRandomValues)try{return n.getRandomValues(new Uint32Array(1))[0]}catch(e){}if("function"==typeof n.randomBytes)try{return n.randomBytes(4).readInt32LE()}catch(e){}}throw new Error("Native crypto module could not be used to get secure random number.")},s=Object.create||function(){function e(){}return function(t){var r;return e.prototype=t,r=new e,e.prototype=null,r}}(),o={},a=o.lib={},u=a.Base={extend:function(e){var t=s(this);return e&&t.mixIn(e),t.hasOwnProperty("init")&&this.init!==t.init||(t.init=function(){t.$super.init.apply(this,arguments)}),t.init.prototype=t,t.$super=this,t},create:function(){var e=this.extend();return e.init.apply(e,arguments),e},init:function(){},mixIn:function(e){for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t]);e.hasOwnProperty("toString")&&(this.toString=e.toString)},clone:function(){return this.init.prototype.extend(this)}},c=a.WordArray=u.extend({init:function(e,t){e=this.words=e||[],this.sigBytes=null!=t?t:4*e.length},toString:function(e){return(e||h).stringify(this)},concat:function(e){var t=this.words,r=e.words,n=this.sigBytes,i=e.sigBytes;if(this.clamp(),n%4)for(var s=0;s<i;s++){var o=r[s>>>2]>>>24-s%4*8&255;t[n+s>>>2]|=o<<24-(n+s)%4*8}else for(var a=0;a<i;a+=4)t[n+a>>>2]=r[a>>>2];return this.sigBytes+=i,this},clamp:function(){var t=this.words,r=this.sigBytes;t[r>>>2]&=4294967295<<32-r%4*8,t.length=e.ceil(r/4)},clone:function(){var e=u.clone.call(this);return e.words=this.words.slice(0),e},random:function(e){for(var t=[],r=0;r<e;r+=4)t.push(i());return new c.init(t,e)}}),l=o.enc={},h=l.Hex={stringify:function(e){for(var t=e.words,r=e.sigBytes,n=[],i=0;i<r;i++){var s=t[i>>>2]>>>24-i%4*8&255;n.push((s>>>4).toString(16)),n.push((15&s).toString(16))}return n.join("")},parse:function(e){for(var t=e.length,r=[],n=0;n<t;n+=2)r[n>>>3]|=parseInt(e.substr(n,2),16)<<24-n%8*4;return new c.init(r,t/2)}},f=l.Latin1={stringify:function(e){for(var t=e.words,r=e.sigBytes,n=[],i=0;i<r;i++){var s=t[i>>>2]>>>24-i%4*8&255;n.push(String.fromCharCode(s))}return n.join("")},parse:function(e){for(var t=e.length,r=[],n=0;n<t;n++)r[n>>>2]|=(255&e.charCodeAt(n))<<24-n%4*8;return new c.init(r,t)}},d=l.Utf8={stringify:function(e){try{return decodeURIComponent(escape(f.stringify(e)))}catch(e){throw new Error("Malformed UTF-8 data")}},parse:function(e){return f.parse(unescape(encodeURIComponent(e)))}},p=a.BufferedBlockAlgorithm=u.extend({reset:function(){this._data=new c.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=d.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(t){var r,n=this._data,i=n.words,s=n.sigBytes,o=this.blockSize,a=s/(4*o),u=(a=t?e.ceil(a):e.max((0|a)-this._minBufferSize,0))*o,l=e.min(4*u,s);if(u){for(var h=0;h<u;h+=o)this._doProcessBlock(i,h);r=i.splice(0,u),n.sigBytes-=l}return new c.init(r,l)},clone:function(){var e=u.clone.call(this);return e._data=this._data.clone(),e},_minBufferSize:0}),g=(a.Hasher=p.extend({cfg:u.extend(),init:function(e){this.cfg=this.cfg.extend(e),this.reset()},reset:function(){p.reset.call(this),this._doReset()},update:function(e){return this._append(e),this._process(),this},finalize:function(e){return e&&this._append(e),this._doFinalize()},blockSize:16,_createHelper:function(e){return function(t,r){return new e.init(r).finalize(t)}},_createHmacHelper:function(e){return function(t,r){return new g.HMAC.init(e,r).finalize(t)}}}),o.algo={});return o}(Math),n)},269:function(e,t,r){var n,i,s;e.exports=(n=r(249),s=(i=n).lib.WordArray,i.enc.Base64={stringify:function(e){var t=e.words,r=e.sigBytes,n=this._map;e.clamp();for(var i=[],s=0;s<r;s+=3)for(var o=(t[s>>>2]>>>24-s%4*8&255)<<16|(t[s+1>>>2]>>>24-(s+1)%4*8&255)<<8|t[s+2>>>2]>>>24-(s+2)%4*8&255,a=0;a<4&&s+.75*a<r;a++)i.push(n.charAt(o>>>6*(3-a)&63));var u=n.charAt(64);if(u)for(;i.length%4;)i.push(u);return i.join("")},parse:function(e){var t=e.length,r=this._map,n=this._reverseMap;if(!n){n=this._reverseMap=[];for(var i=0;i<r.length;i++)n[r.charCodeAt(i)]=i}var o=r.charAt(64);if(o){var a=e.indexOf(o);-1!==a&&(t=a)}return function(e,t,r){for(var n=[],i=0,o=0;o<t;o++)if(o%4){var a=r[e.charCodeAt(o-1)]<<o%4*2|r[e.charCodeAt(o)]>>>6-o%4*2;n[i>>>2]|=a<<24-i%4*8,i++}return s.create(n,i)}(e,t,n)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="},n.enc.Base64)},10:function(e,t,r){var n;e.exports=(n=r(249),r(153),r(824),n.HmacSHA256)},824:function(e,t,r){var n,i,s;e.exports=(i=(n=r(249)).lib.Base,s=n.enc.Utf8,void(n.algo.HMAC=i.extend({init:function(e,t){e=this._hasher=new e.init,"string"==typeof t&&(t=s.parse(t));var r=e.blockSize,n=4*r;t.sigBytes>n&&(t=e.finalize(t)),t.clamp();for(var i=this._oKey=t.clone(),o=this._iKey=t.clone(),a=i.words,u=o.words,c=0;c<r;c++)a[c]^=1549556828,u[c]^=909522486;i.sigBytes=o.sigBytes=n,this.reset()},reset:function(){var e=this._hasher;e.reset(),e.update(this._iKey)},update:function(e){return this._hasher.update(e),this},finalize:function(e){var t=this._hasher,r=t.finalize(e);return t.reset(),t.finalize(this._oKey.clone().concat(r))}})))},433:function(e,t,r){var n;e.exports=(n=r(249),function(){if("function"==typeof ArrayBuffer){var e=n.lib.WordArray,t=e.init,r=e.init=function(e){if(e instanceof ArrayBuffer&&(e=new Uint8Array(e)),(e instanceof Int8Array||"undefined"!=typeof Uint8ClampedArray&&e instanceof Uint8ClampedArray||e instanceof Int16Array||e instanceof Uint16Array||e instanceof Int32Array||e instanceof Uint32Array||e instanceof Float32Array||e instanceof Float64Array)&&(e=new Uint8Array(e.buffer,e.byteOffset,e.byteLength)),e instanceof Uint8Array){for(var r=e.byteLength,n=[],i=0;i<r;i++)n[i>>>2]|=e[i]<<24-i%4*8;t.call(this,n,r)}else t.apply(this,arguments)};r.prototype=e}}(),n.lib.WordArray)},153:function(e,t,r){var n;e.exports=(n=r(249),function(e){var t=n,r=t.lib,i=r.WordArray,s=r.Hasher,o=t.algo,a=[],u=[];!function(){function t(t){for(var r=e.sqrt(t),n=2;n<=r;n++)if(!(t%n))return!1;return!0}function r(e){return 4294967296*(e-(0|e))|0}for(var n=2,i=0;i<64;)t(n)&&(i<8&&(a[i]=r(e.pow(n,.5))),u[i]=r(e.pow(n,1/3)),i++),n++}();var c=[],l=o.SHA256=s.extend({_doReset:function(){this._hash=new i.init(a.slice(0))},_doProcessBlock:function(e,t){for(var r=this._hash.words,n=r[0],i=r[1],s=r[2],o=r[3],a=r[4],l=r[5],h=r[6],f=r[7],d=0;d<64;d++){if(d<16)c[d]=0|e[t+d];else{var p=c[d-15],g=(p<<25|p>>>7)^(p<<14|p>>>18)^p>>>3,y=c[d-2],w=(y<<15|y>>>17)^(y<<13|y>>>19)^y>>>10;c[d]=g+c[d-7]+w+c[d-16]}var m=n&i^n&s^i&s,b=(n<<30|n>>>2)^(n<<19|n>>>13)^(n<<10|n>>>22),_=f+((a<<26|a>>>6)^(a<<21|a>>>11)^(a<<7|a>>>25))+(a&l^~a&h)+u[d]+c[d];f=h,h=l,l=a,a=o+_|0,o=s,s=i,i=n,n=_+(b+m)|0}r[0]=r[0]+n|0,r[1]=r[1]+i|0,r[2]=r[2]+s|0,r[3]=r[3]+o|0,r[4]=r[4]+a|0,r[5]=r[5]+l|0,r[6]=r[6]+h|0,r[7]=r[7]+f|0},_doFinalize:function(){var t=this._data,r=t.words,n=8*this._nDataBytes,i=8*t.sigBytes;return r[i>>>5]|=128<<24-i%32,r[14+(i+64>>>9<<4)]=e.floor(n/4294967296),r[15+(i+64>>>9<<4)]=n,t.sigBytes=4*r.length,this._process(),this._hash},clone:function(){var e=s.clone.call(this);return e._hash=this._hash.clone(),e}});t.SHA256=s._createHelper(l),t.HmacSHA256=s._createHmacHelper(l)}(Math),n.SHA256)},645:(e,t)=>{t.read=function(e,t,r,n,i){var s,o,a=8*i-n-1,u=(1<<a)-1,c=u>>1,l=-7,h=r?i-1:0,f=r?-1:1,d=e[t+h];for(h+=f,s=d&(1<<-l)-1,d>>=-l,l+=a;l>0;s=256*s+e[t+h],h+=f,l-=8);for(o=s&(1<<-l)-1,s>>=-l,l+=n;l>0;o=256*o+e[t+h],h+=f,l-=8);if(0===s)s=1-c;else{if(s===u)return o?NaN:1/0*(d?-1:1);o+=Math.pow(2,n),s-=c}return(d?-1:1)*o*Math.pow(2,s-n)},t.write=function(e,t,r,n,i,s){var o,a,u,c=8*s-i-1,l=(1<<c)-1,h=l>>1,f=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:s-1,p=n?1:-1,g=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,o=l):(o=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-o))<1&&(o--,u*=2),(t+=o+h>=1?f/u:f*Math.pow(2,1-h))*u>=2&&(o++,u/=2),o+h>=l?(a=0,o=l):o+h>=1?(a=(t*u-1)*Math.pow(2,i),o+=h):(a=t*Math.pow(2,h-1)*Math.pow(2,i),o=0));i>=8;e[r+d]=255&a,d+=p,a/=256,i-=8);for(o=o<<i|a,c+=i;c>0;e[r+d]=255&o,d+=p,o/=256,c-=8);e[r+d-p]|=128*g}},826:e=>{var t={}.toString;e.exports=Array.isArray||function(e){return"[object Array]"==t.call(e)}},204:(e,t,r)=>{e.exports=self.fetch||(self.fetch=r(869).default||r(869))},808:(e,t,r)=>{var n,i,s;void 0===(i="function"==typeof(n=s=function(){function e(){for(var e=0,t={};e<arguments.length;e++){var r=arguments[e];for(var n in r)t[n]=r[n]}return t}function t(e){return e.replace(/(%[0-9A-Z]{2})+/g,decodeURIComponent)}return function r(n){function i(){}function s(t,r,s){if("undefined"!=typeof document){"number"==typeof(s=e({path:"/"},i.defaults,s)).expires&&(s.expires=new Date(1*new Date+864e5*s.expires)),s.expires=s.expires?s.expires.toUTCString():"";try{var o=JSON.stringify(r);/^[\{\[]/.test(o)&&(r=o)}catch(e){}r=n.write?n.write(r,t):encodeURIComponent(String(r)).replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g,decodeURIComponent),t=encodeURIComponent(String(t)).replace(/%(23|24|26|2B|5E|60|7C)/g,decodeURIComponent).replace(/[\(\)]/g,escape);var a="";for(var u in s)s[u]&&(a+="; "+u,!0!==s[u]&&(a+="="+s[u].split(";")[0]));return document.cookie=t+"="+r+a}}function o(e,r){if("undefined"!=typeof document){for(var i={},s=document.cookie?document.cookie.split("; "):[],o=0;o<s.length;o++){var a=s[o].split("="),u=a.slice(1).join("=");r||'"'!==u.charAt(0)||(u=u.slice(1,-1));try{var c=t(a[0]);if(u=(n.read||n)(u,c)||t(u),r)try{u=JSON.parse(u)}catch(e){}if(i[c]=u,e===c)break}catch(e){}}return e?i[e]:i}}return i.set=s,i.get=function(e){return o(e,!1)},i.getJSON=function(e){return o(e,!0)},i.remove=function(t,r){s(t,"",e(r,{expires:-1}))},i.defaults={},i.withConverter=r,i}((function(){}))})?n.call(t,r,t,e):n)||(e.exports=i),e.exports=s()},869:(e,t,r)=>{"use strict";function n(e,t){return t=t||{},new Promise((function(r,n){var i=new XMLHttpRequest,s=[],o=[],a={},u=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(i.responseText).then(JSON.parse)},blob:function(){return Promise.resolve(new Blob([i.response]))},clone:u,headers:{keys:function(){return s},entries:function(){return o},get:function(e){return a[e.toLowerCase()]},has:function(e){return e.toLowerCase()in a}}}};for(var c in i.open(t.method||"get",e,!0),i.onload=function(){i.getAllResponseHeaders().replace(/^(.*?):[^\S\n]*([\s\S]*?)$/gm,(function(e,t,r){s.push(t=t.toLowerCase()),o.push([t,r]),a[t]=a[t]?a[t]+","+r:r})),r(u())},i.onerror=n,i.withCredentials="include"==t.credentials,t.headers)i.setRequestHeader(c,t.headers[c]);i.send(t.body||null)}))}r.r(t),r.d(t,{default:()=>n})},296:()=>{},480:()=>{}},t={};function r(n){var i=t[n];if(void 0!==i)return i.exports;var s=t[n]={exports:{}};return e[n].call(s.exports,s,s.exports,r),s.exports}r.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return r.d(t,{a:t}),t},r.d=(e,t)=>{for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var n={};return(()=>{"use strict";r.r(n),r.d(n,{Skapi:()=>At,SkapiError:()=>e});class e extends Error{constructor(e,t){Array.isArray(e)&&e.length<=2?(super(e[1]||"Something went wrong."),this.name="SKAPI",this.code=e[0]||"ERROR",t&&(t.code&&(this.code=t.code),t.cause&&(this.cause=t.cause))):"string"==typeof e?(super(e||"Something went wrong."),this.name="SKAPI",this.code="ERROR",t&&(t.code&&(this.code=t.code),t.cause&&(this.cause=t.cause))):e instanceof Error&&(super(e.message||"Something went wrong."),this.cause=e,this.name=e.name,e.hasOwnProperty("code")&&(this.code=e.code))}}class t{static hash(e){"string"!=typeof e&&(console.warn("coercing non-string value to empty string"),e="");const r=t.sb(e);let n,i,s,o,a=1732584193,u=-271733879,c=-1732584194,l=271733878;for(let e=0;e<r.length;e+=16)n=a,i=u,s=c,o=l,a=t.ff(a,u,c,l,r[e],7,-680876936),l=t.ff(l,a,u,c,r[e+1],12,-389564586),c=t.ff(c,l,a,u,r[e+2],17,606105819),u=t.ff(u,c,l,a,r[e+3],22,-1044525330),a=t.ff(a,u,c,l,r[e+4],7,-176418897),l=t.ff(l,a,u,c,r[e+5],12,1200080426),c=t.ff(c,l,a,u,r[e+6],17,-1473231341),u=t.ff(u,c,l,a,r[e+7],22,-45705983),a=t.ff(a,u,c,l,r[e+8],7,1770035416),l=t.ff(l,a,u,c,r[e+9],12,-1958414417),c=t.ff(c,l,a,u,r[e+10],17,-42063),u=t.ff(u,c,l,a,r[e+11],22,-1990404162),a=t.ff(a,u,c,l,r[e+12],7,1804603682),l=t.ff(l,a,u,c,r[e+13],12,-40341101),c=t.ff(c,l,a,u,r[e+14],17,-1502002290),u=t.ff(u,c,l,a,r[e+15],22,1236535329),a=t.gg(a,u,c,l,r[e+1],5,-165796510),l=t.gg(l,a,u,c,r[e+6],9,-1069501632),c=t.gg(c,l,a,u,r[e+11],14,643717713),u=t.gg(u,c,l,a,r[e],20,-373897302),a=t.gg(a,u,c,l,r[e+5],5,-701558691),l=t.gg(l,a,u,c,r[e+10],9,38016083),c=t.gg(c,l,a,u,r[e+15],14,-660478335),u=t.gg(u,c,l,a,r[e+4],20,-405537848),a=t.gg(a,u,c,l,r[e+9],5,568446438),l=t.gg(l,a,u,c,r[e+14],9,-1019803690),c=t.gg(c,l,a,u,r[e+3],14,-187363961),u=t.gg(u,c,l,a,r[e+8],20,1163531501),a=t.gg(a,u,c,l,r[e+13],5,-1444681467),l=t.gg(l,a,u,c,r[e+2],9,-51403784),c=t.gg(c,l,a,u,r[e+7],14,1735328473),u=t.gg(u,c,l,a,r[e+12],20,-1926607734),a=t.hh(a,u,c,l,r[e+5],4,-378558),l=t.hh(l,a,u,c,r[e+8],11,-2022574463),c=t.hh(c,l,a,u,r[e+11],16,1839030562),u=t.hh(u,c,l,a,r[e+14],23,-35309556),a=t.hh(a,u,c,l,r[e+1],4,-1530992060),l=t.hh(l,a,u,c,r[e+4],11,1272893353),c=t.hh(c,l,a,u,r[e+7],16,-155497632),u=t.hh(u,c,l,a,r[e+10],23,-1094730640),a=t.hh(a,u,c,l,r[e+13],4,681279174),l=t.hh(l,a,u,c,r[e],11,-358537222),c=t.hh(c,l,a,u,r[e+3],16,-722521979),u=t.hh(u,c,l,a,r[e+6],23,76029189),a=t.hh(a,u,c,l,r[e+9],4,-640364487),l=t.hh(l,a,u,c,r[e+12],11,-421815835),c=t.hh(c,l,a,u,r[e+15],16,530742520),u=t.hh(u,c,l,a,r[e+2],23,-995338651),a=t.ii(a,u,c,l,r[e],6,-198630844),l=t.ii(l,a,u,c,r[e+7],10,1126891415),c=t.ii(c,l,a,u,r[e+14],15,-1416354905),u=t.ii(u,c,l,a,r[e+5],21,-57434055),a=t.ii(a,u,c,l,r[e+12],6,1700485571),l=t.ii(l,a,u,c,r[e+3],10,-1894986606),c=t.ii(c,l,a,u,r[e+10],15,-1051523),u=t.ii(u,c,l,a,r[e+1],21,-2054922799),a=t.ii(a,u,c,l,r[e+8],6,1873313359),l=t.ii(l,a,u,c,r[e+15],10,-30611744),c=t.ii(c,l,a,u,r[e+6],15,-1560198380),u=t.ii(u,c,l,a,r[e+13],21,1309151649),a=t.ii(a,u,c,l,r[e+4],6,-145523070),l=t.ii(l,a,u,c,r[e+11],10,-1120210379),c=t.ii(c,l,a,u,r[e+2],15,718787259),u=t.ii(u,c,l,a,r[e+9],21,-343485551),a=t.ad(a,n),u=t.ad(u,i),c=t.ad(c,s),l=t.ad(l,o);return t.rh(a)+t.rh(u)+t.rh(c)+t.rh(l)}static rh(e){let r="";for(let n=0;n<=3;n++)r+=t.alphabet.charAt(e>>8*n+4&15)+t.alphabet.charAt(e>>8*n&15);return r}static ad(e,t){const r=(65535&e)+(65535&t);return(e>>16)+(t>>16)+(r>>16)<<16|65535&r}static rl(e,t){return e<<t|e>>>32-t}static cm(e,r,n,i,s,o){return t.ad(t.rl(t.ad(t.ad(r,e),t.ad(i,o)),s),n)}static ff(e,r,n,i,s,o,a){return t.cm(r&n|~r&i,e,r,s,o,a)}static gg(e,r,n,i,s,o,a){return t.cm(r&i|n&~i,e,r,s,o,a)}static hh(e,r,n,i,s,o,a){return t.cm(r^n^i,e,r,s,o,a)}static ii(e,r,n,i,s,o,a){return t.cm(n^(r|~i),e,r,s,o,a)}static sb(e){let t;const r=1+(e.length+8>>6),n=new Array(16*r);for(t=0;t<16*r;t++)n[t]=0;for(t=0;t<e.length;t++)n[t>>2]|=e.charCodeAt(t)<<t%4*8;return n[t>>2]|=128<<t%4*8,n[16*r-2]=8*e.length,n}}function i(t){function r(e,t,r){let n=t.slice(0,1),i=t.slice(-1);if("."===n&&(t=t.slice(1)),"."===i&&(t=t.slice(0,-1)),t.includes(".")){let r=t.split(".");t=r.pop();for(let t of r)t&&(e.hasOwnProperty(t)||(e[t]={}),e=e[t])}e.hasOwnProperty(t)?Array.isArray(e[t])?e[t].push(r):e[t]=[e[t],r]:e[t]=r}if(t instanceof FormData){let n={},i=0,s=[];for(let e of t.entries()){let t=e[0],o=e[1];if(o instanceof File)s.includes(t)||s.push(t),i+=o.size;else if(o instanceof FileList){if(s.includes(t)||s.push(t),o&&o.length>0)for(let e=0;e<=o.length-1;e++)i+=o.item(e).size}else r(n,t,o)}if(i>44e5)throw new e("Total File size cannot exceed 4MB. Use skapi.uploadFiles() instead.",{code:"INVALID_REQUEST"});return{meta:n,files:s}}if(t instanceof SubmitEvent&&(t=t.target),t instanceof HTMLFormElement){let n={},i=[],s=0,o=t.querySelectorAll("input"),a=t.querySelectorAll("textarea");for(let e=0;e<a.length;e++){let t=a[e];t.name&&r(n,t.name,t.value)}for(let e=0;e<o.length;e++){let t=o[e];if(t.name)if("number"===t.type)t.value&&r(n,t.name,Number(t.value));else if("checkbox"===t.type||"radio"===t.type)t.checked?""===t.value&&"checkbox"===t.type||"on"===t.value||"true"===t.value?r(n,t.name,!0):"false"===t.value?r(n,t.name,!1):t.value&&r(n,t.name,t.value):"checkbox"===t.type&&(""===t.value||"on"===t.value||"true"===t.value?r(n,t.name,!1):"false"===t.value?r(n,t.name,!0):r(n,t.name,void 0));else if("file"===t.type){if(i.includes(t.name)||i.push(t.name),t.files&&t.files.length>0)for(let e=0;e<=t.files.length-1;e++)s+=t.files.item(e).size}else r(n,t.name,t.value)}if(s>44e5)throw new e("Total File size cannot exceed 4MB. Use skapi.uploadFiles() instead.",{code:"INVALID_REQUEST"});return{meta:n,files:i}}return null}t.alphabet="0123456789abcdef";const s={UserId:function(t,r="User ID"){if(!t)throw new e(`${r} is empty.`,{code:"INVALID_PARAMETER"});if("string"!=typeof t)throw new e(`${r} should be type: string.`,{code:"INVALID_PARAMETER"});if(!t.match(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-5][0-9a-f]{3}-[089ab][0-9a-f]{3}-[0-9a-f]{12}$/i))throw new e(`${r} is invalid.`,{code:"INVALID_PARAMETER"});return t},PhoneNumber:function(t){if(t&&("string"!=typeof t||"+"!==t.charAt(0)||isNaN(Number(t.substring(1)))))throw new e('"phone_number" is invalid. The format should be "+00123456789". Type: string.',{code:"INVALID_PARAMETER"});return t||""},Birthdate:function(t){if(t){if("string"!=typeof t)throw new e('"birthdate" is invalid. The format should be "yyyy-mm-dd". Type: string.',{code:"INVALID_PARAMETER"});{let r=new RegExp(/([12]\d{3}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01]))/);if(10!==t.length||3!==t.split("-").length||!r.test(t))throw new e('"birthdate" is invalid. The format should be "yyyy-mm-dd". Type: string.',{code:"INVALID_PARAMETER"})}}return t||""},Password:function(t){if(!t)throw new e('"password" is required.',{code:"INVALID_PARAMETER"});if("string"!=typeof t)throw new e('"password" should be type: string.',{code:"INVALID_PARAMETER"});if(t.length<6)throw new e('"password" should be at least 6 characters.',{code:"INVALID_PARAMETER"});if(t.length>60)throw new e('"password" can be up to 60 characters max.',{code:"INVALID_PARAMETER"});return t},Email:function(t,r="email"){if(!t)throw new e(`"${r}" is required.`,{code:"INVALID_PARAMETER"});if("string"!=typeof t)throw new e(`"${r}"should be type: string.`,{code:"INVALID_PARAMETER"});if(t.length<5)throw new e(`"${r}" should be at least 5 characters.`,{code:"INVALID_PARAMETER"});if(/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/.test(t)&&(t=t.trim()).split("@")[1].split(".").length>=2)return t.toLowerCase();throw new e(`"${t}" is an invalid email.`,{code:"INVALID_PARAMETER"})},Url:function(t){const r=(()=>{let e=window.location.origin||null;return e&&"/"===e.slice(-1)&&(e=e.slice(0,-1)),e})();let n=t=>{if("string"==typeof t){if("*"===t)return"*";{let n=t.trim();if(!n.includes(" ")&&!n.includes(",")){let i;"/"===n.slice(0,1)&&r?n=r+n:"."===n.slice(0,1)&&r&&(n=window.location.href.split("/").slice(0,-1).join("/")+n);try{i=new URL(n)}catch(r){throw new e(`"${t}" is an invalid url.`,{code:"INVALID_PARAMETER"})}if(i.protocol){let e=i.href;return"/"===e.charAt(e.length-1)&&(e=e.substring(0,e.length-1)),e}}}}throw new e(`"${t}" is an invalid url.`,{code:"INVALID_PARAMETER"})};return Array.isArray(t)?t.map((e=>n(e))):n(t)},specialChars:function(t,r="parameter",n=!1,i=!1){let s=s=>{if("string"!=typeof s)throw new e(`${r} should be type: <string | string[]>.`,{code:"INVALID_PARAMETER"});if(!i&&t.includes(" "))throw new e(`${r} should not have whitespace.`,{code:"INVALID_PARAMETER"});if(!n&&t.includes("."))throw new e(`${r} should not have periods.`,{code:"INVALID_PARAMETER"});if(/[`!@#$%^&*()_+\-=\[\]{};':"\\|,<>\/?~]/.test(s))throw new e(`${r} should not have special characters.`,{code:"INVALID_PARAMETER"})};if(Array.isArray(t))for(let e of t)s(e);else s(t);return t},Params:function t(r,n,s=null,o=[],a=null){function u(t){if(t instanceof Promise)throw new e("Parameter should not be a promise",{code:"INVALID_PARAMETER"});return t&&"object"==typeof t&&!Array.isArray(t)&&Object.keys(t).length}Array.isArray(o)&&(o=o.concat(["service","owner"]));let c,l=r,h=null,f=a?` in "${a}" is invalid.`:". Parameter should be type <object>.";if(null===a){if(u(l)){l=l instanceof HTMLFormElement||l instanceof FormData||l instanceof SubmitEvent?i(r)?.meta:JSON.parse(JSON.stringify(r));for(let t in l)if(!n.hasOwnProperty(t)&&Array.isArray(o)&&!o.includes(t))throw new e(`Key name "${t}" is invalid in parameter.`,{code:"INVALID_PARAMETER"});if(Array.isArray(s)&&s.length)for(let t of s)if(!Object.keys(l).includes(t))throw new e(`Key "${t}" is required in parameter.`,{code:"INVALID_PARAMETER"})}else if((d=l)&&"object"==typeof d&&!Array.isArray(d)&&!Object.keys(d).length||void 0===l){let e={};for(let t in n){let r=n[t];Array.isArray(r)&&"function"==typeof r[r.length-1]&&(e[t]=r[r.length-1]())}return Object.keys(e).length?e:l}if(null===l)return null}var d;if(u(n)&&u(l)){for(let e in n){let r=n[e];if(l.hasOwnProperty(e)&&null===l[e])l[e]=null;else if(l.hasOwnProperty(e)&&void 0!==l[e])l[e]=t(l[e],r,null,null,e);else{let t=Array.isArray(r)&&"function"==typeof r[r.length-1]?r[r.length-1]:null;if(t){let r=t();void 0!==r&&(l[e]=r)}}}c=l}else if(Array.isArray(n))for(let r of n)try{void 0!==typeof l&&"function"!=typeof r&&(c=t(l,r,null,null,a));break}catch(t){if("string"==typeof t&&"BREAK:"===t.substring(0,6)){let r=(t=t.substring(6)).split(":");h=new e(r[1],{code:r[0]});break}h=t}else{if("function"==typeof n)return n(l);if("string"==typeof n)if(Array.isArray(l)){if("array"!==n)throw new e(`Invalid type "${typeof l}"${f}`,{code:"INVALID_PARAMETER"});for(let t of l)if(!["number","string","boolean"].includes(typeof t)&&null!==t)throw new e(`Invalid type "${typeof t}" in "${a}" array value.`,{code:"INVALID_PARAMETER"});c=l}else if(["number","string","boolean","array","function"].includes(n)){if(typeof l!==n)throw new e(`Value: ${l}${f}`,{code:"INVALID_PARAMETER"});if("number"===n&&Math.abs(l)>4503599627370496)throw`BREAK:INVALID_PARAMETER:"${a}" integer value should be within -4503599627370496 ~ +4503599627370546.`;c=l}else{if(l!==n)throw new e(`Value: ${l}${f}`,{code:"INVALID_PARAMETER"});c=l}else null===n&&(c=l)}if(void 0===c&&h)throw h;return c}},o={};function a(){return this.__connection}async function u(t,r=null,n){n=n||{};let{auth:i=!1,method:a="post",meta:u=null,bypassAwaitConnection:h=!1}=n;a=a.toLowerCase();let p=h?null:await this.__connection;if(!p&&!h)throw new e("Invalid connection. The service could have been disabled, or has a restricted CORS.",{code:"INVALID_REQUEST"});let g=i?this.session?.idToken?.jwtToken:null;if(i){if(!g)throw this.logout(),new e("User login is required.",{code:"INVALID_REQUEST"});{let t=Date.now()/1e3;if(this.session.idToken.payload.exp<t)try{await this.authentication().getSession({refreshToken:!0}),g=this.session?.idToken?.jwtToken}catch(t){throw this.logout(),new e("User login is required.",{code:"INVALID_REQUEST"})}}}let y="";try{y=s.Url(t)}catch(e){}let w=y||await(async(e,t)=>{const r=await Promise.all([this.admin_endpoint,this.record_endpoint]),n=r[0],i=r[1];return((()=>{switch(e){case"get-newsletters":case"get-public-newsletters":case"delete-newsletter":case"block-account":case"register-service":case"get-users":case"post-userdata":case"remove-account":case"post-secure":case"subscribe-newsletter":case"subscribe-public-newsletter":case"signup":case"confirm-signup":case"recover-account":case"mock":case"get-services":case"service":case"grant-access":case"last-verified-email":case"get-newsletter-subscription":case"request-username-change":case"register-subdomain":case"list-host-directory":case"refresh-cdn":case"request-newsletter-sender":case"set-404":return{public:n.admin_public,private:n.admin_private};case"post-record":case"get-records":case"subscription":case"get-subscription":case"del-records":case"get-table":case"get-tag":case"get-index":case"storage-info":case"get-signed-url":case"grant-private-access":case"request-private-access-key":case"del-files":return{private:i.record_private,public:i.record_public};default:return null}})()?.[t?"private":"public"]||"")+e})(t,!!i),m=this.session?.attributes?.["custom:service"]||p?.service||this.service,b=this.session?.attributes?.["custom:owner"]||p?.owner||this.owner;if(u){if("object"!=typeof u||Array.isArray(u))throw new e("Invalid meta data.",{code:"INVALID_REQUEST"});u=JSON.parse(JSON.stringify(u))}if(Array.isArray(r)||r&&"object"!=typeof r)throw new e("Request data should be a JSON Object | FormData | HTMLFormElement.",{code:"INVALID_REQUEST"});let _="blob"!==n?.responseType?{service:m,owner:b}:{},A={},{fetchMore:v=!1,progress:E}=n?.fetchOptions||{};if(n?.fetchOptions&&Object.keys(n.fetchOptions).length){let t=s.Params({limit:n.fetchOptions?.limit||50,startKey:n.fetchOptions?.startKey||null,ascending:"boolean"!=typeof n.fetchOptions?.ascending||n.fetchOptions.ascending},{limit:["number",()=>50],startKey:null,ascending:["boolean",()=>!0]});if(t.hasOwnProperty("limit")&&"number"==typeof t.limit){if(t.limit>1e3)throw new e("Fetch limit should be below 1000.",{code:"INVALID_REQUEST"});Object.assign(A,{limit:t.limit})}t.hasOwnProperty("startKey")&&"object"==typeof t.startKey&&t.startKey&&Object.keys(t.startKey)&&Object.assign(A,{startKey:t.startKey}),t.hasOwnProperty("ascending")&&"boolean"==typeof t.ascending&&Object.assign(A,{ascending:t.ascending})}Object.assign(_,A);let S=!1;if(r instanceof SubmitEvent&&(r=r?.target),r instanceof HTMLFormElement&&(r=new FormData(r)),r instanceof FormData&&(S=!0),u)u=Object.assign(_,u);else if(r)if(S)for(let e in _)void 0!==_[e]&&r.set(e,new Blob([JSON.stringify(_[e])],{type:"application/json"}));else r=Object.assign(_,r);else r=_;if(S&&"function"==typeof n?.fetchOptions?.formData){let t=n.fetchOptions.formData(r);if(t instanceof Promise&&(t=await t),t instanceof FormData&&(r=t),!(r instanceof FormData))throw new e("Callback for extractFormData() should return FormData",{code:"INVALID_PARAMETER"});{let t=0;for(let e of r.entries()){let r=e[1];if(r instanceof File)t+=r.size;else if(r instanceof FileList&&r&&r.length>0)for(let e=0;e<=r.length-1;e++)t+=r.item(e).size}if(t>42e5)throw new e("Files cannot exceed 4MB. Use skapi.uploadFiles(...) instead.",{code:"INVALID_REQUEST"})}}let I=c.bind(this)({params:r,url:y||t,fetchMore:!S&&v});if(I&&"object"==typeof I)return I;if(!I||"string"!=typeof I)return null;if(!(o[I]instanceof Promise)){let e={Accept:"*/*"};g&&(e.Authorization=g),u&&(e["Content-Meta"]=window.btoa(encodeURIComponent("string"==typeof u?u:JSON.stringify(u)))),n.hasOwnProperty("contentType")?n?.contentType&&(e["Content-Type"]=n.contentType):r instanceof FormData||(e["Content-Type"]="application/json");let i={headers:e};n?.responseType&&(i.responseType=n.responseType),"post"===a?o[I]=f.bind(this)(w,r,i,E):"get"===a&&(o[I]=d.bind(this)(w,r,i,E));try{let e=await o[I];return S?e:l.bind(this)({hashedParam:I,url:t,response:e})}catch(e){throw e}finally{I&&o.hasOwnProperty(I)&&delete o[I]}}}function c(r){let{params:n={},url:i,fetchMore:s=!1}=r||{};if(n.hasOwnProperty("startKey")&&n.startKey){if("object"!=typeof n.startKey&&!Object.keys(n.startKey).length&&"start"!==n.startKey&&"end"!==n.startKey)throw new e(`"${n.startKey}" is invalid startKey key.`,{code:"INVALID_PARAMETER"});"start"===n.startKey&&(s=!1,delete n.startKey)}let o=(()=>{if(n&&"object"==typeof n&&Object.keys(n).length){function e(e){function t(e){return"object"==typeof e&&e?Object.keys(e).sort().reduce(((t,r)=>(t[r]=e[r],t)),{}):e}let r=t(e);r.hasOwnProperty("limit")&&delete r.limit;for(let n in r)r[n]&&"object"==typeof r[n]&&(r[n]=t(e[n]));return r}return t.hash(i+"/"+JSON.stringify(e(n)))}return t.hash(i+"/"+this.service)})();if(!s&&this.__startKeyHistory?.[i]?.[o]){if(this.__cached_requests?.[i]&&this.__cached_requests?.[i]?.[o]&&delete this.__cached_requests[i][o],Array.isArray(this.__startKeyHistory[i][o])&&this.__startKeyHistory[i][o].length)for(let e of this.__startKeyHistory[i][o]){let r=o+"/"+t.hash(JSON.stringify(e));this.__cached_requests?.[i]&&this.__cached_requests?.[i]?.[r]&&delete this.__cached_requests[i][r]}return delete this.__startKeyHistory[i][o],o}if(!Array.isArray(this.__startKeyHistory?.[i]?.[o]))return o;let a=this.__startKeyHistory[i][o],u=a[a.length-1],c=o;if(u){if("end"===u)return{list:[],startKey:"end",endOfList:!0,startKeyHistory:this.__startKeyHistory[i][o]};c+=t.hash(u),n.startKey=JSON.parse(u)}return this.__cached_requests?.[i]?.[c]?this.__cached_requests[i][c]:o}async function l(e){let{hashedParam:t,url:r,response:n}=e,i=null;if(i=n instanceof Promise?await n:n,!(i&&"object"==typeof i&&i.hasOwnProperty("startKey")&&t&&r))return i;this.__startKeyHistory.hasOwnProperty(r)||(this.__startKeyHistory[r]={}),this.__cached_requests?.[r]||(this.__cached_requests[r]={}),this.__cached_requests[r][t]=i,this.__startKeyHistory[r].hasOwnProperty(t)||(this.__startKeyHistory[r][t]=[]);let s="end"===i.startKey?"end":JSON.stringify(i.startKey);return this.__startKeyHistory[r][t].includes(s)||this.__startKeyHistory[r][t].push(s),this.__cached_requests[r][t]=i,Object.assign({startKeyHistory:this.__startKeyHistory[r][t]},i)}async function h(t,r,n){let i=await((t,n,i)=>new Promise(((s,o)=>{let a=new XMLHttpRequest;for(var u in a.open((r.method||"GET").toUpperCase(),t),n.headers||{})a.setRequestHeader(u,n.headers[u]);r.responseType&&(a.responseType=r.responseType),a.onload=()=>{if(a.status>=200&&a.status<300)if("json"==n.responseType||"blob"==n.responseType)s(a.response);else{let e=a.responseText;try{e=JSON.parse(e)}catch(e){}s(e)}else{let t=a.status,r=["INVALID_CORS","INVALID_REQUEST","SERVICE_DISABLED","INVALID_PARAMETER","ERROR","EXISTS","NOT_EXISTS"],n=a.responseText;try{n=JSON.parse(n)}catch(e){}if("string"==typeof n){let t=a.response.split(":"),n=t.splice(0,1)[0].trim();o(new e(t.join("").trim(),{code:r.includes(n)?n:"ERROR"}))}else if("object"==typeof n&&n?.message){let r=n?.code||(t?t.toString():null)||"ERROR";o(new e(n?.message,{code:r}))}}},a.onerror=()=>o("Network error"),a.onabort=()=>o("Aborted"),a.ontimeout=()=>o("Timeout"),"function"==typeof i&&(a.onprogress=e=>{i({status:"download",progress:e.loaded/e.total*100,loaded:e.loaded,total:e.total,abort:()=>a.abort()})},a.upload&&(a.upload.onprogress=e=>{i({status:"upload",progress:e.loaded/e.total*100,loaded:e.loaded,total:e.total,abort:()=>a.abort()})})),a.send(n.body)})))(t,{headers:r?.headers,body:r.body,responseType:r?.responseType},n);if("object"==typeof i&&"GET"===r.method&&i.hasOwnProperty("body"))try{i=JSON.parse(i.body)}catch(e){}return i}async function f(e,t,r,n){let i=Object.assign({method:"POST"},r,{body:t instanceof FormData?t:JSON.stringify(t)});return h.bind(this)(e,i,n)}async function d(e,t,r,n){t&&"object"==typeof t&&Object.keys(t).length&&("?"!==e.substring(e.length-1)&&(e+="?"),e+=Object.keys(t).map((e=>{let r=t[e];return"string"!=typeof r&&(r=JSON.stringify(r)),encodeURIComponent(e)+"="+encodeURIComponent(r)})).join("&"));let i=Object.assign({method:"GET"},r);return h.bind(this)(e,i,n)}async function p(e){let t={url:e=>s.Url(e),data:null,sync:["boolean",()=>!0]};if(Array.isArray(e))for(let r of e)r=s.Params(r,t);else e=s.Params(e,t);return await u.bind(this)("post-secure",e,{auth:!0})}async function g(e,t){let{auth:r=!0,method:n="POST",meta:i,bypassAwaitConnection:s=!1,responseType:o,contentType:a}=t||{},{response:c,onerror:l,formData:h,progress:f}=t||{};return t&&Object.assign({auth:r,method:n,meta:i,bypassAwaitConnection:s,responseType:o,contentType:a},{fetchOptions:{response:c,onerror:l,formData:h,progress:f}}),u.bind(this)("mock",e,t)}async function y(){await this.__connection;let r=`${this.service}:${t.hash(window.location.href.split("?")[0])}`,n=window.sessionStorage.getItem(r);if(null!==n){try{n=JSON.parse(n)}catch(e){}return n}throw new e("Form response doesn't exist.",{code:"NOT_EXISTS"})}const w={};function m(r){let{preventMultipleCalls:n=!1}=r||{};return function(r,i,s){const o=s.value;s.value=function(...r){let s=r[0],a=r?.[1]||{},u=!0,c=null,l="";if(s instanceof SubmitEvent){s.preventDefault();let e=window.location.href;c=s.target;let t=new URL(c.action);l=t.href,c.action&&t.href!==e||(u=!1)}const h=r=>{if(a?.response){if("function"==typeof a.response)return a.response(r);throw new e('Callback "response" should be type: function.',{code:"INVALID_PARAMETER"})}return c&&u&&(window.sessionStorage.setItem(`${this.service}:${t.hash(l)}`,JSON.stringify(r)),window.location.href=l),r};let f,d=t=>{s instanceof SubmitEvent&&s.preventDefault();let r=t instanceof Error?t:new e(t);if(a?.onerror){if("function"==typeof a.onerror)return a.onerror(r);throw new e('Callback "onerror" should be type: function.',{code:"INVALID_PARAMETER"})}throw r};const p=()=>{try{f=o.bind(this)(...r)}catch(e){let t=d(e);if(t instanceof Error)throw t;return t}if(f instanceof Promise)return(async()=>{try{let e=await f;return h(e)}catch(e){return d(e)}})()};return n?(async()=>{if(w?.[i]instanceof Promise){let e=await w[i];return w[i]=null,e}return w[i]=p().finally((()=>{w[i]=null})),w[i]})():p()}}}const b=4503599627370496;function _(t){const r={user_id:"",record_id:"",updated:0,uploaded:0,table:{name:"",access_group:0},reference:{reference_limit:null,allow_multiple_reference:!0,referenced_count:0},ip:"",bin:[]},n={ip:e=>{r.ip=e},rec:e=>{if(!e)return;r.record_id=e;let t=e.substring(0,e.length-9).split("").reverse().reduce(((e,t,r)=>e+"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".indexOf(t)*62**r),0);r.uploaded=t},usr:e=>{r.user_id=e},tbl:e=>{if(!e)return;let t=e.split("/");r.table.name=t[0],r.table.access_group="**"==t[2]?"private":parseInt(t[2]),t?.[3]&&(r.table.subscription={user_id:t[3],group:parseInt(t[4])})},usr_tbl:e=>{let t=e.split("/");r.user_id=t[0],r.table.name=t[1],r.table.access_group="**"==t[3]?"private":parseInt(t[3]),t?.[4]&&(r.table.subscription={user_id:t[4],group:parseInt(t[5])})},idx:t=>{if(!t)return;let n=t.split("!"),i=n.splice(0,1)[0],s=function(t){let r=t.substring(3);switch(t.substring(0,3)){case"!S%":return r;case"!N%":let n=r.split("."),i=Number(n[0])-4503599627370496;return 1===n.length?i:parseFloat(i.toString()+"."+n[1]);case"!B%":return"1"===r;case"!L%":case"!D%":try{return JSON.parse(r)}catch(t){throw new e("Value parse error.",{code:"PARSE_ERROR"})}default:return t}}("!"+n.join("!"));r.index={name:i,value:s}},ref:e=>{e&&(r.reference.record_id=e.split("/")[0])},tags:e=>{r.tags=e},upd:e=>{r.updated=e},acpt_mrf:e=>{r.reference.allow_multiple_reference=e},ref_limt:e=>{r.reference.reference_limit=e},rfd:e=>{r.reference.referenced_count=e},bin:e=>{r.bin=e},data:e=>{let t=e;"!D%{}"===e?t={}:"!L%[]"===e&&(t=[]),r.data=t}};if(t.record_id)return t;for(let e in n)t.hasOwnProperty(e)&&n[e](t[e]);return r}async function A(t){let{endpoints:r}=t;if("string"==typeof r&&(r=[r]),!Array.isArray(r))throw new e('"endpoints" should be type: array | string.',{code:"INVALID_PARAMETER"});return u.bind(this)("del-files",{endpoints:r,storage:"records"},{auth:!0,method:"post"})}async function v(t,r){await this.__connection;let{service:n=this.service,request:i="post"}=r||{};if("post"===i){if(!r?.record_id)throw new e('"record_id" is required.',{code:"INVALID_PARAMETER"})}else{if(n===this.service)throw new e("invalid service.",{code:"INVALID_PARAMETER"});if("host"!==i)throw new e("invalid request.",{code:"INVALID_PARAMETER"})}if(t instanceof SubmitEvent&&(t=t.target),t instanceof HTMLFormElement&&(t=new FormData(t)),t instanceof FormData){let e=[];for(let r of t.entries()){let t=r[1];t instanceof File&&e.push(t)}t=e}if(!(t[0]instanceof File))throw new e('"fileList" should be a FileList or array of File object.',{code:"INVALID_PARAMETER"});let s,o={reserved_key:function(e=6){let t="";let r=0;for(;r<e;)t+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".charAt(Math.floor(62*Math.random())),r+=1;return t}(),service:n,request:i};r?.record_id&&(o.id=r.record_id);let a=(e,t,n)=>new Promise(((i,o)=>{s=new XMLHttpRequest,s.open("POST",e),s.onload=e=>{let t=s.responseText;try{t=JSON.parse(t)}catch(e){}if(s.status>=200&&s.status<300){let e=s.responseText;try{e=JSON.parse(e)}catch(e){}i(e)}else o(t)},s.onerror=()=>o("Network error"),s.onabort=()=>o("Aborted"),s.ontimeout=()=>o("Timeout"),s.upload&&"function"==typeof r.progress&&(s.upload.onprogress=n),s.send(t)})),u=[],c=[];function l(e){const t="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";if(0===e)return t[0];let r="";for(;e>0;)r=t[e%62]+r,e=Math.floor(e/62);return r}for(let e of t){let t=Object.assign({key:e.name,sizeKey:l(e.size),contentType:e.type||null},o),{fields:n=null,url:h}=await i.bind(this)("get-signed-url",t,{auth:!0}),f=new FormData;for(let e in n)f.append(e,n[e]);f.append("file",e);try{await a(h,f,(t=>{r.progress({status:"upload",progress:t.loaded/t.total*100,currentFile:e,completed:u,failed:c,loaded:t.loaded,total:t.total,abort:()=>s.abort()})})),u.push(e)}catch(t){c.push(e)}}return{completed:u,failed:c}}async function E(t,r){if("string"!=typeof t)throw new e('"url" should be type: string.',{code:"INVALID_PARAMETER"});r?.noCdn||s.Url(t);let n=!1,i=t.split("/"),o=i[2].split("."),a=null;3===o.length&&"skapi"===o[1]&&(a=o[0],n=!0);let c=i.slice(3);if(!n){if("auth"!==c[0]&&"publ"!==c[0])throw new e("Invalid file url.",{code:"INVALID_PARAMETER"});try{s.UserId(c[2]),s.UserId(c[3])}catch{throw new e("Invalid file url.",{code:"INVALID_PARAMETER"})}}let l=a?null:c[1];s.Params(r,{expiration:["number",()=>60],noCdn:["boolean",()=>!1],dataType:["base64","blob","endpoint","download",()=>"download"]},[],["progress"]);let h="auth"==c[0],f=t.split("/").slice(-1)[0];if(r?.noCdn||h&&("download"===r?.dataType||"endpoint"===r?.dataType)){let p={request:a?"get-host":"get",id:a||c[5],key:t};l&&(p.service=l),t=(await u.bind(this)("get-signed-url",p,{auth:!0})).url}if("download"===r?.dataType){let g=document.createElement("a");return g.href=t,document.body.appendChild(g),g.setAttribute("download",f),g.target="_blank",g.click(),document.body.removeChild(g),null}if("endpoint"===r?.dataType)return t;let d=await u.bind(this)(t,{service:l||this.service},{method:"get",auth:h,contentType:null,responseType:"blob",fetchOptions:{progress:r?.progress}});if("base64"===r?.dataType){function y(e){return new Promise(((t,r)=>{const n=new FileReader;n.onloadend=()=>t(n.result),n.readAsDataURL(e)}))}return y(d)}return d}async function S(t,r){await this.__connection;const n={$updated:"number",$uploaded:"number",$referenced_count:"number"};"string"==typeof t?.table&&(t.table={name:t.table,access_group:0});const i={table:{name:"string",access_group:["number","private","public","authorized"],subscription:{user_id:e=>s.UserId(e,'User ID in "subscription.user_id"'),group:t=>{if("number"!=typeof t)throw new e('"subscription.group" should be type: number.',{code:"INVALID_PARAMETER"});if(t>99||t<0)throw new e('"subscription.group" should be within range: 0 ~ 99.',{code:"INVALID_PARAMETER"});return t}}},reference:"string",index:{name:t=>{if("string"!=typeof t)throw new e('"index.name" should be type: string.',{code:"INVALID_PARAMETER"});return n.hasOwnProperty(t)||["$uploaded","$updated","$referenced_count","$user_id"].includes(t)?t:s.specialChars(t,"index.name",!0,!1)},value:r=>{if(t.index?.name&&n.hasOwnProperty(t.index.name)){let i=n[t.index.name];if(typeof r===i)return r;throw new e(`"index.value" should be type: ${i}.`,{code:"INVALID_PARAMETER"})}if("number"==typeof r){if(r>b||r<-4503599627370496)throw new e("Number value should be within range -4503599627370496 ~ +4503599627370496",{code:"INVALID_PARAMETER"});return r}return"boolean"==typeof r?r:"$user_id"==t.index?.name?s.UserId(r):s.specialChars(r,"index.value",!1,!0)},condition:["gt","gte","lt","lte",">",">=","<","<=","=","eq","!=","ne"],range:r=>{if(!t.index||!("value"in t.index))throw new e('"index.value" is required.',{code:"INVALID_PARAMETER"});if("$record_id"===t.index.name)throw new e(`Cannot do "index.range" on ${t.index.name}`,{code:"INVALID_PARAMETER"});if(typeof t.index.value!=typeof r)throw new e('"index.range" type should match the type of "index.value".',{code:"INVALID_PARAMETER"});return"string"==typeof r?s.specialChars(r,"index.value"):r}},tag:"string",private_access_key:"string"};if(t?.table&&("public"===t.table.access_group?t.table.access_group=0:"authorized"===t.table.access_group&&(t.table.access_group=1),"number"==typeof t.table.access_group))if(this.__user){if(this.user.access_group<t.table.access_group)throw new e("User has no access",{code:"INVALID_REQUEST"})}else if(0<t.table.access_group)throw new e("User has no access",{code:"INVALID_REQUEST"});if(t?.index&&!t.index?.name)throw new e('"index.name" is required when using "index" parameter.',{code:"INVALID_REQUEST"});if(t?.record_id){s.specialChars(t.record_id,"record_id",!1,!1);let e={record_id:t.record_id};t?.service&&(e.service=t.service),t=e}else{let r;if(!this.session&&"private"===t.table?.access_group)throw new e("Unsigned users have no access to private records.",{code:"INVALID_REQUEST"});if(t.reference)try{r=s.UserId(t?.reference)}catch(e){}if(t=s.Params(t||{},i,r?[]:["table"]),t.table?.subscription&&!this.session)throw new e("Unsigned users have no access to subscription records.",{code:"INVALID_REQUEST"})}let o=!(!t.hasOwnProperty("access_group")||!t.table.access_group)||!!this.__user,a=await u.bind(this)("get-records",t,{fetchOptions:r,auth:o,method:o?"post":"get"});for(let e in a.list)a.list[e]=_(a.list[e]);return a}async function I(t,r){let n=await this.checkAdmin();if(!r)throw new e('"config" argument is required.',{code:"INVALID_PARAMETER"});if(!this.user)throw new e("Login is required.",{code:"INVALID_REQUEST"});let o={};"function"==typeof r?.formData&&(o.formData=r.formData,delete r.formData),"string"==typeof r.table&&(r.table={name:r.table},r.record_id||(r.table.access_group=0));let a=r.progress||null;if(r=s.Params(r||{},{record_id:"string",table:{name:"string",subscription_group:["number",null],access_group:["number","private","public","authorized"]},reference:{record_id:["string",null],reference_limit:t=>{if(null===t)return null;if("number"==typeof t){if(0>t)throw new e('"reference_limit" should be >= 0',{code:"INVALID_PARAMETER"});if(t>4503599627370546)throw new e('"reference_limit" should be <= 4503599627370546',{code:"INVALID_PARAMETER"});return t}throw new e('"reference_limit" should be type: <number | null>',{code:"INVALID_PARAMETER"})},allow_multiple_reference:"boolean"},index:{name:"string",value:["string","number","boolean"]},tags:t=>{if(null===t)return t;if("string"==typeof t)return[t];if(Array.isArray(t)){for(let r of t){if("string"!=typeof r)throw new e('"tags" should be type: <string | string[]>',{code:"INVALID_PARAMETER"});s.specialChars(t,"tag",!1,!0)}return t}throw new e('"tags" should be type: <string | string[]>',{code:"INVALID_PARAMETER"})}},[],["response","onerror","progress"],null),!r?.table&&!r?.record_id)throw new e('Either "record_id" or "table" should have a value.',{code:"INVALID_PARAMETER"});if(r.table){if("public"===r.table.access_group?r.table.access_group=0:"authorized"===r.table.access_group&&(r.table.access_group=1),"number"==typeof r.table.access_group&&!n&&this.user.access_group<r.table.access_group)throw new e("User has no access",{code:"INVALID_REQUEST"});if(!r.table.name)throw new e('"table.name" cannot be empty string.',{code:"INVALID_PARAMETER"});if(n){if("private"===r.table.access_group)throw new e("Service owner cannot write private records.",{code:"INVALID_REQUEST"});if(r.table.hasOwnProperty("subscription_group"))throw new e("Service owner cannot write to subscription table.",{code:"INVALID_REQUEST"})}if("number"==typeof r.table?.subscription_group&&r.table.subscription_group<0||r.table.subscription_group>99)throw new e("Subscription group should be within range: 0 ~ 99",{code:"INVALID_PARAMETER"})}if(delete r.response,delete r.onerror,delete r.progress,r.index){if(!r.index.name||"string"!=typeof r.index.name)throw new e('"index.name" is required. type: string.',{code:"INVALID_PARAMETER"});if(["$uploaded","$updated","$referenced_count","$user_id"].includes(r.index.name)||s.specialChars(r.index.name,"index name",!0),!r.index.hasOwnProperty("value"))throw new e('"index.value" is required.',{code:"INVALID_PARAMETER"});if("string"==typeof r.index.value)s.specialChars(r.index.value,"index value",!1,!0);else if("number"==typeof r.index.value&&(r.index.value>b||r.index.value<-4503599627370496))throw new e("Number value should be within range -4503599627370496 ~ +4503599627370496",{code:"INVALID_PARAMETER"})}let c={auth:!0},l=null;if(t instanceof HTMLFormElement||t instanceof FormData||t instanceof SubmitEvent){let e=t instanceof SubmitEvent?t.target:t,n=t instanceof FormData?t:new FormData(e),s=i(t);c.meta=r,Object.keys(s.meta).length&&(c.meta.data=s.meta);let o={};for(let[e,t]of n.entries())if(s.meta.hasOwnProperty(e)&&!(t instanceof Blob)){let r=n.getAll(e).indexOf(t);o.hasOwnProperty(e)?o[e].push(r):o[e]=[r]}if(Object.keys(o).length)for(let e in o){let t=n.getAll(e),r=t.length;for(;r--;)o[e].includes(r)&&t.splice(r,1);n.delete(e);for(let r of t)n.append(e,r,r instanceof File?r.name:null)}l=n}else l=Object.assign({data:t},r);return"function"==typeof a&&(o.progress=a),Object.keys(o).length&&Object.assign(c,{fetchOptions:o}),_(await u.bind(this)("post-record",l,c))}async function T(e,t){let r=await u.bind(this)("get-table",s.Params(e||{},{table:"string",condition:["gt","gte","lt","lte",">",">=","<","<=","=","eq","!=","ne"]}),Object.assign({auth:!0},{fetchOptions:t})),n={cnt_rec:"number_of_records",tbl:"table",srvc:"service"};if(Array.isArray(r.list))for(let e of r.list)for(let t in n)e.hasOwnProperty(t)&&(e[n[t]]=e[t],delete e[t]);return r}async function R(t,r){let n=s.Params(t||{},{table:"string",index:e=>s.specialChars(e,"index name",!0,!1),order:{by:["average_number","total_number","number_count","average_bool","total_bool","bool_count","string_count","index_name","number_of_records"],value:["string","number","boolean"],condition:["gt","gte","lt","lte",">",">=","<","<=","=","eq","!=","ne"]}},["table"]);if(n.hasOwnProperty("order")){if(!n.order?.by)throw new e('"order.by" is required.',{code:"INVALID_PARAMETER"});if(n.order.hasOwnProperty("condition")&&!n.order.hasOwnProperty("value"))throw new e('"value" is required for "condition".',{code:"INVALID_PARAMETER"});if(n.hasOwnProperty("index")&&"."!==n.index.substring(n.index.length-1))throw new e('"index" should be a parent index name of the compound index when using "order.by"',{code:"INVALID_PARAMETER"})}let i=await u.bind(this)("get-index",n,Object.assign({auth:!0},{fetchOptions:r})),o={cnt_bool:"boolean_count",cnt_numb:"number_count",totl_numb:"total_number",totl_bool:"total_bool",avrg_numb:"average_number",avrg_bool:"average_bool",cnt_str:"string_count"};return Array.isArray(i.list)&&(i.list=i.list.map((e=>{let t=e.idx.split("/"),r={table:t[1],index:t[2],number_of_records:e.cnt_rec};for(let t in o)e?.[t]&&(r[o[t]]=e[t]);return r}))),i}async function U(e,t){let r=await u.bind(this)("get-tag",s.Params(e||{},{table:"string",tag:"string",condition:["gt","gte","lt","lte",">",">=","<","<=","=","eq","!=","ne"]}),Object.assign({auth:!0},{fetchOptions:t}));if(Array.isArray(r.list))for(let e in r.list){let t=r.list[e],n=t.tag.split("/");r.list[e]={table:n[1],tag:n[0],number_of_records:t.cnt_rec}}return r}async function D(t){let r=await this.checkAdmin();if(r&&!t?.service)throw new e("Service ID is required.",{code:"INVALID_PARAMETER"});if(t?.record_id)return await u.bind(this)("del-records",{service:t.service||this.service,record_id:(t=>{let r=s.specialChars(t,"record_id",!1,!1);if("string"==typeof r)return[r];if(r.length>100)throw new e('"record_id" should not exceed 100 items.',{code:"INVALID_PARAMETER"});return r})(t.record_id)},{auth:!0});{if(!t?.table){if(r)return null;throw new e('Either "table" or "record_id" is required.',{code:"INVALID_PARAMETER"})}let n={access_group:t=>{if("string"==typeof t&&["private","public","authorized"].includes(t))switch(t){case"private":return t;case"public":return 0;case"authorized":return 1}else if("number"==typeof t&&t>=0&&t<100)return t;throw new e('Invalid "table.access_group". Access group should be type <number (0~99) | "private" | "public" | "authorized">.',{code:"INVALID_PARAMETER"})},name:"string",subscription:t=>{if(r)return s.UserId(t,'User ID in "table.subscription"');throw new e('"table.subscription" is an invalid parameter key.',{code:"INVALID_PARAMETER"})},subscription_group:n=>{if(r&&"string"!=typeof t?.table?.subscription)throw new e('"table.subscription" is required.',{code:"INVALID_PARAMETER"});if("number"==typeof n&&n>=0&&n<99)return n;throw new e("Subscription group should be between 0 ~ 99.",{code:"INVALID_PARAMETER"})}};t.table=s.Params(t.table||{},n,r?[]:["name"])}return await u.bind(this)("del-records",t,{auth:!0})}function C(t){if(!t.record_id)throw new e("Record ID is required.",{code:"INVALID_PARAMETER"});if(!t.user_id||Array.isArray(t.user_id)&&!t.user_id.length)throw new e("User ID is required.",{code:"INVALID_PARAMETER"});return O({record_id:t.record_id,user_id:t.user_id||null,execute:"add"})}function P(t){if(!t.record_id)throw new e("Record ID is required.",{code:"INVALID_PARAMETER"});if(!t.user_id||Array.isArray(t.user_id)&&!t.user_id.length)throw new e("User ID is required.",{code:"INVALID_PARAMETER"});return O({record_id:t.record_id,user_id:t.user_id||null,execute:"remove"})}function N(e){return O({record_id:e.record_id,user_id:e.user_id||null,execute:"list"})}function k(e){return u.bind(this)("request-private-access-key",{record_id:e},{auth:!0})}function O(t){let r=t.execute,n=s.Params(t,{record_id:"string",user_id:t=>{if(!t){if("list"==r)return null;throw new e("User ID is required.",{code:"INVALID_PARAMETER"})}let n=s.specialChars(t,"user id",!1,!1);if("string"==typeof n)return[n];if(n.length>100)throw new e("Cannot process more than 100 users at once.",{code:"INVALID_REQUEST"});return n},execute:["add","remove","list"]},["execute","record_id","user_id"]);return n.user_id||(n.user_id=null),u.bind(this)("grant-private-access",n,{auth:!0})}function M(t){if(t=s.Params(t,{user_id:e=>s.UserId(e,'"user_id"'),group:t=>{if("*"===t)return t;if("number"!=typeof t)throw new e('"group" should be type: number.',{code:"INVALID_PARAMETER"});if(t<1&&t>99)throw new e('"group" should be within range 1 ~ 99.',{code:"INVALID_PARAMETER"});return t}},["user_id","group"]),this.__user&&t.user_id===this.__user.user_id)throw new e('"user_id" cannot be the user\'s own ID.',{code:"INVALID_PARAMETER"});return t}async function F(t,r,n){if(!(t=s.Params(t,{subscriber:e=>s.UserId(e,'User ID in "subscriber"'),group:"number",subscription:e=>s.UserId(e,'User ID in "subscription"'),blocked:"boolean"})).subscriber&&!t.subscription)throw new e('At least either "subscriber" or "subscription" should have a value.',{code:"INVALID_PARAMETER"});let i=await u.bind(this)("get-subscription",t,Object.assign({auth:!0},{fetchOptions:r}));return i.list=i.list.map(n||(e=>{let t={},r=e.sub.split("#");return t.subscriber=r[2],t.subscription=r[0],t.group=parseInt(r[1]),t.timestamp=e.stmp,t.blocked="N"===e.grp.substring(0,1),t})),i}async function V(t){await this.__connection;let{user_id:r,group:n}=M.bind(this)(t);if("number"!=typeof n)throw new e('"group" should be type: number.',{code:"INVALID_PARAMETER"});return await u.bind(this)("subscription",{subscribe:r,group:n},{auth:!0})}async function x(e){await this.__connection;let{user_id:t,group:r}=M.bind(this)(e);return await u.bind(this)("subscription",{unsubscribe:t,group:r},{auth:!0})}async function L(e){await this.__connection;let{user_id:t,group:r}=M.bind(this)(e);return await u.bind(this)("subscription",{block:t,group:r},{auth:!0})}async function B(e){await this.__connection;let{user_id:t,group:r}=M.bind(this)(e);return await u.bind(this)("subscription",{unblock:t,group:r},{auth:!0})}async function $(e,t){return await this.__connection,e=s.Params(e,{user_id:e=>s.UserId(e,'"user_id"'),group:"number",blocked:"boolean"})||{},F.bind(this)({subscriber:e.user_id||this.__user?.user_id,group:e.group,blocked:e.blocked},t)}async function q(e,t){await this.__connection;let r={subscription:(e=s.Params(e,{user_id:e=>s.UserId(e,'"user_id"'),group:"number",blocked:"boolean"})||{}).user_id||this.__user?.user_id,group:e.group,blocked:e.blocked};return F.bind(this)(r,t)}async function K(t){await this.__connection;let r=await this.checkAdmin();t=s.Params(t,{user_id:t=>{if(t!==this.__user.user_id&&!r)throw new e("No access.",{code:"INVALID_REQUEST"});return t},group:"number"});let n=await u.bind(this)("get-newsletter-subscription",t,{auth:!0}),i=[];for(let e of n){let t=e.subt.split("#"),r=!0;"@"===t[0].charAt(0)&&(r=!1,t[0]=t[0].substring(1));let n=parseInt(t[0]);i.push({timestamp:e.stmp,group:n,subscribed_email:t[1],active:r})}return i}async function j(e){await this.__connection;let t=s.Params(e||{},{email:e=>s.Email(e),group:["number","public","authorized"],redirect:e=>s.Url(e)},this.__user?["group"]:["email","group"]);return u.bind(this)(`subscribe-${this.__user?"":"public-"}newsletter`,t,{auth:!!this.__user})}async function H(e){await this.__connection,e=s.Params(e,{group:["number","public","authorized"]},["group"]);let t=Object.assign({action:"unsubscribe"},e);return u.bind(this)("subscribe-newsletter",t,{auth:!0})}async function W(t,r){let n=await this.checkAdmin(),i={message_id:"string",timestamp:"number",read:"number",complaint:"number",subject:"string"};t||(r||(r={}),r.ascending=!1);let o=t||{searchFor:"timestamp",value:0,condition:">"};t=s.Params(o,{searchFor:["message_id","timestamp","read","complaint","group","subject"],value:t=>{if(typeof t!==i[o.searchFor])throw new e(`"value" type does not match the type of "${o.searchFor}" index.`,{code:"INVALID_PARAMETER"});if("string"==typeof t&&!t)throw new e('"value" should not be empty string.',{code:"INVALID_PARAMETER"});return t},range:t=>{if(!o.hasOwnProperty("value")||typeof t!=typeof o.value)throw new e('"range" should match type of "value".',{code:"INVALID_PARAMETER"});return t},condition:[">",">=","=","<","<=","gt","gte","eq","lt","lte",()=>"="],group:t=>{if(!this.session)throw new e("User should be logged in.",{code:"INVALID_REQUEST"});if("public"===t)return 0;if("authorized"===t)return 1;if("number"==typeof t&&!n&&t>parseInt(this.session.idToken.payload.access_group))throw new e("User has no access.",{code:"INVALID_REQUEST"});return t}},["searchFor","value","group"]);let a=await u.bind(this)(0===t.group?"get-public-newsletters":"get-newsletters",t,Object.assign({method:"get",auth:0!==t.group},{fetchOptions:r})),c={message_id:"mid",timestamp:"stmp",complaint:"cmpl",read:"read",subject:"subj",bounced:"bnce",url:"url"},l={message_id:"",timestamp:0,complaint:0,read:0,subject:"",bounced:0,url:""};return a.list=a.list.map((e=>{let t={};for(let r in c)t[r]=e[c[r]]||l[c[r]];return t})),a}var J,z=function(){function e(e){var t=e||{},r=t.ValidationData,n=t.Username,i=t.Password,s=t.AuthParameters,o=t.ClientMetadata;this.validationData=r||{},this.authParameters=s||{},this.clientMetadata=o||{},this.username=n,this.password=i}var t=e.prototype;return t.getUsername=function(){return this.username},t.getPassword=function(){return this.password},t.getValidationData=function(){return this.validationData},t.getAuthParameters=function(){return this.authParameters},t.getClientMetadata=function(){return this.clientMetadata},e}(),Y=r(764),Q=r(249),G=r.n(Q),Z=(r(433),r(153)),X=r.n(Z),ee=r(10),te=r.n(ee);if("undefined"!=typeof window&&window.crypto&&(J=window.crypto),!J&&"undefined"!=typeof window&&window.msCrypto&&(J=window.msCrypto),!J&&void 0!==r.g&&r.g.crypto&&(J=r.g.crypto),!J)try{J=r(296)}catch(e){}function re(){if(J){if("function"==typeof J.getRandomValues)try{return J.getRandomValues(new Uint32Array(1))[0]}catch(e){}if("function"==typeof J.randomBytes)try{return J.randomBytes(4).readInt32LE()}catch(e){}}throw new Error("Native crypto module could not be used to get secure random number.")}var ne=function(){function e(e,t){e=this.words=e||[],this.sigBytes=null!=t?t:4*e.length}var t=e.prototype;return t.random=function(t){for(var r=[],n=0;n<t;n+=4)r.push(re());return new e(r,t)},t.toString=function(){return function(e){for(var t=e.words,r=e.sigBytes,n=[],i=0;i<r;i++){var s=t[i>>>2]>>>24-i%4*8&255;n.push((s>>>4).toString(16)),n.push((15&s).toString(16))}return n.join("")}(this)},e}();const ie=se;function se(e,t){null!=e&&this.fromString(e,t)}function oe(){return new se(null)}var ae,ue="undefined"!=typeof navigator;ue&&"Microsoft Internet Explorer"==navigator.appName?(se.prototype.am=function(e,t,r,n,i,s){for(var o=32767&t,a=t>>15;--s>=0;){var u=32767&this[e],c=this[e++]>>15,l=a*u+c*o;i=((u=o*u+((32767&l)<<15)+r[n]+(1073741823&i))>>>30)+(l>>>15)+a*c+(i>>>30),r[n++]=1073741823&u}return i},ae=30):ue&&"Netscape"!=navigator.appName?(se.prototype.am=function(e,t,r,n,i,s){for(;--s>=0;){var o=t*this[e++]+r[n]+i;i=Math.floor(o/67108864),r[n++]=67108863&o}return i},ae=26):(se.prototype.am=function(e,t,r,n,i,s){for(var o=16383&t,a=t>>14;--s>=0;){var u=16383&this[e],c=this[e++]>>14,l=a*u+c*o;i=((u=o*u+((16383&l)<<14)+r[n]+i)>>28)+(l>>14)+a*c,r[n++]=268435455&u}return i},ae=28),se.prototype.DB=ae,se.prototype.DM=(1<<ae)-1,se.prototype.DV=1<<ae,se.prototype.FV=Math.pow(2,52),se.prototype.F1=52-ae,se.prototype.F2=2*ae-52;var ce,le,he=new Array;for(ce="0".charCodeAt(0),le=0;le<=9;++le)he[ce++]=le;for(ce="a".charCodeAt(0),le=10;le<36;++le)he[ce++]=le;for(ce="A".charCodeAt(0),le=10;le<36;++le)he[ce++]=le;function fe(e){return"0123456789abcdefghijklmnopqrstuvwxyz".charAt(e)}function de(e,t){var r=he[e.charCodeAt(t)];return null==r?-1:r}function pe(e){var t=oe();return t.fromInt(e),t}function ge(e){var t,r=1;return 0!=(t=e>>>16)&&(e=t,r+=16),0!=(t=e>>8)&&(e=t,r+=8),0!=(t=e>>4)&&(e=t,r+=4),0!=(t=e>>2)&&(e=t,r+=2),0!=(t=e>>1)&&(e=t,r+=1),r}function ye(e){this.m=e,this.mp=e.invDigit(),this.mpl=32767&this.mp,this.mph=this.mp>>15,this.um=(1<<e.DB-15)-1,this.mt2=2*e.t}function we(e){return Y.lW.from((new ne).random(e).toString(),"hex")}ye.prototype.convert=function(e){var t=oe();return e.abs().dlShiftTo(this.m.t,t),t.divRemTo(this.m,null,t),e.s<0&&t.compareTo(se.ZERO)>0&&this.m.subTo(t,t),t},ye.prototype.revert=function(e){var t=oe();return e.copyTo(t),this.reduce(t),t},ye.prototype.reduce=function(e){for(;e.t<=this.mt2;)e[e.t++]=0;for(var t=0;t<this.m.t;++t){var r=32767&e[t],n=r*this.mpl+((r*this.mph+(e[t]>>15)*this.mpl&this.um)<<15)&e.DM;for(e[r=t+this.m.t]+=this.m.am(0,n,e,t,0,this.m.t);e[r]>=e.DV;)e[r]-=e.DV,e[++r]++}e.clamp(),e.drShiftTo(this.m.t,e),e.compareTo(this.m)>=0&&e.subTo(this.m,e)},ye.prototype.mulTo=function(e,t,r){e.multiplyTo(t,r),this.reduce(r)},ye.prototype.sqrTo=function(e,t){e.squareTo(t),this.reduce(t)},se.prototype.copyTo=function(e){for(var t=this.t-1;t>=0;--t)e[t]=this[t];e.t=this.t,e.s=this.s},se.prototype.fromInt=function(e){this.t=1,this.s=e<0?-1:0,e>0?this[0]=e:e<-1?this[0]=e+this.DV:this.t=0},se.prototype.fromString=function(e,t){var r;if(16==t)r=4;else if(8==t)r=3;else if(2==t)r=1;else if(32==t)r=5;else{if(4!=t)throw new Error("Only radix 2, 4, 8, 16, 32 are supported");r=2}this.t=0,this.s=0;for(var n=e.length,i=!1,s=0;--n>=0;){var o=de(e,n);o<0?"-"==e.charAt(n)&&(i=!0):(i=!1,0==s?this[this.t++]=o:s+r>this.DB?(this[this.t-1]|=(o&(1<<this.DB-s)-1)<<s,this[this.t++]=o>>this.DB-s):this[this.t-1]|=o<<s,(s+=r)>=this.DB&&(s-=this.DB))}this.clamp(),i&&se.ZERO.subTo(this,this)},se.prototype.clamp=function(){for(var e=this.s&this.DM;this.t>0&&this[this.t-1]==e;)--this.t},se.prototype.dlShiftTo=function(e,t){var r;for(r=this.t-1;r>=0;--r)t[r+e]=this[r];for(r=e-1;r>=0;--r)t[r]=0;t.t=this.t+e,t.s=this.s},se.prototype.drShiftTo=function(e,t){for(var r=e;r<this.t;++r)t[r-e]=this[r];t.t=Math.max(this.t-e,0),t.s=this.s},se.prototype.lShiftTo=function(e,t){var r,n=e%this.DB,i=this.DB-n,s=(1<<i)-1,o=Math.floor(e/this.DB),a=this.s<<n&this.DM;for(r=this.t-1;r>=0;--r)t[r+o+1]=this[r]>>i|a,a=(this[r]&s)<<n;for(r=o-1;r>=0;--r)t[r]=0;t[o]=a,t.t=this.t+o+1,t.s=this.s,t.clamp()},se.prototype.rShiftTo=function(e,t){t.s=this.s;var r=Math.floor(e/this.DB);if(r>=this.t)t.t=0;else{var n=e%this.DB,i=this.DB-n,s=(1<<n)-1;t[0]=this[r]>>n;for(var o=r+1;o<this.t;++o)t[o-r-1]|=(this[o]&s)<<i,t[o-r]=this[o]>>n;n>0&&(t[this.t-r-1]|=(this.s&s)<<i),t.t=this.t-r,t.clamp()}},se.prototype.subTo=function(e,t){for(var r=0,n=0,i=Math.min(e.t,this.t);r<i;)n+=this[r]-e[r],t[r++]=n&this.DM,n>>=this.DB;if(e.t<this.t){for(n-=e.s;r<this.t;)n+=this[r],t[r++]=n&this.DM,n>>=this.DB;n+=this.s}else{for(n+=this.s;r<e.t;)n-=e[r],t[r++]=n&this.DM,n>>=this.DB;n-=e.s}t.s=n<0?-1:0,n<-1?t[r++]=this.DV+n:n>0&&(t[r++]=n),t.t=r,t.clamp()},se.prototype.multiplyTo=function(e,t){var r=this.abs(),n=e.abs(),i=r.t;for(t.t=i+n.t;--i>=0;)t[i]=0;for(i=0;i<n.t;++i)t[i+r.t]=r.am(0,n[i],t,i,0,r.t);t.s=0,t.clamp(),this.s!=e.s&&se.ZERO.subTo(t,t)},se.prototype.squareTo=function(e){for(var t=this.abs(),r=e.t=2*t.t;--r>=0;)e[r]=0;for(r=0;r<t.t-1;++r){var n=t.am(r,t[r],e,2*r,0,1);(e[r+t.t]+=t.am(r+1,2*t[r],e,2*r+1,n,t.t-r-1))>=t.DV&&(e[r+t.t]-=t.DV,e[r+t.t+1]=1)}e.t>0&&(e[e.t-1]+=t.am(r,t[r],e,2*r,0,1)),e.s=0,e.clamp()},se.prototype.divRemTo=function(e,t,r){var n=e.abs();if(!(n.t<=0)){var i=this.abs();if(i.t<n.t)return null!=t&&t.fromInt(0),void(null!=r&&this.copyTo(r));null==r&&(r=oe());var s=oe(),o=this.s,a=e.s,u=this.DB-ge(n[n.t-1]);u>0?(n.lShiftTo(u,s),i.lShiftTo(u,r)):(n.copyTo(s),i.copyTo(r));var c=s.t,l=s[c-1];if(0!=l){var h=l*(1<<this.F1)+(c>1?s[c-2]>>this.F2:0),f=this.FV/h,d=(1<<this.F1)/h,p=1<<this.F2,g=r.t,y=g-c,w=null==t?oe():t;for(s.dlShiftTo(y,w),r.compareTo(w)>=0&&(r[r.t++]=1,r.subTo(w,r)),se.ONE.dlShiftTo(c,w),w.subTo(s,s);s.t<c;)s[s.t++]=0;for(;--y>=0;){var m=r[--g]==l?this.DM:Math.floor(r[g]*f+(r[g-1]+p)*d);if((r[g]+=s.am(0,m,r,y,0,c))<m)for(s.dlShiftTo(y,w),r.subTo(w,r);r[g]<--m;)r.subTo(w,r)}null!=t&&(r.drShiftTo(c,t),o!=a&&se.ZERO.subTo(t,t)),r.t=c,r.clamp(),u>0&&r.rShiftTo(u,r),o<0&&se.ZERO.subTo(r,r)}}},se.prototype.invDigit=function(){if(this.t<1)return 0;var e=this[0];if(0==(1&e))return 0;var t=3&e;return(t=(t=(t=(t=t*(2-(15&e)*t)&15)*(2-(255&e)*t)&255)*(2-((65535&e)*t&65535))&65535)*(2-e*t%this.DV)%this.DV)>0?this.DV-t:-t},se.prototype.addTo=function(e,t){for(var r=0,n=0,i=Math.min(e.t,this.t);r<i;)n+=this[r]+e[r],t[r++]=n&this.DM,n>>=this.DB;if(e.t<this.t){for(n+=e.s;r<this.t;)n+=this[r],t[r++]=n&this.DM,n>>=this.DB;n+=this.s}else{for(n+=this.s;r<e.t;)n+=e[r],t[r++]=n&this.DM,n>>=this.DB;n+=e.s}t.s=n<0?-1:0,n>0?t[r++]=n:n<-1&&(t[r++]=this.DV+n),t.t=r,t.clamp()},se.prototype.toString=function(e){if(this.s<0)return"-"+this.negate().toString(e);var t;if(16==e)t=4;else if(8==e)t=3;else if(2==e)t=1;else if(32==e)t=5;else{if(4!=e)throw new Error("Only radix 2, 4, 8, 16, 32 are supported");t=2}var r,n=(1<<t)-1,i=!1,s="",o=this.t,a=this.DB-o*this.DB%t;if(o-- >0)for(a<this.DB&&(r=this[o]>>a)>0&&(i=!0,s=fe(r));o>=0;)a<t?(r=(this[o]&(1<<a)-1)<<t-a,r|=this[--o]>>(a+=this.DB-t)):(r=this[o]>>(a-=t)&n,a<=0&&(a+=this.DB,--o)),r>0&&(i=!0),i&&(s+=fe(r));return i?s:"0"},se.prototype.negate=function(){var e=oe();return se.ZERO.subTo(this,e),e},se.prototype.abs=function(){return this.s<0?this.negate():this},se.prototype.compareTo=function(e){var t=this.s-e.s;if(0!=t)return t;var r=this.t;if(0!=(t=r-e.t))return this.s<0?-t:t;for(;--r>=0;)if(0!=(t=this[r]-e[r]))return t;return 0},se.prototype.bitLength=function(){return this.t<=0?0:this.DB*(this.t-1)+ge(this[this.t-1]^this.s&this.DM)},se.prototype.mod=function(e){var t=oe();return this.abs().divRemTo(e,null,t),this.s<0&&t.compareTo(se.ZERO)>0&&e.subTo(t,t),t},se.prototype.equals=function(e){return 0==this.compareTo(e)},se.prototype.add=function(e){var t=oe();return this.addTo(e,t),t},se.prototype.subtract=function(e){var t=oe();return this.subTo(e,t),t},se.prototype.multiply=function(e){var t=oe();return this.multiplyTo(e,t),t},se.prototype.divide=function(e){var t=oe();return this.divRemTo(e,t,null),t},se.prototype.modPow=function(e,t,r){var n,i=e.bitLength(),s=pe(1),o=new ye(t);if(i<=0)return s;n=i<18?1:i<48?3:i<144?4:i<768?5:6;var a=new Array,u=3,c=n-1,l=(1<<n)-1;if(a[1]=o.convert(this),n>1){var h=oe();for(o.sqrTo(a[1],h);u<=l;)a[u]=oe(),o.mulTo(h,a[u-2],a[u]),u+=2}var f,d,p=e.t-1,g=!0,y=oe();for(i=ge(e[p])-1;p>=0;){for(i>=c?f=e[p]>>i-c&l:(f=(e[p]&(1<<i+1)-1)<<c-i,p>0&&(f|=e[p-1]>>this.DB+i-c)),u=n;0==(1&f);)f>>=1,--u;if((i-=u)<0&&(i+=this.DB,--p),g)a[f].copyTo(s),g=!1;else{for(;u>1;)o.sqrTo(s,y),o.sqrTo(y,s),u-=2;u>0?o.sqrTo(s,y):(d=s,s=y,y=d),o.mulTo(y,a[f],s)}for(;p>=0&&0==(e[p]&1<<i);)o.sqrTo(s,y),d=s,s=y,y=d,--i<0&&(i=this.DB-1,--p)}var w=o.revert(s);return r(null,w),w},se.ZERO=pe(0),se.ONE=pe(1);var me=/^[89a-f]/i,be=function(){function e(e){this.N=new ie("FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD129024E088A67CC74020BBEA63B139B22514A08798E3404DDEF9519B3CD3A431B302B0A6DF25F14374FE1356D6D51C245E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7EDEE386BFB5A899FA5AE9F24117C4B1FE649286651ECE45B3DC2007CB8A163BF0598DA48361C55D39A69163FA8FD24CF5F83655D23DCA3AD961C62F356208552BB9ED529077096966D670C354E4ABC9804F1746C08CA18217C32905E462E36CE3BE39E772C180E86039B2783A2EC07A28FB5C55DF06F4C52C9DE2BCBF6955817183995497CEA956AE515D2261898FA051015728E5A8AAAC42DAD33170D04507A33A85521ABDF1CBA64ECFB850458DBEF0A8AEA71575D060C7DB3970F85A6E1E4C7ABF5AE8CDB0933D71E8C94E04A25619DCEE3D2261AD2EE6BF12FFA06D98A0864D87602733EC86A64521F2B18177B200CBBE117577A615D6C770988C0BAD946E208E24FA074E5AB3143DB5BFCE0FD108E4B82D120A93AD2CAFFFFFFFFFFFFFFFF",16),this.g=new ie("2",16),this.k=new ie(this.hexHash(""+this.padHex(this.N)+this.padHex(this.g)),16),this.smallAValue=this.generateRandomSmallA(),this.getLargeAValue((function(){})),this.infoBits=Y.lW.from("Caldera Derived Key","utf8"),this.poolName=e}var t=e.prototype;return t.getSmallAValue=function(){return this.smallAValue},t.getLargeAValue=function(e){var t=this;this.largeAValue?e(null,this.largeAValue):this.calculateA(this.smallAValue,(function(r,n){r&&e(r,null),t.largeAValue=n,e(null,t.largeAValue)}))},t.generateRandomSmallA=function(){var e=we(128).toString("hex");return new ie(e,16)},t.generateRandomString=function(){return we(40).toString("base64")},t.getRandomPassword=function(){return this.randomPassword},t.getSaltDevices=function(){return this.SaltToHashDevices},t.getVerifierDevices=function(){return this.verifierDevices},t.generateHashDevice=function(e,t,r){var n=this;this.randomPassword=this.generateRandomString();var i=""+e+t+":"+this.randomPassword,s=this.hash(i),o=we(16).toString("hex");this.SaltToHashDevices=this.padHex(new ie(o,16)),this.g.modPow(new ie(this.hexHash(this.SaltToHashDevices+s),16),this.N,(function(e,t){e&&r(e,null),n.verifierDevices=n.padHex(t),r(null,null)}))},t.calculateA=function(e,t){var r=this;this.g.modPow(e,this.N,(function(e,n){e&&t(e,null),n.mod(r.N).equals(ie.ZERO)&&t(new Error("Illegal paramater. A mod N cannot be 0."),null),t(null,n)}))},t.calculateU=function(e,t){return this.UHexHash=this.hexHash(this.padHex(e)+this.padHex(t)),new ie(this.UHexHash,16)},t.hash=function(e){var t=e instanceof Y.lW?G().lib.WordArray.create(e):e,r=X()(t).toString();return new Array(64-r.length).join("0")+r},t.hexHash=function(e){return this.hash(Y.lW.from(e,"hex"))},t.computehkdf=function(e,t){var r=G().lib.WordArray.create(Y.lW.concat([this.infoBits,Y.lW.from(String.fromCharCode(1),"utf8")])),n=e instanceof Y.lW?G().lib.WordArray.create(e):e,i=t instanceof Y.lW?G().lib.WordArray.create(t):t,s=te()(n,i),o=te()(r,s);return Y.lW.from(o.toString(),"hex").slice(0,16)},t.getPasswordAuthenticationKey=function(e,t,r,n,i){var s=this;if(r.mod(this.N).equals(ie.ZERO))throw new Error("B cannot be zero.");if(this.UValue=this.calculateU(this.largeAValue,r),this.UValue.equals(ie.ZERO))throw new Error("U cannot be zero.");var o=""+this.poolName+e+":"+t,a=this.hash(o),u=new ie(this.hexHash(this.padHex(n)+a),16);this.calculateS(u,r,(function(e,t){e&&i(e,null);var r=s.computehkdf(Y.lW.from(s.padHex(t),"hex"),Y.lW.from(s.padHex(s.UValue),"hex"));i(null,r)}))},t.calculateS=function(e,t,r){var n=this;this.g.modPow(e,this.N,(function(i,s){i&&r(i,null),t.subtract(n.k.multiply(s)).modPow(n.smallAValue.add(n.UValue.multiply(e)),n.N,(function(e,t){e&&r(e,null),r(null,t.mod(n.N))}))}))},t.getNewPasswordRequiredChallengeUserAttributePrefix=function(){return"userAttributes."},t.padHex=function(e){if(!(e instanceof ie))throw new Error("Not a BigInteger");var t=e.compareTo(ie.ZERO)<0,r=e.abs().toString(16);if(r=r.length%2!=0?"0"+r:r,r=me.test(r)?"00"+r:r,t){var n=r.split("").map((function(e){var t=15&~parseInt(e,16);return"0123456789ABCDEF".charAt(t)})).join("");(r=new ie(n,16).add(ie.ONE).toString(16)).toUpperCase().startsWith("FF8")&&(r=r.substring(2))}return r},e}(),_e=function(){function e(e){this.jwtToken=e||"",this.payload=this.decodePayload()}var t=e.prototype;return t.getJwtToken=function(){return this.jwtToken},t.getExpiration=function(){return this.payload.exp},t.getIssuedAt=function(){return this.payload.iat},t.decodePayload=function(){var e=this.jwtToken.split(".")[1];try{return JSON.parse(Y.lW.from(e,"base64").toString("utf8"))}catch(e){return{}}},e}();function Ae(e,t){return Ae=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},Ae(e,t)}var ve=function(e){var t,r;function n(t){var r=(void 0===t?{}:t).AccessToken;return e.call(this,r||"")||this}return r=e,(t=n).prototype=Object.create(r.prototype),t.prototype.constructor=t,Ae(t,r),n}(_e);function Ee(e,t){return Ee=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},Ee(e,t)}var Se=function(e){var t,r;function n(t){var r=(void 0===t?{}:t).IdToken;return e.call(this,r||"")||this}return r=e,(t=n).prototype=Object.create(r.prototype),t.prototype.constructor=t,Ee(t,r),n}(_e),Ie=r(269),Te=r.n(Ie),Re=function(){function e(e){var t=(void 0===e?{}:e).RefreshToken;this.token=t||""}return e.prototype.getToken=function(){return this.token},e}(),Ue=function(){function e(e){var t=void 0===e?{}:e,r=t.IdToken,n=t.RefreshToken,i=t.AccessToken,s=t.ClockDrift;if(null==i||null==r)throw new Error("Id token and Access Token must be present.");this.idToken=r,this.refreshToken=n,this.accessToken=i,this.clockDrift=void 0===s?this.calculateClockDrift():s}var t=e.prototype;return t.getIdToken=function(){return this.idToken},t.getRefreshToken=function(){return this.refreshToken},t.getAccessToken=function(){return this.accessToken},t.getClockDrift=function(){return this.clockDrift},t.calculateClockDrift=function(){return Math.floor(new Date/1e3)-Math.min(this.accessToken.getIssuedAt(),this.idToken.getIssuedAt())},t.isValid=function(){var e=Math.floor(new Date/1e3)-this.clockDrift;return e<this.accessToken.getExpiration()&&e<this.idToken.getExpiration()},e}(),De=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],Ce=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],Pe=function(){function e(){}return e.prototype.getNowString=function(){var e=new Date,t=Ce[e.getUTCDay()],r=De[e.getUTCMonth()],n=e.getUTCDate(),i=e.getUTCHours();i<10&&(i="0"+i);var s=e.getUTCMinutes();s<10&&(s="0"+s);var o=e.getUTCSeconds();return o<10&&(o="0"+o),t+" "+r+" "+n+" "+i+":"+s+":"+o+" UTC "+e.getUTCFullYear()},e}(),Ne=function(){function e(e){var t=void 0===e?{}:e,r=t.Name,n=t.Value;this.Name=r||"",this.Value=n||""}var t=e.prototype;return t.getValue=function(){return this.Value},t.setValue=function(e){return this.Value=e,this},t.getName=function(){return this.Name},t.setName=function(e){return this.Name=e,this},t.toString=function(){return JSON.stringify(this)},t.toJSON=function(){return{Name:this.Name,Value:this.Value}},e}(),ke={},Oe=function(){function e(){}return e.setItem=function(e,t){return ke[e]=t,ke[e]},e.getItem=function(e){return Object.prototype.hasOwnProperty.call(ke,e)?ke[e]:void 0},e.removeItem=function(e){return delete ke[e]},e.clear=function(){return ke={}},e}(),Me=function(){function e(){try{this.storageWindow=window.localStorage,this.storageWindow.setItem("aws.cognito.test-ls",1),this.storageWindow.removeItem("aws.cognito.test-ls")}catch(e){this.storageWindow=Oe}}return e.prototype.getStorage=function(){return this.storageWindow},e}(),Fe="undefined"!=typeof navigator?navigator.userAgent:"nodejs",Ve=function(){function e(e){if(null==e||null==e.Username||null==e.Pool)throw new Error("Username and Pool information are required.");this.username=e.Username||"",this.pool=e.Pool,this.Session=null,this.client=e.Pool.client,this.signInUserSession=null,this.authenticationFlowType="USER_SRP_AUTH",this.storage=e.Storage||(new Me).getStorage(),this.keyPrefix="CognitoIdentityServiceProvider."+this.pool.getClientId(),this.userDataKey=this.keyPrefix+"."+this.username+".userData"}var t=e.prototype;return t.setSignInUserSession=function(e){this.clearCachedUserData(),this.signInUserSession=e,this.cacheTokens()},t.getSignInUserSession=function(){return this.signInUserSession},t.getUsername=function(){return this.username},t.getAuthenticationFlowType=function(){return this.authenticationFlowType},t.setAuthenticationFlowType=function(e){this.authenticationFlowType=e},t.initiateAuth=function(e,t){var r=this,n=e.getAuthParameters();n.USERNAME=this.username;var i=0!==Object.keys(e.getValidationData()).length?e.getValidationData():e.getClientMetadata(),s={AuthFlow:"CUSTOM_AUTH",ClientId:this.pool.getClientId(),AuthParameters:n,ClientMetadata:i};this.getUserContextData()&&(s.UserContextData=this.getUserContextData()),this.client.request("InitiateAuth",s,(function(e,n){if(e)return t.onFailure(e);var i=n.ChallengeName,s=n.ChallengeParameters;return"CUSTOM_CHALLENGE"===i?(r.Session=n.Session,t.customChallenge(s)):(r.signInUserSession=r.getCognitoUserSession(n.AuthenticationResult),r.cacheTokens(),t.onSuccess(r.signInUserSession))}))},t.authenticateUser=function(e,t){return"USER_PASSWORD_AUTH"===this.authenticationFlowType?this.authenticateUserPlainUsernamePassword(e,t):"USER_SRP_AUTH"===this.authenticationFlowType||"CUSTOM_AUTH"===this.authenticationFlowType?this.authenticateUserDefaultAuth(e,t):t.onFailure(new Error("Authentication flow type is invalid."))},t.authenticateUserDefaultAuth=function(e,t){var r,n,i=this,s=new be(this.pool.getUserPoolName()),o=new Pe,a={};null!=this.deviceKey&&(a.DEVICE_KEY=this.deviceKey),a.USERNAME=this.username,s.getLargeAValue((function(u,c){u&&t.onFailure(u),a.SRP_A=c.toString(16),"CUSTOM_AUTH"===i.authenticationFlowType&&(a.CHALLENGE_NAME="SRP_A");var l=0!==Object.keys(e.getValidationData()).length?e.getValidationData():e.getClientMetadata(),h={AuthFlow:i.authenticationFlowType,ClientId:i.pool.getClientId(),AuthParameters:a,ClientMetadata:l};i.getUserContextData(i.username)&&(h.UserContextData=i.getUserContextData(i.username)),i.client.request("InitiateAuth",h,(function(a,u){if(a)return t.onFailure(a);var c=u.ChallengeParameters;i.username=c.USER_ID_FOR_SRP,i.userDataKey=i.keyPrefix+"."+i.username+".userData",r=new ie(c.SRP_B,16),n=new ie(c.SALT,16),i.getCachedDeviceKeyAndPassword(),s.getPasswordAuthenticationKey(i.username,e.getPassword(),r,n,(function(e,r){e&&t.onFailure(e);var n=o.getNowString(),a=G().lib.WordArray.create(Y.lW.concat([Y.lW.from(i.pool.getUserPoolName(),"utf8"),Y.lW.from(i.username,"utf8"),Y.lW.from(c.SECRET_BLOCK,"base64"),Y.lW.from(n,"utf8")])),h=G().lib.WordArray.create(r),f=Te().stringify(te()(a,h)),d={};d.USERNAME=i.username,d.PASSWORD_CLAIM_SECRET_BLOCK=c.SECRET_BLOCK,d.TIMESTAMP=n,d.PASSWORD_CLAIM_SIGNATURE=f,null!=i.deviceKey&&(d.DEVICE_KEY=i.deviceKey);var p={ChallengeName:"PASSWORD_VERIFIER",ClientId:i.pool.getClientId(),ChallengeResponses:d,Session:u.Session,ClientMetadata:l};i.getUserContextData()&&(p.UserContextData=i.getUserContextData()),function e(t,r){return i.client.request("RespondToAuthChallenge",t,(function(n,s){return n&&"ResourceNotFoundException"===n.code&&-1!==n.message.toLowerCase().indexOf("device")?(d.DEVICE_KEY=null,i.deviceKey=null,i.randomPassword=null,i.deviceGroupKey=null,i.clearCachedDeviceKeyAndPassword(),e(t,r)):r(n,s)}))}(p,(function(e,r){return e?t.onFailure(e):i.authenticateUserInternal(r,s,t)}))}))}))}))},t.authenticateUserPlainUsernamePassword=function(e,t){var r=this,n={};if(n.USERNAME=this.username,n.PASSWORD=e.getPassword(),n.PASSWORD){var i=new be(this.pool.getUserPoolName());this.getCachedDeviceKeyAndPassword(),null!=this.deviceKey&&(n.DEVICE_KEY=this.deviceKey);var s=0!==Object.keys(e.getValidationData()).length?e.getValidationData():e.getClientMetadata(),o={AuthFlow:"USER_PASSWORD_AUTH",ClientId:this.pool.getClientId(),AuthParameters:n,ClientMetadata:s};this.getUserContextData(this.username)&&(o.UserContextData=this.getUserContextData(this.username)),this.client.request("InitiateAuth",o,(function(e,n){return e?t.onFailure(e):r.authenticateUserInternal(n,i,t)}))}else t.onFailure(new Error("PASSWORD parameter is required"))},t.authenticateUserInternal=function(e,t,r){var n=this,i=e.ChallengeName,s=e.ChallengeParameters;if("SMS_MFA"===i)return this.Session=e.Session,r.mfaRequired(i,s);if("SELECT_MFA_TYPE"===i)return this.Session=e.Session,r.selectMFAType(i,s);if("MFA_SETUP"===i)return this.Session=e.Session,r.mfaSetup(i,s);if("SOFTWARE_TOKEN_MFA"===i)return this.Session=e.Session,r.totpRequired(i,s);if("CUSTOM_CHALLENGE"===i)return this.Session=e.Session,r.customChallenge(s);if("NEW_PASSWORD_REQUIRED"===i){this.Session=e.Session;var o=null,a=null,u=[],c=t.getNewPasswordRequiredChallengeUserAttributePrefix();if(s&&(o=JSON.parse(e.ChallengeParameters.userAttributes),a=JSON.parse(e.ChallengeParameters.requiredAttributes)),a)for(var l=0;l<a.length;l++)u[l]=a[l].substr(c.length);return r.newPasswordRequired(o,u)}if("DEVICE_SRP_AUTH"===i)return this.Session=e.Session,void this.getDeviceResponse(r);this.signInUserSession=this.getCognitoUserSession(e.AuthenticationResult),this.challengeName=i,this.cacheTokens();var h=e.AuthenticationResult.NewDeviceMetadata;if(null==h)return r.onSuccess(this.signInUserSession);t.generateHashDevice(e.AuthenticationResult.NewDeviceMetadata.DeviceGroupKey,e.AuthenticationResult.NewDeviceMetadata.DeviceKey,(function(i){if(i)return r.onFailure(i);var s={Salt:Y.lW.from(t.getSaltDevices(),"hex").toString("base64"),PasswordVerifier:Y.lW.from(t.getVerifierDevices(),"hex").toString("base64")};n.verifierDevices=s.PasswordVerifier,n.deviceGroupKey=h.DeviceGroupKey,n.randomPassword=t.getRandomPassword(),n.client.request("ConfirmDevice",{DeviceKey:h.DeviceKey,AccessToken:n.signInUserSession.getAccessToken().getJwtToken(),DeviceSecretVerifierConfig:s,DeviceName:Fe},(function(t,i){return t?r.onFailure(t):(n.deviceKey=e.AuthenticationResult.NewDeviceMetadata.DeviceKey,n.cacheDeviceKeyAndPassword(),!0===i.UserConfirmationNecessary?r.onSuccess(n.signInUserSession,i.UserConfirmationNecessary):r.onSuccess(n.signInUserSession))}))}))},t.completeNewPasswordChallenge=function(e,t,r,n){var i=this;if(!e)return r.onFailure(new Error("New password is required."));var s=new be(this.pool.getUserPoolName()),o=s.getNewPasswordRequiredChallengeUserAttributePrefix(),a={};t&&Object.keys(t).forEach((function(e){a[o+e]=t[e]})),a.NEW_PASSWORD=e,a.USERNAME=this.username;var u={ChallengeName:"NEW_PASSWORD_REQUIRED",ClientId:this.pool.getClientId(),ChallengeResponses:a,Session:this.Session,ClientMetadata:n};this.getUserContextData()&&(u.UserContextData=this.getUserContextData()),this.client.request("RespondToAuthChallenge",u,(function(e,t){return e?r.onFailure(e):i.authenticateUserInternal(t,s,r)}))},t.getDeviceResponse=function(e,t){var r=this,n=new be(this.deviceGroupKey),i=new Pe,s={};s.USERNAME=this.username,s.DEVICE_KEY=this.deviceKey,n.getLargeAValue((function(o,a){o&&e.onFailure(o),s.SRP_A=a.toString(16);var u={ChallengeName:"DEVICE_SRP_AUTH",ClientId:r.pool.getClientId(),ChallengeResponses:s,ClientMetadata:t,Session:r.Session};r.getUserContextData()&&(u.UserContextData=r.getUserContextData()),r.client.request("RespondToAuthChallenge",u,(function(t,s){if(t)return e.onFailure(t);var o=s.ChallengeParameters,a=new ie(o.SRP_B,16),u=new ie(o.SALT,16);n.getPasswordAuthenticationKey(r.deviceKey,r.randomPassword,a,u,(function(t,n){if(t)return e.onFailure(t);var a=i.getNowString(),u=G().lib.WordArray.create(Y.lW.concat([Y.lW.from(r.deviceGroupKey,"utf8"),Y.lW.from(r.deviceKey,"utf8"),Y.lW.from(o.SECRET_BLOCK,"base64"),Y.lW.from(a,"utf8")])),c=G().lib.WordArray.create(n),l=Te().stringify(te()(u,c)),h={};h.USERNAME=r.username,h.PASSWORD_CLAIM_SECRET_BLOCK=o.SECRET_BLOCK,h.TIMESTAMP=a,h.PASSWORD_CLAIM_SIGNATURE=l,h.DEVICE_KEY=r.deviceKey;var f={ChallengeName:"DEVICE_PASSWORD_VERIFIER",ClientId:r.pool.getClientId(),ChallengeResponses:h,Session:s.Session};r.getUserContextData()&&(f.UserContextData=r.getUserContextData()),r.client.request("RespondToAuthChallenge",f,(function(t,n){return t?e.onFailure(t):(r.signInUserSession=r.getCognitoUserSession(n.AuthenticationResult),r.cacheTokens(),e.onSuccess(r.signInUserSession))}))}))}))}))},t.confirmRegistration=function(e,t,r,n){var i={ClientId:this.pool.getClientId(),ConfirmationCode:e,Username:this.username,ForceAliasCreation:t,ClientMetadata:n};this.getUserContextData()&&(i.UserContextData=this.getUserContextData()),this.client.request("ConfirmSignUp",i,(function(e){return e?r(e,null):r(null,"SUCCESS")}))},t.sendCustomChallengeAnswer=function(e,t,r){var n=this,i={};i.USERNAME=this.username,i.ANSWER=e;var s=new be(this.pool.getUserPoolName());this.getCachedDeviceKeyAndPassword(),null!=this.deviceKey&&(i.DEVICE_KEY=this.deviceKey);var o={ChallengeName:"CUSTOM_CHALLENGE",ChallengeResponses:i,ClientId:this.pool.getClientId(),Session:this.Session,ClientMetadata:r};this.getUserContextData()&&(o.UserContextData=this.getUserContextData()),this.client.request("RespondToAuthChallenge",o,(function(e,r){return e?t.onFailure(e):n.authenticateUserInternal(r,s,t)}))},t.sendMFACode=function(e,t,r,n){var i=this,s={};s.USERNAME=this.username,s.SMS_MFA_CODE=e;var o=r||"SMS_MFA";"SOFTWARE_TOKEN_MFA"===o&&(s.SOFTWARE_TOKEN_MFA_CODE=e),null!=this.deviceKey&&(s.DEVICE_KEY=this.deviceKey);var a={ChallengeName:o,ChallengeResponses:s,ClientId:this.pool.getClientId(),Session:this.Session,ClientMetadata:n};this.getUserContextData()&&(a.UserContextData=this.getUserContextData()),this.client.request("RespondToAuthChallenge",a,(function(e,r){if(e)return t.onFailure(e);if("DEVICE_SRP_AUTH"!==r.ChallengeName){if(i.signInUserSession=i.getCognitoUserSession(r.AuthenticationResult),i.cacheTokens(),null==r.AuthenticationResult.NewDeviceMetadata)return t.onSuccess(i.signInUserSession);var n=new be(i.pool.getUserPoolName());n.generateHashDevice(r.AuthenticationResult.NewDeviceMetadata.DeviceGroupKey,r.AuthenticationResult.NewDeviceMetadata.DeviceKey,(function(e){if(e)return t.onFailure(e);var s={Salt:Y.lW.from(n.getSaltDevices(),"hex").toString("base64"),PasswordVerifier:Y.lW.from(n.getVerifierDevices(),"hex").toString("base64")};i.verifierDevices=s.PasswordVerifier,i.deviceGroupKey=r.AuthenticationResult.NewDeviceMetadata.DeviceGroupKey,i.randomPassword=n.getRandomPassword(),i.client.request("ConfirmDevice",{DeviceKey:r.AuthenticationResult.NewDeviceMetadata.DeviceKey,AccessToken:i.signInUserSession.getAccessToken().getJwtToken(),DeviceSecretVerifierConfig:s,DeviceName:Fe},(function(e,n){return e?t.onFailure(e):(i.deviceKey=r.AuthenticationResult.NewDeviceMetadata.DeviceKey,i.cacheDeviceKeyAndPassword(),!0===n.UserConfirmationNecessary?t.onSuccess(i.signInUserSession,n.UserConfirmationNecessary):t.onSuccess(i.signInUserSession))}))}))}else i.getDeviceResponse(t)}))},t.changePassword=function(e,t,r,n){if(null==this.signInUserSession||!this.signInUserSession.isValid())return r(new Error("User is not authenticated"),null);this.client.request("ChangePassword",{PreviousPassword:e,ProposedPassword:t,AccessToken:this.signInUserSession.getAccessToken().getJwtToken(),ClientMetadata:n},(function(e){return e?r(e,null):r(null,"SUCCESS")}))},t.enableMFA=function(e){if(null==this.signInUserSession||!this.signInUserSession.isValid())return e(new Error("User is not authenticated"),null);var t=[];t.push({DeliveryMedium:"SMS",AttributeName:"phone_number"}),this.client.request("SetUserSettings",{MFAOptions:t,AccessToken:this.signInUserSession.getAccessToken().getJwtToken()},(function(t){return t?e(t,null):e(null,"SUCCESS")}))},t.setUserMfaPreference=function(e,t,r){if(null==this.signInUserSession||!this.signInUserSession.isValid())return r(new Error("User is not authenticated"),null);this.client.request("SetUserMFAPreference",{SMSMfaSettings:e,SoftwareTokenMfaSettings:t,AccessToken:this.signInUserSession.getAccessToken().getJwtToken()},(function(e){return e?r(e,null):r(null,"SUCCESS")}))},t.disableMFA=function(e){if(null==this.signInUserSession||!this.signInUserSession.isValid())return e(new Error("User is not authenticated"),null);this.client.request("SetUserSettings",{MFAOptions:[],AccessToken:this.signInUserSession.getAccessToken().getJwtToken()},(function(t){return t?e(t,null):e(null,"SUCCESS")}))},t.deleteUser=function(e,t){var r=this;if(null==this.signInUserSession||!this.signInUserSession.isValid())return e(new Error("User is not authenticated"),null);this.client.request("DeleteUser",{AccessToken:this.signInUserSession.getAccessToken().getJwtToken(),ClientMetadata:t},(function(t){return t?e(t,null):(r.clearCachedUser(),e(null,"SUCCESS"))}))},t.updateAttributes=function(e,t,r){var n=this;if(null==this.signInUserSession||!this.signInUserSession.isValid())return t(new Error("User is not authenticated"),null);this.client.request("UpdateUserAttributes",{AccessToken:this.signInUserSession.getAccessToken().getJwtToken(),UserAttributes:e,ClientMetadata:r},(function(e){return e?t(e,null):n.getUserData((function(){return t(null,"SUCCESS")}),{bypassCache:!0})}))},t.getUserAttributes=function(e){if(null==this.signInUserSession||!this.signInUserSession.isValid())return e(new Error("User is not authenticated"),null);this.client.request("GetUser",{AccessToken:this.signInUserSession.getAccessToken().getJwtToken()},(function(t,r){if(t)return e(t,null);for(var n=[],i=0;i<r.UserAttributes.length;i++){var s={Name:r.UserAttributes[i].Name,Value:r.UserAttributes[i].Value},o=new Ne(s);n.push(o)}return e(null,n)}))},t.getMFAOptions=function(e){if(null==this.signInUserSession||!this.signInUserSession.isValid())return e(new Error("User is not authenticated"),null);this.client.request("GetUser",{AccessToken:this.signInUserSession.getAccessToken().getJwtToken()},(function(t,r){return t?e(t,null):e(null,r.MFAOptions)}))},t.createGetUserRequest=function(){return this.client.promisifyRequest("GetUser",{AccessToken:this.signInUserSession.getAccessToken().getJwtToken()})},t.refreshSessionIfPossible=function(e){var t=this;return void 0===e&&(e={}),new Promise((function(r){var n=t.signInUserSession.getRefreshToken();n&&n.getToken()?t.refreshSession(n,r,e.clientMetadata):r()}))},t.getUserData=function(e,t){var r=this;if(null==this.signInUserSession||!this.signInUserSession.isValid())return this.clearCachedUserData(),e(new Error("User is not authenticated"),null);var n=this.getUserDataFromCache();if(n)if(this.isFetchUserDataAndTokenRequired(t))this.fetchUserData().then((function(e){return r.refreshSessionIfPossible(t).then((function(){return e}))})).then((function(t){return e(null,t)})).catch(e);else try{return void e(null,JSON.parse(n))}catch(t){return this.clearCachedUserData(),void e(t,null)}else this.fetchUserData().then((function(t){e(null,t)})).catch(e)},t.getUserDataFromCache=function(){return this.storage.getItem(this.userDataKey)},t.isFetchUserDataAndTokenRequired=function(e){var t=(e||{}).bypassCache;return void 0!==t&&t},t.fetchUserData=function(){var e=this;return this.createGetUserRequest().then((function(t){return e.cacheUserData(t),t}))},t.deleteAttributes=function(e,t){var r=this;if(null==this.signInUserSession||!this.signInUserSession.isValid())return t(new Error("User is not authenticated"),null);this.client.request("DeleteUserAttributes",{UserAttributeNames:e,AccessToken:this.signInUserSession.getAccessToken().getJwtToken()},(function(e){return e?t(e,null):r.getUserData((function(){return t(null,"SUCCESS")}),{bypassCache:!0})}))},t.resendConfirmationCode=function(e,t){var r={ClientId:this.pool.getClientId(),Username:this.username,ClientMetadata:t};this.client.request("ResendConfirmationCode",r,(function(t,r){return t?e(t,null):e(null,r)}))},t.getSession=function(e,t){if(void 0===t&&(t={}),null==this.username)return e(new Error("Username is null. Cannot retrieve a new session"),null);if(null!=this.signInUserSession&&this.signInUserSession.isValid())return e(null,this.signInUserSession);var r="CognitoIdentityServiceProvider."+this.pool.getClientId()+"."+this.username,n=r+".idToken",i=r+".accessToken",s=r+".refreshToken",o=r+".clockDrift";if(this.storage.getItem(n)){var a=new Se({IdToken:this.storage.getItem(n)}),u=new ve({AccessToken:this.storage.getItem(i)}),c=new Re({RefreshToken:this.storage.getItem(s)}),l=parseInt(this.storage.getItem(o),0)||0,h=new Ue({IdToken:a,AccessToken:u,RefreshToken:c,ClockDrift:l});if(h.isValid())return this.signInUserSession=h,e(null,this.signInUserSession);if(!c.getToken())return e(new Error("Cannot retrieve a new session. Please authenticate."),null);this.refreshSession(c,e,t.clientMetadata)}else e(new Error("Local storage is missing an ID Token, Please authenticate"),null)},t.refreshSession=function(e,t,r){var n=this,i=this.pool.wrapRefreshSessionCallback?this.pool.wrapRefreshSessionCallback(t):t,s={};s.REFRESH_TOKEN=e.getToken();var o="CognitoIdentityServiceProvider."+this.pool.getClientId(),a=o+".LastAuthUser";if(this.storage.getItem(a)){this.username=this.storage.getItem(a);var u=o+"."+this.username+".deviceKey";this.deviceKey=this.storage.getItem(u),s.DEVICE_KEY=this.deviceKey}var c={ClientId:this.pool.getClientId(),AuthFlow:"REFRESH_TOKEN_AUTH",AuthParameters:s,ClientMetadata:r};this.getUserContextData()&&(c.UserContextData=this.getUserContextData()),this.client.request("InitiateAuth",c,(function(t,r){if(t)return"NotAuthorizedException"===t.code&&n.clearCachedUser(),i(t,null);if(r){var s=r.AuthenticationResult;return Object.prototype.hasOwnProperty.call(s,"RefreshToken")||(s.RefreshToken=e.getToken()),n.signInUserSession=n.getCognitoUserSession(s),n.cacheTokens(),i(null,n.signInUserSession)}}))},t.cacheTokens=function(){var e="CognitoIdentityServiceProvider."+this.pool.getClientId(),t=e+"."+this.username+".idToken",r=e+"."+this.username+".accessToken",n=e+"."+this.username+".refreshToken",i=e+"."+this.username+".clockDrift",s=e+".LastAuthUser";this.storage.setItem(t,this.signInUserSession.getIdToken().getJwtToken()),this.storage.setItem(r,this.signInUserSession.getAccessToken().getJwtToken()),this.storage.setItem(n,this.signInUserSession.getRefreshToken().getToken()),this.storage.setItem(i,""+this.signInUserSession.getClockDrift()),this.storage.setItem(s,this.username)},t.cacheUserData=function(e){this.storage.setItem(this.userDataKey,JSON.stringify(e))},t.clearCachedUserData=function(){this.storage.removeItem(this.userDataKey)},t.clearCachedUser=function(){this.clearCachedTokens(),this.clearCachedUserData()},t.cacheDeviceKeyAndPassword=function(){var e="CognitoIdentityServiceProvider."+this.pool.getClientId()+"."+this.username,t=e+".deviceKey",r=e+".randomPasswordKey",n=e+".deviceGroupKey";this.storage.setItem(t,this.deviceKey),this.storage.setItem(r,this.randomPassword),this.storage.setItem(n,this.deviceGroupKey)},t.getCachedDeviceKeyAndPassword=function(){var e="CognitoIdentityServiceProvider."+this.pool.getClientId()+"."+this.username,t=e+".deviceKey",r=e+".randomPasswordKey",n=e+".deviceGroupKey";this.storage.getItem(t)&&(this.deviceKey=this.storage.getItem(t),this.randomPassword=this.storage.getItem(r),this.deviceGroupKey=this.storage.getItem(n))},t.clearCachedDeviceKeyAndPassword=function(){var e="CognitoIdentityServiceProvider."+this.pool.getClientId()+"."+this.username,t=e+".deviceKey",r=e+".randomPasswordKey",n=e+".deviceGroupKey";this.storage.removeItem(t),this.storage.removeItem(r),this.storage.removeItem(n)},t.clearCachedTokens=function(){var e="CognitoIdentityServiceProvider."+this.pool.getClientId(),t=e+"."+this.username+".idToken",r=e+"."+this.username+".accessToken",n=e+"."+this.username+".refreshToken",i=e+".LastAuthUser",s=e+"."+this.username+".clockDrift";this.storage.removeItem(t),this.storage.removeItem(r),this.storage.removeItem(n),this.storage.removeItem(i),this.storage.removeItem(s)},t.getCognitoUserSession=function(e){var t=new Se(e),r=new ve(e),n=new Re(e);return new Ue({IdToken:t,AccessToken:r,RefreshToken:n})},t.forgotPassword=function(e,t){var r={ClientId:this.pool.getClientId(),Username:this.username,ClientMetadata:t};this.getUserContextData()&&(r.UserContextData=this.getUserContextData()),this.client.request("ForgotPassword",r,(function(t,r){return t?e.onFailure(t):"function"==typeof e.inputVerificationCode?e.inputVerificationCode(r):e.onSuccess(r)}))},t.confirmPassword=function(e,t,r,n){var i={ClientId:this.pool.getClientId(),Username:this.username,ConfirmationCode:e,Password:t,ClientMetadata:n};this.getUserContextData()&&(i.UserContextData=this.getUserContextData()),this.client.request("ConfirmForgotPassword",i,(function(e){return e?r.onFailure(e):r.onSuccess("SUCCESS")}))},t.getAttributeVerificationCode=function(e,t,r){if(null==this.signInUserSession||!this.signInUserSession.isValid())return t.onFailure(new Error("User is not authenticated"));this.client.request("GetUserAttributeVerificationCode",{AttributeName:e,AccessToken:this.signInUserSession.getAccessToken().getJwtToken(),ClientMetadata:r},(function(e,r){return e?t.onFailure(e):"function"==typeof t.inputVerificationCode?t.inputVerificationCode(r):t.onSuccess("SUCCESS")}))},t.verifyAttribute=function(e,t,r){if(null==this.signInUserSession||!this.signInUserSession.isValid())return r.onFailure(new Error("User is not authenticated"));this.client.request("VerifyUserAttribute",{AttributeName:e,Code:t,AccessToken:this.signInUserSession.getAccessToken().getJwtToken()},(function(e){return e?r.onFailure(e):r.onSuccess("SUCCESS")}))},t.getDevice=function(e){if(null==this.signInUserSession||!this.signInUserSession.isValid())return e.onFailure(new Error("User is not authenticated"));this.client.request("GetDevice",{AccessToken:this.signInUserSession.getAccessToken().getJwtToken(),DeviceKey:this.deviceKey},(function(t,r){return t?e.onFailure(t):e.onSuccess(r)}))},t.forgetSpecificDevice=function(e,t){if(null==this.signInUserSession||!this.signInUserSession.isValid())return t.onFailure(new Error("User is not authenticated"));this.client.request("ForgetDevice",{AccessToken:this.signInUserSession.getAccessToken().getJwtToken(),DeviceKey:e},(function(e){return e?t.onFailure(e):t.onSuccess("SUCCESS")}))},t.forgetDevice=function(e){var t=this;this.forgetSpecificDevice(this.deviceKey,{onFailure:e.onFailure,onSuccess:function(r){return t.deviceKey=null,t.deviceGroupKey=null,t.randomPassword=null,t.clearCachedDeviceKeyAndPassword(),e.onSuccess(r)}})},t.setDeviceStatusRemembered=function(e){if(null==this.signInUserSession||!this.signInUserSession.isValid())return e.onFailure(new Error("User is not authenticated"));this.client.request("UpdateDeviceStatus",{AccessToken:this.signInUserSession.getAccessToken().getJwtToken(),DeviceKey:this.deviceKey,DeviceRememberedStatus:"remembered"},(function(t){return t?e.onFailure(t):e.onSuccess("SUCCESS")}))},t.setDeviceStatusNotRemembered=function(e){if(null==this.signInUserSession||!this.signInUserSession.isValid())return e.onFailure(new Error("User is not authenticated"));this.client.request("UpdateDeviceStatus",{AccessToken:this.signInUserSession.getAccessToken().getJwtToken(),DeviceKey:this.deviceKey,DeviceRememberedStatus:"not_remembered"},(function(t){return t?e.onFailure(t):e.onSuccess("SUCCESS")}))},t.listDevices=function(e,t,r){if(null==this.signInUserSession||!this.signInUserSession.isValid())return r.onFailure(new Error("User is not authenticated"));var n={AccessToken:this.signInUserSession.getAccessToken().getJwtToken(),Limit:e};t&&(n.PaginationToken=t),this.client.request("ListDevices",n,(function(e,t){return e?r.onFailure(e):r.onSuccess(t)}))},t.globalSignOut=function(e){var t=this;if(null==this.signInUserSession||!this.signInUserSession.isValid())return e.onFailure(new Error("User is not authenticated"));this.client.request("GlobalSignOut",{AccessToken:this.signInUserSession.getAccessToken().getJwtToken()},(function(r){return r?e.onFailure(r):(t.clearCachedUser(),e.onSuccess("SUCCESS"))}))},t.signOut=function(e){var t=this;e&&"function"==typeof e?this.getSession((function(r,n){if(r)return e(r);t.revokeTokens((function(r){t.cleanClientData(),e(r)}))})):this.cleanClientData()},t.revokeTokens=function(e){if(void 0===e&&(e=function(){}),"function"!=typeof e)throw new Error("Invalid revokeTokenCallback. It should be a function.");if(!this.signInUserSession)return e(new Error("User is not authenticated"));if(!this.signInUserSession.getAccessToken())return e(new Error("No Access token available"));var t=this.signInUserSession.getRefreshToken().getToken(),r=this.signInUserSession.getAccessToken();if(this.isSessionRevocable(r)&&t)return this.revokeToken({token:t,callback:e});e()},t.isSessionRevocable=function(e){if(e&&"function"==typeof e.decodePayload)try{return!!e.decodePayload().origin_jti}catch(e){}return!1},t.cleanClientData=function(){this.signInUserSession=null,this.clearCachedUser()},t.revokeToken=function(e){var t=e.token,r=e.callback;this.client.requestWithRetry("RevokeToken",{Token:t,ClientId:this.pool.getClientId()},(function(e){if(e)return r(e);r()}))},t.sendMFASelectionAnswer=function(e,t){var r=this,n={};n.USERNAME=this.username,n.ANSWER=e;var i={ChallengeName:"SELECT_MFA_TYPE",ChallengeResponses:n,ClientId:this.pool.getClientId(),Session:this.Session};this.getUserContextData()&&(i.UserContextData=this.getUserContextData()),this.client.request("RespondToAuthChallenge",i,(function(n,i){return n?t.onFailure(n):(r.Session=i.Session,"SMS_MFA"===e?t.mfaRequired(i.ChallengeName,i.ChallengeParameters):"SOFTWARE_TOKEN_MFA"===e?t.totpRequired(i.ChallengeName,i.ChallengeParameters):void 0)}))},t.getUserContextData=function(){return this.pool.getUserContextData(this.username)},t.associateSoftwareToken=function(e){var t=this;null!=this.signInUserSession&&this.signInUserSession.isValid()?this.client.request("AssociateSoftwareToken",{AccessToken:this.signInUserSession.getAccessToken().getJwtToken()},(function(t,r){return t?e.onFailure(t):e.associateSecretCode(r.SecretCode)})):this.client.request("AssociateSoftwareToken",{Session:this.Session},(function(r,n){return r?e.onFailure(r):(t.Session=n.Session,e.associateSecretCode(n.SecretCode))}))},t.verifySoftwareToken=function(e,t,r){var n=this;null!=this.signInUserSession&&this.signInUserSession.isValid()?this.client.request("VerifySoftwareToken",{AccessToken:this.signInUserSession.getAccessToken().getJwtToken(),UserCode:e,FriendlyDeviceName:t},(function(e,t){return e?r.onFailure(e):r.onSuccess(t)})):this.client.request("VerifySoftwareToken",{Session:this.Session,UserCode:e,FriendlyDeviceName:t},(function(e,t){if(e)return r.onFailure(e);n.Session=t.Session;var i={};i.USERNAME=n.username;var s={ChallengeName:"MFA_SETUP",ClientId:n.pool.getClientId(),ChallengeResponses:i,Session:n.Session};n.getUserContextData()&&(s.UserContextData=n.getUserContextData()),n.client.request("RespondToAuthChallenge",s,(function(e,t){return e?r.onFailure(e):(n.signInUserSession=n.getCognitoUserSession(t.AuthenticationResult),n.cacheTokens(),r.onSuccess(n.signInUserSession))}))}))},e}(),xe=(r(204),"aws-amplify/5.0.4"),Le={userAgent:xe+" js",product:"",navigator:null,isReactNative:!1};function Be(){}"undefined"!=typeof navigator&&navigator.product&&(Le.product=navigator.product||"",Le.navigator=navigator||null,"ReactNative"===navigator.product?(Le.userAgent=xe+" react-native",Le.isReactNative=!0):(Le.userAgent=xe+" js",Le.isReactNative=!1)),Be.prototype.userAgent=Le.userAgent;const $e=Be;function qe(e){var t="function"==typeof Map?new Map:void 0;return qe=function(e){if(null===e||(r=e,-1===Function.toString.call(r).indexOf("[native code]")))return e;var r;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return Ke(e,arguments,He(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),je(n,e)},qe(e)}function Ke(e,t,r){return Ke=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}()?Reflect.construct.bind():function(e,t,r){var n=[null];n.push.apply(n,t);var i=new(Function.bind.apply(e,n));return r&&je(i,r.prototype),i},Ke.apply(null,arguments)}function je(e,t){return je=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},je(e,t)}function He(e){return He=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},He(e)}var We=function(e){function t(t,r,n,i){var s;return(s=e.call(this,t)||this).code=r,s.name=n,s.statusCode=i,s}return n=e,(r=t).prototype=Object.create(n.prototype),r.prototype.constructor=r,je(r,n),t;var r,n}(qe(Error)),Je=function(){function e(e,t,r){this.endpoint=t||"https://cognito-idp."+e+".amazonaws.com/";var n=(r||{}).credentials;this.fetchOptions=n?{credentials:n}:{}}var t=e.prototype;return t.promisifyRequest=function(e,t){var r=this;return new Promise((function(n,i){r.request(e,t,(function(e,t){e?i(new We(e.message,e.code,e.name,e.statusCode)):n(t)}))}))},t.requestWithRetry=function(e,t,r){var n,i,s=this;(n=[t],i=5e3,void 0===i&&(i=Ge),Qe((function(t){return new Promise((function(r,n){s.request(e,t,(function(e,t){e?n(e):r(t)}))}))}),n,function(e){return function(t){var r=100*Math.pow(2,t)+100*Math.random();return!(r>e)&&r}}(i))).then((function(e){return r(null,e)})).catch((function(e){return r(e)}))},t.request=function(e,t,r){var n,i={"Content-Type":"application/x-amz-json-1.1","X-Amz-Target":"AWSCognitoIdentityProviderService."+e,"X-Amz-User-Agent":$e.prototype.userAgent,"Cache-Control":"no-store"},s=Object.assign({},this.fetchOptions,{headers:i,method:"POST",mode:"cors",body:JSON.stringify(t)});fetch(this.endpoint,s).then((function(e){return n=e,e}),(function(e){if(e instanceof TypeError)throw new Error("Network error");throw e})).then((function(e){return e.json().catch((function(){return{}}))})).then((function(e){if(n.ok)return r(null,e);var t=(e.__type||e.code).split("#").pop(),i=new Error(e.message||e.Message||null);return i.name=t,i.code=t,r(i)})).catch((function(e){if(n&&n.headers&&n.headers.get("x-amzn-errortype"))try{var t=n.headers.get("x-amzn-errortype").split(":")[0],i=new Error(n.status?n.status.toString():null);return i.code=t,i.name=t,i.statusCode=n.status,r(i)}catch(t){return r(e)}else e instanceof Error&&"Network error"===e.message&&(e.code="NetworkError");return r(e)}))},e}(),ze={debug:function(){}},Ye=function(e){return e&&e.nonRetryable};function Qe(e,t,r,n){if(void 0===n&&(n=1),"function"!=typeof e)throw Error("functionToRetry must be a function");return ze.debug(e.name+" attempt #"+n+" with args: "+JSON.stringify(t)),e.apply(void 0,t).catch((function(i){if(ze.debug("error on "+e.name,i),Ye(i))throw ze.debug(e.name+" non retryable error",i),i;var s=r(n,t,i);if(ze.debug(e.name+" retrying in "+s+" ms"),!1!==s)return new Promise((function(e){return setTimeout(e,s)})).then((function(){return Qe(e,t,r,n+1)}));throw i}))}var Ge=3e5,Ze=function(){function e(e,t){var r=e||{},n=r.UserPoolId,i=r.ClientId,s=r.endpoint,o=r.fetchOptions,a=r.AdvancedSecurityDataCollectionFlag;if(!n||!i)throw new Error("Both UserPoolId and ClientId are required.");if(n.length>55||!/^[\w-]+_[0-9a-zA-Z]+$/.test(n))throw new Error("Invalid UserPoolId format.");var u=n.split("_")[0];this.userPoolId=n,this.clientId=i,this.client=new Je(u,s,o),this.advancedSecurityDataCollectionFlag=!1!==a,this.storage=e.Storage||(new Me).getStorage(),t&&(this.wrapRefreshSessionCallback=t)}var t=e.prototype;return t.getUserPoolId=function(){return this.userPoolId},t.getUserPoolName=function(){return this.getUserPoolId().split("_")[1]},t.getClientId=function(){return this.clientId},t.signUp=function(e,t,r,n,i,s){var o=this,a={ClientId:this.clientId,Username:e,Password:t,UserAttributes:r,ValidationData:n,ClientMetadata:s};this.getUserContextData(e)&&(a.UserContextData=this.getUserContextData(e)),this.client.request("SignUp",a,(function(t,r){if(t)return i(t,null);var n={Username:e,Pool:o,Storage:o.storage},s={user:new Ve(n),userConfirmed:r.UserConfirmed,userSub:r.UserSub,codeDeliveryDetails:r.CodeDeliveryDetails};return i(null,s)}))},t.getCurrentUser=function(){var e="CognitoIdentityServiceProvider."+this.clientId+".LastAuthUser",t=this.storage.getItem(e);if(t){var r={Username:t,Pool:this,Storage:this.storage};return new Ve(r)}return null},t.getUserContextData=function(e){if("undefined"!=typeof AmazonCognitoAdvancedSecurityData){var t=AmazonCognitoAdvancedSecurityData;if(this.advancedSecurityDataCollectionFlag){var r=t.getData(e,this.userPoolId,this.clientId);if(r)return{EncodedData:r}}return{}}},e}();r(808);let Xe=null,et=null;function tt(){if(!et)throw new e("User pool is missing",{code:"INVALID_REQUEST"});const r=t=>{let r={};if(Array.isArray(t)){let r={};for(let n of t)if(r[n.Name]=n.Value,"custom:service"===n.Name&&r[n.Name]!==this.service)throw new e("The user is not registered to the service.",{code:"INVALID_REQUEST"});t=r}for(let n in t)if(n.includes("custom:")){if("custom:service"===n&&t[n]!==this.service)throw new e("The user is not registered to the service.",{code:"INVALID_REQUEST"});r[n.replace("custom:","")]=t[n]}else{if("address"===n){let e=t[n];if(e&&"object"==typeof e&&Object.keys(e).length&&e?.formatted)try{t[n]=JSON.parse(e.formatted)}catch(r){t[n]=e.formatted}}r[n]=t[n]}for(let e of["address_public","birthdate_public","email_public","gender_public","phone_number_public","access_group"])e.includes("_public")?r.hasOwnProperty(e.split("_")[0])?r[e]=!!r.hasOwnProperty(e)&&!!Number(r[e]):delete r[e]:r[e]=r.hasOwnProperty(e)?Number(r[e]):0;for(let e of["email","phone_number"])r.hasOwnProperty(e)?!0===r[e+"_verified"]||"true"===r[e+"_verified"]?r[e+"_verified"]=!0:r[e+"_verified"]=!1:delete r[e+"_verified"];for(let e of["aud",{from:"auth_time",to:"log"},"cognito:username","event_id","exp","iat","iss","jti","origin_jti","secret_key",{from:"sub",to:"user_id"},"token_use"])"string"==typeof e?delete r[e]:(r[e.to]=r[e.from],delete r[e.from]);this.__user=r},n=t=>{let{refreshToken:n=!1}=t||{};return new Promise(((t,i)=>{Xe=et?.getCurrentUser()||null,null!==Xe?Xe.getSession(((s,o)=>{if(s)i(s);else if(o)if(n||!o.isValid()){let n=!1;try{o.getIdToken().payload["custom:service"]!==this.service&&(Xe.signOut(),this.session=null,n=!0,t(null))}catch(s){}n||Xe.refreshSession(o.getRefreshToken(),((n,s)=>{if(n)i(n);else{if(!s.isValid())return void i(new e("Invalid session.",{code:"INVALID_REQUEST"}));this.session=s,r(s.getIdToken().payload),t(s)}}))}else{let e=o.getIdToken().payload;e["custom:service"]!==this.service?(Xe.signOut(),this.session=null,t(null)):(this.session=o,r(e),t(o))}else i(new e("Current session does not exist.",{code:"INVALID_REQUEST"}))})):i(null)}))},i=async r=>{if(!r)throw new e("E-Mail is required.",{code:"INVALID_PARAMETER"});let n=this.service+"-"+t.hash(r);return{cognitoUser:new Ve({Username:n,Pool:et}),cognitoUsername:n}};return{getSession:n,authenticateUser:(t,r)=>new Promise(((s,o)=>{this.__request_signup_confirmation=null,this.__disabledAccount=null,i(t).then((t=>{Xe=t.cognitoUser;let i=t.cognitoUsername,a=new z({Username:i,Password:r});Xe.authenticateUser(a,{newPasswordRequired:(t,a)=>{this.__request_signup_confirmation=i,"PASS"===t["custom:signup_ticket"]||"MEMBER"===t["custom:signup_ticket"]?Xe.completeNewPasswordChallenge(r,{},{onSuccess:e=>{n().then((e=>s(this.user)))},onFailure:t=>{o(new e(t.message||"Failed to authenticate user.",{code:t.code}))}}):o(new e("User's signup confirmation is required.",{code:"SIGNUP_CONFIRMATION_NEEDED"}))},onSuccess:e=>n().then((e=>s(this.user))),onFailure:t=>{let r=[t.message||"Failed to authenticate user.",t?.code||"INVALID_REQUEST"];"NotAuthorizedException"===t.code&&("User is disabled."===t.message?(this.__disabledAccount=i,r=["This account is disabled.","USER_IS_DISABLED"]):r=["Incorrect username or password.","INCORRECT_USERNAME_OR_PASSWORD"]);let n=r[1],s=r[0],a=r[0].split("#");a.length>1&&(a=a[a.length-1].split(":"),n=a[0],s=a[1]),o(new e(s,{code:n,cause:t}))}})}))})),createCognitoUser:i,getUser:()=>new Promise(((t,n)=>{this.session||t(null),null===Xe?n(new e("Invalid session",{code:"INVALID_REQUEST"})):Xe.getUserAttributes(((e,i)=>{e?n(e):(r(i),t(this.user))}))}))}}async function rt(e){await this.__connection;try{return await tt.bind(this)().getSession(e),this.user}catch(e){return null}}async function nt(){return await this.__connection,this.__user?.service===this.service?this.__user?.owner===this.host:(await it.bind(this)(),!1)}async function it(){await this.__connection,Xe&&Xe.signOut();let e={session:null,__startKeyHistory:{},__cached_requests:{},__user:null};for(let t in e)this[t]=e[t];return"SUCCESS: The user has been logged out."}async function st(t){if(!this.__request_signup_confirmation)throw new e("Least one login attempt is required.",{code:"INVALID_REQUEST"});return t=t?s.Url(t):void 0,await u.bind(this)("confirm-signup",{username:this.__request_signup_confirmation,redirect:t})}async function ot(t=!1){if("string"==typeof t)s.Url(t);else if("boolean"!=typeof t)throw new e("Argument should be type: <boolean | string>.",{code:"INVALID_REQUEST"});if(!this.__disabledAccount)throw new e("Least one signin attempt of disabled account is required.",{code:"INVALID_REQUEST"});return await u.bind(this)("recover-account",{username:this.__disabledAccount,redirect:t}),this.__disabledAccount=null,"SUCCESS: Recovery e-mail has been sent."}async function at(e){await it.bind(this)();let t=s.Params(e,{username:"string",email:e=>s.Email(e),password:e=>s.Password(e)},["email","password"]);return tt.bind(this)().authenticateUser(t.username||t.email,t.password)}async function ut(t,r){let n=s.Params(t||{},{username:"string",email:e=>s.Email(e),password:e=>s.Password(e),name:"string",address:"string",gender:"string",birthdate:e=>s.Birthdate(e),phone_number:e=>s.PhoneNumber(e),email_public:["boolean",()=>!1],address_public:["boolean",()=>!1],gender_public:["boolean",()=>!1],birthdate_public:["boolean",()=>!1],phone_number_public:["boolean",()=>!1],access_group:"number",misc:"string"},["email","password"]),i=await nt.bind(this)()&&n.service&&this.service!==n.service;if(i)n.owner=this.__user.user_id;else{if(n.access_group)throw new e('Only admins can set "access_group" parameter.',{code:"INVALID_PARAMETER"});await this.logout()}r=s.Params(r||{},{email_subscription:t=>{if("boolean"!=typeof t)throw new e('"option.email_subscription" should be type: <boolean>.',{code:"INVALID_PARAMETER"});if(!r?.signup_confirmation)throw new e('"option.signup_confirmation" is required for email subscription.',{code:"INVALID_PARAMETER"});return t},signup_confirmation:t=>{if("string"==typeof t)return s.Url(t);if("boolean"==typeof t)return t;throw new e('"option.signup_confirmation" should be type: <string | boolean>.',{code:"INVALID_PARAMETER"})},login:t=>{if("boolean"==typeof t){if(r.signup_confirmation&&t)throw new e('"login" is not allowed when "option.signup_confirmation" is true.',{code:"INVALID_PARAMETER"});return t}throw new e('"option.login" should be type: boolean.',{code:"INVALID_PARAMETER"})}});let o=r?.login||!1,a=r?.signup_confirmation||!1;if(i&&a)throw new e('Admins cannot create an account with "option.signup_confirmation" option.',{code:"INVALID_PARAMETER"});if(n.email_public&&!a)throw new e('"option.signup_confirmation" should be true if "email_public" is set to true.',{code:"INVALID_PARAMETER"});if(n.signup_confirmation=a,n.email_subscription=r?.email_subscription||!1,delete n.service,delete n.owner,await u.bind(this)("signup",n),a){let e=await tt.bind(this)().createCognitoUser(n.username||n.email);return Xe=e.cognitoUser,this.__request_signup_confirmation=e.cognitoUsername,"SUCCESS: The account has been created. User's signup confirmation is required."}return o?at.bind(this)({email:n.username||n.email,password:n.password}):"SUCCESS: The account has been created."}async function ct(){await this.__connection;let e=await u.bind(this)("remove-account",{disable:this.__user.user_id},{auth:!0});return await it.bind(this)(),e}async function lt(t){await this.__connection;let r=s.Params(t,{email:e=>s.Email(e),code:["number","string"],new_password:e=>s.Password(e)},["email","code","new_password"]),n=r.code,i=r.new_password;return"number"==typeof n&&(n=n.toString()),new Promise((async(t,s)=>{(await tt.bind(this)().createCognitoUser(r.email)).cognitoUser.confirmPassword(n,i,{onSuccess:e=>{t("SUCCESS: New password has been set.")},onFailure:t=>{s(new e(t?.message||"Failed to reset password.",{code:t?.code}))}})}))}async function ht(t,r){let n;if(await this.__connection,!Xe)throw new e("The user has to be logged in.",{code:"INVALID_REQUEST"});if("email"===t||"phone_number"===t){if(!this.__user.hasOwnProperty(t))throw new e(`No ${"email"===t?"e-mail":"phone number"} to verify`,{code:"INVALID_REQUEST"});return this.__user?.[`${t}_verified`]?`SUCCESS: "${t}" is verified.`:(n=(r?s.Params(r,{code:["string"]}):{}).code||"",new Promise(((r,i)=>{let s={onSuccess:e=>{n?tt.bind(this)().getSession({refreshToken:!0}).then((()=>{this.__user&&(this.__user[t+"_verified"]=!0),r(`SUCCESS: "${t}" is verified.`)})).catch((e=>{i(e)})):r("SUCCESS: Verification code has been sent.")},onFailure:t=>{i(new e(t.message||"Failed to request verification code.",{code:t?.code}))}};n?Xe?.verifyAttribute(t,n,s):(s.inputVerificationCode=null,Xe?.getAttributeVerificationCode(t,s))})))}}function ft(e){return ht.bind(this)("phone_number",e)}function dt(e){return ht.bind(this)("email",e)}async function pt(t){await this.__connection;let r=s.Params(t,{email:e=>s.Email(e)},["email"]);return new Promise((async(t,n)=>{(await tt.bind(this)().createCognitoUser(r.email)).cognitoUser.forgotPassword({onSuccess:e=>{t("SUCCESS: Verification code has been sent.")},onFailure:t=>{n(new e(t?.message||"Failed to send verification code.",{code:t?.code||"ERROR"}))}})}))}async function gt(t){if(await this.__connection,!this.session)throw new e("User login is required.",{code:"INVALID_REQUEST"});let r=s.Params(t,{current_password:"string",new_password:"string"});if(!r?.current_password)throw new e('"current_password" is required to change password.',{code:"INVALID_PARAMETER"});if(!r?.new_password)throw new e('"new_password" is required to change password.',{code:"INVALID_PARAMETER"});return s.Password(r.current_password),s.Password(r.new_password),new Promise(((t,n)=>{Xe.changePassword(r.current_password,r.new_password,((r,i)=>{r&&n("InvalidParameterException"===r?.code?new e("Invalid password parameter.",{code:"INVALID_PARAMETER"}):"NotAuthorizedException"===r?.code?new e("Incorrect password.",{code:"INVALID_REQUEST"}):new e(r?.message||"Failed to change user password.",{code:r?.code||r?.name})),t("SUCCESS: Password has been changed.")}))}))}async function yt(r){if(await this.__connection,!this.session)throw new e("User login is required.",{code:"INVALID_REQUEST"});let n=s.Params(r||{},{email:e=>s.Email(e),address:e=>e?"string"==typeof e?e:"object"==typeof e?JSON.stringify(e):"":"",name:"string",gender:"string",birthdate:e=>s.Birthdate(e),phone_number:e=>s.PhoneNumber(e),email_public:"boolean",phone_number_public:"boolean",address_public:"boolean",gender_public:"boolean",birthdate_public:"boolean",misc:"string"});if(n&&"object"==typeof n&&!Object.keys(n).length)return this.user;n.email&&(n.preferred_username=this.service+"-"+t.hash(n.email));let i=[["email_public","email_verified","User's E-Mail should be verified to set"],["phone_number_public","phone_number_verified","User's phone number should be verified to set"]];if(this.__user)for(let t of i)if(n[t[0]]&&!this.__user[t[1]])throw new e(`${t[2]} "${t[0]}" to true.`,{code:"INVALID_REQUEST"});let o=[];for(let e in n)if(n[e]!==this.user[e]){if(["email_public","phone_number_public","address_public","gender_public","birthdate_public","misc"].includes(e)){let t=n[e];"boolean"==typeof t&&(t=t?"1":"0"),n["custom:"+e]=t,o.push(e)}}else o.push(e);for(let e of o)delete n[e];if(n&&"object"==typeof n&&Object.keys(n).length){let e=[];for(let t in n)e.push(new Ne({Name:t,Value:n[t]}));return await new Promise(((t,r)=>{Xe?.updateAttributes(e,((e,n)=>{e&&r([e?.code||e?.name,e?.message||"Failed to update user settings."]),t(n)}))})),await tt.bind(this)().getSession({refreshToken:!0}),this.user}return this.user}async function wt(t,r){if(t||(t={searchFor:"timestamp",condition:">",value:0},r||(r={}),r.ascending=!1),await nt.bind(this)()&&!t.hasOwnProperty("service"))throw new e("Service ID is required.",{code:"INVALID_PARAMETER"});const n={user_id:e=>s.UserId(e),name:"string",email:e=>s.Email(e),phone_number:e=>s.PhoneNumber(e),address:"string",gender:"string",birthdate:e=>s.Birthdate(e),locale:t=>{if("string"!=typeof t||"string"==typeof t&&t.length>5)throw new e('Value of "locale" should be a country code.',{code:"INVALID_PARAMETER"});return t},timestamp:"number",access_group:"number",approved:e=>e?"by_admin:approved":"by_admin:suspended"};if(t=s.Params(t,{searchFor:["user_id","name","email","phone_number","address","gender","birthdate","locale","subscribers","timestamp","access_group","approved"],condition:[">",">=","=","<","<=","gt","gte","eq","lt","lte",()=>"="],value:r=>{let i=n[t.searchFor];if("function"==typeof i)return i(r);if(typeof r!==i)throw new e(`Value does not match the type of "${t.searchFor}" index.`,{code:"INVALID_PARAMETER"});return r},range:r=>{let i=n[t.searchFor];if("function"==typeof i)return i(r);if(typeof r!==i)throw new e(`Range does not match the type of "${t.searchFor}" index.`,{code:"INVALID_PARAMETER"});return r}},["searchFor","value"]),t?.condition&&"="!==t?.condition&&t.hasOwnProperty("range"))throw new e("Conditions does not apply on range search.",{code:"INVALID_PARAMETER"});if("user_id"===t.searchFor&&"="!==t.condition)throw new e('Conditions are not allowed on "user_id"',{code:"INVALID_PARAMETER"});if("access_group"===t.searchFor&&(t.searchFor="group"),"string"==typeof t?.value&&!t?.value)throw new e("Value should not be an empty string.",{code:"INVALID_PARAMETER"});if("string"==typeof t?.searchFor&&!t?.searchFor)throw new e('"searchFor" should not be an empty string.',{code:"INVALID_PARAMETER"});return u.bind(this)("get-users",t,{auth:!0,fetchOptions:r})}async function mt(e){await this.__connection;let t=await u.bind(this)("last-verified-email",e,{auth:!0});return t.includes("SUCCESS")?(await tt.bind(this)().getSession({refreshToken:!0}),this.user):t}async function bt(e){return await this.__connection,e=s.Params(e,{username:s.Email,redirect:s.Url},["username"]),await u.bind(this)("request-username-change",e,{auth:!0})}var _t=function(e,t,r,n){var i,s=arguments.length,o=s<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,r,n);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(o=(s<3?i(o):s>3?i(t,r,o):i(t,r))||o);return s>3&&o&&Object.defineProperty(t,r,o),o};class At{get user(){return this.__user&&Object.keys(this.__user).length?JSON.parse(JSON.stringify(this.__user)):null}set user(e){}constructor(t,r,n){if(this.version="1.0.0-alpha.11",this.session=null,this.connection=null,this.host="skapi",this.hostDomain="skapi.app",this.target_cdn="d1wrj5ymxrt2ir",this.__disabledAccount=null,this.__cached_requests={},this.__startKeyHistory={},this.__request_signup_confirmation=null,this.__class_properties_has_been_cached=!1,this.__user=null,this.validate={userId(e){try{return s.UserId(e),!0}catch(e){return!1}},url(e){try{return s.Url(e),!0}catch(e){return!1}},phoneNumber(e){try{return s.PhoneNumber(e),!0}catch(e){return!1}},birthdate(e){try{return s.Birthdate(e),!0}catch(e){return!1}},email(e){try{return s.Email(e),!0}catch(e){return!1}}},this.checkAdmin=nt.bind(this),this.request=u.bind(this),this.getSubscribedTo=$.bind(this),this.getSubscribers=q.bind(this),"string"!=typeof t||"string"!=typeof r)throw new e('"service" and "owner" should be type <string>.',{code:"INVALID_PARAMETER"});if(!t||!r)throw new e('"service" and "owner" is required',{code:"INVALID_PARAMETER"});r!==this.host&&s.UserId(r,'"owner"'),this.service=t,this.owner=r;let i="boolean"!=typeof n?.autoLogin||n.autoLogin;const o=`https://${this.target_cdn}.cloudfront.net`;let a=t.substring(0,4);this.admin_endpoint=fetch(`${o}/${a}/admin.json`).then((e=>e.blob())).then((e=>new Promise(((t,r)=>{const n=new FileReader;n.onloadend=()=>t(n.result),n.onerror=r,n.readAsDataURL(e)})))).then((e=>"string"==typeof e?JSON.parse(window.atob(e.split(",")[1])):null)),this.record_endpoint=fetch(`${o}/${a}/record.json`).then((e=>e.blob())).then((e=>new Promise(((t,r)=>{const n=new FileReader;n.onloadend=()=>t(n.result),n.onerror=r,n.readAsDataURL(e)})))).then((e=>"string"==typeof e?JSON.parse(window.atob(e.split(",")[1])):null)),this.__connection=(async()=>{if(!window.sessionStorage)throw new Error("This browser does not support skapi.");const e=JSON.parse(window.sessionStorage.getItem(`${t}#${r}`)||"null");if(e?.connection)for(let t in e)this[t]=e[t];const n=await this.admin_endpoint;var s;s={UserPoolId:n.userpool_id,ClientId:n.userpool_client},et=new Ze(s);const o=[];if(e?.connection||o.push(this.updateConnection()),!e?.connection&&!i){let e=et.getCurrentUser();e&&e.signOut()}let a;(e?.connection||i)&&o.push(tt.bind(this)().getSession({refreshToken:!e?.connection}).catch((e=>{this.__user=null}))),o.length&&(a=await Promise.all(o));const u=()=>{if(this.__class_properties_has_been_cached)return;let e=()=>{let e={};const n=["__startKeyHistory","__cached_requests","__request_signup_confirmation","connection"];if(this.connection){for(let t of n)e[t]=this[t];window.sessionStorage.setItem(`${t}#${r}`,JSON.stringify(e)),this.__class_properties_has_been_cached=!0}};return a instanceof Promise?a.then((()=>e())):e()};return window.addEventListener("beforeunload",u),window.addEventListener("visibilitychange",u),this.connection})()}async updateConnection(){return this.connection=await u.bind(this)("service",{service:this.service,owner:this.owner},{bypassAwaitConnection:!0,method:"get"}),console.log(`Built with:\n%c\r\n $$\\ $$\\ \r\n $$ | \\__|\r\n $$$$$$$\\ $$ | $$\\ $$$$$$\\ $$$$$$\\ $$\\ \r\n$$ _____|$$ | $$ |\\____$$\\ $$ __$$\\ $$ |\r\n\\$$$$$$\\ $$$$$$ / $$$$$$$ |$$ / $$ |$$ |\r\n \\____$$\\ $$ _$$< $$ __$$ |$$ | $$ |$$ |\r\n$$$$$$$ |$$ | \\$$\\\\$$$$$$$ |$$$$$$$ |$$ |\r\n\\_______/ \\__| \\__|\\_______|$$ ____/ \\__|\r\n $$ | \r\n $$ | \r\n \\__| \r\nVersion: ${this.version}\n\nDocumentation: https://docs.skapi.com`,"font-family: monospace; color:blue;"),this.connection}getConnection(){return a.bind(this)()}getProfile(e){return rt.bind(this)(e)}getFile(e,t){return E.bind(this)(e,t)}secureRequest(e){return p.bind(this)(e)}getFormResponse(){return y.bind(this)()}getRecords(e,t){return S.bind(this)(e,t)}getTables(e,t){return T.bind(this)(e,t)}getIndexes(e,t){return R.bind(this)(e,t)}getTags(e,t){return U.bind(this)(e,t)}deleteRecords(e){return D.bind(this)(e)}resendSignupConfirmation(e){return st.bind(this)(e)}recoverAccount(e=!1){return ot.bind(this)(e)}getUsers(e,t){return wt.bind(this)(e,t)}disableAccount(){return ct.bind(this)()}lastVerifiedEmail(e){return mt.bind(this)(e)}getSubscriptions(e,t,r){return F.bind(this)(e,t,r)}unsubscribeNewsletter(e){return H.bind(this)(e)}getNewsletters(e,t){return W.bind(this)(e,t)}getNewsletterSubscription(e){return K.bind(this)(e)}requestUsernameChange(e){return bt.bind(this)(e)}grantPrivateRecordAccess(e){return C.bind(this)(e)}removePrivateRecordAccess(e){return P.bind(this)(e)}listPrivateRecordAccess(e){return N.bind(this)(e)}requestPrivateRecordAccessKey(e){return k.bind(this)(e)}deleteFiles(e){return A.bind(this)(e)}uploadFiles(e,t){return v.bind(this)(e,t)}mock(e,t){return g.bind(this)(e,t)}login(e){return at.bind(this)(e)}logout(){return it.bind(this)()}signup(e,t){return ut.bind(this)(e,t)}resetPassword(e){return lt.bind(this)(e)}verifyEmail(e){return dt.bind(this)(e)}verifyPhoneNumber(e){return ft.bind(this)(e)}forgotPassword(e){return pt.bind(this)(e)}changePassword(e){return gt.bind(this)(e)}updateProfile(e){return yt.bind(this)(e)}postRecord(e,t){return I.bind(this)(e,t)}subscribe(e){return V.bind(this)(e)}unsubscribe(e){return x.bind(this)(e)}blockSubscriber(e){return L.bind(this)(e)}unblockSubscriber(e){return B.bind(this)(e)}subscribeNewsletter(e){return j.bind(this)(e)}}_t([m()],At.prototype,"uploadFiles",null),_t([m()],At.prototype,"mock",null),_t([m({preventMultipleCalls:!0})],At.prototype,"login",null),_t([m()],At.prototype,"logout",null),_t([m({preventMultipleCalls:!0})],At.prototype,"signup",null),_t([m({preventMultipleCalls:!0})],At.prototype,"resetPassword",null),_t([m({preventMultipleCalls:!0})],At.prototype,"verifyEmail",null),_t([m({preventMultipleCalls:!0})],At.prototype,"verifyPhoneNumber",null),_t([m({preventMultipleCalls:!0})],At.prototype,"forgotPassword",null),_t([m({preventMultipleCalls:!0})],At.prototype,"changePassword",null),_t([m({preventMultipleCalls:!0})],At.prototype,"updateProfile",null),_t([m()],At.prototype,"postRecord",null),_t([m()],At.prototype,"subscribe",null),_t([m()],At.prototype,"unsubscribe",null),_t([m()],At.prototype,"blockSubscriber",null),_t([m()],At.prototype,"unblockSubscriber",null),_t([m()],At.prototype,"subscribeNewsletter",null)})(),n})()));
|
|
3
3
|
//# sourceMappingURL=skapi.js.map
|