@ztimson/utils 0.21.0 → 0.21.2
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/array.d.ts +7 -0
- package/dist/aset.d.ts +6 -6
- package/dist/cache.d.ts +17 -5
- package/dist/emitter.d.ts +5 -5
- package/dist/index.cjs +2 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -2
- package/dist/index.mjs +438 -370
- package/dist/index.mjs.map +1 -1
- package/dist/logger.d.ts +6 -7
- package/dist/misc.d.ts +11 -0
- package/dist/path-events.d.ts +145 -0
- package/dist/time.d.ts +2 -2
- package/package.json +1 -1
- package/dist/makeArray.ts +0 -7
package/dist/array.d.ts
CHANGED
|
@@ -102,3 +102,10 @@ export declare function sortByProp(prop: string, reverse?: boolean): (a: any, b:
|
|
|
102
102
|
* @deprecated Please use ASet to create a guaranteed unique array
|
|
103
103
|
*/
|
|
104
104
|
export declare function makeUnique(arr: any[]): any[];
|
|
105
|
+
/**
|
|
106
|
+
* Make sure value is an array, if it isn't wrap it in one
|
|
107
|
+
*
|
|
108
|
+
* @param {T[] | T} value Value that should be an array
|
|
109
|
+
* @returns {T[]} Value in an array
|
|
110
|
+
*/
|
|
111
|
+
export declare function makeArray<T>(value: T | T[]): T[];
|
package/dist/aset.d.ts
CHANGED
|
@@ -11,15 +11,15 @@ export declare class ASet<T> extends Array {
|
|
|
11
11
|
*/
|
|
12
12
|
constructor(elements?: T[]);
|
|
13
13
|
/**
|
|
14
|
-
* Add
|
|
15
|
-
* @param
|
|
14
|
+
* Add elements to set if unique
|
|
15
|
+
* @param items
|
|
16
16
|
*/
|
|
17
|
-
add(
|
|
17
|
+
add(...items: T[]): this;
|
|
18
18
|
/**
|
|
19
|
-
* Delete
|
|
20
|
-
* @param
|
|
19
|
+
* Delete elements from set
|
|
20
|
+
* @param items Elements that will be deleted
|
|
21
21
|
*/
|
|
22
|
-
delete(
|
|
22
|
+
delete(...items: T[]): this;
|
|
23
23
|
/**
|
|
24
24
|
* Create list of elements this set has which the comparison set does not
|
|
25
25
|
* @param {ASet<T>} set Set to compare against
|
package/dist/cache.d.ts
CHANGED
|
@@ -1,9 +1,17 @@
|
|
|
1
|
+
export type CacheOptions = {
|
|
2
|
+
/** Delete keys automatically after x amount of seconds */
|
|
3
|
+
ttl?: number;
|
|
4
|
+
/** Storage to persist cache */
|
|
5
|
+
storage?: Storage;
|
|
6
|
+
/** Key cache will be stored under */
|
|
7
|
+
storageKey?: string;
|
|
8
|
+
};
|
|
1
9
|
/**
|
|
2
10
|
* Map of data which tracks whether it is a complete collection & offers optional expiry of cached values
|
|
3
11
|
*/
|
|
4
12
|
export declare class Cache<K extends string | number | symbol, T> {
|
|
5
13
|
readonly key?: keyof T | undefined;
|
|
6
|
-
|
|
14
|
+
readonly options: CacheOptions;
|
|
7
15
|
private store;
|
|
8
16
|
/** Support index lookups */
|
|
9
17
|
[key: string | number | symbol]: T | any;
|
|
@@ -13,9 +21,9 @@ export declare class Cache<K extends string | number | symbol, T> {
|
|
|
13
21
|
* Create new cache
|
|
14
22
|
*
|
|
15
23
|
* @param {keyof T} key Default property to use as primary key
|
|
16
|
-
* @param
|
|
24
|
+
* @param options
|
|
17
25
|
*/
|
|
18
|
-
constructor(key?: keyof T | undefined,
|
|
26
|
+
constructor(key?: keyof T | undefined, options?: CacheOptions);
|
|
19
27
|
private getKey;
|
|
20
28
|
/**
|
|
21
29
|
* Get all cached items
|
|
@@ -30,7 +38,7 @@ export declare class Cache<K extends string | number | symbol, T> {
|
|
|
30
38
|
* @param {number | undefined} ttl Override default expiry
|
|
31
39
|
* @return {this}
|
|
32
40
|
*/
|
|
33
|
-
add(value: T, ttl?:
|
|
41
|
+
add(value: T, ttl?: any): this;
|
|
34
42
|
/**
|
|
35
43
|
* Add several rows to the cache
|
|
36
44
|
*
|
|
@@ -39,6 +47,10 @@ export declare class Cache<K extends string | number | symbol, T> {
|
|
|
39
47
|
* @return {this}
|
|
40
48
|
*/
|
|
41
49
|
addAll(rows: T[], complete?: boolean): this;
|
|
50
|
+
/**
|
|
51
|
+
* Remove all keys from cache
|
|
52
|
+
*/
|
|
53
|
+
clear(): void;
|
|
42
54
|
/**
|
|
43
55
|
* Delete an item from the cache
|
|
44
56
|
*
|
|
@@ -73,7 +85,7 @@ export declare class Cache<K extends string | number | symbol, T> {
|
|
|
73
85
|
*
|
|
74
86
|
* @param {K} key Key item will be cached under
|
|
75
87
|
* @param {T} value Item to cache
|
|
76
|
-
* @param {number | undefined} ttl Override default expiry
|
|
88
|
+
* @param {number | undefined} ttl Override default expiry in seconds
|
|
77
89
|
* @return {this}
|
|
78
90
|
*/
|
|
79
91
|
set(key: K, value: T, ttl?: number | undefined): this;
|
package/dist/emitter.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export type
|
|
1
|
+
export type TypedListener = (...args: any[]) => any;
|
|
2
2
|
export type TypedEvents = {
|
|
3
|
-
[k in string | symbol]:
|
|
3
|
+
[k in string | symbol]: TypedListener;
|
|
4
4
|
} & {
|
|
5
5
|
'*': (event: string, ...args: any[]) => any;
|
|
6
6
|
};
|
|
@@ -11,9 +11,9 @@ export declare class TypedEmitter<T extends TypedEvents = TypedEvents> {
|
|
|
11
11
|
private static listeners;
|
|
12
12
|
private listeners;
|
|
13
13
|
static emit(event: any, ...args: any[]): void;
|
|
14
|
-
static off(event: any, listener:
|
|
15
|
-
static on(event: any, listener:
|
|
16
|
-
static once(event: any, listener?:
|
|
14
|
+
static off(event: any, listener: TypedListener): void;
|
|
15
|
+
static on(event: any, listener: TypedListener): () => void;
|
|
16
|
+
static once(event: any, listener?: TypedListener): Promise<any>;
|
|
17
17
|
emit<K extends keyof T>(event: K, ...args: Parameters<T[K]>): void;
|
|
18
18
|
off<K extends keyof T = string>(event: K, listener: T[K]): void;
|
|
19
19
|
on<K extends keyof T = string>(event: K, listener: T[K]): () => void;
|
package/dist/index.cjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
(function(c,
|
|
2
|
-
`)}class B extends Promise{constructor(e){super((n,i)=>e(o=>n(o),o=>i(o),o=>this.progress=o));a(this,"listeners",[]);a(this,"_progress",0)}get progress(){return this._progress}set progress(e){e!=this._progress&&(this._progress=e,this.listeners.forEach(n=>n(e)))}static from(e){return e instanceof B?e:new B((n,i)=>e.then((...o)=>n(...o)).catch((...o)=>i(...o)))}from(e){const n=B.from(e);return this.onProgress(i=>n.progress=i),n}onProgress(e){return this.listeners.push(e),this}then(e,n){const i=super.then(e,n);return this.from(i)}catch(e){return this.from(super.catch(e))}finally(e){return this.from(super.finally(e))}}function Ct(r,t){r instanceof Blob||(r=new Blob(ct(r)));const e=URL.createObjectURL(r);at(e,t),URL.revokeObjectURL(e)}function at(r,t){const e=document.createElement("a");e.href=r,e.download=t||r.split("/").pop(),document.body.appendChild(e),e.click(),document.body.removeChild(e)}function Rt(r={}){return new Promise(t=>{const e=document.createElement("input");e.type="file",e.accept=r.accept||"*",e.style.display="none",e.multiple=!!r.multiple,e.onblur=e.onchange=async()=>{t(Array.from(e.files)),e.remove()},document.body.appendChild(e),e.click()})}function Nt(r,t=new Date){(typeof t=="number"||typeof t=="string")&&(t=new Date(t));const e=`${t.getFullYear()}-${(t.getMonth()+1).toString().padStart(2,"0")}-${t.getDate().toString().padStart(2,"0")}_${t.getHours().toString().padStart(2,"0")}-${t.getMinutes().toString().padStart(2,"0")}-${t.getSeconds().toString().padStart(2,"0")}`;return r?r.replace("{{TIMESTAMP}}",e):e}function Lt(r){return new B((t,e,n)=>{const i=new XMLHttpRequest,o=new FormData;r.files.forEach(s=>o.append("file",s)),i.withCredentials=!!r.withCredentials,i.upload.addEventListener("progress",s=>s.lengthComputable?n(s.loaded/s.total):null),i.addEventListener("loadend",()=>t(L(i.responseText))),i.addEventListener("error",()=>e(L(i.responseText))),i.addEventListener("timeout",()=>e({error:"Request timed out"})),i.open("POST",r.url),Object.entries(r.headers||{}).forEach(([s,l])=>i.setRequestHeader(s,l)),i.send(o)})}class U{constructor(){a(this,"listeners",{})}static emit(t,...e){(this.listeners["*"]||[]).forEach(n=>n(t,...e)),(this.listeners[t.toString()]||[]).forEach(n=>n(...e))}static off(t,e){const n=t.toString();this.listeners[n]=(this.listeners[n]||[]).filter(i=>i===e)}static on(t,e){var i;const n=t.toString();return this.listeners[n]||(this.listeners[n]=[]),(i=this.listeners[n])==null||i.push(e),()=>this.off(t,e)}static once(t,e){return new Promise(n=>{const i=this.on(t,(...o)=>{n(o.length==1?o[0]:o),e&&e(...o),i()})})}emit(t,...e){(this.listeners["*"]||[]).forEach(n=>n(t,...e)),(this.listeners[t]||[]).forEach(n=>n(...e))}off(t,e){this.listeners[t]=(this.listeners[t]||[]).filter(n=>n===e)}on(t,e){var n;return this.listeners[t]||(this.listeners[t]=[]),(n=this.listeners[t])==null||n.push(e),()=>this.off(t,e)}once(t,e){return new Promise(n=>{const i=this.on(t,(...o)=>{n(o.length==1?o[0]:o),e&&e(...o),i()})})}}a(U,"listeners",{});class m extends Error{constructor(e,n){super(e);a(this,"_code");n!=null&&(this._code=n)}get code(){return this._code||this.constructor.code}set code(e){this._code=e}static from(e){const n=Number(e.statusCode)??Number(e.code),i=new this(e.message||e.toString());return Object.assign(i,{stack:e.stack,...e,code:n??void 0})}static instanceof(e){return e.constructor.code!=null}toString(){return this.message||super.toString()}}a(m,"code",500);class G extends m{constructor(t="Bad Request"){super(t)}static instanceof(t){return t.constructor.code==this.code}}a(G,"code",400);class F extends m{constructor(t="Unauthorized"){super(t)}static instanceof(t){return t.constructor.code==this.code}}a(F,"code",401);class q extends m{constructor(t="Payment Required"){super(t)}static instanceof(t){return t.constructor.code==this.code}}a(q,"code",402);class H extends m{constructor(t="Forbidden"){super(t)}static instanceof(t){return t.constructor.code==this.code}}a(H,"code",403);class Y extends m{constructor(t="Not Found"){super(t)}static instanceof(t){return t.constructor.code==this.code}}a(Y,"code",404);class _ extends m{constructor(t="Method Not Allowed"){super(t)}static instanceof(t){return t.constructor.code==this.code}}a(_,"code",405);class J extends m{constructor(t="Not Acceptable"){super(t)}static instanceof(t){return t.constructor.code==this.code}}a(J,"code",406);class W extends m{constructor(t="Internal Server Error"){super(t)}static instanceof(t){return t.constructor.code==this.code}}a(W,"code",500);class z extends m{constructor(t="Not Implemented"){super(t)}static instanceof(t){return t.constructor.code==this.code}}a(z,"code",501);class K extends m{constructor(t="Bad Gateway"){super(t)}static instanceof(t){return t.constructor.code==this.code}}a(K,"code",502);class V extends m{constructor(t="Service Unavailable"){super(t)}static instanceof(t){return t.constructor.code==this.code}}a(V,"code",503);class Z extends m{constructor(t="Gateway Timeout"){super(t)}static instanceof(t){return t.constructor.code==this.code}}a(Z,"code",504);function $t(r,t){if(r>=200&&r<300)return null;switch(r){case 400:return new G(t);case 401:return new F(t);case 402:return new q(t);case 403:return new H(t);case 404:return new Y(t);case 405:return new _(t);case 406:return new J(t);case 500:return new W(t);case 501:return new z(t);case 502:return new K(t);case 503:return new V(t);case 504:return new Z(t);default:return new m(t,r)}}const E=class E{constructor(t={}){a(this,"interceptors",{});a(this,"headers",{});a(this,"url");this.url=t.url??null,this.headers=t.headers||{},t.interceptors&&t.interceptors.forEach(e=>E.addInterceptor(e))}static addInterceptor(t){const e=Object.keys(E.interceptors).length.toString();return E.interceptors[e]=t,()=>{E.interceptors[e]=null}}addInterceptor(t){const e=Object.keys(this.interceptors).length.toString();return this.interceptors[e]=t,()=>{this.interceptors[e]=null}}request(t={}){var i;if(!this.url&&!t.url)throw new Error("URL needs to be set");let e=((i=t.url)!=null&&i.startsWith("http")?t.url:(this.url||"")+(t.url||"")).replace(/([^:]\/)\/+/g,"$1");if(t.fragment&&(e.includes("#")?e.replace(/#.*(\?|\n)/g,(o,s)=>`#${t.fragment}${s}`):e+="#"+t.fragment),t.query){const o=Array.isArray(t.query)?t.query:Object.keys(t.query).map(s=>({key:s,value:t.query[s]}));e+=(e.includes("?")?"&":"?")+o.map(s=>`${s.key}=${s.value}`).join("&")}const n=p({"Content-Type":t.body?t.body instanceof FormData?"multipart/form-data":"application/json":void 0,...E.headers,...this.headers,...t.headers});return typeof t.body=="object"&&t.body!=null&&n["Content-Type"]=="application/json"&&(t.body=JSON.stringify(t.body)),new B((o,s,l)=>{fetch(e,{headers:n,method:t.method||(t.body?"POST":"GET"),body:t.body}).then(async u=>{var yt,gt;for(let f of[...Object.values(E.interceptors),...Object.values(this.interceptors)])await new Promise(k=>f(u,()=>k()));const M=u.headers.get("Content-Length"),rt=M?parseInt(M,10):0;let dt=0;const nt=(yt=u.body)==null?void 0:yt.getReader(),se=new ReadableStream({start(f){function k(){nt==null||nt.read().then(N=>{if(N.done)return f.close();dt+=N.value.byteLength,l(dt/rt),f.enqueue(N.value),k()}).catch(N=>f.error(N))}k()}});if(u.data=new Response(se),t.decode==null||t.decode){const f=(gt=u.headers.get("Content-Type"))==null?void 0:gt.toLowerCase();f!=null&&f.includes("form")?u.data=await u.data.formData():f!=null&&f.includes("json")?u.data=await u.data.json():f!=null&&f.includes("text")?u.data=await u.data.text():f!=null&&f.includes("application")&&(u.data=await u.data.blob())}u.ok?o(u):s(u)})})}};a(E,"interceptors",{}),a(E,"headers",{});let Q=E;function Tt(r){const t=r.split(".")[1].replace(/-/g,"+").replace(/_/g,"/");return L(decodeURIComponent(atob(t).split("").map(function(e){return"%"+("00"+e.charCodeAt(0).toString(16)).slice(-2)}).join("")))}const j={CLEAR:"\x1B[0m",BRIGHT:"\x1B[1m",DIM:"\x1B[2m",UNDERSCORE:"\x1B[4m",BLINK:"\x1B[5m",REVERSE:"\x1B[7m",HIDDEN:"\x1B[8m"},R={BLACK:"\x1B[30m",RED:"\x1B[31m",GREEN:"\x1B[32m",YELLOW:"\x1B[33m",BLUE:"\x1B[34m",MAGENTA:"\x1B[35m",CYAN:"\x1B[36m",LIGHT_GREY:"\x1B[37m",GREY:"\x1B[90m",LIGHT_RED:"\x1B[91m",LIGHT_GREEN:"\x1B[92m",LIGHT_YELLOW:"\x1B[93m",LIGHT_BLUE:"\x1B[94m",LIGHT_MAGENTA:"\x1B[95m",LIGHT_CYAN:"\x1B[96m",WHITE:"\x1B[97m"},It={BLACK:"\x1B[40m",RED:"\x1B[41m",GREEN:"\x1B[42m",YELLOW:"\x1B[43m",BLUE:"\x1B[44m",MAGENTA:"\x1B[45m",CYAN:"\x1B[46m",WHITE:"\x1B[47m",GREY:"\x1B[100m"};var ut=(r=>(r[r.ERROR=0]="ERROR",r[r.WARN=1]="WARN",r[r.INFO=2]="INFO",r[r.LOG=3]="LOG",r[r.DEBUG=4]="DEBUG",r))(ut||{});const w=class w extends U{constructor(t){super(),this.namespace=t}pad(t,e,n,i=!1){const o=t.toString(),s=e-o.length;if(s<=0)return o;const l=Array(~~(s/n.length)).fill(n).join("");return i?o+l:l+o}format(...t){const e=new Date;return`${`${e.getFullYear()}-${e.getMonth()+1}-${e.getDate()} ${this.pad(e.getHours().toString(),2,"0")}:${this.pad(e.getMinutes().toString(),2,"0")}:${this.pad(e.getSeconds().toString(),2,"0")}.${this.pad(e.getMilliseconds().toString(),3,"0",!0)}`}${this.namespace?` [${this.namespace}]`:""} ${t.join(" ")}`}debug(...t){if(w.LOG_LEVEL<4)return;const e=this.format(...t);w.emit(4,e),console.debug(R.LIGHT_GREY+e+j.CLEAR)}log(...t){if(w.LOG_LEVEL<3)return;const e=this.format(...t);w.emit(3,e),console.log(j.CLEAR+e)}info(...t){if(w.LOG_LEVEL<2)return;const e=this.format(...t);w.emit(2,e),console.info(R.BLUE+e+j.CLEAR)}warn(...t){if(w.LOG_LEVEL<1)return;const e=this.format(...t);w.emit(1,e),console.warn(R.YELLOW+e+j.CLEAR)}error(...t){if(w.LOG_LEVEL<0)return;const e=this.format(...t);w.emit(0,e),console.error(R.RED+e+j.CLEAR)}};a(w,"LOG_LEVEL",4);let X=w;function Mt(r){const t=(l,u)=>u<1e-7?l:t(u,~~(l%u)),e=r.toString().length-2;let n=Math.pow(10,e),i=r*n;const o=t(i,n);i=~~(i/o),n=~~(n/o);const s=~~(i/n);return i-=s*n,`${s?s+" ":""}${~~i}/${~~n}`}function kt(r){let t=r.split(" ");const e=t.length==2?Number(t[0]):0;return t=t.pop().split("/"),e+Number(t[0])/Number(t[1])}const x="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",tt="0123456789",et="~`!@#$%^&*()_-+={[}]|\\:;\"'<,>.?/",Pt=x+tt+et;function Dt(r,t=2){if(r===0)return"0 Bytes";const e=1024,n=["Bytes","KB","MB","GB","TB","PB","EB","ZB","YB"],i=Math.floor(Math.log(r)/Math.log(e));return parseFloat((r/Math.pow(e,i)).toFixed(t))+" "+n[i]}function Ut(r){const t=/(\+?1)?.*?(\d{3}).*?(\d{3}).*?(\d{4})/g.exec(r);if(!t)throw new Error(`Number cannot be parsed: ${r}`);return`${t[1]??""} (${t[2]}) ${t[3]}-${t[4]}`.trim()}function Gt(r,t,e){return`${r.slice(0,e)}${t}${r.slice(e+1)}`}function Ft(r,t,e=" ",n=!0){return n?r.toString().padStart(t,e):r.toString().padEnd(t,e)}function qt(r){return Array(r).fill(null).map(()=>Math.round(Math.random()*15).toString(16)).join("")}function Ht(r,t=Pt){return Array(r).fill(null).map(()=>{const e=~~(Math.random()*t.length);return t[e]}).join("")}function Yt(r,t=!1,e=!1,n=!1){if(!t&&!e&&!n)throw new Error("Must enable at least one: letters, numbers, symbols");return Array(r).fill(null).map(()=>{let i;do{const o=~~(Math.random()*3);t&&o==0?i=x[~~(Math.random()*x.length)]:e&&o==1?i=tt[~~(Math.random()*tt.length)]:n&&o==2&&(i=et[~~(Math.random()*et.length)])}while(!i);return i}).join("")}function _t(r,t){if(typeof t=="string"&&(t=new RegExp(t,"g")),!t.global)throw new TypeError("Regular expression must be global.");let e=[],n;for(;(n=t.exec(r))!==null;)e.push(n);return e}function Jt(r){const t=new RegExp("(?:(?<protocol>[\\w\\d]+)\\:\\/\\/)?(?:(?<user>.+)\\@)?(?<host>(?<domain>[^:\\/\\?#@\\n]+)(?:\\:(?<port>\\d*))?)(?<path>\\/.*?)?(?:\\?(?<query>.*?))?(?:#(?<fragment>.*?))?$","gm").exec(r),e=(t==null?void 0:t.groups)??{},n=e.domain.split(".");if(e.port!=null&&(e.port=Number(e.port)),n.length>2&&(e.domain=n.splice(-2,2).join("."),e.subdomain=n.join(".")),e.query){const i=e.query.split("&"),o={};i.forEach(s=>{const[l,u]=s.split("=");o[l]=u}),e.query=o}return e}function lt(r){var t=Wt(Kt(Vt(zt(r),8*r.length)));return t.toLowerCase()}function Wt(r){for(var t,e="0123456789ABCDEF",n="",i=0;i<r.length;i++)t=r.charCodeAt(i),n+=e.charAt(t>>>4&15)+e.charAt(15&t);return n}function zt(r){for(var t=Array(r.length>>2),e=0;e<t.length;e++)t[e]=0;for(e=0;e<8*r.length;e+=8)t[e>>5]|=(255&r.charCodeAt(e/8))<<e%32;return t}function Kt(r){for(var t="",e=0;e<32*r.length;e+=8)t+=String.fromCharCode(r[e>>5]>>>e%32&255);return t}function Vt(r,t){r[t>>5]|=128<<t%32,r[14+(t+64>>>9<<4)]=t;for(var e=1732584193,n=-271733879,i=-1732584194,o=271733878,s=0;s<r.length;s+=16){var l=e,u=n,M=i,rt=o;n=g(n=g(n=g(n=g(n=y(n=y(n=y(n=y(n=d(n=d(n=d(n=d(n=h(n=h(n=h(n=h(n,i=h(i,o=h(o,e=h(e,n,i,o,r[s+0],7,-680876936),n,i,r[s+1],12,-389564586),e,n,r[s+2],17,606105819),o,e,r[s+3],22,-1044525330),i=h(i,o=h(o,e=h(e,n,i,o,r[s+4],7,-176418897),n,i,r[s+5],12,1200080426),e,n,r[s+6],17,-1473231341),o,e,r[s+7],22,-45705983),i=h(i,o=h(o,e=h(e,n,i,o,r[s+8],7,1770035416),n,i,r[s+9],12,-1958414417),e,n,r[s+10],17,-42063),o,e,r[s+11],22,-1990404162),i=h(i,o=h(o,e=h(e,n,i,o,r[s+12],7,1804603682),n,i,r[s+13],12,-40341101),e,n,r[s+14],17,-1502002290),o,e,r[s+15],22,1236535329),i=d(i,o=d(o,e=d(e,n,i,o,r[s+1],5,-165796510),n,i,r[s+6],9,-1069501632),e,n,r[s+11],14,643717713),o,e,r[s+0],20,-373897302),i=d(i,o=d(o,e=d(e,n,i,o,r[s+5],5,-701558691),n,i,r[s+10],9,38016083),e,n,r[s+15],14,-660478335),o,e,r[s+4],20,-405537848),i=d(i,o=d(o,e=d(e,n,i,o,r[s+9],5,568446438),n,i,r[s+14],9,-1019803690),e,n,r[s+3],14,-187363961),o,e,r[s+8],20,1163531501),i=d(i,o=d(o,e=d(e,n,i,o,r[s+13],5,-1444681467),n,i,r[s+2],9,-51403784),e,n,r[s+7],14,1735328473),o,e,r[s+12],20,-1926607734),i=y(i,o=y(o,e=y(e,n,i,o,r[s+5],4,-378558),n,i,r[s+8],11,-2022574463),e,n,r[s+11],16,1839030562),o,e,r[s+14],23,-35309556),i=y(i,o=y(o,e=y(e,n,i,o,r[s+1],4,-1530992060),n,i,r[s+4],11,1272893353),e,n,r[s+7],16,-155497632),o,e,r[s+10],23,-1094730640),i=y(i,o=y(o,e=y(e,n,i,o,r[s+13],4,681279174),n,i,r[s+0],11,-358537222),e,n,r[s+3],16,-722521979),o,e,r[s+6],23,76029189),i=y(i,o=y(o,e=y(e,n,i,o,r[s+9],4,-640364487),n,i,r[s+12],11,-421815835),e,n,r[s+15],16,530742520),o,e,r[s+2],23,-995338651),i=g(i,o=g(o,e=g(e,n,i,o,r[s+0],6,-198630844),n,i,r[s+7],10,1126891415),e,n,r[s+14],15,-1416354905),o,e,r[s+5],21,-57434055),i=g(i,o=g(o,e=g(e,n,i,o,r[s+12],6,1700485571),n,i,r[s+3],10,-1894986606),e,n,r[s+10],15,-1051523),o,e,r[s+1],21,-2054922799),i=g(i,o=g(o,e=g(e,n,i,o,r[s+8],6,1873313359),n,i,r[s+15],10,-30611744),e,n,r[s+6],15,-1560198380),o,e,r[s+13],21,1309151649),i=g(i,o=g(o,e=g(e,n,i,o,r[s+4],6,-145523070),n,i,r[s+11],10,-1120210379),e,n,r[s+2],15,718787259),o,e,r[s+9],21,-343485551),e=b(e,l),n=b(n,u),i=b(i,M),o=b(o,rt)}return Array(e,n,i,o)}function $(r,t,e,n,i,o){return b(Zt(b(b(t,r),b(n,o)),i),e)}function h(r,t,e,n,i,o,s){return $(t&e|~t&n,r,t,i,o,s)}function d(r,t,e,n,i,o,s){return $(t&n|e&~n,r,t,i,o,s)}function y(r,t,e,n,i,o,s){return $(t^e^n,r,t,i,o,s)}function g(r,t,e,n,i,o,s){return $(e^(t|~n),r,t,i,o,s)}function b(r,t){var e=(65535&r)+(65535&t);return(r>>16)+(t>>16)+(e>>16)<<16|65535&e}function Zt(r,t){return r<<t|r>>>32-t}function Qt(r){return/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/.test(r)}function Xt(r,t="mp"){return r?`https://www.gravatar.com/avatar/${lt(r)}?d=${t}`:""}function xt(r){(typeof r=="number"||typeof r=="string")&&(r=new Date(r));let t=r.getHours(),e="AM";return t>=12?(t>12&&(t-=12),e="PM"):t==0&&(t=12),`${r.getFullYear()}-${(r.getMonth()+1).toString().padStart(2,"0")}-${r.getDate().toString().padStart(2,"0")}, ${t}:${r.getMinutes().toString().padStart(2,"0")} ${e}`}function ft(r){return new Promise(t=>setTimeout(t,r))}async function te(r,t=100){for(;await r();)await ft(t)}function ee(r){return(r instanceof Date?r.getTime():r)-new Date().getTime()}function re(){return Object.keys({})}var T=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},ne={},C={};Object.defineProperty(C,"__esModule",{value:!0}),C.persist=C.Persist=void 0;class ht{constructor(t,e={}){a(this,"key");a(this,"options");a(this,"storage");a(this,"watches",{});a(this,"_value");this.key=t,this.options=e,this.storage=e.storage||localStorage,this.load()}get value(){var t;return this._value!==void 0?this._value:(t=this.options)==null?void 0:t.default}set value(t){t==null||typeof t!="object"?this._value=t:this._value=new Proxy(t,{get:(e,n)=>typeof e[n]=="function"?(...o)=>{const s=e[n](...o);return this.save(),s}:e[n],set:(e,n,i)=>(e[n]=i,this.save(),!0)}),this.save()}notify(t){Object.values(this.watches).forEach(e=>e(t))}clear(){this.storage.removeItem(this.key)}save(){this._value===void 0?this.clear():this.storage.setItem(this.key,JSON.stringify(this._value)),this.notify(this.value)}load(){if(this.storage[this.key]!=null){let t=JSON.parse(this.storage.getItem(this.key));t!=null&&typeof t=="object"&&this.options.type&&(t.__proto__=this.options.type.prototype),this.value=t}else this.value=this.options.default||void 0}watch(t){const e=Object.keys(this.watches).length;return this.watches[e]=t,()=>{delete this.watches[e]}}toString(){return JSON.stringify(this.value)}valueOf(){return this.value}}C.Persist=ht;function ie(r){return(t,e)=>{const n=(r==null?void 0:r.key)||`${t.constructor.name}.${e.toString()}`,i=new ht(n,r);Object.defineProperty(t,e,{get:function(){return i.value},set:function(o){i.value=o}})}}C.persist=ie;var I={};Object.defineProperty(I,"__esModule",{value:!0}),I.MemoryStorage=void 0;class oe{get length(){return Object.keys(this).length}clear(){Object.keys(this).forEach(t=>this.removeItem(t))}getItem(t){return this[t]}key(t){return Object.keys(this)[t]}removeItem(t){delete this[t]}setItem(t,e){this[t]=e}}I.MemoryStorage=oe,function(r){var t=T&&T.__createBinding||(Object.create?function(n,i,o,s){s===void 0&&(s=o);var l=Object.getOwnPropertyDescriptor(i,o);(!l||("get"in l?!i.__esModule:l.writable||l.configurable))&&(l={enumerable:!0,get:function(){return i[o]}}),Object.defineProperty(n,s,l)}:function(n,i,o,s){s===void 0&&(s=o),n[s]=i[o]}),e=T&&T.__exportStar||function(n,i){for(var o in n)o!=="default"&&!Object.prototype.hasOwnProperty.call(i,o)&&t(i,n,o)};Object.defineProperty(r,"__esModule",{value:!0}),e(C,r),e(I,r)}(ne),c.ASet=v,c.BadGatewayError=K,c.BadRequestError=G,c.Cache=vt,c.CliBackground=It,c.CliEffects=j,c.CliForeground=R,c.CustomError=m,c.ForbiddenError=H,c.GatewayTimeoutError=Z,c.Http=Q,c.InternalServerError=W,c.JSONAttemptParse=L,c.JSONSanitize=Et,c.LOG_LEVEL=ut,c.Logger=X,c.MethodNotAllowedError=_,c.NotAcceptableError=J,c.NotFoundError=Y,c.NotImplementedError=z,c.PaymentRequiredError=q,c.PromiseProgress=B,c.ServiceUnavailableError=V,c.TypedEmitter=U,c.UnauthorizedError=F,c.addUnique=bt,c.arrayDiff=St,c.caseInsensitiveSort=Bt,c.clean=p,c.csv=jt,c.dec2Frac=Mt,c.deepCopy=O,c.deepMerge=it,c.dotNotation=S,c.downloadFile=Ct,c.downloadUrl=at,c.encodeQuery=mt,c.errorFromCode=$t,c.fileBrowser=Rt,c.findByProp=Ot,c.flattenArr=ot,c.flattenObj=P,c.formData=pt,c.formatBytes=Dt,c.formatDate=xt,c.formatPhoneNumber=Ut,c.fracToDec=kt,c.gravatar=Xt,c.includes=D,c.insertAt=Gt,c.isEqual=A,c.jwtDecode=Tt,c.makeArray=ct,c.makeUnique=st,c.matchAll=_t,c.md5=lt,c.mixin=wt,c.pad=Ft,c.parseUrl=Jt,c.randomHex=qt,c.randomString=Ht,c.randomStringBuilder=Yt,c.sleep=ft,c.sleepUntil=te,c.sortByProp=At,c.timeUntil=ee,c.timestampFilename=Nt,c.tyoeKeys=re,c.uploadWithProgress=Lt,c.validateEmail=Qt,Object.defineProperty(c,Symbol.toStringTag,{value:"Module"})});
|
|
1
|
+
(function(c,w){typeof exports=="object"&&typeof module<"u"?w(exports):typeof define=="function"&&define.amd?define(["exports"],w):(c=typeof globalThis<"u"?globalThis:c||self,w(c.utils={}))})(this,function(c){"use strict";var oe=Object.defineProperty;var ce=(c,w,C)=>w in c?oe(c,w,{enumerable:!0,configurable:!0,writable:!0,value:C}):c[w]=C;var a=(c,w,C)=>ce(c,typeof w!="symbol"?w+"":w,C);function w(r,t=!1){if(r==null)throw new Error("Cannot clean a NULL value");return Array.isArray(r)?r=r.filter(e=>e!=null):Object.entries(r).forEach(([e,n])=>{(t&&n===void 0||!t&&n==null)&&delete r[e]}),r}function C(r){return structuredClone(r)}function st(r,...t){return t.forEach(e=>{for(const n in e)e[n]&&typeof e[n]=="object"&&!Array.isArray(e[n])?(r[n]||(r[n]={}),st(r[n],e[n])):r[n]=e[n]}),r}function O(r,t,e){if(!(r==null||!t))return t.split(/[.[\]]/g).filter(n=>n.length).reduce((n,s,i,o)=>{if((s[0]=='"'||s[0]=="'")&&(s=s.slice(1,-1)),!(n!=null&&n.hasOwnProperty(s))){if(e==null)return;n[s]={}}return e!==void 0&&i==o.length-1?n[s]=e:n[s]},r)}function gt(r){return Object.entries(r).map(([t,e])=>encodeURIComponent(t)+"="+encodeURIComponent(e)).join("&")}function M(r,t,e={}){if(typeof r=="object"&&!Array.isArray(r)){for(const n of Object.keys(r)){const s=t?t+"."+n:n;typeof r[n]=="object"?M(r[n],s,e):e[s]=r[n]}return e}}function pt(r){const t=new FormData;return Object.entries(r).forEach(([e,n])=>t.append(e,n)),t}function k(r,t,e=!1){if(r==null)return e;if(Array.isArray(t))return t.findIndex((s,i)=>!k(r[i],t[i],e))==-1;const n=typeof t;return n!=typeof r?!1:n=="object"?Object.keys(t).find(s=>!k(r[s],t[s],e))==null:n=="function"?r.toString()==t.toString():r==t}function $(r,t){const e=typeof r,n=typeof t;return e!="object"||r==null||n!="object"||t==null?e=="function"&&n=="function"?r.toString()==t.toString():r===t:Object.keys(r).length!=Object.keys(t).length?!1:Object.keys(r).every(i=>$(r[i],t[i]))}function wt(r,t){t.forEach(e=>{Object.getOwnPropertyNames(e.prototype).forEach(n=>{Object.defineProperty(r.prototype,n,Object.getOwnPropertyDescriptor(e.prototype,n)||Object.create(null))})})}function T(r){try{return JSON.parse(r)}catch{return r}}function it(r,t){let e=[];return JSON.stringify(r,(n,s)=>{if(typeof s=="object"&&s!==null){if(e.includes(s))return;e.push(s)}return s},t)}function Et(r,t){return r.indexOf(t)===-1&&r.push(t),r}function St(r,t){return ct([...r.filter(e=>!t.includes(n=>$(e,n))),...t.filter(e=>!r.includes(n=>$(e,n)))])}function bt(r){return function(t,e){const n=O(t,r),s=O(e,r);return typeof n!="string"||typeof s!="string"?1:n.toLowerCase().localeCompare(s.toLowerCase())}}function Bt(r,t){return e=>$(O(e,r),t)}function ot(r,t=[]){return r.forEach(e=>Array.isArray(e)?ot(e,t):t.push(e)),t}function At(r,t=!1){return function(e,n){const s=O(e,r),i=O(n,r);return typeof s=="number"&&typeof i=="number"?(t?-1:1)*(s-i):s>i?t?-1:1:s<i?t?1:-1:0}}function ct(r){for(let t=r.length-1;t>=0;t--)r.slice(0,t).find(e=>$(e,r[t]))&&r.splice(t,1);return r}function B(r){return Array.isArray(r)?r:[r]}class S extends Array{get size(){return this.length}constructor(t=[]){super(),t!=null&&t.forEach&&t.forEach(e=>this.add(e))}add(...t){return t.filter(e=>!this.has(e)).forEach(e=>this.push(e)),this}delete(...t){return t.forEach(e=>{const n=this.indexOf(e);n!=-1&&this.slice(n,1)}),this}difference(t){return new S(this.filter(e=>!t.has(e)))}has(t){return this.indexOf(t)!=-1}intersection(t){return new S(this.filter(e=>t.has(e)))}isDisjointFrom(t){return this.intersection(t).size==0}isSubsetOf(t){return this.findIndex(e=>!t.has(e))==-1}isSuperset(t){return t.findIndex(e=>!this.has(e))==-1}symmetricDifference(t){return new S([...this.difference(t),...t.difference(this)])}union(t){return new S([...this,...t])}}class Ot{constructor(t,e={}){a(this,"store",{});a(this,"complete",!1);a(this,"values",this.all());if(this.key=t,this.options=e,e.storageKey&&!e.storage&&typeof Storage<"u"&&(e.storage=localStorage),e.storageKey&&e.storage){const n=e.storage.getItem(e.storageKey);if(n)try{Object.assign(this.store,JSON.parse(n))}catch{}}return new Proxy(this,{get:(n,s)=>s in n?n[s]:n.store[s],set:(n,s,i)=>(s in n?n[s]=i:n.store[s]=i,!0)})}getKey(t){if(!this.key)throw new Error("No key defined");return t[this.key]}all(){return Object.values(this.store)}add(t,e=this.ttl){const n=this.getKey(t);return this.set(n,t,e),this}addAll(t,e=!0){return t.forEach(n=>this.add(n)),this.complete=e,this}clear(){this.store={}}delete(t){delete this.store[t],this.options.storageKey&&this.options.storage&&this.options.storage.setItem(this.options.storageKey,JSON.stringify(this.store))}entries(){return Object.entries(this.store)}get(t){return this.store[t]}keys(){return Object.keys(this.store)}map(){return structuredClone(this.store)}set(t,e,n=this.options.ttl){return this.store[t]=e,this.options.storageKey&&this.options.storage&&this.options.storage.setItem(this.options.storageKey,JSON.stringify(this.store)),n&&setTimeout(()=>{this.complete=!1,this.delete(t)},n*1e3),this}}function Rt(r,t=!0){const e=r.reduce((n,s)=>(Object.keys(t?M(s):s).forEach(i=>{n.includes(i)||n.push(i)}),n),[]);return[e.join(","),...r.map(n=>e.map(s=>{const i=O(n,s),o=typeof i;return o=="string"&&i.includes(",")?`"${i}"`:o=="object"?`"${JSON.stringify(i)}"`:i}).join(","))].join(`
|
|
2
|
+
`)}class R extends Promise{constructor(e){super((n,s)=>e(i=>n(i),i=>s(i),i=>this.progress=i));a(this,"listeners",[]);a(this,"_progress",0)}get progress(){return this._progress}set progress(e){e!=this._progress&&(this._progress=e,this.listeners.forEach(n=>n(e)))}static from(e){return e instanceof R?e:new R((n,s)=>e.then((...i)=>n(...i)).catch((...i)=>s(...i)))}from(e){const n=R.from(e);return this.onProgress(s=>n.progress=s),n}onProgress(e){return this.listeners.push(e),this}then(e,n){const s=super.then(e,n);return this.from(s)}catch(e){return this.from(super.catch(e))}finally(e){return this.from(super.finally(e))}}function Ct(r,t){r instanceof Blob||(r=new Blob(B(r)));const e=URL.createObjectURL(r);at(e,t),URL.revokeObjectURL(e)}function at(r,t){const e=document.createElement("a");e.href=r,e.download=t||r.split("/").pop(),document.body.appendChild(e),e.click(),document.body.removeChild(e)}function $t(r={}){return new Promise(t=>{const e=document.createElement("input");e.type="file",e.accept=r.accept||"*",e.style.display="none",e.multiple=!!r.multiple,e.onblur=e.onchange=async()=>{t(Array.from(e.files)),e.remove()},document.body.appendChild(e),e.click()})}function Nt(r,t=new Date){(typeof t=="number"||typeof t=="string")&&(t=new Date(t));const e=`${t.getFullYear()}-${(t.getMonth()+1).toString().padStart(2,"0")}-${t.getDate().toString().padStart(2,"0")}_${t.getHours().toString().padStart(2,"0")}-${t.getMinutes().toString().padStart(2,"0")}-${t.getSeconds().toString().padStart(2,"0")}`;return r?r.replace("{{TIMESTAMP}}",e):e}function Lt(r){return new R((t,e,n)=>{const s=new XMLHttpRequest,i=new FormData;r.files.forEach(o=>i.append("file",o)),s.withCredentials=!!r.withCredentials,s.upload.addEventListener("progress",o=>o.lengthComputable?n(o.loaded/o.total):null),s.addEventListener("loadend",()=>t(T(s.responseText))),s.addEventListener("error",()=>e(T(s.responseText))),s.addEventListener("timeout",()=>e({error:"Request timed out"})),s.open("POST",r.url),Object.entries(r.headers||{}).forEach(([o,l])=>s.setRequestHeader(o,l)),s.send(i)})}class U{constructor(){a(this,"listeners",{})}static emit(t,...e){(this.listeners["*"]||[]).forEach(n=>n(t,...e)),(this.listeners[t.toString()]||[]).forEach(n=>n(...e))}static off(t,e){const n=t.toString();this.listeners[n]=(this.listeners[n]||[]).filter(s=>s===e)}static on(t,e){var s;const n=t.toString();return this.listeners[n]||(this.listeners[n]=[]),(s=this.listeners[n])==null||s.push(e),()=>this.off(t,e)}static once(t,e){return new Promise(n=>{const s=this.on(t,(...i)=>{n(i.length==1?i[0]:i),e&&e(...i),s()})})}emit(t,...e){(this.listeners["*"]||[]).forEach(n=>n(t,...e)),(this.listeners[t]||[]).forEach(n=>n(...e))}off(t,e){this.listeners[t]=(this.listeners[t]||[]).filter(n=>n===e)}on(t,e){var n;return this.listeners[t]||(this.listeners[t]=[]),(n=this.listeners[t])==null||n.push(e),()=>this.off(t,e)}once(t,e){return new Promise(n=>{const s=this.on(t,(...i)=>{n(i.length==1?i[0]:i),e&&e(...i),s()})})}}a(U,"listeners",{});class g extends Error{constructor(e,n){super(e);a(this,"_code");n!=null&&(this._code=n)}get code(){return this._code||this.constructor.code}set code(e){this._code=e}static from(e){const n=Number(e.statusCode)??Number(e.code),s=new this(e.message||e.toString());return Object.assign(s,{stack:e.stack,...e,code:n??void 0})}static instanceof(e){return e.constructor.code!=null}toString(){return this.message||super.toString()}}a(g,"code",500);class q extends g{constructor(t="Bad Request"){super(t)}static instanceof(t){return t.constructor.code==this.code}}a(q,"code",400);class F extends g{constructor(t="Unauthorized"){super(t)}static instanceof(t){return t.constructor.code==this.code}}a(F,"code",401);class G extends g{constructor(t="Payment Required"){super(t)}static instanceof(t){return t.constructor.code==this.code}}a(G,"code",402);class v extends g{constructor(t="Forbidden"){super(t)}static instanceof(t){return t.constructor.code==this.code}}a(v,"code",403);class H extends g{constructor(t="Not Found"){super(t)}static instanceof(t){return t.constructor.code==this.code}}a(H,"code",404);class Y extends g{constructor(t="Method Not Allowed"){super(t)}static instanceof(t){return t.constructor.code==this.code}}a(Y,"code",405);class K extends g{constructor(t="Not Acceptable"){super(t)}static instanceof(t){return t.constructor.code==this.code}}a(K,"code",406);class W extends g{constructor(t="Internal Server Error"){super(t)}static instanceof(t){return t.constructor.code==this.code}}a(W,"code",500);class J extends g{constructor(t="Not Implemented"){super(t)}static instanceof(t){return t.constructor.code==this.code}}a(J,"code",501);class z extends g{constructor(t="Bad Gateway"){super(t)}static instanceof(t){return t.constructor.code==this.code}}a(z,"code",502);class V extends g{constructor(t="Service Unavailable"){super(t)}static instanceof(t){return t.constructor.code==this.code}}a(V,"code",503);class Z extends g{constructor(t="Gateway Timeout"){super(t)}static instanceof(t){return t.constructor.code==this.code}}a(Z,"code",504);function jt(r,t){if(r>=200&&r<300)return null;switch(r){case 400:return new q(t);case 401:return new F(t);case 402:return new G(t);case 403:return new v(t);case 404:return new H(t);case 405:return new Y(t);case 406:return new K(t);case 500:return new W(t);case 501:return new J(t);case 502:return new z(t);case 503:return new V(t);case 504:return new Z(t);default:return new g(t,r)}}const b=class b{constructor(t={}){a(this,"interceptors",{});a(this,"headers",{});a(this,"url");this.url=t.url??null,this.headers=t.headers||{},t.interceptors&&t.interceptors.forEach(e=>b.addInterceptor(e))}static addInterceptor(t){const e=Object.keys(b.interceptors).length.toString();return b.interceptors[e]=t,()=>{b.interceptors[e]=null}}addInterceptor(t){const e=Object.keys(this.interceptors).length.toString();return this.interceptors[e]=t,()=>{this.interceptors[e]=null}}request(t={}){var s;if(!this.url&&!t.url)throw new Error("URL needs to be set");let e=((s=t.url)!=null&&s.startsWith("http")?t.url:(this.url||"")+(t.url||"")).replace(/([^:]\/)\/+/g,"$1");if(t.fragment&&(e.includes("#")?e.replace(/#.*(\?|\n)/g,(i,o)=>`#${t.fragment}${o}`):e+="#"+t.fragment),t.query){const i=Array.isArray(t.query)?t.query:Object.keys(t.query).map(o=>({key:o,value:t.query[o]}));e+=(e.includes("?")?"&":"?")+i.map(o=>`${o.key}=${o.value}`).join("&")}const n=w({"Content-Type":t.body?t.body instanceof FormData?"multipart/form-data":"application/json":void 0,...b.headers,...this.headers,...t.headers});return typeof t.body=="object"&&t.body!=null&&n["Content-Type"]=="application/json"&&(t.body=JSON.stringify(t.body)),new R((i,o,l)=>{try{fetch(e,{headers:n,method:t.method||(t.body?"POST":"GET"),body:t.body}).then(async u=>{var mt,yt;for(let h of[...Object.values(b.interceptors),...Object.values(this.interceptors)])await new Promise(D=>h(u,()=>D()));const I=u.headers.get("Content-Length"),rt=I?parseInt(I,10):0;let ft=0;const nt=(mt=u.body)==null?void 0:mt.getReader(),ie=new ReadableStream({start(h){function D(){nt==null||nt.read().then(j=>{if(j.done)return h.close();ft+=j.value.byteLength,l(ft/rt),h.enqueue(j.value),D()}).catch(j=>h.error(j))}D()}});if(u.data=new Response(ie),t.decode==null||t.decode){const h=(yt=u.headers.get("Content-Type"))==null?void 0:yt.toLowerCase();h!=null&&h.includes("form")?u.data=await u.data.formData():h!=null&&h.includes("json")?u.data=await u.data.json():h!=null&&h.includes("text")?u.data=await u.data.text():h!=null&&h.includes("application")&&(u.data=await u.data.blob())}u.ok?i(u):o(u)}).catch(u=>o(u))}catch(u){o(u)}})}};a(b,"interceptors",{}),a(b,"headers",{});let Q=b;function Tt(r){const t=r.split(".")[1].replace(/-/g,"+").replace(/_/g,"/");return T(decodeURIComponent(atob(t).split("").map(function(e){return"%"+("00"+e.charCodeAt(0).toString(16)).slice(-2)}).join("")))}const N={CLEAR:"\x1B[0m",BRIGHT:"\x1B[1m",DIM:"\x1B[2m",UNDERSCORE:"\x1B[4m",BLINK:"\x1B[5m",REVERSE:"\x1B[7m",HIDDEN:"\x1B[8m"},L={BLACK:"\x1B[30m",RED:"\x1B[31m",GREEN:"\x1B[32m",YELLOW:"\x1B[33m",BLUE:"\x1B[34m",MAGENTA:"\x1B[35m",CYAN:"\x1B[36m",LIGHT_GREY:"\x1B[37m",GREY:"\x1B[90m",LIGHT_RED:"\x1B[91m",LIGHT_GREEN:"\x1B[92m",LIGHT_YELLOW:"\x1B[93m",LIGHT_BLUE:"\x1B[94m",LIGHT_MAGENTA:"\x1B[95m",LIGHT_CYAN:"\x1B[96m",WHITE:"\x1B[97m"},Pt={BLACK:"\x1B[40m",RED:"\x1B[41m",GREEN:"\x1B[42m",YELLOW:"\x1B[43m",BLUE:"\x1B[44m",MAGENTA:"\x1B[45m",CYAN:"\x1B[46m",WHITE:"\x1B[47m",GREY:"\x1B[100m"};var ut=(r=>(r[r.ERROR=0]="ERROR",r[r.WARN=1]="WARN",r[r.INFO=2]="INFO",r[r.LOG=3]="LOG",r[r.DEBUG=4]="DEBUG",r))(ut||{});const E=class E extends U{constructor(t){super(),this.namespace=t}format(...t){const e=new Date;return`${`${e.getFullYear()}-${e.getMonth()+1}-${e.getDate()} ${e.getHours().toString().padStart(2,"0")}:${e.getMinutes().toString().padStart(2,"0")}:${e.getSeconds().toString().padStart(2,"0")}.${e.getMilliseconds().toString().padEnd(3,"0")}`}${this.namespace?` [${this.namespace}]`:""} ${t.map(s=>typeof s=="string"?s:it(s,2)).join(" ")}`}debug(...t){if(E.LOG_LEVEL<4)return;const e=this.format(...t);E.emit(4,e),console.debug(L.LIGHT_GREY+e+N.CLEAR)}log(...t){if(E.LOG_LEVEL<3)return;const e=this.format(...t);E.emit(3,e),console.log(N.CLEAR+e)}info(...t){if(E.LOG_LEVEL<2)return;const e=this.format(...t);E.emit(2,e),console.info(L.BLUE+e+N.CLEAR)}warn(...t){if(E.LOG_LEVEL<1)return;const e=this.format(...t);E.emit(1,e),console.warn(L.YELLOW+e+N.CLEAR)}error(...t){if(E.LOG_LEVEL<0)return;const e=this.format(...t);E.emit(0,e),console.error(L.RED+e+N.CLEAR)}};a(E,"LOG_LEVEL",4);let X=E;function It(r){const t=(l,u)=>u<1e-7?l:t(u,~~(l%u)),e=r.toString().length-2;let n=Math.pow(10,e),s=r*n;const i=t(s,n);s=~~(s/i),n=~~(n/i);const o=~~(s/n);return s-=o*n,`${o?o+" ":""}${~~s}/${~~n}`}function Dt(r){let t=r.split(" ");const e=t.length==2?Number(t[0]):0;return t=t.pop().split("/"),e+Number(t[0])/Number(t[1])}const x="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",_="0123456789",tt="~`!@#$%^&*()_-+={[}]|\\:;\"'<,>.?/",Mt=x+_+tt;function kt(r,t=2){if(r===0)return"0 Bytes";const e=1024,n=["Bytes","KB","MB","GB","TB","PB","EB","ZB","YB"],s=Math.floor(Math.log(r)/Math.log(e));return parseFloat((r/Math.pow(e,s)).toFixed(t))+" "+n[s]}function Ut(r){const t=/(\+?1)?.*?(\d{3}).*?(\d{3}).*?(\d{4})/g.exec(r);if(!t)throw new Error(`Number cannot be parsed: ${r}`);return`${t[1]??""} (${t[2]}) ${t[3]}-${t[4]}`.trim()}function qt(r,t,e){return`${r.slice(0,e)}${t}${r.slice(e+1)}`}function Ft(r,t,e=" ",n=!0){return n?r.toString().padStart(t,e):r.toString().padEnd(t,e)}function Gt(r){return Array(r).fill(null).map(()=>Math.round(Math.random()*15).toString(16)).join("")}function vt(r,t=Mt){return Array(r).fill(null).map(()=>{const e=~~(Math.random()*t.length);return t[e]}).join("")}function Ht(r,t=!1,e=!1,n=!1){if(!t&&!e&&!n)throw new Error("Must enable at least one: letters, numbers, symbols");return Array(r).fill(null).map(()=>{let s;do{const i=~~(Math.random()*3);t&&i==0?s=x[~~(Math.random()*x.length)]:e&&i==1?s=_[~~(Math.random()*_.length)]:n&&i==2&&(s=tt[~~(Math.random()*tt.length)])}while(!s);return s}).join("")}function Yt(r,t){if(typeof t=="string"&&(t=new RegExp(t,"g")),!t.global)throw new TypeError("Regular expression must be global.");let e=[],n;for(;(n=t.exec(r))!==null;)e.push(n);return e}function Kt(r){const t=new RegExp("(?:(?<protocol>[\\w\\d]+)\\:\\/\\/)?(?:(?<user>.+)\\@)?(?<host>(?<domain>[^:\\/\\?#@\\n]+)(?:\\:(?<port>\\d*))?)(?<path>\\/.*?)?(?:\\?(?<query>.*?))?(?:#(?<fragment>.*?))?$","gm").exec(r),e=(t==null?void 0:t.groups)??{},n=e.domain.split(".");if(e.port!=null&&(e.port=Number(e.port)),n.length>2&&(e.domain=n.splice(-2,2).join("."),e.subdomain=n.join(".")),e.query){const s=e.query.split("&"),i={};s.forEach(o=>{const[l,u]=o.split("=");i[l]=u}),e.query=i}return e}function lt(r){var t=Wt(zt(Vt(Jt(r),8*r.length)));return t.toLowerCase()}function Wt(r){for(var t,e="0123456789ABCDEF",n="",s=0;s<r.length;s++)t=r.charCodeAt(s),n+=e.charAt(t>>>4&15)+e.charAt(15&t);return n}function Jt(r){for(var t=Array(r.length>>2),e=0;e<t.length;e++)t[e]=0;for(e=0;e<8*r.length;e+=8)t[e>>5]|=(255&r.charCodeAt(e/8))<<e%32;return t}function zt(r){for(var t="",e=0;e<32*r.length;e+=8)t+=String.fromCharCode(r[e>>5]>>>e%32&255);return t}function Vt(r,t){r[t>>5]|=128<<t%32,r[14+(t+64>>>9<<4)]=t;for(var e=1732584193,n=-271733879,s=-1732584194,i=271733878,o=0;o<r.length;o+=16){var l=e,u=n,I=s,rt=i;n=y(n=y(n=y(n=y(n=m(n=m(n=m(n=m(n=f(n=f(n=f(n=f(n=d(n=d(n=d(n=d(n,s=d(s,i=d(i,e=d(e,n,s,i,r[o+0],7,-680876936),n,s,r[o+1],12,-389564586),e,n,r[o+2],17,606105819),i,e,r[o+3],22,-1044525330),s=d(s,i=d(i,e=d(e,n,s,i,r[o+4],7,-176418897),n,s,r[o+5],12,1200080426),e,n,r[o+6],17,-1473231341),i,e,r[o+7],22,-45705983),s=d(s,i=d(i,e=d(e,n,s,i,r[o+8],7,1770035416),n,s,r[o+9],12,-1958414417),e,n,r[o+10],17,-42063),i,e,r[o+11],22,-1990404162),s=d(s,i=d(i,e=d(e,n,s,i,r[o+12],7,1804603682),n,s,r[o+13],12,-40341101),e,n,r[o+14],17,-1502002290),i,e,r[o+15],22,1236535329),s=f(s,i=f(i,e=f(e,n,s,i,r[o+1],5,-165796510),n,s,r[o+6],9,-1069501632),e,n,r[o+11],14,643717713),i,e,r[o+0],20,-373897302),s=f(s,i=f(i,e=f(e,n,s,i,r[o+5],5,-701558691),n,s,r[o+10],9,38016083),e,n,r[o+15],14,-660478335),i,e,r[o+4],20,-405537848),s=f(s,i=f(i,e=f(e,n,s,i,r[o+9],5,568446438),n,s,r[o+14],9,-1019803690),e,n,r[o+3],14,-187363961),i,e,r[o+8],20,1163531501),s=f(s,i=f(i,e=f(e,n,s,i,r[o+13],5,-1444681467),n,s,r[o+2],9,-51403784),e,n,r[o+7],14,1735328473),i,e,r[o+12],20,-1926607734),s=m(s,i=m(i,e=m(e,n,s,i,r[o+5],4,-378558),n,s,r[o+8],11,-2022574463),e,n,r[o+11],16,1839030562),i,e,r[o+14],23,-35309556),s=m(s,i=m(i,e=m(e,n,s,i,r[o+1],4,-1530992060),n,s,r[o+4],11,1272893353),e,n,r[o+7],16,-155497632),i,e,r[o+10],23,-1094730640),s=m(s,i=m(i,e=m(e,n,s,i,r[o+13],4,681279174),n,s,r[o+0],11,-358537222),e,n,r[o+3],16,-722521979),i,e,r[o+6],23,76029189),s=m(s,i=m(i,e=m(e,n,s,i,r[o+9],4,-640364487),n,s,r[o+12],11,-421815835),e,n,r[o+15],16,530742520),i,e,r[o+2],23,-995338651),s=y(s,i=y(i,e=y(e,n,s,i,r[o+0],6,-198630844),n,s,r[o+7],10,1126891415),e,n,r[o+14],15,-1416354905),i,e,r[o+5],21,-57434055),s=y(s,i=y(i,e=y(e,n,s,i,r[o+12],6,1700485571),n,s,r[o+3],10,-1894986606),e,n,r[o+10],15,-1051523),i,e,r[o+1],21,-2054922799),s=y(s,i=y(i,e=y(e,n,s,i,r[o+8],6,1873313359),n,s,r[o+15],10,-30611744),e,n,r[o+6],15,-1560198380),i,e,r[o+13],21,1309151649),s=y(s,i=y(i,e=y(e,n,s,i,r[o+4],6,-145523070),n,s,r[o+11],10,-1120210379),e,n,r[o+2],15,718787259),i,e,r[o+9],21,-343485551),e=A(e,l),n=A(n,u),s=A(s,I),i=A(i,rt)}return Array(e,n,s,i)}function P(r,t,e,n,s,i){return A(Zt(A(A(t,r),A(n,i)),s),e)}function d(r,t,e,n,s,i,o){return P(t&e|~t&n,r,t,s,i,o)}function f(r,t,e,n,s,i,o){return P(t&n|e&~n,r,t,s,i,o)}function m(r,t,e,n,s,i,o){return P(t^e^n,r,t,s,i,o)}function y(r,t,e,n,s,i,o){return P(e^(t|~n),r,t,s,i,o)}function A(r,t){var e=(65535&r)+(65535&t);return(r>>16)+(t>>16)+(e>>16)<<16|65535&e}function Zt(r,t){return r<<t|r>>>32-t}function Qt(r){return/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/.test(r)}function Xt(r,t="mp"){return r?`https://www.gravatar.com/avatar/${lt(r)}?d=${t}`:""}function xt(r){return r.replace(/[.*+?^${}()|\[\]\\]/g,"\\$&")}function _t(r,...t){const e=[];for(let n=0;n<r.length||n<t.length;n++)r[n]&&e.push(r[n]),t[n]&&e.push(t[n]);return new p(e.join(""))}function ht(r,...t){let e=[];for(let i=0;i<r.length||i<t.length;i++)r[i]&&e.push(r[i]),t[i]&&e.push(t[i]);const[n,s]=e.join("").split(":");return p.toString(n,s==null?void 0:s.split(""))}class et extends Error{}class p{constructor(t){a(this,"module");a(this,"fullPath");a(this,"path");a(this,"name");a(this,"methods");var o;if(typeof t=="object")return Object.assign(this,t);let[e,n,s]=t.split(":");s||(s=n||"*"),(e=="*"||!e&&s=="*")&&(e="",s="*");let i=e.split("/").filter(l=>!!l);this.module=((o=i.splice(0,1)[0])==null?void 0:o.toLowerCase())||"",this.fullPath=e,this.path=i.join("/"),this.name=i.pop()||"",this.methods=new S(s.split(""))}get all(){return this.methods.has("*")}set all(t){t?new S(["*"]):this.methods.delete("*")}get none(){return this.methods.has("n")}set none(t){t?this.methods=new S(["n"]):this.methods.delete("n")}get create(){return!this.methods.has("n")&&(this.methods.has("*")||this.methods.has("c"))}set create(t){t?this.methods.delete("n").add("c"):this.methods.delete("c")}get read(){return!this.methods.has("n")&&(this.methods.has("*")||this.methods.has("r"))}set read(t){t?this.methods.delete("n").add("r"):this.methods.delete("r")}get update(){return!this.methods.has("n")&&(this.methods.has("*")||this.methods.has("u"))}set update(t){t?this.methods.delete("n").add("u"):this.methods.delete("u")}get delete(){return!this.methods.has("n")&&(this.methods.has("*")||this.methods.has("d"))}set delete(t){t?this.methods.delete("n").add("d"):this.methods.delete("d")}static combine(...t){let e=!1;const n=t.map(s=>new p(s)).toSorted((s,i)=>{const o=s.fullPath.length,l=i.fullPath.length;return o<l?1:o>l?-1:0}).reduce((s,i)=>(i.none&&(e=!0),s?(e||(i.all&&(s.all=!0),(i.all||i.create)&&(s.create=!0),(i.all||i.read)&&(s.read=!0),(i.all||i.update)&&(s.update=!0),(i.all||i.delete)&&(s.delete=!0),s.methods=[...s.methods,...i.methods]),s):i),null);return n.methods=new S(n.methods),n.raw=ht`${n.fullPath}:${n.methods}`,n}static has(t,...e){const n=B(e).map(i=>new p(i)),s=B(t).map(i=>new p(i));return!!n.find(i=>{if(!i.fullPath&&i.all)return!0;const o=s.filter(u=>i.fullPath.startsWith(u.fullPath));if(!o.length)return!1;const l=p.combine(...o);return!l.none&&(l.all||new S(l.methods).intersection(new S(i.methods)).length)})}static hasAll(t,...e){return e.filter(n=>p.has(t,n)).length==e.length}static hasFatal(t,...e){if(!p.has(t,...e))throw new et(`Requires one of: ${B(e).join(", ")}`)}static hasAllFatal(t,...e){if(!p.hasAll(t,...e))throw new et(`Requires all: ${B(e).join(", ")}`)}static toString(t,e){let n=B(t).filter(s=>s!=null).join("/");return n=n==null?void 0:n.trim().replaceAll(/\/{2,}/g,"/").replaceAll(/(^\/|\/$)/g,""),e!=null&&e.length&&(n+=`:${B(e).map(s=>s.toLowerCase()).join("")}`),n}toString(){return p.toString(this.fullPath,this.methods)}}class te{constructor(){a(this,"listeners",[])}emit(t,...e){const n=new p(t);this.listeners.filter(s=>p.has(s[0],t)).forEach(async s=>s[1](n,...e))}off(t){this.listeners=this.listeners.filter(e=>e[1]!=t)}on(t,e){return B(t).forEach(n=>this.listeners.push([new p(n),e])),()=>this.off(e)}once(t,e){return new Promise(n=>{const s=this.on(t,(i,...o)=>{n(o.length<2?o[0]:o),e&&e(i,...o),s()})})}relayEvents(t){t.on("*",(e,...n)=>this.emit(e,...n))}}function ee(r){(typeof r=="number"||typeof r=="string")&&(r=new Date(r));let t=r.getHours(),e="AM";return t>=12?(t>12&&(t-=12),e="PM"):t==0&&(t=12),`${r.getFullYear()}-${(r.getMonth()+1).toString().padStart(2,"0")}-${r.getDate().toString().padStart(2,"0")}, ${t}:${r.getMinutes().toString().padStart(2,"0")} ${e}`}function dt(r){return new Promise(t=>setTimeout(t,r))}async function re(r,t=100){for(;await r();)await dt(t)}function ne(r){return(r instanceof Date?r.getTime():r)-new Date().getTime()}function se(){return Object.keys({})}c.ASet=S,c.BadGatewayError=z,c.BadRequestError=q,c.Cache=Ot,c.CliBackground=Pt,c.CliEffects=N,c.CliForeground=L,c.CustomError=g,c.ForbiddenError=v,c.GatewayTimeoutError=Z,c.Http=Q,c.InternalServerError=W,c.JSONAttemptParse=T,c.JSONSanitize=it,c.LOG_LEVEL=ut,c.Logger=X,c.MethodNotAllowedError=Y,c.NotAcceptableError=K,c.NotFoundError=H,c.NotImplementedError=J,c.PE=_t,c.PES=ht,c.PathError=et,c.PathEvent=p,c.PathEventEmitter=te,c.PaymentRequiredError=G,c.PromiseProgress=R,c.ServiceUnavailableError=V,c.TypedEmitter=U,c.UnauthorizedError=F,c.addUnique=Et,c.arrayDiff=St,c.caseInsensitiveSort=bt,c.clean=w,c.csv=Rt,c.dec2Frac=It,c.deepCopy=C,c.deepMerge=st,c.dotNotation=O,c.downloadFile=Ct,c.downloadUrl=at,c.encodeQuery=gt,c.errorFromCode=jt,c.escapeRegex=xt,c.fileBrowser=$t,c.findByProp=Bt,c.flattenArr=ot,c.flattenObj=M,c.formData=pt,c.formatBytes=kt,c.formatDate=ee,c.formatPhoneNumber=Ut,c.fracToDec=Dt,c.gravatar=Xt,c.includes=k,c.insertAt=qt,c.isEqual=$,c.jwtDecode=Tt,c.makeArray=B,c.makeUnique=ct,c.matchAll=Yt,c.md5=lt,c.mixin=wt,c.pad=Ft,c.parseUrl=Kt,c.randomHex=Gt,c.randomString=vt,c.randomStringBuilder=Ht,c.sleep=dt,c.sleepWhile=re,c.sortByProp=At,c.timeUntil=ne,c.timestampFilename=Nt,c.tyoeKeys=se,c.uploadWithProgress=Lt,c.validateEmail=Qt,Object.defineProperty(c,Symbol.toStringTag,{value:"Module"})});
|
|
3
3
|
//# sourceMappingURL=index.cjs.map
|