UNPKG

funtool

Version:

A modern, efficient, and modular JavaScript utility library designed to enhance developer productivity.

3 lines (2 loc) 28.9 kB
"use strict";function e(e){return"function"==typeof Array.isArray?Array.isArray(e):"[object Array]"===Object.prototype.toString.call(e)}function t(e){return"[object ArrayBuffer]"===Object.prototype.toString.call(e)}function n(e){return"[object Boolean]"===Object.prototype.toString.call(e)}function r(e){return e instanceof DataView&&"[object DataView]"===Object.prototype.toString.call(e)}function o(e){return"[object Date]"===Object.prototype.toString.call(e)}function i(e){return"[object Number]"===Object.prototype.toString.call(e)}function s(e){return"[object BigInt]"===Object.prototype.toString.call(e)}function a(e){return"function"==typeof Number.isNaN?Number.isNaN(e)&&"number"==typeof e:"number"==typeof e&&a(e)}function u(e){return"function"==typeof e||"object"==typeof e&&null!==e}function c(e){return null!=e&&"object"==typeof e}function l(e){if(!u(e))return!1;const t=Object.getPrototypeOf(e);return null===t||t===Object.prototype||null===Object.getPrototypeOf(t)}function p(e){return"[object String]"===Object.prototype.toString.call(e)}function f(e){return"[object Map]"===Object.prototype.toString.call(e)&&e instanceof Map}function h(e){return"[object WeakMap]"===Object.prototype.toString.call(e)&&e instanceof WeakMap}function d(e){return"[object RegExp]"===Object.prototype.toString.call(e)}function m(e){return"[object Set]"===Object.prototype.toString.call(e)&&e instanceof Set}function g(e){return"[object WeakSet]"===Object.prototype.toString.call(e)&&e instanceof WeakSet}function x(e){return"symbol"==typeof e}function y(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function b(u,c,p=!0,h=new WeakMap){const g=n(p)?{ordered:p}:p||{ordered:!0};if(u===c)return!0;if(null==u||null==c||typeof u!=typeof c)return!1;if(i(u)&&i(c)&&a(u)&&a(c))return!0;if(x(u)&&x(c))return u.description===c.description;if(s(u)&&s(c))return u===c;if(n(u)&&n(c))return u===c;if(o(u)&&o(c))return u.getTime()===c.getTime();if(d(u)&&d(c))return u.source===c.source&&u.flags===c.flags;if(e(u)&&e(c))return function(e,t,n,r){if(e.length!==t.length)return!1;if(n.ordered){for(let o=0;o<e.length;o++)if(!b(e[o],t[o],n,r))return!1;return!0}{const o=new Array(t.length).fill(!1);for(const i of e){let e=!1;for(let s=0;s<t.length;s++)if(!o[s]&&b(i,t[s],n,r)){o[s]=!0,e=!0;break}if(!e)return!1}return!0}}(u,c,g,h);if(t(u)&&t(c)){if(u.byteLength!==c.byteLength)return!1;const e=new Uint8Array(u),t=new Uint8Array(c);for(const[n,r]of e.entries())if(r!==t[n])return!1;return!0}if(y(u)&&y(c)){if(u.constructor!==c.constructor||u.byteLength!==c.byteLength)return!1;const e=new Uint8Array(u.buffer,u.byteOffset,u.byteLength),t=new Uint8Array(c.buffer,c.byteOffset,c.byteLength);for(const[n,r]of e.entries())if(r!==t[n])return!1;return!0}if(r(u)&&r(c)){if(u.constructor!==c.constructor||u.byteLength!==c.byteLength)return!1;for(let e=0;e<u.byteLength;e++)if(u.getUint8(e)!==c.getUint8(e))return!1;return!0}return m(u)&&m(c)?function(e,t,n,r){if(e.size!==t.size)return!1;const o=e.values(),i=t.values();for(;;){const e=o.next(),t=i.next();if(e.done&&t.done)break;if(e.done||t.done)return!1;if(!b(e.value,t.value,n,r))return!1}return!0}(u,c,{ordered:!0},h):f(u)&&f(c)?function(e,t,n,r){if(e.size!==t.size)return!1;const o=e.entries(),i=t.entries();for(;;){const e=o.next(),t=i.next();if(e.done&&t.done)break;if(e.done||t.done)return!1;const[s,a]=e.value,[u,c]=t.value;if(!b(s,u,n,r)||!b(a,c,n,r))return!1}return!0}(u,c,{ordered:!0},h):!(!l(u)||!l(c))&&function(e,t,n,r){const o=Object.keys(e),i=Object.keys(t);if(o.length!==i.length)return!1;for(const i of o){if(!Object.prototype.hasOwnProperty.call(t,i))return!1;if(!b(e[i],t[i],n,r))return!1}return!0}(u,c,{ordered:!1},h)}function v(e){return"function"==typeof e}function w(e){return"[object Null]"===Object.prototype.toString.call(e)}function O(e){return"object"!=typeof e&&"function"!=typeof e||null==e}function j(t,n){if(O(t))return t;if(e(t))return t.map(((e,t)=>{if(v(n)){return n(e,t)}return e}));if(o(t))return new Date(t.getTime());if(d(t))return new RegExp(t.source,t.flags);if(f(t))return new Map(t);if(m(t))return new Set(t);if(y(t))return t.slice();if(r(t))return new DataView(t.buffer.slice(0));if(u(t)){const e=Object.getPrototypeOf(t),r=Object.create(e);for(const e in t)if(Object.prototype.hasOwnProperty.call(t,e)){const o=t[e],i=n?.(o,e);r[e]=void 0!==i?i:o}return r}return t}function A(e,t){return!O(e)&&Object.prototype.hasOwnProperty.call(e,t)}function S(e,t){if(O(e))return[];return("undefined"!=typeof Reflect&&"function"==typeof Reflect.ownKeys?Reflect.ownKeys(e):[...Object.getOwnPropertyNames?Object.getOwnPropertyNames(e):[],...Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(e):[]]).filter((n=>{const r=Object.getOwnPropertyDescriptor(e,n);return!!r&&(v(t)?t(n,r):r.enumerable)}))}const _={Date:e=>new Date(e.getTime()),RegExp:e=>new RegExp(e.source,e.flags),Array:(e,t,n)=>{const r=[];return t.set(e,r),e.forEach(((e,o)=>{r[o]=n(e,t)})),r},Map:(e,t,n)=>{const r=new Map;return t.set(e,r),e.forEach(((e,o)=>{r.set(o,n(e,t))})),r},Set:(e,t,n)=>{const r=new Set;return t.set(e,r),e.forEach((e=>{r.add(n(e,t))})),r}};function $(e,t,n,r){if(w(e)||!c(e))return e;if(v(e)||x(e)||s(e)||h(e)||g(e)){const t="object"==typeof e&&null!==e&&"constructor"in e&&e.constructor?.name||typeof e;return console.warn(`⚠️ Warning: Unsupported type "${t}" encountered, returning original.`),e}if(t.has(e))return t.get(e);const o=Object.prototype.toString.call(e).slice(8,-1);if(o in _)return _[o](e,t,n);const i={};return t.set(e,i),S(e).forEach((o=>{if(A(e,o)){const s=e[o],a=r?.(s,o,e);i[o]=void 0!==a?a:n(s,t)}})),i}class E{constructor(e,t){if(e){if(!E.isValid(e))throw new Error("Invalid ObjectId hex string.");this.hex=e.toLowerCase()}else this.hex=function(e=Math.random){return(Math.floor(Date.now()/1e3).toString(16).padStart(8,"0")+Array.from({length:16},(()=>Math.floor(16*e()).toString(16))).join("")).slice(0,24)}(t)}static isValid(e){return"string"==typeof e&&/^[a-fA-F0-9]{24}$/.test(e)}static createFromHexString(e){return new E(e)}static createWithPrefix(e){return e+(new E).toHexString()}toHex(){return this.hex}toBuffer(){const e=new Uint8Array(12);for(let t=0;t<12;t++)e[t]=parseInt(this.hex.slice(2*t,2*t+2),16);return e}equals(e){return this.hex===e.hex}static parse(e,t=!1){if(t){if(!E.isValid(e))throw new Error(`Invalid strict ObjectId: ${e}`);return new E(e)}const n=e.match(/[a-fA-F0-9]{24}/);if(!n)throw new Error(`Invalid format for ObjectId: ${e}`);return new E(n[0])}toHexString(){return this.hex}toUUIDString(){const e=this.hex.padEnd(32,"0");return[e.slice(0,8),e.slice(8,12),e.slice(12,16),e.slice(16,20),e.slice(20)].join("-")}toString(){return this.toHexString()}toBase64(){return Buffer.from(this.toBuffer()).toString("base64")}short(e=""){return e+this.toBase64().replace(/=+$/,"")}getTimestamp(){return 1e3*parseInt(this.hex.slice(0,8),16)}compare(e){return this.hex.localeCompare(e.hex)}clone(){return new E(this.hex)}toJSON(){return this.toHexString()}}function C(e){const[t,n]=e.split(",");if(!t||!n)throw new Error("Invalid base64 format");const r=t.match(/:(.*?);/),o=r?.[1]||"application/octet-stream",i=o.split("/")[1]||"bin",s=atob(n),a=Uint8Array.from(s,(e=>e.charCodeAt(0)));return{blob:new Blob([a],{type:o}),mime:o,ext:i}}const N=[{name:"Edge (Chromium)",regex:/Edg\/([\d.]+)/},{name:"Edge (Legacy)",regex:/Edge\/([\d.]+)/},{name:"Opera",regex:/OPR\/([\d.]+)/},{name:"Vivaldi",regex:/Vivaldi\/([\d.]+)/},{name:"Chrome",regex:/Chrome\/([\d.]+)/},{name:"Firefox",regex:/Firefox\/([\d.]+)/},{name:"Safari",regex:/Version\/([\d.]+).*Safari/},{name:"Internet Explorer",regex:/MSIE ([\d.]+);/},{name:"Internet Explorer",regex:/Trident\/7.0.*rv:([\d.]+)/},{name:"Samsung Internet",regex:/SamsungBrowser\/([\d.]+)/}],T=[{name:"Windows",regex:/Windows NT ([\d.]+)/},{name:"macOS",regex:/Mac OS X ([\d_]+)/,versionReplace:/_/g},{name:"iOS",regex:/\(iP(?:hone|ad|od); CPU (?:iPhone )?OS ([\d_]+)/,versionReplace:/_/g},{name:"Android",regex:/Android ([\d.]+)/},{name:"Linux",regex:/Linux/},{name:"Chrome OS",regex:/CrOS [\w\d_]+ ([\d.]+)/},{name:"Windows Phone",regex:/Windows Phone ([\d.]+)/}],P=[{type:"Mobile",regex:/Mobile|iPhone|Android/},{type:"Tablet",regex:/Tablet|iPad/},{type:"SmartTV",regex:/SmartTV|SMART-TV|Smart-TV|NetCast.TV|AppleTV|Roku/},{type:"Console",regex:/Xbox|PlayStation/},{type:"Wearable",regex:/Watch|Wearable/}],I=[{name:"Blink",regex:/Chrome\/([\d.]+)/},{name:"WebKit",regex:/AppleWebKit\/([\d.]+)/},{name:"Gecko",regex:/Gecko\/([\d.]+)/},{name:"Trident",regex:/Trident\/([\d.]+)/},{name:"EdgeHTML",regex:/EdgeHTML\/([\d.]+)/}];function R(e){const t=e||("undefined"!=typeof navigator?navigator.userAgent:""),n={browser:{name:null,version:null,majorVersion:null},os:{name:null,version:null,majorVersion:null},device:{type:"Unknown",model:null,vendor:null},engine:{name:null,version:null},originalUA:t};for(const{name:e,regex:r}of N){const o=t.match(r);if(o){const t=o[1];n.browser={name:e,version:t,majorVersion:t?.split(".")[0]??null};break}}for(const{name:e,regex:r,versionReplace:o}of T){const i=t.match(r);if(i){let t=i[1]||null;t&&o&&(t=t.replace(o,".")),n.os={name:e,version:t,majorVersion:t?.split(".")[0]??null};break}}for(const{name:e,regex:r}of I){const o=t.match(r);if(o){n.engine={name:e,version:o[1]||null};break}}for(const{type:e,regex:r}of P)if(r.test(t)){n.device.type=e,/iPhone/.test(t)?n.device.model="iPhone":/iPad/.test(t)?n.device.model="iPad":/Android/.test(t)&&(n.device.model="Android Device");break}return"Unknown"===n.device.type&&(n.device.type="Desktop"),n}const M=globalThis.Math;class U{constructor(e=0,t=2,n="half-up"){this._precision=t,this._rounding=n,this._value=e}set(e){return this._value=this._round(e),this}value(){return this._round(this._value)}setPrecision(e){return this._precision=e,this}setRounding(e){return this._rounding=e,this}clone(e){return new U(e??this._value,this._precision,this._rounding)}_round(e){if(!isFinite(e))return e;if(M.abs(e)>=1e15){const t=e.toExponential(),[n,r]=t.split("e"),o=Number(Number(n).toFixed(this._precision));return Number(`${o}e${r}`)}const t=10**this._precision;switch(this._rounding){case"up":return M.ceil(e*t)/t;case"down":return M.floor(e*t)/t;default:return M.round(e*t)/t}}add(e){return this._value=this._value+e,this}subtract(e){return this._value=this._value-e,this}multiply(e){return this._value=this._value*e,this}divide(e){if(0===e)throw new Error("Division by zero is not allowed.");return this._value=this._value/e,this}abs(){return this._value=M.abs(this._value),this}sqrt(){if(this._value<0)throw new Error("Square root of negative numbers is not supported.");return this._value=M.sqrt(this._value),this}cbrt(){return this._value=M.cbrt(this._value),this}pow(e){return 1!==this._value||isFinite(e)?this._value=M.pow(this._value,e):this._value=1,this}floor(){return this._value=M.floor(this._value),this}ceil(){return this._value=M.ceil(this._value),this}round(){return this._value=M.round(this._value),this}sign(){return this._value=M.sign(this._value),this}degToRad(){return this._value=this._value*M.PI/180,this}radToDeg(){return this._value=180*this._value/M.PI,this}max(...e){return this._value=M.max(this._value,...e),this}min(...e){return this._value=M.min(this._value,...e),this}sin(){return this._value=M.sin(this._value),this}cos(){return this._value=M.cos(this._value),this}tan(){return this._value=M.tan(this._value),this}asin(){return this._value=M.asin(this._value),this}acos(){return this._value=M.acos(this._value),this}atan(){return this._value=M.atan(this._value),this}log(){return this._value=M.log(this._value),this}log10(){return this._value=M.log10(this._value),this}exp(){return this._value=M.exp(this._value),this}toExponential(e){return void 0===e?this._value.toExponential():this._value.toExponential(e)}}class D{constructor(){this.plugins=new Map,this.internalRuleNames=new Set,this.listeners=[],this.plugins=new Map,this.internalRuleNames=new Set,this.listeners=[]}static getInstance(){return D.instance||(D.instance=new D),D.instance}subscribe(e){return this.listeners.push(e),()=>{this.listeners=this.listeners.filter((t=>t!==e))}}notify(){for(const e of this.listeners)e(this.getAll())}register(e,t=!1){(Array.isArray(e)?e:[e]).forEach((e=>{if(this.plugins.has(e.name))throw new Error(`Rule '${e.name}' is already registered.`);if(t)this.internalRuleNames.add(e.name),Object.defineProperty(e,"_internal",{value:!0,writable:!1,enumerable:!1,configurable:!1});else if(this.internalRuleNames.has(e.name))throw new Error(`Rule name '${e.name}' is reserved and cannot be overridden.`);this.plugins.set(e.name,e)})),this.notify()}get(e){if(this.plugins.has(e))return this.plugins.get(e)}getAll(){return Object.fromEntries(this.plugins)}isInternal(e){return this.internalRuleNames.has(e)}reset(){this.plugins.clear(),this.internalRuleNames.clear(),this.listeners=[],this.notify()}}D.instance=null;const k=D.getInstance();class F{constructor(e){this.input="",this.result=!0,this.isNegated=!1,this.input=e}use(e){let t=!1;if(e instanceof RegExp)t=e.test(this.input);else{const n=k.get(e);if(!n)throw new Error(`Unknown rule: '${e}'`);t=n.validate({input:this.input,name:n.name,pattern:n.pattern})}return this.result=this.isNegated?!t:t,this.isNegated=!1,this}not(){return this.isNegated=!0,this}isValid(){return this.result}}class B{constructor(e){this.input=e}use(e){if(e instanceof RegExp)this.pattern=e;else{const t=k.get(e);if(!t)throw new Error(`Unknown rule: '${e}'`);this.pattern=t.pattern}return this}with(e){if(!this.pattern)throw new Error("No pattern defined. Call .use() first.");return this.input=this.input.replace(this.pattern,e),this}result(){return this.input}}function L(e){return k.register(e,!0),e}const W={email:L({name:"email",pattern:/\w[-\w.+]*@([A-Za-z0-9][-A-Za-z0-9]+\.)+[A-Za-z]{2,14}/i,validate:e=>e.pattern.test(e.input)}),mobile:L({name:"mobile",pattern:/^1[3|4|5|6|7|8|9][0-9]{9}$/,validate:e=>e.pattern.test(e.input)}),alpha:L({name:"alpha",pattern:/^[a-zA-Z]+$/,validate:e=>e.pattern.test(e.input)}),chinese:L({name:"chinese",pattern:/^\p{Script=Han}+$/u,validate:e=>e.pattern.test(e.input)}),ipv6:L({name:"ipv6",pattern:/^(?:[a-fA-F0-9]{1,4}:){7}[a-fA-F0-9]{1,4}$|^(?:[a-fA-F0-9]{1,4}:){1,7}:$|^(?:[a-fA-F0-9]{1,4}:){1,6}:[a-fA-F0-9]{1,4}$|^(?:[a-fA-F0-9]{1,4}:){1,5}(?::[a-fA-F0-9]{1,4}){1,2}$|^(?:[a-fA-F0-9]{1,4}:){1,4}(?::[a-fA-F0-9]{1,4}){1,3}$|^(?:[a-fA-F0-9]{1,4}:){1,3}(?::[a-fA-F0-9]{1,4}){1,4}$|^(?:[a-fA-F0-9]{1,4}:){1,2}(?::[a-fA-F0-9]{1,4}){1,5}$|^[a-fA-F0-9]{1,4}:(?:(?::[a-fA-F0-9]{1,4}){1,6})$|^:(?:(?::[a-fA-F0-9]{1,4}){1,7}|:)$/,validate:e=>e.pattern.test(e.input)}),postal:L({name:"postal",pattern:/\d{6}/,validate:e=>e.pattern.test(e.input)}),username:L({name:"username",pattern:/^[a-zA-Z][a-zA-Z0-9_]{4,15}$/,validate:e=>e.pattern.test(e.input)}),ipv4:L({name:"ipv4",pattern:/^(25[0-5]|2[0-4]\d|1\d{2}|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d{2}|[1-9]?\d)){3}$/,validate:e=>e.pattern.test(e.input)}),IDCard:L({name:"IDCard",pattern:/(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/,validate:e=>e.pattern.test(e.input)}),url:L({name:"url",pattern:/^((https|http|ftp|rtsp|mms)?:\/\/)[^\s]+/,validate:e=>e.pattern.test(e.input)}),qq:L({name:"qq",pattern:/^[1-9][0-9]{4,9}$/,validate:e=>e.pattern.test(e.input)}),landline:L({name:"landline",pattern:/^0\d{2,3}-?\d{7,8}$/,validate:e=>e.pattern.test(e.input)}),number:L({name:"number",pattern:/^[0-9]$/,validate:e=>e.pattern.test(e.input)}),nonAscii:L({name:"nonAscii",pattern:/[^\x00-\xff]/,validate:e=>e.pattern.test(e.input)}),nonLatin:L({name:"nonLatin",pattern:/[^\u0000-\u024F]/,validate:e=>e.pattern.test(e.input)}),password:L({name:"password",pattern:/(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/,validate:e=>e.pattern.test(e.input)}),html:L({name:"html",pattern:/<("[^"]*"|'[^']*'|[^'">])*>/,validate:e=>e.pattern.test(e.input)})};class V{constructor(){for(const e in W)this[e]=W[e]}static getInstance(){return V.instance||(V.instance=new V),V.instance}checker(e){return new F(e)}replacer(e){return new B(e)}definePlugin(e){if(k.isInternal(e.name))throw new Error(`Cannot register plugin with reserved name: '${e.name}'`);return k.register(e),e}}V.instance=null;const z=V.getInstance();function q(e){return e.replace(/[_\-\s]+/g," ").trim().split(/\s+/).flatMap((e=>e.match(/[A-Z]{2,}(?=[A-Z][a-z]|[0-9]|$)|[A-Z]?[a-z]+|[A-Z]+|[0-9]+/g)||[]))}exports.MathX=U,exports.ObjectId=E,exports.VERSION="1.2.1",exports.at=function(e,t){const n=e.length;if(0!==n)return t<0&&(t=n+t),e[t]},exports.awaitTo=function(e){var t;return(null!==(t=e)&&"object"==typeof t&&"function"==typeof t.then?e:Promise.resolve(e)).then((e=>[null,e])).catch((e=>[e,void 0]))},exports.base64ToBlob=C,exports.base64ToFormData=function(e,t){const{blob:n,ext:r}=C(e),o=t?.key||"file";let i=t?.filename;i?i.includes(".")||(i+=`.${r}`):i=`${Date.now()}.${r}`;const s=new FormData;return s.append(o,n,i),s},exports.capitalizeFirstLetter=function(e){return e?e.charAt(0).toUpperCase()+e.slice(1):""},exports.clone=function(e){return j(e)},exports.cloneDeep=function e(t,n=new WeakMap){return $(t,n,e)},exports.cloneDeepWith=function(e,t,n=new WeakMap){const r=(e,o=n)=>{const i=t(e);return void 0!==i?i:$(e,o,r,t)};return r(e)},exports.cloneWith=function(e,t){return j(e,t)},exports.count=function(e,t){return(e.match(new RegExp(t,"g"))||[]).length},exports.currying=function(e){const{fn:t,done:n}=e;return function e(r=[]){const o=(...o)=>{const i=[...r,...o];return n&&n(i)?t(...i):e(i)};return o.map=t=>e(r.map(t)),o.filter=t=>e(r.filter(t)),o.value=()=>t(...r),o.valueOf=()=>o.value(),o.toString=()=>String(o.value()),o}()},exports.debounce=function(e,t=500){let n=null,r=null,o=null,i=null,s=null;const a=()=>{if(r)try{const t=e.apply(o,r);return i?.(t),u(),t}catch(e){throw s?.(e),u(),e}},u=()=>{n=null,r=null,o=null,i=null,s=null};function c(...e){return n&&clearTimeout(n),r=e,o=this,new Promise(((e,r)=>{i=e,s=r,n=setTimeout((()=>{a()}),t)}))}return c.cancel=function(){n&&clearTimeout(n),s?.("Debounced call canceled"),u()},c.flush=function(){return n&&clearTimeout(n),Promise.resolve(a())},c.pending=function(){return!!n},c},exports.debounceSync=function(e,t=500){let n=null,r=null,o=null;const i=()=>{n=null,r=null,o=null},s=()=>{if(r)try{const t=e.apply(o,r);return i(),t}catch(e){throw i(),e}};function a(...e){n&&clearTimeout(n),r=e,o=this,n=setTimeout((()=>{s()}),t)}return a.cancel=()=>{n&&clearTimeout(n),i()},a.flush=()=>(n&&clearTimeout(n),s()),a.pending=()=>!!n,a},exports.findIndex=function(e,t){return e.indexOf(t)},exports.generateVerificationCode=function(e=4,t){if(e<=0)return"";const n=/[0Ool1]/g;let r=t?.charset||"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";if(!1!==t?.excludeConfusing&&(r=r.replace(n,"")),!r)throw new Error("Character set is empty after removing confusing characters.");return Array.from({length:e},(()=>{const e=Math.floor(Math.random()*r.length);return r.charAt(e)})).join("")},exports.getBrowserType=function(){const e=R();if(!e.browser.name||!e.browser.version)return null;const t=e.browser.name.toLowerCase(),n=parseInt(e.browser.majorVersion||"0");switch(t){case"internet explorer":return n>=7&&n<=10?`IE${n}`:11===n?"IE11":null;case"edge (chromium)":case"edge (legacy)":return"Edge";case"firefox":return"FireFox";case"opera":return"Opera";case"chrome":return"Chrome";case"safari":return"Safari";default:return null}},exports.getUA=function(e){return void 0!==e?e:"undefined"!=typeof navigator&&"string"==typeof navigator.userAgent?navigator.userAgent:""},exports.hasOwn=A,exports.includes=function(t,n,r=0){return e(t)?t.slice(r).includes(n):p(t)?-1!==t.indexOf(String(n),r):f(t)||m(t)?t.has(n):!!l(t)&&Object.values(t).includes(n)},exports.insertAfter=function(e,t,n){const r="number"==typeof n?n:e.indexOf(n);return r<0||r>=e.length?e:e.slice(0,r+1)+t+e.slice(r+1)},exports.insertBefore=function(e,t,n){const r="number"==typeof n?n:e.indexOf(n);return r<0||r>e.length?e:e.slice(0,r)+t+e.slice(r)},exports.intersect=function(e,t){return e.filter((e=>t.includes(e)))},exports.isArray=e,exports.isArrayBuffer=t,exports.isBigInt=s,exports.isBlob=function(e){return"undefined"!=typeof Blob&&e instanceof Blob},exports.isBoolean=n,exports.isBuffer=function(e){return"undefined"!=typeof Buffer&&"function"==typeof Buffer.isBuffer&&Buffer.isBuffer(e)},exports.isCommentNode=function(e){return"undefined"!=typeof Node&&e instanceof Node&&e.nodeType===Node.COMMENT_NODE},exports.isDataView=r,exports.isDate=o,exports.isDocument=function(e){return"undefined"!=typeof Document&&e instanceof Document},exports.isDocumentFragment=function(e){return"undefined"!=typeof Node&&e instanceof Node&&e.nodeType===Node.DOCUMENT_FRAGMENT_NODE},exports.isElement=function(e){return"object"==typeof e&&null!==e&&"number"==typeof e.nodeType&&1===e.nodeType&&"string"==typeof e.nodeName&&"undefined"!=typeof Element&&e instanceof Element},exports.isEmpty=function(t){return null==t||(p(t)?0===t.trim().length:i(t)?0===t||a(t):e(t)?0===t.length:l(t)?0===Object.keys(t).length:!!o(t)&&a(t.getTime()))},exports.isEqual=b,exports.isFloat=function(e){return i(e)&&e%1!=0},exports.isFunction=v,exports.isInt=function(e){return i(e)&&e%1==0},exports.isMap=f,exports.isNaN=a,exports.isNil=function(e){return null==e},exports.isNode=function(e){return"undefined"!=typeof Node&&e instanceof Node},exports.isNodeJS=function(){return"undefined"!=typeof process&&!!process.versions?.node},exports.isNull=w,exports.isNumber=i,exports.isObject=u,exports.isObjectLike=c,exports.isPlainObject=l,exports.isPrimitive=O,exports.isPromise=function(e){return e&&"function"==typeof e.then},exports.isRegExp=d,exports.isSet=m,exports.isString=p,exports.isSymbol=x,exports.isTextNode=function(e){return"undefined"!=typeof Node&&e instanceof Node&&e.nodeType===Node.TEXT_NODE},exports.isTypedArray=y,exports.isUndefined=function(e){return"[object Undefined]"===Object.prototype.toString.call(e)},exports.isWeakMap=h,exports.isWeakSet=g,exports.isWindow=function(e){return"undefined"!=typeof window&&e===window},exports.keys=S,exports.lowercaseFirstLetter=function(e){return e?e.charAt(0).toLowerCase()+e.slice(1):""},exports.merge=function(e,t){const n={...e};return S(t).forEach((e=>{const r=Object.getOwnPropertyDescriptor(t,e);r&&Object.defineProperty(n,e,r)})),n},exports.mergeDeep=function t(n,r){if(e(n)&&e(r)){const e=Math.max(n.length,r.length),o=[];for(let i=0;i<e;i++){const e=n[i],s=r[i];O(e)||O(s)?o[i]=void 0!==s?s:e:o[i]=t(e,s)}return o}if(l(n)&&l(r)){const e={...n};return S(r).forEach((o=>{const i=n[o],s=r[o];O(i)||O(s)?e[o]=s:e[o]=t(i,s)})),e}return r},exports.noop=function(){},exports.omit=function(e,t){const n={};return S(e).forEach((r=>{t.includes(r)||(n[r]=e[r])})),n},exports.omitBy=function(e,t){const n={};return S(e).forEach((r=>{t(e[r],r)||(n[r]=e[r])})),n},exports.padEnd=function(e,t,n=" "){return e.padEnd(t,n)},exports.padStart=function(e,t,n=" "){return e.padStart(t,n)},exports.parseQuery=e=>"object"!=typeof e||null==e?"":Object.keys(e).map((t=>{const n=e[t];return null==n?"":`${encodeURIComponent(t)}=${encodeURIComponent(n)}`})).filter(Boolean).join("&"),exports.parseQueryDeep=e=>{const t=(e,n)=>null==e?[]:"object"!=typeof e||Array.isArray(e)?Array.isArray(e)?e.flatMap((e=>t(e,`${n}[]`))):[`${n}=${encodeURIComponent(String(e))}`]:Object.keys(e).flatMap((r=>t(e[r],`${n}[${encodeURIComponent(r)}]`)));return"object"!=typeof e||null==e?"":Object.keys(e).flatMap((n=>t(e[n],encodeURIComponent(n)))).join("&")},exports.parseQueryDeepWith=(e,t)=>{const n=(e,r)=>{if(null==e)return[];if("object"==typeof e&&!Array.isArray(e))return Object.keys(e).flatMap((t=>n(e[t],[...r,t])));if(Array.isArray(e))return e.flatMap(((e,t)=>n(e,[...r,String(t)])));return[`${t(r.map(encodeURIComponent))}=${encodeURIComponent(String(e))}`]};return"object"!=typeof e||null==e?"":Object.keys(e).flatMap((t=>n(e[t],[t]))).join("&")},exports.parseQueryWith=(e,t)=>"object"!=typeof e||null==e?"":Object.entries(e).map((([e,n])=>t(e,n))).filter((e=>"string"==typeof e)).join("&"),exports.parseUA=R,exports.pick=function(e,t){const n={};for(const r of t)r in e&&(n[r]=e[r]);return n},exports.pickBy=function(e,t){const n={};for(const r in e)t(e[r],r)&&(n[r]=e[r]);return n},exports.randomFloat=function(e=0,t=1){return Math.random()*(t-e)+e},exports.randomInt=function(e=0,t=1){return Math.floor(Math.random()*(t-e))+e},exports.regex=z,exports.remove=function(e,t){return e.filter((e=>!t.includes(e)))},exports.removeAfter=function(e,t){const n="number"==typeof t?t:e.indexOf(t);return n>=0?e.slice(0,n+1):e},exports.removeAt=function(e,t){const n="number"==typeof t?t:e.indexOf(t);return n<0||n>=e.length?e:e.slice(0,n)+e.slice(n+1)},exports.removeBefore=function(e,t){const n="number"==typeof t?t:e.indexOf(t);return n>=0?e.slice(n):e},exports.repeat=function(e,t){return e.repeat(t)},exports.replaceAll=function(e,t,n){return e.split(t).join(n)},exports.reverse=function(e){return e.split("").reverse().join("")},exports.substring=function(e,t,n){return e.substring(t,n)},exports.throttle=function(e,t=500){let n=null,r=null,o=null,i=null,s=null;const a=()=>{n=Date.now();const t=e.apply(i,o);return s?.(t),u(),t},u=()=>{r=null,o=null,i=null,s=null};function c(...e){const u=Date.now(),c=n?t-(u-n):0;return o=e,i=this,new Promise((e=>{s=e,c<=0?a():r||(r=setTimeout(a,c))}))}return c.cancel=()=>{r&&clearTimeout(r),u()},c.flush=()=>r?(clearTimeout(r),Promise.resolve(a())):Promise.resolve(void 0),c.pending=()=>Boolean(r),c},exports.throttleSync=function(e,t=500){let n=null,r=null,o=null,i=null;const s=()=>{n=Date.now(),e.apply(i,o),a()},a=()=>{r=null,o=null,i=null};function u(...e){const a=Date.now(),u=n?t-(a-n):0;o=e,i=this,u<=0?s():r||(r=setTimeout(s,u))}return u.cancel=()=>{r&&clearTimeout(r),a()},u.flush=()=>{r&&(clearTimeout(r),s())},u.pending=()=>Boolean(r),u},exports.toCamelCase=function(e){if(!e)return"";const[t,...n]=q(e);return[t.toLowerCase(),...n.map((e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()))].join("")},exports.toKebabCase=function(e){return q(e).map((e=>e.toLowerCase())).join("-")},exports.toLowerAt=function(e,t){const n="number"==typeof t?t:e.indexOf(t);return n<0||n>=e.length?e:e.slice(0,n)+e[n].toLowerCase()+e.slice(n+1)},exports.toLowerCase=function(e){return e.toString().toLowerCase()},exports.toPascalCase=function(e){return q(e).map((e=>/^[A-Z0-9]+$/.test(e)?e:e.charAt(0).toUpperCase()+e.slice(1).toLowerCase())).join("")},exports.toSnakeCase=function(e){return q(e).map((e=>e.toLowerCase())).join("_")},exports.toTitleCase=function(e){return e.toLowerCase().replace(/[_\-]+/g," ").replace(/\b([a-z])([a-z]*)/g,((e,t,n)=>t.toUpperCase()+n))},exports.toUpperAt=function(e,t){const n="number"==typeof t?t:e.indexOf(t);return n<0||n>=e.length?e:e.slice(0,n)+e[n].toUpperCase()+e.slice(n+1)},exports.toUpperCase=function(e){return e.toString().toUpperCase()},exports.trim=function(e){return e.toString().replace(/^\s+|\s+$/g,"")},exports.trimEnd=function(e){return e.toString().replace(/\s+$/g,"")},exports.trimStart=function(e){return e.toString().replace(/^\s+/g,"")},exports.typeOf=function(e){return null===e?"null":Array.isArray(e)?"array":typeof e},exports.union=function(e,t){return[...new Set([...e,...t])]},exports.unique=function(e){return[...new Set(e)]},exports.urlParse=function(e){const[t,n]=e.split("#"),[r,o]=t.split("?");let i="",s="",a="/";const u=r.match(/^([a-zA-Z]+:)?\/\//);if(u){i=u[1]||"";const e=r.slice(i.length+2),t=e.indexOf("/");t>=0?(s=e.slice(0,t),a=e.slice(t)||"/"):(s=e,a="/")}else a=r||"/";let c=s,l="";const p=s.indexOf(":");p>=0&&(c=s.slice(0,p),l=s.slice(p+1));const f=i+"//"+s,h={};if(o){const e=o.split("&");for(const t of e){if(!t)continue;const[e,n]=t.split("="),r=decodeURIComponent(e||"").trim();if(!r)continue;const o=void 0!==n?decodeURIComponent(n).trim():"";let i;i=/^\d+(\.\d+)?$/.test(o)?Number(o):"true"===o||"false"!==o&&o,h.hasOwnProperty(r)?Array.isArray(h[r])?h[r].push(i):h[r]=[h[r],i]:h[r]=i}}return{host:s,hostname:c,pathname:a,port:l,protocol:i,origin:f,href:e,search:o?`?${o}`:"",hash:n?`#${decodeURIComponent(n)}`:"",query:h}},exports.urlStringify=function(e){const{protocol:t="",hostname:n,port:r="",pathname:o="/",query:i={},hash:s=""}=e,a=t?t.endsWith(":")?t:`${t}:`:"",u=r?`${n}:${r}`:n,c=o.startsWith("/")?o:`/${o}`,l=Object.entries(i).flatMap((([e,t])=>{if(!e||null==t)return[];const n=e=>encodeURIComponent(String(e));return Array.isArray(t)?t.map((t=>`${encodeURIComponent(e)}=${n(t)}`)):`${encodeURIComponent(e)}=${n(t)}`})).join("&");return`${a}//${u}${c}${l?`?${l}`:""}${s?s.startsWith("#")?s:`#${s}`:""}`},exports.values=function(e,t){return O(e)?[]:("undefined"!=typeof Reflect&&"function"==typeof Reflect.ownKeys?Reflect.ownKeys(e):[...Object.getOwnPropertyNames?Object.getOwnPropertyNames(e):[],...Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(e):[]]).filter((n=>{const r=Object.getOwnPropertyDescriptor(e,n);return!!r&&(v(t)?t(n,r):r.enumerable)})).map((t=>e[t]))},exports.words=q; //# sourceMappingURL=index.cjs.js.map