@zuzjs/core 0.3.16 → 0.3.17
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 +2 -2
- package/dist/index.d.cts +34 -1
- package/dist/index.d.ts +34 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
'use strict';var
|
|
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 I=/^[0-9a-fA-F]{3}$|^[0-9a-fA-F]{6}$/,L=/^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),l=Object.keys(c);if(a.length!==l.length)return false;for(let h of a)if(!l.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),S=V;var N=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=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),je=(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),F=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=>I.test(e),ne=e=>L.test(e),oe=e=>U.test(e),Ie=e=>M.includes(e.toLowerCase()),Le=e=>re(e)||ne(e)||oe(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})`},Be=()=>{let e=typeof window<"u"?performance.now():Date.now();return `#${(Math.floor(e*2654435769)&16777215).toString(16).padStart(6,"0")}`},se=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 se(t).join(" ")},Ke=()=>E__default.default.CancelToken.source(),Ze=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(!S(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 Ge(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 Ve(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 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:"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=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 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__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)},et=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()},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,l=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?l.replace(new RegExp(`\\${o}`,"g"),a):l}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]},ot=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,l=-a,h=e.caseSensitive?u=>`${u}`.replace(n,""):u=>u.toString().toLowerCase().replace(n,""),$=u=>u.replace(o,"\0$1\0").replace(/\0$/,"").replace(/^\0/,"").split("\0"),j=(u,C)=>(!u.match(t)||C===1)&&parseFloat(u)||u.replace(r," ").replace(n,"")||0;return function(u,C){let f=h(u),g=h(C);if(!f&&!g)return 0;if(!f&&g)return l;if(f&&!g)return a;let R=$(f),D=$(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 l;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=j(R[x]||"",H),m=j(D[x]||"",q);if(isNaN(p)!==isNaN(m))return isNaN(p)?a:l;if(s.test(p+m)&&p.localeCompare){let z=p.localeCompare(m);if(z>0)return a;if(z<0)return l;if(x===W-1)return 0}if(p<m)return l;if(p>m)return a;if(`${p}`<`${m}`)return l;if(`${p}`>`${m}`)return a}return 0}},it=(e,t=false)=>e.toLowerCase().split(/[^a-zA-Z0-9]+/).map((r,n)=>n===0?t?F(r):r:F(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),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"),""),ut=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 J__default.default.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,"/"),s=window.atob(n),i=new Uint8Array(s.length);for(let o=0;o<s.length;++o)i[o]=s.charCodeAt(o);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(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=T__default.default.get(e);return r?t?JSON.parse(r):r:null},bt=e=>T__default.default.remove(e),xt=({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._=S;exports.__SALT=Z;exports.arrayRand=tt;exports.camelCase=it;exports.camelCaseToDash=at;exports.checkPasswordStrength=ht;exports.clamp=ct;exports.copyToClipboard=ot;exports.enumToKeys=dt;exports.escapeRegex=ce;exports.exists=gt;exports.formatNumber=rt;exports.formatSize=nt;exports.fromHash=je;exports.generateColorHex=Be;exports.getCancelToken=Ke;exports.getCookie=yt;exports.hexToRgba=Ue;exports.isColor=Le;exports.isColorName=Ie;exports.isHexColor=re;exports.isHslColor=oe;exports.isRgbaColor=ne;exports.natsort=st;exports.numberInRange=ee;exports.pluralize=Me;exports.removeCookie=bt;exports.removeDuplicateWords=Fe;exports.removeDuplicates=se;exports.removeWords=ft;exports.setCookie=xt;exports.sleep=ut;exports.slugify=lt;exports.time=Xe;exports.timeSince=et;exports.toHash=te;exports.ucfirst=F;exports.urlBase64ToUint8Array=mt;exports.urldecode=We;exports.urlencode=ze;exports.uuid=He;exports.uuid2=qe;exports.withCredentials=Ze;exports.withDelay=pt;exports.withGet=Ve;exports.withPatch=Je;exports.withPost=Ge;exports.withPut=Ye;exports.withTime=Qe;
|
|
1
|
+
'use strict';var O=require('axios'),Q=require('fs/promises'),Z=require('hashids'),A=require('js-cookie'),X=require('md5'),m=require('moment'),nanoid=require('nanoid'),B=require('ip-regex');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var O__default=/*#__PURE__*/_interopDefault(O);var Q__default=/*#__PURE__*/_interopDefault(Q);var Z__default=/*#__PURE__*/_interopDefault(Z);var A__default=/*#__PURE__*/_interopDefault(A);var X__default=/*#__PURE__*/_interopDefault(X);var m__default=/*#__PURE__*/_interopDefault(m);var B__default=/*#__PURE__*/_interopDefault(B);/* ZuzJS Core */
|
|
2
|
+
var I=["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 z=/^[0-9a-fA-F]{3}$|^[0-9a-fA-F]{6}$/,L=/^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 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 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 l of a)if(!u.includes(l)||!s(o[l],c[l]))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 S(e),$=Y;var N=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=N;var G="zuzjs-core",te=(e,t)=>Math.floor(Math.random()*(t-e+1))+e,re=(e,t=6,r=null)=>new Z__default.default(r||G,t).encode(e),He=(e,t=null)=>{try{let r=new Z__default.default(t||G,+process.env.HASHIDS_LENGTH).decode(e);return r.length>=0?Number(r[0]):0}catch{return 0}},Me=e=>X__default.default(e),qe=e=>re(te(11111111111,999999999999)),We=e=>nanoid.nanoid(e),F=e=>`${e.charAt(0).toUpperCase()}${e.substring(1,e.length)}`,Ie=e=>decodeURIComponent(e.replace(/\+/g,"%20")),ze=e=>encodeURIComponent(e),Le=(e,t)=>`${e}${t!==1?"s":""}`,ne=e=>z.test(e),se=e=>L.test(e),oe=e=>U.test(e),Ue=e=>I.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(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})`},Ke=()=>{let e=typeof window<"u"?performance.now():Date.now();return `#${(Math.floor(e*2654435769)&16777215).toString(16).padStart(6,"0")}`};function ie(e,t="string"){e=e.replace(/^#/,""),e.length===3&&(e=e.split("").map(p=>p+p).join(""));let r=parseInt(e.substring(0,2),16)/255,n=parseInt(e.substring(2,4),16)/255,s=parseInt(e.substring(4,6),16)/255,i=Math.max(r,n,s),o=Math.min(r,n,s),c=0,a=0,u=(i+o)/2;if(i!==o){let p=i-o;switch(a=u>.5?p/(2-i-o):p/(i+o),i){case r:c=(n-s)/p+(n<s?6:0);break;case n:c=(s-r)/p+2;break;case s:c=(r-n)/p+4;break}c/=6;}let l={h:Math.round(c*360),s:Math.round(a*100),l:Math.round(u*100)};return t==="string"?`hsl(${l.h}, ${l.s}%, ${l.l}%)`:l}var K=e=>{let t=e.replace(/^#/,""),r=parseInt(t.substring(0,2),16),n=parseInt(t.substring(2,4),16),s=parseInt(t.substring(4,6),16);return (r*299+n*587+s*114)/1e3>=128?"#1a1a1a":"#ffffff"},Ze=e=>{let t=ie(e,"object"),r=K(e)==="#ffffff",n=(s=0,i=0,o=0,c=1)=>{let a=(t.h+s+360)%360,u=Math.min(100,Math.max(0,t.s+i)),l=Math.min(100,Math.max(0,t.l+o));return c===1?`hsl(${a}, ${u}%, ${l}%)`:`hsla(${a}, ${u}%, ${l}%, ${c})`};return {primary:e,onPrimary:K(e),background:r?n(0,-10,-40):n(0,-20,45),surface:r?n(0,-5,-35):n(0,-15,40),foreground:r?"#ffffff":"#1a1a1a",muted:r?n(0,-20,20,.7):n(0,-20,-30,.6),border:r?n(0,0,10,.2):n(0,0,-10,.1),hover:n(0,0,r?10:-10),active:n(0,0,r?-5:5),ghost:n(0,0,0,.12)}},ae=e=>e.reduce((t,r)=>(t.includes(r)||t.push(r),t),[]),Ge=e=>{if(!e.trim())return "";let t=e.split(/\s+/).filter(Boolean);return ae(t).join(" ")},Ve=()=>O__default.default.CancelToken.source(),Ye=e=>O__default.default.defaults.withCredentials=e,ce=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__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(!$(e).isString())throw new Error("Unsupported data type for withPost/withPut/withPatch");return {finalData:n,contentType:s}},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__default.default(e);return ue(r,t)}catch(r){throw r?.response?.data?r.response.data:r?.code==="ERR_NETWORK"?ce(r):r}};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:"post",url:e,data:c,timeout:o.timeout*1e3,withCredentials:o.withCredentials,headers:{"Content-Type":a,...o.headers??{}},onUploadProgress:o.onProgress},o)}async function Qe(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 Xe(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 et(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 tt=e=>{let t=new Date().getTime(),r=e(),n=new Date().getTime();return {result:r,executionTime:n-t}},rt=(e,t)=>{let r=t||"YYYY-MM-DD HH:mm:ss";if(!e)return m__default.default().format(r);if(e instanceof Date)return m__default.default(e).format(r);if(typeof e=="string"&&isNaN(Number(e)))return m__default.default(e).format(r);let n=Number(e);return n>9999999999?m__default.default(n).format(r):m__default.default.unix(n).format(r)},nt=e=>{if(e instanceof Date)return m__default.default(e).fromNow();if(typeof e=="string"&&isNaN(Number(e)))return m__default.default(e).fromNow();let t=Number(e);return t>9999999999?m__default.default(t).fromNow():m__default.default.unix(t).fromNow()},st=e=>e[Math.floor(Math.random()*e.length)],ot=({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)},it=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]},at=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);}),ct=(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,l=e.caseSensitive?d=>`${d}`.replace(n,""):d=>d.toString().toLowerCase().replace(n,""),p=d=>d.replace(o,"\0$1\0").replace(/\0$/,"").replace(/^\0/,"").split("\0"),E=(d,R)=>(!d.match(t)||R===1)&&parseFloat(d)||d.replace(r," ").replace(n,"")||0;return function(d,R){let y=l(d),f=l(R);if(!y&&!f)return 0;if(!y&&f)return u;if(y&&!f)return a;let _=p(y),D=p(f),k=y.match(i),P=f.match(i),b=k&&P?parseInt(k[0],16):_.length!==1&&Date.parse(y),x=k&&P?parseInt(P[0],16):b&&f.match(c)&&Date.parse(f)||null;if(x){if(b===x)return 0;if(typeof b=="number"&&typeof x=="number"&&b<x)return u;if(typeof b=="number"&&b>x)return a}let H=_.length,M=D.length;for(let w=0,q=Math.max(H,M);w<q;w+=1){let g=E(_[w]||"",H),h=E(D[w]||"",M);if(isNaN(g)!==isNaN(h))return isNaN(g)?a:u;if(s.test(g+h)&&g.localeCompare){let W=g.localeCompare(h);if(W>0)return a;if(W<0)return u;if(w===q-1)return 0}if(g<h)return u;if(g>h)return a;if(`${g}`<`${h}`)return u;if(`${g}`>`${h}`)return a}return 0}},ut=(e,t=false)=>e.toLowerCase().split(/[^a-zA-Z0-9]+/).map((r,n)=>n===0?t?F(r):r:F(r)).join(""),lt=e=>e.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase(),pt=(e,t,r)=>Math.min(Math.max(e,t),r),dt=(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"),""),gt=e=>new Promise(t=>setTimeout(t,e)),mt=(e,t)=>setTimeout(e,t||1e3),ft=e=>Object.keys(e).filter(t=>isNaN(Number(t))),ht=async e=>{try{return await Q__default.default.access(e),!0}catch{return false}},yt=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,"/"),s=window.atob(n),i=new Uint8Array(s.length);for(let o=0;o<s.length;++o)i[o]=s.charCodeAt(o);return i},bt=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}},le=e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),xt=(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()},wt=(e,t=false)=>{let r=A__default.default.get(e);return r?t?JSON.parse(r):r:null},Tt=e=>A__default.default.remove(e),At=({key:e,value:t,json:r=false,path:n="/",expires:s,domain:i,secure:o,sameSite:c})=>{try{A__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=Me;exports.PubSub=J;exports.SORT=V;exports._=$;exports.__SALT=G;exports.arrayRand=st;exports.camelCase=ut;exports.camelCaseToDash=lt;exports.checkPasswordStrength=bt;exports.clamp=pt;exports.copyToClipboard=at;exports.enumToKeys=ft;exports.escapeRegex=le;exports.exists=ht;exports.formatNumber=ot;exports.formatSize=it;exports.fromHash=He;exports.generateColorHex=Ke;exports.generatePalette=Ze;exports.getCancelToken=Ve;exports.getContrastColor=K;exports.getCookie=wt;exports.hexToHsl=ie;exports.hexToRgba=Fe;exports.isColor=Be;exports.isColorName=Ue;exports.isHexColor=ne;exports.isHslColor=oe;exports.isRgbaColor=se;exports.natsort=ct;exports.numberInRange=te;exports.pluralize=Le;exports.removeCookie=Tt;exports.removeDuplicateWords=Ge;exports.removeDuplicates=ae;exports.removeWords=xt;exports.setCookie=At;exports.sleep=gt;exports.slugify=dt;exports.time=rt;exports.timeSince=nt;exports.toHash=re;exports.ucfirst=F;exports.urlBase64ToUint8Array=yt;exports.urldecode=Ie;exports.urlencode=ze;exports.uuid=qe;exports.uuid2=We;exports.withCredentials=Ye;exports.withDelay=mt;exports.withGet=Qe;exports.withPatch=et;exports.withPost=Je;exports.withPut=Xe;exports.withTime=tt;
|
package/dist/index.d.cts
CHANGED
|
@@ -141,6 +141,39 @@ declare const hexToRgba: (hex: string, alpha?: number) => string;
|
|
|
141
141
|
* spectrum so sequential colors aren't just "slightly darker/lighter".
|
|
142
142
|
*/
|
|
143
143
|
declare const generateColorHex: () => string;
|
|
144
|
+
/**
|
|
145
|
+
* Converts Hex to HSL with flexible output formats.
|
|
146
|
+
* @param hex - The color string (e.g., "#ff0000" or "ff0000")
|
|
147
|
+
* @param format - 'object' (default) or 'string' for CSS hsl()
|
|
148
|
+
*/
|
|
149
|
+
type HSLObject = {
|
|
150
|
+
h: number;
|
|
151
|
+
s: number;
|
|
152
|
+
l: number;
|
|
153
|
+
};
|
|
154
|
+
declare function hexToHsl(hex: string, format: 'object'): HSLObject;
|
|
155
|
+
declare function hexToHsl(hex: string, format: 'string'): string;
|
|
156
|
+
/**
|
|
157
|
+
* Returns either #FFFFFF or a dark neutral #1A1A1A
|
|
158
|
+
* based on the background color's brightness.
|
|
159
|
+
*/
|
|
160
|
+
declare const getContrastColor: (hex: string) => string;
|
|
161
|
+
/**
|
|
162
|
+
* Generates a functional UI palette based on a single seed color.
|
|
163
|
+
* Uses HSL manipulation to ensure visual harmony.
|
|
164
|
+
*/
|
|
165
|
+
declare const generatePalette: (seedHex: string) => {
|
|
166
|
+
primary: string;
|
|
167
|
+
onPrimary: string;
|
|
168
|
+
background: string;
|
|
169
|
+
surface: string;
|
|
170
|
+
foreground: string;
|
|
171
|
+
muted: string;
|
|
172
|
+
border: string;
|
|
173
|
+
hover: string;
|
|
174
|
+
active: string;
|
|
175
|
+
ghost: string;
|
|
176
|
+
};
|
|
144
177
|
declare const removeDuplicates: <T>(array: T[]) => T[];
|
|
145
178
|
declare const removeDuplicateWords: (text: string) => string;
|
|
146
179
|
declare const getCancelToken: () => CancelTokenSource;
|
|
@@ -199,4 +232,4 @@ declare const setCookie: ({ key, value, json, path, expires, domain, secure, sam
|
|
|
199
232
|
sameSite?: "strict" | "Strict" | "lax" | "Lax" | "none" | "None" | undefined;
|
|
200
233
|
}) => void;
|
|
201
234
|
|
|
202
|
-
export { _ as "_", type EventListener, type FormatNumberParams, MD5, Events as PubSub, SORT, type WithHttpOptions, __SALT, arrayRand, camelCase, camelCaseToDash, checkPasswordStrength, clamp, copyToClipboard, type dynamic, enumToKeys, escapeRegex, exists, formatNumber, formatSize, fromHash, generateColorHex, getCancelToken, getCookie, hexToRgba, isColor, isColorName, isHexColor, isHslColor, isRgbaColor, natsort, numberInRange, pluralize, removeCookie, removeDuplicateWords, removeDuplicates, removeWords, setCookie, sleep, slugify, type sortOptions, time, timeSince, toHash, ucfirst, urlBase64ToUint8Array, urldecode, urlencode, uuid, uuid2, withCredentials, withDelay, withGet, withPatch, withPost, withPut, withTime };
|
|
235
|
+
export { _ as "_", type EventListener, type FormatNumberParams, type HSLObject, MD5, Events as PubSub, SORT, type WithHttpOptions, __SALT, arrayRand, camelCase, camelCaseToDash, checkPasswordStrength, clamp, copyToClipboard, type dynamic, enumToKeys, escapeRegex, exists, formatNumber, formatSize, fromHash, generateColorHex, generatePalette, getCancelToken, getContrastColor, getCookie, hexToHsl, hexToRgba, isColor, isColorName, isHexColor, isHslColor, isRgbaColor, natsort, numberInRange, pluralize, removeCookie, removeDuplicateWords, removeDuplicates, removeWords, setCookie, sleep, slugify, type sortOptions, time, timeSince, toHash, ucfirst, urlBase64ToUint8Array, urldecode, urlencode, uuid, uuid2, withCredentials, withDelay, withGet, withPatch, withPost, withPut, withTime };
|
package/dist/index.d.ts
CHANGED
|
@@ -141,6 +141,39 @@ declare const hexToRgba: (hex: string, alpha?: number) => string;
|
|
|
141
141
|
* spectrum so sequential colors aren't just "slightly darker/lighter".
|
|
142
142
|
*/
|
|
143
143
|
declare const generateColorHex: () => string;
|
|
144
|
+
/**
|
|
145
|
+
* Converts Hex to HSL with flexible output formats.
|
|
146
|
+
* @param hex - The color string (e.g., "#ff0000" or "ff0000")
|
|
147
|
+
* @param format - 'object' (default) or 'string' for CSS hsl()
|
|
148
|
+
*/
|
|
149
|
+
type HSLObject = {
|
|
150
|
+
h: number;
|
|
151
|
+
s: number;
|
|
152
|
+
l: number;
|
|
153
|
+
};
|
|
154
|
+
declare function hexToHsl(hex: string, format: 'object'): HSLObject;
|
|
155
|
+
declare function hexToHsl(hex: string, format: 'string'): string;
|
|
156
|
+
/**
|
|
157
|
+
* Returns either #FFFFFF or a dark neutral #1A1A1A
|
|
158
|
+
* based on the background color's brightness.
|
|
159
|
+
*/
|
|
160
|
+
declare const getContrastColor: (hex: string) => string;
|
|
161
|
+
/**
|
|
162
|
+
* Generates a functional UI palette based on a single seed color.
|
|
163
|
+
* Uses HSL manipulation to ensure visual harmony.
|
|
164
|
+
*/
|
|
165
|
+
declare const generatePalette: (seedHex: string) => {
|
|
166
|
+
primary: string;
|
|
167
|
+
onPrimary: string;
|
|
168
|
+
background: string;
|
|
169
|
+
surface: string;
|
|
170
|
+
foreground: string;
|
|
171
|
+
muted: string;
|
|
172
|
+
border: string;
|
|
173
|
+
hover: string;
|
|
174
|
+
active: string;
|
|
175
|
+
ghost: string;
|
|
176
|
+
};
|
|
144
177
|
declare const removeDuplicates: <T>(array: T[]) => T[];
|
|
145
178
|
declare const removeDuplicateWords: (text: string) => string;
|
|
146
179
|
declare const getCancelToken: () => CancelTokenSource;
|
|
@@ -199,4 +232,4 @@ declare const setCookie: ({ key, value, json, path, expires, domain, secure, sam
|
|
|
199
232
|
sameSite?: "strict" | "Strict" | "lax" | "Lax" | "none" | "None" | undefined;
|
|
200
233
|
}) => void;
|
|
201
234
|
|
|
202
|
-
export { _ as "_", type EventListener, type FormatNumberParams, MD5, Events as PubSub, SORT, type WithHttpOptions, __SALT, arrayRand, camelCase, camelCaseToDash, checkPasswordStrength, clamp, copyToClipboard, type dynamic, enumToKeys, escapeRegex, exists, formatNumber, formatSize, fromHash, generateColorHex, getCancelToken, getCookie, hexToRgba, isColor, isColorName, isHexColor, isHslColor, isRgbaColor, natsort, numberInRange, pluralize, removeCookie, removeDuplicateWords, removeDuplicates, removeWords, setCookie, sleep, slugify, type sortOptions, time, timeSince, toHash, ucfirst, urlBase64ToUint8Array, urldecode, urlencode, uuid, uuid2, withCredentials, withDelay, withGet, withPatch, withPost, withPut, withTime };
|
|
235
|
+
export { _ as "_", type EventListener, type FormatNumberParams, type HSLObject, MD5, Events as PubSub, SORT, type WithHttpOptions, __SALT, arrayRand, camelCase, camelCaseToDash, checkPasswordStrength, clamp, copyToClipboard, type dynamic, enumToKeys, escapeRegex, exists, formatNumber, formatSize, fromHash, generateColorHex, generatePalette, getCancelToken, getContrastColor, getCookie, hexToHsl, hexToRgba, isColor, isColorName, isHexColor, isHslColor, isRgbaColor, natsort, numberInRange, pluralize, removeCookie, removeDuplicateWords, removeDuplicates, removeWords, setCookie, sleep, slugify, type sortOptions, time, timeSince, toHash, ucfirst, urlBase64ToUint8Array, urldecode, urlencode, uuid, uuid2, withCredentials, withDelay, withGet, withPatch, withPost, withPut, withTime };
|
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 F from'ip-regex';var I=["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 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 F.v4({exact:true}).test(this._)}isIPv6(){return F.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),l=Object.keys(c);if(a.length!==l.length)return false;for(let h of a)if(!l.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 S(e),N=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),Ie=(e,t)=>`${e}${t!==1?"s":""}`,ne=e=>L.test(e),oe=e=>U.test(e),se=e=>B.test(e),Le=e=>I.includes(e.toLowerCase()),Ue=e=>ne(e)||oe(e)||se(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})`},Fe=()=>{let e=typeof window<"u"?performance.now():Date.now();return `#${(Math.floor(e*2654435769)&16777215).toString(16).padStart(6,"0")}`},ie=e=>e.reduce((t,r)=>(t.includes(r)||t.push(r),t),[]),Ke=e=>{if(!e.trim())return "";let t=e.split(/\s+/).filter(Boolean);return ie(t).join(" ")},Ze=()=>O.CancelToken.source(),Ge=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},$=(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(!N(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 Ve(e,t,r=60,n=false,s={},i){let o=v(r,n,s,i),{finalData:c,contentType:a}=$(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 Ye(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 Je(e,t,r=60,n=false,s={},i){let o=v(r,n,s,i),{finalData:c,contentType:a}=$(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 Qe(e,t,r=60,n=false,s={},i){let o=v(r,n,s,i),{finalData:c,contentType:a}=$(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 Xe=e=>{let t=new Date().getTime(),r=e(),n=new Date().getTime();return {result:r,executionTime:n-t}},et=(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)},tt=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()},rt=e=>e[Math.floor(Math.random()*e.length)],nt=({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,l=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?l.replace(new RegExp(`\\${o}`,"g"),a):l}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)},ot=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);}),it=(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,l=-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,R)=>(!u.match(t)||R===1)&&parseFloat(u)||u.replace(r," ").replace(n,"")||0;return function(u,R){let f=h(u),g=h(R);if(!f&&!g)return 0;if(!f&&g)return l;if(f&&!g)return a;let _=j(f),H=j(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 l;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:l;if(s.test(p+m)&&p.localeCompare){let M=p.localeCompare(m);if(M>0)return a;if(M<0)return l;if(x===z-1)return 0}if(p<m)return l;if(p>m)return a;if(`${p}`<`${m}`)return l;if(`${p}`>`${m}`)return a}return 0}},at=(e,t=false)=>e.toLowerCase().split(/[^a-zA-Z0-9]+/).map((r,n)=>n===0?t?K(r):r:K(r)).join(""),ct=e=>e.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase(),lt=(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"),""),pt=e=>new Promise(t=>setTimeout(t,e)),dt=(e,t)=>setTimeout(e,t||1e3),gt=e=>Object.keys(e).filter(t=>isNaN(Number(t))),mt=async e=>{try{return await Q.access(e),!0}catch{return false}},ht=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,"/"),s=window.atob(n),i=new Uint8Array(s.length);for(let o=0;o<s.length;++o)i[o]=s.charCodeAt(o);return i},ft=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}},le=e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),yt=(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()},bt=(e,t=false)=>{let r=A.get(e);return r?t?JSON.parse(r):r:null},xt=e=>A.remove(e),wt=({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,N as _,G as __SALT,rt as arrayRand,at as camelCase,ct as camelCaseToDash,ft as checkPasswordStrength,lt as clamp,st as copyToClipboard,gt as enumToKeys,le as escapeRegex,mt as exists,nt as formatNumber,ot as formatSize,De as fromHash,Fe as generateColorHex,Ze as getCancelToken,bt as getCookie,Be as hexToRgba,Ue as isColor,Le as isColorName,ne as isHexColor,se as isHslColor,oe as isRgbaColor,it as natsort,te as numberInRange,Ie as pluralize,xt as removeCookie,Ke as removeDuplicateWords,ie as removeDuplicates,yt as removeWords,wt as setCookie,pt as sleep,ut as slugify,et as time,tt as timeSince,re as toHash,K as ucfirst,ht as urlBase64ToUint8Array,ze as urldecode,Me as urlencode,qe as uuid,We as uuid2,Ge as withCredentials,dt as withDelay,Ye as withGet,Qe as withPatch,Ve as withPost,Je as withPut,Xe as withTime};
|
|
1
|
+
import j from'axios';import X from'fs/promises';import G from'hashids';import v from'js-cookie';import ee from'md5';import m from'moment';import {nanoid}from'nanoid';import F from'ip-regex';var z=["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 Y=(r=>(r.Asc="ASC",r.Desc="DESC",r))(Y||{});var $=class{_;constructor(t){this._=t;}isIP(){return this.isIPv4()||this.isIPv6()}isIPv4(){return F.v4({exact:true}).test(this._)}isIPv6(){return F.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 l of a)if(!u.includes(l)||!s(o[l],c[l]))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._)}},J=e=>new $(e),N=J;var O=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);}},Q=O;var V="zuzjs-core",re=(e,t)=>Math.floor(Math.random()*(t-e+1))+e,ne=(e,t=6,r=null)=>new G(r||V,t).encode(e),Me=(e,t=null)=>{try{let r=new G(t||V,+process.env.HASHIDS_LENGTH).decode(e);return r.length>=0?Number(r[0]):0}catch{return 0}},qe=e=>ee(e),We=e=>ne(re(11111111111,999999999999)),Ie=e=>nanoid(e),K=e=>`${e.charAt(0).toUpperCase()}${e.substring(1,e.length)}`,ze=e=>decodeURIComponent(e.replace(/\+/g,"%20")),Le=e=>encodeURIComponent(e),Ue=(e,t)=>`${e}${t!==1?"s":""}`,se=e=>L.test(e),oe=e=>U.test(e),ie=e=>B.test(e),Be=e=>z.includes(e.toLowerCase()),Fe=e=>se(e)||oe(e)||ie(e),Ke=(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})`},Ze=()=>{let e=typeof window<"u"?performance.now():Date.now();return `#${(Math.floor(e*2654435769)&16777215).toString(16).padStart(6,"0")}`};function ae(e,t="string"){e=e.replace(/^#/,""),e.length===3&&(e=e.split("").map(p=>p+p).join(""));let r=parseInt(e.substring(0,2),16)/255,n=parseInt(e.substring(2,4),16)/255,s=parseInt(e.substring(4,6),16)/255,i=Math.max(r,n,s),o=Math.min(r,n,s),c=0,a=0,u=(i+o)/2;if(i!==o){let p=i-o;switch(a=u>.5?p/(2-i-o):p/(i+o),i){case r:c=(n-s)/p+(n<s?6:0);break;case n:c=(s-r)/p+2;break;case s:c=(r-n)/p+4;break}c/=6;}let l={h:Math.round(c*360),s:Math.round(a*100),l:Math.round(u*100)};return t==="string"?`hsl(${l.h}, ${l.s}%, ${l.l}%)`:l}var Z=e=>{let t=e.replace(/^#/,""),r=parseInt(t.substring(0,2),16),n=parseInt(t.substring(2,4),16),s=parseInt(t.substring(4,6),16);return (r*299+n*587+s*114)/1e3>=128?"#1a1a1a":"#ffffff"},Ge=e=>{let t=ae(e,"object"),r=Z(e)==="#ffffff",n=(s=0,i=0,o=0,c=1)=>{let a=(t.h+s+360)%360,u=Math.min(100,Math.max(0,t.s+i)),l=Math.min(100,Math.max(0,t.l+o));return c===1?`hsl(${a}, ${u}%, ${l}%)`:`hsla(${a}, ${u}%, ${l}%, ${c})`};return {primary:e,onPrimary:Z(e),background:r?n(0,-10,-40):n(0,-20,45),surface:r?n(0,-5,-35):n(0,-15,40),foreground:r?"#ffffff":"#1a1a1a",muted:r?n(0,-20,20,.7):n(0,-20,-30,.6),border:r?n(0,0,10,.2):n(0,0,-10,.1),hover:n(0,0,r?10:-10),active:n(0,0,r?-5:5),ghost:n(0,0,0,.12)}},ce=e=>e.reduce((t,r)=>(t.includes(r)||t.push(r),t),[]),Ve=e=>{if(!e.trim())return "";let t=e.split(/\s+/).filter(Boolean);return ce(t).join(" ")},Ye=()=>j.CancelToken.source(),Je=e=>j.defaults.withCredentials=e,ue=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},E=(e,t)=>{let r=v.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}},le=(e,t)=>{if(t.returnRawResponse)return e;if(e.data&&(t.ignoreKind||"kind"in e.data))return e.data;throw e.data},R=async(e,t)=>{try{let r=await j(e);return le(r,t)}catch(r){throw r?.response?.data?r.response.data:r?.code==="ERR_NETWORK"?ue(r):r}};async function Qe(e,t,r=60,n=false,s={},i){let o=C(r,n,s,i),{finalData:c,contentType:a}=E(t,o);return R({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 Xe(e,t=60,r=false,n={}){let s=C(t,r,n);return R({method:"get",url:e,timeout:s.timeout*1e3,withCredentials:s.withCredentials,headers:s.headers},s)}async function et(e,t,r=60,n=false,s={},i){let o=C(r,n,s,i),{finalData:c,contentType:a}=E(t,o);return R({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 tt(e,t,r=60,n=false,s={},i){let o=C(r,n,s,i),{finalData:c,contentType:a}=E(t,o);return R({method:"patch",url:e,data:c,timeout:o.timeout*1e3,withCredentials:o.withCredentials,headers:{"Content-Type":a,...o.headers??{}},onUploadProgress:o.onProgress},o)}var rt=e=>{let t=new Date().getTime(),r=e(),n=new Date().getTime();return {result:r,executionTime:n-t}},nt=(e,t)=>{let r=t||"YYYY-MM-DD HH:mm:ss";if(!e)return m().format(r);if(e instanceof Date)return m(e).format(r);if(typeof e=="string"&&isNaN(Number(e)))return m(e).format(r);let n=Number(e);return n>9999999999?m(n).format(r):m.unix(n).format(r)},st=e=>{if(e instanceof Date)return m(e).fromNow();if(typeof e=="string"&&isNaN(Number(e)))return m(e).fromNow();let t=Number(e);return t>9999999999?m(t).fromNow():m.unix(t).fromNow()},ot=e=>e[Math.floor(Math.random()*e.length)],it=({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)},at=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]},ct=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);}),ut=(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,l=e.caseSensitive?d=>`${d}`.replace(n,""):d=>d.toString().toLowerCase().replace(n,""),p=d=>d.replace(o,"\0$1\0").replace(/\0$/,"").replace(/^\0/,"").split("\0"),D=(d,_)=>(!d.match(t)||_===1)&&parseFloat(d)||d.replace(r," ").replace(n,"")||0;return function(d,_){let y=l(d),f=l(_);if(!y&&!f)return 0;if(!y&&f)return u;if(y&&!f)return a;let k=p(y),H=p(f),P=y.match(i),S=f.match(i),b=P&&S?parseInt(P[0],16):k.length!==1&&Date.parse(y),x=P&&S?parseInt(S[0],16):b&&f.match(c)&&Date.parse(f)||null;if(x){if(b===x)return 0;if(typeof b=="number"&&typeof x=="number"&&b<x)return u;if(typeof b=="number"&&b>x)return a}let M=k.length,q=H.length;for(let w=0,W=Math.max(M,q);w<W;w+=1){let g=D(k[w]||"",M),h=D(H[w]||"",q);if(isNaN(g)!==isNaN(h))return isNaN(g)?a:u;if(s.test(g+h)&&g.localeCompare){let I=g.localeCompare(h);if(I>0)return a;if(I<0)return u;if(w===W-1)return 0}if(g<h)return u;if(g>h)return a;if(`${g}`<`${h}`)return u;if(`${g}`>`${h}`)return a}return 0}},lt=(e,t=false)=>e.toLowerCase().split(/[^a-zA-Z0-9]+/).map((r,n)=>n===0?t?K(r):r:K(r)).join(""),pt=e=>e.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase(),dt=(e,t,r)=>Math.min(Math.max(e,t),r),gt=(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"),""),mt=e=>new Promise(t=>setTimeout(t,e)),ft=(e,t)=>setTimeout(e,t||1e3),ht=e=>Object.keys(e).filter(t=>isNaN(Number(t))),yt=async e=>{try{return await X.access(e),!0}catch{return false}},bt=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,"/"),s=window.atob(n),i=new Uint8Array(s.length);for(let o=0;o<s.length;++o)i[o]=s.charCodeAt(o);return i},xt=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}},pe=e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),wt=(e,t)=>{if(t.length===0)return e.trim();let r=t.map(s=>s.trim()).filter(Boolean).map(pe);if(r.length===0)return e.trim();let n=new RegExp(`\\b(${r.join("|")})\\b`,"gi");return e.replace(n,"").replace(/\s+/g," ").trim()},Tt=(e,t=false)=>{let r=v.get(e);return r?t?JSON.parse(r):r:null},At=e=>v.remove(e),vt=({key:e,value:t,json:r=false,path:n="/",expires:s,domain:i,secure:o,sameSite:c})=>{try{v.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{qe as MD5,Q as PubSub,Y as SORT,N as _,V as __SALT,ot as arrayRand,lt as camelCase,pt as camelCaseToDash,xt as checkPasswordStrength,dt as clamp,ct as copyToClipboard,ht as enumToKeys,pe as escapeRegex,yt as exists,it as formatNumber,at as formatSize,Me as fromHash,Ze as generateColorHex,Ge as generatePalette,Ye as getCancelToken,Z as getContrastColor,Tt as getCookie,ae as hexToHsl,Ke as hexToRgba,Fe as isColor,Be as isColorName,se as isHexColor,ie as isHslColor,oe as isRgbaColor,ut as natsort,re as numberInRange,Ue as pluralize,At as removeCookie,Ve as removeDuplicateWords,ce as removeDuplicates,wt as removeWords,vt as setCookie,mt as sleep,gt as slugify,nt as time,st as timeSince,ne as toHash,K as ucfirst,bt as urlBase64ToUint8Array,ze as urldecode,Le as urlencode,We as uuid,Ie as uuid2,Je as withCredentials,ft as withDelay,Xe as withGet,tt as withPatch,Qe as withPost,et as withPut,rt as withTime};
|