@zuzjs/core 0.3.12 → 0.3.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1,2 +1,2 @@
1
1
  'use strict';var E=require('axios'),J=require('fs/promises'),K=require('hashids'),T=require('js-cookie'),Q=require('md5'),g=require('moment'),nanoid=require('nanoid'),W=require('ip-regex');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var E__default=/*#__PURE__*/_interopDefault(E);var J__default=/*#__PURE__*/_interopDefault(J);var K__default=/*#__PURE__*/_interopDefault(K);var T__default=/*#__PURE__*/_interopDefault(T);var Q__default=/*#__PURE__*/_interopDefault(Q);var g__default=/*#__PURE__*/_interopDefault(g);var W__default=/*#__PURE__*/_interopDefault(W);/* ZuzJS Core */
2
- var F=["aliceblue","antiquewhite","aqua","aquamarine","azure","beige","bisque","black","blanchedalmond","blue","blueviolet","brown","burlywood","cadetblue","chartreuse","chocolate","coral","cornflowerblue","cornsilk","crimson","cyan","darkblue","darkcyan","darkgoldenrod","darkgray","darkgreen","darkgrey","darkkhaki","darkmagenta","darkolivegreen","darkorange","darkorchid","darkred","darksalmon","darkseagreen","darkslateblue","darkslategray","darkslategrey","darkturquoise","darkviolet","deeppink","deepskyblue","dimgray","dimgrey","dodgerblue","firebrick","floralwhite","forestgreen","fuchsia","gainsboro","ghostwhite","gold","goldenrod","gray","green","greenyellow","grey","honeydew","hotpink","indianred","indigo","ivory","khaki","lavender","lavenderblush","lawngreen","lemonchiffon","lightblue","lightcoral","lightcyan","lightgoldenrodyellow","lightgray","lightgreen","lightgrey","lightpink","lightsalmon","lightseagreen","lightskyblue","lightslategray","lightslategrey","lightsteelblue","lightyellow","lime","limegreen","linen","magenta","maroon","mediumaquamarine","mediumblue","mediumorchid","mediumpurple","mediumseagreen","mediumslateblue","mediumspringgreen","mediumturquoise","mediumvioletred","midnightblue","mintcream","mistyrose","moccasin","navajowhite","navy","oldlace","olive","olivedrab","orange","orangered","orchid","palegoldenrod","palegreen","paleturquoise","palevioletred","papayawhip","peachpuff","peru","pink","plum","powderblue","purple","rebeccapurple","red","rosybrown","royalblue","saddlebrown","salmon","sandybrown","seagreen","seashell","sienna","silver","skyblue","slateblue","slategray","slategrey","snow","springgreen","steelblue","tan","teal","thistle","tomato","turquoise","violet","wheat","white","whitesmoke","yellow","yellowgreen"];var B=/^[0-9a-fA-F]{3}$|^[0-9a-fA-F]{6}$/,U=/^rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*((0|1|0?\.\d+)\s*))?\)$/,I=/^hsl\(\s*(\d{1,3})\s*,\s*(\d{1,3})%\s*,\s*(\d{1,3})%\s*\)$/;var V=(r=>(r.Asc="ASC",r.Desc="DESC",r))(V||{});var P=class{_;constructor(t){this._=t;}isIP(){return this.isIPv4()||this.isIPv6()}isIPv4(){return W__default.default.v4({exact:true}).test(this._)}isIPv6(){return W__default.default.v6({exact:true}).test(this._)}isTypeof(t){return typeof this._==typeof t}isFunction(){return typeof this._=="function"}isArray(){return Array.isArray(this._)}isNull(){return this._===null}isString(){return typeof this._=="string"}isNumber(){return /^[+-]?\d+(\.\d+)?$/.test(this._)}isObject(){return typeof this._=="object"&&!Array.isArray(this._)&&this._!==null}isEmpty(){return Array.isArray(this._)?this._.length===0:typeof this._=="object"&&this._!==null?Object.keys(this._).length===0:this._===""||String(this._).length===0}isEmail(){return typeof this._=="string"&&/^[^\s@]+@[^\s@]+\.[^\s@]{2,}$/.test(this._)}isUrl(){return typeof this._=="string"&&/^(https?:\/\/)?(www\.)?([a-zA-Z0-9-]+\.)+[a-zA-Z]{2,}(\/[^\s]*)?$/.test(this._)}toLowerCase(){return this._=typeof this._=="string"?this._.toLowerCase():String(this._).toLowerCase(),this}equals(t){let r=this._,n=t,s=(o,l)=>{if(o===l)return true;if(o===null||typeof o!="object"||l===null||typeof l!="object")return false;if(Array.isArray(o)&&Array.isArray(l)){if(o.length!==l.length)return false;for(let a=0;a<o.length;a++)if(!s(o[a],l[a]))return false;return true}if(this.isObjectValue(o)&&this.isObjectValue(l)){let a=Object.keys(o),c=Object.keys(l);if(a.length!==c.length)return false;for(let h of a)if(!c.includes(h)||!s(o[h],l[h]))return false;return true}return false},i=o=>typeof o=="object"&&o!==null&&!Array.isArray(o);return this.isObjectValue=i,Array.isArray(r)&&Array.isArray(n)||i(r)&&i(n)?s(r,n):r===n}isObjectValue(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}ucfirst(){return this._=typeof this._=="string"?this._.charAt(0).toUpperCase()+this._.slice(1):this._,this}formatString(t,...r){typeof this._!="string"&&(this._="");let n=[t,...r];return this._=this._.replace(/%(\d+)/g,(s,i)=>n[Number(i)]?.toString()||`%${i}`),this}camelCase(){return this._=typeof this._=="string"?this._.split(/[^a-zA-Z0-9]+/).map((t,r)=>r===0?t:t.charAt(0).toUpperCase()+t.slice(1)).join(""):this._,this}sort(t="asc"){if(!this.isObject())return console.warn("sortKeys can only be applied to objects. Current value is not an object."),this;let r=this._,n=Object.keys(r).sort((i,o)=>t==="desc"?o.localeCompare(i):i.localeCompare(o)),s={};for(let i of n)s[i]=r[i];return this._=s,this}value(){return this._}valueOf(){return this._}toString(){return String(this._)}[Symbol.toPrimitive](t){return t==="number"?Number(this._):t==="boolean"?!!this._:String(this._)}},Y=e=>new P(e),N=Y;var S=class{_events;constructor(){this._events=[];}on(t,r,n){let s=this._events.find(l=>l.event===t),i=Symbol("listener_id"),o={fun:r,context:n,id:i};return s?s.listeners.push(o):this._events.push({event:t,listeners:[o]}),()=>{let l=this._events.find(a=>a.event===t);l&&(l.listeners=l.listeners.filter(a=>a.id!==i),l.listeners.length===0&&(this._events=this._events.filter(a=>a.event!==t)));}}off(t,r){let n=this._events.find(s=>s.event===t);n&&(n.listeners=n.listeners.filter(s=>s.fun!==r),n.listeners.length===0&&(this._events=this._events.filter(s=>s.event!==t)));}emit(t,...r){let n=this._events.find(s=>s.event===t);n&&[...n.listeners].forEach(({fun:s,context:i})=>{try{s.apply(i,r);}catch(o){console.error(`Error during event '${String(t)}' emission:`,o);}});}removeAllListeners(t){this._events=this._events.filter(r=>r.event!==t);}},G=S;var Z="zuzjs-core",ee=(e,t)=>Math.floor(Math.random()*(t-e+1))+e,te=(e,t=6,r=null)=>new K__default.default(r||Z,t).encode(e),De=(e,t=null)=>{try{let r=new K__default.default(t||Z,+process.env.HASHIDS_LENGTH).decode(e);return r.length>=0?Number(r[0]):0}catch{return 0}},He=e=>Q__default.default(e),qe=e=>te(ee(11111111111,999999999999)),ze=e=>nanoid.nanoid(e),O=e=>`${e.charAt(0).toUpperCase()}${e.substring(1,e.length)}`,Me=e=>decodeURIComponent(e.replace(/\+/g,"%20")),Le=e=>encodeURIComponent(e),Fe=(e,t)=>`${e}${t!==1?"s":""}`,re=e=>B.test(e),ne=e=>U.test(e),se=e=>I.test(e),Be=e=>F.includes(e.toLowerCase()),Ue=e=>re(e)||ne(e)||se(e),Ie=(e,t=1)=>{e=e.replace(/^#/,""),e.length===3&&(e=e.split("").map(o=>o+o).join(""));let r=parseInt(e,16),n=r>>16&255,s=r>>8&255,i=r&255;return `rgba(${n}, ${s}, ${i}, ${t})`},oe=e=>e.reduce((t,r)=>(t.includes(r)||t.push(r),t),[]),We=e=>{if(!e.trim())return "";let t=e.split(/\s+/).filter(Boolean);return oe(t).join(" ")},Oe=()=>E__default.default.CancelToken.source(),Ke=e=>E__default.default.defaults.withCredentials=e,ie=e=>{let r=typeof navigator<"u"?navigator.onLine:true;return {error:e?.code??"ERR_NETWORK",message:r?"Unable to connect to the server. It may be temporarily down.":"Network error: Unable to connect. Please check your internet connection and try again."}},A=(e=60,t=false,r={},n)=>typeof e=="object"&&e!==null?{timeout:e.timeout??60,ignoreKind:e.ignoreKind??false,headers:e.headers??{},onProgress:e.onProgress,withCredentials:e.withCredentials,returnRawResponse:e.returnRawResponse,appendCookiesToBody:e.appendCookiesToBody??true,appendTimestamp:e.appendTimestamp??true}:{timeout:e,ignoreKind:t,headers:r,onProgress:n,appendCookiesToBody:true,appendTimestamp:true},$=(e,t)=>{let r=T__default.default.get(),n=e,s="application/json";if(e instanceof FormData){if(s="multipart/form-data",t.appendCookiesToBody)for(let[i,o]of Object.entries(r))e.append(i,o);}else if(typeof e=="object"&&!Array.isArray(e)&&e!==null)n={...e,...t.appendCookiesToBody?r:{},...t.appendTimestamp?{__stmp:Date.now()/1e3}:{}};else if(!N(e).isString())throw new Error("Unsupported data type for withPost/withPut/withPatch");return {finalData:n,contentType:s}},ae=(e,t)=>{if(t.returnRawResponse)return e;if(e.data&&(t.ignoreKind||"kind"in e.data))return e.data;throw e.data},C=async(e,t)=>{try{let r=await E__default.default(e);return ae(r,t)}catch(r){throw r?.response?.data?r.response.data:r?.code==="ERR_NETWORK"?ie(r):r}},Ze=async(e,t,r=60,n=false,s={},i)=>{let o=A(r,n,s,i),{finalData:l,contentType:a}=$(t,o);return C({method:"post",url:e,data:l,timeout:o.timeout*1e3,withCredentials:o.withCredentials,headers:{"Content-Type":a,...o.headers??{}},onUploadProgress:o.onProgress},o)},Ve=async(e,t=60,r=false,n={})=>{let s=A(t,r,n);return C({method:"get",url:e,timeout:s.timeout*1e3,withCredentials:s.withCredentials,headers:s.headers},s)},Ye=async(e,t,r=60,n=false,s={},i)=>{let o=A(r,n,s,i),{finalData:l,contentType:a}=$(t,o);return C({method:"put",url:e,data:l,timeout:o.timeout*1e3,withCredentials:o.withCredentials,headers:{"Content-Type":a,...o.headers??{}},onUploadProgress:o.onProgress},o)},Ge=async(e,t,r=60,n=false,s={},i)=>{let o=A(r,n,s,i),{finalData:l,contentType:a}=$(t,o);return C({method:"patch",url:e,data:l,timeout:o.timeout*1e3,withCredentials:o.withCredentials,headers:{"Content-Type":a,...o.headers??{}},onUploadProgress:o.onProgress},o)},Je=e=>{let t=new Date().getTime(),r=e(),n=new Date().getTime();return {result:r,executionTime:n-t}},Qe=(e,t)=>{let r=t||"YYYY-MM-DD HH:mm:ss";if(!e)return g__default.default().format(r);if(e instanceof Date)return g__default.default(e).format(r);if(typeof e=="string"&&isNaN(Number(e)))return g__default.default(e).format(r);let n=Number(e);return n>9999999999?g__default.default(n).format(r):g__default.default.unix(n).format(r)},Xe=e=>{if(e instanceof Date)return g__default.default(e).fromNow();if(typeof e=="string"&&isNaN(Number(e)))return g__default.default(e).fromNow();let t=Number(e);return t>9999999999?g__default.default(t).fromNow():g__default.default.unix(t).fromNow()},et=e=>e[Math.floor(Math.random()*e.length)],tt=({number:e,locale:t="en-US",style:r="decimal",decimal:n=2,forceDecimal:s=false,currency:i})=>{if(r==="currency"&&!i)throw new TypeError("Currency code is required with currency style.");if(i){let{code:o,style:l,symbol:a}=i,c=new Intl.NumberFormat(t,{style:"currency",currency:o,currencyDisplay:l,minimumFractionDigits:s||+e%1>0?n:0,maximumFractionDigits:s||+e%1>0?n:0}).format(+e);return a?c.replace(new RegExp(`\\${o}`,"g"),a):c}return new Intl.NumberFormat(t,{style:r,minimumFractionDigits:s?n:+e%1>0?2:0,maximumFractionDigits:s?n:+e%1>0?2:0}).format(+e)},rt=e=>{let t=["Bytes","KB","MB","GB","TB"],r=typeof e=="string"?parseFloat(e):e;if(r==0)return "0 Byte";let n=Math.floor(Math.log(r)/Math.log(1024)),s=typeof n=="string"?parseInt(n):n;return (r/Math.pow(1024,s)).toFixed(2)+" "+t[s]},nt=e=>navigator.clipboard&&navigator.clipboard.writeText?navigator.clipboard.writeText(e):new Promise((t,r)=>{let n=document.createElement("textarea");n.value=e,n.style.position="fixed",document.body.appendChild(n),n.focus(),n.select();try{document.execCommand("copy"),t("Copied to clipboard");}catch(s){r(s);}document.body.removeChild(n);}),st=(e={direction:"ASC",caseSensitive:false})=>{let t=/^0/,r=/\s+/g,n=/^\s+|\s+$/g,s=/[^\x00-\x80]/,i=/^0x[0-9a-f]+$/i,o=/(0x[\da-fA-F]+|(^[\+\-]?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?(?=\D|\s|$))|\d+)/g,l=/(^([\w ]+,?[\w ]+)?[\w ]+,?[\w ]+\d+:\d+(:\d+)?[\w ]?|^\d{1,4}[\/\-]\d{1,4}[\/\-]\d{1,4}|^\w+, \w+ \d+, \d{4})/,a=e.direction=="DESC"?-1:1,c=-a,h=e.caseSensitive?u=>`${u}`.replace(n,""):u=>u.toString().toLowerCase().replace(n,""),j=u=>u.replace(o,"\0$1\0").replace(/\0$/,"").replace(/^\0/,"").split("\0"),D=(u,_)=>(!u.match(t)||_===1)&&parseFloat(u)||u.replace(r," ").replace(n,"")||0;return function(u,_){let f=h(u),d=h(_);if(!f&&!d)return 0;if(!f&&d)return c;if(f&&!d)return a;let v=j(f),H=j(d),k=f.match(i),R=d.match(i),y=k&&R?parseInt(k[0],16):v.length!==1&&Date.parse(f),b=k&&R?parseInt(R[0],16):y&&d.match(l)&&Date.parse(d)||null;if(b){if(y===b)return 0;if(typeof y=="number"&&typeof b=="number"&&y<b)return c;if(typeof y=="number"&&y>b)return a}let q=v.length,z=H.length;for(let x=0,M=Math.max(q,z);x<M;x+=1){let p=D(v[x]||"",q),m=D(H[x]||"",z);if(isNaN(p)!==isNaN(m))return isNaN(p)?a:c;if(s.test(p+m)&&p.localeCompare){let L=p.localeCompare(m);if(L>0)return a;if(L<0)return c;if(x===M-1)return 0}if(p<m)return c;if(p>m)return a;if(`${p}`<`${m}`)return c;if(`${p}`>`${m}`)return a}return 0}},ot=(e,t=false)=>e.toLowerCase().split(/[^a-zA-Z0-9]+/).map((r,n)=>n===0?t?O(r):r:O(r)).join(""),it=e=>e.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase(),at=(e,t,r)=>Math.min(Math.max(e,t),r),lt=(e,t="-")=>e==null?(console.log(e,"is undefined"),""):e.normalize("NFKD").replace(/[\u0300-\u036f]/g,"").toLowerCase().replace(/[^a-z0-9\p{L}\p{N}]+/gu,t).replace(new RegExp(`\\${t}{2,}`,"g"),t).replace(new RegExp(`^\\${t}|\\${t}$`,"g"),""),ct=e=>new Promise(t=>setTimeout(t,e)),ut=(e,t)=>setTimeout(e,t||1e3),pt=e=>Object.keys(e).filter(t=>isNaN(Number(t))),gt=async e=>{try{return await J__default.default.access(e),!0}catch{return false}},dt=e=>{let t="=".repeat((4-e.length%4)%4),r=(e+t).replace(/-/g,"+").replace(/_/g,"/"),n=window.atob(r),s=new Uint8Array(n.length);for(let i=0;i<n.length;++i)s[i]=n.charCodeAt(i);return s},mt=e=>{let t=[],r=0;return e.length>=8?r++:t.push("Use at least 8 characters"),/[a-z]/.test(e)?r++:t.push("Add lowercase letters"),/[A-Z]/.test(e)?r++:t.push("Add uppercase letters"),/\d/.test(e)?r++:t.push("Include numbers"),/[^A-Za-z0-9]/.test(e)?r++:t.push("Add special characters (e.g. !, @, #)"),{score:r,result:r<=2?"Weak":r==3?"Moderate":r==4?"Strong":"Excellent",suggestion:t}},le=e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),ht=(e,t)=>{if(t.length===0)return e.trim();let r=t.map(s=>s.trim()).filter(Boolean).map(le);if(r.length===0)return e.trim();let n=new RegExp(`\\b(${r.join("|")})\\b`,"gi");return e.replace(n,"").replace(/\s+/g," ").trim()},ft=(e,t=false)=>{let r=T__default.default.get(e);return r?t?JSON.parse(r):r:null},yt=e=>T__default.default.remove(e),bt=({key:e,value:t,json:r=false,path:n="/",expires:s,domain:i,secure:o,sameSite:l})=>{T__default.default.set(e,r?JSON.stringify(t):t,{expires:s,path:n,domain:i,secure:o,sameSite:l});};exports.MD5=He;exports.PubSub=G;exports.SORT=V;exports._=N;exports.__SALT=Z;exports.arrayRand=et;exports.camelCase=ot;exports.camelCaseToDash=it;exports.checkPasswordStrength=mt;exports.clamp=at;exports.copyToClipboard=nt;exports.enumToKeys=pt;exports.escapeRegex=le;exports.exists=gt;exports.formatNumber=tt;exports.formatSize=rt;exports.fromHash=De;exports.getCancelToken=Oe;exports.getCookie=ft;exports.hexToRgba=Ie;exports.isColor=Ue;exports.isColorName=Be;exports.isHexColor=re;exports.isHslColor=se;exports.isRgbaColor=ne;exports.natsort=st;exports.numberInRange=ee;exports.pluralize=Fe;exports.removeCookie=yt;exports.removeDuplicateWords=We;exports.removeDuplicates=oe;exports.removeWords=ht;exports.setCookie=bt;exports.sleep=ct;exports.slugify=lt;exports.time=Qe;exports.timeSince=Xe;exports.toHash=te;exports.ucfirst=O;exports.urlBase64ToUint8Array=dt;exports.urldecode=Me;exports.urlencode=Le;exports.uuid=qe;exports.uuid2=ze;exports.withCredentials=Ke;exports.withDelay=ut;exports.withGet=Ve;exports.withPatch=Ge;exports.withPost=Ze;exports.withPut=Ye;exports.withTime=Je;
2
+ var F=["aliceblue","antiquewhite","aqua","aquamarine","azure","beige","bisque","black","blanchedalmond","blue","blueviolet","brown","burlywood","cadetblue","chartreuse","chocolate","coral","cornflowerblue","cornsilk","crimson","cyan","darkblue","darkcyan","darkgoldenrod","darkgray","darkgreen","darkgrey","darkkhaki","darkmagenta","darkolivegreen","darkorange","darkorchid","darkred","darksalmon","darkseagreen","darkslateblue","darkslategray","darkslategrey","darkturquoise","darkviolet","deeppink","deepskyblue","dimgray","dimgrey","dodgerblue","firebrick","floralwhite","forestgreen","fuchsia","gainsboro","ghostwhite","gold","goldenrod","gray","green","greenyellow","grey","honeydew","hotpink","indianred","indigo","ivory","khaki","lavender","lavenderblush","lawngreen","lemonchiffon","lightblue","lightcoral","lightcyan","lightgoldenrodyellow","lightgray","lightgreen","lightgrey","lightpink","lightsalmon","lightseagreen","lightskyblue","lightslategray","lightslategrey","lightsteelblue","lightyellow","lime","limegreen","linen","magenta","maroon","mediumaquamarine","mediumblue","mediumorchid","mediumpurple","mediumseagreen","mediumslateblue","mediumspringgreen","mediumturquoise","mediumvioletred","midnightblue","mintcream","mistyrose","moccasin","navajowhite","navy","oldlace","olive","olivedrab","orange","orangered","orchid","palegoldenrod","palegreen","paleturquoise","palevioletred","papayawhip","peachpuff","peru","pink","plum","powderblue","purple","rebeccapurple","red","rosybrown","royalblue","saddlebrown","salmon","sandybrown","seagreen","seashell","sienna","silver","skyblue","slateblue","slategray","slategrey","snow","springgreen","steelblue","tan","teal","thistle","tomato","turquoise","violet","wheat","white","whitesmoke","yellow","yellowgreen"];var U=/^[0-9a-fA-F]{3}$|^[0-9a-fA-F]{6}$/,B=/^rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*((0|1|0?\.\d+)\s*))?\)$/,I=/^hsl\(\s*(\d{1,3})\s*,\s*(\d{1,3})%\s*,\s*(\d{1,3})%\s*\)$/;var V=(r=>(r.Asc="ASC",r.Desc="DESC",r))(V||{});var P=class{_;constructor(t){this._=t;}isIP(){return this.isIPv4()||this.isIPv6()}isIPv4(){return W__default.default.v4({exact:true}).test(this._)}isIPv6(){return W__default.default.v6({exact:true}).test(this._)}isTypeof(t){return typeof this._==typeof t}isFunction(){return typeof this._=="function"}isArray(){return Array.isArray(this._)}isNull(){return this._===null}isString(){return typeof this._=="string"}isNumber(){return /^[+-]?\d+(\.\d+)?$/.test(this._)}isObject(){return typeof this._=="object"&&!Array.isArray(this._)&&this._!==null}isEmpty(){return Array.isArray(this._)?this._.length===0:typeof this._=="object"&&this._!==null?Object.keys(this._).length===0:this._===""||String(this._).length===0}isEmail(){return typeof this._=="string"&&/^[^\s@]+@[^\s@]+\.[^\s@]{2,}$/.test(decodeURIComponent(this._))}isUrl(){return typeof this._=="string"&&/^(https?:\/\/)?(www\.)?([a-zA-Z0-9-]+\.)+[a-zA-Z]{2,}(\/[^\s]*)?$/.test(this._)}toLowerCase(){return this._=typeof this._=="string"?this._.toLowerCase():String(this._).toLowerCase(),this}equals(t){let r=this._,n=t,s=(o,l)=>{if(o===l)return true;if(o===null||typeof o!="object"||l===null||typeof l!="object")return false;if(Array.isArray(o)&&Array.isArray(l)){if(o.length!==l.length)return false;for(let a=0;a<o.length;a++)if(!s(o[a],l[a]))return false;return true}if(this.isObjectValue(o)&&this.isObjectValue(l)){let a=Object.keys(o),c=Object.keys(l);if(a.length!==c.length)return false;for(let h of a)if(!c.includes(h)||!s(o[h],l[h]))return false;return true}return false},i=o=>typeof o=="object"&&o!==null&&!Array.isArray(o);return this.isObjectValue=i,Array.isArray(r)&&Array.isArray(n)||i(r)&&i(n)?s(r,n):r===n}isObjectValue(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}ucfirst(){return this._=typeof this._=="string"?this._.charAt(0).toUpperCase()+this._.slice(1):this._,this}formatString(t,...r){typeof this._!="string"&&(this._="");let n=[t,...r];return this._=this._.replace(/%(\d+)/g,(s,i)=>n[Number(i)]?.toString()||`%${i}`),this}camelCase(){return this._=typeof this._=="string"?this._.split(/[^a-zA-Z0-9]+/).map((t,r)=>r===0?t:t.charAt(0).toUpperCase()+t.slice(1)).join(""):this._,this}sort(t="asc"){if(!this.isObject())return console.warn("sortKeys can only be applied to objects. Current value is not an object."),this;let r=this._,n=Object.keys(r).sort((i,o)=>t==="desc"?o.localeCompare(i):i.localeCompare(o)),s={};for(let i of n)s[i]=r[i];return this._=s,this}value(){return this._}valueOf(){return this._}toString(){return String(this._)}[Symbol.toPrimitive](t){return t==="number"?Number(this._):t==="boolean"?!!this._:String(this._)}},Y=e=>new P(e),N=Y;var S=class{_events;constructor(){this._events=[];}on(t,r,n){let s=this._events.find(l=>l.event===t),i=Symbol("listener_id"),o={fun:r,context:n,id:i};return s?s.listeners.push(o):this._events.push({event:t,listeners:[o]}),()=>{let l=this._events.find(a=>a.event===t);l&&(l.listeners=l.listeners.filter(a=>a.id!==i),l.listeners.length===0&&(this._events=this._events.filter(a=>a.event!==t)));}}off(t,r){let n=this._events.find(s=>s.event===t);n&&(n.listeners=n.listeners.filter(s=>s.fun!==r),n.listeners.length===0&&(this._events=this._events.filter(s=>s.event!==t)));}emit(t,...r){let n=this._events.find(s=>s.event===t);n&&[...n.listeners].forEach(({fun:s,context:i})=>{try{s.apply(i,r);}catch(o){console.error(`Error during event '${String(t)}' emission:`,o);}});}removeAllListeners(t){this._events=this._events.filter(r=>r.event!==t);}},G=S;var Z="zuzjs-core",ee=(e,t)=>Math.floor(Math.random()*(t-e+1))+e,te=(e,t=6,r=null)=>new K__default.default(r||Z,t).encode(e),De=(e,t=null)=>{try{let r=new K__default.default(t||Z,+process.env.HASHIDS_LENGTH).decode(e);return r.length>=0?Number(r[0]):0}catch{return 0}},He=e=>Q__default.default(e),qe=e=>te(ee(11111111111,999999999999)),ze=e=>nanoid.nanoid(e),O=e=>`${e.charAt(0).toUpperCase()}${e.substring(1,e.length)}`,Me=e=>decodeURIComponent(e.replace(/\+/g,"%20")),Le=e=>encodeURIComponent(e),Fe=(e,t)=>`${e}${t!==1?"s":""}`,re=e=>U.test(e),ne=e=>B.test(e),se=e=>I.test(e),Ue=e=>F.includes(e.toLowerCase()),Be=e=>re(e)||ne(e)||se(e),Ie=(e,t=1)=>{e=e.replace(/^#/,""),e.length===3&&(e=e.split("").map(o=>o+o).join(""));let r=parseInt(e,16),n=r>>16&255,s=r>>8&255,i=r&255;return `rgba(${n}, ${s}, ${i}, ${t})`},oe=e=>e.reduce((t,r)=>(t.includes(r)||t.push(r),t),[]),We=e=>{if(!e.trim())return "";let t=e.split(/\s+/).filter(Boolean);return oe(t).join(" ")},Oe=()=>E__default.default.CancelToken.source(),Ke=e=>E__default.default.defaults.withCredentials=e,ie=e=>{let r=typeof navigator<"u"?navigator.onLine:true;return {error:e?.code??"ERR_NETWORK",message:r?"Unable to connect to the server. It may be temporarily down.":"Network error: Unable to connect. Please check your internet connection and try again."}},A=(e=60,t=false,r={},n)=>typeof e=="object"&&e!==null?{timeout:e.timeout??60,ignoreKind:e.ignoreKind??false,headers:e.headers??{},onProgress:e.onProgress,withCredentials:e.withCredentials,returnRawResponse:e.returnRawResponse,appendCookiesToBody:e.appendCookiesToBody??true,appendTimestamp:e.appendTimestamp??true}:{timeout:e,ignoreKind:t,headers:r,onProgress:n,appendCookiesToBody:true,appendTimestamp:true},$=(e,t)=>{let r=T__default.default.get(),n=e,s="application/json";if(e instanceof FormData){if(s="multipart/form-data",t.appendCookiesToBody)for(let[i,o]of Object.entries(r))e.append(i,o);}else if(typeof e=="object"&&!Array.isArray(e)&&e!==null)n={...e,...t.appendCookiesToBody?r:{},...t.appendTimestamp?{__stmp:Date.now()/1e3}:{}};else if(!N(e).isString())throw new Error("Unsupported data type for withPost/withPut/withPatch");return {finalData:n,contentType:s}},ae=(e,t)=>{if(t.returnRawResponse)return e;if(e.data&&(t.ignoreKind||"kind"in e.data))return e.data;throw e.data},C=async(e,t)=>{try{let r=await E__default.default(e);return ae(r,t)}catch(r){throw r?.response?.data?r.response.data:r?.code==="ERR_NETWORK"?ie(r):r}},Ze=async(e,t,r=60,n=false,s={},i)=>{let o=A(r,n,s,i),{finalData:l,contentType:a}=$(t,o);return C({method:"post",url:e,data:l,timeout:o.timeout*1e3,withCredentials:o.withCredentials,headers:{"Content-Type":a,...o.headers??{}},onUploadProgress:o.onProgress},o)},Ve=async(e,t=60,r=false,n={})=>{let s=A(t,r,n);return C({method:"get",url:e,timeout:s.timeout*1e3,withCredentials:s.withCredentials,headers:s.headers},s)},Ye=async(e,t,r=60,n=false,s={},i)=>{let o=A(r,n,s,i),{finalData:l,contentType:a}=$(t,o);return C({method:"put",url:e,data:l,timeout:o.timeout*1e3,withCredentials:o.withCredentials,headers:{"Content-Type":a,...o.headers??{}},onUploadProgress:o.onProgress},o)},Ge=async(e,t,r=60,n=false,s={},i)=>{let o=A(r,n,s,i),{finalData:l,contentType:a}=$(t,o);return C({method:"patch",url:e,data:l,timeout:o.timeout*1e3,withCredentials:o.withCredentials,headers:{"Content-Type":a,...o.headers??{}},onUploadProgress:o.onProgress},o)},Je=e=>{let t=new Date().getTime(),r=e(),n=new Date().getTime();return {result:r,executionTime:n-t}},Qe=(e,t)=>{let r=t||"YYYY-MM-DD HH:mm:ss";if(!e)return g__default.default().format(r);if(e instanceof Date)return g__default.default(e).format(r);if(typeof e=="string"&&isNaN(Number(e)))return g__default.default(e).format(r);let n=Number(e);return n>9999999999?g__default.default(n).format(r):g__default.default.unix(n).format(r)},Xe=e=>{if(e instanceof Date)return g__default.default(e).fromNow();if(typeof e=="string"&&isNaN(Number(e)))return g__default.default(e).fromNow();let t=Number(e);return t>9999999999?g__default.default(t).fromNow():g__default.default.unix(t).fromNow()},et=e=>e[Math.floor(Math.random()*e.length)],tt=({number:e,locale:t="en-US",style:r="decimal",decimal:n=2,forceDecimal:s=false,currency:i})=>{if(r==="currency"&&!i)throw new TypeError("Currency code is required with currency style.");if(i){let{code:o,style:l,symbol:a}=i,c=new Intl.NumberFormat(t,{style:"currency",currency:o,currencyDisplay:l,minimumFractionDigits:s||+e%1>0?n:0,maximumFractionDigits:s||+e%1>0?n:0}).format(+e);return a?c.replace(new RegExp(`\\${o}`,"g"),a):c}return new Intl.NumberFormat(t,{style:r,minimumFractionDigits:s?n:+e%1>0?2:0,maximumFractionDigits:s?n:+e%1>0?2:0}).format(+e)},rt=e=>{let t=["Bytes","KB","MB","GB","TB"],r=typeof e=="string"?parseFloat(e):e;if(r==0)return "0 Byte";let n=Math.floor(Math.log(r)/Math.log(1024)),s=typeof n=="string"?parseInt(n):n;return (r/Math.pow(1024,s)).toFixed(2)+" "+t[s]},nt=e=>navigator.clipboard&&navigator.clipboard.writeText?navigator.clipboard.writeText(e):new Promise((t,r)=>{let n=document.createElement("textarea");n.value=e,n.style.position="fixed",document.body.appendChild(n),n.focus(),n.select();try{document.execCommand("copy"),t("Copied to clipboard");}catch(s){r(s);}document.body.removeChild(n);}),st=(e={direction:"ASC",caseSensitive:false})=>{let t=/^0/,r=/\s+/g,n=/^\s+|\s+$/g,s=/[^\x00-\x80]/,i=/^0x[0-9a-f]+$/i,o=/(0x[\da-fA-F]+|(^[\+\-]?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?(?=\D|\s|$))|\d+)/g,l=/(^([\w ]+,?[\w ]+)?[\w ]+,?[\w ]+\d+:\d+(:\d+)?[\w ]?|^\d{1,4}[\/\-]\d{1,4}[\/\-]\d{1,4}|^\w+, \w+ \d+, \d{4})/,a=e.direction=="DESC"?-1:1,c=-a,h=e.caseSensitive?u=>`${u}`.replace(n,""):u=>u.toString().toLowerCase().replace(n,""),j=u=>u.replace(o,"\0$1\0").replace(/\0$/,"").replace(/^\0/,"").split("\0"),D=(u,_)=>(!u.match(t)||_===1)&&parseFloat(u)||u.replace(r," ").replace(n,"")||0;return function(u,_){let f=h(u),d=h(_);if(!f&&!d)return 0;if(!f&&d)return c;if(f&&!d)return a;let v=j(f),H=j(d),k=f.match(i),R=d.match(i),y=k&&R?parseInt(k[0],16):v.length!==1&&Date.parse(f),b=k&&R?parseInt(R[0],16):y&&d.match(l)&&Date.parse(d)||null;if(b){if(y===b)return 0;if(typeof y=="number"&&typeof b=="number"&&y<b)return c;if(typeof y=="number"&&y>b)return a}let q=v.length,z=H.length;for(let x=0,M=Math.max(q,z);x<M;x+=1){let p=D(v[x]||"",q),m=D(H[x]||"",z);if(isNaN(p)!==isNaN(m))return isNaN(p)?a:c;if(s.test(p+m)&&p.localeCompare){let L=p.localeCompare(m);if(L>0)return a;if(L<0)return c;if(x===M-1)return 0}if(p<m)return c;if(p>m)return a;if(`${p}`<`${m}`)return c;if(`${p}`>`${m}`)return a}return 0}},ot=(e,t=false)=>e.toLowerCase().split(/[^a-zA-Z0-9]+/).map((r,n)=>n===0?t?O(r):r:O(r)).join(""),it=e=>e.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase(),at=(e,t,r)=>Math.min(Math.max(e,t),r),lt=(e,t="-")=>e==null?(console.log(e,"is undefined"),""):e.normalize("NFKD").replace(/[\u0300-\u036f]/g,"").toLowerCase().replace(/[^a-z0-9\p{L}\p{N}]+/gu,t).replace(new RegExp(`\\${t}{2,}`,"g"),t).replace(new RegExp(`^\\${t}|\\${t}$`,"g"),""),ct=e=>new Promise(t=>setTimeout(t,e)),ut=(e,t)=>setTimeout(e,t||1e3),pt=e=>Object.keys(e).filter(t=>isNaN(Number(t))),gt=async e=>{try{return await J__default.default.access(e),!0}catch{return false}},dt=e=>{let t="=".repeat((4-e.length%4)%4),r=(e+t).replace(/-/g,"+").replace(/_/g,"/"),n=window.atob(r),s=new Uint8Array(n.length);for(let i=0;i<n.length;++i)s[i]=n.charCodeAt(i);return s},mt=e=>{let t=[],r=0;return e.length>=8?r++:t.push("Use at least 8 characters"),/[a-z]/.test(e)?r++:t.push("Add lowercase letters"),/[A-Z]/.test(e)?r++:t.push("Add uppercase letters"),/\d/.test(e)?r++:t.push("Include numbers"),/[^A-Za-z0-9]/.test(e)?r++:t.push("Add special characters (e.g. !, @, #)"),{score:r,result:r<=2?"Weak":r==3?"Moderate":r==4?"Strong":"Excellent",suggestion:t}},le=e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),ht=(e,t)=>{if(t.length===0)return e.trim();let r=t.map(s=>s.trim()).filter(Boolean).map(le);if(r.length===0)return e.trim();let n=new RegExp(`\\b(${r.join("|")})\\b`,"gi");return e.replace(n,"").replace(/\s+/g," ").trim()},ft=(e,t=false)=>{let r=T__default.default.get(e);return r?t?JSON.parse(r):r:null},yt=e=>T__default.default.remove(e),bt=({key:e,value:t,json:r=false,path:n="/",expires:s,domain:i,secure:o,sameSite:l})=>{T__default.default.set(e,r?JSON.stringify(t):t,{expires:s,path:n,domain:i,secure:o,sameSite:l});};exports.MD5=He;exports.PubSub=G;exports.SORT=V;exports._=N;exports.__SALT=Z;exports.arrayRand=et;exports.camelCase=ot;exports.camelCaseToDash=it;exports.checkPasswordStrength=mt;exports.clamp=at;exports.copyToClipboard=nt;exports.enumToKeys=pt;exports.escapeRegex=le;exports.exists=gt;exports.formatNumber=tt;exports.formatSize=rt;exports.fromHash=De;exports.getCancelToken=Oe;exports.getCookie=ft;exports.hexToRgba=Ie;exports.isColor=Be;exports.isColorName=Ue;exports.isHexColor=re;exports.isHslColor=se;exports.isRgbaColor=ne;exports.natsort=st;exports.numberInRange=ee;exports.pluralize=Fe;exports.removeCookie=yt;exports.removeDuplicateWords=We;exports.removeDuplicates=oe;exports.removeWords=ht;exports.setCookie=bt;exports.sleep=ct;exports.slugify=lt;exports.time=Qe;exports.timeSince=Xe;exports.toHash=te;exports.ucfirst=O;exports.urlBase64ToUint8Array=dt;exports.urldecode=Me;exports.urlencode=Le;exports.uuid=qe;exports.uuid2=ze;exports.withCredentials=Ke;exports.withDelay=ut;exports.withGet=Ve;exports.withPatch=Ge;exports.withPost=Ze;exports.withPut=Ye;exports.withTime=Je;
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import $ from'axios';import Q from'fs/promises';import Z from'hashids';import A from'js-cookie';import X from'md5';import g from'moment';import {nanoid}from'nanoid';import O from'ip-regex';var B=["aliceblue","antiquewhite","aqua","aquamarine","azure","beige","bisque","black","blanchedalmond","blue","blueviolet","brown","burlywood","cadetblue","chartreuse","chocolate","coral","cornflowerblue","cornsilk","crimson","cyan","darkblue","darkcyan","darkgoldenrod","darkgray","darkgreen","darkgrey","darkkhaki","darkmagenta","darkolivegreen","darkorange","darkorchid","darkred","darksalmon","darkseagreen","darkslateblue","darkslategray","darkslategrey","darkturquoise","darkviolet","deeppink","deepskyblue","dimgray","dimgrey","dodgerblue","firebrick","floralwhite","forestgreen","fuchsia","gainsboro","ghostwhite","gold","goldenrod","gray","green","greenyellow","grey","honeydew","hotpink","indianred","indigo","ivory","khaki","lavender","lavenderblush","lawngreen","lemonchiffon","lightblue","lightcoral","lightcyan","lightgoldenrodyellow","lightgray","lightgreen","lightgrey","lightpink","lightsalmon","lightseagreen","lightskyblue","lightslategray","lightslategrey","lightsteelblue","lightyellow","lime","limegreen","linen","magenta","maroon","mediumaquamarine","mediumblue","mediumorchid","mediumpurple","mediumseagreen","mediumslateblue","mediumspringgreen","mediumturquoise","mediumvioletred","midnightblue","mintcream","mistyrose","moccasin","navajowhite","navy","oldlace","olive","olivedrab","orange","orangered","orchid","palegoldenrod","palegreen","paleturquoise","palevioletred","papayawhip","peachpuff","peru","pink","plum","powderblue","purple","rebeccapurple","red","rosybrown","royalblue","saddlebrown","salmon","sandybrown","seagreen","seashell","sienna","silver","skyblue","slateblue","slategray","slategrey","snow","springgreen","steelblue","tan","teal","thistle","tomato","turquoise","violet","wheat","white","whitesmoke","yellow","yellowgreen"];var U=/^[0-9a-fA-F]{3}$|^[0-9a-fA-F]{6}$/,I=/^rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*((0|1|0?\.\d+)\s*))?\)$/,W=/^hsl\(\s*(\d{1,3})\s*,\s*(\d{1,3})%\s*,\s*(\d{1,3})%\s*\)$/;var Y=(r=>(r.Asc="ASC",r.Desc="DESC",r))(Y||{});var N=class{_;constructor(t){this._=t;}isIP(){return this.isIPv4()||this.isIPv6()}isIPv4(){return O.v4({exact:true}).test(this._)}isIPv6(){return O.v6({exact:true}).test(this._)}isTypeof(t){return typeof this._==typeof t}isFunction(){return typeof this._=="function"}isArray(){return Array.isArray(this._)}isNull(){return this._===null}isString(){return typeof this._=="string"}isNumber(){return /^[+-]?\d+(\.\d+)?$/.test(this._)}isObject(){return typeof this._=="object"&&!Array.isArray(this._)&&this._!==null}isEmpty(){return Array.isArray(this._)?this._.length===0:typeof this._=="object"&&this._!==null?Object.keys(this._).length===0:this._===""||String(this._).length===0}isEmail(){return typeof this._=="string"&&/^[^\s@]+@[^\s@]+\.[^\s@]{2,}$/.test(this._)}isUrl(){return typeof this._=="string"&&/^(https?:\/\/)?(www\.)?([a-zA-Z0-9-]+\.)+[a-zA-Z]{2,}(\/[^\s]*)?$/.test(this._)}toLowerCase(){return this._=typeof this._=="string"?this._.toLowerCase():String(this._).toLowerCase(),this}equals(t){let r=this._,n=t,s=(o,l)=>{if(o===l)return true;if(o===null||typeof o!="object"||l===null||typeof l!="object")return false;if(Array.isArray(o)&&Array.isArray(l)){if(o.length!==l.length)return false;for(let a=0;a<o.length;a++)if(!s(o[a],l[a]))return false;return true}if(this.isObjectValue(o)&&this.isObjectValue(l)){let a=Object.keys(o),c=Object.keys(l);if(a.length!==c.length)return false;for(let h of a)if(!c.includes(h)||!s(o[h],l[h]))return false;return true}return false},i=o=>typeof o=="object"&&o!==null&&!Array.isArray(o);return this.isObjectValue=i,Array.isArray(r)&&Array.isArray(n)||i(r)&&i(n)?s(r,n):r===n}isObjectValue(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}ucfirst(){return this._=typeof this._=="string"?this._.charAt(0).toUpperCase()+this._.slice(1):this._,this}formatString(t,...r){typeof this._!="string"&&(this._="");let n=[t,...r];return this._=this._.replace(/%(\d+)/g,(s,i)=>n[Number(i)]?.toString()||`%${i}`),this}camelCase(){return this._=typeof this._=="string"?this._.split(/[^a-zA-Z0-9]+/).map((t,r)=>r===0?t:t.charAt(0).toUpperCase()+t.slice(1)).join(""):this._,this}sort(t="asc"){if(!this.isObject())return console.warn("sortKeys can only be applied to objects. Current value is not an object."),this;let r=this._,n=Object.keys(r).sort((i,o)=>t==="desc"?o.localeCompare(i):i.localeCompare(o)),s={};for(let i of n)s[i]=r[i];return this._=s,this}value(){return this._}valueOf(){return this._}toString(){return String(this._)}[Symbol.toPrimitive](t){return t==="number"?Number(this._):t==="boolean"?!!this._:String(this._)}},G=e=>new N(e),S=G;var E=class{_events;constructor(){this._events=[];}on(t,r,n){let s=this._events.find(l=>l.event===t),i=Symbol("listener_id"),o={fun:r,context:n,id:i};return s?s.listeners.push(o):this._events.push({event:t,listeners:[o]}),()=>{let l=this._events.find(a=>a.event===t);l&&(l.listeners=l.listeners.filter(a=>a.id!==i),l.listeners.length===0&&(this._events=this._events.filter(a=>a.event!==t)));}}off(t,r){let n=this._events.find(s=>s.event===t);n&&(n.listeners=n.listeners.filter(s=>s.fun!==r),n.listeners.length===0&&(this._events=this._events.filter(s=>s.event!==t)));}emit(t,...r){let n=this._events.find(s=>s.event===t);n&&[...n.listeners].forEach(({fun:s,context:i})=>{try{s.apply(i,r);}catch(o){console.error(`Error during event '${String(t)}' emission:`,o);}});}removeAllListeners(t){this._events=this._events.filter(r=>r.event!==t);}},J=E;var V="zuzjs-core",te=(e,t)=>Math.floor(Math.random()*(t-e+1))+e,re=(e,t=6,r=null)=>new Z(r||V,t).encode(e),He=(e,t=null)=>{try{let r=new Z(t||V,+process.env.HASHIDS_LENGTH).decode(e);return r.length>=0?Number(r[0]):0}catch{return 0}},qe=e=>X(e),ze=e=>re(te(11111111111,999999999999)),Me=e=>nanoid(e),K=e=>`${e.charAt(0).toUpperCase()}${e.substring(1,e.length)}`,Le=e=>decodeURIComponent(e.replace(/\+/g,"%20")),Fe=e=>encodeURIComponent(e),Be=(e,t)=>`${e}${t!==1?"s":""}`,ne=e=>U.test(e),se=e=>I.test(e),oe=e=>W.test(e),Ue=e=>B.includes(e.toLowerCase()),Ie=e=>ne(e)||se(e)||oe(e),We=(e,t=1)=>{e=e.replace(/^#/,""),e.length===3&&(e=e.split("").map(o=>o+o).join(""));let r=parseInt(e,16),n=r>>16&255,s=r>>8&255,i=r&255;return `rgba(${n}, ${s}, ${i}, ${t})`},ie=e=>e.reduce((t,r)=>(t.includes(r)||t.push(r),t),[]),Oe=e=>{if(!e.trim())return "";let t=e.split(/\s+/).filter(Boolean);return ie(t).join(" ")},Ke=()=>$.CancelToken.source(),Ze=e=>$.defaults.withCredentials=e,ae=e=>{let r=typeof navigator<"u"?navigator.onLine:true;return {error:e?.code??"ERR_NETWORK",message:r?"Unable to connect to the server. It may be temporarily down.":"Network error: Unable to connect. Please check your internet connection and try again."}},C=(e=60,t=false,r={},n)=>typeof e=="object"&&e!==null?{timeout:e.timeout??60,ignoreKind:e.ignoreKind??false,headers:e.headers??{},onProgress:e.onProgress,withCredentials:e.withCredentials,returnRawResponse:e.returnRawResponse,appendCookiesToBody:e.appendCookiesToBody??true,appendTimestamp:e.appendTimestamp??true}:{timeout:e,ignoreKind:t,headers:r,onProgress:n,appendCookiesToBody:true,appendTimestamp:true},j=(e,t)=>{let r=A.get(),n=e,s="application/json";if(e instanceof FormData){if(s="multipart/form-data",t.appendCookiesToBody)for(let[i,o]of Object.entries(r))e.append(i,o);}else if(typeof e=="object"&&!Array.isArray(e)&&e!==null)n={...e,...t.appendCookiesToBody?r:{},...t.appendTimestamp?{__stmp:Date.now()/1e3}:{}};else if(!S(e).isString())throw new Error("Unsupported data type for withPost/withPut/withPatch");return {finalData:n,contentType:s}},le=(e,t)=>{if(t.returnRawResponse)return e;if(e.data&&(t.ignoreKind||"kind"in e.data))return e.data;throw e.data},_=async(e,t)=>{try{let r=await $(e);return le(r,t)}catch(r){throw r?.response?.data?r.response.data:r?.code==="ERR_NETWORK"?ae(r):r}},Ve=async(e,t,r=60,n=false,s={},i)=>{let o=C(r,n,s,i),{finalData:l,contentType:a}=j(t,o);return _({method:"post",url:e,data:l,timeout:o.timeout*1e3,withCredentials:o.withCredentials,headers:{"Content-Type":a,...o.headers??{}},onUploadProgress:o.onProgress},o)},Ye=async(e,t=60,r=false,n={})=>{let s=C(t,r,n);return _({method:"get",url:e,timeout:s.timeout*1e3,withCredentials:s.withCredentials,headers:s.headers},s)},Ge=async(e,t,r=60,n=false,s={},i)=>{let o=C(r,n,s,i),{finalData:l,contentType:a}=j(t,o);return _({method:"put",url:e,data:l,timeout:o.timeout*1e3,withCredentials:o.withCredentials,headers:{"Content-Type":a,...o.headers??{}},onUploadProgress:o.onProgress},o)},Je=async(e,t,r=60,n=false,s={},i)=>{let o=C(r,n,s,i),{finalData:l,contentType:a}=j(t,o);return _({method:"patch",url:e,data:l,timeout:o.timeout*1e3,withCredentials:o.withCredentials,headers:{"Content-Type":a,...o.headers??{}},onUploadProgress:o.onProgress},o)},Qe=e=>{let t=new Date().getTime(),r=e(),n=new Date().getTime();return {result:r,executionTime:n-t}},Xe=(e,t)=>{let r=t||"YYYY-MM-DD HH:mm:ss";if(!e)return g().format(r);if(e instanceof Date)return g(e).format(r);if(typeof e=="string"&&isNaN(Number(e)))return g(e).format(r);let n=Number(e);return n>9999999999?g(n).format(r):g.unix(n).format(r)},et=e=>{if(e instanceof Date)return g(e).fromNow();if(typeof e=="string"&&isNaN(Number(e)))return g(e).fromNow();let t=Number(e);return t>9999999999?g(t).fromNow():g.unix(t).fromNow()},tt=e=>e[Math.floor(Math.random()*e.length)],rt=({number:e,locale:t="en-US",style:r="decimal",decimal:n=2,forceDecimal:s=false,currency:i})=>{if(r==="currency"&&!i)throw new TypeError("Currency code is required with currency style.");if(i){let{code:o,style:l,symbol:a}=i,c=new Intl.NumberFormat(t,{style:"currency",currency:o,currencyDisplay:l,minimumFractionDigits:s||+e%1>0?n:0,maximumFractionDigits:s||+e%1>0?n:0}).format(+e);return a?c.replace(new RegExp(`\\${o}`,"g"),a):c}return new Intl.NumberFormat(t,{style:r,minimumFractionDigits:s?n:+e%1>0?2:0,maximumFractionDigits:s?n:+e%1>0?2:0}).format(+e)},nt=e=>{let t=["Bytes","KB","MB","GB","TB"],r=typeof e=="string"?parseFloat(e):e;if(r==0)return "0 Byte";let n=Math.floor(Math.log(r)/Math.log(1024)),s=typeof n=="string"?parseInt(n):n;return (r/Math.pow(1024,s)).toFixed(2)+" "+t[s]},st=e=>navigator.clipboard&&navigator.clipboard.writeText?navigator.clipboard.writeText(e):new Promise((t,r)=>{let n=document.createElement("textarea");n.value=e,n.style.position="fixed",document.body.appendChild(n),n.focus(),n.select();try{document.execCommand("copy"),t("Copied to clipboard");}catch(s){r(s);}document.body.removeChild(n);}),ot=(e={direction:"ASC",caseSensitive:false})=>{let t=/^0/,r=/\s+/g,n=/^\s+|\s+$/g,s=/[^\x00-\x80]/,i=/^0x[0-9a-f]+$/i,o=/(0x[\da-fA-F]+|(^[\+\-]?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?(?=\D|\s|$))|\d+)/g,l=/(^([\w ]+,?[\w ]+)?[\w ]+,?[\w ]+\d+:\d+(:\d+)?[\w ]?|^\d{1,4}[\/\-]\d{1,4}[\/\-]\d{1,4}|^\w+, \w+ \d+, \d{4})/,a=e.direction=="DESC"?-1:1,c=-a,h=e.caseSensitive?u=>`${u}`.replace(n,""):u=>u.toString().toLowerCase().replace(n,""),D=u=>u.replace(o,"\0$1\0").replace(/\0$/,"").replace(/^\0/,"").split("\0"),H=(u,v)=>(!u.match(t)||v===1)&&parseFloat(u)||u.replace(r," ").replace(n,"")||0;return function(u,v){let f=h(u),d=h(v);if(!f&&!d)return 0;if(!f&&d)return c;if(f&&!d)return a;let k=D(f),q=D(d),R=f.match(i),P=d.match(i),y=R&&P?parseInt(R[0],16):k.length!==1&&Date.parse(f),b=R&&P?parseInt(P[0],16):y&&d.match(l)&&Date.parse(d)||null;if(b){if(y===b)return 0;if(typeof y=="number"&&typeof b=="number"&&y<b)return c;if(typeof y=="number"&&y>b)return a}let z=k.length,M=q.length;for(let x=0,L=Math.max(z,M);x<L;x+=1){let p=H(k[x]||"",z),m=H(q[x]||"",M);if(isNaN(p)!==isNaN(m))return isNaN(p)?a:c;if(s.test(p+m)&&p.localeCompare){let F=p.localeCompare(m);if(F>0)return a;if(F<0)return c;if(x===L-1)return 0}if(p<m)return c;if(p>m)return a;if(`${p}`<`${m}`)return c;if(`${p}`>`${m}`)return a}return 0}},it=(e,t=false)=>e.toLowerCase().split(/[^a-zA-Z0-9]+/).map((r,n)=>n===0?t?K(r):r:K(r)).join(""),at=e=>e.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase(),lt=(e,t,r)=>Math.min(Math.max(e,t),r),ct=(e,t="-")=>e==null?(console.log(e,"is undefined"),""):e.normalize("NFKD").replace(/[\u0300-\u036f]/g,"").toLowerCase().replace(/[^a-z0-9\p{L}\p{N}]+/gu,t).replace(new RegExp(`\\${t}{2,}`,"g"),t).replace(new RegExp(`^\\${t}|\\${t}$`,"g"),""),ut=e=>new Promise(t=>setTimeout(t,e)),pt=(e,t)=>setTimeout(e,t||1e3),gt=e=>Object.keys(e).filter(t=>isNaN(Number(t))),dt=async e=>{try{return await Q.access(e),!0}catch{return false}},mt=e=>{let t="=".repeat((4-e.length%4)%4),r=(e+t).replace(/-/g,"+").replace(/_/g,"/"),n=window.atob(r),s=new Uint8Array(n.length);for(let i=0;i<n.length;++i)s[i]=n.charCodeAt(i);return s},ht=e=>{let t=[],r=0;return e.length>=8?r++:t.push("Use at least 8 characters"),/[a-z]/.test(e)?r++:t.push("Add lowercase letters"),/[A-Z]/.test(e)?r++:t.push("Add uppercase letters"),/\d/.test(e)?r++:t.push("Include numbers"),/[^A-Za-z0-9]/.test(e)?r++:t.push("Add special characters (e.g. !, @, #)"),{score:r,result:r<=2?"Weak":r==3?"Moderate":r==4?"Strong":"Excellent",suggestion:t}},ce=e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),ft=(e,t)=>{if(t.length===0)return e.trim();let r=t.map(s=>s.trim()).filter(Boolean).map(ce);if(r.length===0)return e.trim();let n=new RegExp(`\\b(${r.join("|")})\\b`,"gi");return e.replace(n,"").replace(/\s+/g," ").trim()},yt=(e,t=false)=>{let r=A.get(e);return r?t?JSON.parse(r):r:null},bt=e=>A.remove(e),xt=({key:e,value:t,json:r=false,path:n="/",expires:s,domain:i,secure:o,sameSite:l})=>{A.set(e,r?JSON.stringify(t):t,{expires:s,path:n,domain:i,secure:o,sameSite:l});};export{qe as MD5,J as PubSub,Y as SORT,S as _,V as __SALT,tt as arrayRand,it as camelCase,at as camelCaseToDash,ht as checkPasswordStrength,lt as clamp,st as copyToClipboard,gt as enumToKeys,ce as escapeRegex,dt as exists,rt as formatNumber,nt as formatSize,He as fromHash,Ke as getCancelToken,yt as getCookie,We as hexToRgba,Ie as isColor,Ue as isColorName,ne as isHexColor,oe as isHslColor,se as isRgbaColor,ot as natsort,te as numberInRange,Be as pluralize,bt as removeCookie,Oe as removeDuplicateWords,ie as removeDuplicates,ft as removeWords,xt as setCookie,ut as sleep,ct as slugify,Xe as time,et as timeSince,re as toHash,K as ucfirst,mt as urlBase64ToUint8Array,Le as urldecode,Fe as urlencode,ze as uuid,Me as uuid2,Ze as withCredentials,pt as withDelay,Ye as withGet,Je as withPatch,Ve as withPost,Ge as withPut,Qe as withTime};
1
+ import $ from'axios';import Q from'fs/promises';import Z from'hashids';import A from'js-cookie';import X from'md5';import g from'moment';import {nanoid}from'nanoid';import O from'ip-regex';var U=["aliceblue","antiquewhite","aqua","aquamarine","azure","beige","bisque","black","blanchedalmond","blue","blueviolet","brown","burlywood","cadetblue","chartreuse","chocolate","coral","cornflowerblue","cornsilk","crimson","cyan","darkblue","darkcyan","darkgoldenrod","darkgray","darkgreen","darkgrey","darkkhaki","darkmagenta","darkolivegreen","darkorange","darkorchid","darkred","darksalmon","darkseagreen","darkslateblue","darkslategray","darkslategrey","darkturquoise","darkviolet","deeppink","deepskyblue","dimgray","dimgrey","dodgerblue","firebrick","floralwhite","forestgreen","fuchsia","gainsboro","ghostwhite","gold","goldenrod","gray","green","greenyellow","grey","honeydew","hotpink","indianred","indigo","ivory","khaki","lavender","lavenderblush","lawngreen","lemonchiffon","lightblue","lightcoral","lightcyan","lightgoldenrodyellow","lightgray","lightgreen","lightgrey","lightpink","lightsalmon","lightseagreen","lightskyblue","lightslategray","lightslategrey","lightsteelblue","lightyellow","lime","limegreen","linen","magenta","maroon","mediumaquamarine","mediumblue","mediumorchid","mediumpurple","mediumseagreen","mediumslateblue","mediumspringgreen","mediumturquoise","mediumvioletred","midnightblue","mintcream","mistyrose","moccasin","navajowhite","navy","oldlace","olive","olivedrab","orange","orangered","orchid","palegoldenrod","palegreen","paleturquoise","palevioletred","papayawhip","peachpuff","peru","pink","plum","powderblue","purple","rebeccapurple","red","rosybrown","royalblue","saddlebrown","salmon","sandybrown","seagreen","seashell","sienna","silver","skyblue","slateblue","slategray","slategrey","snow","springgreen","steelblue","tan","teal","thistle","tomato","turquoise","violet","wheat","white","whitesmoke","yellow","yellowgreen"];var B=/^[0-9a-fA-F]{3}$|^[0-9a-fA-F]{6}$/,I=/^rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*((0|1|0?\.\d+)\s*))?\)$/,W=/^hsl\(\s*(\d{1,3})\s*,\s*(\d{1,3})%\s*,\s*(\d{1,3})%\s*\)$/;var Y=(r=>(r.Asc="ASC",r.Desc="DESC",r))(Y||{});var N=class{_;constructor(t){this._=t;}isIP(){return this.isIPv4()||this.isIPv6()}isIPv4(){return O.v4({exact:true}).test(this._)}isIPv6(){return O.v6({exact:true}).test(this._)}isTypeof(t){return typeof this._==typeof t}isFunction(){return typeof this._=="function"}isArray(){return Array.isArray(this._)}isNull(){return this._===null}isString(){return typeof this._=="string"}isNumber(){return /^[+-]?\d+(\.\d+)?$/.test(this._)}isObject(){return typeof this._=="object"&&!Array.isArray(this._)&&this._!==null}isEmpty(){return Array.isArray(this._)?this._.length===0:typeof this._=="object"&&this._!==null?Object.keys(this._).length===0:this._===""||String(this._).length===0}isEmail(){return typeof this._=="string"&&/^[^\s@]+@[^\s@]+\.[^\s@]{2,}$/.test(decodeURIComponent(this._))}isUrl(){return typeof this._=="string"&&/^(https?:\/\/)?(www\.)?([a-zA-Z0-9-]+\.)+[a-zA-Z]{2,}(\/[^\s]*)?$/.test(this._)}toLowerCase(){return this._=typeof this._=="string"?this._.toLowerCase():String(this._).toLowerCase(),this}equals(t){let r=this._,n=t,s=(o,l)=>{if(o===l)return true;if(o===null||typeof o!="object"||l===null||typeof l!="object")return false;if(Array.isArray(o)&&Array.isArray(l)){if(o.length!==l.length)return false;for(let a=0;a<o.length;a++)if(!s(o[a],l[a]))return false;return true}if(this.isObjectValue(o)&&this.isObjectValue(l)){let a=Object.keys(o),c=Object.keys(l);if(a.length!==c.length)return false;for(let h of a)if(!c.includes(h)||!s(o[h],l[h]))return false;return true}return false},i=o=>typeof o=="object"&&o!==null&&!Array.isArray(o);return this.isObjectValue=i,Array.isArray(r)&&Array.isArray(n)||i(r)&&i(n)?s(r,n):r===n}isObjectValue(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}ucfirst(){return this._=typeof this._=="string"?this._.charAt(0).toUpperCase()+this._.slice(1):this._,this}formatString(t,...r){typeof this._!="string"&&(this._="");let n=[t,...r];return this._=this._.replace(/%(\d+)/g,(s,i)=>n[Number(i)]?.toString()||`%${i}`),this}camelCase(){return this._=typeof this._=="string"?this._.split(/[^a-zA-Z0-9]+/).map((t,r)=>r===0?t:t.charAt(0).toUpperCase()+t.slice(1)).join(""):this._,this}sort(t="asc"){if(!this.isObject())return console.warn("sortKeys can only be applied to objects. Current value is not an object."),this;let r=this._,n=Object.keys(r).sort((i,o)=>t==="desc"?o.localeCompare(i):i.localeCompare(o)),s={};for(let i of n)s[i]=r[i];return this._=s,this}value(){return this._}valueOf(){return this._}toString(){return String(this._)}[Symbol.toPrimitive](t){return t==="number"?Number(this._):t==="boolean"?!!this._:String(this._)}},G=e=>new N(e),S=G;var E=class{_events;constructor(){this._events=[];}on(t,r,n){let s=this._events.find(l=>l.event===t),i=Symbol("listener_id"),o={fun:r,context:n,id:i};return s?s.listeners.push(o):this._events.push({event:t,listeners:[o]}),()=>{let l=this._events.find(a=>a.event===t);l&&(l.listeners=l.listeners.filter(a=>a.id!==i),l.listeners.length===0&&(this._events=this._events.filter(a=>a.event!==t)));}}off(t,r){let n=this._events.find(s=>s.event===t);n&&(n.listeners=n.listeners.filter(s=>s.fun!==r),n.listeners.length===0&&(this._events=this._events.filter(s=>s.event!==t)));}emit(t,...r){let n=this._events.find(s=>s.event===t);n&&[...n.listeners].forEach(({fun:s,context:i})=>{try{s.apply(i,r);}catch(o){console.error(`Error during event '${String(t)}' emission:`,o);}});}removeAllListeners(t){this._events=this._events.filter(r=>r.event!==t);}},J=E;var V="zuzjs-core",te=(e,t)=>Math.floor(Math.random()*(t-e+1))+e,re=(e,t=6,r=null)=>new Z(r||V,t).encode(e),He=(e,t=null)=>{try{let r=new Z(t||V,+process.env.HASHIDS_LENGTH).decode(e);return r.length>=0?Number(r[0]):0}catch{return 0}},qe=e=>X(e),ze=e=>re(te(11111111111,999999999999)),Me=e=>nanoid(e),K=e=>`${e.charAt(0).toUpperCase()}${e.substring(1,e.length)}`,Le=e=>decodeURIComponent(e.replace(/\+/g,"%20")),Fe=e=>encodeURIComponent(e),Ue=(e,t)=>`${e}${t!==1?"s":""}`,ne=e=>B.test(e),se=e=>I.test(e),oe=e=>W.test(e),Be=e=>U.includes(e.toLowerCase()),Ie=e=>ne(e)||se(e)||oe(e),We=(e,t=1)=>{e=e.replace(/^#/,""),e.length===3&&(e=e.split("").map(o=>o+o).join(""));let r=parseInt(e,16),n=r>>16&255,s=r>>8&255,i=r&255;return `rgba(${n}, ${s}, ${i}, ${t})`},ie=e=>e.reduce((t,r)=>(t.includes(r)||t.push(r),t),[]),Oe=e=>{if(!e.trim())return "";let t=e.split(/\s+/).filter(Boolean);return ie(t).join(" ")},Ke=()=>$.CancelToken.source(),Ze=e=>$.defaults.withCredentials=e,ae=e=>{let r=typeof navigator<"u"?navigator.onLine:true;return {error:e?.code??"ERR_NETWORK",message:r?"Unable to connect to the server. It may be temporarily down.":"Network error: Unable to connect. Please check your internet connection and try again."}},C=(e=60,t=false,r={},n)=>typeof e=="object"&&e!==null?{timeout:e.timeout??60,ignoreKind:e.ignoreKind??false,headers:e.headers??{},onProgress:e.onProgress,withCredentials:e.withCredentials,returnRawResponse:e.returnRawResponse,appendCookiesToBody:e.appendCookiesToBody??true,appendTimestamp:e.appendTimestamp??true}:{timeout:e,ignoreKind:t,headers:r,onProgress:n,appendCookiesToBody:true,appendTimestamp:true},j=(e,t)=>{let r=A.get(),n=e,s="application/json";if(e instanceof FormData){if(s="multipart/form-data",t.appendCookiesToBody)for(let[i,o]of Object.entries(r))e.append(i,o);}else if(typeof e=="object"&&!Array.isArray(e)&&e!==null)n={...e,...t.appendCookiesToBody?r:{},...t.appendTimestamp?{__stmp:Date.now()/1e3}:{}};else if(!S(e).isString())throw new Error("Unsupported data type for withPost/withPut/withPatch");return {finalData:n,contentType:s}},le=(e,t)=>{if(t.returnRawResponse)return e;if(e.data&&(t.ignoreKind||"kind"in e.data))return e.data;throw e.data},_=async(e,t)=>{try{let r=await $(e);return le(r,t)}catch(r){throw r?.response?.data?r.response.data:r?.code==="ERR_NETWORK"?ae(r):r}},Ve=async(e,t,r=60,n=false,s={},i)=>{let o=C(r,n,s,i),{finalData:l,contentType:a}=j(t,o);return _({method:"post",url:e,data:l,timeout:o.timeout*1e3,withCredentials:o.withCredentials,headers:{"Content-Type":a,...o.headers??{}},onUploadProgress:o.onProgress},o)},Ye=async(e,t=60,r=false,n={})=>{let s=C(t,r,n);return _({method:"get",url:e,timeout:s.timeout*1e3,withCredentials:s.withCredentials,headers:s.headers},s)},Ge=async(e,t,r=60,n=false,s={},i)=>{let o=C(r,n,s,i),{finalData:l,contentType:a}=j(t,o);return _({method:"put",url:e,data:l,timeout:o.timeout*1e3,withCredentials:o.withCredentials,headers:{"Content-Type":a,...o.headers??{}},onUploadProgress:o.onProgress},o)},Je=async(e,t,r=60,n=false,s={},i)=>{let o=C(r,n,s,i),{finalData:l,contentType:a}=j(t,o);return _({method:"patch",url:e,data:l,timeout:o.timeout*1e3,withCredentials:o.withCredentials,headers:{"Content-Type":a,...o.headers??{}},onUploadProgress:o.onProgress},o)},Qe=e=>{let t=new Date().getTime(),r=e(),n=new Date().getTime();return {result:r,executionTime:n-t}},Xe=(e,t)=>{let r=t||"YYYY-MM-DD HH:mm:ss";if(!e)return g().format(r);if(e instanceof Date)return g(e).format(r);if(typeof e=="string"&&isNaN(Number(e)))return g(e).format(r);let n=Number(e);return n>9999999999?g(n).format(r):g.unix(n).format(r)},et=e=>{if(e instanceof Date)return g(e).fromNow();if(typeof e=="string"&&isNaN(Number(e)))return g(e).fromNow();let t=Number(e);return t>9999999999?g(t).fromNow():g.unix(t).fromNow()},tt=e=>e[Math.floor(Math.random()*e.length)],rt=({number:e,locale:t="en-US",style:r="decimal",decimal:n=2,forceDecimal:s=false,currency:i})=>{if(r==="currency"&&!i)throw new TypeError("Currency code is required with currency style.");if(i){let{code:o,style:l,symbol:a}=i,c=new Intl.NumberFormat(t,{style:"currency",currency:o,currencyDisplay:l,minimumFractionDigits:s||+e%1>0?n:0,maximumFractionDigits:s||+e%1>0?n:0}).format(+e);return a?c.replace(new RegExp(`\\${o}`,"g"),a):c}return new Intl.NumberFormat(t,{style:r,minimumFractionDigits:s?n:+e%1>0?2:0,maximumFractionDigits:s?n:+e%1>0?2:0}).format(+e)},nt=e=>{let t=["Bytes","KB","MB","GB","TB"],r=typeof e=="string"?parseFloat(e):e;if(r==0)return "0 Byte";let n=Math.floor(Math.log(r)/Math.log(1024)),s=typeof n=="string"?parseInt(n):n;return (r/Math.pow(1024,s)).toFixed(2)+" "+t[s]},st=e=>navigator.clipboard&&navigator.clipboard.writeText?navigator.clipboard.writeText(e):new Promise((t,r)=>{let n=document.createElement("textarea");n.value=e,n.style.position="fixed",document.body.appendChild(n),n.focus(),n.select();try{document.execCommand("copy"),t("Copied to clipboard");}catch(s){r(s);}document.body.removeChild(n);}),ot=(e={direction:"ASC",caseSensitive:false})=>{let t=/^0/,r=/\s+/g,n=/^\s+|\s+$/g,s=/[^\x00-\x80]/,i=/^0x[0-9a-f]+$/i,o=/(0x[\da-fA-F]+|(^[\+\-]?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?(?=\D|\s|$))|\d+)/g,l=/(^([\w ]+,?[\w ]+)?[\w ]+,?[\w ]+\d+:\d+(:\d+)?[\w ]?|^\d{1,4}[\/\-]\d{1,4}[\/\-]\d{1,4}|^\w+, \w+ \d+, \d{4})/,a=e.direction=="DESC"?-1:1,c=-a,h=e.caseSensitive?u=>`${u}`.replace(n,""):u=>u.toString().toLowerCase().replace(n,""),D=u=>u.replace(o,"\0$1\0").replace(/\0$/,"").replace(/^\0/,"").split("\0"),H=(u,v)=>(!u.match(t)||v===1)&&parseFloat(u)||u.replace(r," ").replace(n,"")||0;return function(u,v){let f=h(u),d=h(v);if(!f&&!d)return 0;if(!f&&d)return c;if(f&&!d)return a;let k=D(f),q=D(d),R=f.match(i),P=d.match(i),y=R&&P?parseInt(R[0],16):k.length!==1&&Date.parse(f),b=R&&P?parseInt(P[0],16):y&&d.match(l)&&Date.parse(d)||null;if(b){if(y===b)return 0;if(typeof y=="number"&&typeof b=="number"&&y<b)return c;if(typeof y=="number"&&y>b)return a}let z=k.length,M=q.length;for(let x=0,L=Math.max(z,M);x<L;x+=1){let p=H(k[x]||"",z),m=H(q[x]||"",M);if(isNaN(p)!==isNaN(m))return isNaN(p)?a:c;if(s.test(p+m)&&p.localeCompare){let F=p.localeCompare(m);if(F>0)return a;if(F<0)return c;if(x===L-1)return 0}if(p<m)return c;if(p>m)return a;if(`${p}`<`${m}`)return c;if(`${p}`>`${m}`)return a}return 0}},it=(e,t=false)=>e.toLowerCase().split(/[^a-zA-Z0-9]+/).map((r,n)=>n===0?t?K(r):r:K(r)).join(""),at=e=>e.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase(),lt=(e,t,r)=>Math.min(Math.max(e,t),r),ct=(e,t="-")=>e==null?(console.log(e,"is undefined"),""):e.normalize("NFKD").replace(/[\u0300-\u036f]/g,"").toLowerCase().replace(/[^a-z0-9\p{L}\p{N}]+/gu,t).replace(new RegExp(`\\${t}{2,}`,"g"),t).replace(new RegExp(`^\\${t}|\\${t}$`,"g"),""),ut=e=>new Promise(t=>setTimeout(t,e)),pt=(e,t)=>setTimeout(e,t||1e3),gt=e=>Object.keys(e).filter(t=>isNaN(Number(t))),dt=async e=>{try{return await Q.access(e),!0}catch{return false}},mt=e=>{let t="=".repeat((4-e.length%4)%4),r=(e+t).replace(/-/g,"+").replace(/_/g,"/"),n=window.atob(r),s=new Uint8Array(n.length);for(let i=0;i<n.length;++i)s[i]=n.charCodeAt(i);return s},ht=e=>{let t=[],r=0;return e.length>=8?r++:t.push("Use at least 8 characters"),/[a-z]/.test(e)?r++:t.push("Add lowercase letters"),/[A-Z]/.test(e)?r++:t.push("Add uppercase letters"),/\d/.test(e)?r++:t.push("Include numbers"),/[^A-Za-z0-9]/.test(e)?r++:t.push("Add special characters (e.g. !, @, #)"),{score:r,result:r<=2?"Weak":r==3?"Moderate":r==4?"Strong":"Excellent",suggestion:t}},ce=e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),ft=(e,t)=>{if(t.length===0)return e.trim();let r=t.map(s=>s.trim()).filter(Boolean).map(ce);if(r.length===0)return e.trim();let n=new RegExp(`\\b(${r.join("|")})\\b`,"gi");return e.replace(n,"").replace(/\s+/g," ").trim()},yt=(e,t=false)=>{let r=A.get(e);return r?t?JSON.parse(r):r:null},bt=e=>A.remove(e),xt=({key:e,value:t,json:r=false,path:n="/",expires:s,domain:i,secure:o,sameSite:l})=>{A.set(e,r?JSON.stringify(t):t,{expires:s,path:n,domain:i,secure:o,sameSite:l});};export{qe as MD5,J as PubSub,Y as SORT,S as _,V as __SALT,tt as arrayRand,it as camelCase,at as camelCaseToDash,ht as checkPasswordStrength,lt as clamp,st as copyToClipboard,gt as enumToKeys,ce as escapeRegex,dt as exists,rt as formatNumber,nt as formatSize,He as fromHash,Ke as getCancelToken,yt as getCookie,We as hexToRgba,Ie as isColor,Be as isColorName,ne as isHexColor,oe as isHslColor,se as isRgbaColor,ot as natsort,te as numberInRange,Ue as pluralize,bt as removeCookie,Oe as removeDuplicateWords,ie as removeDuplicates,ft as removeWords,xt as setCookie,ut as sleep,ct as slugify,Xe as time,et as timeSince,re as toHash,K as ucfirst,mt as urlBase64ToUint8Array,Le as urldecode,Fe as urlencode,ze as uuid,Me as uuid2,Ze as withCredentials,pt as withDelay,Ye as withGet,Je as withPatch,Ve as withPost,Ge as withPut,Qe as withTime};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zuzjs/core",
3
- "version": "0.3.12",
3
+ "version": "0.3.13",
4
4
  "keywords": [
5
5
  "core",
6
6
  "zuz",