@superutils/fetch 1.5.7 → 1.5.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/index.min.js +1 -1
- package/dist/browser/index.min.js.map +1 -1
- package/dist/index.cjs +17 -13
- package/dist/index.d.cts +17 -17
- package/dist/index.d.ts +17 -17
- package/dist/index.js +17 -13
- package/package.json +3 -3
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
this.superutils=this.superutils||{};this.superutils.fetch=(function(){'use strict';var We=Object.defineProperty;var Fe=(e,t)=>{for(var n in t)We(e,n,{get:t[n],enumerable:true});};var ce={};Fe(ce,{PromisE:()=>S,PromisEBase:()=>je,ResolveError:()=>oe,ResolveIgnored:()=>ie,TIMEOUT_FALLBACK:()=>G,TIMEOUT_MAX:()=>le,TimeoutPromise:()=>ue,default:()=>Oe,deferred:()=>ae,deferredCallback:()=>k,delay:()=>K,delayReject:()=>Ne,retry:()=>$,timeout:()=>B});var _=(e,t=true)=>!!e&&typeof e=="object"&&(!t||[Object.prototype,null].includes(Object.getPrototypeOf(e)));var L=e=>Array.isArray(e);var Ge=e=>Number.isInteger(e);var J=e=>typeof e=="number"&&!Number.isNaN(e)&&Number.isFinite(e),te=e=>Ge(e)&&e>0,re=e=>J(e)&&e>0,ne=(e,t=false,n=false)=>{if(e==null)return true;switch(typeof e){case "number":return !J(e);case "string":return !e.replaceAll(" ","").trim().length;case "boolean":case "bigint":case "symbol":case "function":return false}if(e instanceof Date)return Number.isNaN(e.getTime());if(e instanceof Map||e instanceof Set)return !e.size;if(Array.isArray(e)||e instanceof Uint8Array)return !e.length;if(e instanceof Error)return !e.message.length;let r=typeof e=="object"&&Object.getPrototypeOf(e);return r===Object.prototype||r===null?t?!Object.getOwnPropertyNames(e).length:!Object.keys(e).length:n};var g=e=>typeof e=="function";var Te=e=>e instanceof URL,Re=(e,t=true,n=["localhost"])=>{if(!e)return false;try{if(typeof e!="string"&&!Te(e))return !1;let r=Te(e)?e:new URL(e);if(!t)return !0;if(!(n.includes(r.hostname)||r.host.split(".").length>1))return !1;let s=`${e}`;return s.endsWith(r.hostname)&&(s+="/"),r.href===s}catch(r){return false}};var Ce=e=>e instanceof Error,W=e=>e instanceof Promise;var Ze=e=>typeof e=="symbol";var E=(e,t,n)=>{try{let r=g(e)?e(...g(t)?t():t):e;return W(r)?r.catch(i=>g(n)?n(i):n):r}catch(r){return g(n)?n(r):n}},N=E;new Date().getTime();var Ye=(e,t=true,n=true)=>N(()=>[...n&&Object.getOwnPropertySymbols(e)||[],...t?Object.keys(e).sort():Object.keys(e)],[],[]),Qe=Ye,q=(e,t="null")=>JSON.parse(N(JSON.stringify,[e],t)),C=(e,t,n,r=false,i=true)=>{let s=_(t,false)||g(t)?t:{};if(!_(e,false)&&!g(t))return s;let a=new Set(n!=null?n:[]),o=Qe(e,true,true).filter(u=>!a.has(u));for(let u of o){let c=u,l=e[c];if(s.hasOwnProperty(c)&&(r==="empty"?!ne(s[c]):g(r)?!r(c,s[c],l):true))continue;if([void 0,null,1/0,NaN].includes(l)||!_(l,false)){s[c]=l;continue}s[c]=(()=>{switch(Object.getPrototypeOf(l)){case Array.prototype:return q(l,"[]");case ArrayBuffer.prototype:return l.slice(0);case Date.prototype:return new Date(l.getTime());case Map.prototype:return new Map(q(Array.from(l),"[]"));case RegExp.prototype:return new RegExp(l);case Set.prototype:return new Set(q(Array.from(l)));case Uint8Array.prototype:return new Uint8Array([...l]);case URL.prototype:return new URL(l);}if(Ze(c)||!i)return q(l);let b=[...a].map(y=>String(y).startsWith(String(c).concat("."))&&String(y).split(String(c).concat("."))[1]).filter(Boolean);return b.length?C(l,s[c],b,r,i):q(l)})();}return s};var se=(e,t=0)=>L(e)?Array.from(new Set(e.flat(t))):[],ee=(e,t=50,n={})=>{let{leading:r=ee.defaults.leading,onError:i=ee.defaults.onError,thisArg:s}=n,{tid:a}=n;s!==void 0&&(e=e.bind(s));let o=(...l)=>N(e,l,i),u=null,c=r==="global";return (...l)=>{clearTimeout(a),a=setTimeout(()=>{u!==l&&o(...l),u=c?true:null;},t),!(!r||u)&&(u=l,o(...l));}};ee.defaults={leading:false,onError:void 0};var tt=ee,ge=(e,t=50,n={})=>{let{defaults:r}=ge,{onError:i=r.onError,trailing:s=r.trailing,thisArg:a}=n,{tid:o}=n,u=(...l)=>N(a!==void 0?e.bind(a):e,l,g(i)?d=>N(i,[d],void 0):void 0),c=null;return (...l)=>{if(o){c=l;return}o=setTimeout(()=>{if(o=void 0,!s)return;let d=c;c=null,d&&d!==l&&u(...d);},t),u(...l);}};ge.defaults={onError:void 0,trailing:false};var rt=ge,Se=(e,t=50,n={})=>n.throttle?rt(e,t,n):tt(e,t,n);var z=globalThis.Promise,F=class extends z{constructor(t){let n,r,i=false,s=(a,o=true,u)=>{if(!i)return queueMicrotask(()=>s(a,o,u));a(u),this._state=o?1:2,this.onFinalize.forEach(c=>E(c,o?[u]:[void 0,u],void 0));};super((a,o)=>{r=u=>s(o,false,u),n=u=>s(a,true,u),g(t)?E(t,[n,r],r):W(t)?t.then(n,r):t!==void 0&&n(t);}),this._state=0,this.onEarlyFinalize=[],this.onFinalize=[],this.resolve=a=>{var o,u;this.pending&&((o=this._resolve)==null||o.call(this,a),(u=this.onEarlyFinalize)==null||u.forEach(c=>{E(c,[true,a],void 0);}));},this.reject=a=>{var o,u;this.pending&&((o=this._reject)==null||o.call(this,a),(u=this.onEarlyFinalize)==null||u.forEach(c=>{E(c,[false,a],void 0);}));},i=true,this._resolve=n,this._reject=r;}get pending(){return this.state===0}get rejected(){return this.state===2}get resolved(){return this.state===1}get state(){return this._state}};F.all=e=>new F(z.all(e));F.allSettled=e=>new F(z.allSettled(e));F.any=e=>new F(z.any(e));F.race=e=>new F(z.race(e));F.reject=e=>{let t=new F;return queueMicrotask(()=>t.reject(e)),t};F.resolve=e=>new F(z.resolve(e));F.try=(e,...t)=>new F(E(e,t,n=>F.reject(n)));F.withResolvers=()=>{let e=new F;return {promise:e,reject:e.reject,resolve:e.resolve}};var je=F,P=je,oe=(e=>(e.NEVER="NEVER",e.REJECT="REJECT",e.WITH_ERROR="RESOLVE_ERROR",e.WITH_UNDEFINED="RESOLVE_UNDEFINED",e))(oe||{}),ie=(e=>(e.NEVER="NEVER",e.WITH_LAST="WITH_LAST",e.WITH_UNDEFINED="WITH_UNDEFINED",e))(ie||{});function ae(e={}){let t=0;e=C(ae.defaults,e,[],"empty");let{onError:n,onIgnore:r,onResult:i}=e,{delay:s=0,ignoreStale:a,resolveError:o,resolveIgnored:u,thisArg:c,throttle:l}=e,d=null,f,b=new Map,y=!re(s);c!==void 0&&(n=n==null?void 0:n.bind(c),r=r==null?void 0:r.bind(c),i=i==null?void 0:i.bind(c));let m=T=>{for(let[v,h]of T){b.delete(v);let w=a&&h.sequence<f.sequence;if(!(h.resolved||h.started&&!w))switch(h.started&&(h.getPromise=(()=>h.result)),E(r,[h.getPromise],0),u){case "WITH_UNDEFINED":h.resolve(void 0);break;case "WITH_LAST":f==null||f.then(h.resolve,h.reject);break;}}b.size||(t=0);},p=T=>{if(d=null,y){b.delete(T);let[h,w]=[...b.entries()][0]||[];return h&&w&&A(h,w)}let v=[...b.entries()];if(l===true&&e.trailing){let h=v.findIndex(([w])=>w===T);v=v.slice(0,h);}else l||(v=v.slice(0,-1));m(v),b.delete(T);},O=async(T,v)=>{var h;try{v.started=!0,f=v,d=v,(h=v.result)!=null||(v.result=P.try(v.getPromise));let w=await v.result;if(!!a&&v.sequence<f.sequence)return m([[T,v]]);v.resolve(w),i&&E(i,[w],void 0);}catch(w){switch(n&&E(n,[w],void 0),o){case "REJECT":v.reject(w);case "NEVER":break;case "RESOLVE_UNDEFINED":v.resolve(void 0);break;case "RESOLVE_ERROR":v.resolve(w);break}}p(T);},A=y?O:Se(O,s,e);return T=>{let v=Symbol("deferred-queue-item-id"),h=new P;return h.getPromise=g(T)?T:()=>T,h.started=false,h.sequence=++t,b.set(v,h),(!d||!y)&&A(v,h),h}}ae.defaults={delay:100,resolveError:"REJECT",resolveIgnored:"WITH_LAST"};var Me=ae;function k(e,t={}){let{thisArg:n}=t;n!==void 0&&(e=e.bind(n));let r=Me(t);return (...i)=>r(()=>e(...i))}var it=k;function K(e=K.defaults.duration,t,n=false){let r=new P,i=s=>{let a=E(async()=>{let o=await(g(s)?s():s);return n?o!=null?o:new Error(`${K.defaults.delayTimeoutMsg} ${e}ms`):o!=null?o:e},[],o=>Promise.reject(o));n?a.then(r.reject,r.reject):r.resolve(a);};return r.timeoutId=setTimeout(()=>i(t),e),r.pause=()=>clearTimeout(r.timeoutId),r.catch(()=>{}).finally(()=>r.pause()),r.onEarlyFinalize.push(()=>r.pause()),r}K.defaults={duration:100,delayTimeoutMsg:"Timed out after"};var be=K;function Ne(e,t){return be(e,t,true)}var Le=Ne,$=(e,t)=>{let n=false,r=P.try(async()=>{var i,s;t=C($.defaults,t!=null?t:{},[],(p,O)=>{switch(p){case "retry":case "retryDelay":case "retryDelayJitterMax":return O!==0&&!te(O)}return !!ne(O)});let{retry:a,retryBackOff:o,retryDelay:u,retryDelayJitter:c,retryDelayJitterMax:l}=t,d=u,f=-1,b,y,m=false;do{if(f++,o==="exponential"&&f>1&&(d*=2),c&&(d+=Math.floor(Math.random()*l)),!n&&f>0&&await be(d),!n)try{y=void 0,b=await e();}catch(p){y=p!=null?p:new Error(p);}if(n||a===0||f>=a)break;m=!!((s=await E((i=t.retryIf)!=null?i:y,[b,f,y],y))!=null?s:y);}while(m);return y!==void 0?Promise.reject(y):b});return r.onEarlyFinalize.push(()=>{n=true;}),r};$.defaults={retry:1,retryBackOff:"exponential",retryDelay:300,retryDelayJitter:true,retryDelayJitterMax:100};var at=$,G=1e4,le=2147483647,ue=class extends P{constructor(e,t,n,r){super(e),this.started=new Date,this._setup=()=>{var i,s,a,o;this._signals=se([(s=(i=this.options)==null?void 0:i.abortCtrl)==null?void 0:s.signal,(a=this.options)==null?void 0:a.signal].filter(Boolean)),!this.onEarlyFinalize.includes(this._handleEarlyFinalize)&&this.onEarlyFinalize.push(this._handleEarlyFinalize),!this.onFinalize.includes(this._handleFinalize)&&this.onFinalize.push(this._handleFinalize),(o=this._signals)==null||o.forEach(u=>u==null?void 0:u.addEventListener("abort",this._handleAbort));},this._handleAbort=async()=>{var i;let a=await E((i=this.options)==null?void 0:i.onAbort,[],void 0);a!=null||(a=new Error(`Aborted after ${new Date().getTime()-this.started.getTime()}ms`)),(a.name)!=null||(a.name="AbortError"),this.reject(a);},this._handleEarlyFinalize=()=>{var i,s,a,o;(i=this.options)!=null&&i.abortOnEarlyFinalize&&((o=(a=(s=this.options)==null?void 0:s.abortCtrl)==null?void 0:a.abort)==null||o.call(a));},this._handleFinalize=((i,s)=>{var a,o,u,c,l;this.cancelAbort(),this.clearTimeout(),!(!this.timeout.rejected&&!((a=this._signals)!=null&&a.find(d=>d==null?void 0:d.aborted)))&&((c=(u=(o=this.options)==null?void 0:o.abortCtrl)==null?void 0:u.signal)==null?void 0:c.aborted)===false&&((l=this.options)==null||l.abortCtrl.abort(s));}),this.data=e,this.options=_(n)?n:{},this.timeout=t,this._signals=r,this._setup();}get abortCtrl(){return this.options.abortCtrl}get aborted(){var e;return this.rejected&&!this.timeout.rejected&&!!((e=this._signals)!=null&&e.find(t=>t==null?void 0:t.aborted))}cancelAbort(){var e;(e=this._signals)==null||e.forEach(t=>t==null?void 0:t.removeEventListener("abort",this._handleAbort));}clearTimeout(){clearTimeout(this.timeout.timeoutId);}get timedout(){return this.rejected&&this.timeout.rejected}},lt=ue;function B(e,...t){var n;let r=C(B.defaults,J(e)?{timeout:e}:_(e)?e:{},[],"empty");r.timeout=Math.min(re(r.timeout)?r.timeout:G,le);let i=t.map(o=>g(o)?P.try(o):o),s=i.length<=1?i[0]instanceof P?i[0]:new P(i[0]):(g(P[r.batchFunc])?P[r.batchFunc]:P.all)(i),a=Le(r.timeout,r.onTimeout);return new lt(P.race([s,a]),a,r,se([(n=r.abortCtrl)==null?void 0:n.signal,r.signal].filter(Boolean)))}B.defaults={abortOnEarlyFinalize:true,batchFunc:"all",timeout:G};var ut=B,S=class extends P{};S.deferred=Me;S.deferredCallback=it;S.delay=be;S.delayReject=Le;S.retry=at;S.timeout=ut;var ct=S,Oe=ct;var pe={};Fe(pe,{ContentType:()=>H,FetchAs:()=>de,FetchError:()=>Z,ResolveError:()=>oe,ResolveIgnored:()=>ie,TIMEOUT_FALLBACK:()=>G,TIMEOUT_MAX:()=>le,TimeoutPromise:()=>ue,createClient:()=>Be,createPostClient:()=>He,default:()=>_e,executeInterceptors:()=>Ue,fetch:()=>x,mergeOptions:()=>ke});var Ue=async(e,t,n,...r)=>{var i;for(let s of [...n!=null?n:[]].filter(g)){if(t!=null&&t.aborted)break;e=(i=await E(s,[e,...r],void 0))!=null?i:e;}return e},X=Ue;var dt=(e,t={})=>{let n=g(t.fetchFunc)?t.fetchFunc:globalThis.fetch;if(!te(t.retry))return n(e,t);let r=0;return $(()=>(r++,n(e,t)),{...t,retryIf:async(s,a,o)=>{var d,f;let{abortCtrl:u,retryIf:c,signal:l}=t;return (d=u==null?void 0:u.signal)!=null&&d.aborted||l!=null&&l.aborted?false:!!((f=await E(c,[s,a,o],void 0))!=null?f:o||!(s!=null&&s.ok))}}).catch(s=>Promise.reject(new Error(`Request failed after attempt #${r}`,{cause:s})))},ze=dt;var ke=(...e)=>e.reduce((t,n)=>{var a;n=_(n)?n:{};let{headers:r,interceptors:i={}}=t,{interceptors:s={}}=n;return n.headers&&new Headers(n.headers).forEach((o,u)=>r.set(u,o)),{...t,...n,errMsgs:C(n.errMsgs,t.errMsgs,[],"empty"),headers:r,interceptors:{error:[...D(i==null?void 0:i.error),...D(s==null?void 0:s.error)],request:[...D(i==null?void 0:i.request),...D(s==null?void 0:s.request)],response:[...D(i==null?void 0:i.response),...D(s==null?void 0:s.response)],result:[...D(i==null?void 0:i.result),...D(s==null?void 0:s.result)]},timeout:(a=n.timeout)!=null?a:t.timeout}},{headers:new Headers}),j=ke,D=e=>L(e)?e:g(e)?[e]:[];var H={APPLICATION_JAVASCRIPT:"application/javascript",APPLICATION_JSON:"application/json",APPLICATION_OCTET_STREAM:"application/octet-stream",APPLICATION_PDF:"application/pdf",APPLICATION_X_WWW_FORM_URLENCODED:"application/x-www-form-urlencoded",APPLICATION_XML:"application/xml",APPLICATION_ZIP:"application/zip",AUDIO_MPEG:"audio/mpeg",MULTIPART_FORM_DATA:"multipart/form-data",TEXT_CSS:"text/css",TEXT_HTML:"text/html",TEXT_PLAIN:"text/plain",VIDEO_MP4:"video/mp4"},de=(o=>(o.arrayBuffer="arrayBuffer",o.blob="blob",o.bytes="bytes",o.formData="formData",o.json="json",o.response="response",o.text="text",o))(de||{});var Z=class e extends Error{constructor(t,n){super(t,{cause:n.cause}),this.name="FetchError",Object.defineProperties(this,{clone:{get(){return r=>new e(r,{cause:n.cause,options:n.options,response:n.response,url:n.url})}},options:{get(){return n.options}},response:{get(){return n.response}},url:{get(){return n.url}}});}};var $e=Object.freeze({aborted:"Request aborted",invalidUrl:"Invalid URL",parseFailed:"Failed to parse response as",timedout:"Request timed out",requestFailed:"Request failed with status code:"}),we=(e,t={})=>{_(t)||(t={});let n,r=j({errMsgs:$e},we.defaults,t);r.abortCtrl=r.abortCtrl instanceof AbortController?r.abortCtrl:new AbortController,(r.as)!=null||(r.as="response"),(r.method)!=null||(r.method="get"),(r.signal)!=null||(r.signal=r.abortCtrl.signal);let{abortCtrl:i,as:s,headers:a,onAbort:o,onTimeout:u}=r;return r.onAbort=async()=>{let f=await E(o,[],void 0);return await Ee(Ce(f)?f:new Error(f),e,r,n)},r.onTimeout=async()=>{let f=await E(u,[],void 0);return await Ee(f!=null?f:new Error(r.errMsgs.timedout),e,r,n)},B(r,async()=>{var f,b,y,m;try{r.body=await E(r.body,[],I=>Promise.reject(I)),e=await X(e,i.signal,(f=r.interceptors)==null?void 0:f.request,r);let{body:p,errMsgs:O,validateUrl:A=!1}=r;if((b=r.signal)!=null||(r.signal=i.signal),A&&!Re(e,!1))throw new Error(O.invalidUrl);["delete","patch","post","put"].includes(`${r.method}`.toLowerCase())&&!["undefined","string"].includes(typeof p)&&_(p,!0)&&a.get("content-type")===H.APPLICATION_JSON&&(r.body=JSON.stringify(r.body)),n=await ze(e,r),n=await X(n,i.signal,(y=r.interceptors)==null?void 0:y.response,e,r);let v=n==null?void 0:n.status;if(!(v>=200&&v<300)){let I=await E(()=>n.json(),[],void 0);throw new Error((I==null?void 0:I.message)||`${O.requestFailed} ${v}`,{cause:I})}let w=n[s],M=g(w)?w.bind(n)():n;return W(M)&&(M=await M.catch(I=>Promise.reject(new Error(`${O.parseFailed} ${s}. ${I==null?void 0:I.message}`,{cause:I})))),M=await X(M,i.signal,(m=r.interceptors)==null?void 0:m.result,e,r),M}catch(p){let O=p;return O=await Ee(p,e,r,n),Promise.reject(O)}})};we.defaults={abortOnEarlyFinalize:true,errMsgs:{...$e},headers:new Headers,interceptors:{error:[],request:[],response:[],result:[]},timeout:6e4,validateUrl:false};var Ee=async(e,t,n,r)=>{var s,a,o;return await X(new Z((s=e==null?void 0:e.message)!=null?s:e,{cause:(a=e==null?void 0:e.cause)!=null?a:e,response:r,options:n,url:t}),void 0,(o=n.interceptors)==null?void 0:o.error,t,n)},R=we;var Be=(e,t,n)=>{function r(i,s){let a=j(R.defaults,t,s,e);return (a.as)!=null||(a.as="json"),R(i,a)}return r.deferred=(i,s,a)=>{let o;return k((...c)=>{var f;let l=j(R.defaults,t,a,s===void 0?c[1]:c[0],e);return (l.as)!=null||(l.as="json"),(f=o==null?void 0:o.abort)==null||f.call(o),o=new AbortController,R(s!=null?s:c[0],l)},{...n,...i})},r},fe=Be;var He=(e,t,n)=>{function r(i,s,a){let o=j(t,a,e);(o.as)!=null||(o.as="json"),o.body=s!=null?s:o.body,(o.method)!=null||(o.method="post");let u=o.headers;return u.get("content-type")||u.set("content-type",H.APPLICATION_JSON),R(i,o)}return r.deferred=(i,s,a,o)=>{let u;return k((...l)=>{var y,m;s!==void 0&&l.splice(0,0,s),a!==void 0&&l.splice(1,0,a);let d=j(R.defaults,t,o,l[2],e);(d.as)!=null||(d.as="json"),(y=u==null?void 0:u.abort)==null||y.call(u),u=new AbortController,d.body=(m=l[1])!=null?m:d.body,(d.method)!=null||(d.method="post");let f=d.headers;return f.get("content-type")||f.set("content-type",H.APPLICATION_JSON),R(l[0],d)},{...n,...i})},r},Y=He;var U={get:fe({method:"get"}),head:fe({method:"head"}),options:fe({method:"options"}),delete:Y({method:"delete"}),patch:Y({method:"patch"}),post:Y({method:"post"}),put:Y({method:"put"})},x=R;x.delete=U.delete;x.get=U.get;x.head=U.head;x.options=U.options;x.patch=U.patch;x.post=U.post;x.put=U.put;var _e=x;var he=_e;Object.keys(pe).forEach(e=>{["default","fetch"].includes(e)||(he[e])!=null||(he[e]=pe[e]);});var vr=he,me=Oe;Object.keys(ce).forEach(e=>{["default","PromisE"].includes(e)||(me[e])!=null||(me[e]=ce[e]);});var ve=globalThis;(ve.superutils)!=null||(ve.superutils={});var Ve;((Ve=ve.superutils).PromisE)!=null||(Ve.PromisE=me);return vr;})();//# sourceMappingURL=index.min.js.map
|
|
1
|
+
this.superutils=this.superutils||{};this.superutils.fetch=(function(){'use strict';var Ge=Object.defineProperty;var Te=(e,t)=>{for(var n in t)Ge(e,n,{get:t[n],enumerable:true});};var ce={};Te(ce,{PromisE:()=>D,PromisEBase:()=>Ne,Promise:()=>x,ResolveError:()=>oe,ResolveIgnored:()=>ie,TIMEOUT_FALLBACK:()=>G,TIMEOUT_MAX:()=>le,TimeoutPromise:()=>ue,default:()=>Oe,deferred:()=>ae,deferredCallback:()=>k,delay:()=>K,delayReject:()=>Ue,retry:()=>$,timeout:()=>B});var F=(e,t=true)=>!!e&&typeof e=="object"&&(!t||[Object.prototype,null].includes(Object.getPrototypeOf(e)));var U=e=>Array.isArray(e);var Ze=e=>Number.isInteger(e);var J=e=>typeof e=="number"&&!Number.isNaN(e)&&Number.isFinite(e),te=e=>Ze(e)&&e>0,re=e=>J(e)&&e>0,ne=(e,t=false,n=false)=>{if(e==null)return true;switch(typeof e){case "number":return !J(e);case "string":return !e.replaceAll(" ","").trim().length;case "boolean":case "bigint":case "symbol":case "function":return false}if(e instanceof Date)return Number.isNaN(e.getTime());if(e instanceof Map||e instanceof Set)return !e.size;if(Array.isArray(e)||e instanceof Uint8Array)return !e.length;if(e instanceof Error)return !e.message.length;let r=typeof e=="object"&&Object.getPrototypeOf(e);return r===Object.prototype||r===null?t?!Object.getOwnPropertyNames(e).length:!Object.keys(e).length:n};var g=e=>typeof e=="function";var Pe=e=>e instanceof URL,xe=(e,t=true,n=["localhost"])=>{if(!e)return false;try{if(typeof e!="string"&&!Pe(e))return !1;let r=Pe(e)?e:new URL(e);if(!t)return !0;if(!(n.includes(r.hostname)||r.host.split(".").length>1))return !1;let s=`${e}`;return s.endsWith(r.hostname)&&(s+="/"),r.href===s}catch(r){return false}};var Se=e=>e instanceof Error,W=e=>e instanceof Promise;var Qe=e=>typeof e=="symbol";var O=(e,t,n)=>{try{let r=g(e)?e(...g(t)?t():t):e;return W(r)?r.catch(i=>g(n)?n(i):n):r}catch(r){return g(n)?n(r):n}},L=O;new Date().getTime();var et=(e,t=true,n=true)=>L(()=>[...n&&Object.getOwnPropertySymbols(e)||[],...t?Object.keys(e).sort():Object.keys(e)],[],[]),tt=et,q=(e,t="null")=>JSON.parse(L(JSON.stringify,[e],t)),R=(e,t,n,r=false,i=true)=>{let s=F(t,false)||g(t)?t:{};if(!F(e,false)&&!g(t))return s;let a=new Set(n!=null?n:[]),o=tt(e,true,true).filter(u=>!a.has(u));for(let u of o){let c=u,l=e[c];if(s.hasOwnProperty(c)&&(r==="empty"?!ne(s[c]):g(r)?!r(c,s[c],l):true))continue;if([void 0,null,1/0,NaN].includes(l)||!F(l,false)){s[c]=l;continue}s[c]=(()=>{switch(Object.getPrototypeOf(l)){case Array.prototype:return q(l,"[]");case ArrayBuffer.prototype:return l.slice(0);case Date.prototype:return new Date(l.getTime());case Map.prototype:return new Map(q(Array.from(l),"[]"));case RegExp.prototype:return new RegExp(l);case Set.prototype:return new Set(q(Array.from(l)));case Uint8Array.prototype:return new Uint8Array([...l]);case URL.prototype:return new URL(l);}if(Qe(c)||!i)return q(l);let b=[...a].map(y=>String(y).startsWith(String(c).concat("."))&&String(y).split(String(c).concat("."))[1]).filter(Boolean);return b.length?R(l,s[c],b,r,i):q(l)})();}return s};var se=(e,t=0)=>U(e)?Array.from(new Set(e.flat(t))):[],ee=(e,t=50,n={})=>{let{leading:r=ee.defaults.leading,onError:i=ee.defaults.onError,thisArg:s}=n,{tid:a}=n;s!==void 0&&(e=e.bind(s));let o=(...l)=>L(e,l,i),u=null,c=r==="global";return (...l)=>{clearTimeout(a),a=setTimeout(()=>{u!==l&&o(...l),u=c?true:null;},t),!(!r||u)&&(u=l,o(...l));}};ee.defaults={leading:false,onError:void 0};var nt=ee,ge=(e,t=50,n={})=>{let{defaults:r}=ge,{onError:i=r.onError,trailing:s=r.trailing,thisArg:a}=n,{tid:o}=n,u=(...l)=>L(a!==void 0?e.bind(a):e,l,g(i)?d=>L(i,[d],void 0):void 0),c=null;return (...l)=>{if(o){c=l;return}o=setTimeout(()=>{if(o=void 0,!s)return;let d=c;c=null,d&&d!==l&&u(...d);},t),u(...l);}};ge.defaults={onError:void 0,trailing:false};var st=ge,je=(e,t=50,n={})=>n.throttle?st(e,t,n):nt(e,t,n);var oe=(e=>(e.NEVER="NEVER",e.REJECT="REJECT",e.WITH_ERROR="RESOLVE_ERROR",e.WITH_UNDEFINED="RESOLVE_UNDEFINED",e))(oe||{}),ie=(e=>(e.NEVER="NEVER",e.WITH_LAST="WITH_LAST",e.WITH_UNDEFINED="WITH_UNDEFINED",e))(ie||{}),x=globalThis.Promise,_=class extends x{constructor(t){let n,r,i=false,s=(a,o=true,u)=>{if(!i)return queueMicrotask(()=>s(a,o,u));a(u),this._state=o?1:2,this.onFinalize.forEach(c=>O(c,o?[u]:[void 0,u],void 0));};super((a,o)=>{r=u=>s(o,false,u),n=u=>s(a,true,u),g(t)?O(t,[n,r],r):W(t)?t.then(n,r):t!==void 0&&n(t);}),this._state=0,this.onEarlyFinalize=[],this.onFinalize=[],this.resolve=a=>{var o,u;this.pending&&((o=this._resolve)==null||o.call(this,a),(u=this.onEarlyFinalize)==null||u.forEach(c=>{O(c,[true,a],void 0);}));},this.reject=a=>{var o,u;this.pending&&((o=this._reject)==null||o.call(this,a),(u=this.onEarlyFinalize)==null||u.forEach(c=>{O(c,[false,a],void 0);}));},i=true,this._resolve=n,this._reject=r;}get pending(){return this.state===0}get rejected(){return this.state===2}get resolved(){return this.state===1}get state(){return this._state}};_.all=e=>new _(x.all(e));_.allSettled=e=>new _(x.allSettled(e));_.any=e=>new _(x.any(e));_.race=e=>new _(x.race(e));_.reject=e=>{let t=new _;return queueMicrotask(()=>t.reject(e)),t};_.resolve=e=>new _(x.resolve(e));_.try=(e,...t)=>new _(O(e,t,n=>_.reject(n)));_.withResolvers=()=>{let e=new _;return {promise:e,reject:e.reject,resolve:e.resolve}};var Ne=_,P=Ne;function ae(e={}){let t=0;e=R(ae.defaults,e,[],"empty");let{onError:n,onIgnore:r,onResult:i}=e,{delay:s=0,ignoreStale:a,resolveError:o,resolveIgnored:u,thisArg:c,throttle:l}=e,d=null,f,b=new Map,y=!re(s);c!==void 0&&(n=n==null?void 0:n.bind(c),r=r==null?void 0:r.bind(c),i=i==null?void 0:i.bind(c));let m=A=>{for(let[v,h]of A){b.delete(v);let w=a&&h.sequence<f.sequence;if(!(h.resolved||h.started&&!w))switch(h.started&&(h.getPromise=(()=>h.result)),O(r,[h.getPromise],0),u){case "WITH_UNDEFINED":h.resolve(void 0);break;case "WITH_LAST":f==null||f.then(h.resolve,h.reject);break;}}b.size||(t=0);},p=A=>{if(d=null,y){b.delete(A);let[h,w]=[...b.entries()][0]||[];return h&&w&&T(h,w)}let v=[...b.entries()];if(l===true&&e.trailing){let h=v.findIndex(([w])=>w===A);v=v.slice(0,h);}else l||(v=v.slice(0,-1));m(v),b.delete(A);},E=async(A,v)=>{var h;try{v.started=!0,f=v,d=v,(h=v.result)!=null||(v.result=P.try(v.getPromise));let w=await v.result;if(!!a&&v.sequence<f.sequence)return m([[A,v]]);v.resolve(w),i&&O(i,[w],void 0);}catch(w){switch(n&&O(n,[w],void 0),o){case "REJECT":v.reject(w);case "NEVER":break;case "RESOLVE_UNDEFINED":v.resolve(void 0);break;case "RESOLVE_ERROR":v.resolve(w);break}}p(A);},T=y?E:je(E,s,e);return A=>{let v=Symbol("deferred-queue-item-id"),h=new P;return h.getPromise=g(A)?A:()=>A,h.started=false,h.sequence=++t,b.set(v,h),(!d||!y)&&T(v,h),h}}ae.defaults={delay:100,resolveError:"REJECT",resolveIgnored:"WITH_LAST"};var Le=ae;function k(e,t={}){let{thisArg:n}=t;n!==void 0&&(e=e.bind(n));let r=Le(t);return (...i)=>r(()=>e(...i))}var lt=k;function K(e=K.defaults.duration,t,n=false){let r=new P,i=s=>{let a=O(async()=>{let o=await(g(s)?s():s);return n?o!=null?o:new Error(`${K.defaults.delayTimeoutMsg} ${e}ms`):o!=null?o:e},[],o=>x.reject(o));n?a.then(r.reject,r.reject):r.resolve(a);};return r.timeoutId=setTimeout(()=>i(t),e),r.pause=()=>clearTimeout(r.timeoutId),r.catch(()=>{}).finally(()=>r.pause()),r.onEarlyFinalize.push(()=>r.pause()),r}K.defaults={duration:100,delayTimeoutMsg:"Timed out after"};var be=K;function Ue(e,t){return be(e,t,true)}var ze=Ue,$=(e,t)=>{let n=false,r=P.try(async()=>{var i,s;t=R($.defaults,t!=null?t:{},[],(p,E)=>{switch(p){case "retry":case "retryDelay":case "retryDelayJitterMax":return E!==0&&!te(E)}return !!ne(E)});let{retry:a,retryBackOff:o,retryDelay:u,retryDelayJitter:c,retryDelayJitterMax:l}=t,d=u,f=0,b,y,m=false;do{if(f++,u>0&&!n&&f>0){o==="exponential"&&f>1&&(d*=2);let p=c?Math.floor(Math.random()*l):0;await be(d+p);}if(n)break;try{y=void 0,b=await e();}catch(p){y=p!=null?p:new Error(p);}if(n||a===0||f>a)break;m=!!((s=await O((i=t.retryIf)!=null?i:y,[b,f,y],y))!=null?s:y);}while(m);return y!==void 0?x.reject(y):b});return r.onEarlyFinalize.push(()=>{n=true;}),r};$.defaults={retry:1,retryBackOff:"exponential",retryDelay:300,retryDelayJitter:true,retryDelayJitterMax:100};var ut=$,G=1e4,le=2147483647,ue=class extends P{constructor(e,t,n,r){super(e),this.started=new Date,this._setup=()=>{var i,s,a,o;this._signals=se([(s=(i=this.options)==null?void 0:i.abortCtrl)==null?void 0:s.signal,(a=this.options)==null?void 0:a.signal].filter(Boolean)),!this.onEarlyFinalize.includes(this._handleEarlyFinalize)&&this.onEarlyFinalize.push(this._handleEarlyFinalize),!this.onFinalize.includes(this._handleFinalize)&&this.onFinalize.push(this._handleFinalize),(o=this._signals)==null||o.forEach(u=>u==null?void 0:u.addEventListener("abort",this._handleAbort));},this._handleAbort=async()=>{var i;let a=await O((i=this.options)==null?void 0:i.onAbort,[],void 0);a!=null||(a=new Error(`Aborted after ${new Date().getTime()-this.started.getTime()}ms`)),(a.name)!=null||(a.name="AbortError"),this.reject(a);},this._handleEarlyFinalize=()=>{var i,s,a,o;(i=this.options)!=null&&i.abortOnEarlyFinalize&&((o=(a=(s=this.options)==null?void 0:s.abortCtrl)==null?void 0:a.abort)==null||o.call(a));},this._handleFinalize=((i,s)=>{var a,o,u,c,l;this.cancelAbort(),this.clearTimeout(),!(!this.timeout.rejected&&!((a=this._signals)!=null&&a.find(d=>d==null?void 0:d.aborted)))&&((c=(u=(o=this.options)==null?void 0:o.abortCtrl)==null?void 0:u.signal)==null?void 0:c.aborted)===false&&((l=this.options)==null||l.abortCtrl.abort(s));}),this.data=e,this.options=F(n)?n:{},this.timeout=t,this._signals=r,this._setup();}get abortCtrl(){return this.options.abortCtrl}get aborted(){var e;return this.rejected&&!this.timeout.rejected&&!!((e=this._signals)!=null&&e.find(t=>t==null?void 0:t.aborted))}cancelAbort(){var e;(e=this._signals)==null||e.forEach(t=>t==null?void 0:t.removeEventListener("abort",this._handleAbort));}clearTimeout(){clearTimeout(this.timeout.timeoutId);}get timedout(){return this.rejected&&this.timeout.rejected}},ct=ue;function B(e,...t){var n;let r=R(B.defaults,J(e)?{timeout:e}:F(e)?e:{},[],"empty");r.timeout=Math.min(re(r.timeout)?r.timeout:G,le);let i=t.map(o=>g(o)?P.try(o):o),s=i.length<=1?i[0]instanceof P?i[0]:new P(i[0]):(g(P[r.batchFunc])?P[r.batchFunc]:P.all)(i),a=ze(r.timeout,r.onTimeout);return new ct(P.race([s,a]),a,r,se([(n=r.abortCtrl)==null?void 0:n.signal,r.signal].filter(Boolean)))}B.defaults={abortOnEarlyFinalize:true,batchFunc:"all",timeout:G};var dt=B,D=class extends P{};D.deferred=Le;D.deferredCallback=lt;D.delay=be;D.delayReject=ze;D.retry=ut;D.timeout=dt;var ft=D,Oe=ft;var pe={};Te(pe,{ContentType:()=>H,FetchAs:()=>de,FetchError:()=>Z,ResolveError:()=>oe,ResolveIgnored:()=>ie,TIMEOUT_FALLBACK:()=>G,TIMEOUT_MAX:()=>le,TimeoutPromise:()=>ue,createClient:()=>qe,createPostClient:()=>Ve,default:()=>_e,executeInterceptors:()=>ke,fetch:()=>S,mergeOptions:()=>Be});var ke=async(e,t,n,...r)=>{var i;for(let s of [...n!=null?n:[]].filter(g)){if(t!=null&&t.aborted)break;e=(i=await O(s,[e,...r],void 0))!=null?i:e;}return e},X=ke;var Ee=(e,t={})=>{let n=g(t.fetchFunc)?t.fetchFunc:Ee.fetch;if(!te(t.retry))return n(e,t);let r=0;return $(()=>(r++,n(e,t)),{...t,retryIf:async(s,a,o)=>{var d,f;let{abortCtrl:u,retryIf:c,signal:l}=t;return l!=null&&l.aborted||(d=u==null?void 0:u.signal)!=null&&d.aborted?false:!!((f=await O(c,[s,a,o],void 0))!=null?f:o||!(s!=null&&s.ok))}}).catch(s=>Promise.reject(new Error(`Request failed after attempt #${r}`,{cause:s})))};Ee.fetch=globalThis.fetch;var $e=Ee;var Be=(...e)=>e.reduce((t,n)=>{var a;n=F(n)?n:{};let{headers:r,interceptors:i={}}=t,{interceptors:s={}}=n;return n.headers&&new Headers(n.headers).forEach((o,u)=>r.set(u,o)),{...t,...n,errMsgs:R(n.errMsgs,t.errMsgs,[],"empty"),headers:r,interceptors:{error:[...j(i==null?void 0:i.error),...j(s==null?void 0:s.error)],request:[...j(i==null?void 0:i.request),...j(s==null?void 0:s.request)],response:[...j(i==null?void 0:i.response),...j(s==null?void 0:s.response)],result:[...j(i==null?void 0:i.result),...j(s==null?void 0:s.result)]},timeout:(a=n.timeout)!=null?a:t.timeout}},{headers:new Headers}),M=Be,j=e=>U(e)?e:g(e)?[e]:[];var H={APPLICATION_JAVASCRIPT:"application/javascript",APPLICATION_JSON:"application/json",APPLICATION_OCTET_STREAM:"application/octet-stream",APPLICATION_PDF:"application/pdf",APPLICATION_X_WWW_FORM_URLENCODED:"application/x-www-form-urlencoded",APPLICATION_XML:"application/xml",APPLICATION_ZIP:"application/zip",AUDIO_MPEG:"audio/mpeg",MULTIPART_FORM_DATA:"multipart/form-data",TEXT_CSS:"text/css",TEXT_HTML:"text/html",TEXT_PLAIN:"text/plain",VIDEO_MP4:"video/mp4"},de=(o=>(o.arrayBuffer="arrayBuffer",o.blob="blob",o.bytes="bytes",o.formData="formData",o.json="json",o.response="response",o.text="text",o))(de||{});var Z=class e extends Error{constructor(t,n){super(t,{cause:n.cause}),this.name="FetchError",Object.defineProperties(this,{clone:{get(){return r=>new e(r,{cause:n.cause,options:n.options,response:n.response,url:n.url})}},options:{get(){return n.options}},response:{get(){return n.response}},url:{get(){return n.url}}});}};var He=Object.freeze({aborted:"Request aborted",invalidUrl:"Invalid URL",parseFailed:"Failed to parse response as",timedout:"Request timed out",requestFailed:"Request failed with status code:"}),Fe=(e,t={})=>{F(t)||(t={});let n,r=M({errMsgs:He},Fe.defaults,t);r.abortCtrl=r.abortCtrl instanceof AbortController?r.abortCtrl:new AbortController,(r.as)!=null||(r.as="response"),(r.method)!=null||(r.method="get"),(r.signal)!=null||(r.signal=r.abortCtrl.signal);let{abortCtrl:i,as:s,headers:a,onAbort:o,onTimeout:u}=r;return r.onAbort=async()=>{let f=await O(o,[],void 0);return await we(Se(f)?f:new Error(f),e,r,n)},r.onTimeout=async()=>{let f=await O(u,[],void 0);return await we(f!=null?f:new Error(r.errMsgs.timedout),e,r,n)},B(r,async()=>{var f,b,y,m;try{r.body=await O(r.body,[],C=>Promise.reject(C)),e=await X(e,i.signal,(f=r.interceptors)==null?void 0:f.request,r);let{body:p,errMsgs:E,validateUrl:T=!1}=r;if((b=r.signal)!=null||(r.signal=i.signal),T&&!xe(e,!1))throw new Error(E.invalidUrl);["delete","patch","post","put"].includes(`${r.method}`.toLowerCase())&&!["undefined","string"].includes(typeof p)&&F(p,!0)&&a.get("content-type")===H.APPLICATION_JSON&&(r.body=JSON.stringify(r.body)),n=await $e(e,r),n=await X(n,i.signal,(y=r.interceptors)==null?void 0:y.response,e,r);let v=n==null?void 0:n.status;if(!(v>=200&&v<300)){let C=await O(()=>{var Ae;return (Ae=n==null?void 0:n.clone())==null?void 0:Ae.json()},[],void 0);throw new Error(C,{cause:C})}let w=n[s],N=g(w)?w.bind(n)():n;return W(N)&&(N=await N.catch(C=>Promise.reject(new Error(`${E.parseFailed} ${s}. ${C==null?void 0:C.message}`,{cause:C})))),N=await X(N,i.signal,(m=r.interceptors)==null?void 0:m.result,e,r),N}catch(p){let E=p;return E=await we(p,e,r,n),Promise.reject(E)}})};Fe.defaults={abortOnEarlyFinalize:true,errMsgs:{...He},headers:new Headers,interceptors:{error:[],request:[],response:[],result:[]},timeout:6e4,validateUrl:false};var we=async(e,t,n,r)=>{var s,a,o;return await X(new Z(((s=e==null?void 0:e.message)!=null?s:e)||`${n.errMsgs.requestFailed} ${r==null?void 0:r.status}`,{cause:(a=e==null?void 0:e.cause)!=null?a:e,response:r,options:n,url:t}),void 0,(o=n.interceptors)==null?void 0:o.error,t,n)},I=Fe;var qe=(e,t,n)=>{function r(i,s){let a=M(I.defaults,t,s,e);return (a.as)!=null||(a.as="json"),I(i,a)}return r.deferred=(i,s,a)=>{let o;return k((...c)=>{var f;let l=M(I.defaults,t,a,s===void 0?c[1]:c[0],e);return (l.as)!=null||(l.as="json"),(f=o==null?void 0:o.abort)==null||f.call(o),o=new AbortController,I(s!=null?s:c[0],l)},{...n,...i})},r},fe=qe;var Ve=(e,t,n)=>{function r(i,s,a){let o=M(t,a,e);(o.as)!=null||(o.as="json"),o.body=s!=null?s:o.body,(o.method)!=null||(o.method="post");let u=o.headers;return u.get("content-type")||u.set("content-type",H.APPLICATION_JSON),I(i,o)}return r.deferred=(i,s,a,o)=>{let u;return k((...l)=>{var y,m;s!==void 0&&l.splice(0,0,s),a!==void 0&&l.splice(1,0,a);let d=M(I.defaults,t,o,l[2],e);(d.as)!=null||(d.as="json"),(y=u==null?void 0:u.abort)==null||y.call(u),u=new AbortController,d.body=(m=l[1])!=null?m:d.body,(d.method)!=null||(d.method="post");let f=d.headers;return f.get("content-type")||f.set("content-type",H.APPLICATION_JSON),I(l[0],d)},{...n,...i})},r},Y=Ve;var z={get:fe({method:"get"}),head:fe({method:"head"}),options:fe({method:"options"}),delete:Y({method:"delete"}),patch:Y({method:"patch"}),post:Y({method:"post"}),put:Y({method:"put"})},S=I;S.delete=z.delete;S.get=z.get;S.head=z.head;S.options=z.options;S.patch=z.patch;S.post=z.post;S.put=z.put;var _e=S;var he=_e;Object.keys(pe).forEach(e=>{["default","fetch"].includes(e)||(he[e])!=null||(he[e]=pe[e]);});var gr=he,me=Oe;Object.keys(ce).forEach(e=>{["default","PromisE"].includes(e)||(me[e])!=null||(me[e]=ce[e]);});var ve=globalThis;(ve.superutils)!=null||(ve.superutils={});var We;((We=ve.superutils).PromisE)!=null||(We.PromisE=me);return gr;})();//# sourceMappingURL=index.min.js.map
|
|
2
2
|
//# sourceMappingURL=index.min.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../promise/dist/index.js","../../../core/dist/index.js","../../src/index.ts","../../src/executeInterceptors.ts","../../src/getResponse.ts","../../src/mergeOptions.ts","../../src/types/constants.ts","../../src/types/FetchError.ts","../../src/fetch.ts","../../src/createClient.ts","../../src/createPostClient.ts","../../src/browser.ts"],"names":["dist_exports","__export","PromisE","PromisEBase","ResolveError","ResolveIgnored","TIMEOUT_FALLBACK","TIMEOUT_MAX","TimeoutPromise","index_default","deferred","deferredCallback","delay","delayReject","retry","timeout","isObj","x","strict","isArr","isInteger","isNumber","isPositiveInteger","isPositiveNumber","isEmpty","nonNumerable","fallback","proto","isFn","isUrl","isUrlValid","tldExceptions","url","y","_","isError","isPromise","isSymbol","fallbackIfFails","target","args","result","err","fallbackIfFails_default","objKeys","obj","sorted","includeSymbols","objKeys_default","clone","value","objCopy","input","output","ignoreKeys","override","recursive","_output","_ignoreKeys","inKeys","_key","key","ignoreChildKeys","arrUnique","arr","flatDepth","debounce","callback","config","leading","onError","thisArg","tid","_callback","firstArgs","leadingGlobal","debounce_default","throttle","d","trailing","handleCallback","trailArgs","cbArgs","throttle_default","options","Promise2","_PromisEBase","_resolve","_reject","superCalled","finalize","fn","resolve","fn2","reject","reason","_a","_b","values","promise","callbackFn","PromisEBase_default","ResolveError2","ResolveIgnored2","sequence","onIgnore","onResult","delay2","ignoreStale","resolveError","resolveIgnored","lastInSeries","lastExecuted","queue","isSequential","handleIgnore","items","iId","iItem","isStale","handleRemaining","currentId","nextId","nextItem","handleItem","currentIndex","id","executeItem","qItem","deferred_default","deferPromise","deferredCallback_default","duration","asRejected","result2","_result","_result2","delay_default","delayReject_default","func","finalized","maxRetries","retryBackOff","retryDelay","retryDelayJitter","retryDelayJitterMax","_retryDelay","retryCount","error","shouldRetry","retry_default","data","timeout2","_signals","_c","_d","signal","_e","s","TimeoutPromise_default","opts","promises","v","dataPromise","timeoutPromise","timeout_default","PromisE_default","index_exports","ContentType","FetchAs","FetchError","createClient","createPostClient","executeInterceptors","fetch","mergeOptions","interceptors","interceptor","executeInterceptors_default","getResponse","fetchFunc","attemptCount","res","count","abortCtrl","retryIf","getResponse_default","allOptions","merged","headers","ints1","ints2","toArr","mergeOptions_default","_FetchError","message","newMessage","defaultErrorMsgs","response","parseAs","onAbort","onTimeout","interceptErr","body","errMsgs","validateUrl","status","jsonError","parseFunc","_err","fetch_default","fixedOptions","commonOptions","commonDeferOptions","client","mergedOptions","deferOptions","defaultUrl","defaultOptions","_abortCtrl","createClient_default","defaultData","createPostClient_default","methods","browser_default","w"],"mappings":"mFAAA,IAAA,EAAA,CAAA,MAAA,CAAA,cAAA,CAAA,IAAA,EAAA,CAAA,CAAA,CAAA,CAAA,CAAA,GAAA,CAAA,IAAA,IAAA,CAAA,IAAA,CAAA,CAAA,EAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,GAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,UAAA,CAAA,IAAA,CAAA,EAAA,CAAA,CAAA,IAAAA,EAAAA,CAAA,EAAA,CAAAC,EAAAA,CAAAD,EAAAA,CAAA,aAAAE,CAAAA,CAAA,WAAA,CAAA,IAAAC,EAAAA,CAAA,YAAA,CAAA,IAAAC,GAAA,cAAA,CAAA,IAAAC,EAAAA,CAAA,gBAAA,CAAA,IAAAC,CAAAA,CAAA,gBAAAC,EAAAA,CAAA,cAAA,CAAA,IAAAC,EAAAA,CAAA,OAAA,CAAA,IAAAC,GAAA,QAAA,CAAA,IAAAC,EAAAA,CAAA,gBAAA,CAAA,IAAAC,CAAAA,CAAA,UAAAC,CAAAA,CAAA,WAAA,CAAA,IAAAC,EAAAA,CAAA,KAAA,CAAA,IAAAC,EAAA,OAAA,CAAA,IAAAC,CAAAA,CAAAA,CAAAA,CCcA,IAAIC,CAAAA,CAAQ,CAACC,CAAAA,CAAGC,CAAAA,CAAS,IAAA,GAAS,CAAC,CAACD,CAAAA,EAAK,OAAOA,CAAAA,EAAM,WAAa,CAACC,CAAAA,EAAU,CAC5E,MAAA,CAAO,UACP,IAEF,CAA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A,EACN,CAAC,CAAA,CACD,IAAOmK,EAAAA,CAAQlD,EAAAA,CAcT5K,GAAyBO,GAC/B,MAAA,CAAO,IAAA,CAAKT,EAAc,EAAE,OAAA,CAAQ6D,CAAAA,EAAO,CACtC,CAAC,SAAA,CAAW,SAAS,CAAA,CAAE,SAASA,CAAG,CAAA,EAAA,CACrC3D,EAAAA,CAAA2D,KAAA,IAAA,GAAA3D,EAAAA,CAAA2D,CAAAA,CAAAA,CACD7D,EAAAA,CACC6D,CAAG,CAAA,EACN,CAAC,CAAA,CACD,IAAMoK,GAAI,UAAA,CAzCVjI,CA0CAiI,EAAAA,CAAE,aAAF,IAAA,GAAAA,EAAAA,CAAE,UAAA,CAAe,IA1CjB,IAAAjI,EAAAA,CAAAC,CA2CAA,CAAAD,GAAAiI,EAAAA,CAAE,UAAA,EAAW,OAAA,GAAb,IAAA,GAAAjI,GAAa,OAAA,CAAY9F,EAAAA,CAAAA","file":"index.min.js","sourcesContent":["// src/deferred.ts\nimport {\n deferred as deferredSync,\n fallbackIfFails as fallbackIfFails2,\n isFn as isFn2,\n isPositiveNumber,\n objCopy\n} from \"@superutils/core\";\n\n// src/PromisEBase.ts\nimport { fallbackIfFails, isFn, isPromise } from \"@superutils/core\";\nvar Promise2 = globalThis.Promise;\nvar _PromisEBase = class _PromisEBase extends Promise2 {\n constructor(input) {\n let _resolve;\n let _reject;\n let superCalled = false;\n const finalize = (fn, resolve = true, value) => {\n if (!superCalled)\n return queueMicrotask(() => finalize(fn, resolve, value));\n fn(value);\n this._state = resolve ? 1 : 2;\n this.onFinalize.forEach(\n (fn2) => fallbackIfFails(\n fn2,\n resolve ? [value] : [void 0, value],\n void 0\n )\n );\n };\n super((resolve, reject) => {\n _reject = (reason) => finalize(reject, false, reason);\n _resolve = (value) => finalize(resolve, true, value);\n if (isFn(input)) {\n fallbackIfFails(input, [_resolve, _reject], _reject);\n } else if (isPromise(input)) {\n input.then(_resolve, _reject);\n } else if (input !== void 0) {\n _resolve(input);\n }\n });\n this._state = 0;\n /**\n * callbacks to be invoked whenever PromisE instance is finalized early using non-static resolve()/reject() methods */\n this.onEarlyFinalize = [];\n this.onFinalize = [];\n //\n //\n // --------------------------- Early resolve/reject ---------------------------\n //\n //\n /** Resovle pending promise early. */\n this.resolve = (value) => {\n var _a, _b;\n if (!this.pending) return;\n (_a = this._resolve) == null ? void 0 : _a.call(this, value);\n (_b = this.onEarlyFinalize) == null ? void 0 : _b.forEach((fn) => {\n fallbackIfFails(fn, [true, value], void 0);\n });\n };\n /** Reject pending promise early. */\n this.reject = (reason) => {\n var _a, _b;\n if (!this.pending) return;\n (_a = this._reject) == null ? void 0 : _a.call(this, reason);\n (_b = this.onEarlyFinalize) == null ? void 0 : _b.forEach((fn) => {\n fallbackIfFails(fn, [false, reason], void 0);\n });\n };\n superCalled = true;\n this._resolve = _resolve;\n this._reject = _reject;\n }\n //\n //\n //-------------------- Status related read-only attributes --------------------\n //\n //\n /** Indicates if the promise is still pending/unfinalized */\n get pending() {\n return this.state === 0;\n }\n /** Indicates if the promise has been rejected */\n get rejected() {\n return this.state === 2;\n }\n /** Indicates if the promise has been resolved */\n get resolved() {\n return this.state === 1;\n }\n /**\n * Get promise status code:\n *\n * - `0` = pending\n * - `1` = resolved\n * - `2` = rejected\n */\n get state() {\n return this._state;\n }\n};\n//\n//\n// Extend all static `Promise` methods\n//\n//\n/** Sugar for `new PromisE(Promise.all(...))` */\n_PromisEBase.all = (values) => new _PromisEBase(Promise2.all(values));\n/** Sugar for `new PromisE(Promise.allSettled(...))` */\n_PromisEBase.allSettled = (values) => new _PromisEBase(Promise2.allSettled(values));\n/** Sugar for `new PromisE(Promise.any(...))` */\n_PromisEBase.any = (values) => new _PromisEBase(Promise2.any(values));\n/** Sugar for `new PromisE(Promise.race(..))` */\n_PromisEBase.race = (values) => new _PromisEBase(Promise2.race(values));\n/** Extends Promise.reject */\n_PromisEBase.reject = (reason) => {\n const promise = new _PromisEBase();\n queueMicrotask(() => promise.reject(reason));\n return promise;\n};\n/** Sugar for `new PromisE(Promise.resolve(...))` */\n_PromisEBase.resolve = (value) => new _PromisEBase(Promise2.resolve(value));\n/** Sugar for `new PromisE(Promise.try(...))` */\n_PromisEBase.try = (callbackFn, ...args) => (\n // Promise.try is not supported in Node < 23.\n new _PromisEBase(\n fallbackIfFails(\n callbackFn,\n args,\n // rethrow error to ensure the returned promise is rejected\n (err) => _PromisEBase.reject(err)\n )\n )\n);\n/**\n * Creates a `PromisE` instance and returns it in an object, along with its `resolve` and `reject` functions.\n *\n * NB: this function is technically no longer needed because the `PromisE` class already comes with the resolvers.\n *\n * ---\n * @example\n * Using `PromisE` directly: simply provide an empty function as the executor\n *\n * ```typescript\n * import PromisE from '@superutils/promise'\n * const promisE = new PromisE<number>(() => {})\n * setTimeout(() => promisE.resolve(1), 1000)\n * promisE.then(console.log)\n * ```\n *\n * @example\n * Using `withResolvers`\n * ```typescript\n * import PromisE from '@superutils/promise'\n * const pwr = PromisE.withResolvers<number>()\n * setTimeout(() => pwr.resolve(1), 1000)\n * pwr.promise.then(console.log)\n * ```\n */\n_PromisEBase.withResolvers = () => {\n const promise = new _PromisEBase();\n return { promise, reject: promise.reject, resolve: promise.resolve };\n};\nvar PromisEBase = _PromisEBase;\nvar PromisEBase_default = PromisEBase;\n\n// src/types/deferred.ts\nvar ResolveError = /* @__PURE__ */ ((ResolveError2) => {\n ResolveError2[\"NEVER\"] = \"NEVER\";\n ResolveError2[\"REJECT\"] = \"REJECT\";\n ResolveError2[\"WITH_ERROR\"] = \"RESOLVE_ERROR\";\n ResolveError2[\"WITH_UNDEFINED\"] = \"RESOLVE_UNDEFINED\";\n return ResolveError2;\n})(ResolveError || {});\nvar ResolveIgnored = /* @__PURE__ */ ((ResolveIgnored2) => {\n ResolveIgnored2[\"NEVER\"] = \"NEVER\";\n ResolveIgnored2[\"WITH_LAST\"] = \"WITH_LAST\";\n ResolveIgnored2[\"WITH_UNDEFINED\"] = \"WITH_UNDEFINED\";\n return ResolveIgnored2;\n})(ResolveIgnored || {});\n\n// src/deferred.ts\nfunction deferred(options = {}) {\n let sequence = 0;\n options = objCopy(\n deferred.defaults,\n options,\n [],\n \"empty\"\n );\n let { onError, onIgnore, onResult } = options;\n const {\n delay: delay2 = 0,\n ignoreStale,\n resolveError,\n resolveIgnored,\n thisArg,\n throttle\n } = options;\n let lastInSeries = null;\n let lastExecuted;\n const queue = /* @__PURE__ */ new Map();\n const isSequential = !isPositiveNumber(delay2);\n if (thisArg !== void 0) {\n onError = onError == null ? void 0 : onError.bind(thisArg);\n onIgnore = onIgnore == null ? void 0 : onIgnore.bind(thisArg);\n onResult = onResult == null ? void 0 : onResult.bind(thisArg);\n }\n const handleIgnore = (items) => {\n for (const [iId, iItem] of items) {\n queue.delete(iId);\n const isStale = ignoreStale && iItem.sequence < lastExecuted.sequence;\n if (iItem.resolved || iItem.started && !isStale) continue;\n if (iItem.started) {\n iItem.getPromise = (() => iItem.result);\n }\n fallbackIfFails2(onIgnore, [iItem.getPromise], 0);\n switch (resolveIgnored) {\n case \"WITH_UNDEFINED\" /* WITH_UNDEFINED */:\n iItem.resolve(void 0);\n break;\n case \"WITH_LAST\" /* WITH_LAST */:\n lastExecuted == null ? void 0 : lastExecuted.then(iItem.resolve, iItem.reject);\n break;\n case \"NEVER\" /* NEVER */:\n break;\n }\n }\n if (!queue.size) sequence = 0;\n };\n const handleRemaining = (currentId) => {\n lastInSeries = null;\n if (isSequential) {\n queue.delete(currentId);\n const [nextId, nextItem] = [...queue.entries()][0] || [];\n return nextId && nextItem && handleItem(nextId, nextItem);\n }\n let items = [...queue.entries()];\n if (throttle === true && options.trailing) {\n const currentIndex = items.findIndex(([id]) => id === currentId);\n items = items.slice(0, currentIndex);\n } else if (!throttle) {\n items = items.slice(0, -1);\n }\n handleIgnore(items);\n queue.delete(currentId);\n };\n const executeItem = async (id, qItem) => {\n var _a;\n try {\n qItem.started = true;\n lastExecuted = qItem;\n lastInSeries = qItem;\n (_a = qItem.result) != null ? _a : qItem.result = PromisEBase_default.try(qItem.getPromise);\n const result = await qItem.result;\n const isStale = !!ignoreStale && qItem.sequence < lastExecuted.sequence;\n if (isStale) return handleIgnore([[id, qItem]]);\n qItem.resolve(result);\n onResult && fallbackIfFails2(onResult, [result], void 0);\n } catch (err) {\n onError && fallbackIfFails2(onError, [err], void 0);\n switch (resolveError) {\n case \"REJECT\" /* REJECT */:\n qItem.reject(err);\n // eslint-disable-next-line no-fallthrough\n case \"NEVER\" /* NEVER */:\n break;\n case \"RESOLVE_UNDEFINED\" /* WITH_UNDEFINED */:\n qItem.resolve(void 0);\n break;\n case \"RESOLVE_ERROR\" /* WITH_ERROR */:\n qItem.resolve(err);\n break;\n }\n }\n handleRemaining(id);\n };\n const handleItem = isSequential ? executeItem : deferredSync(\n executeItem,\n delay2,\n options\n );\n return (promise) => {\n const id = /* @__PURE__ */ Symbol(\"deferred-queue-item-id\");\n const qItem = new PromisEBase_default();\n qItem.getPromise = isFn2(promise) ? promise : () => promise;\n qItem.started = false;\n qItem.sequence = ++sequence;\n queue.set(id, qItem);\n if (!lastInSeries || !isSequential) handleItem(id, qItem);\n return qItem;\n };\n}\ndeferred.defaults = {\n /**\n * Default delay in milliseconds, used in `debounce` and `throttle` modes.\n *\n * Use `0` (or negative number) to disable debounce/throttle and execute all operations sequentially.\n */\n delay: 100,\n /** Set the default error resolution behavior. {@link ResolveError} for all options. */\n resolveError: \"REJECT\" /* REJECT */,\n /** Set the default ignored resolution behavior. See {@link ResolveIgnored} for all options. */\n resolveIgnored: \"WITH_LAST\" /* WITH_LAST */\n};\nvar deferred_default = deferred;\n\n// src/deferredCallback.ts\nfunction deferredCallback(callback, options = {}) {\n const { thisArg } = options;\n if (thisArg !== void 0) callback = callback.bind(thisArg);\n const deferPromise = deferred_default(options);\n return (...args) => deferPromise(() => callback(...args));\n}\nvar deferredCallback_default = deferredCallback;\n\n// src/delay.ts\nimport { fallbackIfFails as fallbackIfFails3, isFn as isFn3 } from \"@superutils/core\";\nfunction delay(duration = delay.defaults.duration, result, asRejected = false) {\n const promise = new PromisEBase_default();\n const finalize = (result2) => {\n const _result = fallbackIfFails3(\n async () => {\n const _result2 = await (isFn3(result2) ? result2() : result2);\n return !asRejected ? _result2 != null ? _result2 : duration : _result2 != null ? _result2 : new Error(\n `${delay.defaults.delayTimeoutMsg} ${duration}ms`\n );\n },\n [],\n // when result is a function and it fails/rejects,\n // promise will reject even if `asRejected = false`\n (err) => Promise.reject(err)\n );\n !asRejected ? promise.resolve(_result) : _result.then(promise.reject, promise.reject);\n };\n promise.timeoutId = setTimeout(() => finalize(result), duration);\n promise.pause = () => clearTimeout(promise.timeoutId);\n promise.catch(() => {\n }).finally(() => promise.pause());\n promise.onEarlyFinalize.push(() => promise.pause());\n return promise;\n}\ndelay.defaults = {\n /** Default delay duration in milliseconds */\n duration: 100,\n /** Default timed out message (if `result` is not provided) */\n delayTimeoutMsg: \"Timed out after\"\n};\nvar delay_default = delay;\n\n// src/delayReject.ts\nfunction delayReject(duration, reason) {\n return delay_default(duration, reason, true);\n}\nvar delayReject_default = delayReject;\n\n// src/retry.ts\nimport {\n fallbackIfFails as fallbackIfFails4,\n isEmpty,\n isPositiveInteger,\n objCopy as objCopy2\n} from \"@superutils/core\";\nvar retry = (func, options) => {\n let finalized = false;\n const promise = PromisEBase_default.try(async () => {\n var _a, _b;\n options = objCopy2(retry.defaults, options != null ? options : {}, [], (key, value) => {\n switch (key) {\n // case 'retryDelayJitter':\n // \treturn true\n case \"retry\":\n // eslint-disable-next-line no-fallthrough\n case \"retryDelay\":\n case \"retryDelayJitterMax\":\n return value !== 0 && !isPositiveInteger(value);\n }\n return !!isEmpty(value);\n });\n const {\n retry: maxRetries,\n retryBackOff,\n retryDelay,\n retryDelayJitter,\n retryDelayJitterMax\n } = options;\n let _retryDelay = retryDelay;\n let retryCount = -1;\n let result;\n let error;\n let shouldRetry = false;\n do {\n retryCount++;\n if (retryBackOff === \"exponential\" && retryCount > 1)\n _retryDelay *= 2;\n if (retryDelayJitter)\n _retryDelay += Math.floor(Math.random() * retryDelayJitterMax);\n if (!finalized && retryCount > 0) await delay_default(_retryDelay);\n if (!finalized) {\n try {\n error = void 0;\n result = await func();\n } catch (err) {\n error = err != null ? err : new Error(err);\n }\n }\n if (finalized || maxRetries === 0 || retryCount >= maxRetries) break;\n shouldRetry = !!((_b = await fallbackIfFails4(\n (_a = options.retryIf) != null ? _a : error,\n // if `retryIf` not provided, retry on error\n [result, retryCount, error],\n error\n // if `retryIf` throws error, default to retry on error\n )) != null ? _b : error);\n } while (shouldRetry);\n if (error !== void 0) return Promise.reject(error);\n return result;\n });\n promise.onEarlyFinalize.push(() => {\n finalized = true;\n });\n return promise;\n};\nretry.defaults = {\n retry: 1,\n retryBackOff: \"exponential\",\n retryDelay: 300,\n retryDelayJitter: true,\n retryDelayJitterMax: 100\n};\nvar retry_default = retry;\n\n// src/timeout.ts\nimport {\n arrUnique as arrUnique2,\n isFn as isFn4,\n isNumber,\n isObj as isObj2,\n isPositiveNumber as isPositiveNumber2,\n objCopy as objCopy3\n} from \"@superutils/core\";\n\n// src/TimeoutPromise.ts\nimport { arrUnique, fallbackIfFails as fallbackIfFails5, isObj } from \"@superutils/core\";\nvar TIMEOUT_FALLBACK = 1e4;\nvar TIMEOUT_MAX = 2147483647;\nvar TimeoutPromise = class extends PromisEBase_default {\n constructor(data, timeout2, options, _signals) {\n super(data);\n this.started = /* @__PURE__ */ new Date();\n this._setup = () => {\n var _a, _b, _c, _d;\n this._signals = arrUnique(\n [(_b = (_a = this.options) == null ? void 0 : _a.abortCtrl) == null ? void 0 : _b.signal, (_c = this.options) == null ? void 0 : _c.signal].filter(\n Boolean\n )\n );\n !this.onEarlyFinalize.includes(this._handleEarlyFinalize) && this.onEarlyFinalize.push(this._handleEarlyFinalize);\n !this.onFinalize.includes(this._handleFinalize) && this.onFinalize.push(this._handleFinalize);\n (_d = this._signals) == null ? void 0 : _d.forEach(\n (signal) => signal == null ? void 0 : signal.addEventListener(\n \"abort\",\n this._handleAbort\n )\n );\n };\n this._handleAbort = async () => {\n var _a, _b;\n let err = await fallbackIfFails5((_a = this.options) == null ? void 0 : _a.onAbort, [], void 0);\n err != null ? err : err = new Error(\n `Aborted after ${(/* @__PURE__ */ new Date()).getTime() - this.started.getTime()}ms`\n );\n (_b = err.name) != null ? _b : err.name = \"AbortError\";\n this.reject(err);\n };\n this._handleEarlyFinalize = () => {\n var _a, _b, _c, _d;\n ((_a = this.options) == null ? void 0 : _a.abortOnEarlyFinalize) && ((_d = (_c = (_b = this.options) == null ? void 0 : _b.abortCtrl) == null ? void 0 : _c.abort) == null ? void 0 : _d.call(_c));\n };\n // cleanup after execution\n this._handleFinalize = ((_, err) => {\n var _a, _b, _c, _d, _e;\n this.cancelAbort();\n this.clearTimeout();\n if (!this.timeout.rejected && !((_a = this._signals) == null ? void 0 : _a.find((x) => x == null ? void 0 : x.aborted)))\n return;\n ((_d = (_c = (_b = this.options) == null ? void 0 : _b.abortCtrl) == null ? void 0 : _c.signal) == null ? void 0 : _d.aborted) === false && ((_e = this.options) == null ? void 0 : _e.abortCtrl.abort(err));\n });\n this.data = data;\n this.options = isObj(options) ? options : {};\n this.timeout = timeout2;\n this._signals = _signals;\n this._setup();\n }\n get abortCtrl() {\n return this.options.abortCtrl;\n }\n get aborted() {\n var _a;\n return this.rejected && !this.timeout.rejected && !!((_a = this._signals) == null ? void 0 : _a.find((s) => s == null ? void 0 : s.aborted));\n }\n cancelAbort() {\n var _a;\n (_a = this._signals) == null ? void 0 : _a.forEach(\n (signal) => signal == null ? void 0 : signal.removeEventListener(\n \"abort\",\n this._handleAbort\n )\n );\n }\n clearTimeout() {\n clearTimeout(this.timeout.timeoutId);\n }\n get timedout() {\n return this.rejected && this.timeout.rejected;\n }\n};\nvar TimeoutPromise_default = TimeoutPromise;\n\n// src/timeout.ts\nfunction timeout(options, ...values) {\n var _a;\n const opts = objCopy3(\n timeout.defaults,\n isNumber(options) ? { timeout: options } : isObj2(options) ? options : {},\n [],\n \"empty\"\n );\n opts.timeout = Math.min(\n isPositiveNumber2(opts.timeout) ? opts.timeout : TIMEOUT_FALLBACK,\n TIMEOUT_MAX\n );\n const promises = values.map(\n (v) => isFn4(v) ? PromisEBase_default.try(v) : v\n );\n const dataPromise = promises.length <= 1 ? (\n // single promise resolves to a single result\n promises[0] instanceof PromisEBase_default ? promises[0] : new PromisEBase_default(promises[0])\n ) : (\n // multiple promises resolve to an array of results\n (isFn4(PromisEBase_default[opts.batchFunc]) ? PromisEBase_default[opts.batchFunc] : PromisEBase_default.all)(promises)\n );\n const timeoutPromise = delayReject_default(opts.timeout, opts.onTimeout);\n return new TimeoutPromise_default(\n PromisEBase_default.race([dataPromise, timeoutPromise]),\n timeoutPromise,\n opts,\n arrUnique2(\n [(_a = opts.abortCtrl) == null ? void 0 : _a.signal, opts.signal].filter(Boolean)\n )\n );\n}\ntimeout.defaults = {\n abortOnEarlyFinalize: true,\n batchFunc: \"all\",\n timeout: TIMEOUT_FALLBACK\n};\nvar timeout_default = timeout;\n\n// src/PromisE.ts\nvar PromisE = class extends PromisEBase_default {\n};\nPromisE.deferred = deferred_default;\nPromisE.deferredCallback = deferredCallback_default;\nPromisE.delay = delay_default;\nPromisE.delayReject = delayReject_default;\nPromisE.retry = retry_default;\nPromisE.timeout = timeout_default;\nvar PromisE_default = PromisE;\n\n// src/index.ts\nvar index_default = PromisE_default;\nexport {\n PromisE,\n PromisEBase,\n ResolveError,\n ResolveIgnored,\n TIMEOUT_FALLBACK,\n TIMEOUT_MAX,\n TimeoutPromise,\n index_default as default,\n deferred,\n deferredCallback,\n delay,\n delayReject,\n retry,\n timeout\n};\n","// src/curry.ts\nfunction curry(func, ...[arity = func.length]) {\n const curriedFn = (...args) => {\n const _args = args;\n if (_args.length >= arity) return func(...args);\n return (...nextArgs) => curriedFn(\n ..._args,\n ...nextArgs\n );\n };\n return curriedFn;\n}\n\n// src/is/isObj.ts\nvar isObj = (x, strict = true) => !!x && typeof x === \"object\" && (!strict || [\n Object.prototype,\n null\n // when an object is created using `Object.create(null)`\n].includes(Object.getPrototypeOf(x)));\nvar isObj_default = isObj;\n\n// src/is/isArr.ts\nvar isArr = (x) => Array.isArray(x);\nvar isArrObj = (x, strict = true) => isArr(x) && x.every((x2) => isObj(x2, strict));\nvar isArr2D = (x) => isArr(x) && x.every(isArr);\nvar isArrLike = (x) => isArr(x) || x instanceof Set || x instanceof Map;\nvar isArrLikeSafe = (x) => [\"[object Array]\", \"[object Map]\", \"[object Set]\"].includes(\n Object.prototype.toString.call(x)\n);\nvar isArrUnique = (x) => isArr(x) && new Set(x).size === x.length;\nvar isUint8Arr = (x) => x instanceof Uint8Array;\nvar isArr_default = isArr;\n\n// src/is/isDate.ts\nvar isDate = (x) => x instanceof Date;\nvar isDateValid = (date) => {\n const dateIsStr = typeof date === \"string\";\n if (!dateIsStr && !isDate(date)) return false;\n const dateObj = new Date(date);\n if (Number.isNaN(dateObj.getTime())) return false;\n if (!dateIsStr) return true;\n const [original, converted] = [date, dateObj.toISOString()].map(\n (y) => y.replace(/[TZ]/g, \"\").substring(0, 10)\n );\n return original === converted;\n};\nvar isDate_default = isDate;\n\n// src/is/isNumber.ts\nvar isInteger = (x) => Number.isInteger(x);\nvar isNegativeInteger = (x) => Number.isInteger(x) && x < 0;\nvar isNegativeNumber = (x) => isNumber(x) && x < 0;\nvar isNumber = (x) => typeof x === \"number\" && !Number.isNaN(x) && Number.isFinite(x);\nvar isPositiveInteger = (x) => isInteger(x) && x > 0;\nvar isPositiveNumber = (x) => isNumber(x) && x > 0;\n\n// src/is/isEmpty.ts\nvar isEmpty = (x, nonNumerable = false, fallback = false) => {\n if (x === null || x === void 0) return true;\n switch (typeof x) {\n case \"number\":\n return !isNumber(x);\n case \"string\":\n return !x.replaceAll(\"\t\", \"\").trim().length;\n case \"boolean\":\n case \"bigint\":\n case \"symbol\":\n case \"function\":\n return false;\n }\n if (x instanceof Date) return Number.isNaN(x.getTime());\n if (x instanceof Map || x instanceof Set) return !x.size;\n if (Array.isArray(x) || x instanceof Uint8Array) return !x.length;\n if (x instanceof Error) return !x.message.length;\n const proto = typeof x === \"object\" && Object.getPrototypeOf(x);\n if (proto === Object.prototype || proto === null) {\n return nonNumerable ? !Object.getOwnPropertyNames(x).length : !Object.keys(x).length;\n }\n return fallback;\n};\nvar isEmptySafe = (x, numberableOnly = false) => {\n const empty = isEmpty(x, numberableOnly, 0);\n if (empty !== 0) return empty;\n switch (Object.prototype.toString.call(x)) {\n case \"[object Uint8Array]\":\n return !x.length;\n case \"[object Date]\":\n return Number.isNaN(x.getTime());\n case \"[object Map]\":\n return !x.size;\n case \"[object Object]\":\n return !Object.keys(x).length;\n case \"[object Set]\":\n return !x.size;\n default:\n return false;\n }\n};\nvar isEmpty_default = isEmpty;\n\n// src/is/isEnv.ts\nvar isEnvBrowser = () => typeof window !== \"undefined\" && typeof (window == null ? void 0 : window.document) !== \"undefined\";\nvar isEnvNode = () => {\n var _a;\n return typeof process !== \"undefined\" && ((_a = process == null ? void 0 : process.versions) == null ? void 0 : _a.node) != null;\n};\nvar isEnvTouchable = () => {\n var _a, _b;\n return typeof window !== \"undefined\" && \"ontouchstart\" in ((_b = (_a = window == null ? void 0 : window.document) == null ? void 0 : _a.documentElement) != null ? _b : {});\n};\n\n// src/noop.ts\nfunction noop() {\n}\nasync function noopAsync() {\n}\n\n// src/is/isFn.ts\nvar isFn = (x) => typeof x === \"function\";\nvar isAsyncFn = (x) => x instanceof noopAsync.constructor && x[Symbol.toStringTag] === \"AsyncFunction\";\nvar isFn_default = isFn;\n\n// src/is/isMap.ts\nvar isMap = (x) => x instanceof Map;\nvar isMapObj = (x, strict = true) => isMap(x) && [...x.values()].every((value) => isObj_default(value, strict));\n\n// src/is/isUrl.ts\nvar isUrl = (x) => x instanceof URL;\nvar isUrlValid = (x, strict = true, tldExceptions = [\"localhost\"]) => {\n if (!x) return false;\n try {\n if (typeof x !== \"string\" && !isUrl(x)) return false;\n const url = isUrl(x) ? x : new URL(x);\n if (!strict) return true;\n const gotTld = tldExceptions.includes(url.hostname) || url.host.split(\".\").length > 1;\n if (!gotTld) return false;\n let y = `${x}`;\n if (y.endsWith(url.hostname)) y += \"/\";\n return url.href === y;\n } catch (_) {\n return false;\n }\n};\nvar isUrl_default = isUrl;\n\n// src/is/index.ts\nvar isBool = (x) => typeof x === \"boolean\" || x instanceof Boolean;\nvar isDefined = (x) => x !== void 0 && x !== null;\nvar isError = (x) => x instanceof Error;\nvar isPromise = (x) => x instanceof Promise;\nvar isRegExp = (x) => x instanceof RegExp;\nvar isSet = (x) => x instanceof Set;\nvar isStr = (x) => typeof x === \"string\";\nvar isSubjectLike = (x, withValue = false) => isObj_default(x, false) && isFn_default(x.subscribe) && isFn_default(x.next) && (!withValue || \"value\" in x);\nvar isSymbol = (x) => typeof x === \"symbol\";\nvar is = {\n arr: isArr_default,\n arr2D: isArr2D,\n arrLike: isArrLike,\n arrLikeSafe: isArrLikeSafe,\n arrObj: isArrObj,\n arrUnique: isArrUnique,\n asyncFn: isAsyncFn,\n bool: isBool,\n date: isDate_default,\n dateValid: isDateValid,\n defined: isDefined,\n empty: isEmpty_default,\n emptySafe: isEmptySafe,\n envBrowser: isEnvBrowser,\n envNode: isEnvNode,\n envTouchable: isEnvTouchable,\n error: isError,\n fn: isFn_default,\n integer: isInteger,\n map: isMap,\n mapObj: isMapObj,\n negativeInteger: isNegativeInteger,\n negativeNumber: isNegativeNumber,\n number: isNumber,\n obj: isObj_default,\n positiveInteger: isPositiveInteger,\n positiveNumber: isPositiveNumber,\n promise: isPromise,\n regExp: isRegExp,\n set: isSet,\n str: isStr,\n subjectLike: isSubjectLike,\n symbol: isSymbol,\n uint8Arr: isUint8Arr,\n url: isUrl_default,\n urlValid: isUrlValid\n};\n\n// src/fallbackIfFails.ts\nvar fallbackIfFails = (target, args, fallback) => {\n try {\n const result = !isFn(target) ? target : target(...isFn(args) ? args() : args);\n if (!isPromise(result)) return result;\n return result.catch(\n (err) => isFn(fallback) ? fallback(err) : fallback\n );\n } catch (err) {\n return isFn(fallback) ? fallback(err) : fallback;\n }\n};\nvar fallbackIfFails_default = fallbackIfFails;\n\n// src/toDatetimeLocal.ts\nvar toDatetimeLocal = (dateStr) => {\n const date = new Date(dateStr);\n if (!isDateValid(date)) return \"\";\n const year = date.getFullYear();\n const month = (date.getMonth() + 1).toString().padStart(2, \"0\");\n const day = date.getDate().toString().padStart(2, \"0\");\n const hours = date.getHours().toString().padStart(2, \"0\");\n const minutes = date.getMinutes().toString().padStart(2, \"0\");\n const res = `${year}-${month}-${day}T${hours}:${minutes}`;\n return res;\n};\n(/* @__PURE__ */ new Date()).getTime();\n\n// src/obj/objClean.ts\nvar objClean = (obj, keys, ignoreIfNotExist = true) => {\n const result = {};\n if (!isObj(obj) || !isArr(keys)) return result;\n const uniqKeys = arrUnique(\n keys.map((x) => String(x).split(\".\")[0])\n ).sort();\n for (const key of uniqKeys) {\n if (ignoreIfNotExist && !obj.hasOwnProperty(key)) continue;\n const value = obj[key];\n if (!isObj(value) || isSymbol(key)) {\n result[key] = value;\n continue;\n }\n const childPrefix = `${key}.`;\n const childKeys = keys.filter((k) => {\n var _a;\n return (_a = k == null ? void 0 : k.startsWith) == null ? void 0 : _a.call(k, childPrefix);\n }).map((k) => k.split(childPrefix)[1]);\n if (!childKeys.length) {\n result[key] = value;\n continue;\n }\n result[key] = objClean(\n value,\n childKeys\n );\n }\n return result;\n};\n\n// src/obj/objKeys.ts\nvar objKeys = (obj, sorted = true, includeSymbols = true) => (\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion\n fallbackIfFails_default(\n () => [\n ...includeSymbols && Object.getOwnPropertySymbols(obj) || [],\n ...sorted ? Object.keys(obj).sort() : Object.keys(obj)\n ],\n [],\n []\n )\n);\nvar objKeys_default = objKeys;\n\n// src/obj/objCopy.ts\nvar clone = (value, fallback = \"null\") => JSON.parse(fallbackIfFails_default(JSON.stringify, [value], fallback));\nvar objCopy = (input, output, ignoreKeys, override = false, recursive = true) => {\n const _output = isObj(output, false) || isFn(output) ? output : {};\n if (!isObj(input, false) && !isFn(output)) return _output;\n const _ignoreKeys = new Set(ignoreKeys != null ? ignoreKeys : []);\n const inKeys = objKeys_default(input, true, true).filter(\n (x) => !_ignoreKeys.has(x)\n );\n for (const _key of inKeys) {\n const key = _key;\n const value = input[key];\n const skip = _output.hasOwnProperty(key) && (override === \"empty\" ? !isEmpty(_output[key]) : isFn(override) ? !override(key, _output[key], value) : true);\n if (skip) continue;\n const isPrimitive = [void 0, null, Infinity, NaN].includes(value) || !isObj(value, false);\n if (isPrimitive) {\n _output[key] = value;\n continue;\n }\n _output[key] = (() => {\n switch (Object.getPrototypeOf(value)) {\n case Array.prototype:\n return clone(value, \"[]\");\n case ArrayBuffer.prototype:\n return value.slice(0);\n case Date.prototype:\n return new Date(value.getTime());\n case Map.prototype:\n return new Map(\n clone(\n Array.from(\n value\n ),\n \"[]\"\n )\n );\n case RegExp.prototype:\n return new RegExp(value);\n case Set.prototype:\n return new Set(\n clone(Array.from(value))\n );\n case Uint8Array.prototype:\n return new Uint8Array([...value]);\n case URL.prototype:\n return new URL(value);\n default:\n break;\n }\n if (isSymbol(key) || !recursive) return clone(value);\n const ignoreChildKeys = [..._ignoreKeys].map(\n (x) => String(x).startsWith(String(key).concat(\".\")) && String(x).split(String(key).concat(\".\"))[1]\n ).filter(Boolean);\n if (!ignoreChildKeys.length) return clone(value);\n return objCopy(\n value,\n _output[key],\n ignoreChildKeys,\n override,\n recursive\n );\n })();\n }\n return _output;\n};\n\n// src/obj/objCreate.ts\nvar objCreate = (keys = [], values = [], result) => {\n if (!isObj(result)) result = {};\n for (let i = 0; i < (isArr(keys) ? keys : []).length; i++) {\n ;\n result[keys[i]] = values == null ? void 0 : values[i];\n }\n return result;\n};\n\n// src/obj/objHasKeys.ts\nfunction objHasKeys(input = {}, keys = [], requireValue = false) {\n if (!isObj(input) || !isArr(keys)) return false;\n for (const key of keys) {\n if (!input.hasOwnProperty(key)) return false;\n if (requireValue && isEmpty(input[key])) return false;\n }\n return true;\n}\n\n// src/obj/objReadOnly.ts\nvar objReadOnly = (obj, config) => {\n if (!isObj(obj, false)) obj = {};\n const { add, revocable, silent = true } = config != null ? config : {};\n const [typeTitle, keyTitle] = isArr(obj) ? [\"array\", \"index\"] : [\"object\", \"property name\"];\n function handleSetProp(obj2, key, value) {\n const isUpdate = obj2[key] !== void 0;\n if (isUpdate && silent) return true;\n const allowAddition = !isUpdate && (!isFn(add) ? add : add(obj2, key, value));\n const shouldThrow = !silent && (isUpdate || !allowAddition);\n if (shouldThrow)\n throw new TypeError(\n `Mutation not allow on read-only ${typeTitle} ${keyTitle}: ${key.toString()}`\n );\n if (!allowAddition) return true;\n obj2[key] = value;\n return true;\n }\n const proxyHandler = {\n get: (obj2, key) => obj2[key],\n set: handleSetProp,\n defineProperty: (obj2, key, { value }) => handleSetProp(obj2, key, value),\n // Prevent removal of properties\n deleteProperty: (obj2, key) => {\n if (!silent && obj2.hasOwnProperty(key)) {\n throw new Error(\n `Mutation not allow on read-only ${typeTitle} ${keyTitle}: ${key.toString()}`\n );\n }\n return true;\n }\n };\n return revocable ? Proxy.revocable(obj, proxyHandler) : new Proxy(obj, proxyHandler);\n};\n\n// src/obj/objSetProp.ts\nvar objSetProp = (obj, key, falsyValue, condition, truthyValue) => {\n var _a;\n const result = !isObj(obj, false) ? {} : obj;\n falsyValue != null ? falsyValue : falsyValue = result[key];\n condition = isFn(condition) ? condition((_a = result[key]) != null ? _a : falsyValue, key, obj) : condition;\n result[key] = !condition ? falsyValue : truthyValue;\n return result;\n};\nvar objSetPropUndefined = (...[obj, key, ...args]) => (obj == null ? void 0 : obj[key]) === void 0 && objSetProp(obj, key, ...args) || obj;\n\n// src/obj/objSort.ts\nvar objSort = (obj, recursive = true, _done = /* @__PURE__ */ new Map()) => {\n const sorted = {};\n if (!isObj(obj)) return sorted;\n for (const key of objKeys_default(obj)) {\n const value = obj[key];\n _done.set(value, true);\n sorted[key] = !recursive || !isObj(value) ? value : objSort(\n value,\n recursive,\n _done\n );\n }\n return sorted;\n};\n\n// src/obj/objWithoutKeys.ts\nvar objWithoutKeys = (input, keys, output) => {\n if (!isObj(input, false)) return {};\n if (!isArr(keys) || !keys.length) return input;\n output = {\n ...isObj(output, false) && output,\n ...input\n };\n for (const key of keys) delete output[key];\n return output;\n};\n\n// src/arr/arrReadOnly.ts\nvar arrReadOnly = (arr, config = {}) => objReadOnly(new ReadOnlyArrayHelper(config, arr), config);\nvar ReadOnlyArrayHelper = class extends Array {\n constructor(config, arr) {\n var _a;\n (_a = config.silent) != null ? _a : config.silent = true;\n super(...arr);\n this.config = config;\n this.ignoreOrThrow = (returnValue) => {\n if (this.config.silent) return returnValue;\n throw new Error(\"Mutation not allowed on read-only array\");\n };\n this.pop = () => this.ignoreOrThrow(this[this.length - 1]);\n this.push = (...items) => !this.config.add ? this.ignoreOrThrow(this.length) : super.push(...items);\n this.reverse = () => this.ignoreOrThrow(this);\n this.shift = () => this.ignoreOrThrow(this[0]);\n this.splice = (..._ignoredArgs) => this.ignoreOrThrow([]);\n this.unshift = (..._ignoredArgs) => this.ignoreOrThrow(this.length);\n }\n // fromAsync = super.fromAsync\n // reduce = super.reduce\n // reduceRight = super.reduceRight\n};\n\n// src/arr/arrReverse.ts\nvar arrReverse = (arr, reverse2 = true, newArray = false) => {\n if (!isArr(arr)) return [];\n if (newArray) arr = [...arr];\n return reverse2 ? arr.reverse() : arr;\n};\n\n// src/arr/arrToMap.ts\nfunction arrToMap(arr, key, flatDepth = 0) {\n ;\n [key, flatDepth] = isNumber(key) ? [void 0, key] : [key, flatDepth];\n const flatEntries = (!isArr(arr) ? [] : flatDepth > 0 ? arr.flat(flatDepth) : arr).map((item, i, flatArr) => {\n var _a;\n return [\n (_a = isFn(key) ? key(item, i, flatArr) : isObj(item) && isDefined(key) ? item[key] : i) != null ? _a : i,\n item\n ];\n });\n return new Map(flatEntries);\n}\n\n// src/arr/arrUnique.ts\nvar arrUnique = (arr, flatDepth = 0) => !isArr(arr) ? [] : Array.from(new Set(arr.flat(flatDepth)));\n\n// src/deferred/debounce.ts\nvar debounce = (callback, delay = 50, config = {}) => {\n const {\n leading = debounce.defaults.leading,\n onError = debounce.defaults.onError,\n thisArg\n } = config;\n let { tid } = config;\n if (thisArg !== void 0) callback = callback.bind(thisArg);\n const _callback = (...args) => fallbackIfFails_default(callback, args, onError);\n let firstArgs = null;\n const leadingGlobal = leading === \"global\";\n return (...args) => {\n clearTimeout(tid);\n tid = setTimeout(() => {\n firstArgs !== args && _callback(...args);\n firstArgs = leadingGlobal ? true : null;\n }, delay);\n if (!leading || firstArgs) return;\n firstArgs = args;\n _callback(...args);\n };\n};\ndebounce.defaults = {\n /**\n * Set the default value of argument `leading` for the `deferred` function.\n * This change is applicable application-wide and only applies to any new invocation of `deferred()`.\n */\n leading: false,\n /**\n * Set the default value of argument `onError` for the `deferred` function.\n * This change is applicable application-wide and only applies to any new invocation of `deferred()`.\n */\n onError: void 0\n};\nvar debounce_default = debounce;\n\n// src/deferred/throttle.ts\nvar throttle = (callback, delay = 50, config = {}) => {\n const { defaults: d } = throttle;\n const { onError = d.onError, trailing = d.trailing, thisArg } = config;\n let { tid } = config;\n const handleCallback = (...args) => fallbackIfFails_default(\n thisArg !== void 0 ? callback.bind(thisArg) : callback,\n args,\n !isFn(onError) ? void 0 : (err) => fallbackIfFails_default(onError, [err], void 0)\n );\n let trailArgs = null;\n return (...args) => {\n if (tid) {\n trailArgs = args;\n return;\n }\n tid = setTimeout(() => {\n tid = void 0;\n if (!trailing) return;\n const cbArgs = trailArgs;\n trailArgs = null;\n cbArgs && cbArgs !== args && handleCallback(...cbArgs);\n }, delay);\n handleCallback(...args);\n };\n};\nthrottle.defaults = {\n onError: void 0,\n trailing: false\n};\nvar throttled = throttle;\nvar throttle_default = throttle;\n\n// src/deferred/deferred.ts\nvar deferred = (callback, delay = 50, options = {}) => options.throttle ? throttle_default(callback, delay, options) : debounce_default(callback, delay, options);\n\n// src/iterable/filter.ts\nvar filter = (data, predicate, limit, asArray, result) => {\n var _a;\n if (!isMap(result)) result = /* @__PURE__ */ new Map();\n if (!isPositiveInteger(limit)) limit = Infinity;\n for (const [key, item] of ((_a = data == null ? void 0 : data.entries) == null ? void 0 : _a.call(data)) || []) {\n if (result.size >= limit) break;\n fallbackIfFails_default(predicate != null ? predicate : item, [item, key, data], false) && result.set(key, item);\n }\n return asArray ? [...result.values()] : result;\n};\nvar filter_default = filter;\n\n// src/iterable/getSize.ts\nvar getSize = (x) => {\n if (!x) return 0;\n try {\n const s = \"size\" in x ? x.size : \"length\" in x ? x.length : 0;\n return isNumber(s) ? s : 0;\n } catch (_) {\n return 0;\n }\n};\nvar getSize_default = getSize;\n\n// src/iterable/getValues.ts\nvar getValues = (data) => {\n var _a;\n return [\n ...((_a = data == null ? void 0 : data.values) == null ? void 0 : _a.call(data)) || []\n ];\n};\nvar getValues_default = getValues;\n\n// src/iterable/search.ts\nvar search = (data, options) => {\n var _a;\n const ignore = !getSize_default(data) || isEmpty(options == null ? void 0 : options.query);\n const result = isMap(options == null ? void 0 : options.result) ? options.result : /* @__PURE__ */ new Map();\n const asMap = (_a = options == null ? void 0 : options.asMap) != null ? _a : search.defaults.asMap;\n if (ignore) return asMap ? result : getValues_default(result);\n options = objCopy(\n search.defaults,\n options,\n [],\n \"empty\"\n // override `option` property with default value when \"empty\" (undefined, null, '',....)\n );\n const {\n ignoreCase,\n limit = Infinity,\n matchAll,\n matchExact,\n ranked\n } = options;\n let { query } = options;\n const qIsStr = isStr(query);\n const qIsRegExp = isRegExp(query);\n const qKeys = fallbackIfFails_default(Object.keys, [query], []);\n if (ignoreCase && !matchExact && !qIsRegExp) {\n query = qIsStr ? query.toLowerCase() : objCreate(\n qKeys,\n Object.values(query).map(\n (x) => isRegExp(x) ? x : `${x}`.toLowerCase()\n )\n );\n }\n options.query = query;\n if (!ranked) {\n for (const [dataKey, dataValue] of data.entries()) {\n if (result.size >= limit) break;\n const matched = qIsStr || qIsRegExp ? (\n // global search across all properties\n matchObjOrProp(options, dataValue, void 0) >= 0\n ) : (\n // field-specific search\n qKeys[matchAll ? \"every\" : \"some\"](\n (key) => matchObjOrProp(options, dataValue, key) >= 0\n )\n );\n if (!matched) continue;\n result.set(dataKey, dataValue);\n }\n } else {\n const preRankedResults = [];\n for (const [dataKey, dataValue] of data.entries()) {\n let matchIndex = -1;\n if (qIsStr || qIsRegExp) {\n matchIndex = matchObjOrProp(options, dataValue, void 0);\n matchIndex >= 0 && preRankedResults.push([matchIndex, dataKey, dataValue]);\n continue;\n }\n const indexes = [];\n const match = qKeys[matchAll ? \"every\" : \"some\"](\n // field-specific search\n (key) => {\n const index = matchObjOrProp(options, dataValue, key);\n indexes.push(index);\n return index >= 0;\n }\n );\n if (!match) continue;\n matchIndex = // eslint-disable-next-line @typescript-eslint/prefer-find\n indexes.sort((a, b) => a - b).filter((n) => n !== -1)[0];\n matchIndex >= 0 && preRankedResults.push([matchIndex, dataKey, dataValue]);\n }\n preRankedResults.sort((a, b) => a[0] - b[0]).slice(0, limit).forEach(([_, key, value]) => result.set(key, value));\n }\n return asMap ? result : getValues_default(result);\n};\nsearch.defaults = {\n asMap: true,\n ignoreCase: true,\n limit: Infinity,\n matchAll: false,\n ranked: false,\n transform: true\n};\nfunction matchObjOrProp({\n query,\n ignoreCase,\n matchExact,\n transform = true\n}, item, propertyName) {\n var _a, _b;\n const global = isStr(query) || isRegExp(query) || propertyName === void 0;\n const keyword = global ? query : query[propertyName];\n const propVal = global || !isObj(item) ? item : item[propertyName];\n const value = fallbackIfFails_default(\n () => isFn(transform) ? transform(\n item,\n global ? void 0 : propVal,\n propertyName\n ) : matchExact && transform === false ? propVal : isObj(propVal, false) ? JSON.stringify(\n isArrLike(propVal) ? [...propVal.values()] : Object.values(propVal)\n ) : String(propVal != null ? propVal : \"\"),\n [],\n \"\"\n );\n if (value === keyword) return 0;\n if (matchExact && !isRegExp(keyword)) return -1;\n let valueStr = String(value);\n if (!valueStr.trim()) return -1;\n if (isRegExp(keyword)) return (_b = (_a = valueStr.match(keyword)) == null ? void 0 : _a.index) != null ? _b : -1;\n if (ignoreCase) valueStr = valueStr.toLowerCase();\n return valueStr.indexOf(String(keyword));\n}\nvar search_default = search;\n\n// src/iterable/find.ts\nfunction find(data, optsOrCb) {\n const result = isFn(optsOrCb) ? filter_default(data, optsOrCb, 1) : search_default(data, { ...optsOrCb, asMap: true, limit: 1 });\n return result[\n (optsOrCb == null ? void 0 : optsOrCb.includeKey) ? \"entries\" : \"values\"\n // returns: value\n ]().next().value;\n}\n\n// src/iterable/getEntries.ts\nvar getEntries = (map) => {\n var _a;\n return [\n ...((_a = map == null ? void 0 : map.entries) == null ? void 0 : _a.call(map)) || []\n ];\n};\n\n// src/iterable/getKeys.ts\nvar getKeys = (data) => {\n var _a;\n return [\n ...((_a = data == null ? void 0 : data.keys) == null ? void 0 : _a.call(data)) || []\n ];\n};\n\n// src/iterable/reverse.ts\nvar reverse = (data, reverse2 = true, newInstance = false) => {\n var _a, _b, _c;\n const dataType = isArr(data) ? 1 : isMap(data) ? 2 : isSet(data) ? 3 : 0;\n if (!dataType) return [];\n const arr = dataType === 1 ? !newInstance ? data : [...data] : dataType === 2 ? [...data.entries()] : [...data.values()];\n if (reverse2) arr.reverse();\n switch (dataType) {\n case 1:\n return arr;\n case 2:\n case 3:\n if (newInstance || !(\"clear\" in data && isFn(data.clear)))\n return dataType === 2 ? new Map(arr) : new Set(arr);\n }\n (_a = data == null ? void 0 : data.clear) == null ? void 0 : _a.call(data);\n for (const item of arr)\n \"set\" in data ? (_b = data.set) == null ? void 0 : _b.call(data, ...item) : \"add\" in data && ((_c = data == null ? void 0 : data.add) == null ? void 0 : _c.call(data, item));\n return data;\n};\n\n// src/iterable/sliceMap.ts\nvar sliceMap = (data, options) => {\n var _a;\n const {\n asMap = false,\n end,\n start = 0,\n transform,\n ignoreEmpty = true\n } = isFn(options) ? { transform: options } : isObj(options) ? options : {};\n const result = /* @__PURE__ */ new Map();\n const subset = [...((_a = data == null ? void 0 : data.entries) == null ? void 0 : _a.call(data)) || []].slice(start, end);\n for (const [_, [key, value]] of subset.entries()) {\n if (ignoreEmpty && isEmpty(value)) continue;\n const newValue = fallbackIfFails_default(\n transform != null ? transform : value,\n [value, key, data],\n void 0\n );\n newValue !== void 0 && result.set(key, newValue);\n }\n return asMap ? result : [...result.values()];\n};\n\n// src/iterable/sort.ts\nfunction sort(data, keyOrFn, options) {\n const dataType = isArr(data) ? 1 : isMap(data) ? 2 : isSet(data) ? 3 : 0;\n if (!dataType) return data;\n const { asString, ignoreCase, newInstance, reverse: reverse2, undefinedFirst } = {\n ...sort.defaults,\n ...isObj(options) ? options : isObj(keyOrFn) ? keyOrFn : {}\n };\n if (dataType === 1 && isFn(keyOrFn)) {\n return arrReverse(\n data.sort(keyOrFn),\n // use provided comparator function\n reverse2,\n newInstance\n );\n }\n const alt = asString ? undefinedFirst ? \"\" : \"Z\".repeat(10) : undefinedFirst ? -Infinity : Infinity;\n const sorted = isFn(keyOrFn) ? arrReverse(\n // handle Set with comparator function\n [...data.entries()].sort(keyOrFn),\n reverse2,\n false\n // not required because of entries() & spread\n ) : (() => {\n let index = 1;\n const getVal = (target) => {\n const val = isObj(target) && index !== 0 ? target[keyOrFn] : target;\n if (!asString) return val;\n const value = `${val != null ? val : alt}`;\n return ignoreCase ? value.toLowerCase() : value;\n };\n const [gt, lt] = reverse2 ? [-1, 1] : [1, -1];\n if ([1, 3].includes(dataType)) {\n return (dataType === 3 || newInstance ? [...data] : data).sort((a, b) => getVal(a) > getVal(b) ? gt : lt);\n }\n index = keyOrFn === true ? 0 : 1;\n return [...data.entries()].sort(\n (a, b) => getVal(a == null ? void 0 : a[index]) > getVal(b == null ? void 0 : b[index]) ? gt : lt\n );\n })();\n if (dataType === 1) return sorted;\n if (newInstance) {\n return dataType === 2 ? new Map(sorted) : new Set(sorted);\n }\n ;\n data.clear();\n for (const entry of sorted)\n dataType === 2 ? data.set(...entry) : data.add(entry);\n return data;\n}\nsort.defaults = {\n asString: true,\n ignoreCase: true,\n newInstance: false,\n reverse: false,\n undefinedFirst: false\n};\n\n// src/map/mapJoin.ts\nvar mapJoin = (...inputs) => {\n var _a;\n return new Map(\n (_a = inputs == null ? void 0 : inputs.flatMap) == null ? void 0 : _a.call(\n inputs,\n (input) => isMap(input) ? Array.from(input.entries()) : isArr2D(input) ? input : []\n )\n );\n};\n\n// src/number/randomInt.ts\nvar randomInt = (min = 0, max = Number.MAX_SAFE_INTEGER) => parseInt(`${Math.random() * (max - min) + min}`);\n\n// src/str/clearClutter.ts\nvar clearClutter = (text, lineSeparator = \" \") => `${text}`.split(\"\\n\").map((ln) => ln.trim()).filter(Boolean).join(lineSeparator);\n\n// src/str/copyToClipboard.ts\nvar copyToClipboard = (str) => fallbackIfFails(\n // First attempt: modern clipboard API\n () => navigator.clipboard.writeText(str).then(() => 1),\n [],\n // If clipboard API is not available or fails, use the fallback method\n () => Promise.resolve(copyLegacy(str) ? 2 : 0)\n);\nvar copyLegacy = (str) => fallbackIfFails(\n () => {\n const el = document.createElement(\"textarea\");\n el.value = str;\n el.setAttribute(\"readonly\", \"\");\n el.style.position = \"absolute\";\n el.style.left = \"-9999px\";\n document.body.appendChild(el);\n el.select();\n const success = document.execCommand(\"copy\");\n document.body.removeChild(el);\n return success;\n },\n [],\n false\n // On error, return false\n);\n\n// src/str/getUrlParam.ts\nvar getUrlParam = (name, url, asArray) => {\n var _a;\n url != null ? url : url = fallbackIfFails_default(() => window.location.href, [], \"\");\n const _asArray = isArr(asArray) ? asArray : asArray === true && isStr(name) ? [name] : [];\n const prepareResult = (value = \"\", values = {}) => name ? isArr(value) || !_asArray.includes(name) ? value : [value].filter(Boolean) : values;\n if (!url) return prepareResult();\n if (typeof URLSearchParams === \"undefined\" || !URLSearchParams) {\n const r = getUrlParamRegex(name, url, _asArray);\n return prepareResult(r, r);\n }\n const search2 = isUrl(url) ? url.search : ((_a = url.split(\"?\")) == null ? void 0 : _a[1]) || \"\";\n if (search2 === \"?\" || !search2) return prepareResult();\n const params = new URLSearchParams(search2);\n const getValue = (paramName) => {\n const value = arrUnique(params.getAll(paramName));\n return value.length > 1 || _asArray.includes(paramName) ? value : value[0];\n };\n if (name) return prepareResult(getValue(name));\n const result = {};\n for (const name2 of arrUnique([...params.keys()])) {\n result[name2] = getValue(name2);\n }\n return result;\n};\nvar getUrlParamRegex = (name, url, asArray = []) => {\n url != null ? url : url = fallbackIfFails_default(() => window.location.href, [], \"\");\n if (isUrl(url)) url = url.toString();\n const params = {};\n const regex = /[?&]+([^=&]+)=([^&]*)/gi;\n url == null ? void 0 : url.replace(regex, (_, name2, value) => {\n value = decodeURIComponent(value);\n if (asArray.includes(name2) || params[name2] !== void 0) {\n params[name2] = isArr(params[name2]) ? params[name2] : [params[name2]];\n params[name2] = arrUnique([...params[name2], value]).filter(Boolean);\n } else {\n params[name2] = value;\n }\n return \"\";\n });\n return name ? params[name] : params;\n};\n\n// src/str/regex.ts\nvar EMAIL_REGEX = new RegExp(\n /^((\"[\\w-\\s]+\")|([\\w-]+(?:\\.[\\w-]+)*)|(\"[\\w-\\s]+\")([\\w-]+(?:\\.[\\w-]+)*))(@((?:[\\w-]+\\.)*\\w[\\w-]{0,66})\\.([a-z]{2,9}(?:\\.[a-z]{2})?)$)|(@\\[?((25[0-5]\\.|2[0-4][0-9]\\.|1[0-9]{2}\\.|[0-9]{1,2}\\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\\]?$)/i\n);\nvar HEX_REGEX = /^0x[0-9a-f]+$/i;\nvar HASH_REGEX = /^0x[0-9a-f]{64}$/i;\n\n// src/str/strToArr.ts\nvar strToArr = (value, seperator = \",\") => typeof value === \"string\" && value.split(seperator).filter(Boolean) || [];\nexport {\n EMAIL_REGEX,\n HASH_REGEX,\n HEX_REGEX,\n ReadOnlyArrayHelper,\n arrReadOnly,\n arrReverse,\n arrToMap,\n arrUnique,\n clearClutter,\n copyToClipboard,\n curry,\n debounce,\n deferred,\n fallbackIfFails,\n filter,\n find,\n getEntries,\n getKeys,\n getSize,\n getUrlParam,\n getValues,\n is,\n isArr,\n isArr2D,\n isArrLike,\n isArrLikeSafe,\n isArrObj,\n isArrUnique,\n isAsyncFn,\n isBool,\n isDate,\n isDateValid,\n isDefined,\n isEmpty,\n isEmptySafe,\n isEnvBrowser,\n isEnvNode,\n isEnvTouchable,\n isError,\n isFn,\n isInteger,\n isMap,\n isMapObj,\n isNegativeInteger,\n isNegativeNumber,\n isNumber,\n isObj,\n isPositiveInteger,\n isPositiveNumber,\n isPromise,\n isRegExp,\n isSet,\n isStr,\n isSubjectLike,\n isSymbol,\n isUint8Arr,\n isUrl,\n isUrlValid,\n mapJoin,\n matchObjOrProp,\n noop,\n noopAsync,\n objClean,\n objCopy,\n objCreate,\n objHasKeys,\n objKeys,\n objReadOnly,\n objSetProp,\n objSetPropUndefined,\n objSort,\n objWithoutKeys,\n randomInt,\n reverse,\n search,\n sliceMap,\n sort,\n strToArr,\n throttle,\n throttled,\n toDatetimeLocal\n};\n","/* eslint-disable @typescript-eslint/no-unused-vars */\n\n// Re-export fetch relevant & useful things from '@superutils/promise' for ease of use\nexport {\n\tResolveError,\n\tResolveIgnored,\n\tTIMEOUT_FALLBACK,\n\tTIMEOUT_MAX,\n\tTimeoutPromise,\n} from '@superutils/promise'\nexport type {\n\tDeferredAsyncOptions,\n\tOnEarlyFinalize,\n\tOnFinalize,\n\tRetryIfFunc,\n\tRetryOptions,\n\tTimeoutOptions,\n} from '@superutils/promise'\n\n/* All local exports */\nexport * from './createClient'\nexport * from './createPostClient'\nexport * from './executeInterceptors'\nexport * from './fetch'\nexport * from './getResponse'\nexport * from './mergeOptions'\nexport * from './types'\nimport createClient from './createClient'\nimport createPostClient from './createPostClient'\nimport _fetch from './fetch'\nimport { FetchAs, FetchCustomOptions, FetchInterceptors } from './types'\n\nconst methods = {\n\t/** Make HTTP requests with method GET */\n\tget: createClient({ method: 'get' }),\n\n\t/** Make HTTP requests with method HEAD */\n\thead: createClient({ method: 'head' }),\n\n\t/** Make HTTP requests with method OPTIONS */\n\toptions: createClient({ method: 'options' }),\n\n\t/** Make HTTP requests with method DELETE */\n\tdelete: createPostClient({ method: 'delete' }),\n\n\t/** Make HTTP requests with method PATCH */\n\tpatch: createPostClient({ method: 'patch' }),\n\n\t/** Make HTTP requests with method POST */\n\tpost: createPostClient({ method: 'post' }),\n\n\t/** Make HTTP requests with method PUT */\n\tput: createPostClient({ method: 'put' }),\n}\n\n/**\n * A `fetch()` replacement that simplifies data fetching with automatic JSON parsing, request timeouts, retries,\n * and handy interceptors that also work as transformers. It also includes deferred and throttled request\n * capabilities for complex asynchronous control flows.\n *\n * Will reject promise if response status code is not 2xx (200 <= status < 300).\n *\n * ## Method Specific Functions\n *\n * While `fetch()` provides access to all HTTP request methods by specifying it in options (eg: `{ method: 'get' }`),\n * for ease of use you can also use the following:\n *\n * - `fetch.delete(...)`\n * - `fetch.get(...)`\n * - `fetch.head(...)`\n * - `fetch.options(...)`\n * - `fetch.patch(...)`\n * - `fetch.post(...)`\n * - `fetch.put(...)`\n *\n * **Deferred variants:** To debounce/throttle requests.\n *\n * - `fetch.delete.deferred(...)`\n * - `fetch.get.deferred(...)`\n * - `fetch.head.deferred(...)`\n * - `fetch.options.deferred(...)`\n * - `fetch.patch.deferred(...)`\n * - `fetch.post.deferred(...)`\n * - `fetch.put.deferred(...)`\n *\n * @template T The type of the value that the `fetch` resolves to.\n * @template TReturn Return value type.\n *\n * If `T` is not specified defaults to the following based on the value of `options.as`:\n * - FetchAs.arrayBuffer: `ArrayBuffer`\n * - FetchAs.blob: `Blob`\n * - FetchAs.bytes: `Uint8Array<ArrayBuffer>`\n * - FetchAs.formData: `FormData`\n * - FetchAs.json: `unknown`\n * - FetchAs.text: `string`\n * - FetchAs.response: `Response`\n *\n * @param url\n * @param options (optional) Standard `fetch` options extended with {@link FetchCustomOptions}\n * @param options.abortCtrl (optional) if not provided `AbortController` will be instantiated when `timeout` used.\n *\n * Default: `new AbortController()`\n * @param options.as (optional) (optional) specify how to parse the result.\n * For raw `Response` use {@link FetchAs.response}\n *\n * Default: {@link FetchAs.json}\n * @param options.headers (optional) request headers\n *\n * Default: `{ 'content-type': 'application/json' }`\n * @param options.interceptors (optional) request interceptor/transformer callbacks.\n * See {@link FetchInterceptors} for details.\n * @param options.method (optional) fetch method.\n *\n * Default: `'get'`\n * @param options.timeout (optional) duration in milliseconds to abort the request.\n * This duration includes the execution of all interceptors/transformers.\n *\n * Default: `60_000`\n *\n * ---\n *\n * @example\n * #### Drop-in replacement for built-in fetch\n *\n * ```javascript\n * import fetch from '@superutils/fetch'\n *\n * fetch('[DUMMYJSON-DOT-COM]/products/1')\n * .then(response => response.json())\n * .then(console.log, console.error)\n * ```\n *\n * @example\n * #### Method specific function with JSON parsing by default\n * ```javascript\n * import fetch from '@superutils/fetch'\n *\n * // no need for `response.json()` or \"result.data.data\" drilling\n * fetch.get('[DUMMYJSON-DOT-COM]/products/1')\n * .then(product => console.log(product))\n * fetch.post('[DUMMYJSON-DOT-COM]/products/add', { title: 'Product title' })\n * .then(product => console.log(product))\n * ```\n *\n * @example\n * #### Set default options.\n *\n * Options' default values (excluding `as` and `method`) can be configured to be EFFECTIVE GLOBALLY.\n *\n * ```typescript\n * import fetch from '@superutils/fetch'\n *\n * const { defaults, errorMsgs, interceptors } = fetch\n *\n * // set default request timeout duration in milliseconds\n * defaults.timeout = 40_000\n *\n * // default headers\n * defaults.headers = { 'content-type': 'text/plain' }\n *\n * // override error messages\n * errorMsgs.invalidUrl = 'URL is not valid'\n * errorMsgs.timedout = 'Request took longer than expected'\n *\n * // add an interceptor to log all request failures.\n * const fetchLogger = (fetchErr, url, options) => console.log('Fetch error log', fetchErr)\n * interceptors.error.push(fetchLogger)\n *\n * // add an interceptor to conditionally include header before making requests\n * interceptors.request.push((url, options) => {\n * // ignore login requests\n * if (`${url}`.includes('/login')) return\n *\n * options.headers.set('x-auth-token', 'my-auth-token')\n * })\n * ```\n */\nexport const fetch = _fetch as typeof _fetch & typeof methods\nfetch.delete = methods.delete\nfetch.get = methods.get\nfetch.head = methods.head\nfetch.options = methods.options\nfetch.patch = methods.patch\nfetch.post = methods.post\nfetch.put = methods.put\n\nexport default fetch\n","import { fallbackIfFails, isFn } from '@superutils/core'\nimport { type Interceptor } from './types'\n\n/**\n * Gracefully executes interceptors and returns the processed value.\n * If the value is not transformed (by returning a new value) by the interceptors,\n * the original value is returned.\n *\n * @param\tvalue value to be passed to the interceptors\n * @param\tsignal The AbortController used to monitor the request status. If the signal is aborted (e.g. due to\n * timeout or manual cancellation), the interceptor chain halts immediately. Note: This does not interrupt the\n * currently executing interceptor, but prevents subsequent ones from running.\n * @param\tinterceptors interceptor/transformer callbacks\n * @param\targs (optional) common arguments to be supplied to all the interceptors in addition to\n * the `value' which will always be the first argument.\n *\n * Interceptor arguments: `[value, ...args]`\n */\nexport const executeInterceptors = async <T, TArgs extends unknown[]>(\n\tvalue: T,\n\tsignal?: AbortSignal,\n\tinterceptors?: Interceptor<T, TArgs>[],\n\t...args: TArgs\n) => {\n\tfor (const interceptor of [...(interceptors ?? [])].filter(isFn)) {\n\t\tif (signal?.aborted) break\n\t\tvalue =\n\t\t\t((await fallbackIfFails(\n\t\t\t\tinterceptor,\n\t\t\t\t[value, ...args],\n\t\t\t\tundefined,\n\t\t\t)) as T) ?? value // if throws error or undefined/null is returned\n\t}\n\treturn value\n}\n\nexport default executeInterceptors\n","import { fallbackIfFails, isFn, isPositiveInteger } from '@superutils/core'\nimport { retry } from '@superutils/promise'\nimport { FetchArgs, FetchFunc } from './types'\n\n/**\n * Executes the built-in `fetch()` (or a custom `fetchFunc` if provided) with support for automatic retries.\n *\n * If `options.retry` is greater than 0, the request will be retried if it fails or if the response is not OK,\n * unless overridden by `options.retryIf`.\n *\n * @param url The request URL.\n * @param options (optional) Fetch options, including retry settings.\n *\n * @returns A promise resolving to the Response.\n */\nconst getResponse = (url: FetchArgs[0], options: FetchArgs[1] = {}) => {\n\tconst fetchFunc = isFn(options.fetchFunc)\n\t\t? options.fetchFunc\n\t\t: (globalThis.fetch as FetchFunc)\n\tif (!isPositiveInteger(options.retry)) return fetchFunc(url, options)\n\n\tlet attemptCount = 0\n\tconst response = retry(\n\t\t() => {\n\t\t\tattemptCount++\n\t\t\treturn fetchFunc(url, options)\n\t\t},\n\t\t{\n\t\t\t...options,\n\t\t\tretryIf: async (res, count, error) => {\n\t\t\t\tconst { abortCtrl, retryIf, signal } = options\n\t\t\t\tif (abortCtrl?.signal?.aborted || signal?.aborted) return false\n\n\t\t\t\treturn !!(\n\t\t\t\t\t(await fallbackIfFails(\n\t\t\t\t\t\tretryIf,\n\t\t\t\t\t\t[res, count, error],\n\t\t\t\t\t\tundefined,\n\t\t\t\t\t))\n\t\t\t\t\t?? (!!error || !res?.ok)\n\t\t\t\t)\n\t\t\t},\n\t\t},\n\t).catch(err =>\n\t\tPromise.reject(\n\t\t\tnew Error(`Request failed after attempt #${attemptCount}`, {\n\t\t\t\tcause: err,\n\t\t\t}),\n\t\t),\n\t)\n\n\treturn response\n}\nexport default getResponse\n","import { isArr, isFn, isObj, objCopy } from '@superutils/core'\nimport { FetchOptions, FetchOptionsInterceptor } from './types'\n\n/**\n * Merge one or more {@link FetchOptions}\n *\n * Notes:\n * - item properties will be prioritized in the order of sequence they were passed in\n * - the following properties will be merged:\n * * `errMsgs`\n * * `headers`\n * * `interceptors`\n * - all other properties will simply override previous values\n *\n * @returns combined\n */\nexport const mergeOptions = (...allOptions: (FetchOptions | undefined)[]) =>\n\tallOptions.reduce(\n\t\t(merged: FetchOptions, options) => {\n\t\t\toptions = isObj(options) ? options : {}\n\t\t\tconst { headers, interceptors: ints1 = {} } = merged\n\t\t\tconst { interceptors: ints2 = {} } = options\n\t\t\toptions.headers\n\t\t\t\t&& new Headers(options.headers).forEach((value, key) =>\n\t\t\t\t\t(headers as Headers).set(key, value),\n\t\t\t\t)\n\n\t\t\treturn {\n\t\t\t\t...merged,\n\t\t\t\t...options,\n\t\t\t\terrMsgs: objCopy(\n\t\t\t\t\toptions.errMsgs as Record<string, string>,\n\t\t\t\t\tmerged.errMsgs,\n\t\t\t\t\t[],\n\t\t\t\t\t'empty',\n\t\t\t\t),\n\t\t\t\theaders,\n\t\t\t\tinterceptors: {\n\t\t\t\t\terror: [...toArr(ints1?.error), ...toArr(ints2?.error)],\n\t\t\t\t\trequest: [\n\t\t\t\t\t\t...toArr(ints1?.request),\n\t\t\t\t\t\t...toArr(ints2?.request),\n\t\t\t\t\t],\n\t\t\t\t\tresponse: [\n\t\t\t\t\t\t...toArr(ints1?.response),\n\t\t\t\t\t\t...toArr(ints2?.response),\n\t\t\t\t\t],\n\t\t\t\t\tresult: [...toArr(ints1?.result), ...toArr(ints2?.result)],\n\t\t\t\t},\n\t\t\t\ttimeout: options.timeout ?? merged.timeout,\n\t\t\t} as FetchOptions\n\t\t},\n\t\t{ headers: new Headers() },\n\t) as FetchOptionsInterceptor\nexport default mergeOptions\n\nconst toArr = <T = unknown>(x?: T | T[]) => (isArr(x) ? x : isFn(x) ? [x] : [])\n","/** Commonly used content types for easier access */\nexport const ContentType = {\n\tAPPLICATION_JAVASCRIPT: 'application/javascript',\n\tAPPLICATION_JSON: 'application/json',\n\tAPPLICATION_OCTET_STREAM: 'application/octet-stream',\n\tAPPLICATION_PDF: 'application/pdf',\n\tAPPLICATION_X_WWW_FORM_URLENCODED: 'application/x-www-form-urlencoded',\n\tAPPLICATION_XML: 'application/xml',\n\tAPPLICATION_ZIP: 'application/zip',\n\tAUDIO_MPEG: 'audio/mpeg',\n\tMULTIPART_FORM_DATA: 'multipart/form-data',\n\tTEXT_CSS: 'text/css',\n\tTEXT_HTML: 'text/html',\n\tTEXT_PLAIN: 'text/plain',\n\tVIDEO_MP4: 'video/mp4',\n} as const\n\nexport enum FetchAs {\n\tarrayBuffer = 'arrayBuffer',\n\tblob = 'blob',\n\tbytes = 'bytes',\n\tformData = 'formData',\n\tjson = 'json',\n\tresponse = 'response',\n\ttext = 'text',\n}\n","import { FetchOptions } from './options'\n\n\n/** Custom error message for fetch requests with more detailed info about the request URL, fetch options and response */\nexport class FetchError extends Error {\n /** Create a new `FetchError` with a new `message` while preserving all metadata */\n clone!: (newMessage: string) => FetchError\n /* FetchOptions */\n options!: FetchOptions\n /* FResponse received, if any */\n response!: Response | undefined\n /* Fetch URL */\n url!: string | URL\n\n constructor(\n message: string,\n options: {\n cause?: unknown\n options: FetchOptions\n response?: Response\n url: string | URL\n },\n ) {\n super(message, { cause: options.cause })\n\n this.name = 'FetchError'\n\n /* Prevents cluttering the console log output while also preserving ready-only member behavior */\n Object.defineProperties(this, {\n clone: {\n get() {\n return (newMessage: string) =>\n new FetchError(newMessage, {\n cause: options.cause,\n options: options.options,\n response: options.response,\n url: options.url,\n })\n },\n },\n options: {\n get() {\n return options.options\n },\n },\n response: {\n get() {\n return options.response\n },\n },\n url: {\n get() {\n return options.url\n },\n },\n })\n }\n}","import {\n\tfallbackIfFails,\n\tisError,\n\tisFn,\n\tisObj,\n\tisPromise,\n\tisUrlValid,\n} from '@superutils/core'\nimport { timeout as PromisE_timeout } from '@superutils/promise'\nimport executeInterceptors from './executeInterceptors'\nimport getResponse from './getResponse'\nimport mergeOptions from './mergeOptions'\nimport type {\n\tFetchOptions,\n\tFetchOptionsInterceptor,\n\tFetchResult,\n\tIPromise_Fetch,\n\tPostBody,\n} from './types'\nimport {\n\tContentType,\n\tFetchAs,\n\tFetchErrMsgs,\n\tFetchError,\n\tFetchOptionsDefault,\n} from './types'\n\nconst defaultErrorMsgs = Object.freeze({\n\taborted: 'Request aborted',\n\tinvalidUrl: 'Invalid URL',\n\tparseFailed: 'Failed to parse response as',\n\ttimedout: 'Request timed out',\n\trequestFailed: 'Request failed with status code:',\n}) as Required<FetchErrMsgs>\n\nconst fetch = <\n\tT = unknown,\n\tTOptions extends FetchOptions = FetchOptions,\n\tTAs extends FetchAs = TOptions['as'] extends FetchAs\n\t\t? TOptions['as']\n\t\t: FetchAs.response,\n\tTReturn = FetchResult<T>[TAs],\n>(\n\turl: string | URL,\n\toptions: FetchOptions & TOptions = {} as TOptions,\n) => {\n\tif (!isObj(options)) options = {} as TOptions\n\n\tlet response: Response | undefined\n\t// merge `defaults` with `options` to make sure default values are used where appropriate\n\tconst opts = mergeOptions(\n\t\t{ errMsgs: defaultErrorMsgs },\n\t\tfetch.defaults,\n\t\toptions,\n\t)\n\t// make sure there's always an abort controller, so that request is aborted when promise is early finalized\n\topts.abortCtrl =\n\t\topts.abortCtrl instanceof AbortController\n\t\t\t? opts.abortCtrl\n\t\t\t: new AbortController()\n\topts.as ??= FetchAs.response\n\topts.method ??= 'get'\n\topts.signal ??= opts.abortCtrl.signal\n\tconst { abortCtrl, as: parseAs, headers, onAbort, onTimeout } = opts\n\topts.onAbort = async () => {\n\t\tconst err: Error = await fallbackIfFails(onAbort, [], undefined)\n\n\t\treturn await interceptErr(\n\t\t\tisError(err) ? err : new Error(err),\n\t\t\turl,\n\t\t\topts,\n\t\t\tresponse,\n\t\t)\n\t}\n\topts.onTimeout = async () => {\n\t\tconst err = await fallbackIfFails(onTimeout, [], undefined)\n\t\treturn await interceptErr(\n\t\t\terr ?? new Error(opts.errMsgs.timedout),\n\t\t\turl,\n\t\t\topts,\n\t\t\tresponse,\n\t\t)\n\t}\n\treturn PromisE_timeout(opts, async () => {\n\t\ttry {\n\t\t\t// invoke body function before executing request interceptors\n\t\t\topts.body = await fallbackIfFails(\n\t\t\t\topts.body as unknown as Promise<PostBody>,\n\t\t\t\t[],\n\t\t\t\t(err: Error) => Promise.reject(err),\n\t\t\t)\n\n\t\t\t// invoke global and local response interceptors to intercept and/or transform `url` and `options`\n\t\t\turl = await executeInterceptors(\n\t\t\t\turl,\n\t\t\t\tabortCtrl.signal,\n\t\t\t\topts.interceptors?.request,\n\t\t\t\topts,\n\t\t\t)\n\n\t\t\tconst { body, errMsgs, validateUrl = false } = opts\n\t\t\topts.signal ??= abortCtrl.signal\n\t\t\tif (validateUrl && !isUrlValid(url, false))\n\t\t\t\tthrow new Error(errMsgs.invalidUrl)\n\n\t\t\tconst stringify =\n\t\t\t\t['delete', 'patch', 'post', 'put'].includes(\n\t\t\t\t\t`${opts.method}`.toLowerCase(),\n\t\t\t\t)\n\t\t\t\t&& !['undefined', 'string'].includes(typeof body)\n\t\t\t\t&& isObj(body, true)\n\t\t\t\t&& headers.get('content-type') === ContentType.APPLICATION_JSON\n\t\t\t// stringify body\n\t\t\tif (stringify) opts.body = JSON.stringify(opts.body)\n\n\t\t\t// make the fetch call\n\t\t\tresponse = await getResponse(url, opts)\n\t\t\t// invoke global and local request interceptors to intercept and/or transform `response`\n\t\t\tresponse = await executeInterceptors(\n\t\t\t\tresponse,\n\t\t\t\tabortCtrl.signal,\n\t\t\t\topts.interceptors?.response,\n\t\t\t\turl,\n\t\t\t\topts,\n\t\t\t)\n\t\t\tconst status = response?.status\n\t\t\tconst isSuccess = status >= 200 && status < 300\n\t\t\tif (!isSuccess) {\n\t\t\t\tconst jsonError: unknown = await fallbackIfFails(\n\t\t\t\t\t// try to parse error response as json first\n\t\t\t\t\t() => response!.json(),\n\t\t\t\t\t[],\n\t\t\t\t\tundefined,\n\t\t\t\t)\n\t\t\t\tthrow new Error(\n\t\t\t\t\t(jsonError as Error)?.message\n\t\t\t\t\t\t|| `${errMsgs.requestFailed} ${status}`,\n\t\t\t\t\t{ cause: jsonError },\n\t\t\t\t)\n\t\t\t}\n\n\t\t\tconst parseFunc = response[parseAs as keyof typeof response]\n\t\t\tlet result: unknown = !isFn(parseFunc)\n\t\t\t\t? response\n\t\t\t\t: parseFunc.bind(response)()\n\t\t\tif (isPromise(result))\n\t\t\t\tresult = await result.catch((err: Error) =>\n\t\t\t\t\tPromise.reject(\n\t\t\t\t\t\tnew Error(\n\t\t\t\t\t\t\t`${errMsgs.parseFailed} ${parseAs}. ${err?.message}`,\n\t\t\t\t\t\t\t{ cause: err },\n\t\t\t\t\t\t),\n\t\t\t\t\t),\n\t\t\t\t)\n\t\t\t// invoke global and local request interceptors to intercept and/or transform parsed `result`\n\t\t\tresult = await executeInterceptors(\n\t\t\t\tresult,\n\t\t\t\tabortCtrl.signal,\n\t\t\t\topts.interceptors?.result,\n\t\t\t\turl,\n\t\t\t\topts,\n\t\t\t)\n\t\t\treturn result as TReturn\n\t\t} catch (_err: unknown) {\n\t\t\tlet err = _err as Error\n\n\t\t\terr = await interceptErr(_err as Error, url, opts, response)\n\t\t\treturn Promise.reject(err as FetchError)\n\t\t}\n\t}) as IPromise_Fetch<TReturn>\n}\n/** Default fetch options */\nfetch.defaults = {\n\tabortOnEarlyFinalize: true,\n\terrMsgs: { ...defaultErrorMsgs }, // all error messages must be defined here\n\theaders: new Headers(),\n\tinterceptors: {\n\t\terror: [],\n\t\trequest: [],\n\t\tresponse: [],\n\t\tresult: [],\n\t},\n\ttimeout: 60_000,\n\tvalidateUrl: false,\n} as FetchOptionsDefault\n\nconst interceptErr = async (\n\terr: Error,\n\turl: string | URL,\n\toptions: FetchOptionsInterceptor,\n\tresponse?: Response,\n) => {\n\t// invoke global and local request interceptors to intercept and/or transform `error`\n\tconst fErr = await executeInterceptors(\n\t\tnew FetchError(err?.message ?? err, {\n\t\t\tcause: err?.cause ?? err,\n\t\t\tresponse: response,\n\t\t\toptions: options,\n\t\t\turl,\n\t\t}),\n\t\tundefined, // should execute regardless of abort status\n\t\toptions.interceptors?.error,\n\t\turl,\n\t\toptions,\n\t)\n\treturn fErr\n}\n\nexport default fetch\n","import { DeferredAsyncOptions, deferredCallback } from '@superutils/promise'\nimport fetch from './fetch'\nimport mergeOptions from './mergeOptions'\nimport type {\n\tExtractAs,\n\tExcludeOptions,\n\tFetchArgs,\n\tFetchOptions,\n\tGetFetchResult,\n\tIPromise_Fetch,\n} from './types'\nimport { FetchAs } from './types'\n\n/**\n * Defines client generic parameter T based on fixed options.\n *\n * If \"fixedOptions.as\" is defined and not `FetcAs.json`, then `T` will be `never`.\n */\nexport type ClientData<FixedOptions> =\n\tExtractAs<[FixedOptions]> extends FetchAs.json ? unknown : never // disallow providing T\n/**\n * Create a reusable fetch client with shared options. The returned function comes attached with a\n * `.deferred()` function for debounce and throttle behavior.\n *\n * The `createClient` utility streamlines the creation of dedicated API clients by generating pre-configured fetch\n * functions. These functions can be equipped with default options like headers, timeouts, or a specific HTTP method,\n * which minimizes code repetition across your application. If a method is not specified during creation, the client\n * will default to `GET`.\n *\n * The returned client also includes a `.deferred()` method, providing the same debounce, throttle, and sequential\n * execution capabilities found in functions like `fetch.get.deferred()`.\n *\n * @example\n * #### Create reusable clients\n * ```javascript\n * import { createClient } from '@superutils/fetch'\n *\n * // Create a \"GET\" client with default headers and a 5-second timeout\n * const apiClient = createClient(\n * \t { method: 'get' }, // fixed options cannot be overridden\n * \t { // default options can be overridden\n * \t headers: {\n * \t \tAuthorization: 'Bearer my-secret-token',\n * \t \t'Content-Type': 'application/json',\n * \t },\n * \t timeout: 5000,\n * \t },\n * \t {// default defer options (can be overridden)\n * \t delay: 300,\n * \t retry: 2, // If request fails, retry up to two more times\n * \t },\n * )\n *\n * // Use it just like the standard fetch\n * apiClient('[DUMMYJSON-DOT-COM]/products/1', {\n * // The 'method' property cannot be overridden as it is used in the fixed options when creating the client.\n * // In TypeScript, the compiler will not allow this property.\n * // In Javascript, it will simply be ignored.\n * // method: 'post',\n * timeout: 3000, // The 'timeout' property can be overridden\n * }).then(console.log, console.warn)\n *\n * // create a deferred client using \"apiClient\"\n * const deferredClient = apiClient.deferred(\n * { retry: 0 }, // disable retrying by overriding the `retry` defer option\n * '[DUMMYJSON-DOT-COM]/products/1',\n * { timeout: 3000 },\n * )\n * deferredClient({ timeout: 10000 }) // timeout is overridden by individual request\n * \t.then(console.log, console.warn)\n * ```\n */\nexport const createClient = <\n\tFixedOptions extends FetchOptions | undefined,\n\tCommonOptions extends ExcludeOptions<FixedOptions> | undefined,\n\tCommonDelay extends number,\n>(\n\t/** Mandatory fetch options that cannot be overriden by individual request */\n\tfixedOptions?: FixedOptions,\n\t/** Common fetch options that can be overriden by individual request */\n\tcommonOptions?: FetchOptions & CommonOptions,\n\tcommonDeferOptions?: DeferredAsyncOptions<unknown, CommonDelay>,\n) => {\n\tfunction client<\n\t\tT extends ClientData<FixedOptions> = never,\n\t\tTOptions extends ExcludeOptions<FixedOptions> | undefined =\n\t\t\t| ExcludeOptions<FixedOptions>\n\t\t\t| undefined,\n\t\tResult = GetFetchResult<[FixedOptions, TOptions, CommonOptions], T>,\n\t>(url: FetchArgs[0], options?: TOptions): IPromise_Fetch<Result> {\n\t\tconst mergedOptions = mergeOptions(\n\t\t\tfetch.defaults,\n\t\t\tcommonOptions,\n\t\t\toptions,\n\t\t\tfixedOptions, // fixed options will always override other options\n\t\t)\n\t\tmergedOptions.as ??= FetchAs.json\n\t\treturn fetch(url, mergedOptions)\n\t}\n\n\t/** Make requests with debounce/throttle behavior */\n\tclient.deferred = <\n\t\tThisArg,\n\t\tDelay extends CommonDelay | number,\n\t\tDefaultUrl extends FetchArgs[0] | undefined = FetchArgs[0] | undefined,\n\t\tDefaultOptions extends ExcludeOptions<FixedOptions> | undefined =\n\t\t\t| ExcludeOptions<FixedOptions>\n\t\t\t| undefined,\n\t>(\n\t\tdeferOptions?: DeferredAsyncOptions<ThisArg, Delay>,\n\t\tdefaultUrl?: DefaultUrl,\n\t\tdefaultOptions?: DefaultOptions,\n\t) => {\n\t\tlet _abortCtrl: AbortController | undefined\n\t\tconst fetchCb = <\n\t\t\tT extends ClientData<FixedOptions> = never,\n\t\t\tTOptions extends ExcludeOptions<FixedOptions> | undefined =\n\t\t\t\t| ExcludeOptions<FixedOptions>\n\t\t\t\t| undefined,\n\t\t\tResult = GetFetchResult<\n\t\t\t\t[FixedOptions, TOptions, DefaultOptions, CommonOptions],\n\t\t\t\tT\n\t\t\t>,\n\t\t>(\n\t\t\t...args: DefaultUrl extends undefined\n\t\t\t\t? [url: FetchArgs[0], options?: TOptions]\n\t\t\t\t: [options?: TOptions]\n\t\t): IPromise_Fetch<Result> => {\n\t\t\tconst mergedOptions = mergeOptions(\n\t\t\t\tfetch.defaults,\n\t\t\t\tcommonOptions,\n\t\t\t\tdefaultOptions,\n\t\t\t\t(defaultUrl === undefined ? args[1] : args[0]) as TOptions,\n\t\t\t\tfixedOptions, // fixed options will always override other options\n\t\t\t) as FetchOptions\n\t\t\tmergedOptions.as ??= FetchAs.json\n\t\t\t// make sure to abort any previously pending request\n\t\t\t_abortCtrl?.abort?.()\n\t\t\t// ensure AbortController is present in options and propagete external abort signal if provided\n\t\t\t_abortCtrl = new AbortController()\n\n\t\t\treturn fetch(\n\t\t\t\t(defaultUrl ?? args[0]) as FetchArgs[0],\n\t\t\t\tmergedOptions,\n\t\t\t) as unknown as IPromise_Fetch<Result>\n\t\t}\n\n\t\treturn deferredCallback(fetchCb, {\n\t\t\t...commonDeferOptions,\n\t\t\t...deferOptions,\n\t\t} as DeferredAsyncOptions<ThisArg, CommonDelay>) as typeof fetchCb\n\t}\n\n\treturn client\n}\nexport default createClient\n","import { DeferredAsyncOptions, deferredCallback } from '@superutils/promise'\nimport { ClientData } from './createClient'\nimport fetch from './fetch'\nimport mergeOptions from './mergeOptions'\nimport {\n\tExcludePostOptions,\n\tFetchAs,\n\tPostArgs,\n\tPostDeferredCbArgs,\n\tPostOptions,\n\tIPromise_Fetch,\n\tGetFetchResult,\n\tContentType,\n} from './types'\n\n/**\n * Create a reusable fetch client with shared options. The returned function comes attached with a\n * `.deferred()` function for debounced and throttled request.\n * While `createClient()` is versatile enough for any HTTP method, `createPostClient()` is specifically designed for\n * methods that require a request body, such as `DELETE`, `PATCH`, `POST`, and `PUT`. If a method is not provided, it\n * defaults to `POST`. The generated client accepts an additional second parameter (`data`) for the request payload.\n *\n * Similar to `createClient`, the returned function comes equipped with a `.deferred()` method, enabling debounced,\n * throttled, or sequential execution.\n *\n * @example\n * #### Create reusable clients\n * ```javascript\n * import { createPostClient, FetchAs } from '@superutils/fetch'\n *\n * // Create a POST client with 10-second as the default timeout\n * const postClient = createPostClient(\n * \t{ // fixed options cannot be overrided by client calls\n * \t method: 'post',\n * \t headers: { 'content-type': 'application/json' },\n * \t},\n * \t{ timeout: 10000 }, // common options that can be overriden by client calls\n * )\n *\n * // Invoking `postClient()` automatically applies the pre-configured options\n * postClient(\n * \t '[DUMMYJSON-DOT-COM]/products/add',\n * \t { title: 'New Product' }, // data/body\n * \t {}, // other options\n * ).then(console.log)\n *\n * // create a deferred client using \"postClient\"\n * const updateProduct = postClient.deferred(\n * \t{\n * \t\tdelay: 300, // debounce duration\n * \t\tonResult: console.log, // prints only successful results\n * \t},\n * \t'[DUMMYJSON-DOT-COM]/products/add',\n * \t{ method: 'patch', timeout: 3000 },\n * )\n * updateProduct({ title: 'New title 1' }) // ignored by debounce\n * updateProduct({ title: 'New title 2' }) // executed\n * ```\n */\nexport const createPostClient = <\n\tFixedOptions extends PostOptions | undefined,\n\tCommonOptions extends ExcludePostOptions<FixedOptions> | undefined,\n\tCommonDelay extends number = number,\n>(\n\t/** Mandatory fetch options that cannot be overriden by individual request */\n\tfixedOptions?: FixedOptions,\n\t/** Common fetch options that can be overriden by individual request */\n\tcommonOptions?: PostOptions & CommonOptions,\n\tcommonDeferOptions?: DeferredAsyncOptions<unknown, CommonDelay>,\n) => {\n\t/**\n\t * Executes the HTTP request using the configured client options.\n\t *\n\t * This function is specifically designed for methods that require a request body (e.g., POST, PUT, PATCH),\n\t * allowing the payload to be passed directly as the second argument.\n\t */\n\tfunction client<\n\t\tT extends ClientData<FixedOptions> = never,\n\t\tOptions extends ExcludePostOptions<FixedOptions> | undefined =\n\t\t\t| ExcludePostOptions<FixedOptions>\n\t\t\t| undefined,\n\t\tResult = GetFetchResult<[FixedOptions, Options, CommonOptions], T>,\n\t>(\n\t\turl: PostArgs[0],\n\t\tdata?: PostArgs[1],\n\t\toptions?: Options,\n\t): IPromise_Fetch<Result> {\n\t\tconst mergedOptions = mergeOptions(\n\t\t\tcommonOptions,\n\t\t\toptions,\n\t\t\tfixedOptions, // fixed options will always override other options\n\t\t) as PostOptions\n\t\tmergedOptions.as ??= FetchAs.json\n\t\tmergedOptions.body = data ?? mergedOptions.body\n\t\tmergedOptions.method ??= 'post'\n\n\t\tconst headers = mergedOptions.headers as Headers\n\t\tif (!headers.get('content-type')) {\n\t\t\theaders.set('content-type', ContentType.APPLICATION_JSON)\n\t\t}\n\t\treturn fetch(url, mergedOptions)\n\t}\n\n\t/**\n\t * Returns a version of the client configured for debounced, throttled, or sequential execution.\n\t *\n\t * This is particularly useful for optimizing high-frequency operations, such as auto-saving forms\n\t * or managing rapid state updates, by automatically handling request cancellation and execution timing.\n\t */\n\tclient.deferred = <\n\t\tThisArg,\n\t\tDefaultUrl extends PostArgs[0] | undefined,\n\t\tDefaultData extends PostArgs[1] | undefined,\n\t\tDefaultOptions extends ExcludePostOptions<FixedOptions> | undefined =\n\t\t\t| ExcludePostOptions<FixedOptions>\n\t\t\t| undefined,\n\t\tDelay extends CommonDelay | number = number,\n\t>(\n\t\tdeferOptions?: DeferredAsyncOptions<ThisArg, Delay>,\n\t\tdefaultUrl?: DefaultUrl,\n\t\tdefaultData?: DefaultData,\n\t\tdefaultOptions?: DefaultOptions,\n\t) => {\n\t\tlet _abortCtrl: AbortController | undefined\n\t\tconst postCb = <\n\t\t\tT extends ClientData<FixedOptions> = never,\n\t\t\tOptions extends ExcludePostOptions<FixedOptions> | undefined =\n\t\t\t\t| ExcludePostOptions<FixedOptions>\n\t\t\t\t| undefined,\n\t\t\tTReturn = GetFetchResult<\n\t\t\t\t[FixedOptions, Options, DefaultOptions, CommonOptions],\n\t\t\t\tT\n\t\t\t>,\n\t\t>(\n\t\t\t...args: PostDeferredCbArgs<DefaultUrl, DefaultData, Options>\n\t\t): IPromise_Fetch<TReturn> => {\n\t\t\t// add default url to the beginning of the array\n\t\t\tif (defaultUrl !== undefined) args.splice(0, 0, defaultUrl)\n\t\t\t// add default data after the url\n\t\t\tif (defaultData !== undefined) args.splice(1, 0, defaultData)\n\t\t\tconst mergedOptions = mergeOptions(\n\t\t\t\tfetch.defaults,\n\t\t\t\tcommonOptions,\n\t\t\t\tdefaultOptions,\n\t\t\t\targs[2] as Options,\n\t\t\t\tfixedOptions, // fixed options will always override other options\n\t\t\t) as PostOptions\n\t\t\tmergedOptions.as ??= FetchAs.json\n\t\t\t// make sure to abort any previously pending request\n\t\t\t_abortCtrl?.abort?.()\n\t\t\t// ensure AbortController is present in options and propagete external abort signal if provided\n\t\t\t_abortCtrl = new AbortController()\n\n\t\t\t// attach body to options\n\t\t\tmergedOptions.body = (args[1] ?? mergedOptions.body) as PostArgs[1]\n\t\t\tmergedOptions.method ??= 'post'\n\n\t\t\tconst headers = mergedOptions.headers as Headers\n\t\t\tif (!headers.get('content-type')) {\n\t\t\t\theaders.set('content-type', ContentType.APPLICATION_JSON)\n\t\t\t}\n\t\t\treturn fetch(args[0] as PostArgs[0], mergedOptions)\n\t\t}\n\n\t\treturn deferredCallback(postCb, {\n\t\t\t...commonDeferOptions,\n\t\t\t...deferOptions,\n\t\t} as typeof deferOptions) as typeof postCb\n\t}\n\n\treturn client\n}\nexport default createPostClient\n","/** This is an entrypoint tailored for IIFE builds for browsers. */\nimport * as promiseExports from '@superutils/promise'\nimport * as fetchExports from './index'\n\n/**\n * Export the fetch function and include all other exports as it's property\n *\n * ### Usage:\n * - `window.superutils.fetch(...)`\n * - `window.superutils.fetch.get(...)`\n * - `window.superutils.fetch.createClient(...)`\n */\nconst fetch = fetchExports.default\n\nObject.keys(fetchExports).forEach(key => {\n\tif (['default', 'fetch'].includes(key)) return\n\t;(fetch as unknown as Record<string, unknown>)[key] ??= (\n\t\tfetchExports as Record<string, unknown>\n\t)[key]\n})\nexport default fetch\n\n/**\n * Include all exports from @supertuils/promise:\n * 1. as if it were imported independantly\n * 2. only adds ~0.5KB (95%+ of the code is already used by @superutils/fetch)\n * 3. eliminates the need to import it separately\n * window.superutils.fetch(...)\n * window.superutils.fetch.get(...)\n * window.superutils.fetch.createClient(...)\n *\n * Usage:\n * window.\n */\nconst PromisE = promiseExports.default\nObject.keys(promiseExports).forEach(key => {\n\tif (['default', 'PromisE'].includes(key)) return\n\t;(PromisE as unknown as Record<string, unknown>)[key] ??= (\n\t\tpromiseExports as Record<string, unknown>\n\t)[key]\n})\nconst w = globalThis as unknown as Record<string, Record<string, unknown>>\nw.superutils ??= {}\nw.superutils.PromisE ??= PromisE\n"]}
|
|
1
|
+
{"version":3,"sources":["../../../promise/dist/index.js","../../../core/dist/index.js","../../src/index.ts","../../src/executeInterceptors.ts","../../src/getResponse.ts","../../src/mergeOptions.ts","../../src/types/constants.ts","../../src/types/FetchError.ts","../../src/fetch.ts","../../src/createClient.ts","../../src/createPostClient.ts","../../src/browser.ts"],"names":["dist_exports","__export","PromisE","PromisEBase","Promise2","ResolveError","ResolveIgnored","TIMEOUT_FALLBACK","TIMEOUT_MAX","TimeoutPromise","index_default","deferred","deferredCallback","delay","delayReject","retry","timeout","isObj","x","strict","isArr","isInteger","isNumber","isPositiveInteger","isPositiveNumber","isEmpty","nonNumerable","fallback","proto","isFn","isUrl","isUrlValid","tldExceptions","url","y","_","isError","isPromise","isSymbol","fallbackIfFails","target","args","result","err","fallbackIfFails_default","objKeys","obj","sorted","includeSymbols","objKeys_default","clone","value","objCopy","input","output","ignoreKeys","override","recursive","_output","_ignoreKeys","inKeys","_key","key","ignoreChildKeys","arrUnique","arr","flatDepth","debounce","callback","config","leading","onError","thisArg","tid","_callback","firstArgs","leadingGlobal","debounce_default","throttle","d","trailing","handleCallback","trailArgs","cbArgs","throttle_default","options","ResolveError2","ResolveIgnored2","_PromisEBase","_resolve","_reject","superCalled","finalize","fn","resolve","fn2","reject","reason","_a","_b","values","promise","callbackFn","PromisEBase_default","sequence","onIgnore","onResult","delay2","ignoreStale","resolveError","resolveIgnored","lastInSeries","lastExecuted","queue","isSequential","handleIgnore","items","iId","iItem","isStale","handleRemaining","currentId","nextId","nextItem","handleItem","currentIndex","id","executeItem","qItem","deferred_default","deferPromise","deferredCallback_default","duration","asRejected","result2","_result","_result2","delay_default","delayReject_default","func","finalized","maxRetries","retryBackOff","retryDelay","retryDelayJitter","retryDelayJitterMax","_retryDelay","attemptCount","error","shouldRetry","jitter","retry_default","data","timeout2","_signals","_c","_d","signal","_e","s","TimeoutPromise_default","opts","promises","v","dataPromise","timeoutPromise","timeout_default","PromisE_default","index_exports","ContentType","FetchAs","FetchError","createClient","createPostClient","executeInterceptors","fetch","mergeOptions","interceptors","interceptor","executeInterceptors_default","getResponse","fetchFunc","res","count","abortCtrl","retryIf","getResponse_default","allOptions","merged","headers","ints1","ints2","toArr","mergeOptions_default","_FetchError","message","newMessage","defaultErrorMsgs","response","parseAs","onAbort","onTimeout","interceptErr","body","errMsgs","validateUrl","status","jsonError","parseFunc","_err","fetch_default","fixedOptions","commonOptions","commonDeferOptions","client","mergedOptions","deferOptions","defaultUrl","defaultOptions","_abortCtrl","createClient_default","defaultData","createPostClient_default","methods","browser_default","w"],"mappings":"mFAAA,IAAA,EAAA,CAAA,MAAA,CAAA,cAAA,CAAA,IAAA,EAAA,CAAA,CAAA,CAAA,CAAA,CAAA,GAAA,CAAA,IAAA,IAAA,CAAA,IAAA,CAAA,CAAA,EAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,GAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,UAAA,CAAA,IAAA,CAAA,EAAA,CAAA,CAAA,IAAAA,EAAAA,CAAA,EAAA,CAAAC,EAAAA,CAAAD,EAAAA,CAAA,aAAAE,CAAAA,CAAA,WAAA,CAAA,IAAAC,EAAAA,CAAA,OAAA,CAAA,IAAAC,EAAA,YAAA,CAAA,IAAAC,EAAAA,CAAA,cAAA,CAAA,IAAAC,EAAAA,CAAA,qBAAAC,CAAAA,CAAA,WAAA,CAAA,IAAAC,EAAAA,CAAA,cAAA,CAAA,IAAAC,GAAA,OAAA,CAAA,IAAAC,EAAAA,CAAA,QAAA,CAAA,IAAAC,EAAAA,CAAA,qBAAAC,CAAAA,CAAA,KAAA,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ferredSync,\n fallbackIfFails as fallbackIfFails2,\n isFn as isFn2,\n isPositiveNumber,\n objCopy\n} from \"@superutils/core\";\n\n// src/PromisEBase.ts\nimport { fallbackIfFails, isFn, isPromise } from \"@superutils/core\";\n\n// src/types/deferred.ts\nvar ResolveError = /* @__PURE__ */ ((ResolveError2) => {\n ResolveError2[\"NEVER\"] = \"NEVER\";\n ResolveError2[\"REJECT\"] = \"REJECT\";\n ResolveError2[\"WITH_ERROR\"] = \"RESOLVE_ERROR\";\n ResolveError2[\"WITH_UNDEFINED\"] = \"RESOLVE_UNDEFINED\";\n return ResolveError2;\n})(ResolveError || {});\nvar ResolveIgnored = /* @__PURE__ */ ((ResolveIgnored2) => {\n ResolveIgnored2[\"NEVER\"] = \"NEVER\";\n ResolveIgnored2[\"WITH_LAST\"] = \"WITH_LAST\";\n ResolveIgnored2[\"WITH_UNDEFINED\"] = \"WITH_UNDEFINED\";\n return ResolveIgnored2;\n})(ResolveIgnored || {});\n\n// src/types/Promise.ts\nvar Promise2 = globalThis.Promise;\n\n// src/PromisEBase.ts\nvar _PromisEBase = class _PromisEBase extends Promise2 {\n constructor(input) {\n let _resolve;\n let _reject;\n let superCalled = false;\n const finalize = (fn, resolve = true, value) => {\n if (!superCalled)\n return queueMicrotask(() => finalize(fn, resolve, value));\n fn(value);\n this._state = resolve ? 1 : 2;\n this.onFinalize.forEach(\n (fn2) => fallbackIfFails(\n fn2,\n resolve ? [value] : [void 0, value],\n void 0\n )\n );\n };\n super((resolve, reject) => {\n _reject = (reason) => finalize(reject, false, reason);\n _resolve = (value) => finalize(resolve, true, value);\n if (isFn(input)) {\n fallbackIfFails(input, [_resolve, _reject], _reject);\n } else if (isPromise(input)) {\n input.then(_resolve, _reject);\n } else if (input !== void 0) {\n _resolve(input);\n }\n });\n this._state = 0;\n /** Callbacks to be invoked whenever promise is finalized externally using `resolve()`/`reject()` methods */\n this.onEarlyFinalize = [];\n /** Callback to be invoked after promise is resolved or rejected */\n this.onFinalize = [];\n //\n //\n // --------------------------- Early resolve/reject ---------------------------\n //\n //\n /** Resovle pending promise early. */\n this.resolve = (value) => {\n var _a, _b;\n if (!this.pending) return;\n (_a = this._resolve) == null ? void 0 : _a.call(this, value);\n (_b = this.onEarlyFinalize) == null ? void 0 : _b.forEach((fn) => {\n fallbackIfFails(fn, [true, value], void 0);\n });\n };\n /** Reject pending promise early. */\n this.reject = (reason) => {\n var _a, _b;\n if (!this.pending) return;\n (_a = this._reject) == null ? void 0 : _a.call(this, reason);\n (_b = this.onEarlyFinalize) == null ? void 0 : _b.forEach((fn) => {\n fallbackIfFails(fn, [false, reason], void 0);\n });\n };\n superCalled = true;\n this._resolve = _resolve;\n this._reject = _reject;\n }\n //\n //\n //-------------------- Status related read-only attributes --------------------\n //\n //\n /** Indicates if the promise is still pending/unfinalized */\n get pending() {\n return this.state === 0;\n }\n /** Indicates if the promise has been rejected */\n get rejected() {\n return this.state === 2;\n }\n /** Indicates if the promise has been resolved */\n get resolved() {\n return this.state === 1;\n }\n /**\n * Get promise status code:\n *\n * - `0` = pending\n * - `1` = resolved\n * - `2` = rejected\n */\n get state() {\n return this._state;\n }\n};\n//\n//\n// Extend all static `Promise` methods\n//\n//\n/** Sugar for `new PromisE(Promise.all(...))` */\n_PromisEBase.all = (values) => new _PromisEBase(Promise2.all(values));\n/** Sugar for `new PromisE(Promise.allSettled(...))` */\n_PromisEBase.allSettled = (values) => new _PromisEBase(Promise2.allSettled(values));\n/** Sugar for `new PromisE(Promise.any(...))` */\n_PromisEBase.any = (values) => new _PromisEBase(Promise2.any(values));\n/** Sugar for `new PromisE(Promise.race(..))` */\n_PromisEBase.race = (values) => new _PromisEBase(Promise2.race(values));\n/** Extends Promise.reject */\n_PromisEBase.reject = (reason) => {\n const promise = new _PromisEBase();\n queueMicrotask(() => promise.reject(reason));\n return promise;\n};\n/** Sugar for `new PromisE(Promise.resolve(...))` */\n_PromisEBase.resolve = (value) => new _PromisEBase(Promise2.resolve(value));\n/** Sugar for `new PromisE(Promise.try(...))` */\n_PromisEBase.try = (callbackFn, ...args) => (\n // Promise.try is not supported in Node < 23.\n new _PromisEBase(\n fallbackIfFails(\n callbackFn,\n args,\n // rethrow error to ensure the returned promise is rejected\n (err) => _PromisEBase.reject(err)\n )\n )\n);\n/**\n * Creates a `PromisE` instance and returns it in an object, along with its `resolve` and `reject` functions.\n *\n * NB: this function is technically no longer needed because the `PromisE` class already comes with the resolvers.\n *\n * ---\n * @example\n * Using `PromisE` directly: simply provide an empty function as the executor\n *\n * ```typescript\n * import PromisE from '@superutils/promise'\n * const promisE = new PromisE<number>(() => {})\n * setTimeout(() => promisE.resolve(1), 1000)\n * promisE.then(console.log)\n * ```\n *\n * @example\n * Using `withResolvers`\n * ```typescript\n * import PromisE from '@superutils/promise'\n * const pwr = PromisE.withResolvers<number>()\n * setTimeout(() => pwr.resolve(1), 1000)\n * pwr.promise.then(console.log)\n * ```\n */\n_PromisEBase.withResolvers = () => {\n const promise = new _PromisEBase();\n return { promise, reject: promise.reject, resolve: promise.resolve };\n};\nvar PromisEBase = _PromisEBase;\nvar PromisEBase_default = PromisEBase;\n\n// src/deferred.ts\nfunction deferred(options = {}) {\n let sequence = 0;\n options = objCopy(\n deferred.defaults,\n options,\n [],\n \"empty\"\n );\n let { onError, onIgnore, onResult } = options;\n const {\n delay: delay2 = 0,\n ignoreStale,\n resolveError,\n resolveIgnored,\n thisArg,\n throttle\n } = options;\n let lastInSeries = null;\n let lastExecuted;\n const queue = /* @__PURE__ */ new Map();\n const isSequential = !isPositiveNumber(delay2);\n if (thisArg !== void 0) {\n onError = onError == null ? void 0 : onError.bind(thisArg);\n onIgnore = onIgnore == null ? void 0 : onIgnore.bind(thisArg);\n onResult = onResult == null ? void 0 : onResult.bind(thisArg);\n }\n const handleIgnore = (items) => {\n for (const [iId, iItem] of items) {\n queue.delete(iId);\n const isStale = ignoreStale && iItem.sequence < lastExecuted.sequence;\n if (iItem.resolved || iItem.started && !isStale) continue;\n if (iItem.started) {\n iItem.getPromise = (() => iItem.result);\n }\n fallbackIfFails2(onIgnore, [iItem.getPromise], 0);\n switch (resolveIgnored) {\n case \"WITH_UNDEFINED\" /* WITH_UNDEFINED */:\n iItem.resolve(void 0);\n break;\n case \"WITH_LAST\" /* WITH_LAST */:\n lastExecuted == null ? void 0 : lastExecuted.then(iItem.resolve, iItem.reject);\n break;\n case \"NEVER\" /* NEVER */:\n break;\n }\n }\n if (!queue.size) sequence = 0;\n };\n const handleRemaining = (currentId) => {\n lastInSeries = null;\n if (isSequential) {\n queue.delete(currentId);\n const [nextId, nextItem] = [...queue.entries()][0] || [];\n return nextId && nextItem && handleItem(nextId, nextItem);\n }\n let items = [...queue.entries()];\n if (throttle === true && options.trailing) {\n const currentIndex = items.findIndex(([id]) => id === currentId);\n items = items.slice(0, currentIndex);\n } else if (!throttle) {\n items = items.slice(0, -1);\n }\n handleIgnore(items);\n queue.delete(currentId);\n };\n const executeItem = async (id, qItem) => {\n var _a;\n try {\n qItem.started = true;\n lastExecuted = qItem;\n lastInSeries = qItem;\n (_a = qItem.result) != null ? _a : qItem.result = PromisEBase_default.try(qItem.getPromise);\n const result = await qItem.result;\n const isStale = !!ignoreStale && qItem.sequence < lastExecuted.sequence;\n if (isStale) return handleIgnore([[id, qItem]]);\n qItem.resolve(result);\n onResult && fallbackIfFails2(onResult, [result], void 0);\n } catch (err) {\n onError && fallbackIfFails2(onError, [err], void 0);\n switch (resolveError) {\n case \"REJECT\" /* REJECT */:\n qItem.reject(err);\n // eslint-disable-next-line no-fallthrough\n case \"NEVER\" /* NEVER */:\n break;\n case \"RESOLVE_UNDEFINED\" /* WITH_UNDEFINED */:\n qItem.resolve(void 0);\n break;\n case \"RESOLVE_ERROR\" /* WITH_ERROR */:\n qItem.resolve(err);\n break;\n }\n }\n handleRemaining(id);\n };\n const handleItem = isSequential ? executeItem : deferredSync(\n executeItem,\n delay2,\n options\n );\n return (promise) => {\n const id = /* @__PURE__ */ Symbol(\"deferred-queue-item-id\");\n const qItem = new PromisEBase_default();\n qItem.getPromise = isFn2(promise) ? promise : () => promise;\n qItem.started = false;\n qItem.sequence = ++sequence;\n queue.set(id, qItem);\n if (!lastInSeries || !isSequential) handleItem(id, qItem);\n return qItem;\n };\n}\ndeferred.defaults = {\n /**\n * Default delay in milliseconds, used in `debounce` and `throttle` modes.\n *\n * Use `0` (or negative number) to disable debounce/throttle and execute all operations sequentially.\n */\n delay: 100,\n /** Set the default error resolution behavior. {@link ResolveError} for all options. */\n resolveError: \"REJECT\" /* REJECT */,\n /** Set the default ignored resolution behavior. See {@link ResolveIgnored} for all options. */\n resolveIgnored: \"WITH_LAST\" /* WITH_LAST */\n};\nvar deferred_default = deferred;\n\n// src/deferredCallback.ts\nfunction deferredCallback(callback, options = {}) {\n const { thisArg } = options;\n if (thisArg !== void 0) callback = callback.bind(thisArg);\n const deferPromise = deferred_default(options);\n return (...args) => deferPromise(() => callback(...args));\n}\nvar deferredCallback_default = deferredCallback;\n\n// src/delay.ts\nimport { fallbackIfFails as fallbackIfFails3, isFn as isFn3 } from \"@superutils/core\";\nfunction delay(duration = delay.defaults.duration, result, asRejected = false) {\n const promise = new PromisEBase_default();\n const finalize = (result2) => {\n const _result = fallbackIfFails3(\n async () => {\n const _result2 = await (isFn3(result2) ? result2() : result2);\n return !asRejected ? _result2 != null ? _result2 : duration : _result2 != null ? _result2 : new Error(\n `${delay.defaults.delayTimeoutMsg} ${duration}ms`\n );\n },\n [],\n // when result is a function and it fails/rejects,\n // promise will reject even if `asRejected = false`\n (err) => Promise2.reject(err)\n );\n !asRejected ? promise.resolve(_result) : _result.then(promise.reject, promise.reject);\n };\n promise.timeoutId = setTimeout(() => finalize(result), duration);\n promise.pause = () => clearTimeout(promise.timeoutId);\n promise.catch(() => {\n }).finally(() => promise.pause());\n promise.onEarlyFinalize.push(() => promise.pause());\n return promise;\n}\ndelay.defaults = {\n /** Default delay duration in milliseconds */\n duration: 100,\n /** Default timed out message (if `result` is not provided) */\n delayTimeoutMsg: \"Timed out after\"\n};\nvar delay_default = delay;\n\n// src/delayReject.ts\nfunction delayReject(duration, reason) {\n return delay_default(duration, reason, true);\n}\nvar delayReject_default = delayReject;\n\n// src/retry.ts\nimport {\n fallbackIfFails as fallbackIfFails4,\n isEmpty,\n isPositiveInteger,\n objCopy as objCopy2\n} from \"@superutils/core\";\nvar retry = (func, options) => {\n let finalized = false;\n const promise = PromisEBase_default.try(async () => {\n var _a, _b;\n options = objCopy2(\n retry.defaults,\n options != null ? options : {},\n [],\n //\n (key, value) => {\n switch (key) {\n // case 'retryDelayJitter':\n // \treturn true\n case \"retry\":\n // eslint-disable-next-line no-fallthrough\n case \"retryDelay\":\n case \"retryDelayJitterMax\":\n return value !== 0 && !isPositiveInteger(value);\n }\n return !!isEmpty(value);\n }\n );\n const {\n retry: maxRetries,\n retryBackOff,\n retryDelay,\n retryDelayJitter,\n retryDelayJitterMax\n } = options;\n let _retryDelay = retryDelay;\n let attemptCount = 0;\n let result;\n let error;\n let shouldRetry = false;\n do {\n attemptCount++;\n if (retryDelay > 0 && !finalized && attemptCount > 0) {\n if (retryBackOff === \"exponential\" && attemptCount > 1)\n _retryDelay *= 2;\n const jitter = !retryDelayJitter ? 0 : Math.floor(Math.random() * retryDelayJitterMax);\n await delay_default(_retryDelay + jitter);\n }\n if (finalized) break;\n try {\n error = void 0;\n result = await func();\n } catch (err) {\n error = err != null ? err : new Error(err);\n }\n if (finalized || maxRetries === 0 || attemptCount > maxRetries)\n break;\n shouldRetry = !!((_b = await fallbackIfFails4(\n (_a = options.retryIf) != null ? _a : error,\n // if `retryIf` not provided, retry on error\n [result, attemptCount, error],\n error\n // if `retryIf` throws error, default to retry on error\n )) != null ? _b : error);\n } while (shouldRetry);\n if (error !== void 0) return Promise2.reject(error);\n return result;\n });\n promise.onEarlyFinalize.push(() => {\n finalized = true;\n });\n return promise;\n};\nretry.defaults = {\n retry: 1,\n retryBackOff: \"exponential\",\n retryDelay: 300,\n retryDelayJitter: true,\n retryDelayJitterMax: 100\n};\nvar retry_default = retry;\n\n// src/timeout.ts\nimport {\n arrUnique as arrUnique2,\n isFn as isFn4,\n isNumber,\n isObj as isObj2,\n isPositiveNumber as isPositiveNumber2,\n objCopy as objCopy3\n} from \"@superutils/core\";\n\n// src/TimeoutPromise.ts\nimport { arrUnique, fallbackIfFails as fallbackIfFails5, isObj } from \"@superutils/core\";\nvar TIMEOUT_FALLBACK = 1e4;\nvar TIMEOUT_MAX = 2147483647;\nvar TimeoutPromise = class extends PromisEBase_default {\n constructor(data, timeout2, options, _signals) {\n super(data);\n this.started = /* @__PURE__ */ new Date();\n this._setup = () => {\n var _a, _b, _c, _d;\n this._signals = arrUnique(\n [(_b = (_a = this.options) == null ? void 0 : _a.abortCtrl) == null ? void 0 : _b.signal, (_c = this.options) == null ? void 0 : _c.signal].filter(\n Boolean\n )\n );\n !this.onEarlyFinalize.includes(this._handleEarlyFinalize) && this.onEarlyFinalize.push(this._handleEarlyFinalize);\n !this.onFinalize.includes(this._handleFinalize) && this.onFinalize.push(this._handleFinalize);\n (_d = this._signals) == null ? void 0 : _d.forEach(\n (signal) => signal == null ? void 0 : signal.addEventListener(\n \"abort\",\n this._handleAbort\n )\n );\n };\n this._handleAbort = async () => {\n var _a, _b;\n let err = await fallbackIfFails5((_a = this.options) == null ? void 0 : _a.onAbort, [], void 0);\n err != null ? err : err = new Error(\n `Aborted after ${(/* @__PURE__ */ new Date()).getTime() - this.started.getTime()}ms`\n );\n (_b = err.name) != null ? _b : err.name = \"AbortError\";\n this.reject(err);\n };\n this._handleEarlyFinalize = () => {\n var _a, _b, _c, _d;\n ((_a = this.options) == null ? void 0 : _a.abortOnEarlyFinalize) && ((_d = (_c = (_b = this.options) == null ? void 0 : _b.abortCtrl) == null ? void 0 : _c.abort) == null ? void 0 : _d.call(_c));\n };\n // cleanup after execution\n this._handleFinalize = ((_, err) => {\n var _a, _b, _c, _d, _e;\n this.cancelAbort();\n this.clearTimeout();\n if (!this.timeout.rejected && !((_a = this._signals) == null ? void 0 : _a.find((x) => x == null ? void 0 : x.aborted)))\n return;\n ((_d = (_c = (_b = this.options) == null ? void 0 : _b.abortCtrl) == null ? void 0 : _c.signal) == null ? void 0 : _d.aborted) === false && ((_e = this.options) == null ? void 0 : _e.abortCtrl.abort(err));\n });\n this.data = data;\n this.options = isObj(options) ? options : {};\n this.timeout = timeout2;\n this._signals = _signals;\n this._setup();\n }\n get abortCtrl() {\n return this.options.abortCtrl;\n }\n get aborted() {\n var _a;\n return this.rejected && !this.timeout.rejected && !!((_a = this._signals) == null ? void 0 : _a.find((s) => s == null ? void 0 : s.aborted));\n }\n cancelAbort() {\n var _a;\n (_a = this._signals) == null ? void 0 : _a.forEach(\n (signal) => signal == null ? void 0 : signal.removeEventListener(\n \"abort\",\n this._handleAbort\n )\n );\n }\n clearTimeout() {\n clearTimeout(this.timeout.timeoutId);\n }\n get timedout() {\n return this.rejected && this.timeout.rejected;\n }\n};\nvar TimeoutPromise_default = TimeoutPromise;\n\n// src/timeout.ts\nfunction timeout(options, ...values) {\n var _a;\n const opts = objCopy3(\n timeout.defaults,\n isNumber(options) ? { timeout: options } : isObj2(options) ? options : {},\n [],\n \"empty\"\n );\n opts.timeout = Math.min(\n isPositiveNumber2(opts.timeout) ? opts.timeout : TIMEOUT_FALLBACK,\n TIMEOUT_MAX\n );\n const promises = values.map(\n (v) => isFn4(v) ? PromisEBase_default.try(v) : v\n );\n const dataPromise = promises.length <= 1 ? (\n // single promise resolves to a single result\n promises[0] instanceof PromisEBase_default ? promises[0] : new PromisEBase_default(promises[0])\n ) : (\n // multiple promises resolve to an array of results\n (isFn4(PromisEBase_default[opts.batchFunc]) ? PromisEBase_default[opts.batchFunc] : PromisEBase_default.all)(promises)\n );\n const timeoutPromise = delayReject_default(opts.timeout, opts.onTimeout);\n return new TimeoutPromise_default(\n PromisEBase_default.race([dataPromise, timeoutPromise]),\n timeoutPromise,\n opts,\n arrUnique2(\n [(_a = opts.abortCtrl) == null ? void 0 : _a.signal, opts.signal].filter(Boolean)\n )\n );\n}\ntimeout.defaults = {\n abortOnEarlyFinalize: true,\n batchFunc: \"all\",\n timeout: TIMEOUT_FALLBACK\n};\nvar timeout_default = timeout;\n\n// src/PromisE.ts\nvar PromisE = class extends PromisEBase_default {\n};\nPromisE.deferred = deferred_default;\nPromisE.deferredCallback = deferredCallback_default;\nPromisE.delay = delay_default;\nPromisE.delayReject = delayReject_default;\nPromisE.retry = retry_default;\nPromisE.timeout = timeout_default;\nvar PromisE_default = PromisE;\n\n// src/index.ts\nvar index_default = PromisE_default;\nexport {\n PromisE,\n PromisEBase,\n Promise2 as Promise,\n ResolveError,\n ResolveIgnored,\n TIMEOUT_FALLBACK,\n TIMEOUT_MAX,\n TimeoutPromise,\n index_default as default,\n deferred,\n deferredCallback,\n delay,\n delayReject,\n retry,\n timeout\n};\n","// src/curry.ts\nfunction curry(func, ...[arity = func.length]) {\n const curriedFn = (...args) => {\n const _args = args;\n if (_args.length >= arity) return func(...args);\n return (...nextArgs) => curriedFn(\n ..._args,\n ...nextArgs\n );\n };\n return curriedFn;\n}\n\n// src/is/isObj.ts\nvar isObj = (x, strict = true) => !!x && typeof x === \"object\" && (!strict || [\n Object.prototype,\n null\n // when an object is created using `Object.create(null)`\n].includes(Object.getPrototypeOf(x)));\nvar isObj_default = isObj;\n\n// src/is/isArr.ts\nvar isArr = (x) => Array.isArray(x);\nvar isArrObj = (x, strict = true) => isArr(x) && x.every((x2) => isObj(x2, strict));\nvar isArr2D = (x) => isArr(x) && x.every(isArr);\nvar isArrLike = (x) => isArr(x) || x instanceof Set || x instanceof Map;\nvar isArrLikeSafe = (x) => [\"[object Array]\", \"[object Map]\", \"[object Set]\"].includes(\n Object.prototype.toString.call(x)\n);\nvar isArrUnique = (x) => isArr(x) && new Set(x).size === x.length;\nvar isUint8Arr = (x) => x instanceof Uint8Array;\nvar isArr_default = isArr;\n\n// src/is/isDate.ts\nvar isDate = (x) => x instanceof Date;\nvar isDateValid = (date) => {\n const dateIsStr = typeof date === \"string\";\n if (!dateIsStr && !isDate(date)) return false;\n const dateObj = new Date(date);\n if (Number.isNaN(dateObj.getTime())) return false;\n if (!dateIsStr) return true;\n const [original, converted] = [date, dateObj.toISOString()].map(\n (y) => y.replace(/[TZ]/g, \"\").substring(0, 10)\n );\n return original === converted;\n};\nvar isDate_default = isDate;\n\n// src/is/isNumber.ts\nvar isInteger = (x) => Number.isInteger(x);\nvar isNegativeInteger = (x) => Number.isInteger(x) && x < 0;\nvar isNegativeNumber = (x) => isNumber(x) && x < 0;\nvar isNumber = (x) => typeof x === \"number\" && !Number.isNaN(x) && Number.isFinite(x);\nvar isPositiveInteger = (x) => isInteger(x) && x > 0;\nvar isPositiveNumber = (x) => isNumber(x) && x > 0;\n\n// src/is/isEmpty.ts\nvar isEmpty = (x, nonNumerable = false, fallback = false) => {\n if (x === null || x === void 0) return true;\n switch (typeof x) {\n case \"number\":\n return !isNumber(x);\n case \"string\":\n return !x.replaceAll(\"\t\", \"\").trim().length;\n case \"boolean\":\n case \"bigint\":\n case \"symbol\":\n case \"function\":\n return false;\n }\n if (x instanceof Date) return Number.isNaN(x.getTime());\n if (x instanceof Map || x instanceof Set) return !x.size;\n if (Array.isArray(x) || x instanceof Uint8Array) return !x.length;\n if (x instanceof Error) return !x.message.length;\n const proto = typeof x === \"object\" && Object.getPrototypeOf(x);\n if (proto === Object.prototype || proto === null) {\n return nonNumerable ? !Object.getOwnPropertyNames(x).length : !Object.keys(x).length;\n }\n return fallback;\n};\nvar isEmptySafe = (x, numberableOnly = false) => {\n const empty = isEmpty(x, numberableOnly, 0);\n if (empty !== 0) return empty;\n switch (Object.prototype.toString.call(x)) {\n case \"[object Uint8Array]\":\n return !x.length;\n case \"[object Date]\":\n return Number.isNaN(x.getTime());\n case \"[object Map]\":\n return !x.size;\n case \"[object Object]\":\n return !Object.keys(x).length;\n case \"[object Set]\":\n return !x.size;\n default:\n return false;\n }\n};\nvar isEmpty_default = isEmpty;\n\n// src/is/isEnv.ts\nvar isEnvBrowser = () => typeof window !== \"undefined\" && typeof (window == null ? void 0 : window.document) !== \"undefined\";\nvar isEnvNode = () => {\n var _a;\n return typeof process !== \"undefined\" && ((_a = process == null ? void 0 : process.versions) == null ? void 0 : _a.node) != null;\n};\nvar isEnvTouchable = () => {\n var _a, _b;\n return typeof window !== \"undefined\" && \"ontouchstart\" in ((_b = (_a = window == null ? void 0 : window.document) == null ? void 0 : _a.documentElement) != null ? _b : {});\n};\n\n// src/noop.ts\nfunction noop() {\n}\nasync function noopAsync() {\n}\n\n// src/is/isFn.ts\nvar isFn = (x) => typeof x === \"function\";\nvar isAsyncFn = (x) => x instanceof noopAsync.constructor && x[Symbol.toStringTag] === \"AsyncFunction\";\nvar isFn_default = isFn;\n\n// src/is/isMap.ts\nvar isMap = (x) => x instanceof Map;\nvar isMapObj = (x, strict = true) => isMap(x) && [...x.values()].every((value) => isObj_default(value, strict));\n\n// src/is/isUrl.ts\nvar isUrl = (x) => x instanceof URL;\nvar isUrlValid = (x, strict = true, tldExceptions = [\"localhost\"]) => {\n if (!x) return false;\n try {\n if (typeof x !== \"string\" && !isUrl(x)) return false;\n const url = isUrl(x) ? x : new URL(x);\n if (!strict) return true;\n const gotTld = tldExceptions.includes(url.hostname) || url.host.split(\".\").length > 1;\n if (!gotTld) return false;\n let y = `${x}`;\n if (y.endsWith(url.hostname)) y += \"/\";\n return url.href === y;\n } catch (_) {\n return false;\n }\n};\nvar isUrl_default = isUrl;\n\n// src/is/index.ts\nvar isBool = (x) => typeof x === \"boolean\" || x instanceof Boolean;\nvar isDefined = (x) => x !== void 0 && x !== null;\nvar isError = (x) => x instanceof Error;\nvar isPromise = (x) => x instanceof Promise;\nvar isRegExp = (x) => x instanceof RegExp;\nvar isSet = (x) => x instanceof Set;\nvar isStr = (x) => typeof x === \"string\";\nvar isSubjectLike = (x, withValue = false) => isObj_default(x, false) && isFn_default(x.subscribe) && isFn_default(x.next) && (!withValue || \"value\" in x);\nvar isSymbol = (x) => typeof x === \"symbol\";\nvar is = {\n arr: isArr_default,\n arr2D: isArr2D,\n arrLike: isArrLike,\n arrLikeSafe: isArrLikeSafe,\n arrObj: isArrObj,\n arrUnique: isArrUnique,\n asyncFn: isAsyncFn,\n bool: isBool,\n date: isDate_default,\n dateValid: isDateValid,\n defined: isDefined,\n empty: isEmpty_default,\n emptySafe: isEmptySafe,\n envBrowser: isEnvBrowser,\n envNode: isEnvNode,\n envTouchable: isEnvTouchable,\n error: isError,\n fn: isFn_default,\n integer: isInteger,\n map: isMap,\n mapObj: isMapObj,\n negativeInteger: isNegativeInteger,\n negativeNumber: isNegativeNumber,\n number: isNumber,\n obj: isObj_default,\n positiveInteger: isPositiveInteger,\n positiveNumber: isPositiveNumber,\n promise: isPromise,\n regExp: isRegExp,\n set: isSet,\n str: isStr,\n subjectLike: isSubjectLike,\n symbol: isSymbol,\n uint8Arr: isUint8Arr,\n url: isUrl_default,\n urlValid: isUrlValid\n};\n\n// src/fallbackIfFails.ts\nvar fallbackIfFails = (target, args, fallback) => {\n try {\n const result = !isFn(target) ? target : target(...isFn(args) ? args() : args);\n if (!isPromise(result)) return result;\n return result.catch(\n (err) => isFn(fallback) ? fallback(err) : fallback\n );\n } catch (err) {\n return isFn(fallback) ? fallback(err) : fallback;\n }\n};\nvar fallbackIfFails_default = fallbackIfFails;\n\n// src/toDatetimeLocal.ts\nvar toDatetimeLocal = (dateStr) => {\n const date = new Date(dateStr);\n if (!isDateValid(date)) return \"\";\n const year = date.getFullYear();\n const month = (date.getMonth() + 1).toString().padStart(2, \"0\");\n const day = date.getDate().toString().padStart(2, \"0\");\n const hours = date.getHours().toString().padStart(2, \"0\");\n const minutes = date.getMinutes().toString().padStart(2, \"0\");\n const res = `${year}-${month}-${day}T${hours}:${minutes}`;\n return res;\n};\n(/* @__PURE__ */ new Date()).getTime();\n\n// src/obj/objClean.ts\nvar objClean = (obj, keys, ignoreIfNotExist = true) => {\n const result = {};\n if (!isObj(obj) || !isArr(keys)) return result;\n const uniqKeys = arrUnique(\n keys.map((x) => String(x).split(\".\")[0])\n ).sort();\n for (const key of uniqKeys) {\n if (ignoreIfNotExist && !obj.hasOwnProperty(key)) continue;\n const value = obj[key];\n if (!isObj(value) || isSymbol(key)) {\n result[key] = value;\n continue;\n }\n const childPrefix = `${key}.`;\n const childKeys = keys.filter((k) => {\n var _a;\n return (_a = k == null ? void 0 : k.startsWith) == null ? void 0 : _a.call(k, childPrefix);\n }).map((k) => k.split(childPrefix)[1]);\n if (!childKeys.length) {\n result[key] = value;\n continue;\n }\n result[key] = objClean(\n value,\n childKeys\n );\n }\n return result;\n};\n\n// src/obj/objKeys.ts\nvar objKeys = (obj, sorted = true, includeSymbols = true) => (\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion\n fallbackIfFails_default(\n () => [\n ...includeSymbols && Object.getOwnPropertySymbols(obj) || [],\n ...sorted ? Object.keys(obj).sort() : Object.keys(obj)\n ],\n [],\n []\n )\n);\nvar objKeys_default = objKeys;\n\n// src/obj/objCopy.ts\nvar clone = (value, fallback = \"null\") => JSON.parse(fallbackIfFails_default(JSON.stringify, [value], fallback));\nvar objCopy = (input, output, ignoreKeys, override = false, recursive = true) => {\n const _output = isObj(output, false) || isFn(output) ? output : {};\n if (!isObj(input, false) && !isFn(output)) return _output;\n const _ignoreKeys = new Set(ignoreKeys != null ? ignoreKeys : []);\n const inKeys = objKeys_default(input, true, true).filter(\n (x) => !_ignoreKeys.has(x)\n );\n for (const _key of inKeys) {\n const key = _key;\n const value = input[key];\n const skip = _output.hasOwnProperty(key) && (override === \"empty\" ? !isEmpty(_output[key]) : isFn(override) ? !override(key, _output[key], value) : true);\n if (skip) continue;\n const isPrimitive = [void 0, null, Infinity, NaN].includes(value) || !isObj(value, false);\n if (isPrimitive) {\n _output[key] = value;\n continue;\n }\n _output[key] = (() => {\n switch (Object.getPrototypeOf(value)) {\n case Array.prototype:\n return clone(value, \"[]\");\n case ArrayBuffer.prototype:\n return value.slice(0);\n case Date.prototype:\n return new Date(value.getTime());\n case Map.prototype:\n return new Map(\n clone(\n Array.from(\n value\n ),\n \"[]\"\n )\n );\n case RegExp.prototype:\n return new RegExp(value);\n case Set.prototype:\n return new Set(\n clone(Array.from(value))\n );\n case Uint8Array.prototype:\n return new Uint8Array([...value]);\n case URL.prototype:\n return new URL(value);\n default:\n break;\n }\n if (isSymbol(key) || !recursive) return clone(value);\n const ignoreChildKeys = [..._ignoreKeys].map(\n (x) => String(x).startsWith(String(key).concat(\".\")) && String(x).split(String(key).concat(\".\"))[1]\n ).filter(Boolean);\n if (!ignoreChildKeys.length) return clone(value);\n return objCopy(\n value,\n _output[key],\n ignoreChildKeys,\n override,\n recursive\n );\n })();\n }\n return _output;\n};\n\n// src/obj/objCreate.ts\nvar objCreate = (keys = [], values = [], result) => {\n if (!isObj(result)) result = {};\n for (let i = 0; i < (isArr(keys) ? keys : []).length; i++) {\n ;\n result[keys[i]] = values == null ? void 0 : values[i];\n }\n return result;\n};\n\n// src/obj/objHasKeys.ts\nfunction objHasKeys(input = {}, keys = [], requireValue = false) {\n if (!isObj(input) || !isArr(keys)) return false;\n for (const key of keys) {\n if (!input.hasOwnProperty(key)) return false;\n if (requireValue && isEmpty(input[key])) return false;\n }\n return true;\n}\n\n// src/obj/objReadOnly.ts\nvar objReadOnly = (obj, config) => {\n if (!isObj(obj, false)) obj = {};\n const { add, revocable, silent = true } = config != null ? config : {};\n const [typeTitle, keyTitle] = isArr(obj) ? [\"array\", \"index\"] : [\"object\", \"property name\"];\n function handleSetProp(obj2, key, value) {\n const isUpdate = obj2[key] !== void 0;\n if (isUpdate && silent) return true;\n const allowAddition = !isUpdate && (!isFn(add) ? add : add(obj2, key, value));\n const shouldThrow = !silent && (isUpdate || !allowAddition);\n if (shouldThrow)\n throw new TypeError(\n `Mutation not allow on read-only ${typeTitle} ${keyTitle}: ${key.toString()}`\n );\n if (!allowAddition) return true;\n obj2[key] = value;\n return true;\n }\n const proxyHandler = {\n get: (obj2, key) => obj2[key],\n set: handleSetProp,\n defineProperty: (obj2, key, { value }) => handleSetProp(obj2, key, value),\n // Prevent removal of properties\n deleteProperty: (obj2, key) => {\n if (!silent && obj2.hasOwnProperty(key)) {\n throw new Error(\n `Mutation not allow on read-only ${typeTitle} ${keyTitle}: ${key.toString()}`\n );\n }\n return true;\n }\n };\n return revocable ? Proxy.revocable(obj, proxyHandler) : new Proxy(obj, proxyHandler);\n};\n\n// src/obj/objSetProp.ts\nvar objSetProp = (obj, key, falsyValue, condition, truthyValue) => {\n var _a;\n const result = !isObj(obj, false) ? {} : obj;\n falsyValue != null ? falsyValue : falsyValue = result[key];\n condition = isFn(condition) ? condition((_a = result[key]) != null ? _a : falsyValue, key, obj) : condition;\n result[key] = !condition ? falsyValue : truthyValue;\n return result;\n};\nvar objSetPropUndefined = (...[obj, key, ...args]) => (obj == null ? void 0 : obj[key]) === void 0 && objSetProp(obj, key, ...args) || obj;\n\n// src/obj/objSort.ts\nvar objSort = (obj, recursive = true, _done = /* @__PURE__ */ new Map()) => {\n const sorted = {};\n if (!isObj(obj)) return sorted;\n for (const key of objKeys_default(obj)) {\n const value = obj[key];\n _done.set(value, true);\n sorted[key] = !recursive || !isObj(value) ? value : objSort(\n value,\n recursive,\n _done\n );\n }\n return sorted;\n};\n\n// src/obj/objWithoutKeys.ts\nvar objWithoutKeys = (input, keys, output) => {\n if (!isObj(input, false)) return {};\n if (!isArr(keys) || !keys.length) return input;\n output = {\n ...isObj(output, false) && output,\n ...input\n };\n for (const key of keys) delete output[key];\n return output;\n};\n\n// src/arr/arrReadOnly.ts\nvar arrReadOnly = (arr, config = {}) => objReadOnly(new ReadOnlyArrayHelper(config, arr), config);\nvar ReadOnlyArrayHelper = class extends Array {\n constructor(config, arr) {\n var _a;\n (_a = config.silent) != null ? _a : config.silent = true;\n super(...arr);\n this.config = config;\n this.ignoreOrThrow = (returnValue) => {\n if (this.config.silent) return returnValue;\n throw new Error(\"Mutation not allowed on read-only array\");\n };\n this.pop = () => this.ignoreOrThrow(this[this.length - 1]);\n this.push = (...items) => !this.config.add ? this.ignoreOrThrow(this.length) : super.push(...items);\n this.reverse = () => this.ignoreOrThrow(this);\n this.shift = () => this.ignoreOrThrow(this[0]);\n this.splice = (..._ignoredArgs) => this.ignoreOrThrow([]);\n this.unshift = (..._ignoredArgs) => this.ignoreOrThrow(this.length);\n }\n // fromAsync = super.fromAsync\n // reduce = super.reduce\n // reduceRight = super.reduceRight\n};\n\n// src/arr/arrReverse.ts\nvar arrReverse = (arr, reverse2 = true, newArray = false) => {\n if (!isArr(arr)) return [];\n if (newArray) arr = [...arr];\n return reverse2 ? arr.reverse() : arr;\n};\n\n// src/arr/arrToMap.ts\nfunction arrToMap(arr, key, flatDepth = 0) {\n ;\n [key, flatDepth] = isNumber(key) ? [void 0, key] : [key, flatDepth];\n const flatEntries = (!isArr(arr) ? [] : flatDepth > 0 ? arr.flat(flatDepth) : arr).map((item, i, flatArr) => {\n var _a;\n return [\n (_a = isFn(key) ? key(item, i, flatArr) : isObj(item) && isDefined(key) ? item[key] : i) != null ? _a : i,\n item\n ];\n });\n return new Map(flatEntries);\n}\n\n// src/arr/arrUnique.ts\nvar arrUnique = (arr, flatDepth = 0) => !isArr(arr) ? [] : Array.from(new Set(arr.flat(flatDepth)));\n\n// src/deferred/debounce.ts\nvar debounce = (callback, delay = 50, config = {}) => {\n const {\n leading = debounce.defaults.leading,\n onError = debounce.defaults.onError,\n thisArg\n } = config;\n let { tid } = config;\n if (thisArg !== void 0) callback = callback.bind(thisArg);\n const _callback = (...args) => fallbackIfFails_default(callback, args, onError);\n let firstArgs = null;\n const leadingGlobal = leading === \"global\";\n return (...args) => {\n clearTimeout(tid);\n tid = setTimeout(() => {\n firstArgs !== args && _callback(...args);\n firstArgs = leadingGlobal ? true : null;\n }, delay);\n if (!leading || firstArgs) return;\n firstArgs = args;\n _callback(...args);\n };\n};\ndebounce.defaults = {\n /**\n * Set the default value of argument `leading` for the `deferred` function.\n * This change is applicable application-wide and only applies to any new invocation of `deferred()`.\n */\n leading: false,\n /**\n * Set the default value of argument `onError` for the `deferred` function.\n * This change is applicable application-wide and only applies to any new invocation of `deferred()`.\n */\n onError: void 0\n};\nvar debounce_default = debounce;\n\n// src/deferred/throttle.ts\nvar throttle = (callback, delay = 50, config = {}) => {\n const { defaults: d } = throttle;\n const { onError = d.onError, trailing = d.trailing, thisArg } = config;\n let { tid } = config;\n const handleCallback = (...args) => fallbackIfFails_default(\n thisArg !== void 0 ? callback.bind(thisArg) : callback,\n args,\n !isFn(onError) ? void 0 : (err) => fallbackIfFails_default(onError, [err], void 0)\n );\n let trailArgs = null;\n return (...args) => {\n if (tid) {\n trailArgs = args;\n return;\n }\n tid = setTimeout(() => {\n tid = void 0;\n if (!trailing) return;\n const cbArgs = trailArgs;\n trailArgs = null;\n cbArgs && cbArgs !== args && handleCallback(...cbArgs);\n }, delay);\n handleCallback(...args);\n };\n};\nthrottle.defaults = {\n onError: void 0,\n trailing: false\n};\nvar throttled = throttle;\nvar throttle_default = throttle;\n\n// src/deferred/deferred.ts\nvar deferred = (callback, delay = 50, options = {}) => options.throttle ? throttle_default(callback, delay, options) : debounce_default(callback, delay, options);\n\n// src/iterable/filter.ts\nvar filter = (data, predicate, limit, asArray, result) => {\n var _a;\n if (!isMap(result)) result = /* @__PURE__ */ new Map();\n if (!isPositiveInteger(limit)) limit = Infinity;\n for (const [key, item] of ((_a = data == null ? void 0 : data.entries) == null ? void 0 : _a.call(data)) || []) {\n if (result.size >= limit) break;\n fallbackIfFails_default(predicate != null ? predicate : item, [item, key, data], false) && result.set(key, item);\n }\n return asArray ? [...result.values()] : result;\n};\nvar filter_default = filter;\n\n// src/iterable/getSize.ts\nvar getSize = (x) => {\n if (!x) return 0;\n try {\n const s = \"size\" in x ? x.size : \"length\" in x ? x.length : 0;\n return isNumber(s) ? s : 0;\n } catch (_) {\n return 0;\n }\n};\nvar getSize_default = getSize;\n\n// src/iterable/getValues.ts\nvar getValues = (data) => {\n var _a;\n return [\n ...((_a = data == null ? void 0 : data.values) == null ? void 0 : _a.call(data)) || []\n ];\n};\nvar getValues_default = getValues;\n\n// src/iterable/search.ts\nvar search = (data, options) => {\n var _a;\n const ignore = !getSize_default(data) || isEmpty(options == null ? void 0 : options.query);\n const result = isMap(options == null ? void 0 : options.result) ? options.result : /* @__PURE__ */ new Map();\n const asMap = (_a = options == null ? void 0 : options.asMap) != null ? _a : search.defaults.asMap;\n if (ignore) return asMap ? result : getValues_default(result);\n options = objCopy(\n search.defaults,\n options,\n [],\n \"empty\"\n // override `option` property with default value when \"empty\" (undefined, null, '',....)\n );\n const {\n ignoreCase,\n limit = Infinity,\n matchAll,\n matchExact,\n ranked\n } = options;\n let { query } = options;\n const qIsStr = isStr(query);\n const qIsRegExp = isRegExp(query);\n const qKeys = fallbackIfFails_default(Object.keys, [query], []);\n if (ignoreCase && !matchExact && !qIsRegExp) {\n query = qIsStr ? query.toLowerCase() : objCreate(\n qKeys,\n Object.values(query).map(\n (x) => isRegExp(x) ? x : `${x}`.toLowerCase()\n )\n );\n }\n options.query = query;\n if (!ranked) {\n for (const [dataKey, dataValue] of data.entries()) {\n if (result.size >= limit) break;\n const matched = qIsStr || qIsRegExp ? (\n // global search across all properties\n matchObjOrProp(options, dataValue, void 0) >= 0\n ) : (\n // field-specific search\n qKeys[matchAll ? \"every\" : \"some\"](\n (key) => matchObjOrProp(options, dataValue, key) >= 0\n )\n );\n if (!matched) continue;\n result.set(dataKey, dataValue);\n }\n } else {\n const preRankedResults = [];\n for (const [dataKey, dataValue] of data.entries()) {\n let matchIndex = -1;\n if (qIsStr || qIsRegExp) {\n matchIndex = matchObjOrProp(options, dataValue, void 0);\n matchIndex >= 0 && preRankedResults.push([matchIndex, dataKey, dataValue]);\n continue;\n }\n const indexes = [];\n const match = qKeys[matchAll ? \"every\" : \"some\"](\n // field-specific search\n (key) => {\n const index = matchObjOrProp(options, dataValue, key);\n indexes.push(index);\n return index >= 0;\n }\n );\n if (!match) continue;\n matchIndex = // eslint-disable-next-line @typescript-eslint/prefer-find\n indexes.sort((a, b) => a - b).filter((n) => n !== -1)[0];\n matchIndex >= 0 && preRankedResults.push([matchIndex, dataKey, dataValue]);\n }\n preRankedResults.sort((a, b) => a[0] - b[0]).slice(0, limit).forEach(([_, key, value]) => result.set(key, value));\n }\n return asMap ? result : getValues_default(result);\n};\nsearch.defaults = {\n asMap: true,\n ignoreCase: true,\n limit: Infinity,\n matchAll: false,\n ranked: false,\n transform: true\n};\nfunction matchObjOrProp({\n query,\n ignoreCase,\n matchExact,\n transform = true\n}, item, propertyName) {\n var _a, _b;\n const global = isStr(query) || isRegExp(query) || propertyName === void 0;\n const keyword = global ? query : query[propertyName];\n const propVal = global || !isObj(item) ? item : item[propertyName];\n const value = fallbackIfFails_default(\n () => isFn(transform) ? transform(\n item,\n global ? void 0 : propVal,\n propertyName\n ) : matchExact && transform === false ? propVal : isObj(propVal, false) ? JSON.stringify(\n isArrLike(propVal) ? [...propVal.values()] : Object.values(propVal)\n ) : String(propVal != null ? propVal : \"\"),\n [],\n \"\"\n );\n if (value === keyword) return 0;\n if (matchExact && !isRegExp(keyword)) return -1;\n let valueStr = String(value);\n if (!valueStr.trim()) return -1;\n if (isRegExp(keyword)) return (_b = (_a = valueStr.match(keyword)) == null ? void 0 : _a.index) != null ? _b : -1;\n if (ignoreCase) valueStr = valueStr.toLowerCase();\n return valueStr.indexOf(String(keyword));\n}\nvar search_default = search;\n\n// src/iterable/find.ts\nfunction find(data, optsOrCb) {\n const result = isFn(optsOrCb) ? filter_default(data, optsOrCb, 1) : search_default(data, { ...optsOrCb, asMap: true, limit: 1 });\n return result[\n (optsOrCb == null ? void 0 : optsOrCb.includeKey) ? \"entries\" : \"values\"\n // returns: value\n ]().next().value;\n}\n\n// src/iterable/getEntries.ts\nvar getEntries = (map) => {\n var _a;\n return [\n ...((_a = map == null ? void 0 : map.entries) == null ? void 0 : _a.call(map)) || []\n ];\n};\n\n// src/iterable/getKeys.ts\nvar getKeys = (data) => {\n var _a;\n return [\n ...((_a = data == null ? void 0 : data.keys) == null ? void 0 : _a.call(data)) || []\n ];\n};\n\n// src/iterable/reverse.ts\nvar reverse = (data, reverse2 = true, newInstance = false) => {\n var _a, _b, _c;\n const dataType = isArr(data) ? 1 : isMap(data) ? 2 : isSet(data) ? 3 : 0;\n if (!dataType) return [];\n const arr = dataType === 1 ? !newInstance ? data : [...data] : dataType === 2 ? [...data.entries()] : [...data.values()];\n if (reverse2) arr.reverse();\n switch (dataType) {\n case 1:\n return arr;\n case 2:\n case 3:\n if (newInstance || !(\"clear\" in data && isFn(data.clear)))\n return dataType === 2 ? new Map(arr) : new Set(arr);\n }\n (_a = data == null ? void 0 : data.clear) == null ? void 0 : _a.call(data);\n for (const item of arr)\n \"set\" in data ? (_b = data.set) == null ? void 0 : _b.call(data, ...item) : \"add\" in data && ((_c = data == null ? void 0 : data.add) == null ? void 0 : _c.call(data, item));\n return data;\n};\n\n// src/iterable/sliceMap.ts\nvar sliceMap = (data, options) => {\n var _a;\n const {\n asMap = false,\n end,\n start = 0,\n transform,\n ignoreEmpty = true\n } = isFn(options) ? { transform: options } : isObj(options) ? options : {};\n const result = /* @__PURE__ */ new Map();\n const subset = [...((_a = data == null ? void 0 : data.entries) == null ? void 0 : _a.call(data)) || []].slice(start, end);\n for (const [_, [key, value]] of subset.entries()) {\n if (ignoreEmpty && isEmpty(value)) continue;\n const newValue = fallbackIfFails_default(\n transform != null ? transform : value,\n [value, key, data],\n void 0\n );\n newValue !== void 0 && result.set(key, newValue);\n }\n return asMap ? result : [...result.values()];\n};\n\n// src/iterable/sort.ts\nfunction sort(data, keyOrFn, options) {\n const dataType = isArr(data) ? 1 : isMap(data) ? 2 : isSet(data) ? 3 : 0;\n if (!dataType) return data;\n const { asString, ignoreCase, newInstance, reverse: reverse2, undefinedFirst } = {\n ...sort.defaults,\n ...isObj(options) ? options : isObj(keyOrFn) ? keyOrFn : {}\n };\n if (dataType === 1 && isFn(keyOrFn)) {\n return arrReverse(\n data.sort(keyOrFn),\n // use provided comparator function\n reverse2,\n newInstance\n );\n }\n const alt = asString ? undefinedFirst ? \"\" : \"Z\".repeat(10) : undefinedFirst ? -Infinity : Infinity;\n const sorted = isFn(keyOrFn) ? arrReverse(\n // handle Set with comparator function\n [...data.entries()].sort(keyOrFn),\n reverse2,\n false\n // not required because of entries() & spread\n ) : (() => {\n let index = 1;\n const getVal = (target) => {\n const val = isObj(target) && index !== 0 ? target[keyOrFn] : target;\n if (!asString) return val;\n const value = `${val != null ? val : alt}`;\n return ignoreCase ? value.toLowerCase() : value;\n };\n const [gt, lt] = reverse2 ? [-1, 1] : [1, -1];\n if ([1, 3].includes(dataType)) {\n return (dataType === 3 || newInstance ? [...data] : data).sort((a, b) => getVal(a) > getVal(b) ? gt : lt);\n }\n index = keyOrFn === true ? 0 : 1;\n return [...data.entries()].sort(\n (a, b) => getVal(a == null ? void 0 : a[index]) > getVal(b == null ? void 0 : b[index]) ? gt : lt\n );\n })();\n if (dataType === 1) return sorted;\n if (newInstance) {\n return dataType === 2 ? new Map(sorted) : new Set(sorted);\n }\n ;\n data.clear();\n for (const entry of sorted)\n dataType === 2 ? data.set(...entry) : data.add(entry);\n return data;\n}\nsort.defaults = {\n asString: true,\n ignoreCase: true,\n newInstance: false,\n reverse: false,\n undefinedFirst: false\n};\n\n// src/map/mapJoin.ts\nvar mapJoin = (...inputs) => {\n var _a;\n return new Map(\n (_a = inputs == null ? void 0 : inputs.flatMap) == null ? void 0 : _a.call(\n inputs,\n (input) => isMap(input) ? Array.from(input.entries()) : isArr2D(input) ? input : []\n )\n );\n};\n\n// src/number/randomInt.ts\nvar randomInt = (min = 0, max = Number.MAX_SAFE_INTEGER) => parseInt(`${Math.random() * (max - min) + min}`);\n\n// src/str/clearClutter.ts\nvar clearClutter = (text, lineSeparator = \" \") => `${text}`.split(\"\\n\").map((ln) => ln.trim()).filter(Boolean).join(lineSeparator);\n\n// src/str/copyToClipboard.ts\nvar copyToClipboard = (str) => fallbackIfFails(\n // First attempt: modern clipboard API\n () => navigator.clipboard.writeText(str).then(() => 1),\n [],\n // If clipboard API is not available or fails, use the fallback method\n () => Promise.resolve(copyLegacy(str) ? 2 : 0)\n);\nvar copyLegacy = (str) => fallbackIfFails(\n () => {\n const el = document.createElement(\"textarea\");\n el.value = str;\n el.setAttribute(\"readonly\", \"\");\n el.style.position = \"absolute\";\n el.style.left = \"-9999px\";\n document.body.appendChild(el);\n el.select();\n const success = document.execCommand(\"copy\");\n document.body.removeChild(el);\n return success;\n },\n [],\n false\n // On error, return false\n);\n\n// src/str/getUrlParam.ts\nvar getUrlParam = (name, url, asArray) => {\n var _a;\n url != null ? url : url = fallbackIfFails_default(() => window.location.href, [], \"\");\n const _asArray = isArr(asArray) ? asArray : asArray === true && isStr(name) ? [name] : [];\n const prepareResult = (value = \"\", values = {}) => name ? isArr(value) || !_asArray.includes(name) ? value : [value].filter(Boolean) : values;\n if (!url) return prepareResult();\n if (typeof URLSearchParams === \"undefined\" || !URLSearchParams) {\n const r = getUrlParamRegex(name, url, _asArray);\n return prepareResult(r, r);\n }\n const search2 = isUrl(url) ? url.search : ((_a = url.split(\"?\")) == null ? void 0 : _a[1]) || \"\";\n if (search2 === \"?\" || !search2) return prepareResult();\n const params = new URLSearchParams(search2);\n const getValue = (paramName) => {\n const value = arrUnique(params.getAll(paramName));\n return value.length > 1 || _asArray.includes(paramName) ? value : value[0];\n };\n if (name) return prepareResult(getValue(name));\n const result = {};\n for (const name2 of arrUnique([...params.keys()])) {\n result[name2] = getValue(name2);\n }\n return result;\n};\nvar getUrlParamRegex = (name, url, asArray = []) => {\n url != null ? url : url = fallbackIfFails_default(() => window.location.href, [], \"\");\n if (isUrl(url)) url = url.toString();\n const params = {};\n const regex = /[?&]+([^=&]+)=([^&]*)/gi;\n url == null ? void 0 : url.replace(regex, (_, name2, value) => {\n value = decodeURIComponent(value);\n if (asArray.includes(name2) || params[name2] !== void 0) {\n params[name2] = isArr(params[name2]) ? params[name2] : [params[name2]];\n params[name2] = arrUnique([...params[name2], value]).filter(Boolean);\n } else {\n params[name2] = value;\n }\n return \"\";\n });\n return name ? params[name] : params;\n};\n\n// src/str/regex.ts\nvar EMAIL_REGEX = new RegExp(\n /^((\"[\\w-\\s]+\")|([\\w-]+(?:\\.[\\w-]+)*)|(\"[\\w-\\s]+\")([\\w-]+(?:\\.[\\w-]+)*))(@((?:[\\w-]+\\.)*\\w[\\w-]{0,66})\\.([a-z]{2,9}(?:\\.[a-z]{2})?)$)|(@\\[?((25[0-5]\\.|2[0-4][0-9]\\.|1[0-9]{2}\\.|[0-9]{1,2}\\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\\]?$)/i\n);\nvar HEX_REGEX = /^0x[0-9a-f]+$/i;\nvar HASH_REGEX = /^0x[0-9a-f]{64}$/i;\n\n// src/str/strToArr.ts\nvar strToArr = (value, seperator = \",\") => typeof value === \"string\" && value.split(seperator).filter(Boolean) || [];\nexport {\n EMAIL_REGEX,\n HASH_REGEX,\n HEX_REGEX,\n ReadOnlyArrayHelper,\n arrReadOnly,\n arrReverse,\n arrToMap,\n arrUnique,\n clearClutter,\n copyToClipboard,\n curry,\n debounce,\n deferred,\n fallbackIfFails,\n filter,\n find,\n getEntries,\n getKeys,\n getSize,\n getUrlParam,\n getValues,\n is,\n isArr,\n isArr2D,\n isArrLike,\n isArrLikeSafe,\n isArrObj,\n isArrUnique,\n isAsyncFn,\n isBool,\n isDate,\n isDateValid,\n isDefined,\n isEmpty,\n isEmptySafe,\n isEnvBrowser,\n isEnvNode,\n isEnvTouchable,\n isError,\n isFn,\n isInteger,\n isMap,\n isMapObj,\n isNegativeInteger,\n isNegativeNumber,\n isNumber,\n isObj,\n isPositiveInteger,\n isPositiveNumber,\n isPromise,\n isRegExp,\n isSet,\n isStr,\n isSubjectLike,\n isSymbol,\n isUint8Arr,\n isUrl,\n isUrlValid,\n mapJoin,\n matchObjOrProp,\n noop,\n noopAsync,\n objClean,\n objCopy,\n objCreate,\n objHasKeys,\n objKeys,\n objReadOnly,\n objSetProp,\n objSetPropUndefined,\n objSort,\n objWithoutKeys,\n randomInt,\n reverse,\n search,\n sliceMap,\n sort,\n strToArr,\n throttle,\n throttled,\n toDatetimeLocal\n};\n","/* eslint-disable @typescript-eslint/no-unused-vars */\n\n// Re-export fetch relevant & useful things from '@superutils/promise' for ease of use\nexport {\n\tResolveError,\n\tResolveIgnored,\n\tTIMEOUT_FALLBACK,\n\tTIMEOUT_MAX,\n\tTimeoutPromise,\n} from '@superutils/promise'\nexport type {\n\tDeferredAsyncOptions,\n\tOnEarlyFinalize,\n\tOnFinalize,\n\tRetryIfFunc,\n\tRetryOptions,\n\tTimeoutOptions,\n} from '@superutils/promise'\n\n/* All local exports */\nexport * from './createClient'\nexport * from './createPostClient'\nexport * from './executeInterceptors'\nexport * from './fetch'\nexport * from './getResponse'\nexport * from './mergeOptions'\nexport * from './types'\nimport createClient from './createClient'\nimport createPostClient from './createPostClient'\nimport _fetch from './fetch'\nimport { FetchAs, FetchCustomOptions, FetchInterceptors } from './types'\n\nconst methods = {\n\t/** Make HTTP requests with method GET */\n\tget: createClient({ method: 'get' }),\n\n\t/** Make HTTP requests with method HEAD */\n\thead: createClient({ method: 'head' }),\n\n\t/** Make HTTP requests with method OPTIONS */\n\toptions: createClient({ method: 'options' }),\n\n\t/** Make HTTP requests with method DELETE */\n\tdelete: createPostClient({ method: 'delete' }),\n\n\t/** Make HTTP requests with method PATCH */\n\tpatch: createPostClient({ method: 'patch' }),\n\n\t/** Make HTTP requests with method POST */\n\tpost: createPostClient({ method: 'post' }),\n\n\t/** Make HTTP requests with method PUT */\n\tput: createPostClient({ method: 'put' }),\n}\n\n/**\n * A `fetch()` replacement that simplifies data fetching with automatic JSON parsing, request timeouts, retries,\n * and handy interceptors that also work as transformers. It also includes deferred and throttled request\n * capabilities for complex asynchronous control flows.\n *\n * Will reject promise if response status code is not 2xx (200 <= status < 300).\n *\n * ## Method Specific Functions\n *\n * While `fetch()` provides access to all HTTP request methods by specifying it in options (eg: `{ method: 'get' }`),\n * for ease of use you can also use the following:\n *\n * - `fetch.delete(...)`\n * - `fetch.get(...)`\n * - `fetch.head(...)`\n * - `fetch.options(...)`\n * - `fetch.patch(...)`\n * - `fetch.post(...)`\n * - `fetch.put(...)`\n *\n * **Deferred variants:** To debounce/throttle requests.\n *\n * - `fetch.delete.deferred(...)`\n * - `fetch.get.deferred(...)`\n * - `fetch.head.deferred(...)`\n * - `fetch.options.deferred(...)`\n * - `fetch.patch.deferred(...)`\n * - `fetch.post.deferred(...)`\n * - `fetch.put.deferred(...)`\n *\n * @template T The type of the value that the `fetch` resolves to.\n * @template TReturn Return value type.\n *\n * If `T` is not specified defaults to the following based on the value of `options.as`:\n * - FetchAs.arrayBuffer: `ArrayBuffer`\n * - FetchAs.blob: `Blob`\n * - FetchAs.bytes: `Uint8Array<ArrayBuffer>`\n * - FetchAs.formData: `FormData`\n * - FetchAs.json: `unknown`\n * - FetchAs.text: `string`\n * - FetchAs.response: `Response`\n *\n * @param url\n * @param options (optional) Standard `fetch` options extended with {@link FetchCustomOptions}\n * @param options.abortCtrl (optional) if not provided `AbortController` will be instantiated when `timeout` used.\n *\n * Default: `new AbortController()`\n * @param options.as (optional) (optional) specify how to parse the result.\n * For raw `Response` use {@link FetchAs.response}\n *\n * Default: {@link FetchAs.json}\n * @param options.headers (optional) request headers\n *\n * Default: `{ 'content-type': 'application/json' }`\n * @param options.interceptors (optional) request interceptor/transformer callbacks.\n * See {@link FetchInterceptors} for details.\n * @param options.method (optional) fetch method.\n *\n * Default: `'get'`\n * @param options.timeout (optional) duration in milliseconds to abort the request.\n * This duration includes the execution of all interceptors/transformers.\n *\n * Default: `60_000`\n *\n * ---\n *\n * @example\n * #### Drop-in replacement for built-in fetch\n *\n * ```javascript\n * import fetch from '@superutils/fetch'\n *\n * fetch('[DUMMYJSON-DOT-COM]/products/1')\n * .then(response => response.json())\n * .then(console.log, console.error)\n * ```\n *\n * @example\n * #### Method specific function with JSON parsing by default\n * ```javascript\n * import fetch from '@superutils/fetch'\n *\n * // no need for `response.json()` or \"result.data.data\" drilling\n * fetch.get('[DUMMYJSON-DOT-COM]/products/1')\n * .then(product => console.log(product))\n * fetch.post('[DUMMYJSON-DOT-COM]/products/add', { title: 'Product title' })\n * .then(product => console.log(product))\n * ```\n *\n * @example\n * #### Set default options.\n *\n * Options' default values (excluding `as` and `method`) can be configured to be EFFECTIVE GLOBALLY.\n *\n * ```typescript\n * import fetch from '@superutils/fetch'\n *\n * const { defaults, errorMsgs, interceptors } = fetch\n *\n * // set default request timeout duration in milliseconds\n * defaults.timeout = 40_000\n *\n * // default headers\n * defaults.headers = { 'content-type': 'text/plain' }\n *\n * // override error messages\n * errorMsgs.invalidUrl = 'URL is not valid'\n * errorMsgs.timedout = 'Request took longer than expected'\n *\n * // add an interceptor to log all request failures.\n * const fetchLogger = (fetchErr, url, options) => console.log('Fetch error log', fetchErr)\n * interceptors.error.push(fetchLogger)\n *\n * // add an interceptor to conditionally include header before making requests\n * interceptors.request.push((url, options) => {\n * // ignore login requests\n * if (`${url}`.includes('/login')) return\n *\n * options.headers.set('x-auth-token', 'my-auth-token')\n * })\n * ```\n */\nexport const fetch = _fetch as typeof _fetch & typeof methods\nfetch.delete = methods.delete\nfetch.get = methods.get\nfetch.head = methods.head\nfetch.options = methods.options\nfetch.patch = methods.patch\nfetch.post = methods.post\nfetch.put = methods.put\n\nexport default fetch\n","import { fallbackIfFails, isFn } from '@superutils/core'\nimport { type Interceptor } from './types'\n\n/**\n * Gracefully executes interceptors and returns the processed value.\n * If the value is not transformed (by returning a new value) by the interceptors,\n * the original value is returned.\n *\n * @param\tvalue value to be passed to the interceptors\n * @param\tsignal The AbortController used to monitor the request status. If the signal is aborted (e.g. due to\n * timeout or manual cancellation), the interceptor chain halts immediately. Note: This does not interrupt the\n * currently executing interceptor, but prevents subsequent ones from running.\n * @param\tinterceptors interceptor/transformer callbacks\n * @param\targs (optional) common arguments to be supplied to all the interceptors in addition to\n * the `value' which will always be the first argument.\n *\n * Interceptor arguments: `[value, ...args]`\n */\nexport const executeInterceptors = async <T, TArgs extends unknown[]>(\n\tvalue: T,\n\tsignal?: AbortSignal,\n\tinterceptors?: Interceptor<T, TArgs>[],\n\t...args: TArgs\n) => {\n\tfor (const interceptor of [...(interceptors ?? [])].filter(isFn)) {\n\t\tif (signal?.aborted) break\n\t\tvalue =\n\t\t\t((await fallbackIfFails(\n\t\t\t\tinterceptor,\n\t\t\t\t[value, ...args],\n\t\t\t\tundefined,\n\t\t\t)) as T) ?? value // if throws error or undefined/null is returned\n\t}\n\treturn value\n}\n\nexport default executeInterceptors\n","import { fallbackIfFails, isFn, isPositiveInteger } from '@superutils/core'\nimport { retry } from '@superutils/promise'\nimport { FetchArgs, FetchFunc } from './types'\n\n/**\n * Executes the built-in `fetch()` (or a custom `fetchFunc` if provided) with support for automatic retries.\n *\n * If `options.retry` is greater than 0, the request will be retried if it fails or if the response is not OK,\n * unless overridden by `options.retryIf`.\n *\n * @param url The request URL.\n * @param options (optional) Fetch options, including retry settings.\n *\n * @returns A promise resolving to the Response.\n */\n// intentionally not exported\nconst getResponse = (url: FetchArgs[0], options: FetchArgs[1] = {}) => {\n\tconst fetchFunc = isFn(options.fetchFunc)\n\t\t? options.fetchFunc\n\t\t: (getResponse.fetch as FetchFunc)\n\tif (!isPositiveInteger(options.retry)) return fetchFunc(url, options)\n\n\tlet attemptCount = 0\n\tconst response = retry(\n\t\t() => {\n\t\t\tattemptCount++\n\t\t\treturn fetchFunc(url, options)\n\t\t},\n\t\t{\n\t\t\t...options,\n\t\t\tretryIf: async (res, count, error) => {\n\t\t\t\tconst { abortCtrl, retryIf, signal } = options\n\t\t\t\tif (signal?.aborted || abortCtrl?.signal?.aborted) return false\n\n\t\t\t\treturn !!(\n\t\t\t\t\t(await fallbackIfFails(\n\t\t\t\t\t\tretryIf,\n\t\t\t\t\t\t[res, count, error],\n\t\t\t\t\t\tundefined,\n\t\t\t\t\t))\n\t\t\t\t\t?? (!!error || !res?.ok)\n\t\t\t\t)\n\t\t\t},\n\t\t},\n\t).catch(err =>\n\t\tPromise.reject(\n\t\t\tnew Error(`Request failed after attempt #${attemptCount}`, {\n\t\t\t\tcause: err,\n\t\t\t}),\n\t\t),\n\t)\n\n\treturn response\n}\n/** Preserve `globalThis.fetch` */\ngetResponse.fetch = globalThis.fetch\nexport default getResponse\n","import { isArr, isFn, isObj, objCopy } from '@superutils/core'\nimport { FetchOptions, FetchOptionsInterceptor } from './types'\n\n/**\n * Merge one or more {@link FetchOptions}\n *\n * Notes:\n * - item properties will be prioritized in the order of sequence they were passed in\n * - the following properties will be merged:\n * * `errMsgs`\n * * `headers`\n * * `interceptors`\n * - all other properties will simply override previous values\n *\n * @returns combined\n */\nexport const mergeOptions = (...allOptions: (FetchOptions | undefined)[]) =>\n\tallOptions.reduce(\n\t\t(merged: FetchOptions, options) => {\n\t\t\toptions = isObj(options) ? options : {}\n\t\t\tconst { headers, interceptors: ints1 = {} } = merged\n\t\t\tconst { interceptors: ints2 = {} } = options\n\t\t\toptions.headers\n\t\t\t\t&& new Headers(options.headers).forEach((value, key) =>\n\t\t\t\t\t(headers as Headers).set(key, value),\n\t\t\t\t)\n\n\t\t\treturn {\n\t\t\t\t...merged,\n\t\t\t\t...options,\n\t\t\t\terrMsgs: objCopy(\n\t\t\t\t\toptions.errMsgs as Record<string, string>,\n\t\t\t\t\tmerged.errMsgs,\n\t\t\t\t\t[],\n\t\t\t\t\t'empty',\n\t\t\t\t),\n\t\t\t\theaders,\n\t\t\t\tinterceptors: {\n\t\t\t\t\terror: [...toArr(ints1?.error), ...toArr(ints2?.error)],\n\t\t\t\t\trequest: [\n\t\t\t\t\t\t...toArr(ints1?.request),\n\t\t\t\t\t\t...toArr(ints2?.request),\n\t\t\t\t\t],\n\t\t\t\t\tresponse: [\n\t\t\t\t\t\t...toArr(ints1?.response),\n\t\t\t\t\t\t...toArr(ints2?.response),\n\t\t\t\t\t],\n\t\t\t\t\tresult: [...toArr(ints1?.result), ...toArr(ints2?.result)],\n\t\t\t\t},\n\t\t\t\ttimeout: options.timeout ?? merged.timeout,\n\t\t\t} as FetchOptions\n\t\t},\n\t\t{ headers: new Headers() },\n\t) as FetchOptionsInterceptor\nexport default mergeOptions\n\nconst toArr = <T = unknown>(x?: T | T[]) => (isArr(x) ? x : isFn(x) ? [x] : [])\n","/** Commonly used content types for easier access */\nexport const ContentType = {\n\tAPPLICATION_JAVASCRIPT: 'application/javascript',\n\tAPPLICATION_JSON: 'application/json',\n\tAPPLICATION_OCTET_STREAM: 'application/octet-stream',\n\tAPPLICATION_PDF: 'application/pdf',\n\tAPPLICATION_X_WWW_FORM_URLENCODED: 'application/x-www-form-urlencoded',\n\tAPPLICATION_XML: 'application/xml',\n\tAPPLICATION_ZIP: 'application/zip',\n\tAUDIO_MPEG: 'audio/mpeg',\n\tMULTIPART_FORM_DATA: 'multipart/form-data',\n\tTEXT_CSS: 'text/css',\n\tTEXT_HTML: 'text/html',\n\tTEXT_PLAIN: 'text/plain',\n\tVIDEO_MP4: 'video/mp4',\n} as const\n\nexport enum FetchAs {\n\tarrayBuffer = 'arrayBuffer',\n\tblob = 'blob',\n\tbytes = 'bytes',\n\tformData = 'formData',\n\tjson = 'json',\n\tresponse = 'response',\n\ttext = 'text',\n}\n","import { FetchArgs, FetchOptions } from './options'\n\n/** Custom error message for fetch requests with more detailed info about the request URL, fetch options and response */\nexport class FetchError extends Error {\n\t/** Create a new `FetchError` with a new `message` while preserving all metadata */\n\tclone!: (newMessage: string) => FetchError\n\t/* FetchOptions */\n\toptions!: FetchOptions\n\t/* FResponse received, if any */\n\tresponse!: Response | undefined\n\t/* Fetch URL */\n\turl!: FetchArgs[0]\n\n\tconstructor(\n\t\tmessage: string,\n\t\toptions: {\n\t\t\tcause?: unknown\n\t\t\toptions: FetchOptions\n\t\t\tresponse?: Response\n\t\t\turl: FetchArgs[0]\n\t\t},\n\t) {\n\t\tsuper(message, { cause: options.cause })\n\n\t\tthis.name = 'FetchError'\n\n\t\t/* Prevents cluttering the console log output while also preserving ready-only member behavior */\n\t\tObject.defineProperties(this, {\n\t\t\tclone: {\n\t\t\t\tget() {\n\t\t\t\t\treturn (newMessage: string) =>\n\t\t\t\t\t\tnew FetchError(newMessage, {\n\t\t\t\t\t\t\tcause: options.cause,\n\t\t\t\t\t\t\toptions: options.options,\n\t\t\t\t\t\t\tresponse: options.response,\n\t\t\t\t\t\t\turl: options.url,\n\t\t\t\t\t\t})\n\t\t\t\t},\n\t\t\t},\n\t\t\toptions: {\n\t\t\t\tget() {\n\t\t\t\t\treturn options.options\n\t\t\t\t},\n\t\t\t},\n\t\t\tresponse: {\n\t\t\t\tget() {\n\t\t\t\t\treturn options.response\n\t\t\t\t},\n\t\t\t},\n\t\t\turl: {\n\t\t\t\tget() {\n\t\t\t\t\treturn options.url\n\t\t\t\t},\n\t\t\t},\n\t\t})\n\t}\n}\n","import {\n\tfallbackIfFails,\n\tisError,\n\tisFn,\n\tisObj,\n\tisPromise,\n\tisStr,\n\tisUrlValid,\n} from '@superutils/core'\nimport { timeout as PromisE_timeout } from '@superutils/promise'\nimport executeInterceptors from './executeInterceptors'\nimport getResponse from './getResponse'\nimport mergeOptions from './mergeOptions'\nimport type {\n\tFetchArgs,\n\tFetchOptions,\n\tFetchOptionsInterceptor,\n\tFetchResult,\n\tIPromise_Fetch,\n\tPostBody,\n} from './types'\nimport {\n\tContentType,\n\tFetchAs,\n\tFetchErrMsgs,\n\tFetchError,\n\tFetchOptionsDefault,\n} from './types'\n\nconst defaultErrorMsgs = Object.freeze({\n\taborted: 'Request aborted',\n\tinvalidUrl: 'Invalid URL',\n\tparseFailed: 'Failed to parse response as',\n\ttimedout: 'Request timed out',\n\trequestFailed: 'Request failed with status code:',\n}) as Required<FetchErrMsgs>\n\nconst fetch = <\n\tT = unknown,\n\tTOptions extends FetchOptions = FetchOptions,\n\tTAs extends FetchAs = TOptions['as'] extends FetchAs\n\t\t? TOptions['as']\n\t\t: FetchAs.response,\n\tTReturn = FetchResult<T>[TAs],\n>(\n\turl: FetchArgs[0],\n\toptions: FetchOptions & TOptions = {} as TOptions,\n) => {\n\t// let url = url instanceof Request ? url.url : url\n\tif (!isObj(options)) options = {} as TOptions\n\n\tlet response: Response | undefined\n\t// merge `defaults` with `options` to make sure default values are used where appropriate\n\tconst opts = mergeOptions(\n\t\t{ errMsgs: defaultErrorMsgs },\n\t\tfetch.defaults,\n\t\toptions,\n\t)\n\n\t// make sure there's always an abort controller, so that request is aborted when promise is early finalized\n\topts.abortCtrl =\n\t\topts.abortCtrl instanceof AbortController\n\t\t\t? opts.abortCtrl\n\t\t\t: new AbortController()\n\topts.as ??= FetchAs.response\n\topts.method ??= 'get'\n\topts.signal ??= opts.abortCtrl.signal\n\tconst { abortCtrl, as: parseAs, headers, onAbort, onTimeout } = opts\n\topts.onAbort = async () => {\n\t\tconst err: Error = await fallbackIfFails(onAbort, [], undefined)\n\n\t\treturn await interceptErr(\n\t\t\tisError(err) ? err : new Error(err),\n\t\t\turl,\n\t\t\topts,\n\t\t\tresponse,\n\t\t)\n\t}\n\topts.onTimeout = async () => {\n\t\tconst err = await fallbackIfFails(onTimeout, [], undefined)\n\t\treturn await interceptErr(\n\t\t\terr ?? new Error(opts.errMsgs.timedout),\n\t\t\turl,\n\t\t\topts,\n\t\t\tresponse,\n\t\t)\n\t}\n\treturn PromisE_timeout(opts, async () => {\n\t\ttry {\n\t\t\t// invoke body function before executing request interceptors\n\t\t\topts.body = await fallbackIfFails(\n\t\t\t\topts.body as unknown as Promise<PostBody>,\n\t\t\t\t[],\n\t\t\t\t(err: Error) => Promise.reject(err),\n\t\t\t)\n\n\t\t\t// invoke global and local response interceptors to intercept and/or transform `url` and `options`\n\t\t\turl = await executeInterceptors(\n\t\t\t\turl,\n\t\t\t\tabortCtrl.signal,\n\t\t\t\topts.interceptors?.request,\n\t\t\t\topts,\n\t\t\t)\n\n\t\t\tconst { body, errMsgs, validateUrl = false } = opts\n\t\t\topts.signal ??= abortCtrl.signal\n\t\t\tif (validateUrl && !isUrlValid(url, false))\n\t\t\t\tthrow new Error(errMsgs.invalidUrl)\n\n\t\t\tconst stringify =\n\t\t\t\t['delete', 'patch', 'post', 'put'].includes(\n\t\t\t\t\t`${opts.method}`.toLowerCase(),\n\t\t\t\t)\n\t\t\t\t&& !['undefined', 'string'].includes(typeof body)\n\t\t\t\t&& isObj(body, true)\n\t\t\t\t&& headers.get('content-type') === ContentType.APPLICATION_JSON\n\t\t\t// stringify body\n\t\t\tif (stringify) opts.body = JSON.stringify(opts.body)\n\n\t\t\t// make the fetch call\n\t\t\tresponse = await getResponse(url, opts)\n\t\t\t// invoke global and local request interceptors to intercept and/or transform `response`\n\t\t\tresponse = await executeInterceptors(\n\t\t\t\tresponse,\n\t\t\t\tabortCtrl.signal,\n\t\t\t\topts.interceptors?.response,\n\t\t\t\turl,\n\t\t\t\topts,\n\t\t\t)\n\t\t\tconst status = response?.status\n\t\t\tconst isSuccess = status >= 200 && status < 300\n\t\t\tif (!isSuccess) {\n\t\t\t\tconst jsonError: unknown = await fallbackIfFails(\n\t\t\t\t\t// try to parse error response as json first\n\t\t\t\t\t() => response?.clone()?.json(),\n\t\t\t\t\t[],\n\t\t\t\t\tundefined,\n\t\t\t\t)\n\t\t\t\tthrow new Error(jsonError as string, { cause: jsonError })\n\t\t\t}\n\n\t\t\tconst parseFunc = response[parseAs as keyof typeof response]\n\t\t\tlet result: unknown = !isFn(parseFunc)\n\t\t\t\t? response\n\t\t\t\t: parseFunc.bind(response)()\n\t\t\tif (isPromise(result))\n\t\t\t\tresult = await result.catch((err: Error) =>\n\t\t\t\t\tPromise.reject(\n\t\t\t\t\t\tnew Error(\n\t\t\t\t\t\t\t`${errMsgs.parseFailed} ${parseAs}. ${err?.message}`,\n\t\t\t\t\t\t\t{ cause: err },\n\t\t\t\t\t\t),\n\t\t\t\t\t),\n\t\t\t\t)\n\t\t\t// invoke global and local request interceptors to intercept and/or transform parsed `result`\n\t\t\tresult = await executeInterceptors(\n\t\t\t\tresult,\n\t\t\t\tabortCtrl.signal,\n\t\t\t\topts.interceptors?.result,\n\t\t\t\turl,\n\t\t\t\topts,\n\t\t\t)\n\t\t\treturn result as TReturn\n\t\t} catch (_err: unknown) {\n\t\t\tlet err = _err as Error\n\n\t\t\terr = await interceptErr(_err as Error, url, opts, response)\n\t\t\treturn Promise.reject(err as FetchError)\n\t\t}\n\t}) as IPromise_Fetch<TReturn>\n}\n/** Default fetch options */\nfetch.defaults = {\n\tabortOnEarlyFinalize: true,\n\terrMsgs: { ...defaultErrorMsgs }, // all error messages must be defined here\n\theaders: new Headers(),\n\tinterceptors: {\n\t\terror: [],\n\t\trequest: [],\n\t\tresponse: [],\n\t\tresult: [],\n\t},\n\ttimeout: 60_000,\n\tvalidateUrl: false,\n} as FetchOptionsDefault\n\nconst interceptErr = async (\n\terr: Error,\n\turl: FetchArgs[0],\n\toptions: FetchOptionsInterceptor,\n\tresponse?: Response,\n) => {\n\t// invoke global and local request interceptors to intercept and/or transform `error`\n\tconst fErr = await executeInterceptors(\n\t\tnew FetchError(\n\t\t\t(err?.message ?? err)\n\t\t\t\t|| `${options.errMsgs.requestFailed} ${response?.status}`,\n\t\t\t{\n\t\t\t\tcause: err?.cause ?? err,\n\t\t\t\tresponse: response,\n\t\t\t\toptions: options,\n\t\t\t\turl,\n\t\t\t},\n\t\t),\n\t\tundefined, // should execute regardless of abort status\n\t\toptions.interceptors?.error,\n\t\turl,\n\t\toptions,\n\t)\n\treturn fErr\n}\n\nexport default fetch\n","import { DeferredAsyncOptions, deferredCallback } from '@superutils/promise'\nimport fetch from './fetch'\nimport mergeOptions from './mergeOptions'\nimport type {\n\tExtractAs,\n\tExcludeOptions,\n\tFetchArgs,\n\tFetchOptions,\n\tGetFetchResult,\n\tIPromise_Fetch,\n} from './types'\nimport { FetchAs } from './types'\n\n/**\n * Defines client generic parameter T based on fixed options.\n *\n * If \"fixedOptions.as\" is defined and not `FetcAs.json`, then `T` will be `never`.\n */\nexport type ClientData<FixedOptions> =\n\tExtractAs<[FixedOptions]> extends FetchAs.json ? unknown : never // disallow providing T\n/**\n * Create a reusable fetch client with shared options. The returned function comes attached with a\n * `.deferred()` function for debounce and throttle behavior.\n *\n * The `createClient` utility streamlines the creation of dedicated API clients by generating pre-configured fetch\n * functions. These functions can be equipped with default options like headers, timeouts, or a specific HTTP method,\n * which minimizes code repetition across your application. If a method is not specified during creation, the client\n * will default to `GET`.\n *\n * The returned client also includes a `.deferred()` method, providing the same debounce, throttle, and sequential\n * execution capabilities found in functions like `fetch.get.deferred()`.\n *\n * @example\n * #### Create reusable clients\n * ```javascript\n * import { createClient } from '@superutils/fetch'\n *\n * // Create a \"GET\" client with default headers and a 5-second timeout\n * const apiClient = createClient(\n * \t { method: 'get' }, // fixed options cannot be overridden\n * \t { // default options can be overridden\n * \t headers: {\n * \t \tAuthorization: 'Bearer my-secret-token',\n * \t \t'Content-Type': 'application/json',\n * \t },\n * \t timeout: 5000,\n * \t },\n * \t {// default defer options (can be overridden)\n * \t delay: 300,\n * \t retry: 2, // If request fails, retry up to two more times\n * \t },\n * )\n *\n * // Use it just like the standard fetch\n * apiClient('[DUMMYJSON-DOT-COM]/products/1', {\n * // The 'method' property cannot be overridden as it is used in the fixed options when creating the client.\n * // In TypeScript, the compiler will not allow this property.\n * // In Javascript, it will simply be ignored.\n * // method: 'post',\n * timeout: 3000, // The 'timeout' property can be overridden\n * }).then(console.log, console.warn)\n *\n * // create a deferred client using \"apiClient\"\n * const deferredClient = apiClient.deferred(\n * { retry: 0 }, // disable retrying by overriding the `retry` defer option\n * '[DUMMYJSON-DOT-COM]/products/1',\n * { timeout: 3000 },\n * )\n * deferredClient({ timeout: 10000 }) // timeout is overridden by individual request\n * \t.then(console.log, console.warn)\n * ```\n */\nexport const createClient = <\n\tFixedOptions extends FetchOptions | undefined,\n\tCommonOptions extends ExcludeOptions<FixedOptions> | undefined,\n\tCommonDelay extends number,\n>(\n\t/** Mandatory fetch options that cannot be overriden by individual request */\n\tfixedOptions?: FixedOptions,\n\t/** Common fetch options that can be overriden by individual request */\n\tcommonOptions?: FetchOptions & CommonOptions,\n\tcommonDeferOptions?: DeferredAsyncOptions<unknown, CommonDelay>,\n) => {\n\tfunction client<\n\t\tT extends ClientData<FixedOptions> = never,\n\t\tTOptions extends ExcludeOptions<FixedOptions> | undefined =\n\t\t\t| ExcludeOptions<FixedOptions>\n\t\t\t| undefined,\n\t\tResult = GetFetchResult<[FixedOptions, TOptions, CommonOptions], T>,\n\t>(url: FetchArgs[0], options?: TOptions): IPromise_Fetch<Result> {\n\t\tconst mergedOptions = mergeOptions(\n\t\t\tfetch.defaults,\n\t\t\tcommonOptions,\n\t\t\toptions,\n\t\t\tfixedOptions, // fixed options will always override other options\n\t\t)\n\t\tmergedOptions.as ??= FetchAs.json\n\t\treturn fetch(url, mergedOptions)\n\t}\n\n\t/** Make requests with debounce/throttle behavior */\n\tclient.deferred = <\n\t\tThisArg,\n\t\tDelay extends CommonDelay | number,\n\t\tDefaultUrl extends FetchArgs[0] | undefined = FetchArgs[0] | undefined,\n\t\tDefaultOptions extends ExcludeOptions<FixedOptions> | undefined =\n\t\t\t| ExcludeOptions<FixedOptions>\n\t\t\t| undefined,\n\t>(\n\t\tdeferOptions?: DeferredAsyncOptions<ThisArg, Delay>,\n\t\tdefaultUrl?: DefaultUrl,\n\t\tdefaultOptions?: DefaultOptions,\n\t) => {\n\t\tlet _abortCtrl: AbortController | undefined\n\t\tconst fetchCb = <\n\t\t\tT extends ClientData<FixedOptions> = never,\n\t\t\tTOptions extends ExcludeOptions<FixedOptions> | undefined =\n\t\t\t\t| ExcludeOptions<FixedOptions>\n\t\t\t\t| undefined,\n\t\t\tResult = GetFetchResult<\n\t\t\t\t[FixedOptions, TOptions, DefaultOptions, CommonOptions],\n\t\t\t\tT\n\t\t\t>,\n\t\t>(\n\t\t\t...args: DefaultUrl extends undefined\n\t\t\t\t? [url: FetchArgs[0], options?: TOptions]\n\t\t\t\t: [options?: TOptions]\n\t\t): IPromise_Fetch<Result> => {\n\t\t\tconst mergedOptions = mergeOptions(\n\t\t\t\tfetch.defaults,\n\t\t\t\tcommonOptions,\n\t\t\t\tdefaultOptions,\n\t\t\t\t(defaultUrl === undefined ? args[1] : args[0]) as TOptions,\n\t\t\t\tfixedOptions, // fixed options will always override other options\n\t\t\t) as FetchOptions\n\t\t\tmergedOptions.as ??= FetchAs.json\n\t\t\t// make sure to abort any previously pending request\n\t\t\t_abortCtrl?.abort?.()\n\t\t\t// ensure AbortController is present in options and propagete external abort signal if provided\n\t\t\t_abortCtrl = new AbortController()\n\n\t\t\treturn fetch(\n\t\t\t\t(defaultUrl ?? args[0]) as FetchArgs[0],\n\t\t\t\tmergedOptions,\n\t\t\t) as unknown as IPromise_Fetch<Result>\n\t\t}\n\n\t\treturn deferredCallback(fetchCb, {\n\t\t\t...commonDeferOptions,\n\t\t\t...deferOptions,\n\t\t} as DeferredAsyncOptions<ThisArg, CommonDelay>) as typeof fetchCb\n\t}\n\n\treturn client\n}\nexport default createClient\n","import { DeferredAsyncOptions, deferredCallback } from '@superutils/promise'\nimport { ClientData } from './createClient'\nimport fetch from './fetch'\nimport mergeOptions from './mergeOptions'\nimport {\n\tExcludePostOptions,\n\tFetchAs,\n\tPostArgs,\n\tPostDeferredCbArgs,\n\tPostOptions,\n\tIPromise_Fetch,\n\tGetFetchResult,\n\tContentType,\n} from './types'\n\n/**\n * Create a reusable fetch client with shared options. The returned function comes attached with a\n * `.deferred()` function for debounced and throttled request.\n * While `createClient()` is versatile enough for any HTTP method, `createPostClient()` is specifically designed for\n * methods that require a request body, such as `DELETE`, `PATCH`, `POST`, and `PUT`. If a method is not provided, it\n * defaults to `POST`. The generated client accepts an additional second parameter (`data`) for the request payload.\n *\n * Similar to `createClient`, the returned function comes equipped with a `.deferred()` method, enabling debounced,\n * throttled, or sequential execution.\n *\n * @example\n * #### Create reusable clients\n * ```javascript\n * import { createPostClient, FetchAs } from '@superutils/fetch'\n *\n * // Create a POST client with 10-second as the default timeout\n * const postClient = createPostClient(\n * \t{ // fixed options cannot be overrided by client calls\n * \t method: 'post',\n * \t headers: { 'content-type': 'application/json' },\n * \t},\n * \t{ timeout: 10000 }, // common options that can be overriden by client calls\n * )\n *\n * // Invoking `postClient()` automatically applies the pre-configured options\n * postClient(\n * \t '[DUMMYJSON-DOT-COM]/products/add',\n * \t { title: 'New Product' }, // data/body\n * \t {}, // other options\n * ).then(console.log)\n *\n * // create a deferred client using \"postClient\"\n * const updateProduct = postClient.deferred(\n * \t{\n * \t\tdelay: 300, // debounce duration\n * \t\tonResult: console.log, // prints only successful results\n * \t},\n * \t'[DUMMYJSON-DOT-COM]/products/add',\n * \t{ method: 'patch', timeout: 3000 },\n * )\n * updateProduct({ title: 'New title 1' }) // ignored by debounce\n * updateProduct({ title: 'New title 2' }) // executed\n * ```\n */\nexport const createPostClient = <\n\tFixedOptions extends PostOptions | undefined,\n\tCommonOptions extends ExcludePostOptions<FixedOptions> | undefined,\n\tCommonDelay extends number = number,\n>(\n\t/** Mandatory fetch options that cannot be overriden by individual request */\n\tfixedOptions?: FixedOptions,\n\t/** Common fetch options that can be overriden by individual request */\n\tcommonOptions?: PostOptions & CommonOptions,\n\tcommonDeferOptions?: DeferredAsyncOptions<unknown, CommonDelay>,\n) => {\n\t/**\n\t * Executes the HTTP request using the configured client options.\n\t *\n\t * This function is specifically designed for methods that require a request body (e.g., POST, PUT, PATCH),\n\t * allowing the payload to be passed directly as the second argument.\n\t */\n\tfunction client<\n\t\tT extends ClientData<FixedOptions> = never,\n\t\tOptions extends ExcludePostOptions<FixedOptions> | undefined =\n\t\t\t| ExcludePostOptions<FixedOptions>\n\t\t\t| undefined,\n\t\tResult = GetFetchResult<[FixedOptions, Options, CommonOptions], T>,\n\t>(\n\t\turl: PostArgs[0],\n\t\tdata?: PostArgs[1],\n\t\toptions?: Options,\n\t): IPromise_Fetch<Result> {\n\t\tconst mergedOptions = mergeOptions(\n\t\t\tcommonOptions,\n\t\t\toptions,\n\t\t\tfixedOptions, // fixed options will always override other options\n\t\t) as PostOptions\n\t\tmergedOptions.as ??= FetchAs.json\n\t\tmergedOptions.body = data ?? mergedOptions.body\n\t\tmergedOptions.method ??= 'post'\n\n\t\tconst headers = mergedOptions.headers as Headers\n\t\tif (!headers.get('content-type')) {\n\t\t\theaders.set('content-type', ContentType.APPLICATION_JSON)\n\t\t}\n\t\treturn fetch(url, mergedOptions)\n\t}\n\n\t/**\n\t * Returns a version of the client configured for debounced, throttled, or sequential execution.\n\t *\n\t * This is particularly useful for optimizing high-frequency operations, such as auto-saving forms\n\t * or managing rapid state updates, by automatically handling request cancellation and execution timing.\n\t */\n\tclient.deferred = <\n\t\tThisArg,\n\t\tDefaultUrl extends PostArgs[0] | undefined,\n\t\tDefaultData extends PostArgs[1] | undefined,\n\t\tDefaultOptions extends ExcludePostOptions<FixedOptions> | undefined =\n\t\t\t| ExcludePostOptions<FixedOptions>\n\t\t\t| undefined,\n\t\tDelay extends CommonDelay | number = number,\n\t>(\n\t\tdeferOptions?: DeferredAsyncOptions<ThisArg, Delay>,\n\t\tdefaultUrl?: DefaultUrl,\n\t\tdefaultData?: DefaultData,\n\t\tdefaultOptions?: DefaultOptions,\n\t) => {\n\t\tlet _abortCtrl: AbortController | undefined\n\t\tconst postCb = <\n\t\t\tT extends ClientData<FixedOptions> = never,\n\t\t\tOptions extends ExcludePostOptions<FixedOptions> | undefined =\n\t\t\t\t| ExcludePostOptions<FixedOptions>\n\t\t\t\t| undefined,\n\t\t\tTReturn = GetFetchResult<\n\t\t\t\t[FixedOptions, Options, DefaultOptions, CommonOptions],\n\t\t\t\tT\n\t\t\t>,\n\t\t>(\n\t\t\t...args: PostDeferredCbArgs<DefaultUrl, DefaultData, Options>\n\t\t): IPromise_Fetch<TReturn> => {\n\t\t\t// add default url to the beginning of the array\n\t\t\tif (defaultUrl !== undefined) args.splice(0, 0, defaultUrl)\n\t\t\t// add default data after the url\n\t\t\tif (defaultData !== undefined) args.splice(1, 0, defaultData)\n\t\t\tconst mergedOptions = mergeOptions(\n\t\t\t\tfetch.defaults,\n\t\t\t\tcommonOptions,\n\t\t\t\tdefaultOptions,\n\t\t\t\targs[2] as Options,\n\t\t\t\tfixedOptions, // fixed options will always override other options\n\t\t\t) as PostOptions\n\t\t\tmergedOptions.as ??= FetchAs.json\n\t\t\t// make sure to abort any previously pending request\n\t\t\t_abortCtrl?.abort?.()\n\t\t\t// ensure AbortController is present in options and propagete external abort signal if provided\n\t\t\t_abortCtrl = new AbortController()\n\n\t\t\t// attach body to options\n\t\t\tmergedOptions.body = (args[1] ?? mergedOptions.body) as PostArgs[1]\n\t\t\tmergedOptions.method ??= 'post'\n\n\t\t\tconst headers = mergedOptions.headers as Headers\n\t\t\tif (!headers.get('content-type')) {\n\t\t\t\theaders.set('content-type', ContentType.APPLICATION_JSON)\n\t\t\t}\n\t\t\treturn fetch(args[0] as PostArgs[0], mergedOptions)\n\t\t}\n\n\t\treturn deferredCallback(postCb, {\n\t\t\t...commonDeferOptions,\n\t\t\t...deferOptions,\n\t\t} as typeof deferOptions) as typeof postCb\n\t}\n\n\treturn client\n}\nexport default createPostClient\n","/** This is an entrypoint tailored for IIFE builds for browsers. */\nimport * as promiseExports from '@superutils/promise'\nimport * as fetchExports from './index'\n\n/**\n * Export the fetch function and include all other exports as it's property\n *\n * ### Usage:\n * - `window.superutils.fetch(...)`\n * - `window.superutils.fetch.get(...)`\n * - `window.superutils.fetch.createClient(...)`\n */\nconst fetch = fetchExports.default\n\nObject.keys(fetchExports).forEach(key => {\n\tif (['default', 'fetch'].includes(key)) return\n\t;(fetch as unknown as Record<string, unknown>)[key] ??= (\n\t\tfetchExports as Record<string, unknown>\n\t)[key]\n})\nexport default fetch\n\n/**\n * Include all exports from @supertuils/promise:\n * 1. as if it were imported independantly\n * 2. only adds ~0.5KB (95%+ of the code is already used by @superutils/fetch)\n * 3. eliminates the need to import it separately\n * window.superutils.fetch(...)\n * window.superutils.fetch.get(...)\n * window.superutils.fetch.createClient(...)\n *\n * Usage:\n * window.\n */\nconst PromisE = promiseExports.default\nObject.keys(promiseExports).forEach(key => {\n\tif (['default', 'PromisE'].includes(key)) return\n\t;(PromisE as unknown as Record<string, unknown>)[key] ??= (\n\t\tpromiseExports as Record<string, unknown>\n\t)[key]\n})\nconst w = globalThis as unknown as Record<string, Record<string, unknown>>\nw.superutils ??= {}\nw.superutils.PromisE ??= PromisE\n"]}
|
package/dist/index.cjs
CHANGED
|
@@ -65,7 +65,7 @@ var executeInterceptors_default = executeInterceptors;
|
|
|
65
65
|
var import_core2 = require("@superutils/core");
|
|
66
66
|
var import_promise = require("@superutils/promise");
|
|
67
67
|
var getResponse = (url, options = {}) => {
|
|
68
|
-
const fetchFunc = (0, import_core2.isFn)(options.fetchFunc) ? options.fetchFunc :
|
|
68
|
+
const fetchFunc = (0, import_core2.isFn)(options.fetchFunc) ? options.fetchFunc : getResponse.fetch;
|
|
69
69
|
if (!(0, import_core2.isPositiveInteger)(options.retry)) return fetchFunc(url, options);
|
|
70
70
|
let attemptCount = 0;
|
|
71
71
|
const response = (0, import_promise.retry)(
|
|
@@ -78,7 +78,7 @@ var getResponse = (url, options = {}) => {
|
|
|
78
78
|
retryIf: async (res, count, error) => {
|
|
79
79
|
var _a, _b;
|
|
80
80
|
const { abortCtrl, retryIf, signal } = options;
|
|
81
|
-
if ((
|
|
81
|
+
if ((signal == null ? void 0 : signal.aborted) || ((_a = abortCtrl == null ? void 0 : abortCtrl.signal) == null ? void 0 : _a.aborted)) return false;
|
|
82
82
|
return !!((_b = await (0, import_core2.fallbackIfFails)(
|
|
83
83
|
retryIf,
|
|
84
84
|
[res, count, error],
|
|
@@ -95,6 +95,7 @@ var getResponse = (url, options = {}) => {
|
|
|
95
95
|
);
|
|
96
96
|
return response;
|
|
97
97
|
};
|
|
98
|
+
getResponse.fetch = globalThis.fetch;
|
|
98
99
|
var getResponse_default = getResponse;
|
|
99
100
|
|
|
100
101
|
// src/mergeOptions.ts
|
|
@@ -275,14 +276,14 @@ var fetch = (url, options = {}) => {
|
|
|
275
276
|
if (!isSuccess) {
|
|
276
277
|
const jsonError = await (0, import_core4.fallbackIfFails)(
|
|
277
278
|
// try to parse error response as json first
|
|
278
|
-
() =>
|
|
279
|
+
() => {
|
|
280
|
+
var _a3;
|
|
281
|
+
return (_a3 = response == null ? void 0 : response.clone()) == null ? void 0 : _a3.json();
|
|
282
|
+
},
|
|
279
283
|
[],
|
|
280
284
|
void 0
|
|
281
285
|
);
|
|
282
|
-
throw new Error(
|
|
283
|
-
(jsonError == null ? void 0 : jsonError.message) || `${errMsgs.requestFailed} ${status}`,
|
|
284
|
-
{ cause: jsonError }
|
|
285
|
-
);
|
|
286
|
+
throw new Error(jsonError, { cause: jsonError });
|
|
286
287
|
}
|
|
287
288
|
const parseFunc = response[parseAs];
|
|
288
289
|
let result = !(0, import_core4.isFn)(parseFunc) ? response : parseFunc.bind(response)();
|
|
@@ -327,12 +328,15 @@ fetch.defaults = {
|
|
|
327
328
|
var interceptErr = async (err, url, options, response) => {
|
|
328
329
|
var _a, _b, _c;
|
|
329
330
|
const fErr = await executeInterceptors_default(
|
|
330
|
-
new FetchError(
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
331
|
+
new FetchError(
|
|
332
|
+
((_a = err == null ? void 0 : err.message) != null ? _a : err) || `${options.errMsgs.requestFailed} ${response == null ? void 0 : response.status}`,
|
|
333
|
+
{
|
|
334
|
+
cause: (_b = err == null ? void 0 : err.cause) != null ? _b : err,
|
|
335
|
+
response,
|
|
336
|
+
options,
|
|
337
|
+
url
|
|
338
|
+
}
|
|
339
|
+
),
|
|
336
340
|
void 0,
|
|
337
341
|
// should execute regardless of abort status
|
|
338
342
|
(_c = options.interceptors) == null ? void 0 : _c.error,
|
package/dist/index.d.cts
CHANGED
|
@@ -257,10 +257,10 @@ type ExtractAs<T extends unknown[], //FetchOptions/FetchAs/...
|
|
|
257
257
|
Fallback = FetchAs.json> = T['length'] extends 0 ? Fallback : T[0] extends FetchAs ? T[0] : T[0] extends {
|
|
258
258
|
as: infer OptAs;
|
|
259
259
|
} ? OptAs extends FetchAs ? OptAs : ExtractAs<DropFirst<T>, Fallback> : ExtractAs<DropFirst<T>, Fallback>;
|
|
260
|
-
type FetchArgs = [url:
|
|
260
|
+
type FetchArgs = [url: URL | RequestInfo, options?: FetchOptions];
|
|
261
261
|
/** Additional arguments provided to interceptors */
|
|
262
262
|
type FetchArgsInterceptor = [
|
|
263
|
-
url:
|
|
263
|
+
url: FetchArgs[0],
|
|
264
264
|
options: FetchOptionsInterceptor
|
|
265
265
|
];
|
|
266
266
|
/** Custom fetch options (not used by built-in `fetch()`*/
|
|
@@ -380,7 +380,7 @@ type FetchRetryOptions = Omit<Partial<RetryOptions>, 'retry' | 'retryIf'> & {
|
|
|
380
380
|
};
|
|
381
381
|
type PostBody = Record<string, unknown> | BodyInit | null;
|
|
382
382
|
type PostArgs = [
|
|
383
|
-
url:
|
|
383
|
+
url: FetchArgs[0],
|
|
384
384
|
/**
|
|
385
385
|
* Post body or a function that returns/resolves post body.
|
|
386
386
|
*
|
|
@@ -426,12 +426,12 @@ declare class FetchError extends Error {
|
|
|
426
426
|
clone: (newMessage: string) => FetchError;
|
|
427
427
|
options: FetchOptions;
|
|
428
428
|
response: Response | undefined;
|
|
429
|
-
url:
|
|
429
|
+
url: FetchArgs[0];
|
|
430
430
|
constructor(message: string, options: {
|
|
431
431
|
cause?: unknown;
|
|
432
432
|
options: FetchOptions;
|
|
433
433
|
response?: Response;
|
|
434
|
-
url:
|
|
434
|
+
url: FetchArgs[0];
|
|
435
435
|
});
|
|
436
436
|
}
|
|
437
437
|
|
|
@@ -504,7 +504,7 @@ fixedOptions?: FixedOptions,
|
|
|
504
504
|
/** Common fetch options that can be overriden by individual request */
|
|
505
505
|
commonOptions?: FetchOptions & CommonOptions, commonDeferOptions?: DeferredAsyncOptions<unknown, CommonDelay>) => {
|
|
506
506
|
<T extends ClientData<FixedOptions> = never, TOptions extends ExcludeOptions<FixedOptions> | undefined = ExcludeOptions<FixedOptions> | undefined, Result = GetFetchResult<[FixedOptions, TOptions, CommonOptions], T>>(url: FetchArgs[0], options?: TOptions): IPromise_Fetch<Result>;
|
|
507
|
-
deferred<ThisArg, Delay extends CommonDelay | number, DefaultUrl extends FetchArgs[0] | undefined =
|
|
507
|
+
deferred<ThisArg, Delay extends CommonDelay | number, DefaultUrl extends FetchArgs[0] | undefined = URL | RequestInfo | undefined, DefaultOptions extends ExcludeOptions<FixedOptions> | undefined = ExcludeOptions<FixedOptions> | undefined>(deferOptions?: DeferredAsyncOptions<ThisArg, Delay>, defaultUrl?: DefaultUrl, defaultOptions?: DefaultOptions): <T extends ClientData<FixedOptions> = never, TOptions_1 extends ExcludeOptions<FixedOptions> | undefined = ExcludeOptions<FixedOptions> | undefined, Result_1 = GetFetchResult<[FixedOptions, TOptions_1, DefaultOptions, CommonOptions], T>>(...args: DefaultUrl extends undefined ? [url: FetchArgs[0], options?: TOptions_1] : [options?: TOptions_1]) => IPromise_Fetch<Result_1>;
|
|
508
508
|
};
|
|
509
509
|
|
|
510
510
|
/**
|
|
@@ -578,7 +578,7 @@ commonOptions?: PostOptions & CommonOptions, commonDeferOptions?: DeferredAsyncO
|
|
|
578
578
|
declare const executeInterceptors: <T, TArgs extends unknown[]>(value: T, signal?: AbortSignal, interceptors?: Interceptor<T, TArgs>[], ...args: TArgs) => Promise<T>;
|
|
579
579
|
|
|
580
580
|
declare const fetch$1: {
|
|
581
|
-
<T = unknown, TOptions extends FetchOptions = FetchOptions, TAs extends FetchAs = TOptions["as"] extends FetchAs ? TOptions["as"] : FetchAs.response, TReturn = FetchResult<T>[TAs]>(url:
|
|
581
|
+
<T = unknown, TOptions extends FetchOptions = FetchOptions, TAs extends FetchAs = TOptions["as"] extends FetchAs ? TOptions["as"] : FetchAs.response, TReturn = FetchResult<T>[TAs]>(url: FetchArgs[0], options?: FetchOptions & TOptions): IPromise_Fetch<TReturn>;
|
|
582
582
|
/** Default fetch options */
|
|
583
583
|
defaults: FetchOptionsDefault;
|
|
584
584
|
};
|
|
@@ -610,7 +610,7 @@ declare const methods: {
|
|
|
610
610
|
}, TOptions, ({
|
|
611
611
|
headers?: HeadersInit | undefined;
|
|
612
612
|
} & Omit<FetchOptions, "headers" | "method"> & Partial<Record<"method", never>>) | undefined], T>>(url: FetchArgs[0], options?: TOptions | undefined): IPromise_Fetch<Result>;
|
|
613
|
-
deferred<ThisArg, Delay extends number, DefaultUrl extends FetchArgs[0] | undefined =
|
|
613
|
+
deferred<ThisArg, Delay extends number, DefaultUrl extends FetchArgs[0] | undefined = URL | RequestInfo | undefined, DefaultOptions extends ({
|
|
614
614
|
headers?: HeadersInit | undefined;
|
|
615
615
|
} & Omit<FetchOptions, "headers" | "method"> & Partial<Record<"method", never>>) | undefined = ({
|
|
616
616
|
headers?: HeadersInit | undefined;
|
|
@@ -622,7 +622,7 @@ declare const methods: {
|
|
|
622
622
|
method: string;
|
|
623
623
|
}, TOptions, DefaultOptions, ({
|
|
624
624
|
headers?: HeadersInit | undefined;
|
|
625
|
-
} & Omit<FetchOptions, "headers" | "method"> & Partial<Record<"method", never>>) | undefined], T>>(...args: DefaultUrl extends undefined ? [url:
|
|
625
|
+
} & Omit<FetchOptions, "headers" | "method"> & Partial<Record<"method", never>>) | undefined], T>>(...args: DefaultUrl extends undefined ? [url: URL | RequestInfo, options?: TOptions | undefined] : [options?: TOptions | undefined]) => IPromise_Fetch<Result>;
|
|
626
626
|
};
|
|
627
627
|
/** Make HTTP requests with method HEAD */
|
|
628
628
|
head: {
|
|
@@ -635,7 +635,7 @@ declare const methods: {
|
|
|
635
635
|
}, TOptions, ({
|
|
636
636
|
headers?: HeadersInit | undefined;
|
|
637
637
|
} & Omit<FetchOptions, "headers" | "method"> & Partial<Record<"method", never>>) | undefined], T>>(url: FetchArgs[0], options?: TOptions | undefined): IPromise_Fetch<Result>;
|
|
638
|
-
deferred<ThisArg, Delay extends number, DefaultUrl extends FetchArgs[0] | undefined =
|
|
638
|
+
deferred<ThisArg, Delay extends number, DefaultUrl extends FetchArgs[0] | undefined = URL | RequestInfo | undefined, DefaultOptions extends ({
|
|
639
639
|
headers?: HeadersInit | undefined;
|
|
640
640
|
} & Omit<FetchOptions, "headers" | "method"> & Partial<Record<"method", never>>) | undefined = ({
|
|
641
641
|
headers?: HeadersInit | undefined;
|
|
@@ -647,7 +647,7 @@ declare const methods: {
|
|
|
647
647
|
method: string;
|
|
648
648
|
}, TOptions, DefaultOptions, ({
|
|
649
649
|
headers?: HeadersInit | undefined;
|
|
650
|
-
} & Omit<FetchOptions, "headers" | "method"> & Partial<Record<"method", never>>) | undefined], T>>(...args: DefaultUrl extends undefined ? [url:
|
|
650
|
+
} & Omit<FetchOptions, "headers" | "method"> & Partial<Record<"method", never>>) | undefined], T>>(...args: DefaultUrl extends undefined ? [url: URL | RequestInfo, options?: TOptions | undefined] : [options?: TOptions | undefined]) => IPromise_Fetch<Result>;
|
|
651
651
|
};
|
|
652
652
|
/** Make HTTP requests with method OPTIONS */
|
|
653
653
|
options: {
|
|
@@ -660,7 +660,7 @@ declare const methods: {
|
|
|
660
660
|
}, TOptions, ({
|
|
661
661
|
headers?: HeadersInit | undefined;
|
|
662
662
|
} & Omit<FetchOptions, "headers" | "method"> & Partial<Record<"method", never>>) | undefined], T>>(url: FetchArgs[0], options?: TOptions | undefined): IPromise_Fetch<Result>;
|
|
663
|
-
deferred<ThisArg, Delay extends number, DefaultUrl extends FetchArgs[0] | undefined =
|
|
663
|
+
deferred<ThisArg, Delay extends number, DefaultUrl extends FetchArgs[0] | undefined = URL | RequestInfo | undefined, DefaultOptions extends ({
|
|
664
664
|
headers?: HeadersInit | undefined;
|
|
665
665
|
} & Omit<FetchOptions, "headers" | "method"> & Partial<Record<"method", never>>) | undefined = ({
|
|
666
666
|
headers?: HeadersInit | undefined;
|
|
@@ -672,7 +672,7 @@ declare const methods: {
|
|
|
672
672
|
method: string;
|
|
673
673
|
}, TOptions, DefaultOptions, ({
|
|
674
674
|
headers?: HeadersInit | undefined;
|
|
675
|
-
} & Omit<FetchOptions, "headers" | "method"> & Partial<Record<"method", never>>) | undefined], T>>(...args: DefaultUrl extends undefined ? [url:
|
|
675
|
+
} & Omit<FetchOptions, "headers" | "method"> & Partial<Record<"method", never>>) | undefined], T>>(...args: DefaultUrl extends undefined ? [url: URL | RequestInfo, options?: TOptions | undefined] : [options?: TOptions | undefined]) => IPromise_Fetch<Result>;
|
|
676
676
|
};
|
|
677
677
|
/** Make HTTP requests with method DELETE */
|
|
678
678
|
delete: {
|
|
@@ -697,7 +697,7 @@ declare const methods: {
|
|
|
697
697
|
method: "delete";
|
|
698
698
|
}, Options, DefaultOptions, ({
|
|
699
699
|
headers?: HeadersInit | undefined;
|
|
700
|
-
} & Omit<PostOptions, "headers" | "method"> & Partial<Record<"method", never>>) | undefined], T>>(...args: PostDeferredCbArgs<DefaultUrl, DefaultData, Options, [url:
|
|
700
|
+
} & Omit<PostOptions, "headers" | "method"> & Partial<Record<"method", never>>) | undefined], T>>(...args: PostDeferredCbArgs<DefaultUrl, DefaultData, Options, [url: URL | RequestInfo, data: PostBody | (() => _superutils_core.ValueOrPromise<PostBody>), options: PostOptions], undefined extends DefaultUrl ? DefaultUrl & undefined : DefaultUrl, undefined extends DefaultData ? DefaultData & undefined : DefaultData>) => IPromise_Fetch<TReturn>;
|
|
701
701
|
};
|
|
702
702
|
/** Make HTTP requests with method PATCH */
|
|
703
703
|
patch: {
|
|
@@ -722,7 +722,7 @@ declare const methods: {
|
|
|
722
722
|
method: "patch";
|
|
723
723
|
}, Options, DefaultOptions, ({
|
|
724
724
|
headers?: HeadersInit | undefined;
|
|
725
|
-
} & Omit<PostOptions, "headers" | "method"> & Partial<Record<"method", never>>) | undefined], T>>(...args: PostDeferredCbArgs<DefaultUrl, DefaultData, Options, [url:
|
|
725
|
+
} & Omit<PostOptions, "headers" | "method"> & Partial<Record<"method", never>>) | undefined], T>>(...args: PostDeferredCbArgs<DefaultUrl, DefaultData, Options, [url: URL | RequestInfo, data: PostBody | (() => _superutils_core.ValueOrPromise<PostBody>), options: PostOptions], undefined extends DefaultUrl ? DefaultUrl & undefined : DefaultUrl, undefined extends DefaultData ? DefaultData & undefined : DefaultData>) => IPromise_Fetch<TReturn>;
|
|
726
726
|
};
|
|
727
727
|
/** Make HTTP requests with method POST */
|
|
728
728
|
post: {
|
|
@@ -747,7 +747,7 @@ declare const methods: {
|
|
|
747
747
|
method: "post";
|
|
748
748
|
}, Options, DefaultOptions, ({
|
|
749
749
|
headers?: HeadersInit | undefined;
|
|
750
|
-
} & Omit<PostOptions, "headers" | "method"> & Partial<Record<"method", never>>) | undefined], T>>(...args: PostDeferredCbArgs<DefaultUrl, DefaultData, Options, [url:
|
|
750
|
+
} & Omit<PostOptions, "headers" | "method"> & Partial<Record<"method", never>>) | undefined], T>>(...args: PostDeferredCbArgs<DefaultUrl, DefaultData, Options, [url: URL | RequestInfo, data: PostBody | (() => _superutils_core.ValueOrPromise<PostBody>), options: PostOptions], undefined extends DefaultUrl ? DefaultUrl & undefined : DefaultUrl, undefined extends DefaultData ? DefaultData & undefined : DefaultData>) => IPromise_Fetch<TReturn>;
|
|
751
751
|
};
|
|
752
752
|
/** Make HTTP requests with method PUT */
|
|
753
753
|
put: {
|
|
@@ -772,7 +772,7 @@ declare const methods: {
|
|
|
772
772
|
method: "put";
|
|
773
773
|
}, Options, DefaultOptions, ({
|
|
774
774
|
headers?: HeadersInit | undefined;
|
|
775
|
-
} & Omit<PostOptions, "headers" | "method"> & Partial<Record<"method", never>>) | undefined], T>>(...args: PostDeferredCbArgs<DefaultUrl, DefaultData, Options, [url:
|
|
775
|
+
} & Omit<PostOptions, "headers" | "method"> & Partial<Record<"method", never>>) | undefined], T>>(...args: PostDeferredCbArgs<DefaultUrl, DefaultData, Options, [url: URL | RequestInfo, data: PostBody | (() => _superutils_core.ValueOrPromise<PostBody>), options: PostOptions], undefined extends DefaultUrl ? DefaultUrl & undefined : DefaultUrl, undefined extends DefaultData ? DefaultData & undefined : DefaultData>) => IPromise_Fetch<TReturn>;
|
|
776
776
|
};
|
|
777
777
|
};
|
|
778
778
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -257,10 +257,10 @@ type ExtractAs<T extends unknown[], //FetchOptions/FetchAs/...
|
|
|
257
257
|
Fallback = FetchAs.json> = T['length'] extends 0 ? Fallback : T[0] extends FetchAs ? T[0] : T[0] extends {
|
|
258
258
|
as: infer OptAs;
|
|
259
259
|
} ? OptAs extends FetchAs ? OptAs : ExtractAs<DropFirst<T>, Fallback> : ExtractAs<DropFirst<T>, Fallback>;
|
|
260
|
-
type FetchArgs = [url:
|
|
260
|
+
type FetchArgs = [url: URL | RequestInfo, options?: FetchOptions];
|
|
261
261
|
/** Additional arguments provided to interceptors */
|
|
262
262
|
type FetchArgsInterceptor = [
|
|
263
|
-
url:
|
|
263
|
+
url: FetchArgs[0],
|
|
264
264
|
options: FetchOptionsInterceptor
|
|
265
265
|
];
|
|
266
266
|
/** Custom fetch options (not used by built-in `fetch()`*/
|
|
@@ -380,7 +380,7 @@ type FetchRetryOptions = Omit<Partial<RetryOptions>, 'retry' | 'retryIf'> & {
|
|
|
380
380
|
};
|
|
381
381
|
type PostBody = Record<string, unknown> | BodyInit | null;
|
|
382
382
|
type PostArgs = [
|
|
383
|
-
url:
|
|
383
|
+
url: FetchArgs[0],
|
|
384
384
|
/**
|
|
385
385
|
* Post body or a function that returns/resolves post body.
|
|
386
386
|
*
|
|
@@ -426,12 +426,12 @@ declare class FetchError extends Error {
|
|
|
426
426
|
clone: (newMessage: string) => FetchError;
|
|
427
427
|
options: FetchOptions;
|
|
428
428
|
response: Response | undefined;
|
|
429
|
-
url:
|
|
429
|
+
url: FetchArgs[0];
|
|
430
430
|
constructor(message: string, options: {
|
|
431
431
|
cause?: unknown;
|
|
432
432
|
options: FetchOptions;
|
|
433
433
|
response?: Response;
|
|
434
|
-
url:
|
|
434
|
+
url: FetchArgs[0];
|
|
435
435
|
});
|
|
436
436
|
}
|
|
437
437
|
|
|
@@ -504,7 +504,7 @@ fixedOptions?: FixedOptions,
|
|
|
504
504
|
/** Common fetch options that can be overriden by individual request */
|
|
505
505
|
commonOptions?: FetchOptions & CommonOptions, commonDeferOptions?: DeferredAsyncOptions<unknown, CommonDelay>) => {
|
|
506
506
|
<T extends ClientData<FixedOptions> = never, TOptions extends ExcludeOptions<FixedOptions> | undefined = ExcludeOptions<FixedOptions> | undefined, Result = GetFetchResult<[FixedOptions, TOptions, CommonOptions], T>>(url: FetchArgs[0], options?: TOptions): IPromise_Fetch<Result>;
|
|
507
|
-
deferred<ThisArg, Delay extends CommonDelay | number, DefaultUrl extends FetchArgs[0] | undefined =
|
|
507
|
+
deferred<ThisArg, Delay extends CommonDelay | number, DefaultUrl extends FetchArgs[0] | undefined = URL | RequestInfo | undefined, DefaultOptions extends ExcludeOptions<FixedOptions> | undefined = ExcludeOptions<FixedOptions> | undefined>(deferOptions?: DeferredAsyncOptions<ThisArg, Delay>, defaultUrl?: DefaultUrl, defaultOptions?: DefaultOptions): <T extends ClientData<FixedOptions> = never, TOptions_1 extends ExcludeOptions<FixedOptions> | undefined = ExcludeOptions<FixedOptions> | undefined, Result_1 = GetFetchResult<[FixedOptions, TOptions_1, DefaultOptions, CommonOptions], T>>(...args: DefaultUrl extends undefined ? [url: FetchArgs[0], options?: TOptions_1] : [options?: TOptions_1]) => IPromise_Fetch<Result_1>;
|
|
508
508
|
};
|
|
509
509
|
|
|
510
510
|
/**
|
|
@@ -578,7 +578,7 @@ commonOptions?: PostOptions & CommonOptions, commonDeferOptions?: DeferredAsyncO
|
|
|
578
578
|
declare const executeInterceptors: <T, TArgs extends unknown[]>(value: T, signal?: AbortSignal, interceptors?: Interceptor<T, TArgs>[], ...args: TArgs) => Promise<T>;
|
|
579
579
|
|
|
580
580
|
declare const fetch$1: {
|
|
581
|
-
<T = unknown, TOptions extends FetchOptions = FetchOptions, TAs extends FetchAs = TOptions["as"] extends FetchAs ? TOptions["as"] : FetchAs.response, TReturn = FetchResult<T>[TAs]>(url:
|
|
581
|
+
<T = unknown, TOptions extends FetchOptions = FetchOptions, TAs extends FetchAs = TOptions["as"] extends FetchAs ? TOptions["as"] : FetchAs.response, TReturn = FetchResult<T>[TAs]>(url: FetchArgs[0], options?: FetchOptions & TOptions): IPromise_Fetch<TReturn>;
|
|
582
582
|
/** Default fetch options */
|
|
583
583
|
defaults: FetchOptionsDefault;
|
|
584
584
|
};
|
|
@@ -610,7 +610,7 @@ declare const methods: {
|
|
|
610
610
|
}, TOptions, ({
|
|
611
611
|
headers?: HeadersInit | undefined;
|
|
612
612
|
} & Omit<FetchOptions, "headers" | "method"> & Partial<Record<"method", never>>) | undefined], T>>(url: FetchArgs[0], options?: TOptions | undefined): IPromise_Fetch<Result>;
|
|
613
|
-
deferred<ThisArg, Delay extends number, DefaultUrl extends FetchArgs[0] | undefined =
|
|
613
|
+
deferred<ThisArg, Delay extends number, DefaultUrl extends FetchArgs[0] | undefined = URL | RequestInfo | undefined, DefaultOptions extends ({
|
|
614
614
|
headers?: HeadersInit | undefined;
|
|
615
615
|
} & Omit<FetchOptions, "headers" | "method"> & Partial<Record<"method", never>>) | undefined = ({
|
|
616
616
|
headers?: HeadersInit | undefined;
|
|
@@ -622,7 +622,7 @@ declare const methods: {
|
|
|
622
622
|
method: string;
|
|
623
623
|
}, TOptions, DefaultOptions, ({
|
|
624
624
|
headers?: HeadersInit | undefined;
|
|
625
|
-
} & Omit<FetchOptions, "headers" | "method"> & Partial<Record<"method", never>>) | undefined], T>>(...args: DefaultUrl extends undefined ? [url:
|
|
625
|
+
} & Omit<FetchOptions, "headers" | "method"> & Partial<Record<"method", never>>) | undefined], T>>(...args: DefaultUrl extends undefined ? [url: URL | RequestInfo, options?: TOptions | undefined] : [options?: TOptions | undefined]) => IPromise_Fetch<Result>;
|
|
626
626
|
};
|
|
627
627
|
/** Make HTTP requests with method HEAD */
|
|
628
628
|
head: {
|
|
@@ -635,7 +635,7 @@ declare const methods: {
|
|
|
635
635
|
}, TOptions, ({
|
|
636
636
|
headers?: HeadersInit | undefined;
|
|
637
637
|
} & Omit<FetchOptions, "headers" | "method"> & Partial<Record<"method", never>>) | undefined], T>>(url: FetchArgs[0], options?: TOptions | undefined): IPromise_Fetch<Result>;
|
|
638
|
-
deferred<ThisArg, Delay extends number, DefaultUrl extends FetchArgs[0] | undefined =
|
|
638
|
+
deferred<ThisArg, Delay extends number, DefaultUrl extends FetchArgs[0] | undefined = URL | RequestInfo | undefined, DefaultOptions extends ({
|
|
639
639
|
headers?: HeadersInit | undefined;
|
|
640
640
|
} & Omit<FetchOptions, "headers" | "method"> & Partial<Record<"method", never>>) | undefined = ({
|
|
641
641
|
headers?: HeadersInit | undefined;
|
|
@@ -647,7 +647,7 @@ declare const methods: {
|
|
|
647
647
|
method: string;
|
|
648
648
|
}, TOptions, DefaultOptions, ({
|
|
649
649
|
headers?: HeadersInit | undefined;
|
|
650
|
-
} & Omit<FetchOptions, "headers" | "method"> & Partial<Record<"method", never>>) | undefined], T>>(...args: DefaultUrl extends undefined ? [url:
|
|
650
|
+
} & Omit<FetchOptions, "headers" | "method"> & Partial<Record<"method", never>>) | undefined], T>>(...args: DefaultUrl extends undefined ? [url: URL | RequestInfo, options?: TOptions | undefined] : [options?: TOptions | undefined]) => IPromise_Fetch<Result>;
|
|
651
651
|
};
|
|
652
652
|
/** Make HTTP requests with method OPTIONS */
|
|
653
653
|
options: {
|
|
@@ -660,7 +660,7 @@ declare const methods: {
|
|
|
660
660
|
}, TOptions, ({
|
|
661
661
|
headers?: HeadersInit | undefined;
|
|
662
662
|
} & Omit<FetchOptions, "headers" | "method"> & Partial<Record<"method", never>>) | undefined], T>>(url: FetchArgs[0], options?: TOptions | undefined): IPromise_Fetch<Result>;
|
|
663
|
-
deferred<ThisArg, Delay extends number, DefaultUrl extends FetchArgs[0] | undefined =
|
|
663
|
+
deferred<ThisArg, Delay extends number, DefaultUrl extends FetchArgs[0] | undefined = URL | RequestInfo | undefined, DefaultOptions extends ({
|
|
664
664
|
headers?: HeadersInit | undefined;
|
|
665
665
|
} & Omit<FetchOptions, "headers" | "method"> & Partial<Record<"method", never>>) | undefined = ({
|
|
666
666
|
headers?: HeadersInit | undefined;
|
|
@@ -672,7 +672,7 @@ declare const methods: {
|
|
|
672
672
|
method: string;
|
|
673
673
|
}, TOptions, DefaultOptions, ({
|
|
674
674
|
headers?: HeadersInit | undefined;
|
|
675
|
-
} & Omit<FetchOptions, "headers" | "method"> & Partial<Record<"method", never>>) | undefined], T>>(...args: DefaultUrl extends undefined ? [url:
|
|
675
|
+
} & Omit<FetchOptions, "headers" | "method"> & Partial<Record<"method", never>>) | undefined], T>>(...args: DefaultUrl extends undefined ? [url: URL | RequestInfo, options?: TOptions | undefined] : [options?: TOptions | undefined]) => IPromise_Fetch<Result>;
|
|
676
676
|
};
|
|
677
677
|
/** Make HTTP requests with method DELETE */
|
|
678
678
|
delete: {
|
|
@@ -697,7 +697,7 @@ declare const methods: {
|
|
|
697
697
|
method: "delete";
|
|
698
698
|
}, Options, DefaultOptions, ({
|
|
699
699
|
headers?: HeadersInit | undefined;
|
|
700
|
-
} & Omit<PostOptions, "headers" | "method"> & Partial<Record<"method", never>>) | undefined], T>>(...args: PostDeferredCbArgs<DefaultUrl, DefaultData, Options, [url:
|
|
700
|
+
} & Omit<PostOptions, "headers" | "method"> & Partial<Record<"method", never>>) | undefined], T>>(...args: PostDeferredCbArgs<DefaultUrl, DefaultData, Options, [url: URL | RequestInfo, data: PostBody | (() => _superutils_core.ValueOrPromise<PostBody>), options: PostOptions], undefined extends DefaultUrl ? DefaultUrl & undefined : DefaultUrl, undefined extends DefaultData ? DefaultData & undefined : DefaultData>) => IPromise_Fetch<TReturn>;
|
|
701
701
|
};
|
|
702
702
|
/** Make HTTP requests with method PATCH */
|
|
703
703
|
patch: {
|
|
@@ -722,7 +722,7 @@ declare const methods: {
|
|
|
722
722
|
method: "patch";
|
|
723
723
|
}, Options, DefaultOptions, ({
|
|
724
724
|
headers?: HeadersInit | undefined;
|
|
725
|
-
} & Omit<PostOptions, "headers" | "method"> & Partial<Record<"method", never>>) | undefined], T>>(...args: PostDeferredCbArgs<DefaultUrl, DefaultData, Options, [url:
|
|
725
|
+
} & Omit<PostOptions, "headers" | "method"> & Partial<Record<"method", never>>) | undefined], T>>(...args: PostDeferredCbArgs<DefaultUrl, DefaultData, Options, [url: URL | RequestInfo, data: PostBody | (() => _superutils_core.ValueOrPromise<PostBody>), options: PostOptions], undefined extends DefaultUrl ? DefaultUrl & undefined : DefaultUrl, undefined extends DefaultData ? DefaultData & undefined : DefaultData>) => IPromise_Fetch<TReturn>;
|
|
726
726
|
};
|
|
727
727
|
/** Make HTTP requests with method POST */
|
|
728
728
|
post: {
|
|
@@ -747,7 +747,7 @@ declare const methods: {
|
|
|
747
747
|
method: "post";
|
|
748
748
|
}, Options, DefaultOptions, ({
|
|
749
749
|
headers?: HeadersInit | undefined;
|
|
750
|
-
} & Omit<PostOptions, "headers" | "method"> & Partial<Record<"method", never>>) | undefined], T>>(...args: PostDeferredCbArgs<DefaultUrl, DefaultData, Options, [url:
|
|
750
|
+
} & Omit<PostOptions, "headers" | "method"> & Partial<Record<"method", never>>) | undefined], T>>(...args: PostDeferredCbArgs<DefaultUrl, DefaultData, Options, [url: URL | RequestInfo, data: PostBody | (() => _superutils_core.ValueOrPromise<PostBody>), options: PostOptions], undefined extends DefaultUrl ? DefaultUrl & undefined : DefaultUrl, undefined extends DefaultData ? DefaultData & undefined : DefaultData>) => IPromise_Fetch<TReturn>;
|
|
751
751
|
};
|
|
752
752
|
/** Make HTTP requests with method PUT */
|
|
753
753
|
put: {
|
|
@@ -772,7 +772,7 @@ declare const methods: {
|
|
|
772
772
|
method: "put";
|
|
773
773
|
}, Options, DefaultOptions, ({
|
|
774
774
|
headers?: HeadersInit | undefined;
|
|
775
|
-
} & Omit<PostOptions, "headers" | "method"> & Partial<Record<"method", never>>) | undefined], T>>(...args: PostDeferredCbArgs<DefaultUrl, DefaultData, Options, [url:
|
|
775
|
+
} & Omit<PostOptions, "headers" | "method"> & Partial<Record<"method", never>>) | undefined], T>>(...args: PostDeferredCbArgs<DefaultUrl, DefaultData, Options, [url: URL | RequestInfo, data: PostBody | (() => _superutils_core.ValueOrPromise<PostBody>), options: PostOptions], undefined extends DefaultUrl ? DefaultUrl & undefined : DefaultUrl, undefined extends DefaultData ? DefaultData & undefined : DefaultData>) => IPromise_Fetch<TReturn>;
|
|
776
776
|
};
|
|
777
777
|
};
|
|
778
778
|
/**
|
package/dist/index.js
CHANGED
|
@@ -41,7 +41,7 @@ var executeInterceptors_default = executeInterceptors;
|
|
|
41
41
|
import { fallbackIfFails as fallbackIfFails2, isFn as isFn2, isPositiveInteger } from "@superutils/core";
|
|
42
42
|
import { retry } from "@superutils/promise";
|
|
43
43
|
var getResponse = (url, options = {}) => {
|
|
44
|
-
const fetchFunc = isFn2(options.fetchFunc) ? options.fetchFunc :
|
|
44
|
+
const fetchFunc = isFn2(options.fetchFunc) ? options.fetchFunc : getResponse.fetch;
|
|
45
45
|
if (!isPositiveInteger(options.retry)) return fetchFunc(url, options);
|
|
46
46
|
let attemptCount = 0;
|
|
47
47
|
const response = retry(
|
|
@@ -54,7 +54,7 @@ var getResponse = (url, options = {}) => {
|
|
|
54
54
|
retryIf: async (res, count, error) => {
|
|
55
55
|
var _a, _b;
|
|
56
56
|
const { abortCtrl, retryIf, signal } = options;
|
|
57
|
-
if ((
|
|
57
|
+
if ((signal == null ? void 0 : signal.aborted) || ((_a = abortCtrl == null ? void 0 : abortCtrl.signal) == null ? void 0 : _a.aborted)) return false;
|
|
58
58
|
return !!((_b = await fallbackIfFails2(
|
|
59
59
|
retryIf,
|
|
60
60
|
[res, count, error],
|
|
@@ -71,6 +71,7 @@ var getResponse = (url, options = {}) => {
|
|
|
71
71
|
);
|
|
72
72
|
return response;
|
|
73
73
|
};
|
|
74
|
+
getResponse.fetch = globalThis.fetch;
|
|
74
75
|
var getResponse_default = getResponse;
|
|
75
76
|
|
|
76
77
|
// src/mergeOptions.ts
|
|
@@ -251,14 +252,14 @@ var fetch = (url, options = {}) => {
|
|
|
251
252
|
if (!isSuccess) {
|
|
252
253
|
const jsonError = await fallbackIfFails3(
|
|
253
254
|
// try to parse error response as json first
|
|
254
|
-
() =>
|
|
255
|
+
() => {
|
|
256
|
+
var _a3;
|
|
257
|
+
return (_a3 = response == null ? void 0 : response.clone()) == null ? void 0 : _a3.json();
|
|
258
|
+
},
|
|
255
259
|
[],
|
|
256
260
|
void 0
|
|
257
261
|
);
|
|
258
|
-
throw new Error(
|
|
259
|
-
(jsonError == null ? void 0 : jsonError.message) || `${errMsgs.requestFailed} ${status}`,
|
|
260
|
-
{ cause: jsonError }
|
|
261
|
-
);
|
|
262
|
+
throw new Error(jsonError, { cause: jsonError });
|
|
262
263
|
}
|
|
263
264
|
const parseFunc = response[parseAs];
|
|
264
265
|
let result = !isFn4(parseFunc) ? response : parseFunc.bind(response)();
|
|
@@ -303,12 +304,15 @@ fetch.defaults = {
|
|
|
303
304
|
var interceptErr = async (err, url, options, response) => {
|
|
304
305
|
var _a, _b, _c;
|
|
305
306
|
const fErr = await executeInterceptors_default(
|
|
306
|
-
new FetchError(
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
307
|
+
new FetchError(
|
|
308
|
+
((_a = err == null ? void 0 : err.message) != null ? _a : err) || `${options.errMsgs.requestFailed} ${response == null ? void 0 : response.status}`,
|
|
309
|
+
{
|
|
310
|
+
cause: (_b = err == null ? void 0 : err.cause) != null ? _b : err,
|
|
311
|
+
response,
|
|
312
|
+
options,
|
|
313
|
+
url
|
|
314
|
+
}
|
|
315
|
+
),
|
|
312
316
|
void 0,
|
|
313
317
|
// should execute regardless of abort status
|
|
314
318
|
(_c = options.interceptors) == null ? void 0 : _c.error,
|
package/package.json
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
"description": "A lightweight `fetch` wrapper for browsers and Node.js, designed to simplify data fetching and reduce boilerplate.",
|
|
7
7
|
"dependencies": {
|
|
8
8
|
"@superutils/core": "^1.2.9",
|
|
9
|
-
"@superutils/promise": "^1.3.
|
|
9
|
+
"@superutils/promise": "^1.3.8"
|
|
10
10
|
},
|
|
11
11
|
"files": [
|
|
12
12
|
"dist",
|
|
@@ -53,6 +53,6 @@
|
|
|
53
53
|
"module": "./dist/index.js",
|
|
54
54
|
"type": "module",
|
|
55
55
|
"types": "./dist/index.d.ts",
|
|
56
|
-
"version": "1.5.
|
|
57
|
-
"gitHead": "
|
|
56
|
+
"version": "1.5.8",
|
|
57
|
+
"gitHead": "1faa1c8734f9892abb9e07616b62abeeff1321b5"
|
|
58
58
|
}
|