genesys-cloud-client-auth 1.0.2 → 2.0.0-release.1

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.
@@ -1,2 +0,0 @@
1
- (()=>{"use strict";var e={d:(t,n)=>{for(var r in n)e.o(n,r)&&!e.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:n[r]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{GenesysCloudClientAuthenticator:()=>kt,TimeoutError:()=>l,VERSION:()=>c,authenticatorFactory:()=>Lt,default:()=>Ft,handleRedirectFromLogin:()=>jt,isIssuedTimeWithinTimeframe:()=>p,isIssuedTimeWithinWindow:()=>g,parseOauthParams:()=>f,tokenWasIssuedAt:()=>m});var n={};e.r(n),e.d(n,{hasBrowserEnv:()=>_e,hasStandardBrowserEnv:()=>Ue,hasStandardBrowserWebWorkerEnv:()=>Ce,navigator:()=>Ae,origin:()=>Pe}),Object.create,Object.create,"function"==typeof SuppressedError&&SuppressedError;const r={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};let o;const s=new Uint8Array(16),i=[];for(let e=0;e<256;++e)i.push((e+256).toString(16).slice(1));const a=function(e,t,n){if(r.randomUUID&&!t&&!e)return r.randomUUID();const a=(e=e||{}).random??e.rng?.()??function(){if(!o){if("undefined"==typeof crypto||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");o=crypto.getRandomValues.bind(crypto)}return o(s)}();if(a.length<16)throw new Error("Random bytes length must be >= 16");if(a[6]=15&a[6]|64,a[8]=63&a[8]|128,t){if((n=n||0)<0||n+16>t.length)throw new RangeError(`UUID byte range ${n}:${n+15} is out of buffer bounds`);for(let e=0;e<16;++e)t[n+e]=a[e];return t}return function(e,t=0){return(i[e[t+0]]+i[e[t+1]]+i[e[t+2]]+i[e[t+3]]+"-"+i[e[t+4]]+i[e[t+5]]+"-"+i[e[t+6]]+i[e[t+7]]+"-"+i[e[t+8]]+i[e[t+9]]+"-"+i[e[t+10]]+i[e[t+11]]+i[e[t+12]]+i[e[t+13]]+i[e[t+14]]+i[e[t+15]]).toLowerCase()}(a)},c="1.0.2",u="color: #f29f2c";class l extends Error{constructor(){super(...arguments),this.name="TIMEOUT_ERROR"}}class d extends Error{constructor(e,t){const n=t&&t instanceof Error;super(n?t.message:t),n&&(this.name=t.name),this.translationKey=e}}const f=(e=window.location.hash)=>{const t={},n={},r=new RegExp("^#*(.+?)=(.+?)$","i");if(e.split("&").forEach(e=>{const n=r.exec(e);n&&(t[n[1]]=decodeURIComponent(decodeURIComponent(n[2].replace(/\+/g,"%20"))))}),t.error)return t;if(t.access_token){if(t.state&&(n.state=t.state),t.expires_in){const e=1e3*parseInt(t.expires_in.replace(/\+/g,"%20"));n.tokenExpiryTime=Date.now()+e,n.tokenExpiryTimeString=new Date(n.tokenExpiryTime).toISOString()}n.accessToken=t.access_token.replace(/\+/g,"%20")}return n},h=(e,t)=>{t?(console.log(`%c [DEBUG:gc-client-auth:${c}] ${e}`,u,t),"object"==typeof t&&console.log(`%c [DEBUG:gc-client-auth:${c}] ^ stringified: ${JSON.stringify(t)}`,u)):console.log(`%c [DEBUG:gc-client-auth:${c}] ${e}`,u)},p=(e,t=691199e3,n=168e4,r=Date.now())=>r-m(e,t)<n,g=(e,t,n)=>p(e,t,n),m=(e,t)=>e-t;function b(e,t){return function(){return e.apply(t,arguments)}}const{toString:y}=Object.prototype,{getPrototypeOf:w}=Object,{iterator:E,toStringTag:O}=Symbol,R=(S=Object.create(null),e=>{const t=y.call(e);return S[t]||(S[t]=t.slice(8,-1).toLowerCase())});var S;const v=e=>(e=e.toLowerCase(),t=>R(t)===e),T=e=>t=>typeof t===e,{isArray:_}=Array,A=T("undefined");function U(e){return null!==e&&!A(e)&&null!==e.constructor&&!A(e.constructor)&&x(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const C=v("ArrayBuffer"),P=T("string"),x=T("function"),D=T("number"),N=e=>null!==e&&"object"==typeof e,k=e=>{if("object"!==R(e))return!1;const t=w(e);return!(null!==t&&t!==Object.prototype&&null!==Object.getPrototypeOf(t)||O in e||E in e)},j=v("Date"),I=v("File"),L=v("Blob"),F=v("FileList"),B="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{},M=void 0!==B.FormData?B.FormData:void 0,q=v("URLSearchParams"),[$,z,H,V]=["ReadableStream","Request","Response","Headers"].map(v);function J(e,t,{allOwnKeys:n=!1}={}){if(null==e)return;let r,o;if("object"!=typeof e&&(e=[e]),_(e))for(r=0,o=e.length;r<o;r++)t.call(null,e[r],r,e);else{if(U(e))return;const o=n?Object.getOwnPropertyNames(e):Object.keys(e),s=o.length;let i;for(r=0;r<s;r++)i=o[r],t.call(null,e[i],i,e)}}function W(e,t){if(U(e))return null;t=t.toLowerCase();const n=Object.keys(e);let r,o=n.length;for(;o-- >0;)if(r=n[o],t===r.toLowerCase())return r;return null}const K="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:global,G=e=>!A(e)&&e!==K,X=(Q="undefined"!=typeof Uint8Array&&w(Uint8Array),e=>Q&&e instanceof Q);var Q;const Y=v("HTMLFormElement"),Z=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),ee=v("RegExp"),te=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),r={};J(n,(n,o)=>{let s;!1!==(s=t(n,o,e))&&(r[o]=s||n)}),Object.defineProperties(e,r)},ne=v("AsyncFunction"),re=(oe="function"==typeof setImmediate,se=x(K.postMessage),oe?setImmediate:se?(ie=`axios@${Math.random()}`,ae=[],K.addEventListener("message",({source:e,data:t})=>{e===K&&t===ie&&ae.length&&ae.shift()()},!1),e=>{ae.push(e),K.postMessage(ie,"*")}):e=>setTimeout(e));var oe,se,ie,ae;const ce="undefined"!=typeof queueMicrotask?queueMicrotask.bind(K):"undefined"!=typeof process&&process.nextTick||re,ue={isArray:_,isArrayBuffer:C,isBuffer:U,isFormData:e=>{if(!e)return!1;if(M&&e instanceof M)return!0;const t=w(e);if(!t||t===Object.prototype)return!1;if(!x(e.append))return!1;const n=R(e);return"formdata"===n||"object"===n&&x(e.toString)&&"[object FormData]"===e.toString()},isArrayBufferView:function(e){let t;return t="undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&C(e.buffer),t},isString:P,isNumber:D,isBoolean:e=>!0===e||!1===e,isObject:N,isPlainObject:k,isEmptyObject:e=>{if(!N(e)||U(e))return!1;try{return 0===Object.keys(e).length&&Object.getPrototypeOf(e)===Object.prototype}catch(e){return!1}},isReadableStream:$,isRequest:z,isResponse:H,isHeaders:V,isUndefined:A,isDate:j,isFile:I,isReactNativeBlob:e=>!(!e||void 0===e.uri),isReactNative:e=>e&&void 0!==e.getParts,isBlob:L,isRegExp:ee,isFunction:x,isStream:e=>N(e)&&x(e.pipe),isURLSearchParams:q,isTypedArray:X,isFileList:F,forEach:J,merge:function e(){const{caseless:t,skipUndefined:n}=G(this)&&this||{},r={},o=(o,s)=>{if("__proto__"===s||"constructor"===s||"prototype"===s)return;const i=t&&W(r,s)||s;k(r[i])&&k(o)?r[i]=e(r[i],o):k(o)?r[i]=e({},o):_(o)?r[i]=o.slice():n&&A(o)||(r[i]=o)};for(let e=0,t=arguments.length;e<t;e++)arguments[e]&&J(arguments[e],o);return r},extend:(e,t,n,{allOwnKeys:r}={})=>(J(t,(t,r)=>{n&&x(t)?Object.defineProperty(e,r,{value:b(t,n),writable:!0,enumerable:!0,configurable:!0}):Object.defineProperty(e,r,{value:t,writable:!0,enumerable:!0,configurable:!0})},{allOwnKeys:r}),e),trim:e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,""),stripBOM:e=>(65279===e.charCodeAt(0)&&(e=e.slice(1)),e),inherits:(e,t,n,r)=>{e.prototype=Object.create(t.prototype,r),Object.defineProperty(e.prototype,"constructor",{value:e,writable:!0,enumerable:!1,configurable:!0}),Object.defineProperty(e,"super",{value:t.prototype}),n&&Object.assign(e.prototype,n)},toFlatObject:(e,t,n,r)=>{let o,s,i;const a={};if(t=t||{},null==e)return t;do{for(o=Object.getOwnPropertyNames(e),s=o.length;s-- >0;)i=o[s],r&&!r(i,e,t)||a[i]||(t[i]=e[i],a[i]=!0);e=!1!==n&&w(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},kindOf:R,kindOfTest:v,endsWith:(e,t,n)=>{e=String(e),(void 0===n||n>e.length)&&(n=e.length),n-=t.length;const r=e.indexOf(t,n);return-1!==r&&r===n},toArray:e=>{if(!e)return null;if(_(e))return e;let t=e.length;if(!D(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},forEachEntry:(e,t)=>{const n=(e&&e[E]).call(e);let r;for(;(r=n.next())&&!r.done;){const n=r.value;t.call(e,n[0],n[1])}},matchAll:(e,t)=>{let n;const r=[];for(;null!==(n=e.exec(t));)r.push(n);return r},isHTMLForm:Y,hasOwnProperty:Z,hasOwnProp:Z,reduceDescriptors:te,freezeMethods:e=>{te(e,(t,n)=>{if(x(e)&&-1!==["arguments","caller","callee"].indexOf(n))return!1;const r=e[n];x(r)&&(t.enumerable=!1,"writable"in t?t.writable=!1:t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+n+"'")}))})},toObjectSet:(e,t)=>{const n={},r=e=>{e.forEach(e=>{n[e]=!0})};return _(e)?r(e):r(String(e).split(t)),n},toCamelCase:e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(e,t,n){return t.toUpperCase()+n}),noop:()=>{},toFiniteNumber:(e,t)=>null!=e&&Number.isFinite(e=+e)?e:t,findKey:W,global:K,isContextDefined:G,isSpecCompliantForm:function(e){return!!(e&&x(e.append)&&"FormData"===e[O]&&e[E])},toJSONObject:e=>{const t=new Array(10),n=(e,r)=>{if(N(e)){if(t.indexOf(e)>=0)return;if(U(e))return e;if(!("toJSON"in e)){t[r]=e;const o=_(e)?[]:{};return J(e,(e,t)=>{const s=n(e,r+1);!A(s)&&(o[t]=s)}),t[r]=void 0,o}}return e};return n(e,0)},isAsyncFn:ne,isThenable:e=>e&&(N(e)||x(e))&&x(e.then)&&x(e.catch),setImmediate:re,asap:ce,isIterable:e=>null!=e&&x(e[E])};class le extends Error{static from(e,t,n,r,o,s){const i=new le(e.message,t||e.code,n,r,o);return i.cause=e,i.name=e.name,null!=e.status&&null==i.status&&(i.status=e.status),s&&Object.assign(i,s),i}constructor(e,t,n,r,o){super(e),Object.defineProperty(this,"message",{value:e,enumerable:!0,writable:!0,configurable:!0}),this.name="AxiosError",this.isAxiosError=!0,t&&(this.code=t),n&&(this.config=n),r&&(this.request=r),o&&(this.response=o,this.status=o.status)}toJSON(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:ue.toJSONObject(this.config),code:this.code,status:this.status}}}le.ERR_BAD_OPTION_VALUE="ERR_BAD_OPTION_VALUE",le.ERR_BAD_OPTION="ERR_BAD_OPTION",le.ECONNABORTED="ECONNABORTED",le.ETIMEDOUT="ETIMEDOUT",le.ERR_NETWORK="ERR_NETWORK",le.ERR_FR_TOO_MANY_REDIRECTS="ERR_FR_TOO_MANY_REDIRECTS",le.ERR_DEPRECATED="ERR_DEPRECATED",le.ERR_BAD_RESPONSE="ERR_BAD_RESPONSE",le.ERR_BAD_REQUEST="ERR_BAD_REQUEST",le.ERR_CANCELED="ERR_CANCELED",le.ERR_NOT_SUPPORT="ERR_NOT_SUPPORT",le.ERR_INVALID_URL="ERR_INVALID_URL",le.ERR_FORM_DATA_DEPTH_EXCEEDED="ERR_FORM_DATA_DEPTH_EXCEEDED";const de=le;function fe(e){return ue.isPlainObject(e)||ue.isArray(e)}function he(e){return ue.endsWith(e,"[]")?e.slice(0,-2):e}function pe(e,t,n){return e?e.concat(t).map(function(e,t){return e=he(e),!n&&t?"["+e+"]":e}).join(n?".":""):t}const ge=ue.toFlatObject(ue,{},null,function(e){return/^is[A-Z]/.test(e)}),me=function(e,t,n){if(!ue.isObject(e))throw new TypeError("target must be an object");t=t||new FormData;const r=(n=ue.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(e,t){return!ue.isUndefined(t[e])})).metaTokens,o=n.visitor||d,s=n.dots,i=n.indexes,a=n.Blob||"undefined"!=typeof Blob&&Blob,c=void 0===n.maxDepth?100:n.maxDepth,u=a&&ue.isSpecCompliantForm(t);if(!ue.isFunction(o))throw new TypeError("visitor must be a function");function l(e){if(null===e)return"";if(ue.isDate(e))return e.toISOString();if(ue.isBoolean(e))return e.toString();if(!u&&ue.isBlob(e))throw new de("Blob is not supported. Use a Buffer instead.");return ue.isArrayBuffer(e)||ue.isTypedArray(e)?u&&"function"==typeof Blob?new Blob([e]):Buffer.from(e):e}function d(e,n,o){let a=e;if(ue.isReactNative(t)&&ue.isReactNativeBlob(e))return t.append(pe(o,n,s),l(e)),!1;if(e&&!o&&"object"==typeof e)if(ue.endsWith(n,"{}"))n=r?n:n.slice(0,-2),e=JSON.stringify(e);else if(ue.isArray(e)&&function(e){return ue.isArray(e)&&!e.some(fe)}(e)||(ue.isFileList(e)||ue.endsWith(n,"[]"))&&(a=ue.toArray(e)))return n=he(n),a.forEach(function(e,r){!ue.isUndefined(e)&&null!==e&&t.append(!0===i?pe([n],r,s):null===i?n:n+"[]",l(e))}),!1;return!!fe(e)||(t.append(pe(o,n,s),l(e)),!1)}const f=[],h=Object.assign(ge,{defaultVisitor:d,convertValue:l,isVisitable:fe});if(!ue.isObject(e))throw new TypeError("data must be an object");return function e(n,r,s=0){if(!ue.isUndefined(n)){if(s>c)throw new de("Object is too deeply nested ("+s+" levels). Max depth: "+c,de.ERR_FORM_DATA_DEPTH_EXCEEDED);if(-1!==f.indexOf(n))throw Error("Circular reference detected in "+r.join("."));f.push(n),ue.forEach(n,function(n,i){!0===(!(ue.isUndefined(n)||null===n)&&o.call(t,n,ue.isString(i)?i.trim():i,r,h))&&e(n,r?r.concat(i):[i],s+1)}),f.pop()}}(e),t};function be(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+"};return encodeURIComponent(e).replace(/[!'()~]|%20/g,function(e){return t[e]})}function ye(e,t){this._pairs=[],e&&me(e,this,t)}const we=ye.prototype;we.append=function(e,t){this._pairs.push([e,t])},we.toString=function(e){const t=e?function(t){return e.call(this,t,be)}:be;return this._pairs.map(function(e){return t(e[0])+"="+t(e[1])},"").join("&")};const Ee=ye;function Oe(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function Re(e,t,n){if(!t)return e;const r=n&&n.encode||Oe,o=ue.isFunction(n)?{serialize:n}:n,s=o&&o.serialize;let i;if(i=s?s(t,o):ue.isURLSearchParams(t)?t.toString():new Ee(t,o).toString(r),i){const t=e.indexOf("#");-1!==t&&(e=e.slice(0,t)),e+=(-1===e.indexOf("?")?"?":"&")+i}return e}const Se=class{constructor(){this.handlers=[]}use(e,t,n){return this.handlers.push({fulfilled:e,rejected:t,synchronous:!!n&&n.synchronous,runWhen:n?n.runWhen:null}),this.handlers.length-1}eject(e){this.handlers[e]&&(this.handlers[e]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(e){ue.forEach(this.handlers,function(t){null!==t&&e(t)})}},ve={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1,legacyInterceptorReqResOrdering:!0},Te={isBrowser:!0,classes:{URLSearchParams:"undefined"!=typeof URLSearchParams?URLSearchParams:Ee,FormData:"undefined"!=typeof FormData?FormData:null,Blob:"undefined"!=typeof Blob?Blob:null},protocols:["http","https","file","blob","url","data"]},_e="undefined"!=typeof window&&"undefined"!=typeof document,Ae="object"==typeof navigator&&navigator||void 0,Ue=_e&&(!Ae||["ReactNative","NativeScript","NS"].indexOf(Ae.product)<0),Ce="undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope&&"function"==typeof self.importScripts,Pe=_e&&window.location.href||"http://localhost",xe={...n,...Te},De=function(e){function t(e,n,r,o){let s=e[o++];if("__proto__"===s)return!0;const i=Number.isFinite(+s),a=o>=e.length;return s=!s&&ue.isArray(r)?r.length:s,a?(ue.hasOwnProp(r,s)?r[s]=ue.isArray(r[s])?r[s].concat(n):[r[s],n]:r[s]=n,!i):(r[s]&&ue.isObject(r[s])||(r[s]=[]),t(e,n,r[s],o)&&ue.isArray(r[s])&&(r[s]=function(e){const t={},n=Object.keys(e);let r;const o=n.length;let s;for(r=0;r<o;r++)s=n[r],t[s]=e[s];return t}(r[s])),!i)}if(ue.isFormData(e)&&ue.isFunction(e.entries)){const n={};return ue.forEachEntry(e,(e,r)=>{t(function(e){return ue.matchAll(/\w+|\[(\w*)]/g,e).map(e=>"[]"===e[0]?"":e[1]||e[0])}(e),r,n,0)}),n}return null},Ne=(e,t)=>null!=e&&ue.hasOwnProp(e,t)?e[t]:void 0,ke={transitional:ve,adapter:["xhr","http","fetch"],transformRequest:[function(e,t){const n=t.getContentType()||"",r=n.indexOf("application/json")>-1,o=ue.isObject(e);if(o&&ue.isHTMLForm(e)&&(e=new FormData(e)),ue.isFormData(e))return r?JSON.stringify(De(e)):e;if(ue.isArrayBuffer(e)||ue.isBuffer(e)||ue.isStream(e)||ue.isFile(e)||ue.isBlob(e)||ue.isReadableStream(e))return e;if(ue.isArrayBufferView(e))return e.buffer;if(ue.isURLSearchParams(e))return t.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),e.toString();let s;if(o){const t=Ne(this,"formSerializer");if(n.indexOf("application/x-www-form-urlencoded")>-1)return function(e,t){return me(e,new xe.classes.URLSearchParams,{visitor:function(e,t,n,r){return xe.isNode&&ue.isBuffer(e)?(this.append(t,e.toString("base64")),!1):r.defaultVisitor.apply(this,arguments)},...t})}(e,t).toString();if((s=ue.isFileList(e))||n.indexOf("multipart/form-data")>-1){const n=Ne(this,"env"),r=n&&n.FormData;return me(s?{"files[]":e}:e,r&&new r,t)}}return o||r?(t.setContentType("application/json",!1),function(e){if(ue.isString(e))try{return(0,JSON.parse)(e),ue.trim(e)}catch(e){if("SyntaxError"!==e.name)throw e}return(0,JSON.stringify)(e)}(e)):e}],transformResponse:[function(e){const t=Ne(this,"transitional")||ke.transitional,n=t&&t.forcedJSONParsing,r=Ne(this,"responseType"),o="json"===r;if(ue.isResponse(e)||ue.isReadableStream(e))return e;if(e&&ue.isString(e)&&(n&&!r||o)){const n=!(t&&t.silentJSONParsing)&&o;try{return JSON.parse(e,Ne(this,"parseReviver"))}catch(e){if(n){if("SyntaxError"===e.name)throw de.from(e,de.ERR_BAD_RESPONSE,this,null,Ne(this,"response"));throw e}}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:xe.classes.FormData,Blob:xe.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};ue.forEach(["delete","get","head","post","put","patch"],e=>{ke.headers[e]={}});const je=ke,Ie=ue.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),Le=Symbol("internals"),Fe=/[^\x09\x20-\x7E\x80-\xFF]/g;function Be(e){return e&&String(e).trim().toLowerCase()}function Me(e){return!1===e||null==e?e:ue.isArray(e)?e.map(Me):function(e){let t=0,n=e.length;for(;t<n;){const n=e.charCodeAt(t);if(9!==n&&32!==n)break;t+=1}for(;n>t;){const t=e.charCodeAt(n-1);if(9!==t&&32!==t)break;n-=1}return 0===t&&n===e.length?e:e.slice(t,n)}(String(e).replace(Fe,""))}function qe(e,t,n,r,o){return ue.isFunction(r)?r.call(this,t,n):(o&&(t=n),ue.isString(t)?ue.isString(r)?-1!==t.indexOf(r):ue.isRegExp(r)?r.test(t):void 0:void 0)}class $e{constructor(e){e&&this.set(e)}set(e,t,n){const r=this;function o(e,t,n){const o=Be(t);if(!o)throw new Error("header name must be a non-empty string");const s=ue.findKey(r,o);(!s||void 0===r[s]||!0===n||void 0===n&&!1!==r[s])&&(r[s||t]=Me(e))}const s=(e,t)=>ue.forEach(e,(e,n)=>o(e,n,t));if(ue.isPlainObject(e)||e instanceof this.constructor)s(e,t);else if(ue.isString(e)&&(e=e.trim())&&!/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim()))s((e=>{const t={};let n,r,o;return e&&e.split("\n").forEach(function(e){o=e.indexOf(":"),n=e.substring(0,o).trim().toLowerCase(),r=e.substring(o+1).trim(),!n||t[n]&&Ie[n]||("set-cookie"===n?t[n]?t[n].push(r):t[n]=[r]:t[n]=t[n]?t[n]+", "+r:r)}),t})(e),t);else if(ue.isObject(e)&&ue.isIterable(e)){let n,r,o={};for(const t of e){if(!ue.isArray(t))throw TypeError("Object iterator must return a key-value pair");o[r=t[0]]=(n=o[r])?ue.isArray(n)?[...n,t[1]]:[n,t[1]]:t[1]}s(o,t)}else null!=e&&o(t,e,n);return this}get(e,t){if(e=Be(e)){const n=ue.findKey(this,e);if(n){const e=this[n];if(!t)return e;if(!0===t)return function(e){const t=Object.create(null),n=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let r;for(;r=n.exec(e);)t[r[1]]=r[2];return t}(e);if(ue.isFunction(t))return t.call(this,e,n);if(ue.isRegExp(t))return t.exec(e);throw new TypeError("parser must be boolean|regexp|function")}}}has(e,t){if(e=Be(e)){const n=ue.findKey(this,e);return!(!n||void 0===this[n]||t&&!qe(0,this[n],n,t))}return!1}delete(e,t){const n=this;let r=!1;function o(e){if(e=Be(e)){const o=ue.findKey(n,e);!o||t&&!qe(0,n[o],o,t)||(delete n[o],r=!0)}}return ue.isArray(e)?e.forEach(o):o(e),r}clear(e){const t=Object.keys(this);let n=t.length,r=!1;for(;n--;){const o=t[n];e&&!qe(0,this[o],o,e,!0)||(delete this[o],r=!0)}return r}normalize(e){const t=this,n={};return ue.forEach(this,(r,o)=>{const s=ue.findKey(n,o);if(s)return t[s]=Me(r),void delete t[o];const i=e?function(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(e,t,n)=>t.toUpperCase()+n)}(o):String(o).trim();i!==o&&delete t[o],t[i]=Me(r),n[i]=!0}),this}concat(...e){return this.constructor.concat(this,...e)}toJSON(e){const t=Object.create(null);return ue.forEach(this,(n,r)=>{null!=n&&!1!==n&&(t[r]=e&&ue.isArray(n)?n.join(", "):n)}),t}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([e,t])=>e+": "+t).join("\n")}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(e){return e instanceof this?e:new this(e)}static concat(e,...t){const n=new this(e);return t.forEach(e=>n.set(e)),n}static accessor(e){const t=(this[Le]=this[Le]={accessors:{}}).accessors,n=this.prototype;function r(e){const r=Be(e);t[r]||(function(e,t){const n=ue.toCamelCase(" "+t);["get","set","has"].forEach(r=>{Object.defineProperty(e,r+n,{value:function(e,n,o){return this[r].call(this,t,e,n,o)},configurable:!0})})}(n,e),t[r]=!0)}return ue.isArray(e)?e.forEach(r):r(e),this}}$e.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),ue.reduceDescriptors($e.prototype,({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(e){this[n]=e}}}),ue.freezeMethods($e);const ze=$e;function He(e,t){const n=this||je,r=t||n,o=ze.from(r.headers);let s=r.data;return ue.forEach(e,function(e){s=e.call(n,s,o.normalize(),t?t.status:void 0)}),o.normalize(),s}function Ve(e){return!(!e||!e.__CANCEL__)}const Je=class extends de{constructor(e,t,n){super(null==e?"canceled":e,de.ERR_CANCELED,t,n),this.name="CanceledError",this.__CANCEL__=!0}};function We(e,t,n){const r=n.config.validateStatus;n.status&&r&&!r(n.status)?t(new de("Request failed with status code "+n.status,[de.ERR_BAD_REQUEST,de.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n)):e(n)}const Ke=(e,t,n=3)=>{let r=0;const o=function(e,t){e=e||10;const n=new Array(e),r=new Array(e);let o,s=0,i=0;return t=void 0!==t?t:1e3,function(a){const c=Date.now(),u=r[i];o||(o=c),n[s]=a,r[s]=c;let l=i,d=0;for(;l!==s;)d+=n[l++],l%=e;if(s=(s+1)%e,s===i&&(i=(i+1)%e),c-o<t)return;const f=u&&c-u;return f?Math.round(1e3*d/f):void 0}}(50,250);return function(e,t){let n,r,o=0,s=1e3/t;const i=(t,s=Date.now())=>{o=s,n=null,r&&(clearTimeout(r),r=null),e(...t)};return[(...e)=>{const t=Date.now(),a=t-o;a>=s?i(e,t):(n=e,r||(r=setTimeout(()=>{r=null,i(n)},s-a)))},()=>n&&i(n)]}(n=>{const s=n.loaded,i=n.lengthComputable?n.total:void 0,a=null!=i?Math.min(s,i):s,c=Math.max(0,a-r),u=o(c);r=Math.max(r,a),e({loaded:a,total:i,progress:i?a/i:void 0,bytes:c,rate:u||void 0,estimated:u&&i?(i-a)/u:void 0,event:n,lengthComputable:null!=i,[t?"download":"upload"]:!0})},n)},Ge=(e,t)=>{const n=null!=e;return[r=>t[0]({lengthComputable:n,total:e,loaded:r}),t[1]]},Xe=e=>(...t)=>ue.asap(()=>e(...t)),Qe=xe.hasStandardBrowserEnv?((e,t)=>n=>(n=new URL(n,xe.origin),e.protocol===n.protocol&&e.host===n.host&&(t||e.port===n.port)))(new URL(xe.origin),xe.navigator&&/(msie|trident)/i.test(xe.navigator.userAgent)):()=>!0,Ye=xe.hasStandardBrowserEnv?{write(e,t,n,r,o,s,i){if("undefined"==typeof document)return;const a=[`${e}=${encodeURIComponent(t)}`];ue.isNumber(n)&&a.push(`expires=${new Date(n).toUTCString()}`),ue.isString(r)&&a.push(`path=${r}`),ue.isString(o)&&a.push(`domain=${o}`),!0===s&&a.push("secure"),ue.isString(i)&&a.push(`SameSite=${i}`),document.cookie=a.join("; ")},read(e){if("undefined"==typeof document)return null;const t=document.cookie.match(new RegExp("(?:^|; )"+e+"=([^;]*)"));return t?decodeURIComponent(t[1]):null},remove(e){this.write(e,"",Date.now()-864e5,"/")}}:{write(){},read:()=>null,remove(){}};function Ze(e,t,n){let r=!("string"==typeof(o=t)&&/^([a-z][a-z\d+\-.]*:)?\/\//i.test(o));var o;return e&&(r||!1===n)?function(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}(e,t):t}const et=e=>e instanceof ze?{...e}:e;function tt(e,t){t=t||{};const n=Object.create(null);function r(e,t,n,r){return ue.isPlainObject(e)&&ue.isPlainObject(t)?ue.merge.call({caseless:r},e,t):ue.isPlainObject(t)?ue.merge({},t):ue.isArray(t)?t.slice():t}function o(e,t,n,o){return ue.isUndefined(t)?ue.isUndefined(e)?void 0:r(void 0,e,0,o):r(e,t,0,o)}function s(e,t){if(!ue.isUndefined(t))return r(void 0,t)}function i(e,t){return ue.isUndefined(t)?ue.isUndefined(e)?void 0:r(void 0,e):r(void 0,t)}function a(n,o,s){return ue.hasOwnProp(t,s)?r(n,o):ue.hasOwnProp(e,s)?r(void 0,n):void 0}Object.defineProperty(n,"hasOwnProperty",{value:Object.prototype.hasOwnProperty,enumerable:!1,writable:!0,configurable:!0});const c={url:s,method:s,data:s,baseURL:i,transformRequest:i,transformResponse:i,paramsSerializer:i,timeout:i,timeoutMessage:i,withCredentials:i,withXSRFToken:i,adapter:i,responseType:i,xsrfCookieName:i,xsrfHeaderName:i,onUploadProgress:i,onDownloadProgress:i,decompress:i,maxContentLength:i,maxBodyLength:i,beforeRedirect:i,transport:i,httpAgent:i,httpsAgent:i,cancelToken:i,socketPath:i,allowedSocketPaths:i,responseEncoding:i,validateStatus:a,headers:(e,t,n)=>o(et(e),et(t),0,!0)};return ue.forEach(Object.keys({...e,...t}),function(r){if("__proto__"===r||"constructor"===r||"prototype"===r)return;const s=ue.hasOwnProp(c,r)?c[r]:o,i=s(ue.hasOwnProp(e,r)?e[r]:void 0,ue.hasOwnProp(t,r)?t[r]:void 0,r);ue.isUndefined(i)&&s!==a||(n[r]=i)}),n}const nt=e=>{const t=tt({},e),n=e=>ue.hasOwnProp(t,e)?t[e]:void 0,r=n("data");let o=n("withXSRFToken");const s=n("xsrfHeaderName"),i=n("xsrfCookieName");let a=n("headers");const c=n("auth"),u=n("baseURL"),l=n("allowAbsoluteUrls"),d=n("url");if(t.headers=a=ze.from(a),t.url=Re(Ze(u,d,l),e.params,e.paramsSerializer),c&&a.set("Authorization","Basic "+btoa((c.username||"")+":"+(c.password?unescape(encodeURIComponent(c.password)):""))),ue.isFormData(r))if(xe.hasStandardBrowserEnv||xe.hasStandardBrowserWebWorkerEnv)a.setContentType(void 0);else if(ue.isFunction(r.getHeaders)){const e=r.getHeaders(),t=["content-type","content-length"];Object.entries(e).forEach(([e,n])=>{t.includes(e.toLowerCase())&&a.set(e,n)})}if(xe.hasStandardBrowserEnv&&(ue.isFunction(o)&&(o=o(t)),!0===o||null==o&&Qe(t.url))){const e=s&&i&&Ye.read(i);e&&a.set(s,e)}return t},rt="undefined"!=typeof XMLHttpRequest&&function(e){return new Promise(function(t,n){const r=nt(e);let o=r.data;const s=ze.from(r.headers).normalize();let i,a,c,u,l,{responseType:d,onUploadProgress:f,onDownloadProgress:h}=r;function p(){u&&u(),l&&l(),r.cancelToken&&r.cancelToken.unsubscribe(i),r.signal&&r.signal.removeEventListener("abort",i)}let g=new XMLHttpRequest;function m(){if(!g)return;const r=ze.from("getAllResponseHeaders"in g&&g.getAllResponseHeaders());We(function(e){t(e),p()},function(e){n(e),p()},{data:d&&"text"!==d&&"json"!==d?g.response:g.responseText,status:g.status,statusText:g.statusText,headers:r,config:e,request:g}),g=null}g.open(r.method.toUpperCase(),r.url,!0),g.timeout=r.timeout,"onloadend"in g?g.onloadend=m:g.onreadystatechange=function(){g&&4===g.readyState&&(0!==g.status||g.responseURL&&0===g.responseURL.indexOf("file:"))&&setTimeout(m)},g.onabort=function(){g&&(n(new de("Request aborted",de.ECONNABORTED,e,g)),g=null)},g.onerror=function(t){const r=t&&t.message?t.message:"Network Error",o=new de(r,de.ERR_NETWORK,e,g);o.event=t||null,n(o),g=null},g.ontimeout=function(){let t=r.timeout?"timeout of "+r.timeout+"ms exceeded":"timeout exceeded";const o=r.transitional||ve;r.timeoutErrorMessage&&(t=r.timeoutErrorMessage),n(new de(t,o.clarifyTimeoutError?de.ETIMEDOUT:de.ECONNABORTED,e,g)),g=null},void 0===o&&s.setContentType(null),"setRequestHeader"in g&&ue.forEach(s.toJSON(),function(e,t){g.setRequestHeader(t,e)}),ue.isUndefined(r.withCredentials)||(g.withCredentials=!!r.withCredentials),d&&"json"!==d&&(g.responseType=r.responseType),h&&([c,l]=Ke(h,!0),g.addEventListener("progress",c)),f&&g.upload&&([a,u]=Ke(f),g.upload.addEventListener("progress",a),g.upload.addEventListener("loadend",u)),(r.cancelToken||r.signal)&&(i=t=>{g&&(n(!t||t.type?new Je(null,e,g):t),g.abort(),g=null)},r.cancelToken&&r.cancelToken.subscribe(i),r.signal&&(r.signal.aborted?i():r.signal.addEventListener("abort",i)));const b=function(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}(r.url);b&&-1===xe.protocols.indexOf(b)?n(new de("Unsupported protocol "+b+":",de.ERR_BAD_REQUEST,e)):g.send(o||null)})},ot=(e,t)=>{const{length:n}=e=e?e.filter(Boolean):[];if(t||n){let n,r=new AbortController;const o=function(e){if(!n){n=!0,i();const t=e instanceof Error?e:this.reason;r.abort(t instanceof de?t:new Je(t instanceof Error?t.message:t))}};let s=t&&setTimeout(()=>{s=null,o(new de(`timeout of ${t}ms exceeded`,de.ETIMEDOUT))},t);const i=()=>{e&&(s&&clearTimeout(s),s=null,e.forEach(e=>{e.unsubscribe?e.unsubscribe(o):e.removeEventListener("abort",o)}),e=null)};e.forEach(e=>e.addEventListener("abort",o));const{signal:a}=r;return a.unsubscribe=()=>ue.asap(i),a}},st=function*(e,t){let n=e.byteLength;if(!t||n<t)return void(yield e);let r,o=0;for(;o<n;)r=o+t,yield e.slice(o,r),o=r},it=(e,t,n,r)=>{const o=async function*(e,t){for await(const n of async function*(e){if(e[Symbol.asyncIterator])return void(yield*e);const t=e.getReader();try{for(;;){const{done:e,value:n}=await t.read();if(e)break;yield n}}finally{await t.cancel()}}(e))yield*st(n,t)}(e,t);let s,i=0,a=e=>{s||(s=!0,r&&r(e))};return new ReadableStream({async pull(e){try{const{done:t,value:r}=await o.next();if(t)return a(),void e.close();let s=r.byteLength;if(n){let e=i+=s;n(e)}e.enqueue(new Uint8Array(r))}catch(e){throw a(e),e}},cancel:e=>(a(e),o.return())},{highWaterMark:2})},{isFunction:at}=ue,ct=(({Request:e,Response:t})=>({Request:e,Response:t}))(ue.global),{ReadableStream:ut,TextEncoder:lt}=ue.global,dt=(e,...t)=>{try{return!!e(...t)}catch(e){return!1}},ft=e=>{e=ue.merge.call({skipUndefined:!0},ct,e);const{fetch:t,Request:n,Response:r}=e,o=t?at(t):"function"==typeof fetch,s=at(n),i=at(r);if(!o)return!1;const a=o&&at(ut),c=o&&("function"==typeof lt?(u=new lt,e=>u.encode(e)):async e=>new Uint8Array(await new n(e).arrayBuffer()));var u;const l=s&&a&&dt(()=>{let e=!1;const t=new n(xe.origin,{body:new ut,method:"POST",get duplex(){return e=!0,"half"}}),r=t.headers.has("Content-Type");return null!=t.body&&t.body.cancel(),e&&!r}),d=i&&a&&dt(()=>ue.isReadableStream(new r("").body)),f={stream:d&&(e=>e.body)};o&&["text","arrayBuffer","blob","formData","stream"].forEach(e=>{!f[e]&&(f[e]=(t,n)=>{let r=t&&t[e];if(r)return r.call(t);throw new de(`Response type '${e}' is not supported`,de.ERR_NOT_SUPPORT,n)})});return async e=>{let{url:o,method:i,data:a,signal:u,cancelToken:h,timeout:p,onDownloadProgress:g,onUploadProgress:m,responseType:b,headers:y,withCredentials:w="same-origin",fetchOptions:E}=nt(e),O=t||fetch;b=b?(b+"").toLowerCase():"text";let R=ot([u,h&&h.toAbortSignal()],p),S=null;const v=R&&R.unsubscribe&&(()=>{R.unsubscribe()});let T;try{if(m&&l&&"get"!==i&&"head"!==i&&0!==(T=await(async(e,t)=>{const r=ue.toFiniteNumber(e.getContentLength());return null==r?(async e=>{if(null==e)return 0;if(ue.isBlob(e))return e.size;if(ue.isSpecCompliantForm(e)){const t=new n(xe.origin,{method:"POST",body:e});return(await t.arrayBuffer()).byteLength}return ue.isArrayBufferView(e)||ue.isArrayBuffer(e)?e.byteLength:(ue.isURLSearchParams(e)&&(e+=""),ue.isString(e)?(await c(e)).byteLength:void 0)})(t):r})(y,a))){let e,t=new n(o,{method:"POST",body:a,duplex:"half"});if(ue.isFormData(a)&&(e=t.headers.get("content-type"))&&y.setContentType(e),t.body){const[e,n]=Ge(T,Ke(Xe(m)));a=it(t.body,65536,e,n)}}ue.isString(w)||(w=w?"include":"omit");const t=s&&"credentials"in n.prototype;if(ue.isFormData(a)){const e=y.getContentType();e&&/^multipart\/form-data/i.test(e)&&!/boundary=/i.test(e)&&y.delete("content-type")}const u={...E,signal:R,method:i.toUpperCase(),headers:y.normalize().toJSON(),body:a,duplex:"half",credentials:t?w:void 0};S=s&&new n(o,u);let h=await(s?O(S,E):O(o,u));const p=d&&("stream"===b||"response"===b);if(d&&(g||p&&v)){const e={};["status","statusText","headers"].forEach(t=>{e[t]=h[t]});const t=ue.toFiniteNumber(h.headers.get("content-length")),[n,o]=g&&Ge(t,Ke(Xe(g),!0))||[];h=new r(it(h.body,65536,n,()=>{o&&o(),v&&v()}),e)}b=b||"text";let _=await f[ue.findKey(f,b)||"text"](h,e);return!p&&v&&v(),await new Promise((t,n)=>{We(t,n,{data:_,headers:ze.from(h.headers),status:h.status,statusText:h.statusText,config:e,request:S})})}catch(t){if(v&&v(),t&&"TypeError"===t.name&&/Load failed|fetch/i.test(t.message))throw Object.assign(new de("Network Error",de.ERR_NETWORK,e,S,t&&t.response),{cause:t.cause||t});throw de.from(t,t&&t.code,e,S,t&&t.response)}}},ht=new Map,pt=e=>{let t=e&&e.env||{};const{fetch:n,Request:r,Response:o}=t,s=[r,o,n];let i,a,c=s.length,u=ht;for(;c--;)i=s[c],a=u.get(i),void 0===a&&u.set(i,a=c?new Map:ft(t)),u=a;return a},gt=(pt(),{http:null,xhr:rt,fetch:{get:pt}});ue.forEach(gt,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch(e){}Object.defineProperty(e,"adapterName",{value:t})}});const mt=e=>`- ${e}`,bt=e=>ue.isFunction(e)||null===e||!1===e,yt=function(e,t){e=ue.isArray(e)?e:[e];const{length:n}=e;let r,o;const s={};for(let i=0;i<n;i++){let n;if(r=e[i],o=r,!bt(r)&&(o=gt[(n=String(r)).toLowerCase()],void 0===o))throw new de(`Unknown adapter '${n}'`);if(o&&(ue.isFunction(o)||(o=o.get(t))))break;s[n||"#"+i]=o}if(!o){const e=Object.entries(s).map(([e,t])=>`adapter ${e} `+(!1===t?"is not supported by the environment":"is not available in the build"));let t=n?e.length>1?"since :\n"+e.map(mt).join("\n"):" "+mt(e[0]):"as no adapter specified";throw new de("There is no suitable adapter to dispatch the request "+t,"ERR_NOT_SUPPORT")}return o};function wt(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new Je(null,e)}function Et(e){return wt(e),e.headers=ze.from(e.headers),e.data=He.call(e,e.transformRequest),-1!==["post","put","patch"].indexOf(e.method)&&e.headers.setContentType("application/x-www-form-urlencoded",!1),yt(e.adapter||je.adapter,e)(e).then(function(t){return wt(e),t.data=He.call(e,e.transformResponse,t),t.headers=ze.from(t.headers),t},function(t){return Ve(t)||(wt(e),t&&t.response&&(t.response.data=He.call(e,e.transformResponse,t.response),t.response.headers=ze.from(t.response.headers))),Promise.reject(t)})}const Ot="1.15.2",Rt={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{Rt[e]=function(n){return typeof n===e||"a"+(t<1?"n ":" ")+e}});const St={};Rt.transitional=function(e,t,n){function r(e,t){return"[Axios v"+Ot+"] Transitional option '"+e+"'"+t+(n?". "+n:"")}return(n,o,s)=>{if(!1===e)throw new de(r(o," has been removed"+(t?" in "+t:"")),de.ERR_DEPRECATED);return t&&!St[o]&&(St[o]=!0,console.warn(r(o," has been deprecated since v"+t+" and will be removed in the near future"))),!e||e(n,o,s)}},Rt.spelling=function(e){return(t,n)=>(console.warn(`${n} is likely a misspelling of ${e}`),!0)};const vt={assertOptions:function(e,t,n){if("object"!=typeof e)throw new de("options must be an object",de.ERR_BAD_OPTION_VALUE);const r=Object.keys(e);let o=r.length;for(;o-- >0;){const s=r[o],i=Object.prototype.hasOwnProperty.call(t,s)?t[s]:void 0;if(i){const t=e[s],n=void 0===t||i(t,s,e);if(!0!==n)throw new de("option "+s+" must be "+n,de.ERR_BAD_OPTION_VALUE);continue}if(!0!==n)throw new de("Unknown option "+s,de.ERR_BAD_OPTION)}},validators:Rt},Tt=vt.validators;class _t{constructor(e){this.defaults=e||{},this.interceptors={request:new Se,response:new Se}}async request(e,t){try{return await this._request(e,t)}catch(e){if(e instanceof Error){let t={};Error.captureStackTrace?Error.captureStackTrace(t):t=new Error;const n=(()=>{if(!t.stack)return"";const e=t.stack.indexOf("\n");return-1===e?"":t.stack.slice(e+1)})();try{if(e.stack){if(n){const t=n.indexOf("\n"),r=-1===t?-1:n.indexOf("\n",t+1),o=-1===r?"":n.slice(r+1);String(e.stack).endsWith(o)||(e.stack+="\n"+n)}}else e.stack=n}catch(e){}}throw e}}_request(e,t){"string"==typeof e?(t=t||{}).url=e:t=e||{},t=tt(this.defaults,t);const{transitional:n,paramsSerializer:r,headers:o}=t;void 0!==n&&vt.assertOptions(n,{silentJSONParsing:Tt.transitional(Tt.boolean),forcedJSONParsing:Tt.transitional(Tt.boolean),clarifyTimeoutError:Tt.transitional(Tt.boolean),legacyInterceptorReqResOrdering:Tt.transitional(Tt.boolean)},!1),null!=r&&(ue.isFunction(r)?t.paramsSerializer={serialize:r}:vt.assertOptions(r,{encode:Tt.function,serialize:Tt.function},!0)),void 0!==t.allowAbsoluteUrls||(void 0!==this.defaults.allowAbsoluteUrls?t.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:t.allowAbsoluteUrls=!0),vt.assertOptions(t,{baseUrl:Tt.spelling("baseURL"),withXsrfToken:Tt.spelling("withXSRFToken")},!0),t.method=(t.method||this.defaults.method||"get").toLowerCase();let s=o&&ue.merge(o.common,o[t.method]);o&&ue.forEach(["delete","get","head","post","put","patch","common"],e=>{delete o[e]}),t.headers=ze.concat(s,o);const i=[];let a=!0;this.interceptors.request.forEach(function(e){if("function"==typeof e.runWhen&&!1===e.runWhen(t))return;a=a&&e.synchronous;const n=t.transitional||ve;n&&n.legacyInterceptorReqResOrdering?i.unshift(e.fulfilled,e.rejected):i.push(e.fulfilled,e.rejected)});const c=[];let u;this.interceptors.response.forEach(function(e){c.push(e.fulfilled,e.rejected)});let l,d=0;if(!a){const e=[Et.bind(this),void 0];for(e.unshift(...i),e.push(...c),l=e.length,u=Promise.resolve(t);d<l;)u=u.then(e[d++],e[d++]);return u}l=i.length;let f=t;for(;d<l;){const e=i[d++],t=i[d++];try{f=e(f)}catch(e){t.call(this,e);break}}try{u=Et.call(this,f)}catch(e){return Promise.reject(e)}for(d=0,l=c.length;d<l;)u=u.then(c[d++],c[d++]);return u}getUri(e){return Re(Ze((e=tt(this.defaults,e)).baseURL,e.url,e.allowAbsoluteUrls),e.params,e.paramsSerializer)}}ue.forEach(["delete","get","head","options"],function(e){_t.prototype[e]=function(t,n){return this.request(tt(n||{},{method:e,url:t,data:(n||{}).data}))}}),ue.forEach(["post","put","patch"],function(e){function t(t){return function(n,r,o){return this.request(tt(o||{},{method:e,headers:t?{"Content-Type":"multipart/form-data"}:{},url:n,data:r}))}}_t.prototype[e]=t(),_t.prototype[e+"Form"]=t(!0)});const At=_t;class Ut{constructor(e){if("function"!=typeof e)throw new TypeError("executor must be a function.");let t;this.promise=new Promise(function(e){t=e});const n=this;this.promise.then(e=>{if(!n._listeners)return;let t=n._listeners.length;for(;t-- >0;)n._listeners[t](e);n._listeners=null}),this.promise.then=e=>{let t;const r=new Promise(e=>{n.subscribe(e),t=e}).then(e);return r.cancel=function(){n.unsubscribe(t)},r},e(function(e,r,o){n.reason||(n.reason=new Je(e,r,o),t(n.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(e){this.reason?e(this.reason):this._listeners?this._listeners.push(e):this._listeners=[e]}unsubscribe(e){if(!this._listeners)return;const t=this._listeners.indexOf(e);-1!==t&&this._listeners.splice(t,1)}toAbortSignal(){const e=new AbortController,t=t=>{e.abort(t)};return this.subscribe(t),e.signal.unsubscribe=()=>this.unsubscribe(t),e.signal}static source(){let e;return{token:new Ut(function(t){e=t}),cancel:e}}}const Ct=Ut,Pt={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511,WebServerIsDown:521,ConnectionTimedOut:522,OriginIsUnreachable:523,TimeoutOccurred:524,SslHandshakeFailed:525,InvalidSslCertificate:526};Object.entries(Pt).forEach(([e,t])=>{Pt[t]=e});const xt=Pt,Dt=function e(t){const n=new At(t),r=b(At.prototype.request,n);return ue.extend(r,At.prototype,n,{allOwnKeys:!0}),ue.extend(r,n,null,{allOwnKeys:!0}),r.create=function(n){return e(tt(t,n))},r}(je);Dt.Axios=At,Dt.CanceledError=Je,Dt.CancelToken=Ct,Dt.isCancel=Ve,Dt.VERSION=Ot,Dt.toFormData=me,Dt.AxiosError=de,Dt.Cancel=Dt.CanceledError,Dt.all=function(e){return Promise.all(e)},Dt.spread=function(e){return function(t){return e.apply(null,t)}},Dt.isAxiosError=function(e){return ue.isObject(e)&&!0===e.isAxiosError},Dt.mergeConfig=tt,Dt.AxiosHeaders=ze,Dt.formToJSON=e=>De(ue.isHTMLForm(e)?new FormData(e):e),Dt.getAdapter=yt,Dt.HttpStatusCode=xt,Dt.default=Dt;const Nt=Dt;class kt{constructor(e,t={}){this.VERSION=c,this.clientId=e,t.storageKey||(t.storageKey="gc_client_auth_data"),"boolean"!=typeof t.persist&&(t.persist=!1),this.config=Object.assign({},t),this.customHeaders=t.customHeaders,this.setEnvironment(t.environment),this.timeout=16e3,this.authData={},this.authentications={"PureCloud OAuth":{type:"oauth2"}};try{localStorage.setItem("genesys_cloud_local_storage_test","genesys_cloud_local_storage_test"),localStorage.removeItem("genesys_cloud_local_storage_test"),this.hasLocalStorage=!0}catch(e){this.hasLocalStorage=!1}this._loadSettings()}loginImplicitGrant(e={},t){const n=t||f();return new Promise((t,r)=>{e.org&&!e.provider?r(new Error("opts.provider must be set if opts.org is set")):e.provider&&!e.org?r(new Error("opts.org must be set if opts.provider is set")):e.redirectUri||e.usePopupAuth||r(new Error("redirectUri must be provided for implicit grant and not utilizing client-auth app for popup auth")),n&&n.error&&(n.accessToken=void 0,this._saveSettings(n),r(new Error(`[${n.error}] ${n.error_description}`))),n.accessToken&&this._saveSettings(n),this._testTokenAccess().then(()=>(!this.authData.state&&e.state&&(this.authData.state=e.state),t(this.authData))).catch(n=>{this._debug("Error encountered during login. This is normal if the application has not yet been authorized.",n);const o={client_id:encodeURIComponent(this.clientId),response_type:"token"};if(e.redirectUri&&(o.redirect_uri=encodeURIComponent(e.redirectUri)),e.state&&(o.state=encodeURIComponent(e.state)),e.org&&(o.org=encodeURIComponent(e.org)),e.provider&&(o.provider=encodeURIComponent(e.provider)),e.usePopupAuth){if(!this.hasLocalStorage)return r(new Error("localStorage is unavailable. Cannot authenticate via popup window."));this._debug("using popup auth – adding listener"),this._authenticateViaPopup(o,e.popupTimeout||15e3).then(e=>{this._saveSettings(e),t(e)}).catch(r)}else{const e=this._buildAuthUrl("oauth/authorize",o);this._debug("Implicit grant: redirecting to: "+e),window.location.replace(e),r(new Error(`Routing to login: "${e}"`))}})})}setEnvironment(e){e||(e="mypurecloud.com"),(e=e.replace(/\/+$/,"")).startsWith("https://")&&(e=e.substring(8)),e.startsWith("http://")&&(e=e.substring(7)),e.startsWith("api.")&&(e=e.substring(4)),this.environment=e,this.basePath=`https://api.${e}`,this.authUrl=`https://login.${e}`}clearAuthData(){this._saveSettings({accessToken:void 0,state:void 0,tokenExpiryTime:void 0,tokenExpiryTimeString:void 0})}logout(e){this.clearAuthData();const t={client_id:encodeURIComponent(this.clientId)};e&&(t.redirect_uri=encodeURIComponent(e));const n=this._buildAuthUrl("logout",t);window.location.replace(n)}setAccessToken(e){this._saveSettings({accessToken:e})}testAccessToken(e){return this.callApi("/api/v2/tokens/me","get",e)}parseDate(e){return new Date(e.replace(/T/i," "))}paramToString(e){return e?e instanceof Date?e.toJSON():e.toString():""}buildUrl(e,t={}){return e.match(/^\//)||(e=`/${e}`),(this.basePath+e).replace(/\{([\w-]+)\}/g,(e,n)=>{let r;return r=Object.getOwnPropertyDescriptor(t,n)?this.paramToString(t[n]):e,encodeURIComponent(r)})}callApi(e,t,n){var r;const o=this.buildUrl(e),s={Authorization:`Bearer ${n||(null===(r=this.authData)||void 0===r?void 0:r.accessToken)}`,"Content-Type":"application/json"};this.customHeaders&&Object.entries(this.customHeaders).forEach(([e,t])=>{s[e]=t});const i={method:t,url:o,headers:s,timeout:this.timeout};return Nt.request(i)}_debug(e,t){this.config.debugMode&&h(e,t)}_saveSettings(e){try{if(this.authData.accessToken=e.accessToken,this.authentications["PureCloud OAuth"].accessToken=e.accessToken,e.state&&(this.authData.state=e.state),this.authData.error=e.error,this.authData.error_description=e.error_description,e.tokenExpiryTime&&(this.authData.tokenExpiryTime=e.tokenExpiryTime,this.authData.tokenExpiryTimeString=e.tokenExpiryTimeString),!this.config.persist)return void this._debug("persist is not true. Settings will not be saved.");if(!this.hasLocalStorage)return void this._debug("Warning: Cannot access local storage. Settings will not be saved.");const t=JSON.parse(JSON.stringify(this.authData));delete t.state,localStorage.setItem(this.config.storageKey,JSON.stringify(t)),this._debug("Auth data saved to local storage",t)}catch(e){console.error(e)}}_getId(e){return`gc-ca_${e=e||a()}`}_authenticateViaPopup(e,t){const n=this._getId(),r=Object.assign(Object.assign({},e),{storageKey:this.config.storageKey});this.config.debugMode&&(r.debug=!0),localStorage.setItem(n,JSON.stringify(r)),e.state=n,e.redirect_uri||(e.redirect_uri=encodeURIComponent(`https://apps.${this.environment}/client-auth`));const o=this._buildAuthUrl("oauth/authorize",e);return new Promise((r,s)=>{this._debug("Implicit grant: opening new window: "+o),window.open(o,"_blank","width=500px,height=500px,noreferrer,noopener,resizable,scrollbars,status");const i=setTimeout(()=>{this._debug("timeout for loginImplicitGrant using popup",e);const t=new l("Popup authentation timeout. It is possible that the popup was blocked or the login page encountered an error");s(t)},t),a=e=>{if(this._debug("value was just written to storage by another app",{key:e.key,newValue:e.newValue,oldValue:e.oldValue}),e.key===this.config.storageKey){this._debug("keys matched. resolving value",{key:e.key,value:e.newValue}),window.removeEventListener("storage",a),clearTimeout(i);const t=JSON.parse(e.newValue);localStorage.removeItem(n),r(t)}};window.addEventListener("storage",a)})}_testTokenAccess(){return e=this,t=void 0,r=function*(){if(this._loadSettings(),!this.authentications["PureCloud OAuth"].accessToken)throw new d("errorTokenNotSet","No access token provided.");try{yield this.callApi("/api/v2/tokens/me","get")}catch(e){throw this._saveSettings({accessToken:void 0}),e}},new((n=void 0)||(n=Promise))(function(o,s){function i(e){try{c(r.next(e))}catch(e){s(e)}}function a(e){try{c(r.throw(e))}catch(e){s(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(i,a)}c((r=r.apply(e,t||[])).next())});var e,t,n,r}_loadSettings(){if(!this.config.persist)return;if(!this.hasLocalStorage)return void this._debug("Warning: Cannot access local storage. Settings will not be loaded.");const e=this.authData.state,t=localStorage.getItem(this.config.storageKey);this.authData=t?JSON.parse(t):{},this.authData.accessToken&&this.setAccessToken(this.authData.accessToken),this.authData.state=e}_buildAuthUrl(e,t={}){return Object.keys(t).reduce((e,n)=>t[n]?`${e}&${n}=${t[n]}`:e,`${this.authUrl}/${e}?`)}}const jt=()=>{const e=f();if(e.error)throw new Error(`[${e.error}]: ${e.error_description}`);if(!e.accessToken)throw new d("errorToken","No access token provided.");const t=e.state;if(!t)throw new d("errorStateParam","No state param on redirect. Unable to determine location to save auth data.");const n=JSON.parse(localStorage.getItem(t)||"false");if(!n||!n.storageKey)throw new d("errorParse","Unable to parse information from localStorage.");n.state?e.state=n.state:delete e.state,h(`setting auth data to key: ${n.storageKey}`,e),localStorage.setItem(n.storageKey,JSON.stringify(e)),n.debug?h("In debug mode. Not closing window or removing storageId",{storageId:t,authData:e,href:window.location.href}):(h(`removing temp storage key: ${t}`),localStorage.removeItem(t),h("closing window"),window.close())},It=new Map,Lt=(e,t)=>{let n=It.get(e);return n||(n=new kt(e,t),It.set(e,n)),n},Ft=Lt;window.GenesysCloudClientAuth=t})();
2
- //# sourceMappingURL=genesys-cloud-client-auth.browser.min.js.map