seatable-html-page-sdk 0.0.2 → 0.0.3

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/index.js CHANGED
@@ -1,3 +1,4314 @@
1
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).HTMLPageSDK=t()}(this,function(){"use strict";function e(e,t,n,r,o,s,i){try{var a=e[s](i),u=a.value}catch(e){return void n(e)}a.done?t(u):Promise.resolve(u).then(r,o)}function t(t){return function(){var n=this,r=arguments;return new Promise(function(o,s){var i=t.apply(n,r);function a(t){e(i,o,s,a,u,"next",t)}function u(t){e(i,o,s,a,u,"throw",t)}a(void 0)})}}function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function r(e){return r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},r(e)}function o(e){var t=function(e,t){if("object"!=r(e)||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var o=n.call(e,t||"default");if("object"!=r(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==r(t)?t:t+""}function s(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,o(r.key),r)}}function i(e,t,n){return t&&s(e.prototype,t),n&&s(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function a(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var u,c={exports:{}},l={exports:{}};function f(){return u||(u=1,function(e){e.exports=function(e,t){this.v=e,this.k=t},e.exports.__esModule=!0,e.exports.default=e.exports}(l)),l.exports}var p,d,h={exports:{}},y={exports:{}};function m(){return p||(p=1,function(e){function t(n,r,o,s){var i=Object.defineProperty;try{i({},"",{})}catch(n){i=0}e.exports=t=function(e,n,r,o){function s(n,r){t(e,n,function(e){return this._invoke(n,r,e)})}n?i?i(e,n,{value:r,enumerable:!o,configurable:!o,writable:!o}):e[n]=r:(s("next",0),s("throw",1),s("return",2))},e.exports.__esModule=!0,e.exports.default=e.exports,t(n,r,o,s)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports}(y)),y.exports}function b(){return d||(d=1,function(e){var t=m();function n(){
2
- /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */
3
- var r,o,s="function"==typeof Symbol?Symbol:{},i=s.iterator||"@@iterator",a=s.toStringTag||"@@toStringTag";function u(e,n,s,i){var a=n&&n.prototype instanceof l?n:l,u=Object.create(a.prototype);return t(u,"_invoke",function(e,t,n){var s,i,a,u=0,l=n||[],f=!1,p={p:0,n:0,v:r,a:d,f:d.bind(r,4),d:function(e,t){return s=e,i=0,a=r,p.n=t,c}};function d(e,t){for(i=e,a=t,o=0;!f&&u&&!n&&o<l.length;o++){var n,s=l[o],d=p.p,h=s[2];e>3?(n=h===t)&&(a=s[(i=s[4])?5:(i=3,3)],s[4]=s[5]=r):s[0]<=d&&((n=e<2&&d<s[1])?(i=0,p.v=t,p.n=s[1]):d<h&&(n=e<3||s[0]>t||t>h)&&(s[4]=e,s[5]=t,p.n=h,i=0))}if(n||e>1)return c;throw f=!0,t}return function(n,l,h){if(u>1)throw TypeError("Generator is already running");for(f&&1===l&&d(l,h),i=l,a=h;(o=i<2?r:a)||!f;){s||(i?i<3?(i>1&&(p.n=-1),d(i,a)):p.n=a:p.v=a);try{if(u=2,s){if(i||(n="next"),o=s[n]){if(!(o=o.call(s,a)))throw TypeError("iterator result is not an object");if(!o.done)return o;a=o.value,i<2&&(i=0)}else 1===i&&(o=s.return)&&o.call(s),i<2&&(a=TypeError("The iterator does not provide a '"+n+"' method"),i=1);s=r}else if((o=(f=p.n<0)?a:e.call(t,p))!==c)break}catch(e){s=r,i=1,a=e}finally{u=1}}return{value:o,done:f}}}(e,s,i),!0),u}var c={};function l(){}function f(){}function p(){}o=Object.getPrototypeOf;var d=[][i]?o(o([][i]())):(t(o={},i,function(){return this}),o),h=p.prototype=l.prototype=Object.create(d);function y(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,p):(e.__proto__=p,t(e,a,"GeneratorFunction")),e.prototype=Object.create(h),e}return f.prototype=p,t(h,"constructor",p),t(p,"constructor",f),f.displayName="GeneratorFunction",t(p,a,"GeneratorFunction"),t(h),t(h,a,"Generator"),t(h,i,function(){return this}),t(h,"toString",function(){return"[object Generator]"}),(e.exports=n=function(){return{w:u,m:y}},e.exports.__esModule=!0,e.exports.default=e.exports)()}e.exports=n,e.exports.__esModule=!0,e.exports.default=e.exports}(h)),h.exports}var v,g,w,E={exports:{}},O={exports:{}},x={exports:{}};function R(){return v||(v=1,function(e){var t=f(),n=m();e.exports=function e(r,o){function s(e,n,i,a){try{var u=r[e](n),c=u.value;return c instanceof t?o.resolve(c.v).then(function(e){s("next",e,i,a)},function(e){s("throw",e,i,a)}):o.resolve(c).then(function(e){u.value=e,i(u)},function(e){return s("throw",e,i,a)})}catch(e){a(e)}}var i;this.next||(n(e.prototype),n(e.prototype,"function"==typeof Symbol&&Symbol.asyncIterator||"@asyncIterator",function(){return this})),n(this,"_invoke",function(e,t,n){function r(){return new o(function(t,r){s(e,n,t,r)})}return i=i?i.then(r,r):r()},!0)},e.exports.__esModule=!0,e.exports.default=e.exports}(x)),x.exports}function S(){return g||(g=1,function(e){var t=b(),n=R();e.exports=function(e,r,o,s,i){return new n(t().w(e,r,o,s),i||Promise)},e.exports.__esModule=!0,e.exports.default=e.exports}(O)),O.exports}function T(){return w||(w=1,function(e){var t=S();e.exports=function(e,n,r,o,s){var i=t(e,n,r,o,s);return i.next().then(function(e){return e.done?e.value:i.next()})},e.exports.__esModule=!0,e.exports.default=e.exports}(E)),E.exports}var _,A={exports:{}};function k(){return _||(_=1,function(e){e.exports=function(e){var t=Object(e),n=[];for(var r in t)n.unshift(r);return function e(){for(;n.length;)if((r=n.pop())in t)return e.value=r,e.done=!1,e;return e.done=!0,e}},e.exports.__esModule=!0,e.exports.default=e.exports}(A)),A.exports}var j,P,N,U,C,L={exports:{}},F={exports:{}};function D(){return j||(j=1,function(e){function t(n){return e.exports=t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e.exports.__esModule=!0,e.exports.default=e.exports,t(n)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports}(F)),F.exports}function q(){return P||(P=1,function(e){var t=D().default;e.exports=function(e){if(null!=e){var n=e["function"==typeof Symbol&&Symbol.iterator||"@@iterator"],r=0;if(n)return n.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length))return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}}}throw new TypeError(t(e)+" is not iterable")},e.exports.__esModule=!0,e.exports.default=e.exports}(L)),L.exports}var B=function(){if(C)return U;C=1;var e=(N||(N=1,function(e){var t=f(),n=b(),r=T(),o=S(),s=R(),i=k(),a=q();function u(){var c=n(),l=c.m(u),f=(Object.getPrototypeOf?Object.getPrototypeOf(l):l.__proto__).constructor;function p(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===f||"GeneratorFunction"===(t.displayName||t.name))}var d={throw:1,return:2,break:3,continue:3};function h(e){var t,n;return function(r){t||(t={stop:function(){return n(r.a,2)},catch:function(){return r.v},abrupt:function(e,t){return n(r.a,d[e],t)},delegateYield:function(e,o,s){return t.resultName=o,n(r.d,a(e),s)},finish:function(e){return n(r.f,e)}},n=function(e,n,o){r.p=t.prev,r.n=t.next;try{return e(n,o)}finally{t.next=r.n}}),t.resultName&&(t[t.resultName]=r.v,t.resultName=void 0),t.sent=r.v,t.next=r.n;try{return e.call(this,t)}finally{r.p=t.prev,r.n=t.next}}}return(e.exports=u=function(){return{wrap:function(e,t,n,r){return c.w(h(e),t,n,r&&r.reverse())},isGeneratorFunction:p,mark:c.m,awrap:function(e,n){return new t(e,n)},AsyncIterator:s,async:function(e,t,n,s,i){return(p(t)?o:r)(h(e),t,n,s,i)},keys:i,values:a}},e.exports.__esModule=!0,e.exports.default=e.exports)()}e.exports=u,e.exports.__esModule=!0,e.exports.default=e.exports}(c)),c.exports)();U=e;try{regeneratorRuntime=e}catch(t){"object"==typeof globalThis?globalThis.regeneratorRuntime=e:Function("r","regeneratorRuntime = r")(e)}return U}(),M=a(B);function I(e,t){return function(){return e.apply(t,arguments)}}const{toString:K}=Object.prototype,{getPrototypeOf:H}=Object,{iterator:z,toStringTag:W}=Symbol,J=(V=Object.create(null),e=>{const t=K.call(e);return V[t]||(V[t]=t.slice(8,-1).toLowerCase())});var V;const G=e=>(e=e.toLowerCase(),t=>J(t)===e),X=e=>t=>typeof t===e,{isArray:$}=Array,Y=X("undefined");function Q(e){return null!==e&&!Y(e)&&null!==e.constructor&&!Y(e.constructor)&&te(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const Z=G("ArrayBuffer");const ee=X("string"),te=X("function"),ne=X("number"),re=e=>null!==e&&"object"==typeof e,oe=e=>{if("object"!==J(e))return!1;const t=H(e);return!(null!==t&&t!==Object.prototype&&null!==Object.getPrototypeOf(t)||W in e||z in e)},se=G("Date"),ie=G("File"),ae=G("Blob"),ue=G("FileList"),ce=G("URLSearchParams"),[le,fe,pe,de]=["ReadableStream","Request","Response","Headers"].map(G);function he(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(Q(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 ye(e,t){if(Q(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 me="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:global,be=e=>!Y(e)&&e!==me;const ve=(ge="undefined"!=typeof Uint8Array&&H(Uint8Array),e=>ge&&e instanceof ge);var ge;const we=G("HTMLFormElement"),Ee=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),Oe=G("RegExp"),xe=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),r={};he(n,(n,o)=>{let s;!1!==(s=t(n,o,e))&&(r[o]=s||n)}),Object.defineProperties(e,r)};const Re=G("AsyncFunction"),Se=(Te="function"==typeof setImmediate,_e=te(me.postMessage),Te?setImmediate:_e?(Ae=`axios@${Math.random()}`,ke=[],me.addEventListener("message",({source:e,data:t})=>{e===me&&t===Ae&&ke.length&&ke.shift()()},!1),e=>{ke.push(e),me.postMessage(Ae,"*")}):e=>setTimeout(e));var Te,_e,Ae,ke;const je="undefined"!=typeof queueMicrotask?queueMicrotask.bind(me):"undefined"!=typeof process&&process.nextTick||Se;var Pe={isArray:$,isArrayBuffer:Z,isBuffer:Q,isFormData:e=>{let t;return e&&("function"==typeof FormData&&e instanceof FormData||te(e.append)&&("formdata"===(t=J(e))||"object"===t&&te(e.toString)&&"[object FormData]"===e.toString()))},isArrayBufferView:function(e){let t;return t="undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&Z(e.buffer),t},isString:ee,isNumber:ne,isBoolean:e=>!0===e||!1===e,isObject:re,isPlainObject:oe,isEmptyObject:e=>{if(!re(e)||Q(e))return!1;try{return 0===Object.keys(e).length&&Object.getPrototypeOf(e)===Object.prototype}catch(e){return!1}},isReadableStream:le,isRequest:fe,isResponse:pe,isHeaders:de,isUndefined:Y,isDate:se,isFile:ie,isBlob:ae,isRegExp:Oe,isFunction:te,isStream:e=>re(e)&&te(e.pipe),isURLSearchParams:ce,isTypedArray:ve,isFileList:ue,forEach:he,merge:function e(){const{caseless:t,skipUndefined:n}=be(this)&&this||{},r={},o=(o,s)=>{const i=t&&ye(r,s)||s;oe(r[i])&&oe(o)?r[i]=e(r[i],o):oe(o)?r[i]=e({},o):$(o)?r[i]=o.slice():n&&Y(o)||(r[i]=o)};for(let e=0,t=arguments.length;e<t;e++)arguments[e]&&he(arguments[e],o);return r},extend:(e,t,n,{allOwnKeys:r}={})=>(he(t,(t,r)=>{n&&te(t)?e[r]=I(t,n):e[r]=t},{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),e.prototype.constructor=e,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&&H(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},kindOf:J,kindOfTest:G,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(!ne(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},forEachEntry:(e,t)=>{const n=(e&&e[z]).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:we,hasOwnProperty:Ee,hasOwnProp:Ee,reduceDescriptors:xe,freezeMethods:e=>{xe(e,(t,n)=>{if(te(e)&&-1!==["arguments","caller","callee"].indexOf(n))return!1;const r=e[n];te(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:ye,global:me,isContextDefined:be,isSpecCompliantForm:function(e){return!!(e&&te(e.append)&&"FormData"===e[W]&&e[z])},toJSONObject:e=>{const t=new Array(10),n=(e,r)=>{if(re(e)){if(t.indexOf(e)>=0)return;if(Q(e))return e;if(!("toJSON"in e)){t[r]=e;const o=$(e)?[]:{};return he(e,(e,t)=>{const s=n(e,r+1);!Y(s)&&(o[t]=s)}),t[r]=void 0,o}}return e};return n(e,0)},isAsyncFn:Re,isThenable:e=>e&&(re(e)||te(e))&&te(e.then)&&te(e.catch),setImmediate:Se,asap:je,isIterable:e=>null!=e&&te(e[z])};function Ne(e,t,n,r,o){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=(new Error).stack,this.message=e,this.name="AxiosError",t&&(this.code=t),n&&(this.config=n),r&&(this.request=r),o&&(this.response=o,this.status=o.status?o.status:null)}Pe.inherits(Ne,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:Pe.toJSONObject(this.config),code:this.code,status:this.status}}});const Ue=Ne.prototype,Ce={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(e=>{Ce[e]={value:e}}),Object.defineProperties(Ne,Ce),Object.defineProperty(Ue,"isAxiosError",{value:!0}),Ne.from=(e,t,n,r,o,s)=>{const i=Object.create(Ue);Pe.toFlatObject(e,i,function(e){return e!==Error.prototype},e=>"isAxiosError"!==e);const a=e&&e.message?e.message:"Error",u=null==t&&e?e.code:t;return Ne.call(i,a,u,n,r,o),e&&null==i.cause&&Object.defineProperty(i,"cause",{value:e,configurable:!0}),i.name=e&&e.name||"Error",s&&Object.assign(i,s),i};function Le(e){return Pe.isPlainObject(e)||Pe.isArray(e)}function Fe(e){return Pe.endsWith(e,"[]")?e.slice(0,-2):e}function De(e,t,n){return e?e.concat(t).map(function(e,t){return e=Fe(e),!n&&t?"["+e+"]":e}).join(n?".":""):t}const qe=Pe.toFlatObject(Pe,{},null,function(e){return/^is[A-Z]/.test(e)});function Be(e,t,n){if(!Pe.isObject(e))throw new TypeError("target must be an object");t=t||new FormData;const r=(n=Pe.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(e,t){return!Pe.isUndefined(t[e])})).metaTokens,o=n.visitor||c,s=n.dots,i=n.indexes,a=(n.Blob||"undefined"!=typeof Blob&&Blob)&&Pe.isSpecCompliantForm(t);if(!Pe.isFunction(o))throw new TypeError("visitor must be a function");function u(e){if(null===e)return"";if(Pe.isDate(e))return e.toISOString();if(Pe.isBoolean(e))return e.toString();if(!a&&Pe.isBlob(e))throw new Ne("Blob is not supported. Use a Buffer instead.");return Pe.isArrayBuffer(e)||Pe.isTypedArray(e)?a&&"function"==typeof Blob?new Blob([e]):Buffer.from(e):e}function c(e,n,o){let a=e;if(e&&!o&&"object"==typeof e)if(Pe.endsWith(n,"{}"))n=r?n:n.slice(0,-2),e=JSON.stringify(e);else if(Pe.isArray(e)&&function(e){return Pe.isArray(e)&&!e.some(Le)}(e)||(Pe.isFileList(e)||Pe.endsWith(n,"[]"))&&(a=Pe.toArray(e)))return n=Fe(n),a.forEach(function(e,r){!Pe.isUndefined(e)&&null!==e&&t.append(!0===i?De([n],r,s):null===i?n:n+"[]",u(e))}),!1;return!!Le(e)||(t.append(De(o,n,s),u(e)),!1)}const l=[],f=Object.assign(qe,{defaultVisitor:c,convertValue:u,isVisitable:Le});if(!Pe.isObject(e))throw new TypeError("data must be an object");return function e(n,r){if(!Pe.isUndefined(n)){if(-1!==l.indexOf(n))throw Error("Circular reference detected in "+r.join("."));l.push(n),Pe.forEach(n,function(n,s){!0===(!(Pe.isUndefined(n)||null===n)&&o.call(t,n,Pe.isString(s)?s.trim():s,r,f))&&e(n,r?r.concat(s):[s])}),l.pop()}}(e),t}function Me(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(e){return t[e]})}function Ie(e,t){this._pairs=[],e&&Be(e,this,t)}const Ke=Ie.prototype;function He(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function ze(e,t,n){if(!t)return e;const r=n&&n.encode||He;Pe.isFunction(n)&&(n={serialize:n});const o=n&&n.serialize;let s;if(s=o?o(t,n):Pe.isURLSearchParams(t)?t.toString():new Ie(t,n).toString(r),s){const t=e.indexOf("#");-1!==t&&(e=e.slice(0,t)),e+=(-1===e.indexOf("?")?"?":"&")+s}return e}Ke.append=function(e,t){this._pairs.push([e,t])},Ke.toString=function(e){const t=e?function(t){return e.call(this,t,Me)}:Me;return this._pairs.map(function(e){return t(e[0])+"="+t(e[1])},"").join("&")};var We=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){Pe.forEach(this.handlers,function(t){null!==t&&e(t)})}},Je={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},Ve={isBrowser:!0,classes:{URLSearchParams:"undefined"!=typeof URLSearchParams?URLSearchParams:Ie,FormData:"undefined"!=typeof FormData?FormData:null,Blob:"undefined"!=typeof Blob?Blob:null},protocols:["http","https","file","blob","url","data"]};const Ge="undefined"!=typeof window&&"undefined"!=typeof document,Xe="object"==typeof navigator&&navigator||void 0,$e=Ge&&(!Xe||["ReactNative","NativeScript","NS"].indexOf(Xe.product)<0),Ye="undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope&&"function"==typeof self.importScripts,Qe=Ge&&window.location.href||"http://localhost";var Ze={...Object.freeze({__proto__:null,hasBrowserEnv:Ge,hasStandardBrowserWebWorkerEnv:Ye,hasStandardBrowserEnv:$e,navigator:Xe,origin:Qe}),...Ve};function et(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;if(s=!s&&Pe.isArray(r)?r.length:s,a)return Pe.hasOwnProp(r,s)?r[s]=[r[s],n]:r[s]=n,!i;r[s]&&Pe.isObject(r[s])||(r[s]=[]);return t(e,n,r[s],o)&&Pe.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(Pe.isFormData(e)&&Pe.isFunction(e.entries)){const n={};return Pe.forEachEntry(e,(e,r)=>{t(function(e){return Pe.matchAll(/\w+|\[(\w*)]/g,e).map(e=>"[]"===e[0]?"":e[1]||e[0])}(e),r,n,0)}),n}return null}const tt={transitional:Je,adapter:["xhr","http","fetch"],transformRequest:[function(e,t){const n=t.getContentType()||"",r=n.indexOf("application/json")>-1,o=Pe.isObject(e);o&&Pe.isHTMLForm(e)&&(e=new FormData(e));if(Pe.isFormData(e))return r?JSON.stringify(et(e)):e;if(Pe.isArrayBuffer(e)||Pe.isBuffer(e)||Pe.isStream(e)||Pe.isFile(e)||Pe.isBlob(e)||Pe.isReadableStream(e))return e;if(Pe.isArrayBufferView(e))return e.buffer;if(Pe.isURLSearchParams(e))return t.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),e.toString();let s;if(o){if(n.indexOf("application/x-www-form-urlencoded")>-1)return function(e,t){return Be(e,new Ze.classes.URLSearchParams,{visitor:function(e,t,n,r){return Ze.isNode&&Pe.isBuffer(e)?(this.append(t,e.toString("base64")),!1):r.defaultVisitor.apply(this,arguments)},...t})}(e,this.formSerializer).toString();if((s=Pe.isFileList(e))||n.indexOf("multipart/form-data")>-1){const t=this.env&&this.env.FormData;return Be(s?{"files[]":e}:e,t&&new t,this.formSerializer)}}return o||r?(t.setContentType("application/json",!1),function(e,t,n){if(Pe.isString(e))try{return(t||JSON.parse)(e),Pe.trim(e)}catch(e){if("SyntaxError"!==e.name)throw e}return(n||JSON.stringify)(e)}(e)):e}],transformResponse:[function(e){const t=this.transitional||tt.transitional,n=t&&t.forcedJSONParsing,r="json"===this.responseType;if(Pe.isResponse(e)||Pe.isReadableStream(e))return e;if(e&&Pe.isString(e)&&(n&&!this.responseType||r)){const n=!(t&&t.silentJSONParsing)&&r;try{return JSON.parse(e,this.parseReviver)}catch(e){if(n){if("SyntaxError"===e.name)throw Ne.from(e,Ne.ERR_BAD_RESPONSE,this,null,this.response);throw e}}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:Ze.classes.FormData,Blob:Ze.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};Pe.forEach(["delete","get","head","post","put","patch"],e=>{tt.headers[e]={}});var nt=tt;const rt=Pe.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"]);const ot=Symbol("internals");function st(e){return e&&String(e).trim().toLowerCase()}function it(e){return!1===e||null==e?e:Pe.isArray(e)?e.map(it):String(e)}function at(e,t,n,r,o){return Pe.isFunction(r)?r.call(this,t,n):(o&&(t=n),Pe.isString(t)?Pe.isString(r)?-1!==t.indexOf(r):Pe.isRegExp(r)?r.test(t):void 0:void 0)}class ut{constructor(e){e&&this.set(e)}set(e,t,n){const r=this;function o(e,t,n){const o=st(t);if(!o)throw new Error("header name must be a non-empty string");const s=Pe.findKey(r,o);(!s||void 0===r[s]||!0===n||void 0===n&&!1!==r[s])&&(r[s||t]=it(e))}const s=(e,t)=>Pe.forEach(e,(e,n)=>o(e,n,t));if(Pe.isPlainObject(e)||e instanceof this.constructor)s(e,t);else if(Pe.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]&&rt[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(Pe.isObject(e)&&Pe.isIterable(e)){let n,r,o={};for(const t of e){if(!Pe.isArray(t))throw TypeError("Object iterator must return a key-value pair");o[r=t[0]]=(n=o[r])?Pe.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=st(e)){const n=Pe.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(Pe.isFunction(t))return t.call(this,e,n);if(Pe.isRegExp(t))return t.exec(e);throw new TypeError("parser must be boolean|regexp|function")}}}has(e,t){if(e=st(e)){const n=Pe.findKey(this,e);return!(!n||void 0===this[n]||t&&!at(0,this[n],n,t))}return!1}delete(e,t){const n=this;let r=!1;function o(e){if(e=st(e)){const o=Pe.findKey(n,e);!o||t&&!at(0,n[o],o,t)||(delete n[o],r=!0)}}return Pe.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&&!at(0,this[o],o,e,!0)||(delete this[o],r=!0)}return r}normalize(e){const t=this,n={};return Pe.forEach(this,(r,o)=>{const s=Pe.findKey(n,o);if(s)return t[s]=it(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]=it(r),n[i]=!0}),this}concat(...e){return this.constructor.concat(this,...e)}toJSON(e){const t=Object.create(null);return Pe.forEach(this,(n,r)=>{null!=n&&!1!==n&&(t[r]=e&&Pe.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[ot]=this[ot]={accessors:{}}).accessors,n=this.prototype;function r(e){const r=st(e);t[r]||(!function(e,t){const n=Pe.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 Pe.isArray(e)?e.forEach(r):r(e),this}}ut.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),Pe.reduceDescriptors(ut.prototype,({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(e){this[n]=e}}}),Pe.freezeMethods(ut);var ct=ut;function lt(e,t){const n=this||nt,r=t||n,o=ct.from(r.headers);let s=r.data;return Pe.forEach(e,function(e){s=e.call(n,s,o.normalize(),t?t.status:void 0)}),o.normalize(),s}function ft(e){return!(!e||!e.__CANCEL__)}function pt(e,t,n){Ne.call(this,null==e?"canceled":e,Ne.ERR_CANCELED,t,n),this.name="CanceledError"}function dt(e,t,n){const r=n.config.validateStatus;n.status&&r&&!r(n.status)?t(new Ne("Request failed with status code "+n.status,[Ne.ERR_BAD_REQUEST,Ne.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n)):e(n)}Pe.inherits(pt,Ne,{__CANCEL__:!0});const ht=(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 u=Date.now(),c=r[i];o||(o=u),n[s]=a,r[s]=u;let l=i,f=0;for(;l!==s;)f+=n[l++],l%=e;if(s=(s+1)%e,s===i&&(i=(i+1)%e),u-o<t)return;const p=c&&u-c;return p?Math.round(1e3*f/p):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=s-r,u=o(a);r=s;e({loaded:s,total:i,progress:i?s/i:void 0,bytes:a,rate:u||void 0,estimated:u&&i&&s<=i?(i-s)/u:void 0,event:n,lengthComputable:null!=i,[t?"download":"upload"]:!0})},n)},yt=(e,t)=>{const n=null!=e;return[r=>t[0]({lengthComputable:n,total:e,loaded:r}),t[1]]},mt=e=>(...t)=>Pe.asap(()=>e(...t));var bt=Ze.hasStandardBrowserEnv?((e,t)=>n=>(n=new URL(n,Ze.origin),e.protocol===n.protocol&&e.host===n.host&&(t||e.port===n.port)))(new URL(Ze.origin),Ze.navigator&&/(msie|trident)/i.test(Ze.navigator.userAgent)):()=>!0,vt=Ze.hasStandardBrowserEnv?{write(e,t,n,r,o,s){const i=[e+"="+encodeURIComponent(t)];Pe.isNumber(n)&&i.push("expires="+new Date(n).toGMTString()),Pe.isString(r)&&i.push("path="+r),Pe.isString(o)&&i.push("domain="+o),!0===s&&i.push("secure"),document.cookie=i.join("; ")},read(e){const t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove(e){this.write(e,"",Date.now()-864e5)}}:{write(){},read:()=>null,remove(){}};function gt(e,t,n){let r=!/^([a-z][a-z\d+\-.]*:)?\/\//i.test(t);return e&&(r||0==n)?function(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}(e,t):t}const wt=e=>e instanceof ct?{...e}:e;function Et(e,t){t=t||{};const n={};function r(e,t,n,r){return Pe.isPlainObject(e)&&Pe.isPlainObject(t)?Pe.merge.call({caseless:r},e,t):Pe.isPlainObject(t)?Pe.merge({},t):Pe.isArray(t)?t.slice():t}function o(e,t,n,o){return Pe.isUndefined(t)?Pe.isUndefined(e)?void 0:r(void 0,e,0,o):r(e,t,0,o)}function s(e,t){if(!Pe.isUndefined(t))return r(void 0,t)}function i(e,t){return Pe.isUndefined(t)?Pe.isUndefined(e)?void 0:r(void 0,e):r(void 0,t)}function a(n,o,s){return s in t?r(n,o):s in e?r(void 0,n):void 0}const u={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,responseEncoding:i,validateStatus:a,headers:(e,t,n)=>o(wt(e),wt(t),0,!0)};return Pe.forEach(Object.keys({...e,...t}),function(r){const s=u[r]||o,i=s(e[r],t[r],r);Pe.isUndefined(i)&&s!==a||(n[r]=i)}),n}var Ot=e=>{const t=Et({},e);let{data:n,withXSRFToken:r,xsrfHeaderName:o,xsrfCookieName:s,headers:i,auth:a}=t;if(t.headers=i=ct.from(i),t.url=ze(gt(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),a&&i.set("Authorization","Basic "+btoa((a.username||"")+":"+(a.password?unescape(encodeURIComponent(a.password)):""))),Pe.isFormData(n))if(Ze.hasStandardBrowserEnv||Ze.hasStandardBrowserWebWorkerEnv)i.setContentType(void 0);else if(Pe.isFunction(n.getHeaders)){const e=n.getHeaders(),t=["content-type","content-length"];Object.entries(e).forEach(([e,n])=>{t.includes(e.toLowerCase())&&i.set(e,n)})}if(Ze.hasStandardBrowserEnv&&(r&&Pe.isFunction(r)&&(r=r(t)),r||!1!==r&&bt(t.url))){const e=o&&s&&vt.read(s);e&&i.set(o,e)}return t};var xt="undefined"!=typeof XMLHttpRequest&&function(e){return new Promise(function(t,n){const r=Ot(e);let o=r.data;const s=ct.from(r.headers).normalize();let i,a,u,c,l,{responseType:f,onUploadProgress:p,onDownloadProgress:d}=r;function h(){c&&c(),l&&l(),r.cancelToken&&r.cancelToken.unsubscribe(i),r.signal&&r.signal.removeEventListener("abort",i)}let y=new XMLHttpRequest;function m(){if(!y)return;const r=ct.from("getAllResponseHeaders"in y&&y.getAllResponseHeaders());dt(function(e){t(e),h()},function(e){n(e),h()},{data:f&&"text"!==f&&"json"!==f?y.response:y.responseText,status:y.status,statusText:y.statusText,headers:r,config:e,request:y}),y=null}y.open(r.method.toUpperCase(),r.url,!0),y.timeout=r.timeout,"onloadend"in y?y.onloadend=m:y.onreadystatechange=function(){y&&4===y.readyState&&(0!==y.status||y.responseURL&&0===y.responseURL.indexOf("file:"))&&setTimeout(m)},y.onabort=function(){y&&(n(new Ne("Request aborted",Ne.ECONNABORTED,e,y)),y=null)},y.onerror=function(t){const r=new Ne(t&&t.message?t.message:"Network Error",Ne.ERR_NETWORK,e,y);r.event=t||null,n(r),y=null},y.ontimeout=function(){let t=r.timeout?"timeout of "+r.timeout+"ms exceeded":"timeout exceeded";const o=r.transitional||Je;r.timeoutErrorMessage&&(t=r.timeoutErrorMessage),n(new Ne(t,o.clarifyTimeoutError?Ne.ETIMEDOUT:Ne.ECONNABORTED,e,y)),y=null},void 0===o&&s.setContentType(null),"setRequestHeader"in y&&Pe.forEach(s.toJSON(),function(e,t){y.setRequestHeader(t,e)}),Pe.isUndefined(r.withCredentials)||(y.withCredentials=!!r.withCredentials),f&&"json"!==f&&(y.responseType=r.responseType),d&&([u,l]=ht(d,!0),y.addEventListener("progress",u)),p&&y.upload&&([a,c]=ht(p),y.upload.addEventListener("progress",a),y.upload.addEventListener("loadend",c)),(r.cancelToken||r.signal)&&(i=t=>{y&&(n(!t||t.type?new pt(null,e,y):t),y.abort(),y=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===Ze.protocols.indexOf(b)?n(new Ne("Unsupported protocol "+b+":",Ne.ERR_BAD_REQUEST,e)):y.send(o||null)})};var Rt=(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 Ne?t:new pt(t instanceof Error?t.message:t))}};let s=t&&setTimeout(()=>{s=null,o(new Ne(`timeout ${t} of ms exceeded`,Ne.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=()=>Pe.asap(i),a}};const 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},Tt=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()}},_t=(e,t,n,r)=>{const o=async function*(e,t){for await(const n of Tt(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}=Pe,kt=(({Request:e,Response:t})=>({Request:e,Response:t}))(Pe.global),{ReadableStream:jt,TextEncoder:Pt}=Pe.global,Nt=(e,...t)=>{try{return!!e(...t)}catch(e){return!1}},Ut=e=>{e=Pe.merge.call({skipUndefined:!0},kt,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(jt),u=o&&("function"==typeof Pt?(c=new Pt,e=>c.encode(e)):async e=>new Uint8Array(await new n(e).arrayBuffer()));var c;const l=s&&a&&Nt(()=>{let e=!1;const t=new n(Ze.origin,{body:new jt,method:"POST",get duplex(){return e=!0,"half"}}).headers.has("Content-Type");return e&&!t}),f=i&&a&&Nt(()=>Pe.isReadableStream(new r("").body)),p={stream:f&&(e=>e.body)};o&&["text","arrayBuffer","blob","formData","stream"].forEach(e=>{!p[e]&&(p[e]=(t,n)=>{let r=t&&t[e];if(r)return r.call(t);throw new Ne(`Response type '${e}' is not supported`,Ne.ERR_NOT_SUPPORT,n)})});const d=async(e,t)=>{const r=Pe.toFiniteNumber(e.getContentLength());return null==r?(async e=>{if(null==e)return 0;if(Pe.isBlob(e))return e.size;if(Pe.isSpecCompliantForm(e)){const t=new n(Ze.origin,{method:"POST",body:e});return(await t.arrayBuffer()).byteLength}return Pe.isArrayBufferView(e)||Pe.isArrayBuffer(e)?e.byteLength:(Pe.isURLSearchParams(e)&&(e+=""),Pe.isString(e)?(await u(e)).byteLength:void 0)})(t):r};return async e=>{let{url:o,method:i,data:a,signal:u,cancelToken:c,timeout:h,onDownloadProgress:y,onUploadProgress:m,responseType:b,headers:v,withCredentials:g="same-origin",fetchOptions:w}=Ot(e),E=t||fetch;b=b?(b+"").toLowerCase():"text";let O=Rt([u,c&&c.toAbortSignal()],h),x=null;const R=O&&O.unsubscribe&&(()=>{O.unsubscribe()});let S;try{if(m&&l&&"get"!==i&&"head"!==i&&0!==(S=await d(v,a))){let e,t=new n(o,{method:"POST",body:a,duplex:"half"});if(Pe.isFormData(a)&&(e=t.headers.get("content-type"))&&v.setContentType(e),t.body){const[e,n]=yt(S,ht(mt(m)));a=_t(t.body,65536,e,n)}}Pe.isString(g)||(g=g?"include":"omit");const t=s&&"credentials"in n.prototype,u={...w,signal:O,method:i.toUpperCase(),headers:v.normalize().toJSON(),body:a,duplex:"half",credentials:t?g:void 0};x=s&&new n(o,u);let c=await(s?E(x,w):E(o,u));const h=f&&("stream"===b||"response"===b);if(f&&(y||h&&R)){const e={};["status","statusText","headers"].forEach(t=>{e[t]=c[t]});const t=Pe.toFiniteNumber(c.headers.get("content-length")),[n,o]=y&&yt(t,ht(mt(y),!0))||[];c=new r(_t(c.body,65536,n,()=>{o&&o(),R&&R()}),e)}b=b||"text";let T=await p[Pe.findKey(p,b)||"text"](c,e);return!h&&R&&R(),await new Promise((t,n)=>{dt(t,n,{data:T,headers:ct.from(c.headers),status:c.status,statusText:c.statusText,config:e,request:x})})}catch(t){if(R&&R(),t&&"TypeError"===t.name&&/Load failed|fetch/i.test(t.message))throw Object.assign(new Ne("Network Error",Ne.ERR_NETWORK,e,x),{cause:t.cause||t});throw Ne.from(t,t&&t.code,e,x)}}},Ct=new Map,Lt=e=>{let t=e?e.env:{};const{fetch:n,Request:r,Response:o}=t,s=[r,o,n];let i,a,u=s.length,c=Ct;for(;u--;)i=s[u],a=c.get(i),void 0===a&&c.set(i,a=u?new Map:Ut(t)),c=a;return a};Lt();const Ft={http:null,xhr:xt,fetch:{get:Lt}};Pe.forEach(Ft,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch(e){}Object.defineProperty(e,"adapterName",{value:t})}});const Dt=e=>`- ${e}`,qt=e=>Pe.isFunction(e)||null===e||!1===e;var Bt=(e,t)=>{e=Pe.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,!qt(r)&&(o=Ft[(n=String(r)).toLowerCase()],void 0===o))throw new Ne(`Unknown adapter '${n}'`);if(o&&(Pe.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"));throw new Ne("There is no suitable adapter to dispatch the request "+(n?e.length>1?"since :\n"+e.map(Dt).join("\n"):" "+Dt(e[0]):"as no adapter specified"),"ERR_NOT_SUPPORT")}return o};function Mt(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new pt(null,e)}function It(e){Mt(e),e.headers=ct.from(e.headers),e.data=lt.call(e,e.transformRequest),-1!==["post","put","patch"].indexOf(e.method)&&e.headers.setContentType("application/x-www-form-urlencoded",!1);return Bt(e.adapter||nt.adapter,e)(e).then(function(t){return Mt(e),t.data=lt.call(e,e.transformResponse,t),t.headers=ct.from(t.headers),t},function(t){return ft(t)||(Mt(e),t&&t.response&&(t.response.data=lt.call(e,e.transformResponse,t.response),t.response.headers=ct.from(t.response.headers))),Promise.reject(t)})}const Kt="1.12.2",Ht={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{Ht[e]=function(n){return typeof n===e||"a"+(t<1?"n ":" ")+e}});const zt={};Ht.transitional=function(e,t,n){function r(e,t){return"[Axios v"+Kt+"] Transitional option '"+e+"'"+t+(n?". "+n:"")}return(n,o,s)=>{if(!1===e)throw new Ne(r(o," has been removed"+(t?" in "+t:"")),Ne.ERR_DEPRECATED);return t&&!zt[o]&&(zt[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)}},Ht.spelling=function(e){return(t,n)=>(console.warn(`${n} is likely a misspelling of ${e}`),!0)};var Wt={assertOptions:function(e,t,n){if("object"!=typeof e)throw new Ne("options must be an object",Ne.ERR_BAD_OPTION_VALUE);const r=Object.keys(e);let o=r.length;for(;o-- >0;){const s=r[o],i=t[s];if(i){const t=e[s],n=void 0===t||i(t,s,e);if(!0!==n)throw new Ne("option "+s+" must be "+n,Ne.ERR_BAD_OPTION_VALUE);continue}if(!0!==n)throw new Ne("Unknown option "+s,Ne.ERR_BAD_OPTION)}},validators:Ht};const Jt=Wt.validators;class Vt{constructor(e){this.defaults=e||{},this.interceptors={request:new We,response:new We}}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=t.stack?t.stack.replace(/^.+\n/,""):"";try{e.stack?n&&!String(e.stack).endsWith(n.replace(/^.+\n.+\n/,""))&&(e.stack+="\n"+n):e.stack=n}catch(e){}}throw e}}_request(e,t){"string"==typeof e?(t=t||{}).url=e:t=e||{},t=Et(this.defaults,t);const{transitional:n,paramsSerializer:r,headers:o}=t;void 0!==n&&Wt.assertOptions(n,{silentJSONParsing:Jt.transitional(Jt.boolean),forcedJSONParsing:Jt.transitional(Jt.boolean),clarifyTimeoutError:Jt.transitional(Jt.boolean)},!1),null!=r&&(Pe.isFunction(r)?t.paramsSerializer={serialize:r}:Wt.assertOptions(r,{encode:Jt.function,serialize:Jt.function},!0)),void 0!==t.allowAbsoluteUrls||(void 0!==this.defaults.allowAbsoluteUrls?t.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:t.allowAbsoluteUrls=!0),Wt.assertOptions(t,{baseUrl:Jt.spelling("baseURL"),withXsrfToken:Jt.spelling("withXSRFToken")},!0),t.method=(t.method||this.defaults.method||"get").toLowerCase();let s=o&&Pe.merge(o.common,o[t.method]);o&&Pe.forEach(["delete","get","head","post","put","patch","common"],e=>{delete o[e]}),t.headers=ct.concat(s,o);const i=[];let a=!0;this.interceptors.request.forEach(function(e){"function"==typeof e.runWhen&&!1===e.runWhen(t)||(a=a&&e.synchronous,i.unshift(e.fulfilled,e.rejected))});const u=[];let c;this.interceptors.response.forEach(function(e){u.push(e.fulfilled,e.rejected)});let l,f=0;if(!a){const e=[It.bind(this),void 0];for(e.unshift(...i),e.push(...u),l=e.length,c=Promise.resolve(t);f<l;)c=c.then(e[f++],e[f++]);return c}l=i.length;let p=t;for(;f<l;){const e=i[f++],t=i[f++];try{p=e(p)}catch(e){t.call(this,e);break}}try{c=It.call(this,p)}catch(e){return Promise.reject(e)}for(f=0,l=u.length;f<l;)c=c.then(u[f++],u[f++]);return c}getUri(e){return ze(gt((e=Et(this.defaults,e)).baseURL,e.url,e.allowAbsoluteUrls),e.params,e.paramsSerializer)}}Pe.forEach(["delete","get","head","options"],function(e){Vt.prototype[e]=function(t,n){return this.request(Et(n||{},{method:e,url:t,data:(n||{}).data}))}}),Pe.forEach(["post","put","patch"],function(e){function t(t){return function(n,r,o){return this.request(Et(o||{},{method:e,headers:t?{"Content-Type":"multipart/form-data"}:{},url:n,data:r}))}}Vt.prototype[e]=t(),Vt.prototype[e+"Form"]=t(!0)});var Gt=Vt;class Xt{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 pt(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 Xt(function(t){e=t}),cancel:e}}}var $t=Xt;const Yt={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};Object.entries(Yt).forEach(([e,t])=>{Yt[t]=e});var Qt=Yt;const Zt=function e(t){const n=new Gt(t),r=I(Gt.prototype.request,n);return Pe.extend(r,Gt.prototype,n,{allOwnKeys:!0}),Pe.extend(r,n,null,{allOwnKeys:!0}),r.create=function(n){return e(Et(t,n))},r}(nt);Zt.Axios=Gt,Zt.CanceledError=pt,Zt.CancelToken=$t,Zt.isCancel=ft,Zt.VERSION=Kt,Zt.toFormData=Be,Zt.AxiosError=Ne,Zt.Cancel=Zt.CanceledError,Zt.all=function(e){return Promise.all(e)},Zt.spread=function(e){return function(t){return e.apply(null,t)}},Zt.isAxiosError=function(e){return Pe.isObject(e)&&!0===e.isAxiosError},Zt.mergeConfig=Et,Zt.AxiosHeaders=ct,Zt.formToJSON=e=>et(Pe.isHTMLForm(e)?new FormData(e):e),Zt.getAdapter=Bt,Zt.HttpStatusCode=Qt,Zt.default=Zt;var en=Zt,tn=function(){return i(function e(t){var r=t.server,o=t.accessToken,s=t.appUuid;n(this,e),this.server=r,this.accessToken=o,this.appUuid=s,this.init()},[{key:"init",value:function(){this.accessToken&&this.server&&(this.server=this.server.endsWith("/")?this.server:"".concat(this.server,"/"),this.req=en.create({baseURL:this.server,headers:{Authorization:"Token "+this.accessToken}}))}},{key:"listRows",value:function(e,t,n,r){var o="".concat(this.server,"api/v2.1/universal-apps/").concat(this.appUuid,"/html-page-rows/"),s={page_id:e,table_name:t,start:n,limit:r};return this.req.get(o,{params:s})}},{key:"addRow",value:function(e,t,n,r){var o="".concat(this.server,"api/v2.1/universal-apps/").concat(this.appUuid,"/html-page-rows/"),s={page_id:e,table_name:t,row_data:n,row_links_data:r};return this.req.post(o,s)}},{key:"addRows",value:function(e,t,n,r){var o="".concat(this.server,"api/v2.1/universal-apps/").concat(this.appUuid,"/html-page-rows/batch/"),s={page_id:e,table_name:t,rows_data:n,rows_links_data:r};return this.req.post(o,s)}},{key:"updateRows",value:function(e,t,n){var r="".concat(this.server,"api/v2.1/universal-apps/").concat(this.appUuid,"/html-page-rows/"),o={page_id:e,table_name:t,rows_data:n};return this.req.put(r,o)}},{key:"deleteRows",value:function(e,t,n){var r="".concat(this.server,"api/v2.1/universal-apps/").concat(this.appUuid,"/html-page-rows/"),o={page_id:e,table_name:t,rows_ids:n};return this.req.delete(r,o)}}])}();function nn(e,t,n){return(t=o(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function rn(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function on(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?rn(Object(n),!0).forEach(function(t){nn(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):rn(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}var sn="HTML_PAGE_REQUEST",an="HTML_PAGE_RESPONSE",un="HTML_PAGE_EVENT",cn="WINDOW_EVENT",ln="get_server",fn="get_access_token",pn="get_app_uuid",dn="get_page_id",hn="app",yn="iframe",mn=["click","dblclick","mousemove","mouseenter","mouseleave","mousedown","mouseup","contextmenu"],bn=["keydown","keyup","keypress"],vn=["dragstart","dragover","drag","dragend","dragenter","dragleave","drop"],gn=["mousemove","dragover"],wn=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},En=function(){for(var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:4,t="ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz0123456789",n="",r=0;r<e;r++)n+=t.charAt(Math.floor(72*Math.random()));return n},On=function(e){var t=e.eventType,n=e.event;return mn.includes(t)?{type:t,x:n.x,y:n.y,button:n.button,buttons:n.buttons}:bn.includes(t)?{type:t,key:n.key,code:n.code,keyCode:n.keyCode,ctrlKey:n.ctrlKey,shiftKey:n.shiftKey,altKey:n.altKey,metaKey:n.metaKey,repeat:n.repeat}:vn.includes(t)?{type:t,x:n.x,y:n.y}:null},xn=function(){return i(function e(t){n(this,e),this.options=t||{},this.selfWindow=window.parent===window.self,this.targetOrigin=this.options.targetOrigin||"*",this.pendingRequests={},this.eventHandlers={},this.timeout=this.options.timeout||1e4,this.setupMessageListener()},[{key:"generatorRequestId",value:function(){for(var e=En();wn(this.pendingRequests,e);)e=En();return e}},{key:"setupMessageListener",value:function(){this.selfWindow||(window.addEventListener("message",this.handleMessage.bind(this)),this.setEventsListener())}},{key:"postWindowEvent",value:function(e){e&&window.parent.postMessage({type:cn,params:{event_data:on(on({},e),{},{source:yn})}},this.targetOrigin)}},{key:"setEventsListener",value:function(){var e=this,t=null,n=null;[].concat(mn,bn,vn).forEach(function(r){window.addEventListener(r,function(o){if(o.source!==hn)return gn.includes(r)?(n=On({eventType:r,event:o}),void(null===t&&(t=requestAnimationFrame(function(){n&&(e.postWindowEvent(n),n=null,t=null)})))):void e.postWindowEvent(On({eventType:r,event:o}))},!0)})}},{key:"request",value:(e=t(M.mark(function e(t,n){var r,o=this;return M.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.selfWindow){e.next=1;break}return e.abrupt("return",new Promise(function(e){e(null)}));case 1:return r=this.generatorRequestId(),e.abrupt("return",new Promise(function(e,s){o.pendingRequests[r]={resolve:e,reject:s},window.parent.postMessage({type:sn,requestId:r,method:t,params:n},o.targetOrigin);var i=setTimeout(function(){wn(o.pendingRequests,r)&&(delete o.pendingRequests[r],s(new Error("Request timeout: ".concat(t))))},o.timeout),a=o.pendingRequests[r];a&&(a.timeoutId=i)}));case 2:case"end":return e.stop()}},e,this)})),function(t,n){return e.apply(this,arguments)})},{key:"handleMessage",value:function(e){var t=e.data,n=t.type,r=t.requestId,o=t.data,s=t.error,i=t.eventType,a=t.payload;if(n===an){var u=this.pendingRequests[r];u&&(clearTimeout(u.timeoutId),delete this.pendingRequests[r],s?u.reject(new Error(s)):u.resolve(o?JSON.parse(o):null))}else if(n===un)this.emitEvent(i,a);else if(n===cn){var c,l,f=o.event_data;if(!f)return;if(bn.includes(f.type))c=new KeyboardEvent(f.type,{bubbles:!0,cancelable:!0,key:f.key,code:f.code,keyCode:f.keyCode,ctrlKey:f.ctrlKey,shiftKey:f.shiftKey,altKey:f.altKey,metaKey:f.metaKey,repeat:f.repeat,view:window}),l=document.activeElement||document.body;else if(mn.includes(f.type)){c=new MouseEvent(f.type,{bubbles:!0,cancelable:!0,view:window,clientX:f.x,clientY:f.y,screenX:f.x,screenY:f.y,button:f.button,buttons:f.buttons}),l=document.elementFromPoint(f.x,f.y)||document.body}else if(vn.includes(f.type)){c=new DragEvent(f.type,{bubbles:!0,cancelable:!0,view:window,clientX:f.x,clientY:f.y,screenX:f.x,screenY:f.y,button:f.button,buttons:f.buttons}),l=document.elementFromPoint(f.x,f.y)||document.body}if(!l||!c)return;c.source=f.source,l.dispatchEvent(c)}}},{key:"on",value:function(e,t){var n=this;return wn(this.eventHandlers,e)||(this.eventHandlers[e]=[]),this.eventHandlers[e].push(t),function(){return n.off(e,t)}}},{key:"off",value:function(e,t){var n=this.eventHandlers[e];if(n){var r=n.indexOf(t);-1!==r&&n.splice(r,1)}}},{key:"emitEvent",value:function(e,t){(this.eventHandlers[e]||[]).forEach(function(n){try{n(t)}catch(t){console.error("Error in event handler for ".concat(e,":"),t)}})}},{key:"destroy",value:function(){this.pendingRequests.forEach(function(e){clearTimeout(e.timeoutId),e.reject(new Error("Adapter destroyed"))}),this.pendingRequests={},this.eventHandlers={}}}]);var e}(),Rn=function(){return i(function e(t){n(this,e),this.options=t||{},this.iframeAdapter=new xn(t)},[{key:"init",value:(e=t(M.mark(function e(){var t,n,r,o;return M.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(this.options||(this.options={}),this.options.server){e.next=2;break}return e.next=1,this.iframeAdapter.request(ln);case 1:this.options.server=e.sent;case 2:if(this.options.accessToken){e.next=4;break}return e.next=3,this.iframeAdapter.request(fn);case 3:this.options.accessToken=e.sent;case 4:if(this.options.appUuid){e.next=6;break}return e.next=5,this.iframeAdapter.request(pn);case 5:this.options.appUuid=e.sent;case 6:if(this.options.pageId){e.next=8;break}return e.next=7,this.iframeAdapter.request(dn);case 7:this.options.pageId=e.sent;case 8:t=this.options,n=t.server,r=t.accessToken,o=t.appUuid,this.universalAppAPI=new tn({server:n,accessToken:r,appUuid:o});case 9:case"end":return e.stop()}},e,this)})),function(){return e.apply(this,arguments)})},{key:"listRows",value:function(e){var t=e.tableName,n=e.start,r=e.limit;return this.universalAppAPI.listRows(this.options.pageId,t,n,r)}},{key:"addRow",value:function(e){var t=e.tableName,n=e.rowData,r=e.rowLinksData;return this.universalAppAPI.addRow(this.options.pageId,t,n,r)}},{key:"updateRow",value:function(e){var t=e.tableName,n=[{id:e.rowId,row:e.rowData}];this.batchUpdateRows({tableName:t,rowsData:n})}},{key:"deleteRow",value:function(e){var t=e.tableName,n=[e.rowId];return this.batchDeleteRows({tableName:t,rowsIds:n})}},{key:"batchAddRows",value:function(e){var t=e.tableName,n=e.rowsData,r=e.rowsLinksData;return this.universalAppAPI.addRows(this.options.pageId,t,n,r)}},{key:"batchUpdateRows",value:function(e){var t=e.tableName,n=e.rowsData;return this.universalAppAPI.updateRows(this.options.pageId,t,n)}},{key:"batchDeleteRows",value:function(e){var t=e.tableName,n=e.rowsIds;return this.universalAppAPI.deleteRows(this.options.pageId,t,n)}}]);var e}();return Rn});
1
+ (function (global, factory) {
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
3
+ typeof define === 'function' && define.amd ? define(factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.HTMLPageSDK = factory());
5
+ })(this, (function () { 'use strict';
6
+
7
+ function bind(fn, thisArg) {
8
+ return function wrap() {
9
+ return fn.apply(thisArg, arguments);
10
+ };
11
+ }
12
+
13
+ // utils is a library of generic helper functions non-specific to axios
14
+
15
+ const {toString} = Object.prototype;
16
+ const {getPrototypeOf} = Object;
17
+ const {iterator, toStringTag} = Symbol;
18
+
19
+ const kindOf = (cache => thing => {
20
+ const str = toString.call(thing);
21
+ return cache[str] || (cache[str] = str.slice(8, -1).toLowerCase());
22
+ })(Object.create(null));
23
+
24
+ const kindOfTest = (type) => {
25
+ type = type.toLowerCase();
26
+ return (thing) => kindOf(thing) === type
27
+ };
28
+
29
+ const typeOfTest = type => thing => typeof thing === type;
30
+
31
+ /**
32
+ * Determine if a value is an Array
33
+ *
34
+ * @param {Object} val The value to test
35
+ *
36
+ * @returns {boolean} True if value is an Array, otherwise false
37
+ */
38
+ const {isArray} = Array;
39
+
40
+ /**
41
+ * Determine if a value is undefined
42
+ *
43
+ * @param {*} val The value to test
44
+ *
45
+ * @returns {boolean} True if the value is undefined, otherwise false
46
+ */
47
+ const isUndefined = typeOfTest('undefined');
48
+
49
+ /**
50
+ * Determine if a value is a Buffer
51
+ *
52
+ * @param {*} val The value to test
53
+ *
54
+ * @returns {boolean} True if value is a Buffer, otherwise false
55
+ */
56
+ function isBuffer(val) {
57
+ return val !== null && !isUndefined(val) && val.constructor !== null && !isUndefined(val.constructor)
58
+ && isFunction$1(val.constructor.isBuffer) && val.constructor.isBuffer(val);
59
+ }
60
+
61
+ /**
62
+ * Determine if a value is an ArrayBuffer
63
+ *
64
+ * @param {*} val The value to test
65
+ *
66
+ * @returns {boolean} True if value is an ArrayBuffer, otherwise false
67
+ */
68
+ const isArrayBuffer = kindOfTest('ArrayBuffer');
69
+
70
+
71
+ /**
72
+ * Determine if a value is a view on an ArrayBuffer
73
+ *
74
+ * @param {*} val The value to test
75
+ *
76
+ * @returns {boolean} True if value is a view on an ArrayBuffer, otherwise false
77
+ */
78
+ function isArrayBufferView(val) {
79
+ let result;
80
+ if ((typeof ArrayBuffer !== 'undefined') && (ArrayBuffer.isView)) {
81
+ result = ArrayBuffer.isView(val);
82
+ } else {
83
+ result = (val) && (val.buffer) && (isArrayBuffer(val.buffer));
84
+ }
85
+ return result;
86
+ }
87
+
88
+ /**
89
+ * Determine if a value is a String
90
+ *
91
+ * @param {*} val The value to test
92
+ *
93
+ * @returns {boolean} True if value is a String, otherwise false
94
+ */
95
+ const isString = typeOfTest('string');
96
+
97
+ /**
98
+ * Determine if a value is a Function
99
+ *
100
+ * @param {*} val The value to test
101
+ * @returns {boolean} True if value is a Function, otherwise false
102
+ */
103
+ const isFunction$1 = typeOfTest('function');
104
+
105
+ /**
106
+ * Determine if a value is a Number
107
+ *
108
+ * @param {*} val The value to test
109
+ *
110
+ * @returns {boolean} True if value is a Number, otherwise false
111
+ */
112
+ const isNumber = typeOfTest('number');
113
+
114
+ /**
115
+ * Determine if a value is an Object
116
+ *
117
+ * @param {*} thing The value to test
118
+ *
119
+ * @returns {boolean} True if value is an Object, otherwise false
120
+ */
121
+ const isObject = (thing) => thing !== null && typeof thing === 'object';
122
+
123
+ /**
124
+ * Determine if a value is a Boolean
125
+ *
126
+ * @param {*} thing The value to test
127
+ * @returns {boolean} True if value is a Boolean, otherwise false
128
+ */
129
+ const isBoolean = thing => thing === true || thing === false;
130
+
131
+ /**
132
+ * Determine if a value is a plain Object
133
+ *
134
+ * @param {*} val The value to test
135
+ *
136
+ * @returns {boolean} True if value is a plain Object, otherwise false
137
+ */
138
+ const isPlainObject = (val) => {
139
+ if (kindOf(val) !== 'object') {
140
+ return false;
141
+ }
142
+
143
+ const prototype = getPrototypeOf(val);
144
+ return (prototype === null || prototype === Object.prototype || Object.getPrototypeOf(prototype) === null) && !(toStringTag in val) && !(iterator in val);
145
+ };
146
+
147
+ /**
148
+ * Determine if a value is an empty object (safely handles Buffers)
149
+ *
150
+ * @param {*} val The value to test
151
+ *
152
+ * @returns {boolean} True if value is an empty object, otherwise false
153
+ */
154
+ const isEmptyObject = (val) => {
155
+ // Early return for non-objects or Buffers to prevent RangeError
156
+ if (!isObject(val) || isBuffer(val)) {
157
+ return false;
158
+ }
159
+
160
+ try {
161
+ return Object.keys(val).length === 0 && Object.getPrototypeOf(val) === Object.prototype;
162
+ } catch (e) {
163
+ // Fallback for any other objects that might cause RangeError with Object.keys()
164
+ return false;
165
+ }
166
+ };
167
+
168
+ /**
169
+ * Determine if a value is a Date
170
+ *
171
+ * @param {*} val The value to test
172
+ *
173
+ * @returns {boolean} True if value is a Date, otherwise false
174
+ */
175
+ const isDate = kindOfTest('Date');
176
+
177
+ /**
178
+ * Determine if a value is a File
179
+ *
180
+ * @param {*} val The value to test
181
+ *
182
+ * @returns {boolean} True if value is a File, otherwise false
183
+ */
184
+ const isFile = kindOfTest('File');
185
+
186
+ /**
187
+ * Determine if a value is a Blob
188
+ *
189
+ * @param {*} val The value to test
190
+ *
191
+ * @returns {boolean} True if value is a Blob, otherwise false
192
+ */
193
+ const isBlob = kindOfTest('Blob');
194
+
195
+ /**
196
+ * Determine if a value is a FileList
197
+ *
198
+ * @param {*} val The value to test
199
+ *
200
+ * @returns {boolean} True if value is a File, otherwise false
201
+ */
202
+ const isFileList = kindOfTest('FileList');
203
+
204
+ /**
205
+ * Determine if a value is a Stream
206
+ *
207
+ * @param {*} val The value to test
208
+ *
209
+ * @returns {boolean} True if value is a Stream, otherwise false
210
+ */
211
+ const isStream = (val) => isObject(val) && isFunction$1(val.pipe);
212
+
213
+ /**
214
+ * Determine if a value is a FormData
215
+ *
216
+ * @param {*} thing The value to test
217
+ *
218
+ * @returns {boolean} True if value is an FormData, otherwise false
219
+ */
220
+ const isFormData = (thing) => {
221
+ let kind;
222
+ return thing && (
223
+ (typeof FormData === 'function' && thing instanceof FormData) || (
224
+ isFunction$1(thing.append) && (
225
+ (kind = kindOf(thing)) === 'formdata' ||
226
+ // detect form-data instance
227
+ (kind === 'object' && isFunction$1(thing.toString) && thing.toString() === '[object FormData]')
228
+ )
229
+ )
230
+ )
231
+ };
232
+
233
+ /**
234
+ * Determine if a value is a URLSearchParams object
235
+ *
236
+ * @param {*} val The value to test
237
+ *
238
+ * @returns {boolean} True if value is a URLSearchParams object, otherwise false
239
+ */
240
+ const isURLSearchParams = kindOfTest('URLSearchParams');
241
+
242
+ const [isReadableStream, isRequest, isResponse, isHeaders] = ['ReadableStream', 'Request', 'Response', 'Headers'].map(kindOfTest);
243
+
244
+ /**
245
+ * Trim excess whitespace off the beginning and end of a string
246
+ *
247
+ * @param {String} str The String to trim
248
+ *
249
+ * @returns {String} The String freed of excess whitespace
250
+ */
251
+ const trim = (str) => str.trim ?
252
+ str.trim() : str.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, '');
253
+
254
+ /**
255
+ * Iterate over an Array or an Object invoking a function for each item.
256
+ *
257
+ * If `obj` is an Array callback will be called passing
258
+ * the value, index, and complete array for each item.
259
+ *
260
+ * If 'obj' is an Object callback will be called passing
261
+ * the value, key, and complete object for each property.
262
+ *
263
+ * @param {Object|Array} obj The object to iterate
264
+ * @param {Function} fn The callback to invoke for each item
265
+ *
266
+ * @param {Boolean} [allOwnKeys = false]
267
+ * @returns {any}
268
+ */
269
+ function forEach(obj, fn, {allOwnKeys = false} = {}) {
270
+ // Don't bother if no value provided
271
+ if (obj === null || typeof obj === 'undefined') {
272
+ return;
273
+ }
274
+
275
+ let i;
276
+ let l;
277
+
278
+ // Force an array if not already something iterable
279
+ if (typeof obj !== 'object') {
280
+ /*eslint no-param-reassign:0*/
281
+ obj = [obj];
282
+ }
283
+
284
+ if (isArray(obj)) {
285
+ // Iterate over array values
286
+ for (i = 0, l = obj.length; i < l; i++) {
287
+ fn.call(null, obj[i], i, obj);
288
+ }
289
+ } else {
290
+ // Buffer check
291
+ if (isBuffer(obj)) {
292
+ return;
293
+ }
294
+
295
+ // Iterate over object keys
296
+ const keys = allOwnKeys ? Object.getOwnPropertyNames(obj) : Object.keys(obj);
297
+ const len = keys.length;
298
+ let key;
299
+
300
+ for (i = 0; i < len; i++) {
301
+ key = keys[i];
302
+ fn.call(null, obj[key], key, obj);
303
+ }
304
+ }
305
+ }
306
+
307
+ function findKey(obj, key) {
308
+ if (isBuffer(obj)){
309
+ return null;
310
+ }
311
+
312
+ key = key.toLowerCase();
313
+ const keys = Object.keys(obj);
314
+ let i = keys.length;
315
+ let _key;
316
+ while (i-- > 0) {
317
+ _key = keys[i];
318
+ if (key === _key.toLowerCase()) {
319
+ return _key;
320
+ }
321
+ }
322
+ return null;
323
+ }
324
+
325
+ const _global = (() => {
326
+ /*eslint no-undef:0*/
327
+ if (typeof globalThis !== "undefined") return globalThis;
328
+ return typeof self !== "undefined" ? self : (typeof window !== 'undefined' ? window : global)
329
+ })();
330
+
331
+ const isContextDefined = (context) => !isUndefined(context) && context !== _global;
332
+
333
+ /**
334
+ * Accepts varargs expecting each argument to be an object, then
335
+ * immutably merges the properties of each object and returns result.
336
+ *
337
+ * When multiple objects contain the same key the later object in
338
+ * the arguments list will take precedence.
339
+ *
340
+ * Example:
341
+ *
342
+ * ```js
343
+ * var result = merge({foo: 123}, {foo: 456});
344
+ * console.log(result.foo); // outputs 456
345
+ * ```
346
+ *
347
+ * @param {Object} obj1 Object to merge
348
+ *
349
+ * @returns {Object} Result of all merge properties
350
+ */
351
+ function merge(/* obj1, obj2, obj3, ... */) {
352
+ const {caseless, skipUndefined} = isContextDefined(this) && this || {};
353
+ const result = {};
354
+ const assignValue = (val, key) => {
355
+ const targetKey = caseless && findKey(result, key) || key;
356
+ if (isPlainObject(result[targetKey]) && isPlainObject(val)) {
357
+ result[targetKey] = merge(result[targetKey], val);
358
+ } else if (isPlainObject(val)) {
359
+ result[targetKey] = merge({}, val);
360
+ } else if (isArray(val)) {
361
+ result[targetKey] = val.slice();
362
+ } else if (!skipUndefined || !isUndefined(val)) {
363
+ result[targetKey] = val;
364
+ }
365
+ };
366
+
367
+ for (let i = 0, l = arguments.length; i < l; i++) {
368
+ arguments[i] && forEach(arguments[i], assignValue);
369
+ }
370
+ return result;
371
+ }
372
+
373
+ /**
374
+ * Extends object a by mutably adding to it the properties of object b.
375
+ *
376
+ * @param {Object} a The object to be extended
377
+ * @param {Object} b The object to copy properties from
378
+ * @param {Object} thisArg The object to bind function to
379
+ *
380
+ * @param {Boolean} [allOwnKeys]
381
+ * @returns {Object} The resulting value of object a
382
+ */
383
+ const extend = (a, b, thisArg, {allOwnKeys}= {}) => {
384
+ forEach(b, (val, key) => {
385
+ if (thisArg && isFunction$1(val)) {
386
+ a[key] = bind(val, thisArg);
387
+ } else {
388
+ a[key] = val;
389
+ }
390
+ }, {allOwnKeys});
391
+ return a;
392
+ };
393
+
394
+ /**
395
+ * Remove byte order marker. This catches EF BB BF (the UTF-8 BOM)
396
+ *
397
+ * @param {string} content with BOM
398
+ *
399
+ * @returns {string} content value without BOM
400
+ */
401
+ const stripBOM = (content) => {
402
+ if (content.charCodeAt(0) === 0xFEFF) {
403
+ content = content.slice(1);
404
+ }
405
+ return content;
406
+ };
407
+
408
+ /**
409
+ * Inherit the prototype methods from one constructor into another
410
+ * @param {function} constructor
411
+ * @param {function} superConstructor
412
+ * @param {object} [props]
413
+ * @param {object} [descriptors]
414
+ *
415
+ * @returns {void}
416
+ */
417
+ const inherits = (constructor, superConstructor, props, descriptors) => {
418
+ constructor.prototype = Object.create(superConstructor.prototype, descriptors);
419
+ constructor.prototype.constructor = constructor;
420
+ Object.defineProperty(constructor, 'super', {
421
+ value: superConstructor.prototype
422
+ });
423
+ props && Object.assign(constructor.prototype, props);
424
+ };
425
+
426
+ /**
427
+ * Resolve object with deep prototype chain to a flat object
428
+ * @param {Object} sourceObj source object
429
+ * @param {Object} [destObj]
430
+ * @param {Function|Boolean} [filter]
431
+ * @param {Function} [propFilter]
432
+ *
433
+ * @returns {Object}
434
+ */
435
+ const toFlatObject = (sourceObj, destObj, filter, propFilter) => {
436
+ let props;
437
+ let i;
438
+ let prop;
439
+ const merged = {};
440
+
441
+ destObj = destObj || {};
442
+ // eslint-disable-next-line no-eq-null,eqeqeq
443
+ if (sourceObj == null) return destObj;
444
+
445
+ do {
446
+ props = Object.getOwnPropertyNames(sourceObj);
447
+ i = props.length;
448
+ while (i-- > 0) {
449
+ prop = props[i];
450
+ if ((!propFilter || propFilter(prop, sourceObj, destObj)) && !merged[prop]) {
451
+ destObj[prop] = sourceObj[prop];
452
+ merged[prop] = true;
453
+ }
454
+ }
455
+ sourceObj = filter !== false && getPrototypeOf(sourceObj);
456
+ } while (sourceObj && (!filter || filter(sourceObj, destObj)) && sourceObj !== Object.prototype);
457
+
458
+ return destObj;
459
+ };
460
+
461
+ /**
462
+ * Determines whether a string ends with the characters of a specified string
463
+ *
464
+ * @param {String} str
465
+ * @param {String} searchString
466
+ * @param {Number} [position= 0]
467
+ *
468
+ * @returns {boolean}
469
+ */
470
+ const endsWith = (str, searchString, position) => {
471
+ str = String(str);
472
+ if (position === undefined || position > str.length) {
473
+ position = str.length;
474
+ }
475
+ position -= searchString.length;
476
+ const lastIndex = str.indexOf(searchString, position);
477
+ return lastIndex !== -1 && lastIndex === position;
478
+ };
479
+
480
+
481
+ /**
482
+ * Returns new array from array like object or null if failed
483
+ *
484
+ * @param {*} [thing]
485
+ *
486
+ * @returns {?Array}
487
+ */
488
+ const toArray = (thing) => {
489
+ if (!thing) return null;
490
+ if (isArray(thing)) return thing;
491
+ let i = thing.length;
492
+ if (!isNumber(i)) return null;
493
+ const arr = new Array(i);
494
+ while (i-- > 0) {
495
+ arr[i] = thing[i];
496
+ }
497
+ return arr;
498
+ };
499
+
500
+ /**
501
+ * Checking if the Uint8Array exists and if it does, it returns a function that checks if the
502
+ * thing passed in is an instance of Uint8Array
503
+ *
504
+ * @param {TypedArray}
505
+ *
506
+ * @returns {Array}
507
+ */
508
+ // eslint-disable-next-line func-names
509
+ const isTypedArray = (TypedArray => {
510
+ // eslint-disable-next-line func-names
511
+ return thing => {
512
+ return TypedArray && thing instanceof TypedArray;
513
+ };
514
+ })(typeof Uint8Array !== 'undefined' && getPrototypeOf(Uint8Array));
515
+
516
+ /**
517
+ * For each entry in the object, call the function with the key and value.
518
+ *
519
+ * @param {Object<any, any>} obj - The object to iterate over.
520
+ * @param {Function} fn - The function to call for each entry.
521
+ *
522
+ * @returns {void}
523
+ */
524
+ const forEachEntry = (obj, fn) => {
525
+ const generator = obj && obj[iterator];
526
+
527
+ const _iterator = generator.call(obj);
528
+
529
+ let result;
530
+
531
+ while ((result = _iterator.next()) && !result.done) {
532
+ const pair = result.value;
533
+ fn.call(obj, pair[0], pair[1]);
534
+ }
535
+ };
536
+
537
+ /**
538
+ * It takes a regular expression and a string, and returns an array of all the matches
539
+ *
540
+ * @param {string} regExp - The regular expression to match against.
541
+ * @param {string} str - The string to search.
542
+ *
543
+ * @returns {Array<boolean>}
544
+ */
545
+ const matchAll = (regExp, str) => {
546
+ let matches;
547
+ const arr = [];
548
+
549
+ while ((matches = regExp.exec(str)) !== null) {
550
+ arr.push(matches);
551
+ }
552
+
553
+ return arr;
554
+ };
555
+
556
+ /* Checking if the kindOfTest function returns true when passed an HTMLFormElement. */
557
+ const isHTMLForm = kindOfTest('HTMLFormElement');
558
+
559
+ const toCamelCase = str => {
560
+ return str.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,
561
+ function replacer(m, p1, p2) {
562
+ return p1.toUpperCase() + p2;
563
+ }
564
+ );
565
+ };
566
+
567
+ /* Creating a function that will check if an object has a property. */
568
+ const hasOwnProperty$1 = (({hasOwnProperty}) => (obj, prop) => hasOwnProperty.call(obj, prop))(Object.prototype);
569
+
570
+ /**
571
+ * Determine if a value is a RegExp object
572
+ *
573
+ * @param {*} val The value to test
574
+ *
575
+ * @returns {boolean} True if value is a RegExp object, otherwise false
576
+ */
577
+ const isRegExp = kindOfTest('RegExp');
578
+
579
+ const reduceDescriptors = (obj, reducer) => {
580
+ const descriptors = Object.getOwnPropertyDescriptors(obj);
581
+ const reducedDescriptors = {};
582
+
583
+ forEach(descriptors, (descriptor, name) => {
584
+ let ret;
585
+ if ((ret = reducer(descriptor, name, obj)) !== false) {
586
+ reducedDescriptors[name] = ret || descriptor;
587
+ }
588
+ });
589
+
590
+ Object.defineProperties(obj, reducedDescriptors);
591
+ };
592
+
593
+ /**
594
+ * Makes all methods read-only
595
+ * @param {Object} obj
596
+ */
597
+
598
+ const freezeMethods = (obj) => {
599
+ reduceDescriptors(obj, (descriptor, name) => {
600
+ // skip restricted props in strict mode
601
+ if (isFunction$1(obj) && ['arguments', 'caller', 'callee'].indexOf(name) !== -1) {
602
+ return false;
603
+ }
604
+
605
+ const value = obj[name];
606
+
607
+ if (!isFunction$1(value)) return;
608
+
609
+ descriptor.enumerable = false;
610
+
611
+ if ('writable' in descriptor) {
612
+ descriptor.writable = false;
613
+ return;
614
+ }
615
+
616
+ if (!descriptor.set) {
617
+ descriptor.set = () => {
618
+ throw Error('Can not rewrite read-only method \'' + name + '\'');
619
+ };
620
+ }
621
+ });
622
+ };
623
+
624
+ const toObjectSet = (arrayOrString, delimiter) => {
625
+ const obj = {};
626
+
627
+ const define = (arr) => {
628
+ arr.forEach(value => {
629
+ obj[value] = true;
630
+ });
631
+ };
632
+
633
+ isArray(arrayOrString) ? define(arrayOrString) : define(String(arrayOrString).split(delimiter));
634
+
635
+ return obj;
636
+ };
637
+
638
+ const noop = () => {};
639
+
640
+ const toFiniteNumber = (value, defaultValue) => {
641
+ return value != null && Number.isFinite(value = +value) ? value : defaultValue;
642
+ };
643
+
644
+
645
+
646
+ /**
647
+ * If the thing is a FormData object, return true, otherwise return false.
648
+ *
649
+ * @param {unknown} thing - The thing to check.
650
+ *
651
+ * @returns {boolean}
652
+ */
653
+ function isSpecCompliantForm(thing) {
654
+ return !!(thing && isFunction$1(thing.append) && thing[toStringTag] === 'FormData' && thing[iterator]);
655
+ }
656
+
657
+ const toJSONObject = (obj) => {
658
+ const stack = new Array(10);
659
+
660
+ const visit = (source, i) => {
661
+
662
+ if (isObject(source)) {
663
+ if (stack.indexOf(source) >= 0) {
664
+ return;
665
+ }
666
+
667
+ //Buffer check
668
+ if (isBuffer(source)) {
669
+ return source;
670
+ }
671
+
672
+ if(!('toJSON' in source)) {
673
+ stack[i] = source;
674
+ const target = isArray(source) ? [] : {};
675
+
676
+ forEach(source, (value, key) => {
677
+ const reducedValue = visit(value, i + 1);
678
+ !isUndefined(reducedValue) && (target[key] = reducedValue);
679
+ });
680
+
681
+ stack[i] = undefined;
682
+
683
+ return target;
684
+ }
685
+ }
686
+
687
+ return source;
688
+ };
689
+
690
+ return visit(obj, 0);
691
+ };
692
+
693
+ const isAsyncFn = kindOfTest('AsyncFunction');
694
+
695
+ const isThenable = (thing) =>
696
+ thing && (isObject(thing) || isFunction$1(thing)) && isFunction$1(thing.then) && isFunction$1(thing.catch);
697
+
698
+ // original code
699
+ // https://github.com/DigitalBrainJS/AxiosPromise/blob/16deab13710ec09779922131f3fa5954320f83ab/lib/utils.js#L11-L34
700
+
701
+ const _setImmediate = ((setImmediateSupported, postMessageSupported) => {
702
+ if (setImmediateSupported) {
703
+ return setImmediate;
704
+ }
705
+
706
+ return postMessageSupported ? ((token, callbacks) => {
707
+ _global.addEventListener("message", ({source, data}) => {
708
+ if (source === _global && data === token) {
709
+ callbacks.length && callbacks.shift()();
710
+ }
711
+ }, false);
712
+
713
+ return (cb) => {
714
+ callbacks.push(cb);
715
+ _global.postMessage(token, "*");
716
+ }
717
+ })(`axios@${Math.random()}`, []) : (cb) => setTimeout(cb);
718
+ })(
719
+ typeof setImmediate === 'function',
720
+ isFunction$1(_global.postMessage)
721
+ );
722
+
723
+ const asap = typeof queueMicrotask !== 'undefined' ?
724
+ queueMicrotask.bind(_global) : ( typeof process !== 'undefined' && process.nextTick || _setImmediate);
725
+
726
+ // *********************
727
+
728
+
729
+ const isIterable = (thing) => thing != null && isFunction$1(thing[iterator]);
730
+
731
+
732
+ var utils$1 = {
733
+ isArray,
734
+ isArrayBuffer,
735
+ isBuffer,
736
+ isFormData,
737
+ isArrayBufferView,
738
+ isString,
739
+ isNumber,
740
+ isBoolean,
741
+ isObject,
742
+ isPlainObject,
743
+ isEmptyObject,
744
+ isReadableStream,
745
+ isRequest,
746
+ isResponse,
747
+ isHeaders,
748
+ isUndefined,
749
+ isDate,
750
+ isFile,
751
+ isBlob,
752
+ isRegExp,
753
+ isFunction: isFunction$1,
754
+ isStream,
755
+ isURLSearchParams,
756
+ isTypedArray,
757
+ isFileList,
758
+ forEach,
759
+ merge,
760
+ extend,
761
+ trim,
762
+ stripBOM,
763
+ inherits,
764
+ toFlatObject,
765
+ kindOf,
766
+ kindOfTest,
767
+ endsWith,
768
+ toArray,
769
+ forEachEntry,
770
+ matchAll,
771
+ isHTMLForm,
772
+ hasOwnProperty: hasOwnProperty$1,
773
+ hasOwnProp: hasOwnProperty$1, // an alias to avoid ESLint no-prototype-builtins detection
774
+ reduceDescriptors,
775
+ freezeMethods,
776
+ toObjectSet,
777
+ toCamelCase,
778
+ noop,
779
+ toFiniteNumber,
780
+ findKey,
781
+ global: _global,
782
+ isContextDefined,
783
+ isSpecCompliantForm,
784
+ toJSONObject,
785
+ isAsyncFn,
786
+ isThenable,
787
+ setImmediate: _setImmediate,
788
+ asap,
789
+ isIterable
790
+ };
791
+
792
+ /**
793
+ * Create an Error with the specified message, config, error code, request and response.
794
+ *
795
+ * @param {string} message The error message.
796
+ * @param {string} [code] The error code (for example, 'ECONNABORTED').
797
+ * @param {Object} [config] The config.
798
+ * @param {Object} [request] The request.
799
+ * @param {Object} [response] The response.
800
+ *
801
+ * @returns {Error} The created error.
802
+ */
803
+ function AxiosError(message, code, config, request, response) {
804
+ Error.call(this);
805
+
806
+ if (Error.captureStackTrace) {
807
+ Error.captureStackTrace(this, this.constructor);
808
+ } else {
809
+ this.stack = (new Error()).stack;
810
+ }
811
+
812
+ this.message = message;
813
+ this.name = 'AxiosError';
814
+ code && (this.code = code);
815
+ config && (this.config = config);
816
+ request && (this.request = request);
817
+ if (response) {
818
+ this.response = response;
819
+ this.status = response.status ? response.status : null;
820
+ }
821
+ }
822
+
823
+ utils$1.inherits(AxiosError, Error, {
824
+ toJSON: function toJSON() {
825
+ return {
826
+ // Standard
827
+ message: this.message,
828
+ name: this.name,
829
+ // Microsoft
830
+ description: this.description,
831
+ number: this.number,
832
+ // Mozilla
833
+ fileName: this.fileName,
834
+ lineNumber: this.lineNumber,
835
+ columnNumber: this.columnNumber,
836
+ stack: this.stack,
837
+ // Axios
838
+ config: utils$1.toJSONObject(this.config),
839
+ code: this.code,
840
+ status: this.status
841
+ };
842
+ }
843
+ });
844
+
845
+ const prototype$1 = AxiosError.prototype;
846
+ const descriptors = {};
847
+
848
+ [
849
+ 'ERR_BAD_OPTION_VALUE',
850
+ 'ERR_BAD_OPTION',
851
+ 'ECONNABORTED',
852
+ 'ETIMEDOUT',
853
+ 'ERR_NETWORK',
854
+ 'ERR_FR_TOO_MANY_REDIRECTS',
855
+ 'ERR_DEPRECATED',
856
+ 'ERR_BAD_RESPONSE',
857
+ 'ERR_BAD_REQUEST',
858
+ 'ERR_CANCELED',
859
+ 'ERR_NOT_SUPPORT',
860
+ 'ERR_INVALID_URL'
861
+ // eslint-disable-next-line func-names
862
+ ].forEach(code => {
863
+ descriptors[code] = {value: code};
864
+ });
865
+
866
+ Object.defineProperties(AxiosError, descriptors);
867
+ Object.defineProperty(prototype$1, 'isAxiosError', {value: true});
868
+
869
+ // eslint-disable-next-line func-names
870
+ AxiosError.from = (error, code, config, request, response, customProps) => {
871
+ const axiosError = Object.create(prototype$1);
872
+
873
+ utils$1.toFlatObject(error, axiosError, function filter(obj) {
874
+ return obj !== Error.prototype;
875
+ }, prop => {
876
+ return prop !== 'isAxiosError';
877
+ });
878
+
879
+ const msg = error && error.message ? error.message : 'Error';
880
+
881
+ // Prefer explicit code; otherwise copy the low-level error's code (e.g. ECONNREFUSED)
882
+ const errCode = code == null && error ? error.code : code;
883
+ AxiosError.call(axiosError, msg, errCode, config, request, response);
884
+
885
+ // Chain the original error on the standard field; non-enumerable to avoid JSON noise
886
+ if (error && axiosError.cause == null) {
887
+ Object.defineProperty(axiosError, 'cause', { value: error, configurable: true });
888
+ }
889
+
890
+ axiosError.name = (error && error.name) || 'Error';
891
+
892
+ customProps && Object.assign(axiosError, customProps);
893
+
894
+ return axiosError;
895
+ };
896
+
897
+ // eslint-disable-next-line strict
898
+ var httpAdapter = null;
899
+
900
+ /**
901
+ * Determines if the given thing is a array or js object.
902
+ *
903
+ * @param {string} thing - The object or array to be visited.
904
+ *
905
+ * @returns {boolean}
906
+ */
907
+ function isVisitable(thing) {
908
+ return utils$1.isPlainObject(thing) || utils$1.isArray(thing);
909
+ }
910
+
911
+ /**
912
+ * It removes the brackets from the end of a string
913
+ *
914
+ * @param {string} key - The key of the parameter.
915
+ *
916
+ * @returns {string} the key without the brackets.
917
+ */
918
+ function removeBrackets(key) {
919
+ return utils$1.endsWith(key, '[]') ? key.slice(0, -2) : key;
920
+ }
921
+
922
+ /**
923
+ * It takes a path, a key, and a boolean, and returns a string
924
+ *
925
+ * @param {string} path - The path to the current key.
926
+ * @param {string} key - The key of the current object being iterated over.
927
+ * @param {string} dots - If true, the key will be rendered with dots instead of brackets.
928
+ *
929
+ * @returns {string} The path to the current key.
930
+ */
931
+ function renderKey(path, key, dots) {
932
+ if (!path) return key;
933
+ return path.concat(key).map(function each(token, i) {
934
+ // eslint-disable-next-line no-param-reassign
935
+ token = removeBrackets(token);
936
+ return !dots && i ? '[' + token + ']' : token;
937
+ }).join(dots ? '.' : '');
938
+ }
939
+
940
+ /**
941
+ * If the array is an array and none of its elements are visitable, then it's a flat array.
942
+ *
943
+ * @param {Array<any>} arr - The array to check
944
+ *
945
+ * @returns {boolean}
946
+ */
947
+ function isFlatArray(arr) {
948
+ return utils$1.isArray(arr) && !arr.some(isVisitable);
949
+ }
950
+
951
+ const predicates = utils$1.toFlatObject(utils$1, {}, null, function filter(prop) {
952
+ return /^is[A-Z]/.test(prop);
953
+ });
954
+
955
+ /**
956
+ * Convert a data object to FormData
957
+ *
958
+ * @param {Object} obj
959
+ * @param {?Object} [formData]
960
+ * @param {?Object} [options]
961
+ * @param {Function} [options.visitor]
962
+ * @param {Boolean} [options.metaTokens = true]
963
+ * @param {Boolean} [options.dots = false]
964
+ * @param {?Boolean} [options.indexes = false]
965
+ *
966
+ * @returns {Object}
967
+ **/
968
+
969
+ /**
970
+ * It converts an object into a FormData object
971
+ *
972
+ * @param {Object<any, any>} obj - The object to convert to form data.
973
+ * @param {string} formData - The FormData object to append to.
974
+ * @param {Object<string, any>} options
975
+ *
976
+ * @returns
977
+ */
978
+ function toFormData(obj, formData, options) {
979
+ if (!utils$1.isObject(obj)) {
980
+ throw new TypeError('target must be an object');
981
+ }
982
+
983
+ // eslint-disable-next-line no-param-reassign
984
+ formData = formData || new (FormData)();
985
+
986
+ // eslint-disable-next-line no-param-reassign
987
+ options = utils$1.toFlatObject(options, {
988
+ metaTokens: true,
989
+ dots: false,
990
+ indexes: false
991
+ }, false, function defined(option, source) {
992
+ // eslint-disable-next-line no-eq-null,eqeqeq
993
+ return !utils$1.isUndefined(source[option]);
994
+ });
995
+
996
+ const metaTokens = options.metaTokens;
997
+ // eslint-disable-next-line no-use-before-define
998
+ const visitor = options.visitor || defaultVisitor;
999
+ const dots = options.dots;
1000
+ const indexes = options.indexes;
1001
+ const _Blob = options.Blob || typeof Blob !== 'undefined' && Blob;
1002
+ const useBlob = _Blob && utils$1.isSpecCompliantForm(formData);
1003
+
1004
+ if (!utils$1.isFunction(visitor)) {
1005
+ throw new TypeError('visitor must be a function');
1006
+ }
1007
+
1008
+ function convertValue(value) {
1009
+ if (value === null) return '';
1010
+
1011
+ if (utils$1.isDate(value)) {
1012
+ return value.toISOString();
1013
+ }
1014
+
1015
+ if (utils$1.isBoolean(value)) {
1016
+ return value.toString();
1017
+ }
1018
+
1019
+ if (!useBlob && utils$1.isBlob(value)) {
1020
+ throw new AxiosError('Blob is not supported. Use a Buffer instead.');
1021
+ }
1022
+
1023
+ if (utils$1.isArrayBuffer(value) || utils$1.isTypedArray(value)) {
1024
+ return useBlob && typeof Blob === 'function' ? new Blob([value]) : Buffer.from(value);
1025
+ }
1026
+
1027
+ return value;
1028
+ }
1029
+
1030
+ /**
1031
+ * Default visitor.
1032
+ *
1033
+ * @param {*} value
1034
+ * @param {String|Number} key
1035
+ * @param {Array<String|Number>} path
1036
+ * @this {FormData}
1037
+ *
1038
+ * @returns {boolean} return true to visit the each prop of the value recursively
1039
+ */
1040
+ function defaultVisitor(value, key, path) {
1041
+ let arr = value;
1042
+
1043
+ if (value && !path && typeof value === 'object') {
1044
+ if (utils$1.endsWith(key, '{}')) {
1045
+ // eslint-disable-next-line no-param-reassign
1046
+ key = metaTokens ? key : key.slice(0, -2);
1047
+ // eslint-disable-next-line no-param-reassign
1048
+ value = JSON.stringify(value);
1049
+ } else if (
1050
+ (utils$1.isArray(value) && isFlatArray(value)) ||
1051
+ ((utils$1.isFileList(value) || utils$1.endsWith(key, '[]')) && (arr = utils$1.toArray(value))
1052
+ )) {
1053
+ // eslint-disable-next-line no-param-reassign
1054
+ key = removeBrackets(key);
1055
+
1056
+ arr.forEach(function each(el, index) {
1057
+ !(utils$1.isUndefined(el) || el === null) && formData.append(
1058
+ // eslint-disable-next-line no-nested-ternary
1059
+ indexes === true ? renderKey([key], index, dots) : (indexes === null ? key : key + '[]'),
1060
+ convertValue(el)
1061
+ );
1062
+ });
1063
+ return false;
1064
+ }
1065
+ }
1066
+
1067
+ if (isVisitable(value)) {
1068
+ return true;
1069
+ }
1070
+
1071
+ formData.append(renderKey(path, key, dots), convertValue(value));
1072
+
1073
+ return false;
1074
+ }
1075
+
1076
+ const stack = [];
1077
+
1078
+ const exposedHelpers = Object.assign(predicates, {
1079
+ defaultVisitor,
1080
+ convertValue,
1081
+ isVisitable
1082
+ });
1083
+
1084
+ function build(value, path) {
1085
+ if (utils$1.isUndefined(value)) return;
1086
+
1087
+ if (stack.indexOf(value) !== -1) {
1088
+ throw Error('Circular reference detected in ' + path.join('.'));
1089
+ }
1090
+
1091
+ stack.push(value);
1092
+
1093
+ utils$1.forEach(value, function each(el, key) {
1094
+ const result = !(utils$1.isUndefined(el) || el === null) && visitor.call(
1095
+ formData, el, utils$1.isString(key) ? key.trim() : key, path, exposedHelpers
1096
+ );
1097
+
1098
+ if (result === true) {
1099
+ build(el, path ? path.concat(key) : [key]);
1100
+ }
1101
+ });
1102
+
1103
+ stack.pop();
1104
+ }
1105
+
1106
+ if (!utils$1.isObject(obj)) {
1107
+ throw new TypeError('data must be an object');
1108
+ }
1109
+
1110
+ build(obj);
1111
+
1112
+ return formData;
1113
+ }
1114
+
1115
+ /**
1116
+ * It encodes a string by replacing all characters that are not in the unreserved set with
1117
+ * their percent-encoded equivalents
1118
+ *
1119
+ * @param {string} str - The string to encode.
1120
+ *
1121
+ * @returns {string} The encoded string.
1122
+ */
1123
+ function encode$1(str) {
1124
+ const charMap = {
1125
+ '!': '%21',
1126
+ "'": '%27',
1127
+ '(': '%28',
1128
+ ')': '%29',
1129
+ '~': '%7E',
1130
+ '%20': '+',
1131
+ '%00': '\x00'
1132
+ };
1133
+ return encodeURIComponent(str).replace(/[!'()~]|%20|%00/g, function replacer(match) {
1134
+ return charMap[match];
1135
+ });
1136
+ }
1137
+
1138
+ /**
1139
+ * It takes a params object and converts it to a FormData object
1140
+ *
1141
+ * @param {Object<string, any>} params - The parameters to be converted to a FormData object.
1142
+ * @param {Object<string, any>} options - The options object passed to the Axios constructor.
1143
+ *
1144
+ * @returns {void}
1145
+ */
1146
+ function AxiosURLSearchParams(params, options) {
1147
+ this._pairs = [];
1148
+
1149
+ params && toFormData(params, this, options);
1150
+ }
1151
+
1152
+ const prototype = AxiosURLSearchParams.prototype;
1153
+
1154
+ prototype.append = function append(name, value) {
1155
+ this._pairs.push([name, value]);
1156
+ };
1157
+
1158
+ prototype.toString = function toString(encoder) {
1159
+ const _encode = encoder ? function(value) {
1160
+ return encoder.call(this, value, encode$1);
1161
+ } : encode$1;
1162
+
1163
+ return this._pairs.map(function each(pair) {
1164
+ return _encode(pair[0]) + '=' + _encode(pair[1]);
1165
+ }, '').join('&');
1166
+ };
1167
+
1168
+ /**
1169
+ * It replaces all instances of the characters `:`, `$`, `,`, `+`, `[`, and `]` with their
1170
+ * URI encoded counterparts
1171
+ *
1172
+ * @param {string} val The value to be encoded.
1173
+ *
1174
+ * @returns {string} The encoded value.
1175
+ */
1176
+ function encode(val) {
1177
+ return encodeURIComponent(val).
1178
+ replace(/%3A/gi, ':').
1179
+ replace(/%24/g, '$').
1180
+ replace(/%2C/gi, ',').
1181
+ replace(/%20/g, '+');
1182
+ }
1183
+
1184
+ /**
1185
+ * Build a URL by appending params to the end
1186
+ *
1187
+ * @param {string} url The base of the url (e.g., http://www.google.com)
1188
+ * @param {object} [params] The params to be appended
1189
+ * @param {?(object|Function)} options
1190
+ *
1191
+ * @returns {string} The formatted url
1192
+ */
1193
+ function buildURL(url, params, options) {
1194
+ /*eslint no-param-reassign:0*/
1195
+ if (!params) {
1196
+ return url;
1197
+ }
1198
+
1199
+ const _encode = options && options.encode || encode;
1200
+
1201
+ if (utils$1.isFunction(options)) {
1202
+ options = {
1203
+ serialize: options
1204
+ };
1205
+ }
1206
+
1207
+ const serializeFn = options && options.serialize;
1208
+
1209
+ let serializedParams;
1210
+
1211
+ if (serializeFn) {
1212
+ serializedParams = serializeFn(params, options);
1213
+ } else {
1214
+ serializedParams = utils$1.isURLSearchParams(params) ?
1215
+ params.toString() :
1216
+ new AxiosURLSearchParams(params, options).toString(_encode);
1217
+ }
1218
+
1219
+ if (serializedParams) {
1220
+ const hashmarkIndex = url.indexOf("#");
1221
+
1222
+ if (hashmarkIndex !== -1) {
1223
+ url = url.slice(0, hashmarkIndex);
1224
+ }
1225
+ url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams;
1226
+ }
1227
+
1228
+ return url;
1229
+ }
1230
+
1231
+ class InterceptorManager {
1232
+ constructor() {
1233
+ this.handlers = [];
1234
+ }
1235
+
1236
+ /**
1237
+ * Add a new interceptor to the stack
1238
+ *
1239
+ * @param {Function} fulfilled The function to handle `then` for a `Promise`
1240
+ * @param {Function} rejected The function to handle `reject` for a `Promise`
1241
+ *
1242
+ * @return {Number} An ID used to remove interceptor later
1243
+ */
1244
+ use(fulfilled, rejected, options) {
1245
+ this.handlers.push({
1246
+ fulfilled,
1247
+ rejected,
1248
+ synchronous: options ? options.synchronous : false,
1249
+ runWhen: options ? options.runWhen : null
1250
+ });
1251
+ return this.handlers.length - 1;
1252
+ }
1253
+
1254
+ /**
1255
+ * Remove an interceptor from the stack
1256
+ *
1257
+ * @param {Number} id The ID that was returned by `use`
1258
+ *
1259
+ * @returns {Boolean} `true` if the interceptor was removed, `false` otherwise
1260
+ */
1261
+ eject(id) {
1262
+ if (this.handlers[id]) {
1263
+ this.handlers[id] = null;
1264
+ }
1265
+ }
1266
+
1267
+ /**
1268
+ * Clear all interceptors from the stack
1269
+ *
1270
+ * @returns {void}
1271
+ */
1272
+ clear() {
1273
+ if (this.handlers) {
1274
+ this.handlers = [];
1275
+ }
1276
+ }
1277
+
1278
+ /**
1279
+ * Iterate over all the registered interceptors
1280
+ *
1281
+ * This method is particularly useful for skipping over any
1282
+ * interceptors that may have become `null` calling `eject`.
1283
+ *
1284
+ * @param {Function} fn The function to call for each interceptor
1285
+ *
1286
+ * @returns {void}
1287
+ */
1288
+ forEach(fn) {
1289
+ utils$1.forEach(this.handlers, function forEachHandler(h) {
1290
+ if (h !== null) {
1291
+ fn(h);
1292
+ }
1293
+ });
1294
+ }
1295
+ }
1296
+
1297
+ var InterceptorManager$1 = InterceptorManager;
1298
+
1299
+ var transitionalDefaults = {
1300
+ silentJSONParsing: true,
1301
+ forcedJSONParsing: true,
1302
+ clarifyTimeoutError: false
1303
+ };
1304
+
1305
+ var URLSearchParams$1 = typeof URLSearchParams !== 'undefined' ? URLSearchParams : AxiosURLSearchParams;
1306
+
1307
+ var FormData$1 = typeof FormData !== 'undefined' ? FormData : null;
1308
+
1309
+ var Blob$1 = typeof Blob !== 'undefined' ? Blob : null;
1310
+
1311
+ var platform$1 = {
1312
+ isBrowser: true,
1313
+ classes: {
1314
+ URLSearchParams: URLSearchParams$1,
1315
+ FormData: FormData$1,
1316
+ Blob: Blob$1
1317
+ },
1318
+ protocols: ['http', 'https', 'file', 'blob', 'url', 'data']
1319
+ };
1320
+
1321
+ const hasBrowserEnv = typeof window !== 'undefined' && typeof document !== 'undefined';
1322
+
1323
+ const _navigator = typeof navigator === 'object' && navigator || undefined;
1324
+
1325
+ /**
1326
+ * Determine if we're running in a standard browser environment
1327
+ *
1328
+ * This allows axios to run in a web worker, and react-native.
1329
+ * Both environments support XMLHttpRequest, but not fully standard globals.
1330
+ *
1331
+ * web workers:
1332
+ * typeof window -> undefined
1333
+ * typeof document -> undefined
1334
+ *
1335
+ * react-native:
1336
+ * navigator.product -> 'ReactNative'
1337
+ * nativescript
1338
+ * navigator.product -> 'NativeScript' or 'NS'
1339
+ *
1340
+ * @returns {boolean}
1341
+ */
1342
+ const hasStandardBrowserEnv = hasBrowserEnv &&
1343
+ (!_navigator || ['ReactNative', 'NativeScript', 'NS'].indexOf(_navigator.product) < 0);
1344
+
1345
+ /**
1346
+ * Determine if we're running in a standard browser webWorker environment
1347
+ *
1348
+ * Although the `isStandardBrowserEnv` method indicates that
1349
+ * `allows axios to run in a web worker`, the WebWorker will still be
1350
+ * filtered out due to its judgment standard
1351
+ * `typeof window !== 'undefined' && typeof document !== 'undefined'`.
1352
+ * This leads to a problem when axios post `FormData` in webWorker
1353
+ */
1354
+ const hasStandardBrowserWebWorkerEnv = (() => {
1355
+ return (
1356
+ typeof WorkerGlobalScope !== 'undefined' &&
1357
+ // eslint-disable-next-line no-undef
1358
+ self instanceof WorkerGlobalScope &&
1359
+ typeof self.importScripts === 'function'
1360
+ );
1361
+ })();
1362
+
1363
+ const origin = hasBrowserEnv && window.location.href || 'http://localhost';
1364
+
1365
+ var utils = /*#__PURE__*/Object.freeze({
1366
+ __proto__: null,
1367
+ hasBrowserEnv: hasBrowserEnv,
1368
+ hasStandardBrowserWebWorkerEnv: hasStandardBrowserWebWorkerEnv,
1369
+ hasStandardBrowserEnv: hasStandardBrowserEnv,
1370
+ navigator: _navigator,
1371
+ origin: origin
1372
+ });
1373
+
1374
+ var platform = {
1375
+ ...utils,
1376
+ ...platform$1
1377
+ };
1378
+
1379
+ function toURLEncodedForm(data, options) {
1380
+ return toFormData(data, new platform.classes.URLSearchParams(), {
1381
+ visitor: function(value, key, path, helpers) {
1382
+ if (platform.isNode && utils$1.isBuffer(value)) {
1383
+ this.append(key, value.toString('base64'));
1384
+ return false;
1385
+ }
1386
+
1387
+ return helpers.defaultVisitor.apply(this, arguments);
1388
+ },
1389
+ ...options
1390
+ });
1391
+ }
1392
+
1393
+ /**
1394
+ * It takes a string like `foo[x][y][z]` and returns an array like `['foo', 'x', 'y', 'z']
1395
+ *
1396
+ * @param {string} name - The name of the property to get.
1397
+ *
1398
+ * @returns An array of strings.
1399
+ */
1400
+ function parsePropPath(name) {
1401
+ // foo[x][y][z]
1402
+ // foo.x.y.z
1403
+ // foo-x-y-z
1404
+ // foo x y z
1405
+ return utils$1.matchAll(/\w+|\[(\w*)]/g, name).map(match => {
1406
+ return match[0] === '[]' ? '' : match[1] || match[0];
1407
+ });
1408
+ }
1409
+
1410
+ /**
1411
+ * Convert an array to an object.
1412
+ *
1413
+ * @param {Array<any>} arr - The array to convert to an object.
1414
+ *
1415
+ * @returns An object with the same keys and values as the array.
1416
+ */
1417
+ function arrayToObject(arr) {
1418
+ const obj = {};
1419
+ const keys = Object.keys(arr);
1420
+ let i;
1421
+ const len = keys.length;
1422
+ let key;
1423
+ for (i = 0; i < len; i++) {
1424
+ key = keys[i];
1425
+ obj[key] = arr[key];
1426
+ }
1427
+ return obj;
1428
+ }
1429
+
1430
+ /**
1431
+ * It takes a FormData object and returns a JavaScript object
1432
+ *
1433
+ * @param {string} formData The FormData object to convert to JSON.
1434
+ *
1435
+ * @returns {Object<string, any> | null} The converted object.
1436
+ */
1437
+ function formDataToJSON(formData) {
1438
+ function buildPath(path, value, target, index) {
1439
+ let name = path[index++];
1440
+
1441
+ if (name === '__proto__') return true;
1442
+
1443
+ const isNumericKey = Number.isFinite(+name);
1444
+ const isLast = index >= path.length;
1445
+ name = !name && utils$1.isArray(target) ? target.length : name;
1446
+
1447
+ if (isLast) {
1448
+ if (utils$1.hasOwnProp(target, name)) {
1449
+ target[name] = [target[name], value];
1450
+ } else {
1451
+ target[name] = value;
1452
+ }
1453
+
1454
+ return !isNumericKey;
1455
+ }
1456
+
1457
+ if (!target[name] || !utils$1.isObject(target[name])) {
1458
+ target[name] = [];
1459
+ }
1460
+
1461
+ const result = buildPath(path, value, target[name], index);
1462
+
1463
+ if (result && utils$1.isArray(target[name])) {
1464
+ target[name] = arrayToObject(target[name]);
1465
+ }
1466
+
1467
+ return !isNumericKey;
1468
+ }
1469
+
1470
+ if (utils$1.isFormData(formData) && utils$1.isFunction(formData.entries)) {
1471
+ const obj = {};
1472
+
1473
+ utils$1.forEachEntry(formData, (name, value) => {
1474
+ buildPath(parsePropPath(name), value, obj, 0);
1475
+ });
1476
+
1477
+ return obj;
1478
+ }
1479
+
1480
+ return null;
1481
+ }
1482
+
1483
+ /**
1484
+ * It takes a string, tries to parse it, and if it fails, it returns the stringified version
1485
+ * of the input
1486
+ *
1487
+ * @param {any} rawValue - The value to be stringified.
1488
+ * @param {Function} parser - A function that parses a string into a JavaScript object.
1489
+ * @param {Function} encoder - A function that takes a value and returns a string.
1490
+ *
1491
+ * @returns {string} A stringified version of the rawValue.
1492
+ */
1493
+ function stringifySafely(rawValue, parser, encoder) {
1494
+ if (utils$1.isString(rawValue)) {
1495
+ try {
1496
+ (parser || JSON.parse)(rawValue);
1497
+ return utils$1.trim(rawValue);
1498
+ } catch (e) {
1499
+ if (e.name !== 'SyntaxError') {
1500
+ throw e;
1501
+ }
1502
+ }
1503
+ }
1504
+
1505
+ return (encoder || JSON.stringify)(rawValue);
1506
+ }
1507
+
1508
+ const defaults = {
1509
+
1510
+ transitional: transitionalDefaults,
1511
+
1512
+ adapter: ['xhr', 'http', 'fetch'],
1513
+
1514
+ transformRequest: [function transformRequest(data, headers) {
1515
+ const contentType = headers.getContentType() || '';
1516
+ const hasJSONContentType = contentType.indexOf('application/json') > -1;
1517
+ const isObjectPayload = utils$1.isObject(data);
1518
+
1519
+ if (isObjectPayload && utils$1.isHTMLForm(data)) {
1520
+ data = new FormData(data);
1521
+ }
1522
+
1523
+ const isFormData = utils$1.isFormData(data);
1524
+
1525
+ if (isFormData) {
1526
+ return hasJSONContentType ? JSON.stringify(formDataToJSON(data)) : data;
1527
+ }
1528
+
1529
+ if (utils$1.isArrayBuffer(data) ||
1530
+ utils$1.isBuffer(data) ||
1531
+ utils$1.isStream(data) ||
1532
+ utils$1.isFile(data) ||
1533
+ utils$1.isBlob(data) ||
1534
+ utils$1.isReadableStream(data)
1535
+ ) {
1536
+ return data;
1537
+ }
1538
+ if (utils$1.isArrayBufferView(data)) {
1539
+ return data.buffer;
1540
+ }
1541
+ if (utils$1.isURLSearchParams(data)) {
1542
+ headers.setContentType('application/x-www-form-urlencoded;charset=utf-8', false);
1543
+ return data.toString();
1544
+ }
1545
+
1546
+ let isFileList;
1547
+
1548
+ if (isObjectPayload) {
1549
+ if (contentType.indexOf('application/x-www-form-urlencoded') > -1) {
1550
+ return toURLEncodedForm(data, this.formSerializer).toString();
1551
+ }
1552
+
1553
+ if ((isFileList = utils$1.isFileList(data)) || contentType.indexOf('multipart/form-data') > -1) {
1554
+ const _FormData = this.env && this.env.FormData;
1555
+
1556
+ return toFormData(
1557
+ isFileList ? {'files[]': data} : data,
1558
+ _FormData && new _FormData(),
1559
+ this.formSerializer
1560
+ );
1561
+ }
1562
+ }
1563
+
1564
+ if (isObjectPayload || hasJSONContentType ) {
1565
+ headers.setContentType('application/json', false);
1566
+ return stringifySafely(data);
1567
+ }
1568
+
1569
+ return data;
1570
+ }],
1571
+
1572
+ transformResponse: [function transformResponse(data) {
1573
+ const transitional = this.transitional || defaults.transitional;
1574
+ const forcedJSONParsing = transitional && transitional.forcedJSONParsing;
1575
+ const JSONRequested = this.responseType === 'json';
1576
+
1577
+ if (utils$1.isResponse(data) || utils$1.isReadableStream(data)) {
1578
+ return data;
1579
+ }
1580
+
1581
+ if (data && utils$1.isString(data) && ((forcedJSONParsing && !this.responseType) || JSONRequested)) {
1582
+ const silentJSONParsing = transitional && transitional.silentJSONParsing;
1583
+ const strictJSONParsing = !silentJSONParsing && JSONRequested;
1584
+
1585
+ try {
1586
+ return JSON.parse(data, this.parseReviver);
1587
+ } catch (e) {
1588
+ if (strictJSONParsing) {
1589
+ if (e.name === 'SyntaxError') {
1590
+ throw AxiosError.from(e, AxiosError.ERR_BAD_RESPONSE, this, null, this.response);
1591
+ }
1592
+ throw e;
1593
+ }
1594
+ }
1595
+ }
1596
+
1597
+ return data;
1598
+ }],
1599
+
1600
+ /**
1601
+ * A timeout in milliseconds to abort a request. If set to 0 (default) a
1602
+ * timeout is not created.
1603
+ */
1604
+ timeout: 0,
1605
+
1606
+ xsrfCookieName: 'XSRF-TOKEN',
1607
+ xsrfHeaderName: 'X-XSRF-TOKEN',
1608
+
1609
+ maxContentLength: -1,
1610
+ maxBodyLength: -1,
1611
+
1612
+ env: {
1613
+ FormData: platform.classes.FormData,
1614
+ Blob: platform.classes.Blob
1615
+ },
1616
+
1617
+ validateStatus: function validateStatus(status) {
1618
+ return status >= 200 && status < 300;
1619
+ },
1620
+
1621
+ headers: {
1622
+ common: {
1623
+ 'Accept': 'application/json, text/plain, */*',
1624
+ 'Content-Type': undefined
1625
+ }
1626
+ }
1627
+ };
1628
+
1629
+ utils$1.forEach(['delete', 'get', 'head', 'post', 'put', 'patch'], (method) => {
1630
+ defaults.headers[method] = {};
1631
+ });
1632
+
1633
+ var defaults$1 = defaults;
1634
+
1635
+ // RawAxiosHeaders whose duplicates are ignored by node
1636
+ // c.f. https://nodejs.org/api/http.html#http_message_headers
1637
+ const ignoreDuplicateOf = utils$1.toObjectSet([
1638
+ 'age', 'authorization', 'content-length', 'content-type', 'etag',
1639
+ 'expires', 'from', 'host', 'if-modified-since', 'if-unmodified-since',
1640
+ 'last-modified', 'location', 'max-forwards', 'proxy-authorization',
1641
+ 'referer', 'retry-after', 'user-agent'
1642
+ ]);
1643
+
1644
+ /**
1645
+ * Parse headers into an object
1646
+ *
1647
+ * ```
1648
+ * Date: Wed, 27 Aug 2014 08:58:49 GMT
1649
+ * Content-Type: application/json
1650
+ * Connection: keep-alive
1651
+ * Transfer-Encoding: chunked
1652
+ * ```
1653
+ *
1654
+ * @param {String} rawHeaders Headers needing to be parsed
1655
+ *
1656
+ * @returns {Object} Headers parsed into an object
1657
+ */
1658
+ var parseHeaders = rawHeaders => {
1659
+ const parsed = {};
1660
+ let key;
1661
+ let val;
1662
+ let i;
1663
+
1664
+ rawHeaders && rawHeaders.split('\n').forEach(function parser(line) {
1665
+ i = line.indexOf(':');
1666
+ key = line.substring(0, i).trim().toLowerCase();
1667
+ val = line.substring(i + 1).trim();
1668
+
1669
+ if (!key || (parsed[key] && ignoreDuplicateOf[key])) {
1670
+ return;
1671
+ }
1672
+
1673
+ if (key === 'set-cookie') {
1674
+ if (parsed[key]) {
1675
+ parsed[key].push(val);
1676
+ } else {
1677
+ parsed[key] = [val];
1678
+ }
1679
+ } else {
1680
+ parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val;
1681
+ }
1682
+ });
1683
+
1684
+ return parsed;
1685
+ };
1686
+
1687
+ const $internals = Symbol('internals');
1688
+
1689
+ function normalizeHeader(header) {
1690
+ return header && String(header).trim().toLowerCase();
1691
+ }
1692
+
1693
+ function normalizeValue(value) {
1694
+ if (value === false || value == null) {
1695
+ return value;
1696
+ }
1697
+
1698
+ return utils$1.isArray(value) ? value.map(normalizeValue) : String(value);
1699
+ }
1700
+
1701
+ function parseTokens(str) {
1702
+ const tokens = Object.create(null);
1703
+ const tokensRE = /([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;
1704
+ let match;
1705
+
1706
+ while ((match = tokensRE.exec(str))) {
1707
+ tokens[match[1]] = match[2];
1708
+ }
1709
+
1710
+ return tokens;
1711
+ }
1712
+
1713
+ const isValidHeaderName = (str) => /^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(str.trim());
1714
+
1715
+ function matchHeaderValue(context, value, header, filter, isHeaderNameFilter) {
1716
+ if (utils$1.isFunction(filter)) {
1717
+ return filter.call(this, value, header);
1718
+ }
1719
+
1720
+ if (isHeaderNameFilter) {
1721
+ value = header;
1722
+ }
1723
+
1724
+ if (!utils$1.isString(value)) return;
1725
+
1726
+ if (utils$1.isString(filter)) {
1727
+ return value.indexOf(filter) !== -1;
1728
+ }
1729
+
1730
+ if (utils$1.isRegExp(filter)) {
1731
+ return filter.test(value);
1732
+ }
1733
+ }
1734
+
1735
+ function formatHeader(header) {
1736
+ return header.trim()
1737
+ .toLowerCase().replace(/([a-z\d])(\w*)/g, (w, char, str) => {
1738
+ return char.toUpperCase() + str;
1739
+ });
1740
+ }
1741
+
1742
+ function buildAccessors(obj, header) {
1743
+ const accessorName = utils$1.toCamelCase(' ' + header);
1744
+
1745
+ ['get', 'set', 'has'].forEach(methodName => {
1746
+ Object.defineProperty(obj, methodName + accessorName, {
1747
+ value: function(arg1, arg2, arg3) {
1748
+ return this[methodName].call(this, header, arg1, arg2, arg3);
1749
+ },
1750
+ configurable: true
1751
+ });
1752
+ });
1753
+ }
1754
+
1755
+ class AxiosHeaders {
1756
+ constructor(headers) {
1757
+ headers && this.set(headers);
1758
+ }
1759
+
1760
+ set(header, valueOrRewrite, rewrite) {
1761
+ const self = this;
1762
+
1763
+ function setHeader(_value, _header, _rewrite) {
1764
+ const lHeader = normalizeHeader(_header);
1765
+
1766
+ if (!lHeader) {
1767
+ throw new Error('header name must be a non-empty string');
1768
+ }
1769
+
1770
+ const key = utils$1.findKey(self, lHeader);
1771
+
1772
+ if(!key || self[key] === undefined || _rewrite === true || (_rewrite === undefined && self[key] !== false)) {
1773
+ self[key || _header] = normalizeValue(_value);
1774
+ }
1775
+ }
1776
+
1777
+ const setHeaders = (headers, _rewrite) =>
1778
+ utils$1.forEach(headers, (_value, _header) => setHeader(_value, _header, _rewrite));
1779
+
1780
+ if (utils$1.isPlainObject(header) || header instanceof this.constructor) {
1781
+ setHeaders(header, valueOrRewrite);
1782
+ } else if(utils$1.isString(header) && (header = header.trim()) && !isValidHeaderName(header)) {
1783
+ setHeaders(parseHeaders(header), valueOrRewrite);
1784
+ } else if (utils$1.isObject(header) && utils$1.isIterable(header)) {
1785
+ let obj = {}, dest, key;
1786
+ for (const entry of header) {
1787
+ if (!utils$1.isArray(entry)) {
1788
+ throw TypeError('Object iterator must return a key-value pair');
1789
+ }
1790
+
1791
+ obj[key = entry[0]] = (dest = obj[key]) ?
1792
+ (utils$1.isArray(dest) ? [...dest, entry[1]] : [dest, entry[1]]) : entry[1];
1793
+ }
1794
+
1795
+ setHeaders(obj, valueOrRewrite);
1796
+ } else {
1797
+ header != null && setHeader(valueOrRewrite, header, rewrite);
1798
+ }
1799
+
1800
+ return this;
1801
+ }
1802
+
1803
+ get(header, parser) {
1804
+ header = normalizeHeader(header);
1805
+
1806
+ if (header) {
1807
+ const key = utils$1.findKey(this, header);
1808
+
1809
+ if (key) {
1810
+ const value = this[key];
1811
+
1812
+ if (!parser) {
1813
+ return value;
1814
+ }
1815
+
1816
+ if (parser === true) {
1817
+ return parseTokens(value);
1818
+ }
1819
+
1820
+ if (utils$1.isFunction(parser)) {
1821
+ return parser.call(this, value, key);
1822
+ }
1823
+
1824
+ if (utils$1.isRegExp(parser)) {
1825
+ return parser.exec(value);
1826
+ }
1827
+
1828
+ throw new TypeError('parser must be boolean|regexp|function');
1829
+ }
1830
+ }
1831
+ }
1832
+
1833
+ has(header, matcher) {
1834
+ header = normalizeHeader(header);
1835
+
1836
+ if (header) {
1837
+ const key = utils$1.findKey(this, header);
1838
+
1839
+ return !!(key && this[key] !== undefined && (!matcher || matchHeaderValue(this, this[key], key, matcher)));
1840
+ }
1841
+
1842
+ return false;
1843
+ }
1844
+
1845
+ delete(header, matcher) {
1846
+ const self = this;
1847
+ let deleted = false;
1848
+
1849
+ function deleteHeader(_header) {
1850
+ _header = normalizeHeader(_header);
1851
+
1852
+ if (_header) {
1853
+ const key = utils$1.findKey(self, _header);
1854
+
1855
+ if (key && (!matcher || matchHeaderValue(self, self[key], key, matcher))) {
1856
+ delete self[key];
1857
+
1858
+ deleted = true;
1859
+ }
1860
+ }
1861
+ }
1862
+
1863
+ if (utils$1.isArray(header)) {
1864
+ header.forEach(deleteHeader);
1865
+ } else {
1866
+ deleteHeader(header);
1867
+ }
1868
+
1869
+ return deleted;
1870
+ }
1871
+
1872
+ clear(matcher) {
1873
+ const keys = Object.keys(this);
1874
+ let i = keys.length;
1875
+ let deleted = false;
1876
+
1877
+ while (i--) {
1878
+ const key = keys[i];
1879
+ if(!matcher || matchHeaderValue(this, this[key], key, matcher, true)) {
1880
+ delete this[key];
1881
+ deleted = true;
1882
+ }
1883
+ }
1884
+
1885
+ return deleted;
1886
+ }
1887
+
1888
+ normalize(format) {
1889
+ const self = this;
1890
+ const headers = {};
1891
+
1892
+ utils$1.forEach(this, (value, header) => {
1893
+ const key = utils$1.findKey(headers, header);
1894
+
1895
+ if (key) {
1896
+ self[key] = normalizeValue(value);
1897
+ delete self[header];
1898
+ return;
1899
+ }
1900
+
1901
+ const normalized = format ? formatHeader(header) : String(header).trim();
1902
+
1903
+ if (normalized !== header) {
1904
+ delete self[header];
1905
+ }
1906
+
1907
+ self[normalized] = normalizeValue(value);
1908
+
1909
+ headers[normalized] = true;
1910
+ });
1911
+
1912
+ return this;
1913
+ }
1914
+
1915
+ concat(...targets) {
1916
+ return this.constructor.concat(this, ...targets);
1917
+ }
1918
+
1919
+ toJSON(asStrings) {
1920
+ const obj = Object.create(null);
1921
+
1922
+ utils$1.forEach(this, (value, header) => {
1923
+ value != null && value !== false && (obj[header] = asStrings && utils$1.isArray(value) ? value.join(', ') : value);
1924
+ });
1925
+
1926
+ return obj;
1927
+ }
1928
+
1929
+ [Symbol.iterator]() {
1930
+ return Object.entries(this.toJSON())[Symbol.iterator]();
1931
+ }
1932
+
1933
+ toString() {
1934
+ return Object.entries(this.toJSON()).map(([header, value]) => header + ': ' + value).join('\n');
1935
+ }
1936
+
1937
+ getSetCookie() {
1938
+ return this.get("set-cookie") || [];
1939
+ }
1940
+
1941
+ get [Symbol.toStringTag]() {
1942
+ return 'AxiosHeaders';
1943
+ }
1944
+
1945
+ static from(thing) {
1946
+ return thing instanceof this ? thing : new this(thing);
1947
+ }
1948
+
1949
+ static concat(first, ...targets) {
1950
+ const computed = new this(first);
1951
+
1952
+ targets.forEach((target) => computed.set(target));
1953
+
1954
+ return computed;
1955
+ }
1956
+
1957
+ static accessor(header) {
1958
+ const internals = this[$internals] = (this[$internals] = {
1959
+ accessors: {}
1960
+ });
1961
+
1962
+ const accessors = internals.accessors;
1963
+ const prototype = this.prototype;
1964
+
1965
+ function defineAccessor(_header) {
1966
+ const lHeader = normalizeHeader(_header);
1967
+
1968
+ if (!accessors[lHeader]) {
1969
+ buildAccessors(prototype, _header);
1970
+ accessors[lHeader] = true;
1971
+ }
1972
+ }
1973
+
1974
+ utils$1.isArray(header) ? header.forEach(defineAccessor) : defineAccessor(header);
1975
+
1976
+ return this;
1977
+ }
1978
+ }
1979
+
1980
+ AxiosHeaders.accessor(['Content-Type', 'Content-Length', 'Accept', 'Accept-Encoding', 'User-Agent', 'Authorization']);
1981
+
1982
+ // reserved names hotfix
1983
+ utils$1.reduceDescriptors(AxiosHeaders.prototype, ({value}, key) => {
1984
+ let mapped = key[0].toUpperCase() + key.slice(1); // map `set` => `Set`
1985
+ return {
1986
+ get: () => value,
1987
+ set(headerValue) {
1988
+ this[mapped] = headerValue;
1989
+ }
1990
+ }
1991
+ });
1992
+
1993
+ utils$1.freezeMethods(AxiosHeaders);
1994
+
1995
+ var AxiosHeaders$1 = AxiosHeaders;
1996
+
1997
+ /**
1998
+ * Transform the data for a request or a response
1999
+ *
2000
+ * @param {Array|Function} fns A single function or Array of functions
2001
+ * @param {?Object} response The response object
2002
+ *
2003
+ * @returns {*} The resulting transformed data
2004
+ */
2005
+ function transformData(fns, response) {
2006
+ const config = this || defaults$1;
2007
+ const context = response || config;
2008
+ const headers = AxiosHeaders$1.from(context.headers);
2009
+ let data = context.data;
2010
+
2011
+ utils$1.forEach(fns, function transform(fn) {
2012
+ data = fn.call(config, data, headers.normalize(), response ? response.status : undefined);
2013
+ });
2014
+
2015
+ headers.normalize();
2016
+
2017
+ return data;
2018
+ }
2019
+
2020
+ function isCancel(value) {
2021
+ return !!(value && value.__CANCEL__);
2022
+ }
2023
+
2024
+ /**
2025
+ * A `CanceledError` is an object that is thrown when an operation is canceled.
2026
+ *
2027
+ * @param {string=} message The message.
2028
+ * @param {Object=} config The config.
2029
+ * @param {Object=} request The request.
2030
+ *
2031
+ * @returns {CanceledError} The created error.
2032
+ */
2033
+ function CanceledError(message, config, request) {
2034
+ // eslint-disable-next-line no-eq-null,eqeqeq
2035
+ AxiosError.call(this, message == null ? 'canceled' : message, AxiosError.ERR_CANCELED, config, request);
2036
+ this.name = 'CanceledError';
2037
+ }
2038
+
2039
+ utils$1.inherits(CanceledError, AxiosError, {
2040
+ __CANCEL__: true
2041
+ });
2042
+
2043
+ /**
2044
+ * Resolve or reject a Promise based on response status.
2045
+ *
2046
+ * @param {Function} resolve A function that resolves the promise.
2047
+ * @param {Function} reject A function that rejects the promise.
2048
+ * @param {object} response The response.
2049
+ *
2050
+ * @returns {object} The response.
2051
+ */
2052
+ function settle(resolve, reject, response) {
2053
+ const validateStatus = response.config.validateStatus;
2054
+ if (!response.status || !validateStatus || validateStatus(response.status)) {
2055
+ resolve(response);
2056
+ } else {
2057
+ reject(new AxiosError(
2058
+ 'Request failed with status code ' + response.status,
2059
+ [AxiosError.ERR_BAD_REQUEST, AxiosError.ERR_BAD_RESPONSE][Math.floor(response.status / 100) - 4],
2060
+ response.config,
2061
+ response.request,
2062
+ response
2063
+ ));
2064
+ }
2065
+ }
2066
+
2067
+ function parseProtocol(url) {
2068
+ const match = /^([-+\w]{1,25})(:?\/\/|:)/.exec(url);
2069
+ return match && match[1] || '';
2070
+ }
2071
+
2072
+ /**
2073
+ * Calculate data maxRate
2074
+ * @param {Number} [samplesCount= 10]
2075
+ * @param {Number} [min= 1000]
2076
+ * @returns {Function}
2077
+ */
2078
+ function speedometer(samplesCount, min) {
2079
+ samplesCount = samplesCount || 10;
2080
+ const bytes = new Array(samplesCount);
2081
+ const timestamps = new Array(samplesCount);
2082
+ let head = 0;
2083
+ let tail = 0;
2084
+ let firstSampleTS;
2085
+
2086
+ min = min !== undefined ? min : 1000;
2087
+
2088
+ return function push(chunkLength) {
2089
+ const now = Date.now();
2090
+
2091
+ const startedAt = timestamps[tail];
2092
+
2093
+ if (!firstSampleTS) {
2094
+ firstSampleTS = now;
2095
+ }
2096
+
2097
+ bytes[head] = chunkLength;
2098
+ timestamps[head] = now;
2099
+
2100
+ let i = tail;
2101
+ let bytesCount = 0;
2102
+
2103
+ while (i !== head) {
2104
+ bytesCount += bytes[i++];
2105
+ i = i % samplesCount;
2106
+ }
2107
+
2108
+ head = (head + 1) % samplesCount;
2109
+
2110
+ if (head === tail) {
2111
+ tail = (tail + 1) % samplesCount;
2112
+ }
2113
+
2114
+ if (now - firstSampleTS < min) {
2115
+ return;
2116
+ }
2117
+
2118
+ const passed = startedAt && now - startedAt;
2119
+
2120
+ return passed ? Math.round(bytesCount * 1000 / passed) : undefined;
2121
+ };
2122
+ }
2123
+
2124
+ /**
2125
+ * Throttle decorator
2126
+ * @param {Function} fn
2127
+ * @param {Number} freq
2128
+ * @return {Function}
2129
+ */
2130
+ function throttle(fn, freq) {
2131
+ let timestamp = 0;
2132
+ let threshold = 1000 / freq;
2133
+ let lastArgs;
2134
+ let timer;
2135
+
2136
+ const invoke = (args, now = Date.now()) => {
2137
+ timestamp = now;
2138
+ lastArgs = null;
2139
+ if (timer) {
2140
+ clearTimeout(timer);
2141
+ timer = null;
2142
+ }
2143
+ fn(...args);
2144
+ };
2145
+
2146
+ const throttled = (...args) => {
2147
+ const now = Date.now();
2148
+ const passed = now - timestamp;
2149
+ if ( passed >= threshold) {
2150
+ invoke(args, now);
2151
+ } else {
2152
+ lastArgs = args;
2153
+ if (!timer) {
2154
+ timer = setTimeout(() => {
2155
+ timer = null;
2156
+ invoke(lastArgs);
2157
+ }, threshold - passed);
2158
+ }
2159
+ }
2160
+ };
2161
+
2162
+ const flush = () => lastArgs && invoke(lastArgs);
2163
+
2164
+ return [throttled, flush];
2165
+ }
2166
+
2167
+ const progressEventReducer = (listener, isDownloadStream, freq = 3) => {
2168
+ let bytesNotified = 0;
2169
+ const _speedometer = speedometer(50, 250);
2170
+
2171
+ return throttle(e => {
2172
+ const loaded = e.loaded;
2173
+ const total = e.lengthComputable ? e.total : undefined;
2174
+ const progressBytes = loaded - bytesNotified;
2175
+ const rate = _speedometer(progressBytes);
2176
+ const inRange = loaded <= total;
2177
+
2178
+ bytesNotified = loaded;
2179
+
2180
+ const data = {
2181
+ loaded,
2182
+ total,
2183
+ progress: total ? (loaded / total) : undefined,
2184
+ bytes: progressBytes,
2185
+ rate: rate ? rate : undefined,
2186
+ estimated: rate && total && inRange ? (total - loaded) / rate : undefined,
2187
+ event: e,
2188
+ lengthComputable: total != null,
2189
+ [isDownloadStream ? 'download' : 'upload']: true
2190
+ };
2191
+
2192
+ listener(data);
2193
+ }, freq);
2194
+ };
2195
+
2196
+ const progressEventDecorator = (total, throttled) => {
2197
+ const lengthComputable = total != null;
2198
+
2199
+ return [(loaded) => throttled[0]({
2200
+ lengthComputable,
2201
+ total,
2202
+ loaded
2203
+ }), throttled[1]];
2204
+ };
2205
+
2206
+ const asyncDecorator = (fn) => (...args) => utils$1.asap(() => fn(...args));
2207
+
2208
+ var isURLSameOrigin = platform.hasStandardBrowserEnv ? ((origin, isMSIE) => (url) => {
2209
+ url = new URL(url, platform.origin);
2210
+
2211
+ return (
2212
+ origin.protocol === url.protocol &&
2213
+ origin.host === url.host &&
2214
+ (isMSIE || origin.port === url.port)
2215
+ );
2216
+ })(
2217
+ new URL(platform.origin),
2218
+ platform.navigator && /(msie|trident)/i.test(platform.navigator.userAgent)
2219
+ ) : () => true;
2220
+
2221
+ var cookies = platform.hasStandardBrowserEnv ?
2222
+
2223
+ // Standard browser envs support document.cookie
2224
+ {
2225
+ write(name, value, expires, path, domain, secure) {
2226
+ const cookie = [name + '=' + encodeURIComponent(value)];
2227
+
2228
+ utils$1.isNumber(expires) && cookie.push('expires=' + new Date(expires).toGMTString());
2229
+
2230
+ utils$1.isString(path) && cookie.push('path=' + path);
2231
+
2232
+ utils$1.isString(domain) && cookie.push('domain=' + domain);
2233
+
2234
+ secure === true && cookie.push('secure');
2235
+
2236
+ document.cookie = cookie.join('; ');
2237
+ },
2238
+
2239
+ read(name) {
2240
+ const match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)'));
2241
+ return (match ? decodeURIComponent(match[3]) : null);
2242
+ },
2243
+
2244
+ remove(name) {
2245
+ this.write(name, '', Date.now() - 86400000);
2246
+ }
2247
+ }
2248
+
2249
+ :
2250
+
2251
+ // Non-standard browser env (web workers, react-native) lack needed support.
2252
+ {
2253
+ write() {},
2254
+ read() {
2255
+ return null;
2256
+ },
2257
+ remove() {}
2258
+ };
2259
+
2260
+ /**
2261
+ * Determines whether the specified URL is absolute
2262
+ *
2263
+ * @param {string} url The URL to test
2264
+ *
2265
+ * @returns {boolean} True if the specified URL is absolute, otherwise false
2266
+ */
2267
+ function isAbsoluteURL(url) {
2268
+ // A URL is considered absolute if it begins with "<scheme>://" or "//" (protocol-relative URL).
2269
+ // RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed
2270
+ // by any combination of letters, digits, plus, period, or hyphen.
2271
+ return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(url);
2272
+ }
2273
+
2274
+ /**
2275
+ * Creates a new URL by combining the specified URLs
2276
+ *
2277
+ * @param {string} baseURL The base URL
2278
+ * @param {string} relativeURL The relative URL
2279
+ *
2280
+ * @returns {string} The combined URL
2281
+ */
2282
+ function combineURLs(baseURL, relativeURL) {
2283
+ return relativeURL
2284
+ ? baseURL.replace(/\/?\/$/, '') + '/' + relativeURL.replace(/^\/+/, '')
2285
+ : baseURL;
2286
+ }
2287
+
2288
+ /**
2289
+ * Creates a new URL by combining the baseURL with the requestedURL,
2290
+ * only when the requestedURL is not already an absolute URL.
2291
+ * If the requestURL is absolute, this function returns the requestedURL untouched.
2292
+ *
2293
+ * @param {string} baseURL The base URL
2294
+ * @param {string} requestedURL Absolute or relative URL to combine
2295
+ *
2296
+ * @returns {string} The combined full path
2297
+ */
2298
+ function buildFullPath(baseURL, requestedURL, allowAbsoluteUrls) {
2299
+ let isRelativeUrl = !isAbsoluteURL(requestedURL);
2300
+ if (baseURL && (isRelativeUrl || allowAbsoluteUrls == false)) {
2301
+ return combineURLs(baseURL, requestedURL);
2302
+ }
2303
+ return requestedURL;
2304
+ }
2305
+
2306
+ const headersToObject = (thing) => thing instanceof AxiosHeaders$1 ? { ...thing } : thing;
2307
+
2308
+ /**
2309
+ * Config-specific merge-function which creates a new config-object
2310
+ * by merging two configuration objects together.
2311
+ *
2312
+ * @param {Object} config1
2313
+ * @param {Object} config2
2314
+ *
2315
+ * @returns {Object} New object resulting from merging config2 to config1
2316
+ */
2317
+ function mergeConfig(config1, config2) {
2318
+ // eslint-disable-next-line no-param-reassign
2319
+ config2 = config2 || {};
2320
+ const config = {};
2321
+
2322
+ function getMergedValue(target, source, prop, caseless) {
2323
+ if (utils$1.isPlainObject(target) && utils$1.isPlainObject(source)) {
2324
+ return utils$1.merge.call({caseless}, target, source);
2325
+ } else if (utils$1.isPlainObject(source)) {
2326
+ return utils$1.merge({}, source);
2327
+ } else if (utils$1.isArray(source)) {
2328
+ return source.slice();
2329
+ }
2330
+ return source;
2331
+ }
2332
+
2333
+ // eslint-disable-next-line consistent-return
2334
+ function mergeDeepProperties(a, b, prop , caseless) {
2335
+ if (!utils$1.isUndefined(b)) {
2336
+ return getMergedValue(a, b, prop , caseless);
2337
+ } else if (!utils$1.isUndefined(a)) {
2338
+ return getMergedValue(undefined, a, prop , caseless);
2339
+ }
2340
+ }
2341
+
2342
+ // eslint-disable-next-line consistent-return
2343
+ function valueFromConfig2(a, b) {
2344
+ if (!utils$1.isUndefined(b)) {
2345
+ return getMergedValue(undefined, b);
2346
+ }
2347
+ }
2348
+
2349
+ // eslint-disable-next-line consistent-return
2350
+ function defaultToConfig2(a, b) {
2351
+ if (!utils$1.isUndefined(b)) {
2352
+ return getMergedValue(undefined, b);
2353
+ } else if (!utils$1.isUndefined(a)) {
2354
+ return getMergedValue(undefined, a);
2355
+ }
2356
+ }
2357
+
2358
+ // eslint-disable-next-line consistent-return
2359
+ function mergeDirectKeys(a, b, prop) {
2360
+ if (prop in config2) {
2361
+ return getMergedValue(a, b);
2362
+ } else if (prop in config1) {
2363
+ return getMergedValue(undefined, a);
2364
+ }
2365
+ }
2366
+
2367
+ const mergeMap = {
2368
+ url: valueFromConfig2,
2369
+ method: valueFromConfig2,
2370
+ data: valueFromConfig2,
2371
+ baseURL: defaultToConfig2,
2372
+ transformRequest: defaultToConfig2,
2373
+ transformResponse: defaultToConfig2,
2374
+ paramsSerializer: defaultToConfig2,
2375
+ timeout: defaultToConfig2,
2376
+ timeoutMessage: defaultToConfig2,
2377
+ withCredentials: defaultToConfig2,
2378
+ withXSRFToken: defaultToConfig2,
2379
+ adapter: defaultToConfig2,
2380
+ responseType: defaultToConfig2,
2381
+ xsrfCookieName: defaultToConfig2,
2382
+ xsrfHeaderName: defaultToConfig2,
2383
+ onUploadProgress: defaultToConfig2,
2384
+ onDownloadProgress: defaultToConfig2,
2385
+ decompress: defaultToConfig2,
2386
+ maxContentLength: defaultToConfig2,
2387
+ maxBodyLength: defaultToConfig2,
2388
+ beforeRedirect: defaultToConfig2,
2389
+ transport: defaultToConfig2,
2390
+ httpAgent: defaultToConfig2,
2391
+ httpsAgent: defaultToConfig2,
2392
+ cancelToken: defaultToConfig2,
2393
+ socketPath: defaultToConfig2,
2394
+ responseEncoding: defaultToConfig2,
2395
+ validateStatus: mergeDirectKeys,
2396
+ headers: (a, b , prop) => mergeDeepProperties(headersToObject(a), headersToObject(b),prop, true)
2397
+ };
2398
+
2399
+ utils$1.forEach(Object.keys({...config1, ...config2}), function computeConfigValue(prop) {
2400
+ const merge = mergeMap[prop] || mergeDeepProperties;
2401
+ const configValue = merge(config1[prop], config2[prop], prop);
2402
+ (utils$1.isUndefined(configValue) && merge !== mergeDirectKeys) || (config[prop] = configValue);
2403
+ });
2404
+
2405
+ return config;
2406
+ }
2407
+
2408
+ var resolveConfig = (config) => {
2409
+ const newConfig = mergeConfig({}, config);
2410
+
2411
+ let { data, withXSRFToken, xsrfHeaderName, xsrfCookieName, headers, auth } = newConfig;
2412
+
2413
+ newConfig.headers = headers = AxiosHeaders$1.from(headers);
2414
+
2415
+ newConfig.url = buildURL(buildFullPath(newConfig.baseURL, newConfig.url, newConfig.allowAbsoluteUrls), config.params, config.paramsSerializer);
2416
+
2417
+ // HTTP basic authentication
2418
+ if (auth) {
2419
+ headers.set('Authorization', 'Basic ' +
2420
+ btoa((auth.username || '') + ':' + (auth.password ? unescape(encodeURIComponent(auth.password)) : ''))
2421
+ );
2422
+ }
2423
+
2424
+ if (utils$1.isFormData(data)) {
2425
+ if (platform.hasStandardBrowserEnv || platform.hasStandardBrowserWebWorkerEnv) {
2426
+ headers.setContentType(undefined); // browser handles it
2427
+ } else if (utils$1.isFunction(data.getHeaders)) {
2428
+ // Node.js FormData (like form-data package)
2429
+ const formHeaders = data.getHeaders();
2430
+ // Only set safe headers to avoid overwriting security headers
2431
+ const allowedHeaders = ['content-type', 'content-length'];
2432
+ Object.entries(formHeaders).forEach(([key, val]) => {
2433
+ if (allowedHeaders.includes(key.toLowerCase())) {
2434
+ headers.set(key, val);
2435
+ }
2436
+ });
2437
+ }
2438
+ }
2439
+
2440
+ // Add xsrf header
2441
+ // This is only done if running in a standard browser environment.
2442
+ // Specifically not if we're in a web worker, or react-native.
2443
+
2444
+ if (platform.hasStandardBrowserEnv) {
2445
+ withXSRFToken && utils$1.isFunction(withXSRFToken) && (withXSRFToken = withXSRFToken(newConfig));
2446
+
2447
+ if (withXSRFToken || (withXSRFToken !== false && isURLSameOrigin(newConfig.url))) {
2448
+ // Add xsrf header
2449
+ const xsrfValue = xsrfHeaderName && xsrfCookieName && cookies.read(xsrfCookieName);
2450
+
2451
+ if (xsrfValue) {
2452
+ headers.set(xsrfHeaderName, xsrfValue);
2453
+ }
2454
+ }
2455
+ }
2456
+
2457
+ return newConfig;
2458
+ };
2459
+
2460
+ const isXHRAdapterSupported = typeof XMLHttpRequest !== 'undefined';
2461
+
2462
+ var xhrAdapter = isXHRAdapterSupported && function (config) {
2463
+ return new Promise(function dispatchXhrRequest(resolve, reject) {
2464
+ const _config = resolveConfig(config);
2465
+ let requestData = _config.data;
2466
+ const requestHeaders = AxiosHeaders$1.from(_config.headers).normalize();
2467
+ let {responseType, onUploadProgress, onDownloadProgress} = _config;
2468
+ let onCanceled;
2469
+ let uploadThrottled, downloadThrottled;
2470
+ let flushUpload, flushDownload;
2471
+
2472
+ function done() {
2473
+ flushUpload && flushUpload(); // flush events
2474
+ flushDownload && flushDownload(); // flush events
2475
+
2476
+ _config.cancelToken && _config.cancelToken.unsubscribe(onCanceled);
2477
+
2478
+ _config.signal && _config.signal.removeEventListener('abort', onCanceled);
2479
+ }
2480
+
2481
+ let request = new XMLHttpRequest();
2482
+
2483
+ request.open(_config.method.toUpperCase(), _config.url, true);
2484
+
2485
+ // Set the request timeout in MS
2486
+ request.timeout = _config.timeout;
2487
+
2488
+ function onloadend() {
2489
+ if (!request) {
2490
+ return;
2491
+ }
2492
+ // Prepare the response
2493
+ const responseHeaders = AxiosHeaders$1.from(
2494
+ 'getAllResponseHeaders' in request && request.getAllResponseHeaders()
2495
+ );
2496
+ const responseData = !responseType || responseType === 'text' || responseType === 'json' ?
2497
+ request.responseText : request.response;
2498
+ const response = {
2499
+ data: responseData,
2500
+ status: request.status,
2501
+ statusText: request.statusText,
2502
+ headers: responseHeaders,
2503
+ config,
2504
+ request
2505
+ };
2506
+
2507
+ settle(function _resolve(value) {
2508
+ resolve(value);
2509
+ done();
2510
+ }, function _reject(err) {
2511
+ reject(err);
2512
+ done();
2513
+ }, response);
2514
+
2515
+ // Clean up request
2516
+ request = null;
2517
+ }
2518
+
2519
+ if ('onloadend' in request) {
2520
+ // Use onloadend if available
2521
+ request.onloadend = onloadend;
2522
+ } else {
2523
+ // Listen for ready state to emulate onloadend
2524
+ request.onreadystatechange = function handleLoad() {
2525
+ if (!request || request.readyState !== 4) {
2526
+ return;
2527
+ }
2528
+
2529
+ // The request errored out and we didn't get a response, this will be
2530
+ // handled by onerror instead
2531
+ // With one exception: request that using file: protocol, most browsers
2532
+ // will return status as 0 even though it's a successful request
2533
+ if (request.status === 0 && !(request.responseURL && request.responseURL.indexOf('file:') === 0)) {
2534
+ return;
2535
+ }
2536
+ // readystate handler is calling before onerror or ontimeout handlers,
2537
+ // so we should call onloadend on the next 'tick'
2538
+ setTimeout(onloadend);
2539
+ };
2540
+ }
2541
+
2542
+ // Handle browser request cancellation (as opposed to a manual cancellation)
2543
+ request.onabort = function handleAbort() {
2544
+ if (!request) {
2545
+ return;
2546
+ }
2547
+
2548
+ reject(new AxiosError('Request aborted', AxiosError.ECONNABORTED, config, request));
2549
+
2550
+ // Clean up request
2551
+ request = null;
2552
+ };
2553
+
2554
+ // Handle low level network errors
2555
+ request.onerror = function handleError(event) {
2556
+ // Browsers deliver a ProgressEvent in XHR onerror
2557
+ // (message may be empty; when present, surface it)
2558
+ // See https://developer.mozilla.org/docs/Web/API/XMLHttpRequest/error_event
2559
+ const msg = event && event.message ? event.message : 'Network Error';
2560
+ const err = new AxiosError(msg, AxiosError.ERR_NETWORK, config, request);
2561
+ // attach the underlying event for consumers who want details
2562
+ err.event = event || null;
2563
+ reject(err);
2564
+ request = null;
2565
+ };
2566
+
2567
+ // Handle timeout
2568
+ request.ontimeout = function handleTimeout() {
2569
+ let timeoutErrorMessage = _config.timeout ? 'timeout of ' + _config.timeout + 'ms exceeded' : 'timeout exceeded';
2570
+ const transitional = _config.transitional || transitionalDefaults;
2571
+ if (_config.timeoutErrorMessage) {
2572
+ timeoutErrorMessage = _config.timeoutErrorMessage;
2573
+ }
2574
+ reject(new AxiosError(
2575
+ timeoutErrorMessage,
2576
+ transitional.clarifyTimeoutError ? AxiosError.ETIMEDOUT : AxiosError.ECONNABORTED,
2577
+ config,
2578
+ request));
2579
+
2580
+ // Clean up request
2581
+ request = null;
2582
+ };
2583
+
2584
+ // Remove Content-Type if data is undefined
2585
+ requestData === undefined && requestHeaders.setContentType(null);
2586
+
2587
+ // Add headers to the request
2588
+ if ('setRequestHeader' in request) {
2589
+ utils$1.forEach(requestHeaders.toJSON(), function setRequestHeader(val, key) {
2590
+ request.setRequestHeader(key, val);
2591
+ });
2592
+ }
2593
+
2594
+ // Add withCredentials to request if needed
2595
+ if (!utils$1.isUndefined(_config.withCredentials)) {
2596
+ request.withCredentials = !!_config.withCredentials;
2597
+ }
2598
+
2599
+ // Add responseType to request if needed
2600
+ if (responseType && responseType !== 'json') {
2601
+ request.responseType = _config.responseType;
2602
+ }
2603
+
2604
+ // Handle progress if needed
2605
+ if (onDownloadProgress) {
2606
+ ([downloadThrottled, flushDownload] = progressEventReducer(onDownloadProgress, true));
2607
+ request.addEventListener('progress', downloadThrottled);
2608
+ }
2609
+
2610
+ // Not all browsers support upload events
2611
+ if (onUploadProgress && request.upload) {
2612
+ ([uploadThrottled, flushUpload] = progressEventReducer(onUploadProgress));
2613
+
2614
+ request.upload.addEventListener('progress', uploadThrottled);
2615
+
2616
+ request.upload.addEventListener('loadend', flushUpload);
2617
+ }
2618
+
2619
+ if (_config.cancelToken || _config.signal) {
2620
+ // Handle cancellation
2621
+ // eslint-disable-next-line func-names
2622
+ onCanceled = cancel => {
2623
+ if (!request) {
2624
+ return;
2625
+ }
2626
+ reject(!cancel || cancel.type ? new CanceledError(null, config, request) : cancel);
2627
+ request.abort();
2628
+ request = null;
2629
+ };
2630
+
2631
+ _config.cancelToken && _config.cancelToken.subscribe(onCanceled);
2632
+ if (_config.signal) {
2633
+ _config.signal.aborted ? onCanceled() : _config.signal.addEventListener('abort', onCanceled);
2634
+ }
2635
+ }
2636
+
2637
+ const protocol = parseProtocol(_config.url);
2638
+
2639
+ if (protocol && platform.protocols.indexOf(protocol) === -1) {
2640
+ reject(new AxiosError('Unsupported protocol ' + protocol + ':', AxiosError.ERR_BAD_REQUEST, config));
2641
+ return;
2642
+ }
2643
+
2644
+
2645
+ // Send the request
2646
+ request.send(requestData || null);
2647
+ });
2648
+ };
2649
+
2650
+ const composeSignals = (signals, timeout) => {
2651
+ const {length} = (signals = signals ? signals.filter(Boolean) : []);
2652
+
2653
+ if (timeout || length) {
2654
+ let controller = new AbortController();
2655
+
2656
+ let aborted;
2657
+
2658
+ const onabort = function (reason) {
2659
+ if (!aborted) {
2660
+ aborted = true;
2661
+ unsubscribe();
2662
+ const err = reason instanceof Error ? reason : this.reason;
2663
+ controller.abort(err instanceof AxiosError ? err : new CanceledError(err instanceof Error ? err.message : err));
2664
+ }
2665
+ };
2666
+
2667
+ let timer = timeout && setTimeout(() => {
2668
+ timer = null;
2669
+ onabort(new AxiosError(`timeout ${timeout} of ms exceeded`, AxiosError.ETIMEDOUT));
2670
+ }, timeout);
2671
+
2672
+ const unsubscribe = () => {
2673
+ if (signals) {
2674
+ timer && clearTimeout(timer);
2675
+ timer = null;
2676
+ signals.forEach(signal => {
2677
+ signal.unsubscribe ? signal.unsubscribe(onabort) : signal.removeEventListener('abort', onabort);
2678
+ });
2679
+ signals = null;
2680
+ }
2681
+ };
2682
+
2683
+ signals.forEach((signal) => signal.addEventListener('abort', onabort));
2684
+
2685
+ const {signal} = controller;
2686
+
2687
+ signal.unsubscribe = () => utils$1.asap(unsubscribe);
2688
+
2689
+ return signal;
2690
+ }
2691
+ };
2692
+
2693
+ var composeSignals$1 = composeSignals;
2694
+
2695
+ const streamChunk = function* (chunk, chunkSize) {
2696
+ let len = chunk.byteLength;
2697
+
2698
+ if (!chunkSize || len < chunkSize) {
2699
+ yield chunk;
2700
+ return;
2701
+ }
2702
+
2703
+ let pos = 0;
2704
+ let end;
2705
+
2706
+ while (pos < len) {
2707
+ end = pos + chunkSize;
2708
+ yield chunk.slice(pos, end);
2709
+ pos = end;
2710
+ }
2711
+ };
2712
+
2713
+ const readBytes = async function* (iterable, chunkSize) {
2714
+ for await (const chunk of readStream(iterable)) {
2715
+ yield* streamChunk(chunk, chunkSize);
2716
+ }
2717
+ };
2718
+
2719
+ const readStream = async function* (stream) {
2720
+ if (stream[Symbol.asyncIterator]) {
2721
+ yield* stream;
2722
+ return;
2723
+ }
2724
+
2725
+ const reader = stream.getReader();
2726
+ try {
2727
+ for (;;) {
2728
+ const {done, value} = await reader.read();
2729
+ if (done) {
2730
+ break;
2731
+ }
2732
+ yield value;
2733
+ }
2734
+ } finally {
2735
+ await reader.cancel();
2736
+ }
2737
+ };
2738
+
2739
+ const trackStream = (stream, chunkSize, onProgress, onFinish) => {
2740
+ const iterator = readBytes(stream, chunkSize);
2741
+
2742
+ let bytes = 0;
2743
+ let done;
2744
+ let _onFinish = (e) => {
2745
+ if (!done) {
2746
+ done = true;
2747
+ onFinish && onFinish(e);
2748
+ }
2749
+ };
2750
+
2751
+ return new ReadableStream({
2752
+ async pull(controller) {
2753
+ try {
2754
+ const {done, value} = await iterator.next();
2755
+
2756
+ if (done) {
2757
+ _onFinish();
2758
+ controller.close();
2759
+ return;
2760
+ }
2761
+
2762
+ let len = value.byteLength;
2763
+ if (onProgress) {
2764
+ let loadedBytes = bytes += len;
2765
+ onProgress(loadedBytes);
2766
+ }
2767
+ controller.enqueue(new Uint8Array(value));
2768
+ } catch (err) {
2769
+ _onFinish(err);
2770
+ throw err;
2771
+ }
2772
+ },
2773
+ cancel(reason) {
2774
+ _onFinish(reason);
2775
+ return iterator.return();
2776
+ }
2777
+ }, {
2778
+ highWaterMark: 2
2779
+ })
2780
+ };
2781
+
2782
+ const DEFAULT_CHUNK_SIZE = 64 * 1024;
2783
+
2784
+ const {isFunction} = utils$1;
2785
+
2786
+ const globalFetchAPI = (({Request, Response}) => ({
2787
+ Request, Response
2788
+ }))(utils$1.global);
2789
+
2790
+ const {
2791
+ ReadableStream: ReadableStream$1, TextEncoder
2792
+ } = utils$1.global;
2793
+
2794
+
2795
+ const test = (fn, ...args) => {
2796
+ try {
2797
+ return !!fn(...args);
2798
+ } catch (e) {
2799
+ return false
2800
+ }
2801
+ };
2802
+
2803
+ const factory = (env) => {
2804
+ env = utils$1.merge.call({
2805
+ skipUndefined: true
2806
+ }, globalFetchAPI, env);
2807
+
2808
+ const {fetch: envFetch, Request, Response} = env;
2809
+ const isFetchSupported = envFetch ? isFunction(envFetch) : typeof fetch === 'function';
2810
+ const isRequestSupported = isFunction(Request);
2811
+ const isResponseSupported = isFunction(Response);
2812
+
2813
+ if (!isFetchSupported) {
2814
+ return false;
2815
+ }
2816
+
2817
+ const isReadableStreamSupported = isFetchSupported && isFunction(ReadableStream$1);
2818
+
2819
+ const encodeText = isFetchSupported && (typeof TextEncoder === 'function' ?
2820
+ ((encoder) => (str) => encoder.encode(str))(new TextEncoder()) :
2821
+ async (str) => new Uint8Array(await new Request(str).arrayBuffer())
2822
+ );
2823
+
2824
+ const supportsRequestStream = isRequestSupported && isReadableStreamSupported && test(() => {
2825
+ let duplexAccessed = false;
2826
+
2827
+ const hasContentType = new Request(platform.origin, {
2828
+ body: new ReadableStream$1(),
2829
+ method: 'POST',
2830
+ get duplex() {
2831
+ duplexAccessed = true;
2832
+ return 'half';
2833
+ },
2834
+ }).headers.has('Content-Type');
2835
+
2836
+ return duplexAccessed && !hasContentType;
2837
+ });
2838
+
2839
+ const supportsResponseStream = isResponseSupported && isReadableStreamSupported &&
2840
+ test(() => utils$1.isReadableStream(new Response('').body));
2841
+
2842
+ const resolvers = {
2843
+ stream: supportsResponseStream && ((res) => res.body)
2844
+ };
2845
+
2846
+ isFetchSupported && ((() => {
2847
+ ['text', 'arrayBuffer', 'blob', 'formData', 'stream'].forEach(type => {
2848
+ !resolvers[type] && (resolvers[type] = (res, config) => {
2849
+ let method = res && res[type];
2850
+
2851
+ if (method) {
2852
+ return method.call(res);
2853
+ }
2854
+
2855
+ throw new AxiosError(`Response type '${type}' is not supported`, AxiosError.ERR_NOT_SUPPORT, config);
2856
+ });
2857
+ });
2858
+ })());
2859
+
2860
+ const getBodyLength = async (body) => {
2861
+ if (body == null) {
2862
+ return 0;
2863
+ }
2864
+
2865
+ if (utils$1.isBlob(body)) {
2866
+ return body.size;
2867
+ }
2868
+
2869
+ if (utils$1.isSpecCompliantForm(body)) {
2870
+ const _request = new Request(platform.origin, {
2871
+ method: 'POST',
2872
+ body,
2873
+ });
2874
+ return (await _request.arrayBuffer()).byteLength;
2875
+ }
2876
+
2877
+ if (utils$1.isArrayBufferView(body) || utils$1.isArrayBuffer(body)) {
2878
+ return body.byteLength;
2879
+ }
2880
+
2881
+ if (utils$1.isURLSearchParams(body)) {
2882
+ body = body + '';
2883
+ }
2884
+
2885
+ if (utils$1.isString(body)) {
2886
+ return (await encodeText(body)).byteLength;
2887
+ }
2888
+ };
2889
+
2890
+ const resolveBodyLength = async (headers, body) => {
2891
+ const length = utils$1.toFiniteNumber(headers.getContentLength());
2892
+
2893
+ return length == null ? getBodyLength(body) : length;
2894
+ };
2895
+
2896
+ return async (config) => {
2897
+ let {
2898
+ url,
2899
+ method,
2900
+ data,
2901
+ signal,
2902
+ cancelToken,
2903
+ timeout,
2904
+ onDownloadProgress,
2905
+ onUploadProgress,
2906
+ responseType,
2907
+ headers,
2908
+ withCredentials = 'same-origin',
2909
+ fetchOptions
2910
+ } = resolveConfig(config);
2911
+
2912
+ let _fetch = envFetch || fetch;
2913
+
2914
+ responseType = responseType ? (responseType + '').toLowerCase() : 'text';
2915
+
2916
+ let composedSignal = composeSignals$1([signal, cancelToken && cancelToken.toAbortSignal()], timeout);
2917
+
2918
+ let request = null;
2919
+
2920
+ const unsubscribe = composedSignal && composedSignal.unsubscribe && (() => {
2921
+ composedSignal.unsubscribe();
2922
+ });
2923
+
2924
+ let requestContentLength;
2925
+
2926
+ try {
2927
+ if (
2928
+ onUploadProgress && supportsRequestStream && method !== 'get' && method !== 'head' &&
2929
+ (requestContentLength = await resolveBodyLength(headers, data)) !== 0
2930
+ ) {
2931
+ let _request = new Request(url, {
2932
+ method: 'POST',
2933
+ body: data,
2934
+ duplex: "half"
2935
+ });
2936
+
2937
+ let contentTypeHeader;
2938
+
2939
+ if (utils$1.isFormData(data) && (contentTypeHeader = _request.headers.get('content-type'))) {
2940
+ headers.setContentType(contentTypeHeader);
2941
+ }
2942
+
2943
+ if (_request.body) {
2944
+ const [onProgress, flush] = progressEventDecorator(
2945
+ requestContentLength,
2946
+ progressEventReducer(asyncDecorator(onUploadProgress))
2947
+ );
2948
+
2949
+ data = trackStream(_request.body, DEFAULT_CHUNK_SIZE, onProgress, flush);
2950
+ }
2951
+ }
2952
+
2953
+ if (!utils$1.isString(withCredentials)) {
2954
+ withCredentials = withCredentials ? 'include' : 'omit';
2955
+ }
2956
+
2957
+ // Cloudflare Workers throws when credentials are defined
2958
+ // see https://github.com/cloudflare/workerd/issues/902
2959
+ const isCredentialsSupported = isRequestSupported && "credentials" in Request.prototype;
2960
+
2961
+ const resolvedOptions = {
2962
+ ...fetchOptions,
2963
+ signal: composedSignal,
2964
+ method: method.toUpperCase(),
2965
+ headers: headers.normalize().toJSON(),
2966
+ body: data,
2967
+ duplex: "half",
2968
+ credentials: isCredentialsSupported ? withCredentials : undefined
2969
+ };
2970
+
2971
+ request = isRequestSupported && new Request(url, resolvedOptions);
2972
+
2973
+ let response = await (isRequestSupported ? _fetch(request, fetchOptions) : _fetch(url, resolvedOptions));
2974
+
2975
+ const isStreamResponse = supportsResponseStream && (responseType === 'stream' || responseType === 'response');
2976
+
2977
+ if (supportsResponseStream && (onDownloadProgress || (isStreamResponse && unsubscribe))) {
2978
+ const options = {};
2979
+
2980
+ ['status', 'statusText', 'headers'].forEach(prop => {
2981
+ options[prop] = response[prop];
2982
+ });
2983
+
2984
+ const responseContentLength = utils$1.toFiniteNumber(response.headers.get('content-length'));
2985
+
2986
+ const [onProgress, flush] = onDownloadProgress && progressEventDecorator(
2987
+ responseContentLength,
2988
+ progressEventReducer(asyncDecorator(onDownloadProgress), true)
2989
+ ) || [];
2990
+
2991
+ response = new Response(
2992
+ trackStream(response.body, DEFAULT_CHUNK_SIZE, onProgress, () => {
2993
+ flush && flush();
2994
+ unsubscribe && unsubscribe();
2995
+ }),
2996
+ options
2997
+ );
2998
+ }
2999
+
3000
+ responseType = responseType || 'text';
3001
+
3002
+ let responseData = await resolvers[utils$1.findKey(resolvers, responseType) || 'text'](response, config);
3003
+
3004
+ !isStreamResponse && unsubscribe && unsubscribe();
3005
+
3006
+ return await new Promise((resolve, reject) => {
3007
+ settle(resolve, reject, {
3008
+ data: responseData,
3009
+ headers: AxiosHeaders$1.from(response.headers),
3010
+ status: response.status,
3011
+ statusText: response.statusText,
3012
+ config,
3013
+ request
3014
+ });
3015
+ })
3016
+ } catch (err) {
3017
+ unsubscribe && unsubscribe();
3018
+
3019
+ if (err && err.name === 'TypeError' && /Load failed|fetch/i.test(err.message)) {
3020
+ throw Object.assign(
3021
+ new AxiosError('Network Error', AxiosError.ERR_NETWORK, config, request),
3022
+ {
3023
+ cause: err.cause || err
3024
+ }
3025
+ )
3026
+ }
3027
+
3028
+ throw AxiosError.from(err, err && err.code, config, request);
3029
+ }
3030
+ }
3031
+ };
3032
+
3033
+ const seedCache = new Map();
3034
+
3035
+ const getFetch = (config) => {
3036
+ let env = config ? config.env : {};
3037
+ const {fetch, Request, Response} = env;
3038
+ const seeds = [
3039
+ Request, Response, fetch
3040
+ ];
3041
+
3042
+ let len = seeds.length, i = len,
3043
+ seed, target, map = seedCache;
3044
+
3045
+ while (i--) {
3046
+ seed = seeds[i];
3047
+ target = map.get(seed);
3048
+
3049
+ target === undefined && map.set(seed, target = (i ? new Map() : factory(env)));
3050
+
3051
+ map = target;
3052
+ }
3053
+
3054
+ return target;
3055
+ };
3056
+
3057
+ getFetch();
3058
+
3059
+ const knownAdapters = {
3060
+ http: httpAdapter,
3061
+ xhr: xhrAdapter,
3062
+ fetch: {
3063
+ get: getFetch,
3064
+ }
3065
+ };
3066
+
3067
+ utils$1.forEach(knownAdapters, (fn, value) => {
3068
+ if (fn) {
3069
+ try {
3070
+ Object.defineProperty(fn, 'name', {value});
3071
+ } catch (e) {
3072
+ // eslint-disable-next-line no-empty
3073
+ }
3074
+ Object.defineProperty(fn, 'adapterName', {value});
3075
+ }
3076
+ });
3077
+
3078
+ const renderReason = (reason) => `- ${reason}`;
3079
+
3080
+ const isResolvedHandle = (adapter) => utils$1.isFunction(adapter) || adapter === null || adapter === false;
3081
+
3082
+ var adapters = {
3083
+ getAdapter: (adapters, config) => {
3084
+ adapters = utils$1.isArray(adapters) ? adapters : [adapters];
3085
+
3086
+ const {length} = adapters;
3087
+ let nameOrAdapter;
3088
+ let adapter;
3089
+
3090
+ const rejectedReasons = {};
3091
+
3092
+ for (let i = 0; i < length; i++) {
3093
+ nameOrAdapter = adapters[i];
3094
+ let id;
3095
+
3096
+ adapter = nameOrAdapter;
3097
+
3098
+ if (!isResolvedHandle(nameOrAdapter)) {
3099
+ adapter = knownAdapters[(id = String(nameOrAdapter)).toLowerCase()];
3100
+
3101
+ if (adapter === undefined) {
3102
+ throw new AxiosError(`Unknown adapter '${id}'`);
3103
+ }
3104
+ }
3105
+
3106
+ if (adapter && (utils$1.isFunction(adapter) || (adapter = adapter.get(config)))) {
3107
+ break;
3108
+ }
3109
+
3110
+ rejectedReasons[id || '#' + i] = adapter;
3111
+ }
3112
+
3113
+ if (!adapter) {
3114
+
3115
+ const reasons = Object.entries(rejectedReasons)
3116
+ .map(([id, state]) => `adapter ${id} ` +
3117
+ (state === false ? 'is not supported by the environment' : 'is not available in the build')
3118
+ );
3119
+
3120
+ let s = length ?
3121
+ (reasons.length > 1 ? 'since :\n' + reasons.map(renderReason).join('\n') : ' ' + renderReason(reasons[0])) :
3122
+ 'as no adapter specified';
3123
+
3124
+ throw new AxiosError(
3125
+ `There is no suitable adapter to dispatch the request ` + s,
3126
+ 'ERR_NOT_SUPPORT'
3127
+ );
3128
+ }
3129
+
3130
+ return adapter;
3131
+ },
3132
+ adapters: knownAdapters
3133
+ };
3134
+
3135
+ /**
3136
+ * Throws a `CanceledError` if cancellation has been requested.
3137
+ *
3138
+ * @param {Object} config The config that is to be used for the request
3139
+ *
3140
+ * @returns {void}
3141
+ */
3142
+ function throwIfCancellationRequested(config) {
3143
+ if (config.cancelToken) {
3144
+ config.cancelToken.throwIfRequested();
3145
+ }
3146
+
3147
+ if (config.signal && config.signal.aborted) {
3148
+ throw new CanceledError(null, config);
3149
+ }
3150
+ }
3151
+
3152
+ /**
3153
+ * Dispatch a request to the server using the configured adapter.
3154
+ *
3155
+ * @param {object} config The config that is to be used for the request
3156
+ *
3157
+ * @returns {Promise} The Promise to be fulfilled
3158
+ */
3159
+ function dispatchRequest(config) {
3160
+ throwIfCancellationRequested(config);
3161
+
3162
+ config.headers = AxiosHeaders$1.from(config.headers);
3163
+
3164
+ // Transform request data
3165
+ config.data = transformData.call(
3166
+ config,
3167
+ config.transformRequest
3168
+ );
3169
+
3170
+ if (['post', 'put', 'patch'].indexOf(config.method) !== -1) {
3171
+ config.headers.setContentType('application/x-www-form-urlencoded', false);
3172
+ }
3173
+
3174
+ const adapter = adapters.getAdapter(config.adapter || defaults$1.adapter, config);
3175
+
3176
+ return adapter(config).then(function onAdapterResolution(response) {
3177
+ throwIfCancellationRequested(config);
3178
+
3179
+ // Transform response data
3180
+ response.data = transformData.call(
3181
+ config,
3182
+ config.transformResponse,
3183
+ response
3184
+ );
3185
+
3186
+ response.headers = AxiosHeaders$1.from(response.headers);
3187
+
3188
+ return response;
3189
+ }, function onAdapterRejection(reason) {
3190
+ if (!isCancel(reason)) {
3191
+ throwIfCancellationRequested(config);
3192
+
3193
+ // Transform response data
3194
+ if (reason && reason.response) {
3195
+ reason.response.data = transformData.call(
3196
+ config,
3197
+ config.transformResponse,
3198
+ reason.response
3199
+ );
3200
+ reason.response.headers = AxiosHeaders$1.from(reason.response.headers);
3201
+ }
3202
+ }
3203
+
3204
+ return Promise.reject(reason);
3205
+ });
3206
+ }
3207
+
3208
+ const VERSION = "1.12.2";
3209
+
3210
+ const validators$1 = {};
3211
+
3212
+ // eslint-disable-next-line func-names
3213
+ ['object', 'boolean', 'number', 'function', 'string', 'symbol'].forEach((type, i) => {
3214
+ validators$1[type] = function validator(thing) {
3215
+ return typeof thing === type || 'a' + (i < 1 ? 'n ' : ' ') + type;
3216
+ };
3217
+ });
3218
+
3219
+ const deprecatedWarnings = {};
3220
+
3221
+ /**
3222
+ * Transitional option validator
3223
+ *
3224
+ * @param {function|boolean?} validator - set to false if the transitional option has been removed
3225
+ * @param {string?} version - deprecated version / removed since version
3226
+ * @param {string?} message - some message with additional info
3227
+ *
3228
+ * @returns {function}
3229
+ */
3230
+ validators$1.transitional = function transitional(validator, version, message) {
3231
+ function formatMessage(opt, desc) {
3232
+ return '[Axios v' + VERSION + '] Transitional option \'' + opt + '\'' + desc + (message ? '. ' + message : '');
3233
+ }
3234
+
3235
+ // eslint-disable-next-line func-names
3236
+ return (value, opt, opts) => {
3237
+ if (validator === false) {
3238
+ throw new AxiosError(
3239
+ formatMessage(opt, ' has been removed' + (version ? ' in ' + version : '')),
3240
+ AxiosError.ERR_DEPRECATED
3241
+ );
3242
+ }
3243
+
3244
+ if (version && !deprecatedWarnings[opt]) {
3245
+ deprecatedWarnings[opt] = true;
3246
+ // eslint-disable-next-line no-console
3247
+ console.warn(
3248
+ formatMessage(
3249
+ opt,
3250
+ ' has been deprecated since v' + version + ' and will be removed in the near future'
3251
+ )
3252
+ );
3253
+ }
3254
+
3255
+ return validator ? validator(value, opt, opts) : true;
3256
+ };
3257
+ };
3258
+
3259
+ validators$1.spelling = function spelling(correctSpelling) {
3260
+ return (value, opt) => {
3261
+ // eslint-disable-next-line no-console
3262
+ console.warn(`${opt} is likely a misspelling of ${correctSpelling}`);
3263
+ return true;
3264
+ }
3265
+ };
3266
+
3267
+ /**
3268
+ * Assert object's properties type
3269
+ *
3270
+ * @param {object} options
3271
+ * @param {object} schema
3272
+ * @param {boolean?} allowUnknown
3273
+ *
3274
+ * @returns {object}
3275
+ */
3276
+
3277
+ function assertOptions(options, schema, allowUnknown) {
3278
+ if (typeof options !== 'object') {
3279
+ throw new AxiosError('options must be an object', AxiosError.ERR_BAD_OPTION_VALUE);
3280
+ }
3281
+ const keys = Object.keys(options);
3282
+ let i = keys.length;
3283
+ while (i-- > 0) {
3284
+ const opt = keys[i];
3285
+ const validator = schema[opt];
3286
+ if (validator) {
3287
+ const value = options[opt];
3288
+ const result = value === undefined || validator(value, opt, options);
3289
+ if (result !== true) {
3290
+ throw new AxiosError('option ' + opt + ' must be ' + result, AxiosError.ERR_BAD_OPTION_VALUE);
3291
+ }
3292
+ continue;
3293
+ }
3294
+ if (allowUnknown !== true) {
3295
+ throw new AxiosError('Unknown option ' + opt, AxiosError.ERR_BAD_OPTION);
3296
+ }
3297
+ }
3298
+ }
3299
+
3300
+ var validator = {
3301
+ assertOptions,
3302
+ validators: validators$1
3303
+ };
3304
+
3305
+ const validators = validator.validators;
3306
+
3307
+ /**
3308
+ * Create a new instance of Axios
3309
+ *
3310
+ * @param {Object} instanceConfig The default config for the instance
3311
+ *
3312
+ * @return {Axios} A new instance of Axios
3313
+ */
3314
+ class Axios {
3315
+ constructor(instanceConfig) {
3316
+ this.defaults = instanceConfig || {};
3317
+ this.interceptors = {
3318
+ request: new InterceptorManager$1(),
3319
+ response: new InterceptorManager$1()
3320
+ };
3321
+ }
3322
+
3323
+ /**
3324
+ * Dispatch a request
3325
+ *
3326
+ * @param {String|Object} configOrUrl The config specific for this request (merged with this.defaults)
3327
+ * @param {?Object} config
3328
+ *
3329
+ * @returns {Promise} The Promise to be fulfilled
3330
+ */
3331
+ async request(configOrUrl, config) {
3332
+ try {
3333
+ return await this._request(configOrUrl, config);
3334
+ } catch (err) {
3335
+ if (err instanceof Error) {
3336
+ let dummy = {};
3337
+
3338
+ Error.captureStackTrace ? Error.captureStackTrace(dummy) : (dummy = new Error());
3339
+
3340
+ // slice off the Error: ... line
3341
+ const stack = dummy.stack ? dummy.stack.replace(/^.+\n/, '') : '';
3342
+ try {
3343
+ if (!err.stack) {
3344
+ err.stack = stack;
3345
+ // match without the 2 top stack lines
3346
+ } else if (stack && !String(err.stack).endsWith(stack.replace(/^.+\n.+\n/, ''))) {
3347
+ err.stack += '\n' + stack;
3348
+ }
3349
+ } catch (e) {
3350
+ // ignore the case where "stack" is an un-writable property
3351
+ }
3352
+ }
3353
+
3354
+ throw err;
3355
+ }
3356
+ }
3357
+
3358
+ _request(configOrUrl, config) {
3359
+ /*eslint no-param-reassign:0*/
3360
+ // Allow for axios('example/url'[, config]) a la fetch API
3361
+ if (typeof configOrUrl === 'string') {
3362
+ config = config || {};
3363
+ config.url = configOrUrl;
3364
+ } else {
3365
+ config = configOrUrl || {};
3366
+ }
3367
+
3368
+ config = mergeConfig(this.defaults, config);
3369
+
3370
+ const {transitional, paramsSerializer, headers} = config;
3371
+
3372
+ if (transitional !== undefined) {
3373
+ validator.assertOptions(transitional, {
3374
+ silentJSONParsing: validators.transitional(validators.boolean),
3375
+ forcedJSONParsing: validators.transitional(validators.boolean),
3376
+ clarifyTimeoutError: validators.transitional(validators.boolean)
3377
+ }, false);
3378
+ }
3379
+
3380
+ if (paramsSerializer != null) {
3381
+ if (utils$1.isFunction(paramsSerializer)) {
3382
+ config.paramsSerializer = {
3383
+ serialize: paramsSerializer
3384
+ };
3385
+ } else {
3386
+ validator.assertOptions(paramsSerializer, {
3387
+ encode: validators.function,
3388
+ serialize: validators.function
3389
+ }, true);
3390
+ }
3391
+ }
3392
+
3393
+ // Set config.allowAbsoluteUrls
3394
+ if (config.allowAbsoluteUrls !== undefined) ; else if (this.defaults.allowAbsoluteUrls !== undefined) {
3395
+ config.allowAbsoluteUrls = this.defaults.allowAbsoluteUrls;
3396
+ } else {
3397
+ config.allowAbsoluteUrls = true;
3398
+ }
3399
+
3400
+ validator.assertOptions(config, {
3401
+ baseUrl: validators.spelling('baseURL'),
3402
+ withXsrfToken: validators.spelling('withXSRFToken')
3403
+ }, true);
3404
+
3405
+ // Set config.method
3406
+ config.method = (config.method || this.defaults.method || 'get').toLowerCase();
3407
+
3408
+ // Flatten headers
3409
+ let contextHeaders = headers && utils$1.merge(
3410
+ headers.common,
3411
+ headers[config.method]
3412
+ );
3413
+
3414
+ headers && utils$1.forEach(
3415
+ ['delete', 'get', 'head', 'post', 'put', 'patch', 'common'],
3416
+ (method) => {
3417
+ delete headers[method];
3418
+ }
3419
+ );
3420
+
3421
+ config.headers = AxiosHeaders$1.concat(contextHeaders, headers);
3422
+
3423
+ // filter out skipped interceptors
3424
+ const requestInterceptorChain = [];
3425
+ let synchronousRequestInterceptors = true;
3426
+ this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) {
3427
+ if (typeof interceptor.runWhen === 'function' && interceptor.runWhen(config) === false) {
3428
+ return;
3429
+ }
3430
+
3431
+ synchronousRequestInterceptors = synchronousRequestInterceptors && interceptor.synchronous;
3432
+
3433
+ requestInterceptorChain.unshift(interceptor.fulfilled, interceptor.rejected);
3434
+ });
3435
+
3436
+ const responseInterceptorChain = [];
3437
+ this.interceptors.response.forEach(function pushResponseInterceptors(interceptor) {
3438
+ responseInterceptorChain.push(interceptor.fulfilled, interceptor.rejected);
3439
+ });
3440
+
3441
+ let promise;
3442
+ let i = 0;
3443
+ let len;
3444
+
3445
+ if (!synchronousRequestInterceptors) {
3446
+ const chain = [dispatchRequest.bind(this), undefined];
3447
+ chain.unshift(...requestInterceptorChain);
3448
+ chain.push(...responseInterceptorChain);
3449
+ len = chain.length;
3450
+
3451
+ promise = Promise.resolve(config);
3452
+
3453
+ while (i < len) {
3454
+ promise = promise.then(chain[i++], chain[i++]);
3455
+ }
3456
+
3457
+ return promise;
3458
+ }
3459
+
3460
+ len = requestInterceptorChain.length;
3461
+
3462
+ let newConfig = config;
3463
+
3464
+ while (i < len) {
3465
+ const onFulfilled = requestInterceptorChain[i++];
3466
+ const onRejected = requestInterceptorChain[i++];
3467
+ try {
3468
+ newConfig = onFulfilled(newConfig);
3469
+ } catch (error) {
3470
+ onRejected.call(this, error);
3471
+ break;
3472
+ }
3473
+ }
3474
+
3475
+ try {
3476
+ promise = dispatchRequest.call(this, newConfig);
3477
+ } catch (error) {
3478
+ return Promise.reject(error);
3479
+ }
3480
+
3481
+ i = 0;
3482
+ len = responseInterceptorChain.length;
3483
+
3484
+ while (i < len) {
3485
+ promise = promise.then(responseInterceptorChain[i++], responseInterceptorChain[i++]);
3486
+ }
3487
+
3488
+ return promise;
3489
+ }
3490
+
3491
+ getUri(config) {
3492
+ config = mergeConfig(this.defaults, config);
3493
+ const fullPath = buildFullPath(config.baseURL, config.url, config.allowAbsoluteUrls);
3494
+ return buildURL(fullPath, config.params, config.paramsSerializer);
3495
+ }
3496
+ }
3497
+
3498
+ // Provide aliases for supported request methods
3499
+ utils$1.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) {
3500
+ /*eslint func-names:0*/
3501
+ Axios.prototype[method] = function(url, config) {
3502
+ return this.request(mergeConfig(config || {}, {
3503
+ method,
3504
+ url,
3505
+ data: (config || {}).data
3506
+ }));
3507
+ };
3508
+ });
3509
+
3510
+ utils$1.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
3511
+ /*eslint func-names:0*/
3512
+
3513
+ function generateHTTPMethod(isForm) {
3514
+ return function httpMethod(url, data, config) {
3515
+ return this.request(mergeConfig(config || {}, {
3516
+ method,
3517
+ headers: isForm ? {
3518
+ 'Content-Type': 'multipart/form-data'
3519
+ } : {},
3520
+ url,
3521
+ data
3522
+ }));
3523
+ };
3524
+ }
3525
+
3526
+ Axios.prototype[method] = generateHTTPMethod();
3527
+
3528
+ Axios.prototype[method + 'Form'] = generateHTTPMethod(true);
3529
+ });
3530
+
3531
+ var Axios$1 = Axios;
3532
+
3533
+ /**
3534
+ * A `CancelToken` is an object that can be used to request cancellation of an operation.
3535
+ *
3536
+ * @param {Function} executor The executor function.
3537
+ *
3538
+ * @returns {CancelToken}
3539
+ */
3540
+ class CancelToken {
3541
+ constructor(executor) {
3542
+ if (typeof executor !== 'function') {
3543
+ throw new TypeError('executor must be a function.');
3544
+ }
3545
+
3546
+ let resolvePromise;
3547
+
3548
+ this.promise = new Promise(function promiseExecutor(resolve) {
3549
+ resolvePromise = resolve;
3550
+ });
3551
+
3552
+ const token = this;
3553
+
3554
+ // eslint-disable-next-line func-names
3555
+ this.promise.then(cancel => {
3556
+ if (!token._listeners) return;
3557
+
3558
+ let i = token._listeners.length;
3559
+
3560
+ while (i-- > 0) {
3561
+ token._listeners[i](cancel);
3562
+ }
3563
+ token._listeners = null;
3564
+ });
3565
+
3566
+ // eslint-disable-next-line func-names
3567
+ this.promise.then = onfulfilled => {
3568
+ let _resolve;
3569
+ // eslint-disable-next-line func-names
3570
+ const promise = new Promise(resolve => {
3571
+ token.subscribe(resolve);
3572
+ _resolve = resolve;
3573
+ }).then(onfulfilled);
3574
+
3575
+ promise.cancel = function reject() {
3576
+ token.unsubscribe(_resolve);
3577
+ };
3578
+
3579
+ return promise;
3580
+ };
3581
+
3582
+ executor(function cancel(message, config, request) {
3583
+ if (token.reason) {
3584
+ // Cancellation has already been requested
3585
+ return;
3586
+ }
3587
+
3588
+ token.reason = new CanceledError(message, config, request);
3589
+ resolvePromise(token.reason);
3590
+ });
3591
+ }
3592
+
3593
+ /**
3594
+ * Throws a `CanceledError` if cancellation has been requested.
3595
+ */
3596
+ throwIfRequested() {
3597
+ if (this.reason) {
3598
+ throw this.reason;
3599
+ }
3600
+ }
3601
+
3602
+ /**
3603
+ * Subscribe to the cancel signal
3604
+ */
3605
+
3606
+ subscribe(listener) {
3607
+ if (this.reason) {
3608
+ listener(this.reason);
3609
+ return;
3610
+ }
3611
+
3612
+ if (this._listeners) {
3613
+ this._listeners.push(listener);
3614
+ } else {
3615
+ this._listeners = [listener];
3616
+ }
3617
+ }
3618
+
3619
+ /**
3620
+ * Unsubscribe from the cancel signal
3621
+ */
3622
+
3623
+ unsubscribe(listener) {
3624
+ if (!this._listeners) {
3625
+ return;
3626
+ }
3627
+ const index = this._listeners.indexOf(listener);
3628
+ if (index !== -1) {
3629
+ this._listeners.splice(index, 1);
3630
+ }
3631
+ }
3632
+
3633
+ toAbortSignal() {
3634
+ const controller = new AbortController();
3635
+
3636
+ const abort = (err) => {
3637
+ controller.abort(err);
3638
+ };
3639
+
3640
+ this.subscribe(abort);
3641
+
3642
+ controller.signal.unsubscribe = () => this.unsubscribe(abort);
3643
+
3644
+ return controller.signal;
3645
+ }
3646
+
3647
+ /**
3648
+ * Returns an object that contains a new `CancelToken` and a function that, when called,
3649
+ * cancels the `CancelToken`.
3650
+ */
3651
+ static source() {
3652
+ let cancel;
3653
+ const token = new CancelToken(function executor(c) {
3654
+ cancel = c;
3655
+ });
3656
+ return {
3657
+ token,
3658
+ cancel
3659
+ };
3660
+ }
3661
+ }
3662
+
3663
+ var CancelToken$1 = CancelToken;
3664
+
3665
+ /**
3666
+ * Syntactic sugar for invoking a function and expanding an array for arguments.
3667
+ *
3668
+ * Common use case would be to use `Function.prototype.apply`.
3669
+ *
3670
+ * ```js
3671
+ * function f(x, y, z) {}
3672
+ * var args = [1, 2, 3];
3673
+ * f.apply(null, args);
3674
+ * ```
3675
+ *
3676
+ * With `spread` this example can be re-written.
3677
+ *
3678
+ * ```js
3679
+ * spread(function(x, y, z) {})([1, 2, 3]);
3680
+ * ```
3681
+ *
3682
+ * @param {Function} callback
3683
+ *
3684
+ * @returns {Function}
3685
+ */
3686
+ function spread(callback) {
3687
+ return function wrap(arr) {
3688
+ return callback.apply(null, arr);
3689
+ };
3690
+ }
3691
+
3692
+ /**
3693
+ * Determines whether the payload is an error thrown by Axios
3694
+ *
3695
+ * @param {*} payload The value to test
3696
+ *
3697
+ * @returns {boolean} True if the payload is an error thrown by Axios, otherwise false
3698
+ */
3699
+ function isAxiosError(payload) {
3700
+ return utils$1.isObject(payload) && (payload.isAxiosError === true);
3701
+ }
3702
+
3703
+ const HttpStatusCode = {
3704
+ Continue: 100,
3705
+ SwitchingProtocols: 101,
3706
+ Processing: 102,
3707
+ EarlyHints: 103,
3708
+ Ok: 200,
3709
+ Created: 201,
3710
+ Accepted: 202,
3711
+ NonAuthoritativeInformation: 203,
3712
+ NoContent: 204,
3713
+ ResetContent: 205,
3714
+ PartialContent: 206,
3715
+ MultiStatus: 207,
3716
+ AlreadyReported: 208,
3717
+ ImUsed: 226,
3718
+ MultipleChoices: 300,
3719
+ MovedPermanently: 301,
3720
+ Found: 302,
3721
+ SeeOther: 303,
3722
+ NotModified: 304,
3723
+ UseProxy: 305,
3724
+ Unused: 306,
3725
+ TemporaryRedirect: 307,
3726
+ PermanentRedirect: 308,
3727
+ BadRequest: 400,
3728
+ Unauthorized: 401,
3729
+ PaymentRequired: 402,
3730
+ Forbidden: 403,
3731
+ NotFound: 404,
3732
+ MethodNotAllowed: 405,
3733
+ NotAcceptable: 406,
3734
+ ProxyAuthenticationRequired: 407,
3735
+ RequestTimeout: 408,
3736
+ Conflict: 409,
3737
+ Gone: 410,
3738
+ LengthRequired: 411,
3739
+ PreconditionFailed: 412,
3740
+ PayloadTooLarge: 413,
3741
+ UriTooLong: 414,
3742
+ UnsupportedMediaType: 415,
3743
+ RangeNotSatisfiable: 416,
3744
+ ExpectationFailed: 417,
3745
+ ImATeapot: 418,
3746
+ MisdirectedRequest: 421,
3747
+ UnprocessableEntity: 422,
3748
+ Locked: 423,
3749
+ FailedDependency: 424,
3750
+ TooEarly: 425,
3751
+ UpgradeRequired: 426,
3752
+ PreconditionRequired: 428,
3753
+ TooManyRequests: 429,
3754
+ RequestHeaderFieldsTooLarge: 431,
3755
+ UnavailableForLegalReasons: 451,
3756
+ InternalServerError: 500,
3757
+ NotImplemented: 501,
3758
+ BadGateway: 502,
3759
+ ServiceUnavailable: 503,
3760
+ GatewayTimeout: 504,
3761
+ HttpVersionNotSupported: 505,
3762
+ VariantAlsoNegotiates: 506,
3763
+ InsufficientStorage: 507,
3764
+ LoopDetected: 508,
3765
+ NotExtended: 510,
3766
+ NetworkAuthenticationRequired: 511,
3767
+ };
3768
+
3769
+ Object.entries(HttpStatusCode).forEach(([key, value]) => {
3770
+ HttpStatusCode[value] = key;
3771
+ });
3772
+
3773
+ var HttpStatusCode$1 = HttpStatusCode;
3774
+
3775
+ /**
3776
+ * Create an instance of Axios
3777
+ *
3778
+ * @param {Object} defaultConfig The default config for the instance
3779
+ *
3780
+ * @returns {Axios} A new instance of Axios
3781
+ */
3782
+ function createInstance(defaultConfig) {
3783
+ const context = new Axios$1(defaultConfig);
3784
+ const instance = bind(Axios$1.prototype.request, context);
3785
+
3786
+ // Copy axios.prototype to instance
3787
+ utils$1.extend(instance, Axios$1.prototype, context, {allOwnKeys: true});
3788
+
3789
+ // Copy context to instance
3790
+ utils$1.extend(instance, context, null, {allOwnKeys: true});
3791
+
3792
+ // Factory for creating new instances
3793
+ instance.create = function create(instanceConfig) {
3794
+ return createInstance(mergeConfig(defaultConfig, instanceConfig));
3795
+ };
3796
+
3797
+ return instance;
3798
+ }
3799
+
3800
+ // Create the default instance to be exported
3801
+ const axios = createInstance(defaults$1);
3802
+
3803
+ // Expose Axios class to allow class inheritance
3804
+ axios.Axios = Axios$1;
3805
+
3806
+ // Expose Cancel & CancelToken
3807
+ axios.CanceledError = CanceledError;
3808
+ axios.CancelToken = CancelToken$1;
3809
+ axios.isCancel = isCancel;
3810
+ axios.VERSION = VERSION;
3811
+ axios.toFormData = toFormData;
3812
+
3813
+ // Expose AxiosError class
3814
+ axios.AxiosError = AxiosError;
3815
+
3816
+ // alias for CanceledError for backward compatibility
3817
+ axios.Cancel = axios.CanceledError;
3818
+
3819
+ // Expose all/spread
3820
+ axios.all = function all(promises) {
3821
+ return Promise.all(promises);
3822
+ };
3823
+
3824
+ axios.spread = spread;
3825
+
3826
+ // Expose isAxiosError
3827
+ axios.isAxiosError = isAxiosError;
3828
+
3829
+ // Expose mergeConfig
3830
+ axios.mergeConfig = mergeConfig;
3831
+
3832
+ axios.AxiosHeaders = AxiosHeaders$1;
3833
+
3834
+ axios.formToJSON = thing => formDataToJSON(utils$1.isHTMLForm(thing) ? new FormData(thing) : thing);
3835
+
3836
+ axios.getAdapter = adapters.getAdapter;
3837
+
3838
+ axios.HttpStatusCode = HttpStatusCode$1;
3839
+
3840
+ axios.default = axios;
3841
+
3842
+ // this module should only have a default export
3843
+ var axios$1 = axios;
3844
+
3845
+ class UniversalAppAPI {
3846
+ constructor(_ref) {
3847
+ let {
3848
+ server,
3849
+ accessToken,
3850
+ appUuid
3851
+ } = _ref;
3852
+ this.server = server;
3853
+ this.accessToken = accessToken;
3854
+ this.appUuid = appUuid;
3855
+ this.init();
3856
+ }
3857
+ init() {
3858
+ if (this.accessToken && this.server) {
3859
+ this.server = this.server.endsWith('/') ? this.server : `${this.server}/`;
3860
+ this.req = axios$1.create({
3861
+ baseURL: this.server,
3862
+ headers: {
3863
+ Authorization: 'Token ' + this.accessToken
3864
+ }
3865
+ });
3866
+ }
3867
+ }
3868
+ listRows(page_id, table_name, start, limit) {
3869
+ const url = `${this.server}api/v2.1/universal-apps/${this.appUuid}/html-page-rows/`;
3870
+ const params = {
3871
+ page_id,
3872
+ table_name,
3873
+ start,
3874
+ limit
3875
+ };
3876
+ return this.req.get(url, {
3877
+ params
3878
+ });
3879
+ }
3880
+ addRow(page_id, table_name, row_data, row_links_data) {
3881
+ const url = `${this.server}api/v2.1/universal-apps/${this.appUuid}/html-page-rows/`;
3882
+ const data = {
3883
+ page_id,
3884
+ table_name,
3885
+ row_data,
3886
+ row_links_data
3887
+ };
3888
+ return this.req.post(url, data);
3889
+ }
3890
+ addRows(page_id, table_name, rows_data, rows_links_data) {
3891
+ const url = `${this.server}api/v2.1/universal-apps/${this.appUuid}/html-page-rows/batch/`;
3892
+ const data = {
3893
+ page_id,
3894
+ table_name,
3895
+ rows_data,
3896
+ rows_links_data
3897
+ };
3898
+ return this.req.post(url, data);
3899
+ }
3900
+ updateRows(page_id, table_name, rows_data) {
3901
+ const url = `${this.server}api/v2.1/universal-apps/${this.appUuid}/html-page-rows/`;
3902
+ const data = {
3903
+ page_id,
3904
+ table_name,
3905
+ rows_data
3906
+ };
3907
+ return this.req.put(url, data);
3908
+ }
3909
+ deleteRows(page_id, table_name, rows_ids) {
3910
+ const url = `${this.server}api/v2.1/universal-apps/${this.appUuid}/html-page-rows/`;
3911
+ const data = {
3912
+ page_id,
3913
+ table_name,
3914
+ rows_ids
3915
+ };
3916
+ return this.req.delete(url, data);
3917
+ }
3918
+ }
3919
+
3920
+ const POST_MESSAGE_TYPE = {
3921
+ HTML_PAGE_REQUEST: 'HTML_PAGE_REQUEST',
3922
+ HTML_PAGE_RESPONSE: 'HTML_PAGE_RESPONSE',
3923
+ HTML_PAGE_EVENT: 'HTML_PAGE_EVENT',
3924
+ WINDOW_EVENT: 'WINDOW_EVENT'
3925
+ };
3926
+ const POST_MESSAGE_REQUEST_TYPE = {
3927
+ GET_SERVER: 'get_server',
3928
+ GET_ACCESS_TOKEN: 'get_access_token',
3929
+ GET_APP_UUID: 'get_app_uuid',
3930
+ GET_PAGE_ID: 'get_page_id'
3931
+ };
3932
+ const WINDOW_EVENT_SOURCE_TYPE = {
3933
+ APP: 'app',
3934
+ IFRAME: 'iframe'
3935
+ };
3936
+ const SUPPORT_WINDOW_MOUSE_EVENT_TYPES = ['click', 'dblclick', 'mousemove', 'mouseenter', 'mouseleave', 'mousedown', 'mouseup', 'contextmenu'];
3937
+ const SUPPORT_WINDOW_KEYBOARD_EVENT_TYPES = ['keydown', 'keyup', 'keypress'];
3938
+ const SUPPORT_WINDOW_DRAG_EVENT_TYPES = ['dragstart', 'dragover', 'drag', 'dragend', 'dragenter', 'dragleave', 'drop'];
3939
+ const HIGH_FREQUENCY_WINDOW_EVENT_TYPES = ['mousemove', 'dragover'];
3940
+ const hasOwnProperty = (obj, key) => {
3941
+ return Object.prototype.hasOwnProperty.call(obj, key);
3942
+ };
3943
+ const generatorBase64Code = function () {
3944
+ let keyLength = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 4;
3945
+ let possible = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz0123456789';
3946
+ let key = '';
3947
+ for (let i = 0; i < keyLength; i++) {
3948
+ key += possible.charAt(Math.floor(Math.random() * possible.length));
3949
+ }
3950
+ return key;
3951
+ };
3952
+ const createWindowEventData = _ref => {
3953
+ let {
3954
+ eventType,
3955
+ event
3956
+ } = _ref;
3957
+ if (SUPPORT_WINDOW_MOUSE_EVENT_TYPES.includes(eventType)) {
3958
+ return {
3959
+ type: eventType,
3960
+ x: event.x,
3961
+ y: event.y,
3962
+ button: event.button,
3963
+ buttons: event.buttons
3964
+ };
3965
+ }
3966
+ if (SUPPORT_WINDOW_KEYBOARD_EVENT_TYPES.includes(eventType)) {
3967
+ return {
3968
+ type: eventType,
3969
+ key: event.key,
3970
+ code: event.code,
3971
+ keyCode: event.keyCode,
3972
+ ctrlKey: event.ctrlKey,
3973
+ shiftKey: event.shiftKey,
3974
+ altKey: event.altKey,
3975
+ metaKey: event.metaKey,
3976
+ repeat: event.repeat
3977
+ };
3978
+ }
3979
+ if (SUPPORT_WINDOW_DRAG_EVENT_TYPES.includes(eventType)) {
3980
+ return {
3981
+ type: eventType,
3982
+ x: event.x,
3983
+ y: event.y
3984
+ };
3985
+ }
3986
+ return null;
3987
+ };
3988
+
3989
+ /**
3990
+ * IframeAdapter – enables secure postMessage communication in production environments
3991
+ * For HTML page running inside an iframe
3992
+ */
3993
+ class IframeAdapter {
3994
+ constructor(options) {
3995
+ this.options = options || {};
3996
+ this.selfWindow = window.parent === window.self;
3997
+ this.targetOrigin = this.options.targetOrigin || '*';
3998
+ this.pendingRequests = {};
3999
+ this.eventHandlers = {};
4000
+ this.timeout = this.options.timeout || 10000;
4001
+ this.setupMessageListener();
4002
+ }
4003
+ generatorRequestId() {
4004
+ let id = generatorBase64Code();
4005
+ while (hasOwnProperty(this.pendingRequests, id)) {
4006
+ id = generatorBase64Code();
4007
+ }
4008
+ return id;
4009
+ }
4010
+ setupMessageListener() {
4011
+ if (this.selfWindow) return;
4012
+ window.addEventListener('message', this.handleMessage.bind(this));
4013
+ this.setEventsListener();
4014
+ }
4015
+ postWindowEvent(eventData) {
4016
+ if (!eventData) return;
4017
+ window.parent.postMessage({
4018
+ type: POST_MESSAGE_TYPE.WINDOW_EVENT,
4019
+ params: {
4020
+ event_data: {
4021
+ ...eventData,
4022
+ source: WINDOW_EVENT_SOURCE_TYPE.IFRAME
4023
+ }
4024
+ }
4025
+ }, this.targetOrigin);
4026
+ }
4027
+ setEventsListener() {
4028
+ let rafId = null;
4029
+ let pendingEvent = null;
4030
+ [...SUPPORT_WINDOW_MOUSE_EVENT_TYPES, ...SUPPORT_WINDOW_KEYBOARD_EVENT_TYPES, ...SUPPORT_WINDOW_DRAG_EVENT_TYPES].forEach(eventType => {
4031
+ window.addEventListener(eventType, event => {
4032
+ if (event.source === WINDOW_EVENT_SOURCE_TYPE.APP) return;
4033
+ if (HIGH_FREQUENCY_WINDOW_EVENT_TYPES.includes(eventType)) {
4034
+ // High-frequency events that need throttling (use RAF to limit to 60fps)
4035
+ // Use requestAnimationFrame for throttling high-frequency events
4036
+ // Store the latest event with necessary data
4037
+ pendingEvent = createWindowEventData({
4038
+ eventType,
4039
+ event
4040
+ });
4041
+
4042
+ // Only schedule a new frame if one isn't already scheduled
4043
+ if (rafId === null) {
4044
+ rafId = requestAnimationFrame(() => {
4045
+ if (pendingEvent) {
4046
+ this.postWindowEvent(pendingEvent);
4047
+ pendingEvent = null;
4048
+ rafId = null;
4049
+ }
4050
+ });
4051
+ }
4052
+ return;
4053
+ }
4054
+
4055
+ // Low-frequency events
4056
+ this.postWindowEvent(createWindowEventData({
4057
+ eventType,
4058
+ event
4059
+ }));
4060
+ }, true);
4061
+ });
4062
+ }
4063
+ async request(method, params) {
4064
+ if (this.selfWindow) {
4065
+ return new Promise(resolve => {
4066
+ resolve(null);
4067
+ });
4068
+ }
4069
+ const requestId = this.generatorRequestId();
4070
+ return new Promise((resolve, reject) => {
4071
+ this.pendingRequests[requestId] = {
4072
+ resolve,
4073
+ reject
4074
+ };
4075
+ window.parent.postMessage({
4076
+ type: POST_MESSAGE_TYPE.HTML_PAGE_REQUEST,
4077
+ requestId,
4078
+ method,
4079
+ params
4080
+ }, this.targetOrigin);
4081
+
4082
+ // request timeout
4083
+ // reject and clear the pending request
4084
+ const timeoutId = setTimeout(() => {
4085
+ if (hasOwnProperty(this.pendingRequests, requestId)) {
4086
+ delete this.pendingRequests[requestId];
4087
+ reject(new Error(`Request timeout: ${method}`));
4088
+ }
4089
+ }, this.timeout);
4090
+
4091
+ // save timeoutId for the pending request
4092
+ const pending = this.pendingRequests[requestId];
4093
+ if (pending) {
4094
+ pending.timeoutId = timeoutId;
4095
+ }
4096
+ });
4097
+ }
4098
+ handleMessage(event) {
4099
+ const {
4100
+ type,
4101
+ requestId,
4102
+ data,
4103
+ error,
4104
+ eventType,
4105
+ payload
4106
+ } = event.data;
4107
+ if (type === POST_MESSAGE_TYPE.HTML_PAGE_RESPONSE) {
4108
+ const pending = this.pendingRequests[requestId];
4109
+ if (pending) {
4110
+ clearTimeout(pending.timeoutId);
4111
+ delete this.pendingRequests[requestId];
4112
+ if (error) {
4113
+ pending.reject(new Error(error));
4114
+ } else {
4115
+ pending.resolve(data ? JSON.parse(data) : null);
4116
+ }
4117
+ }
4118
+ } else if (type === POST_MESSAGE_TYPE.HTML_PAGE_EVENT) {
4119
+ this.emitEvent(eventType, payload);
4120
+ } else if (type === POST_MESSAGE_TYPE.WINDOW_EVENT) {
4121
+ const eventData = data.event_data;
4122
+ if (!eventData) return;
4123
+ let syntheticEvent;
4124
+ let targetElement;
4125
+ if (SUPPORT_WINDOW_KEYBOARD_EVENT_TYPES.includes(eventData.type)) {
4126
+ syntheticEvent = new KeyboardEvent(eventData.type, {
4127
+ bubbles: true,
4128
+ cancelable: true,
4129
+ key: eventData.key,
4130
+ code: eventData.code,
4131
+ keyCode: eventData.keyCode,
4132
+ ctrlKey: eventData.ctrlKey,
4133
+ shiftKey: eventData.shiftKey,
4134
+ altKey: eventData.altKey,
4135
+ metaKey: eventData.metaKey,
4136
+ repeat: eventData.repeat,
4137
+ view: window
4138
+ });
4139
+ targetElement = document.activeElement || document.body;
4140
+ } else if (SUPPORT_WINDOW_MOUSE_EVENT_TYPES.includes(eventData.type)) {
4141
+ syntheticEvent = new MouseEvent(eventData.type, {
4142
+ bubbles: true,
4143
+ cancelable: true,
4144
+ view: window,
4145
+ clientX: eventData.x,
4146
+ clientY: eventData.y,
4147
+ screenX: eventData.x,
4148
+ screenY: eventData.y,
4149
+ button: eventData.button,
4150
+ buttons: eventData.buttons
4151
+ });
4152
+ const elementAtPoint = document.elementFromPoint(eventData.x, eventData.y);
4153
+ targetElement = elementAtPoint || document.body;
4154
+ } else if (SUPPORT_WINDOW_DRAG_EVENT_TYPES.includes(eventData.type)) {
4155
+ syntheticEvent = new DragEvent(eventData.type, {
4156
+ bubbles: true,
4157
+ cancelable: true,
4158
+ view: window,
4159
+ clientX: eventData.x,
4160
+ clientY: eventData.y,
4161
+ screenX: eventData.x,
4162
+ screenY: eventData.y,
4163
+ button: eventData.button,
4164
+ buttons: eventData.buttons
4165
+ });
4166
+ const elementAtPoint = document.elementFromPoint(eventData.x, eventData.y);
4167
+ targetElement = elementAtPoint || document.body;
4168
+ }
4169
+ if (!targetElement || !syntheticEvent) return;
4170
+
4171
+ // Dispatch once on the target element, it will bubble up naturally
4172
+ syntheticEvent.source = eventData.source;
4173
+ targetElement.dispatchEvent(syntheticEvent);
4174
+ }
4175
+ }
4176
+ on(eventType, handler) {
4177
+ if (!hasOwnProperty(this.eventHandlers, eventType)) {
4178
+ this.eventHandlers[eventType] = [];
4179
+ }
4180
+ this.eventHandlers[eventType].push(handler);
4181
+ return () => this.off(eventType, handler);
4182
+ }
4183
+ off(eventType, handler) {
4184
+ const handlers = this.eventHandlers[eventType];
4185
+ if (handlers) {
4186
+ const index = handlers.indexOf(handler);
4187
+ if (index !== -1) {
4188
+ handlers.splice(index, 1);
4189
+ }
4190
+ }
4191
+ }
4192
+ emitEvent(eventType, payload) {
4193
+ const handlers = this.eventHandlers[eventType] || [];
4194
+ handlers.forEach(handler => {
4195
+ try {
4196
+ handler(payload);
4197
+ } catch (error) {
4198
+ // eslint-disable-next-line
4199
+ console.error(`Error in event handler for ${eventType}:`, error);
4200
+ }
4201
+ });
4202
+ }
4203
+ destroy() {
4204
+ this.pendingRequests.forEach(pending => {
4205
+ clearTimeout(pending.timeoutId);
4206
+ pending.reject(new Error('Adapter destroyed'));
4207
+ });
4208
+ this.pendingRequests = {};
4209
+ this.eventHandlers = {};
4210
+ }
4211
+ }
4212
+
4213
+ class HTMLPageSDK {
4214
+ constructor(options) {
4215
+ this.options = options || {};
4216
+ this.iframeAdapter = new IframeAdapter(options);
4217
+ }
4218
+ async init() {
4219
+ if (!this.options) {
4220
+ this.options = {};
4221
+ }
4222
+ if (!this.options.server) {
4223
+ this.options.server = await this.iframeAdapter.request(POST_MESSAGE_REQUEST_TYPE.GET_SERVER);
4224
+ }
4225
+ if (!this.options.accessToken) {
4226
+ this.options.accessToken = await this.iframeAdapter.request(POST_MESSAGE_REQUEST_TYPE.GET_ACCESS_TOKEN);
4227
+ }
4228
+ if (!this.options.appUuid) {
4229
+ this.options.appUuid = await this.iframeAdapter.request(POST_MESSAGE_REQUEST_TYPE.GET_APP_UUID);
4230
+ }
4231
+ if (!this.options.pageId) {
4232
+ this.options.pageId = await this.iframeAdapter.request(POST_MESSAGE_REQUEST_TYPE.GET_PAGE_ID);
4233
+ }
4234
+ const {
4235
+ server,
4236
+ accessToken,
4237
+ appUuid
4238
+ } = this.options;
4239
+ this.universalAppAPI = new UniversalAppAPI({
4240
+ server,
4241
+ accessToken,
4242
+ appUuid
4243
+ });
4244
+ }
4245
+ listRows(_ref) {
4246
+ let {
4247
+ tableName,
4248
+ start,
4249
+ limit
4250
+ } = _ref;
4251
+ return this.universalAppAPI.listRows(this.options.pageId, tableName, start, limit);
4252
+ }
4253
+ addRow(_ref2) {
4254
+ let {
4255
+ tableName,
4256
+ rowData,
4257
+ rowLinksData
4258
+ } = _ref2;
4259
+ return this.universalAppAPI.addRow(this.options.pageId, tableName, rowData, rowLinksData);
4260
+ }
4261
+ updateRow(_ref3) {
4262
+ let {
4263
+ tableName,
4264
+ rowId,
4265
+ rowData
4266
+ } = _ref3;
4267
+ const rowsData = [{
4268
+ id: rowId,
4269
+ row: rowData
4270
+ }];
4271
+ this.batchUpdateRows({
4272
+ tableName,
4273
+ rowsData
4274
+ });
4275
+ }
4276
+ deleteRow(_ref4) {
4277
+ let {
4278
+ tableName,
4279
+ rowId
4280
+ } = _ref4;
4281
+ const rowsIds = [rowId];
4282
+ return this.batchDeleteRows({
4283
+ tableName,
4284
+ rowsIds
4285
+ });
4286
+ }
4287
+ batchAddRows(_ref5) {
4288
+ let {
4289
+ tableName,
4290
+ rowsData,
4291
+ rowsLinksData
4292
+ } = _ref5;
4293
+ return this.universalAppAPI.addRows(this.options.pageId, tableName, rowsData, rowsLinksData);
4294
+ }
4295
+ batchUpdateRows(_ref6) {
4296
+ let {
4297
+ tableName,
4298
+ rowsData
4299
+ } = _ref6;
4300
+ return this.universalAppAPI.updateRows(this.options.pageId, tableName, rowsData);
4301
+ }
4302
+ batchDeleteRows(_ref7) {
4303
+ let {
4304
+ tableName,
4305
+ rowsIds
4306
+ } = _ref7;
4307
+ return this.universalAppAPI.deleteRows(this.options.pageId, tableName, rowsIds);
4308
+ }
4309
+ }
4310
+
4311
+ return HTMLPageSDK;
4312
+
4313
+ }));
4314
+ //# sourceMappingURL=index.js.map