@zuzjs/core 0.3.14 → 0.3.15

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
- 'use strict';var E=require('axios'),J=require('fs/promises'),K=require('hashids'),T=require('js-cookie'),Q=require('md5'),d=require('moment'),nanoid=require('nanoid'),B=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 d__default=/*#__PURE__*/_interopDefault(d);var B__default=/*#__PURE__*/_interopDefault(B);/* ZuzJS Core */
2
- var M=["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 L=/^[0-9a-fA-F]{3}$|^[0-9a-fA-F]{6}$/,F=/^rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*((0|1|0?\.\d+)\s*))?\)$/,U=/^hsl\(\s*(\d{1,3})\s*,\s*(\d{1,3})%\s*,\s*(\d{1,3})%\s*\)$/;var G=(r=>(r.Asc="ASC",r.Desc="DESC",r))(G||{});var P=class{_;constructor(t){this._=t;}isIP(){return this.isIPv4()||this.isIPv6()}isIPv4(){return B__default.default.v4({exact:true}).test(this._)}isIPv6(){return B__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,c)=>{if(o===c)return true;if(o===null||typeof o!="object"||c===null||typeof c!="object")return false;if(Array.isArray(o)&&Array.isArray(c)){if(o.length!==c.length)return false;for(let a=0;a<o.length;a++)if(!s(o[a],c[a]))return false;return true}if(this.isObjectValue(o)&&this.isObjectValue(c)){let a=Object.keys(o),u=Object.keys(c);if(a.length!==u.length)return false;for(let h of a)if(!u.includes(h)||!s(o[h],c[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._)}},V=e=>new P(e),N=V;var S=class{_events;constructor(){this._events=[];}on(t,r,n){let s=this._events.find(c=>c.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 c=this._events.find(a=>a.event===t);c&&(c.listeners=c.listeners.filter(a=>a.id!==i),c.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);}},Y=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),$e=(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}},De=e=>Q__default.default(e),He=e=>te(ee(11111111111,999999999999)),qe=e=>nanoid.nanoid(e),I=e=>`${e.charAt(0).toUpperCase()}${e.substring(1,e.length)}`,We=e=>decodeURIComponent(e.replace(/\+/g,"%20")),ze=e=>encodeURIComponent(e),Me=(e,t)=>`${e}${t!==1?"s":""}`,re=e=>L.test(e),ne=e=>F.test(e),se=e=>U.test(e),Le=e=>M.includes(e.toLowerCase()),Fe=e=>re(e)||ne(e)||se(e),Ue=(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),[]),Be=e=>{if(!e.trim())return "";let t=e.split(/\s+/).filter(Boolean);return oe(t).join(" ")},Ie=()=>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},O=(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},v=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}};async function Ze(e,t,r=60,n=false,s={},i){let o=A(r,n,s,i),{finalData:c,contentType:a}=O(t,o);return v({method:"post",url:e,data:c,timeout:o.timeout*1e3,withCredentials:o.withCredentials,headers:{"Content-Type":a,...o.headers??{}},onUploadProgress:o.onProgress},o)}async function Ge(e,t=60,r=false,n={}){let s=A(t,r,n);return v({method:"get",url:e,timeout:s.timeout*1e3,withCredentials:s.withCredentials,headers:s.headers},s)}async function Ve(e,t,r=60,n=false,s={},i){let o=A(r,n,s,i),{finalData:c,contentType:a}=O(t,o);return v({method:"put",url:e,data:c,timeout:o.timeout*1e3,withCredentials:o.withCredentials,headers:{"Content-Type":a,...o.headers??{}},onUploadProgress:o.onProgress},o)}async function Ye(e,t,r=60,n=false,s={},i){let o=A(r,n,s,i),{finalData:c,contentType:a}=O(t,o);return v({method:"patch",url:e,data:c,timeout:o.timeout*1e3,withCredentials:o.withCredentials,headers:{"Content-Type":a,...o.headers??{}},onUploadProgress:o.onProgress},o)}var 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 d__default.default().format(r);if(e instanceof Date)return d__default.default(e).format(r);if(typeof e=="string"&&isNaN(Number(e)))return d__default.default(e).format(r);let n=Number(e);return n>9999999999?d__default.default(n).format(r):d__default.default.unix(n).format(r)},Xe=e=>{if(e instanceof Date)return d__default.default(e).fromNow();if(typeof e=="string"&&isNaN(Number(e)))return d__default.default(e).fromNow();let t=Number(e);return t>9999999999?d__default.default(t).fromNow():d__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:c,symbol:a}=i,u=new Intl.NumberFormat(t,{style:"currency",currency:o,currencyDisplay:c,minimumFractionDigits:s||+e%1>0?n:0,maximumFractionDigits:s||+e%1>0?n:0}).format(+e);return a?u.replace(new RegExp(`\\${o}`,"g"),a):u}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,c=/(^([\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,u=-a,h=e.caseSensitive?l=>`${l}`.replace(n,""):l=>l.toString().toLowerCase().replace(n,""),j=l=>l.replace(o,"\0$1\0").replace(/\0$/,"").replace(/^\0/,"").split("\0"),$=(l,C)=>(!l.match(t)||C===1)&&parseFloat(l)||l.replace(r," ").replace(n,"")||0;return function(l,C){let f=h(l),g=h(C);if(!f&&!g)return 0;if(!f&&g)return u;if(f&&!g)return a;let R=j(f),D=j(g),_=f.match(i),k=g.match(i),y=_&&k?parseInt(_[0],16):R.length!==1&&Date.parse(f),b=_&&k?parseInt(k[0],16):y&&g.match(c)&&Date.parse(g)||null;if(b){if(y===b)return 0;if(typeof y=="number"&&typeof b=="number"&&y<b)return u;if(typeof y=="number"&&y>b)return a}let H=R.length,q=D.length;for(let x=0,W=Math.max(H,q);x<W;x+=1){let p=$(R[x]||"",H),m=$(D[x]||"",q);if(isNaN(p)!==isNaN(m))return isNaN(p)?a:u;if(s.test(p+m)&&p.localeCompare){let z=p.localeCompare(m);if(z>0)return a;if(z<0)return u;if(x===W-1)return 0}if(p<m)return u;if(p>m)return a;if(`${p}`<`${m}`)return u;if(`${p}`>`${m}`)return a}return 0}},ot=(e,t=false)=>e.toLowerCase().split(/[^a-zA-Z0-9]+/).map((r,n)=>n===0?t?I(r):r:I(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),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)),lt=(e,t)=>setTimeout(e,t||1e3),pt=e=>Object.keys(e).filter(t=>isNaN(Number(t))),dt=async e=>{try{return await J__default.default.access(e),!0}catch{return false}},gt=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}},ce=e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),ht=(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()},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:c})=>{try{T__default.default.set(e,r||typeof t=="object"?JSON.stringify(t):t,{expires:s,path:n,domain:i,secure:o,sameSite:c});}catch(a){console.log("--- Error setting cookie",a);}};exports.MD5=De;exports.PubSub=Y;exports.SORT=G;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=ce;exports.exists=dt;exports.formatNumber=tt;exports.formatSize=rt;exports.fromHash=$e;exports.getCancelToken=Ie;exports.getCookie=ft;exports.hexToRgba=Ue;exports.isColor=Fe;exports.isColorName=Le;exports.isHexColor=re;exports.isHslColor=se;exports.isRgbaColor=ne;exports.natsort=st;exports.numberInRange=ee;exports.pluralize=Me;exports.removeCookie=yt;exports.removeDuplicateWords=Be;exports.removeDuplicates=oe;exports.removeWords=ht;exports.setCookie=bt;exports.sleep=ut;exports.slugify=ct;exports.time=Qe;exports.timeSince=Xe;exports.toHash=te;exports.ucfirst=I;exports.urlBase64ToUint8Array=gt;exports.urldecode=We;exports.urlencode=ze;exports.uuid=He;exports.uuid2=qe;exports.withCredentials=Ke;exports.withDelay=lt;exports.withGet=Ge;exports.withPatch=Ye;exports.withPost=Ze;exports.withPut=Ve;exports.withTime=Je;
1
+ 'use strict';var E=require('axios'),J=require('fs/promises'),K=require('hashids'),T=require('js-cookie'),Q=require('md5'),d=require('moment'),nanoid=require('nanoid'),F=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 d__default=/*#__PURE__*/_interopDefault(d);var F__default=/*#__PURE__*/_interopDefault(F);/* ZuzJS Core */
2
+ var M=["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 L=/^[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*))?\)$/,B=/^hsl\(\s*(\d{1,3})\s*,\s*(\d{1,3})%\s*,\s*(\d{1,3})%\s*\)$/;var G=(r=>(r.Asc="ASC",r.Desc="DESC",r))(G||{});var P=class{_;constructor(t){this._=t;}isIP(){return this.isIPv4()||this.isIPv6()}isIPv4(){return F__default.default.v4({exact:true}).test(this._)}isIPv6(){return F__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,o=(s,u)=>{if(s===u)return true;if(s===null||typeof s!="object"||u===null||typeof u!="object")return false;if(Array.isArray(s)&&Array.isArray(u)){if(s.length!==u.length)return false;for(let a=0;a<s.length;a++)if(!o(s[a],u[a]))return false;return true}if(this.isObjectValue(s)&&this.isObjectValue(u)){let a=Object.keys(s),c=Object.keys(u);if(a.length!==c.length)return false;for(let h of a)if(!c.includes(h)||!o(s[h],u[h]))return false;return true}return false},i=s=>typeof s=="object"&&s!==null&&!Array.isArray(s);return this.isObjectValue=i,Array.isArray(r)&&Array.isArray(n)||i(r)&&i(n)?o(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,(o,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,s)=>t==="desc"?s.localeCompare(i):i.localeCompare(s)),o={};for(let i of n)o[i]=r[i];return this._=o,this}value(){return this._}valueOf(){return this._}toString(){return String(this._)}[Symbol.toPrimitive](t){return t==="number"?Number(this._):t==="boolean"?!!this._:String(this._)}},V=e=>new P(e),S=V;var N=class{_events;constructor(){this._events=[];}on(t,r,n){let o=this._events.find(u=>u.event===t),i=Symbol("listener_id"),s={fun:r,context:n,id:i};return o?o.listeners.push(s):this._events.push({event:t,listeners:[s]}),()=>{let u=this._events.find(a=>a.event===t);u&&(u.listeners=u.listeners.filter(a=>a.id!==i),u.listeners.length===0&&(this._events=this._events.filter(a=>a.event!==t)));}}off(t,r){let n=this._events.find(o=>o.event===t);n&&(n.listeners=n.listeners.filter(o=>o.fun!==r),n.listeners.length===0&&(this._events=this._events.filter(o=>o.event!==t)));}emit(t,...r){let n=this._events.find(o=>o.event===t);n&&[...n.listeners].forEach(({fun:o,context:i})=>{try{o.apply(i,r);}catch(s){console.error(`Error during event '${String(t)}' emission:`,s);}});}removeAllListeners(t){this._events=this._events.filter(r=>r.event!==t);}},Y=N;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),$e=(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}},De=e=>Q__default.default(e),He=e=>te(ee(11111111111,999999999999)),qe=e=>nanoid.nanoid(e),I=e=>`${e.charAt(0).toUpperCase()}${e.substring(1,e.length)}`,We=e=>decodeURIComponent(e.replace(/\+/g,"%20")),ze=e=>encodeURIComponent(e),Me=(e,t)=>`${e}${t!==1?"s":""}`,re=e=>L.test(e),ne=e=>U.test(e),se=e=>B.test(e),Le=e=>M.includes(e.toLowerCase()),Ue=e=>re(e)||ne(e)||se(e),Be=(e,t=1)=>{e=e.replace(/^#/,""),e.length===3&&(e=e.split("").map(s=>s+s).join(""));let r=parseInt(e,16),n=r>>16&255,o=r>>8&255,i=r&255;return `rgba(${n}, ${o}, ${i}, ${t})`},oe=e=>e.reduce((t,r)=>(t.includes(r)||t.push(r),t),[]),Fe=e=>{if(!e.trim())return "";let t=e.split(/\s+/).filter(Boolean);return oe(t).join(" ")},Ie=()=>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},O=(e,t)=>{let r=T__default.default.get(),n=e,o="application/json";if(e instanceof FormData){if(o="multipart/form-data",t.appendCookiesToBody)for(let[i,s]of Object.entries(r))e.append(i,s);}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:o}},ae=(e,t)=>{if(t.returnRawResponse)return e;if(e.data&&(t.ignoreKind||"kind"in e.data))return e.data;throw e.data},v=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}};async function Ze(e,t,r=60,n=false,o={},i){let s=A(r,n,o,i),{finalData:u,contentType:a}=O(t,s);return v({method:"post",url:e,data:u,timeout:s.timeout*1e3,withCredentials:s.withCredentials,headers:{"Content-Type":a,...s.headers??{}},onUploadProgress:s.onProgress},s)}async function Ge(e,t=60,r=false,n={}){let o=A(t,r,n);return v({method:"get",url:e,timeout:o.timeout*1e3,withCredentials:o.withCredentials,headers:o.headers},o)}async function Ve(e,t,r=60,n=false,o={},i){let s=A(r,n,o,i),{finalData:u,contentType:a}=O(t,s);return v({method:"put",url:e,data:u,timeout:s.timeout*1e3,withCredentials:s.withCredentials,headers:{"Content-Type":a,...s.headers??{}},onUploadProgress:s.onProgress},s)}async function Ye(e,t,r=60,n=false,o={},i){let s=A(r,n,o,i),{finalData:u,contentType:a}=O(t,s);return v({method:"patch",url:e,data:u,timeout:s.timeout*1e3,withCredentials:s.withCredentials,headers:{"Content-Type":a,...s.headers??{}},onUploadProgress:s.onProgress},s)}var 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 d__default.default().format(r);if(e instanceof Date)return d__default.default(e).format(r);if(typeof e=="string"&&isNaN(Number(e)))return d__default.default(e).format(r);let n=Number(e);return n>9999999999?d__default.default(n).format(r):d__default.default.unix(n).format(r)},Xe=e=>{if(e instanceof Date)return d__default.default(e).fromNow();if(typeof e=="string"&&isNaN(Number(e)))return d__default.default(e).fromNow();let t=Number(e);return t>9999999999?d__default.default(t).fromNow():d__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:o=false,currency:i})=>{if(r==="currency"&&!i)throw new TypeError("Currency code is required with currency style.");if(i){let{code:s,style:u,symbol:a}=i,c=new Intl.NumberFormat(t,{style:"currency",currency:s,currencyDisplay:u,minimumFractionDigits:o||+e%1>0?n:0,maximumFractionDigits:o||+e%1>0?n:0}).format(+e);return a?c.replace(new RegExp(`\\${s}`,"g"),a):c}return new Intl.NumberFormat(t,{style:r,minimumFractionDigits:o?n:+e%1>0?2:0,maximumFractionDigits:o?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)),o=typeof n=="string"?parseInt(n):n;return (r/Math.pow(1024,o)).toFixed(2)+" "+t[o]},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(o){r(o);}document.body.removeChild(n);}),st=(e={direction:"ASC",caseSensitive:false})=>{let t=/^0/,r=/\s+/g,n=/^\s+|\s+$/g,o=/[^\x00-\x80]/,i=/^0x[0-9a-f]+$/i,s=/(0x[\da-fA-F]+|(^[\+\-]?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?(?=\D|\s|$))|\d+)/g,u=/(^([\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?l=>`${l}`.replace(n,""):l=>l.toString().toLowerCase().replace(n,""),j=l=>l.replace(s,"\0$1\0").replace(/\0$/,"").replace(/^\0/,"").split("\0"),$=(l,C)=>(!l.match(t)||C===1)&&parseFloat(l)||l.replace(r," ").replace(n,"")||0;return function(l,C){let f=h(l),g=h(C);if(!f&&!g)return 0;if(!f&&g)return c;if(f&&!g)return a;let R=j(f),D=j(g),_=f.match(i),k=g.match(i),y=_&&k?parseInt(_[0],16):R.length!==1&&Date.parse(f),b=_&&k?parseInt(k[0],16):y&&g.match(u)&&Date.parse(g)||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 H=R.length,q=D.length;for(let x=0,W=Math.max(H,q);x<W;x+=1){let p=$(R[x]||"",H),m=$(D[x]||"",q);if(isNaN(p)!==isNaN(m))return isNaN(p)?a:c;if(o.test(p+m)&&p.localeCompare){let z=p.localeCompare(m);if(z>0)return a;if(z<0)return c;if(x===W-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?I(r):r:I(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),ut=(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)),lt=(e,t)=>setTimeout(e,t||1e3),pt=e=>Object.keys(e).filter(t=>isNaN(Number(t))),dt=async e=>{try{return await J__default.default.access(e),!0}catch{return false}},gt=e=>{let t=(e??"").trim();if(t.length===0)return new Uint8Array(0);let r="=".repeat((4-t.length%4)%4),n=(t+r).replace(/-/g,"+").replace(/_/g,"/"),o=window.atob(n),i=new Uint8Array(o.length);for(let s=0;s<o.length;++s)i[s]=o.charCodeAt(s);return i},mt=e=>{let t=e??"",r=[],n=0;return t.length>=8?n++:r.push("Use at least 8 characters"),/[a-z]/.test(t)?n++:r.push("Add lowercase letters"),/[A-Z]/.test(t)?n++:r.push("Add uppercase letters"),/\d/.test(t)?n++:r.push("Include numbers"),/[^A-Za-z0-9]/.test(t)?n++:r.push("Add special characters (e.g. !, @, #)"),{score:n,result:n<=2?"Weak":n==3?"Moderate":n==4?"Strong":"Excellent",suggestion:r}},ue=e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),ht=(e,t)=>{if(t.length===0)return e.trim();let r=t.map(o=>o.trim()).filter(Boolean).map(ue);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:o,domain:i,secure:s,sameSite:u})=>{try{T__default.default.set(e,r||typeof t=="object"?JSON.stringify(t):t,{expires:o,path:n,domain:i,secure:s,sameSite:u});}catch(a){console.log("--- Error setting cookie",a);}};exports.MD5=De;exports.PubSub=Y;exports.SORT=G;exports._=S;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=ue;exports.exists=dt;exports.formatNumber=tt;exports.formatSize=rt;exports.fromHash=$e;exports.getCancelToken=Ie;exports.getCookie=ft;exports.hexToRgba=Be;exports.isColor=Ue;exports.isColorName=Le;exports.isHexColor=re;exports.isHslColor=se;exports.isRgbaColor=ne;exports.natsort=st;exports.numberInRange=ee;exports.pluralize=Me;exports.removeCookie=yt;exports.removeDuplicateWords=Fe;exports.removeDuplicates=oe;exports.removeWords=ht;exports.setCookie=bt;exports.sleep=ct;exports.slugify=ut;exports.time=Qe;exports.timeSince=Xe;exports.toHash=te;exports.ucfirst=I;exports.urlBase64ToUint8Array=gt;exports.urldecode=We;exports.urlencode=ze;exports.uuid=He;exports.uuid2=qe;exports.withCredentials=Ke;exports.withDelay=lt;exports.withGet=Ge;exports.withPatch=Ye;exports.withPost=Ze;exports.withPut=Ve;exports.withTime=Je;
package/dist/index.d.cts CHANGED
@@ -172,8 +172,8 @@ declare const sleep: (ms: number) => Promise<any>;
172
172
  declare const withDelay: (callback: (value: any) => void, delay?: number) => NodeJS.Timeout;
173
173
  declare const enumToKeys: <T extends Record<string, any>>(obj: T) => Array<keyof T>;
174
174
  declare const exists: (path: string) => Promise<boolean>;
175
- declare const urlBase64ToUint8Array: (base64String: string) => Uint8Array;
176
- declare const checkPasswordStrength: (password: string) => {
175
+ declare const urlBase64ToUint8Array: (base64String: string | null | undefined) => Uint8Array;
176
+ declare const checkPasswordStrength: (password: string | null | undefined) => {
177
177
  score: number;
178
178
  result: string;
179
179
  suggestion: string[];
package/dist/index.d.ts CHANGED
@@ -172,8 +172,8 @@ declare const sleep: (ms: number) => Promise<any>;
172
172
  declare const withDelay: (callback: (value: any) => void, delay?: number) => NodeJS.Timeout;
173
173
  declare const enumToKeys: <T extends Record<string, any>>(obj: T) => Array<keyof T>;
174
174
  declare const exists: (path: string) => Promise<boolean>;
175
- declare const urlBase64ToUint8Array: (base64String: string) => Uint8Array;
176
- declare const checkPasswordStrength: (password: string) => {
175
+ declare const urlBase64ToUint8Array: (base64String: string | null | undefined) => Uint8Array;
176
+ declare const checkPasswordStrength: (password: string | null | undefined) => {
177
177
  score: number;
178
178
  result: string;
179
179
  suggestion: string[];
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import O from'axios';import Q from'fs/promises';import Z from'hashids';import A from'js-cookie';import X from'md5';import d from'moment';import {nanoid}from'nanoid';import I from'ip-regex';var L=["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 F=/^[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*))?\)$/,B=/^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 N=class{_;constructor(t){this._=t;}isIP(){return this.isIPv4()||this.isIPv6()}isIPv4(){return I.v4({exact:true}).test(this._)}isIPv6(){return I.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,c)=>{if(o===c)return true;if(o===null||typeof o!="object"||c===null||typeof c!="object")return false;if(Array.isArray(o)&&Array.isArray(c)){if(o.length!==c.length)return false;for(let a=0;a<o.length;a++)if(!s(o[a],c[a]))return false;return true}if(this.isObjectValue(o)&&this.isObjectValue(c)){let a=Object.keys(o),u=Object.keys(c);if(a.length!==u.length)return false;for(let h of a)if(!u.includes(h)||!s(o[h],c[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 N(e),S=Y;var E=class{_events;constructor(){this._events=[];}on(t,r,n){let s=this._events.find(c=>c.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 c=this._events.find(a=>a.event===t);c&&(c.listeners=c.listeners.filter(a=>a.id!==i),c.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 G="zuzjs-core",te=(e,t)=>Math.floor(Math.random()*(t-e+1))+e,re=(e,t=6,r=null)=>new Z(r||G,t).encode(e),De=(e,t=null)=>{try{let r=new Z(t||G,+process.env.HASHIDS_LENGTH).decode(e);return r.length>=0?Number(r[0]):0}catch{return 0}},He=e=>X(e),qe=e=>re(te(11111111111,999999999999)),We=e=>nanoid(e),K=e=>`${e.charAt(0).toUpperCase()}${e.substring(1,e.length)}`,ze=e=>decodeURIComponent(e.replace(/\+/g,"%20")),Me=e=>encodeURIComponent(e),Le=(e,t)=>`${e}${t!==1?"s":""}`,ne=e=>F.test(e),se=e=>U.test(e),oe=e=>B.test(e),Fe=e=>L.includes(e.toLowerCase()),Ue=e=>ne(e)||se(e)||oe(e),Be=(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),[]),Ie=e=>{if(!e.trim())return "";let t=e.split(/\s+/).filter(Boolean);return ie(t).join(" ")},Ke=()=>O.CancelToken.source(),Ze=e=>O.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."}},v=(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}},ce=(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 O(e);return ce(r,t)}catch(r){throw r?.response?.data?r.response.data:r?.code==="ERR_NETWORK"?ae(r):r}};async function Ge(e,t,r=60,n=false,s={},i){let o=v(r,n,s,i),{finalData:c,contentType:a}=j(t,o);return C({method:"post",url:e,data:c,timeout:o.timeout*1e3,withCredentials:o.withCredentials,headers:{"Content-Type":a,...o.headers??{}},onUploadProgress:o.onProgress},o)}async function Ve(e,t=60,r=false,n={}){let s=v(t,r,n);return C({method:"get",url:e,timeout:s.timeout*1e3,withCredentials:s.withCredentials,headers:s.headers},s)}async function Ye(e,t,r=60,n=false,s={},i){let o=v(r,n,s,i),{finalData:c,contentType:a}=j(t,o);return C({method:"put",url:e,data:c,timeout:o.timeout*1e3,withCredentials:o.withCredentials,headers:{"Content-Type":a,...o.headers??{}},onUploadProgress:o.onProgress},o)}async function Je(e,t,r=60,n=false,s={},i){let o=v(r,n,s,i),{finalData:c,contentType:a}=j(t,o);return C({method:"patch",url:e,data:c,timeout:o.timeout*1e3,withCredentials:o.withCredentials,headers:{"Content-Type":a,...o.headers??{}},onUploadProgress:o.onProgress},o)}var 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 d().format(r);if(e instanceof Date)return d(e).format(r);if(typeof e=="string"&&isNaN(Number(e)))return d(e).format(r);let n=Number(e);return n>9999999999?d(n).format(r):d.unix(n).format(r)},et=e=>{if(e instanceof Date)return d(e).fromNow();if(typeof e=="string"&&isNaN(Number(e)))return d(e).fromNow();let t=Number(e);return t>9999999999?d(t).fromNow():d.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:c,symbol:a}=i,u=new Intl.NumberFormat(t,{style:"currency",currency:o,currencyDisplay:c,minimumFractionDigits:s||+e%1>0?n:0,maximumFractionDigits:s||+e%1>0?n:0}).format(+e);return a?u.replace(new RegExp(`\\${o}`,"g"),a):u}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,c=/(^([\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,u=-a,h=e.caseSensitive?l=>`${l}`.replace(n,""):l=>l.toString().toLowerCase().replace(n,""),$=l=>l.replace(o,"\0$1\0").replace(/\0$/,"").replace(/^\0/,"").split("\0"),D=(l,R)=>(!l.match(t)||R===1)&&parseFloat(l)||l.replace(r," ").replace(n,"")||0;return function(l,R){let f=h(l),g=h(R);if(!f&&!g)return 0;if(!f&&g)return u;if(f&&!g)return a;let _=$(f),H=$(g),k=f.match(i),P=g.match(i),y=k&&P?parseInt(k[0],16):_.length!==1&&Date.parse(f),b=k&&P?parseInt(P[0],16):y&&g.match(c)&&Date.parse(g)||null;if(b){if(y===b)return 0;if(typeof y=="number"&&typeof b=="number"&&y<b)return u;if(typeof y=="number"&&y>b)return a}let q=_.length,W=H.length;for(let x=0,z=Math.max(q,W);x<z;x+=1){let p=D(_[x]||"",q),m=D(H[x]||"",W);if(isNaN(p)!==isNaN(m))return isNaN(p)?a:u;if(s.test(p+m)&&p.localeCompare){let M=p.localeCompare(m);if(M>0)return a;if(M<0)return u;if(x===z-1)return 0}if(p<m)return u;if(p>m)return a;if(`${p}`<`${m}`)return u;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(),ct=(e,t,r)=>Math.min(Math.max(e,t),r),ut=(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"),""),lt=e=>new Promise(t=>setTimeout(t,e)),pt=(e,t)=>setTimeout(e,t||1e3),dt=e=>Object.keys(e).filter(t=>isNaN(Number(t))),gt=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}},ue=e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),ft=(e,t)=>{if(t.length===0)return e.trim();let r=t.map(s=>s.trim()).filter(Boolean).map(ue);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:c})=>{try{A.set(e,r||typeof t=="object"?JSON.stringify(t):t,{expires:s,path:n,domain:i,secure:o,sameSite:c});}catch(a){console.log("--- Error setting cookie",a);}};export{He as MD5,J as PubSub,V as SORT,S as _,G as __SALT,tt as arrayRand,it as camelCase,at as camelCaseToDash,ht as checkPasswordStrength,ct as clamp,st as copyToClipboard,dt as enumToKeys,ue as escapeRegex,gt as exists,rt as formatNumber,nt as formatSize,De as fromHash,Ke as getCancelToken,yt as getCookie,Be as hexToRgba,Ue as isColor,Fe as isColorName,ne as isHexColor,oe as isHslColor,se as isRgbaColor,ot as natsort,te as numberInRange,Le as pluralize,bt as removeCookie,Ie as removeDuplicateWords,ie as removeDuplicates,ft as removeWords,xt as setCookie,lt as sleep,ut as slugify,Xe as time,et as timeSince,re as toHash,K as ucfirst,mt as urlBase64ToUint8Array,ze as urldecode,Me as urlencode,qe as uuid,We as uuid2,Ze as withCredentials,pt as withDelay,Ve as withGet,Je as withPatch,Ge as withPost,Ye as withPut,Qe as withTime};
1
+ import O from'axios';import Q from'fs/promises';import Z from'hashids';import A from'js-cookie';import X from'md5';import d from'moment';import {nanoid}from'nanoid';import I from'ip-regex';var L=["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*))?\)$/,F=/^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 S=class{_;constructor(t){this._=t;}isIP(){return this.isIPv4()||this.isIPv6()}isIPv4(){return I.v4({exact:true}).test(this._)}isIPv6(){return I.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,o=(s,u)=>{if(s===u)return true;if(s===null||typeof s!="object"||u===null||typeof u!="object")return false;if(Array.isArray(s)&&Array.isArray(u)){if(s.length!==u.length)return false;for(let a=0;a<s.length;a++)if(!o(s[a],u[a]))return false;return true}if(this.isObjectValue(s)&&this.isObjectValue(u)){let a=Object.keys(s),c=Object.keys(u);if(a.length!==c.length)return false;for(let h of a)if(!c.includes(h)||!o(s[h],u[h]))return false;return true}return false},i=s=>typeof s=="object"&&s!==null&&!Array.isArray(s);return this.isObjectValue=i,Array.isArray(r)&&Array.isArray(n)||i(r)&&i(n)?o(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,(o,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,s)=>t==="desc"?s.localeCompare(i):i.localeCompare(s)),o={};for(let i of n)o[i]=r[i];return this._=o,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 S(e),N=Y;var E=class{_events;constructor(){this._events=[];}on(t,r,n){let o=this._events.find(u=>u.event===t),i=Symbol("listener_id"),s={fun:r,context:n,id:i};return o?o.listeners.push(s):this._events.push({event:t,listeners:[s]}),()=>{let u=this._events.find(a=>a.event===t);u&&(u.listeners=u.listeners.filter(a=>a.id!==i),u.listeners.length===0&&(this._events=this._events.filter(a=>a.event!==t)));}}off(t,r){let n=this._events.find(o=>o.event===t);n&&(n.listeners=n.listeners.filter(o=>o.fun!==r),n.listeners.length===0&&(this._events=this._events.filter(o=>o.event!==t)));}emit(t,...r){let n=this._events.find(o=>o.event===t);n&&[...n.listeners].forEach(({fun:o,context:i})=>{try{o.apply(i,r);}catch(s){console.error(`Error during event '${String(t)}' emission:`,s);}});}removeAllListeners(t){this._events=this._events.filter(r=>r.event!==t);}},J=E;var G="zuzjs-core",te=(e,t)=>Math.floor(Math.random()*(t-e+1))+e,re=(e,t=6,r=null)=>new Z(r||G,t).encode(e),De=(e,t=null)=>{try{let r=new Z(t||G,+process.env.HASHIDS_LENGTH).decode(e);return r.length>=0?Number(r[0]):0}catch{return 0}},He=e=>X(e),qe=e=>re(te(11111111111,999999999999)),We=e=>nanoid(e),K=e=>`${e.charAt(0).toUpperCase()}${e.substring(1,e.length)}`,ze=e=>decodeURIComponent(e.replace(/\+/g,"%20")),Me=e=>encodeURIComponent(e),Le=(e,t)=>`${e}${t!==1?"s":""}`,ne=e=>U.test(e),se=e=>B.test(e),oe=e=>F.test(e),Ue=e=>L.includes(e.toLowerCase()),Be=e=>ne(e)||se(e)||oe(e),Fe=(e,t=1)=>{e=e.replace(/^#/,""),e.length===3&&(e=e.split("").map(s=>s+s).join(""));let r=parseInt(e,16),n=r>>16&255,o=r>>8&255,i=r&255;return `rgba(${n}, ${o}, ${i}, ${t})`},ie=e=>e.reduce((t,r)=>(t.includes(r)||t.push(r),t),[]),Ie=e=>{if(!e.trim())return "";let t=e.split(/\s+/).filter(Boolean);return ie(t).join(" ")},Ke=()=>O.CancelToken.source(),Ze=e=>O.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."}},v=(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,o="application/json";if(e instanceof FormData){if(o="multipart/form-data",t.appendCookiesToBody)for(let[i,s]of Object.entries(r))e.append(i,s);}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:o}},ue=(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 O(e);return ue(r,t)}catch(r){throw r?.response?.data?r.response.data:r?.code==="ERR_NETWORK"?ae(r):r}};async function Ge(e,t,r=60,n=false,o={},i){let s=v(r,n,o,i),{finalData:u,contentType:a}=j(t,s);return C({method:"post",url:e,data:u,timeout:s.timeout*1e3,withCredentials:s.withCredentials,headers:{"Content-Type":a,...s.headers??{}},onUploadProgress:s.onProgress},s)}async function Ve(e,t=60,r=false,n={}){let o=v(t,r,n);return C({method:"get",url:e,timeout:o.timeout*1e3,withCredentials:o.withCredentials,headers:o.headers},o)}async function Ye(e,t,r=60,n=false,o={},i){let s=v(r,n,o,i),{finalData:u,contentType:a}=j(t,s);return C({method:"put",url:e,data:u,timeout:s.timeout*1e3,withCredentials:s.withCredentials,headers:{"Content-Type":a,...s.headers??{}},onUploadProgress:s.onProgress},s)}async function Je(e,t,r=60,n=false,o={},i){let s=v(r,n,o,i),{finalData:u,contentType:a}=j(t,s);return C({method:"patch",url:e,data:u,timeout:s.timeout*1e3,withCredentials:s.withCredentials,headers:{"Content-Type":a,...s.headers??{}},onUploadProgress:s.onProgress},s)}var 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 d().format(r);if(e instanceof Date)return d(e).format(r);if(typeof e=="string"&&isNaN(Number(e)))return d(e).format(r);let n=Number(e);return n>9999999999?d(n).format(r):d.unix(n).format(r)},et=e=>{if(e instanceof Date)return d(e).fromNow();if(typeof e=="string"&&isNaN(Number(e)))return d(e).fromNow();let t=Number(e);return t>9999999999?d(t).fromNow():d.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:o=false,currency:i})=>{if(r==="currency"&&!i)throw new TypeError("Currency code is required with currency style.");if(i){let{code:s,style:u,symbol:a}=i,c=new Intl.NumberFormat(t,{style:"currency",currency:s,currencyDisplay:u,minimumFractionDigits:o||+e%1>0?n:0,maximumFractionDigits:o||+e%1>0?n:0}).format(+e);return a?c.replace(new RegExp(`\\${s}`,"g"),a):c}return new Intl.NumberFormat(t,{style:r,minimumFractionDigits:o?n:+e%1>0?2:0,maximumFractionDigits:o?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)),o=typeof n=="string"?parseInt(n):n;return (r/Math.pow(1024,o)).toFixed(2)+" "+t[o]},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(o){r(o);}document.body.removeChild(n);}),ot=(e={direction:"ASC",caseSensitive:false})=>{let t=/^0/,r=/\s+/g,n=/^\s+|\s+$/g,o=/[^\x00-\x80]/,i=/^0x[0-9a-f]+$/i,s=/(0x[\da-fA-F]+|(^[\+\-]?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?(?=\D|\s|$))|\d+)/g,u=/(^([\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?l=>`${l}`.replace(n,""):l=>l.toString().toLowerCase().replace(n,""),$=l=>l.replace(s,"\0$1\0").replace(/\0$/,"").replace(/^\0/,"").split("\0"),D=(l,R)=>(!l.match(t)||R===1)&&parseFloat(l)||l.replace(r," ").replace(n,"")||0;return function(l,R){let f=h(l),g=h(R);if(!f&&!g)return 0;if(!f&&g)return c;if(f&&!g)return a;let _=$(f),H=$(g),k=f.match(i),P=g.match(i),y=k&&P?parseInt(k[0],16):_.length!==1&&Date.parse(f),b=k&&P?parseInt(P[0],16):y&&g.match(u)&&Date.parse(g)||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=_.length,W=H.length;for(let x=0,z=Math.max(q,W);x<z;x+=1){let p=D(_[x]||"",q),m=D(H[x]||"",W);if(isNaN(p)!==isNaN(m))return isNaN(p)?a:c;if(o.test(p+m)&&p.localeCompare){let M=p.localeCompare(m);if(M>0)return a;if(M<0)return c;if(x===z-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(),ut=(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"),""),lt=e=>new Promise(t=>setTimeout(t,e)),pt=(e,t)=>setTimeout(e,t||1e3),dt=e=>Object.keys(e).filter(t=>isNaN(Number(t))),gt=async e=>{try{return await Q.access(e),!0}catch{return false}},mt=e=>{let t=(e??"").trim();if(t.length===0)return new Uint8Array(0);let r="=".repeat((4-t.length%4)%4),n=(t+r).replace(/-/g,"+").replace(/_/g,"/"),o=window.atob(n),i=new Uint8Array(o.length);for(let s=0;s<o.length;++s)i[s]=o.charCodeAt(s);return i},ht=e=>{let t=e??"",r=[],n=0;return t.length>=8?n++:r.push("Use at least 8 characters"),/[a-z]/.test(t)?n++:r.push("Add lowercase letters"),/[A-Z]/.test(t)?n++:r.push("Add uppercase letters"),/\d/.test(t)?n++:r.push("Include numbers"),/[^A-Za-z0-9]/.test(t)?n++:r.push("Add special characters (e.g. !, @, #)"),{score:n,result:n<=2?"Weak":n==3?"Moderate":n==4?"Strong":"Excellent",suggestion:r}},ce=e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),ft=(e,t)=>{if(t.length===0)return e.trim();let r=t.map(o=>o.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:o,domain:i,secure:s,sameSite:u})=>{try{A.set(e,r||typeof t=="object"?JSON.stringify(t):t,{expires:o,path:n,domain:i,secure:s,sameSite:u});}catch(a){console.log("--- Error setting cookie",a);}};export{He as MD5,J as PubSub,V as SORT,N as _,G as __SALT,tt as arrayRand,it as camelCase,at as camelCaseToDash,ht as checkPasswordStrength,ut as clamp,st as copyToClipboard,dt as enumToKeys,ce as escapeRegex,gt as exists,rt as formatNumber,nt as formatSize,De as fromHash,Ke as getCancelToken,yt as getCookie,Fe as hexToRgba,Be as isColor,Ue as isColorName,ne as isHexColor,oe as isHslColor,se as isRgbaColor,ot as natsort,te as numberInRange,Le as pluralize,bt as removeCookie,Ie as removeDuplicateWords,ie as removeDuplicates,ft as removeWords,xt as setCookie,lt as sleep,ct as slugify,Xe as time,et as timeSince,re as toHash,K as ucfirst,mt as urlBase64ToUint8Array,ze as urldecode,Me as urlencode,qe as uuid,We as uuid2,Ze as withCredentials,pt as withDelay,Ve as withGet,Je as withPatch,Ge as withPost,Ye as withPut,Qe as withTime};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zuzjs/core",
3
- "version": "0.3.14",
3
+ "version": "0.3.15",
4
4
  "keywords": [
5
5
  "core",
6
6
  "zuz",