@fuul/sdk 7.12.0 → 7.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1968,7 +1968,7 @@ class yn {
1968
1968
  }
1969
1969
  }
1970
1970
  }
1971
- const gn = "7.12.0", wn = {
1971
+ const gn = "7.13.0", wn = {
1972
1972
  version: gn
1973
1973
  };
1974
1974
  class bn {
package/dist/index.umd.js CHANGED
@@ -3,4 +3,4 @@
3
3
  `)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(e){return e instanceof this?e:new this(e)}static concat(e,...r){const n=new this(e);return r.forEach(s=>n.set(s)),n}static accessor(e){const n=(this[st]=this[st]={accessors:{}}).accessors,s=this.prototype;function i(o){const c=ee(o);n[c]||(Dr(s,o),n[c]=!0)}return a.isArray(e)?e.forEach(i):i(e),this}};N.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),a.reduceDescriptors(N.prototype,({value:t},e)=>{let r=e[0].toUpperCase()+e.slice(1);return{get:()=>t,set(n){this[r]=n}}}),a.freezeMethods(N);function Se(t,e){const r=this||Z,n=e||r,s=N.from(n.headers);let i=n.data;return a.forEach(t,function(c){i=c.call(r,i,s.normalize(),e?e.status:void 0)}),s.normalize(),i}function it(t){return!!(t&&t.__CANCEL__)}function K(t,e,r){m.call(this,t??"canceled",m.ERR_CANCELED,e,r),this.name="CanceledError"}a.inherits(K,m,{__CANCEL__:!0});function ot(t,e,r){const n=r.config.validateStatus;!r.status||!n||n(r.status)?t(r):e(new m("Request failed with status code "+r.status,[m.ERR_BAD_REQUEST,m.ERR_BAD_RESPONSE][Math.floor(r.status/100)-4],r.config,r.request,r))}function Fr(t){const e=/^([-+\w]{1,25})(:?\/\/|:)/.exec(t);return e&&e[1]||""}function kr(t,e){t=t||10;const r=new Array(t),n=new Array(t);let s=0,i=0,o;return e=e!==void 0?e:1e3,function(d){const l=Date.now(),u=n[i];o||(o=l),r[s]=d,n[s]=l;let f=i,g=0;for(;f!==s;)g+=r[f++],f=f%t;if(s=(s+1)%t,s===i&&(i=(i+1)%t),l-o<e)return;const b=u&&l-u;return b?Math.round(g*1e3/b):void 0}}function Br(t,e){let r=0,n=1e3/e,s,i;const o=(l,u=Date.now())=>{r=u,s=null,i&&(clearTimeout(i),i=null),t(...l)};return[(...l)=>{const u=Date.now(),f=u-r;f>=n?o(l,u):(s=l,i||(i=setTimeout(()=>{i=null,o(s)},n-f)))},()=>s&&o(s)]}const ce=(t,e,r=3)=>{let n=0;const s=kr(50,250);return Br(i=>{const o=i.loaded,c=i.lengthComputable?i.total:void 0,d=o-n,l=s(d),u=o<=c;n=o;const f={loaded:o,total:c,progress:c?o/c:void 0,bytes:d,rate:l||void 0,estimated:l&&c&&u?(c-o)/l:void 0,event:i,lengthComputable:c!=null,[e?"download":"upload"]:!0};t(f)},r)},at=(t,e)=>{const r=t!=null;return[n=>e[0]({lengthComputable:r,total:t,loaded:n}),e[1]]},ct=t=>(...e)=>a.asap(()=>t(...e)),qr=A.hasStandardBrowserEnv?((t,e)=>r=>(r=new URL(r,A.origin),t.protocol===r.protocol&&t.host===r.host&&(e||t.port===r.port)))(new URL(A.origin),A.navigator&&/(msie|trident)/i.test(A.navigator.userAgent)):()=>!0,vr=A.hasStandardBrowserEnv?{write(t,e,r,n,s,i){const o=[t+"="+encodeURIComponent(e)];a.isNumber(r)&&o.push("expires="+new Date(r).toGMTString()),a.isString(n)&&o.push("path="+n),a.isString(s)&&o.push("domain="+s),i===!0&&o.push("secure"),document.cookie=o.join("; ")},read(t){const e=document.cookie.match(new RegExp("(^|;\\s*)("+t+")=([^;]*)"));return e?decodeURIComponent(e[3]):null},remove(t){this.write(t,"",Date.now()-864e5)}}:{write(){},read(){return null},remove(){}};function Ir(t){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(t)}function jr(t,e){return e?t.replace(/\/?\/$/,"")+"/"+e.replace(/^\/+/,""):t}function ut(t,e,r){let n=!Ir(e);return t&&(n||r==!1)?jr(t,e):e}const lt=t=>t instanceof N?{...t}:t;function I(t,e){e=e||{};const r={};function n(l,u,f,g){return a.isPlainObject(l)&&a.isPlainObject(u)?a.merge.call({caseless:g},l,u):a.isPlainObject(u)?a.merge({},u):a.isArray(u)?u.slice():u}function s(l,u,f,g){if(a.isUndefined(u)){if(!a.isUndefined(l))return n(void 0,l,f,g)}else return n(l,u,f,g)}function i(l,u){if(!a.isUndefined(u))return n(void 0,u)}function o(l,u){if(a.isUndefined(u)){if(!a.isUndefined(l))return n(void 0,l)}else return n(void 0,u)}function c(l,u,f){if(f in e)return n(l,u);if(f in t)return n(void 0,l)}const d={url:i,method:i,data:i,baseURL:o,transformRequest:o,transformResponse:o,paramsSerializer:o,timeout:o,timeoutMessage:o,withCredentials:o,withXSRFToken:o,adapter:o,responseType:o,xsrfCookieName:o,xsrfHeaderName:o,onUploadProgress:o,onDownloadProgress:o,decompress:o,maxContentLength:o,maxBodyLength:o,beforeRedirect:o,transport:o,httpAgent:o,httpsAgent:o,cancelToken:o,socketPath:o,responseEncoding:o,validateStatus:c,headers:(l,u,f)=>s(lt(l),lt(u),f,!0)};return a.forEach(Object.keys({...t,...e}),function(u){const f=d[u]||s,g=f(t[u],e[u],u);a.isUndefined(g)&&f!==c||(r[u]=g)}),r}const dt=t=>{const e=I({},t);let{data:r,withXSRFToken:n,xsrfHeaderName:s,xsrfCookieName:i,headers:o,auth:c}=e;e.headers=o=N.from(o),e.url=et(ut(e.baseURL,e.url,e.allowAbsoluteUrls),t.params,t.paramsSerializer),c&&o.set("Authorization","Basic "+btoa((c.username||"")+":"+(c.password?unescape(encodeURIComponent(c.password)):"")));let d;if(a.isFormData(r)){if(A.hasStandardBrowserEnv||A.hasStandardBrowserWebWorkerEnv)o.setContentType(void 0);else if((d=o.getContentType())!==!1){const[l,...u]=d?d.split(";").map(f=>f.trim()).filter(Boolean):[];o.setContentType([l||"multipart/form-data",...u].join("; "))}}if(A.hasStandardBrowserEnv&&(n&&a.isFunction(n)&&(n=n(e)),n||n!==!1&&qr(e.url))){const l=s&&i&&vr.read(i);l&&o.set(s,l)}return e},$r=typeof XMLHttpRequest<"u"&&function(t){return new Promise(function(r,n){const s=dt(t);let i=s.data;const o=N.from(s.headers).normalize();let{responseType:c,onUploadProgress:d,onDownloadProgress:l}=s,u,f,g,b,h;function y(){b&&b(),h&&h(),s.cancelToken&&s.cancelToken.unsubscribe(u),s.signal&&s.signal.removeEventListener("abort",u)}let p=new XMLHttpRequest;p.open(s.method.toUpperCase(),s.url,!0),p.timeout=s.timeout;function S(){if(!p)return;const R=N.from("getAllResponseHeaders"in p&&p.getAllResponseHeaders()),x={data:!c||c==="text"||c==="json"?p.responseText:p.response,status:p.status,statusText:p.statusText,headers:R,config:t,request:p};ot(function(M){r(M),y()},function(M){n(M),y()},x),p=null}"onloadend"in p?p.onloadend=S:p.onreadystatechange=function(){!p||p.readyState!==4||p.status===0&&!(p.responseURL&&p.responseURL.indexOf("file:")===0)||setTimeout(S)},p.onabort=function(){p&&(n(new m("Request aborted",m.ECONNABORTED,t,p)),p=null)},p.onerror=function(){n(new m("Network Error",m.ERR_NETWORK,t,p)),p=null},p.ontimeout=function(){let k=s.timeout?"timeout of "+s.timeout+"ms exceeded":"timeout exceeded";const x=s.transitional||rt;s.timeoutErrorMessage&&(k=s.timeoutErrorMessage),n(new m(k,x.clarifyTimeoutError?m.ETIMEDOUT:m.ECONNABORTED,t,p)),p=null},i===void 0&&o.setContentType(null),"setRequestHeader"in p&&a.forEach(o.toJSON(),function(k,x){p.setRequestHeader(x,k)}),a.isUndefined(s.withCredentials)||(p.withCredentials=!!s.withCredentials),c&&c!=="json"&&(p.responseType=s.responseType),l&&([g,h]=ce(l,!0),p.addEventListener("progress",g)),d&&p.upload&&([f,b]=ce(d),p.upload.addEventListener("progress",f),p.upload.addEventListener("loadend",b)),(s.cancelToken||s.signal)&&(u=R=>{p&&(n(!R||R.type?new K(null,t,p):R),p.abort(),p=null)},s.cancelToken&&s.cancelToken.subscribe(u),s.signal&&(s.signal.aborted?u():s.signal.addEventListener("abort",u)));const C=Fr(s.url);if(C&&A.protocols.indexOf(C)===-1){n(new m("Unsupported protocol "+C+":",m.ERR_BAD_REQUEST,t));return}p.send(i||null)})},Mr=(t,e)=>{const{length:r}=t=t?t.filter(Boolean):[];if(e||r){let n=new AbortController,s;const i=function(l){if(!s){s=!0,c();const u=l instanceof Error?l:this.reason;n.abort(u instanceof m?u:new K(u instanceof Error?u.message:u))}};let o=e&&setTimeout(()=>{o=null,i(new m(`timeout ${e} of ms exceeded`,m.ETIMEDOUT))},e);const c=()=>{t&&(o&&clearTimeout(o),o=null,t.forEach(l=>{l.unsubscribe?l.unsubscribe(i):l.removeEventListener("abort",i)}),t=null)};t.forEach(l=>l.addEventListener("abort",i));const{signal:d}=n;return d.unsubscribe=()=>a.asap(c),d}},Hr=function*(t,e){let r=t.byteLength;if(r<e){yield t;return}let n=0,s;for(;n<r;)s=n+e,yield t.slice(n,s),n=s},Vr=async function*(t,e){for await(const r of Kr(t))yield*Hr(r,e)},Kr=async function*(t){if(t[Symbol.asyncIterator]){yield*t;return}const e=t.getReader();try{for(;;){const{done:r,value:n}=await e.read();if(r)break;yield n}}finally{await e.cancel()}},ft=(t,e,r,n)=>{const s=Vr(t,e);let i=0,o,c=d=>{o||(o=!0,n&&n(d))};return new ReadableStream({async pull(d){try{const{done:l,value:u}=await s.next();if(l){c(),d.close();return}let f=u.byteLength;if(r){let g=i+=f;r(g)}d.enqueue(new Uint8Array(u))}catch(l){throw c(l),l}},cancel(d){return c(d),s.return()}},{highWaterMark:2})},ue=typeof fetch=="function"&&typeof Request=="function"&&typeof Response=="function",ht=ue&&typeof ReadableStream=="function",zr=ue&&(typeof TextEncoder=="function"?(t=>e=>t.encode(e))(new TextEncoder):async t=>new Uint8Array(await new Response(t).arrayBuffer())),pt=(t,...e)=>{try{return!!t(...e)}catch{return!1}},Jr=ht&&pt(()=>{let t=!1;const e=new Request(A.origin,{body:new ReadableStream,method:"POST",get duplex(){return t=!0,"half"}}).headers.has("Content-Type");return t&&!e}),mt=64*1024,Ce=ht&&pt(()=>a.isReadableStream(new Response("").body)),le={stream:Ce&&(t=>t.body)};ue&&(t=>{["text","arrayBuffer","blob","formData","stream"].forEach(e=>{!le[e]&&(le[e]=a.isFunction(t[e])?r=>r[e]():(r,n)=>{throw new m(`Response type '${e}' is not supported`,m.ERR_NOT_SUPPORT,n)})})})(new Response);const Wr=async t=>{if(t==null)return 0;if(a.isBlob(t))return t.size;if(a.isSpecCompliantForm(t))return(await new Request(A.origin,{method:"POST",body:t}).arrayBuffer()).byteLength;if(a.isArrayBufferView(t)||a.isArrayBuffer(t))return t.byteLength;if(a.isURLSearchParams(t)&&(t=t+""),a.isString(t))return(await zr(t)).byteLength},Xr=async(t,e)=>{const r=a.toFiniteNumber(t.getContentLength());return r??Wr(e)},Re={http:yr,xhr:$r,fetch:ue&&(async t=>{let{url:e,method:r,data:n,signal:s,cancelToken:i,timeout:o,onDownloadProgress:c,onUploadProgress:d,responseType:l,headers:u,withCredentials:f="same-origin",fetchOptions:g}=dt(t);l=l?(l+"").toLowerCase():"text";let b=Mr([s,i&&i.toAbortSignal()],o),h;const y=b&&b.unsubscribe&&(()=>{b.unsubscribe()});let p;try{if(d&&Jr&&r!=="get"&&r!=="head"&&(p=await Xr(u,n))!==0){let x=new Request(e,{method:"POST",body:n,duplex:"half"}),q;if(a.isFormData(n)&&(q=x.headers.get("content-type"))&&u.setContentType(q),x.body){const[M,pe]=at(p,ce(ct(d)));n=ft(x.body,mt,M,pe)}}a.isString(f)||(f=f?"include":"omit");const S="credentials"in Request.prototype;h=new Request(e,{...g,signal:b,method:r.toUpperCase(),headers:u.normalize().toJSON(),body:n,duplex:"half",credentials:S?f:void 0});let C=await fetch(h,g);const R=Ce&&(l==="stream"||l==="response");if(Ce&&(c||R&&y)){const x={};["status","statusText","headers"].forEach(xt=>{x[xt]=C[xt]});const q=a.toFiniteNumber(C.headers.get("content-length")),[M,pe]=c&&at(q,ce(ct(c),!0))||[];C=new Response(ft(C.body,mt,M,()=>{pe&&pe(),y&&y()}),x)}l=l||"text";let k=await le[a.findKey(le,l)||"text"](C,t);return!R&&y&&y(),await new Promise((x,q)=>{ot(x,q,{data:k,headers:N.from(C.headers),status:C.status,statusText:C.statusText,config:t,request:h})})}catch(S){throw y&&y(),S&&S.name==="TypeError"&&/Load failed|fetch/i.test(S.message)?Object.assign(new m("Network Error",m.ERR_NETWORK,t,h),{cause:S.cause||S}):m.from(S,S&&S.code,t,h)}})};a.forEach(Re,(t,e)=>{if(t){try{Object.defineProperty(t,"name",{value:e})}catch{}Object.defineProperty(t,"adapterName",{value:e})}});const yt=t=>`- ${t}`,Qr=t=>a.isFunction(t)||t===null||t===!1,gt={getAdapter:t=>{t=a.isArray(t)?t:[t];const{length:e}=t;let r,n;const s={};for(let i=0;i<e;i++){r=t[i];let o;if(n=r,!Qr(r)&&(n=Re[(o=String(r)).toLowerCase()],n===void 0))throw new m(`Unknown adapter '${o}'`);if(n)break;s[o||"#"+i]=n}if(!n){const i=Object.entries(s).map(([c,d])=>`adapter ${c} `+(d===!1?"is not supported by the environment":"is not available in the build"));let o=e?i.length>1?`since :
4
4
  `+i.map(yt).join(`
5
5
  `):" "+yt(i[0]):"as no adapter specified";throw new m("There is no suitable adapter to dispatch the request "+o,"ERR_NOT_SUPPORT")}return n},adapters:Re};function Te(t){if(t.cancelToken&&t.cancelToken.throwIfRequested(),t.signal&&t.signal.aborted)throw new K(null,t)}function wt(t){return Te(t),t.headers=N.from(t.headers),t.data=Se.call(t,t.transformRequest),["post","put","patch"].indexOf(t.method)!==-1&&t.headers.setContentType("application/x-www-form-urlencoded",!1),gt.getAdapter(t.adapter||Z.adapter)(t).then(function(n){return Te(t),n.data=Se.call(t,t.transformResponse,n),n.headers=N.from(n.headers),n},function(n){return it(n)||(Te(t),n&&n.response&&(n.response.data=Se.call(t,t.transformResponse,n.response),n.response.headers=N.from(n.response.headers))),Promise.reject(n)})}const bt="1.11.0",de={};["object","boolean","number","function","string","symbol"].forEach((t,e)=>{de[t]=function(n){return typeof n===t||"a"+(e<1?"n ":" ")+t}});const _t={};de.transitional=function(e,r,n){function s(i,o){return"[Axios v"+bt+"] Transitional option '"+i+"'"+o+(n?". "+n:"")}return(i,o,c)=>{if(e===!1)throw new m(s(o," has been removed"+(r?" in "+r:"")),m.ERR_DEPRECATED);return r&&!_t[o]&&(_t[o]=!0,console.warn(s(o," has been deprecated since v"+r+" and will be removed in the near future"))),e?e(i,o,c):!0}},de.spelling=function(e){return(r,n)=>(console.warn(`${n} is likely a misspelling of ${e}`),!0)};function Yr(t,e,r){if(typeof t!="object")throw new m("options must be an object",m.ERR_BAD_OPTION_VALUE);const n=Object.keys(t);let s=n.length;for(;s-- >0;){const i=n[s],o=e[i];if(o){const c=t[i],d=c===void 0||o(c,i,t);if(d!==!0)throw new m("option "+i+" must be "+d,m.ERR_BAD_OPTION_VALUE);continue}if(r!==!0)throw new m("Unknown option "+i,m.ERR_BAD_OPTION)}}const fe={assertOptions:Yr,validators:de},D=fe.validators;let j=class{constructor(e){this.defaults=e||{},this.interceptors={request:new tt,response:new tt}}async request(e,r){try{return await this._request(e,r)}catch(n){if(n instanceof Error){let s={};Error.captureStackTrace?Error.captureStackTrace(s):s=new Error;const i=s.stack?s.stack.replace(/^.+\n/,""):"";try{n.stack?i&&!String(n.stack).endsWith(i.replace(/^.+\n.+\n/,""))&&(n.stack+=`
6
- `+i):n.stack=i}catch{}}throw n}}_request(e,r){typeof e=="string"?(r=r||{},r.url=e):r=e||{},r=I(this.defaults,r);const{transitional:n,paramsSerializer:s,headers:i}=r;n!==void 0&&fe.assertOptions(n,{silentJSONParsing:D.transitional(D.boolean),forcedJSONParsing:D.transitional(D.boolean),clarifyTimeoutError:D.transitional(D.boolean)},!1),s!=null&&(a.isFunction(s)?r.paramsSerializer={serialize:s}:fe.assertOptions(s,{encode:D.function,serialize:D.function},!0)),r.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?r.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:r.allowAbsoluteUrls=!0),fe.assertOptions(r,{baseUrl:D.spelling("baseURL"),withXsrfToken:D.spelling("withXSRFToken")},!0),r.method=(r.method||this.defaults.method||"get").toLowerCase();let o=i&&a.merge(i.common,i[r.method]);i&&a.forEach(["delete","get","head","post","put","patch","common"],h=>{delete i[h]}),r.headers=N.concat(o,i);const c=[];let d=!0;this.interceptors.request.forEach(function(y){typeof y.runWhen=="function"&&y.runWhen(r)===!1||(d=d&&y.synchronous,c.unshift(y.fulfilled,y.rejected))});const l=[];this.interceptors.response.forEach(function(y){l.push(y.fulfilled,y.rejected)});let u,f=0,g;if(!d){const h=[wt.bind(this),void 0];for(h.unshift(...c),h.push(...l),g=h.length,u=Promise.resolve(r);f<g;)u=u.then(h[f++],h[f++]);return u}g=c.length;let b=r;for(f=0;f<g;){const h=c[f++],y=c[f++];try{b=h(b)}catch(p){y.call(this,p);break}}try{u=wt.call(this,b)}catch(h){return Promise.reject(h)}for(f=0,g=l.length;f<g;)u=u.then(l[f++],l[f++]);return u}getUri(e){e=I(this.defaults,e);const r=ut(e.baseURL,e.url,e.allowAbsoluteUrls);return et(r,e.params,e.paramsSerializer)}};a.forEach(["delete","get","head","options"],function(e){j.prototype[e]=function(r,n){return this.request(I(n||{},{method:e,url:r,data:(n||{}).data}))}}),a.forEach(["post","put","patch"],function(e){function r(n){return function(i,o,c){return this.request(I(c||{},{method:e,headers:n?{"Content-Type":"multipart/form-data"}:{},url:i,data:o}))}}j.prototype[e]=r(),j.prototype[e+"Form"]=r(!0)});let Gr=class Ut{constructor(e){if(typeof e!="function")throw new TypeError("executor must be a function.");let r;this.promise=new Promise(function(i){r=i});const n=this;this.promise.then(s=>{if(!n._listeners)return;let i=n._listeners.length;for(;i-- >0;)n._listeners[i](s);n._listeners=null}),this.promise.then=s=>{let i;const o=new Promise(c=>{n.subscribe(c),i=c}).then(s);return o.cancel=function(){n.unsubscribe(i)},o},e(function(i,o,c){n.reason||(n.reason=new K(i,o,c),r(n.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(e){if(this.reason){e(this.reason);return}this._listeners?this._listeners.push(e):this._listeners=[e]}unsubscribe(e){if(!this._listeners)return;const r=this._listeners.indexOf(e);r!==-1&&this._listeners.splice(r,1)}toAbortSignal(){const e=new AbortController,r=n=>{e.abort(n)};return this.subscribe(r),e.signal.unsubscribe=()=>this.unsubscribe(r),e.signal}static source(){let e;return{token:new Ut(function(s){e=s}),cancel:e}}};function Zr(t){return function(r){return t.apply(null,r)}}function en(t){return a.isObject(t)&&t.isAxiosError===!0}const Ae={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(Ae).forEach(([t,e])=>{Ae[e]=t});function Et(t){const e=new j(t),r=Ie(j.prototype.request,e);return a.extend(r,j.prototype,e,{allOwnKeys:!0}),a.extend(r,e,null,{allOwnKeys:!0}),r.create=function(s){return Et(I(t,s))},r}const E=Et(Z);E.Axios=j,E.CanceledError=K,E.CancelToken=Gr,E.isCancel=it,E.VERSION=bt,E.toFormData=oe,E.AxiosError=m,E.Cancel=E.CanceledError,E.all=function(e){return Promise.all(e)},E.spread=Zr,E.isAxiosError=en,E.mergeConfig=I,E.AxiosHeaders=N,E.formToJSON=t=>nt(a.isHTMLForm(t)?new FormData(t):t),E.getAdapter=gt.getAdapter,E.HttpStatusCode=Ae,E.default=E;const{Axios:_s,AxiosError:Pe,CanceledError:Es,isCancel:Ss,CancelToken:Cs,VERSION:Rs,all:Ts,Cancel:As,isAxiosError:Ps,spread:Os,toFormData:Ns,AxiosHeaders:xs,HttpStatusCode:Us,formToJSON:Ls,getAdapter:Ds,mergeConfig:Fs}=E;class Oe extends Error{constructor(r){super(r.join(", "));_(this,"errors");this.name="ValidationError",this.errors=r}}class Ne extends Error{constructor(r){super("Address already registered.");_(this,"address");this.name="AddressInUseError",this.address=r}}class xe extends Error{constructor(r){super("Code already registered.");_(this,"code");this.name="CodeInUseError",this.code=r}}class Ue extends Error{constructor(){super("Invalid signature provided"),this.name="InvalidSignatureError"}}class tn{constructor(e){_(this,"httpClient");_(this,"_debug");this.httpClient=e.httpClient,this._debug=e.debug}async create(e,r,n,s,i,o,c){var d;try{await this.httpClient.post({path:"/affiliates",postData:{address:e,identifier_type:r,name:n,code:n,signature:s,signature_public_key:i,account_chain_id:o,user_rebate_rate:c}})}catch(l){if(l instanceof Pe){const u=(d=l.response)==null?void 0:d.data;if(typeof(u==null?void 0:u.message)=="string"){const f=u.message.toLowerCase();throw f=="invalid signature"?new Ue:f=="address in use"?new Ne(e):f=="code in use"?new xe(n):new Error(f)}else if((u==null?void 0:u.message)instanceof Array)throw new Oe(u.message)}throw l}}async update(e,r,n,s,i,o,c){var d;try{await this.httpClient.post({path:`/affiliates/${e}`,postData:{code:n,user_identifier:e,identifier_type:r,signature:s,signature_public_key:i,account_chain_id:o,user_rebate_rate:c}})}catch(l){if(l instanceof Pe){const u=(d=l.response)==null?void 0:d.data;if(typeof(u==null?void 0:u.message)=="string"){const f=u.message.toLowerCase();throw f=="invalid signature"?new Ue:f=="address in use"?new Ne(e):f=="code in use"?new xe(n):new Error(f)}else if((u==null?void 0:u.message)instanceof Array)throw new Oe(u.message)}throw l}}async isCodeFree(e){try{return(await this.httpClient.get({path:`/affiliates/codes/${e}`})).data.available}catch(r){throw console.error("Fuul SDK: Could not check affiliate code",r),r}}async getCode(e,r){var n;try{return(await this.httpClient.get({path:`/affiliates/${e}`,queryParams:{identifier_type:r}})).data}catch(s){if(s instanceof Pe&&((n=s.response)==null?void 0:n.status)===404)return null;throw console.error("Fuul SDK: Could not get affiliate code",s),s}}}const rn="/audiences";class nn{constructor(e){_(this,"httpClient");_(this,"_debug");this.httpClient=e.httpClient,this._debug=e.debug}async getUserAudiences(e){return(await this.httpClient.get({path:`${rn}/audience-segments/user`,queryParams:{...e}})).data}}const St="/claim-checks";class sn{constructor(e){_(this,"httpClient");_(this,"_debug");this.httpClient=e.httpClient,this._debug=e.debug}async getClaimableChecks(e){return(await this.httpClient.post({path:`${St}/claim`,postData:{userIdentifier:e.user_identifier,userIdentifierType:e.user_identifier_type}})).data}async getClaimCheckTotals(e){return(await this.httpClient.get({path:`${St}/totals`,queryParams:{user_identifier:e.user_identifier,user_identifier_type:e.user_identifier_type}})).data}}class on{constructor(e){_(this,"httpClient");this.httpClient=e.httpClient}async getAll(e){const{data:r}=await this.httpClient.get({path:"conversions",queryParams:{...e}});return r}}const Ct="fuul.sent",an=60,cn="connect_wallet",Rt=10;class un{constructor(e){_(this,"debug");_(this,"httpClient");this.httpClient=e.httpClient,this.debug=!!e.debug}async sendEvent(e,r){if(this.isDuplicate(e)){this.debug&&console.debug("Fuul SDK: Event is considered duplicate and will not be sent");return}if(!r||!Array.isArray(r)||r.length===0)await this.httpClient.post({path:"events",postData:e});else for(const n of r){const s=structuredClone({...e,project_id:n});s.metadata.project_id=n,await this.httpClient.post({path:"events",postData:s,queryParams:{project_id:n}})}this.debug&&console.debug(`Fuul SDK: Sent '${e.name}' event`),this.saveSentEvent(e)}isDuplicate(e){var u,f,g,b;const r=`${Ct}_${e.name}`,n=localStorage.getItem(r);if(!n)return!1;const s=JSON.parse(n);if(this.getCurrentTimestamp()-s.timestamp>an)return!1;let d=!1;e.metadata&&(d=s.metadata.tracking_id===e.metadata.tracking_id&&s.metadata.project_id===e.metadata.project_id&&s.metadata.referrer===e.metadata.referrer&&s.metadata.source===e.metadata.source&&s.metadata.category===e.metadata.category&&s.metadata.title===e.metadata.title&&s.metadata.tag===e.metadata.tag&&s.user_address===e.user_address&&((u=s.user)==null?void 0:u.identifier)===((f=e.user)==null?void 0:f.identifier)&&((g=s.user)==null?void 0:g.identifier_type)===((b=e.user)==null?void 0:b.identifier_type)&&s.signature===e.signature&&s.signature_message===e.signature_message);let l=!1;return e.args&&s.args&&(l=s.args.page===e.args.page),l&&d}getCurrentTimestamp(){return Date.now()/1e3}saveSentEvent(e){var o,c,d,l;const r=`${Ct}_${e.name}`,n=`${r}_all`,s=this.getCurrentTimestamp(),i={...e,timestamp:s};if(localStorage.setItem(r,JSON.stringify(i)),e.name===cn){const u=JSON.parse(localStorage.getItem(n)||"[]"),f={name:e.name,user:{identifier:(o=e.user)==null?void 0:o.identifier,identifier_type:(c=e.user)==null?void 0:c.identifier_type},tracking_id:(d=e.metadata)==null?void 0:d.tracking_id,page:(l=e.args)==null?void 0:l.page};"user_address"in e&&(f.user_address=e.user_address);const g=[...u,f];g.length>Rt&&g.splice(0,g.length-Rt),localStorage.setItem(n,JSON.stringify(g))}}}const ln={version:"7.12.0"};class dn{constructor(e){_(this,"client");_(this,"defaultQueryParams");this.client=E.create({...e,headers:{Authorization:`Bearer ${e.apiKey}`,"X-Fuul-Sdk-Version":ln.version}}),this.defaultQueryParams=e.queryParams||{}}makeQueryParams(e){return Object.assign({},this.defaultQueryParams||{},e||{})}async get(e){return this.client.request({url:e.path,params:this.makeQueryParams(e.queryParams),method:"GET"})}async post(e){return this.client.request({url:e.path,params:this.makeQueryParams(e.queryParams),data:e.postData,method:"POST"})}async put(e){return this.client.request({url:e.path,params:this.makeQueryParams(e.queryParams),data:e.postData,method:"PUT"})}async patch(e){return this.client.request({url:e.path,params:this.makeQueryParams(e.queryParams),data:e.postData,method:"PATCH"})}async delete(e){return this.client.request({url:e.path,params:this.makeQueryParams(e.queryParams),data:e.postData,method:"DELETE"})}}class fn{constructor(e){_(this,"httpClient");this.httpClient=e.httpClient}async getPayoutsLeaderboard(e){const{identifier_type:r,user_identifier_type:n,...s}=e,i={...s,user_identifier_type:r??n};return(await this.httpClient.get({path:"/payouts/leaderboard/payouts",queryParams:i})).data}async getPointsLeaderboard(e){const{identifier_type:r,user_identifier_type:n,...s}=e,i={...s,user_identifier_type:r??n};return(await this.httpClient.get({path:"/payouts/leaderboard/points",queryParams:i})).data}async getVolumeLeaderboard(e){const{identifier_type:r,user_identifier_type:n,...s}=e,i={...s,identifier_type:r??n};return(await this.httpClient.get({path:"/payouts/leaderboard/volume",queryParams:i})).data}async getReferredUsersLeaderboard(e){return(await this.httpClient.get({path:"/leaderboard/referred",queryParams:{...e}})).data}async getReferredVolume(e){const{user_identifiers:r,...n}=e;return(await this.httpClient.get({path:"/payouts/leaderboard/referred-volume",queryParams:{...n,user_identifiers:r.join(",")}})).data}async getRevenueLeaderboard(e){const{identifier_type:r,user_identifier_type:n,...s}=e,i={...s,identifier_type:r??n};return(await this.httpClient.get({path:"/payouts/leaderboard/revenue",queryParams:i})).data}}const te="/payouts";class hn{constructor(e){_(this,"httpClient");_(this,"_debug");this.httpClient=e.httpClient,this._debug=e.debug}async getUserPayoutsByConversion(e){return(await this.httpClient.get({path:te,queryParams:{...e,type:"onchain-currency"}})).data}async getUserPointsByConversion(e){return(await this.httpClient.get({path:te,queryParams:{...e,type:"point"}})).data}async getUserPayoutMovements(e){return(await this.httpClient.get({path:`${te}/movements`,queryParams:{...e,type:"onchain-currency"}})).data}async getUserPointsMovements(e){return(await this.httpClient.get({path:`${te}/movements`,queryParams:{...e,type:"point"}})).data}async getPayoutsByReferrer(e){return(await this.httpClient.get({path:`${te}/by-referrer`,queryParams:{user_identifier:e.user_identifier,user_identifier_type:e.user_identifier_type}})).data}}class pn{constructor(e){_(this,"httpClient");_(this,"_debug");this.httpClient=e.httpClient,this._debug=e.debug}async listUserReferralCodes(e){return(await this.httpClient.get({path:"/referral_codes",queryParams:{user_identifier:e.user_identifier,user_identifier_type:e.user_identifier_type,page:e.page,page_size:e.page_size}})).data}async generateReferralCodes(e){return(await this.httpClient.post({path:"/referral_codes",queryParams:{user_identifier:e.user_identifier,user_identifier_type:e.user_identifier_type,quantity:e.quantity,max_uses:e.max_uses}})).data}async getReferralStatus(e){return(await this.httpClient.get({path:"/referral_codes/status",queryParams:{user_identifier:e.user_identifier,user_identifier_type:e.user_identifier_type}})).data}async getReferralCode(e){return(await this.httpClient.get({path:`/referral_codes/${e.code}`})).data}async useReferralCode(e){const{code:r,user_identifier:n,user_identifier_type:s,signature:i,signature_message:o,chain_id:c,account_chain_id:d}=e;await this.httpClient.patch({path:`/referral_codes/${r}/use`,queryParams:{user_identifier:n,user_identifier_type:s,chain_id:c,account_chain_id:d},postData:{signature:i,signature_message:o}})}async updateReferralCode(e){await this.httpClient.patch({path:`/referral_codes/${e.code}`,postData:{max_uses:e.max_uses}})}async deleteReferral(e){const{code:r,user_identifier:n,user_identifier_type:s,referrer_identifier:i,referrer_identifier_type:o,signature:c,signature_message:d,chain_id:l}=e;await this.httpClient.delete({path:`/referral_codes/${r}/referrals`,queryParams:{user_identifier:n,user_identifier_type:s,referrer_identifier:i,referrer_identifier_type:o},postData:{signature:c,signature_message:d,chain_id:l}})}}const mn="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let yn=(t=21)=>{let e="",r=crypto.getRandomValues(new Uint8Array(t|=0));for(;t--;)e+=mn[r[t]&63];return e};const gn="fuul.tracking_id",Le=()=>Cn(gn,()=>yn()),Tt=()=>z("af")||z("referrer"),wn=()=>document.referrer,bn=()=>Rn(),_n=()=>z("category"),En=()=>z("title"),Sn=()=>z("tag"),Cn=(t,e)=>{const r=localStorage.getItem(t);if(r)return r;{const n=e();return n?localStorage.setItem(t,n):localStorage.removeItem(t),n}},z=t=>new URLSearchParams(window.location.search).get(t),Rn=()=>{const t=z("source");if(t)return t},Tn="/user";class An{constructor(e){_(this,"httpClient");this.httpClient=e.httpClient}async getUserReferrer(e){return(await this.httpClient.get({path:`${Tn}/referrer`,queryParams:{...e}})).data}}const Pn="https://api.fuul.xyz/api/v1/";let F=!1,De=!1,Fe,L,At,Pt,J,ke,he,W,Ot,$,B,Be;function On(t){F=!!t.debug,!De&&(Fe=t.apiKey,cs(),L=us(t.baseApiUrl??Pn,t.defaultQueryParams??{}),At=new on({httpClient:L,debug:F}),he=new un({httpClient:L,debug:F}),J=new tn({httpClient:L,debug:F}),ke=new H({httpClient:L}),W=new hn({httpClient:L,debug:F}),Pt=new An({httpClient:L}),Ot=new nn({httpClient:L,debug:F}),$=new fn({httpClient:L}),B=new pn({httpClient:L,debug:F}),Be=new sn({httpClient:L,debug:F}),De=!0,F&&console.debug("Fuul SDK: init() complete"))}function w(){if(!De)throw new Error("Fuul SDK: You need to call init() to initialize the library before using any methods")}async function Nn(t,e){w(),qe(),ve();const r={name:t,args:e??{},metadata:{tracking_id:Le()}};await he.sendEvent(r)}async function xn(t,e){w(),qe(),ve();const r={name:"pageview",args:{page:t??document.location.pathname,locationOrigin:document.location.origin},metadata:{tracking_id:Le(),referrer_url:wn(),source:bn(),affiliate_id:Tt()??void 0,referrer:Tt()??void 0,category:_n()??void 0,title:En()??void 0,tag:Sn()??void 0}};await he.sendEvent(r,e)}async function Un(t,e){w(),qe(),ve();const r={name:"connect_wallet",user:{identifier:t.identifier,identifier_type:t.identifierType},args:{page:document.location.pathname,locationOrigin:document.location.origin},metadata:{tracking_id:Le()}};t!=null&&t.signature&&(r.signature=t==null?void 0:t.signature,r.signature_message=t==null?void 0:t.message),t!=null&&t.signaturePublicKey&&(r.signature_public_key=t.signaturePublicKey),t!=null&&t.accountChainId&&(r.account_chain_id=t.accountChainId),await he.sendEvent(r,e)}async function Ln(t){w(),await J.create(t.userIdentifier,t.identifierType,t.code,t.signature,t.signaturePublicKey,t.accountChainId,t.userRebateRate)}async function Dn(t){w(),await J.update(t.userIdentifier,t.identifierType,t.code,t.signature,t.signaturePublicKey,t.accountChainId,t.userRebateRate)}async function Fn(t,e){return w(),await J.getCode(t,e)}async function kn(t){return w(),await J.isCodeFree(t)}async function Bn(t,e,r,n){w();const s=await J.getCode(e,r),i=new URLSearchParams({af:(s==null?void 0:s.code)??e});return n!=null&&n.title&&i.append("af_title",n.title),n!=null&&n.format&&i.append("af_format",n.format),n!=null&&n.place&&i.append("af_place",n.place),`${t}?${i.toString()}`}function qn(t){return $.getPayoutsLeaderboard(t)}function vn(t){return $.getPointsLeaderboard(t)}function In(t){return $.getReferredUsersLeaderboard(t)}function jn(t){return w(),$.getReferredVolume(t)}function $n(t){return w(),$.getVolumeLeaderboard(t)}function Mn(t){return w(),$.getRevenueLeaderboard(t)}function Hn(t){return W.getUserPayoutsByConversion(t)}function Vn(t){return W.getUserPointsByConversion(t)}function Kn(t){return W.getUserPayoutMovements(t)}function zn(t){return W.getUserPointsMovements(t)}function Jn(t){return w(),W.getPayoutsByReferrer(t)}async function Wn(t){return w(),At.getAll(t)}async function Xn(t){return w(),Pt.getUserReferrer(t)}async function Qn(t){return w(),Ot.getUserAudiences(t)}async function Yn(t){return w(),B.listUserReferralCodes(t)}async function Gn(t){return w(),B.generateReferralCodes(t)}async function Zn(t){return w(),B.getReferralStatus(t)}async function es(t){return w(),B.getReferralCode(t)}async function ts(t){return w(),B.useReferralCode(t)}async function rs(t){return w(),B.updateReferralCode(t)}async function ns(t){return w(),B.deleteReferral(t)}async function ss(t){return w(),ke.getAffiliateStats(t)}async function is(t){return w(),ke.getAffiliateNewTraders(t)}async function os(t){return w(),Be.getClaimableChecks(t)}async function as(t){return w(),Be.getClaimCheckTotals(t)}function qe(){if(typeof window>"u"||typeof document>"u")throw new Error("Fuul SDK: Browser context required")}function ve(){if(navigator.webdriver)throw new Error("Fuul SDK: Error")}function cs(){if(!Fe)throw new Error("Fuul SDK: Invalid API key")}function us(t,e){return new dn({baseURL:t,timeout:3e4,apiKey:Fe,queryParams:e})}const ls={init:On,sendEvent:Nn,sendPageview:xn,identifyUser:Un,generateTrackingLink:Bn,getConversions:Wn,createAffiliateCode:Ln,updateAffiliateCode:Dn,getAffiliateCode:Fn,isAffiliateCodeFree:kn,getPayoutsLeaderboard:qn,getPointsLeaderboard:vn,getReferredUsersLeaderboard:In,getReferredVolume:jn,getUserAudiences:Qn,getUserPayoutsByConversion:Hn,getUserPointsByConversion:Vn,getUserPointsMovements:zn,getUserPayoutMovements:Kn,getPayoutsByReferrer:Jn,getUserReferrer:Xn,getVolumeLeaderboard:$n,getRevenueLeaderboard:Mn,listUserReferralCodes:Yn,generateReferralCodes:Gn,getReferralStatus:Zn,getReferralCode:es,useReferralCode:ts,updateReferralCode:rs,deleteReferral:ns,getAffiliateStats:ss,getAffiliateNewTraders:is,getClaimableChecks:os,getClaimCheckTotals:as};var Nt=(t=>(t.EvmAddress="evm_address",t.SolanaAddress="solana_address",t.XRPLAddress="xrpl_address",t.SuiAddress="sui_address",t.Email="email",t))(Nt||{});T.AddressInUseError=Ne,T.CodeInUseError=xe,T.Fuul=ls,T.InvalidSignatureError=Ue,T.UserIdentifierType=Nt,T.ValidationError=Oe,Object.defineProperty(T,Symbol.toStringTag,{value:"Module"})});
6
+ `+i):n.stack=i}catch{}}throw n}}_request(e,r){typeof e=="string"?(r=r||{},r.url=e):r=e||{},r=I(this.defaults,r);const{transitional:n,paramsSerializer:s,headers:i}=r;n!==void 0&&fe.assertOptions(n,{silentJSONParsing:D.transitional(D.boolean),forcedJSONParsing:D.transitional(D.boolean),clarifyTimeoutError:D.transitional(D.boolean)},!1),s!=null&&(a.isFunction(s)?r.paramsSerializer={serialize:s}:fe.assertOptions(s,{encode:D.function,serialize:D.function},!0)),r.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?r.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:r.allowAbsoluteUrls=!0),fe.assertOptions(r,{baseUrl:D.spelling("baseURL"),withXsrfToken:D.spelling("withXSRFToken")},!0),r.method=(r.method||this.defaults.method||"get").toLowerCase();let o=i&&a.merge(i.common,i[r.method]);i&&a.forEach(["delete","get","head","post","put","patch","common"],h=>{delete i[h]}),r.headers=N.concat(o,i);const c=[];let d=!0;this.interceptors.request.forEach(function(y){typeof y.runWhen=="function"&&y.runWhen(r)===!1||(d=d&&y.synchronous,c.unshift(y.fulfilled,y.rejected))});const l=[];this.interceptors.response.forEach(function(y){l.push(y.fulfilled,y.rejected)});let u,f=0,g;if(!d){const h=[wt.bind(this),void 0];for(h.unshift(...c),h.push(...l),g=h.length,u=Promise.resolve(r);f<g;)u=u.then(h[f++],h[f++]);return u}g=c.length;let b=r;for(f=0;f<g;){const h=c[f++],y=c[f++];try{b=h(b)}catch(p){y.call(this,p);break}}try{u=wt.call(this,b)}catch(h){return Promise.reject(h)}for(f=0,g=l.length;f<g;)u=u.then(l[f++],l[f++]);return u}getUri(e){e=I(this.defaults,e);const r=ut(e.baseURL,e.url,e.allowAbsoluteUrls);return et(r,e.params,e.paramsSerializer)}};a.forEach(["delete","get","head","options"],function(e){j.prototype[e]=function(r,n){return this.request(I(n||{},{method:e,url:r,data:(n||{}).data}))}}),a.forEach(["post","put","patch"],function(e){function r(n){return function(i,o,c){return this.request(I(c||{},{method:e,headers:n?{"Content-Type":"multipart/form-data"}:{},url:i,data:o}))}}j.prototype[e]=r(),j.prototype[e+"Form"]=r(!0)});let Gr=class Ut{constructor(e){if(typeof e!="function")throw new TypeError("executor must be a function.");let r;this.promise=new Promise(function(i){r=i});const n=this;this.promise.then(s=>{if(!n._listeners)return;let i=n._listeners.length;for(;i-- >0;)n._listeners[i](s);n._listeners=null}),this.promise.then=s=>{let i;const o=new Promise(c=>{n.subscribe(c),i=c}).then(s);return o.cancel=function(){n.unsubscribe(i)},o},e(function(i,o,c){n.reason||(n.reason=new K(i,o,c),r(n.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(e){if(this.reason){e(this.reason);return}this._listeners?this._listeners.push(e):this._listeners=[e]}unsubscribe(e){if(!this._listeners)return;const r=this._listeners.indexOf(e);r!==-1&&this._listeners.splice(r,1)}toAbortSignal(){const e=new AbortController,r=n=>{e.abort(n)};return this.subscribe(r),e.signal.unsubscribe=()=>this.unsubscribe(r),e.signal}static source(){let e;return{token:new Ut(function(s){e=s}),cancel:e}}};function Zr(t){return function(r){return t.apply(null,r)}}function en(t){return a.isObject(t)&&t.isAxiosError===!0}const Ae={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(Ae).forEach(([t,e])=>{Ae[e]=t});function Et(t){const e=new j(t),r=Ie(j.prototype.request,e);return a.extend(r,j.prototype,e,{allOwnKeys:!0}),a.extend(r,e,null,{allOwnKeys:!0}),r.create=function(s){return Et(I(t,s))},r}const E=Et(Z);E.Axios=j,E.CanceledError=K,E.CancelToken=Gr,E.isCancel=it,E.VERSION=bt,E.toFormData=oe,E.AxiosError=m,E.Cancel=E.CanceledError,E.all=function(e){return Promise.all(e)},E.spread=Zr,E.isAxiosError=en,E.mergeConfig=I,E.AxiosHeaders=N,E.formToJSON=t=>nt(a.isHTMLForm(t)?new FormData(t):t),E.getAdapter=gt.getAdapter,E.HttpStatusCode=Ae,E.default=E;const{Axios:_s,AxiosError:Pe,CanceledError:Es,isCancel:Ss,CancelToken:Cs,VERSION:Rs,all:Ts,Cancel:As,isAxiosError:Ps,spread:Os,toFormData:Ns,AxiosHeaders:xs,HttpStatusCode:Us,formToJSON:Ls,getAdapter:Ds,mergeConfig:Fs}=E;class Oe extends Error{constructor(r){super(r.join(", "));_(this,"errors");this.name="ValidationError",this.errors=r}}class Ne extends Error{constructor(r){super("Address already registered.");_(this,"address");this.name="AddressInUseError",this.address=r}}class xe extends Error{constructor(r){super("Code already registered.");_(this,"code");this.name="CodeInUseError",this.code=r}}class Ue extends Error{constructor(){super("Invalid signature provided"),this.name="InvalidSignatureError"}}class tn{constructor(e){_(this,"httpClient");_(this,"_debug");this.httpClient=e.httpClient,this._debug=e.debug}async create(e,r,n,s,i,o,c){var d;try{await this.httpClient.post({path:"/affiliates",postData:{address:e,identifier_type:r,name:n,code:n,signature:s,signature_public_key:i,account_chain_id:o,user_rebate_rate:c}})}catch(l){if(l instanceof Pe){const u=(d=l.response)==null?void 0:d.data;if(typeof(u==null?void 0:u.message)=="string"){const f=u.message.toLowerCase();throw f=="invalid signature"?new Ue:f=="address in use"?new Ne(e):f=="code in use"?new xe(n):new Error(f)}else if((u==null?void 0:u.message)instanceof Array)throw new Oe(u.message)}throw l}}async update(e,r,n,s,i,o,c){var d;try{await this.httpClient.post({path:`/affiliates/${e}`,postData:{code:n,user_identifier:e,identifier_type:r,signature:s,signature_public_key:i,account_chain_id:o,user_rebate_rate:c}})}catch(l){if(l instanceof Pe){const u=(d=l.response)==null?void 0:d.data;if(typeof(u==null?void 0:u.message)=="string"){const f=u.message.toLowerCase();throw f=="invalid signature"?new Ue:f=="address in use"?new Ne(e):f=="code in use"?new xe(n):new Error(f)}else if((u==null?void 0:u.message)instanceof Array)throw new Oe(u.message)}throw l}}async isCodeFree(e){try{return(await this.httpClient.get({path:`/affiliates/codes/${e}`})).data.available}catch(r){throw console.error("Fuul SDK: Could not check affiliate code",r),r}}async getCode(e,r){var n;try{return(await this.httpClient.get({path:`/affiliates/${e}`,queryParams:{identifier_type:r}})).data}catch(s){if(s instanceof Pe&&((n=s.response)==null?void 0:n.status)===404)return null;throw console.error("Fuul SDK: Could not get affiliate code",s),s}}}const rn="/audiences";class nn{constructor(e){_(this,"httpClient");_(this,"_debug");this.httpClient=e.httpClient,this._debug=e.debug}async getUserAudiences(e){return(await this.httpClient.get({path:`${rn}/audience-segments/user`,queryParams:{...e}})).data}}const St="/claim-checks";class sn{constructor(e){_(this,"httpClient");_(this,"_debug");this.httpClient=e.httpClient,this._debug=e.debug}async getClaimableChecks(e){return(await this.httpClient.post({path:`${St}/claim`,postData:{userIdentifier:e.user_identifier,userIdentifierType:e.user_identifier_type}})).data}async getClaimCheckTotals(e){return(await this.httpClient.get({path:`${St}/totals`,queryParams:{user_identifier:e.user_identifier,user_identifier_type:e.user_identifier_type}})).data}}class on{constructor(e){_(this,"httpClient");this.httpClient=e.httpClient}async getAll(e){const{data:r}=await this.httpClient.get({path:"conversions",queryParams:{...e}});return r}}const Ct="fuul.sent",an=60,cn="connect_wallet",Rt=10;class un{constructor(e){_(this,"debug");_(this,"httpClient");this.httpClient=e.httpClient,this.debug=!!e.debug}async sendEvent(e,r){if(this.isDuplicate(e)){this.debug&&console.debug("Fuul SDK: Event is considered duplicate and will not be sent");return}if(!r||!Array.isArray(r)||r.length===0)await this.httpClient.post({path:"events",postData:e});else for(const n of r){const s=structuredClone({...e,project_id:n});s.metadata.project_id=n,await this.httpClient.post({path:"events",postData:s,queryParams:{project_id:n}})}this.debug&&console.debug(`Fuul SDK: Sent '${e.name}' event`),this.saveSentEvent(e)}isDuplicate(e){var u,f,g,b;const r=`${Ct}_${e.name}`,n=localStorage.getItem(r);if(!n)return!1;const s=JSON.parse(n);if(this.getCurrentTimestamp()-s.timestamp>an)return!1;let d=!1;e.metadata&&(d=s.metadata.tracking_id===e.metadata.tracking_id&&s.metadata.project_id===e.metadata.project_id&&s.metadata.referrer===e.metadata.referrer&&s.metadata.source===e.metadata.source&&s.metadata.category===e.metadata.category&&s.metadata.title===e.metadata.title&&s.metadata.tag===e.metadata.tag&&s.user_address===e.user_address&&((u=s.user)==null?void 0:u.identifier)===((f=e.user)==null?void 0:f.identifier)&&((g=s.user)==null?void 0:g.identifier_type)===((b=e.user)==null?void 0:b.identifier_type)&&s.signature===e.signature&&s.signature_message===e.signature_message);let l=!1;return e.args&&s.args&&(l=s.args.page===e.args.page),l&&d}getCurrentTimestamp(){return Date.now()/1e3}saveSentEvent(e){var o,c,d,l;const r=`${Ct}_${e.name}`,n=`${r}_all`,s=this.getCurrentTimestamp(),i={...e,timestamp:s};if(localStorage.setItem(r,JSON.stringify(i)),e.name===cn){const u=JSON.parse(localStorage.getItem(n)||"[]"),f={name:e.name,user:{identifier:(o=e.user)==null?void 0:o.identifier,identifier_type:(c=e.user)==null?void 0:c.identifier_type},tracking_id:(d=e.metadata)==null?void 0:d.tracking_id,page:(l=e.args)==null?void 0:l.page};"user_address"in e&&(f.user_address=e.user_address);const g=[...u,f];g.length>Rt&&g.splice(0,g.length-Rt),localStorage.setItem(n,JSON.stringify(g))}}}const ln={version:"7.13.0"};class dn{constructor(e){_(this,"client");_(this,"defaultQueryParams");this.client=E.create({...e,headers:{Authorization:`Bearer ${e.apiKey}`,"X-Fuul-Sdk-Version":ln.version}}),this.defaultQueryParams=e.queryParams||{}}makeQueryParams(e){return Object.assign({},this.defaultQueryParams||{},e||{})}async get(e){return this.client.request({url:e.path,params:this.makeQueryParams(e.queryParams),method:"GET"})}async post(e){return this.client.request({url:e.path,params:this.makeQueryParams(e.queryParams),data:e.postData,method:"POST"})}async put(e){return this.client.request({url:e.path,params:this.makeQueryParams(e.queryParams),data:e.postData,method:"PUT"})}async patch(e){return this.client.request({url:e.path,params:this.makeQueryParams(e.queryParams),data:e.postData,method:"PATCH"})}async delete(e){return this.client.request({url:e.path,params:this.makeQueryParams(e.queryParams),data:e.postData,method:"DELETE"})}}class fn{constructor(e){_(this,"httpClient");this.httpClient=e.httpClient}async getPayoutsLeaderboard(e){const{identifier_type:r,user_identifier_type:n,...s}=e,i={...s,user_identifier_type:r??n};return(await this.httpClient.get({path:"/payouts/leaderboard/payouts",queryParams:i})).data}async getPointsLeaderboard(e){const{identifier_type:r,user_identifier_type:n,...s}=e,i={...s,user_identifier_type:r??n};return(await this.httpClient.get({path:"/payouts/leaderboard/points",queryParams:i})).data}async getVolumeLeaderboard(e){const{identifier_type:r,user_identifier_type:n,...s}=e,i={...s,identifier_type:r??n};return(await this.httpClient.get({path:"/payouts/leaderboard/volume",queryParams:i})).data}async getReferredUsersLeaderboard(e){return(await this.httpClient.get({path:"/leaderboard/referred",queryParams:{...e}})).data}async getReferredVolume(e){const{user_identifiers:r,...n}=e;return(await this.httpClient.get({path:"/payouts/leaderboard/referred-volume",queryParams:{...n,user_identifiers:r.join(",")}})).data}async getRevenueLeaderboard(e){const{identifier_type:r,user_identifier_type:n,...s}=e,i={...s,identifier_type:r??n};return(await this.httpClient.get({path:"/payouts/leaderboard/revenue",queryParams:i})).data}}const te="/payouts";class hn{constructor(e){_(this,"httpClient");_(this,"_debug");this.httpClient=e.httpClient,this._debug=e.debug}async getUserPayoutsByConversion(e){return(await this.httpClient.get({path:te,queryParams:{...e,type:"onchain-currency"}})).data}async getUserPointsByConversion(e){return(await this.httpClient.get({path:te,queryParams:{...e,type:"point"}})).data}async getUserPayoutMovements(e){return(await this.httpClient.get({path:`${te}/movements`,queryParams:{...e,type:"onchain-currency"}})).data}async getUserPointsMovements(e){return(await this.httpClient.get({path:`${te}/movements`,queryParams:{...e,type:"point"}})).data}async getPayoutsByReferrer(e){return(await this.httpClient.get({path:`${te}/by-referrer`,queryParams:{user_identifier:e.user_identifier,user_identifier_type:e.user_identifier_type}})).data}}class pn{constructor(e){_(this,"httpClient");_(this,"_debug");this.httpClient=e.httpClient,this._debug=e.debug}async listUserReferralCodes(e){return(await this.httpClient.get({path:"/referral_codes",queryParams:{user_identifier:e.user_identifier,user_identifier_type:e.user_identifier_type,page:e.page,page_size:e.page_size}})).data}async generateReferralCodes(e){return(await this.httpClient.post({path:"/referral_codes",queryParams:{user_identifier:e.user_identifier,user_identifier_type:e.user_identifier_type,quantity:e.quantity,max_uses:e.max_uses}})).data}async getReferralStatus(e){return(await this.httpClient.get({path:"/referral_codes/status",queryParams:{user_identifier:e.user_identifier,user_identifier_type:e.user_identifier_type}})).data}async getReferralCode(e){return(await this.httpClient.get({path:`/referral_codes/${e.code}`})).data}async useReferralCode(e){const{code:r,user_identifier:n,user_identifier_type:s,signature:i,signature_message:o,chain_id:c,account_chain_id:d}=e;await this.httpClient.patch({path:`/referral_codes/${r}/use`,queryParams:{user_identifier:n,user_identifier_type:s,chain_id:c,account_chain_id:d},postData:{signature:i,signature_message:o}})}async updateReferralCode(e){await this.httpClient.patch({path:`/referral_codes/${e.code}`,postData:{max_uses:e.max_uses}})}async deleteReferral(e){const{code:r,user_identifier:n,user_identifier_type:s,referrer_identifier:i,referrer_identifier_type:o,signature:c,signature_message:d,chain_id:l}=e;await this.httpClient.delete({path:`/referral_codes/${r}/referrals`,queryParams:{user_identifier:n,user_identifier_type:s,referrer_identifier:i,referrer_identifier_type:o},postData:{signature:c,signature_message:d,chain_id:l}})}}const mn="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let yn=(t=21)=>{let e="",r=crypto.getRandomValues(new Uint8Array(t|=0));for(;t--;)e+=mn[r[t]&63];return e};const gn="fuul.tracking_id",Le=()=>Cn(gn,()=>yn()),Tt=()=>z("af")||z("referrer"),wn=()=>document.referrer,bn=()=>Rn(),_n=()=>z("category"),En=()=>z("title"),Sn=()=>z("tag"),Cn=(t,e)=>{const r=localStorage.getItem(t);if(r)return r;{const n=e();return n?localStorage.setItem(t,n):localStorage.removeItem(t),n}},z=t=>new URLSearchParams(window.location.search).get(t),Rn=()=>{const t=z("source");if(t)return t},Tn="/user";class An{constructor(e){_(this,"httpClient");this.httpClient=e.httpClient}async getUserReferrer(e){return(await this.httpClient.get({path:`${Tn}/referrer`,queryParams:{...e}})).data}}const Pn="https://api.fuul.xyz/api/v1/";let F=!1,De=!1,Fe,L,At,Pt,J,ke,he,W,Ot,$,B,Be;function On(t){F=!!t.debug,!De&&(Fe=t.apiKey,cs(),L=us(t.baseApiUrl??Pn,t.defaultQueryParams??{}),At=new on({httpClient:L,debug:F}),he=new un({httpClient:L,debug:F}),J=new tn({httpClient:L,debug:F}),ke=new H({httpClient:L}),W=new hn({httpClient:L,debug:F}),Pt=new An({httpClient:L}),Ot=new nn({httpClient:L,debug:F}),$=new fn({httpClient:L}),B=new pn({httpClient:L,debug:F}),Be=new sn({httpClient:L,debug:F}),De=!0,F&&console.debug("Fuul SDK: init() complete"))}function w(){if(!De)throw new Error("Fuul SDK: You need to call init() to initialize the library before using any methods")}async function Nn(t,e){w(),qe(),ve();const r={name:t,args:e??{},metadata:{tracking_id:Le()}};await he.sendEvent(r)}async function xn(t,e){w(),qe(),ve();const r={name:"pageview",args:{page:t??document.location.pathname,locationOrigin:document.location.origin},metadata:{tracking_id:Le(),referrer_url:wn(),source:bn(),affiliate_id:Tt()??void 0,referrer:Tt()??void 0,category:_n()??void 0,title:En()??void 0,tag:Sn()??void 0}};await he.sendEvent(r,e)}async function Un(t,e){w(),qe(),ve();const r={name:"connect_wallet",user:{identifier:t.identifier,identifier_type:t.identifierType},args:{page:document.location.pathname,locationOrigin:document.location.origin},metadata:{tracking_id:Le()}};t!=null&&t.signature&&(r.signature=t==null?void 0:t.signature,r.signature_message=t==null?void 0:t.message),t!=null&&t.signaturePublicKey&&(r.signature_public_key=t.signaturePublicKey),t!=null&&t.accountChainId&&(r.account_chain_id=t.accountChainId),await he.sendEvent(r,e)}async function Ln(t){w(),await J.create(t.userIdentifier,t.identifierType,t.code,t.signature,t.signaturePublicKey,t.accountChainId,t.userRebateRate)}async function Dn(t){w(),await J.update(t.userIdentifier,t.identifierType,t.code,t.signature,t.signaturePublicKey,t.accountChainId,t.userRebateRate)}async function Fn(t,e){return w(),await J.getCode(t,e)}async function kn(t){return w(),await J.isCodeFree(t)}async function Bn(t,e,r,n){w();const s=await J.getCode(e,r),i=new URLSearchParams({af:(s==null?void 0:s.code)??e});return n!=null&&n.title&&i.append("af_title",n.title),n!=null&&n.format&&i.append("af_format",n.format),n!=null&&n.place&&i.append("af_place",n.place),`${t}?${i.toString()}`}function qn(t){return $.getPayoutsLeaderboard(t)}function vn(t){return $.getPointsLeaderboard(t)}function In(t){return $.getReferredUsersLeaderboard(t)}function jn(t){return w(),$.getReferredVolume(t)}function $n(t){return w(),$.getVolumeLeaderboard(t)}function Mn(t){return w(),$.getRevenueLeaderboard(t)}function Hn(t){return W.getUserPayoutsByConversion(t)}function Vn(t){return W.getUserPointsByConversion(t)}function Kn(t){return W.getUserPayoutMovements(t)}function zn(t){return W.getUserPointsMovements(t)}function Jn(t){return w(),W.getPayoutsByReferrer(t)}async function Wn(t){return w(),At.getAll(t)}async function Xn(t){return w(),Pt.getUserReferrer(t)}async function Qn(t){return w(),Ot.getUserAudiences(t)}async function Yn(t){return w(),B.listUserReferralCodes(t)}async function Gn(t){return w(),B.generateReferralCodes(t)}async function Zn(t){return w(),B.getReferralStatus(t)}async function es(t){return w(),B.getReferralCode(t)}async function ts(t){return w(),B.useReferralCode(t)}async function rs(t){return w(),B.updateReferralCode(t)}async function ns(t){return w(),B.deleteReferral(t)}async function ss(t){return w(),ke.getAffiliateStats(t)}async function is(t){return w(),ke.getAffiliateNewTraders(t)}async function os(t){return w(),Be.getClaimableChecks(t)}async function as(t){return w(),Be.getClaimCheckTotals(t)}function qe(){if(typeof window>"u"||typeof document>"u")throw new Error("Fuul SDK: Browser context required")}function ve(){if(navigator.webdriver)throw new Error("Fuul SDK: Error")}function cs(){if(!Fe)throw new Error("Fuul SDK: Invalid API key")}function us(t,e){return new dn({baseURL:t,timeout:3e4,apiKey:Fe,queryParams:e})}const ls={init:On,sendEvent:Nn,sendPageview:xn,identifyUser:Un,generateTrackingLink:Bn,getConversions:Wn,createAffiliateCode:Ln,updateAffiliateCode:Dn,getAffiliateCode:Fn,isAffiliateCodeFree:kn,getPayoutsLeaderboard:qn,getPointsLeaderboard:vn,getReferredUsersLeaderboard:In,getReferredVolume:jn,getUserAudiences:Qn,getUserPayoutsByConversion:Hn,getUserPointsByConversion:Vn,getUserPointsMovements:zn,getUserPayoutMovements:Kn,getPayoutsByReferrer:Jn,getUserReferrer:Xn,getVolumeLeaderboard:$n,getRevenueLeaderboard:Mn,listUserReferralCodes:Yn,generateReferralCodes:Gn,getReferralStatus:Zn,getReferralCode:es,useReferralCode:ts,updateReferralCode:rs,deleteReferral:ns,getAffiliateStats:ss,getAffiliateNewTraders:is,getClaimableChecks:os,getClaimCheckTotals:as};var Nt=(t=>(t.EvmAddress="evm_address",t.SolanaAddress="solana_address",t.XRPLAddress="xrpl_address",t.SuiAddress="sui_address",t.Email="email",t))(Nt||{});T.AddressInUseError=Ne,T.CodeInUseError=xe,T.Fuul=ls,T.InvalidSignatureError=Ue,T.UserIdentifierType=Nt,T.ValidationError=Oe,Object.defineProperty(T,Symbol.toStringTag,{value:"Module"})});
@@ -1,4 +1,4 @@
1
- declare const _default: { "version": "7.12.0" }
1
+ declare const _default: { "version": "7.13.0" }
2
2
  ;
3
3
 
4
4
  export default _default;
@@ -176,7 +176,7 @@ export interface Conversion {
176
176
  user_landing_page_url?: string;
177
177
  partner_landing_page_url?: string;
178
178
  user_onboarding_page_url?: string;
179
- contract_chain_id: number | null;
179
+ contract_chain_id: string | null;
180
180
  github_account?: string;
181
181
  whitepaper_url?: string;
182
182
  investors?: ProjectInvestor[];
@@ -290,7 +290,7 @@ export interface PayoutsLeaderboard {
290
290
  user_identifier: string;
291
291
  user_identifier_type: string;
292
292
  rank: number;
293
- chain_id: number;
293
+ chain_id: string;
294
294
  total_amount: number;
295
295
  total_attributions: number;
296
296
  tiers?: Record<string, string>;
@@ -303,7 +303,7 @@ export interface VolumeLeaderboard {
303
303
  user_identifier_type: string;
304
304
  affiliate_code?: string;
305
305
  total_amount: string;
306
- chain_id: number | null;
306
+ chain_id: string | null;
307
307
  rank: number;
308
308
  }
309
309
  export interface RevenueLeaderboard {
@@ -368,7 +368,7 @@ export interface UserConversionPayout {
368
368
  conversion_id: string;
369
369
  conversion_name: string;
370
370
  currency_address: string;
371
- chain_id: number;
371
+ chain_id: string;
372
372
  }
373
373
  export interface UserPointsByConversionResponse {
374
374
  total_results: number;
@@ -396,7 +396,7 @@ export interface UserPayoutMovementsResponse {
396
396
  export interface UserPayoutMovement {
397
397
  date: string;
398
398
  currency_address: string;
399
- chain_id: number;
399
+ chain_id: string;
400
400
  is_referrer: boolean;
401
401
  conversion_id: string;
402
402
  conversion_name: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fuul/sdk",
3
- "version": "7.12.0",
3
+ "version": "7.13.0",
4
4
  "description": "Fuul SDK",
5
5
  "keywords": [
6
6
  "Fuul",