@fyno/node 1.1.4 → 1.1.8
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/README.md +68 -1
- package/dist/main.js +1 -1
- package/package.json +1 -1
- package/src/Profile/index.js +137 -0
- package/src/index.js +57 -1
- package/.github/workflows/npm-publish.yml +0 -37
- package/test/event.test.js +0 -208
- package/test/index.spec.js +0 -1
package/README.md
CHANGED
|
@@ -97,4 +97,71 @@ fyno.fire("<EventName>", [
|
|
|
97
97
|
```
|
|
98
98
|
**Caution:** The maximum accepted payload size (for bulk send) is 10 MB.
|
|
99
99
|
|
|
100
|
-
For more details, please visit our [API Reference guide](https://docs.fyno.io/reference).
|
|
100
|
+
For more details, please visit our [API Reference guide](https://docs.fyno.io/reference).
|
|
101
|
+
|
|
102
|
+
# Creating a user profile
|
|
103
|
+
You can create a user profile using `identify()` method and update the existing profile with `updateProfile()` method, use the below snipped to create user profile in Fyno
|
|
104
|
+
|
|
105
|
+
```js
|
|
106
|
+
const profile = fyno.identify("<DISTINCTID>", {
|
|
107
|
+
name: "<FULL NAME>",
|
|
108
|
+
channel: {
|
|
109
|
+
sms: "", // Enter mobile number for sms channel with country code
|
|
110
|
+
whatsapp: "", // Enter mobile number for whatsapp channel with country code
|
|
111
|
+
email: "", // Enter email address
|
|
112
|
+
slack: "", // Enter Slack Id or Email address
|
|
113
|
+
discord: "", // Enter Discord id
|
|
114
|
+
teams: "", // Enter channel name
|
|
115
|
+
inapp: [{
|
|
116
|
+
token: "", // Enter Inapp token
|
|
117
|
+
integration_id: "", // Enter Inapp integration ID to be used for this token.
|
|
118
|
+
status: "" // Status of token
|
|
119
|
+
}],
|
|
120
|
+
push: [{
|
|
121
|
+
token: "", // Enter Push token
|
|
122
|
+
integration_id: "", // Enter Push integration ID to be used for this token.
|
|
123
|
+
status: "" // Status of token
|
|
124
|
+
}]
|
|
125
|
+
}
|
|
126
|
+
})
|
|
127
|
+
profile.create()
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
use the below code to update the existing profile
|
|
131
|
+
|
|
132
|
+
```js
|
|
133
|
+
const profile = fyno.update("<DISTINCTID>", {
|
|
134
|
+
name: "<MODIFIED_FULL NAME>",
|
|
135
|
+
channel: {
|
|
136
|
+
sms: "", // Enter mobile number for sms channel with country code
|
|
137
|
+
whatsapp: "", // Enter mobile number for whatsapp channel with country code
|
|
138
|
+
email: "", // Enter email address
|
|
139
|
+
slack: "", // Enter Slack Id or Email address
|
|
140
|
+
discord: "", // Enter Discord id
|
|
141
|
+
teams: "", // Enter channel name
|
|
142
|
+
inapp: [{
|
|
143
|
+
token: "", // Enter Inapp token
|
|
144
|
+
integration_id: "", // Enter Inapp integration ID to be used for this token.
|
|
145
|
+
status: "" // Status of token
|
|
146
|
+
}],
|
|
147
|
+
push: [{
|
|
148
|
+
token: "", // Enter Push token
|
|
149
|
+
integration_id: "", // Enter Push integration ID to be used for this token.
|
|
150
|
+
status: "" // Status of token
|
|
151
|
+
}]
|
|
152
|
+
}
|
|
153
|
+
})
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
# Adding and Removing Channels against a proflie
|
|
157
|
+
Once user is created you can use the returned object to add or remove channle data, use the below snippet to add/remove channle data
|
|
158
|
+
|
|
159
|
+
```js
|
|
160
|
+
const profile = fyno.identify("<DISTINCTID>")
|
|
161
|
+
//This will add sms number against the profile
|
|
162
|
+
profile.setSms("<MOBILE_NUMBER>")
|
|
163
|
+
//This will clear sms channel
|
|
164
|
+
profile.clearChannel(["sms", "whatsapp"])
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
> **_NOTE:_** For clearing channel you can just pass channel name except for inapp and push, for inapp and push you need to pass token like `profile.clearChannel("inapp", "<INAPP_TOKEN>")`
|
package/dist/main.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/*! For license information please see main.js.LICENSE.txt */
|
|
2
|
-
(()=>{var e={889:(e,t,r)=>{const n=r(164).ZP;e.exports=n,e.exports.default=n},367:e=>{"use strict";const t=new Set(["ENOTFOUND","ENETUNREACH","UNABLE_TO_GET_ISSUER_CERT","UNABLE_TO_GET_CRL","UNABLE_TO_DECRYPT_CERT_SIGNATURE","UNABLE_TO_DECRYPT_CRL_SIGNATURE","UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY","CERT_SIGNATURE_FAILURE","CRL_SIGNATURE_FAILURE","CERT_NOT_YET_VALID","CERT_HAS_EXPIRED","CRL_NOT_YET_VALID","CRL_HAS_EXPIRED","ERROR_IN_CERT_NOT_BEFORE_FIELD","ERROR_IN_CERT_NOT_AFTER_FIELD","ERROR_IN_CRL_LAST_UPDATE_FIELD","ERROR_IN_CRL_NEXT_UPDATE_FIELD","OUT_OF_MEM","DEPTH_ZERO_SELF_SIGNED_CERT","SELF_SIGNED_CERT_IN_CHAIN","UNABLE_TO_GET_ISSUER_CERT_LOCALLY","UNABLE_TO_VERIFY_LEAF_SIGNATURE","CERT_CHAIN_TOO_LONG","CERT_REVOKED","INVALID_CA","PATH_LENGTH_EXCEEDED","INVALID_PURPOSE","CERT_UNTRUSTED","CERT_REJECTED","HOSTNAME_MISMATCH"]);e.exports=e=>!t.has(e&&e.code)},400:(e,t,r)=>{const n=r(218),o=r(889);e.exports={Event:class{constructor(e,t,r,i){this.endpoint=new URL("event",e).href,this.payload={event:r,...i},this.headers=t,Array.isArray(i)&&(this.endpoint=new URL("event/bulk",e).href,this.payload={event:r,batch:i}),o(n,{retries:3,retryDelay:o.exponentialDelay,retryCondition:e=>202!==e.response.status&&401!==e.response.status})}trigger=async()=>new Promise(((e,t)=>{n.post(this.endpoint,this.payload,{headers:this.headers}).then((t=>{e(t.data)})).catch((e=>{t(e.response?.data)}))}))}}},138:(e,t,r)=>{const{Event:n}=r(400);e.exports={Fyno:class{wsid=process.env.FYNO_WSID;api_key=process.env.FYNO_API_KEY;version=process.env.FYNO_VERSION||"live";endpoint=process.env.FYNO_ENDPOINT||"https://api.fyno.io/v1/";constructor(e=this.wsid,t=this.api_key,r=this.version,n=this.endpoint){this.wsid=e,this.api_key=t,this.version=r,this.endpoint=new URL(`${this.wsid}/${this.version}`,n).href,this.headers=this.getHeaders(),this.validate()}getHeaders(){return{Authorization:`Bearer ${this.api_key}`,"Content-Type":"application/json"}}validate(){if(!this.wsid||this.wsid.length<10||this.wsid.length>20)throw new Error(`Workspace ID value '${this.wsid}' is invalid`);if(!this.api_key||this.api_key.length<25||this.api_key.length>60)throw new Error(`API Key value '${this.api_key}' is invalid`);if(!["test","live"].includes(`${this.version}`))throw new Error(`Environment value '${this.version}' is invalid. It should be either 'test' or 'live'.`)}async fire(e,t){return new n(this.endpoint,this.headers,e,t).trigger()}}}},156:e=>{function t(e,t,r,n,o,i,s){try{var a=e[i](s),c=a.value}catch(e){return void r(e)}a.done?t(c):Promise.resolve(c).then(n,o)}e.exports=function(e){return function(){var r=this,n=arguments;return new Promise((function(o,i){var s=e.apply(r,n);function a(e){t(s,o,i,a,c,"next",e)}function c(e){t(s,o,i,a,c,"throw",e)}a(void 0)}))}},e.exports.__esModule=!0,e.exports.default=e.exports},416:(e,t,r)=>{var n=r(62);e.exports=function(e,t,r){return(t=n(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e},e.exports.__esModule=!0,e.exports.default=e.exports},836:e=>{e.exports=function(e){return e&&e.__esModule?e:{default:e}},e.exports.__esModule=!0,e.exports.default=e.exports},61:(e,t,r)=>{var n=r(698).default;function o(){"use strict";e.exports=o=function(){return t},e.exports.__esModule=!0,e.exports.default=e.exports;var t={},r=Object.prototype,i=r.hasOwnProperty,s=Object.defineProperty||function(e,t,r){e[t]=r.value},a="function"==typeof Symbol?Symbol:{},c=a.iterator||"@@iterator",u=a.asyncIterator||"@@asyncIterator",l=a.toStringTag||"@@toStringTag";function f(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{f({},"")}catch(e){f=function(e,t,r){return e[t]=r}}function p(e,t,r,n){var o=t&&t.prototype instanceof m?t:m,i=Object.create(o.prototype),a=new A(n||[]);return s(i,"_invoke",{value:_(e,r,a)}),i}function d(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}t.wrap=p;var h={};function m(){}function y(){}function g(){}var E={};f(E,c,(function(){return this}));var v=Object.getPrototypeOf,b=v&&v(v(N([])));b&&b!==r&&i.call(b,c)&&(E=b);var w=g.prototype=m.prototype=Object.create(E);function O(e){["next","throw","return"].forEach((function(t){f(e,t,(function(e){return this._invoke(t,e)}))}))}function R(e,t){function r(o,s,a,c){var u=d(e[o],e,s);if("throw"!==u.type){var l=u.arg,f=l.value;return f&&"object"==n(f)&&i.call(f,"__await")?t.resolve(f.__await).then((function(e){r("next",e,a,c)}),(function(e){r("throw",e,a,c)})):t.resolve(f).then((function(e){l.value=e,a(l)}),(function(e){return r("throw",e,a,c)}))}c(u.arg)}var o;s(this,"_invoke",{value:function(e,n){function i(){return new t((function(t,o){r(e,n,t,o)}))}return o=o?o.then(i,i):i()}})}function _(e,t,r){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return{value:void 0,done:!0}}for(r.method=o,r.arg=i;;){var s=r.delegate;if(s){var a=S(s,r);if(a){if(a===h)continue;return a}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var c=d(e,t,r);if("normal"===c.type){if(n=r.done?"completed":"suspendedYield",c.arg===h)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(n="completed",r.method="throw",r.arg=c.arg)}}}function S(e,t){var r=t.method,n=e.iterator[r];if(void 0===n)return t.delegate=null,"throw"===r&&e.iterator.return&&(t.method="return",t.arg=void 0,S(e,t),"throw"===t.method)||"return"!==r&&(t.method="throw",t.arg=new TypeError("The iterator does not provide a '"+r+"' method")),h;var o=d(n,e.iterator,t.arg);if("throw"===o.type)return t.method="throw",t.arg=o.arg,t.delegate=null,h;var i=o.arg;return i?i.done?(t[e.resultName]=i.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,h):i:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,h)}function T(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function x(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function A(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(T,this),this.reset(!0)}function N(e){if(e){var t=e[c];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var r=-1,n=function t(){for(;++r<e.length;)if(i.call(e,r))return t.value=e[r],t.done=!1,t;return t.value=void 0,t.done=!0,t};return n.next=n}}return{next:L}}function L(){return{value:void 0,done:!0}}return y.prototype=g,s(w,"constructor",{value:g,configurable:!0}),s(g,"constructor",{value:y,configurable:!0}),y.displayName=f(g,l,"GeneratorFunction"),t.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===y||"GeneratorFunction"===(t.displayName||t.name))},t.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,g):(e.__proto__=g,f(e,l,"GeneratorFunction")),e.prototype=Object.create(w),e},t.awrap=function(e){return{__await:e}},O(R.prototype),f(R.prototype,u,(function(){return this})),t.AsyncIterator=R,t.async=function(e,r,n,o,i){void 0===i&&(i=Promise);var s=new R(p(e,r,n,o),i);return t.isGeneratorFunction(r)?s:s.next().then((function(e){return e.done?e.value:s.next()}))},O(w),f(w,l,"Generator"),f(w,c,(function(){return this})),f(w,"toString",(function(){return"[object Generator]"})),t.keys=function(e){var t=Object(e),r=[];for(var n in t)r.push(n);return r.reverse(),function e(){for(;r.length;){var n=r.pop();if(n in t)return e.value=n,e.done=!1,e}return e.done=!0,e}},t.values=N,A.prototype={constructor:A,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(x),!e)for(var t in this)"t"===t.charAt(0)&&i.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function r(r,n){return s.type="throw",s.arg=e,t.next=r,n&&(t.method="next",t.arg=void 0),!!n}for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n],s=o.completion;if("root"===o.tryLoc)return r("end");if(o.tryLoc<=this.prev){var a=i.call(o,"catchLoc"),c=i.call(o,"finallyLoc");if(a&&c){if(this.prev<o.catchLoc)return r(o.catchLoc,!0);if(this.prev<o.finallyLoc)return r(o.finallyLoc)}else if(a){if(this.prev<o.catchLoc)return r(o.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return r(o.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var n=this.tryEntries[r];if(n.tryLoc<=this.prev&&i.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var o=n;break}}o&&("break"===e||"continue"===e)&&o.tryLoc<=t&&t<=o.finallyLoc&&(o=null);var s=o?o.completion:{};return s.type=e,s.arg=t,o?(this.method="next",this.next=o.finallyLoc,h):this.complete(s)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),h},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),x(r),h}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var o=n.arg;x(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:N(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=void 0),h}},t}e.exports=o,e.exports.__esModule=!0,e.exports.default=e.exports},36:(e,t,r)=>{var n=r(698).default;e.exports=function(e,t){if("object"!==n(e)||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var o=r.call(e,t||"default");if("object"!==n(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)},e.exports.__esModule=!0,e.exports.default=e.exports},62:(e,t,r)=>{var n=r(698).default,o=r(36);e.exports=function(e){var t=o(e,"string");return"symbol"===n(t)?t:String(t)},e.exports.__esModule=!0,e.exports.default=e.exports},698:e=>{function t(r){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(r)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports},687:(e,t,r)=>{var n=r(61)();e.exports=n;try{regeneratorRuntime=n}catch(e){"object"==typeof globalThis?globalThis.regeneratorRuntime=n:Function("r","regeneratorRuntime = r")(n)}},164:(e,t,r)=>{"use strict";var n=r(836);t.ZP=_;var o=n(r(687)),i=n(r(698)),s=n(r(156)),a=n(r(416)),c=n(r(367));function u(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function l(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?u(Object(r),!0).forEach((function(t){(0,a.default)(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):u(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}var f="axios-retry";function p(e){return!e.response&&Boolean(e.code)&&"ECONNABORTED"!==e.code&&(0,c.default)(e)}var d=["get","head","options"],h=d.concat(["put","delete"]);function m(e){return"ECONNABORTED"!==e.code&&(!e.response||e.response.status>=500&&e.response.status<=599)}function y(e){return!!e.config&&m(e)&&-1!==h.indexOf(e.config.method)}function g(e){return p(e)||y(e)}function E(){return 0}function v(e){var t=e[f]||{};return t.retryCount=t.retryCount||0,e[f]=t,t}function b(e,t){return l(l({},t),e[f])}function w(e,t){e.defaults.agent===t.agent&&delete t.agent,e.defaults.httpAgent===t.httpAgent&&delete t.httpAgent,e.defaults.httpsAgent===t.httpsAgent&&delete t.httpsAgent}function O(e,t,r,n){return R.apply(this,arguments)}function R(){return(R=(0,s.default)(o.default.mark((function e(t,r,n,s){var a,c;return o.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(a=n.retryCount<t&&r(s),"object"!==(0,i.default)(a)){e.next=12;break}return e.prev=2,e.next=5,a;case 5:return c=e.sent,e.abrupt("return",!1!==c);case 9:return e.prev=9,e.t0=e.catch(2),e.abrupt("return",!1);case 12:return e.abrupt("return",a);case 13:case"end":return e.stop()}}),e,null,[[2,9]])})))).apply(this,arguments)}function _(e,t){e.interceptors.request.use((function(e){return v(e).lastRequestTime=Date.now(),e})),e.interceptors.response.use(null,function(){var r=(0,s.default)(o.default.mark((function r(n){var i,s,a,c,u,l,f,p,d,h,m,y,R,_,S,T;return o.default.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(i=n.config){r.next=3;break}return r.abrupt("return",Promise.reject(n));case 3:return s=b(i,t),a=s.retries,c=void 0===a?3:a,u=s.retryCondition,l=void 0===u?g:u,f=s.retryDelay,p=void 0===f?E:f,d=s.shouldResetTimeout,h=void 0!==d&&d,m=s.onRetry,y=void 0===m?function(){}:m,R=v(i),r.next=7,O(c,l,R,n);case 7:if(!r.sent){r.next=20;break}if(R.retryCount+=1,_=p(R.retryCount,n),w(e,i),h||!i.timeout||!R.lastRequestTime){r.next=17;break}if(S=Date.now()-R.lastRequestTime,!((T=i.timeout-S-_)<=0)){r.next=16;break}return r.abrupt("return",Promise.reject(n));case 16:i.timeout=T;case 17:return i.transformRequest=[function(e){return e}],y(R.retryCount,n,i),r.abrupt("return",new Promise((function(t){return setTimeout((function(){return t(e(i))}),_)})));case 20:return r.abrupt("return",Promise.reject(n));case 21:case"end":return r.stop()}}),r)})));return function(e){return r.apply(this,arguments)}}())}_.isNetworkError=p,_.isSafeRequestError=function(e){return!!e.config&&m(e)&&-1!==d.indexOf(e.config.method)},_.isIdempotentRequestError=y,_.isNetworkOrIdempotentRequestError=g,_.exponentialDelay=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,t=100*Math.pow(2,e);return t+.2*t*Math.random()},_.isRetryableError=m},218:(e,t,r)=>{"use strict";function n(e,t){return function(){return e.apply(t,arguments)}}const{toString:o}=Object.prototype,{getPrototypeOf:i}=Object,s=(a=Object.create(null),e=>{const t=o.call(e);return a[t]||(a[t]=t.slice(8,-1).toLowerCase())});var a;const c=e=>(e=e.toLowerCase(),t=>s(t)===e),u=e=>t=>typeof t===e,{isArray:l}=Array,f=u("undefined"),p=c("ArrayBuffer"),d=u("string"),h=u("function"),m=u("number"),y=e=>null!==e&&"object"==typeof e,g=e=>{if("object"!==s(e))return!1;const t=i(e);return!(null!==t&&t!==Object.prototype&&null!==Object.getPrototypeOf(t)||Symbol.toStringTag in e||Symbol.iterator in e)},E=c("Date"),v=c("File"),b=c("Blob"),w=c("FileList"),O=c("URLSearchParams");function R(e,t,{allOwnKeys:r=!1}={}){if(null==e)return;let n,o;if("object"!=typeof e&&(e=[e]),l(e))for(n=0,o=e.length;n<o;n++)t.call(null,e[n],n,e);else{const o=r?Object.getOwnPropertyNames(e):Object.keys(e),i=o.length;let s;for(n=0;n<i;n++)s=o[n],t.call(null,e[s],s,e)}}function _(e,t){t=t.toLowerCase();const r=Object.keys(e);let n,o=r.length;for(;o-- >0;)if(n=r[o],t===n.toLowerCase())return n;return null}const S="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:r.g,T=e=>!f(e)&&e!==S,x=(A="undefined"!=typeof Uint8Array&&i(Uint8Array),e=>A&&e instanceof A);var A;const N=c("HTMLFormElement"),L=(({hasOwnProperty:e})=>(t,r)=>e.call(t,r))(Object.prototype),C=c("RegExp"),P=(e,t)=>{const r=Object.getOwnPropertyDescriptors(e),n={};R(r,((r,o)=>{!1!==t(r,o,e)&&(n[o]=r)})),Object.defineProperties(e,n)},j="abcdefghijklmnopqrstuvwxyz",D="0123456789",U={DIGIT:D,ALPHA:j,ALPHA_DIGIT:j+j.toUpperCase()+D};var F={isArray:l,isArrayBuffer:p,isBuffer:function(e){return null!==e&&!f(e)&&null!==e.constructor&&!f(e.constructor)&&h(e.constructor.isBuffer)&&e.constructor.isBuffer(e)},isFormData:e=>{const t="[object FormData]";return e&&("function"==typeof FormData&&e instanceof FormData||o.call(e)===t||h(e.toString)&&e.toString()===t)},isArrayBufferView:function(e){let t;return t="undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&p(e.buffer),t},isString:d,isNumber:m,isBoolean:e=>!0===e||!1===e,isObject:y,isPlainObject:g,isUndefined:f,isDate:E,isFile:v,isBlob:b,isRegExp:C,isFunction:h,isStream:e=>y(e)&&h(e.pipe),isURLSearchParams:O,isTypedArray:x,isFileList:w,forEach:R,merge:function e(){const{caseless:t}=T(this)&&this||{},r={},n=(n,o)=>{const i=t&&_(r,o)||o;g(r[i])&&g(n)?r[i]=e(r[i],n):g(n)?r[i]=e({},n):l(n)?r[i]=n.slice():r[i]=n};for(let e=0,t=arguments.length;e<t;e++)arguments[e]&&R(arguments[e],n);return r},extend:(e,t,r,{allOwnKeys:o}={})=>(R(t,((t,o)=>{r&&h(t)?e[o]=n(t,r):e[o]=t}),{allOwnKeys:o}),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,r,n)=>{e.prototype=Object.create(t.prototype,n),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),r&&Object.assign(e.prototype,r)},toFlatObject:(e,t,r,n)=>{let o,s,a;const c={};if(t=t||{},null==e)return t;do{for(o=Object.getOwnPropertyNames(e),s=o.length;s-- >0;)a=o[s],n&&!n(a,e,t)||c[a]||(t[a]=e[a],c[a]=!0);e=!1!==r&&i(e)}while(e&&(!r||r(e,t))&&e!==Object.prototype);return t},kindOf:s,kindOfTest:c,endsWith:(e,t,r)=>{e=String(e),(void 0===r||r>e.length)&&(r=e.length),r-=t.length;const n=e.indexOf(t,r);return-1!==n&&n===r},toArray:e=>{if(!e)return null;if(l(e))return e;let t=e.length;if(!m(t))return null;const r=new Array(t);for(;t-- >0;)r[t]=e[t];return r},forEachEntry:(e,t)=>{const r=(e&&e[Symbol.iterator]).call(e);let n;for(;(n=r.next())&&!n.done;){const r=n.value;t.call(e,r[0],r[1])}},matchAll:(e,t)=>{let r;const n=[];for(;null!==(r=e.exec(t));)n.push(r);return n},isHTMLForm:N,hasOwnProperty:L,hasOwnProp:L,reduceDescriptors:P,freezeMethods:e=>{P(e,((t,r)=>{if(h(e)&&-1!==["arguments","caller","callee"].indexOf(r))return!1;const n=e[r];h(n)&&(t.enumerable=!1,"writable"in t?t.writable=!1:t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+r+"'")}))}))},toObjectSet:(e,t)=>{const r={},n=e=>{e.forEach((e=>{r[e]=!0}))};return l(e)?n(e):n(String(e).split(t)),r},toCamelCase:e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,(function(e,t,r){return t.toUpperCase()+r})),noop:()=>{},toFiniteNumber:(e,t)=>(e=+e,Number.isFinite(e)?e:t),findKey:_,global:S,isContextDefined:T,ALPHABET:U,generateString:(e=16,t=U.ALPHA_DIGIT)=>{let r="";const{length:n}=t;for(;e--;)r+=t[Math.random()*n|0];return r},isSpecCompliantForm:function(e){return!!(e&&h(e.append)&&"FormData"===e[Symbol.toStringTag]&&e[Symbol.iterator])},toJSONObject:e=>{const t=new Array(10),r=(e,n)=>{if(y(e)){if(t.indexOf(e)>=0)return;if(!("toJSON"in e)){t[n]=e;const o=l(e)?[]:{};return R(e,((e,t)=>{const i=r(e,n+1);!f(i)&&(o[t]=i)})),t[n]=void 0,o}}return e};return r(e,0)}};function I(e,t,r,n,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),r&&(this.config=r),n&&(this.request=n),o&&(this.response=o)}F.inherits(I,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:F.toJSONObject(this.config),code:this.code,status:this.response&&this.response.status?this.response.status:null}}});const k=I.prototype,B={};function M(e){return F.isPlainObject(e)||F.isArray(e)}function q(e){return F.endsWith(e,"[]")?e.slice(0,-2):e}function H(e,t,r){return e?e.concat(t).map((function(e,t){return e=q(e),!r&&t?"["+e+"]":e})).join(r?".":""):t}["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=>{B[e]={value:e}})),Object.defineProperties(I,B),Object.defineProperty(k,"isAxiosError",{value:!0}),I.from=(e,t,r,n,o,i)=>{const s=Object.create(k);return F.toFlatObject(e,s,(function(e){return e!==Error.prototype}),(e=>"isAxiosError"!==e)),I.call(s,e.message,t,r,n,o),s.cause=e,s.name=e.name,i&&Object.assign(s,i),s};const G=F.toFlatObject(F,{},null,(function(e){return/^is[A-Z]/.test(e)}));function z(e,t,r){if(!F.isObject(e))throw new TypeError("target must be an object");t=t||new FormData;const n=(r=F.toFlatObject(r,{metaTokens:!0,dots:!1,indexes:!1},!1,(function(e,t){return!F.isUndefined(t[e])}))).metaTokens,o=r.visitor||u,i=r.dots,s=r.indexes,a=(r.Blob||"undefined"!=typeof Blob&&Blob)&&F.isSpecCompliantForm(t);if(!F.isFunction(o))throw new TypeError("visitor must be a function");function c(e){if(null===e)return"";if(F.isDate(e))return e.toISOString();if(!a&&F.isBlob(e))throw new I("Blob is not supported. Use a Buffer instead.");return F.isArrayBuffer(e)||F.isTypedArray(e)?a&&"function"==typeof Blob?new Blob([e]):Buffer.from(e):e}function u(e,r,o){let a=e;if(e&&!o&&"object"==typeof e)if(F.endsWith(r,"{}"))r=n?r:r.slice(0,-2),e=JSON.stringify(e);else if(F.isArray(e)&&function(e){return F.isArray(e)&&!e.some(M)}(e)||(F.isFileList(e)||F.endsWith(r,"[]"))&&(a=F.toArray(e)))return r=q(r),a.forEach((function(e,n){!F.isUndefined(e)&&null!==e&&t.append(!0===s?H([r],n,i):null===s?r:r+"[]",c(e))})),!1;return!!M(e)||(t.append(H(o,r,i),c(e)),!1)}const l=[],f=Object.assign(G,{defaultVisitor:u,convertValue:c,isVisitable:M});if(!F.isObject(e))throw new TypeError("data must be an object");return function e(r,n){if(!F.isUndefined(r)){if(-1!==l.indexOf(r))throw Error("Circular reference detected in "+n.join("."));l.push(r),F.forEach(r,(function(r,i){!0===(!(F.isUndefined(r)||null===r)&&o.call(t,r,F.isString(i)?i.trim():i,n,f))&&e(r,n?n.concat(i):[i])})),l.pop()}}(e),t}function J(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,(function(e){return t[e]}))}function V(e,t){this._pairs=[],e&&z(e,this,t)}const K=V.prototype;function W(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function Y(e,t,r){if(!t)return e;const n=r&&r.encode||W,o=r&&r.serialize;let i;if(i=o?o(t,r):F.isURLSearchParams(t)?t.toString():new V(t,r).toString(n),i){const t=e.indexOf("#");-1!==t&&(e=e.slice(0,t)),e+=(-1===e.indexOf("?")?"?":"&")+i}return e}K.append=function(e,t){this._pairs.push([e,t])},K.toString=function(e){const t=e?function(t){return e.call(this,t,J)}:J;return this._pairs.map((function(e){return t(e[0])+"="+t(e[1])}),"").join("&")};var $=class{constructor(){this.handlers=[]}use(e,t,r){return this.handlers.push({fulfilled:e,rejected:t,synchronous:!!r&&r.synchronous,runWhen:r?r.runWhen:null}),this.handlers.length-1}eject(e){this.handlers[e]&&(this.handlers[e]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(e){F.forEach(this.handlers,(function(t){null!==t&&e(t)}))}},X={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},Z={isBrowser:!0,classes:{URLSearchParams:"undefined"!=typeof URLSearchParams?URLSearchParams:V,FormData:"undefined"!=typeof FormData?FormData:null,Blob:"undefined"!=typeof Blob?Blob:null},isStandardBrowserEnv:(()=>{let e;return("undefined"==typeof navigator||"ReactNative"!==(e=navigator.product)&&"NativeScript"!==e&&"NS"!==e)&&"undefined"!=typeof window&&"undefined"!=typeof document})(),isStandardBrowserWebWorkerEnv:"undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope&&"function"==typeof self.importScripts,protocols:["http","https","file","blob","url","data"]};function Q(e){function t(e,r,n,o){let i=e[o++];const s=Number.isFinite(+i),a=o>=e.length;return i=!i&&F.isArray(n)?n.length:i,a?(F.hasOwnProp(n,i)?n[i]=[n[i],r]:n[i]=r,!s):(n[i]&&F.isObject(n[i])||(n[i]=[]),t(e,r,n[i],o)&&F.isArray(n[i])&&(n[i]=function(e){const t={},r=Object.keys(e);let n;const o=r.length;let i;for(n=0;n<o;n++)i=r[n],t[i]=e[i];return t}(n[i])),!s)}if(F.isFormData(e)&&F.isFunction(e.entries)){const r={};return F.forEachEntry(e,((e,n)=>{t(function(e){return F.matchAll(/\w+|\[(\w*)]/g,e).map((e=>"[]"===e[0]?"":e[1]||e[0]))}(e),n,r,0)})),r}return null}const ee={"Content-Type":void 0},te={transitional:X,adapter:["xhr","http"],transformRequest:[function(e,t){const r=t.getContentType()||"",n=r.indexOf("application/json")>-1,o=F.isObject(e);if(o&&F.isHTMLForm(e)&&(e=new FormData(e)),F.isFormData(e))return n&&n?JSON.stringify(Q(e)):e;if(F.isArrayBuffer(e)||F.isBuffer(e)||F.isStream(e)||F.isFile(e)||F.isBlob(e))return e;if(F.isArrayBufferView(e))return e.buffer;if(F.isURLSearchParams(e))return t.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),e.toString();let i;if(o){if(r.indexOf("application/x-www-form-urlencoded")>-1)return function(e,t){return z(e,new Z.classes.URLSearchParams,Object.assign({visitor:function(e,t,r,n){return Z.isNode&&F.isBuffer(e)?(this.append(t,e.toString("base64")),!1):n.defaultVisitor.apply(this,arguments)}},t))}(e,this.formSerializer).toString();if((i=F.isFileList(e))||r.indexOf("multipart/form-data")>-1){const t=this.env&&this.env.FormData;return z(i?{"files[]":e}:e,t&&new t,this.formSerializer)}}return o||n?(t.setContentType("application/json",!1),function(e,t,r){if(F.isString(e))try{return(0,JSON.parse)(e),F.trim(e)}catch(e){if("SyntaxError"!==e.name)throw e}return(0,JSON.stringify)(e)}(e)):e}],transformResponse:[function(e){const t=this.transitional||te.transitional,r=t&&t.forcedJSONParsing,n="json"===this.responseType;if(e&&F.isString(e)&&(r&&!this.responseType||n)){const r=!(t&&t.silentJSONParsing)&&n;try{return JSON.parse(e)}catch(e){if(r){if("SyntaxError"===e.name)throw I.from(e,I.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:Z.classes.FormData,Blob:Z.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*"}}};F.forEach(["delete","get","head"],(function(e){te.headers[e]={}})),F.forEach(["post","put","patch"],(function(e){te.headers[e]=F.merge(ee)}));var re=te;const ne=F.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"]),oe=Symbol("internals");function ie(e){return e&&String(e).trim().toLowerCase()}function se(e){return!1===e||null==e?e:F.isArray(e)?e.map(se):String(e)}function ae(e,t,r,n,o){return F.isFunction(n)?n.call(this,t,r):(o&&(t=r),F.isString(t)?F.isString(n)?-1!==t.indexOf(n):F.isRegExp(n)?n.test(t):void 0:void 0)}class ce{constructor(e){e&&this.set(e)}set(e,t,r){const n=this;function o(e,t,r){const o=ie(t);if(!o)throw new Error("header name must be a non-empty string");const i=F.findKey(n,o);(!i||void 0===n[i]||!0===r||void 0===r&&!1!==n[i])&&(n[i||t]=se(e))}const i=(e,t)=>F.forEach(e,((e,r)=>o(e,r,t)));return F.isPlainObject(e)||e instanceof this.constructor?i(e,t):F.isString(e)&&(e=e.trim())&&!/^[-_a-zA-Z]+$/.test(e.trim())?i((e=>{const t={};let r,n,o;return e&&e.split("\n").forEach((function(e){o=e.indexOf(":"),r=e.substring(0,o).trim().toLowerCase(),n=e.substring(o+1).trim(),!r||t[r]&&ne[r]||("set-cookie"===r?t[r]?t[r].push(n):t[r]=[n]:t[r]=t[r]?t[r]+", "+n:n)})),t})(e),t):null!=e&&o(t,e,r),this}get(e,t){if(e=ie(e)){const r=F.findKey(this,e);if(r){const e=this[r];if(!t)return e;if(!0===t)return function(e){const t=Object.create(null),r=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let n;for(;n=r.exec(e);)t[n[1]]=n[2];return t}(e);if(F.isFunction(t))return t.call(this,e,r);if(F.isRegExp(t))return t.exec(e);throw new TypeError("parser must be boolean|regexp|function")}}}has(e,t){if(e=ie(e)){const r=F.findKey(this,e);return!(!r||void 0===this[r]||t&&!ae(0,this[r],r,t))}return!1}delete(e,t){const r=this;let n=!1;function o(e){if(e=ie(e)){const o=F.findKey(r,e);!o||t&&!ae(0,r[o],o,t)||(delete r[o],n=!0)}}return F.isArray(e)?e.forEach(o):o(e),n}clear(e){const t=Object.keys(this);let r=t.length,n=!1;for(;r--;){const o=t[r];e&&!ae(0,this[o],o,e,!0)||(delete this[o],n=!0)}return n}normalize(e){const t=this,r={};return F.forEach(this,((n,o)=>{const i=F.findKey(r,o);if(i)return t[i]=se(n),void delete t[o];const s=e?function(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,((e,t,r)=>t.toUpperCase()+r))}(o):String(o).trim();s!==o&&delete t[o],t[s]=se(n),r[s]=!0})),this}concat(...e){return this.constructor.concat(this,...e)}toJSON(e){const t=Object.create(null);return F.forEach(this,((r,n)=>{null!=r&&!1!==r&&(t[n]=e&&F.isArray(r)?r.join(", "):r)})),t}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map((([e,t])=>e+": "+t)).join("\n")}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(e){return e instanceof this?e:new this(e)}static concat(e,...t){const r=new this(e);return t.forEach((e=>r.set(e))),r}static accessor(e){const t=(this[oe]=this[oe]={accessors:{}}).accessors,r=this.prototype;function n(e){const n=ie(e);t[n]||(function(e,t){const r=F.toCamelCase(" "+t);["get","set","has"].forEach((n=>{Object.defineProperty(e,n+r,{value:function(e,r,o){return this[n].call(this,t,e,r,o)},configurable:!0})}))}(r,e),t[n]=!0)}return F.isArray(e)?e.forEach(n):n(e),this}}ce.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),F.freezeMethods(ce.prototype),F.freezeMethods(ce);var ue=ce;function le(e,t){const r=this||re,n=t||r,o=ue.from(n.headers);let i=n.data;return F.forEach(e,(function(e){i=e.call(r,i,o.normalize(),t?t.status:void 0)})),o.normalize(),i}function fe(e){return!(!e||!e.__CANCEL__)}function pe(e,t,r){I.call(this,null==e?"canceled":e,I.ERR_CANCELED,t,r),this.name="CanceledError"}F.inherits(pe,I,{__CANCEL__:!0});var de=Z.isStandardBrowserEnv?{write:function(e,t,r,n,o,i){const s=[];s.push(e+"="+encodeURIComponent(t)),F.isNumber(r)&&s.push("expires="+new Date(r).toGMTString()),F.isString(n)&&s.push("path="+n),F.isString(o)&&s.push("domain="+o),!0===i&&s.push("secure"),document.cookie=s.join("; ")},read:function(e){const t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove:function(e){this.write(e,"",Date.now()-864e5)}}:{write:function(){},read:function(){return null},remove:function(){}};function he(e,t){return e&&!/^([a-z][a-z\d+\-.]*:)?\/\//i.test(t)?function(e,t){return t?e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,""):e}(e,t):t}var me=Z.isStandardBrowserEnv?function(){const e=/(msie|trident)/i.test(navigator.userAgent),t=document.createElement("a");let r;function n(r){let n=r;return e&&(t.setAttribute("href",n),n=t.href),t.setAttribute("href",n),{href:t.href,protocol:t.protocol?t.protocol.replace(/:$/,""):"",host:t.host,search:t.search?t.search.replace(/^\?/,""):"",hash:t.hash?t.hash.replace(/^#/,""):"",hostname:t.hostname,port:t.port,pathname:"/"===t.pathname.charAt(0)?t.pathname:"/"+t.pathname}}return r=n(window.location.href),function(e){const t=F.isString(e)?n(e):e;return t.protocol===r.protocol&&t.host===r.host}}():function(){return!0};function ye(e,t){let r=0;const n=function(e,t){e=e||10;const r=new Array(e),n=new Array(e);let o,i=0,s=0;return t=void 0!==t?t:1e3,function(a){const c=Date.now(),u=n[s];o||(o=c),r[i]=a,n[i]=c;let l=s,f=0;for(;l!==i;)f+=r[l++],l%=e;if(i=(i+1)%e,i===s&&(s=(s+1)%e),c-o<t)return;const p=u&&c-u;return p?Math.round(1e3*f/p):void 0}}(50,250);return o=>{const i=o.loaded,s=o.lengthComputable?o.total:void 0,a=i-r,c=n(a);r=i;const u={loaded:i,total:s,progress:s?i/s:void 0,bytes:a,rate:c||void 0,estimated:c&&s&&i<=s?(s-i)/c:void 0,event:o};u[t?"download":"upload"]=!0,e(u)}}const ge={http:null,xhr:"undefined"!=typeof XMLHttpRequest&&function(e){return new Promise((function(t,r){let n=e.data;const o=ue.from(e.headers).normalize(),i=e.responseType;let s;function a(){e.cancelToken&&e.cancelToken.unsubscribe(s),e.signal&&e.signal.removeEventListener("abort",s)}F.isFormData(n)&&(Z.isStandardBrowserEnv||Z.isStandardBrowserWebWorkerEnv)&&o.setContentType(!1);let c=new XMLHttpRequest;if(e.auth){const t=e.auth.username||"",r=e.auth.password?unescape(encodeURIComponent(e.auth.password)):"";o.set("Authorization","Basic "+btoa(t+":"+r))}const u=he(e.baseURL,e.url);function l(){if(!c)return;const n=ue.from("getAllResponseHeaders"in c&&c.getAllResponseHeaders());!function(e,t,r){const n=r.config.validateStatus;r.status&&n&&!n(r.status)?t(new I("Request failed with status code "+r.status,[I.ERR_BAD_REQUEST,I.ERR_BAD_RESPONSE][Math.floor(r.status/100)-4],r.config,r.request,r)):e(r)}((function(e){t(e),a()}),(function(e){r(e),a()}),{data:i&&"text"!==i&&"json"!==i?c.response:c.responseText,status:c.status,statusText:c.statusText,headers:n,config:e,request:c}),c=null}if(c.open(e.method.toUpperCase(),Y(u,e.params,e.paramsSerializer),!0),c.timeout=e.timeout,"onloadend"in c?c.onloadend=l:c.onreadystatechange=function(){c&&4===c.readyState&&(0!==c.status||c.responseURL&&0===c.responseURL.indexOf("file:"))&&setTimeout(l)},c.onabort=function(){c&&(r(new I("Request aborted",I.ECONNABORTED,e,c)),c=null)},c.onerror=function(){r(new I("Network Error",I.ERR_NETWORK,e,c)),c=null},c.ontimeout=function(){let t=e.timeout?"timeout of "+e.timeout+"ms exceeded":"timeout exceeded";const n=e.transitional||X;e.timeoutErrorMessage&&(t=e.timeoutErrorMessage),r(new I(t,n.clarifyTimeoutError?I.ETIMEDOUT:I.ECONNABORTED,e,c)),c=null},Z.isStandardBrowserEnv){const t=(e.withCredentials||me(u))&&e.xsrfCookieName&&de.read(e.xsrfCookieName);t&&o.set(e.xsrfHeaderName,t)}void 0===n&&o.setContentType(null),"setRequestHeader"in c&&F.forEach(o.toJSON(),(function(e,t){c.setRequestHeader(t,e)})),F.isUndefined(e.withCredentials)||(c.withCredentials=!!e.withCredentials),i&&"json"!==i&&(c.responseType=e.responseType),"function"==typeof e.onDownloadProgress&&c.addEventListener("progress",ye(e.onDownloadProgress,!0)),"function"==typeof e.onUploadProgress&&c.upload&&c.upload.addEventListener("progress",ye(e.onUploadProgress)),(e.cancelToken||e.signal)&&(s=t=>{c&&(r(!t||t.type?new pe(null,e,c):t),c.abort(),c=null)},e.cancelToken&&e.cancelToken.subscribe(s),e.signal&&(e.signal.aborted?s():e.signal.addEventListener("abort",s)));const f=function(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}(u);f&&-1===Z.protocols.indexOf(f)?r(new I("Unsupported protocol "+f+":",I.ERR_BAD_REQUEST,e)):c.send(n||null)}))}};F.forEach(ge,((e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch(e){}Object.defineProperty(e,"adapterName",{value:t})}}));var Ee={getAdapter:e=>{e=F.isArray(e)?e:[e];const{length:t}=e;let r,n;for(let o=0;o<t&&(r=e[o],!(n=F.isString(r)?ge[r.toLowerCase()]:r));o++);if(!n){if(!1===n)throw new I(`Adapter ${r} is not supported by the environment`,"ERR_NOT_SUPPORT");throw new Error(F.hasOwnProp(ge,r)?`Adapter '${r}' is not available in the build`:`Unknown adapter '${r}'`)}if(!F.isFunction(n))throw new TypeError("adapter is not a function");return n},adapters:ge};function ve(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new pe(null,e)}function be(e){return ve(e),e.headers=ue.from(e.headers),e.data=le.call(e,e.transformRequest),-1!==["post","put","patch"].indexOf(e.method)&&e.headers.setContentType("application/x-www-form-urlencoded",!1),Ee.getAdapter(e.adapter||re.adapter)(e).then((function(t){return ve(e),t.data=le.call(e,e.transformResponse,t),t.headers=ue.from(t.headers),t}),(function(t){return fe(t)||(ve(e),t&&t.response&&(t.response.data=le.call(e,e.transformResponse,t.response),t.response.headers=ue.from(t.response.headers))),Promise.reject(t)}))}const we=e=>e instanceof ue?e.toJSON():e;function Oe(e,t){t=t||{};const r={};function n(e,t,r){return F.isPlainObject(e)&&F.isPlainObject(t)?F.merge.call({caseless:r},e,t):F.isPlainObject(t)?F.merge({},t):F.isArray(t)?t.slice():t}function o(e,t,r){return F.isUndefined(t)?F.isUndefined(e)?void 0:n(void 0,e,r):n(e,t,r)}function i(e,t){if(!F.isUndefined(t))return n(void 0,t)}function s(e,t){return F.isUndefined(t)?F.isUndefined(e)?void 0:n(void 0,e):n(void 0,t)}function a(r,o,i){return i in t?n(r,o):i in e?n(void 0,r):void 0}const c={url:i,method:i,data:i,baseURL:s,transformRequest:s,transformResponse:s,paramsSerializer:s,timeout:s,timeoutMessage:s,withCredentials:s,adapter:s,responseType:s,xsrfCookieName:s,xsrfHeaderName:s,onUploadProgress:s,onDownloadProgress:s,decompress:s,maxContentLength:s,maxBodyLength:s,beforeRedirect:s,transport:s,httpAgent:s,httpsAgent:s,cancelToken:s,socketPath:s,responseEncoding:s,validateStatus:a,headers:(e,t)=>o(we(e),we(t),!0)};return F.forEach(Object.keys(e).concat(Object.keys(t)),(function(n){const i=c[n]||o,s=i(e[n],t[n],n);F.isUndefined(s)&&i!==a||(r[n]=s)})),r}const Re={};["object","boolean","number","function","string","symbol"].forEach(((e,t)=>{Re[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}}));const _e={};Re.transitional=function(e,t,r){function n(e,t){return"[Axios v1.3.4] Transitional option '"+e+"'"+t+(r?". "+r:"")}return(r,o,i)=>{if(!1===e)throw new I(n(o," has been removed"+(t?" in "+t:"")),I.ERR_DEPRECATED);return t&&!_e[o]&&(_e[o]=!0,console.warn(n(o," has been deprecated since v"+t+" and will be removed in the near future"))),!e||e(r,o,i)}};var Se={assertOptions:function(e,t,r){if("object"!=typeof e)throw new I("options must be an object",I.ERR_BAD_OPTION_VALUE);const n=Object.keys(e);let o=n.length;for(;o-- >0;){const i=n[o],s=t[i];if(s){const t=e[i],r=void 0===t||s(t,i,e);if(!0!==r)throw new I("option "+i+" must be "+r,I.ERR_BAD_OPTION_VALUE)}else if(!0!==r)throw new I("Unknown option "+i,I.ERR_BAD_OPTION)}},validators:Re};const Te=Se.validators;class xe{constructor(e){this.defaults=e,this.interceptors={request:new $,response:new $}}request(e,t){"string"==typeof e?(t=t||{}).url=e:t=e||{},t=Oe(this.defaults,t);const{transitional:r,paramsSerializer:n,headers:o}=t;let i;void 0!==r&&Se.assertOptions(r,{silentJSONParsing:Te.transitional(Te.boolean),forcedJSONParsing:Te.transitional(Te.boolean),clarifyTimeoutError:Te.transitional(Te.boolean)},!1),void 0!==n&&Se.assertOptions(n,{encode:Te.function,serialize:Te.function},!0),t.method=(t.method||this.defaults.method||"get").toLowerCase(),i=o&&F.merge(o.common,o[t.method]),i&&F.forEach(["delete","get","head","post","put","patch","common"],(e=>{delete o[e]})),t.headers=ue.concat(i,o);const s=[];let a=!0;this.interceptors.request.forEach((function(e){"function"==typeof e.runWhen&&!1===e.runWhen(t)||(a=a&&e.synchronous,s.unshift(e.fulfilled,e.rejected))}));const c=[];let u;this.interceptors.response.forEach((function(e){c.push(e.fulfilled,e.rejected)}));let l,f=0;if(!a){const e=[be.bind(this),void 0];for(e.unshift.apply(e,s),e.push.apply(e,c),l=e.length,u=Promise.resolve(t);f<l;)u=u.then(e[f++],e[f++]);return u}l=s.length;let p=t;for(f=0;f<l;){const e=s[f++],t=s[f++];try{p=e(p)}catch(e){t.call(this,e);break}}try{u=be.call(this,p)}catch(e){return Promise.reject(e)}for(f=0,l=c.length;f<l;)u=u.then(c[f++],c[f++]);return u}getUri(e){return Y(he((e=Oe(this.defaults,e)).baseURL,e.url),e.params,e.paramsSerializer)}}F.forEach(["delete","get","head","options"],(function(e){xe.prototype[e]=function(t,r){return this.request(Oe(r||{},{method:e,url:t,data:(r||{}).data}))}})),F.forEach(["post","put","patch"],(function(e){function t(t){return function(r,n,o){return this.request(Oe(o||{},{method:e,headers:t?{"Content-Type":"multipart/form-data"}:{},url:r,data:n}))}}xe.prototype[e]=t(),xe.prototype[e+"Form"]=t(!0)}));var Ae=xe;class Ne{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 r=this;this.promise.then((e=>{if(!r._listeners)return;let t=r._listeners.length;for(;t-- >0;)r._listeners[t](e);r._listeners=null})),this.promise.then=e=>{let t;const n=new Promise((e=>{r.subscribe(e),t=e})).then(e);return n.cancel=function(){r.unsubscribe(t)},n},e((function(e,n,o){r.reason||(r.reason=new pe(e,n,o),t(r.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)}static source(){let e;return{token:new Ne((function(t){e=t})),cancel:e}}}var Le=Ne;const Ce={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(Ce).forEach((([e,t])=>{Ce[t]=e}));var Pe=Ce;const je=function e(t){const r=new Ae(t),o=n(Ae.prototype.request,r);return F.extend(o,Ae.prototype,r,{allOwnKeys:!0}),F.extend(o,r,null,{allOwnKeys:!0}),o.create=function(r){return e(Oe(t,r))},o}(re);je.Axios=Ae,je.CanceledError=pe,je.CancelToken=Le,je.isCancel=fe,je.VERSION="1.3.4",je.toFormData=z,je.AxiosError=I,je.Cancel=je.CanceledError,je.all=function(e){return Promise.all(e)},je.spread=function(e){return function(t){return e.apply(null,t)}},je.isAxiosError=function(e){return F.isObject(e)&&!0===e.isAxiosError},je.mergeConfig=Oe,je.AxiosHeaders=ue,je.formToJSON=e=>Q(F.isHTMLForm(e)?new FormData(e):e),je.HttpStatusCode=Pe,je.default=je,e.exports=je}},t={};function r(n){var o=t[n];if(void 0!==o)return o.exports;var i=t[n]={exports:{}};return e[n](i,i.exports,r),i.exports}r.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),r(138)})();
|
|
2
|
+
(()=>{var e={889:(e,t,r)=>{const n=r(164).ZP;e.exports=n,e.exports.default=n},367:e=>{"use strict";const t=new Set(["ENOTFOUND","ENETUNREACH","UNABLE_TO_GET_ISSUER_CERT","UNABLE_TO_GET_CRL","UNABLE_TO_DECRYPT_CERT_SIGNATURE","UNABLE_TO_DECRYPT_CRL_SIGNATURE","UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY","CERT_SIGNATURE_FAILURE","CRL_SIGNATURE_FAILURE","CERT_NOT_YET_VALID","CERT_HAS_EXPIRED","CRL_NOT_YET_VALID","CRL_HAS_EXPIRED","ERROR_IN_CERT_NOT_BEFORE_FIELD","ERROR_IN_CERT_NOT_AFTER_FIELD","ERROR_IN_CRL_LAST_UPDATE_FIELD","ERROR_IN_CRL_NEXT_UPDATE_FIELD","OUT_OF_MEM","DEPTH_ZERO_SELF_SIGNED_CERT","SELF_SIGNED_CERT_IN_CHAIN","UNABLE_TO_GET_ISSUER_CERT_LOCALLY","UNABLE_TO_VERIFY_LEAF_SIGNATURE","CERT_CHAIN_TOO_LONG","CERT_REVOKED","INVALID_CA","PATH_LENGTH_EXCEEDED","INVALID_PURPOSE","CERT_UNTRUSTED","CERT_REJECTED","HOSTNAME_MISMATCH"]);e.exports=e=>!t.has(e&&e.code)},400:(e,t,r)=>{const n=r(218),o=r(889);e.exports={Event:class{constructor(e,t,r,i){this.endpoint=new URL("event",e).href,this.payload={event:r,...i},this.headers=t,Array.isArray(i)&&(this.endpoint=new URL("event/bulk",e).href,this.payload={event:r,batch:i}),o(n,{retries:3,retryDelay:o.exponentialDelay,retryCondition:e=>202!==e.response.status&&401!==e.response.status})}trigger=async()=>new Promise(((e,t)=>{n.post(this.endpoint,this.payload,{headers:this.headers}).then((t=>{e(t.data)})).catch((e=>{t(e.response?.data)}))}))}}},874:(e,t,r)=>{const n=r(218);e.exports=class{constructor(e,t,r,n){this.distinct_id=r,this.endpoint=new URL("profiles/",e).href,this.payload={distinct_id:r,...n},this.headers=t}async updateProfile(){try{const e=new URL(`${this.endpoint}${this.distinct_id}`).href;return this.request(e,this.payload,"PUT")}catch(e){if(400===e.response.status)return this.createProfile(this.distinct_id);throw new Error("Error while creating profile")}}async createProfile(){try{return this.request(this.endpoint,this.payload)}catch(e){throw new Error("Error while creating profile")}}async mergeProfiles(e){try{const t=new URL(`${this.endpoint}${this.distinct_id}/merge/${e}`).href;return this.distinct_id=e,this.request(t)}catch(e){throw new Error("Error while updating profile")}}async addChannelData(e,t){try{const r=new URL(`${this.endpoint}${this.distinct_id}/channel`).href,n={channel:{}};switch(e){case"push":n.channel.push=[{token:t.token,status:1,integration_id:t.integration}];break;case"inapp":n.channel.inapp=[{token:t.token,status:1,integration_id:t.integration}];break;case"sms":n.channel.sms=t.token;break;case"whatsapp":n.channel.whatsapp=t.token;break;case"slack":n.channel.slack=t.token;break;case"teams":n.channel.teams=t.token;break;case"email":n.channel.email=t.token;break;case"discord":n.channel.discord=t.token;break;default:throw new Error(`Invalid channel: '${e}' dose not exist.`)}return this.request(r,n,"PATCH")}catch(e){throw new Error("Unable to add channel")}}async ClearChannelData(e,t){try{const r=new URL(`${this.endpoint}${this.distinct_id}/channel/delete`).href,n={};if(Array.isArray(e))n.channel=[...e];else switch(e){case"push":n.push=[t];break;case"inapp":n.inapp=[t];break;default:n.channel=[e]}return this.request(r,n,"POST")}catch(e){throw new Error("Unable to clear channel")}}request=async(e,t=null,r="POST")=>await n({method:r,url:e,data:t,headers:this.headers})}},138:(e,t,r)=>{const{Event:n}=r(400),o=r(874);e.exports={Fyno:class{wsid=process.env.FYNO_WSID;api_key=process.env.FYNO_API_KEY;version=process.env.FYNO_VERSION||"live";endpoint=process.env.FYNO_ENDPOINT||"https://api.fyno.io/v1/";profile=null;constructor(e=this.wsid,t=this.api_key,r=this.version,n=this.endpoint){this.wsid=e,this.api_key=t,this.version=r,this.endpoint=new URL(`${this.wsid}/${this.version}/`,n).href,this.headers=this.getHeaders(),this.validate()}getHeaders(){return{Authorization:`Bearer ${this.api_key}`,"Content-Type":"application/json"}}validate(){if(!this.wsid||this.wsid.length<10||this.wsid.length>20)throw new Error(`Workspace ID value '${this.wsid}' is invalid`);if(!this.api_key||this.api_key.length<25||this.api_key.length>60)throw new Error(`API Key value '${this.api_key}' is invalid`);if(!["test","live"].includes(`${this.version}`))throw new Error(`Environment value '${this.version}' is invalid. It should be either 'test' or 'live'.`)}async fire(e,t){return new n(this.endpoint,this.headers,e,t).trigger()}async identify(e,t){const r=new o(this.endpoint,this.headers,e,t);return this.profile=r,this}async create(){return await this.profile.createProfile()}async update(e,t){const r=new o(this.endpoint,this.headers,e,t);return this.profile=r,r.updateProfile()}async setEmail(e){return await this.profile.addChannelData("slack",{token:e})}async setSms(e){return await this.profile.addChannelData("slack",{token:e})}async setSlack(e){return await this.profile.addChannelData("slack",{token:e})}async setDiscord(e){return await this.profile.addChannelData("discord",{token:e})}async setTeams(e){return await this.profile.addChannelData("teams",{token:e})}async setWhatsapp(e){return await this.profile.addChannelData("whatsapp",{token:e})}async clearChannel(e,t=null){return await this.profile.ClearChannelData(e,t)}}}},156:e=>{function t(e,t,r,n,o,i,s){try{var a=e[i](s),c=a.value}catch(e){return void r(e)}a.done?t(c):Promise.resolve(c).then(n,o)}e.exports=function(e){return function(){var r=this,n=arguments;return new Promise((function(o,i){var s=e.apply(r,n);function a(e){t(s,o,i,a,c,"next",e)}function c(e){t(s,o,i,a,c,"throw",e)}a(void 0)}))}},e.exports.__esModule=!0,e.exports.default=e.exports},416:(e,t,r)=>{var n=r(62);e.exports=function(e,t,r){return(t=n(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e},e.exports.__esModule=!0,e.exports.default=e.exports},836:e=>{e.exports=function(e){return e&&e.__esModule?e:{default:e}},e.exports.__esModule=!0,e.exports.default=e.exports},61:(e,t,r)=>{var n=r(698).default;function o(){"use strict";e.exports=o=function(){return t},e.exports.__esModule=!0,e.exports.default=e.exports;var t={},r=Object.prototype,i=r.hasOwnProperty,s=Object.defineProperty||function(e,t,r){e[t]=r.value},a="function"==typeof Symbol?Symbol:{},c=a.iterator||"@@iterator",u=a.asyncIterator||"@@asyncIterator",l=a.toStringTag||"@@toStringTag";function f(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{f({},"")}catch(e){f=function(e,t,r){return e[t]=r}}function h(e,t,r,n){var o=t&&t.prototype instanceof y?t:y,i=Object.create(o.prototype),a=new A(n||[]);return s(i,"_invoke",{value:R(e,r,a)}),i}function d(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}t.wrap=h;var p={};function y(){}function m(){}function g(){}var E={};f(E,c,(function(){return this}));var w=Object.getPrototypeOf,b=w&&w(w(N([])));b&&b!==r&&i.call(b,c)&&(E=b);var v=g.prototype=y.prototype=Object.create(E);function O(e){["next","throw","return"].forEach((function(t){f(e,t,(function(e){return this._invoke(t,e)}))}))}function _(e,t){function r(o,s,a,c){var u=d(e[o],e,s);if("throw"!==u.type){var l=u.arg,f=l.value;return f&&"object"==n(f)&&i.call(f,"__await")?t.resolve(f.__await).then((function(e){r("next",e,a,c)}),(function(e){r("throw",e,a,c)})):t.resolve(f).then((function(e){l.value=e,a(l)}),(function(e){return r("throw",e,a,c)}))}c(u.arg)}var o;s(this,"_invoke",{value:function(e,n){function i(){return new t((function(t,o){r(e,n,t,o)}))}return o=o?o.then(i,i):i()}})}function R(e,t,r){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return{value:void 0,done:!0}}for(r.method=o,r.arg=i;;){var s=r.delegate;if(s){var a=T(s,r);if(a){if(a===p)continue;return a}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var c=d(e,t,r);if("normal"===c.type){if(n=r.done?"completed":"suspendedYield",c.arg===p)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(n="completed",r.method="throw",r.arg=c.arg)}}}function T(e,t){var r=t.method,n=e.iterator[r];if(void 0===n)return t.delegate=null,"throw"===r&&e.iterator.return&&(t.method="return",t.arg=void 0,T(e,t),"throw"===t.method)||"return"!==r&&(t.method="throw",t.arg=new TypeError("The iterator does not provide a '"+r+"' method")),p;var o=d(n,e.iterator,t.arg);if("throw"===o.type)return t.method="throw",t.arg=o.arg,t.delegate=null,p;var i=o.arg;return i?i.done?(t[e.resultName]=i.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,p):i:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,p)}function S(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function x(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function A(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(S,this),this.reset(!0)}function N(e){if(e){var t=e[c];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var r=-1,n=function t(){for(;++r<e.length;)if(i.call(e,r))return t.value=e[r],t.done=!1,t;return t.value=void 0,t.done=!0,t};return n.next=n}}return{next:C}}function C(){return{value:void 0,done:!0}}return m.prototype=g,s(v,"constructor",{value:g,configurable:!0}),s(g,"constructor",{value:m,configurable:!0}),m.displayName=f(g,l,"GeneratorFunction"),t.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===m||"GeneratorFunction"===(t.displayName||t.name))},t.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,g):(e.__proto__=g,f(e,l,"GeneratorFunction")),e.prototype=Object.create(v),e},t.awrap=function(e){return{__await:e}},O(_.prototype),f(_.prototype,u,(function(){return this})),t.AsyncIterator=_,t.async=function(e,r,n,o,i){void 0===i&&(i=Promise);var s=new _(h(e,r,n,o),i);return t.isGeneratorFunction(r)?s:s.next().then((function(e){return e.done?e.value:s.next()}))},O(v),f(v,l,"Generator"),f(v,c,(function(){return this})),f(v,"toString",(function(){return"[object Generator]"})),t.keys=function(e){var t=Object(e),r=[];for(var n in t)r.push(n);return r.reverse(),function e(){for(;r.length;){var n=r.pop();if(n in t)return e.value=n,e.done=!1,e}return e.done=!0,e}},t.values=N,A.prototype={constructor:A,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(x),!e)for(var t in this)"t"===t.charAt(0)&&i.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function r(r,n){return s.type="throw",s.arg=e,t.next=r,n&&(t.method="next",t.arg=void 0),!!n}for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n],s=o.completion;if("root"===o.tryLoc)return r("end");if(o.tryLoc<=this.prev){var a=i.call(o,"catchLoc"),c=i.call(o,"finallyLoc");if(a&&c){if(this.prev<o.catchLoc)return r(o.catchLoc,!0);if(this.prev<o.finallyLoc)return r(o.finallyLoc)}else if(a){if(this.prev<o.catchLoc)return r(o.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return r(o.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var n=this.tryEntries[r];if(n.tryLoc<=this.prev&&i.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var o=n;break}}o&&("break"===e||"continue"===e)&&o.tryLoc<=t&&t<=o.finallyLoc&&(o=null);var s=o?o.completion:{};return s.type=e,s.arg=t,o?(this.method="next",this.next=o.finallyLoc,p):this.complete(s)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),p},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),x(r),p}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var o=n.arg;x(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:N(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=void 0),p}},t}e.exports=o,e.exports.__esModule=!0,e.exports.default=e.exports},36:(e,t,r)=>{var n=r(698).default;e.exports=function(e,t){if("object"!==n(e)||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var o=r.call(e,t||"default");if("object"!==n(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)},e.exports.__esModule=!0,e.exports.default=e.exports},62:(e,t,r)=>{var n=r(698).default,o=r(36);e.exports=function(e){var t=o(e,"string");return"symbol"===n(t)?t:String(t)},e.exports.__esModule=!0,e.exports.default=e.exports},698:e=>{function t(r){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(r)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports},687:(e,t,r)=>{var n=r(61)();e.exports=n;try{regeneratorRuntime=n}catch(e){"object"==typeof globalThis?globalThis.regeneratorRuntime=n:Function("r","regeneratorRuntime = r")(n)}},164:(e,t,r)=>{"use strict";var n=r(836);t.ZP=R;var o=n(r(687)),i=n(r(698)),s=n(r(156)),a=n(r(416)),c=n(r(367));function u(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function l(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?u(Object(r),!0).forEach((function(t){(0,a.default)(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):u(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}var f="axios-retry";function h(e){return!e.response&&Boolean(e.code)&&"ECONNABORTED"!==e.code&&(0,c.default)(e)}var d=["get","head","options"],p=d.concat(["put","delete"]);function y(e){return"ECONNABORTED"!==e.code&&(!e.response||e.response.status>=500&&e.response.status<=599)}function m(e){return!!e.config&&y(e)&&-1!==p.indexOf(e.config.method)}function g(e){return h(e)||m(e)}function E(){return 0}function w(e){var t=e[f]||{};return t.retryCount=t.retryCount||0,e[f]=t,t}function b(e,t){return l(l({},t),e[f])}function v(e,t){e.defaults.agent===t.agent&&delete t.agent,e.defaults.httpAgent===t.httpAgent&&delete t.httpAgent,e.defaults.httpsAgent===t.httpsAgent&&delete t.httpsAgent}function O(e,t,r,n){return _.apply(this,arguments)}function _(){return(_=(0,s.default)(o.default.mark((function e(t,r,n,s){var a,c;return o.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(a=n.retryCount<t&&r(s),"object"!==(0,i.default)(a)){e.next=12;break}return e.prev=2,e.next=5,a;case 5:return c=e.sent,e.abrupt("return",!1!==c);case 9:return e.prev=9,e.t0=e.catch(2),e.abrupt("return",!1);case 12:return e.abrupt("return",a);case 13:case"end":return e.stop()}}),e,null,[[2,9]])})))).apply(this,arguments)}function R(e,t){e.interceptors.request.use((function(e){return w(e).lastRequestTime=Date.now(),e})),e.interceptors.response.use(null,function(){var r=(0,s.default)(o.default.mark((function r(n){var i,s,a,c,u,l,f,h,d,p,y,m,_,R,T,S;return o.default.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(i=n.config){r.next=3;break}return r.abrupt("return",Promise.reject(n));case 3:return s=b(i,t),a=s.retries,c=void 0===a?3:a,u=s.retryCondition,l=void 0===u?g:u,f=s.retryDelay,h=void 0===f?E:f,d=s.shouldResetTimeout,p=void 0!==d&&d,y=s.onRetry,m=void 0===y?function(){}:y,_=w(i),r.next=7,O(c,l,_,n);case 7:if(!r.sent){r.next=20;break}if(_.retryCount+=1,R=h(_.retryCount,n),v(e,i),p||!i.timeout||!_.lastRequestTime){r.next=17;break}if(T=Date.now()-_.lastRequestTime,!((S=i.timeout-T-R)<=0)){r.next=16;break}return r.abrupt("return",Promise.reject(n));case 16:i.timeout=S;case 17:return i.transformRequest=[function(e){return e}],m(_.retryCount,n,i),r.abrupt("return",new Promise((function(t){return setTimeout((function(){return t(e(i))}),R)})));case 20:return r.abrupt("return",Promise.reject(n));case 21:case"end":return r.stop()}}),r)})));return function(e){return r.apply(this,arguments)}}())}R.isNetworkError=h,R.isSafeRequestError=function(e){return!!e.config&&y(e)&&-1!==d.indexOf(e.config.method)},R.isIdempotentRequestError=m,R.isNetworkOrIdempotentRequestError=g,R.exponentialDelay=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:100,r=Math.pow(2,e)*t;return r+.2*r*Math.random()},R.isRetryableError=y},218:(e,t,r)=>{"use strict";function n(e,t){return function(){return e.apply(t,arguments)}}const{toString:o}=Object.prototype,{getPrototypeOf:i}=Object,s=(a=Object.create(null),e=>{const t=o.call(e);return a[t]||(a[t]=t.slice(8,-1).toLowerCase())});var a;const c=e=>(e=e.toLowerCase(),t=>s(t)===e),u=e=>t=>typeof t===e,{isArray:l}=Array,f=u("undefined"),h=c("ArrayBuffer"),d=u("string"),p=u("function"),y=u("number"),m=e=>null!==e&&"object"==typeof e,g=e=>{if("object"!==s(e))return!1;const t=i(e);return!(null!==t&&t!==Object.prototype&&null!==Object.getPrototypeOf(t)||Symbol.toStringTag in e||Symbol.iterator in e)},E=c("Date"),w=c("File"),b=c("Blob"),v=c("FileList"),O=c("URLSearchParams");function _(e,t,{allOwnKeys:r=!1}={}){if(null==e)return;let n,o;if("object"!=typeof e&&(e=[e]),l(e))for(n=0,o=e.length;n<o;n++)t.call(null,e[n],n,e);else{const o=r?Object.getOwnPropertyNames(e):Object.keys(e),i=o.length;let s;for(n=0;n<i;n++)s=o[n],t.call(null,e[s],s,e)}}function R(e,t){t=t.toLowerCase();const r=Object.keys(e);let n,o=r.length;for(;o-- >0;)if(n=r[o],t===n.toLowerCase())return n;return null}const T="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:r.g,S=e=>!f(e)&&e!==T,x=(A="undefined"!=typeof Uint8Array&&i(Uint8Array),e=>A&&e instanceof A);var A;const N=c("HTMLFormElement"),C=(({hasOwnProperty:e})=>(t,r)=>e.call(t,r))(Object.prototype),L=c("RegExp"),P=(e,t)=>{const r=Object.getOwnPropertyDescriptors(e),n={};_(r,((r,o)=>{!1!==t(r,o,e)&&(n[o]=r)})),Object.defineProperties(e,n)},j="abcdefghijklmnopqrstuvwxyz",D="0123456789",k={DIGIT:D,ALPHA:j,ALPHA_DIGIT:j+j.toUpperCase()+D},U=c("AsyncFunction");var F={isArray:l,isArrayBuffer:h,isBuffer:function(e){return null!==e&&!f(e)&&null!==e.constructor&&!f(e.constructor)&&p(e.constructor.isBuffer)&&e.constructor.isBuffer(e)},isFormData:e=>{let t;return e&&("function"==typeof FormData&&e instanceof FormData||p(e.append)&&("formdata"===(t=s(e))||"object"===t&&p(e.toString)&&"[object FormData]"===e.toString()))},isArrayBufferView:function(e){let t;return t="undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&h(e.buffer),t},isString:d,isNumber:y,isBoolean:e=>!0===e||!1===e,isObject:m,isPlainObject:g,isUndefined:f,isDate:E,isFile:w,isBlob:b,isRegExp:L,isFunction:p,isStream:e=>m(e)&&p(e.pipe),isURLSearchParams:O,isTypedArray:x,isFileList:v,forEach:_,merge:function e(){const{caseless:t}=S(this)&&this||{},r={},n=(n,o)=>{const i=t&&R(r,o)||o;g(r[i])&&g(n)?r[i]=e(r[i],n):g(n)?r[i]=e({},n):l(n)?r[i]=n.slice():r[i]=n};for(let e=0,t=arguments.length;e<t;e++)arguments[e]&&_(arguments[e],n);return r},extend:(e,t,r,{allOwnKeys:o}={})=>(_(t,((t,o)=>{r&&p(t)?e[o]=n(t,r):e[o]=t}),{allOwnKeys:o}),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,r,n)=>{e.prototype=Object.create(t.prototype,n),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),r&&Object.assign(e.prototype,r)},toFlatObject:(e,t,r,n)=>{let o,s,a;const c={};if(t=t||{},null==e)return t;do{for(o=Object.getOwnPropertyNames(e),s=o.length;s-- >0;)a=o[s],n&&!n(a,e,t)||c[a]||(t[a]=e[a],c[a]=!0);e=!1!==r&&i(e)}while(e&&(!r||r(e,t))&&e!==Object.prototype);return t},kindOf:s,kindOfTest:c,endsWith:(e,t,r)=>{e=String(e),(void 0===r||r>e.length)&&(r=e.length),r-=t.length;const n=e.indexOf(t,r);return-1!==n&&n===r},toArray:e=>{if(!e)return null;if(l(e))return e;let t=e.length;if(!y(t))return null;const r=new Array(t);for(;t-- >0;)r[t]=e[t];return r},forEachEntry:(e,t)=>{const r=(e&&e[Symbol.iterator]).call(e);let n;for(;(n=r.next())&&!n.done;){const r=n.value;t.call(e,r[0],r[1])}},matchAll:(e,t)=>{let r;const n=[];for(;null!==(r=e.exec(t));)n.push(r);return n},isHTMLForm:N,hasOwnProperty:C,hasOwnProp:C,reduceDescriptors:P,freezeMethods:e=>{P(e,((t,r)=>{if(p(e)&&-1!==["arguments","caller","callee"].indexOf(r))return!1;const n=e[r];p(n)&&(t.enumerable=!1,"writable"in t?t.writable=!1:t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+r+"'")}))}))},toObjectSet:(e,t)=>{const r={},n=e=>{e.forEach((e=>{r[e]=!0}))};return l(e)?n(e):n(String(e).split(t)),r},toCamelCase:e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,(function(e,t,r){return t.toUpperCase()+r})),noop:()=>{},toFiniteNumber:(e,t)=>(e=+e,Number.isFinite(e)?e:t),findKey:R,global:T,isContextDefined:S,ALPHABET:k,generateString:(e=16,t=k.ALPHA_DIGIT)=>{let r="";const{length:n}=t;for(;e--;)r+=t[Math.random()*n|0];return r},isSpecCompliantForm:function(e){return!!(e&&p(e.append)&&"FormData"===e[Symbol.toStringTag]&&e[Symbol.iterator])},toJSONObject:e=>{const t=new Array(10),r=(e,n)=>{if(m(e)){if(t.indexOf(e)>=0)return;if(!("toJSON"in e)){t[n]=e;const o=l(e)?[]:{};return _(e,((e,t)=>{const i=r(e,n+1);!f(i)&&(o[t]=i)})),t[n]=void 0,o}}return e};return r(e,0)},isAsyncFn:U,isThenable:e=>e&&(m(e)||p(e))&&p(e.then)&&p(e.catch)};function I(e,t,r,n,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),r&&(this.config=r),n&&(this.request=n),o&&(this.response=o)}F.inherits(I,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:F.toJSONObject(this.config),code:this.code,status:this.response&&this.response.status?this.response.status:null}}});const B=I.prototype,q={};function M(e){return F.isPlainObject(e)||F.isArray(e)}function H(e){return F.endsWith(e,"[]")?e.slice(0,-2):e}function z(e,t,r){return e?e.concat(t).map((function(e,t){return e=H(e),!r&&t?"["+e+"]":e})).join(r?".":""):t}["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=>{q[e]={value:e}})),Object.defineProperties(I,q),Object.defineProperty(B,"isAxiosError",{value:!0}),I.from=(e,t,r,n,o,i)=>{const s=Object.create(B);return F.toFlatObject(e,s,(function(e){return e!==Error.prototype}),(e=>"isAxiosError"!==e)),I.call(s,e.message,t,r,n,o),s.cause=e,s.name=e.name,i&&Object.assign(s,i),s};const G=F.toFlatObject(F,{},null,(function(e){return/^is[A-Z]/.test(e)}));function $(e,t,r){if(!F.isObject(e))throw new TypeError("target must be an object");t=t||new FormData;const n=(r=F.toFlatObject(r,{metaTokens:!0,dots:!1,indexes:!1},!1,(function(e,t){return!F.isUndefined(t[e])}))).metaTokens,o=r.visitor||u,i=r.dots,s=r.indexes,a=(r.Blob||"undefined"!=typeof Blob&&Blob)&&F.isSpecCompliantForm(t);if(!F.isFunction(o))throw new TypeError("visitor must be a function");function c(e){if(null===e)return"";if(F.isDate(e))return e.toISOString();if(!a&&F.isBlob(e))throw new I("Blob is not supported. Use a Buffer instead.");return F.isArrayBuffer(e)||F.isTypedArray(e)?a&&"function"==typeof Blob?new Blob([e]):Buffer.from(e):e}function u(e,r,o){let a=e;if(e&&!o&&"object"==typeof e)if(F.endsWith(r,"{}"))r=n?r:r.slice(0,-2),e=JSON.stringify(e);else if(F.isArray(e)&&function(e){return F.isArray(e)&&!e.some(M)}(e)||(F.isFileList(e)||F.endsWith(r,"[]"))&&(a=F.toArray(e)))return r=H(r),a.forEach((function(e,n){!F.isUndefined(e)&&null!==e&&t.append(!0===s?z([r],n,i):null===s?r:r+"[]",c(e))})),!1;return!!M(e)||(t.append(z(o,r,i),c(e)),!1)}const l=[],f=Object.assign(G,{defaultVisitor:u,convertValue:c,isVisitable:M});if(!F.isObject(e))throw new TypeError("data must be an object");return function e(r,n){if(!F.isUndefined(r)){if(-1!==l.indexOf(r))throw Error("Circular reference detected in "+n.join("."));l.push(r),F.forEach(r,(function(r,i){!0===(!(F.isUndefined(r)||null===r)&&o.call(t,r,F.isString(i)?i.trim():i,n,f))&&e(r,n?n.concat(i):[i])})),l.pop()}}(e),t}function J(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,(function(e){return t[e]}))}function V(e,t){this._pairs=[],e&&$(e,this,t)}const K=V.prototype;function W(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function Y(e,t,r){if(!t)return e;const n=r&&r.encode||W,o=r&&r.serialize;let i;if(i=o?o(t,r):F.isURLSearchParams(t)?t.toString():new V(t,r).toString(n),i){const t=e.indexOf("#");-1!==t&&(e=e.slice(0,t)),e+=(-1===e.indexOf("?")?"?":"&")+i}return e}K.append=function(e,t){this._pairs.push([e,t])},K.toString=function(e){const t=e?function(t){return e.call(this,t,J)}:J;return this._pairs.map((function(e){return t(e[0])+"="+t(e[1])}),"").join("&")};var X=class{constructor(){this.handlers=[]}use(e,t,r){return this.handlers.push({fulfilled:e,rejected:t,synchronous:!!r&&r.synchronous,runWhen:r?r.runWhen:null}),this.handlers.length-1}eject(e){this.handlers[e]&&(this.handlers[e]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(e){F.forEach(this.handlers,(function(t){null!==t&&e(t)}))}},Z={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},Q={isBrowser:!0,classes:{URLSearchParams:"undefined"!=typeof URLSearchParams?URLSearchParams:V,FormData:"undefined"!=typeof FormData?FormData:null,Blob:"undefined"!=typeof Blob?Blob:null},isStandardBrowserEnv:(()=>{let e;return("undefined"==typeof navigator||"ReactNative"!==(e=navigator.product)&&"NativeScript"!==e&&"NS"!==e)&&"undefined"!=typeof window&&"undefined"!=typeof document})(),isStandardBrowserWebWorkerEnv:"undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope&&"function"==typeof self.importScripts,protocols:["http","https","file","blob","url","data"]};function ee(e){function t(e,r,n,o){let i=e[o++];const s=Number.isFinite(+i),a=o>=e.length;return i=!i&&F.isArray(n)?n.length:i,a?(F.hasOwnProp(n,i)?n[i]=[n[i],r]:n[i]=r,!s):(n[i]&&F.isObject(n[i])||(n[i]=[]),t(e,r,n[i],o)&&F.isArray(n[i])&&(n[i]=function(e){const t={},r=Object.keys(e);let n;const o=r.length;let i;for(n=0;n<o;n++)i=r[n],t[i]=e[i];return t}(n[i])),!s)}if(F.isFormData(e)&&F.isFunction(e.entries)){const r={};return F.forEachEntry(e,((e,n)=>{t(function(e){return F.matchAll(/\w+|\[(\w*)]/g,e).map((e=>"[]"===e[0]?"":e[1]||e[0]))}(e),n,r,0)})),r}return null}const te={"Content-Type":void 0},re={transitional:Z,adapter:["xhr","http"],transformRequest:[function(e,t){const r=t.getContentType()||"",n=r.indexOf("application/json")>-1,o=F.isObject(e);if(o&&F.isHTMLForm(e)&&(e=new FormData(e)),F.isFormData(e))return n&&n?JSON.stringify(ee(e)):e;if(F.isArrayBuffer(e)||F.isBuffer(e)||F.isStream(e)||F.isFile(e)||F.isBlob(e))return e;if(F.isArrayBufferView(e))return e.buffer;if(F.isURLSearchParams(e))return t.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),e.toString();let i;if(o){if(r.indexOf("application/x-www-form-urlencoded")>-1)return function(e,t){return $(e,new Q.classes.URLSearchParams,Object.assign({visitor:function(e,t,r,n){return Q.isNode&&F.isBuffer(e)?(this.append(t,e.toString("base64")),!1):n.defaultVisitor.apply(this,arguments)}},t))}(e,this.formSerializer).toString();if((i=F.isFileList(e))||r.indexOf("multipart/form-data")>-1){const t=this.env&&this.env.FormData;return $(i?{"files[]":e}:e,t&&new t,this.formSerializer)}}return o||n?(t.setContentType("application/json",!1),function(e,t,r){if(F.isString(e))try{return(0,JSON.parse)(e),F.trim(e)}catch(e){if("SyntaxError"!==e.name)throw e}return(0,JSON.stringify)(e)}(e)):e}],transformResponse:[function(e){const t=this.transitional||re.transitional,r=t&&t.forcedJSONParsing,n="json"===this.responseType;if(e&&F.isString(e)&&(r&&!this.responseType||n)){const r=!(t&&t.silentJSONParsing)&&n;try{return JSON.parse(e)}catch(e){if(r){if("SyntaxError"===e.name)throw I.from(e,I.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:Q.classes.FormData,Blob:Q.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*"}}};F.forEach(["delete","get","head"],(function(e){re.headers[e]={}})),F.forEach(["post","put","patch"],(function(e){re.headers[e]=F.merge(te)}));var ne=re;const oe=F.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"]),ie=Symbol("internals");function se(e){return e&&String(e).trim().toLowerCase()}function ae(e){return!1===e||null==e?e:F.isArray(e)?e.map(ae):String(e)}function ce(e,t,r,n,o){return F.isFunction(n)?n.call(this,t,r):(o&&(t=r),F.isString(t)?F.isString(n)?-1!==t.indexOf(n):F.isRegExp(n)?n.test(t):void 0:void 0)}class ue{constructor(e){e&&this.set(e)}set(e,t,r){const n=this;function o(e,t,r){const o=se(t);if(!o)throw new Error("header name must be a non-empty string");const i=F.findKey(n,o);(!i||void 0===n[i]||!0===r||void 0===r&&!1!==n[i])&&(n[i||t]=ae(e))}const i=(e,t)=>F.forEach(e,((e,r)=>o(e,r,t)));return F.isPlainObject(e)||e instanceof this.constructor?i(e,t):F.isString(e)&&(e=e.trim())&&!/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim())?i((e=>{const t={};let r,n,o;return e&&e.split("\n").forEach((function(e){o=e.indexOf(":"),r=e.substring(0,o).trim().toLowerCase(),n=e.substring(o+1).trim(),!r||t[r]&&oe[r]||("set-cookie"===r?t[r]?t[r].push(n):t[r]=[n]:t[r]=t[r]?t[r]+", "+n:n)})),t})(e),t):null!=e&&o(t,e,r),this}get(e,t){if(e=se(e)){const r=F.findKey(this,e);if(r){const e=this[r];if(!t)return e;if(!0===t)return function(e){const t=Object.create(null),r=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let n;for(;n=r.exec(e);)t[n[1]]=n[2];return t}(e);if(F.isFunction(t))return t.call(this,e,r);if(F.isRegExp(t))return t.exec(e);throw new TypeError("parser must be boolean|regexp|function")}}}has(e,t){if(e=se(e)){const r=F.findKey(this,e);return!(!r||void 0===this[r]||t&&!ce(0,this[r],r,t))}return!1}delete(e,t){const r=this;let n=!1;function o(e){if(e=se(e)){const o=F.findKey(r,e);!o||t&&!ce(0,r[o],o,t)||(delete r[o],n=!0)}}return F.isArray(e)?e.forEach(o):o(e),n}clear(e){const t=Object.keys(this);let r=t.length,n=!1;for(;r--;){const o=t[r];e&&!ce(0,this[o],o,e,!0)||(delete this[o],n=!0)}return n}normalize(e){const t=this,r={};return F.forEach(this,((n,o)=>{const i=F.findKey(r,o);if(i)return t[i]=ae(n),void delete t[o];const s=e?function(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,((e,t,r)=>t.toUpperCase()+r))}(o):String(o).trim();s!==o&&delete t[o],t[s]=ae(n),r[s]=!0})),this}concat(...e){return this.constructor.concat(this,...e)}toJSON(e){const t=Object.create(null);return F.forEach(this,((r,n)=>{null!=r&&!1!==r&&(t[n]=e&&F.isArray(r)?r.join(", "):r)})),t}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map((([e,t])=>e+": "+t)).join("\n")}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(e){return e instanceof this?e:new this(e)}static concat(e,...t){const r=new this(e);return t.forEach((e=>r.set(e))),r}static accessor(e){const t=(this[ie]=this[ie]={accessors:{}}).accessors,r=this.prototype;function n(e){const n=se(e);t[n]||(function(e,t){const r=F.toCamelCase(" "+t);["get","set","has"].forEach((n=>{Object.defineProperty(e,n+r,{value:function(e,r,o){return this[n].call(this,t,e,r,o)},configurable:!0})}))}(r,e),t[n]=!0)}return F.isArray(e)?e.forEach(n):n(e),this}}ue.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),F.freezeMethods(ue.prototype),F.freezeMethods(ue);var le=ue;function fe(e,t){const r=this||ne,n=t||r,o=le.from(n.headers);let i=n.data;return F.forEach(e,(function(e){i=e.call(r,i,o.normalize(),t?t.status:void 0)})),o.normalize(),i}function he(e){return!(!e||!e.__CANCEL__)}function de(e,t,r){I.call(this,null==e?"canceled":e,I.ERR_CANCELED,t,r),this.name="CanceledError"}F.inherits(de,I,{__CANCEL__:!0});var pe=Q.isStandardBrowserEnv?{write:function(e,t,r,n,o,i){const s=[];s.push(e+"="+encodeURIComponent(t)),F.isNumber(r)&&s.push("expires="+new Date(r).toGMTString()),F.isString(n)&&s.push("path="+n),F.isString(o)&&s.push("domain="+o),!0===i&&s.push("secure"),document.cookie=s.join("; ")},read:function(e){const t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove:function(e){this.write(e,"",Date.now()-864e5)}}:{write:function(){},read:function(){return null},remove:function(){}};function ye(e,t){return e&&!/^([a-z][a-z\d+\-.]*:)?\/\//i.test(t)?function(e,t){return t?e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,""):e}(e,t):t}var me=Q.isStandardBrowserEnv?function(){const e=/(msie|trident)/i.test(navigator.userAgent),t=document.createElement("a");let r;function n(r){let n=r;return e&&(t.setAttribute("href",n),n=t.href),t.setAttribute("href",n),{href:t.href,protocol:t.protocol?t.protocol.replace(/:$/,""):"",host:t.host,search:t.search?t.search.replace(/^\?/,""):"",hash:t.hash?t.hash.replace(/^#/,""):"",hostname:t.hostname,port:t.port,pathname:"/"===t.pathname.charAt(0)?t.pathname:"/"+t.pathname}}return r=n(window.location.href),function(e){const t=F.isString(e)?n(e):e;return t.protocol===r.protocol&&t.host===r.host}}():function(){return!0};function ge(e,t){let r=0;const n=function(e,t){e=e||10;const r=new Array(e),n=new Array(e);let o,i=0,s=0;return t=void 0!==t?t:1e3,function(a){const c=Date.now(),u=n[s];o||(o=c),r[i]=a,n[i]=c;let l=s,f=0;for(;l!==i;)f+=r[l++],l%=e;if(i=(i+1)%e,i===s&&(s=(s+1)%e),c-o<t)return;const h=u&&c-u;return h?Math.round(1e3*f/h):void 0}}(50,250);return o=>{const i=o.loaded,s=o.lengthComputable?o.total:void 0,a=i-r,c=n(a);r=i;const u={loaded:i,total:s,progress:s?i/s:void 0,bytes:a,rate:c||void 0,estimated:c&&s&&i<=s?(s-i)/c:void 0,event:o};u[t?"download":"upload"]=!0,e(u)}}const Ee={http:null,xhr:"undefined"!=typeof XMLHttpRequest&&function(e){return new Promise((function(t,r){let n=e.data;const o=le.from(e.headers).normalize(),i=e.responseType;let s;function a(){e.cancelToken&&e.cancelToken.unsubscribe(s),e.signal&&e.signal.removeEventListener("abort",s)}F.isFormData(n)&&(Q.isStandardBrowserEnv||Q.isStandardBrowserWebWorkerEnv?o.setContentType(!1):o.setContentType("multipart/form-data;",!1));let c=new XMLHttpRequest;if(e.auth){const t=e.auth.username||"",r=e.auth.password?unescape(encodeURIComponent(e.auth.password)):"";o.set("Authorization","Basic "+btoa(t+":"+r))}const u=ye(e.baseURL,e.url);function l(){if(!c)return;const n=le.from("getAllResponseHeaders"in c&&c.getAllResponseHeaders());!function(e,t,r){const n=r.config.validateStatus;r.status&&n&&!n(r.status)?t(new I("Request failed with status code "+r.status,[I.ERR_BAD_REQUEST,I.ERR_BAD_RESPONSE][Math.floor(r.status/100)-4],r.config,r.request,r)):e(r)}((function(e){t(e),a()}),(function(e){r(e),a()}),{data:i&&"text"!==i&&"json"!==i?c.response:c.responseText,status:c.status,statusText:c.statusText,headers:n,config:e,request:c}),c=null}if(c.open(e.method.toUpperCase(),Y(u,e.params,e.paramsSerializer),!0),c.timeout=e.timeout,"onloadend"in c?c.onloadend=l:c.onreadystatechange=function(){c&&4===c.readyState&&(0!==c.status||c.responseURL&&0===c.responseURL.indexOf("file:"))&&setTimeout(l)},c.onabort=function(){c&&(r(new I("Request aborted",I.ECONNABORTED,e,c)),c=null)},c.onerror=function(){r(new I("Network Error",I.ERR_NETWORK,e,c)),c=null},c.ontimeout=function(){let t=e.timeout?"timeout of "+e.timeout+"ms exceeded":"timeout exceeded";const n=e.transitional||Z;e.timeoutErrorMessage&&(t=e.timeoutErrorMessage),r(new I(t,n.clarifyTimeoutError?I.ETIMEDOUT:I.ECONNABORTED,e,c)),c=null},Q.isStandardBrowserEnv){const t=(e.withCredentials||me(u))&&e.xsrfCookieName&&pe.read(e.xsrfCookieName);t&&o.set(e.xsrfHeaderName,t)}void 0===n&&o.setContentType(null),"setRequestHeader"in c&&F.forEach(o.toJSON(),(function(e,t){c.setRequestHeader(t,e)})),F.isUndefined(e.withCredentials)||(c.withCredentials=!!e.withCredentials),i&&"json"!==i&&(c.responseType=e.responseType),"function"==typeof e.onDownloadProgress&&c.addEventListener("progress",ge(e.onDownloadProgress,!0)),"function"==typeof e.onUploadProgress&&c.upload&&c.upload.addEventListener("progress",ge(e.onUploadProgress)),(e.cancelToken||e.signal)&&(s=t=>{c&&(r(!t||t.type?new de(null,e,c):t),c.abort(),c=null)},e.cancelToken&&e.cancelToken.subscribe(s),e.signal&&(e.signal.aborted?s():e.signal.addEventListener("abort",s)));const f=function(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}(u);f&&-1===Q.protocols.indexOf(f)?r(new I("Unsupported protocol "+f+":",I.ERR_BAD_REQUEST,e)):c.send(n||null)}))}};F.forEach(Ee,((e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch(e){}Object.defineProperty(e,"adapterName",{value:t})}}));function we(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new de(null,e)}function be(e){return we(e),e.headers=le.from(e.headers),e.data=fe.call(e,e.transformRequest),-1!==["post","put","patch"].indexOf(e.method)&&e.headers.setContentType("application/x-www-form-urlencoded",!1),(e=>{e=F.isArray(e)?e:[e];const{length:t}=e;let r,n;for(let o=0;o<t&&(r=e[o],!(n=F.isString(r)?Ee[r.toLowerCase()]:r));o++);if(!n){if(!1===n)throw new I(`Adapter ${r} is not supported by the environment`,"ERR_NOT_SUPPORT");throw new Error(F.hasOwnProp(Ee,r)?`Adapter '${r}' is not available in the build`:`Unknown adapter '${r}'`)}if(!F.isFunction(n))throw new TypeError("adapter is not a function");return n})(e.adapter||ne.adapter)(e).then((function(t){return we(e),t.data=fe.call(e,e.transformResponse,t),t.headers=le.from(t.headers),t}),(function(t){return he(t)||(we(e),t&&t.response&&(t.response.data=fe.call(e,e.transformResponse,t.response),t.response.headers=le.from(t.response.headers))),Promise.reject(t)}))}const ve=e=>e instanceof le?e.toJSON():e;function Oe(e,t){t=t||{};const r={};function n(e,t,r){return F.isPlainObject(e)&&F.isPlainObject(t)?F.merge.call({caseless:r},e,t):F.isPlainObject(t)?F.merge({},t):F.isArray(t)?t.slice():t}function o(e,t,r){return F.isUndefined(t)?F.isUndefined(e)?void 0:n(void 0,e,r):n(e,t,r)}function i(e,t){if(!F.isUndefined(t))return n(void 0,t)}function s(e,t){return F.isUndefined(t)?F.isUndefined(e)?void 0:n(void 0,e):n(void 0,t)}function a(r,o,i){return i in t?n(r,o):i in e?n(void 0,r):void 0}const c={url:i,method:i,data:i,baseURL:s,transformRequest:s,transformResponse:s,paramsSerializer:s,timeout:s,timeoutMessage:s,withCredentials:s,adapter:s,responseType:s,xsrfCookieName:s,xsrfHeaderName:s,onUploadProgress:s,onDownloadProgress:s,decompress:s,maxContentLength:s,maxBodyLength:s,beforeRedirect:s,transport:s,httpAgent:s,httpsAgent:s,cancelToken:s,socketPath:s,responseEncoding:s,validateStatus:a,headers:(e,t)=>o(ve(e),ve(t),!0)};return F.forEach(Object.keys(Object.assign({},e,t)),(function(n){const i=c[n]||o,s=i(e[n],t[n],n);F.isUndefined(s)&&i!==a||(r[n]=s)})),r}const _e={};["object","boolean","number","function","string","symbol"].forEach(((e,t)=>{_e[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}}));const Re={};_e.transitional=function(e,t,r){function n(e,t){return"[Axios v1.4.0] Transitional option '"+e+"'"+t+(r?". "+r:"")}return(r,o,i)=>{if(!1===e)throw new I(n(o," has been removed"+(t?" in "+t:"")),I.ERR_DEPRECATED);return t&&!Re[o]&&(Re[o]=!0,console.warn(n(o," has been deprecated since v"+t+" and will be removed in the near future"))),!e||e(r,o,i)}};var Te={assertOptions:function(e,t,r){if("object"!=typeof e)throw new I("options must be an object",I.ERR_BAD_OPTION_VALUE);const n=Object.keys(e);let o=n.length;for(;o-- >0;){const i=n[o],s=t[i];if(s){const t=e[i],r=void 0===t||s(t,i,e);if(!0!==r)throw new I("option "+i+" must be "+r,I.ERR_BAD_OPTION_VALUE)}else if(!0!==r)throw new I("Unknown option "+i,I.ERR_BAD_OPTION)}},validators:_e};const Se=Te.validators;class xe{constructor(e){this.defaults=e,this.interceptors={request:new X,response:new X}}request(e,t){"string"==typeof e?(t=t||{}).url=e:t=e||{},t=Oe(this.defaults,t);const{transitional:r,paramsSerializer:n,headers:o}=t;let i;void 0!==r&&Te.assertOptions(r,{silentJSONParsing:Se.transitional(Se.boolean),forcedJSONParsing:Se.transitional(Se.boolean),clarifyTimeoutError:Se.transitional(Se.boolean)},!1),null!=n&&(F.isFunction(n)?t.paramsSerializer={serialize:n}:Te.assertOptions(n,{encode:Se.function,serialize:Se.function},!0)),t.method=(t.method||this.defaults.method||"get").toLowerCase(),i=o&&F.merge(o.common,o[t.method]),i&&F.forEach(["delete","get","head","post","put","patch","common"],(e=>{delete o[e]})),t.headers=le.concat(i,o);const s=[];let a=!0;this.interceptors.request.forEach((function(e){"function"==typeof e.runWhen&&!1===e.runWhen(t)||(a=a&&e.synchronous,s.unshift(e.fulfilled,e.rejected))}));const c=[];let u;this.interceptors.response.forEach((function(e){c.push(e.fulfilled,e.rejected)}));let l,f=0;if(!a){const e=[be.bind(this),void 0];for(e.unshift.apply(e,s),e.push.apply(e,c),l=e.length,u=Promise.resolve(t);f<l;)u=u.then(e[f++],e[f++]);return u}l=s.length;let h=t;for(f=0;f<l;){const e=s[f++],t=s[f++];try{h=e(h)}catch(e){t.call(this,e);break}}try{u=be.call(this,h)}catch(e){return Promise.reject(e)}for(f=0,l=c.length;f<l;)u=u.then(c[f++],c[f++]);return u}getUri(e){return Y(ye((e=Oe(this.defaults,e)).baseURL,e.url),e.params,e.paramsSerializer)}}F.forEach(["delete","get","head","options"],(function(e){xe.prototype[e]=function(t,r){return this.request(Oe(r||{},{method:e,url:t,data:(r||{}).data}))}})),F.forEach(["post","put","patch"],(function(e){function t(t){return function(r,n,o){return this.request(Oe(o||{},{method:e,headers:t?{"Content-Type":"multipart/form-data"}:{},url:r,data:n}))}}xe.prototype[e]=t(),xe.prototype[e+"Form"]=t(!0)}));var Ae=xe;class Ne{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 r=this;this.promise.then((e=>{if(!r._listeners)return;let t=r._listeners.length;for(;t-- >0;)r._listeners[t](e);r._listeners=null})),this.promise.then=e=>{let t;const n=new Promise((e=>{r.subscribe(e),t=e})).then(e);return n.cancel=function(){r.unsubscribe(t)},n},e((function(e,n,o){r.reason||(r.reason=new de(e,n,o),t(r.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)}static source(){let e;return{token:new Ne((function(t){e=t})),cancel:e}}}var Ce=Ne;const Le={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(Le).forEach((([e,t])=>{Le[t]=e}));var Pe=Le;const je=function e(t){const r=new Ae(t),o=n(Ae.prototype.request,r);return F.extend(o,Ae.prototype,r,{allOwnKeys:!0}),F.extend(o,r,null,{allOwnKeys:!0}),o.create=function(r){return e(Oe(t,r))},o}(ne);je.Axios=Ae,je.CanceledError=de,je.CancelToken=Ce,je.isCancel=he,je.VERSION="1.4.0",je.toFormData=$,je.AxiosError=I,je.Cancel=je.CanceledError,je.all=function(e){return Promise.all(e)},je.spread=function(e){return function(t){return e.apply(null,t)}},je.isAxiosError=function(e){return F.isObject(e)&&!0===e.isAxiosError},je.mergeConfig=Oe,je.AxiosHeaders=le,je.formToJSON=e=>ee(F.isHTMLForm(e)?new FormData(e):e),je.HttpStatusCode=Pe,je.default=je,e.exports=je}},t={};function r(n){var o=t[n];if(void 0!==o)return o.exports;var i=t[n]={exports:{}};return e[n](i,i.exports,r),i.exports}r.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),r(138)})();
|
package/package.json
CHANGED
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
const axios = require("axios");
|
|
2
|
+
|
|
3
|
+
class Profile {
|
|
4
|
+
constructor(endpoint, headers, distinct_id, payload) {
|
|
5
|
+
// User profile trigger API endpoint is prepared
|
|
6
|
+
this.distinct_id = distinct_id;
|
|
7
|
+
this.endpoint = new URL("profiles/", endpoint).href;
|
|
8
|
+
this.payload = { distinct_id, ...payload };
|
|
9
|
+
this.headers = headers;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
async updateProfile() {
|
|
13
|
+
try {
|
|
14
|
+
const url = new URL(`${this.endpoint}${this.distinct_id}`).href;
|
|
15
|
+
const res = this.request(url, this.payload, "PUT");
|
|
16
|
+
return res;
|
|
17
|
+
} catch (error) {
|
|
18
|
+
if (error.response.status === 400) {
|
|
19
|
+
return this.createProfile(this.distinct_id);
|
|
20
|
+
} else {
|
|
21
|
+
throw new Error(`Error while creating profile`);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
async createProfile() {
|
|
27
|
+
try {
|
|
28
|
+
return this.request(this.endpoint, this.payload);
|
|
29
|
+
} catch (error) {
|
|
30
|
+
throw new Error(`Error while creating profile`);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
async mergeProfiles(new_distinct_id) {
|
|
35
|
+
try {
|
|
36
|
+
const url = new URL(
|
|
37
|
+
`${this.endpoint}${this.distinct_id}/merge/${new_distinct_id}`
|
|
38
|
+
).href;
|
|
39
|
+
this.distinct_id = new_distinct_id;
|
|
40
|
+
return this.request(url);
|
|
41
|
+
} catch (error) {
|
|
42
|
+
throw new Error(`Error while updating profile`);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
async addChannelData(channel_name, channel_data) {
|
|
47
|
+
try {
|
|
48
|
+
const url = new URL(`${this.endpoint}${this.distinct_id}/channel`)
|
|
49
|
+
.href;
|
|
50
|
+
const _channel_object = {
|
|
51
|
+
channel: {},
|
|
52
|
+
};
|
|
53
|
+
switch (channel_name) {
|
|
54
|
+
case "push":
|
|
55
|
+
_channel_object.channel.push = [
|
|
56
|
+
{
|
|
57
|
+
token: channel_data.token,
|
|
58
|
+
status: 1,
|
|
59
|
+
integration_id: channel_data.integration,
|
|
60
|
+
},
|
|
61
|
+
];
|
|
62
|
+
break;
|
|
63
|
+
case "inapp":
|
|
64
|
+
_channel_object.channel.inapp = [
|
|
65
|
+
{
|
|
66
|
+
token: channel_data.token,
|
|
67
|
+
status: 1,
|
|
68
|
+
integration_id: channel_data.integration,
|
|
69
|
+
},
|
|
70
|
+
];
|
|
71
|
+
break;
|
|
72
|
+
case "sms":
|
|
73
|
+
_channel_object.channel.sms = channel_data.token;
|
|
74
|
+
break;
|
|
75
|
+
case "whatsapp":
|
|
76
|
+
_channel_object.channel.whatsapp = channel_data.token;
|
|
77
|
+
break;
|
|
78
|
+
case "slack":
|
|
79
|
+
_channel_object.channel.slack = channel_data.token;
|
|
80
|
+
break;
|
|
81
|
+
case "teams":
|
|
82
|
+
_channel_object.channel.teams = channel_data.token;
|
|
83
|
+
break;
|
|
84
|
+
case "email":
|
|
85
|
+
_channel_object.channel.email = channel_data.token;
|
|
86
|
+
break;
|
|
87
|
+
case "discord":
|
|
88
|
+
_channel_object.channel.discord = channel_data.token;
|
|
89
|
+
break;
|
|
90
|
+
default:
|
|
91
|
+
throw new Error(
|
|
92
|
+
`Invalid channel: '${channel_name}' dose not exist.`
|
|
93
|
+
);
|
|
94
|
+
break;
|
|
95
|
+
}
|
|
96
|
+
return this.request(url, _channel_object, "PATCH");
|
|
97
|
+
} catch (error) {
|
|
98
|
+
throw new Error(`Unable to add channel`);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
async ClearChannelData(channel_name, token) {
|
|
103
|
+
try {
|
|
104
|
+
const url = new URL(
|
|
105
|
+
`${this.endpoint}${this.distinct_id}/channel/delete`
|
|
106
|
+
).href;
|
|
107
|
+
const _channel_object = {};
|
|
108
|
+
if (Array.isArray(channel_name)) {
|
|
109
|
+
_channel_object.channel = [...channel_name];
|
|
110
|
+
} else {
|
|
111
|
+
switch (channel_name) {
|
|
112
|
+
case "push":
|
|
113
|
+
_channel_object.push = [token];
|
|
114
|
+
break;
|
|
115
|
+
case "inapp":
|
|
116
|
+
_channel_object.inapp = [token];
|
|
117
|
+
break;
|
|
118
|
+
default:
|
|
119
|
+
_channel_object.channel = [channel_name];
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
return this.request(url, _channel_object, "POST");
|
|
123
|
+
} catch (error) {
|
|
124
|
+
throw new Error(`Unable to clear channel`);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
request = async (url, payload = null, method = "POST") => {
|
|
129
|
+
return await axios({
|
|
130
|
+
method,
|
|
131
|
+
url,
|
|
132
|
+
data: payload,
|
|
133
|
+
headers: this.headers,
|
|
134
|
+
});
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
module.exports = Profile;
|
package/src/index.js
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
const { Event } = require("./Event");
|
|
2
|
+
const Profile = require("./Profile");
|
|
2
3
|
|
|
3
4
|
class Fyno {
|
|
4
5
|
wsid = process.env.FYNO_WSID;
|
|
5
6
|
api_key = process.env.FYNO_API_KEY;
|
|
6
7
|
version = process.env.FYNO_VERSION || "live";
|
|
7
8
|
endpoint = process.env.FYNO_ENDPOINT || "https://api.fyno.io/v1/";
|
|
9
|
+
profile = null;
|
|
8
10
|
|
|
9
11
|
constructor(
|
|
10
12
|
wsid = this.wsid,
|
|
@@ -16,7 +18,7 @@ class Fyno {
|
|
|
16
18
|
this.api_key = api_key;
|
|
17
19
|
this.version = version;
|
|
18
20
|
// WSID and VERSION values get appended to the endpoint
|
|
19
|
-
this.endpoint = new URL(`${this.wsid}/${this.version}
|
|
21
|
+
this.endpoint = new URL(`${this.wsid}/${this.version}/`, endpoint).href;
|
|
20
22
|
this.headers = this.getHeaders();
|
|
21
23
|
|
|
22
24
|
this.validate();
|
|
@@ -51,6 +53,60 @@ class Fyno {
|
|
|
51
53
|
const _event = new Event(this.endpoint, this.headers, event, payload);
|
|
52
54
|
return _event.trigger();
|
|
53
55
|
}
|
|
56
|
+
|
|
57
|
+
async identify(distinct_id, payload) {
|
|
58
|
+
const profile = new Profile(
|
|
59
|
+
this.endpoint,
|
|
60
|
+
this.headers,
|
|
61
|
+
distinct_id,
|
|
62
|
+
payload
|
|
63
|
+
);
|
|
64
|
+
this.profile = profile;
|
|
65
|
+
return this;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
async create() {
|
|
69
|
+
return await this.profile.createProfile();
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
async update(distinct_id, payload) {
|
|
73
|
+
const profile = new Profile(
|
|
74
|
+
this.endpoint,
|
|
75
|
+
this.headers,
|
|
76
|
+
distinct_id,
|
|
77
|
+
payload
|
|
78
|
+
);
|
|
79
|
+
this.profile = profile;
|
|
80
|
+
return profile.updateProfile();
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
async setEmail(token) {
|
|
84
|
+
return await this.profile.addChannelData("slack", { token });
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
async setSms(token) {
|
|
88
|
+
return await this.profile.addChannelData("slack", { token });
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
async setSlack(token) {
|
|
92
|
+
return await this.profile.addChannelData("slack", { token });
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
async setDiscord(token) {
|
|
96
|
+
return await this.profile.addChannelData("discord", { token });
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
async setTeams(token) {
|
|
100
|
+
return await this.profile.addChannelData("teams", { token });
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
async setWhatsapp(token) {
|
|
104
|
+
return await this.profile.addChannelData("whatsapp", { token });
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
async clearChannel(channel, token = null) {
|
|
108
|
+
return await this.profile.ClearChannelData(channel, token);
|
|
109
|
+
}
|
|
54
110
|
}
|
|
55
111
|
|
|
56
112
|
module.exports = {
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created
|
|
2
|
-
# For more information see: https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages
|
|
3
|
-
|
|
4
|
-
name: Node.js Package
|
|
5
|
-
|
|
6
|
-
on:
|
|
7
|
-
release:
|
|
8
|
-
types: [created]
|
|
9
|
-
|
|
10
|
-
jobs:
|
|
11
|
-
build:
|
|
12
|
-
runs-on: ubuntu-latest
|
|
13
|
-
steps:
|
|
14
|
-
- uses: actions/checkout@v3
|
|
15
|
-
- uses: actions/setup-node@v3
|
|
16
|
-
with:
|
|
17
|
-
node-version: 16
|
|
18
|
-
- run: npm install
|
|
19
|
-
- run: npm test
|
|
20
|
-
env:
|
|
21
|
-
FYNO_WSID: ${{secrets.fyno_wsid}}
|
|
22
|
-
FYNO_API_KEY: ${{secrets.fyno_api_key}}
|
|
23
|
-
FYNO_VERSION: ${{secrets.fyno_version}}
|
|
24
|
-
|
|
25
|
-
publish-npm:
|
|
26
|
-
needs: build
|
|
27
|
-
runs-on: ubuntu-latest
|
|
28
|
-
steps:
|
|
29
|
-
- uses: actions/checkout@v3
|
|
30
|
-
- uses: actions/setup-node@v3
|
|
31
|
-
with:
|
|
32
|
-
node-version: 16
|
|
33
|
-
registry-url: https://registry.npmjs.org/
|
|
34
|
-
- run: npm install
|
|
35
|
-
- run: npm publish --access=public
|
|
36
|
-
env:
|
|
37
|
-
NODE_AUTH_TOKEN: ${{secrets.npm_token}}
|
package/test/event.test.js
DELETED
|
@@ -1,208 +0,0 @@
|
|
|
1
|
-
const { Fyno } = require("../src");
|
|
2
|
-
|
|
3
|
-
const to = {
|
|
4
|
-
sms: "",
|
|
5
|
-
whatsapp: "",
|
|
6
|
-
email: "",
|
|
7
|
-
slack: "ashwin@fyno.io",
|
|
8
|
-
discord: "",
|
|
9
|
-
teams: "",
|
|
10
|
-
push: "",
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
const data = {
|
|
14
|
-
name: "Ashwin",
|
|
15
|
-
sdk: "Node.js",
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
const event_name = "test-cases";
|
|
19
|
-
|
|
20
|
-
const success_response = {
|
|
21
|
-
request_id: expect.anything(),
|
|
22
|
-
received_time: expect.anything(),
|
|
23
|
-
event: event_name,
|
|
24
|
-
response: {
|
|
25
|
-
sms: {
|
|
26
|
-
status: "error",
|
|
27
|
-
message: expect.anything(),
|
|
28
|
-
},
|
|
29
|
-
whatsapp: {
|
|
30
|
-
status: "error",
|
|
31
|
-
message: expect.anything(),
|
|
32
|
-
},
|
|
33
|
-
email: {
|
|
34
|
-
status: "error",
|
|
35
|
-
message: expect.anything(),
|
|
36
|
-
},
|
|
37
|
-
slack: {
|
|
38
|
-
status: "ok",
|
|
39
|
-
destination: to.slack,
|
|
40
|
-
msg_id: expect.anything(),
|
|
41
|
-
},
|
|
42
|
-
discord: {
|
|
43
|
-
status: "error",
|
|
44
|
-
message: expect.anything(),
|
|
45
|
-
},
|
|
46
|
-
teams: {
|
|
47
|
-
status: "error",
|
|
48
|
-
message: expect.anything(),
|
|
49
|
-
},
|
|
50
|
-
push: {
|
|
51
|
-
status: "error",
|
|
52
|
-
message: expect.anything(),
|
|
53
|
-
},
|
|
54
|
-
},
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
const success_response_batch = {
|
|
58
|
-
request_id: expect.anything(),
|
|
59
|
-
received_time: expect.anything(),
|
|
60
|
-
event: event_name,
|
|
61
|
-
response: [
|
|
62
|
-
{
|
|
63
|
-
seq: 1,
|
|
64
|
-
sms: {
|
|
65
|
-
status: "error",
|
|
66
|
-
message: expect.anything(),
|
|
67
|
-
},
|
|
68
|
-
whatsapp: {
|
|
69
|
-
status: "error",
|
|
70
|
-
message: expect.anything(),
|
|
71
|
-
},
|
|
72
|
-
email: {
|
|
73
|
-
status: "error",
|
|
74
|
-
message: expect.anything(),
|
|
75
|
-
},
|
|
76
|
-
slack: {
|
|
77
|
-
status: "ok",
|
|
78
|
-
destination: to.slack,
|
|
79
|
-
msg_id: expect.anything(),
|
|
80
|
-
},
|
|
81
|
-
discord: {
|
|
82
|
-
status: "error",
|
|
83
|
-
message: expect.anything(),
|
|
84
|
-
},
|
|
85
|
-
teams: {
|
|
86
|
-
status: "error",
|
|
87
|
-
message: expect.anything(),
|
|
88
|
-
},
|
|
89
|
-
push: {
|
|
90
|
-
status: "error",
|
|
91
|
-
message: expect.anything(),
|
|
92
|
-
},
|
|
93
|
-
},
|
|
94
|
-
],
|
|
95
|
-
};
|
|
96
|
-
|
|
97
|
-
const failure_response = {
|
|
98
|
-
status: "error",
|
|
99
|
-
_message: "Invalid API details",
|
|
100
|
-
};
|
|
101
|
-
|
|
102
|
-
describe("Firing an event", () => {
|
|
103
|
-
test("Should fail when WSID supplied is incorrect", async () => {
|
|
104
|
-
let response;
|
|
105
|
-
|
|
106
|
-
try {
|
|
107
|
-
const fyno = new Fyno("12345678910");
|
|
108
|
-
response = await fyno.fire(event_name, { to, data });
|
|
109
|
-
} catch (e) {
|
|
110
|
-
response = e;
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
expect(response).toMatchObject(failure_response);
|
|
114
|
-
});
|
|
115
|
-
test("Should fail when WSID supplied is invalid", async () => {
|
|
116
|
-
let response;
|
|
117
|
-
|
|
118
|
-
try {
|
|
119
|
-
const fyno = new Fyno("12345");
|
|
120
|
-
} catch (e) {
|
|
121
|
-
response = e.message;
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
expect(response).toBe(`Workspace ID value '12345' is invalid`);
|
|
125
|
-
});
|
|
126
|
-
test("Should fail when API Key supplied is incorrect", async () => {
|
|
127
|
-
let response;
|
|
128
|
-
|
|
129
|
-
try {
|
|
130
|
-
const fyno = new Fyno(
|
|
131
|
-
(wsid = undefined),
|
|
132
|
-
(api_key = "ABCDEFG.++HIJKLMNOPQRSTUVWXYZ012345678910")
|
|
133
|
-
);
|
|
134
|
-
response = await fyno.fire("event_name", { to, data });
|
|
135
|
-
} catch (e) {
|
|
136
|
-
response = e;
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
expect(response).toMatchObject(failure_response);
|
|
140
|
-
});
|
|
141
|
-
test("Should fail when API Key supplied is invalid", async () => {
|
|
142
|
-
let response;
|
|
143
|
-
|
|
144
|
-
try {
|
|
145
|
-
const fyno = new Fyno((wsid = undefined), (api_key = "12345"));
|
|
146
|
-
} catch (e) {
|
|
147
|
-
response = e.message;
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
expect(response).toBe(`API Key value '12345' is invalid`);
|
|
151
|
-
});
|
|
152
|
-
test("Should fail when ENV supplied is invalid (single)", async () => {
|
|
153
|
-
let response;
|
|
154
|
-
try {
|
|
155
|
-
const fyno = new Fyno(undefined, undefined, "random");
|
|
156
|
-
} catch (e) {
|
|
157
|
-
response = e.message;
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
expect(response).toBe(
|
|
161
|
-
`Environment value 'random' is invalid. It should be either 'test' or 'live'.`
|
|
162
|
-
);
|
|
163
|
-
});
|
|
164
|
-
test("Should succeed when all credentials are correct and supplied through ENV file (single)", async () => {
|
|
165
|
-
const fyno = new Fyno();
|
|
166
|
-
const response = await fyno.fire(event_name, { to, data });
|
|
167
|
-
|
|
168
|
-
expect(response).toMatchObject(success_response);
|
|
169
|
-
});
|
|
170
|
-
test("Should succeed when all credentials are correct and supplied through ENV file (batch)", async () => {
|
|
171
|
-
const fyno = new Fyno();
|
|
172
|
-
const response = await fyno.fire(event_name, [{ to, data }]);
|
|
173
|
-
|
|
174
|
-
expect(response).toMatchObject(success_response_batch);
|
|
175
|
-
});
|
|
176
|
-
test("Should succeed when all credentials are correct and supplied manually (single)", async () => {
|
|
177
|
-
const fyno = new Fyno(
|
|
178
|
-
process.env.FYNO_WSID,
|
|
179
|
-
process.env.FYNO_API_KEY,
|
|
180
|
-
process.env.FYNO_VERSION
|
|
181
|
-
);
|
|
182
|
-
const response = await fyno.fire(event_name, { to, data });
|
|
183
|
-
|
|
184
|
-
expect(response).toMatchObject(success_response);
|
|
185
|
-
});
|
|
186
|
-
test("Should succeed when all credentials are correct and supplied manually (batch)", async () => {
|
|
187
|
-
const fyno = new Fyno(
|
|
188
|
-
process.env.FYNO_WSID,
|
|
189
|
-
process.env.FYNO_API_KEY,
|
|
190
|
-
process.env.FYNO_VERSION
|
|
191
|
-
);
|
|
192
|
-
const response = await fyno.fire(event_name, [{ to, data }]);
|
|
193
|
-
|
|
194
|
-
expect(response).toMatchObject(success_response_batch);
|
|
195
|
-
});
|
|
196
|
-
test("Should succeed when all credentals are correct and supplied manually and through ENV files (single)", async () => {
|
|
197
|
-
const fyno = new Fyno(process.env.FYNO_WSID);
|
|
198
|
-
const response = await fyno.fire(event_name, { to, data });
|
|
199
|
-
|
|
200
|
-
expect(response).toMatchObject(success_response);
|
|
201
|
-
});
|
|
202
|
-
test("Should succeed when all credentals are correct and supplied manually and through ENV files (batch)", async () => {
|
|
203
|
-
const fyno = new Fyno(process.env.FYNO_WSID);
|
|
204
|
-
const response = await fyno.fire(event_name, [{ to, data }]);
|
|
205
|
-
|
|
206
|
-
expect(response).toMatchObject(success_response_batch);
|
|
207
|
-
});
|
|
208
|
-
});
|
package/test/index.spec.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
require("./event.test.js");
|