@fyno/node 1.1.5 → 1.1.9
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 +153 -0
- package/src/index.js +62 -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 getProfile(){try{const e=new URL(`${this.endpoint}${this.distinct_id}`).href;return this.request(e,this.payload,"GET")}catch(e){if(400===e.response.status)return this.createProfile(this.distinct_id);if(404===e.response.status)return new Error("No Profile Found for the disctin_id");throw new Error("Error while getting the profile")}}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 getProfile(e){return new o(this.endpoint,this.headers,e).getProfile()}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 r},e.exports.__esModule=!0,e.exports.default=e.exports;var t,r={},i=Object.prototype,s=i.hasOwnProperty,a=Object.defineProperty||function(e,t,r){e[t]=r.value},c="function"==typeof Symbol?Symbol:{},u=c.iterator||"@@iterator",l=c.asyncIterator||"@@asyncIterator",f=c.toStringTag||"@@toStringTag";function h(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{h({},"")}catch(t){h=function(e,t,r){return e[t]=r}}function p(e,t,r,n){var o=t&&t.prototype instanceof b?t:b,i=Object.create(o.prototype),s=new j(n||[]);return a(i,"_invoke",{value:N(e,r,s)}),i}function d(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}r.wrap=p;var y="suspendedStart",m="suspendedYield",g="executing",E="completed",w={};function b(){}function v(){}function O(){}var _={};h(_,u,(function(){return this}));var R=Object.getPrototypeOf,T=R&&R(R(D([])));T&&T!==i&&s.call(T,u)&&(_=T);var S=O.prototype=b.prototype=Object.create(_);function x(e){["next","throw","return"].forEach((function(t){h(e,t,(function(e){return this._invoke(t,e)}))}))}function A(e,t){function r(o,i,a,c){var u=d(e[o],e,i);if("throw"!==u.type){var l=u.arg,f=l.value;return f&&"object"==n(f)&&s.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;a(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 N(e,r,n){var o=y;return function(i,s){if(o===g)throw new Error("Generator is already running");if(o===E){if("throw"===i)throw s;return{value:t,done:!0}}for(n.method=i,n.arg=s;;){var a=n.delegate;if(a){var c=C(a,n);if(c){if(c===w)continue;return c}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(o===y)throw o=E,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);o=g;var u=d(e,r,n);if("normal"===u.type){if(o=n.done?E:m,u.arg===w)continue;return{value:u.arg,done:n.done}}"throw"===u.type&&(o=E,n.method="throw",n.arg=u.arg)}}}function C(e,r){var n=r.method,o=e.iterator[n];if(o===t)return r.delegate=null,"throw"===n&&e.iterator.return&&(r.method="return",r.arg=t,C(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),w;var i=d(o,e.iterator,r.arg);if("throw"===i.type)return r.method="throw",r.arg=i.arg,r.delegate=null,w;var s=i.arg;return s?s.done?(r[e.resultName]=s.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,w):s:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,w)}function P(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 L(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function j(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(P,this),this.reset(!0)}function D(e){if(e||""===e){var r=e[u];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var o=-1,i=function r(){for(;++o<e.length;)if(s.call(e,o))return r.value=e[o],r.done=!1,r;return r.value=t,r.done=!0,r};return i.next=i}}throw new TypeError(n(e)+" is not iterable")}return v.prototype=O,a(S,"constructor",{value:O,configurable:!0}),a(O,"constructor",{value:v,configurable:!0}),v.displayName=h(O,f,"GeneratorFunction"),r.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===v||"GeneratorFunction"===(t.displayName||t.name))},r.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,O):(e.__proto__=O,h(e,f,"GeneratorFunction")),e.prototype=Object.create(S),e},r.awrap=function(e){return{__await:e}},x(A.prototype),h(A.prototype,l,(function(){return this})),r.AsyncIterator=A,r.async=function(e,t,n,o,i){void 0===i&&(i=Promise);var s=new A(p(e,t,n,o),i);return r.isGeneratorFunction(t)?s:s.next().then((function(e){return e.done?e.value:s.next()}))},x(S),h(S,f,"Generator"),h(S,u,(function(){return this})),h(S,"toString",(function(){return"[object Generator]"})),r.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}},r.values=D,j.prototype={constructor:j,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(L),!e)for(var r in this)"t"===r.charAt(0)&&s.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=t)},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 r=this;function n(n,o){return a.type="throw",a.arg=e,r.next=n,o&&(r.method="next",r.arg=t),!!o}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=s.call(i,"catchLoc"),u=s.call(i,"finallyLoc");if(c&&u){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(c){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return n(i.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&&s.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 i=o?o.completion:{};return i.type=e,i.arg=t,o?(this.method="next",this.next=o.finallyLoc,w):this.complete(i)},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),w},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),L(r),w}},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;L(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:D(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),w}},r}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)&&!["ERR_CANCELED","ECONNABORTED"].includes(e.code)&&(0,c.default)(e)}var p=["get","head","options"],d=p.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!==d.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){var r=e.interceptors.request.use((function(e){return w(e).lastRequestTime=Date.now(),e})),n=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,p,d,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,p=s.shouldResetTimeout,d=void 0!==p&&p,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),d||!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)}}());return{requestInterceptorId:r,responseInterceptorId:n}}R.isNetworkError=h,R.isSafeRequestError=function(e){return!!e.config&&y(e)&&-1!==p.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"),p=u("string"),d=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),P=c("RegExp"),L=(e,t)=>{const r=Object.getOwnPropertyDescriptors(e),n={};_(r,((r,o)=>{let i;!1!==(i=t(r,o,e))&&(n[o]=i||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)&&d(e.constructor.isBuffer)&&e.constructor.isBuffer(e)},isFormData:e=>{let t;return e&&("function"==typeof FormData&&e instanceof FormData||d(e.append)&&("formdata"===(t=s(e))||"object"===t&&d(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:p,isNumber:y,isBoolean:e=>!0===e||!1===e,isObject:m,isPlainObject:g,isUndefined:f,isDate:E,isFile:w,isBlob:b,isRegExp:P,isFunction:d,isStream:e=>m(e)&&d(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&&d(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:L,freezeMethods:e=>{L(e,((t,r)=>{if(d(e)&&-1!==["arguments","caller","callee"].indexOf(r))return!1;const n=e[r];d(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&&d(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)||d(e))&&d(e.then)&&d(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 G(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 $=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=H(r),a.forEach((function(e,n){!F.isUndefined(e)&&null!==e&&t.append(!0===s?G([r],n,i):null===s?r:r+"[]",c(e))})),!1;return!!M(e)||(t.append(G(o,r,i),c(e)),!1)}const l=[],f=Object.assign($,{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 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={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 z(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 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:Q.classes.FormData,Blob:Q.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};F.forEach(["delete","get","head","post","put","patch"],(e=>{te.headers[e]={}}));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-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]&&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.reduceDescriptors(ce.prototype,(({value:e},t)=>{let r=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(e){this[r]=e}}})),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 he(e,t,r){I.call(this,null==e?"canceled":e,I.ERR_CANCELED,t,r),this.name="CanceledError"}F.inherits(he,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 de(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 ye=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 me(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 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,a;function c(){e.cancelToken&&e.cancelToken.unsubscribe(s),e.signal&&e.signal.removeEventListener("abort",s)}F.isFormData(n)&&(Q.isStandardBrowserEnv||Q.isStandardBrowserWebWorkerEnv?o.setContentType(!1):o.getContentType(/^\s*multipart\/form-data/)?F.isString(a=o.getContentType())&&o.setContentType(a.replace(/^\s*(multipart\/form-data);+/,"$1")):o.setContentType("multipart/form-data"));let u=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 l=de(e.baseURL,e.url);function f(){if(!u)return;const n=ue.from("getAllResponseHeaders"in u&&u.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),c()}),(function(e){r(e),c()}),{data:i&&"text"!==i&&"json"!==i?u.response:u.responseText,status:u.status,statusText:u.statusText,headers:n,config:e,request:u}),u=null}if(u.open(e.method.toUpperCase(),Y(l,e.params,e.paramsSerializer),!0),u.timeout=e.timeout,"onloadend"in u?u.onloadend=f:u.onreadystatechange=function(){u&&4===u.readyState&&(0!==u.status||u.responseURL&&0===u.responseURL.indexOf("file:"))&&setTimeout(f)},u.onabort=function(){u&&(r(new I("Request aborted",I.ECONNABORTED,e,u)),u=null)},u.onerror=function(){r(new I("Network Error",I.ERR_NETWORK,e,u)),u=null},u.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,u)),u=null},Q.isStandardBrowserEnv){const t=(e.withCredentials||ye(l))&&e.xsrfCookieName&&pe.read(e.xsrfCookieName);t&&o.set(e.xsrfHeaderName,t)}void 0===n&&o.setContentType(null),"setRequestHeader"in u&&F.forEach(o.toJSON(),(function(e,t){u.setRequestHeader(t,e)})),F.isUndefined(e.withCredentials)||(u.withCredentials=!!e.withCredentials),i&&"json"!==i&&(u.responseType=e.responseType),"function"==typeof e.onDownloadProgress&&u.addEventListener("progress",me(e.onDownloadProgress,!0)),"function"==typeof e.onUploadProgress&&u.upload&&u.upload.addEventListener("progress",me(e.onUploadProgress)),(e.cancelToken||e.signal)&&(s=t=>{u&&(r(!t||t.type?new he(null,e,u):t),u.abort(),u=null)},e.cancelToken&&e.cancelToken.subscribe(s),e.signal&&(e.signal.aborted?s():e.signal.addEventListener("abort",s)));const h=function(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}(l);h&&-1===Q.protocols.indexOf(h)?r(new I("Unsupported protocol "+h+":",I.ERR_BAD_REQUEST,e)):u.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})}}));const Ee=e=>`- ${e}`,we=e=>F.isFunction(e)||null===e||!1===e;var be=e=>{e=F.isArray(e)?e:[e];const{length:t}=e;let r,n;const o={};for(let i=0;i<t;i++){let t;if(r=e[i],n=r,!we(r)&&(n=ge[(t=String(r)).toLowerCase()],void 0===n))throw new I(`Unknown adapter '${t}'`);if(n)break;o[t||"#"+i]=n}if(!n){const e=Object.entries(o).map((([e,t])=>`adapter ${e} `+(!1===t?"is not supported by the environment":"is not available in the build")));throw new I("There is no suitable adapter to dispatch the request "+(t?e.length>1?"since :\n"+e.map(Ee).join("\n"):" "+Ee(e[0]):"as no adapter specified"),"ERR_NOT_SUPPORT")}return n};function ve(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new he(null,e)}function Oe(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),be(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 _e=e=>e instanceof ue?e.toJSON():e;function Re(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(_e(e),_e(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 Te={};["object","boolean","number","function","string","symbol"].forEach(((e,t)=>{Te[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}}));const Se={};Te.transitional=function(e,t,r){function n(e,t){return"[Axios v1.5.1] 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&&!Se[o]&&(Se[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 xe={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:Te};const Ae=xe.validators;class Ne{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=Re(this.defaults,t);const{transitional:r,paramsSerializer:n,headers:o}=t;void 0!==r&&xe.assertOptions(r,{silentJSONParsing:Ae.transitional(Ae.boolean),forcedJSONParsing:Ae.transitional(Ae.boolean),clarifyTimeoutError:Ae.transitional(Ae.boolean)},!1),null!=n&&(F.isFunction(n)?t.paramsSerializer={serialize:n}:xe.assertOptions(n,{encode:Ae.function,serialize:Ae.function},!0)),t.method=(t.method||this.defaults.method||"get").toLowerCase();let i=o&&F.merge(o.common,o[t.method]);o&&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=[Oe.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=Oe.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(de((e=Re(this.defaults,e)).baseURL,e.url),e.params,e.paramsSerializer)}}F.forEach(["delete","get","head","options"],(function(e){Ne.prototype[e]=function(t,r){return this.request(Re(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(Re(o||{},{method:e,headers:t?{"Content-Type":"multipart/form-data"}:{},url:r,data:n}))}}Ne.prototype[e]=t(),Ne.prototype[e+"Form"]=t(!0)}));var Ce=Ne;class Pe{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 he(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 Pe((function(t){e=t})),cancel:e}}}var Le=Pe;const je={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(je).forEach((([e,t])=>{je[t]=e}));var De=je;const ke=function e(t){const r=new Ce(t),o=n(Ce.prototype.request,r);return F.extend(o,Ce.prototype,r,{allOwnKeys:!0}),F.extend(o,r,null,{allOwnKeys:!0}),o.create=function(r){return e(Re(t,r))},o}(re);ke.Axios=Ce,ke.CanceledError=he,ke.CancelToken=Le,ke.isCancel=fe,ke.VERSION="1.5.1",ke.toFormData=z,ke.AxiosError=I,ke.Cancel=ke.CanceledError,ke.all=function(e){return Promise.all(e)},ke.spread=function(e){return function(t){return e.apply(null,t)}},ke.isAxiosError=function(e){return F.isObject(e)&&!0===e.isAxiosError},ke.mergeConfig=Re,ke.AxiosHeaders=ue,ke.formToJSON=e=>ee(F.isHTMLForm(e)?new FormData(e):e),ke.getAdapter=be,ke.HttpStatusCode=De,ke.default=ke,e.exports=ke}},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,153 @@
|
|
|
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 getProfile() {
|
|
13
|
+
try {
|
|
14
|
+
const url = new URL(`${this.endpoint}${this.distinct_id}`).href;
|
|
15
|
+
const res = this.request(url, this.payload, "GET");
|
|
16
|
+
return res;
|
|
17
|
+
} catch (error) {
|
|
18
|
+
if (error.response.status === 400) {
|
|
19
|
+
return this.createProfile(this.distinct_id);
|
|
20
|
+
} else if (error.response.status === 404) {
|
|
21
|
+
return new Error(`No Profile Found for the disctin_id`);
|
|
22
|
+
} else {
|
|
23
|
+
throw new Error(`Error while getting the profile`);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
async updateProfile() {
|
|
29
|
+
try {
|
|
30
|
+
const url = new URL(`${this.endpoint}${this.distinct_id}`).href;
|
|
31
|
+
const res = this.request(url, this.payload, "PUT");
|
|
32
|
+
return res;
|
|
33
|
+
} catch (error) {
|
|
34
|
+
if (error.response.status === 400) {
|
|
35
|
+
return this.createProfile(this.distinct_id);
|
|
36
|
+
} else {
|
|
37
|
+
throw new Error(`Error while creating profile`);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
async createProfile() {
|
|
43
|
+
try {
|
|
44
|
+
return this.request(this.endpoint, this.payload);
|
|
45
|
+
} catch (error) {
|
|
46
|
+
throw new Error(`Error while creating profile`);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
async mergeProfiles(new_distinct_id) {
|
|
51
|
+
try {
|
|
52
|
+
const url = new URL(
|
|
53
|
+
`${this.endpoint}${this.distinct_id}/merge/${new_distinct_id}`
|
|
54
|
+
).href;
|
|
55
|
+
this.distinct_id = new_distinct_id;
|
|
56
|
+
return this.request(url);
|
|
57
|
+
} catch (error) {
|
|
58
|
+
throw new Error(`Error while updating profile`);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
async addChannelData(channel_name, channel_data) {
|
|
63
|
+
try {
|
|
64
|
+
const url = new URL(`${this.endpoint}${this.distinct_id}/channel`)
|
|
65
|
+
.href;
|
|
66
|
+
const _channel_object = {
|
|
67
|
+
channel: {},
|
|
68
|
+
};
|
|
69
|
+
switch (channel_name) {
|
|
70
|
+
case "push":
|
|
71
|
+
_channel_object.channel.push = [
|
|
72
|
+
{
|
|
73
|
+
token: channel_data.token,
|
|
74
|
+
status: 1,
|
|
75
|
+
integration_id: channel_data.integration,
|
|
76
|
+
},
|
|
77
|
+
];
|
|
78
|
+
break;
|
|
79
|
+
case "inapp":
|
|
80
|
+
_channel_object.channel.inapp = [
|
|
81
|
+
{
|
|
82
|
+
token: channel_data.token,
|
|
83
|
+
status: 1,
|
|
84
|
+
integration_id: channel_data.integration,
|
|
85
|
+
},
|
|
86
|
+
];
|
|
87
|
+
break;
|
|
88
|
+
case "sms":
|
|
89
|
+
_channel_object.channel.sms = channel_data.token;
|
|
90
|
+
break;
|
|
91
|
+
case "whatsapp":
|
|
92
|
+
_channel_object.channel.whatsapp = channel_data.token;
|
|
93
|
+
break;
|
|
94
|
+
case "slack":
|
|
95
|
+
_channel_object.channel.slack = channel_data.token;
|
|
96
|
+
break;
|
|
97
|
+
case "teams":
|
|
98
|
+
_channel_object.channel.teams = channel_data.token;
|
|
99
|
+
break;
|
|
100
|
+
case "email":
|
|
101
|
+
_channel_object.channel.email = channel_data.token;
|
|
102
|
+
break;
|
|
103
|
+
case "discord":
|
|
104
|
+
_channel_object.channel.discord = channel_data.token;
|
|
105
|
+
break;
|
|
106
|
+
default:
|
|
107
|
+
throw new Error(
|
|
108
|
+
`Invalid channel: '${channel_name}' dose not exist.`
|
|
109
|
+
);
|
|
110
|
+
break;
|
|
111
|
+
}
|
|
112
|
+
return this.request(url, _channel_object, "PATCH");
|
|
113
|
+
} catch (error) {
|
|
114
|
+
throw new Error(`Unable to add channel`);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
async ClearChannelData(channel_name, token) {
|
|
119
|
+
try {
|
|
120
|
+
const url = new URL(
|
|
121
|
+
`${this.endpoint}${this.distinct_id}/channel/delete`
|
|
122
|
+
).href;
|
|
123
|
+
const _channel_object = {};
|
|
124
|
+
if (Array.isArray(channel_name)) {
|
|
125
|
+
_channel_object.channel = [...channel_name];
|
|
126
|
+
} else {
|
|
127
|
+
switch (channel_name) {
|
|
128
|
+
case "push":
|
|
129
|
+
_channel_object.push = [token];
|
|
130
|
+
break;
|
|
131
|
+
case "inapp":
|
|
132
|
+
_channel_object.inapp = [token];
|
|
133
|
+
break;
|
|
134
|
+
default:
|
|
135
|
+
_channel_object.channel = [channel_name];
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
return this.request(url, _channel_object, "POST");
|
|
139
|
+
} catch (error) {
|
|
140
|
+
throw new Error(`Unable to clear channel`);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
request = async (url, payload = null, method = "POST") => {
|
|
145
|
+
return await axios({
|
|
146
|
+
method,
|
|
147
|
+
url,
|
|
148
|
+
data: payload,
|
|
149
|
+
headers: this.headers,
|
|
150
|
+
});
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
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,65 @@ 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 getProfile(distinct_id) {
|
|
69
|
+
const profile = new Profile(this.endpoint, this.headers, distinct_id);
|
|
70
|
+
return profile.getProfile();
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
async create() {
|
|
74
|
+
return await this.profile.createProfile();
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
async update(distinct_id, payload) {
|
|
78
|
+
const profile = new Profile(
|
|
79
|
+
this.endpoint,
|
|
80
|
+
this.headers,
|
|
81
|
+
distinct_id,
|
|
82
|
+
payload
|
|
83
|
+
);
|
|
84
|
+
this.profile = profile;
|
|
85
|
+
return profile.updateProfile();
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
async setEmail(token) {
|
|
89
|
+
return await this.profile.addChannelData("slack", { token });
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
async setSms(token) {
|
|
93
|
+
return await this.profile.addChannelData("slack", { token });
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
async setSlack(token) {
|
|
97
|
+
return await this.profile.addChannelData("slack", { token });
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
async setDiscord(token) {
|
|
101
|
+
return await this.profile.addChannelData("discord", { token });
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
async setTeams(token) {
|
|
105
|
+
return await this.profile.addChannelData("teams", { token });
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
async setWhatsapp(token) {
|
|
109
|
+
return await this.profile.addChannelData("whatsapp", { token });
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
async clearChannel(channel, token = null) {
|
|
113
|
+
return await this.profile.ClearChannelData(channel, token);
|
|
114
|
+
}
|
|
54
115
|
}
|
|
55
116
|
|
|
56
117
|
module.exports = {
|